@hitachivantara/uikit-react-lab 6.1.9 → 6.1.11

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.
Files changed (69) hide show
  1. package/LICENSE +201 -0
  2. package/dist/Blade/Blade.js +134 -173
  3. package/dist/Blade/Blade.styles.js +54 -69
  4. package/dist/Blades/Blades.js +70 -101
  5. package/dist/Blades/Blades.styles.js +7 -10
  6. package/dist/Dashboard/Dashboard.js +57 -60
  7. package/dist/Dashboard/Dashboard.styles.js +6 -10
  8. package/dist/Flow/Background/Background.js +10 -16
  9. package/dist/Flow/Controls/Controls.js +77 -91
  10. package/dist/Flow/DroppableFlow.js +135 -200
  11. package/dist/Flow/Empty/Empty.js +12 -9
  12. package/dist/Flow/Empty/Empty.styles.js +12 -15
  13. package/dist/Flow/Flow.js +28 -30
  14. package/dist/Flow/Flow.styles.js +12 -18
  15. package/dist/Flow/FlowContext/FlowContext.js +22 -23
  16. package/dist/Flow/FlowContext/NodeMetaContext.js +36 -39
  17. package/dist/Flow/Minimap/Minimap.js +15 -28
  18. package/dist/Flow/Minimap/Minimap.styles.js +4 -9
  19. package/dist/Flow/Node/BaseNode.js +144 -190
  20. package/dist/Flow/Node/BaseNode.styles.js +122 -133
  21. package/dist/Flow/Node/Node.js +90 -108
  22. package/dist/Flow/Node/Node.styles.js +30 -40
  23. package/dist/Flow/Node/Parameters/ParamRenderer.js +17 -14
  24. package/dist/Flow/Node/Parameters/Select.js +33 -38
  25. package/dist/Flow/Node/Parameters/Slider.js +27 -29
  26. package/dist/Flow/Node/Parameters/Text.js +17 -17
  27. package/dist/Flow/Node/utils.js +44 -49
  28. package/dist/Flow/Sidebar/Sidebar.js +115 -137
  29. package/dist/Flow/Sidebar/Sidebar.styles.js +21 -22
  30. package/dist/Flow/Sidebar/SidebarGroup/SidebarGroup.js +57 -60
  31. package/dist/Flow/Sidebar/SidebarGroup/SidebarGroup.styles.js +27 -33
  32. package/dist/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.js +27 -47
  33. package/dist/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.js +14 -32
  34. package/dist/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.styles.js +17 -23
  35. package/dist/Flow/base.js +5 -5
  36. package/dist/Flow/hooks/useFlowContext.js +5 -5
  37. package/dist/Flow/hooks/useFlowInstance.js +5 -4
  38. package/dist/Flow/hooks/useFlowNode.js +92 -113
  39. package/dist/Flow/hooks/useFlowNodeMeta.js +7 -7
  40. package/dist/Flow/hooks/useNode.js +136 -154
  41. package/dist/Flow/hooks/useNodeId.js +8 -7
  42. package/dist/Flow/nodes/DashboardNode.js +64 -86
  43. package/dist/Flow/nodes/DashboardNode.styles.js +8 -14
  44. package/dist/Flow/nodes/StickyNode.js +370 -435
  45. package/dist/StepNavigation/DefaultNavigation/DefaultNavigation.js +36 -52
  46. package/dist/StepNavigation/DefaultNavigation/Step/Step.js +40 -51
  47. package/dist/StepNavigation/DefaultNavigation/Step/Step.styles.js +22 -33
  48. package/dist/StepNavigation/DefaultNavigation/utils.js +38 -30
  49. package/dist/StepNavigation/SimpleNavigation/Dot/Dot.js +24 -41
  50. package/dist/StepNavigation/SimpleNavigation/Dot/Dot.styles.js +13 -16
  51. package/dist/StepNavigation/SimpleNavigation/SimpleNavigation.js +35 -47
  52. package/dist/StepNavigation/SimpleNavigation/utils.js +10 -11
  53. package/dist/StepNavigation/StepNavigation.js +136 -179
  54. package/dist/StepNavigation/StepNavigation.styles.js +29 -32
  55. package/dist/Wizard/Wizard.js +81 -104
  56. package/dist/Wizard/Wizard.styles.js +4 -7
  57. package/dist/Wizard/WizardActions/WizardActions.js +111 -131
  58. package/dist/Wizard/WizardActions/WizardActions.styles.js +19 -20
  59. package/dist/Wizard/WizardContainer/WizardContainer.js +19 -28
  60. package/dist/Wizard/WizardContainer/WizardContainer.styles.js +8 -14
  61. package/dist/Wizard/WizardContent/WizardContent.js +103 -120
  62. package/dist/Wizard/WizardContent/WizardContent.styles.js +33 -36
  63. package/dist/Wizard/WizardContext/WizardContext.js +10 -13
  64. package/dist/Wizard/WizardTitle/WizardTitle.js +74 -79
  65. package/dist/Wizard/WizardTitle/WizardTitle.styles.js +12 -15
  66. package/dist/index.d.ts +1 -1
  67. package/dist/index.js +30 -81
  68. package/package.json +25 -13
  69. package/dist/StepNavigation/utils.js +0 -8
