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