gantt-task-react-v 1.7.3 → 1.7.4
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.
|
@@ -5,5 +5,6 @@ export declare const useTableListResize: (clientColumns: readonly Column[] | und
|
|
|
5
5
|
taskListWidth: number,
|
|
6
6
|
tableWidth: number,
|
|
7
7
|
onTableResizeStart: (clientX: number) => void,
|
|
8
|
-
onColumnResizeStart: (columnIndex: number, clientX: number) => void
|
|
8
|
+
onColumnResizeStart: (columnIndex: number, clientX: number) => void,
|
|
9
|
+
handleColumnVisibilityChange: (columnId: string, hidden: boolean) => void
|
|
9
10
|
];
|
|
@@ -5378,22 +5378,16 @@ const useTableListResize = (clientColumns, canMoveTasks, onResizeColumn, ganttRe
|
|
|
5378
5378
|
useEffect(() => {
|
|
5379
5379
|
if (clientColumns) {
|
|
5380
5380
|
setColumns([...clientColumns]);
|
|
5381
|
-
const
|
|
5382
|
-
const newColumnIds = clientColumns.map((col) => col.id);
|
|
5383
|
-
const widthOfAddedColumns = clientColumns.filter((col) => !currentColumnIds.includes(col.id)).reduce((res, { width }) => res + width, 0);
|
|
5384
|
-
const widthOfRemovedColumns = clientColumns.filter((col) => !newColumnIds.includes(col.id)).reduce((res, { width }) => res + width, 0);
|
|
5381
|
+
const visibleColumns = clientColumns.filter((col) => !col.hidden);
|
|
5385
5382
|
setTableWidth(
|
|
5386
|
-
(
|
|
5387
|
-
prev + widthOfAddedColumns - widthOfRemovedColumns,
|
|
5388
|
-
clientColumns.reduce((res, { width }) => res + width, 0) + extraWidth
|
|
5389
|
-
)
|
|
5383
|
+
visibleColumns.reduce((res, { width }) => res + width, 0) + extraWidth
|
|
5390
5384
|
);
|
|
5391
5385
|
}
|
|
5392
5386
|
}, [clientColumns, extraWidth]);
|
|
5393
5387
|
const [tableResizeEvent, setTableResizeEvent] = useState(null);
|
|
5394
5388
|
const [columnResizeEvent, setColumnResizeEvent] = useState(null);
|
|
5395
5389
|
const [tableWidthState, setTableWidth] = useState(
|
|
5396
|
-
() => columnsState.reduce((res, { width }) => res + width, 0) + extraWidth
|
|
5390
|
+
() => columnsState.filter((c) => !c.hidden).reduce((res, { width }) => res + width, 0) + extraWidth
|
|
5397
5391
|
);
|
|
5398
5392
|
const onTableResizeStart = (clientX) => {
|
|
5399
5393
|
const newTableResizeEvent = {
|
|
@@ -5411,9 +5405,19 @@ const useTableListResize = (clientColumns, canMoveTasks, onResizeColumn, ganttRe
|
|
|
5411
5405
|
initialTableWidth: tableWidthState
|
|
5412
5406
|
});
|
|
5413
5407
|
};
|
|
5408
|
+
const handleColumnVisibilityChange = (columnId, hidden2) => {
|
|
5409
|
+
setColumns((prev) => {
|
|
5410
|
+
const next = prev.map(
|
|
5411
|
+
(col) => col.id === columnId ? { ...col, hidden: hidden2 } : col
|
|
5412
|
+
);
|
|
5413
|
+
const visibleWidth = next.filter((c) => !c.hidden).reduce((s, { width }) => s + width, 0) + extraWidth;
|
|
5414
|
+
setTableWidth(visibleWidth);
|
|
5415
|
+
return next;
|
|
5416
|
+
});
|
|
5417
|
+
};
|
|
5414
5418
|
const isResizeTableInProgress = Boolean(tableResizeEvent);
|
|
5415
5419
|
const isResizeColumnInProgress = Boolean(columnResizeEvent);
|
|
5416
|
-
const taskListWidth = columnsState.reduce((res, { width }) => res + width, 0) + extraWidth;
|
|
5420
|
+
const taskListWidth = columnsState.filter((c) => !c.hidden).reduce((res, { width }) => res + width, 0) + extraWidth;
|
|
5417
5421
|
useEffect(() => {
|
|
5418
5422
|
if (!isResizeTableInProgress) {
|
|
5419
5423
|
return void 0;
|
|
@@ -5534,7 +5538,8 @@ const useTableListResize = (clientColumns, canMoveTasks, onResizeColumn, ganttRe
|
|
|
5534
5538
|
taskListWidth,
|
|
5535
5539
|
tableWidthState,
|
|
5536
5540
|
onTableResizeStart,
|
|
5537
|
-
onColumnResizeStart
|
|
5541
|
+
onColumnResizeStart,
|
|
5542
|
+
handleColumnVisibilityChange
|
|
5538
5543
|
];
|
|
5539
5544
|
};
|
|
5540
5545
|
const toggleWrapper = "_toggleWrapper_rjfhl_1";
|
|
@@ -10450,7 +10455,7 @@ const TaskListTableRowInner = forwardRef(
|
|
|
10450
10455
|
if (isOverlay2) {
|
|
10451
10456
|
return "var(--gantt-table-drag-task-background-color)";
|
|
10452
10457
|
}
|
|
10453
|
-
return isSelected ? "var(--gantt-table-selected-task-background-color)" : isEven ? "var(--gantt-table-even-background-color)" :
|
|
10458
|
+
return isSelected ? "var(--gantt-table-selected-task-background-color)" : isEven ? "var(--gantt-table-even-background-color)" : "var(--gantt-background-color, #fff)";
|
|
10454
10459
|
}, [isEven, isOverlay2, isSelected]);
|
|
10455
10460
|
const rowClassName = useMemo(() => {
|
|
10456
10461
|
const classNames = [styles$h.taskListTableRow];
|
|
@@ -10470,35 +10475,28 @@ const TaskListTableRowInner = forwardRef(
|
|
|
10470
10475
|
}, [isCut2, moveOverPosition, isOverlay2, isDragging]);
|
|
10471
10476
|
const pinnedStyles = useMemo(() => {
|
|
10472
10477
|
const result = {};
|
|
10473
|
-
let leftOffset = 0;
|
|
10474
|
-
if (moveHandleProps || !isOverlay2 && task.type !== "project" && task.id !== "no-project-asigned") {
|
|
10475
|
-
leftOffset = 24;
|
|
10476
|
-
}
|
|
10477
10478
|
for (let i = 0; i < columns.length; i++) {
|
|
10478
10479
|
if (columns[i].pinned === "left") {
|
|
10479
10480
|
result[i] = {
|
|
10480
|
-
position: "
|
|
10481
|
-
|
|
10482
|
-
zIndex:
|
|
10481
|
+
position: "relative",
|
|
10482
|
+
transform: "translateX(var(--pinned-translate-left, 0px))",
|
|
10483
|
+
zIndex: 2,
|
|
10483
10484
|
backgroundColor: "inherit"
|
|
10484
10485
|
};
|
|
10485
|
-
leftOffset += columns[i].width;
|
|
10486
10486
|
}
|
|
10487
10487
|
}
|
|
10488
|
-
let rightOffset = 0;
|
|
10489
10488
|
for (let i = columns.length - 1; i >= 0; i--) {
|
|
10490
10489
|
if (columns[i].pinned === "right") {
|
|
10491
10490
|
result[i] = {
|
|
10492
|
-
position: "
|
|
10493
|
-
|
|
10494
|
-
zIndex:
|
|
10491
|
+
position: "relative",
|
|
10492
|
+
transform: "translateX(var(--pinned-translate-right, 0px))",
|
|
10493
|
+
zIndex: 2,
|
|
10495
10494
|
backgroundColor: "inherit"
|
|
10496
10495
|
};
|
|
10497
|
-
rightOffset += columns[i].width;
|
|
10498
10496
|
}
|
|
10499
10497
|
}
|
|
10500
10498
|
return result;
|
|
10501
|
-
}, [columns
|
|
10499
|
+
}, [columns]);
|
|
10502
10500
|
return /* @__PURE__ */ jsxs(
|
|
10503
10501
|
"div",
|
|
10504
10502
|
{
|
|
@@ -11169,17 +11167,55 @@ const TaskListInner = ({
|
|
|
11169
11167
|
taskListWidth,
|
|
11170
11168
|
tableWidth,
|
|
11171
11169
|
onTableResizeStart,
|
|
11172
|
-
onColumnResizeStart
|
|
11170
|
+
onColumnResizeStart,
|
|
11171
|
+
internalColumnVisibilityChange
|
|
11173
11172
|
] = useTableListResize(
|
|
11174
11173
|
columnsProp,
|
|
11175
11174
|
canReorderTasks,
|
|
11176
11175
|
onResizeColumn,
|
|
11177
11176
|
ganttRef
|
|
11178
11177
|
);
|
|
11178
|
+
const handleColumnVisibilityChange = useCallback(
|
|
11179
|
+
(columnId, hidden2) => {
|
|
11180
|
+
internalColumnVisibilityChange(columnId, hidden2);
|
|
11181
|
+
if (onColumnVisibilityChange) {
|
|
11182
|
+
onColumnVisibilityChange(columnId, hidden2);
|
|
11183
|
+
}
|
|
11184
|
+
},
|
|
11185
|
+
[internalColumnVisibilityChange, onColumnVisibilityChange]
|
|
11186
|
+
);
|
|
11179
11187
|
const columns = useMemo(
|
|
11180
11188
|
() => allColumns.filter((col) => !col.hidden),
|
|
11181
11189
|
[allColumns]
|
|
11182
11190
|
);
|
|
11191
|
+
const horizontalScrollRef = useRef(null);
|
|
11192
|
+
const setHorizontalScrollRef = useCallback(
|
|
11193
|
+
(el) => {
|
|
11194
|
+
horizontalScrollRef.current = el;
|
|
11195
|
+
if (taskListHorizontalScrollRef) {
|
|
11196
|
+
taskListHorizontalScrollRef.current = el;
|
|
11197
|
+
}
|
|
11198
|
+
},
|
|
11199
|
+
[taskListHorizontalScrollRef]
|
|
11200
|
+
);
|
|
11201
|
+
useEffect(() => {
|
|
11202
|
+
const scrollEl = horizontalScrollRef.current;
|
|
11203
|
+
const containerEl = taskListContainerRef.current;
|
|
11204
|
+
if (!scrollEl || !containerEl)
|
|
11205
|
+
return void 0;
|
|
11206
|
+
const update = () => {
|
|
11207
|
+
const sl = scrollEl.scrollLeft;
|
|
11208
|
+
const maxSl = scrollEl.scrollWidth - scrollEl.clientWidth;
|
|
11209
|
+
containerEl.style.setProperty("--pinned-translate-left", `${sl}px`);
|
|
11210
|
+
containerEl.style.setProperty(
|
|
11211
|
+
"--pinned-translate-right",
|
|
11212
|
+
`${sl - maxSl}px`
|
|
11213
|
+
);
|
|
11214
|
+
};
|
|
11215
|
+
update();
|
|
11216
|
+
scrollEl.addEventListener("scroll", update, { passive: true });
|
|
11217
|
+
return () => scrollEl.removeEventListener("scroll", update);
|
|
11218
|
+
}, [taskListContainerRef, taskListWidth, tableWidth]);
|
|
11183
11219
|
const renderedIndexes = useOptimizedList(
|
|
11184
11220
|
taskListContainerRef,
|
|
11185
11221
|
"scrollTop",
|
|
@@ -11256,7 +11292,7 @@ const TaskListInner = ({
|
|
|
11256
11292
|
/* @__PURE__ */ jsxs(
|
|
11257
11293
|
"div",
|
|
11258
11294
|
{
|
|
11259
|
-
ref:
|
|
11295
|
+
ref: setHorizontalScrollRef,
|
|
11260
11296
|
className: styles$e.taskListHorizontalScroll,
|
|
11261
11297
|
style: {
|
|
11262
11298
|
width: tableWidth
|
|
@@ -11271,7 +11307,7 @@ const TaskListInner = ({
|
|
|
11271
11307
|
allColumns,
|
|
11272
11308
|
canToggleColumns: !!canToggleColumns,
|
|
11273
11309
|
onColumnResizeStart,
|
|
11274
|
-
onColumnVisibilityChange,
|
|
11310
|
+
onColumnVisibilityChange: handleColumnVisibilityChange,
|
|
11275
11311
|
canResizeColumns
|
|
11276
11312
|
}
|
|
11277
11313
|
),
|
|
@@ -5395,22 +5395,16 @@
|
|
|
5395
5395
|
React.useEffect(() => {
|
|
5396
5396
|
if (clientColumns) {
|
|
5397
5397
|
setColumns([...clientColumns]);
|
|
5398
|
-
const
|
|
5399
|
-
const newColumnIds = clientColumns.map((col) => col.id);
|
|
5400
|
-
const widthOfAddedColumns = clientColumns.filter((col) => !currentColumnIds.includes(col.id)).reduce((res, { width }) => res + width, 0);
|
|
5401
|
-
const widthOfRemovedColumns = clientColumns.filter((col) => !newColumnIds.includes(col.id)).reduce((res, { width }) => res + width, 0);
|
|
5398
|
+
const visibleColumns = clientColumns.filter((col) => !col.hidden);
|
|
5402
5399
|
setTableWidth(
|
|
5403
|
-
(
|
|
5404
|
-
prev + widthOfAddedColumns - widthOfRemovedColumns,
|
|
5405
|
-
clientColumns.reduce((res, { width }) => res + width, 0) + extraWidth
|
|
5406
|
-
)
|
|
5400
|
+
visibleColumns.reduce((res, { width }) => res + width, 0) + extraWidth
|
|
5407
5401
|
);
|
|
5408
5402
|
}
|
|
5409
5403
|
}, [clientColumns, extraWidth]);
|
|
5410
5404
|
const [tableResizeEvent, setTableResizeEvent] = React.useState(null);
|
|
5411
5405
|
const [columnResizeEvent, setColumnResizeEvent] = React.useState(null);
|
|
5412
5406
|
const [tableWidthState, setTableWidth] = React.useState(
|
|
5413
|
-
() => columnsState.reduce((res, { width }) => res + width, 0) + extraWidth
|
|
5407
|
+
() => columnsState.filter((c) => !c.hidden).reduce((res, { width }) => res + width, 0) + extraWidth
|
|
5414
5408
|
);
|
|
5415
5409
|
const onTableResizeStart = (clientX) => {
|
|
5416
5410
|
const newTableResizeEvent = {
|
|
@@ -5428,9 +5422,19 @@
|
|
|
5428
5422
|
initialTableWidth: tableWidthState
|
|
5429
5423
|
});
|
|
5430
5424
|
};
|
|
5425
|
+
const handleColumnVisibilityChange = (columnId, hidden2) => {
|
|
5426
|
+
setColumns((prev) => {
|
|
5427
|
+
const next = prev.map(
|
|
5428
|
+
(col) => col.id === columnId ? { ...col, hidden: hidden2 } : col
|
|
5429
|
+
);
|
|
5430
|
+
const visibleWidth = next.filter((c) => !c.hidden).reduce((s, { width }) => s + width, 0) + extraWidth;
|
|
5431
|
+
setTableWidth(visibleWidth);
|
|
5432
|
+
return next;
|
|
5433
|
+
});
|
|
5434
|
+
};
|
|
5431
5435
|
const isResizeTableInProgress = Boolean(tableResizeEvent);
|
|
5432
5436
|
const isResizeColumnInProgress = Boolean(columnResizeEvent);
|
|
5433
|
-
const taskListWidth = columnsState.reduce((res, { width }) => res + width, 0) + extraWidth;
|
|
5437
|
+
const taskListWidth = columnsState.filter((c) => !c.hidden).reduce((res, { width }) => res + width, 0) + extraWidth;
|
|
5434
5438
|
React.useEffect(() => {
|
|
5435
5439
|
if (!isResizeTableInProgress) {
|
|
5436
5440
|
return void 0;
|
|
@@ -5551,7 +5555,8 @@
|
|
|
5551
5555
|
taskListWidth,
|
|
5552
5556
|
tableWidthState,
|
|
5553
5557
|
onTableResizeStart,
|
|
5554
|
-
onColumnResizeStart
|
|
5558
|
+
onColumnResizeStart,
|
|
5559
|
+
handleColumnVisibilityChange
|
|
5555
5560
|
];
|
|
5556
5561
|
};
|
|
5557
5562
|
const toggleWrapper = "_toggleWrapper_rjfhl_1";
|
|
@@ -10467,7 +10472,7 @@
|
|
|
10467
10472
|
if (isOverlay2) {
|
|
10468
10473
|
return "var(--gantt-table-drag-task-background-color)";
|
|
10469
10474
|
}
|
|
10470
|
-
return isSelected ? "var(--gantt-table-selected-task-background-color)" : isEven ? "var(--gantt-table-even-background-color)" :
|
|
10475
|
+
return isSelected ? "var(--gantt-table-selected-task-background-color)" : isEven ? "var(--gantt-table-even-background-color)" : "var(--gantt-background-color, #fff)";
|
|
10471
10476
|
}, [isEven, isOverlay2, isSelected]);
|
|
10472
10477
|
const rowClassName = React.useMemo(() => {
|
|
10473
10478
|
const classNames = [styles$h.taskListTableRow];
|
|
@@ -10487,35 +10492,28 @@
|
|
|
10487
10492
|
}, [isCut2, moveOverPosition, isOverlay2, isDragging]);
|
|
10488
10493
|
const pinnedStyles = React.useMemo(() => {
|
|
10489
10494
|
const result = {};
|
|
10490
|
-
let leftOffset = 0;
|
|
10491
|
-
if (moveHandleProps || !isOverlay2 && task.type !== "project" && task.id !== "no-project-asigned") {
|
|
10492
|
-
leftOffset = 24;
|
|
10493
|
-
}
|
|
10494
10495
|
for (let i = 0; i < columns.length; i++) {
|
|
10495
10496
|
if (columns[i].pinned === "left") {
|
|
10496
10497
|
result[i] = {
|
|
10497
|
-
position: "
|
|
10498
|
-
|
|
10499
|
-
zIndex:
|
|
10498
|
+
position: "relative",
|
|
10499
|
+
transform: "translateX(var(--pinned-translate-left, 0px))",
|
|
10500
|
+
zIndex: 2,
|
|
10500
10501
|
backgroundColor: "inherit"
|
|
10501
10502
|
};
|
|
10502
|
-
leftOffset += columns[i].width;
|
|
10503
10503
|
}
|
|
10504
10504
|
}
|
|
10505
|
-
let rightOffset = 0;
|
|
10506
10505
|
for (let i = columns.length - 1; i >= 0; i--) {
|
|
10507
10506
|
if (columns[i].pinned === "right") {
|
|
10508
10507
|
result[i] = {
|
|
10509
|
-
position: "
|
|
10510
|
-
|
|
10511
|
-
zIndex:
|
|
10508
|
+
position: "relative",
|
|
10509
|
+
transform: "translateX(var(--pinned-translate-right, 0px))",
|
|
10510
|
+
zIndex: 2,
|
|
10512
10511
|
backgroundColor: "inherit"
|
|
10513
10512
|
};
|
|
10514
|
-
rightOffset += columns[i].width;
|
|
10515
10513
|
}
|
|
10516
10514
|
}
|
|
10517
10515
|
return result;
|
|
10518
|
-
}, [columns
|
|
10516
|
+
}, [columns]);
|
|
10519
10517
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10520
10518
|
"div",
|
|
10521
10519
|
{
|
|
@@ -11186,17 +11184,55 @@
|
|
|
11186
11184
|
taskListWidth,
|
|
11187
11185
|
tableWidth,
|
|
11188
11186
|
onTableResizeStart,
|
|
11189
|
-
onColumnResizeStart
|
|
11187
|
+
onColumnResizeStart,
|
|
11188
|
+
internalColumnVisibilityChange
|
|
11190
11189
|
] = useTableListResize(
|
|
11191
11190
|
columnsProp,
|
|
11192
11191
|
canReorderTasks,
|
|
11193
11192
|
onResizeColumn,
|
|
11194
11193
|
ganttRef
|
|
11195
11194
|
);
|
|
11195
|
+
const handleColumnVisibilityChange = React.useCallback(
|
|
11196
|
+
(columnId, hidden2) => {
|
|
11197
|
+
internalColumnVisibilityChange(columnId, hidden2);
|
|
11198
|
+
if (onColumnVisibilityChange) {
|
|
11199
|
+
onColumnVisibilityChange(columnId, hidden2);
|
|
11200
|
+
}
|
|
11201
|
+
},
|
|
11202
|
+
[internalColumnVisibilityChange, onColumnVisibilityChange]
|
|
11203
|
+
);
|
|
11196
11204
|
const columns = React.useMemo(
|
|
11197
11205
|
() => allColumns.filter((col) => !col.hidden),
|
|
11198
11206
|
[allColumns]
|
|
11199
11207
|
);
|
|
11208
|
+
const horizontalScrollRef = React.useRef(null);
|
|
11209
|
+
const setHorizontalScrollRef = React.useCallback(
|
|
11210
|
+
(el) => {
|
|
11211
|
+
horizontalScrollRef.current = el;
|
|
11212
|
+
if (taskListHorizontalScrollRef) {
|
|
11213
|
+
taskListHorizontalScrollRef.current = el;
|
|
11214
|
+
}
|
|
11215
|
+
},
|
|
11216
|
+
[taskListHorizontalScrollRef]
|
|
11217
|
+
);
|
|
11218
|
+
React.useEffect(() => {
|
|
11219
|
+
const scrollEl = horizontalScrollRef.current;
|
|
11220
|
+
const containerEl = taskListContainerRef.current;
|
|
11221
|
+
if (!scrollEl || !containerEl)
|
|
11222
|
+
return void 0;
|
|
11223
|
+
const update = () => {
|
|
11224
|
+
const sl = scrollEl.scrollLeft;
|
|
11225
|
+
const maxSl = scrollEl.scrollWidth - scrollEl.clientWidth;
|
|
11226
|
+
containerEl.style.setProperty("--pinned-translate-left", `${sl}px`);
|
|
11227
|
+
containerEl.style.setProperty(
|
|
11228
|
+
"--pinned-translate-right",
|
|
11229
|
+
`${sl - maxSl}px`
|
|
11230
|
+
);
|
|
11231
|
+
};
|
|
11232
|
+
update();
|
|
11233
|
+
scrollEl.addEventListener("scroll", update, { passive: true });
|
|
11234
|
+
return () => scrollEl.removeEventListener("scroll", update);
|
|
11235
|
+
}, [taskListContainerRef, taskListWidth, tableWidth]);
|
|
11200
11236
|
const renderedIndexes = useOptimizedList(
|
|
11201
11237
|
taskListContainerRef,
|
|
11202
11238
|
"scrollTop",
|
|
@@ -11273,7 +11309,7 @@
|
|
|
11273
11309
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11274
11310
|
"div",
|
|
11275
11311
|
{
|
|
11276
|
-
ref:
|
|
11312
|
+
ref: setHorizontalScrollRef,
|
|
11277
11313
|
className: styles$e.taskListHorizontalScroll,
|
|
11278
11314
|
style: {
|
|
11279
11315
|
width: tableWidth
|
|
@@ -11288,7 +11324,7 @@
|
|
|
11288
11324
|
allColumns,
|
|
11289
11325
|
canToggleColumns: !!canToggleColumns,
|
|
11290
11326
|
onColumnResizeStart,
|
|
11291
|
-
onColumnVisibilityChange,
|
|
11327
|
+
onColumnVisibilityChange: handleColumnVisibilityChange,
|
|
11292
11328
|
canResizeColumns
|
|
11293
11329
|
}
|
|
11294
11330
|
),
|
package/package.json
CHANGED