@dreamcommerce/aurora 2.6.7 → 2.6.8-1

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.
@@ -43,12 +43,14 @@ const useStyles = reactJss_esm.createUseStyles({
43
43
  }
44
44
  });
45
45
  const PureColorPicker = ({ hideChooseCancelButtons }) => {
46
+ var _a;
46
47
  const { color, setColor, initialColor, hueSliderPointer, saturationLightnessPointer, setHueSliderPointer, setSaturationLightnessPointer, screenName } = React.useContext(context.ColorPickerContext);
47
48
  const saturationLightnessPanelRef = React.useRef(null);
48
49
  const hueSliderRef = React.useRef(null);
49
50
  const classes = useStyles({ color, saturationLightnessPointer, hueSliderPointer, screenName });
50
51
  React.useEffect(() => {
51
- const initialColor = utilities.getColorFromHex(color.hex || '#ffffff');
52
+ var _a;
53
+ const initialColor = utilities.getColorFromHex((_a = color.hex) !== null && _a !== void 0 ? _a : '');
52
54
  setNewColorPickerPositions(initialColor);
53
55
  // eslint-disable-next-line react-hooks/exhaustive-deps
54
56
  }, []);
@@ -86,11 +88,11 @@ const PureColorPicker = ({ hideChooseCancelButtons }) => {
86
88
  React__default['default'].createElement("div", { className: `${classes.preview} ${main_module['default'][css_classes.cssColorPickerPreview]}` }),
87
89
  React__default['default'].createElement("div", { className: main_module['default'][css_classes.cssColorPickerInputContainer] },
88
90
  React__default['default'].createElement("span", null, "#"),
89
- React__default['default'].createElement(input['default'], { id: "color-picker-id", value: (color.hex || '').replace(/#/g, ''), onChange: inputOnChange }))),
91
+ React__default['default'].createElement(input['default'], { id: "color-picker-id", value: ((_a = color === null || color === void 0 ? void 0 : color.hex) !== null && _a !== void 0 ? _a : '').replace(/#/g, ''), onChange: inputOnChange }))),
90
92
  !hideChooseCancelButtons && React__default['default'].createElement(buttons['default'], { restoreInitialColor: restoreInitialColor })));
91
93
  };
92
94
  const ColorPickerWithContext = ({ initialColor, onChange, hideChooseCancelButtons, name }) => {
93
- const colorPickerContext = use_color_picker.useColorPicker({ initialColorHex: initialColor || '#ffffff', onChange });
95
+ const colorPickerContext = use_color_picker.useColorPicker({ initialColorHex: initialColor !== null && initialColor !== void 0 ? initialColor : '', onChange });
94
96
  return (React__default['default'].createElement(context.ColorPickerContext.Provider, { value: colorPickerContext },
95
97
  React__default['default'].createElement("input", { type: "hidden", name: name }),
96
98
  React__default['default'].createElement(PureColorPicker, { hideChooseCancelButtons: hideChooseCancelButtons })));
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,2BAA2B,yDAA6D;AACxF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,2BAA2B,yDAA6D;AACxF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -7,12 +7,12 @@ var constants = require('./constants.js');
7
7
  var use_screen_detect = require('../../hooks/use_screen_detect.js');
8
8
 
9
9
  const useColorPicker = ({ initialColorHex, onChange }) => {
10
- const [color, setColor] = React.useState({ hue: 0, saturation: constants.SATURATION_OFFSET, lightness: 100, hex: initialColorHex });
10
+ const [color, setColor] = React.useState({ hue: 0, saturation: constants.SATURATION_OFFSET, lightness: 100, hex: initialColorHex !== null && initialColorHex !== void 0 ? initialColorHex : '' });
11
11
  const [initialColor, setInitialColor] = React.useState({
12
12
  hue: 0,
13
13
  saturation: constants.SATURATION_OFFSET,
14
14
  lightness: 100,
15
- hex: initialColorHex
15
+ hex: initialColorHex !== null && initialColorHex !== void 0 ? initialColorHex : ''
16
16
  });
17
17
  const [hueSliderPointer, setHueSliderPointer] = React.useState({ top: 0, left: 0 });
18
18
  const [saturationLightnessPointer, setSaturationLightnessPointer] = React.useState({ left: 0, top: 0 });
@@ -21,7 +21,7 @@ const useColorPicker = ({ initialColorHex, onChange }) => {
21
21
  onChange === null || onChange === void 0 ? void 0 : onChange(color);
22
22
  }, [color]);
23
23
  React.useEffect(() => {
24
- setColor((prevState) => ({ ...prevState, hex: initialColorHex }));
24
+ setColor((prevState) => ({ ...prevState, hex: initialColorHex !== null && initialColorHex !== void 0 ? initialColorHex : '' }));
25
25
  }, [initialColorHex]);
26
26
  return {
27
27
  color,
@@ -28,7 +28,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
28
28
  * />
29
29
  * )
30
30
  */
31
- const ControlColorPicker = ({ initialColor = '#FFFFFF', name, isRequired, label: label$1, id, onChange, hideChooseCancelButtons, errors, hint, labelAdditionalInfo }) => {
31
+ const ControlColorPicker = ({ initialColor, name, isRequired, label: label$1, id, onChange, hideChooseCancelButtons, errors, hint, labelAdditionalInfo }) => {
32
32
  const colorPickerContext = use_color_picker.useColorPicker({ initialColorHex: initialColor, onChange });
33
33
  return (React__default['default'].createElement(context.ColorPickerContext.Provider, { value: colorPickerContext },
34
34
  React__default['default'].createElement(index$1['default'], null,
@@ -35,12 +35,14 @@ const useStyles = createUseStyles({
35
35
  }
36
36
  });
37
37
  const PureColorPicker = ({ hideChooseCancelButtons }) => {
38
+ var _a;
38
39
  const { color, setColor, initialColor, hueSliderPointer, saturationLightnessPointer, setHueSliderPointer, setSaturationLightnessPointer, screenName } = useContext(ColorPickerContext);
39
40
  const saturationLightnessPanelRef = useRef(null);
40
41
  const hueSliderRef = useRef(null);
41
42
  const classes = useStyles({ color, saturationLightnessPointer, hueSliderPointer, screenName });
42
43
  useEffect(() => {
43
- const initialColor = getColorFromHex(color.hex || '#ffffff');
44
+ var _a;
45
+ const initialColor = getColorFromHex((_a = color.hex) !== null && _a !== void 0 ? _a : '');
44
46
  setNewColorPickerPositions(initialColor);
45
47
  // eslint-disable-next-line react-hooks/exhaustive-deps
46
48
  }, []);
@@ -78,11 +80,11 @@ const PureColorPicker = ({ hideChooseCancelButtons }) => {
78
80
  React.createElement("div", { className: `${classes.preview} ${styles[cssColorPickerPreview]}` }),
79
81
  React.createElement("div", { className: styles[cssColorPickerInputContainer] },
80
82
  React.createElement("span", null, "#"),
81
- React.createElement(Input, { id: "color-picker-id", value: (color.hex || '').replace(/#/g, ''), onChange: inputOnChange }))),
83
+ React.createElement(Input, { id: "color-picker-id", value: ((_a = color === null || color === void 0 ? void 0 : color.hex) !== null && _a !== void 0 ? _a : '').replace(/#/g, ''), onChange: inputOnChange }))),
82
84
  !hideChooseCancelButtons && React.createElement(ColorPickerButtons, { restoreInitialColor: restoreInitialColor })));
83
85
  };
84
86
  const ColorPickerWithContext = ({ initialColor, onChange, hideChooseCancelButtons, name }) => {
85
- const colorPickerContext = useColorPicker({ initialColorHex: initialColor || '#ffffff', onChange });
87
+ const colorPickerContext = useColorPicker({ initialColorHex: initialColor !== null && initialColor !== void 0 ? initialColor : '', onChange });
86
88
  return (React.createElement(ColorPickerContext.Provider, { value: colorPickerContext },
87
89
  React.createElement("input", { type: "hidden", name: name }),
88
90
  React.createElement(PureColorPicker, { hideChooseCancelButtons: hideChooseCancelButtons })));
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA,gCAAgC,yDAA6D;AAC7F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA,gCAAgC,yDAA6D;AAC7F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -1,48 +1,5 @@
1
- /// <reference types="react" />
2
- import { IColor } from "./types";
1
+ import { IColor, IColorPickerContextProps } from "./types";
3
2
  export declare const useColorPicker: ({ initialColorHex, onChange }: {
4
- initialColorHex: string;
3
+ initialColorHex: string | undefined;
5
4
  onChange?: ((color: IColor) => void) | undefined;
6
- }) => {
7
- color: {
8
- hue: number;
9
- saturation: number;
10
- lightness: number;
11
- hex: string;
12
- };
13
- setColor: import("react").Dispatch<import("react").SetStateAction<{
14
- hue: number;
15
- saturation: number;
16
- lightness: number;
17
- hex: string;
18
- }>>;
19
- initialColor: {
20
- hue: number;
21
- saturation: number;
22
- lightness: number;
23
- hex: string;
24
- };
25
- setInitialColor: import("react").Dispatch<import("react").SetStateAction<{
26
- hue: number;
27
- saturation: number;
28
- lightness: number;
29
- hex: string;
30
- }>>;
31
- hueSliderPointer: {
32
- top: number;
33
- left: number;
34
- };
35
- setHueSliderPointer: import("react").Dispatch<import("react").SetStateAction<{
36
- top: number;
37
- left: number;
38
- }>>;
39
- screenName: string;
40
- saturationLightnessPointer: {
41
- left: number;
42
- top: number;
43
- };
44
- setSaturationLightnessPointer: import("react").Dispatch<import("react").SetStateAction<{
45
- left: number;
46
- top: number;
47
- }>>;
48
- };
5
+ }) => IColorPickerContextProps;
@@ -3,12 +3,12 @@ import { SATURATION_OFFSET } from './constants.js';
3
3
  import { useScreenDetect } from '../../hooks/use_screen_detect.js';
4
4
 
5
5
  const useColorPicker = ({ initialColorHex, onChange }) => {
6
- const [color, setColor] = useState({ hue: 0, saturation: SATURATION_OFFSET, lightness: 100, hex: initialColorHex });
6
+ const [color, setColor] = useState({ hue: 0, saturation: SATURATION_OFFSET, lightness: 100, hex: initialColorHex !== null && initialColorHex !== void 0 ? initialColorHex : '' });
7
7
  const [initialColor, setInitialColor] = useState({
8
8
  hue: 0,
9
9
  saturation: SATURATION_OFFSET,
10
10
  lightness: 100,
11
- hex: initialColorHex
11
+ hex: initialColorHex !== null && initialColorHex !== void 0 ? initialColorHex : ''
12
12
  });
13
13
  const [hueSliderPointer, setHueSliderPointer] = useState({ top: 0, left: 0 });
14
14
  const [saturationLightnessPointer, setSaturationLightnessPointer] = useState({ left: 0, top: 0 });
@@ -17,7 +17,7 @@ const useColorPicker = ({ initialColorHex, onChange }) => {
17
17
  onChange === null || onChange === void 0 ? void 0 : onChange(color);
18
18
  }, [color]);
19
19
  useEffect(() => {
20
- setColor((prevState) => ({ ...prevState, hex: initialColorHex }));
20
+ setColor((prevState) => ({ ...prevState, hex: initialColorHex !== null && initialColorHex !== void 0 ? initialColorHex : '' }));
21
21
  }, [initialColorHex]);
22
22
  return {
23
23
  color,
@@ -20,7 +20,7 @@ import ColorPickerLabel from '../../../color_picker/components/label.js';
20
20
  * />
21
21
  * )
22
22
  */
23
- const ControlColorPicker = ({ initialColor = '#FFFFFF', name, isRequired, label, id, onChange, hideChooseCancelButtons, errors, hint, labelAdditionalInfo }) => {
23
+ const ControlColorPicker = ({ initialColor, name, isRequired, label, id, onChange, hideChooseCancelButtons, errors, hint, labelAdditionalInfo }) => {
24
24
  const colorPickerContext = useColorPicker({ initialColorHex: initialColor, onChange });
25
25
  return (React.createElement(ColorPickerContext.Provider, { value: colorPickerContext },
26
26
  React.createElement(Dropdown, null,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@dreamcommerce/aurora",
3
3
  "packageManager": "yarn@3.2.0",
4
4
  "sideEffects": false,
5
- "version": "2.6.7",
5
+ "version": "2.6.8-1",
6
6
  "description": "aurora",
7
7
  "author": "k0ssak",
8
8
  "license": "MIT",