1 line
18 KiB
JSON
1 line
18 KiB
JSON
|
{"ast":null,"code":"\"use client\";\n\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport React, { useContext } from 'react';\nimport { render as reactRender, unmount as reactUnmount } from \"rc-util/es/React/render\";\nimport warning from '../_util/warning';\nimport ConfigProvider, { ConfigContext, globalConfig, warnContext } from '../config-provider';\nimport ConfirmDialog from './ConfirmDialog';\nimport destroyFns from './destroyFns';\nimport { getConfirmLocale } from './locale';\nlet defaultRootPrefixCls = '';\nfunction getRootPrefixCls() {\n return defaultRootPrefixCls;\n}\nconst ConfirmDialogWrapper = props => {\n var _a, _b;\n const {\n prefixCls: customizePrefixCls,\n getContainer,\n direction\n } = props;\n const runtimeLocale = getConfirmLocale();\n const config = useContext(ConfigContext);\n const rootPrefixCls = getRootPrefixCls() || config.getPrefixCls();\n // because Modal.config set rootPrefixCls, which is different from other components\n const prefixCls = customizePrefixCls || `${rootPrefixCls}-modal`;\n let mergedGetContainer = getContainer;\n if (mergedGetContainer === false) {\n mergedGetContainer = undefined;\n if (process.env.NODE_ENV !== 'production') {\n process.env.NODE_ENV !== \"production\" ? warning(false, 'Modal', 'Static method not support `getContainer` to be `false` since it do not have context env.') : void 0;\n }\n }\n return /*#__PURE__*/React.createElement(ConfirmDialog, Object.assign({}, props, {\n rootPrefixCls: rootPrefixCls,\n prefixCls: prefixCls,\n iconPrefixCls: config.iconPrefixCls,\n theme: config.theme,\n direction: direction !== null && direction !== void 0 ? direction : config.direction,\n locale: (_b = (_a = config.locale) === null || _a === void 0 ? void 0 : _a.Modal) !== null && _b !== void 0 ? _b : runtimeLocale,\n getContainer: mergedGetContainer\n }));\n};\nexport default function confirm(config) {\n const global = globalConfig();\n if (process.env.NODE_ENV !== 'production' && !global.holderRender) {\n warnContext('Modal');\n }\n const container = document.createDocumentFragment();\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n let currentConfig = Object.assign(Object.assign({}, config), {\n close,\n open: true\n });\n let timeoutId;\n function destroy() {\n var _a;\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n const triggerCancel = args.some(param => param === null || param === void 0 ? void 0 : param.triggerCancel);\n if (triggerCancel) {\n var _a2;\n (_a = config.onCancel) === null || _a === void 0 ? void 0 : (_a2 = _a).call.apply(_a2, [config, () => {}].concat(_toConsumableArray(args.slice(1))));\n }\n for (let i = 0; i < destroyFns.length; i++) {\n const fn = destroyFns[i];\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n if (fn === close) {\n destroyFns.splice(i, 1);\n break;\n }\n }\n reactUnmount(container);\n }\n function render(props) {\n clearTimeout(timeoutId);\n /**\n * https://github.com/ant-design/ant-design/issues/23623\n *\n * Sync render blocks React event. Let's make this async.\n */\n timeoutId = setTimeout(() => {\n const rootPrefixCls = global.getPrefixCls(undefined, getRootPrefixCls());\n const iconPrefixCls = global.getIconPrefixCls();\n const theme = global.getTheme();\n const dom = /*#__PURE__*/React.createElement(ConfirmDialogWrapper, Object.assign({}, props));\n reactRender( /*#__PURE__*/React.createElement(ConfigProvider, {\n prefixCls: rootPrefixCls,\n iconPrefixCls: iconPrefixCls,\n theme: theme\n }, global.holderRender ? global.holderRender(dom) : dom), container);\n });\n }\n function close() {\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n
|