@hitachivantara/uikit-react-lab 5.23.0 → 5.24.1
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.
- package/dist/cjs/Flow/DroppableFlow.cjs +6 -4
- package/dist/cjs/Flow/DroppableFlow.cjs.map +1 -1
- package/dist/cjs/Flow/Node/BaseNode.cjs +45 -35
- package/dist/cjs/Flow/Node/BaseNode.cjs.map +1 -1
- package/dist/cjs/Flow/Node/Node.cjs +1 -1
- package/dist/cjs/Flow/Node/Node.cjs.map +1 -1
- package/dist/cjs/Flow/Node/Parameters/ParamRenderer.cjs +2 -2
- package/dist/cjs/Flow/Node/Parameters/ParamRenderer.cjs.map +1 -1
- package/dist/cjs/Flow/Node/Parameters/Select.cjs +4 -14
- package/dist/cjs/Flow/Node/Parameters/Select.cjs.map +1 -1
- package/dist/cjs/Flow/Node/Parameters/Slider.cjs +5 -18
- package/dist/cjs/Flow/Node/Parameters/Slider.cjs.map +1 -1
- package/dist/cjs/Flow/Node/Parameters/Text.cjs +5 -18
- package/dist/cjs/Flow/Node/Parameters/Text.cjs.map +1 -1
- package/dist/cjs/Flow/hooks/useFlowNode.cjs +26 -0
- package/dist/cjs/Flow/hooks/useFlowNode.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/Flow/DroppableFlow.js +6 -4
- package/dist/esm/Flow/DroppableFlow.js.map +1 -1
- package/dist/esm/Flow/Node/BaseNode.js +46 -36
- package/dist/esm/Flow/Node/BaseNode.js.map +1 -1
- package/dist/esm/Flow/Node/Node.js +1 -1
- package/dist/esm/Flow/Node/Node.js.map +1 -1
- package/dist/esm/Flow/Node/Parameters/ParamRenderer.js +2 -2
- package/dist/esm/Flow/Node/Parameters/ParamRenderer.js.map +1 -1
- package/dist/esm/Flow/Node/Parameters/Select.js +4 -14
- package/dist/esm/Flow/Node/Parameters/Select.js.map +1 -1
- package/dist/esm/Flow/Node/Parameters/Slider.js +5 -18
- package/dist/esm/Flow/Node/Parameters/Slider.js.map +1 -1
- package/dist/esm/Flow/Node/Parameters/Text.js +5 -18
- package/dist/esm/Flow/Node/Parameters/Text.js.map +1 -1
- package/dist/esm/Flow/hooks/useFlowNode.js +27 -1
- package/dist/esm/Flow/hooks/useFlowNode.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/types/index.d.ts +6 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DroppableFlow.js","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 sourceProvides = outputs[edge.sourceHandle]?.provides || \"\";\n const targetAccepts = inputs[edge.targetHandle]?.accepts || [];\n const sourceMaxConnections = outputs[edge.sourceHandle]?.maxConnections;\n const targetMaxConnections = inputs[edge.targetHandle]?.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":[],"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,MAA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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;"}
|
|
1
|
+
{"version":3,"file":"DroppableFlow.js","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":[],"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,MAA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ErC,UAAA;AAAA,UAAC;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;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState, useCallback, isValidElement } from "react";
|
|
2
|
+
import { useMemo, useEffect, useState, useCallback, isValidElement } from "react";
|
|
3
3
|
import { useReactFlow, NodeToolbar, Handle, Position } from "reactflow";
|
|
4
4
|
import { uid } from "uid";
|
|
5
5
|
import { HvButton, HvTypography } from "@hitachivantara/uikit-react-core";
|
|
@@ -29,8 +29,8 @@ const HvFlowBaseNode = ({
|
|
|
29
29
|
headerItems,
|
|
30
30
|
icon,
|
|
31
31
|
color: colorProp,
|
|
32
|
-
inputs,
|
|
33
|
-
outputs,
|
|
32
|
+
inputs: inputsProp,
|
|
33
|
+
outputs: outputsProp,
|
|
34
34
|
nodeActions = defaultActions,
|
|
35
35
|
footer,
|
|
36
36
|
classes: classesProp,
|
|
@@ -38,8 +38,24 @@ const HvFlowBaseNode = ({
|
|
|
38
38
|
children
|
|
39
39
|
}) => {
|
|
40
40
|
const { registerNode, unregisterNode } = useNodeMetaRegistry();
|
|
41
|
+
const inputs = useMemo(
|
|
42
|
+
() => inputsProp?.map(
|
|
43
|
+
(input, idx) => input.id != null ? input : { ...input, id: String(idx) }
|
|
44
|
+
),
|
|
45
|
+
[inputsProp]
|
|
46
|
+
);
|
|
47
|
+
const outputs = useMemo(
|
|
48
|
+
() => outputsProp?.map(
|
|
49
|
+
(output, idx) => output.id != null ? output : { ...output, id: String(idx) }
|
|
50
|
+
),
|
|
51
|
+
[outputsProp]
|
|
52
|
+
);
|
|
41
53
|
useEffect(() => {
|
|
42
|
-
registerNode(id, {
|
|
54
|
+
registerNode(id, {
|
|
55
|
+
label: title || "",
|
|
56
|
+
inputs,
|
|
57
|
+
outputs
|
|
58
|
+
});
|
|
43
59
|
return () => unregisterNode(id);
|
|
44
60
|
}, [id, title, inputs, outputs, registerNode, unregisterNode]);
|
|
45
61
|
const [showActions, setShowActions] = useState(false);
|
|
@@ -137,41 +153,35 @@ const HvFlowBaseNode = ({
|
|
|
137
153
|
children && /* @__PURE__ */ jsx("div", { className: classes.contentContainer, children }),
|
|
138
154
|
inputs && inputs.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
139
155
|
/* @__PURE__ */ jsx("div", { className: classes.inputsTitleContainer, children: /* @__PURE__ */ jsx(HvTypography, { children: "Inputs" }) }),
|
|
140
|
-
/* @__PURE__ */ jsx("div", { className: classes.inputsContainer, children: inputs?.map((input
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
input.isMandatory && !isInputConnected(id, "target", handleId, inputEdges) && /* @__PURE__ */ jsx("div", { className: classes.mandatory })
|
|
154
|
-
] }, idx);
|
|
155
|
-
}) })
|
|
156
|
+
/* @__PURE__ */ jsx("div", { className: classes.inputsContainer, children: inputs?.map((input) => /* @__PURE__ */ jsxs("div", { className: classes.inputContainer, children: [
|
|
157
|
+
/* @__PURE__ */ jsx(
|
|
158
|
+
Handle,
|
|
159
|
+
{
|
|
160
|
+
type: "target",
|
|
161
|
+
isConnectableStart: false,
|
|
162
|
+
id: input.id,
|
|
163
|
+
position: Position.Left
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
/* @__PURE__ */ jsx(HvTypography, { children: input.label }),
|
|
167
|
+
input.isMandatory && !isInputConnected(id, "target", input.id, inputEdges) && /* @__PURE__ */ jsx("div", { className: classes.mandatory })
|
|
168
|
+
] }, input.id)) })
|
|
156
169
|
] }),
|
|
157
170
|
outputs && outputs.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
158
171
|
/* @__PURE__ */ jsx("div", { className: classes.outputsTitleContainer, children: /* @__PURE__ */ jsx(HvTypography, { children: "Outputs" }) }),
|
|
159
|
-
/* @__PURE__ */ jsx("div", { className: classes.outputsContainer, children: outputs?.map((output
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
/* @__PURE__ */ jsx(HvTypography, { children: output.label })
|
|
173
|
-
] }, idx);
|
|
174
|
-
}) })
|
|
172
|
+
/* @__PURE__ */ jsx("div", { className: classes.outputsContainer, children: outputs?.map((output) => /* @__PURE__ */ jsxs("div", { className: classes.outputContainer, children: [
|
|
173
|
+
/* @__PURE__ */ jsx(
|
|
174
|
+
Handle,
|
|
175
|
+
{
|
|
176
|
+
type: "source",
|
|
177
|
+
isConnectableEnd: false,
|
|
178
|
+
id: output.id,
|
|
179
|
+
position: Position.Right
|
|
180
|
+
}
|
|
181
|
+
),
|
|
182
|
+
output.isMandatory && !isInputConnected(id, "source", output.id, outputEdges) && /* @__PURE__ */ jsx("div", { className: classes.mandatory }),
|
|
183
|
+
/* @__PURE__ */ jsx(HvTypography, { children: output.label })
|
|
184
|
+
] }, output.id)) })
|
|
175
185
|
] }),
|
|
176
186
|
footer && /* @__PURE__ */ jsx("div", { className: classes.footerContainer, children: footer })
|
|
177
187
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseNode.js","sources":["../../../../src/Flow/Node/BaseNode.tsx"],"sourcesContent":["import React, { isValidElement, useCallback, useEffect, useState } 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,\n outputs,\n nodeActions = defaultActions,\n footer,\n classes: classesProp,\n className,\n children,\n}: HvFlowBaseNodeProps<unknown>) => {\n const { registerNode, unregisterNode } = useNodeMetaRegistry();\n useEffect(() => {\n registerNode(id, { label: title || \"\", inputs, outputs });\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, idx) => {\n const handleId = input.id ?? idx.toString();\n return (\n <div className={classes.inputContainer} key={idx}>\n <Handle\n type=\"target\"\n isConnectableStart={false}\n id={handleId}\n position={Position.Left}\n />\n <HvTypography>{input.label}</HvTypography>\n {input.isMandatory &&\n !isInputConnected(id, \"target\", handleId, inputEdges) && (\n <div className={classes.mandatory} />\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 const handleId = output.id ?? idx.toString();\n return (\n <div className={classes.outputContainer} key={idx}>\n <Handle\n type=\"source\"\n isConnectableEnd={false}\n id={handleId}\n position={Position.Right}\n />\n {output.isMandatory &&\n !isInputConnected(id, \"source\", handleId, outputEdges) && (\n <div className={classes.mandatory} />\n )}\n <HvTypography>{output.label}</HvTypography>\n </div>\n );\n })}\n </div>\n </>\n )}\n {footer && <div className={classes.footerContainer}>{footer}</div>}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AA6DA,MAAM,mBAAmB,CACvB,IACA,MACA,UACA,UACG;AACH,MAAI,S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AAA,GACF;AAAA,QAED,WAAW,QAAQ,SAAS,KAEzB,qBAAA,UAAA,EAAA,UAAA;AAAA,UAAA,oBAAC,SAAI,WAAW,QAAQ,uBACtB,UAAC,oBAAA,cAAA,EAAa,qBAAO,EACvB,CAAA;AAAA,UACA,oBAAC,SAAI,WAAW,QAAQ,kBACrB,UAAS,SAAA,IAAI,CAAC,QAAQ,QAAQ;AAC7B,kBAAM,WAAW,OAAO,MAAM,IAAI,SAAS;AAC3C,mBACG,qBAAA,OAAA,EAAI,WAAW,QAAQ,iBACtB,UAAA;AAAA,cAAA;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,MAAK;AAAA,kBACL,kBAAkB;AAAA,kBAClB,IAAI;AAAA,kBACJ,UAAU,SAAS;AAAA,gBAAA;AAAA,cACrB;AAAA,cACC,OAAO,eACN,CAAC,iBAAiB,IAAI,UAAU,UAAU,WAAW,KACnD,oBAAC,OAAI,EAAA,WAAW,QAAQ,UAAW,CAAA;AAAA,cAEvC,oBAAC,cAAc,EAAA,UAAA,OAAO,MAAM,CAAA;AAAA,YAAA,EAAA,GAXgB,GAY9C;AAAA,UAEH,CAAA,GACH;AAAA,QAAA,GACF;AAAA,QAED,UAAW,oBAAA,OAAA,EAAI,WAAW,QAAQ,iBAAkB,UAAO,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGlE;"}
|
|
1
|
+
{"version":3,"file":"BaseNode.js","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":[],"mappings":";;;;;;;;;;;AAmEA,MAAM,mBAAmB,CACvB,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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AA,YACA,oBAAC,cAAc,EAAA,UAAA,MAAM,MAAM,CAAA;AAAA,YAC1B,MAAM,eACL,CAAC,iBAAiB,IAAI,UAAU,MAAM,IAAK,UAAU,KACnD,oBAAC,OAAI,EAAA,WAAW,QAAQ,WAAW;AAAA,UAVI,EAAA,GAAA,MAAM,EAYnD,CACD,GACH;AAAA,QAAA,GACF;AAAA,QAED,WAAW,QAAQ,SAAS,KAEzB,qBAAA,UAAA,EAAA,UAAA;AAAA,UAAA,oBAAC,SAAI,WAAW,QAAQ,uBACtB,UAAC,oBAAA,cAAA,EAAa,qBAAO,EACvB,CAAA;AAAA,UACC,oBAAA,OAAA,EAAI,WAAW,QAAQ,kBACrB,UAAA,SAAS,IAAI,CAAC,WACb,qBAAC,OAAI,EAAA,WAAW,QAAQ,iBACtB,UAAA;AAAA,YAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,MAAK;AAAA,gBACL,kBAAkB;AAAA,gBAClB,IAAI,OAAO;AAAA,gBACX,UAAU,SAAS;AAAA,cAAA;AAAA,YACrB;AAAA,YACC,OAAO,eACN,CAAC,iBAAiB,IAAI,UAAU,OAAO,IAAK,WAAW,KACrD,oBAAC,OAAI,EAAA,WAAW,QAAQ,WAAW;AAAA,YAEvC,oBAAC,cAAc,EAAA,UAAA,OAAO,MAAM,CAAA;AAAA,UAXgB,EAAA,GAAA,OAAO,EAYrD,CACD,GACH;AAAA,QAAA,GACF;AAAA,QAED,UAAW,oBAAA,OAAA,EAAI,WAAW,QAAQ,iBAAkB,UAAO,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGlE;"}
|
|
@@ -99,7 +99,7 @@ const HvFlowNode = ({
|
|
|
99
99
|
] }) })
|
|
100
100
|
] }),
|
|
101
101
|
children,
|
|
102
|
-
showParams && params && /* @__PURE__ */ jsx("div", { className: classes.paramsContainer, children: /* @__PURE__ */ jsx(ParamRenderer, {
|
|
102
|
+
showParams && params && /* @__PURE__ */ jsx("div", { className: classes.paramsContainer, children: /* @__PURE__ */ jsx(ParamRenderer, { params, data: node?.data }) })
|
|
103
103
|
]
|
|
104
104
|
}
|
|
105
105
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Node.js","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
|
|
1
|
+
{"version":3,"file":"Node.js","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":[],"mappings":";;;;;;;;;;AA8DA,MAAM,eAAe,CAAC,eACpB,eAAe,UAAU,IAAI,aAAc;AAEtC,MAAM,aAAa,CAAC;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;"}
|
|
@@ -7,12 +7,12 @@ const renderers = {
|
|
|
7
7
|
select: Select,
|
|
8
8
|
slider: Slider
|
|
9
9
|
};
|
|
10
|
-
const ParamRenderer = ({
|
|
10
|
+
const ParamRenderer = ({ params, data }) => {
|
|
11
11
|
return /* @__PURE__ */ jsx(Fragment, { children: params.map((param, idx) => {
|
|
12
12
|
const Renderer = renderers[param.type];
|
|
13
13
|
if (!Renderer)
|
|
14
14
|
return null;
|
|
15
|
-
return /* @__PURE__ */ jsx(Renderer, {
|
|
15
|
+
return /* @__PURE__ */ jsx(Renderer, { param, data }, idx);
|
|
16
16
|
}) });
|
|
17
17
|
};
|
|
18
18
|
const ParamRenderer$1 = ParamRenderer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParamRenderer.js","sources":["../../../../../src/Flow/Node/Parameters/ParamRenderer.tsx"],"sourcesContent":["import { HvFlowNodeParam } from \"../../types\";\nimport Text from \"./Text\";\nimport Select from \"./Select\";\nimport Slider from \"./Slider\";\n\nexport type ParamRendererProps = {\n
|
|
1
|
+
{"version":3,"file":"ParamRenderer.js","sources":["../../../../../src/Flow/Node/Parameters/ParamRenderer.tsx"],"sourcesContent":["import { HvFlowNodeParam } from \"../../types\";\nimport Text from \"./Text\";\nimport Select from \"./Select\";\nimport Slider from \"./Slider\";\n\nexport type ParamRendererProps = {\n params: HvFlowNodeParam[];\n data: any;\n};\n\nconst renderers = {\n text: Text,\n select: Select,\n slider: Slider,\n};\n\nconst ParamRenderer = ({ params, data }: ParamRendererProps) => {\n return (\n <>\n {params.map((param, idx) => {\n const Renderer = renderers[param.type];\n if (!Renderer) return null;\n\n return <Renderer key={idx} param={param} data={data} />;\n })}\n </>\n );\n};\n\nexport default ParamRenderer;\n"],"names":[],"mappings":";;;;AAUA,MAAM,YAAY;AAAA,EAChB,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AACV;AAEA,MAAM,gBAAgB,CAAC,EAAE,QAAQ,WAA+B;AAC9D,SAEK,oBAAA,UAAA,EAAA,UAAA,OAAO,IAAI,CAAC,OAAO,QAAQ;AACpB,UAAA,WAAW,UAAU,MAAM,IAAI;AACrC,QAAI,CAAC;AAAiB,aAAA;AAEtB,WAAQ,oBAAA,UAAA,EAAmB,OAAc,KAAA,GAAnB,GAA+B;AAAA,EACtD,CAAA,EACH,CAAA;AAEJ;AAEA,MAAA,kBAAe;"}
|
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { HvDropdown } from "@hitachivantara/uikit-react-core";
|
|
4
|
-
import {
|
|
5
|
-
const Select = ({
|
|
4
|
+
import { useFlowNodeUtils } from "../../hooks/useFlowNode.js";
|
|
5
|
+
const Select = ({ param, data }) => {
|
|
6
6
|
const { id, label, multiple = false, options } = param;
|
|
7
|
-
const
|
|
7
|
+
const { setNodeData } = useFlowNodeUtils();
|
|
8
8
|
const [opts, setOpts] = useState(
|
|
9
9
|
data[id] ? Array.isArray(data[id]) ? data[id] : [data[id]] : void 0
|
|
10
10
|
);
|
|
11
11
|
const onSelectChange = (item) => {
|
|
12
12
|
const newOpts = Array.isArray(item) ? item.map((x) => x.label) : item?.label ?? void 0;
|
|
13
|
-
|
|
14
|
-
(nodes) => nodes.map((node) => {
|
|
15
|
-
if (node.id === nodeId) {
|
|
16
|
-
node.data = {
|
|
17
|
-
...node.data,
|
|
18
|
-
[id]: newOpts
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
return node;
|
|
22
|
-
})
|
|
23
|
-
);
|
|
13
|
+
setNodeData((prev) => ({ ...prev, [id]: newOpts }));
|
|
24
14
|
setOpts(
|
|
25
15
|
newOpts ? Array.isArray(newOpts) ? newOpts : [newOpts] : void 0
|
|
26
16
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sources":["../../../../../src/Flow/Node/Parameters/Select.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { HvDropdown, HvDropdownProps } from \"@hitachivantara/uikit-react-core\";\nimport {
|
|
1
|
+
{"version":3,"file":"Select.js","sources":["../../../../../src/Flow/Node/Parameters/Select.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { HvDropdown, HvDropdownProps } from \"@hitachivantara/uikit-react-core\";\n\nimport { HvFlowNodeSelectParam } from \"../../types\";\nimport { useFlowNodeUtils } from \"../../hooks\";\n\ninterface SelectProps {\n param: Omit<HvFlowNodeSelectParam, \"type\">;\n data: any;\n}\n\nconst Select = ({ param, data }: SelectProps) => {\n const { id, label, multiple = false, options } = param;\n const { setNodeData } = useFlowNodeUtils();\n\n const [opts, setOpts] = useState<string[] | undefined>(\n data[id] ? (Array.isArray(data[id]) ? data[id] : [data[id]]) : undefined\n );\n\n const onSelectChange: HvDropdownProps[\"onChange\"] = (item) => {\n const newOpts = Array.isArray(item)\n ? item.map((x) => x.label as string)\n : (item?.label as string) ?? undefined;\n\n setNodeData((prev) => ({ ...prev, [id]: newOpts }));\n setOpts(\n newOpts ? (Array.isArray(newOpts) ? newOpts : [newOpts]) : undefined\n );\n };\n\n return (\n <HvDropdown\n className=\"nodrag\" // Prevents dragging within the select field\n disablePortal\n label={label}\n values={options?.map((o) => {\n return { id: o, label: o, selected: !!opts?.find((opt) => opt === o) };\n })}\n onChange={onSelectChange}\n maxHeight={100}\n multiSelect={multiple}\n />\n );\n};\n\nexport default Select;\n"],"names":[],"mappings":";;;;AAWA,MAAM,SAAS,CAAC,EAAE,OAAO,WAAwB;AAC/C,QAAM,EAAE,IAAI,OAAO,WAAW,OAAO,QAAY,IAAA;AAC3C,QAAA,EAAE,gBAAgB;AAElB,QAAA,CAAC,MAAM,OAAO,IAAI;AAAA,IACtB,KAAK,EAAE,IAAK,MAAM,QAAQ,KAAK,EAAE,CAAC,IAAI,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,IAAK;AAAA,EAAA;AAG3D,QAAA,iBAA8C,CAAC,SAAS;AAC5D,UAAM,UAAU,MAAM,QAAQ,IAAI,IAC9B,KAAK,IAAI,CAAC,MAAM,EAAE,KAAe,IAChC,MAAM,SAAoB;AAEnB,gBAAA,CAAC,UAAU,EAAE,GAAG,MAAM,CAAC,EAAE,GAAG,QAAU,EAAA;AAClD;AAAA,MACE,UAAW,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO,IAAK;AAAA,IAAA;AAAA,EAC7D;AAIA,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,eAAa;AAAA,MACb;AAAA,MACA,QAAQ,SAAS,IAAI,CAAC,MAAM;AAC1B,eAAO,EAAE,IAAI,GAAG,OAAO,GAAG,UAAU,CAAC,CAAC,MAAM,KAAK,CAAC,QAAQ,QAAQ,CAAC,EAAE;AAAA,MAAA,CACtE;AAAA,MACD,UAAU;AAAA,MACV,WAAW;AAAA,MACX,aAAa;AAAA,IAAA;AAAA,EAAA;AAGnB;AAEA,MAAA,WAAe;"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
3
2
|
import { css } from "@emotion/css";
|
|
4
|
-
import { useReactFlow } from "reactflow";
|
|
5
3
|
import { HvSlider } from "@hitachivantara/uikit-react-core";
|
|
4
|
+
import { useFlowNodeUtils } from "../../hooks/useFlowNode.js";
|
|
6
5
|
const classes = {
|
|
7
6
|
labelContainer: css({
|
|
8
7
|
marginRight: 0,
|
|
@@ -12,27 +11,15 @@ const classes = {
|
|
|
12
11
|
padding: 0
|
|
13
12
|
})
|
|
14
13
|
};
|
|
15
|
-
const Slider = ({
|
|
14
|
+
const Slider = ({ param, data }) => {
|
|
16
15
|
const { id } = param;
|
|
17
|
-
const
|
|
18
|
-
const [value, setValue] = useState(data[id]);
|
|
19
|
-
const onSliderChange = (val) => {
|
|
20
|
-
reactFlowInstance.setNodes(
|
|
21
|
-
(nodes) => nodes.map((node) => {
|
|
22
|
-
if (node.id === nodeId) {
|
|
23
|
-
node.data = { ...node.data, [id]: val };
|
|
24
|
-
}
|
|
25
|
-
return node;
|
|
26
|
-
})
|
|
27
|
-
);
|
|
28
|
-
setValue(val);
|
|
29
|
-
};
|
|
16
|
+
const { setNodeData } = useFlowNodeUtils();
|
|
30
17
|
return /* @__PURE__ */ jsx(
|
|
31
18
|
HvSlider,
|
|
32
19
|
{
|
|
33
20
|
className: "nodrag",
|
|
34
|
-
defaultValues:
|
|
35
|
-
onChange:
|
|
21
|
+
defaultValues: data[id],
|
|
22
|
+
onChange: (val) => setNodeData((prev) => ({ ...prev, [id]: val })),
|
|
36
23
|
classes: {
|
|
37
24
|
labelContainer: classes.labelContainer,
|
|
38
25
|
sliderBase: classes.sliderBase
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.js","sources":["../../../../../src/Flow/Node/Parameters/Slider.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"Slider.js","sources":["../../../../../src/Flow/Node/Parameters/Slider.tsx"],"sourcesContent":["import { css } from \"@emotion/css\";\nimport { HvSlider } from \"@hitachivantara/uikit-react-core\";\n\nimport { HvFlowNodeSliderParam } from \"../../types\";\nimport { useFlowNodeUtils } from \"../../hooks\";\n\ninterface SliderProps {\n param: Omit<HvFlowNodeSliderParam, \"type\">;\n data: any;\n}\n\nconst classes = {\n labelContainer: css({\n marginRight: 0,\n marginLeft: 0,\n }),\n sliderBase: css({\n padding: 0,\n }),\n};\n\nconst Slider = ({ param, data }: SliderProps) => {\n const { id } = param;\n const { setNodeData } = useFlowNodeUtils();\n\n return (\n <HvSlider\n className=\"nodrag\" // Prevents dragging within the input field\n defaultValues={data[id]}\n onChange={(val) => setNodeData((prev) => ({ ...prev, [id]: val }))}\n classes={{\n labelContainer: classes.labelContainer,\n sliderBase: classes.sliderBase,\n }}\n {...param}\n />\n );\n};\n\nexport default Slider;\n"],"names":[],"mappings":";;;;AAWA,MAAM,UAAU;AAAA,EACd,gBAAgB,IAAI;AAAA,IAClB,aAAa;AAAA,IACb,YAAY;AAAA,EAAA,CACb;AAAA,EACD,YAAY,IAAI;AAAA,IACd,SAAS;AAAA,EAAA,CACV;AACH;AAEA,MAAM,SAAS,CAAC,EAAE,OAAO,WAAwB;AACzC,QAAA,EAAE,GAAO,IAAA;AACT,QAAA,EAAE,gBAAgB;AAGtB,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,eAAe,KAAK,EAAE;AAAA,MACtB,UAAU,CAAC,QAAQ,YAAY,CAAC,UAAU,EAAE,GAAG,MAAM,CAAC,EAAE,GAAG,MAAM;AAAA,MACjE,SAAS;AAAA,QACP,gBAAgB,QAAQ;AAAA,QACxB,YAAY,QAAQ;AAAA,MACtB;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV;AAEA,MAAA,WAAe;"}
|
|
@@ -1,29 +1,16 @@
|
|
|
1
1
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
3
2
|
import { HvInput } from "@hitachivantara/uikit-react-core";
|
|
4
|
-
import {
|
|
5
|
-
const Text = ({
|
|
3
|
+
import { useFlowNodeUtils } from "../../hooks/useFlowNode.js";
|
|
4
|
+
const Text = ({ param, data }) => {
|
|
6
5
|
const { id, label } = param;
|
|
7
|
-
const
|
|
8
|
-
const [text, setText] = useState(data[id]);
|
|
9
|
-
const onTextChange = (event, val) => {
|
|
10
|
-
reactFlowInstance.setNodes(
|
|
11
|
-
(nodes) => nodes.map((node) => {
|
|
12
|
-
if (node.id === nodeId) {
|
|
13
|
-
node.data = { ...node.data, [id]: val };
|
|
14
|
-
}
|
|
15
|
-
return node;
|
|
16
|
-
})
|
|
17
|
-
);
|
|
18
|
-
setText(val);
|
|
19
|
-
};
|
|
6
|
+
const { setNodeData } = useFlowNodeUtils();
|
|
20
7
|
return /* @__PURE__ */ jsx(
|
|
21
8
|
HvInput,
|
|
22
9
|
{
|
|
23
10
|
className: "nodrag",
|
|
24
11
|
label,
|
|
25
|
-
|
|
26
|
-
onChange:
|
|
12
|
+
defaultValue: data[id],
|
|
13
|
+
onChange: (evt, val) => setNodeData((prev) => ({ ...prev, [id]: val }))
|
|
27
14
|
}
|
|
28
15
|
);
|
|
29
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.js","sources":["../../../../../src/Flow/Node/Parameters/Text.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"Text.js","sources":["../../../../../src/Flow/Node/Parameters/Text.tsx"],"sourcesContent":["import { HvInput } from \"@hitachivantara/uikit-react-core\";\n\nimport { HvFlowNodeTextParam } from \"../../types\";\nimport { useFlowNodeUtils } from \"../../hooks\";\n\ninterface TextProps {\n param: Omit<HvFlowNodeTextParam, \"type\">;\n data: any;\n}\n\nconst Text = ({ param, data }: TextProps) => {\n const { id, label } = param;\n const { setNodeData } = useFlowNodeUtils();\n\n return (\n <HvInput\n className=\"nodrag\" // Prevents dragging within the input field\n label={label}\n defaultValue={data[id]}\n onChange={(evt, val) => setNodeData((prev) => ({ ...prev, [id]: val }))}\n />\n );\n};\n\nexport default Text;\n"],"names":[],"mappings":";;;AAUA,MAAM,OAAO,CAAC,EAAE,OAAO,WAAsB;AACrC,QAAA,EAAE,IAAI,MAAU,IAAA;AAChB,QAAA,EAAE,gBAAgB;AAGtB,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV;AAAA,MACA,cAAc,KAAK,EAAE;AAAA,MACrB,UAAU,CAAC,KAAK,QAAQ,YAAY,CAAC,UAAU,EAAE,GAAG,MAAM,CAAC,EAAE,GAAG,IAAM,EAAA;AAAA,IAAA;AAAA,EAAA;AAG5E;AAEA,MAAA,SAAe;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useMemo } from "react";
|
|
2
|
-
import { useStore, useNodes, useEdges } from "reactflow";
|
|
2
|
+
import { useStore, useNodes, useEdges, useNodeId, useReactFlow } from "reactflow";
|
|
3
3
|
function useFlowNode(id) {
|
|
4
4
|
const nodeSelector = useCallback(
|
|
5
5
|
(state) => state.getNodes().find((n) => n.id === id),
|
|
@@ -52,6 +52,31 @@ function useFlowOutputNodes(id) {
|
|
|
52
52
|
return edges.filter((e) => e.source === id).map((e) => nodes.find((n) => n.id === e.target)).filter((n) => n !== null);
|
|
53
53
|
}, [edges, id, nodes]);
|
|
54
54
|
}
|
|
55
|
+
function useFlowNodeUtils() {
|
|
56
|
+
const nodeId = useNodeId();
|
|
57
|
+
const reactFlowInstance = useReactFlow();
|
|
58
|
+
const setNodeData = useCallback(
|
|
59
|
+
(setNewData) => {
|
|
60
|
+
if (!nodeId)
|
|
61
|
+
return;
|
|
62
|
+
reactFlowInstance.setNodes((nodes) => {
|
|
63
|
+
return nodes.map((n) => {
|
|
64
|
+
if (n.id === nodeId) {
|
|
65
|
+
return { ...n, data: setNewData(n.data) };
|
|
66
|
+
}
|
|
67
|
+
return n;
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
[nodeId, reactFlowInstance]
|
|
72
|
+
);
|
|
73
|
+
return useMemo(
|
|
74
|
+
() => ({
|
|
75
|
+
setNodeData
|
|
76
|
+
}),
|
|
77
|
+
[setNodeData]
|
|
78
|
+
);
|
|
79
|
+
}
|
|
55
80
|
export {
|
|
56
81
|
useFlowInputNodes,
|
|
57
82
|
useFlowNode,
|
|
@@ -59,6 +84,7 @@ export {
|
|
|
59
84
|
useFlowNodeInputEdges,
|
|
60
85
|
useFlowNodeOutputEdges,
|
|
61
86
|
useFlowNodeParents,
|
|
87
|
+
useFlowNodeUtils,
|
|
62
88
|
useFlowOutputNodes
|
|
63
89
|
};
|
|
64
90
|
//# sourceMappingURL=useFlowNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFlowNode.js","sources":["../../../../src/Flow/hooks/useFlowNode.ts"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport {\n Node,\n Edge,\n ReactFlowState,\n useStore,\n useNodes,\n useEdges,\n} from \"reactflow\";\n\nexport function useFlowNode<T extends Node = Node>(id: string) {\n const nodeSelector = useCallback(\n (state: ReactFlowState) =>\n state.getNodes().find((n: Node): n is T => n.id === id),\n [id]\n );\n return useStore<T | undefined>(nodeSelector);\n}\n\nexport function useFlowNodeInputEdges(id: string) {\n const inputEdgesSelector = useCallback(\n (state: ReactFlowState) => state.edges.filter((e: Edge) => e.target === id),\n [id]\n );\n return useStore(inputEdgesSelector);\n}\n\nexport function useFlowNodeOutputEdges(id: string) {\n const outputEdgesSelector = useCallback(\n (state: ReactFlowState) => state.edges.filter((e: Edge) => e.source === id),\n [id]\n );\n return useStore(outputEdgesSelector);\n}\n\nexport function useFlowNodeEdges(id: string) {\n const edgesSelector = useCallback(\n (state: ReactFlowState) =>\n state.edges.filter((e: Edge) => e.source === id || e.target === id),\n [id]\n );\n return useStore(edgesSelector);\n}\n\nexport function useFlowNodeParents(id: string) {\n const inputEdges = useFlowNodeInputEdges(id);\n const parentNodesSelector = useCallback(\n (state: ReactFlowState) => {\n return inputEdges\n .map((e) => state.getNodes().find((n: Node) => n.id === e.source))\n .filter((n): n is Node => n !== null);\n },\n [inputEdges]\n );\n return useStore(parentNodesSelector);\n}\n\nexport function useFlowInputNodes<T = any>(id: string) {\n const nodes = useNodes();\n const edges = useEdges();\n\n return useMemo(() => {\n return edges\n .filter((e) => e.target === id)\n .map((e) => nodes.find((n) => n.id === e.source))\n .filter((n): n is Node<T> => n !== null);\n }, [edges, id, nodes]);\n}\n\nexport function useFlowOutputNodes<T = any>(id: string) {\n const nodes = useNodes();\n const edges = useEdges();\n\n return useMemo(() => {\n return edges\n .filter((e) => e.source === id)\n .map((e) => nodes.find((n) => n.id === e.target))\n .filter((n): n is Node<T> => n !== null);\n }, [edges, id, nodes]);\n}\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"useFlowNode.js","sources":["../../../../src/Flow/hooks/useFlowNode.ts"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport {\n Node,\n Edge,\n ReactFlowState,\n useStore,\n useNodes,\n useEdges,\n useReactFlow,\n useNodeId,\n} from \"reactflow\";\n\nexport function useFlowNode<T extends Node = Node>(id: string) {\n const nodeSelector = useCallback(\n (state: ReactFlowState) =>\n state.getNodes().find((n: Node): n is T => n.id === id),\n [id]\n );\n return useStore<T | undefined>(nodeSelector);\n}\n\nexport function useFlowNodeInputEdges(id: string) {\n const inputEdgesSelector = useCallback(\n (state: ReactFlowState) => state.edges.filter((e: Edge) => e.target === id),\n [id]\n );\n return useStore(inputEdgesSelector);\n}\n\nexport function useFlowNodeOutputEdges(id: string) {\n const outputEdgesSelector = useCallback(\n (state: ReactFlowState) => state.edges.filter((e: Edge) => e.source === id),\n [id]\n );\n return useStore(outputEdgesSelector);\n}\n\nexport function useFlowNodeEdges(id: string) {\n const edgesSelector = useCallback(\n (state: ReactFlowState) =>\n state.edges.filter((e: Edge) => e.source === id || e.target === id),\n [id]\n );\n return useStore(edgesSelector);\n}\n\nexport function useFlowNodeParents(id: string) {\n const inputEdges = useFlowNodeInputEdges(id);\n const parentNodesSelector = useCallback(\n (state: ReactFlowState) => {\n return inputEdges\n .map((e) => state.getNodes().find((n: Node) => n.id === e.source))\n .filter((n): n is Node => n !== null);\n },\n [inputEdges]\n );\n return useStore(parentNodesSelector);\n}\n\nexport function useFlowInputNodes<T = any>(id: string) {\n const nodes = useNodes();\n const edges = useEdges();\n\n return useMemo(() => {\n return edges\n .filter((e) => e.target === id)\n .map((e) => nodes.find((n) => n.id === e.source))\n .filter((n): n is Node<T> => n !== null);\n }, [edges, id, nodes]);\n}\n\nexport function useFlowOutputNodes<T = any>(id: string) {\n const nodes = useNodes();\n const edges = useEdges();\n\n return useMemo(() => {\n return edges\n .filter((e) => e.source === id)\n .map((e) => nodes.find((n) => n.id === e.target))\n .filter((n): n is Node<T> => n !== null);\n }, [edges, id, nodes]);\n}\n\n/** Utilities to manipulate a node in the flow */\nexport function useFlowNodeUtils() {\n const nodeId = useNodeId();\n const reactFlowInstance = useReactFlow();\n\n /** Mutate the node's `.data` object */\n const setNodeData = useCallback(\n (setNewData: (newData?: any) => any) => {\n if (!nodeId) return;\n\n reactFlowInstance.setNodes((nodes) => {\n return nodes.map((n) => {\n if (n.id === nodeId) {\n return { ...n, data: setNewData(n.data) };\n }\n return n;\n });\n });\n },\n [nodeId, reactFlowInstance]\n );\n\n return useMemo(\n () => ({\n setNodeData,\n }),\n [setNodeData]\n );\n}\n"],"names":[],"mappings":";;AAYO,SAAS,YAAmC,IAAY;AAC7D,QAAM,eAAe;AAAA,IACnB,CAAC,UACC,MAAM,WAAW,KAAK,CAAC,MAAoB,EAAE,OAAO,EAAE;AAAA,IACxD,CAAC,EAAE;AAAA,EAAA;AAEL,SAAO,SAAwB,YAAY;AAC7C;AAEO,SAAS,sBAAsB,IAAY;AAChD,QAAM,qBAAqB;AAAA,IACzB,CAAC,UAA0B,MAAM,MAAM,OAAO,CAAC,MAAY,EAAE,WAAW,EAAE;AAAA,IAC1E,CAAC,EAAE;AAAA,EAAA;AAEL,SAAO,SAAS,kBAAkB;AACpC;AAEO,SAAS,uBAAuB,IAAY;AACjD,QAAM,sBAAsB;AAAA,IAC1B,CAAC,UAA0B,MAAM,MAAM,OAAO,CAAC,MAAY,EAAE,WAAW,EAAE;AAAA,IAC1E,CAAC,EAAE;AAAA,EAAA;AAEL,SAAO,SAAS,mBAAmB;AACrC;AAEO,SAAS,iBAAiB,IAAY;AAC3C,QAAM,gBAAgB;AAAA,IACpB,CAAC,UACC,MAAM,MAAM,OAAO,CAAC,MAAY,EAAE,WAAW,MAAM,EAAE,WAAW,EAAE;AAAA,IACpE,CAAC,EAAE;AAAA,EAAA;AAEL,SAAO,SAAS,aAAa;AAC/B;AAEO,SAAS,mBAAmB,IAAY;AACvC,QAAA,aAAa,sBAAsB,EA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ACF;AAAA,IACH;AAAA,IACA,CAAC,QAAQ,iBAAiB;AAAA,EAAA;AAGrB,SAAA;AAAA,IACL,OAAO;AAAA,MACL;AAAA,IAAA;AAAA,IAEF,CAAC,WAAW;AAAA,EAAA;AAEhB;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import { HvFlowBaseNode } from "./Flow/Node/BaseNode.js";
|
|
|
18
18
|
import { staticClasses as staticClasses8 } from "./Flow/Node/Node.styles.js";
|
|
19
19
|
import { HvFlowNode } from "./Flow/Node/Node.js";
|
|
20
20
|
import { HvDashboardNode, hvDashboardNodeClasses } from "./Flow/nodes/DashboardNode.js";
|
|
21
|
-
import { useFlowInputNodes, useFlowNode, useFlowNodeEdges, useFlowNodeInputEdges, useFlowNodeOutputEdges, useFlowNodeParents, useFlowOutputNodes } from "./Flow/hooks/useFlowNode.js";
|
|
21
|
+
import { useFlowInputNodes, useFlowNode, useFlowNodeEdges, useFlowNodeInputEdges, useFlowNodeOutputEdges, useFlowNodeParents, useFlowNodeUtils, useFlowOutputNodes } from "./Flow/hooks/useFlowNode.js";
|
|
22
22
|
import { useFlowContext } from "./Flow/hooks/useFlowContext.js";
|
|
23
23
|
import { useFlowNodeMeta } from "./Flow/hooks/useFlowNodeMeta.js";
|
|
24
24
|
import { staticClasses as staticClasses9 } from "./StepNavigation/StepNavigation.styles.js";
|
|
@@ -72,6 +72,7 @@ export {
|
|
|
72
72
|
useFlowNodeMeta,
|
|
73
73
|
useFlowNodeOutputEdges,
|
|
74
74
|
useFlowNodeParents,
|
|
75
|
+
useFlowNodeUtils,
|
|
75
76
|
useFlowOutputNodes,
|
|
76
77
|
staticClasses11 as wizardActionsClasses,
|
|
77
78
|
staticClasses10 as wizardClasses,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -333,7 +333,7 @@ export declare interface HvFlowBackgroundProps extends Omit<BackgroundProps, "co
|
|
|
333
333
|
color?: HvColorAny;
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
-
export declare const HvFlowBaseNode: ({ id, title, headerItems, icon, color: colorProp, inputs, outputs, nodeActions, footer, classes: classesProp, className, children, }: HvFlowBaseNodeProps<unknown>) => JSX_2.Element | null;
|
|
336
|
+
export declare const HvFlowBaseNode: ({ id, title, headerItems, icon, color: colorProp, inputs: inputsProp, outputs: outputsProp, nodeActions, footer, classes: classesProp, className, children, }: HvFlowBaseNodeProps<unknown>) => JSX_2.Element | null;
|
|
337
337
|
|
|
338
338
|
export declare type HvFlowBaseNodeClasses = ExtractNames<typeof useClasses_7>;
|
|
339
339
|
|
|
@@ -1044,6 +1044,11 @@ export declare function useFlowNodeOutputEdges(id: string): Edge<any>[];
|
|
|
1044
1044
|
|
|
1045
1045
|
export declare function useFlowNodeParents(id: string): Node_2<any, string | undefined>[];
|
|
1046
1046
|
|
|
1047
|
+
/** Utilities to manipulate a node in the flow */
|
|
1048
|
+
export declare function useFlowNodeUtils(): {
|
|
1049
|
+
setNodeData: (setNewData: (newData?: any) => any) => void;
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1047
1052
|
export declare function useFlowOutputNodes<T = any>(id: string): Node_2<T, string | undefined>[];
|
|
1048
1053
|
|
|
1049
1054
|
export declare const wizardActionsClasses: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/uikit-react-lab",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.24.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Hitachi Vantara UI Kit Team",
|
|
6
6
|
"description": "Contributed React components for the NEXT UI Kit.",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@dnd-kit/core": "^6.1.0",
|
|
33
33
|
"@dnd-kit/modifiers": "^6.0.1",
|
|
34
34
|
"@emotion/css": "^11.11.0",
|
|
35
|
-
"@hitachivantara/uikit-react-core": "^5.44.
|
|
35
|
+
"@hitachivantara/uikit-react-core": "^5.44.4",
|
|
36
36
|
"@hitachivantara/uikit-react-icons": "^5.8.0",
|
|
37
37
|
"@hitachivantara/uikit-styles": "^5.17.2",
|
|
38
38
|
"@types/react-grid-layout": "^1.3.5",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"access": "public",
|
|
51
51
|
"directory": "package"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "b3de50ca5f1d39d98879d15cfdd10bfa09861302",
|
|
54
54
|
"main": "dist/cjs/index.cjs",
|
|
55
55
|
"exports": {
|
|
56
56
|
".": {
|