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