@tanstack/react-table 8.0.0-beta.4 → 8.0.0-beta.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.
@@ -2032,11 +2032,11 @@ const RowSelection = {
2032
2032
  });
2033
2033
  },
2034
2034
  toggleAllPageRowsSelected: value => instance.setRowSelection(old => {
2035
- typeof value !== 'undefined' ? value : !instance.getIsAllPageRowsSelected();
2035
+ const resolvedValue = typeof value !== 'undefined' ? value : !instance.getIsAllPageRowsSelected();
2036
2036
  const rowSelection = { ...old
2037
2037
  };
2038
2038
  instance.getRowModel().rows.forEach(row => {
2039
- mutateRowIsSelected(rowSelection, row.id, value, instance);
2039
+ mutateRowIsSelected(rowSelection, row.id, resolvedValue, instance);
2040
2040
  });
2041
2041
  return rowSelection;
2042
2042
  }),
@@ -2191,7 +2191,7 @@ const RowSelection = {
2191
2191
  },
2192
2192
  getIsSomePageRowsSelected: () => {
2193
2193
  const paginationFlatRows = instance.getPaginationRowModel().flatRows;
2194
- return instance.getIsAllPageRowsSelected() ? false : !!(paginationFlatRows != null && paginationFlatRows.length);
2194
+ return instance.getIsAllPageRowsSelected() ? false : paginationFlatRows.some(d => d.getIsSelected() || d.getIsSomeSelected());
2195
2195
  },
2196
2196
  getToggleAllRowsSelectedHandler: () => {
2197
2197
  return e => {
@@ -3829,20 +3829,34 @@ function getPaginationRowModel(opts) {
3829
3829
  const pageStart = pageSize * pageIndex;
3830
3830
  const pageEnd = pageStart + pageSize;
3831
3831
  rows = rows.slice(pageStart, pageEnd);
3832
+ let paginatedRowModel;
3832
3833
 
3833
3834
  if (!instance.options.paginateExpandedRows) {
3834
- return expandRows({
3835
+ paginatedRowModel = expandRows({
3835
3836
  rows,
3836
3837
  flatRows,
3837
3838
  rowsById
3838
3839
  });
3840
+ } else {
3841
+ paginatedRowModel = {
3842
+ rows,
3843
+ flatRows,
3844
+ rowsById
3845
+ };
3839
3846
  }
3840
3847
 
3841
- return {
3842
- rows,
3843
- flatRows,
3844
- rowsById
3848
+ paginatedRowModel.flatRows = [];
3849
+
3850
+ const handleRow = row => {
3851
+ paginatedRowModel.flatRows.push(row);
3852
+
3853
+ if (row.subRows.length) {
3854
+ row.subRows.forEach(handleRow);
3855
+ }
3845
3856
  };
3857
+
3858
+ paginatedRowModel.rows.forEach(handleRow);
3859
+ return paginatedRowModel;
3846
3860
  }, {
3847
3861
  key: process.env.NODE_ENV === 'development' && 'getPaginationRowModel',
3848
3862
  debug: () => {