PromoCursed/node_modules/.cache/babel-loader/277fcd64d561e1c6d95696808047a650d2273275c7c8e30859a9a1f8cc8bdc37.json

1 line
18 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"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 isVisible from \"rc-util/es/Dom/isVisible\";\nimport useLayoutEffect from \"rc-util/es/hooks/useLayoutEffect\";\nimport omit from \"rc-util/es/omit\";\nimport { Row } from '../../grid';\nimport { FormContext, NoStyleItemContext } from '../context';\nimport FormItemInput from '../FormItemInput';\nimport FormItemLabel from '../FormItemLabel';\nimport useDebounce from '../hooks/useDebounce';\nimport { getStatus } from '../util';\nimport StatusProvider from './StatusProvider';\nexport default function ItemHolder(props) {\n const {\n prefixCls,\n className,\n rootClassName,\n style,\n help,\n errors,\n warnings,\n validateStatus,\n meta,\n hasFeedback,\n hidden,\n children,\n fieldId,\n required,\n isRequired,\n onSubItemMetaChange,\n layout\n } = props,\n restProps = __rest(props, [\"prefixCls\", \"className\", \"rootClassName\", \"style\", \"help\", \"errors\", \"warnings\", \"validateStatus\", \"meta\", \"hasFeedback\", \"hidden\", \"children\", \"fieldId\", \"required\", \"isRequired\", \"onSubItemMetaChange\", \"layout\"]);\n const itemPrefixCls = `${prefixCls}-item`;\n const {\n requiredMark,\n vertical: formVertical\n } = React.useContext(FormContext);\n const vertical = formVertical || layout === 'vertical';\n // ======================== Margin ========================\n const itemRef = React.useRef(null);\n const debounceErrors = useDebounce(errors);\n const debounceWarnings = useDebounce(warnings);\n const hasHelp = help !== undefined && help !== null;\n const hasError = !!(hasHelp || errors.length || warnings.length);\n const isOnScreen = !!itemRef.current && isVisible(itemRef.current);\n const [marginBottom, setMarginBottom] = React.useState(null);\n useLayoutEffect(() => {\n if (hasError && itemRef.current) {\n // The element must be part of the DOMTree to use getComputedStyle\n // https://stackoverflow.com/questions/35360711/getcomputedstyle-returns-a-cssstyledeclaration-but-all-properties-are-empty-on-a\n const itemStyle = getComputedStyle(itemRef.current);\n setMarginBottom(parseInt(itemStyle.marginBottom, 10));\n }\n }, [hasError, isOnScreen]);\n const onErrorVisibleChanged = nextVisible => {\n if (!nextVisible) {\n setMarginBottom(null);\n }\n };\n // ======================== Status ========================\n const getValidateState = function () {\n let isDebounce = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n const _errors = isDebounce ? debounceErrors : meta.errors;\n const _warnings = isDebounce ? debounceWarnings : meta.warnings;\n return getStatus(_errors, _warnings, meta, '', !!hasFeedback, validateStatus);\n };\n const mergedValidateStatus = getValidateState();\n // ======================== Render ========================\n const itemClassName = classNames(itemPrefixCls, className, rootClassName, {\n [`${itemPrefixCls}-with-help`]: hasHelp || debounceErrors.length || debounceWarnings.length,\n // Status\n [`${itemPrefixCls}-has-feedback`]: mergedValidateStatus && hasFeedback,\n [`${itemPrefixCls}-has-success`]: mergedValidateStatus === 'success',\n [`${itemPrefixCls}-has-warning`]: mergedValidateStatus === 'warning',\n [`${itemPrefixCls}-has-error`]: mergedValidateStatus === 'error',\n [`${itemPrefixCls}-is-validating`]: mergedValidateStatus === 'validating',\n [`${itemPrefixCls}-hidden`]: hidden,\n // Layout\n [`${itemPre