@tanstack/table-core 8.5.15 → 8.5.17

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.
Files changed (71) hide show
  1. package/build/cjs/aggregationFns.js +0 -15
  2. package/build/cjs/aggregationFns.js.map +1 -1
  3. package/build/cjs/columnHelper.js +10 -2
  4. package/build/cjs/columnHelper.js.map +1 -1
  5. package/build/cjs/core/cell.js +0 -3
  6. package/build/cjs/core/cell.js.map +1 -1
  7. package/build/cjs/core/column.js +7 -12
  8. package/build/cjs/core/column.js.map +1 -1
  9. package/build/cjs/core/headers.js +18 -30
  10. package/build/cjs/core/headers.js.map +1 -1
  11. package/build/cjs/core/row.js +0 -5
  12. package/build/cjs/core/row.js.map +1 -1
  13. package/build/cjs/core/table.js +13 -30
  14. package/build/cjs/core/table.js.map +1 -1
  15. package/build/cjs/features/ColumnSizing.js +33 -32
  16. package/build/cjs/features/ColumnSizing.js.map +1 -1
  17. package/build/cjs/features/Expanding.js +9 -19
  18. package/build/cjs/features/Expanding.js.map +1 -1
  19. package/build/cjs/features/Filters.js +6 -34
  20. package/build/cjs/features/Filters.js.map +1 -1
  21. package/build/cjs/features/Grouping.js +1 -16
  22. package/build/cjs/features/Grouping.js.map +1 -1
  23. package/build/cjs/features/Ordering.js +13 -10
  24. package/build/cjs/features/Ordering.js.map +1 -1
  25. package/build/cjs/features/Pagination.js +11 -22
  26. package/build/cjs/features/Pagination.js.map +1 -1
  27. package/build/cjs/features/Pinning.js +5 -11
  28. package/build/cjs/features/Pinning.js.map +1 -1
  29. package/build/cjs/features/RowSelection.js +35 -39
  30. package/build/cjs/features/RowSelection.js.map +1 -1
  31. package/build/cjs/features/Sorting.js +14 -29
  32. package/build/cjs/features/Sorting.js.map +1 -1
  33. package/build/cjs/features/Visibility.js +5 -5
  34. package/build/cjs/features/Visibility.js.map +1 -1
  35. package/build/cjs/filterFns.js +3 -28
  36. package/build/cjs/filterFns.js.map +1 -1
  37. package/build/cjs/sortingFns.js +24 -31
  38. package/build/cjs/sortingFns.js.map +1 -1
  39. package/build/cjs/utils/filterRowsUtils.js +7 -19
  40. package/build/cjs/utils/filterRowsUtils.js.map +1 -1
  41. package/build/cjs/utils/getCoreRowModel.js +11 -13
  42. package/build/cjs/utils/getCoreRowModel.js.map +1 -1
  43. package/build/cjs/utils/getExpandedRowModel.js +0 -6
  44. package/build/cjs/utils/getExpandedRowModel.js.map +1 -1
  45. package/build/cjs/utils/getFacetedMinMaxValues.js +0 -6
  46. package/build/cjs/utils/getFacetedMinMaxValues.js.map +1 -1
  47. package/build/cjs/utils/getFacetedRowModel.js +0 -4
  48. package/build/cjs/utils/getFacetedRowModel.js.map +1 -1
  49. package/build/cjs/utils/getFacetedUniqueValues.js +0 -4
  50. package/build/cjs/utils/getFacetedUniqueValues.js.map +1 -1
  51. package/build/cjs/utils/getFilteredRowModel.js +8 -20
  52. package/build/cjs/utils/getFilteredRowModel.js.map +1 -1
  53. package/build/cjs/utils/getGroupedRowModel.js +21 -25
  54. package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
  55. package/build/cjs/utils/getPaginationRowModel.js +0 -6
  56. package/build/cjs/utils/getPaginationRowModel.js.map +1 -1
  57. package/build/cjs/utils/getSortedRowModel.js +6 -15
  58. package/build/cjs/utils/getSortedRowModel.js.map +1 -1
  59. package/build/cjs/utils.js +7 -13
  60. package/build/cjs/utils.js.map +1 -1
  61. package/build/esm/index.js +267 -504
  62. package/build/esm/index.js.map +1 -1
  63. package/build/stats-html.html +51 -41
  64. package/build/stats-react.json +369 -369
  65. package/build/umd/index.development.js +267 -502
  66. package/build/umd/index.development.js.map +1 -1
  67. package/build/umd/index.production.js +1 -1
  68. package/build/umd/index.production.js.map +1 -1
  69. package/package.json +1 -1
  70. package/src/core/column.ts +5 -0
  71. package/src/features/ColumnSizing.ts +11 -1
@@ -15,17 +15,22 @@
15
15
  })(this, (function (exports) { 'use strict';
16
16
 
17
17
  // Is this type a tuple?
18
+
18
19
  // If this type is a tuple, what indices are allowed?
20
+
19
21
  ///
22
+
20
23
  function functionalUpdate(updater, input) {
21
24
  return typeof updater === 'function' ? updater(input) : updater;
22
25
  }
23
- function noop() {//
26
+ function noop() {
27
+ //
24
28
  }
25
29
  function makeStateUpdater(key, instance) {
26
30
  return updater => {
27
31
  instance.setState(old => {
28
- return { ...old,
32
+ return {
33
+ ...old,
29
34
  [key]: functionalUpdate(updater, old[key])
30
35
  };
31
36
  });
@@ -36,18 +41,15 @@
36
41
  }
37
42
  function flattenBy(arr, getChildren) {
38
43
  const flat = [];
39
-
40
44
  const recurse = subArr => {
41
45
  subArr.forEach(item => {
42
46
  flat.push(item);
43
47
  const children = getChildren(item);
44
-
45
48
  if (children != null && children.length) {
46
49
  recurse(children);
47
50
  }
48
51
  });
49
52
  };
50
-
51
53
  recurse(arr);
52
54
  return flat;
53
55
  }
@@ -59,54 +61,45 @@
59
61
  if (opts.key && opts.debug) depTime = Date.now();
60
62
  const newDeps = getDeps();
61
63
  const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
62
-
63
64
  if (!depsChanged) {
64
65
  return result;
65
66
  }
66
-
67
67
  deps = newDeps;
68
68
  let resultTime;
69
69
  if (opts.key && opts.debug) resultTime = Date.now();
70
70
  result = fn(...newDeps);
71
71
  opts == null ? void 0 : opts.onChange == null ? void 0 : opts.onChange(result);
72
-
73
72
  if (opts.key && opts.debug) {
74
73
  if (opts != null && opts.debug()) {
75
74
  const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
76
75
  const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
77
76
  const resultFpsPercentage = resultEndTime / 16;
78
-
79
77
  const pad = (str, num) => {
80
78
  str = String(str);
81
-
82
79
  while (str.length < num) {
83
80
  str = ' ' + str;
84
81
  }
85
-
86
82
  return str;
87
83
  };
88
-
89
84
  console.info(`%c⏱ ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`, `
90
85
  font-size: .6rem;
91
86
  font-weight: bold;
92
87
  color: hsl(${Math.max(0, Math.min(120 - 120 * resultFpsPercentage, 120))}deg 100% 31%);`, opts == null ? void 0 : opts.key);
93
88
  }
94
89
  }
95
-
96
90
  return result;
97
91
  };
98
92
  }
99
93
 
100
94
  function createColumn(table, columnDef, depth, parent) {
101
95
  const defaultColumn = table._getDefaultColumnDef();
102
-
103
- const resolvedColumnDef = { ...defaultColumn,
96
+ const resolvedColumnDef = {
97
+ ...defaultColumn,
104
98
  ...columnDef
105
99
  };
106
100
  const accessorKey = resolvedColumnDef.accessorKey;
107
101
  let id = resolvedColumnDef.id ?? (accessorKey ? accessorKey.replace('.', '_') : undefined) ?? (typeof resolvedColumnDef.header === 'string' ? resolvedColumnDef.header : undefined);
108
102
  let accessorFn;
109
-
110
103
  if (resolvedColumnDef.accessorFn) {
111
104
  accessorFn = resolvedColumnDef.accessorFn;
112
105
  } else if (accessorKey) {
@@ -114,24 +107,23 @@
114
107
  if (accessorKey.includes('.')) {
115
108
  accessorFn = originalRow => {
116
109
  let result = originalRow;
117
-
118
110
  for (const key of accessorKey.split('.')) {
119
111
  result = result[key];
112
+ if (result === undefined) {
113
+ throw new Error(`"${key}" in deeply nested key "${accessorKey}" returned undefined.`);
114
+ }
120
115
  }
121
-
122
116
  return result;
123
117
  };
124
118
  } else {
125
119
  accessorFn = originalRow => originalRow[resolvedColumnDef.accessorKey];
126
120
  }
127
121
  }
128
-
129
122
  if (!id) {
130
123
  {
131
124
  throw new Error(resolvedColumnDef.accessorFn ? `Columns require an id when using an accessorFn` : `Columns require an id when using a non-string header`);
132
125
  }
133
126
  }
134
-
135
127
  let column = {
136
128
  id: `${String(id)}`,
137
129
  accessorFn,
@@ -141,7 +133,6 @@
141
133
  columns: [],
142
134
  getFlatColumns: memo(() => [true], () => {
143
135
  var _column$columns;
144
-
145
136
  return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
146
137
  }, {
147
138
  key: "development" === 'production' ,
@@ -149,12 +140,10 @@
149
140
  }),
150
141
  getLeafColumns: memo(() => [table._getOrderColumnsFn()], orderColumns => {
151
142
  var _column$columns2;
152
-
153
143
  if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
154
144
  let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
155
145
  return orderColumns(leafColumns);
156
146
  }
157
-
158
147
  return [column];
159
148
  }, {
160
149
  key: "development" === 'production' ,
@@ -163,12 +152,14 @@
163
152
  };
164
153
  column = table._features.reduce((obj, feature) => {
165
154
  return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, table));
166
- }, column); // Yes, we have to convert table to uknown, because we know more than the compiler here.
155
+ }, column);
167
156
 
157
+ // Yes, we have to convert table to uknown, because we know more than the compiler here.
168
158
  return column;
169
159
  }
170
160
 
171
161
  //
162
+
172
163
  function createHeader(table, column, options) {
173
164
  const id = options.id ?? column.id;
174
165
  let header = {
@@ -184,15 +175,12 @@
184
175
  headerGroup: null,
185
176
  getLeafHeaders: () => {
186
177
  const leafHeaders = [];
187
-
188
178
  const recurseHeader = h => {
189
179
  if (h.subHeaders && h.subHeaders.length) {
190
180
  h.subHeaders.map(recurseHeader);
191
181
  }
192
-
193
182
  leafHeaders.push(h);
194
183
  };
195
-
196
184
  recurseHeader(header);
197
185
  return leafHeaders;
198
186
  },
@@ -202,18 +190,16 @@
202
190
  column
203
191
  })
204
192
  };
205
-
206
193
  table._features.forEach(feature => {
207
194
  Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, table));
208
195
  });
209
-
210
196
  return header;
211
197
  }
