1 line
7.1 KiB
JSON
1 line
7.1 KiB
JSON
|
{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport { Color } from \"./color\";\nexport var ColorPickerPrefixCls = 'rc-color-picker';\nexport var generateColor = function generateColor(color) {\n if (color instanceof Color) {\n return color;\n }\n return new Color(color);\n};\nexport var defaultColor = generateColor('#1677ff');\nexport var calculateColor = function calculateColor(props) {\n var offset = props.offset,\n targetRef = props.targetRef,\n containerRef = props.containerRef,\n color = props.color,\n type = props.type;\n var _containerRef$current = containerRef.current.getBoundingClientRect(),\n width = _containerRef$current.width,\n height = _containerRef$current.height;\n var _targetRef$current$ge = targetRef.current.getBoundingClientRect(),\n targetWidth = _targetRef$current$ge.width,\n targetHeight = _targetRef$current$ge.height;\n var centerOffsetX = targetWidth / 2;\n var centerOffsetY = targetHeight / 2;\n var saturation = (offset.x + centerOffsetX) / width;\n var bright = 1 - (offset.y + centerOffsetY) / height;\n var hsb = color.toHsb();\n var alphaOffset = saturation;\n var hueOffset = (offset.x + centerOffsetX) / width * 360;\n if (type) {\n switch (type) {\n case 'hue':\n return generateColor(_objectSpread(_objectSpread({}, hsb), {}, {\n h: hueOffset <= 0 ? 0 : hueOffset\n }));\n case 'alpha':\n return generateColor(_objectSpread(_objectSpread({}, hsb), {}, {\n a: alphaOffset <= 0 ? 0 : alphaOffset\n }));\n }\n }\n return generateColor({\n h: hsb.h,\n s: saturation <= 0 ? 0 : saturation,\n b: bright >= 1 ? 1 : bright,\n a: hsb.a\n });\n};\nexport var calcOffset = function calcOffset(color, type) {\n var hsb = color.toHsb();\n switch (type) {\n case 'hue':\n return {\n x: hsb.h / 360 * 100,\n y: 50\n };\n case 'alpha':\n return {\n x: color.a * 100,\n y: 50\n };\n\n // Picker panel\n default:\n return {\n x: hsb.s * 100,\n y: (1 - hsb.b) * 100\n };\n }\n};","map":{"version":3,"names":["_objectSpread","Color","ColorPickerPrefixCls","generateColor","color","defaultColor","calculateColor","props","offset","targetRef","containerRef","type","_containerRef$current","current","getBoundingClientRect","width","height","_targetRef$current$ge","targetWidth","targetHeight","centerOffsetX","centerOffsetY","saturation","x","bright","y","hsb","toHsb","alphaOffset","hueOffset","h","a","s","b","calcOffset"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/@rc-component/color-picker/es/util.js"],"sourcesContent":["import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport { Color } from \"./color\";\nexport var ColorPickerPrefixCls = 'rc-color-picker';\nexport var generateColor = function generateColor(color) {\n if (color instanceof Color) {\n return color;\n }\n return new Color(color);\n};\nexport var defaultColor = generateColor('#1677ff');\nexport var calculateColor = function calculateColor(props) {\n var offset = props.offset,\n targetRef = props.targetRef,\n containerRef = props.containerRef,\n color = props.color,\n type = props.type;\n var _containerRef$current = containerRef.current.getBoundingClientRect(),\n width = _containerRef$current.width,\n height = _containerRef$current.height;\n var _targetRef$current$ge = targetRef.current.getBoundingClientRect(),\n targetWidth = _targetRef$current$ge.width,\n targetHeight = _targetRef$current$ge.height;\n var centerOffsetX = targetWidth / 2;\n var centerOffsetY = targetHeight / 2;\n var saturation = (offset.x + centerOffsetX) / width;\n var bright = 1 - (offset.y + centerOffsetY) / height;\n var hsb = color.toHsb();\n var alphaOffset = saturation;\n var hueOffset = (offset.x + centerOffsetX) / width * 360;\n if (type) {\n switch (type) {\n case 'hue':\n return generateColor(_objectSpread(_objectSpread({}, hsb), {},
|