@hitachivantara/uikit-react-core 6.0.0-next.4 → 6.0.0-next.6

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.
@@ -1,6 +1,5 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { ClickAwayListener } from "@mui/base/ClickAwayListener";
3
- import { Portal } from "@mui/base/Portal";
2
+ import { Portal, ClickAwayListener } from "@mui/base";
4
3
  import { useCss, useTheme } from "@hitachivantara/uikit-react-utils";
5
4
  import { getContainerElement } from "../utils/document.js";
6
5
  import { useBaseDropdownContext } from "./context.js";
@@ -9,8 +9,8 @@ import { HvIcon } from "../icons.js";
9
9
  import { setId } from "../utils/setId.js";
10
10
  import { useClasses } from "./ColorPicker.styles.js";
11
11
  import { staticClasses } from "./ColorPicker.styles.js";
12
- import { PresetColors } from "./PresetColors/PresetColors.js";
13
12
  import { Picker } from "./Picker/Picker.js";
13
+ import { PresetColors } from "./PresetColors/PresetColors.js";
14
14
  import { SavedColors } from "./SavedColors/SavedColors.js";
15
15
  import { HvFormElement } from "../FormElement/FormElement.js";
16
16
  import { HvBaseDropdown } from "../BaseDropdown/BaseDropdown.js";
