PromoCursed/node_modules/.cache/babel-loader/962d0e84e514285e74a45ed1fa74cc7f9390836c6782b1cf43aa1da2bcc9ab2e.json

1 line
63 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport { isDOM } from \"rc-util/es/Dom/findDOMNode\";\nimport isVisible from \"rc-util/es/Dom/isVisible\";\nimport useEvent from \"rc-util/es/hooks/useEvent\";\nimport useLayoutEffect from \"rc-util/es/hooks/useLayoutEffect\";\nimport * as React from 'react';\nimport { collectScroller, getVisibleArea, getWin, toNum } from \"../util\";\nfunction getUnitOffset(size) {\n var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n var offsetStr = \"\".concat(offset);\n var cells = offsetStr.match(/^(.*)\\%$/);\n if (cells) {\n return size * (parseFloat(cells[1]) / 100);\n }\n return parseFloat(offsetStr);\n}\nfunction getNumberOffset(rect, offset) {\n var _ref = offset || [],\n _ref2 = _slicedToArray(_ref, 2),\n offsetX = _ref2[0],\n offsetY = _ref2[1];\n return [getUnitOffset(rect.width, offsetX), getUnitOffset(rect.height, offsetY)];\n}\nfunction splitPoints() {\n var points = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';\n return [points[0], points[1]];\n}\nfunction getAlignPoint(rect, points) {\n var topBottom = points[0];\n var leftRight = points[1];\n var x;\n var y;\n\n // Top & Bottom\n if (topBottom === 't') {\n y = rect.y;\n } else if (topBottom === 'b') {\n y = rect.y + rect.height;\n } else {\n y = rect.y + rect.height / 2;\n }\n\n // Left & Right\n if (leftRight === 'l') {\n x = rect.x;\n } else if (leftRight === 'r') {\n x = rect.x + rect.width;\n } else {\n x = rect.x + rect.width / 2;\n }\n return {\n x: x,\n y: y\n };\n}\nfunction reversePoints(points, index) {\n var reverseMap = {\n t: 'b',\n b: 't',\n l: 'r',\n r: 'l'\n };\n return points.map(function (point, i) {\n if (i === index) {\n return reverseMap[point] || 'c';\n }\n return point;\n }).join('');\n}\nexport default function useAlign(open, popupEle, target, placement, builtinPlacements, popupAlign, onPopupAlign) {\n var _React$useState = React.useState({\n ready: false,\n offsetX: 0,\n offsetY: 0,\n offsetR: 0,\n offsetB: 0,\n arrowX: 0,\n arrowY: 0,\n scaleX: 1,\n scaleY: 1,\n align: builtinPlacements[placement] || {}\n }),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n offsetInfo = _React$useState2[0],\n setOffsetInfo = _React$useState2[1];\n var alignCountRef = React.useRef(0);\n var scrollerList = React.useMemo(function () {\n if (!popupEle) {\n return [];\n }\n return collectScroller(popupEle);\n }, [popupEle]);\n\n // ========================= Flip ==========================\n // We will memo flip info.\n // If size change to make flip, it will memo the flip info and use it in next align.\n var prevFlipRef = React.useRef({});\n var resetFlipCache = function resetFlipCache() {\n prevFlipRef.current = {};\n };\n if (!open) {\n resetFlipCache();\n }\n\n // ========================= Align =========================\n var onAlign = useEvent(function () {\n if (popupEle && target && open) {\n var _popupElement$parentE, _popupElement$parentE2;\n var popupElement = popupEle;\n var doc = popupElement.ownerDocument;\n var win = getWin(popupElement);\n var _win$getComputedStyle = win.getComputedStyle(popupElement),\n width = _win$getComputedStyle.width,\n height = _win$getComputedStyle.height,\n popupPosition = _win$getComputedStyle.position;\n var originLeft = popupElement.style.left;\n var originTop = popupElement.style.top;\n var originRight = popupElement.style.right;\n var originBottom = popupElement.style.bottom;\n var originOverflow = popupElement.style.overflow;\n\n // Placement\n var placementInfo = _objectSpread(_objectSpread({}, builtinPlacements[placement]), popupAlign);\n\n // placeholder element\n var placeholderElement = doc.createElemen