@tanstack/svelte-table 8.13.2 → 8.15.1
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.
- package/build/lib/index.esm.js +2 -5
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.mjs +2 -5
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/placeholder.svelte.js +2 -5
- package/build/lib/placeholder.svelte.js.map +1 -1
- package/build/umd/index.development.js +1526 -1472
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +2 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +5 -2
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
(function (global, factory) {
|
|
12
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('svelte/internal'), require('svelte/
|
|
13
|
-
typeof define === 'function' && define.amd ? define(['exports', 'svelte/internal', 'svelte/
|
|
14
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.SvelteTable = {}, global.SvelteInternal,
|
|
15
|
-
})(this, (function (exports, internal,
|
|
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
17
|
/**
|
|
18
18
|
* table-core
|
|
@@ -24,6 +24,63 @@
|
|
|
24
24
|
*
|
|
25
25
|
* @license MIT
|
|
26
26
|
*/
|
|
27
|
+
// type Person = {
|
|
28
|
+
// firstName: string
|
|
29
|
+
// lastName: string
|
|
30
|
+
// age: number
|
|
31
|
+
// visits: number
|
|
32
|
+
// status: string
|
|
33
|
+
// progress: number
|
|
34
|
+
// createdAt: Date
|
|
35
|
+
// nested: {
|
|
36
|
+
// foo: [
|
|
37
|
+
// {
|
|
38
|
+
// bar: 'bar'
|
|
39
|
+
// }
|
|
40
|
+
// ]
|
|
41
|
+
// bar: { subBar: boolean }[]
|
|
42
|
+
// baz: {
|
|
43
|
+
// foo: 'foo'
|
|
44
|
+
// bar: {
|
|
45
|
+
// baz: 'baz'
|
|
46
|
+
// }
|
|
47
|
+
// }
|
|
48
|
+
// }
|
|
49
|
+
// }
|
|
50
|
+
|
|
51
|
+
// const test: DeepKeys<Person> = 'nested.foo.0.bar'
|
|
52
|
+
// const test2: DeepKeys<Person> = 'nested.bar'
|
|
53
|
+
|
|
54
|
+
// const helper = createColumnHelper<Person>()
|
|
55
|
+
|
|
56
|
+
// helper.accessor('nested.foo', {
|
|
57
|
+
// cell: info => info.getValue(),
|
|
58
|
+
// })
|
|
59
|
+
|
|
60
|
+
// helper.accessor('nested.foo.0.bar', {
|
|
61
|
+
// cell: info => info.getValue(),
|
|
62
|
+
// })
|
|
63
|
+
|
|
64
|
+
// helper.accessor('nested.bar', {
|
|
65
|
+
// cell: info => info.getValue(),
|
|
66
|
+
// })
|
|
67
|
+
|
|
68
|
+
function createColumnHelper() {
|
|
69
|
+
return {
|
|
70
|
+
accessor: (accessor, column) => {
|
|
71
|
+
return typeof accessor === 'function' ? {
|
|
72
|
+
...column,
|
|
73
|
+
accessorFn: accessor
|
|
74
|
+
} : {
|
|
75
|
+
...column,
|
|
76
|
+
accessorKey: accessor
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
display: column => column,
|
|
80
|
+
group: column => column
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
27
84
|
// Is this type a tuple?
|
|
28
85
|
|
|
29
86
|
// If this type is a tuple, what indices are allowed?
|
|
@@ -114,6 +171,32 @@
|
|
|
114
171
|
};
|
|
115
172
|
}
|
|
116
173
|
|
|
174
|
+
function createCell(table, row, column, columnId) {
|
|
175
|
+
const getRenderValue = () => {
|
|
176
|
+
var _cell$getValue;
|
|
177
|
+
return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : table.options.renderFallbackValue;
|
|
178
|
+
};
|
|
179
|
+
const cell = {
|
|
180
|
+
id: `${row.id}_${column.id}`,
|
|
181
|
+
row,
|
|
182
|
+
column,
|
|
183
|
+
getValue: () => row.getValue(columnId),
|
|
184
|
+
renderValue: getRenderValue,
|
|
185
|
+
getContext: memo(() => [table, column, row, cell], (table, column, row, cell) => ({
|
|
186
|
+
table,
|
|
187
|
+
column,
|
|
188
|
+
row,
|
|
189
|
+
cell: cell,
|
|
190
|
+
getValue: cell.getValue,
|
|
191
|
+
renderValue: cell.renderValue
|
|
192
|
+
}), getMemoOptions(table.options, 'debugCells', 'cell.getContext'))
|
|
193
|
+
};
|
|
194
|
+
table._features.forEach(feature => {
|
|
195
|
+
feature.createCell == null || feature.createCell(cell, column, row, table);
|
|
196
|
+
}, {});
|
|
197
|
+
return cell;
|
|
198
|
+
}
|
|
199
|
+
|
|
117
200
|
function createColumn(table, columnDef, depth, parent) {
|
|
118
201
|
var _ref, _resolvedColumnDef$id;
|
|
119
202
|
const defaultColumn = table._getDefaultColumnDef();
|
|
@@ -173,7 +256,7 @@
|
|
|
173
256
|
feature.createColumn == null || feature.createColumn(column, table);
|
|
174
257
|
}
|
|
175
258
|
|
|
176
|
-
// Yes, we have to convert table to
|
|
259
|
+
// Yes, we have to convert table to unknown, because we know more than the compiler here.
|
|
177
260
|
return column;
|
|
178
261
|
}
|
|
179
262
|
|
|
@@ -430,677 +513,1054 @@
|
|
|
430
513
|
return headerGroups;
|
|
431
514
|
}
|
|
432
515
|
|
|
433
|
-
|
|
516
|
+
const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
|
517
|
+
let row = {
|
|
518
|
+
id,
|
|
519
|
+
index: rowIndex,
|
|
520
|
+
original,
|
|
521
|
+
depth,
|
|
522
|
+
parentId,
|
|
523
|
+
_valuesCache: {},
|
|
524
|
+
_uniqueValuesCache: {},
|
|
525
|
+
getValue: columnId => {
|
|
526
|
+
if (row._valuesCache.hasOwnProperty(columnId)) {
|
|
527
|
+
return row._valuesCache[columnId];
|
|
528
|
+
}
|
|
529
|
+
const column = table.getColumn(columnId);
|
|
530
|
+
if (!(column != null && column.accessorFn)) {
|
|
531
|
+
return undefined;
|
|
532
|
+
}
|
|
533
|
+
row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
|
534
|
+
return row._valuesCache[columnId];
|
|
535
|
+
},
|
|
536
|
+
getUniqueValues: columnId => {
|
|
537
|
+
if (row._uniqueValuesCache.hasOwnProperty(columnId)) {
|
|
538
|
+
return row._uniqueValuesCache[columnId];
|
|
539
|
+
}
|
|
540
|
+
const column = table.getColumn(columnId);
|
|
541
|
+
if (!(column != null && column.accessorFn)) {
|
|
542
|
+
return undefined;
|
|
543
|
+
}
|
|
544
|
+
if (!column.columnDef.getUniqueValues) {
|
|
545
|
+
row._uniqueValuesCache[columnId] = [row.getValue(columnId)];
|
|
546
|
+
return row._uniqueValuesCache[columnId];
|
|
547
|
+
}
|
|
548
|
+
row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(row.original, rowIndex);
|
|
549
|
+
return row._uniqueValuesCache[columnId];
|
|
550
|
+
},
|
|
551
|
+
renderValue: columnId => {
|
|
552
|
+
var _row$getValue;
|
|
553
|
+
return (_row$getValue = row.getValue(columnId)) != null ? _row$getValue : table.options.renderFallbackValue;
|
|
554
|
+
},
|
|
555
|
+
subRows: subRows != null ? subRows : [],
|
|
556
|
+
getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
|
|
557
|
+
getParentRow: () => row.parentId ? table.getRow(row.parentId, true) : undefined,
|
|
558
|
+
getParentRows: () => {
|
|
559
|
+
let parentRows = [];
|
|
560
|
+
let currentRow = row;
|
|
561
|
+
while (true) {
|
|
562
|
+
const parentRow = currentRow.getParentRow();
|
|
563
|
+
if (!parentRow) break;
|
|
564
|
+
parentRows.push(parentRow);
|
|
565
|
+
currentRow = parentRow;
|
|
566
|
+
}
|
|
567
|
+
return parentRows.reverse();
|
|
568
|
+
},
|
|
569
|
+
getAllCells: memo(() => [table.getAllLeafColumns()], leafColumns => {
|
|
570
|
+
return leafColumns.map(column => {
|
|
571
|
+
return createCell(table, row, column, column.id);
|
|
572
|
+
});
|
|
573
|
+
}, getMemoOptions(table.options, 'debugRows', 'getAllCells')),
|
|
574
|
+
_getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
|
|
575
|
+
return allCells.reduce((acc, cell) => {
|
|
576
|
+
acc[cell.column.id] = cell;
|
|
577
|
+
return acc;
|
|
578
|
+
}, {});
|
|
579
|
+
}, getMemoOptions(table.options, 'debugRows', 'getAllCellsByColumnId'))
|
|
580
|
+
};
|
|
581
|
+
for (let i = 0; i < table._features.length; i++) {
|
|
582
|
+
const feature = table._features[i];
|
|
583
|
+
feature == null || feature.createRow == null || feature.createRow(row, table);
|
|
584
|
+
}
|
|
585
|
+
return row;
|
|
586
|
+
};
|
|
434
587
|
|
|
435
588
|
//
|
|
436
589
|
|
|
437
|
-
const
|
|
438
|
-
size: 150,
|
|
439
|
-
minSize: 20,
|
|
440
|
-
maxSize: Number.MAX_SAFE_INTEGER
|
|
441
|
-
};
|
|
442
|
-
const getDefaultColumnSizingInfoState = () => ({
|
|
443
|
-
startOffset: null,
|
|
444
|
-
startSize: null,
|
|
445
|
-
deltaOffset: null,
|
|
446
|
-
deltaPercentage: null,
|
|
447
|
-
isResizingColumn: false,
|
|
448
|
-
columnSizingStart: []
|
|
449
|
-
});
|
|
450
|
-
const ColumnSizing = {
|
|
451
|
-
getDefaultColumnDef: () => {
|
|
452
|
-
return defaultColumnSizing;
|
|
453
|
-
},
|
|
454
|
-
getInitialState: state => {
|
|
455
|
-
return {
|
|
456
|
-
columnSizing: {},
|
|
457
|
-
columnSizingInfo: getDefaultColumnSizingInfoState(),
|
|
458
|
-
...state
|
|
459
|
-
};
|
|
460
|
-
},
|
|
461
|
-
getDefaultOptions: table => {
|
|
462
|
-
return {
|
|
463
|
-
columnResizeMode: 'onEnd',
|
|
464
|
-
columnResizeDirection: 'ltr',
|
|
465
|
-
onColumnSizingChange: makeStateUpdater('columnSizing', table),
|
|
466
|
-
onColumnSizingInfoChange: makeStateUpdater('columnSizingInfo', table)
|
|
467
|
-
};
|
|
468
|
-
},
|
|
590
|
+
const ColumnFaceting = {
|
|
469
591
|
createColumn: (column, table) => {
|
|
470
|
-
column.
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
column.getAfter = memo(position => [position, _getVisibleLeafColumns(table, position), table.getState().columnSizing], (position, columns) => columns.slice(column.getIndex(position) + 1).reduce((sum, column) => sum + column.getSize(), 0), getMemoOptions(table.options, 'debugColumns', 'getAfter'));
|
|
477
|
-
column.resetSize = () => {
|
|
478
|
-
table.setColumnSizing(_ref2 => {
|
|
479
|
-
let {
|
|
480
|
-
[column.id]: _,
|
|
481
|
-
...rest
|
|
482
|
-
} = _ref2;
|
|
483
|
-
return rest;
|
|
484
|
-
});
|
|
485
|
-
};
|
|
486
|
-
column.getCanResize = () => {
|
|
487
|
-
var _column$columnDef$ena, _table$options$enable;
|
|
488
|
-
return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnResizing) != null ? _table$options$enable : true);
|
|
489
|
-
};
|
|
490
|
-
column.getIsResizing = () => {
|
|
491
|
-
return table.getState().columnSizingInfo.isResizingColumn === column.id;
|
|
592
|
+
column._getFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, column.id);
|
|
593
|
+
column.getFacetedRowModel = () => {
|
|
594
|
+
if (!column._getFacetedRowModel) {
|
|
595
|
+
return table.getPreFilteredRowModel();
|
|
596
|
+
}
|
|
597
|
+
return column._getFacetedRowModel();
|
|
492
598
|
};
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
header.subHeaders.forEach(recurse);
|
|
500
|
-
} else {
|
|
501
|
-
var _header$column$getSiz;
|
|
502
|
-
sum += (_header$column$getSiz = header.column.getSize()) != null ? _header$column$getSiz : 0;
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
recurse(header);
|
|
506
|
-
return sum;
|
|
599
|
+
column._getFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, column.id);
|
|
600
|
+
column.getFacetedUniqueValues = () => {
|
|
601
|
+
if (!column._getFacetedUniqueValues) {
|
|
602
|
+
return new Map();
|
|
603
|
+
}
|
|
604
|
+
return column._getFacetedUniqueValues();
|
|
507
605
|
};
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
return
|
|
606
|
+
column._getFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, column.id);
|
|
607
|
+
column.getFacetedMinMaxValues = () => {
|
|
608
|
+
if (!column._getFacetedMinMaxValues) {
|
|
609
|
+
return undefined;
|
|
512
610
|
}
|
|
513
|
-
return
|
|
514
|
-
};
|
|
515
|
-
header.getResizeHandler = _contextDocument => {
|
|
516
|
-
const column = table.getColumn(header.column.id);
|
|
517
|
-
const canResize = column == null ? void 0 : column.getCanResize();
|
|
518
|
-
return e => {
|
|
519
|
-
if (!column || !canResize) {
|
|
520
|
-
return;
|
|
521
|
-
}
|
|
522
|
-
e.persist == null || e.persist();
|
|
523
|
-
if (isTouchStartEvent(e)) {
|
|
524
|
-
// lets not respond to multiple touches (e.g. 2 or 3 fingers)
|
|
525
|
-
if (e.touches && e.touches.length > 1) {
|
|
526
|
-
return;
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
const startSize = header.getSize();
|
|
530
|
-
const columnSizingStart = header ? header.getLeafHeaders().map(d => [d.column.id, d.column.getSize()]) : [[column.id, column.getSize()]];
|
|
531
|
-
const clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
|
|
532
|
-
const newColumnSizing = {};
|
|
533
|
-
const updateOffset = (eventType, clientXPos) => {
|
|
534
|
-
if (typeof clientXPos !== 'number') {
|
|
535
|
-
return;
|
|
536
|
-
}
|
|
537
|
-
table.setColumnSizingInfo(old => {
|
|
538
|
-
var _old$startOffset, _old$startSize;
|
|
539
|
-
const deltaDirection = table.options.columnResizeDirection === 'rtl' ? -1 : 1;
|
|
540
|
-
const deltaOffset = (clientXPos - ((_old$startOffset = old == null ? void 0 : old.startOffset) != null ? _old$startOffset : 0)) * deltaDirection;
|
|
541
|
-
const deltaPercentage = Math.max(deltaOffset / ((_old$startSize = old == null ? void 0 : old.startSize) != null ? _old$startSize : 0), -0.999999);
|
|
542
|
-
old.columnSizingStart.forEach(_ref3 => {
|
|
543
|
-
let [columnId, headerSize] = _ref3;
|
|
544
|
-
newColumnSizing[columnId] = Math.round(Math.max(headerSize + headerSize * deltaPercentage, 0) * 100) / 100;
|
|
545
|
-
});
|
|
546
|
-
return {
|
|
547
|
-
...old,
|
|
548
|
-
deltaOffset,
|
|
549
|
-
deltaPercentage
|
|
550
|
-
};
|
|
551
|
-
});
|
|
552
|
-
if (table.options.columnResizeMode === 'onChange' || eventType === 'end') {
|
|
553
|
-
table.setColumnSizing(old => ({
|
|
554
|
-
...old,
|
|
555
|
-
...newColumnSizing
|
|
556
|
-
}));
|
|
557
|
-
}
|
|
558
|
-
};
|
|
559
|
-
const onMove = clientXPos => updateOffset('move', clientXPos);
|
|
560
|
-
const onEnd = clientXPos => {
|
|
561
|
-
updateOffset('end', clientXPos);
|
|
562
|
-
table.setColumnSizingInfo(old => ({
|
|
563
|
-
...old,
|
|
564
|
-
isResizingColumn: false,
|
|
565
|
-
startOffset: null,
|
|
566
|
-
startSize: null,
|
|
567
|
-
deltaOffset: null,
|
|
568
|
-
deltaPercentage: null,
|
|
569
|
-
columnSizingStart: []
|
|
570
|
-
}));
|
|
571
|
-
};
|
|
572
|
-
const contextDocument = _contextDocument || typeof document !== 'undefined' ? document : null;
|
|
573
|
-
const mouseEvents = {
|
|
574
|
-
moveHandler: e => onMove(e.clientX),
|
|
575
|
-
upHandler: e => {
|
|
576
|
-
contextDocument == null || contextDocument.removeEventListener('mousemove', mouseEvents.moveHandler);
|
|
577
|
-
contextDocument == null || contextDocument.removeEventListener('mouseup', mouseEvents.upHandler);
|
|
578
|
-
onEnd(e.clientX);
|
|
579
|
-
}
|
|
580
|
-
};
|
|
581
|
-
const touchEvents = {
|
|
582
|
-
moveHandler: e => {
|
|
583
|
-
if (e.cancelable) {
|
|
584
|
-
e.preventDefault();
|
|
585
|
-
e.stopPropagation();
|
|
586
|
-
}
|
|
587
|
-
onMove(e.touches[0].clientX);
|
|
588
|
-
return false;
|
|
589
|
-
},
|
|
590
|
-
upHandler: e => {
|
|
591
|
-
var _e$touches$;
|
|
592
|
-
contextDocument == null || contextDocument.removeEventListener('touchmove', touchEvents.moveHandler);
|
|
593
|
-
contextDocument == null || contextDocument.removeEventListener('touchend', touchEvents.upHandler);
|
|
594
|
-
if (e.cancelable) {
|
|
595
|
-
e.preventDefault();
|
|
596
|
-
e.stopPropagation();
|
|
597
|
-
}
|
|
598
|
-
onEnd((_e$touches$ = e.touches[0]) == null ? void 0 : _e$touches$.clientX);
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
|
-
const passiveIfSupported = passiveEventSupported() ? {
|
|
602
|
-
passive: false
|
|
603
|
-
} : false;
|
|
604
|
-
if (isTouchStartEvent(e)) {
|
|
605
|
-
contextDocument == null || contextDocument.addEventListener('touchmove', touchEvents.moveHandler, passiveIfSupported);
|
|
606
|
-
contextDocument == null || contextDocument.addEventListener('touchend', touchEvents.upHandler, passiveIfSupported);
|
|
607
|
-
} else {
|
|
608
|
-
contextDocument == null || contextDocument.addEventListener('mousemove', mouseEvents.moveHandler, passiveIfSupported);
|
|
609
|
-
contextDocument == null || contextDocument.addEventListener('mouseup', mouseEvents.upHandler, passiveIfSupported);
|
|
610
|
-
}
|
|
611
|
-
table.setColumnSizingInfo(old => ({
|
|
612
|
-
...old,
|
|
613
|
-
startOffset: clientX,
|
|
614
|
-
startSize,
|
|
615
|
-
deltaOffset: 0,
|
|
616
|
-
deltaPercentage: 0,
|
|
617
|
-
columnSizingStart,
|
|
618
|
-
isResizingColumn: column.id
|
|
619
|
-
}));
|
|
620
|
-
};
|
|
621
|
-
};
|
|
622
|
-
},
|
|
623
|
-
createTable: table => {
|
|
624
|
-
table.setColumnSizing = updater => table.options.onColumnSizingChange == null ? void 0 : table.options.onColumnSizingChange(updater);
|
|
625
|
-
table.setColumnSizingInfo = updater => table.options.onColumnSizingInfoChange == null ? void 0 : table.options.onColumnSizingInfoChange(updater);
|
|
626
|
-
table.resetColumnSizing = defaultState => {
|
|
627
|
-
var _table$initialState$c;
|
|
628
|
-
table.setColumnSizing(defaultState ? {} : (_table$initialState$c = table.initialState.columnSizing) != null ? _table$initialState$c : {});
|
|
629
|
-
};
|
|
630
|
-
table.resetHeaderSizeInfo = defaultState => {
|
|
631
|
-
var _table$initialState$c2;
|
|
632
|
-
table.setColumnSizingInfo(defaultState ? getDefaultColumnSizingInfoState() : (_table$initialState$c2 = table.initialState.columnSizingInfo) != null ? _table$initialState$c2 : getDefaultColumnSizingInfoState());
|
|
633
|
-
};
|
|
634
|
-
table.getTotalSize = () => {
|
|
635
|
-
var _table$getHeaderGroup, _table$getHeaderGroup2;
|
|
636
|
-
return (_table$getHeaderGroup = (_table$getHeaderGroup2 = table.getHeaderGroups()[0]) == null ? void 0 : _table$getHeaderGroup2.headers.reduce((sum, header) => {
|
|
637
|
-
return sum + header.getSize();
|
|
638
|
-
}, 0)) != null ? _table$getHeaderGroup : 0;
|
|
639
|
-
};
|
|
640
|
-
table.getLeftTotalSize = () => {
|
|
641
|
-
var _table$getLeftHeaderG, _table$getLeftHeaderG2;
|
|
642
|
-
return (_table$getLeftHeaderG = (_table$getLeftHeaderG2 = table.getLeftHeaderGroups()[0]) == null ? void 0 : _table$getLeftHeaderG2.headers.reduce((sum, header) => {
|
|
643
|
-
return sum + header.getSize();
|
|
644
|
-
}, 0)) != null ? _table$getLeftHeaderG : 0;
|
|
645
|
-
};
|
|
646
|
-
table.getCenterTotalSize = () => {
|
|
647
|
-
var _table$getCenterHeade, _table$getCenterHeade2;
|
|
648
|
-
return (_table$getCenterHeade = (_table$getCenterHeade2 = table.getCenterHeaderGroups()[0]) == null ? void 0 : _table$getCenterHeade2.headers.reduce((sum, header) => {
|
|
649
|
-
return sum + header.getSize();
|
|
650
|
-
}, 0)) != null ? _table$getCenterHeade : 0;
|
|
651
|
-
};
|
|
652
|
-
table.getRightTotalSize = () => {
|
|
653
|
-
var _table$getRightHeader, _table$getRightHeader2;
|
|
654
|
-
return (_table$getRightHeader = (_table$getRightHeader2 = table.getRightHeaderGroups()[0]) == null ? void 0 : _table$getRightHeader2.headers.reduce((sum, header) => {
|
|
655
|
-
return sum + header.getSize();
|
|
656
|
-
}, 0)) != null ? _table$getRightHeader : 0;
|
|
611
|
+
return column._getFacetedMinMaxValues();
|
|
657
612
|
};
|
|
658
613
|
}
|
|
659
614
|
};
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
615
|
+
|
|
616
|
+
const includesString = (row, columnId, filterValue) => {
|
|
617
|
+
var _row$getValue;
|
|
618
|
+
const search = filterValue.toLowerCase();
|
|
619
|
+
return Boolean((_row$getValue = row.getValue(columnId)) == null || (_row$getValue = _row$getValue.toString()) == null || (_row$getValue = _row$getValue.toLowerCase()) == null ? void 0 : _row$getValue.includes(search));
|
|
620
|
+
};
|
|
621
|
+
includesString.autoRemove = val => testFalsey(val);
|
|
622
|
+
const includesStringSensitive = (row, columnId, filterValue) => {
|
|
623
|
+
var _row$getValue2;
|
|
624
|
+
return Boolean((_row$getValue2 = row.getValue(columnId)) == null || (_row$getValue2 = _row$getValue2.toString()) == null ? void 0 : _row$getValue2.includes(filterValue));
|
|
625
|
+
};
|
|
626
|
+
includesStringSensitive.autoRemove = val => testFalsey(val);
|
|
627
|
+
const equalsString = (row, columnId, filterValue) => {
|
|
628
|
+
var _row$getValue3;
|
|
629
|
+
return ((_row$getValue3 = row.getValue(columnId)) == null || (_row$getValue3 = _row$getValue3.toString()) == null ? void 0 : _row$getValue3.toLowerCase()) === (filterValue == null ? void 0 : filterValue.toLowerCase());
|
|
630
|
+
};
|
|
631
|
+
equalsString.autoRemove = val => testFalsey(val);
|
|
632
|
+
const arrIncludes = (row, columnId, filterValue) => {
|
|
633
|
+
var _row$getValue4;
|
|
634
|
+
return (_row$getValue4 = row.getValue(columnId)) == null ? void 0 : _row$getValue4.includes(filterValue);
|
|
635
|
+
};
|
|
636
|
+
arrIncludes.autoRemove = val => testFalsey(val) || !(val != null && val.length);
|
|
637
|
+
const arrIncludesAll = (row, columnId, filterValue) => {
|
|
638
|
+
return !filterValue.some(val => {
|
|
639
|
+
var _row$getValue5;
|
|
640
|
+
return !((_row$getValue5 = row.getValue(columnId)) != null && _row$getValue5.includes(val));
|
|
641
|
+
});
|
|
642
|
+
};
|
|
643
|
+
arrIncludesAll.autoRemove = val => testFalsey(val) || !(val != null && val.length);
|
|
644
|
+
const arrIncludesSome = (row, columnId, filterValue) => {
|
|
645
|
+
return filterValue.some(val => {
|
|
646
|
+
var _row$getValue6;
|
|
647
|
+
return (_row$getValue6 = row.getValue(columnId)) == null ? void 0 : _row$getValue6.includes(val);
|
|
648
|
+
});
|
|
649
|
+
};
|
|
650
|
+
arrIncludesSome.autoRemove = val => testFalsey(val) || !(val != null && val.length);
|
|
651
|
+
const equals = (row, columnId, filterValue) => {
|
|
652
|
+
return row.getValue(columnId) === filterValue;
|
|
653
|
+
};
|
|
654
|
+
equals.autoRemove = val => testFalsey(val);
|
|
655
|
+
const weakEquals = (row, columnId, filterValue) => {
|
|
656
|
+
return row.getValue(columnId) == filterValue;
|
|
657
|
+
};
|
|
658
|
+
weakEquals.autoRemove = val => testFalsey(val);
|
|
659
|
+
const inNumberRange = (row, columnId, filterValue) => {
|
|
660
|
+
let [min, max] = filterValue;
|
|
661
|
+
const rowValue = row.getValue(columnId);
|
|
662
|
+
return rowValue >= min && rowValue <= max;
|
|
663
|
+
};
|
|
664
|
+
inNumberRange.resolveFilterValue = val => {
|
|
665
|
+
let [unsafeMin, unsafeMax] = val;
|
|
666
|
+
let parsedMin = typeof unsafeMin !== 'number' ? parseFloat(unsafeMin) : unsafeMin;
|
|
667
|
+
let parsedMax = typeof unsafeMax !== 'number' ? parseFloat(unsafeMax) : unsafeMax;
|
|
668
|
+
let min = unsafeMin === null || Number.isNaN(parsedMin) ? -Infinity : parsedMin;
|
|
669
|
+
let max = unsafeMax === null || Number.isNaN(parsedMax) ? Infinity : parsedMax;
|
|
670
|
+
if (min > max) {
|
|
671
|
+
const temp = min;
|
|
672
|
+
min = max;
|
|
673
|
+
max = temp;
|
|
676
674
|
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
675
|
+
return [min, max];
|
|
676
|
+
};
|
|
677
|
+
inNumberRange.autoRemove = val => testFalsey(val) || testFalsey(val[0]) && testFalsey(val[1]);
|
|
678
|
+
|
|
679
|
+
// Export
|
|
680
|
+
|
|
681
|
+
const filterFns = {
|
|
682
|
+
includesString,
|
|
683
|
+
includesStringSensitive,
|
|
684
|
+
equalsString,
|
|
685
|
+
arrIncludes,
|
|
686
|
+
arrIncludesAll,
|
|
687
|
+
arrIncludesSome,
|
|
688
|
+
equals,
|
|
689
|
+
weakEquals,
|
|
690
|
+
inNumberRange
|
|
691
|
+
};
|
|
692
|
+
// Utils
|
|
693
|
+
|
|
694
|
+
function testFalsey(val) {
|
|
695
|
+
return val === undefined || val === null || val === '';
|
|
682
696
|
}
|
|
683
697
|
|
|
684
698
|
//
|
|
685
699
|
|
|
686
|
-
const
|
|
700
|
+
const ColumnFiltering = {
|
|
701
|
+
getDefaultColumnDef: () => {
|
|
702
|
+
return {
|
|
703
|
+
filterFn: 'auto'
|
|
704
|
+
};
|
|
705
|
+
},
|
|
687
706
|
getInitialState: state => {
|
|
688
707
|
return {
|
|
689
|
-
|
|
708
|
+
columnFilters: [],
|
|
690
709
|
...state
|
|
691
710
|
};
|
|
692
711
|
},
|
|
693
712
|
getDefaultOptions: table => {
|
|
694
713
|
return {
|
|
695
|
-
|
|
696
|
-
|
|
714
|
+
onColumnFiltersChange: makeStateUpdater('columnFilters', table),
|
|
715
|
+
filterFromLeafRows: false,
|
|
716
|
+
maxLeafRowFilterDepth: 100
|
|
697
717
|
};
|
|
698
718
|
},
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
table._queue(() => {
|
|
706
|
-
registered = true;
|
|
707
|
-
});
|
|
708
|
-
return;
|
|
709
|
-
}
|
|
710
|
-
if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetExpanded) != null ? _ref : !table.options.manualExpanding) {
|
|
711
|
-
if (queued) return;
|
|
712
|
-
queued = true;
|
|
713
|
-
table._queue(() => {
|
|
714
|
-
table.resetExpanded();
|
|
715
|
-
queued = false;
|
|
716
|
-
});
|
|
719
|
+
createColumn: (column, table) => {
|
|
720
|
+
column.getAutoFilterFn = () => {
|
|
721
|
+
const firstRow = table.getCoreRowModel().flatRows[0];
|
|
722
|
+
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
|
723
|
+
if (typeof value === 'string') {
|
|
724
|
+
return filterFns.includesString;
|
|
717
725
|
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
table.toggleAllRowsExpanded = expanded => {
|
|
721
|
-
if (expanded != null ? expanded : !table.getIsAllRowsExpanded()) {
|
|
722
|
-
table.setExpanded(true);
|
|
723
|
-
} else {
|
|
724
|
-
table.setExpanded({});
|
|
726
|
+
if (typeof value === 'number') {
|
|
727
|
+
return filterFns.inNumberRange;
|
|
725
728
|
}
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
var _table$initialState$e, _table$initialState;
|
|
729
|
-
table.setExpanded(defaultState ? {} : (_table$initialState$e = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.expanded) != null ? _table$initialState$e : {});
|
|
730
|
-
};
|
|
731
|
-
table.getCanSomeRowsExpand = () => {
|
|
732
|
-
return table.getPrePaginationRowModel().flatRows.some(row => row.getCanExpand());
|
|
733
|
-
};
|
|
734
|
-
table.getToggleAllRowsExpandedHandler = () => {
|
|
735
|
-
return e => {
|
|
736
|
-
e.persist == null || e.persist();
|
|
737
|
-
table.toggleAllRowsExpanded();
|
|
738
|
-
};
|
|
739
|
-
};
|
|
740
|
-
table.getIsSomeRowsExpanded = () => {
|
|
741
|
-
const expanded = table.getState().expanded;
|
|
742
|
-
return expanded === true || Object.values(expanded).some(Boolean);
|
|
743
|
-
};
|
|
744
|
-
table.getIsAllRowsExpanded = () => {
|
|
745
|
-
const expanded = table.getState().expanded;
|
|
746
|
-
|
|
747
|
-
// If expanded is true, save some cycles and return true
|
|
748
|
-
if (typeof expanded === 'boolean') {
|
|
749
|
-
return expanded === true;
|
|
729
|
+
if (typeof value === 'boolean') {
|
|
730
|
+
return filterFns.equals;
|
|
750
731
|
}
|
|
751
|
-
if (
|
|
752
|
-
return
|
|
732
|
+
if (value !== null && typeof value === 'object') {
|
|
733
|
+
return filterFns.equals;
|
|
753
734
|
}
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
if (table.getRowModel().flatRows.some(row => !row.getIsExpanded())) {
|
|
757
|
-
return false;
|
|
735
|
+
if (Array.isArray(value)) {
|
|
736
|
+
return filterFns.arrIncludes;
|
|
758
737
|
}
|
|
759
|
-
|
|
760
|
-
// They must all be expanded :shrug:
|
|
761
|
-
return true;
|
|
738
|
+
return filterFns.weakEquals;
|
|
762
739
|
};
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
const splitId = id.split('.');
|
|
768
|
-
maxDepth = Math.max(maxDepth, splitId.length);
|
|
769
|
-
});
|
|
770
|
-
return maxDepth;
|
|
740
|
+
column.getFilterFn = () => {
|
|
741
|
+
var _table$options$filter, _table$options$filter2;
|
|
742
|
+
return isFunction(column.columnDef.filterFn) ? column.columnDef.filterFn : column.columnDef.filterFn === 'auto' ? column.getAutoFilterFn() : // @ts-ignore
|
|
743
|
+
(_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[column.columnDef.filterFn]) != null ? _table$options$filter : filterFns[column.columnDef.filterFn];
|
|
771
744
|
};
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
table._getExpandedRowModel = table.options.getExpandedRowModel(table);
|
|
776
|
-
}
|
|
777
|
-
if (table.options.manualExpanding || !table._getExpandedRowModel) {
|
|
778
|
-
return table.getPreExpandedRowModel();
|
|
779
|
-
}
|
|
780
|
-
return table._getExpandedRowModel();
|
|
745
|
+
column.getCanFilter = () => {
|
|
746
|
+
var _column$columnDef$ena, _table$options$enable, _table$options$enable2;
|
|
747
|
+
return ((_column$columnDef$ena = column.columnDef.enableColumnFilter) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnFilters) != null ? _table$options$enable : true) && ((_table$options$enable2 = table.options.enableFilters) != null ? _table$options$enable2 : true) && !!column.accessorFn;
|
|
781
748
|
};
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
table.
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
749
|
+
column.getIsFiltered = () => column.getFilterIndex() > -1;
|
|
750
|
+
column.getFilterValue = () => {
|
|
751
|
+
var _table$getState$colum;
|
|
752
|
+
return (_table$getState$colum = table.getState().columnFilters) == null || (_table$getState$colum = _table$getState$colum.find(d => d.id === column.id)) == null ? void 0 : _table$getState$colum.value;
|
|
753
|
+
};
|
|
754
|
+
column.getFilterIndex = () => {
|
|
755
|
+
var _table$getState$colum2, _table$getState$colum3;
|
|
756
|
+
return (_table$getState$colum2 = (_table$getState$colum3 = table.getState().columnFilters) == null ? void 0 : _table$getState$colum3.findIndex(d => d.id === column.id)) != null ? _table$getState$colum2 : -1;
|
|
757
|
+
};
|
|
758
|
+
column.setFilterValue = value => {
|
|
759
|
+
table.setColumnFilters(old => {
|
|
760
|
+
const filterFn = column.getFilterFn();
|
|
761
|
+
const previousFilter = old == null ? void 0 : old.find(d => d.id === column.id);
|
|
762
|
+
const newFilter = functionalUpdate(value, previousFilter ? previousFilter.value : undefined);
|
|
763
|
+
|
|
764
|
+
//
|
|
765
|
+
if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {
|
|
766
|
+
var _old$filter;
|
|
767
|
+
return (_old$filter = old == null ? void 0 : old.filter(d => d.id !== column.id)) != null ? _old$filter : [];
|
|
795
768
|
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
769
|
+
const newFilterObj = {
|
|
770
|
+
id: column.id,
|
|
771
|
+
value: newFilter
|
|
772
|
+
};
|
|
773
|
+
if (previousFilter) {
|
|
774
|
+
var _old$map;
|
|
775
|
+
return (_old$map = old == null ? void 0 : old.map(d => {
|
|
776
|
+
if (d.id === column.id) {
|
|
777
|
+
return newFilterObj;
|
|
778
|
+
}
|
|
779
|
+
return d;
|
|
780
|
+
})) != null ? _old$map : [];
|
|
802
781
|
}
|
|
803
|
-
if (
|
|
804
|
-
|
|
805
|
-
[row.id]: _,
|
|
806
|
-
...rest
|
|
807
|
-
} = oldExpanded;
|
|
808
|
-
return rest;
|
|
782
|
+
if (old != null && old.length) {
|
|
783
|
+
return [...old, newFilterObj];
|
|
809
784
|
}
|
|
810
|
-
return
|
|
785
|
+
return [newFilterObj];
|
|
811
786
|
});
|
|
812
787
|
};
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
788
|
+
},
|
|
789
|
+
createRow: (row, _table) => {
|
|
790
|
+
row.columnFilters = {};
|
|
791
|
+
row.columnFiltersMeta = {};
|
|
792
|
+
},
|
|
793
|
+
createTable: table => {
|
|
794
|
+
table.setColumnFilters = updater => {
|
|
795
|
+
const leafColumns = table.getAllLeafColumns();
|
|
796
|
+
const updateFn = old => {
|
|
797
|
+
var _functionalUpdate;
|
|
798
|
+
return (_functionalUpdate = functionalUpdate(updater, old)) == null ? void 0 : _functionalUpdate.filter(filter => {
|
|
799
|
+
const column = leafColumns.find(d => d.id === filter.id);
|
|
800
|
+
if (column) {
|
|
801
|
+
const filterFn = column.getFilterFn();
|
|
802
|
+
if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {
|
|
803
|
+
return false;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
return true;
|
|
807
|
+
});
|
|
808
|
+
};
|
|
809
|
+
table.options.onColumnFiltersChange == null || table.options.onColumnFiltersChange(updateFn);
|
|
817
810
|
};
|
|
818
|
-
|
|
819
|
-
var _table$
|
|
820
|
-
|
|
811
|
+
table.resetColumnFilters = defaultState => {
|
|
812
|
+
var _table$initialState$c, _table$initialState;
|
|
813
|
+
table.setColumnFilters(defaultState ? [] : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnFilters) != null ? _table$initialState$c : []);
|
|
821
814
|
};
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
currentRow = table.getRow(currentRow.parentId, true);
|
|
827
|
-
isFullyExpanded = currentRow.getIsExpanded();
|
|
815
|
+
table.getPreFilteredRowModel = () => table.getCoreRowModel();
|
|
816
|
+
table.getFilteredRowModel = () => {
|
|
817
|
+
if (!table._getFilteredRowModel && table.options.getFilteredRowModel) {
|
|
818
|
+
table._getFilteredRowModel = table.options.getFilteredRowModel(table);
|
|
828
819
|
}
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
return () => {
|
|
834
|
-
if (!canExpand) return;
|
|
835
|
-
row.toggleExpanded();
|
|
836
|
-
};
|
|
820
|
+
if (table.options.manualFiltering || !table._getFilteredRowModel) {
|
|
821
|
+
return table.getPreFilteredRowModel();
|
|
822
|
+
}
|
|
823
|
+
return table._getFilteredRowModel();
|
|
837
824
|
};
|
|
838
825
|
}
|
|
839
826
|
};
|
|
827
|
+
function shouldAutoRemoveFilter(filterFn, value, column) {
|
|
828
|
+
return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
|
|
829
|
+
}
|
|
840
830
|
|
|
841
|
-
const
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
return
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
var _row$getValue2;
|
|
849
|
-
return Boolean((_row$getValue2 = row.getValue(columnId)) == null || (_row$getValue2 = _row$getValue2.toString()) == null ? void 0 : _row$getValue2.includes(filterValue));
|
|
850
|
-
};
|
|
851
|
-
includesStringSensitive.autoRemove = val => testFalsey(val);
|
|
852
|
-
const equalsString = (row, columnId, filterValue) => {
|
|
853
|
-
var _row$getValue3;
|
|
854
|
-
return ((_row$getValue3 = row.getValue(columnId)) == null || (_row$getValue3 = _row$getValue3.toString()) == null ? void 0 : _row$getValue3.toLowerCase()) === (filterValue == null ? void 0 : filterValue.toLowerCase());
|
|
855
|
-
};
|
|
856
|
-
equalsString.autoRemove = val => testFalsey(val);
|
|
857
|
-
const arrIncludes = (row, columnId, filterValue) => {
|
|
858
|
-
var _row$getValue4;
|
|
859
|
-
return (_row$getValue4 = row.getValue(columnId)) == null ? void 0 : _row$getValue4.includes(filterValue);
|
|
831
|
+
const sum = (columnId, _leafRows, childRows) => {
|
|
832
|
+
// It's faster to just add the aggregations together instead of
|
|
833
|
+
// process leaf nodes individually
|
|
834
|
+
return childRows.reduce((sum, next) => {
|
|
835
|
+
const nextValue = next.getValue(columnId);
|
|
836
|
+
return sum + (typeof nextValue === 'number' ? nextValue : 0);
|
|
837
|
+
}, 0);
|
|
860
838
|
};
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
839
|
+
const min = (columnId, _leafRows, childRows) => {
|
|
840
|
+
let min;
|
|
841
|
+
childRows.forEach(row => {
|
|
842
|
+
const value = row.getValue(columnId);
|
|
843
|
+
if (value != null && (min > value || min === undefined && value >= value)) {
|
|
844
|
+
min = value;
|
|
845
|
+
}
|
|
866
846
|
});
|
|
847
|
+
return min;
|
|
867
848
|
};
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
849
|
+
const max = (columnId, _leafRows, childRows) => {
|
|
850
|
+
let max;
|
|
851
|
+
childRows.forEach(row => {
|
|
852
|
+
const value = row.getValue(columnId);
|
|
853
|
+
if (value != null && (max < value || max === undefined && value >= value)) {
|
|
854
|
+
max = value;
|
|
855
|
+
}
|
|
873
856
|
});
|
|
857
|
+
return max;
|
|
874
858
|
};
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
859
|
+
const extent = (columnId, _leafRows, childRows) => {
|
|
860
|
+
let min;
|
|
861
|
+
let max;
|
|
862
|
+
childRows.forEach(row => {
|
|
863
|
+
const value = row.getValue(columnId);
|
|
864
|
+
if (value != null) {
|
|
865
|
+
if (min === undefined) {
|
|
866
|
+
if (value >= value) min = max = value;
|
|
867
|
+
} else {
|
|
868
|
+
if (min > value) min = value;
|
|
869
|
+
if (max < value) max = value;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
});
|
|
873
|
+
return [min, max];
|
|
874
|
+
};
|
|
875
|
+
const mean = (columnId, leafRows) => {
|
|
876
|
+
let count = 0;
|
|
877
|
+
let sum = 0;
|
|
878
|
+
leafRows.forEach(row => {
|
|
879
|
+
let value = row.getValue(columnId);
|
|
880
|
+
if (value != null && (value = +value) >= value) {
|
|
881
|
+
++count, sum += value;
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
if (count) return sum / count;
|
|
885
|
+
return;
|
|
886
|
+
};
|
|
887
|
+
const median = (columnId, leafRows) => {
|
|
888
|
+
if (!leafRows.length) {
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
const values = leafRows.map(row => row.getValue(columnId));
|
|
892
|
+
if (!isNumberArray(values)) {
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
if (values.length === 1) {
|
|
896
|
+
return values[0];
|
|
897
|
+
}
|
|
898
|
+
const mid = Math.floor(values.length / 2);
|
|
899
|
+
const nums = values.sort((a, b) => a - b);
|
|
900
|
+
return values.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
|
|
901
|
+
};
|
|
902
|
+
const unique = (columnId, leafRows) => {
|
|
903
|
+
return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
|
|
904
|
+
};
|
|
905
|
+
const uniqueCount = (columnId, leafRows) => {
|
|
906
|
+
return new Set(leafRows.map(d => d.getValue(columnId))).size;
|
|
907
|
+
};
|
|
908
|
+
const count = (_columnId, leafRows) => {
|
|
909
|
+
return leafRows.length;
|
|
910
|
+
};
|
|
911
|
+
const aggregationFns = {
|
|
912
|
+
sum,
|
|
913
|
+
min,
|
|
914
|
+
max,
|
|
915
|
+
extent,
|
|
916
|
+
mean,
|
|
917
|
+
median,
|
|
918
|
+
unique,
|
|
919
|
+
uniqueCount,
|
|
920
|
+
count
|
|
921
|
+
};
|
|
922
|
+
|
|
923
|
+
//
|
|
924
|
+
|
|
925
|
+
const ColumnGrouping = {
|
|
926
|
+
getDefaultColumnDef: () => {
|
|
927
|
+
return {
|
|
928
|
+
aggregatedCell: props => {
|
|
929
|
+
var _toString, _props$getValue;
|
|
930
|
+
return (_toString = (_props$getValue = props.getValue()) == null || _props$getValue.toString == null ? void 0 : _props$getValue.toString()) != null ? _toString : null;
|
|
931
|
+
},
|
|
932
|
+
aggregationFn: 'auto'
|
|
933
|
+
};
|
|
934
|
+
},
|
|
935
|
+
getInitialState: state => {
|
|
936
|
+
return {
|
|
937
|
+
grouping: [],
|
|
938
|
+
...state
|
|
939
|
+
};
|
|
940
|
+
},
|
|
941
|
+
getDefaultOptions: table => {
|
|
942
|
+
return {
|
|
943
|
+
onGroupingChange: makeStateUpdater('grouping', table),
|
|
944
|
+
groupedColumnMode: 'reorder'
|
|
945
|
+
};
|
|
946
|
+
},
|
|
947
|
+
createColumn: (column, table) => {
|
|
948
|
+
column.toggleGrouping = () => {
|
|
949
|
+
table.setGrouping(old => {
|
|
950
|
+
// Find any existing grouping for this column
|
|
951
|
+
if (old != null && old.includes(column.id)) {
|
|
952
|
+
return old.filter(d => d !== column.id);
|
|
953
|
+
}
|
|
954
|
+
return [...(old != null ? old : []), column.id];
|
|
955
|
+
});
|
|
956
|
+
};
|
|
957
|
+
column.getCanGroup = () => {
|
|
958
|
+
var _ref, _ref2, _ref3, _column$columnDef$ena;
|
|
959
|
+
return (_ref = (_ref2 = (_ref3 = (_column$columnDef$ena = column.columnDef.enableGrouping) != null ? _column$columnDef$ena : true) != null ? _ref3 : table.options.enableGrouping) != null ? _ref2 : true) != null ? _ref : !!column.accessorFn;
|
|
960
|
+
};
|
|
961
|
+
column.getIsGrouped = () => {
|
|
962
|
+
var _table$getState$group;
|
|
963
|
+
return (_table$getState$group = table.getState().grouping) == null ? void 0 : _table$getState$group.includes(column.id);
|
|
964
|
+
};
|
|
965
|
+
column.getGroupedIndex = () => {
|
|
966
|
+
var _table$getState$group2;
|
|
967
|
+
return (_table$getState$group2 = table.getState().grouping) == null ? void 0 : _table$getState$group2.indexOf(column.id);
|
|
968
|
+
};
|
|
969
|
+
column.getToggleGroupingHandler = () => {
|
|
970
|
+
const canGroup = column.getCanGroup();
|
|
971
|
+
return () => {
|
|
972
|
+
if (!canGroup) return;
|
|
973
|
+
column.toggleGrouping();
|
|
974
|
+
};
|
|
975
|
+
};
|
|
976
|
+
column.getAutoAggregationFn = () => {
|
|
977
|
+
const firstRow = table.getCoreRowModel().flatRows[0];
|
|
978
|
+
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
|
979
|
+
if (typeof value === 'number') {
|
|
980
|
+
return aggregationFns.sum;
|
|
981
|
+
}
|
|
982
|
+
if (Object.prototype.toString.call(value) === '[object Date]') {
|
|
983
|
+
return aggregationFns.extent;
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
column.getAggregationFn = () => {
|
|
987
|
+
var _table$options$aggreg, _table$options$aggreg2;
|
|
988
|
+
if (!column) {
|
|
989
|
+
throw new Error();
|
|
990
|
+
}
|
|
991
|
+
return isFunction(column.columnDef.aggregationFn) ? column.columnDef.aggregationFn : column.columnDef.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_table$options$aggreg = (_table$options$aggreg2 = table.options.aggregationFns) == null ? void 0 : _table$options$aggreg2[column.columnDef.aggregationFn]) != null ? _table$options$aggreg : aggregationFns[column.columnDef.aggregationFn];
|
|
992
|
+
};
|
|
993
|
+
},
|
|
994
|
+
createTable: table => {
|
|
995
|
+
table.setGrouping = updater => table.options.onGroupingChange == null ? void 0 : table.options.onGroupingChange(updater);
|
|
996
|
+
table.resetGrouping = defaultState => {
|
|
997
|
+
var _table$initialState$g, _table$initialState;
|
|
998
|
+
table.setGrouping(defaultState ? [] : (_table$initialState$g = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.grouping) != null ? _table$initialState$g : []);
|
|
999
|
+
};
|
|
1000
|
+
table.getPreGroupedRowModel = () => table.getFilteredRowModel();
|
|
1001
|
+
table.getGroupedRowModel = () => {
|
|
1002
|
+
if (!table._getGroupedRowModel && table.options.getGroupedRowModel) {
|
|
1003
|
+
table._getGroupedRowModel = table.options.getGroupedRowModel(table);
|
|
1004
|
+
}
|
|
1005
|
+
if (table.options.manualGrouping || !table._getGroupedRowModel) {
|
|
1006
|
+
return table.getPreGroupedRowModel();
|
|
1007
|
+
}
|
|
1008
|
+
return table._getGroupedRowModel();
|
|
1009
|
+
};
|
|
1010
|
+
},
|
|
1011
|
+
createRow: (row, table) => {
|
|
1012
|
+
row.getIsGrouped = () => !!row.groupingColumnId;
|
|
1013
|
+
row.getGroupingValue = columnId => {
|
|
1014
|
+
if (row._groupingValuesCache.hasOwnProperty(columnId)) {
|
|
1015
|
+
return row._groupingValuesCache[columnId];
|
|
1016
|
+
}
|
|
1017
|
+
const column = table.getColumn(columnId);
|
|
1018
|
+
if (!(column != null && column.columnDef.getGroupingValue)) {
|
|
1019
|
+
return row.getValue(columnId);
|
|
1020
|
+
}
|
|
1021
|
+
row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(row.original);
|
|
1022
|
+
return row._groupingValuesCache[columnId];
|
|
1023
|
+
};
|
|
1024
|
+
row._groupingValuesCache = {};
|
|
1025
|
+
},
|
|
1026
|
+
createCell: (cell, column, row, table) => {
|
|
1027
|
+
cell.getIsGrouped = () => column.getIsGrouped() && column.id === row.groupingColumnId;
|
|
1028
|
+
cell.getIsPlaceholder = () => !cell.getIsGrouped() && column.getIsGrouped();
|
|
1029
|
+
cell.getIsAggregated = () => {
|
|
1030
|
+
var _row$subRows;
|
|
1031
|
+
return !cell.getIsGrouped() && !cell.getIsPlaceholder() && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
function orderColumns(leafColumns, grouping, groupedColumnMode) {
|
|
1036
|
+
if (!(grouping != null && grouping.length) || !groupedColumnMode) {
|
|
1037
|
+
return leafColumns;
|
|
1038
|
+
}
|
|
1039
|
+
const nonGroupingColumns = leafColumns.filter(col => !grouping.includes(col.id));
|
|
1040
|
+
if (groupedColumnMode === 'remove') {
|
|
1041
|
+
return nonGroupingColumns;
|
|
1042
|
+
}
|
|
1043
|
+
const groupingColumns = grouping.map(g => leafColumns.find(col => col.id === g)).filter(Boolean);
|
|
1044
|
+
return [...groupingColumns, ...nonGroupingColumns];
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
//
|
|
1048
|
+
|
|
1049
|
+
const ColumnOrdering = {
|
|
1050
|
+
getInitialState: state => {
|
|
1051
|
+
return {
|
|
1052
|
+
columnOrder: [],
|
|
1053
|
+
...state
|
|
1054
|
+
};
|
|
1055
|
+
},
|
|
1056
|
+
getDefaultOptions: table => {
|
|
1057
|
+
return {
|
|
1058
|
+
onColumnOrderChange: makeStateUpdater('columnOrder', table)
|
|
1059
|
+
};
|
|
1060
|
+
},
|
|
1061
|
+
createColumn: (column, table) => {
|
|
1062
|
+
column.getIndex = memo(position => [_getVisibleLeafColumns(table, position)], columns => columns.findIndex(d => d.id === column.id), getMemoOptions(table.options, 'debugColumns', 'getIndex'));
|
|
1063
|
+
column.getIsFirstColumn = position => {
|
|
1064
|
+
var _columns$;
|
|
1065
|
+
const columns = _getVisibleLeafColumns(table, position);
|
|
1066
|
+
return ((_columns$ = columns[0]) == null ? void 0 : _columns$.id) === column.id;
|
|
1067
|
+
};
|
|
1068
|
+
column.getIsLastColumn = position => {
|
|
1069
|
+
var _columns;
|
|
1070
|
+
const columns = _getVisibleLeafColumns(table, position);
|
|
1071
|
+
return ((_columns = columns[columns.length - 1]) == null ? void 0 : _columns.id) === column.id;
|
|
1072
|
+
};
|
|
1073
|
+
},
|
|
1074
|
+
createTable: table => {
|
|
1075
|
+
table.setColumnOrder = updater => table.options.onColumnOrderChange == null ? void 0 : table.options.onColumnOrderChange(updater);
|
|
1076
|
+
table.resetColumnOrder = defaultState => {
|
|
1077
|
+
var _table$initialState$c;
|
|
1078
|
+
table.setColumnOrder(defaultState ? [] : (_table$initialState$c = table.initialState.columnOrder) != null ? _table$initialState$c : []);
|
|
1079
|
+
};
|
|
1080
|
+
table._getOrderColumnsFn = memo(() => [table.getState().columnOrder, table.getState().grouping, table.options.groupedColumnMode], (columnOrder, grouping, groupedColumnMode) => columns => {
|
|
1081
|
+
// Sort grouped columns to the start of the column list
|
|
1082
|
+
// before the headers are built
|
|
1083
|
+
let orderedColumns = [];
|
|
1084
|
+
|
|
1085
|
+
// If there is no order, return the normal columns
|
|
1086
|
+
if (!(columnOrder != null && columnOrder.length)) {
|
|
1087
|
+
orderedColumns = columns;
|
|
1088
|
+
} else {
|
|
1089
|
+
const columnOrderCopy = [...columnOrder];
|
|
1090
|
+
|
|
1091
|
+
// If there is an order, make a copy of the columns
|
|
1092
|
+
const columnsCopy = [...columns];
|
|
1093
|
+
|
|
1094
|
+
// And make a new ordered array of the columns
|
|
1095
|
+
|
|
1096
|
+
// Loop over the columns and place them in order into the new array
|
|
1097
|
+
while (columnsCopy.length && columnOrderCopy.length) {
|
|
1098
|
+
const targetColumnId = columnOrderCopy.shift();
|
|
1099
|
+
const foundIndex = columnsCopy.findIndex(d => d.id === targetColumnId);
|
|
1100
|
+
if (foundIndex > -1) {
|
|
1101
|
+
orderedColumns.push(columnsCopy.splice(foundIndex, 1)[0]);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
// If there are any columns left, add them to the end
|
|
1106
|
+
orderedColumns = [...orderedColumns, ...columnsCopy];
|
|
1107
|
+
}
|
|
1108
|
+
return orderColumns(orderedColumns, grouping, groupedColumnMode);
|
|
1109
|
+
}, getMemoOptions(table.options, 'debugTable', '_getOrderColumnsFn'));
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
|
|
1113
|
+
//
|
|
1114
|
+
|
|
1115
|
+
const getDefaultColumnPinningState = () => ({
|
|
1116
|
+
left: [],
|
|
1117
|
+
right: []
|
|
1118
|
+
});
|
|
1119
|
+
const ColumnPinning = {
|
|
1120
|
+
getInitialState: state => {
|
|
1121
|
+
return {
|
|
1122
|
+
columnPinning: getDefaultColumnPinningState(),
|
|
1123
|
+
...state
|
|
1124
|
+
};
|
|
1125
|
+
},
|
|
1126
|
+
getDefaultOptions: table => {
|
|
1127
|
+
return {
|
|
1128
|
+
onColumnPinningChange: makeStateUpdater('columnPinning', table)
|
|
1129
|
+
};
|
|
1130
|
+
},
|
|
1131
|
+
createColumn: (column, table) => {
|
|
1132
|
+
column.pin = position => {
|
|
1133
|
+
const columnIds = column.getLeafColumns().map(d => d.id).filter(Boolean);
|
|
1134
|
+
table.setColumnPinning(old => {
|
|
1135
|
+
var _old$left3, _old$right3;
|
|
1136
|
+
if (position === 'right') {
|
|
1137
|
+
var _old$left, _old$right;
|
|
1138
|
+
return {
|
|
1139
|
+
left: ((_old$left = old == null ? void 0 : old.left) != null ? _old$left : []).filter(d => !(columnIds != null && columnIds.includes(d))),
|
|
1140
|
+
right: [...((_old$right = old == null ? void 0 : old.right) != null ? _old$right : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds]
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
if (position === 'left') {
|
|
1144
|
+
var _old$left2, _old$right2;
|
|
1145
|
+
return {
|
|
1146
|
+
left: [...((_old$left2 = old == null ? void 0 : old.left) != null ? _old$left2 : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds],
|
|
1147
|
+
right: ((_old$right2 = old == null ? void 0 : old.right) != null ? _old$right2 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
return {
|
|
1151
|
+
left: ((_old$left3 = old == null ? void 0 : old.left) != null ? _old$left3 : []).filter(d => !(columnIds != null && columnIds.includes(d))),
|
|
1152
|
+
right: ((_old$right3 = old == null ? void 0 : old.right) != null ? _old$right3 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
|
|
1153
|
+
};
|
|
1154
|
+
});
|
|
1155
|
+
};
|
|
1156
|
+
column.getCanPin = () => {
|
|
1157
|
+
const leafColumns = column.getLeafColumns();
|
|
1158
|
+
return leafColumns.some(d => {
|
|
1159
|
+
var _d$columnDef$enablePi, _ref, _table$options$enable;
|
|
1160
|
+
return ((_d$columnDef$enablePi = d.columnDef.enablePinning) != null ? _d$columnDef$enablePi : true) && ((_ref = (_table$options$enable = table.options.enableColumnPinning) != null ? _table$options$enable : table.options.enablePinning) != null ? _ref : true);
|
|
1161
|
+
});
|
|
1162
|
+
};
|
|
1163
|
+
column.getIsPinned = () => {
|
|
1164
|
+
const leafColumnIds = column.getLeafColumns().map(d => d.id);
|
|
1165
|
+
const {
|
|
1166
|
+
left,
|
|
1167
|
+
right
|
|
1168
|
+
} = table.getState().columnPinning;
|
|
1169
|
+
const isLeft = leafColumnIds.some(d => left == null ? void 0 : left.includes(d));
|
|
1170
|
+
const isRight = leafColumnIds.some(d => right == null ? void 0 : right.includes(d));
|
|
1171
|
+
return isLeft ? 'left' : isRight ? 'right' : false;
|
|
1172
|
+
};
|
|
1173
|
+
column.getPinnedIndex = () => {
|
|
1174
|
+
var _table$getState$colum, _table$getState$colum2;
|
|
1175
|
+
const position = column.getIsPinned();
|
|
1176
|
+
return position ? (_table$getState$colum = (_table$getState$colum2 = table.getState().columnPinning) == null || (_table$getState$colum2 = _table$getState$colum2[position]) == null ? void 0 : _table$getState$colum2.indexOf(column.id)) != null ? _table$getState$colum : -1 : 0;
|
|
1177
|
+
};
|
|
1178
|
+
},
|
|
1179
|
+
createRow: (row, table) => {
|
|
1180
|
+
row.getCenterVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allCells, left, right) => {
|
|
1181
|
+
const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
|
|
1182
|
+
return allCells.filter(d => !leftAndRight.includes(d.column.id));
|
|
1183
|
+
}, getMemoOptions(table.options, 'debugRows', 'getCenterVisibleCells'));
|
|
1184
|
+
row.getLeftVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left], (allCells, left) => {
|
|
1185
|
+
const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
|
|
1186
|
+
...d,
|
|
1187
|
+
position: 'left'
|
|
1188
|
+
}));
|
|
1189
|
+
return cells;
|
|
1190
|
+
}, getMemoOptions(table.options, 'debugRows', 'getLeftVisibleCells'));
|
|
1191
|
+
row.getRightVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.right], (allCells, right) => {
|
|
1192
|
+
const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
|
|
1193
|
+
...d,
|
|
1194
|
+
position: 'right'
|
|
1195
|
+
}));
|
|
1196
|
+
return cells;
|
|
1197
|
+
}, getMemoOptions(table.options, 'debugRows', 'getRightVisibleCells'));
|
|
1198
|
+
},
|
|
1199
|
+
createTable: table => {
|
|
1200
|
+
table.setColumnPinning = updater => table.options.onColumnPinningChange == null ? void 0 : table.options.onColumnPinningChange(updater);
|
|
1201
|
+
table.resetColumnPinning = defaultState => {
|
|
1202
|
+
var _table$initialState$c, _table$initialState;
|
|
1203
|
+
return table.setColumnPinning(defaultState ? getDefaultColumnPinningState() : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnPinning) != null ? _table$initialState$c : getDefaultColumnPinningState());
|
|
1204
|
+
};
|
|
1205
|
+
table.getIsSomeColumnsPinned = position => {
|
|
1206
|
+
var _pinningState$positio;
|
|
1207
|
+
const pinningState = table.getState().columnPinning;
|
|
1208
|
+
if (!position) {
|
|
1209
|
+
var _pinningState$left, _pinningState$right;
|
|
1210
|
+
return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
|
|
1211
|
+
}
|
|
1212
|
+
return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
|
|
1213
|
+
};
|
|
1214
|
+
table.getLeftLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left], (allColumns, left) => {
|
|
1215
|
+
return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
|
|
1216
|
+
}, getMemoOptions(table.options, 'debugColumns', 'getLeftLeafColumns'));
|
|
1217
|
+
table.getRightLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.right], (allColumns, right) => {
|
|
1218
|
+
return (right != null ? right : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
|
|
1219
|
+
}, getMemoOptions(table.options, 'debugColumns', 'getRightLeafColumns'));
|
|
1220
|
+
table.getCenterLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, left, right) => {
|
|
1221
|
+
const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
|
|
1222
|
+
return allColumns.filter(d => !leftAndRight.includes(d.id));
|
|
1223
|
+
}, getMemoOptions(table.options, 'debugColumns', 'getCenterLeafColumns'));
|
|
1224
|
+
}
|
|
882
1225
|
};
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
1226
|
+
|
|
1227
|
+
//
|
|
1228
|
+
|
|
1229
|
+
//
|
|
1230
|
+
|
|
1231
|
+
const defaultColumnSizing = {
|
|
1232
|
+
size: 150,
|
|
1233
|
+
minSize: 20,
|
|
1234
|
+
maxSize: Number.MAX_SAFE_INTEGER
|
|
888
1235
|
};
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
1236
|
+
const getDefaultColumnSizingInfoState = () => ({
|
|
1237
|
+
startOffset: null,
|
|
1238
|
+
startSize: null,
|
|
1239
|
+
deltaOffset: null,
|
|
1240
|
+
deltaPercentage: null,
|
|
1241
|
+
isResizingColumn: false,
|
|
1242
|
+
columnSizingStart: []
|
|
1243
|
+
});
|
|
1244
|
+
const ColumnSizing = {
|
|
1245
|
+
getDefaultColumnDef: () => {
|
|
1246
|
+
return defaultColumnSizing;
|
|
1247
|
+
},
|
|
1248
|
+
getInitialState: state => {
|
|
1249
|
+
return {
|
|
1250
|
+
columnSizing: {},
|
|
1251
|
+
columnSizingInfo: getDefaultColumnSizingInfoState(),
|
|
1252
|
+
...state
|
|
1253
|
+
};
|
|
1254
|
+
},
|
|
1255
|
+
getDefaultOptions: table => {
|
|
1256
|
+
return {
|
|
1257
|
+
columnResizeMode: 'onEnd',
|
|
1258
|
+
columnResizeDirection: 'ltr',
|
|
1259
|
+
onColumnSizingChange: makeStateUpdater('columnSizing', table),
|
|
1260
|
+
onColumnSizingInfoChange: makeStateUpdater('columnSizingInfo', table)
|
|
1261
|
+
};
|
|
1262
|
+
},
|
|
1263
|
+
createColumn: (column, table) => {
|
|
1264
|
+
column.getSize = () => {
|
|
1265
|
+
var _column$columnDef$min, _ref, _column$columnDef$max;
|
|
1266
|
+
const columnSize = table.getState().columnSizing[column.id];
|
|
1267
|
+
return Math.min(Math.max((_column$columnDef$min = column.columnDef.minSize) != null ? _column$columnDef$min : defaultColumnSizing.minSize, (_ref = columnSize != null ? columnSize : column.columnDef.size) != null ? _ref : defaultColumnSizing.size), (_column$columnDef$max = column.columnDef.maxSize) != null ? _column$columnDef$max : defaultColumnSizing.maxSize);
|
|
1268
|
+
};
|
|
1269
|
+
column.getStart = memo(position => [position, _getVisibleLeafColumns(table, position), table.getState().columnSizing], (position, columns) => columns.slice(0, column.getIndex(position)).reduce((sum, column) => sum + column.getSize(), 0), getMemoOptions(table.options, 'debugColumns', 'getStart'));
|
|
1270
|
+
column.getAfter = memo(position => [position, _getVisibleLeafColumns(table, position), table.getState().columnSizing], (position, columns) => columns.slice(column.getIndex(position) + 1).reduce((sum, column) => sum + column.getSize(), 0), getMemoOptions(table.options, 'debugColumns', 'getAfter'));
|
|
1271
|
+
column.resetSize = () => {
|
|
1272
|
+
table.setColumnSizing(_ref2 => {
|
|
1273
|
+
let {
|
|
1274
|
+
[column.id]: _,
|
|
1275
|
+
...rest
|
|
1276
|
+
} = _ref2;
|
|
1277
|
+
return rest;
|
|
1278
|
+
});
|
|
1279
|
+
};
|
|
1280
|
+
column.getCanResize = () => {
|
|
1281
|
+
var _column$columnDef$ena, _table$options$enable;
|
|
1282
|
+
return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnResizing) != null ? _table$options$enable : true);
|
|
1283
|
+
};
|
|
1284
|
+
column.getIsResizing = () => {
|
|
1285
|
+
return table.getState().columnSizingInfo.isResizingColumn === column.id;
|
|
1286
|
+
};
|
|
1287
|
+
},
|
|
1288
|
+
createHeader: (header, table) => {
|
|
1289
|
+
header.getSize = () => {
|
|
1290
|
+
let sum = 0;
|
|
1291
|
+
const recurse = header => {
|
|
1292
|
+
if (header.subHeaders.length) {
|
|
1293
|
+
header.subHeaders.forEach(recurse);
|
|
1294
|
+
} else {
|
|
1295
|
+
var _header$column$getSiz;
|
|
1296
|
+
sum += (_header$column$getSiz = header.column.getSize()) != null ? _header$column$getSiz : 0;
|
|
1297
|
+
}
|
|
1298
|
+
};
|
|
1299
|
+
recurse(header);
|
|
1300
|
+
return sum;
|
|
1301
|
+
};
|
|
1302
|
+
header.getStart = () => {
|
|
1303
|
+
if (header.index > 0) {
|
|
1304
|
+
const prevSiblingHeader = header.headerGroup.headers[header.index - 1];
|
|
1305
|
+
return prevSiblingHeader.getStart() + prevSiblingHeader.getSize();
|
|
1306
|
+
}
|
|
1307
|
+
return 0;
|
|
1308
|
+
};
|
|
1309
|
+
header.getResizeHandler = _contextDocument => {
|
|
1310
|
+
const column = table.getColumn(header.column.id);
|
|
1311
|
+
const canResize = column == null ? void 0 : column.getCanResize();
|
|
1312
|
+
return e => {
|
|
1313
|
+
if (!column || !canResize) {
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
e.persist == null || e.persist();
|
|
1317
|
+
if (isTouchStartEvent(e)) {
|
|
1318
|
+
// lets not respond to multiple touches (e.g. 2 or 3 fingers)
|
|
1319
|
+
if (e.touches && e.touches.length > 1) {
|
|
1320
|
+
return;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
const startSize = header.getSize();
|
|
1324
|
+
const columnSizingStart = header ? header.getLeafHeaders().map(d => [d.column.id, d.column.getSize()]) : [[column.id, column.getSize()]];
|
|
1325
|
+
const clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
|
|
1326
|
+
const newColumnSizing = {};
|
|
1327
|
+
const updateOffset = (eventType, clientXPos) => {
|
|
1328
|
+
if (typeof clientXPos !== 'number') {
|
|
1329
|
+
return;
|
|
1330
|
+
}
|
|
1331
|
+
table.setColumnSizingInfo(old => {
|
|
1332
|
+
var _old$startOffset, _old$startSize;
|
|
1333
|
+
const deltaDirection = table.options.columnResizeDirection === 'rtl' ? -1 : 1;
|
|
1334
|
+
const deltaOffset = (clientXPos - ((_old$startOffset = old == null ? void 0 : old.startOffset) != null ? _old$startOffset : 0)) * deltaDirection;
|
|
1335
|
+
const deltaPercentage = Math.max(deltaOffset / ((_old$startSize = old == null ? void 0 : old.startSize) != null ? _old$startSize : 0), -0.999999);
|
|
1336
|
+
old.columnSizingStart.forEach(_ref3 => {
|
|
1337
|
+
let [columnId, headerSize] = _ref3;
|
|
1338
|
+
newColumnSizing[columnId] = Math.round(Math.max(headerSize + headerSize * deltaPercentage, 0) * 100) / 100;
|
|
1339
|
+
});
|
|
1340
|
+
return {
|
|
1341
|
+
...old,
|
|
1342
|
+
deltaOffset,
|
|
1343
|
+
deltaPercentage
|
|
1344
|
+
};
|
|
1345
|
+
});
|
|
1346
|
+
if (table.options.columnResizeMode === 'onChange' || eventType === 'end') {
|
|
1347
|
+
table.setColumnSizing(old => ({
|
|
1348
|
+
...old,
|
|
1349
|
+
...newColumnSizing
|
|
1350
|
+
}));
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1353
|
+
const onMove = clientXPos => updateOffset('move', clientXPos);
|
|
1354
|
+
const onEnd = clientXPos => {
|
|
1355
|
+
updateOffset('end', clientXPos);
|
|
1356
|
+
table.setColumnSizingInfo(old => ({
|
|
1357
|
+
...old,
|
|
1358
|
+
isResizingColumn: false,
|
|
1359
|
+
startOffset: null,
|
|
1360
|
+
startSize: null,
|
|
1361
|
+
deltaOffset: null,
|
|
1362
|
+
deltaPercentage: null,
|
|
1363
|
+
columnSizingStart: []
|
|
1364
|
+
}));
|
|
1365
|
+
};
|
|
1366
|
+
const contextDocument = _contextDocument || typeof document !== 'undefined' ? document : null;
|
|
1367
|
+
const mouseEvents = {
|
|
1368
|
+
moveHandler: e => onMove(e.clientX),
|
|
1369
|
+
upHandler: e => {
|
|
1370
|
+
contextDocument == null || contextDocument.removeEventListener('mousemove', mouseEvents.moveHandler);
|
|
1371
|
+
contextDocument == null || contextDocument.removeEventListener('mouseup', mouseEvents.upHandler);
|
|
1372
|
+
onEnd(e.clientX);
|
|
1373
|
+
}
|
|
1374
|
+
};
|
|
1375
|
+
const touchEvents = {
|
|
1376
|
+
moveHandler: e => {
|
|
1377
|
+
if (e.cancelable) {
|
|
1378
|
+
e.preventDefault();
|
|
1379
|
+
e.stopPropagation();
|
|
1380
|
+
}
|
|
1381
|
+
onMove(e.touches[0].clientX);
|
|
1382
|
+
return false;
|
|
1383
|
+
},
|
|
1384
|
+
upHandler: e => {
|
|
1385
|
+
var _e$touches$;
|
|
1386
|
+
contextDocument == null || contextDocument.removeEventListener('touchmove', touchEvents.moveHandler);
|
|
1387
|
+
contextDocument == null || contextDocument.removeEventListener('touchend', touchEvents.upHandler);
|
|
1388
|
+
if (e.cancelable) {
|
|
1389
|
+
e.preventDefault();
|
|
1390
|
+
e.stopPropagation();
|
|
1391
|
+
}
|
|
1392
|
+
onEnd((_e$touches$ = e.touches[0]) == null ? void 0 : _e$touches$.clientX);
|
|
1393
|
+
}
|
|
1394
|
+
};
|
|
1395
|
+
const passiveIfSupported = passiveEventSupported() ? {
|
|
1396
|
+
passive: false
|
|
1397
|
+
} : false;
|
|
1398
|
+
if (isTouchStartEvent(e)) {
|
|
1399
|
+
contextDocument == null || contextDocument.addEventListener('touchmove', touchEvents.moveHandler, passiveIfSupported);
|
|
1400
|
+
contextDocument == null || contextDocument.addEventListener('touchend', touchEvents.upHandler, passiveIfSupported);
|
|
1401
|
+
} else {
|
|
1402
|
+
contextDocument == null || contextDocument.addEventListener('mousemove', mouseEvents.moveHandler, passiveIfSupported);
|
|
1403
|
+
contextDocument == null || contextDocument.addEventListener('mouseup', mouseEvents.upHandler, passiveIfSupported);
|
|
1404
|
+
}
|
|
1405
|
+
table.setColumnSizingInfo(old => ({
|
|
1406
|
+
...old,
|
|
1407
|
+
startOffset: clientX,
|
|
1408
|
+
startSize,
|
|
1409
|
+
deltaOffset: 0,
|
|
1410
|
+
deltaPercentage: 0,
|
|
1411
|
+
columnSizingStart,
|
|
1412
|
+
isResizingColumn: column.id
|
|
1413
|
+
}));
|
|
1414
|
+
};
|
|
1415
|
+
};
|
|
1416
|
+
},
|
|
1417
|
+
createTable: table => {
|
|
1418
|
+
table.setColumnSizing = updater => table.options.onColumnSizingChange == null ? void 0 : table.options.onColumnSizingChange(updater);
|
|
1419
|
+
table.setColumnSizingInfo = updater => table.options.onColumnSizingInfoChange == null ? void 0 : table.options.onColumnSizingInfoChange(updater);
|
|
1420
|
+
table.resetColumnSizing = defaultState => {
|
|
1421
|
+
var _table$initialState$c;
|
|
1422
|
+
table.setColumnSizing(defaultState ? {} : (_table$initialState$c = table.initialState.columnSizing) != null ? _table$initialState$c : {});
|
|
1423
|
+
};
|
|
1424
|
+
table.resetHeaderSizeInfo = defaultState => {
|
|
1425
|
+
var _table$initialState$c2;
|
|
1426
|
+
table.setColumnSizingInfo(defaultState ? getDefaultColumnSizingInfoState() : (_table$initialState$c2 = table.initialState.columnSizingInfo) != null ? _table$initialState$c2 : getDefaultColumnSizingInfoState());
|
|
1427
|
+
};
|
|
1428
|
+
table.getTotalSize = () => {
|
|
1429
|
+
var _table$getHeaderGroup, _table$getHeaderGroup2;
|
|
1430
|
+
return (_table$getHeaderGroup = (_table$getHeaderGroup2 = table.getHeaderGroups()[0]) == null ? void 0 : _table$getHeaderGroup2.headers.reduce((sum, header) => {
|
|
1431
|
+
return sum + header.getSize();
|
|
1432
|
+
}, 0)) != null ? _table$getHeaderGroup : 0;
|
|
1433
|
+
};
|
|
1434
|
+
table.getLeftTotalSize = () => {
|
|
1435
|
+
var _table$getLeftHeaderG, _table$getLeftHeaderG2;
|
|
1436
|
+
return (_table$getLeftHeaderG = (_table$getLeftHeaderG2 = table.getLeftHeaderGroups()[0]) == null ? void 0 : _table$getLeftHeaderG2.headers.reduce((sum, header) => {
|
|
1437
|
+
return sum + header.getSize();
|
|
1438
|
+
}, 0)) != null ? _table$getLeftHeaderG : 0;
|
|
1439
|
+
};
|
|
1440
|
+
table.getCenterTotalSize = () => {
|
|
1441
|
+
var _table$getCenterHeade, _table$getCenterHeade2;
|
|
1442
|
+
return (_table$getCenterHeade = (_table$getCenterHeade2 = table.getCenterHeaderGroups()[0]) == null ? void 0 : _table$getCenterHeade2.headers.reduce((sum, header) => {
|
|
1443
|
+
return sum + header.getSize();
|
|
1444
|
+
}, 0)) != null ? _table$getCenterHeade : 0;
|
|
1445
|
+
};
|
|
1446
|
+
table.getRightTotalSize = () => {
|
|
1447
|
+
var _table$getRightHeader, _table$getRightHeader2;
|
|
1448
|
+
return (_table$getRightHeader = (_table$getRightHeader2 = table.getRightHeaderGroups()[0]) == null ? void 0 : _table$getRightHeader2.headers.reduce((sum, header) => {
|
|
1449
|
+
return sum + header.getSize();
|
|
1450
|
+
}, 0)) != null ? _table$getRightHeader : 0;
|
|
1451
|
+
};
|
|
899
1452
|
}
|
|
900
|
-
return [min, max];
|
|
901
|
-
};
|
|
902
|
-
inNumberRange.autoRemove = val => testFalsey(val) || testFalsey(val[0]) && testFalsey(val[1]);
|
|
903
|
-
|
|
904
|
-
// Export
|
|
905
|
-
|
|
906
|
-
const filterFns = {
|
|
907
|
-
includesString,
|
|
908
|
-
includesStringSensitive,
|
|
909
|
-
equalsString,
|
|
910
|
-
arrIncludes,
|
|
911
|
-
arrIncludesAll,
|
|
912
|
-
arrIncludesSome,
|
|
913
|
-
equals,
|
|
914
|
-
weakEquals,
|
|
915
|
-
inNumberRange
|
|
916
1453
|
};
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
1454
|
+
let passiveSupported = null;
|
|
1455
|
+
function passiveEventSupported() {
|
|
1456
|
+
if (typeof passiveSupported === 'boolean') return passiveSupported;
|
|
1457
|
+
let supported = false;
|
|
1458
|
+
try {
|
|
1459
|
+
const options = {
|
|
1460
|
+
get passive() {
|
|
1461
|
+
supported = true;
|
|
1462
|
+
return false;
|
|
1463
|
+
}
|
|
1464
|
+
};
|
|
1465
|
+
const noop = () => {};
|
|
1466
|
+
window.addEventListener('test', noop, options);
|
|
1467
|
+
window.removeEventListener('test', noop);
|
|
1468
|
+
} catch (err) {
|
|
1469
|
+
supported = false;
|
|
1470
|
+
}
|
|
1471
|
+
passiveSupported = supported;
|
|
1472
|
+
return passiveSupported;
|
|
1473
|
+
}
|
|
1474
|
+
function isTouchStartEvent(e) {
|
|
1475
|
+
return e.type === 'touchstart';
|
|
921
1476
|
}
|
|
922
1477
|
|
|
923
1478
|
//
|
|
924
1479
|
|
|
925
|
-
const
|
|
926
|
-
getDefaultColumnDef: () => {
|
|
927
|
-
return {
|
|
928
|
-
filterFn: 'auto'
|
|
929
|
-
};
|
|
930
|
-
},
|
|
1480
|
+
const ColumnVisibility = {
|
|
931
1481
|
getInitialState: state => {
|
|
932
1482
|
return {
|
|
933
|
-
|
|
934
|
-
globalFilter: undefined,
|
|
935
|
-
// filtersProgress: 1,
|
|
936
|
-
// facetProgress: {},
|
|
1483
|
+
columnVisibility: {},
|
|
937
1484
|
...state
|
|
938
1485
|
};
|
|
939
1486
|
},
|
|
940
1487
|
getDefaultOptions: table => {
|
|
941
1488
|
return {
|
|
942
|
-
|
|
943
|
-
onGlobalFilterChange: makeStateUpdater('globalFilter', table),
|
|
944
|
-
filterFromLeafRows: false,
|
|
945
|
-
maxLeafRowFilterDepth: 100,
|
|
946
|
-
globalFilterFn: 'auto',
|
|
947
|
-
getColumnCanGlobalFilter: column => {
|
|
948
|
-
var _table$getCoreRowMode;
|
|
949
|
-
const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) == null || (_table$getCoreRowMode = _table$getCoreRowMode._getAllCellsByColumnId()[column.id]) == null ? void 0 : _table$getCoreRowMode.getValue();
|
|
950
|
-
return typeof value === 'string' || typeof value === 'number';
|
|
951
|
-
}
|
|
1489
|
+
onColumnVisibilityChange: makeStateUpdater('columnVisibility', table)
|
|
952
1490
|
};
|
|
953
1491
|
},
|
|
954
1492
|
createColumn: (column, table) => {
|
|
955
|
-
column.
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
if (typeof value === 'number') {
|
|
962
|
-
return filterFns.inNumberRange;
|
|
963
|
-
}
|
|
964
|
-
if (typeof value === 'boolean') {
|
|
965
|
-
return filterFns.equals;
|
|
966
|
-
}
|
|
967
|
-
if (value !== null && typeof value === 'object') {
|
|
968
|
-
return filterFns.equals;
|
|
969
|
-
}
|
|
970
|
-
if (Array.isArray(value)) {
|
|
971
|
-
return filterFns.arrIncludes;
|
|
1493
|
+
column.toggleVisibility = value => {
|
|
1494
|
+
if (column.getCanHide()) {
|
|
1495
|
+
table.setColumnVisibility(old => ({
|
|
1496
|
+
...old,
|
|
1497
|
+
[column.id]: value != null ? value : !column.getIsVisible()
|
|
1498
|
+
}));
|
|
972
1499
|
}
|
|
973
|
-
return filterFns.weakEquals;
|
|
974
|
-
};
|
|
975
|
-
column.getFilterFn = () => {
|
|
976
|
-
var _table$options$filter, _table$options$filter2;
|
|
977
|
-
return isFunction(column.columnDef.filterFn) ? column.columnDef.filterFn : column.columnDef.filterFn === 'auto' ? column.getAutoFilterFn() : // @ts-ignore
|
|
978
|
-
(_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[column.columnDef.filterFn]) != null ? _table$options$filter : filterFns[column.columnDef.filterFn];
|
|
979
|
-
};
|
|
980
|
-
column.getCanFilter = () => {
|
|
981
|
-
var _column$columnDef$ena, _table$options$enable, _table$options$enable2;
|
|
982
|
-
return ((_column$columnDef$ena = column.columnDef.enableColumnFilter) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnFilters) != null ? _table$options$enable : true) && ((_table$options$enable2 = table.options.enableFilters) != null ? _table$options$enable2 : true) && !!column.accessorFn;
|
|
983
|
-
};
|
|
984
|
-
column.getCanGlobalFilter = () => {
|
|
985
|
-
var _column$columnDef$ena2, _table$options$enable3, _table$options$enable4, _table$options$getCol;
|
|
986
|
-
return ((_column$columnDef$ena2 = column.columnDef.enableGlobalFilter) != null ? _column$columnDef$ena2 : true) && ((_table$options$enable3 = table.options.enableGlobalFilter) != null ? _table$options$enable3 : true) && ((_table$options$enable4 = table.options.enableFilters) != null ? _table$options$enable4 : true) && ((_table$options$getCol = table.options.getColumnCanGlobalFilter == null ? void 0 : table.options.getColumnCanGlobalFilter(column)) != null ? _table$options$getCol : true) && !!column.accessorFn;
|
|
987
|
-
};
|
|
988
|
-
column.getIsFiltered = () => column.getFilterIndex() > -1;
|
|
989
|
-
column.getFilterValue = () => {
|
|
990
|
-
var _table$getState$colum;
|
|
991
|
-
return (_table$getState$colum = table.getState().columnFilters) == null || (_table$getState$colum = _table$getState$colum.find(d => d.id === column.id)) == null ? void 0 : _table$getState$colum.value;
|
|
992
|
-
};
|
|
993
|
-
column.getFilterIndex = () => {
|
|
994
|
-
var _table$getState$colum2, _table$getState$colum3;
|
|
995
|
-
return (_table$getState$colum2 = (_table$getState$colum3 = table.getState().columnFilters) == null ? void 0 : _table$getState$colum3.findIndex(d => d.id === column.id)) != null ? _table$getState$colum2 : -1;
|
|
996
|
-
};
|
|
997
|
-
column.setFilterValue = value => {
|
|
998
|
-
table.setColumnFilters(old => {
|
|
999
|
-
const filterFn = column.getFilterFn();
|
|
1000
|
-
const previousfilter = old == null ? void 0 : old.find(d => d.id === column.id);
|
|
1001
|
-
const newFilter = functionalUpdate(value, previousfilter ? previousfilter.value : undefined);
|
|
1002
|
-
|
|
1003
|
-
//
|
|
1004
|
-
if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {
|
|
1005
|
-
var _old$filter;
|
|
1006
|
-
return (_old$filter = old == null ? void 0 : old.filter(d => d.id !== column.id)) != null ? _old$filter : [];
|
|
1007
|
-
}
|
|
1008
|
-
const newFilterObj = {
|
|
1009
|
-
id: column.id,
|
|
1010
|
-
value: newFilter
|
|
1011
|
-
};
|
|
1012
|
-
if (previousfilter) {
|
|
1013
|
-
var _old$map;
|
|
1014
|
-
return (_old$map = old == null ? void 0 : old.map(d => {
|
|
1015
|
-
if (d.id === column.id) {
|
|
1016
|
-
return newFilterObj;
|
|
1017
|
-
}
|
|
1018
|
-
return d;
|
|
1019
|
-
})) != null ? _old$map : [];
|
|
1020
|
-
}
|
|
1021
|
-
if (old != null && old.length) {
|
|
1022
|
-
return [...old, newFilterObj];
|
|
1023
|
-
}
|
|
1024
|
-
return [newFilterObj];
|
|
1025
|
-
});
|
|
1026
1500
|
};
|
|
1027
|
-
column.
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
}
|
|
1032
|
-
return column._getFacetedRowModel();
|
|
1501
|
+
column.getIsVisible = () => {
|
|
1502
|
+
var _ref, _table$getState$colum;
|
|
1503
|
+
const childColumns = column.columns;
|
|
1504
|
+
return (_ref = childColumns.length ? childColumns.some(c => c.getIsVisible()) : (_table$getState$colum = table.getState().columnVisibility) == null ? void 0 : _table$getState$colum[column.id]) != null ? _ref : true;
|
|
1033
1505
|
};
|
|
1034
|
-
column.
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
return new Map();
|
|
1038
|
-
}
|
|
1039
|
-
return column._getFacetedUniqueValues();
|
|
1506
|
+
column.getCanHide = () => {
|
|
1507
|
+
var _column$columnDef$ena, _table$options$enable;
|
|
1508
|
+
return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableHiding) != null ? _table$options$enable : true);
|
|
1040
1509
|
};
|
|
1041
|
-
column.
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
}
|
|
1046
|
-
return column._getFacetedMinMaxValues();
|
|
1510
|
+
column.getToggleVisibilityHandler = () => {
|
|
1511
|
+
return e => {
|
|
1512
|
+
column.toggleVisibility == null || column.toggleVisibility(e.target.checked);
|
|
1513
|
+
};
|
|
1047
1514
|
};
|
|
1048
|
-
// () => [column.getFacetedRowModel()],
|
|
1049
|
-
// facetedRowModel => getRowModelMinMaxValues(facetedRowModel, column.id),
|
|
1050
1515
|
},
|
|
1051
1516
|
createRow: (row, table) => {
|
|
1052
|
-
row.
|
|
1053
|
-
|
|
1517
|
+
row._getAllVisibleCells = memo(() => [row.getAllCells(), table.getState().columnVisibility], cells => {
|
|
1518
|
+
return cells.filter(cell => cell.column.getIsVisible());
|
|
1519
|
+
}, getMemoOptions(table.options, 'debugRows', '_getAllVisibleCells'));
|
|
1520
|
+
row.getVisibleCells = memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], getMemoOptions(table.options, 'debugRows', 'getVisibleCells'));
|
|
1054
1521
|
},
|
|
1055
1522
|
createTable: table => {
|
|
1056
|
-
|
|
1057
|
-
return
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
var _table$options$filter3, _table$options$filter4;
|
|
1061
|
-
const {
|
|
1062
|
-
globalFilterFn: globalFilterFn
|
|
1063
|
-
} = table.options;
|
|
1064
|
-
return isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === 'auto' ? table.getGlobalAutoFilterFn() : // @ts-ignore
|
|
1065
|
-
(_table$options$filter3 = (_table$options$filter4 = table.options.filterFns) == null ? void 0 : _table$options$filter4[globalFilterFn]) != null ? _table$options$filter3 : filterFns[globalFilterFn];
|
|
1066
|
-
};
|
|
1067
|
-
table.setColumnFilters = updater => {
|
|
1068
|
-
const leafColumns = table.getAllLeafColumns();
|
|
1069
|
-
const updateFn = old => {
|
|
1070
|
-
var _functionalUpdate;
|
|
1071
|
-
return (_functionalUpdate = functionalUpdate(updater, old)) == null ? void 0 : _functionalUpdate.filter(filter => {
|
|
1072
|
-
const column = leafColumns.find(d => d.id === filter.id);
|
|
1073
|
-
if (column) {
|
|
1074
|
-
const filterFn = column.getFilterFn();
|
|
1075
|
-
if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {
|
|
1076
|
-
return false;
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
return true;
|
|
1080
|
-
});
|
|
1081
|
-
};
|
|
1082
|
-
table.options.onColumnFiltersChange == null || table.options.onColumnFiltersChange(updateFn);
|
|
1083
|
-
};
|
|
1084
|
-
table.setGlobalFilter = updater => {
|
|
1085
|
-
table.options.onGlobalFilterChange == null || table.options.onGlobalFilterChange(updater);
|
|
1523
|
+
const makeVisibleColumnsMethod = (key, getColumns) => {
|
|
1524
|
+
return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
|
|
1525
|
+
return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
|
|
1526
|
+
}, getMemoOptions(table.options, 'debugColumns', key));
|
|
1086
1527
|
};
|
|
1087
|
-
table.
|
|
1088
|
-
|
|
1528
|
+
table.getVisibleFlatColumns = makeVisibleColumnsMethod('getVisibleFlatColumns', () => table.getAllFlatColumns());
|
|
1529
|
+
table.getVisibleLeafColumns = makeVisibleColumnsMethod('getVisibleLeafColumns', () => table.getAllLeafColumns());
|
|
1530
|
+
table.getLeftVisibleLeafColumns = makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => table.getLeftLeafColumns());
|
|
1531
|
+
table.getRightVisibleLeafColumns = makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => table.getRightLeafColumns());
|
|
1532
|
+
table.getCenterVisibleLeafColumns = makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => table.getCenterLeafColumns());
|
|
1533
|
+
table.setColumnVisibility = updater => table.options.onColumnVisibilityChange == null ? void 0 : table.options.onColumnVisibilityChange(updater);
|
|
1534
|
+
table.resetColumnVisibility = defaultState => {
|
|
1535
|
+
var _table$initialState$c;
|
|
1536
|
+
table.setColumnVisibility(defaultState ? {} : (_table$initialState$c = table.initialState.columnVisibility) != null ? _table$initialState$c : {});
|
|
1089
1537
|
};
|
|
1090
|
-
table.
|
|
1091
|
-
var
|
|
1092
|
-
|
|
1538
|
+
table.toggleAllColumnsVisible = value => {
|
|
1539
|
+
var _value;
|
|
1540
|
+
value = (_value = value) != null ? _value : !table.getIsAllColumnsVisible();
|
|
1541
|
+
table.setColumnVisibility(table.getAllLeafColumns().reduce((obj, column) => ({
|
|
1542
|
+
...obj,
|
|
1543
|
+
[column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
|
|
1544
|
+
}), {}));
|
|
1093
1545
|
};
|
|
1094
|
-
table.
|
|
1095
|
-
table.
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
}
|
|
1102
|
-
return table._getFilteredRowModel();
|
|
1546
|
+
table.getIsAllColumnsVisible = () => !table.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible()));
|
|
1547
|
+
table.getIsSomeColumnsVisible = () => table.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible());
|
|
1548
|
+
table.getToggleAllColumnsVisibilityHandler = () => {
|
|
1549
|
+
return e => {
|
|
1550
|
+
var _target;
|
|
1551
|
+
table.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
|
|
1552
|
+
};
|
|
1103
1553
|
};
|
|
1554
|
+
}
|
|
1555
|
+
};
|
|
1556
|
+
function _getVisibleLeafColumns(table, position) {
|
|
1557
|
+
return !position ? table.getVisibleLeafColumns() : position === 'center' ? table.getCenterVisibleLeafColumns() : position === 'left' ? table.getLeftVisibleLeafColumns() : table.getRightVisibleLeafColumns();
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
//
|
|
1561
|
+
|
|
1562
|
+
const GlobalFaceting = {
|
|
1563
|
+
createTable: table => {
|
|
1104
1564
|
table._getGlobalFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, '__global__');
|
|
1105
1565
|
table.getGlobalFacetedRowModel = () => {
|
|
1106
1566
|
if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {
|
|
@@ -1124,289 +1584,207 @@
|
|
|
1124
1584
|
};
|
|
1125
1585
|
}
|
|
1126
1586
|
};
|
|
1127
|
-
function shouldAutoRemoveFilter(filterFn, value, column) {
|
|
1128
|
-
return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
const sum = (columnId, _leafRows, childRows) => {
|
|
1132
|
-
// It's faster to just add the aggregations together instead of
|
|
1133
|
-
// process leaf nodes individually
|
|
1134
|
-
return childRows.reduce((sum, next) => {
|
|
1135
|
-
const nextValue = next.getValue(columnId);
|
|
1136
|
-
return sum + (typeof nextValue === 'number' ? nextValue : 0);
|
|
1137
|
-
}, 0);
|
|
1138
|
-
};
|
|
1139
|
-
const min = (columnId, _leafRows, childRows) => {
|
|
1140
|
-
let min;
|
|
1141
|
-
childRows.forEach(row => {
|
|
1142
|
-
const value = row.getValue(columnId);
|
|
1143
|
-
if (value != null && (min > value || min === undefined && value >= value)) {
|
|
1144
|
-
min = value;
|
|
1145
|
-
}
|
|
1146
|
-
});
|
|
1147
|
-
return min;
|
|
1148
|
-
};
|
|
1149
|
-
const max = (columnId, _leafRows, childRows) => {
|
|
1150
|
-
let max;
|
|
1151
|
-
childRows.forEach(row => {
|
|
1152
|
-
const value = row.getValue(columnId);
|
|
1153
|
-
if (value != null && (max < value || max === undefined && value >= value)) {
|
|
1154
|
-
max = value;
|
|
1155
|
-
}
|
|
1156
|
-
});
|
|
1157
|
-
return max;
|
|
1158
|
-
};
|
|
1159
|
-
const extent = (columnId, _leafRows, childRows) => {
|
|
1160
|
-
let min;
|
|
1161
|
-
let max;
|
|
1162
|
-
childRows.forEach(row => {
|
|
1163
|
-
const value = row.getValue(columnId);
|
|
1164
|
-
if (value != null) {
|
|
1165
|
-
if (min === undefined) {
|
|
1166
|
-
if (value >= value) min = max = value;
|
|
1167
|
-
} else {
|
|
1168
|
-
if (min > value) min = value;
|
|
1169
|
-
if (max < value) max = value;
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
});
|
|
1173
|
-
return [min, max];
|
|
1174
|
-
};
|
|
1175
|
-
const mean = (columnId, leafRows) => {
|
|
1176
|
-
let count = 0;
|
|
1177
|
-
let sum = 0;
|
|
1178
|
-
leafRows.forEach(row => {
|
|
1179
|
-
let value = row.getValue(columnId);
|
|
1180
|
-
if (value != null && (value = +value) >= value) {
|
|
1181
|
-
++count, sum += value;
|
|
1182
|
-
}
|
|
1183
|
-
});
|
|
1184
|
-
if (count) return sum / count;
|
|
1185
|
-
return;
|
|
1186
|
-
};
|
|
1187
|
-
const median = (columnId, leafRows) => {
|
|
1188
|
-
if (!leafRows.length) {
|
|
1189
|
-
return;
|
|
1190
|
-
}
|
|
1191
|
-
const values = leafRows.map(row => row.getValue(columnId));
|
|
1192
|
-
if (!isNumberArray(values)) {
|
|
1193
|
-
return;
|
|
1194
|
-
}
|
|
1195
|
-
if (values.length === 1) {
|
|
1196
|
-
return values[0];
|
|
1197
|
-
}
|
|
1198
|
-
const mid = Math.floor(values.length / 2);
|
|
1199
|
-
const nums = values.sort((a, b) => a - b);
|
|
1200
|
-
return values.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
|
|
1201
|
-
};
|
|
1202
|
-
const unique = (columnId, leafRows) => {
|
|
1203
|
-
return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
|
|
1204
|
-
};
|
|
1205
|
-
const uniqueCount = (columnId, leafRows) => {
|
|
1206
|
-
return new Set(leafRows.map(d => d.getValue(columnId))).size;
|
|
1207
|
-
};
|
|
1208
|
-
const count = (_columnId, leafRows) => {
|
|
1209
|
-
return leafRows.length;
|
|
1210
|
-
};
|
|
1211
|
-
const aggregationFns = {
|
|
1212
|
-
sum,
|
|
1213
|
-
min,
|
|
1214
|
-
max,
|
|
1215
|
-
extent,
|
|
1216
|
-
mean,
|
|
1217
|
-
median,
|
|
1218
|
-
unique,
|
|
1219
|
-
uniqueCount,
|
|
1220
|
-
count
|
|
1221
|
-
};
|
|
1222
1587
|
|
|
1223
1588
|
//
|
|
1224
1589
|
|
|
1225
|
-
const
|
|
1226
|
-
getDefaultColumnDef: () => {
|
|
1227
|
-
return {
|
|
1228
|
-
aggregatedCell: props => {
|
|
1229
|
-
var _toString, _props$getValue;
|
|
1230
|
-
return (_toString = (_props$getValue = props.getValue()) == null || _props$getValue.toString == null ? void 0 : _props$getValue.toString()) != null ? _toString : null;
|
|
1231
|
-
},
|
|
1232
|
-
aggregationFn: 'auto'
|
|
1233
|
-
};
|
|
1234
|
-
},
|
|
1590
|
+
const GlobalFiltering = {
|
|
1235
1591
|
getInitialState: state => {
|
|
1236
1592
|
return {
|
|
1237
|
-
|
|
1593
|
+
globalFilter: undefined,
|
|
1238
1594
|
...state
|
|
1239
1595
|
};
|
|
1240
1596
|
},
|
|
1241
1597
|
getDefaultOptions: table => {
|
|
1242
1598
|
return {
|
|
1243
|
-
|
|
1244
|
-
|
|
1599
|
+
onGlobalFilterChange: makeStateUpdater('globalFilter', table),
|
|
1600
|
+
globalFilterFn: 'auto',
|
|
1601
|
+
getColumnCanGlobalFilter: column => {
|
|
1602
|
+
var _table$getCoreRowMode;
|
|
1603
|
+
const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) == null || (_table$getCoreRowMode = _table$getCoreRowMode._getAllCellsByColumnId()[column.id]) == null ? void 0 : _table$getCoreRowMode.getValue();
|
|
1604
|
+
return typeof value === 'string' || typeof value === 'number';
|
|
1605
|
+
}
|
|
1245
1606
|
};
|
|
1246
1607
|
},
|
|
1247
1608
|
createColumn: (column, table) => {
|
|
1248
|
-
column.
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
if (old != null && old.includes(column.id)) {
|
|
1252
|
-
return old.filter(d => d !== column.id);
|
|
1253
|
-
}
|
|
1254
|
-
return [...(old != null ? old : []), column.id];
|
|
1255
|
-
});
|
|
1609
|
+
column.getCanGlobalFilter = () => {
|
|
1610
|
+
var _column$columnDef$ena, _table$options$enable, _table$options$enable2, _table$options$getCol;
|
|
1611
|
+
return ((_column$columnDef$ena = column.columnDef.enableGlobalFilter) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableGlobalFilter) != null ? _table$options$enable : true) && ((_table$options$enable2 = table.options.enableFilters) != null ? _table$options$enable2 : true) && ((_table$options$getCol = table.options.getColumnCanGlobalFilter == null ? void 0 : table.options.getColumnCanGlobalFilter(column)) != null ? _table$options$getCol : true) && !!column.accessorFn;
|
|
1256
1612
|
};
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1613
|
+
},
|
|
1614
|
+
createTable: table => {
|
|
1615
|
+
table.getGlobalAutoFilterFn = () => {
|
|
1616
|
+
return filterFns.includesString;
|
|
1260
1617
|
};
|
|
1261
|
-
|
|
1262
|
-
var _table$
|
|
1263
|
-
|
|
1618
|
+
table.getGlobalFilterFn = () => {
|
|
1619
|
+
var _table$options$filter, _table$options$filter2;
|
|
1620
|
+
const {
|
|
1621
|
+
globalFilterFn: globalFilterFn
|
|
1622
|
+
} = table.options;
|
|
1623
|
+
return isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === 'auto' ? table.getGlobalAutoFilterFn() : (_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[globalFilterFn]) != null ? _table$options$filter : filterFns[globalFilterFn];
|
|
1264
1624
|
};
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
return (_table$getState$group2 = table.getState().grouping) == null ? void 0 : _table$getState$group2.indexOf(column.id);
|
|
1625
|
+
table.setGlobalFilter = updater => {
|
|
1626
|
+
table.options.onGlobalFilterChange == null || table.options.onGlobalFilterChange(updater);
|
|
1268
1627
|
};
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
return () => {
|
|
1272
|
-
if (!canGroup) return;
|
|
1273
|
-
column.toggleGrouping();
|
|
1274
|
-
};
|
|
1628
|
+
table.resetGlobalFilter = defaultState => {
|
|
1629
|
+
table.setGlobalFilter(defaultState ? undefined : table.initialState.globalFilter);
|
|
1275
1630
|
};
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
}
|
|
1631
|
+
}
|
|
1632
|
+
};
|
|
1633
|
+
|
|
1634
|
+
//
|
|
1635
|
+
|
|
1636
|
+
const RowExpanding = {
|
|
1637
|
+
getInitialState: state => {
|
|
1638
|
+
return {
|
|
1639
|
+
expanded: {},
|
|
1640
|
+
...state
|
|
1285
1641
|
};
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
return isFunction(column.columnDef.aggregationFn) ? column.columnDef.aggregationFn : column.columnDef.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_table$options$aggreg = (_table$options$aggreg2 = table.options.aggregationFns) == null ? void 0 : _table$options$aggreg2[column.columnDef.aggregationFn]) != null ? _table$options$aggreg : aggregationFns[column.columnDef.aggregationFn];
|
|
1642
|
+
},
|
|
1643
|
+
getDefaultOptions: table => {
|
|
1644
|
+
return {
|
|
1645
|
+
onExpandedChange: makeStateUpdater('expanded', table),
|
|
1646
|
+
paginateExpandedRows: true
|
|
1292
1647
|
};
|
|
1293
1648
|
},
|
|
1294
1649
|
createTable: table => {
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1650
|
+
let registered = false;
|
|
1651
|
+
let queued = false;
|
|
1652
|
+
table._autoResetExpanded = () => {
|
|
1653
|
+
var _ref, _table$options$autoRe;
|
|
1654
|
+
if (!registered) {
|
|
1655
|
+
table._queue(() => {
|
|
1656
|
+
registered = true;
|
|
1657
|
+
});
|
|
1658
|
+
return;
|
|
1304
1659
|
}
|
|
1305
|
-
if (table.options.
|
|
1306
|
-
|
|
1660
|
+
if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetExpanded) != null ? _ref : !table.options.manualExpanding) {
|
|
1661
|
+
if (queued) return;
|
|
1662
|
+
queued = true;
|
|
1663
|
+
table._queue(() => {
|
|
1664
|
+
table.resetExpanded();
|
|
1665
|
+
queued = false;
|
|
1666
|
+
});
|
|
1307
1667
|
}
|
|
1308
|
-
return table._getGroupedRowModel();
|
|
1309
1668
|
};
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1669
|
+
table.setExpanded = updater => table.options.onExpandedChange == null ? void 0 : table.options.onExpandedChange(updater);
|
|
1670
|
+
table.toggleAllRowsExpanded = expanded => {
|
|
1671
|
+
if (expanded != null ? expanded : !table.getIsAllRowsExpanded()) {
|
|
1672
|
+
table.setExpanded(true);
|
|
1673
|
+
} else {
|
|
1674
|
+
table.setExpanded({});
|
|
1675
|
+
}
|
|
1676
|
+
};
|
|
1677
|
+
table.resetExpanded = defaultState => {
|
|
1678
|
+
var _table$initialState$e, _table$initialState;
|
|
1679
|
+
table.setExpanded(defaultState ? {} : (_table$initialState$e = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.expanded) != null ? _table$initialState$e : {});
|
|
1680
|
+
};
|
|
1681
|
+
table.getCanSomeRowsExpand = () => {
|
|
1682
|
+
return table.getPrePaginationRowModel().flatRows.some(row => row.getCanExpand());
|
|
1683
|
+
};
|
|
1684
|
+
table.getToggleAllRowsExpandedHandler = () => {
|
|
1685
|
+
return e => {
|
|
1686
|
+
e.persist == null || e.persist();
|
|
1687
|
+
table.toggleAllRowsExpanded();
|
|
1688
|
+
};
|
|
1689
|
+
};
|
|
1690
|
+
table.getIsSomeRowsExpanded = () => {
|
|
1691
|
+
const expanded = table.getState().expanded;
|
|
1692
|
+
return expanded === true || Object.values(expanded).some(Boolean);
|
|
1693
|
+
};
|
|
1694
|
+
table.getIsAllRowsExpanded = () => {
|
|
1695
|
+
const expanded = table.getState().expanded;
|
|
1696
|
+
|
|
1697
|
+
// If expanded is true, save some cycles and return true
|
|
1698
|
+
if (typeof expanded === 'boolean') {
|
|
1699
|
+
return expanded === true;
|
|
1316
1700
|
}
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
return row.getValue(columnId);
|
|
1701
|
+
if (!Object.keys(expanded).length) {
|
|
1702
|
+
return false;
|
|
1320
1703
|
}
|
|
1321
|
-
row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(row.original);
|
|
1322
|
-
return row._groupingValuesCache[columnId];
|
|
1323
|
-
};
|
|
1324
|
-
row._groupingValuesCache = {};
|
|
1325
|
-
},
|
|
1326
|
-
createCell: (cell, column, row, table) => {
|
|
1327
|
-
cell.getIsGrouped = () => column.getIsGrouped() && column.id === row.groupingColumnId;
|
|
1328
|
-
cell.getIsPlaceholder = () => !cell.getIsGrouped() && column.getIsGrouped();
|
|
1329
|
-
cell.getIsAggregated = () => {
|
|
1330
|
-
var _row$subRows;
|
|
1331
|
-
return !cell.getIsGrouped() && !cell.getIsPlaceholder() && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
|
|
1332
|
-
};
|
|
1333
|
-
}
|
|
1334
|
-
};
|
|
1335
|
-
function orderColumns(leafColumns, grouping, groupedColumnMode) {
|
|
1336
|
-
if (!(grouping != null && grouping.length) || !groupedColumnMode) {
|
|
1337
|
-
return leafColumns;
|
|
1338
|
-
}
|
|
1339
|
-
const nonGroupingColumns = leafColumns.filter(col => !grouping.includes(col.id));
|
|
1340
|
-
if (groupedColumnMode === 'remove') {
|
|
1341
|
-
return nonGroupingColumns;
|
|
1342
|
-
}
|
|
1343
|
-
const groupingColumns = grouping.map(g => leafColumns.find(col => col.id === g)).filter(Boolean);
|
|
1344
|
-
return [...groupingColumns, ...nonGroupingColumns];
|
|
1345
|
-
}
|
|
1346
1704
|
|
|
1347
|
-
|
|
1705
|
+
// If any row is not expanded, return false
|
|
1706
|
+
if (table.getRowModel().flatRows.some(row => !row.getIsExpanded())) {
|
|
1707
|
+
return false;
|
|
1708
|
+
}
|
|
1348
1709
|
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
return {
|
|
1352
|
-
columnOrder: [],
|
|
1353
|
-
...state
|
|
1710
|
+
// They must all be expanded :shrug:
|
|
1711
|
+
return true;
|
|
1354
1712
|
};
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1713
|
+
table.getExpandedDepth = () => {
|
|
1714
|
+
let maxDepth = 0;
|
|
1715
|
+
const rowIds = table.getState().expanded === true ? Object.keys(table.getRowModel().rowsById) : Object.keys(table.getState().expanded);
|
|
1716
|
+
rowIds.forEach(id => {
|
|
1717
|
+
const splitId = id.split('.');
|
|
1718
|
+
maxDepth = Math.max(maxDepth, splitId.length);
|
|
1719
|
+
});
|
|
1720
|
+
return maxDepth;
|
|
1721
|
+
};
|
|
1722
|
+
table.getPreExpandedRowModel = () => table.getSortedRowModel();
|
|
1723
|
+
table.getExpandedRowModel = () => {
|
|
1724
|
+
if (!table._getExpandedRowModel && table.options.getExpandedRowModel) {
|
|
1725
|
+
table._getExpandedRowModel = table.options.getExpandedRowModel(table);
|
|
1726
|
+
}
|
|
1727
|
+
if (table.options.manualExpanding || !table._getExpandedRowModel) {
|
|
1728
|
+
return table.getPreExpandedRowModel();
|
|
1729
|
+
}
|
|
1730
|
+
return table._getExpandedRowModel();
|
|
1359
1731
|
};
|
|
1360
1732
|
},
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1733
|
+
createRow: (row, table) => {
|
|
1734
|
+
row.toggleExpanded = expanded => {
|
|
1735
|
+
table.setExpanded(old => {
|
|
1736
|
+
var _expanded;
|
|
1737
|
+
const exists = old === true ? true : !!(old != null && old[row.id]);
|
|
1738
|
+
let oldExpanded = {};
|
|
1739
|
+
if (old === true) {
|
|
1740
|
+
Object.keys(table.getRowModel().rowsById).forEach(rowId => {
|
|
1741
|
+
oldExpanded[rowId] = true;
|
|
1742
|
+
});
|
|
1743
|
+
} else {
|
|
1744
|
+
oldExpanded = old;
|
|
1745
|
+
}
|
|
1746
|
+
expanded = (_expanded = expanded) != null ? _expanded : !exists;
|
|
1747
|
+
if (!exists && expanded) {
|
|
1748
|
+
return {
|
|
1749
|
+
...oldExpanded,
|
|
1750
|
+
[row.id]: true
|
|
1751
|
+
};
|
|
1752
|
+
}
|
|
1753
|
+
if (exists && !expanded) {
|
|
1754
|
+
const {
|
|
1755
|
+
[row.id]: _,
|
|
1756
|
+
...rest
|
|
1757
|
+
} = oldExpanded;
|
|
1758
|
+
return rest;
|
|
1759
|
+
}
|
|
1760
|
+
return old;
|
|
1761
|
+
});
|
|
1367
1762
|
};
|
|
1368
|
-
|
|
1369
|
-
var
|
|
1370
|
-
const
|
|
1371
|
-
return ((
|
|
1763
|
+
row.getIsExpanded = () => {
|
|
1764
|
+
var _table$options$getIsR;
|
|
1765
|
+
const expanded = table.getState().expanded;
|
|
1766
|
+
return !!((_table$options$getIsR = table.options.getIsRowExpanded == null ? void 0 : table.options.getIsRowExpanded(row)) != null ? _table$options$getIsR : expanded === true || (expanded == null ? void 0 : expanded[row.id]));
|
|
1372
1767
|
};
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
table.resetColumnOrder = defaultState => {
|
|
1377
|
-
var _table$initialState$c;
|
|
1378
|
-
table.setColumnOrder(defaultState ? [] : (_table$initialState$c = table.initialState.columnOrder) != null ? _table$initialState$c : []);
|
|
1768
|
+
row.getCanExpand = () => {
|
|
1769
|
+
var _table$options$getRow, _table$options$enable, _row$subRows;
|
|
1770
|
+
return (_table$options$getRow = table.options.getRowCanExpand == null ? void 0 : table.options.getRowCanExpand(row)) != null ? _table$options$getRow : ((_table$options$enable = table.options.enableExpanding) != null ? _table$options$enable : true) && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
|
|
1379
1771
|
};
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
if (!(columnOrder != null && columnOrder.length)) {
|
|
1387
|
-
orderedColumns = columns;
|
|
1388
|
-
} else {
|
|
1389
|
-
const columnOrderCopy = [...columnOrder];
|
|
1390
|
-
|
|
1391
|
-
// If there is an order, make a copy of the columns
|
|
1392
|
-
const columnsCopy = [...columns];
|
|
1393
|
-
|
|
1394
|
-
// And make a new ordered array of the columns
|
|
1395
|
-
|
|
1396
|
-
// Loop over the columns and place them in order into the new array
|
|
1397
|
-
while (columnsCopy.length && columnOrderCopy.length) {
|
|
1398
|
-
const targetColumnId = columnOrderCopy.shift();
|
|
1399
|
-
const foundIndex = columnsCopy.findIndex(d => d.id === targetColumnId);
|
|
1400
|
-
if (foundIndex > -1) {
|
|
1401
|
-
orderedColumns.push(columnsCopy.splice(foundIndex, 1)[0]);
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
|
-
// If there are any columns left, add them to the end
|
|
1406
|
-
orderedColumns = [...orderedColumns, ...columnsCopy];
|
|
1772
|
+
row.getIsAllParentsExpanded = () => {
|
|
1773
|
+
let isFullyExpanded = true;
|
|
1774
|
+
let currentRow = row;
|
|
1775
|
+
while (isFullyExpanded && currentRow.parentId) {
|
|
1776
|
+
currentRow = table.getRow(currentRow.parentId, true);
|
|
1777
|
+
isFullyExpanded = currentRow.getIsExpanded();
|
|
1407
1778
|
}
|
|
1408
|
-
return
|
|
1409
|
-
}
|
|
1779
|
+
return isFullyExpanded;
|
|
1780
|
+
};
|
|
1781
|
+
row.getToggleExpandedHandler = () => {
|
|
1782
|
+
const canExpand = row.getCanExpand();
|
|
1783
|
+
return () => {
|
|
1784
|
+
if (!canExpand) return;
|
|
1785
|
+
row.toggleExpanded();
|
|
1786
|
+
};
|
|
1787
|
+
};
|
|
1410
1788
|
}
|
|
1411
1789
|
};
|
|
1412
1790
|
|
|
@@ -1418,7 +1796,7 @@
|
|
|
1418
1796
|
pageIndex: defaultPageIndex,
|
|
1419
1797
|
pageSize: defaultPageSize
|
|
1420
1798
|
});
|
|
1421
|
-
const
|
|
1799
|
+
const RowPagination = {
|
|
1422
1800
|
getInitialState: state => {
|
|
1423
1801
|
return {
|
|
1424
1802
|
...state,
|
|
@@ -1565,88 +1943,34 @@
|
|
|
1565
1943
|
|
|
1566
1944
|
//
|
|
1567
1945
|
|
|
1568
|
-
const getDefaultColumnPinningState = () => ({
|
|
1569
|
-
left: [],
|
|
1570
|
-
right: []
|
|
1571
|
-
});
|
|
1572
1946
|
const getDefaultRowPinningState = () => ({
|
|
1573
1947
|
top: [],
|
|
1574
1948
|
bottom: []
|
|
1575
1949
|
});
|
|
1576
|
-
const
|
|
1950
|
+
const RowPinning = {
|
|
1577
1951
|
getInitialState: state => {
|
|
1578
1952
|
return {
|
|
1579
|
-
columnPinning: getDefaultColumnPinningState(),
|
|
1580
1953
|
rowPinning: getDefaultRowPinningState(),
|
|
1581
1954
|
...state
|
|
1582
1955
|
};
|
|
1583
1956
|
},
|
|
1584
1957
|
getDefaultOptions: table => {
|
|
1585
1958
|
return {
|
|
1586
|
-
onColumnPinningChange: makeStateUpdater('columnPinning', table),
|
|
1587
1959
|
onRowPinningChange: makeStateUpdater('rowPinning', table)
|
|
1588
1960
|
};
|
|
1589
1961
|
},
|
|
1590
|
-
createColumn: (column, table) => {
|
|
1591
|
-
column.pin = position => {
|
|
1592
|
-
const columnIds = column.getLeafColumns().map(d => d.id).filter(Boolean);
|
|
1593
|
-
table.setColumnPinning(old => {
|
|
1594
|
-
var _old$left3, _old$right3;
|
|
1595
|
-
if (position === 'right') {
|
|
1596
|
-
var _old$left, _old$right;
|
|
1597
|
-
return {
|
|
1598
|
-
left: ((_old$left = old == null ? void 0 : old.left) != null ? _old$left : []).filter(d => !(columnIds != null && columnIds.includes(d))),
|
|
1599
|
-
right: [...((_old$right = old == null ? void 0 : old.right) != null ? _old$right : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds]
|
|
1600
|
-
};
|
|
1601
|
-
}
|
|
1602
|
-
if (position === 'left') {
|
|
1603
|
-
var _old$left2, _old$right2;
|
|
1604
|
-
return {
|
|
1605
|
-
left: [...((_old$left2 = old == null ? void 0 : old.left) != null ? _old$left2 : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds],
|
|
1606
|
-
right: ((_old$right2 = old == null ? void 0 : old.right) != null ? _old$right2 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
|
|
1607
|
-
};
|
|
1608
|
-
}
|
|
1609
|
-
return {
|
|
1610
|
-
left: ((_old$left3 = old == null ? void 0 : old.left) != null ? _old$left3 : []).filter(d => !(columnIds != null && columnIds.includes(d))),
|
|
1611
|
-
right: ((_old$right3 = old == null ? void 0 : old.right) != null ? _old$right3 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
|
|
1612
|
-
};
|
|
1613
|
-
});
|
|
1614
|
-
};
|
|
1615
|
-
column.getCanPin = () => {
|
|
1616
|
-
const leafColumns = column.getLeafColumns();
|
|
1617
|
-
return leafColumns.some(d => {
|
|
1618
|
-
var _d$columnDef$enablePi, _ref, _table$options$enable;
|
|
1619
|
-
return ((_d$columnDef$enablePi = d.columnDef.enablePinning) != null ? _d$columnDef$enablePi : true) && ((_ref = (_table$options$enable = table.options.enableColumnPinning) != null ? _table$options$enable : table.options.enablePinning) != null ? _ref : true);
|
|
1620
|
-
});
|
|
1621
|
-
};
|
|
1622
|
-
column.getIsPinned = () => {
|
|
1623
|
-
const leafColumnIds = column.getLeafColumns().map(d => d.id);
|
|
1624
|
-
const {
|
|
1625
|
-
left,
|
|
1626
|
-
right
|
|
1627
|
-
} = table.getState().columnPinning;
|
|
1628
|
-
const isLeft = leafColumnIds.some(d => left == null ? void 0 : left.includes(d));
|
|
1629
|
-
const isRight = leafColumnIds.some(d => right == null ? void 0 : right.includes(d));
|
|
1630
|
-
return isLeft ? 'left' : isRight ? 'right' : false;
|
|
1631
|
-
};
|
|
1632
|
-
column.getPinnedIndex = () => {
|
|
1633
|
-
var _table$getState$colum, _table$getState$colum2;
|
|
1634
|
-
const position = column.getIsPinned();
|
|
1635
|
-
return position ? (_table$getState$colum = (_table$getState$colum2 = table.getState().columnPinning) == null || (_table$getState$colum2 = _table$getState$colum2[position]) == null ? void 0 : _table$getState$colum2.indexOf(column.id)) != null ? _table$getState$colum : -1 : 0;
|
|
1636
|
-
};
|
|
1637
|
-
},
|
|
1638
1962
|
createRow: (row, table) => {
|
|
1639
1963
|
row.pin = (position, includeLeafRows, includeParentRows) => {
|
|
1640
|
-
const leafRowIds = includeLeafRows ? row.getLeafRows().map(
|
|
1964
|
+
const leafRowIds = includeLeafRows ? row.getLeafRows().map(_ref => {
|
|
1641
1965
|
let {
|
|
1642
1966
|
id
|
|
1643
|
-
} =
|
|
1967
|
+
} = _ref;
|
|
1644
1968
|
return id;
|
|
1645
1969
|
}) : [];
|
|
1646
|
-
const parentRowIds = includeParentRows ? row.getParentRows().map(
|
|
1970
|
+
const parentRowIds = includeParentRows ? row.getParentRows().map(_ref2 => {
|
|
1647
1971
|
let {
|
|
1648
1972
|
id
|
|
1649
|
-
} =
|
|
1973
|
+
} = _ref2;
|
|
1650
1974
|
return id;
|
|
1651
1975
|
}) : [];
|
|
1652
1976
|
const rowIds = new Set([...parentRowIds, row.id, ...leafRowIds]);
|
|
@@ -1673,7 +1997,7 @@
|
|
|
1673
1997
|
});
|
|
1674
1998
|
};
|
|
1675
1999
|
row.getCanPin = () => {
|
|
1676
|
-
var
|
|
2000
|
+
var _ref3;
|
|
1677
2001
|
const {
|
|
1678
2002
|
enableRowPinning,
|
|
1679
2003
|
enablePinning
|
|
@@ -1681,7 +2005,7 @@
|
|
|
1681
2005
|
if (typeof enableRowPinning === 'function') {
|
|
1682
2006
|
return enableRowPinning(row);
|
|
1683
2007
|
}
|
|
1684
|
-
return (
|
|
2008
|
+
return (_ref3 = enableRowPinning != null ? enableRowPinning : enablePinning) != null ? _ref3 : true;
|
|
1685
2009
|
};
|
|
1686
2010
|
row.getIsPinned = () => {
|
|
1687
2011
|
const rowIds = [row.id];
|
|
@@ -1696,72 +2020,30 @@
|
|
|
1696
2020
|
row.getPinnedIndex = () => {
|
|
1697
2021
|
var _table$_getPinnedRows, _visiblePinnedRowIds$;
|
|
1698
2022
|
const position = row.getIsPinned();
|
|
1699
|
-
if (!position) return -1;
|
|
1700
|
-
const visiblePinnedRowIds = (_table$_getPinnedRows = table._getPinnedRows(position)) == null ? void 0 : _table$_getPinnedRows.map(
|
|
1701
|
-
let {
|
|
1702
|
-
id
|
|
1703
|
-
} =
|
|
1704
|
-
return id;
|
|
1705
|
-
});
|
|
1706
|
-
return (_visiblePinnedRowIds$ = visiblePinnedRowIds == null ? void 0 : visiblePinnedRowIds.indexOf(row.id)) != null ? _visiblePinnedRowIds$ : -1;
|
|
1707
|
-
};
|
|
1708
|
-
row.getCenterVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allCells, left, right) => {
|
|
1709
|
-
const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
|
|
1710
|
-
return allCells.filter(d => !leftAndRight.includes(d.column.id));
|
|
1711
|
-
}, getMemoOptions(table.options, 'debugRows', 'getCenterVisibleCells'));
|
|
1712
|
-
row.getLeftVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left], (allCells, left) => {
|
|
1713
|
-
const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
|
|
1714
|
-
...d,
|
|
1715
|
-
position: 'left'
|
|
1716
|
-
}));
|
|
1717
|
-
return cells;
|
|
1718
|
-
}, getMemoOptions(table.options, 'debugRows', 'getLeftVisibleCells'));
|
|
1719
|
-
row.getRightVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.right], (allCells, right) => {
|
|
1720
|
-
const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
|
|
1721
|
-
...d,
|
|
1722
|
-
position: 'right'
|
|
1723
|
-
}));
|
|
1724
|
-
return cells;
|
|
1725
|
-
}, getMemoOptions(table.options, 'debugRows', 'getRightVisibleCells'));
|
|
1726
|
-
},
|
|
1727
|
-
createTable: table => {
|
|
1728
|
-
table.setColumnPinning = updater => table.options.onColumnPinningChange == null ? void 0 : table.options.onColumnPinningChange(updater);
|
|
1729
|
-
table.resetColumnPinning = defaultState => {
|
|
1730
|
-
var _table$initialState$c, _table$initialState;
|
|
1731
|
-
return table.setColumnPinning(defaultState ? getDefaultColumnPinningState() : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnPinning) != null ? _table$initialState$c : getDefaultColumnPinningState());
|
|
1732
|
-
};
|
|
1733
|
-
table.getIsSomeColumnsPinned = position => {
|
|
1734
|
-
var _pinningState$positio;
|
|
1735
|
-
const pinningState = table.getState().columnPinning;
|
|
1736
|
-
if (!position) {
|
|
1737
|
-
var _pinningState$left, _pinningState$right;
|
|
1738
|
-
return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
|
|
1739
|
-
}
|
|
1740
|
-
return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
|
|
2023
|
+
if (!position) return -1;
|
|
2024
|
+
const visiblePinnedRowIds = (_table$_getPinnedRows = table._getPinnedRows(position)) == null ? void 0 : _table$_getPinnedRows.map(_ref4 => {
|
|
2025
|
+
let {
|
|
2026
|
+
id
|
|
2027
|
+
} = _ref4;
|
|
2028
|
+
return id;
|
|
2029
|
+
});
|
|
2030
|
+
return (_visiblePinnedRowIds$ = visiblePinnedRowIds == null ? void 0 : visiblePinnedRowIds.indexOf(row.id)) != null ? _visiblePinnedRowIds$ : -1;
|
|
1741
2031
|
};
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
}, getMemoOptions(table.options, 'debugColumns', 'getLeftLeafColumns'));
|
|
1745
|
-
table.getRightLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.right], (allColumns, right) => {
|
|
1746
|
-
return (right != null ? right : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
|
|
1747
|
-
}, getMemoOptions(table.options, 'debugColumns', 'getRightLeafColumns'));
|
|
1748
|
-
table.getCenterLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, left, right) => {
|
|
1749
|
-
const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
|
|
1750
|
-
return allColumns.filter(d => !leftAndRight.includes(d.id));
|
|
1751
|
-
}, getMemoOptions(table.options, 'debugColumns', 'getCenterLeafColumns'));
|
|
2032
|
+
},
|
|
2033
|
+
createTable: table => {
|
|
1752
2034
|
table.setRowPinning = updater => table.options.onRowPinningChange == null ? void 0 : table.options.onRowPinningChange(updater);
|
|
1753
2035
|
table.resetRowPinning = defaultState => {
|
|
1754
|
-
var _table$initialState$r, _table$
|
|
1755
|
-
return table.setRowPinning(defaultState ? getDefaultRowPinningState() : (_table$initialState$r = (_table$
|
|
2036
|
+
var _table$initialState$r, _table$initialState;
|
|
2037
|
+
return table.setRowPinning(defaultState ? getDefaultRowPinningState() : (_table$initialState$r = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.rowPinning) != null ? _table$initialState$r : getDefaultRowPinningState());
|
|
1756
2038
|
};
|
|
1757
2039
|
table.getIsSomeRowsPinned = position => {
|
|
1758
|
-
var _pinningState$
|
|
2040
|
+
var _pinningState$positio;
|
|
1759
2041
|
const pinningState = table.getState().rowPinning;
|
|
1760
2042
|
if (!position) {
|
|
1761
2043
|
var _pinningState$top, _pinningState$bottom;
|
|
1762
2044
|
return Boolean(((_pinningState$top = pinningState.top) == null ? void 0 : _pinningState$top.length) || ((_pinningState$bottom = pinningState.bottom) == null ? void 0 : _pinningState$bottom.length));
|
|
1763
2045
|
}
|
|
1764
|
-
return Boolean((_pinningState$
|
|
2046
|
+
return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
|
|
1765
2047
|
};
|
|
1766
2048
|
table._getPinnedRows = memo(position => [table.getRowModel().rows, table.getState().rowPinning[position], position], (visibleRows, pinnedRowIds, position) => {
|
|
1767
2049
|
var _table$options$keepPi;
|
|
@@ -2267,7 +2549,7 @@
|
|
|
2267
2549
|
|
|
2268
2550
|
//
|
|
2269
2551
|
|
|
2270
|
-
const
|
|
2552
|
+
const RowSorting = {
|
|
2271
2553
|
getInitialState: state => {
|
|
2272
2554
|
return {
|
|
2273
2555
|
sorting: [],
|
|
@@ -2474,99 +2756,24 @@
|
|
|
2474
2756
|
}
|
|
2475
2757
|
};
|
|
2476
2758
|
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
};
|
|
2485
|
-
},
|
|
2486
|
-
getDefaultOptions: table => {
|
|
2487
|
-
return {
|
|
2488
|
-
onColumnVisibilityChange: makeStateUpdater('columnVisibility', table)
|
|
2489
|
-
};
|
|
2490
|
-
},
|
|
2491
|
-
createColumn: (column, table) => {
|
|
2492
|
-
column.toggleVisibility = value => {
|
|
2493
|
-
if (column.getCanHide()) {
|
|
2494
|
-
table.setColumnVisibility(old => ({
|
|
2495
|
-
...old,
|
|
2496
|
-
[column.id]: value != null ? value : !column.getIsVisible()
|
|
2497
|
-
}));
|
|
2498
|
-
}
|
|
2499
|
-
};
|
|
2500
|
-
column.getIsVisible = () => {
|
|
2501
|
-
var _ref, _table$getState$colum;
|
|
2502
|
-
const childColumns = column.columns;
|
|
2503
|
-
return (_ref = childColumns.length ? childColumns.some(c => c.getIsVisible()) : (_table$getState$colum = table.getState().columnVisibility) == null ? void 0 : _table$getState$colum[column.id]) != null ? _ref : true;
|
|
2504
|
-
};
|
|
2505
|
-
column.getCanHide = () => {
|
|
2506
|
-
var _column$columnDef$ena, _table$options$enable;
|
|
2507
|
-
return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableHiding) != null ? _table$options$enable : true);
|
|
2508
|
-
};
|
|
2509
|
-
column.getToggleVisibilityHandler = () => {
|
|
2510
|
-
return e => {
|
|
2511
|
-
column.toggleVisibility == null || column.toggleVisibility(e.target.checked);
|
|
2512
|
-
};
|
|
2513
|
-
};
|
|
2514
|
-
},
|
|
2515
|
-
createRow: (row, table) => {
|
|
2516
|
-
row._getAllVisibleCells = memo(() => [row.getAllCells(), table.getState().columnVisibility], cells => {
|
|
2517
|
-
return cells.filter(cell => cell.column.getIsVisible());
|
|
2518
|
-
}, getMemoOptions(table.options, 'debugRows', '_getAllVisibleCells'));
|
|
2519
|
-
row.getVisibleCells = memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], getMemoOptions(table.options, 'debugRows', 'getVisibleCells'));
|
|
2520
|
-
},
|
|
2521
|
-
createTable: table => {
|
|
2522
|
-
const makeVisibleColumnsMethod = (key, getColumns) => {
|
|
2523
|
-
return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
|
|
2524
|
-
return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
|
|
2525
|
-
}, getMemoOptions(table.options, 'debugColumns', key));
|
|
2526
|
-
};
|
|
2527
|
-
table.getVisibleFlatColumns = makeVisibleColumnsMethod('getVisibleFlatColumns', () => table.getAllFlatColumns());
|
|
2528
|
-
table.getVisibleLeafColumns = makeVisibleColumnsMethod('getVisibleLeafColumns', () => table.getAllLeafColumns());
|
|
2529
|
-
table.getLeftVisibleLeafColumns = makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => table.getLeftLeafColumns());
|
|
2530
|
-
table.getRightVisibleLeafColumns = makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => table.getRightLeafColumns());
|
|
2531
|
-
table.getCenterVisibleLeafColumns = makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => table.getCenterLeafColumns());
|
|
2532
|
-
table.setColumnVisibility = updater => table.options.onColumnVisibilityChange == null ? void 0 : table.options.onColumnVisibilityChange(updater);
|
|
2533
|
-
table.resetColumnVisibility = defaultState => {
|
|
2534
|
-
var _table$initialState$c;
|
|
2535
|
-
table.setColumnVisibility(defaultState ? {} : (_table$initialState$c = table.initialState.columnVisibility) != null ? _table$initialState$c : {});
|
|
2536
|
-
};
|
|
2537
|
-
table.toggleAllColumnsVisible = value => {
|
|
2538
|
-
var _value;
|
|
2539
|
-
value = (_value = value) != null ? _value : !table.getIsAllColumnsVisible();
|
|
2540
|
-
table.setColumnVisibility(table.getAllLeafColumns().reduce((obj, column) => ({
|
|
2541
|
-
...obj,
|
|
2542
|
-
[column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
|
|
2543
|
-
}), {}));
|
|
2544
|
-
};
|
|
2545
|
-
table.getIsAllColumnsVisible = () => !table.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible()));
|
|
2546
|
-
table.getIsSomeColumnsVisible = () => table.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible());
|
|
2547
|
-
table.getToggleAllColumnsVisibilityHandler = () => {
|
|
2548
|
-
return e => {
|
|
2549
|
-
var _target;
|
|
2550
|
-
table.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
|
|
2551
|
-
};
|
|
2552
|
-
};
|
|
2553
|
-
}
|
|
2554
|
-
};
|
|
2555
|
-
function _getVisibleLeafColumns(table, position) {
|
|
2556
|
-
return !position ? table.getVisibleLeafColumns() : position === 'center' ? table.getCenterVisibleLeafColumns() : position === 'left' ? table.getLeftVisibleLeafColumns() : table.getRightVisibleLeafColumns();
|
|
2557
|
-
}
|
|
2558
|
-
|
|
2559
|
-
const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing];
|
|
2759
|
+
const builtInFeatures = [Headers, ColumnVisibility, ColumnOrdering, ColumnPinning, ColumnFaceting, ColumnFiltering, GlobalFaceting,
|
|
2760
|
+
//depends on ColumnFaceting
|
|
2761
|
+
GlobalFiltering,
|
|
2762
|
+
//depends on ColumnFiltering
|
|
2763
|
+
RowSorting, ColumnGrouping,
|
|
2764
|
+
//depends on RowSorting
|
|
2765
|
+
RowExpanding, RowPagination, RowPinning, RowSelection, ColumnSizing];
|
|
2560
2766
|
|
|
2561
2767
|
//
|
|
2562
2768
|
|
|
2563
2769
|
function createTable(options) {
|
|
2564
|
-
var _options$initialState;
|
|
2565
|
-
if (options.debugAll || options.debugTable) {
|
|
2770
|
+
var _options$_features, _options$initialState;
|
|
2771
|
+
if ((options.debugAll || options.debugTable)) {
|
|
2566
2772
|
console.info('Creating Table Instance...');
|
|
2567
2773
|
}
|
|
2774
|
+
const _features = [...builtInFeatures, ...((_options$_features = options._features) != null ? _options$_features : [])];
|
|
2568
2775
|
let table = {
|
|
2569
|
-
_features
|
|
2776
|
+
_features
|
|
2570
2777
|
};
|
|
2571
2778
|
const defaultOptions = table._features.reduce((obj, feature) => {
|
|
2572
2779
|
return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(table));
|
|
@@ -2592,7 +2799,7 @@
|
|
|
2592
2799
|
const queued = [];
|
|
2593
2800
|
let queuedTimeout = false;
|
|
2594
2801
|
const coreInstance = {
|
|
2595
|
-
_features
|
|
2802
|
+
_features,
|
|
2596
2803
|
options: {
|
|
2597
2804
|
...defaultOptions,
|
|
2598
2805
|
...options
|
|
@@ -2655,232 +2862,77 @@
|
|
|
2655
2862
|
}
|
|
2656
2863
|
}
|
|
2657
2864
|
}
|
|
2658
|
-
return row;
|
|
2659
|
-
},
|
|
2660
|
-
_getDefaultColumnDef: memo(() => [table.options.defaultColumn], defaultColumn => {
|
|
2661
|
-
var _defaultColumn;
|
|
2662
|
-
defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
|
|
2663
|
-
return {
|
|
2664
|
-
header: props => {
|
|
2665
|
-
const resolvedColumnDef = props.header.column.columnDef;
|
|
2666
|
-
if (resolvedColumnDef.accessorKey) {
|
|
2667
|
-
return resolvedColumnDef.accessorKey;
|
|
2668
|
-
}
|
|
2669
|
-
if (resolvedColumnDef.accessorFn) {
|
|
2670
|
-
return resolvedColumnDef.id;
|
|
2671
|
-
}
|
|
2672
|
-
return null;
|
|
2673
|
-
},
|
|
2674
|
-
// footer: props => props.header.column.id,
|
|
2675
|
-
cell: props => {
|
|
2676
|
-
var _props$renderValue$to, _props$renderValue;
|
|
2677
|
-
return (_props$renderValue$to = (_props$renderValue = props.renderValue()) == null || _props$renderValue.toString == null ? void 0 : _props$renderValue.toString()) != null ? _props$renderValue$to : null;
|
|
2678
|
-
},
|
|
2679
|
-
...table._features.reduce((obj, feature) => {
|
|
2680
|
-
return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
|
|
2681
|
-
}, {}),
|
|
2682
|
-
...defaultColumn
|
|
2683
|
-
};
|
|
2684
|
-
}, getMemoOptions(options, 'debugColumns', '_getDefaultColumnDef')),
|
|
2685
|
-
_getColumnDefs: () => table.options.columns,
|
|
2686
|
-
getAllColumns: memo(() => [table._getColumnDefs()], columnDefs => {
|
|
2687
|
-
const recurseColumns = function (columnDefs, parent, depth) {
|
|
2688
|
-
if (depth === void 0) {
|
|
2689
|
-
depth = 0;
|
|
2690
|
-
}
|
|
2691
|
-
return columnDefs.map(columnDef => {
|
|
2692
|
-
const column = createColumn(table, columnDef, depth, parent);
|
|
2693
|
-
const groupingColumnDef = columnDef;
|
|
2694
|
-
column.columns = groupingColumnDef.columns ? recurseColumns(groupingColumnDef.columns, column, depth + 1) : [];
|
|
2695
|
-
return column;
|
|
2696
|
-
});
|
|
2697
|
-
};
|
|
2698
|
-
return recurseColumns(columnDefs);
|
|
2699
|
-
}, getMemoOptions(options, 'debugColumns', 'getAllColumns')),
|
|
2700
|
-
getAllFlatColumns: memo(() => [table.getAllColumns()], allColumns => {
|
|
2701
|
-
return allColumns.flatMap(column => {
|
|
2702
|
-
return column.getFlatColumns();
|
|
2703
|
-
});
|
|
2704
|
-
}, getMemoOptions(options, 'debugColumns', 'getAllFlatColumns')),
|
|
2705
|
-
_getAllFlatColumnsById: memo(() => [table.getAllFlatColumns()], flatColumns => {
|
|
2706
|
-
return flatColumns.reduce((acc, column) => {
|
|
2707
|
-
acc[column.id] = column;
|
|
2708
|
-
return acc;
|
|
2709
|
-
}, {});
|
|
2710
|
-
}, getMemoOptions(options, 'debugColumns', 'getAllFlatColumnsById')),
|
|
2711
|
-
getAllLeafColumns: memo(() => [table.getAllColumns(), table._getOrderColumnsFn()], (allColumns, orderColumns) => {
|
|
2712
|
-
let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
|
|
2713
|
-
return orderColumns(leafColumns);
|
|
2714
|
-
}, getMemoOptions(options, 'debugColumns', 'getAllLeafColumns')),
|
|
2715
|
-
getColumn: columnId => {
|
|
2716
|
-
const column = table._getAllFlatColumnsById()[columnId];
|
|
2717
|
-
if (!column) {
|
|
2718
|
-
console.error(`[Table] Column with id '${columnId}' does not exist.`);
|
|
2719
|
-
}
|
|
2720
|
-
return column;
|
|
2721
|
-
}
|
|
2722
|
-
};
|
|
2723
|
-
Object.assign(table, coreInstance);
|
|
2724
|
-
for (let index = 0; index < table._features.length; index++) {
|
|
2725
|
-
const feature = table._features[index];
|
|
2726
|
-
feature == null || feature.createTable == null || feature.createTable(table);
|
|
2727
|
-
}
|
|
2728
|
-
return table;
|
|
2729
|
-
}
|
|
2730
|
-
|
|
2731
|
-
function createCell(table, row, column, columnId) {
|
|
2732
|
-
const getRenderValue = () => {
|
|
2733
|
-
var _cell$getValue;
|
|
2734
|
-
return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : table.options.renderFallbackValue;
|
|
2735
|
-
};
|
|
2736
|
-
const cell = {
|
|
2737
|
-
id: `${row.id}_${column.id}`,
|
|
2738
|
-
row,
|
|
2739
|
-
column,
|
|
2740
|
-
getValue: () => row.getValue(columnId),
|
|
2741
|
-
renderValue: getRenderValue,
|
|
2742
|
-
getContext: memo(() => [table, column, row, cell], (table, column, row, cell) => ({
|
|
2743
|
-
table,
|
|
2744
|
-
column,
|
|
2745
|
-
row,
|
|
2746
|
-
cell: cell,
|
|
2747
|
-
getValue: cell.getValue,
|
|
2748
|
-
renderValue: cell.renderValue
|
|
2749
|
-
}), getMemoOptions(table.options, 'debugCells', 'cell.getContext'))
|
|
2750
|
-
};
|
|
2751
|
-
table._features.forEach(feature => {
|
|
2752
|
-
feature.createCell == null || feature.createCell(cell, column, row, table);
|
|
2753
|
-
}, {});
|
|
2754
|
-
return cell;
|
|
2755
|
-
}
|
|
2756
|
-
|
|
2757
|
-
const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
|
2758
|
-
let row = {
|
|
2759
|
-
id,
|
|
2760
|
-
index: rowIndex,
|
|
2761
|
-
original,
|
|
2762
|
-
depth,
|
|
2763
|
-
parentId,
|
|
2764
|
-
_valuesCache: {},
|
|
2765
|
-
_uniqueValuesCache: {},
|
|
2766
|
-
getValue: columnId => {
|
|
2767
|
-
if (row._valuesCache.hasOwnProperty(columnId)) {
|
|
2768
|
-
return row._valuesCache[columnId];
|
|
2769
|
-
}
|
|
2770
|
-
const column = table.getColumn(columnId);
|
|
2771
|
-
if (!(column != null && column.accessorFn)) {
|
|
2772
|
-
return undefined;
|
|
2773
|
-
}
|
|
2774
|
-
row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
|
2775
|
-
return row._valuesCache[columnId];
|
|
2776
|
-
},
|
|
2777
|
-
getUniqueValues: columnId => {
|
|
2778
|
-
if (row._uniqueValuesCache.hasOwnProperty(columnId)) {
|
|
2779
|
-
return row._uniqueValuesCache[columnId];
|
|
2780
|
-
}
|
|
2781
|
-
const column = table.getColumn(columnId);
|
|
2782
|
-
if (!(column != null && column.accessorFn)) {
|
|
2783
|
-
return undefined;
|
|
2784
|
-
}
|
|
2785
|
-
if (!column.columnDef.getUniqueValues) {
|
|
2786
|
-
row._uniqueValuesCache[columnId] = [row.getValue(columnId)];
|
|
2787
|
-
return row._uniqueValuesCache[columnId];
|
|
2788
|
-
}
|
|
2789
|
-
row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(row.original, rowIndex);
|
|
2790
|
-
return row._uniqueValuesCache[columnId];
|
|
2791
|
-
},
|
|
2792
|
-
renderValue: columnId => {
|
|
2793
|
-
var _row$getValue;
|
|
2794
|
-
return (_row$getValue = row.getValue(columnId)) != null ? _row$getValue : table.options.renderFallbackValue;
|
|
2795
|
-
},
|
|
2796
|
-
subRows: subRows != null ? subRows : [],
|
|
2797
|
-
getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
|
|
2798
|
-
getParentRow: () => row.parentId ? table.getRow(row.parentId, true) : undefined,
|
|
2799
|
-
getParentRows: () => {
|
|
2800
|
-
let parentRows = [];
|
|
2801
|
-
let currentRow = row;
|
|
2802
|
-
while (true) {
|
|
2803
|
-
const parentRow = currentRow.getParentRow();
|
|
2804
|
-
if (!parentRow) break;
|
|
2805
|
-
parentRows.push(parentRow);
|
|
2806
|
-
currentRow = parentRow;
|
|
2807
|
-
}
|
|
2808
|
-
return parentRows.reverse();
|
|
2809
|
-
},
|
|
2810
|
-
getAllCells: memo(() => [table.getAllLeafColumns()], leafColumns => {
|
|
2811
|
-
return leafColumns.map(column => {
|
|
2812
|
-
return createCell(table, row, column, column.id);
|
|
2865
|
+
return row;
|
|
2866
|
+
},
|
|
2867
|
+
_getDefaultColumnDef: memo(() => [table.options.defaultColumn], defaultColumn => {
|
|
2868
|
+
var _defaultColumn;
|
|
2869
|
+
defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
|
|
2870
|
+
return {
|
|
2871
|
+
header: props => {
|
|
2872
|
+
const resolvedColumnDef = props.header.column.columnDef;
|
|
2873
|
+
if (resolvedColumnDef.accessorKey) {
|
|
2874
|
+
return resolvedColumnDef.accessorKey;
|
|
2875
|
+
}
|
|
2876
|
+
if (resolvedColumnDef.accessorFn) {
|
|
2877
|
+
return resolvedColumnDef.id;
|
|
2878
|
+
}
|
|
2879
|
+
return null;
|
|
2880
|
+
},
|
|
2881
|
+
// footer: props => props.header.column.id,
|
|
2882
|
+
cell: props => {
|
|
2883
|
+
var _props$renderValue$to, _props$renderValue;
|
|
2884
|
+
return (_props$renderValue$to = (_props$renderValue = props.renderValue()) == null || _props$renderValue.toString == null ? void 0 : _props$renderValue.toString()) != null ? _props$renderValue$to : null;
|
|
2885
|
+
},
|
|
2886
|
+
...table._features.reduce((obj, feature) => {
|
|
2887
|
+
return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
|
|
2888
|
+
}, {}),
|
|
2889
|
+
...defaultColumn
|
|
2890
|
+
};
|
|
2891
|
+
}, getMemoOptions(options, 'debugColumns', '_getDefaultColumnDef')),
|
|
2892
|
+
_getColumnDefs: () => table.options.columns,
|
|
2893
|
+
getAllColumns: memo(() => [table._getColumnDefs()], columnDefs => {
|
|
2894
|
+
const recurseColumns = function (columnDefs, parent, depth) {
|
|
2895
|
+
if (depth === void 0) {
|
|
2896
|
+
depth = 0;
|
|
2897
|
+
}
|
|
2898
|
+
return columnDefs.map(columnDef => {
|
|
2899
|
+
const column = createColumn(table, columnDef, depth, parent);
|
|
2900
|
+
const groupingColumnDef = columnDef;
|
|
2901
|
+
column.columns = groupingColumnDef.columns ? recurseColumns(groupingColumnDef.columns, column, depth + 1) : [];
|
|
2902
|
+
return column;
|
|
2903
|
+
});
|
|
2904
|
+
};
|
|
2905
|
+
return recurseColumns(columnDefs);
|
|
2906
|
+
}, getMemoOptions(options, 'debugColumns', 'getAllColumns')),
|
|
2907
|
+
getAllFlatColumns: memo(() => [table.getAllColumns()], allColumns => {
|
|
2908
|
+
return allColumns.flatMap(column => {
|
|
2909
|
+
return column.getFlatColumns();
|
|
2813
2910
|
});
|
|
2814
|
-
}, getMemoOptions(
|
|
2815
|
-
|
|
2816
|
-
return
|
|
2817
|
-
acc[
|
|
2911
|
+
}, getMemoOptions(options, 'debugColumns', 'getAllFlatColumns')),
|
|
2912
|
+
_getAllFlatColumnsById: memo(() => [table.getAllFlatColumns()], flatColumns => {
|
|
2913
|
+
return flatColumns.reduce((acc, column) => {
|
|
2914
|
+
acc[column.id] = column;
|
|
2818
2915
|
return acc;
|
|
2819
2916
|
}, {});
|
|
2820
|
-
}, getMemoOptions(
|
|
2917
|
+
}, getMemoOptions(options, 'debugColumns', 'getAllFlatColumnsById')),
|
|
2918
|
+
getAllLeafColumns: memo(() => [table.getAllColumns(), table._getOrderColumnsFn()], (allColumns, orderColumns) => {
|
|
2919
|
+
let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
|
|
2920
|
+
return orderColumns(leafColumns);
|
|
2921
|
+
}, getMemoOptions(options, 'debugColumns', 'getAllLeafColumns')),
|
|
2922
|
+
getColumn: columnId => {
|
|
2923
|
+
const column = table._getAllFlatColumnsById()[columnId];
|
|
2924
|
+
if (!column) {
|
|
2925
|
+
console.error(`[Table] Column with id '${columnId}' does not exist.`);
|
|
2926
|
+
}
|
|
2927
|
+
return column;
|
|
2928
|
+
}
|
|
2821
2929
|
};
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2930
|
+
Object.assign(table, coreInstance);
|
|
2931
|
+
for (let index = 0; index < table._features.length; index++) {
|
|
2932
|
+
const feature = table._features[index];
|
|
2933
|
+
feature == null || feature.createTable == null || feature.createTable(table);
|
|
2825
2934
|
}
|
|
2826
|
-
return
|
|
2827
|
-
};
|
|
2828
|
-
|
|
2829
|
-
// type Person = {
|
|
2830
|
-
// firstName: string
|
|
2831
|
-
// lastName: string
|
|
2832
|
-
// age: number
|
|
2833
|
-
// visits: number
|
|
2834
|
-
// status: string
|
|
2835
|
-
// progress: number
|
|
2836
|
-
// createdAt: Date
|
|
2837
|
-
// nested: {
|
|
2838
|
-
// foo: [
|
|
2839
|
-
// {
|
|
2840
|
-
// bar: 'bar'
|
|
2841
|
-
// }
|
|
2842
|
-
// ]
|
|
2843
|
-
// bar: { subBar: boolean }[]
|
|
2844
|
-
// baz: {
|
|
2845
|
-
// foo: 'foo'
|
|
2846
|
-
// bar: {
|
|
2847
|
-
// baz: 'baz'
|
|
2848
|
-
// }
|
|
2849
|
-
// }
|
|
2850
|
-
// }
|
|
2851
|
-
// }
|
|
2852
|
-
|
|
2853
|
-
// const test: DeepKeys<Person> = 'nested.foo.0.bar'
|
|
2854
|
-
// const test2: DeepKeys<Person> = 'nested.bar'
|
|
2855
|
-
|
|
2856
|
-
// const helper = createColumnHelper<Person>()
|
|
2857
|
-
|
|
2858
|
-
// helper.accessor('nested.foo', {
|
|
2859
|
-
// cell: info => info.getValue(),
|
|
2860
|
-
// })
|
|
2861
|
-
|
|
2862
|
-
// helper.accessor('nested.foo.0.bar', {
|
|
2863
|
-
// cell: info => info.getValue(),
|
|
2864
|
-
// })
|
|
2865
|
-
|
|
2866
|
-
// helper.accessor('nested.bar', {
|
|
2867
|
-
// cell: info => info.getValue(),
|
|
2868
|
-
// })
|
|
2869
|
-
|
|
2870
|
-
function createColumnHelper() {
|
|
2871
|
-
return {
|
|
2872
|
-
accessor: (accessor, column) => {
|
|
2873
|
-
return typeof accessor === 'function' ? {
|
|
2874
|
-
...column,
|
|
2875
|
-
accessorFn: accessor
|
|
2876
|
-
} : {
|
|
2877
|
-
...column,
|
|
2878
|
-
accessorKey: accessor
|
|
2879
|
-
};
|
|
2880
|
-
},
|
|
2881
|
-
display: column => column,
|
|
2882
|
-
group: column => column
|
|
2883
|
-
};
|
|
2935
|
+
return table;
|
|
2884
2936
|
}
|
|
2885
2937
|
|
|
2886
2938
|
function getCoreRowModel() {
|
|
@@ -2931,6 +2983,62 @@
|
|
|
2931
2983
|
}, getMemoOptions(table.options, 'debugTable', 'getRowModel', () => table._autoResetPageIndex()));
|
|
2932
2984
|
}
|
|
2933
2985
|
|
|
2986
|
+
function getExpandedRowModel() {
|
|
2987
|
+
return table => memo(() => [table.getState().expanded, table.getPreExpandedRowModel(), table.options.paginateExpandedRows], (expanded, rowModel, paginateExpandedRows) => {
|
|
2988
|
+
if (!rowModel.rows.length || expanded !== true && !Object.keys(expanded != null ? expanded : {}).length) {
|
|
2989
|
+
return rowModel;
|
|
2990
|
+
}
|
|
2991
|
+
if (!paginateExpandedRows) {
|
|
2992
|
+
// Only expand rows at this point if they are being paginated
|
|
2993
|
+
return rowModel;
|
|
2994
|
+
}
|
|
2995
|
+
return expandRows(rowModel);
|
|
2996
|
+
}, getMemoOptions(table.options, 'debugTable', 'getExpandedRowModel'));
|
|
2997
|
+
}
|
|
2998
|
+
function expandRows(rowModel) {
|
|
2999
|
+
const expandedRows = [];
|
|
3000
|
+
const handleRow = row => {
|
|
3001
|
+
var _row$subRows;
|
|
3002
|
+
expandedRows.push(row);
|
|
3003
|
+
if ((_row$subRows = row.subRows) != null && _row$subRows.length && row.getIsExpanded()) {
|
|
3004
|
+
row.subRows.forEach(handleRow);
|
|
3005
|
+
}
|
|
3006
|
+
};
|
|
3007
|
+
rowModel.rows.forEach(handleRow);
|
|
3008
|
+
return {
|
|
3009
|
+
rows: expandedRows,
|
|
3010
|
+
flatRows: rowModel.flatRows,
|
|
3011
|
+
rowsById: rowModel.rowsById
|
|
3012
|
+
};
|
|
3013
|
+
}
|
|
3014
|
+
|
|
3015
|
+
function getFacetedMinMaxValues() {
|
|
3016
|
+
return (table, columnId) => memo(() => {
|
|
3017
|
+
var _table$getColumn;
|
|
3018
|
+
return [(_table$getColumn = table.getColumn(columnId)) == null ? void 0 : _table$getColumn.getFacetedRowModel()];
|
|
3019
|
+
}, facetedRowModel => {
|
|
3020
|
+
var _facetedRowModel$flat;
|
|
3021
|
+
if (!facetedRowModel) return undefined;
|
|
3022
|
+
const firstValue = (_facetedRowModel$flat = facetedRowModel.flatRows[0]) == null ? void 0 : _facetedRowModel$flat.getUniqueValues(columnId);
|
|
3023
|
+
if (typeof firstValue === 'undefined') {
|
|
3024
|
+
return undefined;
|
|
3025
|
+
}
|
|
3026
|
+
let facetedMinMaxValues = [firstValue, firstValue];
|
|
3027
|
+
for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
|
|
3028
|
+
const values = facetedRowModel.flatRows[i].getUniqueValues(columnId);
|
|
3029
|
+
for (let j = 0; j < values.length; j++) {
|
|
3030
|
+
const value = values[j];
|
|
3031
|
+
if (value < facetedMinMaxValues[0]) {
|
|
3032
|
+
facetedMinMaxValues[0] = value;
|
|
3033
|
+
} else if (value > facetedMinMaxValues[1]) {
|
|
3034
|
+
facetedMinMaxValues[1] = value;
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
3038
|
+
return facetedMinMaxValues;
|
|
3039
|
+
}, getMemoOptions(table.options, 'debugTable', 'getFacetedMinMaxValues'));
|
|
3040
|
+
}
|
|
3041
|
+
|
|
2934
3042
|
function filterRows(rows, filterRowImpl, table) {
|
|
2935
3043
|
if (table.options.filterFromLeafRows) {
|
|
2936
3044
|
return filterRowModelFromLeafs(rows, filterRowImpl, table);
|
|
@@ -3026,6 +3134,48 @@
|
|
|
3026
3134
|
};
|
|
3027
3135
|
}
|
|
3028
3136
|
|
|
3137
|
+
function getFacetedRowModel() {
|
|
3138
|
+
return (table, columnId) => memo(() => [table.getPreFilteredRowModel(), table.getState().columnFilters, table.getState().globalFilter, table.getFilteredRowModel()], (preRowModel, columnFilters, globalFilter) => {
|
|
3139
|
+
if (!preRowModel.rows.length || !(columnFilters != null && columnFilters.length) && !globalFilter) {
|
|
3140
|
+
return preRowModel;
|
|
3141
|
+
}
|
|
3142
|
+
const filterableIds = [...columnFilters.map(d => d.id).filter(d => d !== columnId), globalFilter ? '__global__' : undefined].filter(Boolean);
|
|
3143
|
+
const filterRowsImpl = row => {
|
|
3144
|
+
// Horizontally filter rows through each column
|
|
3145
|
+
for (let i = 0; i < filterableIds.length; i++) {
|
|
3146
|
+
if (row.columnFilters[filterableIds[i]] === false) {
|
|
3147
|
+
return false;
|
|
3148
|
+
}
|
|
3149
|
+
}
|
|
3150
|
+
return true;
|
|
3151
|
+
};
|
|
3152
|
+
return filterRows(preRowModel.rows, filterRowsImpl, table);
|
|
3153
|
+
}, getMemoOptions(table.options, 'debugTable', 'getFacetedRowModel'));
|
|
3154
|
+
}
|
|
3155
|
+
|
|
3156
|
+
function getFacetedUniqueValues() {
|
|
3157
|
+
return (table, columnId) => memo(() => {
|
|
3158
|
+
var _table$getColumn;
|
|
3159
|
+
return [(_table$getColumn = table.getColumn(columnId)) == null ? void 0 : _table$getColumn.getFacetedRowModel()];
|
|
3160
|
+
}, facetedRowModel => {
|
|
3161
|
+
if (!facetedRowModel) return new Map();
|
|
3162
|
+
let facetedUniqueValues = new Map();
|
|
3163
|
+
for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
|
|
3164
|
+
const values = facetedRowModel.flatRows[i].getUniqueValues(columnId);
|
|
3165
|
+
for (let j = 0; j < values.length; j++) {
|
|
3166
|
+
const value = values[j];
|
|
3167
|
+
if (facetedUniqueValues.has(value)) {
|
|
3168
|
+
var _facetedUniqueValues$;
|
|
3169
|
+
facetedUniqueValues.set(value, ((_facetedUniqueValues$ = facetedUniqueValues.get(value)) != null ? _facetedUniqueValues$ : 0) + 1);
|
|
3170
|
+
} else {
|
|
3171
|
+
facetedUniqueValues.set(value, 1);
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
}
|
|
3175
|
+
return facetedUniqueValues;
|
|
3176
|
+
}, getMemoOptions(table.options, 'debugTable', `getFacetedUniqueValues_${columnId}`));
|
|
3177
|
+
}
|
|
3178
|
+
|
|
3029
3179
|
function getFilteredRowModel() {
|
|
3030
3180
|
return table => memo(() => [table.getPreFilteredRowModel(), table.getState().columnFilters, table.getState().globalFilter], (rowModel, columnFilters, globalFilter) => {
|
|
3031
3181
|
if (!rowModel.rows.length || !(columnFilters != null && columnFilters.length) && !globalFilter) {
|
|
@@ -3098,34 +3248,13 @@
|
|
|
3098
3248
|
})) {
|
|
3099
3249
|
row.columnFilters.__global__ = true;
|
|
3100
3250
|
break;
|
|
3101
|
-
}
|
|
3102
|
-
}
|
|
3103
|
-
if (row.columnFilters.__global__ !== true) {
|
|
3104
|
-
row.columnFilters.__global__ = false;
|
|
3105
|
-
}
|
|
3106
|
-
}
|
|
3107
|
-
}
|
|
3108
|
-
const filterRowsImpl = row => {
|
|
3109
|
-
// Horizontally filter rows through each column
|
|
3110
|
-
for (let i = 0; i < filterableIds.length; i++) {
|
|
3111
|
-
if (row.columnFilters[filterableIds[i]] === false) {
|
|
3112
|
-
return false;
|
|
3113
|
-
}
|
|
3114
|
-
}
|
|
3115
|
-
return true;
|
|
3116
|
-
};
|
|
3117
|
-
|
|
3118
|
-
// Filter final rows using all of the active filters
|
|
3119
|
-
return filterRows(rowModel.rows, filterRowsImpl, table);
|
|
3120
|
-
}, getMemoOptions(table.options, 'debugTable', 'getFilteredRowModel', () => table._autoResetPageIndex()));
|
|
3121
|
-
}
|
|
3122
|
-
|
|
3123
|
-
function getFacetedRowModel() {
|
|
3124
|
-
return (table, columnId) => memo(() => [table.getPreFilteredRowModel(), table.getState().columnFilters, table.getState().globalFilter, table.getFilteredRowModel()], (preRowModel, columnFilters, globalFilter) => {
|
|
3125
|
-
if (!preRowModel.rows.length || !(columnFilters != null && columnFilters.length) && !globalFilter) {
|
|
3126
|
-
return preRowModel;
|
|
3251
|
+
}
|
|
3252
|
+
}
|
|
3253
|
+
if (row.columnFilters.__global__ !== true) {
|
|
3254
|
+
row.columnFilters.__global__ = false;
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3127
3257
|
}
|
|
3128
|
-
const filterableIds = [...columnFilters.map(d => d.id).filter(d => d !== columnId), globalFilter ? '__global__' : undefined].filter(Boolean);
|
|
3129
3258
|
const filterRowsImpl = row => {
|
|
3130
3259
|
// Horizontally filter rows through each column
|
|
3131
3260
|
for (let i = 0; i < filterableIds.length; i++) {
|
|
@@ -3135,141 +3264,10 @@
|
|
|
3135
3264
|
}
|
|
3136
3265
|
return true;
|
|
3137
3266
|
};
|
|
3138
|
-
return filterRows(preRowModel.rows, filterRowsImpl, table);
|
|
3139
|
-
}, getMemoOptions(table.options, 'debugTable', 'getFacetedRowModel'));
|
|
3140
|
-
}
|
|
3141
|
-
|
|
3142
|
-
function getFacetedUniqueValues() {
|
|
3143
|
-
return (table, columnId) => memo(() => {
|
|
3144
|
-
var _table$getColumn;
|
|
3145
|
-
return [(_table$getColumn = table.getColumn(columnId)) == null ? void 0 : _table$getColumn.getFacetedRowModel()];
|
|
3146
|
-
}, facetedRowModel => {
|
|
3147
|
-
if (!facetedRowModel) return new Map();
|
|
3148
|
-
let facetedUniqueValues = new Map();
|
|
3149
|
-
for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
|
|
3150
|
-
const values = facetedRowModel.flatRows[i].getUniqueValues(columnId);
|
|
3151
|
-
for (let j = 0; j < values.length; j++) {
|
|
3152
|
-
const value = values[j];
|
|
3153
|
-
if (facetedUniqueValues.has(value)) {
|
|
3154
|
-
var _facetedUniqueValues$;
|
|
3155
|
-
facetedUniqueValues.set(value, ((_facetedUniqueValues$ = facetedUniqueValues.get(value)) != null ? _facetedUniqueValues$ : 0) + 1);
|
|
3156
|
-
} else {
|
|
3157
|
-
facetedUniqueValues.set(value, 1);
|
|
3158
|
-
}
|
|
3159
|
-
}
|
|
3160
|
-
}
|
|
3161
|
-
return facetedUniqueValues;
|
|
3162
|
-
}, getMemoOptions(table.options, 'debugTable', `getFacetedUniqueValues_${columnId}`));
|
|
3163
|
-
}
|
|
3164
|
-
|
|
3165
|
-
function getFacetedMinMaxValues() {
|
|
3166
|
-
return (table, columnId) => memo(() => {
|
|
3167
|
-
var _table$getColumn;
|
|
3168
|
-
return [(_table$getColumn = table.getColumn(columnId)) == null ? void 0 : _table$getColumn.getFacetedRowModel()];
|
|
3169
|
-
}, facetedRowModel => {
|
|
3170
|
-
var _facetedRowModel$flat;
|
|
3171
|
-
if (!facetedRowModel) return undefined;
|
|
3172
|
-
const firstValue = (_facetedRowModel$flat = facetedRowModel.flatRows[0]) == null ? void 0 : _facetedRowModel$flat.getUniqueValues(columnId);
|
|
3173
|
-
if (typeof firstValue === 'undefined') {
|
|
3174
|
-
return undefined;
|
|
3175
|
-
}
|
|
3176
|
-
let facetedMinMaxValues = [firstValue, firstValue];
|
|
3177
|
-
for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
|
|
3178
|
-
const values = facetedRowModel.flatRows[i].getUniqueValues(columnId);
|
|
3179
|
-
for (let j = 0; j < values.length; j++) {
|
|
3180
|
-
const value = values[j];
|
|
3181
|
-
if (value < facetedMinMaxValues[0]) {
|
|
3182
|
-
facetedMinMaxValues[0] = value;
|
|
3183
|
-
} else if (value > facetedMinMaxValues[1]) {
|
|
3184
|
-
facetedMinMaxValues[1] = value;
|
|
3185
|
-
}
|
|
3186
|
-
}
|
|
3187
|
-
}
|
|
3188
|
-
return facetedMinMaxValues;
|
|
3189
|
-
}, getMemoOptions(table.options, 'debugTable', 'getFacetedMinMaxValues'));
|
|
3190
|
-
}
|
|
3191
|
-
|
|
3192
|
-
function getSortedRowModel() {
|
|
3193
|
-
return table => memo(() => [table.getState().sorting, table.getPreSortedRowModel()], (sorting, rowModel) => {
|
|
3194
|
-
if (!rowModel.rows.length || !(sorting != null && sorting.length)) {
|
|
3195
|
-
return rowModel;
|
|
3196
|
-
}
|
|
3197
|
-
const sortingState = table.getState().sorting;
|
|
3198
|
-
const sortedFlatRows = [];
|
|
3199
|
-
|
|
3200
|
-
// Filter out sortings that correspond to non existing columns
|
|
3201
|
-
const availableSorting = sortingState.filter(sort => {
|
|
3202
|
-
var _table$getColumn;
|
|
3203
|
-
return (_table$getColumn = table.getColumn(sort.id)) == null ? void 0 : _table$getColumn.getCanSort();
|
|
3204
|
-
});
|
|
3205
|
-
const columnInfoById = {};
|
|
3206
|
-
availableSorting.forEach(sortEntry => {
|
|
3207
|
-
const column = table.getColumn(sortEntry.id);
|
|
3208
|
-
if (!column) return;
|
|
3209
|
-
columnInfoById[sortEntry.id] = {
|
|
3210
|
-
sortUndefined: column.columnDef.sortUndefined,
|
|
3211
|
-
invertSorting: column.columnDef.invertSorting,
|
|
3212
|
-
sortingFn: column.getSortingFn()
|
|
3213
|
-
};
|
|
3214
|
-
});
|
|
3215
|
-
const sortData = rows => {
|
|
3216
|
-
// This will also perform a stable sorting using the row index
|
|
3217
|
-
// if needed.
|
|
3218
|
-
const sortedData = rows.map(row => ({
|
|
3219
|
-
...row
|
|
3220
|
-
}));
|
|
3221
|
-
sortedData.sort((rowA, rowB) => {
|
|
3222
|
-
for (let i = 0; i < availableSorting.length; i += 1) {
|
|
3223
|
-
var _sortEntry$desc;
|
|
3224
|
-
const sortEntry = availableSorting[i];
|
|
3225
|
-
const columnInfo = columnInfoById[sortEntry.id];
|
|
3226
|
-
const isDesc = (_sortEntry$desc = sortEntry == null ? void 0 : sortEntry.desc) != null ? _sortEntry$desc : false;
|
|
3227
|
-
let sortInt = 0;
|
|
3228
|
-
|
|
3229
|
-
// All sorting ints should always return in ascending order
|
|
3230
|
-
if (columnInfo.sortUndefined) {
|
|
3231
|
-
const aValue = rowA.getValue(sortEntry.id);
|
|
3232
|
-
const bValue = rowB.getValue(sortEntry.id);
|
|
3233
|
-
const aUndefined = aValue === undefined;
|
|
3234
|
-
const bUndefined = bValue === undefined;
|
|
3235
|
-
if (aUndefined || bUndefined) {
|
|
3236
|
-
sortInt = aUndefined && bUndefined ? 0 : aUndefined ? columnInfo.sortUndefined : -columnInfo.sortUndefined;
|
|
3237
|
-
}
|
|
3238
|
-
}
|
|
3239
|
-
if (sortInt === 0) {
|
|
3240
|
-
sortInt = columnInfo.sortingFn(rowA, rowB, sortEntry.id);
|
|
3241
|
-
}
|
|
3242
|
-
|
|
3243
|
-
// If sorting is non-zero, take care of desc and inversion
|
|
3244
|
-
if (sortInt !== 0) {
|
|
3245
|
-
if (isDesc) {
|
|
3246
|
-
sortInt *= -1;
|
|
3247
|
-
}
|
|
3248
|
-
if (columnInfo.invertSorting) {
|
|
3249
|
-
sortInt *= -1;
|
|
3250
|
-
}
|
|
3251
|
-
return sortInt;
|
|
3252
|
-
}
|
|
3253
|
-
}
|
|
3254
|
-
return rowA.index - rowB.index;
|
|
3255
|
-
});
|
|
3256
3267
|
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
sortedFlatRows.push(row);
|
|
3261
|
-
if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
|
|
3262
|
-
row.subRows = sortData(row.subRows);
|
|
3263
|
-
}
|
|
3264
|
-
});
|
|
3265
|
-
return sortedData;
|
|
3266
|
-
};
|
|
3267
|
-
return {
|
|
3268
|
-
rows: sortData(rowModel.rows),
|
|
3269
|
-
flatRows: sortedFlatRows,
|
|
3270
|
-
rowsById: rowModel.rowsById
|
|
3271
|
-
};
|
|
3272
|
-
}, getMemoOptions(table.options, 'debugTable', 'getSortedRowModel', () => table._autoResetPageIndex()));
|
|
3268
|
+
// Filter final rows using all of the active filters
|
|
3269
|
+
return filterRows(rowModel.rows, filterRowsImpl, table);
|
|
3270
|
+
}, getMemoOptions(table.options, 'debugTable', 'getFilteredRowModel', () => table._autoResetPageIndex()));
|
|
3273
3271
|
}
|
|
3274
3272
|
|
|
3275
3273
|
function getGroupedRowModel() {
|
|
@@ -3405,35 +3403,6 @@
|
|
|
3405
3403
|
}, groupMap);
|
|
3406
3404
|
}
|
|
3407
3405
|
|
|
3408
|
-
function getExpandedRowModel() {
|
|
3409
|
-
return table => memo(() => [table.getState().expanded, table.getPreExpandedRowModel(), table.options.paginateExpandedRows], (expanded, rowModel, paginateExpandedRows) => {
|
|
3410
|
-
if (!rowModel.rows.length || expanded !== true && !Object.keys(expanded != null ? expanded : {}).length) {
|
|
3411
|
-
return rowModel;
|
|
3412
|
-
}
|
|
3413
|
-
if (!paginateExpandedRows) {
|
|
3414
|
-
// Only expand rows at this point if they are being paginated
|
|
3415
|
-
return rowModel;
|
|
3416
|
-
}
|
|
3417
|
-
return expandRows(rowModel);
|
|
3418
|
-
}, getMemoOptions(table.options, 'debugTable', 'getExpandedRowModel'));
|
|
3419
|
-
}
|
|
3420
|
-
function expandRows(rowModel) {
|
|
3421
|
-
const expandedRows = [];
|
|
3422
|
-
const handleRow = row => {
|
|
3423
|
-
var _row$subRows;
|
|
3424
|
-
expandedRows.push(row);
|
|
3425
|
-
if ((_row$subRows = row.subRows) != null && _row$subRows.length && row.getIsExpanded()) {
|
|
3426
|
-
row.subRows.forEach(handleRow);
|
|
3427
|
-
}
|
|
3428
|
-
};
|
|
3429
|
-
rowModel.rows.forEach(handleRow);
|
|
3430
|
-
return {
|
|
3431
|
-
rows: expandedRows,
|
|
3432
|
-
flatRows: rowModel.flatRows,
|
|
3433
|
-
rowsById: rowModel.rowsById
|
|
3434
|
-
};
|
|
3435
|
-
}
|
|
3436
|
-
|
|
3437
3406
|
function getPaginationRowModel(opts) {
|
|
3438
3407
|
return table => memo(() => [table.getState().pagination, table.getPrePaginationRowModel(), table.options.paginateExpandedRows ? undefined : table.getState().expanded], (pagination, rowModel) => {
|
|
3439
3408
|
if (!rowModel.rows.length) {
|
|
@@ -3477,7 +3446,90 @@
|
|
|
3477
3446
|
}, getMemoOptions(table.options, 'debugTable', 'getPaginationRowModel'));
|
|
3478
3447
|
}
|
|
3479
3448
|
|
|
3480
|
-
|
|
3449
|
+
function getSortedRowModel() {
|
|
3450
|
+
return table => memo(() => [table.getState().sorting, table.getPreSortedRowModel()], (sorting, rowModel) => {
|
|
3451
|
+
if (!rowModel.rows.length || !(sorting != null && sorting.length)) {
|
|
3452
|
+
return rowModel;
|
|
3453
|
+
}
|
|
3454
|
+
const sortingState = table.getState().sorting;
|
|
3455
|
+
const sortedFlatRows = [];
|
|
3456
|
+
|
|
3457
|
+
// Filter out sortings that correspond to non existing columns
|
|
3458
|
+
const availableSorting = sortingState.filter(sort => {
|
|
3459
|
+
var _table$getColumn;
|
|
3460
|
+
return (_table$getColumn = table.getColumn(sort.id)) == null ? void 0 : _table$getColumn.getCanSort();
|
|
3461
|
+
});
|
|
3462
|
+
const columnInfoById = {};
|
|
3463
|
+
availableSorting.forEach(sortEntry => {
|
|
3464
|
+
const column = table.getColumn(sortEntry.id);
|
|
3465
|
+
if (!column) return;
|
|
3466
|
+
columnInfoById[sortEntry.id] = {
|
|
3467
|
+
sortUndefined: column.columnDef.sortUndefined,
|
|
3468
|
+
invertSorting: column.columnDef.invertSorting,
|
|
3469
|
+
sortingFn: column.getSortingFn()
|
|
3470
|
+
};
|
|
3471
|
+
});
|
|
3472
|
+
const sortData = rows => {
|
|
3473
|
+
// This will also perform a stable sorting using the row index
|
|
3474
|
+
// if needed.
|
|
3475
|
+
const sortedData = rows.map(row => ({
|
|
3476
|
+
...row
|
|
3477
|
+
}));
|
|
3478
|
+
sortedData.sort((rowA, rowB) => {
|
|
3479
|
+
for (let i = 0; i < availableSorting.length; i += 1) {
|
|
3480
|
+
var _sortEntry$desc;
|
|
3481
|
+
const sortEntry = availableSorting[i];
|
|
3482
|
+
const columnInfo = columnInfoById[sortEntry.id];
|
|
3483
|
+
const isDesc = (_sortEntry$desc = sortEntry == null ? void 0 : sortEntry.desc) != null ? _sortEntry$desc : false;
|
|
3484
|
+
let sortInt = 0;
|
|
3485
|
+
|
|
3486
|
+
// All sorting ints should always return in ascending order
|
|
3487
|
+
if (columnInfo.sortUndefined) {
|
|
3488
|
+
const aValue = rowA.getValue(sortEntry.id);
|
|
3489
|
+
const bValue = rowB.getValue(sortEntry.id);
|
|
3490
|
+
const aUndefined = aValue === undefined;
|
|
3491
|
+
const bUndefined = bValue === undefined;
|
|
3492
|
+
if (aUndefined || bUndefined) {
|
|
3493
|
+
sortInt = aUndefined && bUndefined ? 0 : aUndefined ? columnInfo.sortUndefined : -columnInfo.sortUndefined;
|
|
3494
|
+
}
|
|
3495
|
+
}
|
|
3496
|
+
if (sortInt === 0) {
|
|
3497
|
+
sortInt = columnInfo.sortingFn(rowA, rowB, sortEntry.id);
|
|
3498
|
+
}
|
|
3499
|
+
|
|
3500
|
+
// If sorting is non-zero, take care of desc and inversion
|
|
3501
|
+
if (sortInt !== 0) {
|
|
3502
|
+
if (isDesc) {
|
|
3503
|
+
sortInt *= -1;
|
|
3504
|
+
}
|
|
3505
|
+
if (columnInfo.invertSorting) {
|
|
3506
|
+
sortInt *= -1;
|
|
3507
|
+
}
|
|
3508
|
+
return sortInt;
|
|
3509
|
+
}
|
|
3510
|
+
}
|
|
3511
|
+
return rowA.index - rowB.index;
|
|
3512
|
+
});
|
|
3513
|
+
|
|
3514
|
+
// If there are sub-rows, sort them
|
|
3515
|
+
sortedData.forEach(row => {
|
|
3516
|
+
var _row$subRows;
|
|
3517
|
+
sortedFlatRows.push(row);
|
|
3518
|
+
if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
|
|
3519
|
+
row.subRows = sortData(row.subRows);
|
|
3520
|
+
}
|
|
3521
|
+
});
|
|
3522
|
+
return sortedData;
|
|
3523
|
+
};
|
|
3524
|
+
return {
|
|
3525
|
+
rows: sortData(rowModel.rows),
|
|
3526
|
+
flatRows: sortedFlatRows,
|
|
3527
|
+
rowsById: rowModel.rowsById
|
|
3528
|
+
};
|
|
3529
|
+
}, getMemoOptions(table.options, 'debugTable', 'getSortedRowModel', () => table._autoResetPageIndex()));
|
|
3530
|
+
}
|
|
3531
|
+
|
|
3532
|
+
/* src/placeholder.svelte generated by Svelte v3.59.2 */
|
|
3481
3533
|
|
|
3482
3534
|
function create_fragment$1(ctx) {
|
|
3483
3535
|
let t;
|
|
@@ -3495,9 +3547,7 @@
|
|
|
3495
3547
|
i: internal.noop,
|
|
3496
3548
|
o: internal.noop,
|
|
3497
3549
|
d(detaching) {
|
|
3498
|
-
if (detaching)
|
|
3499
|
-
internal.detach(t);
|
|
3500
|
-
}
|
|
3550
|
+
if (detaching) internal.detach(t);
|
|
3501
3551
|
}
|
|
3502
3552
|
};
|
|
3503
3553
|
}
|
|
@@ -3662,17 +3712,21 @@
|
|
|
3662
3712
|
return tableReadable;
|
|
3663
3713
|
}
|
|
3664
3714
|
|
|
3715
|
+
exports.ColumnFaceting = ColumnFaceting;
|
|
3716
|
+
exports.ColumnFiltering = ColumnFiltering;
|
|
3717
|
+
exports.ColumnGrouping = ColumnGrouping;
|
|
3718
|
+
exports.ColumnOrdering = ColumnOrdering;
|
|
3719
|
+
exports.ColumnPinning = ColumnPinning;
|
|
3665
3720
|
exports.ColumnSizing = ColumnSizing;
|
|
3666
|
-
exports.
|
|
3667
|
-
exports.
|
|
3668
|
-
exports.
|
|
3721
|
+
exports.ColumnVisibility = ColumnVisibility;
|
|
3722
|
+
exports.GlobalFaceting = GlobalFaceting;
|
|
3723
|
+
exports.GlobalFiltering = GlobalFiltering;
|
|
3669
3724
|
exports.Headers = Headers;
|
|
3670
|
-
exports.
|
|
3671
|
-
exports.
|
|
3672
|
-
exports.
|
|
3725
|
+
exports.RowExpanding = RowExpanding;
|
|
3726
|
+
exports.RowPagination = RowPagination;
|
|
3727
|
+
exports.RowPinning = RowPinning;
|
|
3673
3728
|
exports.RowSelection = RowSelection;
|
|
3674
|
-
exports.
|
|
3675
|
-
exports.Visibility = Visibility;
|
|
3729
|
+
exports.RowSorting = RowSorting;
|
|
3676
3730
|
exports._getVisibleLeafColumns = _getVisibleLeafColumns;
|
|
3677
3731
|
exports.aggregationFns = aggregationFns;
|
|
3678
3732
|
exports.buildHeaderGroups = buildHeaderGroups;
|