@uipath/apollo-react 3.62.0 → 3.63.0-pr431.16bbfa4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/canvas/components/CanvasPerformance.stories.cjs +361 -0
  2. package/dist/canvas/components/CanvasPerformance.stories.d.ts +6 -0
  3. package/dist/canvas/components/CanvasPerformance.stories.d.ts.map +1 -0
  4. package/dist/canvas/components/CanvasPerformance.stories.js +324 -0
  5. package/dist/canvas/components/NodePropertiesPanel/hooks/index.cjs +4 -1
  6. package/dist/canvas/components/NodePropertiesPanel/hooks/index.d.ts +1 -1
  7. package/dist/canvas/components/NodePropertiesPanel/hooks/index.d.ts.map +1 -1
  8. package/dist/canvas/components/NodePropertiesPanel/hooks/index.js +2 -2
  9. package/dist/canvas/components/NodePropertiesPanel/hooks/useNodeSelection.cjs +27 -6
  10. package/dist/canvas/components/NodePropertiesPanel/hooks/useNodeSelection.d.ts +3 -0
  11. package/dist/canvas/components/NodePropertiesPanel/hooks/useNodeSelection.d.ts.map +1 -1
  12. package/dist/canvas/components/NodePropertiesPanel/hooks/useNodeSelection.js +23 -5
  13. package/dist/canvas/components/StageNode/DraggableTask.cjs +14 -5
  14. package/dist/canvas/components/StageNode/DraggableTask.d.ts +1 -1
  15. package/dist/canvas/components/StageNode/DraggableTask.d.ts.map +1 -1
  16. package/dist/canvas/components/StageNode/DraggableTask.js +14 -5
  17. package/dist/canvas/components/StageNode/DraggableTask.types.d.ts +3 -3
  18. package/dist/canvas/components/StageNode/DraggableTask.types.d.ts.map +1 -1
  19. package/dist/canvas/components/StageNode/StageEdge.cjs +34 -11
  20. package/dist/canvas/components/StageNode/StageEdge.d.ts +2 -1
  21. package/dist/canvas/components/StageNode/StageEdge.d.ts.map +1 -1
  22. package/dist/canvas/components/StageNode/StageEdge.js +35 -12
  23. package/dist/canvas/components/StageNode/StageNode.cjs +78 -45
  24. package/dist/canvas/components/StageNode/StageNode.d.ts +1 -1
  25. package/dist/canvas/components/StageNode/StageNode.d.ts.map +1 -1
  26. package/dist/canvas/components/StageNode/StageNode.js +80 -47
  27. package/dist/canvas/components/StageNode/StageNode.stories.cjs +118 -135
  28. package/dist/canvas/components/StageNode/StageNode.stories.d.ts.map +1 -1
  29. package/dist/canvas/components/StageNode/StageNode.stories.js +115 -132
  30. package/dist/canvas/components/StageNode/StageNode.stories.utils.cjs +42 -0
  31. package/dist/canvas/components/StageNode/StageNode.stories.utils.d.ts +3 -0
  32. package/dist/canvas/components/StageNode/StageNode.stories.utils.d.ts.map +1 -0
  33. package/dist/canvas/components/StageNode/StageNode.stories.utils.js +8 -0
  34. package/dist/canvas/components/StageNode/StageNode.types.d.ts +9 -1
  35. package/dist/canvas/components/StageNode/StageNode.types.d.ts.map +1 -1
  36. package/dist/canvas/components/StageNode/TaskMenu.cjs +13 -17
  37. package/dist/canvas/components/StageNode/TaskMenu.d.ts +1 -2
  38. package/dist/canvas/components/StageNode/TaskMenu.d.ts.map +1 -1
  39. package/dist/canvas/components/StageNode/TaskMenu.js +14 -18
  40. package/dist/canvas/components/TaskIcon/TaskIcon.styles.cjs +1 -1
  41. package/dist/canvas/components/TaskIcon/TaskIcon.styles.js +1 -1
  42. package/dist/canvas/icons/CaseManagementProject.cjs +9 -18
  43. package/dist/canvas/icons/CaseManagementProject.d.ts.map +1 -1
  44. package/dist/canvas/icons/CaseManagementProject.js +9 -18
  45. package/package.json +1 -1
