@tanstack/react-table 8.0.0-beta.6 → 8.0.0-beta.9

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);
@@ -1542,7 +1558,7 @@ const Grouping = {
1542
1558
  getIsAggregated: () => {
1543
1559
  var _row$subRows;
1544
1560
 
1545
- return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
1561
+ return !cell.getIsGrouped() && !cell.getIsPlaceholder() && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
1546
1562
  },
1547
1563
  renderAggregatedCell: () => {
1548
1564
  if (process.env.NODE_ENV === 'development') {
@@ -1697,7 +1713,7 @@ const Pagination = {
1697
1713
  setPageIndex: updater => {
1698
1714
  instance.setPagination(old => {
1699
1715
  let pageIndex = functionalUpdate(updater, old.pageIndex);
1700
- const maxPageIndex = typeof old.pageCount !== 'undefined' ? old.pageCount - 1 : Number.MAX_SAFE_INTEGER;
1716
+ const maxPageIndex = typeof instance.options.pageCount === 'undefined' || instance.options.pageCount === -1 ? Number.MAX_SAFE_INTEGER : instance.options.pageCount - 1;
1701
1717
  pageIndex = Math.min(Math.max(0, pageIndex), maxPageIndex);
1702
1718
  return { ...old,
1703
1719
  pageIndex
@@ -1726,9 +1742,9 @@ const Pagination = {
1726
1742
  });
1727
1743
  },
1728
1744
  setPageCount: updater => instance.setPagination(old => {
1729
- var _old$pageCount;
1745
+ var _instance$options$pag;
1730
1746
 
1731
- let newPageCount = functionalUpdate(updater, (_old$pageCount = old.pageCount) != null ? _old$pageCount : -1);
1747
+ let newPageCount = functionalUpdate(updater, (_instance$options$pag = instance.options.pageCount) != null ? _instance$options$pag : -1);
1732
1748
 
1733
1749
  if (typeof newPageCount === 'number') {
1734
1750
  newPageCount = Math.max(-1, newPageCount);
@@ -1738,7 +1754,7 @@ const Pagination = {
1738
1754
  pageCount: newPageCount
1739
1755
  };
1740
1756
  }),
1741
- getPageOptions: memo(() => [instance.getState().pagination.pageSize, instance.getState().pagination.pageCount], (pageSize, pageCount) => {
1757
+ getPageOptions: memo(() => [instance.getPageCount()], pageCount => {
1742
1758
  let pageOptions = [];
1743
1759
 
1744
1760
  if (pageCount && pageCount > 0) {
@@ -1792,15 +1808,9 @@ const Pagination = {
1792
1808
  return instance._getPaginationRowModel();
1793
1809
  },
1794
1810
  getPageCount: () => {
1795
- const {
1796
- pageCount
1797
- } = instance.getState().pagination;
1811
+ var _instance$options$pag2;
1798
1812
 
1799
- if (typeof pageCount !== 'undefined') {
1800
- return pageCount;
1801
- }
1802
-
1803
- return Math.ceil(instance.getPrePaginationRowModel().rows.length / instance.getState().pagination.pageSize);
1813
+ return (_instance$options$pag2 = instance.options.pageCount) != null ? _instance$options$pag2 : Math.ceil(instance.getPrePaginationRowModel().rows.length / instance.getState().pagination.pageSize);
1804
1814
  }
1805
1815
  };
1806
1816
  }
@@ -3235,8 +3245,6 @@ function filterRows(rows, filterRowImpl, instance) {
3235
3245
  function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
3236
3246
  const newFilteredFlatRows = [];
3237
3247
  const newFilteredRowsById = {};
3238
- let row;
3239
- let newRow;
3240
3248
 
3241
3249
  const recurseFilterRows = function (rowsToFilter, depth) {
3242
3250
  if (depth === void 0) {
@@ -3248,10 +3256,10 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
3248
3256
  for (let i = 0; i < rowsToFilter.length; i++) {
3249
3257
  var _row$subRows;
3250
3258
 
3251
- row = rowsToFilter[i];
3259
+ let row = rowsToFilter[i];
3252
3260
 
3253
3261
  if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
3254
- newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3262
+ const newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3255
3263
  newRow.columnFilters = row.columnFilters;
3256
3264
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3257
3265
 
@@ -3280,10 +3288,7 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
3280
3288
  }
3281
3289
  function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
3282
3290
  const newFilteredFlatRows = [];
3283
- const newFilteredRowsById = {};
3284
- let rows;
3285
- let row;
3286
- let newRow; // Filters top level and nested rows
3291
+ const newFilteredRowsById = {}; // Filters top level and nested rows
3287
3292
 
3288
3293
  const recurseFilterRows = function (rowsToFilter, depth) {
3289
3294
  if (depth === void 0) {
@@ -3291,17 +3296,17 @@ function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
3291
3296
  }
3292
3297
 
3293
3298
  // Filter from parents downward first
3294
- rows = []; // Apply the filter to any subRows
3299
+ const rows = []; // Apply the filter to any subRows
3295
3300
 
3296
3301
  for (let i = 0; i < rowsToFilter.length; i++) {
3297
- row = rowsToFilter[i];
3302
+ let row = rowsToFilter[i];
3298
3303
  const pass = filterRow(row);
3299
3304
 
3300
3305
  if (pass) {
3301
3306
  var _row$subRows2;
3302
3307
 
3303
3308
  if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
3304
- newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3309
+ const newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3305
3310
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3306
3311
  row = newRow;
3307
3312
  }