gantt-lib 0.9.0 → 0.10.0
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 +20 -79
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -79
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3969,43 +3969,8 @@ var GanttChart = (0, import_react13.forwardRef)(({
|
|
|
3969
3969
|
return;
|
|
3970
3970
|
}
|
|
3971
3971
|
const cascadedTasks = disableConstraints ? [updatedTask] : [updatedTask, ...cascadeByLinks(updatedTask.id, newStart, newEnd, tasks)];
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
} else {
|
|
3975
|
-
const changedTasks = new Map(cascadedTasks.map((t) => [t.id, t]));
|
|
3976
|
-
const parentIdsToUpdate = /* @__PURE__ */ new Set();
|
|
3977
|
-
cascadedTasks.forEach((task) => {
|
|
3978
|
-
if (task.parentId) {
|
|
3979
|
-
parentIdsToUpdate.add(task.parentId);
|
|
3980
|
-
}
|
|
3981
|
-
});
|
|
3982
|
-
const additionalParentUpdates = [];
|
|
3983
|
-
parentIdsToUpdate.forEach((parentId) => {
|
|
3984
|
-
if (parentId === updatedTask.id) {
|
|
3985
|
-
const parentTask2 = tasks.find((t) => t.id === parentId);
|
|
3986
|
-
if (parentTask2) {
|
|
3987
|
-
const newProgress = computeParentProgress(parentId, tasks.map((t) => changedTasks.get(t.id) ?? t));
|
|
3988
|
-
additionalParentUpdates.push({ ...parentTask2, progress: newProgress });
|
|
3989
|
-
}
|
|
3990
|
-
return;
|
|
3991
|
-
}
|
|
3992
|
-
const parentTask = tasks.find((t) => t.id === parentId);
|
|
3993
|
-
if (parentTask) {
|
|
3994
|
-
const tempTasks = tasks.map((t) => changedTasks.get(t.id) ?? t);
|
|
3995
|
-
const newDates = computeParentDates(parentId, tempTasks);
|
|
3996
|
-
const newProgress = computeParentProgress(parentId, tempTasks);
|
|
3997
|
-
additionalParentUpdates.push({
|
|
3998
|
-
...parentTask,
|
|
3999
|
-
startDate: newDates.startDate.toISOString().split("T")[0],
|
|
4000
|
-
endDate: newDates.endDate.toISOString().split("T")[0],
|
|
4001
|
-
progress: newProgress
|
|
4002
|
-
});
|
|
4003
|
-
}
|
|
4004
|
-
});
|
|
4005
|
-
onTasksChange?.([...cascadedTasks, ...additionalParentUpdates]);
|
|
4006
|
-
onCascade?.(cascadedTasks);
|
|
4007
|
-
}
|
|
4008
|
-
}, [tasks, onTasksChange, disableConstraints, onCascade, editingTaskId]);
|
|
3972
|
+
onTasksChange?.(cascadedTasks);
|
|
3973
|
+
}, [tasks, onTasksChange, disableConstraints, editingTaskId]);
|
|
4009
3974
|
const handleDelete = (0, import_react13.useCallback)((taskId) => {
|
|
4010
3975
|
const toDelete = /* @__PURE__ */ new Set([taskId]);
|
|
4011
3976
|
function collectDescendants(parentId) {
|
|
@@ -4114,36 +4079,8 @@ var GanttChart = (0, import_react13.forwardRef)(({
|
|
|
4114
4079
|
setCascadeOverrides(new Map(overrides));
|
|
4115
4080
|
}, []);
|
|
4116
4081
|
const handleCascade = (0, import_react13.useCallback)((cascadedTasks) => {
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
const parentIdsToUpdate = /* @__PURE__ */ new Set();
|
|
4120
|
-
cascadedTasks.forEach((task) => {
|
|
4121
|
-
if (task.parentId) {
|
|
4122
|
-
parentIdsToUpdate.add(task.parentId);
|
|
4123
|
-
}
|
|
4124
|
-
});
|
|
4125
|
-
const additionalParentUpdates = [];
|
|
4126
|
-
parentIdsToUpdate.forEach((parentId) => {
|
|
4127
|
-
const parentTask = tasks.find((t) => t.id === parentId);
|
|
4128
|
-
if (!parentTask) return;
|
|
4129
|
-
const tempTasks = tasks.map((t) => cascadeMap.get(t.id) ?? t);
|
|
4130
|
-
if (parentId === draggedTaskId) {
|
|
4131
|
-
const newProgress2 = computeParentProgress(parentId, tempTasks);
|
|
4132
|
-
additionalParentUpdates.push({ ...parentTask, progress: newProgress2 });
|
|
4133
|
-
return;
|
|
4134
|
-
}
|
|
4135
|
-
const newDates = computeParentDates(parentId, tempTasks);
|
|
4136
|
-
const newProgress = computeParentProgress(parentId, tempTasks);
|
|
4137
|
-
additionalParentUpdates.push({
|
|
4138
|
-
...parentTask,
|
|
4139
|
-
startDate: newDates.startDate.toISOString().split("T")[0],
|
|
4140
|
-
endDate: newDates.endDate.toISOString().split("T")[0],
|
|
4141
|
-
progress: newProgress
|
|
4142
|
-
});
|
|
4143
|
-
});
|
|
4144
|
-
onTasksChange?.([...cascadedTasks, ...additionalParentUpdates]);
|
|
4145
|
-
onCascade?.(cascadedTasks);
|
|
4146
|
-
}, [tasks, onTasksChange, onCascade]);
|
|
4082
|
+
onTasksChange?.(cascadedTasks);
|
|
4083
|
+
}, [tasks, onTasksChange]);
|
|
4147
4084
|
const handleTaskSelect = (0, import_react13.useCallback)((taskId) => {
|
|
4148
4085
|
setSelectedTaskId(taskId);
|
|
4149
4086
|
}, []);
|
|
@@ -4211,19 +4148,23 @@ var GanttChart = (0, import_react13.forwardRef)(({
|
|
|
4211
4148
|
}
|
|
4212
4149
|
let updatedTasks = removeDependenciesBetweenTasks(taskId, newParentId, tasks);
|
|
4213
4150
|
const demotedTask = updatedTasks.find((t) => t.id === taskId);
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4151
|
+
if (!demotedTask) return;
|
|
4152
|
+
const wasParent = getChildren(taskId, tasks).length > 0;
|
|
4153
|
+
let taskDates = { startDate: demotedTask.startDate, endDate: demotedTask.endDate };
|
|
4154
|
+
if (wasParent) {
|
|
4155
|
+
const computedDates = computeParentDates(taskId, tasks);
|
|
4156
|
+
taskDates = {
|
|
4157
|
+
startDate: computedDates.startDate.toISOString().split("T")[0],
|
|
4158
|
+
endDate: computedDates.endDate.toISOString().split("T")[0]
|
|
4159
|
+
};
|
|
4160
|
+
}
|
|
4161
|
+
const updatedDemotedTask = {
|
|
4162
|
+
...demotedTask,
|
|
4163
|
+
parentId: newParentId,
|
|
4164
|
+
startDate: taskDates.startDate,
|
|
4165
|
+
endDate: taskDates.endDate
|
|
4225
4166
|
};
|
|
4226
|
-
onTasksChange?.([updatedDemotedTask
|
|
4167
|
+
onTasksChange?.([updatedDemotedTask]);
|
|
4227
4168
|
}, [tasks, onTasksChange, onDemoteTask]);
|
|
4228
4169
|
const panStateRef = (0, import_react13.useRef)(null);
|
|
4229
4170
|
const handlePanStart = (0, import_react13.useCallback)((e) => {
|