@hitachivantara/uikit-react-core 5.78.0 → 5.79.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.
- package/dist/cjs/Button/Button.cjs +24 -31
- package/dist/cjs/Button/Button.styles.cjs +38 -59
- package/dist/cjs/Switch/Switch.cjs +14 -1
- package/dist/cjs/index.cjs +0 -4
- package/dist/esm/Button/Button.js +26 -33
- package/dist/esm/Button/Button.js.map +1 -1
- package/dist/esm/Button/Button.styles.js +38 -59
- package/dist/esm/Button/Button.styles.js.map +1 -1
- package/dist/esm/DropDownMenu/DropDownMenu.js.map +1 -1
- package/dist/esm/MultiButton/MultiButton.js.map +1 -1
- package/dist/esm/Switch/Switch.js +14 -1
- package/dist/esm/Switch/Switch.js.map +1 -1
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/types/index.d.ts +29 -19
- package/package.json +6 -6
- package/dist/cjs/Button/types.cjs +0 -33
- package/dist/esm/Button/types.js +0 -33
- package/dist/esm/Button/types.js.map +0 -1
|
@@ -3,28 +3,31 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const uikitReactUtils = require("@hitachivantara/uikit-react-utils");
|
|
6
|
+
const uikitStyles = require("@hitachivantara/uikit-styles");
|
|
6
7
|
const generic = require("../types/generic.cjs");
|
|
7
8
|
const Button_styles = require("./Button.styles.cjs");
|
|
8
|
-
|
|
9
|
-
if (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
function parseVariant(variant) {
|
|
10
|
+
if (variant === "semantic") return ["inherit", "ghost"];
|
|
11
|
+
if (variant === "secondary") return ["secondary", "subtle"];
|
|
12
|
+
if (variant === "ghost") return ["primary", "ghost"];
|
|
13
|
+
if (variant === "contained" || variant === "subtle") {
|
|
14
|
+
return ["secondary", variant];
|
|
15
|
+
}
|
|
16
|
+
const result = variant.split(/(?=[A-Z])/);
|
|
17
|
+
if (!result[1]) return [result[0], "contained"];
|
|
18
|
+
return result.map((x) => x.toLowerCase());
|
|
19
|
+
}
|
|
17
20
|
const HvButton = generic.fixedForwardRef(function HvButton2(props, ref) {
|
|
18
21
|
const {
|
|
19
22
|
classes: classesProp,
|
|
20
23
|
children,
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
icon = false,
|
|
25
|
+
variant: variantProp = icon ? "secondaryGhost" : "primary",
|
|
26
|
+
color: colorProp,
|
|
23
27
|
disabled = false,
|
|
24
28
|
className,
|
|
25
29
|
startIcon,
|
|
26
30
|
endIcon,
|
|
27
|
-
icon = false,
|
|
28
31
|
size,
|
|
29
32
|
radius,
|
|
30
33
|
overrideIconColors = true,
|
|
@@ -37,11 +40,8 @@ const HvButton = generic.fixedForwardRef(function HvButton2(props, ref) {
|
|
|
37
40
|
...others
|
|
38
41
|
} = uikitReactUtils.useDefaultProps("HvButton", props);
|
|
39
42
|
const { classes, css, cx } = Button_styles.useClasses(classesProp);
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
variantProp ?? (icon ? "secondaryGhost" : "primary"),
|
|
43
|
-
activeTheme?.base
|
|
44
|
-
);
|
|
43
|
+
const [parsedColor, variant] = parseVariant(variantProp);
|
|
44
|
+
const color = colorProp ?? parsedColor;
|
|
45
45
|
const handleClick = (e) => {
|
|
46
46
|
if (disabled) return;
|
|
47
47
|
onClickProp?.(e);
|
|
@@ -50,31 +50,24 @@ const HvButton = generic.fixedForwardRef(function HvButton2(props, ref) {
|
|
|
50
50
|
if (disabled) return;
|
|
51
51
|
onMouseDownProp?.(e);
|
|
52
52
|
};
|
|
53
|
-
const [color, type] = React.useMemo(() => {
|
|
54
|
-
const result = variant.split(/(?=[A-Z])/);
|
|
55
|
-
if (result[0] === "ghost" || result[0] === "semantic" || result[0] === "secondary" && !result[1])
|
|
56
|
-
return [];
|
|
57
|
-
return result.map((x) => x.toLowerCase());
|
|
58
|
-
}, [variant]);
|
|
59
53
|
const sizeStyles = React.useMemo(
|
|
60
|
-
() => size
|
|
54
|
+
() => size && (icon ? Button_styles.getIconSizeStyles(size) : Button_styles.getSizeStyles(size)),
|
|
61
55
|
[size, icon]
|
|
62
56
|
);
|
|
63
57
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
64
58
|
Component,
|
|
65
59
|
{
|
|
66
60
|
ref,
|
|
67
|
-
style: {
|
|
68
|
-
|
|
69
|
-
"--
|
|
70
|
-
|
|
61
|
+
style: uikitReactUtils.mergeStyles(style, {
|
|
62
|
+
"--color": color && uikitStyles.getColor(color),
|
|
63
|
+
"--radius": radius && uikitStyles.theme.radii[radius],
|
|
64
|
+
"--HvButton-height": sizeStyles?.height ?? "32px"
|
|
65
|
+
}),
|
|
71
66
|
className: cx(
|
|
72
67
|
classes.root,
|
|
73
|
-
type && classes[type],
|
|
74
|
-
color && css(Button_styles.getColoringStyle(color, type)),
|
|
75
68
|
classes[variant],
|
|
69
|
+
classes[variantProp],
|
|
76
70
|
// Placed after type and color CSS for DS3 override
|
|
77
|
-
radius && css(Button_styles.getRadiusStyles(radius)),
|
|
78
71
|
overrideIconColors && css(Button_styles.getOverrideColors()),
|
|
79
72
|
{
|
|
80
73
|
[classes.icon]: icon,
|
|
@@ -4,6 +4,9 @@ const uikitReactUtils = require("@hitachivantara/uikit-react-utils");
|
|
|
4
4
|
const uikitStyles = require("@hitachivantara/uikit-styles");
|
|
5
5
|
const focusUtils = require("../utils/focusUtils.cjs");
|
|
6
6
|
const { staticClasses, useClasses } = uikitReactUtils.createClasses("HvButton", {
|
|
7
|
+
/**
|
|
8
|
+
* Classes applied to the root element
|
|
9
|
+
*/
|
|
7
10
|
root: {
|
|
8
11
|
display: "inline-flex",
|
|
9
12
|
alignItems: "center",
|
|
@@ -12,19 +15,22 @@ const { staticClasses, useClasses } = uikitReactUtils.createClasses("HvButton",
|
|
|
12
15
|
cursor: "pointer",
|
|
13
16
|
whiteSpace: "nowrap",
|
|
14
17
|
// Background color common for almost all variants
|
|
15
|
-
"
|
|
16
|
-
|
|
18
|
+
":where(:not($disabled))": {
|
|
19
|
+
":hover, :focus-visible": {
|
|
20
|
+
backgroundColor: uikitStyles.theme.colors.containerBackgroundHover
|
|
21
|
+
}
|
|
17
22
|
},
|
|
18
|
-
"
|
|
19
|
-
...focusUtils.outlineStyles
|
|
20
|
-
backgroundColor: uikitStyles.theme.colors.containerBackgroundHover
|
|
23
|
+
":focus-visible": {
|
|
24
|
+
...focusUtils.outlineStyles
|
|
21
25
|
},
|
|
22
26
|
// Default button - no size specified
|
|
23
27
|
fontFamily: uikitStyles.theme.fontFamily.body,
|
|
24
28
|
...uikitStyles.theme.typography.label,
|
|
29
|
+
color: "var(--color, currentcolor)",
|
|
30
|
+
backgroundColor: "transparent",
|
|
25
31
|
height: "var(--HvButton-height)",
|
|
26
|
-
border: "1px solid
|
|
27
|
-
borderRadius: uikitStyles.theme.radii.base
|
|
32
|
+
border: "1px solid transparent",
|
|
33
|
+
borderRadius: `var(--radius, ${uikitStyles.theme.radii.base})`,
|
|
28
34
|
padding: uikitStyles.theme.spacing(0, "sm")
|
|
29
35
|
},
|
|
30
36
|
startIcon: {
|
|
@@ -37,11 +43,11 @@ const { staticClasses, useClasses } = uikitReactUtils.createClasses("HvButton",
|
|
|
37
43
|
disabled: {
|
|
38
44
|
cursor: "not-allowed",
|
|
39
45
|
color: uikitStyles.theme.colors.secondary_60,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
backgroundColor:
|
|
44
|
-
borderColor:
|
|
46
|
+
backgroundColor: "transparent",
|
|
47
|
+
borderColor: "transparent",
|
|
48
|
+
":hover, :focus-visible": {
|
|
49
|
+
backgroundColor: "transparent",
|
|
50
|
+
borderColor: "transparent"
|
|
45
51
|
}
|
|
46
52
|
},
|
|
47
53
|
icon: {
|
|
@@ -52,27 +58,23 @@ const { staticClasses, useClasses } = uikitReactUtils.createClasses("HvButton",
|
|
|
52
58
|
margin: -1
|
|
53
59
|
}
|
|
54
60
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
contained: {
|
|
62
|
+
color: uikitStyles.theme.colors.atmo1,
|
|
63
|
+
// `color-contrast(var(--color) vs ${colors.atmo1}, ${colors.base_light}, ${colors.base_dark})`,
|
|
64
|
+
backgroundColor: "var(--color)",
|
|
65
|
+
":where(:not($disabled))": {
|
|
66
|
+
":hover, :focus-visible": {
|
|
67
|
+
backgroundColor: "color-mix(in srgb, var(--color), black 20%)"
|
|
68
|
+
},
|
|
69
|
+
":active": {
|
|
70
|
+
backgroundColor: "color-mix(in srgb, var(--color), black 30%)"
|
|
61
71
|
}
|
|
62
72
|
}
|
|
63
73
|
},
|
|
64
|
-
|
|
65
|
-
borderColor: "
|
|
66
|
-
backgroundColor: "transparent",
|
|
67
|
-
"&$disabled": {
|
|
68
|
-
borderColor: "transparent",
|
|
69
|
-
backgroundColor: "transparent",
|
|
70
|
-
"&:hover, &:focus-visible": {
|
|
71
|
-
borderColor: "transparent",
|
|
72
|
-
backgroundColor: "transparent"
|
|
73
|
-
}
|
|
74
|
-
}
|
|
74
|
+
subtle: {
|
|
75
|
+
borderColor: "currentcolor"
|
|
75
76
|
},
|
|
77
|
+
ghost: {},
|
|
76
78
|
semantic: {
|
|
77
79
|
color: uikitStyles.theme.colors.base_dark,
|
|
78
80
|
backgroundColor: "transparent",
|
|
@@ -93,40 +95,19 @@ const { staticClasses, useClasses } = uikitReactUtils.createClasses("HvButton",
|
|
|
93
95
|
// Deprecated (DS3)
|
|
94
96
|
secondary: {}
|
|
95
97
|
});
|
|
96
|
-
const getColoringStyle = (color, type) => {
|
|
97
|
-
if (type)
|
|
98
|
-
return {
|
|
99
|
-
color: uikitStyles.theme.colors[color !== "warning" ? color : `${color}_140`]
|
|
100
|
-
};
|
|
101
|
-
const bg = uikitStyles.theme.colors[color !== "warning" ? color : `${color}_120`];
|
|
102
|
-
const hoverBg = uikitStyles.theme.colors[color !== "warning" ? `${color}_80` : `${color}_140`];
|
|
103
|
-
return {
|
|
104
|
-
color: uikitStyles.theme.colors.atmo1,
|
|
105
|
-
backgroundColor: bg,
|
|
106
|
-
borderColor: bg,
|
|
107
|
-
"&:hover, &:focus-visible": {
|
|
108
|
-
backgroundColor: hoverBg,
|
|
109
|
-
borderColor: hoverBg
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
const getRadiusStyles = (radius) => ({
|
|
114
|
-
borderRadius: uikitStyles.theme.radii[radius]
|
|
115
|
-
});
|
|
116
98
|
const sizes = {
|
|
117
|
-
xs: { height: "24px",
|
|
118
|
-
sm: { height: "24px",
|
|
119
|
-
md: { height: "32px"
|
|
120
|
-
lg: { height: "48px", space: "md"
|
|
121
|
-
xl: { height: "48px", space: "md"
|
|
99
|
+
xs: { height: "24px", fontSize: "sm" },
|
|
100
|
+
sm: { height: "24px", fontSize: "sm" },
|
|
101
|
+
md: { height: "32px" },
|
|
102
|
+
lg: { height: "48px", space: "md" },
|
|
103
|
+
xl: { height: "48px", space: "md" }
|
|
122
104
|
};
|
|
123
105
|
const getSizeStyles = (size) => {
|
|
124
|
-
const { height, space,
|
|
125
|
-
const { color, ...typoProps } = uikitStyles.theme.typography[typography];
|
|
106
|
+
const { height, space = "sm", fontSize } = sizes[size];
|
|
126
107
|
return {
|
|
127
108
|
height,
|
|
128
109
|
padding: uikitStyles.theme.spacing(0, space),
|
|
129
|
-
|
|
110
|
+
fontSize: fontSize && uikitStyles.theme.fontSizes[fontSize]
|
|
130
111
|
};
|
|
131
112
|
};
|
|
132
113
|
const getIconSizeStyles = (size) => {
|
|
@@ -141,10 +122,8 @@ const getOverrideColors = () => ({
|
|
|
141
122
|
fill: "currentcolor"
|
|
142
123
|
}
|
|
143
124
|
});
|
|
144
|
-
exports.getColoringStyle = getColoringStyle;
|
|
145
125
|
exports.getIconSizeStyles = getIconSizeStyles;
|
|
146
126
|
exports.getOverrideColors = getOverrideColors;
|
|
147
|
-
exports.getRadiusStyles = getRadiusStyles;
|
|
148
127
|
exports.getSizeStyles = getSizeStyles;
|
|
149
128
|
exports.staticClasses = staticClasses;
|
|
150
129
|
exports.useClasses = useClasses;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const uikitReactUtils = require("@hitachivantara/uikit-react-utils");
|
|
6
|
+
const uikitStyles = require("@hitachivantara/uikit-styles");
|
|
6
7
|
const validationStates = require("../Forms/FormElement/validationStates.cjs");
|
|
7
8
|
const useControlled = require("../hooks/useControlled.cjs");
|
|
8
9
|
const useUniqueId = require("../hooks/useUniqueId.cjs");
|
|
@@ -12,6 +13,7 @@ const BaseSwitch = require("../BaseSwitch/BaseSwitch.cjs");
|
|
|
12
13
|
const FormElement = require("../Forms/FormElement/FormElement.cjs");
|
|
13
14
|
const Label = require("../Forms/Label/Label.cjs");
|
|
14
15
|
const WarningText = require("../Forms/WarningText/WarningText.cjs");
|
|
16
|
+
const isSemantical = (color) => ["positive", "negative", "warning"].includes(color);
|
|
15
17
|
const HvSwitch = React.forwardRef(
|
|
16
18
|
(props, ref) => {
|
|
17
19
|
const {
|
|
@@ -35,9 +37,10 @@ const HvSwitch = React.forwardRef(
|
|
|
35
37
|
statusMessage,
|
|
36
38
|
"aria-errormessage": ariaErrorMessage,
|
|
37
39
|
inputProps,
|
|
40
|
+
color,
|
|
38
41
|
...others
|
|
39
42
|
} = uikitReactUtils.useDefaultProps("HvSwitch", props);
|
|
40
|
-
const { classes, cx } = Switch_styles.useClasses(classesProp);
|
|
43
|
+
const { classes, cx, css } = Switch_styles.useClasses(classesProp);
|
|
41
44
|
const elementId = useUniqueId.useUniqueId(id);
|
|
42
45
|
const [isChecked, setIsChecked] = useControlled.useControlled(
|
|
43
46
|
checked,
|
|
@@ -115,6 +118,16 @@ const HvSwitch = React.forwardRef(
|
|
|
115
118
|
"aria-describedby": ariaDescribedBy,
|
|
116
119
|
...inputProps
|
|
117
120
|
},
|
|
121
|
+
...color && {
|
|
122
|
+
classes: {
|
|
123
|
+
switchBase: css({
|
|
124
|
+
"&&&+.HvBaseSwitch-track,&&&.HvBaseSwitch-checked+.HvBaseSwitch-track": {
|
|
125
|
+
backgroundColor: uikitStyles.getColor(color),
|
|
126
|
+
borderColor: isSemantical(color) ? uikitStyles.getColor(`${color}_120`) : "#00000032"
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
},
|
|
118
131
|
...others
|
|
119
132
|
}
|
|
120
133
|
)
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -118,7 +118,6 @@ const BulkActions_styles = require("./BulkActions/BulkActions.styles.cjs");
|
|
|
118
118
|
const BulkActions = require("./BulkActions/BulkActions.cjs");
|
|
119
119
|
const Button = require("./Button/Button.cjs");
|
|
120
120
|
const Button_styles = require("./Button/Button.styles.cjs");
|
|
121
|
-
const types = require("./Button/types.cjs");
|
|
122
121
|
const Calendar_styles = require("./Calendar/Calendar.styles.cjs");
|
|
123
122
|
const Calendar = require("./Calendar/Calendar.cjs");
|
|
124
123
|
const CalendarHeader_styles = require("./Calendar/CalendarHeader/CalendarHeader.styles.cjs");
|
|
@@ -503,9 +502,6 @@ exports.bulkActionsClasses = BulkActions_styles.staticClasses;
|
|
|
503
502
|
exports.HvBulkActions = BulkActions.HvBulkActions;
|
|
504
503
|
exports.HvButton = Button.HvButton;
|
|
505
504
|
exports.buttonClasses = Button_styles.staticClasses;
|
|
506
|
-
exports.buttonRadius = types.buttonRadius;
|
|
507
|
-
exports.buttonSize = types.buttonSize;
|
|
508
|
-
exports.buttonVariant = types.buttonVariant;
|
|
509
505
|
exports.calendarClasses = Calendar_styles.staticClasses;
|
|
510
506
|
exports.HvCalendar = Calendar.HvCalendar;
|
|
511
507
|
exports.calendarHeaderClasses = CalendarHeader_styles.staticClasses;
|
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
|
-
import { useDefaultProps,
|
|
3
|
+
import { useDefaultProps, mergeStyles } from "@hitachivantara/uikit-react-utils";
|
|
4
|
+
import { getColor, theme } from "@hitachivantara/uikit-styles";
|
|
4
5
|
import { fixedForwardRef } from "../types/generic.js";
|
|
5
|
-
import { useClasses, getIconSizeStyles, getSizeStyles,
|
|
6
|
+
import { useClasses, getIconSizeStyles, getSizeStyles, getOverrideColors } from "./Button.styles.js";
|
|
6
7
|
import { staticClasses } from "./Button.styles.js";
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
function parseVariant(variant) {
|
|
9
|
+
if (variant === "semantic") return ["inherit", "ghost"];
|
|
10
|
+
if (variant === "secondary") return ["secondary", "subtle"];
|
|
11
|
+
if (variant === "ghost") return ["primary", "ghost"];
|
|
12
|
+
if (variant === "contained" || variant === "subtle") {
|
|
13
|
+
return ["secondary", variant];
|
|
14
|
+
}
|
|
15
|
+
const result = variant.split(/(?=[A-Z])/);
|
|
16
|
+
if (!result[1]) return [result[0], "contained"];
|
|
17
|
+
return result.map((x) => x.toLowerCase());
|
|
18
|
+
}
|
|
16
19
|
const HvButton = fixedForwardRef(function HvButton2(props, ref) {
|
|
17
20
|
const {
|
|
18
21
|
classes: classesProp,
|
|
19
22
|
children,
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
icon = false,
|
|
24
|
+
variant: variantProp = icon ? "secondaryGhost" : "primary",
|
|
25
|
+
color: colorProp,
|
|
22
26
|
disabled = false,
|
|
23
27
|
className,
|
|
24
28
|
startIcon,
|
|
25
29
|
endIcon,
|
|
26
|
-
icon = false,
|
|
27
30
|
size,
|
|
28
31
|
radius,
|
|
29
32
|
overrideIconColors = true,
|
|
@@ -36,11 +39,8 @@ const HvButton = fixedForwardRef(function HvButton2(props, ref) {
|
|
|
36
39
|
...others
|
|
37
40
|
} = useDefaultProps("HvButton", props);
|
|
38
41
|
const { classes, css, cx } = useClasses(classesProp);
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
variantProp ?? (icon ? "secondaryGhost" : "primary"),
|
|
42
|
-
activeTheme?.base
|
|
43
|
-
);
|
|
42
|
+
const [parsedColor, variant] = parseVariant(variantProp);
|
|
43
|
+
const color = colorProp ?? parsedColor;
|
|
44
44
|
const handleClick = (e) => {
|
|
45
45
|
if (disabled) return;
|
|
46
46
|
onClickProp?.(e);
|
|
@@ -49,31 +49,24 @@ const HvButton = fixedForwardRef(function HvButton2(props, ref) {
|
|
|
49
49
|
if (disabled) return;
|
|
50
50
|
onMouseDownProp?.(e);
|
|
51
51
|
};
|
|
52
|
-
const [color, type] = useMemo(() => {
|
|
53
|
-
const result = variant.split(/(?=[A-Z])/);
|
|
54
|
-
if (result[0] === "ghost" || result[0] === "semantic" || result[0] === "secondary" && !result[1])
|
|
55
|
-
return [];
|
|
56
|
-
return result.map((x) => x.toLowerCase());
|
|
57
|
-
}, [variant]);
|
|
58
52
|
const sizeStyles = useMemo(
|
|
59
|
-
() => size
|
|
53
|
+
() => size && (icon ? getIconSizeStyles(size) : getSizeStyles(size)),
|
|
60
54
|
[size, icon]
|
|
61
55
|
);
|
|
62
56
|
return /* @__PURE__ */ jsxs(
|
|
63
57
|
Component,
|
|
64
58
|
{
|
|
65
59
|
ref,
|
|
66
|
-
style: {
|
|
67
|
-
|
|
68
|
-
"--
|
|
69
|
-
|
|
60
|
+
style: mergeStyles(style, {
|
|
61
|
+
"--color": color && getColor(color),
|
|
62
|
+
"--radius": radius && theme.radii[radius],
|
|
63
|
+
"--HvButton-height": sizeStyles?.height ?? "32px"
|
|
64
|
+
}),
|
|
70
65
|
className: cx(
|
|
71
66
|
classes.root,
|
|
72
|
-
type && classes[type],
|
|
73
|
-
color && css(getColoringStyle(color, type)),
|
|
74
67
|
classes[variant],
|
|
68
|
+
classes[variantProp],
|
|
75
69
|
// Placed after type and color CSS for DS3 override
|
|
76
|
-
radius && css(getRadiusStyles(radius)),
|
|
77
70
|
overrideIconColors && css(getOverrideColors()),
|
|
78
71
|
{
|
|
79
72
|
[classes.icon]: icon,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../src/Button/Button.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport {\n
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../src/Button/Button.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport {\n mergeStyles,\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\nimport {\n getColor,\n HvColorAny,\n HvRadius,\n HvSize,\n theme,\n} from \"@hitachivantara/uikit-styles\";\n\nimport {\n fixedForwardRef,\n PolymorphicComponentRef,\n PolymorphicRef,\n} from \"../types/generic\";\nimport {\n getIconSizeStyles,\n getOverrideColors,\n getSizeStyles,\n staticClasses,\n useClasses,\n} from \"./Button.styles\";\nimport { HvButtonVariant } from \"./types\";\n\ntype Variant = \"contained\" | \"subtle\" | \"ghost\";\n\nexport { staticClasses as buttonClasses };\n\nexport type HvButtonClasses = ExtractNames<typeof useClasses>;\n\nexport type HvButtonProps<C extends React.ElementType = \"button\"> =\n PolymorphicComponentRef<\n C,\n {\n /** Use the variant prop to change the visual style of the button. */\n variant?: HvButtonVariant;\n /** Whether the button is an icon-only button. */\n icon?: boolean;\n /** Whether the button is disabled or not. */\n disabled?: boolean;\n /** Class names to be applied. */\n className?: string;\n /** Element placed before the children. */\n startIcon?: React.ReactNode;\n /** Element placed after the children. */\n endIcon?: React.ReactNode;\n /** Color of the button. */\n color?: HvColorAny;\n /** Button size. */\n size?: HvSize;\n /** Button border radius. */\n radius?: HvRadius;\n /** Defines the default colors of the button are forced into the icon. */\n overrideIconColors?: boolean;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvButtonClasses;\n /** Whether the button is selected or not. */\n selected?: boolean;\n /**\n * Whether the button is focusable when disabled.\n * Without this property, the accessibility of the button decreases when disabled since it's not read by screen readers.\n * Set this property to `true` when you need the button to still be focusable when disabled for accessibility purposes.\n */\n focusableWhenDisabled?: boolean;\n }\n >;\n\nfunction parseVariant(variant: HvButtonVariant): [HvColorAny, Variant] {\n const deprecatedVariantMap: Record<string, HvButtonVariant> = {\n secondary: \"secondarySubtle\",\n };\n\n const mappedVariant = deprecatedVariantMap[variant];\n\n if (import.meta.env.DEV && mappedVariant) {\n // eslint-disable-next-line no-console\n console.warn(\n `HvButton variant '${variant}' is deprecated. Please use '${mappedVariant}'.`,\n );\n }\n\n if (variant === \"semantic\") return [\"inherit\", \"ghost\"];\n if (variant === \"secondary\") return [\"secondary\", \"subtle\"];\n if (variant === \"ghost\") return [\"primary\", \"ghost\"];\n if (variant === \"contained\" || variant === \"subtle\") {\n return [\"secondary\", variant];\n }\n\n const result = variant.split(/(?=[A-Z])/);\n if (!result[1]) return [result[0], \"contained\"];\n\n return result.map((x) => x.toLowerCase()) as [HvColorAny, Variant];\n}\n/**\n * Button component is used to trigger an action or event.\n */\nexport const HvButton = fixedForwardRef(function HvButton<\n C extends React.ElementType = \"button\",\n>(props: HvButtonProps<C>, ref: PolymorphicRef<C>) {\n const {\n classes: classesProp,\n children,\n icon = false,\n variant: variantProp = icon ? \"secondaryGhost\" : \"primary\",\n color: colorProp,\n disabled = false,\n className,\n startIcon,\n endIcon,\n size,\n radius,\n overrideIconColors = true,\n component: Component = \"button\",\n focusableWhenDisabled,\n onClick: onClickProp,\n onMouseDown: onMouseDownProp,\n selected,\n style,\n ...others\n } = useDefaultProps(\"HvButton\", props);\n const { classes, css, cx } = useClasses(classesProp);\n const [parsedColor, variant] = parseVariant(variantProp);\n const color = colorProp ?? parsedColor;\n\n const handleClick: HvButtonProps[\"onClick\"] = (e) => {\n if (disabled) return;\n onClickProp?.(e);\n };\n\n const handleMouseDown: HvButtonProps[\"onMouseDown\"] = (e) => {\n if (disabled) return;\n onMouseDownProp?.(e);\n };\n\n const sizeStyles = useMemo(\n () => size && (icon ? getIconSizeStyles(size) : getSizeStyles(size)),\n [size, icon],\n );\n\n return (\n <Component\n ref={ref}\n style={mergeStyles(style, {\n \"--color\": color && getColor(color),\n \"--radius\": radius && theme.radii[radius],\n \"--HvButton-height\": sizeStyles?.height ?? \"32px\",\n })}\n className={cx(\n classes.root,\n classes[variant],\n classes[variantProp as keyof HvButtonClasses], // Placed after type and color CSS for DS3 override\n overrideIconColors && css(getOverrideColors()),\n {\n [classes.icon]: icon,\n [classes.disabled]: disabled,\n },\n sizeStyles && css(sizeStyles),\n className,\n )}\n data-color={color}\n onClick={handleClick}\n onMouseDown={handleMouseDown}\n {...(Component === \"button\" && { type: \"button\" })}\n {...(disabled && {\n disabled: !focusableWhenDisabled,\n tabIndex: focusableWhenDisabled ? 0 : -1,\n \"aria-disabled\": true,\n })}\n {...(selected && { \"aria-pressed\": selected })}\n {...others}\n >\n {startIcon && <span className={classes.startIcon}>{startIcon}</span>}\n {children}\n {endIcon && <span className={classes.endIcon}>{endIcon}</span>}\n </Component>\n );\n});\n"],"names":["HvButton"],"mappings":";;;;;;;AAuEA,SAAS,aAAa,SAAiD;AAcrE,MAAI,YAAY,WAAmB,QAAA,CAAC,WAAW,OAAO;AACtD,MAAI,YAAY,YAAoB,QAAA,CAAC,aAAa,QAAQ;AAC1D,MAAI,YAAY,QAAgB,QAAA,CAAC,WAAW,OAAO;AAC/C,MAAA,YAAY,eAAe,YAAY,UAAU;AAC5C,WAAA,CAAC,aAAa,OAAO;AAAA,EAC9B;AAEM,QAAA,SAAS,QAAQ,MAAM,WAAW;AACpC,MAAA,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,WAAW;AAE9C,SAAO,OAAO,IAAI,CAAC,MAAM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CAAC,QAAQ,QAAQ,GAAG;AAAA,QACtB;AAAA,QACA,cAAc,IAAI,UAAU;AAAA,QAC5B;AAAA,MACF;AAAA,MACA,cAAY;AAAA,MACZ,SAAS;AAAA,MACT,aAAa;AAAA,MACZ,GAAI,cAAc,YAAY,EAAE,MAAM,SAAS;AAAA,MAC/C,GAAI,YAAY;AAAA,QACf,UAAU,CAAC;AAAA,QACX,UAAU,wBAAwB,IAAI;AAAA,QACtC,iBAAiB;AAAA,MACnB;AAAA,MACC,GAAI,YAAY,EAAE,gBAAgB,SAAS;AAAA,MAC3C,GAAG;AAAA,MAEH,UAAA;AAAA,QAAA,aAAc,oBAAA,QAAA,EAAK,WAAW,QAAQ,WAAY,UAAU,WAAA;AAAA,QAC5D;AAAA,QACA,WAAY,oBAAA,QAAA,EAAK,WAAW,QAAQ,SAAU,UAAQ,SAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAG7D,CAAC;"}
|
|
@@ -2,6 +2,9 @@ import { createClasses } from "@hitachivantara/uikit-react-utils";
|
|
|
2
2
|
import { theme } from "@hitachivantara/uikit-styles";
|
|
3
3
|
import { outlineStyles } from "../utils/focusUtils.js";
|
|
4
4
|
const { staticClasses, useClasses } = createClasses("HvButton", {
|
|
5
|
+
/**
|
|
6
|
+
* Classes applied to the root element
|
|
7
|
+
*/
|
|
5
8
|
root: {
|
|
6
9
|
display: "inline-flex",
|
|
7
10
|
alignItems: "center",
|
|
@@ -10,19 +13,22 @@ const { staticClasses, useClasses } = createClasses("HvButton", {
|
|
|
10
13
|
cursor: "pointer",
|
|
11
14
|
whiteSpace: "nowrap",
|
|
12
15
|
// Background color common for almost all variants
|
|
13
|
-
"
|
|
14
|
-
|
|
16
|
+
":where(:not($disabled))": {
|
|
17
|
+
":hover, :focus-visible": {
|
|
18
|
+
backgroundColor: theme.colors.containerBackgroundHover
|
|
19
|
+
}
|
|
15
20
|
},
|
|
16
|
-
"
|
|
17
|
-
...outlineStyles
|
|
18
|
-
backgroundColor: theme.colors.containerBackgroundHover
|
|
21
|
+
":focus-visible": {
|
|
22
|
+
...outlineStyles
|
|
19
23
|
},
|
|
20
24
|
// Default button - no size specified
|
|
21
25
|
fontFamily: theme.fontFamily.body,
|
|
22
26
|
...theme.typography.label,
|
|
27
|
+
color: "var(--color, currentcolor)",
|
|
28
|
+
backgroundColor: "transparent",
|
|
23
29
|
height: "var(--HvButton-height)",
|
|
24
|
-
border: "1px solid
|
|
25
|
-
borderRadius: theme.radii.base
|
|
30
|
+
border: "1px solid transparent",
|
|
31
|
+
borderRadius: `var(--radius, ${theme.radii.base})`,
|
|
26
32
|
padding: theme.spacing(0, "sm")
|
|
27
33
|
},
|
|
28
34
|
startIcon: {
|
|
@@ -35,11 +41,11 @@ const { staticClasses, useClasses } = createClasses("HvButton", {
|
|
|
35
41
|
disabled: {
|
|
36
42
|
cursor: "not-allowed",
|
|
37
43
|
color: theme.colors.secondary_60,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
backgroundColor:
|
|
42
|
-
borderColor:
|
|
44
|
+
backgroundColor: "transparent",
|
|
45
|
+
borderColor: "transparent",
|
|
46
|
+
":hover, :focus-visible": {
|
|
47
|
+
backgroundColor: "transparent",
|
|
48
|
+
borderColor: "transparent"
|
|
43
49
|
}
|
|
44
50
|
},
|
|
45
51
|
icon: {
|
|
@@ -50,27 +56,23 @@ const { staticClasses, useClasses } = createClasses("HvButton", {
|
|
|
50
56
|
margin: -1
|
|
51
57
|
}
|
|
52
58
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
contained: {
|
|
60
|
+
color: theme.colors.atmo1,
|
|
61
|
+
// `color-contrast(var(--color) vs ${colors.atmo1}, ${colors.base_light}, ${colors.base_dark})`,
|
|
62
|
+
backgroundColor: "var(--color)",
|
|
63
|
+
":where(:not($disabled))": {
|
|
64
|
+
":hover, :focus-visible": {
|
|
65
|
+
backgroundColor: "color-mix(in srgb, var(--color), black 20%)"
|
|
66
|
+
},
|
|
67
|
+
":active": {
|
|
68
|
+
backgroundColor: "color-mix(in srgb, var(--color), black 30%)"
|
|
59
69
|
}
|
|
60
70
|
}
|
|
61
71
|
},
|
|
62
|
-
|
|
63
|
-
borderColor: "
|
|
64
|
-
backgroundColor: "transparent",
|
|
65
|
-
"&$disabled": {
|
|
66
|
-
borderColor: "transparent",
|
|
67
|
-
backgroundColor: "transparent",
|
|
68
|
-
"&:hover, &:focus-visible": {
|
|
69
|
-
borderColor: "transparent",
|
|
70
|
-
backgroundColor: "transparent"
|
|
71
|
-
}
|
|
72
|
-
}
|
|
72
|
+
subtle: {
|
|
73
|
+
borderColor: "currentcolor"
|
|
73
74
|
},
|
|
75
|
+
ghost: {},
|
|
74
76
|
semantic: {
|
|
75
77
|
color: theme.colors.base_dark,
|
|
76
78
|
backgroundColor: "transparent",
|
|
@@ -91,40 +93,19 @@ const { staticClasses, useClasses } = createClasses("HvButton", {
|
|
|
91
93
|
// Deprecated (DS3)
|
|
92
94
|
secondary: {}
|
|
93
95
|
});
|
|
94
|
-
const getColoringStyle = (color, type) => {
|
|
95
|
-
if (type)
|
|
96
|
-
return {
|
|
97
|
-
color: theme.colors[color !== "warning" ? color : `${color}_140`]
|
|
98
|
-
};
|
|
99
|
-
const bg = theme.colors[color !== "warning" ? color : `${color}_120`];
|
|
100
|
-
const hoverBg = theme.colors[color !== "warning" ? `${color}_80` : `${color}_140`];
|
|
101
|
-
return {
|
|
102
|
-
color: theme.colors.atmo1,
|
|
103
|
-
backgroundColor: bg,
|
|
104
|
-
borderColor: bg,
|
|
105
|
-
"&:hover, &:focus-visible": {
|
|
106
|
-
backgroundColor: hoverBg,
|
|
107
|
-
borderColor: hoverBg
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
const getRadiusStyles = (radius) => ({
|
|
112
|
-
borderRadius: theme.radii[radius]
|
|
113
|
-
});
|
|
114
96
|
const sizes = {
|
|
115
|
-
xs: { height: "24px",
|
|
116
|
-
sm: { height: "24px",
|
|
117
|
-
md: { height: "32px"
|
|
118
|
-
lg: { height: "48px", space: "md"
|
|
119
|
-
xl: { height: "48px", space: "md"
|
|
97
|
+
xs: { height: "24px", fontSize: "sm" },
|
|
98
|
+
sm: { height: "24px", fontSize: "sm" },
|
|
99
|
+
md: { height: "32px" },
|
|
100
|
+
lg: { height: "48px", space: "md" },
|
|
101
|
+
xl: { height: "48px", space: "md" }
|
|
120
102
|
};
|
|
121
103
|
const getSizeStyles = (size) => {
|
|
122
|
-
const { height, space,
|
|
123
|
-
const { color, ...typoProps } = theme.typography[typography];
|
|
104
|
+
const { height, space = "sm", fontSize } = sizes[size];
|
|
124
105
|
return {
|
|
125
106
|
height,
|
|
126
107
|
padding: theme.spacing(0, space),
|
|
127
|
-
|
|
108
|
+
fontSize: fontSize && theme.fontSizes[fontSize]
|
|
128
109
|
};
|
|
129
110
|
};
|
|
130
111
|
const getIconSizeStyles = (size) => {
|
|
@@ -140,10 +121,8 @@ const getOverrideColors = () => ({
|
|
|
140
121
|
}
|
|
141
122
|
});
|
|
142
123
|
export {
|
|
143
|
-
getColoringStyle,
|
|
144
124
|
getIconSizeStyles,
|
|
145
125
|
getOverrideColors,
|
|
146
|
-
getRadiusStyles,
|
|
147
126
|
getSizeStyles,
|
|
148
127
|
staticClasses,
|
|
149
128
|
useClasses
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.styles.js","sources":["../../../src/Button/Button.styles.ts"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"../utils/focusUtils\";\
|
|
1
|
+
{"version":3,"file":"Button.styles.js","sources":["../../../src/Button/Button.styles.ts"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme, type HvSize } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"../utils/focusUtils\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvButton\", {\n /**\n * Classes applied to the root element\n */\n root: {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n textTransform: \"none\",\n cursor: \"pointer\",\n whiteSpace: \"nowrap\",\n\n // Background color common for almost all variants\n \":where(:not($disabled))\": {\n \":hover, :focus-visible\": {\n backgroundColor: theme.colors.containerBackgroundHover,\n },\n },\n \":focus-visible\": {\n ...outlineStyles,\n },\n\n // Default button - no size specified\n fontFamily: theme.fontFamily.body,\n ...theme.typography.label,\n color: \"var(--color, currentcolor)\",\n backgroundColor: \"transparent\",\n height: \"var(--HvButton-height)\",\n border: \"1px solid transparent\",\n borderRadius: `var(--radius, ${theme.radii.base})`,\n padding: theme.spacing(0, \"sm\"),\n },\n startIcon: {\n marginLeft: `calc(-1 * ${theme.space.xs})`,\n },\n endIcon: {\n marginRight: `calc(-1 * ${theme.space.xs})`,\n },\n focusVisible: {},\n disabled: {\n cursor: \"not-allowed\",\n color: theme.colors.secondary_60,\n backgroundColor: \"transparent\",\n borderColor: \"transparent\",\n \":hover, :focus-visible\": {\n backgroundColor: \"transparent\",\n borderColor: \"transparent\",\n },\n },\n icon: {\n margin: 0,\n padding: 0,\n height: \"fit-content\",\n \"& > *\": {\n margin: -1,\n },\n },\n contained: {\n color: theme.colors.atmo1, // `color-contrast(var(--color) vs ${colors.atmo1}, ${colors.base_light}, ${colors.base_dark})`,\n backgroundColor: \"var(--color)\",\n \":where(:not($disabled))\": {\n \":hover, :focus-visible\": {\n backgroundColor: \"color-mix(in srgb, var(--color), black 20%)\",\n },\n \":active\": {\n backgroundColor: \"color-mix(in srgb, var(--color), black 30%)\",\n },\n },\n },\n subtle: {\n borderColor: \"currentcolor\",\n },\n ghost: {},\n semantic: {\n color: theme.colors.base_dark,\n backgroundColor: \"transparent\",\n borderColor: \"transparent\",\n \"&:hover, &:focus-visible\": {\n backgroundColor: \"rgba(251, 252, 252, 0.3)\",\n },\n \"&$disabled\": {\n backgroundColor: \"rgba(251, 252, 252, 0.1)\",\n },\n },\n\n // TODO - remove in v6\n primary: {},\n primarySubtle: {},\n primaryGhost: {},\n secondarySubtle: {},\n secondaryGhost: {},\n\n // Deprecated (DS3)\n secondary: {},\n});\n\n// TODO - remove xs and xl in v6 since they are not DS spec\nconst sizes: Record<\n HvSize,\n { height: string; space?: HvSize; fontSize?: keyof typeof theme.fontSizes }\n> = {\n xs: { height: \"24px\", fontSize: \"sm\" },\n sm: { height: \"24px\", fontSize: \"sm\" },\n md: { height: \"32px\" },\n lg: { height: \"48px\", space: \"md\" },\n xl: { height: \"48px\", space: \"md\" },\n};\n\nexport const getSizeStyles = (size: HvSize) => {\n const { height, space = \"sm\", fontSize } = sizes[size];\n return {\n height,\n padding: theme.spacing(0, space),\n fontSize: fontSize && theme.fontSizes[fontSize],\n };\n};\n\nexport const getIconSizeStyles = (size: HvSize) => {\n const { height } = sizes[size];\n return {\n height,\n width: height,\n };\n};\n\nexport const getOverrideColors = () => ({\n \"& svg .color0\": {\n fill: \"currentcolor\",\n },\n});\n"],"names":[],"mappings":";;;AAKO,MAAM,EAAE,eAAe,eAAe,cAAc,YAAY;AAAA;AAAA;AAAA;AAAA,EAIrE,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,QAAQ;AAAA,IACR,YAAY;AAAA;AAAA,IAGZ,2BAA2B;AAAA,MACzB,0BAA0B;AAAA,QACxB,iBAAiB,MAAM,OAAO;AAAA,MAChC;AAAA,IACF;AAAA,IACA,kBAAkB;AAAA,MAChB,GAAG;AAAA,IACL;AAAA;AAAA,IAGA,YAAY,MAAM,WAAW;AAAA,IAC7B,GAAG,MAAM,WAAW;AAAA,IACpB,OAAO;AAAA,IACP,iBAAiB;AAAA,IACjB,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,cAAc,iBAAiB,MAAM,MAAM,IAAI;AAAA,IAC/C,SAA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AAAA,EACrC,IAAI,EAAE,QAAQ,QAAQ,UAAU,KAAK;AAAA,EACrC,IAAI,EAAE,QAAQ,OAAO;AAAA,EACrB,IAAI,EAAE,QAAQ,QAAQ,OAAO,KAAK;AAAA,EAClC,IAAI,EAAE,QAAQ,QAAQ,OAAO,KAAK;AACpC;AAEa,MAAA,gBAAgB,CAAC,SAAiB;AAC7C,QAAM,EAAE,QAAQ,QAAQ,MAAM,aAAa,MAAM,IAAI;AAC9C,SAAA;AAAA,IACL;AAAA,IACA,SAAS,MAAM,QAAQ,GAAG,KAAK;AAAA,IAC/B,UAAU,YAAY,MAAM,UAAU,QAAQ;AAAA,EAAA;AAElD;AAEa,MAAA,oBAAoB,CAAC,SAAiB;AACjD,QAAM,EAAE,OAAA,IAAW,MAAM,IAAI;AACtB,SAAA;AAAA,IACL;AAAA,IACA,OAAO;AAAA,EAAA;AAEX;AAEO,MAAM,oBAAoB,OAAO;AAAA,EACtC,iBAAiB;AAAA,IACf,MAAM;AAAA,EACR;AACF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropDownMenu.js","sources":["../../../src/DropDownMenu/DropDownMenu.tsx"],"sourcesContent":["import { forwardRef, useMemo } from \"react\";\nimport { Placement } from \"@popperjs/core\";\nimport { MoreOptionsVertical } from \"@hitachivantara/uikit-react-icons\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseDropdown, HvBaseDropdownProps } from \"../BaseDropdown\";\nimport { useBaseDropdownContext } from \"../BaseDropdown/BaseDropdownContext/BaseDropdownContext\";\nimport {
|
|
1
|
+
{"version":3,"file":"DropDownMenu.js","sources":["../../../src/DropDownMenu/DropDownMenu.tsx"],"sourcesContent":["import { forwardRef, useMemo } from \"react\";\nimport { Placement } from \"@popperjs/core\";\nimport { MoreOptionsVertical } from \"@hitachivantara/uikit-react-icons\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\nimport { HvSize } from \"@hitachivantara/uikit-styles\";\n\nimport { HvBaseDropdown, HvBaseDropdownProps } from \"../BaseDropdown\";\nimport { useBaseDropdownContext } from \"../BaseDropdown/BaseDropdownContext/BaseDropdownContext\";\nimport { HvButtonVariant } from \"../Button\";\nimport { HvDropdownButton, HvDropdownButtonProps } from \"../DropdownButton\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useLabels } from \"../hooks/useLabels\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvList, HvListProps, HvListValue } from \"../List\";\nimport { HvPanel } from \"../Panel\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { getPrevNextFocus } from \"../utils/focusableElementFinder\";\nimport { isKey } from \"../utils/keyboardUtils\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./DropDownMenu.styles\";\n\nexport { staticClasses as dropDownMenuClasses };\n\nexport type HvDropDownMenuClasses = ExtractNames<typeof useClasses>;\n\nconst DEFAULT_LABELS = {\n dropdownMenu: \"Dropdown menu\",\n};\n\nexport interface HvDropDownMenuProps\n extends HvBaseProps<HTMLDivElement, \"onClick\" | \"onToggle\"> {\n /** Icon. */\n icon?: React.ReactElement;\n /**\n * A list containing the elements to be rendered.\n *\n * - label: The label of the element to be rendered.\n * - selected: The selection state of the element.\n * - disabled: The disabled state of the element.\n * - icon: The icon node to be rendered on the left.\n * - showNavIcon: If true renders the navigation icon on the right.\n */\n dataList: HvListValue[];\n /** Placement of the dropdown. */\n placement?: \"left\" | \"right\";\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n /** Function executed on toggle of the dropdown. Should receive the open status. */\n onToggle?: (\n event:\n | Event\n | React.KeyboardEvent<HTMLUListElement>\n | React.ChangeEvent<HTMLInputElement>\n | React.MouseEvent<HTMLLIElement>,\n open: boolean,\n ) => void;\n /** Function executed in each onClick. Should received the clicked element. */\n onClick?: (\n event:\n | React.ChangeEvent<HTMLInputElement>\n | React.MouseEvent<HTMLLIElement>,\n value: HvListValue,\n ) => void;\n /** Keep the Dropdown Menu opened after clicking one option */\n keepOpened?: boolean;\n /** Defines if the component is disabled. */\n disabled?: boolean;\n /** If true it should be displayed open. */\n expanded?: boolean;\n /** When uncontrolled, defines the initial expanded state. */\n defaultExpanded?: boolean;\n /**\n * The variant to be used in the header.\n * @deprecated Use `variant` instead\n */\n category?: HvButtonVariant;\n /** The variant to be used in the header. */\n variant?: HvButtonVariant;\n /** Button size. */\n size?: HvSize;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvDropDownMenuClasses;\n /** An object containing all the labels. */\n labels?: Partial<typeof DEFAULT_LABELS>;\n}\n\nconst HeaderComponent = forwardRef<HTMLButtonElement, HvDropdownButtonProps>(\n (props, ref) => {\n const { open, children, ...others } = props;\n\n const { popperPlacement } = useBaseDropdownContext();\n\n return (\n <HvDropdownButton\n icon\n ref={ref}\n open={open}\n aria-expanded={open}\n aria-haspopup=\"menu\"\n placement={popperPlacement as Placement}\n {...others}\n >\n {children}\n </HvDropdownButton>\n );\n },\n);\n\n/**\n * A dropdown menu is a graphical control element, similar to a list box, that allows the user to choose a value from a list.\n */\nexport const HvDropDownMenu = (props: HvDropDownMenuProps) => {\n const {\n id: idProp,\n classes: classesProp,\n className,\n icon,\n placement = \"right\",\n dataList,\n disablePortal = false,\n onToggle,\n onClick,\n keepOpened = true,\n disabled = false,\n expanded,\n defaultExpanded = false,\n category = \"secondaryGhost\", // TODO - remove and update variant default in v6\n variant,\n size = \"md\",\n labels: labelsProp,\n ...others\n } = useDefaultProps(\"HvDropDownMenu\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const [open, setOpen] = useControlled(expanded, Boolean(defaultExpanded));\n const id = useUniqueId(idProp);\n const focusNodes = getPrevNextFocus(setId(id, \"icon-button\"));\n\n const listId = setId(id, \"list\");\n\n const handleClose = (\n event:\n | React.KeyboardEvent<HTMLUListElement>\n | React.ChangeEvent<HTMLInputElement>\n | React.MouseEvent<HTMLLIElement>,\n ) => {\n // this will only run if uncontrolled\n setOpen(false);\n onToggle?.(event, false);\n };\n\n // If the ESCAPE key is pressed inside the list, the close handler must be called.\n const handleKeyDown: HvListProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"Tab\")) {\n const node = event.shiftKey ? focusNodes.prevFocus : focusNodes.nextFocus;\n if (node) setTimeout(() => node.focus(), 0);\n handleClose(event);\n }\n event.preventDefault();\n };\n\n const setFocusToContent: HvBaseDropdownProps[\"onContainerCreation\"] = (\n containerRef,\n ) => {\n containerRef?.getElementsByTagName(\"li\")[0]?.focus();\n };\n\n const condensed = useMemo(() => dataList.every((el) => !el.icon), [dataList]);\n\n return (\n <HvBaseDropdown\n id={id}\n className={cx(classes.container, className)}\n classes={{\n root: classes.root,\n container: classes.baseContainer,\n }}\n expanded={open && !disabled}\n component={\n <HeaderComponent\n id={setId(id, \"icon-button\")}\n disabled={disabled}\n className={cx(classes.icon, {\n [classes.iconSelected]: open,\n })}\n size={size}\n variant={variant ?? category}\n open={open}\n aria-label={labels.dropdownMenu}\n >\n {icon || <MoreOptionsVertical role=\"presentation\" />}\n </HeaderComponent>\n }\n placement={placement}\n variableWidth\n disablePortal={disablePortal}\n onToggle={(e, s) => {\n // this will only run if uncontrolled\n setOpen(s);\n onToggle?.(e, s);\n }}\n disabled={disabled}\n onContainerCreation={setFocusToContent}\n {...others}\n >\n <HvPanel className={classes.menuListRoot}>\n <HvList\n id={listId}\n values={dataList}\n selectable={false}\n condensed={condensed}\n onClick={(event, item) => {\n if (!keepOpened) handleClose(event);\n onClick?.(event, item);\n }}\n onKeyDown={handleKeyDown}\n classes={{\n root: classes.menuList,\n }}\n />\n </HvPanel>\n </HvBaseDropdown>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA4BA,MAAM,iBAAiB;AAAA,EACrB,cAAc;AAChB;AA2DA,MAAM,kBAAkB;AAAA,EACtB,C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MAAM,QAAQ;AAAA,UAChB;AAAA,QAAA;AAAA,MAAA,GAEJ;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiButton.js","sources":["../../../src/MultiButton/MultiButton.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n isValidElement,\n ReactElement,\n useMemo,\n} from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"MultiButton.js","sources":["../../../src/MultiButton/MultiButton.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n isValidElement,\n ReactElement,\n useMemo,\n} from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\nimport { HvSize } from \"@hitachivantara/uikit-styles\";\n\nimport { HvButtonVariant } from \"../Button\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { staticClasses, useClasses } from \"./MultiButton.styles\";\n\nexport { staticClasses as multiButtonClasses };\nexport type HvMultiButtonClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvMultiButtonProps extends HvBaseProps {\n /** If all the buttons are disabled. */\n disabled?: boolean;\n /** If the MultiButton is to be displayed vertically. */\n vertical?: boolean;\n /** Category of button to use */\n variant?: HvButtonVariant;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvMultiButtonClasses;\n /** Button size. */\n size?: HvSize;\n /** Add a split between buttons */\n split?: boolean;\n}\n\nexport const HvMultiButton = (props: HvMultiButtonProps) => {\n const {\n className,\n children,\n classes: classesProp,\n disabled = false,\n vertical = false,\n variant = \"secondarySubtle\",\n size,\n split,\n ...others\n } = useDefaultProps(\"HvMultiButton\", props);\n const { classes, cx } = useClasses(classesProp);\n\n // Filter children: remove invalid and undefined/null\n const buttons = useMemo(() => {\n const btns: ReactElement[] = [];\n Children.forEach(children, (child) => {\n if (child && isValidElement(child)) {\n btns.push(child);\n }\n });\n return btns;\n }, [children]);\n\n return (\n <div\n className={cx(\n classes.root,\n {\n [classes.multiple]: !split,\n [classes.vertical]: vertical,\n [classes[variant as keyof HvMultiButtonClasses]]: variant, // TODO - remove in v6\n [classes.splitGroup]: split,\n [classes.splitGroupDisabled]: split && disabled,\n },\n className,\n )}\n {...others}\n >\n {buttons.map((child, index) => {\n const childIsSelected = !!child.props.selected;\n return cloneElement(child, {\n key: index,\n variant,\n disabled: disabled || child.props.disabled,\n size,\n className: cx(child.props.className, classes.button, {\n [classes.firstButton]: index === 0,\n [classes.lastButton]: index === buttons.length - 1,\n [classes.selected]: childIsSelected,\n }),\n });\n })}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;AAmCa,MAAA,gBAAgB,CAAC,UAA8B;AACpD,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,WAAW;AAAA,IACX,WAAW;AAAA,IACX,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,iBAAiB,KAAK;AAC1C,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAGxC,QAAA,UAAU,QAAQ,MAAM;AAC5B,UAAM,OAAuB,CAAA;AACpB,aAAA,QAAQ,UAAU,CAAC,UAAU;AAChC,UAAA,SAAS,eAAe,KAAK,GAAG;AAClC,aAAK,KAAK,KAAK;AAAA,MACjB;AAAA,IAAA,CACD;AACM,WAAA;AAAA,EAAA,GACN,CAAC,QAAQ,CAAC;AAGX,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT,QAAQ;AAAA,QACR;AAAA,UACE,CAAC,QAAQ,QAAQ,GAAG,CAAC;AAAA,UACrB,CAAC,QAAQ,QAAQ,GAAG;AAAA,UACpB,CAAC,QAAQ,OAAqC,CAAC,GAAG;AAAA;AAAA,UAClD,CAAC,QAAQ,UAAU,GAAG;AAAA,UACtB,CAAC,QAAQ,kBAAkB,GAAG,SAAS;AAAA,QACzC;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA,MAEH,UAAQ,QAAA,IAAI,CAAC,OAAO,UAAU;AAC7B,cAAM,kBAAkB,CAAC,CAAC,MAAM,MAAM;AACtC,eAAO,aAAa,OAAO;AAAA,UACzB,KAAK;AAAA,UACL;AAAA,UACA,UAAU,YAAY,MAAM,MAAM;AAAA,UAClC;AAAA,UACA,WAAW,GAAG,MAAM,MAAM,WAAW,QAAQ,QAAQ;AAAA,YACnD,CAAC,QAAQ,WAAW,GAAG,UAAU;AAAA,YACjC,CAAC,QAAQ,UAAU,GAAG,UAAU,QAAQ,SAAS;AAAA,YACjD,CAAC,QAAQ,QAAQ,GAAG;AAAA,UAAA,CACrB;AAAA,QAAA,CACF;AAAA,MAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useCallback } from "react";
|
|
3
3
|
import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
|
|
4
|
+
import { getColor } from "@hitachivantara/uikit-styles";
|
|
4
5
|
import { isInvalid } from "../Forms/FormElement/validationStates.js";
|
|
5
6
|
import { useControlled } from "../hooks/useControlled.js";
|
|
6
7
|
import { useUniqueId } from "../hooks/useUniqueId.js";
|
|
@@ -11,6 +12,7 @@ import { HvBaseSwitch } from "../BaseSwitch/BaseSwitch.js";
|
|
|
11
12
|
import { HvFormElement } from "../Forms/FormElement/FormElement.js";
|
|
12
13
|
import { HvLabel } from "../Forms/Label/Label.js";
|
|
13
14
|
import { HvWarningText } from "../Forms/WarningText/WarningText.js";
|
|
15
|
+
const isSemantical = (color) => ["positive", "negative", "warning"].includes(color);
|
|
14
16
|
const HvSwitch = forwardRef(
|
|
15
17
|
(props, ref) => {
|
|
16
18
|
const {
|
|
@@ -34,9 +36,10 @@ const HvSwitch = forwardRef(
|
|
|
34
36
|
statusMessage,
|
|
35
37
|
"aria-errormessage": ariaErrorMessage,
|
|
36
38
|
inputProps,
|
|
39
|
+
color,
|
|
37
40
|
...others
|
|
38
41
|
} = useDefaultProps("HvSwitch", props);
|
|
39
|
-
const { classes, cx } = useClasses(classesProp);
|
|
42
|
+
const { classes, cx, css } = useClasses(classesProp);
|
|
40
43
|
const elementId = useUniqueId(id);
|
|
41
44
|
const [isChecked, setIsChecked] = useControlled(
|
|
42
45
|
checked,
|
|
@@ -114,6 +117,16 @@ const HvSwitch = forwardRef(
|
|
|
114
117
|
"aria-describedby": ariaDescribedBy,
|
|
115
118
|
...inputProps
|
|
116
119
|
},
|
|
120
|
+
...color && {
|
|
121
|
+
classes: {
|
|
122
|
+
switchBase: css({
|
|
123
|
+
"&&&+.HvBaseSwitch-track,&&&.HvBaseSwitch-checked+.HvBaseSwitch-track": {
|
|
124
|
+
backgroundColor: getColor(color),
|
|
125
|
+
borderColor: isSemantical(color) ? getColor(`${color}_120`) : "#00000032"
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
},
|
|
117
130
|
...others
|
|
118
131
|
}
|
|
119
132
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.js","sources":["../../../src/Switch/Switch.tsx"],"sourcesContent":["import { forwardRef, useCallback } from \"react\";\nimport { SwitchProps as MuiSwitchProps } from \"@mui/material/Switch\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseSwitch } from \"../BaseSwitch\";\nimport {\n HvFormElement,\n HvFormStatus,\n HvLabel,\n HvLabelProps,\n HvWarningText,\n} from \"../Forms\";\nimport { isInvalid } from \"../Forms/FormElement/validationStates\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./Switch.styles\";\n\nexport { staticClasses as switchClasses };\n\nexport type HvSwitchClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSwitchProps\n extends Omit<MuiSwitchProps, \"onChange\" | \"classes\"> {\n /**\n * A Jss Object used to override or extend the styles applied to the switch.\n */\n classes?: HvSwitchClasses;\n /**\n * The form element name.\n */\n name?: string;\n /**\n * The value of the form element.\n *\n * Is up to the application's logic when to consider the submission of this value.\n * Generally it should be used only when the switch is neither unchecked nor indeterminate.\n *\n * The default value is \"on\".\n */\n value?: any;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be inputted via inputProps.\n */\n label?: React.ReactNode;\n /**\n * Properties passed on to the label element.\n */\n labelProps?: HvLabelProps;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is not editable.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: boolean;\n /**\n * If `true` the switch is selected, if set to `false` the switch is not selected.\n *\n * When defined the switch state becomes controlled.\n */\n checked?: boolean;\n /**\n * When uncontrolled, defines the initial checked state.\n */\n defaultChecked?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to `checked`, depending of the values of both `required` and `checked`.\n */\n status?: HvFormStatus;\n /**\n * The error message to show when the validation status is \"invalid\".\n *\n * Defaults to \"Required\" when the status is uncontrolled and no `aria-errormessage` is provided.\n */\n statusMessage?: string;\n /**\n * Identifies the element that provides an error message for the switch.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the switch is pressed.\n */\n onChange?: (\n event: React.ChangeEvent<HTMLInputElement>,\n checked: boolean,\n value: any,\n ) => void;\n /**\n * Properties passed on to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /** @ignore */\n ref?: MuiSwitchProps[\"ref\"];\n /** @ignore */\n component?: MuiSwitchProps[\"component\"];\n}\n\n/**\n * A Switch is <b>binary</b> and work as a digital on/off button.\n *\n * Use when two states are <b>opposite</b> and to trigger immediate\n * changes in the system.\n */\nexport const HvSwitch = forwardRef<HTMLButtonElement, HvSwitchProps>(\n (props, ref) => {\n const {\n classes: classesProp,\n className,\n\n id,\n name,\n value = \"on\",\n required = false,\n readOnly = false,\n disabled = false,\n\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n labelProps,\n\n checked,\n defaultChecked = false,\n\n onChange,\n\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n\n inputProps,\n\n ...others\n } = useDefaultProps(\"HvSwitch\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id);\n\n const [isChecked, setIsChecked] = useControlled(\n checked,\n Boolean(defaultChecked),\n );\n\n const [validationState, setValidationState] = useControlled<HvFormStatus>(\n status,\n \"standBy\",\n );\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const onLocalChange = useCallback(\n (evt: React.ChangeEvent<HTMLInputElement>, newChecked: boolean) => {\n setIsChecked(() => {\n // this will only run if uncontrolled\n if (required && !newChecked) {\n setValidationState(\"invalid\");\n } else {\n setValidationState(\"valid\");\n }\n\n return newChecked;\n });\n\n onChange?.(evt, newChecked, value);\n },\n [onChange, required, setIsChecked, setValidationState, value],\n );\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const isStateInvalid = isInvalid(validationState);\n\n let errorMessageId: string | undefined;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(classes.root, className)}\n >\n {label && (\n <HvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={classes.label}\n {...labelProps}\n />\n )}\n <div\n className={cx(classes.switchContainer, {\n [classes.invalidSwitch]: isStateInvalid,\n })}\n >\n <HvBaseSwitch\n ref={ref}\n id={label ? setId(elementId, \"input\") : setId(id, \"input\")}\n name={name}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n onChange={onLocalChange}\n value={value}\n checked={isChecked}\n inputProps={{\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...inputProps,\n }}\n {...others}\n />\n </div>\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n className={classes.error}\n disableBorder\n disableAdornment\n hideText\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n },\n);\n"],"names":[],"mappings":";;;;;;;;;;;;;AA0HO,MAAM,WAAW;AAAA,EACtB,CAAC,OAAO,QAAQ;AACR,UAAA;AAAA,MACJ,SAAS;AAAA,MACT;AAAA,MAEA;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MAEX;AAAA,MACA,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB;AAAA,MAEA;AAAA,MACA,iBAAiB;AAAA,MAEjB;AAAA,MAEA;AAAA,MACA;AAAA,MACA,qBAAqB;AAAA,MAErB;AAAA,MAEA,GAAG;AAAA,IAAA,IACD,gBAAgB,YAAY,KAAK;AAErC,UAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAExC,UAAA,YAAY,YAAY,EAAE;AAE1B,UAAA,CAAC,WAAW,YAAY,IAAI;AAAA,MAChC;AAAA,MACA,QAAQ,cAAc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AAO,IAAI,MAAM,IAAI,OAAO;AAAA,kBACzD;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA,UAAU;AAAA,kBACV;AAAA,kBACA,SAAS;AAAA,kBACT,YAAY;AAAA,oBACV,gBAAgB,iBAAiB,OAAO;AAAA,oBACxC,qBAAqB;AAAA,oBACrB,cAAc;AAAA,oBACd,mBAAmB;AAAA,oBACnB,oBAAoB;AAAA,oBACpB,GAAG;AAAA,kBACL;AAAA,kBACC,GAAG;AAAA,gBAAA;AAAA,cACN;AAAA,YAAA;AAAA,UACF;AAAA,UACC,gBACC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,IAAI,MAAM,WAAW,OAAO;AAAA,cAC5B,WAAW,QAAQ;AAAA,cACnB,eAAa;AAAA,cACb,kBAAgB;AAAA,cAChB,UAAQ;AAAA,cAEP,UAAA;AAAA,YAAA;AAAA,UACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;"}
|
|
1
|
+
{"version":3,"file":"Switch.js","sources":["../../../src/Switch/Switch.tsx"],"sourcesContent":["import { forwardRef, useCallback } from \"react\";\nimport { SwitchProps as MuiSwitchProps } from \"@mui/material/Switch\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\nimport { getColor, HvColorAny } from \"@hitachivantara/uikit-styles\";\n\nimport { HvBaseSwitch } from \"../BaseSwitch\";\nimport {\n HvFormElement,\n HvFormStatus,\n HvLabel,\n HvLabelProps,\n HvWarningText,\n} from \"../Forms\";\nimport { isInvalid } from \"../Forms/FormElement/validationStates\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./Switch.styles\";\n\nexport { staticClasses as switchClasses };\n\nexport type HvSwitchClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSwitchProps\n extends Omit<MuiSwitchProps, \"color\" | \"onChange\" | \"classes\"> {\n /**\n * A Jss Object used to override or extend the styles applied to the switch.\n */\n classes?: HvSwitchClasses;\n /**\n * The form element name.\n */\n name?: string;\n /**\n * The value of the form element.\n *\n * Is up to the application's logic when to consider the submission of this value.\n * Generally it should be used only when the switch is neither unchecked nor indeterminate.\n *\n * The default value is \"on\".\n */\n value?: any;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be inputted via inputProps.\n */\n label?: React.ReactNode;\n /**\n * Properties passed on to the label element.\n */\n labelProps?: HvLabelProps;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is not editable.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: boolean;\n /**\n * If `true` the switch is selected, if set to `false` the switch is not selected.\n *\n * When defined the switch state becomes controlled.\n */\n checked?: boolean;\n /**\n * When uncontrolled, defines the initial checked state.\n */\n defaultChecked?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to `checked`, depending of the values of both `required` and `checked`.\n */\n status?: HvFormStatus;\n /**\n * The error message to show when the validation status is \"invalid\".\n *\n * Defaults to \"Required\" when the status is uncontrolled and no `aria-errormessage` is provided.\n */\n statusMessage?: string;\n /**\n * Identifies the element that provides an error message for the switch.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the switch is pressed.\n */\n onChange?: (\n event: React.ChangeEvent<HTMLInputElement>,\n checked: boolean,\n value: any,\n ) => void;\n /**\n * Properties passed on to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /** @ignore */\n ref?: MuiSwitchProps[\"ref\"];\n /** @ignore */\n component?: MuiSwitchProps[\"component\"];\n /** Color applied to the switch. */\n color?: HvColorAny;\n}\n\nconst isSemantical = (color: HvColorAny) =>\n [\"positive\", \"negative\", \"warning\"].includes(color);\n\n/**\n * A Switch is <b>binary</b> and work as a digital on/off button.\n *\n * Use when two states are <b>opposite</b> and to trigger immediate\n * changes in the system.\n */\nexport const HvSwitch = forwardRef<HTMLButtonElement, HvSwitchProps>(\n (props, ref) => {\n const {\n classes: classesProp,\n className,\n\n id,\n name,\n value = \"on\",\n required = false,\n readOnly = false,\n disabled = false,\n\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n labelProps,\n\n checked,\n defaultChecked = false,\n\n onChange,\n\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n\n inputProps,\n\n color,\n\n ...others\n } = useDefaultProps(\"HvSwitch\", props);\n\n const { classes, cx, css } = useClasses(classesProp);\n\n const elementId = useUniqueId(id);\n\n const [isChecked, setIsChecked] = useControlled(\n checked,\n Boolean(defaultChecked),\n );\n\n const [validationState, setValidationState] = useControlled<HvFormStatus>(\n status,\n \"standBy\",\n );\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const onLocalChange = useCallback(\n (evt: React.ChangeEvent<HTMLInputElement>, newChecked: boolean) => {\n setIsChecked(() => {\n // this will only run if uncontrolled\n if (required && !newChecked) {\n setValidationState(\"invalid\");\n } else {\n setValidationState(\"valid\");\n }\n\n return newChecked;\n });\n\n onChange?.(evt, newChecked, value);\n },\n [onChange, required, setIsChecked, setValidationState, value],\n );\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const isStateInvalid = isInvalid(validationState);\n\n let errorMessageId: string | undefined;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(classes.root, className)}\n >\n {label && (\n <HvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={classes.label}\n {...labelProps}\n />\n )}\n <div\n className={cx(classes.switchContainer, {\n [classes.invalidSwitch]: isStateInvalid,\n })}\n >\n <HvBaseSwitch\n ref={ref}\n id={label ? setId(elementId, \"input\") : setId(id, \"input\")}\n name={name}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n onChange={onLocalChange}\n value={value}\n checked={isChecked}\n inputProps={{\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...inputProps,\n }}\n {...(color && {\n classes: {\n switchBase: css({\n \"&&&+.HvBaseSwitch-track,&&&.HvBaseSwitch-checked+.HvBaseSwitch-track\":\n {\n backgroundColor: getColor(color),\n borderColor: isSemantical(color)\n ? getColor(`${color}_120`)\n : \"#00000032\",\n },\n }),\n },\n })}\n {...others}\n />\n </div>\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n className={classes.error}\n disableBorder\n disableAdornment\n hideText\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n },\n);\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAuHA,MAAM,eAAe,CAAC,UACpB,CAAC,YAAY,YAAY,SAAS,EAAE,SAAS,KAAK;AAQ7C,MAAM,WAAW;AAAA,EACtB,CAAC,OAAO,QAAQ;AACR,UAAA;AAAA,MACJ,SAAS;AAAA,MACT;AAAA,MAEA;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MAEX;AAAA,MACA,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB;AAAA,MAE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31 } from "./BulkActions/BulkActions.styl
|
|
|
116
116
|
import { HvBulkActions } from "./BulkActions/BulkActions.js";
|
|
117
117
|
import { HvButton } from "./Button/Button.js";
|
|
118
118
|
import { staticClasses as staticClasses32 } from "./Button/Button.styles.js";
|
|
119
|
-
import { buttonRadius, buttonSize, buttonVariant } from "./Button/types.js";
|
|
120
119
|
import { staticClasses as staticClasses33 } from "./Calendar/Calendar.styles.js";
|
|
121
120
|
import { HvCalendar } from "./Calendar/Calendar.js";
|
|
122
121
|
import { staticClasses as staticClasses34 } from "./Calendar/CalendarHeader/CalendarHeader.styles.js";
|
|
@@ -489,9 +488,6 @@ export {
|
|
|
489
488
|
staticClasses31 as bulkActionsClasses,
|
|
490
489
|
staticClasses2 as buttonBaseClasses,
|
|
491
490
|
staticClasses32 as buttonClasses,
|
|
492
|
-
buttonRadius,
|
|
493
|
-
buttonSize,
|
|
494
|
-
buttonVariant,
|
|
495
491
|
staticClasses33 as calendarClasses,
|
|
496
492
|
staticClasses34 as calendarHeaderClasses,
|
|
497
493
|
staticClasses35 as cardClasses,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ import { HvColor } from '@hitachivantara/uikit-styles';
|
|
|
46
46
|
import { HvColorAny } from '@hitachivantara/uikit-styles';
|
|
47
47
|
import { HvExtraDeepProps } from '@hitachivantara/uikit-react-shared';
|
|
48
48
|
import { HvExtraProps } from '@hitachivantara/uikit-react-shared';
|
|
49
|
+
import { HvRadius } from '@hitachivantara/uikit-styles';
|
|
49
50
|
import { HvSemanticColor } from '@hitachivantara/uikit-styles';
|
|
50
51
|
import { HvSize } from '@hitachivantara/uikit-styles';
|
|
51
52
|
import { HvSupportColor } from '@hitachivantara/uikit-styles';
|
|
@@ -442,6 +443,7 @@ export declare const buttonClasses: {
|
|
|
442
443
|
focusVisible: string;
|
|
443
444
|
disabled: string;
|
|
444
445
|
icon: string;
|
|
446
|
+
contained: string;
|
|
445
447
|
subtle: string;
|
|
446
448
|
ghost: string;
|
|
447
449
|
semantic: string;
|
|
@@ -453,12 +455,6 @@ export declare const buttonClasses: {
|
|
|
453
455
|
secondary: string;
|
|
454
456
|
};
|
|
455
457
|
|
|
456
|
-
export declare const buttonRadius: readonly ["none", "base", "round", "circle", "full"];
|
|
457
|
-
|
|
458
|
-
export declare const buttonSize: readonly ["xs", "sm", "md", "lg", "xl"];
|
|
459
|
-
|
|
460
|
-
export declare const buttonVariant: readonly ["primary", "primarySubtle", "primaryGhost", "positive", "positiveSubtle", "positiveGhost", "negative", "negativeSubtle", "negativeGhost", "warning", "warningSubtle", "warningGhost", "secondarySubtle", "secondaryGhost", "semantic", "secondary", "ghost"];
|
|
461
|
-
|
|
462
458
|
export declare const calendarClasses: {
|
|
463
459
|
root: string;
|
|
464
460
|
rangeCalendarContainer: string;
|
|
@@ -2013,7 +2009,7 @@ export declare interface HvBulkActionsProps extends HvBaseProps {
|
|
|
2013
2009
|
*/
|
|
2014
2010
|
export declare const HvButton: <C extends ElementType<any, keyof JSX_2.IntrinsicElements> = "button">(props: {
|
|
2015
2011
|
/** Use the variant prop to change the visual style of the button. */
|
|
2016
|
-
variant?:
|
|
2012
|
+
variant?: HvButtonVariant | undefined;
|
|
2017
2013
|
/** Whether the button is an icon-only button. */
|
|
2018
2014
|
icon?: boolean | undefined;
|
|
2019
2015
|
/** Whether the button is disabled or not. */
|
|
@@ -2024,6 +2020,8 @@ export declare const HvButton: <C extends ElementType<any, keyof JSX_2.Intrinsic
|
|
|
2024
2020
|
startIcon?: React.ReactNode;
|
|
2025
2021
|
/** Element placed after the children. */
|
|
2026
2022
|
endIcon?: React.ReactNode;
|
|
2023
|
+
/** Color of the button. */
|
|
2024
|
+
color?: HvColorAny | undefined;
|
|
2027
2025
|
/** Button size. */
|
|
2028
2026
|
size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
|
|
2029
2027
|
/** Button border radius. */
|
|
@@ -2038,6 +2036,7 @@ export declare const HvButton: <C extends ElementType<any, keyof JSX_2.Intrinsic
|
|
|
2038
2036
|
focusVisible: string;
|
|
2039
2037
|
disabled: string;
|
|
2040
2038
|
icon: string;
|
|
2039
|
+
contained: string;
|
|
2041
2040
|
subtle: string;
|
|
2042
2041
|
ghost: string;
|
|
2043
2042
|
semantic: string;
|
|
@@ -2060,8 +2059,8 @@ export declare const HvButton: <C extends ElementType<any, keyof JSX_2.Intrinsic
|
|
|
2060
2059
|
component?: C | undefined;
|
|
2061
2060
|
} & {
|
|
2062
2061
|
children?: ReactNode;
|
|
2063
|
-
} & (Omit<PropsWithoutRef<ComponentProps<C>>, "classes" | "disabled" | "icon" | "selected" | "variant" | "size" | "component" | "className" | "radius" | "focusableWhenDisabled" | "startIcon" | "endIcon" | "overrideIconColors"> extends infer T ? T extends Omit<PropsWithoutRef<ComponentProps<C>>, "classes" | "disabled" | "icon" | "selected" | "variant" | "size" | "component" | "className" | "radius" | "focusableWhenDisabled" | "startIcon" | "endIcon" | "overrideIconColors"> ? T extends any ? T : never : never : never) & {
|
|
2064
|
-
ref?: PolymorphicRef<C> | undefined;
|
|
2062
|
+
} & (Omit<PropsWithoutRef<ComponentProps<C>>, "color" | "classes" | "disabled" | "icon" | "selected" | "variant" | "size" | "component" | "className" | "radius" | "focusableWhenDisabled" | "startIcon" | "endIcon" | "overrideIconColors"> extends infer T ? T extends Omit<PropsWithoutRef<ComponentProps<C>>, "color" | "classes" | "disabled" | "icon" | "selected" | "variant" | "size" | "component" | "className" | "radius" | "focusableWhenDisabled" | "startIcon" | "endIcon" | "overrideIconColors"> ? T extends any ? T : never : never : never) & {
|
|
2063
|
+
ref?: PolymorphicRef<C> | undefined; /** Class names to be applied. */
|
|
2065
2064
|
} & RefAttributes<unknown>) => ReactElement<any, string | JSXElementConstructor<any>> | null;
|
|
2066
2065
|
|
|
2067
2066
|
/**
|
|
@@ -2123,10 +2122,12 @@ export declare type HvButtonProps<C extends React.ElementType = "button"> = Poly
|
|
|
2123
2122
|
startIcon?: React.ReactNode;
|
|
2124
2123
|
/** Element placed after the children. */
|
|
2125
2124
|
endIcon?: React.ReactNode;
|
|
2125
|
+
/** Color of the button. */
|
|
2126
|
+
color?: HvColorAny;
|
|
2126
2127
|
/** Button size. */
|
|
2127
|
-
size?:
|
|
2128
|
+
size?: HvSize;
|
|
2128
2129
|
/** Button border radius. */
|
|
2129
|
-
radius?:
|
|
2130
|
+
radius?: HvRadius;
|
|
2130
2131
|
/** Defines the default colors of the button are forced into the icon. */
|
|
2131
2132
|
overrideIconColors?: boolean;
|
|
2132
2133
|
/** A Jss Object used to override or extend the styles applied. */
|
|
@@ -2141,11 +2142,13 @@ export declare type HvButtonProps<C extends React.ElementType = "button"> = Poly
|
|
|
2141
2142
|
focusableWhenDisabled?: boolean;
|
|
2142
2143
|
}>;
|
|
2143
2144
|
|
|
2144
|
-
|
|
2145
|
+
/** @deprecated use `HvRadius` */
|
|
2146
|
+
export declare type HvButtonRadius = HvRadius;
|
|
2145
2147
|
|
|
2146
|
-
|
|
2148
|
+
/** @deprecated use `HvSize` */
|
|
2149
|
+
export declare type HvButtonSize = HvSize;
|
|
2147
2150
|
|
|
2148
|
-
export declare type HvButtonVariant =
|
|
2151
|
+
export declare type HvButtonVariant = "contained" | "subtle" | "ghost" | `primary${TypeSuffix}` | `secondary${TypeSuffix}` | `positive${TypeSuffix}` | `negative${TypeSuffix}` | `warning${TypeSuffix}` | "semantic";
|
|
2149
2152
|
|
|
2150
2153
|
export declare const HvCalendar: (props: HvCalendarProps) => JSX_3.Element;
|
|
2151
2154
|
|
|
@@ -3252,7 +3255,7 @@ export declare interface HvDropDownMenuProps extends HvBaseProps<HTMLDivElement,
|
|
|
3252
3255
|
/** The variant to be used in the header. */
|
|
3253
3256
|
variant?: HvButtonVariant;
|
|
3254
3257
|
/** Button size. */
|
|
3255
|
-
size?:
|
|
3258
|
+
size?: HvSize;
|
|
3256
3259
|
/** A Jss Object used to override or extend the styles applied to the component. */
|
|
3257
3260
|
classes?: HvDropDownMenuClasses;
|
|
3258
3261
|
/** An object containing all the labels. */
|
|
@@ -4131,7 +4134,7 @@ export declare const HvIconButton: <C extends ElementType<any, keyof JSX_2.Intri
|
|
|
4131
4134
|
component?: C | undefined;
|
|
4132
4135
|
} & {
|
|
4133
4136
|
children?: ReactNode;
|
|
4134
|
-
} & (Omit<PropsWithoutRef<ComponentProps<C>>, "classes" | "disabled" | "title" | "selected" | "variant" | "size" | "component" | "className" | "radius" | "placement" | "overrideIconColors" | "enterDelay" | "tooltipProps" | Exclude<keyof (Omit<PropsWithoutRef<ComponentProps<C>>, "classes" | "disabled" | "icon" | "selected" | "variant" | "size" | "component" | "className" | "radius" | "focusableWhenDisabled" | "startIcon" | "endIcon" | "overrideIconColors"> extends infer T ? T extends Omit<PropsWithoutRef<ComponentProps<C>>, "classes" | "disabled" | "icon" | "selected" | "variant" | "size" | "component" | "className" | "radius" | "focusableWhenDisabled" | "startIcon" | "endIcon" | "overrideIconColors"> ? T extends any ? T : never : never : never), "icon" | "title" | "children" | "ref" | "component" | "focusableWhenDisabled" | "startIcon" | "endIcon">> extends infer T_1 ? T_1 extends Omit<PropsWithoutRef<ComponentProps<C>>, "classes" | "disabled" | "title" | "selected" | "variant" | "size" | "component" | "className" | "radius" | "placement" | "overrideIconColors" | "enterDelay" | "tooltipProps" | Exclude<keyof (Omit<PropsWithoutRef<ComponentProps<C>>, "classes" | "disabled" | "icon" | "selected" | "variant" | "size" | "component" | "className" | "radius" | "focusableWhenDisabled" | "startIcon" | "endIcon" | "overrideIconColors"> extends infer T_2 ? T_2 extends Omit<PropsWithoutRef<ComponentProps<C>>, "classes" | "disabled" | "icon" | "selected" | "variant" | "size" | "component" | "className" | "radius" | "focusableWhenDisabled" | "startIcon" | "endIcon" | "overrideIconColors"> ? T_2 extends any ? T_2 : never : never : never), "icon" | "title" | "children" | "ref" | "component" | "focusableWhenDisabled" | "startIcon" | "endIcon">> ? T_1 extends any ? T_1 : never : never : never) & {
|
|
4137
|
+
} & (Omit<PropsWithoutRef<ComponentProps<C>>, "color" | "classes" | "disabled" | "title" | "selected" | "variant" | "size" | "component" | "className" | "radius" | "placement" | "overrideIconColors" | "enterDelay" | "tooltipProps" | Exclude<keyof (Omit<PropsWithoutRef<ComponentProps<C>>, "color" | "classes" | "disabled" | "icon" | "selected" | "variant" | "size" | "component" | "className" | "radius" | "focusableWhenDisabled" | "startIcon" | "endIcon" | "overrideIconColors"> extends infer T ? T extends Omit<PropsWithoutRef<ComponentProps<C>>, "color" | "classes" | "disabled" | "icon" | "selected" | "variant" | "size" | "component" | "className" | "radius" | "focusableWhenDisabled" | "startIcon" | "endIcon" | "overrideIconColors"> ? T extends any ? T : never : never : never), "icon" | "title" | "children" | "ref" | "component" | "focusableWhenDisabled" | "startIcon" | "endIcon">> extends infer T_1 ? T_1 extends Omit<PropsWithoutRef<ComponentProps<C>>, "color" | "classes" | "disabled" | "title" | "selected" | "variant" | "size" | "component" | "className" | "radius" | "placement" | "overrideIconColors" | "enterDelay" | "tooltipProps" | Exclude<keyof (Omit<PropsWithoutRef<ComponentProps<C>>, "color" | "classes" | "disabled" | "icon" | "selected" | "variant" | "size" | "component" | "className" | "radius" | "focusableWhenDisabled" | "startIcon" | "endIcon" | "overrideIconColors"> extends infer T_2 ? T_2 extends Omit<PropsWithoutRef<ComponentProps<C>>, "color" | "classes" | "disabled" | "icon" | "selected" | "variant" | "size" | "component" | "className" | "radius" | "focusableWhenDisabled" | "startIcon" | "endIcon" | "overrideIconColors"> ? T_2 extends any ? T_2 : never : never : never), "icon" | "title" | "children" | "ref" | "component" | "focusableWhenDisabled" | "startIcon" | "endIcon">> ? T_1 extends any ? T_1 : never : never : never) & {
|
|
4135
4138
|
ref?: PolymorphicRef<C> | undefined;
|
|
4136
4139
|
} & RefAttributes<unknown>) => ReactElement<any, string | JSXElementConstructor<any>> | null;
|
|
4137
4140
|
|
|
@@ -4725,7 +4728,7 @@ export declare interface HvMultiButtonProps extends HvBaseProps {
|
|
|
4725
4728
|
/** A Jss Object used to override or extend the styles applied to the component. */
|
|
4726
4729
|
classes?: HvMultiButtonClasses;
|
|
4727
4730
|
/** Button size. */
|
|
4728
|
-
size?:
|
|
4731
|
+
size?: HvSize;
|
|
4729
4732
|
/** Add a split between buttons */
|
|
4730
4733
|
split?: boolean;
|
|
4731
4734
|
}
|
|
@@ -5427,6 +5430,8 @@ export declare interface HvRadioProps extends Omit<RadioProps, "onChange" | "cla
|
|
|
5427
5430
|
|
|
5428
5431
|
export declare type HvRadioStatus = "standBy" | "valid" | "invalid";
|
|
5429
5432
|
|
|
5433
|
+
export { HvRadius }
|
|
5434
|
+
|
|
5430
5435
|
export declare const HvRightControl: ({ id, classes: classesProp, className, children, values, onSort, hideSortBy, sortProps, ...others }: HvRightControlProps) => JSX_3.Element;
|
|
5431
5436
|
|
|
5432
5437
|
export declare type HvRightControlClasses = ExtractNames<typeof useClasses_57>;
|
|
@@ -6118,7 +6123,7 @@ export declare interface HvSwitchColumnCellProp {
|
|
|
6118
6123
|
switchProps?: HvBaseSwitchProps;
|
|
6119
6124
|
}
|
|
6120
6125
|
|
|
6121
|
-
export declare interface HvSwitchProps extends Omit<SwitchProps, "onChange" | "classes"> {
|
|
6126
|
+
export declare interface HvSwitchProps extends Omit<SwitchProps, "color" | "onChange" | "classes"> {
|
|
6122
6127
|
/**
|
|
6123
6128
|
* A Jss Object used to override or extend the styles applied to the switch.
|
|
6124
6129
|
*/
|
|
@@ -6202,6 +6207,8 @@ export declare interface HvSwitchProps extends Omit<SwitchProps, "onChange" | "c
|
|
|
6202
6207
|
ref?: SwitchProps["ref"];
|
|
6203
6208
|
/** @ignore */
|
|
6204
6209
|
component?: SwitchProps["component"];
|
|
6210
|
+
/** Color applied to the switch. */
|
|
6211
|
+
color?: HvColorAny;
|
|
6205
6212
|
}
|
|
6206
6213
|
|
|
6207
6214
|
export declare const HvTab: (props: HvTabProps) => JSX_3.Element;
|
|
@@ -8343,6 +8350,8 @@ declare interface TreeViewNode {
|
|
|
8343
8350
|
|
|
8344
8351
|
declare type TreeViewSelectionValue<Multiple extends boolean | undefined> = Multiple extends true ? string[] : string | null;
|
|
8345
8352
|
|
|
8353
|
+
declare type TypeSuffix = "" | "Subtle" | "Ghost";
|
|
8354
|
+
|
|
8346
8355
|
export declare const typographyClasses: {
|
|
8347
8356
|
root: string;
|
|
8348
8357
|
disabled: string;
|
|
@@ -8887,7 +8896,7 @@ declare const useClasses_129: (classesProp?: Partial<Record<"content" | "header"
|
|
|
8887
8896
|
readonly cx: (...args: any) => string;
|
|
8888
8897
|
};
|
|
8889
8898
|
|
|
8890
|
-
declare const useClasses_13: (classesProp?: Partial<Record<"secondary" | "primary" | "root" | "disabled" | "semantic" | "icon" | "secondarySubtle" | "ghost" | "secondaryGhost" | "primaryGhost" | "primarySubtle" | "subtle" | "focusVisible" | "startIcon" | "endIcon", string>>, addStatic?: boolean) => {
|
|
8899
|
+
declare const useClasses_13: (classesProp?: Partial<Record<"secondary" | "primary" | "root" | "disabled" | "semantic" | "icon" | "secondarySubtle" | "ghost" | "secondaryGhost" | "contained" | "primaryGhost" | "primarySubtle" | "subtle" | "focusVisible" | "startIcon" | "endIcon", string>>, addStatic?: boolean) => {
|
|
8891
8900
|
readonly classes: {
|
|
8892
8901
|
root: string;
|
|
8893
8902
|
startIcon: string;
|
|
@@ -8895,6 +8904,7 @@ declare const useClasses_13: (classesProp?: Partial<Record<"secondary" | "primar
|
|
|
8895
8904
|
focusVisible: string;
|
|
8896
8905
|
disabled: string;
|
|
8897
8906
|
icon: string;
|
|
8907
|
+
contained: string;
|
|
8898
8908
|
subtle: string;
|
|
8899
8909
|
ghost: string;
|
|
8900
8910
|
semantic: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/uikit-react-core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.79.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Hitachi Vantara UI Kit Team",
|
|
6
6
|
"description": "Core React components for the NEXT Design System.",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@emotion/cache": "^11.11.0",
|
|
34
34
|
"@emotion/serialize": "^1.1.2",
|
|
35
|
-
"@hitachivantara/uikit-react-icons": "^5.12.
|
|
36
|
-
"@hitachivantara/uikit-react-shared": "^5.3.
|
|
37
|
-
"@hitachivantara/uikit-react-utils": "^0.2.
|
|
38
|
-
"@hitachivantara/uikit-styles": "^5.
|
|
35
|
+
"@hitachivantara/uikit-react-icons": "^5.12.5",
|
|
36
|
+
"@hitachivantara/uikit-react-shared": "^5.3.10",
|
|
37
|
+
"@hitachivantara/uikit-react-utils": "^0.2.10",
|
|
38
|
+
"@hitachivantara/uikit-styles": "^5.37.0",
|
|
39
39
|
"@internationalized/date": "^3.2.0",
|
|
40
40
|
"@mui/base": "^5.0.0-beta.40",
|
|
41
41
|
"@popperjs/core": "^2.11.8",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"access": "public",
|
|
63
63
|
"directory": "package"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "2245f2d1fa289ab8eab0c4efa73729e121bb4cf3",
|
|
66
66
|
"exports": {
|
|
67
67
|
".": {
|
|
68
68
|
"types": "./dist/types/index.d.ts",
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const buttonVariant = [
|
|
4
|
-
"primary",
|
|
5
|
-
"primarySubtle",
|
|
6
|
-
"primaryGhost",
|
|
7
|
-
"positive",
|
|
8
|
-
"positiveSubtle",
|
|
9
|
-
"positiveGhost",
|
|
10
|
-
"negative",
|
|
11
|
-
"negativeSubtle",
|
|
12
|
-
"negativeGhost",
|
|
13
|
-
"warning",
|
|
14
|
-
"warningSubtle",
|
|
15
|
-
"warningGhost",
|
|
16
|
-
"secondarySubtle",
|
|
17
|
-
"secondaryGhost",
|
|
18
|
-
"semantic",
|
|
19
|
-
// deprecated props
|
|
20
|
-
"secondary",
|
|
21
|
-
"ghost"
|
|
22
|
-
];
|
|
23
|
-
const buttonSize = ["xs", "sm", "md", "lg", "xl"];
|
|
24
|
-
const buttonRadius = [
|
|
25
|
-
"none",
|
|
26
|
-
"base",
|
|
27
|
-
"round",
|
|
28
|
-
"circle",
|
|
29
|
-
"full"
|
|
30
|
-
];
|
|
31
|
-
exports.buttonRadius = buttonRadius;
|
|
32
|
-
exports.buttonSize = buttonSize;
|
|
33
|
-
exports.buttonVariant = buttonVariant;
|
package/dist/esm/Button/types.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const buttonVariant = [
|
|
2
|
-
"primary",
|
|
3
|
-
"primarySubtle",
|
|
4
|
-
"primaryGhost",
|
|
5
|
-
"positive",
|
|
6
|
-
"positiveSubtle",
|
|
7
|
-
"positiveGhost",
|
|
8
|
-
"negative",
|
|
9
|
-
"negativeSubtle",
|
|
10
|
-
"negativeGhost",
|
|
11
|
-
"warning",
|
|
12
|
-
"warningSubtle",
|
|
13
|
-
"warningGhost",
|
|
14
|
-
"secondarySubtle",
|
|
15
|
-
"secondaryGhost",
|
|
16
|
-
"semantic",
|
|
17
|
-
// deprecated props
|
|
18
|
-
"secondary",
|
|
19
|
-
"ghost"
|
|
20
|
-
];
|
|
21
|
-
const buttonSize = ["xs", "sm", "md", "lg", "xl"];
|
|
22
|
-
const buttonRadius = [
|
|
23
|
-
"none",
|
|
24
|
-
"base",
|
|
25
|
-
"round",
|
|
26
|
-
"circle",
|
|
27
|
-
"full"
|
|
28
|
-
];
|
|
29
|
-
export {
|
|
30
|
-
buttonRadius,
|
|
31
|
-
buttonSize,
|
|
32
|
-
buttonVariant
|
|
33
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/Button/types.ts"],"sourcesContent":["export const buttonVariant = [\n \"primary\",\n \"primarySubtle\",\n \"primaryGhost\",\n \"positive\",\n \"positiveSubtle\",\n \"positiveGhost\",\n \"negative\",\n \"negativeSubtle\",\n \"negativeGhost\",\n \"warning\",\n \"warningSubtle\",\n \"warningGhost\",\n \"secondarySubtle\",\n \"secondaryGhost\",\n \"semantic\",\n // deprecated props\n \"secondary\",\n \"ghost\",\n] as const;\nexport type HvButtonVariant = (typeof buttonVariant)[number];\n\nexport const buttonSize = [\"xs\", \"sm\", \"md\", \"lg\", \"xl\"] as const;\nexport type HvButtonSize = (typeof buttonSize)[number];\n\nexport const buttonRadius = [\n \"none\",\n \"base\",\n \"round\",\n \"circle\",\n \"full\",\n] as const;\nexport type HvButtonRadius = (typeof buttonRadius)[number];\n"],"names":[],"mappings":"AAAO,MAAM,gBAAgB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AACF;AAGO,MAAM,aAAa,CAAC,MAAM,MAAM,MAAM,MAAM,IAAI;AAGhD,MAAM,eAAe;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;"}
|