gantt-lib 0.125.0 → 0.127.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.
@@ -1,2 +1,2 @@
1
- export { aa as CascadeContext, C as CriticalPathOptions, D as DAY_MS, e as DependencyError, L as LinkType, ab as ScheduleCommandOptions, ac as ScheduleCommandResult, ad as ScheduleDependency, ae as ScheduleTask, af as ScheduleTaskUpdate, T as Task, ag as TaskDependency, V as ValidationResult, ah as addBusinessDays, n as alignToWorkingDay, o as areTasksHierarchicallyRelated, p as buildAdjacencyList, q as buildTaskRangeFromEnd, r as buildTaskRangeFromStart, s as calculateSuccessorDate, t as cascadeByLinks, u as clampTaskRangeForIncomingFS, v as computeCriticalPath, w as computeLagFromDates, x as computeParentDates, y as computeParentProgress, ai as createCascadeContext, z as detectCycles, A as extendCriticalIdsToParents, E as findParentId, F as getAllDependencyEdges, H as getAllDescendants, I as getBusinessDayOffset, aj as getBusinessDaysCount, J as getChildren, K as getDependencyLag, N as getSuccessorChain, O as getTaskDuration, P as getTransitiveCascadeChain, Q as isAncestorTask, S as isTaskParent, U as moveTaskRange, X as moveTaskWithCascade, Y as normalizeDependencyLag, Z as normalizePredecessorDates, _ as normalizeTaskDependencyLags, $ as normalizeUTCDate, a0 as parseDateOnly, a1 as recalculateIncomingLags, a2 as recalculateProjectSchedule, a3 as recalculateTaskFromDependencies, a4 as reflowTasksOnModeSwitch, a5 as removeDependenciesBetweenTasks, a6 as resizeTaskWithCascade, a7 as shiftBusinessDayOffset, ak as subtractBusinessDays, a8 as universalCascade, a9 as validateDependencies } from '../../index-DD3YvhvA.mjs';
1
+ export { aa as CascadeContext, C as CriticalPathOptions, D as DAY_MS, e as DependencyError, L as LinkType, ab as ScheduleCommandOptions, ac as ScheduleCommandResult, ad as ScheduleDependency, ae as ScheduleTask, af as ScheduleTaskUpdate, T as Task, ag as TaskDependency, V as ValidationResult, ah as addBusinessDays, n as alignToWorkingDay, o as areTasksHierarchicallyRelated, p as buildAdjacencyList, q as buildTaskRangeFromEnd, r as buildTaskRangeFromStart, s as calculateSuccessorDate, t as cascadeByLinks, ai as cascadeTaskProgress, u as clampTaskRangeForIncomingFS, v as computeCriticalPath, w as computeLagFromDates, x as computeParentDates, y as computeParentProgress, aj as createCascadeContext, z as detectCycles, A as extendCriticalIdsToParents, E as findParentId, F as getAllDependencyEdges, H as getAllDescendants, I as getBusinessDayOffset, ak as getBusinessDaysCount, J as getChildren, K as getDependencyLag, N as getSuccessorChain, O as getTaskDuration, P as getTransitiveCascadeChain, Q as isAncestorTask, S as isTaskParent, U as moveTaskRange, X as moveTaskWithCascade, Y as normalizeDependencyLag, Z as normalizePredecessorDates, _ as normalizeTaskDependencyLags, $ as normalizeUTCDate, a0 as parseDateOnly, a1 as recalculateIncomingLags, a2 as recalculateProjectSchedule, a3 as recalculateTaskFromDependencies, a4 as reflowTasksOnModeSwitch, a5 as removeDependenciesBetweenTasks, a6 as resizeTaskWithCascade, a7 as shiftBusinessDayOffset, al as subtractBusinessDays, a8 as universalCascade, a9 as validateDependencies } from '../../index-B1YUnlWS.mjs';
2
2
  import 'react';
