@rc-component/trigger 1.17.2 → 1.18.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/Popup/index.js CHANGED
@@ -147,7 +147,7 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
147
147
  visible: open,
148
148
  onVisibleChanged: function onVisibleChanged(nextVisible) {
149
149
  var _motion$onVisibleChan;
150
- motion === null || motion === void 0 ? void 0 : (_motion$onVisibleChan = motion.onVisibleChanged) === null || _motion$onVisibleChan === void 0 ? void 0 : _motion$onVisibleChan.call(motion, nextVisible);
150
+ motion === null || motion === void 0 || (_motion$onVisibleChan = motion.onVisibleChanged) === null || _motion$onVisibleChan === void 0 || _motion$onVisibleChan.call(motion, nextVisible);
151
151
  _onVisibleChanged(nextVisible);
152
152
  }
153
153
  }), function (_ref, motionRef) {
@@ -124,7 +124,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
124
124
 
125
125
  // placeholder element
126
126
  var placeholderElement = doc.createElement('div');
127
- (_popupElement$parentE = popupElement.parentElement) === null || _popupElement$parentE === void 0 ? void 0 : _popupElement$parentE.appendChild(placeholderElement);
127
+ (_popupElement$parentE = popupElement.parentElement) === null || _popupElement$parentE === void 0 || _popupElement$parentE.appendChild(placeholderElement);
128
128
  placeholderElement.style.left = "".concat(popupElement.offsetLeft, "px");
129
129
  placeholderElement.style.top = "".concat(popupElement.offsetTop, "px");
130
130
  placeholderElement.style.position = popupPosition;
@@ -208,7 +208,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
208
208
  popupElement.style.top = originTop;
209
209
  popupElement.style.right = originRight;
210
210
  popupElement.style.bottom = originBottom;
211
- (_popupElement$parentE2 = popupElement.parentElement) === null || _popupElement$parentE2 === void 0 ? void 0 : _popupElement$parentE2.removeChild(placeholderElement);
211
+ (_popupElement$parentE2 = popupElement.parentElement) === null || _popupElement$parentE2 === void 0 || _popupElement$parentE2.removeChild(placeholderElement);
212
212
 
213
213
  // Calculate scale
214
214
  var _scaleX = toNum(Math.round(popupWidth / parseFloat(width) * 1000) / 1000);
@@ -465,7 +465,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
465
465
  var minBottom = Math.min(popupBottom, targetBottom);
466
466
  var yCenter = (maxTop + minBottom) / 2;
467
467
  var nextArrowY = yCenter - popupTop;
468
- onPopupAlign === null || onPopupAlign === void 0 ? void 0 : onPopupAlign(popupEle, nextAlignInfo);
468
+ onPopupAlign === null || onPopupAlign === void 0 || onPopupAlign(popupEle, nextAlignInfo);
469
469
 
470
470
  // Additional calculate right & bottom position
471
471
  var offsetX4Right = popupMirrorRect.right - popupRect.x - (nextOffsetX + popupRect.width);
@@ -68,7 +68,7 @@ export default function useWinClick(open, clickToHide, targetEle, popupEle, mask
68
68
  // Warning if target and popup not in same root
69
69
  if (process.env.NODE_ENV !== 'production') {
70
70
  var _targetEle$getRootNod, _popupEle$getRootNode;
71
- var targetRoot = targetEle === null || targetEle === void 0 ? void 0 : (_targetEle$getRootNod = targetEle.getRootNode) === null || _targetEle$getRootNod === void 0 ? void 0 : _targetEle$getRootNod.call(targetEle);
71
+ var targetRoot = targetEle === null || targetEle === void 0 || (_targetEle$getRootNod = targetEle.getRootNode) === null || _targetEle$getRootNod === void 0 ? void 0 : _targetEle$getRootNod.call(targetEle);
72
72
  var popupRoot = (_popupEle$getRootNode = popupEle.getRootNode) === null || _popupEle$getRootNode === void 0 ? void 0 : _popupEle$getRootNode.call(popupEle);
73
73
  warning(targetRoot === popupRoot, "trigger element and popup element should in same shadow root.");
74
74
  }
package/es/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import type { CSSMotionProps } from 'rc-motion';
2
2
  import * as React from 'react';
3
3
  import type { ActionType, AlignType, AnimationType, ArrowTypeOuter, BuildInPlacements, TransitionNameType } from './interface';
4
- export type { BuildInPlacements, AlignType, ActionType, ArrowTypeOuter as ArrowType, };
4
+ export type { ActionType, AlignType, ArrowTypeOuter as ArrowType, BuildInPlacements, };
5
5
  export interface TriggerRef {
6
+ nativeElement: HTMLElement;
6
7
  forceAlign: VoidFunction;
7
8
  }
8
9
  export interface TriggerProps {
package/es/index.js CHANGED
@@ -13,13 +13,13 @@ import useLayoutEffect from "rc-util/es/hooks/useLayoutEffect";
13
13
  import isMobile from "rc-util/es/isMobile";
14
14
  import * as React from 'react';
15
15
  import { flushSync } from 'react-dom';
16
+ import Popup from "./Popup";
17
+ import TriggerWrapper from "./TriggerWrapper";
16
18
  import TriggerContext from "./context";
17
19
  import useAction from "./hooks/useAction";
18
20
  import useAlign from "./hooks/useAlign";
19
21
  import useWatch from "./hooks/useWatch";
20
22
  import useWinClick from "./hooks/useWinClick";
21
- import Popup from "./Popup";
22
- import TriggerWrapper from "./TriggerWrapper";
23
23
  import { getAlignPopupClassName, getMotion } from "./util";
24
24
 
25
25
  // Removed Props List
@@ -94,7 +94,7 @@ export function generateTrigger() {
94
94
  return {
95
95
  registerSubPopup: function registerSubPopup(id, subPopupEle) {
96
96
  subPopupElements.current[id] = subPopupEle;
97
- parentContext === null || parentContext === void 0 ? void 0 : parentContext.registerSubPopup(id, subPopupEle);
97
+ parentContext === null || parentContext === void 0 || parentContext.registerSubPopup(id, subPopupEle);
98
98
  }
99
99
  };
100
100
  }, [parentContext]);
@@ -109,7 +109,7 @@ export function generateTrigger() {
109
109
  if (isDOM(node) && popupEle !== node) {
110
110
  setPopupEle(node);
111
111
  }
112
- parentContext === null || parentContext === void 0 ? void 0 : parentContext.registerSubPopup(id, node);
112
+ parentContext === null || parentContext === void 0 || parentContext.registerSubPopup(id, node);
113
113
  });
114
114
 
115
115
  // =========================== Target ===========================
@@ -118,9 +118,13 @@ export function generateTrigger() {
118
118
  _React$useState6 = _slicedToArray(_React$useState5, 2),
119
119
  targetEle = _React$useState6[0],
120
120
  setTargetEle = _React$useState6[1];
121
+
122
+ // Used for forwardRef target. Not use internal
123
+ var externalForwardRef = React.useRef(null);
121
124
  var setTargetRef = useEvent(function (node) {
122
125
  if (isDOM(node) && targetEle !== node) {
123
126
  setTargetEle(node);
127
+ externalForwardRef.current = node;
124
128
  }
125
129
  });
126
130
 
@@ -166,7 +170,7 @@ export function generateTrigger() {
166
170
  flushSync(function () {
167
171
  if (mergedOpen !== nextOpen) {
168
172
  setMergedOpen(nextOpen);
169
- onPopupVisibleChange === null || onPopupVisibleChange === void 0 ? void 0 : onPopupVisibleChange(nextOpen);
173
+ onPopupVisibleChange === null || onPopupVisibleChange === void 0 || onPopupVisibleChange(nextOpen);
170
174
  }
171
175
  });
172
176
  });
@@ -258,8 +262,11 @@ export function generateTrigger() {
258
262
  var baseClassName = getAlignPopupClassName(builtinPlacements, prefixCls, alignInfo, alignPoint);
259
263
  return classNames(baseClassName, getPopupClassNameFromAlign === null || getPopupClassNameFromAlign === void 0 ? void 0 : getPopupClassNameFromAlign(alignInfo));
260
264
  }, [alignInfo, getPopupClassNameFromAlign, builtinPlacements, prefixCls, alignPoint]);
