@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.
Files changed (68) hide show
  1. package/dist/Blade/Blade.js +134 -173
  2. package/dist/Blade/Blade.styles.js +54 -69
  3. package/dist/Blades/Blades.js +70 -101
  4. package/dist/Blades/Blades.styles.js +7 -10
  5. package/dist/Dashboard/Dashboard.js +57 -60
  6. package/dist/Dashboard/Dashboard.styles.js +6 -10
  7. package/dist/Flow/Background/Background.js +10 -16
  8. package/dist/Flow/Controls/Controls.js +77 -91
  9. package/dist/Flow/DroppableFlow.js +135 -200
  10. package/dist/Flow/Empty/Empty.js +12 -9
  11. package/dist/Flow/Empty/Empty.styles.js +12 -15
  12. package/dist/Flow/Flow.js +28 -30
  13. package/dist/Flow/Flow.styles.js +12 -18
  14. package/dist/Flow/FlowContext/FlowContext.js +22 -23
  15. package/dist/Flow/FlowContext/NodeMetaContext.js +36 -39
  16. package/dist/Flow/Minimap/Minimap.js +15 -28
  17. package/dist/Flow/Minimap/Minimap.styles.js +4 -9
  18. package/dist/Flow/Node/BaseNode.js +144 -190
  19. package/dist/Flow/Node/BaseNode.styles.js +122 -133
  20. package/dist/Flow/Node/Node.js +90 -108
  21. package/dist/Flow/Node/Node.styles.js +30 -40
  22. package/dist/Flow/Node/Parameters/ParamRenderer.js +17 -14
  23. package/dist/Flow/Node/Parameters/Select.js +33 -38
  24. package/dist/Flow/Node/Parameters/Slider.js +27 -29
  25. package/dist/Flow/Node/Parameters/Text.js +17 -17
  26. package/dist/Flow/Node/utils.js +44 -49
  27. package/dist/Flow/Sidebar/Sidebar.js +115 -137
  28. package/dist/Flow/Sidebar/Sidebar.styles.js +21 -22
  29. package/dist/Flow/Sidebar/SidebarGroup/SidebarGroup.js +57 -60
  30. package/dist/Flow/Sidebar/SidebarGroup/SidebarGroup.styles.js +27 -33
  31. package/dist/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.js +27 -47
  32. package/dist/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.js +14 -32
  33. package/dist/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.styles.js +17 -23
  34. package/dist/Flow/base.js +5 -5
  35. package/dist/Flow/hooks/useFlowContext.js +5 -5
  36. package/dist/Flow/hooks/useFlowInstance.js +5 -4
  37. package/dist/Flow/hooks/useFlowNode.js +92 -113
  38. package/dist/Flow/hooks/useFlowNodeMeta.js +7 -7
  39. package/dist/Flow/hooks/useNode.js +136 -154
  40. package/dist/Flow/hooks/useNodeId.js +8 -7
  41. package/dist/Flow/nodes/DashboardNode.js +64 -86
  42. package/dist/Flow/nodes/DashboardNode.styles.js +8 -14
  43. package/dist/Flow/nodes/StickyNode.js +370 -435
  44. package/dist/StepNavigation/DefaultNavigation/DefaultNavigation.js +36 -52
  45. package/dist/StepNavigation/DefaultNavigation/Step/Step.js +40 -51
  46. package/dist/StepNavigation/DefaultNavigation/Step/Step.styles.js +22 -33
  47. package/dist/StepNavigation/DefaultNavigation/utils.js +38 -30
  48. package/dist/StepNavigation/SimpleNavigation/Dot/Dot.js +24 -41
  49. package/dist/StepNavigation/SimpleNavigation/Dot/Dot.styles.js +13 -16
  50. package/dist/StepNavigation/SimpleNavigation/SimpleNavigation.js +35 -47
  51. package/dist/StepNavigation/SimpleNavigation/utils.js +10 -11
  52. package/dist/StepNavigation/StepNavigation.js +136 -179
  53. package/dist/StepNavigation/StepNavigation.styles.js +29 -32
  54. package/dist/Wizard/Wizard.js +81 -104
  55. package/dist/Wizard/Wizard.styles.js +4 -7
  56. package/dist/Wizard/WizardActions/WizardActions.js +111 -131
  57. package/dist/Wizard/WizardActions/WizardActions.styles.js +19 -20
  58. package/dist/Wizard/WizardContainer/WizardContainer.js +19 -28
  59. package/dist/Wizard/WizardContainer/WizardContainer.styles.js +8 -14
  60. package/dist/Wizard/WizardContent/WizardContent.js +103 -120
  61. package/dist/Wizard/WizardContent/WizardContent.styles.js +33 -36
  62. package/dist/Wizard/WizardContext/WizardContext.js +10 -13
  63. package/dist/Wizard/WizardTitle/WizardTitle.js +74 -79
  64. package/dist/Wizard/WizardTitle/WizardTitle.styles.js +12 -15
  65. package/dist/index.d.ts +1 -1
  66. package/dist/index.js +30 -81
  67. package/package.json +6 -6
  68. package/dist/StepNavigation/utils.js +0 -8
