@chayns-components/color-picker 5.0.0-beta.911 → 5.0.0-beta.913

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,7 +18,9 @@ const ColorPickerContext = exports.ColorPickerContext = /*#__PURE__*/_react.defa
18
18
  shouldGetCoordinates: undefined,
19
19
  updateShouldGetCoordinates: undefined,
20
20
  shouldCallOnSelect: undefined,
21
- updateShouldCallOnSelect: undefined
21
+ updateShouldCallOnSelect: undefined,
22
+ canGetColorFromArea: undefined,
23
+ updateCanGetColorFromArea: undefined
22
24
  });
23
25
  ColorPickerContext.displayName = 'ColorPickerContext';
24
26
  const ColorPickerProvider = ({
@@ -31,6 +33,7 @@ const ColorPickerProvider = ({
31
33
  const [internalIsPresetColor, setInternalIsPresetColor] = (0, _react.useState)(false);
32
34
  const [internalShouldGetCoordinates, setInternalShouldGetCoordinates] = (0, _react.useState)(true);
33
35
  const [internalShouldCallOnSelect, setInternalShouldCallOnSelect] = (0, _react.useState)(false);
36
+ const [internalCanGetColorFromArea, setInternalCanGetColorFromArea] = (0, _react.useState)(false);
34
37
  const updateSelectedColor = (0, _react.useCallback)(color => {
35
38
  setInternalSelectedColor(color);
36
39
  }, []);
@@ -46,6 +49,9 @@ const ColorPickerProvider = ({
46
49
  const updateShouldCallOnSelect = (0, _react.useCallback)(shouldCallOnSelect => {
47
50
  setInternalShouldCallOnSelect(shouldCallOnSelect);
48
51
  }, []);
52
+ const updateCanGetColorFromArea = (0, _react.useCallback)(canGetColorFromArea => {
53
+ setInternalCanGetColorFromArea(canGetColorFromArea);
54
+ }, []);
49
55
  (0, _react.useEffect)(() => {
50
56
  let newColor = selectedColor;
51
57
  if (newColor && !(0, _color.isValidRGBA)(newColor)) {
@@ -77,8 +83,10 @@ const ColorPickerProvider = ({
77
83
  shouldGetCoordinates: internalShouldGetCoordinates,
78
84
  updateShouldGetCoordinates,
79
85
  shouldCallOnSelect: internalShouldCallOnSelect,
80
- updateShouldCallOnSelect
81
- }), [internalHueColor, internalIsPresetColor, internalSelectedColor, internalShouldCallOnSelect, internalShouldGetCoordinates, updateHueColor, updateIsPresetColor, updateSelectedColor, updateShouldCallOnSelect, updateShouldGetCoordinates]);
86
+ updateShouldCallOnSelect,
87
+ canGetColorFromArea: internalCanGetColorFromArea,
88
+ updateCanGetColorFromArea
89
+ }), [internalCanGetColorFromArea, internalHueColor, internalIsPresetColor, internalSelectedColor, internalShouldCallOnSelect, internalShouldGetCoordinates, updateCanGetColorFromArea, updateHueColor, updateIsPresetColor, updateSelectedColor, updateShouldCallOnSelect, updateShouldGetCoordinates]);
82
90
  return /*#__PURE__*/_react.default.createElement(ColorPickerContext.Provider, {
83
91
  value: providerValue
84
92
  }, children);
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPickerProvider.js","names":["_react","_interopRequireWildcard","require","_color","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ColorPickerContext","exports","React","createContext","selectedColor","undefined","updateSelectedColor","hueColor","updateHueColor","isPresetColor","updateIsPresetColor","shouldGetCoordinates","updateShouldGetCoordinates","shouldCallOnSelect","updateShouldCallOnSelect","displayName","ColorPickerProvider","children","onSelect","internalSelectedColor","setInternalSelectedColor","useState","internalHueColor","setInternalHueColor","internalIsPresetColor","setInternalIsPresetColor","internalShouldGetCoordinates","setInternalShouldGetCoordinates","internalShouldCallOnSelect","setInternalShouldCallOnSelect","useCallback","color","useEffect","newColor","isValidRGBA","g","b","hexToRgb","providerValue","useMemo","createElement","Provider","value","_default"],"sources":["../../../src/components/ColorPickerProvider.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState, type ReactNode } from 'react';\nimport { hexToRgb, isValidRGBA } from '../utils/color';\n\ninterface IColorPickerContext {\n selectedColor?: string;\n updateSelectedColor?: (color: string | undefined) => void;\n hueColor?: string;\n updateHueColor?: (color: string | undefined) => void;\n isPresetColor?: boolean;\n updateIsPresetColor?: (isPresetColor: boolean) => void;\n shouldGetCoordinates?: boolean;\n updateShouldGetCoordinates?: (shouldGetCoordinates: boolean) => void;\n shouldCallOnSelect?: boolean;\n updateShouldCallOnSelect?: (shouldCallOnSelect: boolean) => void;\n}\n\nexport const ColorPickerContext = React.createContext<IColorPickerContext>({\n selectedColor: undefined,\n updateSelectedColor: undefined,\n hueColor: undefined,\n updateHueColor: undefined,\n isPresetColor: undefined,\n updateIsPresetColor: undefined,\n shouldGetCoordinates: undefined,\n updateShouldGetCoordinates: undefined,\n shouldCallOnSelect: undefined,\n updateShouldCallOnSelect: undefined,\n});\n\nColorPickerContext.displayName = 'ColorPickerContext';\n\ninterface ColorPickerProviderProps {\n /**\n * The children of the provider.\n */\n children: ReactNode;\n /**\n * Function to be executed when a color is selected.\n */\n onSelect?: (color: string) => void;\n /**\n * The color that should be preselected.\n */\n selectedColor?: string;\n}\n\nconst ColorPickerProvider = ({ children, selectedColor, onSelect }: ColorPickerProviderProps) => {\n const [internalSelectedColor, setInternalSelectedColor] = useState<string>();\n const [internalHueColor, setInternalHueColor] = useState<string>();\n const [internalIsPresetColor, setInternalIsPresetColor] = useState<boolean>(false);\n const [internalShouldGetCoordinates, setInternalShouldGetCoordinates] = useState<boolean>(true);\n const [internalShouldCallOnSelect, setInternalShouldCallOnSelect] = useState<boolean>(false);\n\n const updateSelectedColor = useCallback((color: string | undefined) => {\n setInternalSelectedColor(color);\n }, []);\n\n const updateHueColor = useCallback((color: string | undefined) => {\n setInternalHueColor(color);\n }, []);\n\n const updateIsPresetColor = useCallback((isPresetColor: boolean) => {\n setInternalIsPresetColor(isPresetColor);\n }, []);\n\n const updateShouldGetCoordinates = useCallback((shouldGetCoordinates: boolean) => {\n setInternalShouldGetCoordinates(shouldGetCoordinates);\n }, []);\n\n const updateShouldCallOnSelect = useCallback((shouldCallOnSelect: boolean) => {\n setInternalShouldCallOnSelect(shouldCallOnSelect);\n }, []);\n\n useEffect(() => {\n let newColor = selectedColor;\n\n if (newColor && !isValidRGBA(newColor)) {\n const { r, g, b, a } = hexToRgb(newColor);\n\n newColor = `rgba(${r},${g},${b},${a})`;\n }\n\n setInternalSelectedColor(newColor);\n setInternalHueColor(newColor);\n setInternalIsPresetColor(true);\n }, [selectedColor]);\n\n useEffect(() => {\n if (typeof onSelect === 'function' && internalShouldCallOnSelect && internalSelectedColor) {\n onSelect(internalSelectedColor);\n\n setInternalShouldCallOnSelect(false);\n }\n }, [internalSelectedColor, internalShouldCallOnSelect, onSelect]);\n\n const providerValue = useMemo<IColorPickerContext>(\n () => ({\n selectedColor: internalSelectedColor,\n updateSelectedColor,\n hueColor: internalHueColor,\n updateHueColor,\n isPresetColor: internalIsPresetColor,\n updateIsPresetColor,\n shouldGetCoordinates: internalShouldGetCoordinates,\n updateShouldGetCoordinates,\n shouldCallOnSelect: internalShouldCallOnSelect,\n updateShouldCallOnSelect,\n }),\n [\n internalHueColor,\n internalIsPresetColor,\n internalSelectedColor,\n internalShouldCallOnSelect,\n internalShouldGetCoordinates,\n updateHueColor,\n updateIsPresetColor,\n updateSelectedColor,\n updateShouldCallOnSelect,\n updateShouldGetCoordinates,\n ],\n );\n\n return (\n <ColorPickerContext.Provider value={providerValue}>{children}</ColorPickerContext.Provider>\n );\n};\n\nColorPickerProvider.displayName = 'ColorPickerProvider';\n\nexport default ColorPickerProvider;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAuD,SAAAE,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,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,QAAQ;IAACC,KAAK,EAAEJ;EAAc,GAAErB,QAAsC,CAAC;AAEnG,CAAC;AAEDD,mBAAmB,CAACD,WAAW,GAAG,qBAAqB;AAAC,IAAA4B,QAAA,GAAA1C,OAAA,CAAAf,OAAA,GAEzC8B,mBAAmB","ignoreList":[]}
1
+ {"version":3,"file":"ColorPickerProvider.js","names":["_react","_interopRequireWildcard","require","_color","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ColorPickerContext","exports","React","createContext","selectedColor","undefined","updateSelectedColor","hueColor","updateHueColor","isPresetColor","updateIsPresetColor","shouldGetCoordinates","updateShouldGetCoordinates","shouldCallOnSelect","updateShouldCallOnSelect","canGetColorFromArea","updateCanGetColorFromArea","displayName","ColorPickerProvider","children","onSelect","internalSelectedColor","setInternalSelectedColor","useState","internalHueColor","setInternalHueColor","internalIsPresetColor","setInternalIsPresetColor","internalShouldGetCoordinates","setInternalShouldGetCoordinates","internalShouldCallOnSelect","setInternalShouldCallOnSelect","internalCanGetColorFromArea","setInternalCanGetColorFromArea","useCallback","color","useEffect","newColor","isValidRGBA","g","b","hexToRgb","providerValue","useMemo","createElement","Provider","value","_default"],"sources":["../../../src/components/ColorPickerProvider.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState, type ReactNode } from 'react';\nimport { hexToRgb, isValidRGBA } from '../utils/color';\n\ninterface IColorPickerContext {\n selectedColor?: string;\n updateSelectedColor?: (color: string | undefined) => void;\n hueColor?: string;\n updateHueColor?: (color: string | undefined) => void;\n isPresetColor?: boolean;\n updateIsPresetColor?: (isPresetColor: boolean) => void;\n shouldGetCoordinates?: boolean;\n updateShouldGetCoordinates?: (shouldGetCoordinates: boolean) => void;\n shouldCallOnSelect?: boolean;\n updateShouldCallOnSelect?: (shouldCallOnSelect: boolean) => void;\n canGetColorFromArea?: boolean;\n updateCanGetColorFromArea?: (canGetColorFromArea: boolean) => void;\n}\n\nexport const ColorPickerContext = React.createContext<IColorPickerContext>({\n selectedColor: undefined,\n updateSelectedColor: undefined,\n hueColor: undefined,\n updateHueColor: undefined,\n isPresetColor: undefined,\n updateIsPresetColor: undefined,\n shouldGetCoordinates: undefined,\n updateShouldGetCoordinates: undefined,\n shouldCallOnSelect: undefined,\n updateShouldCallOnSelect: undefined,\n canGetColorFromArea: undefined,\n updateCanGetColorFromArea: undefined,\n});\n\nColorPickerContext.displayName = 'ColorPickerContext';\n\ninterface ColorPickerProviderProps {\n /**\n * The children of the provider.\n */\n children: ReactNode;\n /**\n * Function to be executed when a color is selected.\n */\n onSelect?: (color: string) => void;\n /**\n * The color that should be preselected.\n */\n selectedColor?: string;\n}\n\nconst ColorPickerProvider = ({ children, selectedColor, onSelect }: ColorPickerProviderProps) => {\n const [internalSelectedColor, setInternalSelectedColor] = useState<string>();\n const [internalHueColor, setInternalHueColor] = useState<string>();\n const [internalIsPresetColor, setInternalIsPresetColor] = useState<boolean>(false);\n const [internalShouldGetCoordinates, setInternalShouldGetCoordinates] = useState<boolean>(true);\n const [internalShouldCallOnSelect, setInternalShouldCallOnSelect] = useState<boolean>(false);\n const [internalCanGetColorFromArea, setInternalCanGetColorFromArea] = useState<boolean>(false);\n\n const updateSelectedColor = useCallback((color: string | undefined) => {\n setInternalSelectedColor(color);\n }, []);\n\n const updateHueColor = useCallback((color: string | undefined) => {\n setInternalHueColor(color);\n }, []);\n\n const updateIsPresetColor = useCallback((isPresetColor: boolean) => {\n setInternalIsPresetColor(isPresetColor);\n }, []);\n\n const updateShouldGetCoordinates = useCallback((shouldGetCoordinates: boolean) => {\n setInternalShouldGetCoordinates(shouldGetCoordinates);\n }, []);\n\n const updateShouldCallOnSelect = useCallback((shouldCallOnSelect: boolean) => {\n setInternalShouldCallOnSelect(shouldCallOnSelect);\n }, []);\n\n const updateCanGetColorFromArea = useCallback((canGetColorFromArea: boolean) => {\n setInternalCanGetColorFromArea(canGetColorFromArea);\n }, []);\n\n useEffect(() => {\n let newColor = selectedColor;\n\n if (newColor && !isValidRGBA(newColor)) {\n const { r, g, b, a } = hexToRgb(newColor);\n\n newColor = `rgba(${r},${g},${b},${a})`;\n }\n\n setInternalSelectedColor(newColor);\n setInternalHueColor(newColor);\n setInternalIsPresetColor(true);\n }, [selectedColor]);\n\n useEffect(() => {\n if (typeof onSelect === 'function' && internalShouldCallOnSelect && internalSelectedColor) {\n onSelect(internalSelectedColor);\n\n setInternalShouldCallOnSelect(false);\n }\n }, [internalSelectedColor, internalShouldCallOnSelect, onSelect]);\n\n const providerValue = useMemo<IColorPickerContext>(\n () => ({\n selectedColor: internalSelectedColor,\n updateSelectedColor,\n hueColor: internalHueColor,\n updateHueColor,\n isPresetColor: internalIsPresetColor,\n updateIsPresetColor,\n shouldGetCoordinates: internalShouldGetCoordinates,\n updateShouldGetCoordinates,\n shouldCallOnSelect: internalShouldCallOnSelect,\n updateShouldCallOnSelect,\n canGetColorFromArea: internalCanGetColorFromArea,\n updateCanGetColorFromArea,\n }),\n [\n internalCanGetColorFromArea,\n internalHueColor,\n internalIsPresetColor,\n internalSelectedColor,\n internalShouldCallOnSelect,\n internalShouldGetCoordinates,\n updateCanGetColorFromArea,\n updateHueColor,\n updateIsPresetColor,\n updateSelectedColor,\n updateShouldCallOnSelect,\n updateShouldGetCoordinates,\n ],\n );\n\n return (\n <ColorPickerContext.Provider value={providerValue}>{children}</ColorPickerContext.Provider>\n );\n};\n\nColorPickerProvider.displayName = 'ColorPickerProvider';\n\nexport default ColorPickerProvider;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAuD,SAAAE,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAA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C,aAAa,EAAEiB,qBAAqB;IACpChB,mBAAmB;IACnBC,oBAAoB,EAAEiB,4BAA4B;IAClDhB,0BAA0B;IAC1BC,kBAAkB,EAAEiB,0BAA0B;IAC9ChB,wBAAwB;IACxBC,mBAAmB,EAAEiB,2BAA2B;IAChDhB;EACJ,CAAC,CAAC,EACF,CACIgB,2BAA2B,EAC3BR,gBAAgB,EAChBE,qBAAqB,EACrBL,qBAAqB,EACrBS,0BAA0B,EAC1BF,4BAA4B,EAC5BZ,yBAAyB,EACzBR,cAAc,EACdE,mBAAmB,EACnBJ,mBAAmB,EACnBQ,wBAAwB,EACxBF,0BAA0B,CAElC,CAAC;EAED,oBACIpC,MAAA,CAAAU,OAAA,CAAA0D,aAAA,CAAC5C,kBAAkB,CAAC6C,QAAQ;IAACC,KAAK,EAAEJ;EAAc,GAAEvB,QAAsC,CAAC;AAEnG,CAAC;AAEDD,mBAAmB,CAACD,WAAW,GAAG,qBAAqB;AAAC,IAAA8B,QAAA,GAAA9C,OAAA,CAAAf,OAAA,GAEzCgC,mBAAmB","ignoreList":[]}
@@ -38,7 +38,7 @@ const ColorPickerWrapper = ({
38
38
  content: content
39
39
  }, /*#__PURE__*/_react.default.createElement(_ColorPickerWrapper.StyledColorPickerWrapperInfo, null, /*#__PURE__*/_react.default.createElement(_ColorPickerWrapper.StyledColorPickerWrapperInfoColorWrapper, {
40
40
  $shouldShowRoundPreviewColor: shouldShowRoundPreviewColor
41
- }, /*#__PURE__*/_react.default.createElement(_ColorPickerWrapper.StyledColorPickerWrapperInfoColorBackground, null), /*#__PURE__*/_react.default.createElement(_ColorPickerWrapper.StyledColorPickerWrapperInfoColor, {
41
+ }, /*#__PURE__*/_react.default.createElement(_ColorPickerWrapper.StyledColorPickerWrapperInfoColor, {
42
42
  $color: selectedColor
43
43
  })), shouldShowPreviewColorString && /*#__PURE__*/_react.default.createElement(_ColorPickerWrapper.StyledColorPickerWrapperInfoText, null, selectedColor))) : content);
44
44
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPickerWrapper.js","names":["_core","require","_react","_interopRequireWildcard","_ColorPickerPopup","_interopRequireDefault","_ColorPickerProvider","_ColorPickerWrapper","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ColorPickerWrapper","presetColors","onPresetColorRemove","onPresetColorAdd","shouldShowPresetColors","shouldShowAsPopup","shouldShowTransparencySlider","shouldShowMoreOptions","shouldShowRoundPreviewColor","shouldShowPreviewColorString","selectedColor","useContext","ColorPickerContext","content","useMemo","createElement","StyledColorPickerWrapper","Popup","StyledColorPickerWrapperInfo","StyledColorPickerWrapperInfoColorWrapper","$shouldShowRoundPreviewColor","StyledColorPickerWrapperInfoColorBackground","StyledColorPickerWrapperInfoColor","$color","StyledColorPickerWrapperInfoText","displayName","_default","exports"],"sources":["../../../../../src/components/color-picker/color-picker-wrapper/ColorPickerWrapper.tsx"],"sourcesContent":["import { Popup } from '@chayns-components/core';\nimport React, { useContext, useMemo } from 'react';\nimport type { IPresetColor } from '../../../types/colorPicker';\nimport ColorPickerPopup from '../../color-picker-popup/ColorPickerPopup';\nimport { ColorPickerContext } from '../../ColorPickerProvider';\nimport {\n StyledColorPickerWrapper,\n StyledColorPickerWrapperInfo,\n StyledColorPickerWrapperInfoColor,\n StyledColorPickerWrapperInfoColorBackground,\n StyledColorPickerWrapperInfoColorWrapper,\n StyledColorPickerWrapperInfoText,\n} from './ColorPickerWrapper.styles';\n\ninterface ColorPickerWrapperProps {\n presetColors?: IPresetColor[];\n shouldShowPresetColors: boolean;\n onPresetColorAdd?: (presetColor: IPresetColor) => void;\n onPresetColorRemove?: (presetColorId: IPresetColor['id']) => void;\n shouldShowTransparencySlider: boolean;\n shouldShowMoreOptions: boolean;\n shouldShowAsPopup: boolean;\n shouldShowPreviewColorString: boolean;\n shouldShowRoundPreviewColor: boolean;\n}\n\nconst ColorPickerWrapper = ({\n presetColors,\n onPresetColorRemove,\n onPresetColorAdd,\n shouldShowPresetColors,\n shouldShowAsPopup,\n shouldShowTransparencySlider,\n shouldShowMoreOptions,\n shouldShowRoundPreviewColor,\n shouldShowPreviewColorString,\n}: ColorPickerWrapperProps) => {\n const { selectedColor } = useContext(ColorPickerContext);\n\n const content = useMemo(\n () => (\n <ColorPickerPopup\n shouldShowPresetColors={shouldShowPresetColors}\n onPresetColorRemove={onPresetColorRemove}\n onPresetColorAdd={onPresetColorAdd}\n presetColors={presetColors}\n shouldShowMoreOptions={shouldShowMoreOptions}\n shouldShowTransparencySlider={shouldShowTransparencySlider}\n />\n ),\n [\n onPresetColorAdd,\n onPresetColorRemove,\n presetColors,\n shouldShowMoreOptions,\n shouldShowPresetColors,\n shouldShowTransparencySlider,\n ],\n );\n\n return (\n <StyledColorPickerWrapper>\n {shouldShowAsPopup ? (\n <Popup content={content}>\n <StyledColorPickerWrapperInfo>\n <StyledColorPickerWrapperInfoColorWrapper\n $shouldShowRoundPreviewColor={shouldShowRoundPreviewColor}\n >\n <StyledColorPickerWrapperInfoColorBackground />\n <StyledColorPickerWrapperInfoColor $color={selectedColor} />\n </StyledColorPickerWrapperInfoColorWrapper>\n\n {shouldShowPreviewColorString && (\n <StyledColorPickerWrapperInfoText>\n {selectedColor}\n </StyledColorPickerWrapperInfoText>\n )}\n </StyledColorPickerWrapperInfo>\n </Popup>\n ) : (\n content\n )}\n </StyledColorPickerWrapper>\n );\n};\n\nColorPickerWrapper.displayName = 'ColorPickerWrapper';\n\nexport default ColorPickerWrapper;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAEA,IAAAG,iBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AACA,IAAAM,mBAAA,GAAAN,OAAA;AAOqC,SAAAI,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA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AAgC,QAC5Bd,aAC6B,CAEZ,CAC3B,CAAC,GAERG,OAEkB,CAAC;AAEnC,CAAC;AAEDb,kBAAkB,CAACyB,WAAW,GAAG,oBAAoB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA7C,OAAA,GAEvCkB,kBAAkB","ignoreList":[]}
1
+ {"version":3,"file":"ColorPickerWrapper.js","names":["_core","require","_react","_interopRequireWildcard","_ColorPickerPopup","_interopRequireDefault","_ColorPickerProvider","_ColorPickerWrapper","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ColorPickerWrapper","presetColors","onPresetColorRemove","onPresetColorAdd","shouldShowPresetColors","shouldShowAsPopup","shouldShowTransparencySlider","shouldShowMoreOptions","shouldShowRoundPreviewColor","shouldShowPreviewColorString","selectedColor","useContext","ColorPickerContext","content","useMemo","createElement","StyledColorPickerWrapper","Popup","StyledColorPickerWrapperInfo","StyledColorPickerWrapperInfoColorWrapper","$shouldShowRoundPreviewColor","StyledColorPickerWrapperInfoColor","$color","StyledColorPickerWrapperInfoText","displayName","_default","exports"],"sources":["../../../../../src/components/color-picker/color-picker-wrapper/ColorPickerWrapper.tsx"],"sourcesContent":["import { Popup } from '@chayns-components/core';\nimport React, { useContext, useMemo } from 'react';\nimport type { IPresetColor } from '../../../types/colorPicker';\nimport ColorPickerPopup from '../../color-picker-popup/ColorPickerPopup';\nimport { ColorPickerContext } from '../../ColorPickerProvider';\nimport {\n StyledColorPickerWrapper,\n StyledColorPickerWrapperInfo,\n StyledColorPickerWrapperInfoColor,\n StyledColorPickerWrapperInfoColorWrapper,\n StyledColorPickerWrapperInfoText,\n} from './ColorPickerWrapper.styles';\n\ninterface ColorPickerWrapperProps {\n presetColors?: IPresetColor[];\n shouldShowPresetColors: boolean;\n onPresetColorAdd?: (presetColor: IPresetColor) => void;\n onPresetColorRemove?: (presetColorId: IPresetColor['id']) => void;\n shouldShowTransparencySlider: boolean;\n shouldShowMoreOptions: boolean;\n shouldShowAsPopup: boolean;\n shouldShowPreviewColorString: boolean;\n shouldShowRoundPreviewColor: boolean;\n}\n\nconst ColorPickerWrapper = ({\n presetColors,\n onPresetColorRemove,\n onPresetColorAdd,\n shouldShowPresetColors,\n shouldShowAsPopup,\n shouldShowTransparencySlider,\n shouldShowMoreOptions,\n shouldShowRoundPreviewColor,\n shouldShowPreviewColorString,\n}: ColorPickerWrapperProps) => {\n const { selectedColor } = useContext(ColorPickerContext);\n\n const content = useMemo(\n () => (\n <ColorPickerPopup\n shouldShowPresetColors={shouldShowPresetColors}\n onPresetColorRemove={onPresetColorRemove}\n onPresetColorAdd={onPresetColorAdd}\n presetColors={presetColors}\n shouldShowMoreOptions={shouldShowMoreOptions}\n shouldShowTransparencySlider={shouldShowTransparencySlider}\n />\n ),\n [\n onPresetColorAdd,\n onPresetColorRemove,\n presetColors,\n shouldShowMoreOptions,\n shouldShowPresetColors,\n shouldShowTransparencySlider,\n ],\n );\n\n return (\n <StyledColorPickerWrapper>\n {shouldShowAsPopup ? (\n <Popup content={content}>\n <StyledColorPickerWrapperInfo>\n <StyledColorPickerWrapperInfoColorWrapper\n $shouldShowRoundPreviewColor={shouldShowRoundPreviewColor}\n >\n <StyledColorPickerWrapperInfoColor $color={selectedColor} />\n </StyledColorPickerWrapperInfoColorWrapper>\n\n {shouldShowPreviewColorString && (\n <StyledColorPickerWrapperInfoText>\n {selectedColor}\n </StyledColorPickerWrapperInfoText>\n )}\n </StyledColorPickerWrapperInfo>\n </Popup>\n ) : (\n content\n )}\n </StyledColorPickerWrapper>\n );\n};\n\nColorPickerWrapper.displayName = 'ColorPickerWrapper';\n\nexport default ColorPickerWrapper;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAEA,IAAAG,iBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,oBAAA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A,CAACpC,mBAAA,CAAA4C,gCAAgC,QAC5Bb,aAC6B,CAEZ,CAC3B,CAAC,GAERG,OAEkB,CAAC;AAEnC,CAAC;AAEDb,kBAAkB,CAACwB,WAAW,GAAG,oBAAoB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA5C,OAAA,GAEvCkB,kBAAkB","ignoreList":[]}
@@ -20,6 +20,7 @@ const ColorArea = () => {
20
20
  updateIsPresetColor,
21
21
  isPresetColor,
22
22
  shouldGetCoordinates,
23
+ canGetColorFromArea,
23
24
  updateShouldGetCoordinates,
24
25
  updateShouldCallOnSelect,
25
26
  hueColor
@@ -111,8 +112,10 @@ const ColorArea = () => {
111
112
  }
112
113
  return;
113
114
  }
114
- setColor();
115
- }, [hueColor, setColor, updateIsPresetColor]);
115
+ if (canGetColorFromArea) {
116
+ setColor();
117
+ }
118
+ }, [canGetColorFromArea, hueColor, setColor, updateIsPresetColor]);
116
119
  const handleStartDrag = (0, _react.useCallback)(() => {
117
120
  if (typeof updateShouldGetCoordinates === 'function') {
118
121
  updateShouldGetCoordinates(false);
@@ -1 +1 @@
1
- {"version":3,"file":"ColorArea.js","names":["_react","_interopRequireWildcard","require","_ColorArea","_colors","_chaynsApi","_framerMotion","_color","_ColorPickerProvider","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ColorArea","selectedColor","updateSelectedColor","updateIsPresetColor","isPresetColor","shouldGetCoordinates","updateShouldGetCoordinates","updateShouldCallOnSelect","hueColor","useContext","ColorPickerContext","opacity","setOpacity","useState","scale","setScale","scaleX","scaleY","isPresetColorRef","useRef","shouldGetCoordinatesRef","canDrag","canvasRef","pseudoRef","dragControls","useDragControls","x","useMotionValue","y","useEffect","current","extractRgbValues","canvas","rect","getBoundingClientRect","width","height","setColor","useCallback","xCord","yCord","color","getColorFromCoordinates","coordinates","_canvasRef$current","ctx","getContext","hsv","rgbToHsv","hex","hsvToHex","h","s","v","colorGradiant","createLinearGradient","addColorStop","fillStyle","fillRect","transparentGradiant","handleStartDrag","cords","getCoordinatesFromColor","tolerance","handleDrag","handleClick","event","left","top","target","clientX","clientY","handlePointerUp","setRefreshScrollEnabled","move","xCords","yCords","newXCords","newYCords","handleMouseMove","handleTouchMove","preventDefault","changedTouches","pageX","pageY","window","addEventListener","removeEventListener","useMemo","createElement","StyledColorArea","StyledColorAreaCanvas","ref","StyledColorAreaPseudo","onPointerDown","onClick","StyledMotionColorAreaPointer","drag","dragConstraints","style","dragElastic","dragMomentum","onDrag","displayName","_default","exports"],"sources":["../../../../../src/components/color-picker-popup/color-area/ColorArea.tsx"],"sourcesContent":["import React, {\n MouseEvent,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport {\n StyledColorArea,\n StyledColorAreaCanvas,\n StyledColorAreaPseudo,\n StyledMotionColorAreaPointer,\n} from './ColorArea.styles';\n\nimport { hsvToHex } from '@chayns/colors';\nimport { setRefreshScrollEnabled } from 'chayns-api';\nimport { useDragControls, useMotionValue } from 'framer-motion';\nimport type { Scale } from '../../../types/colorPicker';\nimport {\n extractRgbValues,\n getColorFromCoordinates,\n getCoordinatesFromColor,\n rgbToHsv,\n} from '../../../utils/color';\nimport { ColorPickerContext } from '../../ColorPickerProvider';\n\nconst ColorArea = () => {\n const {\n selectedColor,\n updateSelectedColor,\n updateIsPresetColor,\n isPresetColor,\n shouldGetCoordinates,\n updateShouldGetCoordinates,\n updateShouldCallOnSelect,\n hueColor,\n } = useContext(ColorPickerContext);\n\n const [opacity, setOpacity] = useState<number>(1);\n const [scale, setScale] = useState<Scale>({ scaleX: 0, scaleY: 0 });\n\n const isPresetColorRef = useRef(false);\n const shouldGetCoordinatesRef = useRef(false);\n const canDrag = useRef(false);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const pseudoRef = useRef<HTMLDivElement>(null);\n\n const dragControls = useDragControls();\n\n const x = useMotionValue(0);\n const y = useMotionValue(0);\n\n useEffect(() => {\n isPresetColorRef.current = isPresetColor ?? false;\n }, [isPresetColor]);\n\n useEffect(() => {\n shouldGetCoordinatesRef.current = shouldGetCoordinates ?? true;\n }, [shouldGetCoordinates]);\n\n useEffect(() => {\n if (selectedColor) {\n const { a } = extractRgbValues(selectedColor);\n\n setOpacity(a);\n }\n }, [selectedColor]);\n\n useEffect(() => {\n const canvas = canvasRef.current;\n\n if (!canvas) {\n return;\n }\n\n const rect = canvas.getBoundingClientRect();\n\n const scaleX = canvas.width / rect.width;\n const scaleY = canvas.height / rect.height;\n\n setScale({ scaleX, scaleY });\n }, []);\n\n const setColor = useCallback(() => {\n const xCord = x.get();\n const yCord = y.get();\n\n if (typeof updateSelectedColor === 'function') {\n const color = getColorFromCoordinates({\n coordinates: {\n x: xCord,\n y: yCord,\n },\n canvas: canvasRef,\n opacity,\n scale,\n });\n\n if (color === 'transparent') {\n return;\n }\n\n updateSelectedColor(color);\n }\n }, [opacity, scale, updateSelectedColor, x, y]);\n\n useEffect(() => {\n const ctx = canvasRef.current?.getContext('2d');\n\n if (!ctx) {\n return;\n }\n\n const hsv = rgbToHsv(hueColor);\n\n const hex = hsvToHex({ h: hsv?.h ?? 1, s: 1, v: 1 });\n\n const colorGradiant = ctx.createLinearGradient(0, 0, 300, 0);\n colorGradiant.addColorStop(0, '#fff');\n colorGradiant.addColorStop(1, hex ?? 'red');\n\n ctx.fillStyle = colorGradiant;\n ctx.fillRect(0, 0, 300, 150);\n\n const transparentGradiant = ctx.createLinearGradient(0, 0, 0, 150);\n\n transparentGradiant.addColorStop(0, 'transparent');\n transparentGradiant.addColorStop(1, '#000');\n\n ctx.fillStyle = transparentGradiant;\n ctx.fillRect(0, 0, 300, 150);\n\n if (isPresetColorRef.current) {\n if (typeof updateIsPresetColor === 'function') {\n updateIsPresetColor(false);\n }\n\n return;\n }\n\n setColor();\n }, [hueColor, setColor, updateIsPresetColor]);\n\n const handleStartDrag = useCallback(() => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n canDrag.current = true;\n }, [updateShouldGetCoordinates]);\n\n useEffect(() => {\n if (selectedColor && shouldGetCoordinatesRef.current) {\n const cords = getCoordinatesFromColor({\n color: selectedColor,\n canvas: canvasRef,\n tolerance: 10,\n });\n\n if (cords) {\n x.set(cords.x);\n y.set(cords.y);\n }\n }\n }, [selectedColor, x, y]);\n\n const handleDrag = useCallback(() => {\n setColor();\n }, [setColor]);\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLDivElement>) => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n const { left, top } = (event.target as HTMLDivElement).getBoundingClientRect();\n\n x.set(event.clientX - left - 10);\n y.set(event.clientY - top - 10);\n\n setColor();\n },\n [setColor, updateShouldGetCoordinates, x, y],\n );\n\n const handlePointerUp = useCallback(() => {\n canDrag.current = false;\n\n void setRefreshScrollEnabled(true);\n\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(true);\n }\n\n if (typeof updateShouldCallOnSelect === 'function') {\n updateShouldCallOnSelect(true);\n }\n }, [updateShouldCallOnSelect, updateShouldGetCoordinates]);\n\n const move = useCallback(\n (xCords: number, yCords: number) => {\n let newXCords = xCords;\n let newYCords = yCords;\n\n switch (true) {\n case xCords > 300:\n newXCords = 300;\n break;\n case xCords < 0:\n newXCords = 0;\n break;\n default:\n break;\n }\n\n switch (true) {\n case yCords > 150:\n newYCords = 150;\n break;\n case yCords < 0:\n newYCords = 0;\n break;\n default:\n break;\n }\n\n x.set(newXCords);\n y.set(newYCords);\n\n setColor();\n },\n [setColor, x, y],\n );\n\n const handleMouseMove = useCallback(\n (event: MouseEvent) => {\n if (canDrag.current && pseudoRef.current) {\n const { left, top } = pseudoRef.current.getBoundingClientRect();\n\n const xCords = event.clientX - left - 10;\n const yCords = event.clientY - top - 10;\n\n move(xCords, yCords);\n }\n },\n [move],\n );\n\n const handleTouchMove = useCallback(\n (event: TouchEvent) => {\n if (canDrag.current && pseudoRef.current) {\n event.preventDefault();\n\n void setRefreshScrollEnabled(false);\n\n const { left, top } = pseudoRef.current.getBoundingClientRect();\n\n const xCords = event.changedTouches[0]\n ? event.changedTouches[0].clientX - left - 10\n : (event as unknown as { pageX: number }).pageX;\n const yCords = event.changedTouches[0]\n ? event.changedTouches[0].clientY - top - 10\n : (event as unknown as { pageY: number }).pageY;\n\n move(xCords, yCords);\n }\n },\n [move],\n );\n\n useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n window.addEventListener('mousemove', handleMouseMove);\n window.addEventListener('pointerup', handlePointerUp);\n window.addEventListener('touchmove', handleTouchMove);\n window.addEventListener('touchend', handlePointerUp);\n\n return () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n window.removeEventListener('mousemove', handleMouseMove);\n window.removeEventListener('pointerup', handlePointerUp);\n window.removeEventListener('touchmove', handleTouchMove);\n window.removeEventListener('touchend', handlePointerUp);\n };\n }, [handleMouseMove, handlePointerUp, handleTouchMove]);\n\n return useMemo(\n () => (\n <StyledColorArea>\n <StyledColorAreaCanvas ref={canvasRef} />\n <StyledColorAreaPseudo\n ref={pseudoRef}\n onPointerDown={handleStartDrag}\n onClick={handleClick}\n >\n <StyledMotionColorAreaPointer\n drag\n dragConstraints={pseudoRef}\n style={{ x, y }}\n dragElastic={false}\n dragMomentum={false}\n dragControls={dragControls}\n onDrag={handleDrag}\n />\n </StyledColorAreaPseudo>\n </StyledColorArea>\n ),\n [dragControls, handleClick, handleDrag, handleStartDrag, x, y],\n );\n};\n\nColorArea.displayName = 'ColorArea';\n\nexport default ColorArea;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AASA,IAAAC,UAAA,GAAAD,OAAA;AAOA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GA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,YAAY,EAAEyC,WAAW,EAAED,UAAU,EAAEJ,eAAe,EAAElC,CAAC,EAAEE,CAAC,CACjE,CAAC;AACL,CAAC;AAED5B,SAAS,CAACuG,WAAW,GAAG,WAAW;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAvH,OAAA,GAErBc,SAAS","ignoreList":[]}
1
+ {"version":3,"file":"ColorArea.js","names":["_react","_interopRequireWildcard","require","_ColorArea","_colors","_chaynsApi","_framerMotion","_color","_ColorPickerProvider","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ColorArea","selectedColor","updateSelectedColor","updateIsPresetColor","isPresetColor","shouldGetCoordinates","canGetColorFromArea","updateShouldGetCoordinates","updateShouldCallOnSelect","hueColor","useContext","ColorPickerContext","opacity","setOpacity","useState","scale","setScale","scaleX","scaleY","isPresetColorRef","useRef","shouldGetCoordinatesRef","canDrag","canvasRef","pseudoRef","dragControls","useDragControls","x","useMotionValue","y","useEffect","current","extractRgbValues","canvas","rect","getBoundingClientRect","width","height","setColor","useCallback","xCord","yCord","color","getColorFromCoordinates","coordinates","_canvasRef$current","ctx","getContext","hsv","rgbToHsv","hex","hsvToHex","h","s","v","colorGradiant","createLinearGradient","addColorStop","fillStyle","fillRect","transparentGradiant","handleStartDrag","cords","getCoordinatesFromColor","tolerance","handleDrag","handleClick","event","left","top","target","clientX","clientY","handlePointerUp","setRefreshScrollEnabled","move","xCords","yCords","newXCords","newYCords","handleMouseMove","handleTouchMove","preventDefault","changedTouches","pageX","pageY","window","addEventListener","removeEventListener","useMemo","createElement","StyledColorArea","StyledColorAreaCanvas","ref","StyledColorAreaPseudo","onPointerDown","onClick","StyledMotionColorAreaPointer","drag","dragConstraints","style","dragElastic","dragMomentum","onDrag","displayName","_default","exports"],"sources":["../../../../../src/components/color-picker-popup/color-area/ColorArea.tsx"],"sourcesContent":["import React, {\n MouseEvent,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport {\n StyledColorArea,\n StyledColorAreaCanvas,\n StyledColorAreaPseudo,\n StyledMotionColorAreaPointer,\n} from './ColorArea.styles';\n\nimport { hsvToHex } from '@chayns/colors';\nimport { setRefreshScrollEnabled } from 'chayns-api';\nimport { useDragControls, useMotionValue } from 'framer-motion';\nimport type { Scale } from '../../../types/colorPicker';\nimport {\n extractRgbValues,\n getColorFromCoordinates,\n getCoordinatesFromColor,\n rgbToHsv,\n} from '../../../utils/color';\nimport { ColorPickerContext } from '../../ColorPickerProvider';\n\nconst ColorArea = () => {\n const {\n selectedColor,\n updateSelectedColor,\n updateIsPresetColor,\n isPresetColor,\n shouldGetCoordinates,\n canGetColorFromArea,\n updateShouldGetCoordinates,\n updateShouldCallOnSelect,\n hueColor,\n } = useContext(ColorPickerContext);\n\n const [opacity, setOpacity] = useState<number>(1);\n const [scale, setScale] = useState<Scale>({ scaleX: 0, scaleY: 0 });\n\n const isPresetColorRef = useRef(false);\n const shouldGetCoordinatesRef = useRef(false);\n const canDrag = useRef(false);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const pseudoRef = useRef<HTMLDivElement>(null);\n\n const dragControls = useDragControls();\n\n const x = useMotionValue(0);\n const y = useMotionValue(0);\n\n useEffect(() => {\n isPresetColorRef.current = isPresetColor ?? false;\n }, [isPresetColor]);\n\n useEffect(() => {\n shouldGetCoordinatesRef.current = shouldGetCoordinates ?? true;\n }, [shouldGetCoordinates]);\n\n useEffect(() => {\n if (selectedColor) {\n const { a } = extractRgbValues(selectedColor);\n\n setOpacity(a);\n }\n }, [selectedColor]);\n\n useEffect(() => {\n const canvas = canvasRef.current;\n\n if (!canvas) {\n return;\n }\n\n const rect = canvas.getBoundingClientRect();\n\n const scaleX = canvas.width / rect.width;\n const scaleY = canvas.height / rect.height;\n\n setScale({ scaleX, scaleY });\n }, []);\n\n const setColor = useCallback(() => {\n const xCord = x.get();\n const yCord = y.get();\n\n if (typeof updateSelectedColor === 'function') {\n const color = getColorFromCoordinates({\n coordinates: {\n x: xCord,\n y: yCord,\n },\n canvas: canvasRef,\n opacity,\n scale,\n });\n\n if (color === 'transparent') {\n return;\n }\n\n updateSelectedColor(color);\n }\n }, [opacity, scale, updateSelectedColor, x, y]);\n\n useEffect(() => {\n const ctx = canvasRef.current?.getContext('2d');\n\n if (!ctx) {\n return;\n }\n\n const hsv = rgbToHsv(hueColor);\n\n const hex = hsvToHex({ h: hsv?.h ?? 1, s: 1, v: 1 });\n\n const colorGradiant = ctx.createLinearGradient(0, 0, 300, 0);\n colorGradiant.addColorStop(0, '#fff');\n colorGradiant.addColorStop(1, hex ?? 'red');\n\n ctx.fillStyle = colorGradiant;\n ctx.fillRect(0, 0, 300, 150);\n\n const transparentGradiant = ctx.createLinearGradient(0, 0, 0, 150);\n\n transparentGradiant.addColorStop(0, 'transparent');\n transparentGradiant.addColorStop(1, '#000');\n\n ctx.fillStyle = transparentGradiant;\n ctx.fillRect(0, 0, 300, 150);\n\n if (isPresetColorRef.current) {\n if (typeof updateIsPresetColor === 'function') {\n updateIsPresetColor(false);\n }\n\n return;\n }\n\n if (canGetColorFromArea) {\n setColor();\n }\n }, [canGetColorFromArea, hueColor, setColor, updateIsPresetColor]);\n\n const handleStartDrag = useCallback(() => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n canDrag.current = true;\n }, [updateShouldGetCoordinates]);\n\n useEffect(() => {\n if (selectedColor && shouldGetCoordinatesRef.current) {\n const cords = getCoordinatesFromColor({\n color: selectedColor,\n canvas: canvasRef,\n tolerance: 10,\n });\n\n if (cords) {\n x.set(cords.x);\n y.set(cords.y);\n }\n }\n }, [selectedColor, x, y]);\n\n const handleDrag = useCallback(() => {\n setColor();\n }, [setColor]);\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLDivElement>) => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n const { left, top } = (event.target as HTMLDivElement).getBoundingClientRect();\n\n x.set(event.clientX - left - 10);\n y.set(event.clientY - top - 10);\n\n setColor();\n },\n [setColor, updateShouldGetCoordinates, x, y],\n );\n\n const handlePointerUp = useCallback(() => {\n canDrag.current = false;\n\n void setRefreshScrollEnabled(true);\n\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(true);\n }\n\n if (typeof updateShouldCallOnSelect === 'function') {\n updateShouldCallOnSelect(true);\n }\n }, [updateShouldCallOnSelect, updateShouldGetCoordinates]);\n\n const move = useCallback(\n (xCords: number, yCords: number) => {\n let newXCords = xCords;\n let newYCords = yCords;\n\n switch (true) {\n case xCords > 300:\n newXCords = 300;\n break;\n case xCords < 0:\n newXCords = 0;\n break;\n default:\n break;\n }\n\n switch (true) {\n case yCords > 150:\n newYCords = 150;\n break;\n case yCords < 0:\n newYCords = 0;\n break;\n default:\n break;\n }\n\n x.set(newXCords);\n y.set(newYCords);\n\n setColor();\n },\n [setColor, x, y],\n );\n\n const handleMouseMove = useCallback(\n (event: MouseEvent) => {\n if (canDrag.current && pseudoRef.current) {\n const { left, top } = pseudoRef.current.getBoundingClientRect();\n\n const xCords = event.clientX - left - 10;\n const yCords = event.clientY - top - 10;\n\n move(xCords, yCords);\n }\n },\n [move],\n );\n\n const handleTouchMove = useCallback(\n (event: TouchEvent) => {\n if (canDrag.current && pseudoRef.current) {\n event.preventDefault();\n\n void setRefreshScrollEnabled(false);\n\n const { left, top } = pseudoRef.current.getBoundingClientRect();\n\n const xCords = event.changedTouches[0]\n ? event.changedTouches[0].clientX - left - 10\n : (event as unknown as { pageX: number }).pageX;\n const yCords = event.changedTouches[0]\n ? event.changedTouches[0].clientY - top - 10\n : (event as unknown as { pageY: number }).pageY;\n\n move(xCords, yCords);\n }\n },\n [move],\n );\n\n useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n window.addEventListener('mousemove', handleMouseMove);\n window.addEventListener('pointerup', handlePointerUp);\n window.addEventListener('touchmove', handleTouchMove);\n window.addEventListener('touchend', handlePointerUp);\n\n return () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n window.removeEventListener('mousemove', handleMouseMove);\n window.removeEventListener('pointerup', handlePointerUp);\n window.removeEventListener('touchmove', handleTouchMove);\n window.removeEventListener('touchend', handlePointerUp);\n };\n }, [handleMouseMove, handlePointerUp, handleTouchMove]);\n\n return useMemo(\n () => (\n <StyledColorArea>\n <StyledColorAreaCanvas ref={canvasRef} />\n <StyledColorAreaPseudo\n ref={pseudoRef}\n onPointerDown={handleStartDrag}\n onClick={handleClick}\n >\n <StyledMotionColorAreaPointer\n drag\n dragConstraints={pseudoRef}\n style={{ x, y }}\n dragElastic={false}\n dragMomentum={false}\n dragControls={dragControls}\n onDrag={handleDrag}\n />\n </StyledColorAreaPseudo>\n </StyledColorArea>\n ),\n [dragControls, handleClick, handleDrag, handleStartDrag, x, y],\n );\n};\n\nColorArea.displayName = 'ColorArea';\n\nexport default ColorArea;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AASA,IAAAC,UAAA,GAAAD,OAAA;AAOA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AAMA,IAAAM,oBAAA,GAAAN,OAAA;AAA+D,SAAAO,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,W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MACxDa,MAAM,CAACE,mBAAmB,CAAC,WAAW,EAAEP,eAAe,CAAC;MACxDK,MAAM,CAACE,mBAAmB,CAAC,UAAU,EAAEf,eAAe,CAAC;IAC3D,CAAC;EACL,CAAC,EAAE,CAACO,eAAe,EAAEP,eAAe,EAAEQ,eAAe,CAAC,CAAC;EAEvD,OAAO,IAAAQ,cAAO,EACV,mBACItH,MAAA,CAAAe,OAAA,CAAAwG,aAAA,CAACpH,UAAA,CAAAqH,eAAe,qBACZxH,MAAA,CAAAe,OAAA,CAAAwG,aAAA,CAACpH,UAAA,CAAAsH,qBAAqB;IAACC,GAAG,EAAEtE;EAAU,CAAE,CAAC,eACzCpD,MAAA,CAAAe,OAAA,CAAAwG,aAAA,CAACpH,UAAA,CAAAwH,qBAAqB;IAClBD,GAAG,EAAErE,SAAU;IACfuE,aAAa,EAAElC,eAAgB;IAC/BmC,OAAO,EAAE9B;EAAY,gBAErB/F,MAAA,CAAAe,OAAA,CAAAwG,aAAA,CAACpH,UAAA,CAAA2H,4BAA4B;IACzBC,IAAI;IACJC,eAAe,EAAE3E,SAAU;IAC3B4E,KAAK,EAAE;MAAEzE,CAAC;MAAEE;IAAE,CAAE;IAChBwE,WAAW,EAAE,KAAM;IACnBC,YAAY,EAAE,KAAM;IACpB7E,YAAY,EAAEA,YAAa;IAC3B8E,MAAM,EAAEtC;EAAW,CACtB,CACkB,CACV,CACpB,EACD,CAACxC,YAAY,EAAEyC,WAAW,EAAED,UAAU,EAAEJ,eAAe,EAAElC,CAAC,EAAEE,CAAC,CACjE,CAAC;AACL,CAAC;AAED7B,SAAS,CAACwG,WAAW,GAAG,WAAW;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAxH,OAAA,GAErBc,SAAS","ignoreList":[]}
@@ -23,6 +23,7 @@ const Sliders = ({
23
23
  updateHueColor,
24
24
  updateShouldGetCoordinates,
25
25
  updateShouldCallOnSelect,
26
+ updateCanGetColorFromArea,
26
27
  hueColor
27
28
  } = (0, _react.useContext)(_ColorPickerProvider.ColorPickerContext);
28
29
  const handleColorChange = color => {
@@ -40,18 +41,27 @@ const Sliders = ({
40
41
  updateShouldGetCoordinates(false);
41
42
  }
42
43
  };
44
+ const handleHueStart = () => {
45
+ handleStart();
46
+ if (typeof updateCanGetColorFromArea === 'function') {
47
+ updateCanGetColorFromArea(true);
48
+ }
49
+ };
43
50
  const handleEnd = () => {
44
51
  if (typeof updateShouldGetCoordinates === 'function' && typeof updateShouldCallOnSelect === 'function') {
45
52
  updateShouldGetCoordinates(true);
46
53
  updateShouldCallOnSelect(true);
47
54
  }
55
+ if (typeof updateCanGetColorFromArea === 'function') {
56
+ updateCanGetColorFromArea(false);
57
+ }
48
58
  };
49
59
  const opacity = (0, _react.useMemo)(() => (0, _color.extractRgbValues)(selectedColor ?? '').a, [selectedColor]);
50
60
  return /*#__PURE__*/_react.default.createElement(_Sliders.StyledSliders, null, /*#__PURE__*/_react.default.createElement(_Sliders.StyledSlidersWrapper, null, /*#__PURE__*/_react.default.createElement(_HueSlider.default, {
51
61
  color: hueColor,
52
62
  opacity: opacity,
53
63
  onEnd: handleEnd,
54
- onStart: handleStart,
64
+ onStart: handleHueStart,
55
65
  onChange: handleHueColorChange
56
66
  }), shouldShowTransparencySlider && /*#__PURE__*/_react.default.createElement(_TransparencySlider.default, {
57
67
  color: selectedColor,
@@ -1 +1 @@
1
- {"version":3,"file":"Sliders.js","names":["_react","_interopRequireWildcard","require","_color","_ColorPickerProvider","_HueSlider","_interopRequireDefault","_TransparencySlider","_ColorPreview","_Sliders","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Sliders","shouldShowTransparencySlider","selectedColor","updateSelectedColor","updateHueColor","updateShouldGetCoordinates","updateShouldCallOnSelect","hueColor","useContext","ColorPickerContext","handleColorChange","color","handleHueColorChange","handleStart","handleEnd","opacity","useMemo","extractRgbValues","createElement","StyledSliders","StyledSlidersWrapper","onEnd","onStart","onChange","displayName","_default","exports"],"sources":["../../../../../src/components/color-picker-popup/sliders/Sliders.tsx"],"sourcesContent":["import React, { useContext, useMemo, type CSSProperties } from 'react';\nimport { extractRgbValues } from '../../../utils/color';\nimport { ColorPickerContext } from '../../ColorPickerProvider';\nimport HueSlider from '../../hue-slider/HueSlider';\nimport TransparencySlider from '../../transparency-slider/TransparencySlider';\nimport ColorPreview from './color-preview/ColorPreview';\nimport { StyledSliders, StyledSlidersWrapper } from './Sliders.styles';\n\ninterface SlidersProps {\n shouldShowTransparencySlider: boolean;\n}\n\nconst Sliders = ({ shouldShowTransparencySlider }: SlidersProps) => {\n const {\n selectedColor,\n updateSelectedColor,\n updateHueColor,\n updateShouldGetCoordinates,\n updateShouldCallOnSelect,\n hueColor,\n } = useContext(ColorPickerContext);\n\n const handleColorChange = (color: CSSProperties['color']) => {\n if (typeof updateSelectedColor === 'function' && color) {\n updateSelectedColor(color);\n }\n };\n\n const handleHueColorChange = (color: CSSProperties['color']) => {\n if (typeof updateHueColor === 'function' && color) {\n updateHueColor(color);\n }\n };\n\n const handleStart = () => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n };\n\n const handleEnd = () => {\n if (\n typeof updateShouldGetCoordinates === 'function' &&\n typeof updateShouldCallOnSelect === 'function'\n ) {\n updateShouldGetCoordinates(true);\n updateShouldCallOnSelect(true);\n }\n };\n\n const opacity = useMemo(() => extractRgbValues(selectedColor ?? '').a, [selectedColor]);\n\n return (\n <StyledSliders>\n <StyledSlidersWrapper>\n <HueSlider\n color={hueColor}\n opacity={opacity}\n onEnd={handleEnd}\n onStart={handleStart}\n onChange={handleHueColorChange}\n />\n {shouldShowTransparencySlider && (\n <TransparencySlider\n color={selectedColor}\n onEnd={handleEnd}\n onStart={handleStart}\n onChange={handleColorChange}\n />\n )}\n </StyledSlidersWrapper>\n <ColorPreview />\n </StyledSliders>\n );\n};\n\nSliders.displayName = 'Sliders';\n\nexport default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AEvF,oBACIhC,MAAA,CAAAY,OAAA,CAAAoC,aAAA,CAACvC,QAAA,CAAAwC,aAAa,qBACVjD,MAAA,CAAAY,OAAA,CAAAoC,aAAA,CAACvC,QAAA,CAAAyC,oBAAoB,qBACjBlD,MAAA,CAAAY,OAAA,CAAAoC,aAAA,CAAC3C,UAAA,CAAAO,OAAS;IACN6B,KAAK,EAAEJ,QAAS;IAChBQ,OAAO,EAAEA,OAAQ;IACjBM,KAAK,EAAEP,SAAU;IACjBQ,OAAO,EAAET,WAAY;IACrBU,QAAQ,EAAEX;EAAqB,CAClC,CAAC,EACDX,4BAA4B,iBACzB/B,MAAA,CAAAY,OAAA,CAAAoC,aAAA,CAACzC,mBAAA,CAAAK,OAAkB;IACf6B,KAAK,EAAET,aAAc;IACrBmB,KAAK,EAAEP,SAAU;IACjBQ,OAAO,EAAET,WAAY;IACrBU,QAAQ,EAAEb;EAAkB,CAC/B,CAEa,CAAC,eACvBxC,MAAA,CAAAY,OAAA,CAAAoC,aAAA,CAACxC,aAAA,CAAAI,OAAY,MAAE,CACJ,CAAC;AAExB,CAAC;AAEDkB,OAAO,CAACwB,WAAW,GAAG,SAAS;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA5C,OAAA,GAEjBkB,OAAO","ignoreList":[]}
1
+ {"version":3,"file":"Sliders.js","names":["_react","_interopRequireWildcard","require","_color","_ColorPickerProvider","_HueSlider","_interopRequireDefault","_TransparencySlider","_ColorPreview","_Sliders","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Sliders","shouldShowTransparencySlider","selectedColor","updateSelectedColor","updateHueColor","updateShouldGetCoordinates","updateShouldCallOnSelect","updateCanGetColorFromArea","hueColor","useContext","ColorPickerContext","handleColorChange","color","handleHueColorChange","handleStart","handleHueStart","handleEnd","opacity","useMemo","extractRgbValues","createElement","StyledSliders","StyledSlidersWrapper","onEnd","onStart","onChange","displayName","_default","exports"],"sources":["../../../../../src/components/color-picker-popup/sliders/Sliders.tsx"],"sourcesContent":["import React, { useContext, useMemo, type CSSProperties } from 'react';\nimport { extractRgbValues } from '../../../utils/color';\nimport { ColorPickerContext } from '../../ColorPickerProvider';\nimport HueSlider from '../../hue-slider/HueSlider';\nimport TransparencySlider from '../../transparency-slider/TransparencySlider';\nimport ColorPreview from './color-preview/ColorPreview';\nimport { StyledSliders, StyledSlidersWrapper } from './Sliders.styles';\n\ninterface SlidersProps {\n shouldShowTransparencySlider: boolean;\n}\n\nconst Sliders = ({ shouldShowTransparencySlider }: SlidersProps) => {\n const {\n selectedColor,\n updateSelectedColor,\n updateHueColor,\n updateShouldGetCoordinates,\n updateShouldCallOnSelect,\n updateCanGetColorFromArea,\n hueColor,\n } = useContext(ColorPickerContext);\n\n const handleColorChange = (color: CSSProperties['color']) => {\n if (typeof updateSelectedColor === 'function' && color) {\n updateSelectedColor(color);\n }\n };\n\n const handleHueColorChange = (color: CSSProperties['color']) => {\n if (typeof updateHueColor === 'function' && color) {\n updateHueColor(color);\n }\n };\n\n const handleStart = () => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n };\n\n const handleHueStart = () => {\n handleStart();\n\n if (typeof updateCanGetColorFromArea === 'function') {\n updateCanGetColorFromArea(true);\n }\n };\n\n const handleEnd = () => {\n if (\n typeof updateShouldGetCoordinates === 'function' &&\n typeof updateShouldCallOnSelect === 'function'\n ) {\n updateShouldGetCoordinates(true);\n updateShouldCallOnSelect(true);\n }\n\n if (typeof updateCanGetColorFromArea === 'function') {\n updateCanGetColorFromArea(false);\n }\n };\n\n const opacity = useMemo(() => extractRgbValues(selectedColor ?? '').a, [selectedColor]);\n\n return (\n <StyledSliders>\n <StyledSlidersWrapper>\n <HueSlider\n color={hueColor}\n opacity={opacity}\n onEnd={handleEnd}\n onStart={handleHueStart}\n onChange={handleHueColorChange}\n />\n {shouldShowTransparencySlider && (\n <TransparencySlider\n color={selectedColor}\n onEnd={handleEnd}\n onStart={handleStart}\n onChange={handleColorChange}\n />\n )}\n </StyledSlidersWrapper>\n <ColorPreview />\n </StyledSliders>\n );\n};\n\nSliders.displayName = 'Sliders';\n\nexport default Sliders;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,mBAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,aAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAAuE,SAAAI,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,GAAAH,wBAAA,CAAAE,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAP,CAAA,UAAAM,CAAA,CAAAE,GAAA,CAAAR,CAAA,OAAAS,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAf,CAAA,oBAAAe,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAA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ColorPickerContext = /*#__PURE__*/React.createContext({
10
10
  shouldGetCoordinates: undefined,
11
11
  updateShouldGetCoordinates: undefined,
12
12
  shouldCallOnSelect: undefined,
13
- updateShouldCallOnSelect: undefined
13
+ updateShouldCallOnSelect: undefined,
14
+ canGetColorFromArea: undefined,
15
+ updateCanGetColorFromArea: undefined
14
16
  });
15
17
  ColorPickerContext.displayName = 'ColorPickerContext';
16
18
  const ColorPickerProvider = _ref => {
@@ -24,6 +26,7 @@ const ColorPickerProvider = _ref => {
24
26
  const [internalIsPresetColor, setInternalIsPresetColor] = useState(false);
25
27
  const [internalShouldGetCoordinates, setInternalShouldGetCoordinates] = useState(true);
26
28
  const [internalShouldCallOnSelect, setInternalShouldCallOnSelect] = useState(false);
29
+ const [internalCanGetColorFromArea, setInternalCanGetColorFromArea] = useState(false);
27
30
  const updateSelectedColor = useCallback(color => {
28
31
  setInternalSelectedColor(color);
29
32
  }, []);
@@ -39,6 +42,9 @@ const ColorPickerProvider = _ref => {
39
42
  const updateShouldCallOnSelect = useCallback(shouldCallOnSelect => {
40
43
  setInternalShouldCallOnSelect(shouldCallOnSelect);
41
44
  }, []);
45
+ const updateCanGetColorFromArea = useCallback(canGetColorFromArea => {
46
+ setInternalCanGetColorFromArea(canGetColorFromArea);
47
+ }, []);
42
48
  useEffect(() => {
43
49
  let newColor = selectedColor;
44
50
  if (newColor && !isValidRGBA(newColor)) {
@@ -70,8 +76,10 @@ const ColorPickerProvider = _ref => {
70
76
  shouldGetCoordinates: internalShouldGetCoordinates,
71
77
  updateShouldGetCoordinates,
72
78
  shouldCallOnSelect: internalShouldCallOnSelect,
73
- updateShouldCallOnSelect
74
- }), [internalHueColor, internalIsPresetColor, internalSelectedColor, internalShouldCallOnSelect, internalShouldGetCoordinates, updateHueColor, updateIsPresetColor, updateSelectedColor, updateShouldCallOnSelect, updateShouldGetCoordinates]);
79
+ updateShouldCallOnSelect,
80
+ canGetColorFromArea: internalCanGetColorFromArea,
81
+ updateCanGetColorFromArea
82
+ }), [internalCanGetColorFromArea, internalHueColor, internalIsPresetColor, internalSelectedColor, internalShouldCallOnSelect, internalShouldGetCoordinates, updateCanGetColorFromArea, updateHueColor, updateIsPresetColor, updateSelectedColor, updateShouldCallOnSelect, updateShouldGetCoordinates]);
75
83
  return /*#__PURE__*/React.createElement(ColorPickerContext.Provider, {
76
84
  value: providerValue
77
85
  }, children);
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPickerProvider.js","names":["React","useCallback","useEffect","useMemo","useState","hexToRgb","isValidRGBA","ColorPickerContext","createContext","selectedColor","undefined","updateSelectedColor","hueColor","updateHueColor","isPresetColor","updateIsPresetColor","shouldGetCoordinates","updateShouldGetCoordinates","shouldCallOnSelect","updateShouldCallOnSelect","displayName","ColorPickerProvider","_ref","children","onSelect","internalSelectedColor","setInternalSelectedColor","internalHueColor","setInternalHueColor","internalIsPresetColor","setInternalIsPresetColor","internalShouldGetCoordinates","setInternalShouldGetCoordinates","internalShouldCallOnSelect","setInternalShouldCallOnSelect","color","newColor","r","g","b","a","providerValue","createElement","Provider","value"],"sources":["../../../src/components/ColorPickerProvider.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState, type ReactNode } from 'react';\nimport { hexToRgb, isValidRGBA } from '../utils/color';\n\ninterface IColorPickerContext {\n selectedColor?: string;\n updateSelectedColor?: (color: string | undefined) => void;\n hueColor?: string;\n updateHueColor?: (color: string | undefined) => void;\n isPresetColor?: boolean;\n updateIsPresetColor?: (isPresetColor: boolean) => void;\n shouldGetCoordinates?: boolean;\n updateShouldGetCoordinates?: (shouldGetCoordinates: boolean) => void;\n shouldCallOnSelect?: boolean;\n updateShouldCallOnSelect?: (shouldCallOnSelect: boolean) => void;\n}\n\nexport const ColorPickerContext = React.createContext<IColorPickerContext>({\n selectedColor: undefined,\n updateSelectedColor: undefined,\n hueColor: undefined,\n updateHueColor: undefined,\n isPresetColor: undefined,\n updateIsPresetColor: undefined,\n shouldGetCoordinates: undefined,\n updateShouldGetCoordinates: undefined,\n shouldCallOnSelect: undefined,\n updateShouldCallOnSelect: undefined,\n});\n\nColorPickerContext.displayName = 'ColorPickerContext';\n\ninterface ColorPickerProviderProps {\n /**\n * The children of the provider.\n */\n children: ReactNode;\n /**\n * Function to be executed when a color is selected.\n */\n onSelect?: (color: string) => void;\n /**\n * The color that should be preselected.\n */\n selectedColor?: string;\n}\n\nconst ColorPickerProvider = ({ children, selectedColor, onSelect }: ColorPickerProviderProps) => {\n const [internalSelectedColor, setInternalSelectedColor] = useState<string>();\n const [internalHueColor, setInternalHueColor] = useState<string>();\n const [internalIsPresetColor, setInternalIsPresetColor] = useState<boolean>(false);\n const [internalShouldGetCoordinates, setInternalShouldGetCoordinates] = useState<boolean>(true);\n const [internalShouldCallOnSelect, setInternalShouldCallOnSelect] = useState<boolean>(false);\n\n const updateSelectedColor = useCallback((color: string | undefined) => {\n setInternalSelectedColor(color);\n }, []);\n\n const updateHueColor = useCallback((color: string | undefined) => {\n setInternalHueColor(color);\n }, []);\n\n const updateIsPresetColor = useCallback((isPresetColor: boolean) => {\n setInternalIsPresetColor(isPresetColor);\n }, []);\n\n const updateShouldGetCoordinates = useCallback((shouldGetCoordinates: boolean) => {\n setInternalShouldGetCoordinates(shouldGetCoordinates);\n }, []);\n\n const updateShouldCallOnSelect = useCallback((shouldCallOnSelect: boolean) => {\n setInternalShouldCallOnSelect(shouldCallOnSelect);\n }, []);\n\n useEffect(() => {\n let newColor = selectedColor;\n\n if (newColor && !isValidRGBA(newColor)) {\n const { r, g, b, a } = hexToRgb(newColor);\n\n newColor = `rgba(${r},${g},${b},${a})`;\n }\n\n setInternalSelectedColor(newColor);\n setInternalHueColor(newColor);\n setInternalIsPresetColor(true);\n }, [selectedColor]);\n\n useEffect(() => {\n if (typeof onSelect === 'function' && internalShouldCallOnSelect && internalSelectedColor) {\n onSelect(internalSelectedColor);\n\n setInternalShouldCallOnSelect(false);\n }\n }, [internalSelectedColor, internalShouldCallOnSelect, onSelect]);\n\n const providerValue = useMemo<IColorPickerContext>(\n () => ({\n selectedColor: internalSelectedColor,\n updateSelectedColor,\n hueColor: internalHueColor,\n updateHueColor,\n isPresetColor: internalIsPresetColor,\n updateIsPresetColor,\n shouldGetCoordinates: internalShouldGetCoordinates,\n updateShouldGetCoordinates,\n shouldCallOnSelect: internalShouldCallOnSelect,\n updateShouldCallOnSelect,\n }),\n [\n internalHueColor,\n internalIsPresetColor,\n internalSelectedColor,\n internalShouldCallOnSelect,\n internalShouldGetCoordinates,\n updateHueColor,\n updateIsPresetColor,\n updateSelectedColor,\n updateShouldCallOnSelect,\n updateShouldGetCoordinates,\n ],\n );\n\n return (\n <ColorPickerContext.Provider value={providerValue}>{children}</ColorPickerContext.Provider>\n );\n};\n\nColorPickerProvider.displayName = 'ColorPickerProvider';\n\nexport default ColorPickerProvider;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAwB,OAAO;AACxF,SAASC,QAAQ,EAAEC,WAAW,QAAQ,gBAAgB;AAetD,OAAO,MAAMC,kBAAkB,gBAAGP,KAAK,CAACQ,aAAa,CAAsB;EACvEC,aAAa,EAAEC,SAAS;EACxBC,mBAAmB,EAAED,SAAS;EAC9BE,QAAQ,EAAEF,SAAS;EACnBG,cAAc,EAAEH,SAAS;EACzBI,aAAa,EAAEJ,SAAS;EACxBK,mBAAmB,EAAEL,SAAS;EAC9BM,oBAAoB,EAAEN,SAAS;EAC/BO,0BAA0B,EAAEP,SAAS;EACrCQ,kBAAkB,EAAER,SAAS;EAC7BS,wBAAwB,EAAET;AAC9B,CAAC,CAAC;AAEFH,kBAAkB,CAACa,WAAW,GAAG,oBAAoB;AAiBrD,MAAMC,mBAAmB,GAAGC,IAAA,IAAqE;EAAA,IAApE;IAAEC,QAAQ;IAAEd,aAAa;IAAEe;EAAmC,CAAC,GAAAF,IAAA;EACxF,MAAM,CAACG,qBAAqB,EAAEC,wBAAwB,CAAC,GAAGtB,Q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G,QAAQC,CAAC,IAAIC,CAAC,IAAIC,CAAC,IAAIC,CAAC,GAAG;IAC1C;IAEAd,wBAAwB,CAACU,QAAQ,CAAC;IAClCR,mBAAmB,CAACQ,QAAQ,CAAC;IAC7BN,wBAAwB,CAAC,IAAI,CAAC;EAClC,CAAC,EAAE,CAACrB,aAAa,CAAC,CAAC;EAEnBP,SAAS,CAAC,MAAM;IACZ,IAAI,OAAOsB,QAAQ,KAAK,UAAU,IAAIS,0BAA0B,IAAIR,qBAAqB,EAAE;MACvFD,QAAQ,CAACC,qBAAqB,CAAC;MAE/BS,6BAA6B,CAAC,KAAK,CAAC;IACxC;EACJ,CAAC,EAAE,CAACT,qBAAqB,EAAEQ,0BAA0B,EAAET,QAAQ,CAAC,CAAC;EAEjE,MAAMiB,aAAa,GAAGtC,OAAO,CACzB,OAAO;IACHM,aAAa,EAAEgB,qBAAqB;IACpCd,mBAAmB;IACnBC,QAAQ,EAAEe,gBAAgB;IAC1Bd,cAAc;IACdC,aAAa,EAAEe,qBAAqB;IACpCd,mBAAmB;IACnBC,oBAAoB,EAAEe,4BAA4B;IAClDd,0BAA0B;IAC1BC,kBAAkB,EAAEe,0BAA0B;IAC9Cd;EACJ,CAAC,CAAC,EACF,CACIQ,gBAAgB,EAChBE,qBAAqB,EACrBJ,qBAAqB,EACrBQ,0BAA0B,EAC1BF,4BAA4B,EAC5BlB,cAAc,EACdE,mBAAmB,EACnBJ,mBAAmB,EACnBQ,wBAAwB,EACxBF,0BAA0B,CAElC,CAAC;EAED,oBACIjB,KAAA,CAAA0C,aAAA,CAACnC,kBAAkB,CAACoC,QAAQ;IAACC,KAAK,EAAEH;EAAc,GAAElB,QAAsC,CAAC;AAEnG,CAAC;AAEDF,mBAAmB,CAACD,WAAW,GAAG,qBAAqB;AAEvD,eAAeC,mBAAmB","ignoreList":[]}
1
+ {"version":3,"file":"ColorPickerProvider.js","names":["React","useCallback","useEffect","useMemo","useState","hexToRgb","isValidRGBA","ColorPickerContext","createContext","selectedColor","undefined","updateSelectedColor","hueColor","updateHueColor","isPresetColor","updateIsPresetColor","shouldGetCoordinates","updateShouldGetCoordinates","shouldCallOnSelect","updateShouldCallOnSelect","canGetColorFromArea","updateCanGetColorFromArea","displayName","ColorPickerProvider","_ref","children","onSelect","internalSelectedColor","setInternalSelectedColor","internalHueColor","setInternalHueColor","internalIsPresetColor","setInternalIsPresetColor","internalShouldGetCoordinates","setInternalShouldGetCoordinates","internalShouldCallOnSelect","setInternalShouldCallOnSelect","internalCanGetColorFromArea","setInternalCanGetColorFromArea","color","newColor","r","g","b","a","providerValue","createElement","Provider","value"],"sources":["../../../src/components/ColorPickerProvider.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState, type ReactNode } from 'react';\nimport { hexToRgb, isValidRGBA } from '../utils/color';\n\ninterface IColorPickerContext {\n selectedColor?: string;\n updateSelectedColor?: (color: string | undefined) => void;\n hueColor?: string;\n updateHueColor?: (color: string | undefined) => void;\n isPresetColor?: boolean;\n updateIsPresetColor?: (isPresetColor: boolean) => void;\n shouldGetCoordinates?: boolean;\n updateShouldGetCoordinates?: (shouldGetCoordinates: boolean) => void;\n shouldCallOnSelect?: boolean;\n updateShouldCallOnSelect?: (shouldCallOnSelect: boolean) => void;\n canGetColorFromArea?: boolean;\n updateCanGetColorFromArea?: (canGetColorFromArea: boolean) => void;\n}\n\nexport const ColorPickerContext = React.createContext<IColorPickerContext>({\n selectedColor: undefined,\n updateSelectedColor: undefined,\n hueColor: undefined,\n updateHueColor: undefined,\n isPresetColor: undefined,\n updateIsPresetColor: undefined,\n shouldGetCoordinates: undefined,\n updateShouldGetCoordinates: undefined,\n shouldCallOnSelect: undefined,\n updateShouldCallOnSelect: undefined,\n canGetColorFromArea: undefined,\n updateCanGetColorFromArea: undefined,\n});\n\nColorPickerContext.displayName = 'ColorPickerContext';\n\ninterface ColorPickerProviderProps {\n /**\n * The children of the provider.\n */\n children: ReactNode;\n /**\n * Function to be executed when a color is selected.\n */\n onSelect?: (color: string) => void;\n /**\n * The color that should be preselected.\n */\n selectedColor?: string;\n}\n\nconst ColorPickerProvider = ({ children, selectedColor, onSelect }: ColorPickerProviderProps) => {\n const [internalSelectedColor, setInternalSelectedColor] = useState<string>();\n const [internalHueColor, setInternalHueColor] = useState<string>();\n const [internalIsPresetColor, setInternalIsPresetColor] = useState<boolean>(false);\n const [internalShouldGetCoordinates, setInternalShouldGetCoordinates] = useState<boolean>(true);\n const [internalShouldCallOnSelect, setInternalShouldCallOnSelect] = useState<boolean>(false);\n const [internalCanGetColorFromArea, setInternalCanGetColorFromArea] = useState<boolean>(false);\n\n const updateSelectedColor = useCallback((color: string | undefined) => {\n setInternalSelectedColor(color);\n }, []);\n\n const updateHueColor = useCallback((color: string | undefined) => {\n setInternalHueColor(color);\n }, []);\n\n const updateIsPresetColor = useCallback((isPresetColor: boolean) => {\n setInternalIsPresetColor(isPresetColor);\n }, []);\n\n const updateShouldGetCoordinates = useCallback((shouldGetCoordinates: boolean) => {\n setInternalShouldGetCoordinates(shouldGetCoordinates);\n }, []);\n\n const updateShouldCallOnSelect = useCallback((shouldCallOnSelect: boolean) => {\n setInternalShouldCallOnSelect(shouldCallOnSelect);\n }, []);\n\n const updateCanGetColorFromArea = useCallback((canGetColorFromArea: boolean) => {\n setInternalCanGetColorFromArea(canGetColorFromArea);\n }, []);\n\n useEffect(() => {\n let newColor = selectedColor;\n\n if (newColor && !isValidRGBA(newColor)) {\n const { r, g, b, a } = hexToRgb(newColor);\n\n newColor = `rgba(${r},${g},${b},${a})`;\n }\n\n setInternalSelectedColor(newColor);\n setInternalHueColor(newColor);\n setInternalIsPresetColor(true);\n }, [selectedColor]);\n\n useEffect(() => {\n if (typeof onSelect === 'function' && internalShouldCallOnSelect && internalSelectedColor) {\n onSelect(internalSelectedColor);\n\n setInternalShouldCallOnSelect(false);\n }\n }, [internalSelectedColor, internalShouldCallOnSelect, onSelect]);\n\n const providerValue = useMemo<IColorPickerContext>(\n () => ({\n selectedColor: internalSelectedColor,\n updateSelectedColor,\n hueColor: internalHueColor,\n updateHueColor,\n isPresetColor: internalIsPresetColor,\n updateIsPresetColor,\n shouldGetCoordinates: internalShouldGetCoordinates,\n updateShouldGetCoordinates,\n shouldCallOnSelect: internalShouldCallOnSelect,\n updateShouldCallOnSelect,\n canGetColorFromArea: internalCanGetColorFromArea,\n updateCanGetColorFromArea,\n }),\n [\n internalCanGetColorFromArea,\n internalHueColor,\n internalIsPresetColor,\n internalSelectedColor,\n internalShouldCallOnSelect,\n internalShouldGetCoordinates,\n updateCanGetColorFromArea,\n updateHueColor,\n updateIsPresetColor,\n updateSelectedColor,\n updateShouldCallOnSelect,\n updateShouldGetCoordinates,\n ],\n );\n\n return (\n <ColorPickerContext.Provider value={providerValue}>{children}</ColorPickerContext.Provider>\n );\n};\n\nColorPickerProvider.displayName = 'ColorPickerProvider';\n\nexport default ColorPickerProvider;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAwB,OAAO;AACxF,SAASC,QAAQ,EAAEC,WAAW,QAAQ,gBAAgB;AAiBtD,OAAO,MAAMC,kBAAkB,gBAAGP,KAAK,CAACQ,aAAa,CAAsB;EACvEC,aAAa,EAAEC,SAAS;EACxBC,mBAAmB,EAAED,SAAS;EAC9BE,QAAQ,EAAEF,SAAS;EACnBG,cAAc,EAAEH,SAAS;EACzBI,aAAa,EAAEJ,SAAS;EACxBK,mBAAmB,EAAEL,SAAS;EAC9BM,oBAAoB,EAAEN,SAAS;EAC/BO,0BAA0B,EAAEP,SAAS;EACrCQ,kBAAkB,EAAER,SAAS;EAC7BS,wBAAwB,EAAET,SAAS;EACnCU,mBAAmB,EAAEV,SAAS;EAC9BW,yBAAyB,EAAEX;AAC/B,CAAC,CAAC;AAEFH,kBAAkB,CAACe,WAAW,GAAG,oBAAoB;AAiBrD,MAAMC,mBAAmB,GAAGC,IAAA,IAAqE;EAAA,IAApE;IAAEC,QAAQ;IA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4B,EAC5BZ,yBAAyB,EACzBR,cAAc,EACdE,mBAAmB,EACnBJ,mBAAmB,EACnBQ,wBAAwB,EACxBF,0BAA0B,CAElC,CAAC;EAED,oBACIjB,KAAA,CAAA8C,aAAA,CAACvC,kBAAkB,CAACwC,QAAQ;IAACC,KAAK,EAAEH;EAAc,GAAEpB,QAAsC,CAAC;AAEnG,CAAC;AAEDF,mBAAmB,CAACD,WAAW,GAAG,qBAAqB;AAEvD,eAAeC,mBAAmB","ignoreList":[]}
@@ -2,7 +2,7 @@ import { Popup } from '@chayns-components/core';
2
2
  import React, { useContext, useMemo } from 'react';
3
3
  import ColorPickerPopup from '../../color-picker-popup/ColorPickerPopup';
4
4
  import { ColorPickerContext } from '../../ColorPickerProvider';
5
- import { StyledColorPickerWrapper, StyledColorPickerWrapperInfo, StyledColorPickerWrapperInfoColor, StyledColorPickerWrapperInfoColorBackground, StyledColorPickerWrapperInfoColorWrapper, StyledColorPickerWrapperInfoText } from './ColorPickerWrapper.styles';
5
+ import { StyledColorPickerWrapper, StyledColorPickerWrapperInfo, StyledColorPickerWrapperInfoColor, StyledColorPickerWrapperInfoColorWrapper, StyledColorPickerWrapperInfoText } from './ColorPickerWrapper.styles';
6
6
  const ColorPickerWrapper = _ref => {
7
7
  let {
8
8
  presetColors,
@@ -30,7 +30,7 @@ const ColorPickerWrapper = _ref => {
30
30
  content: content
31
31
  }, /*#__PURE__*/React.createElement(StyledColorPickerWrapperInfo, null, /*#__PURE__*/React.createElement(StyledColorPickerWrapperInfoColorWrapper, {
32
32
  $shouldShowRoundPreviewColor: shouldShowRoundPreviewColor
33
- }, /*#__PURE__*/React.createElement(StyledColorPickerWrapperInfoColorBackground, null), /*#__PURE__*/React.createElement(StyledColorPickerWrapperInfoColor, {
33
+ }, /*#__PURE__*/React.createElement(StyledColorPickerWrapperInfoColor, {
34
34
  $color: selectedColor
35
35
  })), shouldShowPreviewColorString && /*#__PURE__*/React.createElement(StyledColorPickerWrapperInfoText, null, selectedColor))) : content);
36
36
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPickerWrapper.js","names":["Popup","React","useContext","useMemo","ColorPickerPopup","ColorPickerContext","StyledColorPickerWrapper","StyledColorPickerWrapperInfo","StyledColorPickerWrapperInfoColor","StyledColorPickerWrapperInfoColorBackground","StyledColorPickerWrapperInfoColorWrapper","StyledColorPickerWrapperInfoText","ColorPickerWrapper","_ref","presetColors","onPresetColorRemove","onPresetColorAdd","shouldShowPresetColors","shouldShowAsPopup","shouldShowTransparencySlider","shouldShowMoreOptions","shouldShowRoundPreviewColor","shouldShowPreviewColorString","selectedColor","content","createElement","$shouldShowRoundPreviewColor","$color","displayName"],"sources":["../../../../../src/components/color-picker/color-picker-wrapper/ColorPickerWrapper.tsx"],"sourcesContent":["import { Popup } from '@chayns-components/core';\nimport React, { useContext, useMemo } from 'react';\nimport type { IPresetColor } from '../../../types/colorPicker';\nimport ColorPickerPopup from '../../color-picker-popup/ColorPickerPopup';\nimport { ColorPickerContext } from '../../ColorPickerProvider';\nimport {\n StyledColorPickerWrapper,\n StyledColorPickerWrapperInfo,\n StyledColorPickerWrapperInfoColor,\n StyledColorPickerWrapperInfoColorBackground,\n StyledColorPickerWrapperInfoColorWrapper,\n StyledColorPickerWrapperInfoText,\n} from './ColorPickerWrapper.styles';\n\ninterface ColorPickerWrapperProps {\n presetColors?: IPresetColor[];\n shouldShowPresetColors: boolean;\n onPresetColorAdd?: (presetColor: IPresetColor) => void;\n onPresetColorRemove?: (presetColorId: IPresetColor['id']) => void;\n shouldShowTransparencySlider: boolean;\n shouldShowMoreOptions: boolean;\n shouldShowAsPopup: boolean;\n shouldShowPreviewColorString: boolean;\n shouldShowRoundPreviewColor: boolean;\n}\n\nconst ColorPickerWrapper = ({\n presetColors,\n onPresetColorRemove,\n onPresetColorAdd,\n shouldShowPresetColors,\n shouldShowAsPopup,\n shouldShowTransparencySlider,\n shouldShowMoreOptions,\n shouldShowRoundPreviewColor,\n shouldShowPreviewColorString,\n}: ColorPickerWrapperProps) => {\n const { selectedColor } = useContext(ColorPickerContext);\n\n const content = useMemo(\n () => (\n <ColorPickerPopup\n shouldShowPresetColors={shouldShowPresetColors}\n onPresetColorRemove={onPresetColorRemove}\n onPresetColorAdd={onPresetColorAdd}\n presetColors={presetColors}\n shouldShowMoreOptions={shouldShowMoreOptions}\n shouldShowTransparencySlider={shouldShowTransparencySlider}\n />\n ),\n [\n onPresetColorAdd,\n onPresetColorRemove,\n presetColors,\n shouldShowMoreOptions,\n shouldShowPresetColors,\n shouldShowTransparencySlider,\n ],\n );\n\n return (\n <StyledColorPickerWrapper>\n {shouldShowAsPopup ? (\n <Popup content={content}>\n <StyledColorPickerWrapperInfo>\n <StyledColorPickerWrapperInfoColorWrapper\n $shouldShowRoundPreviewColor={shouldShowRoundPreviewColor}\n >\n <StyledColorPickerWrapperInfoColorBackground />\n <StyledColorPickerWrapperInfoColor $color={selectedColor} />\n </StyledColorPickerWrapperInfoColorWrapper>\n\n {shouldShowPreviewColorString && (\n <StyledColorPickerWrapperInfoText>\n {selectedColor}\n </StyledColorPickerWrapperInfoText>\n )}\n </StyledColorPickerWrapperInfo>\n </Popup>\n ) : (\n content\n )}\n </StyledColorPickerWrapper>\n );\n};\n\nColorPickerWrapper.displayName = 'ColorPickerWrapper';\n\nexport default ColorPickerWrapper;\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,yBAAyB;AAC/C,OAAOC,KAAK,IAAIC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAElD,OAAOC,gBAAgB,MAAM,2CAA2C;AACxE,SAASC,kBAAkB,QAAQ,2BAA2B;AAC9D,SACIC,wBAAwB,EACxBC,4BAA4B,EAC5BC,iCAAiC,EACjCC,2CAA2C,EAC3CC,wCAAwC,EACxCC,gCAAgC,QAC7B,6BAA6B;AAcpC,MAAMC,kBAAkB,GAAGC,IAAA,IAUI;EAAA,IAVH;IACxBC,YAAY;IACZC,mBAAmB;IACnBC,gBAAgB;IAChBC,sBAAsB;IACtBC,iBAAiB;IACjBC,4BAA4B;IAC5BC,qBAAqB;IACrBC,2BAA2B;IAC3BC;EACqB,CAAC,GAAAT,IAAA;EACtB,MAAM;IAAEU;EAAc,CAAC,GAAGrB,UAAU,CAACG,kBAAkB,CAAC;EAExD,MAAMmB,OAAO,GAAGrB,OAAO,CACnB,mBACIF,KAAA,CAAAwB,aAAA,CAACrB,gBAAgB;IACba,sBAAsB,EAAEA,sBAAuB;IAC/CF,mBAAmB,EAAEA,mBAAoB;IACzCC,gBAAgB,EAAEA,gBAAiB;IACnCF,YAAY,EAAEA,YAAa;IAC3BM,qBAAqB,EAAEA,qBAAsB;IAC7CD,4BAA4B,EAAEA;EAA6B,CAC9D,CACJ,EACD,CACIH,gBAAgB,EAChBD,mBAAmB,EACnBD,YAAY,EACZM,qBAAqB,EACrBH,sBAAsB,EACtBE,4BAA4B,CAEpC,CAAC;EAED,oBACIlB,KAAA,CAAAwB,aAAA,CAACnB,wBAAwB,QACpBY,iBAAiB,gBACdjB,KAAA,CAAAwB,aAAA,CAACzB,KAAK;IAACwB,OAAO,EAAEA;EAAQ,gBACpBvB,KAAA,CAAAwB,aAAA,CAAClB,4BAA4B,qBACzBN,KAAA,CAAAwB,aAAA,CAACf,wCAAwC;IACrCgB,4BAA4B,EAAEL;EAA4B,gBAE1DpB,KAAA,CAAAwB,aAAA,CAAChB,2CAA2C,MAAE,CAAC,eAC/CR,KAAA,CAAAwB,aAAA,CAACjB,iCAAiC;IAACmB,MAAM,EAAEJ;EAAc,CAAE,CACrB,CAAC,EAE1CD,4BAA4B,iBACzBrB,KAAA,CAAAwB,aAAA,CAACd,gCAAgC,QAC5BY,aAC6B,CAEZ,CAC3B,CAAC,GAERC,OAEkB,CAAC;AAEnC,CAAC;AAEDZ,kBAAkB,CAACgB,WAAW,GAAG,oBAAoB;AAErD,eAAehB,kBAAkB","ignoreList":[]}
1
+ {"version":3,"file":"ColorPickerWrapper.js","names":["Popup","React","useContext","useMemo","ColorPickerPopup","ColorPickerContext","StyledColorPickerWrapper","StyledColorPickerWrapperInfo","StyledColorPickerWrapperInfoColor","StyledColorPickerWrapperInfoColorWrapper","StyledColorPickerWrapperInfoText","ColorPickerWrapper","_ref","presetColors","onPresetColorRemove","onPresetColorAdd","shouldShowPresetColors","shouldShowAsPopup","shouldShowTransparencySlider","shouldShowMoreOptions","shouldShowRoundPreviewColor","shouldShowPreviewColorString","selectedColor","content","createElement","$shouldShowRoundPreviewColor","$color","displayName"],"sources":["../../../../../src/components/color-picker/color-picker-wrapper/ColorPickerWrapper.tsx"],"sourcesContent":["import { Popup } from '@chayns-components/core';\nimport React, { useContext, useMemo } from 'react';\nimport type { IPresetColor } from '../../../types/colorPicker';\nimport ColorPickerPopup from '../../color-picker-popup/ColorPickerPopup';\nimport { ColorPickerContext } from '../../ColorPickerProvider';\nimport {\n StyledColorPickerWrapper,\n StyledColorPickerWrapperInfo,\n StyledColorPickerWrapperInfoColor,\n StyledColorPickerWrapperInfoColorWrapper,\n StyledColorPickerWrapperInfoText,\n} from './ColorPickerWrapper.styles';\n\ninterface ColorPickerWrapperProps {\n presetColors?: IPresetColor[];\n shouldShowPresetColors: boolean;\n onPresetColorAdd?: (presetColor: IPresetColor) => void;\n onPresetColorRemove?: (presetColorId: IPresetColor['id']) => void;\n shouldShowTransparencySlider: boolean;\n shouldShowMoreOptions: boolean;\n shouldShowAsPopup: boolean;\n shouldShowPreviewColorString: boolean;\n shouldShowRoundPreviewColor: boolean;\n}\n\nconst ColorPickerWrapper = ({\n presetColors,\n onPresetColorRemove,\n onPresetColorAdd,\n shouldShowPresetColors,\n shouldShowAsPopup,\n shouldShowTransparencySlider,\n shouldShowMoreOptions,\n shouldShowRoundPreviewColor,\n shouldShowPreviewColorString,\n}: ColorPickerWrapperProps) => {\n const { selectedColor } = useContext(ColorPickerContext);\n\n const content = useMemo(\n () => (\n <ColorPickerPopup\n shouldShowPresetColors={shouldShowPresetColors}\n onPresetColorRemove={onPresetColorRemove}\n onPresetColorAdd={onPresetColorAdd}\n presetColors={presetColors}\n shouldShowMoreOptions={shouldShowMoreOptions}\n shouldShowTransparencySlider={shouldShowTransparencySlider}\n />\n ),\n [\n onPresetColorAdd,\n onPresetColorRemove,\n presetColors,\n shouldShowMoreOptions,\n shouldShowPresetColors,\n shouldShowTransparencySlider,\n ],\n );\n\n return (\n <StyledColorPickerWrapper>\n {shouldShowAsPopup ? (\n <Popup content={content}>\n <StyledColorPickerWrapperInfo>\n <StyledColorPickerWrapperInfoColorWrapper\n $shouldShowRoundPreviewColor={shouldShowRoundPreviewColor}\n >\n <StyledColorPickerWrapperInfoColor $color={selectedColor} />\n </StyledColorPickerWrapperInfoColorWrapper>\n\n {shouldShowPreviewColorString && (\n <StyledColorPickerWrapperInfoText>\n {selectedColor}\n </StyledColorPickerWrapperInfoText>\n )}\n </StyledColorPickerWrapperInfo>\n </Popup>\n ) : (\n content\n )}\n </StyledColorPickerWrapper>\n );\n};\n\nColorPickerWrapper.displayName = 'ColorPickerWrapper';\n\nexport default ColorPickerWrapper;\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,yBAAyB;AAC/C,OAAOC,KAAK,IAAIC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAElD,OAAOC,gBAAgB,MAAM,2CAA2C;AACxE,SAASC,kBAAkB,QAAQ,2BAA2B;AAC9D,SACIC,wBAAwB,EACxBC,4BAA4B,EAC5BC,iCAAiC,EACjCC,wCAAwC,EACxCC,gCAAgC,QAC7B,6BAA6B;AAcpC,MAAMC,kBAAkB,GAAGC,IAAA,IAUI;EAAA,IAVH;IACxBC,YAAY;IACZC,mBAAmB;IACnBC,gBAAgB;IAChBC,sBAAsB;IACtBC,iBAAiB;IACjBC,4BAA4B;IAC5BC,qBAAqB;IACrBC,2BAA2B;IAC3BC;EACqB,CAAC,GAAAT,IAAA;EACtB,MAAM;IAAEU;EAAc,CAAC,GAAGpB,UAAU,CAACG,kBAAkB,CAAC;EAExD,MAAMkB,OAAO,GAAGpB,OAAO,CACnB,mBACIF,KAAA,CAAAuB,aAAA,CAACpB,gBAAgB;IACbY,sBAAsB,EAAEA,sBAAuB;IAC/CF,mBAAmB,EAAEA,mBAAoB;IACzCC,gBAAgB,EAAEA,gBAAiB;IACnCF,YAAY,EAAEA,YAAa;IAC3BM,qBAAqB,EAAEA,qBAAsB;IAC7CD,4BAA4B,EAAEA;EAA6B,CAC9D,CACJ,EACD,CACIH,gBAAgB,EAChBD,mBAAmB,EACnBD,YAAY,EACZM,qBAAqB,EACrBH,sBAAsB,EACtBE,4BAA4B,CAEpC,CAAC;EAED,oBACIjB,KAAA,CAAAuB,aAAA,CAAClB,wBAAwB,QACpBW,iBAAiB,gBACdhB,KAAA,CAAAuB,aAAA,CAACxB,KAAK;IAACuB,OAAO,EAAEA;EAAQ,gBACpBtB,KAAA,CAAAuB,aAAA,CAACjB,4BAA4B,qBACzBN,KAAA,CAAAuB,aAAA,CAACf,wCAAwC;IACrCgB,4BAA4B,EAAEL;EAA4B,gBAE1DnB,KAAA,CAAAuB,aAAA,CAAChB,iCAAiC;IAACkB,MAAM,EAAEJ;EAAc,CAAE,CACrB,CAAC,EAE1CD,4BAA4B,iBACzBpB,KAAA,CAAAuB,aAAA,CAACd,gCAAgC,QAC5BY,aAC6B,CAEZ,CAC3B,CAAC,GAERC,OAEkB,CAAC;AAEnC,CAAC;AAEDZ,kBAAkB,CAACgB,WAAW,GAAG,oBAAoB;AAErD,eAAehB,kBAAkB","ignoreList":[]}
@@ -12,6 +12,7 @@ const ColorArea = () => {
12
12
  updateIsPresetColor,
13
13
  isPresetColor,
14
14
  shouldGetCoordinates,
15
+ canGetColorFromArea,
15
16
  updateShouldGetCoordinates,
16
17
  updateShouldCallOnSelect,
17
18
  hueColor
@@ -102,8 +103,10 @@ const ColorArea = () => {
102
103
  }
103
104
  return;
104
105
  }
105
- setColor();
106
- }, [hueColor, setColor, updateIsPresetColor]);
106
+ if (canGetColorFromArea) {
107
+ setColor();
108
+ }
109
+ }, [canGetColorFromArea, hueColor, setColor, updateIsPresetColor]);
107
110
  const handleStartDrag = useCallback(() => {
108
111
  if (typeof updateShouldGetCoordinates === 'function') {
109
112
  updateShouldGetCoordinates(false);
@@ -1 +1 @@
1
- {"version":3,"file":"ColorArea.js","names":["React","useCallback","useContext","useEffect","useMemo","useRef","useState","StyledColorArea","StyledColorAreaCanvas","StyledColorAreaPseudo","StyledMotionColorAreaPointer","hsvToHex","setRefreshScrollEnabled","useDragControls","useMotionValue","extractRgbValues","getColorFromCoordinates","getCoordinatesFromColor","rgbToHsv","ColorPickerContext","ColorArea","selectedColor","updateSelectedColor","updateIsPresetColor","isPresetColor","shouldGetCoordinates","updateShouldGetCoordinates","updateShouldCallOnSelect","hueColor","opacity","setOpacity","scale","setScale","scaleX","scaleY","isPresetColorRef","shouldGetCoordinatesRef","canDrag","canvasRef","pseudoRef","dragControls","x","y","current","a","canvas","rect","getBoundingClientRect","width","height","setColor","xCord","get","yCord","color","coordinates","ctx","getContext","hsv","hex","h","s","v","colorGradiant","createLinearGradient","addColorStop","fillStyle","fillRect","transparentGradiant","handleStartDrag","cords","tolerance","set","handleDrag","handleClick","event","left","top","target","clientX","clientY","handlePointerUp","move","xCords","yCords","newXCords","newYCords","handleMouseMove","handleTouchMove","preventDefault","changedTouches","pageX","pageY","window","addEventListener","removeEventListener","createElement","ref","onPointerDown","onClick","drag","dragConstraints","style","dragElastic","dragMomentum","onDrag","displayName"],"sources":["../../../../../src/components/color-picker-popup/color-area/ColorArea.tsx"],"sourcesContent":["import React, {\n MouseEvent,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport {\n StyledColorArea,\n StyledColorAreaCanvas,\n StyledColorAreaPseudo,\n StyledMotionColorAreaPointer,\n} from './ColorArea.styles';\n\nimport { hsvToHex } from '@chayns/colors';\nimport { setRefreshScrollEnabled } from 'chayns-api';\nimport { useDragControls, useMotionValue } from 'framer-motion';\nimport type { Scale } from '../../../types/colorPicker';\nimport {\n extractRgbValues,\n getColorFromCoordinates,\n getCoordinatesFromColor,\n rgbToHsv,\n} from '../../../utils/color';\nimport { ColorPickerContext } from '../../ColorPickerProvider';\n\nconst ColorArea = () => {\n const {\n selectedColor,\n updateSelectedColor,\n updateIsPresetColor,\n isPresetColor,\n shouldGetCoordinates,\n updateShouldGetCoordinates,\n updateShouldCallOnSelect,\n hueColor,\n } = useContext(ColorPickerContext);\n\n const [opacity, setOpacity] = useState<number>(1);\n const [scale, setScale] = useState<Scale>({ scaleX: 0, scaleY: 0 });\n\n const isPresetColorRef = useRef(false);\n const shouldGetCoordinatesRef = useRef(false);\n const canDrag = useRef(false);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const pseudoRef = useRef<HTMLDivElement>(null);\n\n const dragControls = useDragControls();\n\n const x = useMotionValue(0);\n const y = useMotionValue(0);\n\n useEffect(() => {\n isPresetColorRef.current = isPresetColor ?? false;\n }, [isPresetColor]);\n\n useEffect(() => {\n shouldGetCoordinatesRef.current = shouldGetCoordinates ?? true;\n }, [shouldGetCoordinates]);\n\n useEffect(() => {\n if (selectedColor) {\n const { a } = extractRgbValues(selectedColor);\n\n setOpacity(a);\n }\n }, [selectedColor]);\n\n useEffect(() => {\n const canvas = canvasRef.current;\n\n if (!canvas) {\n return;\n }\n\n const rect = canvas.getBoundingClientRect();\n\n const scaleX = canvas.width / rect.width;\n const scaleY = canvas.height / rect.height;\n\n setScale({ scaleX, scaleY });\n }, []);\n\n const setColor = useCallback(() => {\n const xCord = x.get();\n const yCord = y.get();\n\n if (typeof updateSelectedColor === 'function') {\n const color = getColorFromCoordinates({\n coordinates: {\n x: xCord,\n y: yCord,\n },\n canvas: canvasRef,\n opacity,\n scale,\n });\n\n if (color === 'transparent') {\n return;\n }\n\n updateSelectedColor(color);\n }\n }, [opacity, scale, updateSelectedColor, x, y]);\n\n useEffect(() => {\n const ctx = canvasRef.current?.getContext('2d');\n\n if (!ctx) {\n return;\n }\n\n const hsv = rgbToHsv(hueColor);\n\n const hex = hsvToHex({ h: hsv?.h ?? 1, s: 1, v: 1 });\n\n const colorGradiant = ctx.createLinearGradient(0, 0, 300, 0);\n colorGradiant.addColorStop(0, '#fff');\n colorGradiant.addColorStop(1, hex ?? 'red');\n\n ctx.fillStyle = colorGradiant;\n ctx.fillRect(0, 0, 300, 150);\n\n const transparentGradiant = ctx.createLinearGradient(0, 0, 0, 150);\n\n transparentGradiant.addColorStop(0, 'transparent');\n transparentGradiant.addColorStop(1, '#000');\n\n ctx.fillStyle = transparentGradiant;\n ctx.fillRect(0, 0, 300, 150);\n\n if (isPresetColorRef.current) {\n if (typeof updateIsPresetColor === 'function') {\n updateIsPresetColor(false);\n }\n\n return;\n }\n\n setColor();\n }, [hueColor, setColor, updateIsPresetColor]);\n\n const handleStartDrag = useCallback(() => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n canDrag.current = true;\n }, [updateShouldGetCoordinates]);\n\n useEffect(() => {\n if (selectedColor && shouldGetCoordinatesRef.current) {\n const cords = getCoordinatesFromColor({\n color: selectedColor,\n canvas: canvasRef,\n tolerance: 10,\n });\n\n if (cords) {\n x.set(cords.x);\n y.set(cords.y);\n }\n }\n }, [selectedColor, x, y]);\n\n const handleDrag = useCallback(() => {\n setColor();\n }, [setColor]);\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLDivElement>) => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n const { left, top } = (event.target as HTMLDivElement).getBoundingClientRect();\n\n x.set(event.clientX - left - 10);\n y.set(event.clientY - top - 10);\n\n setColor();\n },\n [setColor, updateShouldGetCoordinates, x, y],\n );\n\n const handlePointerUp = useCallback(() => {\n canDrag.current = false;\n\n void setRefreshScrollEnabled(true);\n\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(true);\n }\n\n if (typeof updateShouldCallOnSelect === 'function') {\n updateShouldCallOnSelect(true);\n }\n }, [updateShouldCallOnSelect, updateShouldGetCoordinates]);\n\n const move = useCallback(\n (xCords: number, yCords: number) => {\n let newXCords = xCords;\n let newYCords = yCords;\n\n switch (true) {\n case xCords > 300:\n newXCords = 300;\n break;\n case xCords < 0:\n newXCords = 0;\n break;\n default:\n break;\n }\n\n switch (true) {\n case yCords > 150:\n newYCords = 150;\n break;\n case yCords < 0:\n newYCords = 0;\n break;\n default:\n break;\n }\n\n x.set(newXCords);\n y.set(newYCords);\n\n setColor();\n },\n [setColor, x, y],\n );\n\n const handleMouseMove = useCallback(\n (event: MouseEvent) => {\n if (canDrag.current && pseudoRef.current) {\n const { left, top } = pseudoRef.current.getBoundingClientRect();\n\n const xCords = event.clientX - left - 10;\n const yCords = event.clientY - top - 10;\n\n move(xCords, yCords);\n }\n },\n [move],\n );\n\n const handleTouchMove = useCallback(\n (event: TouchEvent) => {\n if (canDrag.current && pseudoRef.current) {\n event.preventDefault();\n\n void setRefreshScrollEnabled(false);\n\n const { left, top } = pseudoRef.current.getBoundingClientRect();\n\n const xCords = event.changedTouches[0]\n ? event.changedTouches[0].clientX - left - 10\n : (event as unknown as { pageX: number }).pageX;\n const yCords = event.changedTouches[0]\n ? event.changedTouches[0].clientY - top - 10\n : (event as unknown as { pageY: number }).pageY;\n\n move(xCords, yCords);\n }\n },\n [move],\n );\n\n useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n window.addEventListener('mousemove', handleMouseMove);\n window.addEventListener('pointerup', handlePointerUp);\n window.addEventListener('touchmove', handleTouchMove);\n window.addEventListener('touchend', handlePointerUp);\n\n return () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n window.removeEventListener('mousemove', handleMouseMove);\n window.removeEventListener('pointerup', handlePointerUp);\n window.removeEventListener('touchmove', handleTouchMove);\n window.removeEventListener('touchend', handlePointerUp);\n };\n }, [handleMouseMove, handlePointerUp, handleTouchMove]);\n\n return useMemo(\n () => (\n <StyledColorArea>\n <StyledColorAreaCanvas ref={canvasRef} />\n <StyledColorAreaPseudo\n ref={pseudoRef}\n onPointerDown={handleStartDrag}\n onClick={handleClick}\n >\n <StyledMotionColorAreaPointer\n drag\n dragConstraints={pseudoRef}\n style={{ x, y }}\n dragElastic={false}\n dragMomentum={false}\n dragControls={dragControls}\n onDrag={handleDrag}\n />\n </StyledColorAreaPseudo>\n </StyledColorArea>\n ),\n [dragControls, handleClick, handleDrag, handleStartDrag, x, y],\n );\n};\n\nColorArea.displayName = 'ColorArea';\n\nexport default ColorArea;\n"],"mappings":"AAAA,OAAOA,KAAK,IAERC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SACIC,eAAe,EACfC,qBAAqB,EACrBC,qBAAqB,EACrBC,4BAA4B,QACzB,oBAAoB;AAE3B,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,uBAAuB,QAAQ,YAAY;AACpD,SAASC,eAAe,EAAEC,cAAc,QAAQ,eAAe;AAE/D,SACIC,gBAAgB,EAChBC,uBAAuB,EACvBC,uBAAuB,EACvBC,QAAQ,QACL,sBAAsB;AAC7B,SAASC,kBAAkB,QAAQ,2BAA2B;AAE9D,MAAMC,SAAS,GAAGA,CAAA,KAAM;EACpB,MAAM;IACFC,aAAa;IACbC,mBAAmB;IACnBC,mBAAmB;IACnBC,aAAa;IACbC,oBAAoB;IACpBC,0BAA0B;IAC1BC,wBAAwB;IACxBC;EACJ,CAAC,GAAG1B,UAAU,CAACiB,kBAAkB,CAAC;EAElC,MAAM,CAACU,OAAO,EAAEC,UAAU,CAAC,GAAGxB,QAAQ,CAAS,CAAC,CAAC;EACjD,MAAM,CAACyB,KAAK,EAAEC,QAAQ,CAAC,GAAG1B,QAAQ,CAAQ;IAAE2B,MAAM,EAAE,CAAC;IAAEC,MAAM,EAAE;EAAE,CAAC,CAAC;EAEnE,MAAMC,gBAAgB,GAAG9B,MAAM,CAAC,KAAK,CAAC;EACtC,MAAM+B,uBAAuB,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A,CAACvF,qBAAqB;IAClBwF,GAAG,EAAE1D,SAAU;IACf2D,aAAa,EAAE7B,eAAgB;IAC/B8B,OAAO,EAAEzB;EAAY,gBAErB1E,KAAA,CAAAgG,aAAA,CAACtF,4BAA4B;IACzB0F,IAAI;IACJC,eAAe,EAAE9D,SAAU;IAC3B+D,KAAK,EAAE;MAAE7D,CAAC;MAAEC;IAAE,CAAE;IAChB6D,WAAW,EAAE,KAAM;IACnBC,YAAY,EAAE,KAAM;IACpBhE,YAAY,EAAEA,YAAa;IAC3BiE,MAAM,EAAEhC;EAAW,CACtB,CACkB,CACV,CACpB,EACD,CAACjC,YAAY,EAAEkC,WAAW,EAAED,UAAU,EAAEJ,eAAe,EAAE5B,CAAC,EAAEC,CAAC,CACjE,CAAC;AACL,CAAC;AAEDtB,SAAS,CAACsF,WAAW,GAAG,WAAW;AAEnC,eAAetF,SAAS","ignoreList":[]}
1
+ {"version":3,"file":"ColorArea.js","names":["React","useCallback","useContext","useEffect","useMemo","useRef","useState","StyledColorArea","StyledColorAreaCanvas","StyledColorAreaPseudo","StyledMotionColorAreaPointer","hsvToHex","setRefreshScrollEnabled","useDragControls","useMotionValue","extractRgbValues","getColorFromCoordinates","getCoordinatesFromColor","rgbToHsv","ColorPickerContext","ColorArea","selectedColor","updateSelectedColor","updateIsPresetColor","isPresetColor","shouldGetCoordinates","canGetColorFromArea","updateShouldGetCoordinates","updateShouldCallOnSelect","hueColor","opacity","setOpacity","scale","setScale","scaleX","scaleY","isPresetColorRef","shouldGetCoordinatesRef","canDrag","canvasRef","pseudoRef","dragControls","x","y","current","a","canvas","rect","getBoundingClientRect","width","height","setColor","xCord","get","yCord","color","coordinates","ctx","getContext","hsv","hex","h","s","v","colorGradiant","createLinearGradient","addColorStop","fillStyle","fillRect","transparentGradiant","handleStartDrag","cords","tolerance","set","handleDrag","handleClick","event","left","top","target","clientX","clientY","handlePointerUp","move","xCords","yCords","newXCords","newYCords","handleMouseMove","handleTouchMove","preventDefault","changedTouches","pageX","pageY","window","addEventListener","removeEventListener","createElement","ref","onPointerDown","onClick","drag","dragConstraints","style","dragElastic","dragMomentum","onDrag","displayName"],"sources":["../../../../../src/components/color-picker-popup/color-area/ColorArea.tsx"],"sourcesContent":["import React, {\n MouseEvent,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport {\n StyledColorArea,\n StyledColorAreaCanvas,\n StyledColorAreaPseudo,\n StyledMotionColorAreaPointer,\n} from './ColorArea.styles';\n\nimport { hsvToHex } from '@chayns/colors';\nimport { setRefreshScrollEnabled } from 'chayns-api';\nimport { useDragControls, useMotionValue } from 'framer-motion';\nimport type { Scale } from '../../../types/colorPicker';\nimport {\n extractRgbValues,\n getColorFromCoordinates,\n getCoordinatesFromColor,\n rgbToHsv,\n} from '../../../utils/color';\nimport { ColorPickerContext } from '../../ColorPickerProvider';\n\nconst ColorArea = () => {\n const {\n selectedColor,\n updateSelectedColor,\n updateIsPresetColor,\n isPresetColor,\n shouldGetCoordinates,\n canGetColorFromArea,\n updateShouldGetCoordinates,\n updateShouldCallOnSelect,\n hueColor,\n } = useContext(ColorPickerContext);\n\n const [opacity, setOpacity] = useState<number>(1);\n const [scale, setScale] = useState<Scale>({ scaleX: 0, scaleY: 0 });\n\n const isPresetColorRef = useRef(false);\n const shouldGetCoordinatesRef = useRef(false);\n const canDrag = useRef(false);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const pseudoRef = useRef<HTMLDivElement>(null);\n\n const dragControls = useDragControls();\n\n const x = useMotionValue(0);\n const y = useMotionValue(0);\n\n useEffect(() => {\n isPresetColorRef.current = isPresetColor ?? false;\n }, [isPresetColor]);\n\n useEffect(() => {\n shouldGetCoordinatesRef.current = shouldGetCoordinates ?? true;\n }, [shouldGetCoordinates]);\n\n useEffect(() => {\n if (selectedColor) {\n const { a } = extractRgbValues(selectedColor);\n\n setOpacity(a);\n }\n }, [selectedColor]);\n\n useEffect(() => {\n const canvas = canvasRef.current;\n\n if (!canvas) {\n return;\n }\n\n const rect = canvas.getBoundingClientRect();\n\n const scaleX = canvas.width / rect.width;\n const scaleY = canvas.height / rect.height;\n\n setScale({ scaleX, scaleY });\n }, []);\n\n const setColor = useCallback(() => {\n const xCord = x.get();\n const yCord = y.get();\n\n if (typeof updateSelectedColor === 'function') {\n const color = getColorFromCoordinates({\n coordinates: {\n x: xCord,\n y: yCord,\n },\n canvas: canvasRef,\n opacity,\n scale,\n });\n\n if (color === 'transparent') {\n return;\n }\n\n updateSelectedColor(color);\n }\n }, [opacity, scale, updateSelectedColor, x, y]);\n\n useEffect(() => {\n const ctx = canvasRef.current?.getContext('2d');\n\n if (!ctx) {\n return;\n }\n\n const hsv = rgbToHsv(hueColor);\n\n const hex = hsvToHex({ h: hsv?.h ?? 1, s: 1, v: 1 });\n\n const colorGradiant = ctx.createLinearGradient(0, 0, 300, 0);\n colorGradiant.addColorStop(0, '#fff');\n colorGradiant.addColorStop(1, hex ?? 'red');\n\n ctx.fillStyle = colorGradiant;\n ctx.fillRect(0, 0, 300, 150);\n\n const transparentGradiant = ctx.createLinearGradient(0, 0, 0, 150);\n\n transparentGradiant.addColorStop(0, 'transparent');\n transparentGradiant.addColorStop(1, '#000');\n\n ctx.fillStyle = transparentGradiant;\n ctx.fillRect(0, 0, 300, 150);\n\n if (isPresetColorRef.current) {\n if (typeof updateIsPresetColor === 'function') {\n updateIsPresetColor(false);\n }\n\n return;\n }\n\n if (canGetColorFromArea) {\n setColor();\n }\n }, [canGetColorFromArea, hueColor, setColor, updateIsPresetColor]);\n\n const handleStartDrag = useCallback(() => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n canDrag.current = true;\n }, [updateShouldGetCoordinates]);\n\n useEffect(() => {\n if (selectedColor && shouldGetCoordinatesRef.current) {\n const cords = getCoordinatesFromColor({\n color: selectedColor,\n canvas: canvasRef,\n tolerance: 10,\n });\n\n if (cords) {\n x.set(cords.x);\n y.set(cords.y);\n }\n }\n }, [selectedColor, x, y]);\n\n const handleDrag = useCallback(() => {\n setColor();\n }, [setColor]);\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLDivElement>) => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n const { left, top } = (event.target as HTMLDivElement).getBoundingClientRect();\n\n x.set(event.clientX - left - 10);\n y.set(event.clientY - top - 10);\n\n setColor();\n },\n [setColor, updateShouldGetCoordinates, x, y],\n );\n\n const handlePointerUp = useCallback(() => {\n canDrag.current = false;\n\n void setRefreshScrollEnabled(true);\n\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(true);\n }\n\n if (typeof updateShouldCallOnSelect === 'function') {\n updateShouldCallOnSelect(true);\n }\n }, [updateShouldCallOnSelect, updateShouldGetCoordinates]);\n\n const move = useCallback(\n (xCords: number, yCords: number) => {\n let newXCords = xCords;\n let newYCords = yCords;\n\n switch (true) {\n case xCords > 300:\n newXCords = 300;\n break;\n case xCords < 0:\n newXCords = 0;\n break;\n default:\n break;\n }\n\n switch (true) {\n case yCords > 150:\n newYCords = 150;\n break;\n case yCords < 0:\n newYCords = 0;\n break;\n default:\n break;\n }\n\n x.set(newXCords);\n y.set(newYCords);\n\n setColor();\n },\n [setColor, x, y],\n );\n\n const handleMouseMove = useCallback(\n (event: MouseEvent) => {\n if (canDrag.current && pseudoRef.current) {\n const { left, top } = pseudoRef.current.getBoundingClientRect();\n\n const xCords = event.clientX - left - 10;\n const yCords = event.clientY - top - 10;\n\n move(xCords, yCords);\n }\n },\n [move],\n );\n\n const handleTouchMove = useCallback(\n (event: TouchEvent) => {\n if (canDrag.current && pseudoRef.current) {\n event.preventDefault();\n\n void setRefreshScrollEnabled(false);\n\n const { left, top } = pseudoRef.current.getBoundingClientRect();\n\n const xCords = event.changedTouches[0]\n ? event.changedTouches[0].clientX - left - 10\n : (event as unknown as { pageX: number }).pageX;\n const yCords = event.changedTouches[0]\n ? event.changedTouches[0].clientY - top - 10\n : (event as unknown as { pageY: number }).pageY;\n\n move(xCords, yCords);\n }\n },\n [move],\n );\n\n useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n window.addEventListener('mousemove', handleMouseMove);\n window.addEventListener('pointerup', handlePointerUp);\n window.addEventListener('touchmove', handleTouchMove);\n window.addEventListener('touchend', handlePointerUp);\n\n return () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n window.removeEventListener('mousemove', handleMouseMove);\n window.removeEventListener('pointerup', handlePointerUp);\n window.removeEventListener('touchmove', handleTouchMove);\n window.removeEventListener('touchend', handlePointerUp);\n };\n }, [handleMouseMove, handlePointerUp, handleTouchMove]);\n\n return useMemo(\n () => (\n <StyledColorArea>\n <StyledColorAreaCanvas ref={canvasRef} />\n <StyledColorAreaPseudo\n ref={pseudoRef}\n onPointerDown={handleStartDrag}\n onClick={handleClick}\n >\n <StyledMotionColorAreaPointer\n drag\n dragConstraints={pseudoRef}\n style={{ x, y }}\n dragElastic={false}\n dragMomentum={false}\n dragControls={dragControls}\n onDrag={handleDrag}\n />\n </StyledColorAreaPseudo>\n </StyledColorArea>\n ),\n [dragControls, handleClick, handleDrag, handleStartDrag, x, y],\n );\n};\n\nColorArea.displayName = 'ColorArea';\n\nexport default ColorArea;\n"],"mappings":"AAAA,OAAOA,KAAK,IAERC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SACIC,eAAe,EACfC,qBAAqB,EACrBC,qBAAqB,EACrBC,4BAA4B,QACzB,oBAAoB;AAE3B,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,uBAAuB,QAAQ,YAAY;AACpD,SAASC,eAAe,EAAEC,cAAc,QAAQ,eAAe;AAE/D,SACIC,gBAAgB,EAChBC,uBAAuB,EACvBC,uBAAuB,EACvBC,QAAQ,QACL,sBAAsB;AAC7B,SAASC,kBAAkB,QAAQ,2B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,CAACC,gBAAgB,CAAC,UAAU,EAAEb,eAAe,CAAC;IAEpD,OAAO,MAAM;MACT;MACA;MACAY,MAAM,CAACE,mBAAmB,CAAC,WAAW,EAAER,eAAe,CAAC;MACxDM,MAAM,CAACE,mBAAmB,CAAC,WAAW,EAAEd,eAAe,CAAC;MACxDY,MAAM,CAACE,mBAAmB,CAAC,WAAW,EAAEP,eAAe,CAAC;MACxDK,MAAM,CAACE,mBAAmB,CAAC,UAAU,EAAEd,eAAe,CAAC;IAC3D,CAAC;EACL,CAAC,EAAE,CAACM,eAAe,EAAEN,eAAe,EAAEO,eAAe,CAAC,CAAC;EAEvD,OAAOrF,OAAO,CACV,mBACIJ,KAAA,CAAAiG,aAAA,CAAC1F,eAAe,qBACZP,KAAA,CAAAiG,aAAA,CAACzF,qBAAqB;IAAC0F,GAAG,EAAE3D;EAAU,CAAE,CAAC,eACzCvC,KAAA,CAAAiG,aAAA,CAACxF,qBAAqB;IAClByF,GAAG,EAAE1D,SAAU;IACf2D,aAAa,EAAE7B,eAAgB;IAC/B8B,OAAO,EAAEzB;EAAY,gBAErB3E,KAAA,CAAAiG,aAAA,CAACvF,4BAA4B;IACzB2F,IAAI;IACJC,eAAe,EAAE9D,SAAU;IAC3B+D,KAAK,EAAE;MAAE7D,CAAC;MAAEC;IAAE,CAAE;IAChB6D,WAAW,EAAE,KAAM;IACnBC,YAAY,EAAE,KAAM;IACpBhE,YAAY,EAAEA,YAAa;IAC3BiE,MAAM,EAAEhC;EAAW,CACtB,CACkB,CACV,CACpB,EACD,CAACjC,YAAY,EAAEkC,WAAW,EAAED,UAAU,EAAEJ,eAAe,EAAE5B,CAAC,EAAEC,CAAC,CACjE,CAAC;AACL,CAAC;AAEDvB,SAAS,CAACuF,WAAW,GAAG,WAAW;AAEnC,eAAevF,SAAS","ignoreList":[]}
@@ -15,6 +15,7 @@ const Sliders = _ref => {
15
15
  updateHueColor,
16
16
  updateShouldGetCoordinates,
17
17
  updateShouldCallOnSelect,
18
+ updateCanGetColorFromArea,
18
19
  hueColor
19
20
  } = useContext(ColorPickerContext);
20
21
  const handleColorChange = color => {
@@ -32,18 +33,27 @@ const Sliders = _ref => {
32
33
  updateShouldGetCoordinates(false);
33
34
  }
34
35
  };
36
+ const handleHueStart = () => {
37
+ handleStart();
38
+ if (typeof updateCanGetColorFromArea === 'function') {
39
+ updateCanGetColorFromArea(true);
40
+ }
41
+ };
35
42
  const handleEnd = () => {
36
43
  if (typeof updateShouldGetCoordinates === 'function' && typeof updateShouldCallOnSelect === 'function') {
37
44
  updateShouldGetCoordinates(true);
38
45
  updateShouldCallOnSelect(true);
39
46
  }
47
+ if (typeof updateCanGetColorFromArea === 'function') {
48
+ updateCanGetColorFromArea(false);
49
+ }
40
50
  };
41
51
  const opacity = useMemo(() => extractRgbValues(selectedColor ?? '').a, [selectedColor]);
42
52
  return /*#__PURE__*/React.createElement(StyledSliders, null, /*#__PURE__*/React.createElement(StyledSlidersWrapper, null, /*#__PURE__*/React.createElement(HueSlider, {
43
53
  color: hueColor,
44
54
  opacity: opacity,
45
55
  onEnd: handleEnd,
46
- onStart: handleStart,
56
+ onStart: handleHueStart,
47
57
  onChange: handleHueColorChange
48
58
  }), shouldShowTransparencySlider && /*#__PURE__*/React.createElement(TransparencySlider, {
49
59
  color: selectedColor,
@@ -1 +1 @@
1
- {"version":3,"file":"Sliders.js","names":["React","useContext","useMemo","extractRgbValues","ColorPickerContext","HueSlider","TransparencySlider","ColorPreview","StyledSliders","StyledSlidersWrapper","Sliders","_ref","shouldShowTransparencySlider","selectedColor","updateSelectedColor","updateHueColor","updateShouldGetCoordinates","updateShouldCallOnSelect","hueColor","handleColorChange","color","handleHueColorChange","handleStart","handleEnd","opacity","a","createElement","onEnd","onStart","onChange","displayName"],"sources":["../../../../../src/components/color-picker-popup/sliders/Sliders.tsx"],"sourcesContent":["import React, { useContext, useMemo, type CSSProperties } from 'react';\nimport { extractRgbValues } from '../../../utils/color';\nimport { ColorPickerContext } from '../../ColorPickerProvider';\nimport HueSlider from '../../hue-slider/HueSlider';\nimport TransparencySlider from '../../transparency-slider/TransparencySlider';\nimport ColorPreview from './color-preview/ColorPreview';\nimport { StyledSliders, StyledSlidersWrapper } from './Sliders.styles';\n\ninterface SlidersProps {\n shouldShowTransparencySlider: boolean;\n}\n\nconst Sliders = ({ shouldShowTransparencySlider }: SlidersProps) => {\n const {\n selectedColor,\n updateSelectedColor,\n updateHueColor,\n updateShouldGetCoordinates,\n updateShouldCallOnSelect,\n hueColor,\n } = useContext(ColorPickerContext);\n\n const handleColorChange = (color: CSSProperties['color']) => {\n if (typeof updateSelectedColor === 'function' && color) {\n updateSelectedColor(color);\n }\n };\n\n const handleHueColorChange = (color: CSSProperties['color']) => {\n if (typeof updateHueColor === 'function' && color) {\n updateHueColor(color);\n }\n };\n\n const handleStart = () => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n };\n\n const handleEnd = () => {\n if (\n typeof updateShouldGetCoordinates === 'function' &&\n typeof updateShouldCallOnSelect === 'function'\n ) {\n updateShouldGetCoordinates(true);\n updateShouldCallOnSelect(true);\n }\n };\n\n const opacity = useMemo(() => extractRgbValues(selectedColor ?? '').a, [selectedColor]);\n\n return (\n <StyledSliders>\n <StyledSlidersWrapper>\n <HueSlider\n color={hueColor}\n opacity={opacity}\n onEnd={handleEnd}\n onStart={handleStart}\n onChange={handleHueColorChange}\n />\n {shouldShowTransparencySlider && (\n <TransparencySlider\n color={selectedColor}\n onEnd={handleEnd}\n onStart={handleStart}\n onChange={handleColorChange}\n />\n )}\n </StyledSlidersWrapper>\n <ColorPreview />\n </StyledSliders>\n );\n};\n\nSliders.displayName = 'Sliders';\n\nexport default Sliders;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,OAAO,QAA4B,OAAO;AACtE,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,SAASC,kBAAkB,QAAQ,2BAA2B;AAC9D,OAAOC,SAAS,MAAM,4BAA4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rB,SAAS;IACNe,KAAK,EAAEF,QAAS;IAChBM,OAAO,EAAEA,OAAQ;IACjBG,KAAK,EAAEJ,SAAU;IACjBK,OAAO,EAAEN,WAAY;IACrBO,QAAQ,EAAER;EAAqB,CAClC,CAAC,EACDT,4BAA4B,iBACzBZ,KAAA,CAAA0B,aAAA,CAACpB,kBAAkB;IACfc,KAAK,EAAEP,aAAc;IACrBc,KAAK,EAAEJ,SAAU;IACjBK,OAAO,EAAEN,WAAY;IACrBO,QAAQ,EAAEV;EAAkB,CAC/B,CAEa,CAAC,eACvBnB,KAAA,CAAA0B,aAAA,CAACnB,YAAY,MAAE,CACJ,CAAC;AAExB,CAAC;AAEDG,OAAO,CAACoB,WAAW,GAAG,SAAS;AAE/B,eAAepB,OAAO","ignoreList":[]}
1
+ {"version":3,"file":"Sliders.js","names":["React","useContext","useMemo","extractRgbValues","ColorPickerContext","HueSlider","TransparencySlider","ColorPreview","StyledSliders","StyledSlidersWrapper","Sliders","_ref","shouldShowTransparencySlider","selectedColor","updateSelectedColor","updateHueColor","updateShouldGetCoordinates","updateShouldCallOnSelect","updateCanGetColorFromArea","hueColor","handleColorChange","color","handleHueColorChange","handleStart","handleHueStart","handleEnd","opacity","a","createElement","onEnd","onStart","onChange","displayName"],"sources":["../../../../../src/components/color-picker-popup/sliders/Sliders.tsx"],"sourcesContent":["import React, { useContext, useMemo, type CSSProperties } from 'react';\nimport { extractRgbValues } from '../../../utils/color';\nimport { ColorPickerContext } from '../../ColorPickerProvider';\nimport HueSlider from '../../hue-slider/HueSlider';\nimport TransparencySlider from '../../transparency-slider/TransparencySlider';\nimport ColorPreview from './color-preview/ColorPreview';\nimport { StyledSliders, StyledSlidersWrapper } from './Sliders.styles';\n\ninterface SlidersProps {\n shouldShowTransparencySlider: boolean;\n}\n\nconst Sliders = ({ shouldShowTransparencySlider }: SlidersProps) => {\n const {\n selectedColor,\n updateSelectedColor,\n updateHueColor,\n updateShouldGetCoordinates,\n updateShouldCallOnSelect,\n updateCanGetColorFromArea,\n hueColor,\n } = useContext(ColorPickerContext);\n\n const handleColorChange = (color: CSSProperties['color']) => {\n if (typeof updateSelectedColor === 'function' && color) {\n updateSelectedColor(color);\n }\n };\n\n const handleHueColorChange = (color: CSSProperties['color']) => {\n if (typeof updateHueColor === 'function' && color) {\n updateHueColor(color);\n }\n };\n\n const handleStart = () => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n };\n\n const handleHueStart = () => {\n handleStart();\n\n if (typeof updateCanGetColorFromArea === 'function') {\n updateCanGetColorFromArea(true);\n }\n };\n\n const handleEnd = () => {\n if (\n typeof updateShouldGetCoordinates === 'function' &&\n typeof updateShouldCallOnSelect === 'function'\n ) {\n updateShouldGetCoordinates(true);\n updateShouldCallOnSelect(true);\n }\n\n if (typeof updateCanGetColorFromArea === 'function') {\n updateCanGetColorFromArea(false);\n }\n };\n\n const opacity = useMemo(() => extractRgbValues(selectedColor ?? '').a, [selectedColor]);\n\n return (\n <StyledSliders>\n <StyledSlidersWrapper>\n <HueSlider\n color={hueColor}\n opacity={opacity}\n onEnd={handleEnd}\n onStart={handleHueStart}\n onChange={handleHueColorChange}\n />\n {shouldShowTransparencySlider && (\n <TransparencySlider\n color={selectedColor}\n onEnd={handleEnd}\n onStart={handleStart}\n onChange={handleColorChange}\n />\n )}\n </StyledSlidersWrapper>\n <ColorPreview />\n </StyledSliders>\n );\n};\n\nSliders.displayName = 'Sliders';\n\nexport default Sliders;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,OAAO,QAA4B,OAAO;AACtE,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,SAASC,kBAAkB,QAAQ,2BAA2B;AAC9D,OAAOC,SAAS,MAAM,4BAA4B;AAClD,OAAOC,kBAAkB,MAAM,8CAA8C;AAC7E,OAAOC,YAAY,MAAM,8BAA8B;AACvD,SAASC,aAAa,EAAEC,oBAAoB,QAAQ,kBAAkB;AAMtE,MAAMC,OAAO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AEvF,oBACIb,KAAA,CAAA4B,aAAA,CAACpB,aAAa,qBACVR,KAAA,CAAA4B,aAAA,CAACnB,oBAAoB,qBACjBT,KAAA,CAAA4B,aAAA,CAACvB,SAAS;IACNgB,KAAK,EAAEF,QAAS;IAChBO,OAAO,EAAEA,OAAQ;IACjBG,KAAK,EAAEJ,SAAU;IACjBK,OAAO,EAAEN,cAAe;IACxBO,QAAQ,EAAET;EAAqB,CAClC,CAAC,EACDV,4BAA4B,iBACzBZ,KAAA,CAAA4B,aAAA,CAACtB,kBAAkB;IACfe,KAAK,EAAER,aAAc;IACrBgB,KAAK,EAAEJ,SAAU;IACjBK,OAAO,EAAEP,WAAY;IACrBQ,QAAQ,EAAEX;EAAkB,CAC/B,CAEa,CAAC,eACvBpB,KAAA,CAAA4B,aAAA,CAACrB,YAAY,MAAE,CACJ,CAAC;AAExB,CAAC;AAEDG,OAAO,CAACsB,WAAW,GAAG,SAAS;AAE/B,eAAetB,OAAO","ignoreList":[]}
@@ -10,6 +10,8 @@ interface IColorPickerContext {
10
10
  updateShouldGetCoordinates?: (shouldGetCoordinates: boolean) => void;
11
11
  shouldCallOnSelect?: boolean;
12
12
  updateShouldCallOnSelect?: (shouldCallOnSelect: boolean) => void;
13
+ canGetColorFromArea?: boolean;
14
+ updateCanGetColorFromArea?: (canGetColorFromArea: boolean) => void;
13
15
  }
14
16
  export declare const ColorPickerContext: React.Context<IColorPickerContext>;
15
17
  interface ColorPickerProviderProps {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chayns-components/color-picker",
3
- "version": "5.0.0-beta.911",
3
+ "version": "5.0.0-beta.913",
4
4
  "description": "A set of beautiful React components for developing your own applications with chayns.",
5
5
  "sideEffects": false,
6
6
  "browserslist": [
@@ -39,8 +39,7 @@
39
39
  "url": "git+https://github.com/TobitSoftware/chayns-components.git"
40
40
  },
41
41
  "scripts": {
42
- "build": "npm run build:cjs && npm run build:esm && npm run build:types && npm run minify",
43
- "minify": "terser lib/cjs/index.js --compress --mangle --toplevel --source-map --output lib/cjs/index.min.js && terser lib/esm/index.js --compress --mangle --toplevel --source-map --output lib/esm/index.min.js",
42
+ "build": "npm run build:cjs && npm run build:esm && npm run build:types",
44
43
  "build:types": "tsc",
45
44
  "build:cjs": "cross-env NODE_ENV=cjs babel src --out-dir lib/cjs --extensions=.ts,.tsx --source-maps --ignore=src/stories",
46
45
  "build:esm": "cross-env NODE_ENV=esm babel src --out-dir lib/esm --extensions=.ts,.tsx --source-maps --ignore=src/stories",
@@ -66,13 +65,11 @@
66
65
  "lerna": "^8.1.9",
67
66
  "react": "^18.3.1",
68
67
  "react-dom": "^18.3.1",
69
- "source-map-explorer": "^2.5.3",
70
68
  "styled-components": "^6.1.13",
71
- "terser": "^5.36.0",
72
69
  "typescript": "^5.7.2"
73
70
  },
74
71
  "dependencies": {
75
- "@chayns-components/core": "^5.0.0-beta.911",
72
+ "@chayns-components/core": "^5.0.0-beta.913",
76
73
  "@chayns/colors": "^2.0.0"
77
74
  },
78
75
  "peerDependencies": {
@@ -85,5 +82,5 @@
85
82
  "publishConfig": {
86
83
  "access": "public"
87
84
  },
88
- "gitHead": "cbbad4cae26a078bf6ae2c4e7e52fe9a2edd8f94"
85
+ "gitHead": "cbb05bba8d18477b92474269c86ee738f8a85dd2"
89
86
  }
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ColorPicker",{enumerable:!0,get:function(){return e.default}}),Object.defineProperty(exports,"HueSlider",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(exports,"TransparencySlider",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(exports,"hexToRgb",{enumerable:!0,get:function(){return n.hexToRgb}}),Object.defineProperty(exports,"rgbToHex",{enumerable:!0,get:function(){return n.rgbToHex}});var e=o(require("./components/color-picker/ColorPicker")),r=o(require("./components/hue-slider/HueSlider")),t=o(require("./components/transparency-slider/TransparencySlider")),n=require("./utils/color");function o(e){return e&&e.__esModule?e:{default:e}}
@@ -1 +0,0 @@
1
- {"version":3,"names":["Object","defineProperty","exports","value","enumerable","get","_ColorPicker","default","_HueSlider","_TransparencySlider","_color","hexToRgb","rgbToHex","_interopRequireDefault","require","e","__esModule"],"sources":["lib/cjs/index.js"],"mappings":"AAAA,aAEAA,OAAOC,eAAeC,QAAS,aAAc,CAC3CC,OAAO,IAETH,OAAOC,eAAeC,QAAS,cAAe,CAC5CE,YAAY,EACZC,IAAK,WACH,OAAOC,EAAaC,OACtB,IAEFP,OAAOC,eAAeC,QAAS,YAAa,CAC1CE,YAAY,EACZC,IAAK,WACH,OAAOG,EAAWD,OACpB,IAEFP,OAAOC,eAAeC,QAAS,qBAAsB,CACnDE,YAAY,EACZC,IAAK,WACH,OAAOI,EAAoBF,OAC7B,IAEFP,OAAOC,eAAeC,QAAS,WAAY,CACzCE,YAAY,EACZC,IAAK,WACH,OAAOK,EAAOC,QAChB,IAEFX,OAAOC,eAAeC,QAAS,WAAY,CACzCE,YAAY,EACZC,IAAK,WACH,OAAOK,EAAOE,QAChB,IAEF,IAAIN,EAAeO,EAAuBC,QAAQ,0CAC9CN,EAAaK,EAAuBC,QAAQ,sCAC5CL,EAAsBI,EAAuBC,QAAQ,wDACrDJ,EAASI,QAAQ,iBACrB,SAASD,EAAuBE,GAAK,OAAOA,GAAKA,EAAEC,WAAaD,EAAI,CAAER,QAASQ,EAAK","ignoreList":[]}
@@ -1 +0,0 @@
1
- export{default as ColorPicker}from"./components/color-picker/ColorPicker";export{default as HueSlider}from"./components/hue-slider/HueSlider";export{default as TransparencySlider}from"./components/transparency-slider/TransparencySlider";export{hexToRgb,rgbToHex}from"./utils/color";
@@ -1 +0,0 @@
1
- {"version":3,"names":["hexToRgb","rgbToHex"],"sources":["lib/esm/index.js"],"mappings":"OAAS,2BAA8B,+CAC9B,yBAA4B,2CAC5B,kCAAqC,6DACrCA,SAAUC,aAAgB","ignoreList":[]}