gantt-lib 0.124.1 → 0.125.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
@@ -1004,6 +1004,10 @@ interface TaskListProps {
1004
1004
  filteredTaskIds?: Set<string>;
1005
1005
  /** Whether filter is currently active (needed to distinguish "no filter" from "filter with no matches") */
1006
1006
  isFilterActive?: boolean;
1007
+ /** Critical path display mode. In 'hide' mode only critical tasks (and their parents) are shown. */
1008
+ criticalPathMode?: 'highlight' | 'hide';
1009
+ /** Task IDs that belong to the critical path (leaves + lifted parents). Used when criticalPathMode === 'hide'. */
1010
+ criticalTaskIds?: Set<string>;
1007
1011
  /** Additional columns to display after built-in columns */
1008
1012
  additionalColumns?: TaskListColumn<any>[];
1009
1013
  /** Built-in or custom TaskList column IDs to hide after column placement is resolved */
package/dist/index.d.ts CHANGED
@@ -1004,6 +1004,10 @@ interface TaskListProps {
1004
1004
  filteredTaskIds?: Set<string>;
1005
1005
  /** Whether filter is currently active (needed to distinguish "no filter" from "filter with no matches") */
1006
1006
  isFilterActive?: boolean;
1007
+ /** Critical path display mode. In 'hide' mode only critical tasks (and their parents) are shown. */
1008
+ criticalPathMode?: 'highlight' | 'hide';
1009
+ /** Task IDs that belong to the critical path (leaves + lifted parents). Used when criticalPathMode === 'hide'. */
1010
+ criticalTaskIds?: Set<string>;
1007
1011
  /** Additional columns to display after built-in columns */
1008
1012
  additionalColumns?: TaskListColumn<any>[];
1009
1013
  /** Built-in or custom TaskList column IDs to hide after column placement is resolved */
package/dist/index.js CHANGED
@@ -3177,7 +3177,8 @@ var TaskRow = import_react3.default.memo(
3177
3177
  }
3178
3178
  return calculateTaskBar(baselineStartDate, baselineEndDate, monthStart, dayWidth);
3179
3179
  }, [baselineStartDate, baselineEndDate, milestone, monthStart, dayWidth]);
