@tanstack/react-table 8.5.15 → 8.5.17

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