1 line
39 KiB
JSON
1 line
39 KiB
JSON
|
{"ast":null,"code":"\"use client\";\n\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { Field, FieldContext, ListContext } from 'rc-field-form';\nimport useState from \"rc-util/es/hooks/useState\";\nimport { supportRef } from \"rc-util/es/ref\";\nimport { cloneElement } from '../../_util/reactNode';\nimport { devUseWarning } from '../../_util/warning';\nimport { ConfigContext } from '../../config-provider';\nimport useCSSVarCls from '../../config-provider/hooks/useCSSVarCls';\nimport { FormContext, NoStyleItemContext } from '../context';\nimport useChildren from '../hooks/useChildren';\nimport useFormItemStatus from '../hooks/useFormItemStatus';\nimport useFrameState from '../hooks/useFrameState';\nimport useItemRef from '../hooks/useItemRef';\nimport useStyle from '../style';\nimport { getFieldId, toArray } from '../util';\nimport ItemHolder from './ItemHolder';\nimport StatusProvider from './StatusProvider';\nconst NAME_SPLIT = '__SPLIT__';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst ValidateStatuses = ['success', 'warning', 'error', 'validating', ''];\n// https://github.com/ant-design/ant-design/issues/46417\n// `getValueProps` may modify the value props name,\n// we should check if the control is similar.\nfunction isSimilarControl(a, b) {\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n return keysA.length === keysB.length && keysA.every(key => {\n const propValueA = a[key];\n const propValueB = b[key];\n return propValueA === propValueB || typeof propValueA === 'function' || typeof propValueB === 'function';\n });\n}\nconst MemoInput = /*#__PURE__*/React.memo(_ref => {\n let {\n children\n } = _ref;\n return children;\n}, (prev, next) => isSimilarControl(prev.control, next.control) && prev.update === next.update && prev.childProps.length === next.childProps.length && prev.childProps.every((value, index) => value === next.childProps[index]));\nfunction genEmptyMeta() {\n return {\n errors: [],\n warnings: [],\n touched: false,\n validating: false,\n name: [],\n validated: false\n };\n}\nfunction InternalFormItem(props) {\n const {\n name,\n noStyle,\n className,\n dependencies,\n prefixCls: customizePrefixCls,\n shouldUpdate,\n rules,\n children,\n required,\n label,\n messageVariables,\n trigger = 'onChange',\n validateTrigger,\n hidden,\n help,\n layout\n } = props;\n const {\n getPrefixCls\n } = React.useContext(ConfigContext);\n const {\n name: formName\n } = React.useContext(FormContext);\n const mergedChildren = useChildren(children);\n const isRenderProps = typeof mergedChildren === 'function';\n const notifyParentMetaChange = React.useContext(NoStyleItemContext);\n const {\n validateTrigger: contextValidateTrigger\n } = React.useContext(FieldContext);\n const mergedValidateTrigger = validateTrigger !== undefined ? validateTrigger : contextValidateTrigger;\n const hasName = !(name === undefined || name === null);\n const prefixCls = getPrefixCls('form', customizePrefixCls);\n // Style\n const rootCls = useCSSVarCls(prefixCls);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls, rootCls);\n // ========================= Warn =========================\n const warning = devUseWarning('Form.Item');\n if (process.env.NODE_ENV !== 'production') {\n process.env.NODE_ENV !== \"production\" ? warning(name !== null, 'usage', '`null` is passed as `name` property') : void 0;\n }\n // ========================= MISC =========================\n // Get `noStyle` required info\n const listContext = React.useContext(ListContext);\n const fieldKeyPathRef = React.useRef();\n // ======================== Errors ========================\n // >>>>> Collect sub field errors\n const [subFieldErrors, setSubFieldErrors] = useFrameState({});\n // >>>>> Current field errors\n const [meta, setMeta] = useState(() => genEmptyMeta());\n const onMetaCha
|