@tanstack/react-table 8.0.0-alpha.65 → 8.0.0-alpha.69

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.
@@ -9,91 +9,4044 @@
9
9
  * @license MIT
10
10
  */
11
11
  import * as React from 'react';
12
- import { createTableFactory, createTableInstance } from '@tanstack/table-core';
13
- export * from '@tanstack/table-core';
14
12
 
15
- function _extends() {
16
- _extends = Object.assign || function (target) {
17
- for (var i = 1; i < arguments.length; i++) {
18
- var source = arguments[i];
13
+ /**
14
+ * table-core
15
+ *
16
+ * Copyright (c) TanStack
17
+ *
18
+ * This source code is licensed under the MIT license found in the
19
+ * LICENSE.md file in the root directory of this source tree.
20
+ *
21
+ * @license MIT
22
+ */
23
+ function functionalUpdate(updater, input) {
24
+ return typeof updater === 'function' ? updater(input) : updater;
25
+ }
26
+ function noop() {//
27
+ }
28
+ function makeStateUpdater(key, instance) {
29
+ return updater => {
30
+ instance.setState(old => {
31
+ return { ...old,
32
+ [key]: functionalUpdate(updater, old[key])
33
+ };
34
+ });
35
+ };
36
+ }
37
+ function isFunction(d) {
38
+ return d instanceof Function;
39
+ }
40
+ function flattenBy(arr, getChildren) {
41
+ const flat = [];
42
+
43
+ const recurse = subArr => {
44
+ subArr.forEach(item => {
45
+ flat.push(item);
46
+ const children = getChildren(item);
47
+
48
+ if (children != null && children.length) {
49
+ recurse(children);
50
+ }
51
+ });
52
+ };
53
+
54
+ recurse(arr);
55
+ return flat;
56
+ }
57
+ function memo(getDeps, fn, opts) {
58
+ let deps = [];
59
+ let result;
60
+ return () => {
61
+ let depTime;
62
+ if (opts.key && opts.debug) depTime = Date.now();
63
+ const newDeps = getDeps();
64
+ const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
65
+
66
+ if (!depsChanged) {
67
+ return result;
68
+ }
69
+
70
+ deps = newDeps;
71
+ let resultTime;
72
+ if (opts.key && opts.debug) resultTime = Date.now();
73
+ result = fn(...newDeps);
74
+ opts == null ? void 0 : opts.onChange == null ? void 0 : opts.onChange(result);
75
+
76
+ if (opts.key && opts.debug) {
77
+ if (opts != null && opts.debug()) {
78
+ const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
79
+ const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
80
+ const resultFpsPercentage = resultEndTime / 16;
81
+
82
+ const pad = (str, num) => {
83
+ str = String(str);
84
+
85
+ while (str.length < num) {
86
+ str = ' ' + str;
87
+ }
88
+
89
+ return str;
90
+ };
91
+
92
+ console.info("%c\u23F1 " + pad(resultEndTime, 5) + " /" + pad(depEndTime, 5) + " ms", "\n font-size: .6rem;\n font-weight: bold;\n color: hsl(" + Math.max(0, Math.min(120 - 120 * resultFpsPercentage, 120)) + "deg 100% 31%);", opts == null ? void 0 : opts.key);
93
+ }
94
+ }
95
+
96
+ return result;
97
+ };
98
+ }
99
+
100
+ //
101
+ const Columns = {
102
+ createInstance: instance => {
103
+ return {
104
+ getDefaultColumn: memo(() => [instance.options.defaultColumn], defaultColumn => {
105
+ var _defaultColumn;
106
+
107
+ defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
108
+ return {
109
+ header: props => props.header.column.id,
110
+ footer: props => props.header.column.id,
111
+ cell: props => {
112
+ var _props$getValue$toStr, _props$getValue$toStr2, _props$getValue;
113
+
114
+ return (_props$getValue$toStr = (_props$getValue$toStr2 = (_props$getValue = props.getValue()).toString) == null ? void 0 : _props$getValue$toStr2.call(_props$getValue)) != null ? _props$getValue$toStr : null;
115
+ },
116
+ ...instance._features.reduce((obj, feature) => {
117
+ return Object.assign(obj, feature.getDefaultColumn == null ? void 0 : feature.getDefaultColumn());
118
+ }, {}),
119
+ ...defaultColumn
120
+ };
121
+ }, {
122
+ debug: () => {
123
+ var _instance$options$deb;
124
+
125
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
126
+ },
127
+ key: process.env.NODE_ENV === 'development' && 'getDefaultColumn'
128
+ }),
129
+ getColumnDefs: () => instance.options.columns,
130
+ createColumn: (columnDef, depth, parent) => {
131
+ var _ref, _columnDef$id;
132
+
133
+ const defaultColumn = instance.getDefaultColumn();
134
+ let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
135
+ let accessorFn;
136
+
137
+ if (columnDef.accessorFn) {
138
+ accessorFn = columnDef.accessorFn;
139
+ } else if (columnDef.accessorKey) {
140
+ accessorFn = originalRow => originalRow[columnDef.accessorKey];
141
+ }
142
+
143
+ if (!id) {
144
+ if (process.env.NODE_ENV !== 'production') {
145
+ throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
146
+ }
147
+
148
+ throw new Error();
149
+ }
150
+
151
+ let column = { ...defaultColumn,
152
+ ...columnDef,
153
+ id: "" + id,
154
+ accessorFn,
155
+ parent: parent,
156
+ depth,
157
+ columnDef,
158
+ columnDefType: columnDef.columnDefType,
159
+ columns: [],
160
+ getFlatColumns: memo(() => [true], () => {
161
+ var _column$columns;
162
+
163
+ return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
164
+ }, {
165
+ key: process.env.NODE_ENV === 'production' && 'column.getFlatColumns',
166
+ debug: () => {
167
+ var _instance$options$deb2;
168
+
169
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
170
+ }
171
+ }),
172
+ getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
173
+ var _column$columns2;
174
+
175
+ if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
176
+ let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
177
+ return orderColumns(leafColumns);
178
+ }
179
+
180
+ return [column];
181
+ }, {
182
+ key: process.env.NODE_ENV === 'production' && 'column.getLeafColumns',
183
+ debug: () => {
184
+ var _instance$options$deb3;
185
+
186
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
187
+ }
188
+ })
189
+ };
190
+ column = instance._features.reduce((obj, feature) => {
191
+ return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
192
+ }, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
193
+
194
+ return column;
195
+ },
196
+ getAllColumns: memo(() => [instance.getColumnDefs()], columnDefs => {
197
+ const recurseColumns = function (columnDefs, parent, depth) {
198
+ if (depth === void 0) {
199
+ depth = 0;
200
+ }
201
+
202
+ return columnDefs.map(columnDef => {
203
+ const column = instance.createColumn(columnDef, depth, parent);
204
+ column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
205
+ return column;
206
+ });
207
+ };
208
+
209
+ return recurseColumns(columnDefs);
210
+ }, {
211
+ key: process.env.NODE_ENV === 'development' && 'getAllColumns',
212
+ debug: () => {
213
+ var _instance$options$deb4;
214
+
215
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
216
+ }
217
+ }),
218
+ getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
219
+ return allColumns.flatMap(column => {
220
+ return column.getFlatColumns();
221
+ });
222
+ }, {
223
+ key: process.env.NODE_ENV === 'development' && 'getAllFlatColumns',
224
+ debug: () => {
225
+ var _instance$options$deb5;
226
+
227
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
228
+ }
229
+ }),
230
+ getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
231
+ return flatColumns.reduce((acc, column) => {
232
+ acc[column.id] = column;
233
+ return acc;
234
+ }, {});
235
+ }, {
236
+ key: process.env.NODE_ENV === 'development' && 'getAllFlatColumnsById',
237
+ debug: () => {
238
+ var _instance$options$deb6;
239
+
240
+ return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugColumns;
241
+ }
242
+ }),
243
+ getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
244
+ let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
245
+ return orderColumns(leafColumns);
246
+ }, {
247
+ key: process.env.NODE_ENV === 'development' && 'getAllLeafColumns',
248
+ debug: () => {
249
+ var _instance$options$deb7;
250
+
251
+ return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugColumns;
252
+ }
253
+ }),
254
+ getColumn: columnId => {
255
+ const column = instance.getAllFlatColumnsById()[columnId];
256
+
257
+ if (!column) {
258
+ if (process.env.NODE_ENV !== 'production') {
259
+ console.warn("[Table] Column with id " + columnId + " does not exist.");
260
+ }
261
+
262
+ throw new Error();
263
+ }
264
+
265
+ return column;
266
+ }
267
+ };
268
+ }
269
+ };
270
+
271
+ //
272
+ const Rows = {
273
+ // createRow: <TGenerics extends TableGenerics>(
274
+ // row: Row<TGenerics>,
275
+ // instance: TableInstance<TGenerics>
276
+ // ): CellsRow<TGenerics> => {
277
+ // return {}
278
+ // },
279
+ createInstance: instance => {
280
+ return {
281
+ getRowId: (row, index, parent) => {
282
+ var _instance$options$get;
283
+
284
+ return (_instance$options$get = instance.options.getRowId == null ? void 0 : instance.options.getRowId(row, index, parent)) != null ? _instance$options$get : "" + (parent ? [parent.id, index].join('.') : index);
285
+ },
286
+ createRow: (id, original, rowIndex, depth, subRows) => {
287
+ let row = {
288
+ id,
289
+ index: rowIndex,
290
+ original,
291
+ depth,
292
+ valuesCache: {},
293
+ getValue: columnId => {
294
+ if (row.valuesCache.hasOwnProperty(columnId)) {
295
+ return row.valuesCache[columnId];
296
+ }
297
+
298
+ const column = instance.getColumn(columnId);
299
+
300
+ if (!column.accessorFn) {
301
+ throw new Error();
302
+ }
303
+
304
+ row.valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
305
+ return row.valuesCache[columnId];
306
+ },
307
+ subRows: subRows != null ? subRows : [],
308
+ getLeafRows: () => flattenBy(row.subRows, d => d.subRows)
309
+ };
310
+
311
+ for (let i = 0; i < instance._features.length; i++) {
312
+ const feature = instance._features[i];
313
+ Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
314
+ }
315
+
316
+ return row;
317
+ },
318
+ getCoreRowModel: () => {
319
+ if (!instance._getCoreRowModel) {
320
+ instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
321
+ }
322
+
323
+ return instance._getCoreRowModel();
324
+ },
325
+ // The final calls start at the bottom of the model,
326
+ // expanded rows, which then work their way up
327
+ getRowModel: () => {
328
+ return instance.getPaginationRowModel();
329
+ },
330
+ getRow: id => {
331
+ const row = instance.getRowModel().rowsById[id];
332
+
333
+ if (!row) {
334
+ if (process.env.NODE_ENV !== 'production') {
335
+ throw new Error("getRow expected an ID, but got " + id);
336
+ }
337
+
338
+ throw new Error();
339
+ }
340
+
341
+ return row;
342
+ }
343
+ };
344
+ }
345
+ };
346
+
347
+ //
348
+ const Cells = {
349
+ createRow: (row, instance) => {
350
+ return {
351
+ getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
352
+ return leafColumns.map(column => {
353
+ return instance.createCell(row, column, column.id);
354
+ });
355
+ }, {
356
+ key: process.env.NODE_ENV === 'development' && 'row.getAllCells',
357
+ debug: () => {
358
+ var _instance$options$deb;
359
+
360
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
361
+ }
362
+ }),
363
+ getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
364
+ return allCells.reduce((acc, cell) => {
365
+ acc[cell.columnId] = cell;
366
+ return acc;
367
+ }, {});
368
+ }, {
369
+ key: process.env.NODE_ENV === 'production' && 'row.getAllCellsByColumnId',
370
+ debug: () => {
371
+ var _instance$options$deb2;
372
+
373
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
374
+ }
375
+ })
376
+ };
377
+ },
378
+ createInstance: instance => {
379
+ return {
380
+ createCell: (row, column, columnId) => {
381
+ const cell = {
382
+ id: row.id + "_" + column.id,
383
+ rowId: row.id,
384
+ columnId,
385
+ row,
386
+ column,
387
+ getValue: () => row.getValue(columnId),
388
+ renderCell: () => column.cell ? instance.render(column.cell, {
389
+ instance,
390
+ column,
391
+ row,
392
+ cell: cell,
393
+ getValue: cell.getValue
394
+ }) : null
395
+ };
396
+
397
+ instance._features.forEach(feature => {
398
+ Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
399
+ }, {});
400
+
401
+ return cell;
402
+ },
403
+ getCell: (rowId, columnId) => {
404
+ const row = instance.getRow(rowId);
405
+
406
+ if (!row) {
407
+ if (process.env.NODE_ENV !== 'production') {
408
+ throw new Error("[Table] could not find row with id " + rowId);
409
+ }
410
+
411
+ throw new Error();
412
+ }
413
+
414
+ const cell = row.getAllCellsByColumnId()[columnId];
415
+
416
+ if (!cell) {
417
+ if (process.env.NODE_ENV !== 'production') {
418
+ throw new Error("[Table] could not find cell " + columnId + " in row " + rowId);
419
+ }
420
+
421
+ throw new Error();
422
+ }
423
+
424
+ return cell;
425
+ }
426
+ };
427
+ }
428
+ };
429
+
430
+ //
431
+ const defaultColumnSizing = {
432
+ size: 150,
433
+ minSize: 20,
434
+ maxSize: Number.MAX_SAFE_INTEGER
435
+ };
436
+
437
+ const getDefaultColumnSizingInfoState = () => ({
438
+ startOffset: null,
439
+ startSize: null,
440
+ deltaOffset: null,
441
+ deltaPercentage: null,
442
+ isResizingColumn: false,
443
+ columnSizingStart: []
444
+ });
445
+
446
+ const ColumnSizing = {
447
+ getDefaultColumn: () => {
448
+ return defaultColumnSizing;
449
+ },
450
+ getInitialState: state => {
451
+ return {
452
+ columnSizing: {},
453
+ columnSizingInfo: getDefaultColumnSizingInfoState(),
454
+ ...state
455
+ };
456
+ },
457
+ getDefaultOptions: instance => {
458
+ return {
459
+ columnResizeMode: 'onEnd',
460
+ onColumnSizingChange: makeStateUpdater('columnSizing', instance),
461
+ onColumnSizingInfoChange: makeStateUpdater('columnSizingInfo', instance)
462
+ };
463
+ },
464
+ createColumn: (column, instance) => {
465
+ return {
466
+ getSize: () => {
467
+ var _column$minSize, _ref, _column$maxSize;
468
+
469
+ const columnSize = instance.getState().columnSizing[column.id];
470
+ return Math.min(Math.max((_column$minSize = column.minSize) != null ? _column$minSize : defaultColumnSizing.minSize, (_ref = columnSize != null ? columnSize : column.size) != null ? _ref : defaultColumnSizing.size), (_column$maxSize = column.maxSize) != null ? _column$maxSize : defaultColumnSizing.maxSize);
471
+ },
472
+ getStart: position => {
473
+ const columns = !position ? instance.getVisibleLeafColumns() : position === 'left' ? instance.getLeftVisibleLeafColumns() : instance.getRightVisibleLeafColumns();
474
+ const index = columns.findIndex(d => d.id === column.id);
475
+
476
+ if (index > 0) {
477
+ const prevSiblingColumn = columns[index - 1];
478
+ return prevSiblingColumn.getStart(position) + prevSiblingColumn.getSize();
479
+ }
480
+
481
+ return 0;
482
+ },
483
+ resetSize: () => {
484
+ instance.setColumnSizing(_ref2 => {
485
+ let {
486
+ [column.id]: _,
487
+ ...rest
488
+ } = _ref2;
489
+ return rest;
490
+ });
491
+ },
492
+ getCanResize: () => {
493
+ var _column$enableResizin, _instance$options$ena;
494
+
495
+ return ((_column$enableResizin = column.enableResizing) != null ? _column$enableResizin : true) && ((_instance$options$ena = instance.options.enableColumnResizing) != null ? _instance$options$ena : true);
496
+ },
497
+ getIsResizing: () => {
498
+ return instance.getState().columnSizingInfo.isResizingColumn === column.id;
499
+ }
500
+ };
501
+ },
502
+ createHeader: (header, instance) => {
503
+ return {
504
+ getSize: () => {
505
+ let sum = 0;
506
+
507
+ const recurse = header => {
508
+ if (header.subHeaders.length) {
509
+ header.subHeaders.forEach(recurse);
510
+ } else {
511
+ var _header$column$getSiz;
512
+
513
+ sum += (_header$column$getSiz = header.column.getSize()) != null ? _header$column$getSiz : 0;
514
+ }
515
+ };
516
+
517
+ recurse(header);
518
+ return sum;
519
+ },
520
+ getStart: () => {
521
+ if (header.index > 0) {
522
+ const prevSiblingHeader = header.headerGroup.headers[header.index - 1];
523
+ return prevSiblingHeader.getStart() + prevSiblingHeader.getSize();
524
+ }
525
+
526
+ return 0;
527
+ },
528
+ getResizeHandler: () => {
529
+ const column = instance.getColumn(header.column.id);
530
+ const canResize = column.getCanResize();
531
+ return e => {
532
+ if (!canResize) {
533
+ return;
534
+ }
535
+ e.persist == null ? void 0 : e.persist();
536
+
537
+ if (isTouchStartEvent(e)) {
538
+ // lets not respond to multiple touches (e.g. 2 or 3 fingers)
539
+ if (e.touches && e.touches.length > 1) {
540
+ return;
541
+ }
542
+ }
543
+
544
+ const startSize = column.getSize();
545
+ const columnSizingStart = header ? header.getLeafHeaders().map(d => [d.column.id, d.column.getSize()]) : [[column.id, column.getSize()]];
546
+ const clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
547
+
548
+ const updateOffset = (eventType, clientXPos) => {
549
+ if (typeof clientXPos !== 'number') {
550
+ return;
551
+ }
552
+
553
+ let newColumnSizing = {};
554
+ instance.setColumnSizingInfo(old => {
555
+ var _old$startOffset, _old$startSize;
556
+
557
+ const deltaOffset = clientXPos - ((_old$startOffset = old == null ? void 0 : old.startOffset) != null ? _old$startOffset : 0);
558
+ const deltaPercentage = Math.max(deltaOffset / ((_old$startSize = old == null ? void 0 : old.startSize) != null ? _old$startSize : 0), -0.999999);
559
+ old.columnSizingStart.forEach(_ref3 => {
560
+ let [columnId, headerSize] = _ref3;
561
+ newColumnSizing[columnId] = Math.round(Math.max(headerSize + headerSize * deltaPercentage, 0) * 100) / 100;
562
+ });
563
+ return { ...old,
564
+ deltaOffset,
565
+ deltaPercentage
566
+ };
567
+ });
568
+
569
+ if (instance.options.columnResizeMode === 'onChange' || eventType === 'end') {
570
+ instance.setColumnSizing(old => ({ ...old,
571
+ ...newColumnSizing
572
+ }));
573
+ }
574
+ };
575
+
576
+ const onMove = clientXPos => updateOffset('move', clientXPos);
577
+
578
+ const onEnd = clientXPos => {
579
+ updateOffset('end', clientXPos);
580
+ instance.setColumnSizingInfo(old => ({ ...old,
581
+ isResizingColumn: false,
582
+ startOffset: null,
583
+ startSize: null,
584
+ deltaOffset: null,
585
+ deltaPercentage: null,
586
+ columnSizingStart: []
587
+ }));
588
+ };
589
+
590
+ const mouseEvents = {
591
+ moveHandler: e => onMove(e.clientX),
592
+ upHandler: e => {
593
+ document.removeEventListener('mousemove', mouseEvents.moveHandler);
594
+ document.removeEventListener('mouseup', mouseEvents.upHandler);
595
+ onEnd(e.clientX);
596
+ }
597
+ };
598
+ const passiveIfSupported = passiveEventSupported() ? {
599
+ passive: false
600
+ } : false;
601
+
602
+ if (isTouchStartEvent(e)) ; else {
603
+ document.addEventListener('mousemove', mouseEvents.moveHandler, passiveIfSupported);
604
+ document.addEventListener('mouseup', mouseEvents.upHandler, passiveIfSupported);
605
+ }
606
+
607
+ instance.setColumnSizingInfo(old => ({ ...old,
608
+ startOffset: clientX,
609
+ startSize,
610
+ deltaOffset: 0,
611
+ deltaPercentage: 0,
612
+ columnSizingStart,
613
+ isResizingColumn: column.id
614
+ }));
615
+ };
616
+ }
617
+ };
618
+ },
619
+ createInstance: instance => {
620
+ return {
621
+ setColumnSizing: updater => instance.options.onColumnSizingChange == null ? void 0 : instance.options.onColumnSizingChange(updater),
622
+ setColumnSizingInfo: updater => instance.options.onColumnSizingInfoChange == null ? void 0 : instance.options.onColumnSizingInfoChange(updater),
623
+ resetColumnSizing: defaultState => {
624
+ var _instance$initialStat;
625
+
626
+ instance.setColumnSizing(defaultState ? {} : (_instance$initialStat = instance.initialState.columnSizing) != null ? _instance$initialStat : {});
627
+ },
628
+ resetHeaderSizeInfo: defaultState => {
629
+ var _instance$initialStat2;
630
+
631
+ instance.setColumnSizingInfo(defaultState ? getDefaultColumnSizingInfoState() : (_instance$initialStat2 = instance.initialState.columnSizingInfo) != null ? _instance$initialStat2 : getDefaultColumnSizingInfoState());
632
+ },
633
+ getTotalSize: () => {
634
+ var _instance$getHeaderGr, _instance$getHeaderGr2;
635
+
636
+ return (_instance$getHeaderGr = (_instance$getHeaderGr2 = instance.getHeaderGroups()[0]) == null ? void 0 : _instance$getHeaderGr2.headers.reduce((sum, header) => {
637
+ return sum + header.column.getSize();
638
+ }, 0)) != null ? _instance$getHeaderGr : 0;
639
+ },
640
+ getLeftTotalSize: () => {
641
+ var _instance$getLeftHead, _instance$getLeftHead2;
642
+
643
+ return (_instance$getLeftHead = (_instance$getLeftHead2 = instance.getLeftHeaderGroups()[0]) == null ? void 0 : _instance$getLeftHead2.headers.reduce((sum, header) => {
644
+ return sum + header.column.getSize();
645
+ }, 0)) != null ? _instance$getLeftHead : 0;
646
+ },
647
+ getCenterTotalSize: () => {
648
+ var _instance$getCenterHe, _instance$getCenterHe2;
649
+
650
+ return (_instance$getCenterHe = (_instance$getCenterHe2 = instance.getCenterHeaderGroups()[0]) == null ? void 0 : _instance$getCenterHe2.headers.reduce((sum, header) => {
651
+ return sum + header.column.getSize();
652
+ }, 0)) != null ? _instance$getCenterHe : 0;
653
+ },
654
+ getRightTotalSize: () => {
655
+ var _instance$getRightHea, _instance$getRightHea2;
656
+
657
+ return (_instance$getRightHea = (_instance$getRightHea2 = instance.getRightHeaderGroups()[0]) == null ? void 0 : _instance$getRightHea2.headers.reduce((sum, header) => {
658
+ return sum + header.column.getSize();
659
+ }, 0)) != null ? _instance$getRightHea : 0;
660
+ }
661
+ };
662
+ }
663
+ };
664
+ let passiveSupported = null;
665
+ function passiveEventSupported() {
666
+ if (typeof passiveSupported === 'boolean') return passiveSupported;
667
+ let supported = false;
668
+
669
+ try {
670
+ const options = {
671
+ get passive() {
672
+ supported = true;
673
+ return false;
674
+ }
675
+
676
+ };
677
+
678
+ const noop = () => {};
679
+
680
+ window.addEventListener('test', noop, options);
681
+ window.removeEventListener('test', noop);
682
+ } catch (err) {
683
+ supported = false;
684
+ }
685
+
686
+ passiveSupported = supported;
687
+ return passiveSupported;
688
+ }
689
+
690
+ function isTouchStartEvent(e) {
691
+ return e.type === 'touchstart';
692
+ }
693
+
694
+ //
695
+ const Expanding = {
696
+ getInitialState: state => {
697
+ return {
698
+ expanded: {},
699
+ ...state
700
+ };
701
+ },
702
+ getDefaultOptions: instance => {
703
+ return {
704
+ onExpandedChange: makeStateUpdater('expanded', instance),
705
+ autoResetExpanded: true,
706
+ expandSubRows: true,
707
+ paginateExpandedRows: true
708
+ };
709
+ },
710
+ createInstance: instance => {
711
+ let registered = false;
712
+ return {
713
+ _autoResetExpanded: () => {
714
+ if (!registered) {
715
+ registered = true;
716
+ return;
717
+ }
718
+
719
+ if (instance.options.autoResetAll === false) {
720
+ return;
721
+ }
722
+
723
+ if (instance.options.autoResetAll === true || instance.options.autoResetExpanded) {
724
+ instance.resetExpanded();
725
+ }
726
+ },
727
+ setExpanded: updater => instance.options.onExpandedChange == null ? void 0 : instance.options.onExpandedChange(updater),
728
+ toggleAllRowsExpanded: expanded => {
729
+ if (expanded != null ? expanded : !instance.getIsAllRowsExpanded()) {
730
+ instance.setExpanded(true);
731
+ } else {
732
+ instance.setExpanded({});
733
+ }
734
+ },
735
+ resetExpanded: defaultState => {
736
+ var _instance$initialStat, _instance$initialStat2;
737
+
738
+ instance.setExpanded(defaultState ? {} : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.expanded) != null ? _instance$initialStat : {});
739
+ },
740
+ getCanSomeRowsExpand: () => {
741
+ return instance.getRowModel().flatRows.some(row => row.getCanExpand());
742
+ },
743
+ getToggleAllRowsExpandedHandler: () => {
744
+ return e => {
745
+ e.persist == null ? void 0 : e.persist();
746
+ instance.toggleAllRowsExpanded();
747
+ };
748
+ },
749
+ getIsSomeRowsExpanded: () => {
750
+ const expanded = instance.getState().expanded;
751
+ return expanded === true || Object.values(expanded).some(Boolean);
752
+ },
753
+ getIsAllRowsExpanded: () => {
754
+ const expanded = instance.getState().expanded; // If expanded is true, save some cycles and return true
755
+
756
+ if (expanded === true) {
757
+ return true;
758
+ } // If any row is not expanded, return false
759
+
760
+
761
+ if (instance.getRowModel().flatRows.some(row => row.getIsExpanded())) {
762
+ return false;
763
+ } // They must all be expanded :shrug:
764
+
765
+
766
+ return true;
767
+ },
768
+ getExpandedDepth: () => {
769
+ let maxDepth = 0;
770
+ const rowIds = instance.getState().expanded === true ? Object.keys(instance.getRowModel().rowsById) : Object.keys(instance.getState().expanded);
771
+ rowIds.forEach(id => {
772
+ const splitId = id.split('.');
773
+ maxDepth = Math.max(maxDepth, splitId.length);
774
+ });
775
+ return maxDepth;
776
+ },
777
+ getPreExpandedRowModel: () => instance.getGroupedRowModel(),
778
+ getExpandedRowModel: () => {
779
+ if (!instance._getExpandedRowModel && instance.options.getExpandedRowModel) {
780
+ instance._getExpandedRowModel = instance.options.getExpandedRowModel(instance);
781
+ }
782
+
783
+ if (instance.options.manualExpanding || !instance._getExpandedRowModel) {
784
+ return instance.getPreExpandedRowModel();
785
+ }
786
+
787
+ return instance._getExpandedRowModel();
788
+ }
789
+ };
790
+ },
791
+ createRow: (row, instance) => {
792
+ return {
793
+ toggleExpanded: expanded => {
794
+ instance.setExpanded(old => {
795
+ var _expanded;
796
+
797
+ const exists = old === true ? true : !!(old != null && old[row.id]);
798
+ let oldExpanded = {};
799
+
800
+ if (old === true) {
801
+ Object.keys(instance.getRowModel().rowsById).forEach(rowId => {
802
+ oldExpanded[rowId] = true;
803
+ });
804
+ } else {
805
+ oldExpanded = old;
806
+ }
807
+
808
+ expanded = (_expanded = expanded) != null ? _expanded : !exists;
809
+
810
+ if (!exists && expanded) {
811
+ return { ...oldExpanded,
812
+ [row.id]: true
813
+ };
814
+ }
815
+
816
+ if (exists && !expanded) {
817
+ const {
818
+ [row.id]: _,
819
+ ...rest
820
+ } = oldExpanded;
821
+ return rest;
822
+ }
823
+
824
+ return old;
825
+ });
826
+ },
827
+ getIsExpanded: () => {
828
+ var _instance$options$get;
829
+
830
+ const expanded = instance.getState().expanded;
831
+ return !!((_instance$options$get = instance.options.getIsRowExpanded == null ? void 0 : instance.options.getIsRowExpanded(row)) != null ? _instance$options$get : expanded === true || (expanded == null ? void 0 : expanded[row.id]));
832
+ },
833
+ getCanExpand: () => {
834
+ var _instance$options$get2, _instance$options$ena, _row$subRows;
835
+
836
+ return ((_instance$options$get2 = instance.options.getRowCanExpand == null ? void 0 : instance.options.getRowCanExpand(row)) != null ? _instance$options$get2 : true) && ((_instance$options$ena = instance.options.enableExpanding) != null ? _instance$options$ena : true) && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
837
+ },
838
+ getToggleExpandedHandler: () => {
839
+ const canExpand = row.getCanExpand();
840
+ return () => {
841
+ if (!canExpand) return;
842
+ row.toggleExpanded();
843
+ };
844
+ }
845
+ };
846
+ }
847
+ };
848
+
849
+ const includesString = (row, columnId, filterValue) => {
850
+ const search = filterValue.toLowerCase();
851
+ return row.getValue(columnId).toLowerCase().includes(search);
852
+ };
853
+
854
+ includesString.autoRemove = val => testFalsey(val);
855
+
856
+ const includesStringSensitive = (row, columnId, filterValue) => {
857
+ return row.getValue(columnId).includes(filterValue);
858
+ };
859
+
860
+ includesStringSensitive.autoRemove = val => testFalsey(val);
861
+
862
+ const equalsString = (row, columnId, filterValue) => {
863
+ return row.getValue(columnId).toLowerCase() === filterValue.toLowerCase();
864
+ };
865
+
866
+ equalsString.autoRemove = val => testFalsey(val);
867
+
868
+ const arrIncludes = (row, columnId, filterValue) => {
869
+ return row.getValue(columnId).includes(filterValue);
870
+ };
871
+
872
+ arrIncludes.autoRemove = val => testFalsey(val) || !(val != null && val.length);
873
+
874
+ const arrIncludesAll = (row, columnId, filterValue) => {
875
+ return !filterValue.some(val => !row.getValue(columnId).includes(val));
876
+ };
877
+
878
+ arrIncludesAll.autoRemove = val => testFalsey(val) || !(val != null && val.length);
879
+
880
+ const arrIncludesSome = (row, columnId, filterValue) => {
881
+ return filterValue.some(val => row.getValue(columnId).includes(val));
882
+ };
883
+
884
+ arrIncludesSome.autoRemove = val => testFalsey(val) || !(val != null && val.length);
885
+
886
+ const equals = (row, columnId, filterValue) => {
887
+ return row.getValue(columnId) === filterValue;
888
+ };
889
+
890
+ equals.autoRemove = val => testFalsey(val);
891
+
892
+ const weakEquals = (row, columnId, filterValue) => {
893
+ return row.getValue(columnId) == filterValue;
894
+ };
895
+
896
+ weakEquals.autoRemove = val => testFalsey(val);
897
+
898
+ const inNumberRange = (row, columnId, filterValue) => {
899
+ let [min, max] = filterValue;
900
+ const rowValue = row.getValue(columnId);
901
+ return rowValue >= min && rowValue <= max;
902
+ };
903
+
904
+ inNumberRange.resolveFilterValue = val => {
905
+ let [unsafeMin, unsafeMax] = val;
906
+ let parsedMin = typeof unsafeMin !== 'number' ? parseFloat(unsafeMin) : unsafeMin;
907
+ let parsedMax = typeof unsafeMax !== 'number' ? parseFloat(unsafeMax) : unsafeMax;
908
+ let min = unsafeMin === null || Number.isNaN(parsedMin) ? -Infinity : parsedMin;
909
+ let max = unsafeMax === null || Number.isNaN(parsedMax) ? Infinity : parsedMax;
910
+
911
+ if (min > max) {
912
+ const temp = min;
913
+ min = max;
914
+ max = temp;
915
+ }
916
+
917
+ return [min, max];
918
+ };
919
+
920
+ inNumberRange.autoRemove = val => testFalsey(val) || testFalsey(val[0]) && testFalsey(val[1]); // Export
921
+
922
+
923
+ const filterFns = {
924
+ includesString,
925
+ includesStringSensitive,
926
+ equalsString,
927
+ arrIncludes,
928
+ arrIncludesAll,
929
+ arrIncludesSome,
930
+ equals,
931
+ weakEquals,
932
+ inNumberRange
933
+ };
934
+
935
+ // Utils
936
+ function testFalsey(val) {
937
+ return val === undefined || val === null || val === '';
938
+ }
939
+
940
+ //
941
+ const Filters = {
942
+ getDefaultColumn: () => {
943
+ return {
944
+ filterFn: 'auto'
945
+ };
946
+ },
947
+ getInitialState: state => {
948
+ return {
949
+ columnFilters: [],
950
+ globalFilter: undefined,
951
+ // filtersProgress: 1,
952
+ // facetProgress: {},
953
+ ...state
954
+ };
955
+ },
956
+ getDefaultOptions: instance => {
957
+ return {
958
+ onColumnFiltersChange: makeStateUpdater('columnFilters', instance),
959
+ onGlobalFilterChange: makeStateUpdater('globalFilter', instance),
960
+ filterFromLeafRows: false,
961
+ globalFilterFn: 'auto',
962
+ getColumnCanGlobalFilter: column => {
963
+ var _instance$getCoreRowM, _instance$getCoreRowM2;
964
+
965
+ const value = (_instance$getCoreRowM = instance.getCoreRowModel().flatRows[0]) == null ? void 0 : (_instance$getCoreRowM2 = _instance$getCoreRowM.getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreRowM2.getValue();
966
+ return typeof value === 'string';
967
+ }
968
+ };
969
+ },
970
+ createColumn: (column, instance) => {
971
+ return {
972
+ filterFn: column.filterFn,
973
+ getAutoFilterFn: () => {
974
+ const firstRow = instance.getCoreRowModel().flatRows[0];
975
+ const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
976
+
977
+ if (typeof value === 'string') {
978
+ return filterFns.includesString;
979
+ }
980
+
981
+ if (typeof value === 'number') {
982
+ return filterFns.inNumberRange;
983
+ }
984
+
985
+ if (value !== null && typeof value === 'object') {
986
+ return filterFns.equals;
987
+ }
988
+
989
+ if (Array.isArray(value)) {
990
+ return filterFns.arrIncludes;
991
+ }
992
+
993
+ return filterFns.weakEquals;
994
+ },
995
+ getFilterFn: () => {
996
+ var _ref;
997
+
998
+ const userFilterFns = instance.options.filterFns;
999
+ return isFunction(column.filterFn) ? column.filterFn : column.filterFn === 'auto' ? column.getAutoFilterFn() : (_ref = userFilterFns == null ? void 0 : userFilterFns[column.filterFn]) != null ? _ref : filterFns[column.filterFn];
1000
+ },
1001
+ getCanFilter: () => {
1002
+ var _column$enableColumnF, _instance$options$ena, _instance$options$ena2;
1003
+
1004
+ return ((_column$enableColumnF = column.enableColumnFilter) != null ? _column$enableColumnF : true) && ((_instance$options$ena = instance.options.enableColumnFilters) != null ? _instance$options$ena : true) && ((_instance$options$ena2 = instance.options.enableFilters) != null ? _instance$options$ena2 : true) && !!column.accessorFn;
1005
+ },
1006
+ getCanGlobalFilter: () => {
1007
+ var _column$enableGlobalF, _instance$options$ena3, _instance$options$ena4, _instance$options$get;
1008
+
1009
+ return ((_column$enableGlobalF = column.enableGlobalFilter) != null ? _column$enableGlobalF : true) && ((_instance$options$ena3 = instance.options.enableGlobalFilter) != null ? _instance$options$ena3 : true) && ((_instance$options$ena4 = instance.options.enableFilters) != null ? _instance$options$ena4 : true) && ((_instance$options$get = instance.options.getColumnCanGlobalFilter == null ? void 0 : instance.options.getColumnCanGlobalFilter(column)) != null ? _instance$options$get : true) && !!column.accessorFn;
1010
+ },
1011
+ getIsFiltered: () => column.getFilterIndex() > -1,
1012
+ getFilterValue: () => {
1013
+ var _instance$getState$co, _instance$getState$co2;
1014
+
1015
+ return (_instance$getState$co = instance.getState().columnFilters) == null ? void 0 : (_instance$getState$co2 = _instance$getState$co.find(d => d.id === column.id)) == null ? void 0 : _instance$getState$co2.value;
1016
+ },
1017
+ getFilterIndex: () => {
1018
+ var _instance$getState$co3, _instance$getState$co4;
1019
+
1020
+ return (_instance$getState$co3 = (_instance$getState$co4 = instance.getState().columnFilters) == null ? void 0 : _instance$getState$co4.findIndex(d => d.id === column.id)) != null ? _instance$getState$co3 : -1;
1021
+ },
1022
+ setFilterValue: value => {
1023
+ instance.setColumnFilters(old => {
1024
+ const filterFn = column.getFilterFn();
1025
+ const previousfilter = old == null ? void 0 : old.find(d => d.id === column.id);
1026
+ const newFilter = functionalUpdate(value, previousfilter ? previousfilter.value : undefined); //
1027
+
1028
+ if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {
1029
+ var _old$filter;
1030
+
1031
+ return (_old$filter = old == null ? void 0 : old.filter(d => d.id !== column.id)) != null ? _old$filter : [];
1032
+ }
1033
+
1034
+ const newFilterObj = {
1035
+ id: column.id,
1036
+ value: newFilter
1037
+ };
1038
+
1039
+ if (previousfilter) {
1040
+ var _old$map;
1041
+
1042
+ return (_old$map = old == null ? void 0 : old.map(d => {
1043
+ if (d.id === column.id) {
1044
+ return newFilterObj;
1045
+ }
1046
+
1047
+ return d;
1048
+ })) != null ? _old$map : [];
1049
+ }
1050
+
1051
+ if (old != null && old.length) {
1052
+ return [...old, newFilterObj];
1053
+ }
1054
+
1055
+ return [newFilterObj];
1056
+ });
1057
+ },
1058
+ _getFacetedRowModel: instance.options.getFacetedRowModel && instance.options.getFacetedRowModel(instance, column.id),
1059
+ getFacetedRowModel: () => {
1060
+ if (!column._getFacetedRowModel) {
1061
+ return instance.getPreFilteredRowModel();
1062
+ }
1063
+
1064
+ return column._getFacetedRowModel();
1065
+ },
1066
+ _getFacetedUniqueValues: instance.options.getFacetedUniqueValues && instance.options.getFacetedUniqueValues(instance, column.id),
1067
+ getFacetedUniqueValues: () => {
1068
+ if (!column._getFacetedUniqueValues) {
1069
+ return new Map();
1070
+ }
1071
+
1072
+ return column._getFacetedUniqueValues();
1073
+ },
1074
+ _getFacetedMinMaxValues: instance.options.getFacetedMinMaxValues && instance.options.getFacetedMinMaxValues(instance, column.id),
1075
+ getFacetedMinMaxValues: () => {
1076
+ if (!column._getFacetedMinMaxValues) {
1077
+ return [NaN, NaN];
1078
+ }
1079
+
1080
+ return column._getFacetedMinMaxValues();
1081
+ } // () => [column.getFacetedRowModel()],
1082
+ // facetedRowModel => getRowModelMinMaxValues(facetedRowModel, column.id),
1083
+
1084
+ };
1085
+ },
1086
+ createRow: (row, instance) => {
1087
+ return {
1088
+ columnFilterMap: {},
1089
+ subRowsByFacetId: {}
1090
+ };
1091
+ },
1092
+ createInstance: instance => {
1093
+ return {
1094
+ getGlobalAutoFilterFn: () => {
1095
+ return filterFns.includesString;
1096
+ },
1097
+ getGlobalFilterFn: () => {
1098
+ var _ref2;
1099
+
1100
+ const {
1101
+ filterFns: userFilterFns,
1102
+ globalFilterFn: globalFilterFn
1103
+ } = instance.options;
1104
+ return isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === 'auto' ? instance.getGlobalAutoFilterFn() : (_ref2 = userFilterFns == null ? void 0 : userFilterFns[globalFilterFn]) != null ? _ref2 : filterFns[globalFilterFn];
1105
+ },
1106
+ setColumnFilters: updater => {
1107
+ const leafColumns = instance.getAllLeafColumns();
1108
+
1109
+ const updateFn = old => {
1110
+ var _functionalUpdate;
1111
+
1112
+ return (_functionalUpdate = functionalUpdate(updater, old)) == null ? void 0 : _functionalUpdate.filter(filter => {
1113
+ const column = leafColumns.find(d => d.id === filter.id);
1114
+
1115
+ if (column) {
1116
+ const filterFn = column.getFilterFn();
1117
+
1118
+ if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {
1119
+ return false;
1120
+ }
1121
+ }
1122
+
1123
+ return true;
1124
+ });
1125
+ };
1126
+
1127
+ instance.options.onColumnFiltersChange == null ? void 0 : instance.options.onColumnFiltersChange(updateFn);
1128
+ },
1129
+ setGlobalFilter: updater => {
1130
+ instance.options.onGlobalFilterChange == null ? void 0 : instance.options.onGlobalFilterChange(updater);
1131
+ },
1132
+ resetGlobalFilter: defaultState => {
1133
+ instance.setGlobalFilter(defaultState ? undefined : instance.initialState.globalFilter);
1134
+ },
1135
+ resetColumnFilters: defaultState => {
1136
+ var _instance$initialStat, _instance$initialStat2;
1137
+
1138
+ instance.setColumnFilters(defaultState ? [] : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.columnFilters) != null ? _instance$initialStat : []);
1139
+ },
1140
+ getPreFilteredRowModel: () => instance.getCoreRowModel(),
1141
+ _getFilteredRowModel: instance.options.getFilteredRowModel && instance.options.getFilteredRowModel(instance),
1142
+ getFilteredRowModel: () => {
1143
+ if (instance.options.manualFiltering || !instance._getFilteredRowModel) {
1144
+ return instance.getPreFilteredRowModel();
1145
+ }
1146
+
1147
+ return instance._getFilteredRowModel();
1148
+ },
1149
+ _getGlobalFacetedRowModel: instance.options.getFacetedRowModel && instance.options.getFacetedRowModel(instance, '__global__'),
1150
+ getGlobalFacetedRowModel: () => {
1151
+ if (instance.options.manualFiltering || !instance._getGlobalFacetedRowModel) {
1152
+ return instance.getPreFilteredRowModel();
1153
+ }
1154
+
1155
+ return instance._getGlobalFacetedRowModel();
1156
+ },
1157
+ _getGlobalFacetedUniqueValues: instance.options.getFacetedUniqueValues && instance.options.getFacetedUniqueValues(instance, '__global__'),
1158
+ getGlobalFacetedUniqueValues: () => {
1159
+ if (!instance._getGlobalFacetedUniqueValues) {
1160
+ return new Map();
1161
+ }
1162
+
1163
+ return instance._getGlobalFacetedUniqueValues();
1164
+ },
1165
+ _getGlobalFacetedMinMaxValues: instance.options.getFacetedMinMaxValues && instance.options.getFacetedMinMaxValues(instance, '__global__'),
1166
+ getGlobalFacetedMinMaxValues: () => {
1167
+ if (!instance._getGlobalFacetedMinMaxValues) {
1168
+ return [NaN, NaN];
1169
+ }
1170
+
1171
+ return instance._getGlobalFacetedMinMaxValues();
1172
+ }
1173
+ };
1174
+ }
1175
+ };
1176
+ function shouldAutoRemoveFilter(filterFn, value, column) {
1177
+ return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
1178
+ }
1179
+
1180
+ const aggregationFns = {
1181
+ sum,
1182
+ min,
1183
+ max,
1184
+ extent,
1185
+ mean,
1186
+ median,
1187
+ unique,
1188
+ uniqueCount,
1189
+ count
1190
+ };
1191
+
1192
+ function sum(_getLeafValues, getChildValues) {
1193
+ // It's faster to just add the aggregations together instead of
1194
+ // process leaf nodes individually
1195
+ return getChildValues().reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
1196
+ }
1197
+
1198
+ function min(_getLeafValues, getChildValues) {
1199
+ let min;
1200
+
1201
+ for (const value of getChildValues()) {
1202
+ if (value != null && (min > value || min === undefined && value >= value)) {
1203
+ min = value;
1204
+ }
1205
+ }
1206
+
1207
+ return min;
1208
+ }
1209
+
1210
+ function max(_getLeafValues, getChildValues) {
1211
+ let max;
1212
+
1213
+ for (const value of getChildValues()) {
1214
+ if (value != null && (max < value || max === undefined && value >= value)) {
1215
+ max = value;
1216
+ }
1217
+ }
1218
+
1219
+ return max;
1220
+ }
1221
+
1222
+ function extent(_getLeafValues, getChildValues) {
1223
+ let min;
1224
+ let max;
1225
+
1226
+ for (const value of getChildValues()) {
1227
+ if (value != null) {
1228
+ if (min === undefined) {
1229
+ if (value >= value) min = max = value;
1230
+ } else {
1231
+ if (min > value) min = value;
1232
+ if (max < value) max = value;
1233
+ }
1234
+ }
1235
+ }
1236
+
1237
+ return [min, max];
1238
+ }
1239
+
1240
+ function mean(getLeafValues) {
1241
+ let count = 0;
1242
+ let sum = 0;
1243
+
1244
+ for (let value of getLeafValues()) {
1245
+ if (value != null && (value = +value) >= value) {
1246
+ ++count, sum += value;
1247
+ }
1248
+ }
1249
+
1250
+ if (count) return sum / count;
1251
+ return;
1252
+ }
1253
+
1254
+ function median(getLeafValues) {
1255
+ const leafValues = getLeafValues();
1256
+
1257
+ if (!leafValues.length) {
1258
+ return;
1259
+ }
1260
+
1261
+ let min = 0;
1262
+ let max = 0;
1263
+ leafValues.forEach(value => {
1264
+ if (typeof value === 'number') {
1265
+ min = Math.min(min, value);
1266
+ max = Math.max(max, value);
1267
+ }
1268
+ });
1269
+ return (min + max) / 2;
1270
+ }
1271
+
1272
+ function unique(getLeafValues) {
1273
+ return Array.from(new Set(getLeafValues()).values());
1274
+ }
1275
+
1276
+ function uniqueCount(getLeafValues) {
1277
+ return new Set(getLeafValues()).size;
1278
+ }
1279
+
1280
+ function count(getLeafValues) {
1281
+ return getLeafValues().length;
1282
+ }
1283
+
1284
+ //
1285
+ const Grouping = {
1286
+ getDefaultColumn: () => {
1287
+ return {
1288
+ aggregationFn: 'auto'
1289
+ };
1290
+ },
1291
+ getInitialState: state => {
1292
+ return {
1293
+ grouping: [],
1294
+ ...state
1295
+ };
1296
+ },
1297
+ getDefaultOptions: instance => {
1298
+ return {
1299
+ onGroupingChange: makeStateUpdater('grouping', instance),
1300
+ groupedColumnMode: 'reorder'
1301
+ };
1302
+ },
1303
+ createColumn: (column, instance) => {
1304
+ return {
1305
+ toggleGrouping: () => {
1306
+ instance.setGrouping(old => {
1307
+ // Find any existing grouping for this column
1308
+ if (old != null && old.includes(column.id)) {
1309
+ return old.filter(d => d !== column.id);
1310
+ }
1311
+
1312
+ return [...(old != null ? old : []), column.id];
1313
+ });
1314
+ },
1315
+ getCanGroup: () => {
1316
+ var _ref, _ref2, _ref3, _column$enableGroupin;
1317
+
1318
+ return (_ref = (_ref2 = (_ref3 = (_column$enableGroupin = column.enableGrouping) != null ? _column$enableGroupin : true) != null ? _ref3 : instance.options.enableGrouping) != null ? _ref2 : true) != null ? _ref : !!column.accessorFn;
1319
+ },
1320
+ getIsGrouped: () => {
1321
+ var _instance$getState$gr;
1322
+
1323
+ return (_instance$getState$gr = instance.getState().grouping) == null ? void 0 : _instance$getState$gr.includes(column.id);
1324
+ },
1325
+ getGroupedIndex: () => {
1326
+ var _instance$getState$gr2;
1327
+
1328
+ return (_instance$getState$gr2 = instance.getState().grouping) == null ? void 0 : _instance$getState$gr2.indexOf(column.id);
1329
+ },
1330
+ getToggleGroupingHandler: () => {
1331
+ const canGroup = column.getCanGroup();
1332
+ return () => {
1333
+ if (!canGroup) return;
1334
+ column.toggleGrouping();
1335
+ };
1336
+ },
1337
+ getColumnAutoAggregationFn: () => {
1338
+ const firstRow = instance.getCoreRowModel().flatRows[0];
1339
+ const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
1340
+
1341
+ if (typeof value === 'number') {
1342
+ return aggregationFns.sum;
1343
+ }
1344
+
1345
+ if (Object.prototype.toString.call(value) === '[object Date]') {
1346
+ return aggregationFns.extent;
1347
+ }
1348
+
1349
+ return aggregationFns.count;
1350
+ },
1351
+ getColumnAggregationFn: () => {
1352
+ var _ref4;
1353
+
1354
+ const userAggregationFns = instance.options.aggregationFns;
1355
+
1356
+ if (!column) {
1357
+ throw new Error();
1358
+ }
1359
+
1360
+ return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.getColumnAutoAggregationFn() : (_ref4 = userAggregationFns == null ? void 0 : userAggregationFns[column.aggregationFn]) != null ? _ref4 : aggregationFns[column.aggregationFn];
1361
+ }
1362
+ };
1363
+ },
1364
+ createInstance: instance => {
1365
+ return {
1366
+ setGrouping: updater => instance.options.onGroupingChange == null ? void 0 : instance.options.onGroupingChange(updater),
1367
+ resetGrouping: defaultState => {
1368
+ var _instance$initialStat, _instance$initialStat2;
1369
+
1370
+ instance.setGrouping(defaultState ? [] : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.grouping) != null ? _instance$initialStat : []);
1371
+ },
1372
+ getPreGroupedRowModel: () => instance.getSortedRowModel(),
1373
+ getGroupedRowModel: () => {
1374
+ if (!instance._getGroupedRowModel && instance.options.getGroupedRowModel) {
1375
+ instance._getGroupedRowModel = instance.options.getGroupedRowModel(instance);
1376
+ }
1377
+
1378
+ if (instance.options.manualGrouping || !instance._getGroupedRowModel) {
1379
+ return instance.getPreGroupedRowModel();
1380
+ }
1381
+
1382
+ return instance._getGroupedRowModel();
1383
+ }
1384
+ };
1385
+ },
1386
+ createRow: (row, instance) => {
1387
+ return {
1388
+ getIsGrouped: () => !!row.groupingColumnId,
1389
+ groupingValuesCache: {}
1390
+ };
1391
+ },
1392
+ createCell: (cell, column, row, instance) => {
1393
+ return {
1394
+ getIsGrouped: () => column.getIsGrouped() && column.id === row.groupingColumnId,
1395
+ getIsPlaceholder: () => !cell.getIsGrouped() && column.getIsGrouped(),
1396
+ getIsAggregated: () => {
1397
+ var _row$subRows;
1398
+
1399
+ return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
1400
+ },
1401
+ renderAggregatedCell: () => {
1402
+ var _column$aggregatedCel;
1403
+
1404
+ const template = (_column$aggregatedCel = column.aggregatedCell) != null ? _column$aggregatedCel : column.cell;
1405
+ return template ? instance.render(template, {
1406
+ instance,
1407
+ column,
1408
+ row,
1409
+ cell,
1410
+ getValue: cell.getValue
1411
+ }) : null;
1412
+ }
1413
+ };
1414
+ }
1415
+ };
1416
+ function orderColumns(leafColumns, grouping, groupedColumnMode) {
1417
+ if (!(grouping != null && grouping.length) || !groupedColumnMode) {
1418
+ return leafColumns;
1419
+ }
1420
+
1421
+ const nonGroupingColumns = leafColumns.filter(col => !grouping.includes(col.id));
1422
+
1423
+ if (groupedColumnMode === 'remove') {
1424
+ return nonGroupingColumns;
1425
+ }
1426
+
1427
+ const groupingColumns = grouping.map(g => leafColumns.find(col => col.id === g)).filter(Boolean);
1428
+ return [...groupingColumns, ...nonGroupingColumns];
1429
+ }
1430
+
1431
+ //
1432
+ const Ordering = {
1433
+ getInitialState: state => {
1434
+ return {
1435
+ columnOrder: [],
1436
+ ...state
1437
+ };
1438
+ },
1439
+ getDefaultOptions: instance => {
1440
+ return {
1441
+ onColumnOrderChange: makeStateUpdater('columnOrder', instance)
1442
+ };
1443
+ },
1444
+ createInstance: instance => {
1445
+ return {
1446
+ setColumnOrder: updater => instance.options.onColumnOrderChange == null ? void 0 : instance.options.onColumnOrderChange(updater),
1447
+ resetColumnOrder: defaultState => {
1448
+ var _instance$initialStat;
1449
+
1450
+ instance.setColumnOrder(defaultState ? [] : (_instance$initialStat = instance.initialState.columnOrder) != null ? _instance$initialStat : []);
1451
+ },
1452
+ _getOrderColumnsFn: memo(() => [instance.getState().columnOrder, instance.getState().grouping, instance.options.groupedColumnMode], (columnOrder, grouping, groupedColumnMode) => columns => {
1453
+ // Sort grouped columns to the start of the column list
1454
+ // before the headers are built
1455
+ let orderedColumns = []; // If there is no order, return the normal columns
1456
+
1457
+ if (!(columnOrder != null && columnOrder.length)) {
1458
+ orderedColumns = columns;
1459
+ } else {
1460
+ const columnOrderCopy = [...columnOrder]; // If there is an order, make a copy of the columns
1461
+
1462
+ const columnsCopy = [...columns]; // And make a new ordered array of the columns
1463
+ // Loop over the columns and place them in order into the new array
1464
+
1465
+ while (columnsCopy.length && columnOrderCopy.length) {
1466
+ const targetColumnId = columnOrderCopy.shift();
1467
+ const foundIndex = columnsCopy.findIndex(d => d.id === targetColumnId);
1468
+
1469
+ if (foundIndex > -1) {
1470
+ orderedColumns.push(columnsCopy.splice(foundIndex, 1)[0]);
1471
+ }
1472
+ } // If there are any columns left, add them to the end
1473
+
1474
+
1475
+ orderedColumns = [...orderedColumns, ...columnsCopy];
1476
+ }
1477
+
1478
+ return orderColumns(orderedColumns, grouping, groupedColumnMode);
1479
+ }, {
1480
+ key: process.env.NODE_ENV === 'development' && 'getOrderColumnsFn' // debug: () => instance.options.debugAll ?? instance.options.debugTable,
1481
+
1482
+ })
1483
+ };
1484
+ }
1485
+ };
1486
+
1487
+ //
1488
+ const defaultPageCount = -1;
1489
+ const defaultPageIndex = 0;
1490
+ const defaultPageSize = 10;
1491
+
1492
+ const getDefaultPaginationState = () => ({
1493
+ pageCount: defaultPageCount,
1494
+ pageIndex: defaultPageIndex,
1495
+ pageSize: defaultPageSize
1496
+ });
1497
+
1498
+ const Pagination = {
1499
+ getInitialState: state => {
1500
+ return { ...state,
1501
+ pagination: { ...getDefaultPaginationState(),
1502
+ ...(state == null ? void 0 : state.pagination)
1503
+ }
1504
+ };
1505
+ },
1506
+ getDefaultOptions: instance => {
1507
+ return {
1508
+ onPaginationChange: makeStateUpdater('pagination', instance),
1509
+ autoResetPageIndex: true
1510
+ };
1511
+ },
1512
+ createInstance: instance => {
1513
+ let registered = false;
1514
+ return {
1515
+ _autoResetPageIndex: () => {
1516
+ if (!registered) {
1517
+ registered = true;
1518
+ return;
1519
+ }
1520
+
1521
+ if (instance.options.autoResetAll === false) {
1522
+ return;
1523
+ }
1524
+
1525
+ if (instance.options.autoResetAll === true || instance.options.autoResetPageIndex) {
1526
+ instance.resetPageIndex();
1527
+ }
1528
+ },
1529
+ setPagination: updater => {
1530
+ const safeUpdater = old => {
1531
+ let newState = functionalUpdate(updater, old);
1532
+ return newState;
1533
+ };
1534
+
1535
+ return instance.options.onPaginationChange == null ? void 0 : instance.options.onPaginationChange(safeUpdater);
1536
+ },
1537
+ resetPagination: defaultState => {
1538
+ var _instance$initialStat;
1539
+
1540
+ instance.setPagination(defaultState ? getDefaultPaginationState() : (_instance$initialStat = instance.initialState.pagination) != null ? _instance$initialStat : getDefaultPaginationState());
1541
+ },
1542
+ setPageIndex: updater => {
1543
+ instance.setPagination(old => {
1544
+ let pageIndex = functionalUpdate(updater, old.pageIndex);
1545
+ const maxPageIndex = old.pageCount && old.pageCount > 0 ? old.pageCount - 1 : Number.MAX_SAFE_INTEGER;
1546
+ pageIndex = Math.min(Math.max(0, pageIndex), maxPageIndex);
1547
+ return { ...old,
1548
+ pageIndex
1549
+ };
1550
+ });
1551
+ },
1552
+ resetPageIndex: defaultState => {
1553
+ var _instance$initialStat2, _instance$initialStat3, _instance$initialStat4;
1554
+
1555
+ instance.setPageIndex(defaultState ? defaultPageIndex : (_instance$initialStat2 = (_instance$initialStat3 = instance.initialState) == null ? void 0 : (_instance$initialStat4 = _instance$initialStat3.pagination) == null ? void 0 : _instance$initialStat4.pageIndex) != null ? _instance$initialStat2 : defaultPageIndex);
1556
+ },
1557
+ resetPageSize: defaultState => {
1558
+ var _instance$initialStat5, _instance$initialStat6, _instance$initialStat7;
1559
+
1560
+ instance.setPageSize(defaultState ? defaultPageSize : (_instance$initialStat5 = (_instance$initialStat6 = instance.initialState) == null ? void 0 : (_instance$initialStat7 = _instance$initialStat6.pagination) == null ? void 0 : _instance$initialStat7.pageSize) != null ? _instance$initialStat5 : defaultPageSize);
1561
+ },
1562
+ setPageSize: updater => {
1563
+ instance.setPagination(old => {
1564
+ const pageSize = Math.max(1, functionalUpdate(updater, old.pageSize));
1565
+ const topRowIndex = old.pageSize * old.pageIndex;
1566
+ const pageIndex = Math.floor(topRowIndex / pageSize);
1567
+ return { ...old,
1568
+ pageIndex,
1569
+ pageSize
1570
+ };
1571
+ });
1572
+ },
1573
+ setPageCount: updater => instance.setPagination(old => {
1574
+ let newPageCount = functionalUpdate(updater, old.pageCount);
1575
+
1576
+ if (typeof newPageCount === 'number') {
1577
+ newPageCount = Math.max(-1, newPageCount);
1578
+ }
1579
+
1580
+ return { ...old,
1581
+ pageCount: newPageCount
1582
+ };
1583
+ }),
1584
+ getPageOptions: memo(() => [instance.getState().pagination.pageSize, instance.getState().pagination.pageCount], (pageSize, pageCount) => {
1585
+ let pageOptions = [];
1586
+
1587
+ if (pageCount && pageCount > 0) {
1588
+ pageOptions = [...new Array(pageCount)].fill(null).map((_, i) => i);
1589
+ }
1590
+
1591
+ return pageOptions;
1592
+ }, {
1593
+ key: process.env.NODE_ENV === 'development' && 'getPageOptions',
1594
+ debug: () => {
1595
+ var _instance$options$deb;
1596
+
1597
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
1598
+ }
1599
+ }),
1600
+ getCanPreviousPage: () => instance.getState().pagination.pageIndex > 0,
1601
+ getCanNextPage: () => {
1602
+ const {
1603
+ pageIndex
1604
+ } = instance.getState().pagination;
1605
+ const pageCount = instance.getPageCount();
1606
+
1607
+ if (pageCount === -1) {
1608
+ return true;
1609
+ }
1610
+
1611
+ if (pageCount === 0) {
1612
+ return false;
1613
+ }
1614
+
1615
+ return pageIndex < pageCount - 1;
1616
+ },
1617
+ previousPage: () => {
1618
+ return instance.setPageIndex(old => old - 1);
1619
+ },
1620
+ nextPage: () => {
1621
+ return instance.setPageIndex(old => {
1622
+ return old + 1;
1623
+ });
1624
+ },
1625
+ getPrePaginationRowModel: () => instance.getExpandedRowModel(),
1626
+ getPaginationRowModel: () => {
1627
+ if (!instance._getPaginationRowModel && instance.options.getPaginationRowModel) {
1628
+ instance._getPaginationRowModel = instance.options.getPaginationRowModel(instance);
1629
+ }
1630
+
1631
+ if (instance.options.manualPagination || !instance._getPaginationRowModel) {
1632
+ return instance.getPrePaginationRowModel();
1633
+ }
1634
+
1635
+ return instance._getPaginationRowModel();
1636
+ },
1637
+ getPageCount: () => {
1638
+ const {
1639
+ pageCount
1640
+ } = instance.getState().pagination;
1641
+
1642
+ if (pageCount > 0) {
1643
+ return pageCount;
1644
+ }
1645
+
1646
+ return Math.ceil(instance.getPrePaginationRowModel().rows.length / instance.getState().pagination.pageSize);
1647
+ }
1648
+ };
1649
+ }
1650
+ };
1651
+
1652
+ //
1653
+ const getDefaultPinningState = () => ({
1654
+ left: [],
1655
+ right: []
1656
+ });
1657
+
1658
+ const Pinning = {
1659
+ getInitialState: state => {
1660
+ return {
1661
+ columnPinning: getDefaultPinningState(),
1662
+ ...state
1663
+ };
1664
+ },
1665
+ getDefaultOptions: instance => {
1666
+ return {
1667
+ onColumnPinningChange: makeStateUpdater('columnPinning', instance)
1668
+ };
1669
+ },
1670
+ createColumn: (column, instance) => {
1671
+ return {
1672
+ pin: position => {
1673
+ const columnIds = column.getLeafColumns().map(d => d.id).filter(Boolean);
1674
+ instance.setColumnPinning(old => {
1675
+ var _old$left3, _old$right3;
1676
+
1677
+ if (position === 'right') {
1678
+ var _old$left, _old$right;
1679
+
1680
+ return {
1681
+ left: ((_old$left = old == null ? void 0 : old.left) != null ? _old$left : []).filter(d => !(columnIds != null && columnIds.includes(d))),
1682
+ right: [...((_old$right = old == null ? void 0 : old.right) != null ? _old$right : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds]
1683
+ };
1684
+ }
1685
+
1686
+ if (position === 'left') {
1687
+ var _old$left2, _old$right2;
1688
+
1689
+ return {
1690
+ left: [...((_old$left2 = old == null ? void 0 : old.left) != null ? _old$left2 : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds],
1691
+ right: ((_old$right2 = old == null ? void 0 : old.right) != null ? _old$right2 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
1692
+ };
1693
+ }
1694
+
1695
+ return {
1696
+ left: ((_old$left3 = old == null ? void 0 : old.left) != null ? _old$left3 : []).filter(d => !(columnIds != null && columnIds.includes(d))),
1697
+ right: ((_old$right3 = old == null ? void 0 : old.right) != null ? _old$right3 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
1698
+ };
1699
+ });
1700
+ },
1701
+ getCanPin: () => {
1702
+ const leafColumns = column.getLeafColumns();
1703
+ return leafColumns.some(d => {
1704
+ var _d$enablePinning, _instance$options$ena;
1705
+
1706
+ return ((_d$enablePinning = d.enablePinning) != null ? _d$enablePinning : true) && ((_instance$options$ena = instance.options.enablePinning) != null ? _instance$options$ena : true);
1707
+ });
1708
+ },
1709
+ getIsPinned: () => {
1710
+ const leafColumnIds = column.getLeafColumns().map(d => d.id);
1711
+ const {
1712
+ left,
1713
+ right
1714
+ } = instance.getState().columnPinning;
1715
+ const isLeft = leafColumnIds.some(d => left == null ? void 0 : left.includes(d));
1716
+ const isRight = leafColumnIds.some(d => right == null ? void 0 : right.includes(d));
1717
+ return isLeft ? 'left' : isRight ? 'right' : false;
1718
+ },
1719
+ getPinnedIndex: () => {
1720
+ var _instance$getState$co, _instance$getState$co2, _instance$getState$co3;
1721
+
1722
+ const position = column.getIsPinned();
1723
+ return position ? (_instance$getState$co = (_instance$getState$co2 = instance.getState().columnPinning) == null ? void 0 : (_instance$getState$co3 = _instance$getState$co2[position]) == null ? void 0 : _instance$getState$co3.indexOf(column.id)) != null ? _instance$getState$co : -1 : 0;
1724
+ }
1725
+ };
1726
+ },
1727
+ createRow: (row, instance) => {
1728
+ return {
1729
+ getCenterVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allCells, left, right) => {
1730
+ const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
1731
+ return allCells.filter(d => !leftAndRight.includes(d.columnId));
1732
+ }, {
1733
+ key: process.env.NODE_ENV === 'production' && 'row.getCenterVisibleCells',
1734
+ debug: () => {
1735
+ var _instance$options$deb;
1736
+
1737
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
1738
+ }
1739
+ }),
1740
+ getLeftVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left,,], (allCells, left) => {
1741
+ const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.columnId === columnId)).filter(Boolean).map(d => ({ ...d,
1742
+ position: 'left'
1743
+ }));
1744
+ return cells;
1745
+ }, {
1746
+ key: process.env.NODE_ENV === 'production' && 'row.getLeftVisibleCells',
1747
+ debug: () => {
1748
+ var _instance$options$deb2;
1749
+
1750
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
1751
+ }
1752
+ }),
1753
+ getRightVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.right], (allCells, right) => {
1754
+ const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.columnId === columnId)).filter(Boolean).map(d => ({ ...d,
1755
+ position: 'left'
1756
+ }));
1757
+ return cells;
1758
+ }, {
1759
+ key: process.env.NODE_ENV === 'production' && 'row.getRightVisibleCells',
1760
+ debug: () => {
1761
+ var _instance$options$deb3;
1762
+
1763
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugRows;
1764
+ }
1765
+ })
1766
+ };
1767
+ },
1768
+ createInstance: instance => {
1769
+ return {
1770
+ setColumnPinning: updater => instance.options.onColumnPinningChange == null ? void 0 : instance.options.onColumnPinningChange(updater),
1771
+ resetColumnPinning: defaultState => {
1772
+ var _instance$initialStat, _instance$initialStat2;
1773
+
1774
+ return instance.setColumnPinning(defaultState ? getDefaultPinningState() : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.columnPinning) != null ? _instance$initialStat : getDefaultPinningState());
1775
+ },
1776
+ getIsSomeColumnsPinned: () => {
1777
+ const {
1778
+ left,
1779
+ right
1780
+ } = instance.getState().columnPinning;
1781
+ return Boolean((left == null ? void 0 : left.length) || (right == null ? void 0 : right.length));
1782
+ },
1783
+ getLeftLeafColumns: memo(() => [instance.getAllLeafColumns(), instance.getState().columnPinning.left], (allColumns, left) => {
1784
+ return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
1785
+ }, {
1786
+ key: process.env.NODE_ENV === 'development' && 'getLeftLeafColumns',
1787
+ debug: () => {
1788
+ var _instance$options$deb4;
1789
+
1790
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
1791
+ }
1792
+ }),
1793
+ getRightLeafColumns: memo(() => [instance.getAllLeafColumns(), instance.getState().columnPinning.right], (allColumns, right) => {
1794
+ return (right != null ? right : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
1795
+ }, {
1796
+ key: process.env.NODE_ENV === 'development' && 'getRightLeafColumns',
1797
+ debug: () => {
1798
+ var _instance$options$deb5;
1799
+
1800
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
1801
+ }
1802
+ }),
1803
+ getCenterLeafColumns: memo(() => [instance.getAllLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, left, right) => {
1804
+ const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
1805
+ return allColumns.filter(d => !leftAndRight.includes(d.id));
1806
+ }, {
1807
+ key: process.env.NODE_ENV === 'development' && 'getCenterLeafColumns',
1808
+ debug: () => {
1809
+ var _instance$options$deb6;
1810
+
1811
+ return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugColumns;
1812
+ }
1813
+ })
1814
+ };
1815
+ }
1816
+ };
1817
+
1818
+ //
1819
+ const RowSelection = {
1820
+ getInitialState: state => {
1821
+ return {
1822
+ rowSelection: {},
1823
+ ...state
1824
+ };
1825
+ },
1826
+ getDefaultOptions: instance => {
1827
+ return {
1828
+ onRowSelectionChange: makeStateUpdater('rowSelection', instance),
1829
+ enableRowSelection: true,
1830
+ enableMultiRowSelection: true,
1831
+ enableSubRowSelection: true // enableGroupingRowSelection: false,
1832
+ // isAdditiveSelectEvent: (e: unknown) => !!e.metaKey,
1833
+ // isInclusiveSelectEvent: (e: unknown) => !!e.shiftKey,
1834
+
1835
+ };
1836
+ },
1837
+ createInstance: instance => {
1838
+ return {
1839
+ setRowSelection: updater => instance.options.onRowSelectionChange == null ? void 0 : instance.options.onRowSelectionChange(updater),
1840
+ resetRowSelection: defaultState => {
1841
+ var _instance$initialStat;
1842
+
1843
+ return instance.setRowSelection(defaultState ? {} : (_instance$initialStat = instance.initialState.rowSelection) != null ? _instance$initialStat : {});
1844
+ },
1845
+ toggleAllRowsSelected: value => {
1846
+ instance.setRowSelection(old => {
1847
+ value = typeof value !== 'undefined' ? value : !instance.getIsAllRowsSelected();
1848
+ const rowSelection = { ...old
1849
+ };
1850
+ const preGroupedFlatRows = instance.getPreGroupedRowModel().flatRows; // We don't use `mutateRowIsSelected` here for performance reasons.
1851
+ // All of the rows are flat already, so it wouldn't be worth it
1852
+
1853
+ if (value) {
1854
+ preGroupedFlatRows.forEach(row => {
1855
+ rowSelection[row.id] = true;
1856
+ });
1857
+ } else {
1858
+ preGroupedFlatRows.forEach(row => {
1859
+ delete rowSelection[row.id];
1860
+ });
1861
+ }
1862
+
1863
+ return rowSelection;
1864
+ });
1865
+ },
1866
+ toggleAllPageRowsSelected: value => instance.setRowSelection(old => {
1867
+ typeof value !== 'undefined' ? value : !instance.getIsAllPageRowsSelected();
1868
+ const rowSelection = { ...old
1869
+ };
1870
+ instance.getRowModel().rows.forEach(row => {
1871
+ mutateRowIsSelected(rowSelection, row.id, value, instance);
1872
+ });
1873
+ return rowSelection;
1874
+ }),
1875
+ // addRowSelectionRange: rowId => {
1876
+ // const {
1877
+ // rows,
1878
+ // rowsById,
1879
+ // options: { selectGroupingRows, selectSubRows },
1880
+ // } = instance
1881
+ // const findSelectedRow = (rows: Row[]) => {
1882
+ // let found
1883
+ // rows.find(d => {
1884
+ // if (d.getIsSelected()) {
1885
+ // found = d
1886
+ // return true
1887
+ // }
1888
+ // const subFound = findSelectedRow(d.subRows || [])
1889
+ // if (subFound) {
1890
+ // found = subFound
1891
+ // return true
1892
+ // }
1893
+ // return false
1894
+ // })
1895
+ // return found
1896
+ // }
1897
+ // const firstRow = findSelectedRow(rows) || rows[0]
1898
+ // const lastRow = rowsById[rowId]
1899
+ // let include = false
1900
+ // const selectedRowIds = {}
1901
+ // const addRow = (row: Row) => {
1902
+ // mutateRowIsSelected(selectedRowIds, row.id, true, {
1903
+ // rowsById,
1904
+ // selectGroupingRows: selectGroupingRows!,
1905
+ // selectSubRows: selectSubRows!,
1906
+ // })
1907
+ // }
1908
+ // instance.rows.forEach(row => {
1909
+ // const isFirstRow = row.id === firstRow.id
1910
+ // const isLastRow = row.id === lastRow.id
1911
+ // if (isFirstRow || isLastRow) {
1912
+ // if (!include) {
1913
+ // include = true
1914
+ // } else if (include) {
1915
+ // addRow(row)
1916
+ // include = false
1917
+ // }
1918
+ // }
1919
+ // if (include) {
1920
+ // addRow(row)
1921
+ // }
1922
+ // })
1923
+ // instance.setRowSelection(selectedRowIds)
1924
+ // },
1925
+ getPreSelectedRowModel: () => instance.getCoreRowModel(),
1926
+ getSelectedRowModel: memo(() => [instance.getState().rowSelection, instance.getCoreRowModel()], (rowSelection, rowModel) => {
1927
+ if (!Object.keys(rowSelection).length) {
1928
+ return {
1929
+ rows: [],
1930
+ flatRows: [],
1931
+ rowsById: {}
1932
+ };
1933
+ }
1934
+
1935
+ return selectRowsFn(instance, rowModel);
1936
+ }, {
1937
+ key: process.env.NODE_ENV === 'development' && 'getSelectedRowModel',
1938
+ debug: () => {
1939
+ var _instance$options$deb;
1940
+
1941
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
1942
+ }
1943
+ }),
1944
+ getFilteredSelectedRowModel: memo(() => [instance.getState().rowSelection, instance.getFilteredRowModel()], (rowSelection, rowModel) => {
1945
+ if (!Object.keys(rowSelection).length) {
1946
+ return {
1947
+ rows: [],
1948
+ flatRows: [],
1949
+ rowsById: {}
1950
+ };
1951
+ }
1952
+
1953
+ return selectRowsFn(instance, rowModel);
1954
+ }, {
1955
+ key: process.env.NODE_ENV === 'production' && 'getFilteredSelectedRowModel',
1956
+ debug: () => {
1957
+ var _instance$options$deb2;
1958
+
1959
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugTable;
1960
+ }
1961
+ }),
1962
+ getGroupedSelectedRowModel: memo(() => [instance.getState().rowSelection, instance.getGroupedRowModel()], (rowSelection, rowModel) => {
1963
+ if (!Object.keys(rowSelection).length) {
1964
+ return {
1965
+ rows: [],
1966
+ flatRows: [],
1967
+ rowsById: {}
1968
+ };
1969
+ }
1970
+
1971
+ return selectRowsFn(instance, rowModel);
1972
+ }, {
1973
+ key: process.env.NODE_ENV === 'production' && 'getGroupedSelectedRowModel',
1974
+ debug: () => {
1975
+ var _instance$options$deb3;
1976
+
1977
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugTable;
1978
+ }
1979
+ }),
1980
+ ///
1981
+ // getGroupingRowCanSelect: rowId => {
1982
+ // const row = instance.getRow(rowId)
1983
+ // if (!row) {
1984
+ // throw new Error()
1985
+ // }
1986
+ // if (typeof instance.options.enableGroupingRowSelection === 'function') {
1987
+ // return instance.options.enableGroupingRowSelection(row)
1988
+ // }
1989
+ // return instance.options.enableGroupingRowSelection ?? false
1990
+ // },
1991
+ getIsAllRowsSelected: () => {
1992
+ const preFilteredFlatRows = instance.getPreFilteredRowModel().flatRows;
1993
+ const {
1994
+ rowSelection
1995
+ } = instance.getState();
1996
+ let isAllRowsSelected = Boolean(preFilteredFlatRows.length && Object.keys(rowSelection).length);
1997
+
1998
+ if (isAllRowsSelected) {
1999
+ if (preFilteredFlatRows.some(row => !rowSelection[row.id])) {
2000
+ isAllRowsSelected = false;
2001
+ }
2002
+ }
2003
+
2004
+ return isAllRowsSelected;
2005
+ },
2006
+ getIsAllPageRowsSelected: () => {
2007
+ const paginationFlatRows = instance.getPaginationRowModel().flatRows;
2008
+ const {
2009
+ rowSelection
2010
+ } = instance.getState();
2011
+ let isAllPageRowsSelected = !!paginationFlatRows.length;
2012
+
2013
+ if (isAllPageRowsSelected && paginationFlatRows.some(row => !rowSelection[row.id])) {
2014
+ isAllPageRowsSelected = false;
2015
+ }
2016
+
2017
+ return isAllPageRowsSelected;
2018
+ },
2019
+ getIsSomeRowsSelected: () => {
2020
+ var _instance$getState$ro;
2021
+
2022
+ return !instance.getIsAllRowsSelected() && !!Object.keys((_instance$getState$ro = instance.getState().rowSelection) != null ? _instance$getState$ro : {}).length;
2023
+ },
2024
+ getIsSomePageRowsSelected: () => {
2025
+ const paginationFlatRows = instance.getPaginationRowModel().flatRows;
2026
+ return instance.getIsAllPageRowsSelected() ? false : !!(paginationFlatRows != null && paginationFlatRows.length);
2027
+ },
2028
+ getToggleAllRowsSelectedHandler: () => {
2029
+ return e => {
2030
+ instance.toggleAllRowsSelected(e.target.checked);
2031
+ };
2032
+ },
2033
+ getToggleAllPageRowsSelectedHandler: () => {
2034
+ return e => {
2035
+ instance.toggleAllPageRowsSelected(e.target.checked);
2036
+ };
2037
+ }
2038
+ };
2039
+ },
2040
+ createRow: (row, instance) => {
2041
+ return {
2042
+ toggleSelected: value => {
2043
+ const isSelected = row.getIsSelected();
2044
+ instance.setRowSelection(old => {
2045
+ value = typeof value !== 'undefined' ? value : !isSelected;
2046
+
2047
+ if (isSelected === value) {
2048
+ return old;
2049
+ }
2050
+
2051
+ const selectedRowIds = { ...old
2052
+ };
2053
+ mutateRowIsSelected(selectedRowIds, row.id, value, instance);
2054
+ return selectedRowIds;
2055
+ });
2056
+ },
2057
+ getIsSelected: () => {
2058
+ const {
2059
+ rowSelection
2060
+ } = instance.getState();
2061
+ return isRowSelected(row, rowSelection) === true;
2062
+ },
2063
+ getIsSomeSelected: () => {
2064
+ const {
2065
+ rowSelection
2066
+ } = instance.getState();
2067
+ return isRowSelected(row, rowSelection) === 'some';
2068
+ },
2069
+ getCanSelect: () => {
2070
+ var _instance$options$ena;
2071
+
2072
+ if (typeof instance.options.enableRowSelection === 'function') {
2073
+ return instance.options.enableRowSelection(row);
2074
+ }
2075
+
2076
+ return (_instance$options$ena = instance.options.enableRowSelection) != null ? _instance$options$ena : true;
2077
+ },
2078
+ getCanSelectSubRows: () => {
2079
+ var _instance$options$ena2;
2080
+
2081
+ if (typeof instance.options.enableSubRowSelection === 'function') {
2082
+ return instance.options.enableSubRowSelection(row);
2083
+ }
2084
+
2085
+ return (_instance$options$ena2 = instance.options.enableSubRowSelection) != null ? _instance$options$ena2 : true;
2086
+ },
2087
+ getCanMultiSelect: () => {
2088
+ var _instance$options$ena3;
2089
+
2090
+ if (typeof instance.options.enableMultiRowSelection === 'function') {
2091
+ return instance.options.enableMultiRowSelection(row);
2092
+ }
2093
+
2094
+ return (_instance$options$ena3 = instance.options.enableMultiRowSelection) != null ? _instance$options$ena3 : true;
2095
+ },
2096
+ getToggleSelectedHandler: () => {
2097
+ const canSelect = row.getCanSelect();
2098
+ return e => {
2099
+ var _target;
2100
+
2101
+ if (!canSelect) return;
2102
+ row.toggleSelected((_target = e.target) == null ? void 0 : _target.checked);
2103
+ };
2104
+ }
2105
+ };
2106
+ }
2107
+ };
2108
+
2109
+ const mutateRowIsSelected = (selectedRowIds, id, value, instance) => {
2110
+ var _row$subRows;
2111
+
2112
+ const row = instance.getRow(id);
2113
+ row.getIsGrouped(); // if ( // TODO: enforce grouping row selection rules
2114
+ // !isGrouped ||
2115
+ // (isGrouped && instance.options.enableGroupingRowSelection)
2116
+ // ) {
2117
+
2118
+ if (value) {
2119
+ selectedRowIds[id] = true;
2120
+ } else {
2121
+ delete selectedRowIds[id];
2122
+ } // }
2123
+
2124
+
2125
+ if ((_row$subRows = row.subRows) != null && _row$subRows.length && row.getCanSelectSubRows()) {
2126
+ row.subRows.forEach(row => mutateRowIsSelected(selectedRowIds, row.id, value, instance));
2127
+ }
2128
+ };
2129
+
2130
+ function selectRowsFn(instance, rowModel) {
2131
+ const rowSelection = instance.getState().rowSelection;
2132
+ const newSelectedFlatRows = [];
2133
+ const newSelectedRowsById = {}; // Filters top level and nested rows
2134
+
2135
+ const recurseRows = function (rows, depth) {
2136
+ if (depth === void 0) {
2137
+ depth = 0;
2138
+ }
2139
+
2140
+ return rows.map(row => {
2141
+ var _row$subRows2;
2142
+
2143
+ const isSelected = isRowSelected(row, rowSelection) === true;
2144
+
2145
+ if (isSelected) {
2146
+ newSelectedFlatRows.push(row);
2147
+ newSelectedRowsById[row.id] = row;
2148
+ }
2149
+
2150
+ if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
2151
+ row = { ...row,
2152
+ subRows: recurseRows(row.subRows, depth + 1)
2153
+ };
2154
+ }
2155
+
2156
+ if (isSelected) {
2157
+ return row;
2158
+ }
2159
+ }).filter(Boolean);
2160
+ };
2161
+
2162
+ return {
2163
+ rows: recurseRows(rowModel.rows),
2164
+ flatRows: newSelectedFlatRows,
2165
+ rowsById: newSelectedRowsById
2166
+ };
2167
+ }
2168
+ function isRowSelected(row, selection, instance) {
2169
+ if (selection[row.id]) {
2170
+ return true;
2171
+ }
2172
+
2173
+ if (row.subRows && row.subRows.length) {
2174
+ let allChildrenSelected = true;
2175
+ let someSelected = false;
2176
+ row.subRows.forEach(subRow => {
2177
+ // Bail out early if we know both of these
2178
+ if (someSelected && !allChildrenSelected) {
2179
+ return;
2180
+ }
2181
+
2182
+ if (isRowSelected(subRow, selection)) {
2183
+ someSelected = true;
2184
+ } else {
2185
+ allChildrenSelected = false;
2186
+ }
2187
+ });
2188
+ return allChildrenSelected ? true : someSelected ? 'some' : false;
2189
+ }
2190
+
2191
+ return false;
2192
+ }
2193
+
2194
+ const reSplitAlphaNumeric = /([0-9]+)/gm;
2195
+ const sortingFns = {
2196
+ alphanumeric,
2197
+ alphanumericCaseSensitive,
2198
+ text,
2199
+ textCaseSensitive,
2200
+ datetime,
2201
+ basic
2202
+ };
2203
+
2204
+ function alphanumeric(rowA, rowB, columnId) {
2205
+ return compareAlphanumeric(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
2206
+ }
2207
+
2208
+ function alphanumericCaseSensitive(rowA, rowB, columnId) {
2209
+ return compareAlphanumeric(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
2210
+ } // Mixed sorting is slow, but very inclusive of many edge cases.
2211
+ // It handles numbers, mixed alphanumeric combinations, and even
2212
+ // null, undefined, and Infinity
2213
+
2214
+
2215
+ function compareAlphanumeric(aStr, bStr) {
2216
+ // Split on number groups, but keep the delimiter
2217
+ // Then remove falsey split values
2218
+ const a = aStr.split(reSplitAlphaNumeric).filter(Boolean);
2219
+ const b = bStr.split(reSplitAlphaNumeric).filter(Boolean); // While
2220
+
2221
+ while (a.length && b.length) {
2222
+ const aa = a.shift();
2223
+ const bb = b.shift();
2224
+ const an = parseInt(aa, 10);
2225
+ const bn = parseInt(bb, 10);
2226
+ const combo = [an, bn].sort(); // Both are string
2227
+
2228
+ if (isNaN(combo[0])) {
2229
+ if (aa > bb) {
2230
+ return 1;
2231
+ }
2232
+
2233
+ if (bb > aa) {
2234
+ return -1;
2235
+ }
2236
+
2237
+ continue;
2238
+ } // One is a string, one is a number
2239
+
2240
+
2241
+ if (isNaN(combo[1])) {
2242
+ return isNaN(an) ? -1 : 1;
2243
+ } // Both are numbers
2244
+
2245
+
2246
+ if (an > bn) {
2247
+ return 1;
2248
+ }
2249
+
2250
+ if (bn > an) {
2251
+ return -1;
2252
+ }
2253
+ }
2254
+
2255
+ return a.length - b.length;
2256
+ } // The text filter is more basic (less numeric support)
2257
+ // but is much faster
2258
+
2259
+
2260
+ function text(rowA, rowB, columnId) {
2261
+ return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
2262
+ } // The text filter is more basic (less numeric support)
2263
+ // but is much faster
2264
+
2265
+
2266
+ function textCaseSensitive(rowA, rowB, columnId) {
2267
+ return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
2268
+ }
2269
+
2270
+ function datetime(rowA, rowB, columnId) {
2271
+ return compareBasic(rowA.getValue(columnId).getTime(), rowB.getValue(columnId).getTime());
2272
+ }
2273
+
2274
+ function basic(rowA, rowB, columnId) {
2275
+ return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
2276
+ } // Utils
2277
+
2278
+
2279
+ function compareBasic(a, b) {
2280
+ return a === b ? 0 : a > b ? 1 : -1;
2281
+ }
2282
+
2283
+ function toString(a) {
2284
+ if (typeof a === 'number') {
2285
+ if (isNaN(a) || a === Infinity || a === -Infinity) {
2286
+ return '';
2287
+ }
2288
+
2289
+ return String(a);
2290
+ }
2291
+
2292
+ if (typeof a === 'string') {
2293
+ return a;
2294
+ }
2295
+
2296
+ return '';
2297
+ }
2298
+
2299
+ //
2300
+ const Sorting = {
2301
+ getInitialState: state => {
2302
+ return {
2303
+ sorting: [],
2304
+ ...state
2305
+ };
2306
+ },
2307
+ getDefaultColumn: () => {
2308
+ return {
2309
+ sortingFn: 'auto'
2310
+ };
2311
+ },
2312
+ getDefaultOptions: instance => {
2313
+ return {
2314
+ onSortingChange: makeStateUpdater('sorting', instance),
2315
+ isMultiSortEvent: e => {
2316
+ return e.shiftKey;
2317
+ }
2318
+ };
2319
+ },
2320
+ createColumn: (column, instance) => {
2321
+ return {
2322
+ getAutoSortingFn: () => {
2323
+ const firstRows = instance.getFilteredRowModel().flatRows.slice(100);
2324
+ let isString = false;
2325
+
2326
+ for (const row of firstRows) {
2327
+ const value = row == null ? void 0 : row.getValue(column.id);
2328
+
2329
+ if (Object.prototype.toString.call(value) === '[object Date]') {
2330
+ return sortingFns.datetime;
2331
+ }
2332
+
2333
+ if (typeof value === 'string') {
2334
+ isString = true;
2335
+
2336
+ if (value.split(reSplitAlphaNumeric).length > 1) {
2337
+ return sortingFns.alphanumeric;
2338
+ }
2339
+ }
2340
+ }
2341
+
2342
+ if (isString) {
2343
+ return sortingFns.text;
2344
+ }
2345
+
2346
+ return sortingFns.basic;
2347
+ },
2348
+ getAutoSortDir: () => {
2349
+ const firstRow = instance.getFilteredRowModel().flatRows[0];
2350
+ const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
2351
+
2352
+ if (typeof value === 'string') {
2353
+ return 'asc';
2354
+ }
2355
+
2356
+ return 'desc';
2357
+ },
2358
+ getSortingFn: () => {
2359
+ var _ref;
2360
+
2361
+ const userSortingFn = instance.options.sortingFns;
2362
+
2363
+ if (!column) {
2364
+ throw new Error();
2365
+ }
2366
+
2367
+ return isFunction(column.sortingFn) ? column.sortingFn : column.sortingFn === 'auto' ? column.getAutoSortingFn() : (_ref = userSortingFn == null ? void 0 : userSortingFn[column.sortingFn]) != null ? _ref : sortingFns[column.sortingFn];
2368
+ },
2369
+ toggleSorting: (desc, multi) => {
2370
+ // if (column.columns.length) {
2371
+ // column.columns.forEach((c, i) => {
2372
+ // if (c.id) {
2373
+ // instance.toggleColumnSorting(c.id, undefined, multi || !!i)
2374
+ // }
2375
+ // })
2376
+ // return
2377
+ // }
2378
+ instance.setSorting(old => {
2379
+ var _ref2, _column$sortDescFirst, _instance$options$ena, _instance$options$ena2;
2380
+
2381
+ // Find any existing sorting for this column
2382
+ const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
2383
+ const existingIndex = old == null ? void 0 : old.findIndex(d => d.id === column.id);
2384
+ const hasDescDefined = typeof desc !== 'undefined' && desc !== null;
2385
+ let newSorting = []; // What should we do with this sort action?
2386
+
2387
+ let sortAction;
2388
+
2389
+ if (column.getCanMultiSort() && multi) {
2390
+ if (existingSorting) {
2391
+ sortAction = 'toggle';
2392
+ } else {
2393
+ sortAction = 'add';
2394
+ }
2395
+ } else {
2396
+ // Normal mode
2397
+ if (old != null && old.length && existingIndex !== old.length - 1) {
2398
+ sortAction = 'replace';
2399
+ } else if (existingSorting) {
2400
+ sortAction = 'toggle';
2401
+ } else {
2402
+ sortAction = 'replace';
2403
+ }
2404
+ }
2405
+
2406
+ const sortDescFirst = (_ref2 = (_column$sortDescFirst = column.sortDescFirst) != null ? _column$sortDescFirst : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc'; // Handle toggle states that will remove the sorting
2407
+
2408
+ if (sortAction === 'toggle' && ( // Must be toggling
2409
+ (_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
2410
+ !hasDescDefined && ( // Must not be setting desc
2411
+ multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && ( // If multi, don't allow if enableMultiRemove
2412
+ existingSorting != null && existingSorting.desc // Finally, detect if it should indeed be removed
2413
+ ? !sortDescFirst : sortDescFirst)) {
2414
+ sortAction = 'remove';
2415
+ }
2416
+
2417
+ if (sortAction === 'replace') {
2418
+ newSorting = [{
2419
+ id: column.id,
2420
+ desc: hasDescDefined ? desc : !!sortDescFirst
2421
+ }];
2422
+ } else if (sortAction === 'add' && old != null && old.length) {
2423
+ var _instance$options$max;
2424
+
2425
+ newSorting = [...old, {
2426
+ id: column.id,
2427
+ desc: hasDescDefined ? desc : !!sortDescFirst
2428
+ }]; // Take latest n columns
2429
+
2430
+ newSorting.splice(0, newSorting.length - ((_instance$options$max = instance.options.maxMultiSortColCount) != null ? _instance$options$max : Number.MAX_SAFE_INTEGER));
2431
+ } else if (sortAction === 'toggle' && old != null && old.length) {
2432
+ // This flips (or sets) the
2433
+ newSorting = old.map(d => {
2434
+ if (d.id === column.id) {
2435
+ return { ...d,
2436
+ desc: hasDescDefined ? desc : !(existingSorting != null && existingSorting.desc)
2437
+ };
2438
+ }
2439
+
2440
+ return d;
2441
+ });
2442
+ } else if (sortAction === 'remove' && old != null && old.length) {
2443
+ newSorting = old.filter(d => d.id !== column.id);
2444
+ }
2445
+
2446
+ return newSorting;
2447
+ });
2448
+ },
2449
+ getCanSort: () => {
2450
+ var _column$enableSorting, _instance$options$ena3;
2451
+
2452
+ return ((_column$enableSorting = column.enableSorting) != null ? _column$enableSorting : true) && ((_instance$options$ena3 = instance.options.enableSorting) != null ? _instance$options$ena3 : true) && !!column.accessorFn;
2453
+ },
2454
+ getCanMultiSort: () => {
2455
+ var _ref3, _column$enableMultiSo;
2456
+
2457
+ return (_ref3 = (_column$enableMultiSo = column.enableMultiSort) != null ? _column$enableMultiSo : instance.options.enableMultiSort) != null ? _ref3 : !!column.accessorFn;
2458
+ },
2459
+ getIsSorted: () => {
2460
+ var _instance$getState$so;
2461
+
2462
+ const columnSort = (_instance$getState$so = instance.getState().sorting) == null ? void 0 : _instance$getState$so.find(d => d.id === column.id);
2463
+ return !columnSort ? false : columnSort.desc ? 'desc' : 'asc';
2464
+ },
2465
+ getSortIndex: () => {
2466
+ var _instance$getState$so2, _instance$getState$so3;
2467
+
2468
+ return (_instance$getState$so2 = (_instance$getState$so3 = instance.getState().sorting) == null ? void 0 : _instance$getState$so3.findIndex(d => d.id === column.id)) != null ? _instance$getState$so2 : -1;
2469
+ },
2470
+ clearSorting: () => {
2471
+ //clear sorting for just 1 column
2472
+ instance.setSorting(old => old != null && old.length ? old.filter(d => d.id !== column.id) : []);
2473
+ },
2474
+ getToggleSortingHandler: () => {
2475
+ const canSort = column.getCanSort();
2476
+ return e => {
2477
+ if (!canSort) return;
2478
+ e.persist == null ? void 0 : e.persist();
2479
+ column.toggleSorting == null ? void 0 : column.toggleSorting(undefined, column.getCanMultiSort() ? instance.options.isMultiSortEvent == null ? void 0 : instance.options.isMultiSortEvent(e) : false);
2480
+ };
2481
+ }
2482
+ };
2483
+ },
2484
+ createInstance: instance => {
2485
+ return {
2486
+ setSorting: updater => instance.options.onSortingChange == null ? void 0 : instance.options.onSortingChange(updater),
2487
+ resetSorting: defaultState => {
2488
+ var _instance$initialStat, _instance$initialStat2;
2489
+
2490
+ instance.setSorting(defaultState ? [] : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.sorting) != null ? _instance$initialStat : []);
2491
+ },
2492
+ getPreSortedRowModel: () => instance.getFilteredRowModel(),
2493
+ getSortedRowModel: () => {
2494
+ if (!instance._getSortedRowModel && instance.options.getSortedRowModel) {
2495
+ instance._getSortedRowModel = instance.options.getSortedRowModel(instance);
2496
+ }
2497
+
2498
+ if (instance.options.manualSorting || !instance._getSortedRowModel) {
2499
+ return instance.getPreSortedRowModel();
2500
+ }
2501
+
2502
+ return instance._getSortedRowModel();
2503
+ }
2504
+ };
2505
+ }
2506
+ };
2507
+
2508
+ //
2509
+ const Visibility = {
2510
+ getInitialState: state => {
2511
+ return {
2512
+ columnVisibility: {},
2513
+ ...state
2514
+ };
2515
+ },
2516
+ getDefaultOptions: instance => {
2517
+ return {
2518
+ onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
2519
+ };
2520
+ },
2521
+ getDefaultColumn: () => {
2522
+ return {
2523
+ defaultIsVisible: true
2524
+ };
2525
+ },
2526
+ createColumn: (column, instance) => {
2527
+ return {
2528
+ toggleVisibility: value => {
2529
+ if (column.getCanHide()) {
2530
+ instance.setColumnVisibility(old => ({ ...old,
2531
+ [column.id]: value != null ? value : !column.getIsVisible()
2532
+ }));
2533
+ }
2534
+ },
2535
+ getIsVisible: () => {
2536
+ var _instance$getState$co, _instance$getState$co2;
2537
+
2538
+ return (_instance$getState$co = (_instance$getState$co2 = instance.getState().columnVisibility) == null ? void 0 : _instance$getState$co2[column.id]) != null ? _instance$getState$co : true;
2539
+ },
2540
+ getCanHide: () => {
2541
+ var _column$enableHiding, _instance$options$ena;
2542
+
2543
+ return ((_column$enableHiding = column.enableHiding) != null ? _column$enableHiding : true) && ((_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : true);
2544
+ },
2545
+ getToggleVisibilityHandler: () => {
2546
+ return e => {
2547
+ column.toggleVisibility == null ? void 0 : column.toggleVisibility(e.target.checked);
2548
+ };
2549
+ }
2550
+ };
2551
+ },
2552
+ createRow: (row, instance) => {
2553
+ return {
2554
+ _getAllVisibleCells: memo(() => [row.getAllCells().filter(cell => cell.column.getIsVisible()).map(d => d.id).join('_')], _ => {
2555
+ return row.getAllCells().filter(cell => cell.column.getIsVisible());
2556
+ }, {
2557
+ key: process.env.NODE_ENV === 'production' && 'row._getAllVisibleCells',
2558
+ debug: () => {
2559
+ var _instance$options$deb;
2560
+
2561
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
2562
+ }
2563
+ }),
2564
+ getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
2565
+ key: process.env.NODE_ENV === 'development' && 'row.getVisibleCells',
2566
+ debug: () => {
2567
+ var _instance$options$deb2;
2568
+
2569
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
2570
+ }
2571
+ })
2572
+ };
2573
+ },
2574
+ createInstance: instance => {
2575
+ const makeVisibleColumnsMethod = (key, getColumns) => {
2576
+ return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
2577
+ return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
2578
+ }, {
2579
+ key,
2580
+ debug: () => {
2581
+ var _instance$options$deb3;
2582
+
2583
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2584
+ }
2585
+ });
2586
+ };
2587
+
2588
+ return {
2589
+ getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
2590
+ getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
2591
+ getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
2592
+ getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
2593
+ getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
2594
+ setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
2595
+ resetColumnVisibility: defaultState => {
2596
+ var _instance$initialStat;
2597
+
2598
+ instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
2599
+ },
2600
+ toggleAllColumnsVisible: value => {
2601
+ var _value;
2602
+
2603
+ value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
2604
+ instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
2605
+ [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
2606
+ }), {}));
2607
+ },
2608
+ getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
2609
+ getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
2610
+ getToggleAllColumnsVisibilityHandler: () => {
2611
+ return e => {
2612
+ var _target;
2613
+
2614
+ instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
2615
+ };
2616
+ }
2617
+ };
2618
+ }
2619
+ };
2620
+
2621
+ //
2622
+ const Headers = {
2623
+ createInstance: instance => {
2624
+ return {
2625
+ createHeader: (column, options) => {
2626
+ var _options$id;
2627
+
2628
+ const id = (_options$id = options.id) != null ? _options$id : column.id;
2629
+ let header = {
2630
+ id,
2631
+ column,
2632
+ index: options.index,
2633
+ isPlaceholder: options.isPlaceholder,
2634
+ placeholderId: options.placeholderId,
2635
+ depth: options.depth,
2636
+ subHeaders: [],
2637
+ colSpan: 0,
2638
+ rowSpan: 0,
2639
+ headerGroup: null,
2640
+ getLeafHeaders: () => {
2641
+ const leafHeaders = [];
2642
+
2643
+ const recurseHeader = h => {
2644
+ if (h.subHeaders && h.subHeaders.length) {
2645
+ h.subHeaders.map(recurseHeader);
2646
+ }
2647
+
2648
+ leafHeaders.push(h);
2649
+ };
2650
+
2651
+ recurseHeader(header);
2652
+ return leafHeaders;
2653
+ },
2654
+ renderHeader: () => column.header ? instance.render(column.header, {
2655
+ instance,
2656
+ header: header,
2657
+ column
2658
+ }) : null,
2659
+ renderFooter: () => column.footer ? instance.render(column.footer, {
2660
+ instance,
2661
+ header: header,
2662
+ column
2663
+ }) : null
2664
+ };
2665
+
2666
+ instance._features.forEach(feature => {
2667
+ Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
2668
+ });
2669
+
2670
+ return header;
2671
+ },
2672
+ // Header Groups
2673
+ getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2674
+ const leftColumns = leafColumns.filter(column => left == null ? void 0 : left.includes(column.id));
2675
+ const rightColumns = leafColumns.filter(column => right == null ? void 0 : right.includes(column.id));
2676
+ const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2677
+ const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
2678
+ return headerGroups;
2679
+ }, {
2680
+ key: process.env.NODE_ENV === 'development' && 'getHeaderGroups',
2681
+ debug: () => {
2682
+ var _instance$options$deb;
2683
+
2684
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
2685
+ }
2686
+ }),
2687
+ getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2688
+ leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2689
+ return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
2690
+ }, {
2691
+ key: process.env.NODE_ENV === 'development' && 'getCenterHeaderGroups',
2692
+ debug: () => {
2693
+ var _instance$options$deb2;
2694
+
2695
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
2696
+ }
2697
+ }),
2698
+ getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
2699
+ leafColumns = leafColumns.filter(column => left == null ? void 0 : left.includes(column.id));
2700
+ return buildHeaderGroups(allColumns, leafColumns, instance, 'left');
2701
+ }, {
2702
+ key: process.env.NODE_ENV === 'development' && 'getLeftHeaderGroups',
2703
+ debug: () => {
2704
+ var _instance$options$deb3;
2705
+
2706
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
2707
+ }
2708
+ }),
2709
+ getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
2710
+ leafColumns = leafColumns.filter(column => right == null ? void 0 : right.includes(column.id));
2711
+ return buildHeaderGroups(allColumns, leafColumns, instance, 'right');
2712
+ }, {
2713
+ key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
2714
+ debug: () => {
2715
+ var _instance$options$deb4;
2716
+
2717
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
2718
+ }
2719
+ }),
2720
+ // Footer Groups
2721
+ getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
2722
+ return [...headerGroups].reverse();
2723
+ }, {
2724
+ key: process.env.NODE_ENV === 'development' && 'getFooterGroups',
2725
+ debug: () => {
2726
+ var _instance$options$deb5;
2727
+
2728
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
2729
+ }
2730
+ }),
2731
+ getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
2732
+ return [...headerGroups].reverse();
2733
+ }, {
2734
+ key: process.env.NODE_ENV === 'development' && 'getLeftFooterGroups',
2735
+ debug: () => {
2736
+ var _instance$options$deb6;
2737
+
2738
+ return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
2739
+ }
2740
+ }),
2741
+ getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
2742
+ return [...headerGroups].reverse();
2743
+ }, {
2744
+ key: process.env.NODE_ENV === 'development' && 'getCenterFooterGroups',
2745
+ debug: () => {
2746
+ var _instance$options$deb7;
2747
+
2748
+ return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
2749
+ }
2750
+ }),
2751
+ getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
2752
+ return [...headerGroups].reverse();
2753
+ }, {
2754
+ key: process.env.NODE_ENV === 'development' && 'getRightFooterGroups',
2755
+ debug: () => {
2756
+ var _instance$options$deb8;
2757
+
2758
+ return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
2759
+ }
2760
+ }),
2761
+ // Flat Headers
2762
+ getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
2763
+ return headerGroups.map(headerGroup => {
2764
+ return headerGroup.headers;
2765
+ }).flat();
2766
+ }, {
2767
+ key: process.env.NODE_ENV === 'development' && 'getFlatHeaders',
2768
+ debug: () => {
2769
+ var _instance$options$deb9;
2770
+
2771
+ return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
2772
+ }
2773
+ }),
2774
+ getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
2775
+ return left.map(headerGroup => {
2776
+ return headerGroup.headers;
2777
+ }).flat();
2778
+ }, {
2779
+ key: process.env.NODE_ENV === 'development' && 'getLeftFlatHeaders',
2780
+ debug: () => {
2781
+ var _instance$options$deb10;
2782
+
2783
+ return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
2784
+ }
2785
+ }),
2786
+ getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
2787
+ return left.map(headerGroup => {
2788
+ return headerGroup.headers;
2789
+ }).flat();
2790
+ }, {
2791
+ key: process.env.NODE_ENV === 'development' && 'getCenterFlatHeaders',
2792
+ debug: () => {
2793
+ var _instance$options$deb11;
2794
+
2795
+ return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
2796
+ }
2797
+ }),
2798
+ getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
2799
+ return left.map(headerGroup => {
2800
+ return headerGroup.headers;
2801
+ }).flat();
2802
+ }, {
2803
+ key: process.env.NODE_ENV === 'development' && 'getRightFlatHeaders',
2804
+ debug: () => {
2805
+ var _instance$options$deb12;
2806
+
2807
+ return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
2808
+ }
2809
+ }),
2810
+ // Leaf Headers
2811
+ getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
2812
+ return flatHeaders.filter(header => {
2813
+ var _header$subHeaders;
2814
+
2815
+ return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
2816
+ });
2817
+ }, {
2818
+ key: process.env.NODE_ENV === 'development' && 'getCenterLeafHeaders',
2819
+ debug: () => {
2820
+ var _instance$options$deb13;
2821
+
2822
+ return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
2823
+ }
2824
+ }),
2825
+ getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
2826
+ return flatHeaders.filter(header => {
2827
+ var _header$subHeaders2;
2828
+
2829
+ return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
2830
+ });
2831
+ }, {
2832
+ key: process.env.NODE_ENV === 'development' && 'getLeftLeafHeaders',
2833
+ debug: () => {
2834
+ var _instance$options$deb14;
2835
+
2836
+ return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
2837
+ }
2838
+ }),
2839
+ getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
2840
+ return flatHeaders.filter(header => {
2841
+ var _header$subHeaders3;
2842
+
2843
+ return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
2844
+ });
2845
+ }, {
2846
+ key: process.env.NODE_ENV === 'development' && 'getRightLeafHeaders',
2847
+ debug: () => {
2848
+ var _instance$options$deb15;
2849
+
2850
+ return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
2851
+ }
2852
+ }),
2853
+ getLeafHeaders: memo(() => [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()], (left, center, right) => {
2854
+ var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
2855
+
2856
+ return [...((_left$0$headers = (_left$ = left[0]) == null ? void 0 : _left$.headers) != null ? _left$0$headers : []), ...((_center$0$headers = (_center$ = center[0]) == null ? void 0 : _center$.headers) != null ? _center$0$headers : []), ...((_right$0$headers = (_right$ = right[0]) == null ? void 0 : _right$.headers) != null ? _right$0$headers : [])].map(header => {
2857
+ return header.getLeafHeaders();
2858
+ }).flat();
2859
+ }, {
2860
+ key: process.env.NODE_ENV === 'development' && 'getLeafHeaders',
2861
+ debug: () => {
2862
+ var _instance$options$deb16;
2863
+
2864
+ return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
2865
+ }
2866
+ }),
2867
+ getHeader: id => {
2868
+ const header = [...instance.getFlatHeaders(), ...instance.getCenterFlatHeaders(), ...instance.getLeftFlatHeaders(), ...instance.getRightFlatHeaders()].find(d => d.id === id);
2869
+
2870
+ if (!header) {
2871
+ if (process.env.NODE_ENV !== 'production') {
2872
+ console.warn("Could not find header with id: " + id);
2873
+ }
2874
+
2875
+ throw new Error();
2876
+ }
2877
+
2878
+ return header;
2879
+ }
2880
+ };
2881
+ }
2882
+ };
2883
+ function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
2884
+ var _headerGroups$0$heade, _headerGroups$;
2885
+
2886
+ // Find the max depth of the columns:
2887
+ // build the leaf column row
2888
+ // build each buffer row going up
2889
+ // placeholder for non-existent level
2890
+ // real column for existing level
2891
+ let maxDepth = 0;
2892
+
2893
+ const findMaxDepth = function (columns, depth) {
2894
+ if (depth === void 0) {
2895
+ depth = 1;
2896
+ }
2897
+
2898
+ maxDepth = Math.max(maxDepth, depth);
2899
+ columns.filter(column => column.getIsVisible()).forEach(column => {
2900
+ var _column$columns;
2901
+
2902
+ if ((_column$columns = column.columns) != null && _column$columns.length) {
2903
+ findMaxDepth(column.columns, depth + 1);
2904
+ }
2905
+ }, 0);
2906
+ };
2907
+
2908
+ findMaxDepth(allColumns);
2909
+ let headerGroups = [];
2910
+
2911
+ const createHeaderGroup = (headersToGroup, depth) => {
2912
+ // The header group we are creating
2913
+ const headerGroup = {
2914
+ depth,
2915
+ id: [headerFamily, "" + depth].filter(Boolean).join('_'),
2916
+ headers: []
2917
+ }; // The parent columns we're going to scan next
2918
+
2919
+ const pendingParentHeaders = []; // Scan each column for parents
2920
+
2921
+ headersToGroup.forEach(headerToGroup => {
2922
+ // What is the latest (last) parent column?
2923
+ const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
2924
+ const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
2925
+ let column;
2926
+ let isPlaceholder = false;
2927
+
2928
+ if (isLeafHeader && headerToGroup.column.parent) {
2929
+ // The parent header is new
2930
+ column = headerToGroup.column.parent;
2931
+ } else {
2932
+ // The parent header is repeated
2933
+ column = headerToGroup.column;
2934
+ isPlaceholder = true;
2935
+ }
2936
+
2937
+ if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
2938
+ // This column is repeated. Add it as a sub header to the next batch
2939
+ latestPendingParentHeader.subHeaders.push(headerToGroup);
2940
+ } else {
2941
+ // This is a new header. Let's create it
2942
+ const header = instance.createHeader(column, {
2943
+ id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
2944
+ isPlaceholder,
2945
+ placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
2946
+ depth,
2947
+ index: pendingParentHeaders.length
2948
+ }); // Add the headerToGroup as a subHeader of the new header
2949
+
2950
+ header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
2951
+ // in the next batch
2952
+
2953
+ pendingParentHeaders.push(header);
2954
+ }
2955
+
2956
+ headerGroup.headers.push(headerToGroup);
2957
+ headerToGroup.headerGroup = headerGroup;
2958
+ });
2959
+ headerGroups.push(headerGroup);
2960
+
2961
+ if (depth > 0) {
2962
+ createHeaderGroup(pendingParentHeaders, depth - 1);
2963
+ }
2964
+ };
2965
+
2966
+ const bottomHeaders = columnsToGroup.map((column, index) => instance.createHeader(column, {
2967
+ depth: maxDepth,
2968
+ index
2969
+ }));
2970
+ createHeaderGroup(bottomHeaders, maxDepth - 1);
2971
+ headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
2972
+ // return !headerGroup.headers.every(header => header.isPlaceholder)
2973
+ // })
2974
+
2975
+ const recurseHeadersForSpans = headers => {
2976
+ const filteredHeaders = headers.filter(header => header.column.getIsVisible());
2977
+ return filteredHeaders.map(header => {
2978
+ let colSpan = 0;
2979
+ let rowSpan = 0;
2980
+ let childRowSpans = [0];
2981
+
2982
+ if (header.subHeaders && header.subHeaders.length) {
2983
+ childRowSpans = [];
2984
+ recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
2985
+ let {
2986
+ colSpan: childColSpan,
2987
+ rowSpan: childRowSpan
2988
+ } = _ref;
2989
+ colSpan += childColSpan;
2990
+ childRowSpans.push(childRowSpan);
2991
+ });
2992
+ } else {
2993
+ colSpan = 1;
2994
+ }
2995
+
2996
+ const minChildRowSpan = Math.min(...childRowSpans);
2997
+ rowSpan = rowSpan + minChildRowSpan;
2998
+ header.colSpan = colSpan > 0 ? colSpan : undefined;
2999
+ header.rowSpan = rowSpan > 0 ? rowSpan : undefined;
3000
+ return {
3001
+ colSpan,
3002
+ rowSpan
3003
+ };
3004
+ });
3005
+ };
3006
+
3007
+ recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
3008
+ return headerGroups;
3009
+ }
3010
+
3011
+ // export type Batch = {
3012
+ // id: number
3013
+ // priority: keyof CoreBatches
3014
+ // tasks: (() => void)[]
3015
+ // schedule: (cb: () => void) => void
3016
+ // cancel: () => void
3017
+ // }
3018
+ // type CoreBatches = {
3019
+ // data: Batch[]
3020
+ // facets: Batch[]
3021
+ // }
3022
+ // export type TaskPriority = keyof CoreBatches
3023
+ function createTableInstance(options) {
3024
+ var _options$initialState;
3025
+
3026
+ if (options.debugAll || options.debugTable) {
3027
+ console.info('Creating Table Instance...');
3028
+ }
19
3029
 
20
- for (var key in source) {
21
- if (Object.prototype.hasOwnProperty.call(source, key)) {
22
- target[key] = source[key];
3030
+ let instance = {
3031
+ _features: [Columns, Rows, Cells, Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]
3032
+ };
3033
+
3034
+ const defaultOptions = instance._features.reduce((obj, feature) => {
3035
+ return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(instance));
3036
+ }, {});
3037
+
3038
+ const mergeOptions = options => {
3039
+ if (instance.options.mergeOptions) {
3040
+ return instance.options.mergeOptions(defaultOptions, options);
3041
+ }
3042
+
3043
+ return { ...defaultOptions,
3044
+ ...options
3045
+ };
3046
+ };
3047
+
3048
+ const coreInitialState = {// coreProgress: 1,
3049
+ };
3050
+ let initialState = { ...coreInitialState,
3051
+ ...((_options$initialState = options.initialState) != null ? _options$initialState : {})
3052
+ };
3053
+
3054
+ instance._features.forEach(feature => {
3055
+ var _feature$getInitialSt;
3056
+
3057
+ initialState = (_feature$getInitialSt = feature.getInitialState == null ? void 0 : feature.getInitialState(initialState)) != null ? _feature$getInitialSt : initialState;
3058
+ });
3059
+
3060
+ const queued = [];
3061
+ let queuedTimeout = false; // let workScheduled = false
3062
+ // let working = false
3063
+ // let latestCallback: ReturnType<typeof requestIdleCallback>
3064
+ // let batchUid = 0
3065
+ // const onProgress = () => {}
3066
+ // const getBatch = () => {
3067
+ // instance.batches.data = instance.batches.data.filter(d => d.tasks.length)
3068
+ // instance.batches.facets = instance.batches.facets.filter(
3069
+ // d => d.tasks.length
3070
+ // )
3071
+ // return (
3072
+ // instance.batches.data.find(d => d.tasks.length) ??
3073
+ // instance.batches.facets.find(d => d.tasks.length)
3074
+ // )
3075
+ // }
3076
+ // const startWorkLoop = () => {
3077
+ // working = true
3078
+ // const workLoop = (deadline: IdleDeadline) => {
3079
+ // const batch = getBatch()
3080
+ // if (!batch) {
3081
+ // working = false
3082
+ // return
3083
+ // }
3084
+ // // Prioritize tasks
3085
+ // while (deadline.timeRemaining() > 0 && batch.tasks.length) {
3086
+ // batch.tasks.shift()!()
3087
+ // }
3088
+ // onProgress()
3089
+ // if (working) {
3090
+ // latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
3091
+ // }
3092
+ // }
3093
+ // latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
3094
+ // }
3095
+ // const startWork = () => {
3096
+ // if (getBatch() && !working) {
3097
+ // if (
3098
+ // (process.env.NODE_ENV === 'development' && instance.options.debugAll) ??
3099
+ // instance.options.debugTable
3100
+ // ) {
3101
+ // console.info('Starting work...')
3102
+ // }
3103
+ // startWorkLoop()
3104
+ // }
3105
+ // }
3106
+ // const stopWork = () => {
3107
+ // if (working) {
3108
+ // if (
3109
+ // (process.env.NODE_ENV === 'development' && instance.options.debugAll) ??
3110
+ // instance.options.debugTable
3111
+ // ) {
3112
+ // console.info('Stopping work...')
3113
+ // }
3114
+ // working = false
3115
+ // cancelIdleCallback(latestCallback)
3116
+ // }
3117
+ // }
3118
+
3119
+ const midInstance = { ...instance,
3120
+ // init: () => {
3121
+ // startWork()
3122
+ // },
3123
+ // willUpdate: () => {
3124
+ // startWork()
3125
+ // },
3126
+ // destroy: () => {
3127
+ // stopWork()
3128
+ // },
3129
+ options: { ...defaultOptions,
3130
+ ...options
3131
+ },
3132
+ initialState,
3133
+ queue: cb => {
3134
+ queued.push(cb);
3135
+
3136
+ if (!queuedTimeout) {
3137
+ queuedTimeout = true; // Schedule a microtask to run the queued callbacks after
3138
+ // the current call stack (render, etc) has finished.
3139
+
3140
+ Promise.resolve().then(() => {
3141
+ while (queued.length) {
3142
+ queued.shift()();
3143
+ }
3144
+
3145
+ queuedTimeout = false;
3146
+ }).catch(error => setTimeout(() => {
3147
+ throw error;
3148
+ }));
3149
+ }
3150
+ },
3151
+ // batches: {
3152
+ // data: [],
3153
+ // facets: [],
3154
+ // },
3155
+ // createBatch: priority => {
3156
+ // const batchId = batchUid++
3157
+ // let canceled: boolean
3158
+ // const batch: Batch = {
3159
+ // id: batchId,
3160
+ // priority,
3161
+ // tasks: [],
3162
+ // schedule: cb => {
3163
+ // if (canceled) return
3164
+ // batch.tasks.push(cb)
3165
+ // if (!working && !workScheduled) {
3166
+ // workScheduled = true
3167
+ // instance.queue(() => {
3168
+ // workScheduled = false
3169
+ // instance.setState(old => ({ ...old }))
3170
+ // })
3171
+ // }
3172
+ // },
3173
+ // cancel: () => {
3174
+ // canceled = true
3175
+ // batch.tasks = []
3176
+ // instance.batches[priority] = instance.batches[priority].filter(
3177
+ // b => b.id !== batchId
3178
+ // )
3179
+ // },
3180
+ // }
3181
+ // instance.batches[priority].push(batch)
3182
+ // return batch
3183
+ // },
3184
+ reset: () => {
3185
+ instance.setState(instance.initialState);
3186
+ },
3187
+ setOptions: updater => {
3188
+ const newOptions = functionalUpdate(updater, instance.options);
3189
+ instance.options = mergeOptions(newOptions);
3190
+ },
3191
+ render: (template, props) => {
3192
+ if (typeof instance.options.render === 'function') {
3193
+ return instance.options.render(template, props);
3194
+ }
3195
+
3196
+ if (typeof template === 'function') {
3197
+ return template(props);
3198
+ }
3199
+
3200
+ return template;
3201
+ },
3202
+ getState: () => {
3203
+ return instance.options.state;
3204
+ },
3205
+ setState: updater => {
3206
+ instance.options.onStateChange == null ? void 0 : instance.options.onStateChange(updater);
3207
+ } // getOverallProgress: () => {
3208
+ // const { coreProgress, filtersProgress, facetProgress } =
3209
+ // instance.getState()
3210
+ // return mean(() =>
3211
+ // [coreProgress, filtersProgress].filter(d => d < 1)
3212
+ // ) as number
3213
+ // },
3214
+ // getProgressStage: () => {
3215
+ // const { coreProgress, filtersProgress, facetProgress } =
3216
+ // instance.getState()
3217
+ // if (coreProgress < 1) {
3218
+ // return 'coreRowModel'
3219
+ // }
3220
+ // if (filtersProgress < 1) {
3221
+ // return 'filteredRowModel'
3222
+ // }
3223
+ // if (Object.values(facetProgress).some(d => d < 1)) {
3224
+ // return 'facetedRowModel'
3225
+ // }
3226
+ // },
3227
+
3228
+ };
3229
+ instance = Object.assign(instance, midInstance);
3230
+
3231
+ instance._features.forEach(feature => {
3232
+ return Object.assign(instance, feature.createInstance == null ? void 0 : feature.createInstance(instance));
3233
+ });
3234
+
3235
+ return instance;
3236
+ }
3237
+
3238
+ //
3239
+ function createTableFactory(opts) {
3240
+ return () => createTable$1(undefined, undefined, opts);
3241
+ } // A lot of returns in here are `as any` for a reason. Unless you
3242
+ // can find a better way to do this, then don't worry about them
3243
+
3244
+ function createTable$1(_, __, options) {
3245
+ const table = {
3246
+ generics: undefined,
3247
+ options: options != null ? options : {
3248
+ render: (() => {
3249
+ throw new Error('');
3250
+ })()
3251
+ },
3252
+ setGenerics: () => table,
3253
+ setRowType: () => table,
3254
+ setTableMetaType: () => table,
3255
+ setColumnMetaType: () => table,
3256
+ setOptions: newOptions => createTable$1(_, __, { ...options,
3257
+ ...newOptions
3258
+ }),
3259
+ createDisplayColumn: column => ({ ...column,
3260
+ columnDefType: 'display'
3261
+ }),
3262
+ createGroup: column => ({ ...column,
3263
+ columnDefType: 'group'
3264
+ }),
3265
+ createDataColumn: (accessor, column) => {
3266
+ column = { ...column,
3267
+ columnDefType: 'data',
3268
+ id: column.id
3269
+ };
3270
+
3271
+ if (typeof accessor === 'string') {
3272
+ var _column$id;
3273
+
3274
+ return { ...column,
3275
+ id: (_column$id = column.id) != null ? _column$id : accessor,
3276
+ accessorKey: accessor
3277
+ };
3278
+ }
3279
+
3280
+ if (typeof accessor === 'function') {
3281
+ return { ...column,
3282
+ accessorFn: accessor
3283
+ };
3284
+ }
3285
+
3286
+ throw new Error('Invalid accessor');
3287
+ }
3288
+ };
3289
+ return table;
3290
+ }
3291
+
3292
+ function getCoreRowModel() {
3293
+ return instance => memo(() => [instance.options.data], data => {
3294
+ // Access the row model using initial columns
3295
+ const rows = [];
3296
+ const flatRows = [];
3297
+ const rowsById = {};
3298
+ const leafColumns = instance.getAllLeafColumns();
3299
+
3300
+ const accessRow = function (originalRow, rowIndex, depth, parentRows, parent) {
3301
+ if (depth === void 0) {
3302
+ depth = 0;
3303
+ }
3304
+
3305
+ const id = instance.getRowId(originalRow, rowIndex, parent);
3306
+
3307
+ if (!id) {
3308
+ if (process.env.NODE_ENV !== 'production') {
3309
+ throw new Error("getRowId expected an ID, but got " + id);
3310
+ }
3311
+ }
3312
+
3313
+ const values = {};
3314
+
3315
+ for (let i = 0; i < leafColumns.length; i++) {
3316
+ const column = leafColumns[i];
3317
+
3318
+ if (column && column.accessorFn) {
3319
+ values[column.id] = column.accessorFn(originalRow, rowIndex);
3320
+ }
3321
+ } // Make the row
3322
+
3323
+
3324
+ const row = instance.createRow(id, originalRow, rowIndex, depth); // Push instance row into the parentRows array
3325
+
3326
+ parentRows.push(row); // Keep track of every row in a flat array
3327
+
3328
+ flatRows.push(row); // Also keep track of every row by its ID
3329
+
3330
+ rowsById[id] = row; // Get the original subrows
3331
+
3332
+ if (instance.options.getSubRows) {
3333
+ const originalSubRows = instance.options.getSubRows(originalRow, rowIndex); // Then recursively access them
3334
+
3335
+ if (originalSubRows != null && originalSubRows.length) {
3336
+ row.originalSubRows = originalSubRows;
3337
+ const subRows = [];
3338
+
3339
+ for (let i = 0; i < row.originalSubRows.length; i++) {
3340
+ accessRow(row.originalSubRows[i], i, depth + 1, subRows, row);
3341
+ }
3342
+
3343
+ row.subRows = subRows;
3344
+ }
3345
+ }
3346
+ };
3347
+
3348
+ for (let i = 0; i < data.length; i++) {
3349
+ accessRow(data[i], i, 0, rows);
3350
+ }
3351
+
3352
+ return {
3353
+ rows,
3354
+ flatRows,
3355
+ rowsById
3356
+ };
3357
+ }, {
3358
+ key: process.env.NODE_ENV === 'development' && 'getRowModel',
3359
+ debug: () => {
3360
+ var _instance$options$deb;
3361
+
3362
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3363
+ },
3364
+ onChange: () => {
3365
+ instance.queue(() => {
3366
+ instance._autoResetPageIndex();
3367
+ });
3368
+ }
3369
+ });
3370
+ }
3371
+
3372
+ function filterRows(rows, filterRowImpl, instance) {
3373
+ if (instance.options.filterFromLeafRows) {
3374
+ return filterRowModelFromLeafs(rows, filterRowImpl, instance);
3375
+ }
3376
+
3377
+ return filterRowModelFromRoot(rows, filterRowImpl, instance);
3378
+ }
3379
+ function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
3380
+ const newFilteredFlatRows = [];
3381
+ const newFilteredRowsById = {};
3382
+ let row;
3383
+ let newRow;
3384
+
3385
+ const recurseFilterRows = function (rowsToFilter, depth) {
3386
+ if (depth === void 0) {
3387
+ depth = 0;
3388
+ }
3389
+
3390
+ const rows = []; // Filter from children up first
3391
+
3392
+ for (let i = 0; i < rowsToFilter.length; i++) {
3393
+ var _row$subRows;
3394
+
3395
+ row = rowsToFilter[i];
3396
+
3397
+ if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
3398
+ newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3399
+ newRow.columnFilterMap = row.columnFilterMap;
3400
+ newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3401
+
3402
+ if (!newRow.subRows.length) {
3403
+ continue;
3404
+ }
3405
+
3406
+ row = newRow;
3407
+ }
3408
+
3409
+ if (filterRow(row)) {
3410
+ rows.push(row);
3411
+ newFilteredRowsById[row.id] = row;
3412
+ newFilteredRowsById[i] = row;
3413
+ }
3414
+ }
3415
+
3416
+ return rows;
3417
+ };
3418
+
3419
+ return {
3420
+ rows: recurseFilterRows(rowsToFilter),
3421
+ flatRows: newFilteredFlatRows,
3422
+ rowsById: newFilteredRowsById
3423
+ };
3424
+ }
3425
+ function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
3426
+ const newFilteredFlatRows = [];
3427
+ const newFilteredRowsById = {};
3428
+ let rows;
3429
+ let row;
3430
+ let newRow; // Filters top level and nested rows
3431
+
3432
+ const recurseFilterRows = function (rowsToFilter, depth) {
3433
+ if (depth === void 0) {
3434
+ depth = 0;
3435
+ }
3436
+
3437
+ // Filter from parents downward first
3438
+ rows = []; // Apply the filter to any subRows
3439
+
3440
+ for (let i = 0; i < rowsToFilter.length; i++) {
3441
+ row = rowsToFilter[i];
3442
+ const pass = filterRow(row);
3443
+
3444
+ if (pass) {
3445
+ var _row$subRows2;
3446
+
3447
+ if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
3448
+ newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3449
+ newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3450
+ row = newRow;
3451
+ }
3452
+
3453
+ rows.push(row);
3454
+ newFilteredFlatRows.push(row);
3455
+ newFilteredRowsById[row.id] = row;
3456
+ }
3457
+ }
3458
+
3459
+ return rows;
3460
+ };
3461
+
3462
+ return {
3463
+ rows: recurseFilterRows(rowsToFilter),
3464
+ flatRows: newFilteredFlatRows,
3465
+ rowsById: newFilteredRowsById
3466
+ };
3467
+ }
3468
+
3469
+ function getFilteredRowModel() {
3470
+ return instance => memo(() => [instance.getPreFilteredRowModel(), instance.getState().columnFilters, instance.getState().globalFilter], (rowModel, columnFilters, globalFilter) => {
3471
+ if (!rowModel.rows.length || !(columnFilters != null && columnFilters.length) && !globalFilter) {
3472
+ return rowModel;
3473
+ }
3474
+
3475
+ const resolvedColumnFilters = [];
3476
+ const resolvedGlobalFilters = [];
3477
+ (columnFilters != null ? columnFilters : []).forEach(d => {
3478
+ var _filterFn$resolveFilt;
3479
+
3480
+ const column = instance.getColumn(d.id);
3481
+
3482
+ if (!column) {
3483
+ if (process.env.NODE_ENV !== 'production') {
3484
+ console.warn("Table: Could not find a column to filter with columnId: " + d.id);
3485
+ }
3486
+ }
3487
+
3488
+ const filterFn = column.getFilterFn();
3489
+
3490
+ if (!filterFn) {
3491
+ if (process.env.NODE_ENV !== 'production') {
3492
+ console.warn("Could not find a valid 'column.filterFn' for column with the ID: " + column.id + ".");
3493
+ }
3494
+
3495
+ return;
3496
+ }
3497
+
3498
+ resolvedColumnFilters.push({
3499
+ id: d.id,
3500
+ filterFn,
3501
+ resolvedValue: (_filterFn$resolveFilt = filterFn.resolveFilterValue == null ? void 0 : filterFn.resolveFilterValue(d.value)) != null ? _filterFn$resolveFilt : d.value
3502
+ });
3503
+ });
3504
+ const filterableIds = columnFilters.map(d => d.id);
3505
+ const globalFilterFn = instance.getGlobalFilterFn();
3506
+ const globallyFilterableColumns = instance.getAllLeafColumns().filter(column => column.getCanGlobalFilter());
3507
+
3508
+ if (globalFilter && globalFilterFn && globallyFilterableColumns.length) {
3509
+ filterableIds.push('__global__');
3510
+ globallyFilterableColumns.forEach(column => {
3511
+ var _globalFilterFn$resol;
3512
+
3513
+ resolvedGlobalFilters.push({
3514
+ id: column.id,
3515
+ filterFn: globalFilterFn,
3516
+ resolvedValue: (_globalFilterFn$resol = globalFilterFn.resolveFilterValue == null ? void 0 : globalFilterFn.resolveFilterValue(globalFilter)) != null ? _globalFilterFn$resol : globalFilter
3517
+ });
3518
+ });
3519
+ }
3520
+
3521
+ let currentColumnFilter;
3522
+ let currentGlobalFilter; // Flag the prefiltered row model with each filter state
3523
+
3524
+ for (let j = 0; j < rowModel.flatRows.length; j++) {
3525
+ const row = rowModel.flatRows[j];
3526
+ row.columnFilterMap = {};
3527
+
3528
+ if (resolvedColumnFilters.length) {
3529
+ for (let i = 0; i < resolvedColumnFilters.length; i++) {
3530
+ currentColumnFilter = resolvedColumnFilters[i]; // Tag the row with the column filter state
3531
+
3532
+ row.columnFilterMap[currentColumnFilter.id] = currentColumnFilter.filterFn(row, currentColumnFilter.id, currentColumnFilter.resolvedValue);
3533
+ }
3534
+ }
3535
+
3536
+ if (resolvedGlobalFilters.length) {
3537
+ for (let i = 0; i < resolvedGlobalFilters.length; i++) {
3538
+ currentGlobalFilter = resolvedGlobalFilters[i]; // Tag the row with the first truthy global filter state
3539
+
3540
+ if (currentGlobalFilter.filterFn(row, currentGlobalFilter.id, currentGlobalFilter.resolvedValue)) {
3541
+ row.columnFilterMap.__global__ = true;
3542
+ break;
3543
+ }
23
3544
  }
3545
+
3546
+ if (row.columnFilterMap.__global__ !== true) {
3547
+ row.columnFilterMap.__global__ = false;
3548
+ }
3549
+ }
3550
+ }
3551
+
3552
+ const filterRowsImpl = row => {
3553
+ // Horizontally filter rows through each column
3554
+ for (let i = 0; i < filterableIds.length; i++) {
3555
+ if (row.columnFilterMap[filterableIds[i]] === false) {
3556
+ return false;
3557
+ }
3558
+ }
3559
+
3560
+ return true;
3561
+ }; // Filter final rows using all of the active filters
3562
+
3563
+
3564
+ return filterRows(rowModel.rows, filterRowsImpl, instance);
3565
+ }, {
3566
+ key: process.env.NODE_ENV === 'development' && 'getFilteredRowModel',
3567
+ debug: () => {
3568
+ var _instance$options$deb;
3569
+
3570
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3571
+ },
3572
+ onChange: () => {
3573
+ instance.queue(() => {
3574
+ instance._autoResetPageIndex();
3575
+ });
3576
+ }
3577
+ });
3578
+ }
3579
+
3580
+ function getFacetedRowModel() {
3581
+ return (instance, columnId) => memo(() => [instance.getPreFilteredRowModel(), instance.getState().columnFilters, instance.getState().globalFilter, instance.getFilteredRowModel()], (preRowModel, columnFilters, globalFilter) => {
3582
+ if (!preRowModel.rows.length || !(columnFilters != null && columnFilters.length) && !globalFilter) {
3583
+ return preRowModel;
3584
+ }
3585
+
3586
+ const filterableIds = [...columnFilters.map(d => d.id).filter(d => d !== columnId), globalFilter ? '__global__' : undefined].filter(Boolean);
3587
+
3588
+ const filterRowsImpl = row => {
3589
+ // Horizontally filter rows through each column
3590
+ for (let i = 0; i < filterableIds.length; i++) {
3591
+ if (row.columnFilterMap[filterableIds[i]] === false) {
3592
+ return false;
3593
+ }
3594
+ }
3595
+
3596
+ return true;
3597
+ };
3598
+
3599
+ return filterRows(preRowModel.rows, filterRowsImpl, instance);
3600
+ }, {
3601
+ key: process.env.NODE_ENV === 'development' && 'getFacetedRowModel_' + columnId,
3602
+ debug: () => {
3603
+ var _instance$options$deb;
3604
+
3605
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3606
+ },
3607
+ onChange: () => {}
3608
+ });
3609
+ }
3610
+
3611
+ function getFacetedUniqueValues() {
3612
+ return (instance, columnId) => memo(() => [instance.getColumn(columnId).getFacetedRowModel()], facetedRowModel => {
3613
+ let facetedUniqueValues = new Map();
3614
+
3615
+ for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
3616
+ var _facetedRowModel$flat;
3617
+
3618
+ const value = (_facetedRowModel$flat = facetedRowModel.flatRows[i]) == null ? void 0 : _facetedRowModel$flat.getValue(columnId);
3619
+
3620
+ if (facetedUniqueValues.has(value)) {
3621
+ var _facetedUniqueValues$;
3622
+
3623
+ facetedUniqueValues.set(value, ((_facetedUniqueValues$ = facetedUniqueValues.get(value)) != null ? _facetedUniqueValues$ : 0) + 1);
3624
+ } else {
3625
+ facetedUniqueValues.set(value, 1);
3626
+ }
3627
+ }
3628
+
3629
+ return facetedUniqueValues;
3630
+ }, {
3631
+ key: process.env.NODE_ENV === 'development' && 'getFacetedUniqueValues_' + columnId,
3632
+ debug: () => {
3633
+ var _instance$options$deb;
3634
+
3635
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3636
+ },
3637
+ onChange: () => {}
3638
+ });
3639
+ }
3640
+
3641
+ function getFacetedMinMaxValues() {
3642
+ return (instance, columnId) => memo(() => [instance.getColumn(columnId).getFacetedRowModel()], facetedRowModel => {
3643
+ var _facetedRowModel$flat, _facetedRowModel$flat2, _facetedRowModel$flat3, _facetedRowModel$flat4;
3644
+
3645
+ let facetedMinMaxValues = [(_facetedRowModel$flat = (_facetedRowModel$flat2 = facetedRowModel.flatRows[0]) == null ? void 0 : _facetedRowModel$flat2.getValue(columnId)) != null ? _facetedRowModel$flat : null, (_facetedRowModel$flat3 = (_facetedRowModel$flat4 = facetedRowModel.flatRows[0]) == null ? void 0 : _facetedRowModel$flat4.getValue(columnId)) != null ? _facetedRowModel$flat3 : null];
3646
+
3647
+ for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
3648
+ var _facetedRowModel$flat5;
3649
+
3650
+ const value = (_facetedRowModel$flat5 = facetedRowModel.flatRows[i]) == null ? void 0 : _facetedRowModel$flat5.getValue(columnId);
3651
+
3652
+ if (value < facetedMinMaxValues[0]) {
3653
+ facetedMinMaxValues[0] = value;
3654
+ } else if (value > facetedMinMaxValues[1]) {
3655
+ facetedMinMaxValues[1] = value;
3656
+ }
3657
+ }
3658
+
3659
+ return facetedMinMaxValues;
3660
+ }, {
3661
+ key: process.env.NODE_ENV === 'development' && 'getFacetedMinMaxValues_' + columnId,
3662
+ debug: () => {
3663
+ var _instance$options$deb;
3664
+
3665
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3666
+ },
3667
+ onChange: () => {}
3668
+ });
3669
+ }
3670
+
3671
+ function getSortedRowModel() {
3672
+ return instance => memo(() => [instance.getState().sorting, instance.getPreSortedRowModel()], (sorting, rowModel) => {
3673
+ if (!rowModel.rows.length || !(sorting != null && sorting.length)) {
3674
+ return rowModel;
3675
+ }
3676
+
3677
+ const sortingState = instance.getState().sorting;
3678
+ const sortedFlatRows = []; // Filter out sortings that correspond to non existing columns
3679
+
3680
+ const availableSorting = sortingState.filter(sort => instance.getColumn(sort.id).getCanSort());
3681
+ const columnInfoById = {};
3682
+ availableSorting.forEach(sortEntry => {
3683
+ const column = instance.getColumn(sortEntry.id);
3684
+ columnInfoById[sortEntry.id] = {
3685
+ sortUndefined: column.sortUndefined,
3686
+ invertSorting: column.invertSorting,
3687
+ sortingFn: column.getSortingFn()
3688
+ };
3689
+ });
3690
+
3691
+ const sortData = rows => {
3692
+ // This will also perform a stable sorting using the row index
3693
+ // if needed.
3694
+ const sortedData = rows.slice();
3695
+ sortedData.sort((rowA, rowB) => {
3696
+ for (let i = 0; i < availableSorting.length; i += 1) {
3697
+ var _sortEntry$desc;
3698
+
3699
+ const sortEntry = availableSorting[i];
3700
+ const columnInfo = columnInfoById[sortEntry.id];
3701
+ const isDesc = (_sortEntry$desc = sortEntry == null ? void 0 : sortEntry.desc) != null ? _sortEntry$desc : false;
3702
+
3703
+ if (columnInfo.sortUndefined) {
3704
+ const aValue = rowA.getValue(sortEntry.id);
3705
+ const bValue = rowB.getValue(sortEntry.id);
3706
+ const aUndefined = typeof aValue === 'undefined';
3707
+ const bUndefined = typeof bValue === 'undefined';
3708
+
3709
+ if (aUndefined || bUndefined) {
3710
+ return aUndefined && bUndefined ? 0 : aUndefined ? columnInfo.sortUndefined : -columnInfo.sortUndefined;
3711
+ }
3712
+ } // This function should always return in ascending order
3713
+
3714
+
3715
+ let sortInt = columnInfo.sortingFn(rowA, rowB, sortEntry.id);
3716
+
3717
+ if (sortInt !== 0) {
3718
+ if (isDesc) {
3719
+ sortInt *= -1;
3720
+ }
3721
+
3722
+ if (columnInfo.invertSorting) {
3723
+ sortInt *= -1;
3724
+ }
3725
+
3726
+ return sortInt;
3727
+ }
3728
+ }
3729
+
3730
+ return rowA.index - rowB.index;
3731
+ }); // If there are sub-rows, sort them
3732
+
3733
+ sortedData.forEach(row => {
3734
+ sortedFlatRows.push(row);
3735
+
3736
+ if (!row.subRows || row.subRows.length <= 1) {
3737
+ return;
3738
+ }
3739
+
3740
+ row.subRows = sortData(row.subRows);
3741
+ });
3742
+ return sortedData;
3743
+ };
3744
+
3745
+ return {
3746
+ rows: sortData(rowModel.rows),
3747
+ flatRows: sortedFlatRows,
3748
+ rowsById: rowModel.rowsById
3749
+ };
3750
+ }, {
3751
+ key: process.env.NODE_ENV === 'development' && 'getSortedRowModel',
3752
+ debug: () => {
3753
+ var _instance$options$deb;
3754
+
3755
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3756
+ },
3757
+ onChange: () => {
3758
+ instance.queue(() => {
3759
+ instance._autoResetPageIndex();
3760
+ });
3761
+ }
3762
+ });
3763
+ }
3764
+
3765
+ function getGroupedRowModel() {
3766
+ return instance => memo(() => [instance.getState().grouping, instance.getPreGroupedRowModel()], (grouping, rowModel) => {
3767
+ if (!rowModel.rows.length || !grouping.length) {
3768
+ return rowModel;
3769
+ } // Filter the grouping list down to columns that exist
3770
+
3771
+
3772
+ const existingGrouping = grouping.filter(columnId => instance.getColumn(columnId));
3773
+ const groupedFlatRows = [];
3774
+ const groupedRowsById = {}; // const onlyGroupedFlatRows: Row[] = [];
3775
+ // const onlyGroupedRowsById: Record<RowId, Row> = {};
3776
+ // const nonGroupedFlatRows: Row[] = [];
3777
+ // const nonGroupedRowsById: Record<RowId, Row> = {};
3778
+ // Recursively group the data
3779
+
3780
+ const groupUpRecursively = function (rows, depth, parentId) {
3781
+ if (depth === void 0) {
3782
+ depth = 0;
3783
+ }
3784
+
3785
+ // This is the last level, just return the rows
3786
+ if (depth === existingGrouping.length) {
3787
+ return rows;
24
3788
  }
3789
+
3790
+ const columnId = existingGrouping[depth]; // Group the rows together for this level
3791
+
3792
+ const rowGroupsMap = groupBy(rows, columnId); // Peform aggregations for each group
3793
+
3794
+ const aggregatedGroupedRows = Array.from(rowGroupsMap.entries()).map((_ref, index) => {
3795
+ let [groupingValue, groupedRows] = _ref;
3796
+ let id = columnId + ":" + groupingValue;
3797
+ id = parentId ? parentId + ">" + id : id; // First, Recurse to group sub rows before aggregation
3798
+
3799
+ const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
3800
+
3801
+ const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
3802
+ const row = instance.createRow(id, undefined, index, depth);
3803
+ Object.assign(row, {
3804
+ groupingColumnId: columnId,
3805
+ groupingValue,
3806
+ subRows,
3807
+ leafRows,
3808
+ getValue: columnId => {
3809
+ // Don't aggregate columns that are in the grouping
3810
+ if (existingGrouping.includes(columnId)) {
3811
+ if (row.valuesCache.hasOwnProperty(columnId)) {
3812
+ return row.valuesCache[columnId];
3813
+ }
3814
+
3815
+ if (groupedRows[0]) {
3816
+ var _groupedRows$0$getVal;
3817
+
3818
+ row.valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
3819
+ }
3820
+
3821
+ return row.valuesCache[columnId];
3822
+ }
3823
+
3824
+ if (row.groupingValuesCache.hasOwnProperty(columnId)) {
3825
+ return row.groupingValuesCache[columnId];
3826
+ } // Aggregate the values
3827
+
3828
+
3829
+ const column = instance.getColumn(columnId);
3830
+ const aggregateFn = column.getColumnAggregationFn();
3831
+
3832
+ if (aggregateFn) {
3833
+ row.groupingValuesCache[columnId] = aggregateFn(() => leafRows.map(row => {
3834
+ let columnValue = row.getValue(columnId);
3835
+
3836
+ if (!depth && column.aggregateValue) {
3837
+ columnValue = column.aggregateValue(columnValue);
3838
+ }
3839
+
3840
+ return columnValue;
3841
+ }), () => groupedRows.map(row => row.getValue(columnId)));
3842
+ return row.groupingValuesCache[columnId];
3843
+ } else if (column.aggregationFn) {
3844
+ console.info({
3845
+ column
3846
+ });
3847
+ throw new Error(process.env.NODE_ENV !== 'production' ? "Table: Invalid column.aggregateType option for column listed above" : '');
3848
+ }
3849
+ }
3850
+ });
3851
+ subRows.forEach(subRow => {
3852
+ groupedFlatRows.push(subRow);
3853
+ groupedRowsById[subRow.id] = subRow; // if (subRow.getIsGrouped?.()) {
3854
+ // onlyGroupedFlatRows.push(subRow);
3855
+ // onlyGroupedRowsById[subRow.id] = subRow;
3856
+ // } else {
3857
+ // nonGroupedFlatRows.push(subRow);
3858
+ // nonGroupedRowsById[subRow.id] = subRow;
3859
+ // }
3860
+ });
3861
+ return row;
3862
+ });
3863
+ return aggregatedGroupedRows;
3864
+ };
3865
+
3866
+ const groupedRows = groupUpRecursively(rowModel.rows, 0, '');
3867
+ groupedRows.forEach(subRow => {
3868
+ groupedFlatRows.push(subRow);
3869
+ groupedRowsById[subRow.id] = subRow; // if (subRow.getIsGrouped?.()) {
3870
+ // onlyGroupedFlatRows.push(subRow);
3871
+ // onlyGroupedRowsById[subRow.id] = subRow;
3872
+ // } else {
3873
+ // nonGroupedFlatRows.push(subRow);
3874
+ // nonGroupedRowsById[subRow.id] = subRow;
3875
+ // }
3876
+ });
3877
+ return {
3878
+ rows: groupedRows,
3879
+ flatRows: groupedFlatRows,
3880
+ rowsById: groupedRowsById
3881
+ };
3882
+ }, {
3883
+ key: process.env.NODE_ENV === 'development' && 'getGroupedRowModel',
3884
+ debug: () => {
3885
+ var _instance$options$deb;
3886
+
3887
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3888
+ },
3889
+ onChange: () => {
3890
+ instance.queue(() => {
3891
+ instance._autoResetExpanded();
3892
+
3893
+ instance._autoResetPageIndex();
3894
+ });
3895
+ }
3896
+ });
3897
+ }
3898
+
3899
+ function groupBy(rows, columnId) {
3900
+ const groupMap = new Map();
3901
+ return rows.reduce((map, row) => {
3902
+ const resKey = "" + row.getValue(columnId);
3903
+ const previous = map.get(resKey);
3904
+
3905
+ if (!previous) {
3906
+ map.set(resKey, [row]);
3907
+ } else {
3908
+ map.set(resKey, [...previous, row]);
3909
+ }
3910
+
3911
+ return map;
3912
+ }, groupMap);
3913
+ }
3914
+
3915
+ function getExpandedRowModel() {
3916
+ return instance => memo(() => [instance.getState().expanded, instance.getPreExpandedRowModel(), instance.options.paginateExpandedRows], (expanded, rowModel, paginateExpandedRows) => {
3917
+ if (!rowModel.rows.length || // Do not expand if rows are not included in pagination
3918
+ !paginateExpandedRows || expanded !== true && !Object.keys(expanded != null ? expanded : {}).length) {
3919
+ return rowModel;
3920
+ }
3921
+
3922
+ return expandRows(rowModel, instance);
3923
+ }, {
3924
+ key: process.env.NODE_ENV === 'development' && 'getExpandedRowModel',
3925
+ debug: () => {
3926
+ var _instance$options$deb;
3927
+
3928
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3929
+ }
3930
+ });
3931
+ }
3932
+ function expandRows(rowModel, instance) {
3933
+ const expandedRows = [];
3934
+
3935
+ const handleRow = row => {
3936
+ var _row$subRows;
3937
+
3938
+ expandedRows.push(row);
3939
+
3940
+ if (instance.options.expandSubRows && (_row$subRows = row.subRows) != null && _row$subRows.length && row.getIsExpanded()) {
3941
+ row.subRows.forEach(handleRow);
25
3942
  }
3943
+ };
26
3944
 
27
- return target;
3945
+ rowModel.rows.forEach(handleRow);
3946
+ return {
3947
+ rows: expandedRows,
3948
+ flatRows: rowModel.flatRows,
3949
+ rowsById: rowModel.rowsById
28
3950
  };
3951
+ }
3952
+
3953
+ function getPaginationRowModel(opts) {
3954
+ return instance => memo(() => [instance.getState().pagination, instance.getPrePaginationRowModel()], (pagination, rowModel) => {
3955
+ if (!rowModel.rows.length) {
3956
+ return rowModel;
3957
+ }
3958
+
3959
+ const {
3960
+ pageSize,
3961
+ pageIndex
3962
+ } = pagination;
3963
+ let {
3964
+ rows,
3965
+ flatRows,
3966
+ rowsById
3967
+ } = rowModel;
3968
+ const pageStart = pageSize * pageIndex;
3969
+ const pageEnd = pageStart + pageSize;
3970
+ rows = rows.slice(pageStart, pageEnd);
29
3971
 
30
- return _extends.apply(this, arguments);
3972
+ if (!instance.options.paginateExpandedRows) {
3973
+ return expandRows({
3974
+ rows,
3975
+ flatRows,
3976
+ rowsById
3977
+ }, instance);
3978
+ }
3979
+
3980
+ return {
3981
+ rows,
3982
+ flatRows,
3983
+ rowsById
3984
+ };
3985
+ }, {
3986
+ key: process.env.NODE_ENV === 'development' && 'getPaginationRowModel',
3987
+ debug: () => {
3988
+ var _instance$options$deb;
3989
+
3990
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3991
+ }
3992
+ });
31
3993
  }
