@tanstack/svelte-table 8.0.0-alpha.86 → 8.0.0-beta.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 +75 -71
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +75 -71
- 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 +75 -71
- 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,
|
|
@@ -887,8 +887,12 @@ const Expanding = {
|
|
|
887
887
|
getIsAllRowsExpanded: () => {
|
|
888
888
|
const expanded = instance.getState().expanded; // If expanded is true, save some cycles and return true
|
|
889
889
|
|
|
890
|
-
if (expanded ===
|
|
891
|
-
return true;
|
|
890
|
+
if (typeof expanded === 'boolean') {
|
|
891
|
+
return expanded === true;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
if (!Object.keys(expanded).length) {
|
|
895
|
+
return false;
|
|
892
896
|
} // If any row is not expanded, return false
|
|
893
897
|
|
|
894
898
|
|
|
@@ -2343,21 +2347,54 @@ function isRowSelected(row, selection, instance) {
|
|
|
2343
2347
|
}
|
|
2344
2348
|
|
|
2345
2349
|
const reSplitAlphaNumeric = /([0-9]+)/gm;
|
|
2346
|
-
const sortingFns = {
|
|
2347
|
-
alphanumeric,
|
|
2348
|
-
alphanumericCaseSensitive,
|
|
2349
|
-
text,
|
|
2350
|
-
textCaseSensitive,
|
|
2351
|
-
datetime,
|
|
2352
|
-
basic
|
|
2353
|
-
};
|
|
2354
2350
|
|
|
2355
|
-
|
|
2351
|
+
const alphanumeric = (rowA, rowB, columnId) => {
|
|
2356
2352
|
return compareAlphanumeric(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2357
|
-
}
|
|
2353
|
+
};
|
|
2358
2354
|
|
|
2359
|
-
|
|
2355
|
+
const alphanumericCaseSensitive = (rowA, rowB, columnId) => {
|
|
2360
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 '';
|
|
2361
2398
|
} // Mixed sorting is slow, but very inclusive of many edge cases.
|
|
2362
2399
|
// It handles numbers, mixed alphanumeric combinations, and even
|
|
2363
2400
|
// null, undefined, and Infinity
|
|
@@ -2404,48 +2441,17 @@ function compareAlphanumeric(aStr, bStr) {
|
|
|
2404
2441
|
}
|
|
2405
2442
|
|
|
2406
2443
|
return a.length - b.length;
|
|
2407
|
-
} //
|
|
2408
|
-
// but is much faster
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
function text(rowA, rowB, columnId) {
|
|
2412
|
-
return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2413
|
-
} // The text filter is more basic (less numeric support)
|
|
2414
|
-
// but is much faster
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
function textCaseSensitive(rowA, rowB, columnId) {
|
|
2418
|
-
return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
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
|
-
}
|
|
2444
|
+
} // Exports
|
|
2442
2445
|
|
|
2443
|
-
if (typeof a === 'string') {
|
|
2444
|
-
return a;
|
|
2445
|
-
}
|
|
2446
2446
|
|
|
2447
|
-
|
|
2448
|
-
|
|
2447
|
+
const sortingFns = {
|
|
2448
|
+
alphanumeric,
|
|
2449
|
+
alphanumericCaseSensitive,
|
|
2450
|
+
text,
|
|
2451
|
+
textCaseSensitive,
|
|
2452
|
+
datetime,
|
|
2453
|
+
basic
|
|
2454
|
+
};
|
|
2449
2455
|
|
|
2450
2456
|
//
|
|
2451
2457
|
const Sorting = {
|
|
@@ -2697,8 +2703,8 @@ const Visibility = {
|
|
|
2697
2703
|
},
|
|
2698
2704
|
createRow: (row, instance) => {
|
|
2699
2705
|
return {
|
|
2700
|
-
_getAllVisibleCells: memo(() => [row.getAllCells()
|
|
2701
|
-
return
|
|
2706
|
+
_getAllVisibleCells: memo(() => [row.getAllCells(), instance.getState().columnVisibility], cells => {
|
|
2707
|
+
return cells.filter(cell => cell.column.getIsVisible());
|
|
2702
2708
|
}, {
|
|
2703
2709
|
key: process.env.NODE_ENV === 'production' && 'row._getAllVisibleCells',
|
|
2704
2710
|
debug: () => {
|
|
@@ -3051,13 +3057,15 @@ function createCell(instance, row, column, columnId) {
|
|
|
3051
3057
|
row,
|
|
3052
3058
|
column,
|
|
3053
3059
|
getValue: () => row.getValue(columnId),
|
|
3054
|
-
renderCell: () =>
|
|
3055
|
-
instance,
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
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
|
+
}
|
|
3061
3069
|
};
|
|
3062
3070
|
|
|
3063
3071
|
instance._features.forEach(feature => {
|
|
@@ -3132,27 +3140,23 @@ function getCoreRowModel() {
|
|
|
3132
3140
|
flatRows: [],
|
|
3133
3141
|
rowsById: {}
|
|
3134
3142
|
};
|
|
3135
|
-
let rows;
|
|
3136
|
-
let row;
|
|
3137
|
-
let originalRow;
|
|
3138
3143
|
|
|
3139
3144
|
const accessRows = function (originalRows, depth, parent) {
|
|
3140
3145
|
if (depth === void 0) {
|
|
3141
3146
|
depth = 0;
|
|
3142
3147
|
}
|
|
3143
3148
|
|
|
3144
|
-
rows = [];
|
|
3149
|
+
const rows = [];
|
|
3145
3150
|
|
|
3146
3151
|
for (let i = 0; i < originalRows.length; i++) {
|
|
3147
|
-
|
|
3152
|
+
// This could be an expensive check at scale, so we should move it somewhere else, but where?
|
|
3148
3153
|
// if (!id) {
|
|
3149
3154
|
// if (process.env.NODE_ENV !== 'production') {
|
|
3150
3155
|
// throw new Error(`getRowId expected an ID, but got ${id}`)
|
|
3151
3156
|
// }
|
|
3152
3157
|
// }
|
|
3153
3158
|
// Make the row
|
|
3154
|
-
|
|
3155
|
-
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
|
|
3156
3160
|
|
|
3157
3161
|
rowModel.flatRows.push(row); // Also keep track of every row by its ID
|
|
3158
3162
|
|
|
@@ -3163,7 +3167,7 @@ function getCoreRowModel() {
|
|
|
3163
3167
|
if (instance.options.getSubRows) {
|
|
3164
3168
|
var _row$originalSubRows;
|
|
3165
3169
|
|
|
3166
|
-
row.originalSubRows = instance.options.getSubRows(
|
|
3170
|
+
row.originalSubRows = instance.options.getSubRows(originalRows[i], i); // Then recursively access them
|
|
3167
3171
|
|
|
3168
3172
|
if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
|
|
3169
3173
|
row.subRows = accessRows(row.originalSubRows, depth + 1, row);
|