@tanstack/react-table 8.0.0-beta.4 → 8.0.0-beta.7

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.
@@ -828,7 +828,6 @@ const Expanding = {
828
828
  getDefaultOptions: instance => {
829
829
  return {
830
830
  onExpandedChange: makeStateUpdater('expanded', instance),
831
- autoResetExpanded: true,
832
831
  paginateExpandedRows: true
833
832
  };
834
833
  },
@@ -837,6 +836,8 @@ const Expanding = {
837
836
  let queued = false;
838
837
  return {
839
838
  _autoResetExpanded: () => {
839
+ var _ref, _instance$options$aut;
840
+
840
841
  if (!registered) {
841
842
  instance._queue(() => {
842
843
  registered = true;
@@ -845,11 +846,7 @@ const Expanding = {
845
846
  return;
846
847
  }
847
848
 
848
- if (instance.options.autoResetAll === false) {
849
- return;
850
- }
851
-
852
- if (instance.options.autoResetAll === true || instance.options.autoResetExpanded) {
849
+ if ((_ref = (_instance$options$aut = instance.options.autoResetAll) != null ? _instance$options$aut : instance.options.autoResetExpanded) != null ? _ref : !instance.options.manualExpanding) {
853
850
  if (queued) return;
854
851
  queued = true;
855
852
 
@@ -913,7 +910,7 @@ const Expanding = {
913
910
  });
914
911
  return maxDepth;
915
912
  },
916
- getPreExpandedRowModel: () => instance.getGroupedRowModel(),
913
+ getPreExpandedRowModel: () => instance.getSortedRowModel(),
917
914
  getExpandedRowModel: () => {
918
915
  if (!instance._getExpandedRowModel && instance.options.getExpandedRowModel) {
919
916
  instance._getExpandedRowModel = instance.options.getExpandedRowModel(instance);
@@ -1514,7 +1511,7 @@ const Grouping = {
1514
1511
 
1515
1512
  instance.setGrouping(defaultState ? [] : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.grouping) != null ? _instance$initialStat : []);
1516
1513
  },
1517
- getPreGroupedRowModel: () => instance.getSortedRowModel(),
1514
+ getPreGroupedRowModel: () => instance.getFilteredRowModel(),
1518
1515
  getGroupedRowModel: () => {
1519
1516
  if (!instance._getGroupedRowModel && instance.options.getGroupedRowModel) {
1520
1517
  instance._getGroupedRowModel = instance.options.getGroupedRowModel(instance);
@@ -1547,7 +1544,7 @@ const Grouping = {
1547
1544
  getIsAggregated: () => {
1548
1545
  var _row$subRows;
1549
1546
 
1550
- return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
1547
+ return !cell.getIsGrouped() && !cell.getIsPlaceholder() && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
1551
1548
  },
1552
1549
  renderAggregatedCell: () => {
1553
1550
  if (process.env.NODE_ENV === 'development') {
@@ -2032,11 +2029,11 @@ const RowSelection = {
2032
2029
  });
2033
2030
  },
2034
2031
  toggleAllPageRowsSelected: value => instance.setRowSelection(old => {
2035
- typeof value !== 'undefined' ? value : !instance.getIsAllPageRowsSelected();
2032
+ const resolvedValue = typeof value !== 'undefined' ? value : !instance.getIsAllPageRowsSelected();
2036
2033
  const rowSelection = { ...old
2037
2034
  };
2038
2035
  instance.getRowModel().rows.forEach(row => {
2039
- mutateRowIsSelected(rowSelection, row.id, value, instance);
2036
+ mutateRowIsSelected(rowSelection, row.id, resolvedValue, instance);
2040
2037
  });
2041
2038
  return rowSelection;
2042
2039
  }),
@@ -2127,7 +2124,7 @@ const RowSelection = {
2127
2124
  return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugTable;
2128
2125
  }
2129
2126
  }),
2130
- getGroupedSelectedRowModel: memo(() => [instance.getState().rowSelection, instance.getGroupedRowModel()], (rowSelection, rowModel) => {
2127
+ getGroupedSelectedRowModel: memo(() => [instance.getState().rowSelection, instance.getSortedRowModel()], (rowSelection, rowModel) => {
2131
2128
  if (!Object.keys(rowSelection).length) {
2132
2129
  return {
2133
2130
  rows: [],
@@ -2191,7 +2188,7 @@ const RowSelection = {
2191
2188
  },
2192
2189
  getIsSomePageRowsSelected: () => {
2193
2190
  const paginationFlatRows = instance.getPaginationRowModel().flatRows;
2194
- return instance.getIsAllPageRowsSelected() ? false : !!(paginationFlatRows != null && paginationFlatRows.length);
2191
+ return instance.getIsAllPageRowsSelected() ? false : paginationFlatRows.some(d => d.getIsSelected() || d.getIsSomeSelected());
2195
2192
  },
2196
2193
  getToggleAllRowsSelectedHandler: () => {
2197
2194
  return e => {
@@ -2677,7 +2674,7 @@ const Sorting = {
2677
2674
 
2678
2675
  instance.setSorting(defaultState ? [] : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.sorting) != null ? _instance$initialStat : []);
2679
2676
  },
2680
- getPreSortedRowModel: () => instance.getFilteredRowModel(),
2677
+ getPreSortedRowModel: () => instance.getGroupedRowModel(),
2681
2678
  getSortedRowModel: () => {
2682
2679
  if (!instance._getSortedRowModel && instance.options.getSortedRowModel) {
2683
2680
  instance._getSortedRowModel = instance.options.getSortedRowModel(instance);
@@ -3829,20 +3826,34 @@ function getPaginationRowModel(opts) {
3829
3826
  const pageStart = pageSize * pageIndex;
3830
3827
  const pageEnd = pageStart + pageSize;
3831
3828
  rows = rows.slice(pageStart, pageEnd);
3829
+ let paginatedRowModel;
3832
3830
 
3833
3831
  if (!instance.options.paginateExpandedRows) {
3834
- return expandRows({
3832
+ paginatedRowModel = expandRows({
3835
3833
  rows,
3836
3834
  flatRows,
3837
3835
  rowsById
3838
3836
  });
3837
+ } else {
3838
+ paginatedRowModel = {
3839
+ rows,
3840
+ flatRows,
3841
+ rowsById
3842
+ };
3839
3843
  }
3840
3844
 
3841
- return {
3842
- rows,
3843
- flatRows,
3844
- rowsById
3845
+ paginatedRowModel.flatRows = [];
3846
+
3847
+ const handleRow = row => {
3848
+ paginatedRowModel.flatRows.push(row);
3849
+
3850
+ if (row.subRows.length) {
3851
+ row.subRows.forEach(handleRow);
3852
+ }
3845
3853
  };
3854
+
3855
+ paginatedRowModel.rows.forEach(handleRow);
3856
+ return paginatedRowModel;
3846
3857
  }, {
3847
3858
  key: process.env.NODE_ENV === 'development' && 'getPaginationRowModel',
3848
3859
  debug: () => {