@tanstack/svelte-table 8.0.0-beta.7 → 8.0.3

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.
@@ -982,38 +982,54 @@ const Expanding = {
982
982
  };
983
983
 
984
984
  const includesString = (row, columnId, filterValue) => {
985
+ var _row$getValue;
986
+
985
987
  const search = filterValue.toLowerCase();
986
- return row.getValue(columnId).toLowerCase().includes(search);
988
+ return (_row$getValue = row.getValue(columnId)) == null ? void 0 : _row$getValue.toLowerCase().includes(search);
987
989
  };
988
990
 
989
991
  includesString.autoRemove = val => testFalsey(val);
990
992
 
991
993
  const includesStringSensitive = (row, columnId, filterValue) => {
992
- return row.getValue(columnId).includes(filterValue);
994
+ var _row$getValue2;
995
+
996
+ return (_row$getValue2 = row.getValue(columnId)) == null ? void 0 : _row$getValue2.includes(filterValue);
993
997
  };
994
998
 
995
999
  includesStringSensitive.autoRemove = val => testFalsey(val);
996
1000
 
997
1001
  const equalsString = (row, columnId, filterValue) => {
998
- return row.getValue(columnId).toLowerCase() === filterValue.toLowerCase();
1002
+ var _row$getValue3;
1003
+
1004
+ return ((_row$getValue3 = row.getValue(columnId)) == null ? void 0 : _row$getValue3.toLowerCase()) === filterValue.toLowerCase();
999
1005
  };
1000
1006
 
1001
1007
  equalsString.autoRemove = val => testFalsey(val);
1002
1008
 
1003
1009
  const arrIncludes = (row, columnId, filterValue) => {
1004
- return row.getValue(columnId).includes(filterValue);
1010
+ var _row$getValue4;
1011
+
1012
+ return (_row$getValue4 = row.getValue(columnId)) == null ? void 0 : _row$getValue4.includes(filterValue);
1005
1013
  };
1006
1014
 
1007
1015
  arrIncludes.autoRemove = val => testFalsey(val) || !(val != null && val.length);
1008
1016
 
1009
1017
  const arrIncludesAll = (row, columnId, filterValue) => {
1010
- return !filterValue.some(val => !row.getValue(columnId).includes(val));
1018
+ return !filterValue.some(val => {
1019
+ var _row$getValue5;
1020
+
1021
+ return !((_row$getValue5 = row.getValue(columnId)) != null && _row$getValue5.includes(val));
1022
+ });
1011
1023
  };
1012
1024
 
1013
1025
  arrIncludesAll.autoRemove = val => testFalsey(val) || !(val != null && val.length);
1014
1026
 
1015
1027
  const arrIncludesSome = (row, columnId, filterValue) => {
1016
- return filterValue.some(val => row.getValue(columnId).includes(val));
1028
+ return filterValue.some(val => {
1029
+ var _row$getValue6;
1030
+
1031
+ return (_row$getValue6 = row.getValue(columnId)) == null ? void 0 : _row$getValue6.includes(val);
1032
+ });
1017
1033
  };
1018
1034
 
1019
1035
  arrIncludesSome.autoRemove = val => testFalsey(val) || !(val != null && val.length);
