@tanstack/react-table 8.0.0-alpha.85 → 8.0.0-alpha.88
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 +78 -80
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +78 -80
- 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 +78 -80
- 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 +5 -5
package/build/esm/index.js
CHANGED
|
@@ -122,7 +122,7 @@ function createColumn(instance, columnDef, depth, parent) {
|
|
|
122
122
|
throw new Error();
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
let column = {
|
|
125
|
+
let column = {
|
|
126
126
|
id: "" + id,
|
|
127
127
|
accessorFn,
|
|
128
128
|
parent: parent,
|
|
@@ -827,7 +827,6 @@ const Expanding = {
|
|
|
827
827
|
return {
|
|
828
828
|
onExpandedChange: makeStateUpdater('expanded', instance),
|
|
829
829
|
autoResetExpanded: true,
|
|
830
|
-
expandSubRows: true,
|
|
831
830
|
paginateExpandedRows: true
|
|
832
831
|
};
|
|
833
832
|
},
|
|
@@ -887,8 +886,12 @@ const Expanding = {
|
|
|
887
886
|
getIsAllRowsExpanded: () => {
|
|
888
887
|
const expanded = instance.getState().expanded; // If expanded is true, save some cycles and return true
|
|
889
888
|
|
|
890
|
-
if (expanded ===
|
|
891
|
-
return true;
|
|
889
|
+
if (typeof expanded === 'boolean') {
|
|
890
|
+
return expanded === true;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
if (!Object.keys(expanded).length) {
|
|
894
|
+
return false;
|
|
892
895
|
} // If any row is not expanded, return false
|
|
893
896
|
|
|
894
897
|
|
|
@@ -2343,21 +2346,54 @@ function isRowSelected(row, selection, instance) {
|
|
|
2343
2346
|
}
|
|
2344
2347
|
|
|
2345
2348
|
const reSplitAlphaNumeric = /([0-9]+)/gm;
|
|
2346
|
-
const sortingFns = {
|
|
2347
|
-
alphanumeric,
|
|
2348
|
-
alphanumericCaseSensitive,
|
|
2349
|
-
text,
|
|
2350
|
-
textCaseSensitive,
|
|
2351
|
-
datetime,
|
|
2352
|
-
basic
|
|
2353
|
-
};
|
|
2354
2349
|
|
|
2355
|
-
|
|
2350
|
+
const alphanumeric = (rowA, rowB, columnId) => {
|
|
2356
2351
|
return compareAlphanumeric(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2357
|
-
}
|
|
2352
|
+
};
|
|
2358
2353
|
|
|
2359
|
-
|
|
2354
|
+
const alphanumericCaseSensitive = (rowA, rowB, columnId) => {
|
|
2360
2355
|
return compareAlphanumeric(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
2356
|
+
}; // The text filter is more basic (less numeric support)
|
|
2357
|
+
// but is much faster
|
|
2358
|
+
|
|
2359
|
+
|
|
2360
|
+
const text = (rowA, rowB, columnId) => {
|
|
2361
|
+
return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2362
|
+
}; // The text filter is more basic (less numeric support)
|
|
2363
|
+
// but is much faster
|
|
2364
|
+
|
|
2365
|
+
|
|
2366
|
+
const textCaseSensitive = (rowA, rowB, columnId) => {
|
|
2367
|
+
return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
2368
|
+
};
|
|
2369
|
+
|
|
2370
|
+
const datetime = (rowA, rowB, columnId) => {
|
|
2371
|
+
return compareBasic(rowA.getValue(columnId).getTime(), rowB.getValue(columnId).getTime());
|
|
2372
|
+
};
|
|
2373
|
+
|
|
2374
|
+
const basic = (rowA, rowB, columnId) => {
|
|
2375
|
+
return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
|
|
2376
|
+
}; // Utils
|
|
2377
|
+
|
|
2378
|
+
|
|
2379
|
+
function compareBasic(a, b) {
|
|
2380
|
+
return a === b ? 0 : a > b ? 1 : -1;
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
function toString(a) {
|
|
2384
|
+
if (typeof a === 'number') {
|
|
2385
|
+
if (isNaN(a) || a === Infinity || a === -Infinity) {
|
|
2386
|
+
return '';
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2389
|
+
return String(a);
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
if (typeof a === 'string') {
|
|
2393
|
+
return a;
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
return '';
|
|
2361
2397
|
} // Mixed sorting is slow, but very inclusive of many edge cases.
|
|
2362
2398
|
// It handles numbers, mixed alphanumeric combinations, and even
|
|
2363
2399
|
// null, undefined, and Infinity
|
|
@@ -2404,48 +2440,17 @@ function compareAlphanumeric(aStr, bStr) {
|
|
|
2404
2440
|
}
|
|
2405
2441
|
|
|
2406
2442
|
return a.length - b.length;
|
|
2407
|
-
} //
|
|
2408
|
-
// but is much faster
|
|
2443
|
+
} // Exports
|
|
2409
2444
|
|
|
2410
2445
|
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
}
|
|
2420
|
-
|
|
2421
|
-
function datetime(rowA, rowB, columnId) {
|
|
2422
|
-
return compareBasic(rowA.getValue(columnId).getTime(), rowB.getValue(columnId).getTime());
|
|
2423
|
-
}
|
|
2424
|
-
|
|
2425
|
-
function basic(rowA, rowB, columnId) {
|
|
2426
|
-
return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
|
|
2427
|
-
} // Utils
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
function compareBasic(a, b) {
|
|
2431
|
-
return a === b ? 0 : a > b ? 1 : -1;
|
|
2432
|
-
}
|
|
2433
|
-
|
|
2434
|
-
function toString(a) {
|
|
2435
|
-
if (typeof a === 'number') {
|
|
2436
|
-
if (isNaN(a) || a === Infinity || a === -Infinity) {
|
|
2437
|
-
return '';
|
|
2438
|
-
}
|
|
2439
|
-
|
|
2440
|
-
return String(a);
|
|
2441
|
-
}
|
|
2442
|
-
|
|
2443
|
-
if (typeof a === 'string') {
|
|
2444
|
-
return a;
|
|
2445
|
-
}
|
|
2446
|
-
|
|
2447
|
-
return '';
|
|
2448
|
-
}
|
|
2446
|
+
const sortingFns = {
|
|
2447
|
+
alphanumeric,
|
|
2448
|
+
alphanumericCaseSensitive,
|
|
2449
|
+
text,
|
|
2450
|
+
textCaseSensitive,
|
|
2451
|
+
datetime,
|
|
2452
|
+
basic
|
|
2453
|
+
};
|
|
2449
2454
|
|
|
2450
2455
|
//
|
|
2451
2456
|
const Sorting = {
|
|
@@ -2669,11 +2674,6 @@ const Visibility = {
|
|
|
2669
2674
|
onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
|
|
2670
2675
|
};
|
|
2671
2676
|
},
|
|
2672
|
-
getDefaultColumnDef: () => {
|
|
2673
|
-
return {
|
|
2674
|
-
defaultIsVisible: true
|
|
2675
|
-
};
|
|
2676
|
-
},
|
|
2677
2677
|
createColumn: (column, instance) => {
|
|
2678
2678
|
return {
|
|
2679
2679
|
toggleVisibility: value => {
|
|
@@ -2702,8 +2702,8 @@ const Visibility = {
|
|
|
2702
2702
|
},
|
|
2703
2703
|
createRow: (row, instance) => {
|
|
2704
2704
|
return {
|
|
2705
|
-
_getAllVisibleCells: memo(() => [row.getAllCells()
|
|
2706
|
-
return
|
|
2705
|
+
_getAllVisibleCells: memo(() => [row.getAllCells(), instance.getState().columnVisibility], cells => {
|
|
2706
|
+
return cells.filter(cell => cell.column.getIsVisible());
|
|
2707
2707
|
}, {
|
|
2708
2708
|
key: process.env.NODE_ENV === 'production' && 'row._getAllVisibleCells',
|
|
2709
2709
|
debug: () => {
|
|
@@ -3056,13 +3056,15 @@ function createCell(instance, row, column, columnId) {
|
|
|
3056
3056
|
row,
|
|
3057
3057
|
column,
|
|
3058
3058
|
getValue: () => row.getValue(columnId),
|
|
3059
|
-
renderCell: () =>
|
|
3060
|
-
instance,
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3059
|
+
renderCell: () => {
|
|
3060
|
+
return column.columnDef.cell ? instance._render(column.columnDef.cell, {
|
|
3061
|
+
instance,
|
|
3062
|
+
column,
|
|
3063
|
+
row,
|
|
3064
|
+
cell: cell,
|
|
3065
|
+
getValue: cell.getValue
|
|
3066
|
+
}) : null;
|
|
3067
|
+
}
|
|
3066
3068
|
};
|
|
3067
3069
|
|
|
3068
3070
|
instance._features.forEach(feature => {
|
|
@@ -3137,27 +3139,23 @@ function getCoreRowModel() {
|
|
|
3137
3139
|
flatRows: [],
|
|
3138
3140
|
rowsById: {}
|
|
3139
3141
|
};
|
|
3140
|
-
let rows;
|
|
3141
|
-
let row;
|
|
3142
|
-
let originalRow;
|
|
3143
3142
|
|
|
3144
3143
|
const accessRows = function (originalRows, depth, parent) {
|
|
3145
3144
|
if (depth === void 0) {
|
|
3146
3145
|
depth = 0;
|
|
3147
3146
|
}
|
|
3148
3147
|
|
|
3149
|
-
rows = [];
|
|
3148
|
+
const rows = [];
|
|
3150
3149
|
|
|
3151
3150
|
for (let i = 0; i < originalRows.length; i++) {
|
|
3152
|
-
|
|
3151
|
+
// This could be an expensive check at scale, so we should move it somewhere else, but where?
|
|
3153
3152
|
// if (!id) {
|
|
3154
3153
|
// if (process.env.NODE_ENV !== 'production') {
|
|
3155
3154
|
// throw new Error(`getRowId expected an ID, but got ${id}`)
|
|
3156
3155
|
// }
|
|
3157
3156
|
// }
|
|
3158
3157
|
// Make the row
|
|
3159
|
-
|
|
3160
|
-
row = createRow(instance, instance._getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
|
|
3158
|
+
const row = createRow(instance, instance._getRowId(originalRows[i], i, parent), originalRows[i], i, depth); // Keep track of every row in a flat array
|
|
3161
3159
|
|
|
3162
3160
|
rowModel.flatRows.push(row); // Also keep track of every row by its ID
|
|
3163
3161
|
|
|
@@ -3168,7 +3166,7 @@ function getCoreRowModel() {
|
|
|
3168
3166
|
if (instance.options.getSubRows) {
|
|
3169
3167
|
var _row$originalSubRows;
|
|
3170
3168
|
|
|
3171
|
-
row.originalSubRows = instance.options.getSubRows(
|
|
3169
|
+
row.originalSubRows = instance.options.getSubRows(originalRows[i], i); // Then recursively access them
|
|
3172
3170
|
|
|
3173
3171
|
if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
|
|
3174
3172
|
row.subRows = accessRows(row.originalSubRows, depth + 1, row);
|
|
@@ -3749,7 +3747,7 @@ function getExpandedRowModel() {
|
|
|
3749
3747
|
return rowModel;
|
|
3750
3748
|
}
|
|
3751
3749
|
|
|
3752
|
-
return expandRows(rowModel
|
|
3750
|
+
return expandRows(rowModel);
|
|
3753
3751
|
}, {
|
|
3754
3752
|
key: process.env.NODE_ENV === 'development' && 'getExpandedRowModel',
|
|
3755
3753
|
debug: () => {
|
|
@@ -3767,7 +3765,7 @@ function expandRows(rowModel, instance) {
|
|
|
3767
3765
|
|
|
3768
3766
|
expandedRows.push(row);
|
|
3769
3767
|
|
|
3770
|
-
if (
|
|
3768
|
+
if ((_row$subRows = row.subRows) != null && _row$subRows.length && row.getIsExpanded()) {
|
|
3771
3769
|
row.subRows.forEach(handleRow);
|
|
3772
3770
|
}
|
|
3773
3771
|
};
|
|
@@ -3804,7 +3802,7 @@ function getPaginationRowModel(opts) {
|
|
|
3804
3802
|
rows,
|
|
3805
3803
|
flatRows,
|
|
3806
3804
|
rowsById
|
|
3807
|
-
}
|
|
3805
|
+
});
|
|
3808
3806
|
}
|
|
3809
3807
|
|
|
3810
3808
|
return {
|