1 line
14 KiB
JSON
1 line
14 KiB
JSON
{"ast":null,"code":"\"use client\";\n\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\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 omit from \"rc-util/es/omit\";\nimport { ConfigContext } from '../config-provider';\nimport useCSSVarCls from '../config-provider/hooks/useCSSVarCls';\nimport Checkbox from './Checkbox';\nimport GroupContext from './GroupContext';\nimport useStyle from './style';\nconst CheckboxGroup = /*#__PURE__*/React.forwardRef((props, ref) => {\n const {\n defaultValue,\n children,\n options = [],\n prefixCls: customizePrefixCls,\n className,\n rootClassName,\n style,\n onChange\n } = props,\n restProps = __rest(props, [\"defaultValue\", \"children\", \"options\", \"prefixCls\", \"className\", \"rootClassName\", \"style\", \"onChange\"]);\n const {\n getPrefixCls,\n direction\n } = React.useContext(ConfigContext);\n const [value, setValue] = React.useState(restProps.value || defaultValue || []);\n const [registeredValues, setRegisteredValues] = React.useState([]);\n React.useEffect(() => {\n if ('value' in restProps) {\n setValue(restProps.value || []);\n }\n }, [restProps.value]);\n const memoOptions = React.useMemo(() => options.map(option => {\n if (typeof option === 'string' || typeof option === 'number') {\n return {\n label: option,\n value: option\n };\n }\n return option;\n }), [options]);\n const cancelValue = val => {\n setRegisteredValues(prevValues => prevValues.filter(v => v !== val));\n };\n const registerValue = val => {\n setRegisteredValues(prevValues => [].concat(_toConsumableArray(prevValues), [val]));\n };\n const toggleOption = option => {\n const optionIndex = value.indexOf(option.value);\n const newValue = _toConsumableArray(value);\n if (optionIndex === -1) {\n newValue.push(option.value);\n } else {\n newValue.splice(optionIndex, 1);\n }\n if (!('value' in restProps)) {\n setValue(newValue);\n }\n onChange === null || onChange === void 0 ? void 0 : onChange(newValue.filter(val => registeredValues.includes(val)).sort((a, b) => {\n const indexA = memoOptions.findIndex(opt => opt.value === a);\n const indexB = memoOptions.findIndex(opt => opt.value === b);\n return indexA - indexB;\n }));\n };\n const prefixCls = getPrefixCls('checkbox', customizePrefixCls);\n const groupPrefixCls = `${prefixCls}-group`;\n const rootCls = useCSSVarCls(prefixCls);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls, rootCls);\n const domProps = omit(restProps, ['value', 'disabled']);\n const childrenNode = options.length ? memoOptions.map(option => ( /*#__PURE__*/React.createElement(Checkbox, {\n prefixCls: prefixCls,\n key: option.value.toString(),\n disabled: 'disabled' in option ? option.disabled : restProps.disabled,\n value: option.value,\n checked: value.includes(option.value),\n onChange: option.onChange,\n className: `${groupPrefixCls}-item`,\n style: option.style,\n title: option.title,\n id: option.id,\n required: option.required\n }, option.label))) : children;\n const context = {\n toggleOption,\n value,\n disabled: restProps.disabled,\n name: restProps.name,\n // https://github.com/ant-design/ant-design/issues/16376\n registerValue,\n cancelValue\n };\n const classString = classNames(groupPrefixCls, {\n [`${groupPrefixCls}-rtl`]: direction === 'rtl'\n }, className, rootClassName, cssVarCls, rootCls, hashId);\n return wrapCSSVar( /*#__PURE__*/React.createElement(\"div\", Object.assign({\n className: classString,\n style: style\n }, domProps, {\n ref: ref\n }), /*#__PURE__*/React.createElement(GroupContext.Provider, {\n value: context\n }, childrenNode)));\n});\nexport { GroupContext };\nexport default CheckboxGroup;","map":{"version":3,"names":["_toConsumableArray","__rest","s","e","t","p","Object","prototype","hasOwnProperty","call","indexOf","getOwnPropertySymbols","i","length","propertyIsEnumerable","React","classNames","omit","ConfigContext","useCSSVarCls","Checkbox","GroupContext","useStyle","CheckboxGroup","forwardRef","props","ref","defaultValue","children","options","prefixCls","customizePrefixCls","className","rootClassName","style","onChange","restProps","getPrefixCls","direction","useContext","value","setValue","useState","registeredValues","setRegisteredValues","useEffect","memoOptions","useMemo","map","option","label","cancelValue","val","prevValues","filter","v","registerValue","concat","toggleOption","optionIndex","newValue","push","splice","includes","sort","a","b","indexA","findIndex","opt","indexB","groupPrefixCls","rootCls","wrapCSSVar","hashId","cssVarCls","domProps","childrenNode","createElement","key","toString","disabled","checked","title","id","required","context","name","classString","assign","Provider"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/antd/es/checkbox/Group.js"],"sourcesContent":["\"use client\";\n\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\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 omit from \"rc-util/es/omit\";\nimport { ConfigContext } from '../config-provider';\nimport useCSSVarCls from '../config-provider/hooks/useCSSVarCls';\nimport Checkbox from './Checkbox';\nimport GroupContext from './GroupContext';\nimport useStyle from './style';\nconst CheckboxGroup = /*#__PURE__*/React.forwardRef((props, ref) => {\n const {\n defaultValue,\n children,\n options = [],\n prefixCls: customizePrefixCls,\n className,\n rootClassName,\n style,\n onChange\n } = props,\n restProps = __rest(props, [\"defaultValue\", \"children\", \"options\", \"prefixCls\", \"className\", \"rootClassName\", \"style\", \"onChange\"]);\n const {\n getPrefixCls,\n direction\n } = React.useContext(ConfigContext);\n const [value, setValue] = React.useState(restProps.value || defaultValue || []);\n const [registeredValues, setRegisteredValues] = React.useState([]);\n React.useEffect(() => {\n if ('value' in restProps) {\n setValue(restProps.value || []);\n }\n }, [restProps.value]);\n const memoOptions = React.useMemo(() => options.map(option => {\n if (typeof option === 'string' || typeof option === 'number') {\n return {\n label: option,\n value: option\n };\n }\n return option;\n }), [options]);\n const cancelValue = val => {\n setRegisteredValues(prevValues => prevValues.filter(v => v !== val));\n };\n const registerValue = val => {\n setRegisteredValues(prevValues => [].concat(_toConsumableArray(prevValues), [val]));\n };\n const toggleOption = option => {\n const optionIndex = value.indexOf(option.value);\n const newValue = _toConsumableArray(value);\n if (optionIndex === -1) {\n newValue.push(option.value);\n } else {\n newValue.splice(optionIndex, 1);\n }\n if (!('value' in restProps)) {\n setValue(newValue);\n }\n onChange === null || onChange === void 0 ? void 0 : onChange(newValue.filter(val => registeredValues.includes(val)).sort((a, b) => {\n const indexA = memoOptions.findIndex(opt => opt.value === a);\n const indexB = memoOptions.findIndex(opt => opt.value === b);\n return indexA - indexB;\n }));\n };\n const prefixCls = getPrefixCls('checkbox', customizePrefixCls);\n const groupPrefixCls = `${prefixCls}-group`;\n const rootCls = useCSSVarCls(prefixCls);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls, rootCls);\n const domProps = omit(restProps, ['value', 'disabled']);\n const childrenNode = options.length ? memoOptions.map(option => ( /*#__PURE__*/React.createElement(Checkbox, {\n prefixCls: prefixCls,\n key: option.value.toString(),\n disabled: 'disabled' in option ? option.disabled : restProps.disabled,\n value: option.value,\n checked: value.includes(option.value),\n onChange: option.onChange,\n className: `${groupPrefixCls}-item`,\n style: option.style,\n title: option.title,\n id: option.id,\n required: option.required\n }, option.label))) : children;\n const context = {\n toggleOption,\n value,\n disabled: restProps.disabled,\n name: restProps.name,\n // https://github.com/ant-design/ant-design/issues/16376\n registerValue,\n cancelValue\n };\n const classString = classNames(groupPrefixCls, {\n [`${groupPrefixCls}-rtl`]: direction === 'rtl'\n }, className, rootClassName, cssVarCls, rootCls, hashId);\n return wrapCSSVar( /*#__PURE__*/React.createElement(\"div\", Object.assign({\n className: classString,\n style: style\n }, domProps, {\n ref: ref\n }), /*#__PURE__*/React.createElement(GroupContext.Provider, {\n value: context\n }, childrenNode)));\n});\nexport { GroupContext };\nexport default CheckboxGroup;"],"mappings":"AAAA,YAAY;;AAEZ,OAAOA,kBAAkB,MAAM,8CAA8C;AAC7E,IAAIC,MAAM,GAAG,IAAI,IAAI,IAAI,CAACA,MAAM,IAAI,UAAUC,CAAC,EAAEC,CAAC,EAAE;EAClD,IAAIC,CAAC,GAAG,CAAC,CAAC;EACV,KAAK,IAAIC,CAAC,IAAIH,CAAC,EAAE,IAAII,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACP,CAAC,EAAEG,CAAC,CAAC,IAAIF,CAAC,CAACO,OAAO,CAACL,CAAC,CAAC,GAAG,CAAC,EAAED,CAAC,CAACC,CAAC,CAAC,GAAGH,CAAC,CAACG,CAAC,CAAC;EAChG,IAAIH,CAAC,IAAI,IAAI,IAAI,OAAOI,MAAM,CAACK,qBAAqB,KAAK,UAAU,EAAE,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEP,CAAC,GAAGC,MAAM,CAACK,qBAAqB,CAACT,CAAC,CAAC,EAAEU,CAAC,GAAGP,CAAC,CAACQ,MAAM,EAAED,CAAC,EAAE,EAAE;IAC3I,IAAIT,CAAC,CAACO,OAAO,CAACL,CAAC,CAACO,CAAC,CAAC,CAAC,GAAG,CAAC,IAAIN,MAAM,CAACC,SAAS,CAACO,oBAAoB,CAACL,IAAI,CAACP,CAAC,EAAEG,CAAC,CAACO,CAAC,CAAC,CAAC,EAAER,CAAC,CAACC,CAAC,CAACO,CAAC,CAAC,CAAC,GAAGV,CAAC,CAACG,CAAC,CAACO,CAAC,CAAC,CAAC;EACnG;EACA,OAAOR,CAAC;AACV,CAAC;AACD,OAAO,KAAKW,KAAK,MAAM,OAAO;AAC9B,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,IAAI,MAAM,iBAAiB;AAClC,SAASC,aAAa,QAAQ,oBAAoB;AAClD,OAAOC,YAAY,MAAM,uCAAuC;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