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