@tanstack/react-table 8.0.0-beta.7 → 8.0.0
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.
- package/build/cjs/table-core/build/esm/index.js +38 -30
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +38 -30
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +17 -17
- package/build/umd/index.development.js +38 -30
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
|
@@ -983,38 +983,54 @@ const Expanding = {
|
|
|
983
983
|
};
|
|
984
984
|
|
|
985
985
|
const includesString = (row, columnId, filterValue) => {
|
|
986
|
+
var _row$getValue;
|
|
987
|
+
|
|
986
988
|
const search = filterValue.toLowerCase();
|
|
987
|
-
return row.getValue(columnId).toLowerCase().includes(search);
|
|
989
|
+
return (_row$getValue = row.getValue(columnId)) == null ? void 0 : _row$getValue.toLowerCase().includes(search);
|
|
988
990
|
};
|
|
989
991
|
|
|
990
992
|
includesString.autoRemove = val => testFalsey(val);
|
|
991
993
|
|
|
992
994
|
const includesStringSensitive = (row, columnId, filterValue) => {
|
|
993
|
-
|
|
995
|
+
var _row$getValue2;
|
|
996
|
+
|
|
997
|
+
return (_row$getValue2 = row.getValue(columnId)) == null ? void 0 : _row$getValue2.includes(filterValue);
|
|
994
998
|
};
|
|
995
999
|
|
|
996
1000
|
includesStringSensitive.autoRemove = val => testFalsey(val);
|
|
997
1001
|
|
|
998
1002
|
const equalsString = (row, columnId, filterValue) => {
|
|
999
|
-
|
|
1003
|
+
var _row$getValue3;
|
|
1004
|
+
|
|
1005
|
+
return ((_row$getValue3 = row.getValue(columnId)) == null ? void 0 : _row$getValue3.toLowerCase()) === filterValue.toLowerCase();
|
|
1000
1006
|
};
|
|
1001
1007
|
|
|
1002
1008
|
equalsString.autoRemove = val => testFalsey(val);
|
|
1003
1009
|
|
|
1004
1010
|
const arrIncludes = (row, columnId, filterValue) => {
|
|
1005
|
-
|
|
1011
|
+
var _row$getValue4;
|
|
1012
|
+
|
|
1013
|
+
return (_row$getValue4 = row.getValue(columnId)) == null ? void 0 : _row$getValue4.includes(filterValue);
|
|
1006
1014
|
};
|
|
1007
1015
|
|
|
1008
1016
|
arrIncludes.autoRemove = val => testFalsey(val) || !(val != null && val.length);
|
|
1009
1017
|
|
|
1010
1018
|
const arrIncludesAll = (row, columnId, filterValue) => {
|
|
1011
|
-
return !filterValue.some(val =>
|
|
1019
|
+
return !filterValue.some(val => {
|
|
1020
|
+
var _row$getValue5;
|
|
1021
|
+
|
|
1022
|
+
return !((_row$getValue5 = row.getValue(columnId)) != null && _row$getValue5.includes(val));
|
|
1023
|
+
});
|
|
1012
1024
|
};
|
|
1013
1025
|
|
|
1014
1026
|
arrIncludesAll.autoRemove = val => testFalsey(val) || !(val != null && val.length);
|
|
1015
1027
|
|
|
1016
1028
|
const arrIncludesSome = (row, columnId, filterValue) => {
|
|
1017
|
-
return filterValue.some(val =>
|
|
1029
|
+
return filterValue.some(val => {
|
|
1030
|
+
var _row$getValue6;
|
|
1031
|
+
|
|
1032
|
+
return (_row$getValue6 = row.getValue(columnId)) == null ? void 0 : _row$getValue6.includes(val);
|
|
1033
|
+
});
|
|
1018
1034
|
};
|
|
1019
1035
|
|
|
1020
1036
|
arrIncludesSome.autoRemove = val => testFalsey(val) || !(val != null && val.length);
|
|
@@ -1319,7 +1335,10 @@ function shouldAutoRemoveFilter(filterFn, value, column) {
|
|
|
1319
1335
|
const sum = (columnId, _leafRows, childRows) => {
|
|
1320
1336
|
// It's faster to just add the aggregations together instead of
|
|
1321
1337
|
// process leaf nodes individually
|
|
1322
|
-
return childRows.reduce((sum, next) =>
|
|
1338
|
+
return childRows.reduce((sum, next) => {
|
|
1339
|
+
const nextValue = next.getValue(columnId);
|
|
1340
|
+
return sum + (typeof nextValue === 'number' ? nextValue : 0);
|
|
1341
|
+
}, 0);
|
|
1323
1342
|
};
|
|
1324
1343
|
|
|
1325
1344
|
const min = (columnId, _leafRows, childRows) => {
|
|
@@ -1699,7 +1718,7 @@ const Pagination = {
|
|
|
1699
1718
|
setPageIndex: updater => {
|
|
1700
1719
|
instance.setPagination(old => {
|
|
1701
1720
|
let pageIndex = functionalUpdate(updater, old.pageIndex);
|
|
1702
|
-
const maxPageIndex = typeof
|
|
1721
|
+
const maxPageIndex = typeof instance.options.pageCount === 'undefined' || instance.options.pageCount === -1 ? Number.MAX_SAFE_INTEGER : instance.options.pageCount - 1;
|
|
1703
1722
|
pageIndex = Math.min(Math.max(0, pageIndex), maxPageIndex);
|
|
1704
1723
|
return { ...old,
|
|
1705
1724
|
pageIndex
|
|
@@ -1728,9 +1747,9 @@ const Pagination = {
|
|
|
1728
1747
|
});
|
|
1729
1748
|
},
|
|
1730
1749
|
setPageCount: updater => instance.setPagination(old => {
|
|
1731
|
-
var
|
|
1750
|
+
var _instance$options$pag;
|
|
1732
1751
|
|
|
1733
|
-
let newPageCount = functionalUpdate(updater, (
|
|
1752
|
+
let newPageCount = functionalUpdate(updater, (_instance$options$pag = instance.options.pageCount) != null ? _instance$options$pag : -1);
|
|
1734
1753
|
|
|
1735
1754
|
if (typeof newPageCount === 'number') {
|
|
1736
1755
|
newPageCount = Math.max(-1, newPageCount);
|
|
@@ -1740,7 +1759,7 @@ const Pagination = {
|
|
|
1740
1759
|
pageCount: newPageCount
|
|
1741
1760
|
};
|
|
1742
1761
|
}),
|
|
1743
|
-
getPageOptions: memo(() => [instance.
|
|
1762
|
+
getPageOptions: memo(() => [instance.getPageCount()], pageCount => {
|
|
1744
1763
|
let pageOptions = [];
|
|
1745
1764
|
|
|
1746
1765
|
if (pageCount && pageCount > 0) {
|
|
@@ -1794,15 +1813,9 @@ const Pagination = {
|
|
|
1794
1813
|
return instance._getPaginationRowModel();
|
|
1795
1814
|
},
|
|
1796
1815
|
getPageCount: () => {
|
|
1797
|
-
|
|
1798
|
-
pageCount
|
|
1799
|
-
} = instance.getState().pagination;
|
|
1816
|
+
var _instance$options$pag2;
|
|
1800
1817
|
|
|
1801
|
-
|
|
1802
|
-
return pageCount;
|
|
1803
|
-
}
|
|
1804
|
-
|
|
1805
|
-
return Math.ceil(instance.getPrePaginationRowModel().rows.length / instance.getState().pagination.pageSize);
|
|
1818
|
+
return (_instance$options$pag2 = instance.options.pageCount) != null ? _instance$options$pag2 : Math.ceil(instance.getPrePaginationRowModel().rows.length / instance.getState().pagination.pageSize);
|
|
1806
1819
|
}
|
|
1807
1820
|
};
|
|
1808
1821
|
}
|
|
@@ -3237,8 +3250,6 @@ function filterRows(rows, filterRowImpl, instance) {
|
|
|
3237
3250
|
function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
|
|
3238
3251
|
const newFilteredFlatRows = [];
|
|
3239
3252
|
const newFilteredRowsById = {};
|
|
3240
|
-
let row;
|
|
3241
|
-
let newRow;
|
|
3242
3253
|
|
|
3243
3254
|
const recurseFilterRows = function (rowsToFilter, depth) {
|
|
3244
3255
|
if (depth === void 0) {
|
|
@@ -3250,10 +3261,10 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
|
|
|
3250
3261
|
for (let i = 0; i < rowsToFilter.length; i++) {
|
|
3251
3262
|
var _row$subRows;
|
|
3252
3263
|
|
|
3253
|
-
row = rowsToFilter[i];
|
|
3264
|
+
let row = rowsToFilter[i];
|
|
3254
3265
|
|
|
3255
3266
|
if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
|
|
3256
|
-
newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3267
|
+
const newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3257
3268
|
newRow.columnFilters = row.columnFilters;
|
|
3258
3269
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3259
3270
|
|
|
@@ -3282,10 +3293,7 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
|
|
|
3282
3293
|
}
|
|
3283
3294
|
function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
|
|
3284
3295
|
const newFilteredFlatRows = [];
|
|
3285
|
-
const newFilteredRowsById = {};
|
|
3286
|
-
let rows;
|
|
3287
|
-
let row;
|
|
3288
|
-
let newRow; // Filters top level and nested rows
|
|
3296
|
+
const newFilteredRowsById = {}; // Filters top level and nested rows
|
|
3289
3297
|
|
|
3290
3298
|
const recurseFilterRows = function (rowsToFilter, depth) {
|
|
3291
3299
|
if (depth === void 0) {
|
|
@@ -3293,17 +3301,17 @@ function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
|
|
|
3293
3301
|
}
|
|
3294
3302
|
|
|
3295
3303
|
// Filter from parents downward first
|
|
3296
|
-
rows = []; // Apply the filter to any subRows
|
|
3304
|
+
const rows = []; // Apply the filter to any subRows
|
|
3297
3305
|
|
|
3298
3306
|
for (let i = 0; i < rowsToFilter.length; i++) {
|
|
3299
|
-
row = rowsToFilter[i];
|
|
3307
|
+
let row = rowsToFilter[i];
|
|
3300
3308
|
const pass = filterRow(row);
|
|
3301
3309
|
|
|
3302
3310
|
if (pass) {
|
|
3303
3311
|
var _row$subRows2;
|
|
3304
3312
|
|
|
3305
3313
|
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
|
|
3306
|
-
newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3314
|
+
const newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3307
3315
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3308
3316
|
row = newRow;
|
|
3309
3317
|
}
|