@tanstack/react-table 8.0.0-alpha.1 → 8.0.0-alpha.4
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 +118 -59
- 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 +317 -0
- package/build/cjs/features/ColumnSizing.js.map +1 -0
- 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 +88 -22
- package/build/cjs/features/Headers.js.map +1 -1
- package/build/cjs/features/Ordering.js +4 -1
- package/build/cjs/features/Ordering.js.map +1 -1
- package/build/cjs/features/Pagination.js +198 -0
- package/build/cjs/features/Pagination.js.map +1 -0
- package/build/cjs/features/Pinning.js +0 -14
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js +541 -0
- package/build/cjs/features/RowSelection.js.map +1 -0
- package/build/cjs/features/Sorting.js +76 -18
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +8 -2
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/index.js +2 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/sortTypes.js +1 -0
- package/build/cjs/sortTypes.js.map +1 -1
- package/build/cjs/utils/columnFilterRowsFn.js +3 -2
- package/build/cjs/utils/columnFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/expandRowsFn.js +2 -2
- package/build/cjs/utils/expandRowsFn.js.map +1 -1
- package/build/cjs/utils/globalFilterRowsFn.js +3 -2
- package/build/cjs/utils/globalFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/groupRowsFn.js +4 -3
- package/build/cjs/utils/groupRowsFn.js.map +1 -1
- package/build/cjs/utils/paginateRowsFn.js +44 -0
- package/build/cjs/utils/paginateRowsFn.js.map +1 -0
- package/build/cjs/utils/sortRowsFn.js +3 -2
- package/build/cjs/utils/sortRowsFn.js.map +1 -1
- package/build/cjs/utils.js +6 -3
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +1613 -225
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +363 -217
- package/build/types/core.d.ts +14 -25
- package/build/types/createTable.d.ts +21 -3
- package/build/types/features/ColumnSizing.d.ts +67 -0
- package/build/types/features/Expanding.d.ts +2 -1
- package/build/types/features/Filters.d.ts +7 -2
- package/build/types/features/Grouping.d.ts +2 -2
- package/build/types/features/Ordering.d.ts +1 -1
- package/build/types/features/Pagination.d.ts +44 -0
- package/build/types/features/Pinning.d.ts +3 -3
- package/build/types/features/RowSelection.d.ts +66 -0
- package/build/types/features/Sorting.d.ts +5 -2
- package/build/types/index.d.ts +1 -0
- package/build/types/sortTypes.d.ts +5 -4
- package/build/types/types.d.ts +13 -8
- 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 +7 -3
- package/build/umd/index.development.js +1613 -224
- 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 +252 -265
- package/src/createTable.tsx +69 -9
- package/src/features/ColumnSizing.ts +453 -0
- package/src/features/Expanding.ts +27 -11
- package/src/features/Filters.ts +75 -20
- package/src/features/Grouping.ts +27 -12
- package/src/features/Headers.ts +55 -50
- package/src/features/Ordering.ts +2 -3
- package/src/features/Pagination.ts +327 -0
- package/src/features/Pinning.ts +3 -16
- package/src/features/RowSelection.ts +831 -0
- package/src/features/Sorting.ts +82 -22
- package/src/features/Visibility.ts +2 -4
- package/src/index.tsx +1 -0
- package/src/sortTypes.ts +1 -1
- package/src/types.ts +55 -9
- 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 +20 -6
- package/src/features/withColumnResizing.oldts +0 -281
- 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,41 @@
|
|
|
672
679
|
flatRows: sortedRowModel.flatRows,
|
|
673
680
|
rowsById: sortedRowModel.rowsById
|
|
674
681
|
};
|
|
675
|
-
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
function paginateRowsFn(instance, rowModel) {
|
|
685
|
+
var _instance$getState$pa = instance.getState().pagination,
|
|
686
|
+
pageSize = _instance$getState$pa.pageSize,
|
|
687
|
+
pageIndex = _instance$getState$pa.pageIndex;
|
|
688
|
+
var rows = rowModel.rows,
|
|
689
|
+
flatRows = rowModel.flatRows,
|
|
690
|
+
rowsById = rowModel.rowsById;
|
|
691
|
+
var pageStart = pageSize * pageIndex;
|
|
692
|
+
var pageEnd = pageStart + pageSize;
|
|
693
|
+
rows = rows.slice(pageStart, pageEnd);
|
|
694
|
+
|
|
695
|
+
if (!instance.options.paginateExpandedRows) {
|
|
696
|
+
return expandRowsFn(instance, {
|
|
697
|
+
rows: rows,
|
|
698
|
+
flatRows: flatRows,
|
|
699
|
+
rowsById: rowsById
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
return {
|
|
704
|
+
rows: rows,
|
|
705
|
+
flatRows: flatRows,
|
|
706
|
+
rowsById: rowsById
|
|
707
|
+
};
|
|
708
|
+
}
|
|
676
709
|
|
|
677
710
|
//
|
|
678
|
-
function getInitialState$
|
|
711
|
+
function getInitialState$9() {
|
|
679
712
|
return {
|
|
680
713
|
columnVisibility: {}
|
|
681
714
|
};
|
|
682
715
|
}
|
|
683
|
-
function getDefaultOptions$
|
|
716
|
+
function getDefaultOptions$9(instance) {
|
|
684
717
|
return {
|
|
685
718
|
onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
|
|
686
719
|
};
|
|
@@ -690,7 +723,7 @@
|
|
|
690
723
|
defaultIsVisible: true
|
|
691
724
|
};
|
|
692
725
|
}
|
|
693
|
-
function createColumn$
|
|
726
|
+
function createColumn$5(column, instance) {
|
|
694
727
|
return {
|
|
695
728
|
getCanHide: function getCanHide() {
|
|
696
729
|
return instance.getColumnCanHide(column.id);
|
|
@@ -714,7 +747,7 @@
|
|
|
714
747
|
}
|
|
715
748
|
};
|
|
716
749
|
}
|
|
717
|
-
function getInstance$
|
|
750
|
+
function getInstance$a(instance) {
|
|
718
751
|
return {
|
|
719
752
|
getVisibleFlatColumns: memo(function () {
|
|
720
753
|
return [instance.getAllFlatColumns(), instance.getAllFlatColumns().filter(function (d) {
|
|
@@ -726,7 +759,10 @@
|
|
|
726
759
|
return allFlatColumns.filter(function (d) {
|
|
727
760
|
return d.getIsVisible == null ? void 0 : d.getIsVisible();
|
|
728
761
|
});
|
|
729
|
-
},
|
|
762
|
+
}, {
|
|
763
|
+
key: 'getVisibleFlatColumns',
|
|
764
|
+
debug: instance.options.debug
|
|
765
|
+
}),
|
|
730
766
|
getVisibleLeafColumns: memo(function () {
|
|
731
767
|
return [instance.getAllLeafColumns(), instance.getAllLeafColumns().filter(function (d) {
|
|
732
768
|
return d.getIsVisible == null ? void 0 : d.getIsVisible();
|
|
@@ -737,7 +773,10 @@
|
|
|
737
773
|
return allFlatColumns.filter(function (d) {
|
|
738
774
|
return d.getIsVisible == null ? void 0 : d.getIsVisible();
|
|
739
775
|
});
|
|
740
|
-
},
|
|
776
|
+
}, {
|
|
777
|
+
key: 'getVisibleLeafColumns',
|
|
778
|
+
debug: instance.options.debug
|
|
779
|
+
}),
|
|
741
780
|
setColumnVisibility: function setColumnVisibility(updater) {
|
|
742
781
|
return instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater, functionalUpdate(updater, instance.getState().columnVisibility));
|
|
743
782
|
},
|
|
@@ -811,6 +850,15 @@
|
|
|
811
850
|
};
|
|
812
851
|
}
|
|
813
852
|
|
|
853
|
+
var Visibility = /*#__PURE__*/Object.freeze({
|
|
854
|
+
__proto__: null,
|
|
855
|
+
getInitialState: getInitialState$9,
|
|
856
|
+
getDefaultOptions: getDefaultOptions$9,
|
|
857
|
+
getDefaultColumn: getDefaultColumn$3,
|
|
858
|
+
createColumn: createColumn$5,
|
|
859
|
+
getInstance: getInstance$a
|
|
860
|
+
});
|
|
861
|
+
|
|
814
862
|
var aggregationTypes = {
|
|
815
863
|
sum: sum,
|
|
816
864
|
min: min,
|
|
@@ -929,19 +977,19 @@
|
|
|
929
977
|
aggregationType: 'auto'
|
|
930
978
|
};
|
|
931
979
|
}
|
|
932
|
-
function getInitialState$
|
|
980
|
+
function getInitialState$8() {
|
|
933
981
|
return {
|
|
934
982
|
grouping: []
|
|
935
983
|
};
|
|
936
984
|
}
|
|
937
|
-
function getDefaultOptions$
|
|
985
|
+
function getDefaultOptions$8(instance) {
|
|
938
986
|
return {
|
|
939
987
|
onGroupingChange: makeStateUpdater('grouping', instance),
|
|
940
988
|
autoResetGrouping: true,
|
|
941
989
|
groupedColumnMode: 'reorder'
|
|
942
990
|
};
|
|
943
991
|
}
|
|
944
|
-
function createColumn$
|
|
992
|
+
function createColumn$4(column, instance) {
|
|
945
993
|
return {
|
|
946
994
|
aggregationType: column.aggregationType,
|
|
947
995
|
getCanGroup: function getCanGroup() {
|
|
@@ -961,8 +1009,23 @@
|
|
|
961
1009
|
}
|
|
962
1010
|
};
|
|
963
1011
|
}
|
|
964
|
-
function getInstance$
|
|
1012
|
+
function getInstance$9(instance) {
|
|
1013
|
+
var registered = false;
|
|
965
1014
|
return {
|
|
1015
|
+
_notifyGroupingReset: function _notifyGroupingReset() {
|
|
1016
|
+
if (!registered) {
|
|
1017
|
+
registered = true;
|
|
1018
|
+
return;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
if (instance.options.autoResetAll === false) {
|
|
1022
|
+
return;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
if (instance.options.autoResetAll === true || instance.options.autoResetGrouping) {
|
|
1026
|
+
instance.resetGrouping();
|
|
1027
|
+
}
|
|
1028
|
+
},
|
|
966
1029
|
getColumnAutoAggregationFn: function getColumnAutoAggregationFn(columnId) {
|
|
967
1030
|
var firstRow = instance.getCoreFlatRows()[0];
|
|
968
1031
|
var value = firstRow == null ? void 0 : firstRow.values[columnId];
|
|
@@ -1060,8 +1123,14 @@
|
|
|
1060
1123
|
}
|
|
1061
1124
|
|
|
1062
1125
|
if (instance.options.debug) console.info('Grouping...');
|
|
1063
|
-
return groupRowsFn(instance,
|
|
1064
|
-
},
|
|
1126
|
+
return groupRowsFn(instance, rowModel);
|
|
1127
|
+
}, {
|
|
1128
|
+
key: 'getGroupedRowModel',
|
|
1129
|
+
debug: instance.options.debug,
|
|
1130
|
+
onChange: function onChange() {
|
|
1131
|
+
return instance._notifyExpandedReset();
|
|
1132
|
+
}
|
|
1133
|
+
}),
|
|
1065
1134
|
getPreGroupedRows: function getPreGroupedRows() {
|
|
1066
1135
|
return instance.getSortedRowModel().rows;
|
|
1067
1136
|
},
|
|
@@ -1082,7 +1151,7 @@
|
|
|
1082
1151
|
}
|
|
1083
1152
|
};
|
|
1084
1153
|
}
|
|
1085
|
-
function createRow$
|
|
1154
|
+
function createRow$3(row, instance) {
|
|
1086
1155
|
return {
|
|
1087
1156
|
getIsGrouped: function getIsGrouped() {
|
|
1088
1157
|
return instance.getRowIsGrouped(row.id);
|
|
@@ -1125,18 +1194,30 @@
|
|
|
1125
1194
|
return [].concat(groupingColumns, nonGroupingColumns);
|
|
1126
1195
|
}
|
|
1127
1196
|
|
|
1197
|
+
var Grouping = /*#__PURE__*/Object.freeze({
|
|
1198
|
+
__proto__: null,
|
|
1199
|
+
getDefaultColumn: getDefaultColumn$2,
|
|
1200
|
+
getInitialState: getInitialState$8,
|
|
1201
|
+
getDefaultOptions: getDefaultOptions$8,
|
|
1202
|
+
createColumn: createColumn$4,
|
|
1203
|
+
getInstance: getInstance$9,
|
|
1204
|
+
createRow: createRow$3,
|
|
1205
|
+
createCell: createCell,
|
|
1206
|
+
orderColumns: orderColumns
|
|
1207
|
+
});
|
|
1208
|
+
|
|
1128
1209
|
//
|
|
1129
|
-
function getInitialState$
|
|
1210
|
+
function getInitialState$7() {
|
|
1130
1211
|
return {
|
|
1131
1212
|
columnOrder: []
|
|
1132
1213
|
};
|
|
1133
1214
|
}
|
|
1134
|
-
function getDefaultOptions$
|
|
1215
|
+
function getDefaultOptions$7(instance) {
|
|
1135
1216
|
return {
|
|
1136
1217
|
onColumnOrderChange: makeStateUpdater('columnOrder', instance)
|
|
1137
1218
|
};
|
|
1138
1219
|
}
|
|
1139
|
-
function getInstance$
|
|
1220
|
+
function getInstance$8(instance) {
|
|
1140
1221
|
return {
|
|
1141
1222
|
setColumnOrder: function setColumnOrder(updater) {
|
|
1142
1223
|
return instance.options.onColumnOrderChange == null ? void 0 : instance.options.onColumnOrderChange(updater, functionalUpdate(updater, instance.getState().columnOrder));
|
|
@@ -1183,12 +1264,22 @@
|
|
|
1183
1264
|
|
|
1184
1265
|
return orderColumns(orderedColumns, grouping, groupedColumnMode);
|
|
1185
1266
|
};
|
|
1186
|
-
},
|
|
1267
|
+
}, {
|
|
1268
|
+
key: 'getOrderColumnsFn',
|
|
1269
|
+
debug: instance.options.debug
|
|
1270
|
+
})
|
|
1187
1271
|
};
|
|
1188
1272
|
}
|
|
1189
1273
|
|
|
1274
|
+
var Ordering = /*#__PURE__*/Object.freeze({
|
|
1275
|
+
__proto__: null,
|
|
1276
|
+
getInitialState: getInitialState$7,
|
|
1277
|
+
getDefaultOptions: getDefaultOptions$7,
|
|
1278
|
+
getInstance: getInstance$8
|
|
1279
|
+
});
|
|
1280
|
+
|
|
1190
1281
|
//
|
|
1191
|
-
function getInitialState$
|
|
1282
|
+
function getInitialState$6() {
|
|
1192
1283
|
return {
|
|
1193
1284
|
columnPinning: {
|
|
1194
1285
|
left: [],
|
|
@@ -1196,12 +1287,12 @@
|
|
|
1196
1287
|
}
|
|
1197
1288
|
};
|
|
1198
1289
|
}
|
|
1199
|
-
function getDefaultOptions$
|
|
1290
|
+
function getDefaultOptions$6(instance) {
|
|
1200
1291
|
return {
|
|
1201
1292
|
onColumnPinningChange: makeStateUpdater('columnPinning', instance)
|
|
1202
1293
|
};
|
|
1203
1294
|
}
|
|
1204
|
-
function createColumn$
|
|
1295
|
+
function createColumn$3(column, instance) {
|
|
1205
1296
|
return {
|
|
1206
1297
|
getCanPin: function getCanPin() {
|
|
1207
1298
|
return instance.getColumnCanPin(column.id);
|
|
@@ -1217,7 +1308,7 @@
|
|
|
1217
1308
|
}
|
|
1218
1309
|
};
|
|
1219
1310
|
}
|
|
1220
|
-
function getInstance$
|
|
1311
|
+
function getInstance$7(instance) {
|
|
1221
1312
|
return {
|
|
1222
1313
|
setColumnPinning: function setColumnPinning(updater) {
|
|
1223
1314
|
return instance.options.onColumnPinningChange == null ? void 0 : instance.options.onColumnPinningChange(updater, functionalUpdate(updater, instance.getState().columnPinning));
|
|
@@ -1304,33 +1395,27 @@
|
|
|
1304
1395
|
var isRight = leafColumnIds.some(function (d) {
|
|
1305
1396
|
return right == null ? void 0 : right.includes(d);
|
|
1306
1397
|
});
|
|
1307
|
-
|
|
1308
|
-
if (isLeft && isRight) {
|
|
1309
|
-
return 'both';
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1312
1398
|
return isLeft ? 'left' : isRight ? 'right' : false;
|
|
1313
1399
|
},
|
|
1314
1400
|
getColumnPinnedIndex: function getColumnPinnedIndex(columnId) {
|
|
1315
1401
|
var _instance$getState$co2, _instance$getState$co3, _instance$getState$co4;
|
|
1316
1402
|
|
|
1317
1403
|
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
1404
|
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
1405
|
}
|
|
1329
1406
|
};
|
|
1330
1407
|
}
|
|
1331
1408
|
|
|
1409
|
+
var Pinning = /*#__PURE__*/Object.freeze({
|
|
1410
|
+
__proto__: null,
|
|
1411
|
+
getInitialState: getInitialState$6,
|
|
1412
|
+
getDefaultOptions: getDefaultOptions$6,
|
|
1413
|
+
createColumn: createColumn$3,
|
|
1414
|
+
getInstance: getInstance$7
|
|
1415
|
+
});
|
|
1416
|
+
|
|
1332
1417
|
//
|
|
1333
|
-
function createRow$
|
|
1418
|
+
function createRow$2(row, instance) {
|
|
1334
1419
|
return {
|
|
1335
1420
|
_getAllVisibleCells: memo(function () {
|
|
1336
1421
|
return [row.getAllCells().filter(function (cell) {
|
|
@@ -1342,12 +1427,18 @@
|
|
|
1342
1427
|
return row.getAllCells().filter(function (cell) {
|
|
1343
1428
|
return cell.column.getIsVisible();
|
|
1344
1429
|
});
|
|
1345
|
-
},
|
|
1430
|
+
}, {
|
|
1431
|
+
key: 'row._getAllVisibleCells',
|
|
1432
|
+
debug: instance.options.debug
|
|
1433
|
+
}),
|
|
1346
1434
|
getVisibleCells: memo(function () {
|
|
1347
1435
|
return [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()];
|
|
1348
1436
|
}, function (left, center, right) {
|
|
1349
1437
|
return [].concat(left, center, right);
|
|
1350
|
-
},
|
|
1438
|
+
}, {
|
|
1439
|
+
key: 'row.getVisibleCells',
|
|
1440
|
+
debug: instance.options.debug
|
|
1441
|
+
}),
|
|
1351
1442
|
getCenterVisibleCells: memo(function () {
|
|
1352
1443
|
return [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
|
|
1353
1444
|
}, function (allCells, left, right) {
|
|
@@ -1355,7 +1446,10 @@
|
|
|
1355
1446
|
return allCells.filter(function (d) {
|
|
1356
1447
|
return !leftAndRight.includes(d.columnId);
|
|
1357
1448
|
});
|
|
1358
|
-
},
|
|
1449
|
+
}, {
|
|
1450
|
+
key: 'row.getCenterVisibleCells',
|
|
1451
|
+
debug: instance.options.debug
|
|
1452
|
+
}),
|
|
1359
1453
|
getLeftVisibleCells: memo(function () {
|
|
1360
1454
|
return [row._getAllVisibleCells(), instance.getState().columnPinning.left,,];
|
|
1361
1455
|
}, function (allCells, left) {
|
|
@@ -1365,7 +1459,10 @@
|
|
|
1365
1459
|
});
|
|
1366
1460
|
}).filter(Boolean);
|
|
1367
1461
|
return cells;
|
|
1368
|
-
},
|
|
1462
|
+
}, {
|
|
1463
|
+
key: 'row.getLeftVisibleCells',
|
|
1464
|
+
debug: instance.options.debug
|
|
1465
|
+
}),
|
|
1369
1466
|
getRightVisibleCells: memo(function () {
|
|
1370
1467
|
return [row._getAllVisibleCells(), instance.getState().columnPinning.right];
|
|
1371
1468
|
}, function (allCells, right) {
|
|
@@ -1375,10 +1472,13 @@
|
|
|
1375
1472
|
});
|
|
1376
1473
|
}).filter(Boolean);
|
|
1377
1474
|
return cells;
|
|
1378
|
-
},
|
|
1475
|
+
}, {
|
|
1476
|
+
key: 'row.getRightVisibleCells',
|
|
1477
|
+
debug: instance.options.debug
|
|
1478
|
+
})
|
|
1379
1479
|
};
|
|
1380
1480
|
}
|
|
1381
|
-
function getInstance$
|
|
1481
|
+
function getInstance$6(instance) {
|
|
1382
1482
|
return {
|
|
1383
1483
|
createHeader: function createHeader(column, options) {
|
|
1384
1484
|
var _options$id;
|
|
@@ -1431,17 +1531,20 @@
|
|
|
1431
1531
|
},
|
|
1432
1532
|
renderHeader: function renderHeader() {
|
|
1433
1533
|
return flexRender(column.header, {
|
|
1534
|
+
instance: instance,
|
|
1434
1535
|
header: header,
|
|
1435
1536
|
column: column
|
|
1436
1537
|
});
|
|
1437
1538
|
},
|
|
1438
1539
|
renderFooter: function renderFooter() {
|
|
1439
1540
|
return flexRender(column.footer, {
|
|
1541
|
+
instance: instance,
|
|
1440
1542
|
header: header,
|
|
1441
1543
|
column: column
|
|
1442
1544
|
});
|
|
1443
1545
|
}
|
|
1444
|
-
};
|
|
1546
|
+
}; // Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
1547
|
+
|
|
1445
1548
|
return header;
|
|
1446
1549
|
},
|
|
1447
1550
|
// Header Groups
|
|
@@ -1459,7 +1562,10 @@
|
|
|
1459
1562
|
});
|
|
1460
1563
|
var headerGroups = buildHeaderGroups(allColumns, [].concat(leftColumns, centerColumns, rightColumns), instance);
|
|
1461
1564
|
return headerGroups;
|
|
1462
|
-
},
|
|
1565
|
+
}, {
|
|
1566
|
+
key: 'getHeaderGroups',
|
|
1567
|
+
debug: instance.options.debug
|
|
1568
|
+
}),
|
|
1463
1569
|
getCenterHeaderGroups: memo(function () {
|
|
1464
1570
|
return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
|
|
1465
1571
|
}, function (allColumns, leafColumns, left, right) {
|
|
@@ -1467,7 +1573,10 @@
|
|
|
1467
1573
|
return !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id));
|
|
1468
1574
|
});
|
|
1469
1575
|
return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
|
|
1470
|
-
},
|
|
1576
|
+
}, {
|
|
1577
|
+
key: 'getCenterHeaderGroups',
|
|
1578
|
+
debug: instance.options.debug
|
|
1579
|
+
}),
|
|
1471
1580
|
getLeftHeaderGroups: memo(function () {
|
|
1472
1581
|
return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left];
|
|
1473
1582
|
}, function (allColumns, leafColumns, left) {
|
|
@@ -1475,7 +1584,10 @@
|
|
|
1475
1584
|
return left == null ? void 0 : left.includes(column.id);
|
|
1476
1585
|
});
|
|
1477
1586
|
return buildHeaderGroups(allColumns, leafColumns, instance, 'left');
|
|
1478
|
-
},
|
|
1587
|
+
}, {
|
|
1588
|
+
key: 'getLeftHeaderGroups',
|
|
1589
|
+
debug: instance.options.debug
|
|
1590
|
+
}),
|
|
1479
1591
|
getRightHeaderGroups: memo(function () {
|
|
1480
1592
|
return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right];
|
|
1481
1593
|
}, function (allColumns, leafColumns, right) {
|
|
@@ -1483,28 +1595,43 @@
|
|
|
1483
1595
|
return right == null ? void 0 : right.includes(column.id);
|
|
1484
1596
|
});
|
|
1485
1597
|
return buildHeaderGroups(allColumns, leafColumns, instance, 'right');
|
|
1486
|
-
},
|
|
1598
|
+
}, {
|
|
1599
|
+
key: 'getRightHeaderGroups',
|
|
1600
|
+
debug: instance.options.debug
|
|
1601
|
+
}),
|
|
1487
1602
|
// Footer Groups
|
|
1488
1603
|
getFooterGroups: memo(function () {
|
|
1489
1604
|
return [instance.getHeaderGroups()];
|
|
1490
1605
|
}, function (headerGroups) {
|
|
1491
1606
|
return [].concat(headerGroups).reverse();
|
|
1492
|
-
},
|
|
1607
|
+
}, {
|
|
1608
|
+
key: 'getFooterGroups',
|
|
1609
|
+
debug: instance.options.debug
|
|
1610
|
+
}),
|
|
1493
1611
|
getLeftFooterGroups: memo(function () {
|
|
1494
1612
|
return [instance.getLeftHeaderGroups()];
|
|
1495
1613
|
}, function (headerGroups) {
|
|
1496
1614
|
return [].concat(headerGroups).reverse();
|
|
1497
|
-
},
|
|
1615
|
+
}, {
|
|
1616
|
+
key: 'getLeftFooterGroups',
|
|
1617
|
+
debug: instance.options.debug
|
|
1618
|
+
}),
|
|
1498
1619
|
getCenterFooterGroups: memo(function () {
|
|
1499
1620
|
return [instance.getCenterHeaderGroups()];
|
|
1500
1621
|
}, function (headerGroups) {
|
|
1501
1622
|
return [].concat(headerGroups).reverse();
|
|
1502
|
-
},
|
|
1623
|
+
}, {
|
|
1624
|
+
key: 'getCenterFooterGroups',
|
|
1625
|
+
debug: instance.options.debug
|
|
1626
|
+
}),
|
|
1503
1627
|
getRightFooterGroups: memo(function () {
|
|
1504
1628
|
return [instance.getRightHeaderGroups()];
|
|
1505
1629
|
}, function (headerGroups) {
|
|
1506
1630
|
return [].concat(headerGroups).reverse();
|
|
1507
|
-
},
|
|
1631
|
+
}, {
|
|
1632
|
+
key: 'getRightFooterGroups',
|
|
1633
|
+
debug: instance.options.debug
|
|
1634
|
+
}),
|
|
1508
1635
|
// Flat Headers
|
|
1509
1636
|
getFlatHeaders: memo(function () {
|
|
1510
1637
|
return [instance.getHeaderGroups()];
|
|
@@ -1512,28 +1639,40 @@
|
|
|
1512
1639
|
return headerGroups.map(function (headerGroup) {
|
|
1513
1640
|
return headerGroup.headers;
|
|
1514
1641
|
}).flat();
|
|
1515
|
-
},
|
|
1642
|
+
}, {
|
|
1643
|
+
key: 'getFlatHeaders',
|
|
1644
|
+
debug: instance.options.debug
|
|
1645
|
+
}),
|
|
1516
1646
|
getLeftFlatHeaders: memo(function () {
|
|
1517
1647
|
return [instance.getLeftHeaderGroups()];
|
|
1518
1648
|
}, function (left) {
|
|
1519
1649
|
return left.map(function (headerGroup) {
|
|
1520
1650
|
return headerGroup.headers;
|
|
1521
1651
|
}).flat();
|
|
1522
|
-
},
|
|
1652
|
+
}, {
|
|
1653
|
+
key: 'getLeftFlatHeaders',
|
|
1654
|
+
debug: instance.options.debug
|
|
1655
|
+
}),
|
|
1523
1656
|
getCenterFlatHeaders: memo(function () {
|
|
1524
1657
|
return [instance.getCenterHeaderGroups()];
|
|
1525
1658
|
}, function (left) {
|
|
1526
1659
|
return left.map(function (headerGroup) {
|
|
1527
1660
|
return headerGroup.headers;
|
|
1528
1661
|
}).flat();
|
|
1529
|
-
},
|
|
1662
|
+
}, {
|
|
1663
|
+
key: 'getCenterFlatHeaders',
|
|
1664
|
+
debug: instance.options.debug
|
|
1665
|
+
}),
|
|
1530
1666
|
getRightFlatHeaders: memo(function () {
|
|
1531
1667
|
return [instance.getRightHeaderGroups()];
|
|
1532
1668
|
}, function (left) {
|
|
1533
1669
|
return left.map(function (headerGroup) {
|
|
1534
1670
|
return headerGroup.headers;
|
|
1535
1671
|
}).flat();
|
|
1536
|
-
},
|
|
1672
|
+
}, {
|
|
1673
|
+
key: 'getRightFlatHeaders',
|
|
1674
|
+
debug: instance.options.debug
|
|
1675
|
+
}),
|
|
1537
1676
|
// Leaf Headers
|
|
1538
1677
|
getCenterLeafHeaders: memo(function () {
|
|
1539
1678
|
return [instance.getCenterFlatHeaders()];
|
|
@@ -1543,7 +1682,10 @@
|
|
|
1543
1682
|
|
|
1544
1683
|
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
|
1545
1684
|
});
|
|
1546
|
-
},
|
|
1685
|
+
}, {
|
|
1686
|
+
key: 'getCenterLeafHeaders',
|
|
1687
|
+
debug: instance.options.debug
|
|
1688
|
+
}),
|
|
1547
1689
|
getLeftLeafHeaders: memo(function () {
|
|
1548
1690
|
return [instance.getLeftFlatHeaders()];
|
|
1549
1691
|
}, function (flatHeaders) {
|
|
@@ -1552,7 +1694,10 @@
|
|
|
1552
1694
|
|
|
1553
1695
|
return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
|
|
1554
1696
|
});
|
|
1555
|
-
},
|
|
1697
|
+
}, {
|
|
1698
|
+
key: 'getLeftLeafHeaders',
|
|
1699
|
+
debug: instance.options.debug
|
|
1700
|
+
}),
|
|
1556
1701
|
getRightLeafHeaders: memo(function () {
|
|
1557
1702
|
return [instance.getRightFlatHeaders()];
|
|
1558
1703
|
}, function (flatHeaders) {
|
|
@@ -1561,7 +1706,10 @@
|
|
|
1561
1706
|
|
|
1562
1707
|
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
|
1563
1708
|
});
|
|
1564
|
-
},
|
|
1709
|
+
}, {
|
|
1710
|
+
key: 'getRightLeafHeaders',
|
|
1711
|
+
debug: instance.options.debug
|
|
1712
|
+
}),
|
|
1565
1713
|
getLeafHeaders: memo(function () {
|
|
1566
1714
|
return [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()];
|
|
1567
1715
|
}, function (left, center, right) {
|
|
@@ -1570,7 +1718,10 @@
|
|
|
1570
1718
|
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) {
|
|
1571
1719
|
return header.getLeafHeaders();
|
|
1572
1720
|
}).flat();
|
|
1573
|
-
},
|
|
1721
|
+
}, {
|
|
1722
|
+
key: 'getLeafHeaders',
|
|
1723
|
+
debug: instance.options.debug
|
|
1724
|
+
}),
|
|
1574
1725
|
getHeader: function getHeader(id) {
|
|
1575
1726
|
var header = [].concat(instance.getFlatHeaders(), instance.getCenterFlatHeaders(), instance.getLeftFlatHeaders(), instance.getRightFlatHeaders()).find(function (d) {
|
|
1576
1727
|
return d.id === id;
|
|
@@ -1792,6 +1943,13 @@
|
|
|
1792
1943
|
return headerGroups;
|
|
1793
1944
|
}
|
|
1794
1945
|
|
|
1946
|
+
var Headers = /*#__PURE__*/Object.freeze({
|
|
1947
|
+
__proto__: null,
|
|
1948
|
+
createRow: createRow$2,
|
|
1949
|
+
getInstance: getInstance$6,
|
|
1950
|
+
buildHeaderGroups: buildHeaderGroups
|
|
1951
|
+
});
|
|
1952
|
+
|
|
1795
1953
|
var filterTypes = {
|
|
1796
1954
|
includesString: includesString,
|
|
1797
1955
|
includesStringSensitive: includesStringSensitive,
|
|
@@ -1954,13 +2112,13 @@
|
|
|
1954
2112
|
filterType: 'auto'
|
|
1955
2113
|
};
|
|
1956
2114
|
}
|
|
1957
|
-
function getInitialState$
|
|
2115
|
+
function getInitialState$5() {
|
|
1958
2116
|
return {
|
|
1959
2117
|
columnFilters: [],
|
|
1960
2118
|
globalFilter: undefined
|
|
1961
2119
|
};
|
|
1962
2120
|
}
|
|
1963
|
-
function getDefaultOptions$
|
|
2121
|
+
function getDefaultOptions$5(instance) {
|
|
1964
2122
|
return {
|
|
1965
2123
|
onColumnFiltersChange: makeStateUpdater('columnFilters', instance),
|
|
1966
2124
|
onGlobalFilterChange: makeStateUpdater('globalFilter', instance),
|
|
@@ -1976,7 +2134,7 @@
|
|
|
1976
2134
|
}
|
|
1977
2135
|
};
|
|
1978
2136
|
}
|
|
1979
|
-
function createColumn$
|
|
2137
|
+
function createColumn$2(column, instance) {
|
|
1980
2138
|
var getFacetInfo = memo(function () {
|
|
1981
2139
|
return [column.getPreFilteredRows()];
|
|
1982
2140
|
}, function (rows) {
|
|
@@ -2013,7 +2171,10 @@
|
|
|
2013
2171
|
preFilteredUniqueValues: preFilteredUniqueValues,
|
|
2014
2172
|
preFilteredMinMaxValues: preFilteredMinMaxValues
|
|
2015
2173
|
};
|
|
2016
|
-
},
|
|
2174
|
+
}, {
|
|
2175
|
+
key: 'column.getFacetInfo',
|
|
2176
|
+
debug: instance.options.debug
|
|
2177
|
+
});
|
|
2017
2178
|
return {
|
|
2018
2179
|
filterType: column.filterType,
|
|
2019
2180
|
getCanColumnFilter: function getCanColumnFilter() {
|
|
@@ -2045,8 +2206,31 @@
|
|
|
2045
2206
|
}
|
|
2046
2207
|
};
|
|
2047
2208
|
}
|
|
2048
|
-
function getInstance$
|
|
2209
|
+
function getInstance$5(instance) {
|
|
2210
|
+
var registered = false;
|
|
2049
2211
|
return {
|
|
2212
|
+
_notifyFiltersReset: function _notifyFiltersReset() {
|
|
2213
|
+
if (!registered) {
|
|
2214
|
+
registered = true;
|
|
2215
|
+
return;
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2218
|
+
if (instance.options.autoResetAll === false) {
|
|
2219
|
+
return;
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
if (instance.options.autoResetAll === true) {
|
|
2223
|
+
instance.resetSorting();
|
|
2224
|
+
} else {
|
|
2225
|
+
if (instance.options.autoResetColumnFilters) {
|
|
2226
|
+
instance.resetColumnFilters();
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2229
|
+
if (instance.options.autoResetGlobalFilter) {
|
|
2230
|
+
instance.resetGlobalFilter();
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
},
|
|
2050
2234
|
getColumnAutoFilterFn: function getColumnAutoFilterFn(columnId) {
|
|
2051
2235
|
var firstRow = instance.getCoreFlatRows()[0];
|
|
2052
2236
|
var value = firstRow == null ? void 0 : firstRow.values[columnId];
|
|
@@ -2227,7 +2411,7 @@
|
|
|
2227
2411
|
}
|
|
2228
2412
|
|
|
2229
2413
|
if (instance.options.debug) console.info('Column Filtering...');
|
|
2230
|
-
return columnFiltersFn(instance,
|
|
2414
|
+
return columnFiltersFn(instance, rowModel);
|
|
2231
2415
|
}(); // Now that each filtered column has it's partially filtered rows,
|
|
2232
2416
|
// lets assign the final filtered rows to all of the other columns
|
|
2233
2417
|
|
|
@@ -2247,7 +2431,24 @@
|
|
|
2247
2431
|
};
|
|
2248
2432
|
});
|
|
2249
2433
|
return columnFilteredRowModel;
|
|
2250
|
-
},
|
|
2434
|
+
}, {
|
|
2435
|
+
key: 'getColumnFilteredRowModel',
|
|
2436
|
+
debug: instance.options.debug
|
|
2437
|
+
}),
|
|
2438
|
+
// These might be easier to remember than "column" filtered rows
|
|
2439
|
+
getPreFilteredRowModel: function getPreFilteredRowModel() {
|
|
2440
|
+
return instance.getCoreRowModel();
|
|
2441
|
+
},
|
|
2442
|
+
getPreFilteredRows: function getPreFilteredRows() {
|
|
2443
|
+
return instance.getCoreRowModel().rows;
|
|
2444
|
+
},
|
|
2445
|
+
getPreFilteredFlatRows: function getPreFilteredFlatRows() {
|
|
2446
|
+
return instance.getCoreRowModel().flatRows;
|
|
2447
|
+
},
|
|
2448
|
+
getPreFilteredRowsById: function getPreFilteredRowsById() {
|
|
2449
|
+
return instance.getCoreRowModel().rowsById;
|
|
2450
|
+
},
|
|
2451
|
+
// Pre Column Filter
|
|
2251
2452
|
getPreColumnFilteredRows: function getPreColumnFilteredRows() {
|
|
2252
2453
|
return instance.getCoreRowModel().rows;
|
|
2253
2454
|
},
|
|
@@ -2275,7 +2476,7 @@
|
|
|
2275
2476
|
}
|
|
2276
2477
|
|
|
2277
2478
|
if (instance.options.debug) console.info('Global Filtering...');
|
|
2278
|
-
return globalFiltersFn(instance,
|
|
2479
|
+
return globalFiltersFn(instance, columnFilteredRowModel);
|
|
2279
2480
|
}(); // Now that each filtered column has it's partially filtered rows,
|
|
2280
2481
|
// lets assign the final filtered rows to all of the other columns
|
|
2281
2482
|
|
|
@@ -2295,7 +2496,13 @@
|
|
|
2295
2496
|
};
|
|
2296
2497
|
});
|
|
2297
2498
|
return globalFilteredRowModel;
|
|
2298
|
-
},
|
|
2499
|
+
}, {
|
|
2500
|
+
key: 'getGlobalFilteredRowModel',
|
|
2501
|
+
debug: instance.options.debug,
|
|
2502
|
+
onChange: function onChange() {
|
|
2503
|
+
return instance._notifySortingReset();
|
|
2504
|
+
}
|
|
2505
|
+
}),
|
|
2299
2506
|
getPreGlobalFilteredRows: function getPreGlobalFilteredRows() {
|
|
2300
2507
|
return instance.getColumnFilteredRowModel().rows;
|
|
2301
2508
|
},
|
|
@@ -2320,6 +2527,16 @@
|
|
|
2320
2527
|
return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
|
|
2321
2528
|
}
|
|
2322
2529
|
|
|
2530
|
+
var Filters = /*#__PURE__*/Object.freeze({
|
|
2531
|
+
__proto__: null,
|
|
2532
|
+
getDefaultColumn: getDefaultColumn$1,
|
|
2533
|
+
getInitialState: getInitialState$5,
|
|
2534
|
+
getDefaultOptions: getDefaultOptions$5,
|
|
2535
|
+
createColumn: createColumn$2,
|
|
2536
|
+
getInstance: getInstance$5,
|
|
2537
|
+
shouldAutoRemoveFilter: shouldAutoRemoveFilter
|
|
2538
|
+
});
|
|
2539
|
+
|
|
2323
2540
|
var reSplitAlphaNumeric = /([0-9]+)/gm;
|
|
2324
2541
|
var sortTypes = {
|
|
2325
2542
|
alphanumeric: alphanumeric,
|
|
@@ -2431,18 +2648,21 @@
|
|
|
2431
2648
|
sortType: 'auto'
|
|
2432
2649
|
};
|
|
2433
2650
|
}
|
|
2434
|
-
function getInitialState$
|
|
2651
|
+
function getInitialState$4() {
|
|
2435
2652
|
return {
|
|
2436
2653
|
sorting: []
|
|
2437
2654
|
};
|
|
2438
2655
|
}
|
|
2439
|
-
function getDefaultOptions$
|
|
2656
|
+
function getDefaultOptions$4(instance) {
|
|
2440
2657
|
return {
|
|
2441
2658
|
onSortingChange: makeStateUpdater('sorting', instance),
|
|
2442
|
-
autoResetSorting: true
|
|
2659
|
+
autoResetSorting: true,
|
|
2660
|
+
isMultiSortEvent: function isMultiSortEvent(e) {
|
|
2661
|
+
return e.shiftKey;
|
|
2662
|
+
}
|
|
2443
2663
|
};
|
|
2444
2664
|
}
|
|
2445
|
-
function createColumn(column, instance) {
|
|
2665
|
+
function createColumn$1(column, instance) {
|
|
2446
2666
|
return {
|
|
2447
2667
|
sortType: column.sortType,
|
|
2448
2668
|
getCanSort: function getCanSort() {
|
|
@@ -2465,22 +2685,60 @@
|
|
|
2465
2685
|
}
|
|
2466
2686
|
};
|
|
2467
2687
|
}
|
|
2468
|
-
function getInstance$
|
|
2688
|
+
function getInstance$4(instance) {
|
|
2689
|
+
var registered = false;
|
|
2469
2690
|
return {
|
|
2691
|
+
_notifySortingReset: function _notifySortingReset() {
|
|
2692
|
+
if (!registered) {
|
|
2693
|
+
registered = true;
|
|
2694
|
+
return;
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2697
|
+
if (instance.options.autoResetAll === false) {
|
|
2698
|
+
return;
|
|
2699
|
+
}
|
|
2700
|
+
|
|
2701
|
+
if (instance.options.autoResetAll === true || instance.options.autoResetSorting) {
|
|
2702
|
+
instance.resetSorting();
|
|
2703
|
+
}
|
|
2704
|
+
},
|
|
2470
2705
|
getColumnAutoSortingFn: function getColumnAutoSortingFn(columnId) {
|
|
2471
|
-
var
|
|
2472
|
-
var
|
|
2706
|
+
var firstRows = instance.getGlobalFilteredRowModel().flatRows.slice(100);
|
|
2707
|
+
var isString = false;
|
|
2473
2708
|
|
|
2474
|
-
|
|
2475
|
-
|
|
2709
|
+
for (var _iterator = _createForOfIteratorHelperLoose(firstRows), _step; !(_step = _iterator()).done;) {
|
|
2710
|
+
var row = _step.value;
|
|
2711
|
+
var value = row == null ? void 0 : row.values[columnId];
|
|
2712
|
+
|
|
2713
|
+
if (Object.prototype.toString.call(value) === '[object Date]') {
|
|
2714
|
+
return sortTypes.datetime;
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
if (typeof value === 'string') {
|
|
2718
|
+
isString = true;
|
|
2719
|
+
|
|
2720
|
+
if (value.split(reSplitAlphaNumeric).length > 1) {
|
|
2721
|
+
return sortTypes.alphanumeric;
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2476
2724
|
}
|
|
2477
2725
|
|
|
2478
|
-
if (
|
|
2479
|
-
return sortTypes.
|
|
2726
|
+
if (isString) {
|
|
2727
|
+
return sortTypes.text;
|
|
2480
2728
|
}
|
|
2481
2729
|
|
|
2482
2730
|
return sortTypes.basic;
|
|
2483
2731
|
},
|
|
2732
|
+
getColumnAutoSortDir: function getColumnAutoSortDir(columnId) {
|
|
2733
|
+
var firstRow = instance.getGlobalFilteredRowModel().flatRows[0];
|
|
2734
|
+
var value = firstRow == null ? void 0 : firstRow.values[columnId];
|
|
2735
|
+
|
|
2736
|
+
if (typeof value === 'string') {
|
|
2737
|
+
return 'asc';
|
|
2738
|
+
}
|
|
2739
|
+
|
|
2740
|
+
return 'desc';
|
|
2741
|
+
},
|
|
2484
2742
|
getColumnSortingFn: function getColumnSortingFn(columnId) {
|
|
2485
2743
|
var _ref;
|
|
2486
2744
|
|
|
@@ -2491,7 +2749,7 @@
|
|
|
2491
2749
|
throw new Error();
|
|
2492
2750
|
}
|
|
2493
2751
|
|
|
2494
|
-
return isFunction(column.sortType) ? column.sortType : column.sortType === 'auto' ? instance.
|
|
2752
|
+
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];
|
|
2495
2753
|
},
|
|
2496
2754
|
setSorting: function setSorting(updater) {
|
|
2497
2755
|
return instance.options.onSortingChange == null ? void 0 : instance.options.onSortingChange(updater, functionalUpdate(updater, instance.getState().sorting));
|
|
@@ -2501,10 +2759,18 @@
|
|
|
2501
2759
|
|
|
2502
2760
|
if (!column) {
|
|
2503
2761
|
throw new Error();
|
|
2504
|
-
}
|
|
2762
|
+
} // if (column.columns.length) {
|
|
2763
|
+
// column.columns.forEach((c, i) => {
|
|
2764
|
+
// if (c.id) {
|
|
2765
|
+
// instance.toggleColumnSorting(c.id, undefined, multi || !!i)
|
|
2766
|
+
// }
|
|
2767
|
+
// })
|
|
2768
|
+
// return
|
|
2769
|
+
// }
|
|
2770
|
+
|
|
2505
2771
|
|
|
2506
2772
|
instance.setSorting(function (old) {
|
|
2507
|
-
var _column$sortDescFirst, _instance$options$ena, _instance$options$ena2;
|
|
2773
|
+
var _ref2, _column$sortDescFirst, _instance$options$ena, _instance$options$ena2;
|
|
2508
2774
|
|
|
2509
2775
|
// Find any existing sorting for this column
|
|
2510
2776
|
var existingSorting = old == null ? void 0 : old.find(function (d) {
|
|
@@ -2518,7 +2784,7 @@
|
|
|
2518
2784
|
|
|
2519
2785
|
var sortAction;
|
|
2520
2786
|
|
|
2521
|
-
if (
|
|
2787
|
+
if (column.getCanMultiSort() && multi) {
|
|
2522
2788
|
if (existingSorting) {
|
|
2523
2789
|
sortAction = 'toggle';
|
|
2524
2790
|
} else {
|
|
@@ -2535,7 +2801,7 @@
|
|
|
2535
2801
|
}
|
|
2536
2802
|
}
|
|
2537
2803
|
|
|
2538
|
-
var sortDescFirst = (_column$sortDescFirst = column.sortDescFirst) != null ? _column$sortDescFirst : instance.options.sortDescFirst; // Handle toggle states that will remove the sorting
|
|
2804
|
+
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
|
|
2539
2805
|
|
|
2540
2806
|
if (sortAction === 'toggle' && ( // Must be toggling
|
|
2541
2807
|
(_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
|
|
@@ -2581,7 +2847,7 @@
|
|
|
2581
2847
|
});
|
|
2582
2848
|
},
|
|
2583
2849
|
getColumnCanSort: function getColumnCanSort(columnId) {
|
|
2584
|
-
var
|
|
2850
|
+
var _ref3, _ref4, _column$enableSorting;
|
|
2585
2851
|
|
|
2586
2852
|
var column = instance.getColumn(columnId);
|
|
2587
2853
|
|
|
@@ -2589,10 +2855,13 @@
|
|
|
2589
2855
|
throw new Error();
|
|
2590
2856
|
}
|
|
2591
2857
|
|
|
2592
|
-
return (
|
|
2858
|
+
return (_ref3 = (_ref4 = (_column$enableSorting = column.enableSorting) != null ? _column$enableSorting : instance.options.enableSorting) != null ? _ref4 : column.defaultCanSort) != null ? _ref3 : !!column.accessorFn // (!!column.accessorFn ||
|
|
2859
|
+
// column.columns?.some(c => c.id && instance.getColumnCanSort(c.id))) ??
|
|
2860
|
+
// false
|
|
2861
|
+
;
|
|
2593
2862
|
},
|
|
2594
2863
|
getColumnCanMultiSort: function getColumnCanMultiSort(columnId) {
|
|
2595
|
-
var
|
|
2864
|
+
var _ref5, _column$enableMultiSo;
|
|
2596
2865
|
|
|
2597
2866
|
var column = instance.getColumn(columnId);
|
|
2598
2867
|
|
|
@@ -2600,7 +2869,7 @@
|
|
|
2600
2869
|
throw new Error();
|
|
2601
2870
|
}
|
|
2602
2871
|
|
|
2603
|
-
return (
|
|
2872
|
+
return (_ref5 = (_column$enableMultiSo = column.enableMultiSort) != null ? _column$enableMultiSo : instance.options.enableMultiSort) != null ? _ref5 : !!column.accessorFn;
|
|
2604
2873
|
},
|
|
2605
2874
|
getColumnIsSorted: function getColumnIsSorted(columnId) {
|
|
2606
2875
|
var _instance$getState$so;
|
|
@@ -2647,8 +2916,14 @@
|
|
|
2647
2916
|
}
|
|
2648
2917
|
|
|
2649
2918
|
if (instance.options.debug) console.info('Sorting...');
|
|
2650
|
-
return sortingFn(instance,
|
|
2651
|
-
},
|
|
2919
|
+
return sortingFn(instance, rowModel);
|
|
2920
|
+
}, {
|
|
2921
|
+
key: 'getSortedRowModel',
|
|
2922
|
+
debug: instance.options.debug,
|
|
2923
|
+
onChange: function onChange() {
|
|
2924
|
+
return instance._notifyGroupingReset();
|
|
2925
|
+
}
|
|
2926
|
+
}),
|
|
2652
2927
|
getPreSortedRows: function getPreSortedRows() {
|
|
2653
2928
|
return instance.getGlobalFilteredRowModel().rows;
|
|
2654
2929
|
},
|
|
@@ -2670,13 +2945,22 @@
|
|
|
2670
2945
|
};
|
|
2671
2946
|
}
|
|
2672
2947
|
|
|
2948
|
+
var Sorting = /*#__PURE__*/Object.freeze({
|
|
2949
|
+
__proto__: null,
|
|
2950
|
+
getDefaultColumn: getDefaultColumn,
|
|
2951
|
+
getInitialState: getInitialState$4,
|
|
2952
|
+
getDefaultOptions: getDefaultOptions$4,
|
|
2953
|
+
createColumn: createColumn$1,
|
|
2954
|
+
getInstance: getInstance$4
|
|
2955
|
+
});
|
|
2956
|
+
|
|
2673
2957
|
//
|
|
2674
|
-
function getInitialState() {
|
|
2958
|
+
function getInitialState$3() {
|
|
2675
2959
|
return {
|
|
2676
2960
|
expanded: {}
|
|
2677
2961
|
};
|
|
2678
2962
|
}
|
|
2679
|
-
function getDefaultOptions(instance) {
|
|
2963
|
+
function getDefaultOptions$3(instance) {
|
|
2680
2964
|
return {
|
|
2681
2965
|
onExpandedChange: makeStateUpdater('expanded', instance),
|
|
2682
2966
|
autoResetExpanded: true,
|
|
@@ -2687,8 +2971,23 @@
|
|
|
2687
2971
|
paginateExpandedRows: true
|
|
2688
2972
|
};
|
|
2689
2973
|
}
|
|
2690
|
-
function getInstance(instance) {
|
|
2974
|
+
function getInstance$3(instance) {
|
|
2975
|
+
var registered = false;
|
|
2691
2976
|
return {
|
|
2977
|
+
_notifyExpandedReset: function _notifyExpandedReset() {
|
|
2978
|
+
if (!registered) {
|
|
2979
|
+
registered = true;
|
|
2980
|
+
return;
|
|
2981
|
+
}
|
|
2982
|
+
|
|
2983
|
+
if (instance.options.autoResetAll === false) {
|
|
2984
|
+
return;
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2987
|
+
if (instance.options.autoResetAll === true || instance.options.autoResetExpanded) {
|
|
2988
|
+
instance.resetExpanded();
|
|
2989
|
+
}
|
|
2990
|
+
},
|
|
2692
2991
|
setExpanded: function setExpanded(updater) {
|
|
2693
2992
|
return instance.options.onExpandedChange == null ? void 0 : instance.options.onExpandedChange(updater, functionalUpdate(updater, instance.getState().expanded));
|
|
2694
2993
|
},
|
|
@@ -2836,8 +3135,14 @@
|
|
|
2836
3135
|
}
|
|
2837
3136
|
|
|
2838
3137
|
if (instance.options.debug) console.info('Expanding...');
|
|
2839
|
-
return expandRowsFn(instance,
|
|
2840
|
-
},
|
|
3138
|
+
return expandRowsFn(instance, rowModel);
|
|
3139
|
+
}, {
|
|
3140
|
+
key: 'getExpandedRowModel',
|
|
3141
|
+
debug: instance.options.debug,
|
|
3142
|
+
onChange: function onChange() {
|
|
3143
|
+
return instance._notifyPageIndexReset();
|
|
3144
|
+
}
|
|
3145
|
+
}),
|
|
2841
3146
|
getPreExpandedRows: function getPreExpandedRows() {
|
|
2842
3147
|
return instance.getGroupedRowModel().rows;
|
|
2843
3148
|
},
|
|
@@ -2858,7 +3163,7 @@
|
|
|
2858
3163
|
}
|
|
2859
3164
|
};
|
|
2860
3165
|
}
|
|
2861
|
-
function createRow(row, instance) {
|
|
3166
|
+
function createRow$1(row, instance) {
|
|
2862
3167
|
return {
|
|
2863
3168
|
toggleExpanded: function toggleExpanded(expanded) {
|
|
2864
3169
|
return void instance.toggleRowExpanded(row.id, expanded);
|
|
@@ -2882,87 +3187,1122 @@
|
|
|
2882
3187
|
};
|
|
2883
3188
|
}
|
|
2884
3189
|
|
|
2885
|
-
|
|
2886
|
-
|
|
3190
|
+
var Expanding = /*#__PURE__*/Object.freeze({
|
|
3191
|
+
__proto__: null,
|
|
3192
|
+
getInitialState: getInitialState$3,
|
|
3193
|
+
getDefaultOptions: getDefaultOptions$3,
|
|
3194
|
+
getInstance: getInstance$3,
|
|
3195
|
+
createRow: createRow$1
|
|
3196
|
+
});
|
|
2887
3197
|
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
3198
|
+
//
|
|
3199
|
+
var defaultColumnSizing = {
|
|
3200
|
+
width: 150,
|
|
3201
|
+
minWidth: 20,
|
|
3202
|
+
maxWidth: Number.MAX_SAFE_INTEGER
|
|
3203
|
+
};
|
|
3204
|
+
function getInitialState$2() {
|
|
3205
|
+
return {
|
|
3206
|
+
columnSizing: {},
|
|
3207
|
+
columnSizingInfo: {
|
|
3208
|
+
startOffset: null,
|
|
3209
|
+
startSize: null,
|
|
3210
|
+
deltaOffset: null,
|
|
3211
|
+
deltaPercentage: null,
|
|
3212
|
+
isResizingColumn: false,
|
|
3213
|
+
columnSizingStart: []
|
|
3214
|
+
}
|
|
3215
|
+
};
|
|
3216
|
+
}
|
|
3217
|
+
function getDefaultOptions$2(instance) {
|
|
3218
|
+
return {
|
|
3219
|
+
columnResizeMode: 'onEnd',
|
|
3220
|
+
onColumnSizingChange: makeStateUpdater('columnSizing', instance),
|
|
3221
|
+
onColumnSizingInfoChange: makeStateUpdater('columnSizingInfo', instance)
|
|
3222
|
+
};
|
|
3223
|
+
}
|
|
3224
|
+
function getInstance$2(instance) {
|
|
3225
|
+
return {
|
|
3226
|
+
setColumnSizing: function setColumnSizing(updater) {
|
|
3227
|
+
return instance.options.onColumnSizingChange == null ? void 0 : instance.options.onColumnSizingChange(updater, functionalUpdate(updater, instance.getState().columnSizing));
|
|
3228
|
+
},
|
|
3229
|
+
setColumnSizingInfo: function setColumnSizingInfo(updater) {
|
|
3230
|
+
return instance.options.onColumnSizingInfoChange == null ? void 0 : instance.options.onColumnSizingInfoChange(updater, functionalUpdate(updater, instance.getState().columnSizingInfo));
|
|
3231
|
+
},
|
|
3232
|
+
resetColumnSizing: function resetColumnSizing() {
|
|
3233
|
+
var _instance$initialStat;
|
|
2891
3234
|
|
|
2892
|
-
|
|
3235
|
+
instance.setColumnSizing((_instance$initialStat = instance.initialState.columnSizing) != null ? _instance$initialStat : {});
|
|
3236
|
+
},
|
|
3237
|
+
resetHeaderSizeInfo: function resetHeaderSizeInfo() {
|
|
3238
|
+
var _instance$initialStat2;
|
|
2893
3239
|
|
|
2894
|
-
|
|
3240
|
+
instance.setColumnSizingInfo((_instance$initialStat2 = instance.initialState.columnSizingInfo) != null ? _instance$initialStat2 : {});
|
|
3241
|
+
},
|
|
3242
|
+
resetColumnSize: function resetColumnSize(columnId) {
|
|
3243
|
+
instance.setColumnSizing(function (_ref) {
|
|
3244
|
+
_ref[columnId];
|
|
3245
|
+
var rest = _objectWithoutPropertiesLoose(_ref, [columnId].map(_toPropertyKey));
|
|
2895
3246
|
|
|
2896
|
-
|
|
3247
|
+
return rest;
|
|
3248
|
+
});
|
|
3249
|
+
},
|
|
3250
|
+
resetHeaderSize: function resetHeaderSize(headerId) {
|
|
3251
|
+
var header = instance.getHeader(headerId);
|
|
2897
3252
|
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
}, defaultOptions, options);
|
|
2902
|
-
};
|
|
3253
|
+
if (!header) {
|
|
3254
|
+
return;
|
|
3255
|
+
}
|
|
2903
3256
|
|
|
2904
|
-
|
|
3257
|
+
return instance.resetColumnSize(header.column.id);
|
|
3258
|
+
},
|
|
3259
|
+
getHeaderCanResize: function getHeaderCanResize(headerId) {
|
|
3260
|
+
var header = instance.getHeader(headerId);
|
|
2905
3261
|
|
|
2906
|
-
|
|
3262
|
+
if (!header) {
|
|
3263
|
+
throw new Error();
|
|
3264
|
+
}
|
|
2907
3265
|
|
|
2908
|
-
|
|
2909
|
-
rerender: rerender,
|
|
2910
|
-
initialState: initialState,
|
|
2911
|
-
internalState: initialState,
|
|
2912
|
-
reset: function reset() {
|
|
2913
|
-
instance.setState(instance.initialState);
|
|
2914
|
-
},
|
|
2915
|
-
updateOptions: function updateOptions(newOptions) {
|
|
2916
|
-
instance.options = buildOptions(newOptions);
|
|
3266
|
+
return instance.getColumnCanResize(header.column.id);
|
|
2917
3267
|
},
|
|
2918
|
-
|
|
2919
|
-
|
|
3268
|
+
getColumnCanResize: function getColumnCanResize(columnId) {
|
|
3269
|
+
var _ref2, _ref3, _column$enableResizin;
|
|
3270
|
+
|
|
3271
|
+
var column = instance.getColumn(columnId);
|
|
3272
|
+
|
|
3273
|
+
if (!column) {
|
|
3274
|
+
throw new Error();
|
|
3275
|
+
}
|
|
3276
|
+
|
|
3277
|
+
return (_ref2 = (_ref3 = (_column$enableResizin = column.enableResizing) != null ? _column$enableResizin : instance.options.enableColumnResizing) != null ? _ref3 : column.defaultCanResize) != null ? _ref2 : true;
|
|
2920
3278
|
},
|
|
2921
|
-
|
|
2922
|
-
|
|
3279
|
+
getColumnIsResizing: function getColumnIsResizing(columnId) {
|
|
3280
|
+
var column = instance.getColumn(columnId);
|
|
3281
|
+
|
|
3282
|
+
if (!column) {
|
|
3283
|
+
throw new Error();
|
|
3284
|
+
}
|
|
3285
|
+
|
|
3286
|
+
return instance.getState().columnSizingInfo.isResizingColumn === columnId;
|
|
2923
3287
|
},
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
3288
|
+
getHeaderIsResizing: function getHeaderIsResizing(headerId) {
|
|
3289
|
+
var header = instance.getHeader(headerId);
|
|
3290
|
+
|
|
3291
|
+
if (!header) {
|
|
3292
|
+
throw new Error();
|
|
2927
3293
|
}
|
|
2928
3294
|
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
3295
|
+
return instance.getColumnIsResizing(header.column.id);
|
|
3296
|
+
},
|
|
3297
|
+
getColumnResizerProps: function getColumnResizerProps(headerId, userProps) {
|
|
3298
|
+
var header = instance.getHeader(headerId);
|
|
2932
3299
|
|
|
2933
|
-
if (
|
|
2934
|
-
onStateChange(newState);
|
|
3300
|
+
if (!header) {
|
|
2935
3301
|
return;
|
|
2936
3302
|
}
|
|
2937
3303
|
|
|
2938
|
-
|
|
2939
|
-
|
|
3304
|
+
var column = instance.getColumn(header.column.id);
|
|
3305
|
+
|
|
3306
|
+
if (!column) {
|
|
3307
|
+
return;
|
|
2940
3308
|
}
|
|
2941
|
-
},
|
|
2942
|
-
getDefaultColumn: memo(function () {
|
|
2943
|
-
return [instance.options.defaultColumn];
|
|
2944
|
-
}, function (defaultColumn) {
|
|
2945
|
-
var _defaultColumn;
|
|
2946
3309
|
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
3310
|
+
var canResize = column.getCanResize();
|
|
3311
|
+
|
|
3312
|
+
var onResizeStart = function onResizeStart(e) {
|
|
3313
|
+
if (isTouchStartEvent(e)) {
|
|
3314
|
+
// lets not respond to multiple touches (e.g. 2 or 3 fingers)
|
|
3315
|
+
if (e.touches && e.touches.length > 1) {
|
|
3316
|
+
return;
|
|
3317
|
+
}
|
|
3318
|
+
}
|
|
3319
|
+
|
|
3320
|
+
var columnSizingStart = header.getLeafHeaders().map(function (d) {
|
|
3321
|
+
return [d.column.id, d.getWidth()];
|
|
3322
|
+
});
|
|
3323
|
+
var clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
|
|
3324
|
+
|
|
3325
|
+
var updateOffset = function updateOffset(eventType, clientXPos) {
|
|
3326
|
+
if (typeof clientXPos !== 'number') {
|
|
3327
|
+
return;
|
|
3328
|
+
}
|
|
3329
|
+
|
|
3330
|
+
var newColumnSizing = {};
|
|
3331
|
+
instance.setColumnSizingInfo(function (old) {
|
|
3332
|
+
var _old$startOffset, _old$startSize;
|
|
3333
|
+
|
|
3334
|
+
var deltaOffset = clientXPos - ((_old$startOffset = old == null ? void 0 : old.startOffset) != null ? _old$startOffset : 0);
|
|
3335
|
+
var deltaPercentage = Math.max(deltaOffset / ((_old$startSize = old == null ? void 0 : old.startSize) != null ? _old$startSize : 0), -0.999999);
|
|
3336
|
+
old.columnSizingStart.forEach(function (_ref4) {
|
|
3337
|
+
var columnId = _ref4[0],
|
|
3338
|
+
headerWidth = _ref4[1];
|
|
3339
|
+
newColumnSizing[columnId] = Math.max(headerWidth + headerWidth * deltaPercentage, 0);
|
|
3340
|
+
});
|
|
3341
|
+
return _extends({}, old, {
|
|
3342
|
+
deltaOffset: deltaOffset,
|
|
3343
|
+
deltaPercentage: deltaPercentage
|
|
3344
|
+
});
|
|
3345
|
+
});
|
|
3346
|
+
|
|
3347
|
+
if (instance.options.columnResizeMode === 'onChange' || eventType === 'end') {
|
|
3348
|
+
instance.setColumnSizing(function (old) {
|
|
3349
|
+
return _extends({}, old, newColumnSizing);
|
|
3350
|
+
});
|
|
3351
|
+
}
|
|
3352
|
+
};
|
|
3353
|
+
|
|
3354
|
+
var onMove = function onMove(clientXPos) {
|
|
3355
|
+
return updateOffset('move', clientXPos);
|
|
3356
|
+
};
|
|
3357
|
+
|
|
3358
|
+
var onEnd = function onEnd(clientXPos) {
|
|
3359
|
+
updateOffset('end', clientXPos);
|
|
3360
|
+
instance.setColumnSizingInfo(function (old) {
|
|
3361
|
+
return _extends({}, old, {
|
|
3362
|
+
isResizingColumn: false,
|
|
3363
|
+
startOffset: null,
|
|
3364
|
+
startSize: null,
|
|
3365
|
+
deltaOffset: null,
|
|
3366
|
+
deltaPercentage: null,
|
|
3367
|
+
columnSizingStart: []
|
|
3368
|
+
});
|
|
3369
|
+
});
|
|
3370
|
+
};
|
|
3371
|
+
|
|
3372
|
+
var mouseEvents = {
|
|
3373
|
+
moveHandler: function moveHandler(e) {
|
|
3374
|
+
return onMove(e.clientX);
|
|
3375
|
+
},
|
|
3376
|
+
upHandler: function upHandler(e) {
|
|
3377
|
+
document.removeEventListener('mousemove', mouseEvents.moveHandler);
|
|
3378
|
+
document.removeEventListener('mouseup', mouseEvents.upHandler);
|
|
3379
|
+
onEnd(e.clientX);
|
|
3380
|
+
}
|
|
3381
|
+
};
|
|
3382
|
+
var touchEvents = {
|
|
3383
|
+
moveHandler: function moveHandler(e) {
|
|
3384
|
+
if (e.cancelable) {
|
|
3385
|
+
e.preventDefault();
|
|
3386
|
+
e.stopPropagation();
|
|
3387
|
+
}
|
|
3388
|
+
|
|
3389
|
+
onMove(e.touches[0].clientX);
|
|
3390
|
+
return false;
|
|
3391
|
+
},
|
|
3392
|
+
upHandler: function upHandler(e) {
|
|
3393
|
+
document.removeEventListener('touchmove', touchEvents.moveHandler);
|
|
3394
|
+
document.removeEventListener('touchend', touchEvents.upHandler);
|
|
3395
|
+
|
|
3396
|
+
if (e.cancelable) {
|
|
3397
|
+
e.preventDefault();
|
|
3398
|
+
e.stopPropagation();
|
|
3399
|
+
}
|
|
3400
|
+
|
|
3401
|
+
onEnd(e.touches[0].clientX);
|
|
3402
|
+
}
|
|
3403
|
+
};
|
|
3404
|
+
var passiveIfSupported = passiveEventSupported() ? {
|
|
3405
|
+
passive: false
|
|
3406
|
+
} : false;
|
|
3407
|
+
|
|
3408
|
+
if (isTouchStartEvent(e)) {
|
|
3409
|
+
document.addEventListener('touchmove', touchEvents.moveHandler, passiveIfSupported);
|
|
3410
|
+
document.addEventListener('touchend', touchEvents.upHandler, passiveIfSupported);
|
|
3411
|
+
} else {
|
|
3412
|
+
document.addEventListener('mousemove', mouseEvents.moveHandler, passiveIfSupported);
|
|
3413
|
+
document.addEventListener('mouseup', mouseEvents.upHandler, passiveIfSupported);
|
|
3414
|
+
}
|
|
3415
|
+
|
|
3416
|
+
instance.setColumnSizingInfo(function (old) {
|
|
3417
|
+
return _extends({}, old, {
|
|
3418
|
+
startOffset: clientX,
|
|
3419
|
+
startSize: header.getWidth(),
|
|
3420
|
+
deltaOffset: 0,
|
|
3421
|
+
deltaPercentage: 0,
|
|
3422
|
+
columnSizingStart: columnSizingStart,
|
|
3423
|
+
isResizingColumn: header.column.id
|
|
3424
|
+
});
|
|
3425
|
+
});
|
|
3426
|
+
};
|
|
3427
|
+
|
|
3428
|
+
var initialProps = canResize ? {
|
|
3429
|
+
title: 'Toggle Grouping',
|
|
3430
|
+
draggable: false,
|
|
3431
|
+
role: 'separator',
|
|
3432
|
+
onMouseDown: function onMouseDown(e) {
|
|
3433
|
+
e.persist();
|
|
3434
|
+
onResizeStart(e);
|
|
3435
|
+
},
|
|
3436
|
+
onTouchStart: function onTouchStart(e) {
|
|
3437
|
+
e.persist();
|
|
3438
|
+
onResizeStart(e);
|
|
3439
|
+
}
|
|
3440
|
+
} : {};
|
|
3441
|
+
return propGetter(initialProps, userProps);
|
|
3442
|
+
}
|
|
3443
|
+
};
|
|
3444
|
+
}
|
|
3445
|
+
function createColumn(column, instance) {
|
|
3446
|
+
return {
|
|
3447
|
+
getIsResizing: function getIsResizing() {
|
|
3448
|
+
return instance.getColumnIsResizing(column.id);
|
|
3449
|
+
},
|
|
3450
|
+
getCanResize: function getCanResize() {
|
|
3451
|
+
return instance.getColumnCanResize(column.id);
|
|
3452
|
+
},
|
|
3453
|
+
resetSize: function resetSize() {
|
|
3454
|
+
return instance.resetColumnSize(column.id);
|
|
3455
|
+
},
|
|
3456
|
+
getResizerProps: function getResizerProps(userProps) {
|
|
3457
|
+
return instance.getColumnResizerProps(column.id, userProps);
|
|
3458
|
+
}
|
|
3459
|
+
};
|
|
3460
|
+
}
|
|
3461
|
+
var passiveSupported = null;
|
|
3462
|
+
function passiveEventSupported() {
|
|
3463
|
+
if (typeof passiveSupported === 'boolean') return passiveSupported;
|
|
3464
|
+
var supported = false;
|
|
3465
|
+
|
|
3466
|
+
try {
|
|
3467
|
+
var options = {
|
|
3468
|
+
get passive() {
|
|
3469
|
+
supported = true;
|
|
3470
|
+
return false;
|
|
3471
|
+
}
|
|
3472
|
+
|
|
3473
|
+
};
|
|
3474
|
+
|
|
3475
|
+
var noop = function noop() {};
|
|
3476
|
+
|
|
3477
|
+
window.addEventListener('test', noop, options);
|
|
3478
|
+
window.removeEventListener('test', noop);
|
|
3479
|
+
} catch (err) {
|
|
3480
|
+
supported = false;
|
|
3481
|
+
}
|
|
3482
|
+
|
|
3483
|
+
passiveSupported = supported;
|
|
3484
|
+
return passiveSupported;
|
|
3485
|
+
}
|
|
3486
|
+
|
|
3487
|
+
function isTouchStartEvent(e) {
|
|
3488
|
+
return e.type === 'touchstart';
|
|
3489
|
+
}
|
|
3490
|
+
|
|
3491
|
+
var ColumnSizing = /*#__PURE__*/Object.freeze({
|
|
3492
|
+
__proto__: null,
|
|
3493
|
+
defaultColumnSizing: defaultColumnSizing,
|
|
3494
|
+
getInitialState: getInitialState$2,
|
|
3495
|
+
getDefaultOptions: getDefaultOptions$2,
|
|
3496
|
+
getInstance: getInstance$2,
|
|
3497
|
+
createColumn: createColumn,
|
|
3498
|
+
passiveEventSupported: passiveEventSupported
|
|
3499
|
+
});
|
|
3500
|
+
|
|
3501
|
+
//
|
|
3502
|
+
function getInitialState$1() {
|
|
3503
|
+
return {
|
|
3504
|
+
pagination: {
|
|
3505
|
+
pageIndex: 0,
|
|
3506
|
+
pageSize: 10
|
|
3507
|
+
}
|
|
3508
|
+
};
|
|
3509
|
+
}
|
|
3510
|
+
function getDefaultOptions$1(instance) {
|
|
3511
|
+
return {
|
|
3512
|
+
onPaginationChange: makeStateUpdater('pagination', instance),
|
|
3513
|
+
autoResetPageIndex: true
|
|
3514
|
+
};
|
|
3515
|
+
}
|
|
3516
|
+
function getInstance$1(instance) {
|
|
3517
|
+
var registered = false;
|
|
3518
|
+
return {
|
|
3519
|
+
_notifyPageIndexReset: function _notifyPageIndexReset() {
|
|
3520
|
+
if (!registered) {
|
|
3521
|
+
registered = true;
|
|
3522
|
+
return;
|
|
3523
|
+
}
|
|
3524
|
+
|
|
3525
|
+
if (instance.options.autoResetAll === false) {
|
|
3526
|
+
return;
|
|
3527
|
+
}
|
|
3528
|
+
|
|
3529
|
+
if (instance.options.autoResetAll === true || instance.options.autoResetPageIndex) {
|
|
3530
|
+
instance.resetPageSize();
|
|
3531
|
+
}
|
|
3532
|
+
},
|
|
3533
|
+
setPagination: function setPagination(updater) {
|
|
3534
|
+
var safeUpdater = function safeUpdater(old) {
|
|
3535
|
+
var newState = functionalUpdate(updater, old);
|
|
3536
|
+
|
|
3537
|
+
if (instance.options.paginateRowsFn) {
|
|
3538
|
+
var _instance$getPrePagin;
|
|
3539
|
+
|
|
3540
|
+
newState.pageCount = (_instance$getPrePagin = instance.getPrePaginationRows()) != null && _instance$getPrePagin.length ? Math.ceil(instance.getPrePaginationRows().length / instance.getState().pagination.pageSize) : 0;
|
|
3541
|
+
}
|
|
3542
|
+
|
|
3543
|
+
return newState;
|
|
3544
|
+
};
|
|
3545
|
+
|
|
3546
|
+
return instance.options.onPaginationChange == null ? void 0 : instance.options.onPaginationChange(safeUpdater, functionalUpdate(safeUpdater, instance.getState().pagination));
|
|
3547
|
+
},
|
|
3548
|
+
resetPagination: function resetPagination() {
|
|
3549
|
+
var _instance$initialStat;
|
|
3550
|
+
|
|
3551
|
+
instance.setPagination((_instance$initialStat = instance.initialState.pagination) != null ? _instance$initialStat : {
|
|
3552
|
+
pageIndex: 0,
|
|
3553
|
+
pageSize: 10,
|
|
3554
|
+
pageCount: -1
|
|
3555
|
+
});
|
|
3556
|
+
},
|
|
3557
|
+
setPageIndex: function setPageIndex(updater) {
|
|
3558
|
+
instance.setPagination(function (old) {
|
|
3559
|
+
var pageIndex = functionalUpdate(updater, old.pageIndex);
|
|
3560
|
+
var maxPageIndex = old.pageCount && old.pageCount > 0 ? old.pageCount - 1 : Number.MAX_SAFE_INTEGER;
|
|
3561
|
+
pageIndex = Math.min(Math.max(0, pageIndex), maxPageIndex);
|
|
3562
|
+
return _extends({}, old, {
|
|
3563
|
+
pageIndex: pageIndex
|
|
3564
|
+
});
|
|
3565
|
+
});
|
|
3566
|
+
},
|
|
3567
|
+
resetPageIndex: function resetPageIndex() {
|
|
3568
|
+
instance.setPageIndex(0);
|
|
3569
|
+
},
|
|
3570
|
+
resetPageSize: function resetPageSize() {
|
|
3571
|
+
var _instance$options$ini, _instance$options$ini2, _instance$options$ini3;
|
|
3572
|
+
|
|
3573
|
+
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);
|
|
3574
|
+
},
|
|
3575
|
+
setPageSize: function setPageSize(updater) {
|
|
3576
|
+
instance.setPagination(function (old) {
|
|
3577
|
+
var pageSize = Math.max(1, functionalUpdate(updater, old.pageSize));
|
|
3578
|
+
var topRowIndex = old.pageSize * old.pageIndex;
|
|
3579
|
+
var pageIndex = Math.floor(topRowIndex / pageSize);
|
|
3580
|
+
return _extends({}, old, {
|
|
3581
|
+
pageIndex: pageIndex,
|
|
3582
|
+
pageSize: pageSize
|
|
3583
|
+
});
|
|
3584
|
+
});
|
|
3585
|
+
},
|
|
3586
|
+
setPageCount: function setPageCount(updater) {
|
|
3587
|
+
return instance.setPagination(function (old) {
|
|
3588
|
+
var newPageCount = functionalUpdate(updater, old.pageCount);
|
|
3589
|
+
|
|
3590
|
+
if (typeof newPageCount === 'number') {
|
|
3591
|
+
newPageCount = Math.max(-1, newPageCount);
|
|
3592
|
+
}
|
|
3593
|
+
|
|
3594
|
+
return _extends({}, old, {
|
|
3595
|
+
pageCount: newPageCount
|
|
3596
|
+
});
|
|
3597
|
+
});
|
|
3598
|
+
},
|
|
3599
|
+
getPageOptions: memo(function () {
|
|
3600
|
+
return [instance.getState().pagination.pageSize, instance.getState().pagination.pageCount];
|
|
3601
|
+
}, function (pageSize, pageCount) {
|
|
3602
|
+
var pageOptions = [];
|
|
3603
|
+
|
|
3604
|
+
if (pageCount && pageCount > 0) {
|
|
3605
|
+
pageOptions = [].concat(new Array(pageCount)).fill(null).map(function (_, i) {
|
|
3606
|
+
return i;
|
|
3607
|
+
});
|
|
3608
|
+
}
|
|
3609
|
+
|
|
3610
|
+
return pageOptions;
|
|
3611
|
+
}, {
|
|
3612
|
+
key: 'getPageOptions',
|
|
3613
|
+
debug: instance.options.debug
|
|
3614
|
+
}),
|
|
3615
|
+
getCanPreviousPage: function getCanPreviousPage() {
|
|
3616
|
+
return instance.getState().pagination.pageIndex > 0;
|
|
3617
|
+
},
|
|
3618
|
+
getCanNextPage: function getCanNextPage() {
|
|
3619
|
+
var _instance$getState$pa = instance.getState().pagination,
|
|
3620
|
+
pageIndex = _instance$getState$pa.pageIndex,
|
|
3621
|
+
pageCount = _instance$getState$pa.pageCount,
|
|
3622
|
+
pageSize = _instance$getState$pa.pageSize;
|
|
3623
|
+
|
|
3624
|
+
if (pageCount === -1) {
|
|
3625
|
+
return true;
|
|
3626
|
+
}
|
|
3627
|
+
|
|
3628
|
+
if (pageCount === 0) {
|
|
3629
|
+
return false;
|
|
3630
|
+
}
|
|
3631
|
+
|
|
3632
|
+
return pageIndex < Math.ceil(instance.getPrePaginationRows().length / pageSize) - 1;
|
|
3633
|
+
},
|
|
3634
|
+
previousPage: function previousPage() {
|
|
3635
|
+
return instance.setPageIndex(function (old) {
|
|
3636
|
+
return old - 1;
|
|
3637
|
+
});
|
|
3638
|
+
},
|
|
3639
|
+
nextPage: function nextPage() {
|
|
3640
|
+
return instance.setPageIndex(function (old) {
|
|
3641
|
+
return old + 1;
|
|
3642
|
+
});
|
|
3643
|
+
},
|
|
3644
|
+
getPaginationRowModel: memo(function () {
|
|
3645
|
+
return [instance.getState().pagination, instance.getExpandedRowModel(), instance.options.paginateRowsFn];
|
|
3646
|
+
}, function (_pagination, rowModel, paginateRowsFn) {
|
|
3647
|
+
if (!paginateRowsFn || !rowModel.rows.length) {
|
|
3648
|
+
return rowModel;
|
|
3649
|
+
}
|
|
3650
|
+
|
|
3651
|
+
if (instance.options.debug) console.info('Paginating...');
|
|
3652
|
+
return paginateRowsFn(instance, rowModel);
|
|
3653
|
+
}, {
|
|
3654
|
+
key: 'getPaginationRowModel',
|
|
3655
|
+
debug: instance.options.debug
|
|
3656
|
+
}),
|
|
3657
|
+
getPrePaginationRows: function getPrePaginationRows() {
|
|
3658
|
+
return instance.getExpandedRowModel().rows;
|
|
3659
|
+
},
|
|
3660
|
+
getPrePaginationFlatRows: function getPrePaginationFlatRows() {
|
|
3661
|
+
return instance.getExpandedRowModel().flatRows;
|
|
3662
|
+
},
|
|
3663
|
+
getPrePaginationRowsById: function getPrePaginationRowsById() {
|
|
3664
|
+
return instance.getExpandedRowModel().rowsById;
|
|
3665
|
+
},
|
|
3666
|
+
getPaginationRows: function getPaginationRows() {
|
|
3667
|
+
return instance.getPaginationRowModel().rows;
|
|
3668
|
+
},
|
|
3669
|
+
getPaginationFlatRows: function getPaginationFlatRows() {
|
|
3670
|
+
return instance.getPaginationRowModel().flatRows;
|
|
3671
|
+
},
|
|
3672
|
+
getPaginationRowsById: function getPaginationRowsById() {
|
|
3673
|
+
return instance.getPaginationRowModel().rowsById;
|
|
3674
|
+
}
|
|
3675
|
+
};
|
|
3676
|
+
}
|
|
3677
|
+
|
|
3678
|
+
var Pagination = /*#__PURE__*/Object.freeze({
|
|
3679
|
+
__proto__: null,
|
|
3680
|
+
getInitialState: getInitialState$1,
|
|
3681
|
+
getDefaultOptions: getDefaultOptions$1,
|
|
3682
|
+
getInstance: getInstance$1
|
|
3683
|
+
});
|
|
3684
|
+
|
|
3685
|
+
//
|
|
3686
|
+
function getInitialState() {
|
|
3687
|
+
return {
|
|
3688
|
+
rowSelection: {}
|
|
3689
|
+
};
|
|
3690
|
+
}
|
|
3691
|
+
function getDefaultOptions(instance) {
|
|
3692
|
+
return {
|
|
3693
|
+
onRowSelectionChange: makeStateUpdater('rowSelection', instance),
|
|
3694
|
+
autoResetRowSelection: true,
|
|
3695
|
+
enableRowSelection: true,
|
|
3696
|
+
enableMultiRowSelection: true,
|
|
3697
|
+
enableSubRowSelection: true // enableGroupingRowSelection: false,
|
|
3698
|
+
// isAdditiveSelectEvent: (e: MouseEvent | TouchEvent) => !!e.metaKey,
|
|
3699
|
+
// isInclusiveSelectEvent: (e: MouseEvent | TouchEvent) => !!e.shiftKey,
|
|
3700
|
+
|
|
3701
|
+
};
|
|
3702
|
+
}
|
|
3703
|
+
function getInstance(instance) {
|
|
3704
|
+
var registered = false; // const pageRows = instance.getPageRows()
|
|
3705
|
+
|
|
3706
|
+
return {
|
|
3707
|
+
_notifyRowSelectionReset: function _notifyRowSelectionReset() {
|
|
3708
|
+
if (!registered) {
|
|
3709
|
+
registered = true;
|
|
3710
|
+
return;
|
|
3711
|
+
}
|
|
3712
|
+
|
|
3713
|
+
if (instance.options.autoResetAll === false) {
|
|
3714
|
+
return;
|
|
3715
|
+
}
|
|
3716
|
+
|
|
3717
|
+
if (instance.options.autoResetAll === true || instance.options.autoResetRowSelection) {
|
|
3718
|
+
instance.resetRowSelection();
|
|
3719
|
+
}
|
|
3720
|
+
},
|
|
3721
|
+
setRowSelection: function setRowSelection(updater) {
|
|
3722
|
+
return instance.options.onRowSelectionChange == null ? void 0 : instance.options.onRowSelectionChange(updater, functionalUpdate(updater, instance.getState().rowSelection));
|
|
3723
|
+
},
|
|
3724
|
+
resetRowSelection: function resetRowSelection() {
|
|
3725
|
+
var _getInitialState$rowS;
|
|
3726
|
+
|
|
3727
|
+
return instance.setRowSelection((_getInitialState$rowS = getInitialState().rowSelection) != null ? _getInitialState$rowS : {});
|
|
3728
|
+
},
|
|
3729
|
+
toggleAllRowsSelected: function toggleAllRowsSelected(value) {
|
|
3730
|
+
instance.setRowSelection(function (old) {
|
|
3731
|
+
value = typeof value !== 'undefined' ? value : !instance.getIsAllRowsSelected(); // Only remove/add the rows that are visible on the screen
|
|
3732
|
+
// Leave all the other rows that are selected alone.
|
|
3733
|
+
|
|
3734
|
+
var rowSelection = Object.assign({}, old);
|
|
3735
|
+
var preGroupedFlatRows = instance.getPreGroupedFlatRows(); // We don't use `mutateRowIsSelected` here for performance reasons.
|
|
3736
|
+
// All of the rows are flat already, so it wouldn't be worth it
|
|
3737
|
+
|
|
3738
|
+
if (value) {
|
|
3739
|
+
preGroupedFlatRows.forEach(function (row) {
|
|
3740
|
+
rowSelection[row.id] = true;
|
|
3741
|
+
});
|
|
3742
|
+
} else {
|
|
3743
|
+
preGroupedFlatRows.forEach(function (row) {
|
|
3744
|
+
delete rowSelection[row.id];
|
|
3745
|
+
});
|
|
3746
|
+
}
|
|
3747
|
+
|
|
3748
|
+
return rowSelection;
|
|
3749
|
+
});
|
|
3750
|
+
},
|
|
3751
|
+
toggleAllPageRowsSelected: function toggleAllPageRowsSelected(value) {
|
|
3752
|
+
return instance.setRowSelection(function (old) {
|
|
3753
|
+
typeof value !== 'undefined' ? value : !instance.getIsAllPageRowsSelected();
|
|
3754
|
+
|
|
3755
|
+
var rowSelection = _extends({}, old);
|
|
3756
|
+
|
|
3757
|
+
instance.getRows().forEach(function (row) {
|
|
3758
|
+
mutateRowIsSelected(rowSelection, row.id, value, instance);
|
|
3759
|
+
});
|
|
3760
|
+
return rowSelection;
|
|
3761
|
+
});
|
|
3762
|
+
},
|
|
3763
|
+
toggleRowSelected: function toggleRowSelected(rowId, value) {
|
|
3764
|
+
var row = instance.getRow(rowId);
|
|
3765
|
+
var isSelected = row.getIsSelected();
|
|
3766
|
+
instance.setRowSelection(function (old) {
|
|
3767
|
+
value = typeof value !== 'undefined' ? value : !isSelected;
|
|
3768
|
+
|
|
3769
|
+
if (isSelected === value) {
|
|
3770
|
+
return old;
|
|
3771
|
+
}
|
|
3772
|
+
|
|
3773
|
+
var selectedRowIds = _extends({}, old);
|
|
3774
|
+
|
|
3775
|
+
mutateRowIsSelected(selectedRowIds, rowId, value, instance);
|
|
3776
|
+
return selectedRowIds;
|
|
3777
|
+
});
|
|
3778
|
+
},
|
|
3779
|
+
// addRowSelectionRange: rowId => {
|
|
3780
|
+
// const {
|
|
3781
|
+
// rows,
|
|
3782
|
+
// rowsById,
|
|
3783
|
+
// options: { selectGroupingRows, selectSubRows },
|
|
3784
|
+
// } = instance
|
|
3785
|
+
// const findSelectedRow = (rows: Row[]) => {
|
|
3786
|
+
// let found
|
|
3787
|
+
// rows.find(d => {
|
|
3788
|
+
// if (d.getIsSelected()) {
|
|
3789
|
+
// found = d
|
|
3790
|
+
// return true
|
|
3791
|
+
// }
|
|
3792
|
+
// const subFound = findSelectedRow(d.subRows || [])
|
|
3793
|
+
// if (subFound) {
|
|
3794
|
+
// found = subFound
|
|
3795
|
+
// return true
|
|
3796
|
+
// }
|
|
3797
|
+
// return false
|
|
3798
|
+
// })
|
|
3799
|
+
// return found
|
|
3800
|
+
// }
|
|
3801
|
+
// const firstRow = findSelectedRow(rows) || rows[0]
|
|
3802
|
+
// const lastRow = rowsById[rowId]
|
|
3803
|
+
// let include = false
|
|
3804
|
+
// const selectedRowIds = {}
|
|
3805
|
+
// const addRow = (row: Row) => {
|
|
3806
|
+
// mutateRowIsSelected(selectedRowIds, row.id, true, {
|
|
3807
|
+
// rowsById,
|
|
3808
|
+
// selectGroupingRows: selectGroupingRows!,
|
|
3809
|
+
// selectSubRows: selectSubRows!,
|
|
3810
|
+
// })
|
|
3811
|
+
// }
|
|
3812
|
+
// instance.rows.forEach(row => {
|
|
3813
|
+
// const isFirstRow = row.id === firstRow.id
|
|
3814
|
+
// const isLastRow = row.id === lastRow.id
|
|
3815
|
+
// if (isFirstRow || isLastRow) {
|
|
3816
|
+
// if (!include) {
|
|
3817
|
+
// include = true
|
|
3818
|
+
// } else if (include) {
|
|
3819
|
+
// addRow(row)
|
|
3820
|
+
// include = false
|
|
3821
|
+
// }
|
|
3822
|
+
// }
|
|
3823
|
+
// if (include) {
|
|
3824
|
+
// addRow(row)
|
|
3825
|
+
// }
|
|
3826
|
+
// })
|
|
3827
|
+
// instance.setRowSelection(selectedRowIds)
|
|
3828
|
+
// },
|
|
3829
|
+
getSelectedRowModel: memo(function () {
|
|
3830
|
+
return [instance.getState().rowSelection, instance.getCoreRowModel()];
|
|
3831
|
+
}, function (rowSelection, rowModel) {
|
|
3832
|
+
if (!Object.keys(rowSelection).length) {
|
|
3833
|
+
return {
|
|
3834
|
+
rows: [],
|
|
3835
|
+
flatRows: [],
|
|
3836
|
+
rowsById: {}
|
|
3837
|
+
};
|
|
3838
|
+
}
|
|
3839
|
+
|
|
3840
|
+
if (instance.options.debug) console.info('Selecting...');
|
|
3841
|
+
return selectRowsFn(instance, rowModel);
|
|
3842
|
+
}, {
|
|
3843
|
+
key: 'getSelectedRowModel',
|
|
3844
|
+
debug: instance.options.debug,
|
|
3845
|
+
onChange: function onChange() {
|
|
3846
|
+
return instance._notifyExpandedReset();
|
|
3847
|
+
}
|
|
3848
|
+
}),
|
|
3849
|
+
getSelectedRows: function getSelectedRows() {
|
|
3850
|
+
return instance.getSelectedRowModel().rows;
|
|
3851
|
+
},
|
|
3852
|
+
getSelectedFlatRows: function getSelectedFlatRows() {
|
|
3853
|
+
return instance.getSelectedRowModel().flatRows;
|
|
3854
|
+
},
|
|
3855
|
+
getSelectedRowsById: function getSelectedRowsById() {
|
|
3856
|
+
return instance.getSelectedRowModel().rowsById;
|
|
3857
|
+
},
|
|
3858
|
+
getFilteredSelectedRowModel: memo(function () {
|
|
3859
|
+
return [instance.getState().rowSelection, instance.getGlobalFilteredRowModel()];
|
|
3860
|
+
}, function (rowSelection, rowModel) {
|
|
3861
|
+
if (!Object.keys(rowSelection).length) {
|
|
3862
|
+
return {
|
|
3863
|
+
rows: [],
|
|
3864
|
+
flatRows: [],
|
|
3865
|
+
rowsById: {}
|
|
3866
|
+
};
|
|
3867
|
+
}
|
|
3868
|
+
|
|
3869
|
+
if (instance.options.debug) console.info('Selecting...');
|
|
3870
|
+
return selectRowsFn(instance, rowModel);
|
|
3871
|
+
}, {
|
|
3872
|
+
key: 'getFilteredSelectedRowModel',
|
|
3873
|
+
debug: instance.options.debug,
|
|
3874
|
+
onChange: function onChange() {
|
|
3875
|
+
return instance._notifyExpandedReset();
|
|
3876
|
+
}
|
|
3877
|
+
}),
|
|
3878
|
+
getFilteredSelectedRows: function getFilteredSelectedRows() {
|
|
3879
|
+
return instance.getFilteredSelectedRowModel().rows;
|
|
3880
|
+
},
|
|
3881
|
+
getFilteredSelectedFlatRows: function getFilteredSelectedFlatRows() {
|
|
3882
|
+
return instance.getFilteredSelectedRowModel().flatRows;
|
|
3883
|
+
},
|
|
3884
|
+
getFilteredSelectedRowsById: function getFilteredSelectedRowsById() {
|
|
3885
|
+
return instance.getFilteredSelectedRowModel().rowsById;
|
|
3886
|
+
},
|
|
3887
|
+
getGroupedSelectedRowModel: memo(function () {
|
|
3888
|
+
return [instance.getState().rowSelection, instance.getGroupedRowModel()];
|
|
3889
|
+
}, function (rowSelection, rowModel) {
|
|
3890
|
+
if (!Object.keys(rowSelection).length) {
|
|
3891
|
+
return {
|
|
3892
|
+
rows: [],
|
|
3893
|
+
flatRows: [],
|
|
3894
|
+
rowsById: {}
|
|
3895
|
+
};
|
|
3896
|
+
}
|
|
3897
|
+
|
|
3898
|
+
if (instance.options.debug) console.info('Selecting...');
|
|
3899
|
+
return selectRowsFn(instance, rowModel);
|
|
3900
|
+
}, {
|
|
3901
|
+
key: 'getGroupedSelectedRowModel',
|
|
3902
|
+
debug: instance.options.debug,
|
|
3903
|
+
onChange: function onChange() {
|
|
3904
|
+
return instance._notifyExpandedReset();
|
|
3905
|
+
}
|
|
3906
|
+
}),
|
|
3907
|
+
getGroupedSelectedRows: function getGroupedSelectedRows() {
|
|
3908
|
+
return instance.getGroupedSelectedRowModel().rows;
|
|
3909
|
+
},
|
|
3910
|
+
getGroupedSelectedFlatRows: function getGroupedSelectedFlatRows() {
|
|
3911
|
+
return instance.getGroupedSelectedRowModel().flatRows;
|
|
3912
|
+
},
|
|
3913
|
+
getGroupedSelectedRowsById: function getGroupedSelectedRowsById() {
|
|
3914
|
+
return instance.getGroupedSelectedRowModel().rowsById;
|
|
3915
|
+
},
|
|
3916
|
+
///
|
|
3917
|
+
getRowIsSelected: function getRowIsSelected(rowId) {
|
|
3918
|
+
var _instance$getState = instance.getState(),
|
|
3919
|
+
rowSelection = _instance$getState.rowSelection;
|
|
3920
|
+
|
|
3921
|
+
var row = instance.getRow(rowId);
|
|
3922
|
+
|
|
3923
|
+
if (!row) {
|
|
3924
|
+
throw new Error();
|
|
3925
|
+
}
|
|
3926
|
+
|
|
3927
|
+
return isRowSelected(row, rowSelection) === true;
|
|
3928
|
+
},
|
|
3929
|
+
getRowIsSomeSelected: function getRowIsSomeSelected(rowId) {
|
|
3930
|
+
var _instance$getState2 = instance.getState(),
|
|
3931
|
+
rowSelection = _instance$getState2.rowSelection;
|
|
3932
|
+
|
|
3933
|
+
var row = instance.getRow(rowId);
|
|
3934
|
+
|
|
3935
|
+
if (!row) {
|
|
3936
|
+
throw new Error();
|
|
3937
|
+
}
|
|
3938
|
+
|
|
3939
|
+
return isRowSelected(row, rowSelection) === 'some';
|
|
3940
|
+
},
|
|
3941
|
+
getRowCanSelect: function getRowCanSelect(rowId) {
|
|
3942
|
+
var _instance$options$ena;
|
|
3943
|
+
|
|
3944
|
+
var row = instance.getRow(rowId);
|
|
3945
|
+
|
|
3946
|
+
if (!row) {
|
|
3947
|
+
throw new Error();
|
|
3948
|
+
}
|
|
3949
|
+
|
|
3950
|
+
if (typeof instance.options.enableRowSelection === 'function') {
|
|
3951
|
+
return instance.options.enableRowSelection(row);
|
|
3952
|
+
}
|
|
3953
|
+
|
|
3954
|
+
return (_instance$options$ena = instance.options.enableRowSelection) != null ? _instance$options$ena : true;
|
|
3955
|
+
},
|
|
3956
|
+
getRowCanSelectSubRows: function getRowCanSelectSubRows(rowId) {
|
|
3957
|
+
var _instance$options$ena2;
|
|
3958
|
+
|
|
3959
|
+
var row = instance.getRow(rowId);
|
|
3960
|
+
|
|
3961
|
+
if (!row) {
|
|
3962
|
+
throw new Error();
|
|
3963
|
+
}
|
|
3964
|
+
|
|
3965
|
+
if (typeof instance.options.enableSubRowSelection === 'function') {
|
|
3966
|
+
return instance.options.enableSubRowSelection(row);
|
|
3967
|
+
}
|
|
3968
|
+
|
|
3969
|
+
return (_instance$options$ena2 = instance.options.enableSubRowSelection) != null ? _instance$options$ena2 : true;
|
|
3970
|
+
},
|
|
3971
|
+
getRowCanMultiSelect: function getRowCanMultiSelect(rowId) {
|
|
3972
|
+
var _instance$options$ena3;
|
|
3973
|
+
|
|
3974
|
+
var row = instance.getRow(rowId);
|
|
3975
|
+
|
|
3976
|
+
if (!row) {
|
|
3977
|
+
throw new Error();
|
|
3978
|
+
}
|
|
3979
|
+
|
|
3980
|
+
if (typeof instance.options.enableMultiRowSelection === 'function') {
|
|
3981
|
+
return instance.options.enableMultiRowSelection(row);
|
|
3982
|
+
}
|
|
3983
|
+
|
|
3984
|
+
return (_instance$options$ena3 = instance.options.enableMultiRowSelection) != null ? _instance$options$ena3 : true;
|
|
3985
|
+
},
|
|
3986
|
+
// getGroupingRowCanSelect: rowId => {
|
|
3987
|
+
// const row = instance.getRow(rowId)
|
|
3988
|
+
// if (!row) {
|
|
3989
|
+
// throw new Error()
|
|
3990
|
+
// }
|
|
3991
|
+
// if (typeof instance.options.enableGroupingRowSelection === 'function') {
|
|
3992
|
+
// return instance.options.enableGroupingRowSelection(row)
|
|
3993
|
+
// }
|
|
3994
|
+
// return instance.options.enableGroupingRowSelection ?? false
|
|
3995
|
+
// },
|
|
3996
|
+
getIsAllRowsSelected: function getIsAllRowsSelected() {
|
|
3997
|
+
var preFilteredFlatRows = instance.getPreGlobalFilteredFlatRows();
|
|
3998
|
+
|
|
3999
|
+
var _instance$getState3 = instance.getState(),
|
|
4000
|
+
rowSelection = _instance$getState3.rowSelection;
|
|
4001
|
+
|
|
4002
|
+
var isAllRowsSelected = Boolean(preFilteredFlatRows.length && Object.keys(rowSelection).length);
|
|
4003
|
+
|
|
4004
|
+
if (isAllRowsSelected) {
|
|
4005
|
+
if (preFilteredFlatRows.some(function (row) {
|
|
4006
|
+
return !rowSelection[row.id];
|
|
4007
|
+
})) {
|
|
4008
|
+
isAllRowsSelected = false;
|
|
4009
|
+
}
|
|
4010
|
+
}
|
|
4011
|
+
|
|
4012
|
+
return isAllRowsSelected;
|
|
4013
|
+
},
|
|
4014
|
+
getIsAllPageRowsSelected: function getIsAllPageRowsSelected() {
|
|
4015
|
+
var paginationFlatRows = instance.getPaginationFlatRows();
|
|
4016
|
+
|
|
4017
|
+
var _instance$getState4 = instance.getState(),
|
|
4018
|
+
rowSelection = _instance$getState4.rowSelection;
|
|
4019
|
+
|
|
4020
|
+
var isAllPageRowsSelected = !!paginationFlatRows.length;
|
|
4021
|
+
|
|
4022
|
+
if (isAllPageRowsSelected && paginationFlatRows.some(function (row) {
|
|
4023
|
+
return !rowSelection[row.id];
|
|
4024
|
+
})) {
|
|
4025
|
+
isAllPageRowsSelected = false;
|
|
4026
|
+
}
|
|
4027
|
+
|
|
4028
|
+
return isAllPageRowsSelected;
|
|
4029
|
+
},
|
|
4030
|
+
getIsSomeRowsSelected: function getIsSomeRowsSelected() {
|
|
4031
|
+
var _instance$getState$ro;
|
|
4032
|
+
|
|
4033
|
+
return !instance.getIsAllRowsSelected() && !!Object.keys((_instance$getState$ro = instance.getState().rowSelection) != null ? _instance$getState$ro : {}).length;
|
|
4034
|
+
},
|
|
4035
|
+
getIsSomePageRowsSelected: function getIsSomePageRowsSelected() {
|
|
4036
|
+
var paginationFlatRows = instance.getPaginationFlatRows();
|
|
4037
|
+
return instance.getIsAllPageRowsSelected() ? false : !!(paginationFlatRows != null && paginationFlatRows.length);
|
|
4038
|
+
},
|
|
4039
|
+
getToggleRowSelectedProps: function getToggleRowSelectedProps(rowId, userProps) {
|
|
4040
|
+
var row = instance.getRow(rowId);
|
|
4041
|
+
var isSelected = row.getIsSelected();
|
|
4042
|
+
var isSomeSelected = row.getIsSomeSelected();
|
|
4043
|
+
var canSelect = row.getCanSelect();
|
|
4044
|
+
var initialProps = {
|
|
4045
|
+
onChange: canSelect ? function (e) {
|
|
4046
|
+
row.toggleSelected(e.target.checked);
|
|
4047
|
+
} : undefined,
|
|
4048
|
+
checked: isSelected,
|
|
4049
|
+
title: 'Toggle Row Selected',
|
|
4050
|
+
indeterminate: isSomeSelected // onChange: forInput
|
|
4051
|
+
// ? (e: Event) => e.stopPropagation()
|
|
4052
|
+
// : (e: Event) => {
|
|
4053
|
+
// if (instance.options.isAdditiveSelectEvent(e)) {
|
|
4054
|
+
// row.toggleSelected()
|
|
4055
|
+
// } else if (instance.options.isInclusiveSelectEvent(e)) {
|
|
4056
|
+
// instance.addRowSelectionRange(row.id)
|
|
4057
|
+
// } else {
|
|
4058
|
+
// instance.setRowSelection({})
|
|
4059
|
+
// row.toggleSelected()
|
|
4060
|
+
// }
|
|
4061
|
+
// if (props.onClick) props.onClick(e)
|
|
4062
|
+
// },
|
|
4063
|
+
|
|
4064
|
+
};
|
|
4065
|
+
return propGetter(initialProps, userProps);
|
|
4066
|
+
},
|
|
4067
|
+
getToggleAllRowsSelectedProps: function getToggleAllRowsSelectedProps(userProps) {
|
|
4068
|
+
var isSomeRowsSelected = instance.getIsSomeRowsSelected();
|
|
4069
|
+
var isAllRowsSelected = instance.getIsAllRowsSelected();
|
|
4070
|
+
var initialProps = {
|
|
4071
|
+
onChange: function onChange(e) {
|
|
4072
|
+
instance.toggleAllRowsSelected(e.target.checked);
|
|
4073
|
+
},
|
|
4074
|
+
checked: isAllRowsSelected,
|
|
4075
|
+
title: 'Toggle All Rows Selected',
|
|
4076
|
+
indeterminate: isSomeRowsSelected
|
|
4077
|
+
};
|
|
4078
|
+
return propGetter(initialProps, userProps);
|
|
4079
|
+
},
|
|
4080
|
+
getToggleAllPageRowsSelectedProps: function getToggleAllPageRowsSelectedProps(userProps) {
|
|
4081
|
+
var isSomePageRowsSelected = instance.getIsSomePageRowsSelected();
|
|
4082
|
+
var isAllPageRowsSelected = instance.getIsAllPageRowsSelected();
|
|
4083
|
+
var initialProps = {
|
|
4084
|
+
onChange: function onChange(e) {
|
|
4085
|
+
instance.toggleAllPageRowsSelected(e.target.checked);
|
|
4086
|
+
},
|
|
4087
|
+
checked: isAllPageRowsSelected,
|
|
4088
|
+
title: 'Toggle All Current Page Rows Selected',
|
|
4089
|
+
indeterminate: isSomePageRowsSelected
|
|
4090
|
+
};
|
|
4091
|
+
return propGetter(initialProps, userProps);
|
|
4092
|
+
}
|
|
4093
|
+
};
|
|
4094
|
+
}
|
|
4095
|
+
function createRow(row, instance) {
|
|
4096
|
+
return {
|
|
4097
|
+
getIsSelected: function getIsSelected() {
|
|
4098
|
+
return instance.getRowIsSelected(row.id);
|
|
4099
|
+
},
|
|
4100
|
+
getIsSomeSelected: function getIsSomeSelected() {
|
|
4101
|
+
return instance.getRowIsSomeSelected(row.id);
|
|
4102
|
+
},
|
|
4103
|
+
toggleSelected: function toggleSelected(value) {
|
|
4104
|
+
return instance.toggleRowSelected(row.id, value);
|
|
4105
|
+
},
|
|
4106
|
+
getToggleSelectedProps: function getToggleSelectedProps(userProps) {
|
|
4107
|
+
return instance.getToggleRowSelectedProps(row.id, userProps);
|
|
4108
|
+
},
|
|
4109
|
+
getCanMultiSelect: function getCanMultiSelect() {
|
|
4110
|
+
return instance.getRowCanMultiSelect(row.id);
|
|
4111
|
+
},
|
|
4112
|
+
getCanSelect: function getCanSelect() {
|
|
4113
|
+
return instance.getRowCanSelect(row.id);
|
|
4114
|
+
}
|
|
4115
|
+
};
|
|
4116
|
+
}
|
|
4117
|
+
|
|
4118
|
+
var mutateRowIsSelected = function mutateRowIsSelected(selectedRowIds, id, value, instance) {
|
|
4119
|
+
var _row$subRows;
|
|
4120
|
+
|
|
4121
|
+
var row = instance.getRow(id);
|
|
4122
|
+
row.getIsGrouped(); // if ( // TODO: enforce grouping row selection rules
|
|
4123
|
+
// !isGrouped ||
|
|
4124
|
+
// (isGrouped && instance.options.enableGroupingRowSelection)
|
|
4125
|
+
// ) {
|
|
4126
|
+
|
|
4127
|
+
if (value) {
|
|
4128
|
+
selectedRowIds[id] = true;
|
|
4129
|
+
} else {
|
|
4130
|
+
delete selectedRowIds[id];
|
|
4131
|
+
} // }
|
|
4132
|
+
|
|
4133
|
+
|
|
4134
|
+
if ((_row$subRows = row.subRows) != null && _row$subRows.length && instance.getRowCanSelectSubRows(row.id)) {
|
|
4135
|
+
row.subRows.forEach(function (row) {
|
|
4136
|
+
return mutateRowIsSelected(selectedRowIds, row.id, value, instance);
|
|
4137
|
+
});
|
|
4138
|
+
}
|
|
4139
|
+
};
|
|
4140
|
+
|
|
4141
|
+
function selectRowsFn(instance, rowModel) {
|
|
4142
|
+
var rowSelection = instance.getState().rowSelection;
|
|
4143
|
+
var newSelectedFlatRows = [];
|
|
4144
|
+
var newSelectedRowsById = {}; // Filters top level and nested rows
|
|
4145
|
+
|
|
4146
|
+
var recurseRows = function recurseRows(rows, depth) {
|
|
4147
|
+
|
|
4148
|
+
return rows.map(function (row) {
|
|
4149
|
+
var _row$subRows2;
|
|
4150
|
+
|
|
4151
|
+
var isSelected = isRowSelected(row, rowSelection) === true;
|
|
4152
|
+
|
|
4153
|
+
if (isSelected) {
|
|
4154
|
+
newSelectedFlatRows.push(row);
|
|
4155
|
+
newSelectedRowsById[row.id] = row;
|
|
4156
|
+
}
|
|
4157
|
+
|
|
4158
|
+
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
|
|
4159
|
+
row = _extends({}, row, {
|
|
4160
|
+
subRows: recurseRows(row.subRows)
|
|
4161
|
+
});
|
|
4162
|
+
}
|
|
4163
|
+
|
|
4164
|
+
if (isSelected) {
|
|
4165
|
+
return row;
|
|
4166
|
+
}
|
|
4167
|
+
}).filter(Boolean);
|
|
4168
|
+
};
|
|
4169
|
+
|
|
4170
|
+
return {
|
|
4171
|
+
rows: recurseRows(rowModel.rows),
|
|
4172
|
+
flatRows: newSelectedFlatRows,
|
|
4173
|
+
rowsById: newSelectedRowsById
|
|
4174
|
+
};
|
|
4175
|
+
}
|
|
4176
|
+
function isRowSelected(row, selection, instance) {
|
|
4177
|
+
if (selection[row.id]) {
|
|
4178
|
+
return true;
|
|
4179
|
+
}
|
|
4180
|
+
|
|
4181
|
+
if (row.subRows && row.subRows.length) {
|
|
4182
|
+
var allChildrenSelected = true;
|
|
4183
|
+
var someSelected = false;
|
|
4184
|
+
row.subRows.forEach(function (subRow) {
|
|
4185
|
+
// Bail out early if we know both of these
|
|
4186
|
+
if (someSelected && !allChildrenSelected) {
|
|
4187
|
+
return;
|
|
4188
|
+
}
|
|
4189
|
+
|
|
4190
|
+
if (isRowSelected(subRow, selection)) {
|
|
4191
|
+
someSelected = true;
|
|
4192
|
+
} else {
|
|
4193
|
+
allChildrenSelected = false;
|
|
4194
|
+
}
|
|
4195
|
+
});
|
|
4196
|
+
return allChildrenSelected ? true : someSelected ? 'some' : false;
|
|
4197
|
+
}
|
|
4198
|
+
|
|
4199
|
+
return false;
|
|
4200
|
+
}
|
|
4201
|
+
|
|
4202
|
+
var RowSelection = /*#__PURE__*/Object.freeze({
|
|
4203
|
+
__proto__: null,
|
|
4204
|
+
getInitialState: getInitialState,
|
|
4205
|
+
getDefaultOptions: getDefaultOptions,
|
|
4206
|
+
getInstance: getInstance,
|
|
4207
|
+
createRow: createRow,
|
|
4208
|
+
selectRowsFn: selectRowsFn,
|
|
4209
|
+
isRowSelected: isRowSelected
|
|
4210
|
+
});
|
|
4211
|
+
|
|
4212
|
+
var features = [Visibility, Ordering, Pinning, Headers, Filters, Sorting, Grouping, Expanding, ColumnSizing, Pagination, RowSelection];
|
|
4213
|
+
function createTableInstance(options, rerender) {
|
|
4214
|
+
var _options$initialState;
|
|
4215
|
+
|
|
4216
|
+
if (options.debug) {
|
|
4217
|
+
console.info('Creating React Table Instance...');
|
|
4218
|
+
}
|
|
4219
|
+
|
|
4220
|
+
var instance = {};
|
|
4221
|
+
var defaultOptions = features.reduce(function (obj, feature) {
|
|
4222
|
+
return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(instance));
|
|
4223
|
+
}, {});
|
|
4224
|
+
var defaultState = {};
|
|
4225
|
+
|
|
4226
|
+
var buildOptions = function buildOptions(options) {
|
|
4227
|
+
return _extends({
|
|
4228
|
+
state: defaultState
|
|
4229
|
+
}, defaultOptions, options);
|
|
4230
|
+
};
|
|
4231
|
+
|
|
4232
|
+
instance.options = buildOptions(options);
|
|
4233
|
+
|
|
4234
|
+
var initialState = _extends({}, features.reduce(function (obj, feature) {
|
|
4235
|
+
return Object.assign(obj, feature.getInitialState == null ? void 0 : feature.getInitialState());
|
|
4236
|
+
}, {}), (_options$initialState = options.initialState) != null ? _options$initialState : {});
|
|
4237
|
+
|
|
4238
|
+
var finalInstance = _extends({}, instance, features.reduce(function (obj, feature) {
|
|
4239
|
+
return Object.assign(obj, feature.getInstance == null ? void 0 : feature.getInstance(instance));
|
|
4240
|
+
}, {}), {
|
|
4241
|
+
rerender: rerender,
|
|
4242
|
+
initialState: initialState,
|
|
4243
|
+
internalState: initialState,
|
|
4244
|
+
reset: function reset() {
|
|
4245
|
+
instance.setState(instance.initialState);
|
|
4246
|
+
},
|
|
4247
|
+
updateOptions: function updateOptions(newOptions) {
|
|
4248
|
+
instance.options = buildOptions(newOptions);
|
|
4249
|
+
},
|
|
4250
|
+
getRowId: function getRowId(_, index, parent) {
|
|
4251
|
+
return "" + (parent ? [parent.id, index].join('.') : index);
|
|
4252
|
+
},
|
|
4253
|
+
getState: function getState() {
|
|
4254
|
+
var state = _extends({}, instance.internalState, instance.options.state);
|
|
4255
|
+
|
|
4256
|
+
return state;
|
|
4257
|
+
},
|
|
4258
|
+
setState: function setState(updater, shouldRerender) {
|
|
4259
|
+
if (shouldRerender === void 0) {
|
|
4260
|
+
shouldRerender = true;
|
|
4261
|
+
}
|
|
4262
|
+
|
|
4263
|
+
var onStateChange = instance.options.onStateChange;
|
|
4264
|
+
var internalState = instance.internalState;
|
|
4265
|
+
var newState = functionalUpdate(updater, internalState);
|
|
4266
|
+
instance.internalState = newState;
|
|
4267
|
+
|
|
4268
|
+
if (onStateChange) {
|
|
4269
|
+
onStateChange(newState);
|
|
4270
|
+
return;
|
|
4271
|
+
}
|
|
4272
|
+
|
|
4273
|
+
if (shouldRerender) {
|
|
4274
|
+
instance.rerender();
|
|
4275
|
+
}
|
|
4276
|
+
},
|
|
4277
|
+
getDefaultColumn: memo(function () {
|
|
4278
|
+
return [instance.options.defaultColumn];
|
|
4279
|
+
}, function (defaultColumn) {
|
|
4280
|
+
var _defaultColumn;
|
|
4281
|
+
|
|
4282
|
+
defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
|
|
4283
|
+
return _extends({
|
|
4284
|
+
header: function header(props) {
|
|
4285
|
+
return props.header.column.id;
|
|
4286
|
+
},
|
|
4287
|
+
footer: function footer(props) {
|
|
4288
|
+
return props.header.column.id;
|
|
4289
|
+
},
|
|
4290
|
+
cell: function cell(_ref) {
|
|
4291
|
+
var _ref$value = _ref.value,
|
|
2957
4292
|
value = _ref$value === void 0 ? '' : _ref$value;
|
|
2958
4293
|
return typeof value === 'boolean' ? value.toString() : value;
|
|
2959
4294
|
}
|
|
2960
|
-
},
|
|
2961
|
-
|
|
4295
|
+
}, features.reduce(function (obj, feature) {
|
|
4296
|
+
return Object.assign(obj, feature.getDefaultColumn == null ? void 0 : feature.getDefaultColumn());
|
|
4297
|
+
}, {}), defaultColumn);
|
|
4298
|
+
}, {
|
|
4299
|
+
debug: instance.options.debug,
|
|
4300
|
+
key: 'getDefaultColumn'
|
|
4301
|
+
}),
|
|
2962
4302
|
getColumnDefs: function getColumnDefs() {
|
|
2963
4303
|
return instance.options.columns;
|
|
2964
4304
|
},
|
|
2965
|
-
createColumn: function createColumn
|
|
4305
|
+
createColumn: function createColumn(columnDef, depth, parent) {
|
|
2966
4306
|
var _ref2, _columnDef$id;
|
|
2967
4307
|
|
|
2968
4308
|
var defaultColumn = instance.getDefaultColumn();
|
|
@@ -2983,11 +4323,7 @@
|
|
|
2983
4323
|
}
|
|
2984
4324
|
}
|
|
2985
4325
|
|
|
2986
|
-
var column = _extends({
|
|
2987
|
-
width: 150,
|
|
2988
|
-
minWidth: 20,
|
|
2989
|
-
maxWidth: Number.MAX_SAFE_INTEGER
|
|
2990
|
-
}, defaultColumn, columnDef, {
|
|
4326
|
+
var column = _extends({}, defaultColumnSizing, defaultColumn, columnDef, {
|
|
2991
4327
|
id: "" + id,
|
|
2992
4328
|
accessorFn: accessorFn,
|
|
2993
4329
|
parent: parent,
|
|
@@ -3005,7 +4341,10 @@
|
|
|
3005
4341
|
return [column].concat((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(function (d) {
|
|
3006
4342
|
return d.getFlatColumns();
|
|
3007
4343
|
}));
|
|
3008
|
-
},
|
|
4344
|
+
}, {
|
|
4345
|
+
key: 'column.getFlatColumns',
|
|
4346
|
+
debug: instance.options.debug
|
|
4347
|
+
}),
|
|
3009
4348
|
getLeafColumns: memo(function () {
|
|
3010
4349
|
return [instance.getOrderColumnsFn()];
|
|
3011
4350
|
}, function (orderColumns) {
|
|
@@ -3019,10 +4358,15 @@
|
|
|
3019
4358
|
}
|
|
3020
4359
|
|
|
3021
4360
|
return [column];
|
|
3022
|
-
},
|
|
4361
|
+
}, {
|
|
4362
|
+
key: 'column.getLeafColumns',
|
|
4363
|
+
debug: instance.options.debug
|
|
4364
|
+
})
|
|
3023
4365
|
});
|
|
3024
4366
|
|
|
3025
|
-
column =
|
|
4367
|
+
column = features.reduce(function (obj, feature) {
|
|
4368
|
+
return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
|
|
4369
|
+
}, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
3026
4370
|
|
|
3027
4371
|
return column;
|
|
3028
4372
|
},
|
|
@@ -3044,14 +4388,20 @@
|
|
|
3044
4388
|
};
|
|
3045
4389
|
|
|
3046
4390
|
return recurseColumns(columnDefs);
|
|
3047
|
-
},
|
|
4391
|
+
}, {
|
|
4392
|
+
key: 'getAllColumns',
|
|
4393
|
+
debug: instance.options.debug
|
|
4394
|
+
}),
|
|
3048
4395
|
getAllFlatColumns: memo(function () {
|
|
3049
4396
|
return [instance.getAllColumns()];
|
|
3050
4397
|
}, function (allColumns) {
|
|
3051
4398
|
return allColumns.flatMap(function (column) {
|
|
3052
4399
|
return column.getFlatColumns();
|
|
3053
4400
|
});
|
|
3054
|
-
},
|
|
4401
|
+
}, {
|
|
4402
|
+
key: 'getAllFlatColumns',
|
|
4403
|
+
debug: instance.options.debug
|
|
4404
|
+
}),
|
|
3055
4405
|
getAllFlatColumnsById: memo(function () {
|
|
3056
4406
|
return [instance.getAllFlatColumns()];
|
|
3057
4407
|
}, function (flatColumns) {
|
|
@@ -3059,7 +4409,10 @@
|
|
|
3059
4409
|
acc[column.id] = column;
|
|
3060
4410
|
return acc;
|
|
3061
4411
|
}, {});
|
|
3062
|
-
},
|
|
4412
|
+
}, {
|
|
4413
|
+
key: 'getAllFlatColumnsById',
|
|
4414
|
+
debug: instance.options.debug
|
|
4415
|
+
}),
|
|
3063
4416
|
getAllLeafColumns: memo(function () {
|
|
3064
4417
|
return [instance.getAllColumns(), instance.getOrderColumnsFn()];
|
|
3065
4418
|
}, function (allColumns, orderColumns) {
|
|
@@ -3067,7 +4420,10 @@
|
|
|
3067
4420
|
return column.getLeafColumns();
|
|
3068
4421
|
});
|
|
3069
4422
|
return orderColumns(leafColumns);
|
|
3070
|
-
},
|
|
4423
|
+
}, {
|
|
4424
|
+
key: 'getAllLeafColumns',
|
|
4425
|
+
debug: instance.options.debug
|
|
4426
|
+
}),
|
|
3071
4427
|
getColumn: function getColumn(columnId) {
|
|
3072
4428
|
var column = instance.getAllFlatColumnsById()[columnId];
|
|
3073
4429
|
|
|
@@ -3082,7 +4438,7 @@
|
|
|
3082
4438
|
return column;
|
|
3083
4439
|
},
|
|
3084
4440
|
getColumnWidth: function getColumnWidth(columnId) {
|
|
3085
|
-
var _column$minWidth,
|
|
4441
|
+
var _column$minWidth, _ref3, _column$maxWidth;
|
|
3086
4442
|
|
|
3087
4443
|
var column = instance.getColumn(columnId);
|
|
3088
4444
|
|
|
@@ -3090,9 +4446,10 @@
|
|
|
3090
4446
|
throw new Error();
|
|
3091
4447
|
}
|
|
3092
4448
|
|
|
3093
|
-
|
|
4449
|
+
var columnSize = instance.getState().columnSizing[column.id];
|
|
4450
|
+
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);
|
|
3094
4451
|
},
|
|
3095
|
-
createCell: function createCell
|
|
4452
|
+
createCell: function createCell(row, column, value) {
|
|
3096
4453
|
var cell = {
|
|
3097
4454
|
id: row.id + "_" + column.id,
|
|
3098
4455
|
rowId: row.id,
|
|
@@ -3105,16 +4462,20 @@
|
|
|
3105
4462
|
},
|
|
3106
4463
|
renderCell: function renderCell() {
|
|
3107
4464
|
return flexRender(column.cell, {
|
|
4465
|
+
instance: instance,
|
|
3108
4466
|
column: column,
|
|
4467
|
+
row: row,
|
|
3109
4468
|
cell: cell,
|
|
3110
4469
|
value: value
|
|
3111
4470
|
});
|
|
3112
4471
|
}
|
|
3113
4472
|
};
|
|
3114
|
-
|
|
4473
|
+
features.forEach(function (feature) {
|
|
4474
|
+
Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
|
|
4475
|
+
}, {});
|
|
3115
4476
|
return cell;
|
|
3116
4477
|
},
|
|
3117
|
-
createRow: function createRow
|
|
4478
|
+
createRow: function createRow(id, original, rowIndex, depth, values) {
|
|
3118
4479
|
var row = {
|
|
3119
4480
|
id: id,
|
|
3120
4481
|
index: rowIndex,
|
|
@@ -3135,7 +4496,10 @@
|
|
|
3135
4496
|
return leafColumns.map(function (column) {
|
|
3136
4497
|
return instance.createCell(row, column, row.values[column.id]);
|
|
3137
4498
|
});
|
|
3138
|
-
},
|
|
4499
|
+
}, {
|
|
4500
|
+
key: 'row.getAllCells' ,
|
|
4501
|
+
debug: instance.options.debug
|
|
4502
|
+
});
|
|
3139
4503
|
row.getAllCellsByColumnId = memo(function () {
|
|
3140
4504
|
return [row.getAllCells()];
|
|
3141
4505
|
}, function (allCells) {
|
|
@@ -3143,42 +4507,19 @@
|
|
|
3143
4507
|
acc[cell.columnId] = cell;
|
|
3144
4508
|
return acc;
|
|
3145
4509
|
}, {});
|
|
3146
|
-
},
|
|
3147
|
-
|
|
4510
|
+
}, {
|
|
4511
|
+
key: 'row.getAllCellsByColumnId',
|
|
4512
|
+
debug: instance.options.debug
|
|
4513
|
+
});
|
|
4514
|
+
features.forEach(function (feature) {
|
|
4515
|
+
Object.assign(row, feature.createRow == null ? void 0 : feature.createRow(row, instance));
|
|
4516
|
+
});
|
|
3148
4517
|
return row;
|
|
3149
4518
|
},
|
|
3150
4519
|
getCoreRowModel: memo(function () {
|
|
3151
4520
|
return [instance.options.data];
|
|
3152
4521
|
}, function (data) {
|
|
3153
|
-
if (instance.options.debug) console.info('Accessing...'); //
|
|
3154
|
-
|
|
3155
|
-
if (instance.options.autoResetColumnFilters && // @ts-ignore
|
|
3156
|
-
instance.getRowModelNonFirst) {
|
|
3157
|
-
instance.resetColumnFilters();
|
|
3158
|
-
}
|
|
3159
|
-
|
|
3160
|
-
if (instance.options.autoResetGlobalFilter && // @ts-ignore
|
|
3161
|
-
instance.getRowModelNonFirst) {
|
|
3162
|
-
instance.resetGlobalFilter();
|
|
3163
|
-
}
|
|
3164
|
-
|
|
3165
|
-
if (instance.options.autoResetSorting && // @ts-ignore
|
|
3166
|
-
instance.getRowModelNonFirst) {
|
|
3167
|
-
instance.resetSorting();
|
|
3168
|
-
}
|
|
3169
|
-
|
|
3170
|
-
if (instance.options.autoResetGrouping && // @ts-ignore
|
|
3171
|
-
instance.getRowModelNonFirst) {
|
|
3172
|
-
instance.resetGrouping();
|
|
3173
|
-
}
|
|
3174
|
-
|
|
3175
|
-
if (instance.options.autoResetExpanded && // @ts-ignore
|
|
3176
|
-
instance.getRowModelNonFirst) {
|
|
3177
|
-
instance.resetExpanded();
|
|
3178
|
-
} // @ts-ignore
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
instance.getRowModelNonFirst = true; // Access the row model using initial columns
|
|
4522
|
+
if (instance.options.debug) console.info('Accessing...'); // Access the row model using initial columns
|
|
3182
4523
|
|
|
3183
4524
|
var rows = [];
|
|
3184
4525
|
var flatRows = [];
|
|
@@ -3246,7 +4587,15 @@
|
|
|
3246
4587
|
flatRows: flatRows,
|
|
3247
4588
|
rowsById: rowsById
|
|
3248
4589
|
};
|
|
3249
|
-
},
|
|
4590
|
+
}, {
|
|
4591
|
+
key: 'getRowModel',
|
|
4592
|
+
debug: instance.options.debug,
|
|
4593
|
+
onChange: function onChange() {
|
|
4594
|
+
instance._notifyRowSelectionReset();
|
|
4595
|
+
|
|
4596
|
+
instance._notifyFiltersReset();
|
|
4597
|
+
}
|
|
4598
|
+
}),
|
|
3250
4599
|
// The standard
|
|
3251
4600
|
getCoreRows: function getCoreRows() {
|
|
3252
4601
|
return instance.getCoreRowModel().rows;
|
|
@@ -3260,7 +4609,7 @@
|
|
|
3260
4609
|
// The final calls start at the bottom of the model,
|
|
3261
4610
|
// expanded rows, which then work their way up
|
|
3262
4611
|
getRowModel: function getRowModel() {
|
|
3263
|
-
return instance.
|
|
4612
|
+
return instance.getPaginationRowModel();
|
|
3264
4613
|
},
|
|
3265
4614
|
getRows: function getRows() {
|
|
3266
4615
|
return instance.getRowModel().rows;
|
|
@@ -3334,10 +4683,44 @@
|
|
|
3334
4683
|
key: cell.id,
|
|
3335
4684
|
role: 'gridcell'
|
|
3336
4685
|
}, userProps);
|
|
4686
|
+
},
|
|
4687
|
+
getTableWidth: function getTableWidth() {
|
|
4688
|
+
var _instance$getHeaderGr, _instance$getHeaderGr2;
|
|
4689
|
+
|
|
4690
|
+
return (_instance$getHeaderGr = (_instance$getHeaderGr2 = instance.getHeaderGroups()[0]) == null ? void 0 : _instance$getHeaderGr2.headers.reduce(function (sum, header) {
|
|
4691
|
+
return sum + header.getWidth();
|
|
4692
|
+
}, 0)) != null ? _instance$getHeaderGr : 0;
|
|
4693
|
+
},
|
|
4694
|
+
getLeftTableWidth: function getLeftTableWidth() {
|
|
4695
|
+
var _instance$getLeftHead, _instance$getLeftHead2;
|
|
4696
|
+
|
|
4697
|
+
return (_instance$getLeftHead = (_instance$getLeftHead2 = instance.getLeftHeaderGroups()[0]) == null ? void 0 : _instance$getLeftHead2.headers.reduce(function (sum, header) {
|
|
4698
|
+
return sum + header.getWidth();
|
|
4699
|
+
}, 0)) != null ? _instance$getLeftHead : 0;
|
|
4700
|
+
},
|
|
4701
|
+
getCenterTableWidth: function getCenterTableWidth() {
|
|
4702
|
+
var _instance$getCenterHe, _instance$getCenterHe2;
|
|
4703
|
+
|
|
4704
|
+
return (_instance$getCenterHe = (_instance$getCenterHe2 = instance.getCenterHeaderGroups()[0]) == null ? void 0 : _instance$getCenterHe2.headers.reduce(function (sum, header) {
|
|
4705
|
+
return sum + header.getWidth();
|
|
4706
|
+
}, 0)) != null ? _instance$getCenterHe : 0;
|
|
4707
|
+
},
|
|
4708
|
+
getRightTableWidth: function getRightTableWidth() {
|
|
4709
|
+
var _instance$getRightHea, _instance$getRightHea2;
|
|
4710
|
+
|
|
4711
|
+
return (_instance$getRightHea = (_instance$getRightHea2 = instance.getRightHeaderGroups()[0]) == null ? void 0 : _instance$getRightHea2.headers.reduce(function (sum, header) {
|
|
4712
|
+
return sum + header.getWidth();
|
|
4713
|
+
}, 0)) != null ? _instance$getRightHea : 0;
|
|
3337
4714
|
}
|
|
3338
4715
|
});
|
|
3339
4716
|
|
|
3340
|
-
|
|
4717
|
+
instance = Object.assign(instance, finalInstance); // This won't trigger a rerender yet, but it will force
|
|
4718
|
+
// pagination derivation to run (particularly pageSize detection)
|
|
4719
|
+
|
|
4720
|
+
instance.setPagination(function (d) {
|
|
4721
|
+
return d;
|
|
4722
|
+
});
|
|
4723
|
+
return instance;
|
|
3341
4724
|
}
|
|
3342
4725
|
|
|
3343
4726
|
function createTable() {
|
|
@@ -3357,7 +4740,17 @@
|
|
|
3357
4740
|
createColumns: function createColumns(columns) {
|
|
3358
4741
|
return columns;
|
|
3359
4742
|
},
|
|
3360
|
-
|
|
4743
|
+
createDisplayColumn: function createDisplayColumn(column) {
|
|
4744
|
+
return _extends({}, column, {
|
|
4745
|
+
__generated: true
|
|
4746
|
+
});
|
|
4747
|
+
},
|
|
4748
|
+
createGroup: function createGroup(column) {
|
|
4749
|
+
return _extends({}, column, {
|
|
4750
|
+
__generated: true
|
|
4751
|
+
});
|
|
4752
|
+
},
|
|
4753
|
+
createDataColumn: function createDataColumn(accessor, column) {
|
|
3361
4754
|
column = _extends({}, column, {
|
|
3362
4755
|
id: column.id
|
|
3363
4756
|
});
|
|
@@ -3381,11 +4774,6 @@
|
|
|
3381
4774
|
|
|
3382
4775
|
throw new Error('Invalid accessor');
|
|
3383
4776
|
},
|
|
3384
|
-
createGroup: function createGroup(column) {
|
|
3385
|
-
return _extends({}, column, {
|
|
3386
|
-
__generated: true
|
|
3387
|
-
});
|
|
3388
|
-
},
|
|
3389
4777
|
useTable: function useTable(options) {
|
|
3390
4778
|
var instanceRef = React__namespace.useRef(undefined);
|
|
3391
4779
|
var rerender = React__namespace.useReducer(function () {
|
|
@@ -3408,6 +4796,7 @@
|
|
|
3408
4796
|
exports.expandRowsFn = expandRowsFn;
|
|
3409
4797
|
exports.globalFilterRowsFn = globalFilterRowsFn;
|
|
3410
4798
|
exports.groupRowsFn = groupRowsFn;
|
|
4799
|
+
exports.paginateRowsFn = paginateRowsFn;
|
|
3411
4800
|
exports.sortRowsFn = sortRowsFn;
|
|
3412
4801
|
|
|
3413
4802
|
Object.defineProperty(exports, '__esModule', { value: true });
|