@hitachivantara/uikit-react-lab 5.24.3 → 5.26.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 (44) hide show
  1. package/dist/cjs/Flow/DroppableFlow.cjs +2 -2
  2. package/dist/cjs/Flow/DroppableFlow.cjs.map +1 -1
  3. package/dist/cjs/Flow/Flow.styles.cjs +2 -18
  4. package/dist/cjs/Flow/Flow.styles.cjs.map +1 -1
  5. package/dist/cjs/Flow/Node/BaseNode.cjs +77 -47
  6. package/dist/cjs/Flow/Node/BaseNode.cjs.map +1 -1
  7. package/dist/cjs/Flow/Node/BaseNode.styles.cjs +39 -7
  8. package/dist/cjs/Flow/Node/BaseNode.styles.cjs.map +1 -1
  9. package/dist/cjs/Flow/Node/Node.cjs +1 -5
  10. package/dist/cjs/Flow/Node/Node.cjs.map +1 -1
  11. package/dist/cjs/Flow/Node/Node.styles.cjs +7 -1
  12. package/dist/cjs/Flow/Node/Node.styles.cjs.map +1 -1
  13. package/dist/cjs/Flow/Node/utils.cjs +55 -0
  14. package/dist/cjs/Flow/Node/utils.cjs.map +1 -0
  15. package/dist/cjs/Flow/hooks/useFlowNode.cjs.map +1 -1
  16. package/dist/cjs/Flow/nodes/DashboardNode.cjs +4 -13
  17. package/dist/cjs/Flow/nodes/DashboardNode.cjs.map +1 -1
  18. package/dist/cjs/Flow/nodes/DashboardNode.styles.cjs +17 -0
  19. package/dist/cjs/Flow/nodes/DashboardNode.styles.cjs.map +1 -0
  20. package/dist/cjs/index.cjs +2 -1
  21. package/dist/cjs/index.cjs.map +1 -1
  22. package/dist/esm/Flow/DroppableFlow.js +2 -2
  23. package/dist/esm/Flow/DroppableFlow.js.map +1 -1
  24. package/dist/esm/Flow/Flow.styles.js +2 -18
  25. package/dist/esm/Flow/Flow.styles.js.map +1 -1
  26. package/dist/esm/Flow/Node/BaseNode.js +76 -46
  27. package/dist/esm/Flow/Node/BaseNode.js.map +1 -1
  28. package/dist/esm/Flow/Node/BaseNode.styles.js +39 -7
  29. package/dist/esm/Flow/Node/BaseNode.styles.js.map +1 -1
  30. package/dist/esm/Flow/Node/Node.js +1 -5
  31. package/dist/esm/Flow/Node/Node.js.map +1 -1
  32. package/dist/esm/Flow/Node/Node.styles.js +7 -1
  33. package/dist/esm/Flow/Node/Node.styles.js.map +1 -1
  34. package/dist/esm/Flow/Node/utils.js +55 -0
  35. package/dist/esm/Flow/Node/utils.js.map +1 -0
  36. package/dist/esm/Flow/hooks/useFlowNode.js.map +1 -1
  37. package/dist/esm/Flow/nodes/DashboardNode.js +4 -12
  38. package/dist/esm/Flow/nodes/DashboardNode.js.map +1 -1
  39. package/dist/esm/Flow/nodes/DashboardNode.styles.js +17 -0
  40. package/dist/esm/Flow/nodes/DashboardNode.styles.js.map +1 -0
  41. package/dist/esm/index.js +15 -14
  42. package/dist/esm/index.js.map +1 -1
  43. package/dist/types/index.d.ts +108 -24
  44. package/package.json +4 -4
