@uipath/apollo-react 3.68.1 → 3.68.3-pr431.42f9a1c

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 (52) hide show
  1. package/dist/canvas/components/CanvasPerformance.stories.cjs +349 -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 +312 -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/AdhocTask.cjs +148 -0
  14. package/dist/canvas/components/StageNode/AdhocTask.d.ts +13 -0
  15. package/dist/canvas/components/StageNode/AdhocTask.d.ts.map +1 -0
  16. package/dist/canvas/components/StageNode/AdhocTask.js +104 -0
  17. package/dist/canvas/components/StageNode/DraggableTask.cjs +14 -5
  18. package/dist/canvas/components/StageNode/DraggableTask.d.ts +1 -1
  19. package/dist/canvas/components/StageNode/DraggableTask.d.ts.map +1 -1
  20. package/dist/canvas/components/StageNode/DraggableTask.js +14 -5
  21. package/dist/canvas/components/StageNode/DraggableTask.types.d.ts +3 -3
  22. package/dist/canvas/components/StageNode/DraggableTask.types.d.ts.map +1 -1
  23. package/dist/canvas/components/StageNode/StageEdge.cjs +34 -11
  24. package/dist/canvas/components/StageNode/StageEdge.d.ts +2 -1
  25. package/dist/canvas/components/StageNode/StageEdge.d.ts.map +1 -1
  26. package/dist/canvas/components/StageNode/StageEdge.js +35 -12
  27. package/dist/canvas/components/StageNode/StageNode.cjs +66 -122
  28. package/dist/canvas/components/StageNode/StageNode.d.ts.map +1 -1
  29. package/dist/canvas/components/StageNode/StageNode.js +73 -119
  30. package/dist/canvas/components/StageNode/StageNode.stories.cjs +134 -180
  31. package/dist/canvas/components/StageNode/StageNode.stories.d.ts +2 -2
  32. package/dist/canvas/components/StageNode/StageNode.stories.d.ts.map +1 -1
  33. package/dist/canvas/components/StageNode/StageNode.stories.js +130 -176
  34. package/dist/canvas/components/StageNode/StageNode.stories.utils.cjs +45 -0
  35. package/dist/canvas/components/StageNode/StageNode.stories.utils.d.ts +8 -0
  36. package/dist/canvas/components/StageNode/StageNode.stories.utils.d.ts.map +1 -0
  37. package/dist/canvas/components/StageNode/StageNode.stories.utils.js +11 -0
  38. package/dist/canvas/components/StageNode/StageNode.styles.cjs +1 -1
  39. package/dist/canvas/components/StageNode/StageNode.styles.js +1 -1
  40. package/dist/canvas/components/StageNode/StageNode.types.d.ts +9 -4
  41. package/dist/canvas/components/StageNode/StageNode.types.d.ts.map +1 -1
  42. package/dist/canvas/components/StageNode/StageTaskDragOverlay.cjs +69 -0
  43. package/dist/canvas/components/StageNode/StageTaskDragOverlay.d.ts +3 -0
  44. package/dist/canvas/components/StageNode/StageTaskDragOverlay.d.ts.map +1 -0
  45. package/dist/canvas/components/StageNode/StageTaskDragOverlay.js +35 -0
  46. package/dist/canvas/components/StageNode/TaskMenu.cjs +13 -17
  47. package/dist/canvas/components/StageNode/TaskMenu.d.ts +1 -2
  48. package/dist/canvas/components/StageNode/TaskMenu.d.ts.map +1 -1
  49. package/dist/canvas/components/StageNode/TaskMenu.js +14 -18
  50. package/dist/canvas/components/StageNode/index.d.ts +1 -1
  51. package/dist/canvas/components/StageNode/index.d.ts.map +1 -1
  52. package/package.json +1 -1
