@tanstack/react-table 8.19.1 → 8.19.3

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.
@@ -2037,13 +2037,13 @@
2037
2037
  return isTop ? 'top' : isBottom ? 'bottom' : false;
2038
2038
  };
2039
2039
  row.getPinnedIndex = () => {
2040
- var _table$_getPinnedRows, _visiblePinnedRowIds$;
2040
+ var _ref4, _visiblePinnedRowIds$;
2041
2041
  const position = row.getIsPinned();
2042
2042
  if (!position) return -1;
2043
- const visiblePinnedRowIds = (_table$_getPinnedRows = table._getPinnedRows(position)) == null ? void 0 : _table$_getPinnedRows.map(_ref4 => {
2043
+ const visiblePinnedRowIds = (_ref4 = position === 'top' ? table.getTopRows() : table.getBottomRows()) == null ? void 0 : _ref4.map(_ref5 => {
2044
2044
  let {
2045
2045
  id
2046
- } = _ref4;
2046
+ } = _ref5;
2047
2047
  return id;
2048
2048
  });
2049
2049
  return (_visiblePinnedRowIds$ = visiblePinnedRowIds == null ? void 0 : visiblePinnedRowIds.indexOf(row.id)) != null ? _visiblePinnedRowIds$ : -1;
@@ -2064,7 +2064,7 @@
2064
2064
  }
2065
2065
  return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
2066
2066
  };
2067
- table._getPinnedRows = memo(position => [table.getRowModel().rows, table.getState().rowPinning[position], position], (visibleRows, pinnedRowIds, position) => {
2067
+ table._getPinnedRows = (visibleRows, pinnedRowIds, position) => {
2068
2068
  var _table$options$keepPi;
2069
2069
  const rows = ((_table$options$keepPi = table.options.keepPinnedRows) != null ? _table$options$keepPi : true) ?
2070
2070
  //get all rows that are pinned even if they would not be otherwise visible
@@ -2079,9 +2079,9 @@
2079
2079
  ...d,
2080
2080
  position
2081
2081
  }));
2082
- }, getMemoOptions(table.options, 'debugRows', '_getPinnedRows'));
2083
- table.getTopRows = () => table._getPinnedRows('top');
2084
- table.getBottomRows = () => table._getPinnedRows('bottom');
2082
+ };
2083
+ table.getTopRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.top], (allRows, topPinnedRowIds) => table._getPinnedRows(allRows, topPinnedRowIds, 'top'), getMemoOptions(table.options, 'debugRows', 'getTopRows'));
2084
+ table.getBottomRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.bottom], (allRows, bottomPinnedRowIds) => table._getPinnedRows(allRows, bottomPinnedRowIds, 'bottom'), getMemoOptions(table.options, 'debugRows', 'getBottomRows'));
2085
2085
  table.getCenterRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.top, table.getState().rowPinning.bottom], (allRows, top, bottom) => {
2086
2086
  const topAndBottom = new Set([...(top != null ? top : []), ...(bottom != null ? bottom : [])]);
2087
2087
  return allRows.filter(d => !topAndBottom.has(d.id));
@@ -3292,6 +3292,10 @@
3292
3292
  function getGroupedRowModel() {
3293
3293
  return table => memo(() => [table.getState().grouping, table.getPreGroupedRowModel()], (grouping, rowModel) => {
3294
3294
  if (!rowModel.rows.length || !grouping.length) {
3295
+ rowModel.rows.forEach(row => {
3296
+ row.depth = 0;
3297
+ row.parentId = undefined;
3298
+ });
3295
3299
  return rowModel;
3296
3300
  }
3297
3301
 
@@ -3327,7 +3331,7 @@
3327
3331
  // Group the rows together for this level
3328
3332
  const rowGroupsMap = groupBy(rows, columnId);
3329
3333
 
3330
- // Peform aggregations for each group
3334
+ // Perform aggregations for each group
3331
3335
  const aggregatedGroupedRows = Array.from(rowGroupsMap.entries()).map((_ref, index) => {
3332
3336
  let [groupingValue, groupedRows] = _ref;
3333
3337
  let id = `${columnId}:${groupingValue}`;
@@ -3335,6 +3339,9 @@
3335
3339
 
3336
3340
  // First, Recurse to group sub rows before aggregation
3337
3341
  const subRows = groupUpRecursively(groupedRows, depth + 1, id);
3342
+ subRows.forEach(subRow => {
3343
+ subRow.parentId = id;
3344
+ });
3338
3345
 
3339
3346
  // Flatten the leaf rows of the rows in this group
3340
3347
  const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;