1 line
17 KiB
JSON
1 line
17 KiB
JSON
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport React, { forwardRef, useMemo } from 'react';\nimport { ColorPickerPrefixCls, defaultColor } from \"./util\";\nimport classNames from 'classnames';\nimport { Color } from \"./color\";\nimport ColorBlock from \"./components/ColorBlock\";\nimport Picker from \"./components/Picker\";\nimport useColorState from \"./hooks/useColorState\";\nimport useComponent from \"./hooks/useComponent\";\nvar HUE_COLORS = [{\n color: 'rgb(255, 0, 0)',\n percent: 0\n}, {\n color: 'rgb(255, 255, 0)',\n percent: 17\n}, {\n color: 'rgb(0, 255, 0)',\n percent: 33\n}, {\n color: 'rgb(0, 255, 255)',\n percent: 50\n}, {\n color: 'rgb(0, 0, 255)',\n percent: 67\n}, {\n color: 'rgb(255, 0, 255)',\n percent: 83\n}, {\n color: 'rgb(255, 0, 0)',\n percent: 100\n}];\nvar ColorPicker = /*#__PURE__*/forwardRef(function (props, ref) {\n var value = props.value,\n defaultValue = props.defaultValue,\n _props$prefixCls = props.prefixCls,\n prefixCls = _props$prefixCls === void 0 ? ColorPickerPrefixCls : _props$prefixCls,\n onChange = props.onChange,\n onChangeComplete = props.onChangeComplete,\n className = props.className,\n style = props.style,\n panelRender = props.panelRender,\n _props$disabledAlpha = props.disabledAlpha,\n disabledAlpha = _props$disabledAlpha === void 0 ? false : _props$disabledAlpha,\n _props$disabled = props.disabled,\n disabled = _props$disabled === void 0 ? false : _props$disabled,\n components = props.components;\n\n // ========================== Components ==========================\n var _useComponent = useComponent(components),\n _useComponent2 = _slicedToArray(_useComponent, 1),\n Slider = _useComponent2[0];\n\n // ============================ Color =============================\n var _useColorState = useColorState(defaultValue || defaultColor, value),\n _useColorState2 = _slicedToArray(_useColorState, 2),\n colorValue = _useColorState2[0],\n setColorValue = _useColorState2[1];\n var alphaColor = useMemo(function () {\n return colorValue.setA(1).toRgbString();\n }, [colorValue]);\n\n // ============================ Events ============================\n var handleChange = function handleChange(data, type) {\n if (!value) {\n setColorValue(data);\n }\n onChange === null || onChange === void 0 || onChange(data, type);\n };\n\n // Convert\n var getHueColor = function getHueColor(hue) {\n return new Color(colorValue.setHue(hue));\n };\n var getAlphaColor = function getAlphaColor(alpha) {\n return new Color(colorValue.setA(alpha / 100));\n };\n\n // Slider change\n var onHueChange = function onHueChange(hue) {\n handleChange(getHueColor(hue), {\n type: 'hue',\n value: hue\n });\n };\n var onAlphaChange = function onAlphaChange(alpha) {\n handleChange(getAlphaColor(alpha), {\n type: 'alpha',\n value: alpha\n });\n };\n\n // Complete\n var onHueChangeComplete = function onHueChangeComplete(hue) {\n if (onChangeComplete) {\n onChangeComplete(getHueColor(hue));\n }\n };\n var onAlphaChangeComplete = function onAlphaChangeComplete(alpha) {\n if (onChangeComplete) {\n onChangeComplete(getAlphaColor(alpha));\n }\n };\n\n // ============================ Render ============================\n var mergeCls = classNames(\"\".concat(prefixCls, \"-panel\"), className, _defineProperty({}, \"\".concat(prefixCls, \"-panel-disabled\"), disabled));\n var sharedSliderProps = {\n prefixCls: prefixCls,\n disabled: disabled,\n color: colorValue\n };\n var defaultPanel = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Picker, _extends({\n onChange: handleChange\n }, sharedSliderProps, {\n onChangeComplete: onChangeComplete\n })), /*#__PURE__*/React.createElement(\"div\", {\n className: \"\".concat(prefixCls, \"-slider-container\")\n }, /*#__PURE__*/React.createElement(\"div\", {\n className: classNames(\"\".concat(prefixCls, \"-slider-group\"), _defineProperty({}, \"\".concat(prefixCls, \"-slider-group-disabled-alpha\"), disabledAlpha))\n }, /*#__PURE__*/React.createElement(Slider, _extends({}, sharedSliderProps, {\n type: \"hue\",\n colors: HUE_COLORS,\n min: 0,\n max: 359,\n value: colorValue.getHue(),\n onChange: onHueChange,\n onChangeComplete: onHueChangeComplete\n })), !disabledAlpha && /*#__PURE__*/React.createElement(Slider, _extends({}, sharedSliderProps, {\n type: \"alpha\",\n colors: [{\n percent: 0,\n color: 'rgba(255, 0, 4, 0)'\n }, {\n percent: 100,\n color: alphaColor\n }],\n min: 0,\n max: 100,\n value: colorValue.a * 100,\n onChange: onAlphaChange,\n onChangeComplete: onAlphaChangeComplete\n }))), /*#__PURE__*/React.createElement(ColorBlock, {\n color: colorValue.toRgbString(),\n prefixCls: prefixCls\n })));\n return /*#__PURE__*/React.createElement(\"div\", {\n className: mergeCls,\n style: style,\n ref: ref\n }, typeof panelRender === 'function' ? panelRender(defaultPanel) : defaultPanel);\n});\nif (process.env.NODE_ENV !== 'production') {\n ColorPicker.displayName = 'ColorPicker';\n}\nexport default ColorPicker;","map":{"version":3,"names":["_extends","_defineProperty","_slicedToArray","React","forwardRef","useMemo","ColorPickerPrefixCls","defaultColor","classNames","Color","ColorBlock","Picker","useColorState","useComponent","HUE_COLORS","color","percent","ColorPicker","props","ref","value","defaultValue","_props$prefixCls","prefixCls","onChange","onChangeComplete","className","style","panelRender","_props$disabledAlpha","disabledAlpha","_props$disabled","disabled","components","_useComponent","_useComponent2","Slider","_useColorState","_useColorState2","colorValue","setColorValue","alphaColor","setA","toRgbString","handleChange","data","type","getHueColor","hue","setHue","getAlphaColor","alpha","onHueChange","onAlphaChange","onHueChangeComplete","onAlphaChangeComplete","mergeCls","concat","sharedSliderProps","defaultPanel","createElement","Fragment","colors","min","max","getHue","a","process","env","NODE_ENV","displayName"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/@rc-component/color-picker/es/ColorPicker.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport React, { forwardRef, useMemo } from 'react';\nimport { ColorPickerPrefixCls, defaultColor } from \"./util\";\nimport classNames from 'classnames';\nimport { Color } from \"./color\";\nimport ColorBlock from \"./components/ColorBlock\";\nimport Picker from \"./components/Picker\";\nimport useColorState from \"./hooks/useColorState\";\nimport useComponent from \"./hooks/useComponent\";\nvar HUE_COLORS = [{\n color: 'rgb(255, 0, 0)',\n percent: 0\n}, {\n color: 'rgb(255, 255, 0)',\n percent: 17\n}, {\n color: 'rgb(0, 255, 0)',\n percent: 33\n}, {\n color: 'rgb(0, 255, 255)',\n percent: 50\n}, {\n color: 'rgb(0, 0, 255)',\n percent: 67\n}, {\n color: 'rgb(255, 0, 255)',\n percent: 83\n}, {\n color: 'rgb(255, 0, 0)',\n percent: 100\n}];\nvar ColorPicker = /*#__PURE__*/forwardRef(function (props, ref) {\n var value = props.value,\n defaultValue = props.defaultValue,\n _props$prefixCls = props.prefixCls,\n prefixCls = _props$prefixCls === void 0 ? ColorPickerPrefixCls : _props$prefixCls,\n onChange = props.onChange,\n onChangeComplete = props.onChangeComplete,\n className = props.className,\n style = props.style,\n panelRender = props.panelRender,\n _props$disabledAlpha = props.disabledAlpha,\n disabledAlpha = _props$disabledAlpha === void 0 ? false : _props$disabledAlpha,\n _props$disabled = props.disabled,\n disabled = _props$disabled === void 0 ? false : _props$disabled,\n components = props.components;\n\n // ========================== Components ==========================\n var _useComponent = useComponent(components),\n _useComponent2 = _slicedToArray(_useComponent, 1),\n Slider = _useComponent2[0];\n\n // ============================ Color =============================\n var _useColorState = useColorState(defaultValue || defaultColor, value),\n _useColorState2 = _slicedToArray(_useColorState, 2),\n colorValue = _useColorState2[0],\n setColorValue = _useColorState2[1];\n var alphaColor = useMemo(function () {\n return colorValue.setA(1).toRgbString();\n }, [colorValue]);\n\n // ============================ Events ============================\n var handleChange = function handleChange(data, type) {\n if (!value) {\n setColorValue(data);\n }\n onChange === null || onChange === void 0 || onChange(data, type);\n };\n\n // Convert\n var getHueColor = function getHueColor(hue) {\n return new Color(colorValue.setHue(hue));\n };\n var getAlphaColor = function getAlphaColor(alpha) {\n return new Color(colorValue.setA(alpha / 100));\n };\n\n // Slider change\n var onHueChange = function onHueChange(hue) {\n handleChange(getHueColor(hue), {\n type: 'hue',\n value: hue\n });\n };\n var onAlphaChange = function onAlphaChange(alpha) {\n handleChange(getAlphaColor(alpha), {\n type: 'alpha',\n value: alpha\n });\n };\n\n // Complete\n var onHueChangeComplete = function onHueChangeComplete(hue) {\n if (onChangeComplete) {\n onChangeComplete(getHueColor(hue));\n }\n };\n var onAlphaChangeComplete = function onAlphaChangeComplete(alpha) {\n if (onChangeComplete) {\n onChangeComplete(getAlphaColor(alpha));\n }\n };\n\n // ============================ Render ============================\n var mergeCls = classNames(\"\".concat(prefixCls, \"-panel\"), className, _defineProperty({}, \"\".concat(prefixCls, \"-panel-disabled\"), disabled));\n var sharedSliderProps = {\n prefixCls: prefixCls,\n disabled: disabled,\n color: colorValue\n };\n var defaultPanel = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Picker, _extends({\n onChange: handleChange\n }, sharedSliderProps, {\n onChangeComplete: onChangeComplete\n })), /*#__PURE__*/React.createElement(\"div\", {\n className: \"\".concat(prefixCls, \"-slider-container\")\n }, /*#__PURE__*/React.createElement(\"div\", {\n className: classNames(\"\".concat(prefixCls, \"-slider-group\"), _defineProperty({}, \"\".concat(prefixCls, \"-slider-group-disabled-alpha\"), disabledAlpha))\n }, /*#__PURE__*/React.createElement(Slider, _extends({}, sharedSliderProps, {\n type: \"hue\",\n colors: HUE_COLORS,\n min: 0,\n max: 359,\n value: colorValue.getHue(),\n onChange: onHueChange,\n onChangeComplete: onHueChangeComplete\n })), !disabledAlpha && /*#__PURE__*/React.createElement(Slider, _extends({}, sharedSliderProps, {\n type: \"alpha\",\n colors: [{\n percent: 0,\n color: 'rgba(255, 0, 4, 0)'\n }, {\n percent: 100,\n color: alphaColor\n }],\n min: 0,\n max: 100,\n value: colorValue.a * 100,\n onChange: onAlphaChange,\n onChangeComplete: onAlphaChangeComplete\n }))), /*#__PURE__*/React.createElement(ColorBlock, {\n color: colorValue.toRgbString(),\n prefixCls: prefixCls\n })));\n return /*#__PURE__*/React.createElement(\"div\", {\n className: mergeCls,\n style: style,\n ref: ref\n }, typeof panelRender === 'function' ? panelRender(defaultPanel) : defaultPanel);\n});\nif (process.env.NODE_ENV !== 'production') {\n ColorPicker.displayName = 'ColorPicker';\n}\nexport default ColorPicker;"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,oCAAoC;AACzD,OAAOC,eAAe,MAAM,2CAA2C;AACvE,OAAOC,cAAc,MAAM,0CAA0C;AACrE,OAAOC,KAAK,IAAIC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAClD,SAASC,oBAAoB,EAAEC,YAAY,QAAQ,QAAQ;AAC3D,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,KAAK,QAAQ,SAAS;AAC/B,OAAOC,UAAU,MAAM,yBAAyB;AAChD,OAAOC,MAAM,MAAM,qBAAqB;AACxC,OAAOC,aAAa,MAAM,uBAAuB;AACjD,OAAOC,YAAY,MAAM,sBAAsB;AAC/C,IAAIC,UAAU,GAAG,CAAC;EAChBC,KAAK,EAAE,gBAAgB;EACvBC,OAAO,EAAE;AACX,CAAC,EAAE;EACDD,KAAK,EAAE,kBAAkB;EACzBC,OAAO,EAAE;AACX,CAAC,EAAE;EACDD,KAAK,EAAE,gBAAgB;EACvBC,OAAO,EAAE;AACX,CAAC,EAAE;EACDD,KAAK,EAAE,kBAAkB;EACzBC,OAAO,EAAE;AACX,CAAC,EAAE;EACDD,KAAK,EAAE,gBAAgB;EACvBC,OAAO,EAAE;AACX,CAAC,EAAE;EACDD,KAAK,EAAE,kBAAkB;EACzBC,OAAO,EAAE;AACX,CAAC,EAAE;EACDD,KAAK,EAAE,gBAAgB;EACvBC,OAAO,EAAE;AACX,CAAC,CAAC;AACF,IAAIC,WAAW,GAAG,aAAab,UAAU,CAAC,UAAUc,KAAK,EAAEC,GAAG,EAAE;EAC9D,IAAIC,KAAK,GAAGF,KAAK,CAACE,KAAK;IACrBC,YAAY,GAAGH,KAAK,CAAC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