@thepocman/gantt-task-react 1.0.13 → 1.0.14

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,33 @@ const useOptimizedList = (containerRef, property, cellSize) => {
1921
1943
  ]);
1922
1944
  return indexes;
1923
1945
  };
1946
+ const TASK_SPACING = 2;
1947
+ const buildRowEntries = (rowIndexToTasksMap, taskHeight) => {
1948
+ const rowToTaskCount = /* @__PURE__ */ new Map();
1949
+ for (const rowMap of rowIndexToTasksMap.values()) {
1950
+ for (const [rowIndex, tasks] of rowMap.entries()) {
1951
+ rowToTaskCount.set(rowIndex, (rowToTaskCount.get(rowIndex) ?? 0) + tasks.length);
1952
+ }
1953
+ }
1954
+ return [...rowToTaskCount.entries()].map(([rowIndex, count2]) => ({
1955
+ rowIndex,
1956
+ height: count2 * (taskHeight + TASK_SPACING)
1957
+ })).sort((a4, b3) => a4.rowIndex - b3.rowIndex);
1958
+ };
1959
+ const useGroupedVirtualization = (rowIndexToTasksMap, taskHeight) => {
1960
+ var _a, _b;
1961
+ const rowEntries = useMemo(
1962
+ () => buildRowEntries(rowIndexToTasksMap, taskHeight),
1963
+ [rowIndexToTasksMap, taskHeight]
1964
+ );
1965
+ return [
1966
+ ((_a = rowEntries[0]) == null ? void 0 : _a.rowIndex) ?? 0,
1967
+ ((_b = rowEntries[rowEntries.length - 1]) == null ? void 0 : _b.rowIndex) ?? 0,
1968
+ true,
1969
+ true,
1970
+ rowEntries.reduce((sum, entry) => sum + entry.height, 0)
1971
+ ];
1972
+ };
1924
1973
  const button$2 = "_button_1eue5_1";
