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