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 classNames from 'classnames';\nimport RcDrawer from 'rc-drawer';\nimport ContextIsolator from '../_util/ContextIsolator';\nimport { useZIndex } from '../_util/hooks/useZIndex';\nimport { getTransitionName } from '../_util/motion';\nimport { devUseWarning } from '../_util/warning';\nimport zIndexContext from '../_util/zindexContext';\nimport { ConfigContext } from '../config-provider';\nimport { usePanelRef } from '../watermark/context';\nimport DrawerPanel from './DrawerPanel';\nimport useStyle from './style';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst SizeTypes = ['default', 'large'];\nconst defaultPushState = {\n distance: 180\n};\nconst Drawer = props => {\n var _a;\n const {\n rootClassName,\n width,\n height,\n size = 'default',\n mask = true,\n push = defaultPushState,\n open,\n afterOpenChange,\n onClose,\n prefixCls: customizePrefixCls,\n getContainer: customizeGetContainer,\n style,\n className,\n // Deprecated\n visible,\n afterVisibleChange,\n maskStyle,\n drawerStyle,\n contentWrapperStyle\n } = props,\n rest = __rest(props, [\"rootClassName\", \"width\", \"height\", \"size\", \"mask\", \"push\", \"open\", \"afterOpenChange\", \"onClose\", \"prefixCls\", \"getContainer\", \"style\", \"className\", \"visible\", \"afterVisibleChange\", \"maskStyle\", \"drawerStyle\", \"contentWrapperStyle\"]);\n const {\n getPopupContainer,\n getPrefixCls,\n direction,\n drawer\n } = React.useContext(ConfigContext);\n const prefixCls = getPrefixCls('drawer', customizePrefixCls);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n const getContainer =\n // 有可能为 false,所以不能直接判断\n customizeGetContainer === undefined && getPopupContainer ? () => getPopupContainer(document.body) : customizeGetContainer;\n const drawerClassName = classNames({\n 'no-mask': !mask,\n [`${prefixCls}-rtl`]: direction === 'rtl'\n }, rootClassName, hashId, cssVarCls);\n // ========================== Warning ===========================\n if (process.env.NODE_ENV !== 'production') {\n const warning = devUseWarning('Drawer');\n [['visible', 'open'], ['afterVisibleChange', 'afterOpenChange'], ['headerStyle', 'styles.header'], ['bodyStyle', 'styles.body'], ['footerStyle', 'styles.footer'], ['contentWrapperStyle', 'styles.wrapper'], ['maskStyle', 'styles.mask'], ['drawerStyle', 'styles.content']].forEach(_ref => {\n let [deprecatedName, newName] = _ref;\n warning.deprecated(!(deprecatedName in props), deprecatedName, newName);\n });\n if (getContainer !== undefined && ((_a = props.style) === null || _a === void 0 ? void 0 : _a.position) === 'absolute') {\n process.env.NODE_ENV !== \"production\" ? warning(false, 'breaking', '`style` is replaced by `rootStyle` in v5. Please check that `position: absolute` is necessary.') : void 0;\n }\n }\n // ============================ Size ============================\n const mergedWidth = React.useMemo(() => width !== null && width !== void 0 ? width : size === 'large' ? 736 : 378, [width, size]);\n const mergedHeight = React.useMemo(() => height !== null && height !== void 0 ? height : size === 'large' ? 736 : 378, [height, size]);\n // =========================== Motion ===========================\n const maskMotion = {\n motionName: getTransitionName(prefixCls, 'mask-motion'),\n motionAppear: true,\n motionEnter: true,\n motionLeave: true,\n motionDeadline: 500\n
|