@hitachivantara/uikit-react-lab 6.1.9 → 6.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Blade/Blade.js +134 -173
- package/dist/Blade/Blade.styles.js +54 -69
- package/dist/Blades/Blades.js +70 -101
- package/dist/Blades/Blades.styles.js +7 -10
- package/dist/Dashboard/Dashboard.js +57 -60
- package/dist/Dashboard/Dashboard.styles.js +6 -10
- package/dist/Flow/Background/Background.js +10 -16
- package/dist/Flow/Controls/Controls.js +77 -91
- package/dist/Flow/DroppableFlow.js +135 -200
- package/dist/Flow/Empty/Empty.js +12 -9
- package/dist/Flow/Empty/Empty.styles.js +12 -15
- package/dist/Flow/Flow.js +28 -30
- package/dist/Flow/Flow.styles.js +12 -18
- package/dist/Flow/FlowContext/FlowContext.js +22 -23
- package/dist/Flow/FlowContext/NodeMetaContext.js +36 -39
- package/dist/Flow/Minimap/Minimap.js +15 -28
- package/dist/Flow/Minimap/Minimap.styles.js +4 -9
- package/dist/Flow/Node/BaseNode.js +144 -190
- package/dist/Flow/Node/BaseNode.styles.js +122 -133
- package/dist/Flow/Node/Node.js +90 -108
- package/dist/Flow/Node/Node.styles.js +30 -40
- package/dist/Flow/Node/Parameters/ParamRenderer.js +17 -14
- package/dist/Flow/Node/Parameters/Select.js +33 -38
- package/dist/Flow/Node/Parameters/Slider.js +27 -29
- package/dist/Flow/Node/Parameters/Text.js +17 -17
- package/dist/Flow/Node/utils.js +44 -49
- package/dist/Flow/Sidebar/Sidebar.js +115 -137
- package/dist/Flow/Sidebar/Sidebar.styles.js +21 -22
- package/dist/Flow/Sidebar/SidebarGroup/SidebarGroup.js +57 -60
- package/dist/Flow/Sidebar/SidebarGroup/SidebarGroup.styles.js +27 -33
- package/dist/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.js +27 -47
- package/dist/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.js +14 -32
- package/dist/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.styles.js +17 -23
- package/dist/Flow/base.js +5 -5
- package/dist/Flow/hooks/useFlowContext.js +5 -5
- package/dist/Flow/hooks/useFlowInstance.js +5 -4
- package/dist/Flow/hooks/useFlowNode.js +92 -113
- package/dist/Flow/hooks/useFlowNodeMeta.js +7 -7
- package/dist/Flow/hooks/useNode.js +136 -154
- package/dist/Flow/hooks/useNodeId.js +8 -7
- package/dist/Flow/nodes/DashboardNode.js +64 -86
- package/dist/Flow/nodes/DashboardNode.styles.js +8 -14
- package/dist/Flow/nodes/StickyNode.js +370 -435
- package/dist/StepNavigation/DefaultNavigation/DefaultNavigation.js +36 -52
- package/dist/StepNavigation/DefaultNavigation/Step/Step.js +40 -51
- package/dist/StepNavigation/DefaultNavigation/Step/Step.styles.js +22 -33
- package/dist/StepNavigation/DefaultNavigation/utils.js +38 -30
- package/dist/StepNavigation/SimpleNavigation/Dot/Dot.js +24 -41
- package/dist/StepNavigation/SimpleNavigation/Dot/Dot.styles.js +13 -16
- package/dist/StepNavigation/SimpleNavigation/SimpleNavigation.js +35 -47
- package/dist/StepNavigation/SimpleNavigation/utils.js +10 -11
- package/dist/StepNavigation/StepNavigation.js +136 -179
- package/dist/StepNavigation/StepNavigation.styles.js +29 -32
- package/dist/Wizard/Wizard.js +81 -104
- package/dist/Wizard/Wizard.styles.js +4 -7
- package/dist/Wizard/WizardActions/WizardActions.js +111 -131
- package/dist/Wizard/WizardActions/WizardActions.styles.js +19 -20
- package/dist/Wizard/WizardContainer/WizardContainer.js +19 -28
- package/dist/Wizard/WizardContainer/WizardContainer.styles.js +8 -14
- package/dist/Wizard/WizardContent/WizardContent.js +103 -120
- package/dist/Wizard/WizardContent/WizardContent.styles.js +33 -36
- package/dist/Wizard/WizardContext/WizardContext.js +10 -13
- package/dist/Wizard/WizardTitle/WizardTitle.js +74 -79
- package/dist/Wizard/WizardTitle/WizardTitle.styles.js +12 -15
- package/dist/index.d.ts +1 -1
- package/dist/index.js +30 -81
- package/package.json +6 -6
- package/dist/StepNavigation/utils.js +0 -8
package/dist/Blade/Blade.js
CHANGED
|
@@ -1,175 +1,136 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useMemo, useRef, useState, useEffect } from "react";
|
|
3
|
-
import { useDefaultProps, useControlled, useUniqueId, setId, HvTypography } from "@hitachivantara/uikit-react-core";
|
|
4
1
|
import { useClasses } from "./Blade.styles.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
};
|
|
138
|
-
}, [isExpanded]);
|
|
139
|
-
const { style: containerStyle, ...otherContainerProps } = containerProps || {};
|
|
140
|
-
return /* @__PURE__ */ jsxs(
|
|
141
|
-
"div",
|
|
142
|
-
{
|
|
143
|
-
ref: bladeRef,
|
|
144
|
-
id: idProp,
|
|
145
|
-
className: cx(classes.root, className, {
|
|
146
|
-
[classes.fullWidth]: fullWidth,
|
|
147
|
-
[classes.expanded]: isExpanded
|
|
148
|
-
}),
|
|
149
|
-
...others,
|
|
150
|
-
children: [
|
|
151
|
-
bladeHeader,
|
|
152
|
-
/* @__PURE__ */ jsx(
|
|
153
|
-
"div",
|
|
154
|
-
{
|
|
155
|
-
id: bladeContainerId,
|
|
156
|
-
role: "region",
|
|
157
|
-
"aria-labelledby": bladeHeaderId,
|
|
158
|
-
className: classes.container,
|
|
159
|
-
hidden: !isExpanded,
|
|
160
|
-
style: {
|
|
161
|
-
...containerStyle,
|
|
162
|
-
maxWidth: isExpanded ? maxWidth : 0
|
|
163
|
-
},
|
|
164
|
-
...otherContainerProps,
|
|
165
|
-
children
|
|
166
|
-
}
|
|
167
|
-
)
|
|
168
|
-
]
|
|
169
|
-
}
|
|
170
|
-
);
|
|
171
|
-
};
|
|
172
|
-
export {
|
|
173
|
-
HvBlade,
|
|
174
|
-
staticClasses as bladeClasses
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { HvTypography, setId, useControlled, useDefaultProps, useUniqueId } from "@hitachivantara/uikit-react-core";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/Blade/Blade.tsx
|
|
6
|
+
/**
|
|
7
|
+
* A blade is a design element that expands horizontally to reveal information, similar to an accordion.
|
|
8
|
+
*
|
|
9
|
+
* It is usually stacked horizontally with other blades and works best when used within a flex container.
|
|
10
|
+
* The `HvBlades` component is recommended for this purpose, as it also provides better management of the
|
|
11
|
+
* blades' expanded state.
|
|
12
|
+
*/
|
|
13
|
+
var HvBlade = (props) => {
|
|
14
|
+
const { id: idProp, className, classes: classesProp, expanded, defaultExpanded = false, label, labelVariant = "label", headingLevel, onChange, disabled = false, children, fullWidth, buttonProps, containerProps, ...others } = useDefaultProps("HvBlade", props);
|
|
15
|
+
const { classes, cx } = useClasses(classesProp);
|
|
16
|
+
const [isExpanded, setIsExpanded] = useControlled(expanded, Boolean(defaultExpanded));
|
|
17
|
+
const handleAction = useCallback((event) => {
|
|
18
|
+
if (!disabled) {
|
|
19
|
+
onChange?.(event, !isExpanded);
|
|
20
|
+
setIsExpanded(!isExpanded);
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
}, [
|
|
25
|
+
disabled,
|
|
26
|
+
onChange,
|
|
27
|
+
isExpanded,
|
|
28
|
+
setIsExpanded
|
|
29
|
+
]);
|
|
30
|
+
const handleClick = useCallback((event) => {
|
|
31
|
+
handleAction(event);
|
|
32
|
+
event.preventDefault();
|
|
33
|
+
event.stopPropagation();
|
|
34
|
+
}, [handleAction]);
|
|
35
|
+
const handleKeyDown = useCallback((event) => {
|
|
36
|
+
let isEventHandled = false;
|
|
37
|
+
const { key } = event;
|
|
38
|
+
if (event.altKey || event.ctrlKey || event.metaKey || event.currentTarget !== event.target) return;
|
|
39
|
+
switch (key) {
|
|
40
|
+
case "Enter":
|
|
41
|
+
case " ":
|
|
42
|
+
isEventHandled = handleAction(event);
|
|
43
|
+
break;
|
|
44
|
+
default: return;
|
|
45
|
+
}
|
|
46
|
+
if (isEventHandled) {
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
event.stopPropagation();
|
|
49
|
+
}
|
|
50
|
+
}, [handleAction]);
|
|
51
|
+
const id = useUniqueId(idProp);
|
|
52
|
+
const bladeHeaderId = setId(id, "button");
|
|
53
|
+
const bladeContainerId = setId(id, "container");
|
|
54
|
+
const bladeHeader = useMemo(() => {
|
|
55
|
+
const buttonLabel = typeof label === "function" ? label(isExpanded) : label;
|
|
56
|
+
const bladeButton = /* @__PURE__ */ jsx(HvTypography, {
|
|
57
|
+
id: bladeHeaderId,
|
|
58
|
+
component: "div",
|
|
59
|
+
role: "button",
|
|
60
|
+
className: cx(classes.button, {
|
|
61
|
+
[classes.textOnlyLabel]: typeof buttonLabel === "string",
|
|
62
|
+
[classes.disabled]: disabled
|
|
63
|
+
}),
|
|
64
|
+
style: { flexShrink: headingLevel === void 0 ? 0 : void 0 },
|
|
65
|
+
disabled,
|
|
66
|
+
tabIndex: 0,
|
|
67
|
+
onKeyDown: handleKeyDown,
|
|
68
|
+
onClick: handleClick,
|
|
69
|
+
variant: labelVariant,
|
|
70
|
+
"aria-expanded": isExpanded,
|
|
71
|
+
"aria-controls": bladeContainerId,
|
|
72
|
+
...buttonProps,
|
|
73
|
+
children: buttonLabel
|
|
74
|
+
});
|
|
75
|
+
return headingLevel === void 0 ? bladeButton : /* @__PURE__ */ jsx(HvTypography, {
|
|
76
|
+
component: `h${headingLevel}`,
|
|
77
|
+
variant: labelVariant,
|
|
78
|
+
className: classes.heading,
|
|
79
|
+
style: { flexShrink: 0 },
|
|
80
|
+
children: bladeButton
|
|
81
|
+
});
|
|
82
|
+
}, [
|
|
83
|
+
bladeContainerId,
|
|
84
|
+
bladeHeaderId,
|
|
85
|
+
buttonProps,
|
|
86
|
+
classes.button,
|
|
87
|
+
classes.disabled,
|
|
88
|
+
classes.heading,
|
|
89
|
+
classes.textOnlyLabel,
|
|
90
|
+
cx,
|
|
91
|
+
disabled,
|
|
92
|
+
handleClick,
|
|
93
|
+
handleKeyDown,
|
|
94
|
+
headingLevel,
|
|
95
|
+
isExpanded,
|
|
96
|
+
label,
|
|
97
|
+
labelVariant
|
|
98
|
+
]);
|
|
99
|
+
const bladeRef = useRef(null);
|
|
100
|
+
const [maxWidth, setMaxWidth] = useState(void 0);
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (!bladeRef.current) return;
|
|
103
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
104
|
+
setMaxWidth(entries[0].target.clientWidth);
|
|
105
|
+
});
|
|
106
|
+
resizeObserver.observe(bladeRef.current.parentElement ?? bladeRef.current);
|
|
107
|
+
return () => {
|
|
108
|
+
resizeObserver.disconnect();
|
|
109
|
+
};
|
|
110
|
+
}, [isExpanded]);
|
|
111
|
+
const { style: containerStyle, ...otherContainerProps } = containerProps || {};
|
|
112
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
113
|
+
ref: bladeRef,
|
|
114
|
+
id: idProp,
|
|
115
|
+
className: cx(classes.root, className, {
|
|
116
|
+
[classes.fullWidth]: fullWidth,
|
|
117
|
+
[classes.expanded]: isExpanded
|
|
118
|
+
}),
|
|
119
|
+
...others,
|
|
120
|
+
children: [bladeHeader, /* @__PURE__ */ jsx("div", {
|
|
121
|
+
id: bladeContainerId,
|
|
122
|
+
role: "region",
|
|
123
|
+
"aria-labelledby": bladeHeaderId,
|
|
124
|
+
className: classes.container,
|
|
125
|
+
hidden: !isExpanded,
|
|
126
|
+
style: {
|
|
127
|
+
...containerStyle,
|
|
128
|
+
maxWidth: isExpanded ? maxWidth : 0
|
|
129
|
+
},
|
|
130
|
+
...otherContainerProps,
|
|
131
|
+
children
|
|
132
|
+
})]
|
|
133
|
+
});
|
|
175
134
|
};
|
|
135
|
+
//#endregion
|
|
136
|
+
export { HvBlade };
|
|
@@ -1,71 +1,56 @@
|
|
|
1
1
|
import { createClasses, outlineStyles } from "@hitachivantara/uikit-react-core";
|
|
2
|
-
import { theme } from "@hitachivantara/uikit-styles";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
maxWidth: 0,
|
|
55
|
-
transition: "max-width 600ms linear"
|
|
56
|
-
},
|
|
57
|
-
disabled: {
|
|
58
|
-
cursor: "not-allowed",
|
|
59
|
-
color: theme.colors.textDisabled,
|
|
60
|
-
"&:focus": {
|
|
61
|
-
background: "none"
|
|
62
|
-
},
|
|
63
|
-
"&:hover": {
|
|
64
|
-
background: "none"
|
|
65
|
-
}
|
|
66
|
-
}
|
|
2
|
+
import { theme as theme$1 } from "@hitachivantara/uikit-styles";
|
|
3
|
+
//#region src/Blade/Blade.styles.tsx
|
|
4
|
+
var { staticClasses, useClasses } = createClasses("HvBlade", {
|
|
5
|
+
root: {
|
|
6
|
+
position: "relative",
|
|
7
|
+
display: "flex",
|
|
8
|
+
minWidth: 72,
|
|
9
|
+
"& + $root": { marginLeft: theme$1.spacing("sm") },
|
|
10
|
+
transition: "flex-grow 600ms linear",
|
|
11
|
+
zIndex: 0,
|
|
12
|
+
color: theme$1.colors.text,
|
|
13
|
+
backgroundColor: theme$1.colors.bgContainer,
|
|
14
|
+
borderRadius: theme$1.radii.round,
|
|
15
|
+
border: `1px solid ${theme$1.colors.border}`
|
|
16
|
+
},
|
|
17
|
+
expanded: {},
|
|
18
|
+
fullWidth: {
|
|
19
|
+
flexGrow: 0,
|
|
20
|
+
"&$expanded": { flexGrow: 1 }
|
|
21
|
+
},
|
|
22
|
+
heading: {},
|
|
23
|
+
button: {
|
|
24
|
+
height: "100%",
|
|
25
|
+
minWidth: 70,
|
|
26
|
+
"&[disabled], &:active": { outline: "none" },
|
|
27
|
+
"&:focus": {
|
|
28
|
+
outline: "none",
|
|
29
|
+
background: theme$1.colors.bgHover
|
|
30
|
+
},
|
|
31
|
+
"&:hover": { background: theme$1.colors.bgHover },
|
|
32
|
+
"&:focus-visible": {
|
|
33
|
+
...outlineStyles,
|
|
34
|
+
zIndex: 1
|
|
35
|
+
},
|
|
36
|
+
cursor: "pointer"
|
|
37
|
+
},
|
|
38
|
+
textOnlyLabel: { padding: theme$1.spacing("xs", "sm") },
|
|
39
|
+
container: {
|
|
40
|
+
display: "inline-block",
|
|
41
|
+
height: "100%",
|
|
42
|
+
width: "100%",
|
|
43
|
+
minWidth: 0,
|
|
44
|
+
overflowX: "hidden",
|
|
45
|
+
maxWidth: 0,
|
|
46
|
+
transition: "max-width 600ms linear"
|
|
47
|
+
},
|
|
48
|
+
disabled: {
|
|
49
|
+
cursor: "not-allowed",
|
|
50
|
+
color: theme$1.colors.textDisabled,
|
|
51
|
+
"&:focus": { background: "none" },
|
|
52
|
+
"&:hover": { background: "none" }
|
|
53
|
+
}
|
|
67
54
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
useClasses
|
|
71
|
-
};
|
|
55
|
+
//#endregion
|
|
56
|
+
export { staticClasses, useClasses };
|
package/dist/Blades/Blades.js
CHANGED
|
@@ -1,105 +1,74 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useMemo, Children, cloneElement } from "react";
|
|
3
|
-
import { useDefaultProps, useControlled } from "@hitachivantara/uikit-react-core";
|
|
4
1
|
import { useClasses } from "./Blades.styles.js";
|
|
5
|
-
import {
|
|
2
|
+
import { Children, cloneElement, useCallback, useMemo } from "react";
|
|
3
|
+
import { useControlled, useDefaultProps } from "@hitachivantara/uikit-react-core";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/Blades/Blades.tsx
|
|
6
6
|
function getExpandedBlades(defaultExpanded, children, atMostOneExpanded, atLeastOneExpanded) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return [0];
|
|
16
|
-
}
|
|
17
|
-
if (atMostOneExpanded && numberOfExpandedBlades > 1) {
|
|
18
|
-
return [expandedBlades[0]];
|
|
19
|
-
}
|
|
20
|
-
return expandedBlades;
|
|
7
|
+
const childrenArray = Children.toArray(children);
|
|
8
|
+
const expandedBlades = defaultExpanded ?? childrenArray.map((child, i) => {
|
|
9
|
+
return (child?.props?.expanded !== void 0 ? child?.props?.expanded : child?.props?.defaultExpanded) ? i : void 0;
|
|
10
|
+
}).filter((v) => v !== void 0);
|
|
11
|
+
const numberOfExpandedBlades = expandedBlades.length;
|
|
12
|
+
if (atLeastOneExpanded && numberOfExpandedBlades === 0 && childrenArray.length > 0) return [0];
|
|
13
|
+
if (atMostOneExpanded && numberOfExpandedBlades > 1) return [expandedBlades[0]];
|
|
14
|
+
return expandedBlades;
|
|
21
15
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"aria-disabled": (
|
|
79
|
-
// If the accordion panel associated with an accordion header is visible,
|
|
80
|
-
// and if the accordion does not permit the panel to be collapsed, the header
|
|
81
|
-
// button element has aria-disabled set to true.
|
|
82
|
-
child?.props?.disabled || childIsExpanded && atMostOneExpanded && expanded.length === 1 ? true : void 0
|
|
83
|
-
)
|
|
84
|
-
},
|
|
85
|
-
onChange: (event, isExpanded) => onChildChangeInterceptor(
|
|
86
|
-
i,
|
|
87
|
-
child?.props?.onChange,
|
|
88
|
-
event,
|
|
89
|
-
isExpanded
|
|
90
|
-
)
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
}, [
|
|
94
|
-
children,
|
|
95
|
-
expanded,
|
|
96
|
-
fullWidthBlades,
|
|
97
|
-
atMostOneExpanded,
|
|
98
|
-
onChildChangeInterceptor
|
|
99
|
-
]);
|
|
100
|
-
return /* @__PURE__ */ jsx("div", { id, className: cx(classes.root, className), ...others, children: modifiedChildren });
|
|
101
|
-
};
|
|
102
|
-
export {
|
|
103
|
-
HvBlades,
|
|
104
|
-
staticClasses as bladesClasses
|
|
16
|
+
/**
|
|
17
|
+
* `HvBlades` is a component that groups multiple `HvBlade` components.
|
|
18
|
+
*
|
|
19
|
+
* It allows for better control over the expanded state of blades, suitable for both
|
|
20
|
+
* controlled and uncontrolled scenarios.
|
|
21
|
+
*/
|
|
22
|
+
var HvBlades = (props) => {
|
|
23
|
+
const { id, className, classes: classesProp, children, expanded: expandedProp, defaultExpanded, atMostOneExpanded = false, atLeastOneExpanded = false, fullWidthBlades = false, onChange, ...others } = useDefaultProps("HvBlades", props);
|
|
24
|
+
const { classes, cx } = useClasses(classesProp);
|
|
25
|
+
const [expanded, setExpanded] = useControlled(expandedProp, () => getExpandedBlades(defaultExpanded, children, atMostOneExpanded, atLeastOneExpanded));
|
|
26
|
+
const onChildChangeInterceptor = useCallback((index, childOnChange, event, isExpanded) => {
|
|
27
|
+
const newValue = [];
|
|
28
|
+
if (atMostOneExpanded) {
|
|
29
|
+
if (isExpanded) newValue.push(index);
|
|
30
|
+
} else {
|
|
31
|
+
newValue.push(...expanded);
|
|
32
|
+
if (isExpanded) newValue.push(index);
|
|
33
|
+
else newValue.splice(newValue.indexOf(index), 1);
|
|
34
|
+
}
|
|
35
|
+
if (atLeastOneExpanded && newValue.length === 0) newValue.push(index);
|
|
36
|
+
childOnChange?.(event, isExpanded);
|
|
37
|
+
onChange?.(event, newValue);
|
|
38
|
+
setExpanded(newValue);
|
|
39
|
+
}, [
|
|
40
|
+
onChange,
|
|
41
|
+
expanded,
|
|
42
|
+
setExpanded,
|
|
43
|
+
atMostOneExpanded,
|
|
44
|
+
atLeastOneExpanded
|
|
45
|
+
]);
|
|
46
|
+
const modifiedChildren = useMemo(() => {
|
|
47
|
+
return Children.map(children, (child, i) => {
|
|
48
|
+
const childIsExpanded = expanded.includes(i);
|
|
49
|
+
return cloneElement(child, {
|
|
50
|
+
expanded: childIsExpanded,
|
|
51
|
+
fullWidth: child?.props?.fullWidth ?? fullWidthBlades,
|
|
52
|
+
buttonProps: {
|
|
53
|
+
...child?.props?.buttonProps,
|
|
54
|
+
"aria-disabled": child?.props?.disabled || childIsExpanded && atMostOneExpanded && expanded.length === 1 ? true : void 0
|
|
55
|
+
},
|
|
56
|
+
onChange: (event, isExpanded) => onChildChangeInterceptor(i, child?.props?.onChange, event, isExpanded)
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}, [
|
|
60
|
+
children,
|
|
61
|
+
expanded,
|
|
62
|
+
fullWidthBlades,
|
|
63
|
+
atMostOneExpanded,
|
|
64
|
+
onChildChangeInterceptor
|
|
65
|
+
]);
|
|
66
|
+
return /* @__PURE__ */ jsx("div", {
|
|
67
|
+
id,
|
|
68
|
+
className: cx(classes.root, className),
|
|
69
|
+
...others,
|
|
70
|
+
children: modifiedChildren
|
|
71
|
+
});
|
|
105
72
|
};
|
|
73
|
+
//#endregion
|
|
74
|
+
export { HvBlades };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { createClasses } from "@hitachivantara/uikit-react-core";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
staticClasses,
|
|
10
|
-
useClasses
|
|
11
|
-
};
|
|
2
|
+
//#region src/Blades/Blades.styles.tsx
|
|
3
|
+
var { staticClasses, useClasses } = createClasses("HvBlades", { root: {
|
|
4
|
+
position: "relative",
|
|
5
|
+
display: "flex"
|
|
6
|
+
} });
|
|
7
|
+
//#endregion
|
|
8
|
+
export { staticClasses, useClasses };
|