@tanstack/react-table 8.0.0-alpha.84 → 8.0.0-alpha.85
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/react-table/src/index.js +0 -1
- package/build/cjs/react-table/src/index.js.map +1 -1
- package/build/cjs/table-core/build/esm/index.js +61 -71
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +62 -71
- 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 +61 -71
- 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
|
@@ -1224,8 +1224,7 @@ const Filters = {
|
|
|
1224
1224
|
createRow: (row, instance) => {
|
|
1225
1225
|
return {
|
|
1226
1226
|
columnFilters: {},
|
|
1227
|
-
columnFiltersMeta: {}
|
|
1228
|
-
subRowsByFacetId: {}
|
|
1227
|
+
columnFiltersMeta: {}
|
|
1229
1228
|
};
|
|
1230
1229
|
},
|
|
1231
1230
|
createInstance: instance => {
|
|
@@ -1316,53 +1315,42 @@ function shouldAutoRemoveFilter(filterFn, value, column) {
|
|
|
1316
1315
|
return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
|
|
1317
1316
|
}
|
|
1318
1317
|
|
|
1319
|
-
const
|
|
1320
|
-
sum,
|
|
1321
|
-
min,
|
|
1322
|
-
max,
|
|
1323
|
-
extent,
|
|
1324
|
-
mean,
|
|
1325
|
-
median,
|
|
1326
|
-
unique,
|
|
1327
|
-
uniqueCount,
|
|
1328
|
-
count
|
|
1329
|
-
};
|
|
1330
|
-
|
|
1331
|
-
function sum(_getLeafValues, getChildValues) {
|
|
1318
|
+
const sum = (columnId, _leafRows, childRows) => {
|
|
1332
1319
|
// It's faster to just add the aggregations together instead of
|
|
1333
1320
|
// process leaf nodes individually
|
|
1334
|
-
return
|
|
1335
|
-
}
|
|
1321
|
+
return childRows.reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
|
|
1322
|
+
};
|
|
1336
1323
|
|
|
1337
|
-
|
|
1324
|
+
const min = (columnId, _leafRows, childRows) => {
|
|
1338
1325
|
let min;
|
|
1326
|
+
childRows.forEach(row => {
|
|
1327
|
+
const value = row.getValue(columnId);
|
|
1339
1328
|
|
|
1340
|
-
for (const value of getChildValues()) {
|
|
1341
1329
|
if (value != null && (min > value || min === undefined && value >= value)) {
|
|
1342
1330
|
min = value;
|
|
1343
1331
|
}
|
|
1344
|
-
}
|
|
1345
|
-
|
|
1332
|
+
});
|
|
1346
1333
|
return min;
|
|
1347
|
-
}
|
|
1334
|
+
};
|
|
1348
1335
|
|
|
1349
|
-
|
|
1336
|
+
const max = (columnId, _leafRows, childRows) => {
|
|
1350
1337
|
let max;
|
|
1338
|
+
childRows.forEach(row => {
|
|
1339
|
+
const value = row.getValue(columnId);
|
|
1351
1340
|
|
|
1352
|
-
for (const value of getChildValues()) {
|
|
1353
1341
|
if (value != null && (max < value || max === undefined && value >= value)) {
|
|
1354
1342
|
max = value;
|
|
1355
1343
|
}
|
|
1356
|
-
}
|
|
1357
|
-
|
|
1344
|
+
});
|
|
1358
1345
|
return max;
|
|
1359
|
-
}
|
|
1346
|
+
};
|
|
1360
1347
|
|
|
1361
|
-
|
|
1348
|
+
const extent = (columnId, _leafRows, childRows) => {
|
|
1362
1349
|
let min;
|
|
1363
1350
|
let max;
|
|
1351
|
+
childRows.forEach(row => {
|
|
1352
|
+
const value = row.getValue(columnId);
|
|
1364
1353
|
|
|
1365
|
-
for (const value of getChildValues()) {
|
|
1366
1354
|
if (value != null) {
|
|
1367
1355
|
if (min === undefined) {
|
|
1368
1356
|
if (value >= value) min = max = value;
|
|
@@ -1371,54 +1359,65 @@ function extent(_getLeafValues, getChildValues) {
|
|
|
1371
1359
|
if (max < value) max = value;
|
|
1372
1360
|
}
|
|
1373
1361
|
}
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1362
|
+
});
|
|
1376
1363
|
return [min, max];
|
|
1377
|
-
}
|
|
1364
|
+
};
|
|
1378
1365
|
|
|
1379
|
-
|
|
1366
|
+
const mean = (columnId, leafRows) => {
|
|
1380
1367
|
let count = 0;
|
|
1381
1368
|
let sum = 0;
|
|
1369
|
+
leafRows.forEach(row => {
|
|
1370
|
+
let value = row.getValue(columnId);
|
|
1382
1371
|
|
|
1383
|
-
for (let value of getLeafValues()) {
|
|
1384
1372
|
if (value != null && (value = +value) >= value) {
|
|
1385
1373
|
++count, sum += value;
|
|
1386
1374
|
}
|
|
1387
|
-
}
|
|
1388
|
-
|
|
1375
|
+
});
|
|
1389
1376
|
if (count) return sum / count;
|
|
1390
1377
|
return;
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
|
-
function median(getLeafValues) {
|
|
1394
|
-
const leafValues = getLeafValues();
|
|
1378
|
+
};
|
|
1395
1379
|
|
|
1396
|
-
|
|
1380
|
+
const median = (columnId, leafRows) => {
|
|
1381
|
+
if (!leafRows.length) {
|
|
1397
1382
|
return;
|
|
1398
1383
|
}
|
|
1399
1384
|
|
|
1400
1385
|
let min = 0;
|
|
1401
1386
|
let max = 0;
|
|
1402
|
-
|
|
1387
|
+
leafRows.forEach(row => {
|
|
1388
|
+
let value = row.getValue(columnId);
|
|
1389
|
+
|
|
1403
1390
|
if (typeof value === 'number') {
|
|
1404
1391
|
min = Math.min(min, value);
|
|
1405
1392
|
max = Math.max(max, value);
|
|
1406
1393
|
}
|
|
1407
1394
|
});
|
|
1408
1395
|
return (min + max) / 2;
|
|
1409
|
-
}
|
|
1396
|
+
};
|
|
1410
1397
|
|
|
1411
|
-
|
|
1412
|
-
return Array.from(new Set(
|
|
1413
|
-
}
|
|
1398
|
+
const unique = (columnId, leafRows) => {
|
|
1399
|
+
return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
|
|
1400
|
+
};
|
|
1414
1401
|
|
|
1415
|
-
|
|
1416
|
-
return new Set(
|
|
1417
|
-
}
|
|
1402
|
+
const uniqueCount = (columnId, leafRows) => {
|
|
1403
|
+
return new Set(leafRows.map(d => d.getValue(columnId))).size;
|
|
1404
|
+
};
|
|
1418
1405
|
|
|
1419
|
-
|
|
1420
|
-
return
|
|
1421
|
-
}
|
|
1406
|
+
const count = (_columnId, leafRows) => {
|
|
1407
|
+
return leafRows.length;
|
|
1408
|
+
};
|
|
1409
|
+
|
|
1410
|
+
const aggregationFns = {
|
|
1411
|
+
sum,
|
|
1412
|
+
min,
|
|
1413
|
+
max,
|
|
1414
|
+
extent,
|
|
1415
|
+
mean,
|
|
1416
|
+
median,
|
|
1417
|
+
unique,
|
|
1418
|
+
uniqueCount,
|
|
1419
|
+
count
|
|
1420
|
+
};
|
|
1422
1421
|
|
|
1423
1422
|
//
|
|
1424
1423
|
const Grouping = {
|
|
@@ -1473,7 +1472,7 @@ const Grouping = {
|
|
|
1473
1472
|
column.toggleGrouping();
|
|
1474
1473
|
};
|
|
1475
1474
|
},
|
|
1476
|
-
|
|
1475
|
+
getAutoAggregationFn: () => {
|
|
1477
1476
|
const firstRow = instance.getCoreRowModel().flatRows[0];
|
|
1478
1477
|
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
|
1479
1478
|
|
|
@@ -1487,7 +1486,7 @@ const Grouping = {
|
|
|
1487
1486
|
|
|
1488
1487
|
return aggregationFns.count;
|
|
1489
1488
|
},
|
|
1490
|
-
|
|
1489
|
+
getAggregationFn: () => {
|
|
1491
1490
|
var _ref4;
|
|
1492
1491
|
|
|
1493
1492
|
const userAggregationFns = instance.options.aggregationFns;
|
|
@@ -1496,7 +1495,7 @@ const Grouping = {
|
|
|
1496
1495
|
throw new Error();
|
|
1497
1496
|
}
|
|
1498
1497
|
|
|
1499
|
-
return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.
|
|
1498
|
+
return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_ref4 = userAggregationFns == null ? void 0 : userAggregationFns[column.aggregationFn]) != null ? _ref4 : aggregationFns[column.aggregationFn];
|
|
1500
1499
|
}
|
|
1501
1500
|
};
|
|
1502
1501
|
},
|
|
@@ -1522,10 +1521,10 @@ const Grouping = {
|
|
|
1522
1521
|
}
|
|
1523
1522
|
};
|
|
1524
1523
|
},
|
|
1525
|
-
createRow:
|
|
1524
|
+
createRow: row => {
|
|
1526
1525
|
return {
|
|
1527
1526
|
getIsGrouped: () => !!row.groupingColumnId,
|
|
1528
|
-
|
|
1527
|
+
_groupingValuesCache: {}
|
|
1529
1528
|
};
|
|
1530
1529
|
},
|
|
1531
1530
|
createCell: (cell, column, row, instance) => {
|
|
@@ -3660,25 +3659,17 @@ function getGroupedRowModel() {
|
|
|
3660
3659
|
return row._valuesCache[columnId];
|
|
3661
3660
|
}
|
|
3662
3661
|
|
|
3663
|
-
if (row.
|
|
3664
|
-
return row.
|
|
3662
|
+
if (row._groupingValuesCache.hasOwnProperty(columnId)) {
|
|
3663
|
+
return row._groupingValuesCache[columnId];
|
|
3665
3664
|
} // Aggregate the values
|
|
3666
3665
|
|
|
3667
3666
|
|
|
3668
3667
|
const column = instance.getColumn(columnId);
|
|
3669
|
-
const aggregateFn = column.
|
|
3668
|
+
const aggregateFn = column.getAggregationFn();
|
|
3670
3669
|
|
|
3671
3670
|
if (aggregateFn) {
|
|
3672
|
-
row.
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
if (!depth && column.columnDef.aggregateValue) {
|
|
3676
|
-
columnValue = column.columnDef.aggregateValue(columnValue);
|
|
3677
|
-
}
|
|
3678
|
-
|
|
3679
|
-
return columnValue;
|
|
3680
|
-
}), () => groupedRows.map(row => row.getValue(columnId)));
|
|
3681
|
-
return row.groupingValuesCache[columnId];
|
|
3671
|
+
row._groupingValuesCache[columnId] = aggregateFn(columnId, leafRows, groupedRows);
|
|
3672
|
+
return row._groupingValuesCache[columnId];
|
|
3682
3673
|
} else if (column.aggregationFn) {
|
|
3683
3674
|
console.info({
|
|
3684
3675
|
column
|
|
@@ -3887,5 +3878,5 @@ function useTableInstance(table, options) {
|
|
|
3887
3878
|
return instanceRef.current;
|
|
3888
3879
|
}
|
|
3889
3880
|
|
|
3890
|
-
export { ColumnSizing, Expanding, Filters, Grouping, Headers, Ordering, Pagination, Pinning, RowSelection, Sorting, Visibility, aggregationFns, buildHeaderGroups, createColumn, createRow, createTable, createTableFactory, createTableInstance, defaultColumnSizing, expandRows, filterFns, flattenBy, functionalUpdate, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, isFunction, isRowSelected, makeStateUpdater,
|
|
3881
|
+
export { ColumnSizing, Expanding, Filters, Grouping, Headers, Ordering, Pagination, Pinning, RowSelection, Sorting, Visibility, aggregationFns, buildHeaderGroups, createColumn, createRow, createTable, createTableFactory, createTableInstance, defaultColumnSizing, expandRows, filterFns, flattenBy, functionalUpdate, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, isFunction, isRowSelected, makeStateUpdater, memo, noop, orderColumns, passiveEventSupported, reSplitAlphaNumeric, render, selectRowsFn, shouldAutoRemoveFilter, sortingFns, useTableInstance };
|
|
3891
3882
|
//# sourceMappingURL=index.js.map
|