1 line
7.3 KiB
JSON
1 line
7.3 KiB
JSON
{"ast":null,"code":"\"use client\";\n\nimport React, { useMemo } from 'react';\nimport useMergedState from \"rc-util/es/hooks/useMergedState\";\nimport Select from '../../select';\nimport { ColorFormat } from '../interface';\nimport ColorAlphaInput from './ColorAlphaInput';\nimport ColorHexInput from './ColorHexInput';\nimport ColorHsbInput from './ColorHsbInput';\nimport ColorRgbInput from './ColorRgbInput';\nconst selectOptions = [ColorFormat.hex, ColorFormat.hsb, ColorFormat.rgb].map(format => ({\n value: format,\n label: format.toLocaleUpperCase()\n}));\nconst ColorInput = props => {\n const {\n prefixCls,\n format,\n value,\n disabledAlpha,\n onFormatChange,\n onChange\n } = props;\n const [colorFormat, setColorFormat] = useMergedState(ColorFormat.hex, {\n value: format,\n onChange: onFormatChange\n });\n const colorInputPrefixCls = `${prefixCls}-input`;\n const handleFormatChange = newFormat => {\n setColorFormat(newFormat);\n };\n const steppersNode = useMemo(() => {\n const inputProps = {\n value,\n prefixCls,\n onChange\n };\n switch (colorFormat) {\n case ColorFormat.hsb:\n return /*#__PURE__*/React.createElement(ColorHsbInput, Object.assign({}, inputProps));\n case ColorFormat.rgb:\n return /*#__PURE__*/React.createElement(ColorRgbInput, Object.assign({}, inputProps));\n // case ColorFormat.hex:\n default:\n return /*#__PURE__*/React.createElement(ColorHexInput, Object.assign({}, inputProps));\n }\n }, [colorFormat, prefixCls, value, onChange]);\n return /*#__PURE__*/React.createElement(\"div\", {\n className: `${colorInputPrefixCls}-container`\n }, /*#__PURE__*/React.createElement(Select, {\n value: colorFormat,\n variant: \"borderless\",\n getPopupContainer: current => current,\n popupMatchSelectWidth: 68,\n placement: \"bottomRight\",\n onChange: handleFormatChange,\n className: `${prefixCls}-format-select`,\n size: \"small\",\n options: selectOptions\n }), /*#__PURE__*/React.createElement(\"div\", {\n className: colorInputPrefixCls\n }, steppersNode), !disabledAlpha && ( /*#__PURE__*/React.createElement(ColorAlphaInput, {\n prefixCls: prefixCls,\n value: value,\n onChange: onChange\n })));\n};\nexport default ColorInput;","map":{"version":3,"names":["React","useMemo","useMergedState","Select","ColorFormat","ColorAlphaInput","ColorHexInput","ColorHsbInput","ColorRgbInput","selectOptions","hex","hsb","rgb","map","format","value","label","toLocaleUpperCase","ColorInput","props","prefixCls","disabledAlpha","onFormatChange","onChange","colorFormat","setColorFormat","colorInputPrefixCls","handleFormatChange","newFormat","steppersNode","inputProps","createElement","Object","assign","className","variant","getPopupContainer","current","popupMatchSelectWidth","placement","size","options"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/antd/es/color-picker/components/ColorInput.js"],"sourcesContent":["\"use client\";\n\nimport React, { useMemo } from 'react';\nimport useMergedState from \"rc-util/es/hooks/useMergedState\";\nimport Select from '../../select';\nimport { ColorFormat } from '../interface';\nimport ColorAlphaInput from './ColorAlphaInput';\nimport ColorHexInput from './ColorHexInput';\nimport ColorHsbInput from './ColorHsbInput';\nimport ColorRgbInput from './ColorRgbInput';\nconst selectOptions = [ColorFormat.hex, ColorFormat.hsb, ColorFormat.rgb].map(format => ({\n value: format,\n label: format.toLocaleUpperCase()\n}));\nconst ColorInput = props => {\n const {\n prefixCls,\n format,\n value,\n disabledAlpha,\n onFormatChange,\n onChange\n } = props;\n const [colorFormat, setColorFormat] = useMergedState(ColorFormat.hex, {\n value: format,\n onChange: onFormatChange\n });\n const colorInputPrefixCls = `${prefixCls}-input`;\n const handleFormatChange = newFormat => {\n setColorFormat(newFormat);\n };\n const steppersNode = useMemo(() => {\n const inputProps = {\n value,\n prefixCls,\n onChange\n };\n switch (colorFormat) {\n case ColorFormat.hsb:\n return /*#__PURE__*/React.createElement(ColorHsbInput, Object.assign({}, inputProps));\n case ColorFormat.rgb:\n return /*#__PURE__*/React.createElement(ColorRgbInput, Object.assign({}, inputProps));\n // case ColorFormat.hex:\n default:\n return /*#__PURE__*/React.createElement(ColorHexInput, Object.assign({}, inputProps));\n }\n }, [colorFormat, prefixCls, value, onChange]);\n return /*#__PURE__*/React.createElement(\"div\", {\n className: `${colorInputPrefixCls}-container`\n }, /*#__PURE__*/React.createElement(Select, {\n value: colorFormat,\n variant: \"borderless\",\n getPopupContainer: current => current,\n popupMatchSelectWidth: 68,\n placement: \"bottomRight\",\n onChange: handleFormatChange,\n className: `${prefixCls}-format-select`,\n size: \"small\",\n options: selectOptions\n }), /*#__PURE__*/React.createElement(\"div\", {\n className: colorInputPrefixCls\n }, steppersNode), !disabledAlpha && ( /*#__PURE__*/React.createElement(ColorAlphaInput, {\n prefixCls: prefixCls,\n value: value,\n onChange: onChange\n })));\n};\nexport default ColorInput;"],"mappings":"AAAA,YAAY;;AAEZ,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,OAAOC,cAAc,MAAM,iCAAiC;AAC5D,OAAOC,MAAM,MAAM,cAAc;AACjC,SAASC,WAAW,QAAQ,cAAc;AAC1C,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,OAAOC,aAAa,MAAM,iBAAiB;AAC3C,OAAOC,aAAa,MAAM,iBAAiB;AAC3C,OAAOC,aAAa,MAAM,iBAAiB;AAC3C,MAAMC,aAAa,GAAG,CAACL,WAAW,CAACM,GAAG,EAAEN,WAAW,CAACO,GAAG,EAAEP,WAAW,CAACQ,GAAG,CAAC,CAACC,GAAG,CAACC,MAAM,KAAK;EACvFC,KAAK,EAAED,MAAM;EACbE,KAAK,EAAEF,MAAM,CAACG,iBAAiB,CAAC;AAClC,CAAC,CAAC,CAAC;AACH,MAAMC,UAAU,GAAGC,KAAK,IAAI;EAC1B,MAAM;IACJC,SAAS;IACTN,MAAM;IACNC,KAAK;IACLM,aAAa;IACbC,cAAc;IACdC;EACF,CAAC,GAAGJ,KAAK;EACT,MAAM,CAACK,WAAW,EAAEC,cAAc,CAAC,GAAGvB,cAAc,CAACE,WAAW,CAACM,GAAG,EAAE;IACpEK,KAAK,EAAED,MAAM;IACbS,QAAQ,EAAED;EACZ,CAAC,CAAC;EACF,MAAMI,mBAAmB,GAAG,GAAGN,SAAS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