@hitachivantara/uikit-react-lab 5.9.0 → 5.11.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.
Files changed (60) hide show
  1. package/dist/cjs/components/Flow/DroppableFlow.cjs +54 -67
  2. package/dist/cjs/components/Flow/DroppableFlow.cjs.map +1 -1
  3. package/dist/cjs/components/Flow/Empty/Empty.cjs +19 -0
  4. package/dist/cjs/components/Flow/Empty/Empty.cjs.map +1 -0
  5. package/dist/cjs/components/Flow/Empty/Empty.styles.cjs +20 -0
  6. package/dist/cjs/components/Flow/Empty/Empty.styles.cjs.map +1 -0
  7. package/dist/cjs/components/Flow/Flow.cjs +2 -15
  8. package/dist/cjs/components/Flow/Flow.cjs.map +1 -1
  9. package/dist/cjs/components/Flow/Flow.styles.cjs +2 -2
  10. package/dist/cjs/components/Flow/FlowContext/FlowContext.cjs +0 -2
  11. package/dist/cjs/components/Flow/FlowContext/FlowContext.cjs.map +1 -1
  12. package/dist/cjs/components/Flow/Node/Node.cjs +6 -6
  13. package/dist/cjs/components/Flow/Node/Node.cjs.map +1 -1
  14. package/dist/cjs/components/Flow/Sidebar/Sidebar.cjs +40 -21
  15. package/dist/cjs/components/Flow/Sidebar/Sidebar.cjs.map +1 -1
  16. package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroup.cjs +3 -3
  17. package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroup.cjs.map +1 -1
  18. package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.cjs +12 -4
  19. package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.cjs.map +1 -1
  20. package/dist/cjs/components/Flow/Sidebar/utils.cjs +4 -3
  21. package/dist/cjs/components/Flow/Sidebar/utils.cjs.map +1 -1
  22. package/dist/cjs/components/Flow/base.cjs +16 -0
  23. package/dist/cjs/components/Flow/base.cjs.map +1 -0
  24. package/dist/cjs/components/Flow/hooks/useFlowContext.cjs +7 -0
  25. package/dist/cjs/components/Flow/hooks/useFlowContext.cjs.map +1 -0
  26. package/dist/cjs/components/Flow/hooks/useFlowNode.cjs +25 -0
  27. package/dist/cjs/components/Flow/hooks/useFlowNode.cjs.map +1 -0
  28. package/dist/cjs/index.cjs +6 -0
  29. package/dist/cjs/index.cjs.map +1 -1
  30. package/dist/esm/components/Flow/DroppableFlow.js +54 -67
  31. package/dist/esm/components/Flow/DroppableFlow.js.map +1 -1
  32. package/dist/esm/components/Flow/Empty/Empty.js +19 -0
  33. package/dist/esm/components/Flow/Empty/Empty.js.map +1 -0
  34. package/dist/esm/components/Flow/Empty/Empty.styles.js +20 -0
  35. package/dist/esm/components/Flow/Empty/Empty.styles.js.map +1 -0
  36. package/dist/esm/components/Flow/Flow.js +3 -16
  37. package/dist/esm/components/Flow/Flow.js.map +1 -1
  38. package/dist/esm/components/Flow/Flow.styles.js +2 -2
  39. package/dist/esm/components/Flow/FlowContext/FlowContext.js +2 -4
  40. package/dist/esm/components/Flow/FlowContext/FlowContext.js.map +1 -1
  41. package/dist/esm/components/Flow/Node/Node.js +5 -5
  42. package/dist/esm/components/Flow/Node/Node.js.map +1 -1
  43. package/dist/esm/components/Flow/Sidebar/Sidebar.js +41 -22
  44. package/dist/esm/components/Flow/Sidebar/Sidebar.js.map +1 -1
  45. package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroup.js +2 -2
  46. package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroup.js.map +1 -1
  47. package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.js +12 -4
  48. package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.js.map +1 -1
  49. package/dist/esm/components/Flow/Sidebar/utils.js +4 -3
  50. package/dist/esm/components/Flow/Sidebar/utils.js.map +1 -1
  51. package/dist/esm/components/Flow/base.js +16 -0
  52. package/dist/esm/components/Flow/base.js.map +1 -0
  53. package/dist/esm/components/Flow/hooks/useFlowContext.js +7 -0
  54. package/dist/esm/components/Flow/hooks/useFlowContext.js.map +1 -0
  55. package/dist/esm/components/Flow/hooks/useFlowNode.js +25 -0
  56. package/dist/esm/components/Flow/hooks/useFlowNode.js.map +1 -0
  57. package/dist/esm/index.js +6 -0
  58. package/dist/esm/index.js.map +1 -1
  59. package/dist/types/index.d.ts +39 -16
  60. package/package.json +4 -4
@@ -1,44 +1,42 @@
1
- import { jsx } from "@emotion/react/jsx-runtime";
1
+ import { jsxs, Fragment, jsx } from "@emotion/react/jsx-runtime";
2
2
  import { useState, useCallback } from "react";
3
3
  import ReactFlow, { useReactFlow, addEdge, applyNodeChanges, applyEdgeChanges, MarkerType } from "reactflow";
4
- import "reactflow/dist/style.css";
4
+ import { Global } from "@emotion/react";
5
5
  import { useDroppable, useDndMonitor } from "@dnd-kit/core";
6
6
  import { uid } from "uid";
7
7
  import { useUniqueId } from "@hitachivantara/uikit-react-core";
8
8
  import { useClasses } from "./Flow.styles.js";
9
9
  import { staticClasses } from "./Flow.styles.js";
10
- import { useFlowContext } from "./FlowContext/FlowContext.js";
10
+ import { flowStyles } from "./base.js";
11
+ import { useFlowContext } from "./hooks/useFlowContext.js";
11
12
  const getNode = (nodes, nodeId) => {
12
13
  return nodes.find((n) => n.id === nodeId);
13
14
  };
15
+ const validateEdge = (nodes, edge, nodeTypes) => {
16
+ var _a, _b, _c, _d, _e, _f;
17
+ if (!edge.sourceHandle || !edge.targetHandle)
18
+ return false;
19
+ const sourceNode = getNode(nodes, edge.source);
20
+ const targetNode = getNode(nodes, edge.target);
21
+ if (!sourceNode || !targetNode)
22
+ return false;
23
+ const sourceType = sourceNode.type;
24
+ const targetType = targetNode.type;
25
+ if (!sourceType || !targetType)
26
+ return false;
27
+ const inputs = ((_b = (_a = nodeTypes == null ? void 0 : nodeTypes[targetType]) == null ? void 0 : _a.meta) == null ? void 0 : _b.inputs) || [];
28
+ const outputs = ((_d = (_c = nodeTypes == null ? void 0 : nodeTypes[sourceType]) == null ? void 0 : _c.meta) == null ? void 0 : _d.outputs) || [];
29
+ const sourceProvides = ((_e = outputs[edge.sourceHandle]) == null ? void 0 : _e.provides) || "";
30
+ const targetAccepts = ((_f = inputs[edge.targetHandle]) == null ? void 0 : _f.accepts) || [];
31
+ const isValid = targetAccepts.includes(sourceProvides);
32
+ return isValid;
33
+ };
14
34
  const validateEdges = (edges, nodes, nodeTypes) => {
15
35
  if (edges) {
16
36
  const validEdges = [];
17
37
  edges.forEach((edge) => {
18
- var _a, _b, _c, _d, _e, _f;
19
- if (!edge.sourceHandle || !edge.targetHandle)
20
- return [];
21
- const sourceNode = getNode(nodes, edge.source);
22
- const targetNode = getNode(nodes, edge.target);
23
- if (!sourceNode || !targetNode)
24
- return [];
25
- const sourceType = sourceNode.type;
26
- const targetType = targetNode.type;
27
- if (!sourceType || !targetType)
28
- return [];
29
- const output = (_c = (_b = (_a = nodeTypes == null ? void 0 : nodeTypes[sourceType]) == null ? void 0 : _a.meta) == null ? void 0 : _b.outputs) == null ? void 0 : _c[edge.sourceHandle];
30
- const input = (_f = (_e = (_d = nodeTypes == null ? void 0 : nodeTypes[targetType]) == null ? void 0 : _d.meta) == null ? void 0 : _e.inputs) == null ? void 0 : _f[edge.targetHandle];
31
- const sourceProvides = (output == null ? void 0 : output.provides) || [];
32
- const targetAccepts = (input == null ? void 0 : input.accepts) || [];
33
- let isValid = false;
34
- sourceProvides.forEach((s) => {
35
- targetAccepts.forEach((t) => {
36
- if (s === t) {
37
- isValid = true;
38
- }
39
- });
40
- });
41
- if (isValid) {
38
+ const isValidEdge = validateEdge(nodes, edge, nodeTypes);
39
+ if (isValidEdge) {
42
40
  validEdges.push(edge);
43
41
  }
44
42
  });
@@ -57,6 +55,7 @@ const HvDroppableFlow = ({
57
55
  onConnect: onConnectProp,
58
56
  onNodesChange: onNodesChangeProp,
59
57
  onEdgesChange: onEdgesChangeProp,
58
+ defaultEdgeOptions: defaultEdgeOptionsProp,
60
59
  ...others
61
60
  }) => {
62
61
  const {
@@ -76,22 +75,27 @@ const HvDroppableFlow = ({
76
75
  id: elementId
77
76
  });
78
77
  const handleDragEnd = useCallback((event) => {
79
- var _a, _b, _c, _d;
78
+ var _a, _b, _c, _d, _e, _f, _g, _h;
80
79
  if (event.over && event.over.id === elementId) {
81
- const type = event.active.id.toString();
82
- const position = reactFlowInstance.project({
83
- x: (((_b = (_a = event.active.data.current) == null ? void 0 : _a.hvFlow) == null ? void 0 : _b.x) || 0) - event.over.rect.left,
84
- y: (((_d = (_c = event.active.data.current) == null ? void 0 : _c.hvFlow) == null ? void 0 : _d.y) || 0) - event.over.rect.top
85
- });
86
- const newNode = {
87
- id: uid(),
88
- position,
89
- data: {},
90
- type
91
- };
92
- setNodes((nds) => nds.concat(newNode));
80
+ const type = (_b = (_a = event.active.data.current) == null ? void 0 : _a.hvFlow) == null ? void 0 : _b.type;
81
+ if (type && (nodeTypes == null ? void 0 : nodeTypes[type])) {
82
+ const position = reactFlowInstance.project({
83
+ x: (((_d = (_c = event.active.data.current) == null ? void 0 : _c.hvFlow) == null ? void 0 : _d.x) || 0) - event.over.rect.left,
84
+ y: (((_f = (_e = event.active.data.current) == null ? void 0 : _e.hvFlow) == null ? void 0 : _f.y) || 0) - event.over.rect.top
85
+ });
86
+ const data = ((_h = (_g = event.active.data.current) == null ? void 0 : _g.hvFlow) == null ? void 0 : _h.data) || {};
87
+ const newNode = {
88
+ id: uid(),
89
+ position,
90
+ data,
91
+ type
92
+ };
93
+ setNodes((nds) => nds.concat(newNode));
94
+ } else {
95
+ console.error(`Could not add node to the flow because of unknown type ${type}. Use nodeTypes to define all the node types.`);
96
+ }
93
97
  }
94
- }, [elementId, reactFlowInstance, setNodes]);
98
+ }, [elementId, nodeTypes, reactFlowInstance]);
95
99
  useDndMonitor({
96
100
  onDragEnd: handleDragEnd
97
101
  });
@@ -120,39 +124,22 @@ const HvDroppableFlow = ({
120
124
  onEdgesChangeProp == null ? void 0 : onEdgesChangeProp(changes);
121
125
  }, [edges, handleFlowChange, nodes, onEdgesChangeProp]);
122
126
  const isValidConnection = (connection) => {
123
- var _a, _b, _c, _d, _e, _f;
124
- const sourceNode = getNode(nodes, connection.source);
125
- const targetNode = getNode(nodes, connection.target);
126
- if (!sourceNode || !targetNode) {
127
- return false;
128
- }
129
- const sourceType = sourceNode.type;
130
- const targetType = targetNode.type;
131
- if (!sourceType || !targetType) {
132
- return false;
133
- }
134
- const inputs = ((_b = (_a = nodeTypes == null ? void 0 : nodeTypes[targetType]) == null ? void 0 : _a.meta) == null ? void 0 : _b.inputs) || [];
135
- const outputs = ((_d = (_c = nodeTypes == null ? void 0 : nodeTypes[sourceType]) == null ? void 0 : _c.meta) == null ? void 0 : _d.outputs) || [];
136
- const sourceProvides = ((_e = outputs[connection.sourceHandle]) == null ? void 0 : _e.provides) || [];
137
- const targetAccepts = ((_f = inputs[connection.targetHandle]) == null ? void 0 : _f.accepts) || [];
138
- let isValid = false;
139
- sourceProvides.forEach((s) => {
140
- targetAccepts.forEach((t) => {
141
- if (s === t) {
142
- isValid = true;
143
- }
144
- });
145
- });
127
+ const isValid = validateEdge(nodes, connection, nodeTypes);
146
128
  return isValid;
147
129
  };
148
130
  const validEdges = validateEdges(edges, nodes, nodeTypes);
149
- return /* @__PURE__ */ jsx("div", { id: elementId, ref: setNodeRef, className: cx(classes.root, className), children: /* @__PURE__ */ jsx(ReactFlow, { nodes, edges: validEdges, nodeTypes, onNodesChange: handleNodesChange, onEdgesChange: handleEdgesChange, onConnect: handleConnect, isValidConnection, defaultEdgeOptions: {
131
+ const defaultEdgeOptions = {
150
132
  markerEnd: {
151
133
  type: MarkerType.ArrowClosed,
152
134
  height: 20,
153
135
  width: 20
154
- }
155
- }, ...others, children }) });
136
+ },
137
+ ...defaultEdgeOptionsProp
138
+ };
139
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
140
+ /* @__PURE__ */ jsx(Global, { styles: flowStyles }),
141
+ /* @__PURE__ */ jsx("div", { id: elementId, ref: setNodeRef, className: cx(classes.root, className), children: /* @__PURE__ */ jsx(ReactFlow, { nodes, edges: validEdges, nodeTypes, onNodesChange: handleNodesChange, onEdgesChange: handleEdgesChange, onConnect: handleConnect, isValidConnection, defaultEdgeOptions, ...others, children }) })
142
+ ] });
156
143
  };