1925
1974
  const styles$i = {
1926
1975
  button: button$2
@@ -3357,6 +3406,7 @@ const TaskListInner = ({
3357
3406
  dateSetup,
3358
3407
  dependencyMap,
3359
3408
  distances,
3409
+ rowIndexToTasksMap,
3360
3410
  fontFamily,
3361
3411
  fontSize,
3362
3412
  fullRowHeight,
@@ -3395,7 +3445,11 @@ const TaskListInner = ({
3395
3445
  onTableResizeStart,
3396
3446
  onColumnResizeStart
3397
3447
  ] = useTableListResize(columnsProp, distances, onResizeColumn);
3398
- const renderedIndexes = useOptimizedList(
3448
+ const renderedIndexes = enableTaskGrouping ? useGroupedVirtualization(
3449
+ //taskListContentRef,
3450
+ rowIndexToTasksMap,
3451
+ distances.taskHeight
3452
+ ) : useOptimizedList(
3399
3453
  taskListContentRef,
3400
3454
  "scrollTop",
3401
3455
  fullRowHeight
@@ -3451,6 +3505,7 @@ const TaskListInner = ({
3451
3505
  columns,
3452
3506
  cutIdsMirror,
3453
3507
  enableTaskGrouping,
3508
+ rowIndexToTasksMap,
3454
3509
  dateSetup,
3455
3510
  dependencyMap,
3456
3511
  distances,
@@ -3672,21 +3727,6 @@ const TaskListHeaderDefaultInner = (props) => {
3672
3727
  );
3673
3728
  };
3674
3729
  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
3730
  const taskListTableRow = "_taskListTableRow_1e35i_1";
3691
3731
  const taskListTableRowGrabbing = "_taskListTableRowGrabbing_1e35i_13";
3692
3732
  const cut = "_cut_1e35i_21";
@@ -4030,6 +4070,21 @@ const TaskListTableRowInner = ({
4030
4070
  );
4031
4071
  };
4032
4072
  const TaskListTableRow = memo(TaskListTableRowInner);
4073
+ const checkHasChildren = (task, childTasksMap) => {
4074
+ const {
4075
+ id,
4076
+ comparisonLevel = 1
4077
+ } = task;
4078
+ const childIdsByLevel = childTasksMap.get(comparisonLevel);
4079
+ if (!childIdsByLevel) {
4080
+ return false;
4081
+ }
4082
+ const childs = childIdsByLevel.get(id);
4083
+ if (!childs) {
4084
+ return false;
4085
+ }
4086
+ return childs.length > 0;
4087
+ };
4033
4088
  const taskListWrapper = "_taskListWrapper_5941j_1";
4034
4089
  const styles$b = {
4035
4090
  taskListWrapper
@@ -4058,6 +4113,7 @@ const TaskListTableDefaultInner = ({
4058
4113
  icons,
4059
4114
  isShowTaskNumbers,
4060
4115
  mapTaskToNestedIndex,
4116
+ rowIndexToTasksMap,
4061
4117
  onClick,
4062
4118
  onExpanderClick,
4063
4119
  renderedIndexes,
@@ -4067,98 +4123,146 @@ const TaskListTableDefaultInner = ({
4067
4123
  tasks
4068
4124
  }) => {
4069
4125
  const renderedTasks = useMemo(() => {
4070
- console.log("enableTaskGrouping", enableTaskGrouping);
4071
4126
  if (!enableTaskGrouping) {
4072
- return tasks;
4127
+ return tasks.filter((task) => !task.comparisonLevel || task.comparisonLevel === 1);
4073
4128
  }
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
- });
4129
+ return tasks.filter((task) => task.type !== "user");
4079
4130
  }, [tasks, enableTaskGrouping]);
4080
4131
  const [draggedTask, setDraggedTask] = useState(null);
4081
4132
  const renderedListWithOffset = useMemo(() => {
4082
- if (!renderedIndexes) {
4133
+ var _a;
4134
+ if (!renderedIndexes)
4083
4135
  return null;
4084
- }
4085
4136
  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}`);
4137
+ const renderList = [];
4138
+ if (!enableTaskGrouping) {
4139
+ for (let rowIndex = start; rowIndex <= end; rowIndex++) {
4140
+ const task = renderedTasks[rowIndex];
4141
+ if (!task)
4142
+ break;
4143
+ const { id, comparisonLevel = 1 } = task;
4144
+ const indexesOnLevel = mapTaskToNestedIndex.get(comparisonLevel);
4145
+ const taskIndex = indexesOnLevel == null ? void 0 : indexesOnLevel.get(id);
4146
+ const [depth, indexStr] = taskIndex ?? [0, ""];
4147
+ renderList.push(
4148
+ /* @__PURE__ */ jsx(
4149
+ TaskListTableRow,
4150
+ {
4151
+ canMoveTasks,
4152
+ colors,
4153
+ columns,
4154
+ dateSetup,
4155
+ dependencyMap,
4156
+ depth,
4157
+ distances,
4158
+ fullRowHeight,
4159
+ getTaskCurrentState,
4160
+ handleAddTask,
4161
+ handleDeleteTasks,
4162
+ handleEditTask,
4163
+ handleMoveTaskBefore,
4164
+ handleMoveTaskAfter,
4165
+ handleMoveTasksInside,
4166
+ handleOpenContextMenu,
4167
+ hasChildren: checkHasChildren(task, childTasksMap),
4168
+ icons,
4169
+ indexStr,
4170
+ isClosed: Boolean(task == null ? void 0 : task.hideChildren),
4171
+ isCut: cutIdsMirror[id],
4172
+ isEven: rowIndex % 2 === 1,
4173
+ isSelected: selectedIdsMirror[id],
4174
+ isShowTaskNumbers,
4175
+ onClick,
4176
+ onExpanderClick,
4177
+ scrollToTask,
4178
+ selectTaskOnMouseDown,
4179
+ task,
4180
+ tasks,
4181
+ draggedTask,
4182
+ setDraggedTask
4183
+ },
4184
+ id
4185
+ )
4186
+ );
4096
4187
  }
4097
- const taskIndex = indexesOnLevel.get(id);
4098
- if (!taskIndex) {
4099
- throw new Error(`Index is not found for task ${id}`);
4188
+ } else {
4189
+ for (let rowIndex = start; rowIndex <= end; rowIndex++) {
4190
+ const taskList = (_a = rowIndexToTasksMap.get(1)) == null ? void 0 : _a.get(rowIndex);
4191
+ if (!taskList)
4192
+ continue;
4193
+ for (const task of taskList) {
4194
+ const parent = tasks.find((t2) => t2.id === task.parent);
4195
+ if (parent == null ? void 0 : parent.hideChildren)
4196
+ continue;
4197
+ const { id, comparisonLevel } = task;
4198
+ let depth = 0;
4199
+ let indexStr = "";
4200
+ console.log("comparisonLevel", comparisonLevel);
4201
+ const levelMap = mapTaskToNestedIndex.get(comparisonLevel);
4202
+ const taskIndex = levelMap == null ? void 0 : levelMap.get(id);
4203
+ if (taskIndex) {
4204
+ console.log("object :>> ", [depth, indexStr] = taskIndex);
4205
+ [depth, indexStr] = taskIndex;
4206
+ }
4207
+ renderList.push(
4208
+ /* @__PURE__ */ jsx(
4209
+ TaskListTableRow,
4210
+ {
4211
+ canMoveTasks,
4212
+ colors,
4213
+ columns,
4214
+ dateSetup,
4215
+ dependencyMap,
4216
+ depth,
4217
+ distances,
4218
+ fullRowHeight,
4219
+ getTaskCurrentState,
4220
+ handleAddTask,
4221
+ handleDeleteTasks,
4222
+ handleEditTask,
4223
+ handleMoveTaskBefore,
4224
+ handleMoveTaskAfter,
4225
+ handleMoveTasksInside,
4226
+ handleOpenContextMenu,
4227
+ hasChildren: checkHasChildren(task, childTasksMap),
4228
+ icons,
4229
+ indexStr,
4230
+ isClosed: Boolean(task == null ? void 0 : task.hideChildren),
4231
+ isCut: cutIdsMirror[id],
4232
+ isEven: rowIndex % 2 === 1,
4233
+ isSelected: selectedIdsMirror[id],
4234
+ isShowTaskNumbers,
4235
+ onClick,
4236
+ onExpanderClick,
4237
+ scrollToTask,
4238
+ selectTaskOnMouseDown,
4239
+ task,
4240
+ tasks,
4241
+ draggedTask,
4242
+ setDraggedTask
4243
+ },
4244
+ id
4245
+ )
4246
+ );
4247
+ }
4100
4248
  }
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
4249
  }
4143
4250
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
4144
- /* @__PURE__ */ jsx(
4145
- "div",
4146
- {
4147
- style: {
4148
- height: fullRowHeight * start
4149
- }
4150
- }
4151
- ),
4152
- renderedList
4251
+ /* @__PURE__ */ jsx("div", { style: { height: fullRowHeight * start } }),
4252
+ renderList
4153
4253
  ] });
4154
4254
  }, [
4255
+ renderedIndexes,
4256
+ renderedTasks,
4257
+ rowIndexToTasksMap,
4258
+ mapTaskToNestedIndex,
4259
+ tasks,
4260
+ enableTaskGrouping,
4261
+ fullRowHeight,
4155
4262
  colors,
4156
4263
  columns,
4157
4264
  cutIdsMirror,
4158
- fullRowHeight,
4159
4265
  getTaskCurrentState,
4160
- renderedIndexes,
4161
- renderedTasks,
4162
4266
  selectTaskOnMouseDown,
4163
4267
  selectedIdsMirror,
4164
4268
  draggedTask
@@ -4167,10 +4271,7 @@ const TaskListTableDefaultInner = ({
4167
4271
  "div",
4168
4272
  {
4169
4273
  className: styles$b.taskListWrapper,
4170
- style: {
4171
- fontFamily,
4172
- fontSize
4173
- },
4274
+ style: { fontFamily, fontSize },
4174
4275
  children: renderedListWithOffset
4175
4276
  }
4176
4277
  );
@@ -4979,9 +5080,9 @@ const Grid = (props) => {
4979
5080
  /* @__PURE__ */ jsx(GridBody, { ...props })
4980
5081
  ] });
4981
5082
  };
4982
- const ganttTaskRoot = "_ganttTaskRoot_1g0yd_1";
4983
- const ganttTaskContent = "_ganttTaskContent_1g0yd_81";
4984
- const wrapper$2 = "_wrapper_1g0yd_107";
5083
+ const ganttTaskRoot = "_ganttTaskRoot_jnu0p_1";
5084
+ const ganttTaskContent = "_ganttTaskContent_jnu0p_83";
5085
+ const wrapper$2 = "_wrapper_jnu0p_111";
4985
5086
  const styles$9 = {
4986
5087
  ganttTaskRoot,
4987
5088
  ganttTaskContent,
@@ -6410,6 +6511,8 @@ const TaskGanttContent = ({
6410
6511
  handleFixDependency,
6411
6512
  handleTaskDragStart,
6412
6513
  isShowDependencyWarnings,
6514
+ enableTaskGrouping,
6515
+ rowIndexToTasksMap,
6413
6516
  mapGlobalRowIndexToTask,
6414
6517
  onArrowDoubleClick,
6415
6518
  onArrowClick,
@@ -6429,263 +6532,228 @@ const TaskGanttContent = ({
6429
6532
  }) => {
6430
6533
  const [renderedTasks, renderedArrows, renderedSelectedTasks] = useMemo(() => {
6431
6534
  var _a;
6432
- if (!renderedRowIndexes) {
6535
+ if (!renderedRowIndexes)
6433
6536
  return [null, null, null];
6434
- }
6435
6537
  const [start, end] = renderedRowIndexes;
6436
6538
  const tasksRes = [];
6437
6539
  const arrowsRes = [];
6438
6540
  const selectedTasksRes = [];
6439
6541
  const addedSelectedTasks = {};
6440
6542
  const addedDependencies = {};
6441
- console.log("mapGlobalRowIndexToTask", mapGlobalRowIndexToTask);
6442
6543
  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
- );
6544
+ const tasksAtRow = [];
6545
+ if (enableTaskGrouping) {
6546
+ for (let level = 1; level <= comparisonLevels; level++) {
6547
+ const levelMap = rowIndexToTasksMap.get(level);
6548
+ const rowTasks = levelMap == null ? void 0 : levelMap.get(index2);
6549
+ if (Array.isArray(rowTasks)) {
6550
+ tasksAtRow.push(...rowTasks);
6551
+ }
6466
6552
  }
6553
+ } else {
6554
+ const task = mapGlobalRowIndexToTask.get(index2);
6555
+ if (task)
6556
+ tasksAtRow.push(task);
6467
6557
  }
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(
6558
+ console.log("tasksAtRow", tasksAtRow);
6559
+ for (const task of tasksAtRow) {
6560
+ const comparisonLevel = task.comparisonLevel ?? 1;
6561
+ const { id: taskId } = task;
6562
+ if (selectedIdsMirror[taskId] && !addedSelectedTasks[taskId]) {
6563
+ addedSelectedTasks[taskId] = true;
6564
+ const rowIndex = (_a = taskToRowIndexMap.get(comparisonLevel)) == null ? void 0 : _a.get(taskId);
6565
+ if (typeof rowIndex === "number") {
6566
+ selectedTasksRes.push(
6578
6567
  /* @__PURE__ */ jsx(
6579
- "svg",
6568
+ "rect",
6580
6569
  {
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
- )
6570
+ x: 0,
6571
+ y: rowIndex * fullRowHeight,
6572
+ width: "100%",
6573
+ height: fullRowHeight,
6574
+ fill: colorStyles.selectedTaskBackgroundColor
6612
6575
  },
6613
- `Arrow from ${source.id} to ${taskId} on ${comparisonLevel}`
6576
+ `selected-${taskId}`
6614
6577
  )
6615
6578
  );
6616
6579
  }
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",
6580
+ }
6581
+ if (comparisonLevel > comparisonLevels)
6582
+ continue;
6583
+ if (task.type === "empty" || task.type === "user")
6584
+ continue;
6585
+ const key = `${comparisonLevel}_${task.id}`;
6586
+ const criticalPathOnLevel = criticalPaths == null ? void 0 : criticalPaths.get(comparisonLevel);
6587
+ const isCritical = !!(criticalPathOnLevel == null ? void 0 : criticalPathOnLevel.tasks.has(task.id));
6588
+ const {
6589
+ containerX,
6590
+ containerWidth,
6591
+ innerX1,
6592
+ innerX2,
6593
+ width,
6594
+ levelY,
6595
+ progressWidth,
6596
+ x1: taskX1,
6597
+ x2: taskX2
6598
+ } = getTaskCoordinates2(task);
6599
+ tasksRes.push(
6600
+ /* @__PURE__ */ jsx(
6601
+ "svg",
6602
+ {
6603
+ id: task.id,
6604
+ className: "TaskItemClassName",
6605
+ x: containerX + additionalLeftSpace,
6606
+ y: levelY,
6607
+ width: containerWidth,
6608
+ height: fullRowHeight,
6609
+ children: /* @__PURE__ */ jsx(
6610
+ TaskItem,
6652
6611
  {
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}`
6612
+ getTaskGlobalIndexByRef,
6613
+ hasChildren: checkHasChildren(task, childTasksMap),
6614
+ hasDependencyWarning: taskToHasDependencyWarningMap ? checkTaskHasDependencyWarning(task, taskToHasDependencyWarningMap) : false,
6615
+ progressWidth,
6616
+ progressX: rtl ? innerX2 : innerX1,
6617
+ selectTaskOnMouseDown,
6618
+ task,
6619
+ taskYOffset,
6620
+ width,
6621
+ x1: innerX1,
6622
+ x2: innerX2,
6623
+ childOutOfParentWarnings,
6624
+ distances,
6625
+ taskHeight,
6626
+ taskHalfHeight,
6627
+ isProgressChangeable: !task.isDisabled,
6628
+ isDateChangeable: !task.isDisabled,
6629
+ isRelationChangeable: !task.isRelationDisabled,
6630
+ authorizedRelations,
6631
+ ganttRelationEvent,
6632
+ isDelete: !task.isDisabled,
6633
+ onDoubleClick,
6634
+ onClick,
6635
+ onEventStart: handleTaskDragStart,
6636
+ setTooltipTask,
6637
+ onRelationStart: handleBarRelationStart,
6638
+ isSelected: Boolean(selectedIdsMirror[taskId]),
6639
+ isCritical,
6640
+ rtl,
6641
+ fixStartPosition,
6642
+ fixEndPosition,
6643
+ handleDeleteTasks,
6644
+ colorStyles
6645
+ }
6685
6646
  )
6686
- );
6687
- }
6647
+ },
6648
+ key
6649
+ )
6688
6650
  );
6651
+ const addedDependenciesAtLevel = addedDependencies[comparisonLevel] ?? (addedDependencies[comparisonLevel] = {});
6652
+ const addedDependenciesAtTask = addedDependenciesAtLevel[taskId] ?? (addedDependenciesAtLevel[taskId] = {});
6653
+ const dependenciesAtLevel = dependencyMap.get(comparisonLevel);
6654
+ const dependenciesByTask = dependenciesAtLevel == null ? void 0 : dependenciesAtLevel.get(taskId);
6655
+ dependenciesByTask == null ? void 0 : dependenciesByTask.filter(({ source }) => visibleTasksMirror[source.id]).forEach((dep) => {
6656
+ var _a2;
6657
+ if (addedDependenciesAtTask[dep.source.id])
6658
+ return;
6659
+ addedDependenciesAtTask[dep.source.id] = true;
6660
+ const { x1: fromX1, x2: fromX2 } = getTaskCoordinates2(dep.source);
6661
+ const containerX2 = Math.min(fromX1, taskX1) - 300;
6662
+ const containerWidth2 = Math.max(fromX2, taskX2) - containerX2 + 300;
6663
+ const isDepCritical = !!((_a2 = criticalPathOnLevel == null ? void 0 : criticalPathOnLevel.dependencies.get(task.id)) == null ? void 0 : _a2.has(dep.source.id));
6664
+ arrowsRes.push(
6665
+ /* @__PURE__ */ jsx(
6666
+ "svg",
6667
+ {
6668
+ className: "ArrowClassName",
6669
+ x: containerX2 + additionalLeftSpace,
6670
+ y: dep.containerY,
6671
+ width: containerWidth2,
6672
+ height: dep.containerHeight,
6673
+ children: /* @__PURE__ */ jsx(
6674
+ Arrow,
6675
+ {
6676
+ colorStyles,
6677
+ distances,
6678
+ taskFrom: dep.source,
6679
+ extremityFrom: dep.sourceTarget,
6680
+ fromX1: fromX1 - containerX2,
6681
+ fromX2: fromX2 - containerX2,
6682
+ fromY: dep.innerFromY,
6683
+ taskTo: task,
6684
+ extremityTo: dep.ownTarget,
6685
+ toX1: taskX1 - containerX2,
6686
+ toX2: taskX2 - containerX2,
6687
+ toY: dep.innerToY,
6688
+ marginBetweenTasks: dep.marginBetweenTasks,
6689
+ fullRowHeight,
6690
+ taskHeight,
6691
+ isShowDependencyWarnings,
6692
+ isCritical: isDepCritical,
6693
+ rtl,
6694
+ onArrowDoubleClick,
6695
+ onArrowClick,
6696
+ handleFixDependency
6697
+ }
6698
+ )
6699
+ },
6700
+ `Arrow from ${dep.source.id} to ${taskId} on ${comparisonLevel}`
6701
+ )
6702
+ );
6703
+ });
6704
+ const dependentsAtLevel = dependentMap.get(comparisonLevel);
6705
+ const dependentsByTask = dependentsAtLevel == null ? void 0 : dependentsAtLevel.get(taskId);
6706
+ dependentsByTask == null ? void 0 : dependentsByTask.filter(({ dependent }) => visibleTasksMirror[dependent.id]).forEach((dep) => {
6707
+ var _a2, _b;
6708
+ console.log("dependent", dep);
6709
+ const addedDepsForDep = addedDependenciesAtLevel[_a2 = dep.dependent.id] ?? (addedDependenciesAtLevel[_a2] = {});
6710
+ if (addedDepsForDep[taskId])
6711
+ return;
6712
+ addedDepsForDep[taskId] = true;
6713
+ const isDepCritical = !!((_b = criticalPathOnLevel == null ? void 0 : criticalPathOnLevel.dependencies.get(dep.dependent.id)) == null ? void 0 : _b.has(task.id));
6714
+ const { x1: toX1, x2: toX2 } = getTaskCoordinates2(dep.dependent);
6715
+ const containerX2 = Math.min(toX1, taskX1) - 300;
6716
+ const containerWidth2 = Math.max(toX2, taskX2) - containerX2 + 300;
6717
+ arrowsRes.push(
6718
+ /* @__PURE__ */ jsx(
6719
+ "svg",
6720
+ {
6721
+ className: "ArrowClassName",
6722
+ x: containerX2 + additionalLeftSpace,
6723
+ y: dep.containerY,
6724
+ width: containerWidth2,
6725
+ height: dep.containerHeight,
6726
+ children: /* @__PURE__ */ jsx(
6727
+ Arrow,
6728
+ {
6729
+ colorStyles,
6730
+ distances,
6731
+ taskFrom: task,
6732
+ extremityFrom: dep.ownTarget,
6733
+ fromX1: taskX1 - containerX2,
6734
+ fromX2: taskX2 - containerX2,
6735
+ fromY: dep.innerFromY,
6736
+ taskTo: dep.dependent,
6737
+ extremityTo: dep.dependentTarget,
6738
+ toX1: toX1 - containerX2,
6739
+ toX2: toX2 - containerX2,
6740
+ toY: dep.innerToY,
6741
+ marginBetweenTasks: dep.marginBetweenTasks,
6742
+ fullRowHeight,
6743
+ taskHeight,
6744
+ isShowDependencyWarnings,
6745
+ isCritical: isDepCritical,
6746
+ rtl,
6747
+ onArrowDoubleClick,
6748
+ onArrowClick,
6749
+ handleFixDependency
6750
+ }
6751
+ )
6752
+ },
6753
+ `Arrow from ${taskId} to ${dep.dependent.id} on ${comparisonLevel}`
6754
+ )
6755
+ );
6756
+ });
6689
6757
  }
6690
6758
  }
6691
6759
  return [tasksRes, arrowsRes, selectedTasksRes];
@@ -6702,7 +6770,9 @@ const TaskGanttContent = ({
6702
6770
  renderedRowIndexes,
6703
6771
  selectTaskOnMouseDown,
6704
6772
  selectedIdsMirror,
6705
- visibleTasksMirror
6773
+ visibleTasksMirror,
6774
+ rowIndexToTasksMap,
6775
+ enableTaskGrouping
6706
6776
  ]);
6707
6777
  return /* @__PURE__ */ jsxs("g", { className: "content", children: [
6708
6778
  renderedSelectedTasks,
@@ -11376,42 +11446,48 @@ const getMapTaskToRowIndexWithGrouping = (tasks, comparisonLevels, isGrouped = f
11376
11446
  const rowIndexToTaskMap = /* @__PURE__ */ new Map();
11377
11447
  const rowIndexToTasksMap = /* @__PURE__ */ new Map();
11378
11448
  const mapGlobalRowIndexToTask = /* @__PURE__ */ new Map();
11379
- const parentMap = new Map(
11380
- tasks.map((task) => [task.id, task])
11381
- );
11449
+ const parentMap = new Map(tasks.map((t2) => [t2.id, t2]));
11382
11450
  let globalRowIndex = 0;
11383
11451
  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);
11452
+ const taskToRow = /* @__PURE__ */ new Map();
11453
+ const rowToTask = /* @__PURE__ */ new Map();
11454
+ const rowToTasks = /* @__PURE__ */ new Map();
11455
+ taskToRowIndexMap.set(comparisonLevel, taskToRow);
11456
+ rowIndexToTaskMap.set(comparisonLevel, rowToTask);
11457
+ rowIndexToTasksMap.set(comparisonLevel, rowToTasks);
11390
11458
  let rowIndex = 0;
11391
11459
  for (const task of tasks) {
11392
- const level = task.comparisonLevel ?? 1;
11393
- if (level !== comparisonLevel)
11460
+ if ((task.comparisonLevel ?? 1) !== comparisonLevel)
11394
11461
  continue;
11395
- const { id, parent } = task;
11462
+ const { id, parent, type } = task;
11396
11463
  let assignedRowIndex = rowIndex;
11397
- if (isGrouped && parent && parentMap.has(parent)) {
11464
+ if (type === "user" || type === "project") {
11465
+ taskToRow.set(id, rowIndex);
11466
+ rowToTask.set(rowIndex, task);
11467
+ rowToTasks.set(rowIndex, [task]);
11468
+ mapGlobalRowIndexToTask.set(globalRowIndex, task);
11469
+ rowIndex++;
11470
+ globalRowIndex++;
11471
+ continue;
11472
+ }
11473
+ if (isGrouped && parent) {
11398
11474
  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
- }
11475
+ const parentRowIndex = taskToRow.get(parent);
11476
+ if ((parentTask == null ? void 0 : parentTask.hideChildren) && parentRowIndex !== void 0) {
11477
+ assignedRowIndex = parentRowIndex;
11478
+ } else {
11479
+ assignedRowIndex = rowIndex;
11480
+ rowIndex++;
11405
11481
  }
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) {
11482
+ } else {
11483
+ assignedRowIndex = rowIndex;
11413
11484
  rowIndex++;
11414
11485
  }
11486
+ taskToRow.set(id, assignedRowIndex);
11487
+ rowToTask.set(assignedRowIndex, task);
11488
+ const existing = rowToTasks.get(assignedRowIndex) ?? [];
11489
+ rowToTasks.set(assignedRowIndex, [...existing, task]);
11490
+ mapGlobalRowIndexToTask.set(globalRowIndex, task);
11415
11491
  globalRowIndex++;
11416
11492
  }
11417
11493
  }
@@ -11477,6 +11553,7 @@ const defaultDateFormats = {
11477
11553
  const defaultDistances = {
11478
11554
  actionColumnWidth: 40,
11479
11555
  arrowIndent: 20,
11556
+ taskHeight: 24,
11480
11557
  barCornerRadius: 3,
11481
11558
  barFill: 60,
11482
11559
  columnWidth: 60,
@@ -11663,11 +11740,6 @@ const Gantt = ({
11663
11740
  () => distances.rowHeight * comparisonLevels,
11664
11741
  [distances, comparisonLevels]
11665
11742
  );
11666
- const renderedRowIndexes = useOptimizedList(
11667
- ganttTaskContentRef,
11668
- "scrollTop",
11669
- distances.rowHeight
11670
- );
11671
11743
  const colorStyles = useMemo(
11672
11744
  () => ({
11673
11745
  ...defaultColors,
@@ -11683,18 +11755,15 @@ const Gantt = ({
11683
11755
  () => (distances.rowHeight - taskHeight) / 2,
11684
11756
  [distances, taskHeight]
11685
11757
  );
11686
- const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask, rowIndexToTasksMap] = useMemo(
11687
- () => enableTaskGrouping ? getMapTaskToRowIndexWithGrouping(visibleTasks, comparisonLevels, true) : getMapTaskToRowIndex(visibleTasks, comparisonLevels),
11688
- [visibleTasks, comparisonLevels, enableTaskGrouping]
11689
- );
11690
11758
  const taskHalfHeight = useMemo(
11691
11759
  () => Math.round(taskHeight / 2),
11692
11760
  [taskHeight]
11693
11761
  );
11762
+ const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask, rowIndexToTasksMap] = useMemo(
11763
+ () => enableTaskGrouping ? getMapTaskToRowIndexWithGrouping(visibleTasks, comparisonLevels, true) : getMapTaskToRowIndex(visibleTasks, comparisonLevels),
11764
+ [visibleTasks, comparisonLevels, enableTaskGrouping]
11765
+ );
11694
11766
  const maxLevelLength = useMemo(() => {
11695
- if (enableTaskGrouping) {
11696
- return Math.max((rowIndexToTasksMap == null ? void 0 : rowIndexToTasksMap.size) ?? 0, 1);
11697
- }
11698
11767
  let maxLength = 0;
11699
11768
  const countByLevel = {};
11700
11769
  visibleTasks.forEach(({ comparisonLevel = 1 }) => {
@@ -11707,20 +11776,26 @@ const Gantt = ({
11707
11776
  }
11708
11777
  });
11709
11778
  return maxLength;
11710
- }, [visibleTasks, comparisonLevels, enableTaskGrouping, rowIndexToTasksMap]);
11779
+ }, [visibleTasks, comparisonLevels]);
11711
11780
  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);
11781
+ if (!enableTaskGrouping) {
11782
+ return maxLevelLength * fullRowHeight;
11721
11783
  }
11722
- return maxLevelLength * fullRowHeight;
11723
- }, [enableTaskGrouping, rowIndexToTasksMap, maxLevelLength, fullRowHeight, taskHeight]);
11784
+ let totalRows = 0;
11785
+ for (const comparisonMap of rowIndexToTasksMap.values()) {
11786
+ totalRows += comparisonMap.size;
11787
+ }
11788
+ return totalRows * fullRowHeight;
11789
+ }, [enableTaskGrouping, rowIndexToTasksMap, maxLevelLength, fullRowHeight]);
11790
+ const renderedRowIndexes = enableTaskGrouping ? useGroupedVirtualization(
11791
+ //ganttTaskContentRef,
11792
+ rowIndexToTasksMap,
11793
+ fullRowHeight
11794
+ ) : useOptimizedList(
11795
+ ganttTaskContentRef,
11796
+ "scrollTop",
11797
+ fullRowHeight
11798
+ );
11724
11799
  const {
11725
11800
  checkHasCopyTasks,
11726
11801
  checkHasCutTasks,
@@ -11779,22 +11854,10 @@ const Gantt = ({
11779
11854
  const svgClientWidth = renderedColumnIndexes && renderedColumnIndexes[4];
11780
11855
  const countTaskCoordinates$1 = useCallback(
11781
11856
  (task) => {
11782
- var _a;
11783
11857
  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
11858
  return countTaskCoordinatesWithGrouping(
11796
11859
  task,
11797
- taskToRowIndexMap,
11860
+ rowIndexToTasksMap,
11798
11861
  startDate,
11799
11862
  viewMode,
11800
11863
  rtl,
@@ -11803,7 +11866,7 @@ const Gantt = ({
11803
11866
  taskYOffset,
11804
11867
  distances,
11805
11868
  svgWidth,
11806
- sequentialOffset
11869
+ 0
11807
11870
  );
11808
11871
  }
11809
11872
  return countTaskCoordinates(
@@ -11834,7 +11897,19 @@ const Gantt = ({
11834
11897
  ]
11835
11898
  );
11836
11899
  const mapTaskToCoordinates = useMemo(
11837
- () => getMapTaskToCoordinates(
11900
+ () => enableTaskGrouping ? getMapTaskToCoordinatesWithGrouping(
11901
+ tasks,
11902
+ visibleTasksMirror,
11903
+ rowIndexToTasksMap,
11904
+ startDate,
11905
+ viewMode,
11906
+ rtl,
11907
+ fullRowHeight,
11908
+ taskHeight,
11909
+ taskYOffset,
11910
+ distances,
11911
+ svgWidth
11912
+ ) : getMapTaskToCoordinates(
11838
11913
  tasks,
11839
11914
  visibleTasksMirror,
11840
11915
  taskToRowIndexMap,
@@ -11848,17 +11923,19 @@ const Gantt = ({
11848
11923
  svgWidth
11849
11924
  ),
11850
11925
  [
11851
- distances,
11852
- fullRowHeight,
11926
+ tasks,
11927
+ visibleTasksMirror,
11928
+ rowIndexToTasksMap,
11853
11929
  taskToRowIndexMap,
11854
- rtl,
11855
11930
  startDate,
11856
- svgWidth,
11931
+ viewMode,
11932
+ rtl,
11933
+ fullRowHeight,
11857
11934
  taskHeight,
11858
- tasks,
11859
11935
  taskYOffset,
11860
- viewMode,
11861
- visibleTasksMirror
11936
+ distances,
11937
+ svgWidth,
11938
+ enableTaskGrouping
11862
11939
  ]
11863
11940
  );
11864
11941
  const scrollToTask = useCallback(
@@ -11993,8 +12070,6 @@ const Gantt = ({
11993
12070
  };
11994
12071
  const handleExpanderClick = useCallback(
11995
12072
  (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
12073
  if (onChangeExpandState) {
11999
12074
  onChangeExpandState({
12000
12075
  ...clickedTask,
@@ -12870,6 +12945,8 @@ const Gantt = ({
12870
12945
  };
12871
12946
  const barProps = useMemo(
12872
12947
  () => ({
12948
+ enableTaskGrouping,
12949
+ rowIndexToTasksMap,
12873
12950
  authorizedRelations,
12874
12951
  additionalLeftSpace,
12875
12952
  additionalRightSpace,
@@ -12919,6 +12996,8 @@ const Gantt = ({
12919
12996
  [
12920
12997
  additionalLeftSpace,
12921
12998
  additionalRightSpace,
12999
+ enableTaskGrouping,
13000
+ rowIndexToTasksMap,
12922
13001
  checkIsHoliday,
12923
13002
  childOutOfParentWarnings,
12924
13003
  childTasksMap,
@@ -12970,6 +13049,7 @@ const Gantt = ({
12970
13049
  TaskListHeader,
12971
13050
  TaskListTable,
12972
13051
  enableTaskGrouping,
13052
+ rowIndexToTasksMap,
12973
13053
  canMoveTasks,
12974
13054
  canResizeColumns,
12975
13055
  childTasksMap,