@tanstack/react-table 8.0.0-beta.8 → 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.
@@ -981,38 +981,54 @@ const Expanding = {
981
981
  };
982
982
 
983
983
  const includesString = (row, columnId, filterValue) => {
984
+ var _row$getValue;
985
+
984
986
  const search = filterValue.toLowerCase();
985
- return row.getValue(columnId).toLowerCase().includes(search);
987
+ return (_row$getValue = row.getValue(columnId)) == null ? void 0 : _row$getValue.toLowerCase().includes(search);
986
988
  };
987
989
 
988
990
  includesString.autoRemove = val => testFalsey(val);
989
991
 
990
992
  const includesStringSensitive = (row, columnId, filterValue) => {
991
- return row.getValue(columnId).includes(filterValue);
993
+ var _row$getValue2;
994
+
995
+ return (_row$getValue2 = row.getValue(columnId)) == null ? void 0 : _row$getValue2.includes(filterValue);
992
996
  };
993
997
 
994
998
  includesStringSensitive.autoRemove = val => testFalsey(val);
995
999
 
996
1000
  const equalsString = (row, columnId, filterValue) => {
997
- return row.getValue(columnId).toLowerCase() === filterValue.toLowerCase();
1001
+ var _row$getValue3;
1002
+
1003
+ return ((_row$getValue3 = row.getValue(columnId)) == null ? void 0 : _row$getValue3.toLowerCase()) === filterValue.toLowerCase();
998
1004
  };
999
1005
 
1000
1006
  equalsString.autoRemove = val => testFalsey(val);
1001
1007
 
1002
1008
  const arrIncludes = (row, columnId, filterValue) => {
1003
- return row.getValue(columnId).includes(filterValue);
1009
+ var _row$getValue4;
1010
+
1011
+ return (_row$getValue4 = row.getValue(columnId)) == null ? void 0 : _row$getValue4.includes(filterValue);
1004
1012
  };
1005
1013
 
1006
1014
  arrIncludes.autoRemove = val => testFalsey(val) || !(val != null && val.length);
1007
1015
 
1008
1016
  const arrIncludesAll = (row, columnId, filterValue) => {
1009
- return !filterValue.some(val => !row.getValue(columnId).includes(val));
1017
+ return !filterValue.some(val => {
1018
+ var _row$getValue5;
1019
+
1020
+ return !((_row$getValue5 = row.getValue(columnId)) != null && _row$getValue5.includes(val));
1021
+ });
1010
1022
  };
1011
1023
 
1012
1024
  arrIncludesAll.autoRemove = val => testFalsey(val) || !(val != null && val.length);
1013
1025
 
1014
1026
  const arrIncludesSome = (row, columnId, filterValue) => {
1015
- return filterValue.some(val => row.getValue(columnId).includes(val));
1027
+ return filterValue.some(val => {
1028
+ var _row$getValue6;
1029
+
1030
+ return (_row$getValue6 = row.getValue(columnId)) == null ? void 0 : _row$getValue6.includes(val);
1031
+ });
1016
1032
  };
1017
1033
 
1018
1034
  arrIncludesSome.autoRemove = val => testFalsey(val) || !(val != null && val.length);
