gantt-lib 0.89.0 → 0.90.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
@@ -5027,10 +5027,13 @@ var TaskListRow = React9.memo(
5027
5027
  }
5028
5028
  const clampedValue = Math.max(0, Math.min(100, progressValue));
5029
5029
  if ((clampedValue === 100 || clampedValue === 0) && isTaskParent(task.id, allTasks)) {
5030
- const children = getChildren(task.id, allTasks);
5030
+ const descendants = getAllDescendants(task.id, allTasks);
5031
5031
  const updatedTasks = [
5032
5032
  { ...task, progress: clampedValue },
5033
- ...children.map((child) => ({ ...child, progress: clampedValue }))
5033
+ ...descendants.map((descendant) => ({
5034
+ ...descendant,
5035
+ progress: clampedValue
5036
+ }))
5034
5037
  ];
5035
5038
  onTasksChange?.(updatedTasks);
5036
5039
  } else {
@@ -5053,11 +5056,11 @@ var TaskListRow = React9.memo(
5053
5056
  progressConfirmedRef.current = true;
5054
5057
  const clampedValue = Math.max(0, Math.min(100, progressValue));
5055
5058
  if ((clampedValue === 100 || clampedValue === 0) && isTaskParent(task.id, allTasks)) {
5056
- const children = getChildren(task.id, allTasks);
5059
+ const descendants = getAllDescendants(task.id, allTasks);
5057
5060
  const updatedTasks = [
5058
5061
  { ...task, progress: clampedValue },
5059
- ...children.map((child) => ({
5060
- ...child,
5062
+ ...descendants.map((descendant) => ({
5063
+ ...descendant,
5061
5064
  progress: clampedValue
5062
5065
  }))
5063
5066
  ];
@@ -5264,16 +5267,9 @@ var TaskListRow = React9.memo(
5264
5267
  const handleApplyColor = useCallback4(
5265
5268
  (color) => {
5266
5269
  if (!onTasksChange) return;
5267
- const descendantIds = /* @__PURE__ */ new Set();
5268
- if (isParent) {
5269
- const stack = getChildren(task.id, allTasks);
5270
- while (stack.length > 0) {
5271
- const current = stack.shift();
5272
- if (!current || descendantIds.has(current.id)) continue;
5273
- descendantIds.add(current.id);
5274
- stack.push(...getChildren(current.id, allTasks));
5275
- }
5276
- }
5270
+ const descendantIds = new Set(
5271
+ isParent ? getAllDescendants(task.id, allTasks).map((descendant) => descendant.id) : []
5272
+ );
5277
5273
  const updatedTasks = [
5278
5274
  { ...task, color },
5279
5275
  ...allTasks.filter((candidate) => descendantIds.has(candidate.id)).map((candidate) => ({ ...candidate, color }))
@@ -9519,7 +9515,17 @@ function TaskGanttChartInner(props, ref) {
9519
9515
  () => createCustomDayPredicate({ customDays, isWeekend: isWeekend3 }),
9520
9516
  [customDays, isWeekend3]
9521
9517
  );
9522
- const dateRange = useMemo10(() => getMultiMonthDays(normalizedTasks), [normalizedTasks]);
9518
+ const dateRangeTasks = useMemo10(() => {
9519
+ if (!showBaseline) {
9520
+ return normalizedTasks;
9521
+ }
9522
+ return normalizedTasks.map((task) => ({
9523
+ ...task,
9524
+ startDate: task.baselineStartDate && parseUTCDate(task.baselineStartDate).getTime() < parseUTCDate(task.startDate).getTime() ? task.baselineStartDate : task.startDate,
9525
+ endDate: task.baselineEndDate && parseUTCDate(task.baselineEndDate).getTime() > parseUTCDate(task.endDate).getTime() ? task.baselineEndDate : task.endDate
9526
+ }));
9527
+ }, [normalizedTasks, showBaseline]);
9528
+ const dateRange = useMemo10(() => getMultiMonthDays(dateRangeTasks), [dateRangeTasks]);
9523
9529
  const [validationResult, setValidationResult] = useState9(null);
9524
9530
  const [cascadeOverrides, setCascadeOverrides] = useState9(/* @__PURE__ */ new Map());
9525
9531
  const gridWidth = useMemo10(
@@ -9987,7 +9993,6 @@ function TaskGanttChartInner(props, ref) {
9987
9993
  if (!hasDirectChildren) return;
9988
9994
  const changedTasks = [];
9989
9995
  for (const task of tasks) {
9990
- if (task.id === taskId) continue;
9991
9996
  const nextParentId = task.parentId === taskId ? parentTask.parentId : task.parentId;
9992
9997
  const nextDependencies = task.dependencies?.filter((dep) => dep.taskId !== taskId);
9993
9998
  if (nextParentId !== task.parentId || nextDependencies?.length !== task.dependencies?.length) {
@@ -10001,8 +10006,7 @@ function TaskGanttChartInner(props, ref) {
10001
10006
  if (changedTasks.length > 0) {
10002
10007
  onTasksChange?.(changedTasks);
10003
10008
  }
10004
- onDelete?.(taskId);
10005
- }, [tasks, onTasksChange, onDelete, onUngroupTask]);
10009
+ }, [tasks, onTasksChange, onUngroupTask]);
10006
10010
  const panStateRef = useRef9(null);
10007
10011
  const handlePanStart = useCallback8((e) => {
10008
10012
  if (e.button !== 0) return;