@uipath/apollo-react 3.44.0 → 3.44.2-pr255.af80ea0
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/canvas/components/StageNode/CrossStageTaskDrag.stories.cjs +581 -0
- package/dist/canvas/components/StageNode/CrossStageTaskDrag.stories.d.ts +6 -0
- package/dist/canvas/components/StageNode/CrossStageTaskDrag.stories.d.ts.map +1 -0
- package/dist/canvas/components/StageNode/CrossStageTaskDrag.stories.js +544 -0
- package/dist/canvas/components/StageNode/DropPlaceholder.cjs +106 -0
- package/dist/canvas/components/StageNode/DropPlaceholder.d.ts +10 -0
- package/dist/canvas/components/StageNode/DropPlaceholder.d.ts.map +1 -0
- package/dist/canvas/components/StageNode/DropPlaceholder.js +72 -0
- package/dist/canvas/components/StageNode/StageNode.cjs +334 -389
- package/dist/canvas/components/StageNode/StageNode.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNode.js +336 -391
- package/dist/canvas/components/StageNode/StageNode.stories.cjs +1910 -1416
- package/dist/canvas/components/StageNode/StageNode.stories.d.ts +1 -1
- package/dist/canvas/components/StageNode/StageNode.stories.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNode.stories.js +1906 -1412
- package/dist/canvas/components/StageNode/StageNode.styles.cjs +1 -1
- package/dist/canvas/components/StageNode/StageNode.styles.js +1 -1
- package/dist/canvas/components/StageNode/StageNode.types.d.ts +26 -10
- package/dist/canvas/components/StageNode/StageNode.types.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNodeTaskUtilities.cjs +10 -5
- package/dist/canvas/components/StageNode/StageNodeTaskUtilities.d.ts +2 -1
- package/dist/canvas/components/StageNode/StageNodeTaskUtilities.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNodeTaskUtilities.js +6 -4
- package/dist/canvas/components/StageNode/TaskMenu.cjs +11 -43
- package/dist/canvas/components/StageNode/TaskMenu.d.ts +1 -6
- package/dist/canvas/components/StageNode/TaskMenu.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/TaskMenu.js +13 -35
- package/dist/canvas/components/StageNode/index.cjs +17 -3
- package/dist/canvas/components/StageNode/index.d.ts +4 -1
- package/dist/canvas/components/StageNode/index.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/index.js +3 -1
- package/dist/canvas/components/TaskNode/PlaceholderTaskNode.cjs +51 -0
- package/dist/canvas/components/TaskNode/PlaceholderTaskNode.d.ts +8 -0
- package/dist/canvas/components/TaskNode/PlaceholderTaskNode.d.ts.map +1 -0
- package/dist/canvas/components/TaskNode/PlaceholderTaskNode.js +17 -0
- package/dist/canvas/components/TaskNode/TaskNode.cjs +235 -0
- package/dist/canvas/components/TaskNode/TaskNode.d.ts +11 -0
- package/dist/canvas/components/TaskNode/TaskNode.d.ts.map +1 -0
- package/dist/canvas/components/TaskNode/TaskNode.js +198 -0
- package/dist/canvas/components/TaskNode/TaskNode.stories.cjs +558 -0
- package/dist/canvas/components/TaskNode/TaskNode.stories.d.ts +8 -0
- package/dist/canvas/components/TaskNode/TaskNode.stories.d.ts.map +1 -0
- package/dist/canvas/components/TaskNode/TaskNode.stories.js +515 -0
- package/dist/canvas/components/TaskNode/TaskNode.types.d.ts +40 -0
- package/dist/canvas/components/TaskNode/TaskNode.types.d.ts.map +1 -0
- package/dist/canvas/components/TaskNode/TaskNodeContext.cjs +86 -0
- package/dist/canvas/components/TaskNode/TaskNodeContext.d.ts +24 -0
- package/dist/canvas/components/TaskNode/TaskNodeContext.d.ts.map +1 -0
- package/dist/canvas/components/TaskNode/TaskNodeContext.js +40 -0
- package/dist/canvas/components/TaskNode/index.cjs +82 -0
- package/dist/canvas/components/TaskNode/index.d.ts +8 -0
- package/dist/canvas/components/TaskNode/index.d.ts.map +1 -0
- package/dist/canvas/components/TaskNode/index.js +6 -0
- package/dist/canvas/components/TaskNode/taskReorderUtils.cjs +206 -0
- package/dist/canvas/components/TaskNode/taskReorderUtils.d.ts +23 -0
- package/dist/canvas/components/TaskNode/taskReorderUtils.d.ts.map +1 -0
- package/dist/canvas/components/TaskNode/taskReorderUtils.js +154 -0
- package/dist/canvas/components/TaskNode/useTaskPositions.cjs +153 -0
- package/dist/canvas/components/TaskNode/useTaskPositions.d.ts +29 -0
- package/dist/canvas/components/TaskNode/useTaskPositions.d.ts.map +1 -0
- package/dist/canvas/components/TaskNode/useTaskPositions.js +110 -0
- package/dist/canvas/core/TaskTypeRegistry.cjs +132 -0
- package/dist/canvas/core/TaskTypeRegistry.d.ts +18 -0
- package/dist/canvas/core/TaskTypeRegistry.d.ts.map +1 -0
- package/dist/canvas/core/TaskTypeRegistry.js +98 -0
- package/dist/canvas/core/index.cjs +21 -3
- package/dist/canvas/core/index.d.ts +2 -0
- package/dist/canvas/core/index.d.ts.map +1 -1
- package/dist/canvas/core/index.js +2 -0
- package/dist/canvas/core/useTaskTypeRegistry.cjs +82 -0
- package/dist/canvas/core/useTaskTypeRegistry.d.ts +13 -0
- package/dist/canvas/core/useTaskTypeRegistry.d.ts.map +1 -0
- package/dist/canvas/core/useTaskTypeRegistry.js +33 -0
- package/dist/canvas/hooks/CrossStageDragContext.cjs +45 -0
- package/dist/canvas/hooks/CrossStageDragContext.d.ts +8 -0
- package/dist/canvas/hooks/CrossStageDragContext.d.ts.map +1 -0
- package/dist/canvas/hooks/CrossStageDragContext.js +8 -0
- package/dist/canvas/hooks/calculateTaskDropPosition.cjs +253 -0
- package/dist/canvas/hooks/calculateTaskDropPosition.d.ts +11 -0
- package/dist/canvas/hooks/calculateTaskDropPosition.d.ts.map +1 -0
- package/dist/canvas/hooks/calculateTaskDropPosition.js +216 -0
- package/dist/canvas/hooks/index.cjs +57 -30
- package/dist/canvas/hooks/index.d.ts +3 -0
- package/dist/canvas/hooks/index.d.ts.map +1 -1
- package/dist/canvas/hooks/index.js +3 -0
- package/dist/canvas/hooks/useCrossStageTaskDrag.cjs +346 -0
- package/dist/canvas/hooks/useCrossStageTaskDrag.d.ts +44 -0
- package/dist/canvas/hooks/useCrossStageTaskDrag.d.ts.map +1 -0
- package/dist/canvas/hooks/useCrossStageTaskDrag.js +312 -0
- package/dist/canvas/hooks/useTaskCopyPaste.cjs +155 -0
- package/dist/canvas/hooks/useTaskCopyPaste.d.ts +34 -0
- package/dist/canvas/hooks/useTaskCopyPaste.d.ts.map +1 -0
- package/dist/canvas/hooks/useTaskCopyPaste.js +121 -0
- package/dist/canvas/schema/index.cjs +12 -3
- package/dist/canvas/schema/index.d.ts +1 -0
- package/dist/canvas/schema/index.d.ts.map +1 -1
- package/dist/canvas/schema/index.js +1 -0
- package/dist/canvas/schema/task-definition/index.cjs +60 -0
- package/dist/canvas/schema/task-definition/index.d.ts +2 -0
- package/dist/canvas/schema/task-definition/index.d.ts.map +1 -0
- package/dist/canvas/schema/task-definition/index.js +1 -0
- package/dist/canvas/schema/task-definition/task-manifest.cjs +78 -0
- package/dist/canvas/schema/task-definition/task-manifest.d.ts +43 -0
- package/dist/canvas/schema/task-definition/task-manifest.d.ts.map +1 -0
- package/dist/canvas/schema/task-definition/task-manifest.js +29 -0
- package/dist/material/components/ap-sankey-diagram/ApSankeyDiagram.cjs +44 -21
- package/dist/material/components/ap-sankey-diagram/ApSankeyDiagram.d.ts.map +1 -1
- package/dist/material/components/ap-sankey-diagram/ApSankeyDiagram.js +44 -21
- package/package.json +3 -3
- package/dist/canvas/components/StageNode/DraggableTask.cjs +0 -271
- package/dist/canvas/components/StageNode/DraggableTask.d.ts +0 -4
- package/dist/canvas/components/StageNode/DraggableTask.d.ts.map +0 -1
- package/dist/canvas/components/StageNode/DraggableTask.js +0 -234
- package/dist/canvas/components/StageNode/DraggableTask.types.d.ts +0 -20
- package/dist/canvas/components/StageNode/DraggableTask.types.d.ts.map +0 -1
- package/dist/canvas/components/StageNode/StageNode.utils.cjs +0 -164
- package/dist/canvas/components/StageNode/StageNode.utils.d.ts +0 -19
- package/dist/canvas/components/StageNode/StageNode.utils.d.ts.map +0 -1
- package/dist/canvas/components/StageNode/StageNode.utils.js +0 -121
- /package/dist/canvas/components/{StageNode/DraggableTask.types.cjs → TaskNode/TaskNode.types.cjs} +0 -0
- /package/dist/canvas/components/{StageNode/DraggableTask.types.js → TaskNode/TaskNode.types.js} +0 -0
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
reorderTasks: ()=>reorderTasks,
|
|
28
|
-
flattenTasks: ()=>flattenTasks,
|
|
29
|
-
getProjection: ()=>getProjection,
|
|
30
|
-
buildTaskGroups: ()=>buildTaskGroups
|
|
31
|
-
});
|
|
32
|
-
const sortable_namespaceObject = require("@dnd-kit/sortable");
|
|
33
|
-
const external_StageNode_styles_cjs_namespaceObject = require("./StageNode.styles.cjs");
|
|
34
|
-
function flattenTasks(tasks) {
|
|
35
|
-
const flattened = [];
|
|
36
|
-
for (const [groupIndex, group] of tasks.entries()){
|
|
37
|
-
if (!group) continue;
|
|
38
|
-
const depth = group.length > 1 ? 1 : 0;
|
|
39
|
-
for (const [taskIndex, task] of group.entries())if (task) flattened.push({
|
|
40
|
-
id: task.id,
|
|
41
|
-
task,
|
|
42
|
-
groupIndex,
|
|
43
|
-
taskIndex,
|
|
44
|
-
depth
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
return flattened;
|
|
48
|
-
}
|
|
49
|
-
function buildTaskGroups(flattenedTasks) {
|
|
50
|
-
const groups = [];
|
|
51
|
-
let currentGroup = [];
|
|
52
|
-
let previousDepth = null;
|
|
53
|
-
let previousGroupIndex = null;
|
|
54
|
-
for (const item of flattenedTasks){
|
|
55
|
-
if (null === previousDepth) currentGroup.push(item.task);
|
|
56
|
-
else if (1 === item.depth && 1 === previousDepth && item.groupIndex === previousGroupIndex) currentGroup.push(item.task);
|
|
57
|
-
else {
|
|
58
|
-
if (currentGroup.length > 0) groups.push(currentGroup);
|
|
59
|
-
currentGroup = [
|
|
60
|
-
item.task
|
|
61
|
-
];
|
|
62
|
-
}
|
|
63
|
-
previousDepth = item.depth;
|
|
64
|
-
previousGroupIndex = item.groupIndex;
|
|
65
|
-
}
|
|
66
|
-
if (currentGroup.length > 0) groups.push(currentGroup);
|
|
67
|
-
return groups;
|
|
68
|
-
}
|
|
69
|
-
function reorderTasks(tasks, activeId, overId, projectedDepth) {
|
|
70
|
-
const flattened = flattenTasks(tasks);
|
|
71
|
-
const activeIndex = flattened.findIndex((t)=>t.id === activeId);
|
|
72
|
-
const overIndex = flattened.findIndex((t)=>t.id === overId);
|
|
73
|
-
if (-1 === activeIndex || -1 === overIndex) return tasks;
|
|
74
|
-
const activeTask = flattened[activeIndex];
|
|
75
|
-
if (!activeTask) return tasks;
|
|
76
|
-
const reordered = (0, sortable_namespaceObject.arrayMove)(flattened, activeIndex, overIndex);
|
|
77
|
-
const movedItem = reordered[overIndex];
|
|
78
|
-
if (movedItem) {
|
|
79
|
-
let newGroupIndex = movedItem.groupIndex;
|
|
80
|
-
if (1 === projectedDepth) {
|
|
81
|
-
const prevItem = reordered[overIndex - 1];
|
|
82
|
-
const nextItem = reordered[overIndex + 1];
|
|
83
|
-
if (prevItem?.depth === 1) newGroupIndex = prevItem.groupIndex;
|
|
84
|
-
else if (nextItem?.depth === 1) newGroupIndex = nextItem.groupIndex;
|
|
85
|
-
}
|
|
86
|
-
reordered[overIndex] = {
|
|
87
|
-
...movedItem,
|
|
88
|
-
depth: projectedDepth,
|
|
89
|
-
groupIndex: newGroupIndex
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
return buildTaskGroups(reordered);
|
|
93
|
-
}
|
|
94
|
-
function getDragDepth(offsetLeft) {
|
|
95
|
-
return Math.round(offsetLeft / external_StageNode_styles_cjs_namespaceObject.INDENTATION_WIDTH);
|
|
96
|
-
}
|
|
97
|
-
function getParallelGroupInfo(tasks, groupIndex, taskIndex) {
|
|
98
|
-
const group = tasks[groupIndex];
|
|
99
|
-
if (!group || group.length <= 1) return {
|
|
100
|
-
isParallel: false,
|
|
101
|
-
isFirstItem: false,
|
|
102
|
-
isLastItem: false
|
|
103
|
-
};
|
|
104
|
-
return {
|
|
105
|
-
isParallel: true,
|
|
106
|
-
isFirstItem: 0 === taskIndex,
|
|
107
|
-
isLastItem: taskIndex === group.length - 1
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
function getProjection(tasks, activeId, overId, offsetLeft) {
|
|
111
|
-
const flattened = flattenTasks(tasks);
|
|
112
|
-
const activeIndex = flattened.findIndex((t)=>t.id === activeId);
|
|
113
|
-
const overIndex = flattened.findIndex((t)=>t.id === overId);
|
|
114
|
-
if (-1 === activeIndex || -1 === overIndex) return null;
|
|
115
|
-
const activeTask = flattened[activeIndex];
|
|
116
|
-
const overTask = flattened[overIndex];
|
|
117
|
-
if (!activeTask || !overTask) return null;
|
|
118
|
-
const overInfo = getParallelGroupInfo(tasks, overTask.groupIndex, overTask.taskIndex);
|
|
119
|
-
const minDepth = 0;
|
|
120
|
-
const maxDepth = 1;
|
|
121
|
-
let depth = 0;
|
|
122
|
-
const isActiveParallel = 1 === activeTask.depth;
|
|
123
|
-
const dragDepth = isActiveParallel ? offsetLeft > 0 ? 1 : 0 : getDragDepth(offsetLeft);
|
|
124
|
-
const isDraggingDown = activeIndex < overIndex;
|
|
125
|
-
const isDraggingUp = activeIndex > overIndex;
|
|
126
|
-
const isDraggingInPlace = activeIndex === overIndex;
|
|
127
|
-
if (isDraggingInPlace) if (overInfo.isParallel) {
|
|
128
|
-
const isOnBorder = overInfo.isFirstItem || overInfo.isLastItem;
|
|
129
|
-
depth = isOnBorder ? Math.max(minDepth, Math.min(maxDepth, dragDepth)) : maxDepth;
|
|
130
|
-
} else {
|
|
131
|
-
const nextTask = flattened[overIndex + 1];
|
|
132
|
-
const prevTask = flattened[overIndex - 1];
|
|
133
|
-
const isAdjacentToParallel = nextTask?.depth === 1 || prevTask?.depth === 1;
|
|
134
|
-
if (isAdjacentToParallel) depth = Math.max(minDepth, Math.min(maxDepth, dragDepth));
|
|
135
|
-
}
|
|
136
|
-
else if (overInfo.isParallel) {
|
|
137
|
-
const isEdgeInsertion = isDraggingUp && overInfo.isFirstItem || isDraggingDown && overInfo.isLastItem;
|
|
138
|
-
depth = isEdgeInsertion ? Math.max(minDepth, Math.min(maxDepth, dragDepth)) : maxDepth;
|
|
139
|
-
} else {
|
|
140
|
-
const nextTask = flattened[overIndex + 1];
|
|
141
|
-
const prevTask = flattened[overIndex - 1];
|
|
142
|
-
const isAdjacentToParallel = isDraggingDown && nextTask?.depth === 1 || isDraggingUp && prevTask?.depth === 1;
|
|
143
|
-
if (isAdjacentToParallel) depth = Math.max(minDepth, Math.min(maxDepth, dragDepth));
|
|
144
|
-
}
|
|
145
|
-
return {
|
|
146
|
-
depth,
|
|
147
|
-
maxDepth,
|
|
148
|
-
groupIndex: overTask.groupIndex,
|
|
149
|
-
taskIndex: overTask.taskIndex
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
exports.buildTaskGroups = __webpack_exports__.buildTaskGroups;
|
|
153
|
-
exports.flattenTasks = __webpack_exports__.flattenTasks;
|
|
154
|
-
exports.getProjection = __webpack_exports__.getProjection;
|
|
155
|
-
exports.reorderTasks = __webpack_exports__.reorderTasks;
|
|
156
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
157
|
-
"buildTaskGroups",
|
|
158
|
-
"flattenTasks",
|
|
159
|
-
"getProjection",
|
|
160
|
-
"reorderTasks"
|
|
161
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
162
|
-
Object.defineProperty(exports, '__esModule', {
|
|
163
|
-
value: true
|
|
164
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { StageTaskItem } from './StageNode.types';
|
|
2
|
-
export interface FlattenedTask {
|
|
3
|
-
id: string;
|
|
4
|
-
task: StageTaskItem;
|
|
5
|
-
groupIndex: number;
|
|
6
|
-
taskIndex: number;
|
|
7
|
-
depth: number;
|
|
8
|
-
}
|
|
9
|
-
export interface ProjectionResult {
|
|
10
|
-
depth: number;
|
|
11
|
-
maxDepth: number;
|
|
12
|
-
groupIndex: number;
|
|
13
|
-
taskIndex: number;
|
|
14
|
-
}
|
|
15
|
-
export declare function flattenTasks(tasks: StageTaskItem[][]): FlattenedTask[];
|
|
16
|
-
export declare function buildTaskGroups(flattenedTasks: FlattenedTask[]): StageTaskItem[][];
|
|
17
|
-
export declare function reorderTasks(tasks: StageTaskItem[][], activeId: string, overId: string, projectedDepth: number): StageTaskItem[][];
|
|
18
|
-
export declare function getProjection(tasks: StageTaskItem[][], activeId: string, overId: string, offsetLeft: number): ProjectionResult | null;
|
|
19
|
-
//# sourceMappingURL=StageNode.utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StageNode.utils.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StageNode/StageNode.utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,aAAa,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,GAAG,aAAa,EAAE,CAoBtE;AAED,wBAAgB,eAAe,CAAC,cAAc,EAAE,aAAa,EAAE,GAAG,aAAa,EAAE,EAAE,CA0BlF;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,aAAa,EAAE,EAAE,EACxB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,GACrB,aAAa,EAAE,EAAE,CAkCnB;AAsBD,wBAAgB,aAAa,CAC3B,KAAK,EAAE,aAAa,EAAE,EAAE,EACxB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,GACjB,gBAAgB,GAAG,IAAI,CAwEzB"}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { arrayMove } from "@dnd-kit/sortable";
|
|
2
|
-
import { INDENTATION_WIDTH } from "./StageNode.styles.js";
|
|
3
|
-
function flattenTasks(tasks) {
|
|
4
|
-
const flattened = [];
|
|
5
|
-
for (const [groupIndex, group] of tasks.entries()){
|
|
6
|
-
if (!group) continue;
|
|
7
|
-
const depth = group.length > 1 ? 1 : 0;
|
|
8
|
-
for (const [taskIndex, task] of group.entries())if (task) flattened.push({
|
|
9
|
-
id: task.id,
|
|
10
|
-
task,
|
|
11
|
-
groupIndex,
|
|
12
|
-
taskIndex,
|
|
13
|
-
depth
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return flattened;
|
|
17
|
-
}
|
|
18
|
-
function buildTaskGroups(flattenedTasks) {
|
|
19
|
-
const groups = [];
|
|
20
|
-
let currentGroup = [];
|
|
21
|
-
let previousDepth = null;
|
|
22
|
-
let previousGroupIndex = null;
|
|
23
|
-
for (const item of flattenedTasks){
|
|
24
|
-
if (null === previousDepth) currentGroup.push(item.task);
|
|
25
|
-
else if (1 === item.depth && 1 === previousDepth && item.groupIndex === previousGroupIndex) currentGroup.push(item.task);
|
|
26
|
-
else {
|
|
27
|
-
if (currentGroup.length > 0) groups.push(currentGroup);
|
|
28
|
-
currentGroup = [
|
|
29
|
-
item.task
|
|
30
|
-
];
|
|
31
|
-
}
|
|
32
|
-
previousDepth = item.depth;
|
|
33
|
-
previousGroupIndex = item.groupIndex;
|
|
34
|
-
}
|
|
35
|
-
if (currentGroup.length > 0) groups.push(currentGroup);
|
|
36
|
-
return groups;
|
|
37
|
-
}
|
|
38
|
-
function reorderTasks(tasks, activeId, overId, projectedDepth) {
|
|
39
|
-
const flattened = flattenTasks(tasks);
|
|
40
|
-
const activeIndex = flattened.findIndex((t)=>t.id === activeId);
|
|
41
|
-
const overIndex = flattened.findIndex((t)=>t.id === overId);
|
|
42
|
-
if (-1 === activeIndex || -1 === overIndex) return tasks;
|
|
43
|
-
const activeTask = flattened[activeIndex];
|
|
44
|
-
if (!activeTask) return tasks;
|
|
45
|
-
const reordered = arrayMove(flattened, activeIndex, overIndex);
|
|
46
|
-
const movedItem = reordered[overIndex];
|
|
47
|
-
if (movedItem) {
|
|
48
|
-
let newGroupIndex = movedItem.groupIndex;
|
|
49
|
-
if (1 === projectedDepth) {
|
|
50
|
-
const prevItem = reordered[overIndex - 1];
|
|
51
|
-
const nextItem = reordered[overIndex + 1];
|
|
52
|
-
if (prevItem?.depth === 1) newGroupIndex = prevItem.groupIndex;
|
|
53
|
-
else if (nextItem?.depth === 1) newGroupIndex = nextItem.groupIndex;
|
|
54
|
-
}
|
|
55
|
-
reordered[overIndex] = {
|
|
56
|
-
...movedItem,
|
|
57
|
-
depth: projectedDepth,
|
|
58
|
-
groupIndex: newGroupIndex
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
return buildTaskGroups(reordered);
|
|
62
|
-
}
|
|
63
|
-
function getDragDepth(offsetLeft) {
|
|
64
|
-
return Math.round(offsetLeft / INDENTATION_WIDTH);
|
|
65
|
-
}
|
|
66
|
-
function getParallelGroupInfo(tasks, groupIndex, taskIndex) {
|
|
67
|
-
const group = tasks[groupIndex];
|
|
68
|
-
if (!group || group.length <= 1) return {
|
|
69
|
-
isParallel: false,
|
|
70
|
-
isFirstItem: false,
|
|
71
|
-
isLastItem: false
|
|
72
|
-
};
|
|
73
|
-
return {
|
|
74
|
-
isParallel: true,
|
|
75
|
-
isFirstItem: 0 === taskIndex,
|
|
76
|
-
isLastItem: taskIndex === group.length - 1
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
function getProjection(tasks, activeId, overId, offsetLeft) {
|
|
80
|
-
const flattened = flattenTasks(tasks);
|
|
81
|
-
const activeIndex = flattened.findIndex((t)=>t.id === activeId);
|
|
82
|
-
const overIndex = flattened.findIndex((t)=>t.id === overId);
|
|
83
|
-
if (-1 === activeIndex || -1 === overIndex) return null;
|
|
84
|
-
const activeTask = flattened[activeIndex];
|
|
85
|
-
const overTask = flattened[overIndex];
|
|
86
|
-
if (!activeTask || !overTask) return null;
|
|
87
|
-
const overInfo = getParallelGroupInfo(tasks, overTask.groupIndex, overTask.taskIndex);
|
|
88
|
-
const minDepth = 0;
|
|
89
|
-
const maxDepth = 1;
|
|
90
|
-
let depth = 0;
|
|
91
|
-
const isActiveParallel = 1 === activeTask.depth;
|
|
92
|
-
const dragDepth = isActiveParallel ? offsetLeft > 0 ? 1 : 0 : getDragDepth(offsetLeft);
|
|
93
|
-
const isDraggingDown = activeIndex < overIndex;
|
|
94
|
-
const isDraggingUp = activeIndex > overIndex;
|
|
95
|
-
const isDraggingInPlace = activeIndex === overIndex;
|
|
96
|
-
if (isDraggingInPlace) if (overInfo.isParallel) {
|
|
97
|
-
const isOnBorder = overInfo.isFirstItem || overInfo.isLastItem;
|
|
98
|
-
depth = isOnBorder ? Math.max(minDepth, Math.min(maxDepth, dragDepth)) : maxDepth;
|
|
99
|
-
} else {
|
|
100
|
-
const nextTask = flattened[overIndex + 1];
|
|
101
|
-
const prevTask = flattened[overIndex - 1];
|
|
102
|
-
const isAdjacentToParallel = nextTask?.depth === 1 || prevTask?.depth === 1;
|
|
103
|
-
if (isAdjacentToParallel) depth = Math.max(minDepth, Math.min(maxDepth, dragDepth));
|
|
104
|
-
}
|
|
105
|
-
else if (overInfo.isParallel) {
|
|
106
|
-
const isEdgeInsertion = isDraggingUp && overInfo.isFirstItem || isDraggingDown && overInfo.isLastItem;
|
|
107
|
-
depth = isEdgeInsertion ? Math.max(minDepth, Math.min(maxDepth, dragDepth)) : maxDepth;
|
|
108
|
-
} else {
|
|
109
|
-
const nextTask = flattened[overIndex + 1];
|
|
110
|
-
const prevTask = flattened[overIndex - 1];
|
|
111
|
-
const isAdjacentToParallel = isDraggingDown && nextTask?.depth === 1 || isDraggingUp && prevTask?.depth === 1;
|
|
112
|
-
if (isAdjacentToParallel) depth = Math.max(minDepth, Math.min(maxDepth, dragDepth));
|
|
113
|
-
}
|
|
114
|
-
return {
|
|
115
|
-
depth,
|
|
116
|
-
maxDepth,
|
|
117
|
-
groupIndex: overTask.groupIndex,
|
|
118
|
-
taskIndex: overTask.taskIndex
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
export { buildTaskGroups, flattenTasks, getProjection, reorderTasks };
|
/package/dist/canvas/components/{StageNode/DraggableTask.types.cjs → TaskNode/TaskNode.types.cjs}
RENAMED
|
File without changes
|
/package/dist/canvas/components/{StageNode/DraggableTask.types.js → TaskNode/TaskNode.types.js}
RENAMED
|
File without changes
|