265
+
266
+ // ============================ Refs ============================
261
267
  React.useImperativeHandle(ref, function () {
262
268
  return {
269
+ nativeElement: externalForwardRef.current,
263
270
  forceAlign: triggerAlign
264
271
  };
265
272
  });
@@ -289,7 +296,7 @@ export function generateTrigger() {
289
296
  var onVisibleChanged = function onVisibleChanged(visible) {
290
297
  setInMotion(false);
291
298
  onAlign();
292
- afterPopupVisibleChange === null || afterPopupVisibleChange === void 0 ? void 0 : afterPopupVisibleChange(visible);
299
+ afterPopupVisibleChange === null || afterPopupVisibleChange === void 0 || afterPopupVisibleChange(visible);
293
300
  };
294
301
 
295
302
  // We will trigger align when motion is in prepare
@@ -316,14 +323,14 @@ export function generateTrigger() {
316
323
  function wrapperAction(eventName, nextOpen, delay, preEvent) {
317
324
  cloneProps[eventName] = function (event) {
318
325
  var _originChildProps$eve;
319
- preEvent === null || preEvent === void 0 ? void 0 : preEvent(event);
326
+ preEvent === null || preEvent === void 0 || preEvent(event);
320
327
  triggerOpen(nextOpen, delay);
321
328
 
322
329
  // Pass to origin
323
330
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
324
331
  args[_key - 1] = arguments[_key];
325
332
  }
326
- (_originChildProps$eve = originChildProps[eventName]) === null || _originChildProps$eve === void 0 ? void 0 : _originChildProps$eve.call.apply(_originChildProps$eve, [originChildProps, event].concat(args));
333
+ (_originChildProps$eve = originChildProps[eventName]) === null || _originChildProps$eve === void 0 || _originChildProps$eve.call.apply(_originChildProps$eve, [originChildProps, event].concat(args));
327
334
  };
328
335
  }
329
336
 
@@ -342,7 +349,7 @@ export function generateTrigger() {
342
349
  for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
343
350
  args[_key2 - 1] = arguments[_key2];
344
351
  }
345
- (_originChildProps$onC = originChildProps.onClick) === null || _originChildProps$onC === void 0 ? void 0 : _originChildProps$onC.call.apply(_originChildProps$onC, [originChildProps, event].concat(args));
352
+ (_originChildProps$onC = originChildProps.onClick) === null || _originChildProps$onC === void 0 || _originChildProps$onC.call.apply(_originChildProps$onC, [originChildProps, event].concat(args));
346
353
  };
