1 line
6.4 KiB
JSON
1 line
6.4 KiB
JSON
{"ast":null,"code":"\"use client\";\n\nimport React, { useEffect, useState } from 'react';\nimport { generateColor, getRoundNumber } from '../util';\nimport ColorSteppers from './ColorSteppers';\nconst ColorHsbInput = _ref => {\n let {\n prefixCls,\n value,\n onChange\n } = _ref;\n const colorHsbInputPrefixCls = `${prefixCls}-hsb-input`;\n const [hsbValue, setHsbValue] = useState(generateColor(value || '#000'));\n // Update step value\n useEffect(() => {\n if (value) {\n setHsbValue(value);\n }\n }, [value]);\n const handleHsbChange = (step, type) => {\n const hsb = hsbValue.toHsb();\n hsb[type] = type === 'h' ? step : (step || 0) / 100;\n const genColor = generateColor(hsb);\n if (!value) {\n setHsbValue(genColor);\n }\n onChange === null || onChange === void 0 ? void 0 : onChange(genColor);\n };\n return /*#__PURE__*/React.createElement(\"div\", {\n className: colorHsbInputPrefixCls\n }, /*#__PURE__*/React.createElement(ColorSteppers, {\n max: 360,\n min: 0,\n value: Number(hsbValue.toHsb().h),\n prefixCls: prefixCls,\n className: colorHsbInputPrefixCls,\n formatter: step => getRoundNumber(step || 0).toString(),\n onChange: step => handleHsbChange(Number(step), 'h')\n }), /*#__PURE__*/React.createElement(ColorSteppers, {\n max: 100,\n min: 0,\n value: Number(hsbValue.toHsb().s) * 100,\n prefixCls: prefixCls,\n className: colorHsbInputPrefixCls,\n formatter: step => `${getRoundNumber(step || 0)}%`,\n onChange: step => handleHsbChange(Number(step), 's')\n }), /*#__PURE__*/React.createElement(ColorSteppers, {\n max: 100,\n min: 0,\n value: Number(hsbValue.toHsb().b) * 100,\n prefixCls: prefixCls,\n className: colorHsbInputPrefixCls,\n formatter: step => `${getRoundNumber(step || 0)}%`,\n onChange: step => handleHsbChange(Number(step), 'b')\n }));\n};\nexport default ColorHsbInput;","map":{"version":3,"names":["React","useEffect","useState","generateColor","getRoundNumber","ColorSteppers","ColorHsbInput","_ref","prefixCls","value","onChange","colorHsbInputPrefixCls","hsbValue","setHsbValue","handleHsbChange","step","type","hsb","toHsb","genColor","createElement","className","max","min","Number","h","formatter","toString","s","b"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/antd/es/color-picker/components/ColorHsbInput.js"],"sourcesContent":["\"use client\";\n\nimport React, { useEffect, useState } from 'react';\nimport { generateColor, getRoundNumber } from '../util';\nimport ColorSteppers from './ColorSteppers';\nconst ColorHsbInput = _ref => {\n let {\n prefixCls,\n value,\n onChange\n } = _ref;\n const colorHsbInputPrefixCls = `${prefixCls}-hsb-input`;\n const [hsbValue, setHsbValue] = useState(generateColor(value || '#000'));\n // Update step value\n useEffect(() => {\n if (value) {\n setHsbValue(value);\n }\n }, [value]);\n const handleHsbChange = (step, type) => {\n const hsb = hsbValue.toHsb();\n hsb[type] = type === 'h' ? step : (step || 0) / 100;\n const genColor = generateColor(hsb);\n if (!value) {\n setHsbValue(genColor);\n }\n onChange === null || onChange === void 0 ? void 0 : onChange(genColor);\n };\n return /*#__PURE__*/React.createElement(\"div\", {\n className: colorHsbInputPrefixCls\n }, /*#__PURE__*/React.createElement(ColorSteppers, {\n max: 360,\n min: 0,\n value: Number(hsbValue.toHsb().h),\n prefixCls: prefixCls,\n className: colorHsbInputPrefixCls,\n formatter: step => getRoundNumber(step || 0).toString(),\n onChange: step => handleHsbChange(Number(step), 'h')\n }), /*#__PURE__*/React.createElement(ColorSteppers, {\n max: 100,\n min: 0,\n value: Number(hsbValue.toHsb().s) * 100,\n prefixCls: prefixCls,\n className: colorHsbInputPrefixCls,\n formatter: step => `${getRoundNumber(step || 0)}%`,\n onChange: step => handleHsbChange(Number(step), 's')\n }), /*#__PURE__*/React.createElement(ColorSteppers, {\n max: 100,\n min: 0,\n value: Number(hsbValue.toHsb().b) * 100,\n prefixCls: prefixCls,\n className: colorHsbInputPrefixCls,\n formatter: step => `${getRoundNumber(step || 0)}%`,\n onChange: step => handleHsbChange(Number(step), 'b')\n }));\n};\nexport default ColorHsbInput;"],"mappings":"AAAA,YAAY;;AAEZ,OAAOA,KAAK,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