PromoCursed/node_modules/.cache/babel-loader/5a1b9fdac59140c1b70a18a24ac0801a3cd8bb691f77cd58fd6b2b8ad6d1c5a2.json

1 line
18 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport classNames from 'classnames';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport * as React from 'react';\nimport pickAttrs from \"rc-util/es/pickAttrs\";\nvar Notify = /*#__PURE__*/React.forwardRef(function (props, ref) {\n var prefixCls = props.prefixCls,\n style = props.style,\n className = props.className,\n _props$duration = props.duration,\n duration = _props$duration === void 0 ? 4.5 : _props$duration,\n showProgress = props.showProgress,\n _props$pauseOnHover = props.pauseOnHover,\n pauseOnHover = _props$pauseOnHover === void 0 ? true : _props$pauseOnHover,\n eventKey = props.eventKey,\n content = props.content,\n closable = props.closable,\n _props$closeIcon = props.closeIcon,\n closeIcon = _props$closeIcon === void 0 ? 'x' : _props$closeIcon,\n divProps = props.props,\n onClick = props.onClick,\n onNoticeClose = props.onNoticeClose,\n times = props.times,\n forcedHovering = props.hovering;\n var _React$useState = React.useState(false),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n hovering = _React$useState2[0],\n setHovering = _React$useState2[1];\n var _React$useState3 = React.useState(0),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n percent = _React$useState4[0],\n setPercent = _React$useState4[1];\n var _React$useState5 = React.useState(0),\n _React$useState6 = _slicedToArray(_React$useState5, 2),\n spentTime = _React$useState6[0],\n setSpentTime = _React$useState6[1];\n var mergedHovering = forcedHovering || hovering;\n var mergedShowProgress = duration > 0 && showProgress;\n\n // ======================== Close =========================\n var onInternalClose = function onInternalClose() {\n onNoticeClose(eventKey);\n };\n var onCloseKeyDown = function onCloseKeyDown(e) {\n if (e.key === 'Enter' || e.code === 'Enter' || e.keyCode === KeyCode.ENTER) {\n onInternalClose();\n }\n };\n\n // ======================== Effect ========================\n React.useEffect(function () {\n if (!mergedHovering && duration > 0) {\n var start = Date.now() - spentTime;\n var timeout = setTimeout(function () {\n onInternalClose();\n }, duration * 1000 - spentTime);\n return function () {\n if (pauseOnHover) {\n clearTimeout(timeout);\n }\n setSpentTime(Date.now() - start);\n };\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [duration, mergedHovering, times]);\n React.useEffect(function () {\n if (!mergedHovering && mergedShowProgress && (pauseOnHover || spentTime === 0)) {\n var start = performance.now();\n var animationFrame;\n var calculate = function calculate() {\n cancelAnimationFrame(animationFrame);\n animationFrame = requestAnimationFrame(function (timestamp) {\n var runtime = timestamp + spentTime - start;\n var progress = Math.min(runtime / (duration * 1000), 1);\n setPercent(progress * 100);\n if (progress < 1) {\n calculate();\n }\n });\n };\n calculate();\n return function () {\n if (pauseOnHover) {\n cancelAnimationFrame(animationFrame);\n }\n };\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [duration, spentTime, mergedHovering, mergedShowProgress, times]);\n\n // ======================== Closable ========================\n var closableObj = React.useMemo(function () {\n if (_typeof(closable) === 'object' && closable !== null) {\n return closable;\n }\n if (closable) {\n return {\n closeIcon: closeIcon\n };\n }\n return {};\n }, [closable, closeIcon]);\n var ariaProps = pickAttrs(closableObj