@thepocman/gantt-task-react 1.0.12 → 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.
@@ -474,7 +474,6 @@
474
474
  const enDateLocale = locale;
475
475
  const collectChildren = (arrayRes, mirrorRes, task, childTasksOnLevel, enableTaskGrouping) => {
476
476
  const { comparisonLevel = 1 } = task;
477
- console.log(`Task ${task.id} visibility check: type=${task.type}, hideChildren=${task.hideChildren}, will ${task.type === "empty" || task.hideChildren && task.type !== "user" ? "hide" : "show"} children`);
478
477
  arrayRes.push(task);
479
478
  if (comparisonLevel === 1) {
480
479
  mirrorRes[task.id] = true;
@@ -1604,14 +1603,9 @@
1604
1603
  return { isChanged, changedTask };
1605
1604
  };
1606
1605
  const countTaskCoordinates = (task, taskToRowIndexMap, startDate, viewMode, rtl, fullRowHeight, taskHeight, taskYOffset, distances, svgWidth, sequentialOffset = 0) => {
1607
- const { columnWidth, rowHeight } = distances;
1606
+ const { columnWidth } = distances;
1608
1607
  const { id, comparisonLevel = 1, progress, type } = task;
1609
1608
  const indexesAtLevel = taskToRowIndexMap.get(comparisonLevel);
1610
- console.log("Looking for task id:", task.id, "level:", comparisonLevel);
1611
- console.log("taskToRowIndexMap", Array.from(taskToRowIndexMap.entries()).map(([level, map]) => ({
1612
- level,
1613
- rows: Array.from(map.entries())
1614
- })));
1615
1609
  if (!indexesAtLevel) {
1616
1610
  throw new Error(`Indexes at level ${comparisonLevel} are not found`);
1617
1611
  }
@@ -1621,7 +1615,7 @@
1621
1615
  }
1622
1616
  const x1 = rtl ? svgWidth - taskXCoordinate(task.end, startDate, viewMode, columnWidth) : taskXCoordinate(task.start, startDate, viewMode, columnWidth);
1623
1617
  const x2 = rtl ? svgWidth - taskXCoordinate(task.start, startDate, viewMode, columnWidth) : taskXCoordinate(task.end, startDate, viewMode, columnWidth);
1624
- const levelY = rowIndex * fullRowHeight + rowHeight * (comparisonLevel - 1);
1618
+ const levelY = rowIndex * fullRowHeight;
1625
1619
  const y = levelY + taskYOffset + sequentialOffset;
1626
1620
  const [progressWidth, progressX] = type === "milestone" ? [0, x1] : progressWithByParams(x1, x2, progress, rtl);
1627
1621
  const taskX1 = type === "milestone" ? x1 - taskHeight * 0.5 : x1;
@@ -1673,21 +1667,31 @@
1673
1667
  });
1674
1668
  return res;
1675
1669
  };
