@thepocman/gantt-task-react 1.0.13 → 1.0.15

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.
@@ -474,7 +474,6 @@
474
474
  const enDateLocale = locale;
475
475
  const collectChildren = (arrayRes, mirrorRes, task, childTasksOnLevel, enableTaskGrouping) => {
476
476
  const { comparisonLevel = 1 } = task;
477
- console.log(`Task ${task.id} visibility check: type=${task.type}, hideChildren=${task.hideChildren}, will ${task.type === "empty" || task.hideChildren && task.type !== "user" ? "hide" : "show"} children`);
478
477
  arrayRes.push(task);
479
478
  if (comparisonLevel === 1) {
480
479
  mirrorRes[task.id] = true;
@@ -1604,14 +1603,9 @@
1604
1603
  return { isChanged, changedTask };
1605
1604
  };
1606
1605
  const countTaskCoordinates = (task, taskToRowIndexMap, startDate, viewMode, rtl, fullRowHeight, taskHeight, taskYOffset, distances, svgWidth, sequentialOffset = 0) => {
1607
- const { columnWidth, rowHeight } = distances;
1606
+ const { columnWidth } = distances;
1608
1607
  const { id, comparisonLevel = 1, progress, type } = task;
1609
1608
  const indexesAtLevel = taskToRowIndexMap.get(comparisonLevel);
1610
- console.log("Looking for task id:", task.id, "level:", comparisonLevel);
1611
- console.log("taskToRowIndexMap", Array.from(taskToRowIndexMap.entries()).map(([level, map]) => ({
1612
- level,
1613
- rows: Array.from(map.entries())
1614
- })));
1615
1609
  if (!indexesAtLevel) {
1616
1610
  throw new Error(`Indexes at level ${comparisonLevel} are not found`);
1617
1611
  }
@@ -1621,7 +1615,7 @@
1621
1615
  }
1622
1616
  const x1 = rtl ? svgWidth - taskXCoordinate(task.end, startDate, viewMode, columnWidth) : taskXCoordinate(task.start, startDate, viewMode, columnWidth);
1623
1617
  const x2 = rtl ? svgWidth - taskXCoordinate(task.start, startDate, viewMode, columnWidth) : taskXCoordinate(task.end, startDate, viewMode, columnWidth);
1624
- const levelY = rowIndex * fullRowHeight + rowHeight * (comparisonLevel - 1);
1618
+ const levelY = rowIndex * fullRowHeight;
1625
1619
  const y = levelY + taskYOffset + sequentialOffset;
1626
1620
  const [progressWidth, progressX] = type === "milestone" ? [0, x1] : progressWithByParams(x1, x2, progress, rtl);
1627
1621
  const taskX1 = type === "milestone" ? x1 - taskHeight * 0.5 : x1;
@@ -1673,21 +1667,31 @@
1673
1667
  });
1674
1668
  return res;
1675
1669
  };