212
-
213
198
  const Headers = {
214
199
  createTable: table => {
215
200
  return {
216
201
  // Header Groups
202
+
217
203
  getHeaderGroups: memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
218
204
  const leftColumns = (left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) ?? [];
219
205
  const rightColumns = (right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) ?? [];
@@ -246,6 +232,7 @@
246
232
  debug: () => table.options.debugAll ?? table.options.debugHeaders
247
233
  }),
248
234
  // Footer Groups
235
+
249
236
  getFooterGroups: memo(() => [table.getHeaderGroups()], headerGroups => {
250
237
  return [...headerGroups].reverse();
251
238
  }, {
@@ -271,6 +258,7 @@
271
258
  debug: () => table.options.debugAll ?? table.options.debugHeaders
272
259
  }),
273
260
  // Flat Headers
261
+
274
262
  getFlatHeaders: memo(() => [table.getHeaderGroups()], headerGroups => {
275
263
  return headerGroups.map(headerGroup => {
276
264
  return headerGroup.headers;
@@ -304,10 +292,10 @@
304
292
  debug: () => table.options.debugAll ?? table.options.debugHeaders
305
293
  }),
306
294
  // Leaf Headers
295
+
307
296
  getCenterLeafHeaders: memo(() => [table.getCenterFlatHeaders()], flatHeaders => {
308
297
  return flatHeaders.filter(header => {
309
298
  var _header$subHeaders;
310
-
311
299
  return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
312
300
  });
313
301
  }, {
@@ -317,7 +305,6 @@
317
305
  getLeftLeafHeaders: memo(() => [table.getLeftFlatHeaders()], flatHeaders => {
318
306
  return flatHeaders.filter(header => {
319
307
  var _header$subHeaders2;
320
-
321
308
  return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
322
309
  });
323
310
  }, {
@@ -327,7 +314,6 @@
327
314
  getRightLeafHeaders: memo(() => [table.getRightFlatHeaders()], flatHeaders => {
328
315
  return flatHeaders.filter(header => {
329
316
  var _header$subHeaders3;
330
-
331
317
  return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
332
318
  });
333
319
  }, {
@@ -336,7 +322,6 @@
336
322
  }),
337
323
  getLeafHeaders: memo(() => [table.getLeftHeaderGroups(), table.getCenterHeaderGroups(), table.getRightHeaderGroups()], (left, center, right) => {
338
324
  var _left$, _center$, _right$;
339
-
340
325
  return [...(((_left$ = left[0]) == null ? void 0 : _left$.headers) ?? []), ...(((_center$ = center[0]) == null ? void 0 : _center$.headers) ?? []), ...(((_right$ = right[0]) == null ? void 0 : _right$.headers) ?? [])].map(header => {
341
326
  return header.getLeafHeaders();
342
327
  }).flat();
@@ -349,49 +334,46 @@
349
334
  };
350
335
  function buildHeaderGroups(allColumns, columnsToGroup, table, headerFamily) {
351
336
  var _headerGroups$;
352
-
353
337
  // Find the max depth of the columns:
354
338
  // build the leaf column row
355
339
  // build each buffer row going up
356
340
  // placeholder for non-existent level
357
341
  // real column for existing level
358
- let maxDepth = 0;
359
342
 
343
+ let maxDepth = 0;
360
344
  const findMaxDepth = function (columns, depth) {
361
345
  if (depth === void 0) {
362
346
  depth = 1;
363
347
  }
364
-
365
348
  maxDepth = Math.max(maxDepth, depth);
366
349
  columns.filter(column => column.getIsVisible()).forEach(column => {
367
350
  var _column$columns;
368
-
369
351
  if ((_column$columns = column.columns) != null && _column$columns.length) {
370
352
  findMaxDepth(column.columns, depth + 1);
371
353
  }
372
354
  }, 0);
373
355
  };
374
-
375
356
  findMaxDepth(allColumns);
376
357
  let headerGroups = [];
377
-
378
358
  const createHeaderGroup = (headersToGroup, depth) => {
379
359
  // The header group we are creating
380
360
  const headerGroup = {
381
361
  depth,
382
362
  id: [headerFamily, `${depth}`].filter(Boolean).join('_'),
383
363
  headers: []
384
- }; // The parent columns we're going to scan next
364
+ };
385
365
 
386
- const pendingParentHeaders = []; // Scan each column for parents
366
+ // The parent columns we're going to scan next
367
+ const pendingParentHeaders = [];
387
368
 
369
+ // Scan each column for parents
388
370
  headersToGroup.forEach(headerToGroup => {
389
371
  // What is the latest (last) parent column?
372
+
390
373
  const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
391
374
  const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
392
375
  let column;
393
376
  let isPlaceholder = false;
394
-
395
377
  if (isLeafHeader && headerToGroup.column.parent) {
396
378
  // The parent header is new
397
379
  column = headerToGroup.column.parent;
@@ -400,7 +382,6 @@
400
382
  column = headerToGroup.column;
401
383
  isPlaceholder = true;
402
384
  }
403
-
404
385
  if (latestPendingParentHeader && (latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
405
386
  // This column is repeated. Add it as a sub header to the next batch
406
387
  latestPendingParentHeader.subHeaders.push(headerToGroup);
@@ -412,30 +393,30 @@
412
393
  placeholderId: isPlaceholder ? `${pendingParentHeaders.filter(d => d.column === column).length}` : undefined,
413
394
  depth,
414
395
  index: pendingParentHeaders.length
415
- }); // Add the headerToGroup as a subHeader of the new header
396
+ });
416
397
 
417
- header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
398
+ // Add the headerToGroup as a subHeader of the new header
399
+ header.subHeaders.push(headerToGroup);
400
+ // Add the new header to the pendingParentHeaders to get grouped
418
401
  // in the next batch
419
-
420
402
  pendingParentHeaders.push(header);
421
403
  }
422
-
423
404
  headerGroup.headers.push(headerToGroup);
424
405
  headerToGroup.headerGroup = headerGroup;
425
406
  });
426
407
  headerGroups.push(headerGroup);
427
-
428
408
  if (depth > 0) {
429
409
  createHeaderGroup(pendingParentHeaders, depth - 1);
430
410
  }
431
411
  };
432
-
433
412
  const bottomHeaders = columnsToGroup.map((column, index) => createHeader(table, column, {
434
413
  depth: maxDepth,
435
414
  index
436
415
  }));
437
416
  createHeaderGroup(bottomHeaders, maxDepth - 1);
438
- headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
417
+ headerGroups.reverse();
418
+
419
+ // headerGroups = headerGroups.filter(headerGroup => {
439
420
  // return !headerGroup.headers.every(header => header.isPlaceholder)
440
421
  // })
441
422
 
@@ -445,7 +426,6 @@
445
426
  let colSpan = 0;
446
427
  let rowSpan = 0;
447
428
  let childRowSpans = [0];
448
-
449
429
  if (header.subHeaders && header.subHeaders.length) {
450
430
  childRowSpans = [];
451
431
  recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
@@ -459,7 +439,6 @@
459
439
  } else {
460
440
  colSpan = 1;
461
441
  }
462
-
463
442
  const minChildRowSpan = Math.min(...childRowSpans);
464
443
  rowSpan = rowSpan + minChildRowSpan;
465
444
  header.colSpan = colSpan;
@@ -470,18 +449,17 @@
470
449
  };
471
450
  });
472
451
  };
473
-
474
452
  recurseHeadersForSpans(((_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) ?? []);
475
453
  return headerGroups;
476
454
  }
477
455
 
478
456
  //
457
+
479
458
  const defaultColumnSizing = {
480
459
  size: 150,
481
460
  minSize: 20,
482
461
  maxSize: Number.MAX_SAFE_INTEGER
483
462
  };
484
-
485
463
  const getDefaultColumnSizingInfoState = () => ({
486
464
  startOffset: null,
487
465
  startSize: null,
@@ -490,7 +468,6 @@
490
468
  isResizingColumn: false,
491
469
  columnSizingStart: []
492
470
  });
493
-
494
471
  const ColumnSizing = {
495
472
  getDefaultColumnDef: () => {
496
473
  return defaultColumnSizing;
@@ -518,12 +495,10 @@
518
495
  getStart: position => {
519
496
  const columns = !position ? table.getVisibleLeafColumns() : position === 'left' ? table.getLeftVisibleLeafColumns() : table.getRightVisibleLeafColumns();
520
497
  const index = columns.findIndex(d => d.id === column.id);
521
-
522
498
  if (index > 0) {
523
499
  const prevSiblingColumn = columns[index - 1];
524
500
  return prevSiblingColumn.getStart(position) + prevSiblingColumn.getSize();
525
501
  }
526
-
527
502
  return 0;
528
503
  },
529
504
  resetSize: () => {
@@ -547,7 +522,6 @@
547
522
  return {
548
523
  getSize: () => {
549
524
  let sum = 0;
550
-
551
525
  const recurse = header => {
552
526
  if (header.subHeaders.length) {
553
527
  header.subHeaders.forEach(recurse);
@@ -555,7 +529,6 @@
555
529
  sum += header.column.getSize() ?? 0;
556
530
  }
557
531
  };
558
-
559
532
  recurse(header);
560
533
  return sum;
561
534
  },
@@ -564,7 +537,6 @@
564
537
  const prevSiblingHeader = header.headerGroup.headers[header.index - 1];
565
538
  return prevSiblingHeader.getStart() + prevSiblingHeader.getSize();
566
539
  }
567
-
568
540
  return 0;
569
541
  },
570
542
  getResizeHandler: () => {
@@ -575,23 +547,19 @@
575
547
  return;
576
548
  }
577
549
  e.persist == null ? void 0 : e.persist();
578
-
579
550
  if (isTouchStartEvent(e)) {
580
551
  // lets not respond to multiple touches (e.g. 2 or 3 fingers)
581
552
  if (e.touches && e.touches.length > 1) {
582
553
  return;
583
554
  }
584
555
  }
585
-
586
556
  const startSize = header.getSize();
587
557
  const columnSizingStart = header ? header.getLeafHeaders().map(d => [d.column.id, d.column.getSize()]) : [[column.id, column.getSize()]];
588
558
  const clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
589
-
590
559
  const updateOffset = (eventType, clientXPos) => {
591
560
  if (typeof clientXPos !== 'number') {
592
561
  return;
593
562
  }
594
-
595
563
  let newColumnSizing = {};
596
564
  table.setColumnSizingInfo(old => {
597
565
  const deltaOffset = clientXPos - ((old == null ? void 0 : old.startOffset) ?? 0);
@@ -600,24 +568,24 @@
600
568
  let [columnId, headerSize] = _ref2;
601
569
  newColumnSizing[columnId] = Math.round(Math.max(headerSize + headerSize * deltaPercentage, 0) * 100) / 100;
602
570
  });
603
- return { ...old,
571
+ return {
572
+ ...old,
604
573
  deltaOffset,
605
574
  deltaPercentage
606
575
  };
607
576
  });
608
-
609
577
  if (table.options.columnResizeMode === 'onChange' || eventType === 'end') {
610
- table.setColumnSizing(old => ({ ...old,
578
+ table.setColumnSizing(old => ({
579
+ ...old,
611
580
  ...newColumnSizing
612
581
  }));
613
582
  }
614
583
  };
615
-
616
584
  const onMove = clientXPos => updateOffset('move', clientXPos);
617
-
618
585
  const onEnd = clientXPos => {
619
586
  updateOffset('end', clientXPos);
620
- table.setColumnSizingInfo(old => ({ ...old,
587
+ table.setColumnSizingInfo(old => ({
588
+ ...old,
621
589
  isResizingColumn: false,
622
590
  startOffset: null,
623
591
  startSize: null,
@@ -626,7 +594,6 @@
626
594
  columnSizingStart: []
627
595
  }));
628
596
  };
629
-
630
597
  const mouseEvents = {
631
598
  moveHandler: e => onMove(e.clientX),
632
599
  upHandler: e => {
@@ -635,16 +602,38 @@
635
602
  onEnd(e.clientX);
636
603
  }
637
604
  };
605
+ const touchEvents = {
606
+ moveHandler: e => {
607
+ if (e.cancelable) {
608
+ e.preventDefault();
609
+ e.stopPropagation();
610
+ }
611
+ onMove(e.touches[0].clientX);
612
+ return false;
613
+ },
614
+ upHandler: e => {
615
+ var _e$touches$;
616
+ document.removeEventListener('touchmove', touchEvents.moveHandler);
617
+ document.removeEventListener('touchend', touchEvents.upHandler);
618
+ if (e.cancelable) {
619
+ e.preventDefault();
620
+ e.stopPropagation();
621
+ }
622
+ onEnd((_e$touches$ = e.touches[0]) == null ? void 0 : _e$touches$.clientX);
623
+ }
624
+ };
638
625
  const passiveIfSupported = passiveEventSupported() ? {
639
626
  passive: false
640
627
  } : false;
641
-
642
- if (isTouchStartEvent(e)) ; else {
628
+ if (isTouchStartEvent(e)) {
629
+ document.addEventListener('touchmove', touchEvents.moveHandler, passiveIfSupported);
630
+ document.addEventListener('touchend', touchEvents.upHandler, passiveIfSupported);
631
+ } else {
643
632
  document.addEventListener('mousemove', mouseEvents.moveHandler, passiveIfSupported);
644
633
  document.addEventListener('mouseup', mouseEvents.upHandler, passiveIfSupported);
645
634
  }
646
-
647
- table.setColumnSizingInfo(old => ({ ...old,
635
+ table.setColumnSizingInfo(old => ({
636
+ ...old,
648
637
  startOffset: clientX,
649
638
  startSize,
650
639
  deltaOffset: 0,
@@ -668,28 +657,24 @@
668
657
  },
669
658
  getTotalSize: () => {
670
659
  var _table$getHeaderGroup;
671
-
672
660
  return ((_table$getHeaderGroup = table.getHeaderGroups()[0]) == null ? void 0 : _table$getHeaderGroup.headers.reduce((sum, header) => {
673
661
  return sum + header.getSize();
674
662
  }, 0)) ?? 0;
675
663
  },
676
664
  getLeftTotalSize: () => {
677
665
  var _table$getLeftHeaderG;
678
-
679
666
  return ((_table$getLeftHeaderG = table.getLeftHeaderGroups()[0]) == null ? void 0 : _table$getLeftHeaderG.headers.reduce((sum, header) => {
680
667
  return sum + header.getSize();
681
668
  }, 0)) ?? 0;
682
669
  },
683
670
  getCenterTotalSize: () => {
684
671
  var _table$getCenterHeade;
685
-
686
672
  return ((_table$getCenterHeade = table.getCenterHeaderGroups()[0]) == null ? void 0 : _table$getCenterHeade.headers.reduce((sum, header) => {
687
673
  return sum + header.getSize();
688
674
  }, 0)) ?? 0;
689
675
  },
690
676
  getRightTotalSize: () => {
691
677
  var _table$getRightHeader;
692
-
693
678
  return ((_table$getRightHeader = table.getRightHeaderGroups()[0]) == null ? void 0 : _table$getRightHeader.headers.reduce((sum, header) => {
694
679
  return sum + header.getSize();
695
680
  }, 0)) ?? 0;
@@ -701,33 +686,28 @@
701
686
  function passiveEventSupported() {
702
687
  if (typeof passiveSupported === 'boolean') return passiveSupported;
703
688
  let supported = false;
704
-
705
689
  try {
706
690
  const options = {
707
691
  get passive() {
708
692
  supported = true;
709
693
  return false;
710
694
  }
711
-
712
695
  };
713
-
714
696
  const noop = () => {};
715
-
716
697
  window.addEventListener('test', noop, options);
717
698
  window.removeEventListener('test', noop);
718
699
  } catch (err) {
719
700
  supported = false;
720
701
  }
721
-
722
702
  passiveSupported = supported;
723
703
  return passiveSupported;
724
704
  }
725
-
726
705
  function isTouchStartEvent(e) {
727
706
  return e.type === 'touchstart';
728
707
  }
729
708
 
730
709
  //
710
+
731
711
  const Expanding = {
732
712
  getInitialState: state => {
733
713
  return {
@@ -750,14 +730,11 @@
750
730
  table._queue(() => {
751
731
  registered = true;
752
732
  });
753
-
754
733
  return;
755
734
  }
756
-
757
735
  if (table.options.autoResetAll ?? table.options.autoResetExpanded ?? !table.options.manualExpanding) {
758
736
  if (queued) return;
759
737
  queued = true;
760
-
761
738
  table._queue(() => {
762
739
  table.resetExpanded();
763
740
  queued = false;
@@ -774,7 +751,6 @@
774
751
  },
775
752
  resetExpanded: defaultState => {
776
753
  var _table$initialState;
777
-
778
754
  table.setExpanded(defaultState ? {} : ((_table$initialState = table.initialState) == null ? void 0 : _table$initialState.expanded) ?? {});
779
755
  },
780
756
  getCanSomeRowsExpand: () => {
@@ -791,22 +767,22 @@
791
767
  return expanded === true || Object.values(expanded).some(Boolean);
792
768
  },
793
769
  getIsAllRowsExpanded: () => {
794
- const expanded = table.getState().expanded; // If expanded is true, save some cycles and return true
770
+ const expanded = table.getState().expanded;
795
771
 
772
+ // If expanded is true, save some cycles and return true
796
773
  if (typeof expanded === 'boolean') {
797
774
  return expanded === true;
798
775
  }
799
-
800
776
  if (!Object.keys(expanded).length) {
801
777
  return false;
802
- } // If any row is not expanded, return false
803
-
778
+ }
804
779
 
780
+ // If any row is not expanded, return false
805
781
  if (table.getRowModel().flatRows.some(row => !row.getIsExpanded())) {
806
782
  return false;
807
- } // They must all be expanded :shrug:
808
-
783
+ }
809
784
 
785
+ // They must all be expanded :shrug:
810
786
  return true;
811
787
  },
812
788
  getExpandedDepth: () => {
@@ -823,11 +799,9 @@
823
799
  if (!table._getExpandedRowModel && table.options.getExpandedRowModel) {
824
800
  table._getExpandedRowModel = table.options.getExpandedRowModel(table);
825
801
  }
826
-
827
802
  if (table.options.manualExpanding || !table._getExpandedRowModel) {
828
803
  return table.getPreExpandedRowModel();
829
804
  }
830
-
831
805
  return table._getExpandedRowModel();
832
806
  }
833
807
  };
@@ -838,7 +812,6 @@
838
812
  table.setExpanded(old => {
839
813
  const exists = old === true ? true : !!(old != null && old[row.id]);
840
814
  let oldExpanded = {};
841
-
842
815
  if (old === true) {
843
816
  Object.keys(table.getRowModel().rowsById).forEach(rowId => {
844
817
  oldExpanded[rowId] = true;
@@ -846,15 +819,13 @@
846
819
  } else {
847
820
  oldExpanded = old;
848
821
  }
849
-
850
822
  expanded = expanded ?? !exists;
851
-
852
823
  if (!exists && expanded) {
853
- return { ...oldExpanded,
824
+ return {
825
+ ...oldExpanded,
854
826
  [row.id]: true
855
827
  };
856
828
  }
857
-
858
829
  if (exists && !expanded) {
859
830
  const {
860
831
  [row.id]: _,
@@ -862,7 +833,6 @@
862
833
  } = oldExpanded;
863
834
  return rest;
864
835
  }
865
-
866
836
  return old;
867
837
  });
868
838
  },
@@ -872,7 +842,6 @@
872
842
  },
873
843
  getCanExpand: () => {
874
844
  var _row$subRows;
875
-
876
845
  return (table.options.getRowCanExpand == null ? void 0 : table.options.getRowCanExpand(row)) ?? ((table.options.enableExpanding ?? true) && !!((_row$subRows = row.subRows) != null && _row$subRows.length));
877
846
  },
878
847
  getToggleExpandedHandler: () => {
@@ -888,93 +857,68 @@
888
857
 
889
858
  const includesString = (row, columnId, filterValue) => {
890
859
  var _row$getValue;
891
-
892
860
  const search = filterValue.toLowerCase();
893
861
  return (_row$getValue = row.getValue(columnId)) == null ? void 0 : _row$getValue.toLowerCase().includes(search);
894
862
  };
895
-
896
863
  includesString.autoRemove = val => testFalsey(val);
897
-
898
864
  const includesStringSensitive = (row, columnId, filterValue) => {
899
865
  var _row$getValue2;
900
-
901
866
  return (_row$getValue2 = row.getValue(columnId)) == null ? void 0 : _row$getValue2.includes(filterValue);
902
867
  };
903
-
904
868
  includesStringSensitive.autoRemove = val => testFalsey(val);
905
-
906
869
  const equalsString = (row, columnId, filterValue) => {
907
870
  var _row$getValue3;
908
-
909
871
  return ((_row$getValue3 = row.getValue(columnId)) == null ? void 0 : _row$getValue3.toLowerCase()) === filterValue.toLowerCase();
910
872
  };
911
-
912
873
  equalsString.autoRemove = val => testFalsey(val);
913
-
914
874
  const arrIncludes = (row, columnId, filterValue) => {
915
875
  var _row$getValue4;
916
-
917
876
  return (_row$getValue4 = row.getValue(columnId)) == null ? void 0 : _row$getValue4.includes(filterValue);
918
877
  };
919
-
920
878
  arrIncludes.autoRemove = val => testFalsey(val) || !(val != null && val.length);
921
-
922
879
  const arrIncludesAll = (row, columnId, filterValue) => {
923
880
  return !filterValue.some(val => {
924
881
  var _row$getValue5;
925
-
926
882
  return !((_row$getValue5 = row.getValue(columnId)) != null && _row$getValue5.includes(val));
927
883
  });
928
884
  };
929
-
930
885
  arrIncludesAll.autoRemove = val => testFalsey(val) || !(val != null && val.length);
931
-
932
886
  const arrIncludesSome = (row, columnId, filterValue) => {
933
887
  return filterValue.some(val => {
934
888
  var _row$getValue6;
935
-
936
889
  return (_row$getValue6 = row.getValue(columnId)) == null ? void 0 : _row$getValue6.includes(val);
937
890
  });
938
891
  };
939
-
940
892
  arrIncludesSome.autoRemove = val => testFalsey(val) || !(val != null && val.length);
941
-
942
893
  const equals = (row, columnId, filterValue) => {
943
894
  return row.getValue(columnId) === filterValue;
944
895
  };
945
-
946
896
  equals.autoRemove = val => testFalsey(val);
947
-
948
897
  const weakEquals = (row, columnId, filterValue) => {
949
898
  return row.getValue(columnId) == filterValue;
950
899
  };
951
-
952
900
  weakEquals.autoRemove = val => testFalsey(val);
953
-
954
901
  const inNumberRange = (row, columnId, filterValue) => {
955
902
  let [min, max] = filterValue;
956
903
  const rowValue = row.getValue(columnId);
957
904
  return rowValue >= min && rowValue <= max;
958
905
  };
959
-
960
906
  inNumberRange.resolveFilterValue = val => {
961
907
  let [unsafeMin, unsafeMax] = val;
962
908
  let parsedMin = typeof unsafeMin !== 'number' ? parseFloat(unsafeMin) : unsafeMin;
963
909
  let parsedMax = typeof unsafeMax !== 'number' ? parseFloat(unsafeMax) : unsafeMax;
964
910
  let min = unsafeMin === null || Number.isNaN(parsedMin) ? -Infinity : parsedMin;
965
911
  let max = unsafeMax === null || Number.isNaN(parsedMax) ? Infinity : parsedMax;
966
-
967
912
  if (min > max) {
968
913
  const temp = min;
969
914
  min = max;
970
915
  max = temp;
971
916
  }
972
-
973
917
  return [min, max];
974
918
  };
919
+ inNumberRange.autoRemove = val => testFalsey(val) || testFalsey(val[0]) && testFalsey(val[1]);
975
920
 
976
- inNumberRange.autoRemove = val => testFalsey(val) || testFalsey(val[0]) && testFalsey(val[1]); // Export
977
-
921
+ // Export
978
922
 
979
923
  const filterFns = {
980
924
  includesString,
@@ -987,13 +931,14 @@
987
931
  weakEquals,
988
932
  inNumberRange
989
933
  };
990
-
991
934
  // Utils
935
+
992
936
  function testFalsey(val) {
993
937
  return val === undefined || val === null || val === '';
994
938
  }
995
939
 
996
940
  //
941
+
997
942
  const Filters = {
998
943
  getDefaultColumnDef: () => {
999
944
  return {
@@ -1017,7 +962,6 @@
1017
962
  globalFilterFn: 'auto',
1018
963
  getColumnCanGlobalFilter: column => {
1019
964
  var _table$getCoreRowMode, _table$getCoreRowMode2;
1020
-
1021
965
  const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) == null ? void 0 : (_table$getCoreRowMode2 = _table$getCoreRowMode._getAllCellsByColumnId()[column.id]) == null ? void 0 : _table$getCoreRowMode2.getValue();
1022
966
  return typeof value === 'string' || typeof value === 'number';
1023
967
  }
@@ -1028,32 +972,25 @@
1028
972
  getAutoFilterFn: () => {
1029
973
  const firstRow = table.getCoreRowModel().flatRows[0];
1030
974
  const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
1031
-
1032
975
  if (typeof value === 'string') {
1033
976
  return filterFns.includesString;
1034
977
  }
1035
-
1036
978
  if (typeof value === 'number') {
1037
979
  return filterFns.inNumberRange;
1038
980
  }
1039
-
1040
981
  if (typeof value === 'boolean') {
1041
982
  return filterFns.equals;
1042
983
  }
1043
-
1044
984
  if (value !== null && typeof value === 'object') {
1045
985
  return filterFns.equals;
1046
986
  }
1047
-
1048
987
  if (Array.isArray(value)) {
1049
988
  return filterFns.arrIncludes;
1050
989
  }
1051
-
1052
990
  return filterFns.weakEquals;
1053
991
  },
1054
992
  getFilterFn: () => {
1055
993
  var _table$options$filter;
1056
-
1057
994
  return isFunction(column.columnDef.filterFn) ? column.columnDef.filterFn : column.columnDef.filterFn === 'auto' ? column.getAutoFilterFn() : ((_table$options$filter = table.options.filterFns) == null ? void 0 : _table$options$filter[column.columnDef.filterFn]) ?? filterFns[column.columnDef.filterFn];
1058
995
  },
1059
996
  getCanFilter: () => {
@@ -1065,43 +1002,37 @@
1065
1002
  getIsFiltered: () => column.getFilterIndex() > -1,
1066
1003
  getFilterValue: () => {
1067
1004
  var _table$getState$colum, _table$getState$colum2;
1068
-
1069
1005
  return (_table$getState$colum = table.getState().columnFilters) == null ? void 0 : (_table$getState$colum2 = _table$getState$colum.find(d => d.id === column.id)) == null ? void 0 : _table$getState$colum2.value;
1070
1006
  },
1071
1007
  getFilterIndex: () => {
1072
1008
  var _table$getState$colum3;
1073
-
1074
1009
  return ((_table$getState$colum3 = table.getState().columnFilters) == null ? void 0 : _table$getState$colum3.findIndex(d => d.id === column.id)) ?? -1;
1075
1010
  },
1076
1011
  setFilterValue: value => {
1077
1012
  table.setColumnFilters(old => {
1078
1013
  const filterFn = column.getFilterFn();
1079
1014
  const previousfilter = old == null ? void 0 : old.find(d => d.id === column.id);
1080
- const newFilter = functionalUpdate(value, previousfilter ? previousfilter.value : undefined); //
1015
+ const newFilter = functionalUpdate(value, previousfilter ? previousfilter.value : undefined);
1081
1016
 
1017
+ //
1082
1018
  if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {
1083
1019
  return (old == null ? void 0 : old.filter(d => d.id !== column.id)) ?? [];
1084
1020
  }
1085
-
1086
1021
  const newFilterObj = {
1087
1022
  id: column.id,
1088
1023
  value: newFilter
1089
1024
  };
1090
-
1091
1025
  if (previousfilter) {
1092
1026
  return (old == null ? void 0 : old.map(d => {
1093
1027
  if (d.id === column.id) {
1094
1028
  return newFilterObj;
1095
1029
  }
1096
-
1097
1030
  return d;
1098
1031
  })) ?? [];
1099
1032
  }
1100
-
1101
1033
  if (old != null && old.length) {
1102
1034
  return [...old, newFilterObj];
1103
1035
  }
1104
-
1105
1036
  return [newFilterObj];
1106
1037
  });
1107
1038
  },
@@ -1110,7 +1041,6 @@
1110
1041
  if (!column._getFacetedRowModel) {
1111
1042
  return table.getPreFilteredRowModel();
1112
1043
  }
1113
-
1114
1044
  return column._getFacetedRowModel();
1115
1045
  },
1116
1046
  _getFacetedUniqueValues: table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, column.id),
@@ -1118,7 +1048,6 @@
1118
1048
  if (!column._getFacetedUniqueValues) {
1119
1049
  return new Map();
1120
1050
  }
1121
-
1122
1051
  return column._getFacetedUniqueValues();
1123
1052
  },
1124
1053
  _getFacetedMinMaxValues: table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, column.id),
@@ -1126,13 +1055,13 @@
1126
1055
  if (!column._getFacetedMinMaxValues) {
1127
1056
  return undefined;
1128
1057
  }
1129
-
1130
1058
  return column._getFacetedMinMaxValues();
1131
- } // () => [column.getFacetedRowModel()],
1059
+ }
1060
+ // () => [column.getFacetedRowModel()],
1132
1061
  // facetedRowModel => getRowModelMinMaxValues(facetedRowModel, column.id),
1133
-
1134
1062
  };
1135
1063
  },
1064
+
1136
1065
  createRow: (row, table) => {
1137
1066
  return {
1138
1067
  columnFilters: {},
@@ -1146,7 +1075,6 @@
1146
1075
  },
1147
1076
  getGlobalFilterFn: () => {
1148
1077
  var _table$options$filter2;
1149
-
1150
1078
  const {
1151
1079
  globalFilterFn: globalFilterFn
1152
1080
  } = table.options;
@@ -1154,25 +1082,19 @@
1154
1082
  },
1155
1083
  setColumnFilters: updater => {
1156
1084
  const leafColumns = table.getAllLeafColumns();
1157
-
1158
1085
  const updateFn = old => {
1159
1086
  var _functionalUpdate;
1160
-
1161
1087
  return (_functionalUpdate = functionalUpdate(updater, old)) == null ? void 0 : _functionalUpdate.filter(filter => {
1162
1088
  const column = leafColumns.find(d => d.id === filter.id);
1163
-
1164
1089
  if (column) {
1165
1090
  const filterFn = column.getFilterFn();
1166
-
1167
1091
  if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {
1168
1092
  return false;
1169
1093
  }
1170
1094
  }
1171
-
1172
1095
  return true;
1173
1096
  });
1174
1097
  };
1175
-
1176
1098
  table.options.onColumnFiltersChange == null ? void 0 : table.options.onColumnFiltersChange(updateFn);
1177
1099
  },
1178
1100
  setGlobalFilter: updater => {
@@ -1183,7 +1105,6 @@
1183
1105
  },
1184
1106
  resetColumnFilters: defaultState => {
1185
1107
  var _table$initialState;
1186
-
1187
1108
  table.setColumnFilters(defaultState ? [] : ((_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnFilters) ?? []);
1188
1109
  },
1189
1110
  getPreFilteredRowModel: () => table.getCoreRowModel(),
@@ -1191,11 +1112,9 @@
1191
1112
  if (!table._getFilteredRowModel && table.options.getFilteredRowModel) {
1192
1113
  table._getFilteredRowModel = table.options.getFilteredRowModel(table);
1193
1114
  }
1194
-
1195
1115
  if (table.options.manualFiltering || !table._getFilteredRowModel) {
1196
1116
  return table.getPreFilteredRowModel();
1197
1117
  }
1198
-
1199
1118
  return table._getFilteredRowModel();
1200
1119
  },
1201
1120
  _getGlobalFacetedRowModel: table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, '__global__'),
@@ -1203,7 +1122,6 @@
1203
1122
  if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {
1204
1123
  return table.getPreFilteredRowModel();
1205
1124
  }
1206
-
1207
1125
  return table._getGlobalFacetedRowModel();
1208
1126
  },
1209
1127
  _getGlobalFacetedUniqueValues: table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, '__global__'),
@@ -1211,7 +1129,6 @@
1211
1129
  if (!table._getGlobalFacetedUniqueValues) {
1212
1130
  return new Map();
1213
1131
  }
1214
-
1215
1132
  return table._getGlobalFacetedUniqueValues();
1216
1133
  },
1217
1134
  _getGlobalFacetedMinMaxValues: table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, '__global__'),
@@ -1219,7 +1136,6 @@
1219
1136
  if (!table._getGlobalFacetedMinMaxValues) {
1220
1137
  return;
1221
1138
  }
1222
-
1223
1139
  return table._getGlobalFacetedMinMaxValues();
1224
1140
  }
1225
1141
  };
@@ -1237,37 +1153,31 @@
1237
1153
  return sum + (typeof nextValue === 'number' ? nextValue : 0);
1238
1154
  }, 0);
1239
1155
  };
1240
-
1241
1156
  const min = (columnId, _leafRows, childRows) => {
1242
1157
  let min;
1243
1158
  childRows.forEach(row => {
1244
1159
  const value = row.getValue(columnId);
1245
-
1246
1160
  if (value != null && (min > value || min === undefined && value >= value)) {
1247
1161
  min = value;
1248
1162
  }
1249
1163
  });
1250
1164
  return min;
1251
1165
  };
1252
-
1253
1166
  const max = (columnId, _leafRows, childRows) => {
1254
1167
  let max;
1255
1168
  childRows.forEach(row => {
1256
1169
  const value = row.getValue(columnId);
1257
-
1258
1170
  if (value != null && (max < value || max === undefined && value >= value)) {
1259
1171
  max = value;
1260
1172
  }
1261
1173
  });
1262
1174
  return max;
1263
1175
  };
1264
-
1265
1176
  const extent = (columnId, _leafRows, childRows) => {
1266
1177
  let min;
1267
1178
  let max;
1268
1179
  childRows.forEach(row => {
1269
1180
  const value = row.getValue(columnId);
1270
-
1271
1181
  if (value != null) {
1272
1182
  if (min === undefined) {
1273
1183
  if (value >= value) min = max = value;
@@ -1279,13 +1189,11 @@
1279
1189
  });
1280
1190
  return [min, max];
1281
1191
  };
1282
-
1283
1192
  const mean = (columnId, leafRows) => {
1284
1193
  let count = 0;
1285
1194
  let sum = 0;
1286
1195
  leafRows.forEach(row => {
1287
1196
  let value = row.getValue(columnId);
1288
-
1289
1197
  if (value != null && (value = +value) >= value) {
1290
1198
  ++count, sum += value;
1291
1199
  }
@@ -1293,17 +1201,14 @@
1293
1201
  if (count) return sum / count;
1294
1202
  return;
1295
1203
  };
1296
-
1297
1204
  const median = (columnId, leafRows) => {
1298
1205
  if (!leafRows.length) {
1299
1206
  return;
1300
1207
  }
1301
-
1302
1208
  let min = 0;
1303
1209
  let max = 0;
1304
1210
  leafRows.forEach(row => {
1305
1211
  let value = row.getValue(columnId);
1306
-
1307
1212
  if (typeof value === 'number') {
1308
1213
  min = Math.min(min, value);
1309
1214
  max = Math.max(max, value);
@@ -1311,19 +1216,15 @@
1311
1216
  });
1312
1217
  return (min + max) / 2;
1313
1218
  };
1314
-
1315
1219
  const unique = (columnId, leafRows) => {
1316
1220
  return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
1317
1221
  };
1318
-
1319
1222
  const uniqueCount = (columnId, leafRows) => {
1320
1223
  return new Set(leafRows.map(d => d.getValue(columnId))).size;
1321
1224
  };
1322
-
1323
1225
  const count = (_columnId, leafRows) => {
1324
1226
  return leafRows.length;
1325
1227
  };
1326
-
1327
1228
  const aggregationFns = {
1328
1229
  sum,
1329
1230
  min,
@@ -1337,12 +1238,12 @@
1337
1238
  };
1338
1239
 
1339
1240
  //
1241
+
1340
1242
  const Grouping = {
1341
1243
  getDefaultColumnDef: () => {
1342
1244
  return {
1343
1245
  aggregatedCell: props => {
1344
1246
  var _props$getValue;
1345
-
1346
1247
  return ((_props$getValue = props.getValue()) == null ? void 0 : _props$getValue.toString == null ? void 0 : _props$getValue.toString()) ?? null;
1347
1248
  },
1348
1249
  aggregationFn: 'auto'
@@ -1368,7 +1269,6 @@
1368
1269
  if (old != null && old.includes(column.id)) {
1369
1270
  return old.filter(d => d !== column.id);
1370
1271
  }
1371
-
1372
1272
  return [...(old ?? []), column.id];
1373
1273
  });
1374
1274
  },
@@ -1377,12 +1277,10 @@
1377
1277
  },
1378
1278
  getIsGrouped: () => {
1379
1279
  var _table$getState$group;
1380
-
1381
1280
  return (_table$getState$group = table.getState().grouping) == null ? void 0 : _table$getState$group.includes(column.id);
1382
1281
  },
1383
1282
  getGroupedIndex: () => {
1384
1283
  var _table$getState$group2;
1385
-
1386
1284
  return (_table$getState$group2 = table.getState().grouping) == null ? void 0 : _table$getState$group2.indexOf(column.id);
1387
1285
  },
1388
1286
  getToggleGroupingHandler: () => {
@@ -1395,22 +1293,18 @@
1395
1293
  getAutoAggregationFn: () => {
1396
1294
  const firstRow = table.getCoreRowModel().flatRows[0];
1397
1295
  const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
1398
-
1399
1296
  if (typeof value === 'number') {
1400
1297
  return aggregationFns.sum;
1401
1298
  }
1402
-
1403
1299
  if (Object.prototype.toString.call(value) === '[object Date]') {
1404
1300
  return aggregationFns.extent;
1405
1301
  }
1406
1302
  },
1407
1303
  getAggregationFn: () => {
1408
1304
  var _table$options$aggreg;
1409
-
1410
1305
  if (!column) {
1411
1306
  throw new Error();
1412
1307
  }
1413
-
1414
1308
  return isFunction(column.columnDef.aggregationFn) ? column.columnDef.aggregationFn : column.columnDef.aggregationFn === 'auto' ? column.getAutoAggregationFn() : ((_table$options$aggreg = table.options.aggregationFns) == null ? void 0 : _table$options$aggreg[column.columnDef.aggregationFn]) ?? aggregationFns[column.columnDef.aggregationFn];
1415
1309
  }
1416
1310
  };
@@ -1420,7 +1314,6 @@
1420
1314
  setGrouping: updater => table.options.onGroupingChange == null ? void 0 : table.options.onGroupingChange(updater),
1421
1315
  resetGrouping: defaultState => {
1422
1316
  var _table$initialState;
1423
-
1424
1317
  table.setGrouping(defaultState ? [] : ((_table$initialState = table.initialState) == null ? void 0 : _table$initialState.grouping) ?? []);
1425
1318
  },
1426
1319
  getPreGroupedRowModel: () => table.getFilteredRowModel(),
@@ -1428,11 +1321,9 @@
1428
1321
  if (!table._getGroupedRowModel && table.options.getGroupedRowModel) {
1429
1322
  table._getGroupedRowModel = table.options.getGroupedRowModel(table);
1430
1323
  }
1431
-
1432
1324
  if (table.options.manualGrouping || !table._getGroupedRowModel) {
1433
1325
  return table.getPreGroupedRowModel();
1434
1326
  }
1435
-
1436
1327
  return table._getGroupedRowModel();
1437
1328
  }
1438
1329
  };
@@ -1444,13 +1335,11 @@
1444
1335
  };
1445
1336
  },
1446
1337
  createCell: (cell, column, row, table) => {
1447
-
1448
1338
  return {
1449
1339
  getIsGrouped: () => column.getIsGrouped() && column.id === row.groupingColumnId,
1450
1340
  getIsPlaceholder: () => !cell.getIsGrouped() && column.getIsGrouped(),
1451
1341
  getIsAggregated: () => {
1452
1342
  var _row$subRows;
1453
-
1454
1343
  return !cell.getIsGrouped() && !cell.getIsPlaceholder() && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
1455
1344
  }
1456
1345
  };
@@ -1460,18 +1349,16 @@
1460
1349
  if (!(grouping != null && grouping.length) || !groupedColumnMode) {
1461
1350
  return leafColumns;
1462
1351
  }
1463
-
1464
1352
  const nonGroupingColumns = leafColumns.filter(col => !grouping.includes(col.id));
1465
-
1466
1353
  if (groupedColumnMode === 'remove') {
1467
1354
  return nonGroupingColumns;
1468
1355
  }
1469
-
1470
1356
  const groupingColumns = grouping.map(g => leafColumns.find(col => col.id === g)).filter(Boolean);
1471
1357
  return [...groupingColumns, ...nonGroupingColumns];
1472
1358
  }
1473
1359
 
1474
1360
  //
1361
+
1475
1362
  const Ordering = {
1476
1363
  getInitialState: state => {
1477
1364
  return {
@@ -1493,51 +1380,54 @@
1493
1380
  _getOrderColumnsFn: memo(() => [table.getState().columnOrder, table.getState().grouping, table.options.groupedColumnMode], (columnOrder, grouping, groupedColumnMode) => columns => {
1494
1381
  // Sort grouped columns to the start of the column list
1495
1382
  // before the headers are built
1496
- let orderedColumns = []; // If there is no order, return the normal columns
1383
+ let orderedColumns = [];
1497
1384
 
1385
+ // If there is no order, return the normal columns
1498
1386
  if (!(columnOrder != null && columnOrder.length)) {
1499
1387
  orderedColumns = columns;
1500
1388
  } else {
1501
- const columnOrderCopy = [...columnOrder]; // If there is an order, make a copy of the columns
1389
+ const columnOrderCopy = [...columnOrder];
1502
1390
 
1503
- const columnsCopy = [...columns]; // And make a new ordered array of the columns
1504
- // Loop over the columns and place them in order into the new array
1391
+ // If there is an order, make a copy of the columns
1392
+ const columnsCopy = [...columns];
1505
1393
 
1394
+ // And make a new ordered array of the columns
1395
+
1396
+ // Loop over the columns and place them in order into the new array
1506
1397
  while (columnsCopy.length && columnOrderCopy.length) {
1507
1398
  const targetColumnId = columnOrderCopy.shift();
1508
1399
  const foundIndex = columnsCopy.findIndex(d => d.id === targetColumnId);
1509
-
1510
1400
  if (foundIndex > -1) {
1511
1401
  orderedColumns.push(columnsCopy.splice(foundIndex, 1)[0]);
1512
1402
  }
1513
- } // If there are any columns left, add them to the end
1514
-
1403
+ }
1515
1404
 
1405
+ // If there are any columns left, add them to the end
1516
1406
  orderedColumns = [...orderedColumns, ...columnsCopy];
1517
1407
  }
1518
-
1519
1408
  return orderColumns(orderedColumns, grouping, groupedColumnMode);
1520
1409
  }, {
1521
- key: 'getOrderColumnsFn' // debug: () => table.options.debugAll ?? table.options.debugTable,
1522
-
1410
+ key: 'getOrderColumnsFn'
1411
+ // debug: () => table.options.debugAll ?? table.options.debugTable,
1523
1412
  })
1524
1413
  };
1525
1414
  }
1526
1415
  };
1527
1416
 
1528
1417
  //
1418
+
1529
1419
  const defaultPageIndex = 0;
1530
1420
  const defaultPageSize = 10;
1531
-
1532
1421
  const getDefaultPaginationState = () => ({
1533
1422
  pageIndex: defaultPageIndex,
1534
1423
  pageSize: defaultPageSize
1535
1424
  });
1536
-
1537
1425
  const Pagination = {
1538
1426
  getInitialState: state => {
1539
- return { ...state,
1540
- pagination: { ...getDefaultPaginationState(),
1427
+ return {
1428
+ ...state,
1429
+ pagination: {
1430
+ ...getDefaultPaginationState(),
1541
1431
  ...(state == null ? void 0 : state.pagination)
1542
1432
  }
1543
1433
  };
@@ -1556,14 +1446,11 @@
1556
1446
  table._queue(() => {
1557
1447
  registered = true;
1558
1448
  });
1559
-
1560
1449
  return;
1561
1450
  }
1562
-
1563
1451
  if (table.options.autoResetAll ?? table.options.autoResetPageIndex ?? !table.options.manualPagination) {
1564
1452
  if (queued) return;
1565
1453
  queued = true;
1566
-
1567
1454
  table._queue(() => {
1568
1455
  table.resetPageIndex();
1569
1456
  queued = false;
@@ -1575,7 +1462,6 @@
1575
1462
  let newState = functionalUpdate(updater, old);
1576
1463
  return newState;
1577
1464
  };
1578
-
1579
1465
  return table.options.onPaginationChange == null ? void 0 : table.options.onPaginationChange(safeUpdater);
1580
1466
  },
1581
1467
  resetPagination: defaultState => {
@@ -1586,19 +1472,18 @@
1586
1472
  let pageIndex = functionalUpdate(updater, old.pageIndex);
1587
1473
  const maxPageIndex = typeof table.options.pageCount === 'undefined' || table.options.pageCount === -1 ? Number.MAX_SAFE_INTEGER : table.options.pageCount - 1;
1588
1474
  pageIndex = Math.min(Math.max(0, pageIndex), maxPageIndex);
1589
- return { ...old,
1475
+ return {
1476
+ ...old,
1590
1477
  pageIndex
1591
1478
  };
1592
1479
  });
1593
1480
  },
1594
1481
  resetPageIndex: defaultState => {
1595
1482
  var _table$initialState, _table$initialState$p;
1596
-
1597
1483
  table.setPageIndex(defaultState ? defaultPageIndex : ((_table$initialState = table.initialState) == null ? void 0 : (_table$initialState$p = _table$initialState.pagination) == null ? void 0 : _table$initialState$p.pageIndex) ?? defaultPageIndex);
1598
1484
  },
1599
1485
  resetPageSize: defaultState => {
1600
1486
  var _table$initialState2, _table$initialState2$;
1601
-
1602
1487
  table.setPageSize(defaultState ? defaultPageSize : ((_table$initialState2 = table.initialState) == null ? void 0 : (_table$initialState2$ = _table$initialState2.pagination) == null ? void 0 : _table$initialState2$.pageSize) ?? defaultPageSize);
1603
1488
  },
1604
1489
  setPageSize: updater => {
@@ -1606,7 +1491,8 @@
1606
1491
  const pageSize = Math.max(1, functionalUpdate(updater, old.pageSize));
1607
1492
  const topRowIndex = old.pageSize * old.pageIndex;
1608
1493
  const pageIndex = Math.floor(topRowIndex / pageSize);
1609
- return { ...old,
1494
+ return {
1495
+ ...old,
1610
1496
  pageIndex,
1611
1497
  pageSize
1612
1498
  };
@@ -1614,22 +1500,19 @@
1614
1500
  },
1615
1501
  setPageCount: updater => table.setPagination(old => {
1616
1502
  let newPageCount = functionalUpdate(updater, table.options.pageCount ?? -1);
1617
-
1618
1503
  if (typeof newPageCount === 'number') {
1619
1504
  newPageCount = Math.max(-1, newPageCount);
1620
1505
  }
1621
-
1622
- return { ...old,
1506
+ return {
1507
+ ...old,
1623
1508
  pageCount: newPageCount
1624
1509
  };
1625
1510
  }),
1626
1511
  getPageOptions: memo(() => [table.getPageCount()], pageCount => {
1627
1512
  let pageOptions = [];
1628
-
1629
1513
  if (pageCount && pageCount > 0) {
1630
1514
  pageOptions = [...new Array(pageCount)].fill(null).map((_, i) => i);
1631
1515
  }
1632
-
1633
1516
  return pageOptions;
1634
1517
  }, {
1635
1518
  key: 'getPageOptions',
@@ -1641,15 +1524,12 @@
1641
1524
  pageIndex
1642
1525
  } = table.getState().pagination;
1643
1526
  const pageCount = table.getPageCount();
1644
-
1645
1527
  if (pageCount === -1) {
1646
1528
  return true;
1647
1529
  }
1648
-
1649
1530
  if (pageCount === 0) {
1650
1531
  return false;
1651
1532
  }
1652
-
1653
1533
  return pageIndex < pageCount - 1;
1654
1534
  },
1655
1535
  previousPage: () => {
@@ -1665,11 +1545,9 @@
1665
1545
  if (!table._getPaginationRowModel && table.options.getPaginationRowModel) {
1666
1546
  table._getPaginationRowModel = table.options.getPaginationRowModel(table);
1667
1547
  }
1668
-
1669
1548
  if (table.options.manualPagination || !table._getPaginationRowModel) {
1670
1549
  return table.getPrePaginationRowModel();
1671
1550
  }
1672
-
1673
1551
  return table._getPaginationRowModel();
1674
1552
  },
1675
1553
  getPageCount: () => {
@@ -1680,11 +1558,11 @@
1680
1558
  };
1681
1559
 
1682
1560
  //
1561
+
1683
1562
  const getDefaultPinningState = () => ({
1684
1563
  left: [],
1685
1564
  right: []
1686
1565
  });
1687
-
1688
1566
  const Pinning = {
1689
1567
  getInitialState: state => {
1690
1568
  return {
@@ -1708,14 +1586,12 @@
1708
1586
  right: [...((old == null ? void 0 : old.right) ?? []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds]
1709
1587
  };
1710
1588
  }
1711
-
1712
1589
  if (position === 'left') {
1713
1590
  return {
1714
1591
  left: [...((old == null ? void 0 : old.left) ?? []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds],
1715
1592
  right: ((old == null ? void 0 : old.right) ?? []).filter(d => !(columnIds != null && columnIds.includes(d)))
1716
1593
  };
1717
1594
  }
1718
-
1719
1595
  return {
1720
1596
  left: ((old == null ? void 0 : old.left) ?? []).filter(d => !(columnIds != null && columnIds.includes(d))),
1721
1597
  right: ((old == null ? void 0 : old.right) ?? []).filter(d => !(columnIds != null && columnIds.includes(d)))
@@ -1738,7 +1614,6 @@
1738
1614
  },
1739
1615
  getPinnedIndex: () => {
1740
1616
  var _table$getState$colum, _table$getState$colum2;
1741
-
1742
1617
  const position = column.getIsPinned();
1743
1618
  return position ? ((_table$getState$colum = table.getState().columnPinning) == null ? void 0 : (_table$getState$colum2 = _table$getState$colum[position]) == null ? void 0 : _table$getState$colum2.indexOf(column.id)) ?? -1 : 0;
1744
1619
  }
@@ -1754,7 +1629,8 @@
1754
1629
  debug: () => table.options.debugAll ?? table.options.debugRows
1755
1630
  }),
1756
1631
  getLeftVisibleCells: memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left,,], (allCells, left) => {
1757
- const cells = (left ?? []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
1632
+ const cells = (left ?? []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
1633
+ ...d,
1758
1634
  position: 'left'
1759
1635
  }));
1760
1636
  return cells;
@@ -1763,7 +1639,8 @@
1763
1639
  debug: () => table.options.debugAll ?? table.options.debugRows
1764
1640
  }),
1765
1641
  getRightVisibleCells: memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.right], (allCells, right) => {
1766
- const cells = (right ?? []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
1642
+ const cells = (right ?? []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
1643
+ ...d,
1767
1644
  position: 'right'
1768
1645
  }));
1769
1646
  return cells;
@@ -1778,20 +1655,15 @@
1778
1655
  setColumnPinning: updater => table.options.onColumnPinningChange == null ? void 0 : table.options.onColumnPinningChange(updater),
1779
1656
  resetColumnPinning: defaultState => {
1780
1657
  var _table$initialState;
1781
-
1782
1658
  return table.setColumnPinning(defaultState ? getDefaultPinningState() : ((_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnPinning) ?? getDefaultPinningState());
1783
1659
  },
1784
1660
  getIsSomeColumnsPinned: position => {
1785
1661
  var _pinningState$positio;
1786
-
1787
1662
  const pinningState = table.getState().columnPinning;
1788
-
1789
1663
  if (!position) {
1790
1664
  var _pinningState$left, _pinningState$right;
1791
-
1792
1665
  return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
1793
1666
  }
1794
-
1795
1667
  return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
1796
1668
  },
1797
1669
  getLeftLeafColumns: memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left], (allColumns, left) => {
@@ -1818,6 +1690,7 @@
1818
1690
  };
1819
1691
 
1820
1692
  //
1693
+
1821
1694
  const RowSelection = {
1822
1695
  getInitialState: state => {
1823
1696
  return {
@@ -1830,12 +1703,13 @@
1830
1703
  onRowSelectionChange: makeStateUpdater('rowSelection', table),
1831
1704
  enableRowSelection: true,
1832
1705
  enableMultiRowSelection: true,
1833
- enableSubRowSelection: true // enableGroupingRowSelection: false,
1706
+ enableSubRowSelection: true
1707
+ // enableGroupingRowSelection: false,
1834
1708
  // isAdditiveSelectEvent: (e: unknown) => !!e.metaKey,
1835
1709
  // isInclusiveSelectEvent: (e: unknown) => !!e.shiftKey,
1836
-
1837
1710
  };
1838
1711
  },
1712
+
1839
1713
  createTable: table => {
1840
1714
  return {
1841
1715
  setRowSelection: updater => table.options.onRowSelectionChange == null ? void 0 : table.options.onRowSelectionChange(updater),
@@ -1843,17 +1717,18 @@
1843
1717
  toggleAllRowsSelected: value => {
1844
1718
  table.setRowSelection(old => {
1845
1719
  value = typeof value !== 'undefined' ? value : !table.getIsAllRowsSelected();
1846
- const rowSelection = { ...old
1720
+ const rowSelection = {
1721
+ ...old
1847
1722
  };
1848
- const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows; // We don't use `mutateRowIsSelected` here for performance reasons.
1849
- // All of the rows are flat already, so it wouldn't be worth it
1723
+ const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows;
1850
1724
 
1725
+ // We don't use `mutateRowIsSelected` here for performance reasons.
1726
+ // All of the rows are flat already, so it wouldn't be worth it
1851
1727
  if (value) {
1852
1728
  preGroupedFlatRows.forEach(row => {
1853
1729
  if (!row.getCanSelect()) {
1854
1730
  return;
1855
1731
  }
1856
-
1857
1732
  rowSelection[row.id] = true;
1858
1733
  });
1859
1734
  } else {
@@ -1861,13 +1736,13 @@
1861
1736
  delete rowSelection[row.id];
1862
1737
  });
1863
1738
  }
1864
-
1865
1739
  return rowSelection;
1866
1740
  });
1867
1741
  },
1868
1742
  toggleAllPageRowsSelected: value => table.setRowSelection(old => {
1869
1743
  const resolvedValue = typeof value !== 'undefined' ? value : !table.getIsAllPageRowsSelected();
1870
- const rowSelection = { ...old
1744
+ const rowSelection = {
1745
+ ...old
1871
1746
  };
1872
1747
  table.getRowModel().rows.forEach(row => {
1873
1748
  mutateRowIsSelected(rowSelection, row.id, resolvedValue, table);
@@ -1880,6 +1755,7 @@
1880
1755
  // rowsById,
1881
1756
  // options: { selectGroupingRows, selectSubRows },
1882
1757
  // } = table
1758
+
1883
1759
  // const findSelectedRow = (rows: Row[]) => {
1884
1760
  // let found
1885
1761
  // rows.find(d => {
@@ -1896,10 +1772,13 @@
1896
1772
  // })
1897
1773
  // return found
1898
1774
  // }
1775
+
1899
1776
  // const firstRow = findSelectedRow(rows) || rows[0]
1900
1777
  // const lastRow = rowsById[rowId]
1778
+
1901
1779
  // let include = false
1902
1780
  // const selectedRowIds = {}
1781
+
1903
1782
  // const addRow = (row: Row) => {
1904
1783
  // mutateRowIsSelected(selectedRowIds, row.id, true, {
1905
1784
  // rowsById,
@@ -1907,9 +1786,11 @@
1907
1786
  // selectSubRows: selectSubRows!,
1908
1787
  // })
1909
1788
  // }
1789
+
1910
1790
  // table.rows.forEach(row => {
1911
1791
  // const isFirstRow = row.id === firstRow.id
1912
1792
  // const isLastRow = row.id === lastRow.id
1793
+
1913
1794
  // if (isFirstRow || isLastRow) {
1914
1795
  // if (!include) {
1915
1796
  // include = true
@@ -1918,10 +1799,12 @@
1918
1799
  // include = false
1919
1800
  // }
1920
1801
  // }
1802
+
1921
1803
  // if (include) {
1922
1804
  // addRow(row)
1923
1805
  // }
1924
1806
  // })
1807
+
1925
1808
  // table.setRowSelection(selectedRowIds)
1926
1809
  // },
1927
1810
  getPreSelectedRowModel: () => table.getCoreRowModel(),
@@ -1933,7 +1816,6 @@
1933
1816
  rowsById: {}
1934
1817
  };
1935
1818
  }
1936
-
1937
1819
  return selectRowsFn(table, rowModel);
1938
1820
  }, {
1939
1821
  key: 'getSelectedRowModel',
@@ -1947,7 +1829,6 @@
1947
1829
  rowsById: {}
1948
1830
  };
1949
1831
  }
1950
-
1951
1832
  return selectRowsFn(table, rowModel);
1952
1833
  }, {
1953
1834
  key: "development" === 'production' ,
@@ -1961,36 +1842,38 @@
1961
1842
  rowsById: {}
1962
1843
  };
1963
1844
  }
1964
-
1965
1845
  return selectRowsFn(table, rowModel);
1966
1846
  }, {
1967
1847
  key: "development" === 'production' ,
1968
1848
  debug: () => table.options.debugAll ?? table.options.debugTable
1969
1849
  }),
1970
1850
  ///
1851
+
1971
1852
  // getGroupingRowCanSelect: rowId => {
1972
1853
  // const row = table.getRow(rowId)
1854
+
1973
1855
  // if (!row) {
1974
1856
  // throw new Error()
1975
1857
  // }
1858
+
1976
1859
  // if (typeof table.options.enableGroupingRowSelection === 'function') {
1977
1860
  // return table.options.enableGroupingRowSelection(row)
1978
1861
  // }
1862
+
1979
1863
  // return table.options.enableGroupingRowSelection ?? false
1980
1864
  // },
1865
+
1981
1866
  getIsAllRowsSelected: () => {
1982
1867
  const preGroupedFlatRows = table.getFilteredRowModel().flatRows;
1983
1868
  const {
1984
1869
  rowSelection
1985
1870
  } = table.getState();
1986
1871
  let isAllRowsSelected = Boolean(preGroupedFlatRows.length && Object.keys(rowSelection).length);
1987
-
1988
1872
  if (isAllRowsSelected) {
1989
1873
  if (preGroupedFlatRows.some(row => row.getCanSelect() && !rowSelection[row.id])) {
1990
1874
  isAllRowsSelected = false;
1991
1875
  }
1992
1876
  }
1993
-
1994
1877
  return isAllRowsSelected;
1995
1878
  },
1996
1879
  getIsAllPageRowsSelected: () => {
@@ -1999,11 +1882,9 @@
1999
1882
  rowSelection
2000
1883
  } = table.getState();
2001
1884
  let isAllPageRowsSelected = !!paginationFlatRows.length;
2002
-
2003
1885
  if (isAllPageRowsSelected && paginationFlatRows.some(row => !rowSelection[row.id])) {
2004
1886
  isAllPageRowsSelected = false;
2005
1887
  }
2006
-
2007
1888
  return isAllPageRowsSelected;
2008
1889
  },
2009
1890
  getIsSomeRowsSelected: () => {
@@ -2032,12 +1913,11 @@
2032
1913
  const isSelected = row.getIsSelected();
2033
1914
  table.setRowSelection(old => {
2034
1915
  value = typeof value !== 'undefined' ? value : !isSelected;
2035
-
2036
1916
  if (isSelected === value) {
2037
1917
  return old;
2038
1918
  }
2039
-
2040
- const selectedRowIds = { ...old
1919
+ const selectedRowIds = {
1920
+ ...old
2041
1921
  };
2042
1922
  mutateRowIsSelected(selectedRowIds, row.id, value, table);
2043
1923
  return selectedRowIds;
@@ -2065,28 +1945,24 @@
2065
1945
  if (typeof table.options.enableRowSelection === 'function') {
2066
1946
  return table.options.enableRowSelection(row);
2067
1947
  }
2068
-
2069
1948
  return table.options.enableRowSelection ?? true;
2070
1949
  },
2071
1950
  getCanSelectSubRows: () => {
2072
1951
  if (typeof table.options.enableSubRowSelection === 'function') {
2073
1952
  return table.options.enableSubRowSelection(row);
2074
1953
  }
2075
-
2076
1954
  return table.options.enableSubRowSelection ?? true;
2077
1955
  },
2078
1956
  getCanMultiSelect: () => {
2079
1957
  if (typeof table.options.enableMultiRowSelection === 'function') {
2080
1958
  return table.options.enableMultiRowSelection(row);
2081
1959
  }
2082
-
2083
1960
  return table.options.enableMultiRowSelection ?? true;
2084
1961
  },
2085
1962
  getToggleSelectedHandler: () => {
2086
1963
  const canSelect = row.getCanSelect();
2087
1964
  return e => {
2088
1965
  var _target;
2089
-
2090
1966
  if (!canSelect) return;
2091
1967
  row.toggleSelected((_target = e.target) == null ? void 0 : _target.checked);
2092
1968
  };
@@ -2094,63 +1970,57 @@
2094
1970
  };
2095
1971
  }
2096
1972
  };
2097
-
2098
1973
  const mutateRowIsSelected = (selectedRowIds, id, value, table) => {
2099
1974
  var _row$subRows;
1975
+ const row = table.getRow(id);
1976
+
1977
+ // const isGrouped = row.getIsGrouped()
2100
1978
 
2101
- const row = table.getRow(id); // const isGrouped = row.getIsGrouped()
2102
1979
  // if ( // TODO: enforce grouping row selection rules
2103
1980
  // !isGrouped ||
2104
1981
  // (isGrouped && table.options.enableGroupingRowSelection)
2105
1982
  // ) {
2106
-
2107
1983
  if (value) {
2108
1984
  if (!row.getCanMultiSelect()) {
2109
1985
  Object.keys(selectedRowIds).forEach(key => delete selectedRowIds[key]);
2110
1986
  }
2111
-
2112
1987
  if (row.getCanSelect()) {
2113
1988
  selectedRowIds[id] = true;
2114
1989
  }
2115
1990
  } else {
2116
1991
  delete selectedRowIds[id];
2117
- } // }
2118
-
1992
+ }
1993
+ // }
2119
1994
 
2120
1995
  if ((_row$subRows = row.subRows) != null && _row$subRows.length && row.getCanSelectSubRows()) {
2121
1996
  row.subRows.forEach(row => mutateRowIsSelected(selectedRowIds, row.id, value, table));
2122
1997
  }
2123
1998
  };
2124
-
2125
1999
  function selectRowsFn(table, rowModel) {
2126
2000
  const rowSelection = table.getState().rowSelection;
2127
2001
  const newSelectedFlatRows = [];
2128
- const newSelectedRowsById = {}; // Filters top level and nested rows
2002
+ const newSelectedRowsById = {};
2129
2003
 
2004
+ // Filters top level and nested rows
2130
2005
  const recurseRows = function (rows, depth) {
2131
-
2132
2006
  return rows.map(row => {
2133
2007
  var _row$subRows2;
2134
-
2135
2008
  const isSelected = isRowSelected(row, rowSelection);
2136
-
2137
2009
  if (isSelected) {
2138
2010
  newSelectedFlatRows.push(row);
2139
2011
  newSelectedRowsById[row.id] = row;
2140
2012
  }
2141
-
2142
2013
  if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
2143
- row = { ...row,
2014
+ row = {
2015
+ ...row,
2144
2016
  subRows: recurseRows(row.subRows)
2145
2017
  };
2146
2018
  }
2147
-
2148
2019
  if (isSelected) {
2149
2020
  return row;
2150
2021
  }
2151
2022
  }).filter(Boolean);
2152
2023
  };
2153
-
2154
2024
  return {
2155
2025
  rows: recurseRows(rowModel.rows),
2156
2026
  flatRows: newSelectedFlatRows,
@@ -2169,7 +2039,6 @@
2169
2039
  if (someSelected && !allChildrenSelected) {
2170
2040
  return;
2171
2041
  }
2172
-
2173
2042
  if (isRowSelected(subRow, selection)) {
2174
2043
  someSelected = true;
2175
2044
  } else {
@@ -2178,112 +2047,104 @@
2178
2047
  });
2179
2048
  return allChildrenSelected ? 'all' : someSelected ? 'some' : false;
2180
2049
  }
2181
-
2182
2050
  return false;
2183
2051
  }
2184
2052
 
2185
2053
  const reSplitAlphaNumeric = /([0-9]+)/gm;
2186
-
2187
2054
  const alphanumeric = (rowA, rowB, columnId) => {
2188
2055
  return compareAlphanumeric(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
2189
2056
  };
2190
-
2191
2057
  const alphanumericCaseSensitive = (rowA, rowB, columnId) => {
2192
2058
  return compareAlphanumeric(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
2193
- }; // The text filter is more basic (less numeric support)
2194
- // but is much faster
2195
-
2059
+ };
2196
2060
 
2061
+ // The text filter is more basic (less numeric support)
2062
+ // but is much faster
2197
2063
  const text = (rowA, rowB, columnId) => {
2198
2064
  return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
2199
- }; // The text filter is more basic (less numeric support)
2200
- // but is much faster
2201
-
2065
+ };
2202
2066
 
2067
+ // The text filter is more basic (less numeric support)
2068
+ // but is much faster
2203
2069
  const textCaseSensitive = (rowA, rowB, columnId) => {
2204
2070
  return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
2205
2071
  };
2206
-
2207
2072
  const datetime = (rowA, rowB, columnId) => {
2208
2073
  const a = rowA.getValue(columnId);
2209
- const b = rowB.getValue(columnId); // Can handle nullish values
2074
+ const b = rowB.getValue(columnId);
2075
+
2076
+ // Can handle nullish values
2210
2077
  // Use > and < because == (and ===) doesn't work with
2211
2078
  // Date objects (would require calling getTime()).
2212
-
2213
2079
  return a > b ? 1 : a < b ? -1 : 0;
2214
2080
  };
2215
-
2216
2081
  const basic = (rowA, rowB, columnId) => {
2217
2082
  return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
2218
- }; // Utils
2083
+ };
2219
2084
 
2085
+ // Utils
2220
2086
 
2221
2087
  function compareBasic(a, b) {
2222
2088
  return a === b ? 0 : a > b ? 1 : -1;
2223
2089
  }
2224
-
2225
2090
  function toString(a) {
2226
2091
  if (typeof a === 'number') {
2227
2092
  if (isNaN(a) || a === Infinity || a === -Infinity) {
2228
2093
  return '';
2229
2094
  }
2230
-
2231
2095
  return String(a);
2232
2096
  }
2233
-
2234
2097
  if (typeof a === 'string') {
2235
2098
  return a;
2236
2099
  }
2237
-
2238
2100
  return '';
2239
- } // Mixed sorting is slow, but very inclusive of many edge cases.
2101
+ }
2102
+
2103
+ // Mixed sorting is slow, but very inclusive of many edge cases.
2240
2104
  // It handles numbers, mixed alphanumeric combinations, and even