1676
- const countTaskCoordinatesWithGrouping = (task, taskToRowIndexMap, startDate, viewMode, rtl, fullRowHeight, taskHeight, taskYOffset, distances, svgWidth, sequentialOffset = 0) => {
1677
- const { columnWidth, rowHeight } = distances;
1670
+ const countTaskCoordinatesWithGrouping = (task, rowIndexToTasksMap, startDate, viewMode, rtl, fullRowHeight, taskHeight, taskYOffset, distances, svgWidth, sequentialOffset = 0) => {
1671
+ const { columnWidth } = distances;
1678
1672
  const { id, comparisonLevel = 1, progress, type } = task;
1679
- const indexesAtLevel = taskToRowIndexMap.get(comparisonLevel);
1680
- if (!indexesAtLevel) {
1681
- throw new Error(`Indexes at level ${comparisonLevel} are not found`);
1673
+ let rowIndex = -1;
1674
+ let taskIndexInRow = 0;
1675
+ const rowMapAtLevel = rowIndexToTasksMap.get(comparisonLevel);
1676
+ if (!rowMapAtLevel) {
1677
+ throw new Error(`No rows found for comparison level ${comparisonLevel}`);
1678
+ }
1679
+ for (const [currentRowIndex, tasksInRow] of rowMapAtLevel.entries()) {
1680
+ const taskIndex = tasksInRow.findIndex((t) => t.id === id);
1681
+ if (taskIndex !== -1) {
1682
+ rowIndex = currentRowIndex;
1683
+ taskIndexInRow = taskIndex;
1684
+ break;
1685
+ }
1682
1686
  }
1683
- const rowIndex = indexesAtLevel.get(id);
1684
- if (typeof rowIndex !== "number") {
1685
- throw new Error(`Row index for task ${id} is not found`);
1687
+ if (rowIndex === -1) {
1688
+ throw new Error(`Task ${id} not found in rowIndexToTasksMap`);
1686
1689
  }
1687
1690
  const x1 = rtl ? svgWidth - taskXCoordinate(task.end, startDate, viewMode, columnWidth) : taskXCoordinate(task.start, startDate, viewMode, columnWidth);
1688
1691
  const x2 = rtl ? svgWidth - taskXCoordinate(task.start, startDate, viewMode, columnWidth) : taskXCoordinate(task.end, startDate, viewMode, columnWidth);
1689
- const levelY = rowIndex * fullRowHeight + rowHeight * (comparisonLevel - 1);
1690
- const y = levelY + taskYOffset + sequentialOffset;
1692
+ const levelY = rowIndex * fullRowHeight;
1693
+ const taskStackOffset = taskIndexInRow * (taskHeight + 2);
1694
+ const y = levelY + taskYOffset + sequentialOffset + taskStackOffset;
1691
1695
  const [progressWidth, progressX] = type === "milestone" ? [0, x1] : progressWithByParams(x1, x2, progress, rtl);
1692
1696
  const taskX1 = type === "milestone" ? x1 - taskHeight * 0.5 : x1;
1693
1697
  const taskX2 = type === "milestone" ? x2 + taskHeight * 0.5 : x2;
@@ -1710,6 +1714,34 @@
1710
1714
  y
1711
1715
  };
1712
1716
  };
1717
+ const getMapTaskToCoordinatesWithGrouping = (tasks, visibleTasksMirror, rowIndexToTasksMap, startDate, viewMode, rtl, fullRowHeight, taskHeight, taskYOffset, distances, svgWidth) => {
1718
+ const res = /* @__PURE__ */ new Map();
1719
+ tasks.forEach((task) => {
1720
+ if (task.type === "empty" || task.type === "user") {
1721
+ return;
1722
+ }
1723
+ const { id, comparisonLevel = 1 } = task;
1724
+ if (!visibleTasksMirror[id]) {
1725
+ return;
1726
+ }
1727
+ const taskCoordinates = countTaskCoordinatesWithGrouping(
1728
+ task,
1729
+ rowIndexToTasksMap,
1730
+ startDate,
1731
+ viewMode,
1732
+ rtl,
1733
+ fullRowHeight,
1734
+ taskHeight,
1735
+ taskYOffset,
1736
+ distances,
1737
+ svgWidth
1738
+ );
1739
+ const resByLevel = res.get(comparisonLevel) || /* @__PURE__ */ new Map();
1740
+ resByLevel.set(id, taskCoordinates);
1741
+ res.set(comparisonLevel, resByLevel);
1742
+ });
1743
+ return res;
1744
+ };
1713
1745
  const getMapTaskToGlobalIndex = (tasks) => {
1714
1746
  const res = /* @__PURE__ */ new Map();
1715
1747
  tasks.forEach((task, index2) => {
@@ -1723,43 +1755,33 @@
1723
1755
  });
1724
1756
  return res;
1725
1757
  };
1726
- const getMapTaskTo = (indexesOnLevel, taskId, level, collectedIndex, childTasksOnLevel) => {
1727
- const childs = childTasksOnLevel.get(taskId);
1728
- if (childs && childs.length > 0) {
1729
- childs.forEach(({
1730
- id: childId
1731
- }, index2) => {
1732
- const childIndex = `${collectedIndex}.${index2 + 1}`;
1733
- indexesOnLevel.set(childId, [level, childIndex]);
1734
- getMapTaskTo(
1735
- indexesOnLevel,
1736
- childId,
1737
- level + 1,
1738
- childIndex,
1739
- childTasksOnLevel
1740
- );
1741
- });
1758
+ const setIndex = (map, level, id, depth, indexStr) => {
1759
+ if (!map.has(level)) {
1760
+ map.set(level, /* @__PURE__ */ new Map());
1742
1761
  }
1762
+ map.get(level).set(id, [depth, indexStr]);
1763
+ };
1764
+ const walkTasks = (map, comparisonLevel, parentId, depth, prefix, childTasksMap) => {
1765
+ const children = childTasksMap.get(parentId);
1766
+ if (!children)
1767
+ return;
1768
+ children.forEach((child, i) => {
1769
+ const indexStr = `${prefix}.${i + 1}`;
1770
+ setIndex(map, comparisonLevel, child.id, depth, indexStr);
1771
+ walkTasks(map, comparisonLevel, child.id, depth + 1, indexStr, childTasksMap);
1772
+ });
1743
1773
  };
1744
1774
  const getMapTaskToNestedIndex = (childTasksMap, rootTasksMap) => {
1745
- const res = /* @__PURE__ */ new Map();
1775
+ const map = /* @__PURE__ */ new Map();
1746
1776
  for (const [comparisonLevel, rootTasks] of rootTasksMap.entries()) {
1747
- const indexesOnLevel = /* @__PURE__ */ new Map();
1748
- const childTasksOnLevel = childTasksMap.get(comparisonLevel) || /* @__PURE__ */ new Map();
1749
- rootTasks.forEach(({ id: rootId }, index2) => {
1750
- const rootIndex = `${index2 + 1}`;
1751
- indexesOnLevel.set(rootId, [0, rootIndex]);
1752
- getMapTaskTo(
1753
- indexesOnLevel,
1754
- rootId,
1755
- 1,
1756
- rootIndex,
1757
- childTasksOnLevel
1758
- );
1777
+ const childMap = childTasksMap.get(comparisonLevel) ?? /* @__PURE__ */ new Map();
1778
+ rootTasks.forEach((task, i) => {
1779
+ const indexStr = `${i + 1}`;
1780
+ setIndex(map, comparisonLevel, task.id, 0, indexStr);
1781
+ walkTasks(map, comparisonLevel, task.id, 1, indexStr, childMap);
1759
1782
  });
1760
- res.set(comparisonLevel, indexesOnLevel);
1761
1783
  }
1762
- return res;
1784
+ return map;
1763
1785
  };
1764
1786
  const getMapTaskToRowIndex = (visibleTasks, comparisonLevels) => {
1765
1787
  const taskToRowIndexRes = /* @__PURE__ */ new Map();
@@ -1934,6 +1956,33 @@
1934
1956
  ]);
1935
1957
  return indexes;
1936
1958
  };
1959
+ const TASK_SPACING = 2;
1960
+ const buildRowEntries = (rowIndexToTasksMap, taskHeight) => {
1961
+ const rowToTaskCount = /* @__PURE__ */ new Map();
1962
+ for (const rowMap of rowIndexToTasksMap.values()) {
1963
+ for (const [rowIndex, tasks] of rowMap.entries()) {
1964
+ rowToTaskCount.set(rowIndex, (rowToTaskCount.get(rowIndex) ?? 0) + tasks.length);
1965
+ }
1966
+ }
1967
+ return [...rowToTaskCount.entries()].map(([rowIndex, count2]) => ({
1968
+ rowIndex,
1969
+ height: count2 * (taskHeight + TASK_SPACING)
1970
+ })).sort((a2, b2) => a2.rowIndex - b2.rowIndex);
1971
+ };
1972
+ const useGroupedVirtualization = (rowIndexToTasksMap, taskHeight) => {
1973
+ var _a, _b;
1974
+ const rowEntries = React.useMemo(
1975
+ () => buildRowEntries(rowIndexToTasksMap, taskHeight),
1976
+ [rowIndexToTasksMap, taskHeight]
1977
+ );
1978
+ return [
1979
+ ((_a = rowEntries[0]) == null ? void 0 : _a.rowIndex) ?? 0,
1980
+ ((_b = rowEntries[rowEntries.length - 1]) == null ? void 0 : _b.rowIndex) ?? 0,
1981
+ true,
1982
+ true,
1983
+ rowEntries.reduce((sum, entry) => sum + entry.height, 0)
1984
+ ];
1985
+ };
1937
1986
  const button$2 = "_button_1eue5_1";
1938
1987
  const styles$i = {
1939
1988
  button: button$2
@@ -3370,6 +3419,7 @@
3370
3419
  dateSetup,
3371
3420
  dependencyMap,
3372
3421
  distances,
3422
+ rowIndexToTasksMap,
3373
3423
  fontFamily,
3374
3424
  fontSize,
3375
3425
  fullRowHeight,
@@ -3408,7 +3458,11 @@
3408
3458
  onTableResizeStart,
3409
3459
  onColumnResizeStart
3410
3460
  ] = useTableListResize(columnsProp, distances, onResizeColumn);
3411
- const renderedIndexes = useOptimizedList(
3461
+ const renderedIndexes = enableTaskGrouping ? useGroupedVirtualization(
3462
+ //taskListContentRef,
3463
+ rowIndexToTasksMap,
3464
+ distances.taskHeight
3465
+ ) : useOptimizedList(
3412
3466
  taskListContentRef,
3413
3467
  "scrollTop",
3414
3468
  fullRowHeight
@@ -3464,6 +3518,7 @@
3464
3518
  columns,
3465
3519
  cutIdsMirror,
3466
3520
  enableTaskGrouping,
3521
+ rowIndexToTasksMap,
3467
3522
  dateSetup,
3468
3523
  dependencyMap,
3469
3524
  distances,
@@ -3685,21 +3740,6 @@
3685
3740
  );
3686
3741
  };
3687
3742
  const TaskListHeaderDefault = React.memo(TaskListHeaderDefaultInner);
3688
- const checkHasChildren = (task, childTasksMap) => {
3689
- const {
3690
- id,
3691
- comparisonLevel = 1
3692
- } = task;
3693
- const childIdsByLevel = childTasksMap.get(comparisonLevel);
3694
- if (!childIdsByLevel) {
3695
- return false;
3696
- }
3697
- const childs = childIdsByLevel.get(id);
3698
- if (!childs) {
3699
- return false;
3700
- }
3701
- return childs.length > 0;
3702
- };
3703
3743
  const taskListTableRow = "_taskListTableRow_1e35i_1";
3704
3744
  const taskListTableRowGrabbing = "_taskListTableRowGrabbing_1e35i_13";
3705
3745
  const cut = "_cut_1e35i_21";
@@ -4043,6 +4083,21 @@
4043
4083
  );
4044
4084
  };
4045
4085
  const TaskListTableRow = React.memo(TaskListTableRowInner);
4086
+ const checkHasChildren = (task, childTasksMap) => {
4087
+ const {
4088
+ id,
4089
+ comparisonLevel = 1
4090
+ } = task;
4091
+ const childIdsByLevel = childTasksMap.get(comparisonLevel);
4092
+ if (!childIdsByLevel) {
4093
+ return false;
4094
+ }
4095
+ const childs = childIdsByLevel.get(id);
4096
+ if (!childs) {
4097
+ return false;
4098
+ }
4099
+ return childs.length > 0;
4100
+ };
4046
4101
  const taskListWrapper = "_taskListWrapper_5941j_1";
4047
4102
  const styles$b = {
4048
4103
  taskListWrapper
@@ -4071,6 +4126,7 @@
4071
4126
  icons,
4072
4127
  isShowTaskNumbers,
4073
4128
  mapTaskToNestedIndex,
4129
+ rowIndexToTasksMap,
4074
4130
  onClick,
4075
4131
  onExpanderClick,
4076
4132
  renderedIndexes,
@@ -4080,98 +4136,146 @@
4080
4136
  tasks
4081
4137
  }) => {
4082
4138
  const renderedTasks = React.useMemo(() => {
4083
- console.log("enableTaskGrouping", enableTaskGrouping);
4084
4139
  if (!enableTaskGrouping) {
4085
- return tasks;
4140
+ return tasks.filter((task) => !task.comparisonLevel || task.comparisonLevel === 1);
4086
4141
  }
4087
- return tasks.filter((task) => {
4088
- const parent = tasks.find((t) => t.id === task.parent);
4089
- const isGroupedChildOfCollapsedUser = parent && parent.type === "user" && parent.hideChildren === true;
4090
- return !isGroupedChildOfCollapsedUser;
4091
- });
4142
+ return tasks.filter((task) => task.type !== "user");
4092
4143
  }, [tasks, enableTaskGrouping]);
4093
4144
  const [draggedTask, setDraggedTask] = React.useState(null);
4094
4145
  const renderedListWithOffset = React.useMemo(() => {
4095
- if (!renderedIndexes) {
4146
+ var _a;
4147
+ if (!renderedIndexes)
4096
4148
  return null;
4097
- }
4098
4149
  const [start, end] = renderedIndexes;
4099
- const renderedList = [];
4100
- for (let index2 = start; index2 <= end; ++index2) {
4101
- const task = renderedTasks[index2];
4102
- if (!task) {
4103
- break;
4104
- }
4105
- const { id, comparisonLevel = 1 } = task;
4106
- const indexesOnLevel = mapTaskToNestedIndex.get(comparisonLevel);
4107
- if (!indexesOnLevel) {
4108
- throw new Error(`Indexes are not found for level ${comparisonLevel}`);
4150
+ const renderList = [];
4151
+ if (!enableTaskGrouping) {
4152
+ for (let rowIndex = start; rowIndex <= end; rowIndex++) {
4153
+ const task = renderedTasks[rowIndex];
4154
+ if (!task)
4155
+ break;
4156
+ const { id, comparisonLevel = 1 } = task;
4157
+ const indexesOnLevel = mapTaskToNestedIndex.get(comparisonLevel);
4158
+ const taskIndex = indexesOnLevel == null ? void 0 : indexesOnLevel.get(id);
4159
+ const [depth, indexStr] = taskIndex ?? [0, ""];
4160
+ renderList.push(
4161
+ /* @__PURE__ */ jsxRuntime.jsx(
4162
+ TaskListTableRow,
4163
+ {
4164
+ canMoveTasks,
4165
+ colors,
4166
+ columns,
4167
+ dateSetup,
4168
+ dependencyMap,
4169
+ depth,
4170
+ distances,
4171
+ fullRowHeight,
4172
+ getTaskCurrentState,
4173
+ handleAddTask,
4174
+ handleDeleteTasks,
4175
+ handleEditTask,
4176
+ handleMoveTaskBefore,
4177
+ handleMoveTaskAfter,
4178
+ handleMoveTasksInside,
4179
+ handleOpenContextMenu,
4180
+ hasChildren: checkHasChildren(task, childTasksMap),
4181
+ icons,
4182
+ indexStr,
4183
+ isClosed: Boolean(task == null ? void 0 : task.hideChildren),
4184
+ isCut: cutIdsMirror[id],
4185
+ isEven: rowIndex % 2 === 1,
4186
+ isSelected: selectedIdsMirror[id],
4187
+ isShowTaskNumbers,
4188
+ onClick,
4189
+ onExpanderClick,
4190
+ scrollToTask,
4191
+ selectTaskOnMouseDown,
4192
+ task,
4193
+ tasks,
4194
+ draggedTask,
4195
+ setDraggedTask
4196
+ },
4197
+ id
4198
+ )
4199
+ );
4109
4200
  }
4110
- const taskIndex = indexesOnLevel.get(id);
4111
- if (!taskIndex) {
4112
- throw new Error(`Index is not found for task ${id}`);
4201
+ } else {
4202
+ for (let rowIndex = start; rowIndex <= end; rowIndex++) {
4203
+ const taskList = (_a = rowIndexToTasksMap.get(1)) == null ? void 0 : _a.get(rowIndex);
4204
+ if (!taskList)
4205
+ continue;
4206
+ for (const task of taskList) {
4207
+ const parent = tasks.find((t) => t.id === task.parent);
4208
+ if (parent == null ? void 0 : parent.hideChildren)
4209
+ continue;
4210
+ const { id, comparisonLevel } = task;
4211
+ let depth = 0;
4212
+ let indexStr = "";
4213
+ console.log("comparisonLevel", comparisonLevel);
4214
+ const levelMap = mapTaskToNestedIndex.get(comparisonLevel);
4215
+ const taskIndex = levelMap == null ? void 0 : levelMap.get(id);
4216
+ if (taskIndex) {
4217
+ console.log("object :>> ", [depth, indexStr] = taskIndex);
4218
+ [depth, indexStr] = taskIndex;
4219
+ }
4220
+ renderList.push(
4221
+ /* @__PURE__ */ jsxRuntime.jsx(
4222
+ TaskListTableRow,
4223
+ {
4224
+ canMoveTasks,
4225
+ colors,
4226
+ columns,
4227
+ dateSetup,
4228
+ dependencyMap,
4229
+ depth,
4230
+ distances,
4231
+ fullRowHeight,
4232
+ getTaskCurrentState,
4233
+ handleAddTask,
4234
+ handleDeleteTasks,
4235
+ handleEditTask,
4236
+ handleMoveTaskBefore,
4237
+ handleMoveTaskAfter,
4238
+ handleMoveTasksInside,
4239
+ handleOpenContextMenu,
4240
+ hasChildren: checkHasChildren(task, childTasksMap),
4241
+ icons,
4242
+ indexStr,
4243
+ isClosed: Boolean(task == null ? void 0 : task.hideChildren),
4244
+ isCut: cutIdsMirror[id],
4245
+ isEven: rowIndex % 2 === 1,
4246
+ isSelected: selectedIdsMirror[id],
4247
+ isShowTaskNumbers,
4248
+ onClick,
4249
+ onExpanderClick,
4250
+ scrollToTask,
4251
+ selectTaskOnMouseDown,
4252
+ task,
4253
+ tasks,
4254
+ draggedTask,
4255
+ setDraggedTask
4256
+ },
4257
+ id
4258
+ )
4259
+ );
4260
+ }
4113
4261
  }
4114
- const [depth, indexStr] = taskIndex;
4115
- renderedList.push(
4116
- /* @__PURE__ */ jsxRuntime.jsx(
4117
- TaskListTableRow,
4118
- {
4119
- canMoveTasks,
4120
- colors,
4121
- columns,
4122
- dateSetup,
4123
- dependencyMap,
4124
- depth,
4125
- distances,
4126
- fullRowHeight,
4127
- getTaskCurrentState,
4128
- handleAddTask,
4129
- handleDeleteTasks,
4130
- handleEditTask,
4131
- handleMoveTaskBefore,
4132
- handleMoveTaskAfter,
4133
- handleMoveTasksInside,
4134
- handleOpenContextMenu,
4135
- hasChildren: checkHasChildren(task, childTasksMap),
4136
- icons,
4137
- indexStr,
4138
- isClosed: Boolean(task == null ? void 0 : task.hideChildren),
4139
- isCut: cutIdsMirror[id],
4140
- isEven: index2 % 2 === 1,
4141
- isSelected: selectedIdsMirror[id],
4142
- isShowTaskNumbers,
4143
- onClick,
4144
- onExpanderClick,
4145
- scrollToTask,
4146
- selectTaskOnMouseDown,
4147
- task,
4148
- tasks,
4149
- draggedTask,
4150
- setDraggedTask
4151
- },
4152
- id
4153
- )
4154
- );
4155
4262
  }
4156
4263
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4157
- /* @__PURE__ */ jsxRuntime.jsx(
4158
- "div",
4159
- {
4160
- style: {
4161
- height: fullRowHeight * start
4162
- }
4163
- }
4164
- ),
4165
- renderedList
4264
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { height: fullRowHeight * start } }),
4265
+ renderList
4166
4266
  ] });
4167
4267
  }, [
4268
+ renderedIndexes,
4269
+ renderedTasks,
4270
+ rowIndexToTasksMap,
4271
+ mapTaskToNestedIndex,
4272
+ tasks,
4273
+ enableTaskGrouping,
4274
+ fullRowHeight,
4168
4275
  colors,
4169
4276
  columns,
4170
4277
  cutIdsMirror,
4171
- fullRowHeight,
4172
4278
  getTaskCurrentState,
4173
- renderedIndexes,
4174
- renderedTasks,
4175
4279
  selectTaskOnMouseDown,
4176
4280
  selectedIdsMirror,
4177
4281
  draggedTask
@@ -4180,10 +4284,7 @@
4180
4284
  "div",
4181
4285
  {
4182
4286
  className: styles$b.taskListWrapper,
4183
- style: {
4184
- fontFamily,
4185
- fontSize
4186
- },
4287
+ style: { fontFamily, fontSize },
4187
4288
  children: renderedListWithOffset
4188
4289
  }
4189
4290
  );
@@ -4992,9 +5093,9 @@
4992
5093
  /* @__PURE__ */ jsxRuntime.jsx(GridBody, { ...props })
4993
5094
  ] });
