PromoCursed/node_modules/.cache/babel-loader/88ed95f67316a68470524a123d7451d59b05042274267b9d35f0b963254e3d05.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 _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport * as React from 'react';\nimport { useMemo } from 'react';\nimport classNames from 'classnames';\nimport CSSMotion, { CSSMotionList } from 'rc-motion';\nimport initCollapseMotion from '../_util/motion';\nimport useCSSVarCls from '../config-provider/hooks/useCSSVarCls';\nimport { FormItemPrefixContext } from './context';\nimport useDebounce from './hooks/useDebounce';\nimport useStyle from './style';\nconst EMPTY_LIST = [];\nfunction toErrorEntity(error, prefix, errorStatus) {\n let index = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;\n return {\n key: typeof error === 'string' ? error : `${prefix}-${index}`,\n error,\n errorStatus\n };\n}\nconst ErrorList = _ref => {\n let {\n help,\n helpStatus,\n errors = EMPTY_LIST,\n warnings = EMPTY_LIST,\n className: rootClassName,\n fieldId,\n onVisibleChanged\n } = _ref;\n const {\n prefixCls\n } = React.useContext(FormItemPrefixContext);\n const baseClassName = `${prefixCls}-item-explain`;\n const rootCls = useCSSVarCls(prefixCls);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls, rootCls);\n const collapseMotion = useMemo(() => initCollapseMotion(prefixCls), [prefixCls]);\n // We have to debounce here again since somewhere use ErrorList directly still need no shaking\n // ref: https://github.com/ant-design/ant-design/issues/36336\n const debounceErrors = useDebounce(errors);\n const debounceWarnings = useDebounce(warnings);\n const fullKeyList = React.useMemo(() => {\n if (help !== undefined && help !== null) {\n return [toErrorEntity(help, 'help', helpStatus)];\n }\n return [].concat(_toConsumableArray(debounceErrors.map((error, index) => toErrorEntity(error, 'error', 'error', index))), _toConsumableArray(debounceWarnings.map((warning, index) => toErrorEntity(warning, 'warning', 'warning', index))));\n }, [help, helpStatus, debounceErrors, debounceWarnings]);\n const helpProps = {};\n if (fieldId) {\n helpProps.id = `${fieldId}_help`;\n }\n return wrapCSSVar( /*#__PURE__*/React.createElement(CSSMotion, {\n motionDeadline: collapseMotion.motionDeadline,\n motionName: `${prefixCls}-show-help`,\n visible: !!fullKeyList.length,\n onVisibleChanged: onVisibleChanged\n }, holderProps => {\n const {\n className: holderClassName,\n style: holderStyle\n } = holderProps;\n return /*#__PURE__*/React.createElement(\"div\", Object.assign({}, helpProps, {\n className: classNames(baseClassName, holderClassName, cssVarCls, rootCls, rootClassName, hashId),\n style: holderStyle,\n role: \"alert\"\n }), /*#__PURE__*/React.createElement(CSSMotionList, Object.assign({\n keys: fullKeyList\n }, initCollapseMotion(prefixCls), {\n motionName: `${prefixCls}-show-help-item`,\n component: false\n }), itemProps => {\n const {\n key,\n error,\n errorStatus,\n className: itemClassName,\n style: itemStyle\n } = itemProps;\n return /*#__PURE__*/React.createElement(\"div\", {\n key: key,\n className: classNames(itemClassName, {\n [`${baseClassName}-${errorStatus}`]: errorStatus\n }),\n style: itemStyle\n }, error);\n }));\n }));\n};\nexport default ErrorList;","map":{"version":3,"names":["_toConsumableArray","React","useMemo","classNames","CSSMotion","CSSMotionList","initCollapseMotion","useCSSVarCls","FormItemPrefixContext","useDebounce","useStyle","EMPTY_LIST","toErrorEntity","error","prefix","errorStatus","index","arguments","length","undefined","key","ErrorList","_ref","help","helpStatus","errors","warnings","className","rootClassName","fieldId","onVisibleChanged","prefixCls","useContext","baseClassName","rootCls","wrapCSSVar","hashId","cssVarCls","collapseMotion","debounceErrors","debounceWarnings","fullKeyList","concat","map","warning","helpProps","id","createElement","motionDeadline","motionName","visible",