@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
package/build/esm/index.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =>
|
|
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 =>
|
|
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) =>
|
|
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
|
|
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
|
|
@@ -1726,9 +1745,9 @@ const Pagination = {
|
|
|
1726
1745
|
});
|
|
1727
1746
|
},
|
|
1728
1747
|
setPageCount: updater => instance.setPagination(old => {
|
|
1729
|
-
var
|
|
1748
|
+
var _instance$options$pag;
|
|
1730
1749
|
|
|
1731
|
-
let newPageCount = functionalUpdate(updater, (
|
|
1750
|
+
let newPageCount = functionalUpdate(updater, (_instance$options$pag = instance.options.pageCount) != null ? _instance$options$pag : -1);
|
|
1732
1751
|
|
|
1733
1752
|
if (typeof newPageCount === 'number') {
|
|
1734
1753
|
newPageCount = Math.max(-1, newPageCount);
|
|
@@ -1738,7 +1757,7 @@ const Pagination = {
|
|
|
1738
1757
|
pageCount: newPageCount
|
|
1739
1758
|
};
|
|
1740
1759
|
}),
|
|
1741
|
-
getPageOptions: memo(() => [instance.
|
|
1760
|
+
getPageOptions: memo(() => [instance.getPageCount()], pageCount => {
|
|
1742
1761
|
let pageOptions = [];
|
|
1743
1762
|
|
|
1744
1763
|
if (pageCount && pageCount > 0) {
|
|
@@ -1792,15 +1811,9 @@ const Pagination = {
|
|
|
1792
1811
|
return instance._getPaginationRowModel();
|
|
1793
1812
|
},
|
|
1794
1813
|
getPageCount: () => {
|
|
1795
|
-
|
|
1796
|
-
pageCount
|
|
1797
|
-
} = instance.getState().pagination;
|
|
1814
|
+
var _instance$options$pag2;
|
|
1798
1815
|
|
|
1799
|
-
|
|
1800
|
-
return pageCount;
|
|
1801
|
-
}
|
|
1802
|
-
|
|
1803
|
-
return Math.ceil(instance.getPrePaginationRowModel().rows.length / instance.getState().pagination.pageSize);
|
|
1816
|
+
return (_instance$options$pag2 = instance.options.pageCount) != null ? _instance$options$pag2 : Math.ceil(instance.getPrePaginationRowModel().rows.length / instance.getState().pagination.pageSize);
|
|
1804
1817
|
}
|
|
1805
1818
|
};
|
|
1806
1819
|
}
|
|
@@ -3235,8 +3248,6 @@ function filterRows(rows, filterRowImpl, instance) {
|
|
|
3235
3248
|
function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
|
|
3236
3249
|
const newFilteredFlatRows = [];
|
|
3237
3250
|
const newFilteredRowsById = {};
|
|
3238
|
-
let row;
|
|
3239
|
-
let newRow;
|
|
3240
3251
|
|
|
3241
3252
|
const recurseFilterRows = function (rowsToFilter, depth) {
|
|
3242
3253
|
if (depth === void 0) {
|
|
@@ -3248,10 +3259,10 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
|
|
|
3248
3259
|
for (let i = 0; i < rowsToFilter.length; i++) {
|
|
3249
3260
|
var _row$subRows;
|
|
3250
3261
|
|
|
3251
|
-
row = rowsToFilter[i];
|
|
3262
|
+
let row = rowsToFilter[i];
|
|
3252
3263
|
|
|
3253
3264
|
if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
|
|
3254
|
-
newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3265
|
+
const newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3255
3266
|
newRow.columnFilters = row.columnFilters;
|
|
3256
3267
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3257
3268
|
|
|
@@ -3280,10 +3291,7 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
|
|
|
3280
3291
|
}
|
|
3281
3292
|
function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
|
|
3282
3293
|
const newFilteredFlatRows = [];
|
|
3283
|
-
const newFilteredRowsById = {};
|
|
3284
|
-
let rows;
|
|
3285
|
-
let row;
|
|
3286
|
-
let newRow; // Filters top level and nested rows
|
|
3294
|
+
const newFilteredRowsById = {}; // Filters top level and nested rows
|
|
3287
3295
|
|
|
3288
3296
|
const recurseFilterRows = function (rowsToFilter, depth) {
|
|
3289
3297
|
if (depth === void 0) {
|
|
@@ -3291,17 +3299,17 @@ function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
|
|
|
3291
3299
|
}
|
|
3292
3300
|
|
|
3293
3301
|
// Filter from parents downward first
|
|
3294
|
-
rows = []; // Apply the filter to any subRows
|
|
3302
|
+
const rows = []; // Apply the filter to any subRows
|
|
3295
3303
|
|
|
3296
3304
|
for (let i = 0; i < rowsToFilter.length; i++) {
|
|
3297
|
-
row = rowsToFilter[i];
|
|
3305
|
+
let row = rowsToFilter[i];
|
|
3298
3306
|
const pass = filterRow(row);
|
|
3299
3307
|
|
|
3300
3308
|
if (pass) {
|
|
3301
3309
|
var _row$subRows2;
|
|
3302
3310
|
|
|
3303
3311
|
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
|
|
3304
|
-
newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3312
|
+
const newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3305
3313
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3306
3314
|
row = newRow;
|
|
3307
3315
|
}
|