@tanstack/react-table 8.0.0-alpha.84 → 8.0.0-alpha.87
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 +117 -131
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +118 -131
- 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 +117 -131
- 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
|
@@ -827,7 +827,6 @@ const Expanding = {
|
|
|
827
827
|
return {
|
|
828
828
|
onExpandedChange: makeStateUpdater('expanded', instance),
|
|
829
829
|
autoResetExpanded: true,
|
|
830
|
-
expandSubRows: true,
|
|
831
830
|
paginateExpandedRows: true
|
|
832
831
|
};
|
|
833
832
|
},
|
|
@@ -1224,8 +1223,7 @@ const Filters = {
|
|
|
1224
1223
|
createRow: (row, instance) => {
|
|
1225
1224
|
return {
|
|
1226
1225
|
columnFilters: {},
|
|
1227
|
-
columnFiltersMeta: {}
|
|
1228
|
-
subRowsByFacetId: {}
|
|
1226
|
+
columnFiltersMeta: {}
|
|
1229
1227
|
};
|
|
1230
1228
|
},
|
|
1231
1229
|
createInstance: instance => {
|
|
@@ -1316,53 +1314,42 @@ function shouldAutoRemoveFilter(filterFn, value, column) {
|
|
|
1316
1314
|
return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
|
|
1317
1315
|
}
|
|
1318
1316
|
|
|
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) {
|
|
1317
|
+
const sum = (columnId, _leafRows, childRows) => {
|
|
1332
1318
|
// It's faster to just add the aggregations together instead of
|
|
1333
1319
|
// process leaf nodes individually
|
|
1334
|
-
return
|
|
1335
|
-
}
|
|
1320
|
+
return childRows.reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
|
|
1321
|
+
};
|
|
1336
1322
|
|
|
1337
|
-
|
|
1323
|
+
const min = (columnId, _leafRows, childRows) => {
|
|
1338
1324
|
let min;
|
|
1325
|
+
childRows.forEach(row => {
|
|
1326
|
+
const value = row.getValue(columnId);
|
|
1339
1327
|
|
|
1340
|
-
for (const value of getChildValues()) {
|
|
1341
1328
|
if (value != null && (min > value || min === undefined && value >= value)) {
|
|
1342
1329
|
min = value;
|
|
1343
1330
|
}
|
|
1344
|
-
}
|
|
1345
|
-
|
|
1331
|
+
});
|
|
1346
1332
|
return min;
|
|
1347
|
-
}
|
|
1333
|
+
};
|
|
1348
1334
|
|
|
1349
|
-
|
|
1335
|
+
const max = (columnId, _leafRows, childRows) => {
|
|
1350
1336
|
let max;
|
|
1337
|
+
childRows.forEach(row => {
|
|
1338
|
+
const value = row.getValue(columnId);
|
|
1351
1339
|
|
|
1352
|
-
for (const value of getChildValues()) {
|
|
1353
1340
|
if (value != null && (max < value || max === undefined && value >= value)) {
|
|
1354
1341
|
max = value;
|
|
1355
1342
|
}
|
|
1356
|
-
}
|
|
1357
|
-
|
|
1343
|
+
});
|
|
1358
1344
|
return max;
|
|
1359
|
-
}
|
|
1345
|
+
};
|
|
1360
1346
|
|
|
1361
|
-
|
|
1347
|
+
const extent = (columnId, _leafRows, childRows) => {
|
|
1362
1348
|
let min;
|
|
1363
1349
|
let max;
|
|
1350
|
+
childRows.forEach(row => {
|
|
1351
|
+
const value = row.getValue(columnId);
|
|
1364
1352
|
|
|
1365
|
-
for (const value of getChildValues()) {
|
|
1366
1353
|
if (value != null) {
|
|
1367
1354
|
if (min === undefined) {
|
|
1368
1355
|
if (value >= value) min = max = value;
|
|
@@ -1371,54 +1358,65 @@ function extent(_getLeafValues, getChildValues) {
|
|
|
1371
1358
|
if (max < value) max = value;
|
|
1372
1359
|
}
|
|
1373
1360
|
}
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1361
|
+
});
|
|
1376
1362
|
return [min, max];
|
|
1377
|
-
}
|
|
1363
|
+
};
|
|
1378
1364
|
|
|
1379
|
-
|
|
1365
|
+
const mean = (columnId, leafRows) => {
|
|
1380
1366
|
let count = 0;
|
|
1381
1367
|
let sum = 0;
|
|
1368
|
+
leafRows.forEach(row => {
|
|
1369
|
+
let value = row.getValue(columnId);
|
|
1382
1370
|
|
|
1383
|
-
for (let value of getLeafValues()) {
|
|
1384
1371
|
if (value != null && (value = +value) >= value) {
|
|
1385
1372
|
++count, sum += value;
|
|
1386
1373
|
}
|
|
1387
|
-
}
|
|
1388
|
-
|
|
1374
|
+
});
|
|
1389
1375
|
if (count) return sum / count;
|
|
1390
1376
|
return;
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
|
-
function median(getLeafValues) {
|
|
1394
|
-
const leafValues = getLeafValues();
|
|
1377
|
+
};
|
|
1395
1378
|
|
|
1396
|
-
|
|
1379
|
+
const median = (columnId, leafRows) => {
|
|
1380
|
+
if (!leafRows.length) {
|
|
1397
1381
|
return;
|
|
1398
1382
|
}
|
|
1399
1383
|
|
|
1400
1384
|
let min = 0;
|
|
1401
1385
|
let max = 0;
|
|
1402
|
-
|
|
1386
|
+
leafRows.forEach(row => {
|
|
1387
|
+
let value = row.getValue(columnId);
|
|
1388
|
+
|
|
1403
1389
|
if (typeof value === 'number') {
|
|
1404
1390
|
min = Math.min(min, value);
|
|
1405
1391
|
max = Math.max(max, value);
|
|
1406
1392
|
}
|
|
1407
1393
|
});
|
|
1408
1394
|
return (min + max) / 2;
|
|
1409
|
-
}
|
|
1395
|
+
};
|
|
1410
1396
|
|
|
1411
|
-
|
|
1412
|
-
return Array.from(new Set(
|
|
1413
|
-
}
|
|
1397
|
+
const unique = (columnId, leafRows) => {
|
|
1398
|
+
return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
|
|
1399
|
+
};
|
|
1414
1400
|
|
|
1415
|
-
|
|
1416
|
-
return new Set(
|
|
1417
|
-
}
|
|
1401
|
+
const uniqueCount = (columnId, leafRows) => {
|
|
1402
|
+
return new Set(leafRows.map(d => d.getValue(columnId))).size;
|
|
1403
|
+
};
|
|
1418
1404
|
|
|
1419
|
-
|
|
1420
|
-
return
|
|
1421
|
-
}
|
|
1405
|
+
const count = (_columnId, leafRows) => {
|
|
1406
|
+
return leafRows.length;
|
|
1407
|
+
};
|
|
1408
|
+
|
|
1409
|
+
const aggregationFns = {
|
|
1410
|
+
sum,
|
|
1411
|
+
min,
|
|
1412
|
+
max,
|
|
1413
|
+
extent,
|
|
1414
|
+
mean,
|
|
1415
|
+
median,
|
|
1416
|
+
unique,
|
|
1417
|
+
uniqueCount,
|
|
1418
|
+
count
|
|
1419
|
+
};
|
|
1422
1420
|
|
|
1423
1421
|
//
|
|
1424
1422
|
const Grouping = {
|
|
@@ -1473,7 +1471,7 @@ const Grouping = {
|
|
|
1473
1471
|
column.toggleGrouping();
|
|
1474
1472
|
};
|
|
1475
1473
|
},
|
|
1476
|
-
|
|
1474
|
+
getAutoAggregationFn: () => {
|
|
1477
1475
|
const firstRow = instance.getCoreRowModel().flatRows[0];
|
|
1478
1476
|
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
|
1479
1477
|
|
|
@@ -1487,7 +1485,7 @@ const Grouping = {
|
|
|
1487
1485
|
|
|
1488
1486
|
return aggregationFns.count;
|
|
1489
1487
|
},
|
|
1490
|
-
|
|
1488
|
+
getAggregationFn: () => {
|
|
1491
1489
|
var _ref4;
|
|
1492
1490
|
|
|
1493
1491
|
const userAggregationFns = instance.options.aggregationFns;
|
|
@@ -1496,7 +1494,7 @@ const Grouping = {
|
|
|
1496
1494
|
throw new Error();
|
|
1497
1495
|
}
|
|
1498
1496
|
|
|
1499
|
-
return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.
|
|
1497
|
+
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
1498
|
}
|
|
1501
1499
|
};
|
|
1502
1500
|
},
|
|
@@ -1522,10 +1520,10 @@ const Grouping = {
|
|
|
1522
1520
|
}
|
|
1523
1521
|
};
|
|
1524
1522
|
},
|
|
1525
|
-
createRow:
|
|
1523
|
+
createRow: row => {
|
|
1526
1524
|
return {
|
|
1527
1525
|
getIsGrouped: () => !!row.groupingColumnId,
|
|
1528
|
-
|
|
1526
|
+
_groupingValuesCache: {}
|
|
1529
1527
|
};
|
|
1530
1528
|
},
|
|
1531
1529
|
createCell: (cell, column, row, instance) => {
|
|
@@ -2344,21 +2342,54 @@ function isRowSelected(row, selection, instance) {
|
|
|
2344
2342
|
}
|
|
2345
2343
|
|
|
2346
2344
|
const reSplitAlphaNumeric = /([0-9]+)/gm;
|
|
2347
|
-
const sortingFns = {
|
|
2348
|
-
alphanumeric,
|
|
2349
|
-
alphanumericCaseSensitive,
|
|
2350
|
-
text,
|
|
2351
|
-
textCaseSensitive,
|
|
2352
|
-
datetime,
|
|
2353
|
-
basic
|
|
2354
|
-
};
|
|
2355
2345
|
|
|
2356
|
-
|
|
2346
|
+
const alphanumeric = (rowA, rowB, columnId) => {
|
|
2357
2347
|
return compareAlphanumeric(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2358
|
-
}
|
|
2348
|
+
};
|
|
2359
2349
|
|
|
2360
|
-
|
|
2350
|
+
const alphanumericCaseSensitive = (rowA, rowB, columnId) => {
|
|
2361
2351
|
return compareAlphanumeric(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
2352
|
+
}; // The text filter is more basic (less numeric support)
|
|
2353
|
+
// but is much faster
|
|
2354
|
+
|
|
2355
|
+
|
|
2356
|
+
const text = (rowA, rowB, columnId) => {
|
|
2357
|
+
return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2358
|
+
}; // The text filter is more basic (less numeric support)
|
|
2359
|
+
// but is much faster
|
|
2360
|
+
|
|
2361
|
+
|
|
2362
|
+
const textCaseSensitive = (rowA, rowB, columnId) => {
|
|
2363
|
+
return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
2364
|
+
};
|
|
2365
|
+
|
|
2366
|
+
const datetime = (rowA, rowB, columnId) => {
|
|
2367
|
+
return compareBasic(rowA.getValue(columnId).getTime(), rowB.getValue(columnId).getTime());
|
|
2368
|
+
};
|
|
2369
|
+
|
|
2370
|
+
const basic = (rowA, rowB, columnId) => {
|
|
2371
|
+
return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
|
|
2372
|
+
}; // Utils
|
|
2373
|
+
|
|
2374
|
+
|
|
2375
|
+
function compareBasic(a, b) {
|
|
2376
|
+
return a === b ? 0 : a > b ? 1 : -1;
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
function toString(a) {
|
|
2380
|
+
if (typeof a === 'number') {
|
|
2381
|
+
if (isNaN(a) || a === Infinity || a === -Infinity) {
|
|
2382
|
+
return '';
|
|
2383
|
+
}
|
|
2384
|
+
|
|
2385
|
+
return String(a);
|
|
2386
|
+
}
|
|
2387
|
+
|
|
2388
|
+
if (typeof a === 'string') {
|
|
2389
|
+
return a;
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
return '';
|
|
2362
2393
|
} // Mixed sorting is slow, but very inclusive of many edge cases.
|
|
2363
2394
|
// It handles numbers, mixed alphanumeric combinations, and even
|
|
2364
2395
|
// null, undefined, and Infinity
|
|
@@ -2405,48 +2436,17 @@ function compareAlphanumeric(aStr, bStr) {
|
|
|
2405
2436
|
}
|
|
2406
2437
|
|
|
2407
2438
|
return a.length - b.length;
|
|
2408
|
-
} //
|
|
2409
|
-
// but is much faster
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
function text(rowA, rowB, columnId) {
|
|
2413
|
-
return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2414
|
-
} // The text filter is more basic (less numeric support)
|
|
2415
|
-
// but is much faster
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
function textCaseSensitive(rowA, rowB, columnId) {
|
|
2419
|
-
return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
2420
|
-
}
|
|
2421
|
-
|
|
2422
|
-
function datetime(rowA, rowB, columnId) {
|
|
2423
|
-
return compareBasic(rowA.getValue(columnId).getTime(), rowB.getValue(columnId).getTime());
|
|
2424
|
-
}
|
|
2425
|
-
|
|
2426
|
-
function basic(rowA, rowB, columnId) {
|
|
2427
|
-
return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
|
|
2428
|
-
} // Utils
|
|
2439
|
+
} // Exports
|
|
2429
2440
|
|
|
2430
2441
|
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
}
|
|
2440
|
-
|
|
2441
|
-
return String(a);
|
|
2442
|
-
}
|
|
2443
|
-
|
|
2444
|
-
if (typeof a === 'string') {
|
|
2445
|
-
return a;
|
|
2446
|
-
}
|
|
2447
|
-
|
|
2448
|
-
return '';
|
|
2449
|
-
}
|
|
2442
|
+
const sortingFns = {
|
|
2443
|
+
alphanumeric,
|
|
2444
|
+
alphanumericCaseSensitive,
|
|
2445
|
+
text,
|
|
2446
|
+
textCaseSensitive,
|
|
2447
|
+
datetime,
|
|
2448
|
+
basic
|
|
2449
|
+
};
|
|
2450
2450
|
|
|
2451
2451
|
//
|
|
2452
2452
|
const Sorting = {
|
|
@@ -2670,11 +2670,6 @@ const Visibility = {
|
|
|
2670
2670
|
onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
|
|
2671
2671
|
};
|
|
2672
2672
|
},
|
|
2673
|
-
getDefaultColumnDef: () => {
|
|
2674
|
-
return {
|
|
2675
|
-
defaultIsVisible: true
|
|
2676
|
-
};
|
|
2677
|
-
},
|
|
2678
2673
|
createColumn: (column, instance) => {
|
|
2679
2674
|
return {
|
|
2680
2675
|
toggleVisibility: value => {
|
|
@@ -3660,25 +3655,17 @@ function getGroupedRowModel() {
|
|
|
3660
3655
|
return row._valuesCache[columnId];
|
|
3661
3656
|
}
|
|
3662
3657
|
|
|
3663
|
-
if (row.
|
|
3664
|
-
return row.
|
|
3658
|
+
if (row._groupingValuesCache.hasOwnProperty(columnId)) {
|
|
3659
|
+
return row._groupingValuesCache[columnId];
|
|
3665
3660
|
} // Aggregate the values
|
|
3666
3661
|
|
|
3667
3662
|
|
|
3668
3663
|
const column = instance.getColumn(columnId);
|
|
3669
|
-
const aggregateFn = column.
|
|
3664
|
+
const aggregateFn = column.getAggregationFn();
|
|
3670
3665
|
|
|
3671
3666
|
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];
|
|
3667
|
+
row._groupingValuesCache[columnId] = aggregateFn(columnId, leafRows, groupedRows);
|
|
3668
|
+
return row._groupingValuesCache[columnId];
|
|
3682
3669
|
} else if (column.aggregationFn) {
|
|
3683
3670
|
console.info({
|
|
3684
3671
|
column
|
|
@@ -3758,7 +3745,7 @@ function getExpandedRowModel() {
|
|
|
3758
3745
|
return rowModel;
|
|
3759
3746
|
}
|
|
3760
3747
|
|
|
3761
|
-
return expandRows(rowModel
|
|
3748
|
+
return expandRows(rowModel);
|
|
3762
3749
|
}, {
|
|
3763
3750
|
key: process.env.NODE_ENV === 'development' && 'getExpandedRowModel',
|
|
3764
3751
|
debug: () => {
|
|
@@ -3776,7 +3763,7 @@ function expandRows(rowModel, instance) {
|
|
|
3776
3763
|
|
|
3777
3764
|
expandedRows.push(row);
|
|
3778
3765
|
|
|
3779
|
-
if (
|
|
3766
|
+
if ((_row$subRows = row.subRows) != null && _row$subRows.length && row.getIsExpanded()) {
|
|
3780
3767
|
row.subRows.forEach(handleRow);
|
|
3781
3768
|
}
|
|
3782
3769
|
};
|
|
@@ -3813,7 +3800,7 @@ function getPaginationRowModel(opts) {
|
|
|
3813
3800
|
rows,
|
|
3814
3801
|
flatRows,
|
|
3815
3802
|
rowsById
|
|
3816
|
-
}
|
|
3803
|
+
});
|
|
3817
3804
|
}
|
|
3818
3805
|
|
|
3819
3806
|
return {
|
|
@@ -3887,5 +3874,5 @@ function useTableInstance(table, options) {
|
|
|
3887
3874
|
return instanceRef.current;
|
|
3888
3875
|
}
|
|
3889
3876
|
|
|
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,
|
|
3877
|
+
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
3878
|
//# sourceMappingURL=index.js.map
|