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.d.mts CHANGED
@@ -467,7 +467,7 @@ interface GanttModeProps<TTask extends Task = Task> {
467
467
  onPromoteTask?: (taskId: string) => void;
468
468
  /** Callback when a task is demoted (parentId set). If not provided, default internal logic is used. */
469
469
  onDemoteTask?: (taskId: string, newParentId: string) => void;
470
- /** Callback when a parent task is ungrouped (removed while direct children move one level up). */
470
+ /** Callback when a parent task is ungrouped while direct children move one level up and the parent remains. */
471
471
  onUngroupTask?: (taskId: string) => void;
472
472
  /** Enable add task button at bottom of task list (default: true) */
473
473
  enableAddTask?: boolean;
@@ -772,7 +772,7 @@ interface TaskListProps {
772
772
  onPromoteTask?: (taskId: string) => void;
773
773
  /** Callback when task is demoted (parentId set to previous task) */
774
774
  onDemoteTask?: (taskId: string, newParentId: string) => void;
775
- /** Callback when parent task is ungrouped (removed while direct children move one level up) */
775
+ /** Callback when a parent task is ungrouped while direct children move one level up and the parent remains */
776
776
  onUngroupTask?: (taskId: string) => void;
777
777
  /** Custom day configurations for date picker */
778
778
  customDays?: CustomDayConfig[];
package/dist/index.d.ts CHANGED
@@ -467,7 +467,7 @@ interface GanttModeProps<TTask extends Task = Task> {
467
467
  onPromoteTask?: (taskId: string) => void;
468
468
  /** Callback when a task is demoted (parentId set). If not provided, default internal logic is used. */
469
469
  onDemoteTask?: (taskId: string, newParentId: string) => void;
470
- /** Callback when a parent task is ungrouped (removed while direct children move one level up). */
470
+ /** Callback when a parent task is ungrouped while direct children move one level up and the parent remains. */
471
471
  onUngroupTask?: (taskId: string) => void;
472
472
  /** Enable add task button at bottom of task list (default: true) */
473
473
  enableAddTask?: boolean;
@@ -772,7 +772,7 @@ interface TaskListProps {
772
772
  onPromoteTask?: (taskId: string) => void;
773
773
  /** Callback when task is demoted (parentId set to previous task) */
774
774
  onDemoteTask?: (taskId: string, newParentId: string) => void;
775
- /** Callback when parent task is ungrouped (removed while direct children move one level up) */
775
+ /** Callback when a parent task is ungrouped while direct children move one level up and the parent remains */
776
776
  onUngroupTask?: (taskId: string) => void;
777
777
  /** Custom day configurations for date picker */
778
778
  customDays?: CustomDayConfig[];
package/dist/index.js CHANGED
@@ -5142,10 +5142,13 @@ var TaskListRow = import_react10.default.memo(
5142
5142
  }
5143
5143
  const clampedValue = Math.max(0, Math.min(100, progressValue));
5144
5144
  if ((clampedValue === 100 || clampedValue === 0) && isTaskParent(task.id, allTasks)) {
5145
- const children = getChildren(task.id, allTasks);
5145
+ const descendants = getAllDescendants(task.id, allTasks);
5146
5146
  const updatedTasks = [
5147
5147
  { ...task, progress: clampedValue },
5148
- ...children.map((child) => ({ ...child, progress: clampedValue }))
5148
+ ...descendants.map((descendant) => ({
5149
+ ...descendant,
5150
+ progress: clampedValue
5151
+ }))
5149
5152
  ];
5150
5153
  onTasksChange?.(updatedTasks);
5151
5154
  } else {
@@ -5168,11 +5171,11 @@ var TaskListRow = import_react10.default.memo(
5168
5171
  progressConfirmedRef.current = true;
5169
5172
  const clampedValue = Math.max(0, Math.min(100, progressValue));
5170
5173
  if ((clampedValue === 100 || clampedValue === 0) && isTaskParent(task.id, allTasks)) {
5171
- const children = getChildren(task.id, allTasks);
5174
+ const descendants = getAllDescendants(task.id, allTasks);
5172
5175
  const updatedTasks = [
5173
5176
  { ...task, progress: clampedValue },
5174
- ...children.map((child) => ({
5175
- ...child,
5177
+ ...descendants.map((descendant) => ({
5178
+ ...descendant,
5176
5179
  progress: clampedValue
5177
5180
  }))
5178
5181
  ];
@@ -5379,16 +5382,9 @@ var TaskListRow = import_react10.default.memo(
5379
5382
  const handleApplyColor = (0, import_react10.useCallback)(
5380
5383
  (color) => {
5381
5384
  if (!onTasksChange) return;
5382
- const descendantIds = /* @__PURE__ */ new Set();
5383
- if (isParent) {
5384
- const stack = getChildren(task.id, allTasks);
5385
- while (stack.length > 0) {
5386
- const current = stack.shift();
5387
- if (!current || descendantIds.has(current.id)) continue;
5388
- descendantIds.add(current.id);
5389
- stack.push(...getChildren(current.id, allTasks));
5390
- }
5391
- }
5385
+ const descendantIds = new Set(
5386
+ isParent ? getAllDescendants(task.id, allTasks).map((descendant) => descendant.id) : []
5387
+ );
5392
5388
  const updatedTasks = [
5393
5389
  { ...task, color },
5394
5390
  ...allTasks.filter((candidate) => descendantIds.has(candidate.id)).map((candidate) => ({ ...candidate, color }))
@@ -9634,7 +9630,17 @@ function TaskGanttChartInner(props, ref) {
9634
9630
  () => createCustomDayPredicate({ customDays, isWeekend: isWeekend3 }),
9635
9631
  [customDays, isWeekend3]
9636
9632
  );
9637
- const dateRange = (0, import_react15.useMemo)(() => getMultiMonthDays(normalizedTasks), [normalizedTasks]);
9633
+ const dateRangeTasks = (0, import_react15.useMemo)(() => {
9634
+ if (!showBaseline) {
9635
+ return normalizedTasks;
9636
+ }
9637
+ return normalizedTasks.map((task) => ({
9638
+ ...task,
9639
+ startDate: task.baselineStartDate && parseUTCDate(task.baselineStartDate).getTime() < parseUTCDate(task.startDate).getTime() ? task.baselineStartDate : task.startDate,
9640
+ endDate: task.baselineEndDate && parseUTCDate(task.baselineEndDate).getTime() > parseUTCDate(task.endDate).getTime() ? task.baselineEndDate : task.endDate
9641
+ }));
9642
+ }, [normalizedTasks, showBaseline]);
9643
+ const dateRange = (0, import_react15.useMemo)(() => getMultiMonthDays(dateRangeTasks), [dateRangeTasks]);
9638
9644
  const [validationResult, setValidationResult] = (0, import_react15.useState)(null);
9639
9645
  const [cascadeOverrides, setCascadeOverrides] = (0, import_react15.useState)(/* @__PURE__ */ new Map());
9640
9646
  const gridWidth = (0, import_react15.useMemo)(
@@ -10102,7 +10108,6 @@ function TaskGanttChartInner(props, ref) {
10102
10108
  if (!hasDirectChildren) return;
10103
10109
  const changedTasks = [];
10104
10110
  for (const task of tasks) {
10105
- if (task.id === taskId) continue;
10106
10111
  const nextParentId = task.parentId === taskId ? parentTask.parentId : task.parentId;
10107
10112
  const nextDependencies = task.dependencies?.filter((dep) => dep.taskId !== taskId);
10108
10113
  if (nextParentId !== task.parentId || nextDependencies?.length !== task.dependencies?.length) {
@@ -10116,8 +10121,7 @@ function TaskGanttChartInner(props, ref) {
10116
10121
  if (changedTasks.length > 0) {
10117
10122
  onTasksChange?.(changedTasks);
10118
10123
  }
10119
- onDelete?.(taskId);
10120
- }, [tasks, onTasksChange, onDelete, onUngroupTask]);
10124
+ }, [tasks, onTasksChange, onUngroupTask]);
10121
10125
  const panStateRef = (0, import_react15.useRef)(null);
10122
10126
  const handlePanStart = (0, import_react15.useCallback)((e) => {
10123
10127
  if (e.button !== 0) return;