2241
2105
  // null, undefined, and Infinity
2242
-
2243
-
2244
2106
  function compareAlphanumeric(aStr, bStr) {
2245
2107
  // Split on number groups, but keep the delimiter
2246
2108
  // Then remove falsey split values
2247
2109
  const a = aStr.split(reSplitAlphaNumeric).filter(Boolean);
2248
- const b = bStr.split(reSplitAlphaNumeric).filter(Boolean); // While
2110
+ const b = bStr.split(reSplitAlphaNumeric).filter(Boolean);
2249
2111
 
2112
+ // While
2250
2113
  while (a.length && b.length) {
2251
2114
  const aa = a.shift();
2252
2115
  const bb = b.shift();
2253
2116
  const an = parseInt(aa, 10);
2254
2117
  const bn = parseInt(bb, 10);
2255
- const combo = [an, bn].sort(); // Both are string
2118
+ const combo = [an, bn].sort();
2256
2119
 
2120
+ // Both are string
2257
2121
  if (isNaN(combo[0])) {
2258
2122
  if (aa > bb) {
2259
2123
  return 1;
2260
2124
  }
2261
-
2262
2125
  if (bb > aa) {
2263
2126
  return -1;
2264
2127
  }
2265
-
2266
2128
  continue;
2267
- } // One is a string, one is a number
2268
-
2129
+ }
2269
2130
 
2131
+ // One is a string, one is a number
2270
2132
  if (isNaN(combo[1])) {
2271
2133
  return isNaN(an) ? -1 : 1;
2272
- } // Both are numbers
2273
-
2134
+ }
2274
2135
 