@@ -29,8 +29,8 @@ const validateEdge = (nodes, edges, edge, nodeMetaRegistry) => {
29
29
  return false;
30
30
  const inputs = nodeMetaRegistry[edge.target]?.inputs || [];
31
31
  const outputs = nodeMetaRegistry[edge.source]?.outputs || [];
32
- const source = outputs.find((out) => out.id === edge.sourceHandle);
33
- const target = inputs.find((inp) => inp.id === edge.targetHandle);
32
+ const source = outputs.map((out) => out.outputs || out).flat().find((out) => out.id === edge.sourceHandle);
33
+ const target = inputs.map((inp) => inp.inputs || inp).flat().find((inp) => inp.id === edge.targetHandle);
34
34
  const sourceProvides = source?.provides || "";
35
35
  const targetAccepts = target?.accepts || [];
36
36
  const sourceMaxConnections = source?.maxConnections;
@@ -1 +1 @@
1
- {"version":3,"file":"DroppableFlow.cjs","sources":["../../../src/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 { HvFlowNodeMetaRegistry } from \"./types\";\nimport { staticClasses, useClasses } from \"./Flow.styles\";\nimport { useFlowContext } from \"./hooks\";\nimport { flowStyles } from \"./base\";\nimport { useNodeMetaRegistry } from \"./FlowContext/NodeMetaContext\";\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 /** Callback called when the flow changes. Returns the updated nodes and edges. */\n onFlowChange?: (nodes: Node<NodeData, NodeType>[], edges: Edge[]) => void;\n /**\n * Callback called when a node is dropped in the flow.\n *\n * This callback should be used to override the custom UI Kit drop event.\n * Thus, when defined, the user is responsible for adding nodes to the flow.\n *\n * This callback is called when `HvFlowSidebar` is used or a custom sidebar was created using Dnd Kit.\n * When a custom sidebar was created using the native HTML drag and drop API, refer to the `onDrop` callback.\n *\n * Returns the event and the node to be added to the flow.\n */\n onDndDrop?: (event: DragEndEvent, node: Node) => 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 edges: Edge[],\n edge: Edge,\n nodeMetaRegistry: HvFlowNodeMetaRegistry\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 = nodeMetaRegistry[edge.target]?.inputs || [];\n const outputs = nodeMetaRegistry[edge.source]?.outputs || [];\n\n const source = outputs.find((out) => out.id === edge.sourceHandle);\n const target = inputs.find((inp) => inp.id === edge.targetHandle);\n\n const sourceProvides = source?.provides || \"\";\n const targetAccepts = target?.accepts || [];\n const sourceMaxConnections = source?.maxConnections;\n const targetMaxConnections = target?.maxConnections;\n\n let isValid =\n targetAccepts.length === 0 || targetAccepts.includes(sourceProvides);\n\n if (isValid && targetMaxConnections != null) {\n const targetConnections = edges.filter(\n (edg) =>\n edg.target === edge.target && edg.targetHandle === edge.targetHandle\n ).length;\n\n isValid = targetConnections < targetMaxConnections;\n }\n\n if (isValid && sourceMaxConnections != null) {\n const sourceConnections = edges.filter(\n (edg) =>\n edg.source === edge.source && edg.sourceHandle === edge.sourceHandle\n ).length;\n\n isValid = sourceConnections < sourceMaxConnections;\n }\n\n return isValid;\n};\n\nexport const HvDroppableFlow = ({\n id,\n className,\n children,\n onFlowChange,\n onDndDrop,\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?.id !== elementId) return;\n\n const hvFlow = event.active.data.current?.hvFlow;\n const type = hvFlow?.type;\n\n // Only known node types can be dropped in the canvas\n if (!type || !nodeTypes?.[type]) {\n if (import.meta.env.DEV) {\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 return;\n }\n\n // Position node in the flow\n const position = reactFlowInstance.screenToFlowPosition({\n x: hvFlow?.x || 0,\n y: hvFlow?.y || 0,\n });\n\n // Node data\n const data = hvFlow?.data || {};\n\n // Node to add\n const newNode: Node = {\n id: uid(),\n position,\n data,\n type,\n };\n\n // Drop override\n if (onDndDrop) {\n onDndDrop(event, newNode);\n return;\n }\n\n setNodes((nds) => nds.concat(newNode));\n },\n [elementId, nodeTypes, onDndDrop, 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 { registry } = useNodeMetaRegistry();\n const isValidConnection = (connection) =>\n validateEdge(nodes, edges, connection, registry);\n\n const defaultEdgeOptions = {\n markerEnd: {\n type: MarkerType.ArrowClosed,\n height: 20,\n width: 20,\n },\n type: \"smoothstep\",\n pathOptions: {\n borderRadius: 40,\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={edges}\n nodeTypes={nodeTypes}\n onNodesChange={handleNodesChange}\n onEdgesChange={handleEdgesChange}\n onConnect={handleConnect}\n isValidConnection={isValidConnection}\n defaultEdgeOptions={defaultEdgeOptions}\n snapGrid={[1, 1]}\n snapToGrid\n onError={(code, message) => {\n if (import.meta.env.DEV) {\n // eslint-disable-next-line no-console\n console.error(message);\n }\n }}\n {...others}\n >\n {children}\n </ReactFlow>\n </div>\n </>\n );\n};\n"],"names":["useClasses","useUniqueId","useReactFlow","useFlowContext","useState","useDroppable","useCallback","uid","useDndMonitor","addEdge","applyNodeChanges","applyEdgeChanges","useNodeMetaRegistry","MarkerType","jsxs","Fragment","jsx","Global","flowStyles","ReactFlow"],"mappings":";;;;;;;;;;;;;;;AA8Da,MAAA,UAAU,CAAC,OAAe,WAAmB;AACxD,SAAO,MAAM,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM;AAC1C;AAEA,MAAM,eAAe,CACnB,OACA,OACA,MACA,qBACG;AACH,MAAI,CAAC,KAAK,gBAAgB,CAAC,KAAK;AAAqB,WAAA;AAErD,QAAM,aAAa,QAAQ,OAAO,KAAK,MAAM;AAC7C,QAAM,aAAa,QAAQ,OAAO,KAAK,MAAM;AAEzC,MAAA,CAAC,cAAc,CAAC;AAAmB,WAAA;AAEvC,QAAM,aAAa,WAAW;AAC9B,QAAM,aAAa,WAAW;AAE1B,MAAA,CAAC,cAAc,CAAC;AAAmB,WAAA;AAEvC,QAAM,SAAS,iBAAiB,KAAK,MAAM,GAAG,UAAU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AAU,CAAC,GAAG,CAAC;AAAA,YACf,YAAU;AAAA,YACV,SAAS,CAAC,MAAM,YAAY;AAAA,YAK5B;AAAA,YACC,GAAG;AAAA,YAEH;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IACF;AAAA,EACF,EAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"DroppableFlow.cjs","sources":["../../../src/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 {\n HvFlowNodeInputGroup,\n HvFlowNodeMetaRegistry,\n HvFlowNodeOutputGroup,\n} from \"./types\";\nimport { staticClasses, useClasses } from \"./Flow.styles\";\nimport { useFlowContext } from \"./hooks\";\nimport { flowStyles } from \"./base\";\nimport { useNodeMetaRegistry } from \"./FlowContext/NodeMetaContext\";\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 /** Callback called when the flow changes. Returns the updated nodes and edges. */\n onFlowChange?: (nodes: Node<NodeData, NodeType>[], edges: Edge[]) => void;\n /**\n * Callback called when a node is dropped in the flow.\n *\n * This callback should be used to override the custom UI Kit drop event.\n * Thus, when defined, the user is responsible for adding nodes to the flow.\n *\n * This callback is called when `HvFlowSidebar` is used or a custom sidebar was created using Dnd Kit.\n * When a custom sidebar was created using the native HTML drag and drop API, refer to the `onDrop` callback.\n *\n * Returns the event and the node to be added to the flow.\n */\n onDndDrop?: (event: DragEndEvent, node: Node) => 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 edges: Edge[],\n edge: Edge,\n nodeMetaRegistry: HvFlowNodeMetaRegistry\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 = nodeMetaRegistry[edge.target]?.inputs || [];\n const outputs = nodeMetaRegistry[edge.source]?.outputs || [];\n\n const source = outputs\n .map((out) => (out as HvFlowNodeOutputGroup).outputs || out)\n .flat()\n .find((out) => out.id === edge.sourceHandle);\n const target = inputs\n .map((inp) => (inp as HvFlowNodeInputGroup).inputs || inp)\n .flat()\n .find((inp) => inp.id === edge.targetHandle);\n\n const sourceProvides = source?.provides || \"\";\n const targetAccepts = target?.accepts || [];\n const sourceMaxConnections = source?.maxConnections;\n const targetMaxConnections = target?.maxConnections;\n\n let isValid =\n targetAccepts.length === 0 || targetAccepts.includes(sourceProvides);\n\n if (isValid && targetMaxConnections != null) {\n const targetConnections = edges.filter(\n (edg) =>\n edg.target === edge.target && edg.targetHandle === edge.targetHandle\n ).length;\n\n isValid = targetConnections < targetMaxConnections;\n }\n\n if (isValid && sourceMaxConnections != null) {\n const sourceConnections = edges.filter(\n (edg) =>\n edg.source === edge.source && edg.sourceHandle === edge.sourceHandle\n ).length;\n\n isValid = sourceConnections < sourceMaxConnections;\n }\n\n return isValid;\n};\n\nexport const HvDroppableFlow = ({\n id,\n className,\n children,\n onFlowChange,\n onDndDrop,\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?.id !== elementId) return;\n\n const hvFlow = event.active.data.current?.hvFlow;\n const type = hvFlow?.type;\n\n // Only known node types can be dropped in the canvas\n if (!type || !nodeTypes?.[type]) {\n if (import.meta.env.DEV) {\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 return;\n }\n\n // Position node in the flow\n const position = reactFlowInstance.screenToFlowPosition({\n x: hvFlow?.x || 0,\n y: hvFlow?.y || 0,\n });\n\n // Node data\n const data = hvFlow?.data || {};\n\n // Node to add\n const newNode: Node = {\n id: uid(),\n position,\n data,\n type,\n };\n\n // Drop override\n if (onDndDrop) {\n onDndDrop(event, newNode);\n return;\n }\n\n setNodes((nds) => nds.concat(newNode));\n },\n [elementId, nodeTypes, onDndDrop, 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 { registry } = useNodeMetaRegistry();\n const isValidConnection = (connection) =>\n validateEdge(nodes, edges, connection, registry);\n\n const defaultEdgeOptions = {\n markerEnd: {\n type: MarkerType.ArrowClosed,\n height: 20,\n width: 20,\n },\n type: \"smoothstep\",\n pathOptions: {\n borderRadius: 40,\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={edges}\n nodeTypes={nodeTypes}\n onNodesChange={handleNodesChange}\n onEdgesChange={handleEdgesChange}\n onConnect={handleConnect}\n isValidConnection={isValidConnection}\n defaultEdgeOptions={defaultEdgeOptions}\n snapGrid={[1, 1]}\n snapToGrid\n onError={(code, message) => {\n if (import.meta.env.DEV) {\n // eslint-disable-next-line no-console\n console.error(message);\n }\n }}\n {...others}\n >\n {children}\n </ReactFlow>\n </div>\n </>\n );\n};\n"],"names":["useClasses","useUniqueId","useReactFlow","useFlowContext","useState","useDroppable","useCallback","uid","useDndMonitor","addEdge","applyNodeChanges","applyEdgeChanges","useNodeMetaRegistry","MarkerType","jsx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Y,QAAQ;AAEjD,QAAM,qBAAqB;AAAA,IACzB,WAAW;AAAA,MACT,MAAMC,UAAW,WAAA;AAAA,MACjB,QAAQ;AAAA,MACR,OAAO;AAAA,IACT;AAAA,IACA,MAAM;AAAA,IACN,aAAa;AAAA,MACX,cAAc;AAAA,IAChB;AAAA,IACA,GAAG;AAAA,EAAA;AAGL,SAEIC,2BAAA,KAAAC,qBAAA,EAAA,UAAA;AAAA,IAACC,2BAAAA,IAAAC,MAAA,QAAA,EAAO,QAAQC,KAAY,WAAA,CAAA;AAAA,IAC5BF,2BAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAI;AAAA,QACJ,KAAK;AAAA,QACL,WAAW,GAAG,QAAQ,MAAM,SAAS;AAAA,QAErC,UAAAA,2BAAA;AAAA,UAACG,mBAAA;AAAA,UAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA,eAAe;AAAA,YACf,eAAe;AAAA,YACf,WAAW;AAAA,YACX;AAAA,YACA;AAAA,YACA,UAAU,CAAC,GAAG,CAAC;AAAA,YACf,YAAU;AAAA,YACV,SAAS,CAAC,MAAM,YAAY;AAAA,YAK5B;AAAA,YACC,GAAG;AAAA,YAEH;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IACF;AAAA,EACF,EAAA,CAAA;AAEJ;;;;"}
@@ -11,27 +11,11 @@ require("@hitachivantara/uikit-styles");
11
11
  const { staticClasses, useClasses } = uikitReactCore.createClasses("HvFlow", {
12
12
  root: {
13
13
  height: "100%",
14
- "& .react-flow__handle": {
15
- backgroundColor: uikitReactCore.theme.colors.secondary_60,
16
- width: 8,
17
- height: 8,
18
- zIndex: uikitReactCore.theme.zIndices.overlay
19
- },
20
14
  "& .react-flow__handle-connecting": {
21
- backgroundColor: uikitReactCore.theme.colors.negative_20,
22
- width: 12,
23
- height: 12,
24
- "&.react-flow__handle-left": {
25
- translate: "0 4px"
26
- }
15
+ backgroundColor: uikitReactCore.theme.colors.negative_20
27
16
  },
28
17
  "& .react-flow__handle-valid": {
29
- backgroundColor: uikitReactCore.theme.colors.positive_20,
30
- width: 12,
31
- height: 12,
32
- "&.react-flow__handle-left": {
33
- translate: "0 4px"
34
- }
18
+ backgroundColor: uikitReactCore.theme.colors.positive_20
35
19
  },
36
20
  [`& .selected > .${BaseNode_styles.staticClasses.root}`]: {
37
21
  border: `1px solid ${uikitReactCore.theme.colors.secondary_60}`,
@@ -1 +1 @@
1
- {"version":3,"file":"Flow.styles.cjs","sources":["../../../src/Flow/Flow.styles.tsx"],"sourcesContent":["import { createClasses, theme } from \"@hitachivantara/uikit-react-core\";\n\nimport { flowBaseNodeClasses } 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-left\": {\n translate: \"0 4px\",\n },\n },\n \"& .react-flow__handle-valid\": {\n backgroundColor: theme.colors.positive_20,\n width: 12,\n height: 12,\n \"&.react-flow__handle-left\": {\n translate: \"0 4px\",\n },\n },\n [`& .selected > .${flowBaseNodeClasses.root}`]: {\n border: `1px solid ${theme.colors.secondary_60}`,\n borderRadius: theme.radii.round,\n boxSizing: \"border-box\",\n },\n },\n});\n"],"names":["createClasses","theme","flowBaseNodeClasses"],"mappings":";;;;;;;;;;AAIO,MAAM,EAAE,eAAe,eAAeA,eAAAA,cAAc,UAAU;AAAA,EACnE,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,yBAAyB;AAAA,MACvB,iBAAiBC,eAAAA,MAAM,OAAO;AAAA,MAC9B,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,QAAQA,eAAAA,MAAM,SAAS;AAAA,IACzB;AAAA,IACA,oCAAoC;AAAA,MAClC,iBAAiBA,eAAAA,MAAM,OAAO;AAAA,MAC9B,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,6BAA6B;AAAA,QAC3B,WAAW;AAAA,MACb;AAAA,IACF;AAAA,IACA,+BAA+B;AAAA,MAC7B,iBAAiBA,eAAAA,MAAM,OAAO;AAAA,MAC9B,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,6BAA6B;AAAA,QAC3B,WAAW;AAAA,MACb;AAAA,IACF;AAAA,IACA,CAAC,kBAAkBC,8BAAoB,IAAI,EAAE,GAAG;AAAA,MAC9C,QAAQ,aAAaD,eAAM,MAAA,OAAO,YAAY;AAAA,MAC9C,cAAcA,eAAAA,MAAM,MAAM;AAAA,MAC1B,WAAW;AAAA,IACb;AAAA,EACF;AACF,CAAC;;;"}
1
+ {"version":3,"file":"Flow.styles.cjs","sources":["../../../src/Flow/Flow.styles.tsx"],"sourcesContent":["import { createClasses, theme } from \"@hitachivantara/uikit-react-core\";\n\nimport { flowBaseNodeClasses } from \"./Node\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFlow\", {\n root: {\n height: \"100%\",\n \"& .react-flow__handle-connecting\": {\n backgroundColor: theme.colors.negative_20,\n },\n \"& .react-flow__handle-valid\": {\n backgroundColor: theme.colors.positive_20,\n },\n [`& .selected > .${flowBaseNodeClasses.root}`]: {\n border: `1px solid ${theme.colors.secondary_60}`,\n borderRadius: theme.radii.round,\n boxSizing: \"border-box\",\n },\n },\n});\n"],"names":["createClasses","theme","flowBaseNodeClasses"],"mappings":";;;;;;;;;;AAIO,MAAM,EAAE,eAAe,eAAeA,eAAAA,cAAc,UAAU;AAAA,EACnE,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,oCAAoC;AAAA,MAClC,iBAAiBC,eAAAA,MAAM,OAAO;AAAA,IAChC;AAAA,IACA,+BAA+B;AAAA,MAC7B,iBAAiBA,eAAAA,MAAM,OAAO;AAAA,IAChC;AAAA,IACA,CAAC,kBAAkBC,8BAAoB,IAAI,EAAE,GAAG;AAAA,MAC9C,QAAQ,aAAaD,eAAM,MAAA,OAAO,YAAY;AAAA,MAC9C,cAAcA,eAAAA,MAAM,MAAM;AAAA,MAC1B,WAAW;AAAA,IACb;AAAA,EACF;AACF,CAAC;;;"}
@@ -10,20 +10,11 @@ const uikitStyles = require("@hitachivantara/uikit-styles");
10
10
  const useFlowNode = require("../hooks/useFlowNode.cjs");
11
11
  const NodeMetaContext = require("../FlowContext/NodeMetaContext.cjs");
12
12
  const BaseNode_styles = require("./BaseNode.styles.cjs");
13
- const isInputConnected = (id, type, handleId, edges) => {
14
- if (type === "target") {
15
- return edges.some((e) => e.target === id && e.targetHandle === handleId);
16
- }
17
- if (type === "source") {
18
- return edges.some((e) => e.source === id && e.sourceHandle === handleId);
19
- }
20
- return false;
21
- };
13
+ const utils = require("./utils.cjs");
22
14
  const defaultActions = [
23
15
  { id: "delete", label: "Delete", icon: /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Delete, {}) },
24
16
  { id: "duplicate", label: "Duplicate", icon: /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Duplicate, {}) }
25
17
  ];
26
- const renderedIcon = (actionIcon) => React.isValidElement(actionIcon) ? actionIcon : actionIcon?.();
27
18
  const HvFlowBaseNode = ({
28
19
  id,
29
20
  title,
@@ -39,18 +30,8 @@ const HvFlowBaseNode = ({
39
30
  children
40
31
  }) => {
41
32
  const { registerNode, unregisterNode } = NodeMetaContext.useNodeMetaRegistry();
42
- const inputs = React.useMemo(
43
- () => inputsProp?.map(
44
- (input, idx) => input.id != null ? input : { ...input, id: String(idx) }
45
- ),
46
- [inputsProp]
47
- );
48
- const outputs = React.useMemo(
49
- () => outputsProp?.map(
50
- (output, idx) => output.id != null ? output : { ...output, id: String(idx) }
51
- ),
52
- [outputsProp]
53
- );
33
+ const inputs = React.useMemo(() => utils.identifyHandles(inputsProp), [inputsProp]);
34
+ const outputs = React.useMemo(() => utils.identifyHandles(outputsProp), [outputsProp]);
54
35
  React.useEffect(() => {
55
36
  registerNode(id, {
56
37
  label: title || "",
@@ -95,6 +76,46 @@ const HvFlowBaseNode = ({
95
76
  },
96
77
  [node, reactFlowInstance]
97
78
  );
79
+ const renderOutput = (output) => {
80
+ const edgeConnected = utils.isConnected(id, "source", output.id, outputEdges);
81
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes.outputContainer, children: [
82
+ /* @__PURE__ */ jsxRuntime.jsx(
83
+ ReactFlow.Handle,
84
+ {
85
+ type: "source",
86
+ isConnectableEnd: false,
87
+ id: output.id,
88
+ position: ReactFlow.Position.Right,
89
+ className: cx(
90
+ classes.handle,
91
+ edgeConnected && classes.handleConnected
92
+ )
93
+ }
94
+ ),
95
+ output.isMandatory && !edgeConnected && /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.mandatory }),
96
+ /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { component: "div", children: output.label })
97
+ ] }, output.id);
98
+ };
99
+ const renderInput = (input) => {
100
+ const edgeConnected = utils.isConnected(id, "target", input.id, inputEdges);
101
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes.inputContainer, children: [
102
+ /* @__PURE__ */ jsxRuntime.jsx(
103
+ ReactFlow.Handle,
104
+ {
105
+ type: "target",
106
+ isConnectableStart: false,
107
+ id: input.id,
108
+ position: ReactFlow.Position.Left,
109
+ className: cx(
110
+ classes.handle,
111
+ edgeConnected && classes.handleConnected
112
+ )
113
+ }
114
+ ),
115
+ /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { component: "div", children: input.label }),
116
+ input.isMandatory && !edgeConnected && /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.mandatory })
117
+ ] }, input.id);
118
+ };
98
119
  if (!node)
