@tanstack/react-table 8.9.0 → 8.9.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.
|
@@ -69,6 +69,9 @@
|
|
|
69
69
|
function isFunction(d) {
|
|
70
70
|
return d instanceof Function;
|
|
71
71
|
}
|
|
72
|
+
function isNumberArray(d) {
|
|
73
|
+
return Array.isArray(d) && d.every(val => typeof val === 'number');
|
|
74
|
+
}
|
|
72
75
|
function flattenBy(arr, getChildren) {
|
|
73
76
|
const flat = [];
|
|
74
77
|
const recurse = subArr => {
|
|
@@ -1315,16 +1318,16 @@
|
|
|
1315
1318
|
if (!leafRows.length) {
|
|
1316
1319
|
return;
|
|
1317
1320
|
}
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
return (
|
|
1321
|
+
const values = leafRows.map(row => row.getValue(columnId));
|
|
1322
|
+
if (!isNumberArray(values)) {
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
if (values.length === 1) {
|
|
1326
|
+
return values[0];
|
|
1327
|
+
}
|
|
1328
|
+
const mid = Math.floor(values.length / 2);
|
|
1329
|
+
const nums = values.sort((a, b) => a - b);
|
|
1330
|
+
return values.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
|
|
1328
1331
|
};
|
|
1329
1332
|
const unique = (columnId, leafRows) => {
|
|
1330
1333
|
return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
|
|
@@ -3390,7 +3393,11 @@
|
|
|
3390
3393
|
const aUndefined = typeof aValue === 'undefined';
|
|
3391
3394
|
const bUndefined = typeof bValue === 'undefined';
|
|
3392
3395
|
if (aUndefined || bUndefined) {
|
|
3393
|
-
|
|
3396
|
+
let undefinedSort = aUndefined && bUndefined ? 0 : aUndefined ? columnInfo.sortUndefined : -columnInfo.sortUndefined;
|
|
3397
|
+
if (isDesc && undefinedSort !== 0) {
|
|
3398
|
+
undefinedSort *= -1;
|
|
3399
|
+
}
|
|
3400
|
+
return undefinedSort;
|
|
3394
3401
|
}
|
|
3395
3402
|
}
|
|
3396
3403
|
|
|
@@ -3751,6 +3758,7 @@
|
|
|
3751
3758
|
exports.getPaginationRowModel = getPaginationRowModel;
|
|
3752
3759
|
exports.getSortedRowModel = getSortedRowModel;
|
|
3753
3760
|
exports.isFunction = isFunction;
|
|
3761
|
+
exports.isNumberArray = isNumberArray;
|
|
3754
3762
|
exports.isRowSelected = isRowSelected;
|
|
3755
3763
|
exports.isSubRowSelected = isSubRowSelected;
|
|
3756
3764
|
exports.makeStateUpdater = makeStateUpdater;
|