@tanstack/svelte-table 8.2.1 → 8.2.4
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 +62 -33
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +62 -33
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +47 -47
- package/build/umd/index.development.js +62 -33
- 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 +2 -2
package/build/esm/index.js
CHANGED
|
@@ -1992,6 +1992,10 @@ const RowSelection = {
|
|
|
1992
1992
|
|
|
1993
1993
|
if (value) {
|
|
1994
1994
|
preGroupedFlatRows.forEach(row => {
|
|
1995
|
+
if (!row.getCanSelect()) {
|
|
1996
|
+
return;
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1995
1999
|
rowSelection[row.id] = true;
|
|
1996
2000
|
});
|
|
1997
2001
|
} else {
|
|
@@ -2255,8 +2259,8 @@ const RowSelection = {
|
|
|
2255
2259
|
const mutateRowIsSelected = (selectedRowIds, id, value, table) => {
|
|
2256
2260
|
var _row$subRows;
|
|
2257
2261
|
|
|
2258
|
-
const row = table.getRow(id);
|
|
2259
|
-
|
|
2262
|
+
const row = table.getRow(id); // const isGrouped = row.getIsGrouped()
|
|
2263
|
+
// if ( // TODO: enforce grouping row selection rules
|
|
2260
2264
|
// !isGrouped ||
|
|
2261
2265
|
// (isGrouped && table.options.enableGroupingRowSelection)
|
|
2262
2266
|
// ) {
|
|
@@ -2266,7 +2270,9 @@ const mutateRowIsSelected = (selectedRowIds, id, value, table) => {
|
|
|
2266
2270
|
Object.keys(selectedRowIds).forEach(key => delete selectedRowIds[key]);
|
|
2267
2271
|
}
|
|
2268
2272
|
|
|
2269
|
-
|
|
2273
|
+
if (row.getCanSelect()) {
|
|
2274
|
+
selectedRowIds[id] = true;
|
|
2275
|
+
}
|
|
2270
2276
|
} else {
|
|
2271
2277
|
delete selectedRowIds[id];
|
|
2272
2278
|
} // }
|
|
@@ -2362,7 +2368,12 @@ const textCaseSensitive = (rowA, rowB, columnId) => {
|
|
|
2362
2368
|
};
|
|
2363
2369
|
|
|
2364
2370
|
const datetime = (rowA, rowB, columnId) => {
|
|
2365
|
-
|
|
2371
|
+
const a = rowA.getValue(columnId);
|
|
2372
|
+
const b = rowB.getValue(columnId); // Can handle nullish values
|
|
2373
|
+
// Use > and < because == (and ===) doesn't work with
|
|
2374
|
+
// Date objects (would require calling getTime()).
|
|
2375
|
+
|
|
2376
|
+
return a > b ? 1 : a < b ? -1 : 0;
|
|
2366
2377
|
};
|
|
2367
2378
|
|
|
2368
2379
|
const basic = (rowA, rowB, columnId) => {
|
|
@@ -2523,18 +2534,17 @@ const Sorting = {
|
|
|
2523
2534
|
// }
|
|
2524
2535
|
// this needs to be outside of table.setSorting to be in sync with rerender
|
|
2525
2536
|
const nextSortingOrder = column.getNextSortingOrder();
|
|
2537
|
+
const hasManualValue = typeof desc !== 'undefined' && desc !== null;
|
|
2526
2538
|
table.setSorting(old => {
|
|
2527
|
-
var _table$options$enable, _table$options$enable2;
|
|
2528
|
-
|
|
2529
2539
|
// Find any existing sorting for this column
|
|
2530
2540
|
const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
|
|
2531
2541
|
const existingIndex = old == null ? void 0 : old.findIndex(d => d.id === column.id);
|
|
2532
|
-
const hasDescDefined = typeof desc !== 'undefined' && desc !== null;
|
|
2533
2542
|
let newSorting = []; // What should we do with this sort action?
|
|
2534
2543
|
|
|
2535
2544
|
let sortAction;
|
|
2545
|
+
let nextDesc = hasManualValue ? desc : nextSortingOrder === 'desc'; // Multi-mode
|
|
2536
2546
|
|
|
2537
|
-
if (column.getCanMultiSort() && multi) {
|
|
2547
|
+
if (old != null && old.length && column.getCanMultiSort() && multi) {
|
|
2538
2548
|
if (existingSorting) {
|
|
2539
2549
|
sortAction = 'toggle';
|
|
2540
2550
|
} else {
|
|
@@ -2552,63 +2562,71 @@ const Sorting = {
|
|
|
2552
2562
|
} // Handle toggle states that will remove the sorting
|
|
2553
2563
|
|
|
2554
2564
|
|
|
2555
|
-
if (sortAction === 'toggle'
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2565
|
+
if (sortAction === 'toggle') {
|
|
2566
|
+
// If we are "actually" toggling (not a manual set value), should we remove the sorting?
|
|
2567
|
+
if (!hasManualValue) {
|
|
2568
|
+
// Is our intention to remove?
|
|
2569
|
+
if (!nextSortingOrder) {
|
|
2570
|
+
sortAction = 'remove';
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2562
2573
|
}
|
|
2563
2574
|
|
|
2564
|
-
if (sortAction === '
|
|
2565
|
-
newSorting = [{
|
|
2566
|
-
id: column.id,
|
|
2567
|
-
desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
|
|
2568
|
-
}];
|
|
2569
|
-
} else if (sortAction === 'add' && old != null && old.length) {
|
|
2575
|
+
if (sortAction === 'add') {
|
|
2570
2576
|
var _table$options$maxMul;
|
|
2571
2577
|
|
|
2572
2578
|
newSorting = [...old, {
|
|
2573
2579
|
id: column.id,
|
|
2574
|
-
desc:
|
|
2580
|
+
desc: nextDesc
|
|
2575
2581
|
}]; // Take latest n columns
|
|
2576
2582
|
|
|
2577
2583
|
newSorting.splice(0, newSorting.length - ((_table$options$maxMul = table.options.maxMultiSortColCount) != null ? _table$options$maxMul : Number.MAX_SAFE_INTEGER));
|
|
2578
|
-
} else if (sortAction === 'toggle'
|
|
2584
|
+
} else if (sortAction === 'toggle') {
|
|
2579
2585
|
// This flips (or sets) the
|
|
2580
2586
|
newSorting = old.map(d => {
|
|
2581
2587
|
if (d.id === column.id) {
|
|
2582
2588
|
return { ...d,
|
|
2583
|
-
desc:
|
|
2589
|
+
desc: nextDesc
|
|
2584
2590
|
};
|
|
2585
2591
|
}
|
|
2586
2592
|
|
|
2587
2593
|
return d;
|
|
2588
2594
|
});
|
|
2589
|
-
} else if (sortAction === 'remove'
|
|
2595
|
+
} else if (sortAction === 'remove') {
|
|
2590
2596
|
newSorting = old.filter(d => d.id !== column.id);
|
|
2597
|
+
} else {
|
|
2598
|
+
newSorting = [{
|
|
2599
|
+
id: column.id,
|
|
2600
|
+
desc: nextDesc
|
|
2601
|
+
}];
|
|
2591
2602
|
}
|
|
2592
2603
|
|
|
2593
2604
|
return newSorting;
|
|
2594
2605
|
});
|
|
2595
2606
|
},
|
|
2596
|
-
|
|
2607
|
+
getFirstSortDir: () => {
|
|
2597
2608
|
var _ref, _column$columnDef$sor;
|
|
2598
2609
|
|
|
2599
2610
|
const sortDescFirst = (_ref = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : table.options.sortDescFirst) != null ? _ref : column.getAutoSortDir() === 'desc';
|
|
2600
|
-
|
|
2611
|
+
return sortDescFirst ? 'desc' : 'asc';
|
|
2612
|
+
},
|
|
2613
|
+
getNextSortingOrder: multi => {
|
|
2614
|
+
var _table$options$enable, _table$options$enable2;
|
|
2615
|
+
|
|
2616
|
+
const firstSortDirection = column.getFirstSortDir();
|
|
2601
2617
|
const isSorted = column.getIsSorted();
|
|
2602
2618
|
|
|
2603
2619
|
if (!isSorted) {
|
|
2604
2620
|
return firstSortDirection;
|
|
2605
2621
|
}
|
|
2606
2622
|
|
|
2607
|
-
if (isSorted
|
|
2608
|
-
|
|
2609
|
-
|
|
2623
|
+
if (isSorted !== firstSortDirection && ((_table$options$enable = table.options.enableSortingRemoval) != null ? _table$options$enable : true) && ( // If enableSortRemove, enable in general
|
|
2624
|
+
multi ? (_table$options$enable2 = table.options.enableMultiRemove) != null ? _table$options$enable2 : true : true) // If multi, don't allow if enableMultiRemove))
|
|
2625
|
+
) {
|
|
2610
2626
|
return false;
|
|
2611
2627
|
}
|
|
2628
|
+
|
|
2629
|
+
return isSorted === 'desc' ? 'asc' : 'desc';
|
|
2612
2630
|
},
|
|
2613
2631
|
getCanSort: () => {
|
|
2614
2632
|
var _column$columnDef$ena, _table$options$enable3;
|
|
@@ -3557,9 +3575,20 @@ function getGroupedRowModel() {
|
|
|
3557
3575
|
depth = 0;
|
|
3558
3576
|
}
|
|
3559
3577
|
|
|
3560
|
-
//
|
|
3561
|
-
|
|
3562
|
-
|
|
3578
|
+
// Grouping depth has been been met
|
|
3579
|
+
// Stop grouping and simply rewrite thd depth and row relationships
|
|
3580
|
+
if (depth >= existingGrouping.length) {
|
|
3581
|
+
return rows.map(row => {
|
|
3582
|
+
row.depth = depth;
|
|
3583
|
+
groupedFlatRows.push(row);
|
|
3584
|
+
groupedRowsById[row.id] = row;
|
|
3585
|
+
|
|
3586
|
+
if (row.subRows) {
|
|
3587
|
+
row.subRows = groupUpRecursively(row.subRows, depth + 1);
|
|
3588
|
+
}
|
|
3589
|
+
|
|
3590
|
+
return row;
|
|
3591
|
+
});
|
|
3563
3592
|
}
|
|
3564
3593
|
|
|
3565
3594
|
const columnId = existingGrouping[depth]; // Group the rows together for this level
|