@@ -1,2 +1,2 @@
1
- export { aa as CascadeContext, C as CriticalPathOptions, D as DAY_MS, e as DependencyError, L as LinkType, ab as ScheduleCommandOptions, ac as ScheduleCommandResult, ad as ScheduleDependency, ae as ScheduleTask, af as ScheduleTaskUpdate, T as Task, ag as TaskDependency, V as ValidationResult, ah as addBusinessDays, n as alignToWorkingDay, o as areTasksHierarchicallyRelated, p as buildAdjacencyList, q as buildTaskRangeFromEnd, r as buildTaskRangeFromStart, s as calculateSuccessorDate, t as cascadeByLinks, u as clampTaskRangeForIncomingFS, v as computeCriticalPath, w as computeLagFromDates, x as computeParentDates, y as computeParentProgress, ai as createCascadeContext, z as detectCycles, A as extendCriticalIdsToParents, E as findParentId, F as getAllDependencyEdges, H as getAllDescendants, I as getBusinessDayOffset, aj as getBusinessDaysCount, J as getChildren, K as getDependencyLag, N as getSuccessorChain, O as getTaskDuration, P as getTransitiveCascadeChain, Q as isAncestorTask, S as isTaskParent, U as moveTaskRange, X as moveTaskWithCascade, Y as normalizeDependencyLag, Z as normalizePredecessorDates, _ as normalizeTaskDependencyLags, $ as normalizeUTCDate, a0 as parseDateOnly, a1 as recalculateIncomingLags, a2 as recalculateProjectSchedule, a3 as recalculateTaskFromDependencies, a4 as reflowTasksOnModeSwitch, a5 as removeDependenciesBetweenTasks, a6 as resizeTaskWithCascade, a7 as shiftBusinessDayOffset, ak as subtractBusinessDays, a8 as universalCascade, a9 as validateDependencies } from '../../index-DD3YvhvA.js';
1
+ export { aa as CascadeContext, C as CriticalPathOptions, D as DAY_MS, e as DependencyError, L as LinkType, ab as ScheduleCommandOptions, ac as ScheduleCommandResult, ad as ScheduleDependency, ae as ScheduleTask, af as ScheduleTaskUpdate, T as Task, ag as TaskDependency, V as ValidationResult, ah as addBusinessDays, n as alignToWorkingDay, o as areTasksHierarchicallyRelated, p as buildAdjacencyList, q as buildTaskRangeFromEnd, r as buildTaskRangeFromStart, s as calculateSuccessorDate, t as cascadeByLinks, ai as cascadeTaskProgress, u as clampTaskRangeForIncomingFS, v as computeCriticalPath, w as computeLagFromDates, x as computeParentDates, y as computeParentProgress, aj as createCascadeContext, z as detectCycles, A as extendCriticalIdsToParents, E as findParentId, F as getAllDependencyEdges, H as getAllDescendants, I as getBusinessDayOffset, ak as getBusinessDaysCount, J as getChildren, K as getDependencyLag, N as getSuccessorChain, O as getTaskDuration, P as getTransitiveCascadeChain, Q as isAncestorTask, S as isTaskParent, U as moveTaskRange, X as moveTaskWithCascade, Y as normalizeDependencyLag, Z as normalizePredecessorDates, _ as normalizeTaskDependencyLags, $ as normalizeUTCDate, a0 as parseDateOnly, a1 as recalculateIncomingLags, a2 as recalculateProjectSchedule, a3 as recalculateTaskFromDependencies, a4 as reflowTasksOnModeSwitch, a5 as removeDependenciesBetweenTasks, a6 as resizeTaskWithCascade, a7 as shiftBusinessDayOffset, al as subtractBusinessDays, a8 as universalCascade, a9 as validateDependencies } from '../../index-B1YUnlWS.js';
2
2
  import 'react';
