@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.
@@ -2669,7 +2669,7 @@ var drawChart = (function (exports) {
2669
2669
  </script>
2670
2670
  <script>
2671
2671
  /*<!--*/
2672
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"name":"packages","children":[{"name":"table-core/build/esm/index.js","uid":"137d-127"},{"name":"react-table/src/index.tsx","uid":"137d-129"}]}]}],"isRoot":true},"nodeParts":{"137d-127":{"renderedLength":137713,"gzipLength":23466,"brotliLength":0,"mainUid":"137d-126"},"137d-129":{"renderedLength":2102,"gzipLength":836,"brotliLength":0,"mainUid":"137d-128"}},"nodeMetas":{"137d-126":{"id":"/packages/table-core/build/esm/index.js","moduleParts":{"index.production.js":"137d-127"},"imported":[],"importedBy":[{"uid":"137d-128"}]},"137d-128":{"id":"/packages/react-table/src/index.tsx","moduleParts":{"index.production.js":"137d-129"},"imported":[{"uid":"137d-130"},{"uid":"137d-126"}],"importedBy":[],"isEntry":true},"137d-130":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"137d-128"}],"isExternal":true}},"env":{"rollup":"2.70.2"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
2672
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"name":"packages","children":[{"name":"table-core/build/esm/index.js","uid":"ddcf-127"},{"name":"react-table/src/index.tsx","uid":"ddcf-129"}]}]}],"isRoot":true},"nodeParts":{"ddcf-127":{"renderedLength":137536,"gzipLength":23386,"brotliLength":0,"mainUid":"ddcf-126"},"ddcf-129":{"renderedLength":2102,"gzipLength":836,"brotliLength":0,"mainUid":"ddcf-128"}},"nodeMetas":{"ddcf-126":{"id":"/packages/table-core/build/esm/index.js","moduleParts":{"index.production.js":"ddcf-127"},"imported":[],"importedBy":[{"uid":"ddcf-128"}]},"ddcf-128":{"id":"/packages/react-table/src/index.tsx","moduleParts":{"index.production.js":"ddcf-129"},"imported":[{"uid":"ddcf-130"},{"uid":"ddcf-126"}],"importedBy":[],"isEntry":true},"ddcf-130":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"ddcf-128"}],"isExternal":true}},"env":{"rollup":"2.70.2"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
2673
2673
 
2674
2674
  const run = () => {
2675
2675
  const width = window.innerWidth;
@@ -11,11 +11,11 @@
11
11
  "children": [
12
12
  {
13
13
  "name": "table-core/build/esm/index.js",
14
- "uid": "137d-132"
14
+ "uid": "ddcf-132"
15
15
  },
16
16
  {
17
17
  "name": "react-table/src/index.tsx",
18
- "uid": "137d-134"
18
+ "uid": "ddcf-134"
19
19
  }
20
20
  ]
21
21
  }
@@ -25,55 +25,55 @@
25
25
  "isRoot": true
26
26
  },