@@ -81,18 +81,18 @@ const HvColorPicker = forwardRef(
81
81
  const handleToggle = (_, open) => {
82
82
  setIsOpen(open);
83
83
  };
84
- const handleSelect = (val) => {
85
- onChange?.(val.hex);
86
- onChangeComplete?.(val.hex);
87
- setColor(val.hex);
84
+ const handleSelect = (hex) => {
85
+ onChange?.(hex);
86
+ onChangeComplete?.(hex);
87
+ setColor(hex);
88
88
  };
89
- const handleOnChange = (val) => {
90
- onChange?.(val.hex);
91
- setColor(val.hex);
89
+ const handleOnChange = (hex) => {
90
+ onChange?.(hex);
91
+ setColor(hex);
92
92
  };
93
- const handleOnChangeComplete = (val) => {
94
- onChangeComplete?.(val.hex);
95
- setColor(val.hex);
93
+ const handleOnChangeComplete = (hex) => {
94
+ onChangeComplete?.(hex);
95
+ setColor(hex);
96
96
  };
97
97
  const handleAddColor = () => {
98
98
  const colorToAdd = color || "#000000";
@@ -157,7 +157,7 @@ const HvColorPicker = forwardRef(
157
157
  classes.headerColorIconOnly
158
158
  )
159
159
  }
160
- ) : dropdownIcon === "colorPicker" ? /* @__PURE__ */ jsx(HvIcon, { name: "ColorPicker", className: classes.colorPickerIcon }) : void 0,
160
+ ) : dropdownIcon === "colorPicker" ? /* @__PURE__ */ jsx(HvIcon, { name: "ColorPicker" }) : void 0,
161
161
  placeholder: iconOnly ? void 0 : color ? /* @__PURE__ */ jsxs(Fragment, { children: [
162
162
  /* @__PURE__ */ jsx(
163
163
  "div",
@@ -178,11 +178,10 @@ const HvColorPicker = forwardRef(
178
178
  "aria-label": ariaLabel,
179
179
  "aria-labelledby": [label && setId(elementId, "label"), ariaLabelledBy].join(" ").trim() || void 0,
180
180
  "aria-describedby": [description && setId(elementId, "description"), ariaDescribedBy].join(" ").trim() || void 0,
181
- children: /* @__PURE__ */ jsx(HvPanel, { className: classes.panel, children: /* @__PURE__ */ jsxs("div", { className: classes.colorPicker, children: [
181
+ children: /* @__PURE__ */ jsxs(HvPanel, { className: cx(classes.panel, classes.colorPicker), children: [
182
182
  recommendedColorsPosition === "top" && /* @__PURE__ */ jsx(
183
183
  PresetColors,
184
184
  {
185
- className: classes.recommendedColorsRoot,
186
185
  colors: recommendedColors,
187
186
  onClick: handleSelect,
188
187
  title: showLabels ? labels.recommendedColorsLabel : void 0
@@ -191,13 +190,8 @@ const HvColorPicker = forwardRef(
191
190
  showCustomColors && /* @__PURE__ */ jsx(
192
191
  Picker,
193
192
  {
194
- classes: {
195
- fields: cx({
196
- [classes.pickerFields]: recommendedColorsPosition === "bottom" || showSavedColors
197
- })
198
- },
199
193
  title: showLabels ? labels.customColorsLabel : void 0,
200
- color,
194
+ hex: color,
201
195
  onChange: handleOnChange,
202
196
  onChangeComplete: handleOnChangeComplete
203
197
  }
@@ -221,7 +215,7 @@ const HvColorPicker = forwardRef(
221
215
  title: showLabels ? labels.recommendedColorsLabel : void 0
222
216
  }
223
217
  )
224
- ] }) })
218
+ ] })
225
219
  }
226
220
  )
227
221
  ]
@@ -1,4 +1,5 @@
1
1
  import { createClasses } from "@hitachivantara/uikit-react-utils";
2
+ import { theme } from "@hitachivantara/uikit-styles";
2
3
  const { staticClasses, useClasses } = createClasses("HvColorPicker", {
3
4
  root: {},
4
5
  labelContainer: {},
@@ -19,19 +20,14 @@ const { staticClasses, useClasses } = createClasses("HvColorPicker", {
19
20
  width: "100%",
20
21
  minWidth: "266px",
21
22
  display: "flex",
23
+ flexDirection: "column",
24
+ gap: theme.space.md,
22
25
  justifyContent: "center",
23
26
  padding: "16px",
24
27
  backgroundColor: "transparent"
25
28
  },
26
- colorPicker: {
27
- width: "232px"
28
- },
29
+ colorPicker: {},
29
30
  colorPickerIcon: {},
30
- recommendedColorsRoot: {
31
- ":not(:only-child)": {
32
- paddingBottom: "24px"
33
- }
34
- },
35
31
  dropdownRootIconOnly: {
36
32
  "&,& .HvBaseDropdown-arrowContainer": {
37
33
  width: 32,
@@ -43,8 +39,7 @@ const { staticClasses, useClasses } = createClasses("HvColorPicker", {
43
39
  },
44
40
  headerColorIconOnly: {
45
41
  margin: 8
46
- },
47
- pickerFields: { paddingBottom: 20 }
42
+ }
48
43
  });
49
44
  export {
50
45
  staticClasses,
@@ -1,18 +1,47 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useState, useRef, useEffect } from "react";
3
- import * as color from "react-color/lib/helpers/color";
4
- import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
5
- import { useClasses } from "./Fields.styles.js";
2
+ import { useMemo, useState, useRef, useEffect } from "react";
3
+ import { hexToRgba, validHex, rgbToHex } from "@uiw/color-convert";
4
+ import { useDefaultProps, createClasses } from "@hitachivantara/uikit-react-utils";
5
+ import { theme } from "@hitachivantara/uikit-styles";
6
6
  import { HvInput } from "../../Input/Input.js";
7
+ const { useClasses } = createClasses("HvColorPickerFields", {
8
+ root: {
9
+ width: "100%",
10
+ display: "flex",
11
+ gap: theme.space.xxs
12
+ },
13
+ single: {
14
+ maxWidth: "50px",
15
+ "& input": {
16
+ marginLeft: 5,
17
+ marginRight: 5
18
+ },
19
+ "& label": {
20
+ paddingLeft: 5
21
+ }
22
+ },
23
+ double: {
24
+ maxWidth: "82px",
25
+ paddingRight: theme.space.xxs,
26
+ "& input": {
27
+ textTransform: "uppercase",
28
+ marginLeft: 5,
29
+ marginRight: 5
30
+ },
31
+ "& label": {
32
+ paddingLeft: 5
33
+ }
34
+ }
35
+ });
7
36
  const Fields = (props) => {
8
37
  const {
9
38
  className,
10
39
  onChange,
11
- rgb,
12
40
  hex,
13
41
  classes: classesProp
14
42
  } = useDefaultProps("HvColorPickerFields", props);
15
43
  const { classes, cx } = useClasses(classesProp);
44
+ const rgb = useMemo(() => hexToRgba(hex), [hex]);
16
45
  const [internalHex, setInternalHex] = useState(hex);
17
46
  const [internalRed, setInternalRed] = useState(rgb?.r);
18
47
  const [internalGreen, setInternalGreen] = useState(rgb?.g);
@@ -37,45 +66,23 @@ const Fields = (props) => {
37
66
  setInternalBlue(rgb?.b);
38
67
  }
39
68
  }, [rgb]);
40
- const handleChange = (data, event) => {
41
- if (data.hex && color.isValidHex(data.hex)) {
42
- onChange(
43
- {
44
- hex: data.hex,
45
- source: "hex"
46
- },
47
- event
48
- );
49
- } else if (data.r !== void 0 || data.g !== void 0 || data.b !== void 0) {
50
- onChange(
51
- {
52
- r: data.r ?? rgb?.r,
53
- g: data.g ?? rgb?.g,
54
- b: data.b ?? rgb?.b,
55
- source: "rgb"
56
- },
57
- event
58
- );
59
- }
60
- };
61
- const onChangeHex = (event, value) => {
62
- setInternalHex(value);
63
- handleChange({ hex: value }, event);
69
+ const handleChange = (hex2) => {
70
+ if (!validHex(hex2)) return;
71
+ onChange?.(hex2);
64
72
  };
65
- const onChangeRbg = (event, value, colorPart) => {
66
- if (colorPart === "r") setInternalRed(Number(value));
67
- if (colorPart === "g") setInternalGreen(Number(value));
68
- if (colorPart === "b") setInternalBlue(Number(value));
73
+ const onChangeRbg = ({ r, g, b }) => {
74
+ if (r) setInternalRed(Number(r));
75
+ if (g) setInternalGreen(Number(g));
76
+ if (b) setInternalBlue(Number(b));
69
77
  handleChange(
70
- {
71
- r: colorPart === "r" ? Number(value) : rgb?.r,
72
- g: colorPart === "g" ? Number(value) : rgb?.g,
73
- b: colorPart === "b" ? Number(value) : rgb?.b
74
- },
75
- event
78
+ rgbToHex({
79
+ r: r ? Number(r) : rgb?.r,
80
+ g: g ? Number(g) : rgb?.g,
81
+ b: b ? Number(b) : rgb?.b
82
+ })
76
83
  );
77
84
  };
78
- return /* @__PURE__ */ jsxs("div", { className: cx(classes.fields, className), children: [
85
+ return /* @__PURE__ */ jsxs("div", { className: cx(classes.root, className), children: [
79
86
  /* @__PURE__ */ jsx(
80
87
  HvInput,
81
88
  {
@@ -83,7 +90,10 @@ const Fields = (props) => {
83
90
  className: classes.double,
84
91
  label: "HEX",
85
92
  value: internalHex?.replace("#", ""),
86
- onChange: onChangeHex,
93
+ onChange: (event, value) => {
94
+ setInternalHex(value);
95
+ handleChange(value);
96
+ },
87
97
  onBlur: () => setInternalHex(hex),
88
98
  disableClear: true
89
99
  }
@@ -95,7 +105,7 @@ const Fields = (props) => {
95
105
  className: classes.single,
96
106
  label: "R",
97
107
  value: internalRed,
98
- onChange: (event, value) => onChangeRbg(event, value, "r"),
108
+ onChange: (event, value) => onChangeRbg({ r: value }),
99
109
  onBlur: () => setInternalRed(rgb?.r),
100
110
  inputProps: { type: "number", min: 0, max: 255 },
101
111
  disableClear: true
@@ -108,7 +118,7 @@ const Fields = (props) => {
108
118
  className: classes.single,
109
119
  label: "G",
110
120
  value: internalGreen,
111
- onChange: (event, value) => onChangeRbg(event, value, "g"),
121
+ onChange: (event, value) => onChangeRbg({ g: value }),
112
122
  onBlur: () => setInternalGreen(rgb?.g),
113
123
  inputProps: { type: "number", min: 0, max: 255 },
114
124
  disableClear: true
@@ -121,7 +131,7 @@ const Fields = (props) => {
121
131
  className: classes.single,
122
132
  label: "B",
123
133
  value: internalBlue,
124
- onChange: (event, value) => onChangeRbg(event, value, "b"),
134
+ onChange: (event, value) => onChangeRbg({ b: value }),
125
135
  onBlur: () => setInternalBlue(rgb?.b),
126
136
  inputProps: { type: "number", min: 0, max: 255 },
127
137
  disableClear: true
@@ -1,64 +1,55 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { useCallback } from "react";
3
- import { CustomPicker } from "react-color";
4
- import { Saturation, Hue } from "react-color/lib/components/common";
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { hexToHsva, hsvaToHex } from "@uiw/color-convert";
4
+ import Hue from "@uiw/react-color-hue";
5
+ import Saturation from "@uiw/react-color-saturation";
5
6
  import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
7
+ import { Fields } from "./Fields.js";
6
8
  import { useClasses } from "./Picker.styles.js";
7
- import { Fields } from "../Fields/Fields.js";
8
9
  import { HvTypography } from "../../Typography/Typography.js";
9
- const Component = (props) => {
10
+ const Picker = (props) => {
10
11
  const {
12
+ hex: hexProp,
11
13
  onChange,
12
- rgb,
13
- hsl,
14
- hsv,
15
- hex,
14
+ onChangeComplete,
16
15
  title,
17
16
  classes: classesProp
18
17
  } = useDefaultProps("HvColorPickerPicker", props);
19
18
  const { classes } = useClasses(classesProp);
20
- const SaturationPointer = useCallback(
21
- () => /* @__PURE__ */ jsx("div", { className: classes?.saturationPointer }),
22
- [classes?.saturationPointer]
23
- );
24
- const HueSlider = useCallback(
25
- () => /* @__PURE__ */ jsx("div", { className: classes?.hueSlider }),
26
- [classes?.hueSlider]
27
- );
28
- return /* @__PURE__ */ jsxs(Fragment, { children: [
19
+ const hex = hexProp || "#000000";
20
+ const hsva = useMemo(() => hexToHsva(hex), [hex]);
21
+ return /* @__PURE__ */ jsxs("div", { className: classes.root, children: [
29
22
  title && /* @__PURE__ */ jsx(HvTypography, { className: classes.title, variant: "caption1", children: title }),
30
23
  /* @__PURE__ */ jsxs("div", { className: classes.pickers, children: [
31
- /* @__PURE__ */ jsx("div", { className: classes.saturation, children: /* @__PURE__ */ jsx(
24
+ /* @__PURE__ */ jsx(
32
25
  Saturation,
33
26
  {
34
- hsl,
35
- hsv,
36
- onChange,
37
- pointer: SaturationPointer
27
+ className: classes.saturation,
28
+ hsva,
29
+ onChange: (newColor) => {
30
+ const newHex = hsvaToHex(newColor);
31
+ onChange?.(newHex);
32
+ onChangeComplete?.(newHex);
33
+ }
38
34
  }
39
- ) }),
40
- /* @__PURE__ */ jsx("div", { className: classes.hue, children: /* @__PURE__ */ jsx(
35
+ ),
36
+ /* @__PURE__ */ jsx(
41
37
  Hue,
42
38
  {
39
+ className: classes.hue,
43
40
  direction: "horizontal",
44
- hsl,
45
- onChange,
46
- pointer: HueSlider
41
+ hue: hsva.h,
42
+ onChange: ({ h }) => {
43
+ const newHex = hsvaToHex({ ...hsva, h });
44
+ onChange?.(newHex);
45
+ onChangeComplete?.(newHex);
46
+ }
47
47
  }
48
- ) })
49
- ] }),
50
- /* @__PURE__ */ jsx(
51
- Fields,
52
- {
53
- className: classes.fields,
54
- rgb,
55
- hex,
56
- onChange
57
- }
58
- )
48
+ ),
49
+ /* @__PURE__ */ jsx(Fields, { hex, onChange })
50
+ ] })
59
51
  ] });
60
52
  };
61
- const Picker = CustomPicker(Component);
62
53
  export {
63
54
  Picker
64
55
  };
@@ -1,59 +1,43 @@
1
1
  import { createClasses } from "@hitachivantara/uikit-react-utils";
2
2
  import { theme } from "@hitachivantara/uikit-styles";
3
3
  const { useClasses } = createClasses("HvColorPickerPicker", {
4
+ root: {},
4
5
  pickers: {
5
6
  display: "flex",
6
- flexDirection: "column"
7
+ flexDirection: "column",
8
+ gap: theme.space.sm
7
9
  },
8
10
  saturation: {
9
- width: "232px",
10
- height: "140px",
11
- marginRight: "0px",
11
+ width: "232px !important",
12
+ height: "140px !important",
12
13
  position: "relative",
13
14
  overflow: "visible",
14
- "& > div": {
15
- borderRadius: theme.radii.base,
16
- "& .saturation-white": {
17
- borderRadius: theme.radii.base,
18
- "& .saturation-black": {
19
- borderRadius: theme.radii.base
20
- }
21
- }
15
+ "& .w-color-saturation-fill": {
16
+ width: "8px !important",
17
+ height: "8px !important",
18
+ boxShadow: `0 0 0 2px #fff, inset 0 0 1px 1px rgba(0,0,0,.3),0 0 1px 2px rgba(0,0,0,.4) !important`
22
19
  }
23
20
  },
24
- saturationPointer: {
25
- width: "8px",
26
- height: "8px",
27
- boxShadow: `0 0 0 2px #fff, inset 0 0 1px 1px rgba(0,0,0,.3),
28
- 0 0 1px 2px rgba(0,0,0,.4)`,
29
- borderRadius: theme.radii.full,
30
- transform: "translate(-3px, -3px)"
31
- },
32
21
  hue: {
33
- height: "8px",
34
- width: "232px",
22
+ height: "8px !important",
23
+ width: "232px !important",
35
24
  position: "relative",
36
25
  overflow: "visible",
37
- marginTop: "18px",
38
- "& .hue-horizontal": {
39
- borderRadius: `calc(2*${theme.radii.base})`
26
+ "& .w-color-alpha-fill": {
27
+ width: "12px !important",
28
+ height: "12px !important",
29
+ backgroundColor: "transparent !important",
30
+ boxShadow: "0 0 2px rgb(0 0 0 / 60%)",
31
+ marginLeft: "0px",
32
+ border: "2px solid #fff",
33
+ borderRadius: theme.radii.full,
34
+ transform: "translate(-6px, -2px) !important"
40
35
  }
41
36
  },
42
- hueSlider: {
43
- width: "12px",
44
- height: "12px",
45
- background: "transparent",
46
- boxShadow: "0 0 2px rgb(0 0 0 / 60%)",
47
- marginLeft: "0px",
48
- border: "2px solid #fff",
49
- borderRadius: theme.radii.full,
50
- transform: "translate(-6px, -2px)"
51
- },
52
37
  title: {
53
38
  fontWeight: theme.fontWeights.semibold,
54
39
  marginBottom: 8
55
- },
56
- fields: {}
40
+ }
57
41
  });
58
42
  export {
59
43
  useClasses
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { Swatch } from "react-color/lib/components/common";
3
2
  import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
4
3
  import { getColor } from "@hitachivantara/uikit-styles";
4
+ import { Swatch } from "../Swatch.js";
5
5
  import { useClasses } from "./PresetColors.styles.js";
6
6
  import { HvTypography } from "../../Typography/Typography.js";
7
7
  const PresetColors = (props) => {
@@ -13,29 +13,14 @@ const PresetColors = (props) => {
13
13
  classes: classesProp
14
14
  } = useDefaultProps("HvColorPickerPresetColors", props);
15
15
  const { classes, cx } = useClasses(classesProp);
16
- const handleClick = (hex) => {
17
- onClick({
18
- hex,
19
- source: "hex"
20
- });
21
- };
22
16
  return /* @__PURE__ */ jsxs("div", { className: cx(classes.root, className), children: [
23
17
  title && /* @__PURE__ */ jsx(HvTypography, { className: classes.title, variant: "caption1", children: title }),
24
18
  /* @__PURE__ */ jsx("div", { className: classes.colors, children: colors.map((color, index) => /* @__PURE__ */ jsx(
25
- "div",
19
+ Swatch,
26
20
  {
27
- className: classes.swatchWrap,
28
- children: /* @__PURE__ */ jsx(
29
- Swatch,
30
- {
31
- color,
32
- style: { backgroundColor: getColor(color) },
33
- onClick: handleClick,
34
- focusStyle: {
35
- boxShadow: `inset 0 0 0 1px rgba(0,0,0,.15), 0 0 4px ${color}`
36
- }
37
- }
38
- )
21
+ color,
22
+ style: { backgroundColor: getColor(color) },
23
+ onClick: () => onClick(color)
39
24
  },
40
25
  `recommended-color-${color}-${index}`
41
26
  )) })
@@ -6,21 +6,12 @@ const { useClasses } = createClasses("HvColorPickerPresetColors", {
6
6
  display: "flex",
7
7
  flexWrap: "wrap",
8
8
  position: "relative",
9
- width: "calc(100% + 8px)",
10
- margin: "-4px -4px",
9
+ gap: theme.space.xs,
11
10
  padding: 0
12
11
  },
13
12
  title: {
14
13
  fontWeight: theme.fontWeights.semibold,
15
14
  marginBottom: 8
16
- },
17
- swatchWrap: {
18
- width: "32px",
19
- height: "32px",
20
- margin: theme.space.xxs,
21
- "& > span > div": {
22
- borderRadius: theme.radii.base
23
- }
24
15
  }
25
16
  });
26
17
  export {
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { Swatch } from "react-color/lib/components/common";
3
2
  import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
4
3
  import { HvIcon } from "../../icons.js";
4
+ import { Swatch } from "../Swatch.js";
5
5
  import { useClasses } from "./SavedColors.styles.js";
6
6
  import { HvIconButton } from "../../IconButton/IconButton.js";
7
7
  const SavedColors = (props) => {
@@ -15,52 +15,29 @@ const SavedColors = (props) => {
15
15
  classes: classesProp
16
16
  } = useDefaultProps("HvColorPickerSavedColors", props);
17
17
  const { classes } = useClasses(classesProp);
18
- const handleClick = (hex) => {
19
- onClickColor({
20
- hex,
21
- source: "hex"
22
- });
23
- };
24
18
  return /* @__PURE__ */ jsxs("div", { className: classes.root, children: [
25
19
  /* @__PURE__ */ jsx(
26
20
  HvIconButton,
27
21
  {
28
- className: classes.addButton,
29
22
  variant: "secondarySubtle",
30
23
  onClick: onAddColor,
31
24
  title: addButtonAriaLabel,
32
25
  children: /* @__PURE__ */ jsx(HvIcon, { name: "Add", compact: true })
33
26
  }
34
27
  ),
35
- colors.map((color, index) => /* @__PURE__ */ jsxs(
36
- "div",
37
- {
38
- className: classes.swatchRoot,
39
- children: [
40
- /* @__PURE__ */ jsx("div", { className: classes.swatchWrap, children: /* @__PURE__ */ jsx(
41
- Swatch,
42
- {
43
- color,
44
- onClick: handleClick,
45
- focusStyle: {
46
- boxShadow: `inset 0 0 0 1px rgba(0,0,0,.15), 0 0 4px ${color}`
47
- }
48
- }
49
- ) }),
50
- /* @__PURE__ */ jsx("div", { className: classes.removeButtonRoot, children: /* @__PURE__ */ jsx(
51
- HvIconButton,
52
- {
53
- className: classes.removeButton,
54
- variant: "secondarySubtle",
55
- onClick: () => onRemoveColor(color, index),
56
- title: deleteButtonAriaLabel,
57
- children: /* @__PURE__ */ jsx(HvIcon, { name: "Close", compact: true, size: "xs" })
58
- }
59
- ) })
60
- ]
61
- },
62
- `saved-color-${color}-${index}`
63
- ))
28
+ [...new Set(colors)].map((color, index) => /* @__PURE__ */ jsxs("div", { className: classes.swatchRoot, children: [
29
+ /* @__PURE__ */ jsx(Swatch, { color, onClick: () => onClickColor(color) }),
30
+ /* @__PURE__ */ jsx(
31
+ HvIconButton,
32
+ {
33
+ className: classes.removeButton,
34
+ variant: "secondarySubtle",
35
+ onClick: () => onRemoveColor(color, index),
36
+ title: deleteButtonAriaLabel,
37
+ children: /* @__PURE__ */ jsx(HvIcon, { name: "Close", compact: true, size: "xs" })
38
+ }
39
+ )
40
+ ] }, color))
64
41
  ] });
65
42
  };
66
43
  export {
@@ -1,44 +1,29 @@
1
1
  import { createClasses } from "@hitachivantara/uikit-react-utils";
2
2
  import { theme } from "@hitachivantara/uikit-styles";
3
3
  const { useClasses } = createClasses("HvColorPickerSavedColors", {
4
- addButton: {
5
- margin: theme.space.xxs,
6
- width: "32px",
7
- height: "32px"
8
- },
9
4
  root: {
10
5
  display: "flex",
11
6
  flexWrap: "wrap",
12
7
  position: "relative",
13
- alignItems: "center",
14
- padding: 0,
15
- width: "calc(100% + 8px)",
16
- margin: "-4px -4px"
8
+ gap: theme.space.xs,
9
+ alignItems: "center"
17
10
  },
18
- swatchRoot: { position: "relative" },
19
- swatchWrap: {
20
- width: "32px",
21
- height: "32px",
22
- margin: theme.space.xxs,
23
- "& > span > div": {
24
- borderRadius: theme.radii.base
25
- }
11
+ swatchRoot: {
12
+ position: "relative",
13
+ height: 32
26
14
  },
27
- removeButtonRoot: {
15
+ removeButton: {
28
16
  position: "absolute",
29
17
  top: 0,
30
18
  right: 0,
19
+ transform: "translate(25%, -25%)",
31
20
  display: "flex",
32
21
  justifyContent: "center",
33
22
  alignItems: "center",
34
- height: 16,
35
- width: 16,
36
- background: theme.colors.bgContainer,
37
- borderRadius: theme.radii.base
38
- },
39
- removeButton: {
40
23
  height: 16,
41
24
  width: 16
25
+ // background: theme.colors.bgContainer,
26
+ // borderRadius: theme.radii.base,
42
27
  }
43
28
  });
44
29
  export {
@@ -0,0 +1,39 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useDefaultProps, createClasses, mergeStyles } from "@hitachivantara/uikit-react-utils";
3
+ import { theme } from "@hitachivantara/uikit-styles";
4
+ import { HvButtonBase } from "../ButtonBase/ButtonBase.js";
5
+ const { useClasses } = createClasses("HvColorPickerSwatch", {
6
+ root: {
7
+ width: "32px",
8
+ height: "32px",
9
+ borderRadius: theme.radii.base,
10
+ ":focus": {
11
+ boxShadow: `rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset, var(--color) 0px 0px 4px`
12
+ },
13
+ "&,&:hover,&:focus-visible": {
14
+ backgroundColor: "var(--color)"
15
+ }
16
+ }
17
+ });
18
+ const Swatch = (props) => {
19
+ const {
20
+ classes: classesProp,
21
+ className,
22
+ style,
23
+ color,
24
+ ...others
25
+ } = useDefaultProps("HvColorPickerSwatch", props);
26
+ const { classes, cx } = useClasses(classesProp);
27
+ return /* @__PURE__ */ jsx(
28
+ HvButtonBase,
29
+ {
30
+ title: color,
31
+ style: mergeStyles(style, { "--color": color }),
32
+ className: cx(classes.root, className),
33
+ ...others
34
+ }
35
+ );
36
+ };
37
+ export {
38
+ Swatch
39
+ };
@@ -1,7 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { forwardRef, useContext, useRef } from "react";
3
- import { ClickAwayListener } from "@mui/base/ClickAwayListener";
4
- import { Popper } from "@mui/base/Popper";
3
+ import { ClickAwayListener, Popper } from "@mui/base";
5
4
  import { useForkRef } from "@mui/material/utils";
6
5
  import { useDefaultProps, useTheme } from "@hitachivantara/uikit-react-utils";
7
6
  import { getContainerElement } from "../../utils/document.js";
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useRef } from "react";
3
- import { useOption } from "@mui/base/useOption";
3
+ import { useOption } from "@mui/base";
4
4
  import { useForkRef } from "@mui/material/utils";
5
5
  import { createClasses, useDefaultProps } from "@hitachivantara/uikit-react-utils";
6
6
  import { fixedForwardRef } from "../types/generic.js";
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
- import { OptionGroup } from "@mui/base/OptionGroup";
3
+ import { OptionGroup } from "@mui/base";
4
4
  import { createClasses, useDefaultProps } from "@hitachivantara/uikit-react-utils";
5
5
  import { theme } from "@hitachivantara/uikit-styles";
6
6
  const { staticClasses, useClasses } = createClasses("HvOptionGroup", {
@@ -1,7 +1,6 @@
1
1
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import { useState, useRef } from "react";
3
- import { Popper } from "@mui/base/Popper";
4
- import { useSelect, SelectProvider } from "@mui/base/useSelect";
3
+ import { useSelect, Popper, SelectProvider } from "@mui/base";
5
4
  import { useForkRef, useControlled } from "@mui/material/utils";
6
5
  import { clsx } from "clsx";
7
6
  import { useDefaultProps, useTheme } from "@hitachivantara/uikit-react-utils";
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { useSlotProps } from "@mui/base/utils";
2
+ import { useSlotProps } from "@mui/base";
3
3
  import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
4
4
  import { HvIcon } from "../icons.js";
5
5
  import { fixedForwardRef } from "../types/generic.js";
@@ -1,6 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { Popper } from "@mui/base/Popper";
3
- import ClickAwayListener from "@mui/material/ClickAwayListener";
2
+ import { Popper, ClickAwayListener } from "@mui/base";
4
3
  import { useTheme } from "@hitachivantara/uikit-react-utils";
5
4
  import { getContainerElement } from "../../utils/document.js";
6
5
  import { HvVerticalNavigation } from "../VerticalNavigation.js";
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ import { CardHeaderProps } from '@mui/material/CardHeader';
6
6
  import { CardMediaProps } from '@mui/material/CardMedia';
7
7
  import { Cell } from 'react-table';
8
8
  import { CheckboxProps } from '@mui/material/Checkbox';
9
- import { ClickAwayListenerProps } from '@mui/base/ClickAwayListener';
9
+ import { ClickAwayListenerProps } from '@mui/base';
10
10
  import { ColumnInstance } from 'react-table';
11
11
  import { ColumnInterface } from 'react-table';
12
12
  import { ComponentProps } from 'react';
@@ -46,10 +46,10 @@ import { IdType as IdType_2 } from 'react-table';
46
46
  import { InputBaseProps } from '@mui/material/InputBase';
47
47
  import { JSX as JSX_2 } from 'react/jsx-runtime';
48
48
  import { MutableRefObject } from 'react';
49
- import { OptionGroupProps } from '@mui/base/OptionGroup';
50
- import { OptionOwnProps } from '@mui/base/Option';
49
+ import { OptionGroupProps } from '@mui/base';
50
+ import { OptionOwnProps } from '@mui/base';
51
51
  import { OptionsObject } from 'notistack';
52
- import { PopperProps } from '@mui/base/Popper';
52
+ import { PopperProps } from '@mui/base';
53
53
  import { PopperProps as PopperProps_2 } from 'react-popper';
54
54
  import { PropGetter } from 'react-table';
55
55
  import { PropsWithoutRef } from 'react';
@@ -60,8 +60,8 @@ import { ReducerTableState } from 'react-table';
60
60
  import { RefAttributes } from 'react';
61
61
  import { Renderer } from 'react-table';
62
62
  import { Row } from 'react-table';
63
- import { SelectOption } from '@mui/base/useOption';
64
- import { SelectValue } from '@mui/base/useSelect';
63
+ import { SelectOption } from '@mui/base';
64
+ import { SelectValue } from '@mui/base';
65
65
  import { SlideProps } from '@mui/material/Slide';
66
66
  import { SliderProps } from 'rc-slider';
67
67
  import { SliderRef } from 'rc-slider';
@@ -126,7 +126,7 @@ import { UseRowStateInstanceProps } from 'react-table';
126
126
  import { UseRowStateOptions } from 'react-table';
127
127
  import { UseRowStateRowProps } from 'react-table';
128
128
  import { UseRowStateState } from 'react-table';
129
- import { UseSelectParameters } from '@mui/base/useSelect';
129
+ import { UseSelectParameters } from '@mui/base';
130
130
  import { UseSortByColumnOptions } from 'react-table';
131
131
  import { UseSortByColumnProps } from 'react-table';
132
132
  import { UseSortByHooks } from 'react-table';
@@ -515,10 +515,8 @@ export declare const colorPickerClasses: {
515
515
  panel: string;
516
516
  colorPicker: string;
517
517
  colorPickerIcon: string;
518
- recommendedColorsRoot: string;
519
518
  dropdownRootIconOnly: string;
520
519
  headerColorIconOnly: string;
521
- pickerFields: string;
522
520
  };
523
521
 
524
522
  declare type ColorVariant = "primary" | "secondary" | "positive" | "negative" | "warning";
@@ -8781,7 +8779,7 @@ declare const useClasses_47: (classesProp?: Partial<Record<"vertical" | "horizon
8781
8779
  readonly cx: (...args: any) => string;
8782
8780
  };
8783
8781
 
8784
- declare const useClasses_48: (classesProp?: Partial<Record<"label" | "colorPicker" | "root" | "description" | "panel" | "labelContainer" | "headerColorValue" | "headerColorIcon" | "colorPickerIcon" | "recommendedColorsRoot" | "dropdownRootIconOnly" | "headerColorIconOnly" | "pickerFields", string>>, addStatic?: boolean) => {
8782
+ declare const useClasses_48: (classesProp?: Partial<Record<"label" | "colorPicker" | "root" | "description" | "panel" | "labelContainer" | "headerColorValue" | "headerColorIcon" | "colorPickerIcon" | "dropdownRootIconOnly" | "headerColorIconOnly", string>>, addStatic?: boolean) => {
8785
8783
  readonly classes: {
8786
8784
  root: string;
8787
8785
  labelContainer: string;
@@ -8792,10 +8790,8 @@ declare const useClasses_48: (classesProp?: Partial<Record<"label" | "colorPicke
8792
8790
  panel: string;
8793
8791
  colorPicker: string;
8794
8792
  colorPickerIcon: string;
8795
- recommendedColorsRoot: string;
8796
8793
  dropdownRootIconOnly: string;
8797
8794
  headerColorIconOnly: string;
8798
- pickerFields: string;
8799
8795
  };
8800
8796
  readonly css: any;
8801
8797
  readonly cx: (...args: any) => string;
@@ -122,20 +122,8 @@ const next = mergeTheme(next$1, {
122
122
  HvColorPicker: {
123
123
  classes: {
124
124
  colorPicker: {
125
- " .HvColorPickerPresetColors-swatchWrap > span > div": {
125
+ ".HvColorPickerSwatch-root": {
126
126
  borderRadius: theme.radii.round
127
- },
128
- " .HvColorPickerSavedColors-swatchWrap > span > div": {
129
- borderRadius: theme.radii.round
130
- },
131
- " .HvColorPickerPicker-saturation > div": {
132
- borderRadius: theme.radii.round,
133
- " .saturation-white": {
134
- borderRadius: theme.radii.round,
135
- " .saturation-black": {
136
- borderRadius: theme.radii.round
137
- }
138
- }
139
127
  }
140
128
  }
141
129
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hitachivantara/uikit-react-core",
3
- "version": "6.0.0-next.4",
3
+ "version": "6.0.0-next.6",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "author": "Hitachi Vantara UI Kit Team",
@@ -33,21 +33,22 @@
33
33
  "dependencies": {
34
34
  "@emotion/cache": "^11.11.0",
35
35
  "@emotion/serialize": "^1.1.2",
36
- "@hitachivantara/uikit-react-shared": "^6.0.0-next.4",
37
- "@hitachivantara/uikit-react-utils": "^6.0.0-next.4",
38
- "@hitachivantara/uikit-styles": "^6.0.0-next.4",
36
+ "@hitachivantara/uikit-react-shared": "^6.0.0-next.5",
37
+ "@hitachivantara/uikit-react-utils": "^6.0.0-next.5",
38
+ "@hitachivantara/uikit-styles": "^6.0.0-next.5",
39
39
  "@internationalized/date": "^3.2.0",
40
40
  "@mui/base": "5.0.0-beta.68",
41
41
  "@popperjs/core": "^2.11.8",
42
42
  "@react-aria/datepicker": "^3.9.0",
43
43
  "@react-stately/datepicker": "^3.9.0",
44
44
  "@types/react-table": "^7.7.18",
45
+ "@uiw/react-color-hue": "^2.9.2",
46
+ "@uiw/react-color-saturation": "^2.9.2",
45
47
  "clsx": "^2.0.0",
46
48
  "embla-carousel-react": "^8.1.3",
47
49
  "notistack": "^3.0.2",
48
50
  "rc-slider": "^10.5.0",
49
51
  "rc-tooltip": "~6.3.0",
50
- "react-color": "^2.19.3",
51
52
  "react-popper": "^2.3.0",
52
53
  "react-resize-detector": "^8.1.0",
53
54
  "react-table": "^7.8.0",
@@ -60,11 +61,11 @@
60
61
  "access": "public",
61
62
  "directory": "package"
62
63
  },
63
- "gitHead": "66ab53a4c56da226078cf7dd92881ba7f0f521a4",
64
+ "gitHead": "bf1f8dcbead53467253e86b24f15ecbc2b23ed0f",
64
65
  "exports": {
65
66
  ".": {
66
67
  "types": "./dist/index.d.ts",
67
- "import": "./dist/index.js"
68
+ "default": "./dist/index.js"
68
69
  }
69
70
  },
70
71
  "types": "dist/index.d.ts",
@@ -1,36 +0,0 @@
1
- import { createClasses } from "@hitachivantara/uikit-react-utils";
2
- import { theme } from "@hitachivantara/uikit-styles";
3
- const { useClasses } = createClasses("HvColorPickerFields", {
4
- fields: {
5
- width: "100%",
6
- display: "flex",
7
- paddingTop: "18px",
8
- marginRight: "0px"
9
- },
10
- single: {
11
- maxWidth: "50px",
12
- paddingLeft: theme.space.xxs,
13
- "& input": {
14
- marginLeft: 5,
15
- marginRight: 5
16
- },
17
- "& label": {
18
- paddingLeft: 5
19
- }
20
- },
21
- double: {
22
- maxWidth: "82px",
23
- paddingRight: theme.space.xxs,
24
- "& input": {
25
- textTransform: "uppercase",
26
- marginLeft: 5,
27
- marginRight: 5
28
- },
29
- "& label": {
30
- paddingLeft: 5
31
- }
32
- }
33
- });
34
- export {
35
- useClasses
36
- };