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