@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.
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
- import React__default, { useState, useEffect, useCallback, memo, Fragment, useMemo, useRef, useLayoutEffect } from "react";
3
+ import React__default, { useState, useEffect, useMemo, useCallback, memo, Fragment, useRef, useLayoutEffect } from "react";
4
4
  import { UnfoldLess, UnfoldMore, UnfoldMoreDouble } from "@mui/icons-material";
5
5
  import { createTheme, ThemeProvider, Tooltip as Tooltip$1, IconButton } from "@mui/material";
6
6
  import ClickAwayListener from "@mui/material/ClickAwayListener";
@@ -461,7 +461,6 @@ var locale = {
461
461
  const enDateLocale = locale;
462
462
  const collectChildren = (arrayRes, mirrorRes, task, childTasksOnLevel, enableTaskGrouping) => {
463
463
  const { comparisonLevel = 1 } = task;
464
- 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`);
465
464
  arrayRes.push(task);
466
465
  if (comparisonLevel === 1) {
467
466
  mirrorRes[task.id] = true;
@@ -1591,14 +1590,9 @@ const handleTaskBySVGMouseEventForMilestone = (action, selectedTask, initialCoor
1591
1590
  return { isChanged, changedTask };
1592
1591
  };
1593
1592
  const countTaskCoordinates = (task, taskToRowIndexMap, startDate, viewMode, rtl, fullRowHeight, taskHeight, taskYOffset, distances, svgWidth, sequentialOffset = 0) => {
1594
- const { columnWidth, rowHeight } = distances;
1593
+ const { columnWidth } = distances;
1595
1594
  const { id, comparisonLevel = 1, progress, type } = task;
1596
1595
  const indexesAtLevel = taskToRowIndexMap.get(comparisonLevel);
1597
- console.log("Looking for task id:", task.id, "level:", comparisonLevel);
1598
- console.log("taskToRowIndexMap", Array.from(taskToRowIndexMap.entries()).map(([level, map]) => ({
1599
- level,
1600
- rows: Array.from(map.entries())
1601
- })));
1602
1596
  if (!indexesAtLevel) {
1603
1597
  throw new Error(`Indexes at level ${comparisonLevel} are not found`);
1604
1598
  }
@@ -1608,7 +1602,7 @@ const countTaskCoordinates = (task, taskToRowIndexMap, startDate, viewMode, rtl,
1608
1602
  }
1609
1603
  const x1 = rtl ? svgWidth - taskXCoordinate(task.end, startDate, viewMode, columnWidth) : taskXCoordinate(task.start, startDate, viewMode, columnWidth);
1610
1604
  const x22 = rtl ? svgWidth - taskXCoordinate(task.start, startDate, viewMode, columnWidth) : taskXCoordinate(task.end, startDate, viewMode, columnWidth);
1611
- const levelY = rowIndex * fullRowHeight + rowHeight * (comparisonLevel - 1);
1605
+ const levelY = rowIndex * fullRowHeight;
1612
1606
  const y3 = levelY + taskYOffset + sequentialOffset;
1613
1607
  const [progressWidth, progressX] = type === "milestone" ? [0, x1] : progressWithByParams(x1, x22, progress, rtl);
1614
1608
  const taskX1 = type === "milestone" ? x1 - taskHeight * 0.5 : x1;
@@ -1660,21 +1654,31 @@ const getMapTaskToCoordinates = (tasks, visibleTasksMirror, taskToRowIndexMap, s
1660
1654
  });
1661
1655
  return res;
1662
1656
  };
1663
- const countTaskCoordinatesWithGrouping = (task, taskToRowIndexMap, startDate, viewMode, rtl, fullRowHeight, taskHeight, taskYOffset, distances, svgWidth, sequentialOffset = 0) => {
1664
- const { columnWidth, rowHeight } = distances;
1657
+ const countTaskCoordinatesWithGrouping = (task, rowIndexToTasksMap, startDate, viewMode, rtl, fullRowHeight, taskHeight, taskYOffset, distances, svgWidth, sequentialOffset = 0) => {
1658
+ const { columnWidth } = distances;
1665
1659
  const { id, comparisonLevel = 1, progress, type } = task;
1666
- const indexesAtLevel = taskToRowIndexMap.get(comparisonLevel);
1667
- if (!indexesAtLevel) {
1668
- throw new Error(`Indexes at level ${comparisonLevel} are not found`);
1660
+ let rowIndex = -1;
1661
+ let taskIndexInRow = 0;
1662
+ const rowMapAtLevel = rowIndexToTasksMap.get(comparisonLevel);
1663
+ if (!rowMapAtLevel) {
1664
+ throw new Error(`No rows found for comparison level ${comparisonLevel}`);
1665
+ }
1666
+ for (const [currentRowIndex, tasksInRow] of rowMapAtLevel.entries()) {
1667
+ const taskIndex = tasksInRow.findIndex((t2) => t2.id === id);
1668
+ if (taskIndex !== -1) {
1669
+ rowIndex = currentRowIndex;
1670
+ taskIndexInRow = taskIndex;
1671
+ break;
1672
+ }
1669
1673
  }
1670
- const rowIndex = indexesAtLevel.get(id);
1671
- if (typeof rowIndex !== "number") {
1672
- throw new Error(`Row index for task ${id} is not found`);
1674
+ if (rowIndex === -1) {
1675
+ throw new Error(`Task ${id} not found in rowIndexToTasksMap`);
1673
1676
  }
1674
1677
  const x1 = rtl ? svgWidth - taskXCoordinate(task.end, startDate, viewMode, columnWidth) : taskXCoordinate(task.start, startDate, viewMode, columnWidth);
1675
1678
  const x22 = rtl ? svgWidth - taskXCoordinate(task.start, startDate, viewMode, columnWidth) : taskXCoordinate(task.end, startDate, viewMode, columnWidth);
1676
- const levelY = rowIndex * fullRowHeight + rowHeight * (comparisonLevel - 1);
1677
- const y3 = levelY + taskYOffset + sequentialOffset;
1679
+ const levelY = rowIndex * fullRowHeight;
1680
+ const taskStackOffset = taskIndexInRow * (taskHeight + 2);
1681
+ const y3 = levelY + taskYOffset + sequentialOffset + taskStackOffset;
1678
1682
  const [progressWidth, progressX] = type === "milestone" ? [0, x1] : progressWithByParams(x1, x22, progress, rtl);
1679
1683
  const taskX1 = type === "milestone" ? x1 - taskHeight * 0.5 : x1;
1680
1684
  const taskX2 = type === "milestone" ? x22 + taskHeight * 0.5 : x22;
@@ -1697,6 +1701,34 @@ const countTaskCoordinatesWithGrouping = (task, taskToRowIndexMap, startDate, vi
1697
1701
  y: y3
1698
1702
  };
1699
1703
  };
1704
+ const getMapTaskToCoordinatesWithGrouping = (tasks, visibleTasksMirror, rowIndexToTasksMap, startDate, viewMode, rtl, fullRowHeight, taskHeight, taskYOffset, distances, svgWidth) => {
1705
+ const res = /* @__PURE__ */ new Map();
1706
+ tasks.forEach((task) => {
1707
+ if (task.type === "empty" || task.type === "user") {
1708
+ return;
1709
+ }
1710
+ const { id, comparisonLevel = 1 } = task;
1711
+ if (!visibleTasksMirror[id]) {
1712
+ return;
1713
+ }
1714
+ const taskCoordinates = countTaskCoordinatesWithGrouping(
1715
+ task,
1716
+ rowIndexToTasksMap,
1717
+ startDate,
1718
+ viewMode,
1719
+ rtl,
1720
+ fullRowHeight,
1721
+ taskHeight,
1722
+ taskYOffset,
1723
+ distances,
1724
+ svgWidth
1725
+ );
1726
+ const resByLevel = res.get(comparisonLevel) || /* @__PURE__ */ new Map();
1727
+ resByLevel.set(id, taskCoordinates);
1728
+ res.set(comparisonLevel, resByLevel);
1729
+ });
1730
+ return res;
1731
+ };
1700
1732
  const getMapTaskToGlobalIndex = (tasks) => {
1701
1733
  const res = /* @__PURE__ */ new Map();
1702
1734
  tasks.forEach((task, index2) => {
@@ -1710,43 +1742,33 @@ const getMapTaskToGlobalIndex = (tasks) => {
1710
1742
  });
1711
1743
  return res;
1712
1744
  };
1713
- const getMapTaskTo = (indexesOnLevel, taskId, level, collectedIndex, childTasksOnLevel) => {
1714
- const childs = childTasksOnLevel.get(taskId);
1715
- if (childs && childs.length > 0) {
1716
- childs.forEach(({
1717
- id: childId
1718
- }, index2) => {
1719
- const childIndex = `${collectedIndex}.${index2 + 1}`;
1720
- indexesOnLevel.set(childId, [level, childIndex]);
1721
- getMapTaskTo(
1722
- indexesOnLevel,
1723
- childId,
1724
- level + 1,
1725
- childIndex,
1726
- childTasksOnLevel
1727
- );
1728
- });
1745
+ const setIndex = (map, level, id, depth, indexStr) => {
1746
+ if (!map.has(level)) {
1747
+ map.set(level, /* @__PURE__ */ new Map());
1729
1748
  }
1749
+ map.get(level).set(id, [depth, indexStr]);
1750
+ };
1751
+ const walkTasks = (map, comparisonLevel, parentId, depth, prefix, childTasksMap) => {
1752
+ const children = childTasksMap.get(parentId);
1753
+ if (!children)
1754
+ return;
1755
+ children.forEach((child, i2) => {
1756
+ const indexStr = `${prefix}.${i2 + 1}`;
1757
+ setIndex(map, comparisonLevel, child.id, depth, indexStr);
1758
+ walkTasks(map, comparisonLevel, child.id, depth + 1, indexStr, childTasksMap);
1759
+ });
1730
1760
  };
1731
1761
  const getMapTaskToNestedIndex = (childTasksMap, rootTasksMap) => {
1732
- const res = /* @__PURE__ */ new Map();
1762
+ const map = /* @__PURE__ */ new Map();
1733
1763
  for (const [comparisonLevel, rootTasks] of rootTasksMap.entries()) {
1734
- const indexesOnLevel = /* @__PURE__ */ new Map();
1735
- const childTasksOnLevel = childTasksMap.get(comparisonLevel) || /* @__PURE__ */ new Map();
1736
- rootTasks.forEach(({ id: rootId }, index2) => {
1737
- const rootIndex = `${index2 + 1}`;
1738
- indexesOnLevel.set(rootId, [0, rootIndex]);
1739
- getMapTaskTo(
1740
- indexesOnLevel,
1741
- rootId,
1742
- 1,
1743
- rootIndex,
1744
- childTasksOnLevel
1745
- );
1764
+ const childMap = childTasksMap.get(comparisonLevel) ?? /* @__PURE__ */ new Map();
1765
+ rootTasks.forEach((task, i2) => {
1766
+ const indexStr = `${i2 + 1}`;
1767
+ setIndex(map, comparisonLevel, task.id, 0, indexStr);
1768
+ walkTasks(map, comparisonLevel, task.id, 1, indexStr, childMap);
1746
1769
  });
1747
- res.set(comparisonLevel, indexesOnLevel);
1748
1770
  }
1749
- return res;
1771
+ return map;
1750
1772
  };
1751
1773
  const getMapTaskToRowIndex = (visibleTasks, comparisonLevels) => {
1752
1774
  const taskToRowIndexRes = /* @__PURE__ */ new Map();
@@ -1921,6 +1943,26 @@ const useOptimizedList = (containerRef, property, cellSize) => {
1921
1943
  ]);
1922
1944
  return indexes;
1923
1945
  };
1946
+ const useGroupedVirtualization = (rowIndexToTasksMap, taskHeight) => {
1947
+ var _a, _b;
1948
+ const rowEntries = useMemo(() => {
1949
+ const rowToHeight = /* @__PURE__ */ new Map();
1950
+ for (const levelMap of rowIndexToTasksMap.values()) {
1951
+ for (const [rowIndex, tasks] of levelMap.entries()) {
1952
+ const height = tasks.length * (taskHeight + 2);
1953
+ rowToHeight.set(rowIndex, (rowToHeight.get(rowIndex) ?? 0) + height);
1954
+ }
1955
+ }
1956
+ return [...rowToHeight.entries()].map(([rowIndex, height]) => ({ rowIndex, height })).sort((a4, b3) => a4.rowIndex - b3.rowIndex);
1957
+ }, [rowIndexToTasksMap, taskHeight]);
1958
+ return [
1959
+ ((_a = rowEntries[0]) == null ? void 0 : _a.rowIndex) ?? 0,
1960
+ ((_b = rowEntries[rowEntries.length - 1]) == null ? void 0 : _b.rowIndex) ?? 0,
1961
+ true,
1962
+ true,
1963
+ rowEntries.reduce((sum, entry) => sum + entry.height, 0)
1964
+ ];
1965
+ };
1924
1966
  const button$2 = "_button_1eue5_1";
1925
1967
  const styles$i = {
1926
1968
  button: button$2
@@ -3357,6 +3399,7 @@ const TaskListInner = ({
3357
3399
  dateSetup,
3358
3400
  dependencyMap,
3359
3401
  distances,
3402
+ rowIndexToTasksMap,
3360
3403
  fontFamily,
3361
3404
  fontSize,
3362
3405
  fullRowHeight,
@@ -3395,7 +3438,11 @@ const TaskListInner = ({
3395
3438
  onTableResizeStart,
3396
3439
  onColumnResizeStart
3397
3440
  ] = useTableListResize(columnsProp, distances, onResizeColumn);
3398
- const renderedIndexes = useOptimizedList(
3441
+ const renderedIndexes = enableTaskGrouping ? useGroupedVirtualization(
3442
+ //taskListContentRef,
3443
+ rowIndexToTasksMap,
3444
+ distances.taskHeight
3445
+ ) : useOptimizedList(
3399
3446
  taskListContentRef,
3400
3447
  "scrollTop",
3401
3448
  fullRowHeight
@@ -3451,6 +3498,7 @@ const TaskListInner = ({
3451
3498
  columns,
3452
3499
  cutIdsMirror,
3453
3500
  enableTaskGrouping,
3501
+ rowIndexToTasksMap,
3454
3502
  dateSetup,
3455
3503
  dependencyMap,
3456
3504
  distances,
@@ -3672,21 +3720,6 @@ const TaskListHeaderDefaultInner = (props) => {
3672
3720
  );
3673
3721
  };
3674
3722
  const TaskListHeaderDefault = memo(TaskListHeaderDefaultInner);
3675
- const checkHasChildren = (task, childTasksMap) => {
3676
- const {
3677
- id,
3678
- comparisonLevel = 1
3679
- } = task;
3680
- const childIdsByLevel = childTasksMap.get(comparisonLevel);
3681
- if (!childIdsByLevel) {
3682
- return false;
3683
- }
3684
- const childs = childIdsByLevel.get(id);
3685
- if (!childs) {
3686
- return false;
3687
- }
3688
- return childs.length > 0;
3689
- };
3690
3723
  const taskListTableRow = "_taskListTableRow_1e35i_1";
3691
3724
  const taskListTableRowGrabbing = "_taskListTableRowGrabbing_1e35i_13";
3692
3725
  const cut = "_cut_1e35i_21";
@@ -4030,6 +4063,21 @@ const TaskListTableRowInner = ({
4030
4063
  );
4031
4064
  };
4032
4065
  const TaskListTableRow = memo(TaskListTableRowInner);
4066
+ const checkHasChildren = (task, childTasksMap) => {
4067
+ const {
4068
+ id,
4069
+ comparisonLevel = 1
4070
+ } = task;
4071
+ const childIdsByLevel = childTasksMap.get(comparisonLevel);
4072
+ if (!childIdsByLevel) {
4073
+ return false;
4074
+ }
4075
+ const childs = childIdsByLevel.get(id);
4076
+ if (!childs) {
4077
+ return false;
4078
+ }
4079
+ return childs.length > 0;
4080
+ };
4033
4081
  const taskListWrapper = "_taskListWrapper_5941j_1";
4034
4082
  const styles$b = {
4035
4083
  taskListWrapper
@@ -4058,6 +4106,7 @@ const TaskListTableDefaultInner = ({
4058
4106
  icons,
4059
4107
  isShowTaskNumbers,
4060
4108
  mapTaskToNestedIndex,
4109
+ rowIndexToTasksMap,
4061
4110
  onClick,
4062
4111
  onExpanderClick,
4063
4112
  renderedIndexes,
@@ -4067,98 +4116,146 @@ const TaskListTableDefaultInner = ({
4067
4116
  tasks
4068
4117
  }) => {
4069
4118
  const renderedTasks = useMemo(() => {
4070
- console.log("enableTaskGrouping", enableTaskGrouping);
4071
4119
  if (!enableTaskGrouping) {
4072
- return tasks;
4120
+ return tasks.filter((task) => !task.comparisonLevel || task.comparisonLevel === 1);
4073
4121
  }
4074
- return tasks.filter((task) => {
4075
- const parent = tasks.find((t2) => t2.id === task.parent);
4076
- const isGroupedChildOfCollapsedUser = parent && parent.type === "user" && parent.hideChildren === true;
4077
- return !isGroupedChildOfCollapsedUser;
4078
- });
4122
+ return tasks.filter((task) => task.type !== "user");
4079
4123
  }, [tasks, enableTaskGrouping]);
4080
4124
  const [draggedTask, setDraggedTask] = useState(null);
4081
4125
  const renderedListWithOffset = useMemo(() => {
4082
- if (!renderedIndexes) {
4126
+ var _a;
4127
+ if (!renderedIndexes)
4083
4128
  return null;
4084
- }
4085
4129
  const [start, end] = renderedIndexes;
4086
- const renderedList = [];
4087
- for (let index2 = start; index2 <= end; ++index2) {
4088
- const task = renderedTasks[index2];
4089
- if (!task) {
4090
- break;
4091
- }
4092
- const { id, comparisonLevel = 1 } = task;
4093
- const indexesOnLevel = mapTaskToNestedIndex.get(comparisonLevel);
4094
- if (!indexesOnLevel) {
4095
- throw new Error(`Indexes are not found for level ${comparisonLevel}`);
4130
+ const renderList = [];
4131
+ if (!enableTaskGrouping) {
4132
+ for (let rowIndex = start; rowIndex <= end; rowIndex++) {
4133
+ const task = renderedTasks[rowIndex];
4134
+ if (!task)
4135
+ break;
4136
+ const { id, comparisonLevel = 1 } = task;
4137
+ const indexesOnLevel = mapTaskToNestedIndex.get(comparisonLevel);
4138
+ const taskIndex = indexesOnLevel == null ? void 0 : indexesOnLevel.get(id);
4139
+ const [depth, indexStr] = taskIndex ?? [0, ""];
4140
+ renderList.push(
4141
+ /* @__PURE__ */ jsx(
4142
+ TaskListTableRow,
4143
+ {
4144
+ canMoveTasks,
4145
+ colors,
4146
+ columns,
4147
+ dateSetup,
4148
+ dependencyMap,
4149
+ depth,
4150
+ distances,
4151
+ fullRowHeight,
4152
+ getTaskCurrentState,
4153
+ handleAddTask,
4154
+ handleDeleteTasks,
4155
+ handleEditTask,
4156
+ handleMoveTaskBefore,
4157
+ handleMoveTaskAfter,
4158
+ handleMoveTasksInside,
4159
+ handleOpenContextMenu,
4160
+ hasChildren: checkHasChildren(task, childTasksMap),
4161
+ icons,
4162
+ indexStr,
4163
+ isClosed: Boolean(task == null ? void 0 : task.hideChildren),
4164
+ isCut: cutIdsMirror[id],
4165
+ isEven: rowIndex % 2 === 1,
4166
+ isSelected: selectedIdsMirror[id],
4167
+ isShowTaskNumbers,
4168
+ onClick,
4169
+ onExpanderClick,
4170
+ scrollToTask,
4171
+ selectTaskOnMouseDown,
4172
+ task,
4173
+ tasks,
4174
+ draggedTask,
4175
+ setDraggedTask
4176
+ },
4177
+ id
4178
+ )
4179
+ );
4096
4180
  }
4097
- const taskIndex = indexesOnLevel.get(id);
4098
- if (!taskIndex) {
4099
- throw new Error(`Index is not found for task ${id}`);
4181
+ } else {
4182
+ for (let rowIndex = start; rowIndex <= end; rowIndex++) {
4183
+ const taskList = (_a = rowIndexToTasksMap.get(1)) == null ? void 0 : _a.get(rowIndex);
4184
+ if (!taskList)
4185
+ continue;
4186
+ for (const task of taskList) {
4187
+ const parent = tasks.find((t2) => t2.id === task.parent);
4188
+ if (parent == null ? void 0 : parent.hideChildren)
4189
+ continue;
4190
+ const { id, comparisonLevel } = task;
4191
+ let depth = 0;
4192
+ let indexStr = "";
4193
+ console.log("comparisonLevel", comparisonLevel);
4194
+ const levelMap = mapTaskToNestedIndex.get(comparisonLevel);
4195
+ const taskIndex = levelMap == null ? void 0 : levelMap.get(id);
4196
+ if (taskIndex) {
4197
+ console.log("object :>> ", [depth, indexStr] = taskIndex);
4198
+ [depth, indexStr] = taskIndex;
4199
+ }
4200
+ renderList.push(
4201
+ /* @__PURE__ */ jsx(
4202
+ TaskListTableRow,
4203
+ {
4204
+ canMoveTasks,
4205
+ colors,
4206
+ columns,
4207
+ dateSetup,
4208
+ dependencyMap,
4209
+ depth,
4210
+ distances,
4211
+ fullRowHeight,
4212
+ getTaskCurrentState,
4213
+ handleAddTask,
4214
+ handleDeleteTasks,
4215
+ handleEditTask,
4216
+ handleMoveTaskBefore,
4217
+ handleMoveTaskAfter,
4218
+ handleMoveTasksInside,
4219
+ handleOpenContextMenu,
4220
+ hasChildren: checkHasChildren(task, childTasksMap),
4221
+ icons,
4222
+ indexStr,
4223
+ isClosed: Boolean(task == null ? void 0 : task.hideChildren),
4224
+ isCut: cutIdsMirror[id],
4225
+ isEven: rowIndex % 2 === 1,
4226
+ isSelected: selectedIdsMirror[id],
4227
+ isShowTaskNumbers,
4228
+ onClick,
4229
+ onExpanderClick,
4230
+ scrollToTask,
4231
+ selectTaskOnMouseDown,
4232
+ task,
4233
+ tasks,
4234
+ draggedTask,
4235
+ setDraggedTask
4236
+ },
4237
+ id
4238
+ )
4239
+ );
4240
+ }
4100
4241
  }
4101
- const [depth, indexStr] = taskIndex;
4102
- renderedList.push(
4103
- /* @__PURE__ */ jsx(
4104
- TaskListTableRow,
4105
- {
4106
- canMoveTasks,
4107
- colors,
4108
- columns,
4109
- dateSetup,
4110
- dependencyMap,
4111
- depth,
4112
- distances,
4113
- fullRowHeight,
4114
- getTaskCurrentState,
4115
- handleAddTask,
4116
- handleDeleteTasks,
4117
- handleEditTask,
4118
- handleMoveTaskBefore,
4119
- handleMoveTaskAfter,
4120
- handleMoveTasksInside,
4121
- handleOpenContextMenu,
4122
- hasChildren: checkHasChildren(task, childTasksMap),
4123
- icons,
4124
- indexStr,
4125
- isClosed: Boolean(task == null ? void 0 : task.hideChildren),
4126
- isCut: cutIdsMirror[id],
4127
- isEven: index2 % 2 === 1,
4128
- isSelected: selectedIdsMirror[id],
4129
- isShowTaskNumbers,
4130
- onClick,
4131
- onExpanderClick,
4132
- scrollToTask,
4133
- selectTaskOnMouseDown,
4134
- task,
4135
- tasks,
4136
- draggedTask,
4137
- setDraggedTask
4138
- },
4139
- id
4140
- )
4141
- );
4142
4242
  }
4143
4243
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
4144
- /* @__PURE__ */ jsx(
4145
- "div",
4146
- {
4147
- style: {
4148
- height: fullRowHeight * start
4149
- }
4150
- }
4151
- ),
4152
- renderedList
4244
+ /* @__PURE__ */ jsx("div", { style: { height: fullRowHeight * start } }),
4245
+ renderList
4153
4246
  ] });
4154
4247
  }, [
4248
+ renderedIndexes,
4249
+ renderedTasks,
4250
+ rowIndexToTasksMap,
4251
+ mapTaskToNestedIndex,
4252
+ tasks,
4253
+ enableTaskGrouping,
4254
+ fullRowHeight,
4155
4255
  colors,
4156
4256
  columns,
4157
4257
  cutIdsMirror,
4158
- fullRowHeight,
4159
4258
  getTaskCurrentState,
4160
- renderedIndexes,
4161
- renderedTasks,
4162
4259
  selectTaskOnMouseDown,
4163
4260
  selectedIdsMirror,
4164
4261
  draggedTask
@@ -4167,10 +4264,7 @@ const TaskListTableDefaultInner = ({
4167
4264
  "div",
4168
4265
  {
4169
4266
  className: styles$b.taskListWrapper,
4170
- style: {
4171
- fontFamily,
4172
- fontSize
4173
- },
4267
+ style: { fontFamily, fontSize },
4174
4268
  children: renderedListWithOffset
4175
4269
  }
4176
4270
  );
@@ -4979,9 +5073,9 @@ const Grid = (props) => {
4979
5073
  /* @__PURE__ */ jsx(GridBody, { ...props })
4980
5074
  ] });
4981
5075
  };
4982
- const ganttTaskRoot = "_ganttTaskRoot_1g0yd_1";
4983
- const ganttTaskContent = "_ganttTaskContent_1g0yd_81";
4984
- const wrapper$2 = "_wrapper_1g0yd_107";
5076
+ const ganttTaskRoot = "_ganttTaskRoot_jnu0p_1";
5077
+ const ganttTaskContent = "_ganttTaskContent_jnu0p_83";
5078
+ const wrapper$2 = "_wrapper_jnu0p_111";
4985
5079
  const styles$9 = {
4986
5080
  ganttTaskRoot,
4987
5081
  ganttTaskContent,
@@ -6410,6 +6504,8 @@ const TaskGanttContent = ({
6410
6504
  handleFixDependency,
6411
6505
  handleTaskDragStart,
6412
6506
  isShowDependencyWarnings,
6507
+ enableTaskGrouping,
6508
+ rowIndexToTasksMap,
6413
6509
  mapGlobalRowIndexToTask,
6414
6510
  onArrowDoubleClick,
6415
6511
  onArrowClick,
@@ -6429,263 +6525,228 @@ const TaskGanttContent = ({
6429
6525
  }) => {
6430
6526
  const [renderedTasks, renderedArrows, renderedSelectedTasks] = useMemo(() => {
6431
6527
  var _a;
6432
- if (!renderedRowIndexes) {
6528
+ if (!renderedRowIndexes)
6433
6529
  return [null, null, null];
6434
- }
6435
6530
  const [start, end] = renderedRowIndexes;
6436
6531
  const tasksRes = [];
6437
6532
  const arrowsRes = [];
6438
6533
  const selectedTasksRes = [];
6439
6534
  const addedSelectedTasks = {};
6440
6535
  const addedDependencies = {};
6441
- console.log("mapGlobalRowIndexToTask", mapGlobalRowIndexToTask);
6442
6536
  for (let index2 = start; index2 <= end; ++index2) {
6443
- const task = mapGlobalRowIndexToTask.get(index2);
6444
- if (!task) {
6445
- continue;
6446
- }
6447
- const { comparisonLevel = 1, id: taskId } = task;
6448
- if (selectedIdsMirror[taskId] && !addedSelectedTasks[taskId]) {
6449
- addedSelectedTasks[taskId] = true;
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
- );
6537
+ const tasksAtRow = [];
6538
+ if (enableTaskGrouping) {
6539
+ for (let level = 1; level <= comparisonLevels; level++) {
6540
+ const levelMap = rowIndexToTasksMap.get(level);
6541
+ const rowTasks = levelMap == null ? void 0 : levelMap.get(index2);
6542
+ if (Array.isArray(rowTasks)) {
6543
+ tasksAtRow.push(...rowTasks);
6544
+ }
6466
6545
  }
6546
+ } else {
6547
+ const task = mapGlobalRowIndexToTask.get(index2);
6548
+ if (task)
6549
+ tasksAtRow.push(task);
6467
6550
  }
6468
- if (comparisonLevel > comparisonLevels) {
6469
- continue;
6470
- }
6471
- if (task.type === "empty" || task.type === "user") {
6472
- continue;
6473
- }
6474
- const key = `${comparisonLevel}_${task.id}`;
6475
- const criticalPathOnLevel = criticalPaths ? criticalPaths.get(comparisonLevel) : void 0;
6476
- const isCritical = criticalPathOnLevel ? criticalPathOnLevel.tasks.has(task.id) : false;
6477
- const {
6478
- containerX,
6479
- containerWidth,
6480
- innerX1,
6481
- innerX2,
6482
- width,
6483
- levelY,
6484
- progressWidth,
6485
- x1: taskX1,
6486
- x2: taskX2
6487
- } = getTaskCoordinates2(task);
6488
- tasksRes.push(
6489
- /* @__PURE__ */ jsx(
6490
- "svg",
6491
- {
6492
- id: task.id,
6493
- className: "TaskItemClassName",
6494
- x: containerX + (additionalLeftSpace || 0),
6495
- y: levelY,
6496
- width: containerWidth,
6497
- height: fullRowHeight,
6498
- children: /* @__PURE__ */ jsx(
6499
- TaskItem,
6500
- {
6501
- getTaskGlobalIndexByRef,
6502
- hasChildren: checkHasChildren(task, childTasksMap),
6503
- hasDependencyWarning: taskToHasDependencyWarningMap ? checkTaskHasDependencyWarning(
6504
- task,
6505
- taskToHasDependencyWarningMap
6506
- ) : false,
6507
- progressWidth,
6508
- progressX: rtl ? innerX2 : innerX1,
6509
- selectTaskOnMouseDown,
6510
- task,
6511
- taskYOffset,
6512
- width,
6513
- x1: innerX1,
6514
- x2: innerX2,
6515
- childOutOfParentWarnings,
6516
- distances,
6517
- taskHeight,
6518
- taskHalfHeight,
6519
- isProgressChangeable: !task.isDisabled,
6520
- isDateChangeable: !task.isDisabled,
6521
- isRelationChangeable: !task.isRelationDisabled,
6522
- authorizedRelations,
6523
- ganttRelationEvent,
6524
- isDelete: !task.isDisabled,
6525
- onDoubleClick,
6526
- onClick,
6527
- onEventStart: handleTaskDragStart,
6528
- setTooltipTask,
6529
- onRelationStart: handleBarRelationStart,
6530
- isSelected: Boolean(selectedIdsMirror[taskId]),
6531
- isCritical,
6532
- rtl,
6533
- fixStartPosition,
6534
- fixEndPosition,
6535
- handleDeleteTasks,
6536
- colorStyles
6537
- }
6538
- )
6539
- },
6540
- key
6541
- )
6542
- );
6543
- const addedDependenciesAtLevel = addedDependencies[comparisonLevel] || {};
6544
- if (!addedDependencies[comparisonLevel]) {
6545
- addedDependencies[comparisonLevel] = addedDependenciesAtLevel;
6546
- }
6547
- const addedDependenciesAtTask = addedDependenciesAtLevel[taskId] || {};
6548
- if (!addedDependenciesAtLevel[taskId]) {
6549
- addedDependenciesAtLevel[taskId] = addedDependenciesAtTask;
6550
- }
6551
- const dependenciesAtLevel = dependencyMap.get(comparisonLevel);
6552
- if (!dependenciesAtLevel) {
6553
- continue;
6554
- }
6555
- const dependenciesByTask = dependenciesAtLevel.get(taskId);
6556
- if (dependenciesByTask) {
6557
- const criticalPathForTask = criticalPathOnLevel ? criticalPathOnLevel.dependencies.get(task.id) : void 0;
6558
- dependenciesByTask.filter(({ source }) => visibleTasksMirror[source.id]).forEach(
6559
- ({
6560
- containerHeight,
6561
- containerY,
6562
- innerFromY,
6563
- innerToY,
6564
- marginBetweenTasks,
6565
- ownTarget,
6566
- source,
6567
- sourceTarget
6568
- }) => {
6569
- if (addedDependenciesAtTask[source.id]) {
6570
- return;
6571
- }
6572
- addedDependenciesAtTask[source.id] = true;
6573
- const isCritical2 = criticalPathForTask ? criticalPathForTask.has(source.id) : false;
6574
- const { x1: fromX1, x2: fromX2 } = getTaskCoordinates2(source);
6575
- const containerX2 = Math.min(fromX1, taskX1) - 300;
6576
- const containerWidth2 = Math.max(fromX2, taskX2) - containerX2 + 300;
6577
- arrowsRes.push(
6551
+ console.log("tasksAtRow", tasksAtRow);
6552
+ for (const task of tasksAtRow) {
6553
+ const comparisonLevel = task.comparisonLevel ?? 1;
6554
+ const { id: taskId } = task;
6555
+ if (selectedIdsMirror[taskId] && !addedSelectedTasks[taskId]) {
6556
+ addedSelectedTasks[taskId] = true;
6557
+ const rowIndex = (_a = taskToRowIndexMap.get(comparisonLevel)) == null ? void 0 : _a.get(taskId);
6558
+ if (typeof rowIndex === "number") {
6559
+ selectedTasksRes.push(
6578
6560
  /* @__PURE__ */ jsx(
6579
- "svg",
6561
+ "rect",
6580
6562
  {
6581
- className: "ArrowClassName",
6582
- x: containerX2 + (additionalLeftSpace || 0),
6583
- y: containerY,
6584
- width: containerWidth2,
6585
- height: containerHeight,
6586
- children: /* @__PURE__ */ jsx(
6587
- Arrow,
6588
- {
6589
- colorStyles,
6590
- distances,
6591
- taskFrom: source,
6592
- extremityFrom: sourceTarget,
6593
- fromX1: fromX1 - containerX2,
6594
- fromX2: fromX2 - containerX2,
6595
- fromY: innerFromY,
6596
- taskTo: task,
6597
- extremityTo: ownTarget,
6598
- toX1: taskX1 - containerX2,
6599
- toX2: taskX2 - containerX2,
6600
- toY: innerToY,
6601
- marginBetweenTasks,
6602
- fullRowHeight,
6603
- taskHeight,
6604
- isShowDependencyWarnings,
6605
- isCritical: isCritical2,
6606
- rtl,
6607
- onArrowDoubleClick,
6608
- onArrowClick,
6609
- handleFixDependency
6610
- }
6611
- )
6563
+ x: 0,
6564
+ y: rowIndex * fullRowHeight,
6565
+ width: "100%",
6566
+ height: fullRowHeight,
6567
+ fill: colorStyles.selectedTaskBackgroundColor
6612
6568
  },
6613
- `Arrow from ${source.id} to ${taskId} on ${comparisonLevel}`
6569
+ `selected-${taskId}`
6614
6570
  )
6615
6571
  );
6616
6572
  }
6617
- );
6618
- }
6619
- const dependentsAtLevel = dependentMap.get(comparisonLevel);
6620
- if (!dependentsAtLevel) {
6621
- continue;
6622
- }
6623
- const dependentsByTask = dependentsAtLevel.get(taskId);
6624
- if (dependentsByTask) {
6625
- dependentsByTask.filter(({ dependent }) => visibleTasksMirror[dependent.id]).forEach(
6626
- ({
6627
- containerHeight,
6628
- containerY,
6629
- innerFromY,
6630
- innerToY,
6631
- marginBetweenTasks,
6632
- ownTarget,
6633
- dependent,
6634
- dependentTarget
6635
- }) => {
6636
- const addedDependenciesAtDependent = addedDependenciesAtLevel[dependent.id] || {};
6637
- if (!addedDependenciesAtLevel[dependent.id]) {
6638
- addedDependenciesAtLevel[dependent.id] = addedDependenciesAtDependent;
6639
- }
6640
- if (addedDependenciesAtDependent[taskId]) {
6641
- return;
6642
- }
6643
- addedDependenciesAtDependent[taskId] = true;
6644
- const criticalPathForTask = criticalPathOnLevel ? criticalPathOnLevel.dependencies.get(dependent.id) : void 0;
6645
- const isCritical2 = criticalPathForTask ? criticalPathForTask.has(task.id) : false;
6646
- const { x1: toX1, x2: toX2 } = getTaskCoordinates2(dependent);
6647
- const containerX2 = Math.min(toX1, taskX1) - 300;
6648
- const containerWidth2 = Math.max(toX2, taskX2) - containerX2 + 300;
6649
- arrowsRes.push(
6650
- /* @__PURE__ */ jsx(
6651
- "svg",
6573
+ }
6574
+ if (comparisonLevel > comparisonLevels)
6575
+ continue;
6576
+ if (task.type === "empty" || task.type === "user")
6577
+ continue;
6578
+ const key = `${comparisonLevel}_${task.id}`;
6579
+ const criticalPathOnLevel = criticalPaths == null ? void 0 : criticalPaths.get(comparisonLevel);
6580
+ const isCritical = !!(criticalPathOnLevel == null ? void 0 : criticalPathOnLevel.tasks.has(task.id));
6581
+ const {
6582
+ containerX,
6583
+ containerWidth,
6584
+ innerX1,
6585
+ innerX2,
6586
+ width,
6587
+ levelY,
6588
+ progressWidth,
6589
+ x1: taskX1,
6590
+ x2: taskX2
6591
+ } = getTaskCoordinates2(task);
6592
+ tasksRes.push(
6593
+ /* @__PURE__ */ jsx(
6594
+ "svg",
6595
+ {
6596
+ id: task.id,
6597
+ className: "TaskItemClassName",
6598
+ x: containerX + additionalLeftSpace,
6599
+ y: levelY,
6600
+ width: containerWidth,
6601
+ height: fullRowHeight,
6602
+ children: /* @__PURE__ */ jsx(
6603
+ TaskItem,
6652
6604
  {
6653
- x: containerX2 + (additionalLeftSpace || 0),
6654
- y: containerY,
6655
- width: containerWidth2,
6656
- height: containerHeight,
6657
- children: /* @__PURE__ */ jsx(
6658
- Arrow,
6659
- {
6660
- colorStyles,
6661
- distances,
6662
- taskFrom: task,
6663
- extremityFrom: ownTarget,
6664
- fromX1: taskX1 - containerX2,
6665
- fromX2: taskX2 - containerX2,
6666
- fromY: innerFromY,
6667
- taskTo: dependent,
6668
- extremityTo: dependentTarget,
6669
- toX1: toX1 - containerX2,
6670
- toX2: toX2 - containerX2,
6671
- toY: innerToY,
6672
- marginBetweenTasks,
6673
- fullRowHeight,
6674
- taskHeight,
6675
- isShowDependencyWarnings,
6676
- isCritical: isCritical2,
6677
- rtl,
6678
- onArrowDoubleClick,
6679
- onArrowClick,
6680
- handleFixDependency
6681
- }
6682
- )
6683
- },
6684
- `Arrow from ${taskId} to ${dependent.id} on ${comparisonLevel}`
6605
+ getTaskGlobalIndexByRef,
6606
+ hasChildren: checkHasChildren(task, childTasksMap),
6607
+ hasDependencyWarning: taskToHasDependencyWarningMap ? checkTaskHasDependencyWarning(task, taskToHasDependencyWarningMap) : false,
6608
+ progressWidth,
6609
+ progressX: rtl ? innerX2 : innerX1,
6610
+ selectTaskOnMouseDown,
6611
+ task,
6612
+ taskYOffset,
6613
+ width,
6614
+ x1: innerX1,
6615
+ x2: innerX2,
6616
+ childOutOfParentWarnings,
6617
+ distances,
6618
+ taskHeight,
6619
+ taskHalfHeight,
6620
+ isProgressChangeable: !task.isDisabled,
6621
+ isDateChangeable: !task.isDisabled,
6622
+ isRelationChangeable: !task.isRelationDisabled,
6623
+ authorizedRelations,
6624
+ ganttRelationEvent,
6625
+ isDelete: !task.isDisabled,
6626
+ onDoubleClick,
6627
+ onClick,
6628
+ onEventStart: handleTaskDragStart,
6629
+ setTooltipTask,
6630
+ onRelationStart: handleBarRelationStart,
6631
+ isSelected: Boolean(selectedIdsMirror[taskId]),
6632
+ isCritical,
6633
+ rtl,
6634
+ fixStartPosition,
6635
+ fixEndPosition,
6636
+ handleDeleteTasks,
6637
+ colorStyles
6638
+ }
6685
6639
  )
6686
- );
6687
- }
6640
+ },
6641
+ key
6642
+ )
6688
6643
  );
6644
+ const addedDependenciesAtLevel = addedDependencies[comparisonLevel] ?? (addedDependencies[comparisonLevel] = {});
6645
+ const addedDependenciesAtTask = addedDependenciesAtLevel[taskId] ?? (addedDependenciesAtLevel[taskId] = {});
6646
+ const dependenciesAtLevel = dependencyMap.get(comparisonLevel);
6647
+ const dependenciesByTask = dependenciesAtLevel == null ? void 0 : dependenciesAtLevel.get(taskId);
6648
+ dependenciesByTask == null ? void 0 : dependenciesByTask.filter(({ source }) => visibleTasksMirror[source.id]).forEach((dep) => {
6649
+ var _a2;
6650
+ if (addedDependenciesAtTask[dep.source.id])
6651
+ return;
6652
+ addedDependenciesAtTask[dep.source.id] = true;
6653
+ const { x1: fromX1, x2: fromX2 } = getTaskCoordinates2(dep.source);
6654
+ const containerX2 = Math.min(fromX1, taskX1) - 300;
6655
+ const containerWidth2 = Math.max(fromX2, taskX2) - containerX2 + 300;
6656
+ const isDepCritical = !!((_a2 = criticalPathOnLevel == null ? void 0 : criticalPathOnLevel.dependencies.get(task.id)) == null ? void 0 : _a2.has(dep.source.id));
6657
+ arrowsRes.push(
6658
+ /* @__PURE__ */ jsx(
6659
+ "svg",
6660
+ {
6661
+ className: "ArrowClassName",
6662
+ x: containerX2 + additionalLeftSpace,
6663
+ y: dep.containerY,
6664
+ width: containerWidth2,
6665
+ height: dep.containerHeight,
6666
+ children: /* @__PURE__ */ jsx(
6667
+ Arrow,
6668
+ {
6669
+ colorStyles,
6670
+ distances,
6671
+ taskFrom: dep.source,
6672
+ extremityFrom: dep.sourceTarget,
6673
+ fromX1: fromX1 - containerX2,
6674
+ fromX2: fromX2 - containerX2,
6675
+ fromY: dep.innerFromY,
6676
+ taskTo: task,
6677
+ extremityTo: dep.ownTarget,
6678
+ toX1: taskX1 - containerX2,
6679
+ toX2: taskX2 - containerX2,
6680
+ toY: dep.innerToY,
6681
+ marginBetweenTasks: dep.marginBetweenTasks,
6682
+ fullRowHeight,
6683
+ taskHeight,
6684
+ isShowDependencyWarnings,
6685
+ isCritical: isDepCritical,
6686
+ rtl,
6687
+ onArrowDoubleClick,
6688
+ onArrowClick,
6689
+ handleFixDependency
6690
+ }
6691
+ )
6692
+ },
6693
+ `Arrow from ${dep.source.id} to ${taskId} on ${comparisonLevel}`
6694
+ )
6695
+ );
6696
+ });
6697
+ const dependentsAtLevel = dependentMap.get(comparisonLevel);
6698
+ const dependentsByTask = dependentsAtLevel == null ? void 0 : dependentsAtLevel.get(taskId);
6699
+ dependentsByTask == null ? void 0 : dependentsByTask.filter(({ dependent }) => visibleTasksMirror[dependent.id]).forEach((dep) => {
6700
+ var _a2, _b;
6701
+ console.log("dependent", dep);
6702
+ const addedDepsForDep = addedDependenciesAtLevel[_a2 = dep.dependent.id] ?? (addedDependenciesAtLevel[_a2] = {});
6703
+ if (addedDepsForDep[taskId])
6704
+ return;
6705
+ addedDepsForDep[taskId] = true;
6706
+ const isDepCritical = !!((_b = criticalPathOnLevel == null ? void 0 : criticalPathOnLevel.dependencies.get(dep.dependent.id)) == null ? void 0 : _b.has(task.id));
6707
+ const { x1: toX1, x2: toX2 } = getTaskCoordinates2(dep.dependent);
6708
+ const containerX2 = Math.min(toX1, taskX1) - 300;
6709
+ const containerWidth2 = Math.max(toX2, taskX2) - containerX2 + 300;
6710
+ arrowsRes.push(
6711
+ /* @__PURE__ */ jsx(
6712
+ "svg",
6713
+ {
6714
+ className: "ArrowClassName",
6715
+ x: containerX2 + additionalLeftSpace,
6716
+ y: dep.containerY,
6717
+ width: containerWidth2,
6718
+ height: dep.containerHeight,
6719
+ children: /* @__PURE__ */ jsx(
6720
+ Arrow,
6721
+ {
6722
+ colorStyles,
6723
+ distances,
6724
+ taskFrom: task,
6725
+ extremityFrom: dep.ownTarget,
6726
+ fromX1: taskX1 - containerX2,
6727
+ fromX2: taskX2 - containerX2,
6728
+ fromY: dep.innerFromY,
6729
+ taskTo: dep.dependent,
6730
+ extremityTo: dep.dependentTarget,
6731
+ toX1: toX1 - containerX2,
6732
+ toX2: toX2 - containerX2,
6733
+ toY: dep.innerToY,
6734
+ marginBetweenTasks: dep.marginBetweenTasks,
6735
+ fullRowHeight,
6736
+ taskHeight,
6737
+ isShowDependencyWarnings,
6738
+ isCritical: isDepCritical,
6739
+ rtl,
6740
+ onArrowDoubleClick,
6741
+ onArrowClick,
6742
+ handleFixDependency
6743
+ }
6744
+ )
6745
+ },
6746
+ `Arrow from ${taskId} to ${dep.dependent.id} on ${comparisonLevel}`
6747
+ )
6748
+ );
6749
+ });
6689
6750
  }
6690
6751
  }
6691
6752
  return [tasksRes, arrowsRes, selectedTasksRes];
@@ -6702,7 +6763,9 @@ const TaskGanttContent = ({
6702
6763
  renderedRowIndexes,
6703
6764
  selectTaskOnMouseDown,
6704
6765
  selectedIdsMirror,
6705
- visibleTasksMirror
6766
+ visibleTasksMirror,
6767
+ rowIndexToTasksMap,
6768
+ enableTaskGrouping
6706
6769
  ]);
6707
6770
  return /* @__PURE__ */ jsxs("g", { className: "content", children: [
6708
6771
  renderedSelectedTasks,
@@ -11376,42 +11439,48 @@ const getMapTaskToRowIndexWithGrouping = (tasks, comparisonLevels, isGrouped = f
11376
11439
  const rowIndexToTaskMap = /* @__PURE__ */ new Map();
11377
11440
  const rowIndexToTasksMap = /* @__PURE__ */ new Map();
11378
11441
  const mapGlobalRowIndexToTask = /* @__PURE__ */ new Map();
11379
- const parentMap = new Map(
11380
- tasks.map((task) => [task.id, task])
11381
- );
11442
+ const parentMap = new Map(tasks.map((t2) => [t2.id, t2]));
11382
11443
  let globalRowIndex = 0;
11383
11444
  for (let comparisonLevel = 1; comparisonLevel <= comparisonLevels; comparisonLevel++) {
11384
- const taskToRowIndexMapAtLevel = /* @__PURE__ */ new Map();
11385
- const rowIndexToTaskMapAtLevel = /* @__PURE__ */ new Map();
11386
- const rowIndexToTasksMapAtLevel = /* @__PURE__ */ new Map();
11387
- taskToRowIndexMap.set(comparisonLevel, taskToRowIndexMapAtLevel);
11388
- rowIndexToTaskMap.set(comparisonLevel, rowIndexToTaskMapAtLevel);
11389
- rowIndexToTasksMap.set(comparisonLevel, rowIndexToTasksMapAtLevel);
11445
+ const taskToRow = /* @__PURE__ */ new Map();
11446
+ const rowToTask = /* @__PURE__ */ new Map();
11447
+ const rowToTasks = /* @__PURE__ */ new Map();
11448
+ taskToRowIndexMap.set(comparisonLevel, taskToRow);
11449
+ rowIndexToTaskMap.set(comparisonLevel, rowToTask);
11450
+ rowIndexToTasksMap.set(comparisonLevel, rowToTasks);
11390
11451
  let rowIndex = 0;
11391
11452
  for (const task of tasks) {
11392
- const level = task.comparisonLevel ?? 1;
11393
- if (level !== comparisonLevel)
11453
+ if ((task.comparisonLevel ?? 1) !== comparisonLevel)
11394
11454
  continue;
11395
- const { id, parent } = task;
11455
+ const { id, parent, type } = task;
11396
11456
  let assignedRowIndex = rowIndex;
11397
- if (isGrouped && parent && parentMap.has(parent)) {
11457
+ if (type === "user" || type === "project") {
11458
+ taskToRow.set(id, rowIndex);
11459
+ rowToTask.set(rowIndex, task);
11460
+ rowToTasks.set(rowIndex, [task]);
11461
+ mapGlobalRowIndexToTask.set(globalRowIndex, task);
11462
+ rowIndex++;
11463
+ globalRowIndex++;
11464
+ continue;
11465
+ }
11466
+ if (isGrouped && parent) {
11398
11467
  const parentTask = parentMap.get(parent);
11399
- const isGroupedAudit = (parentTask == null ? void 0 : parentTask.type) === "user" && (parentTask == null ? void 0 : parentTask.hideChildren);
11400
- if (isGroupedAudit) {
11401
- const parentRowIndex = taskToRowIndexMapAtLevel.get(parent);
11402
- if (typeof parentRowIndex === "number") {
11403
- assignedRowIndex = parentRowIndex;
11404
- }
11468
+ const parentRowIndex = taskToRow.get(parent);
11469
+ if ((parentTask == null ? void 0 : parentTask.hideChildren) && parentRowIndex !== void 0) {
11470
+ assignedRowIndex = parentRowIndex;
11471
+ } else {
11472
+ assignedRowIndex = rowIndex;
11473
+ rowIndex++;
11405
11474
  }
11406
- }
11407
- taskToRowIndexMapAtLevel.set(id, assignedRowIndex);
11408
- rowIndexToTaskMapAtLevel.set(assignedRowIndex, task);
11409
- const existingTasks = rowIndexToTasksMapAtLevel.get(assignedRowIndex) ?? [];
11410
- rowIndexToTasksMapAtLevel.set(assignedRowIndex, [...existingTasks, task]);
11411
- mapGlobalRowIndexToTask.set(globalRowIndex, task);
11412
- if (assignedRowIndex === rowIndex) {
11475
+ } else {
11476
+ assignedRowIndex = rowIndex;
11413
11477
  rowIndex++;
11414
11478
  }
11479
+ taskToRow.set(id, assignedRowIndex);
11480
+ rowToTask.set(assignedRowIndex, task);
11481
+ const existing = rowToTasks.get(assignedRowIndex) ?? [];
11482
+ rowToTasks.set(assignedRowIndex, [...existing, task]);
11483
+ mapGlobalRowIndexToTask.set(globalRowIndex, task);
11415
11484
  globalRowIndex++;
11416
11485
  }
11417
11486
  }
@@ -11477,6 +11546,7 @@ const defaultDateFormats = {
11477
11546
  const defaultDistances = {
11478
11547
  actionColumnWidth: 40,
11479
11548
  arrowIndent: 20,
11549
+ taskHeight: 24,
11480
11550
  barCornerRadius: 3,
11481
11551
  barFill: 60,
11482
11552
  columnWidth: 60,
@@ -11663,11 +11733,6 @@ const Gantt = ({
11663
11733
  () => distances.rowHeight * comparisonLevels,
11664
11734
  [distances, comparisonLevels]
11665
11735
  );
11666
- const renderedRowIndexes = useOptimizedList(
11667
- ganttTaskContentRef,
11668
- "scrollTop",
11669
- distances.rowHeight
11670
- );
11671
11736
  const colorStyles = useMemo(
11672
11737
  () => ({
11673
11738
  ...defaultColors,
@@ -11683,18 +11748,15 @@ const Gantt = ({
11683
11748
  () => (distances.rowHeight - taskHeight) / 2,
11684
11749
  [distances, taskHeight]
11685
11750
  );
11686
- const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask, rowIndexToTasksMap] = useMemo(
11687
- () => enableTaskGrouping ? getMapTaskToRowIndexWithGrouping(visibleTasks, comparisonLevels, true) : getMapTaskToRowIndex(visibleTasks, comparisonLevels),
11688
- [visibleTasks, comparisonLevels, enableTaskGrouping]
11689
- );
11690
11751
  const taskHalfHeight = useMemo(
11691
11752
  () => Math.round(taskHeight / 2),
11692
11753
  [taskHeight]
11693
11754
  );
11755
+ const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask, rowIndexToTasksMap] = useMemo(
11756
+ () => enableTaskGrouping ? getMapTaskToRowIndexWithGrouping(visibleTasks, comparisonLevels, true) : getMapTaskToRowIndex(visibleTasks, comparisonLevels),
11757
+ [visibleTasks, comparisonLevels, enableTaskGrouping]
11758
+ );
11694
11759
  const maxLevelLength = useMemo(() => {
11695
- if (enableTaskGrouping) {
11696
- return Math.max((rowIndexToTasksMap == null ? void 0 : rowIndexToTasksMap.size) ?? 0, 1);
11697
- }
11698
11760
  let maxLength = 0;
11699
11761
  const countByLevel = {};
11700
11762
  visibleTasks.forEach(({ comparisonLevel = 1 }) => {
@@ -11707,20 +11769,26 @@ const Gantt = ({
11707
11769
  }
11708
11770
  });
11709
11771
  return maxLength;
11710
- }, [visibleTasks, comparisonLevels, enableTaskGrouping, rowIndexToTasksMap]);
11772
+ }, [visibleTasks, comparisonLevels]);
11711
11773
  const ganttFullHeight = useMemo(() => {
11712
- if (enableTaskGrouping) {
11713
- let totalHeight = 0;
11714
- for (const [, taskMap] of rowIndexToTasksMap) {
11715
- for (const [, tasks2] of taskMap) {
11716
- const rowHeight = tasks2.length * (taskHeight + 2);
11717
- totalHeight += Math.max(rowHeight, fullRowHeight);
11718
- }
11719
- }
11720
- return Math.max(totalHeight, fullRowHeight);
11774
+ if (!enableTaskGrouping) {
11775
+ return maxLevelLength * fullRowHeight;
11721
11776
  }
11722
- return maxLevelLength * fullRowHeight;
11723
- }, [enableTaskGrouping, rowIndexToTasksMap, maxLevelLength, fullRowHeight, taskHeight]);
11777
+ let totalRows = 0;
11778
+ for (const comparisonMap of rowIndexToTasksMap.values()) {
11779
+ totalRows += comparisonMap.size;
11780
+ }
11781
+ return totalRows * fullRowHeight;
11782
+ }, [enableTaskGrouping, rowIndexToTasksMap, maxLevelLength, fullRowHeight]);
11783
+ const renderedRowIndexes = enableTaskGrouping ? useGroupedVirtualization(
11784
+ //ganttTaskContentRef,
11785
+ rowIndexToTasksMap,
11786
+ fullRowHeight
11787
+ ) : useOptimizedList(
11788
+ ganttTaskContentRef,
11789
+ "scrollTop",
11790
+ fullRowHeight
11791
+ );
11724
11792
  const {
11725
11793
  checkHasCopyTasks,
11726
11794
  checkHasCutTasks,
@@ -11779,22 +11847,10 @@ const Gantt = ({
11779
11847
  const svgClientWidth = renderedColumnIndexes && renderedColumnIndexes[4];
11780
11848
  const countTaskCoordinates$1 = useCallback(
11781
11849
  (task) => {
11782
- var _a;
11783
11850
  if (enableTaskGrouping) {
11784
- const comparisonLevel = task.comparisonLevel ?? 1;
11785
- let sequentialOffset = 0;
11786
- const indexesAtLevel = taskToRowIndexMap.get(comparisonLevel);
11787
- const rowIndex = indexesAtLevel == null ? void 0 : indexesAtLevel.get(task.id);
11788
- if (typeof rowIndex === "number") {
11789
- const rowTasksAtLevel = ((_a = rowIndexToTasksMap.get(comparisonLevel)) == null ? void 0 : _a.get(rowIndex)) ?? [];
11790
- const indexInRow = rowTasksAtLevel.findIndex((t2) => t2.id === task.id);
11791
- if (indexInRow !== -1) {
11792
- sequentialOffset = indexInRow * (taskHeight + 2);
11793
- }
11794
- }
11795
11851
  return countTaskCoordinatesWithGrouping(
11796
11852
  task,
11797
- taskToRowIndexMap,
11853
+ rowIndexToTasksMap,
11798
11854
  startDate,
11799
11855
  viewMode,
11800
11856
  rtl,
@@ -11803,7 +11859,7 @@ const Gantt = ({
11803
11859
  taskYOffset,
11804
11860
  distances,
11805
11861
  svgWidth,
11806
- sequentialOffset
11862
+ 0
11807
11863
  );
11808
11864
  }
11809
11865
  return countTaskCoordinates(
@@ -11834,7 +11890,19 @@ const Gantt = ({
11834
11890
  ]
11835
11891
  );
11836
11892
  const mapTaskToCoordinates = useMemo(
11837
- () => getMapTaskToCoordinates(
11893
+ () => enableTaskGrouping ? getMapTaskToCoordinatesWithGrouping(
11894
+ tasks,
11895
+ visibleTasksMirror,
11896
+ rowIndexToTasksMap,
11897
+ startDate,
11898
+ viewMode,
11899
+ rtl,
11900
+ fullRowHeight,
11901
+ taskHeight,
11902
+ taskYOffset,
11903
+ distances,
11904
+ svgWidth
11905
+ ) : getMapTaskToCoordinates(
11838
11906
  tasks,
11839
11907
  visibleTasksMirror,
11840
11908
  taskToRowIndexMap,
@@ -11848,17 +11916,19 @@ const Gantt = ({
11848
11916
  svgWidth
11849
11917
  ),
11850
11918
  [
11851
- distances,
11852
- fullRowHeight,
11919
+ tasks,
11920
+ visibleTasksMirror,
11921
+ rowIndexToTasksMap,
11853
11922
  taskToRowIndexMap,
11854
- rtl,
11855
11923
  startDate,
11856
- svgWidth,
11924
+ viewMode,
11925
+ rtl,
11926
+ fullRowHeight,
11857
11927
  taskHeight,
11858
- tasks,
11859
11928
  taskYOffset,
11860
- viewMode,
11861
- visibleTasksMirror
11929
+ distances,
11930
+ svgWidth,
11931
+ enableTaskGrouping
11862
11932
  ]
11863
11933
  );
11864
11934
  const scrollToTask = useCallback(
@@ -11993,8 +12063,6 @@ const Gantt = ({
11993
12063
  };
11994
12064
  const handleExpanderClick = useCallback(
11995
12065
  (clickedTask) => {
11996
- console.log(`Task ${clickedTask.id} hideChildren changed from ${clickedTask.hideChildren} to ${!clickedTask.hideChildren}`);
11997
- console.log("Task types:", tasks.map((task) => `${task.id}: ${task.type}`));
11998
12066
  if (onChangeExpandState) {
11999
12067
  onChangeExpandState({
12000
12068
  ...clickedTask,
@@ -12870,6 +12938,8 @@ const Gantt = ({
12870
12938
  };
12871
12939
  const barProps = useMemo(
12872
12940
  () => ({
12941
+ enableTaskGrouping,
12942
+ rowIndexToTasksMap,
12873
12943
  authorizedRelations,
12874
12944
  additionalLeftSpace,
12875
12945
  additionalRightSpace,
@@ -12919,6 +12989,8 @@ const Gantt = ({
12919
12989
  [
12920
12990
  additionalLeftSpace,
12921
12991
  additionalRightSpace,
12992
+ enableTaskGrouping,
12993
+ rowIndexToTasksMap,
12922
12994
  checkIsHoliday,
12923
12995
  childOutOfParentWarnings,
12924
12996
  childTasksMap,
@@ -12970,6 +13042,7 @@ const Gantt = ({
12970
13042
  TaskListHeader,
12971
13043
  TaskListTable,
12972
13044
  enableTaskGrouping,
13045
+ rowIndexToTasksMap,
12973
13046
  canMoveTasks,
12974
13047
  canResizeColumns,
12975
13048
  childTasksMap,