PromoCursed/node_modules/.cache/babel-loader/8a2b6b7c6dfac673b2895dc3d5e1a9971248812d5d1c2324cfa51f4021af677a.json

1 line
20 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport classNames from 'classnames';\nimport ResizeObserver from 'rc-resize-observer';\nimport * as React from 'react';\nimport { toArray } from \"../../utils/miscUtil\";\nimport { getRealPlacement, getoffsetUnit } from \"../../utils/uiUtil\";\nimport PickerContext from \"../context\";\nimport Footer from \"./Footer\";\nimport PopupPanel from \"./PopupPanel\";\nimport PresetPanel from \"./PresetPanel\";\nexport default function Popup(props) {\n var panelRender = props.panelRender,\n internalMode = props.internalMode,\n picker = props.picker,\n showNow = props.showNow,\n range = props.range,\n multiple = props.multiple,\n _props$activeOffset = props.activeOffset,\n activeOffset = _props$activeOffset === void 0 ? 0 : _props$activeOffset,\n placement = props.placement,\n presets = props.presets,\n onPresetHover = props.onPresetHover,\n onPresetSubmit = props.onPresetSubmit,\n onFocus = props.onFocus,\n onBlur = props.onBlur,\n onPanelMouseDown = props.onPanelMouseDown,\n direction = props.direction,\n value = props.value,\n onSelect = props.onSelect,\n isInvalid = props.isInvalid,\n defaultOpenValue = props.defaultOpenValue,\n onOk = props.onOk,\n onSubmit = props.onSubmit;\n var _React$useContext = React.useContext(PickerContext),\n prefixCls = _React$useContext.prefixCls;\n var panelPrefixCls = \"\".concat(prefixCls, \"-panel\");\n var rtl = direction === 'rtl';\n\n // ========================= Refs =========================\n var arrowRef = React.useRef(null);\n var wrapperRef = React.useRef(null);\n\n // ======================== Offset ========================\n var _React$useState = React.useState(0),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n containerWidth = _React$useState2[0],\n setContainerWidth = _React$useState2[1];\n var _React$useState3 = React.useState(0),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n containerOffset = _React$useState4[0],\n setContainerOffset = _React$useState4[1];\n var onResize = function onResize(info) {\n if (info.offsetWidth) {\n setContainerWidth(info.offsetWidth);\n }\n };\n React.useEffect(function () {\n // `activeOffset` is always align with the active input element\n // So we need only check container contains the `activeOffset`\n if (range) {\n var _arrowRef$current;\n // Offset in case container has border radius\n var arrowWidth = ((_arrowRef$current = arrowRef.current) === null || _arrowRef$current === void 0 ? void 0 : _arrowRef$current.offsetWidth) || 0;\n var maxOffset = containerWidth - arrowWidth;\n if (activeOffset <= maxOffset) {\n setContainerOffset(0);\n } else {\n setContainerOffset(activeOffset + arrowWidth - containerWidth);\n }\n }\n }, [containerWidth, activeOffset, range]);\n\n // ======================== Custom ========================\n function filterEmpty(list) {\n return list.filter(function (item) {\n return item;\n });\n }\n var valueList = React.useMemo(function () {\n return filterEmpty(toArray(value));\n }, [value]);\n var isTimePickerEmptyValue = picker === 'time' && !valueList.length;\n var footerSubmitValue = React.useMemo(function () {\n if (isTimePickerEmptyValue) {\n return filterEmpty([defaultOpenValue]);\n }\n return valueList;\n }, [isTimePickerEmptyValue, valueList, defaultOpenValue]);\n var popupPanelValue = isTimePickerEmptyValue ? defaultOpenValue : valueList;\n var disableSubmit = React.useMemo(function () {\n // Empty is invalid\n if (!footerSubmitValue.length) {\n return true;\n }\n return footerSubmitValue.some(function (val) {\n return isInvalid(val);\n });\n }, [footerSubmitValue, isInvalid]);\n var onFooterSubmit = function onFooterSubmit() {\n