@@ -1318,7 +1334,10 @@ function shouldAutoRemoveFilter(filterFn, value, column) {
1318
1334
  const sum = (columnId, _leafRows, childRows) => {
1319
1335
  // It's faster to just add the aggregations together instead of
1320
1336
  // process leaf nodes individually
1321
- return childRows.reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
1337
+ return childRows.reduce((sum, next) => {
1338
+ const nextValue = next.getValue(columnId);
1339
+ return sum + (typeof nextValue === 'number' ? nextValue : 0);
1340
+ }, 0);
1322
1341
  };
1323
1342
 
1324
1343
  const min = (columnId, _leafRows, childRows) => {
@@ -1698,7 +1717,7 @@ const Pagination = {
1698
1717
  setPageIndex: updater => {
1699
1718
  instance.setPagination(old => {
1700
1719
  let pageIndex = functionalUpdate(updater, old.pageIndex);
1701
- const maxPageIndex = typeof old.pageCount !== 'undefined' ? old.pageCount - 1 : Number.MAX_SAFE_INTEGER;
1720
+ const maxPageIndex = typeof instance.options.pageCount === 'undefined' || instance.options.pageCount === -1 ? Number.MAX_SAFE_INTEGER : instance.options.pageCount - 1;
1702
1721
  pageIndex = Math.min(Math.max(0, pageIndex), maxPageIndex);
1703
1722
  return { ...old,
1704
1723
  pageIndex
@@ -1727,9 +1746,9 @@ const Pagination = {
1727
1746
  });
1728
1747
  },
1729
1748
  setPageCount: updater => instance.setPagination(old => {
1730
- var _old$pageCount;
1749
+ var _instance$options$pag;
1731
1750
 
1732
- let newPageCount = functionalUpdate(updater, (_old$pageCount = old.pageCount) != null ? _old$pageCount : -1);
1751
+ let newPageCount = functionalUpdate(updater, (_instance$options$pag = instance.options.pageCount) != null ? _instance$options$pag : -1);
1733
1752
 
1734
1753
  if (typeof newPageCount === 'number') {
1735
1754
  newPageCount = Math.max(-1, newPageCount);
@@ -1739,7 +1758,7 @@ const Pagination = {
1739
1758
  pageCount: newPageCount
1740
1759
  };
1741
1760
  }),
1742
- getPageOptions: memo(() => [instance.getState().pagination.pageSize, instance.getState().pagination.pageCount], (pageSize, pageCount) => {
1761
+ getPageOptions: memo(() => [instance.getPageCount()], pageCount => {
1743
1762
  let pageOptions = [];
1744
1763
 
1745
1764
  if (pageCount && pageCount > 0) {
@@ -1793,15 +1812,9 @@ const Pagination = {
1793
1812
  return instance._getPaginationRowModel();
1794
1813
  },
1795
1814
  getPageCount: () => {
1796
- const {
1797
- pageCount
1798
- } = instance.getState().pagination;
1815
+ var _instance$options$pag2;
1799
1816
 
1800
- if (typeof pageCount !== 'undefined') {
1801
- return pageCount;
1802
- }
1803
-
1804
- return Math.ceil(instance.getPrePaginationRowModel().rows.length / instance.getState().pagination.pageSize);
1817
+ return (_instance$options$pag2 = instance.options.pageCount) != null ? _instance$options$pag2 : Math.ceil(instance.getPrePaginationRowModel().rows.length / instance.getState().pagination.pageSize);
1805
1818
  }
1806
1819
  };
1807
1820
  }
@@ -2297,9 +2310,6 @@ function selectRowsFn(instance, rowModel) {
2297
2310
  const newSelectedRowsById = {}; // Filters top level and nested rows
2298
2311
 
2299
2312
  const recurseRows = function (rows, depth) {
2300
- if (depth === void 0) {
2301
- depth = 0;
2302
- }
2303
2313
 
2304
2314
  return rows.map(row => {
2305
2315
  var _row$subRows2;
@@ -2313,7 +2323,7 @@ function selectRowsFn(instance, rowModel) {
2313
2323
 
2314
2324
  if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
2315
2325
  row = { ...row,
2316
- subRows: recurseRows(row.subRows, depth + 1)
2326
+ subRows: recurseRows(row.subRows)
2317
2327
  };
2318
2328
  }
2319
2329
 
@@ -3236,25 +3246,20 @@ function filterRows(rows, filterRowImpl, instance) {
3236
3246
  function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
3237
3247
  const newFilteredFlatRows = [];
3238
3248
  const newFilteredRowsById = {};
3239
- let row;
3240
- let newRow;
3241
3249
 
3242
3250
  const recurseFilterRows = function (rowsToFilter, depth) {
3243
- if (depth === void 0) {
3244
- depth = 0;
3245
- }
3246
3251
 
3247
3252
  const rows = []; // Filter from children up first
3248
3253
 
3249
3254
  for (let i = 0; i < rowsToFilter.length; i++) {
3250
3255
  var _row$subRows;
3251
3256
 
3252
- row = rowsToFilter[i];
3257
+ let row = rowsToFilter[i];
3253
3258
 
3254
3259
  if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
3255
- newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3260
+ const newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3256
3261
  newRow.columnFilters = row.columnFilters;
3257
- newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3262
+ newRow.subRows = recurseFilterRows(row.subRows);
3258
3263
 
3259
3264
  if (!newRow.subRows.length) {
3260
3265
  continue;
@@ -3281,29 +3286,23 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
3281
3286
  }
3282
3287
  function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
3283
3288
  const newFilteredFlatRows = [];
3284
- const newFilteredRowsById = {};
3285
- let rows;
3286
- let row;
3287
- let newRow; // Filters top level and nested rows
3289
+ const newFilteredRowsById = {}; // Filters top level and nested rows
3288
3290
 
3289
3291
  const recurseFilterRows = function (rowsToFilter, depth) {
3290
- if (depth === void 0) {
3291
- depth = 0;
3292
- }
3293
3292
 
3294
3293
  // Filter from parents downward first
3295
- rows = []; // Apply the filter to any subRows
3294
+ const rows = []; // Apply the filter to any subRows
3296
3295
 
3297
3296
  for (let i = 0; i < rowsToFilter.length; i++) {
3298
- row = rowsToFilter[i];
3297
+ let row = rowsToFilter[i];
3299
3298
  const pass = filterRow(row);
3300
3299
 
3301
3300
  if (pass) {
3302
3301
  var _row$subRows2;
3303
3302
 
3304
3303
  if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
3305
- newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3306
- newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3304
+ const newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3305
+ newRow.subRows = recurseFilterRows(row.subRows);
3307
3306
  row = newRow;
3308
3307
  }
3309
3308