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