gantt-lib 0.120.0 → 0.121.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
@@ -3457,6 +3457,24 @@ var DependencyLines = React6.memo(({
3457
3457
  });
3458
3458
  }
3459
3459
  }
3460
+ if (allTasks) {
3461
+ for (const task of allTasks) {
3462
+ if (positions.has(task.id)) continue;
3463
+ if (collapsedParentIds.size > 0 && isTaskHidden(task.id, collapsedParentIds, taskMap)) continue;
3464
+ hidden.add(task.id);
3465
+ const override = dragOverrides?.get(task.id);
3466
+ const computed = resolveTaskHorizontalGeometry(task, monthStart, dayWidth, override);
3467
+ const rowIndex = rowIndexByTaskId?.get(task.id);
3468
+ const rowTop = rowIndex !== void 0 ? rowIndex * rowHeight : 0;
3469
+ positions.set(task.id, {
3470
+ left: computed.left,
3471
+ right: computed.right,
3472
+ centerX: computed.centerX,
3473
+ rowTop,
3474
+ isVirtual: false
3475
+ });
3476
+ }
3477
+ }
3460
3478
  return { taskPositions: positions, taskIndices: indices, hiddenTaskIds: hidden };
3461
3479
  }, [tasks, tasksForPositions, allTasks, collapsedParentIds, monthStart, dayWidth, rowHeight, dragOverrides, rowIndexByTaskId]);