157
144
  export {
158
145
  HvDroppableFlow,
@@ -1 +1 @@
1
- {"version":3,"file":"DroppableFlow.js","sources":["../../../../src/components/Flow/DroppableFlow.tsx"],"sourcesContent":["import { useCallback, useState } from \"react\";\n\nimport ReactFlow, {\n Connection,\n EdgeChange,\n NodeChange,\n ReactFlowProps,\n addEdge,\n applyEdgeChanges,\n applyNodeChanges,\n useReactFlow,\n MarkerType,\n Edge,\n Node,\n} from \"reactflow\";\nimport \"reactflow/dist/style.css\";\n\nimport { DragEndEvent, useDndMonitor, useDroppable } from \"@dnd-kit/core\";\n\nimport { uid } from \"uid\";\n\nimport { ExtractNames, useUniqueId } from \"@hitachivantara/uikit-react-core\";\n\nimport { HvFlowNodeTypes } from \"./types\";\nimport { staticClasses, useClasses } from \"./Flow.styles\";\nimport { useFlowContext } from \"./FlowContext\";\n\nexport { staticClasses as flowClasses };\n\nexport type HvFlowClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDroppableFlowProps<\n NodeData = any,\n NodeType extends string | undefined = string | undefined\n> extends Omit<ReactFlowProps, \"nodes\" | \"edges\" | \"nodeTypes\"> {\n /** Flow content: background, controls, and minimap. */\n children?: React.ReactNode;\n /** Flow nodes. */\n nodes?: Node<NodeData, NodeType>[];\n /** Flow edges. */\n edges?: Edge[];\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowClasses;\n /** Function called when the flow changes. Returns the updated nodes and edges. */\n onFlowChange?: (nodes: Node<NodeData, NodeType>[], edges: Edge[]) => void;\n}\n\nexport const getNode = (nodes: Node[], nodeId: string) => {\n return nodes.find((n) => n.id === nodeId);\n};\n\nconst validateEdges = (\n edges: Edge[],\n nodes: Node[],\n nodeTypes: HvFlowNodeTypes<string> | undefined\n) => {\n if (edges) {\n const validEdges: Edge[] = [];\n\n edges.forEach((edge) => {\n if (!edge.sourceHandle || !edge.targetHandle) return [];\n\n const sourceNode = getNode(nodes, edge.source);\n const targetNode = getNode(nodes, edge.target);\n\n if (!sourceNode || !targetNode) return [];\n\n const sourceType = sourceNode.type;\n const targetType = targetNode.type;\n\n if (!sourceType || !targetType) return [];\n\n const output =\n nodeTypes?.[sourceType]?.meta?.outputs?.[edge.sourceHandle];\n const input = nodeTypes?.[targetType]?.meta?.inputs?.[edge.targetHandle];\n\n const sourceProvides = output?.provides || [];\n const targetAccepts = input?.accepts || [];\n\n let isValid = false;\n sourceProvides.forEach((s) => {\n targetAccepts.forEach((t) => {\n if (s === t) {\n isValid = true;\n }\n });\n });\n\n if (isValid) {\n validEdges.push(edge);\n }\n });\n\n return validEdges;\n }\n return [];\n};\n\nexport const HvDroppableFlow = ({\n id,\n className,\n children,\n onFlowChange,\n classes: classesProp,\n nodes: initialNodes = [],\n edges: initialEdges = [],\n onConnect: onConnectProp,\n onNodesChange: onNodesChangeProp,\n onEdgesChange: onEdgesChangeProp,\n ...others\n}: HvDroppableFlowProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id, \"hvFlow\");\n\n const reactFlowInstance = useReactFlow();\n\n const { nodeTypes } = useFlowContext();\n\n const [nodes, setNodes] = useState(initialNodes);\n const [edges, setEdges] = useState(initialEdges);\n\n const { setNodeRef } = useDroppable({\n id: elementId,\n });\n\n const handleDragEnd = useCallback(\n (event: DragEndEvent) => {\n if (event.over && event.over.id === elementId) {\n const type = event.active.id.toString();\n\n // Converts the coordinates to the react flow coordinate system\n const position = reactFlowInstance.project({\n x: (event.active.data.current?.hvFlow?.x || 0) - event.over.rect.left,\n y: (event.active.data.current?.hvFlow?.y || 0) - event.over.rect.top,\n });\n\n const newNode: Node = {\n id: uid(),\n position,\n data: {},\n type,\n };\n\n setNodes((nds) => nds.concat(newNode));\n }\n },\n [elementId, reactFlowInstance, setNodes]\n );\n\n useDndMonitor({\n onDragEnd: handleDragEnd,\n });\n\n const handleFlowChange = useCallback(\n (\n nds: NonNullable<HvDroppableFlowProps[\"nodes\"]>,\n eds: NonNullable<HvDroppableFlowProps[\"edges\"]>\n ) => {\n // The new flow is returned if the user is not dragging nodes\n // This avoids triggering this handler too many times\n const isDragging = nds.find((node) => node.dragging);\n if (!isDragging) {\n onFlowChange?.(nds, eds);\n }\n },\n [onFlowChange]\n );\n\n const handleConnect = useCallback(\n (connection: Connection) => {\n const eds = addEdge(connection, edges);\n setEdges(eds);\n\n handleFlowChange(nodes, eds);\n onConnectProp?.(connection);\n },\n [edges, handleFlowChange, nodes, onConnectProp]\n );\n\n const handleNodesChange = useCallback(\n (changes: NodeChange[]) => {\n const nds = applyNodeChanges(changes, nodes);\n setNodes(nds);\n\n handleFlowChange(nds, edges);\n onNodesChangeProp?.(changes);\n },\n [edges, handleFlowChange, nodes, onNodesChangeProp]\n );\n\n const handleEdgesChange = useCallback(\n (changes: EdgeChange[]) => {\n const eds = applyEdgeChanges(changes, edges);\n setEdges(eds);\n\n handleFlowChange(nodes, eds);\n onEdgesChangeProp?.(changes);\n },\n [edges, handleFlowChange, nodes, onEdgesChangeProp]\n );\n\n const isValidConnection = (connection) => {\n const sourceNode = getNode(nodes, connection.source);\n const targetNode = getNode(nodes, connection.target);\n\n if (!sourceNode || !targetNode) {\n return false;\n }\n\n const sourceType = sourceNode.type;\n const targetType = targetNode.type;\n\n if (!sourceType || !targetType) {\n return false;\n }\n\n const inputs = nodeTypes?.[targetType]?.meta?.inputs || [];\n const outputs = nodeTypes?.[sourceType]?.meta?.outputs || [];\n\n const sourceProvides = outputs[connection.sourceHandle]?.provides || [];\n const targetAccepts = inputs[connection.targetHandle]?.accepts || [];\n\n let isValid = false;\n sourceProvides.forEach((s) => {\n targetAccepts.forEach((t) => {\n if (s === t) {\n isValid = true;\n }\n });\n });\n\n return isValid;\n };\n\n const validEdges = validateEdges(edges, nodes, nodeTypes);\n\n return (\n <div\n id={elementId}\n ref={setNodeRef}\n className={cx(classes.root, className)}\n >\n <ReactFlow\n nodes={nodes}\n edges={validEdges}\n nodeTypes={nodeTypes}\n onNodesChange={handleNodesChange}\n onEdgesChange={handleEdgesChange}\n onConnect={handleConnect}\n isValidConnection={isValidConnection}\n defaultEdgeOptions={{\n markerEnd: {\n type: MarkerType.ArrowClosed,\n height: 20,\n width: 20,\n },\n }}\n {...others}\n >\n {children}\n </ReactFlow>\n </div>\n );\n};\n"],"names":["getNode","nodes","nodeId","find","n","id","validateEdges","edges","nodeTypes","validEdges","forEach","edge","sourceHandle","targetHandle","sourceNode","source","targetNode","target","sourceType","type","targetType","output","meta","outputs","input","inputs","sourceProvides","provides","targetAccepts","accepts","isValid","s","t","push","HvDroppableFlow","className","children","onFlowChange","classes","classesProp","initialNodes","initialEdges","onConnect","onConnectProp","onNodesChange","onNodesChangeProp","onEdgesChange","onEdgesChangeProp","others","cx","useClasses","elementId","useUniqueId","reactFlowInstance","useReactFlow","useFlowContext","setNodes","useState","setEdges","setNodeRef","useDroppable","handleDragEnd","useCallback","event","over","active","toString","position","project","x","data","current","hvFlow","rect","left","y","top","newNode","uid","nds","concat","onDragEnd","handleFlowChange","eds","isDragging","node","dragging","handleConnect","connection","addEdge","handleNodesChange","changes","applyNodeChanges","handleEdgesChange","applyEdgeChanges","isValidConnection","root","markerEnd","MarkerType","ArrowClosed","height","width"],"mappings":";;;;;;;;;;AA+CaA,MAAAA,UAAUA,CAACC,OAAeC,WAAmB;AACxD,SAAOD,MAAME,KAAMC,CAAMA,MAAAA,EAAEC,OAAOH,MAAM;AAC1C;AAEA,MAAMI,gBAAgBA,CACpBC,OACAN,OACAO,cACG;AACH,MAAID,OAAO;AACT,UAAME,aAAqB,CAAA;AAE3BF,UAAMG,QAASC,CAAS,SAAA;;AACtB,UAAI,CAACA,KAAKC,gBAAgB,CAACD,KAAKE;AAAc,e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mBAAiCI,YAAW;AAElE,QAAIC,UAAU;AACdJ,mBAAehB,QAASqB,CAAM,MAAA;AAC5BH,oBAAclB,QAASsB,CAAM,MAAA;AAC3B,YAAID,MAAMC,GAAG;AACD,oBAAA;AAAA,QACZ;AAAA,MAAA,CACD;AAAA,IAAA,CACF;AAEMF,WAAAA;AAAAA,EAAAA;AAGT,QAAMrB,aAAaH,cAAcC,OAAON,OAAOO,SAAS;AAGtD,SAAA,oBAAC,OACC,EAAA,IAAI2C,WACJ,KAAKQ,YACL,WAAWV,GAAGX,QAAQ0D,MAAM7D,SAAS,GAErC,8BAAC,WACC,EAAA,OACA,OAAO1B,YACP,WACA,eAAeiF,mBACf,eAAeG,mBACf,WAAWN,eACX,mBACA,oBAAoB;AAAA,IAClBU,WAAW;AAAA,MACT9E,MAAM+E,WAAWC;AAAAA,MACjBC,QAAQ;AAAA,MACRC,OAAO;AAAA,IACT;AAAA,EAEErD,GAAAA,GAAAA,QAEHZ,SACH,CAAA,EACF,CAAA;AAEJ;"}
1
+ {"version":3,"file":"DroppableFlow.js","sources":["../../../../src/components/Flow/DroppableFlow.tsx"],"sourcesContent":["import { useCallback, useState } from \"react\";\n\nimport ReactFlow, {\n Connection,\n EdgeChange,\n NodeChange,\n ReactFlowProps,\n addEdge,\n applyEdgeChanges,\n applyNodeChanges,\n useReactFlow,\n MarkerType,\n Edge,\n Node,\n} from \"reactflow\";\n\nimport { Global } from \"@emotion/react\";\n\nimport { DragEndEvent, useDndMonitor, useDroppable } from \"@dnd-kit/core\";\n\nimport { uid } from \"uid\";\n\nimport { ExtractNames, useUniqueId } from \"@hitachivantara/uikit-react-core\";\n\nimport { HvFlowNodeTypes } from \"./types\";\nimport { staticClasses, useClasses } from \"./Flow.styles\";\nimport { useFlowContext } from \"./hooks\";\nimport { flowStyles } from \"./base\";\n\nexport { staticClasses as flowClasses };\n\nexport type HvFlowClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDroppableFlowProps<\n NodeType extends string | undefined = string | undefined,\n NodeData = any\n> extends Omit<ReactFlowProps, \"nodes\" | \"edges\" | \"nodeTypes\"> {\n /** Flow content: background, controls, and minimap. */\n children?: React.ReactNode;\n /** Flow nodes. */\n nodes?: Node<NodeData, NodeType>[];\n /** Flow edges. */\n edges?: Edge[];\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowClasses;\n /** Function called when the flow changes. Returns the updated nodes and edges. */\n onFlowChange?: (nodes: Node<NodeData, NodeType>[], edges: Edge[]) => void;\n}\n\nexport const getNode = (nodes: Node[], nodeId: string) => {\n return nodes.find((n) => n.id === nodeId);\n};\n\nconst validateEdge = (\n nodes: Node[],\n edge: Edge,\n nodeTypes: HvFlowNodeTypes<string> | undefined\n) => {\n if (!edge.sourceHandle || !edge.targetHandle) return false;\n\n const sourceNode = getNode(nodes, edge.source);\n const targetNode = getNode(nodes, edge.target);\n\n if (!sourceNode || !targetNode) return false;\n\n const sourceType = sourceNode.type;\n const targetType = targetNode.type;\n\n if (!sourceType || !targetType) return false;\n\n const inputs = nodeTypes?.[targetType]?.meta?.inputs || [];\n const outputs = nodeTypes?.[sourceType]?.meta?.outputs || [];\n\n const sourceProvides = outputs[edge.sourceHandle]?.provides || \"\";\n const targetAccepts = inputs[edge.targetHandle]?.accepts || [];\n\n const isValid = targetAccepts.includes(sourceProvides);\n return isValid;\n};\n\nconst validateEdges = (\n edges: Edge[],\n nodes: Node[],\n nodeTypes: HvFlowNodeTypes<string> | undefined\n) => {\n if (edges) {\n const validEdges: Edge[] = [];\n\n edges.forEach((edge) => {\n const isValidEdge = validateEdge(nodes, edge, nodeTypes);\n if (isValidEdge) {\n validEdges.push(edge);\n }\n });\n\n return validEdges;\n }\n return [];\n};\n\nexport const HvDroppableFlow = ({\n id,\n className,\n children,\n onFlowChange,\n classes: classesProp,\n nodes: initialNodes = [],\n edges: initialEdges = [],\n onConnect: onConnectProp,\n onNodesChange: onNodesChangeProp,\n onEdgesChange: onEdgesChangeProp,\n defaultEdgeOptions: defaultEdgeOptionsProp,\n ...others\n}: HvDroppableFlowProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id, \"hvFlow\");\n\n const reactFlowInstance = useReactFlow();\n\n const { nodeTypes } = useFlowContext();\n\n const [nodes, setNodes] = useState(initialNodes);\n const [edges, setEdges] = useState(initialEdges);\n\n const { setNodeRef } = useDroppable({\n id: elementId,\n });\n\n const handleDragEnd = useCallback(\n (event: DragEndEvent) => {\n if (event.over && event.over.id === elementId) {\n const type = event.active.data.current?.hvFlow?.type;\n\n // Only known node types can be dropped in the canvas\n if (type && nodeTypes?.[type]) {\n // Converts the coordinates to the react flow coordinate system\n const position = reactFlowInstance.project({\n x:\n (event.active.data.current?.hvFlow?.x || 0) -\n event.over.rect.left,\n y:\n (event.active.data.current?.hvFlow?.y || 0) - event.over.rect.top,\n });\n\n // Node data\n const data = event.active.data.current?.hvFlow?.data || {};\n\n const newNode: Node = {\n id: uid(),\n position,\n data,\n type,\n };\n\n setNodes((nds) => nds.concat(newNode));\n } else {\n // eslint-disable-next-line no-console\n console.error(\n `Could not add node to the flow because of unknown type ${type}. Use nodeTypes to define all the node types.`\n );\n }\n }\n },\n [elementId, nodeTypes, reactFlowInstance]\n );\n\n useDndMonitor({\n onDragEnd: handleDragEnd,\n });\n\n const handleFlowChange = useCallback(\n (\n nds: NonNullable<HvDroppableFlowProps[\"nodes\"]>,\n eds: NonNullable<HvDroppableFlowProps[\"edges\"]>\n ) => {\n // The new flow is returned if the user is not dragging nodes\n // This avoids triggering this handler too many times\n const isDragging = nds.find((node) => node.dragging);\n if (!isDragging) {\n onFlowChange?.(nds, eds);\n }\n },\n [onFlowChange]\n );\n\n const handleConnect = useCallback(\n (connection: Connection) => {\n const eds = addEdge(connection, edges);\n setEdges(eds);\n\n handleFlowChange(nodes, eds);\n onConnectProp?.(connection);\n },\n [edges, handleFlowChange, nodes, onConnectProp]\n );\n\n const handleNodesChange = useCallback(\n (changes: NodeChange[]) => {\n const nds = applyNodeChanges(changes, nodes);\n setNodes(nds);\n\n handleFlowChange(nds, edges);\n onNodesChangeProp?.(changes);\n },\n [edges, handleFlowChange, nodes, onNodesChangeProp]\n );\n\n const handleEdgesChange = useCallback(\n (changes: EdgeChange[]) => {\n const eds = applyEdgeChanges(changes, edges);\n setEdges(eds);\n\n handleFlowChange(nodes, eds);\n onEdgesChangeProp?.(changes);\n },\n [edges, handleFlowChange, nodes, onEdgesChangeProp]\n );\n\n const isValidConnection = (connection) => {\n const isValid = validateEdge(nodes, connection, nodeTypes);\n return isValid;\n };\n\n const validEdges = validateEdges(edges, nodes, nodeTypes);\n\n const defaultEdgeOptions = {\n markerEnd: {\n type: MarkerType.ArrowClosed,\n height: 20,\n width: 20,\n },\n ...defaultEdgeOptionsProp,\n };\n\n return (\n <>\n <Global styles={flowStyles} />\n <div\n id={elementId}\n ref={setNodeRef}\n className={cx(classes.root, className)}\n >\n <ReactFlow\n nodes={nodes}\n edges={validEdges}\n nodeTypes={nodeTypes}\n onNodesChange={handleNodesChange}\n onEdgesChange={handleEdgesChange}\n onConnect={handleConnect}\n isValidConnection={isValidConnection}\n defaultEdgeOptions={defaultEdgeOptions}\n {...others}\n >\n {children}\n </ReactFlow>\n </div>\n </>\n );\n};\n"],"names":["getNode","nodes","nodeId","find","n","id","validateEdge","edge","nodeTypes","sourceHandle","targetHandle","sourceNode","source","targetNode","target","sourceType","type","targetType","inputs","meta","outputs","sourceProvides","provides","targetAccepts","accepts","isValid","includes","validateEdges","edges","validEdges","forEach","isValidEdge","push","HvDroppableFlow","className","children","onFlowChange","classes","classesProp","initialNodes","initialEdges","onConnect","onConnectProp","onNodesChange","onNodesChangeProp","onEdgesChange","onEdgesChangeProp","defaultEdgeOptions","defaultEdgeOptionsProp","others","cx","useClasses","elementId","useUniqueId","reactFlowInstance","useReactFlow","useFlowContext","setNodes","useState","setEdges","setNodeRef","useDroppable","handleDragEnd","useCallback","event","over","active","data","current","hvFlow","position","project","x","rect","left","y","top","newNode","uid","nds","concat","error","onDragEnd","handleFlowChange","eds","isDragging","node","dragging","handleConnect","connection","addEdge","handleNodesChange","changes","applyNodeChanges","handleEdgesChange","applyEdgeChanges","isValidConnection","markerEnd","MarkerType","ArrowClosed","height","width","flowStyles","root"],"mappings":";;;;;;;;;;;AAiDaA,MAAAA,UAAUA,CAACC,OAAeC,WAAmB;AACxD,SAAOD,MAAME,KAAMC,CAAMA,MAAAA,EAAEC,OAAOH,MAAM;AAC1C;AAEA,MAAMI,eAAeA,CACnBL,OACAM,MACAC,cACG;;AACH,MAAI,CAACD,KAAKE,gBAAgB,CAACF,KAAKG;AAAqB,WAAA;AAErD,QAAMC,aAAaX,QAAQC,OAAOM,KAAKK,MAAM;AAC7C,QAAMC,aAAab,QAAQC,OAAOM,KAAKO,MAAM;AAEzC,MAAA,CAACH,cAAc,CAACE;AAAmB,WAAA;AAEvC,QAAME,aAAaJ,WAAWK;AAC9B,QAAMC,aAAaJ,WAAWG;AAE1B,MAAA,CAACD,cAAc,CAACE;AAAmB,WAAA;AAEvC,QAAMC,WAASV,kDAAYS,gBAAZT,mBAAyBW,SAAzBX,mBAA+BU,WAAU;AACxD,QAAME,YAAUZ,kDAAYO,gBAAZP,mBAAyBW,SAAzBX,mBAA+BY,YAAW;AAE1D,QAAMC,mBAAiBD,aAAQb,KAAKE,YAAY,MAAzBW,mBAA4BE,aAAY;AAC/D,QAAMC,kBAAgBL,YAAOX,KAAKG,YAAY,MAAxBQ,mBAA2BM,YAAW;AAEtDC,QAAAA,UAAUF,cAAcG,SAASL,cAAc;AAC9CI,SAAAA;AACT;AAEA,MAAME,gBAAgBA,CACpBC,OACA3B,OACAO,cACG;AACH,MAAIoB,OAAO;AACT,UAAMC,aAAqB,CAAA;AAE3BD,UAAME,QAASvB,CAAS,SAAA;AACtB,YAAMwB,cAAczB,aAAaL,OAAOM,MAAMC,SAAS;AACvD,UAAIuB,aAAa;AACfF,mBAAWG,KAAKzB,IAAI;AAAA,MACtB;AAAA,IAAA,CACD;AAE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yB,GAAG;AAEZD,qBAAiBlF,OAAOmF,GAAG;AAC3BtC,2DAAoB8C;AAAAA,KAEtB,CAAChE,OAAOuD,kBAAkBlF,OAAO6C,iBAAiB,CACpD;AAEA,QAAMkD,oBAAqBP,CAAe,eAAA;AACxC,UAAMhE,UAAUnB,aAAaL,OAAOwF,YAAYjF,SAAS;AAClDiB,WAAAA;AAAAA,EAAAA;AAGT,QAAMI,aAAaF,cAAcC,OAAO3B,OAAOO,SAAS;AAExD,QAAMuC,qBAAqB;AAAA,IACzBkD,WAAW;AAAA,MACTjF,MAAMkF,WAAWC;AAAAA,MACjBC,QAAQ;AAAA,MACRC,OAAO;AAAA,IACT;AAAA,IACA,GAAGrD;AAAAA,EAAAA;AAGL,SAEI,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAC,oBAAA,QAAA,EAAO,QAAQsD,WAAW,CAAA;AAAA,IAC1B,oBAAA,OAAA,EACC,IAAIlD,WACJ,KAAKQ,YACL,WAAWV,GAAGb,QAAQkE,MAAMrE,SAAS,GAErC,UAAC,oBAAA,WAAA,EACC,OACA,OAAOL,YACP,WACA,eAAe8D,mBACf,eAAeG,mBACf,WAAWN,eACX,mBACA,oBACIvC,GAAAA,QAEHd,SACH,CAAA,GACF;AAAA,EACF,EAAA,CAAA;AAEJ;"}
@@ -0,0 +1,19 @@
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import { useStore } from "reactflow";
3
+ import { HvEmptyState } from "@hitachivantara/uikit-react-core";
4
+ import { useClasses } from "./Empty.styles.js";
5
+ const HvFlowEmpty = ({
6
+ className,
7
+ ...others
8
+ }) => {
9
+ const {
10
+ classes,
11
+ cx
12
+ } = useClasses();
13
+ const nodes = useStore((state) => state.getNodes());
14
+ return !nodes || (nodes.length === 0 ? /* @__PURE__ */ jsx(HvEmptyState, { className: cx(classes.root, className), ...others }) : null);
15
+ };
16
+ export {
17
+ HvFlowEmpty
18
+ };
19
+ //# sourceMappingURL=Empty.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Empty.js","sources":["../../../../../src/components/Flow/Empty/Empty.tsx"],"sourcesContent":["import { useStore } from \"reactflow\";\nimport {\n HvEmptyState,\n HvEmptyStateProps,\n} from \"@hitachivantara/uikit-react-core\";\nimport { useClasses } from \"./Empty.styles\";\n\nexport interface HvFlowEmptyProps extends HvEmptyStateProps {}\n\nexport const HvFlowEmpty = ({ className, ...others }: HvFlowEmptyProps) => {\n const { classes, cx } = useClasses();\n const nodes = useStore((state) => state.getNodes());\n return (\n !nodes ||\n (nodes.length === 0 ? (\n <HvEmptyState className={cx(classes.root, className)} {...others} />\n ) : null)\n );\n};\n"],"names":["HvFlowEmpty","className","others","classes","cx","useClasses","nodes","useStore","state","getNodes","length","root"],"mappings":";;;;AASO,MAAMA,cAAcA,CAAC;AAAA,EAAEC;AAAAA,EAAW,GAAGC;AAAyB,MAAM;AACnE,QAAA;AAAA,IAAEC;AAAAA,IAASC;AAAAA,MAAOC,WAAW;AACnC,QAAMC,QAAQC,SAAUC,CAAUA,UAAAA,MAAMC,UAAU;AAClD,SACE,CAACH,UACAA,MAAMI,WAAW,IACf,oBAAA,cAAA,EAAa,WAAWN,GAAGD,QAAQQ,MAAMV,SAAS,GAAG,GAAIC,OAAU,CAAA,IAClE;AAER;"}
@@ -0,0 +1,20 @@
1
+ import { createClasses, theme } from "@hitachivantara/uikit-react-core";
2
+ const {
3
+ staticClasses,
4
+ useClasses
5
+ } = createClasses("HvFlowEmpty", {
6
+ root: {
7
+ width: "100%",
8
+ height: "100%",
9
+ alignItems: "center",
10
+ justifyContent: "center",
11
+ backgroundColor: theme.colors.backgroundColor,
12
+ position: "absolute",
13
+ zIndex: theme.zIndices.popover
14
+ }
15
+ });
16
+ export {
17
+ staticClasses,
18
+ useClasses
19
+ };
20
+ //# sourceMappingURL=Empty.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Empty.styles.js","sources":["../../../../../src/components/Flow/Empty/Empty.styles.tsx"],"sourcesContent":["import { createClasses, theme } from \"@hitachivantara/uikit-react-core\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFlowEmpty\", {\n root: {\n width: \"100%\",\n height: \"100%\",\n alignItems: \"center\",\n justifyContent: \"center\",\n backgroundColor: theme.colors.backgroundColor,\n position: \"absolute\",\n zIndex: theme.zIndices.popover,\n },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","width","height","alignItems","justifyContent","backgroundColor","theme","colors","position","zIndex","zIndices","popover"],"mappings":";AAEa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,cAAc,eAAe;AAAA,EACxEC,MAAM;AAAA,IACJC,OAAO;AAAA,IACPC,QAAQ;AAAA,IACRC,YAAY;AAAA,IACZC,gBAAgB;AAAA,IAChBC,iBAAiBC,MAAMC,OAAOF;AAAAA,IAC9BG,UAAU;AAAA,IACVC,QAAQH,MAAMI,SAASC;AAAAA,EACzB;AACF,CAAC;"}
@@ -1,11 +1,9 @@
1
1
  import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
- import { useState } from "react";
3
- import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, DragOverlay } from "@dnd-kit/core";
2
+ import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext } from "@dnd-kit/core";
4
3
  import { restrictToWindowEdges } from "@dnd-kit/modifiers";