@@ -29,6 +29,7 @@ __export(scheduling_exports, {
29
29
  buildTaskRangeFromStart: () => buildTaskRangeFromStart,
30
30
  calculateSuccessorDate: () => calculateSuccessorDate,
31
31
  cascadeByLinks: () => cascadeByLinks,
32
+ cascadeTaskProgress: () => cascadeTaskProgress,
32
33
  clampTaskRangeForIncomingFS: () => clampTaskRangeForIncomingFS,
33
34
  computeCriticalPath: () => computeCriticalPath,
34
35
  computeLagFromDates: () => computeLagFromDates,
@@ -172,8 +173,7 @@ function getTaskDuration(startDate, endDate, businessDays = false, weekendPredic
172
173
  // src/core/scheduling/dependencies.ts
173
174
  function normalizePredecessorDates(predecessor, parseDateFn) {
174
175
  const predStart = parseDateFn(predecessor.startDate);
175
- const isMilestone = predecessor.type === "milestone";
176
- const predEnd = isMilestone ? new Date(predStart.getTime() - DAY_MS) : parseDateFn(predecessor.endDate);
176
+ const predEnd = predecessor.type === "milestone" ? predStart : parseDateFn(predecessor.endDate);
177
177
  return { predStart, predEnd };
178
178
  }
179
179
  function getDependencyLag(dep) {
@@ -182,7 +182,7 @@ function getDependencyLag(dep) {
182
182
  function normalizeTaskDependencyLags(task) {
183
183
  return task;
184
184
  }
185
- function normalizeDependencyLag(linkType, lag, predecessorStart, predecessorEnd, businessDays = false, weekendPredicate) {
185
+ function normalizeDependencyLag(linkType, lag, predecessorStart, predecessorEnd, businessDays = false, weekendPredicate, successorType) {
186
186
  if (linkType !== "FS") {
187
187
  return lag;
188
188
  }
@@ -192,9 +192,10 @@ function normalizeDependencyLag(linkType, lag, predecessorStart, predecessorEnd,
192
192
  businessDays,
193
193
  weekendPredicate
194
194
  );
195
- return Math.max(-predecessorDuration, lag);
195
+ const minimumLag = successorType === "milestone" ? -Math.max(0, predecessorDuration - 1) : -predecessorDuration;
196
+ return Math.max(minimumLag, lag);
196
197
  }
197
- function computeLagFromDates(linkType, predStart, predEnd, succStart, succEnd, businessDays = false, weekendPredicate) {
198
+ function computeLagFromDates(linkType, predStart, predEnd, succStart, succEnd, businessDays = false, weekendPredicate, successorType) {
198
199
  const pS = Date.UTC(predStart.getUTCFullYear(), predStart.getUTCMonth(), predStart.getUTCDate());
199
200
  const pE = Date.UTC(predEnd.getUTCFullYear(), predEnd.getUTCMonth(), predEnd.getUTCDate());
200
201
  const sS = Date.UTC(succStart.getUTCFullYear(), succStart.getUTCMonth(), succStart.getUTCDate());
@@ -204,11 +205,12 @@ function computeLagFromDates(linkType, predStart, predEnd, succStart, succEnd, b
204
205
  case "FS":
205
206
  return normalizeDependencyLag(
206
207
  linkType,
207
- Math.round((sS - pE) / DAY_MS) - 1,
208
+ Math.round((sS - pE) / DAY_MS) - (successorType === "milestone" ? 0 : 1),
208
209
  predStart,
209
210
  predEnd,
210
211
  businessDays,
211
- weekendPredicate
212
+ weekendPredicate,
213
+ successorType
212
214
  );
213
215
  case "SS":
214
216
  return Math.round((sS - pS) / DAY_MS);
@@ -225,11 +227,12 @@ function computeLagFromDates(linkType, predStart, predEnd, succStart, succEnd, b
225
227
  case "FS":
226
228
  return normalizeDependencyLag(
227
229
  linkType,
228
- businessOffset - 1,
230
+ businessOffset - (successorType === "milestone" ? 0 : 1),
229
231
  predStart,
230
232
  predEnd,
231
233
  businessDays,
232
- weekendPredicate
234
+ weekendPredicate,
235
+ successorType
233
236
  );
234
237
  case "SS":
235
238
  return businessOffset;
@@ -239,19 +242,20 @@ function computeLagFromDates(linkType, predStart, predEnd, succStart, succEnd, b
239
242
  return businessOffset + 1;
240
243
  }
241
244
  }
242
- function calculateSuccessorDate(predecessorStart, predecessorEnd, linkType, lag = 0, businessDays = false, weekendPredicate) {
245
+ function calculateSuccessorDate(predecessorStart, predecessorEnd, linkType, lag = 0, businessDays = false, weekendPredicate, successorType) {
243
246
  const normalizedLag = normalizeDependencyLag(
244
247
  linkType,
245
248
  lag,
246
249
  predecessorStart,
247
250
  predecessorEnd,
248
251
  businessDays,
249
- weekendPredicate
252
+ weekendPredicate,
253
+ successorType
250
254
  );
251
255
  if (!businessDays || !weekendPredicate) {
252
256
  switch (linkType) {
253
257
  case "FS":
254
- return new Date(predecessorEnd.getTime() + (normalizedLag + 1) * DAY_MS);
258
+ return new Date(predecessorEnd.getTime() + (normalizedLag + (successorType === "milestone" ? 0 : 1)) * DAY_MS);
255
259
  case "SS":
256
260
  return new Date(predecessorStart.getTime() + normalizedLag * DAY_MS);
257
261
  case "FF":
@@ -264,7 +268,7 @@ function calculateSuccessorDate(predecessorStart, predecessorEnd, linkType, lag
264
268
  let offset;
265
269
  switch (linkType) {
266
270
  case "FS":
267
- offset = normalizedLag + 1;
271
+ offset = normalizedLag + (successorType === "milestone" ? 0 : 1);
268
272
  break;
269
273
  case "SS":
270
274
  offset = normalizedLag;
@@ -496,7 +500,8 @@ function clampTaskRangeForIncomingFS(task, proposedStart, proposedEnd, allTasks,
496
500
  "FS",
497
501
  -predecessorDuration,
498
502
  businessDays,
499
- weekendPredicate
503
+ weekendPredicate,
504
+ task.type
500
505
  );
501
506
  if (!minAllowedStart || candidateMinStart.getTime() > minAllowedStart.getTime()) {
502
507
  minAllowedStart = candidateMinStart;
@@ -530,7 +535,8 @@ function recalculateIncomingLags(task, newStartDate, newEndDate, allTasks, busin
530
535
  newStartDate,
531
536
  newEndDate,
532
537
  businessDays,
533
- weekendPredicate
538
+ weekendPredicate,
539
+ task.type
534
540
  );
535
541
  return { ...dep, lag: nextLag };
536
542
  });
@@ -645,7 +651,10 @@ function cascadeByLinks(movedTaskId, newStart, newEnd, allTasks, skipChildCascad
645
651
  normalizedPredStart,
646
652
  normalizedPredEnd,
647
653
  dep.type,
648
- getDependencyLag(dep)
654
+ getDependencyLag(dep),
655
+ false,
656
+ void 0,
657
+ task.type
649
658
  );
650
659
  let newSuccStart;
651
660
  let newSuccEnd;
@@ -807,7 +816,8 @@ function universalCascade(movedTask, newStart, newEnd, allTasks, businessDays =
807
816
  dep.type,
808
817
  getDependencyLag(dep),
809
818
  businessDays,
810
- weekendPredicate
819
+ weekendPredicate,
820
+ task.type
811
821
  );
812
822
  let succNewStart;
813
823
  let succNewEnd;
@@ -903,6 +913,20 @@ function getAllDescendants(parentId, tasks) {
903
913
  collectChildren(parentId);
904
914
  return descendants;
905
915
  }
916
+ function cascadeTaskProgress(task, tasks) {
917
+ const progress = task.progress;
918
+ if (progress !== 0 && progress !== 100) {
919
+ return [task];
920
+ }
921
+ const descendants = getAllDescendants(task.id, tasks);
922
+ if (descendants.length === 0) {
923
+ return [task];
924
+ }
925
+ return [
926
+ { ...task, progress },
927
+ ...descendants.map((descendant) => ({ ...descendant, progress }))
928
+ ];
929
+ }
906
930
  function getAllDependencyEdges(tasks) {
907
931
  const edges = [];
908
932
  for (const task of tasks) {
@@ -1107,7 +1131,8 @@ function recalculateTaskFromDependencies(taskId, snapshot, options) {
1107
1131
  dep.type,
1108
1132
  getDependencyLag(dep),
1109
1133
  businessDays,
1110
- weekendPredicate
1134
+ weekendPredicate,
1135
+ task.type
1111
1136
  );
1112
1137
  const duration = getTaskDuration(
1113
1138
  parseDateOnly(task.startDate),
@@ -1223,7 +1248,8 @@ function recalculateProjectSchedule(snapshot, options) {
1223
1248
  dep.type,
1224
1249
  getDependencyLag(dep),
1225
1250
  businessDays,
1226
- weekendPredicate
1251
+ weekendPredicate,
1252
+ currentTask.type
1227
1253
  );
1228
1254
  const candidateRange = dep.type === "FS" || dep.type === "SS" ? buildTaskRangeFromStart(constraintDate, duration, businessDays, weekendPredicate) : buildTaskRangeFromEnd(constraintDate, duration, businessDays, weekendPredicate);
1229
1255
  if (!constrainedRange || candidateRange.start.getTime() > constrainedRange.start.getTime() || candidateRange.start.getTime() === constrainedRange.start.getTime() && candidateRange.end.getTime() > constrainedRange.end.getTime()) {
@@ -1414,6 +1440,7 @@ function validateDependencies(tasks) {
1414
1440
  buildTaskRangeFromStart,
1415
1441
  calculateSuccessorDate,
1416
1442
  cascadeByLinks,
1443
+ cascadeTaskProgress,
1417
1444
  clampTaskRangeForIncomingFS,
1418
1445
  computeCriticalPath,
1419
1446
  computeLagFromDates,