1676
- const countTaskCoordinatesWithGrouping = (task, taskToRowIndexMap, startDate, viewMode, rtl, fullRowHeight, taskHeight, taskYOffset, distances, svgWidth, sequentialOffset = 0) => {
1677
- const { columnWidth, rowHeight } = distances;
1670
+ const countTaskCoordinatesWithGrouping = (task, rowIndexToTasksMap, startDate, viewMode, rtl, fullRowHeight, taskHeight, taskYOffset, distances, svgWidth, sequentialOffset = 0) => {
1671
+ const { columnWidth } = distances;
1678
1672
  const { id, comparisonLevel = 1, progress, type } = task;
1679
- const indexesAtLevel = taskToRowIndexMap.get(comparisonLevel);
1680
- if (!indexesAtLevel) {
1681
- throw new Error(`Indexes at level ${comparisonLevel} are not found`);
1673
+ let rowIndex = -1;
1674
+ let taskIndexInRow = 0;
1675
+ const rowMapAtLevel = rowIndexToTasksMap.get(comparisonLevel);
1676
+ if (!rowMapAtLevel) {
1677
+ throw new Error(`No rows found for comparison level ${comparisonLevel}`);
1678
+ }
1679
+ for (const [currentRowIndex, tasksInRow] of rowMapAtLevel.entries()) {
1680
+ const taskIndex = tasksInRow.findIndex((t) => t.id === id);
1681
+ if (taskIndex !== -1) {
1682
+ rowIndex = currentRowIndex;
1683
+ taskIndexInRow = taskIndex;
1684
+ break;
1685
+ }
1682
1686
  }
1683
- const rowIndex = indexesAtLevel.get(id);
1684
- if (typeof rowIndex !== "number") {
1685
- throw new Error(`Row index for task ${id} is not found`);
1687
+ if (rowIndex === -1) {
1688
+ throw new Error(`Task ${id} not found in rowIndexToTasksMap`);
1686
1689
  }
1687
1690
  const x1 = rtl ? svgWidth - taskXCoordinate(task.end, startDate, viewMode, columnWidth) : taskXCoordinate(task.start, startDate, viewMode, columnWidth);
1688
1691
  const x2 = rtl ? svgWidth - taskXCoordinate(task.start, startDate, viewMode, columnWidth) : taskXCoordinate(task.end, startDate, viewMode, columnWidth);
1689
- const levelY = rowIndex * fullRowHeight + rowHeight * (comparisonLevel - 1);
1690
- const y = levelY + taskYOffset + sequentialOffset;
1692
+ const levelY = rowIndex * fullRowHeight;
1693
+ const taskStackOffset = taskIndexInRow * (taskHeight + 2);
1694
+ const y = levelY + taskYOffset + sequentialOffset + taskStackOffset;
1691
1695
  const [progressWidth, progressX] = type === "milestone" ? [0, x1] : progressWithByParams(x1, x2, progress, rtl);
1692
1696
  const taskX1 = type === "milestone" ? x1 - taskHeight * 0.5 : x1;
1693
1697
  const taskX2 = type === "milestone" ? x2 + taskHeight * 0.5 : x2;
@@ -1710,6 +1714,34 @@
1710
1714
  y
1711
1715
  };
1712
1716
  };
1717
+ const getMapTaskToCoordinatesWithGrouping = (tasks, visibleTasksMirror, rowIndexToTasksMap, startDate, viewMode, rtl, fullRowHeight, taskHeight, taskYOffset, distances, svgWidth) => {
1718
+ const res = /* @__PURE__ */ new Map();
1719
+ tasks.forEach((task) => {
1720
+ if (task.type === "empty" || task.type === "user") {
1721
+ return;
1722
+ }
1723
+ const { id, comparisonLevel = 1 } = task;
1724
+ if (!visibleTasksMirror[id]) {
1725
+ return;
1726
+ }
1727
+ const taskCoordinates = countTaskCoordinatesWithGrouping(
1728
+ task,
1729
+ rowIndexToTasksMap,
1730
+ startDate,
1731
+ viewMode,
1732
+ rtl,
1733
+ fullRowHeight,
1734
+ taskHeight,
1735
+ taskYOffset,
1736
+ distances,
1737
+ svgWidth
1738
+ );
1739
+ const resByLevel = res.get(comparisonLevel) || /* @__PURE__ */ new Map();
1740
+ resByLevel.set(id, taskCoordinates);
1741
+ res.set(comparisonLevel, resByLevel);
1742
+ });
1743
+ return res;
1744
+ };
1713
1745
  const getMapTaskToGlobalIndex = (tasks) => {
1714
1746
  const res = /* @__PURE__ */ new Map();
1715
1747
  tasks.forEach((task, index2) => {
@@ -1723,43 +1755,33 @@
1723
1755
  });
1724
1756
  return res;
1725
1757
  };
1726
- const getMapTaskTo = (indexesOnLevel, taskId, level, collectedIndex, childTasksOnLevel) => {
1727
- const childs = childTasksOnLevel.get(taskId);
1728
- if (childs && childs.length > 0) {
1729
- childs.forEach(({
1730
- id: childId
1731
- }, index2) => {
1732
- const childIndex = `${collectedIndex}.${index2 + 1}`;
1733
- indexesOnLevel.set(childId, [level, childIndex]);
1734
- getMapTaskTo(
1735
- indexesOnLevel,
1736
- childId,
1737
- level + 1,
1738
- childIndex,
1739
- childTasksOnLevel
1740
- );
1741
- });
1758
+ const setIndex = (map, level, id, depth, indexStr) => {
1759
+ if (!map.has(level)) {
1760
+ map.set(level, /* @__PURE__ */ new Map());
1742
1761
  }
1762
+ map.get(level).set(id, [depth, indexStr]);
1763
+ };
1764
+ const walkTasks = (map, comparisonLevel, parentId, depth, prefix, childTasksMap) => {
1765
+ const children = childTasksMap.get(parentId);
1766
+ if (!children)
1767
+ return;
1768
+ children.forEach((child, i) => {
1769
+ const indexStr = `${prefix}.${i + 1}`;
1770
+ setIndex(map, comparisonLevel, child.id, depth, indexStr);
1771
+ walkTasks(map, comparisonLevel, child.id, depth + 1, indexStr, childTasksMap);
1772
+ });
1743
1773
  };
1744
1774
  const getMapTaskToNestedIndex = (childTasksMap, rootTasksMap) => {
1745
- const res = /* @__PURE__ */ new Map();
1775
+ const map = /* @__PURE__ */ new Map();
1746
1776
  for (const [comparisonLevel, rootTasks] of rootTasksMap.entries()) {
1747
- const indexesOnLevel = /* @__PURE__ */ new Map();
1748
- const childTasksOnLevel = childTasksMap.get(comparisonLevel) || /* @__PURE__ */ new Map();
1749
- rootTasks.forEach(({ id: rootId }, index2) => {
1750
- const rootIndex = `${index2 + 1}`;
1751
- indexesOnLevel.set(rootId, [0, rootIndex]);
1752
- getMapTaskTo(
1753
- indexesOnLevel,
1754
- rootId,
1755
- 1,
1756
- rootIndex,
1757
- childTasksOnLevel
1758
- );
1777
+ const childMap = childTasksMap.get(comparisonLevel) ?? /* @__PURE__ */ new Map();
1778
+ rootTasks.forEach((task, i) => {
1779
+ const indexStr = `${i + 1}`;
1780
+ setIndex(map, comparisonLevel, task.id, 0, indexStr);
1781
+ walkTasks(map, comparisonLevel, task.id, 1, indexStr, childMap);
1759
1782
  });
1760
- res.set(comparisonLevel, indexesOnLevel);
1761
1783
  }
1762
- return res;
1784
+ return map;
1763
1785
  };
1764
1786
  const getMapTaskToRowIndex = (visibleTasks, comparisonLevels) => {
1765
1787
  const taskToRowIndexRes = /* @__PURE__ */ new Map();
@@ -1934,6 +1956,26 @@
1934
1956
  ]);
1935
1957
  return indexes;
1936
1958
  };
1959
+ const useGroupedVirtualization = (rowIndexToTasksMap, taskHeight) => {
1960
+ var _a, _b;
1961
+ const rowEntries = React.useMemo(() => {
1962
+ const rowToHeight = /* @__PURE__ */ new Map();
1963
+ for (const levelMap of rowIndexToTasksMap.values()) {
1964
+ for (const [rowIndex, tasks] of levelMap.entries()) {
1965
+ const height = tasks.length * (taskHeight + 2);
1966
+ rowToHeight.set(rowIndex, (rowToHeight.get(rowIndex) ?? 0) + height);
1967
+ }
1968
+ }
1969
+ return [...rowToHeight.entries()].map(([rowIndex, height]) => ({ rowIndex, height })).sort((a2, b2) => a2.rowIndex - b2.rowIndex);
1970
+ }, [rowIndexToTasksMap, taskHeight]);
1971
+ return [
1972
+ ((_a = rowEntries[0]) == null ? void 0 : _a.rowIndex) ?? 0,
1973
+ ((_b = rowEntries[rowEntries.length - 1]) == null ? void 0 : _b.rowIndex) ?? 0,
1974
+ true,
1975
+ true,
1976
+ rowEntries.reduce((sum, entry) => sum + entry.height, 0)
1977
+ ];
1978
+ };
1937
1979
  const button$2 = "_button_1eue5_1";
1938
1980
  const styles$i = {
1939
1981
  button: button$2
@@ -3370,6 +3412,7 @@
3370
3412
  dateSetup,
3371
3413
  dependencyMap,
3372
3414
  distances,
3415
+ rowIndexToTasksMap,
3373
3416
  fontFamily,
3374
3417
  fontSize,
3375
3418
  fullRowHeight,
@@ -3408,7 +3451,11 @@
3408
3451
  onTableResizeStart,
3409
3452
  onColumnResizeStart
3410
3453
  ] = useTableListResize(columnsProp, distances, onResizeColumn);
3411
- const renderedIndexes = useOptimizedList(
3454
+ const renderedIndexes = enableTaskGrouping ? useGroupedVirtualization(
3455
+ //taskListContentRef,
3456
+ rowIndexToTasksMap,
3457
+ distances.taskHeight
3458
+ ) : useOptimizedList(
3412
3459
  taskListContentRef,
3413
3460
  "scrollTop",
3414
3461
  fullRowHeight
@@ -3464,6 +3511,7 @@
3464
3511
  columns,
3465
3512
  cutIdsMirror,
3466
3513
  enableTaskGrouping,
3514
+ rowIndexToTasksMap,
3467
3515
  dateSetup,
3468
3516
  dependencyMap,
3469
3517
  distances,
@@ -3685,21 +3733,6 @@
3685
3733
  );
3686
3734
  };
3687
3735
  const TaskListHeaderDefault = React.memo(TaskListHeaderDefaultInner);
3688
- const checkHasChildren = (task, childTasksMap) => {
3689
- const {
3690
- id,
3691
- comparisonLevel = 1
3692
- } = task;
3693
- const childIdsByLevel = childTasksMap.get(comparisonLevel);
3694
- if (!childIdsByLevel) {
3695
- return false;
3696
- }
3697
- const childs = childIdsByLevel.get(id);
3698
- if (!childs) {
3699
- return false;
3700
- }
3701
- return childs.length > 0;
3702
- };
3703
3736
  const taskListTableRow = "_taskListTableRow_1e35i_1";
3704
3737
  const taskListTableRowGrabbing = "_taskListTableRowGrabbing_1e35i_13";
3705
3738
  const cut = "_cut_1e35i_21";
@@ -4043,6 +4076,21 @@
4043
4076
  );
4044
4077
  };
4045
4078
  const TaskListTableRow = React.memo(TaskListTableRowInner);
4079
+ const checkHasChildren = (task, childTasksMap) => {
4080
+ const {
4081
+ id,
4082
+ comparisonLevel = 1
4083
+ } = task;
4084
+ const childIdsByLevel = childTasksMap.get(comparisonLevel);
4085
+ if (!childIdsByLevel) {
4086
+ return false;
4087
+ }
4088
+ const childs = childIdsByLevel.get(id);
4089
+ if (!childs) {
4090
+ return false;
4091
+ }
4092
+ return childs.length > 0;
4093
+ };
4046
4094
  const taskListWrapper = "_taskListWrapper_5941j_1";
4047
4095
  const styles$b = {
4048
4096
  taskListWrapper
@@ -4071,6 +4119,7 @@
4071
4119
  icons,
4072
4120
  isShowTaskNumbers,
4073
4121
  mapTaskToNestedIndex,
4122
+ rowIndexToTasksMap,
4074
4123
  onClick,
4075
4124
  onExpanderClick,
4076
4125
  renderedIndexes,
@@ -4080,98 +4129,146 @@
4080
4129
  tasks
4081
4130
  }) => {
4082
4131
  const renderedTasks = React.useMemo(() => {
4083
- console.log("enableTaskGrouping", enableTaskGrouping);
4084
4132
  if (!enableTaskGrouping) {
4085
- return tasks;
4133
+ return tasks.filter((task) => !task.comparisonLevel || task.comparisonLevel === 1);
4086
4134
  }
4087
- return tasks.filter((task) => {
4088
- const parent = tasks.find((t) => t.id === task.parent);
4089
- const isGroupedChildOfCollapsedUser = parent && parent.type === "user" && parent.hideChildren === true;
4090
- return !isGroupedChildOfCollapsedUser;
4091
- });
4135
+ return tasks.filter((task) => task.type !== "user");
4092
4136
  }, [tasks, enableTaskGrouping]);
4093
4137
  const [draggedTask, setDraggedTask] = React.useState(null);
4094
4138
  const renderedListWithOffset = React.useMemo(() => {
4095
- if (!renderedIndexes) {
4139
+ var _a;
4140
+ if (!renderedIndexes)
4096
4141
  return null;
4097
- }
4098
4142
  const [start, end] = renderedIndexes;
4099
- const renderedList = [];
4100
- for (let index2 = start; index2 <= end; ++index2) {
4101
- const task = renderedTasks[index2];
4102
- if (!task) {
4103
- break;
4104
- }
4105
- const { id, comparisonLevel = 1 } = task;
4106
- const indexesOnLevel = mapTaskToNestedIndex.get(comparisonLevel);
4107
- if (!indexesOnLevel) {
4108
- throw new Error(`Indexes are not found for level ${comparisonLevel}`);
4143
+ const renderList = [];
4144
+ if (!enableTaskGrouping) {
4145
+ for (let rowIndex = start; rowIndex <= end; rowIndex++) {
4146
+ const task = renderedTasks[rowIndex];
4147
+ if (!task)
4148
+ break;
4149
+ const { id, comparisonLevel = 1 } = task;
4150
+ const indexesOnLevel = mapTaskToNestedIndex.get(comparisonLevel);
4151
+ const taskIndex = indexesOnLevel == null ? void 0 : indexesOnLevel.get(id);
4152
+ const [depth, indexStr] = taskIndex ?? [0, ""];
4153
+ renderList.push(
4154
+ /* @__PURE__ */ jsxRuntime.jsx(
4155
+ TaskListTableRow,
4156
+ {
4157
+ canMoveTasks,
4158
+ colors,
4159
+ columns,
4160
+ dateSetup,
4161
+ dependencyMap,
4162
+ depth,
4163
+ distances,
4164
+ fullRowHeight,
4165
+ getTaskCurrentState,
4166
+ handleAddTask,
4167
+ handleDeleteTasks,
4168
+ handleEditTask,
4169
+ handleMoveTaskBefore,
4170
+ handleMoveTaskAfter,
4171
+ handleMoveTasksInside,
4172
+ handleOpenContextMenu,
4173
+ hasChildren: checkHasChildren(task, childTasksMap),
4174
+ icons,
4175
+ indexStr,
4176
+ isClosed: Boolean(task == null ? void 0 : task.hideChildren),
4177
+ isCut: cutIdsMirror[id],
4178
+ isEven: rowIndex % 2 === 1,
4179
+ isSelected: selectedIdsMirror[id],
4180
+ isShowTaskNumbers,
4181
+ onClick,
4182
+ onExpanderClick,
4183
+ scrollToTask,
4184
+ selectTaskOnMouseDown,
4185
+ task,
4186
+ tasks,
4187
+ draggedTask,
4188
+ setDraggedTask
4189
+ },
4190
+ id
4191
+ )
4192
+ );
4109
4193
  }
4110
- const taskIndex = indexesOnLevel.get(id);
4111
- if (!taskIndex) {
4112
- throw new Error(`Index is not found for task ${id}`);
4194
+ } else {
4195
+ for (let rowIndex = start; rowIndex <= end; rowIndex++) {
4196
+ const taskList = (_a = rowIndexToTasksMap.get(1)) == null ? void 0 : _a.get(rowIndex);
4197
+ if (!taskList)
4198
+ continue;
4199
+ for (const task of taskList) {
4200
+ const parent = tasks.find((t) => t.id === task.parent);
4201
+ if (parent == null ? void 0 : parent.hideChildren)
4202
+ continue;
4203
+ const { id, comparisonLevel } = task;
4204
+ let depth = 0;
4205
+ let indexStr = "";
4206
+ console.log("comparisonLevel", comparisonLevel);
4207
+ const levelMap = mapTaskToNestedIndex.get(comparisonLevel);
4208
+ const taskIndex = levelMap == null ? void 0 : levelMap.get(id);
4209
+ if (taskIndex) {
4210
+ console.log("object :>> ", [depth, indexStr] = taskIndex);
4211
+ [depth, indexStr] = taskIndex;
4212
+ }
4213
+ renderList.push(
4214
+ /* @__PURE__ */ jsxRuntime.jsx(
4215
+ TaskListTableRow,
4216
+ {
4217
+ canMoveTasks,
4218
+ colors,
4219
+ columns,
4220
+ dateSetup,
4221
+ dependencyMap,
4222
+ depth,
4223
+ distances,
4224
+ fullRowHeight,
4225
+ getTaskCurrentState,
4226
+ handleAddTask,
4227
+ handleDeleteTasks,
4228
+ handleEditTask,
4229
+ handleMoveTaskBefore,
4230
+ handleMoveTaskAfter,
4231
+ handleMoveTasksInside,
4232
+ handleOpenContextMenu,
4233
+ hasChildren: checkHasChildren(task, childTasksMap),
4234
+ icons,
4235
+ indexStr,
4236
+ isClosed: Boolean(task == null ? void 0 : task.hideChildren),
4237
+ isCut: cutIdsMirror[id],
4238
+ isEven: rowIndex % 2 === 1,
4239
+ isSelected: selectedIdsMirror[id],
4240
+ isShowTaskNumbers,
4241
+ onClick,
4242
+ onExpanderClick,
4243
+ scrollToTask,
4244
+ selectTaskOnMouseDown,
4245
+ task,
4246
+ tasks,
4247
+ draggedTask,
4248
+ setDraggedTask
4249
+ },
4250
+ id
4251
+ )
4252
+ );
4253
+ }
4113
4254
  }
4114
- const [depth, indexStr] = taskIndex;
4115
- renderedList.push(
4116
- /* @__PURE__ */ jsxRuntime.jsx(
4117
- TaskListTableRow,
4118
- {
4119
- canMoveTasks,
4120
- colors,
4121
- columns,
4122
- dateSetup,
4123
- dependencyMap,
4124
- depth,
4125
- distances,
4126
- fullRowHeight,
4127
- getTaskCurrentState,
4128
- handleAddTask,
4129
- handleDeleteTasks,
4130
- handleEditTask,
4131
- handleMoveTaskBefore,
4132
- handleMoveTaskAfter,
4133
- handleMoveTasksInside,
4134
- handleOpenContextMenu,
4135
- hasChildren: checkHasChildren(task, childTasksMap),
4136
- icons,
4137
- indexStr,
4138
- isClosed: Boolean(task == null ? void 0 : task.hideChildren),
4139
- isCut: cutIdsMirror[id],
4140
- isEven: index2 % 2 === 1,
4141
- isSelected: selectedIdsMirror[id],
4142
- isShowTaskNumbers,
4143
- onClick,
4144
- onExpanderClick,
4145
- scrollToTask,
4146
- selectTaskOnMouseDown,
4147
- task,
4148
- tasks,
4149
- draggedTask,
4150
- setDraggedTask
4151
- },
4152
- id
4153
- )
4154
- );
4155
4255
  }
4156
4256
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4157
- /* @__PURE__ */ jsxRuntime.jsx(
4158
- "div",
4159
- {
4160
- style: {
4161
- height: fullRowHeight * start
4162
- }
4163
- }
4164
- ),
4165
- renderedList
4257
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { height: fullRowHeight * start } }),
4258
+ renderList
4166
4259
  ] });
4167
4260
  }, [
4261
+ renderedIndexes,
4262
+ renderedTasks,
4263
+ rowIndexToTasksMap,
4264
+ mapTaskToNestedIndex,
4265
+ tasks,
4266
+ enableTaskGrouping,
4267
+ fullRowHeight,
4168
4268
  colors,
4169
4269
  columns,
4170
4270
  cutIdsMirror,
4171
- fullRowHeight,
4172
4271
  getTaskCurrentState,
4173
- renderedIndexes,
4174
- renderedTasks,
4175
4272
  selectTaskOnMouseDown,
4176
4273
  selectedIdsMirror,
4177
4274
  draggedTask
@@ -4180,10 +4277,7 @@
4180
4277
  "div",
4181
4278
  {
4182
4279
  className: styles$b.taskListWrapper,
4183
- style: {
4184
- fontFamily,
4185
- fontSize
4186
- },
4280
+ style: { fontFamily, fontSize },
4187
4281
  children: renderedListWithOffset
4188
4282
  }
4189
4283
  );
@@ -4992,9 +5086,9 @@
4992
5086
  /* @__PURE__ */ jsxRuntime.jsx(GridBody, { ...props })
4993
5087
  ] });