@@ -1,205 +1,140 @@
1
- import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
- import { useState, useRef, useCallback } from "react";
3
- import { useDroppable, useDndMonitor } from "@dnd-kit/core";
4
- import { Global } from "@emotion/react";
5
- import { addEdge, applyNodeChanges, applyEdgeChanges, MarkerType, ReactFlow } from "reactflow";
6
- import { uid } from "uid";
7
- import { useUniqueId } from "@hitachivantara/uikit-react-core";
1
+ import { useFlowInstance } from "./hooks/useFlowInstance.js";
2
+ import { useNodeMetaRegistry } from "./FlowContext/NodeMetaContext.js";
8
3
  import { flowStyles } from "./base.js";
9
4
  import { useClasses } from "./Flow.styles.js";
10
- import { staticClasses } from "./Flow.styles.js";
11
- import { useNodeMetaRegistry } from "./FlowContext/NodeMetaContext.js";
12
- import { useFlowInstance } from "./hooks/useFlowInstance.js";
13
- const getNode = (nodes, nodeId) => {
14
- return nodes.find((n) => n.id === nodeId);
15
- };
16
- const validateEdge = (nodes, edges, connection, nodeMetaRegistry) => {
17
- const {
18
- source: sourceId,
19
- sourceHandle,
20
- target: targetId,
21
- targetHandle
22
- } = connection;
23
- if (!sourceHandle || !targetHandle || !sourceId || !targetId) return false;
24
- const sourceNode = getNode(nodes, sourceId);
25
- const targetNode = getNode(nodes, targetId);
26
- if (!sourceNode || !targetNode) return false;
27
- const sourceType = sourceNode.type;
28
- const targetType = targetNode.type;
29
- if (!sourceType || !targetType) return false;
30
- const inputs = nodeMetaRegistry[targetId]?.inputs || [];
31
- const outputs = nodeMetaRegistry[sourceId]?.outputs || [];
32
- const source = outputs.flatMap((out) => out.outputs || out).find((out) => out.id === sourceHandle);
33
- const target = inputs.flatMap((inp) => inp.inputs || inp).find((inp) => inp.id === targetHandle);
34
- const sourceProvides = source?.provides || "";
35
- const targetAccepts = target?.accepts || [];
36
- const sourceMaxConnections = source?.maxConnections;
37
- const targetMaxConnections = target?.maxConnections;
38
- let isValid = targetAccepts.length === 0 || targetAccepts.includes(sourceProvides);
39
- if (isValid && targetMaxConnections != null) {
40
- const targetConnections = edges.filter(
41
- (edg) => edg.target === targetId && edg.targetHandle === targetHandle
42
- ).length;
43
- isValid = targetConnections < targetMaxConnections;
44
- }
45
- if (isValid && sourceMaxConnections != null) {
46
- const sourceConnections = edges.filter(
47
- (edg) => edg.source === sourceId && edg.sourceHandle === sourceHandle
48
- ).length;
49
- isValid = sourceConnections < sourceMaxConnections;
50
- }
51
- return isValid;
5
+ import { useCallback, useRef, useState } from "react";
6
+ import { useUniqueId } from "@hitachivantara/uikit-react-core";
7
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
+ import { Global } from "@emotion/react";
9
+ import { MarkerType, ReactFlow, addEdge, applyEdgeChanges, applyNodeChanges } from "reactflow";
10
+ import { uid } from "uid";
11
+ import { useDndMonitor, useDroppable } from "@dnd-kit/core";
12
+ //#region src/Flow/DroppableFlow.tsx
13
+ var getNode = (nodes, nodeId) => {
14
+ return nodes.find((n) => n.id === nodeId);
52
15
  };
53
- const HvDroppableFlow = ({
54
- id,
55
- className,
56
- children,
57
- onFlowChange,
58
- onDndDrop,
59
- classes: classesProp,
60
- nodes: initialNodes = [],
61
- edges: initialEdges = [],
62
- onConnect: onConnectProp,
63
- onNodesChange: onNodesChangeProp,
64
- onEdgesChange: onEdgesChangeProp,
65
- defaultEdgeOptions: defaultEdgeOptionsProp,
66
- nodeTypes,
67
- ...others
68
- }) => {
69
- const { classes, cx } = useClasses(classesProp);
70
- const elementId = useUniqueId(id);
71
- const reactFlowInstance = useFlowInstance();
72
- const [nodes, setNodes] = useState(initialNodes);
73
- const [edges, setEdges] = useState(initialEdges);
74
- const nodesRef = useRef(initialNodes);
75
- const edgesRef = useRef(initialEdges);
76
- const updateNodes = (nds) => {
77
- setNodes(nds);
78
- nodesRef.current = nds;
79
- };
80
- const updateEdges = (eds) => {
81
- setEdges(eds);
82
- edgesRef.current = eds;
83
- };
84
- const { setNodeRef } = useDroppable({
85
- id: elementId
86
- });
87
- const handleDragEnd = useCallback(
88
- (event) => {
89
- if (event.over?.id !== elementId) return;
90
- const hvFlow = event.active.data.current?.hvFlow;
91
- const type = hvFlow?.type;
92
- if (!type || !nodeTypes?.[type]) {
93
- return;
94
- }
95
- const position = reactFlowInstance.screenToFlowPosition({
96
- x: hvFlow?.x || 0,
97
- y: hvFlow?.y || 0
98
- });
99
- const data = {
100
- nodeLabel: hvFlow?.label,
101
- ...hvFlow?.data
102
- };
103
- const newNode = {
104
- id: uid(),
105
- position,
106
- data,
107
- type
108
- };
109
- if (onDndDrop) {
110
- onDndDrop(event, newNode);
111
- return;
112
- }
113
- updateNodes(nodes.concat(newNode));
114
- },
115
- [elementId, nodeTypes, nodes, onDndDrop, reactFlowInstance]
116
- );
117
- useDndMonitor({
118
- onDragEnd: handleDragEnd
119
- });
120
- const handleFlowChange = useCallback(
121
- (nds, eds) => {
122
- const isDragging = nds.find((node) => node.dragging);
123
- if (!isDragging) {
124
- onFlowChange?.(nds, eds);
125
- }
126
- },
127
- [onFlowChange]
128
- );
129
- const handleConnect = useCallback(
130
- (connection) => {
131
- const eds = addEdge(connection, edgesRef.current);
132
- updateEdges(eds);
133
- handleFlowChange(nodesRef.current, eds);
134
- onConnectProp?.(connection);
135
- },
136
- [handleFlowChange, onConnectProp]
137
- );
138
- const handleNodesChange = useCallback(
139
- (changes) => {
140
- const nds = applyNodeChanges(changes, nodesRef.current);
141
- updateNodes(nds);
142
- handleFlowChange(nds, edgesRef.current);
143
- onNodesChangeProp?.(changes);
144
- },
145
- [handleFlowChange, onNodesChangeProp]
146
- );
147
- const handleEdgesChange = useCallback(
148
- (changes) => {
149
- const eds = applyEdgeChanges(changes, edgesRef.current);
150
- updateEdges(eds);
151
- handleFlowChange(nodesRef.current, eds);
152
- onEdgesChangeProp?.(changes);
153
- },
154
- [handleFlowChange, onEdgesChangeProp]
155
- );
156
- const { registry } = useNodeMetaRegistry();
157
- const isValidConnection = (connection) => validateEdge(nodes, edges, connection, registry);
158
- const defaultEdgeOptions = {
159
- markerEnd: {
160
- type: MarkerType.ArrowClosed,
161
- height: 20,
162
- width: 20
163
- },
164
- type: "smoothstep",
165
- pathOptions: {
166
- borderRadius: 40
167
- },
168
- ...defaultEdgeOptionsProp
169
- };
170
- return /* @__PURE__ */ jsxs(Fragment, { children: [
171
- /* @__PURE__ */ jsx(Global, { styles: flowStyles }),
172
- /* @__PURE__ */ jsx(
173
- "div",
174
- {
175
- id: elementId,
176
- ref: setNodeRef,
177
- className: cx(classes.root, className),
178
- children: /* @__PURE__ */ jsx(
179
- ReactFlow,
180
- {
181
- nodes,
182
- edges,
183
- nodeTypes,
184
- onNodesChange: handleNodesChange,
185
- onEdgesChange: handleEdgesChange,
186
- onConnect: handleConnect,
187
- isValidConnection,
188
- defaultEdgeOptions,
189
- snapGrid: [1, 1],
190
- snapToGrid: true,
191
- onError: (code, message) => {
192
- },
193
- ...others,
194
- children
195
- }
196
- )
197
- }
198
- )
199
- ] });
16
+ var validateEdge = (nodes, edges, connection, nodeMetaRegistry) => {
17
+ const { source: sourceId, sourceHandle, target: targetId, targetHandle } = connection;
18
+ if (!sourceHandle || !targetHandle || !sourceId || !targetId) return false;
19
+ const sourceNode = getNode(nodes, sourceId);
20
+ const targetNode = getNode(nodes, targetId);
21
+ if (!sourceNode || !targetNode) return false;
22
+ const sourceType = sourceNode.type;
23
+ const targetType = targetNode.type;
24
+ if (!sourceType || !targetType) return false;
25
+ const inputs = nodeMetaRegistry[targetId]?.inputs || [];
26
+ const source = (nodeMetaRegistry[sourceId]?.outputs || []).flatMap((out) => out.outputs || out).find((out) => out.id === sourceHandle);
27
+ const target = inputs.flatMap((inp) => inp.inputs || inp).find((inp) => inp.id === targetHandle);
28
+ const sourceProvides = source?.provides || "";
29
+ const targetAccepts = target?.accepts || [];
30
+ const sourceMaxConnections = source?.maxConnections;
31
+ const targetMaxConnections = target?.maxConnections;
32
+ let isValid = targetAccepts.length === 0 || targetAccepts.includes(sourceProvides);
33
+ if (isValid && targetMaxConnections != null) isValid = edges.filter((edg) => edg.target === targetId && edg.targetHandle === targetHandle).length < targetMaxConnections;
34
+ if (isValid && sourceMaxConnections != null) isValid = edges.filter((edg) => edg.source === sourceId && edg.sourceHandle === sourceHandle).length < sourceMaxConnections;
35
+ return isValid;
200
36
  };
201
- export {
202
- HvDroppableFlow,
203
- staticClasses as flowClasses,
204
- getNode
37
+ var HvDroppableFlow = ({ id, className, children, onFlowChange, onDndDrop, classes: classesProp, nodes: initialNodes = [], edges: initialEdges = [], onConnect: onConnectProp, onNodesChange: onNodesChangeProp, onEdgesChange: onEdgesChangeProp, defaultEdgeOptions: defaultEdgeOptionsProp, nodeTypes, ...others }) => {
38
+ const { classes, cx } = useClasses(classesProp);
39
+ const elementId = useUniqueId(id);
40
+ const reactFlowInstance = useFlowInstance();
41
+ const [nodes, setNodes] = useState(initialNodes);
42
+ const [edges, setEdges] = useState(initialEdges);
43
+ const nodesRef = useRef(initialNodes);
44
+ const edgesRef = useRef(initialEdges);
45
+ const updateNodes = (nds) => {
46
+ setNodes(nds);
47
+ nodesRef.current = nds;
48
+ };
49
+ const updateEdges = (eds) => {
50
+ setEdges(eds);
51
+ edgesRef.current = eds;
52
+ };
53
+ const { setNodeRef } = useDroppable({ id: elementId });
54
+ useDndMonitor({ onDragEnd: useCallback((event) => {
55
+ if (event.over?.id !== elementId) return;
56
+ const hvFlow = event.active.data.current?.hvFlow;
57
+ const type = hvFlow?.type;
58
+ if (!type || !nodeTypes?.[type]) return;
59
+ const position = reactFlowInstance.screenToFlowPosition({
60
+ x: hvFlow?.x || 0,
61
+ y: hvFlow?.y || 0
62
+ });
63
+ const data = {
64
+ nodeLabel: hvFlow?.label,
65
+ ...hvFlow?.data
66
+ };
67
+ const newNode = {
68
+ id: uid(),
69
+ position,
70
+ data,
71
+ type
72
+ };
73
+ if (onDndDrop) {
74
+ onDndDrop(event, newNode);
75
+ return;
76
+ }
77
+ updateNodes(nodes.concat(newNode));
78
+ }, [
79
+ elementId,
80
+ nodeTypes,
81
+ nodes,
82
+ onDndDrop,
83
+ reactFlowInstance
84
+ ]) });
85
+ const handleFlowChange = useCallback((nds, eds) => {
86
+ if (!nds.find((node) => node.dragging)) onFlowChange?.(nds, eds);
87
+ }, [onFlowChange]);
88
+ const handleConnect = useCallback((connection) => {
89
+ const eds = addEdge(connection, edgesRef.current);
90
+ updateEdges(eds);
91
+ handleFlowChange(nodesRef.current, eds);
92
+ onConnectProp?.(connection);
93
+ }, [handleFlowChange, onConnectProp]);
94
+ const handleNodesChange = useCallback((changes) => {
95
+ const nds = applyNodeChanges(changes, nodesRef.current);
96
+ updateNodes(nds);
97
+ handleFlowChange(nds, edgesRef.current);
98
+ onNodesChangeProp?.(changes);
99
+ }, [handleFlowChange, onNodesChangeProp]);
100
+ const handleEdgesChange = useCallback((changes) => {
101
+ const eds = applyEdgeChanges(changes, edgesRef.current);
102
+ updateEdges(eds);
103
+ handleFlowChange(nodesRef.current, eds);
104
+ onEdgesChangeProp?.(changes);
105
+ }, [handleFlowChange, onEdgesChangeProp]);
106
+ const { registry } = useNodeMetaRegistry();
107
+ const isValidConnection = (connection) => validateEdge(nodes, edges, connection, registry);
108
+ const defaultEdgeOptions = {
109
+ markerEnd: {
110
+ type: MarkerType.ArrowClosed,
111
+ height: 20,
112
+ width: 20
113
+ },
114
+ type: "smoothstep",
115
+ pathOptions: { borderRadius: 40 },
116
+ ...defaultEdgeOptionsProp
117
+ };
118
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Global, { styles: flowStyles }), /* @__PURE__ */ jsx("div", {
119
+ id: elementId,
120
+ ref: setNodeRef,
121
+ className: cx(classes.root, className),
122
+ children: /* @__PURE__ */ jsx(ReactFlow, {
123
+ nodes,
124
+ edges,
125
+ nodeTypes,
126
+ onNodesChange: handleNodesChange,
127
+ onEdgesChange: handleEdgesChange,
128
+ onConnect: handleConnect,
129
+ isValidConnection,
130
+ defaultEdgeOptions,
131
+ snapGrid: [1, 1],
132
+ snapToGrid: true,
133
+ onError: (code, message) => {},
134
+ ...others,
135
+ children
136
+ })
137
+ })] });
205
138
  };