2136
+ // Both are numbers
2275
2137
  if (an > bn) {
2276
2138
  return 1;
2277
2139
  }
2278
-
2279
2140
  if (bn > an) {
2280
2141
  return -1;
2281
2142
  }
2282
2143
  }
2283
-
2284
2144
  return a.length - b.length;
2285
- } // Exports
2145
+ }
2286
2146
 
2147
+ // Exports
2287
2148
 
2288
2149
  const sortingFns = {
2289
2150
  alphanumeric,
@@ -2295,6 +2156,7 @@
2295
2156
  };
2296
2157
 
2297
2158
  //
2159
+
2298
2160
  const Sorting = {
2299
2161
  getInitialState: state => {
2300
2162
  return {
@@ -2320,46 +2182,36 @@
2320
2182
  getAutoSortingFn: () => {
2321
2183
  const firstRows = table.getFilteredRowModel().flatRows.slice(10);
2322
2184
  let isString = false;
2323
-
2324
2185
  for (const row of firstRows) {
2325
2186
  const value = row == null ? void 0 : row.getValue(column.id);
2326
-
2327
2187
  if (Object.prototype.toString.call(value) === '[object Date]') {
2328
2188
  return sortingFns.datetime;
2329
2189
  }
2330
-
2331
2190
  if (typeof value === 'string') {
2332
2191
  isString = true;
2333
-
2334
2192
  if (value.split(reSplitAlphaNumeric).length > 1) {
2335
2193
  return sortingFns.alphanumeric;
2336
2194
  }
2337
2195
  }
2338
2196
  }
2339
-
2340
2197
  if (isString) {
2341
2198
  return sortingFns.text;
2342
2199
  }
2343
-
2344
2200
  return sortingFns.basic;
2345
2201
  },
2346
2202
  getAutoSortDir: () => {
2347
2203
  const firstRow = table.getFilteredRowModel().flatRows[0];
2348
2204
  const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
2349
-
2350
2205
  if (typeof value === 'string') {
2351
2206
  return 'asc';
2352
2207
  }
2353
-
2354
2208
  return 'desc';
2355
2209
  },
2356
2210
  getSortingFn: () => {
2357
2211
  var _table$options$sortin;
2358
-
2359
2212
  if (!column) {
2360
2213
  throw new Error();
2361
2214
  }
2362
-
2363
2215
  return isFunction(column.columnDef.sortingFn) ? column.columnDef.sortingFn : column.columnDef.sortingFn === 'auto' ? column.getAutoSortingFn() : ((_table$options$sortin = table.options.sortingFns) == null ? void 0 : _table$options$sortin[column.columnDef.sortingFn]) ?? sortingFns[column.columnDef.sortingFn];
2364
2216
  },
2365
2217
  toggleSorting: (desc, multi) => {
@@ -2371,6 +2223,7 @@
2371
2223
  // })
2372
2224
  // return
2373
2225
  // }
2226
+
2374
2227
  // this needs to be outside of table.setSorting to be in sync with rerender
2375
2228
  const nextSortingOrder = column.getNextSortingOrder();
2376
2229
  const hasManualValue = typeof desc !== 'undefined' && desc !== null;
@@ -2378,11 +2231,13 @@
2378
2231
  // Find any existing sorting for this column
2379
2232
  const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
2380
2233
  const existingIndex = old == null ? void 0 : old.findIndex(d => d.id === column.id);
2381
- let newSorting = []; // What should we do with this sort action?
2234
+ let newSorting = [];
2382
2235
 
2236
+ // What should we do with this sort action?
2383
2237
  let sortAction;
2384
- let nextDesc = hasManualValue ? desc : nextSortingOrder === 'desc'; // Multi-mode
2238
+ let nextDesc = hasManualValue ? desc : nextSortingOrder === 'desc';
2385
2239
 
2240
+ // Multi-mode
2386
2241
  if (old != null && old.length && column.getCanMultiSort() && multi) {
2387
2242
  if (existingSorting) {
2388
2243
  sortAction = 'toggle';
@@ -2398,9 +2253,9 @@
2398
2253
  } else {
2399
2254
  sortAction = 'replace';
2400
2255
  }
2401
- } // Handle toggle states that will remove the sorting
2402
-
2256
+ }
2403
2257
 
2258
+ // Handle toggle states that will remove the sorting
2404
2259
  if (sortAction === 'toggle') {
2405
2260
  // If we are "actually" toggling (not a manual set value), should we remove the sorting?
2406
2261
  if (!hasManualValue) {
@@ -2410,23 +2265,22 @@
2410
2265
  }
2411
2266
  }
2412
2267
  }
2413
-
2414
2268
  if (sortAction === 'add') {
2415
2269
  newSorting = [...old, {
2416
2270
  id: column.id,
2417
2271
  desc: nextDesc
2418
- }]; // Take latest n columns
2419
-
2272
+ }];
2273
+ // Take latest n columns
2420
2274
  newSorting.splice(0, newSorting.length - (table.options.maxMultiSortColCount ?? Number.MAX_SAFE_INTEGER));
2421
2275
  } else if (sortAction === 'toggle') {
2422
2276
  // This flips (or sets) the
2423
2277
  newSorting = old.map(d => {
2424
2278
  if (d.id === column.id) {
2425
- return { ...d,
2279
+ return {
2280
+ ...d,
2426
2281
  desc: nextDesc
2427
2282
  };
2428
2283
  }
2429
-
2430
2284
  return d;
2431
2285
  });
2432
2286
  } else if (sortAction === 'remove') {
@@ -2437,7 +2291,6 @@
2437
2291
  desc: nextDesc
2438
2292
  }];
