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