1 |
- {"ast":null,"code":"\"use client\";\n\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport * as React 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, index = 0) {\n return {\n key: typeof error === 'string' ? error : `${prefix}-${index}`,\n error,\n errorStatus\n };\n}\nconst ErrorList = ({\n help,\n helpStatus,\n errors = EMPTY_LIST,\n warnings = EMPTY_LIST,\n className: rootClassName,\n fieldId,\n onVisibleChanged\n}) => {\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 = React.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 filledKeyFullKeyList = React.useMemo(() => {\n const keysCount = {};\n fullKeyList.forEach(({\n key\n }) => {\n keysCount[key] = (keysCount[key] || 0) + 1;\n });\n return fullKeyList.map((entity, index) => Object.assign(Object.assign({}, entity), {\n key: keysCount[entity.key] > 1 ? `${entity.key}-fallback-${index}` : entity.key\n }));\n }, [fullKeyList]);\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: !!filledKeyFullKeyList.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 }), /*#__PURE__*/React.createElement(CSSMotionList, Object.assign({\n keys: filledKeyFullKeyList\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","classNames","CSSMotion","CSSMotionList","initCollapseMotion","useCSSVarCls","FormItemPrefixContext","useDebounce","useStyle","EMPTY_LIST","toErrorEntity","error","prefix","errorStatus","index","key","ErrorList","help","helpStatus","errors","warnings","className","rootClassName","fieldId","onVisibleChanged","prefixCls","useContext","baseClassName","rootCls","wrapCSSVar","hashId","cssVarCls","collapseMotion","useMemo","debounceErrors","debounceWarnings","fullKeyList","undefined","concat","map","warning","filledKeyFullKeyList","keysCount","forEach","entity","Object","assign","helpProps","id","createElement","motionDeadline","motionName","visible","length","holderProps","holderClassName","style","holderStyle","keys","component","itemProps","itemClassName","itemStyle"],"sources":["/Users/max_liu/max_liu/company/tools_auto_pt/node_modules/antd/es/form/ErrorList.js"],"sourcesContent":["\"use client\";\n\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport * as React 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, index = 0) {\n return {\n key: typeof error === 'string' ? error : `${prefix}-${index}`,\n error,\n errorStatus\n };\n}\nconst ErrorList = ({\n help,\n helpStatus,\n errors = EMPTY_LIST,\n warnings = EMPTY_LIST,\n className: rootClassName,\n fieldId,\n onVisibleChanged\n}) => {\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 = React.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 filledKeyFullKeyList = React.useMemo(() => {\n const keysCount = {};\n fullKeyList.forEach(({\n key\n }) => {\n keysCount[key] = (keysCount[key] || 0) + 1;\n });\n return fullKeyList.map((entity, index) => Object.assign(Object.assign({}, entity), {\n key: keysCount[entity.key] > 1 ? `${entity.key}-fallback-${index}` : entity.key\n }));\n }, [fullKeyList]);\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: !!filledKeyFullKeyList.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 }), /*#__PURE__*/React.createElement(CSSMotionList, Object.assign({\n keys: filledKeyFullKeyList\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;"],"mappings":"AAAA,YAAY;;AAEZ,OAAOA,kBAAkB,MAAM,8CAA8C;AAC7E,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,SAAS,IAAIC,aAAa,QAAQ,WAAW;AACpD,OAAOC,kBAAkB,MAAM,iBAAiB;AAChD,OAAOC,YAAY,MAAM,uCAAuC;AAChE,SAASC,qBAAqB,QAAQ,WAAW;AACjD,OAAOC,WAAW,MAAM,qBAAqB;AAC7C,OAAOC,QAAQ,MAAM,SAAS;AAC9B,MAAMC,UAAU,GAAG,EAAE;AACrB,SAASC,aAAaA,CAACC,KAAK,EAAEC,MAAM,EAAEC,WAAW,EAAEC,KAAK,GAAG,CAAC,EAAE;EAC5D,OAAO;IACLC,GAAG,EAAE,OAAOJ,KAAK,KAAK,QAAQ,GAAGA,KAAK,GAAG,GAAGC,MAAM,IAAIE,KAAK,EAAE;IAC7DH,KAA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