first commit
This commit is contained in:
9
frontend/node_modules/@rc-component/trigger/es/Popup/Arrow.d.ts
generated
vendored
Normal file
9
frontend/node_modules/@rc-component/trigger/es/Popup/Arrow.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import * as React from 'react';
|
||||
import type { AlignType, ArrowPos, ArrowTypeOuter } from '../interface';
|
||||
export interface ArrowProps {
|
||||
prefixCls: string;
|
||||
align: AlignType;
|
||||
arrow: ArrowTypeOuter;
|
||||
arrowPos: ArrowPos;
|
||||
}
|
||||
export default function Arrow(props: ArrowProps): React.JSX.Element;
|
||||
57
frontend/node_modules/@rc-component/trigger/es/Popup/Arrow.js
generated
vendored
Normal file
57
frontend/node_modules/@rc-component/trigger/es/Popup/Arrow.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
import classNames from 'classnames';
|
||||
import * as React from 'react';
|
||||
export default function Arrow(props) {
|
||||
var prefixCls = props.prefixCls,
|
||||
align = props.align,
|
||||
arrow = props.arrow,
|
||||
arrowPos = props.arrowPos;
|
||||
var _ref = arrow || {},
|
||||
className = _ref.className,
|
||||
content = _ref.content;
|
||||
var _arrowPos$x = arrowPos.x,
|
||||
x = _arrowPos$x === void 0 ? 0 : _arrowPos$x,
|
||||
_arrowPos$y = arrowPos.y,
|
||||
y = _arrowPos$y === void 0 ? 0 : _arrowPos$y;
|
||||
var arrowRef = React.useRef();
|
||||
|
||||
// Skip if no align
|
||||
if (!align || !align.points) {
|
||||
return null;
|
||||
}
|
||||
var alignStyle = {
|
||||
position: 'absolute'
|
||||
};
|
||||
|
||||
// Skip if no need to align
|
||||
if (align.autoArrow !== false) {
|
||||
var popupPoints = align.points[0];
|
||||
var targetPoints = align.points[1];
|
||||
var popupTB = popupPoints[0];
|
||||
var popupLR = popupPoints[1];
|
||||
var targetTB = targetPoints[0];
|
||||
var targetLR = targetPoints[1];
|
||||
|
||||
// Top & Bottom
|
||||
if (popupTB === targetTB || !['t', 'b'].includes(popupTB)) {
|
||||
alignStyle.top = y;
|
||||
} else if (popupTB === 't') {
|
||||
alignStyle.top = 0;
|
||||
} else {
|
||||
alignStyle.bottom = 0;
|
||||
}
|
||||
|
||||
// Left & Right
|
||||
if (popupLR === targetLR || !['l', 'r'].includes(popupLR)) {
|
||||
alignStyle.left = x;
|
||||
} else if (popupLR === 'l') {
|
||||
alignStyle.left = 0;
|
||||
} else {
|
||||
alignStyle.right = 0;
|
||||
}
|
||||
}
|
||||
return /*#__PURE__*/React.createElement("div", {
|
||||
ref: arrowRef,
|
||||
className: classNames("".concat(prefixCls, "-arrow"), className),
|
||||
style: alignStyle
|
||||
}, content);
|
||||
}
|
||||
10
frontend/node_modules/@rc-component/trigger/es/Popup/Mask.d.ts
generated
vendored
Normal file
10
frontend/node_modules/@rc-component/trigger/es/Popup/Mask.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { CSSMotionProps } from 'rc-motion';
|
||||
import * as React from 'react';
|
||||
export interface MaskProps {
|
||||
prefixCls: string;
|
||||
open?: boolean;
|
||||
zIndex?: number;
|
||||
mask?: boolean;
|
||||
motion?: CSSMotionProps;
|
||||
}
|
||||
export default function Mask(props: MaskProps): React.JSX.Element;
|
||||
27
frontend/node_modules/@rc-component/trigger/es/Popup/Mask.js
generated
vendored
Normal file
27
frontend/node_modules/@rc-component/trigger/es/Popup/Mask.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import classNames from 'classnames';
|
||||
import CSSMotion from 'rc-motion';
|
||||
import * as React from 'react';
|
||||
export default function Mask(props) {
|
||||
var prefixCls = props.prefixCls,
|
||||
open = props.open,
|
||||
zIndex = props.zIndex,
|
||||
mask = props.mask,
|
||||
motion = props.motion;
|
||||
if (!mask) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(CSSMotion, _extends({}, motion, {
|
||||
motionAppear: true,
|
||||
visible: open,
|
||||
removeOnLeave: true
|
||||
}), function (_ref) {
|
||||
var className = _ref.className;
|
||||
return /*#__PURE__*/React.createElement("div", {
|
||||
style: {
|
||||
zIndex: zIndex
|
||||
},
|
||||
className: classNames("".concat(prefixCls, "-mask"), className)
|
||||
});
|
||||
});
|
||||
}
|
||||
7
frontend/node_modules/@rc-component/trigger/es/Popup/PopupContent.d.ts
generated
vendored
Normal file
7
frontend/node_modules/@rc-component/trigger/es/Popup/PopupContent.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import * as React from 'react';
|
||||
export interface PopupContentProps {
|
||||
children?: React.ReactNode;
|
||||
cache?: boolean;
|
||||
}
|
||||
declare const PopupContent: React.MemoExoticComponent<({ children }: PopupContentProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>>;
|
||||
export default PopupContent;
|
||||
11
frontend/node_modules/@rc-component/trigger/es/Popup/PopupContent.js
generated
vendored
Normal file
11
frontend/node_modules/@rc-component/trigger/es/Popup/PopupContent.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import * as React from 'react';
|
||||
var PopupContent = /*#__PURE__*/React.memo(function (_ref) {
|
||||
var children = _ref.children;
|
||||
return children;
|
||||
}, function (_, next) {
|
||||
return next.cache;
|
||||
});
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
PopupContent.displayName = 'PopupContent';
|
||||
}
|
||||
export default PopupContent;
|
||||
44
frontend/node_modules/@rc-component/trigger/es/Popup/index.d.ts
generated
vendored
Normal file
44
frontend/node_modules/@rc-component/trigger/es/Popup/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
import type { CSSMotionProps } from 'rc-motion';
|
||||
import * as React from 'react';
|
||||
import type { TriggerProps } from '../';
|
||||
import type { AlignType, ArrowPos, ArrowTypeOuter } from '../interface';
|
||||
export interface PopupProps {
|
||||
prefixCls: string;
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
popup?: TriggerProps['popup'];
|
||||
target: HTMLElement;
|
||||
onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
|
||||
onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
|
||||
onPointerEnter?: React.MouseEventHandler<HTMLDivElement>;
|
||||
onPointerDownCapture?: React.MouseEventHandler<HTMLDivElement>;
|
||||
zIndex?: number;
|
||||
mask?: boolean;
|
||||
onVisibleChanged: (visible: boolean) => void;
|
||||
align?: AlignType;
|
||||
arrow?: ArrowTypeOuter;
|
||||
arrowPos: ArrowPos;
|
||||
open: boolean;
|
||||
/** Tell Portal that should keep in screen. e.g. should wait all motion end */
|
||||
keepDom: boolean;
|
||||
fresh?: boolean;
|
||||
onClick?: React.MouseEventHandler<HTMLDivElement>;
|
||||
motion?: CSSMotionProps;
|
||||
maskMotion?: CSSMotionProps;
|
||||
forceRender?: boolean;
|
||||
getPopupContainer?: TriggerProps['getPopupContainer'];
|
||||
autoDestroy?: boolean;
|
||||
portal: React.ComponentType<any>;
|
||||
ready: boolean;
|
||||
offsetX: number;
|
||||
offsetY: number;
|
||||
offsetR: number;
|
||||
offsetB: number;
|
||||
onAlign: VoidFunction;
|
||||
onPrepare: () => Promise<void>;
|
||||
stretch?: string;
|
||||
targetWidth?: number;
|
||||
targetHeight?: number;
|
||||
}
|
||||
declare const Popup: React.ForwardRefExoticComponent<PopupProps & React.RefAttributes<HTMLDivElement>>;
|
||||
export default Popup;
|
||||
187
frontend/node_modules/@rc-component/trigger/es/Popup/index.js
generated
vendored
Normal file
187
frontend/node_modules/@rc-component/trigger/es/Popup/index.js
generated
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import classNames from 'classnames';
|
||||
import CSSMotion from 'rc-motion';
|
||||
import ResizeObserver from 'rc-resize-observer';
|
||||
import useLayoutEffect from "rc-util/es/hooks/useLayoutEffect";
|
||||
import { composeRef } from "rc-util/es/ref";
|
||||
import * as React from 'react';
|
||||
import Arrow from "./Arrow";
|
||||
import Mask from "./Mask";
|
||||
import PopupContent from "./PopupContent";
|
||||
var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
||||
var popup = props.popup,
|
||||
className = props.className,
|
||||
prefixCls = props.prefixCls,
|
||||
style = props.style,
|
||||
target = props.target,
|
||||
_onVisibleChanged = props.onVisibleChanged,
|
||||
open = props.open,
|
||||
keepDom = props.keepDom,
|
||||
fresh = props.fresh,
|
||||
onClick = props.onClick,
|
||||
mask = props.mask,
|
||||
arrow = props.arrow,
|
||||
arrowPos = props.arrowPos,
|
||||
align = props.align,
|
||||
motion = props.motion,
|
||||
maskMotion = props.maskMotion,
|
||||
forceRender = props.forceRender,
|
||||
getPopupContainer = props.getPopupContainer,
|
||||
autoDestroy = props.autoDestroy,
|
||||
Portal = props.portal,
|
||||
zIndex = props.zIndex,
|
||||
onMouseEnter = props.onMouseEnter,
|
||||
onMouseLeave = props.onMouseLeave,
|
||||
onPointerEnter = props.onPointerEnter,
|
||||
onPointerDownCapture = props.onPointerDownCapture,
|
||||
ready = props.ready,
|
||||
offsetX = props.offsetX,
|
||||
offsetY = props.offsetY,
|
||||
offsetR = props.offsetR,
|
||||
offsetB = props.offsetB,
|
||||
onAlign = props.onAlign,
|
||||
onPrepare = props.onPrepare,
|
||||
stretch = props.stretch,
|
||||
targetWidth = props.targetWidth,
|
||||
targetHeight = props.targetHeight;
|
||||
var childNode = typeof popup === 'function' ? popup() : popup;
|
||||
|
||||
// We can not remove holder only when motion finished.
|
||||
var isNodeVisible = open || keepDom;
|
||||
|
||||
// ======================= Container ========================
|
||||
var getPopupContainerNeedParams = (getPopupContainer === null || getPopupContainer === void 0 ? void 0 : getPopupContainer.length) > 0;
|
||||
var _React$useState = React.useState(!getPopupContainer || !getPopupContainerNeedParams),
|
||||
_React$useState2 = _slicedToArray(_React$useState, 2),
|
||||
show = _React$useState2[0],
|
||||
setShow = _React$useState2[1];
|
||||
|
||||
// Delay to show since `getPopupContainer` need target element
|
||||
useLayoutEffect(function () {
|
||||
if (!show && getPopupContainerNeedParams && target) {
|
||||
setShow(true);
|
||||
}
|
||||
}, [show, getPopupContainerNeedParams, target]);
|
||||
|
||||
// ========================= Render =========================
|
||||
if (!show) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// >>>>> Offset
|
||||
var AUTO = 'auto';
|
||||
var offsetStyle = {
|
||||
left: '-1000vw',
|
||||
top: '-1000vh',
|
||||
right: AUTO,
|
||||
bottom: AUTO
|
||||
};
|
||||
|
||||
// Set align style
|
||||
if (ready || !open) {
|
||||
var _experimental;
|
||||
var points = align.points;
|
||||
var dynamicInset = align.dynamicInset || ((_experimental = align._experimental) === null || _experimental === void 0 ? void 0 : _experimental.dynamicInset);
|
||||
var alignRight = dynamicInset && points[0][1] === 'r';
|
||||
var alignBottom = dynamicInset && points[0][0] === 'b';
|
||||
if (alignRight) {
|
||||
offsetStyle.right = offsetR;
|
||||
offsetStyle.left = AUTO;
|
||||
} else {
|
||||
offsetStyle.left = offsetX;
|
||||
offsetStyle.right = AUTO;
|
||||
}
|
||||
if (alignBottom) {
|
||||
offsetStyle.bottom = offsetB;
|
||||
offsetStyle.top = AUTO;
|
||||
} else {
|
||||
offsetStyle.top = offsetY;
|
||||
offsetStyle.bottom = AUTO;
|
||||
}
|
||||
}
|
||||
|
||||
// >>>>> Misc
|
||||
var miscStyle = {};
|
||||
if (stretch) {
|
||||
if (stretch.includes('height') && targetHeight) {
|
||||
miscStyle.height = targetHeight;
|
||||
} else if (stretch.includes('minHeight') && targetHeight) {
|
||||
miscStyle.minHeight = targetHeight;
|
||||
}
|
||||
if (stretch.includes('width') && targetWidth) {
|
||||
miscStyle.width = targetWidth;
|
||||
} else if (stretch.includes('minWidth') && targetWidth) {
|
||||
miscStyle.minWidth = targetWidth;
|
||||
}
|
||||
}
|
||||
if (!open) {
|
||||
miscStyle.pointerEvents = 'none';
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(Portal, {
|
||||
open: forceRender || isNodeVisible,
|
||||
getContainer: getPopupContainer && function () {
|
||||
return getPopupContainer(target);
|
||||
},
|
||||
autoDestroy: autoDestroy
|
||||
}, /*#__PURE__*/React.createElement(Mask, {
|
||||
prefixCls: prefixCls,
|
||||
open: open,
|
||||
zIndex: zIndex,
|
||||
mask: mask,
|
||||
motion: maskMotion
|
||||
}), /*#__PURE__*/React.createElement(ResizeObserver, {
|
||||
onResize: onAlign,
|
||||
disabled: !open
|
||||
}, function (resizeObserverRef) {
|
||||
return /*#__PURE__*/React.createElement(CSSMotion, _extends({
|
||||
motionAppear: true,
|
||||
motionEnter: true,
|
||||
motionLeave: true,
|
||||
removeOnLeave: false,
|
||||
forceRender: forceRender,
|
||||
leavedClassName: "".concat(prefixCls, "-hidden")
|
||||
}, motion, {
|
||||
onAppearPrepare: onPrepare,
|
||||
onEnterPrepare: onPrepare,
|
||||
visible: open,
|
||||
onVisibleChanged: function onVisibleChanged(nextVisible) {
|
||||
var _motion$onVisibleChan;
|
||||
motion === null || motion === void 0 || (_motion$onVisibleChan = motion.onVisibleChanged) === null || _motion$onVisibleChan === void 0 || _motion$onVisibleChan.call(motion, nextVisible);
|
||||
_onVisibleChanged(nextVisible);
|
||||
}
|
||||
}), function (_ref, motionRef) {
|
||||
var motionClassName = _ref.className,
|
||||
motionStyle = _ref.style;
|
||||
var cls = classNames(prefixCls, motionClassName, className);
|
||||
return /*#__PURE__*/React.createElement("div", {
|
||||
ref: composeRef(resizeObserverRef, ref, motionRef),
|
||||
className: cls,
|
||||
style: _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
||||
'--arrow-x': "".concat(arrowPos.x || 0, "px"),
|
||||
'--arrow-y': "".concat(arrowPos.y || 0, "px")
|
||||
}, offsetStyle), miscStyle), motionStyle), {}, {
|
||||
boxSizing: 'border-box',
|
||||
zIndex: zIndex
|
||||
}, style),
|
||||
onMouseEnter: onMouseEnter,
|
||||
onMouseLeave: onMouseLeave,
|
||||
onPointerEnter: onPointerEnter,
|
||||
onClick: onClick,
|
||||
onPointerDownCapture: onPointerDownCapture
|
||||
}, arrow && /*#__PURE__*/React.createElement(Arrow, {
|
||||
prefixCls: prefixCls,
|
||||
arrow: arrow,
|
||||
arrowPos: arrowPos,
|
||||
align: align
|
||||
}), /*#__PURE__*/React.createElement(PopupContent, {
|
||||
cache: !open && !fresh
|
||||
}, childNode));
|
||||
});
|
||||
}));
|
||||
});
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Popup.displayName = 'Popup';
|
||||
}
|
||||
export default Popup;
|
||||
Reference in New Issue
Block a user