99
120
  return null;
100
121
  const color = uikitStyles.getColor(colorProp);
@@ -117,7 +138,7 @@ const HvFlowBaseNode = ({
117
138
  {
118
139
  icon: true,
119
140
  onClick: () => handleDefaultAction(action),
120
- children: renderedIcon(action.icon)
141
+ children: utils.renderedIcon(action.icon)
121
142
  },
122
143
  action.id
123
144
  )) }),
@@ -154,35 +175,44 @@ const HvFlowBaseNode = ({
154
175
  children && /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.contentContainer, children }),
155
176
  inputs && inputs.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
156
177
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.inputsTitleContainer, children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { children: "Inputs" }) }),
157
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.inputsContainer, children: inputs?.map((input) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes.inputContainer, children: [
158
- /* @__PURE__ */ jsxRuntime.jsx(
159
- ReactFlow.Handle,
178
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.inputsContainer, children: inputs?.map((input, idx) => {
179
+ if (!utils.isInputGroup(input))
180
+ return renderInput(input);
181
+ return /* @__PURE__ */ jsxRuntime.jsxs(
182
+ "div",
160
183
  {
161
- type: "target",
162
- isConnectableStart: false,
163
- id: input.id,
164
- position: ReactFlow.Position.Left
165
- }
166
- ),
167
- /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { children: input.label }),
168
- input.isMandatory && !isInputConnected(id, "target", input.id, inputEdges) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.mandatory })
169
- ] }, input.id)) })
184
+ className: classes.inputGroupContainer,
185
+ children: [
186
+ /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { component: "div", variant: "label", children: input.label }),
187
+ input.inputs.map(
188
+ (inp) => renderInput(inp)
189
+ )
190
+ ]
191
+ },
192
+ `group${idx}`
193
+ );
194
+ }) })
170
195
  ] }),
171
196
  outputs && outputs.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
172
197
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.outputsTitleContainer, children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { children: "Outputs" }) }),
173
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.outputsContainer, children: outputs?.map((output) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes.outputContainer, children: [
174
- /* @__PURE__ */ jsxRuntime.jsx(
175
- ReactFlow.Handle,
198
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.outputsContainer, children: outputs?.map((output, idx) => {
199
+ if (!utils.isOutputGroup(output)) {
200
+ return renderOutput(output);
201
+ }
202
+ return /* @__PURE__ */ jsxRuntime.jsxs(
203
+ "div",
176
204
  {
177
- type: "source",
178
- isConnectableEnd: false,
179
- id: output.id,
180
- position: ReactFlow.Position.Right
181
- }
182
- ),
183
- output.isMandatory && !isInputConnected(id, "source", output.id, outputEdges) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.mandatory }),
184
- /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { children: output.label })
185
- ] }, output.id)) })
205
+ className: classes.outputGroupContainer,
206
+ children: [
207
+ /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { component: "div", variant: "label", children: output.label }),
208
+ output.outputs.map((out) => {
209
+ return renderOutput(out);
210
+ })
211
+ ]
212
+ },
213
+ `group${idx}`
214
+ );
215
+ }) })
186
216
  ] }),
187
217
  footer && /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.footerContainer, children: footer })
188
218
  ]
