@hitachivantara/uikit-react-lab 5.4.50 → 5.5.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/components/Flow/Background/Background.cjs +16 -0
- package/dist/cjs/components/Flow/Background/Background.cjs.map +1 -0
- package/dist/cjs/components/Flow/Controls/Controls.cjs +108 -0
- package/dist/cjs/components/Flow/Controls/Controls.cjs.map +1 -0
- package/dist/cjs/components/Flow/DroppableFlow.cjs +105 -0
- package/dist/cjs/components/Flow/DroppableFlow.cjs.map +1 -0
- package/dist/cjs/components/Flow/Flow.cjs +53 -0
- package/dist/cjs/components/Flow/Flow.cjs.map +1 -0
- package/dist/cjs/components/Flow/Flow.styles.cjs +14 -0
- package/dist/cjs/components/Flow/Flow.styles.cjs.map +1 -0
- package/dist/cjs/components/Flow/FlowContext/FlowContext.cjs +27 -0
- package/dist/cjs/components/Flow/FlowContext/FlowContext.cjs.map +1 -0
- package/dist/cjs/components/Flow/Minimap/Minimap.cjs +31 -0
- package/dist/cjs/components/Flow/Minimap/Minimap.cjs.map +1 -0
- package/dist/cjs/components/Flow/Minimap/Minimap.styles.cjs +16 -0
- package/dist/cjs/components/Flow/Minimap/Minimap.styles.cjs.map +1 -0
- package/dist/cjs/components/Flow/Sidebar/Sidebar.cjs +121 -0
- package/dist/cjs/components/Flow/Sidebar/Sidebar.cjs.map +1 -0
- package/dist/cjs/components/Flow/Sidebar/Sidebar.styles.cjs +34 -0
- package/dist/cjs/components/Flow/Sidebar/Sidebar.styles.cjs.map +1 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroup.cjs +78 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroup.cjs.map +1 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroup.styles.cjs +37 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroup.styles.cjs.map +1 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.cjs +48 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.cjs.map +1 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.cjs +34 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.cjs.map +1 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.styles.cjs +26 -0
- package/dist/cjs/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.styles.cjs.map +1 -0
- package/dist/cjs/components/Flow/Sidebar/utils.cjs +27 -0
- package/dist/cjs/components/Flow/Sidebar/utils.cjs.map +1 -0
- package/dist/cjs/index.cjs +16 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/components/Flow/Background/Background.js +16 -0
- package/dist/esm/components/Flow/Background/Background.js.map +1 -0
- package/dist/esm/components/Flow/Controls/Controls.js +108 -0
- package/dist/esm/components/Flow/Controls/Controls.js.map +1 -0
- package/dist/esm/components/Flow/DroppableFlow.js +104 -0
- package/dist/esm/components/Flow/DroppableFlow.js.map +1 -0
- package/dist/esm/components/Flow/Flow.js +53 -0
- package/dist/esm/components/Flow/Flow.js.map +1 -0
- package/dist/esm/components/Flow/Flow.styles.js +14 -0
- package/dist/esm/components/Flow/Flow.styles.js.map +1 -0
- package/dist/esm/components/Flow/FlowContext/FlowContext.js +27 -0
- package/dist/esm/components/Flow/FlowContext/FlowContext.js.map +1 -0
- package/dist/esm/components/Flow/Minimap/Minimap.js +32 -0
- package/dist/esm/components/Flow/Minimap/Minimap.js.map +1 -0
- package/dist/esm/components/Flow/Minimap/Minimap.styles.js +16 -0
- package/dist/esm/components/Flow/Minimap/Minimap.styles.js.map +1 -0
- package/dist/esm/components/Flow/Sidebar/Sidebar.js +120 -0
- package/dist/esm/components/Flow/Sidebar/Sidebar.js.map +1 -0
- package/dist/esm/components/Flow/Sidebar/Sidebar.styles.js +34 -0
- package/dist/esm/components/Flow/Sidebar/Sidebar.styles.js.map +1 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroup.js +79 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroup.js.map +1 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroup.styles.js +37 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroup.styles.js.map +1 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.js +48 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.js.map +1 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.js +35 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.js.map +1 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.styles.js +26 -0
- package/dist/esm/components/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.styles.js.map +1 -0
- package/dist/esm/components/Flow/Sidebar/utils.js +27 -0
- package/dist/esm/components/Flow/Sidebar/utils.js.map +1 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/types/index.d.ts +216 -0
- package/package.json +10 -4
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const ReactFlow = require("reactflow");
|
|
4
|
+
const uikitStyles = require("@hitachivantara/uikit-styles");
|
|
5
|
+
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
6
|
+
const HvFlowBackground = ({
|
|
7
|
+
color = "secondary",
|
|
8
|
+
...others
|
|
9
|
+
}) => {
|
|
10
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ReactFlow.Background, {
|
|
11
|
+
color: uikitStyles.getColor(color, uikitStyles.theme.colors.secondary),
|
|
12
|
+
...others
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
exports.HvFlowBackground = HvFlowBackground;
|
|
16
|
+
//# sourceMappingURL=Background.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Background.cjs","sources":["../../../../../src/components/Flow/Background/Background.tsx"],"sourcesContent":["import { Background, BackgroundProps } from \"reactflow\";\n\nimport { HvColorAny, getColor, theme } from \"@hitachivantara/uikit-styles\";\n\nexport interface HvFlowBackgroundProps extends Omit<BackgroundProps, \"color\"> {\n /** Color for the background dots. Defaults to `secondary`. */\n color?: HvColorAny;\n}\n\nexport const HvFlowBackground = ({\n color = \"secondary\",\n ...others\n}: HvFlowBackgroundProps) => {\n return (\n <Background color={getColor(color, theme.colors.secondary)} {...others} />\n );\n};\n"],"names":["HvFlowBackground","color","others","Background","getColor","theme","colors","secondary"],"mappings":";;;;;AASO,MAAMA,mBAAmBA,CAAC;AAAA,EAC/BC,QAAQ;AAAA,EACR,GAAGC;AACkB,MAAM;AAC3B,wCACGC,UAAAA,YAAU;AAAA,IAACF,OAAOG,YAAAA,SAASH,OAAOI,YAAAA,MAAMC,OAAOC,SAAS;AAAA,IAAE,GAAKL;AAAAA,EAAAA,CAAS;AAE7E;;"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const ReactFlow = require("reactflow");
|
|
4
|
+
const shallow = require("zustand/shallow");
|
|
5
|
+
const uikitReactCore = require("@hitachivantara/uikit-react-core");
|
|
6
|
+
const uikitReactIcons = require("@hitachivantara/uikit-react-icons");
|
|
7
|
+
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
8
|
+
const DEFAULT_LABELS = {
|
|
9
|
+
fitView: "Fit view",
|
|
10
|
+
zoomIn: "Zoom in",
|
|
11
|
+
zoomOut: "Zoom out",
|
|
12
|
+
interactive: "Interactive"
|
|
13
|
+
};
|
|
14
|
+
const selector = (state) => ({
|
|
15
|
+
isInteractive: state.nodesDraggable || state.nodesConnectable || state.elementsSelectable,
|
|
16
|
+
minZoomReached: state.transform[2] <= state.minZoom,
|
|
17
|
+
maxZoomReached: state.transform[2] >= state.maxZoom
|
|
18
|
+
});
|
|
19
|
+
const HvFlowControls = ({
|
|
20
|
+
onZoomIn: onZoomInProp,
|
|
21
|
+
onZoomOut: onZoomOutProp,
|
|
22
|
+
onFitView: onFitViewProp,
|
|
23
|
+
labels: labelsProps,
|
|
24
|
+
hideInteractive,
|
|
25
|
+
hideFitView,
|
|
26
|
+
hideZoom,
|
|
27
|
+
position = "bottom-center",
|
|
28
|
+
orientation = "horizontal",
|
|
29
|
+
onInteractiveChange,
|
|
30
|
+
fitViewOptions,
|
|
31
|
+
children,
|
|
32
|
+
...others
|
|
33
|
+
}) => {
|
|
34
|
+
const {
|
|
35
|
+
isInteractive,
|
|
36
|
+
minZoomReached,
|
|
37
|
+
maxZoomReached
|
|
38
|
+
} = ReactFlow.useStore(selector, shallow.shallow);
|
|
39
|
+
const store = ReactFlow.useStoreApi();
|
|
40
|
+
const {
|
|
41
|
+
zoomIn,
|
|
42
|
+
zoomOut,
|
|
43
|
+
fitView
|
|
44
|
+
} = ReactFlow.useReactFlow();
|
|
45
|
+
const labels = uikitReactCore.useLabels(DEFAULT_LABELS, labelsProps);
|
|
46
|
+
const handleZoomIn = () => {
|
|
47
|
+
zoomIn();
|
|
48
|
+
onZoomInProp == null ? void 0 : onZoomInProp();
|
|
49
|
+
};
|
|
50
|
+
const handleZoomOut = () => {
|
|
51
|
+
zoomOut();
|
|
52
|
+
onZoomOutProp == null ? void 0 : onZoomOutProp();
|
|
53
|
+
};
|
|
54
|
+
const handleFitView = () => {
|
|
55
|
+
fitView(fitViewOptions);
|
|
56
|
+
onFitViewProp == null ? void 0 : onFitViewProp();
|
|
57
|
+
};
|
|
58
|
+
const handleInteractive = () => {
|
|
59
|
+
store.setState({
|
|
60
|
+
nodesDraggable: !isInteractive,
|
|
61
|
+
nodesConnectable: !isInteractive,
|
|
62
|
+
elementsSelectable: !isInteractive
|
|
63
|
+
});
|
|
64
|
+
onInteractiveChange == null ? void 0 : onInteractiveChange(!isInteractive);
|
|
65
|
+
};
|
|
66
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ReactFlow.Panel, {
|
|
67
|
+
position,
|
|
68
|
+
...others,
|
|
69
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(uikitReactCore.HvMultiButton, {
|
|
70
|
+
vertical: orientation === "vertical",
|
|
71
|
+
children: [!hideZoom && /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvButton, {
|
|
72
|
+
icon: true,
|
|
73
|
+
title: labels == null ? void 0 : labels.zoomIn,
|
|
74
|
+
onClick: handleZoomIn,
|
|
75
|
+
disabled: maxZoomReached,
|
|
76
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.ZoomIn, {
|
|
77
|
+
role: "none"
|
|
78
|
+
})
|
|
79
|
+
}), !hideZoom && /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvButton, {
|
|
80
|
+
icon: true,
|
|
81
|
+
title: labels == null ? void 0 : labels.zoomOut,
|
|
82
|
+
onClick: handleZoomOut,
|
|
83
|
+
disabled: minZoomReached,
|
|
84
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.ZoomOut, {
|
|
85
|
+
role: "none"
|
|
86
|
+
})
|
|
87
|
+
}), !hideFitView && /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvButton, {
|
|
88
|
+
icon: true,
|
|
89
|
+
title: labels == null ? void 0 : labels.fitView,
|
|
90
|
+
onClick: handleFitView,
|
|
91
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Focus, {
|
|
92
|
+
role: "none"
|
|
93
|
+
})
|
|
94
|
+
}), !hideInteractive && /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvButton, {
|
|
95
|
+
icon: true,
|
|
96
|
+
title: labels == null ? void 0 : labels.interactive,
|
|
97
|
+
onClick: handleInteractive,
|
|
98
|
+
children: isInteractive ? /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Unlock, {
|
|
99
|
+
role: "none"
|
|
100
|
+
}) : /* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Lock, {
|
|
101
|
+
role: "none"
|
|
102
|
+
})
|
|
103
|
+
}), children]
|
|
104
|
+
})
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
exports.HvFlowControls = HvFlowControls;
|
|
108
|
+
//# sourceMappingURL=Controls.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Controls.cjs","sources":["../../../../../src/components/Flow/Controls/Controls.tsx"],"sourcesContent":["import {\n ControlProps,\n Panel,\n PanelPosition,\n ReactFlowState,\n useReactFlow,\n useStore,\n useStoreApi,\n} from \"reactflow\";\n\nimport { shallow } from \"zustand/shallow\";\n\nimport {\n HvButton,\n HvMultiButton,\n useLabels,\n} from \"@hitachivantara/uikit-react-core\";\nimport {\n Focus,\n Lock,\n Unlock,\n ZoomIn,\n ZoomOut,\n} from \"@hitachivantara/uikit-react-icons\";\n\nexport type HvFlowControlsPosition = PanelPosition;\n\nexport interface HvFlowControlsProps\n extends Omit<\n ControlProps,\n \"position\" | \"showFitView\" | \"showInteractive\" | \"showZoom\"\n > {\n /** Controls position. Defaults to `bottom-center`. */\n position?: HvFlowControlsPosition;\n /** Controls orientation. Defaults to `horizontal`. */\n orientation?: \"vertical\" | \"horizontal\";\n /** Labels used on the controls buttons. */\n labels?: {\n zoomIn?: string;\n zoomOut?: string;\n fitView?: string;\n interactive?: string;\n };\n /** Whether to hide the zoom controls. */\n hideZoom?: boolean;\n /** Whether to hide the fit view controls. */\n hideFitView?: boolean;\n /** Whether to hide the interactive controls. */\n hideInteractive?: boolean;\n}\n\nconst DEFAULT_LABELS: HvFlowControlsProps[\"labels\"] = {\n fitView: \"Fit view\",\n zoomIn: \"Zoom in\",\n zoomOut: \"Zoom out\",\n interactive: \"Interactive\",\n};\n\nconst selector = (state: ReactFlowState) => ({\n isInteractive:\n state.nodesDraggable || state.nodesConnectable || state.elementsSelectable,\n minZoomReached: state.transform[2] <= state.minZoom,\n maxZoomReached: state.transform[2] >= state.maxZoom,\n});\n\nexport const HvFlowControls = ({\n onZoomIn: onZoomInProp,\n onZoomOut: onZoomOutProp,\n onFitView: onFitViewProp,\n labels: labelsProps,\n hideInteractive,\n hideFitView,\n hideZoom,\n position = \"bottom-center\",\n orientation = \"horizontal\",\n onInteractiveChange,\n fitViewOptions,\n children,\n ...others\n}: HvFlowControlsProps) => {\n const { isInteractive, minZoomReached, maxZoomReached } = useStore(\n selector,\n shallow\n );\n const store = useStoreApi();\n const { zoomIn, zoomOut, fitView } = useReactFlow();\n\n const labels = useLabels(DEFAULT_LABELS, labelsProps);\n\n const handleZoomIn = () => {\n zoomIn();\n onZoomInProp?.();\n };\n\n const handleZoomOut = () => {\n zoomOut();\n onZoomOutProp?.();\n };\n\n const handleFitView = () => {\n fitView(fitViewOptions);\n onFitViewProp?.();\n };\n\n const handleInteractive = () => {\n store.setState({\n nodesDraggable: !isInteractive,\n nodesConnectable: !isInteractive,\n elementsSelectable: !isInteractive,\n });\n\n onInteractiveChange?.(!isInteractive);\n };\n\n return (\n <Panel position={position} {...others}>\n <HvMultiButton vertical={orientation === \"vertical\"}>\n {!hideZoom && (\n <HvButton\n icon\n title={labels?.zoomIn}\n onClick={handleZoomIn}\n disabled={maxZoomReached}\n >\n <ZoomIn role=\"none\" />\n </HvButton>\n )}\n {!hideZoom && (\n <HvButton\n icon\n title={labels?.zoomOut}\n onClick={handleZoomOut}\n disabled={minZoomReached}\n >\n <ZoomOut role=\"none\" />\n </HvButton>\n )}\n {!hideFitView && (\n <HvButton icon title={labels?.fitView} onClick={handleFitView}>\n <Focus role=\"none\" />\n </HvButton>\n )}\n {!hideInteractive && (\n <HvButton\n icon\n title={labels?.interactive}\n onClick={handleInteractive}\n >\n {isInteractive ? <Unlock role=\"none\" /> : <Lock role=\"none\" />}\n </HvButton>\n )}\n {children}\n </HvMultiButton>\n </Panel>\n );\n};\n"],"names":["DEFAULT_LABELS","fitView","zoomIn","zoomOut","interactive","selector","state","isInteractive","nodesDraggable","nodesConnectable","elementsSelectable","minZoomReached","transform","minZoom","maxZoomReached","maxZoom","HvFlowControls","onZoomIn","onZoomInProp","onZoomOut","onZoomOutProp","onFitView","onFitViewProp","labels","labelsProps","hideInteractive","hideFitView","hideZoom","position","orientation","onInteractiveChange","fitViewOptions","children","others","useStore","shallow","store","useStoreApi","useReactFlow","useLabels","handleZoomIn","handleZoomOut","handleFitView","handleInteractive","setState","Panel","HvMultiButton","vertical","HvButton","icon","title","onClick","disabled","ZoomIn","role","ZoomOut","Focus","_jsx","Unlock","Lock"],"mappings":";;;;;;;AAmDA,MAAMA,iBAAgD;AAAA,EACpDC,SAAS;AAAA,EACTC,QAAQ;AAAA,EACRC,SAAS;AAAA,EACTC,aAAa;AACf;AAEA,MAAMC,WAAWA,CAACC,WAA2B;AAAA,EAC3CC,eACED,MAAME,kBAAkBF,MAAMG,oBAAoBH,MAAMI;AAAAA,EAC1DC,gBAAgBL,MAAMM,UAAU,CAAC,KAAKN,MAAMO;AAAAA,EAC5CC,gBAAgBR,MAAMM,UAAU,CAAC,KAAKN,MAAMS;AAC9C;AAEO,MAAMC,iBAAiBA,CAAC;AAAA,EAC7BC,UAAUC;AAAAA,EACVC,WAAWC;AAAAA,EACXC,WAAWC;AAAAA,EACXC,QAAQC;AAAAA,EACRC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,WAAW;AAAA,EACXC,cAAc;AAAA,EACdC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AACgB,MAAM;AACnB,QAA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AAA,QAACC,MAAI;AAAA,QAACC,OAAO3B,iCAAQtB;AAAAA,QAASkD,SAAST;AAAAA,QAAcV,yCAC3DwB,uBAAK;AAAA,UAACF,MAAK;AAAA,QAAA,CAAQ;AAAA,MACZ,CAAA,GAEX,CAAC7B,kDACCuB,yBAAQ;AAAA,QACPC,MAAI;AAAA,QACJC,OAAO3B,iCAAQnB;AAAAA,QACf+C,SAASR;AAAAA,QAAkBX,UAE1BzB,gBAAgBkD,2BAAAA,IAACC,wBAAM;AAAA,UAACJ,MAAK;AAAA,QAAA,CAAQ,IAAIG,2BAAAA,IAACE,sBAAI;AAAA,UAACL,MAAK;AAAA,QAAA,CAAQ;AAAA,MACrD,CAAA,GAEXtB,QAAQ;AAAA,IAAA,CACI;AAAA,EAAA,CACV;AAEX;;"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const ReactFlow = require("reactflow");
|
|
5
|
+
require("reactflow/dist/style.css");
|
|
6
|
+
const core = require("@dnd-kit/core");
|
|
7
|
+
const uid = require("uid");
|
|
8
|
+
const uikitReactCore = require("@hitachivantara/uikit-react-core");
|
|
9
|
+
const Flow_styles = require("./Flow.styles.cjs");
|
|
10
|
+
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
11
|
+
const FlowContext = require("./FlowContext/FlowContext.cjs");
|
|
12
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
13
|
+
const ReactFlow__default = /* @__PURE__ */ _interopDefault(ReactFlow);
|
|
14
|
+
const HvDroppableFlow = ({
|
|
15
|
+
id,
|
|
16
|
+
className,
|
|
17
|
+
children,
|
|
18
|
+
onFlowChange,
|
|
19
|
+
classes: classesProp,
|
|
20
|
+
nodes: initialNodes = [],
|
|
21
|
+
edges: initialEdges = [],
|
|
22
|
+
onConnect: onConnectProp,
|
|
23
|
+
onNodesChange: onNodesChangeProp,
|
|
24
|
+
onEdgesChange: onEdgesChangeProp,
|
|
25
|
+
...others
|
|
26
|
+
}) => {
|
|
27
|
+
const {
|
|
28
|
+
classes,
|
|
29
|
+
cx
|
|
30
|
+
} = Flow_styles.useClasses(classesProp);
|
|
31
|
+
const elementId = uikitReactCore.useUniqueId(id, "hvFlow");
|
|
32
|
+
const reactFlowInstance = ReactFlow.useReactFlow();
|
|
33
|
+
const {
|
|
34
|
+
nodeTypes
|
|
35
|
+
} = FlowContext.useFlowContext();
|
|
36
|
+
const [nodes, setNodes] = React.useState(initialNodes);
|
|
37
|
+
const [edges, setEdges] = React.useState(initialEdges);
|
|
38
|
+
const {
|
|
39
|
+
setNodeRef
|
|
40
|
+
} = core.useDroppable({
|
|
41
|
+
id: elementId
|
|
42
|
+
});
|
|
43
|
+
const handleDragEnd = React.useCallback((event) => {
|
|
44
|
+
var _a, _b, _c, _d;
|
|
45
|
+
if (event.over && event.over.id === elementId) {
|
|
46
|
+
const type = event.active.id.toString();
|
|
47
|
+
const position = reactFlowInstance.project({
|
|
48
|
+
x: (((_b = (_a = event.active.data.current) == null ? void 0 : _a.hvFlow) == null ? void 0 : _b.x) || 0) - event.over.rect.left,
|
|
49
|
+
y: (((_d = (_c = event.active.data.current) == null ? void 0 : _c.hvFlow) == null ? void 0 : _d.y) || 0) - event.over.rect.top
|
|
50
|
+
});
|
|
51
|
+
const newNode = {
|
|
52
|
+
id: uid.uid(),
|
|
53
|
+
position,
|
|
54
|
+
data: {},
|
|
55
|
+
type
|
|
56
|
+
};
|
|
57
|
+
setNodes((nds) => nds.concat(newNode));
|
|
58
|
+
}
|
|
59
|
+
}, [elementId, reactFlowInstance, setNodes]);
|
|
60
|
+
core.useDndMonitor({
|
|
61
|
+
onDragEnd: handleDragEnd
|
|
62
|
+
});
|
|
63
|
+
const handleFlowChange = React.useCallback((nds, eds) => {
|
|
64
|
+
const isDragging = nds.find((node) => node.dragging);
|
|
65
|
+
if (!isDragging) {
|
|
66
|
+
onFlowChange == null ? void 0 : onFlowChange(nds, eds);
|
|
67
|
+
}
|
|
68
|
+
}, [onFlowChange]);
|
|
69
|
+
const handleConnect = React.useCallback((connection) => {
|
|
70
|
+
const eds = ReactFlow.addEdge(connection, edges);
|
|
71
|
+
setEdges(eds);
|
|
72
|
+
handleFlowChange(nodes, eds);
|
|
73
|
+
onConnectProp == null ? void 0 : onConnectProp(connection);
|
|
74
|
+
}, [edges, handleFlowChange, nodes, onConnectProp]);
|
|
75
|
+
const handleNodesChange = React.useCallback((changes) => {
|
|
76
|
+
const nds = ReactFlow.applyNodeChanges(changes, nodes);
|
|
77
|
+
setNodes(nds);
|
|
78
|
+
handleFlowChange(nds, edges);
|
|
79
|
+
onNodesChangeProp == null ? void 0 : onNodesChangeProp(changes);
|
|
80
|
+
}, [edges, handleFlowChange, nodes, onNodesChangeProp]);
|
|
81
|
+
const handleEdgesChange = React.useCallback((changes) => {
|
|
82
|
+
const eds = ReactFlow.applyEdgeChanges(changes, edges);
|
|
83
|
+
setEdges(eds);
|
|
84
|
+
handleFlowChange(nodes, eds);
|
|
85
|
+
onEdgesChangeProp == null ? void 0 : onEdgesChangeProp(changes);
|
|
86
|
+
}, [edges, handleFlowChange, nodes, onEdgesChangeProp]);
|
|
87
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
88
|
+
id: elementId,
|
|
89
|
+
ref: setNodeRef,
|
|
90
|
+
className: cx(classes.root, className),
|
|
91
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ReactFlow__default.default, {
|
|
92
|
+
nodes,
|
|
93
|
+
edges,
|
|
94
|
+
nodeTypes,
|
|
95
|
+
onNodesChange: handleNodesChange,
|
|
96
|
+
onEdgesChange: handleEdgesChange,
|
|
97
|
+
onConnect: handleConnect,
|
|
98
|
+
...others,
|
|
99
|
+
children
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
exports.flowClasses = Flow_styles.staticClasses;
|
|
104
|
+
exports.HvDroppableFlow = HvDroppableFlow;
|
|
105
|
+
//# sourceMappingURL=DroppableFlow.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DroppableFlow.cjs","sources":["../../../../src/components/Flow/DroppableFlow.tsx"],"sourcesContent":["import { useCallback, useState } from \"react\";\n\nimport ReactFlow, {\n Connection,\n EdgeChange,\n NodeChange,\n ReactFlowProps,\n addEdge,\n applyEdgeChanges,\n applyNodeChanges,\n useReactFlow,\n} from \"reactflow\";\nimport \"reactflow/dist/style.css\";\n\nimport { DragEndEvent, useDndMonitor, useDroppable } from \"@dnd-kit/core\";\n\nimport { uid } from \"uid\";\n\nimport { ExtractNames, useUniqueId } from \"@hitachivantara/uikit-react-core\";\n\nimport { HvFlowEdge, HvFlowNode } from \"./types\";\nimport { staticClasses, useClasses } from \"./Flow.styles\";\nimport { useFlowContext } from \"./FlowContext\";\n\nexport { staticClasses as flowClasses };\n\nexport type HvFlowClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDroppableFlowProps<\n NodeData = any,\n NodeType extends string | undefined = string | undefined\n> extends Omit<ReactFlowProps, \"nodes\" | \"edges\" | \"nodeTypes\"> {\n /** Flow content: background, controls, and minimap. */\n children?: React.ReactNode;\n /** Flow nodes. */\n nodes?: HvFlowNode<NodeData, NodeType>[];\n /** Flow edges. */\n edges?: HvFlowEdge[];\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowClasses;\n /** Function called when the flow changes. Returns the updated nodes and edges. */\n onFlowChange?: (\n nodes: HvFlowNode<NodeData, NodeType>[],\n edges: HvFlowEdge[]\n ) => void;\n}\n\nexport const HvDroppableFlow = ({\n id,\n className,\n children,\n onFlowChange,\n classes: classesProp,\n nodes: initialNodes = [],\n edges: initialEdges = [],\n onConnect: onConnectProp,\n onNodesChange: onNodesChangeProp,\n onEdgesChange: onEdgesChangeProp,\n ...others\n}: HvDroppableFlowProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id, \"hvFlow\");\n\n const reactFlowInstance = useReactFlow();\n\n const { nodeTypes } = useFlowContext();\n\n const [nodes, setNodes] = useState(initialNodes);\n const [edges, setEdges] = useState(initialEdges);\n\n const { setNodeRef } = useDroppable({\n id: elementId,\n });\n\n const handleDragEnd = useCallback(\n (event: DragEndEvent) => {\n if (event.over && event.over.id === elementId) {\n const type = event.active.id.toString();\n\n // Converts the coordinates to the react flow coordinate system\n const position = reactFlowInstance.project({\n x: (event.active.data.current?.hvFlow?.x || 0) - event.over.rect.left,\n y: (event.active.data.current?.hvFlow?.y || 0) - event.over.rect.top,\n });\n\n const newNode: HvFlowNode = {\n id: uid(),\n position,\n data: {},\n type,\n };\n\n setNodes((nds) => nds.concat(newNode));\n }\n },\n [elementId, reactFlowInstance, setNodes]\n );\n\n useDndMonitor({\n onDragEnd: handleDragEnd,\n });\n\n const handleFlowChange = useCallback(\n (\n nds: NonNullable<HvDroppableFlowProps[\"nodes\"]>,\n eds: NonNullable<HvDroppableFlowProps[\"edges\"]>\n ) => {\n // The new flow is returned if the user is not dragging nodes\n // This avoids triggering this handler too many times\n const isDragging = nds.find((node) => node.dragging);\n if (!isDragging) {\n onFlowChange?.(nds, eds);\n }\n },\n [onFlowChange]\n );\n\n const handleConnect = useCallback(\n (connection: Connection) => {\n const eds = addEdge(connection, edges);\n setEdges(eds);\n\n handleFlowChange(nodes, eds);\n onConnectProp?.(connection);\n },\n [edges, handleFlowChange, nodes, onConnectProp]\n );\n\n const handleNodesChange = useCallback(\n (changes: NodeChange[]) => {\n const nds = applyNodeChanges(changes, nodes);\n setNodes(nds);\n\n handleFlowChange(nds, edges);\n onNodesChangeProp?.(changes);\n },\n [edges, handleFlowChange, nodes, onNodesChangeProp]\n );\n\n const handleEdgesChange = useCallback(\n (changes: EdgeChange[]) => {\n const eds = applyEdgeChanges(changes, edges);\n setEdges(eds);\n\n handleFlowChange(nodes, eds);\n onEdgesChangeProp?.(changes);\n },\n [edges, handleFlowChange, nodes, onEdgesChangeProp]\n );\n\n return (\n <div\n id={elementId}\n ref={setNodeRef}\n className={cx(classes.root, className)}\n >\n <ReactFlow\n nodes={nodes}\n edges={edges}\n nodeTypes={nodeTypes}\n onNodesChange={handleNodesChange}\n onEdgesChange={handleEdgesChange}\n onConnect={handleConnect}\n {...others}\n >\n {children}\n </ReactFlow>\n </div>\n );\n};\n"],"names":["HvDroppableFlow","id","className","children","onFlowChange","classes","classesProp","nodes","initialNodes","edges","initialEdges","onConnect","onConnectProp","onNodesChange","onNodesChangeProp","onEdgesChange","onEdgesChangeProp","others","cx","useClasses","elementId","useUniqueId","reactFlowInstance","useReactFlow","nodeTypes","useFlowContext","setNodes","useState","setEdges","setNodeRef","useDroppable","handleDragEnd","useCallback","event","over","type","active","toString","position","project","x","data","current","hvFlow","rect","left","y","top","newNode","uid","nds","concat","useDndMonitor","onDragEnd","handleFlowChange","eds","isDragging","find","node","dragging","handleConnect","connection","addEdge","handleNodesChange","changes","applyNodeChanges","handleEdgesChange","applyEdgeChanges","ref","root","ReactFlow"],"mappings":";;;;;;;;;;;;;AA+CO,MAAMA,kBAAkBA,CAAC;AAAA,EAC9BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,SAASC;AAAAA,EACTC,OAAOC,eAAe,CAAE;AAAA,EACxBC,OAAOC,eAAe,CAAE;AAAA,EACxBC,WAAWC;AAAAA,EACXC,eAAeC;AAAAA,EACfC,eAAeC;AAAAA,EACf,GAAGC;AACiB,MAAM;AACpB,QAAA;AAAA,IAAEZ;AAAAA,IAASa;AAAAA,EAAAA,IAAOC,YAAAA,WAAWb,WAAW;AAExCc,QAAAA,YAAYC,eAAAA,YAAYpB,IAAI,QAAQ;AAE1C,QAAMqB,oBAAoBC,UAAAA;AAEpB,QAAA;AAAA,IAAEC;AAAAA,MAAcC,YAAe,eAAA;AAErC,QAAM,CAAClB,OAAOmB,QAAQ,IAAIC,eAASnB,YAAY;AAC/C,QAAM,CAACC,OAAOmB,QAAQ,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C3B3C,mDAAgBiD;AAAAA,KAElB,CAACpD,OAAO6C,kBAAkB/C,OAAOK,aAAa,CAChD;AAEMmD,QAAAA,oBAAoB/B,kBACxB,CAACgC,YAA0B;AACnBd,UAAAA,MAAMe,UAAAA,iBAAiBD,SAASzD,KAAK;AAC3CmB,aAASwB,GAAG;AAEZI,qBAAiBJ,KAAKzC,KAAK;AAC3BK,2DAAoBkD;AAAAA,KAEtB,CAACvD,OAAO6C,kBAAkB/C,OAAOO,iBAAiB,CACpD;AAEMoD,QAAAA,oBAAoBlC,kBACxB,CAACgC,YAA0B;AACnBT,UAAAA,MAAMY,UAAAA,iBAAiBH,SAASvD,KAAK;AAC3CmB,aAAS2B,GAAG;AAEZD,qBAAiB/C,OAAOgD,GAAG;AAC3BvC,2DAAoBgD;AAAAA,KAEtB,CAACvD,OAAO6C,kBAAkB/C,OAAOS,iBAAiB,CACpD;AAEA,wCACE,OAAA;AAAA,IACEf,IAAImB;AAAAA,IACJgD,KAAKvC;AAAAA,IACL3B,WAAWgB,GAAGb,QAAQgE,MAAMnE,SAAS;AAAA,IAAEC,yCAEtCmE,4BAAS;AAAA,MACR/D;AAAAA,MACAE;AAAAA,MACAe;AAAAA,MACAX,eAAekD;AAAAA,MACfhD,eAAemD;AAAAA,MACfvD,WAAWiD;AAAAA,MAAc,GACrB3C;AAAAA,MAAMd;AAAAA,IAAAA,CAGD;AAAA,EAAA,CACR;AAET;;;"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const core = require("@dnd-kit/core");
|
|
5
|
+
const modifiers = require("@dnd-kit/modifiers");
|
|
6
|
+
const ReactFlow = require("reactflow");
|
|
7
|
+
const DroppableFlow = require("./DroppableFlow.cjs");
|
|
8
|
+
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
9
|
+
const FlowContext = require("./FlowContext/FlowContext.cjs");
|
|
10
|
+
const SidebarGroupItem = require("./Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.cjs");
|
|
11
|
+
const HvFlow = ({
|
|
12
|
+
nodeTypes,
|
|
13
|
+
nodeGroups,
|
|
14
|
+
sidebar,
|
|
15
|
+
dndContextProps,
|
|
16
|
+
...others
|
|
17
|
+
}) => {
|
|
18
|
+
const [draggingLabel, setDraggingLabel] = React.useState(void 0);
|
|
19
|
+
const sensors = core.useSensors(core.useSensor(core.PointerSensor), core.useSensor(core.KeyboardSensor));
|
|
20
|
+
const handleDragStart = (event) => {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
if ((_a = event.active.data.current) == null ? void 0 : _a.hvFlow) {
|
|
23
|
+
setDraggingLabel((_b = event.active.data.current.hvFlow) == null ? void 0 : _b.label);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const handleDragEnd = () => {
|
|
27
|
+
setDraggingLabel(void 0);
|
|
28
|
+
};
|
|
29
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ReactFlow.ReactFlowProvider, {
|
|
30
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(FlowContext.HvFlowProvider, {
|
|
31
|
+
nodeGroups,
|
|
32
|
+
nodeTypes,
|
|
33
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(core.DndContext, {
|
|
34
|
+
onDragStart: handleDragStart,
|
|
35
|
+
onDragEnd: handleDragEnd,
|
|
36
|
+
sensors,
|
|
37
|
+
modifiers: [modifiers.restrictToWindowEdges],
|
|
38
|
+
...dndContextProps,
|
|
39
|
+
children: [/* @__PURE__ */ jsxRuntime.jsx(DroppableFlow.HvDroppableFlow, {
|
|
40
|
+
...others
|
|
41
|
+
}), sidebar, /* @__PURE__ */ jsxRuntime.jsx(core.DragOverlay, {
|
|
42
|
+
modifiers: [modifiers.restrictToWindowEdges],
|
|
43
|
+
children: draggingLabel ? /* @__PURE__ */ jsxRuntime.jsx(SidebarGroupItem.HvFlowSidebarGroupItem, {
|
|
44
|
+
label: draggingLabel,
|
|
45
|
+
isDragging: true
|
|
46
|
+
}) : null
|
|
47
|
+
})]
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
exports.HvFlow = HvFlow;
|
|
53
|
+
//# sourceMappingURL=Flow.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Flow.cjs","sources":["../../../../src/components/Flow/Flow.tsx"],"sourcesContent":["import { useState } from \"react\";\n\nimport {\n DndContext,\n DndContextProps,\n DragOverlay,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport { restrictToWindowEdges } from \"@dnd-kit/modifiers\";\n\nimport { ReactFlowProvider } from \"reactflow\";\n\nimport { HvFlowNodeGroups, HvFlowNodeTypes } from \"./types\";\nimport { HvFlowProvider } from \"./FlowContext\";\nimport { HvDroppableFlow, HvDroppableFlowProps } from \"./DroppableFlow\";\nimport { HvFlowSidebarGroupItem } from \"./Sidebar/SidebarGroup/SidebarGroupItem\";\n\nexport interface HvFlowProps<\n NodeData = any,\n NodeType extends string | undefined = string | undefined,\n NodeGroups extends keyof any = string\n> extends HvDroppableFlowProps<NodeData, NodeType> {\n /** Flow nodes groups. */\n nodeGroups?: HvFlowNodeGroups<NodeGroups>;\n /** Flow nodes types. */\n nodeTypes?: HvFlowNodeTypes<NodeGroups>;\n /** Flow sidebar. */\n sidebar?: React.ReactNode;\n /**\n * Dnd Kit context props. This should be used for accessibility purposes.\n *\n * More information can be found on the [Dnd Kit documentation](https://docs.dndkit.com/guides/accessibility)\n */\n dndContextProps?: Pick<DndContextProps, \"accessibility\">;\n}\n\n/**\n * Flow component to build interactive node-based UIs.\n *\n * This implementation leverages [React Flow](https://reactflow.dev).\n * The drag and drop functionality leverages [Dnd Kit](https://docs.dndkit.com)\n *\n * DISCLAIMER: This component is a work in progress and there might be breaking changes.\n */\nexport const HvFlow = ({\n nodeTypes,\n nodeGroups,\n sidebar,\n dndContextProps,\n ...others\n}: HvFlowProps) => {\n const [draggingLabel, setDraggingLabel] = useState(undefined);\n\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor)\n );\n\n const handleDragStart: DndContextProps[\"onDragStart\"] = (event) => {\n if (event.active.data.current?.hvFlow) {\n setDraggingLabel(event.active.data.current.hvFlow?.label);\n }\n };\n\n const handleDragEnd: DndContextProps[\"onDragEnd\"] = () => {\n setDraggingLabel(undefined);\n };\n\n // We're wrapping the main Flow component with the ReactFlowProvider to access the react flow instance.\n // HvFlowContext is our custom internal context.\n return (\n <ReactFlowProvider>\n <HvFlowProvider nodeGroups={nodeGroups} nodeTypes={nodeTypes}>\n <DndContext\n onDragStart={handleDragStart}\n onDragEnd={handleDragEnd}\n sensors={sensors}\n modifiers={[restrictToWindowEdges]}\n {...dndContextProps}\n >\n <HvDroppableFlow {...others} />\n {sidebar}\n <DragOverlay modifiers={[restrictToWindowEdges]}>\n {draggingLabel ? (\n <HvFlowSidebarGroupItem label={draggingLabel} isDragging />\n ) : null}\n </DragOverlay>\n </DndContext>\n </HvFlowProvider>\n </ReactFlowProvider>\n );\n};\n"],"names":["HvFlow","nodeTypes","nodeGroups","sidebar","dndContextProps","others","draggingLabel","setDraggingLabel","useState","undefined","sensors","useSensors","useSensor","PointerSensor","KeyboardSensor","handleDragStart","event","active","data","current","hvFlow","label","handleDragEnd","ReactFlowProvider","children","HvFlowProvider","DndContext","onDragStart","onDragEnd","modifiers","restrictToWindowEdges","_jsx","HvDroppableFlow","DragOverlay","HvFlowSidebarGroupItem","isDragging"],"mappings":";;;;;;;;;;AA+CO,MAAMA,SAASA,CAAC;AAAA,EACrBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AACQ,MAAM;AACjB,QAAM,CAACC,eAAeC,gBAAgB,IAAIC,MAAAA,SAASC,MAAS;AAE5D,QAAMC,UAAUC,KAAAA,WACdC,KAAAA,UAAUC,KAAa,aAAA,GACvBD,KAAAA,UAAUE,KAAc,cAAA,CAC1B;AAEA,QAAMC,kBAAmDC,CAAU,UAAA;;AACjE,SAAIA,WAAMC,OAAOC,KAAKC,YAAlBH,mBAA2BI,QAAQ;AACrCb,wBAAiBS,WAAMC,OAAOC,KAAKC,QAAQC,WAA1BJ,mBAAkCK,KAAK;AAAA,IAC1D;AAAA,EAAA;AAGF,QAAMC,gBAA8CA,MAAM;AACxDf,qBAAiBE,MAAS;AAAA,EAAA;AAK5B,wCACGc,UAAAA,mBAAiB;AAAA,IAAAC,yCACfC,4BAAc;AAAA,MAACvB;AAAAA,MAAwBD;AAAAA,MAAqBuB,0CAC1DE,iBAAU;AAAA,QACTC,aAAaZ;AAAAA,QACba,WAAWN;AAAAA,QACXZ;AAAAA,QACAmB,WAAW,CAACC,UAAAA,qBAAqB;AAAA,QAAE,GAC/B1B;AAAAA,QAAeoB,UAAA,CAEnBO,2BAAAA,IAACC,+BAAe;AAAA,UAAA,GAAK3B;AAAAA,QAAAA,CAAS,GAC7BF,SACD4B,2BAAAA,IAACE,kBAAW;AAAA,UAACJ,WAAW,CAACC,UAAAA,qBAAqB;AAAA,UAAEN,UAC7ClB,gBACCyB,2BAAAA,IAACG,yCAAsB;AAAA,YAACb,OAAOf;AAAAA,YAAe6B,YAAU;AAAA,UAAE,CAAA,IACxD;AAAA,QAAA,CACO,CAAC;AAAA,MAAA,CACJ;AAAA,IAAA,CACE;AAAA,EAAA,CACC;AAEvB;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const uikitReactCore = require("@hitachivantara/uikit-react-core");
|
|
4
|
+
const {
|
|
5
|
+
staticClasses,
|
|
6
|
+
useClasses
|
|
7
|
+
} = uikitReactCore.createClasses("HvFlow", {
|
|
8
|
+
root: {
|
|
9
|
+
height: "100%"
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.staticClasses = staticClasses;
|
|
13
|
+
exports.useClasses = useClasses;
|
|
14
|
+
//# sourceMappingURL=Flow.styles.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Flow.styles.cjs","sources":["../../../../src/components/Flow/Flow.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-core\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFlow\", {\n root: { height: \"100%\" },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","height"],"mappings":";;;AAEa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,eAAAA,cAAc,UAAU;AAAA,EACnEC,MAAM;AAAA,IAAEC,QAAQ;AAAA,EAAO;AACzB,CAAC;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
+
const HvFlowContext = React.createContext({});
|
|
6
|
+
const HvFlowProvider = ({
|
|
7
|
+
nodeGroups,
|
|
8
|
+
nodeTypes,
|
|
9
|
+
children
|
|
10
|
+
}) => {
|
|
11
|
+
const [expandedNodeGroups, setExpandedNodeGroups] = React.useState([]);
|
|
12
|
+
const value = React.useMemo(() => ({
|
|
13
|
+
nodeTypes,
|
|
14
|
+
nodeGroups,
|
|
15
|
+
expandedNodeGroups,
|
|
16
|
+
setExpandedNodeGroups
|
|
17
|
+
}), [nodeGroups, nodeTypes, expandedNodeGroups]);
|
|
18
|
+
return /* @__PURE__ */ jsxRuntime.jsx(HvFlowContext.Provider, {
|
|
19
|
+
value,
|
|
20
|
+
children
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const useFlowContext = () => React.useContext(HvFlowContext);
|
|
24
|
+
exports.HvFlowContext = HvFlowContext;
|
|
25
|
+
exports.HvFlowProvider = HvFlowProvider;
|
|
26
|
+
exports.useFlowContext = useFlowContext;
|
|
27
|
+
//# sourceMappingURL=FlowContext.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlowContext.cjs","sources":["../../../../../src/components/Flow/FlowContext/FlowContext.tsx"],"sourcesContent":["import {\n Dispatch,\n SetStateAction,\n createContext,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nimport { HvFlowNodeGroups, HvFlowNodeTypes } from \"../types\";\n\nexport interface HvFlowContextValue<NodeGroups extends keyof any = string> {\n /** Flow nodes types. */\n nodeTypes?: HvFlowNodeTypes<NodeGroups>;\n /** Flow nodes groups. */\n nodeGroups?: HvFlowNodeGroups<NodeGroups>;\n /** Flow nodes groups expanded on sidebar. */\n expandedNodeGroups?: string[];\n /** Function to set `expandedNodeGroups`. */\n setExpandedNodeGroups?: Dispatch<SetStateAction<string[]>>;\n}\n\nexport const HvFlowContext = createContext<HvFlowContextValue>({});\n\nexport interface HvFlowProviderProps<NodeGroups extends keyof any = string> {\n /** Flow nodes types. */\n nodeTypes?: HvFlowContextValue<NodeGroups>[\"nodeTypes\"];\n /** Flow nodes groups. */\n nodeGroups?: HvFlowContextValue<NodeGroups>[\"nodeGroups\"];\n /** Children. */\n children?: React.ReactNode;\n}\n\nexport const HvFlowProvider = ({\n nodeGroups,\n nodeTypes,\n children,\n}: HvFlowProviderProps) => {\n const [expandedNodeGroups, setExpandedNodeGroups] = useState<string[]>([]);\n\n const value = useMemo(\n () => ({\n nodeTypes,\n nodeGroups,\n expandedNodeGroups,\n setExpandedNodeGroups,\n }),\n [nodeGroups, nodeTypes, expandedNodeGroups]\n );\n\n return (\n <HvFlowContext.Provider value={value}>{children}</HvFlowContext.Provider>\n );\n};\n\nexport const useFlowContext = () => useContext(HvFlowContext);\n"],"names":["HvFlowContext","createContext","HvFlowProvider","nodeGroups","nodeTypes","children","expandedNodeGroups","setExpandedNodeGroups","useState","value","useMemo","_jsx","Provider","useFlowContext","useContext"],"mappings":";;;;AAsBaA,MAAAA,gBAAgBC,MAAkC,cAAA,EAAE;AAW1D,MAAMC,iBAAiBA,CAAC;AAAA,EAC7BC;AAAAA,EACAC;AAAAA,EACAC;AACmB,MAAM;AACzB,QAAM,CAACC,oBAAoBC,qBAAqB,IAAIC,MAAAA,SAAmB,CAAE,CAAA;AAEnEC,QAAAA,QAAQC,MAAAA,QACZ,OAAO;AAAA,IACLN;AAAAA,IACAD;AAAAA,IACAG;AAAAA,IACAC;AAAAA,EAEF,IAAA,CAACJ,YAAYC,WAAWE,kBAAkB,CAC5C;AAGEK,SAAAA,2BAAAA,IAACX,cAAcY,UAAQ;AAAA,IAACH;AAAAA,IAAaJ;AAAAA,EAAAA,CAAmC;AAE5E;AAEaQ,MAAAA,iBAAiBA,MAAMC,MAAAA,WAAWd,aAAa;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const ReactFlow = require("reactflow");
|
|
4
|
+
const uikitStyles = require("@hitachivantara/uikit-styles");
|
|
5
|
+
const Minimap_styles = require("./Minimap.styles.cjs");
|
|
6
|
+
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
7
|
+
const HvFlowMinimap = ({
|
|
8
|
+
nodeColor = "atmo4",
|
|
9
|
+
maskColor = "atmo3",
|
|
10
|
+
maskStrokeColor = "atmo3",
|
|
11
|
+
nodeStrokeColor = "atmo4",
|
|
12
|
+
classes: classesProp,
|
|
13
|
+
className,
|
|
14
|
+
...others
|
|
15
|
+
}) => {
|
|
16
|
+
const {
|
|
17
|
+
classes,
|
|
18
|
+
cx
|
|
19
|
+
} = Minimap_styles.useClasses(classesProp);
|
|
20
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ReactFlow.MiniMap, {
|
|
21
|
+
className: cx(classes.root, className),
|
|
22
|
+
nodeColor: typeof nodeColor === "string" ? uikitStyles.getColor(nodeColor, uikitStyles.theme.colors.atmo4) : nodeColor,
|
|
23
|
+
nodeStrokeColor: typeof nodeStrokeColor === "string" ? uikitStyles.getColor(nodeStrokeColor, uikitStyles.theme.colors.atmo4) : nodeStrokeColor,
|
|
24
|
+
maskColor: uikitStyles.getColor(maskColor, uikitStyles.theme.colors.atmo3),
|
|
25
|
+
maskStrokeColor: uikitStyles.getColor(maskStrokeColor, uikitStyles.theme.colors.atmo3),
|
|
26
|
+
...others
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
exports.flowMinimapClasses = Minimap_styles.staticClasses;
|
|
30
|
+
exports.HvFlowMinimap = HvFlowMinimap;
|
|
31
|
+
//# sourceMappingURL=Minimap.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Minimap.cjs","sources":["../../../../../src/components/Flow/Minimap/Minimap.tsx"],"sourcesContent":["import { GetMiniMapNodeAttribute, MiniMap, MiniMapProps } from \"reactflow\";\n\nimport { ExtractNames } from \"@hitachivantara/uikit-react-core\";\nimport { HvColorAny, getColor, theme } from \"@hitachivantara/uikit-styles\";\n\nimport { staticClasses, useClasses } from \"./Minimap.styles\";\n\nexport { staticClasses as flowMinimapClasses };\n\nexport type HvFlowMinimapClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFlowMinimapProps<NodeData = any>\n extends Omit<\n MiniMapProps<NodeData>,\n \"nodeColor\" | \"nodeStrokeColor\" | \"maskColor\" | \"maskStrokeColor\"\n > {\n /** Node color. Defaults to `atmo4`. */\n nodeColor?: HvColorAny | GetMiniMapNodeAttribute<NodeData>;\n /** Node stroke color. Defaults to `atmo4`. */\n nodeStrokeColor?: HvColorAny | GetMiniMapNodeAttribute<NodeData>;\n /** Mask color. Defaults to `atmo3`. */\n maskColor?: HvColorAny;\n /** Mask stroke color. Defaults to `atmo3`. */\n maskStrokeColor?: HvColorAny;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowMinimapClasses;\n}\n\nexport const HvFlowMinimap = ({\n nodeColor = \"atmo4\",\n maskColor = \"atmo3\",\n maskStrokeColor = \"atmo3\",\n nodeStrokeColor = \"atmo4\",\n classes: classesProp,\n className,\n ...others\n}: HvFlowMinimapProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n return (\n <MiniMap\n className={cx(classes.root, className)}\n nodeColor={\n typeof nodeColor === \"string\"\n ? getColor(nodeColor, theme.colors.atmo4)\n : nodeColor\n }\n nodeStrokeColor={\n typeof nodeStrokeColor === \"string\"\n ? getColor(nodeStrokeColor, theme.colors.atmo4)\n : nodeStrokeColor\n }\n maskColor={getColor(maskColor, theme.colors.atmo3)}\n maskStrokeColor={getColor(maskStrokeColor, theme.colors.atmo3)}\n {...others}\n />\n );\n};\n"],"names":["HvFlowMinimap","nodeColor","maskColor","maskStrokeColor","nodeStrokeColor","classes","classesProp","className","others","cx","useClasses","MiniMap","root","getColor","theme","colors","atmo4","atmo3"],"mappings":";;;;;;AA4BO,MAAMA,gBAAgBA,CAAC;AAAA,EAC5BC,YAAY;AAAA,EACZC,YAAY;AAAA,EACZC,kBAAkB;AAAA,EAClBC,kBAAkB;AAAA,EAClBC,SAASC;AAAAA,EACTC;AAAAA,EACA,GAAGC;AACe,MAAM;AAClB,QAAA;AAAA,IAAEH;AAAAA,IAASI;AAAAA,EAAAA,IAAOC,eAAAA,WAAWJ,WAAW;AAE9C,wCACGK,UAAAA,SAAO;AAAA,IACNJ,WAAWE,GAAGJ,QAAQO,MAAML,SAAS;AAAA,IACrCN,WACE,OAAOA,cAAc,WACjBY,qBAASZ,WAAWa,kBAAMC,OAAOC,KAAK,IACtCf;AAAAA,IAENG,iBACE,OAAOA,oBAAoB,WACvBS,qBAAST,iBAAiBU,kBAAMC,OAAOC,KAAK,IAC5CZ;AAAAA,IAENF,WAAWW,YAAAA,SAASX,WAAWY,YAAAA,MAAMC,OAAOE,KAAK;AAAA,IACjDd,iBAAiBU,YAAAA,SAASV,iBAAiBW,YAAAA,MAAMC,OAAOE,KAAK;AAAA,IAAE,GAC3DT;AAAAA,EAAAA,CACL;AAEL;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const uikitReactCore = require("@hitachivantara/uikit-react-core");
|
|
4
|
+
const {
|
|
5
|
+
staticClasses,
|
|
6
|
+
useClasses
|
|
7
|
+
} = uikitReactCore.createClasses("HvFlowMinimap", {
|
|
8
|
+
root: {
|
|
9
|
+
"&.react-flow__minimap": {
|
|
10
|
+
backgroundColor: uikitReactCore.theme.colors.atmo2
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
exports.staticClasses = staticClasses;
|
|
15
|
+
exports.useClasses = useClasses;
|
|
16
|
+
//# sourceMappingURL=Minimap.styles.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Minimap.styles.cjs","sources":["../../../../../src/components/Flow/Minimap/Minimap.styles.tsx"],"sourcesContent":["import { createClasses, theme } from \"@hitachivantara/uikit-react-core\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFlowMinimap\", {\n root: {\n \"&.react-flow__minimap\": { backgroundColor: theme.colors.atmo2 },\n },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","backgroundColor","theme","colors","atmo2"],"mappings":";;;AAEa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,eAAAA,cAAc,iBAAiB;AAAA,EAC1EC,MAAM;AAAA,IACJ,yBAAyB;AAAA,MAAEC,iBAAiBC,eAAAA,MAAMC,OAAOC;AAAAA,IAAM;AAAA,EACjE;AACF,CAAC;;;"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const debounce = require("lodash/debounce");
|
|
5
|
+
const core = require("@dnd-kit/core");
|
|
6
|
+
const uikitReactCore = require("@hitachivantara/uikit-react-core");
|
|
7
|
+
const uikitReactIcons = require("@hitachivantara/uikit-react-icons");
|
|
8
|
+
const Sidebar_styles = require("./Sidebar.styles.cjs");
|
|
9
|
+
const utils = require("./utils.cjs");
|
|
10
|
+
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
11
|
+
const SidebarGroup = require("./SidebarGroup/SidebarGroup.cjs");
|
|
12
|
+
const FlowContext = require("../FlowContext/FlowContext.cjs");
|
|
13
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
14
|
+
const debounce__default = /* @__PURE__ */ _interopDefault(debounce);
|
|
15
|
+
const DEFAULT_LABELS = {
|
|
16
|
+
itemAriaRoleDescription: "Draggable",
|
|
17
|
+
expandGroupButtonAriaLabel: "Expand group",
|
|
18
|
+
searchPlaceholder: "Search node...",
|
|
19
|
+
searchAriaLabel: "Search node..."
|
|
20
|
+
};
|
|
21
|
+
const HvFlowSidebar = ({
|
|
22
|
+
id,
|
|
23
|
+
title,
|
|
24
|
+
description,
|
|
25
|
+
anchor = "right",
|
|
26
|
+
buttonTitle = "Close",
|
|
27
|
+
classes: classesProp,
|
|
28
|
+
labels: labelsProps,
|
|
29
|
+
...others
|
|
30
|
+
}) => {
|
|
31
|
+
const {
|
|
32
|
+
classes
|
|
33
|
+
} = Sidebar_styles.useClasses(classesProp);
|
|
34
|
+
const {
|
|
35
|
+
nodeGroups,
|
|
36
|
+
nodeTypes,
|
|
37
|
+
setExpandedNodeGroups
|
|
38
|
+
} = FlowContext.useFlowContext();
|
|
39
|
+
const unfilteredGroups = React.useMemo(() => utils.buildGroups(nodeGroups, nodeTypes), [nodeGroups, nodeTypes]);
|
|
40
|
+
const [groups, setGroups] = React.useState(unfilteredGroups);
|
|
41
|
+
const labels = uikitReactCore.useLabels(DEFAULT_LABELS, labelsProps);
|
|
42
|
+
const drawerElementId = uikitReactCore.useUniqueId(id, "hvFlowSidebarDrawer");
|
|
43
|
+
const groupsElementId = uikitReactCore.useUniqueId(id, "hvFlowSidebarGroups");
|
|
44
|
+
const {
|
|
45
|
+
setNodeRef
|
|
46
|
+
} = core.useDroppable({
|
|
47
|
+
id: drawerElementId
|
|
48
|
+
});
|
|
49
|
+
const handleSearch = (event, value) => {
|
|
50
|
+
const gps = value ? Object.entries(unfilteredGroups).reduce((acc, curr) => {
|
|
51
|
+
const filteredNodes = curr[1].nodes.filter((obj) => obj.label.toLocaleLowerCase().includes(value.toLocaleLowerCase()));
|
|
52
|
+
const nodesCount = filteredNodes.length;
|
|
53
|
+
if (nodesCount > 0) {
|
|
54
|
+
acc[curr[0]] = {
|
|
55
|
+
...curr[1],
|
|
56
|
+
nodes: filteredNodes
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return acc;
|
|
60
|
+
}, {}) : unfilteredGroups;
|
|
61
|
+
setGroups(gps);
|
|
62
|
+
setExpandedNodeGroups == null ? void 0 : setExpandedNodeGroups(value ? Object.keys(gps) : []);
|
|
63
|
+
};
|
|
64
|
+
const handleDebouncedSearch = debounce__default.default(handleSearch, 500);
|
|
65
|
+
return /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvDrawer, {
|
|
66
|
+
BackdropComponent: void 0,
|
|
67
|
+
variant: "persistent",
|
|
68
|
+
classes: {
|
|
69
|
+
paper: classes.drawerPaper
|
|
70
|
+
},
|
|
71
|
+
anchor,
|
|
72
|
+
buttonTitle,
|
|
73
|
+
...others,
|
|
74
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
75
|
+
id: drawerElementId,
|
|
76
|
+
ref: setNodeRef,
|
|
77
|
+
children: [/* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
78
|
+
className: classes.titleContainer,
|
|
79
|
+
children: [/* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Add, {
|
|
80
|
+
role: "none"
|
|
81
|
+
}), /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, {
|
|
82
|
+
variant: "title3",
|
|
83
|
+
children: title
|
|
84
|
+
})]
|
|
85
|
+
}), /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
86
|
+
className: classes.contentContainer,
|
|
87
|
+
children: [/* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvTypography, {
|
|
88
|
+
className: classes.description,
|
|
89
|
+
children: description
|
|
90
|
+
}), /* @__PURE__ */ jsxRuntime.jsx(uikitReactCore.HvInput, {
|
|
91
|
+
className: classes.searchRoot,
|
|
92
|
+
type: "search",
|
|
93
|
+
placeholder: labels == null ? void 0 : labels.searchPlaceholder,
|
|
94
|
+
"aria-label": labels == null ? void 0 : labels.searchAriaLabel,
|
|
95
|
+
"aria-controls": groupsElementId,
|
|
96
|
+
"aria-owns": groupsElementId,
|
|
97
|
+
onChange: handleDebouncedSearch,
|
|
98
|
+
inputProps: {
|
|
99
|
+
autoComplete: "off"
|
|
100
|
+
}
|
|
101
|
+
}), /* @__PURE__ */ jsxRuntime.jsx("ul", {
|
|
102
|
+
id: groupsElementId,
|
|
103
|
+
className: classes.groupsContainer,
|
|
104
|
+
children: Object.entries(groups).map((obj) => /* @__PURE__ */ jsxRuntime.jsx(SidebarGroup.HvFlowSidebarGroup, {
|
|
105
|
+
id: obj[0],
|
|
106
|
+
expandButtonProps: {
|
|
107
|
+
"aria-label": labels == null ? void 0 : labels.expandGroupButtonAriaLabel
|
|
108
|
+
},
|
|
109
|
+
itemProps: {
|
|
110
|
+
"aria-roledescription": labels == null ? void 0 : labels.itemAriaRoleDescription
|
|
111
|
+
},
|
|
112
|
+
...obj[1]
|
|
113
|
+
}, obj[0]))
|
|
114
|
+
})]
|
|
115
|
+
})]
|
|
116
|
+
})
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
exports.flowSidebarClasses = Sidebar_styles.staticClasses;
|
|
120
|
+
exports.HvFlowSidebar = HvFlowSidebar;
|
|
121
|
+
//# sourceMappingURL=Sidebar.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sidebar.cjs","sources":["../../../../../src/components/Flow/Sidebar/Sidebar.tsx"],"sourcesContent":["import { useMemo, useState } from \"react\";\n\nimport debounce from \"lodash/debounce\";\n\nimport { useDroppable } from \"@dnd-kit/core\";\n\nimport {\n ExtractNames,\n HvDrawer,\n HvDrawerProps,\n HvInput,\n HvInputProps,\n HvTypography,\n useLabels,\n useUniqueId,\n} from \"@hitachivantara/uikit-react-core\";\nimport { Add } from \"@hitachivantara/uikit-react-icons\";\n\nimport { staticClasses, useClasses } from \"./Sidebar.styles\";\nimport { HvFlowSidebarGroup } from \"./SidebarGroup\";\nimport { useFlowContext } from \"../FlowContext\";\nimport { buildGroups } from \"./utils\";\n\nexport { staticClasses as flowSidebarClasses };\n\nexport type HvFlowSidebarClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFlowSidebarProps\n extends Omit<HvDrawerProps, \"classes\" | \"title\"> {\n /** Sidebar title. */\n title?: string;\n /** Sidebar description. */\n description?: string;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFlowSidebarClasses;\n /** Labels used on the sidebar. */\n labels?: {\n itemAriaRoleDescription?: string;\n expandGroupButtonAriaLabel?: string;\n searchPlaceholder?: string;\n searchAriaLabel?: string;\n };\n}\n\nconst DEFAULT_LABELS: HvFlowSidebarProps[\"labels\"] = {\n itemAriaRoleDescription: \"Draggable\",\n expandGroupButtonAriaLabel: \"Expand group\",\n searchPlaceholder: \"Search node...\",\n searchAriaLabel: \"Search node...\",\n};\n\nexport const HvFlowSidebar = ({\n id,\n title,\n description,\n anchor = \"right\",\n buttonTitle = \"Close\",\n classes: classesProp,\n labels: labelsProps,\n ...others\n}: HvFlowSidebarProps) => {\n const { classes } = useClasses(classesProp);\n\n const { nodeGroups, nodeTypes, setExpandedNodeGroups } = useFlowContext();\n\n const unfilteredGroups = useMemo(\n () => buildGroups(nodeGroups, nodeTypes),\n [nodeGroups, nodeTypes]\n );\n\n const [groups, setGroups] = useState(unfilteredGroups);\n\n const labels = useLabels(DEFAULT_LABELS, labelsProps);\n\n const drawerElementId = useUniqueId(id, \"hvFlowSidebarDrawer\");\n const groupsElementId = useUniqueId(id, \"hvFlowSidebarGroups\");\n\n // The sidebar is droppable to distinguish between the canvas and the sidebar\n // Otherwise items dropped inside the sidebar will be added to the canvas\n const { setNodeRef } = useDroppable({\n id: drawerElementId,\n });\n\n const handleSearch: HvInputProps[\"onChange\"] = (event, value) => {\n const gps = value\n ? Object.entries(unfilteredGroups).reduce((acc, curr) => {\n // Filter nodes by search\n const filteredNodes = curr[1].nodes.filter((obj) =>\n obj.label.toLocaleLowerCase().includes(value.toLocaleLowerCase())\n );\n const nodesCount = filteredNodes.length;\n\n // Only show groups with nodes\n if (nodesCount > 0) {\n acc[curr[0]] = {\n ...curr[1],\n nodes: filteredNodes,\n };\n }\n\n return acc;\n }, {})\n : unfilteredGroups;\n\n setGroups(gps);\n setExpandedNodeGroups?.(value ? Object.keys(gps) : []);\n };\n\n const handleDebouncedSearch = debounce(handleSearch, 500);\n\n return (\n <HvDrawer\n BackdropComponent={undefined}\n variant=\"persistent\"\n classes={{\n paper: classes.drawerPaper,\n }}\n anchor={anchor}\n buttonTitle={buttonTitle}\n {...others}\n >\n <div id={drawerElementId} ref={setNodeRef}>\n <div className={classes.titleContainer}>\n <Add role=\"none\" />\n <HvTypography variant=\"title3\">{title}</HvTypography>\n </div>\n <div className={classes.contentContainer}>\n <HvTypography className={classes.description}>\n {description}\n </HvTypography>\n <HvInput\n className={classes.searchRoot}\n type=\"search\"\n placeholder={labels?.searchPlaceholder}\n aria-label={labels?.searchAriaLabel}\n aria-controls={groupsElementId}\n aria-owns={groupsElementId}\n onChange={handleDebouncedSearch}\n inputProps={{ autoComplete: \"off\" }}\n />\n <ul id={groupsElementId} className={classes.groupsContainer}>\n {Object.entries(groups).map((obj) => (\n <HvFlowSidebarGroup\n key={obj[0]}\n id={obj[0]}\n expandButtonProps={{\n \"aria-label\": labels?.expandGroupButtonAriaLabel,\n }}\n itemProps={{\n \"aria-roledescription\": labels?.itemAriaRoleDescription,\n }}\n {...obj[1]}\n />\n ))}\n </ul>\n </div>\n </div>\n </HvDrawer>\n );\n};\n"],"names":["DEFAULT_LABELS","itemAriaRoleDescription","expandGroupButtonAriaLabel","searchPlaceholder","searchAriaLabel","HvFlowSidebar","id","title","description","anchor","buttonTitle","classes","classesProp","labels","labelsProps","others","useClasses","nodeGroups","nodeTypes","setExpandedNodeGroups","useFlowContext","unfilteredGroups","useMemo","buildGroups","groups","setGroups","useState","useLabels","drawerElementId","useUniqueId","groupsElementId","setNodeRef","useDroppable","handleSearch","event","value","gps","Object","entries","reduce","acc","curr","filteredNodes","nodes","filter","obj","label","toLocaleLowerCase","includes","nodesCount","length","keys","handleDebouncedSearch","debounce","HvDrawer","BackdropComponent","undefined","variant","paper","drawerPaper","children","ref","_jsxs","className","titleContainer","_jsx","Add","role","HvTypography","contentContainer","HvInput","searchRoot","type","placeholder","onChange","inputProps","autoComplete","groupsContainer","map","HvFlowSidebarGroup","expandButtonProps","itemProps"],"mappings":";;;;;;;;;;;;;;AA4CA,MAAMA,iBAA+C;AAAA,EACnDC,yBAAyB;AAAA,EACzBC,4BAA4B;AAAA,EAC5BC,mBAAmB;AAAA,EACnBC,iBAAiB;AACnB;AAEO,MAAMC,gBAAgBA,CAAC;AAAA,EAC5BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,SAAS;AAAA,EACTC,cAAc;AAAA,EACdC,SAASC;AAAAA,EACTC,QAAQC;AAAAA,EACR,GAAGC;AACe,MAAM;AAClB,QAAA;AAAA,IAAEJ;AAAAA,EAAAA,IAAYK,eAAAA,WAAWJ,WAAW;AAEpC,QAAA;AAAA,IAAEK;AAAAA,IAAYC;AAAAA,IAAWC;AAAAA,MAA0BC,YAAe,eAAA;AAElEC,QAAAA,mBAAmBC,cACvB,MAAMC,kBAAYN,YAAYC,SAAS,GACvC,CAACD,YAAYC,SAAS,CACxB;AAEA,QAAM,CAACM,QA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(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const uikitReactCore = require("@hitachivantara/uikit-react-core");
|
|
4
|
+
const {
|
|
5
|
+
staticClasses,
|
|
6
|
+
useClasses
|
|
7
|
+
} = uikitReactCore.createClasses("HvFlowSidebar", {
|
|
8
|
+
drawerPaper: {
|
|
9
|
+
width: "360px"
|
|
10
|
+
},
|
|
11
|
+
titleContainer: {
|
|
12
|
+
display: "flex",
|
|
13
|
+
padding: uikitReactCore.theme.spacing("sm", "lg", "xs", "sm")
|
|
14
|
+
},
|
|
15
|
+
contentContainer: {
|
|
16
|
+
padding: uikitReactCore.theme.spacing(0, "lg", "sm", "lg")
|
|
17
|
+
},
|
|
18
|
+
description: {
|
|
19
|
+
color: uikitReactCore.theme.colors.secondary_60
|
|
20
|
+
},
|
|
21
|
+
searchRoot: {
|
|
22
|
+
paddingTop: uikitReactCore.theme.space.sm,
|
|
23
|
+
paddingBottom: uikitReactCore.theme.space.sm
|
|
24
|
+
},
|
|
25
|
+
groupsContainer: {
|
|
26
|
+
display: "flex",
|
|
27
|
+
flexDirection: "column",
|
|
28
|
+
gap: uikitReactCore.theme.space.sm,
|
|
29
|
+
listStyleType: "none"
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
exports.staticClasses = staticClasses;
|
|
33
|
+
exports.useClasses = useClasses;
|
|
34
|
+
//# sourceMappingURL=Sidebar.styles.cjs.map
|