@tanstack/react-table 8.5.15 → 8.5.16

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