@tanstack/react-table 8.0.0-alpha.88 → 8.0.0-alpha.89
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 +27 -9
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +27 -9
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +17 -17
- package/build/umd/index.development.js +27 -9
- 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
|
@@ -2533,8 +2533,10 @@ const Sorting = {
|
|
|
2533
2533
|
// })
|
|
2534
2534
|
// return
|
|
2535
2535
|
// }
|
|
2536
|
+
// this needs to be outside of instance.setSorting to be in sync with rerender
|
|
2537
|
+
const nextSortingOrder = column.getNextSortingOrder();
|
|
2536
2538
|
instance.setSorting(old => {
|
|
2537
|
-
var
|
|
2539
|
+
var _instance$options$ena, _instance$options$ena2;
|
|
2538
2540
|
|
|
2539
2541
|
// Find any existing sorting for this column
|
|
2540
2542
|
const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
|
|
@@ -2559,30 +2561,29 @@ const Sorting = {
|
|
|
2559
2561
|
} else {
|
|
2560
2562
|
sortAction = 'replace';
|
|
2561
2563
|
}
|
|
2562
|
-
}
|
|
2564
|
+
} // Handle toggle states that will remove the sorting
|
|
2563
2565
|
|
|
2564
|
-
const sortDescFirst = (_ref2 = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc'; // Handle toggle states that will remove the sorting
|
|
2565
2566
|
|
|
2566
2567
|
if (sortAction === 'toggle' && ( // Must be toggling
|
|
2567
2568
|
(_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
|
|
2568
2569
|
!hasDescDefined && ( // Must not be setting desc
|
|
2569
|
-
multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) &&
|
|
2570
|
-
|
|
2571
|
-
|
|
2570
|
+
multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && // If multi, don't allow if enableMultiRemove
|
|
2571
|
+
!nextSortingOrder // Finally, detect if it should indeed be removed
|
|
2572
|
+
) {
|
|
2572
2573
|
sortAction = 'remove';
|
|
2573
2574
|
}
|
|
2574
2575
|
|
|
2575
2576
|
if (sortAction === 'replace') {
|
|
2576
2577
|
newSorting = [{
|
|
2577
2578
|
id: column.id,
|
|
2578
|
-
desc: hasDescDefined ? desc :
|
|
2579
|
+
desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
|
|
2579
2580
|
}];
|
|
2580
2581
|
} else if (sortAction === 'add' && old != null && old.length) {
|
|
2581
2582
|
var _instance$options$max;
|
|
2582
2583
|
|
|
2583
2584
|
newSorting = [...old, {
|
|
2584
2585
|
id: column.id,
|
|
2585
|
-
desc: hasDescDefined ? desc :
|
|
2586
|
+
desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
|
|
2586
2587
|
}]; // Take latest n columns
|
|
2587
2588
|
|
|
2588
2589
|
newSorting.splice(0, newSorting.length - ((_instance$options$max = instance.options.maxMultiSortColCount) != null ? _instance$options$max : Number.MAX_SAFE_INTEGER));
|
|
@@ -2591,7 +2592,7 @@ const Sorting = {
|
|
|
2591
2592
|
newSorting = old.map(d => {
|
|
2592
2593
|
if (d.id === column.id) {
|
|
2593
2594
|
return { ...d,
|
|
2594
|
-
desc: hasDescDefined ? desc :
|
|
2595
|
+
desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
|
|
2595
2596
|
};
|
|
2596
2597
|
}
|
|
2597
2598
|
|
|
@@ -2604,6 +2605,23 @@ const Sorting = {
|
|
|
2604
2605
|
return newSorting;
|
|
2605
2606
|
});
|
|
2606
2607
|
},
|
|
2608
|
+
getNextSortingOrder: () => {
|
|
2609
|
+
var _ref2, _column$columnDef$sor;
|
|
2610
|
+
|
|
2611
|
+
const sortDescFirst = (_ref2 = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc';
|
|
2612
|
+
const firstSortDirection = sortDescFirst ? 'desc' : 'asc';
|
|
2613
|
+
const isSorted = column.getIsSorted();
|
|
2614
|
+
|
|
2615
|
+
if (!isSorted) {
|
|
2616
|
+
return firstSortDirection;
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2619
|
+
if (isSorted === firstSortDirection) {
|
|
2620
|
+
return isSorted === 'desc' ? 'asc' : 'desc';
|
|
2621
|
+
} else {
|
|
2622
|
+
return false;
|
|
2623
|
+
}
|
|
2624
|
+
},
|
|
2607
2625
|
getCanSort: () => {
|
|
2608
2626
|
var _column$columnDef$ena, _instance$options$ena3;
|
|
2609
2627
|
|