@@ -1,26 +1,27 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { DndContext, DragOverlay, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
2
+ import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
3
3
  import { SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy } from "@dnd-kit/sortable";
4
4
  import { FontVariantToken, Icon, Padding, Spacing } from "@uipath/apollo-core";
5
5
  import { Column, Row } from "../../layouts/index.js";
6
- import { Position, useStore, useViewport } from "../../xyflow/react.js";
7
- import { ApCircularProgress, ApIcon, ApIconButton, ApLink, ApTooltip, ApTypography } from "../../../material/index.js";
8
- import debounce from "debounce";
6
+ import { Position, useStore, useStoreApi } from "../../xyflow/react.js";
7
+ import { ApIcon, ApIconButton, ApLink, ApTooltip, ApTypography } from "../../../material/index.js";
9
8
  import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
10
- import { createPortal } from "react-dom";
11
- import { EntryConditionIcon, ExitConditionIcon, PlayIcon, ReturnToOriginIcon } from "../../icons/index.js";
9
+ import { EntryConditionIcon, ExitConditionIcon, ReturnToOriginIcon } from "../../icons/index.js";
10
+ import { GroupModificationType } from "../../utils/GroupModificationUtils.js";
12
11
  import { useConnectedHandles } from "../BaseCanvas/ConnectedHandlesContext.js";
13
12
  import { useButtonHandles } from "../ButtonHandle/useButtonHandles.js";
14
13
  import { ExecutionStatusIcon } from "../ExecutionStatusIcon/index.js";
15
14
  import { FloatingCanvasPanel } from "../FloatingCanvasPanel/index.js";
16
15
  import { NodeContextMenu } from "../NodeContextMenu/index.js";
17
- import { useNodeSelection } from "../NodePropertiesPanel/hooks/index.js";
16
+ import { useSetNodeSelection } from "../NodePropertiesPanel/hooks/index.js";
18
17
  import { Toolbox } from "../Toolbox/index.js";
19
- import { DraggableTask, TaskContent } from "./DraggableTask.js";
20
- import { INDENTATION_WIDTH, STAGE_CONTENT_INSET, StageAdhocHeaderSection, StageAdhocSection, StageChip, StageContainer, StageContent, StageHeader, StageHeaderChipsRow, StageParallelBracket, StageParallelLabel, StageTask, StageTaskGroup, StageTaskList, StageTitleContainer, StageTitleInput } from "./StageNode.styles.js";
18
+ import { AdhocTaskItem } from "./AdhocTask.js";
19
+ import { DraggableTask } from "./DraggableTask.js";
20
+ import { INDENTATION_WIDTH, STAGE_CONTENT_INSET, StageAdhocHeaderSection, StageAdhocSection, StageChip, StageContainer, StageContent, StageHeader, StageHeaderChipsRow, StageParallelBracket, StageParallelLabel, StageTaskGroup, StageTaskList, StageTitleContainer, StageTitleInput } from "./StageNode.styles.js";
21
21
  import { StageHeaderChipType } from "./StageNode.types.js";
22
22
  import { flattenTasks, getProjection, reorderTasks } from "./StageNode.utils.js";
23
23
  import { getContextMenuItems, getDivider, getMenuItem } from "./StageNodeTaskUtilities.js";
24
+ import { StageTaskDragOverlay } from "./StageTaskDragOverlay.js";
24
25
  const CHIP_ICONS = {
25
26
  [StageHeaderChipType.Entry]: /*#__PURE__*/ jsx(EntryConditionIcon, {
26
27
  w: Icon.IconXs,
@@ -43,54 +44,7 @@ const CHIP_ICONS = {
43
44
  size: Icon.IconXs
44
45
  })
45
46
  };
46
- const AdhocTaskPlayButton = /*#__PURE__*/ memo(({ taskId, onTaskPlay })=>{
47
- const [playLoading, setPlayLoading] = useState(false);
48
- const debouncedTaskPlay = useMemo(()=>debounce(async (id)=>{
49
- setPlayLoading(true);
50
- try {
51
- await onTaskPlay(id);
52
- } catch {} finally{
53
- setPlayLoading(false);
54
- }
55
- }, 500, {
56
- immediate: true
57
- }), [
58
- onTaskPlay
59
- ]);
60
- const handlePlayClick = useCallback((e)=>{
61
- e.stopPropagation();
62
- e.preventDefault();
63
- debouncedTaskPlay(taskId);
64
- }, [
65
- debouncedTaskPlay,
66
- taskId
67
- ]);
68
- return /*#__PURE__*/ jsx(ApTooltip, {
69
- content: "Trigger task",
70
- placement: "top",
71
- children: /*#__PURE__*/ jsx(ApIconButton, {
72
- "data-testid": `stage-task-play-${taskId}`,
73
- onClick: handlePlayClick,
74
- onMouseDown: (e)=>e.stopPropagation(),
75
- onKeyDown: (e)=>e.stopPropagation(),
76
- className: "task-menu-icon-button",
77
- sx: {
78
- color: 'var(--uix-canvas-primary) !important',
79
- minWidth: 'unset !important',
80
- width: `${Spacing.SpacingL} !important`,
81
- height: `${Spacing.SpacingL} !important`,
82
- padding: '0 !important'
83
- },
84
- children: playLoading ? /*#__PURE__*/ jsx(ApCircularProgress, {
85
- size: 20
86
- }) : /*#__PURE__*/ jsx(PlayIcon, {
87
- w: 20,
88
- h: 20
89
- })
90
- })
91
- });
92
- });
93
- const StageNodeComponent = (props)=>{
47
+ const StageNodeInner = (props)=>{
94
48
  const { dragging, selected, id, width, execution, stageDetails, addTaskLabel = 'Add task', addTaskLoading = false, replaceTaskLabel = 'Replace task', taskOptions = [], menuItems, pendingReplaceTask, onStageClick, onTaskAdd, onAddTaskFromToolbox, onTaskToolboxSearch, onTaskClick, onTaskGroupModification, onStageTitleChange, onTaskReorder, onReplaceTaskFromToolbox, onTaskPlay, hideParallelOptions } = props;
95
49
  const taskWidth = width ? width - STAGE_CONTENT_INSET : void 0;
96
50
  const allTasks = useMemo(()=>stageDetails?.tasks || [], [
@@ -99,7 +53,11 @@ const StageNodeComponent = (props)=>{
99
53
  const tasks = useMemo(()=>allTasks.filter((group)=>group.some((t)=>!t.isAdhoc)), [
100
54
  allTasks
101
55
  ]);
102
- const adhocTasks = useMemo(()=>allTasks.flat().filter((t)=>t.isAdhoc), [
56
+ const adhocTasks = useMemo(()=>allTasks.flatMap((group, groupIndex)=>group.map((task, taskIndex)=>({
57
+ task,
58
+ groupIndex,
59
+ taskIndex
60
+ })).filter(({ task })=>task.isAdhoc)), [
103
61
  allTasks
104
62
  ]);
105
63
  const flatTasks = useMemo(()=>tasks.flat(), [
@@ -116,9 +74,6 @@ const StageNodeComponent = (props)=>{
116
74
  const status = execution?.stageStatus?.status;
117
75
  const statusLabel = execution?.stageStatus?.label;
118
76
  const stageDuration = execution?.stageStatus?.duration;
119
- const reGroupTaskFunction = useMemo(()=>onTaskGroupModification || (()=>{}), [
120
- onTaskGroupModification
121
- ]);
122
77
  const isStageTitleEditable = !!onStageTitleChange && !isReadOnly;
123
78
  const [isHovered, setIsHovered] = useState(false);
124
79
  const [label, setLabel] = useState(props.stageDetails.label);
@@ -135,6 +90,7 @@ const StageNodeComponent = (props)=>{
135
90
  taskIndex: -1
136
91
  });
137
92
  const isConnecting = useStore((state)=>!!state.connectionClickStartHandle);
93
+ const storeApi = useStoreApi();
138
94
  const connectedHandleIds = useConnectedHandles(id);
139
95
  const [isAddingTask, setIsAddingTask] = useState(false);
140
96
  const [isReplacingTask, setIsReplacingTask] = useState(false);
@@ -174,7 +130,6 @@ const StageNodeComponent = (props)=>{
174
130
  tasks,
175
131
  activeDragId
176
132
  ]);
177
- const { zoom } = useViewport();
178
133
  const projected = useMemo(()=>{
179
134
  if (!activeDragId || !overId) return null;
180
135
  return getProjection(tasks, activeDragId, overId, offsetLeft);
@@ -257,18 +212,26 @@ const StageNodeComponent = (props)=>{
257
212
  handleStageTitleClickToSave,
258
213
  isStageTitleEditing
259
214
  ]);
260
- const contextMenuItems = useCallback((isParallel, groupIndex, taskIndex, tasksLength, taskGroupLength, isAboveParallel, isBelowParallel)=>{
215
+ const hasContextMenu = !!(onReplaceTaskFromToolbox || onTaskGroupModification);
216
+ const buildContextMenuItems = useCallback((groupIndex, taskIndex)=>{
217
+ const taskGroup = tasks[groupIndex] ?? [];
218
+ const isParallel = taskGroup.length > 1;
261
219
  const items = [];
262
220
  if (onReplaceTaskFromToolbox) {
263
221
  items.push(getMenuItem('replace-task', 'Replace task', ()=>{
264
- const taskId = tasks[groupIndex]?.[taskIndex]?.id;
222
+ taskStateReference.current = {
223
+ isParallel,
224
+ groupIndex,
225
+ taskIndex
226
+ };
227
+ const taskId = taskGroup[taskIndex]?.id;
265
228
  if (taskId) onTaskClick?.(taskId);
266
229
  setIsReplacingTask(true);
267
230
  }));
268
231
  items.push(getDivider());
269
232
  }
270
233
  if (onTaskGroupModification) {
271
- const reGroupOptions = getContextMenuItems(isParallel, groupIndex, tasksLength, taskIndex, taskGroupLength, isAboveParallel, isBelowParallel, reGroupTaskFunction, hideParallelOptions);
234
+ const reGroupOptions = getContextMenuItems(isParallel, groupIndex, tasks.length, taskIndex, taskGroup.length, (tasks[groupIndex - 1]?.length ?? 0) > 1, (tasks[groupIndex + 1]?.length ?? 0) > 1, onTaskGroupModification, hideParallelOptions);
272
235
  return [
273
236
  ...items,
274
237
  ...reGroupOptions
@@ -279,11 +242,31 @@ const StageNodeComponent = (props)=>{
279
242
  onReplaceTaskFromToolbox,
280
243
  onTaskClick,
281
244
  onTaskGroupModification,
282
- reGroupTaskFunction,
283
245
  tasks,
284
246
  hideParallelOptions
285
247
  ]);
286
- const { setSelectedNodeId } = useNodeSelection();
248
+ const getAdhocContextMenuItems = useCallback((groupIndex, taskIndex, taskId)=>{
249
+ const items = [];
250
+ if (onReplaceTaskFromToolbox) items.push(getMenuItem('replace-task', 'Replace task', ()=>{
251
+ taskStateReference.current = {
252
+ isParallel: false,
253
+ groupIndex,
254
+ taskIndex
255
+ };
256
+ onTaskClick?.(taskId);
257
+ setIsReplacingTask(true);
258
+ }));
259
+ if (onTaskGroupModification) {
260
+ if (items.length > 0) items.push(getDivider());
261
+ items.push(getMenuItem('remove-task', 'Delete task', ()=>onTaskGroupModification(GroupModificationType.REMOVE_TASK, groupIndex, taskIndex)));
262
+ }
263
+ return items;
264
+ }, [
265
+ onReplaceTaskFromToolbox,
266
+ onTaskClick,
267
+ onTaskGroupModification
268
+ ]);
269
+ const { setSelectedNodeId } = useSetNodeSelection();
287
270
  const handleStageClick = useCallback(()=>{
288
271
  onStageClick?.();
289
272
  }, [
@@ -406,9 +389,9 @@ const StageNodeComponent = (props)=>{
406
389
  setActiveDragId(event.active.id);
407
390
  }, []);
408
391
  const handleDragMove = useCallback((event)=>{
409
- setOffsetLeft(event.delta.x / zoom);
392
+ setOffsetLeft(event.delta.x / storeApi.getState().transform[2]);
410
393
  }, [
411
- zoom
394
+ storeApi
412
395
  ]);
413
396
  const handleDragOver = useCallback((event)=>{
414
397
  setOverId(event.over?.id ?? null);
@@ -444,12 +427,6 @@ const StageNodeComponent = (props)=>{
444
427
  } : void 0, [
445
428
  taskWidth
446
429
  ]);
447
- const dragOverlayStyle = useMemo(()=>({
448
- transform: `scale(${zoom})`,
449
- transformOrigin: 'top left'
450
- }), [
451
- zoom
452
- ]);
453
430
  return /*#__PURE__*/ jsxs("div", {
454
431
  "data-testid": `stage-${id}`,
455
432
  style: {
@@ -467,6 +444,7 @@ const StageNodeComponent = (props)=>{
467
444
  children: [
468
445
  /*#__PURE__*/ jsxs(StageHeader, {
469
446
  isException: isException,
447
+ "data-testid": `stage-header-${id}`,
470
448
  children: [
471
449
  /*#__PURE__*/ jsxs(Row, {
472
450
  gap: Spacing.SpacingMicro,
@@ -631,19 +609,13 @@ const StageNodeComponent = (props)=>{
631
609
  taskExecution: taskExecution,
632
610
  isSelected: selectedTaskId === task.id,
633
611
  isParallel: isParallel,
634
- contextMenuItems: contextMenuItems(isParallel, groupIndex, taskIndex, tasks.length, taskGroup.length, (tasks[groupIndex - 1]?.length ?? 0) > 1, (tasks[groupIndex + 1]?.length ?? 0) > 1),
612
+ groupIndex: groupIndex,
613
+ taskIndex: taskIndex,
635
614
  onTaskClick: handleTaskClick,
636
615
  projectedDepth: task.id === activeDragId && projected ? projected.depth : void 0,
637
616
  isDragDisabled: !onTaskReorder,
638
- zoom: zoom,
639
- ...(onTaskGroupModification || onReplaceTaskFromToolbox) && {
640
- onMenuOpen: ()=>{
641
- taskStateReference.current = {
642
- isParallel,
643
- groupIndex,
644
- taskIndex
645
- };
646
- }
617
+ ...hasContextMenu && {
618
+ getContextMenuItems: buildContextMenuItems
647
619
  }
648
620
  }, task.id);
649
621
  })
@@ -654,23 +626,11 @@ const StageNodeComponent = (props)=>{
654
626
  })
655
627
  })
656
628
  }),
657
- /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx(DragOverlay, {
658
- children: activeTask ? /*#__PURE__*/ jsx("div", {
659
- style: dragOverlayStyle,
660
- children: /*#__PURE__*/ jsx(StageTask, {
661
- selected: true,
662
- isParallel: isActiveTaskParallel,
663
- style: {
664
- cursor: 'grabbing',
665
- ...taskWidthStyle
666
- },
667
- children: /*#__PURE__*/ jsx(TaskContent, {
668
- task: activeTask,
669
- isDragging: true
670
- })
671
- })
672
- }) : null
673
- }), document.body)
629
+ /*#__PURE__*/ jsx(StageTaskDragOverlay, {
630
+ activeTask: activeTask,
631
+ isActiveTaskParallel: isActiveTaskParallel,
632
+ taskWidthStyle: taskWidthStyle
633
+ })
674
634
  ]
675
635
  }),
676
636
  adhocTasks.length > 0 && /*#__PURE__*/ jsxs(StageAdhocSection, {
@@ -686,23 +646,17 @@ const StageNodeComponent = (props)=>{
686
646
  })
687
647
  }),
688
648
  /*#__PURE__*/ jsx(StageTaskList, {
689
- children: adhocTasks.map((task)=>{
649
+ children: adhocTasks.map(({ task, groupIndex, taskIndex })=>{
690
650
  const taskExecution = execution?.taskStatus?.[task.id];
691
- return /*#__PURE__*/ jsxs(StageTask, {
692
- "data-testid": `stage-task-${task.id}`,
693
- selected: selectedTaskId === task.id,
694
- status: taskExecution?.status,
695
- onClick: (e)=>handleTaskClick(e, task.id),
696
- children: [
697
- /*#__PURE__*/ jsx(TaskContent, {
698
- task: task,
699
- taskExecution: taskExecution
700
- }),
701
- onTaskPlay && /*#__PURE__*/ jsx(AdhocTaskPlayButton, {
702
- taskId: task.id,
703
- onTaskPlay: onTaskPlay
704
- })
705
- ]
651
+ return /*#__PURE__*/ jsx(AdhocTaskItem, {
652
+ task: task,
653
+ taskExecution: taskExecution,
654
+ isSelected: selectedTaskId === task.id,
655
+ onTaskClick: handleTaskClick,
656
+ onTaskPlay: onTaskPlay,
657
+ ...(onTaskGroupModification || onReplaceTaskFromToolbox) && {
658
+ getContextMenuItems: ()=>getAdhocContextMenuItems(groupIndex, taskIndex, task.id)
659
+ }
706
660
  }, task.id);
707
661
  })
708
662
  })
@@ -746,5 +700,5 @@ const StageNodeComponent = (props)=>{
746
700
  ]
747
701
  });
748
702
  };
749
- const StageNode = /*#__PURE__*/ memo(StageNodeComponent);
703
+ const StageNode = /*#__PURE__*/ memo(StageNodeInner);
750
704
  export { StageNode };