You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1728 lines
69 KiB
1728 lines
69 KiB
"use strict";
|
|
(self["webpackChunk"] = self["webpackChunk"] || []).push([[35593],{
|
|
|
|
/***/ 35593:
|
|
/*!***************************************************************************************************!*\
|
|
!*** ./node_modules/_@rc-component_trigger@1.18.3@@rc-component/trigger/es/index.js + 11 modules ***!
|
|
\***************************************************************************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
// EXPORTS
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
Z: function() { return /* binding */ trigger_es; }
|
|
});
|
|
|
|
// UNUSED EXPORTS: generateTrigger
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.27.6@@babel/runtime/helpers/esm/objectSpread2.js
|
|
var objectSpread2 = __webpack_require__(20439);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.27.6@@babel/runtime/helpers/esm/slicedToArray.js + 1 modules
|
|
var slicedToArray = __webpack_require__(50298);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.27.6@@babel/runtime/helpers/esm/objectWithoutProperties.js
|
|
var objectWithoutProperties = __webpack_require__(62646);
|
|
// EXTERNAL MODULE: ./node_modules/_@rc-component_portal@1.1.2@@rc-component/portal/es/index.js + 6 modules
|
|
var es = __webpack_require__(43403);
|
|
// EXTERNAL MODULE: ./node_modules/_classnames@2.5.1@classnames/index.js
|
|
var _classnames_2_5_1_classnames = __webpack_require__(92310);
|
|
var _classnames_2_5_1_classnames_default = /*#__PURE__*/__webpack_require__.n(_classnames_2_5_1_classnames);
|
|
// EXTERNAL MODULE: ./node_modules/_rc-resize-observer@1.4.3@rc-resize-observer/es/index.js + 4 modules
|
|
var _rc_resize_observer_1_4_3_rc_resize_observer_es = __webpack_require__(29301);
|
|
// EXTERNAL MODULE: ./node_modules/_rc-util@5.44.4@rc-util/es/Dom/findDOMNode.js
|
|
var findDOMNode = __webpack_require__(76846);
|
|
// EXTERNAL MODULE: ./node_modules/_rc-util@5.44.4@rc-util/es/Dom/shadow.js
|
|
var shadow = __webpack_require__(96452);
|
|
// EXTERNAL MODULE: ./node_modules/_rc-util@5.44.4@rc-util/es/hooks/useEvent.js
|
|
var useEvent = __webpack_require__(6089);
|
|
// EXTERNAL MODULE: ./node_modules/_rc-util@5.44.4@rc-util/es/hooks/useId.js
|
|
var useId = __webpack_require__(80402);
|
|
// EXTERNAL MODULE: ./node_modules/_rc-util@5.44.4@rc-util/es/hooks/useLayoutEffect.js
|
|
var useLayoutEffect = __webpack_require__(34280);
|
|
// EXTERNAL MODULE: ./node_modules/_rc-util@5.44.4@rc-util/es/isMobile.js
|
|
var isMobile = __webpack_require__(49658);
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
|
|
var _react_17_0_2_react = __webpack_require__(59301);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.27.6@@babel/runtime/helpers/esm/extends.js
|
|
var esm_extends = __webpack_require__(14809);
|
|
// EXTERNAL MODULE: ./node_modules/_rc-motion@2.9.5@rc-motion/es/index.js + 13 modules
|
|
var _rc_motion_2_9_5_rc_motion_es = __webpack_require__(77900);
|
|
// EXTERNAL MODULE: ./node_modules/_rc-util@5.44.4@rc-util/es/ref.js
|
|
var es_ref = __webpack_require__(8654);
|
|
;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.18.3@@rc-component/trigger/es/Popup/Arrow.js
|
|
|
|
|
|
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_17_0_2_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_17_0_2_react.createElement("div", {
|
|
ref: arrowRef,
|
|
className: _classnames_2_5_1_classnames_default()("".concat(prefixCls, "-arrow"), className),
|
|
style: alignStyle
|
|
}, content);
|
|
}
|
|
;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.18.3@@rc-component/trigger/es/Popup/Mask.js
|
|
|
|
|
|
|
|
|
|
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_17_0_2_react.createElement(_rc_motion_2_9_5_rc_motion_es["default"], (0,esm_extends/* default */.Z)({}, motion, {
|
|
motionAppear: true,
|
|
visible: open,
|
|
removeOnLeave: true
|
|
}), function (_ref) {
|
|
var className = _ref.className;
|
|
return /*#__PURE__*/_react_17_0_2_react.createElement("div", {
|
|
style: {
|
|
zIndex: zIndex
|
|
},
|
|
className: _classnames_2_5_1_classnames_default()("".concat(prefixCls, "-mask"), className)
|
|
});
|
|
});
|
|
}
|
|
;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.18.3@@rc-component/trigger/es/Popup/PopupContent.js
|
|
|
|
var PopupContent = /*#__PURE__*/_react_17_0_2_react.memo(function (_ref) {
|
|
var children = _ref.children;
|
|
return children;
|
|
}, function (_, next) {
|
|
return next.cache;
|
|
});
|
|
if (false) {}
|
|
/* harmony default export */ var Popup_PopupContent = (PopupContent);
|
|
;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.18.3@@rc-component/trigger/es/Popup/index.js
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var Popup = /*#__PURE__*/_react_17_0_2_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,
|
|
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_17_0_2_react.useState(!getPopupContainer || !getPopupContainerNeedParams),
|
|
_React$useState2 = (0,slicedToArray/* default */.Z)(_React$useState, 2),
|
|
show = _React$useState2[0],
|
|
setShow = _React$useState2[1];
|
|
|
|
// Delay to show since `getPopupContainer` need target element
|
|
(0,useLayoutEffect/* default */.Z)(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_17_0_2_react.createElement(Portal, {
|
|
open: forceRender || isNodeVisible,
|
|
getContainer: getPopupContainer && function () {
|
|
return getPopupContainer(target);
|
|
},
|
|
autoDestroy: autoDestroy
|
|
}, /*#__PURE__*/_react_17_0_2_react.createElement(Mask, {
|
|
prefixCls: prefixCls,
|
|
open: open,
|
|
zIndex: zIndex,
|
|
mask: mask,
|
|
motion: maskMotion
|
|
}), /*#__PURE__*/_react_17_0_2_react.createElement(_rc_resize_observer_1_4_3_rc_resize_observer_es/* default */.Z, {
|
|
onResize: onAlign,
|
|
disabled: !open
|
|
}, function (resizeObserverRef) {
|
|
return /*#__PURE__*/_react_17_0_2_react.createElement(_rc_motion_2_9_5_rc_motion_es["default"], (0,esm_extends/* default */.Z)({
|
|
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_2_5_1_classnames_default()(prefixCls, motionClassName, className);
|
|
return /*#__PURE__*/_react_17_0_2_react.createElement("div", {
|
|
ref: (0,es_ref/* composeRef */.sQ)(resizeObserverRef, ref, motionRef),
|
|
className: cls,
|
|
style: (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({
|
|
'--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
|
|
}, arrow && /*#__PURE__*/_react_17_0_2_react.createElement(Arrow, {
|
|
prefixCls: prefixCls,
|
|
arrow: arrow,
|
|
arrowPos: arrowPos,
|
|
align: align
|
|
}), /*#__PURE__*/_react_17_0_2_react.createElement(Popup_PopupContent, {
|
|
cache: !open && !fresh
|
|
}, childNode));
|
|
});
|
|
}));
|
|
});
|
|
if (false) {}
|
|
/* harmony default export */ var es_Popup = (Popup);
|
|
;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.18.3@@rc-component/trigger/es/TriggerWrapper.js
|
|
|
|
|
|
var TriggerWrapper = /*#__PURE__*/_react_17_0_2_react.forwardRef(function (props, ref) {
|
|
var children = props.children,
|
|
getTriggerDOMNode = props.getTriggerDOMNode;
|
|
var canUseRef = (0,es_ref/* supportRef */.Yr)(children);
|
|
|
|
// When use `getTriggerDOMNode`, we should do additional work to get the real dom
|
|
var setRef = _react_17_0_2_react.useCallback(function (node) {
|
|
(0,es_ref/* fillRef */.mH)(ref, getTriggerDOMNode ? getTriggerDOMNode(node) : node);
|
|
}, [getTriggerDOMNode]);
|
|
var mergedRef = (0,es_ref/* useComposeRef */.x1)(setRef, children.ref);
|
|
return canUseRef ? /*#__PURE__*/_react_17_0_2_react.cloneElement(children, {
|
|
ref: mergedRef
|
|
}) : children;
|
|
});
|
|
if (false) {}
|
|
/* harmony default export */ var es_TriggerWrapper = (TriggerWrapper);
|
|
;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.18.3@@rc-component/trigger/es/context.js
|
|
|
|
var TriggerContext = /*#__PURE__*/_react_17_0_2_react.createContext(null);
|
|
/* harmony default export */ var es_context = (TriggerContext);
|
|
;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.18.3@@rc-component/trigger/es/hooks/useAction.js
|
|
|
|
function toArray(val) {
|
|
return val ? Array.isArray(val) ? val : [val] : [];
|
|
}
|
|
function useAction(mobile, action, showAction, hideAction) {
|
|
return _react_17_0_2_react.useMemo(function () {
|
|
var mergedShowAction = toArray(showAction !== null && showAction !== void 0 ? showAction : action);
|
|
var mergedHideAction = toArray(hideAction !== null && hideAction !== void 0 ? hideAction : action);
|
|
var showActionSet = new Set(mergedShowAction);
|
|
var hideActionSet = new Set(mergedHideAction);
|
|
if (mobile) {
|
|
if (showActionSet.has('hover')) {
|
|
showActionSet.delete('hover');
|
|
showActionSet.add('click');
|
|
}
|
|
if (hideActionSet.has('hover')) {
|
|
hideActionSet.delete('hover');
|
|
hideActionSet.add('click');
|
|
}
|
|
}
|
|
return [showActionSet, hideActionSet];
|
|
}, [mobile, action, showAction, hideAction]);
|
|
}
|
|
// EXTERNAL MODULE: ./node_modules/_rc-util@5.44.4@rc-util/es/Dom/isVisible.js
|
|
var isVisible = __webpack_require__(29194);
|
|
;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.18.3@@rc-component/trigger/es/util.js
|
|
|
|
function isPointsEq() {
|
|
var a1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
var a2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
var isAlignPoint = arguments.length > 2 ? arguments[2] : undefined;
|
|
if (isAlignPoint) {
|
|
return a1[0] === a2[0];
|
|
}
|
|
return a1[0] === a2[0] && a1[1] === a2[1];
|
|
}
|
|
function getAlignPopupClassName(builtinPlacements, prefixCls, align, isAlignPoint) {
|
|
var points = align.points;
|
|
var placements = Object.keys(builtinPlacements);
|
|
for (var i = 0; i < placements.length; i += 1) {
|
|
var _builtinPlacements$pl;
|
|
var placement = placements[i];
|
|
if (isPointsEq((_builtinPlacements$pl = builtinPlacements[placement]) === null || _builtinPlacements$pl === void 0 ? void 0 : _builtinPlacements$pl.points, points, isAlignPoint)) {
|
|
return "".concat(prefixCls, "-placement-").concat(placement);
|
|
}
|
|
}
|
|
return '';
|
|
}
|
|
|
|
/** @deprecated We should not use this if we can refactor all deps */
|
|
function getMotion(prefixCls, motion, animation, transitionName) {
|
|
if (motion) {
|
|
return motion;
|
|
}
|
|
if (animation) {
|
|
return {
|
|
motionName: "".concat(prefixCls, "-").concat(animation)
|
|
};
|
|
}
|
|
if (transitionName) {
|
|
return {
|
|
motionName: transitionName
|
|
};
|
|
}
|
|
return null;
|
|
}
|
|
function getWin(ele) {
|
|
return ele.ownerDocument.defaultView;
|
|
}
|
|
|
|
/**
|
|
* Get all the scrollable parent elements of the element
|
|
* @param ele The element to be detected
|
|
* @param areaOnly Only return the parent which will cut visible area
|
|
*/
|
|
function collectScroller(ele) {
|
|
var scrollerList = [];
|
|
var current = ele === null || ele === void 0 ? void 0 : ele.parentElement;
|
|
var scrollStyle = ['hidden', 'scroll', 'clip', 'auto'];
|
|
while (current) {
|
|
var _getWin$getComputedSt = getWin(current).getComputedStyle(current),
|
|
overflowX = _getWin$getComputedSt.overflowX,
|
|
overflowY = _getWin$getComputedSt.overflowY,
|
|
overflow = _getWin$getComputedSt.overflow;
|
|
if ([overflowX, overflowY, overflow].some(function (o) {
|
|
return scrollStyle.includes(o);
|
|
})) {
|
|
scrollerList.push(current);
|
|
}
|
|
current = current.parentElement;
|
|
}
|
|
return scrollerList;
|
|
}
|
|
function toNum(num) {
|
|
var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
return Number.isNaN(num) ? defaultValue : num;
|
|
}
|
|
function getPxValue(val) {
|
|
return toNum(parseFloat(val), 0);
|
|
}
|
|
/**
|
|
*
|
|
*
|
|
* **************************************
|
|
* * Border *
|
|
* * ************************** *
|
|
* * * * * *
|
|
* * B * * S * B *
|
|
* * o * * c * o *
|
|
* * r * Content * r * r *
|
|
* * d * * o * d *
|
|
* * e * * l * e *
|
|
* * r ******************** l * r *
|
|
* * * Scroll * *
|
|
* * ************************** *
|
|
* * Border *
|
|
* **************************************
|
|
*
|
|
*/
|
|
/**
|
|
* Get visible area of element
|
|
*/
|
|
function getVisibleArea(initArea, scrollerList) {
|
|
var visibleArea = (0,objectSpread2/* default */.Z)({}, initArea);
|
|
(scrollerList || []).forEach(function (ele) {
|
|
if (ele instanceof HTMLBodyElement || ele instanceof HTMLHtmlElement) {
|
|
return;
|
|
}
|
|
|
|
// Skip if static position which will not affect visible area
|
|
var _getWin$getComputedSt2 = getWin(ele).getComputedStyle(ele),
|
|
overflow = _getWin$getComputedSt2.overflow,
|
|
overflowClipMargin = _getWin$getComputedSt2.overflowClipMargin,
|
|
borderTopWidth = _getWin$getComputedSt2.borderTopWidth,
|
|
borderBottomWidth = _getWin$getComputedSt2.borderBottomWidth,
|
|
borderLeftWidth = _getWin$getComputedSt2.borderLeftWidth,
|
|
borderRightWidth = _getWin$getComputedSt2.borderRightWidth;
|
|
var eleRect = ele.getBoundingClientRect();
|
|
var eleOutHeight = ele.offsetHeight,
|
|
eleInnerHeight = ele.clientHeight,
|
|
eleOutWidth = ele.offsetWidth,
|
|
eleInnerWidth = ele.clientWidth;
|
|
var borderTopNum = getPxValue(borderTopWidth);
|
|
var borderBottomNum = getPxValue(borderBottomWidth);
|
|
var borderLeftNum = getPxValue(borderLeftWidth);
|
|
var borderRightNum = getPxValue(borderRightWidth);
|
|
var scaleX = toNum(Math.round(eleRect.width / eleOutWidth * 1000) / 1000);
|
|
var scaleY = toNum(Math.round(eleRect.height / eleOutHeight * 1000) / 1000);
|
|
|
|
// Original visible area
|
|
var eleScrollWidth = (eleOutWidth - eleInnerWidth - borderLeftNum - borderRightNum) * scaleX;
|
|
var eleScrollHeight = (eleOutHeight - eleInnerHeight - borderTopNum - borderBottomNum) * scaleY;
|
|
|
|
// Cut border size
|
|
var scaledBorderTopWidth = borderTopNum * scaleY;
|
|
var scaledBorderBottomWidth = borderBottomNum * scaleY;
|
|
var scaledBorderLeftWidth = borderLeftNum * scaleX;
|
|
var scaledBorderRightWidth = borderRightNum * scaleX;
|
|
|
|
// Clip margin
|
|
var clipMarginWidth = 0;
|
|
var clipMarginHeight = 0;
|
|
if (overflow === 'clip') {
|
|
var clipNum = getPxValue(overflowClipMargin);
|
|
clipMarginWidth = clipNum * scaleX;
|
|
clipMarginHeight = clipNum * scaleY;
|
|
}
|
|
|
|
// Region
|
|
var eleLeft = eleRect.x + scaledBorderLeftWidth - clipMarginWidth;
|
|
var eleTop = eleRect.y + scaledBorderTopWidth - clipMarginHeight;
|
|
var eleRight = eleLeft + eleRect.width + 2 * clipMarginWidth - scaledBorderLeftWidth - scaledBorderRightWidth - eleScrollWidth;
|
|
var eleBottom = eleTop + eleRect.height + 2 * clipMarginHeight - scaledBorderTopWidth - scaledBorderBottomWidth - eleScrollHeight;
|
|
visibleArea.left = Math.max(visibleArea.left, eleLeft);
|
|
visibleArea.top = Math.max(visibleArea.top, eleTop);
|
|
visibleArea.right = Math.min(visibleArea.right, eleRight);
|
|
visibleArea.bottom = Math.min(visibleArea.bottom, eleBottom);
|
|
});
|
|
return visibleArea;
|
|
}
|
|
;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.18.3@@rc-component/trigger/es/hooks/useAlign.js
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getUnitOffset(size) {
|
|
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
var offsetStr = "".concat(offset);
|
|
var cells = offsetStr.match(/^(.*)\%$/);
|
|
if (cells) {
|
|
return size * (parseFloat(cells[1]) / 100);
|
|
}
|
|
return parseFloat(offsetStr);
|
|
}
|
|
function getNumberOffset(rect, offset) {
|
|
var _ref = offset || [],
|
|
_ref2 = (0,slicedToArray/* default */.Z)(_ref, 2),
|
|
offsetX = _ref2[0],
|
|
offsetY = _ref2[1];
|
|
return [getUnitOffset(rect.width, offsetX), getUnitOffset(rect.height, offsetY)];
|
|
}
|
|
function splitPoints() {
|
|
var points = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
return [points[0], points[1]];
|
|
}
|
|
function getAlignPoint(rect, points) {
|
|
var topBottom = points[0];
|
|
var leftRight = points[1];
|
|
var x;
|
|
var y;
|
|
|
|
// Top & Bottom
|
|
if (topBottom === 't') {
|
|
y = rect.y;
|
|
} else if (topBottom === 'b') {
|
|
y = rect.y + rect.height;
|
|
} else {
|
|
y = rect.y + rect.height / 2;
|
|
}
|
|
|
|
// Left & Right
|
|
if (leftRight === 'l') {
|
|
x = rect.x;
|
|
} else if (leftRight === 'r') {
|
|
x = rect.x + rect.width;
|
|
} else {
|
|
x = rect.x + rect.width / 2;
|
|
}
|
|
return {
|
|
x: x,
|
|
y: y
|
|
};
|
|
}
|
|
function reversePoints(points, index) {
|
|
var reverseMap = {
|
|
t: 'b',
|
|
b: 't',
|
|
l: 'r',
|
|
r: 'l'
|
|
};
|
|
return points.map(function (point, i) {
|
|
if (i === index) {
|
|
return reverseMap[point] || 'c';
|
|
}
|
|
return point;
|
|
}).join('');
|
|
}
|
|
function useAlign(open, popupEle, target, placement, builtinPlacements, popupAlign, onPopupAlign) {
|
|
var _React$useState = _react_17_0_2_react.useState({
|
|
ready: false,
|
|
offsetX: 0,
|
|
offsetY: 0,
|
|
offsetR: 0,
|
|
offsetB: 0,
|
|
arrowX: 0,
|
|
arrowY: 0,
|
|
scaleX: 1,
|
|
scaleY: 1,
|
|
align: builtinPlacements[placement] || {}
|
|
}),
|
|
_React$useState2 = (0,slicedToArray/* default */.Z)(_React$useState, 2),
|
|
offsetInfo = _React$useState2[0],
|
|
setOffsetInfo = _React$useState2[1];
|
|
var alignCountRef = _react_17_0_2_react.useRef(0);
|
|
var scrollerList = _react_17_0_2_react.useMemo(function () {
|
|
if (!popupEle) {
|
|
return [];
|
|
}
|
|
return collectScroller(popupEle);
|
|
}, [popupEle]);
|
|
|
|
// ========================= Flip ==========================
|
|
// We will memo flip info.
|
|
// If size change to make flip, it will memo the flip info and use it in next align.
|
|
var prevFlipRef = _react_17_0_2_react.useRef({});
|
|
var resetFlipCache = function resetFlipCache() {
|
|
prevFlipRef.current = {};
|
|
};
|
|
if (!open) {
|
|
resetFlipCache();
|
|
}
|
|
|
|
// ========================= Align =========================
|
|
var onAlign = (0,useEvent/* default */.Z)(function () {
|
|
if (popupEle && target && open) {
|
|
var _popupElement$parentE, _popupElement$parentE2;
|
|
var popupElement = popupEle;
|
|
var doc = popupElement.ownerDocument;
|
|
var win = getWin(popupElement);
|
|
var _win$getComputedStyle = win.getComputedStyle(popupElement),
|
|
width = _win$getComputedStyle.width,
|
|
height = _win$getComputedStyle.height,
|
|
popupPosition = _win$getComputedStyle.position;
|
|
var originLeft = popupElement.style.left;
|
|
var originTop = popupElement.style.top;
|
|
var originRight = popupElement.style.right;
|
|
var originBottom = popupElement.style.bottom;
|
|
var originOverflow = popupElement.style.overflow;
|
|
|
|
// Placement
|
|
var placementInfo = (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, builtinPlacements[placement]), popupAlign);
|
|
|
|
// placeholder element
|
|
var placeholderElement = doc.createElement('div');
|
|
(_popupElement$parentE = popupElement.parentElement) === null || _popupElement$parentE === void 0 || _popupElement$parentE.appendChild(placeholderElement);
|
|
placeholderElement.style.left = "".concat(popupElement.offsetLeft, "px");
|
|
placeholderElement.style.top = "".concat(popupElement.offsetTop, "px");
|
|
placeholderElement.style.position = popupPosition;
|
|
placeholderElement.style.height = "".concat(popupElement.offsetHeight, "px");
|
|
placeholderElement.style.width = "".concat(popupElement.offsetWidth, "px");
|
|
|
|
// Reset first
|
|
popupElement.style.left = '0';
|
|
popupElement.style.top = '0';
|
|
popupElement.style.right = 'auto';
|
|
popupElement.style.bottom = 'auto';
|
|
popupElement.style.overflow = 'hidden';
|
|
|
|
// Calculate align style, we should consider `transform` case
|
|
var targetRect;
|
|
if (Array.isArray(target)) {
|
|
targetRect = {
|
|
x: target[0],
|
|
y: target[1],
|
|
width: 0,
|
|
height: 0
|
|
};
|
|
} else {
|
|
var rect = target.getBoundingClientRect();
|
|
targetRect = {
|
|
x: rect.x,
|
|
y: rect.y,
|
|
width: rect.width,
|
|
height: rect.height
|
|
};
|
|
}
|
|
var popupRect = popupElement.getBoundingClientRect();
|
|
var _doc$documentElement = doc.documentElement,
|
|
clientWidth = _doc$documentElement.clientWidth,
|
|
clientHeight = _doc$documentElement.clientHeight,
|
|
scrollWidth = _doc$documentElement.scrollWidth,
|
|
scrollHeight = _doc$documentElement.scrollHeight,
|
|
scrollTop = _doc$documentElement.scrollTop,
|
|
scrollLeft = _doc$documentElement.scrollLeft;
|
|
var popupHeight = popupRect.height;
|
|
var popupWidth = popupRect.width;
|
|
var targetHeight = targetRect.height;
|
|
var targetWidth = targetRect.width;
|
|
|
|
// Get bounding of visible area
|
|
var visibleRegion = {
|
|
left: 0,
|
|
top: 0,
|
|
right: clientWidth,
|
|
bottom: clientHeight
|
|
};
|
|
var scrollRegion = {
|
|
left: -scrollLeft,
|
|
top: -scrollTop,
|
|
right: scrollWidth - scrollLeft,
|
|
bottom: scrollHeight - scrollTop
|
|
};
|
|
var htmlRegion = placementInfo.htmlRegion;
|
|
var VISIBLE = 'visible';
|
|
var VISIBLE_FIRST = 'visibleFirst';
|
|
if (htmlRegion !== 'scroll' && htmlRegion !== VISIBLE_FIRST) {
|
|
htmlRegion = VISIBLE;
|
|
}
|
|
var isVisibleFirst = htmlRegion === VISIBLE_FIRST;
|
|
var scrollRegionArea = getVisibleArea(scrollRegion, scrollerList);
|
|
var visibleRegionArea = getVisibleArea(visibleRegion, scrollerList);
|
|
var visibleArea = htmlRegion === VISIBLE ? visibleRegionArea : scrollRegionArea;
|
|
|
|
// When set to `visibleFirst`,
|
|
// the check `adjust` logic will use `visibleRegion` for check first.
|
|
var adjustCheckVisibleArea = isVisibleFirst ? visibleRegionArea : visibleArea;
|
|
|
|
// Record right & bottom align data
|
|
popupElement.style.left = 'auto';
|
|
popupElement.style.top = 'auto';
|
|
popupElement.style.right = '0';
|
|
popupElement.style.bottom = '0';
|
|
var popupMirrorRect = popupElement.getBoundingClientRect();
|
|
|
|
// Reset back
|
|
popupElement.style.left = originLeft;
|
|
popupElement.style.top = originTop;
|
|
popupElement.style.right = originRight;
|
|
popupElement.style.bottom = originBottom;
|
|
popupElement.style.overflow = originOverflow;
|
|
(_popupElement$parentE2 = popupElement.parentElement) === null || _popupElement$parentE2 === void 0 || _popupElement$parentE2.removeChild(placeholderElement);
|
|
|
|
// Calculate scale
|
|
var _scaleX = toNum(Math.round(popupWidth / parseFloat(width) * 1000) / 1000);
|
|
var _scaleY = toNum(Math.round(popupHeight / parseFloat(height) * 1000) / 1000);
|
|
|
|
// No need to align since it's not visible in view
|
|
if (_scaleX === 0 || _scaleY === 0 || (0,findDOMNode/* isDOM */.Sh)(target) && !(0,isVisible/* default */.Z)(target)) {
|
|
return;
|
|
}
|
|
|
|
// Offset
|
|
var offset = placementInfo.offset,
|
|
targetOffset = placementInfo.targetOffset;
|
|
var _getNumberOffset = getNumberOffset(popupRect, offset),
|
|
_getNumberOffset2 = (0,slicedToArray/* default */.Z)(_getNumberOffset, 2),
|
|
popupOffsetX = _getNumberOffset2[0],
|
|
popupOffsetY = _getNumberOffset2[1];
|
|
var _getNumberOffset3 = getNumberOffset(targetRect, targetOffset),
|
|
_getNumberOffset4 = (0,slicedToArray/* default */.Z)(_getNumberOffset3, 2),
|
|
targetOffsetX = _getNumberOffset4[0],
|
|
targetOffsetY = _getNumberOffset4[1];
|
|
targetRect.x -= targetOffsetX;
|
|
targetRect.y -= targetOffsetY;
|
|
|
|
// Points
|
|
var _ref3 = placementInfo.points || [],
|
|
_ref4 = (0,slicedToArray/* default */.Z)(_ref3, 2),
|
|
popupPoint = _ref4[0],
|
|
targetPoint = _ref4[1];
|
|
var targetPoints = splitPoints(targetPoint);
|
|
var popupPoints = splitPoints(popupPoint);
|
|
var targetAlignPoint = getAlignPoint(targetRect, targetPoints);
|
|
var popupAlignPoint = getAlignPoint(popupRect, popupPoints);
|
|
|
|
// Real align info may not same as origin one
|
|
var nextAlignInfo = (0,objectSpread2/* default */.Z)({}, placementInfo);
|
|
|
|
// Next Offset
|
|
var nextOffsetX = targetAlignPoint.x - popupAlignPoint.x + popupOffsetX;
|
|
var nextOffsetY = targetAlignPoint.y - popupAlignPoint.y + popupOffsetY;
|
|
|
|
// ============== Intersection ===============
|
|
// Get area by position. Used for check if flip area is better
|
|
function getIntersectionVisibleArea(offsetX, offsetY) {
|
|
var area = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : visibleArea;
|
|
var l = popupRect.x + offsetX;
|
|
var t = popupRect.y + offsetY;
|
|
var r = l + popupWidth;
|
|
var b = t + popupHeight;
|
|
var visibleL = Math.max(l, area.left);
|
|
var visibleT = Math.max(t, area.top);
|
|
var visibleR = Math.min(r, area.right);
|
|
var visibleB = Math.min(b, area.bottom);
|
|
return Math.max(0, (visibleR - visibleL) * (visibleB - visibleT));
|
|
}
|
|
var originIntersectionVisibleArea = getIntersectionVisibleArea(nextOffsetX, nextOffsetY);
|
|
|
|
// As `visibleFirst`, we prepare this for check
|
|
var originIntersectionRecommendArea = getIntersectionVisibleArea(nextOffsetX, nextOffsetY, visibleRegionArea);
|
|
|
|
// ========================== Overflow ===========================
|
|
var targetAlignPointTL = getAlignPoint(targetRect, ['t', 'l']);
|
|
var popupAlignPointTL = getAlignPoint(popupRect, ['t', 'l']);
|
|
var targetAlignPointBR = getAlignPoint(targetRect, ['b', 'r']);
|
|
var popupAlignPointBR = getAlignPoint(popupRect, ['b', 'r']);
|
|
var overflow = placementInfo.overflow || {};
|
|
var adjustX = overflow.adjustX,
|
|
adjustY = overflow.adjustY,
|
|
shiftX = overflow.shiftX,
|
|
shiftY = overflow.shiftY;
|
|
var supportAdjust = function supportAdjust(val) {
|
|
if (typeof val === 'boolean') {
|
|
return val;
|
|
}
|
|
return val >= 0;
|
|
};
|
|
|
|
// Prepare position
|
|
var nextPopupY;
|
|
var nextPopupBottom;
|
|
var nextPopupX;
|
|
var nextPopupRight;
|
|
function syncNextPopupPosition() {
|
|
nextPopupY = popupRect.y + nextOffsetY;
|
|
nextPopupBottom = nextPopupY + popupHeight;
|
|
nextPopupX = popupRect.x + nextOffsetX;
|
|
nextPopupRight = nextPopupX + popupWidth;
|
|
}
|
|
syncNextPopupPosition();
|
|
|
|
// >>>>>>>>>> Top & Bottom
|
|
var needAdjustY = supportAdjust(adjustY);
|
|
var sameTB = popupPoints[0] === targetPoints[0];
|
|
|
|
// Bottom to Top
|
|
if (needAdjustY && popupPoints[0] === 't' && (nextPopupBottom > adjustCheckVisibleArea.bottom || prevFlipRef.current.bt)) {
|
|
var tmpNextOffsetY = nextOffsetY;
|
|
if (sameTB) {
|
|
tmpNextOffsetY -= popupHeight - targetHeight;
|
|
} else {
|
|
tmpNextOffsetY = targetAlignPointTL.y - popupAlignPointBR.y - popupOffsetY;
|
|
}
|
|
var newVisibleArea = getIntersectionVisibleArea(nextOffsetX, tmpNextOffsetY);
|
|
var newVisibleRecommendArea = getIntersectionVisibleArea(nextOffsetX, tmpNextOffsetY, visibleRegionArea);
|
|
if (
|
|
// Of course use larger one
|
|
newVisibleArea > originIntersectionVisibleArea || newVisibleArea === originIntersectionVisibleArea && (!isVisibleFirst ||
|
|
// Choose recommend one
|
|
newVisibleRecommendArea >= originIntersectionRecommendArea)) {
|
|
prevFlipRef.current.bt = true;
|
|
nextOffsetY = tmpNextOffsetY;
|
|
popupOffsetY = -popupOffsetY;
|
|
nextAlignInfo.points = [reversePoints(popupPoints, 0), reversePoints(targetPoints, 0)];
|
|
} else {
|
|
prevFlipRef.current.bt = false;
|
|
}
|
|
}
|
|
|
|
// Top to Bottom
|
|
if (needAdjustY && popupPoints[0] === 'b' && (nextPopupY < adjustCheckVisibleArea.top || prevFlipRef.current.tb)) {
|
|
var _tmpNextOffsetY = nextOffsetY;
|
|
if (sameTB) {
|
|
_tmpNextOffsetY += popupHeight - targetHeight;
|
|
} else {
|
|
_tmpNextOffsetY = targetAlignPointBR.y - popupAlignPointTL.y - popupOffsetY;
|
|
}
|
|
var _newVisibleArea = getIntersectionVisibleArea(nextOffsetX, _tmpNextOffsetY);
|
|
var _newVisibleRecommendArea = getIntersectionVisibleArea(nextOffsetX, _tmpNextOffsetY, visibleRegionArea);
|
|
if (
|
|
// Of course use larger one
|
|
_newVisibleArea > originIntersectionVisibleArea || _newVisibleArea === originIntersectionVisibleArea && (!isVisibleFirst ||
|
|
// Choose recommend one
|
|
_newVisibleRecommendArea >= originIntersectionRecommendArea)) {
|
|
prevFlipRef.current.tb = true;
|
|
nextOffsetY = _tmpNextOffsetY;
|
|
popupOffsetY = -popupOffsetY;
|
|
nextAlignInfo.points = [reversePoints(popupPoints, 0), reversePoints(targetPoints, 0)];
|
|
} else {
|
|
prevFlipRef.current.tb = false;
|
|
}
|
|
}
|
|
|
|
// >>>>>>>>>> Left & Right
|
|
var needAdjustX = supportAdjust(adjustX);
|
|
|
|
// >>>>> Flip
|
|
var sameLR = popupPoints[1] === targetPoints[1];
|
|
|
|
// Right to Left
|
|
if (needAdjustX && popupPoints[1] === 'l' && (nextPopupRight > adjustCheckVisibleArea.right || prevFlipRef.current.rl)) {
|
|
var tmpNextOffsetX = nextOffsetX;
|
|
if (sameLR) {
|
|
tmpNextOffsetX -= popupWidth - targetWidth;
|
|
} else {
|
|
tmpNextOffsetX = targetAlignPointTL.x - popupAlignPointBR.x - popupOffsetX;
|
|
}
|
|
var _newVisibleArea2 = getIntersectionVisibleArea(tmpNextOffsetX, nextOffsetY);
|
|
var _newVisibleRecommendArea2 = getIntersectionVisibleArea(tmpNextOffsetX, nextOffsetY, visibleRegionArea);
|
|
if (
|
|
// Of course use larger one
|
|
_newVisibleArea2 > originIntersectionVisibleArea || _newVisibleArea2 === originIntersectionVisibleArea && (!isVisibleFirst ||
|
|
// Choose recommend one
|
|
_newVisibleRecommendArea2 >= originIntersectionRecommendArea)) {
|
|
prevFlipRef.current.rl = true;
|
|
nextOffsetX = tmpNextOffsetX;
|
|
popupOffsetX = -popupOffsetX;
|
|
nextAlignInfo.points = [reversePoints(popupPoints, 1), reversePoints(targetPoints, 1)];
|
|
} else {
|
|
prevFlipRef.current.rl = false;
|
|
}
|
|
}
|
|
|
|
// Left to Right
|
|
if (needAdjustX && popupPoints[1] === 'r' && (nextPopupX < adjustCheckVisibleArea.left || prevFlipRef.current.lr)) {
|
|
var _tmpNextOffsetX = nextOffsetX;
|
|
if (sameLR) {
|
|
_tmpNextOffsetX += popupWidth - targetWidth;
|
|
} else {
|
|
_tmpNextOffsetX = targetAlignPointBR.x - popupAlignPointTL.x - popupOffsetX;
|
|
}
|
|
var _newVisibleArea3 = getIntersectionVisibleArea(_tmpNextOffsetX, nextOffsetY);
|
|
var _newVisibleRecommendArea3 = getIntersectionVisibleArea(_tmpNextOffsetX, nextOffsetY, visibleRegionArea);
|
|
if (
|
|
// Of course use larger one
|
|
_newVisibleArea3 > originIntersectionVisibleArea || _newVisibleArea3 === originIntersectionVisibleArea && (!isVisibleFirst ||
|
|
// Choose recommend one
|
|
_newVisibleRecommendArea3 >= originIntersectionRecommendArea)) {
|
|
prevFlipRef.current.lr = true;
|
|
nextOffsetX = _tmpNextOffsetX;
|
|
popupOffsetX = -popupOffsetX;
|
|
nextAlignInfo.points = [reversePoints(popupPoints, 1), reversePoints(targetPoints, 1)];
|
|
} else {
|
|
prevFlipRef.current.lr = false;
|
|
}
|
|
}
|
|
|
|
// ============================ Shift ============================
|
|
syncNextPopupPosition();
|
|
var numShiftX = shiftX === true ? 0 : shiftX;
|
|
if (typeof numShiftX === 'number') {
|
|
// Left
|
|
if (nextPopupX < visibleRegionArea.left) {
|
|
nextOffsetX -= nextPopupX - visibleRegionArea.left - popupOffsetX;
|
|
if (targetRect.x + targetWidth < visibleRegionArea.left + numShiftX) {
|
|
nextOffsetX += targetRect.x - visibleRegionArea.left + targetWidth - numShiftX;
|
|
}
|
|
}
|
|
|
|
// Right
|
|
if (nextPopupRight > visibleRegionArea.right) {
|
|
nextOffsetX -= nextPopupRight - visibleRegionArea.right - popupOffsetX;
|
|
if (targetRect.x > visibleRegionArea.right - numShiftX) {
|
|
nextOffsetX += targetRect.x - visibleRegionArea.right + numShiftX;
|
|
}
|
|
}
|
|
}
|
|
var numShiftY = shiftY === true ? 0 : shiftY;
|
|
if (typeof numShiftY === 'number') {
|
|
// Top
|
|
if (nextPopupY < visibleRegionArea.top) {
|
|
nextOffsetY -= nextPopupY - visibleRegionArea.top - popupOffsetY;
|
|
|
|
// When target if far away from visible area
|
|
// Stop shift
|
|
if (targetRect.y + targetHeight < visibleRegionArea.top + numShiftY) {
|
|
nextOffsetY += targetRect.y - visibleRegionArea.top + targetHeight - numShiftY;
|
|
}
|
|
}
|
|
|
|
// Bottom
|
|
if (nextPopupBottom > visibleRegionArea.bottom) {
|
|
nextOffsetY -= nextPopupBottom - visibleRegionArea.bottom - popupOffsetY;
|
|
if (targetRect.y > visibleRegionArea.bottom - numShiftY) {
|
|
nextOffsetY += targetRect.y - visibleRegionArea.bottom + numShiftY;
|
|
}
|
|
}
|
|
}
|
|
|
|
// ============================ Arrow ============================
|
|
// Arrow center align
|
|
var popupLeft = popupRect.x + nextOffsetX;
|
|
var popupRight = popupLeft + popupWidth;
|
|
var popupTop = popupRect.y + nextOffsetY;
|
|
var popupBottom = popupTop + popupHeight;
|
|
var targetLeft = targetRect.x;
|
|
var targetRight = targetLeft + targetWidth;
|
|
var targetTop = targetRect.y;
|
|
var targetBottom = targetTop + targetHeight;
|
|
var maxLeft = Math.max(popupLeft, targetLeft);
|
|
var minRight = Math.min(popupRight, targetRight);
|
|
var xCenter = (maxLeft + minRight) / 2;
|
|
var nextArrowX = xCenter - popupLeft;
|
|
var maxTop = Math.max(popupTop, targetTop);
|
|
var minBottom = Math.min(popupBottom, targetBottom);
|
|
var yCenter = (maxTop + minBottom) / 2;
|
|
var nextArrowY = yCenter - popupTop;
|
|
onPopupAlign === null || onPopupAlign === void 0 || onPopupAlign(popupEle, nextAlignInfo);
|
|
|
|
// Additional calculate right & bottom position
|
|
var offsetX4Right = popupMirrorRect.right - popupRect.x - (nextOffsetX + popupRect.width);
|
|
var offsetY4Bottom = popupMirrorRect.bottom - popupRect.y - (nextOffsetY + popupRect.height);
|
|
setOffsetInfo({
|
|
ready: true,
|
|
offsetX: nextOffsetX / _scaleX,
|
|
offsetY: nextOffsetY / _scaleY,
|
|
offsetR: offsetX4Right / _scaleX,
|
|
offsetB: offsetY4Bottom / _scaleY,
|
|
arrowX: nextArrowX / _scaleX,
|
|
arrowY: nextArrowY / _scaleY,
|
|
scaleX: _scaleX,
|
|
scaleY: _scaleY,
|
|
align: nextAlignInfo
|
|
});
|
|
}
|
|
});
|
|
var triggerAlign = function triggerAlign() {
|
|
alignCountRef.current += 1;
|
|
var id = alignCountRef.current;
|
|
|
|
// Merge all align requirement into one frame
|
|
Promise.resolve().then(function () {
|
|
if (alignCountRef.current === id) {
|
|
onAlign();
|
|
}
|
|
});
|
|
};
|
|
|
|
// Reset ready status when placement & open changed
|
|
var resetReady = function resetReady() {
|
|
setOffsetInfo(function (ori) {
|
|
return (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, ori), {}, {
|
|
ready: false
|
|
});
|
|
});
|
|
};
|
|
(0,useLayoutEffect/* default */.Z)(resetReady, [placement]);
|
|
(0,useLayoutEffect/* default */.Z)(function () {
|
|
if (!open) {
|
|
resetReady();
|
|
}
|
|
}, [open]);
|
|
return [offsetInfo.ready, offsetInfo.offsetX, offsetInfo.offsetY, offsetInfo.offsetR, offsetInfo.offsetB, offsetInfo.arrowX, offsetInfo.arrowY, offsetInfo.scaleX, offsetInfo.scaleY, offsetInfo.align, triggerAlign];
|
|
}
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.27.6@@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
|
|
var toConsumableArray = __webpack_require__(95190);
|
|
;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.18.3@@rc-component/trigger/es/hooks/useWatch.js
|
|
|
|
|
|
|
|
function useWatch(open, target, popup, onAlign, onScroll) {
|
|
(0,useLayoutEffect/* default */.Z)(function () {
|
|
if (open && target && popup) {
|
|
var targetElement = target;
|
|
var popupElement = popup;
|
|
var targetScrollList = collectScroller(targetElement);
|
|
var popupScrollList = collectScroller(popupElement);
|
|
var win = getWin(popupElement);
|
|
var mergedList = new Set([win].concat((0,toConsumableArray/* default */.Z)(targetScrollList), (0,toConsumableArray/* default */.Z)(popupScrollList)));
|
|
function notifyScroll() {
|
|
onAlign();
|
|
onScroll();
|
|
}
|
|
mergedList.forEach(function (scroller) {
|
|
scroller.addEventListener('scroll', notifyScroll, {
|
|
passive: true
|
|
});
|
|
});
|
|
win.addEventListener('resize', notifyScroll, {
|
|
passive: true
|
|
});
|
|
|
|
// First time always do align
|
|
onAlign();
|
|
return function () {
|
|
mergedList.forEach(function (scroller) {
|
|
scroller.removeEventListener('scroll', notifyScroll);
|
|
win.removeEventListener('resize', notifyScroll);
|
|
});
|
|
};
|
|
}
|
|
}, [open, target, popup]);
|
|
}
|
|
// EXTERNAL MODULE: ./node_modules/_rc-util@5.44.4@rc-util/es/warning.js
|
|
var warning = __webpack_require__(48736);
|
|
// EXTERNAL MODULE: ./node_modules/_rc-util@5.44.4@rc-util/es/raf.js
|
|
var raf = __webpack_require__(16089);
|
|
;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.18.3@@rc-component/trigger/es/hooks/useWinClick.js
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function useWinClick(open, clickToHide, targetEle, popupEle, mask, maskClosable, inPopupOrChild, triggerOpen) {
|
|
var openRef = _react_17_0_2_react.useRef(open);
|
|
|
|
// Window click to hide should be lock to avoid trigger lock immediately
|
|
var lockRef = _react_17_0_2_react.useRef(false);
|
|
if (openRef.current !== open) {
|
|
lockRef.current = true;
|
|
openRef.current = open;
|
|
}
|
|
_react_17_0_2_react.useEffect(function () {
|
|
var id = (0,raf/* default */.Z)(function () {
|
|
lockRef.current = false;
|
|
});
|
|
return function () {
|
|
raf/* default */.Z.cancel(id);
|
|
};
|
|
}, [open]);
|
|
|
|
// Click to hide is special action since click popup element should not hide
|
|
_react_17_0_2_react.useEffect(function () {
|
|
if (clickToHide && popupEle && (!mask || maskClosable)) {
|
|
var genClickEvents = function genClickEvents() {
|
|
var clickInside = false;
|
|
|
|
// User may mouseDown inside and drag out of popup and mouse up
|
|
// Record here to prevent close
|
|
var onWindowMouseDown = function onWindowMouseDown(_ref) {
|
|
var target = _ref.target;
|
|
clickInside = inPopupOrChild(target);
|
|
};
|
|
var onWindowClick = function onWindowClick(_ref2) {
|
|
var target = _ref2.target;
|
|
if (!lockRef.current && openRef.current && !clickInside && !inPopupOrChild(target)) {
|
|
triggerOpen(false);
|
|
}
|
|
};
|
|
return [onWindowMouseDown, onWindowClick];
|
|
};
|
|
|
|
// Events
|
|
var _genClickEvents = genClickEvents(),
|
|
_genClickEvents2 = (0,slicedToArray/* default */.Z)(_genClickEvents, 2),
|
|
onWinMouseDown = _genClickEvents2[0],
|
|
onWinClick = _genClickEvents2[1];
|
|
var _genClickEvents3 = genClickEvents(),
|
|
_genClickEvents4 = (0,slicedToArray/* default */.Z)(_genClickEvents3, 2),
|
|
onShadowMouseDown = _genClickEvents4[0],
|
|
onShadowClick = _genClickEvents4[1];
|
|
var win = getWin(popupEle);
|
|
win.addEventListener('mousedown', onWinMouseDown, true);
|
|
win.addEventListener('click', onWinClick, true);
|
|
win.addEventListener('contextmenu', onWinClick, true);
|
|
|
|
// shadow root
|
|
var targetShadowRoot = (0,shadow/* getShadowRoot */.A)(targetEle);
|
|
if (targetShadowRoot) {
|
|
targetShadowRoot.addEventListener('mousedown', onShadowMouseDown, true);
|
|
targetShadowRoot.addEventListener('click', onShadowClick, true);
|
|
targetShadowRoot.addEventListener('contextmenu', onShadowClick, true);
|
|
}
|
|
|
|
// Warning if target and popup not in same root
|
|
if (false) { var popupRoot, targetRoot, _targetEle$getRootNod, _popupEle$getRootNode; }
|
|
return function () {
|
|
win.removeEventListener('mousedown', onWinMouseDown, true);
|
|
win.removeEventListener('click', onWinClick, true);
|
|
win.removeEventListener('contextmenu', onWinClick, true);
|
|
if (targetShadowRoot) {
|
|
targetShadowRoot.removeEventListener('mousedown', onShadowMouseDown, true);
|
|
targetShadowRoot.removeEventListener('click', onShadowClick, true);
|
|
targetShadowRoot.removeEventListener('contextmenu', onShadowClick, true);
|
|
}
|
|
};
|
|
}
|
|
}, [clickToHide, targetEle, popupEle, mask, maskClosable]);
|
|
}
|
|
;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.18.3@@rc-component/trigger/es/index.js
|
|
|
|
|
|
|
|
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"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Removed Props List
|
|
// Seems this can be auto
|
|
// getDocument?: (element?: HTMLElement) => Document;
|
|
|
|
// New version will not wrap popup with `rc-trigger-popup-content` when multiple children
|
|
|
|
function generateTrigger() {
|
|
var PortalComponent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : es/* default */.Z;
|
|
var Trigger = /*#__PURE__*/_react_17_0_2_react.forwardRef(function (props, ref) {
|
|
var _props$prefixCls = props.prefixCls,
|
|
prefixCls = _props$prefixCls === void 0 ? 'rc-trigger-popup' : _props$prefixCls,
|
|
children = props.children,
|
|
_props$action = props.action,
|
|
action = _props$action === void 0 ? 'hover' : _props$action,
|
|
showAction = props.showAction,
|
|
hideAction = props.hideAction,
|
|
popupVisible = props.popupVisible,
|
|
defaultPopupVisible = props.defaultPopupVisible,
|
|
onPopupVisibleChange = props.onPopupVisibleChange,
|
|
afterPopupVisibleChange = props.afterPopupVisibleChange,
|
|
mouseEnterDelay = props.mouseEnterDelay,
|
|
_props$mouseLeaveDela = props.mouseLeaveDelay,
|
|
mouseLeaveDelay = _props$mouseLeaveDela === void 0 ? 0.1 : _props$mouseLeaveDela,
|
|
focusDelay = props.focusDelay,
|
|
blurDelay = props.blurDelay,
|
|
mask = props.mask,
|
|
_props$maskClosable = props.maskClosable,
|
|
maskClosable = _props$maskClosable === void 0 ? true : _props$maskClosable,
|
|
getPopupContainer = props.getPopupContainer,
|
|
forceRender = props.forceRender,
|
|
autoDestroy = props.autoDestroy,
|
|
destroyPopupOnHide = props.destroyPopupOnHide,
|
|
popup = props.popup,
|
|
popupClassName = props.popupClassName,
|
|
popupStyle = props.popupStyle,
|
|
popupPlacement = props.popupPlacement,
|
|
_props$builtinPlaceme = props.builtinPlacements,
|
|
builtinPlacements = _props$builtinPlaceme === void 0 ? {} : _props$builtinPlaceme,
|
|
popupAlign = props.popupAlign,
|
|
zIndex = props.zIndex,
|
|
stretch = props.stretch,
|
|
getPopupClassNameFromAlign = props.getPopupClassNameFromAlign,
|
|
fresh = props.fresh,
|
|
alignPoint = props.alignPoint,
|
|
onPopupClick = props.onPopupClick,
|
|
onPopupAlign = props.onPopupAlign,
|
|
arrow = props.arrow,
|
|
popupMotion = props.popupMotion,
|
|
maskMotion = props.maskMotion,
|
|
popupTransitionName = props.popupTransitionName,
|
|
popupAnimation = props.popupAnimation,
|
|
maskTransitionName = props.maskTransitionName,
|
|
maskAnimation = props.maskAnimation,
|
|
className = props.className,
|
|
getTriggerDOMNode = props.getTriggerDOMNode,
|
|
restProps = (0,objectWithoutProperties/* default */.Z)(props, _excluded);
|
|
var mergedAutoDestroy = autoDestroy || destroyPopupOnHide || false;
|
|
|
|
// =========================== Mobile ===========================
|
|
var _React$useState = _react_17_0_2_react.useState(false),
|
|
_React$useState2 = (0,slicedToArray/* default */.Z)(_React$useState, 2),
|
|
mobile = _React$useState2[0],
|
|
setMobile = _React$useState2[1];
|
|
(0,useLayoutEffect/* default */.Z)(function () {
|
|
setMobile((0,isMobile/* default */.Z)());
|
|
}, []);
|
|
|
|
// ========================== Context ===========================
|
|
var subPopupElements = _react_17_0_2_react.useRef({});
|
|
var parentContext = _react_17_0_2_react.useContext(es_context);
|
|
var context = _react_17_0_2_react.useMemo(function () {
|
|
return {
|
|
registerSubPopup: function registerSubPopup(id, subPopupEle) {
|
|
subPopupElements.current[id] = subPopupEle;
|
|
parentContext === null || parentContext === void 0 || parentContext.registerSubPopup(id, subPopupEle);
|
|
}
|
|
};
|
|
}, [parentContext]);
|
|
|
|
// =========================== Popup ============================
|
|
var id = (0,useId/* default */.Z)();
|
|
var _React$useState3 = _react_17_0_2_react.useState(null),
|
|
_React$useState4 = (0,slicedToArray/* default */.Z)(_React$useState3, 2),
|
|
popupEle = _React$useState4[0],
|
|
setPopupEle = _React$useState4[1];
|
|
var setPopupRef = (0,useEvent/* default */.Z)(function (node) {
|
|
if ((0,findDOMNode/* isDOM */.Sh)(node) && popupEle !== node) {
|
|
setPopupEle(node);
|
|
}
|
|
parentContext === null || parentContext === void 0 || parentContext.registerSubPopup(id, node);
|
|
});
|
|
|
|
// =========================== Target ===========================
|
|
// Use state to control here since `useRef` update not trigger render
|
|
var _React$useState5 = _react_17_0_2_react.useState(null),
|
|
_React$useState6 = (0,slicedToArray/* default */.Z)(_React$useState5, 2),
|
|
targetEle = _React$useState6[0],
|
|
setTargetEle = _React$useState6[1];
|
|
|
|
// Used for forwardRef target. Not use internal
|
|
var externalForwardRef = _react_17_0_2_react.useRef(null);
|
|
var setTargetRef = (0,useEvent/* default */.Z)(function (node) {
|
|
if ((0,findDOMNode/* isDOM */.Sh)(node) && targetEle !== node) {
|
|
setTargetEle(node);
|
|
externalForwardRef.current = node;
|
|
}
|
|
});
|
|
|
|
// ========================== Children ==========================
|
|
var child = _react_17_0_2_react.Children.only(children);
|
|
var originChildProps = (child === null || child === void 0 ? void 0 : child.props) || {};
|
|
var cloneProps = {};
|
|
var inPopupOrChild = (0,useEvent/* default */.Z)(function (ele) {
|
|
var _getShadowRoot, _getShadowRoot2;
|
|
var childDOM = targetEle;
|
|
return (childDOM === null || childDOM === void 0 ? void 0 : childDOM.contains(ele)) || ((_getShadowRoot = (0,shadow/* getShadowRoot */.A)(childDOM)) === null || _getShadowRoot === void 0 ? void 0 : _getShadowRoot.host) === ele || ele === childDOM || (popupEle === null || popupEle === void 0 ? void 0 : popupEle.contains(ele)) || ((_getShadowRoot2 = (0,shadow/* getShadowRoot */.A)(popupEle)) === null || _getShadowRoot2 === void 0 ? void 0 : _getShadowRoot2.host) === ele || ele === popupEle || Object.values(subPopupElements.current).some(function (subPopupEle) {
|
|
return (subPopupEle === null || subPopupEle === void 0 ? void 0 : subPopupEle.contains(ele)) || ele === subPopupEle;
|
|
});
|
|
});
|
|
|
|
// =========================== Motion ===========================
|
|
var mergePopupMotion = getMotion(prefixCls, popupMotion, popupAnimation, popupTransitionName);
|
|
var mergeMaskMotion = getMotion(prefixCls, maskMotion, maskAnimation, maskTransitionName);
|
|
|
|
// ============================ Open ============================
|
|
var _React$useState7 = _react_17_0_2_react.useState(defaultPopupVisible || false),
|
|
_React$useState8 = (0,slicedToArray/* default */.Z)(_React$useState7, 2),
|
|
internalOpen = _React$useState8[0],
|
|
setInternalOpen = _React$useState8[1];
|
|
|
|
// Render still use props as first priority
|
|
var mergedOpen = popupVisible !== null && popupVisible !== void 0 ? popupVisible : internalOpen;
|
|
|
|
// We use effect sync here in case `popupVisible` back to `undefined`
|
|
var setMergedOpen = (0,useEvent/* default */.Z)(function (nextOpen) {
|
|
if (popupVisible === undefined) {
|
|
setInternalOpen(nextOpen);
|
|
}
|
|
});
|
|
(0,useLayoutEffect/* default */.Z)(function () {
|
|
setInternalOpen(popupVisible || false);
|
|
}, [popupVisible]);
|
|
var openRef = _react_17_0_2_react.useRef(mergedOpen);
|
|
openRef.current = mergedOpen;
|
|
var lastTriggerRef = _react_17_0_2_react.useRef([]);
|
|
lastTriggerRef.current = [];
|
|
var internalTriggerOpen = (0,useEvent/* default */.Z)(function (nextOpen) {
|
|
var _lastTriggerRef$curre;
|
|
setMergedOpen(nextOpen);
|
|
|
|
// Enter or Pointer will both trigger open state change
|
|
// We only need take one to avoid duplicated change event trigger
|
|
// Use `lastTriggerRef` to record last open type
|
|
if (((_lastTriggerRef$curre = lastTriggerRef.current[lastTriggerRef.current.length - 1]) !== null && _lastTriggerRef$curre !== void 0 ? _lastTriggerRef$curre : mergedOpen) !== nextOpen) {
|
|
lastTriggerRef.current.push(nextOpen);
|
|
onPopupVisibleChange === null || onPopupVisibleChange === void 0 || onPopupVisibleChange(nextOpen);
|
|
}
|
|
});
|
|
|
|
// Trigger for delay
|
|
var delayRef = _react_17_0_2_react.useRef();
|
|
var clearDelay = function clearDelay() {
|
|
clearTimeout(delayRef.current);
|
|
};
|
|
var triggerOpen = function triggerOpen(nextOpen) {
|
|
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
clearDelay();
|
|
if (delay === 0) {
|
|
internalTriggerOpen(nextOpen);
|
|
} else {
|
|
delayRef.current = setTimeout(function () {
|
|
internalTriggerOpen(nextOpen);
|
|
}, delay * 1000);
|
|
}
|
|
};
|
|
_react_17_0_2_react.useEffect(function () {
|
|
return clearDelay;
|
|
}, []);
|
|
|
|
// ========================== Motion ============================
|
|
var _React$useState9 = _react_17_0_2_react.useState(false),
|
|
_React$useState10 = (0,slicedToArray/* default */.Z)(_React$useState9, 2),
|
|
inMotion = _React$useState10[0],
|
|
setInMotion = _React$useState10[1];
|
|
(0,useLayoutEffect/* default */.Z)(function (firstMount) {
|
|
if (!firstMount || mergedOpen) {
|
|
setInMotion(true);
|
|
}
|
|
}, [mergedOpen]);
|
|
var _React$useState11 = _react_17_0_2_react.useState(null),
|
|
_React$useState12 = (0,slicedToArray/* default */.Z)(_React$useState11, 2),
|
|
motionPrepareResolve = _React$useState12[0],
|
|
setMotionPrepareResolve = _React$useState12[1];
|
|
|
|
// =========================== Align ============================
|
|
var _React$useState13 = _react_17_0_2_react.useState([0, 0]),
|
|
_React$useState14 = (0,slicedToArray/* default */.Z)(_React$useState13, 2),
|
|
mousePos = _React$useState14[0],
|
|
setMousePos = _React$useState14[1];
|
|
var setMousePosByEvent = function setMousePosByEvent(event) {
|
|
setMousePos([event.clientX, event.clientY]);
|
|
};
|
|
var _useAlign = useAlign(mergedOpen, popupEle, alignPoint ? mousePos : targetEle, popupPlacement, builtinPlacements, popupAlign, onPopupAlign),
|
|
_useAlign2 = (0,slicedToArray/* default */.Z)(_useAlign, 11),
|
|
ready = _useAlign2[0],
|
|
offsetX = _useAlign2[1],
|
|
offsetY = _useAlign2[2],
|
|
offsetR = _useAlign2[3],
|
|
offsetB = _useAlign2[4],
|
|
arrowX = _useAlign2[5],
|
|
arrowY = _useAlign2[6],
|
|
scaleX = _useAlign2[7],
|
|
scaleY = _useAlign2[8],
|
|
alignInfo = _useAlign2[9],
|
|
onAlign = _useAlign2[10];
|
|
var _useAction = useAction(mobile, action, showAction, hideAction),
|
|
_useAction2 = (0,slicedToArray/* default */.Z)(_useAction, 2),
|
|
showActions = _useAction2[0],
|
|
hideActions = _useAction2[1];
|
|
var clickToShow = showActions.has('click');
|
|
var clickToHide = hideActions.has('click') || hideActions.has('contextMenu');
|
|
var triggerAlign = (0,useEvent/* default */.Z)(function () {
|
|
if (!inMotion) {
|
|
onAlign();
|
|
}
|
|
});
|
|
var onScroll = function onScroll() {
|
|
if (openRef.current && alignPoint && clickToHide) {
|
|
triggerOpen(false);
|
|
}
|
|
};
|
|
useWatch(mergedOpen, targetEle, popupEle, triggerAlign, onScroll);
|
|
(0,useLayoutEffect/* default */.Z)(function () {
|
|
triggerAlign();
|
|
}, [mousePos, popupPlacement]);
|
|
|
|
// When no builtinPlacements and popupAlign changed
|
|
(0,useLayoutEffect/* default */.Z)(function () {
|
|
if (mergedOpen && !(builtinPlacements !== null && builtinPlacements !== void 0 && builtinPlacements[popupPlacement])) {
|
|
triggerAlign();
|
|
}
|
|
}, [JSON.stringify(popupAlign)]);
|
|
var alignedClassName = _react_17_0_2_react.useMemo(function () {
|
|
var baseClassName = getAlignPopupClassName(builtinPlacements, prefixCls, alignInfo, alignPoint);
|
|
return _classnames_2_5_1_classnames_default()(baseClassName, getPopupClassNameFromAlign === null || getPopupClassNameFromAlign === void 0 ? void 0 : getPopupClassNameFromAlign(alignInfo));
|
|
}, [alignInfo, getPopupClassNameFromAlign, builtinPlacements, prefixCls, alignPoint]);
|
|
|
|
// ============================ Refs ============================
|
|
_react_17_0_2_react.useImperativeHandle(ref, function () {
|
|
return {
|
|
nativeElement: externalForwardRef.current,
|
|
forceAlign: triggerAlign
|
|
};
|
|
});
|
|
|
|
// ========================== Stretch ===========================
|
|
var _React$useState15 = _react_17_0_2_react.useState(0),
|
|
_React$useState16 = (0,slicedToArray/* default */.Z)(_React$useState15, 2),
|
|
targetWidth = _React$useState16[0],
|
|
setTargetWidth = _React$useState16[1];
|
|
var _React$useState17 = _react_17_0_2_react.useState(0),
|
|
_React$useState18 = (0,slicedToArray/* default */.Z)(_React$useState17, 2),
|
|
targetHeight = _React$useState18[0],
|
|
setTargetHeight = _React$useState18[1];
|
|
var syncTargetSize = function syncTargetSize() {
|
|
if (stretch && targetEle) {
|
|
var rect = targetEle.getBoundingClientRect();
|
|
setTargetWidth(rect.width);
|
|
setTargetHeight(rect.height);
|
|
}
|
|
};
|
|
var onTargetResize = function onTargetResize() {
|
|
syncTargetSize();
|
|
triggerAlign();
|
|
};
|
|
|
|
// ========================== Motion ============================
|
|
var onVisibleChanged = function onVisibleChanged(visible) {
|
|
setInMotion(false);
|
|
onAlign();
|
|
afterPopupVisibleChange === null || afterPopupVisibleChange === void 0 || afterPopupVisibleChange(visible);
|
|
};
|
|
|
|
// We will trigger align when motion is in prepare
|
|
var onPrepare = function onPrepare() {
|
|
return new Promise(function (resolve) {
|
|
syncTargetSize();
|
|
setMotionPrepareResolve(function () {
|
|
return resolve;
|
|
});
|
|
});
|
|
};
|
|
(0,useLayoutEffect/* default */.Z)(function () {
|
|
if (motionPrepareResolve) {
|
|
onAlign();
|
|
motionPrepareResolve();
|
|
setMotionPrepareResolve(null);
|
|
}
|
|
}, [motionPrepareResolve]);
|
|
|
|
// =========================== Action ===========================
|
|
/**
|
|
* Util wrapper for trigger action
|
|
*/
|
|
function wrapperAction(eventName, nextOpen, delay, preEvent) {
|
|
cloneProps[eventName] = function (event) {
|
|
var _originChildProps$eve;
|
|
preEvent === null || preEvent === void 0 || preEvent(event);
|
|
triggerOpen(nextOpen, delay);
|
|
|
|
// Pass to origin
|
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
args[_key - 1] = arguments[_key];
|
|
}
|
|
(_originChildProps$eve = originChildProps[eventName]) === null || _originChildProps$eve === void 0 || _originChildProps$eve.call.apply(_originChildProps$eve, [originChildProps, event].concat(args));
|
|
};
|
|
}
|
|
|
|
// ======================= Action: Click ========================
|
|
if (clickToShow || clickToHide) {
|
|
cloneProps.onClick = function (event) {
|
|
var _originChildProps$onC;
|
|
if (openRef.current && clickToHide) {
|
|
triggerOpen(false);
|
|
} else if (!openRef.current && clickToShow) {
|
|
setMousePosByEvent(event);
|
|
triggerOpen(true);
|
|
}
|
|
|
|
// Pass to origin
|
|
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
args[_key2 - 1] = arguments[_key2];
|
|
}
|
|
(_originChildProps$onC = originChildProps.onClick) === null || _originChildProps$onC === void 0 || _originChildProps$onC.call.apply(_originChildProps$onC, [originChildProps, event].concat(args));
|
|
};
|
|
}
|
|
|
|
// Click to hide is special action since click popup element should not hide
|
|
useWinClick(mergedOpen, clickToHide, targetEle, popupEle, mask, maskClosable, inPopupOrChild, triggerOpen);
|
|
|
|
// ======================= Action: Hover ========================
|
|
var hoverToShow = showActions.has('hover');
|
|
var hoverToHide = hideActions.has('hover');
|
|
var onPopupMouseEnter;
|
|
var onPopupMouseLeave;
|
|
if (hoverToShow) {
|
|
// Compatible with old browser which not support pointer event
|
|
wrapperAction('onMouseEnter', true, mouseEnterDelay, function (event) {
|
|
setMousePosByEvent(event);
|
|
});
|
|
wrapperAction('onPointerEnter', true, mouseEnterDelay, function (event) {
|
|
setMousePosByEvent(event);
|
|
});
|
|
onPopupMouseEnter = function onPopupMouseEnter(event) {
|
|
// Only trigger re-open when popup is visible
|
|
if ((mergedOpen || inMotion) && popupEle !== null && popupEle !== void 0 && popupEle.contains(event.target)) {
|
|
triggerOpen(true, mouseEnterDelay);
|
|
}
|
|
};
|
|
|
|
// Align Point
|
|
if (alignPoint) {
|
|
cloneProps.onMouseMove = function (event) {
|
|
var _originChildProps$onM;
|
|
// setMousePosByEvent(event);
|
|
(_originChildProps$onM = originChildProps.onMouseMove) === null || _originChildProps$onM === void 0 || _originChildProps$onM.call(originChildProps, event);
|
|
};
|
|
}
|
|
}
|
|
if (hoverToHide) {
|
|
wrapperAction('onMouseLeave', false, mouseLeaveDelay);
|
|
wrapperAction('onPointerLeave', false, mouseLeaveDelay);
|
|
onPopupMouseLeave = function onPopupMouseLeave() {
|
|
triggerOpen(false, mouseLeaveDelay);
|
|
};
|
|
}
|
|
|
|
// ======================= Action: Focus ========================
|
|
if (showActions.has('focus')) {
|
|
wrapperAction('onFocus', true, focusDelay);
|
|
}
|
|
if (hideActions.has('focus')) {
|
|
wrapperAction('onBlur', false, blurDelay);
|
|
}
|
|
|
|
// ==================== Action: ContextMenu =====================
|
|
if (showActions.has('contextMenu')) {
|
|
cloneProps.onContextMenu = function (event) {
|
|
var _originChildProps$onC2;
|
|
if (openRef.current && hideActions.has('contextMenu')) {
|
|
triggerOpen(false);
|
|
} else {
|
|
setMousePosByEvent(event);
|
|
triggerOpen(true);
|
|
}
|
|
event.preventDefault();
|
|
|
|
// Pass to origin
|
|
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
args[_key3 - 1] = arguments[_key3];
|
|
}
|
|
(_originChildProps$onC2 = originChildProps.onContextMenu) === null || _originChildProps$onC2 === void 0 || _originChildProps$onC2.call.apply(_originChildProps$onC2, [originChildProps, event].concat(args));
|
|
};
|
|
}
|
|
|
|
// ========================= ClassName ==========================
|
|
if (className) {
|
|
cloneProps.className = _classnames_2_5_1_classnames_default()(originChildProps.className, className);
|
|
}
|
|
|
|
// =========================== Render ===========================
|
|
var mergedChildrenProps = (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, originChildProps), cloneProps);
|
|
|
|
// Pass props into cloneProps for nest usage
|
|
var passedProps = {};
|
|
var passedEventList = ['onContextMenu', 'onClick', 'onMouseDown', 'onTouchStart', 'onMouseEnter', 'onMouseLeave', 'onFocus', 'onBlur'];
|
|
passedEventList.forEach(function (eventName) {
|
|
if (restProps[eventName]) {
|
|
passedProps[eventName] = function () {
|
|
var _mergedChildrenProps$;
|
|
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
args[_key4] = arguments[_key4];
|
|
}
|
|
(_mergedChildrenProps$ = mergedChildrenProps[eventName]) === null || _mergedChildrenProps$ === void 0 || _mergedChildrenProps$.call.apply(_mergedChildrenProps$, [mergedChildrenProps].concat(args));
|
|
restProps[eventName].apply(restProps, args);
|
|
};
|
|
}
|
|
});
|
|
|
|
// Child Node
|
|
var triggerNode = /*#__PURE__*/_react_17_0_2_react.cloneElement(child, (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, mergedChildrenProps), passedProps));
|
|
var arrowPos = {
|
|
x: arrowX,
|
|
y: arrowY
|
|
};
|
|
var innerArrow = arrow ? (0,objectSpread2/* default */.Z)({}, arrow !== true ? arrow : {}) : null;
|
|
|
|
// Render
|
|
return /*#__PURE__*/_react_17_0_2_react.createElement(_react_17_0_2_react.Fragment, null, /*#__PURE__*/_react_17_0_2_react.createElement(_rc_resize_observer_1_4_3_rc_resize_observer_es/* default */.Z, {
|
|
disabled: !mergedOpen,
|
|
ref: setTargetRef,
|
|
onResize: onTargetResize
|
|
}, /*#__PURE__*/_react_17_0_2_react.createElement(es_TriggerWrapper, {
|
|
getTriggerDOMNode: getTriggerDOMNode
|
|
}, triggerNode)), /*#__PURE__*/_react_17_0_2_react.createElement(es_context.Provider, {
|
|
value: context
|
|
}, /*#__PURE__*/_react_17_0_2_react.createElement(es_Popup, {
|
|
portal: PortalComponent,
|
|
ref: setPopupRef,
|
|
prefixCls: prefixCls,
|
|
popup: popup,
|
|
className: _classnames_2_5_1_classnames_default()(popupClassName, alignedClassName),
|
|
style: popupStyle,
|
|
target: targetEle,
|
|
onMouseEnter: onPopupMouseEnter,
|
|
onMouseLeave: onPopupMouseLeave
|
|
// https://github.com/ant-design/ant-design/issues/43924
|
|
,
|
|
onPointerEnter: onPopupMouseEnter,
|
|
zIndex: zIndex
|
|
// Open
|
|
,
|
|
open: mergedOpen,
|
|
keepDom: inMotion,
|
|
fresh: fresh
|
|
// Click
|
|
,
|
|
onClick: onPopupClick
|
|
// Mask
|
|
,
|
|
mask: mask
|
|
// Motion
|
|
,
|
|
motion: mergePopupMotion,
|
|
maskMotion: mergeMaskMotion,
|
|
onVisibleChanged: onVisibleChanged,
|
|
onPrepare: onPrepare
|
|
// Portal
|
|
,
|
|
forceRender: forceRender,
|
|
autoDestroy: mergedAutoDestroy,
|
|
getPopupContainer: getPopupContainer
|
|
// Arrow
|
|
,
|
|
align: alignInfo,
|
|
arrow: innerArrow,
|
|
arrowPos: arrowPos
|
|
// Align
|
|
,
|
|
ready: ready,
|
|
offsetX: offsetX,
|
|
offsetY: offsetY,
|
|
offsetR: offsetR,
|
|
offsetB: offsetB,
|
|
onAlign: triggerAlign
|
|
// Stretch
|
|
,
|
|
stretch: stretch,
|
|
targetWidth: targetWidth / scaleX,
|
|
targetHeight: targetHeight / scaleY
|
|
})));
|
|
});
|
|
if (false) {}
|
|
return Trigger;
|
|
}
|
|
/* harmony default export */ var trigger_es = (generateTrigger(es/* default */.Z));
|
|
|
|
/***/ }),
|
|
|
|
/***/ 49658:
|
|
/*!*************************************************************!*\
|
|
!*** ./node_modules/_rc-util@5.44.4@rc-util/es/isMobile.js ***!
|
|
\*************************************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__) {
|
|
|
|
/* harmony default export */ __webpack_exports__.Z = (function () {
|
|
if (typeof navigator === 'undefined' || typeof window === 'undefined') {
|
|
return false;
|
|
}
|
|
var agent = navigator.userAgent || navigator.vendor || window.opera;
|
|
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(agent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(agent === null || agent === void 0 ? void 0 : agent.substr(0, 4));
|
|
});
|
|
|
|
/***/ })
|
|
|
|
}]); |