@hitachivantara/uikit-react-lab 5.5.5 → 5.7.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 (42) hide show
  1. package/dist/cjs/components/Flow/DroppableFlow.cjs +73 -1
  2. package/dist/cjs/components/Flow/DroppableFlow.cjs.map +1 -1
  3. package/dist/cjs/components/Flow/Flow.cjs +2 -1
  4. package/dist/cjs/components/Flow/Flow.cjs.map +1 -1
  5. package/dist/cjs/components/Flow/Flow.styles.cjs +40 -1
  6. package/dist/cjs/components/Flow/Flow.styles.cjs.map +1 -1
  7. package/dist/cjs/components/Flow/FlowContext/FlowContext.cjs +3 -1
  8. package/dist/cjs/components/Flow/FlowContext/FlowContext.cjs.map +1 -1
  9. package/dist/cjs/components/Flow/Node/Node.cjs +153 -0
  10. package/dist/cjs/components/Flow/Node/Node.cjs.map +1 -0
  11. package/dist/cjs/components/Flow/Node/Node.styles.cjs +97 -0
  12. package/dist/cjs/components/Flow/Node/Node.styles.cjs.map +1 -0
  13. package/dist/cjs/components/Flow/Node/Parameters/ParamRenderer.cjs +28 -0
  14. package/dist/cjs/components/Flow/Node/Parameters/ParamRenderer.cjs.map +1 -0
  15. package/dist/cjs/components/Flow/Node/Parameters/Select.cjs +39 -0
  16. package/dist/cjs/components/Flow/Node/Parameters/Select.cjs.map +1 -0
  17. package/dist/cjs/components/Flow/Node/Parameters/Text.cjs +32 -0
  18. package/dist/cjs/components/Flow/Node/Parameters/Text.cjs.map +1 -0
  19. package/dist/cjs/index.cjs +4 -0
  20. package/dist/cjs/index.cjs.map +1 -1
  21. package/dist/esm/components/Flow/DroppableFlow.js +75 -3
  22. package/dist/esm/components/Flow/DroppableFlow.js.map +1 -1
  23. package/dist/esm/components/Flow/Flow.js +2 -1
  24. package/dist/esm/components/Flow/Flow.js.map +1 -1
  25. package/dist/esm/components/Flow/Flow.styles.js +41 -2
  26. package/dist/esm/components/Flow/Flow.styles.js.map +1 -1
  27. package/dist/esm/components/Flow/FlowContext/FlowContext.js +3 -1
  28. package/dist/esm/components/Flow/FlowContext/FlowContext.js.map +1 -1
  29. package/dist/esm/components/Flow/Node/Node.js +154 -0
  30. package/dist/esm/components/Flow/Node/Node.js.map +1 -0
  31. package/dist/esm/components/Flow/Node/Node.styles.js +97 -0
  32. package/dist/esm/components/Flow/Node/Node.styles.js.map +1 -0
  33. package/dist/esm/components/Flow/Node/Parameters/ParamRenderer.js +28 -0
  34. package/dist/esm/components/Flow/Node/Parameters/ParamRenderer.js.map +1 -0
  35. package/dist/esm/components/Flow/Node/Parameters/Select.js +39 -0
  36. package/dist/esm/components/Flow/Node/Parameters/Select.js.map +1 -0
  37. package/dist/esm/components/Flow/Node/Parameters/Text.js +32 -0
  38. package/dist/esm/components/Flow/Node/Parameters/Text.js.map +1 -0
  39. package/dist/esm/index.js +4 -0
  40. package/dist/esm/index.js.map +1 -1
  41. package/dist/types/index.d.ts +105 -20
  42. package/package.json +3 -3
@@ -11,6 +11,44 @@ const Flow_styles = require("./Flow.styles.cjs");
11
11
  const FlowContext = require("./FlowContext/FlowContext.cjs");
12
12
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
13
13
  const ReactFlow__default = /* @__PURE__ */ _interopDefault(ReactFlow);
14
+ const getNode = (nodes, nodeId) => {
15
+ return nodes.find((n) => n.id === nodeId);
16
+ };
17
+ const validateEdges = (edges, nodes, nodeTypes) => {
18
+ if (edges) {
19
+ const validEdges = [];
20
+ edges.forEach((edge) => {
21
+ var _a, _b, _c, _d, _e, _f;
22
+ if (!edge.sourceHandle || !edge.targetHandle)
23
+ return [];
24
+ const sourceNode = getNode(nodes, edge.source);
25
+ const targetNode = getNode(nodes, edge.target);
26
+ if (!sourceNode || !targetNode)
27
+ return [];
28
+ const sourceType = sourceNode.type;
29
+ const targetType = targetNode.type;
30
+ if (!sourceType || !targetType)
31
+ return [];
32
+ 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];
33
+ 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];
34
+ const sourceProvides = (output == null ? void 0 : output.provides) || [];
35
+ const targetAccepts = (input == null ? void 0 : input.accepts) || [];
36
+ let isValid = false;
37
+ sourceProvides.forEach((s) => {
38
+ targetAccepts.forEach((t) => {
39
+ if (s === t) {
40
+ isValid = true;
41
+ }
42
+ });
43
+ });
44
+ if (isValid) {
45
+ validEdges.push(edge);
46
+ }
47
+ });
48
+ return validEdges;
49
+ }
50
+ return [];
51
+ };
14
52
  const HvDroppableFlow = ({
15
53
  id,
16
54
  className,
@@ -84,8 +122,42 @@ const HvDroppableFlow = ({
84
122
  handleFlowChange(nodes, eds);
85
123
  onEdgesChangeProp == null ? void 0 : onEdgesChangeProp(changes);
86
124
  }, [edges, handleFlowChange, nodes, onEdgesChangeProp]);
87
- return /* @__PURE__ */ jsxRuntime.jsx("div", { id: elementId, ref: setNodeRef, className: cx(classes.root, className), children: /* @__PURE__ */ jsxRuntime.jsx(ReactFlow__default.default, { nodes, edges, nodeTypes, onNodesChange: handleNodesChange, onEdgesChange: handleEdgesChange, onConnect: handleConnect, ...others, children }) });
125
+ const isValidConnection = (connection) => {
126
+ var _a, _b, _c, _d, _e, _f;
127
+ const sourceNode = getNode(nodes, connection.source);
128
+ const targetNode = getNode(nodes, connection.target);
129
+ if (!sourceNode || !targetNode) {
130
+ return false;
131
+ }
132
+ const sourceType = sourceNode.type;
133
+ const targetType = targetNode.type;
134
+ if (!sourceType || !targetType) {
135
+ return false;
136
+ }
137
+ const inputs = ((_b = (_a = nodeTypes == null ? void 0 : nodeTypes[targetType]) == null ? void 0 : _a.meta) == null ? void 0 : _b.inputs) || [];
138
+ const outputs = ((_d = (_c = nodeTypes == null ? void 0 : nodeTypes[sourceType]) == null ? void 0 : _c.meta) == null ? void 0 : _d.outputs) || [];
139
+ const sourceProvides = ((_e = outputs[connection.sourceHandle]) == null ? void 0 : _e.provides) || [];
140
+ const targetAccepts = ((_f = inputs[connection.targetHandle]) == null ? void 0 : _f.accepts) || [];
141
+ let isValid = false;
142
+ sourceProvides.forEach((s) => {
143
+ targetAccepts.forEach((t) => {
144
+ if (s === t) {
145
+ isValid = true;
146
+ }
147
+ });
148
+ });
149
+ return isValid;
150
+ };
151
+ const validEdges = validateEdges(edges, nodes, nodeTypes);
152
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { id: elementId, ref: setNodeRef, className: cx(classes.root, className), children: /* @__PURE__ */ jsxRuntime.jsx(ReactFlow__default.default, { nodes, edges: validEdges, nodeTypes, onNodesChange: handleNodesChange, onEdgesChange: handleEdgesChange, onConnect: handleConnect, isValidConnection, defaultEdgeOptions: {
153
+ markerEnd: {
154
+ type: ReactFlow.MarkerType.ArrowClosed,
155
+ height: 20,
156
+ width: 20
157
+ }
158
+ }, ...others, children }) });
88
159
  };
