@tanstack/svelte-table 8.1.4 → 8.2.2
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/svelte-table/src/placeholder.svelte.js +1 -1
- package/build/cjs/table-core/build/esm/index.js +43 -33
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +44 -34
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +48 -48
- package/build/umd/index.development.js +44 -34
- 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
|
@@ -2362,7 +2362,12 @@ const textCaseSensitive = (rowA, rowB, columnId) => {
|
|
|
2362
2362
|
};
|
|
2363
2363
|
|
|
2364
2364
|
const datetime = (rowA, rowB, columnId) => {
|
|
2365
|
-
|
|
2365
|
+
const a = rowA.getValue(columnId);
|
|
2366
|
+
const b = rowB.getValue(columnId); // Can handle nullish values
|
|
2367
|
+
// Use > and < because == (and ===) doesn't work with
|
|
2368
|
+
// Date objects (would require calling getTime()).
|
|
2369
|
+
|
|
2370
|
+
return a > b ? 1 : a < b ? -1 : 0;
|
|
2366
2371
|
};
|
|
2367
2372
|
|
|
2368
2373
|
const basic = (rowA, rowB, columnId) => {
|
|
@@ -2523,18 +2528,17 @@ const Sorting = {
|
|
|
2523
2528
|
// }
|
|
2524
2529
|
// this needs to be outside of table.setSorting to be in sync with rerender
|
|
2525
2530
|
const nextSortingOrder = column.getNextSortingOrder();
|
|
2531
|
+
const hasManualValue = typeof desc !== 'undefined' && desc !== null;
|
|
2526
2532
|
table.setSorting(old => {
|
|
2527
|
-
var _table$options$enable, _table$options$enable2;
|
|
2528
|
-
|
|
2529
2533
|
// Find any existing sorting for this column
|
|
2530
2534
|
const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
|
|
2531
2535
|
const existingIndex = old == null ? void 0 : old.findIndex(d => d.id === column.id);
|
|
2532
|
-
const hasDescDefined = typeof desc !== 'undefined' && desc !== null;
|
|
2533
2536
|
let newSorting = []; // What should we do with this sort action?
|
|
2534
2537
|
|
|
2535
2538
|
let sortAction;
|
|
2539
|
+
let nextDesc = hasManualValue ? desc : nextSortingOrder === 'desc'; // Multi-mode
|
|
2536
2540
|
|
|
2537
|
-
if (column.getCanMultiSort() && multi) {
|
|
2541
|
+
if (old != null && old.length && column.getCanMultiSort() && multi) {
|
|
2538
2542
|
if (existingSorting) {
|
|
2539
2543
|
sortAction = 'toggle';
|
|
2540
2544
|
} else {
|
|
@@ -2552,63 +2556,71 @@ const Sorting = {
|
|
|
2552
2556
|
} // Handle toggle states that will remove the sorting
|
|
2553
2557
|
|
|
2554
2558
|
|
|
2555
|
-
if (sortAction === 'toggle'
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2559
|
+
if (sortAction === 'toggle') {
|
|
2560
|
+
// If we are "actually" toggling (not a manual set value), should we remove the sorting?
|
|
2561
|
+
if (!hasManualValue) {
|
|
2562
|
+
// Is our intention to remove?
|
|
2563
|
+
if (!nextSortingOrder) {
|
|
2564
|
+
sortAction = 'remove';
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2562
2567
|
}
|
|
2563
2568
|
|
|
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) {
|
|
2569
|
+
if (sortAction === 'add') {
|
|
2570
2570
|
var _table$options$maxMul;
|
|
2571
2571
|
|
|
2572
2572
|
newSorting = [...old, {
|
|
2573
2573
|
id: column.id,
|
|
2574
|
-
desc:
|
|
2574
|
+
desc: nextDesc
|
|
2575
2575
|
}]; // Take latest n columns
|
|
2576
2576
|
|
|
2577
2577
|
newSorting.splice(0, newSorting.length - ((_table$options$maxMul = table.options.maxMultiSortColCount) != null ? _table$options$maxMul : Number.MAX_SAFE_INTEGER));
|
|
2578
|
-
} else if (sortAction === 'toggle'
|
|
2578
|
+
} else if (sortAction === 'toggle') {
|
|
2579
2579
|
// This flips (or sets) the
|
|
2580
2580
|
newSorting = old.map(d => {
|
|
2581
2581
|
if (d.id === column.id) {
|
|
2582
2582
|
return { ...d,
|
|
2583
|
-
desc:
|
|
2583
|
+
desc: nextDesc
|
|
2584
2584
|
};
|
|
2585
2585
|
}
|
|
2586
2586
|
|
|
2587
2587
|
return d;
|
|
2588
2588
|
});
|
|
2589
|
-
} else if (sortAction === 'remove'
|
|
2589
|
+
} else if (sortAction === 'remove') {
|
|
2590
2590
|
newSorting = old.filter(d => d.id !== column.id);
|
|
2591
|
+
} else {
|
|
2592
|
+
newSorting = [{
|
|
2593
|
+
id: column.id,
|
|
2594
|
+
desc: nextDesc
|
|
2595
|
+
}];
|
|
2591
2596
|
}
|
|
2592
2597
|
|
|
2593
2598
|
return newSorting;
|
|
2594
2599
|
});
|
|
2595
2600
|
},
|
|
2596
|
-
|
|
2601
|
+
getFirstSortDir: () => {
|
|
2597
2602
|
var _ref, _column$columnDef$sor;
|
|
2598
2603
|
|
|
2599
2604
|
const sortDescFirst = (_ref = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : table.options.sortDescFirst) != null ? _ref : column.getAutoSortDir() === 'desc';
|
|
2600
|
-
|
|
2605
|
+
return sortDescFirst ? 'desc' : 'asc';
|
|
2606
|
+
},
|
|
2607
|
+
getNextSortingOrder: multi => {
|
|
2608
|
+
var _table$options$enable, _table$options$enable2;
|
|
2609
|
+
|
|
2610
|
+
const firstSortDirection = column.getFirstSortDir();
|
|
2601
2611
|
const isSorted = column.getIsSorted();
|
|
2602
2612
|
|
|
2603
2613
|
if (!isSorted) {
|
|
2604
2614
|
return firstSortDirection;
|
|
2605
2615
|
}
|
|
2606
2616
|
|
|
2607
|
-
if (isSorted
|
|
2608
|
-
|
|
2609
|
-
|
|
2617
|
+
if (isSorted !== firstSortDirection && ((_table$options$enable = table.options.enableSortingRemoval) != null ? _table$options$enable : true) && ( // If enableSortRemove, enable in general
|
|
2618
|
+
multi ? (_table$options$enable2 = table.options.enableMultiRemove) != null ? _table$options$enable2 : true : true) // If multi, don't allow if enableMultiRemove))
|
|
2619
|
+
) {
|
|
2610
2620
|
return false;
|
|
2611
2621
|
}
|
|
2622
|
+
|
|
2623
|
+
return isSorted === 'desc' ? 'asc' : 'desc';
|
|
2612
2624
|
},
|
|
2613
2625
|
getCanSort: () => {
|
|
2614
2626
|
var _column$columnDef$ena, _table$options$enable3;
|
|
@@ -2892,9 +2904,9 @@ function createTable(options) {
|
|
|
2892
2904
|
header: props => props.header.column.id,
|
|
2893
2905
|
footer: props => props.header.column.id,
|
|
2894
2906
|
cell: props => {
|
|
2895
|
-
var
|
|
2907
|
+
var _props$renderValue$to, _props$renderValue;
|
|
2896
2908
|
|
|
2897
|
-
return (
|
|
2909
|
+
return (_props$renderValue$to = (_props$renderValue = props.renderValue()) == null ? void 0 : _props$renderValue.toString == null ? void 0 : _props$renderValue.toString()) != null ? _props$renderValue$to : null;
|
|
2898
2910
|
},
|
|
2899
2911
|
...table._features.reduce((obj, feature) => {
|
|
2900
2912
|
return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
|
|
@@ -3424,9 +3436,7 @@ function getFacetedMinMaxValues() {
|
|
|
3424
3436
|
let facetedMinMaxValues = [firstValue, firstValue];
|
|
3425
3437
|
|
|
3426
3438
|
for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
const value = (_facetedRowModel$flat2 = facetedRowModel.flatRows[i]) == null ? void 0 : _facetedRowModel$flat2.getValue(columnId);
|
|
3439
|
+
const value = facetedRowModel.flatRows[i].getValue(columnId);
|
|
3430
3440
|
|
|
3431
3441
|
if (value < facetedMinMaxValues[0]) {
|
|
3432
3442
|
facetedMinMaxValues[0] = value;
|
|
@@ -3576,7 +3586,7 @@ function getGroupedRowModel() {
|
|
|
3576
3586
|
const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
|
|
3577
3587
|
|
|
3578
3588
|
const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
|
|
3579
|
-
const row = createRow(table, id,
|
|
3589
|
+
const row = createRow(table, id, leafRows[0].original, index, depth);
|
|
3580
3590
|
Object.assign(row, {
|
|
3581
3591
|
groupingColumnId: columnId,
|
|
3582
3592
|
groupingValue,
|
|
@@ -3770,7 +3780,7 @@ function getPaginationRowModel(opts) {
|
|
|
3770
3780
|
});
|
|
3771
3781
|
}
|
|
3772
3782
|
|
|
3773
|
-
/* packages/svelte-table/src/placeholder.svelte generated by Svelte v3.
|
|
3783
|
+
/* packages/svelte-table/src/placeholder.svelte generated by Svelte v3.49.0 */
|
|
3774
3784
|
|
|
3775
3785
|
function create_fragment$1(ctx) {
|
|
3776
3786
|
let t;
|