gantt-lib 0.85.0 → 0.86.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.mjs CHANGED
@@ -448,17 +448,27 @@ function normalizePredecessorDates(predecessor, parseDateFn) {
448
448
  function getDependencyLag(dep) {
449
449
  return Number.isFinite(dep.lag) ? dep.lag : 0;
450
450
  }
451
+ function normalizeTaskDependencyLags(task) {
452
+ if (!task.dependencies?.length) {
453
+ return task;
454
+ }
455
+ let changed = false;
456
+ const dependencies = task.dependencies.map((dep) => {
457
+ const lag = getDependencyLag(dep);
458
+ const normalizedLag = dep.type === "FS" ? Math.max(0, lag) : lag;
459
+ if (normalizedLag === dep.lag) {
460
+ return dep;
461
+ }
462
+ changed = true;
463
+ return { ...dep, lag: normalizedLag };
464
+ });
465
+ return changed ? { ...task, dependencies } : task;
466
+ }
451
467
  function normalizeDependencyLag(linkType, lag, predecessorStart, predecessorEnd, businessDays = false, weekendPredicate) {
452
468
  if (linkType !== "FS") {
453
469
  return lag;
454
470
  }
455
- const predecessorDuration = getTaskDuration(
456
- predecessorStart,
457
- predecessorEnd,
458
- businessDays,
459
- weekendPredicate
460
- );
461
- return Math.max(-predecessorDuration, lag);
471
+ return Math.max(0, lag);
462
472
  }
463
473
  function computeLagFromDates(linkType, predStart, predEnd, succStart, succEnd, businessDays = false, weekendPredicate) {
464
474
  const pS = Date.UTC(predStart.getUTCFullYear(), predStart.getUTCMonth(), predStart.getUTCDate());
@@ -717,17 +727,11 @@ function clampTaskRangeForIncomingFS(task, proposedStart, proposedEnd, allTasks,
717
727
  continue;
718
728
  }
719
729
  const { predStart: predecessorStart, predEnd: predecessorEnd } = normalizePredecessorDates(predecessor, parseDateOnly);
720
- const predecessorDuration = getTaskDuration(
721
- predecessorStart,
722
- predecessorEnd,
723
- businessDays,
724
- weekendPredicate
725
- );
726
730
  const candidateMinStart = calculateSuccessorDate(
727
731
  predecessorStart,
728
732
  predecessorEnd,
729
733
  "FS",
730
- -predecessorDuration,
734
+ 0,
731
735
  businessDays,
732
736
  weekendPredicate
733
737
  );
@@ -838,11 +842,11 @@ function cascadeByLinks(movedTaskId, newStart, newEnd, allTasks, skipChildCascad
838
842
  const newChildEnd = new Date(origEnd.getTime() + parentEndDelta);
839
843
  visited.add(child.id);
840
844
  updatedDates.set(child.id, { start: newChildStart, end: newChildEnd });
841
- result.push({
845
+ result.push(normalizeTaskDependencyLags({
842
846
  ...child,
843
847
  startDate: newChildStart.toISOString().split("T")[0],
844
848
  endDate: newChildEnd.toISOString().split("T")[0]
845
- });
849
+ }));
846
850
  queue.push(child.id);
847
851
  }
848
852
  }
@@ -878,11 +882,11 @@ function cascadeByLinks(movedTaskId, newStart, newEnd, allTasks, skipChildCascad
878
882
  }
879
883
  visited.add(task.id);
880
884
  updatedDates.set(task.id, { start: newSuccStart, end: newSuccEnd });
881
- result.push({
885
+ result.push(normalizeTaskDependencyLags({
882
886
  ...task,
883
887
  startDate: newSuccStart.toISOString().split("T")[0],
884
888
  endDate: newSuccEnd.toISOString().split("T")[0]
885
- });
889
+ }));
886
890
  queue.push(task.id);
887
891
  break;
888
892
  }