89
160
  exports.flowClasses = Flow_styles.staticClasses;
90
161
  exports.HvDroppableFlow = HvDroppableFlow;
162
+ exports.getNode = getNode;
91
163
  //# sourceMappingURL=DroppableFlow.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"DroppableFlow.cjs","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} 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 { HvFlowEdge, HvFlowNode } 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?: HvFlowNode<NodeData, NodeType>[];\n /** Flow edges. */\n edges?: HvFlowEdge[];\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?: (\n nodes: HvFlowNode<NodeData, NodeType>[],\n edges: HvFlowEdge[]\n ) => void;\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: HvFlowNode = {\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 return (\n <div\n id={elementId}\n ref={setNodeRef}\n className={cx(classes.root, className)}\n >\n <ReactFlow\n nodes={nodes}\n edges={edges}\n nodeTypes={nodeTypes}\n onNodesChange={handleNodesChange}\n onEdgesChange={handleEdgesChange}\n onConnect={handleConnect}\n {...others}\n >\n {children}\n </ReactFlow>\n </div>\n );\n};\n"],"names":["HvDroppableFlow","id","className","children","onFlowChange","classes","classesProp","nodes","initialNodes","edges","initialEdges","onConnect","onConnectProp","onNodesChange","onNodesChangeProp","onEdgesChange","onEdgesChangeProp","others","cx","useClasses","elementId","useUniqueId","reactFlowInstance","useReactFlow","nodeTypes","useFlowContext","setNodes","useState","setEdges","setNodeRef","useDroppable","handleDragEnd","useCallback","event","over","type","active","toString","position","project","x","data","current","hvFlow","rect","left","y","top","newNode","uid","nds","concat","useDndMonitor","onDragEnd","handleFlowChange","eds","isDragging","find","node","dragging","handleConnect","connection","addEdge","handleNodesChange","changes","applyNodeChanges","handleEdgesChange","applyEdgeChanges","jsx","root","ReactFlow"],"mappings":";;;;;;;;;;;;;AA+CO,MAAMA,kBAAkBA,CAAC;AAAA,EAC9BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,SAASC;AAAAA,EACTC,OAAOC,eAAe,CAAE;AAAA,EACxBC,OAAOC,eAAe,CAAE;AAAA,EACxBC,WAAWC;AAAAA,EACXC,eAAeC;AAAAA,EACfC,eAAeC;AAAAA,EACf,GAAGC;AACiB,MAAM;AACpB,QAAA;AAAA,IAAEZ;AAAAA,IAASa;AAAAA,EAAAA,IAAOC,YAAAA,WAAWb,WAAW;AAExCc,QAAAA,YAAYC,eAAAA,YAAYpB,IAAI,QAAQ;AAE1C,QAAMqB,oBAAoBC,UAAAA;AAEpB,QAAA;AAAA,IAAEC;AAAAA,MAAcC,YAAe,eAAA;AAErC,QAAM,CAAClB,OAAOmB,QAAQ,IAAIC,eAASnB,YAAY;AAC/C,QAAM,CAACC,OAAOmB,QAAQ,IAAID,eAASjB,YAAY;AAEzC,QAAA;AAAA,IAAEmB;AAAAA,MAAeC,kBAAa;AAAA,IAClC7B,IAAImB;AAAAA,EAAAA,CACL;AAEKW,QAAAA,gBAAgBC,kBACpB,CAACC,UAAwB;;AACvB,QAAIA,MAAMC,QAAQD,MAAMC,KAAKjC,OAAOmB,WAAW;AAC7C,YAAMe,OAAOF,MAAMG,OAAOnC,GAAGoC,SAAS;AAGhCC,YAAAA,WAAWhB,kBAAkBiB,QAAQ;AAAA,QACzCC,MAAIP,iBAAMG,OAAOK,KAAKC,YAAlBT,mBAA2BU,WAA3BV,mBAAmCO,MAAK,KAAKP,MAAMC,KAAKU,KAAKC;AAAAA,QACjEC,MAAIb,iBAAMG,OAAOK,KAAKC,YAAlBT,mBAA2BU,WAA3BV,mBAAmCa,MAAK,KAAKb,MAAMC,KAAKU,KAAKG;AAAAA,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iB,CACpD;AAGE,SAAAoD,2BAAA,IAAC,OACC,EAAA,IAAIhD,WACJ,KAAKS,YACL,WAAWX,GAAGb,QAAQgE,MAAMnE,SAAS,GAErC,UAAAkE,2BAAA,IAACE,8BACC,OACA,OACA,WACA,eAAeP,mBACf,eAAeG,mBACf,WAAWN,eACX,GAAI3C,QAEHd,SACH,CAAA,EACF,CAAA;AAEJ;;;"}
