@thepocman/gantt-task-react 1.0.8 → 1.0.10
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.
|
@@ -2,13 +2,14 @@ import type { MouseEvent } from "react";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import type { OptimizedListParams } from "../../helpers/use-optimized-list";
|
|
4
4
|
import { GanttRelationEvent } from "../../types/gantt-task-actions";
|
|
5
|
-
import { BarMoveAction, ChildByLevelMap, ChildOutOfParentWarnings, ColorStyles, CriticalPaths, DateExtremity, DependencyMap, DependentMap, Distances, FixPosition, GlobalRowIndexToTaskMap, RelationKind, Task, TaskContextualPaletteProps, TaskCoordinates, TaskDependencyContextualPaletteProps, TaskOrEmpty, TaskToHasDependencyWarningMap } from "../../types/public-types";
|
|
5
|
+
import { BarMoveAction, ChildByLevelMap, ChildOutOfParentWarnings, ColorStyles, CriticalPaths, DateExtremity, DependencyMap, DependentMap, Distances, FixPosition, GlobalRowIndexToTaskMap, RelationKind, Task, TaskContextualPaletteProps, TaskCoordinates, TaskDependencyContextualPaletteProps, TaskOrEmpty, TaskToHasDependencyWarningMap, TaskToRowIndexMap } from "../../types/public-types";
|
|
6
6
|
export type TaskGanttContentProps = {
|
|
7
7
|
authorizedRelations: RelationKind[];
|
|
8
8
|
additionalLeftSpace: number;
|
|
9
9
|
additionalRightSpace: number;
|
|
10
10
|
childOutOfParentWarnings: ChildOutOfParentWarnings | null;
|
|
11
11
|
childTasksMap: ChildByLevelMap;
|
|
12
|
+
taskToRowIndexMap: TaskToRowIndexMap;
|
|
12
13
|
colorStyles: ColorStyles;
|
|
13
14
|
comparisonLevels: number;
|
|
14
15
|
criticalPaths: CriticalPaths | null;
|
|
@@ -6424,9 +6424,11 @@ const TaskGanttContent = ({
|
|
|
6424
6424
|
taskYOffset,
|
|
6425
6425
|
taskHeight,
|
|
6426
6426
|
taskHalfHeight,
|
|
6427
|
-
visibleTasksMirror
|
|
6427
|
+
visibleTasksMirror,
|
|
6428
|
+
taskToRowIndexMap
|
|
6428
6429
|
}) => {
|
|
6429
6430
|
const [renderedTasks, renderedArrows, renderedSelectedTasks] = useMemo(() => {
|
|
6431
|
+
var _a;
|
|
6430
6432
|
if (!renderedRowIndexes) {
|
|
6431
6433
|
return [null, null, null];
|
|
6432
6434
|
}
|
|
@@ -6445,19 +6447,23 @@ const TaskGanttContent = ({
|
|
|
6445
6447
|
const { comparisonLevel = 1, id: taskId } = task;
|
|
6446
6448
|
if (selectedIdsMirror[taskId] && !addedSelectedTasks[taskId]) {
|
|
6447
6449
|
addedSelectedTasks[taskId] = true;
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6450
|
+
const rowIndex = (_a = taskToRowIndexMap.get(comparisonLevel)) == null ? void 0 : _a.get(taskId);
|
|
6451
|
+
if (typeof rowIndex === "number") {
|
|
6452
|
+
const y3 = rowIndex * fullRowHeight;
|
|
6453
|
+
selectedTasksRes.push(
|
|
6454
|
+
/* @__PURE__ */ jsx(
|
|
6455
|
+
"rect",
|
|
6456
|
+
{
|
|
6457
|
+
x: 0,
|
|
6458
|
+
y: y3,
|
|
6459
|
+
width: "100%",
|
|
6460
|
+
height: fullRowHeight,
|
|
6461
|
+
fill: colorStyles.selectedTaskBackgroundColor
|
|
6462
|
+
},
|
|
6463
|
+
`selected-${taskId}`
|
|
6464
|
+
)
|
|
6465
|
+
);
|
|
6466
|
+
}
|
|
6461
6467
|
}
|
|
6462
6468
|
if (comparisonLevel > comparisonLevels) {
|
|
6463
6469
|
continue;
|
|
@@ -11602,7 +11608,6 @@ const Gantt = ({
|
|
|
11602
11608
|
() => collectVisibleTasks(childTasksMap, rootTasksMap, enableTaskGrouping),
|
|
11603
11609
|
[childTasksMap, rootTasksMap]
|
|
11604
11610
|
);
|
|
11605
|
-
console.log("Visible Task IDs:", visibleTasks.map((t2) => t2.id));
|
|
11606
11611
|
const tasksMap = useMemo(() => getTasksMap(tasks), [tasks]);
|
|
11607
11612
|
const checkTaskIdExists = useCallback(
|
|
11608
11613
|
(newId, comparisonLevel = 1) => {
|
|
@@ -11678,11 +11683,23 @@ const Gantt = ({
|
|
|
11678
11683
|
() => (distances.rowHeight - taskHeight) / 2,
|
|
11679
11684
|
[distances, taskHeight]
|
|
11680
11685
|
);
|
|
11686
|
+
const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask, rowIndexToTasksMap] = useMemo(
|
|
11687
|
+
() => enableTaskGrouping ? getMapTaskToRowIndexWithGrouping(visibleTasks, comparisonLevels, true) : getMapTaskToRowIndex(visibleTasks, comparisonLevels),
|
|
11688
|
+
[visibleTasks, comparisonLevels, enableTaskGrouping]
|
|
11689
|
+
);
|
|
11681
11690
|
const taskHalfHeight = useMemo(
|
|
11682
11691
|
() => Math.round(taskHeight / 2),
|
|
11683
11692
|
[taskHeight]
|
|
11684
11693
|
);
|
|
11694
|
+
console.log("rowIndexToTasksMap ------", rowIndexToTasksMap);
|
|
11685
11695
|
const maxLevelLength = useMemo(() => {
|
|
11696
|
+
if (enableTaskGrouping) {
|
|
11697
|
+
let totalRows = 0;
|
|
11698
|
+
for (const [, rowMap] of rowIndexToTasksMap ?? /* @__PURE__ */ new Map()) {
|
|
11699
|
+
totalRows += rowMap.size;
|
|
11700
|
+
}
|
|
11701
|
+
return Math.max(totalRows, 1);
|
|
11702
|
+
}
|
|
11686
11703
|
let maxLength = 0;
|
|
11687
11704
|
const countByLevel = {};
|
|
11688
11705
|
visibleTasks.forEach(({ comparisonLevel = 1 }) => {
|
|
@@ -11694,16 +11711,14 @@ const Gantt = ({
|
|
|
11694
11711
|
maxLength = countByLevel[comparisonLevel];
|
|
11695
11712
|
}
|
|
11696
11713
|
});
|
|
11714
|
+
console.log("📦 Tasks per level:", countByLevel);
|
|
11715
|
+
console.log("📏 maxLevelLength:", maxLength);
|
|
11697
11716
|
return maxLength;
|
|
11698
|
-
}, [visibleTasks, comparisonLevels]);
|
|
11717
|
+
}, [visibleTasks, comparisonLevels, enableTaskGrouping, rowIndexToTasksMap]);
|
|
11699
11718
|
const ganttFullHeight = useMemo(
|
|
11700
11719
|
() => maxLevelLength * fullRowHeight,
|
|
11701
11720
|
[maxLevelLength, fullRowHeight]
|
|
11702
11721
|
);
|
|
11703
|
-
const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask, rowIndexToTasksMap] = useMemo(
|
|
11704
|
-
() => enableTaskGrouping ? getMapTaskToRowIndexWithGrouping(visibleTasks, comparisonLevels, true) : getMapTaskToRowIndex(visibleTasks, comparisonLevels),
|
|
11705
|
-
[visibleTasks, comparisonLevels, enableTaskGrouping]
|
|
11706
|
-
);
|
|
11707
11722
|
const {
|
|
11708
11723
|
checkHasCopyTasks,
|
|
11709
11724
|
checkHasCutTasks,
|
|
@@ -6437,9 +6437,11 @@
|
|
|
6437
6437
|
taskYOffset,
|
|
6438
6438
|
taskHeight,
|
|
6439
6439
|
taskHalfHeight,
|
|
6440
|
-
visibleTasksMirror
|
|
6440
|
+
visibleTasksMirror,
|
|
6441
|
+
taskToRowIndexMap
|
|
6441
6442
|
}) => {
|
|
6442
6443
|
const [renderedTasks, renderedArrows, renderedSelectedTasks] = React.useMemo(() => {
|
|
6444
|
+
var _a;
|
|
6443
6445
|
if (!renderedRowIndexes) {
|
|
6444
6446
|
return [null, null, null];
|
|
6445
6447
|
}
|
|
@@ -6458,19 +6460,23 @@
|
|
|
6458
6460
|
const { comparisonLevel = 1, id: taskId } = task;
|
|
6459
6461
|
if (selectedIdsMirror[taskId] && !addedSelectedTasks[taskId]) {
|
|
6460
6462
|
addedSelectedTasks[taskId] = true;
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6463
|
+
const rowIndex = (_a = taskToRowIndexMap.get(comparisonLevel)) == null ? void 0 : _a.get(taskId);
|
|
6464
|
+
if (typeof rowIndex === "number") {
|
|
6465
|
+
const y = rowIndex * fullRowHeight;
|
|
6466
|
+
selectedTasksRes.push(
|
|
6467
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6468
|
+
"rect",
|
|
6469
|
+
{
|
|
6470
|
+
x: 0,
|
|
6471
|
+
y,
|
|
6472
|
+
width: "100%",
|
|
6473
|
+
height: fullRowHeight,
|
|
6474
|
+
fill: colorStyles.selectedTaskBackgroundColor
|
|
6475
|
+
},
|
|
6476
|
+
`selected-${taskId}`
|
|
6477
|
+
)
|
|
6478
|
+
);
|
|
6479
|
+
}
|
|
6474
6480
|
}
|
|
6475
6481
|
if (comparisonLevel > comparisonLevels) {
|
|
6476
6482
|
continue;
|
|
@@ -11615,7 +11621,6 @@
|
|
|
11615
11621
|
() => collectVisibleTasks(childTasksMap, rootTasksMap, enableTaskGrouping),
|
|
11616
11622
|
[childTasksMap, rootTasksMap]
|
|
11617
11623
|
);
|
|
11618
|
-
console.log("Visible Task IDs:", visibleTasks.map((t) => t.id));
|
|
11619
11624
|
const tasksMap = React.useMemo(() => getTasksMap(tasks), [tasks]);
|
|
11620
11625
|
const checkTaskIdExists = React.useCallback(
|
|
11621
11626
|
(newId, comparisonLevel = 1) => {
|
|
@@ -11691,11 +11696,23 @@
|
|
|
11691
11696
|
() => (distances.rowHeight - taskHeight) / 2,
|
|
11692
11697
|
[distances, taskHeight]
|
|
11693
11698
|
);
|
|
11699
|
+
const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask, rowIndexToTasksMap] = React.useMemo(
|
|
11700
|
+
() => enableTaskGrouping ? getMapTaskToRowIndexWithGrouping(visibleTasks, comparisonLevels, true) : getMapTaskToRowIndex(visibleTasks, comparisonLevels),
|
|
11701
|
+
[visibleTasks, comparisonLevels, enableTaskGrouping]
|
|
11702
|
+
);
|
|
11694
11703
|
const taskHalfHeight = React.useMemo(
|
|
11695
11704
|
() => Math.round(taskHeight / 2),
|
|
11696
11705
|
[taskHeight]
|
|
11697
11706
|
);
|
|
11707
|
+
console.log("rowIndexToTasksMap ------", rowIndexToTasksMap);
|
|
11698
11708
|
const maxLevelLength = React.useMemo(() => {
|
|
11709
|
+
if (enableTaskGrouping) {
|
|
11710
|
+
let totalRows = 0;
|
|
11711
|
+
for (const [, rowMap] of rowIndexToTasksMap ?? /* @__PURE__ */ new Map()) {
|
|
11712
|
+
totalRows += rowMap.size;
|
|
11713
|
+
}
|
|
11714
|
+
return Math.max(totalRows, 1);
|
|
11715
|
+
}
|
|
11699
11716
|
let maxLength = 0;
|
|
11700
11717
|
const countByLevel = {};
|
|
11701
11718
|
visibleTasks.forEach(({ comparisonLevel = 1 }) => {
|
|
@@ -11707,16 +11724,14 @@
|
|
|
11707
11724
|
maxLength = countByLevel[comparisonLevel];
|
|
11708
11725
|
}
|
|
11709
11726
|
});
|
|
11727
|
+
console.log("📦 Tasks per level:", countByLevel);
|
|
11728
|
+
console.log("📏 maxLevelLength:", maxLength);
|
|
11710
11729
|
return maxLength;
|
|
11711
|
-
}, [visibleTasks, comparisonLevels]);
|
|
11730
|
+
}, [visibleTasks, comparisonLevels, enableTaskGrouping, rowIndexToTasksMap]);
|
|
11712
11731
|
const ganttFullHeight = React.useMemo(
|
|
11713
11732
|
() => maxLevelLength * fullRowHeight,
|
|
11714
11733
|
[maxLevelLength, fullRowHeight]
|
|
11715
11734
|
);
|
|
11716
|
-
const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask, rowIndexToTasksMap] = React.useMemo(
|
|
11717
|
-
() => enableTaskGrouping ? getMapTaskToRowIndexWithGrouping(visibleTasks, comparisonLevels, true) : getMapTaskToRowIndex(visibleTasks, comparisonLevels),
|
|
11718
|
-
[visibleTasks, comparisonLevels, enableTaskGrouping]
|
|
11719
|
-
);
|
|
11720
11735
|
const {
|
|
11721
11736
|
checkHasCopyTasks,
|
|
11722
11737
|
checkHasCutTasks,
|
|
@@ -158,6 +158,7 @@ export interface Task {
|
|
|
158
158
|
displayOrder?: number;
|
|
159
159
|
comparisonLevel?: number;
|
|
160
160
|
status?: string;
|
|
161
|
+
phase?: string;
|
|
161
162
|
}
|
|
162
163
|
export interface EmptyTask {
|
|
163
164
|
id: string;
|
|
@@ -167,6 +168,7 @@ export interface EmptyTask {
|
|
|
167
168
|
parent?: string;
|
|
168
169
|
comparisonLevel?: number;
|
|
169
170
|
status?: string;
|
|
171
|
+
phase?: string;
|
|
170
172
|
displayOrder?: number;
|
|
171
173
|
isDisabled?: boolean;
|
|
172
174
|
styles?: Partial<ColorStyles>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thepocman/gantt-task-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "Fork of gantt-task-react with support for grouped tasks on a single row when collapsed",
|
|
5
5
|
"author": "Adrian Bueno <adrianlbueno@users.noreply.github.com>",
|
|
6
6
|
"homepage": "https://github.com/adrianlbueno/gantt-task-react#readme",
|