@tanstack/react-table 8.0.0-alpha.2 → 8.0.0-alpha.5
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/cjs/core.js +85 -52
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/createTable.js +11 -6
- package/build/cjs/createTable.js.map +1 -1
- package/build/cjs/features/ColumnSizing.js +2 -16
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Expanding.js +23 -2
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js +54 -5
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +23 -2
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Headers.js +87 -24
- package/build/cjs/features/Headers.js.map +1 -1
- package/build/cjs/features/Ordering.js +4 -1
- package/build/cjs/features/Ordering.js.map +1 -1
- package/build/cjs/features/Pagination.js +198 -0
- package/build/cjs/features/Pagination.js.map +1 -0
- package/build/cjs/features/Pinning.js +0 -14
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js +541 -0
- package/build/cjs/features/RowSelection.js.map +1 -0
- package/build/cjs/features/Sorting.js +76 -18
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +8 -2
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/index.js +2 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/sortTypes.js +1 -0
- package/build/cjs/sortTypes.js.map +1 -1
- package/build/cjs/utils/columnFilterRowsFn.js +3 -2
- package/build/cjs/utils/columnFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/expandRowsFn.js +2 -2
- package/build/cjs/utils/expandRowsFn.js.map +1 -1
- package/build/cjs/utils/globalFilterRowsFn.js +3 -2
- package/build/cjs/utils/globalFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/groupRowsFn.js +4 -3
- package/build/cjs/utils/groupRowsFn.js.map +1 -1
- package/build/cjs/utils/paginateRowsFn.js +44 -0
- package/build/cjs/utils/paginateRowsFn.js.map +1 -0
- package/build/cjs/utils/sortRowsFn.js +3 -2
- package/build/cjs/utils/sortRowsFn.js.map +1 -1
- package/build/cjs/utils.js +6 -3
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +2626 -1571
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +350 -248
- package/build/types/core.d.ts +10 -25
- package/build/types/createTable.d.ts +21 -4
- package/build/types/features/ColumnSizing.d.ts +4 -10
- package/build/types/features/Expanding.d.ts +2 -1
- package/build/types/features/Filters.d.ts +7 -2
- package/build/types/features/Grouping.d.ts +2 -2
- package/build/types/features/Ordering.d.ts +1 -1
- package/build/types/features/Pagination.d.ts +44 -0
- package/build/types/features/Pinning.d.ts +3 -3
- package/build/types/features/RowSelection.d.ts +66 -0
- package/build/types/features/Sorting.d.ts +5 -2
- package/build/types/index.d.ts +2 -1
- package/build/types/sortTypes.d.ts +1 -0
- package/build/types/types.d.ts +9 -6
- package/build/types/utils/columnFilterRowsFn.d.ts +2 -2
- package/build/types/utils/expandRowsFn.d.ts +2 -2
- package/build/types/utils/globalFilterRowsFn.d.ts +2 -2
- package/build/types/utils/groupRowsFn.d.ts +2 -2
- package/build/types/utils/paginateRowsFn.d.ts +2 -0
- package/build/types/utils/sortRowsFn.d.ts +2 -2
- package/build/types/utils.d.ts +5 -1
- package/build/umd/index.development.js +2626 -1570
- 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/core.tsx +222 -273
- package/src/createTable.tsx +69 -9
- package/src/features/ColumnSizing.ts +8 -37
- package/src/features/Expanding.ts +27 -11
- package/src/features/Filters.ts +74 -19
- package/src/features/Grouping.ts +27 -12
- package/src/features/Headers.ts +26 -58
- package/src/features/Ordering.ts +2 -3
- package/src/features/Pagination.ts +327 -0
- package/src/features/Pinning.ts +3 -16
- package/src/features/RowSelection.ts +831 -0
- package/src/features/Sorting.ts +82 -22
- package/src/features/Visibility.ts +2 -4
- package/src/index.tsx +2 -1
- package/src/sortTypes.ts +1 -1
- package/src/types.ts +25 -8
- package/src/utils/columnFilterRowsFn.ts +5 -12
- package/src/utils/expandRowsFn.ts +2 -5
- package/src/utils/globalFilterRowsFn.ts +3 -10
- package/src/utils/groupRowsFn.ts +3 -5
- package/src/utils/paginateRowsFn.ts +34 -0
- package/src/utils/sortRowsFn.ts +5 -5
- package/src/utils.tsx +12 -4
- package/src/features/withPagination.oldts +0 -208
- package/src/features/withRowSelection.oldts +0 -467
package/build/esm/index.js
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
import * as React from 'react';
|
|
12
12
|
import React__default from 'react';
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
function columnFilterRowsFn(instance, rowModel) {
|
|
15
|
+
var columnFilters = instance.getState().columnFilters;
|
|
15
16
|
var newFilteredFlatRows = [];
|
|
16
17
|
var newFilteredRowsById = {};
|
|
17
18
|
var filterFromChildrenUp = instance.options.filterFromChildrenUp;
|
|
@@ -123,9 +124,10 @@ var columnFilterRowsFn = function columnFilterRowsFn(instance, columnFilters, ro
|
|
|
123
124
|
flatRows: newFilteredFlatRows,
|
|
124
125
|
rowsById: newFilteredRowsById
|
|
125
126
|
};
|
|
126
|
-
}
|
|
127
|
+
}
|
|
127
128
|
|
|
128
|
-
|
|
129
|
+
function globalFilterRowsFn(instance, rowModel) {
|
|
130
|
+
var globalFilter = instance.getState().globalFilter;
|
|
129
131
|
var newFilteredFlatRows = [];
|
|
130
132
|
var newFilteredRowsById = {};
|
|
131
133
|
var filterFromChildrenUp = instance.options.filterFromChildrenUp;
|
|
@@ -207,9 +209,10 @@ var globalFilterRowsFn = function globalFilterRowsFn(instance, globalFilter, row
|
|
|
207
209
|
flatRows: newFilteredFlatRows,
|
|
208
210
|
rowsById: newFilteredRowsById
|
|
209
211
|
};
|
|
210
|
-
}
|
|
212
|
+
}
|
|
211
213
|
|
|
212
|
-
|
|
214
|
+
function sortRowsFn(instance, rowModel) {
|
|
215
|
+
var sortingState = instance.getState().sorting;
|
|
213
216
|
var sortedFlatRows = []; // Filter out sortings that correspond to non existing columns
|
|
214
217
|
|
|
215
218
|
var availableSorting = sortingState.filter(function (sort) {
|
|
@@ -284,7 +287,7 @@ var sortRowsFn = function sortRowsFn(instance, sortingState, rowModel) {
|
|
|
284
287
|
flatRows: sortedFlatRows,
|
|
285
288
|
rowsById: rowModel.rowsById
|
|
286
289
|
};
|
|
287
|
-
}
|
|
290
|
+
}
|
|
288
291
|
|
|
289
292
|
function _extends() {
|
|
290
293
|
_extends = Object.assign || function (target) {
|
|
@@ -418,7 +421,7 @@ var propGetter = function propGetter(initial, getter) {
|
|
|
418
421
|
|
|
419
422
|
return _extends({}, initial, getter != null ? getter : {});
|
|
420
423
|
};
|
|
421
|
-
function memo(getDeps, fn,
|
|
424
|
+
function memo(getDeps, fn, opts) {
|
|
422
425
|
var deps = [];
|
|
423
426
|
var result;
|
|
424
427
|
return function () {
|
|
@@ -430,8 +433,8 @@ function memo(getDeps, fn, key, debug) {
|
|
|
430
433
|
});
|
|
431
434
|
|
|
432
435
|
if (depsChanged) {
|
|
433
|
-
if (debug) {
|
|
434
|
-
console.info(key, _extends({
|
|
436
|
+
if (opts != null && opts.debug) {
|
|
437
|
+
console.info(opts == null ? void 0 : opts.key, _extends({
|
|
435
438
|
length: oldSerializedDeps.length + " -> " + newSerializedDeps.length
|
|
436
439
|
}, newSerializedDeps.map(function (_, index) {
|
|
437
440
|
if (oldSerializedDeps[index] !== newSerializedDeps[index]) {
|
|
@@ -448,8 +451,11 @@ function memo(getDeps, fn, key, debug) {
|
|
|
448
451
|
}));
|
|
449
452
|
}
|
|
450
453
|
|
|
454
|
+
var oldResult = result;
|
|
451
455
|
result = fn.apply(void 0, newDeps);
|
|
452
456
|
deps = newSerializedDeps;
|
|
457
|
+
opts == null ? void 0 : opts.onChange == null ? void 0 : opts.onChange(result, oldResult);
|
|
458
|
+
oldResult = undefined;
|
|
453
459
|
}
|
|
454
460
|
|
|
455
461
|
return result;
|
|
@@ -490,8 +496,9 @@ function isExoticComponent(component) {
|
|
|
490
496
|
// return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString()
|
|
491
497
|
// }
|
|
492
498
|
|
|
493
|
-
|
|
494
|
-
// Filter the grouping list down to columns that exist
|
|
499
|
+
function groupRowsFn(instance, sortedRowModel) {
|
|
500
|
+
var groupingState = instance.getState().grouping; // Filter the grouping list down to columns that exist
|
|
501
|
+
|
|
495
502
|
var existingGrouping = groupingState.filter(function (columnId) {
|
|
496
503
|
return instance.getColumn(columnId);
|
|
497
504
|
}); // Find the columns that can or are aggregating
|
|
@@ -608,7 +615,7 @@ var groupRowsFn = function groupRowsFn(instance, groupingState, sortedRowModel)
|
|
|
608
615
|
flatRows: groupedFlatRows,
|
|
609
616
|
rowsById: groupedRowsById
|
|
610
617
|
};
|
|
611
|
-
}
|
|
618
|
+
}
|
|
612
619
|
|
|
613
620
|
function groupBy(rows, columnId) {
|
|
614
621
|
var groupMap = new Map();
|
|
@@ -626,7 +633,7 @@ function groupBy(rows, columnId) {
|
|
|
626
633
|
}, groupMap);
|
|
627
634
|
}
|
|
628
635
|
|
|
629
|
-
|
|
636
|
+
function expandRowsFn(instance, sortedRowModel) {
|
|
630
637
|
var expandedRows = [];
|
|
631
638
|
var expandSubRows = instance.options.expandSubRows;
|
|
632
639
|
|
|
@@ -646,15 +653,41 @@ var expandRowsFn = function expandRowsFn(instance, _expandedState, sortedRowMode
|
|
|
646
653
|
flatRows: sortedRowModel.flatRows,
|
|
647
654
|
rowsById: sortedRowModel.rowsById
|
|
648
655
|
};
|
|
649
|
-
}
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
function paginateRowsFn(instance, rowModel) {
|
|
659
|
+
var _instance$getState$pa = instance.getState().pagination,
|
|
660
|
+
pageSize = _instance$getState$pa.pageSize,
|
|
661
|
+
pageIndex = _instance$getState$pa.pageIndex;
|
|
662
|
+
var rows = rowModel.rows,
|
|
663
|
+
flatRows = rowModel.flatRows,
|
|
664
|
+
rowsById = rowModel.rowsById;
|
|
665
|
+
var pageStart = pageSize * pageIndex;
|
|
666
|
+
var pageEnd = pageStart + pageSize;
|
|
667
|
+
rows = rows.slice(pageStart, pageEnd);
|
|
668
|
+
|
|
669
|
+
if (!instance.options.paginateExpandedRows) {
|
|
670
|
+
return expandRowsFn(instance, {
|
|
671
|
+
rows: rows,
|
|
672
|
+
flatRows: flatRows,
|
|
673
|
+
rowsById: rowsById
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
return {
|
|
678
|
+
rows: rows,
|
|
679
|
+
flatRows: flatRows,
|
|
680
|
+
rowsById: rowsById
|
|
681
|
+
};
|
|
682
|
+
}
|
|
650
683
|
|
|
651
684
|
//
|
|
652
|
-
function getInitialState$
|
|
685
|
+
function getInitialState$9() {
|
|
653
686
|
return {
|
|
654
687
|
columnVisibility: {}
|
|
655
688
|
};
|
|
656
689
|
}
|
|
657
|
-
function getDefaultOptions$
|
|
690
|
+
function getDefaultOptions$9(instance) {
|
|
658
691
|
return {
|
|
659
692
|
onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
|
|
660
693
|
};
|
|
@@ -688,7 +721,7 @@ function createColumn$5(column, instance) {
|
|
|
688
721
|
}
|
|
689
722
|
};
|
|
690
723
|
}
|
|
691
|
-
function getInstance$
|
|
724
|
+
function getInstance$a(instance) {
|
|
692
725
|
return {
|
|
693
726
|
getVisibleFlatColumns: memo(function () {
|
|
694
727
|
return [instance.getAllFlatColumns(), instance.getAllFlatColumns().filter(function (d) {
|
|
@@ -700,7 +733,10 @@ function getInstance$8(instance) {
|
|
|
700
733
|
return allFlatColumns.filter(function (d) {
|
|
701
734
|
return d.getIsVisible == null ? void 0 : d.getIsVisible();
|
|
702
735
|
});
|
|
703
|
-
},
|
|
736
|
+
}, {
|
|
737
|
+
key: 'getVisibleFlatColumns',
|
|
738
|
+
debug: instance.options.debug
|
|
739
|
+
}),
|
|
704
740
|
getVisibleLeafColumns: memo(function () {
|
|
705
741
|
return [instance.getAllLeafColumns(), instance.getAllLeafColumns().filter(function (d) {
|
|
706
742
|
return d.getIsVisible == null ? void 0 : d.getIsVisible();
|
|
@@ -711,7 +747,10 @@ function getInstance$8(instance) {
|
|
|
711
747
|
return allFlatColumns.filter(function (d) {
|
|
712
748
|
return d.getIsVisible == null ? void 0 : d.getIsVisible();
|
|
713
749
|
});
|
|
714
|
-
},
|
|
750
|
+
}, {
|
|
751
|
+
key: 'getVisibleLeafColumns',
|
|
752
|
+
debug: instance.options.debug
|
|
753
|
+
}),
|
|
715
754
|
setColumnVisibility: function setColumnVisibility(updater) {
|
|
716
755
|
return instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater, functionalUpdate(updater, instance.getState().columnVisibility));
|
|
717
756
|
},
|
|
@@ -785,6 +824,15 @@ function getInstance$8(instance) {
|
|
|
785
824
|
};
|
|
786
825
|
}
|
|
787
826
|
|
|
827
|
+
var Visibility = /*#__PURE__*/Object.freeze({
|
|
828
|
+
__proto__: null,
|
|
829
|
+
getInitialState: getInitialState$9,
|
|
830
|
+
getDefaultOptions: getDefaultOptions$9,
|
|
831
|
+
getDefaultColumn: getDefaultColumn$3,
|
|
832
|
+
createColumn: createColumn$5,
|
|
833
|
+
getInstance: getInstance$a
|
|
834
|
+
});
|
|
835
|
+
|
|
788
836
|
var aggregationTypes = {
|
|
789
837
|
sum: sum,
|
|
790
838
|
min: min,
|
|
@@ -903,12 +951,12 @@ function getDefaultColumn$2() {
|
|
|
903
951
|
aggregationType: 'auto'
|
|
904
952
|
};
|
|
905
953
|
}
|
|
906
|
-
function getInitialState$
|
|
954
|
+
function getInitialState$8() {
|
|
907
955
|
return {
|
|
908
956
|
grouping: []
|
|
909
957
|
};
|
|
910
958
|
}
|
|
911
|
-
function getDefaultOptions$
|
|
959
|
+
function getDefaultOptions$8(instance) {
|
|
912
960
|
return {
|
|
913
961
|
onGroupingChange: makeStateUpdater('grouping', instance),
|
|
914
962
|
autoResetGrouping: true,
|
|
@@ -935,8 +983,23 @@ function createColumn$4(column, instance) {
|
|
|
935
983
|
}
|
|
936
984
|
};
|
|
937
985
|
}
|
|
938
|
-
function getInstance$
|
|
986
|
+
function getInstance$9(instance) {
|
|
987
|
+
var registered = false;
|
|
939
988
|
return {
|
|
989
|
+
_notifyGroupingReset: function _notifyGroupingReset() {
|
|
990
|
+
if (!registered) {
|
|
991
|
+
registered = true;
|
|
992
|
+
return;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
if (instance.options.autoResetAll === false) {
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
if (instance.options.autoResetAll === true || instance.options.autoResetGrouping) {
|
|
1000
|
+
instance.resetGrouping();
|
|
1001
|
+
}
|
|
1002
|
+
},
|
|
940
1003
|
getColumnAutoAggregationFn: function getColumnAutoAggregationFn(columnId) {
|
|
941
1004
|
var firstRow = instance.getCoreFlatRows()[0];
|
|
942
1005
|
var value = firstRow == null ? void 0 : firstRow.values[columnId];
|
|
@@ -1034,8 +1097,14 @@ function getInstance$7(instance) {
|
|
|
1034
1097
|
}
|
|
1035
1098
|
|
|
1036
1099
|
if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Grouping...');
|
|
1037
|
-
return groupRowsFn(instance,
|
|
1038
|
-
},
|
|
1100
|
+
return groupRowsFn(instance, rowModel);
|
|
1101
|
+
}, {
|
|
1102
|
+
key: 'getGroupedRowModel',
|
|
1103
|
+
debug: instance.options.debug,
|
|
1104
|
+
onChange: function onChange() {
|
|
1105
|
+
return instance._notifyExpandedReset();
|
|
1106
|
+
}
|
|
1107
|
+
}),
|
|
1039
1108
|
getPreGroupedRows: function getPreGroupedRows() {
|
|
1040
1109
|
return instance.getSortedRowModel().rows;
|
|
1041
1110
|
},
|
|
@@ -1056,7 +1125,7 @@ function getInstance$7(instance) {
|
|
|
1056
1125
|
}
|
|
1057
1126
|
};
|
|
1058
1127
|
}
|
|
1059
|
-
function createRow$
|
|
1128
|
+
function createRow$3(row, instance) {
|
|
1060
1129
|
return {
|
|
1061
1130
|
getIsGrouped: function getIsGrouped() {
|
|
1062
1131
|
return instance.getRowIsGrouped(row.id);
|
|
@@ -1099,18 +1168,30 @@ function orderColumns(leafColumns, grouping, groupedColumnMode) {
|
|
|
1099
1168
|
return [].concat(groupingColumns, nonGroupingColumns);
|
|
1100
1169
|
}
|
|
1101
1170
|
|
|
1171
|
+
var Grouping = /*#__PURE__*/Object.freeze({
|
|
1172
|
+
__proto__: null,
|
|
1173
|
+
getDefaultColumn: getDefaultColumn$2,
|
|
1174
|
+
getInitialState: getInitialState$8,
|
|
1175
|
+
getDefaultOptions: getDefaultOptions$8,
|
|
1176
|
+
createColumn: createColumn$4,
|
|
1177
|
+
getInstance: getInstance$9,
|
|
1178
|
+
createRow: createRow$3,
|
|
1179
|
+
createCell: createCell,
|
|
1180
|
+
orderColumns: orderColumns
|
|
1181
|
+
});
|
|
1182
|
+
|
|
1102
1183
|
//
|
|
1103
|
-
function getInitialState$
|
|
1184
|
+
function getInitialState$7() {
|
|
1104
1185
|
return {
|
|
1105
1186
|
columnOrder: []
|
|
1106
1187
|
};
|
|
1107
1188
|
}
|
|
1108
|
-
function getDefaultOptions$
|
|
1189
|
+
function getDefaultOptions$7(instance) {
|
|
1109
1190
|
return {
|
|
1110
1191
|
onColumnOrderChange: makeStateUpdater('columnOrder', instance)
|
|
1111
1192
|
};
|
|
1112
1193
|
}
|
|
1113
|
-
function getInstance$
|
|
1194
|
+
function getInstance$8(instance) {
|
|
1114
1195
|
return {
|
|
1115
1196
|
setColumnOrder: function setColumnOrder(updater) {
|
|
1116
1197
|
return instance.options.onColumnOrderChange == null ? void 0 : instance.options.onColumnOrderChange(updater, functionalUpdate(updater, instance.getState().columnOrder));
|
|
@@ -1157,12 +1238,22 @@ function getInstance$6(instance) {
|
|
|
1157
1238
|
|
|
1158
1239
|
return orderColumns(orderedColumns, grouping, groupedColumnMode);
|
|
1159
1240
|
};
|
|
1160
|
-
},
|
|
1241
|
+
}, {
|
|
1242
|
+
key: 'getOrderColumnsFn',
|
|
1243
|
+
debug: instance.options.debug
|
|
1244
|
+
})
|
|
1161
1245
|
};
|
|
1162
1246
|
}
|
|
1163
1247
|
|
|
1248
|
+
var Ordering = /*#__PURE__*/Object.freeze({
|
|
1249
|
+
__proto__: null,
|
|
1250
|
+
getInitialState: getInitialState$7,
|
|
1251
|
+
getDefaultOptions: getDefaultOptions$7,
|
|
1252
|
+
getInstance: getInstance$8
|
|
1253
|
+
});
|
|
1254
|
+
|
|
1164
1255
|
//
|
|
1165
|
-
function getInitialState$
|
|
1256
|
+
function getInitialState$6() {
|
|
1166
1257
|
return {
|
|
1167
1258
|
columnPinning: {
|
|
1168
1259
|
left: [],
|
|
@@ -1170,7 +1261,7 @@ function getInitialState$4() {
|
|
|
1170
1261
|
}
|
|
1171
1262
|
};
|
|
1172
1263
|
}
|
|
1173
|
-
function getDefaultOptions$
|
|
1264
|
+
function getDefaultOptions$6(instance) {
|
|
1174
1265
|
return {
|
|
1175
1266
|
onColumnPinningChange: makeStateUpdater('columnPinning', instance)
|
|
1176
1267
|
};
|
|
@@ -1191,7 +1282,7 @@ function createColumn$3(column, instance) {
|
|
|
1191
1282
|
}
|
|
1192
1283
|
};
|
|
1193
1284
|
}
|
|
1194
|
-
function getInstance$
|
|
1285
|
+
function getInstance$7(instance) {
|
|
1195
1286
|
return {
|
|
1196
1287
|
setColumnPinning: function setColumnPinning(updater) {
|
|
1197
1288
|
return instance.options.onColumnPinningChange == null ? void 0 : instance.options.onColumnPinningChange(updater, functionalUpdate(updater, instance.getState().columnPinning));
|
|
@@ -1278,1892 +1369,2821 @@ function getInstance$5(instance) {
|
|
|
1278
1369
|
var isRight = leafColumnIds.some(function (d) {
|
|
1279
1370
|
return right == null ? void 0 : right.includes(d);
|
|
1280
1371
|
});
|
|
1281
|
-
|
|
1282
|
-
if (isLeft && isRight) {
|
|
1283
|
-
return 'both';
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
1372
|
return isLeft ? 'left' : isRight ? 'right' : false;
|
|
1287
1373
|
},
|
|
1288
1374
|
getColumnPinnedIndex: function getColumnPinnedIndex(columnId) {
|
|
1289
1375
|
var _instance$getState$co2, _instance$getState$co3, _instance$getState$co4;
|
|
1290
1376
|
|
|
1291
1377
|
var position = instance.getColumnIsPinned(columnId);
|
|
1292
|
-
|
|
1293
|
-
if (position === 'both') {
|
|
1294
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1295
|
-
console.warn("Column " + columnId + " has leaf columns that are pinned on both sides");
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
throw new Error();
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
1378
|
return position ? (_instance$getState$co2 = (_instance$getState$co3 = instance.getState().columnPinning) == null ? void 0 : (_instance$getState$co4 = _instance$getState$co3[position]) == null ? void 0 : _instance$getState$co4.indexOf(columnId)) != null ? _instance$getState$co2 : -1 : 0;
|
|
1302
1379
|
}
|
|
1303
1380
|
};
|
|
1304
1381
|
}
|
|
1305
1382
|
|
|
1383
|
+
var Pinning = /*#__PURE__*/Object.freeze({
|
|
1384
|
+
__proto__: null,
|
|
1385
|
+
getInitialState: getInitialState$6,
|
|
1386
|
+
getDefaultOptions: getDefaultOptions$6,
|
|
1387
|
+
createColumn: createColumn$3,
|
|
1388
|
+
getInstance: getInstance$7
|
|
1389
|
+
});
|
|
1390
|
+
|
|
1306
1391
|
//
|
|
1307
|
-
|
|
1308
|
-
width: 150,
|
|
1309
|
-
minWidth: 20,
|
|
1310
|
-
maxWidth: Number.MAX_SAFE_INTEGER
|
|
1311
|
-
};
|
|
1312
|
-
function getInitialState$3() {
|
|
1313
|
-
return {
|
|
1314
|
-
columnSizing: {},
|
|
1315
|
-
columnSizingInfo: {
|
|
1316
|
-
startOffset: null,
|
|
1317
|
-
startSize: null,
|
|
1318
|
-
deltaOffset: null,
|
|
1319
|
-
deltaPercentage: null,
|
|
1320
|
-
isResizingColumn: false,
|
|
1321
|
-
columnSizingStart: []
|
|
1322
|
-
}
|
|
1323
|
-
};
|
|
1324
|
-
}
|
|
1325
|
-
function getDefaultOptions$3(instance) {
|
|
1392
|
+
function createRow$2(row, instance) {
|
|
1326
1393
|
return {
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1394
|
+
_getAllVisibleCells: memo(function () {
|
|
1395
|
+
return [row.getAllCells().filter(function (cell) {
|
|
1396
|
+
return cell.column.getIsVisible();
|
|
1397
|
+
}).map(function (d) {
|
|
1398
|
+
return d.id;
|
|
1399
|
+
}).join('_')];
|
|
1400
|
+
}, function (_) {
|
|
1401
|
+
return row.getAllCells().filter(function (cell) {
|
|
1402
|
+
return cell.column.getIsVisible();
|
|
1403
|
+
});
|
|
1404
|
+
}, {
|
|
1405
|
+
key: 'row._getAllVisibleCells',
|
|
1406
|
+
debug: instance.options.debug
|
|
1407
|
+
}),
|
|
1408
|
+
getVisibleCells: memo(function () {
|
|
1409
|
+
return [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()];
|
|
1410
|
+
}, function (left, center, right) {
|
|
1411
|
+
return [].concat(left, center, right);
|
|
1412
|
+
}, {
|
|
1413
|
+
key: 'row.getVisibleCells',
|
|
1414
|
+
debug: instance.options.debug
|
|
1415
|
+
}),
|
|
1416
|
+
getCenterVisibleCells: memo(function () {
|
|
1417
|
+
return [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
|
|
1418
|
+
}, function (allCells, left, right) {
|
|
1419
|
+
var leftAndRight = [].concat(left != null ? left : [], right != null ? right : []);
|
|
1420
|
+
return allCells.filter(function (d) {
|
|
1421
|
+
return !leftAndRight.includes(d.columnId);
|
|
1422
|
+
});
|
|
1423
|
+
}, {
|
|
1424
|
+
key: 'row.getCenterVisibleCells',
|
|
1425
|
+
debug: instance.options.debug
|
|
1426
|
+
}),
|
|
1427
|
+
getLeftVisibleCells: memo(function () {
|
|
1428
|
+
return [row._getAllVisibleCells(), instance.getState().columnPinning.left,,];
|
|
1429
|
+
}, function (allCells, left) {
|
|
1430
|
+
var cells = (left != null ? left : []).map(function (columnId) {
|
|
1431
|
+
return allCells.find(function (cell) {
|
|
1432
|
+
return cell.columnId === columnId;
|
|
1433
|
+
});
|
|
1434
|
+
}).filter(Boolean);
|
|
1435
|
+
return cells;
|
|
1436
|
+
}, {
|
|
1437
|
+
key: 'row.getLeftVisibleCells',
|
|
1438
|
+
debug: instance.options.debug
|
|
1439
|
+
}),
|
|
1440
|
+
getRightVisibleCells: memo(function () {
|
|
1441
|
+
return [row._getAllVisibleCells(), instance.getState().columnPinning.right];
|
|
1442
|
+
}, function (allCells, right) {
|
|
1443
|
+
var cells = (right != null ? right : []).map(function (columnId) {
|
|
1444
|
+
return allCells.find(function (cell) {
|
|
1445
|
+
return cell.columnId === columnId;
|
|
1446
|
+
});
|
|
1447
|
+
}).filter(Boolean);
|
|
1448
|
+
return cells;
|
|
1449
|
+
}, {
|
|
1450
|
+
key: 'row.getRightVisibleCells',
|
|
1451
|
+
debug: instance.options.debug
|
|
1452
|
+
})
|
|
1330
1453
|
};
|
|
1331
1454
|
}
|
|
1332
|
-
function getInstance$
|
|
1455
|
+
function getInstance$6(instance) {
|
|
1333
1456
|
return {
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
},
|
|
1337
|
-
setColumnSizingInfo: function setColumnSizingInfo(updater) {
|
|
1338
|
-
return instance.options.onColumnSizingInfoChange == null ? void 0 : instance.options.onColumnSizingInfoChange(updater, functionalUpdate(updater, instance.getState().columnSizingInfo));
|
|
1339
|
-
},
|
|
1340
|
-
resetColumnSizing: function resetColumnSizing() {
|
|
1341
|
-
var _instance$initialStat;
|
|
1342
|
-
|
|
1343
|
-
instance.setColumnSizing((_instance$initialStat = instance.initialState.columnSizing) != null ? _instance$initialStat : {});
|
|
1344
|
-
},
|
|
1345
|
-
resetHeaderSizeInfo: function resetHeaderSizeInfo() {
|
|
1346
|
-
var _instance$initialStat2;
|
|
1347
|
-
|
|
1348
|
-
instance.setColumnSizingInfo((_instance$initialStat2 = instance.initialState.columnSizingInfo) != null ? _instance$initialStat2 : {});
|
|
1349
|
-
},
|
|
1350
|
-
resetColumnSize: function resetColumnSize(columnId) {
|
|
1351
|
-
instance.setColumnSizing(function (_ref) {
|
|
1352
|
-
_ref[columnId];
|
|
1353
|
-
var rest = _objectWithoutPropertiesLoose(_ref, [columnId].map(_toPropertyKey));
|
|
1354
|
-
|
|
1355
|
-
return rest;
|
|
1356
|
-
});
|
|
1357
|
-
},
|
|
1358
|
-
resetHeaderSize: function resetHeaderSize(headerId) {
|
|
1359
|
-
var header = instance.getHeader(headerId);
|
|
1360
|
-
|
|
1361
|
-
if (!header) {
|
|
1362
|
-
return;
|
|
1363
|
-
}
|
|
1364
|
-
|
|
1365
|
-
return instance.resetColumnSize(header.column.id);
|
|
1366
|
-
},
|
|
1367
|
-
getHeaderCanResize: function getHeaderCanResize(headerId) {
|
|
1368
|
-
var header = instance.getHeader(headerId);
|
|
1369
|
-
|
|
1370
|
-
if (!header) {
|
|
1371
|
-
throw new Error();
|
|
1372
|
-
}
|
|
1457
|
+
createHeader: function createHeader(column, options) {
|
|
1458
|
+
var _options$id;
|
|
1373
1459
|
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1460
|
+
var id = (_options$id = options.id) != null ? _options$id : column.id;
|
|
1461
|
+
var header = {
|
|
1462
|
+
id: id,
|
|
1463
|
+
column: column,
|
|
1464
|
+
isPlaceholder: options.isPlaceholder,
|
|
1465
|
+
placeholderId: options.placeholderId,
|
|
1466
|
+
depth: options.depth,
|
|
1467
|
+
subHeaders: [],
|
|
1468
|
+
colSpan: 0,
|
|
1469
|
+
rowSpan: 0,
|
|
1470
|
+
getWidth: function getWidth() {
|
|
1471
|
+
var sum = 0;
|
|
1378
1472
|
|
|
1379
|
-
|
|
1473
|
+
var recurse = function recurse(header) {
|
|
1474
|
+
if (header.subHeaders.length) {
|
|
1475
|
+
header.subHeaders.forEach(recurse);
|
|
1476
|
+
} else {
|
|
1477
|
+
var _header$column$getWid;
|
|
1380
1478
|
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1479
|
+
sum += (_header$column$getWid = header.column.getWidth()) != null ? _header$column$getWid : 0;
|
|
1480
|
+
}
|
|
1481
|
+
};
|
|
1384
1482
|
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1483
|
+
recurse(header);
|
|
1484
|
+
return sum;
|
|
1485
|
+
},
|
|
1486
|
+
getLeafHeaders: function getLeafHeaders() {
|
|
1487
|
+
var leafHeaders = [];
|
|
1389
1488
|
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1489
|
+
var recurseHeader = function recurseHeader(h) {
|
|
1490
|
+
if (h.subHeaders && h.subHeaders.length) {
|
|
1491
|
+
h.subHeaders.map(recurseHeader);
|
|
1492
|
+
}
|
|
1393
1493
|
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
getHeaderIsResizing: function getHeaderIsResizing(headerId) {
|
|
1397
|
-
var header = instance.getHeader(headerId);
|
|
1494
|
+
leafHeaders.push(h);
|
|
1495
|
+
};
|
|
1398
1496
|
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1497
|
+
recurseHeader(header);
|
|
1498
|
+
return leafHeaders;
|
|
1499
|
+
},
|
|
1500
|
+
getHeaderProps: function getHeaderProps(userProps) {
|
|
1501
|
+
return instance.getHeaderProps(header.id, userProps);
|
|
1502
|
+
},
|
|
1503
|
+
getFooterProps: function getFooterProps(userProps) {
|
|
1504
|
+
return instance.getFooterProps(header.id, userProps);
|
|
1505
|
+
},
|
|
1506
|
+
renderHeader: function renderHeader() {
|
|
1507
|
+
return flexRender(column.header, {
|
|
1508
|
+
instance: instance,
|
|
1509
|
+
header: header,
|
|
1510
|
+
column: column
|
|
1511
|
+
});
|
|
1512
|
+
},
|
|
1513
|
+
renderFooter: function renderFooter() {
|
|
1514
|
+
return flexRender(column.footer, {
|
|
1515
|
+
instance: instance,
|
|
1516
|
+
header: header,
|
|
1517
|
+
column: column
|
|
1518
|
+
});
|
|
1519
|
+
}
|
|
1520
|
+
}; // Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
1402
1521
|
|
|
1403
|
-
return
|
|
1522
|
+
return header;
|
|
1404
1523
|
},
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
var
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
var
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1524
|
+
// Header Groups
|
|
1525
|
+
getHeaderGroups: memo(function () {
|
|
1526
|
+
return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
|
|
1527
|
+
}, function (allColumns, leafColumns, left, right) {
|
|
1528
|
+
var leftColumns = leafColumns.filter(function (column) {
|
|
1529
|
+
return left == null ? void 0 : left.includes(column.id);
|
|
1530
|
+
});
|
|
1531
|
+
var rightColumns = leafColumns.filter(function (column) {
|
|
1532
|
+
return right == null ? void 0 : right.includes(column.id);
|
|
1533
|
+
});
|
|
1534
|
+
var centerColumns = leafColumns.filter(function (column) {
|
|
1535
|
+
return !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id));
|
|
1536
|
+
});
|
|
1537
|
+
var headerGroups = buildHeaderGroups(allColumns, [].concat(leftColumns, centerColumns, rightColumns), instance);
|
|
1538
|
+
return headerGroups;
|
|
1539
|
+
}, {
|
|
1540
|
+
key: 'getHeaderGroups',
|
|
1541
|
+
debug: instance.options.debug
|
|
1542
|
+
}),
|
|
1543
|
+
getCenterHeaderGroups: memo(function () {
|
|
1544
|
+
return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
|
|
1545
|
+
}, function (allColumns, leafColumns, left, right) {
|
|
1546
|
+
leafColumns = leafColumns.filter(function (column) {
|
|
1547
|
+
return !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id));
|
|
1548
|
+
});
|
|
1549
|
+
return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
|
|
1550
|
+
}, {
|
|
1551
|
+
key: 'getCenterHeaderGroups',
|
|
1552
|
+
debug: instance.options.debug
|
|
1553
|
+
}),
|
|
1554
|
+
getLeftHeaderGroups: memo(function () {
|
|
1555
|
+
return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left];
|
|
1556
|
+
}, function (allColumns, leafColumns, left) {
|
|
1557
|
+
leafColumns = leafColumns.filter(function (column) {
|
|
1558
|
+
return left == null ? void 0 : left.includes(column.id);
|
|
1559
|
+
});
|
|
1560
|
+
return buildHeaderGroups(allColumns, leafColumns, instance, 'left');
|
|
1561
|
+
}, {
|
|
1562
|
+
key: 'getLeftHeaderGroups',
|
|
1563
|
+
debug: instance.options.debug
|
|
1564
|
+
}),
|
|
1565
|
+
getRightHeaderGroups: memo(function () {
|
|
1566
|
+
return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right];
|
|
1567
|
+
}, function (allColumns, leafColumns, right) {
|
|
1568
|
+
leafColumns = leafColumns.filter(function (column) {
|
|
1569
|
+
return right == null ? void 0 : right.includes(column.id);
|
|
1570
|
+
});
|
|
1571
|
+
return buildHeaderGroups(allColumns, leafColumns, instance, 'right');
|
|
1572
|
+
}, {
|
|
1573
|
+
key: 'getRightHeaderGroups',
|
|
1574
|
+
debug: instance.options.debug
|
|
1575
|
+
}),
|
|
1576
|
+
// Footer Groups
|
|
1577
|
+
getFooterGroups: memo(function () {
|
|
1578
|
+
return [instance.getHeaderGroups()];
|
|
1579
|
+
}, function (headerGroups) {
|
|
1580
|
+
return [].concat(headerGroups).reverse();
|
|
1581
|
+
}, {
|
|
1582
|
+
key: 'getFooterGroups',
|
|
1583
|
+
debug: instance.options.debug
|
|
1584
|
+
}),
|
|
1585
|
+
getLeftFooterGroups: memo(function () {
|
|
1586
|
+
return [instance.getLeftHeaderGroups()];
|
|
1587
|
+
}, function (headerGroups) {
|
|
1588
|
+
return [].concat(headerGroups).reverse();
|
|
1589
|
+
}, {
|
|
1590
|
+
key: 'getLeftFooterGroups',
|
|
1591
|
+
debug: instance.options.debug
|
|
1592
|
+
}),
|
|
1593
|
+
getCenterFooterGroups: memo(function () {
|
|
1594
|
+
return [instance.getCenterHeaderGroups()];
|
|
1595
|
+
}, function (headerGroups) {
|
|
1596
|
+
return [].concat(headerGroups).reverse();
|
|
1597
|
+
}, {
|
|
1598
|
+
key: 'getCenterFooterGroups',
|
|
1599
|
+
debug: instance.options.debug
|
|
1600
|
+
}),
|
|
1601
|
+
getRightFooterGroups: memo(function () {
|
|
1602
|
+
return [instance.getRightHeaderGroups()];
|
|
1603
|
+
}, function (headerGroups) {
|
|
1604
|
+
return [].concat(headerGroups).reverse();
|
|
1605
|
+
}, {
|
|
1606
|
+
key: 'getRightFooterGroups',
|
|
1607
|
+
debug: instance.options.debug
|
|
1608
|
+
}),
|
|
1609
|
+
// Flat Headers
|
|
1610
|
+
getFlatHeaders: memo(function () {
|
|
1611
|
+
return [instance.getHeaderGroups()];
|
|
1612
|
+
}, function (headerGroups) {
|
|
1613
|
+
return headerGroups.map(function (headerGroup) {
|
|
1614
|
+
return headerGroup.headers;
|
|
1615
|
+
}).flat();
|
|
1616
|
+
}, {
|
|
1617
|
+
key: 'getFlatHeaders',
|
|
1618
|
+
debug: instance.options.debug
|
|
1619
|
+
}),
|
|
1620
|
+
getLeftFlatHeaders: memo(function () {
|
|
1621
|
+
return [instance.getLeftHeaderGroups()];
|
|
1622
|
+
}, function (left) {
|
|
1623
|
+
return left.map(function (headerGroup) {
|
|
1624
|
+
return headerGroup.headers;
|
|
1625
|
+
}).flat();
|
|
1626
|
+
}, {
|
|
1627
|
+
key: 'getLeftFlatHeaders',
|
|
1628
|
+
debug: instance.options.debug
|
|
1629
|
+
}),
|
|
1630
|
+
getCenterFlatHeaders: memo(function () {
|
|
1631
|
+
return [instance.getCenterHeaderGroups()];
|
|
1632
|
+
}, function (left) {
|
|
1633
|
+
return left.map(function (headerGroup) {
|
|
1634
|
+
return headerGroup.headers;
|
|
1635
|
+
}).flat();
|
|
1636
|
+
}, {
|
|
1637
|
+
key: 'getCenterFlatHeaders',
|
|
1638
|
+
debug: instance.options.debug
|
|
1639
|
+
}),
|
|
1640
|
+
getRightFlatHeaders: memo(function () {
|
|
1641
|
+
return [instance.getRightHeaderGroups()];
|
|
1642
|
+
}, function (left) {
|
|
1643
|
+
return left.map(function (headerGroup) {
|
|
1644
|
+
return headerGroup.headers;
|
|
1645
|
+
}).flat();
|
|
1646
|
+
}, {
|
|
1647
|
+
key: 'getRightFlatHeaders',
|
|
1648
|
+
debug: instance.options.debug
|
|
1649
|
+
}),
|
|
1650
|
+
// Leaf Headers
|
|
1651
|
+
getCenterLeafHeaders: memo(function () {
|
|
1652
|
+
return [instance.getCenterFlatHeaders()];
|
|
1653
|
+
}, function (flatHeaders) {
|
|
1654
|
+
return flatHeaders.filter(function (header) {
|
|
1655
|
+
var _header$subHeaders;
|
|
1656
|
+
|
|
1657
|
+
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
|
1658
|
+
});
|
|
1659
|
+
}, {
|
|
1660
|
+
key: 'getCenterLeafHeaders',
|
|
1661
|
+
debug: instance.options.debug
|
|
1662
|
+
}),
|
|
1663
|
+
getLeftLeafHeaders: memo(function () {
|
|
1664
|
+
return [instance.getLeftFlatHeaders()];
|
|
1665
|
+
}, function (flatHeaders) {
|
|
1666
|
+
return flatHeaders.filter(function (header) {
|
|
1667
|
+
var _header$subHeaders2;
|
|
1668
|
+
|
|
1669
|
+
return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
|
|
1670
|
+
});
|
|
1671
|
+
}, {
|
|
1672
|
+
key: 'getLeftLeafHeaders',
|
|
1673
|
+
debug: instance.options.debug
|
|
1674
|
+
}),
|
|
1675
|
+
getRightLeafHeaders: memo(function () {
|
|
1676
|
+
return [instance.getRightFlatHeaders()];
|
|
1677
|
+
}, function (flatHeaders) {
|
|
1678
|
+
return flatHeaders.filter(function (header) {
|
|
1679
|
+
var _header$subHeaders3;
|
|
1680
|
+
|
|
1681
|
+
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
|
1682
|
+
});
|
|
1683
|
+
}, {
|
|
1684
|
+
key: 'getRightLeafHeaders',
|
|
1685
|
+
debug: instance.options.debug
|
|
1686
|
+
}),
|
|
1687
|
+
getLeafHeaders: memo(function () {
|
|
1688
|
+
return [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()];
|
|
1689
|
+
}, function (left, center, right) {
|
|
1690
|
+
var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
|
|
1691
|
+
|
|
1692
|
+
return [].concat((_left$0$headers = (_left$ = left[0]) == null ? void 0 : _left$.headers) != null ? _left$0$headers : [], (_center$0$headers = (_center$ = center[0]) == null ? void 0 : _center$.headers) != null ? _center$0$headers : [], (_right$0$headers = (_right$ = right[0]) == null ? void 0 : _right$.headers) != null ? _right$0$headers : []).map(function (header) {
|
|
1693
|
+
return header.getLeafHeaders();
|
|
1694
|
+
}).flat();
|
|
1695
|
+
}, {
|
|
1696
|
+
key: 'getLeafHeaders',
|
|
1697
|
+
debug: instance.options.debug
|
|
1698
|
+
}),
|
|
1699
|
+
getHeader: function getHeader(id) {
|
|
1700
|
+
var header = [].concat(instance.getFlatHeaders(), instance.getCenterFlatHeaders(), instance.getLeftFlatHeaders(), instance.getRightFlatHeaders()).find(function (d) {
|
|
1701
|
+
return d.id === id;
|
|
1702
|
+
});
|
|
1703
|
+
|
|
1704
|
+
if (!header) {
|
|
1705
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1706
|
+
console.warn("Could not find header with id: " + id);
|
|
1426
1707
|
}
|
|
1427
1708
|
|
|
1428
|
-
|
|
1429
|
-
|
|
1709
|
+
throw new Error();
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
return header;
|
|
1713
|
+
},
|
|
1714
|
+
getHeaderGroupProps: function getHeaderGroupProps(id, userProps) {
|
|
1715
|
+
var headerGroup = instance.getHeaderGroups().find(function (d) {
|
|
1716
|
+
return d.id === id;
|
|
1717
|
+
});
|
|
1718
|
+
|
|
1719
|
+
if (!headerGroup) {
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
return propGetter({
|
|
1724
|
+
key: headerGroup.id,
|
|
1725
|
+
role: 'row'
|
|
1726
|
+
}, userProps);
|
|
1727
|
+
},
|
|
1728
|
+
getFooterGroupProps: function getFooterGroupProps(id, userProps) {
|
|
1729
|
+
var headerGroup = instance.getFooterGroups().find(function (d) {
|
|
1730
|
+
return d.id === id;
|
|
1731
|
+
});
|
|
1732
|
+
|
|
1733
|
+
if (!headerGroup) {
|
|
1734
|
+
return;
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
var initialProps = {
|
|
1738
|
+
key: headerGroup.id,
|
|
1739
|
+
role: 'row'
|
|
1740
|
+
};
|
|
1741
|
+
return propGetter(initialProps, userProps);
|
|
1742
|
+
},
|
|
1743
|
+
getHeaderProps: function getHeaderProps(id, userProps) {
|
|
1744
|
+
var header = instance.getHeader(id);
|
|
1745
|
+
|
|
1746
|
+
if (!header) {
|
|
1747
|
+
throw new Error();
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
var initialProps = {
|
|
1751
|
+
key: header.id,
|
|
1752
|
+
role: 'columnheader',
|
|
1753
|
+
colSpan: header.colSpan,
|
|
1754
|
+
rowSpan: header.rowSpan
|
|
1755
|
+
};
|
|
1756
|
+
return propGetter(initialProps, userProps);
|
|
1757
|
+
},
|
|
1758
|
+
getFooterProps: function getFooterProps(id, userProps) {
|
|
1759
|
+
var header = instance.getHeader(id);
|
|
1760
|
+
|
|
1761
|
+
if (!header) {
|
|
1762
|
+
return;
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
var initialProps = {
|
|
1766
|
+
key: header.id,
|
|
1767
|
+
role: 'columnfooter',
|
|
1768
|
+
colSpan: header.colSpan,
|
|
1769
|
+
rowSpan: header.rowSpan
|
|
1770
|
+
};
|
|
1771
|
+
return propGetter(initialProps, userProps);
|
|
1772
|
+
},
|
|
1773
|
+
getTotalWidth: function getTotalWidth() {
|
|
1774
|
+
var width = 0;
|
|
1775
|
+
instance.getVisibleLeafColumns().forEach(function (column) {
|
|
1776
|
+
var _column$getWidth;
|
|
1777
|
+
|
|
1778
|
+
width += (_column$getWidth = column.getWidth()) != null ? _column$getWidth : 0;
|
|
1779
|
+
});
|
|
1780
|
+
return width;
|
|
1781
|
+
}
|
|
1782
|
+
};
|
|
1783
|
+
}
|
|
1784
|
+
function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
|
|
1785
|
+
var _headerGroups$0$heade, _headerGroups$;
|
|
1786
|
+
|
|
1787
|
+
// Find the max depth of the columns:
|
|
1788
|
+
// build the leaf column row
|
|
1789
|
+
// build each buffer row going up
|
|
1790
|
+
// placeholder for non-existent level
|
|
1791
|
+
// real column for existing level
|
|
1792
|
+
var maxDepth = 0;
|
|
1793
|
+
|
|
1794
|
+
var findMaxDepth = function findMaxDepth(columns, depth) {
|
|
1795
|
+
if (depth === void 0) {
|
|
1796
|
+
depth = 1;
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
maxDepth = Math.max(maxDepth, depth);
|
|
1800
|
+
columns.filter(function (column) {
|
|
1801
|
+
return column.getIsVisible();
|
|
1802
|
+
}).forEach(function (column) {
|
|
1803
|
+
var _column$columns;
|
|
1804
|
+
|
|
1805
|
+
if ((_column$columns = column.columns) != null && _column$columns.length) {
|
|
1806
|
+
findMaxDepth(column.columns, depth + 1);
|
|
1807
|
+
}
|
|
1808
|
+
}, 0);
|
|
1809
|
+
};
|
|
1810
|
+
|
|
1811
|
+
findMaxDepth(allColumns);
|
|
1812
|
+
var headerGroups = [];
|
|
1813
|
+
|
|
1814
|
+
var createHeaderGroup = function createHeaderGroup(headersToGroup, depth) {
|
|
1815
|
+
// The header group we are creating
|
|
1816
|
+
var headerGroup = {
|
|
1817
|
+
depth: depth,
|
|
1818
|
+
id: [headerFamily, "" + depth].filter(Boolean).join('_'),
|
|
1819
|
+
headers: [],
|
|
1820
|
+
getHeaderGroupProps: function getHeaderGroupProps(getterValue) {
|
|
1821
|
+
return instance.getHeaderGroupProps("" + depth, getterValue);
|
|
1822
|
+
},
|
|
1823
|
+
getFooterGroupProps: function getFooterGroupProps(getterValue) {
|
|
1824
|
+
return instance.getFooterGroupProps("" + depth, getterValue);
|
|
1825
|
+
}
|
|
1826
|
+
}; // The parent columns we're going to scan next
|
|
1827
|
+
|
|
1828
|
+
var parentHeaders = []; // Scan each column for parents
|
|
1829
|
+
|
|
1830
|
+
headersToGroup.forEach(function (headerToGroup) {
|
|
1831
|
+
// What is the latest (last) parent column?
|
|
1832
|
+
var latestParentHeader = [].concat(parentHeaders).reverse()[0];
|
|
1833
|
+
var isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
|
|
1834
|
+
var column;
|
|
1835
|
+
var isPlaceholder = false;
|
|
1836
|
+
|
|
1837
|
+
if (isLeafHeader && headerToGroup.column.parent) {
|
|
1838
|
+
// The parent header is new
|
|
1839
|
+
column = headerToGroup.column.parent;
|
|
1840
|
+
} else {
|
|
1841
|
+
// The parent header is repeated
|
|
1842
|
+
column = headerToGroup.column;
|
|
1843
|
+
isPlaceholder = true;
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
var header = instance.createHeader(column, {
|
|
1847
|
+
id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
|
|
1848
|
+
isPlaceholder: isPlaceholder,
|
|
1849
|
+
placeholderId: isPlaceholder ? "" + parentHeaders.filter(function (d) {
|
|
1850
|
+
return d.column === column;
|
|
1851
|
+
}).length : undefined,
|
|
1852
|
+
depth: depth
|
|
1853
|
+
});
|
|
1854
|
+
|
|
1855
|
+
if (!latestParentHeader || latestParentHeader.column !== header.column) {
|
|
1856
|
+
header.subHeaders.push(headerToGroup);
|
|
1857
|
+
parentHeaders.push(header);
|
|
1858
|
+
} else {
|
|
1859
|
+
latestParentHeader.subHeaders.push(headerToGroup);
|
|
1860
|
+
} // if (!headerToGroup.isPlaceholder) {
|
|
1861
|
+
// headerToGroup.column.header = headerToGroup;
|
|
1862
|
+
// }
|
|
1863
|
+
|
|
1864
|
+
|
|
1865
|
+
headerGroup.headers.push(headerToGroup);
|
|
1866
|
+
});
|
|
1867
|
+
headerGroups.push(headerGroup);
|
|
1868
|
+
|
|
1869
|
+
if (depth > 0) {
|
|
1870
|
+
createHeaderGroup(parentHeaders, depth - 1);
|
|
1871
|
+
}
|
|
1872
|
+
};
|
|
1873
|
+
|
|
1874
|
+
var bottomHeaders = columnsToGroup.map(function (column) {
|
|
1875
|
+
return instance.createHeader(column, {
|
|
1876
|
+
depth: maxDepth
|
|
1877
|
+
});
|
|
1878
|
+
});
|
|
1879
|
+
createHeaderGroup(bottomHeaders, maxDepth - 1);
|
|
1880
|
+
headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
|
|
1881
|
+
// return !headerGroup.headers.every(header => header.isPlaceholder)
|
|
1882
|
+
// })
|
|
1883
|
+
|
|
1884
|
+
var recurseHeadersForSpans = function recurseHeadersForSpans(headers) {
|
|
1885
|
+
var filteredHeaders = headers.filter(function (header) {
|
|
1886
|
+
return header.column.getIsVisible();
|
|
1887
|
+
});
|
|
1888
|
+
return filteredHeaders.map(function (header) {
|
|
1889
|
+
var colSpan = 0;
|
|
1890
|
+
var rowSpan = 0;
|
|
1891
|
+
var childRowSpans = [0];
|
|
1892
|
+
|
|
1893
|
+
if (header.subHeaders && header.subHeaders.length) {
|
|
1894
|
+
childRowSpans = [];
|
|
1895
|
+
recurseHeadersForSpans(header.subHeaders).forEach(function (_ref) {
|
|
1896
|
+
var childColSpan = _ref.colSpan,
|
|
1897
|
+
childRowSpan = _ref.rowSpan;
|
|
1898
|
+
colSpan += childColSpan;
|
|
1899
|
+
childRowSpans.push(childRowSpan);
|
|
1430
1900
|
});
|
|
1431
|
-
|
|
1901
|
+
} else {
|
|
1902
|
+
colSpan = 1;
|
|
1903
|
+
}
|
|
1432
1904
|
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1905
|
+
var minChildRowSpan = Math.min.apply(Math, childRowSpans);
|
|
1906
|
+
rowSpan = rowSpan + minChildRowSpan;
|
|
1907
|
+
header.colSpan = colSpan > 0 ? colSpan : undefined;
|
|
1908
|
+
header.rowSpan = rowSpan > 0 ? rowSpan : undefined;
|
|
1909
|
+
return {
|
|
1910
|
+
colSpan: colSpan,
|
|
1911
|
+
rowSpan: rowSpan
|
|
1912
|
+
};
|
|
1913
|
+
});
|
|
1914
|
+
};
|
|
1437
1915
|
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1916
|
+
recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
|
|
1917
|
+
return headerGroups;
|
|
1918
|
+
}
|
|
1441
1919
|
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
});
|
|
1449
|
-
return _extends({}, old, {
|
|
1450
|
-
deltaOffset: deltaOffset,
|
|
1451
|
-
deltaPercentage: deltaPercentage
|
|
1452
|
-
});
|
|
1453
|
-
});
|
|
1920
|
+
var Headers = /*#__PURE__*/Object.freeze({
|
|
1921
|
+
__proto__: null,
|
|
1922
|
+
createRow: createRow$2,
|
|
1923
|
+
getInstance: getInstance$6,
|
|
1924
|
+
buildHeaderGroups: buildHeaderGroups
|
|
1925
|
+
});
|
|
1454
1926
|
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1927
|
+
var filterTypes = {
|
|
1928
|
+
includesString: includesString,
|
|
1929
|
+
includesStringSensitive: includesStringSensitive,
|
|
1930
|
+
equalsString: equalsString,
|
|
1931
|
+
equalsStringSensitive: equalsStringSensitive,
|
|
1932
|
+
arrIncludes: arrIncludes,
|
|
1933
|
+
arrIncludesAll: arrIncludesAll,
|
|
1934
|
+
equals: equals,
|
|
1935
|
+
weakEquals: weakEquals,
|
|
1936
|
+
betweenNumberRange: betweenNumberRange
|
|
1937
|
+
};
|
|
1461
1938
|
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1939
|
+
function includesString(rows, columnIds, filterValue) {
|
|
1940
|
+
var search = String(filterValue).toLowerCase();
|
|
1941
|
+
rows = rows.filter(function (row) {
|
|
1942
|
+
return columnIds.some(function (id) {
|
|
1943
|
+
return String(row.values[id]).toLowerCase().includes(search);
|
|
1944
|
+
});
|
|
1945
|
+
});
|
|
1946
|
+
return rows;
|
|
1947
|
+
}
|
|
1465
1948
|
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
return _extends({}, old, {
|
|
1470
|
-
isResizingColumn: false,
|
|
1471
|
-
startOffset: null,
|
|
1472
|
-
startSize: null,
|
|
1473
|
-
deltaOffset: null,
|
|
1474
|
-
deltaPercentage: null,
|
|
1475
|
-
columnSizingStart: []
|
|
1476
|
-
});
|
|
1477
|
-
});
|
|
1478
|
-
};
|
|
1949
|
+
includesString.autoRemove = function (val) {
|
|
1950
|
+
return testFalsey(val);
|
|
1951
|
+
};
|
|
1479
1952
|
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1953
|
+
function includesStringSensitive(rows, columnIds, filterValue) {
|
|
1954
|
+
var search = String(filterValue);
|
|
1955
|
+
rows = rows.filter(function (row) {
|
|
1956
|
+
return columnIds.some(function (id) {
|
|
1957
|
+
return String(row.values[id]).includes(search);
|
|
1958
|
+
});
|
|
1959
|
+
});
|
|
1960
|
+
return rows;
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1963
|
+
includesStringSensitive.autoRemove = function (val) {
|
|
1964
|
+
return testFalsey(val);
|
|
1965
|
+
};
|
|
1966
|
+
|
|
1967
|
+
function equalsString(rows, columnIds, filterValue) {
|
|
1968
|
+
var search = String(filterValue).toLowerCase();
|
|
1969
|
+
return rows.filter(function (row) {
|
|
1970
|
+
return columnIds.some(function (id) {
|
|
1971
|
+
var rowValue = row.values[id];
|
|
1972
|
+
return rowValue !== undefined ? String(rowValue).toLowerCase() === search : true;
|
|
1973
|
+
});
|
|
1974
|
+
});
|
|
1975
|
+
}
|
|
1496
1976
|
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
upHandler: function upHandler(e) {
|
|
1501
|
-
document.removeEventListener('touchmove', touchEvents.moveHandler);
|
|
1502
|
-
document.removeEventListener('touchend', touchEvents.upHandler);
|
|
1977
|
+
equalsString.autoRemove = function (val) {
|
|
1978
|
+
return testFalsey(val);
|
|
1979
|
+
};
|
|
1503
1980
|
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1981
|
+
function equalsStringSensitive(rows, columnIds, filterValue) {
|
|
1982
|
+
var search = String(filterValue);
|
|
1983
|
+
return rows.filter(function (row) {
|
|
1984
|
+
return columnIds.some(function (id) {
|
|
1985
|
+
var rowValue = row.values[id];
|
|
1986
|
+
return rowValue !== undefined ? String(rowValue) === search : true;
|
|
1987
|
+
});
|
|
1988
|
+
});
|
|
1989
|
+
}
|
|
1508
1990
|
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
var passiveIfSupported = passiveEventSupported() ? {
|
|
1513
|
-
passive: false
|
|
1514
|
-
} : false;
|
|
1991
|
+
equalsStringSensitive.autoRemove = function (val) {
|
|
1992
|
+
return testFalsey(val);
|
|
1993
|
+
};
|
|
1515
1994
|
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1995
|
+
function arrIncludes(rows, columnIds, filterValue) {
|
|
1996
|
+
return rows.filter(function (row) {
|
|
1997
|
+
return columnIds.some(function (id) {
|
|
1998
|
+
var rowValue = row.values[id];
|
|
1999
|
+
return rowValue.includes(filterValue);
|
|
2000
|
+
});
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
1523
2003
|
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
startSize: header.getWidth(),
|
|
1528
|
-
deltaOffset: 0,
|
|
1529
|
-
deltaPercentage: 0,
|
|
1530
|
-
columnSizingStart: columnSizingStart,
|
|
1531
|
-
isResizingColumn: header.column.id
|
|
1532
|
-
});
|
|
1533
|
-
});
|
|
1534
|
-
};
|
|
2004
|
+
arrIncludes.autoRemove = function (val) {
|
|
2005
|
+
return testFalsey(val) || !(val != null && val.length);
|
|
2006
|
+
};
|
|
1535
2007
|
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
e.persist();
|
|
1546
|
-
onResizeStart(e);
|
|
1547
|
-
}
|
|
1548
|
-
} : {};
|
|
1549
|
-
return propGetter(initialProps, userProps);
|
|
1550
|
-
}
|
|
1551
|
-
};
|
|
2008
|
+
function arrIncludesAll(rows, columnIds, filterValue) {
|
|
2009
|
+
return rows.filter(function (row) {
|
|
2010
|
+
return columnIds.some(function (id) {
|
|
2011
|
+
var rowValue = row.values[id];
|
|
2012
|
+
return rowValue && rowValue.length && filterValue.every(function (val) {
|
|
2013
|
+
return rowValue.includes(val);
|
|
2014
|
+
});
|
|
2015
|
+
});
|
|
2016
|
+
});
|
|
1552
2017
|
}
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
return
|
|
1563
|
-
}
|
|
1564
|
-
};
|
|
2018
|
+
|
|
2019
|
+
arrIncludesAll.autoRemove = function (val) {
|
|
2020
|
+
return testFalsey(val) || !(val != null && val.length);
|
|
2021
|
+
};
|
|
2022
|
+
|
|
2023
|
+
function equals(rows, columnIds, filterValue) {
|
|
2024
|
+
return rows.filter(function (row) {
|
|
2025
|
+
return columnIds.some(function (id) {
|
|
2026
|
+
var rowValue = row.values[id];
|
|
2027
|
+
return rowValue === filterValue;
|
|
2028
|
+
});
|
|
2029
|
+
});
|
|
1565
2030
|
}
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
}
|
|
1580
|
-
};
|
|
2031
|
+
|
|
2032
|
+
equals.autoRemove = function (val) {
|
|
2033
|
+
return testFalsey(val);
|
|
2034
|
+
};
|
|
2035
|
+
|
|
2036
|
+
function weakEquals(rows, columnIds, filterValue) {
|
|
2037
|
+
return rows.filter(function (row) {
|
|
2038
|
+
return columnIds.some(function (id) {
|
|
2039
|
+
var rowValue = row.values[id]; // eslint-disable-next-line eqeqeq
|
|
2040
|
+
|
|
2041
|
+
return rowValue == filterValue;
|
|
2042
|
+
});
|
|
2043
|
+
});
|
|
1581
2044
|
}
|
|
1582
|
-
var passiveSupported = null;
|
|
1583
|
-
function passiveEventSupported() {
|
|
1584
|
-
if (typeof passiveSupported === 'boolean') return passiveSupported;
|
|
1585
|
-
var supported = false;
|
|
1586
2045
|
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
supported = true;
|
|
1591
|
-
return false;
|
|
1592
|
-
}
|
|
2046
|
+
weakEquals.autoRemove = function (val) {
|
|
2047
|
+
return testFalsey(val);
|
|
2048
|
+
};
|
|
1593
2049
|
|
|
1594
|
-
|
|
2050
|
+
function betweenNumberRange(rows, columnIds, filterValue) {
|
|
2051
|
+
var _ref = filterValue || [],
|
|
2052
|
+
unsafeMin = _ref[0],
|
|
2053
|
+
unsafeMax = _ref[1];
|
|
1595
2054
|
|
|
1596
|
-
|
|
2055
|
+
var parsedMin = typeof unsafeMin !== 'number' ? parseFloat(unsafeMin) : unsafeMin;
|
|
2056
|
+
var parsedMax = typeof unsafeMax !== 'number' ? parseFloat(unsafeMax) : unsafeMax;
|
|
2057
|
+
var min = unsafeMin === null || Number.isNaN(parsedMin) ? -Infinity : parsedMin;
|
|
2058
|
+
var max = unsafeMax === null || Number.isNaN(parsedMax) ? Infinity : parsedMax;
|
|
1597
2059
|
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
2060
|
+
if (min > max) {
|
|
2061
|
+
var temp = min;
|
|
2062
|
+
min = max;
|
|
2063
|
+
max = temp;
|
|
1602
2064
|
}
|
|
1603
2065
|
|
|
1604
|
-
|
|
1605
|
-
|
|
2066
|
+
return rows.filter(function (row) {
|
|
2067
|
+
return columnIds.some(function (id) {
|
|
2068
|
+
var rowValue = row.values[id];
|
|
2069
|
+
return rowValue >= min && rowValue <= max;
|
|
2070
|
+
});
|
|
2071
|
+
});
|
|
1606
2072
|
}
|
|
1607
2073
|
|
|
1608
|
-
function
|
|
1609
|
-
return
|
|
2074
|
+
betweenNumberRange.autoRemove = function (val) {
|
|
2075
|
+
return testFalsey(val) || testFalsey(val[0]) && testFalsey(val[1]);
|
|
2076
|
+
}; // Utils
|
|
2077
|
+
|
|
2078
|
+
|
|
2079
|
+
function testFalsey(val) {
|
|
2080
|
+
return val === undefined || val === null || val === '';
|
|
1610
2081
|
}
|
|
1611
2082
|
|
|
1612
2083
|
//
|
|
1613
|
-
function
|
|
2084
|
+
function getDefaultColumn$1() {
|
|
1614
2085
|
return {
|
|
1615
|
-
|
|
1616
|
-
return [row.getAllCells().filter(function (cell) {
|
|
1617
|
-
return cell.column.getIsVisible();
|
|
1618
|
-
}).map(function (d) {
|
|
1619
|
-
return d.id;
|
|
1620
|
-
}).join('_')];
|
|
1621
|
-
}, function (_) {
|
|
1622
|
-
return row.getAllCells().filter(function (cell) {
|
|
1623
|
-
return cell.column.getIsVisible();
|
|
1624
|
-
});
|
|
1625
|
-
}, 'row._getAllVisibleCells', instance.options.debug),
|
|
1626
|
-
getVisibleCells: memo(function () {
|
|
1627
|
-
return [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()];
|
|
1628
|
-
}, function (left, center, right) {
|
|
1629
|
-
return [].concat(left, center, right);
|
|
1630
|
-
}, 'row.getVisibleCells', instance.options.debug),
|
|
1631
|
-
getCenterVisibleCells: memo(function () {
|
|
1632
|
-
return [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
|
|
1633
|
-
}, function (allCells, left, right) {
|
|
1634
|
-
var leftAndRight = [].concat(left != null ? left : [], right != null ? right : []);
|
|
1635
|
-
return allCells.filter(function (d) {
|
|
1636
|
-
return !leftAndRight.includes(d.columnId);
|
|
1637
|
-
});
|
|
1638
|
-
}, 'row.getCenterVisibleCells', instance.options.debug),
|
|
1639
|
-
getLeftVisibleCells: memo(function () {
|
|
1640
|
-
return [row._getAllVisibleCells(), instance.getState().columnPinning.left,,];
|
|
1641
|
-
}, function (allCells, left) {
|
|
1642
|
-
var cells = (left != null ? left : []).map(function (columnId) {
|
|
1643
|
-
return allCells.find(function (cell) {
|
|
1644
|
-
return cell.columnId === columnId;
|
|
1645
|
-
});
|
|
1646
|
-
}).filter(Boolean);
|
|
1647
|
-
return cells;
|
|
1648
|
-
}, 'row.getLeftVisibleCells', instance.options.debug),
|
|
1649
|
-
getRightVisibleCells: memo(function () {
|
|
1650
|
-
return [row._getAllVisibleCells(), instance.getState().columnPinning.right];
|
|
1651
|
-
}, function (allCells, right) {
|
|
1652
|
-
var cells = (right != null ? right : []).map(function (columnId) {
|
|
1653
|
-
return allCells.find(function (cell) {
|
|
1654
|
-
return cell.columnId === columnId;
|
|
1655
|
-
});
|
|
1656
|
-
}).filter(Boolean);
|
|
1657
|
-
return cells;
|
|
1658
|
-
}, 'row.getRightVisibleCells', instance.options.debug)
|
|
2086
|
+
filterType: 'auto'
|
|
1659
2087
|
};
|
|
1660
2088
|
}
|
|
1661
|
-
function
|
|
2089
|
+
function getInitialState$5() {
|
|
1662
2090
|
return {
|
|
1663
|
-
|
|
1664
|
-
|
|
2091
|
+
columnFilters: [],
|
|
2092
|
+
globalFilter: undefined
|
|
2093
|
+
};
|
|
2094
|
+
}
|
|
2095
|
+
function getDefaultOptions$5(instance) {
|
|
2096
|
+
return {
|
|
2097
|
+
onColumnFiltersChange: makeStateUpdater('columnFilters', instance),
|
|
2098
|
+
onGlobalFilterChange: makeStateUpdater('globalFilter', instance),
|
|
2099
|
+
autoResetColumnFilters: true,
|
|
2100
|
+
filterFromChildrenUp: true,
|
|
2101
|
+
autoResetGlobalFilter: true,
|
|
2102
|
+
globalFilterType: 'auto',
|
|
2103
|
+
getColumnCanGlobalFilterFn: function getColumnCanGlobalFilterFn(column) {
|
|
2104
|
+
var _instance$getCoreFlat, _instance$getCoreFlat2;
|
|
2105
|
+
|
|
2106
|
+
var value = (_instance$getCoreFlat = instance.getCoreFlatRows()[0]) == null ? void 0 : (_instance$getCoreFlat2 = _instance$getCoreFlat.getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreFlat2.value;
|
|
2107
|
+
return typeof value === 'string';
|
|
2108
|
+
}
|
|
2109
|
+
};
|
|
2110
|
+
}
|
|
2111
|
+
function createColumn$2(column, instance) {
|
|
2112
|
+
var getFacetInfo = memo(function () {
|
|
2113
|
+
return [column.getPreFilteredRows()];
|
|
2114
|
+
}, function (rows) {
|
|
2115
|
+
var _rows$0$values$column, _rows$, _rows$0$values$column2, _rows$2;
|
|
2116
|
+
|
|
2117
|
+
if (rows === void 0) {
|
|
2118
|
+
rows = [];
|
|
2119
|
+
}
|
|
1665
2120
|
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
id: id,
|
|
1669
|
-
column: column,
|
|
1670
|
-
isPlaceholder: options.isPlaceholder,
|
|
1671
|
-
placeholderId: options.placeholderId,
|
|
1672
|
-
depth: options.depth,
|
|
1673
|
-
subHeaders: [],
|
|
1674
|
-
colSpan: 0,
|
|
1675
|
-
rowSpan: 0,
|
|
1676
|
-
getWidth: function getWidth() {
|
|
1677
|
-
var sum = 0;
|
|
2121
|
+
var preFilteredUniqueValues = new Map();
|
|
2122
|
+
var preFilteredMinMaxValues = [(_rows$0$values$column = (_rows$ = rows[0]) == null ? void 0 : _rows$.values[column.id]) != null ? _rows$0$values$column : null, (_rows$0$values$column2 = (_rows$2 = rows[0]) == null ? void 0 : _rows$2.values[column.id]) != null ? _rows$0$values$column2 : null];
|
|
1678
2123
|
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
header.subHeaders.forEach(recurse);
|
|
1682
|
-
} else {
|
|
1683
|
-
var _header$column$getWid;
|
|
2124
|
+
for (var i = 0; i < rows.length; i++) {
|
|
2125
|
+
var _rows$i;
|
|
1684
2126
|
|
|
1685
|
-
|
|
1686
|
-
}
|
|
1687
|
-
};
|
|
2127
|
+
var _value = (_rows$i = rows[i]) == null ? void 0 : _rows$i.values[column.id];
|
|
1688
2128
|
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
},
|
|
1692
|
-
getLeafHeaders: function getLeafHeaders() {
|
|
1693
|
-
var leafHeaders = [];
|
|
2129
|
+
if (preFilteredUniqueValues.has(_value)) {
|
|
2130
|
+
var _preFilteredUniqueVal;
|
|
1694
2131
|
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
2132
|
+
preFilteredUniqueValues.set(_value, ((_preFilteredUniqueVal = preFilteredUniqueValues.get(_value)) != null ? _preFilteredUniqueVal : 0) + 1);
|
|
2133
|
+
} else {
|
|
2134
|
+
preFilteredUniqueValues.set(_value, 1);
|
|
2135
|
+
}
|
|
1699
2136
|
|
|
1700
|
-
|
|
1701
|
-
|
|
2137
|
+
if (_value < preFilteredMinMaxValues[0]) {
|
|
2138
|
+
preFilteredMinMaxValues[0] = _value;
|
|
2139
|
+
} else if (_value > preFilteredMinMaxValues[1]) {
|
|
2140
|
+
preFilteredMinMaxValues[1] = _value;
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
1702
2143
|
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
2144
|
+
return {
|
|
2145
|
+
preFilteredUniqueValues: preFilteredUniqueValues,
|
|
2146
|
+
preFilteredMinMaxValues: preFilteredMinMaxValues
|
|
2147
|
+
};
|
|
2148
|
+
}, {
|
|
2149
|
+
key: 'column.getFacetInfo',
|
|
2150
|
+
debug: instance.options.debug
|
|
2151
|
+
});
|
|
2152
|
+
return {
|
|
2153
|
+
filterType: column.filterType,
|
|
2154
|
+
getCanColumnFilter: function getCanColumnFilter() {
|
|
2155
|
+
return instance.getColumnCanColumnFilter(column.id);
|
|
2156
|
+
},
|
|
2157
|
+
getCanGlobalFilter: function getCanGlobalFilter() {
|
|
2158
|
+
return instance.getColumnCanGlobalFilter(column.id);
|
|
2159
|
+
},
|
|
2160
|
+
getColumnFilterIndex: function getColumnFilterIndex() {
|
|
2161
|
+
return instance.getColumnFilterIndex(column.id);
|
|
2162
|
+
},
|
|
2163
|
+
getIsColumnFiltered: function getIsColumnFiltered() {
|
|
2164
|
+
return instance.getColumnIsFiltered(column.id);
|
|
2165
|
+
},
|
|
2166
|
+
getColumnFilterValue: function getColumnFilterValue() {
|
|
2167
|
+
return instance.getColumnFilterValue(column.id);
|
|
2168
|
+
},
|
|
2169
|
+
setColumnFilterValue: function setColumnFilterValue(val) {
|
|
2170
|
+
return instance.setColumnFilterValue(column.id, val);
|
|
2171
|
+
},
|
|
2172
|
+
getPreFilteredUniqueValues: function getPreFilteredUniqueValues() {
|
|
2173
|
+
return getFacetInfo().preFilteredUniqueValues;
|
|
2174
|
+
},
|
|
2175
|
+
getPreFilteredMinMaxValues: function getPreFilteredMinMaxValues() {
|
|
2176
|
+
return getFacetInfo().preFilteredMinMaxValues;
|
|
2177
|
+
},
|
|
2178
|
+
getPreFilteredRows: function getPreFilteredRows() {
|
|
2179
|
+
return undefined;
|
|
2180
|
+
}
|
|
2181
|
+
};
|
|
2182
|
+
}
|
|
2183
|
+
function getInstance$5(instance) {
|
|
2184
|
+
var registered = false;
|
|
2185
|
+
return {
|
|
2186
|
+
_notifyFiltersReset: function _notifyFiltersReset() {
|
|
2187
|
+
if (!registered) {
|
|
2188
|
+
registered = true;
|
|
2189
|
+
return;
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2192
|
+
if (instance.options.autoResetAll === false) {
|
|
2193
|
+
return;
|
|
2194
|
+
}
|
|
2195
|
+
|
|
2196
|
+
if (instance.options.autoResetAll === true) {
|
|
2197
|
+
instance.resetSorting();
|
|
2198
|
+
} else {
|
|
2199
|
+
if (instance.options.autoResetColumnFilters) {
|
|
2200
|
+
instance.resetColumnFilters();
|
|
1723
2201
|
}
|
|
1724
|
-
};
|
|
1725
|
-
header = Object.assign(header, createHeader(header, instance)); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
1726
2202
|
|
|
1727
|
-
|
|
2203
|
+
if (instance.options.autoResetGlobalFilter) {
|
|
2204
|
+
instance.resetGlobalFilter();
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
1728
2207
|
},
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
}, function (allColumns, leafColumns, left, right) {
|
|
1733
|
-
var leftColumns = leafColumns.filter(function (column) {
|
|
1734
|
-
return left == null ? void 0 : left.includes(column.id);
|
|
1735
|
-
});
|
|
1736
|
-
var rightColumns = leafColumns.filter(function (column) {
|
|
1737
|
-
return right == null ? void 0 : right.includes(column.id);
|
|
1738
|
-
});
|
|
1739
|
-
var centerColumns = leafColumns.filter(function (column) {
|
|
1740
|
-
return !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id));
|
|
1741
|
-
});
|
|
1742
|
-
var headerGroups = buildHeaderGroups(allColumns, [].concat(leftColumns, centerColumns, rightColumns), instance);
|
|
1743
|
-
return headerGroups;
|
|
1744
|
-
}, 'getHeaderGroups', instance.options.debug),
|
|
1745
|
-
getCenterHeaderGroups: memo(function () {
|
|
1746
|
-
return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
|
|
1747
|
-
}, function (allColumns, leafColumns, left, right) {
|
|
1748
|
-
leafColumns = leafColumns.filter(function (column) {
|
|
1749
|
-
return !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id));
|
|
1750
|
-
});
|
|
1751
|
-
return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
|
|
1752
|
-
}, 'getCenterHeaderGroups', instance.options.debug),
|
|
1753
|
-
getLeftHeaderGroups: memo(function () {
|
|
1754
|
-
return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left];
|
|
1755
|
-
}, function (allColumns, leafColumns, left) {
|
|
1756
|
-
leafColumns = leafColumns.filter(function (column) {
|
|
1757
|
-
return left == null ? void 0 : left.includes(column.id);
|
|
1758
|
-
});
|
|
1759
|
-
return buildHeaderGroups(allColumns, leafColumns, instance, 'left');
|
|
1760
|
-
}, 'getLeftHeaderGroups', instance.options.debug),
|
|
1761
|
-
getRightHeaderGroups: memo(function () {
|
|
1762
|
-
return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right];
|
|
1763
|
-
}, function (allColumns, leafColumns, right) {
|
|
1764
|
-
leafColumns = leafColumns.filter(function (column) {
|
|
1765
|
-
return right == null ? void 0 : right.includes(column.id);
|
|
1766
|
-
});
|
|
1767
|
-
return buildHeaderGroups(allColumns, leafColumns, instance, 'right');
|
|
1768
|
-
}, 'getRightHeaderGroups', instance.options.debug),
|
|
1769
|
-
// Footer Groups
|
|
1770
|
-
getFooterGroups: memo(function () {
|
|
1771
|
-
return [instance.getHeaderGroups()];
|
|
1772
|
-
}, function (headerGroups) {
|
|
1773
|
-
return [].concat(headerGroups).reverse();
|
|
1774
|
-
}, 'getFooterGroups', instance.options.debug),
|
|
1775
|
-
getLeftFooterGroups: memo(function () {
|
|
1776
|
-
return [instance.getLeftHeaderGroups()];
|
|
1777
|
-
}, function (headerGroups) {
|
|
1778
|
-
return [].concat(headerGroups).reverse();
|
|
1779
|
-
}, 'getLeftFooterGroups', instance.options.debug),
|
|
1780
|
-
getCenterFooterGroups: memo(function () {
|
|
1781
|
-
return [instance.getCenterHeaderGroups()];
|
|
1782
|
-
}, function (headerGroups) {
|
|
1783
|
-
return [].concat(headerGroups).reverse();
|
|
1784
|
-
}, 'getCenterFooterGroups', instance.options.debug),
|
|
1785
|
-
getRightFooterGroups: memo(function () {
|
|
1786
|
-
return [instance.getRightHeaderGroups()];
|
|
1787
|
-
}, function (headerGroups) {
|
|
1788
|
-
return [].concat(headerGroups).reverse();
|
|
1789
|
-
}, 'getRightFooterGroups', instance.options.debug),
|
|
1790
|
-
// Flat Headers
|
|
1791
|
-
getFlatHeaders: memo(function () {
|
|
1792
|
-
return [instance.getHeaderGroups()];
|
|
1793
|
-
}, function (headerGroups) {
|
|
1794
|
-
return headerGroups.map(function (headerGroup) {
|
|
1795
|
-
return headerGroup.headers;
|
|
1796
|
-
}).flat();
|
|
1797
|
-
}, 'getFlatHeaders', instance.options.debug),
|
|
1798
|
-
getLeftFlatHeaders: memo(function () {
|
|
1799
|
-
return [instance.getLeftHeaderGroups()];
|
|
1800
|
-
}, function (left) {
|
|
1801
|
-
return left.map(function (headerGroup) {
|
|
1802
|
-
return headerGroup.headers;
|
|
1803
|
-
}).flat();
|
|
1804
|
-
}, 'getLeftFlatHeaders', instance.options.debug),
|
|
1805
|
-
getCenterFlatHeaders: memo(function () {
|
|
1806
|
-
return [instance.getCenterHeaderGroups()];
|
|
1807
|
-
}, function (left) {
|
|
1808
|
-
return left.map(function (headerGroup) {
|
|
1809
|
-
return headerGroup.headers;
|
|
1810
|
-
}).flat();
|
|
1811
|
-
}, 'getCenterFlatHeaders', instance.options.debug),
|
|
1812
|
-
getRightFlatHeaders: memo(function () {
|
|
1813
|
-
return [instance.getRightHeaderGroups()];
|
|
1814
|
-
}, function (left) {
|
|
1815
|
-
return left.map(function (headerGroup) {
|
|
1816
|
-
return headerGroup.headers;
|
|
1817
|
-
}).flat();
|
|
1818
|
-
}, 'getRightFlatHeaders', instance.options.debug),
|
|
1819
|
-
// Leaf Headers
|
|
1820
|
-
getCenterLeafHeaders: memo(function () {
|
|
1821
|
-
return [instance.getCenterFlatHeaders()];
|
|
1822
|
-
}, function (flatHeaders) {
|
|
1823
|
-
return flatHeaders.filter(function (header) {
|
|
1824
|
-
var _header$subHeaders;
|
|
2208
|
+
getColumnAutoFilterFn: function getColumnAutoFilterFn(columnId) {
|
|
2209
|
+
var firstRow = instance.getCoreFlatRows()[0];
|
|
2210
|
+
var value = firstRow == null ? void 0 : firstRow.values[columnId];
|
|
1825
2211
|
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
getLeftLeafHeaders: memo(function () {
|
|
1830
|
-
return [instance.getLeftFlatHeaders()];
|
|
1831
|
-
}, function (flatHeaders) {
|
|
1832
|
-
return flatHeaders.filter(function (header) {
|
|
1833
|
-
var _header$subHeaders2;
|
|
2212
|
+
if (typeof value === 'string') {
|
|
2213
|
+
return filterTypes.includesString;
|
|
2214
|
+
}
|
|
1834
2215
|
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
getRightLeafHeaders: memo(function () {
|
|
1839
|
-
return [instance.getRightFlatHeaders()];
|
|
1840
|
-
}, function (flatHeaders) {
|
|
1841
|
-
return flatHeaders.filter(function (header) {
|
|
1842
|
-
var _header$subHeaders3;
|
|
2216
|
+
if (typeof value === 'number') {
|
|
2217
|
+
return filterTypes.betweenNumberRange;
|
|
2218
|
+
}
|
|
1843
2219
|
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
getLeafHeaders: memo(function () {
|
|
1848
|
-
return [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()];
|
|
1849
|
-
}, function (left, center, right) {
|
|
1850
|
-
var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
|
|
2220
|
+
if (value !== null && typeof value === 'object') {
|
|
2221
|
+
return filterTypes.equals;
|
|
2222
|
+
}
|
|
1851
2223
|
|
|
1852
|
-
|
|
1853
|
-
return
|
|
1854
|
-
}
|
|
1855
|
-
}, 'getLeafHeaders', instance.options.debug),
|
|
1856
|
-
getHeader: function getHeader(id) {
|
|
1857
|
-
var header = [].concat(instance.getFlatHeaders(), instance.getCenterFlatHeaders(), instance.getLeftFlatHeaders(), instance.getRightFlatHeaders()).find(function (d) {
|
|
1858
|
-
return d.id === id;
|
|
1859
|
-
});
|
|
2224
|
+
if (Array.isArray(value)) {
|
|
2225
|
+
return filterTypes.arrIncludes;
|
|
2226
|
+
}
|
|
1860
2227
|
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
2228
|
+
return filterTypes.weakEquals;
|
|
2229
|
+
},
|
|
2230
|
+
getGlobalAutoFilterFn: function getGlobalAutoFilterFn() {
|
|
2231
|
+
return filterTypes.includesString;
|
|
2232
|
+
},
|
|
2233
|
+
getColumnFilterFn: function getColumnFilterFn(columnId) {
|
|
2234
|
+
var _ref;
|
|
2235
|
+
|
|
2236
|
+
var column = instance.getColumn(columnId);
|
|
2237
|
+
var userFilterTypes = instance.options.filterTypes;
|
|
1865
2238
|
|
|
2239
|
+
if (!column) {
|
|
1866
2240
|
throw new Error();
|
|
1867
2241
|
}
|
|
1868
2242
|
|
|
1869
|
-
return
|
|
2243
|
+
return isFunction(column.filterType) ? column.filterType : column.filterType === 'auto' ? instance.getColumnAutoFilterFn(columnId) : (_ref = userFilterTypes == null ? void 0 : userFilterTypes[column.filterType]) != null ? _ref : filterTypes[column.filterType];
|
|
1870
2244
|
},
|
|
1871
|
-
|
|
1872
|
-
var
|
|
1873
|
-
return d.id === id;
|
|
1874
|
-
});
|
|
1875
|
-
|
|
1876
|
-
if (!headerGroup) {
|
|
1877
|
-
return;
|
|
1878
|
-
}
|
|
2245
|
+
getGlobalFilterFn: function getGlobalFilterFn() {
|
|
2246
|
+
var _ref2;
|
|
1879
2247
|
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
2248
|
+
var _instance$options = instance.options,
|
|
2249
|
+
userFilterTypes = _instance$options.filterTypes,
|
|
2250
|
+
globalFilterType = _instance$options.globalFilterType;
|
|
2251
|
+
return isFunction(globalFilterType) ? globalFilterType : globalFilterType === 'auto' ? instance.getGlobalAutoFilterFn() : (_ref2 = userFilterTypes == null ? void 0 : userFilterTypes[globalFilterType]) != null ? _ref2 : filterTypes[globalFilterType];
|
|
1884
2252
|
},
|
|
1885
|
-
|
|
1886
|
-
var
|
|
1887
|
-
return d.id === id;
|
|
1888
|
-
});
|
|
2253
|
+
setColumnFilters: function setColumnFilters(updater) {
|
|
2254
|
+
var leafColumns = instance.getAllLeafColumns();
|
|
1889
2255
|
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
}
|
|
2256
|
+
var updateFn = function updateFn(old) {
|
|
2257
|
+
var _functionalUpdate;
|
|
1893
2258
|
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
2259
|
+
return (_functionalUpdate = functionalUpdate(updater, old)) == null ? void 0 : _functionalUpdate.filter(function (filter) {
|
|
2260
|
+
var column = leafColumns.find(function (d) {
|
|
2261
|
+
return d.id === filter.id;
|
|
2262
|
+
});
|
|
2263
|
+
|
|
2264
|
+
if (column) {
|
|
2265
|
+
var filterFn = instance.getColumnFilterFn(column.id);
|
|
2266
|
+
|
|
2267
|
+
if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {
|
|
2268
|
+
return false;
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
return true;
|
|
2273
|
+
});
|
|
1897
2274
|
};
|
|
1898
|
-
|
|
2275
|
+
|
|
2276
|
+
instance.options.onColumnFiltersChange == null ? void 0 : instance.options.onColumnFiltersChange(updateFn, updateFn(instance.getState().columnFilters));
|
|
1899
2277
|
},
|
|
1900
|
-
|
|
1901
|
-
|
|
2278
|
+
setGlobalFilter: function setGlobalFilter(updater) {
|
|
2279
|
+
instance.options.onGlobalFilterChange == null ? void 0 : instance.options.onGlobalFilterChange(updater, functionalUpdate(updater, instance.getState().globalFilter));
|
|
2280
|
+
},
|
|
2281
|
+
resetGlobalFilter: function resetGlobalFilter() {
|
|
2282
|
+
instance.setGlobalFilter(undefined);
|
|
2283
|
+
},
|
|
2284
|
+
getColumnCanColumnFilter: function getColumnCanColumnFilter(columnId) {
|
|
2285
|
+
var _ref3, _ref4, _ref5, _ref6, _ref7, _column$enableAllFilt;
|
|
1902
2286
|
|
|
1903
|
-
|
|
2287
|
+
var column = instance.getColumn(columnId);
|
|
2288
|
+
|
|
2289
|
+
if (!column) {
|
|
1904
2290
|
throw new Error();
|
|
1905
2291
|
}
|
|
1906
2292
|
|
|
1907
|
-
|
|
1908
|
-
key: header.id,
|
|
1909
|
-
role: 'columnheader',
|
|
1910
|
-
colSpan: header.colSpan,
|
|
1911
|
-
rowSpan: header.rowSpan
|
|
1912
|
-
};
|
|
1913
|
-
return propGetter(initialProps, userProps);
|
|
2293
|
+
return (_ref3 = (_ref4 = (_ref5 = (_ref6 = (_ref7 = (_column$enableAllFilt = column.enableAllFilters) != null ? _column$enableAllFilt : column.enableColumnFilter) != null ? _ref7 : instance.options.enableFilters) != null ? _ref6 : instance.options.enableColumnFilters) != null ? _ref5 : column.defaultCanFilter) != null ? _ref4 : column.defaultCanColumnFilter) != null ? _ref3 : !!column.accessorFn;
|
|
1914
2294
|
},
|
|
1915
|
-
|
|
1916
|
-
var
|
|
2295
|
+
getColumnCanGlobalFilter: function getColumnCanGlobalFilter(columnId) {
|
|
2296
|
+
var _ref8, _ref9, _ref10, _ref11, _ref12, _ref13, _instance$options$ena;
|
|
1917
2297
|
|
|
1918
|
-
|
|
1919
|
-
|
|
2298
|
+
var column = instance.getColumn(columnId);
|
|
2299
|
+
|
|
2300
|
+
if (!column) {
|
|
2301
|
+
throw new Error();
|
|
1920
2302
|
}
|
|
1921
2303
|
|
|
1922
|
-
|
|
1923
|
-
key: header.id,
|
|
1924
|
-
role: 'columnfooter',
|
|
1925
|
-
colSpan: header.colSpan,
|
|
1926
|
-
rowSpan: header.rowSpan
|
|
1927
|
-
};
|
|
1928
|
-
return propGetter(initialProps, userProps);
|
|
2304
|
+
return (_ref8 = ((_ref9 = (_ref10 = (_ref11 = (_ref12 = (_ref13 = (_instance$options$ena = instance.options.enableFilters) != null ? _instance$options$ena : instance.options.enableGlobalFilter) != null ? _ref13 : column.enableAllFilters) != null ? _ref12 : column.enableGlobalFilter) != null ? _ref11 : column.defaultCanFilter) != null ? _ref10 : column.defaultCanGlobalFilter) != null ? _ref9 : !!column.accessorFn) && (instance.options.getColumnCanGlobalFilterFn == null ? void 0 : instance.options.getColumnCanGlobalFilterFn(column))) != null ? _ref8 : true;
|
|
1929
2305
|
},
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
2306
|
+
getColumnIsFiltered: function getColumnIsFiltered(columnId) {
|
|
2307
|
+
return instance.getColumnFilterIndex(columnId) > -1;
|
|
2308
|
+
},
|
|
2309
|
+
getColumnFilterValue: function getColumnFilterValue(columnId) {
|
|
2310
|
+
var _instance$getState$co, _instance$getState$co2;
|
|
1934
2311
|
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
}
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
|
|
1942
|
-
var _headerGroups$0$heade, _headerGroups$;
|
|
2312
|
+
return (_instance$getState$co = instance.getState().columnFilters) == null ? void 0 : (_instance$getState$co2 = _instance$getState$co.find(function (d) {
|
|
2313
|
+
return d.id === columnId;
|
|
2314
|
+
})) == null ? void 0 : _instance$getState$co2.value;
|
|
2315
|
+
},
|
|
2316
|
+
getColumnFilterIndex: function getColumnFilterIndex(columnId) {
|
|
2317
|
+
var _instance$getState$co3, _instance$getState$co4;
|
|
1943
2318
|
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
2319
|
+
return (_instance$getState$co3 = (_instance$getState$co4 = instance.getState().columnFilters) == null ? void 0 : _instance$getState$co4.findIndex(function (d) {
|
|
2320
|
+
return d.id === columnId;
|
|
2321
|
+
})) != null ? _instance$getState$co3 : -1;
|
|
2322
|
+
},
|
|
2323
|
+
setColumnFilterValue: function setColumnFilterValue(columnId, value) {
|
|
2324
|
+
if (!columnId) return;
|
|
2325
|
+
instance.setColumnFilters(function (old) {
|
|
2326
|
+
var column = instance.getColumn(columnId);
|
|
1950
2327
|
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
2328
|
+
if (!column) {
|
|
2329
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2330
|
+
console.warn("React-Table: Could not find a column with id: " + columnId);
|
|
2331
|
+
}
|
|
1955
2332
|
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
return column.getIsVisible();
|
|
1959
|
-
}).forEach(function (column) {
|
|
1960
|
-
var _column$columns;
|
|
2333
|
+
throw new Error();
|
|
2334
|
+
}
|
|
1961
2335
|
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
2336
|
+
var filterFn = instance.getColumnFilterFn(column.id);
|
|
2337
|
+
var previousfilter = old == null ? void 0 : old.find(function (d) {
|
|
2338
|
+
return d.id === columnId;
|
|
2339
|
+
});
|
|
2340
|
+
var newFilter = functionalUpdate(value, previousfilter ? previousfilter.value : undefined); //
|
|
1967
2341
|
|
|
1968
|
-
|
|
1969
|
-
|
|
2342
|
+
if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {
|
|
2343
|
+
var _old$filter;
|
|
1970
2344
|
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
id: [headerFamily, "" + depth].filter(Boolean).join('_'),
|
|
1976
|
-
headers: [],
|
|
1977
|
-
getHeaderGroupProps: function getHeaderGroupProps(getterValue) {
|
|
1978
|
-
return instance.getHeaderGroupProps("" + depth, getterValue);
|
|
1979
|
-
},
|
|
1980
|
-
getFooterGroupProps: function getFooterGroupProps(getterValue) {
|
|
1981
|
-
return instance.getFooterGroupProps("" + depth, getterValue);
|
|
1982
|
-
}
|
|
1983
|
-
}; // The parent columns we're going to scan next
|
|
2345
|
+
return (_old$filter = old == null ? void 0 : old.filter(function (d) {
|
|
2346
|
+
return d.id !== columnId;
|
|
2347
|
+
})) != null ? _old$filter : [];
|
|
2348
|
+
}
|
|
1984
2349
|
|
|
1985
|
-
|
|
2350
|
+
var newFilterObj = {
|
|
2351
|
+
id: columnId,
|
|
2352
|
+
value: newFilter
|
|
2353
|
+
};
|
|
1986
2354
|
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
var latestParentHeader = [].concat(parentHeaders).reverse()[0];
|
|
1990
|
-
var isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
|
|
1991
|
-
var column;
|
|
1992
|
-
var isPlaceholder = false;
|
|
2355
|
+
if (previousfilter) {
|
|
2356
|
+
var _old$map;
|
|
1993
2357
|
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
// The parent header is repeated
|
|
1999
|
-
column = headerToGroup.column;
|
|
2000
|
-
isPlaceholder = true;
|
|
2001
|
-
}
|
|
2358
|
+
return (_old$map = old == null ? void 0 : old.map(function (d) {
|
|
2359
|
+
if (d.id === columnId) {
|
|
2360
|
+
return newFilterObj;
|
|
2361
|
+
}
|
|
2002
2362
|
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2363
|
+
return d;
|
|
2364
|
+
})) != null ? _old$map : [];
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2367
|
+
if (old != null && old.length) {
|
|
2368
|
+
return [].concat(old, [newFilterObj]);
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
return [newFilterObj];
|
|
2010
2372
|
});
|
|
2373
|
+
},
|
|
2374
|
+
resetColumnFilters: function resetColumnFilters() {
|
|
2375
|
+
var _instance$options$ini, _instance$options2, _instance$options2$in;
|
|
2011
2376
|
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2377
|
+
instance.setColumnFilters((_instance$options$ini = (_instance$options2 = instance.options) == null ? void 0 : (_instance$options2$in = _instance$options2.initialState) == null ? void 0 : _instance$options2$in.columnFilters) != null ? _instance$options$ini : []);
|
|
2378
|
+
},
|
|
2379
|
+
getColumnFilteredRowModel: memo(function () {
|
|
2380
|
+
return [instance.getState().columnFilters, instance.getCoreRowModel(), instance.options.columnFilterRowsFn];
|
|
2381
|
+
}, function (columnFilters, rowModel, columnFiltersFn) {
|
|
2382
|
+
var columnFilteredRowModel = function () {
|
|
2383
|
+
if (!(columnFilters != null && columnFilters.length) || !columnFiltersFn) {
|
|
2384
|
+
return rowModel;
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Column Filtering...');
|
|
2388
|
+
return columnFiltersFn(instance, rowModel);
|
|
2389
|
+
}(); // Now that each filtered column has it's partially filtered rows,
|
|
2390
|
+
// lets assign the final filtered rows to all of the other columns
|
|
2391
|
+
|
|
2392
|
+
|
|
2393
|
+
var nonFilteredColumns = instance.getAllLeafColumns().filter(function (column) {
|
|
2394
|
+
var _instance$getState$co5;
|
|
2395
|
+
|
|
2396
|
+
return !((_instance$getState$co5 = instance.getState().columnFilters) != null && _instance$getState$co5.find(function (d) {
|
|
2397
|
+
return d.id === column.id;
|
|
2398
|
+
}));
|
|
2399
|
+
}); // This essentially enables faceted filter options to be built easily
|
|
2400
|
+
// using every column's preFilteredRows value
|
|
2020
2401
|
|
|
2402
|
+
nonFilteredColumns.forEach(function (column) {
|
|
2403
|
+
column.getPreFilteredRows = function () {
|
|
2404
|
+
return columnFilteredRowModel.rows;
|
|
2405
|
+
};
|
|
2406
|
+
});
|
|
2407
|
+
return columnFilteredRowModel;
|
|
2408
|
+
}, {
|
|
2409
|
+
key: 'getColumnFilteredRowModel',
|
|
2410
|
+
debug: instance.options.debug
|
|
2411
|
+
}),
|
|
2412
|
+
// These might be easier to remember than "column" filtered rows
|
|
2413
|
+
getPreFilteredRowModel: function getPreFilteredRowModel() {
|
|
2414
|
+
return instance.getCoreRowModel();
|
|
2415
|
+
},
|
|
2416
|
+
getPreFilteredRows: function getPreFilteredRows() {
|
|
2417
|
+
return instance.getCoreRowModel().rows;
|
|
2418
|
+
},
|
|
2419
|
+
getPreFilteredFlatRows: function getPreFilteredFlatRows() {
|
|
2420
|
+
return instance.getCoreRowModel().flatRows;
|
|
2421
|
+
},
|
|
2422
|
+
getPreFilteredRowsById: function getPreFilteredRowsById() {
|
|
2423
|
+
return instance.getCoreRowModel().rowsById;
|
|
2424
|
+
},
|
|
2425
|
+
// Pre Column Filter
|
|
2426
|
+
getPreColumnFilteredRows: function getPreColumnFilteredRows() {
|
|
2427
|
+
return instance.getCoreRowModel().rows;
|
|
2428
|
+
},
|
|
2429
|
+
getPreColumnFilteredFlatRows: function getPreColumnFilteredFlatRows() {
|
|
2430
|
+
return instance.getCoreRowModel().flatRows;
|
|
2431
|
+
},
|
|
2432
|
+
getPreColumnFilteredRowsById: function getPreColumnFilteredRowsById() {
|
|
2433
|
+
return instance.getCoreRowModel().rowsById;
|
|
2434
|
+
},
|
|
2435
|
+
getColumnFilteredRows: function getColumnFilteredRows() {
|
|
2436
|
+
return instance.getColumnFilteredRowModel().rows;
|
|
2437
|
+
},
|
|
2438
|
+
getColumnFilteredFlatRows: function getColumnFilteredFlatRows() {
|
|
2439
|
+
return instance.getColumnFilteredRowModel().flatRows;
|
|
2440
|
+
},
|
|
2441
|
+
getColumnFilteredRowsById: function getColumnFilteredRowsById() {
|
|
2442
|
+
return instance.getColumnFilteredRowModel().rowsById;
|
|
2443
|
+
},
|
|
2444
|
+
getGlobalFilteredRowModel: memo(function () {
|
|
2445
|
+
return [instance.getState().globalFilter, instance.getColumnFilteredRowModel(), instance.options.globalFilterRowsFn];
|
|
2446
|
+
}, function (globalFilterValue, columnFilteredRowModel, globalFiltersFn) {
|
|
2447
|
+
var globalFilteredRowModel = function () {
|
|
2448
|
+
if (!globalFiltersFn || !globalFilterValue) {
|
|
2449
|
+
return columnFilteredRowModel;
|
|
2450
|
+
}
|
|
2021
2451
|
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2452
|
+
if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Global Filtering...');
|
|
2453
|
+
return globalFiltersFn(instance, columnFilteredRowModel);
|
|
2454
|
+
}(); // Now that each filtered column has it's partially filtered rows,
|
|
2455
|
+
// lets assign the final filtered rows to all of the other columns
|
|
2025
2456
|
|
|
2026
|
-
if (depth > 0) {
|
|
2027
|
-
createHeaderGroup(parentHeaders, depth - 1);
|
|
2028
|
-
}
|
|
2029
|
-
};
|
|
2030
2457
|
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
depth: maxDepth
|
|
2034
|
-
});
|
|
2035
|
-
});
|
|
2036
|
-
createHeaderGroup(bottomHeaders, maxDepth - 1);
|
|
2037
|
-
headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
|
|
2038
|
-
// return !headerGroup.headers.every(header => header.isPlaceholder)
|
|
2039
|
-
// })
|
|
2458
|
+
var nonFilteredColumns = instance.getAllLeafColumns().filter(function (column) {
|
|
2459
|
+
var _instance$getState$co6;
|
|
2040
2460
|
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
var colSpan = 0;
|
|
2047
|
-
var rowSpan = 0;
|
|
2048
|
-
var childRowSpans = [0];
|
|
2461
|
+
return !((_instance$getState$co6 = instance.getState().columnFilters) != null && _instance$getState$co6.find(function (d) {
|
|
2462
|
+
return d.id === column.id;
|
|
2463
|
+
}));
|
|
2464
|
+
}); // This essentially enables faceted filter options to be built easily
|
|
2465
|
+
// using every column's preFilteredRows value
|
|
2049
2466
|
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2467
|
+
nonFilteredColumns.forEach(function (column) {
|
|
2468
|
+
column.getPreFilteredRows = function () {
|
|
2469
|
+
return globalFilteredRowModel.rows;
|
|
2470
|
+
};
|
|
2471
|
+
});
|
|
2472
|
+
return globalFilteredRowModel;
|
|
2473
|
+
}, {
|
|
2474
|
+
key: 'getGlobalFilteredRowModel',
|
|
2475
|
+
debug: instance.options.debug,
|
|
2476
|
+
onChange: function onChange() {
|
|
2477
|
+
return instance._notifySortingReset();
|
|
2060
2478
|
}
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
return
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
}
|
|
2479
|
+
}),
|
|
2480
|
+
getPreGlobalFilteredRows: function getPreGlobalFilteredRows() {
|
|
2481
|
+
return instance.getColumnFilteredRowModel().rows;
|
|
2482
|
+
},
|
|
2483
|
+
getPreGlobalFilteredFlatRows: function getPreGlobalFilteredFlatRows() {
|
|
2484
|
+
return instance.getColumnFilteredRowModel().flatRows;
|
|
2485
|
+
},
|
|
2486
|
+
getPreGlobalFilteredRowsById: function getPreGlobalFilteredRowsById() {
|
|
2487
|
+
return instance.getColumnFilteredRowModel().rowsById;
|
|
2488
|
+
},
|
|
2489
|
+
getGlobalFilteredRows: function getGlobalFilteredRows() {
|
|
2490
|
+
return instance.getGlobalFilteredRowModel().rows;
|
|
2491
|
+
},
|
|
2492
|
+
getGlobalFilteredFlatRows: function getGlobalFilteredFlatRows() {
|
|
2493
|
+
return instance.getGlobalFilteredRowModel().flatRows;
|
|
2494
|
+
},
|
|
2495
|
+
getGlobalFilteredRowsById: function getGlobalFilteredRowsById() {
|
|
2496
|
+
return instance.getGlobalFilteredRowModel().rowsById;
|
|
2497
|
+
}
|
|
2071
2498
|
};
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
return
|
|
2499
|
+
}
|
|
2500
|
+
function shouldAutoRemoveFilter(filterFn, value, column) {
|
|
2501
|
+
return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
|
|
2075
2502
|
}
|
|
2076
2503
|
|
|
2077
|
-
var
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2504
|
+
var Filters = /*#__PURE__*/Object.freeze({
|
|
2505
|
+
__proto__: null,
|
|
2506
|
+
getDefaultColumn: getDefaultColumn$1,
|
|
2507
|
+
getInitialState: getInitialState$5,
|
|
2508
|
+
getDefaultOptions: getDefaultOptions$5,
|
|
2509
|
+
createColumn: createColumn$2,
|
|
2510
|
+
getInstance: getInstance$5,
|
|
2511
|
+
shouldAutoRemoveFilter: shouldAutoRemoveFilter
|
|
2512
|
+
});
|
|
2513
|
+
|
|
2514
|
+
var reSplitAlphaNumeric = /([0-9]+)/gm;
|
|
2515
|
+
var sortTypes = {
|
|
2516
|
+
alphanumeric: alphanumeric,
|
|
2517
|
+
alphanumericCaseSensitive: alphanumericCaseSensitive,
|
|
2518
|
+
text: text,
|
|
2519
|
+
textCaseSensitive: textCaseSensitive,
|
|
2520
|
+
datetime: datetime,
|
|
2521
|
+
basic: basic
|
|
2087
2522
|
};
|
|
2088
2523
|
|
|
2089
|
-
function
|
|
2090
|
-
|
|
2091
|
-
rows = rows.filter(function (row) {
|
|
2092
|
-
return columnIds.some(function (id) {
|
|
2093
|
-
return String(row.values[id]).toLowerCase().includes(search);
|
|
2094
|
-
});
|
|
2095
|
-
});
|
|
2096
|
-
return rows;
|
|
2524
|
+
function alphanumeric(rowA, rowB, columnId) {
|
|
2525
|
+
return compareAlphanumeric(toString(rowA.values[columnId]).toLowerCase(), toString(rowB.values[columnId]).toLowerCase());
|
|
2097
2526
|
}
|
|
2098
2527
|
|
|
2099
|
-
|
|
2100
|
-
return
|
|
2101
|
-
}
|
|
2528
|
+
function alphanumericCaseSensitive(rowA, rowB, columnId) {
|
|
2529
|
+
return compareAlphanumeric(toString(rowA.values[columnId]), toString(rowB.values[columnId]));
|
|
2530
|
+
} // Mixed sorting is slow, but very inclusive of many edge cases.
|
|
2531
|
+
// It handles numbers, mixed alphanumeric combinations, and even
|
|
2532
|
+
// null, undefined, and Infinity
|
|
2102
2533
|
|
|
2103
|
-
function includesStringSensitive(rows, columnIds, filterValue) {
|
|
2104
|
-
var search = String(filterValue);
|
|
2105
|
-
rows = rows.filter(function (row) {
|
|
2106
|
-
return columnIds.some(function (id) {
|
|
2107
|
-
return String(row.values[id]).includes(search);
|
|
2108
|
-
});
|
|
2109
|
-
});
|
|
2110
|
-
return rows;
|
|
2111
|
-
}
|
|
2112
2534
|
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2535
|
+
function compareAlphanumeric(aStr, bStr) {
|
|
2536
|
+
// Split on number groups, but keep the delimiter
|
|
2537
|
+
// Then remove falsey split values
|
|
2538
|
+
var a = aStr.split(reSplitAlphaNumeric).filter(Boolean);
|
|
2539
|
+
var b = bStr.split(reSplitAlphaNumeric).filter(Boolean); // While
|
|
2116
2540
|
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
});
|
|
2124
|
-
});
|
|
2125
|
-
}
|
|
2541
|
+
while (a.length && b.length) {
|
|
2542
|
+
var aa = a.shift();
|
|
2543
|
+
var bb = b.shift();
|
|
2544
|
+
var an = parseInt(aa, 10);
|
|
2545
|
+
var bn = parseInt(bb, 10);
|
|
2546
|
+
var combo = [an, bn].sort(); // Both are string
|
|
2126
2547
|
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2548
|
+
if (isNaN(combo[0])) {
|
|
2549
|
+
if (aa > bb) {
|
|
2550
|
+
return 1;
|
|
2551
|
+
}
|
|
2130
2552
|
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
return columnIds.some(function (id) {
|
|
2135
|
-
var rowValue = row.values[id];
|
|
2136
|
-
return rowValue !== undefined ? String(rowValue) === search : true;
|
|
2137
|
-
});
|
|
2138
|
-
});
|
|
2139
|
-
}
|
|
2553
|
+
if (bb > aa) {
|
|
2554
|
+
return -1;
|
|
2555
|
+
}
|
|
2140
2556
|
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
};
|
|
2557
|
+
continue;
|
|
2558
|
+
} // One is a string, one is a number
|
|
2144
2559
|
|
|
2145
|
-
function arrIncludes(rows, columnIds, filterValue) {
|
|
2146
|
-
return rows.filter(function (row) {
|
|
2147
|
-
return columnIds.some(function (id) {
|
|
2148
|
-
var rowValue = row.values[id];
|
|
2149
|
-
return rowValue.includes(filterValue);
|
|
2150
|
-
});
|
|
2151
|
-
});
|
|
2152
|
-
}
|
|
2153
2560
|
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
}
|
|
2561
|
+
if (isNaN(combo[1])) {
|
|
2562
|
+
return isNaN(an) ? -1 : 1;
|
|
2563
|
+
} // Both are numbers
|
|
2157
2564
|
|
|
2158
|
-
function arrIncludesAll(rows, columnIds, filterValue) {
|
|
2159
|
-
return rows.filter(function (row) {
|
|
2160
|
-
return columnIds.some(function (id) {
|
|
2161
|
-
var rowValue = row.values[id];
|
|
2162
|
-
return rowValue && rowValue.length && filterValue.every(function (val) {
|
|
2163
|
-
return rowValue.includes(val);
|
|
2164
|
-
});
|
|
2165
|
-
});
|
|
2166
|
-
});
|
|
2167
|
-
}
|
|
2168
2565
|
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
}
|
|
2566
|
+
if (an > bn) {
|
|
2567
|
+
return 1;
|
|
2568
|
+
}
|
|
2172
2569
|
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
return rowValue === filterValue;
|
|
2178
|
-
});
|
|
2179
|
-
});
|
|
2180
|
-
}
|
|
2570
|
+
if (bn > an) {
|
|
2571
|
+
return -1;
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2181
2574
|
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2575
|
+
return a.length - b.length;
|
|
2576
|
+
} // The text filter is more basic (less numeric support)
|
|
2577
|
+
// but is much faster
|
|
2185
2578
|
|
|
2186
|
-
function weakEquals(rows, columnIds, filterValue) {
|
|
2187
|
-
return rows.filter(function (row) {
|
|
2188
|
-
return columnIds.some(function (id) {
|
|
2189
|
-
var rowValue = row.values[id]; // eslint-disable-next-line eqeqeq
|
|
2190
2579
|
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2580
|
+
function text(rowA, rowB, columnId) {
|
|
2581
|
+
return compareBasic(toString(rowA.values[columnId]).toLowerCase(), toString(rowB.values[columnId]).toLowerCase());
|
|
2582
|
+
} // The text filter is more basic (less numeric support)
|
|
2583
|
+
// but is much faster
|
|
2195
2584
|
|
|
2196
|
-
weakEquals.autoRemove = function (val) {
|
|
2197
|
-
return testFalsey(val);
|
|
2198
|
-
};
|
|
2199
2585
|
|
|
2200
|
-
function
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
unsafeMax = _ref[1];
|
|
2586
|
+
function textCaseSensitive(rowA, rowB, columnId) {
|
|
2587
|
+
return compareBasic(toString(rowA.values[columnId]), toString(rowB.values[columnId]));
|
|
2588
|
+
}
|
|
2204
2589
|
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
var max = unsafeMax === null || Number.isNaN(parsedMax) ? Infinity : parsedMax;
|
|
2590
|
+
function datetime(rowA, rowB, columnId) {
|
|
2591
|
+
return compareBasic(rowA.values[columnId].getTime(), rowB.values[columnId].getTime());
|
|
2592
|
+
}
|
|
2209
2593
|
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
max = temp;
|
|
2214
|
-
}
|
|
2594
|
+
function basic(rowA, rowB, columnId) {
|
|
2595
|
+
return compareBasic(rowA.values[columnId], rowB.values[columnId]);
|
|
2596
|
+
} // Utils
|
|
2215
2597
|
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
return rowValue >= min && rowValue <= max;
|
|
2220
|
-
});
|
|
2221
|
-
});
|
|
2598
|
+
|
|
2599
|
+
function compareBasic(a, b) {
|
|
2600
|
+
return a === b ? 0 : a > b ? 1 : -1;
|
|
2222
2601
|
}
|
|
2223
2602
|
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2603
|
+
function toString(a) {
|
|
2604
|
+
if (typeof a === 'number') {
|
|
2605
|
+
if (isNaN(a) || a === Infinity || a === -Infinity) {
|
|
2606
|
+
return '';
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
return String(a);
|
|
2610
|
+
}
|
|
2227
2611
|
|
|
2612
|
+
if (typeof a === 'string') {
|
|
2613
|
+
return a;
|
|
2614
|
+
}
|
|
2228
2615
|
|
|
2229
|
-
|
|
2230
|
-
return val === undefined || val === null || val === '';
|
|
2616
|
+
return '';
|
|
2231
2617
|
}
|
|
2232
2618
|
|
|
2233
2619
|
//
|
|
2234
|
-
function getDefaultColumn
|
|
2620
|
+
function getDefaultColumn() {
|
|
2235
2621
|
return {
|
|
2236
|
-
|
|
2622
|
+
sortType: 'auto'
|
|
2237
2623
|
};
|
|
2238
2624
|
}
|
|
2239
|
-
function getInitialState$
|
|
2625
|
+
function getInitialState$4() {
|
|
2240
2626
|
return {
|
|
2241
|
-
|
|
2242
|
-
globalFilter: undefined
|
|
2627
|
+
sorting: []
|
|
2243
2628
|
};
|
|
2244
2629
|
}
|
|
2245
|
-
function getDefaultOptions$
|
|
2630
|
+
function getDefaultOptions$4(instance) {
|
|
2246
2631
|
return {
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
autoResetGlobalFilter: true,
|
|
2252
|
-
globalFilterType: 'auto',
|
|
2253
|
-
getColumnCanGlobalFilterFn: function getColumnCanGlobalFilterFn(column) {
|
|
2254
|
-
var _instance$getCoreFlat, _instance$getCoreFlat2;
|
|
2255
|
-
|
|
2256
|
-
var value = (_instance$getCoreFlat = instance.getCoreFlatRows()[0]) == null ? void 0 : (_instance$getCoreFlat2 = _instance$getCoreFlat.getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreFlat2.value;
|
|
2257
|
-
return typeof value === 'string';
|
|
2632
|
+
onSortingChange: makeStateUpdater('sorting', instance),
|
|
2633
|
+
autoResetSorting: true,
|
|
2634
|
+
isMultiSortEvent: function isMultiSortEvent(e) {
|
|
2635
|
+
return e.shiftKey;
|
|
2258
2636
|
}
|
|
2259
2637
|
};
|
|
2260
2638
|
}
|
|
2261
2639
|
function createColumn$1(column, instance) {
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2640
|
+
return {
|
|
2641
|
+
sortType: column.sortType,
|
|
2642
|
+
getCanSort: function getCanSort() {
|
|
2643
|
+
return instance.getColumnCanSort(column.id);
|
|
2644
|
+
},
|
|
2645
|
+
getCanMultiSort: function getCanMultiSort() {
|
|
2646
|
+
return instance.getColumnCanMultiSort(column.id);
|
|
2647
|
+
},
|
|
2648
|
+
getSortIndex: function getSortIndex() {
|
|
2649
|
+
return instance.getColumnSortIndex(column.id);
|
|
2650
|
+
},
|
|
2651
|
+
getIsSorted: function getIsSorted() {
|
|
2652
|
+
return instance.getColumnIsSorted(column.id);
|
|
2653
|
+
},
|
|
2654
|
+
toggleSorting: function toggleSorting(desc, isMulti) {
|
|
2655
|
+
return instance.toggleColumnSorting(column.id, desc, isMulti);
|
|
2656
|
+
},
|
|
2657
|
+
getToggleSortingProps: function getToggleSortingProps(userProps) {
|
|
2658
|
+
return instance.getToggleSortingProps(column.id, userProps);
|
|
2269
2659
|
}
|
|
2660
|
+
};
|
|
2661
|
+
}
|
|
2662
|
+
function getInstance$4(instance) {
|
|
2663
|
+
var registered = false;
|
|
2664
|
+
return {
|
|
2665
|
+
_notifySortingReset: function _notifySortingReset() {
|
|
2666
|
+
if (!registered) {
|
|
2667
|
+
registered = true;
|
|
2668
|
+
return;
|
|
2669
|
+
}
|
|
2270
2670
|
|
|
2271
|
-
|
|
2272
|
-
|
|
2671
|
+
if (instance.options.autoResetAll === false) {
|
|
2672
|
+
return;
|
|
2673
|
+
}
|
|
2273
2674
|
|
|
2274
|
-
|
|
2275
|
-
|
|
2675
|
+
if (instance.options.autoResetAll === true || instance.options.autoResetSorting) {
|
|
2676
|
+
instance.resetSorting();
|
|
2677
|
+
}
|
|
2678
|
+
},
|
|
2679
|
+
getColumnAutoSortingFn: function getColumnAutoSortingFn(columnId) {
|
|
2680
|
+
var firstRows = instance.getGlobalFilteredRowModel().flatRows.slice(100);
|
|
2681
|
+
var isString = false;
|
|
2276
2682
|
|
|
2277
|
-
var
|
|
2683
|
+
for (var _iterator = _createForOfIteratorHelperLoose(firstRows), _step; !(_step = _iterator()).done;) {
|
|
2684
|
+
var row = _step.value;
|
|
2685
|
+
var value = row == null ? void 0 : row.values[columnId];
|
|
2278
2686
|
|
|
2279
|
-
|
|
2280
|
-
|
|
2687
|
+
if (Object.prototype.toString.call(value) === '[object Date]') {
|
|
2688
|
+
return sortTypes.datetime;
|
|
2689
|
+
}
|
|
2281
2690
|
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2691
|
+
if (typeof value === 'string') {
|
|
2692
|
+
isString = true;
|
|
2693
|
+
|
|
2694
|
+
if (value.split(reSplitAlphaNumeric).length > 1) {
|
|
2695
|
+
return sortTypes.alphanumeric;
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2285
2698
|
}
|
|
2286
2699
|
|
|
2287
|
-
if (
|
|
2288
|
-
|
|
2289
|
-
} else if (_value > preFilteredMinMaxValues[1]) {
|
|
2290
|
-
preFilteredMinMaxValues[1] = _value;
|
|
2700
|
+
if (isString) {
|
|
2701
|
+
return sortTypes.text;
|
|
2291
2702
|
}
|
|
2292
|
-
}
|
|
2293
2703
|
|
|
2294
|
-
|
|
2295
|
-
preFilteredUniqueValues: preFilteredUniqueValues,
|
|
2296
|
-
preFilteredMinMaxValues: preFilteredMinMaxValues
|
|
2297
|
-
};
|
|
2298
|
-
}, 'column.getFacetInfo', instance.options.debug);
|
|
2299
|
-
return {
|
|
2300
|
-
filterType: column.filterType,
|
|
2301
|
-
getCanColumnFilter: function getCanColumnFilter() {
|
|
2302
|
-
return instance.getColumnCanColumnFilter(column.id);
|
|
2303
|
-
},
|
|
2304
|
-
getCanGlobalFilter: function getCanGlobalFilter() {
|
|
2305
|
-
return instance.getColumnCanGlobalFilter(column.id);
|
|
2306
|
-
},
|
|
2307
|
-
getColumnFilterIndex: function getColumnFilterIndex() {
|
|
2308
|
-
return instance.getColumnFilterIndex(column.id);
|
|
2309
|
-
},
|
|
2310
|
-
getIsColumnFiltered: function getIsColumnFiltered() {
|
|
2311
|
-
return instance.getColumnIsFiltered(column.id);
|
|
2312
|
-
},
|
|
2313
|
-
getColumnFilterValue: function getColumnFilterValue() {
|
|
2314
|
-
return instance.getColumnFilterValue(column.id);
|
|
2704
|
+
return sortTypes.basic;
|
|
2315
2705
|
},
|
|
2316
|
-
|
|
2317
|
-
|
|
2706
|
+
getColumnAutoSortDir: function getColumnAutoSortDir(columnId) {
|
|
2707
|
+
var firstRow = instance.getGlobalFilteredRowModel().flatRows[0];
|
|
2708
|
+
var value = firstRow == null ? void 0 : firstRow.values[columnId];
|
|
2709
|
+
|
|
2710
|
+
if (typeof value === 'string') {
|
|
2711
|
+
return 'asc';
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2714
|
+
return 'desc';
|
|
2318
2715
|
},
|
|
2319
|
-
|
|
2320
|
-
|
|
2716
|
+
getColumnSortingFn: function getColumnSortingFn(columnId) {
|
|
2717
|
+
var _ref;
|
|
2718
|
+
|
|
2719
|
+
var column = instance.getColumn(columnId);
|
|
2720
|
+
var userSortTypes = instance.options.sortTypes;
|
|
2721
|
+
|
|
2722
|
+
if (!column) {
|
|
2723
|
+
throw new Error();
|
|
2724
|
+
}
|
|
2725
|
+
|
|
2726
|
+
return isFunction(column.sortType) ? column.sortType : column.sortType === 'auto' ? instance.getColumnAutoSortingFn(columnId) : (_ref = userSortTypes == null ? void 0 : userSortTypes[column.sortType]) != null ? _ref : sortTypes[column.sortType];
|
|
2321
2727
|
},
|
|
2322
|
-
|
|
2323
|
-
return
|
|
2728
|
+
setSorting: function setSorting(updater) {
|
|
2729
|
+
return instance.options.onSortingChange == null ? void 0 : instance.options.onSortingChange(updater, functionalUpdate(updater, instance.getState().sorting));
|
|
2324
2730
|
},
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2731
|
+
toggleColumnSorting: function toggleColumnSorting(columnId, desc, multi) {
|
|
2732
|
+
var column = instance.getColumn(columnId);
|
|
2733
|
+
|
|
2734
|
+
if (!column) {
|
|
2735
|
+
throw new Error();
|
|
2736
|
+
} // if (column.columns.length) {
|
|
2737
|
+
// column.columns.forEach((c, i) => {
|
|
2738
|
+
// if (c.id) {
|
|
2739
|
+
// instance.toggleColumnSorting(c.id, undefined, multi || !!i)
|
|
2740
|
+
// }
|
|
2741
|
+
// })
|
|
2742
|
+
// return
|
|
2743
|
+
// }
|
|
2744
|
+
|
|
2745
|
+
|
|
2746
|
+
instance.setSorting(function (old) {
|
|
2747
|
+
var _ref2, _column$sortDescFirst, _instance$options$ena, _instance$options$ena2;
|
|
2748
|
+
|
|
2749
|
+
// Find any existing sorting for this column
|
|
2750
|
+
var existingSorting = old == null ? void 0 : old.find(function (d) {
|
|
2751
|
+
return d.id === columnId;
|
|
2752
|
+
});
|
|
2753
|
+
var existingIndex = old == null ? void 0 : old.findIndex(function (d) {
|
|
2754
|
+
return d.id === columnId;
|
|
2755
|
+
});
|
|
2756
|
+
var hasDescDefined = typeof desc !== 'undefined' && desc !== null;
|
|
2757
|
+
var newSorting = []; // What should we do with this sort action?
|
|
2758
|
+
|
|
2759
|
+
var sortAction;
|
|
2760
|
+
|
|
2761
|
+
if (column.getCanMultiSort() && multi) {
|
|
2762
|
+
if (existingSorting) {
|
|
2763
|
+
sortAction = 'toggle';
|
|
2764
|
+
} else {
|
|
2765
|
+
sortAction = 'add';
|
|
2766
|
+
}
|
|
2767
|
+
} else {
|
|
2768
|
+
// Normal mode
|
|
2769
|
+
if (old != null && old.length && existingIndex !== old.length - 1) {
|
|
2770
|
+
sortAction = 'replace';
|
|
2771
|
+
} else if (existingSorting) {
|
|
2772
|
+
sortAction = 'toggle';
|
|
2773
|
+
} else {
|
|
2774
|
+
sortAction = 'replace';
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
|
|
2778
|
+
var sortDescFirst = (_ref2 = (_column$sortDescFirst = column.sortDescFirst) != null ? _column$sortDescFirst : instance.options.sortDescFirst) != null ? _ref2 : instance.getColumnAutoSortDir(columnId) === 'desc'; // Handle toggle states that will remove the sorting
|
|
2779
|
+
|
|
2780
|
+
if (sortAction === 'toggle' && ( // Must be toggling
|
|
2781
|
+
(_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
|
|
2782
|
+
!hasDescDefined && ( // Must not be setting desc
|
|
2783
|
+
multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && ( // If multi, don't allow if enableMultiRemove
|
|
2784
|
+
existingSorting != null && existingSorting.desc // Finally, detect if it should indeed be removed
|
|
2785
|
+
? !sortDescFirst : sortDescFirst)) {
|
|
2786
|
+
sortAction = 'remove';
|
|
2787
|
+
}
|
|
2788
|
+
|
|
2789
|
+
if (sortAction === 'replace') {
|
|
2790
|
+
newSorting = [{
|
|
2791
|
+
id: columnId,
|
|
2792
|
+
desc: hasDescDefined ? desc : !!sortDescFirst
|
|
2793
|
+
}];
|
|
2794
|
+
} else if (sortAction === 'add' && old != null && old.length) {
|
|
2795
|
+
var _instance$options$max;
|
|
2335
2796
|
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2797
|
+
newSorting = [].concat(old, [{
|
|
2798
|
+
id: columnId,
|
|
2799
|
+
desc: hasDescDefined ? desc : !!sortDescFirst
|
|
2800
|
+
}]); // Take latest n columns
|
|
2339
2801
|
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2802
|
+
newSorting.splice(0, newSorting.length - ((_instance$options$max = instance.options.maxMultiSortColCount) != null ? _instance$options$max : Number.MAX_SAFE_INTEGER));
|
|
2803
|
+
} else if (sortAction === 'toggle' && old != null && old.length) {
|
|
2804
|
+
// This flips (or sets) the
|
|
2805
|
+
newSorting = old.map(function (d) {
|
|
2806
|
+
if (d.id === columnId) {
|
|
2807
|
+
return _extends({}, d, {
|
|
2808
|
+
desc: hasDescDefined ? desc : !(existingSorting != null && existingSorting.desc)
|
|
2809
|
+
});
|
|
2810
|
+
}
|
|
2343
2811
|
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2812
|
+
return d;
|
|
2813
|
+
});
|
|
2814
|
+
} else if (sortAction === 'remove' && old != null && old.length) {
|
|
2815
|
+
newSorting = old.filter(function (d) {
|
|
2816
|
+
return d.id !== columnId;
|
|
2817
|
+
});
|
|
2818
|
+
}
|
|
2347
2819
|
|
|
2348
|
-
|
|
2349
|
-
|
|
2820
|
+
return newSorting;
|
|
2821
|
+
});
|
|
2822
|
+
},
|
|
2823
|
+
getColumnCanSort: function getColumnCanSort(columnId) {
|
|
2824
|
+
var _ref3, _ref4, _column$enableSorting;
|
|
2825
|
+
|
|
2826
|
+
var column = instance.getColumn(columnId);
|
|
2827
|
+
|
|
2828
|
+
if (!column) {
|
|
2829
|
+
throw new Error();
|
|
2350
2830
|
}
|
|
2351
2831
|
|
|
2352
|
-
return
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2832
|
+
return (_ref3 = (_ref4 = (_column$enableSorting = column.enableSorting) != null ? _column$enableSorting : instance.options.enableSorting) != null ? _ref4 : column.defaultCanSort) != null ? _ref3 : !!column.accessorFn // (!!column.accessorFn ||
|
|
2833
|
+
// column.columns?.some(c => c.id && instance.getColumnCanSort(c.id))) ??
|
|
2834
|
+
// false
|
|
2835
|
+
;
|
|
2356
2836
|
},
|
|
2357
|
-
|
|
2358
|
-
var
|
|
2837
|
+
getColumnCanMultiSort: function getColumnCanMultiSort(columnId) {
|
|
2838
|
+
var _ref5, _column$enableMultiSo;
|
|
2359
2839
|
|
|
2360
2840
|
var column = instance.getColumn(columnId);
|
|
2361
|
-
var userFilterTypes = instance.options.filterTypes;
|
|
2362
2841
|
|
|
2363
2842
|
if (!column) {
|
|
2364
2843
|
throw new Error();
|
|
2365
2844
|
}
|
|
2366
2845
|
|
|
2367
|
-
return
|
|
2846
|
+
return (_ref5 = (_column$enableMultiSo = column.enableMultiSort) != null ? _column$enableMultiSo : instance.options.enableMultiSort) != null ? _ref5 : !!column.accessorFn;
|
|
2368
2847
|
},
|
|
2369
|
-
|
|
2370
|
-
var
|
|
2848
|
+
getColumnIsSorted: function getColumnIsSorted(columnId) {
|
|
2849
|
+
var _instance$getState$so;
|
|
2371
2850
|
|
|
2372
|
-
var _instance$
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
return
|
|
2851
|
+
var columnSort = (_instance$getState$so = instance.getState().sorting) == null ? void 0 : _instance$getState$so.find(function (d) {
|
|
2852
|
+
return d.id === columnId;
|
|
2853
|
+
});
|
|
2854
|
+
return !columnSort ? false : columnSort.desc ? 'desc' : 'asc';
|
|
2376
2855
|
},
|
|
2377
|
-
|
|
2378
|
-
var
|
|
2379
|
-
|
|
2380
|
-
var updateFn = function updateFn(old) {
|
|
2381
|
-
var _functionalUpdate;
|
|
2856
|
+
getColumnSortIndex: function getColumnSortIndex(columnId) {
|
|
2857
|
+
var _instance$getState$so2, _instance$getState$so3;
|
|
2382
2858
|
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2859
|
+
return (_instance$getState$so2 = (_instance$getState$so3 = instance.getState().sorting) == null ? void 0 : _instance$getState$so3.findIndex(function (d) {
|
|
2860
|
+
return d.id === columnId;
|
|
2861
|
+
})) != null ? _instance$getState$so2 : -1;
|
|
2862
|
+
},
|
|
2863
|
+
resetSorting: function resetSorting() {
|
|
2864
|
+
var _instance$options$ini, _instance$options, _instance$options$ini2;
|
|
2387
2865
|
|
|
2388
|
-
|
|
2389
|
-
|
|
2866
|
+
instance.setSorting((_instance$options$ini = (_instance$options = instance.options) == null ? void 0 : (_instance$options$ini2 = _instance$options.initialState) == null ? void 0 : _instance$options$ini2.sorting) != null ? _instance$options$ini : []);
|
|
2867
|
+
},
|
|
2868
|
+
getToggleSortingProps: function getToggleSortingProps(columnId, userProps) {
|
|
2869
|
+
var column = instance.getColumn(columnId);
|
|
2390
2870
|
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
}
|
|
2871
|
+
if (!column) {
|
|
2872
|
+
throw new Error();
|
|
2873
|
+
}
|
|
2395
2874
|
|
|
2396
|
-
|
|
2397
|
-
|
|
2875
|
+
var canSort = column.getCanSort();
|
|
2876
|
+
var initialProps = {
|
|
2877
|
+
title: canSort ? 'Toggle Sorting' : undefined,
|
|
2878
|
+
onClick: canSort ? function (e) {
|
|
2879
|
+
e.persist();
|
|
2880
|
+
column.toggleSorting == null ? void 0 : column.toggleSorting(undefined, column.getCanMultiSort() ? instance.options.isMultiSortEvent == null ? void 0 : instance.options.isMultiSortEvent(e) : false);
|
|
2881
|
+
} : undefined
|
|
2398
2882
|
};
|
|
2883
|
+
return propGetter(initialProps, userProps);
|
|
2884
|
+
},
|
|
2885
|
+
getSortedRowModel: memo(function () {
|
|
2886
|
+
return [instance.getState().sorting, instance.getGlobalFilteredRowModel(), instance.options.sortRowsFn];
|
|
2887
|
+
}, function (sorting, rowModel, sortingFn) {
|
|
2888
|
+
if (!sortingFn || !(sorting != null && sorting.length)) {
|
|
2889
|
+
return rowModel;
|
|
2890
|
+
}
|
|
2399
2891
|
|
|
2400
|
-
|
|
2892
|
+
if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Sorting...');
|
|
2893
|
+
return sortingFn(instance, rowModel);
|
|
2894
|
+
}, {
|
|
2895
|
+
key: 'getSortedRowModel',
|
|
2896
|
+
debug: instance.options.debug,
|
|
2897
|
+
onChange: function onChange() {
|
|
2898
|
+
return instance._notifyGroupingReset();
|
|
2899
|
+
}
|
|
2900
|
+
}),
|
|
2901
|
+
getPreSortedRows: function getPreSortedRows() {
|
|
2902
|
+
return instance.getGlobalFilteredRowModel().rows;
|
|
2401
2903
|
},
|
|
2402
|
-
|
|
2403
|
-
|
|
2904
|
+
getPreSortedFlatRows: function getPreSortedFlatRows() {
|
|
2905
|
+
return instance.getGlobalFilteredRowModel().flatRows;
|
|
2404
2906
|
},
|
|
2405
|
-
|
|
2406
|
-
instance.
|
|
2907
|
+
getPreSortedRowsById: function getPreSortedRowsById() {
|
|
2908
|
+
return instance.getGlobalFilteredRowModel().rowsById;
|
|
2407
2909
|
},
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2910
|
+
getSortedRows: function getSortedRows() {
|
|
2911
|
+
return instance.getSortedRowModel().rows;
|
|
2912
|
+
},
|
|
2913
|
+
getSortedFlatRows: function getSortedFlatRows() {
|
|
2914
|
+
return instance.getSortedRowModel().flatRows;
|
|
2915
|
+
},
|
|
2916
|
+
getSortedRowsById: function getSortedRowsById() {
|
|
2917
|
+
return instance.getSortedRowModel().rowsById;
|
|
2918
|
+
}
|
|
2919
|
+
};
|
|
2920
|
+
}
|
|
2412
2921
|
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2922
|
+
var Sorting = /*#__PURE__*/Object.freeze({
|
|
2923
|
+
__proto__: null,
|
|
2924
|
+
getDefaultColumn: getDefaultColumn,
|
|
2925
|
+
getInitialState: getInitialState$4,
|
|
2926
|
+
getDefaultOptions: getDefaultOptions$4,
|
|
2927
|
+
createColumn: createColumn$1,
|
|
2928
|
+
getInstance: getInstance$4
|
|
2929
|
+
});
|
|
2416
2930
|
|
|
2417
|
-
|
|
2931
|
+
//
|
|
2932
|
+
function getInitialState$3() {
|
|
2933
|
+
return {
|
|
2934
|
+
expanded: {}
|
|
2935
|
+
};
|
|
2936
|
+
}
|
|
2937
|
+
function getDefaultOptions$3(instance) {
|
|
2938
|
+
return {
|
|
2939
|
+
onExpandedChange: makeStateUpdater('expanded', instance),
|
|
2940
|
+
autoResetExpanded: true,
|
|
2941
|
+
getIsRowExpanded: function getIsRowExpanded(row) {
|
|
2942
|
+
return !!(row == null ? void 0 : row.original).expanded;
|
|
2418
2943
|
},
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2944
|
+
expandSubRows: true,
|
|
2945
|
+
paginateExpandedRows: true
|
|
2946
|
+
};
|
|
2947
|
+
}
|
|
2948
|
+
function getInstance$3(instance) {
|
|
2949
|
+
var registered = false;
|
|
2950
|
+
return {
|
|
2951
|
+
_notifyExpandedReset: function _notifyExpandedReset() {
|
|
2952
|
+
if (!registered) {
|
|
2953
|
+
registered = true;
|
|
2954
|
+
return;
|
|
2955
|
+
}
|
|
2423
2956
|
|
|
2424
|
-
if (
|
|
2425
|
-
|
|
2957
|
+
if (instance.options.autoResetAll === false) {
|
|
2958
|
+
return;
|
|
2426
2959
|
}
|
|
2427
2960
|
|
|
2428
|
-
|
|
2961
|
+
if (instance.options.autoResetAll === true || instance.options.autoResetExpanded) {
|
|
2962
|
+
instance.resetExpanded();
|
|
2963
|
+
}
|
|
2429
2964
|
},
|
|
2430
|
-
|
|
2431
|
-
return instance.
|
|
2965
|
+
setExpanded: function setExpanded(updater) {
|
|
2966
|
+
return instance.options.onExpandedChange == null ? void 0 : instance.options.onExpandedChange(updater, functionalUpdate(updater, instance.getState().expanded));
|
|
2432
2967
|
},
|
|
2433
|
-
|
|
2434
|
-
|
|
2968
|
+
toggleRowExpanded: function toggleRowExpanded(rowId, expanded) {
|
|
2969
|
+
if (!rowId) return;
|
|
2970
|
+
instance.setExpanded(function (old) {
|
|
2971
|
+
var _old, _expanded;
|
|
2435
2972
|
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
},
|
|
2440
|
-
getColumnFilterIndex: function getColumnFilterIndex(columnId) {
|
|
2441
|
-
var _instance$getState$co3, _instance$getState$co4;
|
|
2973
|
+
if (old === void 0) {
|
|
2974
|
+
old = {};
|
|
2975
|
+
}
|
|
2442
2976
|
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
})) != null ? _instance$getState$co3 : -1;
|
|
2446
|
-
},
|
|
2447
|
-
setColumnFilterValue: function setColumnFilterValue(columnId, value) {
|
|
2448
|
-
if (!columnId) return;
|
|
2449
|
-
instance.setColumnFilters(function (old) {
|
|
2450
|
-
var column = instance.getColumn(columnId);
|
|
2977
|
+
var exists = old === true ? true : !!((_old = old) != null && _old[rowId]);
|
|
2978
|
+
var oldExpanded = {};
|
|
2451
2979
|
|
|
2452
|
-
if (
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
}
|
|
2980
|
+
if (old === true) {
|
|
2981
|
+
Object.keys(instance.getRowsById()).forEach(function (rowId) {
|
|
2982
|
+
oldExpanded[rowId] = true;
|
|
2983
|
+
});
|
|
2984
|
+
} else {
|
|
2985
|
+
oldExpanded = old;
|
|
2986
|
+
}
|
|
2456
2987
|
|
|
2457
|
-
|
|
2988
|
+
expanded = (_expanded = expanded) != null ? _expanded : !exists;
|
|
2989
|
+
|
|
2990
|
+
if (!exists && expanded) {
|
|
2991
|
+
var _extends2;
|
|
2992
|
+
|
|
2993
|
+
return _extends({}, oldExpanded, (_extends2 = {}, _extends2[rowId] = true, _extends2));
|
|
2458
2994
|
}
|
|
2459
2995
|
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
var newFilter = functionalUpdate(value, previousfilter ? previousfilter.value : undefined); //
|
|
2996
|
+
if (exists && !expanded) {
|
|
2997
|
+
var _oldExpanded = oldExpanded;
|
|
2998
|
+
_oldExpanded[rowId];
|
|
2999
|
+
var rest = _objectWithoutPropertiesLoose(_oldExpanded, [rowId].map(_toPropertyKey));
|
|
2465
3000
|
|
|
2466
|
-
|
|
2467
|
-
|
|
3001
|
+
return rest;
|
|
3002
|
+
}
|
|
2468
3003
|
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
3004
|
+
return old;
|
|
3005
|
+
});
|
|
3006
|
+
},
|
|
3007
|
+
toggleAllRowsExpanded: function toggleAllRowsExpanded(expanded) {
|
|
3008
|
+
if (expanded != null ? expanded : !instance.getIsAllRowsExpanded()) {
|
|
3009
|
+
instance.setExpanded(true);
|
|
3010
|
+
} else {
|
|
3011
|
+
instance.setExpanded({});
|
|
3012
|
+
}
|
|
3013
|
+
},
|
|
3014
|
+
resetExpanded: function resetExpanded() {
|
|
3015
|
+
var _instance$options$ini, _instance$options, _instance$options$ini2;
|
|
3016
|
+
|
|
3017
|
+
instance.setExpanded((_instance$options$ini = (_instance$options = instance.options) == null ? void 0 : (_instance$options$ini2 = _instance$options.initialState) == null ? void 0 : _instance$options$ini2.expanded) != null ? _instance$options$ini : {});
|
|
3018
|
+
},
|
|
3019
|
+
getIsRowExpanded: function getIsRowExpanded(rowId) {
|
|
3020
|
+
var _instance$options$get;
|
|
3021
|
+
|
|
3022
|
+
var row = instance.getRow(rowId);
|
|
3023
|
+
|
|
3024
|
+
if (!row) {
|
|
3025
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3026
|
+
console.warn("[ReactTable] getIsRowExpanded: no row found with id " + rowId);
|
|
2472
3027
|
}
|
|
2473
3028
|
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
value: newFilter
|
|
2477
|
-
};
|
|
3029
|
+
throw new Error();
|
|
3030
|
+
}
|
|
2478
3031
|
|
|
2479
|
-
|
|
2480
|
-
|
|
3032
|
+
var expanded = instance.getState().expanded;
|
|
3033
|
+
return !!((_instance$options$get = instance.options.getIsRowExpanded == null ? void 0 : instance.options.getIsRowExpanded(row)) != null ? _instance$options$get : expanded || (expanded == null ? void 0 : expanded[rowId]));
|
|
3034
|
+
},
|
|
3035
|
+
getRowCanExpand: function getRowCanExpand(rowId) {
|
|
3036
|
+
var _ref, _ref2, _instance$options$get2, _row$subRows;
|
|
2481
3037
|
|
|
2482
|
-
|
|
2483
|
-
if (d.id === columnId) {
|
|
2484
|
-
return newFilterObj;
|
|
2485
|
-
}
|
|
3038
|
+
var row = instance.getRow(rowId);
|
|
2486
3039
|
|
|
2487
|
-
|
|
2488
|
-
|
|
3040
|
+
if (!row) {
|
|
3041
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3042
|
+
console.warn("[ReactTable] getRowCanExpand: no row found with id " + rowId);
|
|
2489
3043
|
}
|
|
2490
3044
|
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
}
|
|
3045
|
+
throw new Error();
|
|
3046
|
+
}
|
|
2494
3047
|
|
|
2495
|
-
|
|
2496
|
-
});
|
|
3048
|
+
return (_ref = (_ref2 = (_instance$options$get2 = instance.options.getRowCanExpand == null ? void 0 : instance.options.getRowCanExpand(row)) != null ? _instance$options$get2 : instance.options.enableExpanded) != null ? _ref2 : instance.options.defaultCanExpand) != null ? _ref : !!((_row$subRows = row.subRows) != null && _row$subRows.length);
|
|
2497
3049
|
},
|
|
2498
|
-
|
|
2499
|
-
var
|
|
3050
|
+
getToggleExpandedProps: function getToggleExpandedProps(rowId, userProps) {
|
|
3051
|
+
var row = instance.getRow(rowId);
|
|
2500
3052
|
|
|
2501
|
-
|
|
3053
|
+
if (!row) {
|
|
3054
|
+
return;
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3057
|
+
var canExpand = instance.getRowCanExpand(rowId);
|
|
3058
|
+
var initialProps = {
|
|
3059
|
+
title: canExpand ? 'Toggle Expanded' : undefined,
|
|
3060
|
+
onClick: canExpand ? function (e) {
|
|
3061
|
+
e.persist();
|
|
3062
|
+
instance.toggleRowExpanded(rowId);
|
|
3063
|
+
} : undefined
|
|
3064
|
+
};
|
|
3065
|
+
return propGetter(initialProps, userProps);
|
|
2502
3066
|
},
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
3067
|
+
getToggleAllRowsExpandedProps: function getToggleAllRowsExpandedProps(userProps) {
|
|
3068
|
+
var initialProps = {
|
|
3069
|
+
title: 'Toggle All Expanded',
|
|
3070
|
+
onClick: function onClick(e) {
|
|
3071
|
+
e.persist();
|
|
3072
|
+
instance.toggleAllRowsExpanded();
|
|
2509
3073
|
}
|
|
3074
|
+
};
|
|
3075
|
+
return propGetter(initialProps, userProps);
|
|
3076
|
+
},
|
|
3077
|
+
getIsAllRowsExpanded: function getIsAllRowsExpanded() {
|
|
3078
|
+
var expanded = instance.getState().expanded; // If expanded is true, save some cycles and return true
|
|
2510
3079
|
|
|
2511
|
-
|
|
2512
|
-
return
|
|
2513
|
-
}
|
|
2514
|
-
// lets assign the final filtered rows to all of the other columns
|
|
3080
|
+
if (expanded === true) {
|
|
3081
|
+
return true;
|
|
3082
|
+
} // If any row is not expanded, return false
|
|
2515
3083
|
|
|
2516
3084
|
|
|
2517
|
-
|
|
2518
|
-
|
|
3085
|
+
if (Object.keys(instance.getRowsById()).some(function (id) {
|
|
3086
|
+
return !instance.getIsRowExpanded(id);
|
|
3087
|
+
})) {
|
|
3088
|
+
return false;
|
|
3089
|
+
} // They must all be expanded :shrug:
|
|
2519
3090
|
|
|
2520
|
-
return !((_instance$getState$co5 = instance.getState().columnFilters) != null && _instance$getState$co5.find(function (d) {
|
|
2521
|
-
return d.id === column.id;
|
|
2522
|
-
}));
|
|
2523
|
-
}); // This essentially enables faceted filter options to be built easily
|
|
2524
|
-
// using every column's preFilteredRows value
|
|
2525
3091
|
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
3092
|
+
return true;
|
|
3093
|
+
},
|
|
3094
|
+
getExpandedDepth: function getExpandedDepth() {
|
|
3095
|
+
var maxDepth = 0;
|
|
3096
|
+
var rowIds = instance.getState().expanded === true ? Object.keys(instance.getRowsById()) : Object.keys(instance.getState().expanded);
|
|
3097
|
+
rowIds.forEach(function (id) {
|
|
3098
|
+
var splitId = id.split('.');
|
|
3099
|
+
maxDepth = Math.max(maxDepth, splitId.length);
|
|
2530
3100
|
});
|
|
2531
|
-
return
|
|
2532
|
-
}, 'getColumnFilteredRowModel', instance.options.debug),
|
|
2533
|
-
getPreColumnFilteredRows: function getPreColumnFilteredRows() {
|
|
2534
|
-
return instance.getCoreRowModel().rows;
|
|
3101
|
+
return maxDepth;
|
|
2535
3102
|
},
|
|
2536
|
-
|
|
2537
|
-
return instance.
|
|
3103
|
+
getExpandedRowModel: memo(function () {
|
|
3104
|
+
return [instance.getState().expanded, instance.getGroupedRowModel(), instance.options.expandRowsFn, instance.options.paginateExpandedRows];
|
|
3105
|
+
}, function (expanded, rowModel, expandRowsFn, paginateExpandedRows) {
|
|
3106
|
+
if (!expandRowsFn || // Do not expand if rows are not included in pagination
|
|
3107
|
+
!paginateExpandedRows || !Object.keys(expanded != null ? expanded : {}).length) {
|
|
3108
|
+
return rowModel;
|
|
3109
|
+
}
|
|
3110
|
+
|
|
3111
|
+
if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Expanding...');
|
|
3112
|
+
return expandRowsFn(instance, rowModel);
|
|
3113
|
+
}, {
|
|
3114
|
+
key: 'getExpandedRowModel',
|
|
3115
|
+
debug: instance.options.debug,
|
|
3116
|
+
onChange: function onChange() {
|
|
3117
|
+
return instance._notifyPageIndexReset();
|
|
3118
|
+
}
|
|
3119
|
+
}),
|
|
3120
|
+
getPreExpandedRows: function getPreExpandedRows() {
|
|
3121
|
+
return instance.getGroupedRowModel().rows;
|
|
2538
3122
|
},
|
|
2539
|
-
|
|
2540
|
-
return instance.
|
|
3123
|
+
getPreExpandedFlatRows: function getPreExpandedFlatRows() {
|
|
3124
|
+
return instance.getGroupedRowModel().flatRows;
|
|
2541
3125
|
},
|
|
2542
|
-
|
|
2543
|
-
return instance.
|
|
3126
|
+
getPreExpandedRowsById: function getPreExpandedRowsById() {
|
|
3127
|
+
return instance.getGroupedRowModel().rowsById;
|
|
2544
3128
|
},
|
|
2545
|
-
|
|
2546
|
-
return instance.
|
|
3129
|
+
getExpandedRows: function getExpandedRows() {
|
|
3130
|
+
return instance.getExpandedRowModel().rows;
|
|
2547
3131
|
},
|
|
2548
|
-
|
|
2549
|
-
return instance.
|
|
3132
|
+
getExpandedFlatRows: function getExpandedFlatRows() {
|
|
3133
|
+
return instance.getExpandedRowModel().flatRows;
|
|
2550
3134
|
},
|
|
2551
|
-
|
|
2552
|
-
return
|
|
2553
|
-
}
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
3135
|
+
getExpandedRowsById: function getExpandedRowsById() {
|
|
3136
|
+
return instance.getExpandedRowModel().rowsById;
|
|
3137
|
+
}
|
|
3138
|
+
};
|
|
3139
|
+
}
|
|
3140
|
+
function createRow$1(row, instance) {
|
|
3141
|
+
return {
|
|
3142
|
+
toggleExpanded: function toggleExpanded(expanded) {
|
|
3143
|
+
return void instance.toggleRowExpanded(row.id, expanded);
|
|
3144
|
+
},
|
|
3145
|
+
getIsExpanded: function getIsExpanded() {
|
|
3146
|
+
return instance.getIsRowExpanded(row.id);
|
|
3147
|
+
},
|
|
3148
|
+
getCanExpand: function getCanExpand() {
|
|
3149
|
+
return row.subRows && !!row.subRows.length;
|
|
3150
|
+
},
|
|
3151
|
+
getToggleExpandedProps: function getToggleExpandedProps(userProps) {
|
|
3152
|
+
var initialProps = {
|
|
3153
|
+
title: 'Toggle Row Expanded',
|
|
3154
|
+
onClick: function onClick(e) {
|
|
3155
|
+
e.stopPropagation();
|
|
3156
|
+
instance.toggleRowExpanded(row.id);
|
|
2557
3157
|
}
|
|
3158
|
+
};
|
|
3159
|
+
return propGetter(initialProps, userProps);
|
|
3160
|
+
}
|
|
3161
|
+
};
|
|
3162
|
+
}
|
|
2558
3163
|
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
3164
|
+
var Expanding = /*#__PURE__*/Object.freeze({
|
|
3165
|
+
__proto__: null,
|
|
3166
|
+
getInitialState: getInitialState$3,
|
|
3167
|
+
getDefaultOptions: getDefaultOptions$3,
|
|
3168
|
+
getInstance: getInstance$3,
|
|
3169
|
+
createRow: createRow$1
|
|
3170
|
+
});
|
|
2563
3171
|
|
|
3172
|
+
//
|
|
3173
|
+
var defaultColumnSizing = {
|
|
3174
|
+
width: 150,
|
|
3175
|
+
minWidth: 20,
|
|
3176
|
+
maxWidth: Number.MAX_SAFE_INTEGER
|
|
3177
|
+
};
|
|
3178
|
+
function getInitialState$2() {
|
|
3179
|
+
return {
|
|
3180
|
+
columnSizing: {},
|
|
3181
|
+
columnSizingInfo: {
|
|
3182
|
+
startOffset: null,
|
|
3183
|
+
startSize: null,
|
|
3184
|
+
deltaOffset: null,
|
|
3185
|
+
deltaPercentage: null,
|
|
3186
|
+
isResizingColumn: false,
|
|
3187
|
+
columnSizingStart: []
|
|
3188
|
+
}
|
|
3189
|
+
};
|
|
3190
|
+
}
|
|
3191
|
+
function getDefaultOptions$2(instance) {
|
|
3192
|
+
return {
|
|
3193
|
+
columnResizeMode: 'onEnd',
|
|
3194
|
+
onColumnSizingChange: makeStateUpdater('columnSizing', instance),
|
|
3195
|
+
onColumnSizingInfoChange: makeStateUpdater('columnSizingInfo', instance)
|
|
3196
|
+
};
|
|
3197
|
+
}
|
|
3198
|
+
function getInstance$2(instance) {
|
|
3199
|
+
return {
|
|
3200
|
+
setColumnSizing: function setColumnSizing(updater) {
|
|
3201
|
+
return instance.options.onColumnSizingChange == null ? void 0 : instance.options.onColumnSizingChange(updater, functionalUpdate(updater, instance.getState().columnSizing));
|
|
3202
|
+
},
|
|
3203
|
+
setColumnSizingInfo: function setColumnSizingInfo(updater) {
|
|
3204
|
+
return instance.options.onColumnSizingInfoChange == null ? void 0 : instance.options.onColumnSizingInfoChange(updater, functionalUpdate(updater, instance.getState().columnSizingInfo));
|
|
3205
|
+
},
|
|
3206
|
+
resetColumnSizing: function resetColumnSizing() {
|
|
3207
|
+
var _instance$initialStat;
|
|
2564
3208
|
|
|
2565
|
-
|
|
2566
|
-
|
|
3209
|
+
instance.setColumnSizing((_instance$initialStat = instance.initialState.columnSizing) != null ? _instance$initialStat : {});
|
|
3210
|
+
},
|
|
3211
|
+
resetHeaderSizeInfo: function resetHeaderSizeInfo() {
|
|
3212
|
+
var _instance$initialStat2;
|
|
2567
3213
|
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
3214
|
+
instance.setColumnSizingInfo((_instance$initialStat2 = instance.initialState.columnSizingInfo) != null ? _instance$initialStat2 : {});
|
|
3215
|
+
},
|
|
3216
|
+
resetColumnSize: function resetColumnSize(columnId) {
|
|
3217
|
+
instance.setColumnSizing(function (_ref) {
|
|
3218
|
+
_ref[columnId];
|
|
3219
|
+
var rest = _objectWithoutPropertiesLoose(_ref, [columnId].map(_toPropertyKey));
|
|
2573
3220
|
|
|
2574
|
-
|
|
2575
|
-
column.getPreFilteredRows = function () {
|
|
2576
|
-
return globalFilteredRowModel.rows;
|
|
2577
|
-
};
|
|
3221
|
+
return rest;
|
|
2578
3222
|
});
|
|
2579
|
-
return globalFilteredRowModel;
|
|
2580
|
-
}, 'getGlobalFilteredRowModel', instance.options.debug),
|
|
2581
|
-
getPreGlobalFilteredRows: function getPreGlobalFilteredRows() {
|
|
2582
|
-
return instance.getColumnFilteredRowModel().rows;
|
|
2583
3223
|
},
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
return instance.
|
|
3224
|
+
resetHeaderSize: function resetHeaderSize(headerId) {
|
|
3225
|
+
var header = instance.getHeader(headerId);
|
|
3226
|
+
|
|
3227
|
+
if (!header) {
|
|
3228
|
+
return;
|
|
3229
|
+
}
|
|
3230
|
+
|
|
3231
|
+
return instance.resetColumnSize(header.column.id);
|
|
2592
3232
|
},
|
|
2593
|
-
|
|
2594
|
-
|
|
3233
|
+
getHeaderCanResize: function getHeaderCanResize(headerId) {
|
|
3234
|
+
var header = instance.getHeader(headerId);
|
|
3235
|
+
|
|
3236
|
+
if (!header) {
|
|
3237
|
+
throw new Error();
|
|
3238
|
+
}
|
|
3239
|
+
|
|
3240
|
+
return instance.getColumnCanResize(header.column.id);
|
|
2595
3241
|
},
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
}
|
|
2599
|
-
};
|
|
2600
|
-
}
|
|
2601
|
-
function shouldAutoRemoveFilter(filterFn, value, column) {
|
|
2602
|
-
return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
|
|
2603
|
-
}
|
|
3242
|
+
getColumnCanResize: function getColumnCanResize(columnId) {
|
|
3243
|
+
var _ref2, _ref3, _column$enableResizin;
|
|
2604
3244
|
|
|
2605
|
-
var
|
|
2606
|
-
var sortTypes = {
|
|
2607
|
-
alphanumeric: alphanumeric,
|
|
2608
|
-
alphanumericCaseSensitive: alphanumericCaseSensitive,
|
|
2609
|
-
text: text,
|
|
2610
|
-
textCaseSensitive: textCaseSensitive,
|
|
2611
|
-
datetime: datetime,
|
|
2612
|
-
basic: basic
|
|
2613
|
-
};
|
|
3245
|
+
var column = instance.getColumn(columnId);
|
|
2614
3246
|
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
}
|
|
3247
|
+
if (!column) {
|
|
3248
|
+
throw new Error();
|
|
3249
|
+
}
|
|
2618
3250
|
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
// null, undefined, and Infinity
|
|
3251
|
+
return (_ref2 = (_ref3 = (_column$enableResizin = column.enableResizing) != null ? _column$enableResizin : instance.options.enableColumnResizing) != null ? _ref3 : column.defaultCanResize) != null ? _ref2 : true;
|
|
3252
|
+
},
|
|
3253
|
+
getColumnIsResizing: function getColumnIsResizing(columnId) {
|
|
3254
|
+
var column = instance.getColumn(columnId);
|
|
2624
3255
|
|
|
3256
|
+
if (!column) {
|
|
3257
|
+
throw new Error();
|
|
3258
|
+
}
|
|
2625
3259
|
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
var b = bStr.split(reSplitAlphaNumeric).filter(Boolean); // While
|
|
3260
|
+
return instance.getState().columnSizingInfo.isResizingColumn === columnId;
|
|
3261
|
+
},
|
|
3262
|
+
getHeaderIsResizing: function getHeaderIsResizing(headerId) {
|
|
3263
|
+
var header = instance.getHeader(headerId);
|
|
2631
3264
|
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
var an = parseInt(aa, 10);
|
|
2636
|
-
var bn = parseInt(bb, 10);
|
|
2637
|
-
var combo = [an, bn].sort(); // Both are string
|
|
3265
|
+
if (!header) {
|
|
3266
|
+
throw new Error();
|
|
3267
|
+
}
|
|
2638
3268
|
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
3269
|
+
return instance.getColumnIsResizing(header.column.id);
|
|
3270
|
+
},
|
|
3271
|
+
getColumnResizerProps: function getColumnResizerProps(headerId, userProps) {
|
|
3272
|
+
var header = instance.getHeader(headerId);
|
|
3273
|
+
|
|
3274
|
+
if (!header) {
|
|
3275
|
+
return;
|
|
2642
3276
|
}
|
|
2643
3277
|
|
|
2644
|
-
|
|
2645
|
-
|
|
3278
|
+
var column = instance.getColumn(header.column.id);
|
|
3279
|
+
|
|
3280
|
+
if (!column) {
|
|
3281
|
+
return;
|
|
2646
3282
|
}
|
|
2647
3283
|
|
|
2648
|
-
|
|
2649
|
-
} // One is a string, one is a number
|
|
3284
|
+
var canResize = column.getCanResize();
|
|
2650
3285
|
|
|
3286
|
+
var onResizeStart = function onResizeStart(e) {
|
|
3287
|
+
if (isTouchStartEvent(e)) {
|
|
3288
|
+
// lets not respond to multiple touches (e.g. 2 or 3 fingers)
|
|
3289
|
+
if (e.touches && e.touches.length > 1) {
|
|
3290
|
+
return;
|
|
3291
|
+
}
|
|
3292
|
+
}
|
|
2651
3293
|
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
3294
|
+
var columnSizingStart = header.getLeafHeaders().map(function (d) {
|
|
3295
|
+
return [d.column.id, d.getWidth()];
|
|
3296
|
+
});
|
|
3297
|
+
var clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
|
|
2655
3298
|
|
|
3299
|
+
var updateOffset = function updateOffset(eventType, clientXPos) {
|
|
3300
|
+
if (typeof clientXPos !== 'number') {
|
|
3301
|
+
return;
|
|
3302
|
+
}
|
|
2656
3303
|
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
3304
|
+
var newColumnSizing = {};
|
|
3305
|
+
instance.setColumnSizingInfo(function (old) {
|
|
3306
|
+
var _old$startOffset, _old$startSize;
|
|
2660
3307
|
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
3308
|
+
var deltaOffset = clientXPos - ((_old$startOffset = old == null ? void 0 : old.startOffset) != null ? _old$startOffset : 0);
|
|
3309
|
+
var deltaPercentage = Math.max(deltaOffset / ((_old$startSize = old == null ? void 0 : old.startSize) != null ? _old$startSize : 0), -0.999999);
|
|
3310
|
+
old.columnSizingStart.forEach(function (_ref4) {
|
|
3311
|
+
var columnId = _ref4[0],
|
|
3312
|
+
headerWidth = _ref4[1];
|
|
3313
|
+
newColumnSizing[columnId] = Math.max(headerWidth + headerWidth * deltaPercentage, 0);
|
|
3314
|
+
});
|
|
3315
|
+
return _extends({}, old, {
|
|
3316
|
+
deltaOffset: deltaOffset,
|
|
3317
|
+
deltaPercentage: deltaPercentage
|
|
3318
|
+
});
|
|
3319
|
+
});
|
|
2665
3320
|
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
3321
|
+
if (instance.options.columnResizeMode === 'onChange' || eventType === 'end') {
|
|
3322
|
+
instance.setColumnSizing(function (old) {
|
|
3323
|
+
return _extends({}, old, newColumnSizing);
|
|
3324
|
+
});
|
|
3325
|
+
}
|
|
3326
|
+
};
|
|
3327
|
+
|
|
3328
|
+
var onMove = function onMove(clientXPos) {
|
|
3329
|
+
return updateOffset('move', clientXPos);
|
|
3330
|
+
};
|
|
2669
3331
|
|
|
3332
|
+
var onEnd = function onEnd(clientXPos) {
|
|
3333
|
+
updateOffset('end', clientXPos);
|
|
3334
|
+
instance.setColumnSizingInfo(function (old) {
|
|
3335
|
+
return _extends({}, old, {
|
|
3336
|
+
isResizingColumn: false,
|
|
3337
|
+
startOffset: null,
|
|
3338
|
+
startSize: null,
|
|
3339
|
+
deltaOffset: null,
|
|
3340
|
+
deltaPercentage: null,
|
|
3341
|
+
columnSizingStart: []
|
|
3342
|
+
});
|
|
3343
|
+
});
|
|
3344
|
+
};
|
|
2670
3345
|
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
3346
|
+
var mouseEvents = {
|
|
3347
|
+
moveHandler: function moveHandler(e) {
|
|
3348
|
+
return onMove(e.clientX);
|
|
3349
|
+
},
|
|
3350
|
+
upHandler: function upHandler(e) {
|
|
3351
|
+
document.removeEventListener('mousemove', mouseEvents.moveHandler);
|
|
3352
|
+
document.removeEventListener('mouseup', mouseEvents.upHandler);
|
|
3353
|
+
onEnd(e.clientX);
|
|
3354
|
+
}
|
|
3355
|
+
};
|
|
3356
|
+
var touchEvents = {
|
|
3357
|
+
moveHandler: function moveHandler(e) {
|
|
3358
|
+
if (e.cancelable) {
|
|
3359
|
+
e.preventDefault();
|
|
3360
|
+
e.stopPropagation();
|
|
3361
|
+
}
|
|
2675
3362
|
|
|
3363
|
+
onMove(e.touches[0].clientX);
|
|
3364
|
+
return false;
|
|
3365
|
+
},
|
|
3366
|
+
upHandler: function upHandler(e) {
|
|
3367
|
+
document.removeEventListener('touchmove', touchEvents.moveHandler);
|
|
3368
|
+
document.removeEventListener('touchend', touchEvents.upHandler);
|
|
2676
3369
|
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
3370
|
+
if (e.cancelable) {
|
|
3371
|
+
e.preventDefault();
|
|
3372
|
+
e.stopPropagation();
|
|
3373
|
+
}
|
|
2680
3374
|
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
}
|
|
3375
|
+
onEnd(e.touches[0].clientX);
|
|
3376
|
+
}
|
|
3377
|
+
};
|
|
3378
|
+
var passiveIfSupported = passiveEventSupported() ? {
|
|
3379
|
+
passive: false
|
|
3380
|
+
} : false;
|
|
2684
3381
|
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
3382
|
+
if (isTouchStartEvent(e)) {
|
|
3383
|
+
document.addEventListener('touchmove', touchEvents.moveHandler, passiveIfSupported);
|
|
3384
|
+
document.addEventListener('touchend', touchEvents.upHandler, passiveIfSupported);
|
|
3385
|
+
} else {
|
|
3386
|
+
document.addEventListener('mousemove', mouseEvents.moveHandler, passiveIfSupported);
|
|
3387
|
+
document.addEventListener('mouseup', mouseEvents.upHandler, passiveIfSupported);
|
|
3388
|
+
}
|
|
2688
3389
|
|
|
3390
|
+
instance.setColumnSizingInfo(function (old) {
|
|
3391
|
+
return _extends({}, old, {
|
|
3392
|
+
startOffset: clientX,
|
|
3393
|
+
startSize: header.getWidth(),
|
|
3394
|
+
deltaOffset: 0,
|
|
3395
|
+
deltaPercentage: 0,
|
|
3396
|
+
columnSizingStart: columnSizingStart,
|
|
3397
|
+
isResizingColumn: header.column.id
|
|
3398
|
+
});
|
|
3399
|
+
});
|
|
3400
|
+
};
|
|
2689
3401
|
|
|
2690
|
-
|
|
2691
|
-
|
|
3402
|
+
var initialProps = canResize ? {
|
|
3403
|
+
title: 'Toggle Grouping',
|
|
3404
|
+
draggable: false,
|
|
3405
|
+
role: 'separator',
|
|
3406
|
+
onMouseDown: function onMouseDown(e) {
|
|
3407
|
+
e.persist();
|
|
3408
|
+
onResizeStart(e);
|
|
3409
|
+
},
|
|
3410
|
+
onTouchStart: function onTouchStart(e) {
|
|
3411
|
+
e.persist();
|
|
3412
|
+
onResizeStart(e);
|
|
3413
|
+
}
|
|
3414
|
+
} : {};
|
|
3415
|
+
return propGetter(initialProps, userProps);
|
|
3416
|
+
}
|
|
3417
|
+
};
|
|
2692
3418
|
}
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
3419
|
+
function createColumn(column, instance) {
|
|
3420
|
+
return {
|
|
3421
|
+
getIsResizing: function getIsResizing() {
|
|
3422
|
+
return instance.getColumnIsResizing(column.id);
|
|
3423
|
+
},
|
|
3424
|
+
getCanResize: function getCanResize() {
|
|
3425
|
+
return instance.getColumnCanResize(column.id);
|
|
3426
|
+
},
|
|
3427
|
+
resetSize: function resetSize() {
|
|
3428
|
+
return instance.resetColumnSize(column.id);
|
|
3429
|
+
},
|
|
3430
|
+
getResizerProps: function getResizerProps(userProps) {
|
|
3431
|
+
return instance.getColumnResizerProps(column.id, userProps);
|
|
2698
3432
|
}
|
|
3433
|
+
};
|
|
3434
|
+
}
|
|
3435
|
+
var passiveSupported = null;
|
|
3436
|
+
function passiveEventSupported() {
|
|
3437
|
+
if (typeof passiveSupported === 'boolean') return passiveSupported;
|
|
3438
|
+
var supported = false;
|
|
3439
|
+
|
|
3440
|
+
try {
|
|
3441
|
+
var options = {
|
|
3442
|
+
get passive() {
|
|
3443
|
+
supported = true;
|
|
3444
|
+
return false;
|
|
3445
|
+
}
|
|
3446
|
+
|
|
3447
|
+
};
|
|
3448
|
+
|
|
3449
|
+
var noop = function noop() {};
|
|
2699
3450
|
|
|
2700
|
-
|
|
3451
|
+
window.addEventListener('test', noop, options);
|
|
3452
|
+
window.removeEventListener('test', noop);
|
|
3453
|
+
} catch (err) {
|
|
3454
|
+
supported = false;
|
|
2701
3455
|
}
|
|
2702
3456
|
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
3457
|
+
passiveSupported = supported;
|
|
3458
|
+
return passiveSupported;
|
|
3459
|
+
}
|
|
2706
3460
|
|
|
2707
|
-
|
|
3461
|
+
function isTouchStartEvent(e) {
|
|
3462
|
+
return e.type === 'touchstart';
|
|
2708
3463
|
}
|
|
2709
3464
|
|
|
3465
|
+
var ColumnSizing = /*#__PURE__*/Object.freeze({
|
|
3466
|
+
__proto__: null,
|
|
3467
|
+
defaultColumnSizing: defaultColumnSizing,
|
|
3468
|
+
getInitialState: getInitialState$2,
|
|
3469
|
+
getDefaultOptions: getDefaultOptions$2,
|
|
3470
|
+
getInstance: getInstance$2,
|
|
3471
|
+
createColumn: createColumn,
|
|
3472
|
+
passiveEventSupported: passiveEventSupported
|
|
3473
|
+
});
|
|
3474
|
+
|
|
2710
3475
|
//
|
|
2711
|
-
function getDefaultColumn() {
|
|
2712
|
-
return {
|
|
2713
|
-
sortType: 'auto'
|
|
2714
|
-
};
|
|
2715
|
-
}
|
|
2716
3476
|
function getInitialState$1() {
|
|
2717
3477
|
return {
|
|
2718
|
-
|
|
3478
|
+
pagination: {
|
|
3479
|
+
pageIndex: 0,
|
|
3480
|
+
pageSize: 10
|
|
3481
|
+
}
|
|
2719
3482
|
};
|
|
2720
3483
|
}
|
|
2721
3484
|
function getDefaultOptions$1(instance) {
|
|
2722
3485
|
return {
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
};
|
|
2726
|
-
}
|
|
2727
|
-
function createColumn(column, instance) {
|
|
2728
|
-
return {
|
|
2729
|
-
sortType: column.sortType,
|
|
2730
|
-
getCanSort: function getCanSort() {
|
|
2731
|
-
return instance.getColumnCanSort(column.id);
|
|
2732
|
-
},
|
|
2733
|
-
getCanMultiSort: function getCanMultiSort() {
|
|
2734
|
-
return instance.getColumnCanMultiSort(column.id);
|
|
2735
|
-
},
|
|
2736
|
-
getSortIndex: function getSortIndex() {
|
|
2737
|
-
return instance.getColumnSortIndex(column.id);
|
|
2738
|
-
},
|
|
2739
|
-
getIsSorted: function getIsSorted() {
|
|
2740
|
-
return instance.getColumnIsSorted(column.id);
|
|
2741
|
-
},
|
|
2742
|
-
toggleSorting: function toggleSorting(desc, isMulti) {
|
|
2743
|
-
return instance.toggleColumnSorting(column.id, desc, isMulti);
|
|
2744
|
-
},
|
|
2745
|
-
getToggleSortingProps: function getToggleSortingProps(userProps) {
|
|
2746
|
-
return instance.getToggleSortingProps(column.id, userProps);
|
|
2747
|
-
}
|
|
3486
|
+
onPaginationChange: makeStateUpdater('pagination', instance),
|
|
3487
|
+
autoResetPageIndex: true
|
|
2748
3488
|
};
|
|
2749
3489
|
}
|
|
2750
3490
|
function getInstance$1(instance) {
|
|
3491
|
+
var registered = false;
|
|
2751
3492
|
return {
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
if (typeof value === 'string') {
|
|
2757
|
-
return sortTypes.alphanumeric;
|
|
3493
|
+
_notifyPageIndexReset: function _notifyPageIndexReset() {
|
|
3494
|
+
if (!registered) {
|
|
3495
|
+
registered = true;
|
|
3496
|
+
return;
|
|
2758
3497
|
}
|
|
2759
3498
|
|
|
2760
|
-
if (
|
|
2761
|
-
return
|
|
3499
|
+
if (instance.options.autoResetAll === false) {
|
|
3500
|
+
return;
|
|
2762
3501
|
}
|
|
2763
3502
|
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
getColumnSortingFn: function getColumnSortingFn(columnId) {
|
|
2767
|
-
var _ref;
|
|
2768
|
-
|
|
2769
|
-
var column = instance.getColumn(columnId);
|
|
2770
|
-
var userSortTypes = instance.options.sortTypes;
|
|
2771
|
-
|
|
2772
|
-
if (!column) {
|
|
2773
|
-
throw new Error();
|
|
3503
|
+
if (instance.options.autoResetAll === true || instance.options.autoResetPageIndex) {
|
|
3504
|
+
instance.resetPageSize();
|
|
2774
3505
|
}
|
|
2775
|
-
|
|
2776
|
-
return isFunction(column.sortType) ? column.sortType : column.sortType === 'auto' ? instance.getColumnAutoFilterFn(columnId) : (_ref = userSortTypes == null ? void 0 : userSortTypes[column.sortType]) != null ? _ref : sortTypes[column.sortType];
|
|
2777
|
-
},
|
|
2778
|
-
setSorting: function setSorting(updater) {
|
|
2779
|
-
return instance.options.onSortingChange == null ? void 0 : instance.options.onSortingChange(updater, functionalUpdate(updater, instance.getState().sorting));
|
|
2780
3506
|
},
|
|
2781
|
-
|
|
2782
|
-
var
|
|
2783
|
-
|
|
2784
|
-
if (!column) {
|
|
2785
|
-
throw new Error();
|
|
2786
|
-
}
|
|
2787
|
-
|
|
2788
|
-
instance.setSorting(function (old) {
|
|
2789
|
-
var _column$sortDescFirst, _instance$options$ena, _instance$options$ena2;
|
|
2790
|
-
|
|
2791
|
-
// Find any existing sorting for this column
|
|
2792
|
-
var existingSorting = old == null ? void 0 : old.find(function (d) {
|
|
2793
|
-
return d.id === columnId;
|
|
2794
|
-
});
|
|
2795
|
-
var existingIndex = old == null ? void 0 : old.findIndex(function (d) {
|
|
2796
|
-
return d.id === columnId;
|
|
2797
|
-
});
|
|
2798
|
-
var hasDescDefined = typeof desc !== 'undefined' && desc !== null;
|
|
2799
|
-
var newSorting = []; // What should we do with this sort action?
|
|
3507
|
+
setPagination: function setPagination(updater) {
|
|
3508
|
+
var safeUpdater = function safeUpdater(old) {
|
|
3509
|
+
var newState = functionalUpdate(updater, old);
|
|
2800
3510
|
|
|
2801
|
-
|
|
3511
|
+
if (instance.options.paginateRowsFn) {
|
|
3512
|
+
var _instance$getPrePagin;
|
|
2802
3513
|
|
|
2803
|
-
|
|
2804
|
-
if (existingSorting) {
|
|
2805
|
-
sortAction = 'toggle';
|
|
2806
|
-
} else {
|
|
2807
|
-
sortAction = 'add';
|
|
2808
|
-
}
|
|
2809
|
-
} else {
|
|
2810
|
-
// Normal mode
|
|
2811
|
-
if (old != null && old.length && existingIndex !== old.length - 1) {
|
|
2812
|
-
sortAction = 'replace';
|
|
2813
|
-
} else if (existingSorting) {
|
|
2814
|
-
sortAction = 'toggle';
|
|
2815
|
-
} else {
|
|
2816
|
-
sortAction = 'replace';
|
|
2817
|
-
}
|
|
3514
|
+
newState.pageCount = (_instance$getPrePagin = instance.getPrePaginationRows()) != null && _instance$getPrePagin.length ? Math.ceil(instance.getPrePaginationRows().length / instance.getState().pagination.pageSize) : 0;
|
|
2818
3515
|
}
|
|
2819
3516
|
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
if (sortAction === 'toggle' && ( // Must be toggling
|
|
2823
|
-
(_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
|
|
2824
|
-
!hasDescDefined && ( // Must not be setting desc
|
|
2825
|
-
multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && ( // If multi, don't allow if enableMultiRemove
|
|
2826
|
-
existingSorting != null && existingSorting.desc // Finally, detect if it should indeed be removed
|
|
2827
|
-
? !sortDescFirst : sortDescFirst)) {
|
|
2828
|
-
sortAction = 'remove';
|
|
2829
|
-
}
|
|
3517
|
+
return newState;
|
|
3518
|
+
};
|
|
2830
3519
|
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
}];
|
|
2836
|
-
} else if (sortAction === 'add' && old != null && old.length) {
|
|
2837
|
-
var _instance$options$max;
|
|
3520
|
+
return instance.options.onPaginationChange == null ? void 0 : instance.options.onPaginationChange(safeUpdater, functionalUpdate(safeUpdater, instance.getState().pagination));
|
|
3521
|
+
},
|
|
3522
|
+
resetPagination: function resetPagination() {
|
|
3523
|
+
var _instance$initialStat;
|
|
2838
3524
|
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
3525
|
+
instance.setPagination((_instance$initialStat = instance.initialState.pagination) != null ? _instance$initialStat : {
|
|
3526
|
+
pageIndex: 0,
|
|
3527
|
+
pageSize: 10,
|
|
3528
|
+
pageCount: -1
|
|
3529
|
+
});
|
|
3530
|
+
},
|
|
3531
|
+
setPageIndex: function setPageIndex(updater) {
|
|
3532
|
+
instance.setPagination(function (old) {
|
|
3533
|
+
var pageIndex = functionalUpdate(updater, old.pageIndex);
|
|
3534
|
+
var maxPageIndex = old.pageCount && old.pageCount > 0 ? old.pageCount - 1 : Number.MAX_SAFE_INTEGER;
|
|
3535
|
+
pageIndex = Math.min(Math.max(0, pageIndex), maxPageIndex);
|
|
3536
|
+
return _extends({}, old, {
|
|
3537
|
+
pageIndex: pageIndex
|
|
3538
|
+
});
|
|
3539
|
+
});
|
|
3540
|
+
},
|
|
3541
|
+
resetPageIndex: function resetPageIndex() {
|
|
3542
|
+
instance.setPageIndex(0);
|
|
3543
|
+
},
|
|
3544
|
+
resetPageSize: function resetPageSize() {
|
|
3545
|
+
var _instance$options$ini, _instance$options$ini2, _instance$options$ini3;
|
|
2843
3546
|
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
3547
|
+
instance.setPageSize((_instance$options$ini = (_instance$options$ini2 = instance.options.initialState) == null ? void 0 : (_instance$options$ini3 = _instance$options$ini2.pagination) == null ? void 0 : _instance$options$ini3.pageSize) != null ? _instance$options$ini : 10);
|
|
3548
|
+
},
|
|
3549
|
+
setPageSize: function setPageSize(updater) {
|
|
3550
|
+
instance.setPagination(function (old) {
|
|
3551
|
+
var pageSize = Math.max(1, functionalUpdate(updater, old.pageSize));
|
|
3552
|
+
var topRowIndex = old.pageSize * old.pageIndex;
|
|
3553
|
+
var pageIndex = Math.floor(topRowIndex / pageSize);
|
|
3554
|
+
return _extends({}, old, {
|
|
3555
|
+
pageIndex: pageIndex,
|
|
3556
|
+
pageSize: pageSize
|
|
3557
|
+
});
|
|
3558
|
+
});
|
|
3559
|
+
},
|
|
3560
|
+
setPageCount: function setPageCount(updater) {
|
|
3561
|
+
return instance.setPagination(function (old) {
|
|
3562
|
+
var newPageCount = functionalUpdate(updater, old.pageCount);
|
|
2853
3563
|
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
} else if (sortAction === 'remove' && old != null && old.length) {
|
|
2857
|
-
newSorting = old.filter(function (d) {
|
|
2858
|
-
return d.id !== columnId;
|
|
2859
|
-
});
|
|
3564
|
+
if (typeof newPageCount === 'number') {
|
|
3565
|
+
newPageCount = Math.max(-1, newPageCount);
|
|
2860
3566
|
}
|
|
2861
3567
|
|
|
2862
|
-
return
|
|
3568
|
+
return _extends({}, old, {
|
|
3569
|
+
pageCount: newPageCount
|
|
3570
|
+
});
|
|
2863
3571
|
});
|
|
2864
3572
|
},
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
var
|
|
3573
|
+
getPageOptions: memo(function () {
|
|
3574
|
+
return [instance.getState().pagination.pageSize, instance.getState().pagination.pageCount];
|
|
3575
|
+
}, function (pageSize, pageCount) {
|
|
3576
|
+
var pageOptions = [];
|
|
2869
3577
|
|
|
2870
|
-
if (
|
|
2871
|
-
|
|
3578
|
+
if (pageCount && pageCount > 0) {
|
|
3579
|
+
pageOptions = [].concat(new Array(pageCount)).fill(null).map(function (_, i) {
|
|
3580
|
+
return i;
|
|
3581
|
+
});
|
|
2872
3582
|
}
|
|
2873
3583
|
|
|
2874
|
-
return
|
|
2875
|
-
},
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
3584
|
+
return pageOptions;
|
|
3585
|
+
}, {
|
|
3586
|
+
key: 'getPageOptions',
|
|
3587
|
+
debug: instance.options.debug
|
|
3588
|
+
}),
|
|
3589
|
+
getCanPreviousPage: function getCanPreviousPage() {
|
|
3590
|
+
return instance.getState().pagination.pageIndex > 0;
|
|
3591
|
+
},
|
|
3592
|
+
getCanNextPage: function getCanNextPage() {
|
|
3593
|
+
var _instance$getState$pa = instance.getState().pagination,
|
|
3594
|
+
pageIndex = _instance$getState$pa.pageIndex,
|
|
3595
|
+
pageCount = _instance$getState$pa.pageCount,
|
|
3596
|
+
pageSize = _instance$getState$pa.pageSize;
|
|
3597
|
+
|
|
3598
|
+
if (pageCount === -1) {
|
|
3599
|
+
return true;
|
|
3600
|
+
}
|
|
2880
3601
|
|
|
2881
|
-
if (
|
|
2882
|
-
|
|
3602
|
+
if (pageCount === 0) {
|
|
3603
|
+
return false;
|
|
2883
3604
|
}
|
|
2884
3605
|
|
|
2885
|
-
return
|
|
3606
|
+
return pageIndex < Math.ceil(instance.getPrePaginationRows().length / pageSize) - 1;
|
|
2886
3607
|
},
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
var columnSort = (_instance$getState$so = instance.getState().sorting) == null ? void 0 : _instance$getState$so.find(function (d) {
|
|
2891
|
-
return d.id === columnId;
|
|
3608
|
+
previousPage: function previousPage() {
|
|
3609
|
+
return instance.setPageIndex(function (old) {
|
|
3610
|
+
return old - 1;
|
|
2892
3611
|
});
|
|
2893
|
-
return !columnSort ? false : columnSort.desc ? 'desc' : 'asc';
|
|
2894
|
-
},
|
|
2895
|
-
getColumnSortIndex: function getColumnSortIndex(columnId) {
|
|
2896
|
-
var _instance$getState$so2, _instance$getState$so3;
|
|
2897
|
-
|
|
2898
|
-
return (_instance$getState$so2 = (_instance$getState$so3 = instance.getState().sorting) == null ? void 0 : _instance$getState$so3.findIndex(function (d) {
|
|
2899
|
-
return d.id === columnId;
|
|
2900
|
-
})) != null ? _instance$getState$so2 : -1;
|
|
2901
|
-
},
|
|
2902
|
-
resetSorting: function resetSorting() {
|
|
2903
|
-
var _instance$options$ini, _instance$options, _instance$options$ini2;
|
|
2904
|
-
|
|
2905
|
-
instance.setSorting((_instance$options$ini = (_instance$options = instance.options) == null ? void 0 : (_instance$options$ini2 = _instance$options.initialState) == null ? void 0 : _instance$options$ini2.sorting) != null ? _instance$options$ini : []);
|
|
2906
3612
|
},
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
throw new Error();
|
|
2912
|
-
}
|
|
2913
|
-
|
|
2914
|
-
var canSort = column.getCanSort();
|
|
2915
|
-
var initialProps = {
|
|
2916
|
-
title: canSort ? 'Toggle Sorting' : undefined,
|
|
2917
|
-
onClick: canSort ? function (e) {
|
|
2918
|
-
e.persist();
|
|
2919
|
-
column.toggleSorting == null ? void 0 : column.toggleSorting(undefined, column.getCanMultiSort() ? instance.options.isMultiSortEvent == null ? void 0 : instance.options.isMultiSortEvent(e) : false);
|
|
2920
|
-
} : undefined
|
|
2921
|
-
};
|
|
2922
|
-
return propGetter(initialProps, userProps);
|
|
3613
|
+
nextPage: function nextPage() {
|
|
3614
|
+
return instance.setPageIndex(function (old) {
|
|
3615
|
+
return old + 1;
|
|
3616
|
+
});
|
|
2923
3617
|
},
|
|
2924
|
-
|
|
2925
|
-
return [instance.getState().
|
|
2926
|
-
}, function (
|
|
2927
|
-
if (!
|
|
3618
|
+
getPaginationRowModel: memo(function () {
|
|
3619
|
+
return [instance.getState().pagination, instance.getExpandedRowModel(), instance.options.paginateRowsFn];
|
|
3620
|
+
}, function (_pagination, rowModel, paginateRowsFn) {
|
|
3621
|
+
if (!paginateRowsFn || !rowModel.rows.length) {
|
|
2928
3622
|
return rowModel;
|
|
2929
3623
|
}
|
|
2930
3624
|
|
|
2931
|
-
if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('
|
|
2932
|
-
return
|
|
2933
|
-
},
|
|
2934
|
-
|
|
2935
|
-
|
|
3625
|
+
if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Paginating...');
|
|
3626
|
+
return paginateRowsFn(instance, rowModel);
|
|
3627
|
+
}, {
|
|
3628
|
+
key: 'getPaginationRowModel',
|
|
3629
|
+
debug: instance.options.debug
|
|
3630
|
+
}),
|
|
3631
|
+
getPrePaginationRows: function getPrePaginationRows() {
|
|
3632
|
+
return instance.getExpandedRowModel().rows;
|
|
2936
3633
|
},
|
|
2937
|
-
|
|
2938
|
-
return instance.
|
|
3634
|
+
getPrePaginationFlatRows: function getPrePaginationFlatRows() {
|
|
3635
|
+
return instance.getExpandedRowModel().flatRows;
|
|
2939
3636
|
},
|
|
2940
|
-
|
|
2941
|
-
return instance.
|
|
3637
|
+
getPrePaginationRowsById: function getPrePaginationRowsById() {
|
|
3638
|
+
return instance.getExpandedRowModel().rowsById;
|
|
2942
3639
|
},
|
|
2943
|
-
|
|
2944
|
-
return instance.
|
|
3640
|
+
getPaginationRows: function getPaginationRows() {
|
|
3641
|
+
return instance.getPaginationRowModel().rows;
|
|
2945
3642
|
},
|
|
2946
|
-
|
|
2947
|
-
return instance.
|
|
3643
|
+
getPaginationFlatRows: function getPaginationFlatRows() {
|
|
3644
|
+
return instance.getPaginationRowModel().flatRows;
|
|
2948
3645
|
},
|
|
2949
|
-
|
|
2950
|
-
return instance.
|
|
3646
|
+
getPaginationRowsById: function getPaginationRowsById() {
|
|
3647
|
+
return instance.getPaginationRowModel().rowsById;
|
|
2951
3648
|
}
|
|
2952
3649
|
};
|
|
2953
3650
|
}
|
|
2954
3651
|
|
|
3652
|
+
var Pagination = /*#__PURE__*/Object.freeze({
|
|
3653
|
+
__proto__: null,
|
|
3654
|
+
getInitialState: getInitialState$1,
|
|
3655
|
+
getDefaultOptions: getDefaultOptions$1,
|
|
3656
|
+
getInstance: getInstance$1
|
|
3657
|
+
});
|
|
3658
|
+
|
|
2955
3659
|
//
|
|
2956
3660
|
function getInitialState() {
|
|
2957
3661
|
return {
|
|
2958
|
-
|
|
3662
|
+
rowSelection: {}
|
|
2959
3663
|
};
|
|
2960
3664
|
}
|
|
2961
3665
|
function getDefaultOptions(instance) {
|
|
2962
3666
|
return {
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
3667
|
+
onRowSelectionChange: makeStateUpdater('rowSelection', instance),
|
|
3668
|
+
autoResetRowSelection: true,
|
|
3669
|
+
enableRowSelection: true,
|
|
3670
|
+
enableMultiRowSelection: true,
|
|
3671
|
+
enableSubRowSelection: true // enableGroupingRowSelection: false,
|
|
3672
|
+
// isAdditiveSelectEvent: (e: MouseEvent | TouchEvent) => !!e.metaKey,
|
|
3673
|
+
// isInclusiveSelectEvent: (e: MouseEvent | TouchEvent) => !!e.shiftKey,
|
|
3674
|
+
|
|
2970
3675
|
};
|
|
2971
3676
|
}
|
|
2972
3677
|
function getInstance(instance) {
|
|
3678
|
+
var registered = false; // const pageRows = instance.getPageRows()
|
|
3679
|
+
|
|
2973
3680
|
return {
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
instance.setExpanded(function (old) {
|
|
2980
|
-
var _old, _expanded;
|
|
3681
|
+
_notifyRowSelectionReset: function _notifyRowSelectionReset() {
|
|
3682
|
+
if (!registered) {
|
|
3683
|
+
registered = true;
|
|
3684
|
+
return;
|
|
3685
|
+
}
|
|
2981
3686
|
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
3687
|
+
if (instance.options.autoResetAll === false) {
|
|
3688
|
+
return;
|
|
3689
|
+
}
|
|
2985
3690
|
|
|
2986
|
-
|
|
2987
|
-
|
|
3691
|
+
if (instance.options.autoResetAll === true || instance.options.autoResetRowSelection) {
|
|
3692
|
+
instance.resetRowSelection();
|
|
3693
|
+
}
|
|
3694
|
+
},
|
|
3695
|
+
setRowSelection: function setRowSelection(updater) {
|
|
3696
|
+
return instance.options.onRowSelectionChange == null ? void 0 : instance.options.onRowSelectionChange(updater, functionalUpdate(updater, instance.getState().rowSelection));
|
|
3697
|
+
},
|
|
3698
|
+
resetRowSelection: function resetRowSelection() {
|
|
3699
|
+
var _getInitialState$rowS;
|
|
2988
3700
|
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
3701
|
+
return instance.setRowSelection((_getInitialState$rowS = getInitialState().rowSelection) != null ? _getInitialState$rowS : {});
|
|
3702
|
+
},
|
|
3703
|
+
toggleAllRowsSelected: function toggleAllRowsSelected(value) {
|
|
3704
|
+
instance.setRowSelection(function (old) {
|
|
3705
|
+
value = typeof value !== 'undefined' ? value : !instance.getIsAllRowsSelected(); // Only remove/add the rows that are visible on the screen
|
|
3706
|
+
// Leave all the other rows that are selected alone.
|
|
3707
|
+
|
|
3708
|
+
var rowSelection = Object.assign({}, old);
|
|
3709
|
+
var preGroupedFlatRows = instance.getPreGroupedFlatRows(); // We don't use `mutateRowIsSelected` here for performance reasons.
|
|
3710
|
+
// All of the rows are flat already, so it wouldn't be worth it
|
|
3711
|
+
|
|
3712
|
+
if (value) {
|
|
3713
|
+
preGroupedFlatRows.forEach(function (row) {
|
|
3714
|
+
rowSelection[row.id] = true;
|
|
2992
3715
|
});
|
|
2993
3716
|
} else {
|
|
2994
|
-
|
|
3717
|
+
preGroupedFlatRows.forEach(function (row) {
|
|
3718
|
+
delete rowSelection[row.id];
|
|
3719
|
+
});
|
|
2995
3720
|
}
|
|
2996
3721
|
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3722
|
+
return rowSelection;
|
|
3723
|
+
});
|
|
3724
|
+
},
|
|
3725
|
+
toggleAllPageRowsSelected: function toggleAllPageRowsSelected(value) {
|
|
3726
|
+
return instance.setRowSelection(function (old) {
|
|
3727
|
+
typeof value !== 'undefined' ? value : !instance.getIsAllPageRowsSelected();
|
|
3001
3728
|
|
|
3002
|
-
|
|
3003
|
-
}
|
|
3729
|
+
var rowSelection = _extends({}, old);
|
|
3004
3730
|
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3731
|
+
instance.getRows().forEach(function (row) {
|
|
3732
|
+
mutateRowIsSelected(rowSelection, row.id, value, instance);
|
|
3733
|
+
});
|
|
3734
|
+
return rowSelection;
|
|
3735
|
+
});
|
|
3736
|
+
},
|
|
3737
|
+
toggleRowSelected: function toggleRowSelected(rowId, value) {
|
|
3738
|
+
var row = instance.getRow(rowId);
|
|
3739
|
+
var isSelected = row.getIsSelected();
|
|
3740
|
+
instance.setRowSelection(function (old) {
|
|
3741
|
+
value = typeof value !== 'undefined' ? value : !isSelected;
|
|
3009
3742
|
|
|
3010
|
-
|
|
3743
|
+
if (isSelected === value) {
|
|
3744
|
+
return old;
|
|
3011
3745
|
}
|
|
3012
3746
|
|
|
3013
|
-
|
|
3747
|
+
var selectedRowIds = _extends({}, old);
|
|
3748
|
+
|
|
3749
|
+
mutateRowIsSelected(selectedRowIds, rowId, value, instance);
|
|
3750
|
+
return selectedRowIds;
|
|
3014
3751
|
});
|
|
3015
3752
|
},
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3753
|
+
// addRowSelectionRange: rowId => {
|
|
3754
|
+
// const {
|
|
3755
|
+
// rows,
|
|
3756
|
+
// rowsById,
|
|
3757
|
+
// options: { selectGroupingRows, selectSubRows },
|
|
3758
|
+
// } = instance
|
|
3759
|
+
// const findSelectedRow = (rows: Row[]) => {
|
|
3760
|
+
// let found
|
|
3761
|
+
// rows.find(d => {
|
|
3762
|
+
// if (d.getIsSelected()) {
|
|
3763
|
+
// found = d
|
|
3764
|
+
// return true
|
|
3765
|
+
// }
|
|
3766
|
+
// const subFound = findSelectedRow(d.subRows || [])
|
|
3767
|
+
// if (subFound) {
|
|
3768
|
+
// found = subFound
|
|
3769
|
+
// return true
|
|
3770
|
+
// }
|
|
3771
|
+
// return false
|
|
3772
|
+
// })
|
|
3773
|
+
// return found
|
|
3774
|
+
// }
|
|
3775
|
+
// const firstRow = findSelectedRow(rows) || rows[0]
|
|
3776
|
+
// const lastRow = rowsById[rowId]
|
|
3777
|
+
// let include = false
|
|
3778
|
+
// const selectedRowIds = {}
|
|
3779
|
+
// const addRow = (row: Row) => {
|
|
3780
|
+
// mutateRowIsSelected(selectedRowIds, row.id, true, {
|
|
3781
|
+
// rowsById,
|
|
3782
|
+
// selectGroupingRows: selectGroupingRows!,
|
|
3783
|
+
// selectSubRows: selectSubRows!,
|
|
3784
|
+
// })
|
|
3785
|
+
// }
|
|
3786
|
+
// instance.rows.forEach(row => {
|
|
3787
|
+
// const isFirstRow = row.id === firstRow.id
|
|
3788
|
+
// const isLastRow = row.id === lastRow.id
|
|
3789
|
+
// if (isFirstRow || isLastRow) {
|
|
3790
|
+
// if (!include) {
|
|
3791
|
+
// include = true
|
|
3792
|
+
// } else if (include) {
|
|
3793
|
+
// addRow(row)
|
|
3794
|
+
// include = false
|
|
3795
|
+
// }
|
|
3796
|
+
// }
|
|
3797
|
+
// if (include) {
|
|
3798
|
+
// addRow(row)
|
|
3799
|
+
// }
|
|
3800
|
+
// })
|
|
3801
|
+
// instance.setRowSelection(selectedRowIds)
|
|
3802
|
+
// },
|
|
3803
|
+
getSelectedRowModel: memo(function () {
|
|
3804
|
+
return [instance.getState().rowSelection, instance.getCoreRowModel()];
|
|
3805
|
+
}, function (rowSelection, rowModel) {
|
|
3806
|
+
if (!Object.keys(rowSelection).length) {
|
|
3807
|
+
return {
|
|
3808
|
+
rows: [],
|
|
3809
|
+
flatRows: [],
|
|
3810
|
+
rowsById: {}
|
|
3811
|
+
};
|
|
3812
|
+
}
|
|
3813
|
+
|
|
3814
|
+
if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Selecting...');
|
|
3815
|
+
return selectRowsFn(instance, rowModel);
|
|
3816
|
+
}, {
|
|
3817
|
+
key: 'getSelectedRowModel',
|
|
3818
|
+
debug: instance.options.debug,
|
|
3819
|
+
onChange: function onChange() {
|
|
3820
|
+
return instance._notifyExpandedReset();
|
|
3021
3821
|
}
|
|
3822
|
+
}),
|
|
3823
|
+
getSelectedRows: function getSelectedRows() {
|
|
3824
|
+
return instance.getSelectedRowModel().rows;
|
|
3022
3825
|
},
|
|
3023
|
-
|
|
3024
|
-
|
|
3826
|
+
getSelectedFlatRows: function getSelectedFlatRows() {
|
|
3827
|
+
return instance.getSelectedRowModel().flatRows;
|
|
3828
|
+
},
|
|
3829
|
+
getSelectedRowsById: function getSelectedRowsById() {
|
|
3830
|
+
return instance.getSelectedRowModel().rowsById;
|
|
3831
|
+
},
|
|
3832
|
+
getFilteredSelectedRowModel: memo(function () {
|
|
3833
|
+
return [instance.getState().rowSelection, instance.getGlobalFilteredRowModel()];
|
|
3834
|
+
}, function (rowSelection, rowModel) {
|
|
3835
|
+
if (!Object.keys(rowSelection).length) {
|
|
3836
|
+
return {
|
|
3837
|
+
rows: [],
|
|
3838
|
+
flatRows: [],
|
|
3839
|
+
rowsById: {}
|
|
3840
|
+
};
|
|
3841
|
+
}
|
|
3025
3842
|
|
|
3026
|
-
|
|
3843
|
+
if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Selecting...');
|
|
3844
|
+
return selectRowsFn(instance, rowModel);
|
|
3845
|
+
}, {
|
|
3846
|
+
key: 'getFilteredSelectedRowModel',
|
|
3847
|
+
debug: instance.options.debug,
|
|
3848
|
+
onChange: function onChange() {
|
|
3849
|
+
return instance._notifyExpandedReset();
|
|
3850
|
+
}
|
|
3851
|
+
}),
|
|
3852
|
+
getFilteredSelectedRows: function getFilteredSelectedRows() {
|
|
3853
|
+
return instance.getFilteredSelectedRowModel().rows;
|
|
3027
3854
|
},
|
|
3028
|
-
|
|
3029
|
-
|
|
3855
|
+
getFilteredSelectedFlatRows: function getFilteredSelectedFlatRows() {
|
|
3856
|
+
return instance.getFilteredSelectedRowModel().flatRows;
|
|
3857
|
+
},
|
|
3858
|
+
getFilteredSelectedRowsById: function getFilteredSelectedRowsById() {
|
|
3859
|
+
return instance.getFilteredSelectedRowModel().rowsById;
|
|
3860
|
+
},
|
|
3861
|
+
getGroupedSelectedRowModel: memo(function () {
|
|
3862
|
+
return [instance.getState().rowSelection, instance.getGroupedRowModel()];
|
|
3863
|
+
}, function (rowSelection, rowModel) {
|
|
3864
|
+
if (!Object.keys(rowSelection).length) {
|
|
3865
|
+
return {
|
|
3866
|
+
rows: [],
|
|
3867
|
+
flatRows: [],
|
|
3868
|
+
rowsById: {}
|
|
3869
|
+
};
|
|
3870
|
+
}
|
|
3871
|
+
|
|
3872
|
+
if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Selecting...');
|
|
3873
|
+
return selectRowsFn(instance, rowModel);
|
|
3874
|
+
}, {
|
|
3875
|
+
key: 'getGroupedSelectedRowModel',
|
|
3876
|
+
debug: instance.options.debug,
|
|
3877
|
+
onChange: function onChange() {
|
|
3878
|
+
return instance._notifyExpandedReset();
|
|
3879
|
+
}
|
|
3880
|
+
}),
|
|
3881
|
+
getGroupedSelectedRows: function getGroupedSelectedRows() {
|
|
3882
|
+
return instance.getGroupedSelectedRowModel().rows;
|
|
3883
|
+
},
|
|
3884
|
+
getGroupedSelectedFlatRows: function getGroupedSelectedFlatRows() {
|
|
3885
|
+
return instance.getGroupedSelectedRowModel().flatRows;
|
|
3886
|
+
},
|
|
3887
|
+
getGroupedSelectedRowsById: function getGroupedSelectedRowsById() {
|
|
3888
|
+
return instance.getGroupedSelectedRowModel().rowsById;
|
|
3889
|
+
},
|
|
3890
|
+
///
|
|
3891
|
+
getRowIsSelected: function getRowIsSelected(rowId) {
|
|
3892
|
+
var _instance$getState = instance.getState(),
|
|
3893
|
+
rowSelection = _instance$getState.rowSelection;
|
|
3030
3894
|
|
|
3031
3895
|
var row = instance.getRow(rowId);
|
|
3032
3896
|
|
|
3033
3897
|
if (!row) {
|
|
3034
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
3035
|
-
console.warn("[ReactTable] getIsRowExpanded: no row found with id " + rowId);
|
|
3036
|
-
}
|
|
3037
|
-
|
|
3038
3898
|
throw new Error();
|
|
3039
3899
|
}
|
|
3040
3900
|
|
|
3041
|
-
|
|
3042
|
-
return !!((_instance$options$get = instance.options.getIsRowExpanded == null ? void 0 : instance.options.getIsRowExpanded(row)) != null ? _instance$options$get : expanded || (expanded == null ? void 0 : expanded[rowId]));
|
|
3901
|
+
return isRowSelected(row, rowSelection) === true;
|
|
3043
3902
|
},
|
|
3044
|
-
|
|
3045
|
-
var
|
|
3903
|
+
getRowIsSomeSelected: function getRowIsSomeSelected(rowId) {
|
|
3904
|
+
var _instance$getState2 = instance.getState(),
|
|
3905
|
+
rowSelection = _instance$getState2.rowSelection;
|
|
3046
3906
|
|
|
3047
3907
|
var row = instance.getRow(rowId);
|
|
3048
3908
|
|
|
3049
3909
|
if (!row) {
|
|
3050
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
3051
|
-
console.warn("[ReactTable] getRowCanExpand: no row found with id " + rowId);
|
|
3052
|
-
}
|
|
3053
|
-
|
|
3054
3910
|
throw new Error();
|
|
3055
3911
|
}
|
|
3056
3912
|
|
|
3057
|
-
return (
|
|
3913
|
+
return isRowSelected(row, rowSelection) === 'some';
|
|
3058
3914
|
},
|
|
3059
|
-
|
|
3915
|
+
getRowCanSelect: function getRowCanSelect(rowId) {
|
|
3916
|
+
var _instance$options$ena;
|
|
3917
|
+
|
|
3060
3918
|
var row = instance.getRow(rowId);
|
|
3061
3919
|
|
|
3062
3920
|
if (!row) {
|
|
3063
|
-
|
|
3921
|
+
throw new Error();
|
|
3064
3922
|
}
|
|
3065
3923
|
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
instance.toggleRowExpanded(rowId);
|
|
3072
|
-
} : undefined
|
|
3073
|
-
};
|
|
3074
|
-
return propGetter(initialProps, userProps);
|
|
3924
|
+
if (typeof instance.options.enableRowSelection === 'function') {
|
|
3925
|
+
return instance.options.enableRowSelection(row);
|
|
3926
|
+
}
|
|
3927
|
+
|
|
3928
|
+
return (_instance$options$ena = instance.options.enableRowSelection) != null ? _instance$options$ena : true;
|
|
3075
3929
|
},
|
|
3076
|
-
|
|
3077
|
-
var
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
}
|
|
3084
|
-
|
|
3930
|
+
getRowCanSelectSubRows: function getRowCanSelectSubRows(rowId) {
|
|
3931
|
+
var _instance$options$ena2;
|
|
3932
|
+
|
|
3933
|
+
var row = instance.getRow(rowId);
|
|
3934
|
+
|
|
3935
|
+
if (!row) {
|
|
3936
|
+
throw new Error();
|
|
3937
|
+
}
|
|
3938
|
+
|
|
3939
|
+
if (typeof instance.options.enableSubRowSelection === 'function') {
|
|
3940
|
+
return instance.options.enableSubRowSelection(row);
|
|
3941
|
+
}
|
|
3942
|
+
|
|
3943
|
+
return (_instance$options$ena2 = instance.options.enableSubRowSelection) != null ? _instance$options$ena2 : true;
|
|
3085
3944
|
},
|
|
3086
|
-
|
|
3087
|
-
var
|
|
3945
|
+
getRowCanMultiSelect: function getRowCanMultiSelect(rowId) {
|
|
3946
|
+
var _instance$options$ena3;
|
|
3088
3947
|
|
|
3089
|
-
|
|
3090
|
-
return true;
|
|
3091
|
-
} // If any row is not expanded, return false
|
|
3948
|
+
var row = instance.getRow(rowId);
|
|
3092
3949
|
|
|
3950
|
+
if (!row) {
|
|
3951
|
+
throw new Error();
|
|
3952
|
+
}
|
|
3093
3953
|
|
|
3094
|
-
if (
|
|
3095
|
-
return
|
|
3096
|
-
}
|
|
3097
|
-
return false;
|
|
3098
|
-
} // They must all be expanded :shrug:
|
|
3954
|
+
if (typeof instance.options.enableMultiRowSelection === 'function') {
|
|
3955
|
+
return instance.options.enableMultiRowSelection(row);
|
|
3956
|
+
}
|
|
3099
3957
|
|
|
3958
|
+
return (_instance$options$ena3 = instance.options.enableMultiRowSelection) != null ? _instance$options$ena3 : true;
|
|
3959
|
+
},
|
|
3960
|
+
// getGroupingRowCanSelect: rowId => {
|
|
3961
|
+
// const row = instance.getRow(rowId)
|
|
3962
|
+
// if (!row) {
|
|
3963
|
+
// throw new Error()
|
|
3964
|
+
// }
|
|
3965
|
+
// if (typeof instance.options.enableGroupingRowSelection === 'function') {
|
|
3966
|
+
// return instance.options.enableGroupingRowSelection(row)
|
|
3967
|
+
// }
|
|
3968
|
+
// return instance.options.enableGroupingRowSelection ?? false
|
|
3969
|
+
// },
|
|
3970
|
+
getIsAllRowsSelected: function getIsAllRowsSelected() {
|
|
3971
|
+
var preFilteredFlatRows = instance.getPreGlobalFilteredFlatRows();
|
|
3972
|
+
|
|
3973
|
+
var _instance$getState3 = instance.getState(),
|
|
3974
|
+
rowSelection = _instance$getState3.rowSelection;
|
|
3975
|
+
|
|
3976
|
+
var isAllRowsSelected = Boolean(preFilteredFlatRows.length && Object.keys(rowSelection).length);
|
|
3977
|
+
|
|
3978
|
+
if (isAllRowsSelected) {
|
|
3979
|
+
if (preFilteredFlatRows.some(function (row) {
|
|
3980
|
+
return !rowSelection[row.id];
|
|
3981
|
+
})) {
|
|
3982
|
+
isAllRowsSelected = false;
|
|
3983
|
+
}
|
|
3984
|
+
}
|
|
3100
3985
|
|
|
3101
|
-
return
|
|
3102
|
-
},
|
|
3103
|
-
getExpandedDepth: function getExpandedDepth() {
|
|
3104
|
-
var maxDepth = 0;
|
|
3105
|
-
var rowIds = instance.getState().expanded === true ? Object.keys(instance.getRowsById()) : Object.keys(instance.getState().expanded);
|
|
3106
|
-
rowIds.forEach(function (id) {
|
|
3107
|
-
var splitId = id.split('.');
|
|
3108
|
-
maxDepth = Math.max(maxDepth, splitId.length);
|
|
3109
|
-
});
|
|
3110
|
-
return maxDepth;
|
|
3986
|
+
return isAllRowsSelected;
|
|
3111
3987
|
},
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3988
|
+
getIsAllPageRowsSelected: function getIsAllPageRowsSelected() {
|
|
3989
|
+
var paginationFlatRows = instance.getPaginationFlatRows();
|
|
3990
|
+
|
|
3991
|
+
var _instance$getState4 = instance.getState(),
|
|
3992
|
+
rowSelection = _instance$getState4.rowSelection;
|
|
3993
|
+
|
|
3994
|
+
var isAllPageRowsSelected = !!paginationFlatRows.length;
|
|
3995
|
+
|
|
3996
|
+
if (isAllPageRowsSelected && paginationFlatRows.some(function (row) {
|
|
3997
|
+
return !rowSelection[row.id];
|
|
3998
|
+
})) {
|
|
3999
|
+
isAllPageRowsSelected = false;
|
|
3118
4000
|
}
|
|
3119
4001
|
|
|
3120
|
-
|
|
3121
|
-
return expandRowsFn(instance, expanded, rowModel);
|
|
3122
|
-
}, 'getExpandedRowModel', instance.options.debug),
|
|
3123
|
-
getPreExpandedRows: function getPreExpandedRows() {
|
|
3124
|
-
return instance.getGroupedRowModel().rows;
|
|
4002
|
+
return isAllPageRowsSelected;
|
|
3125
4003
|
},
|
|
3126
|
-
|
|
3127
|
-
|
|
4004
|
+
getIsSomeRowsSelected: function getIsSomeRowsSelected() {
|
|
4005
|
+
var _instance$getState$ro;
|
|
4006
|
+
|
|
4007
|
+
return !instance.getIsAllRowsSelected() && !!Object.keys((_instance$getState$ro = instance.getState().rowSelection) != null ? _instance$getState$ro : {}).length;
|
|
3128
4008
|
},
|
|
3129
|
-
|
|
3130
|
-
|
|
4009
|
+
getIsSomePageRowsSelected: function getIsSomePageRowsSelected() {
|
|
4010
|
+
var paginationFlatRows = instance.getPaginationFlatRows();
|
|
4011
|
+
return instance.getIsAllPageRowsSelected() ? false : !!(paginationFlatRows != null && paginationFlatRows.length);
|
|
3131
4012
|
},
|
|
3132
|
-
|
|
3133
|
-
|
|
4013
|
+
getToggleRowSelectedProps: function getToggleRowSelectedProps(rowId, userProps) {
|
|
4014
|
+
var row = instance.getRow(rowId);
|
|
4015
|
+
var isSelected = row.getIsSelected();
|
|
4016
|
+
var isSomeSelected = row.getIsSomeSelected();
|
|
4017
|
+
var canSelect = row.getCanSelect();
|
|
4018
|
+
var initialProps = {
|
|
4019
|
+
onChange: canSelect ? function (e) {
|
|
4020
|
+
row.toggleSelected(e.target.checked);
|
|
4021
|
+
} : undefined,
|
|
4022
|
+
checked: isSelected,
|
|
4023
|
+
title: 'Toggle Row Selected',
|
|
4024
|
+
indeterminate: isSomeSelected // onChange: forInput
|
|
4025
|
+
// ? (e: Event) => e.stopPropagation()
|
|
4026
|
+
// : (e: Event) => {
|
|
4027
|
+
// if (instance.options.isAdditiveSelectEvent(e)) {
|
|
4028
|
+
// row.toggleSelected()
|
|
4029
|
+
// } else if (instance.options.isInclusiveSelectEvent(e)) {
|
|
4030
|
+
// instance.addRowSelectionRange(row.id)
|
|
4031
|
+
// } else {
|
|
4032
|
+
// instance.setRowSelection({})
|
|
4033
|
+
// row.toggleSelected()
|
|
4034
|
+
// }
|
|
4035
|
+
// if (props.onClick) props.onClick(e)
|
|
4036
|
+
// },
|
|
4037
|
+
|
|
4038
|
+
};
|
|
4039
|
+
return propGetter(initialProps, userProps);
|
|
3134
4040
|
},
|
|
3135
|
-
|
|
3136
|
-
|
|
4041
|
+
getToggleAllRowsSelectedProps: function getToggleAllRowsSelectedProps(userProps) {
|
|
4042
|
+
var isSomeRowsSelected = instance.getIsSomeRowsSelected();
|
|
4043
|
+
var isAllRowsSelected = instance.getIsAllRowsSelected();
|
|
4044
|
+
var initialProps = {
|
|
4045
|
+
onChange: function onChange(e) {
|
|
4046
|
+
instance.toggleAllRowsSelected(e.target.checked);
|
|
4047
|
+
},
|
|
4048
|
+
checked: isAllRowsSelected,
|
|
4049
|
+
title: 'Toggle All Rows Selected',
|
|
4050
|
+
indeterminate: isSomeRowsSelected
|
|
4051
|
+
};
|
|
4052
|
+
return propGetter(initialProps, userProps);
|
|
3137
4053
|
},
|
|
3138
|
-
|
|
3139
|
-
|
|
4054
|
+
getToggleAllPageRowsSelectedProps: function getToggleAllPageRowsSelectedProps(userProps) {
|
|
4055
|
+
var isSomePageRowsSelected = instance.getIsSomePageRowsSelected();
|
|
4056
|
+
var isAllPageRowsSelected = instance.getIsAllPageRowsSelected();
|
|
4057
|
+
var initialProps = {
|
|
4058
|
+
onChange: function onChange(e) {
|
|
4059
|
+
instance.toggleAllPageRowsSelected(e.target.checked);
|
|
4060
|
+
},
|
|
4061
|
+
checked: isAllPageRowsSelected,
|
|
4062
|
+
title: 'Toggle All Current Page Rows Selected',
|
|
4063
|
+
indeterminate: isSomePageRowsSelected
|
|
4064
|
+
};
|
|
4065
|
+
return propGetter(initialProps, userProps);
|
|
3140
4066
|
}
|
|
3141
4067
|
};
|
|
3142
4068
|
}
|
|
3143
4069
|
function createRow(row, instance) {
|
|
3144
4070
|
return {
|
|
3145
|
-
|
|
3146
|
-
return
|
|
4071
|
+
getIsSelected: function getIsSelected() {
|
|
4072
|
+
return instance.getRowIsSelected(row.id);
|
|
3147
4073
|
},
|
|
3148
|
-
|
|
3149
|
-
return instance.
|
|
4074
|
+
getIsSomeSelected: function getIsSomeSelected() {
|
|
4075
|
+
return instance.getRowIsSomeSelected(row.id);
|
|
3150
4076
|
},
|
|
3151
|
-
|
|
3152
|
-
return row.
|
|
4077
|
+
toggleSelected: function toggleSelected(value) {
|
|
4078
|
+
return instance.toggleRowSelected(row.id, value);
|
|
3153
4079
|
},
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
return propGetter(initialProps, userProps);
|
|
4080
|
+
getToggleSelectedProps: function getToggleSelectedProps(userProps) {
|
|
4081
|
+
return instance.getToggleRowSelectedProps(row.id, userProps);
|
|
4082
|
+
},
|
|
4083
|
+
getCanMultiSelect: function getCanMultiSelect() {
|
|
4084
|
+
return instance.getRowCanMultiSelect(row.id);
|
|
4085
|
+
},
|
|
4086
|
+
getCanSelect: function getCanSelect() {
|
|
4087
|
+
return instance.getRowCanSelect(row.id);
|
|
3163
4088
|
}
|
|
3164
4089
|
};
|
|
3165
4090
|
}
|
|
3166
4091
|
|
|
4092
|
+
var mutateRowIsSelected = function mutateRowIsSelected(selectedRowIds, id, value, instance) {
|
|
4093
|
+
var _row$subRows;
|
|
4094
|
+
|
|
4095
|
+
var row = instance.getRow(id);
|
|
4096
|
+
row.getIsGrouped(); // if ( // TODO: enforce grouping row selection rules
|
|
4097
|
+
// !isGrouped ||
|
|
4098
|
+
// (isGrouped && instance.options.enableGroupingRowSelection)
|
|
4099
|
+
// ) {
|
|
4100
|
+
|
|
4101
|
+
if (value) {
|
|
4102
|
+
selectedRowIds[id] = true;
|
|
4103
|
+
} else {
|
|
4104
|
+
delete selectedRowIds[id];
|
|
4105
|
+
} // }
|
|
4106
|
+
|
|
4107
|
+
|
|
4108
|
+
if ((_row$subRows = row.subRows) != null && _row$subRows.length && instance.getRowCanSelectSubRows(row.id)) {
|
|
4109
|
+
row.subRows.forEach(function (row) {
|
|
4110
|
+
return mutateRowIsSelected(selectedRowIds, row.id, value, instance);
|
|
4111
|
+
});
|
|
4112
|
+
}
|
|
4113
|
+
};
|
|
4114
|
+
|
|
4115
|
+
function selectRowsFn(instance, rowModel) {
|
|
4116
|
+
var rowSelection = instance.getState().rowSelection;
|
|
4117
|
+
var newSelectedFlatRows = [];
|
|
4118
|
+
var newSelectedRowsById = {}; // Filters top level and nested rows
|
|
4119
|
+
|
|
4120
|
+
var recurseRows = function recurseRows(rows, depth) {
|
|
4121
|
+
|
|
4122
|
+
return rows.map(function (row) {
|
|
4123
|
+
var _row$subRows2;
|
|
4124
|
+
|
|
4125
|
+
var isSelected = isRowSelected(row, rowSelection) === true;
|
|
4126
|
+
|
|
4127
|
+
if (isSelected) {
|
|
4128
|
+
newSelectedFlatRows.push(row);
|
|
4129
|
+
newSelectedRowsById[row.id] = row;
|
|
4130
|
+
}
|
|
4131
|
+
|
|
4132
|
+
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
|
|
4133
|
+
row = _extends({}, row, {
|
|
4134
|
+
subRows: recurseRows(row.subRows)
|
|
4135
|
+
});
|
|
4136
|
+
}
|
|
4137
|
+
|
|
4138
|
+
if (isSelected) {
|
|
4139
|
+
return row;
|
|
4140
|
+
}
|
|
4141
|
+
}).filter(Boolean);
|
|
4142
|
+
};
|
|
4143
|
+
|
|
4144
|
+
return {
|
|
4145
|
+
rows: recurseRows(rowModel.rows),
|
|
4146
|
+
flatRows: newSelectedFlatRows,
|
|
4147
|
+
rowsById: newSelectedRowsById
|
|
4148
|
+
};
|
|
4149
|
+
}
|
|
4150
|
+
function isRowSelected(row, selection, instance) {
|
|
4151
|
+
if (selection[row.id]) {
|
|
4152
|
+
return true;
|
|
4153
|
+
}
|
|
4154
|
+
|
|
4155
|
+
if (row.subRows && row.subRows.length) {
|
|
4156
|
+
var allChildrenSelected = true;
|
|
4157
|
+
var someSelected = false;
|
|
4158
|
+
row.subRows.forEach(function (subRow) {
|
|
4159
|
+
// Bail out early if we know both of these
|
|
4160
|
+
if (someSelected && !allChildrenSelected) {
|
|
4161
|
+
return;
|
|
4162
|
+
}
|
|
4163
|
+
|
|
4164
|
+
if (isRowSelected(subRow, selection)) {
|
|
4165
|
+
someSelected = true;
|
|
4166
|
+
} else {
|
|
4167
|
+
allChildrenSelected = false;
|
|
4168
|
+
}
|
|
4169
|
+
});
|
|
4170
|
+
return allChildrenSelected ? true : someSelected ? 'some' : false;
|
|
4171
|
+
}
|
|
4172
|
+
|
|
4173
|
+
return false;
|
|
4174
|
+
}
|
|
4175
|
+
|
|
4176
|
+
var RowSelection = /*#__PURE__*/Object.freeze({
|
|
4177
|
+
__proto__: null,
|
|
4178
|
+
getInitialState: getInitialState,
|
|
4179
|
+
getDefaultOptions: getDefaultOptions,
|
|
4180
|
+
getInstance: getInstance,
|
|
4181
|
+
createRow: createRow,
|
|
4182
|
+
selectRowsFn: selectRowsFn,
|
|
4183
|
+
isRowSelected: isRowSelected
|
|
4184
|
+
});
|
|
4185
|
+
|
|
4186
|
+
var features = [Visibility, Ordering, Pinning, Headers, Filters, Sorting, Grouping, Expanding, ColumnSizing, Pagination, RowSelection];
|
|
3167
4187
|
function createTableInstance(options, rerender) {
|
|
3168
4188
|
var _options$initialState;
|
|
3169
4189
|
|
|
@@ -3172,9 +4192,9 @@ function createTableInstance(options, rerender) {
|
|
|
3172
4192
|
}
|
|
3173
4193
|
|
|
3174
4194
|
var instance = {};
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
4195
|
+
var defaultOptions = features.reduce(function (obj, feature) {
|
|
4196
|
+
return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(instance));
|
|
4197
|
+
}, {});
|
|
3178
4198
|
var defaultState = {};
|
|
3179
4199
|
|
|
3180
4200
|
var buildOptions = function buildOptions(options) {
|
|
@@ -3185,9 +4205,13 @@ function createTableInstance(options, rerender) {
|
|
|
3185
4205
|
|
|
3186
4206
|
instance.options = buildOptions(options);
|
|
3187
4207
|
|
|
3188
|
-
var initialState = _extends({},
|
|
4208
|
+
var initialState = _extends({}, features.reduce(function (obj, feature) {
|
|
4209
|
+
return Object.assign(obj, feature.getInitialState == null ? void 0 : feature.getInitialState());
|
|
4210
|
+
}, {}), (_options$initialState = options.initialState) != null ? _options$initialState : {});
|
|
3189
4211
|
|
|
3190
|
-
var finalInstance = _extends({}, instance,
|
|
4212
|
+
var finalInstance = _extends({}, instance, features.reduce(function (obj, feature) {
|
|
4213
|
+
return Object.assign(obj, feature.getInstance == null ? void 0 : feature.getInstance(instance));
|
|
4214
|
+
}, {}), {
|
|
3191
4215
|
rerender: rerender,
|
|
3192
4216
|
initialState: initialState,
|
|
3193
4217
|
internalState: initialState,
|
|
@@ -3201,15 +4225,18 @@ function createTableInstance(options, rerender) {
|
|
|
3201
4225
|
return "" + (parent ? [parent.id, index].join('.') : index);
|
|
3202
4226
|
},
|
|
3203
4227
|
getState: function getState() {
|
|
3204
|
-
|
|
4228
|
+
var state = _extends({}, instance.internalState, instance.options.state);
|
|
4229
|
+
|
|
4230
|
+
return state;
|
|
3205
4231
|
},
|
|
3206
4232
|
setState: function setState(updater, shouldRerender) {
|
|
3207
4233
|
if (shouldRerender === void 0) {
|
|
3208
4234
|
shouldRerender = true;
|
|
3209
4235
|
}
|
|
3210
4236
|
|
|
3211
|
-
var newState = functionalUpdate(updater, instance.internalState);
|
|
3212
4237
|
var onStateChange = instance.options.onStateChange;
|
|
4238
|
+
var internalState = instance.internalState;
|
|
4239
|
+
var newState = functionalUpdate(updater, internalState);
|
|
3213
4240
|
instance.internalState = newState;
|
|
3214
4241
|
|
|
3215
4242
|
if (onStateChange) {
|
|
@@ -3239,12 +4266,17 @@ function createTableInstance(options, rerender) {
|
|
|
3239
4266
|
value = _ref$value === void 0 ? '' : _ref$value;
|
|
3240
4267
|
return typeof value === 'boolean' ? value.toString() : value;
|
|
3241
4268
|
}
|
|
3242
|
-
},
|
|
3243
|
-
|
|
4269
|
+
}, features.reduce(function (obj, feature) {
|
|
4270
|
+
return Object.assign(obj, feature.getDefaultColumn == null ? void 0 : feature.getDefaultColumn());
|
|
4271
|
+
}, {}), defaultColumn);
|
|
4272
|
+
}, {
|
|
4273
|
+
debug: instance.options.debug,
|
|
4274
|
+
key: 'getDefaultColumn'
|
|
4275
|
+
}),
|
|
3244
4276
|
getColumnDefs: function getColumnDefs() {
|
|
3245
4277
|
return instance.options.columns;
|
|
3246
4278
|
},
|
|
3247
|
-
createColumn: function createColumn
|
|
4279
|
+
createColumn: function createColumn(columnDef, depth, parent) {
|
|
3248
4280
|
var _ref2, _columnDef$id;
|
|
3249
4281
|
|
|
3250
4282
|
var defaultColumn = instance.getDefaultColumn();
|
|
@@ -3285,7 +4317,10 @@ function createTableInstance(options, rerender) {
|
|
|
3285
4317
|
return [column].concat((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(function (d) {
|
|
3286
4318
|
return d.getFlatColumns();
|
|
3287
4319
|
}));
|
|
3288
|
-
},
|
|
4320
|
+
}, {
|
|
4321
|
+
key: 'column.getFlatColumns',
|
|
4322
|
+
debug: instance.options.debug
|
|
4323
|
+
}),
|
|
3289
4324
|
getLeafColumns: memo(function () {
|
|
3290
4325
|
return [instance.getOrderColumnsFn()];
|
|
3291
4326
|
}, function (orderColumns) {
|
|
@@ -3299,10 +4334,15 @@ function createTableInstance(options, rerender) {
|
|
|
3299
4334
|
}
|
|
3300
4335
|
|
|
3301
4336
|
return [column];
|
|
3302
|
-
},
|
|
4337
|
+
}, {
|
|
4338
|
+
key: 'column.getLeafColumns',
|
|
4339
|
+
debug: instance.options.debug
|
|
4340
|
+
})
|
|
3303
4341
|
});
|
|
3304
4342
|
|
|
3305
|
-
column =
|
|
4343
|
+
column = features.reduce(function (obj, feature) {
|
|
4344
|
+
return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
|
|
4345
|
+
}, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
3306
4346
|
|
|
3307
4347
|
return column;
|
|
3308
4348
|
},
|
|
@@ -3324,14 +4364,20 @@ function createTableInstance(options, rerender) {
|
|
|
3324
4364
|
};
|
|
3325
4365
|
|
|
3326
4366
|
return recurseColumns(columnDefs);
|
|
3327
|
-
},
|
|
4367
|
+
}, {
|
|
4368
|
+
key: 'getAllColumns',
|
|
4369
|
+
debug: instance.options.debug
|
|
4370
|
+
}),
|
|
3328
4371
|
getAllFlatColumns: memo(function () {
|
|
3329
4372
|
return [instance.getAllColumns()];
|
|
3330
4373
|
}, function (allColumns) {
|
|
3331
4374
|
return allColumns.flatMap(function (column) {
|
|
3332
4375
|
return column.getFlatColumns();
|
|
3333
4376
|
});
|
|
3334
|
-
},
|
|
4377
|
+
}, {
|
|
4378
|
+
key: 'getAllFlatColumns',
|
|
4379
|
+
debug: instance.options.debug
|
|
4380
|
+
}),
|
|
3335
4381
|
getAllFlatColumnsById: memo(function () {
|
|
3336
4382
|
return [instance.getAllFlatColumns()];
|
|
3337
4383
|
}, function (flatColumns) {
|
|
@@ -3339,7 +4385,10 @@ function createTableInstance(options, rerender) {
|
|
|
3339
4385
|
acc[column.id] = column;
|
|
3340
4386
|
return acc;
|
|
3341
4387
|
}, {});
|
|
3342
|
-
},
|
|
4388
|
+
}, {
|
|
4389
|
+
key: 'getAllFlatColumnsById',
|
|
4390
|
+
debug: instance.options.debug
|
|
4391
|
+
}),
|
|
3343
4392
|
getAllLeafColumns: memo(function () {
|
|
3344
4393
|
return [instance.getAllColumns(), instance.getOrderColumnsFn()];
|
|
3345
4394
|
}, function (allColumns, orderColumns) {
|
|
@@ -3347,7 +4396,10 @@ function createTableInstance(options, rerender) {
|
|
|
3347
4396
|
return column.getLeafColumns();
|
|
3348
4397
|
});
|
|
3349
4398
|
return orderColumns(leafColumns);
|
|
3350
|
-
},
|
|
4399
|
+
}, {
|
|
4400
|
+
key: 'getAllLeafColumns',
|
|
4401
|
+
debug: instance.options.debug
|
|
4402
|
+
}),
|
|
3351
4403
|
getColumn: function getColumn(columnId) {
|
|
3352
4404
|
var column = instance.getAllFlatColumnsById()[columnId];
|
|
3353
4405
|
|
|
@@ -3373,7 +4425,7 @@ function createTableInstance(options, rerender) {
|
|
|
3373
4425
|
var columnSize = instance.getState().columnSizing[column.id];
|
|
3374
4426
|
return Math.min(Math.max((_column$minWidth = column.minWidth) != null ? _column$minWidth : defaultColumnSizing.minWidth, (_ref3 = columnSize != null ? columnSize : column.width) != null ? _ref3 : defaultColumnSizing.width), (_column$maxWidth = column.maxWidth) != null ? _column$maxWidth : defaultColumnSizing.maxWidth);
|
|
3375
4427
|
},
|
|
3376
|
-
createCell: function createCell
|
|
4428
|
+
createCell: function createCell(row, column, value) {
|
|
3377
4429
|
var cell = {
|
|
3378
4430
|
id: row.id + "_" + column.id,
|
|
3379
4431
|
rowId: row.id,
|
|
@@ -3386,16 +4438,20 @@ function createTableInstance(options, rerender) {
|
|
|
3386
4438
|
},
|
|
3387
4439
|
renderCell: function renderCell() {
|
|
3388
4440
|
return flexRender(column.cell, {
|
|
4441
|
+
instance: instance,
|
|
3389
4442
|
column: column,
|
|
4443
|
+
row: row,
|
|
3390
4444
|
cell: cell,
|
|
3391
4445
|
value: value
|
|
3392
4446
|
});
|
|
3393
4447
|
}
|
|
3394
4448
|
};
|
|
3395
|
-
|
|
4449
|
+
features.forEach(function (feature) {
|
|
4450
|
+
Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
|
|
4451
|
+
}, {});
|
|
3396
4452
|
return cell;
|
|
3397
4453
|
},
|
|
3398
|
-
createRow: function createRow
|
|
4454
|
+
createRow: function createRow(id, original, rowIndex, depth, values) {
|
|
3399
4455
|
var row = {
|
|
3400
4456
|
id: id,
|
|
3401
4457
|
index: rowIndex,
|
|
@@ -3416,7 +4472,10 @@ function createTableInstance(options, rerender) {
|
|
|
3416
4472
|
return leafColumns.map(function (column) {
|
|
3417
4473
|
return instance.createCell(row, column, row.values[column.id]);
|
|
3418
4474
|
});
|
|
3419
|
-
},
|
|
4475
|
+
}, {
|
|
4476
|
+
key: process.env.NODE_ENV !== 'production' ? 'row.getAllCells' : '',
|
|
4477
|
+
debug: instance.options.debug
|
|
4478
|
+
});
|
|
3420
4479
|
row.getAllCellsByColumnId = memo(function () {
|
|
3421
4480
|
return [row.getAllCells()];
|
|
3422
4481
|
}, function (allCells) {
|
|
@@ -3424,42 +4483,19 @@ function createTableInstance(options, rerender) {
|
|
|
3424
4483
|
acc[cell.columnId] = cell;
|
|
3425
4484
|
return acc;
|
|
3426
4485
|
}, {});
|
|
3427
|
-
},
|
|
3428
|
-
|
|
4486
|
+
}, {
|
|
4487
|
+
key: 'row.getAllCellsByColumnId',
|
|
4488
|
+
debug: instance.options.debug
|
|
4489
|
+
});
|
|
4490
|
+
features.forEach(function (feature) {
|
|
4491
|
+
Object.assign(row, feature.createRow == null ? void 0 : feature.createRow(row, instance));
|
|
4492
|
+
});
|
|
3429
4493
|
return row;
|
|
3430
4494
|
},
|
|
3431
4495
|
getCoreRowModel: memo(function () {
|
|
3432
4496
|
return [instance.options.data];
|
|
3433
4497
|
}, function (data) {
|
|
3434
|
-
if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Accessing...'); //
|
|
3435
|
-
|
|
3436
|
-
if (instance.options.autoResetColumnFilters && // @ts-ignore
|
|
3437
|
-
instance.getRowModelNonFirst) {
|
|
3438
|
-
instance.resetColumnFilters();
|
|
3439
|
-
}
|
|
3440
|
-
|
|
3441
|
-
if (instance.options.autoResetGlobalFilter && // @ts-ignore
|
|
3442
|
-
instance.getRowModelNonFirst) {
|
|
3443
|
-
instance.resetGlobalFilter();
|
|
3444
|
-
}
|
|
3445
|
-
|
|
3446
|
-
if (instance.options.autoResetSorting && // @ts-ignore
|
|
3447
|
-
instance.getRowModelNonFirst) {
|
|
3448
|
-
instance.resetSorting();
|
|
3449
|
-
}
|
|
3450
|
-
|
|
3451
|
-
if (instance.options.autoResetGrouping && // @ts-ignore
|
|
3452
|
-
instance.getRowModelNonFirst) {
|
|
3453
|
-
instance.resetGrouping();
|
|
3454
|
-
}
|
|
3455
|
-
|
|
3456
|
-
if (instance.options.autoResetExpanded && // @ts-ignore
|
|
3457
|
-
instance.getRowModelNonFirst) {
|
|
3458
|
-
instance.resetExpanded();
|
|
3459
|
-
} // @ts-ignore
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
instance.getRowModelNonFirst = true; // Access the row model using initial columns
|
|
4498
|
+
if (process.env.NODE_ENV !== 'production' && instance.options.debug) console.info('Accessing...'); // Access the row model using initial columns
|
|
3463
4499
|
|
|
3464
4500
|
var rows = [];
|
|
3465
4501
|
var flatRows = [];
|
|
@@ -3527,7 +4563,15 @@ function createTableInstance(options, rerender) {
|
|
|
3527
4563
|
flatRows: flatRows,
|
|
3528
4564
|
rowsById: rowsById
|
|
3529
4565
|
};
|
|
3530
|
-
},
|
|
4566
|
+
}, {
|
|
4567
|
+
key: 'getRowModel',
|
|
4568
|
+
debug: instance.options.debug,
|
|
4569
|
+
onChange: function onChange() {
|
|
4570
|
+
instance._notifyRowSelectionReset();
|
|
4571
|
+
|
|
4572
|
+
instance._notifyFiltersReset();
|
|
4573
|
+
}
|
|
4574
|
+
}),
|
|
3531
4575
|
// The standard
|
|
3532
4576
|
getCoreRows: function getCoreRows() {
|
|
3533
4577
|
return instance.getCoreRowModel().rows;
|
|
@@ -3541,7 +4585,7 @@ function createTableInstance(options, rerender) {
|
|
|
3541
4585
|
// The final calls start at the bottom of the model,
|
|
3542
4586
|
// expanded rows, which then work their way up
|
|
3543
4587
|
getRowModel: function getRowModel() {
|
|
3544
|
-
return instance.
|
|
4588
|
+
return instance.getPaginationRowModel();
|
|
3545
4589
|
},
|
|
3546
4590
|
getRows: function getRows() {
|
|
3547
4591
|
return instance.getRowModel().rows;
|
|
@@ -3652,7 +4696,13 @@ function createTableInstance(options, rerender) {
|
|
|
3652
4696
|
}
|
|
3653
4697
|
});
|
|
3654
4698
|
|
|
3655
|
-
|
|
4699
|
+
instance = Object.assign(instance, finalInstance); // This won't trigger a rerender yet, but it will force
|
|
4700
|
+
// pagination derivation to run (particularly pageSize detection)
|
|
4701
|
+
|
|
4702
|
+
instance.setPagination(function (d) {
|
|
4703
|
+
return d;
|
|
4704
|
+
});
|
|
4705
|
+
return instance;
|
|
3656
4706
|
}
|
|
3657
4707
|
|
|
3658
4708
|
function createTable() {
|
|
@@ -3672,7 +4722,17 @@ function createTable() {
|
|
|
3672
4722
|
createColumns: function createColumns(columns) {
|
|
3673
4723
|
return columns;
|
|
3674
4724
|
},
|
|
3675
|
-
|
|
4725
|
+
createDisplayColumn: function createDisplayColumn(column) {
|
|
4726
|
+
return _extends({}, column, {
|
|
4727
|
+
__generated: true
|
|
4728
|
+
});
|
|
4729
|
+
},
|
|
4730
|
+
createGroup: function createGroup(column) {
|
|
4731
|
+
return _extends({}, column, {
|
|
4732
|
+
__generated: true
|
|
4733
|
+
});
|
|
4734
|
+
},
|
|
4735
|
+
createDataColumn: function createDataColumn(accessor, column) {
|
|
3676
4736
|
column = _extends({}, column, {
|
|
3677
4737
|
id: column.id
|
|
3678
4738
|
});
|
|
@@ -3696,11 +4756,6 @@ function createTable() {
|
|
|
3696
4756
|
|
|
3697
4757
|
throw new Error('Invalid accessor');
|
|
3698
4758
|
},
|
|
3699
|
-
createGroup: function createGroup(column) {
|
|
3700
|
-
return _extends({}, column, {
|
|
3701
|
-
__generated: true
|
|
3702
|
-
});
|
|
3703
|
-
},
|
|
3704
4759
|
useTable: function useTable(options) {
|
|
3705
4760
|
var instanceRef = React.useRef(undefined);
|
|
3706
4761
|
var rerender = React.useReducer(function () {
|
|
@@ -3718,5 +4773,5 @@ function createTable() {
|
|
|
3718
4773
|
};
|
|
3719
4774
|
}
|
|
3720
4775
|
|
|
3721
|
-
export { columnFilterRowsFn, createTable, expandRowsFn, globalFilterRowsFn, groupRowsFn, sortRowsFn };
|
|
4776
|
+
export { columnFilterRowsFn, createTable, expandRowsFn, globalFilterRowsFn, groupRowsFn, paginateRowsFn, sortRowsFn };
|
|
3722
4777
|
//# sourceMappingURL=index.js.map
|