PromoCursed/node_modules/.cache/babel-loader/d2e7f5f1040f94195ae721baaaf609e80a0eef29714b113e26171de54f2987df.json

1 line
11 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"\"use client\";\n\nimport * as React from 'react';\nimport VerticalAlignTopOutlined from \"@ant-design/icons/es/icons/VerticalAlignTopOutlined\";\nimport classNames from 'classnames';\nimport CSSMotion from 'rc-motion';\nimport omit from \"rc-util/es/omit\";\nimport getScroll from '../_util/getScroll';\nimport { cloneElement } from '../_util/reactNode';\nimport scrollTo from '../_util/scrollTo';\nimport throttleByAnimationFrame from '../_util/throttleByAnimationFrame';\nimport { devUseWarning } from '../_util/warning';\nimport { ConfigContext } from '../config-provider';\nimport useStyle from './style';\nconst BackTop = props => {\n const {\n prefixCls: customizePrefixCls,\n className,\n rootClassName,\n visibilityHeight = 400,\n target,\n onClick,\n duration = 450\n } = props;\n const [visible, setVisible] = React.useState(visibilityHeight === 0);\n const ref = React.useRef(null);\n const getDefaultTarget = () => {\n var _a;\n return ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.ownerDocument) || window;\n };\n const handleScroll = throttleByAnimationFrame(e => {\n const scrollTop = getScroll(e.target);\n setVisible(scrollTop >= visibilityHeight);\n });\n if (process.env.NODE_ENV !== 'production') {\n const warning = devUseWarning('BackTop');\n warning.deprecated(false, 'BackTop', 'FloatButton.BackTop');\n }\n React.useEffect(() => {\n const getTarget = target || getDefaultTarget;\n const container = getTarget();\n handleScroll({\n target: container\n });\n container === null || container === void 0 ? void 0 : container.addEventListener('scroll', handleScroll);\n return () => {\n handleScroll.cancel();\n container === null || container === void 0 ? void 0 : container.removeEventListener('scroll', handleScroll);\n };\n }, [target]);\n const scrollToTop = e => {\n scrollTo(0, {\n getContainer: target || getDefaultTarget,\n duration\n });\n onClick === null || onClick === void 0 ? void 0 : onClick(e);\n };\n const {\n getPrefixCls,\n direction\n } = React.useContext(ConfigContext);\n const prefixCls = getPrefixCls('back-top', customizePrefixCls);\n const rootPrefixCls = getPrefixCls();\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n const classString = classNames(hashId, cssVarCls, prefixCls, {\n [`${prefixCls}-rtl`]: direction === 'rtl'\n }, className, rootClassName);\n // fix https://fb.me/react-unknown-prop\n const divProps = omit(props, ['prefixCls', 'className', 'rootClassName', 'children', 'visibilityHeight', 'target']);\n const defaultElement = /*#__PURE__*/React.createElement(\"div\", {\n className: `${prefixCls}-content`\n }, /*#__PURE__*/React.createElement(\"div\", {\n className: `${prefixCls}-icon`\n }, /*#__PURE__*/React.createElement(VerticalAlignTopOutlined, null)));\n return wrapCSSVar( /*#__PURE__*/React.createElement(\"div\", Object.assign({}, divProps, {\n className: classString,\n onClick: scrollToTop,\n ref: ref\n }), /*#__PURE__*/React.createElement(CSSMotion, {\n visible: visible,\n motionName: `${rootPrefixCls}-fade`\n }, _ref => {\n let {\n className: motionClassName\n } = _ref;\n return cloneElement(props.children || defaultElement, _ref2 => {\n let {\n className: cloneCls\n } = _ref2;\n return {\n className: classNames(motionClassName, cloneCls)\n };\n });\n })));\n};\nif (process.env.NODE_ENV !== 'production') {\n BackTop.displayName = 'BackTop';\n}\nexport default BackTop;","map":{"version":3,"names":["React","VerticalAlignTopOutlined","classNames","CSSMotion","omit","getScroll","cloneElement","scrollTo","throttleByAnimationFrame","devUseWarning","ConfigContext","useStyle","BackTop","props","prefixCls","customizePrefixCls","className","rootClassName","visibilityHeight","target","onClick","duration","visible","setVisible","useState","ref","useRef","getDefaultTarget","_a","current","ownerDocument","window","handleScroll","e","scrollTop","proce