diff --git a/19284.async.js b/19284.async.js index b389d75633..125f86d792 100644 --- a/19284.async.js +++ b/19284.async.js @@ -690,8 +690,8 @@ var defineProperty = __webpack_require__(80268); var slicedToArray = __webpack_require__(39718); // EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/esm/objectWithoutProperties.js var objectWithoutProperties = __webpack_require__(26779); -// EXTERNAL MODULE: ./node_modules/_@rc-component_trigger@1.17.2@@rc-component/trigger/es/index.js + 11 modules -var es = __webpack_require__(88246); +// EXTERNAL MODULE: ./node_modules/_@rc-component_trigger@1.18.0@@rc-component/trigger/es/index.js + 11 modules +var es = __webpack_require__(34666); // EXTERNAL MODULE: ./node_modules/_classnames@2.3.2@classnames/index.js var _classnames_2_3_2_classnames = __webpack_require__(12124); var _classnames_2_3_2_classnames_default = /*#__PURE__*/__webpack_require__.n(_classnames_2_3_2_classnames); diff --git a/2015.async.js b/2015.async.js index 7df6c10f27..db2fe724f9 100644 --- a/2015.async.js +++ b/2015.async.js @@ -1592,8 +1592,8 @@ var defineProperty = __webpack_require__(80268); var slicedToArray = __webpack_require__(39718); // EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/esm/objectWithoutProperties.js var objectWithoutProperties = __webpack_require__(26779); -// EXTERNAL MODULE: ./node_modules/_@rc-component_trigger@1.17.2@@rc-component/trigger/es/index.js + 11 modules -var es = __webpack_require__(88246); +// EXTERNAL MODULE: ./node_modules/_@rc-component_trigger@1.18.0@@rc-component/trigger/es/index.js + 11 modules +var es = __webpack_require__(34666); // EXTERNAL MODULE: ./node_modules/_classnames@2.3.2@classnames/index.js var _classnames_2_3_2_classnames = __webpack_require__(12124); var _classnames_2_3_2_classnames_default = /*#__PURE__*/__webpack_require__.n(_classnames_2_3_2_classnames); diff --git a/24908.async.js b/24908.async.js index 58cfaee838..faaa8c771d 100644 --- a/24908.async.js +++ b/24908.async.js @@ -1898,8 +1898,8 @@ var defineProperty = __webpack_require__(80268); var slicedToArray = __webpack_require__(39718); // EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/esm/objectWithoutProperties.js var objectWithoutProperties = __webpack_require__(26779); -// EXTERNAL MODULE: ./node_modules/_@rc-component_trigger@1.17.2@@rc-component/trigger/es/index.js + 11 modules -var es = __webpack_require__(88246); +// EXTERNAL MODULE: ./node_modules/_@rc-component_trigger@1.18.0@@rc-component/trigger/es/index.js + 11 modules +var es = __webpack_require__(34666); // EXTERNAL MODULE: ./node_modules/_classnames@2.3.2@classnames/index.js var _classnames_2_3_2_classnames = __webpack_require__(12124); var _classnames_2_3_2_classnames_default = /*#__PURE__*/__webpack_require__.n(_classnames_2_3_2_classnames); diff --git a/88246.async.js b/34666.async.js similarity index 96% rename from 88246.async.js rename to 34666.async.js index b5305b735d..343a913199 100644 --- a/88246.async.js +++ b/34666.async.js @@ -1,9 +1,9 @@ "use strict"; -(self["webpackChunk"] = self["webpackChunk"] || []).push([[88246],{ +(self["webpackChunk"] = self["webpackChunk"] || []).push([[34666],{ -/***/ 88246: +/***/ 34666: /*!***************************************************************************************************!*\ - !*** ./node_modules/_@rc-component_trigger@1.17.2@@rc-component/trigger/es/index.js + 11 modules ***! + !*** ./node_modules/_@rc-component_trigger@1.18.0@@rc-component/trigger/es/index.js + 11 modules ***! \***************************************************************************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { @@ -44,192 +44,113 @@ var isMobile = __webpack_require__(10103); var _react_17_0_2_react = __webpack_require__(59301); // EXTERNAL MODULE: ./node_modules/_react-dom@17.0.2@react-dom/index.js var _react_dom_17_0_2_react_dom = __webpack_require__(4676); -;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.17.2@@rc-component/trigger/es/context.js +// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/esm/extends.js +var esm_extends = __webpack_require__(26508); +// EXTERNAL MODULE: ./node_modules/_rc-motion@2.9.0@rc-motion/es/index.js + 12 modules +var _rc_motion_2_9_0_rc_motion_es = __webpack_require__(44516); +// EXTERNAL MODULE: ./node_modules/_rc-util@5.38.0@rc-util/es/ref.js +var es_ref = __webpack_require__(9681); +;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.18.0@@rc-component/trigger/es/Popup/Arrow.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.17.2@@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.38.0@rc-util/es/Dom/isVisible.js -var isVisible = __webpack_require__(64630); -;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.17.2@@rc-component/trigger/es/util.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(); -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]; + // Skip if no align + if (!align || !align.points) { + return null; } - 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); + 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; } - } - 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 - }; + // Left & Right + if (popupLR === targetLR || !['l', 'r'].includes(popupLR)) { + alignStyle.left = x; + } else if (popupLR === 'l') { + alignStyle.left = 0; + } else { + alignStyle.right = 0; + } } - return null; -} -function getWin(ele) { - return ele.ownerDocument.defaultView; + return /*#__PURE__*/_react_17_0_2_react.createElement("div", { + ref: arrowRef, + className: _classnames_2_3_2_classnames_default()("".concat(prefixCls, "-arrow"), className), + style: alignStyle + }, content); } +;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.18.0@@rc-component/trigger/es/Popup/Mask.js -/** - * 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; + + + +function Mask(props) { + var prefixCls = props.prefixCls, + open = props.open, + zIndex = props.zIndex, + mask = props.mask, + motion = props.motion; + if (!mask) { + return null; } - 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); + return /*#__PURE__*/_react_17_0_2_react.createElement(_rc_motion_2_9_0_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_3_2_classnames_default()("".concat(prefixCls, "-mask"), className) + }); + }); } -/** - * - * - * ************************************** - * * 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; - } +;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.18.0@@rc-component/trigger/es/Popup/PopupContent.js - // 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); +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.0@@rc-component/trigger/es/Popup/index.js - // 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.17.2@@rc-component/trigger/es/hooks/useAlign.js @@ -238,944 +159,1023 @@ function getVisibleArea(initArea, scrollerList) { -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; +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; - // Top & Bottom - if (topBottom === 't') { - y = rect.y; - } else if (topBottom === 'b') { - y = rect.y + rect.height; - } else { - y = rect.y + rect.height / 2; - } + // We can not remove holder only when motion finished. + var isNodeVisible = open || keepDom; - // Left & Right - if (leftRight === 'l') { - x = rect.x; - } else if (leftRight === 'r') { - x = rect.x + rect.width; - } else { - x = rect.x + rect.width / 2; + // ======================= 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; } - return { - x: x, - y: y - }; -} -function reversePoints(points, index) { - var reverseMap = { - t: 'b', - b: 't', - l: 'r', - r: 'l' + + // >>>>> Offset + var AUTO = 'auto'; + var offsetStyle = { + left: '-1000vw', + top: '-1000vh', + right: AUTO, + bottom: AUTO }; - return points.map(function (point, i) { - if (i === index) { - return reverseMap[point] || 'c'; + + // 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; } - 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 []; + if (alignBottom) { + offsetStyle.bottom = offsetB; + offsetStyle.top = AUTO; + } else { + offsetStyle.top = offsetY; + offsetStyle.bottom = AUTO; } - 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 = {}; - }; + // >>>>> 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) { - resetFlipCache(); + 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_0_rc_resize_observer_es/* default */.Z, { + onResize: onAlign, + disabled: !open + }, function (resizeObserverRef) { + return /*#__PURE__*/_react_17_0_2_react.createElement(_rc_motion_2_9_0_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_3_2_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.0@@rc-component/trigger/es/TriggerWrapper.js - // ========================= 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; - - // 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 ? 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'; - - // 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$parentE2 = popupElement.parentElement) === null || _popupElement$parentE2 === void 0 ? 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 */.S)(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); +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); - // Real align info may not same as origin one - var nextAlignInfo = (0,objectSpread2/* default */.Z)({}, placementInfo); + // 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.0@@rc-component/trigger/es/context.js - // Next Offset - var nextOffsetX = targetAlignPoint.x - popupAlignPoint.x + popupOffsetX; - var nextOffsetY = targetAlignPoint.y - popupAlignPoint.y + popupOffsetY; +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.0@@rc-component/trigger/es/hooks/useAction.js - // ============== 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)); +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'); } - 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; + if (hideActionSet.has('hover')) { + hideActionSet.delete('hover'); + hideActionSet.add('click'); } - syncNextPopupPosition(); + } + return [showActionSet, hideActionSet]; + }, [mobile, action, showAction, hideAction]); +} +// EXTERNAL MODULE: ./node_modules/_rc-util@5.38.0@rc-util/es/Dom/isVisible.js +var isVisible = __webpack_require__(64630); +;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.18.0@@rc-component/trigger/es/util.js - // >>>>>>>>>> Top & Bottom - var needAdjustY = supportAdjust(adjustY); - var sameTB = popupPoints[0] === targetPoints[0]; +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 ''; +} - // 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; - } - } +/** @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; +} - // 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; - } - } +/** + * 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; + } - // >>>>>>>>>> Left & Right - var needAdjustX = supportAdjust(adjustX); + // 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); - // >>>>> Flip - var sameLR = popupPoints[1] === targetPoints[1]; + // Original visible area + var eleScrollWidth = (eleOutWidth - eleInnerWidth - borderLeftNum - borderRightNum) * scaleX; + var eleScrollHeight = (eleOutHeight - eleInnerHeight - borderTopNum - borderBottomNum) * scaleY; - // 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; - } - } + // Cut border size + var scaledBorderTopWidth = borderTopNum * scaleY; + var scaledBorderBottomWidth = borderBottomNum * scaleY; + var scaledBorderLeftWidth = borderLeftNum * scaleX; + var scaledBorderRightWidth = borderRightNum * scaleX; - // 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; - } - } + // Clip margin + var clipMarginWidth = 0; + var clipMarginHeight = 0; + if (overflow === 'clip') { + var clipNum = getPxValue(overflowClipMargin); + clipMarginWidth = clipNum * scaleX; + clipMarginHeight = clipNum * scaleY; + } - // ============================ 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; - } - } + // 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.0@@rc-component/trigger/es/hooks/useAlign.js - // 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 ? 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 - }); - }); + +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 }; - (0,useLayoutEffect/* default */.Z)(resetReady, [placement]); - (0,useLayoutEffect/* default */.Z)(function () { - if (!open) { - resetReady(); +} +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'; } - }, [open]); - return [offsetInfo.ready, offsetInfo.offsetX, offsetInfo.offsetY, offsetInfo.offsetR, offsetInfo.offsetB, offsetInfo.arrowX, offsetInfo.arrowY, offsetInfo.scaleX, offsetInfo.scaleY, offsetInfo.align, triggerAlign]; + return point; + }).join(''); } -// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules -var toConsumableArray = __webpack_require__(42371); -;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.17.2@@rc-component/trigger/es/hooks/useWatch.js - +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(); + } -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); + // ========================= 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 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 - }); + 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; - // 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.38.0@rc-util/es/warning.js -var warning = __webpack_require__(46644); -// EXTERNAL MODULE: ./node_modules/_rc-util@5.38.0@rc-util/es/raf.js -var raf = __webpack_require__(28637); -;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.17.2@@rc-component/trigger/es/hooks/useWinClick.js + // 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'; + + // 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$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); -function useWinClick(open, clickToHide, targetEle, popupEle, mask, maskClosable, inPopupOrChild, triggerOpen) { - var openRef = _react_17_0_2_react.useRef(open); + // No need to align since it's not visible in view + if (_scaleX === 0 || _scaleY === 0 || (0,findDOMNode/* isDOM */.S)(target) && !(0,isVisible/* default */.Z)(target)) { + return; + } - // 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]); + // 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; - // 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; + // 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); - // 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]; - }; + // Real align info may not same as origin one + var nextAlignInfo = (0,objectSpread2/* default */.Z)({}, placementInfo); - // 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); + // Next Offset + var nextOffsetX = targetAlignPoint.x - popupAlignPoint.x + popupOffsetX; + var nextOffsetY = targetAlignPoint.y - popupAlignPoint.y + popupOffsetY; - // 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); + // ============== 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); - // 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); + // 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; }; - } - }, [clickToHide, targetEle, popupEle, mask, maskClosable]); -} -// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/esm/extends.js -var esm_extends = __webpack_require__(26508); -// EXTERNAL MODULE: ./node_modules/_rc-motion@2.9.0@rc-motion/es/index.js + 12 modules -var _rc_motion_2_9_0_rc_motion_es = __webpack_require__(44516); -// EXTERNAL MODULE: ./node_modules/_rc-util@5.38.0@rc-util/es/ref.js -var es_ref = __webpack_require__(9681); -;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.17.2@@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_3_2_classnames_default()("".concat(prefixCls, "-arrow"), className), - style: alignStyle - }, content); -} -;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.17.2@@rc-component/trigger/es/Popup/Mask.js - + // 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]; -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_0_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_3_2_classnames_default()("".concat(prefixCls, "-mask"), className) - }); - }); -} -;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.17.2@@rc-component/trigger/es/Popup/PopupContent.js + // 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; + } + } -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.17.2@@rc-component/trigger/es/Popup/index.js + // 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(); + } + }); + }; -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; + // 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.23.2@@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules +var toConsumableArray = __webpack_require__(42371); +;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.18.0@@rc-component/trigger/es/hooks/useWatch.js - // 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 +function useWatch(open, target, popup, onAlign, onScroll) { (0,useLayoutEffect/* default */.Z)(function () { - if (!show && getPopupContainerNeedParams && target) { - setShow(true); + 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); + }); + }; } - }, [show, getPopupContainerNeedParams, target]); + }, [open, target, popup]); +} +// EXTERNAL MODULE: ./node_modules/_rc-util@5.38.0@rc-util/es/warning.js +var warning = __webpack_require__(46644); +// EXTERNAL MODULE: ./node_modules/_rc-util@5.38.0@rc-util/es/raf.js +var raf = __webpack_require__(28637); +;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.18.0@@rc-component/trigger/es/hooks/useWinClick.js - // ========================= 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'; + + +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; } - 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_0_rc_resize_observer_es/* default */.Z, { - onResize: onAlign, - disabled: !open - }, function (resizeObserverRef) { - return /*#__PURE__*/_react_17_0_2_react.createElement(_rc_motion_2_9_0_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 ? void 0 : (_motion$onVisibleChan = motion.onVisibleChanged) === null || _motion$onVisibleChan === void 0 ? void 0 : _motion$onVisibleChan.call(motion, nextVisible); - _onVisibleChanged(nextVisible); - } - }), function (_ref, motionRef) { - var motionClassName = _ref.className, - motionStyle = _ref.style; - var cls = _classnames_2_3_2_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)); + _react_17_0_2_react.useEffect(function () { + var id = (0,raf/* default */.Z)(function () { + lockRef.current = false; }); - })); -}); -if (false) {} -/* harmony default export */ var es_Popup = (Popup); -;// CONCATENATED MODULE: ./node_modules/_@rc-component_trigger@1.17.2@@rc-component/trigger/es/TriggerWrapper.js + 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; -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); + // 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]; + }; - // 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.17.2@@rc-component/trigger/es/index.js + // 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.0@@rc-component/trigger/es/index.js @@ -1272,7 +1272,7 @@ function generateTrigger() { return { registerSubPopup: function registerSubPopup(id, subPopupEle) { subPopupElements.current[id] = subPopupEle; - parentContext === null || parentContext === void 0 ? void 0 : parentContext.registerSubPopup(id, subPopupEle); + parentContext === null || parentContext === void 0 || parentContext.registerSubPopup(id, subPopupEle); } }; }, [parentContext]); @@ -1287,7 +1287,7 @@ function generateTrigger() { if ((0,findDOMNode/* isDOM */.S)(node) && popupEle !== node) { setPopupEle(node); } - parentContext === null || parentContext === void 0 ? void 0 : parentContext.registerSubPopup(id, node); + parentContext === null || parentContext === void 0 || parentContext.registerSubPopup(id, node); }); // =========================== Target =========================== @@ -1296,9 +1296,13 @@ function generateTrigger() { _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 */.S)(node) && targetEle !== node) { setTargetEle(node); + externalForwardRef.current = node; } }); @@ -1344,7 +1348,7 @@ function generateTrigger() { (0,_react_dom_17_0_2_react_dom.flushSync)(function () { if (mergedOpen !== nextOpen) { setMergedOpen(nextOpen); - onPopupVisibleChange === null || onPopupVisibleChange === void 0 ? void 0 : onPopupVisibleChange(nextOpen); + onPopupVisibleChange === null || onPopupVisibleChange === void 0 || onPopupVisibleChange(nextOpen); } }); }); @@ -1436,8 +1440,11 @@ function generateTrigger() { var baseClassName = getAlignPopupClassName(builtinPlacements, prefixCls, alignInfo, alignPoint); return _classnames_2_3_2_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 }; }); @@ -1467,7 +1474,7 @@ function generateTrigger() { var onVisibleChanged = function onVisibleChanged(visible) { setInMotion(false); onAlign(); - afterPopupVisibleChange === null || afterPopupVisibleChange === void 0 ? void 0 : afterPopupVisibleChange(visible); + afterPopupVisibleChange === null || afterPopupVisibleChange === void 0 || afterPopupVisibleChange(visible); }; // We will trigger align when motion is in prepare @@ -1494,14 +1501,14 @@ function generateTrigger() { function wrapperAction(eventName, nextOpen, delay, preEvent) { cloneProps[eventName] = function (event) { var _originChildProps$eve; - preEvent === null || preEvent === void 0 ? void 0 : preEvent(event); + 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 ? void 0 : _originChildProps$eve.call.apply(_originChildProps$eve, [originChildProps, event].concat(args)); + (_originChildProps$eve = originChildProps[eventName]) === null || _originChildProps$eve === void 0 || _originChildProps$eve.call.apply(_originChildProps$eve, [originChildProps, event].concat(args)); }; } @@ -1520,7 +1527,7 @@ function generateTrigger() { 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 ? void 0 : _originChildProps$onC.call.apply(_originChildProps$onC, [originChildProps, event].concat(args)); + (_originChildProps$onC = originChildProps.onClick) === null || _originChildProps$onC === void 0 || _originChildProps$onC.call.apply(_originChildProps$onC, [originChildProps, event].concat(args)); }; } @@ -1552,7 +1559,7 @@ function generateTrigger() { cloneProps.onMouseMove = function (event) { var _originChildProps$onM; // setMousePosByEvent(event); - (_originChildProps$onM = originChildProps.onMouseMove) === null || _originChildProps$onM === void 0 ? void 0 : _originChildProps$onM.call(originChildProps, event); + (_originChildProps$onM = originChildProps.onMouseMove) === null || _originChildProps$onM === void 0 || _originChildProps$onM.call(originChildProps, event); }; } } @@ -1588,7 +1595,7 @@ function generateTrigger() { 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 ? void 0 : _originChildProps$onC2.call.apply(_originChildProps$onC2, [originChildProps, event].concat(args)); + (_originChildProps$onC2 = originChildProps.onContextMenu) === null || _originChildProps$onC2 === void 0 || _originChildProps$onC2.call.apply(_originChildProps$onC2, [originChildProps, event].concat(args)); }; } @@ -1610,7 +1617,7 @@ function generateTrigger() { 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 ? void 0 : _mergedChildrenProps$.call.apply(_mergedChildrenProps$, [mergedChildrenProps].concat(args)); + (_mergedChildrenProps$ = mergedChildrenProps[eventName]) === null || _mergedChildrenProps$ === void 0 || _mergedChildrenProps$.call.apply(_mergedChildrenProps$, [mergedChildrenProps].concat(args)); restProps[eventName].apply(restProps, args); }; } diff --git a/38685.async.js b/38685.async.js index 9d6198680d..d54f779ccd 100644 --- a/38685.async.js +++ b/38685.async.js @@ -566,8 +566,8 @@ var defineProperty = __webpack_require__(80268); var slicedToArray = __webpack_require__(39718); // EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/esm/objectWithoutProperties.js var objectWithoutProperties = __webpack_require__(26779); -// EXTERNAL MODULE: ./node_modules/_@rc-component_trigger@1.17.2@@rc-component/trigger/es/index.js + 11 modules -var es = __webpack_require__(88246); +// EXTERNAL MODULE: ./node_modules/_@rc-component_trigger@1.18.0@@rc-component/trigger/es/index.js + 11 modules +var es = __webpack_require__(34666); // EXTERNAL MODULE: ./node_modules/_classnames@2.3.2@classnames/index.js var _classnames_2_3_2_classnames = __webpack_require__(12124); var _classnames_2_3_2_classnames_default = /*#__PURE__*/__webpack_require__.n(_classnames_2_3_2_classnames); diff --git a/41757.async.js b/41757.async.js index 23e80ea3f9..030db559d5 100644 --- a/41757.async.js +++ b/41757.async.js @@ -1960,8 +1960,8 @@ var defineProperty = __webpack_require__(80268); var slicedToArray = __webpack_require__(39718); // EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/esm/objectWithoutProperties.js var objectWithoutProperties = __webpack_require__(26779); -// EXTERNAL MODULE: ./node_modules/_@rc-component_trigger@1.17.2@@rc-component/trigger/es/index.js + 11 modules -var es = __webpack_require__(88246); +// EXTERNAL MODULE: ./node_modules/_@rc-component_trigger@1.18.0@@rc-component/trigger/es/index.js + 11 modules +var es = __webpack_require__(34666); // EXTERNAL MODULE: ./node_modules/_classnames@2.3.2@classnames/index.js var _classnames_2_3_2_classnames = __webpack_require__(12124); var _classnames_2_3_2_classnames_default = /*#__PURE__*/__webpack_require__.n(_classnames_2_3_2_classnames); diff --git a/46576.async.js b/46576.async.js new file mode 100644 index 0000000000..f0aeaa8bc5 --- /dev/null +++ b/46576.async.js @@ -0,0 +1,5758 @@ +"use strict"; +(self["webpackChunk"] = self["webpackChunk"] || []).push([[46576,4977,55523,10014,64125,97120],{ + +/***/ 56672: +/*!*********************************!*\ + !*** ./src/pages/tasks/util.js ***! + \*********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ Ax: function() { return /* binding */ processTreeData; }, +/* harmony export */ Ds: function() { return /* binding */ debounce; }, +/* harmony export */ KI: function() { return /* binding */ apiPref; }, +/* harmony export */ SI: function() { return /* binding */ getTreeData; }, +/* harmony export */ f1: function() { return /* binding */ isCompileOk; } +/* harmony export */ }); +/* unused harmony export isProd */ +/* harmony import */ var _utils_env__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/utils/env */ 47015); + +function isCompileOk(rs) { + var flag = true; + if (rs.length > 0) { + for (var i = 0; i < rs.length; i++) { + if (rs[i].compile_success == 0 || !rs[i].compile_success) { + flag = false; + break; + } + } + } else { + flag = false; + } + return flag; +} +function getTreeData(data) { + var parentKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; + var result = []; + for (var i = 0; i < data.length; i++) { + var item = data[i]; + var key = parentKey ? "".concat(parentKey, "/").concat(item.name) : "".concat(item.name); + result.push({ + title: item.name, + isLeaf: item.type === 'tree' ? false : true, + key: key + }); + } + return result; +} +function processTreeData(repos, key, newData) { + for (var i = 0; i < repos.length; i++) { + var item = repos[i]; + if (item.key === key) { + item.children = newData; + break; + } + if (item.children) { + processTreeData(item.children, key, newData); + } + } + return repos; +} +function debounce(func, wait, immediate) { + var timeout; + return function () { + var context = this, + args = arguments; + var later = function later() { + timeout = null; + if (!immediate) func.apply(context, args); + }; + var callNow = immediate && !timeout; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + if (callNow) func.apply(context, args); + }; +} +var isProd = true; +var apiPref = _utils_env__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z.API_SERVER; +// export const isProd = +// window.location.href.indexOf('test-') > 0 || +// window.location.href.indexOf('localhost') > 0 +// ? false +// : true; + +// export const apiPref = isProd +// ? 'https://www.educoder.net' +// : 'https://test-newweb.educoder.net'; + +/***/ }), + +/***/ 72020: +/*!*****************************************!*\ + !*** ./src/components/NoData/index.tsx ***! + \*****************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +/* harmony import */ var _root_workspace_ppte5yg23_local_v9_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectSpread2.js */ 26801); +/* harmony import */ var _root_workspace_ppte5yg23_local_v9_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_local_v9_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ 59301); +/* harmony import */ var _assets_images_icons_nodata_png__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/assets/images/icons/nodata.png */ 4977); +/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! antd */ 5436); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ 37712); + + + + + + +var noData = function noData(_ref) { + var img = _ref.img, + _ref$buttonProps = _ref.buttonProps, + buttonProps = _ref$buttonProps === void 0 ? {} : _ref$buttonProps, + _ref$styles = _ref.styles, + styles = _ref$styles === void 0 ? {} : _ref$styles, + customText = _ref.customText, + ButtonText = _ref.ButtonText, + ButtonClick = _ref.ButtonClick, + Buttonclass = _ref.Buttonclass, + ButtonTwo = _ref.ButtonTwo, + imgStyles = _ref.imgStyles, + _ref$loading = _ref.loading, + loading = _ref$loading === void 0 ? false : _ref$loading; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)("section", { + className: "tc animated fadeIn", + style: _root_workspace_ppte5yg23_local_v9_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()(_root_workspace_ppte5yg23_local_v9_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()({}, { + color: '#999', + margin: '100px auto', + visibility: loading ? 'hidden' : 'visible' + }), styles), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("img", { + src: img || _assets_images_icons_nodata_png__WEBPACK_IMPORTED_MODULE_2__, + style: _root_workspace_ppte5yg23_local_v9_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()({}, imgStyles) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("p", { + className: "mt20 font14", + children: customText || '暂时还没有相关数据哦!' + }), ButtonText && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(antd__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .ZP, _root_workspace_ppte5yg23_local_v9_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()(_root_workspace_ppte5yg23_local_v9_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()({ + className: Buttonclass, + onClick: ButtonClick + }, buttonProps), {}, { + children: ButtonText + })), ButtonTwo && ButtonTwo] + }); +}; +/* harmony default export */ __webpack_exports__.Z = (noData); + +/***/ }), + +/***/ 48058: +/*!*********************************************************!*\ + !*** ./src/components/PreviewAll/index.tsx + 1 modules ***! + \*********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + + +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + Z: function() { return /* binding */ PreviewAll; } +}); + +// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectSpread2.js +var objectSpread2 = __webpack_require__(26801); +var objectSpread2_default = /*#__PURE__*/__webpack_require__.n(objectSpread2); +// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/regeneratorRuntime.js +var regeneratorRuntime = __webpack_require__(10574); +var regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(regeneratorRuntime); +// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/asyncToGenerator.js +var asyncToGenerator = __webpack_require__(39343); +var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator); +// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/slicedToArray.js +var slicedToArray = __webpack_require__(11006); +var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray); +// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js +var _react_17_0_2_react = __webpack_require__(59301); +;// CONCATENATED MODULE: ./src/components/PreviewAll/index.less?modules +// extracted by mini-css-extract-plugin +/* harmony default export */ var PreviewAllmodules = ({"wrp":"wrp___dq7YK","bgBlack":"bgBlack___ARIUV","monaco":"monaco___VnZC3","darkBlue":"darkBlue___UprA9","close":"close___LKoWu","embed":"embed___hvpEJ"}); +// EXTERNAL MODULE: ./node_modules/_antd@5.7.1@antd/es/button/index.js +var es_button = __webpack_require__(5436); +// EXTERNAL MODULE: ./node_modules/_@ant-design_icons@5.2.6@@ant-design/icons/es/icons/ArrowDownOutlined.js + 1 modules +var ArrowDownOutlined = __webpack_require__(98915); +// EXTERNAL MODULE: ./src/components/monaco-editor/index.jsx + 3 modules +var monaco_editor = __webpack_require__(86171); +// EXTERNAL MODULE: ./node_modules/_antd@5.7.1@antd/es/tooltip/index.js + 3 modules +var tooltip = __webpack_require__(47640); +// EXTERNAL MODULE: ./src/utils/util.tsx +var util = __webpack_require__(27291); +// EXTERNAL MODULE: ./src/service/exercise.ts +var exercise = __webpack_require__(6303); +// EXTERNAL MODULE: ./src/components/NoData/index.tsx +var NoData = __webpack_require__(72020); +// EXTERNAL MODULE: ./src/utils/env.ts + 1 modules +var env = __webpack_require__(47015); +// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js +var jsx_runtime = __webpack_require__(37712); +;// CONCATENATED MODULE: ./src/components/PreviewAll/index.tsx + + + + + + + + + + + + + + + + + +/* harmony default export */ var PreviewAll = (function (_ref) { + var _data, _data2, _data3, _data4, _data5, _data6, _data7; + var _ref$editOffice = _ref.editOffice, + editOffice = _ref$editOffice === void 0 ? 'view' : _ref$editOffice, + data = _ref.data, + theme = _ref.theme, + type = _ref.type, + filename = _ref.filename, + monacoEditor = _ref.monacoEditor, + className = _ref.className, + style = _ref.style, + close = _ref.close, + onClose = _ref.onClose, + hasMask = _ref.hasMask, + disabledDownload = _ref.disabledDownload, + onImgDimensions = _ref.onImgDimensions, + showNodata = _ref.showNodata; + var _useState = (0,_react_17_0_2_react.useState)('https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt'), + _useState2 = slicedToArray_default()(_useState, 2), + src = _useState2[0], + setSrc = _useState2[1]; + var _useState3 = (0,_react_17_0_2_react.useState)(""), + _useState4 = slicedToArray_default()(_useState3, 2), + token = _useState4[0], + setToken = _useState4[1]; + var _useState5 = (0,_react_17_0_2_react.useState)(), + _useState6 = slicedToArray_default()(_useState5, 2), + officeData = _useState6[0], + setOfficeData = _useState6[1]; + var officePath = window.ENV === "build" ? "/react/build" : ""; + var apiServer = location.host.startsWith("localhost") ? env/* default */.Z.PROXY_SERVER : env/* default */.Z.API_SERVER; + // let size; + console.log("disabledDownload---", disabledDownload); + var unit = 1024 * 1024; + var maxSize = 10 * unit; + var closeRef = (0,_react_17_0_2_react.useRef)(); + if ((_data = data) !== null && _data !== void 0 && _data.startsWith("/api") && type !== "txt") { + data = env/* default */.Z.API_SERVER + data; + } + // if (type === "office") { + // size = parseUrl(data).filesize + // if (size > maxSize) { + // type = "other" + // } + // } + if (filename) monacoEditor.filename = filename; + (0,_react_17_0_2_react.useEffect)(function () { + var _document$cookie; + var cookies = (_document$cookie = document.cookie) === null || _document$cookie === void 0 || (_document$cookie = _document$cookie.replace(/\s/g, "")) === null || _document$cookie === void 0 ? void 0 : _document$cookie.split(";"); + cookies === null || cookies === void 0 || cookies.map(function (item) { + var i = item.split("="); + if (i[0] === '_educoder_session') { + setToken(i[1]); + } + }); + }, []); + (0,_react_17_0_2_react.useEffect)(function () { + if (type === "office") getData(); + }, [type, data]); + var getData = /*#__PURE__*/function () { + var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() { + var _url, _id, res; + return regeneratorRuntime_default()().wrap(function _callee$(_context) { + while (1) switch (_context.prev = _context.next) { + case 0: + console.log("data:", data); + _url = data; + if (!data.startsWith("http")) { + _url = location.origin + _url; + } + _id = new URL(_url).pathname.split("/").pop(); + _context.next = 6; + return (0,exercise/* setEcsAttachment */.gJ)({ + attachment_id: _id + }); + case 6: + res = _context.sent; + setOfficeData(res); + case 8: + case "end": + return _context.stop(); + } + }, _callee); + })); + return function getData() { + return _ref2.apply(this, arguments); + }; + }(); + var handleClick = function handleClick() { + if (data.startsWith("http") || data.startsWith('blob:')) { + handleDown(); + return; + } + (0,util/* downloadFile */.Sv)(filename || 'educoder', data, filename); + }; + var handleDown = function handleDown() { + (0,util/* downLoadLink */.Nd)(filename || 'educoder', decodeURIComponent(data)); + }; + console.log(data, 'data'); + return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { + style: objectSpread2_default()({}, style || {}), + className: "".concat(hasMask && PreviewAllmodules.bgBlack, " ").concat(!!type ? PreviewAllmodules.wrp : "hide"), + children: [close && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { + className: PreviewAllmodules.close, + ref: closeRef, + children: [!!onImgDimensions && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { + title: "\u70B9\u51FB\u5BF9\u56FE\u7247\u8FDB\u884C\u6279\u6CE8", + getPopupContainer: function getPopupContainer() { + return closeRef.current; + }, + children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { + onClick: function onClick() { + onClose(); + onImgDimensions(); + }, + children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", { + className: "icon-yulanpizhu" + }) + }) + }), !disabledDownload && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { + title: "\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6", + getPopupContainer: function getPopupContainer() { + return closeRef.current; + }, + children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { + onClick: handleDown, + children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", { + className: "icon-quxiaozhiding" + }) + }) + }), /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { + title: "\u5173\u95ED", + getPopupContainer: function getPopupContainer() { + return closeRef.current; + }, + children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { + className: "", + onClick: onClose, + children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", { + className: "icon-guanbi1" + }) + }) + })] + }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { + className: "".concat(PreviewAllmodules[className], " ").concat(className, " ").concat(PreviewAllmodules.monaco, " ").concat(type === "txt" ? "show" : "hide"), + children: type === "txt" && /*#__PURE__*/(0,jsx_runtime.jsx)(monaco_editor/* default */.ZP, objectSpread2_default()({}, monacoEditor)) + }), type === "audio" && /*#__PURE__*/(0,jsx_runtime.jsx)("audio", { + src: ((_data2 = data) === null || _data2 === void 0 ? void 0 : _data2.indexOf("http")) > -1 || (_data3 = data) !== null && _data3 !== void 0 && _data3.startsWith("/api") ? data : "data:image/png;base64,".concat(data), + autoPlay: true + }), type === "video" && /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, { + children: ((_data4 = data) === null || _data4 === void 0 ? void 0 : _data4.indexOf("http")) > -1 || (_data5 = data) !== null && _data5 !== void 0 && _data5.startsWith("/api") ? /*#__PURE__*/(0,jsx_runtime.jsx)("video", { + controls: true, + src: "".concat(data), + autoPlay: true + }) : /*#__PURE__*/(0,jsx_runtime.jsx)("video", { + controls: true, + src: "data:video/mp4;base64,".concat(data), + autoPlay: true + }) + }), type === 'office' && officeData && /*#__PURE__*/(0,jsx_runtime.jsx)("iframe", { + src: "".concat(officePath, "/office.html?key=").concat(officeData.key, "&url=").concat(apiServer + officeData.url, "&callbackUrl=").concat(apiServer + officeData.callbackUrl, "&fileType=").concat(officeData.fileType, "&title=").concat(officeData.title, "&model=").concat(editOffice, "&officeServer=").concat(env/* default */.Z.ONLYOFFICE, "&disabledDownload=").concat(!!disabledDownload) + }), type === 'html' && /*#__PURE__*/(0,jsx_runtime.jsx)("iframe", { + src: data + '&disposition=inline' + }), type === 'pdf' && /*#__PURE__*/(0,jsx_runtime.jsx)("iframe", { + src: "".concat(officePath, "/js/pdfview/index.html?url=").concat(data, "&disabledDownload=").concat(!!disabledDownload) + }) // + , type === "image" && /*#__PURE__*/(0,jsx_runtime.jsx)("img", { + src: ((_data6 = data) === null || _data6 === void 0 ? void 0 : _data6.indexOf("http")) > -1 || (_data7 = data) !== null && _data7 !== void 0 && _data7.startsWith("/api") ? data : "data:image/png;base64,".concat(data) + }), (type === "other" || type === "download") && /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, { + children: showNodata ? /*#__PURE__*/(0,jsx_runtime.jsx)(NoData/* default */.Z, { + customText: "\u5F53\u524D\u6587\u4EF6\u4E0D\u652F\u6301\u9884\u89C8\uFF0C\u53EF\u70B9\u51FB\u4E0B\u8F7D\u67E5\u770B", + ButtonTwo: /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, { + icon: /*#__PURE__*/(0,jsx_runtime.jsx)("i", { + className: "iconfont icon-xiazai4 font14" + }), + type: "primary", + size: 'middle', + onClick: handleClick, + children: "\u4E0B\u8F7D" + }) + }) : /*#__PURE__*/(0,jsx_runtime.jsxs)(es_button/* default */.ZP, { + type: "primary", + size: 'middle', + onClick: handleClick, + children: [/*#__PURE__*/(0,jsx_runtime.jsx)(ArrowDownOutlined/* default */.Z, {}), "\u70B9\u51FB\u4E0B\u8F7D"] + }) + })] + }); +}); + +/***/ }), + +/***/ 55523: +/*!*********************************************************!*\ + !*** ./src/components/RenderHtml/index.tsx + 1 modules ***! + \*********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + + +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + Z: function() { return /* binding */ RenderHtml; } +}); + +// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectSpread2.js +var objectSpread2 = __webpack_require__(26801); +var objectSpread2_default = /*#__PURE__*/__webpack_require__.n(objectSpread2); +// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/toConsumableArray.js +var toConsumableArray = __webpack_require__(93923); +var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray); +// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/createForOfIteratorHelper.js +var createForOfIteratorHelper = __webpack_require__(98190); +var createForOfIteratorHelper_default = /*#__PURE__*/__webpack_require__.n(createForOfIteratorHelper); +// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/slicedToArray.js +var slicedToArray = __webpack_require__(11006); +var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray); +// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js +var _react_17_0_2_react = __webpack_require__(59301); +// EXTERNAL MODULE: ./node_modules/_katex@0.11.1@katex/dist/katex.min.css +var katex_min = __webpack_require__(70657); +// EXTERNAL MODULE: ./node_modules/_marked@2.0.7@marked/lib/marked.js +var marked = __webpack_require__(32834); +var marked_default = /*#__PURE__*/__webpack_require__.n(marked); +// EXTERNAL MODULE: ./node_modules/_marked@2.0.7@marked/src/helpers.js +var helpers = __webpack_require__(11690); +;// CONCATENATED MODULE: ./src/utils/marked.ts + + + +function indentCodeCompensation(raw, text) { + var matchIndentToCode = raw.match(/^(\s+)(?:```)/); + if (matchIndentToCode === null) { + return text; + } + var indentToCode = matchIndentToCode[1]; + return text.split('\n').map(function (node) { + var matchIndentInNode = node.match(/^\s+/); + if (matchIndentInNode === null) { + return node; + } + var _matchIndentInNode = slicedToArray_default()(matchIndentInNode, 1), + indentInNode = _matchIndentInNode[0]; + if (indentInNode.length >= indentToCode.length) { + return node.slice(indentToCode.length); + } + return node; + }).join('\n'); +} +//兼容之前的 ##标题式写法 +var toc = []; +var ctx = ["