5
4
  import { ReactFlowProvider } from "reactflow";
6
5
  import { HvDroppableFlow } from "./DroppableFlow.js";
7
6
  import { HvFlowProvider } from "./FlowContext/FlowContext.js";
8
- import { HvFlowSidebarGroupItem } from "./Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.js";
9
7
  const HvFlow = ({
10
8
  nodeTypes,
11
9
  nodeGroups,
@@ -14,21 +12,10 @@ const HvFlow = ({
14
12
  dndContextProps,
15
13
  ...others
16
14
  }) => {
17
- const [draggingLabel, setDraggingLabel] = useState(void 0);
18
15
  const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor));
19
- const handleDragStart = (event) => {
20
- var _a, _b;
21
- if ((_a = event.active.data.current) == null ? void 0 : _a.hvFlow) {
22
- setDraggingLabel((_b = event.active.data.current.hvFlow) == null ? void 0 : _b.label);
23
- }
24
- };
25
- const handleDragEnd = () => {
26
- setDraggingLabel(void 0);
27
- };
28
- return /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(HvFlowProvider, { nodeGroups, nodeTypes, defaultActions, children: /* @__PURE__ */ jsxs(DndContext, { onDragStart: handleDragStart, onDragEnd: handleDragEnd, sensors, modifiers: [restrictToWindowEdges], ...dndContextProps, children: [
16
+ return /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(HvFlowProvider, { nodeGroups, nodeTypes, defaultActions, children: /* @__PURE__ */ jsxs(DndContext, { sensors, modifiers: [restrictToWindowEdges], ...dndContextProps, children: [
29
17
  /* @__PURE__ */ jsx(HvDroppableFlow, { ...others }),
30
- sidebar,
31
- /* @__PURE__ */ jsx(DragOverlay, { modifiers: [restrictToWindowEdges], children: draggingLabel ? /* @__PURE__ */ jsx(HvFlowSidebarGroupItem, { label: draggingLabel, isDragging: true }) : null })
18
+ sidebar
32
19
  ] }) }) });
33
20
  };
34
21
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"Flow.js","sources":["../../../../src/components/Flow/Flow.tsx"],"sourcesContent":["import { useState } from \"react\";\n\nimport {\n DndContext,\n DndContextProps,\n DragOverlay,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport { restrictToWindowEdges } from \"@dnd-kit/modifiers\";\n\nimport { ReactFlowProvider } from \"reactflow\";\n\nimport {\n HvFlowDefaultActions,\n HvFlowNodeGroups,\n HvFlowNodeTypes,\n} from \"./types\";\nimport { HvFlowProvider } from \"./FlowContext\";\nimport { HvDroppableFlow, HvDroppableFlowProps } from \"./DroppableFlow\";\nimport { HvFlowSidebarGroupItem } from \"./Sidebar/SidebarGroup/SidebarGroupItem\";\n\nexport interface HvFlowProps<\n NodeData = any,\n NodeType extends string | undefined = string | undefined,\n NodeGroups extends keyof any = string\n> extends HvDroppableFlowProps<NodeData, NodeType> {\n /** Flow nodes groups. */\n nodeGroups?: HvFlowNodeGroups<NodeGroups>;\n /** Flow nodes types. */\n nodeTypes?: HvFlowNodeTypes<NodeGroups>;\n /** Flow sidebar. */\n sidebar?: React.ReactNode;\n /** Flow default actions. */\n defaultActions?: HvFlowDefaultActions[];\n /**\n * Dnd Kit context props. This should be used for accessibility purposes.\n *\n * More information can be found on the [Dnd Kit documentation](https://docs.dndkit.com/guides/accessibility)\n */\n dndContextProps?: Pick<DndContextProps, \"accessibility\">;\n}\n\n/**\n * Flow component to build interactive node-based UIs.\n *\n * This implementation leverages [React Flow](https://reactflow.dev).\n * The drag and drop functionality leverages [Dnd Kit](https://docs.dndkit.com)\n *\n * DISCLAIMER: This component is a work in progress and there might be breaking changes.\n */\nexport const HvFlow = ({\n nodeTypes,\n nodeGroups,\n sidebar,\n defaultActions,\n dndContextProps,\n ...others\n}: HvFlowProps) => {\n const [draggingLabel, setDraggingLabel] = useState(undefined);\n\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor)\n );\n\n const handleDragStart: DndContextProps[\"onDragStart\"] = (event) => {\n if (event.active.data.current?.hvFlow) {\n setDraggingLabel(event.active.data.current.hvFlow?.label);\n }\n };\n\n const handleDragEnd: DndContextProps[\"onDragEnd\"] = () => {\n setDraggingLabel(undefined);\n };\n\n // We're wrapping the main Flow component with the ReactFlowProvider to access the react flow instance.\n // HvFlowContext is our custom internal context.\n return (\n <ReactFlowProvider>\n <HvFlowProvider\n nodeGroups={nodeGroups}\n nodeTypes={nodeTypes}\n defaultActions={defaultActions}\n >\n <DndContext\n onDragStart={handleDragStart}\n onDragEnd={handleDragEnd}\n sensors={sensors}\n modifiers={[restrictToWindowEdges]}\n {...dndContextProps}\n >\n <HvDroppableFlow {...others} />\n {sidebar}\n <DragOverlay modifiers={[restrictToWindowEdges]}>\n {draggingLabel ? (\n <HvFlowSidebarGroupItem label={draggingLabel} isDragging />\n ) : null}\n </DragOverlay>\n </DndContext>\n </HvFlowProvider>\n </ReactFlowProvider>\n );\n};\n"],"names":["HvFlow","nodeTypes","nodeGroups","sidebar","defaultActions","dndContextProps","others","draggingLabel","setDraggingLabel","useState","undefined","sensors","useSensors","useSensor","PointerSensor","KeyboardSensor","handleDragStart","event","active","data","current","hvFlow","label","handleDragEnd","restrictToWindowEdges"],"mappings":";;;;;;;;AAqDO,MAAMA,SAASA,CAAC;AAAA,EACrBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AACQ,MAAM;AACjB,QAAM,CAACC,eAAeC,gBAAgB,IAAIC,SAASC,MAAS;AAE5D,QAAMC,UAAUC,WACdC,UAAUC,aAAa,GACvBD,UAAUE,cAAc,CAC1B;AAEA,QAAMC,kBAAmDC,CAAU,UAAA;;AACjE,SAAIA,WAAMC,OAAOC,KAAKC,YAAlBH,mBAA2BI,QAAQ;AACrCb,wBAAiBS,WAAMC,OAAOC,KAAKC,QAAQC,WAA1BJ,mBAAkCK,KAAK;AAAA,IAC1D;AAAA,EAAA;AAGF,QAAMC,gBAA8CA,MAAM;AACxDf,qBAAiBE,MAAS;AAAA,EAAA;AAK5B,6BACG,mBACC,EAAA,UAAA,oBAAC,kBACC,YACA,WACA,gBAEA,UAAC,qBAAA,YAAA,EACC,aAAaM,iBACb,WAAWO,eACX,SACA,WAAW,CAACC,qBAAqB,GACjC,GAAInB,iBAEJ,UAAA;AAAA,IAAC,oBAAA,iBAAA,EAAgB,GAAIC,QAAO;AAAA,IAC3BH;AAAAA,IACA,oBAAA,aAAA,EAAY,WAAW,CAACqB,qBAAqB,GAC3CjB,UAAAA,gBACE,oBAAA,wBAAA,EAAuB,OAAOA,eAAe,YAAU,KAAA,CAAA,IACtD,MACN;AAAA,EAAA,GACF,GACF,EACF,CAAA;AAEJ;"}
1
+ {"version":3,"file":"Flow.js","sources":["../../../../src/components/Flow/Flow.tsx"],"sourcesContent":["import {\n DndContext,\n DndContextProps,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport { restrictToWindowEdges } from \"@dnd-kit/modifiers\";\n\nimport { ReactFlowProvider } from \"reactflow\";\n\nimport {\n HvFlowDefaultActions,\n HvFlowNodeGroups,\n HvFlowNodeTypes,\n} from \"./types\";\nimport { HvFlowProvider } from \"./FlowContext\";\nimport { HvDroppableFlow, HvDroppableFlowProps } from \"./DroppableFlow\";\n\nexport interface HvFlowProps<\n NodeGroups extends keyof any = string,\n NodeType extends string | undefined = string | undefined,\n NodeData = any\n> extends HvDroppableFlowProps<NodeType, NodeData> {\n /** Flow nodes groups. */\n nodeGroups?: HvFlowNodeGroups<NodeGroups>;\n /** Flow nodes types. */\n nodeTypes?: HvFlowNodeTypes<NodeGroups, NodeData>;\n /** Flow sidebar. */\n sidebar?: React.ReactNode;\n /** Flow default actions. */\n defaultActions?: HvFlowDefaultActions[];\n /**\n * Dnd Kit context props. This should be used for accessibility purposes.\n *\n * More information can be found on the [Dnd Kit documentation](https://docs.dndkit.com/guides/accessibility)\n */\n dndContextProps?: Pick<DndContextProps, \"accessibility\">;\n}\n\n/**\n * Flow component to build interactive node-based UIs.\n *\n * This implementation leverages [React Flow](https://reactflow.dev).\n * The drag and drop functionality leverages [Dnd Kit](https://docs.dndkit.com)\n *\n * DISCLAIMER: This component is a work in progress and there might be breaking changes.\n */\nexport const HvFlow = ({\n nodeTypes,\n nodeGroups,\n sidebar,\n defaultActions,\n dndContextProps,\n ...others\n}: HvFlowProps) => {\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor)\n );\n\n // We're wrapping the main Flow component with the ReactFlowProvider to access the react flow instance.\n // HvFlowContext is our custom internal context.\n return (\n <ReactFlowProvider>\n <HvFlowProvider\n nodeGroups={nodeGroups}\n nodeTypes={nodeTypes}\n defaultActions={defaultActions}\n >\n <DndContext\n sensors={sensors}\n modifiers={[restrictToWindowEdges]}\n {...dndContextProps}\n >\n <HvDroppableFlow {...others} />\n {sidebar}\n </DndContext>\n </HvFlowProvider>\n </ReactFlowProvider>\n );\n};\n"],"names":["HvFlow","nodeTypes","nodeGroups","sidebar","defaultActions","dndContextProps","others","sensors","useSensors","useSensor","PointerSensor","KeyboardSensor","restrictToWindowEdges"],"mappings":";;;;;;AAiDO,MAAMA,SAASA,CAAC;AAAA,EACrBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AACQ,MAAM;AACjB,QAAMC,UAAUC,WACdC,UAAUC,aAAa,GACvBD,UAAUE,cAAc,CAC1B;AAIA,SACG,oBAAA,mBAAA,EACC,UAAC,oBAAA,gBAAA,EACC,YACA,WACA,gBAEA,UAAC,qBAAA,YAAA,EACC,SACA,WAAW,CAACC,qBAAqB,GACjC,GAAIP,iBAEJ,UAAA;AAAA,IAAC,oBAAA,iBAAA,EAAgB,GAAIC,QAAO;AAAA,IAC3BH;AAAAA,EAAAA,GACH,GACF,EACF,CAAA;AAEJ;"}
@@ -1,10 +1,10 @@
1
1
  import { createClasses, theme } from "@hitachivantara/uikit-react-core";
2
2
  import { staticClasses as staticClasses$1 } from "./Node/Node.styles.js";
3
3
  import "@emotion/react/jsx-runtime";
4
- import "@hitachivantara/uikit-react-icons";
5
- import "@hitachivantara/uikit-styles";
6
4
  import "react";
7
5
  import "reactflow";
6
+ import "@hitachivantara/uikit-react-icons";
7
+ import "@hitachivantara/uikit-styles";
8
8
  const {
9
9
  staticClasses,
10
10
  useClasses
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "@emotion/react/jsx-runtime";
2
- import { createContext, useState, useMemo, useContext } from "react";
2
+ import { createContext, useState, useMemo } from "react";
3
3
  const HvFlowContext = createContext({});
4
4
  const HvFlowProvider = ({
5
5
  nodeGroups,
@@ -17,10 +17,8 @@ const HvFlowProvider = ({
17
17
  }), [nodeTypes, nodeGroups, defaultActions, expandedNodeGroups]);
18
18
  return /* @__PURE__ */ jsx(HvFlowContext.Provider, { value, children });
19
19
  };
20
- const useFlowContext = () => useContext(HvFlowContext);
21
20
  export {
22
21
  HvFlowContext,
23
- HvFlowProvider,
24
- useFlowContext
22
+ HvFlowProvider
25
23
  };
26
24
  //# sourceMappingURL=FlowContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FlowContext.js","sources":["../../../../../src/components/Flow/FlowContext/FlowContext.tsx"],"sourcesContent":["import {\n Dispatch,\n SetStateAction,\n createContext,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nimport {\n HvFlowDefaultActions,\n HvFlowNodeGroups,\n HvFlowNodeTypes,\n} from \"../types\";\n\nexport interface HvFlowContextValue<NodeGroups extends keyof any = string> {\n /** Flow nodes types. */\n nodeTypes?: HvFlowNodeTypes<NodeGroups>;\n /** Flow nodes groups. */\n nodeGroups?: HvFlowNodeGroups<NodeGroups>;\n /** Flow nodes groups expanded on sidebar. */\n expandedNodeGroups?: string[];\n /** Flow default actions. */\n defaultActions?: HvFlowDefaultActions[];\n /** Function to set `expandedNodeGroups`. */\n setExpandedNodeGroups?: Dispatch<SetStateAction<string[]>>;\n}\n\nexport const HvFlowContext = createContext<HvFlowContextValue>({});\n\nexport interface HvFlowProviderProps<NodeGroups extends keyof any = string> {\n /** Flow nodes types. */\n nodeTypes?: HvFlowContextValue<NodeGroups>[\"nodeTypes\"];\n /** Flow nodes groups. */\n nodeGroups?: HvFlowContextValue<NodeGroups>[\"nodeGroups\"];\n /** Flow default actions. */\n defaultActions?: HvFlowDefaultActions[];\n /** Children. */\n children?: React.ReactNode;\n}\n\nexport const HvFlowProvider = ({\n nodeGroups,\n nodeTypes,\n defaultActions,\n children,\n}: HvFlowProviderProps) => {\n const [expandedNodeGroups, setExpandedNodeGroups] = useState<string[]>([]);\n\n const value = useMemo(\n () => ({\n nodeTypes,\n nodeGroups,\n defaultActions,\n expandedNodeGroups,\n setExpandedNodeGroups,\n }),\n [nodeTypes, nodeGroups, defaultActions, expandedNodeGroups]\n );\n\n return (\n <HvFlowContext.Provider value={value}>{children}</HvFlowContext.Provider>\n );\n};\n\nexport const useFlowContext = () => useContext(HvFlowContext);\n"],"names":["HvFlowContext","createContext","HvFlowProvider","nodeGroups","nodeTypes","defaultActions","children","expandedNodeGroups","setExpandedNodeGroups","useState","value","useMemo","useFlowContext","useContext"],"mappings":";;AA4BaA,MAAAA,gBAAgBC,cAAkC,EAAE;AAa1D,MAAMC,iBAAiBA,CAAC;AAAA,EAC7BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACmB,MAAM;AACzB,QAAM,CAACC,oBAAoBC,qBAAqB,IAAIC,SAAmB,CAAE,CAAA;AAEnEC,QAAAA,QAAQC,QACZ,OAAO;AAAA,IACLP;AAAAA,IACAD;AAAAA,IACAE;AAAAA,IACAE;AAAAA,IACAC;AAAAA,EAAAA,IAEF,CAACJ,WAAWD,YAAYE,gBAAgBE,kBAAkB,CAC5D;AAEA,SACG,oBAAA,cAAc,UAAd,EAAuB,OAAeD,SAAS,CAAA;AAEpD;AAEaM,MAAAA,iBAAiBA,MAAMC,WAAWb,aAAa;"}
1
+ {"version":3,"file":"FlowContext.js","sources":["../../../../../src/components/Flow/FlowContext/FlowContext.tsx"],"sourcesContent":["import {\n Dispatch,\n SetStateAction,\n createContext,\n useMemo,\n useState,\n} from \"react\";\n\nimport {\n HvFlowDefaultActions,\n HvFlowNodeGroups,\n HvFlowNodeTypes,\n} from \"../types\";\n\nexport interface HvFlowContextValue<NodeGroups extends keyof any = string> {\n /** Flow nodes types. */\n nodeTypes?: HvFlowNodeTypes<NodeGroups>;\n /** Flow nodes groups. */\n nodeGroups?: HvFlowNodeGroups<NodeGroups>;\n /** Flow nodes groups expanded on sidebar. */\n expandedNodeGroups?: string[];\n /** Flow default actions. */\n defaultActions?: HvFlowDefaultActions[];\n /** Function to set `expandedNodeGroups`. */\n setExpandedNodeGroups?: Dispatch<SetStateAction<string[]>>;\n}\n\nexport const HvFlowContext = createContext<HvFlowContextValue>({});\n\nexport interface HvFlowProviderProps<NodeGroups extends keyof any = string> {\n /** Flow nodes types. */\n nodeTypes?: HvFlowContextValue<NodeGroups>[\"nodeTypes\"];\n /** Flow nodes groups. */\n nodeGroups?: HvFlowContextValue<NodeGroups>[\"nodeGroups\"];\n /** Flow default actions. */\n defaultActions?: HvFlowDefaultActions[];\n /** Children. */\n children?: React.ReactNode;\n}\n\nexport const HvFlowProvider = ({\n nodeGroups,\n nodeTypes,\n defaultActions,\n children,\n}: HvFlowProviderProps) => {\n const [expandedNodeGroups, setExpandedNodeGroups] = useState<string[]>([]);\n\n const value = useMemo(\n () => ({\n nodeTypes,\n nodeGroups,\n defaultActions,\n expandedNodeGroups,\n setExpandedNodeGroups,\n }),\n [nodeTypes, nodeGroups, defaultActions, expandedNodeGroups]\n );\n\n return (\n <HvFlowContext.Provider value={value}>{children}</HvFlowContext.Provider>\n );\n};\n"],"names":["HvFlowContext","createContext","HvFlowProvider","nodeGroups","nodeTypes","defaultActions","children","expandedNodeGroups","setExpandedNodeGroups","useState","value","useMemo"],"mappings":";;AA2BaA,MAAAA,gBAAgBC,cAAkC,EAAE;AAa1D,MAAMC,iBAAiBA,CAAC;AAAA,EAC7BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACmB,MAAM;AACzB,QAAM,CAACC,oBAAoBC,qBAAqB,IAAIC,SAAmB,CAAE,CAAA;AAEnEC,QAAAA,QAAQC,QACZ,OAAO;AAAA,IACLP;AAAAA,IACAD;AAAAA,IACAE;AAAAA,IACAE;AAAAA,IACAC;AAAAA,EAAAA,IAEF,CAACJ,WAAWD,YAAYE,gBAAgBE,kBAAkB,CAC5D;AAEA,SACG,oBAAA,cAAc,UAAd,EAAuB,OAAeD,SAAS,CAAA;AAEpD;"}
@@ -1,13 +1,13 @@
1
1
  import { jsxs, jsx, Fragment } from "@emotion/react/jsx-runtime";
2
+ import { useState, useEffect, useCallback, isValidElement } from "react";
3
+ import { useReactFlow, useStore, NodeToolbar, Handle, Position } from "reactflow";
2
4
  import { HvButton, HvTypography, HvTooltip, HvDropDownMenu } from "@hitachivantara/uikit-react-core";
3
5
  import { Info, Up, Down } from "@hitachivantara/uikit-react-icons";
4
6
  import { getColor, theme } from "@hitachivantara/uikit-styles";
5
- import { useState, useEffect, useCallback, isValidElement } from "react";
6
- import { useReactFlow, useStore, NodeToolbar, Handle, Position } from "reactflow";
7
- import { useFlowContext } from "../FlowContext/FlowContext.js";
8
7
  import { useClasses } from "./Node.styles.js";
9
8
  import { staticClasses } from "./Node.styles.js";
10
9
  import ParamRenderer from "./Parameters/ParamRenderer.js";
10
+ import { useFlowContext } from "../hooks/useFlowContext.js";
11
11
  const isInputConnected = (id, type, idx, edges) => {
12
12
  if (type === "target") {
13
13
  return edges.some((e) => e.target === id && e.targetHandle === idx.toString());
@@ -99,7 +99,7 @@ const HvFlowNode = ({
99
99
  return /* @__PURE__ */ jsxs("div", { className: cx(css({
100
100
  border: `1px solid ${color}`
101
101
  }), classes.root, className), onMouseEnter: () => setShowActions(true), onMouseLeave: () => setShowActions(false), children: [
102
- /* @__PURE__ */ jsx(NodeToolbar, { isVisible: showActions, offset: 0, children: defaultActions == null ? void 0 : defaultActions.map((action) => /* @__PURE__ */ jsx(HvButton, { icon: true, onClick: () => handleDefaultAction(action.id), children: renderedIcon(action.icon) })) }),
102
+ /* @__PURE__ */ jsx(NodeToolbar, { isVisible: showActions, offset: 0, children: defaultActions == null ? void 0 : defaultActions.map((action) => /* @__PURE__ */ jsx(HvButton, { icon: true, onClick: () => handleDefaultAction(action.id), children: renderedIcon(action.icon) }, action.id)) }),
103
103
  /* @__PURE__ */ jsxs("div", { className: cx(css({
104
104
  backgroundColor: color
105
105
  }), classes.headerContainer), children: [
@@ -119,7 +119,7 @@ const HvFlowNode = ({
119
119
  /* @__PURE__ */ jsx("div", { className: classes.actions, children: (actions == null ? void 0 : actions.length) && (actions == null ? void 0 : actions.length) > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
120
120
  actsVisible == null ? void 0 : actsVisible.map((action) => /* @__PURE__ */ jsx(HvTooltip, { title: /* @__PURE__ */ jsx(HvTypography, { children: action.label }), children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(HvButton, { icon: true, onClick: (event) => {
121
121
  actionCallback == null ? void 0 : actionCallback(event, node.id, action);
122
- }, "aria-label": action.label, children: renderedIcon(action.icon) }) }) })),
122
+ }, "aria-label": action.label, children: renderedIcon(action.icon) }) }) }, action.id)),
123
123
  actsDropdown && actsDropdown.length > 0 && /* @__PURE__ */ jsx(HvDropDownMenu, { keepOpened: false, dataList: actsDropdown == null ? void 0 : actsDropdown.map((action) => ({
124
124
  id: action.id,
125
125
  label: action.label
@@ -1 +1 @@
1
- {"version":3,"file":"Node.js","sources":["../../../../../src/components/Flow/Node/Node.tsx"],"sourcesContent":["import {\n ExtractNames,\n HvActionGeneric,\n HvActionsGenericProps,\n HvBaseProps,\n HvButton,\n HvDropDownMenu,\n HvTooltip,\n HvTypography,\n} from \"@hitachivantara/uikit-react-core\";\nimport { Down, Info, Up } from \"@hitachivantara/uikit-react-icons\";\nimport { getColor, theme } from \"@hitachivantara/uikit-styles\";\nimport { isValidElement, useCallback, useEffect, useState } from \"react\";\nimport {\n Handle,\n NodeProps,\n NodeToolbar,\n Position,\n useReactFlow,\n useStore,\n} from \"reactflow\";\nimport { useFlowContext } from \"../FlowContext/FlowContext\";\n\nimport {\n HvFlowDefaultAction,\n HvFlowNodeInput,\n HvFlowNodeOutput,\n HvFlowNodeParam,\n} from \"../types\";\nimport { staticClasses, useClasses } from \"./Node.styles\";\nimport ParamRenderer from \"./Parameters/ParamRenderer\";\n\nexport { staticClasses as flowNodeClasses };\n\nexport type HvFlowNodeClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFlowNodeProps extends Omit<HvBaseProps, \"id\">, NodeProps {\n /** Node description */\n description: string;\n /** Node expanded */\n expanded?: boolean;\n /** Node inputs */\n inputs?: HvFlowNodeInput[];\n /** Node outputs */\n outputs?: HvFlowNodeOutput[];\n /** Node parameters */\n params?: HvFlowNodeParam[];\n /** Node actions */\n actions?: HvActionGeneric[]; // HvFlowNodeActions[];\n /** Node action callback */\n actionCallback?: HvActionsGenericProps[\"actionsCallback\"];\n /** Node maximum number of actions visible */\n maxVisibleActions?: number;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowNodeClasses;\n}\n\nconst isInputConnected = (id, type, idx, edges) => {\n if (type === \"target\") {\n return edges.some(\n (e) => e.target === id && e.targetHandle === idx.toString()\n );\n }\n if (type === \"source\") {\n return edges.some(\n (e) => e.source === id && e.sourceHandle === idx.toString()\n );\n }\n};\n\nexport const HvFlowNode = ({\n id,\n type,\n description,\n expanded = false,\n params,\n actions,\n actionCallback,\n maxVisibleActions = 1,\n classes: classesProp,\n className,\n children,\n}: HvFlowNodeProps) => {\n const [showParams, setShowParams] = useState(expanded);\n const [showActions, setShowActions] = useState(false);\n const reactFlowInstance = useReactFlow();\n\n const { classes, cx, css } = useClasses(classesProp);\n\n const { nodeGroups, nodeTypes, defaultActions } = useFlowContext();\n const edges = useStore((s) => s.edges);\n const nodes = useStore((s) => s.getNodes());\n\n const node = nodes.find((n) => n.id === id);\n\n const groupId = nodeTypes?.[type].meta?.groupId;\n const title = nodeTypes?.[type].meta?.label;\n const groupLabel = groupId && nodeGroups && nodeGroups[groupId].label;\n\n const inputs = nodeTypes?.[type]?.meta?.inputs;\n const outputs = nodeTypes?.[type]?.meta?.outputs;\n const icon = groupId && nodeGroups && nodeGroups[groupId].icon;\n const colorProp = groupId && nodeGroups && nodeGroups[groupId].color;\n const color = getColor(colorProp);\n\n useEffect(() => {\n const newNodes = nodes.map((n) => {\n if (n.id === id) {\n if (Object.keys(n.data).length === 0) {\n params?.forEach((param) => {\n n.data[param.id] = param.value;\n });\n }\n }\n return n;\n });\n reactFlowInstance.setNodes(newNodes);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const handleDefaultAction = useCallback(\n (action: HvFlowDefaultAction) => {\n if (!node) return;\n\n switch (action) {\n case \"delete\":\n reactFlowInstance.deleteElements({ nodes: [node] });\n break;\n case \"duplicate\":\n reactFlowInstance.addNodes([\n {\n ...node,\n id: `${reactFlowInstance.getNodes().length + 1}`,\n position: {\n x: node.position.x,\n y: node.position.y + (node.height || 0) + 20,\n },\n selected: false,\n zIndex: Number(theme.zIndices.overlay),\n },\n ]);\n break;\n default:\n break;\n }\n },\n [node, reactFlowInstance]\n );\n\n const hasParams = !!(params && params.length > 0);\n\n if (!node) return null;\n\n const actsVisible = actions?.slice(0, maxVisibleActions);\n const actsDropdown = actions?.slice(maxVisibleActions);\n\n const renderedIcon = (actionIcon: HvActionGeneric[\"icon\"]) =>\n isValidElement(actionIcon) ? actionIcon : (actionIcon as Function)?.();\n\n return (\n <div\n className={cx(\n css({ border: `1px solid ${color}` }),\n classes.root,\n className\n )}\n onMouseEnter={() => setShowActions(true)}\n onMouseLeave={() => setShowActions(false)}\n >\n <NodeToolbar isVisible={showActions} offset={0}>\n {defaultActions?.map((action) => (\n <HvButton icon onClick={() => handleDefaultAction(action.id)}>\n {renderedIcon(action.icon)}\n </HvButton>\n ))}\n </NodeToolbar>\n <div\n className={cx(css({ backgroundColor: color }), classes.headerContainer)}\n >\n <div className={classes.groupContainer}>\n {icon}\n <HvTypography variant=\"title4\" className={classes.group}>\n {groupLabel}\n </HvTypography>\n </div>\n <div style={{ display: \"flex\" }}>\n <HvTooltip title={<HvTypography>{description}</HvTypography>}>\n <div>\n <Info />\n </div>\n </HvTooltip>\n <HvButton\n icon\n disabled={!hasParams}\n onClick={() => setShowParams((p) => !p)}\n >\n {showParams ? <Up /> : <Down />}\n </HvButton>\n </div>\n </div>\n <div className={classes.titleContainer}>\n <div>\n <HvTypography>{title}</HvTypography>\n </div>\n <div className={classes.actions}>\n {actions?.length && actions?.length > 0 && (\n <>\n {actsVisible?.map((action) => (\n <HvTooltip title={<HvTypography>{action.label}</HvTypography>}>\n <div>\n <HvButton\n icon\n onClick={(event) => {\n actionCallback?.(event, node.id, action);\n }}\n aria-label={action.label}\n >\n {renderedIcon(action.icon)}\n </HvButton>\n </div>\n </HvTooltip>\n ))}\n\n {actsDropdown && actsDropdown.length > 0 && (\n <HvDropDownMenu\n keepOpened={false}\n dataList={actsDropdown?.map((action) => ({\n id: action.id,\n label: action.label,\n }))}\n onClick={(event, action) => {\n actionCallback?.(event, node.id, action as HvActionGeneric);\n }}\n />\n )}\n </>\n )}\n </div>\n </div>\n {children && <div className={classes.contentContainer}>{children}</div>}\n {showParams && params && (\n <div className={classes.paramsContainer}>\n <ParamRenderer nodeId={id} params={params} data={node?.data} />\n </div>\n )}\n {inputs && inputs.length > 0 && (\n <>\n <div className={classes.inputsTitleContainer}>\n <HvTypography>Inputs</HvTypography>\n </div>\n\n <div className={classes.inputsContainer}>\n {inputs?.map((input, idx) => (\n <div className={classes.inputContainer} key={idx}>\n <Handle\n type=\"target\"\n isConnectableStart={false}\n id={`${idx}`}\n position={Position.Left}\n style={{\n top: \"auto\",\n bottom:\n (outputs?.length ? 80 : 18) +\n (outputs?.length || 0) * 29 +\n 29 * idx,\n }}\n />\n <HvTypography>{input.label}</HvTypography>\n {input.isMandatory &&\n !isInputConnected(id, \"target\", idx, edges) && (\n <div className={classes.mandatory} />\n )}\n </div>\n ))}\n </div>\n </>\n )}\n {outputs && outputs.length > 0 && (\n <>\n <div className={classes.outputsTitleContainer}>\n <HvTypography>Outputs</HvTypography>\n </div>\n <div className={classes.outputsContainer}>\n {outputs?.map((output, idx) => (\n <div className={classes.outputContainer} key={idx}>\n <Handle\n type=\"source\"\n isConnectableEnd={false}\n id={`${idx}`}\n position={Position.Right}\n style={{\n bottom: -10 + 29 * (outputs.length - idx),\n top: \"auto\",\n }}\n />\n {output.isMandatory &&\n !isInputConnected(id, \"source\", idx, edges) && (\n <div className={classes.mandatory} />\n )}\n <HvTypography>{output.label}</HvTypography>\n </div>\n ))}\n </div>\n </>\n )}\n </div>\n );\n};\n"],"names":["isInputConnected","id","type","idx","edges","some","e","target","targetHandle","toString","source","sourceHandle","HvFlowNode","description","expanded","params","actions","actionCallback","maxVisibleActions","classes","classesProp","className","children","showParams","setShowParams","useState","showActions","setShowActions","reactFlowInstance","useReactFlow","cx","css","useClasses","nodeGroups","nodeTypes","defaultActions","useFlowContext","useStore","s","nodes","getNodes","node","find","n","groupId","meta","title","label","groupLabel","inputs","outputs","icon","colorProp","color","getColor","useEffect","newNodes","map","Object","keys","data","length","forEach","param","value","setNodes","handleDefaultAction","useCallback","action","deleteElements","addNodes","position","x","y","height","selected","zIndex","Number","theme","zIndices","overlay","hasParams","actsVisible","slice","actsDropdown","renderedIcon","actionIcon","isValidElement","border","root","backgroundColor","headerContainer","groupContainer","group","display","p","titleContainer","event","contentContainer","paramsContainer","inputsTitleContainer","inputsContainer","input","inputContainer","Position","Left","top","bottom","isMandatory","mandatory","outputsTitleContainer","outputsContainer","output","outputContainer","Right"],"mappings":";;;;;;;;;;AAyDA,MAAMA,mBAAmBA,CAACC,IAAIC,MAAMC,KAAKC,UAAU;AACjD,MAAIF,SAAS,UAAU;AACdE,WAAAA,MAAMC,KACVC,CAAAA,MAAMA,EAAEC,WAAWN,MAAMK,EAAEE,iBAAiBL,IAAIM,SACnD,CAAA;AAAA,EACF;AACA,MAAIP,SAAS,UAAU;AACdE,WAAAA,MAAMC,KACVC,CAAAA,MAAMA,EAAEI,WAAWT,MAAMK,EAAEK,iBAAiBR,IAAIM,SACnD,CAAA;AAAA,EACF;AACF;AAEO,MAAMG,aAAaA,CAAC;AAAA,EACzBX;AAAAA,EACAC;AAAAA,EACAW;AAAAA,EACAC,WAAW;AAAA,EACXC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,oBAAoB;AAAA,EACpBC,SAASC;AAAAA,EACTC;AAAAA,EACAC;AACe,MAAM;;AACrB,QAAM,CAACC,YAAYC,aAAa,IAAIC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AU,KAAK,KACzB,KAAK1D;AAAAA,QAAAA,GACP;AAAA,QAEJ,oBAAC,cAAcmG,EAAAA,UAAAA,MAAMvD,MAAM,CAAA;AAAA,QAC1BuD,MAAMM,eACL,CAAC5G,iBAAiBC,IAAI,UAAUE,KAAKC,KAAK,KACxC,oBAAC,OAAI,EAAA,WAAWe,QAAQ0F,UACzB,CAAA;AAAA,MAAA,KAlBwC1G,GAmB7C,IAEJ;AAAA,IAAA,GACF;AAAA,IAED+C,WAAWA,QAAQW,SAAS,KAEzB,qBAAA,UAAA,EAAA,UAAA;AAAA,MAAA,oBAAC,SAAI,WAAW1C,QAAQ2F,uBACtB,UAAC,oBAAA,cAAA,EAAa,qBAAO,EACvB,CAAA;AAAA,MACC,oBAAA,OAAA,EAAI,WAAW3F,QAAQ4F,kBACrB7D,UAASO,mCAAAA,IAAI,CAACuD,QAAQ7G,QACrB,qBAAC,OAAI,EAAA,WAAWgB,QAAQ8F,iBACtB,UAAA;AAAA,QAAA,oBAAC,QACC,EAAA,MAAK,UACL,kBAAkB,OAClB,IAAK,GAAE9G,GAAI,IACX,UAAUqG,SAASU,OACnB,OAAO;AAAA,UACLP,QAAQ,MAAM,MAAMzD,QAAQW,SAAS1D;AAAAA,UACrCuG,KAAK;AAAA,QAAA,GACL;AAAA,QAEHM,OAAOJ,eACN,CAAC5G,iBAAiBC,IAAI,UAAUE,KAAKC,KAAK,KACxC,oBAAC,OAAI,EAAA,WAAWe,QAAQ0F,UACzB,CAAA;AAAA,QACH,oBAAC,cAAcG,EAAAA,UAAAA,OAAOjE,MAAM,CAAA;AAAA,MAAA,KAfgB5C,GAgB9C,IAEJ;AAAA,IAAA,GACF;AAAA,EAEJ,EAAA,CAAA;AAEJ;"}
1
+ {"version":3,"file":"Node.js","sources":["../../../../../src/components/Flow/Node/Node.tsx"],"sourcesContent":["import { isValidElement, useCallback, useEffect, useState } from \"react\";\n\nimport {\n Handle,\n NodeProps,\n NodeToolbar,\n Position,\n useReactFlow,\n useStore,\n} from \"reactflow\";\n\nimport {\n ExtractNames,\n HvActionGeneric,\n HvActionsGenericProps,\n HvBaseProps,\n HvButton,\n HvDropDownMenu,\n HvTooltip,\n HvTypography,\n} from \"@hitachivantara/uikit-react-core\";\nimport { Down, Info, Up } from \"@hitachivantara/uikit-react-icons\";\nimport { getColor, theme } from \"@hitachivantara/uikit-styles\";\n\nimport { useFlowContext } from \"../hooks\";\nimport { HvFlowDefaultAction, HvFlowNodeParam } from \"../types\";\nimport { staticClasses, useClasses } from \"./Node.styles\";\nimport ParamRenderer from \"./Parameters/ParamRenderer\";\n\nexport { staticClasses as flowNodeClasses };\n\nexport type HvFlowNodeClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFlowNodeProps extends Omit<HvBaseProps, \"id\">, NodeProps {\n /** Node description */\n description: string;\n /** Node expanded */\n expanded?: boolean;\n /** Node parameters */\n params?: HvFlowNodeParam[];\n /** Node actions */\n actions?: HvActionGeneric[]; // HvFlowNodeActions[];\n /** Node action callback */\n actionCallback?: HvActionsGenericProps[\"actionsCallback\"];\n /** Node maximum number of actions visible */\n maxVisibleActions?: number;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowNodeClasses;\n}\n\nconst isInputConnected = (id, type, idx, edges) => {\n if (type === \"target\") {\n return edges.some(\n (e) => e.target === id && e.targetHandle === idx.toString()\n );\n }\n if (type === \"source\") {\n return edges.some(\n (e) => e.source === id && e.sourceHandle === idx.toString()\n );\n }\n};\n\nexport const HvFlowNode = ({\n id,\n type,\n description,\n expanded = false,\n params,\n actions,\n actionCallback,\n maxVisibleActions = 1,\n classes: classesProp,\n className,\n children,\n}: HvFlowNodeProps) => {\n const [showParams, setShowParams] = useState(expanded);\n const [showActions, setShowActions] = useState(false);\n const reactFlowInstance = useReactFlow();\n\n const { classes, cx, css } = useClasses(classesProp);\n\n const { nodeGroups, nodeTypes, defaultActions } = useFlowContext();\n const edges = useStore((s) => s.edges);\n const nodes = useStore((s) => s.getNodes());\n\n const node = nodes.find((n) => n.id === id);\n\n const groupId = nodeTypes?.[type].meta?.groupId;\n const title = nodeTypes?.[type].meta?.label;\n const groupLabel = groupId && nodeGroups && nodeGroups[groupId].label;\n\n const inputs = nodeTypes?.[type]?.meta?.inputs;\n const outputs = nodeTypes?.[type]?.meta?.outputs;\n const icon = groupId && nodeGroups && nodeGroups[groupId].icon;\n const colorProp = groupId && nodeGroups && nodeGroups[groupId].color;\n const color = getColor(colorProp);\n\n useEffect(() => {\n const newNodes = nodes.map((n) => {\n if (n.id === id) {\n if (Object.keys(n.data).length === 0) {\n params?.forEach((param) => {\n n.data[param.id] = param.value;\n });\n }\n }\n return n;\n });\n reactFlowInstance.setNodes(newNodes);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const handleDefaultAction = useCallback(\n (action: HvFlowDefaultAction) => {\n if (!node) return;\n\n switch (action) {\n case \"delete\":\n reactFlowInstance.deleteElements({ nodes: [node] });\n break;\n case \"duplicate\":\n reactFlowInstance.addNodes([\n {\n ...node,\n id: `${reactFlowInstance.getNodes().length + 1}`,\n position: {\n x: node.position.x,\n y: node.position.y + (node.height || 0) + 20,\n },\n selected: false,\n zIndex: Number(theme.zIndices.overlay),\n },\n ]);\n break;\n default:\n break;\n }\n },\n [node, reactFlowInstance]\n );\n\n const hasParams = !!(params && params.length > 0);\n\n if (!node) return null;\n\n const actsVisible = actions?.slice(0, maxVisibleActions);\n const actsDropdown = actions?.slice(maxVisibleActions);\n\n const renderedIcon = (actionIcon: HvActionGeneric[\"icon\"]) =>\n isValidElement(actionIcon) ? actionIcon : (actionIcon as Function)?.();\n\n return (\n <div\n className={cx(\n css({ border: `1px solid ${color}` }),\n classes.root,\n className\n )}\n onMouseEnter={() => setShowActions(true)}\n onMouseLeave={() => setShowActions(false)}\n >\n <NodeToolbar isVisible={showActions} offset={0}>\n {defaultActions?.map((action) => (\n <HvButton\n key={action.id}\n icon\n onClick={() => handleDefaultAction(action.id)}\n >\n {renderedIcon(action.icon)}\n </HvButton>\n ))}\n </NodeToolbar>\n <div\n className={cx(css({ backgroundColor: color }), classes.headerContainer)}\n >\n <div className={classes.groupContainer}>\n {icon}\n <HvTypography variant=\"title4\" className={classes.group}>\n {groupLabel}\n </HvTypography>\n </div>\n <div style={{ display: \"flex\" }}>\n <HvTooltip title={<HvTypography>{description}</HvTypography>}>\n <div>\n <Info />\n </div>\n </HvTooltip>\n <HvButton\n icon\n disabled={!hasParams}\n onClick={() => setShowParams((p) => !p)}\n >\n {showParams ? <Up /> : <Down />}\n </HvButton>\n </div>\n </div>\n <div className={classes.titleContainer}>\n <div>\n <HvTypography>{title}</HvTypography>\n </div>\n <div className={classes.actions}>\n {actions?.length && actions?.length > 0 && (\n <>\n {actsVisible?.map((action) => (\n <HvTooltip\n key={action.id}\n title={<HvTypography>{action.label}</HvTypography>}\n >\n <div>\n <HvButton\n icon\n onClick={(event) => {\n actionCallback?.(event, node.id, action);\n }}\n aria-label={action.label}\n >\n {renderedIcon(action.icon)}\n </HvButton>\n </div>\n </HvTooltip>\n ))}\n\n {actsDropdown && actsDropdown.length > 0 && (\n <HvDropDownMenu\n keepOpened={false}\n dataList={actsDropdown?.map((action) => ({\n id: action.id,\n label: action.label,\n }))}\n onClick={(event, action) => {\n actionCallback?.(event, node.id, action as HvActionGeneric);\n }}\n />\n )}\n </>\n )}\n </div>\n </div>\n {children && <div className={classes.contentContainer}>{children}</div>}\n {showParams && params && (\n <div className={classes.paramsContainer}>\n <ParamRenderer nodeId={id} params={params} data={node?.data} />\n </div>\n )}\n {inputs && inputs.length > 0 && (\n <>\n <div className={classes.inputsTitleContainer}>\n <HvTypography>Inputs</HvTypography>\n </div>\n\n <div className={classes.inputsContainer}>\n {inputs?.map((input, idx) => (\n <div className={classes.inputContainer} key={idx}>\n <Handle\n type=\"target\"\n isConnectableStart={false}\n id={`${idx}`}\n position={Position.Left}\n style={{\n top: \"auto\",\n bottom:\n (outputs?.length ? 80 : 18) +\n (outputs?.length || 0) * 29 +\n 29 * idx,\n }}\n />\n <HvTypography>{input.label}</HvTypography>\n {input.isMandatory &&\n !isInputConnected(id, \"target\", idx, edges) && (\n <div className={classes.mandatory} />\n )}\n </div>\n ))}\n </div>\n </>\n )}\n {outputs && outputs.length > 0 && (\n <>\n <div className={classes.outputsTitleContainer}>\n <HvTypography>Outputs</HvTypography>\n </div>\n <div className={classes.outputsContainer}>\n {outputs?.map((output, idx) => (\n <div className={classes.outputContainer} key={idx}>\n <Handle\n type=\"source\"\n isConnectableEnd={false}\n id={`${idx}`}\n position={Position.Right}\n style={{\n bottom: -10 + 29 * (outputs.length - idx),\n top: \"auto\",\n }}\n />\n {output.isMandatory &&\n !isInputConnected(id, \"source\", idx, edges) && (\n <div className={classes.mandatory} />\n )}\n <HvTypography>{output.label}</HvTypography>\n </div>\n ))}\n </div>\n </>\n )}\n </div>\n );\n};\n"],"names":["isInputConnected","id","type","idx","edges","some","e","target","targetHandle","toString","source","sourceHandle","HvFlowNode","description","expanded","params","actions","actionCallback","maxVisibleActions","classes","classesProp","className","children","showParams","setShowParams","useState","showActions","setShowActions","reactFlowInstance","useReactFlow","cx","css","useClasses","nodeGroups","nodeTypes","defaultActions","useFlowContext","useStore","s","nodes","getNodes","node","find","n","groupId","meta","title","label","groupLabel","inputs","outputs","icon","colorProp","color","getColor","useEffect","newNodes","map","Object","keys","data","length","forEach","param","value","setNodes","handleDefaultAction","useCallback","action","deleteElements","addNodes","position","x","y","height","selected","zIndex","Number","theme","zIndices","overlay","hasParams","actsVisible","slice","actsDropdown","renderedIcon","actionIcon","isValidElement","border","root","backgroundColor","headerContainer","groupContainer","group","display","p","titleContainer","event","contentContainer","paramsContainer","inputsTitleContainer","inputsContainer","input","inputContainer","Position","Left","top","bottom","isMandatory","mandatory","outputsTitleContainer","outputsContainer","output","outputContainer","Right"],"mappings":";;;;;;;;;;AAkDA,MAAMA,mBAAmBA,CAACC,IAAIC,MAAMC,KAAKC,UAAU;AACjD,MAAIF,SAAS,UAAU;AACdE,WAAAA,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