4994
5095
  };
4995
- const ganttTaskRoot = "_ganttTaskRoot_1g0yd_1";
4996
- const ganttTaskContent = "_ganttTaskContent_1g0yd_81";
4997
- const wrapper$2 = "_wrapper_1g0yd_107";
5096
+ const ganttTaskRoot = "_ganttTaskRoot_jnu0p_1";
5097
+ const ganttTaskContent = "_ganttTaskContent_jnu0p_83";
5098
+ const wrapper$2 = "_wrapper_jnu0p_111";
4998
5099
  const styles$9 = {
4999
5100
  ganttTaskRoot,
5000
5101
  ganttTaskContent,
@@ -6423,6 +6524,8 @@
6423
6524
  handleFixDependency,
6424
6525
  handleTaskDragStart,
6425
6526
  isShowDependencyWarnings,
6527
+ enableTaskGrouping,
6528
+ rowIndexToTasksMap,
6426
6529
  mapGlobalRowIndexToTask,
6427
6530
  onArrowDoubleClick,
6428
6531
  onArrowClick,
@@ -6442,263 +6545,228 @@
6442
6545
  }) => {
6443
6546
  const [renderedTasks, renderedArrows, renderedSelectedTasks] = React.useMemo(() => {
6444
6547
  var _a;
6445
- if (!renderedRowIndexes) {
6548
+ if (!renderedRowIndexes)
6446
6549
  return [null, null, null];
6447
- }
6448
6550
  const [start, end] = renderedRowIndexes;
6449
6551
  const tasksRes = [];
6450
6552
  const arrowsRes = [];
6451
6553
  const selectedTasksRes = [];
6452
6554
  const addedSelectedTasks = {};
6453
6555
  const addedDependencies = {};
6454
- console.log("mapGlobalRowIndexToTask", mapGlobalRowIndexToTask);
6455
6556
  for (let index2 = start; index2 <= end; ++index2) {
6456
- const task = mapGlobalRowIndexToTask.get(index2);
6457
- if (!task) {
6458
- continue;
6459
- }
6460
- const { comparisonLevel = 1, id: taskId } = task;
6461
- if (selectedIdsMirror[taskId] && !addedSelectedTasks[taskId]) {
6462
- addedSelectedTasks[taskId] = true;
6463
- const rowIndex = (_a = taskToRowIndexMap.get(comparisonLevel)) == null ? void 0 : _a.get(taskId);
6464
- if (typeof rowIndex === "number") {
6465
- const y = rowIndex * fullRowHeight;
6466
- selectedTasksRes.push(
6467
- /* @__PURE__ */ jsxRuntime.jsx(
6468
- "rect",
6469
- {
6470
- x: 0,
6471
- y,
6472
- width: "100%",
6473
- height: fullRowHeight,
6474
- fill: colorStyles.selectedTaskBackgroundColor
6475
- },
6476
- `selected-${taskId}`
6477
- )
6478
- );
6557
+ const tasksAtRow = [];
6558
+ if (enableTaskGrouping) {
6559
+ for (let level = 1; level <= comparisonLevels; level++) {
6560
+ const levelMap = rowIndexToTasksMap.get(level);
6561
+ const rowTasks = levelMap == null ? void 0 : levelMap.get(index2);
6562
+ if (Array.isArray(rowTasks)) {
6563
+ tasksAtRow.push(...rowTasks);
6564
+ }
6479
6565
  }
6566
+ } else {
6567
+ const task = mapGlobalRowIndexToTask.get(index2);
6568
+ if (task)
6569
+ tasksAtRow.push(task);
6480
6570
  }
6481
- if (comparisonLevel > comparisonLevels) {
6482
- continue;
6483
- }
6484
- if (task.type === "empty" || task.type === "user") {
6485
- continue;
6486
- }
6487
- const key = `${comparisonLevel}_${task.id}`;
6488
- const criticalPathOnLevel = criticalPaths ? criticalPaths.get(comparisonLevel) : void 0;
6489
- const isCritical = criticalPathOnLevel ? criticalPathOnLevel.tasks.has(task.id) : false;
6490
- const {
6491
- containerX,
6492
- containerWidth,
6493
- innerX1,
6494
- innerX2,
6495
- width,
6496
- levelY,
6497
- progressWidth,
6498
- x1: taskX1,
6499
- x2: taskX2
6500
- } = getTaskCoordinates2(task);
6501
- tasksRes.push(
6502
- /* @__PURE__ */ jsxRuntime.jsx(
6503
- "svg",
6504
- {
6505
- id: task.id,
6506
- className: "TaskItemClassName",
6507
- x: containerX + (additionalLeftSpace || 0),
6508
- y: levelY,
6509
- width: containerWidth,
6510
- height: fullRowHeight,
6511
- children: /* @__PURE__ */ jsxRuntime.jsx(
6512
- TaskItem,
6513
- {
6514
- getTaskGlobalIndexByRef,
6515
- hasChildren: checkHasChildren(task, childTasksMap),
6516
- hasDependencyWarning: taskToHasDependencyWarningMap ? checkTaskHasDependencyWarning(
6517
- task,
6518
- taskToHasDependencyWarningMap
6519
- ) : false,
6520
- progressWidth,
6521
- progressX: rtl ? innerX2 : innerX1,
6522
- selectTaskOnMouseDown,
6523
- task,
6524
- taskYOffset,
6525
- width,
6526
- x1: innerX1,
6527
- x2: innerX2,
6528
- childOutOfParentWarnings,
6529
- distances,
6530
- taskHeight,
6531
- taskHalfHeight,
6532
- isProgressChangeable: !task.isDisabled,
6533
- isDateChangeable: !task.isDisabled,
6534
- isRelationChangeable: !task.isRelationDisabled,
6535
- authorizedRelations,
6536
- ganttRelationEvent,
6537
- isDelete: !task.isDisabled,
6538
- onDoubleClick,
6539
- onClick,
6540
- onEventStart: handleTaskDragStart,
6541
- setTooltipTask,
6542
- onRelationStart: handleBarRelationStart,
6543
- isSelected: Boolean(selectedIdsMirror[taskId]),
6544
- isCritical,
6545
- rtl,
6546
- fixStartPosition,
6547
- fixEndPosition,
6548
- handleDeleteTasks,
6549
- colorStyles
6550
- }
6551
- )
6552
- },
6553
- key
6554
- )
6555
- );
6556
- const addedDependenciesAtLevel = addedDependencies[comparisonLevel] || {};
6557
- if (!addedDependencies[comparisonLevel]) {
6558
- addedDependencies[comparisonLevel] = addedDependenciesAtLevel;
6559
- }
6560
- const addedDependenciesAtTask = addedDependenciesAtLevel[taskId] || {};
6561
- if (!addedDependenciesAtLevel[taskId]) {
6562
- addedDependenciesAtLevel[taskId] = addedDependenciesAtTask;
6563
- }
6564
- const dependenciesAtLevel = dependencyMap.get(comparisonLevel);
6565
- if (!dependenciesAtLevel) {
6566
- continue;
6567
- }
6568
- const dependenciesByTask = dependenciesAtLevel.get(taskId);
6569
- if (dependenciesByTask) {
6570
- const criticalPathForTask = criticalPathOnLevel ? criticalPathOnLevel.dependencies.get(task.id) : void 0;
6571
- dependenciesByTask.filter(({ source }) => visibleTasksMirror[source.id]).forEach(
6572
- ({
6573
- containerHeight,
6574
- containerY,
6575
- innerFromY,
6576
- innerToY,
6577
- marginBetweenTasks,
6578
- ownTarget,
6579
- source,
6580
- sourceTarget
6581
- }) => {
6582
- if (addedDependenciesAtTask[source.id]) {
6583
- return;
6584
- }
6585
- addedDependenciesAtTask[source.id] = true;
6586
- const isCritical2 = criticalPathForTask ? criticalPathForTask.has(source.id) : false;
6587
- const { x1: fromX1, x2: fromX2 } = getTaskCoordinates2(source);
6588
- const containerX2 = Math.min(fromX1, taskX1) - 300;
6589
- const containerWidth2 = Math.max(fromX2, taskX2) - containerX2 + 300;
6590
- arrowsRes.push(
6571
+ console.log("tasksAtRow", tasksAtRow);
6572
+ for (const task of tasksAtRow) {
6573
+ const comparisonLevel = task.comparisonLevel ?? 1;
6574
+ const { id: taskId } = task;
6575
+ if (selectedIdsMirror[taskId] && !addedSelectedTasks[taskId]) {
6576
+ addedSelectedTasks[taskId] = true;
6577
+ const rowIndex = (_a = taskToRowIndexMap.get(comparisonLevel)) == null ? void 0 : _a.get(taskId);
6578
+ if (typeof rowIndex === "number") {
6579
+ selectedTasksRes.push(
6591
6580
  /* @__PURE__ */ jsxRuntime.jsx(
6592
- "svg",
6581
+ "rect",
6593
6582
  {
6594
- className: "ArrowClassName",
6595
- x: containerX2 + (additionalLeftSpace || 0),
6596
- y: containerY,
6597
- width: containerWidth2,
6598
- height: containerHeight,
6599
- children: /* @__PURE__ */ jsxRuntime.jsx(
6600
- Arrow,
6601
- {
6602
- colorStyles,
6603
- distances,
6604
- taskFrom: source,
6605
- extremityFrom: sourceTarget,
6606
- fromX1: fromX1 - containerX2,
6607
- fromX2: fromX2 - containerX2,
6608
- fromY: innerFromY,
6609
- taskTo: task,
6610
- extremityTo: ownTarget,
6611
- toX1: taskX1 - containerX2,
6612
- toX2: taskX2 - containerX2,
6613
- toY: innerToY,
6614
- marginBetweenTasks,
6615
- fullRowHeight,
6616
- taskHeight,
6617
- isShowDependencyWarnings,
6618
- isCritical: isCritical2,
6619
- rtl,
6620
- onArrowDoubleClick,
6621
- onArrowClick,
6622
- handleFixDependency
6623
- }
6624
- )
6583
+ x: 0,
6584
+ y: rowIndex * fullRowHeight,
6585
+ width: "100%",
6586
+ height: fullRowHeight,
6587
+ fill: colorStyles.selectedTaskBackgroundColor
6625
6588
  },
6626
- `Arrow from ${source.id} to ${taskId} on ${comparisonLevel}`
6589
+ `selected-${taskId}`
6627
6590
  )
6628
6591
  );
6629
6592
  }
6630
- );
6631
- }
6632
- const dependentsAtLevel = dependentMap.get(comparisonLevel);
6633
- if (!dependentsAtLevel) {
6634
- continue;
6635
- }
6636
- const dependentsByTask = dependentsAtLevel.get(taskId);
6637
- if (dependentsByTask) {
6638
- dependentsByTask.filter(({ dependent }) => visibleTasksMirror[dependent.id]).forEach(
6639
- ({
6640
- containerHeight,
6641
- containerY,
6642
- innerFromY,
6643
- innerToY,
6644
- marginBetweenTasks,
6645
- ownTarget,
6646
- dependent,
6647
- dependentTarget
6648
- }) => {
6649
- const addedDependenciesAtDependent = addedDependenciesAtLevel[dependent.id] || {};
6650
- if (!addedDependenciesAtLevel[dependent.id]) {
6651
- addedDependenciesAtLevel[dependent.id] = addedDependenciesAtDependent;
6652
- }
6653
- if (addedDependenciesAtDependent[taskId]) {
6654
- return;
6655
- }
6656
- addedDependenciesAtDependent[taskId] = true;
6657
- const criticalPathForTask = criticalPathOnLevel ? criticalPathOnLevel.dependencies.get(dependent.id) : void 0;
6658
- const isCritical2 = criticalPathForTask ? criticalPathForTask.has(task.id) : false;
6659
- const { x1: toX1, x2: toX2 } = getTaskCoordinates2(dependent);
6660
- const containerX2 = Math.min(toX1, taskX1) - 300;
6661
- const containerWidth2 = Math.max(toX2, taskX2) - containerX2 + 300;
6662
- arrowsRes.push(
6663
- /* @__PURE__ */ jsxRuntime.jsx(
6664
- "svg",
6593
+ }
6594
+ if (comparisonLevel > comparisonLevels)
6595
+ continue;
6596
+ if (task.type === "empty" || task.type === "user")
6597
+ continue;
6598
+ const key = `${comparisonLevel}_${task.id}`;
6599
+ const criticalPathOnLevel = criticalPaths == null ? void 0 : criticalPaths.get(comparisonLevel);
6600
+ const isCritical = !!(criticalPathOnLevel == null ? void 0 : criticalPathOnLevel.tasks.has(task.id));
6601
+ const {
6602
+ containerX,
6603
+ containerWidth,
6604
+ innerX1,
6605
+ innerX2,
6606
+ width,
6607
+ levelY,
6608
+ progressWidth,
6609
+ x1: taskX1,
6610
+ x2: taskX2
6611
+ } = getTaskCoordinates2(task);
6612
+ tasksRes.push(
6613
+ /* @__PURE__ */ jsxRuntime.jsx(
6614
+ "svg",
6615
+ {
6616
+ id: task.id,
6617
+ className: "TaskItemClassName",
6618
+ x: containerX + additionalLeftSpace,
6619
+ y: levelY,
6620
+ width: containerWidth,
6621
+ height: fullRowHeight,
6622
+ children: /* @__PURE__ */ jsxRuntime.jsx(
6623
+ TaskItem,
6665
6624
  {
6666
- x: containerX2 + (additionalLeftSpace || 0),
6667
- y: containerY,
6668
- width: containerWidth2,
6669
- height: containerHeight,
6670
- children: /* @__PURE__ */ jsxRuntime.jsx(
6671
- Arrow,
6672
- {
6673
- colorStyles,
6674
- distances,
6675
- taskFrom: task,
6676
- extremityFrom: ownTarget,
6677
- fromX1: taskX1 - containerX2,
6678
- fromX2: taskX2 - containerX2,
6679
- fromY: innerFromY,
6680
- taskTo: dependent,
6681
- extremityTo: dependentTarget,
6682
- toX1: toX1 - containerX2,
6683
- toX2: toX2 - containerX2,
6684
- toY: innerToY,
6685
- marginBetweenTasks,
6686
- fullRowHeight,
6687
- taskHeight,
6688
- isShowDependencyWarnings,
6689
- isCritical: isCritical2,
6690
- rtl,
6691
- onArrowDoubleClick,
6692
- onArrowClick,
6693
- handleFixDependency
6694
- }
6695
- )
6696
- },
6697
- `Arrow from ${taskId} to ${dependent.id} on ${comparisonLevel}`
6625
+ getTaskGlobalIndexByRef,
6626
+ hasChildren: checkHasChildren(task, childTasksMap),
6627
+ hasDependencyWarning: taskToHasDependencyWarningMap ? checkTaskHasDependencyWarning(task, taskToHasDependencyWarningMap) : false,
6628
+ progressWidth,
6629
+ progressX: rtl ? innerX2 : innerX1,
6630
+ selectTaskOnMouseDown,
6631
+ task,
6632
+ taskYOffset,
6633
+ width,
6634
+ x1: innerX1,
6635
+ x2: innerX2,
6636
+ childOutOfParentWarnings,
6637
+ distances,
6638
+ taskHeight,
6639
+ taskHalfHeight,
6640
+ isProgressChangeable: !task.isDisabled,
6641
+ isDateChangeable: !task.isDisabled,
6642
+ isRelationChangeable: !task.isRelationDisabled,
6643
+ authorizedRelations,
6644
+ ganttRelationEvent,
6645
+ isDelete: !task.isDisabled,
6646
+ onDoubleClick,
6647
+ onClick,
6648
+ onEventStart: handleTaskDragStart,
6649
+ setTooltipTask,
6650
+ onRelationStart: handleBarRelationStart,
6651
+ isSelected: Boolean(selectedIdsMirror[taskId]),
6652
+ isCritical,
6653
+ rtl,
6654
+ fixStartPosition,
6655
+ fixEndPosition,
6656
+ handleDeleteTasks,
6657
+ colorStyles
6658
+ }
6698
6659
  )
6699
- );
6700
- }
6660
+ },
6661
+ key
6662
+ )
6701
6663
  );
6664
+ const addedDependenciesAtLevel = addedDependencies[comparisonLevel] ?? (addedDependencies[comparisonLevel] = {});
6665
+ const addedDependenciesAtTask = addedDependenciesAtLevel[taskId] ?? (addedDependenciesAtLevel[taskId] = {});
6666
+ const dependenciesAtLevel = dependencyMap.get(comparisonLevel);
6667
+ const dependenciesByTask = dependenciesAtLevel == null ? void 0 : dependenciesAtLevel.get(taskId);
6668
+ dependenciesByTask == null ? void 0 : dependenciesByTask.filter(({ source }) => visibleTasksMirror[source.id]).forEach((dep) => {
6669
+ var _a2;
6670
+ if (addedDependenciesAtTask[dep.source.id])
6671
+ return;
6672
+ addedDependenciesAtTask[dep.source.id] = true;
6673
+ const { x1: fromX1, x2: fromX2 } = getTaskCoordinates2(dep.source);
6674
+ const containerX2 = Math.min(fromX1, taskX1) - 300;
6675
+ const containerWidth2 = Math.max(fromX2, taskX2) - containerX2 + 300;
6676
+ const isDepCritical = !!((_a2 = criticalPathOnLevel == null ? void 0 : criticalPathOnLevel.dependencies.get(task.id)) == null ? void 0 : _a2.has(dep.source.id));
6677
+ arrowsRes.push(
6678
+ /* @__PURE__ */ jsxRuntime.jsx(
6679
+ "svg",
6680
+ {
6681
+ className: "ArrowClassName",
6682
+ x: containerX2 + additionalLeftSpace,
6683
+ y: dep.containerY,
6684
+ width: containerWidth2,
6685
+ height: dep.containerHeight,
6686
+ children: /* @__PURE__ */ jsxRuntime.jsx(
6687
+ Arrow,
6688
+ {
6689
+ colorStyles,
6690
+ distances,
6691
+ taskFrom: dep.source,
6692
+ extremityFrom: dep.sourceTarget,
6693
+ fromX1: fromX1 - containerX2,
6694
+ fromX2: fromX2 - containerX2,
6695
+ fromY: dep.innerFromY,
6696
+ taskTo: task,
6697
+ extremityTo: dep.ownTarget,
6698
+ toX1: taskX1 - containerX2,
6699
+ toX2: taskX2 - containerX2,
6700
+ toY: dep.innerToY,
6701
+ marginBetweenTasks: dep.marginBetweenTasks,
6702
+ fullRowHeight,
6703
+ taskHeight,
6704
+ isShowDependencyWarnings,
6705
+ isCritical: isDepCritical,
6706
+ rtl,
6707
+ onArrowDoubleClick,
6708
+ onArrowClick,
6709
+ handleFixDependency
6710
+ }
6711
+ )
6712
+ },
6713
+ `Arrow from ${dep.source.id} to ${taskId} on ${comparisonLevel}`
6714
+ )
6715
+ );
6716
+ });
6717
+ const dependentsAtLevel = dependentMap.get(comparisonLevel);
6718
+ const dependentsByTask = dependentsAtLevel == null ? void 0 : dependentsAtLevel.get(taskId);
6719
+ dependentsByTask == null ? void 0 : dependentsByTask.filter(({ dependent }) => visibleTasksMirror[dependent.id]).forEach((dep) => {
6720
+ var _a2, _b;
6721
+ console.log("dependent", dep);
6722
+ const addedDepsForDep = addedDependenciesAtLevel[_a2 = dep.dependent.id] ?? (addedDependenciesAtLevel[_a2] = {});
6723
+ if (addedDepsForDep[taskId])
6724
+ return;
6725
+ addedDepsForDep[taskId] = true;
6726
+ const isDepCritical = !!((_b = criticalPathOnLevel == null ? void 0 : criticalPathOnLevel.dependencies.get(dep.dependent.id)) == null ? void 0 : _b.has(task.id));
6727
+ const { x1: toX1, x2: toX2 } = getTaskCoordinates2(dep.dependent);
6728
+ const containerX2 = Math.min(toX1, taskX1) - 300;
6729
+ const containerWidth2 = Math.max(toX2, taskX2) - containerX2 + 300;
6730
+ arrowsRes.push(
6731
+ /* @__PURE__ */ jsxRuntime.jsx(
6732
+ "svg",
6733
+ {
6734
+ className: "ArrowClassName",
6735
+ x: containerX2 + additionalLeftSpace,
6736
+ y: dep.containerY,
6737
+ width: containerWidth2,
6738
+ height: dep.containerHeight,
6739
+ children: /* @__PURE__ */ jsxRuntime.jsx(
6740
+ Arrow,
6741
+ {
6742
+ colorStyles,
6743
+ distances,
6744
+ taskFrom: task,
6745
+ extremityFrom: dep.ownTarget,
6746
+ fromX1: taskX1 - containerX2,
6747
+ fromX2: taskX2 - containerX2,
6748
+ fromY: dep.innerFromY,
6749
+ taskTo: dep.dependent,
6750
+ extremityTo: dep.dependentTarget,
6751
+ toX1: toX1 - containerX2,
6752
+ toX2: toX2 - containerX2,
6753
+ toY: dep.innerToY,
6754
+ marginBetweenTasks: dep.marginBetweenTasks,
6755
+ fullRowHeight,
6756
+ taskHeight,
6757
+ isShowDependencyWarnings,
6758
+ isCritical: isDepCritical,
6759
+ rtl,
6760
+ onArrowDoubleClick,
6761
+ onArrowClick,
6762
+ handleFixDependency
6763
+ }
6764
+ )
6765
+ },
6766
+ `Arrow from ${taskId} to ${dep.dependent.id} on ${comparisonLevel}`
6767
+ )
6768
+ );
6769
+ });
6702
6770
  }
6703
6771
  }
6704
6772
  return [tasksRes, arrowsRes, selectedTasksRes];
@@ -6715,7 +6783,9 @@
6715
6783
  renderedRowIndexes,
6716
6784
  selectTaskOnMouseDown,
6717
6785
  selectedIdsMirror,
6718
- visibleTasksMirror
6786
+ visibleTasksMirror,
6787
+ rowIndexToTasksMap,
6788
+ enableTaskGrouping
6719
6789
  ]);
6720
6790
  return /* @__PURE__ */ jsxRuntime.jsxs("g", { className: "content", children: [
6721
6791
  renderedSelectedTasks,
@@ -11389,42 +11459,48 @@
11389
11459
  const rowIndexToTaskMap = /* @__PURE__ */ new Map();
11390
11460
  const rowIndexToTasksMap = /* @__PURE__ */ new Map();
11391
11461
  const mapGlobalRowIndexToTask = /* @__PURE__ */ new Map();
11392
- const parentMap = new Map(
11393
- tasks.map((task) => [task.id, task])
11394
- );
11462
+ const parentMap = new Map(tasks.map((t) => [t.id, t]));
11395
11463
  let globalRowIndex = 0;
11396
11464
  for (let comparisonLevel = 1; comparisonLevel <= comparisonLevels; comparisonLevel++) {
11397
- const taskToRowIndexMapAtLevel = /* @__PURE__ */ new Map();
11398
- const rowIndexToTaskMapAtLevel = /* @__PURE__ */ new Map();
11399
- const rowIndexToTasksMapAtLevel = /* @__PURE__ */ new Map();
11400
- taskToRowIndexMap.set(comparisonLevel, taskToRowIndexMapAtLevel);
11401
- rowIndexToTaskMap.set(comparisonLevel, rowIndexToTaskMapAtLevel);
11402
- rowIndexToTasksMap.set(comparisonLevel, rowIndexToTasksMapAtLevel);
11465
+ const taskToRow = /* @__PURE__ */ new Map();
11466
+ const rowToTask = /* @__PURE__ */ new Map();
11467
+ const rowToTasks = /* @__PURE__ */ new Map();
11468
+ taskToRowIndexMap.set(comparisonLevel, taskToRow);
11469
+ rowIndexToTaskMap.set(comparisonLevel, rowToTask);
11470
+ rowIndexToTasksMap.set(comparisonLevel, rowToTasks);
11403
11471
  let rowIndex = 0;
11404
11472
  for (const task of tasks) {
11405
- const level = task.comparisonLevel ?? 1;
11406
- if (level !== comparisonLevel)
11473
+ if ((task.comparisonLevel ?? 1) !== comparisonLevel)
11407
11474
  continue;
11408
- const { id, parent } = task;
11475
+ const { id, parent, type } = task;
11409
11476
  let assignedRowIndex = rowIndex;
11410
- if (isGrouped && parent && parentMap.has(parent)) {
11477
+ if (type === "user" || type === "project") {
11478
+ taskToRow.set(id, rowIndex);
11479
+ rowToTask.set(rowIndex, task);
11480
+ rowToTasks.set(rowIndex, [task]);
11481
+ mapGlobalRowIndexToTask.set(globalRowIndex, task);
11482
+ rowIndex++;
11483
+ globalRowIndex++;
11484
+ continue;
11485
+ }
11486
+ if (isGrouped && parent) {
11411
11487
  const parentTask = parentMap.get(parent);
11412
- const isGroupedAudit = (parentTask == null ? void 0 : parentTask.type) === "user" && (parentTask == null ? void 0 : parentTask.hideChildren);
11413
- if (isGroupedAudit) {
11414
- const parentRowIndex = taskToRowIndexMapAtLevel.get(parent);
11415
- if (typeof parentRowIndex === "number") {
11416
- assignedRowIndex = parentRowIndex;
11417
- }
11488
+ const parentRowIndex = taskToRow.get(parent);
11489
+ if ((parentTask == null ? void 0 : parentTask.hideChildren) && parentRowIndex !== void 0) {
11490
+ assignedRowIndex = parentRowIndex;
11491
+ } else {
11492
+ assignedRowIndex = rowIndex;
11493
+ rowIndex++;
11418
11494
  }
11419
- }
11420
- taskToRowIndexMapAtLevel.set(id, assignedRowIndex);
11421
- rowIndexToTaskMapAtLevel.set(assignedRowIndex, task);
11422
- const existingTasks = rowIndexToTasksMapAtLevel.get(assignedRowIndex) ?? [];
11423
- rowIndexToTasksMapAtLevel.set(assignedRowIndex, [...existingTasks, task]);
11424
- mapGlobalRowIndexToTask.set(globalRowIndex, task);
11425
- if (assignedRowIndex === rowIndex) {
11495
+ } else {
11496
+ assignedRowIndex = rowIndex;
11426
11497
  rowIndex++;
11427
11498
  }
11499
+ taskToRow.set(id, assignedRowIndex);
11500
+ rowToTask.set(assignedRowIndex, task);
11501
+ const existing = rowToTasks.get(assignedRowIndex) ?? [];
11502
+ rowToTasks.set(assignedRowIndex, [...existing, task]);
11503
+ mapGlobalRowIndexToTask.set(globalRowIndex, task);
11428
11504
  globalRowIndex++;
11429
11505
  }
11430
11506
  }
@@ -11490,6 +11566,7 @@
11490
11566
  const defaultDistances = {
11491
11567
  actionColumnWidth: 40,
11492
11568
  arrowIndent: 20,
11569
+ taskHeight: 24,
11493
11570
  barCornerRadius: 3,
11494
11571
  barFill: 60,
11495
11572
  columnWidth: 60,
@@ -11676,11 +11753,6 @@
11676
11753
  () => distances.rowHeight * comparisonLevels,
11677
11754
  [distances, comparisonLevels]
11678
11755
  );
11679
- const renderedRowIndexes = useOptimizedList(
11680
- ganttTaskContentRef,
11681
- "scrollTop",
11682
- distances.rowHeight
11683
- );
11684
11756
  const colorStyles = React.useMemo(
11685
11757
  () => ({
11686
11758
  ...defaultColors,
@@ -11696,27 +11768,15 @@
11696
11768
  () => (distances.rowHeight - taskHeight) / 2,
11697
11769
  [distances, taskHeight]
11698
11770
  );
11699
- const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask, rowIndexToTasksMap] = React.useMemo(
11700
- () => enableTaskGrouping ? getMapTaskToRowIndexWithGrouping(visibleTasks, comparisonLevels, true) : getMapTaskToRowIndex(visibleTasks, comparisonLevels),
11701
- [visibleTasks, comparisonLevels, enableTaskGrouping]
11702
- );
11703
11771
  const taskHalfHeight = React.useMemo(
11704
11772
  () => Math.round(taskHeight / 2),
11705
11773
  [taskHeight]
11706
11774
  );
11775
+ const [taskToRowIndexMap, rowIndexToTaskMap, mapGlobalRowIndexToTask, rowIndexToTasksMap] = React.useMemo(
11776
+ () => enableTaskGrouping ? getMapTaskToRowIndexWithGrouping(visibleTasks, comparisonLevels, true) : getMapTaskToRowIndex(visibleTasks, comparisonLevels),
11777
+ [visibleTasks, comparisonLevels, enableTaskGrouping]
11778
+ );
11707
11779
  const maxLevelLength = React.useMemo(() => {
11708
- if (enableTaskGrouping) {
11709
- let totalHeightInRows = 0;
11710
- for (const [_, rowMap] of rowIndexToTasksMap) {
11711
- for (const [_2, tasksInRow] of rowMap) {
11712
- const maxStack = tasksInRow.length;
11713
- const stackedHeight = maxStack * (taskHeight + 2);
11714
- const rowsNeeded = Math.ceil(stackedHeight / fullRowHeight);
11715
- totalHeightInRows += rowsNeeded;
11716
- }
11717
- }
11718
- return Math.max(totalHeightInRows, 1);
11719
- }
11720
11780
  let maxLength = 0;
11721
11781
  const countByLevel = {};
11722
11782
  visibleTasks.forEach(({ comparisonLevel = 1 }) => {
@@ -11729,20 +11789,26 @@
11729
11789
  }
11730
11790
  });
11731
11791
  return maxLength;
11732
- }, [visibleTasks, comparisonLevels, enableTaskGrouping, rowIndexToTasksMap, fullRowHeight, taskHeight]);
11792
+ }, [visibleTasks, comparisonLevels]);
11733
11793
  const ganttFullHeight = React.useMemo(() => {
11734
- if (enableTaskGrouping) {
11735
- let totalHeight = 0;
11736
- for (const [, taskMap] of rowIndexToTasksMap) {
11737
- for (const [, tasks2] of taskMap) {
11738
- const stackedHeight = tasks2.length * (taskHeight + 2);
11739
- totalHeight += Math.max(stackedHeight, fullRowHeight);
11740
- }
11741
- }
11742
- return totalHeight;
11794
+ if (!enableTaskGrouping) {
11795
+ return maxLevelLength * fullRowHeight;
11796
+ }
11797
+ let totalRows = 0;
11798
+ for (const comparisonMap of rowIndexToTasksMap.values()) {
11799
+ totalRows += comparisonMap.size;
11743
11800
  }
11744
- return maxLevelLength * fullRowHeight;
11745
- }, [enableTaskGrouping, rowIndexToTasksMap, maxLevelLength, fullRowHeight, taskHeight]);
11801
+ return totalRows * fullRowHeight;
11802
+ }, [enableTaskGrouping, rowIndexToTasksMap, maxLevelLength, fullRowHeight]);
11803
+ const renderedRowIndexes = enableTaskGrouping ? useGroupedVirtualization(
11804
+ //ganttTaskContentRef,
11805
+ rowIndexToTasksMap,
11806
+ fullRowHeight
11807
+ ) : useOptimizedList(
11808
+ ganttTaskContentRef,
11809
+ "scrollTop",
11810
+ fullRowHeight
11811
+ );
11746
11812
  const {
11747
11813
  checkHasCopyTasks,
11748
11814
  checkHasCutTasks,
@@ -11801,22 +11867,10 @@
11801
11867
  const svgClientWidth = renderedColumnIndexes && renderedColumnIndexes[4];
11802
11868
  const countTaskCoordinates$1 = React.useCallback(
11803
11869
  (task) => {
11804
- var _a;
11805
11870
  if (enableTaskGrouping) {
11806
- const comparisonLevel = task.comparisonLevel ?? 1;
11807
- let sequentialOffset = 0;
11808
- const indexesAtLevel = taskToRowIndexMap.get(comparisonLevel);
11809
- const rowIndex = indexesAtLevel == null ? void 0 : indexesAtLevel.get(task.id);
11810
- if (typeof rowIndex === "number") {
11811
- const rowTasksAtLevel = ((_a = rowIndexToTasksMap.get(comparisonLevel)) == null ? void 0 : _a.get(rowIndex)) ?? [];
11812
- const indexInRow = rowTasksAtLevel.findIndex((t) => t.id === task.id);
11813
- if (indexInRow !== -1) {
11814
- sequentialOffset = indexInRow * (taskHeight + 2);
11815
- }
11816
- }
11817
11871
  return countTaskCoordinatesWithGrouping(
11818
11872
  task,
11819
- taskToRowIndexMap,
11873
+ rowIndexToTasksMap,
11820
11874
  startDate,
11821
11875
  viewMode,
11822
11876
  rtl,
@@ -11825,7 +11879,7 @@
11825
11879
  taskYOffset,
11826
11880
  distances,
11827
11881
  svgWidth,
11828
- sequentialOffset
11882
+ 0
11829
11883
  );
11830
11884
  }
11831
11885
  return countTaskCoordinates(
@@ -11856,7 +11910,19 @@
11856
11910
  ]
11857
11911
  );
11858
11912
  const mapTaskToCoordinates = React.useMemo(
11859
- () => getMapTaskToCoordinates(
11913
+ () => enableTaskGrouping ? getMapTaskToCoordinatesWithGrouping(
11914
+ tasks,
11915
+ visibleTasksMirror,
11916
+ rowIndexToTasksMap,
11917
+ startDate,
11918
+ viewMode,
11919
+ rtl,
11920
+ fullRowHeight,
11921
+ taskHeight,
11922
+ taskYOffset,
11923
+ distances,
11924
+ svgWidth
11925
+ ) : getMapTaskToCoordinates(
11860
11926
  tasks,
11861
11927
  visibleTasksMirror,
11862
11928
  taskToRowIndexMap,
@@ -11870,17 +11936,19 @@
11870
11936
  svgWidth
11871
11937
  ),
11872
11938
  [
11873
- distances,
11874
- fullRowHeight,
11939
+ tasks,
11940
+ visibleTasksMirror,
11941
+ rowIndexToTasksMap,
11875
11942
  taskToRowIndexMap,
11876
- rtl,
11877
11943
  startDate,
11878
- svgWidth,
11944
+ viewMode,
11945
+ rtl,
11946
+ fullRowHeight,
11879
11947
  taskHeight,
11880
- tasks,
11881
11948
  taskYOffset,
11882
- viewMode,
11883
- visibleTasksMirror
11949
+ distances,
11950
+ svgWidth,
11951
+ enableTaskGrouping
11884
11952
  ]
11885
11953
  );
11886
11954
  const scrollToTask = React.useCallback(
@@ -12890,6 +12958,8 @@
12890
12958
  };
12891
12959
  const barProps = React.useMemo(
12892
12960
  () => ({
12961
+ enableTaskGrouping,
12962
+ rowIndexToTasksMap,
12893
12963
  authorizedRelations,
12894
12964
  additionalLeftSpace,
12895
12965
  additionalRightSpace,
@@ -12939,6 +13009,8 @@
12939
13009
  [
12940
13010
  additionalLeftSpace,
12941
13011
  additionalRightSpace,
13012
+ enableTaskGrouping,
13013
+ rowIndexToTasksMap,
12942
13014
  checkIsHoliday,
12943
13015
  childOutOfParentWarnings,
12944
13016
  childTasksMap,
@@ -12990,6 +13062,7 @@
12990
13062
  TaskListHeader,
12991
13063
  TaskListTable,
12992
13064
  enableTaskGrouping,
13065
+ rowIndexToTasksMap,
12993
13066
  canMoveTasks,
12994
13067
  canResizeColumns,
12995
13068
  childTasksMap,