@tanstack/svelte-table 8.0.0-alpha.67 → 8.0.0-alpha.68

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