@@ -1317,7 +1333,10 @@ function shouldAutoRemoveFilter(filterFn, value, column) {
1317
1333
  const sum = (columnId, _leafRows, childRows) => {
1318
1334
  // It's faster to just add the aggregations together instead of
1319
1335
  // process leaf nodes individually
1320
- return childRows.reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
1336
+ return childRows.reduce((sum, next) => {
1337
+ const nextValue = next.getValue(columnId);
1338
+ return sum + (typeof nextValue === 'number' ? nextValue : 0);
1339
+ }, 0);
1321
1340
  };
1322
1341
 
1323
1342
  const min = (columnId, _leafRows, childRows) => {
@@ -1697,7 +1716,7 @@ const Pagination = {
1697
1716
  setPageIndex: updater => {
1698
1717
  instance.setPagination(old => {
1699
1718
  let pageIndex = functionalUpdate(updater, old.pageIndex);
1700
- const maxPageIndex = typeof instance.options.pageCount !== 'undefined' ? instance.options.pageCount - 1 : Number.MAX_SAFE_INTEGER;
1719
+ const maxPageIndex = typeof instance.options.pageCount === 'undefined' || instance.options.pageCount === -1 ? Number.MAX_SAFE_INTEGER : instance.options.pageCount - 1;
1701
1720
  pageIndex = Math.min(Math.max(0, pageIndex), maxPageIndex);
1702
1721
  return { ...old,
1703
1722
  pageIndex
@@ -2290,9 +2309,6 @@ function selectRowsFn(instance, rowModel) {
2290
2309
  const newSelectedRowsById = {}; // Filters top level and nested rows
2291
2310
 
2292
2311
  const recurseRows = function (rows, depth) {
2293
- if (depth === void 0) {
2294
- depth = 0;
2295
- }
2296
2312
 
2297
2313
  return rows.map(row => {
2298
2314
  var _row$subRows2;
@@ -2306,7 +2322,7 @@ function selectRowsFn(instance, rowModel) {
2306
2322
 
2307
2323
  if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
2308
2324
  row = { ...row,
2309
- subRows: recurseRows(row.subRows, depth + 1)
2325
+ subRows: recurseRows(row.subRows)
2310
2326
  };
2311
2327
  }
2312
2328
 
@@ -3229,25 +3245,20 @@ function filterRows(rows, filterRowImpl, instance) {
3229
3245
  function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
3230
3246
  const newFilteredFlatRows = [];
3231
3247
  const newFilteredRowsById = {};
3232
- let row;
3233
- let newRow;
3234
3248
 
3235
3249
  const recurseFilterRows = function (rowsToFilter, depth) {
3236
- if (depth === void 0) {
3237
- depth = 0;
3238
- }
3239
3250
 
3240
3251
  const rows = []; // Filter from children up first
3241
3252
 
3242
3253
  for (let i = 0; i < rowsToFilter.length; i++) {
3243
3254
  var _row$subRows;
3244
3255
 
3245
- row = rowsToFilter[i];
3256
+ let row = rowsToFilter[i];
3246
3257
 
3247
3258
  if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
3248
- newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3259
+ const newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3249
3260
  newRow.columnFilters = row.columnFilters;
3250
- newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3261
+ newRow.subRows = recurseFilterRows(row.subRows);
3251
3262
 
3252
3263
  if (!newRow.subRows.length) {
3253
3264
  continue;
@@ -3274,29 +3285,23 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
3274
3285
  }
3275
3286
  function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
3276
3287
  const newFilteredFlatRows = [];
3277
- const newFilteredRowsById = {};
3278
- let rows;
3279
- let row;
3280
- let newRow; // Filters top level and nested rows
3288
+ const newFilteredRowsById = {}; // Filters top level and nested rows
3281
3289
 
3282
3290
  const recurseFilterRows = function (rowsToFilter, depth) {
3283
- if (depth === void 0) {
3284
- depth = 0;
3285
- }
3286
3291
 
3287
3292
  // Filter from parents downward first
3288
- rows = []; // Apply the filter to any subRows
3293
+ const rows = []; // Apply the filter to any subRows
3289
3294
 
3290
3295
  for (let i = 0; i < rowsToFilter.length; i++) {
3291
- row = rowsToFilter[i];
3296
+ let row = rowsToFilter[i];
3292
3297
  const pass = filterRow(row);
3293
3298
 
3294
3299
  if (pass) {
3295
3300
  var _row$subRows2;
3296
3301
 
3297
3302
  if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
3298
- newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3299
- newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3303
+ const newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3304
+ newRow.subRows = recurseFilterRows(row.subRows);
3300
3305
  row = newRow;
3301
3306
  }
3302
3307