@@ -0,0 +1,324 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { ConnectionMode, Panel, ReactFlowProvider, addEdge, useEdgesState, useNodesState } from "../xyflow/react.js";
3
+ import { useCallback, useMemo, useState } from "react";
4
+ import { DefaultCanvasTranslations } from "../types.js";
5
+ import { BaseCanvas } from "./BaseCanvas/index.js";
6
+ import { CanvasPositionControls } from "./CanvasPositionControls.js";
7
+ import { StageConnectionEdge } from "./StageNode/StageConnectionEdge.js";
8
+ import { StageEdge } from "./StageNode/StageEdge.js";
9
+ import { StageNodeWrapper } from "./StageNode/StageNode.stories.utils.js";
10
+ const meta = {
11
+ title: 'Canvas/Performance',
12
+ parameters: {
13
+ layout: 'fullscreen'
14
+ }
15
+ };
16
+ const CanvasPerformance_stories = meta;
17
+ const PERFORMANCE_STAGE_NODE_WIDTH = 304;
18
+ const PERFORMANCE_STAGE_SPACING_X = 400;
19
+ const PERFORMANCE_STAGE_SPACING_Y = 384;
20
+ const DEFAULT_STAGE_COUNT = 48;
21
+ const MIN_STAGE_COUNT = 1;
22
+ const MAX_STAGE_COUNT = 200;
23
+ const VerificationIcon = ()=>/*#__PURE__*/ jsxs("svg", {
24
+ viewBox: "0 0 24 24",
25
+ fill: "none",
26
+ stroke: "currentColor",
27
+ strokeWidth: "1.5",
28
+ children: [
29
+ /*#__PURE__*/ jsx("path", {
30
+ d: "M9 11L12 14L20 6"
31
+ }),
32
+ /*#__PURE__*/ jsx("path", {
33
+ d: "M20 12V18C20 19.1046 19.1046 20 18 20H6C4.89543 20 4 19.1046 4 18V6C4 4.89543 4.89543 4 6 4H13"
34
+ })
35
+ ]
36
+ });
37
+ const DocumentIcon = ()=>/*#__PURE__*/ jsxs("svg", {
38
+ viewBox: "0 0 24 24",
39
+ fill: "none",
40
+ stroke: "currentColor",
41
+ strokeWidth: "1.5",
42
+ children: [
43
+ /*#__PURE__*/ jsx("path", {
44
+ d: "M14 2H6C4.9 2 4 2.9 4 4V20C4 21.1 4.9 22 6 22H18C19.1 22 20 21.1 20 20V8L14 2Z"
45
+ }),
46
+ /*#__PURE__*/ jsx("path", {
47
+ d: "M14 2V8H20"
48
+ }),
49
+ /*#__PURE__*/ jsx("path", {
50
+ d: "M8 12H16"
51
+ }),
52
+ /*#__PURE__*/ jsx("path", {
53
+ d: "M8 16H16"
54
+ })
55
+ ]
56
+ });
57
+ const ProcessIcon = ()=>/*#__PURE__*/ jsxs("svg", {
58
+ viewBox: "0 0 24 24",
59
+ fill: "none",
60
+ stroke: "currentColor",
61
+ strokeWidth: "1.5",
62
+ children: [
63
+ /*#__PURE__*/ jsx("rect", {
64
+ x: "3",
65
+ y: "3",
66
+ width: "7",
67
+ height: "7",
68
+ rx: "1"
69
+ }),
70
+ /*#__PURE__*/ jsx("rect", {
71
+ x: "14",
72
+ y: "3",
73
+ width: "7",
74
+ height: "7",
75
+ rx: "1"
76
+ }),
77
+ /*#__PURE__*/ jsx("rect", {
78
+ x: "3",
79
+ y: "14",
80
+ width: "7",
81
+ height: "7",
82
+ rx: "1"
83
+ }),
84
+ /*#__PURE__*/ jsx("rect", {
85
+ x: "14",
86
+ y: "14",
87
+ width: "7",
88
+ height: "7",
89
+ rx: "1"
90
+ })
91
+ ]
92
+ });
93
+ function createPerformanceStageTasks(index) {
94
+ return [
95
+ [
96
+ {
97
+ id: `stage-${index}-task-intake`,
98
+ label: 'Intake Review',
99
+ icon: /*#__PURE__*/ jsx(VerificationIcon, {})
100
+ }
101
+ ],
102
+ [
103
+ {
104
+ id: `stage-${index}-task-documents`,
105
+ label: 'Document Processing',
106
+ icon: /*#__PURE__*/ jsx(DocumentIcon, {})
107
+ }
108
+ ],
109
+ [
110
+ {
111
+ id: `stage-${index}-task-risk`,
112
+ label: 'Risk Assessment',
113
+ icon: /*#__PURE__*/ jsx(VerificationIcon, {})
114
+ },
115
+ {
116
+ id: `stage-${index}-task-policy`,
117
+ label: 'Policy Validation',
118
+ icon: /*#__PURE__*/ jsx(VerificationIcon, {})
119
+ }
120
+ ],
121
+ [
122
+ {
123
+ id: `stage-${index}-task-review`,
124
+ label: 'Final Review',
125
+ icon: /*#__PURE__*/ jsx(ProcessIcon, {})
126
+ }
127
+ ]
128
+ ];
129
+ }
130
+ function createPerformanceStageNodes(stageCount) {
131
+ const columns = Math.ceil(Math.sqrt(stageCount));
132
+ return Array.from({
133
+ length: stageCount
134
+ }, (_, index)=>{
135
+ const row = Math.floor(index / columns);
136
+ const col = index % columns;
137
+ const stageId = `performance-stage-${index}`;
138
+ return {
139
+ id: stageId,
140
+ type: 'stage',
141
+ position: {
142
+ x: col * PERFORMANCE_STAGE_SPACING_X,
143
+ y: row * PERFORMANCE_STAGE_SPACING_Y
144
+ },
145
+ width: PERFORMANCE_STAGE_NODE_WIDTH,
146
+ data: {
147
+ stageDetails: {
148
+ label: `Performance Stage ${index + 1}`,
149
+ tasks: createPerformanceStageTasks(index)
150
+ },
151
+ execution: {
152
+ stageStatus: {
153
+ duration: `SLA: ${30 + index % 5 * 15}m`
154
+ }
155
+ }
156
+ }
157
+ };
158
+ });
159
+ }
160
+ function createPerformanceStageEdges(stageCount) {
161
+ const columns = Math.ceil(Math.sqrt(stageCount));
162
+ const edges = [];
163
+ for(let index = 0; index < stageCount; index++){
164
+ const col = index % columns;
165
+ const sourceId = `performance-stage-${index}`;
166
+ const rightIndex = index + 1;
167
+ if (col < columns - 1 && rightIndex < stageCount) {
168
+ const targetId = `performance-stage-${rightIndex}`;
169
+ edges.push({
170
+ id: `performance-edge-right-${index}`,
171
+ type: 'stage',
172
+ source: sourceId,
173
+ sourceHandle: `${sourceId}____source____right`,
174
+ target: targetId,
175
+ targetHandle: `${targetId}____target____left`
176
+ });
177
+ }
178
+ const downIndex = index + columns;
179
+ if (downIndex < stageCount) {
180
+ const targetId = `performance-stage-${downIndex}`;
181
+ edges.push({
182
+ id: `performance-edge-down-${index}`,
183
+ type: 'stage',
184
+ source: sourceId,
185
+ sourceHandle: `${sourceId}____source____bottom`,
186
+ target: targetId,
187
+ targetHandle: `${targetId}____target____top`
188
+ });
189
+ }
190
+ }
191
+ return edges;
192
+ }
193
+ const CanvasPerformanceStory = ()=>{
194
+ const nodeTypes = useMemo(()=>({
195
+ stage: StageNodeWrapper
196
+ }), []);
197
+ const edgeTypes = useMemo(()=>({
198
+ stage: StageEdge
199
+ }), []);
200
+ const defaultEdgeOptions = useMemo(()=>({
201
+ type: 'stage'
202
+ }), []);
203
+ const [stageCount, setStageCount] = useState(DEFAULT_STAGE_COUNT);
204
+ const [nodes, setNodes, onNodesChange] = useNodesState(createPerformanceStageNodes(DEFAULT_STAGE_COUNT));
205
+ const [edges, setEdges, onEdgesChange] = useEdgesState(createPerformanceStageEdges(DEFAULT_STAGE_COUNT));
206
+ const onConnect = useCallback((connection)=>setEdges((eds)=>addEdge(connection, eds)), [
207
+ setEdges
208
+ ]);
209
+ const handleStageCountChange = useCallback((e)=>{
210
+ const nextCount = Number.parseInt(e.target.value, 10);
211
+ setStageCount(nextCount);
212
+ setNodes(createPerformanceStageNodes(nextCount));
213
+ setEdges(createPerformanceStageEdges(nextCount));
214
+ }, [
215
+ setEdges,
216
+ setNodes
217
+ ]);
218
+ return /*#__PURE__*/ jsx("div", {
219
+ style: {
220
+ width: '100vw',
221
+ height: '100vh'
222
+ },
223
+ children: /*#__PURE__*/ jsx(ReactFlowProvider, {
224
+ children: /*#__PURE__*/ jsxs(BaseCanvas, {
225
+ nodes: nodes,
226
+ edges: edges,
227
+ onNodesChange: onNodesChange,
228
+ onEdgesChange: onEdgesChange,
229
+ onConnect: onConnect,
230
+ nodeTypes: nodeTypes,
231
+ edgeTypes: edgeTypes,
232
+ mode: "design",
233
+ connectionMode: ConnectionMode.Strict,
234
+ defaultEdgeOptions: defaultEdgeOptions,
235
+ connectionLineComponent: StageConnectionEdge,
236
+ elevateEdgesOnSelect: true,
237
+ children: [
238
+ /*#__PURE__*/ jsx(Panel, {
239
+ position: "top-left",
240
+ children: /*#__PURE__*/ jsxs("div", {
241
+ className: "nodrag nopan nowheel",
242
+ style: {
243
+ width: 240,
244
+ background: 'var(--uix-canvas-background)',
245
+ border: '1px solid var(--uix-canvas-border-de-emp)',
246
+ borderRadius: 16,
247
+ padding: 16,
248
+ boxShadow: '0 8px 32px rgba(15, 23, 42, 0.08)'
249
+ },
250
+ children: [
251
+ /*#__PURE__*/ jsx("div", {
252
+ style: {
253
+ fontWeight: 600,
254
+ fontSize: 14
255
+ },
256
+ children: "Performance Test"
257
+ }),
258
+ /*#__PURE__*/ jsx("div", {
259
+ style: {
260
+ marginTop: 6,
261
+ color: 'var(--uix-canvas-foreground-de-emp)',
262
+ fontSize: 12,
263
+ lineHeight: 1.4
264
+ },
265
+ children: "Adjust the number of stage nodes to profile drag and pan performance."
266
+ }),
267
+ /*#__PURE__*/ jsxs("div", {
268
+ style: {
269
+ display: 'flex',
270
+ justifyContent: 'space-between',
271
+ alignItems: 'center',
272
+ marginTop: 12,
273
+ marginBottom: 8,
274
+ fontSize: 12
275
+ },
276
+ children: [
277
+ /*#__PURE__*/ jsx("span", {
278
+ children: "Stage Count"
279
+ }),
280
+ /*#__PURE__*/ jsx("strong", {
281
+ style: {
282
+ fontSize: 14
283
+ },
284
+ children: stageCount
285
+ })
286
+ ]
287
+ }),
288
+ /*#__PURE__*/ jsx("input", {
289
+ type: "range",
290
+ min: MIN_STAGE_COUNT,
291
+ max: MAX_STAGE_COUNT,
292
+ value: stageCount,
293
+ onChange: handleStageCountChange,
294
+ style: {
295
+ width: '100%',
296
+ cursor: 'pointer'
297
+ }
298
+ })
299
+ ]
300
+ })
301
+ }),
302
+ /*#__PURE__*/ jsx(Panel, {
303
+ position: "bottom-right",
304
+ children: /*#__PURE__*/ jsx(CanvasPositionControls, {
305
+ translations: DefaultCanvasTranslations
306
+ })
307
+ })
308
+ ]
309
+ })
310
+ })
311
+ });
312
+ };
313
+ const StageWorkflow = {
314
+ name: 'Stage Workflow',
315
+ parameters: {
316
+ docs: {
317
+ description: {
318
+ story: 'Standalone performance story with adjustable stage count. Use this to profile stage workflow drag and pan behavior under load.'
319
+ }
320
+ }
321
+ },
322
+ render: ()=>/*#__PURE__*/ jsx(CanvasPerformanceStory, {})
323
+ };
324
+ export { StageWorkflow, CanvasPerformance_stories as default };
@@ -24,6 +24,7 @@ var __webpack_require__ = {};
24
24
  var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