27
27
  "nodeParts": {
28
- "137d-132": {
29
- "renderedLength": 137713,
30
- "gzipLength": 23466,
28
+ "ddcf-132": {
29
+ "renderedLength": 137536,
30
+ "gzipLength": 23386,
31
31
  "brotliLength": 0,
32
- "mainUid": "137d-131"
32
+ "mainUid": "ddcf-131"
33
33
  },
34
- "137d-134": {
34
+ "ddcf-134": {
35
35
  "renderedLength": 2102,
36
36
  "gzipLength": 836,
37
37
  "brotliLength": 0,
38
- "mainUid": "137d-133"
38
+ "mainUid": "ddcf-133"
39
39
  }
40
40
  },
41
41
  "nodeMetas": {
42
- "137d-131": {
42
+ "ddcf-131": {
43
43
  "id": "/packages/table-core/build/esm/index.js",
44
44
  "moduleParts": {
45
- "index.production.js": "137d-132"
45
+ "index.production.js": "ddcf-132"
46
46
  },
47
47
  "imported": [],
48
48
  "importedBy": [
49
49
  {
50
- "uid": "137d-133"
50
+ "uid": "ddcf-133"
51
51
  }
52
52
  ]
53
53
  },
54
- "137d-133": {
54
+ "ddcf-133": {
55
55
  "id": "/packages/react-table/src/index.tsx",
56
56
  "moduleParts": {
57
- "index.production.js": "137d-134"
57
+ "index.production.js": "ddcf-134"
58
58
  },
59
59
  "imported": [
60
60
  {
61
- "uid": "137d-135"
61
+ "uid": "ddcf-135"
62
62
  },
63
63
  {
64
- "uid": "137d-131"
64
+ "uid": "ddcf-131"
65
65
  }
66
66
  ],
67
67
  "importedBy": [],
68
68
  "isEntry": true
69
69
  },
70
- "137d-135": {
70
+ "ddcf-135": {
71
71
  "id": "react",
72
72
  "moduleParts": {},
73
73
  "imported": [],
74
74
  "importedBy": [
75
75
  {
76
- "uid": "137d-133"
76
+ "uid": "ddcf-133"
77
77
  }
78
78
  ],
79
79
  "isExternal": true
@@ -1246,8 +1246,7 @@
1246
1246
  createRow: (row, instance) => {
1247
1247
  return {
1248
1248
  columnFilters: {},
1249
- columnFiltersMeta: {},
1250
- subRowsByFacetId: {}
1249
+ columnFiltersMeta: {}
1251
1250
  };
1252
1251
  },
1253
1252
  createInstance: instance => {
@@ -1338,53 +1337,42 @@
1338
1337
  return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
1339
1338
  }
1340
1339
 
1341
- const aggregationFns = {
1342
- sum,
1343
- min,
1344
- max,
1345
- extent,
1346
- mean,
1347
- median,
1348
- unique,
1349
- uniqueCount,
1350
- count
1351
- };
1352
-
1353
- function sum(_getLeafValues, getChildValues) {
1340
+ const sum = (columnId, _leafRows, childRows) => {
1354
1341
  // It's faster to just add the aggregations together instead of
1355
1342
  // process leaf nodes individually
1356
- return getChildValues().reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
1357
- }
1343
+ return childRows.reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
1344
+ };
1358
1345
 
1359
- function min(_getLeafValues, getChildValues) {
1346
+ const min = (columnId, _leafRows, childRows) => {
1360
1347
  let min;
1348
+ childRows.forEach(row => {
1349
+ const value = row.getValue(columnId);
1361
1350
 
1362
- for (const value of getChildValues()) {
1363
1351
  if (value != null && (min > value || min === undefined && value >= value)) {
1364
1352
  min = value;
1365
1353
  }
1366
- }
1367
-
1354
+ });
1368
1355
  return min;
1369
- }
1356
+ };
1370
1357
 
1371
- function max(_getLeafValues, getChildValues) {
1358
+ const max = (columnId, _leafRows, childRows) => {
1372
1359
  let max;
1360
+ childRows.forEach(row => {
1361
+ const value = row.getValue(columnId);
1373
1362
 
1374
- for (const value of getChildValues()) {
1375
1363
  if (value != null && (max < value || max === undefined && value >= value)) {
1376
1364
  max = value;
1377
1365
  }
1378
- }
1379
-
1366
+ });
1380
1367
  return max;
1381
- }
1368
+ };
1382
1369
 
1383
- function extent(_getLeafValues, getChildValues) {
1370
+ const extent = (columnId, _leafRows, childRows) => {
1384
1371
  let min;
1385
1372
  let max;
1373
+ childRows.forEach(row => {
1374
+ const value = row.getValue(columnId);
1386
1375
 
1387
- for (const value of getChildValues()) {
1388
1376
  if (value != null) {
1389
1377
  if (min === undefined) {
1390
1378
  if (value >= value) min = max = value;
@@ -1393,54 +1381,65 @@
1393
1381
  if (max < value) max = value;
1394
1382
  }
1395
1383
  }
1396
- }
1397
-
1384
+ });
1398
1385
  return [min, max];
1399
- }
1386
+ };
1400
1387
 
1401
- function mean(getLeafValues) {
1388
+ const mean = (columnId, leafRows) => {
1402
1389
  let count = 0;
1403
1390
  let sum = 0;
1391
+ leafRows.forEach(row => {
1392
+ let value = row.getValue(columnId);
1404
1393
 
1405
- for (let value of getLeafValues()) {
1406
1394
  if (value != null && (value = +value) >= value) {
1407
1395
  ++count, sum += value;
1408
1396
  }
1409
- }
1410
-
1397
+ });
1411
1398
  if (count) return sum / count;
1412
1399
  return;
1413
- }
1414
-
1415
- function median(getLeafValues) {
1416
- const leafValues = getLeafValues();
1400
+ };
1417
1401
 
1418
- if (!leafValues.length) {
1402
+ const median = (columnId, leafRows) => {
1403
+ if (!leafRows.length) {
1419
1404
  return;
1420
1405
  }
1421
1406
 
1422
1407
  let min = 0;
1423
1408
  let max = 0;
1424
- leafValues.forEach(value => {
1409
+ leafRows.forEach(row => {
1410
+ let value = row.getValue(columnId);
1411
+
1425
1412
  if (typeof value === 'number') {
1426
1413
  min = Math.min(min, value);
1427
1414
  max = Math.max(max, value);
1428
1415
  }
1429
1416
  });
1430
1417
  return (min + max) / 2;
1431
- }
1418
+ };
1432
1419
 
1433
- function unique(getLeafValues) {
1434
- return Array.from(new Set(getLeafValues()).values());
1435
- }
1420
+ const unique = (columnId, leafRows) => {
1421
+ return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
1422
+ };
1436
1423
 
1437
- function uniqueCount(getLeafValues) {
1438
- return new Set(getLeafValues()).size;
1439
- }
1424
+ const uniqueCount = (columnId, leafRows) => {
1425
+ return new Set(leafRows.map(d => d.getValue(columnId))).size;
1426
+ };
1440
1427
 
1441
- function count(getLeafValues) {
1442
- return getLeafValues().length;
1443
- }
1428
+ const count = (_columnId, leafRows) => {
1429
+ return leafRows.length;
1430
+ };
1431
+
1432
+ const aggregationFns = {
1433
+ sum,
1434
+ min,
1435
+ max,
1436
+ extent,
1437
+ mean,
1438
+ median,
1439
+ unique,
1440
+ uniqueCount,
1441
+ count
1442
+ };
1444
1443
 
1445
1444
  //
1446
1445
  const Grouping = {
@@ -1495,7 +1494,7 @@
1495
1494
  column.toggleGrouping();
1496
1495
  };
1497
1496
  },
1498
- getColumnAutoAggregationFn: () => {
1497
+ getAutoAggregationFn: () => {
1499
1498
  const firstRow = instance.getCoreRowModel().flatRows[0];
1500
1499
  const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
1501
1500
 
@@ -1509,7 +1508,7 @@
1509
1508
 
1510
1509
  return aggregationFns.count;
1511
1510
  },
1512
- getColumnAggregationFn: () => {
1511
+ getAggregationFn: () => {
1513
1512
  var _ref4;
1514
1513
 
1515
1514
  const userAggregationFns = instance.options.aggregationFns;
@@ -1518,7 +1517,7 @@
1518
1517
  throw new Error();
1519
1518
  }
1520
1519
 
1521
- return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.getColumnAutoAggregationFn() : (_ref4 = userAggregationFns == null ? void 0 : userAggregationFns[column.aggregationFn]) != null ? _ref4 : aggregationFns[column.aggregationFn];
1520
+ return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_ref4 = userAggregationFns == null ? void 0 : userAggregationFns[column.aggregationFn]) != null ? _ref4 : aggregationFns[column.aggregationFn];
1522
1521
  }
1523
1522
  };
1524
1523
  },
@@ -1544,10 +1543,10 @@
1544
1543
  }
1545
1544
  };
1546
1545
  },
1547
- createRow: (row, instance) => {
1546
+ createRow: row => {
1548
1547
  return {
1549
1548
  getIsGrouped: () => !!row.groupingColumnId,
1550
- groupingValuesCache: {}
1549
+ _groupingValuesCache: {}
1551
1550
  };
1552
1551
  },
1553
1552
  createCell: (cell, column, row, instance) => {
@@ -3680,25 +3679,17 @@
3680
3679
  return row._valuesCache[columnId];
3681
3680
  }
3682
3681
 
3683
- if (row.groupingValuesCache.hasOwnProperty(columnId)) {
3684
- return row.groupingValuesCache[columnId];
3682
+ if (row._groupingValuesCache.hasOwnProperty(columnId)) {
3683
+ return row._groupingValuesCache[columnId];
3685
3684
  } // Aggregate the values
3686
3685
 
3687
3686
 
3688
3687
  const column = instance.getColumn(columnId);
3689
- const aggregateFn = column.getColumnAggregationFn();
3688
+ const aggregateFn = column.getAggregationFn();
3690
3689
 
3691
3690
  if (aggregateFn) {
3692
- row.groupingValuesCache[columnId] = aggregateFn(() => leafRows.map(row => {
3693
- let columnValue = row.getValue(columnId);
3694
-
3695
- if (!depth && column.columnDef.aggregateValue) {
3696
- columnValue = column.columnDef.aggregateValue(columnValue);
3697
- }
3698
-
3699
- return columnValue;
3700
- }), () => groupedRows.map(row => row.getValue(columnId)));
3701
- return row.groupingValuesCache[columnId];
3691
+ row._groupingValuesCache[columnId] = aggregateFn(columnId, leafRows, groupedRows);
3692
+ return row._groupingValuesCache[columnId];
3702
3693
  } else if (column.aggregationFn) {
3703
3694
  console.info({
3704
3695
  column
@@ -3942,7 +3933,6 @@
3942
3933
  exports.isFunction = isFunction;
3943
3934
  exports.isRowSelected = isRowSelected;
3944
3935
  exports.makeStateUpdater = makeStateUpdater;
3945
- exports.mean = mean;
3946
3936
  exports.memo = memo;
3947
3937
  exports.noop = noop;
3948
3938
  exports.orderColumns = orderColumns;