@thepocman/gantt-task-react 1.0.15 → 1.0.18

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.
@@ -1943,24 +1943,32 @@ const useOptimizedList = (containerRef, property, cellSize) => {
1943
1943
  ]);
1944
1944
  return indexes;
1945
1945
  };
1946
- const useGroupedVirtualization = (rowIndexToTasksMap, taskHeight) => {
1947
- var _a, _b;
1946
+ const TASK_SPACING = 2;
1947
+ const useGroupedVirtualization = (_containerRef, rowIndexToTasksMap, taskHeight) => {
1948
1948
  const rowEntries = useMemo(() => {
1949
+ if (!rowIndexToTasksMap || rowIndexToTasksMap.size === 0)
1950
+ return [];
1949
1951
  const rowToHeight = /* @__PURE__ */ new Map();
1950
1952
  for (const levelMap of rowIndexToTasksMap.values()) {
1951
1953
  for (const [rowIndex, tasks] of levelMap.entries()) {
1952
- const height = tasks.length * (taskHeight + 2);
1954
+ const height = tasks.length * (taskHeight + TASK_SPACING);
1953
1955
  rowToHeight.set(rowIndex, (rowToHeight.get(rowIndex) ?? 0) + height);
1954
1956
  }
1955
1957
  }
1956
1958
  return [...rowToHeight.entries()].map(([rowIndex, height]) => ({ rowIndex, height })).sort((a4, b3) => a4.rowIndex - b3.rowIndex);
1957
1959
  }, [rowIndexToTasksMap, taskHeight]);
1960
+ if (!rowEntries || rowEntries.length === 0) {
1961
+ return [0, 0, true, true, 0];
1962
+ }
1963
+ const first = rowEntries[0];
1964
+ const last = rowEntries[rowEntries.length - 1];
1965
+ const fullHeight = rowEntries.reduce((sum, r) => sum + r.height, 0);
1958
1966
  return [
1959
- ((_a = rowEntries[0]) == null ? void 0 : _a.rowIndex) ?? 0,
1960
- ((_b = rowEntries[rowEntries.length - 1]) == null ? void 0 : _b.rowIndex) ?? 0,
1967
+ (first == null ? void 0 : first.rowIndex) ?? 0,
1968
+ (last == null ? void 0 : last.rowIndex) ?? 0,
1961
1969
  true,
1962
1970
  true,
1963
- rowEntries.reduce((sum, entry) => sum + entry.height, 0)
1971
+ fullHeight
1964
1972
  ];
1965
1973
  };
1966
1974
  const button$2 = "_button_1eue5_1";
@@ -3439,7 +3447,7 @@ const TaskListInner = ({
3439
3447
  onColumnResizeStart
3440
3448
  ] = useTableListResize(columnsProp, distances, onResizeColumn);
3441
3449
  const renderedIndexes = enableTaskGrouping ? useGroupedVirtualization(
3442
- //taskListContentRef,
3450
+ taskListContentRef,
3443
3451
  rowIndexToTasksMap,
3444
3452
  distances.taskHeight
3445
3453
  ) : useOptimizedList(
@@ -11781,7 +11789,7 @@ const Gantt = ({
11781
11789
  return totalRows * fullRowHeight;
11782
11790
  }, [enableTaskGrouping, rowIndexToTasksMap, maxLevelLength, fullRowHeight]);
11783
11791
  const renderedRowIndexes = enableTaskGrouping ? useGroupedVirtualization(
11784
- //ganttTaskContentRef,
11792
+ ganttTaskContentRef,
11785
11793
  rowIndexToTasksMap,
11786
11794
  fullRowHeight
11787
11795
  ) : useOptimizedList(
@@ -1956,24 +1956,32 @@
1956
1956
  ]);
1957
1957
  return indexes;
1958
1958
  };
1959
- const useGroupedVirtualization = (rowIndexToTasksMap, taskHeight) => {
1960
- var _a, _b;
1959
+ const TASK_SPACING = 2;
1960
+ const useGroupedVirtualization = (_containerRef, rowIndexToTasksMap, taskHeight) => {
1961
1961
  const rowEntries = React.useMemo(() => {
1962
+ if (!rowIndexToTasksMap || rowIndexToTasksMap.size === 0)
1963
+ return [];
1962
1964
  const rowToHeight = /* @__PURE__ */ new Map();
1963
1965
  for (const levelMap of rowIndexToTasksMap.values()) {
1964
1966
  for (const [rowIndex, tasks] of levelMap.entries()) {
1965
- const height = tasks.length * (taskHeight + 2);
1967
+ const height = tasks.length * (taskHeight + TASK_SPACING);
1966
1968
  rowToHeight.set(rowIndex, (rowToHeight.get(rowIndex) ?? 0) + height);
1967
1969
  }
1968
1970
  }
1969
1971
  return [...rowToHeight.entries()].map(([rowIndex, height]) => ({ rowIndex, height })).sort((a2, b2) => a2.rowIndex - b2.rowIndex);
1970
1972
  }, [rowIndexToTasksMap, taskHeight]);
1973
+ if (!rowEntries || rowEntries.length === 0) {
1974
+ return [0, 0, true, true, 0];
1975
+ }
1976
+ const first = rowEntries[0];
1977
+ const last = rowEntries[rowEntries.length - 1];
1978
+ const fullHeight = rowEntries.reduce((sum, r) => sum + r.height, 0);
1971
1979
  return [
1972
- ((_a = rowEntries[0]) == null ? void 0 : _a.rowIndex) ?? 0,
1973
- ((_b = rowEntries[rowEntries.length - 1]) == null ? void 0 : _b.rowIndex) ?? 0,
1980
+ (first == null ? void 0 : first.rowIndex) ?? 0,
1981
+ (last == null ? void 0 : last.rowIndex) ?? 0,
1974
1982
  true,
1975
1983
  true,
1976
- rowEntries.reduce((sum, entry) => sum + entry.height, 0)
1984
+ fullHeight
1977
1985
  ];
1978
1986
  };
1979
1987
  const button$2 = "_button_1eue5_1";
@@ -3452,7 +3460,7 @@
3452
3460
  onColumnResizeStart
3453
3461
  ] = useTableListResize(columnsProp, distances, onResizeColumn);
3454
3462
  const renderedIndexes = enableTaskGrouping ? useGroupedVirtualization(
3455
- //taskListContentRef,
3463
+ taskListContentRef,
3456
3464
  rowIndexToTasksMap,
3457
3465
  distances.taskHeight
3458
3466
  ) : useOptimizedList(
@@ -11794,7 +11802,7 @@
11794
11802
  return totalRows * fullRowHeight;
11795
11803
  }, [enableTaskGrouping, rowIndexToTasksMap, maxLevelLength, fullRowHeight]);
