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