347
354
  }
348
355
 
@@ -374,7 +381,7 @@ export function generateTrigger() {
374
381
  cloneProps.onMouseMove = function (event) {
375
382
  var _originChildProps$onM;
376
383
  // setMousePosByEvent(event);
377
- (_originChildProps$onM = originChildProps.onMouseMove) === null || _originChildProps$onM === void 0 ? void 0 : _originChildProps$onM.call(originChildProps, event);
384
+ (_originChildProps$onM = originChildProps.onMouseMove) === null || _originChildProps$onM === void 0 || _originChildProps$onM.call(originChildProps, event);
378
385
  };
379
386
  }
380
387
  }
@@ -410,7 +417,7 @@ export function generateTrigger() {
410
417
  for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
411
418
  args[_key3 - 1] = arguments[_key3];
412
419
  }
413
- (_originChildProps$onC2 = originChildProps.onContextMenu) === null || _originChildProps$onC2 === void 0 ? void 0 : _originChildProps$onC2.call.apply(_originChildProps$onC2, [originChildProps, event].concat(args));
420
+ (_originChildProps$onC2 = originChildProps.onContextMenu) === null || _originChildProps$onC2 === void 0 || _originChildProps$onC2.call.apply(_originChildProps$onC2, [originChildProps, event].concat(args));
414
421
  };
415
422
  }
416
423
 
@@ -432,7 +439,7 @@ export function generateTrigger() {
432
439
  for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
433
440
  args[_key4] = arguments[_key4];
434
441
  }
435
- (_mergedChildrenProps$ = mergedChildrenProps[eventName]) === null || _mergedChildrenProps$ === void 0 ? void 0 : _mergedChildrenProps$.call.apply(_mergedChildrenProps$, [mergedChildrenProps].concat(args));
442
+ (_mergedChildrenProps$ = mergedChildrenProps[eventName]) === null || _mergedChildrenProps$ === void 0 || _mergedChildrenProps$.call.apply(_mergedChildrenProps$, [mergedChildrenProps].concat(args));
436
443
  restProps[eventName].apply(restProps, args);
437
444
  };
438
445
  }
