@hitachivantara/uikit-react-core 5.77.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/Footer/Footer.cjs +1 -1
- package/dist/cjs/Loading/Loading.styles.cjs +4 -2
- package/dist/cjs/MultiButton/MultiButton.cjs +12 -39
- package/dist/cjs/MultiButton/MultiButton.styles.cjs +25 -56
- package/dist/cjs/Select/Select.styles.cjs +1 -0
- package/dist/cjs/Switch/Switch.cjs +14 -1
- package/dist/cjs/Table/TableCell/TableCell.styles.cjs +3 -0
- package/dist/cjs/Table/TableHeader/TableHeader.styles.cjs +3 -0
- package/dist/cjs/Table/TableRow/TableRow.styles.cjs +1 -0
- package/dist/cjs/Table/hooks/useRowExpand.cjs +3 -3
- package/dist/cjs/Tooltip/Tooltip.styles.cjs +12 -6
- 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/Footer/Footer.js +1 -1
- package/dist/esm/Footer/Footer.js.map +1 -1
- package/dist/esm/Loading/Loading.styles.js +4 -2
- package/dist/esm/Loading/Loading.styles.js.map +1 -1
- package/dist/esm/MultiButton/MultiButton.js +15 -42
- package/dist/esm/MultiButton/MultiButton.js.map +1 -1
- package/dist/esm/MultiButton/MultiButton.styles.js +25 -56
- package/dist/esm/MultiButton/MultiButton.styles.js.map +1 -1
- package/dist/esm/Select/Select.styles.js +1 -0
- package/dist/esm/Select/Select.styles.js.map +1 -1
- package/dist/esm/Switch/Switch.js +14 -1
- package/dist/esm/Switch/Switch.js.map +1 -1
- package/dist/esm/Table/TableCell/TableCell.styles.js +3 -0
- package/dist/esm/Table/TableCell/TableCell.styles.js.map +1 -1
- package/dist/esm/Table/TableHeader/TableHeader.styles.js +3 -0
- package/dist/esm/Table/TableHeader/TableHeader.styles.js.map +1 -1
- package/dist/esm/Table/TableRow/TableRow.styles.js +1 -0
- package/dist/esm/Table/TableRow/TableRow.styles.js.map +1 -1
- package/dist/esm/Table/hooks/useRowExpand.js +4 -4
- package/dist/esm/Table/hooks/useRowExpand.js.map +1 -1
- package/dist/esm/Tooltip/Tooltip.js.map +1 -1
- package/dist/esm/Tooltip/Tooltip.styles.js +12 -6
- package/dist/esm/Tooltip/Tooltip.styles.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 +39 -34
- 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
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,OAA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,QAC7C;AAAA,UACE,CAAC,QAAQ,IAAI,GAAG;AAAA,UAChB,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;AAA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,QAGF;AAAA,EACF,IAAI,EAAE,QAAQ,QAAQ,UAAU,KAAK;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;AA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AAAA,UACvB;AAAA,UACA,WAAW;AAAA,UACX,SAAS;AAAA,YACP,MAAM,QAAQ;AAAA,UAChB;AAAA,QAAA;AAAA,MAAA,GAEJ;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -8,7 +8,7 @@ import { HvTypography } from "../Typography/Typography.js";
|
|
|
8
8
|
const HvFooter = (props) => {
|
|
9
9
|
const {
|
|
10
10
|
name = "Hitachi Vantara",
|
|
11
|
-
copyright = `© Hitachi Vantara
|
|
11
|
+
copyright = `© Hitachi Vantara LLC ${(/* @__PURE__ */ new Date()).getFullYear()}. All Rights Reserved.`,
|
|
12
12
|
links,
|
|
13
13
|
classes: classesProp,
|
|
14
14
|
className,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Footer.js","sources":["../../../src/Footer/Footer.tsx"],"sourcesContent":["import { useTheme } from \"@mui/material/styles\";\nimport useMediaQuery from \"@mui/material/useMediaQuery\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseProps } from \"../types/generic\";\nimport { HvTypography } from \"../Typography\";\nimport { staticClasses, useClasses } from \"./Footer.styles\";\n\nexport { staticClasses as footerClasses };\n\nexport type HvFooterClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFooterProps extends HvBaseProps {\n /** Footer name. */\n name?: React.ReactNode;\n /** Footer copyright. */\n copyright?: React.ReactNode;\n /** Footer links. */\n links?: React.ReactNode;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFooterClasses;\n}\n\n/**\n * A Footer is a way of providing extra information at the end of a page.\n */\nexport const HvFooter = (props: HvFooterProps) => {\n const {\n name = \"Hitachi Vantara\",\n copyright = `© Hitachi Vantara
|
|
1
|
+
{"version":3,"file":"Footer.js","sources":["../../../src/Footer/Footer.tsx"],"sourcesContent":["import { useTheme } from \"@mui/material/styles\";\nimport useMediaQuery from \"@mui/material/useMediaQuery\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseProps } from \"../types/generic\";\nimport { HvTypography } from \"../Typography\";\nimport { staticClasses, useClasses } from \"./Footer.styles\";\n\nexport { staticClasses as footerClasses };\n\nexport type HvFooterClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFooterProps extends HvBaseProps {\n /** Footer name. */\n name?: React.ReactNode;\n /** Footer copyright. */\n copyright?: React.ReactNode;\n /** Footer links. */\n links?: React.ReactNode;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFooterClasses;\n}\n\n/**\n * A Footer is a way of providing extra information at the end of a page.\n */\nexport const HvFooter = (props: HvFooterProps) => {\n const {\n name = \"Hitachi Vantara\",\n copyright = `© Hitachi Vantara LLC ${new Date().getFullYear()}. All Rights Reserved.`,\n links,\n classes: classesProp,\n className,\n ...others\n } = useDefaultProps(\"HvFooter\", props);\n const muiTheme = useTheme();\n const { classes, cx } = useClasses(classesProp);\n\n const isSmDown = useMediaQuery(muiTheme.breakpoints.down(\"sm\"));\n\n return (\n <footer\n className={cx(classes.root, { [classes.small]: isSmDown }, className)}\n {...others}\n >\n <HvTypography variant=\"label\" className={classes.name}>\n {name}\n </HvTypography>\n <div className={classes.rightContainer}>\n <HvTypography className={classes.copyright}>{copyright}</HvTypography>\n {links && <div className={classes.separator} />}\n {links}\n </div>\n </footer>\n );\n};\n"],"names":[],"mappings":";;;;;;;AA6Ba,MAAA,WAAW,CAAC,UAAyB;AAC1C,QAAA;AAAA,IACJ,OAAO;AAAA,IACP,YAAY,0BAAyB,oBAAI,KAAK,GAAE,YAAa,CAAA;AAAA,IAC7D;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,YAAY,KAAK;AACrC,QAAM,WAAW;AACjB,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAE9C,QAAM,WAAW,cAAc,SAAS,YAAY,KAAK,IAAI,CAAC;AAG5D,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW,GAAG,QAAQ,MAAM,EAAE,CAAC,QAAQ,KAAK,GAAG,SAAS,GAAG,SAAS;AAAA,MACnE,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAA,oBAAC,gBAAa,SAAQ,SAAQ,WAAW,QAAQ,MAC9C,UACH,MAAA;AAAA,QACC,qBAAA,OAAA,EAAI,WAAW,QAAQ,gBACtB,UAAA;AAAA,UAAA,oBAAC,cAAa,EAAA,WAAW,QAAQ,WAAY,UAAU,WAAA;AAAA,UACtD,SAAS,oBAAC,OAAI,EAAA,WAAW,QAAQ,WAAW;AAAA,UAC5C;AAAA,QAAA,GACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -10,13 +10,14 @@ const { staticClasses, useClasses } = createClasses("HvLoading", {
|
|
|
10
10
|
},
|
|
11
11
|
barContainer: {
|
|
12
12
|
display: "flex",
|
|
13
|
+
alignItems: "center",
|
|
13
14
|
justifyContent: "space-around",
|
|
14
15
|
":has($regular)": {
|
|
15
16
|
width: 30,
|
|
16
17
|
height: 30
|
|
17
18
|
},
|
|
18
19
|
":has($small)": {
|
|
19
|
-
"--
|
|
20
|
+
"--height": "40%",
|
|
20
21
|
width: 18,
|
|
21
22
|
height: 18
|
|
22
23
|
}
|
|
@@ -27,9 +28,10 @@ const { staticClasses, useClasses } = createClasses("HvLoading", {
|
|
|
27
28
|
animation: "loading 1s ease-in-out infinite",
|
|
28
29
|
// TODO: make this the default when it has better support
|
|
29
30
|
width: "round(up, 0.11em, 2px)",
|
|
31
|
+
height: "100%",
|
|
30
32
|
"@keyframes loading": {
|
|
31
33
|
"50%": {
|
|
32
|
-
|
|
34
|
+
height: "var(--height, 60%)",
|
|
33
35
|
backgroundColor: `var(--customColor, ${theme.colors.secondary})`
|
|
34
36
|
}
|
|
35
37
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Loading.styles.js","sources":["../../../src/Loading/Loading.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvLoading\", {\n root: {\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: theme.space.xs,\n },\n barContainer: {\n display: \"flex\",\n justifyContent: \"space-around\",\n\n \":has($regular)\": {\n width: 30,\n height: 30,\n },\n\n \":has($small)\": {\n \"--
|
|
1
|
+
{"version":3,"file":"Loading.styles.js","sources":["../../../src/Loading/Loading.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvLoading\", {\n root: {\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: theme.space.xs,\n },\n barContainer: {\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-around\",\n\n \":has($regular)\": {\n width: 30,\n height: 30,\n },\n\n \":has($small)\": {\n \"--height\": \"40%\",\n width: 18,\n height: 18,\n },\n },\n loadingBar: {\n backgroundColor: \"currentcolor\",\n display: \"inline-block\",\n animation: \"loading 1s ease-in-out infinite\",\n // TODO: make this the default when it has better support\n width: \"round(up, 0.11em, 2px)\",\n height: \"100%\",\n\n \"@keyframes loading\": {\n \"50%\": {\n height: \"var(--height, 60%)\",\n backgroundColor: `var(--customColor, ${theme.colors.secondary})`,\n },\n },\n\n \":nth-of-type(2)\": { animationDelay: \"0.22s\" },\n \":nth-of-type(3)\": { animationDelay: \"0.44s\" },\n },\n label: {},\n overlay: {},\n blur: {},\n hidden: { display: \"none\" },\n small: {\n width: 2,\n },\n regular: {\n width: 4,\n },\n smallColor: {},\n regularColor: {},\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,aAAa;AAAA,EACtE,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,eAAe;AAAA,IACf,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,KAAK,MAAM,MAAM;AAAA,EACnB;AAAA,EACA,cAAc;AAAA,IACZ,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAEhB,kBAAkB;AAAA,MAChB,OAAO;AAAA,MACP,QAAQ;AAAA,IACV;AAAA,IAEA,gBAAgB;AAAA,MACd,YAAY;AAAA,MACZ,OAAO;AAAA,MACP,QAAQ;AAAA,IACV;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV,iBAAiB;AAAA,IACjB,SAAS;AAAA,IACT,WAAW;AAAA;AAAA,IAEX,OAAO;AAAA,IACP,QAAQ;AAAA,IAER,sBAAsB;AAAA,MACpB,OAAO;AAAA,QACL,QAAQ;AAAA,QACR,iBAAiB,sBAAsB,MAAM,OAAO,SAAS;AAAA,MAC/D;AAAA,IACF;AAAA,IAEA,mBAAmB,EAAE,gBAAgB,QAAQ;AAAA,IAC7C,mBAAmB,EAAE,gBAAgB,QAAQ;AAAA,EAC/C;AAAA,EACA,OAAO,CAAC;AAAA,EACR,SAAS,CAAC;AAAA,EACV,MAAM,CAAC;AAAA,EACP,QAAQ,EAAE,SAAS,OAAO;AAAA,EAC1B,OAAO;AAAA,IACL,OAAO;AAAA,EACT;AAAA,EACA,SAAS;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA,YAAY,CAAC;AAAA,EACb,cAAc,CAAC;AACjB,CAAC;"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import { useMemo, Children, isValidElement,
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, Children, isValidElement, cloneElement } from "react";
|
|
3
3
|
import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
|
|
4
|
-
import {
|
|
5
|
-
import { useClasses, getSplitContainerColor, getSplitContainerHeight } from "./MultiButton.styles.js";
|
|
4
|
+
import { useClasses } from "./MultiButton.styles.js";
|
|
6
5
|
import { staticClasses } from "./MultiButton.styles.js";
|
|
7
6
|
const HvMultiButton = (props) => {
|
|
8
7
|
const {
|
|
9
|
-
id,
|
|
10
8
|
className,
|
|
11
9
|
children,
|
|
12
10
|
classes: classesProp,
|
|
@@ -17,13 +15,7 @@ const HvMultiButton = (props) => {
|
|
|
17
15
|
split,
|
|
18
16
|
...others
|
|
19
17
|
} = useDefaultProps("HvMultiButton", props);
|
|
20
|
-
const { classes, cx
|
|
21
|
-
const [color, type] = useMemo(() => {
|
|
22
|
-
const result = variant.split(/(?=[A-Z])/);
|
|
23
|
-
if (result[0] === "ghost" || result[0] === "semantic" || result[0] === "secondary" && !result[1])
|
|
24
|
-
return [];
|
|
25
|
-
return result.map((x) => x.toLowerCase());
|
|
26
|
-
}, [variant]);
|
|
18
|
+
const { classes, cx } = useClasses(classesProp);
|
|
27
19
|
const buttons = useMemo(() => {
|
|
28
20
|
const btns = [];
|
|
29
21
|
Children.forEach(children, (child) => {
|
|
@@ -36,7 +28,6 @@ const HvMultiButton = (props) => {
|
|
|
36
28
|
return /* @__PURE__ */ jsx(
|
|
37
29
|
"div",
|
|
38
30
|
{
|
|
39
|
-
id,
|
|
40
31
|
className: cx(
|
|
41
32
|
classes.root,
|
|
42
33
|
{
|
|
@@ -52,35 +43,17 @@ const HvMultiButton = (props) => {
|
|
|
52
43
|
...others,
|
|
53
44
|
children: buttons.map((child, index) => {
|
|
54
45
|
const childIsSelected = !!child.props.selected;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}),
|
|
67
|
-
split && index < buttons.length - 1 && /* @__PURE__ */ jsx(
|
|
68
|
-
"div",
|
|
69
|
-
{
|
|
70
|
-
className: cx(
|
|
71
|
-
classes.splitContainer,
|
|
72
|
-
color && css(getSplitContainerColor(color, type, disabled)),
|
|
73
|
-
size && css(getSplitContainerHeight(size)),
|
|
74
|
-
{
|
|
75
|
-
[classes.splitDisabled]: disabled
|
|
76
|
-
},
|
|
77
|
-
classes[variant]
|
|
78
|
-
// TODO - remove in v6
|
|
79
|
-
),
|
|
80
|
-
children: /* @__PURE__ */ jsx("div", { className: classes.split })
|
|
81
|
-
}
|
|
82
|
-
)
|
|
83
|
-
] }, btnKey);
|
|
46
|
+
return cloneElement(child, {
|
|
47
|
+
key: index,
|
|
48
|
+
variant,
|
|
49
|
+
disabled: disabled || child.props.disabled,
|
|
50
|
+
size,
|
|
51
|
+
className: cx(child.props.className, classes.button, {
|
|
52
|
+
[classes.firstButton]: index === 0,
|
|
53
|
+
[classes.lastButton]: index === buttons.length - 1,
|
|
54
|
+
[classes.selected]: childIsSelected
|
|
55
|
+
})
|
|
56
|
+
});
|
|
84
57
|
})
|
|
85
58
|
}
|
|
86
59
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiButton.js","sources":["../../../src/MultiButton/MultiButton.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n
|
|
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;AACl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