139
+ //#endregion
140
+ export { HvDroppableFlow };
@@ -1,12 +1,15 @@
1
+ import { useClasses } from "./Empty.styles.js";
2
+ import { HvEmptyState } from "@hitachivantara/uikit-react-core";
1
3
  import { jsx } from "react/jsx-runtime";
2
4
  import { useNodes } from "reactflow";
3
- import { HvEmptyState } from "@hitachivantara/uikit-react-core";
4
- import { useClasses } from "./Empty.styles.js";
5
- const HvFlowEmpty = ({ className, ...others }) => {
6
- const { classes, cx } = useClasses();
7
- const nodes = useNodes();
8
- return !nodes || (nodes.length === 0 ? /* @__PURE__ */ jsx(HvEmptyState, { className: cx(classes.root, className), ...others }) : null);
9
- };
10
- export {
11
- HvFlowEmpty
5
+ //#region src/Flow/Empty/Empty.tsx
6
+ var HvFlowEmpty = ({ className, ...others }) => {
7
+ const { classes, cx } = useClasses();
8
+ const nodes = useNodes();
9
+ return !nodes || (nodes.length === 0 ? /* @__PURE__ */ jsx(HvEmptyState, {
10
+ className: cx(classes.root, className),
11
+ ...others
12
+ }) : null);
12
13
  };
14
+ //#endregion
15
+ export { HvFlowEmpty };
@@ -1,16 +1,13 @@
1
1
  import { createClasses, theme } from "@hitachivantara/uikit-react-core";
2
- const { staticClasses, useClasses } = createClasses("HvFlowEmpty", {
3
- root: {
4
- width: "100%",
5
- height: "100%",
6
- alignItems: "center",
7
- justifyContent: "center",
8
- backgroundColor: theme.colors.bgPage,
9
- position: "absolute",
10
- zIndex: theme.zIndices.popover
11
- }
12
- });
13
- export {
14
- staticClasses,
15
- useClasses
16
- };
2
+ //#region src/Flow/Empty/Empty.styles.tsx
3
+ var { staticClasses, useClasses } = createClasses("HvFlowEmpty", { root: {
4
+ width: "100%",
5
+ height: "100%",
6
+ alignItems: "center",
7
+ justifyContent: "center",
8
+ backgroundColor: theme.colors.bgPage,
9
+ position: "absolute",
10
+ zIndex: theme.zIndices.popover
11
+ } });
12
+ //#endregion
13
+ export { useClasses };
package/dist/Flow/Flow.js CHANGED
@@ -1,33 +1,31 @@
1
+ import { HvFlowProvider } from "./FlowContext/FlowContext.js";
2
+ import { HvDroppableFlow } from "./DroppableFlow.js";
1
3
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext } from "@dnd-kit/core";
3
- import { restrictToWindowEdges } from "@dnd-kit/modifiers";
4
4
  import { ReactFlowProvider } from "reactflow";
