@tanstack/react-table 8.9.0 → 8.9.1
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());
|
|
@@ -3751,6 +3754,7 @@
|
|
|
3751
3754
|
exports.getPaginationRowModel = getPaginationRowModel;
|
|
3752
3755
|
exports.getSortedRowModel = getSortedRowModel;
|
|
3753
3756
|
exports.isFunction = isFunction;
|
|
3757
|
+
exports.isNumberArray = isNumberArray;
|
|
3754
3758
|
exports.isRowSelected = isRowSelected;
|
|
3755
3759
|
exports.isSubRowSelected = isSubRowSelected;
|
|
3756
3760
|
exports.makeStateUpdater = makeStateUpdater;
|