gantt-lib 0.120.1 → 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.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +47 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -391,8 +391,9 @@ interface TableMatrixProps<TTask extends Task = Task> {
|
|
|
391
391
|
dateOverlay?: TableMatrixDateOverlay<TTask> | false;
|
|
392
392
|
highlightedTaskIds?: Set<string>;
|
|
393
393
|
filterMode?: 'highlight' | 'hide';
|
|
394
|
+
visibleRowIndices?: number[];
|
|
394
395
|
}
|
|
395
|
-
declare function TableMatrix<TTask extends Task = Task>({ tasks, allTasks, columns, columnGroups, rowHeight, headerHeight, bodyMinHeight, selectedTaskId, onTaskSelect, onCellClick, dateOverlay, highlightedTaskIds, filterMode, }: TableMatrixProps<TTask>): react_jsx_runtime.JSX.Element;
|
|
396
|
+
declare function TableMatrix<TTask extends Task = Task>({ tasks, allTasks, columns, columnGroups, rowHeight, headerHeight, bodyMinHeight, selectedTaskId, onTaskSelect, onCellClick, dateOverlay, highlightedTaskIds, filterMode, visibleRowIndices, }: TableMatrixProps<TTask>): react_jsx_runtime.JSX.Element;
|
|
396
397
|
|
|
397
398
|
type PlanFactCellKind = 'plan' | 'fact';
|
|
398
399
|
interface PlanFactCellCommitContext<TTask extends Task = Task> {
|
package/dist/index.d.ts
CHANGED
|
@@ -391,8 +391,9 @@ interface TableMatrixProps<TTask extends Task = Task> {
|
|
|
391
391
|
dateOverlay?: TableMatrixDateOverlay<TTask> | false;
|
|
392
392
|
highlightedTaskIds?: Set<string>;
|
|
393
393
|
filterMode?: 'highlight' | 'hide';
|
|
394
|
+
visibleRowIndices?: number[];
|
|
394
395
|
}
|
|
395
|
-
declare function TableMatrix<TTask extends Task = Task>({ tasks, allTasks, columns, columnGroups, rowHeight, headerHeight, bodyMinHeight, selectedTaskId, onTaskSelect, onCellClick, dateOverlay, highlightedTaskIds, filterMode, }: TableMatrixProps<TTask>): react_jsx_runtime.JSX.Element;
|
|
396
|
+
declare function TableMatrix<TTask extends Task = Task>({ tasks, allTasks, columns, columnGroups, rowHeight, headerHeight, bodyMinHeight, selectedTaskId, onTaskSelect, onCellClick, dateOverlay, highlightedTaskIds, filterMode, visibleRowIndices, }: TableMatrixProps<TTask>): react_jsx_runtime.JSX.Element;
|
|
396
397
|
|
|
397
398
|
type PlanFactCellKind = 'plan' | 'fact';
|
|
398
399
|
interface PlanFactCellCommitContext<TTask extends Task = Task> {
|
package/dist/index.js
CHANGED
|
@@ -10354,7 +10354,8 @@ function TableMatrix({
|
|
|
10354
10354
|
onCellClick,
|
|
10355
10355
|
dateOverlay,
|
|
10356
10356
|
highlightedTaskIds,
|
|
10357
|
-
filterMode = "highlight"
|
|
10357
|
+
filterMode = "highlight",
|
|
10358
|
+
visibleRowIndices
|
|
10358
10359
|
}) {
|
|
10359
10360
|
const measureRef = (0, import_react16.useRef)(null);
|
|
10360
10361
|
const [measuredAutoWidths, setMeasuredAutoWidths] = (0, import_react16.useState)([]);
|
|
@@ -10481,6 +10482,15 @@ function TableMatrix({
|
|
|
10481
10482
|
}
|
|
10482
10483
|
return depthMap;
|
|
10483
10484
|
}, [allTasks]);
|
|
10485
|
+
const renderedRows = (0, import_react16.useMemo)(() => {
|
|
10486
|
+
if (!visibleRowIndices) {
|
|
10487
|
+
return tasks.map((task, index) => ({ task, index }));
|
|
10488
|
+
}
|
|
10489
|
+
return visibleRowIndices.map((index) => {
|
|
10490
|
+
const task = tasks[index];
|
|
10491
|
+
return task ? { task, index } : null;
|
|
10492
|
+
}).filter((entry) => entry !== null);
|
|
10493
|
+
}, [tasks, visibleRowIndices]);
|
|
10484
10494
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "gantt-mx-root", style: { width: `${totalWidth}px` }, children: [
|
|
10485
10495
|
hasAutoWidthColumns && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { ref: measureRef, className: "gantt-mx-measure", "aria-hidden": "true", children: [
|
|
10486
10496
|
columns.map((column, columnIndex) => typeof column.width === "number" ? null : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
@@ -10566,7 +10576,7 @@ function TableMatrix({
|
|
|
10566
10576
|
height: `${tasks.length * rowHeight}px`,
|
|
10567
10577
|
minHeight: bodyMinHeight
|
|
10568
10578
|
},
|
|
10569
|
-
children:
|
|
10579
|
+
children: renderedRows.map(({ task, index }) => {
|
|
10570
10580
|
const isHighlighted = filterMode === "highlight" && !!highlightedTaskIds?.has(task.id);
|
|
10571
10581
|
const isParent = parentTaskIds.has(task.id);
|
|
10572
10582
|
const nestingDepth = nestingDepthMap.get(task.id) ?? 0;
|
|
@@ -12074,6 +12084,33 @@ var SCROLL_TO_ROW_CONTEXT_ROWS = 2;
|
|
|
12074
12084
|
var TASK_ROW_OVERSCAN = 8;
|
|
12075
12085
|
var PLAN_FACT_COLUMN_OVERSCAN = 24;
|
|
12076
12086
|
var PLAN_FACT_COLUMN_WINDOW_STEP = 14;
|
|
12087
|
+
function getInitialScrollViewportHeight(containerHeight, headerHeight) {
|
|
12088
|
+
if (containerHeight === void 0) {
|
|
12089
|
+
return 0;
|
|
12090
|
+
}
|
|
12091
|
+
if (typeof containerHeight === "number") {
|
|
12092
|
+
return Math.max(0, containerHeight - headerHeight);
|
|
12093
|
+
}
|
|
12094
|
+
if (typeof window === "undefined") {
|
|
12095
|
+
return 0;
|
|
12096
|
+
}
|
|
12097
|
+
const dynamicViewportMatch = containerHeight.match(/^([\d.]+)dvh$/);
|
|
12098
|
+
if (dynamicViewportMatch) {
|
|
12099
|
+
const ratio = Number(dynamicViewportMatch[1]);
|
|
12100
|
+
return Number.isFinite(ratio) ? Math.max(0, window.innerHeight * (ratio / 100) - headerHeight) : 0;
|
|
12101
|
+
}
|
|
12102
|
+
const viewportMatch = containerHeight.match(/^([\d.]+)vh$/);
|
|
12103
|
+
if (viewportMatch) {
|
|
12104
|
+
const ratio = Number(viewportMatch[1]);
|
|
12105
|
+
return Number.isFinite(ratio) ? Math.max(0, window.innerHeight * (ratio / 100) - headerHeight) : 0;
|
|
12106
|
+
}
|
|
12107
|
+
const pixelMatch = containerHeight.match(/^([\d.]+)px$/);
|
|
12108
|
+
if (pixelMatch) {
|
|
12109
|
+
const height = Number(pixelMatch[1]);
|
|
12110
|
+
return Number.isFinite(height) ? Math.max(0, height - headerHeight) : 0;
|
|
12111
|
+
}
|
|
12112
|
+
return 0;
|
|
12113
|
+
}
|
|
12077
12114
|
function waitForNextPaint2(win) {
|
|
12078
12115
|
return new Promise((resolve) => {
|
|
12079
12116
|
if (typeof win.requestAnimationFrame === "function") {
|
|
@@ -12257,7 +12294,10 @@ function TaskGanttChartInner(props, ref) {
|
|
|
12257
12294
|
const [selectedTaskId, setSelectedTaskId] = (0, import_react18.useState)(null);
|
|
12258
12295
|
const [taskListHasRightShadow, setTaskListHasRightShadow] = (0, import_react18.useState)(false);
|
|
12259
12296
|
const [internalTaskDateChangeMode, setInternalTaskDateChangeMode] = (0, import_react18.useState)("preserve-duration");
|
|
12260
|
-
const [scrollViewport, setScrollViewport] = (0, import_react18.useState)(
|
|
12297
|
+
const [scrollViewport, setScrollViewport] = (0, import_react18.useState)(() => ({
|
|
12298
|
+
scrollTop: 0,
|
|
12299
|
+
viewportHeight: getInitialScrollViewportHeight(containerHeight, headerHeight + 1)
|
|
12300
|
+
}));
|
|
12261
12301
|
const [forceFullRenderForPrint, setForceFullRenderForPrint] = (0, import_react18.useState)(false);
|
|
12262
12302
|
const [planFactDateWindow, setPlanFactDateWindow] = (0, import_react18.useState)(null);
|
|
12263
12303
|
const [selectedChip, setSelectedChip] = (0, import_react18.useState)(null);
|
|
@@ -12406,7 +12446,7 @@ function TaskGanttChartInner(props, ref) {
|
|
|
12406
12446
|
(previous) => previous === nextHasRightShadow ? previous : nextHasRightShadow
|
|
12407
12447
|
);
|
|
12408
12448
|
setScrollViewport(
|
|
12409
|
-
(previous) => previous.scrollTop === nextScrollTop && previous.viewportHeight === nextViewportHeight ? previous : { scrollTop: nextScrollTop, viewportHeight: nextViewportHeight }
|
|
12449
|
+
(previous) => previous.viewportHeight > 0 && nextViewportHeight === 0 ? { scrollTop: nextScrollTop, viewportHeight: previous.viewportHeight } : previous.scrollTop === nextScrollTop && previous.viewportHeight === nextViewportHeight ? previous : { scrollTop: nextScrollTop, viewportHeight: nextViewportHeight }
|
|
12410
12450
|
);
|
|
12411
12451
|
setPlanFactDateWindow((previous) => {
|
|
12412
12452
|
if (!isPlanFactMode || dateRange.length === 0 || nextViewportWidth <= 0) {
|
|
@@ -13072,7 +13112,7 @@ function TaskGanttChartInner(props, ref) {
|
|
|
13072
13112
|
onDelete: handleDelete,
|
|
13073
13113
|
onInsertAfter: handleInsertAfter,
|
|
13074
13114
|
onReorder: handleReorder,
|
|
13075
|
-
disableTaskDrag: disableTaskListReorder,
|
|
13115
|
+
disableTaskDrag: disableTaskDrag || disableTaskListReorder,
|
|
13076
13116
|
editingTaskId,
|
|
13077
13117
|
enableAddTask,
|
|
13078
13118
|
defaultTaskDurationDays,
|
|
@@ -13132,7 +13172,8 @@ function TaskGanttChartInner(props, ref) {
|
|
|
13132
13172
|
onCellClick: onMatrixCellClick,
|
|
13133
13173
|
dateOverlay: matrixDateOverlay,
|
|
13134
13174
|
highlightedTaskIds: taskListHighlightedTaskIds,
|
|
13135
|
-
filterMode
|
|
13175
|
+
filterMode,
|
|
13176
|
+
visibleRowIndices: visibleTaskWindowIndices
|
|
13136
13177
|
}
|
|
13137
13178
|
) : isPlanFactMode ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
13138
13179
|
PlanFactMatrix,
|