2439
2293
  }
2440
-
2441
2294
  return newSorting;
2442
2295
  });
2443
2296
  },
@@ -2448,17 +2301,15 @@
2448
2301
  getNextSortingOrder: multi => {
2449
2302
  const firstSortDirection = column.getFirstSortDir();
2450
2303
  const isSorted = column.getIsSorted();
2451
-
2452
2304
  if (!isSorted) {
2453
2305
  return firstSortDirection;
2454
2306
  }
2455
-
2456
- if (isSorted !== firstSortDirection && (table.options.enableSortingRemoval ?? true) && ( // If enableSortRemove, enable in general
2307
+ if (isSorted !== firstSortDirection && (table.options.enableSortingRemoval ?? true) && (
2308
+ // If enableSortRemove, enable in general
2457
2309
  multi ? table.options.enableMultiRemove ?? true : true) // If multi, don't allow if enableMultiRemove))
2458
2310
  ) {
2459
2311
  return false;
2460
2312
  }
2461
-
2462
2313
  return isSorted === 'desc' ? 'asc' : 'desc';
2463
2314
  },
2464
2315
  getCanSort: () => {
@@ -2469,13 +2320,11 @@
2469
2320
  },
2470
2321
  getIsSorted: () => {
2471
2322
  var _table$getState$sorti;
2472
-
2473
2323
  const columnSort = (_table$getState$sorti = table.getState().sorting) == null ? void 0 : _table$getState$sorti.find(d => d.id === column.id);
2474
2324
  return !columnSort ? false : columnSort.desc ? 'desc' : 'asc';
2475
2325
  },
2476
2326
  getSortIndex: () => {
2477
2327
  var _table$getState$sorti2;
2478
-
2479
2328
  return ((_table$getState$sorti2 = table.getState().sorting) == null ? void 0 : _table$getState$sorti2.findIndex(d => d.id === column.id)) ?? -1;
2480
2329
  },
2481
2330
  clearSorting: () => {
@@ -2497,7 +2346,6 @@
2497
2346
  setSorting: updater => table.options.onSortingChange == null ? void 0 : table.options.onSortingChange(updater),
2498
2347
  resetSorting: defaultState => {
2499
2348
  var _table$initialState;
2500
-
2501
2349
  table.setSorting(defaultState ? [] : ((_table$initialState = table.initialState) == null ? void 0 : _table$initialState.sorting) ?? []);
2502
2350
  },
2503
2351
  getPreSortedRowModel: () => table.getGroupedRowModel(),
@@ -2505,11 +2353,9 @@
2505
2353
  if (!table._getSortedRowModel && table.options.getSortedRowModel) {
2506
2354
  table._getSortedRowModel = table.options.getSortedRowModel(table);
2507
2355
  }
2508
-
2509
2356
  if (table.options.manualSorting || !table._getSortedRowModel) {
2510
2357
  return table.getPreSortedRowModel();
2511
2358
  }
2512
-
2513
2359
  return table._getSortedRowModel();
2514
2360
  }
2515
2361
  };
@@ -2517,6 +2363,7 @@
2517
2363
  };