5
- import { HvDroppableFlow } from "./DroppableFlow.js";
6
- import { HvFlowProvider } from "./FlowContext/FlowContext.js";
7
- const HvFlow = ({
8
- nodeGroups,
9
- sidebar,
10
- defaultActions,
11
- dndContextProps,
12
- ...others
13
- }) => {
14
- const sensors = useSensors(
15
- useSensor(PointerSensor),
16
- useSensor(KeyboardSensor)
17
- );
18
- return /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(HvFlowProvider, { nodeGroups, defaultActions, children: /* @__PURE__ */ jsxs(
19
- DndContext,
20
- {
21
- sensors,
22
- modifiers: [restrictToWindowEdges],
23
- ...dndContextProps,
24
- children: [
25
- /* @__PURE__ */ jsx(HvDroppableFlow, { ...others }),
26
- sidebar
27
- ]
28
- }
29
- ) }) });
30
- };
31
- export {
32
- HvFlow
5
+ import { DndContext, KeyboardSensor, PointerSensor, useSensor, useSensors } from "@dnd-kit/core";
6
+ import { restrictToWindowEdges } from "@dnd-kit/modifiers";
7
+ //#region src/Flow/Flow.tsx
8
+ /**
9
+ * Flow component to build interactive node-based UIs.
10
+ *
11
+ * This implementation leverages [React Flow](https://reactflow.dev).
12
+ * The drag and drop functionality leverages [Dnd Kit](https://docs.dndkit.com)
13
+ *
14
+ * Take a look at the [usage page](https://lumada-design.github.io/uikit/master/?path=/docs/lab-flow-usage--docs) to learn more about this component.
15
+ *
16
+ * DISCLAIMER: This component is a work in progress and there might be breaking changes.
17
+ */
18
+ var HvFlow = ({ nodeGroups, sidebar, defaultActions, dndContextProps, ...others }) => {
19
+ return /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(HvFlowProvider, {
20
+ nodeGroups,
21
+ defaultActions,
22
+ children: /* @__PURE__ */ jsxs(DndContext, {
23
+ sensors: useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor)),
24
+ modifiers: [restrictToWindowEdges],
25
+ ...dndContextProps,
26
+ children: [/* @__PURE__ */ jsx(HvDroppableFlow, { ...others }), sidebar]
27
+ })
28
+ }) });
33
29
  };