1
+ {"version":3,"file":"DroppableFlow.cjs","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","useDndMonitor","onDragEnd","handleFlowChange","eds","isDragging","node","dragging","handleConnect","connection","addEdge","handleNodesChange","changes","applyNodeChanges","handleEdgesChange","applyEdgeChanges","isValidConnection","jsx","root","ReactFlow","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,C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WAAW7E,YAAY,MAA/BW,mBAAkCI,aAAY;AACrE,UAAMC,kBAAgBH,YAAOgE,WAAW5E,YAAY,MAA9BY,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,SAAAyF,2BAAA,IAAC,OACC,EAAA,IAAI9C,WACJ,KAAKQ,YACL,WAAWV,GAAGX,QAAQ4D,MAAM/D,SAAS,GAErC,yCAACgE,mBAAAA,SACC,EAAA,OACA,OAAO1F,YACP,WACA,eAAekF,mBACf,eAAeG,mBACf,WAAWN,eACX,mBACA,oBAAoB;AAAA,IAClBY,WAAW;AAAA,MACTjF,MAAMkF,UAAWC,WAAAA;AAAAA,MACjBC,QAAQ;AAAA,MACRC,OAAO;AAAA,IACT;AAAA,EAEExD,GAAAA,GAAAA,QAEHZ,SACH,CAAA,EACF,CAAA;AAEJ;;;;"}
@@ -12,6 +12,7 @@ const HvFlow = ({
12
12
  nodeTypes,
13
13
  nodeGroups,
14
14
  sidebar,
15
+ defaultActions,
15
16
  dndContextProps,
16
17
  ...others
17
18
  }) => {
@@ -26,7 +27,7 @@ const HvFlow = ({
26
27
  const handleDragEnd = () => {
27
28
  setDraggingLabel(void 0);
28
29
  };
29
- return /* @__PURE__ */ jsxRuntime.jsx(ReactFlow.ReactFlowProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(FlowContext.HvFlowProvider, { nodeGroups, nodeTypes, children: /* @__PURE__ */ jsxRuntime.jsxs(core.DndContext, { onDragStart: handleDragStart, onDragEnd: handleDragEnd, sensors, modifiers: [modifiers.restrictToWindowEdges], ...dndContextProps, children: [
30
+ return /* @__PURE__ */ jsxRuntime.jsx(ReactFlow.ReactFlowProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(FlowContext.HvFlowProvider, { nodeGroups, nodeTypes, defaultActions, children: /* @__PURE__ */ jsxRuntime.jsxs(core.DndContext, { onDragStart: handleDragStart, onDragEnd: handleDragEnd, sensors, modifiers: [modifiers.restrictToWindowEdges], ...dndContextProps, children: [
30
31
  /* @__PURE__ */ jsxRuntime.jsx(DroppableFlow.HvDroppableFlow, { ...others }),
31
32
  sidebar,
32
33
  /* @__PURE__ */ jsxRuntime.jsx(core.DragOverlay, { modifiers: [modifiers.restrictToWindowEdges], children: draggingLabel ? /* @__PURE__ */ jsxRuntime.jsx(SidebarGroupItem.HvFlowSidebarGroupItem, { label: draggingLabel, isDragging: true }) : null })
@@ -1 +1 @@
1
- {"version":3,"file":"Flow.cjs","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 { HvFlowNodeGroups, HvFlowNodeTypes } 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 /**\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 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 nodeGroups={nodeGroups} nodeTypes={nodeTypes}>\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","dndContextProps","others","draggingLabel","setDraggingLabel","useState","undefined","sensors","useSensors","useSensor","PointerSensor","KeyboardSensor","handleDragStart","event","active","data","current","hvFlow","label","handleDragEnd","ReactFlowProvider","jsx","HvFlowProvider","DndContext","restrictToWindowEdges","HvDroppableFlow","DragOverlay","HvFlowSidebarGroupItem"],"mappings":";;;;;;;;;;AA+CO,MAAMA,SAASA,CAAC;AAAA,EACrBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AACQ,MAAM;AACjB,QAAM,CAACC,eAAeC,gBAAgB,IAAIC,MAAAA,SAASC,MAAS;AAE5D,QAAMC,UAAUC,KAAAA,WACdC,KAAAA,UAAUC,KAAa,aAAA,GACvBD,KAAAA,UAAUE,KAAc,cAAA,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,wCACGc,UAAAA,mBACC,EAAA,UAAAC,2BAAA,IAACC,8BAAe,YAAwB,WACtC,0CAACC,KAAAA,YACC,EAAA,aAAaX,iBACb,WAAWO,eACX,SACA,WAAW,CAACK,+BAAqB,GACjC,GAAIvB,iBAEJ,UAAA;AAAA,IAACoB,2BAAAA,IAAAI,cAAA,iBAAA,EAAgB,GAAIvB,QAAO;AAAA,IAC3BF;AAAAA,IACAqB,2BAAA,IAAAK,KAAA,aAAA,EAAY,WAAW,CAACF,UAAAA,qBAAqB,GAC3CrB,UAAAA,gBACEkB,2BAAAA,IAAAM,iBAAAA,wBAAA,EAAuB,OAAOxB,eAAe,YAAU,KAAA,CAAA,IACtD,MACN;AAAA,EAAA,GACF,GACF,EACF,CAAA;AAEJ;;"}
1
+ {"version":3,"file":"Flow.cjs","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 { HvActionGeneric } from \"@hitachivantara/uikit-react-core\";\nimport { HvFlowNodeGroups, HvFlowNodeTypes } 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?: HvActionGeneric[];\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","ReactFlowProvider","jsx","HvFlowProvider","jsxs","DndContext","restrictToWindowEdges","HvDroppableFlow","DragOverlay","HvFlowSidebarGroupItem"],"mappings":";;;;;;;;;;AAkDO,MAAMA,SAASA,CAAC;AAAA,EACrBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AACQ,MAAM;AACjB,QAAM,CAACC,eAAeC,gBAAgB,IAAIC,MAAAA,SAASC,MAAS;AAE5D,QAAMC,UAAUC,KAAAA,WACdC,KAAAA,UAAUC,KAAa,aAAA,GACvBD,KAAAA,UAAUE,KAAc,cAAA,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,wCACGc,UAAAA,mBACC,EAAA,UAAAC,2BAAA,IAACC,8BACC,YACA,WACA,gBAEA,UAACC,2BAAA,KAAAC,iBAAA,EACC,aAAaZ,iBACb,WAAWO,eACX,SACA,WAAW,CAACM,UAAqB,qBAAA,GACjC,GAAIxB,iBAEJ,UAAA;AAAA,IAACoB,2BAAAA,IAAAK,cAAA,iBAAA,EAAgB,GAAIxB,QAAO;AAAA,IAC3BH;AAAAA,IACAsB,2BAAA,IAAAM,KAAA,aAAA,EAAY,WAAW,CAACF,UAAAA,qBAAqB,GAC3CtB,UAAAA,gBACEkB,2BAAAA,IAAAO,iBAAAA,wBAAA,EAAuB,OAAOzB,eAAe,YAAU,KAAA,CAAA,IACtD,MACN;AAAA,EAAA,GACF,GACF,EACF,CAAA;AAEJ;;"}
@@ -1,12 +1,51 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const uikitReactCore = require("@hitachivantara/uikit-react-core");
4
+ const Node_styles = require("./Node/Node.styles.cjs");
5
+ require("@emotion/react/jsx-runtime");
6
+ require("@hitachivantara/uikit-react-icons");
7
+ require("@hitachivantara/uikit-styles");
8
+ require("react");
9
+ require("reactflow");
4
10
  const {
5
11
  staticClasses,
6
12
  useClasses
7
13
  } = uikitReactCore.createClasses("HvFlow", {
8
14
  root: {
9
- height: "100%"
15
+ height: "100%",
16
+ "& .react-flow__handle": {
17
+ backgroundColor: uikitReactCore.theme.colors.secondary_60,
18
+ width: 8,
19
+ height: 8,
20
+ zIndex: uikitReactCore.theme.zIndices.overlay
21
+ },
22
+ "& .react-flow__handle-connecting": {
23
+ backgroundColor: uikitReactCore.theme.colors.negative_20,
24
+ width: 12,
25
+ height: 12,
26
+ "&.react-flow__handle-top": {
27
+ top: -6
28
+ },
29
+ "&.react-flow__handle-bottom": {
30
+ bottom: -6
31
+ }
32
+ },
33
+ "& .react-flow__handle-valid": {
34
+ backgroundColor: uikitReactCore.theme.colors.positive_20,
35
+ width: 12,
36
+ height: 12,
37
+ "&.react-flow__handle-top": {
38
+ top: -6
39
+ },
40
+ "&.react-flow__handle-bottom": {
41
+ bottom: -6
42
+ }
43
+ },
44
+ [`& .selected > .${Node_styles.staticClasses.root}`]: {
45
+ border: `1px solid ${uikitReactCore.theme.colors.secondary_60}`,
46
+ borderRadius: uikitReactCore.theme.radii.round,
47
+ boxSizing: "border-box"
48
+ }
10
49
  }
11
50
  });
12
51
  exports.staticClasses = staticClasses;
@@ -1 +1 @@
1
- {"version":3,"file":"Flow.styles.cjs","sources":["../../../../src/components/Flow/Flow.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-core\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFlow\", {\n root: { height: \"100%\" },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","height"],"mappings":";;;AAEa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,eAAAA,cAAc,UAAU;AAAA,EACnEC,MAAM;AAAA,IAAEC,QAAQ;AAAA,EAAO;AACzB,CAAC;;;"}
1
+ {"version":3,"file":"Flow.styles.cjs","sources":["../../../../src/components/Flow/Flow.styles.tsx"],"sourcesContent":["import { createClasses, theme } from \"@hitachivantara/uikit-react-core\";\nimport { flowNodeClasses } from \"./Node\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFlow\", {\n root: {\n height: \"100%\",\n \"& .react-flow__handle\": {\n backgroundColor: theme.colors.secondary_60,\n width: 8,\n height: 8,\n zIndex: theme.zIndices.overlay,\n },\n \"& .react-flow__handle-connecting\": {\n backgroundColor: theme.colors.negative_20,\n width: 12,\n height: 12,\n \"&.react-flow__handle-top\": {\n top: -6,\n },\n \"&.react-flow__handle-bottom\": {\n bottom: -6,\n },\n },\n \"& .react-flow__handle-valid\": {\n backgroundColor: theme.colors.positive_20,\n width: 12,\n height: 12,\n \"&.react-flow__handle-top\": {\n top: -6,\n },\n \"&.react-flow__handle-bottom\": {\n bottom: -6,\n },\n },\n [`& .selected > .${flowNodeClasses.root}`]: {\n border: `1px solid ${theme.colors.secondary_60}`,\n borderRadius: theme.radii.round,\n boxSizing: \"border-box\",\n },\n },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","height","backgroundColor","theme","colors","secondary_60","width","zIndex","zIndices","overlay","negative_20","top","bottom","positive_20","flowNodeClasses","border","borderRadius","radii","round","boxSizing"],"mappings":";;;;;;;;;AAGa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,eAAAA,cAAc,UAAU;AAAA,EACnEC,MAAM;AAAA,IACJC,QAAQ;AAAA,IACR,yBAAyB;AAAA,MACvBC,iBAAiBC,eAAAA,MAAMC,OAAOC;AAAAA,MAC9BC,OAAO;AAAA,MACPL,QAAQ;AAAA,MACRM,QAAQJ,eAAAA,MAAMK,SAASC;AAAAA,IACzB;AAAA,IACA,oCAAoC;AAAA,MAClCP,iBAAiBC,eAAAA,MAAMC,OAAOM;AAAAA,MAC9BJ,OAAO;AAAA,MACPL,QAAQ;AAAA,MACR,4BAA4B;AAAA,QAC1BU,KAAK;AAAA,MACP;AAAA,MACA,+BAA+B;AAAA,QAC7BC,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,IACA,+BAA+B;AAAA,MAC7BV,iBAAiBC,eAAAA,MAAMC,OAAOS;AAAAA,MAC9BP,OAAO;AAAA,MACPL,QAAQ;AAAA,MACR,4BAA4B;AAAA,QAC1BU,KAAK;AAAA,MACP;AAAA,MACA,+BAA+B;AAAA,QAC7BC,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,IACA,CAAE,kBAAiBE,0BAAgBd,IAAK,EAAC,GAAG;AAAA,MAC1Ce,QAAS,aAAYZ,eAAMC,MAAAA,OAAOC,YAAa;AAAA,MAC/CW,cAAcb,eAAAA,MAAMc,MAAMC;AAAAA,MAC1BC,WAAW;AAAA,IACb;AAAA,EACF;AACF,CAAC;;;"}
@@ -6,15 +6,17 @@ const HvFlowContext = React.createContext({});
6
6
  const HvFlowProvider = ({
7
7
  nodeGroups,
8
8
  nodeTypes,
9
+ defaultActions,
9
10
  children
10
11
  }) => {
11
12
  const [expandedNodeGroups, setExpandedNodeGroups] = React.useState([]);
12
13
  const value = React.useMemo(() => ({
13
14
  nodeTypes,
14
15
  nodeGroups,
16
+ defaultActions,
15
17
  expandedNodeGroups,
16
18
  setExpandedNodeGroups
17
- }), [nodeGroups, nodeTypes, expandedNodeGroups]);
19
+ }), [nodeTypes, nodeGroups, defaultActions, expandedNodeGroups]);
18
20
  return /* @__PURE__ */ jsxRuntime.jsx(HvFlowContext.Provider, { value, children });
19
21
  };
20
22
  const useFlowContext = () => React.useContext(HvFlowContext);
@@ -1 +1 @@
1
- {"version":3,"file":"FlowContext.cjs","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 { HvFlowNodeGroups, HvFlowNodeTypes } 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 /** 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 /** Children. */\n children?: React.ReactNode;\n}\n\nexport const HvFlowProvider = ({\n nodeGroups,\n nodeTypes,\n children,\n}: HvFlowProviderProps) => {\n const [expandedNodeGroups, setExpandedNodeGroups] = useState<string[]>([]);\n\n const value = useMemo(\n () => ({\n nodeTypes,\n nodeGroups,\n expandedNodeGroups,\n setExpandedNodeGroups,\n }),\n [nodeGroups, nodeTypes, 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","children","expandedNodeGroups","setExpandedNodeGroups","useState","value","useMemo","jsx","useFlowContext","useContext"],"mappings":";;;;AAsBaA,MAAAA,gBAAgBC,MAAkC,cAAA,EAAE;AAW1D,MAAMC,iBAAiBA,CAAC;AAAA,EAC7BC;AAAAA,EACAC;AAAAA,EACAC;AACmB,MAAM;AACzB,QAAM,CAACC,oBAAoBC,qBAAqB,IAAIC,MAAAA,SAAmB,CAAE,CAAA;AAEnEC,QAAAA,QAAQC,MAAAA,QACZ,OAAO;AAAA,IACLN;AAAAA,IACAD;AAAAA,IACAG;AAAAA,IACAC;AAAAA,EAEF,IAAA,CAACJ,YAAYC,WAAWE,kBAAkB,CAC5C;AAEA,SACGK,2BAAAA,IAAA,cAAc,UAAd,EAAuB,OAAeN,SAAS,CAAA;AAEpD;AAEaO,MAAAA,iBAAiBA,MAAMC,MAAAA,WAAWb,aAAa;;;;"}
1
+ {"version":3,"file":"FlowContext.cjs","sources":["../../../../../src/components/Flow/FlowContext/FlowContext.tsx"],"sourcesContent":["import { HvActionGeneric } from \"@hitachivantara/uikit-react-core\";\nimport {\n Dispatch,\n SetStateAction,\n createContext,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nimport { HvFlowNodeGroups, HvFlowNodeTypes } 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?: HvActionGeneric[];\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?: HvActionGeneric[];\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","jsx","useFlowContext","useContext"],"mappings":";;;;AAyBaA,MAAAA,gBAAgBC,MAAkC,cAAA,EAAE;AAa1D,MAAMC,iBAAiBA,CAAC;AAAA,EAC7BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACmB,MAAM;AACzB,QAAM,CAACC,oBAAoBC,qBAAqB,IAAIC,MAAAA,SAAmB,CAAE,CAAA;AAEnEC,QAAAA,QAAQC,MAAAA,QACZ,OAAO;AAAA,IACLP;AAAAA,IACAD;AAAAA,IACAE;AAAAA,IACAE;AAAAA,IACAC;AAAAA,EAAAA,IAEF,CAACJ,WAAWD,YAAYE,gBAAgBE,kBAAkB,CAC5D;AAEA,SACGK,2BAAAA,IAAA,cAAc,UAAd,EAAuB,OAAeN,SAAS,CAAA;AAEpD;AAEaO,MAAAA,iBAAiBA,MAAMC,MAAAA,WAAWd,aAAa;;;;"}
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("@emotion/react/jsx-runtime");
4
+ const uikitReactCore = require("@hitachivantara/uikit-react-core");
5
+ const uikitReactIcons = require("@hitachivantara/uikit-react-icons");
6
+ const uikitStyles = require("@hitachivantara/uikit-styles");
7
+ const React = require("react");
8
+ const ReactFlow = require("reactflow");
9
+ const FlowContext = require("../FlowContext/FlowContext.cjs");
10
+ const Node_styles = require("./Node.styles.cjs");
11
+ const ParamRenderer = require("./Parameters/ParamRenderer.cjs");
12
+ const isInputConnected = (id, type, idx, edges) => {
13
+ if (type === "target") {
14
+ return edges.some((e) => e.target === id && e.targetHandle === idx.toString());
15
+ }
16
+ if (type === "source") {
17
+ return edges.some((e) => e.source === id && e.sourceHandle === idx.toString());
18
+ }
19
+ };
20
+ const HvFlowNode = ({
21
+ id,
22
+ type,
23
+ description,
24
+ expanded = false,
25
+ params,
26
+ actions,
27
+ actionCallback,
28
+ maxVisibleActions = 1,
29
+ classes: classesProp,
30
+ className
31
+ }) => {
32
+ var _a, _b, _c, _d, _e, _f;
33
+ const [showParams, setShowParams] = React.useState(expanded);
34
+ const [showActions, setShowActions] = React.useState(false);
35
+ const reactFlowInstance = ReactFlow.useReactFlow();
36
+ const {
37
+ classes,
38
+ cx,
39
+ css
40
+ } = Node_styles.useClasses(classesProp);
41
+ const {
42
+ nodeGroups,
43
+ nodeTypes,
44
+ defaultActions
45
+ } = FlowContext.useFlowContext();
46
+ const edges = ReactFlow.useStore((s) => s.edges);
47
+ const nodes = ReactFlow.useStore((s) => s.getNodes());
48
+ const node = nodes.find((n) => n.id === id);
49
+ const groupId = (_a = nodeTypes == null ? void 0 : nodeTypes[type].meta) == null ? void 0 : _a.groupId;
50
+ const title = (_b = nodeTypes == null ? void 0 : nodeTypes[type].meta) == null ? void 0 : _b.label;
51
+ const groupLabel = groupId && nodeGroups && nodeGroups[groupId].label;
52
+ const inputs = (_d = (_c = nodeTypes == null ? void 0 : nodeTypes[type]) == null ? void 0 : _c.meta) == null ? void 0 : _d.inputs;
53
+ const outputs = (_f = (_e = nodeTypes == null ? void 0 : nodeTypes[type]) == null ? void 0 : _e.meta) == null ? void 0 : _f.outputs;
54
+ const icon = groupId && nodeGroups && nodeGroups[groupId].icon;
55
+ const colorProp = groupId && nodeGroups && nodeGroups[groupId].color;
56
+ const color = uikitStyles.getColor(colorProp);
57
+ React.useEffect(() => {
58
+ const newNodes = nodes.map((n) => {
59
+ if (n.id === id) {
60
+ if (Object.keys(n.data).length === 0) {
61
+ params == null ? void 0 : params.forEach((param) => {
62
+ n.data[param.label] = param.value;
63
+ });
64
+ }
65
+ }
66
+ return n;
67
+ });
68
+ reactFlowInstance.setNodes(newNodes);
69
+ }, []);
70
+ const handleDefaultAction = React.useCallback((action) => {
71
+ if (!node)
72
+ return;
73
+ switch (action) {
74
+ case "delete":
75
+ reactFlowInstance.deleteElements({
76
+ nodes: [node]
77
+ });
78
+ break;
79
+ case "duplicate":
80
+ reactFlowInstance.addNodes([{
81
+ ...node,
82
+ id: `${reactFlowInstance.getNodes().length + 1}`,
83
+ position: {
84
+ x: node.position.x,
85
+ y: node.position.y + (node.height || 0) + 20
86
+ },
87
+ selected: false,
88
+ zIndex: Number(uikitStyles.theme.zIndices.overlay)
89
+ }]);
90
+ break;
91
+ }
92
+ }, [node, reactFlowInstance]);
93
+ const hasParams = !!(params && params.length > 0);
94
+ if (!node)
95
+ return null;
96
+ const actsVisible = actions == null ? void 0 : actions.slice(0, maxVisibleActions);
97
+ const actsDropdown = actions == null ? void 0 : actions.slice(maxVisibleActions);
98
+ const renderedIcon = (actionIcon) => React.isValidElement(actionIcon) ? actionIcon : actionIcon == null ? void 0 : actionIcon();
99
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx(css({
100
+ border: `1px solid ${color}`
101
+ }), classes.root, className), onMouseEnter: () => setShowActions(true), onMouseLeave: () => setShowActions(false), children: [
102
+ /* @__PURE__ */ jsxRuntime.jsx(ReactFlow.NodeToolbar, { isVisible: showActions, offset: 0, children: defaultActions == null ? void 0 : defaultActions.map((action) => /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvButton, { icon: true, onClick: () => handleDefaultAction(action.id), children: renderedIcon(action.icon) })) }),
103
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx(css({
104
+ backgroundColor: color
105
+ }), classes.headerContainer), children: [
106
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes.groupContainer, children: [
107
+ icon,
108
+ /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { variant: "title4", className: classes.group, children: groupLabel })
109
+ ] }),
110
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
111
+ display: "flex"
112
+ }, children: [
113
+ /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTooltip, { title: /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { children: description }), children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Info, {}) }) }),
114
+ /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvButton, { icon: true, disabled: !hasParams, onClick: () => setShowParams((p) => !p), children: showParams ? /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Up, {}) : /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Down, {}) })
115
+ ] })
116
+ ] }),
117
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes.titleContainer, children: [
118
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { children: title }) }),
119
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.actions, children: (actions == null ? void 0 : actions.length) && (actions == null ? void 0 : actions.length) > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
120
+ actsVisible == null ? void 0 : actsVisible.map((action) => /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTooltip, { title: /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { children: action.label }), children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvButton, { icon: true, onClick: (event) => {
121
+ actionCallback == null ? void 0 : actionCallback(event, node.id, action);
122
+ }, children: renderedIcon(action.icon) }) }) })),
123
+ actsDropdown && actsDropdown.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvDropDownMenu, { keepOpened: false, dataList: actsDropdown == null ? void 0 : actsDropdown.map((action) => ({
124
+ id: action.id,
125
+ label: action.label
126
+ })), onClick: (event, action) => {
127
+ actionCallback == null ? void 0 : actionCallback(event, node.id, action);
128
+ } })
129
+ ] }) })
130
+ ] }),
131
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.inputsTitleContainer, children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { children: "Inputs" }) }),
132
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.inputsContainer, children: inputs == null ? void 0 : inputs.map((input, idx) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes.inputContainer, children: [
133
+ /* @__PURE__ */ jsxRuntime.jsx(ReactFlow.Handle, { type: "target", isConnectableStart: false, id: `${idx}`, position: ReactFlow.Position.Left, style: {
134
+ top: 160 + 29 * idx
135
+ } }),
136
+ /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { children: input.label }),
137
+ input.isMandatory && !isInputConnected(id, "target", idx, edges) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.mandatory })
138
+ ] }, idx)) }),
139
+ showParams && params && /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.paramsContainer, children: /* @__PURE__ */ jsxRuntime.jsx(ParamRenderer.default, { nodeId: id, params, data: node == null ? void 0 : node.data }) }),
140
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.outputsTitleContainer, children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { children: "Outputs" }) }),
141
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.outputsContainer, children: outputs == null ? void 0 : outputs.map((output, idx) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes.outputContainer, children: [
142
+ /* @__PURE__ */ jsxRuntime.jsx(ReactFlow.Handle, { type: "source", isConnectableEnd: false, id: `${idx}`, position: ReactFlow.Position.Right, style: {
143
+ bottom: -8 + 29 * (outputs.length - idx),
144
+ top: "auto"
145
+ } }),
146
+ output.isMandatory && !isInputConnected(id, "source", idx, edges) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.mandatory }),
147
+ /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { children: output.label })
148
+ ] }, idx)) })
149
+ ] });
150
+ };
151
+ exports.flowNodeClasses = Node_styles.staticClasses;
152
+ exports.HvFlowNode = HvFlowNode;
153
+ //# sourceMappingURL=Node.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Node.cjs","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 { HvFlowNodeInput, HvFlowNodeOutput, 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 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}: 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.label] = 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: string) => {\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 >\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 <div className={classes.inputsTitleContainer}>\n <HvTypography>Inputs</HvTypography>\n </div>\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: 160 + 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 {showParams && params && (\n <div className={classes.paramsContainer}>\n <ParamRenderer nodeId={id} params={params} data={node?.data} />\n </div>\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: -8 + 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 </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","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","jsxs","border","root","jsx","NodeToolbar","HvButton","backgroundColor","headerContainer","groupContainer","HvTypography","group","display","HvTooltip","Info","p","Up","Down","titleContainer","event","HvDropDownMenu","inputsTitleContainer","inputsContainer","input","inputContainer","Handle","Position","Left","top","isMandatory","mandatory","paramsContainer","ParamRenderer","outputsTitleContainer","outputsContainer","output","outputContainer","Right","bottom"],"mappings":";;;;;;;;;;;AAoDA,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,oB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MAAM,CAAA;AAAA,IAAA,KAfgB3C,GAgB9C,IAEJ;AAAA,EACF,EAAA,CAAA;AAEJ;;;"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const uikitReactCore = require("@hitachivantara/uikit-react-core");
4
+ const {
5
+ staticClasses,
6
+ useClasses
7
+ } = uikitReactCore.createClasses("HvFlowNode", {
8
+ root: {
9
+ borderRadius: uikitReactCore.theme.radii.round,
10
+ backgroundColor: uikitReactCore.theme.colors.atmo1,
11
+ boxShadow: uikitReactCore.theme.colors.shadow,
12
+ minWidth: "250px"
13
+ },
14
+ headerContainer: {
15
+ padding: uikitReactCore.theme.spacing(0.5, 1),
16
+ display: "flex",
17
+ flexDirection: "row",
18
+ justifyContent: "space-between",
19
+ alignItems: "center"
20
+ },
21
+ groupContainer: {
22
+ display: "flex",
23
+ flexDirection: "row",
24
+ alignItems: "center"
25
+ },
26
+ group: {
27
+ color: uikitReactCore.theme.colors.base_dark
28
+ },
29
+ titleContainer: {
30
+ padding: uikitReactCore.theme.spacing(uikitReactCore.theme.space.xs, uikitReactCore.theme.space.xs, uikitReactCore.theme.space.xs, uikitReactCore.theme.space.sm),
31
+ display: "flex",
32
+ flexDirection: "row",
33
+ justifyContent: "space-between",
34
+ alignItems: "center"
35
+ },
36
+ actions: {
37
+ display: "flex",
38
+ alignItems: "center"
39
+ },
40
+ inputsTitleContainer: {
41
+ display: "flex",
42
+ justifyContent: "center",
43
+ padding: uikitReactCore.theme.space.xs,
44
+ backgroundColor: uikitReactCore.theme.colors.atmo2,
45
+ borderTop: `1px solid ${uikitReactCore.theme.colors.atmo4}`,
46
+ borderBottom: `1px solid ${uikitReactCore.theme.colors.atmo4}`
47
+ },
48
+ outputsTitleContainer: {
49
+ display: "flex",
50
+ justifyContent: "center",
51
+ padding: uikitReactCore.theme.space.xs,
52
+ backgroundColor: uikitReactCore.theme.colors.atmo2,
53
+ borderTop: `1px solid ${uikitReactCore.theme.colors.atmo4}`,
54
+ borderBottom: `1px solid ${uikitReactCore.theme.colors.atmo4}`
55
+ },
56
+ inputsContainer: {
57
+ display: "flex",
58
+ flexDirection: "column",
59
+ padding: uikitReactCore.theme.space.sm,
60
+ gap: uikitReactCore.theme.space.xs,
61
+ alignItems: "flex-start"
62
+ },
63
+ outputsContainer: {
64
+ display: "flex",
65
+ flexDirection: "column",
66
+ padding: uikitReactCore.theme.space.sm,
67
+ gap: uikitReactCore.theme.space.xs,
68
+ alignItems: "flex-end"
69
+ },
70
+ paramsContainer: {
71
+ borderTop: `1px solid ${uikitReactCore.theme.colors.atmo4}`,
72
+ display: "flex",
73
+ flexDirection: "column",
74
+ gap: uikitReactCore.theme.space.xs,
75
+ padding: uikitReactCore.theme.space.sm
76
+ },
77
+ inputContainer: {
78
+ display: "flex",
79
+ flexDirection: "row",
80
+ alignItems: "center"
81
+ },
82
+ outputContainer: {
83
+ display: "flex",
84
+ flexDirection: "row",
85
+ alignItems: "center"
86
+ },
87
+ mandatory: {
88
+ width: 10,
89
+ height: 10,
90
+ margin: uikitReactCore.theme.spacing(0, uikitReactCore.theme.space.xs),
91
+ borderRadius: uikitReactCore.theme.radii.circle,
92
+ backgroundColor: uikitReactCore.theme.colors.negative_20
93
+ }
94
+ });
95
+ exports.staticClasses = staticClasses;
96
+ exports.useClasses = useClasses;
97
+ //# sourceMappingURL=Node.styles.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Node.styles.cjs","sources":["../../../../../src/components/Flow/Node/Node.styles.tsx"],"sourcesContent":["import { createClasses, theme } from \"@hitachivantara/uikit-react-core\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFlowNode\", {\n root: {\n borderRadius: theme.radii.round,\n backgroundColor: theme.colors.atmo1,\n boxShadow: theme.colors.shadow,\n minWidth: \"250px\",\n },\n headerContainer: {\n padding: theme.spacing(0.5, 1),\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n },\n groupContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n },\n group: {\n color: theme.colors.base_dark,\n },\n titleContainer: {\n padding: theme.spacing(\n theme.space.xs,\n theme.space.xs,\n theme.space.xs,\n theme.space.sm\n ),\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n },\n actions: {\n display: \"flex\",\n alignItems: \"center\",\n },\n inputsTitleContainer: {\n display: \"flex\",\n justifyContent: \"center\",\n padding: theme.space.xs,\n backgroundColor: theme.colors.atmo2,\n borderTop: `1px solid ${theme.colors.atmo4}`,\n borderBottom: `1px solid ${theme.colors.atmo4}`,\n },\n outputsTitleContainer: {\n display: \"flex\",\n justifyContent: \"center\",\n padding: theme.space.xs,\n backgroundColor: theme.colors.atmo2,\n borderTop: `1px solid ${theme.colors.atmo4}`,\n borderBottom: `1px solid ${theme.colors.atmo4}`,\n },\n inputsContainer: {\n display: \"flex\",\n flexDirection: \"column\",\n padding: theme.space.sm,\n gap: theme.space.xs,\n alignItems: \"flex-start\",\n },\n outputsContainer: {\n display: \"flex\",\n flexDirection: \"column\",\n padding: theme.space.sm,\n gap: theme.space.xs,\n alignItems: \"flex-end\",\n },\n paramsContainer: {\n borderTop: `1px solid ${theme.colors.atmo4}`,\n display: \"flex\",\n flexDirection: \"column\",\n gap: theme.space.xs,\n padding: theme.space.sm,\n },\n inputContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n },\n outputContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n },\n mandatory: {\n width: 10,\n height: 10,\n margin: theme.spacing(0, theme.space.xs),\n borderRadius: theme.radii.circle,\n backgroundColor: theme.colors.negative_20,\n },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","borderRadius","theme","radii","round","backgroundColor","colors","atmo1","boxShadow","shadow","minWidth","headerContainer","padding","spacing","display","flexDirection","justifyContent","alignItems","groupContainer","group","color","base_dark","titleContainer","space","xs","sm","actions","inputsTitleContainer","atmo2","borderTop","atmo4","borderBottom","outputsTitleContainer","inputsContainer","gap","outputsContainer","paramsContainer","inputContainer","outputContainer","mandatory","width","height","margin","circle","negative_20"],"mappings":";;;AAEa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,eAAAA,cAAc,cAAc;AAAA,EACvEC,MAAM;AAAA,IACJC,cAAcC,eAAAA,MAAMC,MAAMC;AAAAA,IAC1BC,iBAAiBH,eAAAA,MAAMI,OAAOC;AAAAA,IAC9BC,WAAWN,eAAAA,MAAMI,OAAOG;AAAAA,IACxBC,UAAU;AAAA,EACZ;AAAA,EACAC,iBAAiB;AAAA,IACfC,SAASV,eAAAA,MAAMW,QAAQ,KAAK,CAAC;AAAA,IAC7BC,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,gBAAgB;AAAA,IAChBC,YAAY;AAAA,EACd;AAAA,EACAC,gBAAgB;AAAA,IACdJ,SAAS;AAAA,IACTC,eAAe;AAAA,IACfE,YAAY;AAAA,EACd;AAAA,EACAE,OAAO;AAAA,IACLC,OAAOlB,eAAAA,MAAMI,OAAOe;AAAAA,EACtB;AAAA,EACAC,gBAAgB;AAAA,IACdV,SAASV,eAAAA,MAAMW,QACbX,eAAAA,MAAMqB,MAAMC,IACZtB,eAAAA,MAAMqB,MAAMC,IACZtB,eAAMqB,MAAAA,MAAMC,IACZtB,eAAAA,MAAMqB,MAAME,EACd;AAAA,IACAX,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,gBAAgB;AAAA,IAChBC,YAAY;AAAA,EACd;AAAA,EACAS,SAAS;AAAA,IACPZ,SAAS;AAAA,IACTG,YAAY;AAAA,EACd;AAAA,EACAU,sBAAsB;AAAA,IACpBb,SAAS;AAAA,IACTE,gBAAgB;AAAA,IAChBJ,SAASV,eAAAA,MAAMqB,MAAMC;AAAAA,IACrBnB,iBAAiBH,eAAAA,MAAMI,OAAOsB;AAAAA,IAC9BC,WAAY,aAAY3B,eAAM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MAAMqB,MAAMC,EAAE;AAAA,IACvCvB,cAAcC,eAAAA,MAAMC,MAAMwC;AAAAA,IAC1BtC,iBAAiBH,eAAAA,MAAMI,OAAOsC;AAAAA,EAChC;AACF,CAAC;;;"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const jsxRuntime = require("@emotion/react/jsx-runtime");
4
+ const Text = require("./Text.cjs");
5
+ const Select = require("./Select.cjs");
6
+ const renderers = {
7
+ text: Text.default,
8
+ select: Select.default
9
+ };
10
+ const ParamRenderer = ({
11
+ nodeId,
12
+ params,
13
+ data
14
+ }) => {
15
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: params.map((param, idx) => {
16
+ const Renderer = renderers[param.type];
17
+ if (Renderer) {
18
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
19
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: param.label }),
20
+ /* @__PURE__ */ jsxRuntime.jsx(Renderer, { nodeId, param, data })
21
+ ] }, idx);
22
+ }
23
+ return null;
24
+ }) });
25
+ };
26
+ const ParamRenderer$1 = ParamRenderer;
27
+ exports.default = ParamRenderer$1;
28
+ //# sourceMappingURL=ParamRenderer.cjs.map