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.mjs CHANGED
@@ -3873,7 +3873,8 @@ var TaskListRow = React9.memo(
3873
3873
  customDays,
3874
3874
  isWeekend: isWeekend3,
3875
3875
  businessDays,
3876
- isFilterMatch = false
3876
+ isFilterMatch = false,
3877
+ isFilterHideMode = false
3877
3878
  }) => {
3878
3879
  const [editingName, setEditingName] = useState4(false);
3879
3880
  const [nameValue, setNameValue] = useState4("");
@@ -4637,39 +4638,41 @@ var TaskListRow = React9.memo(
4637
4638
  ),
4638
4639
  /* @__PURE__ */ jsxs9("div", { className: "gantt-tl-cell gantt-tl-cell-name", children: [
4639
4640
  isChild && !editingName && /* @__PURE__ */ jsxs9(Fragment2, { children: [
4640
- ancestorContinues.map(
4641
- (continues, idx) => continues ? /* @__PURE__ */ jsx12(
4641
+ !isFilterHideMode && /* @__PURE__ */ jsxs9(Fragment2, { children: [
4642
+ ancestorContinues.map(
4643
+ (continues, idx) => continues ? /* @__PURE__ */ jsx12(
4644
+ "span",
4645
+ {
4646
+ style: {
4647
+ position: "absolute",
4648
+ left: `${idx * 20 + 9}px`,
4649
+ top: 0,
4650
+ height: `${rowHeight}px`,
4651
+ width: "1.5px",
4652
+ background: "var(--gantt-hierarchy-line-color)",
4653
+ borderRadius: "1px",
4654
+ pointerEvents: "none"
4655
+ }
4656
+ },
4657
+ idx
4658
+ ) : null
4659
+ ),
4660
+ /* @__PURE__ */ jsx12(
4642
4661
  "span",
4643
4662
  {
4644
4663
  style: {
4645
4664
  position: "absolute",
4646
- left: `${idx * 20 + 9}px`,
4665
+ left: `${(nestingDepth - 1) * 20 + 9}px`,
4647
4666
  top: 0,
4648
- height: `${rowHeight}px`,
4667
+ height: isLastChild ? `${rowHeight / 2}px` : `${rowHeight}px`,
4649
4668
  width: "1.5px",
4650
4669
  background: "var(--gantt-hierarchy-line-color)",
4651
4670
  borderRadius: "1px",
4652
4671
  pointerEvents: "none"
4653
4672
  }
4654
- },
4655
- idx
4656
- ) : null
4657
- ),
4658
- /* @__PURE__ */ jsx12(
4659
- "span",
4660
- {
4661
- style: {
4662
- position: "absolute",
4663
- left: `${(nestingDepth - 1) * 20 + 9}px`,
4664
- top: 0,
4665
- height: isLastChild ? `${rowHeight / 2}px` : `${rowHeight}px`,
4666
- width: "1.5px",
4667
- background: "var(--gantt-hierarchy-line-color)",
4668
- borderRadius: "1px",
4669
- pointerEvents: "none"
4670
4673
  }
4671
- }
4672
- ),
4674
+ )
4675
+ ] }),
4673
4676
  /* @__PURE__ */ jsx12(
4674
4677
  "span",
4675
4678
  {
@@ -4702,7 +4705,7 @@ var TaskListRow = React9.memo(
4702
4705
  )
4703
4706
  ] }),
4704
4707
  isParent && !editingName && /* @__PURE__ */ jsxs9(Fragment2, { children: [
4705
- !isCollapsed && /* @__PURE__ */ jsx12(
4708
+ !isFilterHideMode && !isCollapsed && /* @__PURE__ */ jsx12(
4706
4709
  "span",
4707
4710
  {
4708
4711
  style: {
@@ -5310,7 +5313,10 @@ var TaskList = ({
5310
5313
  customDays,
5311
5314
  isWeekend: isWeekend3,
5312
5315
  businessDays,
5313
- highlightedTaskIds = /* @__PURE__ */ new Set()
5316
+ highlightedTaskIds = /* @__PURE__ */ new Set(),
5317
+ filterMode = "highlight",
5318
+ filteredTaskIds = /* @__PURE__ */ new Set(),
5319
+ isFilterActive = false
5314
5320
  }) => {
5315
5321
  const [internalCollapsedParentIds, setInternalCollapsedParentIds] = useState6(/* @__PURE__ */ new Set());
5316
5322
  const collapsedParentIds = externalCollapsedParentIds ?? internalCollapsedParentIds;
@@ -5342,8 +5348,12 @@ var TaskList = ({
5342
5348
  }
5343
5349
  return false;
5344
5350
  }
5345
- return orderedTasks.filter((task) => !isAnyAncestorCollapsed(task.parentId));
5346
- }, [orderedTasks, collapsedParentIds]);
5351
+ let tasks2 = orderedTasks.filter((task) => !isAnyAncestorCollapsed(task.parentId));
5352
+ if (filterMode === "hide" && isFilterActive) {
5353
+ tasks2 = tasks2.filter((task) => filteredTaskIds.has(task.id));
5354
+ }
5355
+ return tasks2;
5356
+ }, [orderedTasks, collapsedParentIds, filterMode, filteredTaskIds, isFilterActive]);
5347
5357
  const totalHeight = useMemo8(
5348
5358
  () => visibleTasks.length * rowHeight,
5349
5359
  [visibleTasks.length, rowHeight]
@@ -5354,6 +5364,16 @@ var TaskList = ({
5354
5364
  ),
5355
5365
  [visibleTasks]
5356
5366
  );
5367
+ const originalTaskNumberMap = useMemo8(
5368
+ () => {
5369
+ const numberMap = /* @__PURE__ */ new Map();
5370
+ for (let i = 0; i < orderedTasks.length; i++) {
5371
+ numberMap.set(orderedTasks[i].id, getTaskNumber(orderedTasks, i));
5372
+ }
5373
+ return Object.fromEntries(numberMap);
5374
+ },
5375
+ [orderedTasks]
5376
+ );
5357
5377
  const nestingDepthMap = useMemo8(() => {
5358
5378
  const depthMap = /* @__PURE__ */ new Map();
5359
5379
  const taskById = new Map(tasks.map((t) => [t.id, t]));
@@ -5775,8 +5795,8 @@ var TaskList = ({
5775
5795
  {
5776
5796
  task,
5777
5797
  rowIndex: index,
5778
- taskNumber: getTaskNumber(visibleTasks, index),
5779
- taskNumberMap: visibleTaskNumberMap,
5798
+ taskNumber: originalTaskNumberMap[task.id] || "",
5799
+ taskNumberMap: originalTaskNumberMap,
5780
5800
  rowHeight,
5781
5801
  onTasksChange,
5782
5802
  selectedTaskId,
@@ -5815,7 +5835,8 @@ var TaskList = ({
5815
5835
  customDays,
5816
5836
  isWeekend: isWeekend3,
5817
5837
  businessDays,
5818
- isFilterMatch: highlightedTaskIds.has(task.id)
5838
+ isFilterMatch: filterMode === "highlight" ? highlightedTaskIds.has(task.id) : false,
5839
+ isFilterHideMode: filterMode === "hide" && isFilterActive
5819
5840
  },
5820
5841
  task.id
5821
5842
  )) }),
@@ -5889,10 +5910,12 @@ var GanttChart = forwardRef(({
5889
5910
  isWeekend: isWeekend3,
5890
5911
  businessDays = true,
5891
5912
  taskFilter,
5913
+ filterMode = "highlight",
5892
5914
  collapsedParentIds: externalCollapsedParentIds,
5893
5915
  onToggleCollapse: externalOnToggleCollapse,
5894
5916
  highlightedTaskIds,
5895
- disableTaskDrag = false
5917
+ disableTaskDrag = false,
5918
+ showChart = true
5896
5919
  }, ref) => {
5897
5920
  const scrollContainerRef = useRef7(null);
5898
5921
  const [selectedTaskId, setSelectedTaskId] = useState7(null);
@@ -5923,20 +5946,27 @@ var GanttChart = forwardRef(({
5923
5946
  }
5924
5947
  return false;
5925
5948
  }
5926
- return normalizedTasks.filter((task) => !isAnyAncestorCollapsed(task.parentId));
5927
- }, [normalizedTasks, collapsedParentIds]);
5949
+ let tasks2 = normalizedTasks.filter((task) => !isAnyAncestorCollapsed(task.parentId));
5950
+ if (filterMode === "hide" && taskFilter) {
5951
+ tasks2 = tasks2.filter(taskFilter);
5952
+ }
5953
+ return tasks2;
5954
+ }, [normalizedTasks, collapsedParentIds, filterMode, taskFilter]);
5928
5955
  const matchedTaskIds = useMemo9(() => {
5929
5956
  if (!taskFilter) return /* @__PURE__ */ new Set();
5930
5957
  return new Set(visibleTasks.filter(taskFilter).map((task) => task.id));
5931
5958
  }, [visibleTasks, taskFilter]);
5932
5959
  const taskListHighlightedTaskIds = useMemo9(() => {
5960
+ if (filterMode === "hide") {
5961
+ return /* @__PURE__ */ new Set();
5962
+ }
5933
5963
  if ((!highlightedTaskIds || highlightedTaskIds.size === 0) && matchedTaskIds.size === 0) {
5934
5964
  return /* @__PURE__ */ new Set();
5935
5965
  }
5936
5966
  const mergedHighlightedTaskIds = new Set(highlightedTaskIds ?? []);
5937
5967
  matchedTaskIds.forEach((taskId) => mergedHighlightedTaskIds.add(taskId));
5938
5968
  return mergedHighlightedTaskIds;
5939
- }, [highlightedTaskIds, matchedTaskIds]);
5969
+ }, [filterMode, highlightedTaskIds, matchedTaskIds]);
5940
5970
  const totalGridHeight = useMemo9(
5941
5971
  () => visibleTasks.length * rowHeight,
5942
5972
  [visibleTasks.length, rowHeight]
@@ -6352,10 +6382,13 @@ var GanttChart = forwardRef(({
6352
6382
  highlightedTaskIds: taskListHighlightedTaskIds,
6353
6383
  customDays,
6354
6384
  isWeekend: isWeekend3,
6355
- businessDays
6385
+ businessDays,
6386
+ filterMode,
6387
+ filteredTaskIds: matchedTaskIds,
6388
+ isFilterActive: !!taskFilter
6356
6389
  }
6357
6390
  ),
6358
- /* @__PURE__ */ jsxs12("div", { style: { minWidth: `${gridWidth}px`, flex: 1 }, children: [
6391
+ /* @__PURE__ */ jsxs12("div", { className: showChart ? "" : "gantt-chart-hidden", style: { minWidth: `${gridWidth}px`, flex: 1 }, children: [
6359
6392
  /* @__PURE__ */ jsx15("div", { className: "gantt-stickyHeader", style: { width: `${gridWidth}px` }, children: /* @__PURE__ */ jsx15(
6360
6393
  TimeScaleHeader_default,
6361
6394
  {
@@ -6437,7 +6470,7 @@ var GanttChart = forwardRef(({
6437
6470
  onCascadeProgress: handleCascadeProgress,
6438
6471
  onCascade: handleCascade,
6439
6472
  highlightExpiredTasks,
6440
- isFilterMatch: matchedTaskIds.has(task.id),
6473
+ isFilterMatch: filterMode === "highlight" ? matchedTaskIds.has(task.id) : false,
6441
6474
  businessDays,
6442
6475
  customDays,
6443
6476
  isWeekend: isWeekend3,