30
+ //#endregion
31
+ export { HvFlow };
@@ -1,19 +1,13 @@
1
- import { createClasses, theme } from "@hitachivantara/uikit-react-core";
2
1
  import { staticClasses as staticClasses$1 } from "./Node/BaseNode.styles.js";
3
- import "react/jsx-runtime";
4
- import "reactflow";
5
- import "@hitachivantara/uikit-react-utils";
6
- const { staticClasses, useClasses } = createClasses("HvFlow", {
7
- root: {
8
- height: "100%",
9
- [`& .selected > .${staticClasses$1.root}`]: {
10
- border: `1px solid ${theme.colors.textDisabled}`,
11
- borderRadius: theme.radii.round,
12
- boxSizing: "border-box"
13
- }
14
- }
15
- });
16
- export {
17
- staticClasses,
18
- useClasses
19
- };
2
+ import { createClasses, theme } from "@hitachivantara/uikit-react-core";
3
+ //#region src/Flow/Flow.styles.tsx
4
+ var { staticClasses, useClasses } = createClasses("HvFlow", { root: {
5
+ height: "100%",
6
+ [`& .selected > .${staticClasses$1.root}`]: {
7
+ border: `1px solid ${theme.colors.textDisabled}`,
8
+ borderRadius: theme.radii.round,
9
+ boxSizing: "border-box"
10
+ }
11
+ } });
12
+ //#endregion
13
+ export { staticClasses, useClasses };
@@ -1,25 +1,24 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useState, useMemo, createContext } from "react";
3
1
  import { HvFlowNodeMetaProvider } from "./NodeMetaContext.js";