2518
2364
 
2519
2365
  //
2366
+
2520
2367
  const Visibility = {
2521
2368
  getInitialState: state => {
2522
2369
  return {
@@ -2533,14 +2380,14 @@
2533
2380
  return {
2534
2381
  toggleVisibility: value => {
2535
2382
  if (column.getCanHide()) {
2536
- table.setColumnVisibility(old => ({ ...old,
2383
+ table.setColumnVisibility(old => ({
2384
+ ...old,
2537
2385
  [column.id]: value ?? !column.getIsVisible()
2538
2386
  }));
2539
2387
  }
2540
2388
  },
2541
2389
  getIsVisible: () => {
2542
2390
  var _table$getState$colum;
2543
-
2544
2391
  return ((_table$getState$colum = table.getState().columnVisibility) == null ? void 0 : _table$getState$colum[column.id]) ?? true;
2545
2392
  },
2546
2393
  getCanHide: () => {
@@ -2576,7 +2423,6 @@
2576
2423
  debug: () => table.options.debugAll ?? table.options.debugColumns
2577
2424
  });
2578
2425
  };
2579
-
2580
2426
  return {
2581
2427
  getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => table.getAllFlatColumns()),
2582
2428
  getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => table.getAllLeafColumns()),
@@ -2589,7 +2435,8 @@
2589
2435
  },
2590
2436
  toggleAllColumnsVisible: value => {
2591
2437
  value = value ?? !table.getIsAllColumnsVisible();
2592
- table.setColumnVisibility(table.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
2438
+ table.setColumnVisibility(table.getAllLeafColumns().reduce((obj, column) => ({
2439
+ ...obj,
2593
2440
  [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
2594
2441
  }), {}));
2595
2442
  },
@@ -2598,7 +2445,6 @@
2598
2445
  getToggleAllColumnsVisibilityHandler: () => {
2599
2446
  return e => {
2600
2447
  var _target;
2601
-
2602
2448
  table.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
2603
2449
  };
2604
2450
  }
@@ -2606,60 +2452,57 @@
2606
2452
  }
2607
2453
  };
2608
2454
 
2609
- const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]; //
2455
+ const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing];
2456
+
2457
+ //
2610
2458
 
2611
2459
  function createTable(options) {
2612
2460
  if (options.debugAll || options.debugTable) {
2613
2461
  console.info('Creating Table Instance...');
2614
2462
  }
2615
-
2616
2463
  let table = {
2617
2464
  _features: features
2618
2465
  };
2619
-
2620
2466
  const defaultOptions = table._features.reduce((obj, feature) => {
2621
2467
  return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(table));
2622
2468
  }, {});
2623
-
2624
2469
  const mergeOptions = options => {
2625
2470
  if (table.options.mergeOptions) {
2626
2471
  return table.options.mergeOptions(defaultOptions, options);
2627
2472
  }
2628
-
2629
- return { ...defaultOptions,
2473
+ return {
2474
+ ...defaultOptions,
2630
2475
  ...options
2631
2476
  };
2632
2477
  };
2633
-
2634
2478
  const coreInitialState = {};
2635
- let initialState = { ...coreInitialState,
2479
+ let initialState = {
2480
+ ...coreInitialState,
2636
2481
  ...(options.initialState ?? {})
2637
2482
  };
2638
-
2639
2483
  table._features.forEach(feature => {
2640
2484
  initialState = (feature.getInitialState == null ? void 0 : feature.getInitialState(initialState)) ?? initialState;
2641
2485
  });
2642
-
2643
2486
  const queued = [];
2644
2487
  let queuedTimeout = false;
2645
2488
  const coreInstance = {
2646
2489
  _features: features,
2647
- options: { ...defaultOptions,
2490
+ options: {
2491
+ ...defaultOptions,
2648
2492
  ...options
2649
2493
  },
2650
2494
  initialState,
2651
2495
  _queue: cb => {
2652
2496
  queued.push(cb);
2653
-
2654
2497
  if (!queuedTimeout) {
2655
- queuedTimeout = true; // Schedule a microtask to run the queued callbacks after
2656
- // the current call stack (render, etc) has finished.
2498
+ queuedTimeout = true;
2657
2499
 
2500
+ // Schedule a microtask to run the queued callbacks after
2501
+ // the current call stack (render, etc) has finished.
2658
2502
  Promise.resolve().then(() => {
2659
2503
  while (queued.length) {
2660
2504
  queued.shift()();
2661
2505
  }
2662
-
2663
2506
  queuedTimeout = false;
2664
2507
  }).catch(error => setTimeout(() => {
2665
2508
  throw error;
@@ -2684,23 +2527,21 @@
2684
2527
  if (!table._getCoreRowModel) {
2685
2528
  table._getCoreRowModel = table.options.getCoreRowModel(table);
2686
2529
  }
2687
-
2688
2530
  return table._getCoreRowModel();
2689
2531
  },
2690
2532
  // The final calls start at the bottom of the model,
2691
2533
  // expanded rows, which then work their way up
2534
+
2692
2535
  getRowModel: () => {
2693
2536
  return table.getPaginationRowModel();
2694
2537
  },
2695
2538
  getRow: id => {
2696
2539
  const row = table.getRowModel().rowsById[id];
2697
-
2698
2540
  if (!row) {
2699
2541
  {
2700
2542
  throw new Error(`getRow expected an ID, but got ${id}`);
2701
2543
  }
2702
2544
  }
2703
-
2704
2545
  return row;
2705
2546
  },
2706
2547
  _getDefaultColumnDef: memo(() => [table.options.defaultColumn], defaultColumn => {
@@ -2708,21 +2549,17 @@
2708
2549
  return {
2709
2550
  header: props => {
2710
2551
  const resolvedColumnDef = props.header.column.columnDef;
2711
-
2712
2552
  if (resolvedColumnDef.accessorKey) {
2713
2553
  return resolvedColumnDef.accessorKey;
2714
2554
  }
2715
-
2716
2555
  if (resolvedColumnDef.accessorFn) {
2717
2556
  return resolvedColumnDef.id;
2718
2557
  }
2719
-
2720
2558
  return null;
2721
2559
  },
2722
2560
  // footer: props => props.header.column.id,
2723
2561
  cell: props => {
2724
2562
  var _props$renderValue;
2725
-
2726
2563
  return ((_props$renderValue = props.renderValue()) == null ? void 0 : _props$renderValue.toString == null ? void 0 : _props$renderValue.toString()) ?? null;
2727
2564
  },
2728
2565
  ...table._features.reduce((obj, feature) => {
@@ -2740,7 +2577,6 @@
2740
2577
  if (depth === void 0) {
2741
2578
  depth = 0;
2742
2579
  }
2743
-
2744
2580
  return columnDefs.map(columnDef => {
2745
2581
  const column = createColumn(table, columnDef, depth, parent);
2746
2582
  const groupingColumnDef = columnDef;
@@ -2748,7 +2584,6 @@
2748
2584
  return column;
2749
2585
  });
2750
2586
  };
2751
-
2752
2587
  return recurseColumns(columnDefs);
2753
2588
  }, {
2754
2589
  key: 'getAllColumns',
@@ -2780,30 +2615,24 @@
2780
2615
  }),
2781
2616
  getColumn: columnId => {
2782
2617
  const column = table._getAllFlatColumnsById()[columnId];
2783
-
2784
2618
  if (!column) {
2785
2619
  {
2786
2620
  console.warn(`[Table] Column with id ${columnId} does not exist.`);
2787
2621
  }
2788
-
2789
2622
  throw new Error();
2790
2623
  }
2791
-
2792
2624
  return column;
2793
2625
  }
2794
2626
  };
2795
2627
  Object.assign(table, coreInstance);
2796
-
2797
2628
  table._features.forEach(feature => {
2798
2629
  return Object.assign(table, feature.createTable == null ? void 0 : feature.createTable(table));
2799
2630
  });
2800
-
2801
2631
  return table;
2802
2632
  }
2803
2633
 
2804
2634
  function createCell(table, row, column, columnId) {
2805
2635
  const getRenderValue = () => cell.getValue() ?? table.options.renderFallbackValue;
2806
-
2807
2636
  const cell = {
2808
2637
  id: `${row.id}_${column.id}`,
2809
2638
  row,
@@ -2822,11 +2651,9 @@
2822
2651
  debug: () => table.options.debugAll
2823
2652
  })
2824
2653
  };
2825
-
2826
2654
  table._features.forEach(feature => {
2827
2655
  Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, table));
2828
2656
  }, {});
2829
-
2830
2657
  return cell;
2831
2658
  }
2832
2659
 
@@ -2841,13 +2668,10 @@
2841
2668
  if (row._valuesCache.hasOwnProperty(columnId)) {
2842
2669
  return row._valuesCache[columnId];
2843
2670
  }
2844
-
2845
2671
  const column = table.getColumn(columnId);
2846
-
2847
2672
  if (!column.accessorFn) {
2848
2673
  return undefined;
2849
2674
  }
2850
-
2851
2675
  row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
2852
2676
  return row._valuesCache[columnId];
2853
2677
  },
@@ -2872,12 +2696,10 @@
2872
2696
  debug: () => table.options.debugAll ?? table.options.debugRows
2873
2697
  })
2874
2698
  };
2875
-
2876
2699
  for (let i = 0; i < table._features.length; i++) {
2877
2700
  const feature = table._features[i];
2878
2701
  Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, table));