@@ -1 +1 @@
1
- {"version":3,"file":"BaseNode.cjs","sources":["../../../../src/Flow/Node/BaseNode.tsx"],"sourcesContent":["import React, {\n isValidElement,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport {\n Edge,\n Handle,\n NodeProps,\n NodeToolbar,\n Position,\n useReactFlow,\n} from \"reactflow\";\nimport { uid } from \"uid\";\nimport {\n ExtractNames,\n HvActionGeneric,\n HvBaseProps,\n HvButton,\n HvTypography,\n} from \"@hitachivantara/uikit-react-core\";\nimport { Delete, Duplicate } from \"@hitachivantara/uikit-react-icons\";\nimport { HvColorAny, getColor, theme } from \"@hitachivantara/uikit-styles\";\n\nimport {\n HvFlowNodeAction,\n HvFlowBuiltInActions,\n HvFlowNodeInput,\n HvFlowNodeOutput,\n} from \"../types\";\nimport {\n useFlowNode,\n useFlowNodeInputEdges,\n useFlowNodeOutputEdges,\n} from \"../hooks/useFlowNode\";\nimport { useNodeMetaRegistry } from \"../FlowContext/NodeMetaContext\";\nimport { staticClasses, useClasses } from \"./BaseNode.styles\";\n\nexport { staticClasses as flowBaseNodeClasses };\n\nexport type HvFlowBaseNodeClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFlowBaseNodeProps<T = any>\n extends Omit<HvBaseProps, \"id\">,\n NodeProps<T> {\n /** Header title */\n title?: string;\n /** Header icon */\n icon?: React.ReactNode;\n /** Header color */\n color?: HvColorAny;\n /** Header items */\n headerItems?: React.ReactNode;\n /** Node inputs */\n inputs?: HvFlowNodeInput[];\n /** Node outputs */\n outputs?: HvFlowNodeOutput[];\n /** Node actions */\n nodeActions?: HvFlowNodeAction[];\n /** The content of the Node footer */\n footer?: React.ReactNode;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowBaseNodeClasses;\n}\n\nconst isInputConnected = (\n id: string,\n type: \"target\" | \"source\",\n handleId: string,\n edges: Edge[]\n) => {\n if (type === \"target\") {\n return edges.some((e) => e.target === id && e.targetHandle === handleId);\n }\n if (type === \"source\") {\n return edges.some((e) => e.source === id && e.sourceHandle === handleId);\n }\n\n return false;\n};\n\nconst defaultActions: HvFlowBuiltInActions[] = [\n { id: \"delete\", label: \"Delete\", icon: <Delete /> },\n { id: \"duplicate\", label: \"Duplicate\", icon: <Duplicate /> },\n];\n\nconst renderedIcon = (actionIcon: HvActionGeneric[\"icon\"]) =>\n isValidElement(actionIcon) ? actionIcon : (actionIcon as Function)?.();\n\nexport const HvFlowBaseNode = ({\n id,\n title,\n headerItems,\n icon,\n color: colorProp,\n inputs: inputsProp,\n outputs: outputsProp,\n nodeActions = defaultActions,\n footer,\n classes: classesProp,\n className,\n children,\n}: HvFlowBaseNodeProps<unknown>) => {\n const { registerNode, unregisterNode } = useNodeMetaRegistry();\n\n const inputs = useMemo(\n () =>\n inputsProp?.map((input, idx) =>\n input.id != null ? input : { ...input, id: String(idx) }\n ),\n [inputsProp]\n );\n\n const outputs = useMemo(\n () =>\n outputsProp?.map((output, idx) =>\n output.id != null ? output : { ...output, id: String(idx) }\n ),\n [outputsProp]\n );\n\n useEffect(() => {\n registerNode(id, {\n label: title || \"\",\n inputs,\n outputs,\n });\n return () => unregisterNode(id);\n }, [id, title, inputs, outputs, registerNode, unregisterNode]);\n\n const [showActions, setShowActions] = useState(false);\n const reactFlowInstance = useReactFlow();\n\n const { classes, cx, css } = useClasses(classesProp);\n\n const node = useFlowNode(id);\n const inputEdges = useFlowNodeInputEdges(id);\n const outputEdges = useFlowNodeOutputEdges(id);\n\n const handleDefaultAction = useCallback(\n (action: HvFlowNodeAction) => {\n if (!node) return;\n\n if (action.callback) {\n action.callback(node);\n return;\n }\n\n // built-in actions\n switch (action.id) {\n case \"delete\":\n reactFlowInstance.deleteElements({ nodes: [node] });\n break;\n case \"duplicate\":\n reactFlowInstance.addNodes([\n {\n ...node,\n id: uid(),\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 if (!node) return null;\n\n const color = getColor(colorProp);\n const iconColor = isValidElement(icon)\n ? getColor(icon.props.color || \"base_dark\")\n : getColor(\"base_dark\");\n\n return (\n <div\n className={cx(\n \"nowheel\", // Disables the default canvas pan behaviour when scrolling inside the node\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 {nodeActions?.map((action) => (\n <HvButton\n key={action.id}\n icon\n onClick={() => handleDefaultAction(action)}\n >\n {renderedIcon(action.icon)}\n </HvButton>\n ))}\n </NodeToolbar>\n <div\n className={cx(css({ backgroundColor: color }), classes.headerContainer)}\n >\n <div\n className={cx(\n classes.titleContainer,\n css({ \"& svg *.color0\": { fill: iconColor } })\n )}\n >\n {icon}\n <HvTypography\n component=\"p\"\n variant=\"title4\"\n className={classes.title}\n >\n {title}\n </HvTypography>\n </div>\n {headerItems && <div style={{ display: \"flex\" }}>{headerItems}</div>}\n </div>\n {children && <div className={classes.contentContainer}>{children}</div>}\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) => (\n <div className={classes.inputContainer} key={input.id}>\n <Handle\n type=\"target\"\n isConnectableStart={false}\n id={input.id}\n position={Position.Left}\n />\n <HvTypography>{input.label}</HvTypography>\n {input.isMandatory &&\n !isInputConnected(id, \"target\", input.id!, inputEdges) && (\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) => (\n <div className={classes.outputContainer} key={output.id}>\n <Handle\n type=\"source\"\n isConnectableEnd={false}\n id={output.id}\n position={Position.Right}\n />\n {output.isMandatory &&\n !isInputConnected(id, \"source\", output.id!, outputEdges) && (\n <div className={classes.mandatory} />\n )}\n <HvTypography>{output.label}</HvTypography>\n </div>\n ))}\n </div>\n </>\n )}\n {footer && <div className={classes.footerContainer}>{footer}</div>}\n </div>\n );\n};\n"],"names":["jsx","Delete","Duplicate","isValidElement","useNodeMetaRegistry","useMemo","useEffect","useState","useReactFlow","useClasses","useFlowNode","useFlowNodeInputEdges","useFlowNodeOutputEdges","useCallback","uid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IAAI,OAAO;AAAA,gBACX,UAAUC,UAAS,SAAA;AAAA,cAAA;AAAA,YACrB;AAAA,YACC,OAAO,eACN,CAAC,iBAAiB,IAAI,UAAU,OAAO,IAAK,WAAW,KACrDvB,2BAAA,IAAC,OAAI,EAAA,WAAW,QAAQ,WAAW;AAAA,YAEvCA,2BAAAA,IAACoB,eAAAA,cAAc,EAAA,UAAA,OAAO,MAAM,CAAA;AAAA,UAXgB,EAAA,GAAA,OAAO,EAYrD,CACD,GACH;AAAA,QAAA,GACF;AAAA,QAED,UAAWpB,2BAAAA,IAAA,OAAA,EAAI,WAAW,QAAQ,iBAAkB,UAAO,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGlE;;;"}
1
+ {"version":3,"file":"BaseNode.cjs","sources":["../../../../src/Flow/Node/BaseNode.tsx"],"sourcesContent":["import React, {\n isValidElement,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport {\n Handle,\n NodeProps,\n NodeToolbar,\n Position,\n useReactFlow,\n} from \"reactflow\";\nimport { uid } from \"uid\";\nimport {\n ExtractNames,\n HvBaseProps,\n HvButton,\n HvTypography,\n} from \"@hitachivantara/uikit-react-core\";\nimport { Delete, Duplicate } from \"@hitachivantara/uikit-react-icons\";\nimport { HvColorAny, getColor, theme } from \"@hitachivantara/uikit-styles\";\n\nimport {\n HvFlowNodeAction,\n HvFlowBuiltInActions,\n HvFlowNodeInput,\n HvFlowNodeOutput,\n HvFlowNodeOutputGroup,\n HvFlowNodeInputGroup,\n} from \"../types\";\nimport {\n useFlowNode,\n useFlowNodeInputEdges,\n useFlowNodeOutputEdges,\n} from \"../hooks/useFlowNode\";\nimport { useNodeMetaRegistry } from \"../FlowContext/NodeMetaContext\";\nimport { staticClasses, useClasses } from \"./BaseNode.styles\";\nimport {\n identifyHandles,\n isConnected,\n isInputGroup,\n isOutputGroup,\n renderedIcon,\n} from \"./utils\";\n\nexport { staticClasses as flowBaseNodeClasses };\n\nexport type HvFlowBaseNodeClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFlowBaseNodeProps<T = any>\n extends Omit<HvBaseProps, \"id\">,\n NodeProps<T> {\n /** Header title */\n title?: string;\n /** Header icon */\n icon?: React.ReactNode;\n /** Header color */\n color?: HvColorAny;\n /** Header items */\n headerItems?: React.ReactNode;\n /** Node inputs */\n inputs?: (HvFlowNodeInput | HvFlowNodeInputGroup)[];\n /** Node outputs */\n outputs?: (HvFlowNodeOutput | HvFlowNodeOutputGroup)[];\n /** Node actions */\n nodeActions?: HvFlowNodeAction[];\n /** The content of the Node footer */\n footer?: React.ReactNode;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowBaseNodeClasses;\n}\n\nconst defaultActions: HvFlowBuiltInActions[] = [\n { id: \"delete\", label: \"Delete\", icon: <Delete /> },\n { id: \"duplicate\", label: \"Duplicate\", icon: <Duplicate /> },\n];\n\nexport const HvFlowBaseNode = ({\n id,\n title,\n headerItems,\n icon,\n color: colorProp,\n inputs: inputsProp,\n outputs: outputsProp,\n nodeActions = defaultActions,\n footer,\n classes: classesProp,\n className,\n children,\n}: HvFlowBaseNodeProps<unknown>) => {\n const { registerNode, unregisterNode } = useNodeMetaRegistry();\n\n const inputs = useMemo(() => identifyHandles(inputsProp), [inputsProp]);\n\n const outputs = useMemo(() => identifyHandles(outputsProp), [outputsProp]);\n\n useEffect(() => {\n registerNode(id, {\n label: title || \"\",\n inputs,\n outputs,\n });\n return () => unregisterNode(id);\n }, [id, title, inputs, outputs, registerNode, unregisterNode]);\n\n const [showActions, setShowActions] = useState(false);\n const reactFlowInstance = useReactFlow();\n\n const { classes, cx, css } = useClasses(classesProp);\n\n const node = useFlowNode(id);\n const inputEdges = useFlowNodeInputEdges(id);\n const outputEdges = useFlowNodeOutputEdges(id);\n\n const handleDefaultAction = useCallback(\n (action: HvFlowNodeAction) => {\n if (!node) return;\n\n if (action.callback) {\n action.callback(node);\n return;\n }\n\n // built-in actions\n switch (action.id) {\n case \"delete\":\n reactFlowInstance.deleteElements({ nodes: [node] });\n break;\n case \"duplicate\":\n reactFlowInstance.addNodes([\n {\n ...node,\n id: uid(),\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 renderOutput = (output: HvFlowNodeOutput) => {\n const edgeConnected = isConnected(id, \"source\", output.id!, outputEdges);\n\n return (\n <div className={classes.outputContainer} key={output.id}>\n <Handle\n type=\"source\"\n isConnectableEnd={false}\n id={output.id}\n position={Position.Right}\n className={cx(\n classes.handle,\n edgeConnected && classes.handleConnected\n )}\n />\n {output.isMandatory && !edgeConnected && (\n <div className={classes.mandatory} />\n )}\n <HvTypography component=\"div\">{output.label}</HvTypography>\n </div>\n );\n };\n\n const renderInput = (input: HvFlowNodeInput) => {\n const edgeConnected = isConnected(id, \"target\", input.id!, inputEdges);\n\n return (\n <div className={classes.inputContainer} key={input.id}>\n <Handle\n type=\"target\"\n isConnectableStart={false}\n id={input.id}\n position={Position.Left}\n className={cx(\n classes.handle,\n edgeConnected && classes.handleConnected\n )}\n />\n <HvTypography component=\"div\">{input.label}</HvTypography>\n {input.isMandatory && !edgeConnected && (\n <div className={classes.mandatory} />\n )}\n </div>\n );\n };\n\n if (!node) return null;\n\n const color = getColor(colorProp);\n const iconColor = isValidElement(icon)\n ? getColor(icon.props.color || \"base_dark\")\n : getColor(\"base_dark\");\n\n return (\n <div\n className={cx(\n \"nowheel\", // Disables the default canvas pan behaviour when scrolling inside the node\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 {nodeActions?.map((action) => (\n <HvButton\n key={action.id}\n icon\n onClick={() => handleDefaultAction(action)}\n >\n {renderedIcon(action.icon)}\n </HvButton>\n ))}\n </NodeToolbar>\n <div\n className={cx(css({ backgroundColor: color }), classes.headerContainer)}\n >\n <div\n className={cx(\n classes.titleContainer,\n css({ \"& svg *.color0\": { fill: iconColor } })\n )}\n >\n {icon}\n <HvTypography\n component=\"p\"\n variant=\"title4\"\n className={classes.title}\n >\n {title}\n </HvTypography>\n </div>\n {headerItems && <div style={{ display: \"flex\" }}>{headerItems}</div>}\n </div>\n {children && <div className={classes.contentContainer}>{children}</div>}\n {inputs && inputs.length > 0 && (\n <>\n <div className={classes.inputsTitleContainer}>\n <HvTypography>Inputs</HvTypography>\n </div>\n <div className={classes.inputsContainer}>\n {inputs?.map((input, idx) => {\n if (!isInputGroup(input)) return renderInput(input);\n\n return (\n <div\n className={classes.inputGroupContainer}\n key={`group${idx}`}\n >\n <HvTypography component=\"div\" variant=\"label\">\n {input.label}\n </HvTypography>\n {(input as HvFlowNodeInputGroup).inputs.map((inp) =>\n renderInput(inp)\n )}\n </div>\n );\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 if (!isOutputGroup(output)) {\n return renderOutput(output);\n }\n\n return (\n <div\n className={classes.outputGroupContainer}\n key={`group${idx}`}\n >\n <HvTypography component=\"div\" variant=\"label\">\n {output.label}\n </HvTypography>\n {(output as HvFlowNodeOutputGroup).outputs.map((out) => {\n return renderOutput(out);\n })}\n </div>\n );\n })}\n </div>\n </>\n )}\n {footer && <div className={classes.footerContainer}>{footer}</div>}\n </div>\n );\n};\n"],"names":["jsx","Delete","Duplicate","useNodeMetaRegistry","useMemo","identifyHandles","useEffect","useState","useReactFlow","useClasses","useFlowNode","useFlowNodeInputEdges","useFlowNodeOutputEdges","useCallback","uid","theme","isConnected","jsxs","Handle","Position","HvTypography","getColor","isValidElement","NodeToolbar","HvButton","renderedIcon","Fragment","isInputGroup","isOutputGroup"],"mappings":";;;;;;;;;;;;;AA0E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A,YAAA;AAAA,UAUrB,CAAA,GACH;AAAA,QAAA,GACF;AAAA,QAED,WAAW,QAAQ,SAAS,KAEzBH,2BAAAA,KAAAS,WAAAA,UAAA,EAAA,UAAA;AAAA,UAAA1B,2BAAAA,IAAC,SAAI,WAAW,QAAQ,uBACtB,UAACA,2BAAA,IAAAoB,eAAA,cAAA,EAAa,qBAAO,EACvB,CAAA;AAAA,UACApB,2BAAAA,IAAC,SAAI,WAAW,QAAQ,kBACrB,UAAS,SAAA,IAAI,CAAC,QAAQ,QAAQ;AACzB,gBAAA,CAAC4B,MAAAA,cAAc,MAAM,GAAG;AAC1B,qBAAO,aAAa,MAAM;AAAA,YAC5B;AAGE,mBAAAX,2BAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,WAAW,QAAQ;AAAA,gBAGnB,UAAA;AAAA,kBAAAjB,+BAACoB,eAAAA,gBAAa,WAAU,OAAM,SAAQ,SACnC,iBAAO,OACV;AAAA,kBACE,OAAiC,QAAQ,IAAI,CAAC,QAAQ;AACtD,2BAAO,aAAa,GAAG;AAAA,kBAAA,CACxB;AAAA,gBAAA;AAAA,cAAA;AAAA,cAPI,QAAQ,GAAG;AAAA,YAAA;AAAA,UAUrB,CAAA,GACH;AAAA,QAAA,GACF;AAAA,QAED,UAAWpB,2BAAAA,IAAA,OAAA,EAAI,WAAW,QAAQ,iBAAkB,UAAO,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGlE;;;"}
@@ -56,24 +56,56 @@ const { staticClasses, useClasses } = uikitReactCore.createClasses("HvFlowBaseNo
56
56
  gap: uikitReactCore.theme.space.xs,
57
57
  alignItems: "flex-end"
58
58
  },
59
+ inputGroupContainer: {
60
+ display: "flex",
61
+ flexDirection: "column",
62
+ gap: uikitReactCore.theme.space.xs,
63
+ alignItems: "flex-start"
64
+ },
65
+ outputGroupContainer: {
66
+ display: "flex",
67
+ flexDirection: "column",
68
+ gap: uikitReactCore.theme.space.xs,
69
+ alignItems: "flex-end"
70
+ },
59
71
  inputContainer: {
60
72
  display: "flex",
61
73
  flexDirection: "row",
62
74
  alignItems: "center",
63
- position: "relative",
64
- "& .react-flow__handle-left": {
65
- left: -20
66
- }
75
+ position: "relative"
67
76
  },
68
77
  outputContainer: {
69
78
  display: "flex",
70
79
  flexDirection: "row",
71
80
  alignItems: "center",
72
- position: "relative",
73
- "& .react-flow__handle-right": {
74
- right: -20
81
+ position: "relative"
82
+ },
83
+ handle: {
84
+ zIndex: uikitReactCore.theme.zIndices.overlay,
85
+ marginLeft: 2,
86
+ backgroundColor: uikitReactCore.theme.colors.atmo1,
87
+ height: 10,
88
+ width: 10,
89
+ border: `1px solid ${uikitReactCore.theme.colors.secondary_60}`,
90
+ "&.react-flow__handle-left": {
91
+ left: -23
92
+ },
93
+ "&.react-flow__handle-right": {
94
+ right: -21
95
+ },
96
+ "::before": {
97
+ fontSize: 14,
98
+ color: uikitReactCore.theme.colors.secondary_60,
99
+ content: '"+"',
100
+ marginTop: -7,
101
+ position: "absolute"
75
102
  }
76
103
  },
104
+ handleConnected: {
105
+ backgroundColor: uikitReactCore.theme.colors.secondary_60,
106
+ width: 8,
107
+ height: 8
108
+ },
77
109
  mandatory: {
78
110
  width: 10,
79
111
  height: 10,
@@ -1 +1 @@
1
- {"version":3,"file":"BaseNode.styles.cjs","sources":["../../../../src/Flow/Node/BaseNode.styles.tsx"],"sourcesContent":["import { createClasses, theme } from \"@hitachivantara/uikit-react-core\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFlowBaseNode\", {\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 borderTopLeftRadius: \"inherit\",\n borderTopRightRadius: \"inherit\",\n },\n titleContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n },\n title: {\n color: theme.colors.base_dark,\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.atmo3}`,\n borderBottom: `1px solid ${theme.colors.atmo3}`,\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.atmo3}`,\n borderBottom: `1px solid ${theme.colors.atmo3}`,\n },\n contentContainer: {},\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 inputContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n position: \"relative\",\n \"& .react-flow__handle-left\": {\n left: -20,\n },\n },\n outputContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n position: \"relative\",\n \"& .react-flow__handle-right\": {\n right: -20,\n },\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 footerContainer: {\n padding: theme.space.sm,\n borderTop: `1px solid ${theme.colors.atmo3}`,\n },\n});\n"],"names":["createClasses","theme"],"mappings":";;;AAEO,MAAM,EAAE,eAAe,eAAeA,eAAAA,cAAc,kBAAkB;AAAA,EAC3E,MAAM;AAAA,IACJ,cAAcC,eAAAA,MAAM,MAAM;AAAA,IAC1B,iBAAiBA,eAAAA,MAAM,OAAO;AAAA,IAC9B,WAAWA,eAAAA,MAAM,OAAO;AAAA,IACxB,UAAU;AAAA,EACZ;AAAA,EACA,iBAAiB;AAAA,IACf,SAASA,eAAA,MAAM,QAAQ,KAAK,CAAC;AA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AM;AAAA,IACR;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,SAAS;AAAA,IACT,eAAe;AAAA,IACf,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,+BAA+B;AAAA,MAC7B,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,WAAW;AAAA,IACT,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQA,eAAM,MAAA,QAAQ,GAAGA,eAAA,MAAM,MAAM,EAAE;AAAA,IACvC,cAAcA,eAAAA,MAAM,MAAM;AAAA,IAC1B,iBAAiBA,eAAAA,MAAM,OAAO;AAAA,EAChC;AAAA,EACA,iBAAiB;AAAA,IACf,SAASA,eAAAA,MAAM,MAAM;AAAA,IACrB,WAAW,aAAaA,eAAM,MAAA,OAAO,KAAK;AAAA,EAC5C;AACF,CAAC;;;"}
1
+ {"version":3,"file":"BaseNode.styles.cjs","sources":["../../../../src/Flow/Node/BaseNode.styles.tsx"],"sourcesContent":["import { createClasses, theme } from \"@hitachivantara/uikit-react-core\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFlowBaseNode\", {\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 borderTopLeftRadius: \"inherit\",\n borderTopRightRadius: \"inherit\",\n },\n titleContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n },\n title: {\n color: theme.colors.base_dark,\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.atmo3}`,\n borderBottom: `1px solid ${theme.colors.atmo3}`,\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.atmo3}`,\n borderBottom: `1px solid ${theme.colors.atmo3}`,\n },\n contentContainer: {},\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 inputGroupContainer: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: theme.space.xs,\n alignItems: \"flex-start\",\n },\n outputGroupContainer: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: theme.space.xs,\n alignItems: \"flex-end\",\n },\n inputContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n position: \"relative\",\n },\n outputContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n position: \"relative\",\n },\n handle: {\n zIndex: theme.zIndices.overlay,\n marginLeft: 2,\n backgroundColor: theme.colors.atmo1,\n height: 10,\n width: 10,\n border: `1px solid ${theme.colors.secondary_60}`,\n \"&.react-flow__handle-left\": {\n left: -23,\n },\n \"&.react-flow__handle-right\": {\n right: -21,\n },\n \"::before\": {\n fontSize: 14,\n color: theme.colors.secondary_60,\n content: '\"+\"',\n marginTop: -7,\n position: \"absolute\",\n },\n },\n handleConnected: {\n backgroundColor: theme.colors.secondary_60,\n width: 8,\n height: 8,\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 footerContainer: {\n padding: theme.space.sm,\n borderTop: `1px solid ${theme.colors.atmo3}`,\n },\n});\n"],"names":["createClasses","theme"],"mappings":";;;AAEO,MAAM,EAAE,eAAe,eAAeA,eAAAA,cAAc,kBAAkB;AAAA,EAC3E,MAAM;AAAA,IACJ,cAAcC,eAAAA,MAAM,MAAM;AAAA,IAC1B,iBAAiBA,eAA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A,EAChC;AAAA,EACA,iBAAiB;AAAA,IACf,SAASA,eAAAA,MAAM,MAAM;AAAA,IACrB,WAAW,aAAaA,eAAM,MAAA,OAAO,KAAK;AAAA,EAC5C;AACF,CAAC;;;"}
@@ -16,8 +16,6 @@ const HvFlowNode = ({
16
16
  headerItems,
17
17
  description,
18
18
  actions,
19
- outputs,
20
- inputs,
21
19
  actionCallback,
22
20
  maxVisibleActions = 1,
23
21
  expanded = false,
@@ -49,10 +47,8 @@ const HvFlowNode = ({
49
47
  title: groupLabel,
50
48
  icon,
51
49
  color,
52
- inputs,
53
- outputs,
54
50
  nodeActions: defaultActions,
55
- classes: classesProp,
51
+ classes,
56
52
  headerItems: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
57
53
  headerItems,
58
54
  description && /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTooltip, { title: description, children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Info, { color: "base_dark" }) }) }),
@@ -1 +1 @@
1
- {"version":3,"file":"Node.cjs","sources":["../../../../src/Flow/Node/Node.tsx"],"sourcesContent":["import React, { isValidElement, useState } from \"react\";\n\nimport {\n ExtractNames,\n HvActionGeneric,\n HvActionsGenericProps,\n HvButton,\n HvButtonProps,\n HvDropDownMenu,\n HvTooltip,\n HvTypography,\n} from \"@hitachivantara/uikit-react-core\";\nimport { Down, Info, Up } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useFlowContext, useFlowNode } from \"../hooks\";\nimport { HvFlowNodeInput, HvFlowNodeOutput, HvFlowNodeParam } from \"../types\";\nimport { staticClasses, useClasses } from \"./Node.styles\";\nimport ParamRenderer from \"./Parameters/ParamRenderer\";\nimport {\n HvFlowBaseNode,\n HvFlowBaseNodeProps,\n HvFlowBaseNodeClasses,\n} from \"./BaseNode\";\n\nexport { staticClasses as flowNodeClasses };\n\nexport interface HvFlowNodeClasses\n extends ExtractNames<typeof useClasses>,\n HvFlowBaseNodeClasses {}\n\nexport type HvFlowNodeDefaults = {\n title?: string;\n subTitle?: string;\n color?: string;\n icon?: React.ReactNode;\n};\n\nexport interface HvFlowNodeProps<T = any> extends HvFlowBaseNodeProps<T> {\n /** Node description */\n description?: string;\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 /** Node expanded */\n expanded?: boolean;\n /** Node parameters */\n params?: HvFlowNodeParam[];\n /** A set of node default values for when there are no groups to fetch this data from. */\n nodeDefaults?: HvFlowNodeDefaults;\n /** Props to be passed to the expand parameters button. */\n expandParamsButtonProps?: HvButtonProps;\n /** Node outputs. */\n outputs?: HvFlowNodeOutput[];\n /** Node inputs. */\n inputs?: HvFlowNodeInput[];\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowNodeClasses;\n}\n\nconst renderedIcon = (actionIcon: HvActionGeneric[\"icon\"]) =>\n isValidElement(actionIcon) ? actionIcon : (actionIcon as Function)?.();\n\nexport const HvFlowNode = ({\n id,\n type,\n headerItems,\n description,\n actions,\n outputs,\n inputs,\n actionCallback,\n maxVisibleActions = 1,\n expanded = false,\n params,\n nodeDefaults,\n classes: classesProp,\n children,\n expandParamsButtonProps,\n ...props\n}: HvFlowNodeProps<unknown>) => {\n const { classes } = useClasses(classesProp as HvFlowNodeClasses);\n\n const [showParams, setShowParams] = useState(expanded);\n\n const node = useFlowNode(id);\n\n const { nodeGroups, nodeTypes, defaultActions } = useFlowContext();\n\n const subtitle = nodeTypes?.[type].meta?.label || nodeDefaults?.subTitle;\n const groupId = nodeTypes?.[type].meta?.groupId;\n\n const group = (groupId && nodeGroups && nodeGroups[groupId]) || undefined;\n const groupLabel = group?.label || nodeDefaults?.title;\n const icon = group?.icon || nodeDefaults?.icon;\n const color = group?.color || nodeDefaults?.color;\n\n const actsVisible = actions?.slice(0, maxVisibleActions);\n const actsDropdown = actions?.slice(maxVisibleActions);\n\n const hasParams = !!(params && params.length > 0);\n\n return (\n <HvFlowBaseNode\n id={id}\n type={type}\n title={groupLabel}\n icon={icon}\n color={color}\n inputs={inputs}\n outputs={outputs}\n nodeActions={defaultActions}\n classes={classesProp as HvFlowBaseNodeClasses}\n headerItems={\n <>\n {headerItems}\n {description && (\n <HvTooltip title={description}>\n <div>\n <Info color=\"base_dark\" />\n </div>\n </HvTooltip>\n )}\n {hasParams && (\n <HvButton\n icon\n overrideIconColors={false}\n onClick={() => setShowParams((p) => !p)}\n aria-label={showParams ? \"Collapse\" : \"Expand\"}\n {...expandParamsButtonProps}\n >\n {showParams ? (\n <Up role=\"none\" color=\"base_dark\" />\n ) : (\n <Down role=\"none\" color=\"base_dark\" />\n )}\n </HvButton>\n )}\n </>\n }\n {...props}\n >\n {(subtitle || actsVisible?.length || actsDropdown?.length) && (\n <div className={classes.subtitleContainer}>\n {subtitle && (\n <div>\n <HvTypography>{subtitle}</HvTypography>\n </div>\n )}\n <div className={classes.actions}>\n {actions?.length && actions?.length > 0 && (\n <>\n {actsVisible?.map((action) => (\n <HvTooltip key={action.id} title={action.label}>\n <HvButton\n icon\n onClick={(event) => {\n actionCallback?.(event, id, action);\n }}\n aria-label={action.label}\n >\n {renderedIcon(action.icon)}\n </HvButton>\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, id, action as HvActionGeneric);\n }}\n />\n )}\n </>\n )}\n </div>\n </div>\n )}\n {children}\n {showParams && params && (\n <div className={classes.paramsContainer}>\n <ParamRenderer params={params} data={node?.data} />\n </div>\n )}\n </HvFlowBaseNode>\n );\n};\n"],"names":["isValidElement","useClasses","useState","useFlowNode","useFlowContext","jsxs","HvFlowBaseNode","Fragment","jsx","HvTooltip","Info","HvButton","Up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,YAAY;AAAA,gBACZ,UAAU,cAAc,IAAI,CAAC,YAAY;AAAA,kBACvC,IAAI,OAAO;AAAA,kBACX,OAAO,OAAO;AAAA,gBAAA,EACd;AAAA,gBACF,SAAS,CAAC,OAAO,WAAW;AACT,mCAAA,OAAO,IAAI,MAAyB;AAAA,gBACvD;AAAA,cAAA;AAAA,YACF;AAAA,UAAA,EAAA,CAEJ,EAEJ,CAAA;AAAA,QAAA,GACF;AAAA,QAED;AAAA,QACA,cAAc,UACZP,+BAAA,OAAA,EAAI,WAAW,QAAQ,iBACtB,UAAAA,2BAAAA,IAACQ,cAAAA,SAAc,EAAA,QAAgB,MAAM,MAAM,KAAM,CAAA,GACnD;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;;;"}
1
+ {"version":3,"file":"Node.cjs","sources":["../../../../src/Flow/Node/Node.tsx"],"sourcesContent":["import React, { isValidElement, useState } from \"react\";\nimport {\n ExtractNames,\n HvActionGeneric,\n HvActionsGenericProps,\n HvButton,\n HvButtonProps,\n HvDropDownMenu,\n HvTooltip,\n HvTypography,\n} from \"@hitachivantara/uikit-react-core\";\nimport { Down, Info, Up } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useFlowContext, useFlowNode } from \"../hooks\";\nimport { HvFlowNodeParam } from \"../types\";\nimport { staticClasses, useClasses } from \"./Node.styles\";\nimport ParamRenderer from \"./Parameters/ParamRenderer\";\nimport { HvFlowBaseNode, HvFlowBaseNodeProps } from \"./BaseNode\";\n\nexport { staticClasses as flowNodeClasses };\n\nexport type HvFlowNodeClasses = ExtractNames<typeof useClasses>;\n\nexport type HvFlowNodeDefaults = {\n title?: string;\n subTitle?: string;\n color?: string;\n icon?: React.ReactNode;\n};\n\nexport interface HvFlowNodeProps<T = any> extends HvFlowBaseNodeProps<T> {\n /** Node description */\n description?: string;\n /** Node actions */\n actions?: HvActionGeneric[];\n /** Node action callback */\n actionCallback?: HvActionsGenericProps[\"actionsCallback\"];\n /** Node maximum number of actions visible */\n maxVisibleActions?: number;\n /** Node expanded */\n expanded?: boolean;\n /** Node parameters */\n params?: HvFlowNodeParam[];\n /** A set of node default values for when there are no groups to fetch this data from. */\n nodeDefaults?: HvFlowNodeDefaults;\n /** Props to be passed to the expand parameters button. */\n expandParamsButtonProps?: HvButtonProps;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowNodeClasses;\n}\n\nconst renderedIcon = (actionIcon: HvActionGeneric[\"icon\"]) =>\n isValidElement(actionIcon) ? actionIcon : (actionIcon as Function)?.();\n\nexport const HvFlowNode = ({\n id,\n type,\n headerItems,\n description,\n actions,\n actionCallback,\n maxVisibleActions = 1,\n expanded = false,\n params,\n nodeDefaults,\n classes: classesProp,\n children,\n expandParamsButtonProps,\n ...props\n}: HvFlowNodeProps<unknown>) => {\n const { classes } = useClasses(classesProp);\n\n const [showParams, setShowParams] = useState(expanded);\n\n const node = useFlowNode(id);\n\n const { nodeGroups, nodeTypes, defaultActions } = useFlowContext();\n\n const subtitle = nodeTypes?.[type].meta?.label || nodeDefaults?.subTitle;\n const groupId = nodeTypes?.[type].meta?.groupId;\n\n const group = (groupId && nodeGroups && nodeGroups[groupId]) || undefined;\n const groupLabel = group?.label || nodeDefaults?.title;\n const icon = group?.icon || nodeDefaults?.icon;\n const color = group?.color || nodeDefaults?.color;\n\n const actsVisible = actions?.slice(0, maxVisibleActions);\n const actsDropdown = actions?.slice(maxVisibleActions);\n\n const hasParams = !!(params && params.length > 0);\n\n return (\n <HvFlowBaseNode\n id={id}\n type={type}\n title={groupLabel}\n icon={icon}\n color={color}\n nodeActions={defaultActions}\n classes={classes}\n headerItems={\n <>\n {headerItems}\n {description && (\n <HvTooltip title={description}>\n <div>\n <Info color=\"base_dark\" />\n </div>\n </HvTooltip>\n )}\n {hasParams && (\n <HvButton\n icon\n overrideIconColors={false}\n onClick={() => setShowParams((p) => !p)}\n aria-label={showParams ? \"Collapse\" : \"Expand\"}\n {...expandParamsButtonProps}\n >\n {showParams ? (\n <Up role=\"none\" color=\"base_dark\" />\n ) : (\n <Down role=\"none\" color=\"base_dark\" />\n )}\n </HvButton>\n )}\n </>\n }\n {...props}\n >\n {(subtitle || actsVisible?.length || actsDropdown?.length) && (\n <div className={classes.subtitleContainer}>\n {subtitle && (\n <div>\n <HvTypography>{subtitle}</HvTypography>\n </div>\n )}\n <div className={classes.actions}>\n {actions?.length && actions?.length > 0 && (\n <>\n {actsVisible?.map((action) => (\n <HvTooltip key={action.id} title={action.label}>\n <HvButton\n icon\n onClick={(event) => {\n actionCallback?.(event, id, action);\n }}\n aria-label={action.label}\n >\n {renderedIcon(action.icon)}\n </HvButton>\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, id, action as HvActionGeneric);\n }}\n />\n )}\n </>\n )}\n </div>\n </div>\n )}\n {children}\n {showParams && params && (\n <div className={classes.paramsContainer}>\n <ParamRenderer params={params} data={node?.data} />\n </div>\n )}\n </HvFlowBaseNode>\n );\n};\n"],"names":["isValidElement","useClasses","useState","useFlowNode","useFlowContext","jsxs","HvFlowBaseNode","Fragment","jsx","HvTooltip","Info","HvButton","Up","Down","HvTypography","HvDropDownMenu","ParamRenderer"],"mappings":";;;;;;;;;;;AAmDA,MAAM,eAAe,CAAC,eACpBA,qBAAe,UAAU,IAAI,aAAc;AAEtC,MAAM,aAAa,CAAC;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,oBAAoB;AAAA,EACpB,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAgC;AAC9B,QAAM,EAAE,QAAA,IAAYC,YAAA,WAAW,WAAW;AAE1C,QAAM,CAAC,YAAY,aAAa,IAAIC,eAAS,QAAQ;AA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6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const uikitReactCore = require("@hitachivantara/uikit-react-core");
4
+ const BaseNode_styles = require("./BaseNode.styles.cjs");
5
+ const baseClasses = Object.fromEntries(
6
+ Object.keys(BaseNode_styles.staticClasses).map((key) => [key, {}])
7
+ );
4
8
  const { staticClasses, useClasses } = uikitReactCore.createClasses("HvFlowNode", {
5
9
  subtitleContainer: {
6
10
  minHeight: 48,
@@ -25,7 +29,9 @@ const { staticClasses, useClasses } = uikitReactCore.createClasses("HvFlowNode",
25
29
  flexDirection: "column",
26
30
  gap: uikitReactCore.theme.space.xs,
27
31
  padding: uikitReactCore.theme.space.sm
28
- }
32
+ },
33
+ // Spread here to know if we are overriding classes from parents
34
+ ...baseClasses
29
35
  });
30
36
  exports.staticClasses = staticClasses;
31
37
  exports.useClasses = useClasses;
@@ -1 +1 @@
1
- {"version":3,"file":"Node.styles.cjs","sources":["../../../../src/Flow/Node/Node.styles.tsx"],"sourcesContent":["import { createClasses, theme } from \"@hitachivantara/uikit-react-core\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFlowNode\", {\n subtitleContainer: {\n minHeight: 48,\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 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});\n"],"names":["createClasses","theme"],"mappings":";;;AAEO,MAAM,EAAE,eAAe,eAAeA,eAAAA,cAAc,cAAc;AAAA,EACvE,mBAAmB;AAAA,IACjB,WAAW;AAAA,IACX,SAASC,eAAM,MAAA;AAAA,MACbA,qBAAM,MAAM;AAAA,MACZA,qBAAM,MAAM;AAAA,MACZA,qBAAM,MAAM;AAAA,MACZA,qBAAM,MAAM;AAAA,IACd;AAAA,IACA,SAAS;AAAA,IACT,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,YAAY;AAAA,EACd;AAAA,EACA,SAAS;AAAA,IACP,SAAS;AAAA,IACT,YAAY;AAAA,EACd;AAAA,EACA,iBAAiB;AAAA,IACf,WAAW,aAAaA,eAAM,MAAA,OAAO,KAAK;AAAA,IAC1C,SAAS;AAAA,IACT,eAAe;AAAA,IACf,KAAKA,eAAAA,MAAM,MAAM;AAAA,IACjB,SAASA,eAAAA,MAAM,MAAM;AAAA,EACvB;AACF,CAAC;;;"}
1
+ {"version":3,"file":"Node.styles.cjs","sources":["../../../../src/Flow/Node/Node.styles.tsx"],"sourcesContent":["import { createClasses, theme } from \"@hitachivantara/uikit-react-core\";\n\nimport { staticClasses as baseNodeClasses } from \"./BaseNode.styles\";\n\nconst baseClasses = Object.fromEntries(\n Object.keys(baseNodeClasses).map((key) => [key, {}])\n) as Record<keyof typeof baseNodeClasses, {}>;\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFlowNode\", {\n subtitleContainer: {\n minHeight: 48,\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 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 // Spread here to know if we are overriding classes from parents\n ...baseClasses,\n});\n"],"names":["baseNodeClasses","createClasses","theme"],"mappings":";;;;AAIA,MAAM,cAAc,OAAO;AAAA,EACzB,OAAO,KAAKA,gBAAAA,aAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAA,CAAE,CAAC;AACrD;AAEO,MAAM,EAAE,eAAe,eAAeC,eAAAA,cAAc,cAAc;AAAA,EACvE,mBAAmB;AAAA,IACjB,WAAW;AAAA,IACX,SAASC,eAAM,MAAA;AAAA,MACbA,qBAAM,MAAM;AAAA,MACZA,qBAAM,MAAM;AAAA,MACZA,qBAAM,MAAM;AAAA,MACZA,qBAAM,MAAM;AAAA,IACd;AAAA,IACA,SAAS;AAAA,IACT,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,YAAY;AAAA,EACd;AAAA,EACA,SAAS;AAAA,IACP,SAAS;AAAA,IACT,YAAY;AAAA,EACd;AAAA,EACA,iBAAiB;AAAA,IACf,WAAW,aAAaA,eAAM,MAAA,OAAO,KAAK;AAAA,IAC1C,SAAS;AAAA,IACT,eAAe;AAAA,IACf,KAAKA,eAAAA,MAAM,MAAM;AAAA,IACjB,SAASA,eAAAA,MAAM,MAAM;AAAA,EACvB;AAAA;AAAA,EAEA,GAAG;AACL,CAAC;;;"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const React = require("react");
4
+ const isInputGroup = (input) => {
5
+ return "inputs" in input;
6
+ };
7
+ const isOutputGroup = (output) => {
8
+ return "outputs" in output;
9
+ };
10
+ const isConnected = (id, type, handleId, edges) => {
11
+ if (type === "target") {
12
+ return edges.some((e) => e.target === id && e.targetHandle === handleId);
13
+ }
14
+ if (type === "source") {
15
+ return edges.some((e) => e.source === id && e.sourceHandle === handleId);
16
+ }
17
+ return false;
18
+ };
19
+ const renderedIcon = (actionIcon) => React.isValidElement(actionIcon) ? actionIcon : actionIcon?.();
20
+ const identifyHandles = (handles) => {
21
+ let idx = 0;
22
+ return handles?.map(
23
+ (handle) => {
24
+ if (isInputGroup(handle)) {
25
+ return {
26
+ ...handle,
27
+ inputs: handle.inputs.map((x) => {
28
+ const identifiedHandle2 = x.id != null ? x : { ...x, id: String(idx) };
29
+ idx += 1;
30
+ return identifiedHandle2;
31
+ })
32
+ };
33
+ }
34
+ if (isOutputGroup(handle)) {
35
+ return {
36
+ ...handle,
37
+ outputs: handle.outputs.map((x) => {
38
+ const identifiedHandle2 = x.id != null ? x : { ...x, id: String(idx) };
39
+ idx += 1;
40
+ return identifiedHandle2;
41
+ })
42
+ };
43
+ }
44
+ const identifiedHandle = handle.id != null ? handle : { ...handle, id: String(idx) };
45
+ idx += 1;
46
+ return identifiedHandle;
47
+ }
48
+ );
49
+ };
50
+ exports.identifyHandles = identifyHandles;
51
+ exports.isConnected = isConnected;
52
+ exports.isInputGroup = isInputGroup;
53
+ exports.isOutputGroup = isOutputGroup;
54
+ exports.renderedIcon = renderedIcon;
55
+ //# sourceMappingURL=utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.cjs","sources":["../../../../src/Flow/Node/utils.ts"],"sourcesContent":["import { isValidElement } from \"react\";\nimport { Edge } from \"reactflow\";\nimport { HvActionGeneric } from \"@hitachivantara/uikit-react-core\";\n\nimport {\n HvFlowNodeInput,\n HvFlowNodeInputGroup,\n HvFlowNodeOutput,\n HvFlowNodeOutputGroup,\n} from \"../types\";\n\nexport const isInputGroup = (\n input: HvFlowNodeInput | HvFlowNodeInputGroup\n): input is HvFlowNodeInputGroup => {\n return \"inputs\" in input;\n};\n\nexport const isOutputGroup = (\n output: HvFlowNodeOutput | HvFlowNodeOutputGroup\n): output is HvFlowNodeOutputGroup => {\n return \"outputs\" in output;\n};\n\nexport const isConnected = (\n id: string,\n type: \"target\" | \"source\",\n handleId: string,\n edges: Edge[]\n) => {\n if (type === \"target\") {\n return edges.some((e) => e.target === id && e.targetHandle === handleId);\n }\n if (type === \"source\") {\n return edges.some((e) => e.source === id && e.sourceHandle === handleId);\n }\n\n return false;\n};\n\nexport const renderedIcon = (actionIcon: HvActionGeneric[\"icon\"]) =>\n isValidElement(actionIcon) ? actionIcon : (actionIcon as Function)?.();\n\nexport const identifyHandles = (\n handles?:\n | (HvFlowNodeInput | HvFlowNodeInputGroup)[]\n | (HvFlowNodeOutput | HvFlowNodeOutputGroup)[]\n) => {\n let idx = 0;\n\n return handles?.map(\n (\n handle:\n | HvFlowNodeOutput\n | HvFlowNodeOutputGroup\n | HvFlowNodeInput\n | HvFlowNodeInputGroup\n ) => {\n if (isInputGroup(handle)) {\n return {\n ...handle,\n inputs: handle.inputs.map((x) => {\n const identifiedHandle =\n x.id != null ? x : { ...x, id: String(idx) };\n idx += 1;\n return identifiedHandle;\n }),\n } satisfies HvFlowNodeInputGroup;\n }\n\n if (isOutputGroup(handle)) {\n return {\n ...handle,\n outputs: handle.outputs.map((x) => {\n const identifiedHandle =\n x.id != null ? x : { ...x, id: String(idx) };\n idx += 1;\n return identifiedHandle;\n }),\n } satisfies HvFlowNodeOutputGroup;\n }\n\n const identifiedHandle =\n handle.id != null ? handle : { ...handle, id: String(idx) };\n idx += 1;\n return identifiedHandle;\n }\n );\n};\n"],"names":["isValidElement","identifiedHandle"],"mappings":";;;AAWa,MAAA,eAAe,CAC1B,UACkC;AAClC,SAAO,YAAY;AACrB;AAEa,MAAA,gBAAgB,CAC3B,WACoC;AACpC,SAAO,aAAa;AACtB;AAEO,MAAM,cAAc,CACzB,IACA,MACA,UACA,UACG;AACH,MAAI,SAAS,UAAU;AACd,WAAA,MAAM,KAAK,CAAC,MAAM,EAAE,WAAW,MAAM,EAAE,iBAAiB,QAAQ;AAAA,EACzE;AACA,MAAI,SAAS,UAAU;AACd,WAAA,MAAM,KAAK,CAAC,MAAM,EAAE,WAAW,MAAM,EAAE,iBAAiB,QAAQ;AAAA,EACzE;AAEO,SAAA;AACT;AAEO,MAAM,eAAe,CAAC,eAC3BA,MAAAA,eAAe,UAAU,IAAI,aAAc,aAA0B;AAE1D,MAAA,kBAAkB,CAC7B,YAGG;AACH,MAAI,MAAM;AAEV,SAAO,SAAS;AAAA,IACd,CACE,WAKG;AACC,UAAA,aAAa,MAAM,GAAG;AACjB,eAAA;AAAA,UACL,GAAG;AAAA,UACH,QAAQ,OAAO,OAAO,IAAI,CAAC,MAAM;AACzBC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