4
- const HvFlowContext = createContext({});
5
- const HvFlowProvider = ({
6
- nodeGroups,
7
- defaultActions,
8
- children
9
- }) => {
10
- const [expandedNodeGroups, setExpandedNodeGroups] = useState([]);
11
- const value = useMemo(
12
- () => ({
13
- nodeGroups,
14
- defaultActions,
15
- expandedNodeGroups,
16
- setExpandedNodeGroups
17
- }),
18
- [nodeGroups, defaultActions, expandedNodeGroups]
19
- );
20
- return /* @__PURE__ */ jsx(HvFlowNodeMetaProvider, { children: /* @__PURE__ */ jsx(HvFlowContext.Provider, { value, children }) });
21
- };
22
- export {
23
- HvFlowContext,
24
- HvFlowProvider
2
+ import { createContext, useMemo, useState } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ //#region src/Flow/FlowContext/FlowContext.tsx
5
+ var HvFlowContext = createContext({});
6
+ var HvFlowProvider = ({ nodeGroups, defaultActions, children }) => {
7
+ const [expandedNodeGroups, setExpandedNodeGroups] = useState([]);
8
+ const value = useMemo(() => ({
9
+ nodeGroups,
10
+ defaultActions,
11
+ expandedNodeGroups,
12
+ setExpandedNodeGroups
13
+ }), [
14
+ nodeGroups,
15
+ defaultActions,
16
+ expandedNodeGroups
17
+ ]);
18
+ return /* @__PURE__ */ jsx(HvFlowNodeMetaProvider, { children: /* @__PURE__ */ jsx(HvFlowContext.Provider, {
19
+ value,
20
+ children
21
+ }) });
25
22
  };
23
+ //#endregion
24
+ export { HvFlowContext, HvFlowProvider };
@@ -1,43 +1,40 @@
1
+ import { createContext, useCallback, useContext, useMemo, useRef } from "react";
1
2
  import { jsx } from "react/jsx-runtime";
2
- import { useContext, createContext, useRef, useCallback, useMemo } from "react";
3
- const HvFlowNodeMetaContext = createContext(void 0);
4
- const HvFlowNodeMetaProvider = ({
5
- children
6
- }) => {
7
- const registryRef = useRef({});
8
- const registerNode = useCallback((id, nodeInfo) => {
9
- registryRef.current[id] = nodeInfo;
10
- }, []);
11
- const unregisterNode = useCallback((id) => {
12
- delete registryRef.current[id];
13
- }, []);
14
- const getRegistry = useCallback(() => {
15
- return registryRef.current;
16
- }, []);
17
- const value = useMemo(
18
- () => ({
19
- registerNode,
20
- unregisterNode,
21
- getRegistry
22
- }),
23
- [registerNode, unregisterNode, getRegistry]
24
- );
25
- return /* @__PURE__ */ jsx(HvFlowNodeMetaContext.Provider, { value, children });
3
+ //#region src/Flow/FlowContext/NodeMetaContext.tsx
4
+ var HvFlowNodeMetaContext = createContext(void 0);
5
+ var HvFlowNodeMetaProvider = ({ children }) => {
6
+ const registryRef = useRef({});
7
+ const registerNode = useCallback((id, nodeInfo) => {
8
+ registryRef.current[id] = nodeInfo;
9
+ }, []);
10
+ const unregisterNode = useCallback((id) => {
11
+ delete registryRef.current[id];
12
+ }, []);
13
+ const getRegistry = useCallback(() => {
14
+ return registryRef.current;
15
+ }, []);
16
+ const value = useMemo(() => ({
17
+ registerNode,
18
+ unregisterNode,
19
+ getRegistry
20
+ }), [
21
+ registerNode,
22
+ unregisterNode,
23
+ getRegistry
24
+ ]);
25
+ return /* @__PURE__ */ jsx(HvFlowNodeMetaContext.Provider, {
26
+ value,
27
+ children
28
+ });
26
29
  };
27
30
  function useNodeMetaRegistry() {
28
- const context = useContext(HvFlowNodeMetaContext);
29
- if (context === void 0) {
30
- throw new Error(
31
- "useNodeRegistry must be used within a HvFlowNodeMetaProvider"
32
- );
33
- }
34
- return {
35
- registerNode: context.registerNode,
36
- unregisterNode: context.unregisterNode,
37
- registry: context.getRegistry()
38
- };
31
+ const context = useContext(HvFlowNodeMetaContext);
32
+ if (context === void 0) throw new Error("useNodeRegistry must be used within a HvFlowNodeMetaProvider");
33
+ return {
34
+ registerNode: context.registerNode,
35
+ unregisterNode: context.unregisterNode,
36
+ registry: context.getRegistry()
37
+ };
39
38
  }
40
- export {
41
- HvFlowNodeMetaProvider,
42
- useNodeMetaRegistry
43
- };
39
+ //#endregion
40
+ export { HvFlowNodeMetaProvider, useNodeMetaRegistry };
@@ -1,31 +1,18 @@
1
+ import { useClasses } from "./Minimap.styles.js";
2
+ import { getColor } from "@hitachivantara/uikit-styles";
1
3
  import { jsx } from "react/jsx-runtime";
2
4
  import { MiniMap } from "reactflow";
3
- import { getColor } from "@hitachivantara/uikit-styles";
4
- import { useClasses } from "./Minimap.styles.js";
5
- import { staticClasses } from "./Minimap.styles.js";
6
- const HvFlowMinimap = ({
7
- nodeColor = "border",
8
- maskColor = "borderSubtle",
9
- maskStrokeColor = "borderSubtle",
10
- nodeStrokeColor = "border",
11
- classes: classesProp,
12
- className,
13
- ...others
14
- }) => {
15
- const { classes, cx } = useClasses(classesProp);
16
- return /* @__PURE__ */ jsx(
17
- MiniMap,
18
- {
19
- className: cx(classes.root, className),
20
- nodeColor: typeof nodeColor === "string" ? getColor(nodeColor, "border") : nodeColor,
21
- nodeStrokeColor: typeof nodeStrokeColor === "string" ? getColor(nodeStrokeColor, "border") : nodeStrokeColor,
22
- maskColor: getColor(maskColor, "borderSubtle"),
23
- maskStrokeColor: getColor(maskStrokeColor, "borderSubtle"),
24
- ...others
25
- }
26
- );
27
- };
28
- export {
29
- HvFlowMinimap,
30
- staticClasses as flowMinimapClasses
5
+ //#region src/Flow/Minimap/Minimap.tsx
6
+ var HvFlowMinimap = ({ nodeColor = "border", maskColor = "borderSubtle", maskStrokeColor = "borderSubtle", nodeStrokeColor = "border", classes: classesProp, className, ...others }) => {
7
+ const { classes, cx } = useClasses(classesProp);
8
+ return /* @__PURE__ */ jsx(MiniMap, {
9
+ className: cx(classes.root, className),
10
+ nodeColor: typeof nodeColor === "string" ? getColor(nodeColor, "border") : nodeColor,
11
+ nodeStrokeColor: typeof nodeStrokeColor === "string" ? getColor(nodeStrokeColor, "border") : nodeStrokeColor,
12
+ maskColor: getColor(maskColor, "borderSubtle"),
13
+ maskStrokeColor: getColor(maskStrokeColor, "borderSubtle"),
14
+ ...others
15
+ });
31
16
  };
17
+ //#endregion
18
+ export { HvFlowMinimap };