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