@tanstack/svelte-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-163"},{"name":"svelte-table/src","children":[{"uid":"137d-165","name":"placeholder.svelte"},{"uid":"137d-167","name":"render-component.ts"},{"uid":"137d-169","name":"index.ts"}]}]}]}],"isRoot":true},"nodeParts":{"137d-163":{"renderedLength":137715,"gzipLength":23468,"brotliLength":0,"mainUid":"137d-162"},"137d-165":{"renderedLength":925,"gzipLength":444,"brotliLength":0,"mainUid":"137d-164"},"137d-167":{"renderedLength":1365,"gzipLength":519,"brotliLength":0,"mainUid":"137d-166"},"137d-169":{"renderedLength":2729,"gzipLength":868,"brotliLength":0,"mainUid":"137d-168"}},"nodeMetas":{"137d-162":{"id":"/packages/table-core/build/esm/index.js","moduleParts":{"index.production.js":"137d-163"},"imported":[],"importedBy":[{"uid":"137d-168"}]},"137d-164":{"id":"/packages/svelte-table/src/placeholder.svelte","moduleParts":{"index.production.js":"137d-165"},"imported":[{"uid":"137d-170"}],"importedBy":[{"uid":"137d-168"}]},"137d-166":{"id":"/packages/svelte-table/src/render-component.ts","moduleParts":{"index.production.js":"137d-167"},"imported":[{"uid":"137d-170"}],"importedBy":[{"uid":"137d-168"}]},"137d-168":{"id":"/packages/svelte-table/src/index.ts","moduleParts":{"index.production.js":"137d-169"},"imported":[{"uid":"137d-162"},{"uid":"137d-164"},{"uid":"137d-170"},{"uid":"137d-171"},{"uid":"137d-166"}],"importedBy":[],"isEntry":true},"137d-170":{"id":"svelte/internal","moduleParts":{},"imported":[],"importedBy":[{"uid":"137d-168"},{"uid":"137d-164"},{"uid":"137d-166"}],"isExternal":true},"137d-171":{"id":"svelte/store","moduleParts":{},"imported":[],"importedBy":[{"uid":"137d-168"}],"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-163"},{"name":"svelte-table/src","children":[{"uid":"ddcf-165","name":"placeholder.svelte"},{"uid":"ddcf-167","name":"render-component.ts"},{"uid":"ddcf-169","name":"index.ts"}]}]}]}],"isRoot":true},"nodeParts":{"ddcf-163":{"renderedLength":137538,"gzipLength":23388,"brotliLength":0,"mainUid":"ddcf-162"},"ddcf-165":{"renderedLength":925,"gzipLength":444,"brotliLength":0,"mainUid":"ddcf-164"},"ddcf-167":{"renderedLength":1365,"gzipLength":519,"brotliLength":0,"mainUid":"ddcf-166"},"ddcf-169":{"renderedLength":2729,"gzipLength":868,"brotliLength":0,"mainUid":"ddcf-168"}},"nodeMetas":{"ddcf-162":{"id":"/packages/table-core/build/esm/index.js","moduleParts":{"index.production.js":"ddcf-163"},"imported":[],"importedBy":[{"uid":"ddcf-168"}]},"ddcf-164":{"id":"/packages/svelte-table/src/placeholder.svelte","moduleParts":{"index.production.js":"ddcf-165"},"imported":[{"uid":"ddcf-170"}],"importedBy":[{"uid":"ddcf-168"}]},"ddcf-166":{"id":"/packages/svelte-table/src/render-component.ts","moduleParts":{"index.production.js":"ddcf-167"},"imported":[{"uid":"ddcf-170"}],"importedBy":[{"uid":"ddcf-168"}]},"ddcf-168":{"id":"/packages/svelte-table/src/index.ts","moduleParts":{"index.production.js":"ddcf-169"},"imported":[{"uid":"ddcf-162"},{"uid":"ddcf-164"},{"uid":"ddcf-170"},{"uid":"ddcf-171"},{"uid":"ddcf-166"}],"importedBy":[],"isEntry":true},"ddcf-170":{"id":"svelte/internal","moduleParts":{},"imported":[],"importedBy":[{"uid":"ddcf-168"},{"uid":"ddcf-164"},{"uid":"ddcf-166"}],"isExternal":true},"ddcf-171":{"id":"svelte/store","moduleParts":{},"imported":[],"importedBy":[{"uid":"ddcf-168"}],"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,21 +11,21 @@
11
11
  "children": [
12
12
  {
13
13
  "name": "table-core/build/esm/index.js",
14
- "uid": "137d-173"
14
+ "uid": "ddcf-173"
15
15
  },
16
16
  {
17
17
  "name": "svelte-table/src",
18
18
  "children": [
19
19
  {
20
- "uid": "137d-175",
20
+ "uid": "ddcf-175",
21
21
  "name": "placeholder.svelte"
22
22
  },
23
23
  {
24
- "uid": "137d-177",
24
+ "uid": "ddcf-177",
25
25
  "name": "render-component.ts"
26
26
  },
27
27
  {
28
- "uid": "137d-179",
28
+ "uid": "ddcf-179",
29
29
  "name": "index.ts"
30
30
  }
31
31
  ]
@@ -38,125 +38,125 @@
38
38
  "isRoot": true
39
39
  },
40
40
  "nodeParts": {
41
- "137d-173": {
42
- "renderedLength": 137715,
43
- "gzipLength": 23468,
41
+ "ddcf-173": {
42
+ "renderedLength": 137538,
43
+ "gzipLength": 23388,
44
44
  "brotliLength": 0,
45
- "mainUid": "137d-172"
45
+ "mainUid": "ddcf-172"
46
46
  },
47
- "137d-175": {
47
+ "ddcf-175": {
48
48
  "renderedLength": 925,
49
49
  "gzipLength": 444,
50
50
  "brotliLength": 0,
51
- "mainUid": "137d-174"
51
+ "mainUid": "ddcf-174"
52
52
  },
53
- "137d-177": {
53
+ "ddcf-177": {
54
54
  "renderedLength": 1365,
55
55
  "gzipLength": 519,
56
56
  "brotliLength": 0,
57
- "mainUid": "137d-176"
57
+ "mainUid": "ddcf-176"
58
58
  },
59
- "137d-179": {
59
+ "ddcf-179": {
60
60
  "renderedLength": 2729,
61
61
  "gzipLength": 868,
62
62
  "brotliLength": 0,
63
- "mainUid": "137d-178"
63
+ "mainUid": "ddcf-178"
64
64
  }
65
65
  },
66
66
  "nodeMetas": {
67
- "137d-172": {
67
+ "ddcf-172": {
68
68
  "id": "/packages/table-core/build/esm/index.js",
69
69
  "moduleParts": {
70
- "index.production.js": "137d-173"
70
+ "index.production.js": "ddcf-173"
71
71
  },
72
72
  "imported": [],
73
73
  "importedBy": [
74
74
  {
75
- "uid": "137d-178"
75
+ "uid": "ddcf-178"
76
76
  }
77
77
  ]
78
78
  },
79
- "137d-174": {
79
+ "ddcf-174": {
80
80
  "id": "/packages/svelte-table/src/placeholder.svelte",
81
81
  "moduleParts": {
82
- "index.production.js": "137d-175"
82
+ "index.production.js": "ddcf-175"
83
83
  },
84
84
  "imported": [
85
85
  {
86
- "uid": "137d-180"
86
+ "uid": "ddcf-180"
87
87
  }
88
88
  ],
89
89
  "importedBy": [
90
90
  {
91
- "uid": "137d-178"
91
+ "uid": "ddcf-178"
92
92
  }
93
93
  ]
94
94
  },
95
- "137d-176": {
95
+ "ddcf-176": {
96
96
  "id": "/packages/svelte-table/src/render-component.ts",
97
97
  "moduleParts": {
98
- "index.production.js": "137d-177"
98
+ "index.production.js": "ddcf-177"
99
99
  },
100
100
  "imported": [
101
101
  {
102
- "uid": "137d-180"
102
+ "uid": "ddcf-180"
103
103
  }
104
104
  ],
105
105
  "importedBy": [
106
106
  {
107
- "uid": "137d-178"
107
+ "uid": "ddcf-178"
108
108
  }
109
109
  ]
110
110
  },
111
- "137d-178": {
111
+ "ddcf-178": {
112
112
  "id": "/packages/svelte-table/src/index.ts",
113
113
  "moduleParts": {
114
- "index.production.js": "137d-179"
114
+ "index.production.js": "ddcf-179"
115
115
  },
116
116
  "imported": [
117
117
  {
118
- "uid": "137d-172"
118
+ "uid": "ddcf-172"
119
119
  },
120
120
  {
121
- "uid": "137d-174"
121
+ "uid": "ddcf-174"
122
122
  },
123
123
  {
124
- "uid": "137d-180"
124
+ "uid": "ddcf-180"
125
125
  },
126
126
  {
127
- "uid": "137d-181"
127
+ "uid": "ddcf-181"
128
128
  },
129
129
  {
130
- "uid": "137d-176"
130
+ "uid": "ddcf-176"
131
131
  }
132
132
  ],
133
133
  "importedBy": [],
134
134
  "isEntry": true
135
135
  },
136
- "137d-180": {
136
+ "ddcf-180": {
137
137
  "id": "svelte/internal",
138
138
  "moduleParts": {},
139
139
  "imported": [],
140
140
  "importedBy": [
141
141
  {
142
- "uid": "137d-178"
142
+ "uid": "ddcf-178"
143
143
  },
144
144
  {
145
- "uid": "137d-174"
145
+ "uid": "ddcf-174"
146
146
  },
147
147
  {
148
- "uid": "137d-176"
148
+ "uid": "ddcf-176"
149
149
  }
150
150
  ],
151
151
  "isExternal": true
152
152
  },
153
- "137d-181": {
153
+ "ddcf-181": {
154
154
  "id": "svelte/store",
155
155
  "moduleParts": {},
156
156
  "imported": [],
157
157
  "importedBy": [
158
158
  {
159
- "uid": "137d-178"
159
+ "uid": "ddcf-178"
160
160
  }
161
161
  ],
162
162
  "isExternal": true
@@ -1226,8 +1226,7 @@
1226
1226
  createRow: (row, instance) => {
1227
1227
  return {
1228
1228
  columnFilters: {},
1229
- columnFiltersMeta: {},
1230
- subRowsByFacetId: {}
1229
+ columnFiltersMeta: {}
1231
1230
  };
1232
1231
  },
1233
1232
  createInstance: instance => {
@@ -1318,53 +1317,42 @@
1318
1317
  return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
1319
1318
  }
1320
1319
 
1321
- const aggregationFns = {
1322
- sum,
1323
- min,
1324
- max,
1325
- extent,
1326
- mean,
1327
- median,
1328
- unique,
1329
- uniqueCount,
1330
- count
1331
- };
1332
-
1333
- function sum(_getLeafValues, getChildValues) {
1320
+ const sum = (columnId, _leafRows, childRows) => {
1334
1321
  // It's faster to just add the aggregations together instead of
1335
1322
  // process leaf nodes individually
1336
- return getChildValues().reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
1337
- }
1323
+ return childRows.reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
1324
+ };
1338
1325
 
1339
- function min(_getLeafValues, getChildValues) {
1326
+ const min = (columnId, _leafRows, childRows) => {
1340
1327
  let min;
1328
+ childRows.forEach(row => {
1329
+ const value = row.getValue(columnId);
1341
1330
 
1342
- for (const value of getChildValues()) {
1343
1331
  if (value != null && (min > value || min === undefined && value >= value)) {
1344
1332
  min = value;
1345
1333
  }
1346
- }
1347
-
1334
+ });
1348
1335
  return min;
1349
- }
1336
+ };
1350
1337
 
1351
- function max(_getLeafValues, getChildValues) {
1338
+ const max = (columnId, _leafRows, childRows) => {
1352
1339
  let max;
1340
+ childRows.forEach(row => {
1341
+ const value = row.getValue(columnId);
1353
1342
 
1354
- for (const value of getChildValues()) {
1355
1343
  if (value != null && (max < value || max === undefined && value >= value)) {
1356
1344
  max = value;
1357
1345
  }
1358
- }
1359
-
1346
+ });
1360
1347
  return max;
1361
- }
1348
+ };
1362
1349
 
1363
- function extent(_getLeafValues, getChildValues) {
1350
+ const extent = (columnId, _leafRows, childRows) => {
1364
1351
  let min;
1365
1352
  let max;
1353
+ childRows.forEach(row => {
1354
+ const value = row.getValue(columnId);
1366
1355
 
1367
- for (const value of getChildValues()) {
1368
1356
  if (value != null) {
1369
1357
  if (min === undefined) {
1370
1358
  if (value >= value) min = max = value;
@@ -1373,54 +1361,65 @@
1373
1361
  if (max < value) max = value;
1374
1362
  }
1375
1363
  }
1376
- }
1377
-
1364
+ });
1378
1365
  return [min, max];
1379
- }
1366
+ };
1380
1367
 
1381
- function mean(getLeafValues) {
1368
+ const mean = (columnId, leafRows) => {
1382
1369
  let count = 0;
1383
1370
  let sum = 0;
1371
+ leafRows.forEach(row => {
1372
+ let value = row.getValue(columnId);
1384
1373
 
1385
- for (let value of getLeafValues()) {
1386
1374
  if (value != null && (value = +value) >= value) {
1387
1375
  ++count, sum += value;
1388
1376
  }
1389
- }
1390
-
1377
+ });
1391
1378
  if (count) return sum / count;
1392
1379
  return;
1393
- }
1394
-
1395
- function median(getLeafValues) {
1396
- const leafValues = getLeafValues();
1380
+ };
1397
1381
 
1398
- if (!leafValues.length) {
1382
+ const median = (columnId, leafRows) => {
1383
+ if (!leafRows.length) {
1399
1384
  return;
1400
1385
  }
1401
1386
 
1402
1387
  let min = 0;
1403
1388
  let max = 0;
1404
- leafValues.forEach(value => {
1389
+ leafRows.forEach(row => {
1390
+ let value = row.getValue(columnId);
1391
+
1405
1392
  if (typeof value === 'number') {
1406
1393
  min = Math.min(min, value);
1407
1394
  max = Math.max(max, value);
1408
1395
  }
1409
1396
  });
1410
1397
  return (min + max) / 2;
1411
- }
1398
+ };
1412
1399
 
1413
- function unique(getLeafValues) {
1414
- return Array.from(new Set(getLeafValues()).values());
1415
- }
1400
+ const unique = (columnId, leafRows) => {
1401
+ return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
1402
+ };
1416
1403
 
1417
- function uniqueCount(getLeafValues) {
1418
- return new Set(getLeafValues()).size;
1419
- }
1404
+ const uniqueCount = (columnId, leafRows) => {
1405
+ return new Set(leafRows.map(d => d.getValue(columnId))).size;
1406
+ };
1420
1407
 
1421
- function count(getLeafValues) {
1422
- return getLeafValues().length;
1423
- }
1408
+ const count = (_columnId, leafRows) => {
1409
+ return leafRows.length;
1410
+ };
1411
+
1412
+ const aggregationFns = {
1413
+ sum,
1414
+ min,
1415
+ max,
1416
+ extent,
1417
+ mean,
1418
+ median,
1419
+ unique,
1420
+ uniqueCount,
1421
+ count
1422
+ };
1424
1423
 
1425
1424
  //
1426
1425
  const Grouping = {
@@ -1475,7 +1474,7 @@
1475
1474
  column.toggleGrouping();
1476
1475
  };
1477
1476
  },
1478
- getColumnAutoAggregationFn: () => {
1477
+ getAutoAggregationFn: () => {
1479
1478
  const firstRow = instance.getCoreRowModel().flatRows[0];
1480
1479
  const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
1481
1480
 
@@ -1489,7 +1488,7 @@
1489
1488
 
1490
1489
  return aggregationFns.count;
1491
1490
  },
1492
- getColumnAggregationFn: () => {
1491
+ getAggregationFn: () => {
1493
1492
  var _ref4;
1494
1493
 
1495
1494
  const userAggregationFns = instance.options.aggregationFns;
@@ -1498,7 +1497,7 @@
1498
1497
  throw new Error();
1499
1498
  }
1500
1499
 
1501
- return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.getColumnAutoAggregationFn() : (_ref4 = userAggregationFns == null ? void 0 : userAggregationFns[column.aggregationFn]) != null ? _ref4 : aggregationFns[column.aggregationFn];
1500
+ return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_ref4 = userAggregationFns == null ? void 0 : userAggregationFns[column.aggregationFn]) != null ? _ref4 : aggregationFns[column.aggregationFn];
1502
1501
  }
1503
1502
  };
1504
1503
  },
@@ -1524,10 +1523,10 @@
1524
1523
  }
1525
1524
  };
1526
1525
  },
1527
- createRow: (row, instance) => {
1526
+ createRow: row => {
1528
1527
  return {
1529
1528
  getIsGrouped: () => !!row.groupingColumnId,
1530
- groupingValuesCache: {}
1529
+ _groupingValuesCache: {}
1531
1530
  };
1532
1531
  },
1533
1532
  createCell: (cell, column, row, instance) => {
@@ -3660,25 +3659,17 @@
3660
3659
  return row._valuesCache[columnId];
3661
3660
  }
3662
3661
 
3663
- if (row.groupingValuesCache.hasOwnProperty(columnId)) {
3664
- return row.groupingValuesCache[columnId];
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.getColumnAggregationFn();
3668
+ const aggregateFn = column.getAggregationFn();
3670
3669
 
3671
3670
  if (aggregateFn) {
3672
- row.groupingValuesCache[columnId] = aggregateFn(() => leafRows.map(row => {
3673
- let columnValue = row.getValue(columnId);
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
@@ -4062,7 +4053,6 @@
4062
4053
  exports.isFunction = isFunction;
4063
4054
  exports.isRowSelected = isRowSelected;
4064
4055
  exports.makeStateUpdater = makeStateUpdater;
4065
- exports.mean = mean;
4066
4056
  exports.memo = memo;
4067
4057
  exports.noop = noop;
4068
4058
  exports.orderColumns = orderColumns;