2879
2702
  }
2880
-
2881
2703
  return row;
2882
2704
  };
2883
2705
 
@@ -2904,24 +2726,32 @@
2904
2726
  // }
2905
2727
  // }
2906
2728
  // }
2729
+
2907
2730
  // const test: DeepKeys<Person> = 'nested.foo.0.bar'
2908
2731
  // const test2: DeepKeys<Person> = 'nested.bar'
2732
+
2909
2733
  // const helper = createColumnHelper<Person>()
2734
+
2910
2735
  // helper.accessor('nested.foo', {
2911
2736
  // cell: info => info.getValue(),
2912
2737
  // })
2738
+
2913
2739
  // helper.accessor('nested.foo.0.bar', {
2914
2740
  // cell: info => info.getValue(),
2915
2741
  // })
2742
+
2916
2743
  // helper.accessor('nested.bar', {
2917
2744
  // cell: info => info.getValue(),
2918
2745
  // })
2746
+
2919
2747
  function createColumnHelper() {
2920
2748
  return {
2921
2749
  accessor: (accessor, column) => {
2922
- return typeof accessor === 'function' ? { ...column,
2750
+ return typeof accessor === 'function' ? {
2751
+ ...column,
2923
2752
  accessorFn: accessor
2924
- } : { ...column,
2753
+ } : {
2754
+ ...column,
2925
2755
  accessorKey: accessor
2926
2756
  };
2927
2757
  },
@@ -2937,14 +2767,11 @@
2937
2767
  flatRows: [],
2938
2768
  rowsById: {}
2939
2769
  };
2940
-
2941
2770
  const accessRows = function (originalRows, depth, parent) {
2942
2771
  if (depth === void 0) {
2943
2772
  depth = 0;
2944
2773
  }
2945
-
2946
2774
  const rows = [];
2947
-
2948
2775
  for (let i = 0; i < originalRows.length; i++) {
2949
2776
  // This could be an expensive check at scale, so we should move it somewhere else, but where?
2950
2777
  // if (!id) {
@@ -2952,29 +2779,30 @@
2952
2779
  // throw new Error(`getRowId expected an ID, but got ${id}`)
2953
2780
  // }
2954
2781
  // }
2955
- // Make the row
2956
- const row = createRow(table, table._getRowId(originalRows[i], i, parent), originalRows[i], i, depth); // Keep track of every row in a flat array
2957
-
2958
- rowModel.flatRows.push(row); // Also keep track of every row by its ID
2959
2782
 
2960
- rowModel.rowsById[row.id] = row; // Push table row into parent
2783
+ // Make the row
2784
+ const row = createRow(table, table._getRowId(originalRows[i], i, parent), originalRows[i], i, depth);
2961
2785
 
2962
- rows.push(row); // Get the original subrows
2786
+ // Keep track of every row in a flat array
2787
+ rowModel.flatRows.push(row);
2788
+ // Also keep track of every row by its ID
2789
+ rowModel.rowsById[row.id] = row;
2790
+ // Push table row into parent
2791
+ rows.push(row);
2963
2792
 
2793
+ // Get the original subrows
2964
2794
  if (table.options.getSubRows) {
2965
2795
  var _row$originalSubRows;
2796
+ row.originalSubRows = table.options.getSubRows(originalRows[i], i);
2966
2797
 
2967
- row.originalSubRows = table.options.getSubRows(originalRows[i], i); // Then recursively access them
2968
-
2798
+ // Then recursively access them
2969
2799
  if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
2970
2800
  row.subRows = accessRows(row.originalSubRows, depth + 1, row);
2971
2801
  }
2972
2802
  }
2973
2803
  }
2974
-
2975
2804
  return rows;
2976
2805
  };
2977
-
2978
2806
  rowModel.rows = accessRows(data);
2979
2807
  return rowModel;
2980
2808
  }, {
@@ -2990,44 +2818,35 @@
2990
2818
  if (table.options.filterFromLeafRows) {
2991
2819
  return filterRowModelFromLeafs(rows, filterRowImpl, table);
2992
2820
  }
2993
-
2994
2821
  return filterRowModelFromRoot(rows, filterRowImpl, table);
2995
2822
  }
2996
2823
  function filterRowModelFromLeafs(rowsToFilter, filterRow, table) {
2997
2824
  const newFilteredFlatRows = [];
2998
2825
  const newFilteredRowsById = {};
2999
-
3000
2826
  const recurseFilterRows = function (rowsToFilter, depth) {
2827
+ const rows = [];
3001
2828
 
3002
- const rows = []; // Filter from children up first
3003
-
2829
+ // Filter from children up first
3004
2830
  for (let i = 0; i < rowsToFilter.length; i++) {
3005
2831
  var _row$subRows;
3006
-
3007
2832
  let row = rowsToFilter[i];
3008
-
3009
2833
  if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
3010
2834
  const newRow = createRow(table, row.id, row.original, row.index, row.depth);
3011
2835
  newRow.columnFilters = row.columnFilters;
3012
2836
  newRow.subRows = recurseFilterRows(row.subRows);
3013
-
3014
2837
  if (!newRow.subRows.length) {
3015
2838
  continue;
3016
2839
  }
3017
-
3018
2840
  row = newRow;
3019
2841
  }
3020
-
3021
2842
  if (filterRow(row)) {
3022
2843
  rows.push(row);
3023
2844
  newFilteredRowsById[row.id] = row;
3024
2845
  newFilteredRowsById[i] = row;
3025
2846
  }
3026
2847
  }
3027
-
3028
2848
  return rows;
3029
2849
  };
3030
-
3031
2850
  return {
3032
2851
  rows: recurseFilterRows(rowsToFilter),
3033
2852
  flatRows: newFilteredFlatRows,
@@ -3036,35 +2855,32 @@
3036
2855
  }
3037
2856
  function filterRowModelFromRoot(rowsToFilter, filterRow, table) {
3038
2857
  const newFilteredFlatRows = [];
3039
- const newFilteredRowsById = {}; // Filters top level and nested rows
2858
+ const newFilteredRowsById = {};
3040
2859
 
2860
+ // Filters top level and nested rows
3041
2861
  const recurseFilterRows = function (rowsToFilter, depth) {
3042
-
3043
2862
  // Filter from parents downward first
3044
- const rows = []; // Apply the filter to any subRows
3045
2863
 
2864
+ const rows = [];
2865
+
2866
+ // Apply the filter to any subRows
3046
2867
  for (let i = 0; i < rowsToFilter.length; i++) {
3047
2868
  let row = rowsToFilter[i];
3048
2869
  const pass = filterRow(row);
3049
-
3050
2870
  if (pass) {
3051
2871
  var _row$subRows2;
3052
-
3053
2872
  if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
3054
2873
  const newRow = createRow(table, row.id, row.original, row.index, row.depth);
3055
2874
  newRow.subRows = recurseFilterRows(row.subRows);
3056
2875
  row = newRow;
3057
2876
  }
3058
-
3059
2877
  rows.push(row);
3060
2878
  newFilteredFlatRows.push(row);
3061
2879
  newFilteredRowsById[row.id] = row;
3062
2880
  }
3063
2881
  }
3064
-
3065
2882
  return rows;
3066
2883
  };
3067
-
3068
2884
  return {
3069
2885
  rows: recurseFilterRows(rowsToFilter),
3070
2886
  flatRows: newFilteredFlatRows,
@@ -3079,31 +2895,24 @@
3079
2895
  rowModel.flatRows[i].columnFilters = {};
3080
2896
  rowModel.flatRows[i].columnFiltersMeta = {};
3081
2897
  }
3082
-
3083
2898
  return rowModel;
3084
2899
  }
3085
-
3086
2900
  const resolvedColumnFilters = [];
3087
2901
  const resolvedGlobalFilters = [];
