@tanstack/react-table 8.5.15 → 8.5.16

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