@@ -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 { staticClasses } from "./Blades.styles.js";
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
- const childrenArray = Children.toArray(children);
8
- const expandedBlades = defaultExpanded ?? childrenArray.map((child, i) => {
9
- const childIsControlled = child?.props?.expanded !== void 0;
10
- const childIsExpanded = childIsControlled ? child?.props?.expanded : child?.props?.defaultExpanded;
11
- return childIsExpanded ? i : void 0;
12
- }).filter((v) => v !== void 0);
13
- const numberOfExpandedBlades = expandedBlades.length;
14
- if (atLeastOneExpanded && numberOfExpandedBlades === 0 && childrenArray.length > 0) {
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
- const HvBlades = (props) => {
23
- const {
24
- id,
25
- className,
26
- classes: classesProp,
27
- children,
28
- expanded: expandedProp,
29
- defaultExpanded,
30
- atMostOneExpanded = false,
31
- atLeastOneExpanded = false,
32
- fullWidthBlades = false,
33
- onChange,
34
- ...others
35
- } = useDefaultProps("HvBlades", props);
36
- const { classes, cx } = useClasses(classesProp);
37
- const [expanded, setExpanded] = useControlled(
38
- expandedProp,
39
- () => getExpandedBlades(
40
- defaultExpanded,
41
- children,
42
- atMostOneExpanded,
43
- atLeastOneExpanded
44
- )
45
- );
46
- const onChildChangeInterceptor = useCallback(
47
- (index, childOnChange, event, isExpanded) => {
48
- const newValue = [];
49
- if (atMostOneExpanded) {
50
- if (isExpanded) {
51
- newValue.push(index);
52
- }
53
- } else {
54
- newValue.push(...expanded);
55
- if (isExpanded) {
56
- newValue.push(index);
57
- } else {
58
- newValue.splice(newValue.indexOf(index), 1);
59
- }
60
- }
61
- if (atLeastOneExpanded && newValue.length === 0) {
62
- newValue.push(index);
63
- }
64
- childOnChange?.(event, isExpanded);
65
- onChange?.(event, newValue);
66
- setExpanded(newValue);
67
- },
68
- [onChange, expanded, setExpanded, atMostOneExpanded, atLeastOneExpanded]
69
- );
70
- const modifiedChildren = useMemo(() => {
71
- return Children.map(children, (child, i) => {
72
- const childIsExpanded = expanded.includes(i);
73
- return cloneElement(child, {
74
- expanded: childIsExpanded,
75
- fullWidth: child?.props?.fullWidth ?? fullWidthBlades,
76
- buttonProps: {
77
- ...child?.props?.buttonProps,
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
- const { staticClasses, useClasses } = createClasses("HvBlades", {
3
- root: {
4
- position: "relative",
5
- display: "flex"
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 };
@@ -1,64 +1,61 @@
1
- import { jsxs, Fragment, jsx } from "react/jsx-runtime";
1
+ import { gridStyles, useClasses } from "./Dashboard.styles.js";
2
2
  import { useMemo } from "react";
3
- import { WidthProvider, Responsive } from "react-grid-layout";
4
- import { Global } from "@emotion/react";
5
3
  import { useDefaultProps, useTheme } from "@hitachivantara/uikit-react-core";
6
- import { useClasses, gridStyles } from "./Dashboard.styles.js";
7
- import { staticClasses } from "./Dashboard.styles.js";
8
- const GridLayout = WidthProvider(Responsive);
9
- const defaultCols = {
10
- xs: 12,
11
- sm: 12,
12
- md: 12,
13
- lg: 12,
14
- xl: 12
15
- };
16
- const HvDashboard = (props) => {
17
- const {
18
- children,
19
- className,
20
- layout,
21
- cols: colsProp,
22
- layouts: layoutsProp,
23
- classes: classesProp,
24
- ...others
25
- } = useDefaultProps("HvDashboard", props);
26
- const { classes, cx } = useClasses(classesProp);
27
- const { activeTheme } = useTheme();
28
- const layouts = useMemo(() => {
29
- if (layoutsProp) return layoutsProp;
30
- if (!layout) return {};
31
- return { xs: layout, sm: layout, md: layout, lg: layout, xl: layout };
32
- }, [layoutsProp, layout]);
33
- const cols = useMemo(() => {
34
- if (!colsProp) return defaultCols;
35
- if (typeof colsProp === "number") {
36
- return {
37
- xs: colsProp,
38
- sm: colsProp,
39
- md: colsProp,
40
- lg: colsProp,
41
- xl: colsProp
42
- };
43
- }
44
- return colsProp;
45
- }, [colsProp]);
46
- return /* @__PURE__ */ jsxs(Fragment, { children: [
47
- /* @__PURE__ */ jsx(Global, { styles: gridStyles }),
48
- /* @__PURE__ */ jsx(
49
- GridLayout,
50
- {
51
- className: cx(classes.root, className),
52
- breakpoints: activeTheme?.breakpoints.values,
53
- cols,
54
- layouts,
55
- ...others,
56
- children
57
- }
58
- )
59
- ] });
4
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
+ import { Responsive, WidthProvider } from "react-grid-layout";
6
+ import { Global } from "@emotion/react";
7
+ //#region src/Dashboard/Dashboard.tsx
8
+ var GridLayout = WidthProvider(Responsive);
9
+ /** Default column breakpoints. For now, use always 12-column */
10
+ var defaultCols = {
11
+ xs: 12,
12
+ sm: 12,
13
+ md: 12,
14
+ lg: 12,
15
+ xl: 12
60
16
  };
61
- export {
62
- HvDashboard,
63
- staticClasses as dashboardClasses
17
+ /**
18
+ * A Dashboard grid layout component, based on `react-grid-layout`.
19
+ * The children elements are grid items and must be `key`ed.
20
+ *
21
+ * @see https://github.com/react-grid-layout/react-grid-layout?tab=readme-ov-file#grid-layout-props
22
+ *
23
+ * DISCLAIMER: This component is a work in progress and there might be breaking changes.
24
+ */
25
+ var HvDashboard = (props) => {
26
+ const { children, className, layout, cols: colsProp, layouts: layoutsProp, classes: classesProp, ...others } = useDefaultProps("HvDashboard", props);
27
+ const { classes, cx } = useClasses(classesProp);
28
+ const { activeTheme } = useTheme();
29
+ const layouts = useMemo(() => {
30
+ if (layoutsProp) return layoutsProp;
31
+ if (!layout) return {};
32
+ return {
33
+ xs: layout,
34
+ sm: layout,
35
+ md: layout,
36
+ lg: layout,
37
+ xl: layout
38
+ };
39
+ }, [layoutsProp, layout]);
40
+ const cols = useMemo(() => {
41
+ if (!colsProp) return defaultCols;
42
+ if (typeof colsProp === "number") return {
43
+ xs: colsProp,
44
+ sm: colsProp,
45
+ md: colsProp,
46
+ lg: colsProp,
47
+ xl: colsProp
48
+ };
49
+ return colsProp;
50
+ }, [colsProp]);
51
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Global, { styles: gridStyles }), /* @__PURE__ */ jsx(GridLayout, {
52
+ className: cx(classes.root, className),
53
+ breakpoints: activeTheme?.breakpoints.values,
54
+ cols,
55
+ layouts,
56
+ ...others,
57
+ children
58
+ })] });
64
59
  };
60
+ //#endregion
61
+ export { HvDashboard };
@@ -1,9 +1,8 @@
1
- import { css } from "@emotion/react";
2
1
  import { createClasses, theme } from "@hitachivantara/uikit-react-core";
3
- const { staticClasses, useClasses } = createClasses("HvDashboard", {
4
- root: {}
5
- });
6
- const gridStyles = css`
2
+ import { css } from "@emotion/react";
3
+ //#region src/Dashboard/Dashboard.styles.ts
4
+ var { staticClasses, useClasses } = createClasses("HvDashboard", { root: {} });
5
+ var gridStyles = css`
7
6
  .react-grid-layout {
8
7
  position: relative;
9
8
  transition: height 200ms ease;
@@ -189,8 +188,5 @@ const gridStyles = css`
189
188
  transform: rotate(45deg);
190
189
  }
191
190
  `;
192
- export {
193
- gridStyles,
194
- staticClasses,
195
- useClasses
196
- };
191
+ //#endregion
192
+ export { gridStyles, staticClasses, useClasses };
@@ -1,19 +1,13 @@
1
+ import { getColor, theme } from "@hitachivantara/uikit-styles";
1
2
  import { jsx } from "react/jsx-runtime";
2
3
  import { Background } from "reactflow";
3
- import { getColor, theme } from "@hitachivantara/uikit-styles";
4
- const HvFlowBackground = ({
5
- color = "text",
6
- ...others
7
- }) => {
8
- return /* @__PURE__ */ jsx(
9
- Background,
10
- {
11
- color: getColor(color, theme.colors.textSubtle),
12
- gap: 16,
13
- ...others
14
- }
15
- );
16
- };
17
- export {
18
- HvFlowBackground
4
+ //#region src/Flow/Background/Background.tsx
5
+ var HvFlowBackground = ({ color = "text", ...others }) => {
6
+ return /* @__PURE__ */ jsx(Background, {
7
+ color: getColor(color, theme.colors.textSubtle),
8
+ gap: 16,
9
+ ...others
10
+ });
19
11
  };
12
+ //#endregion
13
+ export { HvFlowBackground };
@@ -1,96 +1,82 @@
1
+ import { useFlowInstance } from "../hooks/useFlowInstance.js";
2
+ import { HvButton, HvMultiButton, useLabels } from "@hitachivantara/uikit-react-core";
1
3
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useStore, useStoreApi, Panel } from "reactflow";
4
+ import { Panel, useStore, useStoreApi } from "reactflow";
3
5
  import { shallow } from "zustand/shallow";
4
- import { useLabels, HvMultiButton, HvButton } from "@hitachivantara/uikit-react-core";
5
- import { ZoomIn, ZoomOut, Focus, Unlock, Lock } from "@hitachivantara/uikit-react-icons";
6
- import { useFlowInstance } from "../hooks/useFlowInstance.js";
7
- const DEFAULT_LABELS = {
8
- fitView: "Fit view",
9
- zoomIn: "Zoom in",
10
- zoomOut: "Zoom out",
11
- interactive: "Interactive"
6
+ import { Focus, Lock, Unlock, ZoomIn, ZoomOut } from "@hitachivantara/uikit-react-icons";
7
+ //#region src/Flow/Controls/Controls.tsx
8
+ var DEFAULT_LABELS = {
9
+ fitView: "Fit view",
10
+ zoomIn: "Zoom in",
11
+ zoomOut: "Zoom out",
12
+ interactive: "Interactive"
12
13
  };
13
- const selector = (state) => ({
14
- isInteractive: state.nodesDraggable || state.nodesConnectable || state.elementsSelectable,
15
- minZoomReached: state.transform[2] <= state.minZoom,
16
- maxZoomReached: state.transform[2] >= state.maxZoom
14
+ var selector = (state) => ({
15
+ isInteractive: state.nodesDraggable || state.nodesConnectable || state.elementsSelectable,
16
+ minZoomReached: state.transform[2] <= state.minZoom,
17
+ maxZoomReached: state.transform[2] >= state.maxZoom
17
18
  });
18
- const HvFlowControls = ({
19
- onZoomIn: onZoomInProp,
20
- onZoomOut: onZoomOutProp,
21
- onFitView: onFitViewProp,
22
- labels: labelsProps,
23
- hideInteractive,
24
- hideFitView,
25
- hideZoom,
26
- position = "bottom-center",
27
- orientation = "horizontal",
28
- onInteractiveChange,
29
- fitViewOptions,
30
- children,
31
- ...others
32
- }) => {
33
- const { isInteractive, minZoomReached, maxZoomReached } = useStore(
34
- selector,
35
- shallow
36
- );
37
- const store = useStoreApi();
38
- const { zoomIn, zoomOut, fitView } = useFlowInstance();
39
- const labels = useLabels(DEFAULT_LABELS, labelsProps);
40
- const handleZoomIn = () => {
41
- zoomIn();
42
- onZoomInProp?.();
43
- };
44
- const handleZoomOut = () => {
45
- zoomOut();
46
- onZoomOutProp?.();
47
- };
48
- const handleFitView = () => {
49
- fitView(fitViewOptions);
50
- onFitViewProp?.();
51
- };
52
- const handleInteractive = () => {
53
- store.setState({
54
- nodesDraggable: !isInteractive,
55
- nodesConnectable: !isInteractive,
56
- elementsSelectable: !isInteractive
57
- });
58
- onInteractiveChange?.(!isInteractive);
59
- };
60
- return /* @__PURE__ */ jsx(Panel, { position, ...others, children: /* @__PURE__ */ jsxs(HvMultiButton, { vertical: orientation === "vertical", children: [
61
- !hideZoom && /* @__PURE__ */ jsx(
62
- HvButton,
63
- {
64
- icon: true,
65
- title: labels?.zoomIn,
66
- onClick: handleZoomIn,
67
- disabled: maxZoomReached,
68
- children: /* @__PURE__ */ jsx(ZoomIn, {})
69
- }
70
- ),
71
- !hideZoom && /* @__PURE__ */ jsx(
72
- HvButton,
73
- {
74
- icon: true,
75
- title: labels?.zoomOut,
76
- onClick: handleZoomOut,
77
- disabled: minZoomReached,
78
- children: /* @__PURE__ */ jsx(ZoomOut, {})
79
- }
80
- ),
81
- !hideFitView && /* @__PURE__ */ jsx(HvButton, { icon: true, title: labels?.fitView, onClick: handleFitView, children: /* @__PURE__ */ jsx(Focus, {}) }),
82
- !hideInteractive && /* @__PURE__ */ jsx(
83
- HvButton,
84
- {
85
- icon: true,
86
- title: labels?.interactive,
87
- onClick: handleInteractive,
88
- children: isInteractive ? /* @__PURE__ */ jsx(Unlock, {}) : /* @__PURE__ */ jsx(Lock, {})
89
- }
90
- ),
91
- children
92
- ] }) });
93
- };
94
- export {
95
- HvFlowControls
19
+ var HvFlowControls = ({ onZoomIn: onZoomInProp, onZoomOut: onZoomOutProp, onFitView: onFitViewProp, labels: labelsProps, hideInteractive, hideFitView, hideZoom, position = "bottom-center", orientation = "horizontal", onInteractiveChange, fitViewOptions, children, ...others }) => {
20
+ const { isInteractive, minZoomReached, maxZoomReached } = useStore(selector, shallow);
21
+ const store = useStoreApi();
22
+ const { zoomIn, zoomOut, fitView } = useFlowInstance();
23
+ const labels = useLabels(DEFAULT_LABELS, labelsProps);
24
+ const handleZoomIn = () => {
25
+ zoomIn();
26
+ onZoomInProp?.();
27
+ };
28
+ const handleZoomOut = () => {
29
+ zoomOut();
30
+ onZoomOutProp?.();
31
+ };
32
+ const handleFitView = () => {
33
+ fitView(fitViewOptions);
34
+ onFitViewProp?.();
35
+ };
36
+ const handleInteractive = () => {
37
+ store.setState({
38
+ nodesDraggable: !isInteractive,
39
+ nodesConnectable: !isInteractive,
40
+ elementsSelectable: !isInteractive
41
+ });
42
+ onInteractiveChange?.(!isInteractive);
43
+ };
44
+ return /* @__PURE__ */ jsx(Panel, {
45
+ position,
46
+ ...others,
47
+ children: /* @__PURE__ */ jsxs(HvMultiButton, {
48
+ vertical: orientation === "vertical",
49
+ children: [
50
+ !hideZoom && /* @__PURE__ */ jsx(HvButton, {
51
+ icon: true,
52
+ title: labels?.zoomIn,
53
+ onClick: handleZoomIn,
54
+ disabled: maxZoomReached,
55
+ children: /* @__PURE__ */ jsx(ZoomIn, {})
56
+ }),
57
+ !hideZoom && /* @__PURE__ */ jsx(HvButton, {
58
+ icon: true,
59
+ title: labels?.zoomOut,
60
+ onClick: handleZoomOut,
61
+ disabled: minZoomReached,
62
+ children: /* @__PURE__ */ jsx(ZoomOut, {})
63
+ }),
64
+ !hideFitView && /* @__PURE__ */ jsx(HvButton, {
65
+ icon: true,
66
+ title: labels?.fitView,
67
+ onClick: handleFitView,
68
+ children: /* @__PURE__ */ jsx(Focus, {})
69
+ }),
70
+ !hideInteractive && /* @__PURE__ */ jsx(HvButton, {
71
+ icon: true,
72
+ title: labels?.interactive,
73
+ onClick: handleInteractive,
74
+ children: isInteractive ? /* @__PURE__ */ jsx(Unlock, {}) : /* @__PURE__ */ jsx(Lock, {})
75
+ }),
76
+ children
77
+ ]
78
+ })
79
+ });
96
80
  };
81
+ //#endregion
82
+ export { HvFlowControls };