3088
2902
  (columnFilters ?? []).forEach(d => {
3089
2903
  const column = table.getColumn(d.id);
3090
-
3091
2904
  if (!column) {
3092
2905
  {
3093
2906
  console.warn(`Table: Could not find a column to filter with columnId: ${d.id}`);
3094
2907
  }
3095
2908
  }
3096
-
3097
2909
  const filterFn = column.getFilterFn();
3098
-
3099
2910
  if (!filterFn) {
3100
2911
  {
3101
2912
  console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${column.id}.`);
3102
2913
  }
3103
-
3104
2914
  return;
3105
2915
  }
3106
-
3107
2916
  resolvedColumnFilters.push({
3108
2917
  id: d.id,
3109
2918
  filterFn,
@@ -3113,7 +2922,6 @@
3113
2922
  const filterableIds = columnFilters.map(d => d.id);
3114
2923
  const globalFilterFn = table.getGlobalFilterFn();
3115
2924
  const globallyFilterableColumns = table.getAllLeafColumns().filter(column => column.getCanGlobalFilter());
3116
-
3117
2925
  if (globalFilter && globalFilterFn && globallyFilterableColumns.length) {
3118
2926
  filterableIds.push('__global__');
3119
2927
  globallyFilterableColumns.forEach(column => {
@@ -3124,30 +2932,29 @@
3124
2932
  });
3125
2933
  });
3126
2934
  }
3127
-
3128
2935
  let currentColumnFilter;
3129
- let currentGlobalFilter; // Flag the prefiltered row model with each filter state
2936
+ let currentGlobalFilter;
3130
2937
 
2938
+ // Flag the prefiltered row model with each filter state
3131
2939
  for (let j = 0; j < rowModel.flatRows.length; j++) {
3132
2940
  const row = rowModel.flatRows[j];
3133
2941
  row.columnFilters = {};
3134
-
3135
2942
  if (resolvedColumnFilters.length) {
3136
2943
  for (let i = 0; i < resolvedColumnFilters.length; i++) {
3137
2944
  currentColumnFilter = resolvedColumnFilters[i];
3138
- const id = currentColumnFilter.id; // Tag the row with the column filter state
2945
+ const id = currentColumnFilter.id;
3139
2946
 
2947
+ // Tag the row with the column filter state
3140
2948
  row.columnFilters[id] = currentColumnFilter.filterFn(row, id, currentColumnFilter.resolvedValue, filterMeta => {
3141
2949
  row.columnFiltersMeta[id] = filterMeta;
3142
2950
  });
3143
2951
  }
3144
2952
  }
3145
-
3146
2953
  if (resolvedGlobalFilters.length) {
3147
2954
  for (let i = 0; i < resolvedGlobalFilters.length; i++) {
3148
2955
  currentGlobalFilter = resolvedGlobalFilters[i];
3149
- const id = currentGlobalFilter.id; // Tag the row with the first truthy global filter state
3150
-
2956
+ const id = currentGlobalFilter.id;
2957
+ // Tag the row with the first truthy global filter state
3151
2958
  if (currentGlobalFilter.filterFn(row, id, currentGlobalFilter.resolvedValue, filterMeta => {
3152
2959
  row.columnFiltersMeta[id] = filterMeta;
3153
2960
  })) {
@@ -3155,13 +2962,11 @@
3155
2962
  break;
3156
2963
  }
3157
2964
  }
3158
-
3159
2965
  if (row.columnFilters.__global__ !== true) {
3160
2966
  row.columnFilters.__global__ = false;
3161
2967
  }
3162
2968
  }
3163
2969
  }
3164
-
3165
2970
  const filterRowsImpl = row => {
3166
2971
  // Horizontally filter rows through each column
3167
2972
  for (let i = 0; i < filterableIds.length; i++) {
@@ -3169,11 +2974,10 @@
3169
2974
  return false;
3170
2975
  }
3171
2976
  }
3172
-
3173
2977
  return true;
3174
- }; // Filter final rows using all of the active filters
3175
-
2978
+ };
3176
2979
 
2980
+ // Filter final rows using all of the active filters
3177
2981
  return filterRows(rowModel.rows, filterRowsImpl, table);
3178
2982
  }, {
3179
2983
  key: 'getFilteredRowModel',
@@ -3189,9 +2993,7 @@
3189
2993
  if (!preRowModel.rows.length || !(columnFilters != null && columnFilters.length) && !globalFilter) {
3190
2994
  return preRowModel;
3191
2995
  }
3192
-
3193
2996
  const filterableIds = [...columnFilters.map(d => d.id).filter(d => d !== columnId), globalFilter ? '__global__' : undefined].filter(Boolean);
3194
-
3195
2997
  const filterRowsImpl = row => {
3196
2998
  // Horizontally filter rows through each column
3197
2999
  for (let i = 0; i < filterableIds.length; i++) {
@@ -3199,10 +3001,8 @@
3199
3001
  return false;
3200
3002
  }
3201
3003
  }
3202
-
3203
3004
  return true;
3204
3005
  };
3205
-
3206
3006
  return filterRows(preRowModel.rows, filterRowsImpl, table);
3207
3007
  }, {
3208
3008
  key: 'getFacetedRowModel_' + columnId,
@@ -3214,19 +3014,15 @@
3214
3014
  function getFacetedUniqueValues() {
3215
3015
  return (table, columnId) => memo(() => [table.getColumn(columnId).getFacetedRowModel()], facetedRowModel => {
3216
3016
  let facetedUniqueValues = new Map();
3217
-
3218
3017
  for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
3219
3018
  var _facetedRowModel$flat;
3220
-
3221
3019
  const value = (_facetedRowModel$flat = facetedRowModel.flatRows[i]) == null ? void 0 : _facetedRowModel$flat.getValue(columnId);
3222
-
3223
3020
  if (facetedUniqueValues.has(value)) {
3224
3021
  facetedUniqueValues.set(value, (facetedUniqueValues.get(value) ?? 0) + 1);
3225
3022
  } else {
3226
3023
  facetedUniqueValues.set(value, 1);
3227
3024
  }
3228
3025
  }
3229
-
3230
3026
  return facetedUniqueValues;
3231
3027
  }, {
3232
3028
  key: 'getFacetedUniqueValues_' + columnId,
@@ -3238,25 +3034,19 @@
3238
3034
  function getFacetedMinMaxValues() {
3239
3035
  return (table, columnId) => memo(() => [table.getColumn(columnId).getFacetedRowModel()], facetedRowModel => {
3240
3036
  var _facetedRowModel$flat;
3241
-
3242
3037
  const firstValue = (_facetedRowModel$flat = facetedRowModel.flatRows[0]) == null ? void 0 : _facetedRowModel$flat.getValue(columnId);
3243
-
3244
3038
  if (typeof firstValue === 'undefined') {
3245
3039
  return undefined;
3246
3040
  }
3247
-
3248
3041
  let facetedMinMaxValues = [firstValue, firstValue];
3249
-
3250
3042
  for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
3251
3043
  const value = facetedRowModel.flatRows[i].getValue(columnId);
3252
-
3253
3044
  if (value < facetedMinMaxValues[0]) {
3254
3045
  facetedMinMaxValues[0] = value;
3255
3046
  } else if (value > facetedMinMaxValues[1]) {
3256
3047
  facetedMinMaxValues[1] = value;
3257
3048
  }
3258
3049
  }
3259
-
3260
3050
  return facetedMinMaxValues;
3261
3051
  }, {
3262
3052
  key: 'getFacetedMinMaxValues_' + columnId,
@@ -3270,10 +3060,10 @@
3270
3060
  if (!rowModel.rows.length || !(sorting != null && sorting.length)) {
3271
3061
  return rowModel;
3272
3062
  }
3273
-
3274
3063
  const sortingState = table.getState().sorting;
3275
- const sortedFlatRows = []; // Filter out sortings that correspond to non existing columns
3064
+ const sortedFlatRows = [];
3276
3065
 
3066
+ // Filter out sortings that correspond to non existing columns
3277
3067
  const availableSorting = sortingState.filter(sort => table.getColumn(sort.id).getCanSort());
3278
3068
  const columnInfoById = {};
3279
3069
  availableSorting.forEach(sortEntry => {
@@ -3284,7 +3074,6 @@
3284
3074
  sortingFn: column.getSortingFn()
3285
3075
  };
3286
3076
  });
3287
-
3288
3077
  const sortData = rows => {
3289
3078
  // This will also perform a stable sorting using the row index
3290
3079
  // if needed.
@@ -3294,49 +3083,41 @@
3294
3083
  const sortEntry = availableSorting[i];
3295
3084
  const columnInfo = columnInfoById[sortEntry.id];
3296
3085
  const isDesc = (sortEntry == null ? void 0 : sortEntry.desc) ?? false;
3297
-
3298
3086
  if (columnInfo.sortUndefined) {
3299
3087
  const aValue = rowA.getValue(sortEntry.id);
3300
3088
  const bValue = rowB.getValue(sortEntry.id);
3301
3089
  const aUndefined = typeof aValue === 'undefined';
3302
3090
  const bUndefined = typeof bValue === 'undefined';
3303
-
3304
3091
  if (aUndefined || bUndefined) {
3305
3092
  return aUndefined && bUndefined ? 0 : aUndefined ? columnInfo.sortUndefined : -columnInfo.sortUndefined;
3306
3093
  }
3307
- } // This function should always return in ascending order
3308
-
3094
+ }
3309
3095
 
3096
+ // This function should always return in ascending order
3310
3097
  let sortInt = columnInfo.sortingFn(rowA, rowB, sortEntry.id);
3311
-
3312
3098
  if (sortInt !== 0) {
3313
3099
  if (isDesc) {
3314
3100
  sortInt *= -1;
3315
3101
  }
3316
-
3317
3102
  if (columnInfo.invertSorting) {
3318
3103
  sortInt *= -1;
3319
3104
  }
3320
-
3321
3105
  return sortInt;
3322
3106
  }
3323
3107
  }
3324
-
3325
3108
  return rowA.index - rowB.index;
3326
- }); // If there are sub-rows, sort them
3109
+ });
3327
3110
 
3111
+ // If there are sub-rows, sort them
3328
3112
  sortedData.forEach(row => {
3329
3113
  sortedFlatRows.push(row);
3330
-
3331
3114
  if (!row.subRows || row.subRows.length <= 1) {
3332
3115
  return;
3333
3116
  }
3334
-
3335
3117
  row.subRows = sortData(row.subRows);
3336
3118
  });
3337
3119
  return sortedData;
3338
3120
  };
3339
-
3340
3121
  return {
3341
3122
  rows: sortData(rowModel.rows),
3342
3123
  flatRows: sortedFlatRows,
@@ -3355,22 +3136,22 @@
3355
3136
  return table => memo(() => [table.getState().grouping, table.getPreGroupedRowModel()], (grouping, rowModel) => {
3356
3137
  if (!rowModel.rows.length || !grouping.length) {
3357
3138
  return rowModel;
3358
- } // Filter the grouping list down to columns that exist
3359
-
3139
+ }
3360
3140
 
3141
+ // Filter the grouping list down to columns that exist
3361
3142
  const existingGrouping = grouping.filter(columnId => table.getColumn(columnId));
3362
3143
  const groupedFlatRows = [];
3363
- const groupedRowsById = {}; // const onlyGroupedFlatRows: Row[] = [];
3144
+ const groupedRowsById = {};
3145
+ // const onlyGroupedFlatRows: Row[] = [];
3364
3146
  // const onlyGroupedRowsById: Record<RowId, Row> = {};
3365
3147
  // const nonGroupedFlatRows: Row[] = [];
3366
3148
  // const nonGroupedRowsById: Record<RowId, Row> = {};
3367
- // Recursively group the data
3368
3149
 
3150
+ // Recursively group the data
3369
3151
  const groupUpRecursively = function (rows, depth, parentId) {
3370
3152
  if (depth === void 0) {
3371
3153
  depth = 0;
3372
3154
  }
3373
-
3374
3155
  // Grouping depth has been been met
3375
3156
  // Stop grouping and simply rewrite thd depth and row relationships
3376
3157
  if (depth >= existingGrouping.length) {
@@ -3378,26 +3159,27 @@
3378
3159
  row.depth = depth;
3379
3160
  groupedFlatRows.push(row);
3380
3161
  groupedRowsById[row.id] = row;
3381
-
3382
3162
  if (row.subRows) {
3383
3163
  row.subRows = groupUpRecursively(row.subRows, depth + 1);
3384
3164
  }
3385
-
3386
3165
  return row;
3387
3166
  });
3388
3167
  }
3168
+ const columnId = existingGrouping[depth];
3389
3169
 
3390
- const columnId = existingGrouping[depth]; // Group the rows together for this level
3391
-
3392
- const rowGroupsMap = groupBy(rows, columnId); // Peform aggregations for each group
3170
+ // Group the rows together for this level
3171
+ const rowGroupsMap = groupBy(rows, columnId);
3393
3172
 
3173
+ // Peform aggregations for each group
3394
3174
  const aggregatedGroupedRows = Array.from(rowGroupsMap.entries()).map((_ref, index) => {
3395
3175
  let [groupingValue, groupedRows] = _ref;
3396
3176
  let id = `${columnId}:${groupingValue}`;
3397
- id = parentId ? `${parentId}>${id}` : id; // First, Recurse to group sub rows before aggregation
3177
+ id = parentId ? `${parentId}>${id}` : id;
3398
3178
 
3399
- const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
3179
+ // First, Recurse to group sub rows before aggregation
3180
+ const subRows = groupUpRecursively(groupedRows, depth + 1, id);
3400
3181
 
3182
+ // Flatten the leaf rows of the rows in this group
3401
3183
  const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
3402
3184
  const row = createRow(table, id, leafRows[0].original, index, depth);
3403
3185
  Object.assign(row, {
@@ -3411,22 +3193,18 @@
3411
3193
  if (row._valuesCache.hasOwnProperty(columnId)) {
3412
3194
  return row._valuesCache[columnId];
3413
3195
  }
3414
-
3415
3196
  if (groupedRows[0]) {
3416
3197
  row._valuesCache[columnId] = groupedRows[0].getValue(columnId) ?? undefined;
3417
3198
  }
3418
-
3419
3199
  return row._valuesCache[columnId];
3420
3200
  }
3421
-
3422
3201
  if (row._groupingValuesCache.hasOwnProperty(columnId)) {
3423
3202
  return row._groupingValuesCache[columnId];
3424
- } // Aggregate the values
3425
-
3203
+ }
3426
3204
 
3205
+ // Aggregate the values
3427
3206
  const column = table.getColumn(columnId);
3428
3207
  const aggregateFn = column.getAggregationFn();
3429
-
3430
3208
  if (aggregateFn) {
3431
3209
  row._groupingValuesCache[columnId] = aggregateFn(columnId, leafRows, groupedRows);
3432
3210
  return row._groupingValuesCache[columnId];
@@ -3435,7 +3213,8 @@
3435
3213
  });
3436
3214
  subRows.forEach(subRow => {
3437
3215
  groupedFlatRows.push(subRow);
3438
- groupedRowsById[subRow.id] = subRow; // if (subRow.getIsGrouped?.()) {
3216
+ groupedRowsById[subRow.id] = subRow;
3217
+ // if (subRow.getIsGrouped?.()) {
3439
3218
  // onlyGroupedFlatRows.push(subRow);
3440
3219
  // onlyGroupedRowsById[subRow.id] = subRow;
3441
3220
  // } else {
@@ -3443,15 +3222,16 @@
3443
3222
  // nonGroupedRowsById[subRow.id] = subRow;
3444
3223
  // }
3445
3224
  });
3225
+
3446
3226
  return row;
3447
3227
  });
3448
3228
  return aggregatedGroupedRows;
3449
3229
  };
3450
-
3451
3230
  const groupedRows = groupUpRecursively(rowModel.rows, 0, '');
3452
3231
  groupedRows.forEach(subRow => {
3453
3232
  groupedFlatRows.push(subRow);
3454
- groupedRowsById[subRow.id] = subRow; // if (subRow.getIsGrouped?.()) {
3233
+ groupedRowsById[subRow.id] = subRow;
3234
+ // if (subRow.getIsGrouped?.()) {
3455
3235
  // onlyGroupedFlatRows.push(subRow);
3456
3236
  // onlyGroupedRowsById[subRow.id] = subRow;
3457
3237
  // } else {
@@ -3459,6 +3239,7 @@
3459
3239
  // nonGroupedRowsById[subRow.id] = subRow;
3460
3240
  // }
3461
3241
  });
3242
+
3462
3243
  return {
3463
3244
  rows: groupedRows,
3464
3245
  flatRows: groupedFlatRows,
@@ -3470,25 +3251,21 @@
3470
3251
  onChange: () => {
3471
3252
  table._queue(() => {
3472
3253
  table._autoResetExpanded();
3473
-
3474
3254
  table._autoResetPageIndex();
3475
3255
  });
3476
3256
  }
3477
3257
  });
3478
3258
  }
3479
-
3480
3259
  function groupBy(rows, columnId) {
3481
3260
  const groupMap = new Map();
3482
3261
  return rows.reduce((map, row) => {
3483
3262
  const resKey = `${row.getValue(columnId)}`;
3484
3263
  const previous = map.get(resKey);
3485
-
3486
3264
  if (!previous) {
3487
3265
  map.set(resKey, [row]);
3488
3266
  } else {
3489
3267
  map.set(resKey, [...previous, row]);
3490
3268
  }
3491
-
3492
3269
  return map;
3493
3270
  }, groupMap);
3494
3271
  }
@@ -3498,12 +3275,10 @@
3498
3275
  if (!rowModel.rows.length || expanded !== true && !Object.keys(expanded ?? {}).length) {
3499
3276
  return rowModel;
3500
3277
  }
3501
-
3502
3278
  if (!paginateExpandedRows) {
3503
3279
  // Only expand rows at this point if they are being paginated
3504
3280
  return rowModel;
3505
3281
  }
3506
-
3507
3282
  return expandRows(rowModel);
3508
3283
  }, {
3509
3284
  key: 'getExpandedRowModel',
@@ -3512,17 +3287,13 @@
3512
3287
  }
3513
3288
  function expandRows(rowModel) {
3514
3289
  const expandedRows = [];
3515
-
3516
3290
  const handleRow = row => {
3517
3291
  var _row$subRows;
3518
-
3519
3292
  expandedRows.push(row);
3520
-
3521
3293
  if ((_row$subRows = row.subRows) != null && _row$subRows.length && row.getIsExpanded()) {
3522
3294
  row.subRows.forEach(handleRow);
3523
3295
  }
3524
3296
  };
3525
-
3526
3297
  rowModel.rows.forEach(handleRow);
3527
3298
  return {
3528
3299
  rows: expandedRows,
@@ -3536,7 +3307,6 @@
3536
3307
  if (!rowModel.rows.length) {
3537
3308
  return rowModel;
3538
3309
  }
3539
-
3540
3310
  const {
3541
3311
  pageSize,
3542
3312
  pageIndex
@@ -3550,7 +3320,6 @@
3550
3320
  const pageEnd = pageStart + pageSize;
3551
3321
  rows = rows.slice(pageStart, pageEnd);
3552
3322
  let paginatedRowModel;
3553
-
3554
3323
  if (!table.options.paginateExpandedRows) {
3555
3324
  paginatedRowModel = expandRows({
3556
3325
  rows,
@@ -3564,17 +3333,13 @@
3564
3333
  rowsById
3565
3334
  };
3566
3335
  }
3567
-
3568
3336
  paginatedRowModel.flatRows = [];
3569
-
3570
3337
  const handleRow = row => {
3571
3338
  paginatedRowModel.flatRows.push(row);
3572
-
3573
3339
  if (row.subRows.length) {
3574
3340
  row.subRows.forEach(handleRow);
3575
3341
  }
3576
3342
  };
3577
-
3578
3343
  paginatedRowModel.rows.forEach(handleRow);
3579
3344
  return paginatedRowModel;
3580
3345
  }, {