gantt-lib 0.26.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.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,10 +5987,12 @@ 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,
5972
- disableTaskDrag = false
5994
+ disableTaskDrag = false,
5995
+ showChart = true
5973
5996
  }, ref) => {
5974
5997
  const scrollContainerRef = (0, import_react13.useRef)(null);
5975
5998
  const [selectedTaskId, setSelectedTaskId] = (0, import_react13.useState)(null);
@@ -6000,20 +6023,27 @@ var GanttChart = (0, import_react13.forwardRef)(({
6000
6023
  }
6001
6024
  return false;
6002
6025
  }
6003
- return normalizedTasks.filter((task) => !isAnyAncestorCollapsed(task.parentId));
6004
- }, [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]);
6005
6032
  const matchedTaskIds = (0, import_react13.useMemo)(() => {
6006
6033
  if (!taskFilter) return /* @__PURE__ */ new Set();
6007
6034
  return new Set(visibleTasks.filter(taskFilter).map((task) => task.id));
6008
6035
  }, [visibleTasks, taskFilter]);
6009
6036
  const taskListHighlightedTaskIds = (0, import_react13.useMemo)(() => {
6037
+ if (filterMode === "hide") {
6038
+ return /* @__PURE__ */ new Set();
6039
+ }
6010
6040
  if ((!highlightedTaskIds || highlightedTaskIds.size === 0) && matchedTaskIds.size === 0) {
6011
6041
  return /* @__PURE__ */ new Set();
6012
6042
  }
6013
6043
  const mergedHighlightedTaskIds = new Set(highlightedTaskIds ?? []);
6014
6044
  matchedTaskIds.forEach((taskId) => mergedHighlightedTaskIds.add(taskId));
6015
6045
  return mergedHighlightedTaskIds;
6016
- }, [highlightedTaskIds, matchedTaskIds]);
6046
+ }, [filterMode, highlightedTaskIds, matchedTaskIds]);
6017
6047
  const totalGridHeight = (0, import_react13.useMemo)(
6018
6048
  () => visibleTasks.length * rowHeight,
6019
6049
  [visibleTasks.length, rowHeight]
@@ -6429,10 +6459,13 @@ var GanttChart = (0, import_react13.forwardRef)(({
6429
6459
  highlightedTaskIds: taskListHighlightedTaskIds,
6430
6460
  customDays,
6431
6461
  isWeekend: isWeekend3,
6432
- businessDays
6462
+ businessDays,
6463
+ filterMode,
6464
+ filteredTaskIds: matchedTaskIds,
6465
+ isFilterActive: !!taskFilter
6433
6466
  }
6434
6467
  ),
6435
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { style: { minWidth: `${gridWidth}px`, flex: 1 }, children: [
6468
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: showChart ? "" : "gantt-chart-hidden", style: { minWidth: `${gridWidth}px`, flex: 1 }, children: [
6436
6469
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "gantt-stickyHeader", style: { width: `${gridWidth}px` }, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
6437
6470
  TimeScaleHeader_default,
6438
6471
  {
@@ -6514,7 +6547,7 @@ var GanttChart = (0, import_react13.forwardRef)(({
6514
6547
  onCascadeProgress: handleCascadeProgress,
6515
6548
  onCascade: handleCascade,
6516
6549
  highlightExpiredTasks,
6517
- isFilterMatch: matchedTaskIds.has(task.id),
6550
+ isFilterMatch: filterMode === "highlight" ? matchedTaskIds.has(task.id) : false,
6518
6551
  businessDays,
6519
6552
  customDays,
6520
6553
  isWeekend: isWeekend3,