3462
3480
  const cycleInfo = useMemo6(() => {
@@ -3469,6 +3487,7 @@ var DependencyLines = React6.memo(({
3469
3487
  const tasksForEdges = allTasks ?? tasks;
3470
3488
  const taskMap = new Map(tasksForEdges.map((task) => [task.id, task]));
3471
3489
  const positionedTaskIds = Array.from(taskPositions.keys());
3490
+ const renderedTaskIdSet = new Set(tasks.map((t) => t.id));
3472
3491
  const lines2 = [];
3473
3492
  for (const successorId of positionedTaskIds) {
3474
3493
  const successorTaskForEdges = taskMap.get(successorId);
@@ -3499,6 +3518,9 @@ var DependencyLines = React6.memo(({
3499
3518
  continue;
3500
3519
  }
3501
3520
  }
3521
+ if (!renderedTaskIdSet.has(edge.predecessorId) && !renderedTaskIdSet.has(edge.successorId)) {
3522
+ continue;
3523
+ }
3502
3524
  const isVirtual = predecessor.isVirtual || successor.isVirtual;
3503
3525
  let reverseOrder = false;
3504
3526
  if (predecessorIndex !== void 0 && successorIndex !== void 0) {
@@ -10213,7 +10235,8 @@ function TableMatrix({
10213
10235
  onCellClick,
10214
10236
  dateOverlay,
10215
10237
  highlightedTaskIds,
10216
- filterMode = "highlight"
10238
+ filterMode = "highlight",
10239
+ visibleRowIndices
10217
10240
  }) {
10218
10241
  const measureRef = useRef9(null);
10219
10242
  const [measuredAutoWidths, setMeasuredAutoWidths] = useState9([]);
@@ -10340,6 +10363,15 @@ function TableMatrix({
10340
10363
  }
10341
10364
  return depthMap;
10342
10365
  }, [allTasks]);
10366
+ const renderedRows = useMemo11(() => {
10367
+ if (!visibleRowIndices) {
10368
+ return tasks.map((task, index) => ({ task, index }));
10369
+ }
10370
+ return visibleRowIndices.map((index) => {
10371
+ const task = tasks[index];
10372
+ return task ? { task, index } : null;
10373
+ }).filter((entry) => entry !== null);
10374
+ }, [tasks, visibleRowIndices]);
10343
10375
  return /* @__PURE__ */ jsxs13("div", { className: "gantt-mx-root", style: { width: `${totalWidth}px` }, children: [
10344
10376
  hasAutoWidthColumns && /* @__PURE__ */ jsxs13("div", { ref: measureRef, className: "gantt-mx-measure", "aria-hidden": "true", children: [
10345
10377
  columns.map((column, columnIndex) => typeof column.width === "number" ? null : /* @__PURE__ */ jsx17(
@@ -10425,7 +10457,7 @@ function TableMatrix({
10425
10457
  height: `${tasks.length * rowHeight}px`,
10426
10458
  minHeight: bodyMinHeight
10427
10459
  },
10428
- children: tasks.map((task, index) => {
10460
+ children: renderedRows.map(({ task, index }) => {
10429
10461
  const isHighlighted = filterMode === "highlight" && !!highlightedTaskIds?.has(task.id);
10430
10462
  const isParent = parentTaskIds.has(task.id);
10431
10463
  const nestingDepth = nestingDepthMap.get(task.id) ?? 0;
@@ -11933,6 +11965,33 @@ var SCROLL_TO_ROW_CONTEXT_ROWS = 2;
11933
11965
  var TASK_ROW_OVERSCAN = 8;
11934
11966
  var PLAN_FACT_COLUMN_OVERSCAN = 24;
11935
11967
  var PLAN_FACT_COLUMN_WINDOW_STEP = 14;
11968
+ function getInitialScrollViewportHeight(containerHeight, headerHeight) {
11969
+ if (containerHeight === void 0) {
11970
+ return 0;
11971
+ }
11972
+ if (typeof containerHeight === "number") {
11973
+ return Math.max(0, containerHeight - headerHeight);
11974
+ }
11975
+ if (typeof window === "undefined") {
11976
+ return 0;
11977
+ }
11978
+ const dynamicViewportMatch = containerHeight.match(/^([\d.]+)dvh$/);
11979
+ if (dynamicViewportMatch) {
11980
+ const ratio = Number(dynamicViewportMatch[1]);
11981
+ return Number.isFinite(ratio) ? Math.max(0, window.innerHeight * (ratio / 100) - headerHeight) : 0;
11982
+ }
11983
+ const viewportMatch = containerHeight.match(/^([\d.]+)vh$/);
11984
+ if (viewportMatch) {
11985
+ const ratio = Number(viewportMatch[1]);
11986
+ return Number.isFinite(ratio) ? Math.max(0, window.innerHeight * (ratio / 100) - headerHeight) : 0;
11987
+ }
11988
+ const pixelMatch = containerHeight.match(/^([\d.]+)px$/);
11989
+ if (pixelMatch) {
11990
+ const height = Number(pixelMatch[1]);
11991
+ return Number.isFinite(height) ? Math.max(0, height - headerHeight) : 0;
11992
+ }
11993
+ return 0;
11994
+ }
11936
11995
  function waitForNextPaint2(win) {
11937
11996
  return new Promise((resolve) => {
11938
11997
  if (typeof win.requestAnimationFrame === "function") {
@@ -12116,7 +12175,10 @@ function TaskGanttChartInner(props, ref) {
12116
12175
  const [selectedTaskId, setSelectedTaskId] = useState11(null);
12117
12176
  const [taskListHasRightShadow, setTaskListHasRightShadow] = useState11(false);
12118
12177
  const [internalTaskDateChangeMode, setInternalTaskDateChangeMode] = useState11("preserve-duration");
12119
- const [scrollViewport, setScrollViewport] = useState11({ scrollTop: 0, viewportHeight: 0 });
12178
+ const [scrollViewport, setScrollViewport] = useState11(() => ({
12179
+ scrollTop: 0,
12180
+ viewportHeight: getInitialScrollViewportHeight(containerHeight, headerHeight + 1)
12181
+ }));
12120
12182
  const [forceFullRenderForPrint, setForceFullRenderForPrint] = useState11(false);
12121
12183
  const [planFactDateWindow, setPlanFactDateWindow] = useState11(null);
12122
12184
  const [selectedChip, setSelectedChip] = useState11(null);
@@ -12265,7 +12327,7 @@ function TaskGanttChartInner(props, ref) {
12265
12327
  (previous) => previous === nextHasRightShadow ? previous : nextHasRightShadow
12266
12328
  );
12267
12329
  setScrollViewport(
12268
- (previous) => previous.scrollTop === nextScrollTop && previous.viewportHeight === nextViewportHeight ? previous : { scrollTop: nextScrollTop, viewportHeight: nextViewportHeight }
12330
+ (previous) => previous.viewportHeight > 0 && nextViewportHeight === 0 ? { scrollTop: nextScrollTop, viewportHeight: previous.viewportHeight } : previous.scrollTop === nextScrollTop && previous.viewportHeight === nextViewportHeight ? previous : { scrollTop: nextScrollTop, viewportHeight: nextViewportHeight }
12269
12331
  );
12270
12332
  setPlanFactDateWindow((previous) => {
12271
12333
  if (!isPlanFactMode || dateRange.length === 0 || nextViewportWidth <= 0) {
@@ -12931,7 +12993,7 @@ function TaskGanttChartInner(props, ref) {
12931
12993
  onDelete: handleDelete,
12932
12994
  onInsertAfter: handleInsertAfter,
12933
12995
  onReorder: handleReorder,
12934
- disableTaskDrag: disableTaskListReorder,
12996
+ disableTaskDrag: disableTaskDrag || disableTaskListReorder,
12935
12997
  editingTaskId,
12936
12998
  enableAddTask,
12937
12999
  defaultTaskDurationDays,
@@ -12991,7 +13053,8 @@ function TaskGanttChartInner(props, ref) {
12991
13053
  onCellClick: onMatrixCellClick,
12992
13054
  dateOverlay: matrixDateOverlay,
12993
13055
  highlightedTaskIds: taskListHighlightedTaskIds,
12994
- filterMode
13056
+ filterMode,
13057
+ visibleRowIndices: visibleTaskWindowIndices
12995
13058
  }
12996
13059
  ) : isPlanFactMode ? /* @__PURE__ */ jsx19(
12997
13060
  PlanFactMatrix,