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