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