1 line
24 KiB
JSON
1 line
24 KiB
JSON
|
{"ast":null,"code":"\"use client\";\n\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\nimport * as React from 'react';\nimport CloseOutlined from \"@ant-design/icons/es/icons/CloseOutlined\";\nimport classNames from 'classnames';\nimport { NotificationProvider, useNotification as useRcNotification } from 'rc-notification';\nimport { devUseWarning } from '../_util/warning';\nimport { ConfigContext } from '../config-provider';\nimport useCSSVarCls from '../config-provider/hooks/useCSSVarCls';\nimport { PureContent } from './PurePanel';\nimport useStyle from './style';\nimport { getMotion, wrapPromiseFn } from './util';\nconst DEFAULT_OFFSET = 8;\nconst DEFAULT_DURATION = 3;\nconst Wrapper = _ref => {\n let {\n children,\n prefixCls\n } = _ref;\n const rootCls = useCSSVarCls(prefixCls);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls, rootCls);\n return wrapCSSVar( /*#__PURE__*/React.createElement(NotificationProvider, {\n classNames: {\n list: classNames(hashId, cssVarCls, rootCls)\n }\n }, children));\n};\nconst renderNotifications = (node, _ref2) => {\n let {\n prefixCls,\n key\n } = _ref2;\n return /*#__PURE__*/React.createElement(Wrapper, {\n prefixCls: prefixCls,\n key: key\n }, node);\n};\nconst Holder = /*#__PURE__*/React.forwardRef((props, ref) => {\n const {\n top,\n prefixCls: staticPrefixCls,\n getContainer: staticGetContainer,\n maxCount,\n duration = DEFAULT_DURATION,\n rtl,\n transitionName,\n onAllRemoved\n } = props;\n const {\n getPrefixCls,\n getPopupContainer,\n message,\n direction\n } = React.useContext(ConfigContext);\n const prefixCls = staticPrefixCls || getPrefixCls('message');\n // =============================== Style ===============================\n const getStyle = () => ({\n left: '50%',\n transform: 'translateX(-50%)',\n top: top !== null && top !== void 0 ? top : DEFAULT_OFFSET\n });\n const getClassName = () => classNames({\n [`${prefixCls}-rtl`]: rtl !== null && rtl !== void 0 ? rtl : direction === 'rtl'\n });\n // ============================== Motion ===============================\n const getNotificationMotion = () => getMotion(prefixCls, transitionName);\n // ============================ Close Icon =============================\n const mergedCloseIcon = /*#__PURE__*/React.createElement(\"span\", {\n className: `${prefixCls}-close-x`\n }, /*#__PURE__*/React.createElement(CloseOutlined, {\n className: `${prefixCls}-close-icon`\n }));\n // ============================== Origin ===============================\n const [api, holder] = useRcNotification({\n prefixCls,\n style: getStyle,\n className: getClassName,\n motion: getNotificationMotion,\n closable: false,\n closeIcon: mergedCloseIcon,\n duration,\n getContainer: () => (staticGetContainer === null || staticGetContainer === void 0 ? void 0 : staticGetContainer()) || (getPopupContainer === null || getPopupContainer === void 0 ? void 0 : getPopupContainer()) || document.body,\n maxCount,\n onAllRemoved,\n renderNotifications\n });\n // ================================ Ref ================================\n React.useImperativeHandle(ref, () => Object.assign(Object.assign({}, api), {\n prefixCls,\n message\n }));\n return holder;\n});\n// ==============================================================================\n// == Hook ==\n// ==============================================================================\nlet keyIndex = 0;\nexport function useInternalMessage(messageConfig) {\n const holderRef = React.useRef(
|