@tanstack/react-table 8.2.2 → 8.2.5

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.
@@ -963,7 +963,7 @@ const Expanding = {
963
963
  getCanExpand: () => {
964
964
  var _table$options$getRow, _table$options$enable, _row$subRows;
965
965
 
966
- return ((_table$options$getRow = table.options.getRowCanExpand == null ? void 0 : table.options.getRowCanExpand(row)) != null ? _table$options$getRow : true) && ((_table$options$enable = table.options.enableExpanding) != null ? _table$options$enable : true) && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
966
+ return (_table$options$getRow = table.options.getRowCanExpand == null ? void 0 : table.options.getRowCanExpand(row)) != null ? _table$options$getRow : ((_table$options$enable = table.options.enableExpanding) != null ? _table$options$enable : true) && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
967
967
  },
968
968
  getToggleExpandedHandler: () => {
969
969
  const canExpand = row.getCanExpand();
@@ -1993,6 +1993,10 @@ const RowSelection = {
1993
1993
 
1994
1994
  if (value) {
1995
1995
  preGroupedFlatRows.forEach(row => {
1996
+ if (!row.getCanSelect()) {
1997
+ return;
1998
+ }
1999
+
1996
2000
  rowSelection[row.id] = true;
1997
2001
  });
1998
2002
  } else {
@@ -2256,8 +2260,8 @@ const RowSelection = {
2256
2260
  const mutateRowIsSelected = (selectedRowIds, id, value, table) => {
2257
2261
  var _row$subRows;
2258
2262
 
2259
- const row = table.getRow(id);
2260
- row.getIsGrouped(); // if ( // TODO: enforce grouping row selection rules
2263
+ const row = table.getRow(id); // const isGrouped = row.getIsGrouped()
2264
+ // if ( // TODO: enforce grouping row selection rules
2261
2265
  // !isGrouped ||
2262
2266
  // (isGrouped && table.options.enableGroupingRowSelection)
2263
2267
  // ) {
@@ -2267,7 +2271,9 @@ const mutateRowIsSelected = (selectedRowIds, id, value, table) => {
2267
2271
  Object.keys(selectedRowIds).forEach(key => delete selectedRowIds[key]);
2268
2272
  }
2269
2273
 
2270
- selectedRowIds[id] = true;
2274
+ if (row.getCanSelect()) {
2275
+ selectedRowIds[id] = true;
2276
+ }
2271
2277
  } else {
2272
2278
  delete selectedRowIds[id];
2273
2279
  } // }
@@ -3570,9 +3576,20 @@ function getGroupedRowModel() {
3570
3576
  depth = 0;
3571
3577
  }
3572
3578
 
3573
- // This is the last level, just return the rows
3574
- if (depth === existingGrouping.length) {
3575
- return rows;
3579
+ // Grouping depth has been been met
3580
+ // Stop grouping and simply rewrite thd depth and row relationships
3581
+ if (depth >= existingGrouping.length) {
3582
+ return rows.map(row => {
3583
+ row.depth = depth;
3584
+ groupedFlatRows.push(row);
3585
+ groupedRowsById[row.id] = row;
3586
+
3587
+ if (row.subRows) {
3588
+ row.subRows = groupUpRecursively(row.subRows, depth + 1);
3589
+ }
3590
+
3591
+ return row;
3592
+ });
3576
3593
  }
3577
3594
 
3578
3595
  const columnId = existingGrouping[depth]; // Group the rows together for this level