@chayns-components/color-picker 5.0.0-beta.998 → 5.0.0

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.
Files changed (96) hide show
  1. package/lib/cjs/components/ColorPickerProvider.js +1 -2
  2. package/lib/cjs/components/ColorPickerProvider.js.map +1 -1
  3. package/lib/cjs/components/color-picker/ColorPicker.js +8 -2
  4. package/lib/cjs/components/color-picker/ColorPicker.js.map +1 -1
  5. package/lib/cjs/components/color-picker/color-picker-wrapper/ColorPickerWrapper.js +10 -5
  6. package/lib/cjs/components/color-picker/color-picker-wrapper/ColorPickerWrapper.js.map +1 -1
  7. package/lib/cjs/components/color-picker/color-picker-wrapper/ColorPickerWrapper.styles.js +3 -3
  8. package/lib/cjs/components/color-picker/color-picker-wrapper/ColorPickerWrapper.styles.js.map +1 -1
  9. package/lib/cjs/components/color-picker-popup/ColorPickerPopup.js +5 -2
  10. package/lib/cjs/components/color-picker-popup/ColorPickerPopup.js.map +1 -1
  11. package/lib/cjs/components/color-picker-popup/color-area/ColorArea.js +30 -26
  12. package/lib/cjs/components/color-picker-popup/color-area/ColorArea.js.map +1 -1
  13. package/lib/cjs/components/color-picker-popup/color-area/ColorArea.styles.js +2 -2
  14. package/lib/cjs/components/color-picker-popup/color-area/ColorArea.styles.js.map +1 -1
  15. package/lib/cjs/components/color-picker-popup/more-options/MoreOptions.js +1 -2
  16. package/lib/cjs/components/color-picker-popup/more-options/MoreOptions.js.map +1 -1
  17. package/lib/cjs/components/color-picker-popup/preset-colors/PresetColors.js +8 -5
  18. package/lib/cjs/components/color-picker-popup/preset-colors/PresetColors.js.map +1 -1
  19. package/lib/cjs/components/color-picker-popup/preset-colors/preset-button/PresetButton.js +1 -2
  20. package/lib/cjs/components/color-picker-popup/preset-colors/preset-button/PresetButton.js.map +1 -1
  21. package/lib/cjs/components/color-picker-popup/preset-colors/preset-color/PresetColor.js +1 -2
  22. package/lib/cjs/components/color-picker-popup/preset-colors/preset-color/PresetColor.js.map +1 -1
  23. package/lib/cjs/components/color-picker-popup/preset-colors/preset-color/PresetColor.styles.js +3 -3
  24. package/lib/cjs/components/color-picker-popup/preset-colors/preset-color/PresetColor.styles.js.map +1 -1
  25. package/lib/cjs/components/color-picker-popup/sliders/Sliders.js +1 -2
  26. package/lib/cjs/components/color-picker-popup/sliders/Sliders.js.map +1 -1
  27. package/lib/cjs/components/color-picker-popup/sliders/color-preview/ColorPreview.js +1 -2
  28. package/lib/cjs/components/color-picker-popup/sliders/color-preview/ColorPreview.js.map +1 -1
  29. package/lib/cjs/components/color-picker-popup/sliders/color-preview/ColorPreview.styles.js +3 -3
  30. package/lib/cjs/components/color-picker-popup/sliders/color-preview/ColorPreview.styles.js.map +1 -1
  31. package/lib/cjs/components/hue-slider/HueSlider.js +1 -2
  32. package/lib/cjs/components/hue-slider/HueSlider.js.map +1 -1
  33. package/lib/cjs/components/transparency-slider/TransparencySlider.js +1 -2
  34. package/lib/cjs/components/transparency-slider/TransparencySlider.js.map +1 -1
  35. package/lib/cjs/components/transparency-slider/TransparencySlider.styles.js +6 -6
  36. package/lib/cjs/components/transparency-slider/TransparencySlider.styles.js.map +1 -1
  37. package/lib/cjs/constants/color.js +11 -8
  38. package/lib/cjs/constants/color.js.map +1 -1
  39. package/lib/cjs/index.js +6 -0
  40. package/lib/cjs/index.js.map +1 -1
  41. package/lib/cjs/types/colorPicker.js +4 -0
  42. package/lib/cjs/utils/color.js +2 -2
  43. package/lib/cjs/utils/color.js.map +1 -1
  44. package/lib/esm/components/ColorPickerProvider.js +5 -6
  45. package/lib/esm/components/ColorPickerProvider.js.map +1 -1
  46. package/lib/esm/components/color-picker/ColorPicker.js +35 -32
  47. package/lib/esm/components/color-picker/ColorPicker.js.map +1 -1
  48. package/lib/esm/components/color-picker/color-picker-wrapper/ColorPickerWrapper.js +21 -16
  49. package/lib/esm/components/color-picker/color-picker-wrapper/ColorPickerWrapper.js.map +1 -1
  50. package/lib/esm/components/color-picker/color-picker-wrapper/ColorPickerWrapper.styles.js +19 -31
  51. package/lib/esm/components/color-picker/color-picker-wrapper/ColorPickerWrapper.styles.js.map +1 -1
  52. package/lib/esm/components/color-picker-popup/ColorPickerPopup.js +19 -19
  53. package/lib/esm/components/color-picker-popup/ColorPickerPopup.js.map +1 -1
  54. package/lib/esm/components/color-picker-popup/color-area/ColorArea.js +26 -21
  55. package/lib/esm/components/color-picker-popup/color-area/ColorArea.js.map +1 -1
  56. package/lib/esm/components/color-picker-popup/color-area/ColorArea.styles.js +1 -1
  57. package/lib/esm/components/color-picker-popup/color-area/ColorArea.styles.js.map +1 -1
  58. package/lib/esm/components/color-picker-popup/more-options/MoreOptions.styles.js +12 -21
  59. package/lib/esm/components/color-picker-popup/more-options/MoreOptions.styles.js.map +1 -1
  60. package/lib/esm/components/color-picker-popup/preset-colors/PresetColors.js +36 -46
  61. package/lib/esm/components/color-picker-popup/preset-colors/PresetColors.js.map +1 -1
  62. package/lib/esm/components/color-picker-popup/preset-colors/preset-button/PresetButton.js +6 -7
  63. package/lib/esm/components/color-picker-popup/preset-colors/preset-button/PresetButton.js.map +1 -1
  64. package/lib/esm/components/color-picker-popup/preset-colors/preset-button/PresetButton.styles.js +6 -12
  65. package/lib/esm/components/color-picker-popup/preset-colors/preset-button/PresetButton.styles.js.map +1 -1
  66. package/lib/esm/components/color-picker-popup/preset-colors/preset-color/PresetColor.js +3 -4
  67. package/lib/esm/components/color-picker-popup/preset-colors/preset-color/PresetColor.js.map +1 -1
  68. package/lib/esm/components/color-picker-popup/preset-colors/preset-color/PresetColor.styles.js +9 -15
  69. package/lib/esm/components/color-picker-popup/preset-colors/preset-color/PresetColor.styles.js.map +1 -1
  70. package/lib/esm/components/color-picker-popup/sliders/Sliders.js +3 -4
  71. package/lib/esm/components/color-picker-popup/sliders/Sliders.js.map +1 -1
  72. package/lib/esm/components/color-picker-popup/sliders/color-preview/ColorPreview.styles.js +12 -15
  73. package/lib/esm/components/color-picker-popup/sliders/color-preview/ColorPreview.styles.js.map +1 -1
  74. package/lib/esm/components/hue-slider/HueSlider.js +7 -8
  75. package/lib/esm/components/hue-slider/HueSlider.js.map +1 -1
  76. package/lib/esm/components/hue-slider/HueSlider.styles.js +9 -12
  77. package/lib/esm/components/hue-slider/HueSlider.styles.js.map +1 -1
  78. package/lib/esm/components/transparency-slider/TransparencySlider.js +6 -7
  79. package/lib/esm/components/transparency-slider/TransparencySlider.js.map +1 -1
  80. package/lib/esm/components/transparency-slider/TransparencySlider.styles.js +27 -36
  81. package/lib/esm/components/transparency-slider/TransparencySlider.styles.js.map +1 -1
  82. package/lib/esm/constants/color.js +11 -8
  83. package/lib/esm/constants/color.js.map +1 -1
  84. package/lib/esm/index.js +1 -1
  85. package/lib/esm/index.js.map +1 -1
  86. package/lib/esm/types/colorPicker.js +1 -1
  87. package/lib/esm/utils/color.js +19 -22
  88. package/lib/esm/utils/color.js.map +1 -1
  89. package/lib/types/components/color-picker/ColorPicker.d.ts +14 -1
  90. package/lib/types/components/color-picker/color-picker-wrapper/ColorPickerWrapper.d.ts +5 -1
  91. package/lib/types/components/color-picker/color-picker-wrapper/ColorPickerWrapper.styles.d.ts +1 -1
  92. package/lib/types/components/color-picker-popup/ColorPickerPopup.d.ts +3 -1
  93. package/lib/types/components/color-picker-popup/color-area/ColorArea.styles.d.ts +2 -263
  94. package/lib/types/components/color-picker-popup/preset-colors/PresetColors.d.ts +2 -1
  95. package/lib/types/index.d.ts +1 -1
  96. package/package.json +19 -18
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = exports.ColorPickerContext = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _color = require("../utils/color");
9
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
9
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
10
  const ColorPickerContext = exports.ColorPickerContext = /*#__PURE__*/_react.default.createContext({
12
11
  selectedColor: undefined,
13
12
  updateSelectedColor: undefined,
@@ -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","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,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,C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ireWildcard","require","_color","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","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","a","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,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,C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AwB,EACxBF,0BAA0B,CAElC,CAAC;EAED,oBACInC,MAAA,CAAAc,OAAA,CAAAsD,aAAA,CAAC7C,kBAAkB,CAAC8C,QAAQ;IAACC,KAAK,EAAEJ;EAAc,GAAExB,QAAsC,CAAC;AAEnG,CAAC;AAEDD,mBAAmB,CAACD,WAAW,GAAG,qBAAqB;AAAC,IAAA+B,QAAA,GAAA/C,OAAA,CAAAV,OAAA,GAEzC2B,mBAAmB","ignoreList":[]}
@@ -14,6 +14,8 @@ const ColorPicker = ({
14
14
  onPresetColorAdd,
15
15
  onPresetColorRemove,
16
16
  onSelect,
17
+ shouldHideColorArea = false,
18
+ shouldHideDefaultPresetColors = false,
17
19
  presetColors,
18
20
  selectedColor = 'rgba(0, 94, 184, 1)',
19
21
  shouldShowAsPopup = true,
@@ -22,21 +24,25 @@ const ColorPicker = ({
22
24
  shouldShowPreviewColorString = true,
23
25
  shouldShowRoundPreviewColor = true,
24
26
  shouldShowTransparencySlider = false,
25
- shouldUseSiteColors = false
27
+ shouldUseSiteColors = false,
28
+ alignment
26
29
  }) => /*#__PURE__*/_react.default.createElement(_ColorPickerProvider.default, {
27
30
  selectedColor: selectedColor,
28
31
  onSelect: onSelect
29
32
  }, /*#__PURE__*/_react.default.createElement(_ColorPicker.StyledColorPicker, null, /*#__PURE__*/_react.default.createElement(_ColorPickerWrapper.default, {
33
+ alignment: alignment,
30
34
  onPresetColorAdd: onPresetColorAdd,
31
35
  onPresetColorRemove: onPresetColorRemove,
32
36
  presetColors: presetColors,
37
+ shouldHideDefaultPresetColors: shouldHideDefaultPresetColors,
33
38
  shouldShowAsPopup: shouldShowAsPopup,
34
39
  shouldShowMoreOptions: shouldShowMoreOptions,
35
40
  shouldShowPresetColors: shouldShowPresetColors,
36
41
  shouldShowPreviewColorString: shouldShowPreviewColorString,
37
42
  shouldShowRoundPreviewColor: shouldShowRoundPreviewColor,
38
43
  shouldShowTransparencySlider: shouldShowTransparencySlider,
39
- shouldUseSiteColors: shouldUseSiteColors
44
+ shouldUseSiteColors: shouldUseSiteColors,
45
+ shouldHideColorArea: shouldHideColorArea
40
46
  }, children)));
41
47
  ColorPicker.displayName = 'ColorPicker';
42
48
  var _default = exports.default = ColorPicker;
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPicker.js","names":["_react","_interopRequireDefault","require","_ColorPickerProvider","_ColorPickerWrapper","_ColorPicker","e","__esModule","default","ColorPicker","children","onPresetColorAdd","onPresetColorRemove","onSelect","presetColors","selectedColor","shouldShowAsPopup","shouldShowMoreOptions","shouldShowPresetColors","shouldShowPreviewColorString","shouldShowRoundPreviewColor","shouldShowTransparencySlider","shouldUseSiteColors","createElement","StyledColorPicker","displayName","_default","exports"],"sources":["../../../../src/components/color-picker/ColorPicker.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport type { IPresetColor } from '../../types/colorPicker';\nimport ColorPickerProvider from '../ColorPickerProvider';\nimport ColorPickerWrapper from './color-picker-wrapper/ColorPickerWrapper';\nimport { StyledColorPicker } from './ColorPicker.styles';\n\ninterface ColorPickerProps {\n /**\n * The element that should be rendered to trigger the ColorPicker popup on click.\n */\n children?: ReactNode;\n /**\n * Function to be executed when a preset color is added.\n */\n onPresetColorAdd?: (presetColor: IPresetColor) => void;\n /**\n * Function to be executed when a preset color is removed.\n */\n onPresetColorRemove?: (presetColorId: IPresetColor['id']) => void;\n /**\n * Function to be executed when a color is selected.\n */\n onSelect?: (color: string) => void;\n /**\n * Colors the user can select from.\n */\n presetColors?: IPresetColor[];\n /**\n * The color that should be preselected.\n */\n selectedColor?: string;\n /**\n * Whether the ColorPicker should be displayed inside a popup.\n */\n shouldShowAsPopup?: boolean;\n /**\n * Whether the more options accordion should be displayed.\n */\n shouldShowMoreOptions?: boolean;\n /**\n * Whether the preset colors should be displayed.\n */\n shouldShowPresetColors?: boolean;\n /**\n * Whether the preview color should be displayed as text.\n */\n shouldShowPreviewColorString?: boolean;\n /**\n * Whether the preview color should be displayed round.\n */\n shouldShowRoundPreviewColor?: boolean;\n /**\n * Whether the transparency slider should be displayed.\n */\n shouldShowTransparencySlider?: boolean;\n /**\n * Whether presetColors should be got and uploaded to the site storage.\n */\n shouldUseSiteColors?: boolean;\n}\n\nconst ColorPicker = ({\n children,\n onPresetColorAdd,\n onPresetColorRemove,\n onSelect,\n presetColors,\n selectedColor = 'rgba(0, 94, 184, 1)',\n shouldShowAsPopup = true,\n shouldShowMoreOptions = false,\n shouldShowPresetColors = false,\n shouldShowPreviewColorString = true,\n shouldShowRoundPreviewColor = true,\n shouldShowTransparencySlider = false,\n shouldUseSiteColors = false,\n}: ColorPickerProps) => (\n <ColorPickerProvider selectedColor={selectedColor} onSelect={onSelect}>\n <StyledColorPicker>\n <ColorPickerWrapper\n onPresetColorAdd={onPresetColorAdd}\n onPresetColorRemove={onPresetColorRemove}\n presetColors={presetColors}\n shouldShowAsPopup={shouldShowAsPopup}\n shouldShowMoreOptions={shouldShowMoreOptions}\n shouldShowPresetColors={shouldShowPresetColors}\n shouldShowPreviewColorString={shouldShowPreviewColorString}\n shouldShowRoundPreviewColor={shouldShowRoundPreviewColor}\n shouldShowTransparencySlider={shouldShowTransparencySlider}\n shouldUseSiteColors={shouldUseSiteColors}\n >\n {children}\n </ColorPickerWrapper>\n </StyledColorPicker>\n </ColorPickerProvider>\n);\n\nColorPicker.displayName = 'ColorPicker';\n\nexport default ColorPicker;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,oBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,mBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAAyD,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAyDzD,MAAMG,WAAW,GAAGA,CAAC;EACjBC,QAAQ;EACRC,gBAAgB;EAChBC,mBAAmB;EACnBC,QAAQ;EACRC,YAAY;EACZC,aAAa,GAAG,qBAAqB;EACrCC,iBAAiB,GAAG,IAAI;EACxBC,qBAAqB,GAAG,KAAK;EAC7BC,sBAAsB,GAAG,KAAK;EAC9BC,4BAA4B,GAAG,IAAI;EACnCC,2BAA2B,GAAG,IAAI;EAClCC,4BAA4B,GAAG,KAAK;EACpCC,mBAAmB,GAAG;AACR,CAAC,kBACftB,MAAA,CAAAQ,OAAA,CAAAe,aAAA,CAACpB,oBAAA,CAAAK,OAAmB;EAACO,aAAa,EAAEA,aAAc;EAACF,QAAQ,EAAEA;AAAS,gBAClEb,MAAA,CAAAQ,OAAA,CAAAe,aAAA,CAAClB,YAAA,CAAAmB,iBAAiB,qBACdxB,MAAA,CAAAQ,OAAA,CAAAe,aAAA,CAACnB,mBAAA,CAAAI,OAAkB;EACfG,gBAAgB,EAAEA,gBAAiB;EACnCC,mBAAmB,EAAEA,mBAAoB;EACzCE,YAAY,EAAEA,YAAa;EAC3BE,iBAAiB,EAAEA,iBAAkB;EACrCC,qBAAqB,EAAEA,qBAAsB;EAC7CC,sBAAsB,EAAEA,sBAAuB;EAC/CC,4BAA4B,EAAEA,4BAA6B;EAC3DC,2BAA2B,EAAEA,2BAA4B;EACzDC,4BAA4B,EAAEA,4BAA6B;EAC3DC,mBAAmB,EAAEA;AAAoB,GAExCZ,QACe,CACL,CACF,CACxB;AAEDD,WAAW,CAACgB,WAAW,GAAG,aAAa;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAnB,OAAA,GAEzBC,WAAW","ignoreList":[]}
1
+ {"version":3,"file":"ColorPicker.js","names":["_react","_interopRequireDefault","require","_ColorPickerProvider","_ColorPickerWrapper","_ColorPicker","e","__esModule","default","ColorPicker","children","onPresetColorAdd","onPresetColorRemove","onSelect","shouldHideColorArea","shouldHideDefaultPresetColors","presetColors","selectedColor","shouldShowAsPopup","shouldShowMoreOptions","shouldShowPresetColors","shouldShowPreviewColorString","shouldShowRoundPreviewColor","shouldShowTransparencySlider","shouldUseSiteColors","alignment","createElement","StyledColorPicker","displayName","_default","exports"],"sources":["../../../../src/components/color-picker/ColorPicker.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport type { IPresetColor } from '../../types/colorPicker';\nimport ColorPickerProvider from '../ColorPickerProvider';\nimport ColorPickerWrapper from './color-picker-wrapper/ColorPickerWrapper';\nimport { StyledColorPicker } from './ColorPicker.styles';\nimport { PopupAlignment } from '@chayns-components/core';\n\ninterface ColorPickerProps {\n /**\n * The element that should be rendered to trigger the ColorPicker popup on click.\n */\n children?: ReactNode;\n /**\n * Function to be executed when a preset color is added.\n */\n onPresetColorAdd?: (presetColor: IPresetColor) => void;\n /**\n * Function to be executed when a preset color is removed.\n */\n onPresetColorRemove?: (presetColorId: IPresetColor['id']) => void;\n /**\n * Function to be executed when a color is selected.\n */\n onSelect?: (color: string) => void;\n /**\n * Colors the user can select from.\n */\n presetColors?: IPresetColor[];\n /**\n * The color that should be preselected.\n */\n selectedColor?: string;\n /**\n * Whether the ColorPicker should be displayed inside a popup.\n */\n shouldShowAsPopup?: boolean;\n /**\n * Whether the more options accordion should be displayed.\n */\n shouldShowMoreOptions?: boolean;\n /**\n * Whether the preset colors should be displayed.\n */\n shouldShowPresetColors?: boolean;\n /**\n * Whether the preview color should be displayed as text.\n */\n shouldShowPreviewColorString?: boolean;\n /**\n * Whether the preview color should be displayed round.\n */\n shouldShowRoundPreviewColor?: boolean;\n /**\n * Whether the transparency slider should be displayed.\n */\n shouldShowTransparencySlider?: boolean;\n /**\n * Whether presetColors should be got and uploaded to the site storage.\n */\n shouldUseSiteColors?: boolean;\n /**\n * Whether the color area should be displayed.\n */\n shouldHideColorArea?: boolean;\n /**\n * Whether the default preset colors should be hidden.\n */\n shouldHideDefaultPresetColors?: boolean;\n /**\n * The alignment of the popup\n */\n alignment?: PopupAlignment;\n}\n\nconst ColorPicker = ({\n children,\n onPresetColorAdd,\n onPresetColorRemove,\n onSelect,\n shouldHideColorArea = false,\n shouldHideDefaultPresetColors = false,\n presetColors,\n selectedColor = 'rgba(0, 94, 184, 1)',\n shouldShowAsPopup = true,\n shouldShowMoreOptions = false,\n shouldShowPresetColors = false,\n shouldShowPreviewColorString = true,\n shouldShowRoundPreviewColor = true,\n shouldShowTransparencySlider = false,\n shouldUseSiteColors = false,\n alignment,\n}: ColorPickerProps) => (\n <ColorPickerProvider selectedColor={selectedColor} onSelect={onSelect}>\n <StyledColorPicker>\n <ColorPickerWrapper\n alignment={alignment}\n onPresetColorAdd={onPresetColorAdd}\n onPresetColorRemove={onPresetColorRemove}\n presetColors={presetColors}\n shouldHideDefaultPresetColors={shouldHideDefaultPresetColors}\n shouldShowAsPopup={shouldShowAsPopup}\n shouldShowMoreOptions={shouldShowMoreOptions}\n shouldShowPresetColors={shouldShowPresetColors}\n shouldShowPreviewColorString={shouldShowPreviewColorString}\n shouldShowRoundPreviewColor={shouldShowRoundPreviewColor}\n shouldShowTransparencySlider={shouldShowTransparencySlider}\n shouldUseSiteColors={shouldUseSiteColors}\n shouldHideColorArea={shouldHideColorArea}\n >\n {children}\n </ColorPickerWrapper>\n </StyledColorPicker>\n </ColorPickerProvider>\n);\n\nColorPicker.displayName = 'ColorPicker';\n\nexport default ColorPicker;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,oBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,mBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAAyD,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAsEzD,MAAMG,WAAW,GAAGA,CAAC;EACjBC,QAAQ;EACRC,gBAAgB;EAChBC,mBAAmB;EACnBC,QAAQ;EACRC,mBAAmB,GAAG,KAAK;EAC3BC,6BAA6B,GAAG,KAAK;EACrCC,YAAY;EACZC,aAAa,GAAG,qBAAqB;EACrCC,iBAAiB,GAAG,IAAI;EACxBC,qBAAqB,GAAG,KAAK;EAC7BC,sBAAsB,GAAG,KAAK;EAC9BC,4BAA4B,GAAG,IAAI;EACnCC,2BAA2B,GAAG,IAAI;EAClCC,4BAA4B,GAAG,KAAK;EACpCC,mBAAmB,GAAG,KAAK;EAC3BC;AACc,CAAC,kBACfzB,MAAA,CAAAQ,OAAA,CAAAkB,aAAA,CAACvB,oBAAA,CAAAK,OAAmB;EAACS,aAAa,EAAEA,aAAc;EAACJ,QAAQ,EAAEA;AAAS,gBAClEb,MAAA,CAAAQ,OAAA,CAAAkB,aAAA,CAACrB,YAAA,CAAAsB,iBAAiB,qBACd3B,MAAA,CAAAQ,OAAA,CAAAkB,aAAA,CAACtB,mBAAA,CAAAI,OAAkB;EACfiB,SAAS,EAAEA,SAAU;EACrBd,gBAAgB,EAAEA,gBAAiB;EACnCC,mBAAmB,EAAEA,mBAAoB;EACzCI,YAAY,EAAEA,YAAa;EAC3BD,6BAA6B,EAAEA,6BAA8B;EAC7DG,iBAAiB,EAAEA,iBAAkB;EACrCC,qBAAqB,EAAEA,qBAAsB;EAC7CC,sBAAsB,EAAEA,sBAAuB;EAC/CC,4BAA4B,EAAEA,4BAA6B;EAC3DC,2BAA2B,EAAEA,2BAA4B;EACzDC,4BAA4B,EAAEA,4BAA6B;EAC3DC,mBAAmB,EAAEA,mBAAoB;EACzCV,mBAAmB,EAAEA;AAAoB,GAExCJ,QACe,CACL,CACF,CACxB;AAEDD,WAAW,CAACmB,WAAW,GAAG,aAAa;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAtB,OAAA,GAEzBC,WAAW","ignoreList":[]}
@@ -10,8 +10,7 @@ var _ColorPickerPopup = _interopRequireDefault(require("../../color-picker-popup
10
10
  var _ColorPickerProvider = require("../../ColorPickerProvider");
11
11
  var _ColorPickerWrapper = require("./ColorPickerWrapper.styles");
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
15
14
  const ColorPickerWrapper = ({
16
15
  children,
17
16
  onPresetColorAdd,
@@ -19,16 +18,21 @@ const ColorPickerWrapper = ({
19
18
  presetColors,
20
19
  shouldShowAsPopup,
21
20
  shouldShowMoreOptions,
21
+ shouldHideDefaultPresetColors,
22
22
  shouldShowPresetColors,
23
23
  shouldShowPreviewColorString,
24
24
  shouldShowRoundPreviewColor,
25
+ shouldHideColorArea,
25
26
  shouldShowTransparencySlider,
26
- shouldUseSiteColors
27
+ shouldUseSiteColors,
28
+ alignment
27
29
  }) => {
28
30
  const {
29
31
  selectedColor
30
32
  } = (0, _react.useContext)(_ColorPickerProvider.ColorPickerContext);
31
33
  const content = (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_ColorPickerPopup.default, {
34
+ shouldHideDefaultPresetColors: shouldHideDefaultPresetColors,
35
+ shouldHideColorArea: shouldHideColorArea,
32
36
  shouldShowPresetColors: shouldShowPresetColors,
33
37
  onPresetColorRemove: onPresetColorRemove,
34
38
  onPresetColorAdd: onPresetColorAdd,
@@ -36,9 +40,10 @@ const ColorPickerWrapper = ({
36
40
  shouldUseSiteColors: shouldUseSiteColors,
37
41
  shouldShowMoreOptions: shouldShowMoreOptions,
38
42
  shouldShowTransparencySlider: shouldShowTransparencySlider
39
- }), [onPresetColorAdd, onPresetColorRemove, presetColors, shouldShowMoreOptions, shouldShowPresetColors, shouldShowTransparencySlider, shouldUseSiteColors]);
43
+ }), [onPresetColorAdd, onPresetColorRemove, presetColors, shouldHideColorArea, shouldHideDefaultPresetColors, shouldShowMoreOptions, shouldShowPresetColors, shouldShowTransparencySlider, shouldUseSiteColors]);
40
44
  return /*#__PURE__*/_react.default.createElement(_ColorPickerWrapper.StyledColorPickerWrapper, null, shouldShowAsPopup ? /*#__PURE__*/_react.default.createElement(_core.Popup, {
41
- content: content
45
+ content: content,
46
+ alignment: alignment
42
47
  }, children ?? /*#__PURE__*/_react.default.createElement(_ColorPickerWrapper.StyledColorPickerWrapperInfo, null, /*#__PURE__*/_react.default.createElement(_ColorPickerWrapper.StyledColorPickerWrapperInfoColorWrapper, {
43
48
  $shouldShowRoundPreviewColor: shouldShowRoundPreviewColor
44
49
  }, /*#__PURE__*/_react.default.createElement(_ColorPickerWrapper.StyledColorPickerWrapperInfoColor, {
@@ -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","children","onPresetColorAdd","onPresetColorRemove","presetColors","shouldShowAsPopup","shouldShowMoreOptions","shouldShowPresetColors","shouldShowPreviewColorString","shouldShowRoundPreviewColor","shouldShowTransparencySlider","shouldUseSiteColors","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, { ReactNode, 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 children?: ReactNode;\n onPresetColorAdd?: (presetColor: IPresetColor) => void;\n onPresetColorRemove?: (presetColorId: IPresetColor['id']) => void;\n presetColors?: IPresetColor[];\n shouldShowAsPopup: boolean;\n shouldShowMoreOptions: boolean;\n shouldShowPresetColors: boolean;\n shouldShowPreviewColorString: boolean;\n shouldShowRoundPreviewColor: boolean;\n shouldShowTransparencySlider: boolean;\n shouldUseSiteColors: boolean;\n}\n\nconst ColorPickerWrapper = ({\n children,\n onPresetColorAdd,\n onPresetColorRemove,\n presetColors,\n shouldShowAsPopup,\n shouldShowMoreOptions,\n shouldShowPresetColors,\n shouldShowPreviewColorString,\n shouldShowRoundPreviewColor,\n shouldShowTransparencySlider,\n shouldUseSiteColors,\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 shouldUseSiteColors={shouldUseSiteColors}\n shouldShowMoreOptions={shouldShowMoreOptions}\n shouldShowTransparencySlider={shouldShowTransparencySlider}\n />\n ),\n [\n onPresetColorAdd,\n onPresetColorRemove,\n presetColors,\n shouldShowMoreOptions,\n shouldShowPresetColors,\n shouldShowTransparencySlider,\n shouldUseSiteColors,\n ],\n );\n\n return (\n <StyledColorPickerWrapper>\n {shouldShowAsPopup ? (\n <Popup content={content}>\n {children ?? (\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 )}\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;AAMqC,SAAAI,uBAAAG,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,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":[]}
1
+ {"version":3,"file":"ColorPickerWrapper.js","names":["_core","require","_react","_interopRequireWildcard","_ColorPickerPopup","_interopRequireDefault","_ColorPickerProvider","_ColorPickerWrapper","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ColorPickerWrapper","children","onPresetColorAdd","onPresetColorRemove","presetColors","shouldShowAsPopup","shouldShowMoreOptions","shouldHideDefaultPresetColors","shouldShowPresetColors","shouldShowPreviewColorString","shouldShowRoundPreviewColor","shouldHideColorArea","shouldShowTransparencySlider","shouldUseSiteColors","alignment","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, PopupAlignment } from '@chayns-components/core';\nimport React, { ReactNode, 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 children?: ReactNode;\n onPresetColorAdd?: (presetColor: IPresetColor) => void;\n onPresetColorRemove?: (presetColorId: IPresetColor['id']) => void;\n presetColors?: IPresetColor[];\n shouldShowAsPopup: boolean;\n shouldShowMoreOptions: boolean;\n shouldShowPresetColors: boolean;\n shouldShowPreviewColorString: boolean;\n shouldShowRoundPreviewColor: boolean;\n shouldShowTransparencySlider: boolean;\n shouldUseSiteColors: boolean;\n shouldHideColorArea: boolean;\n shouldHideDefaultPresetColors: boolean;\n alignment?: PopupAlignment;\n}\n\nconst ColorPickerWrapper = ({\n children,\n onPresetColorAdd,\n onPresetColorRemove,\n presetColors,\n shouldShowAsPopup,\n shouldShowMoreOptions,\n shouldHideDefaultPresetColors,\n shouldShowPresetColors,\n shouldShowPreviewColorString,\n shouldShowRoundPreviewColor,\n shouldHideColorArea,\n shouldShowTransparencySlider,\n shouldUseSiteColors,\n alignment,\n}: ColorPickerWrapperProps) => {\n const { selectedColor } = useContext(ColorPickerContext);\n\n const content = useMemo(\n () => (\n <ColorPickerPopup\n shouldHideDefaultPresetColors={shouldHideDefaultPresetColors}\n shouldHideColorArea={shouldHideColorArea}\n shouldShowPresetColors={shouldShowPresetColors}\n onPresetColorRemove={onPresetColorRemove}\n onPresetColorAdd={onPresetColorAdd}\n presetColors={presetColors}\n shouldUseSiteColors={shouldUseSiteColors}\n shouldShowMoreOptions={shouldShowMoreOptions}\n shouldShowTransparencySlider={shouldShowTransparencySlider}\n />\n ),\n [\n onPresetColorAdd,\n onPresetColorRemove,\n presetColors,\n shouldHideColorArea,\n shouldHideDefaultPresetColors,\n shouldShowMoreOptions,\n shouldShowPresetColors,\n shouldShowTransparencySlider,\n shouldUseSiteColors,\n ],\n );\n\n return (\n <StyledColorPickerWrapper>\n {shouldShowAsPopup ? (\n <Popup content={content} alignment={alignment}>\n {children ?? (\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 )}\n </Popup>\n ) : (\n content\n )}\n </StyledColorPickerWrapper>\n );\n};\n\nColorPickerWrapper.displayName = 'ColorPickerW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AA,CAAAqC,aAAA,CAACxC,mBAAA,CAAA2C,4BAA4B,qBACzBhD,MAAA,CAAAQ,OAAA,CAAAqC,aAAA,CAACxC,mBAAA,CAAA4C,wCAAwC;IACrCC,4BAA4B,EAAEf;EAA4B,gBAE1DnC,MAAA,CAAAQ,OAAA,CAAAqC,aAAA,CAACxC,mBAAA,CAAA8C,iCAAiC;IAACC,MAAM,EAAEZ;EAAc,CAAE,CACrB,CAAC,EAE1CN,4BAA4B,iBACzBlC,MAAA,CAAAQ,OAAA,CAAAqC,aAAA,CAACxC,mBAAA,CAAAgD,gCAAgC,QAC5Bb,aAC6B,CAEZ,CAE/B,CAAC,GAERG,OAEkB,CAAC;AAEnC,CAAC;AAEDlB,kBAAkB,CAAC6B,WAAW,GAAG,oBAAoB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAhD,OAAA,GAEvCiB,kBAAkB","ignoreList":[]}
@@ -29,9 +29,9 @@ const StyledColorPickerWrapperInfoColorWrapper = exports.StyledColorPickerWrappe
29
29
  const StyledColorPickerWrapperInfoColorBackground = exports.StyledColorPickerWrapperInfoColorBackground = _styledComponents.default.div`
30
30
  position: absolute;
31
31
  background-color: #fff;
32
- background-image: linear-gradient(45deg, #a0a0a0 25%, #0000 0),
33
- linear-gradient(-45deg, #a0a0a0 25%, #0000 0), linear-gradient(45deg, #0000 75%, #a0a0a0 0),
34
- linear-gradient(-45deg, #0000 75%, #a0a0a0 0);
32
+ background-image:
33
+ linear-gradient(45deg, #a0a0a0 25%, #0000 0), linear-gradient(-45deg, #a0a0a0 25%, #0000 0),
34
+ linear-gradient(45deg, #0000 75%, #a0a0a0 0), linear-gradient(-45deg, #0000 75%, #a0a0a0 0);
35
35
  background-position:
36
36
  0 0,
37
37
  0 4px,
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPickerWrapper.styles.js","names":["_styledComponents","_interopRequireDefault","require","e","__esModule","default","StyledColorPickerWrapper","exports","styled","div","StyledColorPickerWrapperInfo","StyledColorPickerWrapperInfoColorWrapper","$shouldShowRoundPreviewColor","theme","text","StyledColorPickerWrapperInfoColorBackground","StyledColorPickerWrapperInfoColor","attrs","$color","style","backgroundColor","StyledColorPickerWrapperInfoText"],"sources":["../../../../../src/components/color-picker/color-picker-wrapper/ColorPickerWrapper.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport styled from 'styled-components';\n\nexport const StyledColorPickerWrapper = styled.div``;\n\nexport const StyledColorPickerWrapperInfo = styled.div`\n display: flex;\n align-items: center;\n gap: 8px;\n`;\n\ntype StyledColorPickerWrapperInfoColorProps = WithTheme<{\n $color?: string;\n}>;\n\ntype StyledColorPickerWrapperInfoColorWrapperProps = WithTheme<{\n $shouldShowRoundPreviewColor: boolean;\n}>;\n\nexport const StyledColorPickerWrapperInfoColorWrapper = styled.div<StyledColorPickerWrapperInfoColorWrapperProps>`\n border-radius: ${({ $shouldShowRoundPreviewColor }) =>\n $shouldShowRoundPreviewColor ? '50px' : '0px'};\n border: 1px ${({ theme }: StyledColorPickerWrapperInfoColorProps) => theme.text} solid;\n\n width: 15px;\n aspect-ratio: 1;\n position: relative;\n\n overflow: hidden;\n`;\n\nexport const StyledColorPickerWrapperInfoColorBackground = styled.div`\n position: absolute;\n background-color: #fff;\n background-image: linear-gradient(45deg, #a0a0a0 25%, #0000 0),\n linear-gradient(-45deg, #a0a0a0 25%, #0000 0), linear-gradient(45deg, #0000 75%, #a0a0a0 0),\n linear-gradient(-45deg, #0000 75%, #a0a0a0 0);\n background-position:\n 0 0,\n 0 4px,\n 4px -4px,\n -4px 0;\n background-repeat: repeat;\n background-size: 8px 8px;\n height: 100%;\n width: 100%;\n`;\n\nexport const StyledColorPickerWrapperInfoColor = styled.div.attrs<StyledColorPickerWrapperInfoColorProps>(\n ({ $color }) => ({\n style: {\n backgroundColor: $color,\n },\n }),\n)`\n height: 100%;\n width: 100%;\n position: absolute;\n`;\n\ntype StyledColorPickerWrapperInfoTextProps = WithTheme<unknown>;\n\nexport const StyledColorPickerWrapperInfoText = styled.div<StyledColorPickerWrapperInfoTextProps>`\n border-bottom-style: dashed;\n border-bottom-width: 1px;\n\n color: ${({ theme }: StyledColorPickerWrapperInfoTextProps) => theme.text};\n`;\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEhC,MAAMG,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAGE,yBAAM,CAACC,GAAG,EAAE;AAE7C,MAAMC,4BAA4B,GAAAH,OAAA,CAAAG,4BAAA,GAAGF,yBAAM,CAACC,GAAG;AACtD;AACA;AACA;AACA,CAAC;AAUM,MAAME,wCAAwC,GAAAJ,OAAA,CAAAI,wCAAA,GAAGH,yBAAM,CAACC,GAAkD;AACjH,qBAAqB,CAAC;EAAEG;AAA6B,CAAC,KAC9CA,4BAA4B,GAAG,MAAM,GAAG,KAAK;AACrD,kBAAkB,CAAC;EAAEC;AAA8C,CAAC,KAAKA,KAAK,CAACC,IAAI;AACnF;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,2CAA2C,GAAAR,OAAA,CAAAQ,2CAAA,GAAGP,yBAAM,CAACC,GAAG;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMO,iCAAiC,GAAAT,OAAA,CAAAS,iCAAA,GAAGR,yBAAM,CAACC,GAAG,CAACQ,KAAK,CAC7D,CAAC;EAAEC;AAAO,CAAC,MAAM;EACbC,KAAK,EAAE;IACHC,eAAe,EAAEF;EACrB;AACJ,CAAC,CACL,CAAC;AACD;AACA;AACA;AACA,CAAC;AAIM,MAAMG,gCAAgC,GAAAd,OAAA,CAAAc,gCAAA,GAAGb,yBAAM,CAACC,GAA0C;AACjG;AACA;AACA;AACA,aAAa,CAAC;EAAEI;AAA6C,CAAC,KAAKA,KAAK,CAACC,IAAI;AAC7E,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ColorPickerWrapper.styles.js","names":["_styledComponents","_interopRequireDefault","require","e","__esModule","default","StyledColorPickerWrapper","exports","styled","div","StyledColorPickerWrapperInfo","StyledColorPickerWrapperInfoColorWrapper","$shouldShowRoundPreviewColor","theme","text","StyledColorPickerWrapperInfoColorBackground","StyledColorPickerWrapperInfoColor","attrs","$color","style","backgroundColor","StyledColorPickerWrapperInfoText"],"sources":["../../../../../src/components/color-picker/color-picker-wrapper/ColorPickerWrapper.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport styled from 'styled-components';\n\nexport const StyledColorPickerWrapper = styled.div``;\n\nexport const StyledColorPickerWrapperInfo = styled.div`\n display: flex;\n align-items: center;\n gap: 8px;\n`;\n\ntype StyledColorPickerWrapperInfoColorProps = WithTheme<{\n $color?: string;\n}>;\n\ntype StyledColorPickerWrapperInfoColorWrapperProps = WithTheme<{\n $shouldShowRoundPreviewColor: boolean;\n}>;\n\nexport const StyledColorPickerWrapperInfoColorWrapper = styled.div<StyledColorPickerWrapperInfoColorWrapperProps>`\n border-radius: ${({ $shouldShowRoundPreviewColor }) =>\n $shouldShowRoundPreviewColor ? '50px' : '0px'};\n border: 1px ${({ theme }: StyledColorPickerWrapperInfoColorProps) => theme.text} solid;\n\n width: 15px;\n aspect-ratio: 1;\n position: relative;\n\n overflow: hidden;\n`;\n\nexport const StyledColorPickerWrapperInfoColorBackground = styled.div`\n position: absolute;\n background-color: #fff;\n background-image:\n linear-gradient(45deg, #a0a0a0 25%, #0000 0), linear-gradient(-45deg, #a0a0a0 25%, #0000 0),\n linear-gradient(45deg, #0000 75%, #a0a0a0 0), linear-gradient(-45deg, #0000 75%, #a0a0a0 0);\n background-position:\n 0 0,\n 0 4px,\n 4px -4px,\n -4px 0;\n background-repeat: repeat;\n background-size: 8px 8px;\n height: 100%;\n width: 100%;\n`;\n\nexport const StyledColorPickerWrapperInfoColor = styled.div.attrs<StyledColorPickerWrapperInfoColorProps>(\n ({ $color }) => ({\n style: {\n backgroundColor: $color,\n },\n }),\n)`\n height: 100%;\n width: 100%;\n position: absolute;\n`;\n\ntype StyledColorPickerWrapperInfoTextProps = WithTheme<unknown>;\n\nexport const StyledColorPickerWrapperInfoText = styled.div<StyledColorPickerWrapperInfoTextProps>`\n border-bottom-style: dashed;\n border-bottom-width: 1px;\n\n color: ${({ theme }: StyledColorPickerWrapperInfoTextProps) => theme.text};\n`;\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEhC,MAAMG,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAGE,yBAAM,CAACC,GAAG,EAAE;AAE7C,MAAMC,4BAA4B,GAAAH,OAAA,CAAAG,4BAAA,GAAGF,yBAAM,CAACC,GAAG;AACtD;AACA;AACA;AACA,CAAC;AAUM,MAAME,wCAAwC,GAAAJ,OAAA,CAAAI,wCAAA,GAAGH,yBAAM,CAACC,GAAkD;AACjH,qBAAqB,CAAC;EAAEG;AAA6B,CAAC,KAC9CA,4BAA4B,GAAG,MAAM,GAAG,KAAK;AACrD,kBAAkB,CAAC;EAAEC;AAA8C,CAAC,KAAKA,KAAK,CAACC,IAAI;AACnF;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,2CAA2C,GAAAR,OAAA,CAAAQ,2CAAA,GAAGP,yBAAM,CAACC,GAAG;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMO,iCAAiC,GAAAT,OAAA,CAAAS,iCAAA,GAAGR,yBAAM,CAACC,GAAG,CAACQ,KAAK,CAC7D,CAAC;EAAEC;AAAO,CAAC,MAAM;EACbC,KAAK,EAAE;IACHC,eAAe,EAAEF;EACrB;AACJ,CAAC,CACL,CAAC;AACD;AACA;AACA;AACA,CAAC;AAIM,MAAMG,gCAAgC,GAAAd,OAAA,CAAAc,gCAAA,GAAGb,yBAAM,CAACC,GAA0C;AACjG;AACA;AACA;AACA,aAAa,CAAC;EAAEI;AAA6C,CAAC,KAAKA,KAAK,CAACC,IAAI;AAC7E,CAAC","ignoreList":[]}
@@ -17,11 +17,14 @@ const ColorPickerPopup = ({
17
17
  onPresetColorAdd,
18
18
  shouldShowPresetColors,
19
19
  shouldShowTransparencySlider,
20
+ shouldHideDefaultPresetColors,
20
21
  shouldUseSiteColors,
21
- shouldShowMoreOptions
22
- }) => /*#__PURE__*/_react.default.createElement(_ColorPickerPopup.StyledColorPickerPopup, null, /*#__PURE__*/_react.default.createElement(_ColorArea.default, null), /*#__PURE__*/_react.default.createElement(_Sliders.default, {
22
+ shouldShowMoreOptions,
23
+ shouldHideColorArea
24
+ }) => /*#__PURE__*/_react.default.createElement(_ColorPickerPopup.StyledColorPickerPopup, null, !shouldHideColorArea && /*#__PURE__*/_react.default.createElement(_ColorArea.default, null), !shouldHideColorArea && /*#__PURE__*/_react.default.createElement(_Sliders.default, {
23
25
  shouldShowTransparencySlider: shouldShowTransparencySlider
24
26
  }), shouldShowPresetColors && /*#__PURE__*/_react.default.createElement(_PresetColors.default, {
27
+ shouldHideDefaultPresetColors: shouldHideDefaultPresetColors,
25
28
  presetColors: presetColors,
26
29
  shouldUseSiteColors: shouldUseSiteColors,
27
30
  onPresetColorAdd: onPresetColorAdd,
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPickerPopup.js","names":["_react","_interopRequireDefault","require","_ColorArea","_ColorPickerPopup","_MoreOptions","_PresetColors","_Sliders","e","__esModule","default","ColorPickerPopup","presetColors","onPresetColorRemove","onPresetColorAdd","shouldShowPresetColors","shouldShowTransparencySlider","shouldUseSiteColors","shouldShowMoreOptions","createElement","StyledColorPickerPopup","displayName","_default","exports"],"sources":["../../../../src/components/color-picker-popup/ColorPickerPopup.tsx"],"sourcesContent":["import React from 'react';\nimport type { IPresetColor } from '../../types/colorPicker';\nimport ColorArea from './color-area/ColorArea';\nimport { StyledColorPickerPopup } from './ColorPickerPopup.styles';\nimport MoreOptions from './more-options/MoreOptions';\nimport PresetColors from './preset-colors/PresetColors';\nimport Sliders from './sliders/Sliders';\n\ninterface ColorPickerPopupProps {\n presetColors?: IPresetColor[];\n shouldShowPresetColors: boolean;\n onPresetColorAdd?: (presetColor: IPresetColor) => void;\n onPresetColorRemove?: (presetColorId: IPresetColor['id']) => void;\n shouldShowTransparencySlider: boolean;\n shouldShowMoreOptions: boolean;\n shouldUseSiteColors: boolean;\n}\n\nconst ColorPickerPopup = ({\n presetColors,\n onPresetColorRemove,\n onPresetColorAdd,\n shouldShowPresetColors,\n shouldShowTransparencySlider,\n shouldUseSiteColors,\n shouldShowMoreOptions,\n}: ColorPickerPopupProps) => (\n <StyledColorPickerPopup>\n <ColorArea />\n <Sliders shouldShowTransparencySlider={shouldShowTransparencySlider} />\n {shouldShowPresetColors && (\n <PresetColors\n presetColors={presetColors}\n shouldUseSiteColors={shouldUseSiteColors}\n onPresetColorAdd={onPresetColorAdd}\n onPresetColorRemove={onPresetColorRemove}\n />\n )}\n {shouldShowMoreOptions && <MoreOptions />}\n </StyledColorPickerPopup>\n);\n\nColorPickerPopup.displayName = 'ColorPickerPopup';\n\nexport default ColorPickerPopup;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,aAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,QAAA,GAAAN,sBAAA,CAAAC,OAAA;AAAwC,SAAAD,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAYxC,MAAMG,gBAAgB,GAAGA,CAAC;EACtBC,YAAY;EACZC,mBAAmB;EACnBC,gBAAgB;EAChBC,sBAAsB;EACtBC,4BAA4B;EAC5BC,mBAAmB;EACnBC;AACmB,CAAC,kBACpBlB,MAAA,CAAAU,OAAA,CAAAS,aAAA,CAACf,iBAAA,CAAAgB,sBAAsB,qBACnBpB,MAAA,CAAAU,OAAA,CAAAS,aAAA,CAAChB,UAAA,CAAAO,OAAS,MAAE,CAAC,eACbV,MAAA,CAAAU,OAAA,CAAAS,aAAA,CAACZ,QAAA,CAAAG,OAAO;EAACM,4BAA4B,EAAEA;AAA6B,CAAE,CAAC,EACtED,sBAAsB,iBACnBf,MAAA,CAAAU,OAAA,CAAAS,aAAA,CAACb,aAAA,CAAAI,OAAY;EACTE,YAAY,EAAEA,YAAa;EAC3BK,mBAAmB,EAAEA,mBAAoB;EACzCH,gBAAgB,EAAEA,gBAAiB;EACnCD,mBAAmB,EAAEA;AAAoB,CAC5C,CACJ,EACAK,qBAAqB,iBAAIlB,MAAA,CAAAU,OAAA,CAAAS,aAAA,CAACd,YAAA,CAAAK,OAAW,MAAE,CACpB,CAC3B;AAEDC,gBAAgB,CAACU,WAAW,GAAG,kBAAkB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAb,OAAA,GAEnCC,gBAAgB","ignoreList":[]}
1
+ {"version":3,"file":"ColorPickerPopup.js","names":["_react","_interopRequireDefault","require","_ColorArea","_ColorPickerPopup","_MoreOptions","_PresetColors","_Sliders","e","__esModule","default","ColorPickerPopup","presetColors","onPresetColorRemove","onPresetColorAdd","shouldShowPresetColors","shouldShowTransparencySlider","shouldHideDefaultPresetColors","shouldUseSiteColors","shouldShowMoreOptions","shouldHideColorArea","createElement","StyledColorPickerPopup","displayName","_default","exports"],"sources":["../../../../src/components/color-picker-popup/ColorPickerPopup.tsx"],"sourcesContent":["import React from 'react';\nimport type { IPresetColor } from '../../types/colorPicker';\nimport ColorArea from './color-area/ColorArea';\nimport { StyledColorPickerPopup } from './ColorPickerPopup.styles';\nimport MoreOptions from './more-options/MoreOptions';\nimport PresetColors from './preset-colors/PresetColors';\nimport Sliders from './sliders/Sliders';\n\ninterface ColorPickerPopupProps {\n presetColors?: IPresetColor[];\n shouldShowPresetColors: boolean;\n onPresetColorAdd?: (presetColor: IPresetColor) => void;\n onPresetColorRemove?: (presetColorId: IPresetColor['id']) => void;\n shouldShowTransparencySlider: boolean;\n shouldShowMoreOptions: boolean;\n shouldUseSiteColors: boolean;\n shouldHideColorArea: boolean;\n shouldHideDefaultPresetColors: boolean;\n}\n\nconst ColorPickerPopup = ({\n presetColors,\n onPresetColorRemove,\n onPresetColorAdd,\n shouldShowPresetColors,\n shouldShowTransparencySlider,\n shouldHideDefaultPresetColors,\n shouldUseSiteColors,\n shouldShowMoreOptions,\n shouldHideColorArea,\n}: ColorPickerPopupProps) => (\n <StyledColorPickerPopup>\n {!shouldHideColorArea && <ColorArea />}\n {!shouldHideColorArea && (\n <Sliders shouldShowTransparencySlider={shouldShowTransparencySlider} />\n )}\n {shouldShowPresetColors && (\n <PresetColors\n shouldHideDefaultPresetColors={shouldHideDefaultPresetColors}\n presetColors={presetColors}\n shouldUseSiteColors={shouldUseSiteColors}\n onPresetColorAdd={onPresetColorAdd}\n onPresetColorRemove={onPresetColorRemove}\n />\n )}\n {shouldShowMoreOptions && <MoreOptions />}\n </StyledColorPickerPopup>\n);\n\nColorPickerPopup.displayName = 'ColorPickerPopup';\n\nexport default ColorPickerPopup;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,aAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,QAAA,GAAAN,sBAAA,CAAAC,OAAA;AAAwC,SAAAD,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAcxC,MAAMG,gBAAgB,GAAGA,CAAC;EACtBC,YAAY;EACZC,mBAAmB;EACnBC,gBAAgB;EAChBC,sBAAsB;EACtBC,4BAA4B;EAC5BC,6BAA6B;EAC7BC,mBAAmB;EACnBC,qBAAqB;EACrBC;AACmB,CAAC,kBACpBpB,MAAA,CAAAU,OAAA,CAAAW,aAAA,CAACjB,iBAAA,CAAAkB,sBAAsB,QAClB,CAACF,mBAAmB,iBAAIpB,MAAA,CAAAU,OAAA,CAAAW,aAAA,CAAClB,UAAA,CAAAO,OAAS,MAAE,CAAC,EACrC,CAACU,mBAAmB,iBACjBpB,MAAA,CAAAU,OAAA,CAAAW,aAAA,CAACd,QAAA,CAAAG,OAAO;EAACM,4BAA4B,EAAEA;AAA6B,CAAE,CACzE,EACAD,sBAAsB,iBACnBf,MAAA,CAAAU,OAAA,CAAAW,aAAA,CAACf,aAAA,CAAAI,OAAY;EACTO,6BAA6B,EAAEA,6BAA8B;EAC7DL,YAAY,EAAEA,YAAa;EAC3BM,mBAAmB,EAAEA,mBAAoB;EACzCJ,gBAAgB,EAAEA,gBAAiB;EACnCD,mBAAmB,EAAEA;AAAoB,CAC5C,CACJ,EACAM,qBAAqB,iBAAInB,MAAA,CAAAU,OAAA,CAAAW,aAAA,CAAChB,YAAA,CAAAK,OAAW,MAAE,CACpB,CAC3B;AAEDC,gBAAgB,CAACY,WAAW,GAAG,kBAAkB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAf,OAAA,GAEnCC,gBAAgB","ignoreList":[]}
@@ -8,11 +8,11 @@ var _react = _interopRequireWildcard(require("react"));
8
8
  var _ColorArea = require("./ColorArea.styles");
9
9
  var _colors = require("@chayns/colors");
10
10
  var _chaynsApi = require("chayns-api");
11
- var _framerMotion = require("framer-motion");
11
+ var _react2 = require("motion/react");
12
12
  var _color = require("../../../utils/color");
13
13
  var _ColorPickerProvider = require("../../ColorPickerProvider");
14
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ var _core = require("@chayns-components/core");
15
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
16
16
  const ColorArea = () => {
17
17
  const {
18
18
  selectedColor,
@@ -35,9 +35,10 @@ const ColorArea = () => {
35
35
  const canDrag = (0, _react.useRef)(false);
36
36
  const canvasRef = (0, _react.useRef)(null);
37
37
  const pseudoRef = (0, _react.useRef)(null);
38
- const dragControls = (0, _framerMotion.useDragControls)();
39
- const x = (0, _framerMotion.useMotionValue)(0);
40
- const y = (0, _framerMotion.useMotionValue)(0);
38
+ const [shouldPreventListener, ref] = (0, _core.useIsMeasuredClone)();
39
+ const dragControls = (0, _react2.useDragControls)();
40
+ const x = (0, _react2.useMotionValue)(0);
41
+ const y = (0, _react2.useMotionValue)(0);
41
42
  (0, _react.useEffect)(() => {
42
43
  isPresetColorRef.current = isPresetColor ?? false;
43
44
  }, [isPresetColor]);
@@ -116,12 +117,6 @@ const ColorArea = () => {
116
117
  setColor();
117
118
  }
118
119
  }, [canGetColorFromArea, hueColor, setColor, updateIsPresetColor]);
119
- const handleStartDrag = (0, _react.useCallback)(() => {
120
- if (typeof updateShouldGetCoordinates === 'function') {
121
- updateShouldGetCoordinates(false);
122
- }
123
- canDrag.current = true;
124
- }, [updateShouldGetCoordinates]);
125
120
  (0, _react.useEffect)(() => {
126
121
  if (selectedColor && shouldGetCoordinatesRef.current) {
127
122
  const cords = (0, _color.getCoordinatesFromColor)({
@@ -188,6 +183,9 @@ const ColorArea = () => {
188
183
  setColor();
189
184
  }, [setColor, x, y]);
190
185
  const handleMouseMove = (0, _react.useCallback)(event => {
186
+ if (shouldPreventListener) {
187
+ return;
188
+ }
191
189
  if (canDrag.current && pseudoRef.current) {
192
190
  const {
193
191
  left,
@@ -197,7 +195,7 @@ const ColorArea = () => {
197
195
  const yCords = event.clientY - top - 10;
198
196
  move(xCords, yCords);
199
197
  }
200
- }, [move]);
198
+ }, [move, shouldPreventListener]);
201
199
  const handleTouchMove = (0, _react.useCallback)(event => {
202
200
  if (canDrag.current && pseudoRef.current) {
203
201
  event.preventDefault();
@@ -211,23 +209,29 @@ const ColorArea = () => {
211
209
  move(xCords, yCords);
212
210
  }
213
211
  }, [move]);
214
- (0, _react.useEffect)(() => {
215
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
216
- // @ts-ignore
212
+ const handleStartDrag = (0, _react.useCallback)(() => {
213
+ if (typeof updateShouldGetCoordinates === 'function') {
214
+ updateShouldGetCoordinates(false);
215
+ }
216
+ canDrag.current = true;
217
217
  window.addEventListener('mousemove', handleMouseMove);
218
- window.addEventListener('pointerup', handlePointerUp);
219
218
  window.addEventListener('touchmove', handleTouchMove);
220
- window.addEventListener('touchend', handlePointerUp);
221
- return () => {
222
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
223
- // @ts-ignore
219
+ const endTouching = () => {
220
+ if (shouldPreventListener) {
221
+ return;
222
+ }
223
+ handlePointerUp();
224
224
  window.removeEventListener('mousemove', handleMouseMove);
225
- window.removeEventListener('pointerup', handlePointerUp);
226
225
  window.removeEventListener('touchmove', handleTouchMove);
227
- window.removeEventListener('touchend', handlePointerUp);
226
+ window.removeEventListener('pointerup', endTouching);
227
+ window.removeEventListener('touchend', endTouching);
228
228
  };
229
- }, [handleMouseMove, handlePointerUp, handleTouchMove]);
230
- return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_ColorArea.StyledColorArea, null, /*#__PURE__*/_react.default.createElement(_ColorArea.StyledColorAreaCanvas, {
229
+ window.addEventListener('pointerup', endTouching);
230
+ window.addEventListener('touchend', endTouching);
231
+ }, [handleMouseMove, handlePointerUp, handleTouchMove, shouldPreventListener, updateShouldGetCoordinates]);
232
+ return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_ColorArea.StyledColorArea, {
233
+ ref: ref
234
+ }, /*#__PURE__*/_react.default.createElement(_ColorArea.StyledColorAreaCanvas, {
231
235
  ref: canvasRef
232
236
  }), /*#__PURE__*/_react.default.createElement(_ColorArea.StyledColorAreaPseudo, {
233
237
  ref: pseudoRef,
@@ -244,7 +248,7 @@ const ColorArea = () => {
244
248
  dragMomentum: false,
245
249
  dragControls: dragControls,
246
250
  onDrag: handleDrag
247
- }))), [dragControls, handleClick, handleDrag, handleStartDrag, x, y]);
251
+ }))), [dragControls, handleClick, handleDrag, handleStartDrag, ref, x, y]);
248
252
  };
249
253
  ColorArea.displayName = 'ColorArea';
250
254
  var _default = exports.default = ColorArea;
@@ -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","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,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBA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,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":[]}
1
+ {"version":3,"file":"ColorArea.js","names":["_react","_interopRequireWildcard","require","_ColorArea","_colors","_chaynsApi","_react2","_color","_ColorPickerProvider","_core","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","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","shouldPreventListener","ref","useIsMeasuredClone","dragControls","useDragControls","x","useMotionValue","y","useEffect","current","a","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","cords","getCoordinatesFromColor","tolerance","handleDrag","handleClick","event","left","top","target","clientX","clientY","handlePointerUp","setRefreshScrollEnabled","move","xCords","yCords","newXCords","newYCords","handleMouseMove","handleTouchMove","preventDefault","changedTouches","pageX","pageY","handleStartDrag","window","addEventListener","endTouching","removeEventListener","useMemo","createElement","StyledColorArea","StyledColorAreaCanvas","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, { useCallback, useContext, useEffect, useMemo, useRef, useState } 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 'motion/react';\nimport type { Scale } from '../../../types/colorPicker';\nimport {\n extractRgbValues,\n getColorFromCoordinates,\n getCoordinatesFromColor,\n rgbToHsv,\n} from '../../../utils/color';\nimport { ColorPickerContext } from '../../ColorPickerProvider';\nimport { useIsMeasuredClone } from '@chayns-components/core';\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 [shouldPreventListener, ref] = useIsMeasuredClone<HTMLDivElement>();\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 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: React.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 (shouldPreventListener) {\n return;\n }\n\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, shouldPreventListener],\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 const handleStartDrag = useCallback(() => {\n if (typeof updateShouldGetCoordinates === 'function') {\n updateShouldGetCoordinates(false);\n }\n\n canDrag.current = true;\n\n window.addEventListener('mousemove', handleMouseMove);\n window.addEventListener('touchmove', handleTouchMove);\n\n const endTouching = () => {\n if (shouldPreventListener) {\n return;\n }\n\n handlePointerUp();\n\n window.removeEventListener('mousemove', handleMouseMove);\n window.removeEventListener('touchmove', handleTouchMove);\n window.removeEventListener('pointerup', endTouching);\n window.removeEventListener('touchend', endTouching);\n };\n\n window.addEventListener('pointerup', endTouching);\n window.addEventListener('touchend', endTouching);\n }, [\n handleMouseMove,\n handlePointerUp,\n handleTouchMove,\n shouldPreventListener,\n updateShouldGetCoordinates,\n ]);\n\n return useMemo(\n () => (\n <StyledColorArea ref={ref}>\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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AAqB;IAClBxE,GAAG,EAAEF,SAAU;IACf2E,aAAa,EAAEV,eAAgB;IAC/BW,OAAO,EAAE/B;EAAY,gBAErBlG,MAAA,CAAAoB,OAAA,CAAAwG,aAAA,CAACzH,UAAA,CAAA+H,4BAA4B;IACzBC,IAAI;IACJC,eAAe,EAAE/E,SAAU;IAC3BgF,KAAK,EAAE;MAAE1E,CAAC;MAAEE;IAAE,CAAE;IAChByE,WAAW,EAAE,KAAM;IACnBC,YAAY,EAAE,KAAM;IACpB9E,YAAY,EAAEA,YAAa;IAC3B+E,MAAM,EAAEvC;EAAW,CACtB,CACkB,CACV,CACpB,EACD,CAACxC,YAAY,EAAEyC,WAAW,EAAED,UAAU,EAAEqB,eAAe,EAAE/D,GAAG,EAAEI,CAAC,EAAEE,CAAC,CACtE,CAAC;AACL,CAAC;AAEDhC,SAAS,CAAC4G,WAAW,GAAG,WAAW;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAvH,OAAA,GAErBS,SAAS","ignoreList":[]}
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.StyledMotionColorAreaPointer = exports.StyledColorAreaPseudo = exports.StyledColorAreaCanvas = exports.StyledColorArea = void 0;
7
- var _framerMotion = require("framer-motion");
7
+ var _react = require("motion/react");
8
8
  var _styledComponents = _interopRequireDefault(require("styled-components"));
9
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
10
  const StyledColorArea = exports.StyledColorArea = _styledComponents.default.div`
@@ -28,7 +28,7 @@ const StyledColorAreaPseudo = exports.StyledColorAreaPseudo = _styledComponents.
28
28
  height: 170px;
29
29
  width: 320px;
30
30
  `;
31
- const StyledMotionColorAreaPointer = exports.StyledMotionColorAreaPointer = (0, _styledComponents.default)(_framerMotion.motion.div)`
31
+ const StyledMotionColorAreaPointer = exports.StyledMotionColorAreaPointer = (0, _styledComponents.default)(_react.motion.div)`
32
32
  position: absolute;
33
33
  border-radius: 100%;
34
34
  border: 2px solid white;
@@ -1 +1 @@
1
- {"version":3,"file":"ColorArea.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireDefault","e","__esModule","default","StyledColorArea","exports","styled","div","StyledColorAreaCanvas","canvas","StyledColorAreaPseudo","StyledMotionColorAreaPointer","motion"],"sources":["../../../../../src/components/color-picker-popup/color-area/ColorArea.styles.ts"],"sourcesContent":["import { motion } from 'framer-motion';\nimport styled from 'styled-components';\n\nexport const StyledColorArea = styled.div`\n height: 150px;\n width: 300px;\n position: relative;\n user-select: none;\n overflow: hidden;\n cursor: crosshair;\n`;\n\nexport const StyledColorAreaCanvas = styled.canvas`\n user-select: none;\n`;\n\nexport const StyledColorAreaPseudo = styled.div`\n position: absolute;\n top: -10px;\n left: -10px;\n touch-action: none;\n user-select: none;\n\n height: 170px;\n width: 320px;\n`;\n\nexport const StyledMotionColorAreaPointer = styled(motion.div)`\n position: absolute;\n border-radius: 100%;\n border: 2px solid white;\n width: 20px;\n height: 20px;\n box-shadow:\n 0 0 5px 0 rgba(0, 0, 0, 0.5),\n 0 0 3px 0 rgba(0, 0, 0, 0.5) inset;\n pointer-events: none;\n user-select: none;\n top: 0;\n left: 0;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAuC,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEhC,MAAMG,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAGE,yBAAM,CAACC,GAAG;AACzC;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,qBAAqB,GAAAH,OAAA,CAAAG,qBAAA,GAAGF,yBAAM,CAACG,MAAM;AAClD;AACA,CAAC;AAEM,MAAMC,qBAAqB,GAAAL,OAAA,CAAAK,qBAAA,GAAGJ,yBAAM,CAACC,GAAG;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMI,4BAA4B,GAAAN,OAAA,CAAAM,4BAAA,GAAG,IAAAL,yBAAM,EAACM,oBAAM,CAACL,GAAG,CAAC;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ColorArea.styles.js","names":["_react","require","_styledComponents","_interopRequireDefault","e","__esModule","default","StyledColorArea","exports","styled","div","StyledColorAreaCanvas","canvas","StyledColorAreaPseudo","StyledMotionColorAreaPointer","motion"],"sources":["../../../../../src/components/color-picker-popup/color-area/ColorArea.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport styled from 'styled-components';\n\nexport const StyledColorArea = styled.div`\n height: 150px;\n width: 300px;\n position: relative;\n user-select: none;\n overflow: hidden;\n cursor: crosshair;\n`;\n\nexport const StyledColorAreaCanvas = styled.canvas`\n user-select: none;\n`;\n\nexport const StyledColorAreaPseudo = styled.div`\n position: absolute;\n top: -10px;\n left: -10px;\n touch-action: none;\n user-select: none;\n\n height: 170px;\n width: 320px;\n`;\n\nexport const StyledMotionColorAreaPointer = styled(motion.div)`\n position: absolute;\n border-radius: 100%;\n border: 2px solid white;\n width: 20px;\n height: 20px;\n box-shadow:\n 0 0 5px 0 rgba(0, 0, 0, 0.5),\n 0 0 3px 0 rgba(0, 0, 0, 0.5) inset;\n pointer-events: none;\n user-select: none;\n top: 0;\n left: 0;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAuC,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEhC,MAAMG,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAGE,yBAAM,CAACC,GAAG;AACzC;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,qBAAqB,GAAAH,OAAA,CAAAG,qBAAA,GAAGF,yBAAM,CAACG,MAAM;AAClD;AACA,CAAC;AAEM,MAAMC,qBAAqB,GAAAL,OAAA,CAAAK,qBAAA,GAAGJ,yBAAM,CAACC,GAAG;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMI,4BAA4B,GAAAN,OAAA,CAAAM,4BAAA,GAAG,IAAAL,yBAAM,EAACM,aAAM,CAACL,GAAG,CAAC;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
@@ -10,8 +10,7 @@ var _react = _interopRequireWildcard(require("react"));
10
10
  var _color = require("../../../utils/color");
11
11
  var _ColorPickerProvider = require("../../ColorPickerProvider");
12
12
  var _MoreOptions = require("./MoreOptions.styles");
13
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
15
14
  const MoreOptions = () => {
16
15
  const {
17
16
  selectedColor,