gantt-lib 0.135.5 → 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 +33 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3039,19 +3039,37 @@ function normalizeHierarchyTasks(tasks) {
|
|
|
3039
3039
|
const { startDate, endDate } = normalizeTaskDates(task.startDate, task.endDate);
|
|
3040
3040
|
return { ...task, startDate, endDate };
|
|
3041
3041
|
});
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
const
|
|
3045
|
-
|
|
3046
|
-
const
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3042
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
3043
|
+
for (let index = 0; index < orderedTasks.length; index++) {
|
|
3044
|
+
const parentId = orderedTasks[index].parentId;
|
|
3045
|
+
if (!parentId) continue;
|
|
3046
|
+
const children = childrenByParent.get(parentId) ?? [];
|
|
3047
|
+
children.push(index);
|
|
3048
|
+
childrenByParent.set(parentId, children);
|
|
3049
|
+
}
|
|
3050
|
+
const DAY_MS6 = 24 * 60 * 60 * 1e3;
|
|
3051
|
+
for (let index = orderedTasks.length - 1; index >= 0; index--) {
|
|
3052
|
+
const children = childrenByParent.get(orderedTasks[index].id);
|
|
3053
|
+
if (!children?.length) continue;
|
|
3054
|
+
let minStart = Infinity;
|
|
3055
|
+
let maxEnd = -Infinity;
|
|
3056
|
+
let totalWeight = 0;
|
|
3057
|
+
let weightedProgress = 0;
|
|
3058
|
+
for (const childIndex of children) {
|
|
3059
|
+
const child = orderedTasks[childIndex];
|
|
3060
|
+
const start = new Date(child.startDate).getTime();
|
|
3061
|
+
const end = new Date(child.endDate).getTime();
|
|
3062
|
+
minStart = Math.min(minStart, start);
|
|
3063
|
+
maxEnd = Math.max(maxEnd, end);
|
|
3064
|
+
const duration = (end - start + DAY_MS6) / DAY_MS6;
|
|
3065
|
+
totalWeight += duration;
|
|
3066
|
+
weightedProgress += duration * (child.progress ?? 0);
|
|
3067
|
+
}
|
|
3068
|
+
orderedTasks[index] = {
|
|
3069
|
+
...orderedTasks[index],
|
|
3070
|
+
startDate: new Date(minStart).toISOString().split("T")[0],
|
|
3071
|
+
endDate: new Date(maxEnd).toISOString().split("T")[0],
|
|
3072
|
+
progress: totalWeight === 0 ? 0 : Math.round(weightedProgress / totalWeight * 10) / 10
|
|
3055
3073
|
};
|
|
3056
3074
|
}
|
|
3057
3075
|
return orderedTasks;
|
|
@@ -15096,9 +15114,8 @@ function TaskGanttChartInner(props, ref) {
|
|
|
15096
15114
|
});
|
|
15097
15115
|
}, []);
|
|
15098
15116
|
const allParentIds = (0, import_react19.useMemo)(() => {
|
|
15099
|
-
|
|
15100
|
-
|
|
15101
|
-
);
|
|
15117
|
+
const taskIds = new Set(normalizedTasks.map((task) => task.id));
|
|
15118
|
+
return new Set(normalizedTasks.map((task) => task.parentId).filter((parentId) => Boolean(parentId && taskIds.has(parentId))));
|
|
15102
15119
|
}, [normalizedTasks]);
|
|
15103
15120
|
const handleCollapseAll = (0, import_react19.useCallback)(() => {
|
|
15104
15121
|
if (externalCollapsedParentIds) return;
|