@hitachivantara/uikit-react-lab 5.6.0 → 5.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Flow/Flow.cjs +2 -1
- package/dist/cjs/components/Flow/Flow.cjs.map +1 -1
- package/dist/cjs/components/Flow/FlowContext/FlowContext.cjs +3 -1
- package/dist/cjs/components/Flow/FlowContext/FlowContext.cjs.map +1 -1
- package/dist/cjs/components/Flow/Node/Node.cjs +54 -7
- package/dist/cjs/components/Flow/Node/Node.cjs.map +1 -1
- package/dist/cjs/components/Flow/Node/Node.styles.cjs +9 -1
- package/dist/cjs/components/Flow/Node/Node.styles.cjs.map +1 -1
- package/dist/esm/components/Flow/Flow.js +2 -1
- package/dist/esm/components/Flow/Flow.js.map +1 -1
- package/dist/esm/components/Flow/FlowContext/FlowContext.js +3 -1
- package/dist/esm/components/Flow/FlowContext/FlowContext.js.map +1 -1
- package/dist/esm/components/Flow/Node/Node.js +59 -12
- package/dist/esm/components/Flow/Node/Node.js.map +1 -1
- package/dist/esm/components/Flow/Node/Node.styles.js +9 -1
- package/dist/esm/components/Flow/Node/Node.styles.js.map +1 -1
- package/dist/types/index.d.ts +15 -5
- package/package.json +2 -2
|
@@ -12,6 +12,7 @@ const HvFlow = ({
|
|
|
12
12
|
nodeTypes,
|
|
13
13
|
nodeGroups,
|
|
14
14
|
sidebar,
|
|
15
|
+
defaultActions,
|
|
15
16
|
dndContextProps,
|
|
16
17
|
...others
|
|
17
18
|
}) => {
|
|
@@ -26,7 +27,7 @@ const HvFlow = ({
|
|
|
26
27
|
const handleDragEnd = () => {
|
|
27
28
|
setDraggingLabel(void 0);
|
|
28
29
|
};
|
|
29
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ReactFlow.ReactFlowProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(FlowContext.HvFlowProvider, { nodeGroups, nodeTypes, children: /* @__PURE__ */ jsxRuntime.jsxs(core.DndContext, { onDragStart: handleDragStart, onDragEnd: handleDragEnd, sensors, modifiers: [modifiers.restrictToWindowEdges], ...dndContextProps, children: [
|
|
30
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ReactFlow.ReactFlowProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(FlowContext.HvFlowProvider, { nodeGroups, nodeTypes, defaultActions, children: /* @__PURE__ */ jsxRuntime.jsxs(core.DndContext, { onDragStart: handleDragStart, onDragEnd: handleDragEnd, sensors, modifiers: [modifiers.restrictToWindowEdges], ...dndContextProps, children: [
|
|
30
31
|
/* @__PURE__ */ jsxRuntime.jsx(DroppableFlow.HvDroppableFlow, { ...others }),
|
|
31
32
|
sidebar,
|
|
32
33
|
/* @__PURE__ */ jsxRuntime.jsx(core.DragOverlay, { modifiers: [modifiers.restrictToWindowEdges], children: draggingLabel ? /* @__PURE__ */ jsxRuntime.jsx(SidebarGroupItem.HvFlowSidebarGroupItem, { label: draggingLabel, isDragging: true }) : null })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flow.cjs","sources":["../../../../src/components/Flow/Flow.tsx"],"sourcesContent":["import { useState } from \"react\";\n\nimport {\n DndContext,\n DndContextProps,\n DragOverlay,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport { restrictToWindowEdges } from \"@dnd-kit/modifiers\";\n\nimport { ReactFlowProvider } from \"reactflow\";\n\nimport { HvFlowNodeGroups, HvFlowNodeTypes } from \"./types\";\nimport { HvFlowProvider } from \"./FlowContext\";\nimport { HvDroppableFlow, HvDroppableFlowProps } from \"./DroppableFlow\";\nimport { HvFlowSidebarGroupItem } from \"./Sidebar/SidebarGroup/SidebarGroupItem\";\n\nexport interface HvFlowProps<\n NodeData = any,\n NodeType extends string | undefined = string | undefined,\n NodeGroups extends keyof any = string\n> extends HvDroppableFlowProps<NodeData, NodeType> {\n /** Flow nodes groups. */\n nodeGroups?: HvFlowNodeGroups<NodeGroups>;\n /** Flow nodes types. */\n nodeTypes?: HvFlowNodeTypes<NodeGroups>;\n /** Flow sidebar. */\n sidebar?: React.ReactNode;\n /**\n * Dnd Kit context props. This should be used for accessibility purposes.\n *\n * More information can be found on the [Dnd Kit documentation](https://docs.dndkit.com/guides/accessibility)\n */\n dndContextProps?: Pick<DndContextProps, \"accessibility\">;\n}\n\n/**\n * Flow component to build interactive node-based UIs.\n *\n * This implementation leverages [React Flow](https://reactflow.dev).\n * The drag and drop functionality leverages [Dnd Kit](https://docs.dndkit.com)\n *\n * DISCLAIMER: This component is a work in progress and there might be breaking changes.\n */\nexport const HvFlow = ({\n nodeTypes,\n nodeGroups,\n sidebar,\n dndContextProps,\n ...others\n}: HvFlowProps) => {\n const [draggingLabel, setDraggingLabel] = useState(undefined);\n\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor)\n );\n\n const handleDragStart: DndContextProps[\"onDragStart\"] = (event) => {\n if (event.active.data.current?.hvFlow) {\n setDraggingLabel(event.active.data.current.hvFlow?.label);\n }\n };\n\n const handleDragEnd: DndContextProps[\"onDragEnd\"] = () => {\n setDraggingLabel(undefined);\n };\n\n // We're wrapping the main Flow component with the ReactFlowProvider to access the react flow instance.\n // HvFlowContext is our custom internal context.\n return (\n <ReactFlowProvider>\n <HvFlowProvider
|
|
1
|
+
{"version":3,"file":"Flow.cjs","sources":["../../../../src/components/Flow/Flow.tsx"],"sourcesContent":["import { useState } from \"react\";\n\nimport {\n DndContext,\n DndContextProps,\n DragOverlay,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport { restrictToWindowEdges } from \"@dnd-kit/modifiers\";\n\nimport { ReactFlowProvider } from \"reactflow\";\n\nimport { HvActionGeneric } from \"@hitachivantara/uikit-react-core\";\nimport { HvFlowNodeGroups, HvFlowNodeTypes } from \"./types\";\nimport { HvFlowProvider } from \"./FlowContext\";\nimport { HvDroppableFlow, HvDroppableFlowProps } from \"./DroppableFlow\";\nimport { HvFlowSidebarGroupItem } from \"./Sidebar/SidebarGroup/SidebarGroupItem\";\n\nexport interface HvFlowProps<\n NodeData = any,\n NodeType extends string | undefined = string | undefined,\n NodeGroups extends keyof any = string\n> extends HvDroppableFlowProps<NodeData, NodeType> {\n /** Flow nodes groups. */\n nodeGroups?: HvFlowNodeGroups<NodeGroups>;\n /** Flow nodes types. */\n nodeTypes?: HvFlowNodeTypes<NodeGroups>;\n /** Flow sidebar. */\n sidebar?: React.ReactNode;\n /** Flow default actions. */\n defaultActions?: HvActionGeneric[];\n /**\n * Dnd Kit context props. This should be used for accessibility purposes.\n *\n * More information can be found on the [Dnd Kit documentation](https://docs.dndkit.com/guides/accessibility)\n */\n dndContextProps?: Pick<DndContextProps, \"accessibility\">;\n}\n\n/**\n * Flow component to build interactive node-based UIs.\n *\n * This implementation leverages [React Flow](https://reactflow.dev).\n * The drag and drop functionality leverages [Dnd Kit](https://docs.dndkit.com)\n *\n * DISCLAIMER: This component is a work in progress and there might be breaking changes.\n */\nexport const HvFlow = ({\n nodeTypes,\n nodeGroups,\n sidebar,\n defaultActions,\n dndContextProps,\n ...others\n}: HvFlowProps) => {\n const [draggingLabel, setDraggingLabel] = useState(undefined);\n\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor)\n );\n\n const handleDragStart: DndContextProps[\"onDragStart\"] = (event) => {\n if (event.active.data.current?.hvFlow) {\n setDraggingLabel(event.active.data.current.hvFlow?.label);\n }\n };\n\n const handleDragEnd: DndContextProps[\"onDragEnd\"] = () => {\n setDraggingLabel(undefined);\n };\n\n // We're wrapping the main Flow component with the ReactFlowProvider to access the react flow instance.\n // HvFlowContext is our custom internal context.\n return (\n <ReactFlowProvider>\n <HvFlowProvider\n nodeGroups={nodeGroups}\n nodeTypes={nodeTypes}\n defaultActions={defaultActions}\n >\n <DndContext\n onDragStart={handleDragStart}\n onDragEnd={handleDragEnd}\n sensors={sensors}\n modifiers={[restrictToWindowEdges]}\n {...dndContextProps}\n >\n <HvDroppableFlow {...others} />\n {sidebar}\n <DragOverlay modifiers={[restrictToWindowEdges]}>\n {draggingLabel ? (\n <HvFlowSidebarGroupItem label={draggingLabel} isDragging />\n ) : null}\n </DragOverlay>\n </DndContext>\n </HvFlowProvider>\n </ReactFlowProvider>\n );\n};\n"],"names":["HvFlow","nodeTypes","nodeGroups","sidebar","defaultActions","dndContextProps","others","draggingLabel","setDraggingLabel","useState","undefined","sensors","useSensors","useSensor","PointerSensor","KeyboardSensor","handleDragStart","event","active","data","current","hvFlow","label","handleDragEnd","ReactFlowProvider","jsx","HvFlowProvider","jsxs","DndContext","restrictToWindowEdges","HvDroppableFlow","DragOverlay","HvFlowSidebarGroupItem"],"mappings":";;;;;;;;;;AAkDO,MAAMA,SAASA,CAAC;AAAA,EACrBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AACQ,MAAM;AACjB,QAAM,CAACC,eAAeC,gBAAgB,IAAIC,MAAAA,SAASC,MAAS;AAE5D,QAAMC,UAAUC,KAAAA,WACdC,KAAAA,UAAUC,KAAa,aAAA,GACvBD,KAAAA,UAAUE,KAAc,cAAA,CAC1B;AAEA,QAAMC,kBAAmDC,CAAU,UAAA;;AACjE,SAAIA,WAAMC,OAAOC,KAAKC,YAAlBH,mBAA2BI,QAAQ;AACrCb,wBAAiBS,WAAMC,OAAOC,KAAKC,QAAQC,WAA1BJ,mBAAkCK,KAAK;AAAA,IAC1D;AAAA,EAAA;AAGF,QAAMC,gBAA8CA,MAAM;AACxDf,qBAAiBE,MAAS;AAAA,EAAA;AAK5B,wCACGc,UAAAA,mBACC,EAAA,UAAAC,2BAAA,IAACC,8BACC,YACA,WACA,gBAEA,UAACC,2BAAA,KAAAC,iBAAA,EACC,aAAaZ,iBACb,WAAWO,eACX,SACA,WAAW,CAACM,UAAqB,qBAAA,GACjC,GAAIxB,iBAEJ,UAAA;AAAA,IAACoB,2BAAAA,IAAAK,cAAA,iBAAA,EAAgB,GAAIxB,QAAO;AAAA,IAC3BH;AAAAA,IACAsB,2BAAA,IAAAM,KAAA,aAAA,EAAY,WAAW,CAACF,UAAAA,qBAAqB,GAC3CtB,UAAAA,gBACEkB,2BAAAA,IAAAO,iBAAAA,wBAAA,EAAuB,OAAOzB,eAAe,YAAU,KAAA,CAAA,IACtD,MACN;AAAA,EAAA,GACF,GACF,EACF,CAAA;AAEJ;;"}
|
|
@@ -6,15 +6,17 @@ const HvFlowContext = React.createContext({});
|
|
|
6
6
|
const HvFlowProvider = ({
|
|
7
7
|
nodeGroups,
|
|
8
8
|
nodeTypes,
|
|
9
|
+
defaultActions,
|
|
9
10
|
children
|
|
10
11
|
}) => {
|
|
11
12
|
const [expandedNodeGroups, setExpandedNodeGroups] = React.useState([]);
|
|
12
13
|
const value = React.useMemo(() => ({
|
|
13
14
|
nodeTypes,
|
|
14
15
|
nodeGroups,
|
|
16
|
+
defaultActions,
|
|
15
17
|
expandedNodeGroups,
|
|
16
18
|
setExpandedNodeGroups
|
|
17
|
-
}), [nodeGroups,
|
|
19
|
+
}), [nodeTypes, nodeGroups, defaultActions, expandedNodeGroups]);
|
|
18
20
|
return /* @__PURE__ */ jsxRuntime.jsx(HvFlowContext.Provider, { value, children });
|
|
19
21
|
};
|
|
20
22
|
const useFlowContext = () => React.useContext(HvFlowContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlowContext.cjs","sources":["../../../../../src/components/Flow/FlowContext/FlowContext.tsx"],"sourcesContent":["import {\n Dispatch,\n SetStateAction,\n createContext,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nimport { HvFlowNodeGroups, HvFlowNodeTypes } from \"../types\";\n\nexport interface HvFlowContextValue<NodeGroups extends keyof any = string> {\n /** Flow nodes types. */\n nodeTypes?: HvFlowNodeTypes<NodeGroups>;\n /** Flow nodes groups. */\n nodeGroups?: HvFlowNodeGroups<NodeGroups>;\n /** Flow nodes groups expanded on sidebar. */\n expandedNodeGroups?: string[];\n /** Function to set `expandedNodeGroups`. */\n setExpandedNodeGroups?: Dispatch<SetStateAction<string[]>>;\n}\n\nexport const HvFlowContext = createContext<HvFlowContextValue>({});\n\nexport interface HvFlowProviderProps<NodeGroups extends keyof any = string> {\n /** Flow nodes types. */\n nodeTypes?: HvFlowContextValue<NodeGroups>[\"nodeTypes\"];\n /** Flow nodes groups. */\n nodeGroups?: HvFlowContextValue<NodeGroups>[\"nodeGroups\"];\n /** Children. */\n children?: React.ReactNode;\n}\n\nexport const HvFlowProvider = ({\n nodeGroups,\n nodeTypes,\n children,\n}: HvFlowProviderProps) => {\n const [expandedNodeGroups, setExpandedNodeGroups] = useState<string[]>([]);\n\n const value = useMemo(\n () => ({\n nodeTypes,\n nodeGroups,\n expandedNodeGroups,\n setExpandedNodeGroups,\n }),\n [nodeGroups,
|
|
1
|
+
{"version":3,"file":"FlowContext.cjs","sources":["../../../../../src/components/Flow/FlowContext/FlowContext.tsx"],"sourcesContent":["import { HvActionGeneric } from \"@hitachivantara/uikit-react-core\";\nimport {\n Dispatch,\n SetStateAction,\n createContext,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nimport { HvFlowNodeGroups, HvFlowNodeTypes } from \"../types\";\n\nexport interface HvFlowContextValue<NodeGroups extends keyof any = string> {\n /** Flow nodes types. */\n nodeTypes?: HvFlowNodeTypes<NodeGroups>;\n /** Flow nodes groups. */\n nodeGroups?: HvFlowNodeGroups<NodeGroups>;\n /** Flow nodes groups expanded on sidebar. */\n expandedNodeGroups?: string[];\n /** Flow default actions. */\n defaultActions?: HvActionGeneric[];\n /** Function to set `expandedNodeGroups`. */\n setExpandedNodeGroups?: Dispatch<SetStateAction<string[]>>;\n}\n\nexport const HvFlowContext = createContext<HvFlowContextValue>({});\n\nexport interface HvFlowProviderProps<NodeGroups extends keyof any = string> {\n /** Flow nodes types. */\n nodeTypes?: HvFlowContextValue<NodeGroups>[\"nodeTypes\"];\n /** Flow nodes groups. */\n nodeGroups?: HvFlowContextValue<NodeGroups>[\"nodeGroups\"];\n /** Flow default actions. */\n defaultActions?: HvActionGeneric[];\n /** Children. */\n children?: React.ReactNode;\n}\n\nexport const HvFlowProvider = ({\n nodeGroups,\n nodeTypes,\n defaultActions,\n children,\n}: HvFlowProviderProps) => {\n const [expandedNodeGroups, setExpandedNodeGroups] = useState<string[]>([]);\n\n const value = useMemo(\n () => ({\n nodeTypes,\n nodeGroups,\n defaultActions,\n expandedNodeGroups,\n setExpandedNodeGroups,\n }),\n [nodeTypes, nodeGroups, defaultActions, expandedNodeGroups]\n );\n\n return (\n <HvFlowContext.Provider value={value}>{children}</HvFlowContext.Provider>\n );\n};\n\nexport const useFlowContext = () => useContext(HvFlowContext);\n"],"names":["HvFlowContext","createContext","HvFlowProvider","nodeGroups","nodeTypes","defaultActions","children","expandedNodeGroups","setExpandedNodeGroups","useState","value","useMemo","jsx","useFlowContext","useContext"],"mappings":";;;;AAyBaA,MAAAA,gBAAgBC,MAAkC,cAAA,EAAE;AAa1D,MAAMC,iBAAiBA,CAAC;AAAA,EAC7BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACmB,MAAM;AACzB,QAAM,CAACC,oBAAoBC,qBAAqB,IAAIC,MAAAA,SAAmB,CAAE,CAAA;AAEnEC,QAAAA,QAAQC,MAAAA,QACZ,OAAO;AAAA,IACLP;AAAAA,IACAD;AAAAA,IACAE;AAAAA,IACAE;AAAAA,IACAC;AAAAA,EAAAA,IAEF,CAACJ,WAAWD,YAAYE,gBAAgBE,kBAAkB,CAC5D;AAEA,SACGK,2BAAAA,IAAA,cAAc,UAAd,EAAuB,OAAeN,SAAS,CAAA;AAEpD;AAEaO,MAAAA,iBAAiBA,MAAMC,MAAAA,WAAWd,aAAa;;;;"}
|
|
@@ -20,15 +20,18 @@ const isInputConnected = (id, type, idx, edges) => {
|
|
|
20
20
|
const HvFlowNode = ({
|
|
21
21
|
id,
|
|
22
22
|
type,
|
|
23
|
-
title,
|
|
24
23
|
description,
|
|
25
24
|
expanded = false,
|
|
26
25
|
params,
|
|
26
|
+
actions,
|
|
27
|
+
actionCallback,
|
|
28
|
+
maxVisibleActions = 1,
|
|
27
29
|
classes: classesProp,
|
|
28
30
|
className
|
|
29
31
|
}) => {
|
|
30
|
-
var _a, _b, _c, _d, _e;
|
|
32
|
+
var _a, _b, _c, _d, _e, _f;
|
|
31
33
|
const [showParams, setShowParams] = React.useState(expanded);
|
|
34
|
+
const [showActions, setShowActions] = React.useState(false);
|
|
32
35
|
const reactFlowInstance = ReactFlow.useReactFlow();
|
|
33
36
|
const {
|
|
34
37
|
classes,
|
|
@@ -37,15 +40,17 @@ const HvFlowNode = ({
|
|
|
37
40
|
} = Node_styles.useClasses(classesProp);
|
|
38
41
|
const {
|
|
39
42
|
nodeGroups,
|
|
40
|
-
nodeTypes
|
|
43
|
+
nodeTypes,
|
|
44
|
+
defaultActions
|
|
41
45
|
} = FlowContext.useFlowContext();
|
|
42
46
|
const edges = ReactFlow.useStore((s) => s.edges);
|
|
43
47
|
const nodes = ReactFlow.useStore((s) => s.getNodes());
|
|
44
48
|
const node = nodes.find((n) => n.id === id);
|
|
45
49
|
const groupId = (_a = nodeTypes == null ? void 0 : nodeTypes[type].meta) == null ? void 0 : _a.groupId;
|
|
50
|
+
const title = (_b = nodeTypes == null ? void 0 : nodeTypes[type].meta) == null ? void 0 : _b.label;
|
|
46
51
|
const groupLabel = groupId && nodeGroups && nodeGroups[groupId].label;
|
|
47
|
-
const inputs = (
|
|
48
|
-
const outputs = (
|
|
52
|
+
const inputs = (_d = (_c = nodeTypes == null ? void 0 : nodeTypes[type]) == null ? void 0 : _c.meta) == null ? void 0 : _d.inputs;
|
|
53
|
+
const outputs = (_f = (_e = nodeTypes == null ? void 0 : nodeTypes[type]) == null ? void 0 : _e.meta) == null ? void 0 : _f.outputs;
|
|
49
54
|
const icon = groupId && nodeGroups && nodeGroups[groupId].icon;
|
|
50
55
|
const colorProp = groupId && nodeGroups && nodeGroups[groupId].color;
|
|
51
56
|
const color = uikitStyles.getColor(colorProp);
|
|
@@ -62,10 +67,39 @@ const HvFlowNode = ({
|
|
|
62
67
|
});
|
|
63
68
|
reactFlowInstance.setNodes(newNodes);
|
|
64
69
|
}, []);
|
|
70
|
+
const handleDefaultAction = React.useCallback((action) => {
|
|
71
|
+
if (!node)
|
|
72
|
+
return;
|
|
73
|
+
switch (action) {
|
|
74
|
+
case "delete":
|
|
75
|
+
reactFlowInstance.deleteElements({
|
|
76
|
+
nodes: [node]
|
|
77
|
+
});
|
|
78
|
+
break;
|
|
79
|
+
case "duplicate":
|
|
80
|
+
reactFlowInstance.addNodes([{
|
|
81
|
+
...node,
|
|
82
|
+
id: `${reactFlowInstance.getNodes().length + 1}`,
|
|
83
|
+
position: {
|
|
84
|
+
x: node.position.x,
|
|
85
|
+
y: node.position.y + (node.height || 0) + 20
|
|
86
|
+
},
|
|
87
|
+
selected: false,
|
|
88
|
+
zIndex: Number(uikitStyles.theme.zIndices.overlay)
|
|
89
|
+
}]);
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}, [node, reactFlowInstance]);
|
|
65
93
|
const hasParams = !!(params && params.length > 0);
|
|
94
|
+
if (!node)
|
|
95
|
+
return null;
|
|
96
|
+
const actsVisible = actions == null ? void 0 : actions.slice(0, maxVisibleActions);
|
|
97
|
+
const actsDropdown = actions == null ? void 0 : actions.slice(maxVisibleActions);
|
|
98
|
+
const renderedIcon = (actionIcon) => React.isValidElement(actionIcon) ? actionIcon : actionIcon == null ? void 0 : actionIcon();
|
|
66
99
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx(css({
|
|
67
100
|
border: `1px solid ${color}`
|
|
68
|
-
}), classes.root, className), children: [
|
|
101
|
+
}), classes.root, className), onMouseEnter: () => setShowActions(true), onMouseLeave: () => setShowActions(false), children: [
|
|
102
|
+
/* @__PURE__ */ jsxRuntime.jsx(ReactFlow.NodeToolbar, { isVisible: showActions, offset: 0, children: defaultActions == null ? void 0 : defaultActions.map((action) => /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvButton, { icon: true, onClick: () => handleDefaultAction(action.id), children: renderedIcon(action.icon) })) }),
|
|
69
103
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx(css({
|
|
70
104
|
backgroundColor: color
|
|
71
105
|
}), classes.headerContainer), children: [
|
|
@@ -80,7 +114,20 @@ const HvFlowNode = ({
|
|
|
80
114
|
/* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvButton, { icon: true, disabled: !hasParams, onClick: () => setShowParams((p) => !p), children: showParams ? /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Up, {}) : /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Down, {}) })
|
|
81
115
|
] })
|
|
82
116
|
] }),
|
|
83
|
-
/* @__PURE__ */ jsxRuntime.
|
|
117
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes.titleContainer, children: [
|
|
118
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { children: title }) }),
|
|
119
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.actions, children: (actions == null ? void 0 : actions.length) && (actions == null ? void 0 : actions.length) > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
120
|
+
actsVisible == null ? void 0 : actsVisible.map((action) => /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTooltip, { title: /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { children: action.label }), children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvButton, { icon: true, onClick: (event) => {
|
|
121
|
+
actionCallback == null ? void 0 : actionCallback(event, node.id, action);
|
|
122
|
+
}, children: renderedIcon(action.icon) }) }) })),
|
|
123
|
+
actsDropdown && actsDropdown.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvDropDownMenu, { keepOpened: false, dataList: actsDropdown == null ? void 0 : actsDropdown.map((action) => ({
|
|
124
|
+
id: action.id,
|
|
125
|
+
label: action.label
|
|
126
|
+
})), onClick: (event, action) => {
|
|
127
|
+
actionCallback == null ? void 0 : actionCallback(event, node.id, action);
|
|
128
|
+
} })
|
|
129
|
+
] }) })
|
|
130
|
+
] }),
|
|
84
131
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.inputsTitleContainer, children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, { children: "Inputs" }) }),
|
|
85
132
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.inputsContainer, children: inputs == null ? void 0 : inputs.map((input, idx) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes.inputContainer, children: [
|
|
86
133
|
/* @__PURE__ */ jsxRuntime.jsx(ReactFlow.Handle, { type: "target", isConnectableStart: false, id: `${idx}`, position: ReactFlow.Position.Left, style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Node.cjs","sources":["../../../../../src/components/Flow/Node/Node.tsx"],"sourcesContent":["import {\n ExtractNames,\n HvBaseProps,\n HvButton,\n HvTooltip,\n HvTypography,\n} from \"@hitachivantara/uikit-react-core\";\nimport { Down, Info, Up } from \"@hitachivantara/uikit-react-icons\";\nimport { getColor } from \"@hitachivantara/uikit-styles\";\nimport { useEffect, useState } from \"react\";\nimport { Handle, NodeProps, Position, useReactFlow, useStore } from \"reactflow\";\nimport { useFlowContext } from \"../FlowContext/FlowContext\";\n\nimport { HvFlowNodeInput, HvFlowNodeOutput, HvFlowNodeParam } from \"../types\";\nimport { staticClasses, useClasses } from \"./Node.styles\";\nimport ParamRenderer from \"./Parameters/ParamRenderer\";\n\nexport { staticClasses as flowNodeClasses };\n\nexport type HvFlowNodeClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFlowNodeProps extends Omit<HvBaseProps, \"id\">, NodeProps {\n /** Node title */\n title: string;\n /** Node description */\n description: string;\n /** Node expanded */\n expanded?: boolean;\n /** Node inputs */\n inputs?: HvFlowNodeInput[];\n /** Node outputs */\n outputs?: HvFlowNodeOutput[];\n /** Node parameters */\n params?: HvFlowNodeParam[];\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowNodeClasses;\n}\n\nconst isInputConnected = (id, type, idx, edges) => {\n if (type === \"target\") {\n return edges.some(\n (e) => e.target === id && e.targetHandle === idx.toString()\n );\n }\n if (type === \"source\") {\n return edges.some(\n (e) => e.source === id && e.sourceHandle === idx.toString()\n );\n }\n};\n\nexport const HvFlowNode = ({\n id,\n type,\n title,\n description,\n expanded = false,\n params,\n classes: classesProp,\n className,\n}: HvFlowNodeProps) => {\n const [showParams, setShowParams] = useState(expanded);\n const reactFlowInstance = useReactFlow();\n\n const { classes, cx, css } = useClasses(classesProp);\n\n const { nodeGroups, nodeTypes } = useFlowContext();\n const edges = useStore((s) => s.edges);\n const nodes = useStore((s) => s.getNodes());\n\n const node = nodes.find((n) => n.id === id);\n\n const groupId = nodeTypes?.[type].meta?.groupId;\n const groupLabel = groupId && nodeGroups && nodeGroups[groupId].label;\n const inputs = nodeTypes?.[type]?.meta?.inputs;\n const outputs = nodeTypes?.[type]?.meta?.outputs;\n const icon = groupId && nodeGroups && nodeGroups[groupId].icon;\n const colorProp = groupId && nodeGroups && nodeGroups[groupId].color;\n const color = getColor(colorProp);\n\n useEffect(() => {\n const newNodes = nodes.map((n) => {\n if (n.id === id) {\n if (Object.keys(n.data).length === 0) {\n params?.forEach((param) => {\n n.data[param.label] = param.value;\n });\n }\n }\n return n;\n });\n reactFlowInstance.setNodes(newNodes);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const hasParams = !!(params && params.length > 0);\n\n return (\n <div\n className={cx(\n css({ border: `1px solid ${color}` }),\n classes.root,\n className\n )}\n >\n <div\n className={cx(css({ backgroundColor: color }), classes.headerContainer)}\n >\n <div className={classes.groupContainer}>\n {icon}\n <HvTypography variant=\"title4\" className={classes.group}>\n {groupLabel}\n </HvTypography>\n </div>\n <div style={{ display: \"flex\" }}>\n <HvTooltip title={<HvTypography>{description}</HvTypography>}>\n <div>\n <Info />\n </div>\n </HvTooltip>\n <HvButton\n icon\n disabled={!hasParams}\n onClick={() => setShowParams((p) => !p)}\n >\n {showParams ? <Up /> : <Down />}\n </HvButton>\n </div>\n </div>\n <div className={classes.titleContainer}>\n <HvTypography>{title}</HvTypography>\n </div>\n <div className={classes.inputsTitleContainer}>\n <HvTypography>Inputs</HvTypography>\n </div>\n <div className={classes.inputsContainer}>\n {inputs?.map((input, idx) => (\n <div className={classes.inputContainer} key={idx}>\n <Handle\n type=\"target\"\n isConnectableStart={false}\n id={`${idx}`}\n position={Position.Left}\n style={{\n top: 160 + 29 * idx,\n }}\n />\n <HvTypography>{input.label}</HvTypography>\n {input.isMandatory &&\n !isInputConnected(id, \"target\", idx, edges) && (\n <div className={classes.mandatory} />\n )}\n </div>\n ))}\n </div>\n {showParams && params && (\n <div className={classes.paramsContainer}>\n <ParamRenderer nodeId={id} params={params} data={node?.data} />\n </div>\n )}\n <div className={classes.outputsTitleContainer}>\n <HvTypography>Outputs</HvTypography>\n </div>\n <div className={classes.outputsContainer}>\n {outputs?.map((output, idx) => (\n <div className={classes.outputContainer} key={idx}>\n <Handle\n type=\"source\"\n isConnectableEnd={false}\n id={`${idx}`}\n position={Position.Right}\n style={{\n bottom: -8 + 29 * (outputs.length - idx),\n top: \"auto\",\n }}\n />\n {output.isMandatory &&\n !isInputConnected(id, \"source\", idx, edges) && (\n <div className={classes.mandatory} />\n )}\n <HvTypography>{output.label}</HvTypography>\n </div>\n ))}\n </div>\n </div>\n );\n};\n"],"names":["isInputConnected","id","type","idx","edges","some","e","target","targetHandle","toString","source","sourceHandle","HvFlowNode","title","description","expanded","params","classes","classesProp","className","showParams","setShowParams","useState","reactFlowInstance","useReactFlow","cx","css","useClasses","nodeGroups","nodeTypes","useFlowContext","useStore","s","nodes","getNodes","node","find","n","groupId","meta","groupLabel","label","inputs","outputs","icon","colorProp","color","getColor","useEffect","newNodes","map","Object","keys","data","length","forEach","param","value","setNodes","hasParams","jsxs","border","root","backgroundColor","headerContainer","groupContainer","HvTypography","group","display","jsx","HvTooltip","Info","HvButton","p","Up","Down","titleContainer","inputsTitleContainer","inputsContainer","input","inputContainer","Handle","Position","Left","top","isMandatory","mandatory","paramsContainer","ParamRenderer","outputsTitleContainer","outputsContainer","output","outputContainer","Right","bottom"],"mappings":";;;;;;;;;;;AAsCA,MAAMA,mBAAmBA,CAACC,IAAIC,MAAMC,KAAKC,UAAU;AACjD,MAAIF,SAAS,UAAU;AACdE,WAAAA,MAAMC,KACVC,CAAAA,MAAMA,EAAEC,WAAWN,MAAMK,EAAEE,iBAAiBL,IAAIM,SACnD,CAAA;AAAA,EACF;AACA,MAAIP,SAAS,UAAU;AACdE,WAAAA,MAAMC,KACVC,CAAAA,MAAMA,EAAEI,WAAWT,MAAMK,EAAEK,iBAAiBR,IAAIM,SACnD,CAAA;AAAA,EACF;AACF;AAEO,MAAMG,aAAaA,CAAC;AAAA,EACzBX;AAAAA,EACAC;AAAAA,EACAW;AAAAA,EACAC;AAAAA,EACAC,WAAW;AAAA,EACXC;AAAAA,EACAC,SAASC;AAAAA,EACTC;AACe,MAAM;;AACrB,QAAM,CAACC,YAAYC,aAAa,IAAIC,eAASP,QAAQ;AACrD,QAAMQ,oBAAoBC,UAAAA;AAEpB,QAAA;AAAA,IAAEP;AAAAA,IAASQ;AAAAA,IAAIC;AAAAA,EAAAA,IAAQC,YAAAA,WAAWT,WAAW;AAE7C,QAAA;AAAA,IAAEU;AAAAA,IAAYC;AAAAA,MAAcC,YAAe,eAAA;AACjD,QAAM1B,QAAQ2B,UAAAA,SAAUC,CAAMA,MAAAA,EAAE5B,KAAK;AACrC,QAAM6B,QAAQF,UAAAA,SAAUC,CAAMA,MAAAA,EAAEE,UAAU;AAE1C,QAAMC,OAAOF,MAAMG,KAAMC,CAAMA,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ow/Node/Node.tsx"],"sourcesContent":["import {\n ExtractNames,\n HvActionGeneric,\n HvActionsGenericProps,\n HvBaseProps,\n HvButton,\n HvDropDownMenu,\n HvTooltip,\n HvTypography,\n} from \"@hitachivantara/uikit-react-core\";\nimport { Down, Info, Up } from \"@hitachivantara/uikit-react-icons\";\nimport { getColor, theme } from \"@hitachivantara/uikit-styles\";\nimport { isValidElement, useCallback, useEffect, useState } from \"react\";\nimport {\n Handle,\n NodeProps,\n NodeToolbar,\n Position,\n useReactFlow,\n useStore,\n} from \"reactflow\";\nimport { useFlowContext } from \"../FlowContext/FlowContext\";\n\nimport { HvFlowNodeInput, HvFlowNodeOutput, HvFlowNodeParam } from \"../types\";\nimport { staticClasses, useClasses } from \"./Node.styles\";\nimport ParamRenderer from \"./Parameters/ParamRenderer\";\n\nexport { staticClasses as flowNodeClasses };\n\nexport type HvFlowNodeClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFlowNodeProps extends Omit<HvBaseProps, \"id\">, NodeProps {\n /** Node description */\n description: string;\n /** Node expanded */\n expanded?: boolean;\n /** Node inputs */\n inputs?: HvFlowNodeInput[];\n /** Node outputs */\n outputs?: HvFlowNodeOutput[];\n /** Node parameters */\n params?: HvFlowNodeParam[];\n /** Node actions */\n actions?: HvActionGeneric[]; // HvFlowNodeActions[];\n /** Node action callback */\n actionCallback?: HvActionsGenericProps[\"actionsCallback\"];\n /** Node maximum number of actions visible */\n maxVisibleActions?: number;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowNodeClasses;\n}\n\nconst isInputConnected = (id, type, idx, edges) => {\n if (type === \"target\") {\n return edges.some(\n (e) => e.target === id && e.targetHandle === idx.toString()\n );\n }\n if (type === \"source\") {\n return edges.some(\n (e) => e.source === id && e.sourceHandle === idx.toString()\n );\n }\n};\n\nexport const HvFlowNode = ({\n id,\n type,\n description,\n expanded = false,\n params,\n actions,\n actionCallback,\n maxVisibleActions = 1,\n classes: classesProp,\n className,\n}: HvFlowNodeProps) => {\n const [showParams, setShowParams] = useState(expanded);\n const [showActions, setShowActions] = useState(false);\n const reactFlowInstance = useReactFlow();\n\n const { classes, cx, css } = useClasses(classesProp);\n\n const { nodeGroups, nodeTypes, defaultActions } = useFlowContext();\n const edges = useStore((s) => s.edges);\n const nodes = useStore((s) => s.getNodes());\n\n const node = nodes.find((n) => n.id === id);\n\n const groupId = nodeTypes?.[type].meta?.groupId;\n const title = nodeTypes?.[type].meta?.label;\n const groupLabel = groupId && nodeGroups && nodeGroups[groupId].label;\n\n const inputs = nodeTypes?.[type]?.meta?.inputs;\n const outputs = nodeTypes?.[type]?.meta?.outputs;\n const icon = groupId && nodeGroups && nodeGroups[groupId].icon;\n const colorProp = groupId && nodeGroups && nodeGroups[groupId].color;\n const color = getColor(colorProp);\n\n useEffect(() => {\n const newNodes = nodes.map((n) => {\n if (n.id === id) {\n if (Object.keys(n.data).length === 0) {\n params?.forEach((param) => {\n n.data[param.label] = param.value;\n });\n }\n }\n return n;\n });\n reactFlowInstance.setNodes(newNodes);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const handleDefaultAction = useCallback(\n (action: string) => {\n if (!node) return;\n\n switch (action) {\n case \"delete\":\n reactFlowInstance.deleteElements({ nodes: [node] });\n break;\n case \"duplicate\":\n reactFlowInstance.addNodes([\n {\n ...node,\n id: `${reactFlowInstance.getNodes().length + 1}`,\n position: {\n x: node.position.x,\n y: node.position.y + (node.height || 0) + 20,\n },\n selected: false,\n zIndex: Number(theme.zIndices.overlay),\n },\n ]);\n break;\n default:\n break;\n }\n },\n [node, reactFlowInstance]\n );\n\n const hasParams = !!(params && params.length > 0);\n\n if (!node) return null;\n\n const actsVisible = actions?.slice(0, maxVisibleActions);\n const actsDropdown = actions?.slice(maxVisibleActions);\n\n const renderedIcon = (actionIcon: HvActionGeneric[\"icon\"]) =>\n isValidElement(actionIcon) ? actionIcon : (actionIcon as Function)?.();\n\n return (\n <div\n className={cx(\n css({ border: `1px solid ${color}` }),\n classes.root,\n className\n )}\n onMouseEnter={() => setShowActions(true)}\n onMouseLeave={() => setShowActions(false)}\n >\n <NodeToolbar isVisible={showActions} offset={0}>\n {defaultActions?.map((action) => (\n <HvButton icon onClick={() => handleDefaultAction(action.id)}>\n {renderedIcon(action.icon)}\n </HvButton>\n ))}\n </NodeToolbar>\n <div\n className={cx(css({ backgroundColor: color }), classes.headerContainer)}\n >\n <div className={classes.groupContainer}>\n {icon}\n <HvTypography variant=\"title4\" className={classes.group}>\n {groupLabel}\n </HvTypography>\n </div>\n <div style={{ display: \"flex\" }}>\n <HvTooltip title={<HvTypography>{description}</HvTypography>}>\n <div>\n <Info />\n </div>\n </HvTooltip>\n <HvButton\n icon\n disabled={!hasParams}\n onClick={() => setShowParams((p) => !p)}\n >\n {showParams ? <Up /> : <Down />}\n </HvButton>\n </div>\n </div>\n <div className={classes.titleContainer}>\n <div>\n <HvTypography>{title}</HvTypography>\n </div>\n <div className={classes.actions}>\n {actions?.length && actions?.length > 0 && (\n <>\n {actsVisible?.map((action) => (\n <HvTooltip title={<HvTypography>{action.label}</HvTypography>}>\n <div>\n <HvButton\n icon\n onClick={(event) => {\n actionCallback?.(event, node.id, action);\n }}\n >\n {renderedIcon(action.icon)}\n </HvButton>\n </div>\n </HvTooltip>\n ))}\n\n {actsDropdown && actsDropdown.length > 0 && (\n <HvDropDownMenu\n keepOpened={false}\n dataList={actsDropdown?.map((action) => ({\n id: action.id,\n label: action.label,\n }))}\n onClick={(event, action) => {\n actionCallback?.(event, node.id, action as HvActionGeneric);\n }}\n />\n )}\n </>\n )}\n </div>\n </div>\n <div className={classes.inputsTitleContainer}>\n <HvTypography>Inputs</HvTypography>\n </div>\n <div className={classes.inputsContainer}>\n {inputs?.map((input, idx) => (\n <div className={classes.inputContainer} key={idx}>\n <Handle\n type=\"target\"\n isConnectableStart={false}\n id={`${idx}`}\n position={Position.Left}\n style={{\n top: 160 + 29 * idx,\n }}\n />\n <HvTypography>{input.label}</HvTypography>\n {input.isMandatory &&\n !isInputConnected(id, \"target\", idx, edges) && (\n <div className={classes.mandatory} />\n )}\n </div>\n ))}\n </div>\n {showParams && params && (\n <div className={classes.paramsContainer}>\n <ParamRenderer nodeId={id} params={params} data={node?.data} />\n </div>\n )}\n <div className={classes.outputsTitleContainer}>\n <HvTypography>Outputs</HvTypography>\n </div>\n <div className={classes.outputsContainer}>\n {outputs?.map((output, idx) => (\n <div className={classes.outputContainer} key={idx}>\n <Handle\n type=\"source\"\n isConnectableEnd={false}\n id={`${idx}`}\n position={Position.Right}\n style={{\n bottom: -8 + 29 * (outputs.length - idx),\n top: \"auto\",\n }}\n />\n {output.isMandatory &&\n !isInputConnected(id, \"source\", idx, edges) && (\n <div className={classes.mandatory} />\n )}\n <HvTypography>{output.label}</HvTypography>\n </div>\n ))}\n </div>\n </div>\n );\n};\n"],"names":["isInputConnected","id","type","idx","edges","some","e","target","targetHandle","toString","source","sourceHandle","HvFlowNode","description","expanded","params","actions","actionCallback","maxVisibleActions","classes","classesProp","className","showParams","setShowParams","useState","showActions","setShowActions","reactFlowInstance","useReactFlow","cx","css","useClasses","nodeGroups","nodeTypes","defaultActions","useFlowContext","useStore","s","nodes","getNodes","node","find","n","groupId","meta","title","label","groupLabel","inputs","outputs","icon","colorProp","color","getColor","useEffect","newNodes","map","Object","keys","data","length","forEach","param","value","setNodes","handleDefaultAction","useCallback","action","deleteElements","addNodes","position","x","y","height","selected","zIndex","Number","theme","zIndices","overlay","hasParams","actsVisible","slice","actsDropdown","renderedIcon","actionIcon","isValidElement","jsxs","border","root","jsx","NodeToolbar","HvButton","backgroundColor","headerContainer","groupContainer","HvTypography","group","display","HvTooltip","Info","p","Up","Down","titleContainer","event","HvDropDownMenu","inputsTitleContainer","inputsContainer","input","inputContainer","Handle","Position","Left","top","isMandatory","mandatory","paramsContainer","ParamRenderer","outputsTitleContainer","outputsContainer","output","outputContainer","Right","bottom"],"mappings":";;;;;;;;;;;AAoDA,MAAMA,mBAAmBA,CAACC,IAAIC,MAA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G,iBACtB,UAAA;AAAA,MAAAhC,2BAAA,IAACqB,UACC,QAAA,EAAA,MAAK,UACL,kBAAkB,OAClB,IAAK,GAAE5G,GAAI,IACX,UAAU6G,UAAAA,SAASW,OACnB,OAAO;AAAA,QACLC,QAAQ,KAAK,MAAM3E,QAAQW,SAASzD;AAAAA,QACpC+G,KAAK;AAAA,MAAA,GACL;AAAA,MAEHO,OAAON,eACN,CAACnH,iBAAiBC,IAAI,UAAUE,KAAKC,KAAK,KACxCsF,2BAAAA,IAAC,OAAI,EAAA,WAAWvE,QAAQiG,UACzB,CAAA;AAAA,MACH1B,2BAAAA,IAACM,eAAAA,cAAcyB,EAAAA,UAAAA,OAAO3E,MAAM,CAAA;AAAA,IAAA,KAfgB3C,GAgB9C,IAEJ;AAAA,EACF,EAAA,CAAA;AAEJ;;;"}
|
|
@@ -27,7 +27,15 @@ const {
|
|
|
27
27
|
color: uikitReactCore.theme.colors.base_dark
|
|
28
28
|
},
|
|
29
29
|
titleContainer: {
|
|
30
|
-
padding: uikitReactCore.theme.space.sm
|
|
30
|
+
padding: uikitReactCore.theme.spacing(uikitReactCore.theme.space.xs, uikitReactCore.theme.space.xs, uikitReactCore.theme.space.xs, uikitReactCore.theme.space.sm),
|
|
31
|
+
display: "flex",
|
|
32
|
+
flexDirection: "row",
|
|
33
|
+
justifyContent: "space-between",
|
|
34
|
+
alignItems: "center"
|
|
35
|
+
},
|
|
36
|
+
actions: {
|
|
37
|
+
display: "flex",
|
|
38
|
+
alignItems: "center"
|
|
31
39
|
},
|
|
32
40
|
inputsTitleContainer: {
|
|
33
41
|
display: "flex",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Node.styles.cjs","sources":["../../../../../src/components/Flow/Node/Node.styles.tsx"],"sourcesContent":["import { createClasses, theme } from \"@hitachivantara/uikit-react-core\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFlowNode\", {\n root: {\n borderRadius: theme.radii.round,\n backgroundColor: theme.colors.atmo1,\n boxShadow: theme.colors.shadow,\n minWidth: \"250px\",\n },\n headerContainer: {\n padding: theme.spacing(0.5, 1),\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n },\n groupContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n },\n group: {\n color: theme.colors.base_dark,\n },\n titleContainer: {
|
|
1
|
+
{"version":3,"file":"Node.styles.cjs","sources":["../../../../../src/components/Flow/Node/Node.styles.tsx"],"sourcesContent":["import { createClasses, theme } from \"@hitachivantara/uikit-react-core\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFlowNode\", {\n root: {\n borderRadius: theme.radii.round,\n backgroundColor: theme.colors.atmo1,\n boxShadow: theme.colors.shadow,\n minWidth: \"250px\",\n },\n headerContainer: {\n padding: theme.spacing(0.5, 1),\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n },\n groupContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n },\n group: {\n color: theme.colors.base_dark,\n },\n titleContainer: {\n padding: theme.spacing(\n theme.space.xs,\n theme.space.xs,\n theme.space.xs,\n theme.space.sm\n ),\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n },\n actions: {\n display: \"flex\",\n alignItems: \"center\",\n },\n inputsTitleContainer: {\n display: \"flex\",\n justifyContent: \"center\",\n padding: theme.space.xs,\n backgroundColor: theme.colors.atmo2,\n borderTop: `1px solid ${theme.colors.atmo4}`,\n borderBottom: `1px solid ${theme.colors.atmo4}`,\n },\n outputsTitleContainer: {\n display: \"flex\",\n justifyContent: \"center\",\n padding: theme.space.xs,\n backgroundColor: theme.colors.atmo2,\n borderTop: `1px solid ${theme.colors.atmo4}`,\n borderBottom: `1px solid ${theme.colors.atmo4}`,\n },\n inputsContainer: {\n display: \"flex\",\n flexDirection: \"column\",\n padding: theme.space.sm,\n gap: theme.space.xs,\n alignItems: \"flex-start\",\n },\n outputsContainer: {\n display: \"flex\",\n flexDirection: \"column\",\n padding: theme.space.sm,\n gap: theme.space.xs,\n alignItems: \"flex-end\",\n },\n paramsContainer: {\n borderTop: `1px solid ${theme.colors.atmo4}`,\n display: \"flex\",\n flexDirection: \"column\",\n gap: theme.space.xs,\n padding: theme.space.sm,\n },\n inputContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n },\n outputContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n },\n mandatory: {\n width: 10,\n height: 10,\n margin: theme.spacing(0, theme.space.xs),\n borderRadius: theme.radii.circle,\n backgroundColor: theme.colors.negative_20,\n },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","borderRadius","theme","radii","round","backgroundColor","colors","atmo1","boxShadow","shadow","minWidth","headerContainer","padding","spacing","display","flexDirection","justifyContent","alignItems","groupContainer","group","color","base_dark","titleContainer","space","xs","sm","actions","inputsTitleContainer","atmo2","borderTop","atmo4","borderBottom","outputsTitleContainer","inputsContainer","gap","outputsContainer","paramsContainer","inputContainer","outputContainer","mandatory","width","height","margin","circle","negative_20"],"mappings":";;;AAEa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,eAAAA,cAAc,cAAc;AAAA,EACvEC,MAAM;AAAA,IACJC,cAAcC,eAAAA,MAAMC,MAAMC;AAAAA,IAC1BC,iBAAiBH,eAAAA,MAAMI,OAAOC;AAAAA,IAC9BC,WAAWN,eAAAA,MAAMI,OAAOG;AAAAA,IACxBC,UAAU;AAAA,EACZ;AAAA,EACAC,iBAAiB;AAAA,IACfC,SAASV,eAAAA,MAAMW,QAAQ,KAAK,CAAC;AAAA,IAC7BC,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,gBAAgB;AAAA,IAChBC,YAAY;AAAA,EACd;AAAA,EACAC,gBAAgB;AAAA,IACdJ,SAAS;AAAA,IACTC,eAAe;AAAA,IACfE,YAAY;AAAA,EACd;AAAA,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AAAAA,IACrBS,KAAKhC,eAAAA,MAAMqB,MAAMC;AAAAA,IACjBP,YAAY;AAAA,EACd;AAAA,EACAmB,iBAAiB;AAAA,IACfP,WAAY,aAAY3B,eAAMI,MAAAA,OAAOwB,KAAM;AAAA,IAC3ChB,SAAS;AAAA,IACTC,eAAe;AAAA,IACfmB,KAAKhC,eAAAA,MAAMqB,MAAMC;AAAAA,IACjBZ,SAASV,eAAAA,MAAMqB,MAAME;AAAAA,EACvB;AAAA,EACAY,gBAAgB;AAAA,IACdvB,SAAS;AAAA,IACTC,eAAe;AAAA,IACfE,YAAY;AAAA,EACd;AAAA,EACAqB,iBAAiB;AAAA,IACfxB,SAAS;AAAA,IACTC,eAAe;AAAA,IACfE,YAAY;AAAA,EACd;AAAA,EACAsB,WAAW;AAAA,IACTC,OAAO;AAAA,IACPC,QAAQ;AAAA,IACRC,QAAQxC,eAAMW,MAAAA,QAAQ,GAAGX,eAAAA,MAAMqB,MAAMC,EAAE;AAAA,IACvCvB,cAAcC,eAAAA,MAAMC,MAAMwC;AAAAA,IAC1BtC,iBAAiBH,eAAAA,MAAMI,OAAOsC;AAAAA,EAChC;AACF,CAAC;;;"}
|
|
@@ -10,6 +10,7 @@ const HvFlow = ({
|
|
|
10
10
|
nodeTypes,
|
|
11
11
|
nodeGroups,
|
|
12
12
|
sidebar,
|
|
13
|
+
defaultActions,
|
|
13
14
|
dndContextProps,
|
|
14
15
|
...others
|
|
15
16
|
}) => {
|
|
@@ -24,7 +25,7 @@ const HvFlow = ({
|
|
|
24
25
|
const handleDragEnd = () => {
|
|
25
26
|
setDraggingLabel(void 0);
|
|
26
27
|
};
|
|
27
|
-
return /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(HvFlowProvider, { nodeGroups, nodeTypes, children: /* @__PURE__ */ jsxs(DndContext, { onDragStart: handleDragStart, onDragEnd: handleDragEnd, sensors, modifiers: [restrictToWindowEdges], ...dndContextProps, children: [
|
|
28
|
+
return /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(HvFlowProvider, { nodeGroups, nodeTypes, defaultActions, children: /* @__PURE__ */ jsxs(DndContext, { onDragStart: handleDragStart, onDragEnd: handleDragEnd, sensors, modifiers: [restrictToWindowEdges], ...dndContextProps, children: [
|
|
28
29
|
/* @__PURE__ */ jsx(HvDroppableFlow, { ...others }),
|
|
29
30
|
sidebar,
|
|
30
31
|
/* @__PURE__ */ jsx(DragOverlay, { modifiers: [restrictToWindowEdges], children: draggingLabel ? /* @__PURE__ */ jsx(HvFlowSidebarGroupItem, { label: draggingLabel, isDragging: true }) : null })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flow.js","sources":["../../../../src/components/Flow/Flow.tsx"],"sourcesContent":["import { useState } from \"react\";\n\nimport {\n DndContext,\n DndContextProps,\n DragOverlay,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport { restrictToWindowEdges } from \"@dnd-kit/modifiers\";\n\nimport { ReactFlowProvider } from \"reactflow\";\n\nimport { HvFlowNodeGroups, HvFlowNodeTypes } from \"./types\";\nimport { HvFlowProvider } from \"./FlowContext\";\nimport { HvDroppableFlow, HvDroppableFlowProps } from \"./DroppableFlow\";\nimport { HvFlowSidebarGroupItem } from \"./Sidebar/SidebarGroup/SidebarGroupItem\";\n\nexport interface HvFlowProps<\n NodeData = any,\n NodeType extends string | undefined = string | undefined,\n NodeGroups extends keyof any = string\n> extends HvDroppableFlowProps<NodeData, NodeType> {\n /** Flow nodes groups. */\n nodeGroups?: HvFlowNodeGroups<NodeGroups>;\n /** Flow nodes types. */\n nodeTypes?: HvFlowNodeTypes<NodeGroups>;\n /** Flow sidebar. */\n sidebar?: React.ReactNode;\n /**\n * Dnd Kit context props. This should be used for accessibility purposes.\n *\n * More information can be found on the [Dnd Kit documentation](https://docs.dndkit.com/guides/accessibility)\n */\n dndContextProps?: Pick<DndContextProps, \"accessibility\">;\n}\n\n/**\n * Flow component to build interactive node-based UIs.\n *\n * This implementation leverages [React Flow](https://reactflow.dev).\n * The drag and drop functionality leverages [Dnd Kit](https://docs.dndkit.com)\n *\n * DISCLAIMER: This component is a work in progress and there might be breaking changes.\n */\nexport const HvFlow = ({\n nodeTypes,\n nodeGroups,\n sidebar,\n dndContextProps,\n ...others\n}: HvFlowProps) => {\n const [draggingLabel, setDraggingLabel] = useState(undefined);\n\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor)\n );\n\n const handleDragStart: DndContextProps[\"onDragStart\"] = (event) => {\n if (event.active.data.current?.hvFlow) {\n setDraggingLabel(event.active.data.current.hvFlow?.label);\n }\n };\n\n const handleDragEnd: DndContextProps[\"onDragEnd\"] = () => {\n setDraggingLabel(undefined);\n };\n\n // We're wrapping the main Flow component with the ReactFlowProvider to access the react flow instance.\n // HvFlowContext is our custom internal context.\n return (\n <ReactFlowProvider>\n <HvFlowProvider
|
|
1
|
+
{"version":3,"file":"Flow.js","sources":["../../../../src/components/Flow/Flow.tsx"],"sourcesContent":["import { useState } from \"react\";\n\nimport {\n DndContext,\n DndContextProps,\n DragOverlay,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport { restrictToWindowEdges } from \"@dnd-kit/modifiers\";\n\nimport { ReactFlowProvider } from \"reactflow\";\n\nimport { HvActionGeneric } from \"@hitachivantara/uikit-react-core\";\nimport { HvFlowNodeGroups, HvFlowNodeTypes } from \"./types\";\nimport { HvFlowProvider } from \"./FlowContext\";\nimport { HvDroppableFlow, HvDroppableFlowProps } from \"./DroppableFlow\";\nimport { HvFlowSidebarGroupItem } from \"./Sidebar/SidebarGroup/SidebarGroupItem\";\n\nexport interface HvFlowProps<\n NodeData = any,\n NodeType extends string | undefined = string | undefined,\n NodeGroups extends keyof any = string\n> extends HvDroppableFlowProps<NodeData, NodeType> {\n /** Flow nodes groups. */\n nodeGroups?: HvFlowNodeGroups<NodeGroups>;\n /** Flow nodes types. */\n nodeTypes?: HvFlowNodeTypes<NodeGroups>;\n /** Flow sidebar. */\n sidebar?: React.ReactNode;\n /** Flow default actions. */\n defaultActions?: HvActionGeneric[];\n /**\n * Dnd Kit context props. This should be used for accessibility purposes.\n *\n * More information can be found on the [Dnd Kit documentation](https://docs.dndkit.com/guides/accessibility)\n */\n dndContextProps?: Pick<DndContextProps, \"accessibility\">;\n}\n\n/**\n * Flow component to build interactive node-based UIs.\n *\n * This implementation leverages [React Flow](https://reactflow.dev).\n * The drag and drop functionality leverages [Dnd Kit](https://docs.dndkit.com)\n *\n * DISCLAIMER: This component is a work in progress and there might be breaking changes.\n */\nexport const HvFlow = ({\n nodeTypes,\n nodeGroups,\n sidebar,\n defaultActions,\n dndContextProps,\n ...others\n}: HvFlowProps) => {\n const [draggingLabel, setDraggingLabel] = useState(undefined);\n\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor)\n );\n\n const handleDragStart: DndContextProps[\"onDragStart\"] = (event) => {\n if (event.active.data.current?.hvFlow) {\n setDraggingLabel(event.active.data.current.hvFlow?.label);\n }\n };\n\n const handleDragEnd: DndContextProps[\"onDragEnd\"] = () => {\n setDraggingLabel(undefined);\n };\n\n // We're wrapping the main Flow component with the ReactFlowProvider to access the react flow instance.\n // HvFlowContext is our custom internal context.\n return (\n <ReactFlowProvider>\n <HvFlowProvider\n nodeGroups={nodeGroups}\n nodeTypes={nodeTypes}\n defaultActions={defaultActions}\n >\n <DndContext\n onDragStart={handleDragStart}\n onDragEnd={handleDragEnd}\n sensors={sensors}\n modifiers={[restrictToWindowEdges]}\n {...dndContextProps}\n >\n <HvDroppableFlow {...others} />\n {sidebar}\n <DragOverlay modifiers={[restrictToWindowEdges]}>\n {draggingLabel ? (\n <HvFlowSidebarGroupItem label={draggingLabel} isDragging />\n ) : null}\n </DragOverlay>\n </DndContext>\n </HvFlowProvider>\n </ReactFlowProvider>\n );\n};\n"],"names":["HvFlow","nodeTypes","nodeGroups","sidebar","defaultActions","dndContextProps","others","draggingLabel","setDraggingLabel","useState","undefined","sensors","useSensors","useSensor","PointerSensor","KeyboardSensor","handleDragStart","event","active","data","current","hvFlow","label","handleDragEnd","restrictToWindowEdges"],"mappings":";;;;;;;;AAkDO,MAAMA,SAASA,CAAC;AAAA,EACrBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AACQ,MAAM;AACjB,QAAM,CAACC,eAAeC,gBAAgB,IAAIC,SAASC,MAAS;AAE5D,QAAMC,UAAUC,WACdC,UAAUC,aAAa,GACvBD,UAAUE,cAAc,CAC1B;AAEA,QAAMC,kBAAmDC,CAAU,UAAA;;AACjE,SAAIA,WAAMC,OAAOC,KAAKC,YAAlBH,mBAA2BI,QAAQ;AACrCb,wBAAiBS,WAAMC,OAAOC,KAAKC,QAAQC,WAA1BJ,mBAAkCK,KAAK;AAAA,IAC1D;AAAA,EAAA;AAGF,QAAMC,gBAA8CA,MAAM;AACxDf,qBAAiBE,MAAS;AAAA,EAAA;AAK5B,6BACG,mBACC,EAAA,UAAA,oBAAC,kBACC,YACA,WACA,gBAEA,UAAC,qBAAA,YAAA,EACC,aAAaM,iBACb,WAAWO,eACX,SACA,WAAW,CAACC,qBAAqB,GACjC,GAAInB,iBAEJ,UAAA;AAAA,IAAC,oBAAA,iBAAA,EAAgB,GAAIC,QAAO;AAAA,IAC3BH;AAAAA,IACA,oBAAA,aAAA,EAAY,WAAW,CAACqB,qBAAqB,GAC3CjB,UAAAA,gBACE,oBAAA,wBAAA,EAAuB,OAAOA,eAAe,YAAU,KAAA,CAAA,IACtD,MACN;AAAA,EAAA,GACF,GACF,EACF,CAAA;AAEJ;"}
|
|
@@ -4,15 +4,17 @@ const HvFlowContext = createContext({});
|
|
|
4
4
|
const HvFlowProvider = ({
|
|
5
5
|
nodeGroups,
|
|
6
6
|
nodeTypes,
|
|
7
|
+
defaultActions,
|
|
7
8
|
children
|
|
8
9
|
}) => {
|
|
9
10
|
const [expandedNodeGroups, setExpandedNodeGroups] = useState([]);
|
|
10
11
|
const value = useMemo(() => ({
|
|
11
12
|
nodeTypes,
|
|
12
13
|
nodeGroups,
|
|
14
|
+
defaultActions,
|
|
13
15
|
expandedNodeGroups,
|
|
14
16
|
setExpandedNodeGroups
|
|
15
|
-
}), [nodeGroups,
|
|
17
|
+
}), [nodeTypes, nodeGroups, defaultActions, expandedNodeGroups]);
|
|
16
18
|
return /* @__PURE__ */ jsx(HvFlowContext.Provider, { value, children });
|
|
17
19
|
};
|
|
18
20
|
const useFlowContext = () => useContext(HvFlowContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlowContext.js","sources":["../../../../../src/components/Flow/FlowContext/FlowContext.tsx"],"sourcesContent":["import {\n Dispatch,\n SetStateAction,\n createContext,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nimport { HvFlowNodeGroups, HvFlowNodeTypes } from \"../types\";\n\nexport interface HvFlowContextValue<NodeGroups extends keyof any = string> {\n /** Flow nodes types. */\n nodeTypes?: HvFlowNodeTypes<NodeGroups>;\n /** Flow nodes groups. */\n nodeGroups?: HvFlowNodeGroups<NodeGroups>;\n /** Flow nodes groups expanded on sidebar. */\n expandedNodeGroups?: string[];\n /** Function to set `expandedNodeGroups`. */\n setExpandedNodeGroups?: Dispatch<SetStateAction<string[]>>;\n}\n\nexport const HvFlowContext = createContext<HvFlowContextValue>({});\n\nexport interface HvFlowProviderProps<NodeGroups extends keyof any = string> {\n /** Flow nodes types. */\n nodeTypes?: HvFlowContextValue<NodeGroups>[\"nodeTypes\"];\n /** Flow nodes groups. */\n nodeGroups?: HvFlowContextValue<NodeGroups>[\"nodeGroups\"];\n /** Children. */\n children?: React.ReactNode;\n}\n\nexport const HvFlowProvider = ({\n nodeGroups,\n nodeTypes,\n children,\n}: HvFlowProviderProps) => {\n const [expandedNodeGroups, setExpandedNodeGroups] = useState<string[]>([]);\n\n const value = useMemo(\n () => ({\n nodeTypes,\n nodeGroups,\n expandedNodeGroups,\n setExpandedNodeGroups,\n }),\n [nodeGroups,
|
|
1
|
+
{"version":3,"file":"FlowContext.js","sources":["../../../../../src/components/Flow/FlowContext/FlowContext.tsx"],"sourcesContent":["import { HvActionGeneric } from \"@hitachivantara/uikit-react-core\";\nimport {\n Dispatch,\n SetStateAction,\n createContext,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nimport { HvFlowNodeGroups, HvFlowNodeTypes } from \"../types\";\n\nexport interface HvFlowContextValue<NodeGroups extends keyof any = string> {\n /** Flow nodes types. */\n nodeTypes?: HvFlowNodeTypes<NodeGroups>;\n /** Flow nodes groups. */\n nodeGroups?: HvFlowNodeGroups<NodeGroups>;\n /** Flow nodes groups expanded on sidebar. */\n expandedNodeGroups?: string[];\n /** Flow default actions. */\n defaultActions?: HvActionGeneric[];\n /** Function to set `expandedNodeGroups`. */\n setExpandedNodeGroups?: Dispatch<SetStateAction<string[]>>;\n}\n\nexport const HvFlowContext = createContext<HvFlowContextValue>({});\n\nexport interface HvFlowProviderProps<NodeGroups extends keyof any = string> {\n /** Flow nodes types. */\n nodeTypes?: HvFlowContextValue<NodeGroups>[\"nodeTypes\"];\n /** Flow nodes groups. */\n nodeGroups?: HvFlowContextValue<NodeGroups>[\"nodeGroups\"];\n /** Flow default actions. */\n defaultActions?: HvActionGeneric[];\n /** Children. */\n children?: React.ReactNode;\n}\n\nexport const HvFlowProvider = ({\n nodeGroups,\n nodeTypes,\n defaultActions,\n children,\n}: HvFlowProviderProps) => {\n const [expandedNodeGroups, setExpandedNodeGroups] = useState<string[]>([]);\n\n const value = useMemo(\n () => ({\n nodeTypes,\n nodeGroups,\n defaultActions,\n expandedNodeGroups,\n setExpandedNodeGroups,\n }),\n [nodeTypes, nodeGroups, defaultActions, expandedNodeGroups]\n );\n\n return (\n <HvFlowContext.Provider value={value}>{children}</HvFlowContext.Provider>\n );\n};\n\nexport const useFlowContext = () => useContext(HvFlowContext);\n"],"names":["HvFlowContext","createContext","HvFlowProvider","nodeGroups","nodeTypes","defaultActions","children","expandedNodeGroups","setExpandedNodeGroups","useState","value","useMemo","useFlowContext","useContext"],"mappings":";;AAyBaA,MAAAA,gBAAgBC,cAAkC,EAAE;AAa1D,MAAMC,iBAAiBA,CAAC;AAAA,EAC7BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACmB,MAAM;AACzB,QAAM,CAACC,oBAAoBC,qBAAqB,IAAIC,SAAmB,CAAE,CAAA;AAEnEC,QAAAA,QAAQC,QACZ,OAAO;AAAA,IACLP;AAAAA,IACAD;AAAAA,IACAE;AAAAA,IACAE;AAAAA,IACAC;AAAAA,EAAAA,IAEF,CAACJ,WAAWD,YAAYE,gBAAgBE,kBAAkB,CAC5D;AAEA,SACG,oBAAA,cAAc,UAAd,EAAuB,OAAeD,SAAS,CAAA;AAEpD;AAEaM,MAAAA,iBAAiBA,MAAMC,WAAWb,aAAa;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsxs, jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { HvTypography, HvTooltip,
|
|
1
|
+
import { jsxs, jsx, Fragment } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { HvButton, HvTypography, HvTooltip, HvDropDownMenu } from "@hitachivantara/uikit-react-core";
|
|
3
3
|
import { Info, Up, Down } from "@hitachivantara/uikit-react-icons";
|
|
4
|
-
import { getColor } from "@hitachivantara/uikit-styles";
|
|
5
|
-
import { useState, useEffect } from "react";
|
|
6
|
-
import { useReactFlow, useStore, Handle, Position } from "reactflow";
|
|
4
|
+
import { getColor, theme } from "@hitachivantara/uikit-styles";
|
|
5
|
+
import { useState, useEffect, useCallback, isValidElement } from "react";
|
|
6
|
+
import { useReactFlow, useStore, NodeToolbar, Handle, Position } from "reactflow";
|
|
7
7
|
import { useFlowContext } from "../FlowContext/FlowContext.js";
|
|
8
8
|
import { useClasses } from "./Node.styles.js";
|
|
9
9
|
import { staticClasses } from "./Node.styles.js";
|
|
@@ -19,15 +19,18 @@ const isInputConnected = (id, type, idx, edges) => {
|
|
|
19
19
|
const HvFlowNode = ({
|
|
20
20
|
id,
|
|
21
21
|
type,
|
|
22
|
-
title,
|
|
23
22
|
description,
|
|
24
23
|
expanded = false,
|
|
25
24
|
params,
|
|
25
|
+
actions,
|
|
26
|
+
actionCallback,
|
|
27
|
+
maxVisibleActions = 1,
|
|
26
28
|
classes: classesProp,
|
|
27
29
|
className
|
|
28
30
|
}) => {
|
|
29
|
-
var _a, _b, _c, _d, _e;
|
|
31
|
+
var _a, _b, _c, _d, _e, _f;
|
|
30
32
|
const [showParams, setShowParams] = useState(expanded);
|
|
33
|
+
const [showActions, setShowActions] = useState(false);
|
|
31
34
|
const reactFlowInstance = useReactFlow();
|
|
32
35
|
const {
|
|
33
36
|
classes,
|
|
@@ -36,15 +39,17 @@ const HvFlowNode = ({
|
|
|
36
39
|
} = useClasses(classesProp);
|
|
37
40
|
const {
|
|
38
41
|
nodeGroups,
|
|
39
|
-
nodeTypes
|
|
42
|
+
nodeTypes,
|
|
43
|
+
defaultActions
|
|
40
44
|
} = useFlowContext();
|
|
41
45
|
const edges = useStore((s) => s.edges);
|
|
42
46
|
const nodes = useStore((s) => s.getNodes());
|
|
43
47
|
const node = nodes.find((n) => n.id === id);
|
|
44
48
|
const groupId = (_a = nodeTypes == null ? void 0 : nodeTypes[type].meta) == null ? void 0 : _a.groupId;
|
|
49
|
+
const title = (_b = nodeTypes == null ? void 0 : nodeTypes[type].meta) == null ? void 0 : _b.label;
|
|
45
50
|
const groupLabel = groupId && nodeGroups && nodeGroups[groupId].label;
|
|
46
|
-
const inputs = (
|
|
47
|
-
const outputs = (
|
|
51
|
+
const inputs = (_d = (_c = nodeTypes == null ? void 0 : nodeTypes[type]) == null ? void 0 : _c.meta) == null ? void 0 : _d.inputs;
|
|
52
|
+
const outputs = (_f = (_e = nodeTypes == null ? void 0 : nodeTypes[type]) == null ? void 0 : _e.meta) == null ? void 0 : _f.outputs;
|
|
48
53
|
const icon = groupId && nodeGroups && nodeGroups[groupId].icon;
|
|
49
54
|
const colorProp = groupId && nodeGroups && nodeGroups[groupId].color;
|
|
50
55
|
const color = getColor(colorProp);
|
|
@@ -61,10 +66,39 @@ const HvFlowNode = ({
|
|
|
61
66
|
});
|
|
62
67
|
reactFlowInstance.setNodes(newNodes);
|
|
63
68
|
}, []);
|
|
69
|
+
const handleDefaultAction = useCallback((action) => {
|
|
70
|
+
if (!node)
|
|
71
|
+
return;
|
|
72
|
+
switch (action) {
|
|
73
|
+
case "delete":
|
|
74
|
+
reactFlowInstance.deleteElements({
|
|
75
|
+
nodes: [node]
|
|
76
|
+
});
|
|
77
|
+
break;
|
|
78
|
+
case "duplicate":
|
|
79
|
+
reactFlowInstance.addNodes([{
|
|
80
|
+
...node,
|
|
81
|
+
id: `${reactFlowInstance.getNodes().length + 1}`,
|
|
82
|
+
position: {
|
|
83
|
+
x: node.position.x,
|
|
84
|
+
y: node.position.y + (node.height || 0) + 20
|
|
85
|
+
},
|
|
86
|
+
selected: false,
|
|
87
|
+
zIndex: Number(theme.zIndices.overlay)
|
|
88
|
+
}]);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}, [node, reactFlowInstance]);
|
|
64
92
|
const hasParams = !!(params && params.length > 0);
|
|
93
|
+
if (!node)
|
|
94
|
+
return null;
|
|
95
|
+
const actsVisible = actions == null ? void 0 : actions.slice(0, maxVisibleActions);
|
|
96
|
+
const actsDropdown = actions == null ? void 0 : actions.slice(maxVisibleActions);
|
|
97
|
+
const renderedIcon = (actionIcon) => isValidElement(actionIcon) ? actionIcon : actionIcon == null ? void 0 : actionIcon();
|
|
65
98
|
return /* @__PURE__ */ jsxs("div", { className: cx(css({
|
|
66
99
|
border: `1px solid ${color}`
|
|
67
|
-
}), classes.root, className), children: [
|
|
100
|
+
}), classes.root, className), onMouseEnter: () => setShowActions(true), onMouseLeave: () => setShowActions(false), children: [
|
|
101
|
+
/* @__PURE__ */ jsx(NodeToolbar, { isVisible: showActions, offset: 0, children: defaultActions == null ? void 0 : defaultActions.map((action) => /* @__PURE__ */ jsx(HvButton, { icon: true, onClick: () => handleDefaultAction(action.id), children: renderedIcon(action.icon) })) }),
|
|
68
102
|
/* @__PURE__ */ jsxs("div", { className: cx(css({
|
|
69
103
|
backgroundColor: color
|
|
70
104
|
}), classes.headerContainer), children: [
|
|
@@ -79,7 +113,20 @@ const HvFlowNode = ({
|
|
|
79
113
|
/* @__PURE__ */ jsx(HvButton, { icon: true, disabled: !hasParams, onClick: () => setShowParams((p) => !p), children: showParams ? /* @__PURE__ */ jsx(Up, {}) : /* @__PURE__ */ jsx(Down, {}) })
|
|
80
114
|
] })
|
|
81
115
|
] }),
|
|
82
|
-
/* @__PURE__ */
|
|
116
|
+
/* @__PURE__ */ jsxs("div", { className: classes.titleContainer, children: [
|
|
117
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(HvTypography, { children: title }) }),
|
|
118
|
+
/* @__PURE__ */ jsx("div", { className: classes.actions, children: (actions == null ? void 0 : actions.length) && (actions == null ? void 0 : actions.length) > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
119
|
+
actsVisible == null ? void 0 : actsVisible.map((action) => /* @__PURE__ */ jsx(HvTooltip, { title: /* @__PURE__ */ jsx(HvTypography, { children: action.label }), children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(HvButton, { icon: true, onClick: (event) => {
|
|
120
|
+
actionCallback == null ? void 0 : actionCallback(event, node.id, action);
|
|
121
|
+
}, children: renderedIcon(action.icon) }) }) })),
|
|
122
|
+
actsDropdown && actsDropdown.length > 0 && /* @__PURE__ */ jsx(HvDropDownMenu, { keepOpened: false, dataList: actsDropdown == null ? void 0 : actsDropdown.map((action) => ({
|
|
123
|
+
id: action.id,
|
|
124
|
+
label: action.label
|
|
125
|
+
})), onClick: (event, action) => {
|
|
126
|
+
actionCallback == null ? void 0 : actionCallback(event, node.id, action);
|
|
127
|
+
} })
|
|
128
|
+
] }) })
|
|
129
|
+
] }),
|
|
83
130
|
/* @__PURE__ */ jsx("div", { className: classes.inputsTitleContainer, children: /* @__PURE__ */ jsx(HvTypography, { children: "Inputs" }) }),
|
|
84
131
|
/* @__PURE__ */ jsx("div", { className: classes.inputsContainer, children: inputs == null ? void 0 : inputs.map((input, idx) => /* @__PURE__ */ jsxs("div", { className: classes.inputContainer, children: [
|
|
85
132
|
/* @__PURE__ */ jsx(Handle, { type: "target", isConnectableStart: false, id: `${idx}`, position: Position.Left, style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Node.js","sources":["../../../../../src/components/Flow/Node/Node.tsx"],"sourcesContent":["import {\n ExtractNames,\n HvBaseProps,\n HvButton,\n HvTooltip,\n HvTypography,\n} from \"@hitachivantara/uikit-react-core\";\nimport { Down, Info, Up } from \"@hitachivantara/uikit-react-icons\";\nimport { getColor } from \"@hitachivantara/uikit-styles\";\nimport { useEffect, useState } from \"react\";\nimport { Handle, NodeProps, Position, useReactFlow, useStore } from \"reactflow\";\nimport { useFlowContext } from \"../FlowContext/FlowContext\";\n\nimport { HvFlowNodeInput, HvFlowNodeOutput, HvFlowNodeParam } from \"../types\";\nimport { staticClasses, useClasses } from \"./Node.styles\";\nimport ParamRenderer from \"./Parameters/ParamRenderer\";\n\nexport { staticClasses as flowNodeClasses };\n\nexport type HvFlowNodeClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFlowNodeProps extends Omit<HvBaseProps, \"id\">, NodeProps {\n /** Node title */\n title: string;\n /** Node description */\n description: string;\n /** Node expanded */\n expanded?: boolean;\n /** Node inputs */\n inputs?: HvFlowNodeInput[];\n /** Node outputs */\n outputs?: HvFlowNodeOutput[];\n /** Node parameters */\n params?: HvFlowNodeParam[];\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowNodeClasses;\n}\n\nconst isInputConnected = (id, type, idx, edges) => {\n if (type === \"target\") {\n return edges.some(\n (e) => e.target === id && e.targetHandle === idx.toString()\n );\n }\n if (type === \"source\") {\n return edges.some(\n (e) => e.source === id && e.sourceHandle === idx.toString()\n );\n }\n};\n\nexport const HvFlowNode = ({\n id,\n type,\n title,\n description,\n expanded = false,\n params,\n classes: classesProp,\n className,\n}: HvFlowNodeProps) => {\n const [showParams, setShowParams] = useState(expanded);\n const reactFlowInstance = useReactFlow();\n\n const { classes, cx, css } = useClasses(classesProp);\n\n const { nodeGroups, nodeTypes } = useFlowContext();\n const edges = useStore((s) => s.edges);\n const nodes = useStore((s) => s.getNodes());\n\n const node = nodes.find((n) => n.id === id);\n\n const groupId = nodeTypes?.[type].meta?.groupId;\n const groupLabel = groupId && nodeGroups && nodeGroups[groupId].label;\n const inputs = nodeTypes?.[type]?.meta?.inputs;\n const outputs = nodeTypes?.[type]?.meta?.outputs;\n const icon = groupId && nodeGroups && nodeGroups[groupId].icon;\n const colorProp = groupId && nodeGroups && nodeGroups[groupId].color;\n const color = getColor(colorProp);\n\n useEffect(() => {\n const newNodes = nodes.map((n) => {\n if (n.id === id) {\n if (Object.keys(n.data).length === 0) {\n params?.forEach((param) => {\n n.data[param.label] = param.value;\n });\n }\n }\n return n;\n });\n reactFlowInstance.setNodes(newNodes);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const hasParams = !!(params && params.length > 0);\n\n return (\n <div\n className={cx(\n css({ border: `1px solid ${color}` }),\n classes.root,\n className\n )}\n >\n <div\n className={cx(css({ backgroundColor: color }), classes.headerContainer)}\n >\n <div className={classes.groupContainer}>\n {icon}\n <HvTypography variant=\"title4\" className={classes.group}>\n {groupLabel}\n </HvTypography>\n </div>\n <div style={{ display: \"flex\" }}>\n <HvTooltip title={<HvTypography>{description}</HvTypography>}>\n <div>\n <Info />\n </div>\n </HvTooltip>\n <HvButton\n icon\n disabled={!hasParams}\n onClick={() => setShowParams((p) => !p)}\n >\n {showParams ? <Up /> : <Down />}\n </HvButton>\n </div>\n </div>\n <div className={classes.titleContainer}>\n <HvTypography>{title}</HvTypography>\n </div>\n <div className={classes.inputsTitleContainer}>\n <HvTypography>Inputs</HvTypography>\n </div>\n <div className={classes.inputsContainer}>\n {inputs?.map((input, idx) => (\n <div className={classes.inputContainer} key={idx}>\n <Handle\n type=\"target\"\n isConnectableStart={false}\n id={`${idx}`}\n position={Position.Left}\n style={{\n top: 160 + 29 * idx,\n }}\n />\n <HvTypography>{input.label}</HvTypography>\n {input.isMandatory &&\n !isInputConnected(id, \"target\", idx, edges) && (\n <div className={classes.mandatory} />\n )}\n </div>\n ))}\n </div>\n {showParams && params && (\n <div className={classes.paramsContainer}>\n <ParamRenderer nodeId={id} params={params} data={node?.data} />\n </div>\n )}\n <div className={classes.outputsTitleContainer}>\n <HvTypography>Outputs</HvTypography>\n </div>\n <div className={classes.outputsContainer}>\n {outputs?.map((output, idx) => (\n <div className={classes.outputContainer} key={idx}>\n <Handle\n type=\"source\"\n isConnectableEnd={false}\n id={`${idx}`}\n position={Position.Right}\n style={{\n bottom: -8 + 29 * (outputs.length - idx),\n top: \"auto\",\n }}\n />\n {output.isMandatory &&\n !isInputConnected(id, \"source\", idx, edges) && (\n <div className={classes.mandatory} />\n )}\n <HvTypography>{output.label}</HvTypography>\n </div>\n ))}\n </div>\n </div>\n );\n};\n"],"names":["isInputConnected","id","type","idx","edges","some","e","target","targetHandle","toString","source","sourceHandle","HvFlowNode","title","description","expanded","params","classes","classesProp","className","showParams","setShowParams","useState","reactFlowInstance","useReactFlow","cx","css","useClasses","nodeGroups","nodeTypes","useFlowContext","useStore","s","nodes","getNodes","node","find","n","groupId","meta","groupLabel","label","inputs","outputs","icon","colorProp","color","getColor","useEffect","newNodes","map","Object","keys","data","length","forEach","param","value","setNodes","hasParams","border","root","backgroundColor","headerContainer","groupContainer","group","display","p","titleContainer","inputsTitleContainer","inputsContainer","input","inputContainer","Position","Left","top","isMandatory","mandatory","paramsContainer","outputsTitleContainer","outputsContainer","output","outputContainer","Right","bottom"],"mappings":";;;;;;;;;;AAsCA,MAA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c,QAAQiE,iBACtB,UAAA;AAAA,MAAA,oBAAC,QACC,EAAA,MAAK,UACL,kBAAkB,OAClB,IAAK,GAAE/E,GAAI,IACX,UAAUsE,SAASU,OACnB,OAAO;AAAA,QACLC,QAAQ,KAAK,MAAMzC,QAAQW,SAASnD;AAAAA,QACpCwE,KAAK;AAAA,MAAA,GACL;AAAA,MAEHM,OAAOL,eACN,CAAC5E,iBAAiBC,IAAI,UAAUE,KAAKC,KAAK,KACxC,oBAAC,OAAI,EAAA,WAAWa,QAAQ4D,UACzB,CAAA;AAAA,MACH,oBAAC,cAAcI,EAAAA,UAAAA,OAAOxC,MAAM,CAAA;AAAA,IAAA,KAfgBtC,GAgB9C,IAEJ;AAAA,EACF,EAAA,CAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"Node.js","sources":["../../../../../src/components/Flow/Node/Node.tsx"],"sourcesContent":["import {\n ExtractNames,\n HvActionGeneric,\n HvActionsGenericProps,\n HvBaseProps,\n HvButton,\n HvDropDownMenu,\n HvTooltip,\n HvTypography,\n} from \"@hitachivantara/uikit-react-core\";\nimport { Down, Info, Up } from \"@hitachivantara/uikit-react-icons\";\nimport { getColor, theme } from \"@hitachivantara/uikit-styles\";\nimport { isValidElement, useCallback, useEffect, useState } from \"react\";\nimport {\n Handle,\n NodeProps,\n NodeToolbar,\n Position,\n useReactFlow,\n useStore,\n} from \"reactflow\";\nimport { useFlowContext } from \"../FlowContext/FlowContext\";\n\nimport { HvFlowNodeInput, HvFlowNodeOutput, HvFlowNodeParam } from \"../types\";\nimport { staticClasses, useClasses } from \"./Node.styles\";\nimport ParamRenderer from \"./Parameters/ParamRenderer\";\n\nexport { staticClasses as flowNodeClasses };\n\nexport type HvFlowNodeClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFlowNodeProps extends Omit<HvBaseProps, \"id\">, NodeProps {\n /** Node description */\n description: string;\n /** Node expanded */\n expanded?: boolean;\n /** Node inputs */\n inputs?: HvFlowNodeInput[];\n /** Node outputs */\n outputs?: HvFlowNodeOutput[];\n /** Node parameters */\n params?: HvFlowNodeParam[];\n /** Node actions */\n actions?: HvActionGeneric[]; // HvFlowNodeActions[];\n /** Node action callback */\n actionCallback?: HvActionsGenericProps[\"actionsCallback\"];\n /** Node maximum number of actions visible */\n maxVisibleActions?: number;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowNodeClasses;\n}\n\nconst isInputConnected = (id, type, idx, edges) => {\n if (type === \"target\") {\n return edges.some(\n (e) => e.target === id && e.targetHandle === idx.toString()\n );\n }\n if (type === \"source\") {\n return edges.some(\n (e) => e.source === id && e.sourceHandle === idx.toString()\n );\n }\n};\n\nexport const HvFlowNode = ({\n id,\n type,\n description,\n expanded = false,\n params,\n actions,\n actionCallback,\n maxVisibleActions = 1,\n classes: classesProp,\n className,\n}: HvFlowNodeProps) => {\n const [showParams, setShowParams] = useState(expanded);\n const [showActions, setShowActions] = useState(false);\n const reactFlowInstance = useReactFlow();\n\n const { classes, cx, css } = useClasses(classesProp);\n\n const { nodeGroups, nodeTypes, defaultActions } = useFlowContext();\n const edges = useStore((s) => s.edges);\n const nodes = useStore((s) => s.getNodes());\n\n const node = nodes.find((n) => n.id === id);\n\n const groupId = nodeTypes?.[type].meta?.groupId;\n const title = nodeTypes?.[type].meta?.label;\n const groupLabel = groupId && nodeGroups && nodeGroups[groupId].label;\n\n const inputs = nodeTypes?.[type]?.meta?.inputs;\n const outputs = nodeTypes?.[type]?.meta?.outputs;\n const icon = groupId && nodeGroups && nodeGroups[groupId].icon;\n const colorProp = groupId && nodeGroups && nodeGroups[groupId].color;\n const color = getColor(colorProp);\n\n useEffect(() => {\n const newNodes = nodes.map((n) => {\n if (n.id === id) {\n if (Object.keys(n.data).length === 0) {\n params?.forEach((param) => {\n n.data[param.label] = param.value;\n });\n }\n }\n return n;\n });\n reactFlowInstance.setNodes(newNodes);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const handleDefaultAction = useCallback(\n (action: string) => {\n if (!node) return;\n\n switch (action) {\n case \"delete\":\n reactFlowInstance.deleteElements({ nodes: [node] });\n break;\n case \"duplicate\":\n reactFlowInstance.addNodes([\n {\n ...node,\n id: `${reactFlowInstance.getNodes().length + 1}`,\n position: {\n x: node.position.x,\n y: node.position.y + (node.height || 0) + 20,\n },\n selected: false,\n zIndex: Number(theme.zIndices.overlay),\n },\n ]);\n break;\n default:\n break;\n }\n },\n [node, reactFlowInstance]\n );\n\n const hasParams = !!(params && params.length > 0);\n\n if (!node) return null;\n\n const actsVisible = actions?.slice(0, maxVisibleActions);\n const actsDropdown = actions?.slice(maxVisibleActions);\n\n const renderedIcon = (actionIcon: HvActionGeneric[\"icon\"]) =>\n isValidElement(actionIcon) ? actionIcon : (actionIcon as Function)?.();\n\n return (\n <div\n className={cx(\n css({ border: `1px solid ${color}` }),\n classes.root,\n className\n )}\n onMouseEnter={() => setShowActions(true)}\n onMouseLeave={() => setShowActions(false)}\n >\n <NodeToolbar isVisible={showActions} offset={0}>\n {defaultActions?.map((action) => (\n <HvButton icon onClick={() => handleDefaultAction(action.id)}>\n {renderedIcon(action.icon)}\n </HvButton>\n ))}\n </NodeToolbar>\n <div\n className={cx(css({ backgroundColor: color }), classes.headerContainer)}\n >\n <div className={classes.groupContainer}>\n {icon}\n <HvTypography variant=\"title4\" className={classes.group}>\n {groupLabel}\n </HvTypography>\n </div>\n <div style={{ display: \"flex\" }}>\n <HvTooltip title={<HvTypography>{description}</HvTypography>}>\n <div>\n <Info />\n </div>\n </HvTooltip>\n <HvButton\n icon\n disabled={!hasParams}\n onClick={() => setShowParams((p) => !p)}\n >\n {showParams ? <Up /> : <Down />}\n </HvButton>\n </div>\n </div>\n <div className={classes.titleContainer}>\n <div>\n <HvTypography>{title}</HvTypography>\n </div>\n <div className={classes.actions}>\n {actions?.length && actions?.length > 0 && (\n <>\n {actsVisible?.map((action) => (\n <HvTooltip title={<HvTypography>{action.label}</HvTypography>}>\n <div>\n <HvButton\n icon\n onClick={(event) => {\n actionCallback?.(event, node.id, action);\n }}\n >\n {renderedIcon(action.icon)}\n </HvButton>\n </div>\n </HvTooltip>\n ))}\n\n {actsDropdown && actsDropdown.length > 0 && (\n <HvDropDownMenu\n keepOpened={false}\n dataList={actsDropdown?.map((action) => ({\n id: action.id,\n label: action.label,\n }))}\n onClick={(event, action) => {\n actionCallback?.(event, node.id, action as HvActionGeneric);\n }}\n />\n )}\n </>\n )}\n </div>\n </div>\n <div className={classes.inputsTitleContainer}>\n <HvTypography>Inputs</HvTypography>\n </div>\n <div className={classes.inputsContainer}>\n {inputs?.map((input, idx) => (\n <div className={classes.inputContainer} key={idx}>\n <Handle\n type=\"target\"\n isConnectableStart={false}\n id={`${idx}`}\n position={Position.Left}\n style={{\n top: 160 + 29 * idx,\n }}\n />\n <HvTypography>{input.label}</HvTypography>\n {input.isMandatory &&\n !isInputConnected(id, \"target\", idx, edges) && (\n <div className={classes.mandatory} />\n )}\n </div>\n ))}\n </div>\n {showParams && params && (\n <div className={classes.paramsContainer}>\n <ParamRenderer nodeId={id} params={params} data={node?.data} />\n </div>\n )}\n <div className={classes.outputsTitleContainer}>\n <HvTypography>Outputs</HvTypography>\n </div>\n <div className={classes.outputsContainer}>\n {outputs?.map((output, idx) => (\n <div className={classes.outputContainer} key={idx}>\n <Handle\n type=\"source\"\n isConnectableEnd={false}\n id={`${idx}`}\n position={Position.Right}\n style={{\n bottom: -8 + 29 * (outputs.length - idx),\n top: \"auto\",\n }}\n />\n {output.isMandatory &&\n !isInputConnected(id, \"source\", idx, edges) && (\n <div className={classes.mandatory} />\n )}\n <HvTypography>{output.label}</HvTypography>\n </div>\n ))}\n </div>\n </div>\n );\n};\n"],"names":["isInputConnected","id","type","idx","edges","some","e","target","targetHandle","toString","source","sourceHandle","HvFlowNode","description","expanded","params","actions","actionCallback","maxVisibleActions","classes","classesProp","className","showParams","setShowParams","useState","showActions","setShowActions","reactFlowInstance","useReactFlow","cx","css","useClasses","nodeGroups","nodeTypes","defaultActions","useFlowContext","useStore","s","nodes","getNodes","node","find","n","groupId","meta","title","label","groupLabel","inputs","outputs","icon","colorProp","color","getColor","useEffect","newNodes","map","Object","keys","data","length","forEach","param","value","setNodes","handleDefaultAction","useCallback","action","deleteElements","addNodes","position","x","y","height","selected","zIndex","Number","theme","zIndices","overlay","hasParams","actsVisible","slice","actsDropdown","renderedIcon","actionIcon","isValidElement","border","root","backgroundColor","headerContainer","groupContainer","group","display","p","titleContainer","event","inputsTitleContainer","inputsContainer","input","inputContainer","Position","Left","top","isMandatory","mandatory","paramsContainer","outputsTitleContainer","outputsContainer","output","outputContainer","Right","bottom"],"mappings":";;;;;;;;;;AAoDA,MAAMA,mBAAmBA,CAACC,IAAIC,MAAMC,KAAKC,UAAU;AACjD,MAAIF,SAAS,UAAU;AACdE,WAAAA,MAAMC,KACVC,CAAAA,MAAMA,EAAEC,WAAWN,MAAMK,EAAEE,iBAAiBL,IAAIM,SACnD,CAAA;AAAA,EACF;AACA,MAAIP,SAAS,UAAU;AACdE,WAAAA,MAAMC,KACVC,CAAAA,MAAMA,EAAEI,WAAWT,MAAMK,EAAEK,iBAAiBR,IAAIM,SACnD,CAAA;AAAA,EACF;AACF;AAEO,MAAMG,aAAaA,CAAC;AAAA,EACzBX;AAAAA,EACAC;AAAAA,EACAW;AAAAA,EACAC,WAAW;AAAA,EACXC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,oBAAoB;AAAA,EACpBC,SAASC;AAAAA,EACTC;AACe,MAAM;;AACrB,QAAM,CAACC,YAAYC,aAAa,IAAIC,SAASV,QAAQ;AACrD,QAAM,CAACW,aAAaC,cAAc,IAAIF,SAAS,KAAK;AACpD,QAAMG,oBAAoBC;AAEpB,QAAA;AAAA,IAAET;AAAAA,IAASU;AAAAA,IAAIC;AAAAA,EAAAA,IAAQC,WAAWX,WAAW;AAE7C,QAAA;AAAA,IAAEY;AAAAA,IAAYC;AAAAA,IAAWC;AAAAA,MAAmBC,eAAe;AACjE,QAAM/B,QAAQgC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UAAA;AAAA,MAAA,oBAAC,QACC,EAAA,MAAK,UACL,kBAAkB,OAClB,IAAK,GAAE3G,GAAI,IACX,UAAUkG,SAASU,OACnB,OAAO;AAAA,QACLC,QAAQ,KAAK,MAAM/D,QAAQW,SAASzD;AAAAA,QACpCoG,KAAK;AAAA,MAAA,GACL;AAAA,MAEHM,OAAOL,eACN,CAACxG,iBAAiBC,IAAI,UAAUE,KAAKC,KAAK,KACxC,oBAAC,OAAI,EAAA,WAAWe,QAAQsF,UACzB,CAAA;AAAA,MACH,oBAAC,cAAcI,EAAAA,UAAAA,OAAO/D,MAAM,CAAA;AAAA,IAAA,KAfgB3C,GAgB9C,IAEJ;AAAA,EACF,EAAA,CAAA;AAEJ;"}
|
|
@@ -25,7 +25,15 @@ const {
|
|
|
25
25
|
color: theme.colors.base_dark
|
|
26
26
|
},
|
|
27
27
|
titleContainer: {
|
|
28
|
-
padding: theme.space.sm
|
|
28
|
+
padding: theme.spacing(theme.space.xs, theme.space.xs, theme.space.xs, theme.space.sm),
|
|
29
|
+
display: "flex",
|
|
30
|
+
flexDirection: "row",
|
|
31
|
+
justifyContent: "space-between",
|
|
32
|
+
alignItems: "center"
|
|
33
|
+
},
|
|
34
|
+
actions: {
|
|
35
|
+
display: "flex",
|
|
36
|
+
alignItems: "center"
|
|
29
37
|
},
|
|
30
38
|
inputsTitleContainer: {
|
|
31
39
|
display: "flex",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Node.styles.js","sources":["../../../../../src/components/Flow/Node/Node.styles.tsx"],"sourcesContent":["import { createClasses, theme } from \"@hitachivantara/uikit-react-core\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFlowNode\", {\n root: {\n borderRadius: theme.radii.round,\n backgroundColor: theme.colors.atmo1,\n boxShadow: theme.colors.shadow,\n minWidth: \"250px\",\n },\n headerContainer: {\n padding: theme.spacing(0.5, 1),\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n },\n groupContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n },\n group: {\n color: theme.colors.base_dark,\n },\n titleContainer: {
|
|
1
|
+
{"version":3,"file":"Node.styles.js","sources":["../../../../../src/components/Flow/Node/Node.styles.tsx"],"sourcesContent":["import { createClasses, theme } from \"@hitachivantara/uikit-react-core\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFlowNode\", {\n root: {\n borderRadius: theme.radii.round,\n backgroundColor: theme.colors.atmo1,\n boxShadow: theme.colors.shadow,\n minWidth: \"250px\",\n },\n headerContainer: {\n padding: theme.spacing(0.5, 1),\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n },\n groupContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n },\n group: {\n color: theme.colors.base_dark,\n },\n titleContainer: {\n padding: theme.spacing(\n theme.space.xs,\n theme.space.xs,\n theme.space.xs,\n theme.space.sm\n ),\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n },\n actions: {\n display: \"flex\",\n alignItems: \"center\",\n },\n inputsTitleContainer: {\n display: \"flex\",\n justifyContent: \"center\",\n padding: theme.space.xs,\n backgroundColor: theme.colors.atmo2,\n borderTop: `1px solid ${theme.colors.atmo4}`,\n borderBottom: `1px solid ${theme.colors.atmo4}`,\n },\n outputsTitleContainer: {\n display: \"flex\",\n justifyContent: \"center\",\n padding: theme.space.xs,\n backgroundColor: theme.colors.atmo2,\n borderTop: `1px solid ${theme.colors.atmo4}`,\n borderBottom: `1px solid ${theme.colors.atmo4}`,\n },\n inputsContainer: {\n display: \"flex\",\n flexDirection: \"column\",\n padding: theme.space.sm,\n gap: theme.space.xs,\n alignItems: \"flex-start\",\n },\n outputsContainer: {\n display: \"flex\",\n flexDirection: \"column\",\n padding: theme.space.sm,\n gap: theme.space.xs,\n alignItems: \"flex-end\",\n },\n paramsContainer: {\n borderTop: `1px solid ${theme.colors.atmo4}`,\n display: \"flex\",\n flexDirection: \"column\",\n gap: theme.space.xs,\n padding: theme.space.sm,\n },\n inputContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n },\n outputContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n },\n mandatory: {\n width: 10,\n height: 10,\n margin: theme.spacing(0, theme.space.xs),\n borderRadius: theme.radii.circle,\n backgroundColor: theme.colors.negative_20,\n },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","borderRadius","theme","radii","round","backgroundColor","colors","atmo1","boxShadow","shadow","minWidth","headerContainer","padding","spacing","display","flexDirection","justifyContent","alignItems","groupContainer","group","color","base_dark","titleContainer","space","xs","sm","actions","inputsTitleContainer","atmo2","borderTop","atmo4","borderBottom","outputsTitleContainer","inputsContainer","gap","outputsContainer","paramsContainer","inputContainer","outputContainer","mandatory","width","height","margin","circle","negative_20"],"mappings":";AAEa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,cAAc,cAAc;AAAA,EACvEC,MAAM;AAAA,IACJC,cAAcC,MAAMC,MAAMC;AAAAA,IAC1BC,iBAAiBH,MAAMI,OAAOC;AAAAA,IAC9BC,WAAWN,MAAMI,OAAOG;AAAAA,IACxBC,UAAU;AAAA,EACZ;AAAA,EACAC,iBAAiB;AAAA,IACfC,SAASV,MAAMW,QAAQ,KAAK,CAAC;AAAA,IAC7BC,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,gBAAgB;AAAA,IAChBC,YAAY;AAAA,EACd;AAAA,EACAC,gBAAgB;AAAA,IACdJ,SAAS;AAAA,IACTC,eAAe;AAAA,IACfE,YAAY;AAAA,EACd;AAAA,EACAE,OAAO;AAAA,IACLC,OAAOlB,MAAMI,OAAOe;AAAAA,EACtB;AAAA,EACAC,gBAAgB;AAAA,IACdV,SAASV,MAAMW,QACbX,MAAMqB,MAAMC,IACZtB,MAAMqB,MAAMC,IACZtB,MAAMqB,MAAMC,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vB,SAAS;AAAA,IACTC,eAAe;AAAA,IACfE,YAAY;AAAA,EACd;AAAA,EACAqB,iBAAiB;AAAA,IACfxB,SAAS;AAAA,IACTC,eAAe;AAAA,IACfE,YAAY;AAAA,EACd;AAAA,EACAsB,WAAW;AAAA,IACTC,OAAO;AAAA,IACPC,QAAQ;AAAA,IACRC,QAAQxC,MAAMW,QAAQ,GAAGX,MAAMqB,MAAMC,EAAE;AAAA,IACvCvB,cAAcC,MAAMC,MAAMwC;AAAAA,IAC1BtC,iBAAiBH,MAAMI,OAAOsC;AAAAA,EAChC;AACF,CAAC;"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ import { Edge } from 'reactflow';
|
|
|
8
8
|
import { ExtractNames } from '@hitachivantara/uikit-react-core';
|
|
9
9
|
import { FunctionComponent } from 'react';
|
|
10
10
|
import { GetMiniMapNodeAttribute } from 'reactflow';
|
|
11
|
+
import { HvActionGeneric } from '@hitachivantara/uikit-react-core';
|
|
12
|
+
import { HvActionsGenericProps } from '@hitachivantara/uikit-react-core';
|
|
11
13
|
import { HvAvatarSize } from '@hitachivantara/uikit-react-core';
|
|
12
14
|
import { HvBaseProps } from '@hitachivantara/uikit-react-core';
|
|
13
15
|
import { HvBreakpoints } from '@hitachivantara/uikit-react-core';
|
|
@@ -37,6 +39,7 @@ export declare const flowNodeClasses: {
|
|
|
37
39
|
root: "HvFlowNode-root";
|
|
38
40
|
group: "HvFlowNode-group";
|
|
39
41
|
mandatory: "HvFlowNode-mandatory";
|
|
42
|
+
actions: "HvFlowNode-actions";
|
|
40
43
|
titleContainer: "HvFlowNode-titleContainer";
|
|
41
44
|
headerContainer: "HvFlowNode-headerContainer";
|
|
42
45
|
groupContainer: "HvFlowNode-groupContainer";
|
|
@@ -79,7 +82,7 @@ declare interface HvDroppableFlowProps<NodeData = any, NodeType extends string |
|
|
|
79
82
|
*
|
|
80
83
|
* DISCLAIMER: This component is a work in progress and there might be breaking changes.
|
|
81
84
|
*/
|
|
82
|
-
export declare const HvFlow: ({ nodeTypes, nodeGroups, sidebar, dndContextProps, ...others }: HvFlowProps) => JSX_2.Element;
|
|
85
|
+
export declare const HvFlow: ({ nodeTypes, nodeGroups, sidebar, defaultActions, dndContextProps, ...others }: HvFlowProps) => JSX_2.Element;
|
|
83
86
|
|
|
84
87
|
export declare const HvFlowBackground: ({ color, ...others }: HvFlowBackgroundProps) => JSX_2.Element;
|
|
85
88
|
|
|
@@ -131,7 +134,7 @@ export declare interface HvFlowMinimapProps<NodeData = any> extends Omit<MiniMap
|
|
|
131
134
|
classes?: HvFlowMinimapClasses;
|
|
132
135
|
}
|
|
133
136
|
|
|
134
|
-
export declare const HvFlowNode: ({ id, type,
|
|
137
|
+
export declare const HvFlowNode: ({ id, type, description, expanded, params, actions, actionCallback, maxVisibleActions, classes: classesProp, className, }: HvFlowNodeProps) => JSX_2.Element | null;
|
|
135
138
|
|
|
136
139
|
export declare type HvFlowNodeClasses = ExtractNames<typeof useClasses_11>;
|
|
137
140
|
|
|
@@ -186,8 +189,6 @@ export declare type HvFlowNodeParam = {
|
|
|
186
189
|
};
|
|
187
190
|
|
|
188
191
|
export declare interface HvFlowNodeProps extends Omit<HvBaseProps, "id">, NodeProps {
|
|
189
|
-
/** Node title */
|
|
190
|
-
title: string;
|
|
191
192
|
/** Node description */
|
|
192
193
|
description: string;
|
|
193
194
|
/** Node expanded */
|
|
@@ -198,6 +199,12 @@ export declare interface HvFlowNodeProps extends Omit<HvBaseProps, "id">, NodePr
|
|
|
198
199
|
outputs?: HvFlowNodeOutput[];
|
|
199
200
|
/** Node parameters */
|
|
200
201
|
params?: HvFlowNodeParam[];
|
|
202
|
+
/** Node actions */
|
|
203
|
+
actions?: HvActionGeneric[];
|
|
204
|
+
/** Node action callback */
|
|
205
|
+
actionCallback?: HvActionsGenericProps["actionsCallback"];
|
|
206
|
+
/** Node maximum number of actions visible */
|
|
207
|
+
maxVisibleActions?: number;
|
|
201
208
|
/** A Jss Object used to override or extend the styles applied to the component. */
|
|
202
209
|
classes?: HvFlowNodeClasses;
|
|
203
210
|
}
|
|
@@ -213,6 +220,8 @@ export declare interface HvFlowProps<NodeData = any, NodeType extends string | u
|
|
|
213
220
|
nodeTypes?: HvFlowNodeTypes<NodeGroups>;
|
|
214
221
|
/** Flow sidebar. */
|
|
215
222
|
sidebar?: React.ReactNode;
|
|
223
|
+
/** Flow default actions. */
|
|
224
|
+
defaultActions?: HvActionGeneric[];
|
|
216
225
|
/**
|
|
217
226
|
* Dnd Kit context props. This should be used for accessibility purposes.
|
|
218
227
|
*
|
|
@@ -481,11 +490,12 @@ declare const useClasses_10: (classesProp?: Partial<Record<"description" | "titl
|
|
|
481
490
|
cx: (...args: any) => string;
|
|
482
491
|
};
|
|
483
492
|
|
|
484
|
-
declare const useClasses_11: (classesProp?: Partial<Record<"root" | "group" | "mandatory" | "titleContainer" | "headerContainer" | "groupContainer" | "inputsTitleContainer" | "outputsTitleContainer" | "inputsContainer" | "outputsContainer" | "paramsContainer" | "inputContainer" | "outputContainer", string>>, addStatic?: boolean) => {
|
|
493
|
+
declare const useClasses_11: (classesProp?: Partial<Record<"root" | "group" | "mandatory" | "actions" | "titleContainer" | "headerContainer" | "groupContainer" | "inputsTitleContainer" | "outputsTitleContainer" | "inputsContainer" | "outputsContainer" | "paramsContainer" | "inputContainer" | "outputContainer", string>>, addStatic?: boolean) => {
|
|
485
494
|
classes: {
|
|
486
495
|
root: string;
|
|
487
496
|
group: string;
|
|
488
497
|
mandatory: string;
|
|
498
|
+
actions: string;
|
|
489
499
|
titleContainer: string;
|
|
490
500
|
headerContainer: string;
|
|
491
501
|
groupContainer: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/uikit-react-lab",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.7.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Hitachi Vantara UI Kit Team",
|
|
6
6
|
"description": "Contributed React components for the NEXT UI Kit.",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"access": "public",
|
|
49
49
|
"directory": "package"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "f1d113e5f993a61c1a2a2733001ac2f70b8ede56",
|
|
52
52
|
"main": "dist/cjs/index.cjs",
|
|
53
53
|
"exports": {
|
|
54
54
|
".": {
|