@tanstack/svelte-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.
|
@@ -49,6 +49,9 @@
|
|
|
49
49
|
function isFunction(d) {
|
|
50
50
|
return d instanceof Function;
|
|
51
51
|
}
|
|
52
|
+
function isNumberArray(d) {
|
|
53
|
+
return Array.isArray(d) && d.every(val => typeof val === 'number');
|
|
54
|
+
}
|
|
52
55
|
function flattenBy(arr, getChildren) {
|
|
53
56
|
const flat = [];
|
|
54
57
|
const recurse = subArr => {
|
|
@@ -1295,16 +1298,16 @@
|
|
|
1295
1298
|
if (!leafRows.length) {
|
|
1296
1299
|
return;
|
|
1297
1300
|
}
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
return (
|
|
1301
|
+
const values = leafRows.map(row => row.getValue(columnId));
|
|
1302
|
+
if (!isNumberArray(values)) {
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1305
|
+
if (values.length === 1) {
|
|
1306
|
+
return values[0];
|
|
1307
|
+
}
|
|
1308
|
+
const mid = Math.floor(values.length / 2);
|
|
1309
|
+
const nums = values.sort((a, b) => a - b);
|
|
1310
|
+
return values.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
|
|
1308
1311
|
};
|
|
1309
1312
|
const unique = (columnId, leafRows) => {
|
|
1310
1313
|
return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
|
|
@@ -3860,6 +3863,7 @@
|
|
|
3860
3863
|
exports.getPaginationRowModel = getPaginationRowModel;
|
|
3861
3864
|
exports.getSortedRowModel = getSortedRowModel;
|
|
3862
3865
|
exports.isFunction = isFunction;
|
|
3866
|
+
exports.isNumberArray = isNumberArray;
|
|
3863
3867
|
exports.isRowSelected = isRowSelected;
|
|
3864
3868
|
exports.isSubRowSelected = isSubRowSelected;
|
|
3865
3869
|
exports.makeStateUpdater = makeStateUpdater;
|