32
3994
 
33
3995
  //
34
- var render = function render(Comp, props) {
35
- return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React.createElement(Comp, props) : Comp;
36
- };
3996
+ const render = (Comp, props) => !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React.createElement(Comp, props) : Comp;
37
3997
 
38
3998
  function isReactComponent(component) {
39
3999
  return isClassComponent(component) || typeof component === 'function' || isExoticComponent(component);
40
4000
  }
41
4001
 
42
4002
  function isClassComponent(component) {
43
- return typeof component === 'function' && function () {
44
- var proto = Object.getPrototypeOf(component);
4003
+ return typeof component === 'function' && (() => {
4004
+ const proto = Object.getPrototypeOf(component);
45
4005
  return proto.prototype && proto.prototype.isReactComponent;
46
- }();
4006
+ })();
47
4007
  }
48
4008
 
49
4009
  function isExoticComponent(component) {
50
4010
  return typeof component === 'object' && typeof component.$$typeof === 'symbol' && ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description);
51
4011
  }
52
4012
 
53
- var createTable = createTableFactory({
54
- render: render
55
- });
4013
+ const createTable = createTableFactory({
4014
+ render
4015
+ }); // const useIsomorphicLayoutEffect =
4016
+ // typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect
4017
+
56
4018
  function useTableInstance(table, options) {
57
4019
  // Compose in the generic options to the user options
58
- var resolvedOptions = _extends({}, table.options, {
4020
+ const resolvedOptions = { ...table.options,
59
4021
  state: {},
60
4022
  // Dummy state
61
- onStateChange: function onStateChange() {},
4023
+ onStateChange: () => {},
62
4024
  // noop
63
- render: render
64
- }, options); // Create a new table instance and store it in state
65
-
4025
+ render,
4026
+ ...options
4027
+ }; // Create a new table instance and store it in state
66
4028
 
67
- var _React$useState = React.useState(function () {
68
- return createTableInstance(resolvedOptions);
69
- }),
70
- instance = _React$useState[0]; // By default, manage table state here using the instance's initial state
4029
+ const [instanceRef] = React.useState(() => ({
4030
+ current: createTableInstance(resolvedOptions)
4031
+ })); // By default, manage table state here using the instance's initial state
71
4032
 
72
-
73
- var _React$useState2 = React.useState(function () {
74
- return instance.initialState;
75
- }),
76
- state = _React$useState2[0],
77
- setState = _React$useState2[1]; // Compose the default state above with any user state. This will allow the user
4033
+ const [state, setState] = React.useState(() => instanceRef.current.initialState); // Compose the default state above with any user state. This will allow the user
78
4034
  // to only control a subset of the state if desired.
79
4035
 
80
-
81
- instance.setOptions(function (prev) {
82
- return _extends({}, prev, options, {
83
- state: _extends({}, state, options.state),
84
- // Similarly, we'll maintain both our internal state and any user-provided
85
- // state.
86
- onStateChange: function onStateChange(updater) {
87
- setState(updater);
88
- options.onStateChange == null ? void 0 : options.onStateChange(updater);
89
- }
90
- });
91
- }); // useIsomorphicLayoutEffect(() => {
92
- // instance.willUpdate()
93
- // })
94
-
95
- return instance;
4036
+ instanceRef.current.setOptions(prev => ({ ...prev,
4037
+ ...options,
4038
+ state: { ...state,
4039
+ ...options.state
4040
+ },
4041
+ // Similarly, we'll maintain both our internal state and any user-provided
4042
+ // state.
4043
+ onStateChange: updater => {
4044
+ setState(updater);
4045
+ options.onStateChange == null ? void 0 : options.onStateChange(updater);
4046
+ }
4047
+ }));
4048
+ return instanceRef.current;
96
4049
  }
97
4050
 
98
- export { createTable, render, useTableInstance };
4051
+ export { ColumnSizing, Expanding, Filters, Grouping, Headers, Ordering, Pagination, Pinning, RowSelection, Sorting, Visibility, buildHeaderGroups, createTable, createTableFactory, createTableInstance, defaultColumnSizing, expandRows, flattenBy, functionalUpdate, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, isFunction, isRowSelected, makeStateUpdater, memo, noop, orderColumns, passiveEventSupported, render, selectRowsFn, shouldAutoRemoveFilter, useTableInstance };
99
4052
  //# sourceMappingURL=index.js.map