@tanstack/svelte-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.
@@ -2018,13 +2018,13 @@
2018
2018
  return isTop ? 'top' : isBottom ? 'bottom' : false;
2019
2019
  };
2020
2020
  row.getPinnedIndex = () => {
2021
- var _table$_getPinnedRows, _visiblePinnedRowIds$;
2021
+ var _ref4, _visiblePinnedRowIds$;
2022
2022
  const position = row.getIsPinned();
2023
2023
  if (!position) return -1;
2024
- const visiblePinnedRowIds = (_table$_getPinnedRows = table._getPinnedRows(position)) == null ? void 0 : _table$_getPinnedRows.map(_ref4 => {
2024
+ const visiblePinnedRowIds = (_ref4 = position === 'top' ? table.getTopRows() : table.getBottomRows()) == null ? void 0 : _ref4.map(_ref5 => {
2025
2025
  let {
2026
2026
  id
2027
- } = _ref4;
2027
+ } = _ref5;
2028
2028
  return id;
2029
2029
  });
2030
2030
  return (_visiblePinnedRowIds$ = visiblePinnedRowIds == null ? void 0 : visiblePinnedRowIds.indexOf(row.id)) != null ? _visiblePinnedRowIds$ : -1;
@@ -2045,7 +2045,7 @@
2045
2045
  }
2046
2046
  return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
2047
2047
  };
2048
- table._getPinnedRows = memo(position => [table.getRowModel().rows, table.getState().rowPinning[position], position], (visibleRows, pinnedRowIds, position) => {
2048
+ table._getPinnedRows = (visibleRows, pinnedRowIds, position) => {
2049
2049
  var _table$options$keepPi;
2050
2050
  const rows = ((_table$options$keepPi = table.options.keepPinnedRows) != null ? _table$options$keepPi : true) ?
2051
2051
  //get all rows that are pinned even if they would not be otherwise visible
@@ -2060,9 +2060,9 @@
2060
2060
  ...d,
2061
2061
  position
2062
2062
  }));
2063
- }, getMemoOptions(table.options, 'debugRows', '_getPinnedRows'));
2064
- table.getTopRows = () => table._getPinnedRows('top');
2065
- table.getBottomRows = () => table._getPinnedRows('bottom');
2063
+ };
2064
+ table.getTopRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.top], (allRows, topPinnedRowIds) => table._getPinnedRows(allRows, topPinnedRowIds, 'top'), getMemoOptions(table.options, 'debugRows', 'getTopRows'));
2065
+ table.getBottomRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.bottom], (allRows, bottomPinnedRowIds) => table._getPinnedRows(allRows, bottomPinnedRowIds, 'bottom'), getMemoOptions(table.options, 'debugRows', 'getBottomRows'));
2066
2066
  table.getCenterRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.top, table.getState().rowPinning.bottom], (allRows, top, bottom) => {
2067
2067
  const topAndBottom = new Set([...(top != null ? top : []), ...(bottom != null ? bottom : [])]);
2068
2068
  return allRows.filter(d => !topAndBottom.has(d.id));
@@ -3273,6 +3273,10 @@
3273
3273
  function getGroupedRowModel() {
3274
3274
  return table => memo(() => [table.getState().grouping, table.getPreGroupedRowModel()], (grouping, rowModel) => {
3275
3275
  if (!rowModel.rows.length || !grouping.length) {
3276
+ rowModel.rows.forEach(row => {
3277
+ row.depth = 0;
3278
+ row.parentId = undefined;
3279
+ });
3276
3280
  return rowModel;
3277
3281
  }
3278
3282
 
@@ -3308,7 +3312,7 @@
3308
3312
  // Group the rows together for this level
3309
3313
  const rowGroupsMap = groupBy(rows, columnId);
3310
3314
 
3311
- // Peform aggregations for each group
3315
+ // Perform aggregations for each group
3312
3316
  const aggregatedGroupedRows = Array.from(rowGroupsMap.entries()).map((_ref, index) => {
3313
3317
  let [groupingValue, groupedRows] = _ref;
3314
3318
  let id = `${columnId}:${groupingValue}`;
@@ -3316,6 +3320,9 @@
3316
3320
 
3317
3321
  // First, Recurse to group sub rows before aggregation
3318
3322
  const subRows = groupUpRecursively(groupedRows, depth + 1, id);
3323
+ subRows.forEach(subRow => {
3324
+ subRow.parentId = id;
3325
+ });
3319
3326
 
3320
3327
  // Flatten the leaf rows of the rows in this group
3321
3328
  const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;