gantt-lib 0.27.0 → 0.28.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
@@ -569,6 +569,8 @@ interface GanttChartProps {
569
569
  * Dependencies are still computed on ALL tasks (normalizedTasks).
570
570
  */
571
571
  taskFilter?: TaskPredicate;
572
+ /** Filter mode: 'highlight' shows all tasks with yellow highlight on matches, 'hide' hides non-matching tasks (default: 'highlight') */
573
+ filterMode?: 'highlight' | 'hide';
572
574
  /** Set of collapsed parent task IDs for controlled mode */
573
575
  collapsedParentIds?: Set<string>;
574
576
  /** Callback when collapse/expand button is clicked (controlled mode) */
@@ -816,6 +818,12 @@ interface TaskListProps {
816
818
  businessDays?: boolean;
817
819
  /** Task IDs highlighted by the active filter */
818
820
  highlightedTaskIds?: Set<string>;
821
+ /** Filter mode: 'highlight' shows yellow highlight on matches, 'hide' hides non-matching tasks */
822
+ filterMode?: 'highlight' | 'hide';
823
+ /** Task IDs that match the filter (used for hide mode). When undefined, no filtering is applied */
824
+ filteredTaskIds?: Set<string>;
825
+ /** Whether filter is currently active (needed to distinguish "no filter" from "filter with no matches") */
826
+ isFilterActive?: boolean;
819
827
  }
820
828
  /**
821
829
  * TaskList component - displays tasks in a table format as an overlay
package/dist/index.d.ts CHANGED
@@ -569,6 +569,8 @@ interface GanttChartProps {
569
569
  * Dependencies are still computed on ALL tasks (normalizedTasks).
570
570
  */
571
571
  taskFilter?: TaskPredicate;
572
+ /** Filter mode: 'highlight' shows all tasks with yellow highlight on matches, 'hide' hides non-matching tasks (default: 'highlight') */
573
+ filterMode?: 'highlight' | 'hide';
572
574
  /** Set of collapsed parent task IDs for controlled mode */
573
575
  collapsedParentIds?: Set<string>;
574
576
  /** Callback when collapse/expand button is clicked (controlled mode) */
@@ -816,6 +818,12 @@ interface TaskListProps {
816
818
  businessDays?: boolean;
817
819
  /** Task IDs highlighted by the active filter */
818
820
  highlightedTaskIds?: Set<string>;
821
+ /** Filter mode: 'highlight' shows yellow highlight on matches, 'hide' hides non-matching tasks */
822
+ filterMode?: 'highlight' | 'hide';
823
+ /** Task IDs that match the filter (used for hide mode). When undefined, no filtering is applied */
824
+ filteredTaskIds?: Set<string>;
825
+ /** Whether filter is currently active (needed to distinguish "no filter" from "filter with no matches") */
826
+ isFilterActive?: boolean;
819
827
  }
820
828
  /**
821
829
  * TaskList component - displays tasks in a table format as an overlay
package/dist/index.js CHANGED
@@ -3950,7 +3950,8 @@ var TaskListRow = import_react10.default.memo(
3950
3950
  customDays,
3951
3951
  isWeekend: isWeekend3,
3952
3952
  businessDays,
3953
- isFilterMatch = false
3953
+ isFilterMatch = false,
3954
+ isFilterHideMode = false
3954
3955
  }) => {
3955
3956
  const [editingName, setEditingName] = (0, import_react10.useState)(false);
3956
3957
  const [nameValue, setNameValue] = (0, import_react10.useState)("");
@@ -4714,39 +4715,41 @@ var TaskListRow = import_react10.default.memo(
4714
4715
  ),
4715
4716
  /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "gantt-tl-cell gantt-tl-cell-name", children: [
4716
4717
  isChild && !editingName && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
4717
- ancestorContinues.map(
4718
- (continues, idx) => continues ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
4718
+ !isFilterHideMode && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
4719
+ ancestorContinues.map(
4720
+ (continues, idx) => continues ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
4721
+ "span",
4722
+ {
4723
+ style: {
4724
+ position: "absolute",
4725
+ left: `${idx * 20 + 9}px`,
4726
+ top: 0,
4727
+ height: `${rowHeight}px`,
4728
+ width: "1.5px",
4729
+ background: "var(--gantt-hierarchy-line-color)",
4730
+ borderRadius: "1px",
4731
+ pointerEvents: "none"
4732
+ }
4733
+ },
4734
+ idx
4735
+ ) : null
4736
+ ),
4737
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
4719
4738
  "span",
4720
4739
  {
4721
4740
  style: {
4722
4741
  position: "absolute",
4723
- left: `${idx * 20 + 9}px`,
4742
+ left: `${(nestingDepth - 1) * 20 + 9}px`,
4724
4743
  top: 0,
4725
- height: `${rowHeight}px`,
4744
+ height: isLastChild ? `${rowHeight / 2}px` : `${rowHeight}px`,
4726
4745
  width: "1.5px",
4727
4746
  background: "var(--gantt-hierarchy-line-color)",
4728
4747
  borderRadius: "1px",
4729
4748
  pointerEvents: "none"
4730
4749
  }
4731
- },
4732
- idx
4733
- ) : null
4734
- ),
4735
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
4736
- "span",
4737
- {
4738
- style: {
4739
- position: "absolute",
4740
- left: `${(nestingDepth - 1) * 20 + 9}px`,
4741
- top: 0,
4742
- height: isLastChild ? `${rowHeight / 2}px` : `${rowHeight}px`,
4743
- width: "1.5px",
4744
- background: "var(--gantt-hierarchy-line-color)",
4745
- borderRadius: "1px",
4746
- pointerEvents: "none"
4747
4750
  }
4748
- }
4749
- ),
4751
+ )
4752
+ ] }),
4750
4753
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
4751
4754
  "span",
4752
4755
  {
@@ -4779,7 +4782,7 @@ var TaskListRow = import_react10.default.memo(
4779
4782
  )
4780
4783
  ] }),
4781
4784
  isParent && !editingName && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
4782
- !isCollapsed && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
4785
+ !isFilterHideMode && !isCollapsed && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
4783
4786
  "span",
4784
4787
  {
4785
4788
  style: {
@@ -5387,7 +5390,10 @@ var TaskList = ({
5387
5390
  customDays,
5388
5391
  isWeekend: isWeekend3,
5389
5392
  businessDays,
5390
- highlightedTaskIds = /* @__PURE__ */ new Set()
5393
+ highlightedTaskIds = /* @__PURE__ */ new Set(),
5394
+ filterMode = "highlight",
5395
+ filteredTaskIds = /* @__PURE__ */ new Set(),
5396
+ isFilterActive = false
5391
5397
  }) => {
5392
5398
  const [internalCollapsedParentIds, setInternalCollapsedParentIds] = (0, import_react12.useState)(/* @__PURE__ */ new Set());
5393
5399
  const collapsedParentIds = externalCollapsedParentIds ?? internalCollapsedParentIds;
@@ -5419,8 +5425,12 @@ var TaskList = ({
5419
5425
  }
5420
5426
  return false;
5421
5427
  }
5422
- return orderedTasks.filter((task) => !isAnyAncestorCollapsed(task.parentId));
5423
- }, [orderedTasks, collapsedParentIds]);
5428
+ let tasks2 = orderedTasks.filter((task) => !isAnyAncestorCollapsed(task.parentId));
5429
+ if (filterMode === "hide" && isFilterActive) {
5430
+ tasks2 = tasks2.filter((task) => filteredTaskIds.has(task.id));
5431
+ }
5432
+ return tasks2;
5433
+ }, [orderedTasks, collapsedParentIds, filterMode, filteredTaskIds, isFilterActive]);
5424
5434
  const totalHeight = (0, import_react12.useMemo)(
5425
5435
  () => visibleTasks.length * rowHeight,
5426
5436
  [visibleTasks.length, rowHeight]
@@ -5431,6 +5441,16 @@ var TaskList = ({
5431
5441
  ),
5432
5442
  [visibleTasks]
5433
5443
  );
5444
+ const originalTaskNumberMap = (0, import_react12.useMemo)(
5445
+ () => {
5446
+ const numberMap = /* @__PURE__ */ new Map();
5447
+ for (let i = 0; i < orderedTasks.length; i++) {
5448
+ numberMap.set(orderedTasks[i].id, getTaskNumber(orderedTasks, i));
5449
+ }
5450
+ return Object.fromEntries(numberMap);
5451
+ },
5452
+ [orderedTasks]
5453
+ );
5434
5454
  const nestingDepthMap = (0, import_react12.useMemo)(() => {
5435
5455
  const depthMap = /* @__PURE__ */ new Map();
5436
5456
  const taskById = new Map(tasks.map((t) => [t.id, t]));
@@ -5852,8 +5872,8 @@ var TaskList = ({
5852
5872
  {
5853
5873
  task,
5854
5874
  rowIndex: index,
5855
- taskNumber: getTaskNumber(visibleTasks, index),
5856
- taskNumberMap: visibleTaskNumberMap,
5875
+ taskNumber: originalTaskNumberMap[task.id] || "",
5876
+ taskNumberMap: originalTaskNumberMap,
5857
5877
  rowHeight,
5858
5878
  onTasksChange,
5859
5879
  selectedTaskId,
@@ -5892,7 +5912,8 @@ var TaskList = ({
5892
5912
  customDays,
5893
5913
  isWeekend: isWeekend3,
5894
5914
  businessDays,
5895
- isFilterMatch: highlightedTaskIds.has(task.id)
5915
+ isFilterMatch: filterMode === "highlight" ? highlightedTaskIds.has(task.id) : false,
5916
+ isFilterHideMode: filterMode === "hide" && isFilterActive
5896
5917
  },
5897
5918
  task.id
5898
5919
  )) }),
@@ -5966,6 +5987,7 @@ var GanttChart = (0, import_react13.forwardRef)(({
5966
5987
  isWeekend: isWeekend3,
5967
5988
  businessDays = true,
5968
5989
  taskFilter,
5990
+ filterMode = "highlight",
5969
5991
  collapsedParentIds: externalCollapsedParentIds,
5970
5992
  onToggleCollapse: externalOnToggleCollapse,
5971
5993
  highlightedTaskIds,
@@ -6001,20 +6023,27 @@ var GanttChart = (0, import_react13.forwardRef)(({
6001
6023
  }
6002
6024
  return false;
6003
6025
  }
6004
- return normalizedTasks.filter((task) => !isAnyAncestorCollapsed(task.parentId));
6005
- }, [normalizedTasks, collapsedParentIds]);
6026
+ let tasks2 = normalizedTasks.filter((task) => !isAnyAncestorCollapsed(task.parentId));
6027
+ if (filterMode === "hide" && taskFilter) {
6028
+ tasks2 = tasks2.filter(taskFilter);
6029
+ }
6030
+ return tasks2;
6031
+ }, [normalizedTasks, collapsedParentIds, filterMode, taskFilter]);
6006
6032
  const matchedTaskIds = (0, import_react13.useMemo)(() => {
6007
6033
  if (!taskFilter) return /* @__PURE__ */ new Set();
6008
6034
  return new Set(visibleTasks.filter(taskFilter).map((task) => task.id));
6009
6035
  }, [visibleTasks, taskFilter]);
6010
6036
  const taskListHighlightedTaskIds = (0, import_react13.useMemo)(() => {
6037
+ if (filterMode === "hide") {
6038
+ return /* @__PURE__ */ new Set();
6039
+ }
6011
6040
  if ((!highlightedTaskIds || highlightedTaskIds.size === 0) && matchedTaskIds.size === 0) {
6012
6041
  return /* @__PURE__ */ new Set();
6013
6042
  }
6014
6043
  const mergedHighlightedTaskIds = new Set(highlightedTaskIds ?? []);
6015
6044
  matchedTaskIds.forEach((taskId) => mergedHighlightedTaskIds.add(taskId));
6016
6045
  return mergedHighlightedTaskIds;
6017
- }, [highlightedTaskIds, matchedTaskIds]);
6046
+ }, [filterMode, highlightedTaskIds, matchedTaskIds]);
6018
6047
  const totalGridHeight = (0, import_react13.useMemo)(
6019
6048
  () => visibleTasks.length * rowHeight,
6020
6049
  [visibleTasks.length, rowHeight]
@@ -6430,7 +6459,10 @@ var GanttChart = (0, import_react13.forwardRef)(({
6430
6459
  highlightedTaskIds: taskListHighlightedTaskIds,
6431
6460
  customDays,
6432
6461
  isWeekend: isWeekend3,
6433
- businessDays
6462
+ businessDays,
6463
+ filterMode,
6464
+ filteredTaskIds: matchedTaskIds,
6465
+ isFilterActive: !!taskFilter
6434
6466
  }
6435
6467
  ),
6436
6468
  /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: showChart ? "" : "gantt-chart-hidden", style: { minWidth: `${gridWidth}px`, flex: 1 }, children: [
@@ -6515,7 +6547,7 @@ var GanttChart = (0, import_react13.forwardRef)(({
6515
6547
  onCascadeProgress: handleCascadeProgress,
6516
6548
  onCascade: handleCascade,
6517
6549
  highlightExpiredTasks,
6518
- isFilterMatch: matchedTaskIds.has(task.id),
6550
+ isFilterMatch: filterMode === "highlight" ? matchedTaskIds.has(task.id) : false,
6519
6551
  businessDays,
6520
6552
  customDays,
6521
6553
  isWeekend: isWeekend3,