@tanstack/svelte-table 8.0.0-beta.8 → 8.0.4

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 instance.options.pageCount !== 'undefined' ? instance.options.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
@@ -2291,9 +2310,6 @@ function selectRowsFn(instance, rowModel) {
2291
2310
  const newSelectedRowsById = {}; // Filters top level and nested rows
2292
2311
 
2293
2312
  const recurseRows = function (rows, depth) {
2294
- if (depth === void 0) {
2295
- depth = 0;
2296
- }
2297
2313
 
2298
2314
  return rows.map(row => {
2299
2315
  var _row$subRows2;
@@ -2307,7 +2323,7 @@ function selectRowsFn(instance, rowModel) {
2307
2323
 
2308
2324
  if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
2309
2325
  row = { ...row,
2310
- subRows: recurseRows(row.subRows, depth + 1)
2326
+ subRows: recurseRows(row.subRows)
2311
2327
  };
2312
2328
  }
2313
2329
 
@@ -3230,25 +3246,20 @@ function filterRows(rows, filterRowImpl, instance) {
3230
3246
  function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
3231
3247
  const newFilteredFlatRows = [];
3232
3248
  const newFilteredRowsById = {};
3233
- let row;
3234
- let newRow;
3235
3249
 
3236
3250
  const recurseFilterRows = function (rowsToFilter, depth) {
3237
- if (depth === void 0) {
3238
- depth = 0;
3239
- }
3240
3251
 
3241
3252
  const rows = []; // Filter from children up first
3242
3253
 
3243
3254
  for (let i = 0; i < rowsToFilter.length; i++) {
3244
3255
  var _row$subRows;
3245
3256
 
3246
- row = rowsToFilter[i];
3257
+ let row = rowsToFilter[i];
3247
3258
 
3248
3259
  if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
3249
- newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3260
+ const newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3250
3261
  newRow.columnFilters = row.columnFilters;
3251
- newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3262
+ newRow.subRows = recurseFilterRows(row.subRows);
3252
3263
 
3253
3264
  if (!newRow.subRows.length) {
3254
3265
  continue;
@@ -3275,29 +3286,23 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
3275
3286
  }
3276
3287
  function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
3277
3288
  const newFilteredFlatRows = [];
3278
- const newFilteredRowsById = {};
3279
- let rows;
3280
- let row;
3281
- let newRow; // Filters top level and nested rows
3289
+ const newFilteredRowsById = {}; // Filters top level and nested rows
3282
3290
 
3283
3291
  const recurseFilterRows = function (rowsToFilter, depth) {
3284
- if (depth === void 0) {
3285
- depth = 0;
3286
- }
3287
3292
 
3288
3293
  // Filter from parents downward first
3289
- rows = []; // Apply the filter to any subRows
3294
+ const rows = []; // Apply the filter to any subRows
3290
3295
 
3291
3296
  for (let i = 0; i < rowsToFilter.length; i++) {
3292
- row = rowsToFilter[i];
3297
+ let row = rowsToFilter[i];
3293
3298
  const pass = filterRow(row);
3294
3299
 
3295
3300
  if (pass) {
3296
3301
  var _row$subRows2;
3297
3302
 
3298
3303
  if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
3299
- newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3300
- 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);
3301
3306
  row = newRow;
3302
3307
  }
3303
3308