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