1 line
16 KiB
JSON
1 line
16 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 omit from \"rc-util/es/omit\";\nimport { isPresetColor, isPresetStatusColor } from '../_util/colors';\nimport useClosable, { pickClosable } from '../_util/hooks/useClosable';\nimport { replaceElement } from '../_util/reactNode';\nimport { devUseWarning } from '../_util/warning';\nimport Wave from '../_util/wave';\nimport { ConfigContext } from '../config-provider';\nimport CheckableTag from './CheckableTag';\nimport useStyle from './style';\nimport PresetCmp from './style/presetCmp';\nimport StatusCmp from './style/statusCmp';\nconst InternalTag = /*#__PURE__*/React.forwardRef((tagProps, ref) => {\n const {\n prefixCls: customizePrefixCls,\n className,\n rootClassName,\n style,\n children,\n icon,\n color,\n onClose,\n bordered = true,\n visible: deprecatedVisible\n } = tagProps,\n props = __rest(tagProps, [\"prefixCls\", \"className\", \"rootClassName\", \"style\", \"children\", \"icon\", \"color\", \"onClose\", \"bordered\", \"visible\"]);\n const {\n getPrefixCls,\n direction,\n tag: tagContext\n } = React.useContext(ConfigContext);\n const [visible, setVisible] = React.useState(true);\n const domProps = omit(props, ['closeIcon', 'closable']);\n // Warning for deprecated usage\n if (process.env.NODE_ENV !== 'production') {\n const warning = devUseWarning('Tag');\n warning.deprecated(!('visible' in tagProps), 'visible', 'visible && <Tag />');\n }\n React.useEffect(() => {\n if (deprecatedVisible !== undefined) {\n setVisible(deprecatedVisible);\n }\n }, [deprecatedVisible]);\n const isPreset = isPresetColor(color);\n const isStatus = isPresetStatusColor(color);\n const isInternalColor = isPreset || isStatus;\n const tagStyle = Object.assign(Object.assign({\n backgroundColor: color && !isInternalColor ? color : undefined\n }, tagContext === null || tagContext === void 0 ? void 0 : tagContext.style), style);\n const prefixCls = getPrefixCls('tag', customizePrefixCls);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n // Style\n const tagClassName = classNames(prefixCls, tagContext === null || tagContext === void 0 ? void 0 : tagContext.className, {\n [`${prefixCls}-${color}`]: isInternalColor,\n [`${prefixCls}-has-color`]: color && !isInternalColor,\n [`${prefixCls}-hidden`]: !visible,\n [`${prefixCls}-rtl`]: direction === 'rtl',\n [`${prefixCls}-borderless`]: !bordered\n }, className, rootClassName, hashId, cssVarCls);\n const handleCloseClick = e => {\n e.stopPropagation();\n onClose === null || onClose === void 0 ? void 0 : onClose(e);\n if (e.defaultPrevented) {\n return;\n }\n setVisible(false);\n };\n const [, mergedCloseIcon] = useClosable(pickClosable(tagProps), pickClosable(tagContext), {\n closable: false,\n closeIconRender: iconNode => {\n const replacement = /*#__PURE__*/React.createElement(\"span\", {\n className: `${prefixCls}-close-icon`,\n onClick: handleCloseClick\n }, iconNode);\n return replaceElement(iconNode, replacement, originProps => ({\n onClick: e => {\n var _a;\n (_a = originProps === null || originProps === void 0 ? void 0 : originProps.onClick) === null || _a === void 0 ? void 0 : _a.call(originProps, e);\n handleCloseClick(e);\n },\n className: classNames(originProps === null || originProps === void 0 ? void 0 : originProps.className, `${prefixCls}-close-icon`)\n }));\n }\n });\n const isNeedW
|