05459261d75c06076978433ad8a6c5da.json
9.75 KB
{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport CSSMotion from 'rc-motion';\nimport useMemo from \"rc-util/es/hooks/useMemo\";\nimport useCacheErrors from './hooks/useCacheErrors';\nimport useForceUpdate from '../_util/hooks/useForceUpdate';\nimport { FormItemPrefixContext } from './context';\nvar EMPTY_LIST = [];\nexport default function ErrorList(_ref) {\n var _ref$errors = _ref.errors,\n errors = _ref$errors === void 0 ? EMPTY_LIST : _ref$errors,\n help = _ref.help,\n onDomErrorVisibleChange = _ref.onDomErrorVisibleChange;\n var forceUpdate = useForceUpdate();\n\n var _React$useContext = React.useContext(FormItemPrefixContext),\n prefixCls = _React$useContext.prefixCls,\n status = _React$useContext.status;\n\n var _useCacheErrors = useCacheErrors(errors, function (changedVisible) {\n if (changedVisible) {\n /**\n * We trigger in sync to avoid dom shaking but this get warning in react 16.13.\n * So use Promise to keep in micro async to handle this.\n * https://github.com/ant-design/ant-design/issues/21698#issuecomment-593743485\n */\n Promise.resolve().then(function () {\n onDomErrorVisibleChange === null || onDomErrorVisibleChange === void 0 ? void 0 : onDomErrorVisibleChange(true);\n });\n }\n\n forceUpdate();\n }, !!help),\n _useCacheErrors2 = _slicedToArray(_useCacheErrors, 2),\n visible = _useCacheErrors2[0],\n cacheErrors = _useCacheErrors2[1];\n\n var memoErrors = useMemo(function () {\n return cacheErrors;\n }, visible, function (_, nextVisible) {\n return nextVisible;\n }); // Memo status in same visible\n\n var _React$useState = React.useState(status),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n innerStatus = _React$useState2[0],\n setInnerStatus = _React$useState2[1];\n\n React.useEffect(function () {\n if (visible && status) {\n setInnerStatus(status);\n }\n }, [visible, status]);\n var baseClassName = \"\".concat(prefixCls, \"-item-explain\");\n return /*#__PURE__*/React.createElement(CSSMotion, {\n motionDeadline: 500,\n visible: visible,\n motionName: \"show-help\",\n onLeaveEnd: function onLeaveEnd() {\n onDomErrorVisibleChange === null || onDomErrorVisibleChange === void 0 ? void 0 : onDomErrorVisibleChange(false);\n },\n motionAppear: true,\n removeOnLeave: true\n }, function (_ref2) {\n var motionClassName = _ref2.className;\n return /*#__PURE__*/React.createElement(\"div\", {\n className: classNames(baseClassName, _defineProperty({}, \"\".concat(baseClassName, \"-\").concat(innerStatus), innerStatus), motionClassName),\n key: \"help\"\n }, memoErrors.map(function (error, index) {\n return (\n /*#__PURE__*/\n // eslint-disable-next-line react/no-array-index-key\n React.createElement(\"div\", {\n key: index,\n role: \"alert\"\n }, error)\n );\n }));\n });\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/antd/es/form/ErrorList.js"],"names":["_defineProperty","_slicedToArray","React","classNames","CSSMotion","useMemo","useCacheErrors","useForceUpdate","FormItemPrefixContext","EMPTY_LIST","ErrorList","_ref","_ref$errors","errors","help","onDomErrorVisibleChange","forceUpdate","_React$useContext","useContext","prefixCls","status","_useCacheErrors","changedVisible","Promise","resolve","then","_useCacheErrors2","visible","cacheErrors","memoErrors","_","nextVisible","_React$useState","useState","_React$useState2","innerStatus","setInnerStatus","useEffect","baseClassName","concat","createElement","motionDeadline","motionName","onLeaveEnd","motionAppear","removeOnLeave","_ref2","motionClassName","className","key","map","error","index","role"],"mappings":"AAAA,OAAOA,eAAP,MAA4B,uCAA5B;AACA,OAAOC,cAAP,MAA2B,sCAA3B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,SAAP,MAAsB,WAAtB;AACA,OAAOC,OAAP,MAAoB,0BAApB;AACA,OAAOC,cAAP,MAA2B,wBAA3B;AACA,OAAOC,cAAP,MAA2B,+BAA3B;AACA,SAASC,qBAAT,QAAsC,WAAtC;AACA,IAAIC,UAAU,GAAG,EAAjB;AACA,eAAe,SAASC,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AAxD,CAA/B,EAAqGY,eAArG,CADwB;AAE7CE,MAAAA,GAAG,EAAE;AAFwC,KAA3B,EAGjBpB,UAAU,CAACqB,GAAX,CAAe,UAAUC,KAAV,EAAiBC,KAAjB,EAAwB;AACxC;AACE;AACA;AACAlD,QAAAA,KAAK,CAACsC,aAAN,CAAoB,KAApB,EAA2B;AACzBS,UAAAA,GAAG,EAAEG,KADoB;AAEzBC,UAAAA,IAAI,EAAE;AAFmB,SAA3B,EAGGF,KAHH;AAHF;AAQD,KATE,CAHiB,CAApB;AAaD,GAxBmB,CAApB;AAyBD","sourcesContent":["import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport CSSMotion from 'rc-motion';\nimport useMemo from \"rc-util/es/hooks/useMemo\";\nimport useCacheErrors from './hooks/useCacheErrors';\nimport useForceUpdate from '../_util/hooks/useForceUpdate';\nimport { FormItemPrefixContext } from './context';\nvar EMPTY_LIST = [];\nexport default function ErrorList(_ref) {\n var _ref$errors = _ref.errors,\n errors = _ref$errors === void 0 ? EMPTY_LIST : _ref$errors,\n help = _ref.help,\n onDomErrorVisibleChange = _ref.onDomErrorVisibleChange;\n var forceUpdate = useForceUpdate();\n\n var _React$useContext = React.useContext(FormItemPrefixContext),\n prefixCls = _React$useContext.prefixCls,\n status = _React$useContext.status;\n\n var _useCacheErrors = useCacheErrors(errors, function (changedVisible) {\n if (changedVisible) {\n /**\n * We trigger in sync to avoid dom shaking but this get warning in react 16.13.\n * So use Promise to keep in micro async to handle this.\n * https://github.com/ant-design/ant-design/issues/21698#issuecomment-593743485\n */\n Promise.resolve().then(function () {\n onDomErrorVisibleChange === null || onDomErrorVisibleChange === void 0 ? void 0 : onDomErrorVisibleChange(true);\n });\n }\n\n forceUpdate();\n }, !!help),\n _useCacheErrors2 = _slicedToArray(_useCacheErrors, 2),\n visible = _useCacheErrors2[0],\n cacheErrors = _useCacheErrors2[1];\n\n var memoErrors = useMemo(function () {\n return cacheErrors;\n }, visible, function (_, nextVisible) {\n return nextVisible;\n }); // Memo status in same visible\n\n var _React$useState = React.useState(status),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n innerStatus = _React$useState2[0],\n setInnerStatus = _React$useState2[1];\n\n React.useEffect(function () {\n if (visible && status) {\n setInnerStatus(status);\n }\n }, [visible, status]);\n var baseClassName = \"\".concat(prefixCls, \"-item-explain\");\n return /*#__PURE__*/React.createElement(CSSMotion, {\n motionDeadline: 500,\n visible: visible,\n motionName: \"show-help\",\n onLeaveEnd: function onLeaveEnd() {\n onDomErrorVisibleChange === null || onDomErrorVisibleChange === void 0 ? void 0 : onDomErrorVisibleChange(false);\n },\n motionAppear: true,\n removeOnLeave: true\n }, function (_ref2) {\n var motionClassName = _ref2.className;\n return /*#__PURE__*/React.createElement(\"div\", {\n className: classNames(baseClassName, _defineProperty({}, \"\".concat(baseClassName, \"-\").concat(innerStatus), innerStatus), motionClassName),\n key: \"help\"\n }, memoErrors.map(function (error, index) {\n return (\n /*#__PURE__*/\n // eslint-disable-next-line react/no-array-index-key\n React.createElement(\"div\", {\n key: index,\n role: \"alert\"\n }, error)\n );\n }));\n });\n}"]},"metadata":{},"sourceType":"module"}