1 line
15 KiB
JSON
1 line
15 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 classNames from 'classnames';\nimport RcCheckbox from 'rc-checkbox';\nimport { composeRef } from \"rc-util/es/ref\";\nimport { devUseWarning } from '../_util/warning';\nimport Wave from '../_util/wave';\nimport { TARGET_CLS } from '../_util/wave/interface';\nimport { ConfigContext } from '../config-provider';\nimport DisabledContext from '../config-provider/DisabledContext';\nimport useCSSVarCls from '../config-provider/hooks/useCSSVarCls';\nimport { FormItemInputContext } from '../form/context';\nimport RadioGroupContext, { RadioOptionTypeContext } from './context';\nimport useStyle from './style';\nconst InternalRadio = (props, ref) => {\n var _a, _b;\n const groupContext = React.useContext(RadioGroupContext);\n const radioOptionTypeContext = React.useContext(RadioOptionTypeContext);\n const {\n getPrefixCls,\n direction,\n radio\n } = React.useContext(ConfigContext);\n const innerRef = React.useRef(null);\n const mergedRef = composeRef(ref, innerRef);\n const {\n isFormItemInput\n } = React.useContext(FormItemInputContext);\n if (process.env.NODE_ENV !== 'production') {\n const warning = devUseWarning('Radio');\n process.env.NODE_ENV !== \"production\" ? warning(!('optionType' in props), 'usage', '`optionType` is only support in Radio.Group.') : void 0;\n }\n const onChange = e => {\n var _a, _b;\n (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, e);\n (_b = groupContext === null || groupContext === void 0 ? void 0 : groupContext.onChange) === null || _b === void 0 ? void 0 : _b.call(groupContext, e);\n };\n const {\n prefixCls: customizePrefixCls,\n className,\n rootClassName,\n children,\n style,\n title\n } = props,\n restProps = __rest(props, [\"prefixCls\", \"className\", \"rootClassName\", \"children\", \"style\", \"title\"]);\n const radioPrefixCls = getPrefixCls('radio', customizePrefixCls);\n const isButtonType = ((groupContext === null || groupContext === void 0 ? void 0 : groupContext.optionType) || radioOptionTypeContext) === 'button';\n const prefixCls = isButtonType ? `${radioPrefixCls}-button` : radioPrefixCls;\n // Style\n const rootCls = useCSSVarCls(radioPrefixCls);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(radioPrefixCls, rootCls);\n const radioProps = Object.assign({}, restProps);\n // ===================== Disabled =====================\n const disabled = React.useContext(DisabledContext);\n if (groupContext) {\n radioProps.name = groupContext.name;\n radioProps.onChange = onChange;\n radioProps.checked = props.value === groupContext.value;\n radioProps.disabled = (_a = radioProps.disabled) !== null && _a !== void 0 ? _a : groupContext.disabled;\n }\n radioProps.disabled = (_b = radioProps.disabled) !== null && _b !== void 0 ? _b : disabled;\n const wrapperClassString = classNames(`${prefixCls}-wrapper`, {\n [`${prefixCls}-wrapper-checked`]: radioProps.checked,\n [`${prefixCls}-wrapper-disabled`]: radioProps.disabled,\n [`${prefixCls}-wrapper-rtl`]: direction === 'rtl',\n [`${prefixCls}-wrapper-in-form-item`]: isFormItemInput\n }, radio === null || radio === void 0 ? void 0 : radio.className, className, rootClassName, hashId, cssVarCls, rootCls);\n return wrapCSSVar( /*#__PURE__*/React.createElement(Wave, {\n component: \"Radio\",\n disabled: radioProps.disabled\n }, /*#__PURE__*/React.createElement(\"label\", {\n className: wrapperClassString,\n style: Object.assign(Object.assign({}, radio === null || radio === void 0 ? v
|