@tanstack/table-core 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.
@@ -28,8 +28,8 @@ export declare type RowSelectionInstance<TGenerics extends TableGenerics> = {
28
28
  getIsAllPageRowsSelected: () => boolean;
29
29
  getIsSomeRowsSelected: () => boolean;
30
30
  getIsSomePageRowsSelected: () => boolean;
31
- toggleAllRowsSelected: (value: boolean) => void;
32
- toggleAllPageRowsSelected: (value: boolean) => void;
31
+ toggleAllRowsSelected: (value?: boolean) => void;
32
+ toggleAllPageRowsSelected: (value?: boolean) => void;
33
33
  getPreSelectedRowModel: () => RowModel<TGenerics>;
34
34
  getSelectedRowModel: () => RowModel<TGenerics>;
35
35
  getFilteredSelectedRowModel: () => RowModel<TGenerics>;
@@ -818,7 +818,6 @@
818
818
  getDefaultOptions: instance => {
819
819
  return {
820
820
  onExpandedChange: makeStateUpdater('expanded', instance),
821
- autoResetExpanded: true,
822
821
  paginateExpandedRows: true
823
822
  };
824
823
  },
@@ -827,6 +826,8 @@
827
826
  let queued = false;
828
827
  return {
829
828
  _autoResetExpanded: () => {
829
+ var _ref, _instance$options$aut;
830
+
830
831
  if (!registered) {
831
832
  instance._queue(() => {
832
833
  registered = true;
@@ -835,11 +836,7 @@
835
836
  return;
836
837
  }
837
838
 
838
- if (instance.options.autoResetAll === false) {
839
- return;
840
- }
841
-
842
- if (instance.options.autoResetAll === true || instance.options.autoResetExpanded) {
839
+ if ((_ref = (_instance$options$aut = instance.options.autoResetAll) != null ? _instance$options$aut : instance.options.autoResetExpanded) != null ? _ref : !instance.options.manualExpanding) {
843
840
  if (queued) return;
844
841
  queued = true;
845
842
 
@@ -903,7 +900,7 @@
903
900
  });
904
901
  return maxDepth;
905
902
  },
906
- getPreExpandedRowModel: () => instance.getGroupedRowModel(),
903
+ getPreExpandedRowModel: () => instance.getSortedRowModel(),
907
904
  getExpandedRowModel: () => {
908
905
  if (!instance._getExpandedRowModel && instance.options.getExpandedRowModel) {
909
906
  instance._getExpandedRowModel = instance.options.getExpandedRowModel(instance);
@@ -1504,7 +1501,7 @@
1504
1501
 
1505
1502
  instance.setGrouping(defaultState ? [] : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.grouping) != null ? _instance$initialStat : []);
1506
1503
  },
1507
- getPreGroupedRowModel: () => instance.getSortedRowModel(),
1504
+ getPreGroupedRowModel: () => instance.getFilteredRowModel(),
1508
1505
  getGroupedRowModel: () => {
1509
1506
  if (!instance._getGroupedRowModel && instance.options.getGroupedRowModel) {
1510
1507
  instance._getGroupedRowModel = instance.options.getGroupedRowModel(instance);
@@ -1537,7 +1534,7 @@
1537
1534
  getIsAggregated: () => {
1538
1535
  var _row$subRows;
1539
1536
 
1540
- return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
1537
+ return !cell.getIsGrouped() && !cell.getIsPlaceholder() && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
1541
1538
  },
1542
1539
  renderAggregatedCell: () => {
1543
1540
  {
@@ -2022,11 +2019,11 @@
2022
2019
  });
2023
2020
  },
2024
2021
  toggleAllPageRowsSelected: value => instance.setRowSelection(old => {
2025
- typeof value !== 'undefined' ? value : !instance.getIsAllPageRowsSelected();
2022
+ const resolvedValue = typeof value !== 'undefined' ? value : !instance.getIsAllPageRowsSelected();
2026
2023
  const rowSelection = { ...old
2027
2024
  };
2028
2025
  instance.getRowModel().rows.forEach(row => {
2029
- mutateRowIsSelected(rowSelection, row.id, value, instance);
2026
+ mutateRowIsSelected(rowSelection, row.id, resolvedValue, instance);
2030
2027
  });
2031
2028
  return rowSelection;
2032
2029
  }),
@@ -2117,7 +2114,7 @@
2117
2114
  return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugTable;
2118
2115
  }
2119
2116
  }),
2120
- getGroupedSelectedRowModel: memo(() => [instance.getState().rowSelection, instance.getGroupedRowModel()], (rowSelection, rowModel) => {
2117
+ getGroupedSelectedRowModel: memo(() => [instance.getState().rowSelection, instance.getSortedRowModel()], (rowSelection, rowModel) => {
2121
2118
  if (!Object.keys(rowSelection).length) {
2122
2119
  return {
2123
2120
  rows: [],
@@ -2181,7 +2178,7 @@
2181
2178
  },
2182
2179
  getIsSomePageRowsSelected: () => {
2183
2180
  const paginationFlatRows = instance.getPaginationRowModel().flatRows;
2184
- return instance.getIsAllPageRowsSelected() ? false : !!(paginationFlatRows != null && paginationFlatRows.length);
2181
+ return instance.getIsAllPageRowsSelected() ? false : paginationFlatRows.some(d => d.getIsSelected() || d.getIsSomeSelected());
2185
2182
  },
2186
2183
  getToggleAllRowsSelectedHandler: () => {
2187
2184
  return e => {
@@ -2667,7 +2664,7 @@
2667
2664
 
2668
2665
  instance.setSorting(defaultState ? [] : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.sorting) != null ? _instance$initialStat : []);
2669
2666
  },
2670
- getPreSortedRowModel: () => instance.getFilteredRowModel(),
2667
+ getPreSortedRowModel: () => instance.getGroupedRowModel(),
2671
2668
  getSortedRowModel: () => {
2672
2669
  if (!instance._getSortedRowModel && instance.options.getSortedRowModel) {
2673
2670
  instance._getSortedRowModel = instance.options.getSortedRowModel(instance);
@@ -3817,20 +3814,34 @@
3817
3814
  const pageStart = pageSize * pageIndex;
3818
3815
  const pageEnd = pageStart + pageSize;
3819
3816
  rows = rows.slice(pageStart, pageEnd);
3817
+ let paginatedRowModel;
3820
3818
 
3821
3819
  if (!instance.options.paginateExpandedRows) {
3822
- return expandRows({
3820
+ paginatedRowModel = expandRows({
3823
3821
  rows,
3824
3822
  flatRows,
3825
3823
  rowsById
3826
3824
  });
3825
+ } else {
3826
+ paginatedRowModel = {
3827
+ rows,
3828
+ flatRows,
3829
+ rowsById
3830
+ };
3827
3831
  }
3828
3832
 
3829
- return {
3830
- rows,
3831
- flatRows,
3832
- rowsById
3833
+ paginatedRowModel.flatRows = [];
3834
+
3835
+ const handleRow = row => {
3836
+ paginatedRowModel.flatRows.push(row);
3837
+
3838
+ if (row.subRows.length) {
3839
+ row.subRows.forEach(handleRow);
3840
+ }
3833
3841
  };
3842
+
3843
+ paginatedRowModel.rows.forEach(handleRow);
3844
+ return paginatedRowModel;
3834
3845
  }, {
3835
3846
  key: 'getPaginationRowModel',
3836
3847
  debug: () => {