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