1 line
14 KiB
JSON
1 line
14 KiB
JSON
|
{"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 QuestionCircleOutlined from \"@ant-design/icons/es/icons/QuestionCircleOutlined\";\nimport classNames from 'classnames';\nimport Col from '../grid/col';\nimport { useLocale } from '../locale';\nimport defaultLocale from '../locale/en_US';\nimport Tooltip from '../tooltip';\nimport { FormContext } from './context';\nfunction toTooltipProps(tooltip) {\n if (!tooltip) {\n return null;\n }\n if (typeof tooltip === 'object' && ! /*#__PURE__*/React.isValidElement(tooltip)) {\n return tooltip;\n }\n return {\n title: tooltip\n };\n}\nconst FormItemLabel = _ref => {\n let {\n prefixCls,\n label,\n htmlFor,\n labelCol,\n labelAlign,\n colon,\n required,\n requiredMark,\n tooltip,\n vertical\n } = _ref;\n var _a;\n const [formLocale] = useLocale('Form');\n const {\n labelAlign: contextLabelAlign,\n labelCol: contextLabelCol,\n labelWrap,\n colon: contextColon\n } = React.useContext(FormContext);\n if (!label) {\n return null;\n }\n const mergedLabelCol = labelCol || contextLabelCol || {};\n const mergedLabelAlign = labelAlign || contextLabelAlign;\n const labelClsBasic = `${prefixCls}-item-label`;\n const labelColClassName = classNames(labelClsBasic, mergedLabelAlign === 'left' && `${labelClsBasic}-left`, mergedLabelCol.className, {\n [`${labelClsBasic}-wrap`]: !!labelWrap\n });\n let labelChildren = label;\n // Keep label is original where there should have no colon\n const computedColon = colon === true || contextColon !== false && colon !== false;\n const haveColon = computedColon && !vertical;\n // Remove duplicated user input colon\n if (haveColon && typeof label === 'string' && label.trim()) {\n labelChildren = label.replace(/[:|:]\\s*$/, '');\n }\n // Tooltip\n const tooltipProps = toTooltipProps(tooltip);\n if (tooltipProps) {\n const {\n icon = /*#__PURE__*/React.createElement(QuestionCircleOutlined, null)\n } = tooltipProps,\n restTooltipProps = __rest(tooltipProps, [\"icon\"]);\n const tooltipNode = /*#__PURE__*/React.createElement(Tooltip, Object.assign({}, restTooltipProps), /*#__PURE__*/React.cloneElement(icon, {\n className: `${prefixCls}-item-tooltip`,\n title: '',\n onClick: e => {\n // Prevent label behavior in tooltip icon\n // https://github.com/ant-design/ant-design/issues/46154\n e.preventDefault();\n },\n tabIndex: null\n }));\n labelChildren = /*#__PURE__*/React.createElement(React.Fragment, null, labelChildren, tooltipNode);\n }\n // Required Mark\n const isOptionalMark = requiredMark === 'optional';\n const isRenderMark = typeof requiredMark === 'function';\n if (isRenderMark) {\n labelChildren = requiredMark(labelChildren, {\n required: !!required\n });\n } else if (isOptionalMark && !required) {\n labelChildren = /*#__PURE__*/React.createElement(React.Fragment, null, labelChildren, /*#__PURE__*/React.createElement(\"span\", {\n className: `${prefixCls}-item-optional`,\n title: \"\"\n }, (formLocale === null || formLocale === void 0 ? void 0 : formLocale.optional) || ((_a = defaultLocale.Form) === null || _a === void 0 ? void 0 : _a.optional)));\n }\n const labelClassName = classNames({\n [`${prefixCls}-item-required`]: required,\n [`${prefixCls}-item-required-mark-optional`]: isOptionalMark || isRenderMark,\n [`${prefixCls}-item-no-colon`]: !computedColon\n });\n return /*#__PURE__*/React.createElement(Col, Object.assign({}, mergedLabelCol, {\n className: labelColClassName\n }
|