@rc-component/trigger 2.2.5 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/mock.js CHANGED
@@ -1,19 +1,16 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
1
  import * as React from 'react';
3
2
  import { generateTrigger } from "./index";
4
- var MockPortal = function MockPortal(_ref) {
5
- var open = _ref.open,
6
- autoDestroy = _ref.autoDestroy,
7
- children = _ref.children,
8
- getContainer = _ref.getContainer;
9
- var _React$useState = React.useState(open),
10
- _React$useState2 = _slicedToArray(_React$useState, 2),
11
- visible = _React$useState2[0],
12
- setVisible = _React$useState2[1];
13
- React.useEffect(function () {
14
- getContainer === null || getContainer === void 0 || getContainer();
3
+ const MockPortal = ({
4
+ open,
5
+ autoDestroy,
6
+ children,
7
+ getContainer
8
+ }) => {
9
+ const [visible, setVisible] = React.useState(open);
10
+ React.useEffect(() => {
11
+ getContainer?.();
15
12
  });
16
- React.useEffect(function () {
13
+ React.useEffect(() => {
17
14
  if (open) {
18
15
  setVisible(true);
19
16
  } else if (autoDestroy) {
package/es/util.d.ts CHANGED
@@ -1,8 +1,5 @@
1
- import type { CSSMotionProps } from 'rc-motion';
2
- import type { AlignType, AnimationType, BuildInPlacements, TransitionNameType } from './interface';
1
+ import type { AlignType, BuildInPlacements } from './interface';
3
2
  export declare function getAlignPopupClassName(builtinPlacements: BuildInPlacements, prefixCls: string, align: AlignType, isAlignPoint: boolean): string;
4
- /** @deprecated We should not use this if we can refactor all deps */
5
- export declare function getMotion(prefixCls: string, motion: CSSMotionProps, animation: AnimationType, transitionName: TransitionNameType): CSSMotionProps;
6
3
  export declare function getWin(ele: HTMLElement): Window & typeof globalThis;
7
4
  /**
8
5
  * Get all the scrollable parent elements of the element
package/es/util.js CHANGED
@@ -1,43 +1,22 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- function isPointsEq() {
3
- var a1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
4
- var a2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
5
- var isAlignPoint = arguments.length > 2 ? arguments[2] : undefined;
1
+ function isPointsEq(a1 = [], a2 = [], isAlignPoint) {
6
2
  if (isAlignPoint) {
7
3
  return a1[0] === a2[0];
8
4
  }
9
5
  return a1[0] === a2[0] && a1[1] === a2[1];
10
6
  }
11
7
  export function getAlignPopupClassName(builtinPlacements, prefixCls, align, isAlignPoint) {
12
- var points = align.points;
13
- var placements = Object.keys(builtinPlacements);
14
- for (var i = 0; i < placements.length; i += 1) {
15
- var _builtinPlacements$pl;
16
- var placement = placements[i];
17
- if (isPointsEq((_builtinPlacements$pl = builtinPlacements[placement]) === null || _builtinPlacements$pl === void 0 ? void 0 : _builtinPlacements$pl.points, points, isAlignPoint)) {
18
- return "".concat(prefixCls, "-placement-").concat(placement);
8
+ const {
9
+ points
10
+ } = align;
11
+ const placements = Object.keys(builtinPlacements);
12
+ for (let i = 0; i < placements.length; i += 1) {
13
+ const placement = placements[i];
14
+ if (isPointsEq(builtinPlacements[placement]?.points, points, isAlignPoint)) {
15
+ return `${prefixCls}-placement-${placement}`;
19
16
  }
20
17
  }
21
18
  return '';
22
19
  }
23
-
24
- /** @deprecated We should not use this if we can refactor all deps */
25
- export function getMotion(prefixCls, motion, animation, transitionName) {
26
- if (motion) {
27
- return motion;
28
- }
29
- if (animation) {
30
- return {
31
- motionName: "".concat(prefixCls, "-").concat(animation)
32
- };
33
- }
34
- if (transitionName) {
35
- return {
36
- motionName: transitionName
37
- };
38
- }
39
- return null;
40
- }
41
20
  export function getWin(ele) {
42
21
  return ele.ownerDocument.defaultView;
43
22
  }
@@ -48,25 +27,23 @@ export function getWin(ele) {
48
27
  * @param areaOnly Only return the parent which will cut visible area
49
28
  */
50
29
  export function collectScroller(ele) {
51
- var scrollerList = [];
52
- var current = ele === null || ele === void 0 ? void 0 : ele.parentElement;
53
- var scrollStyle = ['hidden', 'scroll', 'clip', 'auto'];
30
+ const scrollerList = [];
31
+ let current = ele?.parentElement;
32
+ const scrollStyle = ['hidden', 'scroll', 'clip', 'auto'];
54
33
  while (current) {
55
- var _getWin$getComputedSt = getWin(current).getComputedStyle(current),
56
- overflowX = _getWin$getComputedSt.overflowX,
57
- overflowY = _getWin$getComputedSt.overflowY,
58
- overflow = _getWin$getComputedSt.overflow;
59
- if ([overflowX, overflowY, overflow].some(function (o) {
60
- return scrollStyle.includes(o);
61
- })) {
34
+ const {
35
+ overflowX,
36
+ overflowY,
37
+ overflow
38
+ } = getWin(current).getComputedStyle(current);
39
+ if ([overflowX, overflowY, overflow].some(o => scrollStyle.includes(o))) {
62
40
  scrollerList.push(current);
63
41
  }
64
42
  current = current.parentElement;
65
43
  }
66
44
  return scrollerList;
67
45
  }
68
- export function toNum(num) {
69
- var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
46
+ export function toNum(num, defaultValue = 1) {
70
47
  return Number.isNaN(num) ? defaultValue : num;
71
48
  }
72
49
  function getPxValue(val) {
@@ -95,56 +72,61 @@ function getPxValue(val) {
95
72
  * Get visible area of element
96
73
  */
97
74
  export function getVisibleArea(initArea, scrollerList) {
98
- var visibleArea = _objectSpread({}, initArea);
99
- (scrollerList || []).forEach(function (ele) {
75
+ const visibleArea = {
76
+ ...initArea
77
+ };
78
+ (scrollerList || []).forEach(ele => {
100
79
  if (ele instanceof HTMLBodyElement || ele instanceof HTMLHtmlElement) {
101
80
  return;
102
81
  }
103
82
 
104
83
  // Skip if static position which will not affect visible area
105
- var _getWin$getComputedSt2 = getWin(ele).getComputedStyle(ele),
106
- overflow = _getWin$getComputedSt2.overflow,
107
- overflowClipMargin = _getWin$getComputedSt2.overflowClipMargin,
108
- borderTopWidth = _getWin$getComputedSt2.borderTopWidth,
109
- borderBottomWidth = _getWin$getComputedSt2.borderBottomWidth,
110
- borderLeftWidth = _getWin$getComputedSt2.borderLeftWidth,
111
- borderRightWidth = _getWin$getComputedSt2.borderRightWidth;
112
- var eleRect = ele.getBoundingClientRect();
113
- var eleOutHeight = ele.offsetHeight,
114
- eleInnerHeight = ele.clientHeight,
115
- eleOutWidth = ele.offsetWidth,
116
- eleInnerWidth = ele.clientWidth;
117
- var borderTopNum = getPxValue(borderTopWidth);
118
- var borderBottomNum = getPxValue(borderBottomWidth);
119
- var borderLeftNum = getPxValue(borderLeftWidth);
120
- var borderRightNum = getPxValue(borderRightWidth);
121
- var scaleX = toNum(Math.round(eleRect.width / eleOutWidth * 1000) / 1000);
122
- var scaleY = toNum(Math.round(eleRect.height / eleOutHeight * 1000) / 1000);
84
+ const {
85
+ overflow,
86
+ overflowClipMargin,
87
+ borderTopWidth,
88
+ borderBottomWidth,
89
+ borderLeftWidth,
90
+ borderRightWidth
91
+ } = getWin(ele).getComputedStyle(ele);
92
+ const eleRect = ele.getBoundingClientRect();
93
+ const {
94
+ offsetHeight: eleOutHeight,
95
+ clientHeight: eleInnerHeight,
96
+ offsetWidth: eleOutWidth,
97
+ clientWidth: eleInnerWidth
98
+ } = ele;
99
+ const borderTopNum = getPxValue(borderTopWidth);
100
+ const borderBottomNum = getPxValue(borderBottomWidth);
101
+ const borderLeftNum = getPxValue(borderLeftWidth);
102
+ const borderRightNum = getPxValue(borderRightWidth);
103
+ const scaleX = toNum(Math.round(eleRect.width / eleOutWidth * 1000) / 1000);
104
+ const scaleY = toNum(Math.round(eleRect.height / eleOutHeight * 1000) / 1000);
123
105
 
124
106
  // Original visible area
125
- var eleScrollWidth = (eleOutWidth - eleInnerWidth - borderLeftNum - borderRightNum) * scaleX;
126
- var eleScrollHeight = (eleOutHeight - eleInnerHeight - borderTopNum - borderBottomNum) * scaleY;
107
+ const eleScrollWidth = (eleOutWidth - eleInnerWidth - borderLeftNum - borderRightNum) * scaleX;
108
+ const eleScrollHeight = (eleOutHeight - eleInnerHeight - borderTopNum - borderBottomNum) * scaleY;
127
109
 
128
110
  // Cut border size
129
- var scaledBorderTopWidth = borderTopNum * scaleY;
130
- var scaledBorderBottomWidth = borderBottomNum * scaleY;
131
- var scaledBorderLeftWidth = borderLeftNum * scaleX;
132
- var scaledBorderRightWidth = borderRightNum * scaleX;
111
+ const scaledBorderTopWidth = borderTopNum * scaleY;
112
+ const scaledBorderBottomWidth = borderBottomNum * scaleY;
113
+ const scaledBorderLeftWidth = borderLeftNum * scaleX;
114
+ const scaledBorderRightWidth = borderRightNum * scaleX;
133
115
 
134
116
  // Clip margin
135
- var clipMarginWidth = 0;
136
- var clipMarginHeight = 0;
117
+ let clipMarginWidth = 0;
118
+ let clipMarginHeight = 0;
137
119
  if (overflow === 'clip') {
138
- var clipNum = getPxValue(overflowClipMargin);
120
+ const clipNum = getPxValue(overflowClipMargin);
139
121
  clipMarginWidth = clipNum * scaleX;
140
122
  clipMarginHeight = clipNum * scaleY;
141
123
  }
142
124
 
143
125
  // Region
144
- var eleLeft = eleRect.x + scaledBorderLeftWidth - clipMarginWidth;
145
- var eleTop = eleRect.y + scaledBorderTopWidth - clipMarginHeight;
146
- var eleRight = eleLeft + eleRect.width + 2 * clipMarginWidth - scaledBorderLeftWidth - scaledBorderRightWidth - eleScrollWidth;
147
- var eleBottom = eleTop + eleRect.height + 2 * clipMarginHeight - scaledBorderTopWidth - scaledBorderBottomWidth - eleScrollHeight;
126
+ const eleLeft = eleRect.x + scaledBorderLeftWidth - clipMarginWidth;
127
+ const eleTop = eleRect.y + scaledBorderTopWidth - clipMarginHeight;
128
+ const eleRight = eleLeft + eleRect.width + 2 * clipMarginWidth - scaledBorderLeftWidth - scaledBorderRightWidth - eleScrollWidth;
129
+ const eleBottom = eleTop + eleRect.height + 2 * clipMarginHeight - scaledBorderTopWidth - scaledBorderBottomWidth - eleScrollHeight;
148
130
  visibleArea.left = Math.max(visibleArea.left, eleLeft);
149
131
  visibleArea.top = Math.max(visibleArea.top, eleTop);
150
132
  visibleArea.right = Math.min(visibleArea.right, eleRight);
@@ -1,43 +1,47 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.default = Arrow;
9
7
  var _classnames = _interopRequireDefault(require("classnames"));
10
8
  var React = _interopRequireWildcard(require("react"));
9
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
12
  function Arrow(props) {
12
- var prefixCls = props.prefixCls,
13
- align = props.align,
14
- arrow = props.arrow,
15
- arrowPos = props.arrowPos;
16
- var _ref = arrow || {},
17
- className = _ref.className,
18
- content = _ref.content;
19
- var _arrowPos$x = arrowPos.x,
20
- x = _arrowPos$x === void 0 ? 0 : _arrowPos$x,
21
- _arrowPos$y = arrowPos.y,
22
- y = _arrowPos$y === void 0 ? 0 : _arrowPos$y;
23
- var arrowRef = React.useRef();
13
+ const {
14
+ prefixCls,
15
+ align,
16
+ arrow,
17
+ arrowPos
18
+ } = props;
19
+ const {
20
+ className,
21
+ content
22
+ } = arrow || {};
23
+ const {
24
+ x = 0,
25
+ y = 0
26
+ } = arrowPos;
27
+ const arrowRef = React.useRef();
24
28
 
25
29
  // Skip if no align
26
30
  if (!align || !align.points) {
27
31
  return null;
28
32
  }
29
- var alignStyle = {
33
+ const alignStyle = {
30
34
  position: 'absolute'
31
35
  };
32
36
 
33
37
  // Skip if no need to align
34
38
  if (align.autoArrow !== false) {
35
- var popupPoints = align.points[0];
36
- var targetPoints = align.points[1];
37
- var popupTB = popupPoints[0];
38
- var popupLR = popupPoints[1];
39
- var targetTB = targetPoints[0];
40
- var targetLR = targetPoints[1];
39
+ const popupPoints = align.points[0];
40
+ const targetPoints = align.points[1];
41
+ const popupTB = popupPoints[0];
42
+ const popupLR = popupPoints[1];
43
+ const targetTB = targetPoints[0];
44
+ const targetLR = targetPoints[1];
41
45
 
42
46
  // Top & Bottom
43
47
  if (popupTB === targetTB || !['t', 'b'].includes(popupTB)) {
@@ -59,7 +63,7 @@ function Arrow(props) {
59
63
  }
60
64
  return /*#__PURE__*/React.createElement("div", {
61
65
  ref: arrowRef,
62
- className: (0, _classnames.default)("".concat(prefixCls, "-arrow"), className),
66
+ className: (0, _classnames.default)(`${prefixCls}-arrow`, className),
63
67
  style: alignStyle
64
68
  }, content);
65
69
  }
@@ -1,4 +1,4 @@
1
- import type { CSSMotionProps } from 'rc-motion';
1
+ import type { CSSMotionProps } from '@rc-component/motion';
2
2
  import * as React from 'react';
3
3
  export interface MaskProps {
4
4
  prefixCls: string;
package/lib/Popup/Mask.js CHANGED
@@ -1,35 +1,37 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.default = Mask;
9
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
7
  var _classnames = _interopRequireDefault(require("classnames"));
11
- var _rcMotion = _interopRequireDefault(require("rc-motion"));
8
+ var _motion = _interopRequireDefault(require("@rc-component/motion"));
12
9
  var React = _interopRequireWildcard(require("react"));
10
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
13
14
  function Mask(props) {
14
- var prefixCls = props.prefixCls,
15
- open = props.open,
16
- zIndex = props.zIndex,
17
- mask = props.mask,
18
- motion = props.motion;
15
+ const {
16
+ prefixCls,
17
+ open,
18
+ zIndex,
19
+ mask,
20
+ motion
21
+ } = props;
19
22
  if (!mask) {
20
23
  return null;
21
24
  }
22
- return /*#__PURE__*/React.createElement(_rcMotion.default, (0, _extends2.default)({}, motion, {
25
+ return /*#__PURE__*/React.createElement(_motion.default, _extends({}, motion, {
23
26
  motionAppear: true,
24
27
  visible: open,
25
28
  removeOnLeave: true
26
- }), function (_ref) {
27
- var className = _ref.className;
28
- return /*#__PURE__*/React.createElement("div", {
29
- style: {
30
- zIndex: zIndex
31
- },
32
- className: (0, _classnames.default)("".concat(prefixCls, "-mask"), className)
33
- });
34
- });
29
+ }), ({
30
+ className
31
+ }) => /*#__PURE__*/React.createElement("div", {
32
+ style: {
33
+ zIndex
34
+ },
35
+ className: (0, _classnames.default)(`${prefixCls}-mask`, className)
36
+ }));
35
37
  }
@@ -1,17 +1,15 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = void 0;
8
7
  var React = _interopRequireWildcard(require("react"));
9
- var PopupContent = /*#__PURE__*/React.memo(function (_ref) {
10
- var children = _ref.children;
11
- return children;
12
- }, function (_, next) {
13
- return next.cache;
14
- });
8
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
+ const PopupContent = /*#__PURE__*/React.memo(({
11
+ children
12
+ }) => children, (_, next) => next.cache);
15
13
  if (process.env.NODE_ENV !== 'production') {
16
14
  PopupContent.displayName = 'PopupContent';
17
15
  }
@@ -1,4 +1,4 @@
1
- import type { CSSMotionProps } from 'rc-motion';
1
+ import type { CSSMotionProps } from '@rc-component/motion';
2
2
  import * as React from 'react';
3
3
  import type { TriggerProps } from '../';
4
4
  import type { AlignType, ArrowPos, ArrowTypeOuter } from '../interface';
@@ -1,73 +1,77 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.default = void 0;
9
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
7
  var _classnames = _interopRequireDefault(require("classnames"));
13
- var _rcMotion = _interopRequireDefault(require("rc-motion"));
14
- var _rcResizeObserver = _interopRequireDefault(require("rc-resize-observer"));
15
- var _useLayoutEffect = _interopRequireDefault(require("rc-util/lib/hooks/useLayoutEffect"));
16
- var _ref2 = require("rc-util/lib/ref");
8
+ var _motion = _interopRequireDefault(require("@rc-component/motion"));
9
+ var _resizeObserver = _interopRequireDefault(require("@rc-component/resize-observer"));
10
+ var _useLayoutEffect = _interopRequireDefault(require("@rc-component/util/lib/hooks/useLayoutEffect"));
11
+ var _ref = require("@rc-component/util/lib/ref");
17
12
  var React = _interopRequireWildcard(require("react"));
18
13
  var _Arrow = _interopRequireDefault(require("./Arrow"));
19
14
  var _Mask = _interopRequireDefault(require("./Mask"));
20
15
  var _PopupContent = _interopRequireDefault(require("./PopupContent"));
21
- var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
22
- var popup = props.popup,
23
- className = props.className,
24
- prefixCls = props.prefixCls,
25
- style = props.style,
26
- target = props.target,
27
- _onVisibleChanged = props.onVisibleChanged,
28
- open = props.open,
29
- keepDom = props.keepDom,
30
- fresh = props.fresh,
31
- onClick = props.onClick,
32
- mask = props.mask,
33
- arrow = props.arrow,
34
- arrowPos = props.arrowPos,
35
- align = props.align,
36
- motion = props.motion,
37
- maskMotion = props.maskMotion,
38
- forceRender = props.forceRender,
39
- getPopupContainer = props.getPopupContainer,
40
- autoDestroy = props.autoDestroy,
41
- Portal = props.portal,
42
- zIndex = props.zIndex,
43
- onMouseEnter = props.onMouseEnter,
44
- onMouseLeave = props.onMouseLeave,
45
- onPointerEnter = props.onPointerEnter,
46
- onPointerDownCapture = props.onPointerDownCapture,
47
- ready = props.ready,
48
- offsetX = props.offsetX,
49
- offsetY = props.offsetY,
50
- offsetR = props.offsetR,
51
- offsetB = props.offsetB,
52
- onAlign = props.onAlign,
53
- onPrepare = props.onPrepare,
54
- stretch = props.stretch,
55
- targetWidth = props.targetWidth,
56
- targetHeight = props.targetHeight;
57
- var childNode = typeof popup === 'function' ? popup() : popup;
16
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
20
+ const Popup = /*#__PURE__*/React.forwardRef((props, ref) => {
21
+ const {
22
+ popup,
23
+ className,
24
+ prefixCls,
25
+ style,
26
+ target,
27
+ onVisibleChanged,
28
+ // Open
29
+ open,
30
+ keepDom,
31
+ fresh,
32
+ // Click
33
+ onClick,
34
+ // Mask
35
+ mask,
36
+ // Arrow
37
+ arrow,
38
+ arrowPos,
39
+ align,
40
+ // Motion
41
+ motion,
42
+ maskMotion,
43
+ // Portal
44
+ forceRender,
45
+ getPopupContainer,
46
+ autoDestroy,
47
+ portal: Portal,
48
+ zIndex,
49
+ onMouseEnter,
50
+ onMouseLeave,
51
+ onPointerEnter,
52
+ onPointerDownCapture,
53
+ ready,
54
+ offsetX,
55
+ offsetY,
56
+ offsetR,
57
+ offsetB,
58
+ onAlign,
59
+ onPrepare,
60
+ stretch,
61
+ targetWidth,
62
+ targetHeight
63
+ } = props;
64
+ const childNode = typeof popup === 'function' ? popup() : popup;
58
65
 
59
66
  // We can not remove holder only when motion finished.
60
- var isNodeVisible = open || keepDom;
67
+ const isNodeVisible = open || keepDom;
61
68
 
62
69
  // ======================= Container ========================
63
- var getPopupContainerNeedParams = (getPopupContainer === null || getPopupContainer === void 0 ? void 0 : getPopupContainer.length) > 0;
64
- var _React$useState = React.useState(!getPopupContainer || !getPopupContainerNeedParams),
65
- _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
66
- show = _React$useState2[0],
67
- setShow = _React$useState2[1];
70
+ const getPopupContainerNeedParams = getPopupContainer?.length > 0;
71
+ const [show, setShow] = React.useState(!getPopupContainer || !getPopupContainerNeedParams);
68
72
 
69
73
  // Delay to show since `getPopupContainer` need target element
70
- (0, _useLayoutEffect.default)(function () {
74
+ (0, _useLayoutEffect.default)(() => {
71
75
  if (!show && getPopupContainerNeedParams && target) {
72
76
  setShow(true);
73
77
  }
@@ -79,8 +83,8 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
79
83
  }
80
84
 
81
85
  // >>>>> Offset
82
- var AUTO = 'auto';
83
- var offsetStyle = {
86
+ const AUTO = 'auto';
87
+ const offsetStyle = {
84
88
  left: '-1000vw',
85
89
  top: '-1000vh',
86
90
  right: AUTO,
@@ -89,11 +93,12 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
89
93
 
90
94
  // Set align style
91
95
  if (ready || !open) {
92
- var _experimental;
93
- var points = align.points;
94
- var dynamicInset = align.dynamicInset || ((_experimental = align._experimental) === null || _experimental === void 0 ? void 0 : _experimental.dynamicInset);
95
- var alignRight = dynamicInset && points[0][1] === 'r';
96
- var alignBottom = dynamicInset && points[0][0] === 'b';
96
+ const {
97
+ points
98
+ } = align;
99
+ const dynamicInset = align.dynamicInset || align._experimental?.dynamicInset;
100
+ const alignRight = dynamicInset && points[0][1] === 'r';
101
+ const alignBottom = dynamicInset && points[0][0] === 'b';
97
102
  if (alignRight) {
98
103
  offsetStyle.right = offsetR;
99
104
  offsetStyle.left = AUTO;
@@ -111,7 +116,7 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
111
116
  }
112
117
 
113
118
  // >>>>> Misc
114
- var miscStyle = {};
119
+ const miscStyle = {};
115
120
  if (stretch) {
116
121
  if (stretch.includes('height') && targetHeight) {
117
122
  miscStyle.height = targetHeight;
@@ -129,9 +134,7 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
129
134
  }
130
135
  return /*#__PURE__*/React.createElement(Portal, {
131
136
  open: forceRender || isNodeVisible,
132
- getContainer: getPopupContainer && function () {
133
- return getPopupContainer(target);
134
- },
137
+ getContainer: getPopupContainer && (() => getPopupContainer(target)),
135
138
  autoDestroy: autoDestroy
136
139
  }, /*#__PURE__*/React.createElement(_Mask.default, {
137
140
  prefixCls: prefixCls,
@@ -139,40 +142,43 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
139
142
  zIndex: zIndex,
140
143
  mask: mask,
141
144
  motion: maskMotion
142
- }), /*#__PURE__*/React.createElement(_rcResizeObserver.default, {
145
+ }), /*#__PURE__*/React.createElement(_resizeObserver.default, {
143
146
  onResize: onAlign,
144
147
  disabled: !open
145
- }, function (resizeObserverRef) {
146
- return /*#__PURE__*/React.createElement(_rcMotion.default, (0, _extends2.default)({
148
+ }, resizeObserverRef => {
149
+ return /*#__PURE__*/React.createElement(_motion.default, _extends({
147
150
  motionAppear: true,
148
151
  motionEnter: true,
149
152
  motionLeave: true,
150
153
  removeOnLeave: false,
151
154
  forceRender: forceRender,
152
- leavedClassName: "".concat(prefixCls, "-hidden")
155
+ leavedClassName: `${prefixCls}-hidden`
153
156
  }, motion, {
154
157
  onAppearPrepare: onPrepare,
155
158
  onEnterPrepare: onPrepare,
156
159
  visible: open,
157
- onVisibleChanged: function onVisibleChanged(nextVisible) {
158
- var _motion$onVisibleChan;
159
- motion === null || motion === void 0 || (_motion$onVisibleChan = motion.onVisibleChanged) === null || _motion$onVisibleChan === void 0 || _motion$onVisibleChan.call(motion, nextVisible);
160
- _onVisibleChanged(nextVisible);
160
+ onVisibleChanged: nextVisible => {
161
+ motion?.onVisibleChanged?.(nextVisible);
162
+ onVisibleChanged(nextVisible);
161
163
  }
162
- }), function (_ref, motionRef) {
163
- var motionClassName = _ref.className,
164
- motionStyle = _ref.style;
165
- var cls = (0, _classnames.default)(prefixCls, motionClassName, className);
164
+ }), ({
165
+ className: motionClassName,
166
+ style: motionStyle
167
+ }, motionRef) => {
168
+ const cls = (0, _classnames.default)(prefixCls, motionClassName, className);
166
169
  return /*#__PURE__*/React.createElement("div", {
167
- ref: (0, _ref2.composeRef)(resizeObserverRef, ref, motionRef),
170
+ ref: (0, _ref.composeRef)(resizeObserverRef, ref, motionRef),
168
171
  className: cls,
169
- style: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({
170
- '--arrow-x': "".concat(arrowPos.x || 0, "px"),
171
- '--arrow-y': "".concat(arrowPos.y || 0, "px")
172
- }, offsetStyle), miscStyle), motionStyle), {}, {
172
+ style: {
173
+ '--arrow-x': `${arrowPos.x || 0}px`,
174
+ '--arrow-y': `${arrowPos.y || 0}px`,
175
+ ...offsetStyle,
176
+ ...miscStyle,
177
+ ...motionStyle,
173
178
  boxSizing: 'border-box',
174
- zIndex: zIndex
175
- }, style),
179
+ zIndex,
180
+ ...style
181
+ },
176
182
  onMouseEnter: onMouseEnter,
177
183
  onMouseLeave: onMouseLeave,
178
184
  onPointerEnter: onPointerEnter,