1 line
12 KiB
JSON
1 line
12 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 LoadingOutlined from \"@ant-design/icons/es/icons/LoadingOutlined\";\nimport classNames from 'classnames';\nimport RcSwitch from 'rc-switch';\nimport useMergedState from \"rc-util/es/hooks/useMergedState\";\nimport Wave from '../_util/wave';\nimport { ConfigContext } from '../config-provider';\nimport DisabledContext from '../config-provider/DisabledContext';\nimport useSize from '../config-provider/hooks/useSize';\nimport useStyle from './style';\nconst InternalSwitch = /*#__PURE__*/React.forwardRef((props, ref) => {\n const {\n prefixCls: customizePrefixCls,\n size: customizeSize,\n disabled: customDisabled,\n loading,\n className,\n rootClassName,\n style,\n checked: checkedProp,\n value,\n defaultChecked: defaultCheckedProp,\n defaultValue,\n onChange\n } = props,\n restProps = __rest(props, [\"prefixCls\", \"size\", \"disabled\", \"loading\", \"className\", \"rootClassName\", \"style\", \"checked\", \"value\", \"defaultChecked\", \"defaultValue\", \"onChange\"]);\n const [checked, setChecked] = useMergedState(false, {\n value: checkedProp !== null && checkedProp !== void 0 ? checkedProp : value,\n defaultValue: defaultCheckedProp !== null && defaultCheckedProp !== void 0 ? defaultCheckedProp : defaultValue\n });\n const {\n getPrefixCls,\n direction,\n switch: SWITCH\n } = React.useContext(ConfigContext);\n // ===================== Disabled =====================\n const disabled = React.useContext(DisabledContext);\n const mergedDisabled = (customDisabled !== null && customDisabled !== void 0 ? customDisabled : disabled) || loading;\n const prefixCls = getPrefixCls('switch', customizePrefixCls);\n const loadingIcon = /*#__PURE__*/React.createElement(\"div\", {\n className: `${prefixCls}-handle`\n }, loading && /*#__PURE__*/React.createElement(LoadingOutlined, {\n className: `${prefixCls}-loading-icon`\n }));\n // Style\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n const mergedSize = useSize(customizeSize);\n const classes = classNames(SWITCH === null || SWITCH === void 0 ? void 0 : SWITCH.className, {\n [`${prefixCls}-small`]: mergedSize === 'small',\n [`${prefixCls}-loading`]: loading,\n [`${prefixCls}-rtl`]: direction === 'rtl'\n }, className, rootClassName, hashId, cssVarCls);\n const mergedStyle = Object.assign(Object.assign({}, SWITCH === null || SWITCH === void 0 ? void 0 : SWITCH.style), style);\n const changeHandler = function () {\n setChecked(arguments.length <= 0 ? undefined : arguments[0]);\n onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, arguments);\n };\n return wrapCSSVar( /*#__PURE__*/React.createElement(Wave, {\n component: \"Switch\"\n }, /*#__PURE__*/React.createElement(RcSwitch, Object.assign({}, restProps, {\n checked: checked,\n onChange: changeHandler,\n prefixCls: prefixCls,\n className: classes,\n style: mergedStyle,\n disabled: mergedDisabled,\n ref: ref,\n loadingIcon: loadingIcon\n }))));\n});\nconst Switch = InternalSwitch;\nSwitch.__ANT_SWITCH = true;\nif (process.env.NODE_ENV !== 'production') {\n Switch.displayName = 'Switch';\n}\nexport default Switch;","map":{"version":3,"names":["__rest","s","e","t","p","Object","prototype","hasOwnProperty","call","indexOf","getOwnPropertySymbols","i","length","propertyIsEnumerable","React","LoadingOutlined","classNames","RcSwitch","useMergedState","Wave","ConfigContext","DisabledContext","useSize","useStyle","InternalSwitch","forwardRef
|