3180
- const barColor = isExpired ? "var(--gantt-expired-color)" : task.color || "var(--gantt-task-bar-default-color)";
3180
+ const criticalBarColor = "var(--gantt-critical-path-color, #dc2626)";
3181
+ const barColor = isExpired ? "var(--gantt-expired-color)" : isCritical ? criticalBarColor : task.color || "var(--gantt-task-bar-default-color)";
3181
3182
  const progressWidth = (0, import_react3.useMemo)(() => {
3182
3183
  if (task.progress === void 0 || task.progress <= 0) return 0;
3183
3184
  return Math.min(100, Math.max(0, Math.round(task.progress)));
@@ -3186,21 +3187,31 @@ var TaskRow = import_react3.default.memo(
3186
3187
  if (isExpired) {
3187
3188
  return "color-mix(in srgb, var(--gantt-expired-color) 40%, black)";
3188
3189
  }
3190
+ if (isCritical) {
3191
+ return `color-mix(in srgb, ${criticalBarColor} 40%, black)`;
3192
+ }
3189
3193
  if (progressWidth === 100) {
3190
3194
  return task.accepted ? "var(--gantt-progress-accepted, #22c55e)" : "var(--gantt-progress-completed, #fbbf24)";
3191
3195
  }
3192
3196
  const baseColor = task.color || "var(--gantt-task-bar-default-color)";
3193
3197
  return `color-mix(in srgb, ${baseColor} 40%, black)`;
3194
- }, [isExpired, progressWidth, task.accepted, task.color]);
3198
+ }, [isCritical, isExpired, progressWidth, task.accepted, task.color]);
3195
3199
  const externalTaskNameColor = (0, import_react3.useMemo)(() => {
3196
3200
  if (isExpired) {
3197
3201
  return "color-mix(in srgb, var(--gantt-expired-color) 40%, black)";
3198
3202
  }
3199
3203
  const baseColor = isParent ? task.color || defaultParentBarColor : task.color || "var(--gantt-task-bar-default-color)";
3200
3204
  return `color-mix(in srgb, ${baseColor} 40%, black)`;
3201
- }, [defaultParentBarColor, isExpired, isParent, task.color]);
3205
+ }, [defaultParentBarColor, isCritical, isExpired, isParent, task.color]);
3202
3206
  const barStyle = (0, import_react3.useMemo)(() => {
3203
3207
  const parentBarColor = task.color || defaultParentBarColor;
3208
+ if (isCritical && !isExpired) {
3209
+ const c = criticalBarColor;
3210
+ if (isParent) {
3211
+ return { backgroundColor: c, "--gantt-parent-bar-color": c };
3212
+ }
3213
+ return { backgroundColor: c };
3214
+ }
3204
3215
  if (isParent) {
3205
3216
  if (progressWidth >= 100) {
3206
3217
  const c = isExpired ? "color-mix(in srgb, var(--gantt-expired-color) 40%, black)" : `color-mix(in srgb, ${parentBarColor} 40%, black)`;
@@ -3212,7 +3223,7 @@ var TaskRow = import_react3.default.memo(
3212
3223
  return { backgroundColor: progressColor };
3213
3224
  }
3214
3225
  return { backgroundColor: barColor };
3215
- }, [defaultParentBarColor, isExpired, isParent, progressWidth, barColor, progressColor, task.color]);
3226
+ }, [isCritical, defaultParentBarColor, isExpired, isParent, progressWidth, barColor, progressColor, task.color]);
3216
3227
  const handleDragEnd = (result) => {
3217
3228
  const updatedTask = {
3218
3229
  ...normalizedTask,
@@ -3791,6 +3802,7 @@ var DependencyLines = import_react7.default.memo(({
3791
3802
  for (const task of allTasks) {
3792
3803
  if (positions.has(task.id)) continue;
3793
3804
  if (collapsedParentIds.size > 0 && isTaskHidden(task.id, collapsedParentIds, taskMap)) continue;
3805
+ if (rowIndexByTaskId && !rowIndexByTaskId.has(task.id)) continue;
3794
3806
  hidden.add(task.id);
3795
3807
  const override = dragOverrides?.get(task.id);
3796
3808
  const computed = resolveTaskHorizontalGeometry(task, monthStart, dayWidth, override);
@@ -7703,6 +7715,8 @@ var TaskList = ({
7703
7715
  filterMode = "highlight",
7704
7716
  filteredTaskIds = /* @__PURE__ */ new Set(),
7705
7717
  isFilterActive = false,
7718
+ criticalPathMode,
7719
+ criticalTaskIds,
7706
7720
  additionalColumns,
7707
7721
  hiddenTaskListColumns,
7708
7722
  taskListColumnWidths,
@@ -7763,8 +7777,11 @@ var TaskList = ({
7763
7777
  if (filterMode === "hide" && isFilterActive) {
7764
7778
  tasks2 = tasks2.filter((task) => filteredTaskIds.has(task.id));
7765
7779
  }
7780
+ if (criticalPathMode === "hide" && criticalTaskIds) {
7781
+ tasks2 = tasks2.filter((task) => criticalTaskIds.has(task.id));
7782
+ }
7766
7783
  return tasks2;
7767
- }, [orderedTasks, collapsedParentIds, filterMode, filteredTaskIds, isFilterActive]);
7784
+ }, [orderedTasks, collapsedParentIds, filterMode, filteredTaskIds, isFilterActive, criticalPathMode, criticalTaskIds]);
7768
7785
  const totalHeight = (0, import_react13.useMemo)(
7769
7786
  () => visibleTasks.length * rowHeight,
7770
7787
  [visibleTasks.length, rowHeight]
@@ -13005,13 +13022,18 @@ function TaskGanttChartInner(props, ref) {
13005
13022
  if (filterMode === "hide") {
13006
13023
  return /* @__PURE__ */ new Set();
13007
13024
  }
13008
- if ((!highlightedTaskIds || highlightedTaskIds.size === 0) && matchedTaskIds.size === 0) {
13025
+ const criticalHighlightMode = criticalPathMode === "highlight";
13026
+ const hasExternalHighlights = !!highlightedTaskIds && highlightedTaskIds.size > 0;
13027
+ if (!hasExternalHighlights && matchedTaskIds.size === 0 && !criticalHighlightMode) {
13009
13028
  return /* @__PURE__ */ new Set();
13010
13029
  }
13011
13030
  const mergedHighlightedTaskIds = new Set(highlightedTaskIds ?? []);
13012
13031
  matchedTaskIds.forEach((taskId) => mergedHighlightedTaskIds.add(taskId));
13032
+ if (criticalHighlightMode) {
13033
+ criticalTaskIds.forEach((taskId) => mergedHighlightedTaskIds.add(taskId));
13034
+ }
13013
13035
  return mergedHighlightedTaskIds;
13014
- }, [filterMode, highlightedTaskIds, matchedTaskIds]);
13036
+ }, [filterMode, highlightedTaskIds, matchedTaskIds, criticalPathMode, criticalTaskIds]);
13015
13037
  const totalGridHeight = (0, import_react18.useMemo)(
13016
13038
  () => visibleTasks.length * effectiveRowHeight,
13017
13039
  [effectiveRowHeight, visibleTasks.length]
@@ -13765,6 +13787,8 @@ function TaskGanttChartInner(props, ref) {
13765
13787
  filterMode,
13766
13788
  filteredTaskIds: matchedTaskIds,
13767
13789
  isFilterActive: !!taskFilter,
13790
+ criticalPathMode,
13791
+ criticalTaskIds: criticalPathMode === "hide" ? criticalTaskIds : void 0,
13768
13792
  additionalColumns,
13769
13793
  hiddenTaskListColumns,
13770
13794
  taskListColumnWidths,
@@ -14004,7 +14028,7 @@ function TaskGanttChartInner(props, ref) {
14004
14028
  onCascade: handleCascade,
14005
14029
  highlightExpiredTasks,
14006
14030
  showBaseline,
14007
- isFilterMatch: filterMode === "highlight" ? matchedTaskIds.has(task.id) : false,
14031
+ isFilterMatch: (filterMode === "highlight" ? matchedTaskIds.has(task.id) : false) || (criticalPathMode === "highlight" ? criticalTaskIds.has(task.id) : false),
14008
14032
  isCritical: criticalTaskIds.has(task.id),
14009
14033
  businessDays,
14010
14034
  customDays,