@uipath/apollo-react 3.68.2 → 3.68.3-pr431.8e3b0c3

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 +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/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 +90 -122
  28. package/dist/canvas/components/StageNode/StageNode.d.ts +1 -1
  29. package/dist/canvas/components/StageNode/StageNode.d.ts.map +1 -1
  30. package/dist/canvas/components/StageNode/StageNode.js +97 -119
  31. package/dist/canvas/components/StageNode/StageNode.stories.cjs +123 -158
  32. package/dist/canvas/components/StageNode/StageNode.stories.d.ts.map +1 -1
  33. package/dist/canvas/components/StageNode/StageNode.stories.js +119 -154
  34. package/dist/canvas/components/StageNode/StageNode.stories.utils.cjs +42 -0
  35. package/dist/canvas/components/StageNode/StageNode.stories.utils.d.ts +3 -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 +8 -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 -1
  41. package/dist/canvas/components/StageNode/StageNode.types.d.ts.map +1 -1
  42. package/dist/canvas/components/StageNode/StageTaskDragOverlay.cjs +68 -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 +34 -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: {
@@ -632,19 +609,13 @@ const StageNodeComponent = (props)=>{
632
609
  taskExecution: taskExecution,
633
610
  isSelected: selectedTaskId === task.id,
634
611
  isParallel: isParallel,
635
- 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,
636
614
  onTaskClick: handleTaskClick,
637
615
  projectedDepth: task.id === activeDragId && projected ? projected.depth : void 0,
638
616
  isDragDisabled: !onTaskReorder,
639
- zoom: zoom,
640
- ...(onTaskGroupModification || onReplaceTaskFromToolbox) && {
641
- onMenuOpen: ()=>{
642
- taskStateReference.current = {
643
- isParallel,
644
- groupIndex,
645
- taskIndex
646
- };
647
- }
617
+ ...hasContextMenu && {
618
+ getContextMenuItems: buildContextMenuItems
648
619
  }
649
620
  }, task.id);
650
621
  })
@@ -655,23 +626,11 @@ const StageNodeComponent = (props)=>{
655
626
  })
656
627
  })
657
628
  }),
658
- /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx(DragOverlay, {
659
- children: activeTask ? /*#__PURE__*/ jsx("div", {
660
- style: dragOverlayStyle,
661
- children: /*#__PURE__*/ jsx(StageTask, {
662
- selected: true,
663
- isParallel: isActiveTaskParallel,
664
- style: {
665
- cursor: 'grabbing',
666
- ...taskWidthStyle
667
- },
668
- children: /*#__PURE__*/ jsx(TaskContent, {
669
- task: activeTask,
670
- isDragging: true
671
- })
672
- })
673
- }) : null
674
- }), document.body)
629
+ /*#__PURE__*/ jsx(StageTaskDragOverlay, {
630
+ activeTask: activeTask,
631
+ isActiveTaskParallel: isActiveTaskParallel,
632
+ taskWidthStyle: taskWidthStyle
633
+ })
675
634
  ]
676
635
  }),
677
636
  adhocTasks.length > 0 && /*#__PURE__*/ jsxs(StageAdhocSection, {
@@ -687,23 +646,17 @@ const StageNodeComponent = (props)=>{
687
646
  })
688
647
  }),
689
648
  /*#__PURE__*/ jsx(StageTaskList, {
690
- children: adhocTasks.map((task)=>{
649
+ children: adhocTasks.map(({ task, groupIndex, taskIndex })=>{
691
650
  const taskExecution = execution?.taskStatus?.[task.id];
692
- return /*#__PURE__*/ jsxs(StageTask, {
693
- "data-testid": `stage-task-${task.id}`,
694
- selected: selectedTaskId === task.id,
695
- status: taskExecution?.status,
696
- onClick: (e)=>handleTaskClick(e, task.id),
697
- children: [
698
- /*#__PURE__*/ jsx(TaskContent, {
699
- task: task,
700
- taskExecution: taskExecution
701
- }),
702
- onTaskPlay && /*#__PURE__*/ jsx(AdhocTaskPlayButton, {
703
- taskId: task.id,
704
- onTaskPlay: onTaskPlay
705
- })
706
- ]
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
+ }
707
660
  }, task.id);
708
661
  })
709
662
  })
@@ -747,5 +700,30 @@ const StageNodeComponent = (props)=>{
747
700
  ]
748
701
  });
749
702
  };
750
- const StageNode = /*#__PURE__*/ memo(StageNodeComponent);
703
+ const StageNodeInnerMemo = /*#__PURE__*/ memo(StageNodeInner);
704
+ const StageNode = ({ dragging, selected, id, width, execution, stageDetails, addTaskLabel, addTaskLoading, replaceTaskLabel, taskOptions, menuItems, pendingReplaceTask, onStageClick, onTaskAdd, onAddTaskFromToolbox, onTaskToolboxSearch, onTaskClick, onTaskGroupModification, onStageTitleChange, onTaskReorder, onReplaceTaskFromToolbox, onTaskPlay, hideParallelOptions })=>/*#__PURE__*/ jsx(StageNodeInnerMemo, {
705
+ dragging: dragging,
706
+ selected: selected,
707
+ id: id,
708
+ width: width,
709
+ execution: execution,
710
+ stageDetails: stageDetails,
711
+ addTaskLabel: addTaskLabel,
712
+ addTaskLoading: addTaskLoading,
713
+ replaceTaskLabel: replaceTaskLabel,
714
+ taskOptions: taskOptions,
715
+ menuItems: menuItems,
716
+ pendingReplaceTask: pendingReplaceTask,
717
+ onStageClick: onStageClick,
718
+ onTaskAdd: onTaskAdd,
719
+ onAddTaskFromToolbox: onAddTaskFromToolbox,
720
+ onTaskToolboxSearch: onTaskToolboxSearch,
721
+ onTaskClick: onTaskClick,
722
+ onTaskGroupModification: onTaskGroupModification,
723
+ onStageTitleChange: onStageTitleChange,
724
+ onTaskReorder: onTaskReorder,
725
+ onReplaceTaskFromToolbox: onReplaceTaskFromToolbox,
726
+ onTaskPlay: onTaskPlay,
727
+ hideParallelOptions: hideParallelOptions
728
+ });
751
729
  export { StageNode };