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