gantt-lib 0.135.4 → 0.135.6
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/index.js +34 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2891,19 +2891,37 @@ function normalizeHierarchyTasks(tasks) {
|
|
|
2891
2891
|
const { startDate, endDate } = normalizeTaskDates(task.startDate, task.endDate);
|
|
2892
2892
|
return { ...task, startDate, endDate };
|
|
2893
2893
|
});
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
const
|
|
2897
|
-
|
|
2898
|
-
const
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2894
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
2895
|
+
for (let index = 0; index < orderedTasks.length; index++) {
|
|
2896
|
+
const parentId = orderedTasks[index].parentId;
|
|
2897
|
+
if (!parentId) continue;
|
|
2898
|
+
const children = childrenByParent.get(parentId) ?? [];
|
|
2899
|
+
children.push(index);
|
|
2900
|
+
childrenByParent.set(parentId, children);
|
|
2901
|
+
}
|
|
2902
|
+
const DAY_MS6 = 24 * 60 * 60 * 1e3;
|
|
2903
|
+
for (let index = orderedTasks.length - 1; index >= 0; index--) {
|
|
2904
|
+
const children = childrenByParent.get(orderedTasks[index].id);
|
|
2905
|
+
if (!children?.length) continue;
|
|
2906
|
+
let minStart = Infinity;
|
|
2907
|
+
let maxEnd = -Infinity;
|
|
2908
|
+
let totalWeight = 0;
|
|
2909
|
+
let weightedProgress = 0;
|
|
2910
|
+
for (const childIndex of children) {
|
|
2911
|
+
const child = orderedTasks[childIndex];
|
|
2912
|
+
const start = new Date(child.startDate).getTime();
|
|
2913
|
+
const end = new Date(child.endDate).getTime();
|
|
2914
|
+
minStart = Math.min(minStart, start);
|
|
2915
|
+
maxEnd = Math.max(maxEnd, end);
|
|
2916
|
+
const duration = (end - start + DAY_MS6) / DAY_MS6;
|
|
2917
|
+
totalWeight += duration;
|
|
2918
|
+
weightedProgress += duration * (child.progress ?? 0);
|
|
2919
|
+
}
|
|
2920
|
+
orderedTasks[index] = {
|
|
2921
|
+
...orderedTasks[index],
|
|
2922
|
+
startDate: new Date(minStart).toISOString().split("T")[0],
|
|
2923
|
+
endDate: new Date(maxEnd).toISOString().split("T")[0],
|
|
2924
|
+
progress: totalWeight === 0 ? 0 : Math.round(weightedProgress / totalWeight * 10) / 10
|
|
2907
2925
|
};
|
|
2908
2926
|
}
|
|
2909
2927
|
return orderedTasks;
|
|
@@ -14972,9 +14990,8 @@ function TaskGanttChartInner(props, ref) {
|
|
|
14972
14990
|
});
|
|
14973
14991
|
}, []);
|
|
14974
14992
|
const allParentIds = useMemo13(() => {
|
|
14975
|
-
|
|
14976
|
-
|
|
14977
|
-
);
|
|
14993
|
+
const taskIds = new Set(normalizedTasks.map((task) => task.id));
|
|
14994
|
+
return new Set(normalizedTasks.map((task) => task.parentId).filter((parentId) => Boolean(parentId && taskIds.has(parentId))));
|
|
14978
14995
|
}, [normalizedTasks]);
|
|
14979
14996
|
const handleCollapseAll = useCallback10(() => {
|
|
14980
14997
|
if (externalCollapsedParentIds) return;
|
|
@@ -15543,6 +15560,7 @@ function TaskGanttChartInner(props, ref) {
|
|
|
15543
15560
|
onTasksChange: handleTaskChange,
|
|
15544
15561
|
onDragStateChange: (state) => {
|
|
15545
15562
|
if (state.isDragging) {
|
|
15563
|
+
if (normalizedTasks.length >= 1e3) return;
|
|
15546
15564
|
setDragGuideLines((current) => current && current.isDragging === state.isDragging && current.dragMode === state.dragMode && current.left === state.left && current.width === state.width ? current : state);
|
|
15547
15565
|
setDraggedTaskOverride((current) => current && current.taskId === task.id && current.left === state.left && current.width === state.width ? current : { taskId: task.id, left: state.left, width: state.width });
|
|
15548
15566
|
} else {
|