4994
5088
  };
4995
- const ganttTaskRoot = "_ganttTaskRoot_1g0yd_1";
4996
- const ganttTaskContent = "_ganttTaskContent_1g0yd_81";
4997
- const wrapper$2 = "_wrapper_1g0yd_107";
5089
+ const ganttTaskRoot = "_ganttTaskRoot_jnu0p_1";
5090
+ const ganttTaskContent = "_ganttTaskContent_jnu0p_83";
5091
+ const wrapper$2 = "_wrapper_jnu0p_111";
4998
5092
  const styles$9 = {
4999
5093
  ganttTaskRoot,
5000
5094
  ganttTaskContent,
@@ -6423,6 +6517,8 @@
6423
6517
  handleFixDependency,
6424
6518
  handleTaskDragStart,
6425
6519
  isShowDependencyWarnings,
6520
+ enableTaskGrouping,
6521
+ rowIndexToTasksMap,
6426
6522
  mapGlobalRowIndexToTask,
6427
6523
  onArrowDoubleClick,
6428
6524
  onArrowClick,
@@ -6442,263 +6538,228 @@
6442
6538
  }) => {
6443
6539
  const [renderedTasks, renderedArrows, renderedSelectedTasks] = React.useMemo(() => {
6444
6540
  var _a;
6445
- if (!renderedRowIndexes) {
6541
+ if (!renderedRowIndexes)
6446
6542
  return [null, null, null];
6447
- }
6448
6543
  const [start, end] = renderedRowIndexes;
6449
6544
  const tasksRes = [];
6450
6545
  const arrowsRes = [];
6451
6546
  const selectedTasksRes = [];
6452
6547
  const addedSelectedTasks = {};
6453
6548
  const addedDependencies = {};
6454
- console.log("mapGlobalRowIndexToTask", mapGlobalRowIndexToTask);
6455
6549
  for (let index2 = start; index2 <= end; ++index2) {
6456
- const task = mapGlobalRowIndexToTask.get(index2);
6457
- if (!task) {
6458
- continue;
6459
- }
6460
- const { comparisonLevel = 1, id: taskId } = task;
6461
- if (selectedIdsMirror[taskId] && !addedSelectedTasks[taskId]) {
6462
- addedSelectedTasks[taskId] = true;
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
- );
6550
+ const tasksAtRow = [];
6551
+ if (enableTaskGrouping) {
6552
+ for (let level = 1; level <= comparisonLevels; level++) {
6553
+ const levelMap = rowIndexToTasksMap.get(level);
6554
+ const rowTasks = levelMap == null ? void 0 : levelMap.get(index2);
6555
+ if (Array.isArray(rowTasks)) {
6556
+ tasksAtRow.push(...rowTasks);
6557
+ }
6479
6558
  }
6559
+ } else {
6560
+ const task = mapGlobalRowIndexToTask.get(index2);
6561
+ if (task)
6562
+ tasksAtRow.push(task);
6480
6563
  }
6481
- if (comparisonLevel > comparisonLevels) {
6482
- continue;
6483
- }
6484
- if (task.type === "empty" || task.type === "user") {
6485
- continue;
6486
- }
6487
- const key = `${comparisonLevel}_${task.id}`;
6488
- const criticalPathOnLevel = criticalPaths ? criticalPaths.get(comparisonLevel) : void 0;
6489
- const isCritical = criticalPathOnLevel ? criticalPathOnLevel.tasks.has(task.id) : false;
6490
- const {
6491
- containerX,
6492
- containerWidth,
6493
- innerX1,
6494
- innerX2,
6495
- width,
6496
- levelY,
6497
- progressWidth,
6498
- x1: taskX1,
6499
- x2: taskX2
6500
- } = getTaskCoordinates2(task);
6501
- tasksRes.push(
6502
- /* @__PURE__ */ jsxRuntime.jsx(
6503
- "svg",
6504
- {
6505
- id: task.id,
6506
- className: "TaskItemClassName",
6507
- x: containerX + (additionalLeftSpace || 0),
6508
- y: levelY,
6509
- width: containerWidth,
6510
- height: fullRowHeight,
6511
- children: /* @__PURE__ */ jsxRuntime.jsx(
6512
- TaskItem,
6513
- {
6514
- getTaskGlobalIndexByRef,
6515
- hasChildren: checkHasChildren(task, childTasksMap),
6516
- hasDependencyWarning: taskToHasDependencyWarningMap ? checkTaskHasDependencyWarning(
6517
- task,
6518
- taskToHasDependencyWarningMap
6519
- ) : false,
6520
- progressWidth,
6521
- progressX: rtl ? innerX2 : innerX1,
6522
- selectTaskOnMouseDown,
6523
- task,
6524
- taskYOffset,
6525
- width,
6526
- x1: innerX1,
6527
- x2: innerX2,
6528
- childOutOfParentWarnings,
6529
- distances,
6530
- taskHeight,
6531
- taskHalfHeight,
6532
- isProgressChangeable: !task.isDisabled,
6533
- isDateChangeable: !task.isDisabled,
6534
- isRelationChangeable: !task.isRelationDisabled,
6535
- authorizedRelations,
6536
- ganttRelationEvent,
6537
- isDelete: !task.isDisabled,
6538
- onDoubleClick,
6539
- onClick,
6540
- onEventStart: handleTaskDragStart,
6541
- setTooltipTask,
6542
- onRelationStart: handleBarRelationStart,
6543
- isSelected: Boolean(selectedIdsMirror[taskId]),
6544
- isCritical,
6545
- rtl,
6546
- fixStartPosition,
6547
- fixEndPosition,
6548
- handleDeleteTasks,
6549
- colorStyles
6550
- }
6551
- )
6552
- },
6553
- key
6554
- )
6555
- );
6556
- const addedDependenciesAtLevel = addedDependencies[comparisonLevel] || {};
6557
- if (!addedDependencies[comparisonLevel]) {
6558
- addedDependencies[comparisonLevel] = addedDependenciesAtLevel;
6559
- }
6560
- const addedDependenciesAtTask = addedDependenciesAtLevel[taskId] || {};
6561
- if (!addedDependenciesAtLevel[taskId]) {
6562
- addedDependenciesAtLevel[taskId] = addedDependenciesAtTask;
6563
- }
6564
- const dependenciesAtLevel = dependencyMap.get(comparisonLevel);
6565
- if (!dependenciesAtLevel) {
6566
- continue;
6567
- }
6568
- const dependenciesByTask = dependenciesAtLevel.get(taskId);
6569
- if (dependenciesByTask) {
6570
- const criticalPathForTask = criticalPathOnLevel ? criticalPathOnLevel.dependencies.get(task.id) : void 0;
6571
- dependenciesByTask.filter(({ source }) => visibleTasksMirror[source.id]).forEach(
6572
- ({
6573
- containerHeight,
6574
- containerY,
6575
- innerFromY,
6576
- innerToY,
6577
- marginBetweenTasks,
6578
- ownTarget,
6579
- source,
6580
- sourceTarget
6581
- }) => {
6582
- if (addedDependenciesAtTask[source.id]) {
6583
- return;
6584
- }
6585
- addedDependenciesAtTask[source.id] = true;
6586
- const isCritical2 = criticalPathForTask ? criticalPathForTask.has(source.id) : false;
6587
- const { x1: fromX1, x2: fromX2 } = getTaskCoordinates2(source);
6588
- const containerX2 = Math.min(fromX1, taskX1) - 300;
6589
- const containerWidth2 = Math.max(fromX2, taskX2) - containerX2 + 300;
6590
- arrowsRes.push(
6564
+ console.log("tasksAtRow", tasksAtRow);
6565
+ for (const task of tasksAtRow) {
6566
+ const comparisonLevel = task.comparisonLevel ?? 1;
6567
+ const { id: taskId } = task;
6568
+ if (selectedIdsMirror[taskId] && !addedSelectedTasks[taskId]) {
6569
+ addedSelectedTasks[taskId] = true;
6570
+ const rowIndex = (_a = taskToRowIndexMap.get(comparisonLevel)) == null ? void 0 : _a.get(taskId);
6571
+ if (typeof rowIndex === "number") {
6572
+ selectedTasksRes.push(
6591
6573
  /* @__PURE__ */ jsxRuntime.jsx(
6592
- "svg",
6574
+ "rect",
6593
6575
  {
6594
- className: "ArrowClassName",
6595
- x: containerX2 + (additionalLeftSpace || 0),
6596
- y: containerY,
6597
- width: containerWidth2,
6598
- height: containerHeight,
6599
- children: /* @__PURE__ */ jsxRuntime.jsx(
6600
- Arrow,
6601
- {
6602
- colorStyles,
6603
- distances,
6604
- taskFrom: source,
6605
- extremityFrom: sourceTarget,
6606
- fromX1: fromX1 - containerX2,
6607
- fromX2: fromX2 - containerX2,
6608
- fromY: innerFromY,
6609
- taskTo: task,
6610
- extremityTo: ownTarget,
6611
- toX1: taskX1 - containerX2,
6612
- toX2: taskX2 - containerX2,
6613
- toY: innerToY,
6614
- marginBetweenTasks,
6615
- fullRowHeight,
6616
- taskHeight,
6617
- isShowDependencyWarnings,
6618
- isCritical: isCritical2,
6619
- rtl,
6620
- onArrowDoubleClick,
6621
- onArrowClick,
6622
- handleFixDependency
6623
- }
6624
- )
6576
+ x: 0,
6577
+ y: rowIndex * fullRowHeight,
6578
+ width: "100%",
6579
+ height: fullRowHeight,
6580
+ fill: colorStyles.selectedTaskBackgroundColor
6625
6581
  },
6626
- `Arrow from ${source.id} to ${taskId} on ${comparisonLevel}`
6582
+ `selected-${taskId}`
6627
6583
  )
6628
6584
  );
6629
6585
  }
6630
- );
6631
- }
6632
- const dependentsAtLevel = dependentMap.get(comparisonLevel);
6633
- if (!dependentsAtLevel) {
6634
- continue;
6635
- }
6636
- const dependentsByTask = dependentsAtLevel.get(taskId);
6637
- if (dependentsByTask) {
6638
- dependentsByTask.filter(({ dependent }) => visibleTasksMirror[dependent.id]).forEach(
6639
- ({
6640
- containerHeight,
6641
- containerY,
6642
- innerFromY,
6643
- innerToY,
6644
- marginBetweenTasks,
6645
- ownTarget,
6646
- dependent,
6647
- dependentTarget
6648
- }) => {
6649
- const addedDependenciesAtDependent = addedDependenciesAtLevel[dependent.id] || {};
6650
- if (!addedDependenciesAtLevel[dependent.id]) {
6651
- addedDependenciesAtLevel[dependent.id] = addedDependenciesAtDependent;
6652
- }
6653
- if (addedDependenciesAtDependent[taskId]) {
6654
- return;
6655
- }
6656
- addedDependenciesAtDependent[taskId] = true;
6657
- const criticalPathForTask = criticalPathOnLevel ? criticalPathOnLevel.dependencies.get(dependent.id) : void 0;
6658
- const isCritical2 = criticalPathForTask ? criticalPathForTask.has(task.id) : false;
6659
- const { x1: toX1, x2: toX2 } = getTaskCoordinates2(dependent);
6660
- const containerX2 = Math.min(toX1, taskX1) - 300;
6661
- const containerWidth2 = Math.max(toX2, taskX2) - containerX2 + 300;
6662
- arrowsRes.push(
6663
- /* @__PURE__ */ jsxRuntime.jsx(
6664
- "svg",
6586
+ }
6587
+ if (comparisonLevel > comparisonLevels)
6588
+ continue;
6589
+ if (task.type === "empty" || task.type === "user")
6590
+ continue;
6591
+ const key = `${comparisonLevel}_${task.id}`;
6592
+ const criticalPathOnLevel = criticalPaths == null ? void 0 : criticalPaths.get(comparisonLevel);
6593
+ const isCritical = !!(criticalPathOnLevel == null ? void 0 : criticalPathOnLevel.tasks.has(task.id));
6594
+ const {
6595
+ containerX,
6596
+ containerWidth,
6597
+ innerX1,
6598
+ innerX2,
6599
+ width,
6600
+ levelY,
6601
+ progressWidth,
6602
+ x1: taskX1,
6603
+ x2: taskX2
6604
+ } = getTaskCoordinates2(task);
6605
+ tasksRes.push(
6606
+ /* @__PURE__ */ jsxRuntime.jsx(
6607
+ "svg",
6608
+ {
6609
+ id: task.id,
6610
+ className: "TaskItemClassName",
6611
+ x: containerX + additionalLeftSpace,
6612
+ y: levelY,
6613
+ width: containerWidth,
6614
+ height: fullRowHeight,
6615
+ children: /* @__PURE__ */ jsxRuntime.jsx(
6616
+ TaskItem,
6665
6617
  {
6666
- x: containerX2 + (additionalLeftSpace || 0),
6667
- y: containerY,
6668
- width: containerWidth2,
6669
- height: containerHeight,
6670
- children: /* @__PURE__ */ jsxRuntime.jsx(
6671
- Arrow,
6672
- {
6673
- colorStyles,
6674
- distances,
6675
- taskFrom: task,
6676
- extremityFrom: ownTarget,
6677
- fromX1: taskX1 - containerX2,
6678
- fromX2: taskX2 - containerX2,
6679
- fromY: innerFromY,
6680
- taskTo: dependent,
6681
- extremityTo: dependentTarget,
6682
- toX1: toX1 - containerX2,
6683
- toX2: toX2 - containerX2,
6684
- toY: innerToY,
6685
- marginBetweenTasks,
6686
- fullRowHeight,
6687
- taskHeight,
6688
- isShowDependencyWarnings,
6689
- isCritical: isCritical2,
6690
- rtl,
6691
- onArrowDoubleClick,
6692
- onArrowClick,
6693
- handleFixDependency
6694
- }
6695
- )
6696
- },
6697
- `Arrow from ${taskId} to ${dependent.id} on ${comparisonLevel}`
6618
+ getTaskGlobalIndexByRef,
6619
+ hasChildren: checkHasChildren(task, childTasksMap),
6620
+ hasDependencyWarning: taskToHasDependencyWarningMap ? checkTaskHasDependencyWarning(task, taskToHasDependencyWarningMap) : false,
6621
+ progressWidth,
6622
+ progressX: rtl ? innerX2 : innerX1,
6623
+ selectTaskOnMouseDown,
6624
+ task,
6625
+ taskYOffset,
6626
+ width,
6627
+ x1: innerX1,
6628
+ x2: innerX2,
6629
+ childOutOfParentWarnings,
6630
+ distances,
6631
+ taskHeight,
6632
+ taskHalfHeight,
6633
+ isProgressChangeable: !task.isDisabled,
6634
+ isDateChangeable: !task.isDisabled,
6635
+ isRelationChangeable: !task.isRelationDisabled,
6636
+ authorizedRelations,
6637
+ ganttRelationEvent,
6638
+ isDelete: !task.isDisabled,
6639
+ onDoubleClick,
6640
+ onClick,
6641
+ onEventStart: handleTaskDragStart,
6642
+ setTooltipTask,
6643
+ onRelationStart: handleBarRelationStart,
6644
+ isSelected: Boolean(selectedIdsMirror[taskId]),
6645
+ isCritical,
6646
+ rtl,
6647
+ fixStartPosition,
6648
+ fixEndPosition,
6649
+ handleDeleteTasks,
6650
+ colorStyles
6651
+ }
6698
6652
  )
6699
- );
6700
- }
6653
+ },
6654
+ key
6655
+ )
6701
6656
  );
6657
+ const addedDependenciesAtLevel = addedDependencies[comparisonLevel] ?? (addedDependencies[comparisonLevel] = {});
6658
+ const addedDependenciesAtTask = addedDependenciesAtLevel[taskId] ?? (addedDependenciesAtLevel[taskId] = {});
6659
+ const dependenciesAtLevel = dependencyMap.get(comparisonLevel);
6660
+ const dependenciesByTask = dependenciesAtLevel == null ? void 0 : dependenciesAtLevel.get(taskId);
6661
+ dependenciesByTask == null ? void 0 : dependenciesByTask.filter(({ source }) => visibleTasksMirror[source.id]).forEach((dep) => {
6662
+ var _a2;
6663
+ if (addedDependenciesAtTask[dep.source.id])
6664
+ return;
6665
+ addedDependenciesAtTask[dep.source.id] = true;
6666
+ const { x1: fromX1, x2: fromX2 } = getTaskCoordinates2(dep.source);
6667
+ const containerX2 = Math.min(fromX1, taskX1) - 300;
6668
+ const containerWidth2 = Math.max(fromX2, taskX2) - containerX2 + 300;
6669
+ const isDepCritical = !!((_a2 = criticalPathOnLevel == null ? void 0 : criticalPathOnLevel.dependencies.get(task.id)) == null ? void 0 : _a2.has(dep.source.id));
6670
+ arrowsRes.push(
6671
+ /* @__PURE__ */ jsxRuntime.jsx(
6672
+ "svg",
6673
+ {
6674
+ className: "ArrowClassName",
6675
+ x: containerX2 + additionalLeftSpace,
6676
+ y: dep.containerY,
6677
+ width: containerWidth2,
6678
+ height: dep.containerHeight,
6679
+ children: /* @__PURE__ */ jsxRuntime.jsx(
6680
+ Arrow,
6681
+ {
6682
+ colorStyles,
6683
+ distances,
6684
+ taskFrom: dep.source,
6685
+ extremityFrom: dep.sourceTarget,
6686
+ fromX1: fromX1 - containerX2,
6687
+ fromX2: fromX2 - containerX2,
6688
+ fromY: dep.innerFromY,
6689
+ taskTo: task,
6690
+ extremityTo: dep.ownTarget,
6691
+ toX1: taskX1 - containerX2,
6692
+ toX2: taskX2 - containerX2,
6693
+ toY: dep.innerToY,
6694
+ marginBetweenTasks: dep.marginBetweenTasks,
6695
+ fullRowHeight,
6696
+ taskHeight,
6697
+ isShowDependencyWarnings,
6698
+ isCritical: isDepCritical,
6699
+ rtl,
6700
+ onArrowDoubleClick,
6701
+ onArrowClick,
6702
+ handleFixDependency
6703
+ }
6704
+ )
6705
+ },
6706
+ `Arrow from ${dep.source.id} to ${taskId} on ${comparisonLevel}`
6707
+ )
6708
+ );
6709
+ });
6710
+ const dependentsAtLevel = dependentMap.get(comparisonLevel);
6711
+ const dependentsByTask = dependentsAtLevel == null ? void 0 : dependentsAtLevel.get(taskId);
6712
+ dependentsByTask == null ? void 0 : dependentsByTask.filter(({ dependent }) => visibleTasksMirror[dependent.id]).forEach((dep) => {
6713
+ var _a2, _b;
6714
+ console.log("dependent", dep);
6715
+ const addedDepsForDep = addedDependenciesAtLevel[_a2 = dep.dependent.id] ?? (addedDependenciesAtLevel[_a2] = {});
6716
+ if (addedDepsForDep[taskId])
6717
+ return;
6718
+ addedDepsForDep[taskId] = true;
6719
+ const isDepCritical = !!((_b = criticalPathOnLevel == null ? void 0 : criticalPathOnLevel.dependencies.get(dep.dependent.id)) == null ? void 0 : _b.has(task.id));
6720
+ const { x1: toX1, x2: toX2 } = getTaskCoordinates2(dep.dependent);
6721
+ const containerX2 = Math.min(toX1, taskX1) - 300;
6722
+ const containerWidth2 = Math.max(toX2, taskX2) - containerX2 + 300;
6723
+ arrowsRes.push(
6724
+ /* @__PURE__ */ jsxRuntime.jsx(
6725
+ "svg",
6726
+ {
6727
+ className: "ArrowClassName",
6728
+ x: containerX2 + additionalLeftSpace,
6729
+ y: dep.containerY,
6730
+ width: containerWidth2,
6731
+ height: dep.containerHeight,
6732
+ children: /* @__PURE__ */ jsxRuntime.jsx(
6733
+ Arrow,
6734
+ {
6735
+ colorStyles,
6736
+ distances,
6737
+ taskFrom: task,
6738
+ extremityFrom: dep.ownTarget,
6739
+ fromX1: taskX1 - containerX2,
6740
+ fromX2: taskX2 - containerX2,
6741
+ fromY: dep.innerFromY,
6742
+ taskTo: dep.dependent,
6743
+ extremityTo: dep.dependentTarget,
6744
+ toX1: toX1 - containerX2,
6745
+ toX2: toX2 - containerX2,
6746
+ toY: dep.innerToY,
6747
+ marginBetweenTasks: dep.marginBetweenTasks,
6748
+ fullRowHeight,
6749
+ taskHeight,
6750
+ isShowDependencyWarnings,
6751
+ isCritical: isDepCritical,
6752
+ rtl,
6753
+ onArrowDoubleClick,
6754
+ onArrowClick,
6755
+ handleFixDependency
6756
+ }
6757
+ )
6758
+ },
6759
+ `Arrow from ${taskId} to ${dep.dependent.id} on ${comparisonLevel}`
6760
+ )
6761
+ );
6762
+ });
6702
6763
  }
6703
6764
  }
6704
6765
  return [tasksRes, arrowsRes, selectedTasksRes];
@@ -6715,7 +6776,9 @@
6715
6776
  renderedRowIndexes,
6716
6777
  selectTaskOnMouseDown,
6717
6778
  selectedIdsMirror,
6718
- visibleTasksMirror
6779
+ visibleTasksMirror,
6780
+ rowIndexToTasksMap,
6781
+ enableTaskGrouping
6719
6782
  ]);
6720
6783
  return /* @__PURE__ */ jsxRuntime.jsxs("g", { className: "content", children: [
6721
6784
  renderedSelectedTasks,
@@ -11389,42 +11452,48 @@
11389
11452
  const rowIndexToTaskMap = /* @__PURE__ */ new Map();
11390
11453
  const rowIndexToTasksMap = /* @__PURE__ */ new Map();
11391
11454
  const mapGlobalRowIndexToTask = /* @__PURE__ */ new Map();
11392
- const parentMap = new Map(
11393
- tasks.map((task) => [task.id, task])
11394
- );
11455
+ const parentMap = new Map(tasks.map((t) => [t.id, t]));
11395
11456
  let globalRowIndex = 0;
11396
11457
  for (let comparisonLevel = 1; comparisonLevel <= comparisonLevels; comparisonLevel++) {
11397
- const taskToRowIndexMapAtLevel = /* @__PURE__ */ new Map();
11398
- const rowIndexToTaskMapAtLevel = /* @__PURE__ */ new Map();
11399
- const rowIndexToTasksMapAtLevel = /* @__PURE__ */ new Map();
11400
- taskToRowIndexMap.set(comparisonLevel, taskToRowIndexMapAtLevel);
11401
- rowIndexToTaskMap.set(comparisonLevel, rowIndexToTaskMapAtLevel);
11402
- rowIndexToTasksMap.set(comparisonLevel, rowIndexToTasksMapAtLevel);
11458
+ const taskToRow = /* @__PURE__ */ new Map();
11459
+ const rowToTask = /* @__PURE__ */ new Map();
11460
+ const rowToTasks = /* @__PURE__ */ new Map();
11461
+ taskToRowIndexMap.set(comparisonLevel, taskToRow);
11462
+ rowIndexToTaskMap.set(comparisonLevel, rowToTask);
11463
+ rowIndexToTasksMap.set(comparisonLevel, rowToTasks);
11403
11464
  let rowIndex = 0;
11404
11465
  for (const task of tasks) {
11405
- const level = task.comparisonLevel ?? 1;
11406
- if (level !== comparisonLevel)
11466
+ if ((task.comparisonLevel ?? 1) !== comparisonLevel)
11407
11467
  continue;
11408
- const { id, parent } = task;
11468
+ const { id, parent, type } = task;
11409
11469
  let assignedRowIndex = rowIndex;
11410
- if (isGrouped && parent && parentMap.has(parent)) {
11470
+ if (type === "user" || type === "project") {
11471
+ taskToRow.set(id, rowIndex);
11472
+ rowToTask.set(rowIndex, task);
11473
+ rowToTasks.set(rowIndex, [task]);
11474
+ mapGlobalRowIndexToTask.set(globalRowIndex, task);
11475
+ rowIndex++;
11476
+ globalRowIndex++;
11477
+ continue;
11478
+ }
11479
+ if (isGrouped && parent) {
11411
11480
  const parentTask = parentMap.get(parent);
11412
- const isGroupedAudit = (parentTask == null ? void 0 : parentTask.type) === "user" && (parentTask == null ? void 0 : parentTask.hideChildren);
11413
- if (isGroupedAudit) {
11414
- const parentRowIndex = taskToRowIndexMapAtLevel.get(parent);
11415
- if (typeof parentRowIndex === "number") {
11416
- assignedRowIndex = parentRowIndex;
11417
- }
11481
+ const parentRowIndex = taskToRow.get(parent);
11482
+ if ((parentTask == null ? void 0 : parentTask.hideChildren) && parentRowIndex !== void 0) {
11483
+ assignedRowIndex = parentRowIndex;
11484
+ } else {
11485
+ assignedRowIndex = rowIndex;
11486
+ rowIndex++;
11418
11487
  }
11419
- }
11420
- taskToRowIndexMapAtLevel.set(id, assignedRowIndex);
11421
- rowIndexToTaskMapAtLevel.set(assignedRowIndex, task);
11422
- const existingTasks = rowIndexToTasksMapAtLevel.get(assignedRowIndex) ?? [];
11423
- rowIndexToTasksMapAtLevel.set(assignedRowIndex, [...existingTasks, task]);
11424
- mapGlobalRowIndexToTask.set(globalRowIndex, task);
11425
- if (assignedRowIndex === rowIndex) {
11488
+ } else {
11489
+ assignedRowIndex = rowIndex;
11426
11490
  rowIndex++;
11427
11491
  }
11492
+ taskToRow.set(id, assignedRowIndex);
11493
+ rowToTask.set(assignedRowIndex, task);
11494
+ const existing = rowToTasks.get(assignedRowIndex) ?? [];
11495
+ rowToTasks.set(assignedRowIndex, [...existing, task]);
11496
+ mapGlobalRowIndexToTask.set(globalRowIndex, task);
11428
11497
  globalRowIndex++;
11429
11498
  }
11430
11499
  }
@@ -11490,6 +11559,7 @@
11490
11559
  const defaultDistances = {
11491
11560
  actionColumnWidth: 40,
11492
11561
  arrowIndent: 20,
11562
+ taskHeight: 24,
11493
11563
  barCornerRadius: 3,
11494
11564
  barFill: 60,
11495
11565
  columnWidth: 60,
@@ -11676,11 +11746,6 @@
11676
11746
  () => distances.rowHeight * comparisonLevels,
11677
11747
  [distances, comparisonLevels]
11678
11748
  );
11679
- const renderedRowIndexes = useOptimizedList(
11680
- ganttTaskContentRef,
11681
- "scrollTop",
11682
- distances.rowHeight
11683
- );
11684
11749
  const colorStyles = React.useMemo(
11685
11750
  () => ({
11686
11751
  ...defaultColors,
@@ -11696,18 +11761,15 @@
11696
11761
  () => (distances.rowHeight - taskHeight) / 2,
11697
11762
  [distances, taskHeight]
11698
11763
  );
11699
- const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask, rowIndexToTasksMap] = React.useMemo(
11700
- () => enableTaskGrouping ? getMapTaskToRowIndexWithGrouping(visibleTasks, comparisonLevels, true) : getMapTaskToRowIndex(visibleTasks, comparisonLevels),
11701
- [visibleTasks, comparisonLevels, enableTaskGrouping]
11702
- );
11703
11764
  const taskHalfHeight = React.useMemo(
11704
11765
  () => Math.round(taskHeight / 2),
11705
11766
  [taskHeight]
11706
11767
  );
11768
+ const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask, rowIndexToTasksMap] = React.useMemo(
11769
+ () => enableTaskGrouping ? getMapTaskToRowIndexWithGrouping(visibleTasks, comparisonLevels, true) : getMapTaskToRowIndex(visibleTasks, comparisonLevels),
11770
+ [visibleTasks, comparisonLevels, enableTaskGrouping]
11771
+ );
11707
11772
  const maxLevelLength = React.useMemo(() => {
11708
- if (enableTaskGrouping) {
11709
- return Math.max((rowIndexToTasksMap == null ? void 0 : rowIndexToTasksMap.size) ?? 0, 1);
11710
- }
11711
11773
  let maxLength = 0;
11712
11774
  const countByLevel = {};
11713
11775
  visibleTasks.forEach(({ comparisonLevel = 1 }) => {
@@ -11720,20 +11782,26 @@
11720
11782
  }
11721
11783
  });
11722
11784
  return maxLength;
11723
- }, [visibleTasks, comparisonLevels, enableTaskGrouping, rowIndexToTasksMap]);
11785
+ }, [visibleTasks, comparisonLevels]);
11724
11786
  const ganttFullHeight = React.useMemo(() => {
11725
- if (enableTaskGrouping) {
11726
- let totalHeight = 0;
11727
- for (const [, taskMap] of rowIndexToTasksMap) {
11728
- for (const [, tasks2] of taskMap) {
11729
- const rowHeight = tasks2.length * (taskHeight + 2);
11730
- totalHeight += Math.max(rowHeight, fullRowHeight);
11731
- }
11732
- }
11733
- return Math.max(totalHeight, fullRowHeight);
11787
+ if (!enableTaskGrouping) {
11788
+ return maxLevelLength * fullRowHeight;
11734
11789
  }
11735
- return maxLevelLength * fullRowHeight;
11736
- }, [enableTaskGrouping, rowIndexToTasksMap, maxLevelLength, fullRowHeight, taskHeight]);
11790
+ let totalRows = 0;
11791
+ for (const comparisonMap of rowIndexToTasksMap.values()) {
11792
+ totalRows += comparisonMap.size;
11793
+ }
11794
+ return totalRows * fullRowHeight;
11795
+ }, [enableTaskGrouping, rowIndexToTasksMap, maxLevelLength, fullRowHeight]);
11796
+ const renderedRowIndexes = enableTaskGrouping ? useGroupedVirtualization(
11797
+ //ganttTaskContentRef,
11798
+ rowIndexToTasksMap,
11799
+ fullRowHeight
11800
+ ) : useOptimizedList(
11801
+ ganttTaskContentRef,
11802
+ "scrollTop",
11803
+ fullRowHeight
11804
+ );
11737
11805
  const {
11738
11806
  checkHasCopyTasks,
11739
11807
  checkHasCutTasks,
@@ -11792,22 +11860,10 @@
11792
11860
  const svgClientWidth = renderedColumnIndexes && renderedColumnIndexes[4];
11793
11861
  const countTaskCoordinates$1 = React.useCallback(
11794
11862
  (task) => {
11795
- var _a;
11796
11863
  if (enableTaskGrouping) {
11797
- const comparisonLevel = task.comparisonLevel ?? 1;
11798
- let sequentialOffset = 0;
11799
- const indexesAtLevel = taskToRowIndexMap.get(comparisonLevel);
11800
- const rowIndex = indexesAtLevel == null ? void 0 : indexesAtLevel.get(task.id);
11801
- if (typeof rowIndex === "number") {
11802
- const rowTasksAtLevel = ((_a = rowIndexToTasksMap.get(comparisonLevel)) == null ? void 0 : _a.get(rowIndex)) ?? [];
11803
- const indexInRow = rowTasksAtLevel.findIndex((t) => t.id === task.id);
11804
- if (indexInRow !== -1) {
11805
- sequentialOffset = indexInRow * (taskHeight + 2);
11806
- }
11807
- }
11808
11864
  return countTaskCoordinatesWithGrouping(
11809
11865
  task,
11810
- taskToRowIndexMap,
11866
+ rowIndexToTasksMap,
11811
11867
  startDate,
11812
11868
  viewMode,
11813
11869
  rtl,
@@ -11816,7 +11872,7 @@
11816
11872
  taskYOffset,
11817
11873
  distances,
11818
11874
  svgWidth,
11819
- sequentialOffset
11875
+ 0
11820
11876
  );
11821
11877
  }
11822
11878
  return countTaskCoordinates(
@@ -11847,7 +11903,19 @@
11847
11903
  ]
11848
11904
  );
11849
11905
  const mapTaskToCoordinates = React.useMemo(
11850
- () => getMapTaskToCoordinates(
11906
+ () => enableTaskGrouping ? getMapTaskToCoordinatesWithGrouping(
11907
+ tasks,
11908
+ visibleTasksMirror,
11909
+ rowIndexToTasksMap,
11910
+ startDate,
11911
+ viewMode,
11912
+ rtl,
11913
+ fullRowHeight,
11914
+ taskHeight,
11915
+ taskYOffset,
11916
+ distances,
11917
+ svgWidth
11918
+ ) : getMapTaskToCoordinates(
11851
11919
  tasks,
11852
11920
  visibleTasksMirror,
11853
11921
  taskToRowIndexMap,
@@ -11861,17 +11929,19 @@
11861
11929
  svgWidth
11862
11930
  ),
11863
11931
  [
11864
- distances,
11865
- fullRowHeight,
11932
+ tasks,
11933
+ visibleTasksMirror,
11934
+ rowIndexToTasksMap,
11866
11935
  taskToRowIndexMap,
11867
- rtl,
11868
11936
  startDate,
11869
- svgWidth,
11937
+ viewMode,
11938
+ rtl,
11939
+ fullRowHeight,
11870
11940
  taskHeight,
11871
- tasks,
11872
11941
  taskYOffset,
11873
- viewMode,
11874
- visibleTasksMirror
11942
+ distances,
11943
+ svgWidth,
11944
+ enableTaskGrouping
11875
11945
  ]
11876
11946
  );
11877
11947
  const scrollToTask = React.useCallback(
@@ -12006,8 +12076,6 @@
12006
12076
  };
12007
12077
  const handleExpanderClick = React.useCallback(
12008
12078
  (clickedTask) => {
12009
- console.log(`Task ${clickedTask.id} hideChildren changed from ${clickedTask.hideChildren} to ${!clickedTask.hideChildren}`);
12010
- console.log("Task types:", tasks.map((task) => `${task.id}: ${task.type}`));
12011
12079
  if (onChangeExpandState) {
12012
12080
  onChangeExpandState({
12013
12081
  ...clickedTask,
@@ -12883,6 +12951,8 @@
12883
12951
  };
12884
12952
  const barProps = React.useMemo(
12885
12953
  () => ({
12954
+ enableTaskGrouping,
12955
+ rowIndexToTasksMap,
12886
12956
  authorizedRelations,
12887
12957
  additionalLeftSpace,
12888
12958
  additionalRightSpace,
@@ -12932,6 +13002,8 @@
12932
13002
  [
12933
13003
  additionalLeftSpace,
12934
13004
  additionalRightSpace,
13005
+ enableTaskGrouping,
13006
+ rowIndexToTasksMap,
12935
13007
  checkIsHoliday,
12936
13008
  childOutOfParentWarnings,
12937
13009
  childTasksMap,
@@ -12983,6 +13055,7 @@
12983
13055
  TaskListHeader,
12984
13056
  TaskListTable,
12985
13057
  enableTaskGrouping,
13058
+ rowIndexToTasksMap,
12986
13059
  canMoveTasks,
12987
13060
  canResizeColumns,
12988
13061
  childTasksMap,