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