+ useSetNodeSelection: ()=>external_useNodeSelection_cjs_namespaceObject.useSetNodeSelection,
27
28
  useNodeSelection: ()=>external_useNodeSelection_cjs_namespaceObject.useNodeSelection,
28
29
  useNodeConfiguration: ()=>external_useNodeConfiguration_cjs_namespaceObject.useNodeConfiguration
29
30
  });
@@ -31,9 +32,11 @@ const external_useNodeConfiguration_cjs_namespaceObject = require("./useNodeConf
31
32
  const external_useNodeSelection_cjs_namespaceObject = require("./useNodeSelection.cjs");
32
33
  exports.useNodeConfiguration = __webpack_exports__.useNodeConfiguration;
33
34
  exports.useNodeSelection = __webpack_exports__.useNodeSelection;
35
+ exports.useSetNodeSelection = __webpack_exports__.useSetNodeSelection;
34
36
  for(var __rspack_i in __webpack_exports__)if (-1 === [
35
37
  "useNodeConfiguration",
36
- "useNodeSelection"
38
+ "useNodeSelection",
39
+ "useSetNodeSelection"
37
40
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
38
41
  Object.defineProperty(exports, '__esModule', {
39
42
  value: true
@@ -1,3 +1,3 @@
1
1
  export { useNodeConfiguration } from './useNodeConfiguration';
2
- export { useNodeSelection } from './useNodeSelection';
2
+ export { useNodeSelection, useSetNodeSelection } from './useNodeSelection';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/NodePropertiesPanel/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/NodePropertiesPanel/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import { useNodeConfiguration } from "./useNodeConfiguration.js";
2
- import { useNodeSelection } from "./useNodeSelection.js";
3
- export { useNodeConfiguration, useNodeSelection };
2
+ import { useNodeSelection, useSetNodeSelection } from "./useNodeSelection.js";
3
+ export { useNodeConfiguration, useNodeSelection, useSetNodeSelection };
@@ -24,10 +24,21 @@ var __webpack_require__ = {};
24
24
  var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
- useNodeSelection: ()=>useNodeSelection
27
+ useNodeSelection: ()=>useNodeSelection,
28
+ useSetNodeSelection: ()=>useSetNodeSelection
28
29
  });
29
30
  const react_cjs_namespaceObject = require("../../../xyflow/react.cjs");
30
31
  const external_react_namespaceObject = require("react");
32
+ function applySelection(nodes, nodeId) {
33
+ return nodes.map((node)=>{
34
+ const shouldBeSelected = node.id === nodeId;
35
+ if (node.selected === shouldBeSelected) return node;
36
+ return {
37
+ ...node,
38
+ selected: shouldBeSelected
39
+ };
40
+ });
41
+ }
31
42
  function useNodeSelection(nodeId, maintainSelection = true) {
32
43
  const nodes = (0, react_cjs_namespaceObject.useNodes)();
33
44
  const { setNodes } = (0, react_cjs_namespaceObject.useReactFlow)();
@@ -40,10 +51,7 @@ function useNodeSelection(nodeId, maintainSelection = true) {
40
51
  ])
41
52
  });
42
53
  (0, external_react_namespaceObject.useEffect)(()=>{
43
- if (maintainSelection && selectedNodeId) setNodes((nds)=>nds.map((node)=>({
44
- ...node,
45
- selected: node.id === selectedNodeId
46
- })));
54
+ if (maintainSelection && selectedNodeId) setNodes((nds)=>applySelection(nds, selectedNodeId));
47
55
  }, [
48
56
  selectedNodeId,
49
57
  maintainSelection,
@@ -56,9 +64,22 @@ function useNodeSelection(nodeId, maintainSelection = true) {
56
64
  selectedNode
57
65
  };
58
66
  }
67
+ function useSetNodeSelection() {
68
+ const { setNodes } = (0, react_cjs_namespaceObject.useReactFlow)();
69
+ const setSelectedNodeId = (0, external_react_namespaceObject.useCallback)((nodeId)=>{
70
+ setNodes((nds)=>applySelection(nds, nodeId));
71
+ }, [
72
+ setNodes
73
+ ]);
74
+ return {
75
+ setSelectedNodeId
76
+ };
77
+ }
59
78
  exports.useNodeSelection = __webpack_exports__.useNodeSelection;
79
+ exports.useSetNodeSelection = __webpack_exports__.useSetNodeSelection;
60
80
  for(var __rspack_i in __webpack_exports__)if (-1 === [
61
- "useNodeSelection"
81
+ "useNodeSelection",
82
+ "useSetNodeSelection"
62
83
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
63
84
  Object.defineProperty(exports, '__esModule', {
64
85
  value: true
@@ -4,4 +4,7 @@ export declare function useNodeSelection(nodeId?: string, maintainSelection?: bo
4
4
  setSelectedNodeId: import("react").Dispatch<import("react").SetStateAction<string | null>>;
5
5
  selectedNode: ConfigurableNode | undefined;
6
6
  };
7
+ export declare function useSetNodeSelection(): {
8
+ setSelectedNodeId: (nodeId: string) => void;
9
+ };
7
10
  //# sourceMappingURL=useNodeSelection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useNodeSelection.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/NodePropertiesPanel/hooks/useNodeSelection.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAErE,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,iBAAiB,UAAO;;;;EAwCzE"}
1
+ {"version":3,"file":"useNodeSelection.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/NodePropertiesPanel/hooks/useNodeSelection.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAUrE,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,iBAAiB,UAAO;;;;EAmCzE;AAOD,wBAAgB,mBAAmB;gCAItB,MAAM;EAOlB"}
@@ -1,5 +1,15 @@
1
1
  import { useNodes, useOnSelectionChange, useReactFlow } from "../../../xyflow/react.js";
2
2
  import { useCallback, useEffect, useState } from "react";
3
+ function applySelection(nodes, nodeId) {
4
+ return nodes.map((node)=>{
5
+ const shouldBeSelected = node.id === nodeId;
6
+ if (node.selected === shouldBeSelected) return node;
7
+ return {
8
+ ...node,
9
+ selected: shouldBeSelected
10
+ };
11
+ });
12
+ }
3
13
  function useNodeSelection(nodeId, maintainSelection = true) {
4
14
  const nodes = useNodes();
5
15
  const { setNodes } = useReactFlow();
@@ -12,10 +22,7 @@ function useNodeSelection(nodeId, maintainSelection = true) {
12
22
  ])
13
23
  });
14
24
  useEffect(()=>{
15
- if (maintainSelection && selectedNodeId) setNodes((nds)=>nds.map((node)=>({
16
- ...node,
17
- selected: node.id === selectedNodeId
18
- })));
25
+ if (maintainSelection && selectedNodeId) setNodes((nds)=>applySelection(nds, selectedNodeId));
19
26
  }, [
20
27
  selectedNodeId,
21
28
  maintainSelection,
@@ -28,4 +35,15 @@ function useNodeSelection(nodeId, maintainSelection = true) {
28
35
  selectedNode
29
36
  };
30
37
  }
31
- export { useNodeSelection };
38
+ function useSetNodeSelection() {
39
+ const { setNodes } = useReactFlow();
40
+ const setSelectedNodeId = useCallback((nodeId)=>{
41
+ setNodes((nds)=>applySelection(nds, nodeId));
42
+ }, [
43
+ setNodes
44
+ ]);
45
+ return {
46
+ setSelectedNodeId
47
+ };
48
+ }
49
+ export { useNodeSelection, useSetNodeSelection };
@@ -41,6 +41,7 @@ const sortable_namespaceObject = require("@dnd-kit/sortable");
41
41
  const utilities_namespaceObject = require("@dnd-kit/utilities");
42
42
  const apollo_core_namespaceObject = require("@uipath/apollo-core");
43
43
  const index_cjs_namespaceObject = require("../../layouts/index.cjs");
44
+ const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
44
45
  const external_material_index_cjs_namespaceObject = require("../../../material/index.cjs");
45
46
  const external_debounce_namespaceObject = require("debounce");
46
47
  var external_debounce_default = /*#__PURE__*/ __webpack_require__.n(external_debounce_namespaceObject);
@@ -182,8 +183,9 @@ const TaskContent = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ ta
182
183
  ]
183
184
  })
184
185
  }));