package/es/mock.js CHANGED
@@ -11,7 +11,7 @@ var MockPortal = function MockPortal(_ref) {
11
11
  visible = _React$useState2[0],
12
12
  setVisible = _React$useState2[1];
13
13
  React.useEffect(function () {
14
- getContainer === null || getContainer === void 0 ? void 0 : getContainer();
14
+ getContainer === null || getContainer === void 0 || getContainer();
15
15
  });
16
16
  React.useEffect(function () {
17
17
  if (open) {
@@ -15,5 +15,4 @@ var PopupContent = /*#__PURE__*/React.memo(function (_ref) {
15
15
  if (process.env.NODE_ENV !== 'production') {
16
16
  PopupContent.displayName = 'PopupContent';
17
17
  }
18
- var _default = PopupContent;
19
- exports.default = _default;
18
+ var _default = exports.default = PopupContent;
@@ -155,7 +155,7 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
155
155
  visible: open,
156
156
  onVisibleChanged: function onVisibleChanged(nextVisible) {
157
157
  var _motion$onVisibleChan;
158
- motion === null || motion === void 0 ? void 0 : (_motion$onVisibleChan = motion.onVisibleChanged) === null || _motion$onVisibleChan === void 0 ? void 0 : _motion$onVisibleChan.call(motion, nextVisible);
158
+ motion === null || motion === void 0 || (_motion$onVisibleChan = motion.onVisibleChanged) === null || _motion$onVisibleChan === void 0 || _motion$onVisibleChan.call(motion, nextVisible);
159
159
  _onVisibleChanged(nextVisible);
160
160
  }
161
161
  }), function (_ref, motionRef) {
@@ -190,5 +190,4 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
190
190
  if (process.env.NODE_ENV !== 'production') {
191
191
  Popup.displayName = 'Popup';
192
192
  }
193
- var _default = Popup;
194
- exports.default = _default;
193
+ var _default = exports.default = Popup;
@@ -24,5 +24,4 @@ var TriggerWrapper = /*#__PURE__*/React.forwardRef(function (props, ref) {
24
24
  if (process.env.NODE_ENV !== 'production') {
25
25
  TriggerWrapper.displayName = 'TriggerWrapper';
26
26
  }
27
- var _default = TriggerWrapper;
28
- exports.default = _default;
27
+ var _default = exports.default = TriggerWrapper;
package/lib/context.js CHANGED
@@ -7,5 +7,4 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var React = _interopRequireWildcard(require("react"));
9
9
  var TriggerContext = /*#__PURE__*/React.createContext(null);
10
- var _default = TriggerContext;
11
- exports.default = _default;
10
+ var _default = exports.default = TriggerContext;
@@ -132,7 +132,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
132
132
 
133
133
  // placeholder element
134
134
  var placeholderElement = doc.createElement('div');
135
- (_popupElement$parentE = popupElement.parentElement) === null || _popupElement$parentE === void 0 ? void 0 : _popupElement$parentE.appendChild(placeholderElement);
135
+ (_popupElement$parentE = popupElement.parentElement) === null || _popupElement$parentE === void 0 || _popupElement$parentE.appendChild(placeholderElement);
136
136
  placeholderElement.style.left = "".concat(popupElement.offsetLeft, "px");
137
137
  placeholderElement.style.top = "".concat(popupElement.offsetTop, "px");
138
138
  placeholderElement.style.position = popupPosition;
@@ -216,7 +216,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
216
216
  popupElement.style.top = originTop;
217
217
  popupElement.style.right = originRight;
218
218
  popupElement.style.bottom = originBottom;
219
- (_popupElement$parentE2 = popupElement.parentElement) === null || _popupElement$parentE2 === void 0 ? void 0 : _popupElement$parentE2.removeChild(placeholderElement);
219
+ (_popupElement$parentE2 = popupElement.parentElement) === null || _popupElement$parentE2 === void 0 || _popupElement$parentE2.removeChild(placeholderElement);
220
220
 
221
221
  // Calculate scale
222
222
  var _scaleX = (0, _util.toNum)(Math.round(popupWidth / parseFloat(width) * 1000) / 1000);
@@ -473,7 +473,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
473
473
  var minBottom = Math.min(popupBottom, targetBottom);
474
474
  var yCenter = (maxTop + minBottom) / 2;
475
475
  var nextArrowY = yCenter - popupTop;
476
- onPopupAlign === null || onPopupAlign === void 0 ? void 0 : onPopupAlign(popupEle, nextAlignInfo);
476
+ onPopupAlign === null || onPopupAlign === void 0 || onPopupAlign(popupEle, nextAlignInfo);
477
477
 
478
478
  // Additional calculate right & bottom position
479
479
  var offsetX4Right = popupMirrorRect.right - popupRect.x - (nextOffsetX + popupRect.width);
@@ -76,7 +76,7 @@ function useWinClick(open, clickToHide, targetEle, popupEle, mask, maskClosable,
76
76
  // Warning if target and popup not in same root
77
77
  if (process.env.NODE_ENV !== 'production') {
78
78
  var _targetEle$getRootNod, _popupEle$getRootNode;
79
- var targetRoot = targetEle === null || targetEle === void 0 ? void 0 : (_targetEle$getRootNod = targetEle.getRootNode) === null || _targetEle$getRootNod === void 0 ? void 0 : _targetEle$getRootNod.call(targetEle);
79
+ var targetRoot = targetEle === null || targetEle === void 0 || (_targetEle$getRootNod = targetEle.getRootNode) === null || _targetEle$getRootNod === void 0 ? void 0 : _targetEle$getRootNod.call(targetEle);
80
80
  var popupRoot = (_popupEle$getRootNode = popupEle.getRootNode) === null || _popupEle$getRootNode === void 0 ? void 0 : _popupEle$getRootNode.call(popupEle);
81
81
  (0, _warning.warning)(targetRoot === popupRoot, "trigger element and popup element should in same shadow root.");
82
82
  }
package/lib/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import type { CSSMotionProps } from 'rc-motion';
2
2
  import * as React from 'react';
3
3
  import type { ActionType, AlignType, AnimationType, ArrowTypeOuter, BuildInPlacements, TransitionNameType } from './interface';
4
- export type { BuildInPlacements, AlignType, ActionType, ArrowTypeOuter as ArrowType, };
4
+ export type { ActionType, AlignType, ArrowTypeOuter as ArrowType, BuildInPlacements, };
5
5
  export interface TriggerRef {
6
+ nativeElement: HTMLElement;
6
7
  forceAlign: VoidFunction;
7
8
  }
8
9
  export interface TriggerProps {
package/lib/index.js CHANGED
@@ -21,13 +21,13 @@ var _useLayoutEffect = _interopRequireDefault(require("rc-util/lib/hooks/useLayo
21
21
  var _isMobile = _interopRequireDefault(require("rc-util/lib/isMobile"));
22
22
  var React = _interopRequireWildcard(require("react"));
23
23
  var _reactDom = require("react-dom");
24
+ var _Popup = _interopRequireDefault(require("./Popup"));
25
+ var _TriggerWrapper = _interopRequireDefault(require("./TriggerWrapper"));
24
26
  var _context = _interopRequireDefault(require("./context"));
25
27
  var _useAction3 = _interopRequireDefault(require("./hooks/useAction"));
26
28
  var _useAlign3 = _interopRequireDefault(require("./hooks/useAlign"));
27
29
  var _useWatch = _interopRequireDefault(require("./hooks/useWatch"));
28
30
  var _useWinClick = _interopRequireDefault(require("./hooks/useWinClick"));
29
- var _Popup = _interopRequireDefault(require("./Popup"));
30
- var _TriggerWrapper = _interopRequireDefault(require("./TriggerWrapper"));
31
31
  var _util = require("./util");
32
32
  var _excluded = ["prefixCls", "children", "action", "showAction", "hideAction", "popupVisible", "defaultPopupVisible", "onPopupVisibleChange", "afterPopupVisibleChange", "mouseEnterDelay", "mouseLeaveDelay", "focusDelay", "blurDelay", "mask", "maskClosable", "getPopupContainer", "forceRender", "autoDestroy", "destroyPopupOnHide", "popup", "popupClassName", "popupStyle", "popupPlacement", "builtinPlacements", "popupAlign", "zIndex", "stretch", "getPopupClassNameFromAlign", "fresh", "alignPoint", "onPopupClick", "onPopupAlign", "arrow", "popupMotion", "maskMotion", "popupTransitionName", "popupAnimation", "maskTransitionName", "maskAnimation", "className", "getTriggerDOMNode"];
33
33
  // Removed Props List
@@ -104,7 +104,7 @@ function generateTrigger() {
104
104
  return {
105
105
  registerSubPopup: function registerSubPopup(id, subPopupEle) {
106
106
  subPopupElements.current[id] = subPopupEle;
107
- parentContext === null || parentContext === void 0 ? void 0 : parentContext.registerSubPopup(id, subPopupEle);
107
+ parentContext === null || parentContext === void 0 || parentContext.registerSubPopup(id, subPopupEle);
108
108
  }
109
109
  };
110
110
  }, [parentContext]);
@@ -119,7 +119,7 @@ function generateTrigger() {
119
119
  if ((0, _findDOMNode.isDOM)(node) && popupEle !== node) {
120
120
  setPopupEle(node);
121
121
  }
122
- parentContext === null || parentContext === void 0 ? void 0 : parentContext.registerSubPopup(id, node);
122
+ parentContext === null || parentContext === void 0 || parentContext.registerSubPopup(id, node);
123
123
  });
124
124
 
125
125
  // =========================== Target ===========================
@@ -128,9 +128,13 @@ function generateTrigger() {
128
128
  _React$useState6 = (0, _slicedToArray2.default)(_React$useState5, 2),
129
129
  targetEle = _React$useState6[0],
130
130
  setTargetEle = _React$useState6[1];
131
+
132
+ // Used for forwardRef target. Not use internal
133
+ var externalForwardRef = React.useRef(null);
131
134
  var setTargetRef = (0, _useEvent.default)(function (node) {
132
135
  if ((0, _findDOMNode.isDOM)(node) && targetEle !== node) {
133
136
  setTargetEle(node);
137
+ externalForwardRef.current = node;
134
138
  }
135
139
  });
136
140
 
@@ -176,7 +180,7 @@ function generateTrigger() {
176
180
  (0, _reactDom.flushSync)(function () {
177
181
  if (mergedOpen !== nextOpen) {
178
182
  setMergedOpen(nextOpen);
179
- onPopupVisibleChange === null || onPopupVisibleChange === void 0 ? void 0 : onPopupVisibleChange(nextOpen);
183
+ onPopupVisibleChange === null || onPopupVisibleChange === void 0 || onPopupVisibleChange(nextOpen);
180
184
  }
181
185
  });
182
186
  });
@@ -268,8 +272,11 @@ function generateTrigger() {
268
272
  var baseClassName = (0, _util.getAlignPopupClassName)(builtinPlacements, prefixCls, alignInfo, alignPoint);
269
273
  return (0, _classnames.default)(baseClassName, getPopupClassNameFromAlign === null || getPopupClassNameFromAlign === void 0 ? void 0 : getPopupClassNameFromAlign(alignInfo));
270
274
  }, [alignInfo, getPopupClassNameFromAlign, builtinPlacements, prefixCls, alignPoint]);
275
+
276
+ // ============================ Refs ============================
271
277
  React.useImperativeHandle(ref, function () {
272
278
  return {
279
+ nativeElement: externalForwardRef.current,
273
280
  forceAlign: triggerAlign
274
281
  };
275
282
  });
@@ -299,7 +306,7 @@ function generateTrigger() {
299
306
  var onVisibleChanged = function onVisibleChanged(visible) {
300
307
  setInMotion(false);
301
308
  onAlign();
302
- afterPopupVisibleChange === null || afterPopupVisibleChange === void 0 ? void 0 : afterPopupVisibleChange(visible);
309
+ afterPopupVisibleChange === null || afterPopupVisibleChange === void 0 || afterPopupVisibleChange(visible);
303
310
  };
304
311
 
305
312
  // We will trigger align when motion is in prepare
@@ -326,14 +333,14 @@ function generateTrigger() {
326
333
  function wrapperAction(eventName, nextOpen, delay, preEvent) {
327
334
  cloneProps[eventName] = function (event) {
328
335
  var _originChildProps$eve;
329
- preEvent === null || preEvent === void 0 ? void 0 : preEvent(event);
336
+ preEvent === null || preEvent === void 0 || preEvent(event);
330
337
  triggerOpen(nextOpen, delay);
331
338
 
332
339
  // Pass to origin
333
340
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
334
341
  args[_key - 1] = arguments[_key];
335
342
  }
336
- (_originChildProps$eve = originChildProps[eventName]) === null || _originChildProps$eve === void 0 ? void 0 : _originChildProps$eve.call.apply(_originChildProps$eve, [originChildProps, event].concat(args));
343
+ (_originChildProps$eve = originChildProps[eventName]) === null || _originChildProps$eve === void 0 || _originChildProps$eve.call.apply(_originChildProps$eve, [originChildProps, event].concat(args));
337
344
  };
338
345
  }
339
346
 
@@ -352,7 +359,7 @@ function generateTrigger() {
352
359
  for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
353
360
  args[_key2 - 1] = arguments[_key2];
354
361
  }
355
- (_originChildProps$onC = originChildProps.onClick) === null || _originChildProps$onC === void 0 ? void 0 : _originChildProps$onC.call.apply(_originChildProps$onC, [originChildProps, event].concat(args));
362
+ (_originChildProps$onC = originChildProps.onClick) === null || _originChildProps$onC === void 0 || _originChildProps$onC.call.apply(_originChildProps$onC, [originChildProps, event].concat(args));
356
363
  };
357
364
  }
358
365
 
@@ -384,7 +391,7 @@ function generateTrigger() {
384
391
  cloneProps.onMouseMove = function (event) {
385
392
  var _originChildProps$onM;
386
393
  // setMousePosByEvent(event);
387
- (_originChildProps$onM = originChildProps.onMouseMove) === null || _originChildProps$onM === void 0 ? void 0 : _originChildProps$onM.call(originChildProps, event);
394
+ (_originChildProps$onM = originChildProps.onMouseMove) === null || _originChildProps$onM === void 0 || _originChildProps$onM.call(originChildProps, event);
388
395
  };
389
396
  }
390
397
  }
@@ -420,7 +427,7 @@ function generateTrigger() {
420
427
  for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
421
428
  args[_key3 - 1] = arguments[_key3];
422
429
  }
423
- (_originChildProps$onC2 = originChildProps.onContextMenu) === null || _originChildProps$onC2 === void 0 ? void 0 : _originChildProps$onC2.call.apply(_originChildProps$onC2, [originChildProps, event].concat(args));
430
+ (_originChildProps$onC2 = originChildProps.onContextMenu) === null || _originChildProps$onC2 === void 0 || _originChildProps$onC2.call.apply(_originChildProps$onC2, [originChildProps, event].concat(args));
424
431
  };
425
432
  }
426
433
 
@@ -442,7 +449,7 @@ function generateTrigger() {
442
449
  for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
443
450
  args[_key4] = arguments[_key4];
444
451
  }
445
- (_mergedChildrenProps$ = mergedChildrenProps[eventName]) === null || _mergedChildrenProps$ === void 0 ? void 0 : _mergedChildrenProps$.call.apply(_mergedChildrenProps$, [mergedChildrenProps].concat(args));
452
+ (_mergedChildrenProps$ = mergedChildrenProps[eventName]) === null || _mergedChildrenProps$ === void 0 || _mergedChildrenProps$.call.apply(_mergedChildrenProps$, [mergedChildrenProps].concat(args));
446
453
  restProps[eventName].apply(restProps, args);
447
454
  };
448
455
  }
@@ -526,5 +533,4 @@ function generateTrigger() {
526
533
  }
527
534
  return Trigger;
528
535
  }
529
- var _default = generateTrigger(_portal.default);
530
- exports.default = _default;
536
+ var _default = exports.default = generateTrigger(_portal.default);
package/lib/mock.js CHANGED
@@ -19,7 +19,7 @@ var MockPortal = function MockPortal(_ref) {
19
19
  visible = _React$useState2[0],
20
20
  setVisible = _React$useState2[1];
21
21
  React.useEffect(function () {
22
- getContainer === null || getContainer === void 0 ? void 0 : getContainer();
22
+ getContainer === null || getContainer === void 0 || getContainer();
23
23
  });
24
24
  React.useEffect(function () {
25
25
  if (open) {
@@ -30,5 +30,4 @@ var MockPortal = function MockPortal(_ref) {
30
30
  }, [open, autoDestroy]);
31
31
  return visible ? children : null;
32
32
  };
33
- var _default = (0, _index.generateTrigger)(MockPortal);
34
- exports.default = _default;
33
+ var _default = exports.default = (0, _index.generateTrigger)(MockPortal);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/trigger",
3
- "version": "1.17.2",
3
+ "version": "1.18.0",
4
4
  "description": "base abstract trigger component for react",
5
5
  "engines": {
6
6
  "node": ">=8.x"