@@ -937,11 +941,11 @@ function universalCascade(movedTask, newStart, newEnd, allTasks, businessDays =
937
941
  const updatedDates = /* @__PURE__ */ new Map();
938
942
  updatedDates.set(movedTask.id, { start: newStart, end: newEnd });
939
943
  const resultMap = /* @__PURE__ */ new Map();
940
- resultMap.set(movedTask.id, {
944
+ resultMap.set(movedTask.id, normalizeTaskDependencyLags({
941
945
  ...movedTask,
942
946
  startDate: newStart.toISOString().split("T")[0],
943
947
  endDate: newEnd.toISOString().split("T")[0]
944
- });
948
+ }));
945
949
  const queue = [[movedTask.id, "direct"]];
946
950
  const childShifted = /* @__PURE__ */ new Set();
947
951
  let iterations = 0;
@@ -987,11 +991,11 @@ function universalCascade(movedTask, newStart, newEnd, allTasks, businessDays =
987
991
  updatedDates.set(child.id, { start: childNewStart, end: childNewEnd });
988
992
  childShifted.add(child.id);
989
993
  queue.push([child.id, "child-delta"]);
990
- resultMap.set(child.id, {
994
+ resultMap.set(child.id, normalizeTaskDependencyLags({
991
995
  ...child,
992
996
  startDate: childNewStart.toISOString().split("T")[0],
993
997
  endDate: childNewEnd.toISOString().split("T")[0]
994
- });
998
+ }));
995
999
  }
996
1000
  }
997
1001
  const parentId = currentOriginal.parentId;
@@ -1009,11 +1013,11 @@ function universalCascade(movedTask, newStart, newEnd, allTasks, businessDays =
1009
1013
  if (!prev || prev.start.getTime() !== minStart.getTime() || prev.end.getTime() !== maxEnd.getTime()) {
1010
1014
  updatedDates.set(parentId, { start: minStart, end: maxEnd });
1011
1015
  queue.push([parentId, "parent-recalc"]);
1012
- resultMap.set(parentId, {
1016
+ resultMap.set(parentId, normalizeTaskDependencyLags({
1013
1017
  ...parent,
1014
1018
  startDate: minStart.toISOString().split("T")[0],
1015
1019
  endDate: maxEnd.toISOString().split("T")[0]
1016
- });
1020
+ }));
1017
1021
  }
1018
1022
  }
1019
1023
  }
@@ -1063,11 +1067,11 @@ function universalCascade(movedTask, newStart, newEnd, allTasks, businessDays =
1063
1067
  }
1064
1068
  updatedDates.set(task.id, { start: succNewStart, end: succNewEnd });
1065
1069
  queue.push([task.id, "dependency"]);
1066
- resultMap.set(task.id, {
1070
+ resultMap.set(task.id, normalizeTaskDependencyLags({
1067
1071
  ...task,
1068
1072
  startDate: succNewStart.toISOString().split("T")[0],
1069
1073
  endDate: succNewEnd.toISOString().split("T")[0]
1070
- });
1074
+ }));
1071
1075
  }
1072
1076
  }
1073
1077
  return Array.from(resultMap.values());
@@ -6456,7 +6460,7 @@ var TaskList = ({
6456
6460
  tasks,
6457
6461
  rowHeight,
6458
6462
  headerHeight,
6459
- taskListWidth = MIN_TASK_LIST_WIDTH,
6463
+ taskListWidth,
6460
6464
  onTasksChange,
6461
6465
  selectedTaskId,
6462
6466
  onTaskSelect,
@@ -7029,7 +7033,8 @@ var TaskList = ({
7029
7033
  () => resolvedColumns.reduce((sum, col) => sum + (col.width ?? 120), 0),
7030
7034
  [resolvedColumns]
7031
7035
  );
7032
- const effectiveTaskListWidth = Math.max(taskListWidth, MIN_TASK_LIST_WIDTH, resolvedColumnWidthTotal);
7036
+ const requestedTaskListWidth = taskListWidth ?? Math.min(MIN_TASK_LIST_WIDTH, resolvedColumnWidthTotal);
7037
+ const effectiveTaskListWidth = Math.max(requestedTaskListWidth, resolvedColumnWidthTotal);
7033
7038
  const tableHeaderHeight = headerHeight + 1;
7034
7039
  return /* @__PURE__ */ jsx14(
7035
7040
  "div",
@@ -10034,6 +10039,7 @@ export {
10034
10039
  normalizeHierarchyTasks,
10035
10040
  normalizePredecessorDates,
10036
10041
  normalizeTaskDates,
10042
+ normalizeTaskDependencyLags,
10037
10043
  normalizeUTCDate,
10038
10044
  not,
10039
10045
  or,