185
- const DraggableTaskComponent = ({ task, taskExecution, isSelected, isParallel, contextMenuItems, onTaskClick, onMenuOpen, onTaskPlay, isDragDisabled, projectedDepth, zoom = 1 })=>{
186
+ const DraggableTaskComponent = ({ task, taskExecution, isSelected, isParallel, groupIndex, taskIndex, getContextMenuItems, onTaskClick, onTaskPlay, isDragDisabled, projectedDepth })=>{
186
187
  const [isMenuOpen, setIsMenuOpen] = (0, external_react_namespaceObject.useState)(false);
188
+ const zoom = (0, react_cjs_namespaceObject.useStore)((s)=>s.transform[2]);
187
189
  const taskRef = (0, external_react_namespaceObject.useRef)(null);
188
190
  const menuRef = (0, external_react_namespaceObject.useRef)(null);
189
191
  const [playLoading, setPlayLoading] = (0, external_react_namespaceObject.useState)(false);
@@ -221,6 +223,14 @@ const DraggableTaskComponent = ({ task, taskExecution, isSelected, isParallel, c
221
223
  const handleContextMenu = (0, external_react_namespaceObject.useCallback)((e)=>{
222
224
  menuRef.current?.handleContextMenu(e);
223
225
  }, []);
226
+ const handleGetContextMenuItems = (0, external_react_namespaceObject.useCallback)(()=>{
227
+ if (!getContextMenuItems || void 0 === groupIndex || void 0 === taskIndex) return [];
228
+ return getContextMenuItems(groupIndex, taskIndex);
229
+ }, [
230
+ getContextMenuItems,
231
+ groupIndex,
232
+ taskIndex
233
+ ]);
224
234
  const { attributes, listeners, setNodeRef, transition, transform, isDragging } = (0, sortable_namespaceObject.useSortable)({
225
235
  id: task.id,
226
236
  disabled: isDragDisabled
@@ -266,7 +276,7 @@ const DraggableTaskComponent = ({ task, taskExecution, isSelected, isParallel, c
266
276
  isParallel: isParallel,
267
277
  isDragEnabled: !isDragDisabled,
268
278
  onClick: handleClick,
269
- ...contextMenuItems.length > 0 && {
279
+ ...getContextMenuItems && {
270
280
  onContextMenu: handleContextMenu
271
281
  },
272
282
  children: [
@@ -313,12 +323,11 @@ const DraggableTaskComponent = ({ task, taskExecution, isSelected, isParallel, c
313
323
  })
314
324
  })
315
325
  }),
316
- contextMenuItems.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_TaskMenu_cjs_namespaceObject.TaskMenu, {
326
+ getContextMenuItems && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_TaskMenu_cjs_namespaceObject.TaskMenu, {
317
327
  ref: menuRef,
318
328
  taskId: task.id,
319
- contextMenuItems: contextMenuItems,
329
+ getContextMenuItems: handleGetContextMenuItems,
320
330
  onMenuOpenChange: handleMenuOpenChange,
321
- onMenuOpen: onMenuOpen,
322
331
  taskRef: taskRef
323
332
  })
324
333
  ]
@@ -1,4 +1,4 @@
1
1
  import type { DraggableTaskProps, TaskContentProps } from './DraggableTask.types';
2
2
  export declare const TaskContent: import("react").MemoExoticComponent<({ task, taskExecution, isDragging }: TaskContentProps) => import("react/jsx-runtime").JSX.Element>;
3
- export declare const DraggableTask: import("react").MemoExoticComponent<({ task, taskExecution, isSelected, isParallel, contextMenuItems, onTaskClick, onMenuOpen, onTaskPlay, isDragDisabled, projectedDepth, zoom, }: DraggableTaskProps) => import("react/jsx-runtime").JSX.Element>;
3
+ export declare const DraggableTask: import("react").MemoExoticComponent<({ task, taskExecution, isSelected, isParallel, groupIndex, taskIndex, getContextMenuItems, onTaskClick, onTaskPlay, isDragDisabled, projectedDepth, }: DraggableTaskProps) => import("react/jsx-runtime").JSX.Element>;
4
4
  //# sourceMappingURL=DraggableTask.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DraggableTask.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StageNode/DraggableTask.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAgClF,eAAO,MAAM,WAAW,4EAA8C,gBAAgB,6CAwEpF,CAAC;AAqLH,eAAO,MAAM,aAAa,sLAvKvB,kBAAkB,6CAuKoC,CAAC"}
1
+ {"version":3,"file":"DraggableTask.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StageNode/DraggableTask.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAgClF,eAAO,MAAM,WAAW,4EAA8C,gBAAgB,6CAwEpF,CAAC;AA4LH,eAAO,MAAM,aAAa,8LA9KvB,kBAAkB,6CA8KoC,CAAC"}
@@ -3,6 +3,7 @@ import { useSortable } from "@dnd-kit/sortable";
3
3
  import { CSS } from "@dnd-kit/utilities";
4
4
  import { FontVariantToken, Padding, Spacing } from "@uipath/apollo-core";
5
5
  import { Column, Row } from "../../layouts/index.js";
6
+ import { useStore } from "../../xyflow/react.js";
6
7
  import { ApBadge, ApCircularProgress, ApIconButton, ApTooltip, ApTypography, BadgeSize } from "../../../material/index.js";
7
8
  import debounce from "debounce";
8
9
  import { memo, useCallback, useMemo, useRef, useState } from "react";
@@ -143,8 +144,9 @@ const TaskContent = /*#__PURE__*/ memo(({ task, taskExecution, isDragging })=>/*
143
144
  ]
144
145
  })
145
146
  }));
146
- const DraggableTaskComponent = ({ task, taskExecution, isSelected, isParallel, contextMenuItems, onTaskClick, onMenuOpen, onTaskPlay, isDragDisabled, projectedDepth, zoom = 1 })=>{
147
+ const DraggableTaskComponent = ({ task, taskExecution, isSelected, isParallel, groupIndex, taskIndex, getContextMenuItems, onTaskClick, onTaskPlay, isDragDisabled, projectedDepth })=>{
147
148
  const [isMenuOpen, setIsMenuOpen] = useState(false);
149
+ const zoom = useStore((s)=>s.transform[2]);
148
150
  const taskRef = useRef(null);
149
151
  const menuRef = useRef(null);
150
152
  const [playLoading, setPlayLoading] = useState(false);
@@ -182,6 +184,14 @@ const DraggableTaskComponent = ({ task, taskExecution, isSelected, isParallel, c
182
184
  const handleContextMenu = useCallback((e)=>{
183
185
  menuRef.current?.handleContextMenu(e);
184
186
  }, []);
187
+ const handleGetContextMenuItems = useCallback(()=>{
188
+ if (!getContextMenuItems || void 0 === groupIndex || void 0 === taskIndex) return [];
189
+ return getContextMenuItems(groupIndex, taskIndex);
190
+ }, [
191
+ getContextMenuItems,
192
+ groupIndex,
193
+ taskIndex
194
+ ]);
185
195
  const { attributes, listeners, setNodeRef, transition, transform, isDragging } = useSortable({
186
196
  id: task.id,
187
197
  disabled: isDragDisabled
@@ -227,7 +237,7 @@ const DraggableTaskComponent = ({ task, taskExecution, isSelected, isParallel, c
227
237
  isParallel: isParallel,
228
238
  isDragEnabled: !isDragDisabled,
229
239
  onClick: handleClick,
230
- ...contextMenuItems.length > 0 && {
240
+ ...getContextMenuItems && {
231
241
  onContextMenu: handleContextMenu
232
242
  },
233
243
  children: [
@@ -274,12 +284,11 @@ const DraggableTaskComponent = ({ task, taskExecution, isSelected, isParallel, c
274
284
  })
275
285
  })
276
286
  }),
277
- contextMenuItems.length > 0 && /*#__PURE__*/ jsx(TaskMenu, {
287
+ getContextMenuItems && /*#__PURE__*/ jsx(TaskMenu, {
278
288
  ref: menuRef,
279
289
  taskId: task.id,
280
- contextMenuItems: contextMenuItems,
290
+ getContextMenuItems: handleGetContextMenuItems,
281
291
  onMenuOpenChange: handleMenuOpenChange,
282
- onMenuOpen: onMenuOpen,
283
292
  taskRef: taskRef
284
293
  })
285
294
  ]
@@ -10,12 +10,12 @@ export interface DraggableTaskProps {
10
10
  taskExecution?: StageTaskExecution;
11
11
  isSelected: boolean;
12
12
  isParallel: boolean;
13
- contextMenuItems: NodeMenuItem[];
13
+ groupIndex?: number;
14
+ taskIndex?: number;
15
+ getContextMenuItems?: (groupIndex: number, taskIndex: number) => NodeMenuItem[];
14
16
  onTaskClick: (e: React.MouseEvent, taskId: string) => void;
15
- onMenuOpen?: () => void;
16
17
  onTaskPlay?: (taskId: string) => Promise<void>;
17
18
  isDragDisabled?: boolean;
18
19
  projectedDepth?: number;
19
- zoom?: number;
20
20
  }
21
21
  //# sourceMappingURL=DraggableTask.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DraggableTask.types.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StageNode/DraggableTask.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE3E,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,aAAa,CAAC;IACpB,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,aAAa,CAAC;IACpB,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,YAAY,EAAE,CAAC;IACjC,WAAW,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
1
+ {"version":3,"file":"DraggableTask.types.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StageNode/DraggableTask.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE3E,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,aAAa,CAAC;IACpB,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,aAAa,CAAC;IACpB,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,YAAY,EAAE,CAAC;IAChF,WAAW,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}