11796
11804
  const renderedRowIndexes = enableTaskGrouping ? useGroupedVirtualization(
11797
- //ganttTaskContentRef,
11805
+ ganttTaskContentRef,
11798
11806
  rowIndexToTasksMap,
11799
11807
  fullRowHeight
11800
11808
  ) : useOptimizedList(
@@ -1,3 +1,3 @@
1
1
  import type { RowIndexToTasksMap } from "../types/public-types";
2
- import { OptimizedListParams } from "./use-optimized-list";
3
- export declare const useGroupedVirtualization: (rowIndexToTasksMap: RowIndexToTasksMap, taskHeight: number) => OptimizedListParams;
2
+ import type { OptimizedListParams } from "./use-optimized-list";
3
+ export declare const useGroupedVirtualization: (_containerRef: React.RefObject<HTMLElement>, rowIndexToTasksMap: RowIndexToTasksMap, taskHeight: number) => OptimizedListParams;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thepocman/gantt-task-react",
3
- "version": "1.0.15",
3
+ "version": "1.0.18",
4
4
  "description": "Fork of gantt-task-react with support for grouped tasks on a single row when collapsed",
5
5
  "author": "Adrian Bueno <adrianlbueno@users.noreply.github.com>",
6
6
  "homepage": "https://github.com/adrianlbueno/gantt-task-react#readme",