@hitachivantara/uikit-react-core 6.0.0-next.1 → 6.0.0-next.10
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.
- package/dist/ActionBar/ActionBar.styles.js +1 -1
- package/dist/BaseDropdown/BaseDropdownPanel.js +1 -2
- package/dist/Button/Button.js +2 -2
- package/dist/CheckBox/CheckBox.js +2 -1
- package/dist/CheckBox/CheckBox.styles.js +10 -11
- package/dist/ColorPicker/ColorPicker.js +15 -21
- package/dist/ColorPicker/ColorPicker.styles.js +5 -10
- package/dist/ColorPicker/{Fields → Picker}/Fields.js +54 -44
- package/dist/ColorPicker/Picker/Picker.js +32 -41
- package/dist/ColorPicker/Picker/Picker.styles.js +21 -37
- package/dist/ColorPicker/PresetColors/PresetColors.js +5 -20
- package/dist/ColorPicker/PresetColors/PresetColors.styles.js +1 -10
- package/dist/ColorPicker/SavedColors/SavedColors.js +14 -37
- package/dist/ColorPicker/SavedColors/SavedColors.styles.js +9 -24
- package/dist/ColorPicker/Swatch.js +39 -0
- package/dist/FormElement/Suggestions/Suggestions.js +1 -2
- package/dist/Header/Actions/Actions.styles.js +2 -5
- package/dist/Header/Header.js +0 -1
- package/dist/Header/Header.styles.js +1 -2
- package/dist/Input/Input.js +1 -1
- package/dist/OverflowTooltip/OverflowTooltip.js +2 -2
- package/dist/Pagination/Pagination.js +17 -39
- package/dist/Pagination/Pagination.styles.js +32 -54
- package/dist/Radio/Radio.js +2 -2
- package/dist/Radio/Radio.styles.js +9 -11
- package/dist/SearchInput/SearchInput.styles.js +1 -2
- package/dist/Select/Option.js +1 -1
- package/dist/Select/OptionGroup.js +1 -1
- package/dist/Select/Select.js +4 -4
- package/dist/StatusIcon/StatusIcon.js +4 -4
- package/dist/StatusIcon/StatusIcon.styles.js +9 -14
- package/dist/Tag/Tag.js +1 -1
- package/dist/TextArea/TextArea.js +1 -1
- package/dist/TreeView/TreeView.js +1 -1
- package/dist/VerticalNavigation/NavigationPopup/NavigationPopupContainer.js +1 -2
- package/dist/icons.js +2 -2
- package/dist/index.d.ts +98 -115
- package/dist/index.js +3 -4
- package/dist/providers/Provider.js +3 -3
- package/dist/providers/ThemeProvider.js +24 -6
- package/dist/themes/index.js +3 -3
- package/dist/themes/{ds5.js → next.js} +4 -16
- package/dist/themes/pentaho.js +34 -1
- package/dist/utils/theme.js +0 -20
- package/package.json +11 -10
- package/dist/ColorPicker/Fields/Fields.styles.js +0 -36
|
@@ -4,7 +4,7 @@ const { staticClasses, useClasses } = createClasses("HvActionBar", {
|
|
|
4
4
|
root: {
|
|
5
5
|
width: "100%",
|
|
6
6
|
padding: theme.space.sm,
|
|
7
|
-
borderTop: `1px solid ${theme.colors.
|
|
7
|
+
borderTop: `1px solid ${theme.colors.borderSubtle}`,
|
|
8
8
|
display: "flex",
|
|
9
9
|
alignItems: "center",
|
|
10
10
|
justifyContent: "flex-end"
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { ClickAwayListener } from "@mui/base
|
|
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";
|
package/dist/Button/Button.js
CHANGED
|
@@ -7,10 +7,10 @@ import { useClasses, getIconSizeStyles, getSizeStyles } from "./Button.styles.js
|
|
|
7
7
|
import { staticClasses } from "./Button.styles.js";
|
|
8
8
|
function parseVariant(variant) {
|
|
9
9
|
if (variant === "semantic") return ["inherit", "ghost"];
|
|
10
|
-
if (variant === "secondary") return ["
|
|
10
|
+
if (variant === "secondary") return ["text", "subtle"];
|
|
11
11
|
if (variant === "ghost") return ["primary", "ghost"];
|
|
12
12
|
if (variant === "contained" || variant === "subtle") {
|
|
13
|
-
return ["
|
|
13
|
+
return ["text", variant];
|
|
14
14
|
}
|
|
15
15
|
const result = variant.split(/(?=[A-Z])/);
|
|
16
16
|
if (!result[1]) return [result[0], "contained"];
|
|
@@ -138,6 +138,7 @@ const HvCheckBox = forwardRef(
|
|
|
138
138
|
readOnly,
|
|
139
139
|
className: cx(
|
|
140
140
|
classes.root,
|
|
141
|
+
classes[labelPosition],
|
|
141
142
|
{ [classes.focusVisible]: !!(focusVisible && label) },
|
|
142
143
|
className
|
|
143
144
|
),
|
|
@@ -145,7 +146,7 @@ const HvCheckBox = forwardRef(
|
|
|
145
146
|
hasLabel ? /* @__PURE__ */ jsxs(
|
|
146
147
|
"div",
|
|
147
148
|
{
|
|
148
|
-
className: cx(classes.container,
|
|
149
|
+
className: cx(classes.container, {
|
|
149
150
|
[classes.invalidContainer]: isStateInvalid,
|
|
150
151
|
[classes.disabled]: disabled
|
|
151
152
|
}),
|
|
@@ -14,13 +14,6 @@ const { staticClasses, useClasses } = createClasses("HvCheckBox", {
|
|
|
14
14
|
},
|
|
15
15
|
":where(:has($label)) $checkbox": {
|
|
16
16
|
borderRadius: "inherit"
|
|
17
|
-
},
|
|
18
|
-
"&$left": {
|
|
19
|
-
flexDirection: "row-reverse",
|
|
20
|
-
justifyContent: "flex-end"
|
|
21
|
-
},
|
|
22
|
-
"&$right": {
|
|
23
|
-
flexDirection: "row"
|
|
24
17
|
}
|
|
25
18
|
},
|
|
26
19
|
invalidContainer: {},
|
|
@@ -38,18 +31,24 @@ const { staticClasses, useClasses } = createClasses("HvCheckBox", {
|
|
|
38
31
|
verticalAlign: "middle",
|
|
39
32
|
...theme.typography.body,
|
|
40
33
|
cursor: "pointer",
|
|
41
|
-
lineHeight: "32px"
|
|
34
|
+
lineHeight: "32px",
|
|
35
|
+
flex: 1
|
|
42
36
|
},
|
|
43
37
|
checked: {},
|
|
44
38
|
indeterminate: {},
|
|
45
39
|
semantic: {},
|
|
46
40
|
left: {
|
|
47
|
-
"&
|
|
48
|
-
paddingLeft: theme.space.xs
|
|
41
|
+
"& $label": {
|
|
42
|
+
paddingLeft: theme.space.xs,
|
|
43
|
+
textAlign: "right"
|
|
44
|
+
},
|
|
45
|
+
"& $container": {
|
|
46
|
+
flexDirection: "row-reverse"
|
|
47
|
+
// justifyContent: "flex-end",
|
|
49
48
|
}
|
|
50
49
|
},
|
|
51
50
|
right: {
|
|
52
|
-
"&
|
|
51
|
+
"& $label": {
|
|
53
52
|
paddingRight: theme.space.xs
|
|
54
53
|
}
|
|
55
54
|
}
|
|
@@ -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 = (
|
|
85
|
-
onChange?.(
|
|
86
|
-
onChangeComplete?.(
|
|
87
|
-
setColor(
|
|
84
|
+
const handleSelect = (hex) => {
|
|
85
|
+
onChange?.(hex);
|
|
86
|
+
onChangeComplete?.(hex);
|
|
87
|
+
setColor(hex);
|
|
88
88
|
};
|
|
89
|
-
const handleOnChange = (
|
|
90
|
-
onChange?.(
|
|
91
|
-
setColor(
|
|
89
|
+
const handleOnChange = (hex) => {
|
|
90
|
+
onChange?.(hex);
|
|
91
|
+
setColor(hex);
|
|
92
92
|
};
|
|
93
|
-
const handleOnChangeComplete = (
|
|
94
|
-
onChangeComplete?.(
|
|
95
|
-
setColor(
|
|
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"
|
|
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__ */
|
|
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
|
|
4
|
-
import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
|
|
5
|
-
import {
|
|
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 = (
|
|
41
|
-
if (
|
|
42
|
-
|
|
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 = (
|
|
66
|
-
if (
|
|
67
|
-
if (
|
|
68
|
-
if (
|
|
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:
|
|
72
|
-
g:
|
|
73
|
-
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.
|
|
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:
|
|
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(
|
|
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(
|
|
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(
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
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
|
|
10
|
+
const Picker = (props) => {
|
|
10
11
|
const {
|
|
12
|
+
hex: hexProp,
|
|
11
13
|
onChange,
|
|
12
|
-
|
|
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
|
|
21
|
-
|
|
22
|
-
|
|
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(
|
|
24
|
+
/* @__PURE__ */ jsx(
|
|
32
25
|
Saturation,
|
|
33
26
|
{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
onChange
|
|
37
|
-
|
|
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(
|
|
35
|
+
),
|
|
36
|
+
/* @__PURE__ */ jsx(
|
|
41
37
|
Hue,
|
|
42
38
|
{
|
|
39
|
+
className: classes.hue,
|
|
43
40
|
direction: "horizontal",
|
|
44
|
-
|
|
45
|
-
onChange
|
|
46
|
-
|
|
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
|
-
|
|
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
|
-
"&
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
19
|
+
Swatch,
|
|
26
20
|
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
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 {
|