@tanstack/react-table 8.0.0-alpha.4 → 8.0.0-alpha.42
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/_virtual/_rollupPluginBabelHelpers.js +0 -78
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/build/cjs/index.js +102 -17
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.js +41 -4716
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +29 -779
- package/build/types/index.d.ts +13 -8
- package/build/umd/index.development.js +51 -4719
- 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 +4 -1
- package/src/index.tsx +107 -8
- package/build/cjs/aggregationTypes.js +0 -130
- package/build/cjs/aggregationTypes.js.map +0 -1
- package/build/cjs/core.js +0 -552
- package/build/cjs/core.js.map +0 -1
- package/build/cjs/createTable.js +0 -108
- package/build/cjs/createTable.js.map +0 -1
- package/build/cjs/features/ColumnSizing.js +0 -317
- package/build/cjs/features/ColumnSizing.js.map +0 -1
- package/build/cjs/features/Expanding.js +0 -255
- package/build/cjs/features/Expanding.js.map +0 -1
- package/build/cjs/features/Filters.js +0 -445
- package/build/cjs/features/Filters.js.map +0 -1
- package/build/cjs/features/Grouping.js +0 -249
- package/build/cjs/features/Grouping.js.map +0 -1
- package/build/cjs/features/Headers.js +0 -549
- package/build/cjs/features/Headers.js.map +0 -1
- package/build/cjs/features/Ordering.js +0 -86
- package/build/cjs/features/Ordering.js.map +0 -1
- package/build/cjs/features/Pagination.js +0 -198
- package/build/cjs/features/Pagination.js.map +0 -1
- package/build/cjs/features/Pinning.js +0 -149
- package/build/cjs/features/Pinning.js.map +0 -1
- package/build/cjs/features/RowSelection.js +0 -541
- package/build/cjs/features/RowSelection.js.map +0 -1
- package/build/cjs/features/Sorting.js +0 -327
- package/build/cjs/features/Sorting.js.map +0 -1
- package/build/cjs/features/Visibility.js +0 -166
- package/build/cjs/features/Visibility.js.map +0 -1
- package/build/cjs/filterTypes.js +0 -172
- package/build/cjs/filterTypes.js.map +0 -1
- package/build/cjs/sortTypes.js +0 -122
- package/build/cjs/sortTypes.js.map +0 -1
- package/build/cjs/utils/columnFilterRowsFn.js +0 -131
- package/build/cjs/utils/columnFilterRowsFn.js.map +0 -1
- package/build/cjs/utils/expandRowsFn.js +0 -38
- package/build/cjs/utils/expandRowsFn.js.map +0 -1
- package/build/cjs/utils/globalFilterRowsFn.js +0 -101
- package/build/cjs/utils/globalFilterRowsFn.js.map +0 -1
- package/build/cjs/utils/groupRowsFn.js +0 -155
- package/build/cjs/utils/groupRowsFn.js.map +0 -1
- package/build/cjs/utils/paginateRowsFn.js +0 -44
- package/build/cjs/utils/paginateRowsFn.js.map +0 -1
- package/build/cjs/utils/sortRowsFn.js +0 -94
- package/build/cjs/utils/sortRowsFn.js.map +0 -1
- package/build/cjs/utils.js +0 -146
- package/build/cjs/utils.js.map +0 -1
- package/build/types/aggregationTypes.d.ts +0 -22
- package/build/types/core.d.ts +0 -111
- package/build/types/createTable.d.ts +0 -53
- package/build/types/features/ColumnSizing.d.ts +0 -67
- package/build/types/features/Expanding.d.ts +0 -53
- package/build/types/features/Filters.d.ts +0 -98
- package/build/types/features/Grouping.d.ts +0 -82
- package/build/types/features/Headers.d.ts +0 -41
- package/build/types/features/Ordering.d.ts +0 -19
- package/build/types/features/Pagination.d.ts +0 -44
- package/build/types/features/Pinning.d.ts +0 -39
- package/build/types/features/RowSelection.d.ts +0 -66
- package/build/types/features/Sorting.d.ts +0 -78
- package/build/types/features/Visibility.d.ts +0 -47
- package/build/types/filterTypes.d.ts +0 -50
- package/build/types/sortTypes.d.ts +0 -18
- package/build/types/types.d.ts +0 -127
- package/build/types/utils/columnFilterRowsFn.d.ts +0 -2
- package/build/types/utils/expandRowsFn.d.ts +0 -2
- package/build/types/utils/globalFilterRowsFn.d.ts +0 -2
- package/build/types/utils/groupRowsFn.d.ts +0 -2
- package/build/types/utils/paginateRowsFn.d.ts +0 -2
- package/build/types/utils/sortRowsFn.d.ts +0 -2
- package/build/types/utils.d.ts +0 -28
- package/src/aggregationTypes.ts +0 -115
- package/src/core.tsx +0 -1181
- package/src/createTable.tsx +0 -241
- package/src/features/ColumnSizing.ts +0 -453
- package/src/features/Expanding.ts +0 -404
- package/src/features/Filters.ts +0 -762
- package/src/features/Grouping.ts +0 -466
- package/src/features/Headers.ts +0 -912
- package/src/features/Ordering.ts +0 -133
- package/src/features/Pagination.ts +0 -327
- package/src/features/Pinning.ts +0 -200
- package/src/features/RowSelection.ts +0 -831
- package/src/features/Sorting.ts +0 -547
- package/src/features/Visibility.ts +0 -279
- package/src/filterTypes.ts +0 -251
- package/src/sortTypes.ts +0 -159
- package/src/types.ts +0 -331
- package/src/utils/columnFilterRowsFn.ts +0 -155
- package/src/utils/expandRowsFn.ts +0 -50
- package/src/utils/globalFilterRowsFn.ts +0 -122
- package/src/utils/groupRowsFn.ts +0 -194
- package/src/utils/paginateRowsFn.ts +0 -34
- package/src/utils/sortRowsFn.ts +0 -115
- package/src/utils.tsx +0 -257
|
@@ -9,12 +9,10 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
(function (global, factory) {
|
|
12
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
|
|
13
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
|
|
14
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactTable = {}, global.React));
|
|
15
|
-
})(this, (function (exports, React) { 'use strict';
|
|
16
|
-
|
|
17
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@tanstack/table-core')) :
|
|
13
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', '@tanstack/table-core'], factory) :
|
|
14
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactTable = {}, global.React, global.TableCore));
|
|
15
|
+
})(this, (function (exports, React, tableCore) { 'use strict';
|
|
18
16
|
|
|
19
17
|
function _interopNamespace(e) {
|
|
20
18
|
if (e && e.__esModule) return e;
|
|
@@ -34,287 +32,8 @@
|
|
|
34
32
|
return Object.freeze(n);
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
38
35
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
39
36
|
|
|
40
|
-
function columnFilterRowsFn(instance, rowModel) {
|
|
41
|
-
var columnFilters = instance.getState().columnFilters;
|
|
42
|
-
var newFilteredFlatRows = [];
|
|
43
|
-
var newFilteredRowsById = {};
|
|
44
|
-
var filterFromChildrenUp = instance.options.filterFromChildrenUp;
|
|
45
|
-
|
|
46
|
-
var filterRows = function filterRows(rowsToFilter, depth) {
|
|
47
|
-
columnFilters.forEach(function (_ref) {
|
|
48
|
-
var columnId = _ref.id,
|
|
49
|
-
filterValue = _ref.value;
|
|
50
|
-
// Find the columnFilters column
|
|
51
|
-
var column = instance.getColumn(columnId);
|
|
52
|
-
|
|
53
|
-
if (!column) {
|
|
54
|
-
{
|
|
55
|
-
console.warn("React-Table: Could not find a column with id: " + columnId);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
throw new Error();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (depth === 0) {
|
|
62
|
-
var preFilteredRows = [].concat(rowsToFilter);
|
|
63
|
-
|
|
64
|
-
column.getPreFilteredRows = function () {
|
|
65
|
-
return preFilteredRows;
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
var filterFn = instance.getColumnFilterFn(column.id);
|
|
70
|
-
|
|
71
|
-
if (!filterFn) {
|
|
72
|
-
{
|
|
73
|
-
console.warn("Could not find a valid 'column.filterType' for column with the ID: " + column.id + ".");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return;
|
|
77
|
-
} // Pass the rows, id, filterValue and column to the filterFn
|
|
78
|
-
// to get the filtered rows back
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
rowsToFilter = filterFn(rowsToFilter, [columnId], filterValue);
|
|
82
|
-
});
|
|
83
|
-
return rowsToFilter;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
if (filterFromChildrenUp) {
|
|
87
|
-
var _recurseFilterRows = function _recurseFilterRows(rowsToFilter, depth) {
|
|
88
|
-
if (depth === void 0) {
|
|
89
|
-
depth = 0;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Filter from children up
|
|
93
|
-
rowsToFilter = rowsToFilter.filter(function (row) {
|
|
94
|
-
var _row$subRows;
|
|
95
|
-
|
|
96
|
-
if (!((_row$subRows = row.subRows) != null && _row$subRows.length)) {
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
row.subRows = _recurseFilterRows(row.subRows, depth + 1);
|
|
101
|
-
return row.subRows.length;
|
|
102
|
-
});
|
|
103
|
-
rowsToFilter = filterRows(rowsToFilter, depth); // Apply the filter to any subRows
|
|
104
|
-
|
|
105
|
-
rowsToFilter.forEach(function (row) {
|
|
106
|
-
newFilteredFlatRows.push(row);
|
|
107
|
-
newFilteredRowsById[row.id] = row;
|
|
108
|
-
});
|
|
109
|
-
return rowsToFilter;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
return {
|
|
113
|
-
rows: _recurseFilterRows(rowModel.rows),
|
|
114
|
-
flatRows: newFilteredFlatRows,
|
|
115
|
-
rowsById: newFilteredRowsById
|
|
116
|
-
};
|
|
117
|
-
} // Filters top level and nested rows
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
var recurseFilterRows = function recurseFilterRows(rowsToFilter, depth) {
|
|
121
|
-
if (depth === void 0) {
|
|
122
|
-
depth = 0;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Filter from parents downward
|
|
126
|
-
rowsToFilter = filterRows(rowsToFilter, depth); // Apply the filter to any subRows
|
|
127
|
-
// We technically could do this recursively in the above loop,
|
|
128
|
-
// but that would severely hinder the API for the user, since they
|
|
129
|
-
// would be required to do that recursion in some scenarios
|
|
130
|
-
|
|
131
|
-
rowsToFilter.forEach(function (row) {
|
|
132
|
-
newFilteredFlatRows.push(row);
|
|
133
|
-
newFilteredRowsById[row.id] = row;
|
|
134
|
-
|
|
135
|
-
if (!filterFromChildrenUp) {
|
|
136
|
-
var _row$subRows2;
|
|
137
|
-
|
|
138
|
-
if (!((_row$subRows2 = row.subRows) != null && _row$subRows2.length)) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
row.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
return rowsToFilter;
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
return {
|
|
149
|
-
rows: recurseFilterRows(rowModel.rows),
|
|
150
|
-
flatRows: newFilteredFlatRows,
|
|
151
|
-
rowsById: newFilteredRowsById
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function globalFilterRowsFn(instance, rowModel) {
|
|
156
|
-
var globalFilter = instance.getState().globalFilter;
|
|
157
|
-
var newFilteredFlatRows = [];
|
|
158
|
-
var newFilteredRowsById = {};
|
|
159
|
-
var filterFromChildrenUp = instance.options.filterFromChildrenUp;
|
|
160
|
-
var filterFn = instance.getGlobalFilterFn();
|
|
161
|
-
|
|
162
|
-
if (!filterFn) {
|
|
163
|
-
{
|
|
164
|
-
console.warn("Could not find a valid 'globalFilterType'");
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return rowModel;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
var filterableColumns = instance.getAllLeafColumns().filter(function (column) {
|
|
171
|
-
return column.getCanGlobalFilter();
|
|
172
|
-
});
|
|
173
|
-
var filterableColumnIds = filterableColumns.map(function (d) {
|
|
174
|
-
return d.id;
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
if (filterFromChildrenUp) {
|
|
178
|
-
var _recurseFilterRows = function _recurseFilterRows(rowsToFilter, depth) {
|
|
179
|
-
|
|
180
|
-
// Filter from children up
|
|
181
|
-
rowsToFilter = rowsToFilter.filter(function (row) {
|
|
182
|
-
var _row$subRows;
|
|
183
|
-
|
|
184
|
-
if (!((_row$subRows = row.subRows) != null && _row$subRows.length)) {
|
|
185
|
-
return true;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
row.subRows = _recurseFilterRows(row.subRows);
|
|
189
|
-
return row.subRows.length;
|
|
190
|
-
});
|
|
191
|
-
rowsToFilter = filterFn(rowsToFilter, filterableColumnIds, globalFilter); // Apply the filter to any subRows
|
|
192
|
-
|
|
193
|
-
rowsToFilter.forEach(function (row) {
|
|
194
|
-
newFilteredFlatRows.push(row);
|
|
195
|
-
newFilteredRowsById[row.id] = row;
|
|
196
|
-
});
|
|
197
|
-
return rowsToFilter;
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
return {
|
|
201
|
-
rows: _recurseFilterRows(rowModel.rows),
|
|
202
|
-
flatRows: newFilteredFlatRows,
|
|
203
|
-
rowsById: newFilteredRowsById
|
|
204
|
-
};
|
|
205
|
-
} // Filters top level and nested rows
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
var recurseFilterRows = function recurseFilterRows(rowsToFilter, depth) {
|
|
209
|
-
|
|
210
|
-
// Filter from parents downward
|
|
211
|
-
rowsToFilter = filterFn(rowsToFilter, filterableColumnIds, globalFilter); // Apply the filter to any subRows
|
|
212
|
-
// We technically could do this recursively in the above loop,
|
|
213
|
-
// but that would severely hinder the API for the user, since they
|
|
214
|
-
// would be required to do that recursion in some scenarios
|
|
215
|
-
|
|
216
|
-
rowsToFilter.forEach(function (row) {
|
|
217
|
-
newFilteredFlatRows.push(row);
|
|
218
|
-
newFilteredRowsById[row.id] = row;
|
|
219
|
-
|
|
220
|
-
if (!filterFromChildrenUp) {
|
|
221
|
-
var _row$subRows2;
|
|
222
|
-
|
|
223
|
-
if (!((_row$subRows2 = row.subRows) != null && _row$subRows2.length)) {
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
row.subRows = recurseFilterRows(row.subRows);
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
return rowsToFilter;
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
return {
|
|
234
|
-
rows: recurseFilterRows(rowModel.rows),
|
|
235
|
-
flatRows: newFilteredFlatRows,
|
|
236
|
-
rowsById: newFilteredRowsById
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function sortRowsFn(instance, rowModel) {
|
|
241
|
-
var sortingState = instance.getState().sorting;
|
|
242
|
-
var sortedFlatRows = []; // Filter out sortings that correspond to non existing columns
|
|
243
|
-
|
|
244
|
-
var availableSorting = sortingState.filter(function (sort) {
|
|
245
|
-
return instance.getColumnCanSort(sort.id);
|
|
246
|
-
});
|
|
247
|
-
var columnInfoById = {};
|
|
248
|
-
availableSorting.forEach(function (sortEntry) {
|
|
249
|
-
var column = instance.getColumn(sortEntry.id);
|
|
250
|
-
columnInfoById[sortEntry.id] = {
|
|
251
|
-
sortUndefined: column.sortUndefined,
|
|
252
|
-
invertSorting: column.invertSorting,
|
|
253
|
-
sortingFn: instance.getColumnSortingFn(sortEntry.id)
|
|
254
|
-
};
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
var sortData = function sortData(rows) {
|
|
258
|
-
// This will also perform a stable sorting using the row index
|
|
259
|
-
// if needed.
|
|
260
|
-
var sortedData = rows.slice();
|
|
261
|
-
sortedData.sort(function (rowA, rowB) {
|
|
262
|
-
for (var i = 0; i < availableSorting.length; i += 1) {
|
|
263
|
-
var _sortEntry$desc;
|
|
264
|
-
|
|
265
|
-
var sortEntry = availableSorting[i];
|
|
266
|
-
var columnInfo = columnInfoById[sortEntry.id];
|
|
267
|
-
var isDesc = (_sortEntry$desc = sortEntry == null ? void 0 : sortEntry.desc) != null ? _sortEntry$desc : false;
|
|
268
|
-
|
|
269
|
-
if (columnInfo.sortUndefined) {
|
|
270
|
-
var aValue = rowA.values[sortEntry.id];
|
|
271
|
-
var bValue = rowB.values[sortEntry.id];
|
|
272
|
-
var aUndefined = typeof aValue === 'undefined';
|
|
273
|
-
var bUndefined = typeof bValue === 'undefined';
|
|
274
|
-
|
|
275
|
-
if (aUndefined || bUndefined) {
|
|
276
|
-
return aUndefined && bUndefined ? 0 : aUndefined ? 1 : -1;
|
|
277
|
-
}
|
|
278
|
-
} // This function should always return in ascending order
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
var sortInt = columnInfo.sortingFn(rowA, rowB, sortEntry.id);
|
|
282
|
-
|
|
283
|
-
if (sortInt !== 0) {
|
|
284
|
-
if (isDesc) {
|
|
285
|
-
sortInt *= -1;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
if (columnInfo.invertSorting) {
|
|
289
|
-
sortInt *= -1;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
return sortInt;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
return rowA.index - rowB.index;
|
|
297
|
-
}); // If there are sub-rows, sort them
|
|
298
|
-
|
|
299
|
-
sortedData.forEach(function (row) {
|
|
300
|
-
sortedFlatRows.push(row);
|
|
301
|
-
|
|
302
|
-
if (!row.subRows || row.subRows.length <= 1) {
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
row.subRows = sortData(row.subRows);
|
|
307
|
-
});
|
|
308
|
-
return sortedData;
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
return {
|
|
312
|
-
rows: sortData(rowModel.rows),
|
|
313
|
-
flatRows: sortedFlatRows,
|
|
314
|
-
rowsById: rowModel.rowsById
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
|
|
318
37
|
function _extends() {
|
|
319
38
|
_extends = Object.assign || function (target) {
|
|
320
39
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -333,164 +52,9 @@
|
|
|
333
52
|
return _extends.apply(this, arguments);
|
|
334
53
|
}
|
|
335
54
|
|
|
336
|
-
function
|
|
337
|
-
|
|
338
|
-
var target = {};
|
|
339
|
-
var sourceKeys = Object.keys(source);
|
|
340
|
-
var key, i;
|
|
341
|
-
|
|
342
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
343
|
-
key = sourceKeys[i];
|
|
344
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
345
|
-
target[key] = source[key];
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
return target;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
352
|
-
if (!o) return;
|
|
353
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
354
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
355
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
356
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
357
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
function _arrayLikeToArray(arr, len) {
|
|
361
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
362
|
-
|
|
363
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
364
|
-
|
|
365
|
-
return arr2;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
369
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
370
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
371
|
-
|
|
372
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
373
|
-
if (it) o = it;
|
|
374
|
-
var i = 0;
|
|
375
|
-
return function () {
|
|
376
|
-
if (i >= o.length) return {
|
|
377
|
-
done: true
|
|
378
|
-
};
|
|
379
|
-
return {
|
|
380
|
-
done: false,
|
|
381
|
-
value: o[i++]
|
|
382
|
-
};
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
function _toPrimitive(input, hint) {
|
|
390
|
-
if (typeof input !== "object" || input === null) return input;
|
|
391
|
-
var prim = input[Symbol.toPrimitive];
|
|
392
|
-
|
|
393
|
-
if (prim !== undefined) {
|
|
394
|
-
var res = prim.call(input, hint || "default");
|
|
395
|
-
if (typeof res !== "object") return res;
|
|
396
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
return (hint === "string" ? String : Number)(input);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
function _toPropertyKey(arg) {
|
|
403
|
-
var key = _toPrimitive(arg, "string");
|
|
404
|
-
|
|
405
|
-
return typeof key === "symbol" ? key : String(key);
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
function functionalUpdate(updater, input) {
|
|
409
|
-
return typeof updater === 'function' ? updater(input) : updater;
|
|
410
|
-
}
|
|
411
|
-
function makeStateUpdater(key, instance) {
|
|
412
|
-
return function (updater) {
|
|
413
|
-
instance.setState(function (old) {
|
|
414
|
-
var _extends2;
|
|
415
|
-
|
|
416
|
-
return _extends({}, old, (_extends2 = {}, _extends2[key] = functionalUpdate(updater, old[key]), _extends2));
|
|
417
|
-
});
|
|
418
|
-
};
|
|
419
|
-
} // SSR has issues with useLayoutEffect still, so use useEffect during SSR
|
|
420
|
-
|
|
421
|
-
typeof document !== 'undefined' ? React__default["default"].useLayoutEffect : React__default["default"].useEffect;
|
|
422
|
-
function isFunction(d) {
|
|
423
|
-
return d instanceof Function;
|
|
424
|
-
}
|
|
425
|
-
function flattenBy(arr, getChildren) {
|
|
426
|
-
var flat = [];
|
|
427
|
-
|
|
428
|
-
var recurse = function recurse(subArr) {
|
|
429
|
-
subArr.forEach(function (item) {
|
|
430
|
-
flat.push(item);
|
|
431
|
-
var children = getChildren(item);
|
|
432
|
-
|
|
433
|
-
if (children != null && children.length) {
|
|
434
|
-
recurse(children);
|
|
435
|
-
}
|
|
436
|
-
});
|
|
437
|
-
};
|
|
438
|
-
|
|
439
|
-
recurse(arr);
|
|
440
|
-
return flat;
|
|
441
|
-
}
|
|
442
|
-
// @ts-ignore // Just rely on the type, not the implementation
|
|
443
|
-
var propGetter = function propGetter(initial, getter) {
|
|
444
|
-
if (isFunction(getter)) {
|
|
445
|
-
return getter(initial);
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
return _extends({}, initial, getter != null ? getter : {});
|
|
55
|
+
var render = function render(Comp, props) {
|
|
56
|
+
return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React__namespace.createElement(Comp, props) : Comp;
|
|
449
57
|
};
|
|
450
|
-
function memo(getDeps, fn, opts) {
|
|
451
|
-
var deps = [];
|
|
452
|
-
var result;
|
|
453
|
-
return function () {
|
|
454
|
-
var newDeps = getDeps();
|
|
455
|
-
var newSerializedDeps = newDeps;
|
|
456
|
-
var oldSerializedDeps = deps;
|
|
457
|
-
var depsChanged = newSerializedDeps.length !== oldSerializedDeps.length || newSerializedDeps.some(function (dep, index) {
|
|
458
|
-
return oldSerializedDeps[index] !== dep;
|
|
459
|
-
});
|
|
460
|
-
|
|
461
|
-
if (depsChanged) {
|
|
462
|
-
if (opts != null && opts.debug) {
|
|
463
|
-
console.info(opts == null ? void 0 : opts.key, _extends({
|
|
464
|
-
length: oldSerializedDeps.length + " -> " + newSerializedDeps.length
|
|
465
|
-
}, newSerializedDeps.map(function (_, index) {
|
|
466
|
-
if (oldSerializedDeps[index] !== newSerializedDeps[index]) {
|
|
467
|
-
return [index, oldSerializedDeps[index], newSerializedDeps[index]];
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
return false;
|
|
471
|
-
}).filter(Boolean).reduce(function (accu, curr) {
|
|
472
|
-
var _extends3;
|
|
473
|
-
|
|
474
|
-
return _extends({}, accu, (_extends3 = {}, _extends3[curr[0]] = curr.slice(1), _extends3));
|
|
475
|
-
}, {}), {
|
|
476
|
-
parent: parent
|
|
477
|
-
}));
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
var oldResult = result;
|
|
481
|
-
result = fn.apply(void 0, newDeps);
|
|
482
|
-
deps = newSerializedDeps;
|
|
483
|
-
opts == null ? void 0 : opts.onChange == null ? void 0 : opts.onChange(result, oldResult);
|
|
484
|
-
oldResult = undefined;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
return result;
|
|
488
|
-
};
|
|
489
|
-
} // Copied from: https://github.com/jonschlinkert/is-plain-object
|
|
490
|
-
|
|
491
|
-
function flexRender(Comp, props) {
|
|
492
|
-
return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React__default["default"].createElement(Comp, props) : Comp;
|
|
493
|
-
}
|
|
494
58
|
|
|
495
59
|
function isReactComponent(component) {
|
|
496
60
|
return isClassComponent(component) || typeof component === 'function' || isExoticComponent(component);
|
|
@@ -505,4300 +69,68 @@
|
|
|
505
69
|
|
|
506
70
|
function isExoticComponent(component) {
|
|
507
71
|
return typeof component === 'object' && typeof component.$$typeof === 'symbol' && ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description);
|
|
508
|
-
}
|
|
509
|
-
// let h1 = 0xdeadbeef ^ seed,
|
|
510
|
-
// h2 = 0x41c6ce57 ^ seed
|
|
511
|
-
// for (let i = 0, ch; i < str.length; i++) {
|
|
512
|
-
// ch = str.charCodeAt(i)
|
|
513
|
-
// h1 = Math.imul(h1 ^ ch, 2654435761)
|
|
514
|
-
// h2 = Math.imul(h2 ^ ch, 1597334677)
|
|
515
|
-
// }
|
|
516
|
-
// h1 =
|
|
517
|
-
// Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^
|
|
518
|
-
// Math.imul(h2 ^ (h2 >>> 13), 3266489909)
|
|
519
|
-
// h2 =
|
|
520
|
-
// Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^
|
|
521
|
-
// Math.imul(h1 ^ (h1 >>> 13), 3266489909)
|
|
522
|
-
// return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString()
|
|
523
|
-
// }
|
|
524
|
-
|
|
525
|
-
function groupRowsFn(instance, sortedRowModel) {
|
|
526
|
-
var groupingState = instance.getState().grouping; // Filter the grouping list down to columns that exist
|
|
72
|
+
}
|
|
527
73
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
74
|
+
var _init = tableCore.init({
|
|
75
|
+
render: render
|
|
76
|
+
}),
|
|
77
|
+
createTable = _init.createTable,
|
|
78
|
+
createTableFactory = _init.createTableFactory;
|
|
79
|
+
function useTableInstance(table, options) {
|
|
80
|
+
var _table$__options;
|
|
532
81
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
82
|
+
// Compose in the generic options to the user options
|
|
83
|
+
var resolvedOptions = _extends({}, (_table$__options = table.__options) != null ? _table$__options : {}, {
|
|
84
|
+
state: {},
|
|
85
|
+
// Dummy state
|
|
86
|
+
onStateChange: function onStateChange() {},
|
|
87
|
+
// noop
|
|
88
|
+
render: render
|
|
89
|
+
}, options); // Create a new table instance and store it in state
|
|
541
90
|
|
|
542
91
|
|
|
543
|
-
|
|
92
|
+
var _React$useState = React__namespace.useState(function () {
|
|
93
|
+
return tableCore.createTableInstance(resolvedOptions);
|
|
94
|
+
}),
|
|
95
|
+
instance = _React$useState[0]; // By default, manage table state here using the instance's initial state
|
|
544
96
|
|
|
545
|
-
if (aggregateFn) {
|
|
546
|
-
// Get the columnValues to aggregate
|
|
547
|
-
var groupedValues = groupedRows.map(function (row) {
|
|
548
|
-
return row.values[column.id];
|
|
549
|
-
}); // Get the columnValues to aggregate
|
|
550
97
|
|
|
551
|
-
|
|
552
|
-
|
|
98
|
+
var _React$useState2 = React__namespace.useState(function () {
|
|
99
|
+
return instance.initialState;
|
|
100
|
+
}),
|
|
101
|
+
state = _React$useState2[0],
|
|
102
|
+
setState = _React$useState2[1]; // Compose the default state above with any user state. This will allow the user
|
|
103
|
+
// to only control a subset of the state if desired.
|
|
553
104
|
|
|
554
|
-
if (!depth && column.aggregateValue) {
|
|
555
|
-
columnValue = column.aggregateValue(columnValue);
|
|
556
|
-
}
|
|
557
105
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
} else {
|
|
567
|
-
values[column.id] = null;
|
|
106
|
+
instance.setOptions(function (prev) {
|
|
107
|
+
return _extends({}, prev, options, {
|
|
108
|
+
state: _extends({}, state, options.state),
|
|
109
|
+
// Similarly, we'll maintain both our internal state and any user-provided
|
|
110
|
+
// state.
|
|
111
|
+
onStateChange: function onStateChange(updater) {
|
|
112
|
+
setState(updater);
|
|
113
|
+
options.onStateChange == null ? void 0 : options.onStateChange(updater);
|
|
568
114
|
}
|
|
569
115
|
});
|
|
570
|
-
return values;
|
|
571
|
-
};
|
|
572
|
-
|
|
573
|
-
var groupedFlatRows = [];
|
|
574
|
-
var groupedRowsById = {}; // const onlyGroupedFlatRows: Row[] = [];
|
|
575
|
-
// const onlyGroupedRowsById: Record<RowId, Row> = {};
|
|
576
|
-
// const nonGroupedFlatRows: Row[] = [];
|
|
577
|
-
// const nonGroupedRowsById: Record<RowId, Row> = {};
|
|
578
|
-
// Recursively group the data
|
|
579
|
-
|
|
580
|
-
var groupUpRecursively = function groupUpRecursively(rows, depth, parentId) {
|
|
581
|
-
if (depth === void 0) {
|
|
582
|
-
depth = 0;
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
// This is the last level, just return the rows
|
|
586
|
-
if (depth === existingGrouping.length) {
|
|
587
|
-
return rows;
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
var columnId = existingGrouping[depth]; // Group the rows together for this level
|
|
591
|
-
|
|
592
|
-
var rowGroupsMap = groupBy(rows, columnId); // Peform aggregations for each group
|
|
593
|
-
|
|
594
|
-
var aggregatedGroupedRows = Array.from(rowGroupsMap.entries()).map(function (_ref, index) {
|
|
595
|
-
var groupingValue = _ref[0],
|
|
596
|
-
groupedRows = _ref[1];
|
|
597
|
-
var id = columnId + ":" + groupingValue;
|
|
598
|
-
id = parentId ? parentId + ">" + id : id; // First, Recurse to group sub rows before aggregation
|
|
599
|
-
|
|
600
|
-
var subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
|
|
601
|
-
|
|
602
|
-
var leafRows = depth ? flattenBy(groupedRows, function (row) {
|
|
603
|
-
return row.leafRows;
|
|
604
|
-
}) : groupedRows;
|
|
605
|
-
var values = aggregateRowsToValues(leafRows, groupedRows, depth);
|
|
606
|
-
var row = instance.createRow(id, undefined, index, depth, values);
|
|
607
|
-
Object.assign(row, {
|
|
608
|
-
groupingColumnId: columnId,
|
|
609
|
-
groupingValue: groupingValue,
|
|
610
|
-
subRows: subRows,
|
|
611
|
-
leafRows: leafRows
|
|
612
|
-
});
|
|
613
|
-
subRows.forEach(function (subRow) {
|
|
614
|
-
groupedFlatRows.push(subRow);
|
|
615
|
-
groupedRowsById[subRow.id] = subRow; // if (subRow.getIsGrouped?.()) {
|
|
616
|
-
// onlyGroupedFlatRows.push(subRow);
|
|
617
|
-
// onlyGroupedRowsById[subRow.id] = subRow;
|
|
618
|
-
// } else {
|
|
619
|
-
// nonGroupedFlatRows.push(subRow);
|
|
620
|
-
// nonGroupedRowsById[subRow.id] = subRow;
|
|
621
|
-
// }
|
|
622
|
-
});
|
|
623
|
-
return row;
|
|
624
|
-
});
|
|
625
|
-
return aggregatedGroupedRows;
|
|
626
|
-
};
|
|
627
|
-
|
|
628
|
-
var groupedRows = groupUpRecursively(sortedRowModel.rows, 0, '');
|
|
629
|
-
groupedRows.forEach(function (subRow) {
|
|
630
|
-
groupedFlatRows.push(subRow);
|
|
631
|
-
groupedRowsById[subRow.id] = subRow; // if (subRow.getIsGrouped?.()) {
|
|
632
|
-
// onlyGroupedFlatRows.push(subRow);
|
|
633
|
-
// onlyGroupedRowsById[subRow.id] = subRow;
|
|
634
|
-
// } else {
|
|
635
|
-
// nonGroupedFlatRows.push(subRow);
|
|
636
|
-
// nonGroupedRowsById[subRow.id] = subRow;
|
|
637
|
-
// }
|
|
638
116
|
});
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
flatRows: groupedFlatRows,
|
|
642
|
-
rowsById: groupedRowsById
|
|
643
|
-
};
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
function groupBy(rows, columnId) {
|
|
647
|
-
var groupMap = new Map();
|
|
648
|
-
return rows.reduce(function (map, row) {
|
|
649
|
-
var resKey = "" + row.values[columnId];
|
|
650
|
-
var previous = map.get(resKey);
|
|
651
|
-
|
|
652
|
-
if (!previous) {
|
|
653
|
-
map.set(resKey, [row]);
|
|
654
|
-
} else {
|
|
655
|
-
map.set(resKey, [].concat(previous, [row]));
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
return map;
|
|
659
|
-
}, groupMap);
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
function expandRowsFn(instance, sortedRowModel) {
|
|
663
|
-
var expandedRows = [];
|
|
664
|
-
var expandSubRows = instance.options.expandSubRows;
|
|
665
|
-
|
|
666
|
-
var handleRow = function handleRow(row) {
|
|
667
|
-
var _row$subRows;
|
|
668
|
-
|
|
669
|
-
expandedRows.push(row);
|
|
670
|
-
|
|
671
|
-
if (expandSubRows && (_row$subRows = row.subRows) != null && _row$subRows.length && instance.getIsRowExpanded(row.id)) {
|
|
672
|
-
row.subRows.forEach(handleRow);
|
|
673
|
-
}
|
|
674
|
-
};
|
|
675
|
-
|
|
676
|
-
sortedRowModel.rows.forEach(handleRow);
|
|
677
|
-
return {
|
|
678
|
-
rows: expandedRows,
|
|
679
|
-
flatRows: sortedRowModel.flatRows,
|
|
680
|
-
rowsById: sortedRowModel.rowsById
|
|
681
|
-
};
|
|
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
|
-
}
|
|
709
|
-
|
|
710
|
-
//
|
|
711
|
-
function getInitialState$9() {
|
|
712
|
-
return {
|
|
713
|
-
columnVisibility: {}
|
|
714
|
-
};
|
|
715
|
-
}
|
|
716
|
-
function getDefaultOptions$9(instance) {
|
|
717
|
-
return {
|
|
718
|
-
onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
|
|
719
|
-
};
|
|
720
|
-
}
|
|
721
|
-
function getDefaultColumn$3() {
|
|
722
|
-
return {
|
|
723
|
-
defaultIsVisible: true
|
|
724
|
-
};
|
|
725
|
-
}
|
|
726
|
-
function createColumn$5(column, instance) {
|
|
727
|
-
return {
|
|
728
|
-
getCanHide: function getCanHide() {
|
|
729
|
-
return instance.getColumnCanHide(column.id);
|
|
730
|
-
},
|
|
731
|
-
getIsVisible: function getIsVisible() {
|
|
732
|
-
return instance.getColumnIsVisible(column.id);
|
|
733
|
-
},
|
|
734
|
-
toggleVisibility: function toggleVisibility(value) {
|
|
735
|
-
return instance.toggleColumnVisibility(column.id, value);
|
|
736
|
-
},
|
|
737
|
-
getToggleVisibilityProps: function getToggleVisibilityProps(userProps) {
|
|
738
|
-
var props = {
|
|
739
|
-
type: 'checkbox',
|
|
740
|
-
checked: column.getIsVisible == null ? void 0 : column.getIsVisible(),
|
|
741
|
-
title: 'Toggle Column Visibility',
|
|
742
|
-
onChange: function onChange(e) {
|
|
743
|
-
column.toggleVisibility == null ? void 0 : column.toggleVisibility(e.target.checked);
|
|
744
|
-
}
|
|
745
|
-
};
|
|
746
|
-
return propGetter(props, userProps);
|
|
747
|
-
}
|
|
748
|
-
};
|
|
749
|
-
}
|
|
750
|
-
function getInstance$a(instance) {
|
|
751
|
-
return {
|
|
752
|
-
getVisibleFlatColumns: memo(function () {
|
|
753
|
-
return [instance.getAllFlatColumns(), instance.getAllFlatColumns().filter(function (d) {
|
|
754
|
-
return d.getIsVisible == null ? void 0 : d.getIsVisible();
|
|
755
|
-
}).map(function (d) {
|
|
756
|
-
return d.id;
|
|
757
|
-
}).join('_')];
|
|
758
|
-
}, function (allFlatColumns) {
|
|
759
|
-
return allFlatColumns.filter(function (d) {
|
|
760
|
-
return d.getIsVisible == null ? void 0 : d.getIsVisible();
|
|
761
|
-
});
|
|
762
|
-
}, {
|
|
763
|
-
key: 'getVisibleFlatColumns',
|
|
764
|
-
debug: instance.options.debug
|
|
765
|
-
}),
|
|
766
|
-
getVisibleLeafColumns: memo(function () {
|
|
767
|
-
return [instance.getAllLeafColumns(), instance.getAllLeafColumns().filter(function (d) {
|
|
768
|
-
return d.getIsVisible == null ? void 0 : d.getIsVisible();
|
|
769
|
-
}).map(function (d) {
|
|
770
|
-
return d.id;
|
|
771
|
-
}).join('_')];
|
|
772
|
-
}, function (allFlatColumns) {
|
|
773
|
-
return allFlatColumns.filter(function (d) {
|
|
774
|
-
return d.getIsVisible == null ? void 0 : d.getIsVisible();
|
|
775
|
-
});
|
|
776
|
-
}, {
|
|
777
|
-
key: 'getVisibleLeafColumns',
|
|
778
|
-
debug: instance.options.debug
|
|
779
|
-
}),
|
|
780
|
-
setColumnVisibility: function setColumnVisibility(updater) {
|
|
781
|
-
return instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater, functionalUpdate(updater, instance.getState().columnVisibility));
|
|
782
|
-
},
|
|
783
|
-
toggleColumnVisibility: function toggleColumnVisibility(columnId, value) {
|
|
784
|
-
if (!columnId) return;
|
|
785
|
-
|
|
786
|
-
if (instance.getColumnCanHide(columnId)) {
|
|
787
|
-
instance.setColumnVisibility(function (old) {
|
|
788
|
-
var _extends2;
|
|
789
|
-
|
|
790
|
-
return _extends({}, old, (_extends2 = {}, _extends2[columnId] = value != null ? value : !instance.getColumnIsVisible(columnId), _extends2));
|
|
791
|
-
});
|
|
792
|
-
}
|
|
793
|
-
},
|
|
794
|
-
toggleAllColumnsVisible: function toggleAllColumnsVisible(value) {
|
|
795
|
-
var _value;
|
|
796
|
-
|
|
797
|
-
value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
|
|
798
|
-
instance.setColumnVisibility(instance.getAllLeafColumns().reduce(function (obj, column) {
|
|
799
|
-
var _extends3;
|
|
800
|
-
|
|
801
|
-
return _extends({}, obj, (_extends3 = {}, _extends3[column.id] = !value ? !(column.getCanHide != null && column.getCanHide()) : value, _extends3));
|
|
802
|
-
}, {}));
|
|
803
|
-
},
|
|
804
|
-
getColumnIsVisible: function getColumnIsVisible(columnId) {
|
|
805
|
-
var _ref, _instance$getState$co, _instance$getState$co2;
|
|
806
|
-
|
|
807
|
-
var column = instance.getColumn(columnId);
|
|
808
|
-
|
|
809
|
-
if (!column) {
|
|
810
|
-
throw new Error();
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
return (_ref = (_instance$getState$co = (_instance$getState$co2 = instance.getState().columnVisibility) == null ? void 0 : _instance$getState$co2[columnId]) != null ? _instance$getState$co : column.defaultIsVisible) != null ? _ref : true;
|
|
814
|
-
},
|
|
815
|
-
getColumnCanHide: function getColumnCanHide(columnId) {
|
|
816
|
-
var _ref2, _ref3, _instance$options$ena;
|
|
817
|
-
|
|
818
|
-
var column = instance.getColumn(columnId);
|
|
819
|
-
|
|
820
|
-
if (!column) {
|
|
821
|
-
throw new Error();
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
return (_ref2 = (_ref3 = (_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : column.enableHiding) != null ? _ref3 : column.defaultCanHide) != null ? _ref2 : true;
|
|
825
|
-
},
|
|
826
|
-
getIsAllColumnsVisible: function getIsAllColumnsVisible() {
|
|
827
|
-
return !instance.getAllLeafColumns().some(function (column) {
|
|
828
|
-
return !(column.getIsVisible != null && column.getIsVisible());
|
|
829
|
-
});
|
|
830
|
-
},
|
|
831
|
-
getIsSomeColumnsVisible: function getIsSomeColumnsVisible() {
|
|
832
|
-
return instance.getAllLeafColumns().some(function (column) {
|
|
833
|
-
return column.getIsVisible == null ? void 0 : column.getIsVisible();
|
|
834
|
-
});
|
|
835
|
-
},
|
|
836
|
-
getToggleAllColumnsVisibilityProps: function getToggleAllColumnsVisibilityProps(userProps) {
|
|
837
|
-
var props = {
|
|
838
|
-
onChange: function onChange(e) {
|
|
839
|
-
var _e$target;
|
|
840
|
-
|
|
841
|
-
instance.toggleAllColumnsVisible((_e$target = e.target) == null ? void 0 : _e$target.checked);
|
|
842
|
-
},
|
|
843
|
-
type: 'checkbox',
|
|
844
|
-
title: 'Toggle visibility for all columns',
|
|
845
|
-
checked: instance.getIsAllColumnsVisible(),
|
|
846
|
-
indeterminate: !instance.getIsAllColumnsVisible() && instance.getIsSomeColumnsVisible() ? 'indeterminate' : undefined
|
|
847
|
-
};
|
|
848
|
-
return propGetter(props, userProps);
|
|
849
|
-
}
|
|
850
|
-
};
|
|
851
|
-
}
|
|
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
|
-
|
|
862
|
-
var aggregationTypes = {
|
|
863
|
-
sum: sum,
|
|
864
|
-
min: min,
|
|
865
|
-
max: max,
|
|
866
|
-
extent: extent,
|
|
867
|
-
mean: mean,
|
|
868
|
-
median: median,
|
|
869
|
-
unique: unique,
|
|
870
|
-
uniqueCount: uniqueCount,
|
|
871
|
-
count: count
|
|
872
|
-
};
|
|
873
|
-
|
|
874
|
-
function sum(_leafValues, childValues) {
|
|
875
|
-
// It's faster to just add the aggregations together instead of
|
|
876
|
-
// process leaf nodes individually
|
|
877
|
-
return childValues.reduce(function (sum, next) {
|
|
878
|
-
return sum + (typeof next === 'number' ? next : 0);
|
|
879
|
-
}, 0);
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
function min(_leafValues, childValues) {
|
|
883
|
-
var min;
|
|
884
|
-
|
|
885
|
-
for (var _iterator = _createForOfIteratorHelperLoose(childValues), _step; !(_step = _iterator()).done;) {
|
|
886
|
-
var value = _step.value;
|
|
887
|
-
|
|
888
|
-
if (value != null && (min > value || min === undefined && value >= value)) {
|
|
889
|
-
min = value;
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
return min;
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
function max(_leafValues, childValues) {
|
|
897
|
-
var max;
|
|
898
|
-
|
|
899
|
-
for (var _iterator2 = _createForOfIteratorHelperLoose(childValues), _step2; !(_step2 = _iterator2()).done;) {
|
|
900
|
-
var value = _step2.value;
|
|
901
|
-
|
|
902
|
-
if (value != null && (max < value || max === undefined && value >= value)) {
|
|
903
|
-
max = value;
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
return max;
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
function extent(_leafValues, childValues) {
|
|
911
|
-
var min;
|
|
912
|
-
var max;
|
|
913
|
-
|
|
914
|
-
for (var _iterator3 = _createForOfIteratorHelperLoose(childValues), _step3; !(_step3 = _iterator3()).done;) {
|
|
915
|
-
var value = _step3.value;
|
|
916
|
-
|
|
917
|
-
if (value != null) {
|
|
918
|
-
if (min === undefined) {
|
|
919
|
-
if (value >= value) min = max = value;
|
|
920
|
-
} else {
|
|
921
|
-
if (min > value) min = value;
|
|
922
|
-
if (max < value) max = value;
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
return [min, max];
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
function mean(leafValues) {
|
|
931
|
-
var count = 0;
|
|
932
|
-
var sum = 0;
|
|
933
|
-
|
|
934
|
-
for (var _iterator4 = _createForOfIteratorHelperLoose(leafValues), _step4; !(_step4 = _iterator4()).done;) {
|
|
935
|
-
var value = _step4.value;
|
|
936
|
-
|
|
937
|
-
if (value != null && (value = +value) >= value) {
|
|
938
|
-
++count, sum += value;
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
if (count) return sum / count;
|
|
943
|
-
return;
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
function median(values) {
|
|
947
|
-
if (!values.length) {
|
|
948
|
-
return;
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
var min = 0;
|
|
952
|
-
var max = 0;
|
|
953
|
-
values.forEach(function (value) {
|
|
954
|
-
if (typeof value === 'number') {
|
|
955
|
-
min = Math.min(min, value);
|
|
956
|
-
max = Math.max(max, value);
|
|
957
|
-
}
|
|
117
|
+
React__namespace.useLayoutEffect(function () {
|
|
118
|
+
instance.willUpdate();
|
|
958
119
|
});
|
|
959
|
-
return
|
|
120
|
+
return instance;
|
|
960
121
|
}
|
|
961
122
|
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
function
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
function count(values) {
|
|
971
|
-
return values.length;
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
//
|
|
975
|
-
function getDefaultColumn$2() {
|
|
976
|
-
return {
|
|
977
|
-
aggregationType: 'auto'
|
|
978
|
-
};
|
|
979
|
-
}
|
|
980
|
-
function getInitialState$8() {
|
|
981
|
-
return {
|
|
982
|
-
grouping: []
|
|
983
|
-
};
|
|
984
|
-
}
|
|
985
|
-
function getDefaultOptions$8(instance) {
|
|
986
|
-
return {
|
|
987
|
-
onGroupingChange: makeStateUpdater('grouping', instance),
|
|
988
|
-
autoResetGrouping: true,
|
|
989
|
-
groupedColumnMode: 'reorder'
|
|
990
|
-
};
|
|
991
|
-
}
|
|
992
|
-
function createColumn$4(column, instance) {
|
|
993
|
-
return {
|
|
994
|
-
aggregationType: column.aggregationType,
|
|
995
|
-
getCanGroup: function getCanGroup() {
|
|
996
|
-
return instance.getColumnCanGroup(column.id);
|
|
997
|
-
},
|
|
998
|
-
getGroupedIndex: function getGroupedIndex() {
|
|
999
|
-
return instance.getColumnGroupedIndex(column.id);
|
|
1000
|
-
},
|
|
1001
|
-
getIsGrouped: function getIsGrouped() {
|
|
1002
|
-
return instance.getColumnIsGrouped(column.id);
|
|
1003
|
-
},
|
|
1004
|
-
toggleGrouping: function toggleGrouping() {
|
|
1005
|
-
return instance.toggleColumnGrouping(column.id);
|
|
1006
|
-
},
|
|
1007
|
-
getToggleGroupingProps: function getToggleGroupingProps(userProps) {
|
|
1008
|
-
return instance.getToggleGroupingProps(column.id, userProps);
|
|
1009
|
-
}
|
|
1010
|
-
};
|
|
1011
|
-
}
|
|
1012
|
-
function getInstance$9(instance) {
|
|
1013
|
-
var registered = false;
|
|
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
|
-
},
|
|
1029
|
-
getColumnAutoAggregationFn: function getColumnAutoAggregationFn(columnId) {
|
|
1030
|
-
var firstRow = instance.getCoreFlatRows()[0];
|
|
1031
|
-
var value = firstRow == null ? void 0 : firstRow.values[columnId];
|
|
1032
|
-
|
|
1033
|
-
if (typeof value === 'number') {
|
|
1034
|
-
return aggregationTypes.sum;
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
if (Object.prototype.toString.call(value) === '[object Date]') {
|
|
1038
|
-
return aggregationTypes.extent;
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
return aggregationTypes.count;
|
|
1042
|
-
},
|
|
1043
|
-
getColumnAggregationFn: function getColumnAggregationFn(columnId) {
|
|
1044
|
-
var _ref;
|
|
1045
|
-
|
|
1046
|
-
var column = instance.getColumn(columnId);
|
|
1047
|
-
var userAggregationTypes = instance.options.aggregationTypes;
|
|
1048
|
-
|
|
1049
|
-
if (!column) {
|
|
1050
|
-
throw new Error();
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
return isFunction(column.aggregationType) ? column.aggregationType : column.aggregationType === 'auto' ? instance.getColumnAutoFilterFn(columnId) : (_ref = userAggregationTypes == null ? void 0 : userAggregationTypes[column.aggregationType]) != null ? _ref : aggregationTypes[column.aggregationType];
|
|
1054
|
-
},
|
|
1055
|
-
setGrouping: function setGrouping(updater) {
|
|
1056
|
-
return instance.options.onGroupingChange == null ? void 0 : instance.options.onGroupingChange(updater, functionalUpdate(updater, instance.getState().grouping));
|
|
1057
|
-
},
|
|
1058
|
-
toggleColumnGrouping: function toggleColumnGrouping(columnId) {
|
|
1059
|
-
instance.setGrouping(function (old) {
|
|
1060
|
-
// Find any existing grouping for this column
|
|
1061
|
-
if (old != null && old.includes(columnId)) {
|
|
1062
|
-
return old.filter(function (d) {
|
|
1063
|
-
return d !== columnId;
|
|
1064
|
-
});
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
return [].concat(old != null ? old : [], [columnId]);
|
|
1068
|
-
});
|
|
1069
|
-
},
|
|
1070
|
-
getColumnCanGroup: function getColumnCanGroup(columnId) {
|
|
1071
|
-
var _ref2, _ref3, _column$enableGroupin;
|
|
1072
|
-
|
|
1073
|
-
var column = instance.getColumn(columnId);
|
|
1074
|
-
|
|
1075
|
-
if (!column) {
|
|
1076
|
-
throw new Error();
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
return (_ref2 = (_ref3 = (_column$enableGroupin = column.enableGrouping) != null ? _column$enableGroupin : instance.options.enableGrouping) != null ? _ref3 : column.defaultCanGroup) != null ? _ref2 : !!column.accessorFn;
|
|
1080
|
-
},
|
|
1081
|
-
getColumnIsGrouped: function getColumnIsGrouped(columnId) {
|
|
1082
|
-
var _instance$getState$gr;
|
|
1083
|
-
|
|
1084
|
-
return (_instance$getState$gr = instance.getState().grouping) == null ? void 0 : _instance$getState$gr.includes(columnId);
|
|
1085
|
-
},
|
|
1086
|
-
getColumnGroupedIndex: function getColumnGroupedIndex(columnId) {
|
|
1087
|
-
var _instance$getState$gr2;
|
|
1088
|
-
|
|
1089
|
-
return (_instance$getState$gr2 = instance.getState().grouping) == null ? void 0 : _instance$getState$gr2.indexOf(columnId);
|
|
1090
|
-
},
|
|
1091
|
-
resetGrouping: function resetGrouping() {
|
|
1092
|
-
var _instance$options$ini, _instance$options, _instance$options$ini2;
|
|
1093
|
-
|
|
1094
|
-
instance.setGrouping((_instance$options$ini = (_instance$options = instance.options) == null ? void 0 : (_instance$options$ini2 = _instance$options.initialState) == null ? void 0 : _instance$options$ini2.grouping) != null ? _instance$options$ini : []);
|
|
1095
|
-
},
|
|
1096
|
-
getToggleGroupingProps: function getToggleGroupingProps(columnId, userProps) {
|
|
1097
|
-
var column = instance.getColumn(columnId);
|
|
1098
|
-
|
|
1099
|
-
if (!column) {
|
|
1100
|
-
return;
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
var canGroup = column.getCanGroup();
|
|
1104
|
-
var initialProps = {
|
|
1105
|
-
title: canGroup ? 'Toggle Grouping' : undefined,
|
|
1106
|
-
onClick: canGroup ? function (e) {
|
|
1107
|
-
e.persist();
|
|
1108
|
-
column.toggleGrouping == null ? void 0 : column.toggleGrouping();
|
|
1109
|
-
} : undefined
|
|
1110
|
-
};
|
|
1111
|
-
return propGetter(initialProps, userProps);
|
|
1112
|
-
},
|
|
1113
|
-
getRowIsGrouped: function getRowIsGrouped(rowId) {
|
|
1114
|
-
var _instance$getRow;
|
|
1115
|
-
|
|
1116
|
-
return !!((_instance$getRow = instance.getRow(rowId)) != null && _instance$getRow.groupingColumnId);
|
|
1117
|
-
},
|
|
1118
|
-
getGroupedRowModel: memo(function () {
|
|
1119
|
-
return [instance.getState().grouping, instance.getSortedRowModel(), instance.options.groupRowsFn];
|
|
1120
|
-
}, function (grouping, rowModel, groupRowsFn) {
|
|
1121
|
-
if (!groupRowsFn || !grouping.length) {
|
|
1122
|
-
return rowModel;
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
if (instance.options.debug) console.info('Grouping...');
|
|
1126
|
-
return groupRowsFn(instance, rowModel);
|
|
1127
|
-
}, {
|
|
1128
|
-
key: 'getGroupedRowModel',
|
|
1129
|
-
debug: instance.options.debug,
|
|
1130
|
-
onChange: function onChange() {
|
|
1131
|
-
return instance._notifyExpandedReset();
|
|
1132
|
-
}
|
|
1133
|
-
}),
|
|
1134
|
-
getPreGroupedRows: function getPreGroupedRows() {
|
|
1135
|
-
return instance.getSortedRowModel().rows;
|
|
1136
|
-
},
|
|
1137
|
-
getPreGroupedFlatRows: function getPreGroupedFlatRows() {
|
|
1138
|
-
return instance.getSortedRowModel().flatRows;
|
|
1139
|
-
},
|
|
1140
|
-
getPreGroupedRowsById: function getPreGroupedRowsById() {
|
|
1141
|
-
return instance.getSortedRowModel().rowsById;
|
|
1142
|
-
},
|
|
1143
|
-
getGroupedRows: function getGroupedRows() {
|
|
1144
|
-
return instance.getGroupedRowModel().rows;
|
|
1145
|
-
},
|
|
1146
|
-
getGroupedFlatRows: function getGroupedFlatRows() {
|
|
1147
|
-
return instance.getGroupedRowModel().flatRows;
|
|
1148
|
-
},
|
|
1149
|
-
getGroupedRowsById: function getGroupedRowsById() {
|
|
1150
|
-
return instance.getGroupedRowModel().rowsById;
|
|
1151
|
-
}
|
|
1152
|
-
};
|
|
1153
|
-
}
|
|
1154
|
-
function createRow$3(row, instance) {
|
|
1155
|
-
return {
|
|
1156
|
-
getIsGrouped: function getIsGrouped() {
|
|
1157
|
-
return instance.getRowIsGrouped(row.id);
|
|
1158
|
-
}
|
|
1159
|
-
};
|
|
1160
|
-
}
|
|
1161
|
-
function createCell(cell, column, row, _instance) {
|
|
1162
|
-
return {
|
|
1163
|
-
getIsGrouped: function getIsGrouped() {
|
|
1164
|
-
return column.getIsGrouped() && column.id === row.groupingColumnId;
|
|
1165
|
-
},
|
|
1166
|
-
getIsPlaceholder: function getIsPlaceholder() {
|
|
1167
|
-
return !cell.getIsGrouped() && column.getIsGrouped();
|
|
1168
|
-
},
|
|
1169
|
-
getIsAggregated: function getIsAggregated() {
|
|
1170
|
-
var _row$subRows;
|
|
1171
|
-
|
|
1172
|
-
return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
|
|
1173
|
-
}
|
|
1174
|
-
};
|
|
1175
|
-
}
|
|
1176
|
-
function orderColumns(leafColumns, grouping, groupedColumnMode) {
|
|
1177
|
-
if (!(grouping != null && grouping.length) || !groupedColumnMode) {
|
|
1178
|
-
return leafColumns;
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
var nonGroupingColumns = leafColumns.filter(function (col) {
|
|
1182
|
-
return !grouping.includes(col.id);
|
|
1183
|
-
});
|
|
1184
|
-
|
|
1185
|
-
if (groupedColumnMode === 'remove') {
|
|
1186
|
-
return nonGroupingColumns;
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
var groupingColumns = grouping.map(function (g) {
|
|
1190
|
-
return leafColumns.find(function (col) {
|
|
1191
|
-
return col.id === g;
|
|
1192
|
-
});
|
|
1193
|
-
}).filter(Boolean);
|
|
1194
|
-
return [].concat(groupingColumns, nonGroupingColumns);
|
|
1195
|
-
}
|
|
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
|
-
|
|
1209
|
-
//
|
|
1210
|
-
function getInitialState$7() {
|
|
1211
|
-
return {
|
|
1212
|
-
columnOrder: []
|
|
1213
|
-
};
|
|
1214
|
-
}
|
|
1215
|
-
function getDefaultOptions$7(instance) {
|
|
1216
|
-
return {
|
|
1217
|
-
onColumnOrderChange: makeStateUpdater('columnOrder', instance)
|
|
1218
|
-
};
|
|
1219
|
-
}
|
|
1220
|
-
function getInstance$8(instance) {
|
|
1221
|
-
return {
|
|
1222
|
-
setColumnOrder: function setColumnOrder(updater) {
|
|
1223
|
-
return instance.options.onColumnOrderChange == null ? void 0 : instance.options.onColumnOrderChange(updater, functionalUpdate(updater, instance.getState().columnOrder));
|
|
1224
|
-
},
|
|
1225
|
-
resetColumnOrder: function resetColumnOrder() {
|
|
1226
|
-
var _instance$initialStat;
|
|
1227
|
-
|
|
1228
|
-
instance.setColumnOrder((_instance$initialStat = instance.initialState.columnOrder) != null ? _instance$initialStat : []);
|
|
1229
|
-
},
|
|
1230
|
-
getOrderColumnsFn: memo(function () {
|
|
1231
|
-
return [instance.getState().columnOrder, instance.getState().grouping, instance.options.groupedColumnMode];
|
|
1232
|
-
}, function (columnOrder, grouping, groupedColumnMode) {
|
|
1233
|
-
return function (columns) {
|
|
1234
|
-
// Sort grouped columns to the start of the column list
|
|
1235
|
-
// before the headers are built
|
|
1236
|
-
var orderedColumns = []; // If there is no order, return the normal columns
|
|
1237
|
-
|
|
1238
|
-
if (!(columnOrder != null && columnOrder.length)) {
|
|
1239
|
-
orderedColumns = columns;
|
|
1240
|
-
} else {
|
|
1241
|
-
var columnOrderCopy = [].concat(columnOrder); // If there is an order, make a copy of the columns
|
|
1242
|
-
|
|
1243
|
-
var columnsCopy = [].concat(columns); // And make a new ordered array of the columns
|
|
1244
|
-
// Loop over the columns and place them in order into the new array
|
|
1245
|
-
|
|
1246
|
-
var _loop = function _loop() {
|
|
1247
|
-
var targetColumnId = columnOrderCopy.shift();
|
|
1248
|
-
var foundIndex = columnsCopy.findIndex(function (d) {
|
|
1249
|
-
return d.id === targetColumnId;
|
|
1250
|
-
});
|
|
1251
|
-
|
|
1252
|
-
if (foundIndex > -1) {
|
|
1253
|
-
orderedColumns.push(columnsCopy.splice(foundIndex, 1)[0]);
|
|
1254
|
-
}
|
|
1255
|
-
};
|
|
1256
|
-
|
|
1257
|
-
while (columnsCopy.length && columnOrderCopy.length) {
|
|
1258
|
-
_loop();
|
|
1259
|
-
} // If there are any columns left, add them to the end
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
orderedColumns = [].concat(orderedColumns, columnsCopy);
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
return orderColumns(orderedColumns, grouping, groupedColumnMode);
|
|
1266
|
-
};
|
|
1267
|
-
}, {
|
|
1268
|
-
key: 'getOrderColumnsFn',
|
|
1269
|
-
debug: instance.options.debug
|
|
1270
|
-
})
|
|
1271
|
-
};
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
var Ordering = /*#__PURE__*/Object.freeze({
|
|
1275
|
-
__proto__: null,
|
|
1276
|
-
getInitialState: getInitialState$7,
|
|
1277
|
-
getDefaultOptions: getDefaultOptions$7,
|
|
1278
|
-
getInstance: getInstance$8
|
|
1279
|
-
});
|
|
1280
|
-
|
|
1281
|
-
//
|
|
1282
|
-
function getInitialState$6() {
|
|
1283
|
-
return {
|
|
1284
|
-
columnPinning: {
|
|
1285
|
-
left: [],
|
|
1286
|
-
right: []
|
|
1287
|
-
}
|
|
1288
|
-
};
|
|
1289
|
-
}
|
|
1290
|
-
function getDefaultOptions$6(instance) {
|
|
1291
|
-
return {
|
|
1292
|
-
onColumnPinningChange: makeStateUpdater('columnPinning', instance)
|
|
1293
|
-
};
|
|
1294
|
-
}
|
|
1295
|
-
function createColumn$3(column, instance) {
|
|
1296
|
-
return {
|
|
1297
|
-
getCanPin: function getCanPin() {
|
|
1298
|
-
return instance.getColumnCanPin(column.id);
|
|
1299
|
-
},
|
|
1300
|
-
getPinnedIndex: function getPinnedIndex() {
|
|
1301
|
-
return instance.getColumnPinnedIndex(column.id);
|
|
1302
|
-
},
|
|
1303
|
-
getIsPinned: function getIsPinned() {
|
|
1304
|
-
return instance.getColumnIsPinned(column.id);
|
|
1305
|
-
},
|
|
1306
|
-
pin: function pin(position) {
|
|
1307
|
-
return instance.pinColumn(column.id, position);
|
|
1308
|
-
}
|
|
1309
|
-
};
|
|
1310
|
-
}
|
|
1311
|
-
function getInstance$7(instance) {
|
|
1312
|
-
return {
|
|
1313
|
-
setColumnPinning: function setColumnPinning(updater) {
|
|
1314
|
-
return instance.options.onColumnPinningChange == null ? void 0 : instance.options.onColumnPinningChange(updater, functionalUpdate(updater, instance.getState().columnPinning));
|
|
1315
|
-
},
|
|
1316
|
-
resetColumnPinning: function resetColumnPinning() {
|
|
1317
|
-
var _instance$options$ini, _instance$options$ini2;
|
|
1318
|
-
|
|
1319
|
-
return instance.setColumnPinning((_instance$options$ini = (_instance$options$ini2 = instance.options.initialState) == null ? void 0 : _instance$options$ini2.columnPinning) != null ? _instance$options$ini : {});
|
|
1320
|
-
},
|
|
1321
|
-
pinColumn: function pinColumn(columnId, position) {
|
|
1322
|
-
var column = instance.getColumn(columnId);
|
|
1323
|
-
var columnIds = column == null ? void 0 : column.getLeafColumns().map(function (d) {
|
|
1324
|
-
return d.id;
|
|
1325
|
-
}).filter(Boolean);
|
|
1326
|
-
instance.setColumnPinning(function (old) {
|
|
1327
|
-
var _old$left3, _old$right3;
|
|
1328
|
-
|
|
1329
|
-
if (position === 'right') {
|
|
1330
|
-
var _old$left, _old$right;
|
|
1331
|
-
|
|
1332
|
-
return {
|
|
1333
|
-
left: ((_old$left = old == null ? void 0 : old.left) != null ? _old$left : []).filter(function (d) {
|
|
1334
|
-
return !(columnIds != null && columnIds.includes(d));
|
|
1335
|
-
}),
|
|
1336
|
-
right: [].concat(((_old$right = old == null ? void 0 : old.right) != null ? _old$right : []).filter(function (d) {
|
|
1337
|
-
return !(columnIds != null && columnIds.includes(d));
|
|
1338
|
-
}), columnIds)
|
|
1339
|
-
};
|
|
1340
|
-
}
|
|
1341
|
-
|
|
1342
|
-
if (position === 'left') {
|
|
1343
|
-
var _old$left2, _old$right2;
|
|
1344
|
-
|
|
1345
|
-
return {
|
|
1346
|
-
left: [].concat(((_old$left2 = old == null ? void 0 : old.left) != null ? _old$left2 : []).filter(function (d) {
|
|
1347
|
-
return !(columnIds != null && columnIds.includes(d));
|
|
1348
|
-
}), columnIds),
|
|
1349
|
-
right: ((_old$right2 = old == null ? void 0 : old.right) != null ? _old$right2 : []).filter(function (d) {
|
|
1350
|
-
return !(columnIds != null && columnIds.includes(d));
|
|
1351
|
-
})
|
|
1352
|
-
};
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
|
-
return {
|
|
1356
|
-
left: ((_old$left3 = old == null ? void 0 : old.left) != null ? _old$left3 : []).filter(function (d) {
|
|
1357
|
-
return !(columnIds != null && columnIds.includes(d));
|
|
1358
|
-
}),
|
|
1359
|
-
right: ((_old$right3 = old == null ? void 0 : old.right) != null ? _old$right3 : []).filter(function (d) {
|
|
1360
|
-
return !(columnIds != null && columnIds.includes(d));
|
|
1361
|
-
})
|
|
1362
|
-
};
|
|
1363
|
-
});
|
|
1364
|
-
},
|
|
1365
|
-
getColumnCanPin: function getColumnCanPin(columnId) {
|
|
1366
|
-
var column = instance.getColumn(columnId);
|
|
1367
|
-
|
|
1368
|
-
if (!column) {
|
|
1369
|
-
throw new Error();
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
var leafColumns = column.getLeafColumns();
|
|
1373
|
-
return leafColumns.some(function (d) {
|
|
1374
|
-
var _ref, _ref2, _d$enablePinning;
|
|
1375
|
-
|
|
1376
|
-
return (_ref = (_ref2 = (_d$enablePinning = d.enablePinning) != null ? _d$enablePinning : instance.options.enablePinning) != null ? _ref2 : d.defaultCanPin) != null ? _ref : !!d.accessorFn;
|
|
1377
|
-
});
|
|
1378
|
-
},
|
|
1379
|
-
getColumnIsPinned: function getColumnIsPinned(columnId) {
|
|
1380
|
-
var column = instance.getColumn(columnId);
|
|
1381
|
-
|
|
1382
|
-
if (!column) {
|
|
1383
|
-
throw new Error();
|
|
1384
|
-
}
|
|
1385
|
-
|
|
1386
|
-
var leafColumnIds = column.getLeafColumns().map(function (d) {
|
|
1387
|
-
return d.id;
|
|
1388
|
-
});
|
|
1389
|
-
var _instance$getState$co = instance.getState().columnPinning,
|
|
1390
|
-
left = _instance$getState$co.left,
|
|
1391
|
-
right = _instance$getState$co.right;
|
|
1392
|
-
var isLeft = leafColumnIds.some(function (d) {
|
|
1393
|
-
return left == null ? void 0 : left.includes(d);
|
|
1394
|
-
});
|
|
1395
|
-
var isRight = leafColumnIds.some(function (d) {
|
|
1396
|
-
return right == null ? void 0 : right.includes(d);
|
|
1397
|
-
});
|
|
1398
|
-
return isLeft ? 'left' : isRight ? 'right' : false;
|
|
1399
|
-
},
|
|
1400
|
-
getColumnPinnedIndex: function getColumnPinnedIndex(columnId) {
|
|
1401
|
-
var _instance$getState$co2, _instance$getState$co3, _instance$getState$co4;
|
|
1402
|
-
|
|
1403
|
-
var position = instance.getColumnIsPinned(columnId);
|
|
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;
|
|
1405
|
-
}
|
|
1406
|
-
};
|
|
1407
|
-
}
|
|
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
|
-
|
|
1417
|
-
//
|
|
1418
|
-
function createRow$2(row, instance) {
|
|
1419
|
-
return {
|
|
1420
|
-
_getAllVisibleCells: memo(function () {
|
|
1421
|
-
return [row.getAllCells().filter(function (cell) {
|
|
1422
|
-
return cell.column.getIsVisible();
|
|
1423
|
-
}).map(function (d) {
|
|
1424
|
-
return d.id;
|
|
1425
|
-
}).join('_')];
|
|
1426
|
-
}, function (_) {
|
|
1427
|
-
return row.getAllCells().filter(function (cell) {
|
|
1428
|
-
return cell.column.getIsVisible();
|
|
1429
|
-
});
|
|
1430
|
-
}, {
|
|
1431
|
-
key: 'row._getAllVisibleCells',
|
|
1432
|
-
debug: instance.options.debug
|
|
1433
|
-
}),
|
|
1434
|
-
getVisibleCells: memo(function () {
|
|
1435
|
-
return [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()];
|
|
1436
|
-
}, function (left, center, right) {
|
|
1437
|
-
return [].concat(left, center, right);
|
|
1438
|
-
}, {
|
|
1439
|
-
key: 'row.getVisibleCells',
|
|
1440
|
-
debug: instance.options.debug
|
|
1441
|
-
}),
|
|
1442
|
-
getCenterVisibleCells: memo(function () {
|
|
1443
|
-
return [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
|
|
1444
|
-
}, function (allCells, left, right) {
|
|
1445
|
-
var leftAndRight = [].concat(left != null ? left : [], right != null ? right : []);
|
|
1446
|
-
return allCells.filter(function (d) {
|
|
1447
|
-
return !leftAndRight.includes(d.columnId);
|
|
1448
|
-
});
|
|
1449
|
-
}, {
|
|
1450
|
-
key: 'row.getCenterVisibleCells',
|
|
1451
|
-
debug: instance.options.debug
|
|
1452
|
-
}),
|
|
1453
|
-
getLeftVisibleCells: memo(function () {
|
|
1454
|
-
return [row._getAllVisibleCells(), instance.getState().columnPinning.left,,];
|
|
1455
|
-
}, function (allCells, left) {
|
|
1456
|
-
var cells = (left != null ? left : []).map(function (columnId) {
|
|
1457
|
-
return allCells.find(function (cell) {
|
|
1458
|
-
return cell.columnId === columnId;
|
|
1459
|
-
});
|
|
1460
|
-
}).filter(Boolean);
|
|
1461
|
-
return cells;
|
|
1462
|
-
}, {
|
|
1463
|
-
key: 'row.getLeftVisibleCells',
|
|
1464
|
-
debug: instance.options.debug
|
|
1465
|
-
}),
|
|
1466
|
-
getRightVisibleCells: memo(function () {
|
|
1467
|
-
return [row._getAllVisibleCells(), instance.getState().columnPinning.right];
|
|
1468
|
-
}, function (allCells, right) {
|
|
1469
|
-
var cells = (right != null ? right : []).map(function (columnId) {
|
|
1470
|
-
return allCells.find(function (cell) {
|
|
1471
|
-
return cell.columnId === columnId;
|
|
1472
|
-
});
|
|
1473
|
-
}).filter(Boolean);
|
|
1474
|
-
return cells;
|
|
1475
|
-
}, {
|
|
1476
|
-
key: 'row.getRightVisibleCells',
|
|
1477
|
-
debug: instance.options.debug
|
|
1478
|
-
})
|
|
1479
|
-
};
|
|
1480
|
-
}
|
|
1481
|
-
function getInstance$6(instance) {
|
|
1482
|
-
return {
|
|
1483
|
-
createHeader: function createHeader(column, options) {
|
|
1484
|
-
var _options$id;
|
|
1485
|
-
|
|
1486
|
-
var id = (_options$id = options.id) != null ? _options$id : column.id;
|
|
1487
|
-
var header = {
|
|
1488
|
-
id: id,
|
|
1489
|
-
column: column,
|
|
1490
|
-
isPlaceholder: options.isPlaceholder,
|
|
1491
|
-
placeholderId: options.placeholderId,
|
|
1492
|
-
depth: options.depth,
|
|
1493
|
-
subHeaders: [],
|
|
1494
|
-
colSpan: 0,
|
|
1495
|
-
rowSpan: 0,
|
|
1496
|
-
getWidth: function getWidth() {
|
|
1497
|
-
var sum = 0;
|
|
1498
|
-
|
|
1499
|
-
var recurse = function recurse(header) {
|
|
1500
|
-
if (header.subHeaders.length) {
|
|
1501
|
-
header.subHeaders.forEach(recurse);
|
|
1502
|
-
} else {
|
|
1503
|
-
var _header$column$getWid;
|
|
1504
|
-
|
|
1505
|
-
sum += (_header$column$getWid = header.column.getWidth()) != null ? _header$column$getWid : 0;
|
|
1506
|
-
}
|
|
1507
|
-
};
|
|
1508
|
-
|
|
1509
|
-
recurse(header);
|
|
1510
|
-
return sum;
|
|
1511
|
-
},
|
|
1512
|
-
getLeafHeaders: function getLeafHeaders() {
|
|
1513
|
-
var leafHeaders = [];
|
|
1514
|
-
|
|
1515
|
-
var recurseHeader = function recurseHeader(h) {
|
|
1516
|
-
if (h.subHeaders && h.subHeaders.length) {
|
|
1517
|
-
h.subHeaders.map(recurseHeader);
|
|
1518
|
-
}
|
|
1519
|
-
|
|
1520
|
-
leafHeaders.push(h);
|
|
1521
|
-
};
|
|
1522
|
-
|
|
1523
|
-
recurseHeader(header);
|
|
1524
|
-
return leafHeaders;
|
|
1525
|
-
},
|
|
1526
|
-
getHeaderProps: function getHeaderProps(userProps) {
|
|
1527
|
-
return instance.getHeaderProps(header.id, userProps);
|
|
1528
|
-
},
|
|
1529
|
-
getFooterProps: function getFooterProps(userProps) {
|
|
1530
|
-
return instance.getFooterProps(header.id, userProps);
|
|
1531
|
-
},
|
|
1532
|
-
renderHeader: function renderHeader() {
|
|
1533
|
-
return flexRender(column.header, {
|
|
1534
|
-
instance: instance,
|
|
1535
|
-
header: header,
|
|
1536
|
-
column: column
|
|
1537
|
-
});
|
|
1538
|
-
},
|
|
1539
|
-
renderFooter: function renderFooter() {
|
|
1540
|
-
return flexRender(column.footer, {
|
|
1541
|
-
instance: instance,
|
|
1542
|
-
header: header,
|
|
1543
|
-
column: column
|
|
1544
|
-
});
|
|
1545
|
-
}
|
|
1546
|
-
}; // Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
1547
|
-
|
|
1548
|
-
return header;
|
|
1549
|
-
},
|
|
1550
|
-
// Header Groups
|
|
1551
|
-
getHeaderGroups: memo(function () {
|
|
1552
|
-
return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
|
|
1553
|
-
}, function (allColumns, leafColumns, left, right) {
|
|
1554
|
-
var leftColumns = leafColumns.filter(function (column) {
|
|
1555
|
-
return left == null ? void 0 : left.includes(column.id);
|
|
1556
|
-
});
|
|
1557
|
-
var rightColumns = leafColumns.filter(function (column) {
|
|
1558
|
-
return right == null ? void 0 : right.includes(column.id);
|
|
1559
|
-
});
|
|
1560
|
-
var centerColumns = leafColumns.filter(function (column) {
|
|
1561
|
-
return !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id));
|
|
1562
|
-
});
|
|
1563
|
-
var headerGroups = buildHeaderGroups(allColumns, [].concat(leftColumns, centerColumns, rightColumns), instance);
|
|
1564
|
-
return headerGroups;
|
|
1565
|
-
}, {
|
|
1566
|
-
key: 'getHeaderGroups',
|
|
1567
|
-
debug: instance.options.debug
|
|
1568
|
-
}),
|
|
1569
|
-
getCenterHeaderGroups: memo(function () {
|
|
1570
|
-
return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
|
|
1571
|
-
}, function (allColumns, leafColumns, left, right) {
|
|
1572
|
-
leafColumns = leafColumns.filter(function (column) {
|
|
1573
|
-
return !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id));
|
|
1574
|
-
});
|
|
1575
|
-
return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
|
|
1576
|
-
}, {
|
|
1577
|
-
key: 'getCenterHeaderGroups',
|
|
1578
|
-
debug: instance.options.debug
|
|
1579
|
-
}),
|
|
1580
|
-
getLeftHeaderGroups: memo(function () {
|
|
1581
|
-
return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left];
|
|
1582
|
-
}, function (allColumns, leafColumns, left) {
|
|
1583
|
-
leafColumns = leafColumns.filter(function (column) {
|
|
1584
|
-
return left == null ? void 0 : left.includes(column.id);
|
|
1585
|
-
});
|
|
1586
|
-
return buildHeaderGroups(allColumns, leafColumns, instance, 'left');
|
|
1587
|
-
}, {
|
|
1588
|
-
key: 'getLeftHeaderGroups',
|
|
1589
|
-
debug: instance.options.debug
|
|
1590
|
-
}),
|
|
1591
|
-
getRightHeaderGroups: memo(function () {
|
|
1592
|
-
return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right];
|
|
1593
|
-
}, function (allColumns, leafColumns, right) {
|
|
1594
|
-
leafColumns = leafColumns.filter(function (column) {
|
|
1595
|
-
return right == null ? void 0 : right.includes(column.id);
|
|
1596
|
-
});
|
|
1597
|
-
return buildHeaderGroups(allColumns, leafColumns, instance, 'right');
|
|
1598
|
-
}, {
|
|
1599
|
-
key: 'getRightHeaderGroups',
|
|
1600
|
-
debug: instance.options.debug
|
|
1601
|
-
}),
|
|
1602
|
-
// Footer Groups
|
|
1603
|
-
getFooterGroups: memo(function () {
|
|
1604
|
-
return [instance.getHeaderGroups()];
|
|
1605
|
-
}, function (headerGroups) {
|
|
1606
|
-
return [].concat(headerGroups).reverse();
|
|
1607
|
-
}, {
|
|
1608
|
-
key: 'getFooterGroups',
|
|
1609
|
-
debug: instance.options.debug
|
|
1610
|
-
}),
|
|
1611
|
-
getLeftFooterGroups: memo(function () {
|
|
1612
|
-
return [instance.getLeftHeaderGroups()];
|
|
1613
|
-
}, function (headerGroups) {
|
|
1614
|
-
return [].concat(headerGroups).reverse();
|
|
1615
|
-
}, {
|
|
1616
|
-
key: 'getLeftFooterGroups',
|
|
1617
|
-
debug: instance.options.debug
|
|
1618
|
-
}),
|
|
1619
|
-
getCenterFooterGroups: memo(function () {
|
|
1620
|
-
return [instance.getCenterHeaderGroups()];
|
|
1621
|
-
}, function (headerGroups) {
|
|
1622
|
-
return [].concat(headerGroups).reverse();
|
|
1623
|
-
}, {
|
|
1624
|
-
key: 'getCenterFooterGroups',
|
|
1625
|
-
debug: instance.options.debug
|
|
1626
|
-
}),
|
|
1627
|
-
getRightFooterGroups: memo(function () {
|
|
1628
|
-
return [instance.getRightHeaderGroups()];
|
|
1629
|
-
}, function (headerGroups) {
|
|
1630
|
-
return [].concat(headerGroups).reverse();
|
|
1631
|
-
}, {
|
|
1632
|
-
key: 'getRightFooterGroups',
|
|
1633
|
-
debug: instance.options.debug
|
|
1634
|
-
}),
|
|
1635
|
-
// Flat Headers
|
|
1636
|
-
getFlatHeaders: memo(function () {
|
|
1637
|
-
return [instance.getHeaderGroups()];
|
|
1638
|
-
}, function (headerGroups) {
|
|
1639
|
-
return headerGroups.map(function (headerGroup) {
|
|
1640
|
-
return headerGroup.headers;
|
|
1641
|
-
}).flat();
|
|
1642
|
-
}, {
|
|
1643
|
-
key: 'getFlatHeaders',
|
|
1644
|
-
debug: instance.options.debug
|
|
1645
|
-
}),
|
|
1646
|
-
getLeftFlatHeaders: memo(function () {
|
|
1647
|
-
return [instance.getLeftHeaderGroups()];
|
|
1648
|
-
}, function (left) {
|
|
1649
|
-
return left.map(function (headerGroup) {
|
|
1650
|
-
return headerGroup.headers;
|
|
1651
|
-
}).flat();
|
|
1652
|
-
}, {
|
|
1653
|
-
key: 'getLeftFlatHeaders',
|
|
1654
|
-
debug: instance.options.debug
|
|
1655
|
-
}),
|
|
1656
|
-
getCenterFlatHeaders: memo(function () {
|
|
1657
|
-
return [instance.getCenterHeaderGroups()];
|
|
1658
|
-
}, function (left) {
|
|
1659
|
-
return left.map(function (headerGroup) {
|
|
1660
|
-
return headerGroup.headers;
|
|
1661
|
-
}).flat();
|
|
1662
|
-
}, {
|
|
1663
|
-
key: 'getCenterFlatHeaders',
|
|
1664
|
-
debug: instance.options.debug
|
|
1665
|
-
}),
|
|
1666
|
-
getRightFlatHeaders: memo(function () {
|
|
1667
|
-
return [instance.getRightHeaderGroups()];
|
|
1668
|
-
}, function (left) {
|
|
1669
|
-
return left.map(function (headerGroup) {
|
|
1670
|
-
return headerGroup.headers;
|
|
1671
|
-
}).flat();
|
|
1672
|
-
}, {
|
|
1673
|
-
key: 'getRightFlatHeaders',
|
|
1674
|
-
debug: instance.options.debug
|
|
1675
|
-
}),
|
|
1676
|
-
// Leaf Headers
|
|
1677
|
-
getCenterLeafHeaders: memo(function () {
|
|
1678
|
-
return [instance.getCenterFlatHeaders()];
|
|
1679
|
-
}, function (flatHeaders) {
|
|
1680
|
-
return flatHeaders.filter(function (header) {
|
|
1681
|
-
var _header$subHeaders;
|
|
1682
|
-
|
|
1683
|
-
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
|
1684
|
-
});
|
|
1685
|
-
}, {
|
|
1686
|
-
key: 'getCenterLeafHeaders',
|
|
1687
|
-
debug: instance.options.debug
|
|
1688
|
-
}),
|
|
1689
|
-
getLeftLeafHeaders: memo(function () {
|
|
1690
|
-
return [instance.getLeftFlatHeaders()];
|
|
1691
|
-
}, function (flatHeaders) {
|
|
1692
|
-
return flatHeaders.filter(function (header) {
|
|
1693
|
-
var _header$subHeaders2;
|
|
1694
|
-
|
|
1695
|
-
return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
|
|
1696
|
-
});
|
|
1697
|
-
}, {
|
|
1698
|
-
key: 'getLeftLeafHeaders',
|
|
1699
|
-
debug: instance.options.debug
|
|
1700
|
-
}),
|
|
1701
|
-
getRightLeafHeaders: memo(function () {
|
|
1702
|
-
return [instance.getRightFlatHeaders()];
|
|
1703
|
-
}, function (flatHeaders) {
|
|
1704
|
-
return flatHeaders.filter(function (header) {
|
|
1705
|
-
var _header$subHeaders3;
|
|
1706
|
-
|
|
1707
|
-
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
|
1708
|
-
});
|
|
1709
|
-
}, {
|
|
1710
|
-
key: 'getRightLeafHeaders',
|
|
1711
|
-
debug: instance.options.debug
|
|
1712
|
-
}),
|
|
1713
|
-
getLeafHeaders: memo(function () {
|
|
1714
|
-
return [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()];
|
|
1715
|
-
}, function (left, center, right) {
|
|
1716
|
-
var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
|
|
1717
|
-
|
|
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) {
|
|
1719
|
-
return header.getLeafHeaders();
|
|
1720
|
-
}).flat();
|
|
1721
|
-
}, {
|
|
1722
|
-
key: 'getLeafHeaders',
|
|
1723
|
-
debug: instance.options.debug
|
|
1724
|
-
}),
|
|
1725
|
-
getHeader: function getHeader(id) {
|
|
1726
|
-
var header = [].concat(instance.getFlatHeaders(), instance.getCenterFlatHeaders(), instance.getLeftFlatHeaders(), instance.getRightFlatHeaders()).find(function (d) {
|
|
1727
|
-
return d.id === id;
|
|
1728
|
-
});
|
|
1729
|
-
|
|
1730
|
-
if (!header) {
|
|
1731
|
-
{
|
|
1732
|
-
console.warn("Could not find header with id: " + id);
|
|
1733
|
-
}
|
|
1734
|
-
|
|
1735
|
-
throw new Error();
|
|
1736
|
-
}
|
|
1737
|
-
|
|
1738
|
-
return header;
|
|
1739
|
-
},
|
|
1740
|
-
getHeaderGroupProps: function getHeaderGroupProps(id, userProps) {
|
|
1741
|
-
var headerGroup = instance.getHeaderGroups().find(function (d) {
|
|
1742
|
-
return d.id === id;
|
|
1743
|
-
});
|
|
1744
|
-
|
|
1745
|
-
if (!headerGroup) {
|
|
1746
|
-
return;
|
|
1747
|
-
}
|
|
1748
|
-
|
|
1749
|
-
return propGetter({
|
|
1750
|
-
key: headerGroup.id,
|
|
1751
|
-
role: 'row'
|
|
1752
|
-
}, userProps);
|
|
1753
|
-
},
|
|
1754
|
-
getFooterGroupProps: function getFooterGroupProps(id, userProps) {
|
|
1755
|
-
var headerGroup = instance.getFooterGroups().find(function (d) {
|
|
1756
|
-
return d.id === id;
|
|
1757
|
-
});
|
|
1758
|
-
|
|
1759
|
-
if (!headerGroup) {
|
|
1760
|
-
return;
|
|
1761
|
-
}
|
|
1762
|
-
|
|
1763
|
-
var initialProps = {
|
|
1764
|
-
key: headerGroup.id,
|
|
1765
|
-
role: 'row'
|
|
1766
|
-
};
|
|
1767
|
-
return propGetter(initialProps, userProps);
|
|
1768
|
-
},
|
|
1769
|
-
getHeaderProps: function getHeaderProps(id, userProps) {
|
|
1770
|
-
var header = instance.getHeader(id);
|
|
1771
|
-
|
|
1772
|
-
if (!header) {
|
|
1773
|
-
throw new Error();
|
|
1774
|
-
}
|
|
1775
|
-
|
|
1776
|
-
var initialProps = {
|
|
1777
|
-
key: header.id,
|
|
1778
|
-
role: 'columnheader',
|
|
1779
|
-
colSpan: header.colSpan,
|
|
1780
|
-
rowSpan: header.rowSpan
|
|
1781
|
-
};
|
|
1782
|
-
return propGetter(initialProps, userProps);
|
|
1783
|
-
},
|
|
1784
|
-
getFooterProps: function getFooterProps(id, userProps) {
|
|
1785
|
-
var header = instance.getHeader(id);
|
|
1786
|
-
|
|
1787
|
-
if (!header) {
|
|
1788
|
-
return;
|
|
1789
|
-
}
|
|
1790
|
-
|
|
1791
|
-
var initialProps = {
|
|
1792
|
-
key: header.id,
|
|
1793
|
-
role: 'columnfooter',
|
|
1794
|
-
colSpan: header.colSpan,
|
|
1795
|
-
rowSpan: header.rowSpan
|
|
1796
|
-
};
|
|
1797
|
-
return propGetter(initialProps, userProps);
|
|
1798
|
-
},
|
|
1799
|
-
getTotalWidth: function getTotalWidth() {
|
|
1800
|
-
var width = 0;
|
|
1801
|
-
instance.getVisibleLeafColumns().forEach(function (column) {
|
|
1802
|
-
var _column$getWidth;
|
|
1803
|
-
|
|
1804
|
-
width += (_column$getWidth = column.getWidth()) != null ? _column$getWidth : 0;
|
|
1805
|
-
});
|
|
1806
|
-
return width;
|
|
1807
|
-
}
|
|
1808
|
-
};
|
|
1809
|
-
}
|
|
1810
|
-
function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
|
|
1811
|
-
var _headerGroups$0$heade, _headerGroups$;
|
|
1812
|
-
|
|
1813
|
-
// Find the max depth of the columns:
|
|
1814
|
-
// build the leaf column row
|
|
1815
|
-
// build each buffer row going up
|
|
1816
|
-
// placeholder for non-existent level
|
|
1817
|
-
// real column for existing level
|
|
1818
|
-
var maxDepth = 0;
|
|
1819
|
-
|
|
1820
|
-
var findMaxDepth = function findMaxDepth(columns, depth) {
|
|
1821
|
-
if (depth === void 0) {
|
|
1822
|
-
depth = 1;
|
|
1823
|
-
}
|
|
1824
|
-
|
|
1825
|
-
maxDepth = Math.max(maxDepth, depth);
|
|
1826
|
-
columns.filter(function (column) {
|
|
1827
|
-
return column.getIsVisible();
|
|
1828
|
-
}).forEach(function (column) {
|
|
1829
|
-
var _column$columns;
|
|
1830
|
-
|
|
1831
|
-
if ((_column$columns = column.columns) != null && _column$columns.length) {
|
|
1832
|
-
findMaxDepth(column.columns, depth + 1);
|
|
1833
|
-
}
|
|
1834
|
-
}, 0);
|
|
1835
|
-
};
|
|
1836
|
-
|
|
1837
|
-
findMaxDepth(allColumns);
|
|
1838
|
-
var headerGroups = [];
|
|
1839
|
-
|
|
1840
|
-
var createHeaderGroup = function createHeaderGroup(headersToGroup, depth) {
|
|
1841
|
-
// The header group we are creating
|
|
1842
|
-
var headerGroup = {
|
|
1843
|
-
depth: depth,
|
|
1844
|
-
id: [headerFamily, "" + depth].filter(Boolean).join('_'),
|
|
1845
|
-
headers: [],
|
|
1846
|
-
getHeaderGroupProps: function getHeaderGroupProps(getterValue) {
|
|
1847
|
-
return instance.getHeaderGroupProps("" + depth, getterValue);
|
|
1848
|
-
},
|
|
1849
|
-
getFooterGroupProps: function getFooterGroupProps(getterValue) {
|
|
1850
|
-
return instance.getFooterGroupProps("" + depth, getterValue);
|
|
1851
|
-
}
|
|
1852
|
-
}; // The parent columns we're going to scan next
|
|
1853
|
-
|
|
1854
|
-
var parentHeaders = []; // Scan each column for parents
|
|
1855
|
-
|
|
1856
|
-
headersToGroup.forEach(function (headerToGroup) {
|
|
1857
|
-
// What is the latest (last) parent column?
|
|
1858
|
-
var latestParentHeader = [].concat(parentHeaders).reverse()[0];
|
|
1859
|
-
var isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
|
|
1860
|
-
var column;
|
|
1861
|
-
var isPlaceholder = false;
|
|
1862
|
-
|
|
1863
|
-
if (isLeafHeader && headerToGroup.column.parent) {
|
|
1864
|
-
// The parent header is new
|
|
1865
|
-
column = headerToGroup.column.parent;
|
|
1866
|
-
} else {
|
|
1867
|
-
// The parent header is repeated
|
|
1868
|
-
column = headerToGroup.column;
|
|
1869
|
-
isPlaceholder = true;
|
|
1870
|
-
}
|
|
1871
|
-
|
|
1872
|
-
var header = instance.createHeader(column, {
|
|
1873
|
-
id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
|
|
1874
|
-
isPlaceholder: isPlaceholder,
|
|
1875
|
-
placeholderId: isPlaceholder ? "" + parentHeaders.filter(function (d) {
|
|
1876
|
-
return d.column === column;
|
|
1877
|
-
}).length : undefined,
|
|
1878
|
-
depth: depth
|
|
1879
|
-
});
|
|
1880
|
-
|
|
1881
|
-
if (!latestParentHeader || latestParentHeader.column !== header.column) {
|
|
1882
|
-
header.subHeaders.push(headerToGroup);
|
|
1883
|
-
parentHeaders.push(header);
|
|
1884
|
-
} else {
|
|
1885
|
-
latestParentHeader.subHeaders.push(headerToGroup);
|
|
1886
|
-
} // if (!headerToGroup.isPlaceholder) {
|
|
1887
|
-
// headerToGroup.column.header = headerToGroup;
|
|
1888
|
-
// }
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
headerGroup.headers.push(headerToGroup);
|
|
1892
|
-
});
|
|
1893
|
-
headerGroups.push(headerGroup);
|
|
1894
|
-
|
|
1895
|
-
if (depth > 0) {
|
|
1896
|
-
createHeaderGroup(parentHeaders, depth - 1);
|
|
1897
|
-
}
|
|
1898
|
-
};
|
|
1899
|
-
|
|
1900
|
-
var bottomHeaders = columnsToGroup.map(function (column) {
|
|
1901
|
-
return instance.createHeader(column, {
|
|
1902
|
-
depth: maxDepth
|
|
1903
|
-
});
|
|
123
|
+
exports.createTable = createTable;
|
|
124
|
+
exports.createTableFactory = createTableFactory;
|
|
125
|
+
exports.render = render;
|
|
126
|
+
exports.useTableInstance = useTableInstance;
|
|
127
|
+
Object.keys(tableCore).forEach(function (k) {
|
|
128
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
129
|
+
enumerable: true,
|
|
130
|
+
get: function () { return tableCore[k]; }
|
|
1904
131
|
});
|
|
1905
|
-
createHeaderGroup(bottomHeaders, maxDepth - 1);
|
|
1906
|
-
headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
|
|
1907
|
-
// return !headerGroup.headers.every(header => header.isPlaceholder)
|
|
1908
|
-
// })
|
|
1909
|
-
|
|
1910
|
-
var recurseHeadersForSpans = function recurseHeadersForSpans(headers) {
|
|
1911
|
-
var filteredHeaders = headers.filter(function (header) {
|
|
1912
|
-
return header.column.getIsVisible();
|
|
1913
|
-
});
|
|
1914
|
-
return filteredHeaders.map(function (header) {
|
|
1915
|
-
var colSpan = 0;
|
|
1916
|
-
var rowSpan = 0;
|
|
1917
|
-
var childRowSpans = [0];
|
|
1918
|
-
|
|
1919
|
-
if (header.subHeaders && header.subHeaders.length) {
|
|
1920
|
-
childRowSpans = [];
|
|
1921
|
-
recurseHeadersForSpans(header.subHeaders).forEach(function (_ref) {
|
|
1922
|
-
var childColSpan = _ref.colSpan,
|
|
1923
|
-
childRowSpan = _ref.rowSpan;
|
|
1924
|
-
colSpan += childColSpan;
|
|
1925
|
-
childRowSpans.push(childRowSpan);
|
|
1926
|
-
});
|
|
1927
|
-
} else {
|
|
1928
|
-
colSpan = 1;
|
|
1929
|
-
}
|
|
1930
|
-
|
|
1931
|
-
var minChildRowSpan = Math.min.apply(Math, childRowSpans);
|
|
1932
|
-
rowSpan = rowSpan + minChildRowSpan;
|
|
1933
|
-
header.colSpan = colSpan > 0 ? colSpan : undefined;
|
|
1934
|
-
header.rowSpan = rowSpan > 0 ? rowSpan : undefined;
|
|
1935
|
-
return {
|
|
1936
|
-
colSpan: colSpan,
|
|
1937
|
-
rowSpan: rowSpan
|
|
1938
|
-
};
|
|
1939
|
-
});
|
|
1940
|
-
};
|
|
1941
|
-
|
|
1942
|
-
recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
|
|
1943
|
-
return headerGroups;
|
|
1944
|
-
}
|
|
1945
|
-
|
|
1946
|
-
var Headers = /*#__PURE__*/Object.freeze({
|
|
1947
|
-
__proto__: null,
|
|
1948
|
-
createRow: createRow$2,
|
|
1949
|
-
getInstance: getInstance$6,
|
|
1950
|
-
buildHeaderGroups: buildHeaderGroups
|
|
1951
132
|
});
|
|
1952
133
|
|
|
1953
|
-
var filterTypes = {
|
|
1954
|
-
includesString: includesString,
|
|
1955
|
-
includesStringSensitive: includesStringSensitive,
|
|
1956
|
-
equalsString: equalsString,
|
|
1957
|
-
equalsStringSensitive: equalsStringSensitive,
|
|
1958
|
-
arrIncludes: arrIncludes,
|
|
1959
|
-
arrIncludesAll: arrIncludesAll,
|
|
1960
|
-
equals: equals,
|
|
1961
|
-
weakEquals: weakEquals,
|
|
1962
|
-
betweenNumberRange: betweenNumberRange
|
|
1963
|
-
};
|
|
1964
|
-
|
|
1965
|
-
function includesString(rows, columnIds, filterValue) {
|
|
1966
|
-
var search = String(filterValue).toLowerCase();
|
|
1967
|
-
rows = rows.filter(function (row) {
|
|
1968
|
-
return columnIds.some(function (id) {
|
|
1969
|
-
return String(row.values[id]).toLowerCase().includes(search);
|
|
1970
|
-
});
|
|
1971
|
-
});
|
|
1972
|
-
return rows;
|
|
1973
|
-
}
|
|
1974
|
-
|
|
1975
|
-
includesString.autoRemove = function (val) {
|
|
1976
|
-
return testFalsey(val);
|
|
1977
|
-
};
|
|
1978
|
-
|
|
1979
|
-
function includesStringSensitive(rows, columnIds, filterValue) {
|
|
1980
|
-
var search = String(filterValue);
|
|
1981
|
-
rows = rows.filter(function (row) {
|
|
1982
|
-
return columnIds.some(function (id) {
|
|
1983
|
-
return String(row.values[id]).includes(search);
|
|
1984
|
-
});
|
|
1985
|
-
});
|
|
1986
|
-
return rows;
|
|
1987
|
-
}
|
|
1988
|
-
|
|
1989
|
-
includesStringSensitive.autoRemove = function (val) {
|
|
1990
|
-
return testFalsey(val);
|
|
1991
|
-
};
|
|
1992
|
-
|
|
1993
|
-
function equalsString(rows, columnIds, filterValue) {
|
|
1994
|
-
var search = String(filterValue).toLowerCase();
|
|
1995
|
-
return rows.filter(function (row) {
|
|
1996
|
-
return columnIds.some(function (id) {
|
|
1997
|
-
var rowValue = row.values[id];
|
|
1998
|
-
return rowValue !== undefined ? String(rowValue).toLowerCase() === search : true;
|
|
1999
|
-
});
|
|
2000
|
-
});
|
|
2001
|
-
}
|
|
2002
|
-
|
|
2003
|
-
equalsString.autoRemove = function (val) {
|
|
2004
|
-
return testFalsey(val);
|
|
2005
|
-
};
|
|
2006
|
-
|
|
2007
|
-
function equalsStringSensitive(rows, columnIds, filterValue) {
|
|
2008
|
-
var search = String(filterValue);
|
|
2009
|
-
return rows.filter(function (row) {
|
|
2010
|
-
return columnIds.some(function (id) {
|
|
2011
|
-
var rowValue = row.values[id];
|
|
2012
|
-
return rowValue !== undefined ? String(rowValue) === search : true;
|
|
2013
|
-
});
|
|
2014
|
-
});
|
|
2015
|
-
}
|
|
2016
|
-
|
|
2017
|
-
equalsStringSensitive.autoRemove = function (val) {
|
|
2018
|
-
return testFalsey(val);
|
|
2019
|
-
};
|
|
2020
|
-
|
|
2021
|
-
function arrIncludes(rows, columnIds, filterValue) {
|
|
2022
|
-
return rows.filter(function (row) {
|
|
2023
|
-
return columnIds.some(function (id) {
|
|
2024
|
-
var rowValue = row.values[id];
|
|
2025
|
-
return rowValue.includes(filterValue);
|
|
2026
|
-
});
|
|
2027
|
-
});
|
|
2028
|
-
}
|
|
2029
|
-
|
|
2030
|
-
arrIncludes.autoRemove = function (val) {
|
|
2031
|
-
return testFalsey(val) || !(val != null && val.length);
|
|
2032
|
-
};
|
|
2033
|
-
|
|
2034
|
-
function arrIncludesAll(rows, columnIds, filterValue) {
|
|
2035
|
-
return rows.filter(function (row) {
|
|
2036
|
-
return columnIds.some(function (id) {
|
|
2037
|
-
var rowValue = row.values[id];
|
|
2038
|
-
return rowValue && rowValue.length && filterValue.every(function (val) {
|
|
2039
|
-
return rowValue.includes(val);
|
|
2040
|
-
});
|
|
2041
|
-
});
|
|
2042
|
-
});
|
|
2043
|
-
}
|
|
2044
|
-
|
|
2045
|
-
arrIncludesAll.autoRemove = function (val) {
|
|
2046
|
-
return testFalsey(val) || !(val != null && val.length);
|
|
2047
|
-
};
|
|
2048
|
-
|
|
2049
|
-
function equals(rows, columnIds, filterValue) {
|
|
2050
|
-
return rows.filter(function (row) {
|
|
2051
|
-
return columnIds.some(function (id) {
|
|
2052
|
-
var rowValue = row.values[id];
|
|
2053
|
-
return rowValue === filterValue;
|
|
2054
|
-
});
|
|
2055
|
-
});
|
|
2056
|
-
}
|
|
2057
|
-
|
|
2058
|
-
equals.autoRemove = function (val) {
|
|
2059
|
-
return testFalsey(val);
|
|
2060
|
-
};
|
|
2061
|
-
|
|
2062
|
-
function weakEquals(rows, columnIds, filterValue) {
|
|
2063
|
-
return rows.filter(function (row) {
|
|
2064
|
-
return columnIds.some(function (id) {
|
|
2065
|
-
var rowValue = row.values[id]; // eslint-disable-next-line eqeqeq
|
|
2066
|
-
|
|
2067
|
-
return rowValue == filterValue;
|
|
2068
|
-
});
|
|
2069
|
-
});
|
|
2070
|
-
}
|
|
2071
|
-
|
|
2072
|
-
weakEquals.autoRemove = function (val) {
|
|
2073
|
-
return testFalsey(val);
|
|
2074
|
-
};
|
|
2075
|
-
|
|
2076
|
-
function betweenNumberRange(rows, columnIds, filterValue) {
|
|
2077
|
-
var _ref = filterValue || [],
|
|
2078
|
-
unsafeMin = _ref[0],
|
|
2079
|
-
unsafeMax = _ref[1];
|
|
2080
|
-
|
|
2081
|
-
var parsedMin = typeof unsafeMin !== 'number' ? parseFloat(unsafeMin) : unsafeMin;
|
|
2082
|
-
var parsedMax = typeof unsafeMax !== 'number' ? parseFloat(unsafeMax) : unsafeMax;
|
|
2083
|
-
var min = unsafeMin === null || Number.isNaN(parsedMin) ? -Infinity : parsedMin;
|
|
2084
|
-
var max = unsafeMax === null || Number.isNaN(parsedMax) ? Infinity : parsedMax;
|
|
2085
|
-
|
|
2086
|
-
if (min > max) {
|
|
2087
|
-
var temp = min;
|
|
2088
|
-
min = max;
|
|
2089
|
-
max = temp;
|
|
2090
|
-
}
|
|
2091
|
-
|
|
2092
|
-
return rows.filter(function (row) {
|
|
2093
|
-
return columnIds.some(function (id) {
|
|
2094
|
-
var rowValue = row.values[id];
|
|
2095
|
-
return rowValue >= min && rowValue <= max;
|
|
2096
|
-
});
|
|
2097
|
-
});
|
|
2098
|
-
}
|
|
2099
|
-
|
|
2100
|
-
betweenNumberRange.autoRemove = function (val) {
|
|
2101
|
-
return testFalsey(val) || testFalsey(val[0]) && testFalsey(val[1]);
|
|
2102
|
-
}; // Utils
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
function testFalsey(val) {
|
|
2106
|
-
return val === undefined || val === null || val === '';
|
|
2107
|
-
}
|
|
2108
|
-
|
|
2109
|
-
//
|
|
2110
|
-
function getDefaultColumn$1() {
|
|
2111
|
-
return {
|
|
2112
|
-
filterType: 'auto'
|
|
2113
|
-
};
|
|
2114
|
-
}
|
|
2115
|
-
function getInitialState$5() {
|
|
2116
|
-
return {
|
|
2117
|
-
columnFilters: [],
|
|
2118
|
-
globalFilter: undefined
|
|
2119
|
-
};
|
|
2120
|
-
}
|
|
2121
|
-
function getDefaultOptions$5(instance) {
|
|
2122
|
-
return {
|
|
2123
|
-
onColumnFiltersChange: makeStateUpdater('columnFilters', instance),
|
|
2124
|
-
onGlobalFilterChange: makeStateUpdater('globalFilter', instance),
|
|
2125
|
-
autoResetColumnFilters: true,
|
|
2126
|
-
filterFromChildrenUp: true,
|
|
2127
|
-
autoResetGlobalFilter: true,
|
|
2128
|
-
globalFilterType: 'auto',
|
|
2129
|
-
getColumnCanGlobalFilterFn: function getColumnCanGlobalFilterFn(column) {
|
|
2130
|
-
var _instance$getCoreFlat, _instance$getCoreFlat2;
|
|
2131
|
-
|
|
2132
|
-
var value = (_instance$getCoreFlat = instance.getCoreFlatRows()[0]) == null ? void 0 : (_instance$getCoreFlat2 = _instance$getCoreFlat.getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreFlat2.value;
|
|
2133
|
-
return typeof value === 'string';
|
|
2134
|
-
}
|
|
2135
|
-
};
|
|
2136
|
-
}
|
|
2137
|
-
function createColumn$2(column, instance) {
|
|
2138
|
-
var getFacetInfo = memo(function () {
|
|
2139
|
-
return [column.getPreFilteredRows()];
|
|
2140
|
-
}, function (rows) {
|
|
2141
|
-
var _rows$0$values$column, _rows$, _rows$0$values$column2, _rows$2;
|
|
2142
|
-
|
|
2143
|
-
if (rows === void 0) {
|
|
2144
|
-
rows = [];
|
|
2145
|
-
}
|
|
2146
|
-
|
|
2147
|
-
var preFilteredUniqueValues = new Map();
|
|
2148
|
-
var preFilteredMinMaxValues = [(_rows$0$values$column = (_rows$ = rows[0]) == null ? void 0 : _rows$.values[column.id]) != null ? _rows$0$values$column : null, (_rows$0$values$column2 = (_rows$2 = rows[0]) == null ? void 0 : _rows$2.values[column.id]) != null ? _rows$0$values$column2 : null];
|
|
2149
|
-
|
|
2150
|
-
for (var i = 0; i < rows.length; i++) {
|
|
2151
|
-
var _rows$i;
|
|
2152
|
-
|
|
2153
|
-
var _value = (_rows$i = rows[i]) == null ? void 0 : _rows$i.values[column.id];
|
|
2154
|
-
|
|
2155
|
-
if (preFilteredUniqueValues.has(_value)) {
|
|
2156
|
-
var _preFilteredUniqueVal;
|
|
2157
|
-
|
|
2158
|
-
preFilteredUniqueValues.set(_value, ((_preFilteredUniqueVal = preFilteredUniqueValues.get(_value)) != null ? _preFilteredUniqueVal : 0) + 1);
|
|
2159
|
-
} else {
|
|
2160
|
-
preFilteredUniqueValues.set(_value, 1);
|
|
2161
|
-
}
|
|
2162
|
-
|
|
2163
|
-
if (_value < preFilteredMinMaxValues[0]) {
|
|
2164
|
-
preFilteredMinMaxValues[0] = _value;
|
|
2165
|
-
} else if (_value > preFilteredMinMaxValues[1]) {
|
|
2166
|
-
preFilteredMinMaxValues[1] = _value;
|
|
2167
|
-
}
|
|
2168
|
-
}
|
|
2169
|
-
|
|
2170
|
-
return {
|
|
2171
|
-
preFilteredUniqueValues: preFilteredUniqueValues,
|
|
2172
|
-
preFilteredMinMaxValues: preFilteredMinMaxValues
|
|
2173
|
-
};
|
|
2174
|
-
}, {
|
|
2175
|
-
key: 'column.getFacetInfo',
|
|
2176
|
-
debug: instance.options.debug
|
|
2177
|
-
});
|
|
2178
|
-
return {
|
|
2179
|
-
filterType: column.filterType,
|
|
2180
|
-
getCanColumnFilter: function getCanColumnFilter() {
|
|
2181
|
-
return instance.getColumnCanColumnFilter(column.id);
|
|
2182
|
-
},
|
|
2183
|
-
getCanGlobalFilter: function getCanGlobalFilter() {
|
|
2184
|
-
return instance.getColumnCanGlobalFilter(column.id);
|
|
2185
|
-
},
|
|
2186
|
-
getColumnFilterIndex: function getColumnFilterIndex() {
|
|
2187
|
-
return instance.getColumnFilterIndex(column.id);
|
|
2188
|
-
},
|
|
2189
|
-
getIsColumnFiltered: function getIsColumnFiltered() {
|
|
2190
|
-
return instance.getColumnIsFiltered(column.id);
|
|
2191
|
-
},
|
|
2192
|
-
getColumnFilterValue: function getColumnFilterValue() {
|
|
2193
|
-
return instance.getColumnFilterValue(column.id);
|
|
2194
|
-
},
|
|
2195
|
-
setColumnFilterValue: function setColumnFilterValue(val) {
|
|
2196
|
-
return instance.setColumnFilterValue(column.id, val);
|
|
2197
|
-
},
|
|
2198
|
-
getPreFilteredUniqueValues: function getPreFilteredUniqueValues() {
|
|
2199
|
-
return getFacetInfo().preFilteredUniqueValues;
|
|
2200
|
-
},
|
|
2201
|
-
getPreFilteredMinMaxValues: function getPreFilteredMinMaxValues() {
|
|
2202
|
-
return getFacetInfo().preFilteredMinMaxValues;
|
|
2203
|
-
},
|
|
2204
|
-
getPreFilteredRows: function getPreFilteredRows() {
|
|
2205
|
-
return undefined;
|
|
2206
|
-
}
|
|
2207
|
-
};
|
|
2208
|
-
}
|
|
2209
|
-
function getInstance$5(instance) {
|
|
2210
|
-
var registered = false;
|
|
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
|
-
},
|
|
2234
|
-
getColumnAutoFilterFn: function getColumnAutoFilterFn(columnId) {
|
|
2235
|
-
var firstRow = instance.getCoreFlatRows()[0];
|
|
2236
|
-
var value = firstRow == null ? void 0 : firstRow.values[columnId];
|
|
2237
|
-
|
|
2238
|
-
if (typeof value === 'string') {
|
|
2239
|
-
return filterTypes.includesString;
|
|
2240
|
-
}
|
|
2241
|
-
|
|
2242
|
-
if (typeof value === 'number') {
|
|
2243
|
-
return filterTypes.betweenNumberRange;
|
|
2244
|
-
}
|
|
2245
|
-
|
|
2246
|
-
if (value !== null && typeof value === 'object') {
|
|
2247
|
-
return filterTypes.equals;
|
|
2248
|
-
}
|
|
2249
|
-
|
|
2250
|
-
if (Array.isArray(value)) {
|
|
2251
|
-
return filterTypes.arrIncludes;
|
|
2252
|
-
}
|
|
2253
|
-
|
|
2254
|
-
return filterTypes.weakEquals;
|
|
2255
|
-
},
|
|
2256
|
-
getGlobalAutoFilterFn: function getGlobalAutoFilterFn() {
|
|
2257
|
-
return filterTypes.includesString;
|
|
2258
|
-
},
|
|
2259
|
-
getColumnFilterFn: function getColumnFilterFn(columnId) {
|
|
2260
|
-
var _ref;
|
|
2261
|
-
|
|
2262
|
-
var column = instance.getColumn(columnId);
|
|
2263
|
-
var userFilterTypes = instance.options.filterTypes;
|
|
2264
|
-
|
|
2265
|
-
if (!column) {
|
|
2266
|
-
throw new Error();
|
|
2267
|
-
}
|
|
2268
|
-
|
|
2269
|
-
return isFunction(column.filterType) ? column.filterType : column.filterType === 'auto' ? instance.getColumnAutoFilterFn(columnId) : (_ref = userFilterTypes == null ? void 0 : userFilterTypes[column.filterType]) != null ? _ref : filterTypes[column.filterType];
|
|
2270
|
-
},
|
|
2271
|
-
getGlobalFilterFn: function getGlobalFilterFn() {
|
|
2272
|
-
var _ref2;
|
|
2273
|
-
|
|
2274
|
-
var _instance$options = instance.options,
|
|
2275
|
-
userFilterTypes = _instance$options.filterTypes,
|
|
2276
|
-
globalFilterType = _instance$options.globalFilterType;
|
|
2277
|
-
return isFunction(globalFilterType) ? globalFilterType : globalFilterType === 'auto' ? instance.getGlobalAutoFilterFn() : (_ref2 = userFilterTypes == null ? void 0 : userFilterTypes[globalFilterType]) != null ? _ref2 : filterTypes[globalFilterType];
|
|
2278
|
-
},
|
|
2279
|
-
setColumnFilters: function setColumnFilters(updater) {
|
|
2280
|
-
var leafColumns = instance.getAllLeafColumns();
|
|
2281
|
-
|
|
2282
|
-
var updateFn = function updateFn(old) {
|
|
2283
|
-
var _functionalUpdate;
|
|
2284
|
-
|
|
2285
|
-
return (_functionalUpdate = functionalUpdate(updater, old)) == null ? void 0 : _functionalUpdate.filter(function (filter) {
|
|
2286
|
-
var column = leafColumns.find(function (d) {
|
|
2287
|
-
return d.id === filter.id;
|
|
2288
|
-
});
|
|
2289
|
-
|
|
2290
|
-
if (column) {
|
|
2291
|
-
var filterFn = instance.getColumnFilterFn(column.id);
|
|
2292
|
-
|
|
2293
|
-
if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {
|
|
2294
|
-
return false;
|
|
2295
|
-
}
|
|
2296
|
-
}
|
|
2297
|
-
|
|
2298
|
-
return true;
|
|
2299
|
-
});
|
|
2300
|
-
};
|
|
2301
|
-
|
|
2302
|
-
instance.options.onColumnFiltersChange == null ? void 0 : instance.options.onColumnFiltersChange(updateFn, updateFn(instance.getState().columnFilters));
|
|
2303
|
-
},
|
|
2304
|
-
setGlobalFilter: function setGlobalFilter(updater) {
|
|
2305
|
-
instance.options.onGlobalFilterChange == null ? void 0 : instance.options.onGlobalFilterChange(updater, functionalUpdate(updater, instance.getState().globalFilter));
|
|
2306
|
-
},
|
|
2307
|
-
resetGlobalFilter: function resetGlobalFilter() {
|
|
2308
|
-
instance.setGlobalFilter(undefined);
|
|
2309
|
-
},
|
|
2310
|
-
getColumnCanColumnFilter: function getColumnCanColumnFilter(columnId) {
|
|
2311
|
-
var _ref3, _ref4, _ref5, _ref6, _ref7, _column$enableAllFilt;
|
|
2312
|
-
|
|
2313
|
-
var column = instance.getColumn(columnId);
|
|
2314
|
-
|
|
2315
|
-
if (!column) {
|
|
2316
|
-
throw new Error();
|
|
2317
|
-
}
|
|
2318
|
-
|
|
2319
|
-
return (_ref3 = (_ref4 = (_ref5 = (_ref6 = (_ref7 = (_column$enableAllFilt = column.enableAllFilters) != null ? _column$enableAllFilt : column.enableColumnFilter) != null ? _ref7 : instance.options.enableFilters) != null ? _ref6 : instance.options.enableColumnFilters) != null ? _ref5 : column.defaultCanFilter) != null ? _ref4 : column.defaultCanColumnFilter) != null ? _ref3 : !!column.accessorFn;
|
|
2320
|
-
},
|
|
2321
|
-
getColumnCanGlobalFilter: function getColumnCanGlobalFilter(columnId) {
|
|
2322
|
-
var _ref8, _ref9, _ref10, _ref11, _ref12, _ref13, _instance$options$ena;
|
|
2323
|
-
|
|
2324
|
-
var column = instance.getColumn(columnId);
|
|
2325
|
-
|
|
2326
|
-
if (!column) {
|
|
2327
|
-
throw new Error();
|
|
2328
|
-
}
|
|
2329
|
-
|
|
2330
|
-
return (_ref8 = ((_ref9 = (_ref10 = (_ref11 = (_ref12 = (_ref13 = (_instance$options$ena = instance.options.enableFilters) != null ? _instance$options$ena : instance.options.enableGlobalFilter) != null ? _ref13 : column.enableAllFilters) != null ? _ref12 : column.enableGlobalFilter) != null ? _ref11 : column.defaultCanFilter) != null ? _ref10 : column.defaultCanGlobalFilter) != null ? _ref9 : !!column.accessorFn) && (instance.options.getColumnCanGlobalFilterFn == null ? void 0 : instance.options.getColumnCanGlobalFilterFn(column))) != null ? _ref8 : true;
|
|
2331
|
-
},
|
|
2332
|
-
getColumnIsFiltered: function getColumnIsFiltered(columnId) {
|
|
2333
|
-
return instance.getColumnFilterIndex(columnId) > -1;
|
|
2334
|
-
},
|
|
2335
|
-
getColumnFilterValue: function getColumnFilterValue(columnId) {
|
|
2336
|
-
var _instance$getState$co, _instance$getState$co2;
|
|
2337
|
-
|
|
2338
|
-
return (_instance$getState$co = instance.getState().columnFilters) == null ? void 0 : (_instance$getState$co2 = _instance$getState$co.find(function (d) {
|
|
2339
|
-
return d.id === columnId;
|
|
2340
|
-
})) == null ? void 0 : _instance$getState$co2.value;
|
|
2341
|
-
},
|
|
2342
|
-
getColumnFilterIndex: function getColumnFilterIndex(columnId) {
|
|
2343
|
-
var _instance$getState$co3, _instance$getState$co4;
|
|
2344
|
-
|
|
2345
|
-
return (_instance$getState$co3 = (_instance$getState$co4 = instance.getState().columnFilters) == null ? void 0 : _instance$getState$co4.findIndex(function (d) {
|
|
2346
|
-
return d.id === columnId;
|
|
2347
|
-
})) != null ? _instance$getState$co3 : -1;
|
|
2348
|
-
},
|
|
2349
|
-
setColumnFilterValue: function setColumnFilterValue(columnId, value) {
|
|
2350
|
-
if (!columnId) return;
|
|
2351
|
-
instance.setColumnFilters(function (old) {
|
|
2352
|
-
var column = instance.getColumn(columnId);
|
|
2353
|
-
|
|
2354
|
-
if (!column) {
|
|
2355
|
-
{
|
|
2356
|
-
console.warn("React-Table: Could not find a column with id: " + columnId);
|
|
2357
|
-
}
|
|
2358
|
-
|
|
2359
|
-
throw new Error();
|
|
2360
|
-
}
|
|
2361
|
-
|
|
2362
|
-
var filterFn = instance.getColumnFilterFn(column.id);
|
|
2363
|
-
var previousfilter = old == null ? void 0 : old.find(function (d) {
|
|
2364
|
-
return d.id === columnId;
|
|
2365
|
-
});
|
|
2366
|
-
var newFilter = functionalUpdate(value, previousfilter ? previousfilter.value : undefined); //
|
|
2367
|
-
|
|
2368
|
-
if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {
|
|
2369
|
-
var _old$filter;
|
|
2370
|
-
|
|
2371
|
-
return (_old$filter = old == null ? void 0 : old.filter(function (d) {
|
|
2372
|
-
return d.id !== columnId;
|
|
2373
|
-
})) != null ? _old$filter : [];
|
|
2374
|
-
}
|
|
2375
|
-
|
|
2376
|
-
var newFilterObj = {
|
|
2377
|
-
id: columnId,
|
|
2378
|
-
value: newFilter
|
|
2379
|
-
};
|
|
2380
|
-
|
|
2381
|
-
if (previousfilter) {
|
|
2382
|
-
var _old$map;
|
|
2383
|
-
|
|
2384
|
-
return (_old$map = old == null ? void 0 : old.map(function (d) {
|
|
2385
|
-
if (d.id === columnId) {
|
|
2386
|
-
return newFilterObj;
|
|
2387
|
-
}
|
|
2388
|
-
|
|
2389
|
-
return d;
|
|
2390
|
-
})) != null ? _old$map : [];
|
|
2391
|
-
}
|
|
2392
|
-
|
|
2393
|
-
if (old != null && old.length) {
|
|
2394
|
-
return [].concat(old, [newFilterObj]);
|
|
2395
|
-
}
|
|
2396
|
-
|
|
2397
|
-
return [newFilterObj];
|
|
2398
|
-
});
|
|
2399
|
-
},
|
|
2400
|
-
resetColumnFilters: function resetColumnFilters() {
|
|
2401
|
-
var _instance$options$ini, _instance$options2, _instance$options2$in;
|
|
2402
|
-
|
|
2403
|
-
instance.setColumnFilters((_instance$options$ini = (_instance$options2 = instance.options) == null ? void 0 : (_instance$options2$in = _instance$options2.initialState) == null ? void 0 : _instance$options2$in.columnFilters) != null ? _instance$options$ini : []);
|
|
2404
|
-
},
|
|
2405
|
-
getColumnFilteredRowModel: memo(function () {
|
|
2406
|
-
return [instance.getState().columnFilters, instance.getCoreRowModel(), instance.options.columnFilterRowsFn];
|
|
2407
|
-
}, function (columnFilters, rowModel, columnFiltersFn) {
|
|
2408
|
-
var columnFilteredRowModel = function () {
|
|
2409
|
-
if (!(columnFilters != null && columnFilters.length) || !columnFiltersFn) {
|
|
2410
|
-
return rowModel;
|
|
2411
|
-
}
|
|
2412
|
-
|
|
2413
|
-
if (instance.options.debug) console.info('Column Filtering...');
|
|
2414
|
-
return columnFiltersFn(instance, rowModel);
|
|
2415
|
-
}(); // Now that each filtered column has it's partially filtered rows,
|
|
2416
|
-
// lets assign the final filtered rows to all of the other columns
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
var nonFilteredColumns = instance.getAllLeafColumns().filter(function (column) {
|
|
2420
|
-
var _instance$getState$co5;
|
|
2421
|
-
|
|
2422
|
-
return !((_instance$getState$co5 = instance.getState().columnFilters) != null && _instance$getState$co5.find(function (d) {
|
|
2423
|
-
return d.id === column.id;
|
|
2424
|
-
}));
|
|
2425
|
-
}); // This essentially enables faceted filter options to be built easily
|
|
2426
|
-
// using every column's preFilteredRows value
|
|
2427
|
-
|
|
2428
|
-
nonFilteredColumns.forEach(function (column) {
|
|
2429
|
-
column.getPreFilteredRows = function () {
|
|
2430
|
-
return columnFilteredRowModel.rows;
|
|
2431
|
-
};
|
|
2432
|
-
});
|
|
2433
|
-
return columnFilteredRowModel;
|
|
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
|
|
2452
|
-
getPreColumnFilteredRows: function getPreColumnFilteredRows() {
|
|
2453
|
-
return instance.getCoreRowModel().rows;
|
|
2454
|
-
},
|
|
2455
|
-
getPreColumnFilteredFlatRows: function getPreColumnFilteredFlatRows() {
|
|
2456
|
-
return instance.getCoreRowModel().flatRows;
|
|
2457
|
-
},
|
|
2458
|
-
getPreColumnFilteredRowsById: function getPreColumnFilteredRowsById() {
|
|
2459
|
-
return instance.getCoreRowModel().rowsById;
|
|
2460
|
-
},
|
|
2461
|
-
getColumnFilteredRows: function getColumnFilteredRows() {
|
|
2462
|
-
return instance.getColumnFilteredRowModel().rows;
|
|
2463
|
-
},
|
|
2464
|
-
getColumnFilteredFlatRows: function getColumnFilteredFlatRows() {
|
|
2465
|
-
return instance.getColumnFilteredRowModel().flatRows;
|
|
2466
|
-
},
|
|
2467
|
-
getColumnFilteredRowsById: function getColumnFilteredRowsById() {
|
|
2468
|
-
return instance.getColumnFilteredRowModel().rowsById;
|
|
2469
|
-
},
|
|
2470
|
-
getGlobalFilteredRowModel: memo(function () {
|
|
2471
|
-
return [instance.getState().globalFilter, instance.getColumnFilteredRowModel(), instance.options.globalFilterRowsFn];
|
|
2472
|
-
}, function (globalFilterValue, columnFilteredRowModel, globalFiltersFn) {
|
|
2473
|
-
var globalFilteredRowModel = function () {
|
|
2474
|
-
if (!globalFiltersFn || !globalFilterValue) {
|
|
2475
|
-
return columnFilteredRowModel;
|
|
2476
|
-
}
|
|
2477
|
-
|
|
2478
|
-
if (instance.options.debug) console.info('Global Filtering...');
|
|
2479
|
-
return globalFiltersFn(instance, columnFilteredRowModel);
|
|
2480
|
-
}(); // Now that each filtered column has it's partially filtered rows,
|
|
2481
|
-
// lets assign the final filtered rows to all of the other columns
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
var nonFilteredColumns = instance.getAllLeafColumns().filter(function (column) {
|
|
2485
|
-
var _instance$getState$co6;
|
|
2486
|
-
|
|
2487
|
-
return !((_instance$getState$co6 = instance.getState().columnFilters) != null && _instance$getState$co6.find(function (d) {
|
|
2488
|
-
return d.id === column.id;
|
|
2489
|
-
}));
|
|
2490
|
-
}); // This essentially enables faceted filter options to be built easily
|
|
2491
|
-
// using every column's preFilteredRows value
|
|
2492
|
-
|
|
2493
|
-
nonFilteredColumns.forEach(function (column) {
|
|
2494
|
-
column.getPreFilteredRows = function () {
|
|
2495
|
-
return globalFilteredRowModel.rows;
|
|
2496
|
-
};
|
|
2497
|
-
});
|
|
2498
|
-
return globalFilteredRowModel;
|
|
2499
|
-
}, {
|
|
2500
|
-
key: 'getGlobalFilteredRowModel',
|
|
2501
|
-
debug: instance.options.debug,
|
|
2502
|
-
onChange: function onChange() {
|
|
2503
|
-
return instance._notifySortingReset();
|
|
2504
|
-
}
|
|
2505
|
-
}),
|
|
2506
|
-
getPreGlobalFilteredRows: function getPreGlobalFilteredRows() {
|
|
2507
|
-
return instance.getColumnFilteredRowModel().rows;
|
|
2508
|
-
},
|
|
2509
|
-
getPreGlobalFilteredFlatRows: function getPreGlobalFilteredFlatRows() {
|
|
2510
|
-
return instance.getColumnFilteredRowModel().flatRows;
|
|
2511
|
-
},
|
|
2512
|
-
getPreGlobalFilteredRowsById: function getPreGlobalFilteredRowsById() {
|
|
2513
|
-
return instance.getColumnFilteredRowModel().rowsById;
|
|
2514
|
-
},
|
|
2515
|
-
getGlobalFilteredRows: function getGlobalFilteredRows() {
|
|
2516
|
-
return instance.getGlobalFilteredRowModel().rows;
|
|
2517
|
-
},
|
|
2518
|
-
getGlobalFilteredFlatRows: function getGlobalFilteredFlatRows() {
|
|
2519
|
-
return instance.getGlobalFilteredRowModel().flatRows;
|
|
2520
|
-
},
|
|
2521
|
-
getGlobalFilteredRowsById: function getGlobalFilteredRowsById() {
|
|
2522
|
-
return instance.getGlobalFilteredRowModel().rowsById;
|
|
2523
|
-
}
|
|
2524
|
-
};
|
|
2525
|
-
}
|
|
2526
|
-
function shouldAutoRemoveFilter(filterFn, value, column) {
|
|
2527
|
-
return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
|
|
2528
|
-
}
|
|
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
|
-
|
|
2540
|
-
var reSplitAlphaNumeric = /([0-9]+)/gm;
|
|
2541
|
-
var sortTypes = {
|
|
2542
|
-
alphanumeric: alphanumeric,
|
|
2543
|
-
alphanumericCaseSensitive: alphanumericCaseSensitive,
|
|
2544
|
-
text: text,
|
|
2545
|
-
textCaseSensitive: textCaseSensitive,
|
|
2546
|
-
datetime: datetime,
|
|
2547
|
-
basic: basic
|
|
2548
|
-
};
|
|
2549
|
-
|
|
2550
|
-
function alphanumeric(rowA, rowB, columnId) {
|
|
2551
|
-
return compareAlphanumeric(toString(rowA.values[columnId]).toLowerCase(), toString(rowB.values[columnId]).toLowerCase());
|
|
2552
|
-
}
|
|
2553
|
-
|
|
2554
|
-
function alphanumericCaseSensitive(rowA, rowB, columnId) {
|
|
2555
|
-
return compareAlphanumeric(toString(rowA.values[columnId]), toString(rowB.values[columnId]));
|
|
2556
|
-
} // Mixed sorting is slow, but very inclusive of many edge cases.
|
|
2557
|
-
// It handles numbers, mixed alphanumeric combinations, and even
|
|
2558
|
-
// null, undefined, and Infinity
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
function compareAlphanumeric(aStr, bStr) {
|
|
2562
|
-
// Split on number groups, but keep the delimiter
|
|
2563
|
-
// Then remove falsey split values
|
|
2564
|
-
var a = aStr.split(reSplitAlphaNumeric).filter(Boolean);
|
|
2565
|
-
var b = bStr.split(reSplitAlphaNumeric).filter(Boolean); // While
|
|
2566
|
-
|
|
2567
|
-
while (a.length && b.length) {
|
|
2568
|
-
var aa = a.shift();
|
|
2569
|
-
var bb = b.shift();
|
|
2570
|
-
var an = parseInt(aa, 10);
|
|
2571
|
-
var bn = parseInt(bb, 10);
|
|
2572
|
-
var combo = [an, bn].sort(); // Both are string
|
|
2573
|
-
|
|
2574
|
-
if (isNaN(combo[0])) {
|
|
2575
|
-
if (aa > bb) {
|
|
2576
|
-
return 1;
|
|
2577
|
-
}
|
|
2578
|
-
|
|
2579
|
-
if (bb > aa) {
|
|
2580
|
-
return -1;
|
|
2581
|
-
}
|
|
2582
|
-
|
|
2583
|
-
continue;
|
|
2584
|
-
} // One is a string, one is a number
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
if (isNaN(combo[1])) {
|
|
2588
|
-
return isNaN(an) ? -1 : 1;
|
|
2589
|
-
} // Both are numbers
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
if (an > bn) {
|
|
2593
|
-
return 1;
|
|
2594
|
-
}
|
|
2595
|
-
|
|
2596
|
-
if (bn > an) {
|
|
2597
|
-
return -1;
|
|
2598
|
-
}
|
|
2599
|
-
}
|
|
2600
|
-
|
|
2601
|
-
return a.length - b.length;
|
|
2602
|
-
} // The text filter is more basic (less numeric support)
|
|
2603
|
-
// but is much faster
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
function text(rowA, rowB, columnId) {
|
|
2607
|
-
return compareBasic(toString(rowA.values[columnId]).toLowerCase(), toString(rowB.values[columnId]).toLowerCase());
|
|
2608
|
-
} // The text filter is more basic (less numeric support)
|
|
2609
|
-
// but is much faster
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
function textCaseSensitive(rowA, rowB, columnId) {
|
|
2613
|
-
return compareBasic(toString(rowA.values[columnId]), toString(rowB.values[columnId]));
|
|
2614
|
-
}
|
|
2615
|
-
|
|
2616
|
-
function datetime(rowA, rowB, columnId) {
|
|
2617
|
-
return compareBasic(rowA.values[columnId].getTime(), rowB.values[columnId].getTime());
|
|
2618
|
-
}
|
|
2619
|
-
|
|
2620
|
-
function basic(rowA, rowB, columnId) {
|
|
2621
|
-
return compareBasic(rowA.values[columnId], rowB.values[columnId]);
|
|
2622
|
-
} // Utils
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
function compareBasic(a, b) {
|
|
2626
|
-
return a === b ? 0 : a > b ? 1 : -1;
|
|
2627
|
-
}
|
|
2628
|
-
|
|
2629
|
-
function toString(a) {
|
|
2630
|
-
if (typeof a === 'number') {
|
|
2631
|
-
if (isNaN(a) || a === Infinity || a === -Infinity) {
|
|
2632
|
-
return '';
|
|
2633
|
-
}
|
|
2634
|
-
|
|
2635
|
-
return String(a);
|
|
2636
|
-
}
|
|
2637
|
-
|
|
2638
|
-
if (typeof a === 'string') {
|
|
2639
|
-
return a;
|
|
2640
|
-
}
|
|
2641
|
-
|
|
2642
|
-
return '';
|
|
2643
|
-
}
|
|
2644
|
-
|
|
2645
|
-
//
|
|
2646
|
-
function getDefaultColumn() {
|
|
2647
|
-
return {
|
|
2648
|
-
sortType: 'auto'
|
|
2649
|
-
};
|
|
2650
|
-
}
|
|
2651
|
-
function getInitialState$4() {
|
|
2652
|
-
return {
|
|
2653
|
-
sorting: []
|
|
2654
|
-
};
|
|
2655
|
-
}
|
|
2656
|
-
function getDefaultOptions$4(instance) {
|
|
2657
|
-
return {
|
|
2658
|
-
onSortingChange: makeStateUpdater('sorting', instance),
|
|
2659
|
-
autoResetSorting: true,
|
|
2660
|
-
isMultiSortEvent: function isMultiSortEvent(e) {
|
|
2661
|
-
return e.shiftKey;
|
|
2662
|
-
}
|
|
2663
|
-
};
|
|
2664
|
-
}
|
|
2665
|
-
function createColumn$1(column, instance) {
|
|
2666
|
-
return {
|
|
2667
|
-
sortType: column.sortType,
|
|
2668
|
-
getCanSort: function getCanSort() {
|
|
2669
|
-
return instance.getColumnCanSort(column.id);
|
|
2670
|
-
},
|
|
2671
|
-
getCanMultiSort: function getCanMultiSort() {
|
|
2672
|
-
return instance.getColumnCanMultiSort(column.id);
|
|
2673
|
-
},
|
|
2674
|
-
getSortIndex: function getSortIndex() {
|
|
2675
|
-
return instance.getColumnSortIndex(column.id);
|
|
2676
|
-
},
|
|
2677
|
-
getIsSorted: function getIsSorted() {
|
|
2678
|
-
return instance.getColumnIsSorted(column.id);
|
|
2679
|
-
},
|
|
2680
|
-
toggleSorting: function toggleSorting(desc, isMulti) {
|
|
2681
|
-
return instance.toggleColumnSorting(column.id, desc, isMulti);
|
|
2682
|
-
},
|
|
2683
|
-
getToggleSortingProps: function getToggleSortingProps(userProps) {
|
|
2684
|
-
return instance.getToggleSortingProps(column.id, userProps);
|
|
2685
|
-
}
|
|
2686
|
-
};
|
|
2687
|
-
}
|
|
2688
|
-
function getInstance$4(instance) {
|
|
2689
|
-
var registered = false;
|
|
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
|
-
},
|
|
2705
|
-
getColumnAutoSortingFn: function getColumnAutoSortingFn(columnId) {
|
|
2706
|
-
var firstRows = instance.getGlobalFilteredRowModel().flatRows.slice(100);
|
|
2707
|
-
var isString = false;
|
|
2708
|
-
|
|
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
|
-
}
|
|
2724
|
-
}
|
|
2725
|
-
|
|
2726
|
-
if (isString) {
|
|
2727
|
-
return sortTypes.text;
|
|
2728
|
-
}
|
|
2729
|
-
|
|
2730
|
-
return sortTypes.basic;
|
|
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
|
-
},
|
|
2742
|
-
getColumnSortingFn: function getColumnSortingFn(columnId) {
|
|
2743
|
-
var _ref;
|
|
2744
|
-
|
|
2745
|
-
var column = instance.getColumn(columnId);
|
|
2746
|
-
var userSortTypes = instance.options.sortTypes;
|
|
2747
|
-
|
|
2748
|
-
if (!column) {
|
|
2749
|
-
throw new Error();
|
|
2750
|
-
}
|
|
2751
|
-
|
|
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];
|
|
2753
|
-
},
|
|
2754
|
-
setSorting: function setSorting(updater) {
|
|
2755
|
-
return instance.options.onSortingChange == null ? void 0 : instance.options.onSortingChange(updater, functionalUpdate(updater, instance.getState().sorting));
|
|
2756
|
-
},
|
|
2757
|
-
toggleColumnSorting: function toggleColumnSorting(columnId, desc, multi) {
|
|
2758
|
-
var column = instance.getColumn(columnId);
|
|
2759
|
-
|
|
2760
|
-
if (!column) {
|
|
2761
|
-
throw new Error();
|
|
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
|
-
|
|
2771
|
-
|
|
2772
|
-
instance.setSorting(function (old) {
|
|
2773
|
-
var _ref2, _column$sortDescFirst, _instance$options$ena, _instance$options$ena2;
|
|
2774
|
-
|
|
2775
|
-
// Find any existing sorting for this column
|
|
2776
|
-
var existingSorting = old == null ? void 0 : old.find(function (d) {
|
|
2777
|
-
return d.id === columnId;
|
|
2778
|
-
});
|
|
2779
|
-
var existingIndex = old == null ? void 0 : old.findIndex(function (d) {
|
|
2780
|
-
return d.id === columnId;
|
|
2781
|
-
});
|
|
2782
|
-
var hasDescDefined = typeof desc !== 'undefined' && desc !== null;
|
|
2783
|
-
var newSorting = []; // What should we do with this sort action?
|
|
2784
|
-
|
|
2785
|
-
var sortAction;
|
|
2786
|
-
|
|
2787
|
-
if (column.getCanMultiSort() && multi) {
|
|
2788
|
-
if (existingSorting) {
|
|
2789
|
-
sortAction = 'toggle';
|
|
2790
|
-
} else {
|
|
2791
|
-
sortAction = 'add';
|
|
2792
|
-
}
|
|
2793
|
-
} else {
|
|
2794
|
-
// Normal mode
|
|
2795
|
-
if (old != null && old.length && existingIndex !== old.length - 1) {
|
|
2796
|
-
sortAction = 'replace';
|
|
2797
|
-
} else if (existingSorting) {
|
|
2798
|
-
sortAction = 'toggle';
|
|
2799
|
-
} else {
|
|
2800
|
-
sortAction = 'replace';
|
|
2801
|
-
}
|
|
2802
|
-
}
|
|
2803
|
-
|
|
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
|
|
2805
|
-
|
|
2806
|
-
if (sortAction === 'toggle' && ( // Must be toggling
|
|
2807
|
-
(_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
|
|
2808
|
-
!hasDescDefined && ( // Must not be setting desc
|
|
2809
|
-
multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && ( // If multi, don't allow if enableMultiRemove
|
|
2810
|
-
existingSorting != null && existingSorting.desc // Finally, detect if it should indeed be removed
|
|
2811
|
-
? !sortDescFirst : sortDescFirst)) {
|
|
2812
|
-
sortAction = 'remove';
|
|
2813
|
-
}
|
|
2814
|
-
|
|
2815
|
-
if (sortAction === 'replace') {
|
|
2816
|
-
newSorting = [{
|
|
2817
|
-
id: columnId,
|
|
2818
|
-
desc: hasDescDefined ? desc : !!sortDescFirst
|
|
2819
|
-
}];
|
|
2820
|
-
} else if (sortAction === 'add' && old != null && old.length) {
|
|
2821
|
-
var _instance$options$max;
|
|
2822
|
-
|
|
2823
|
-
newSorting = [].concat(old, [{
|
|
2824
|
-
id: columnId,
|
|
2825
|
-
desc: hasDescDefined ? desc : !!sortDescFirst
|
|
2826
|
-
}]); // Take latest n columns
|
|
2827
|
-
|
|
2828
|
-
newSorting.splice(0, newSorting.length - ((_instance$options$max = instance.options.maxMultiSortColCount) != null ? _instance$options$max : Number.MAX_SAFE_INTEGER));
|
|
2829
|
-
} else if (sortAction === 'toggle' && old != null && old.length) {
|
|
2830
|
-
// This flips (or sets) the
|
|
2831
|
-
newSorting = old.map(function (d) {
|
|
2832
|
-
if (d.id === columnId) {
|
|
2833
|
-
return _extends({}, d, {
|
|
2834
|
-
desc: hasDescDefined ? desc : !(existingSorting != null && existingSorting.desc)
|
|
2835
|
-
});
|
|
2836
|
-
}
|
|
2837
|
-
|
|
2838
|
-
return d;
|
|
2839
|
-
});
|
|
2840
|
-
} else if (sortAction === 'remove' && old != null && old.length) {
|
|
2841
|
-
newSorting = old.filter(function (d) {
|
|
2842
|
-
return d.id !== columnId;
|
|
2843
|
-
});
|
|
2844
|
-
}
|
|
2845
|
-
|
|
2846
|
-
return newSorting;
|
|
2847
|
-
});
|
|
2848
|
-
},
|
|
2849
|
-
getColumnCanSort: function getColumnCanSort(columnId) {
|
|
2850
|
-
var _ref3, _ref4, _column$enableSorting;
|
|
2851
|
-
|
|
2852
|
-
var column = instance.getColumn(columnId);
|
|
2853
|
-
|
|
2854
|
-
if (!column) {
|
|
2855
|
-
throw new Error();
|
|
2856
|
-
}
|
|
2857
|
-
|
|
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
|
-
;
|
|
2862
|
-
},
|
|
2863
|
-
getColumnCanMultiSort: function getColumnCanMultiSort(columnId) {
|
|
2864
|
-
var _ref5, _column$enableMultiSo;
|
|
2865
|
-
|
|
2866
|
-
var column = instance.getColumn(columnId);
|
|
2867
|
-
|
|
2868
|
-
if (!column) {
|
|
2869
|
-
throw new Error();
|
|
2870
|
-
}
|
|
2871
|
-
|
|
2872
|
-
return (_ref5 = (_column$enableMultiSo = column.enableMultiSort) != null ? _column$enableMultiSo : instance.options.enableMultiSort) != null ? _ref5 : !!column.accessorFn;
|
|
2873
|
-
},
|
|
2874
|
-
getColumnIsSorted: function getColumnIsSorted(columnId) {
|
|
2875
|
-
var _instance$getState$so;
|
|
2876
|
-
|
|
2877
|
-
var columnSort = (_instance$getState$so = instance.getState().sorting) == null ? void 0 : _instance$getState$so.find(function (d) {
|
|
2878
|
-
return d.id === columnId;
|
|
2879
|
-
});
|
|
2880
|
-
return !columnSort ? false : columnSort.desc ? 'desc' : 'asc';
|
|
2881
|
-
},
|
|
2882
|
-
getColumnSortIndex: function getColumnSortIndex(columnId) {
|
|
2883
|
-
var _instance$getState$so2, _instance$getState$so3;
|
|
2884
|
-
|
|
2885
|
-
return (_instance$getState$so2 = (_instance$getState$so3 = instance.getState().sorting) == null ? void 0 : _instance$getState$so3.findIndex(function (d) {
|
|
2886
|
-
return d.id === columnId;
|
|
2887
|
-
})) != null ? _instance$getState$so2 : -1;
|
|
2888
|
-
},
|
|
2889
|
-
resetSorting: function resetSorting() {
|
|
2890
|
-
var _instance$options$ini, _instance$options, _instance$options$ini2;
|
|
2891
|
-
|
|
2892
|
-
instance.setSorting((_instance$options$ini = (_instance$options = instance.options) == null ? void 0 : (_instance$options$ini2 = _instance$options.initialState) == null ? void 0 : _instance$options$ini2.sorting) != null ? _instance$options$ini : []);
|
|
2893
|
-
},
|
|
2894
|
-
getToggleSortingProps: function getToggleSortingProps(columnId, userProps) {
|
|
2895
|
-
var column = instance.getColumn(columnId);
|
|
2896
|
-
|
|
2897
|
-
if (!column) {
|
|
2898
|
-
throw new Error();
|
|
2899
|
-
}
|
|
2900
|
-
|
|
2901
|
-
var canSort = column.getCanSort();
|
|
2902
|
-
var initialProps = {
|
|
2903
|
-
title: canSort ? 'Toggle Sorting' : undefined,
|
|
2904
|
-
onClick: canSort ? function (e) {
|
|
2905
|
-
e.persist();
|
|
2906
|
-
column.toggleSorting == null ? void 0 : column.toggleSorting(undefined, column.getCanMultiSort() ? instance.options.isMultiSortEvent == null ? void 0 : instance.options.isMultiSortEvent(e) : false);
|
|
2907
|
-
} : undefined
|
|
2908
|
-
};
|
|
2909
|
-
return propGetter(initialProps, userProps);
|
|
2910
|
-
},
|
|
2911
|
-
getSortedRowModel: memo(function () {
|
|
2912
|
-
return [instance.getState().sorting, instance.getGlobalFilteredRowModel(), instance.options.sortRowsFn];
|
|
2913
|
-
}, function (sorting, rowModel, sortingFn) {
|
|
2914
|
-
if (!sortingFn || !(sorting != null && sorting.length)) {
|
|
2915
|
-
return rowModel;
|
|
2916
|
-
}
|
|
2917
|
-
|
|
2918
|
-
if (instance.options.debug) console.info('Sorting...');
|
|
2919
|
-
return sortingFn(instance, rowModel);
|
|
2920
|
-
}, {
|
|
2921
|
-
key: 'getSortedRowModel',
|
|
2922
|
-
debug: instance.options.debug,
|
|
2923
|
-
onChange: function onChange() {
|
|
2924
|
-
return instance._notifyGroupingReset();
|
|
2925
|
-
}
|
|
2926
|
-
}),
|
|
2927
|
-
getPreSortedRows: function getPreSortedRows() {
|
|
2928
|
-
return instance.getGlobalFilteredRowModel().rows;
|
|
2929
|
-
},
|
|
2930
|
-
getPreSortedFlatRows: function getPreSortedFlatRows() {
|
|
2931
|
-
return instance.getGlobalFilteredRowModel().flatRows;
|
|
2932
|
-
},
|
|
2933
|
-
getPreSortedRowsById: function getPreSortedRowsById() {
|
|
2934
|
-
return instance.getGlobalFilteredRowModel().rowsById;
|
|
2935
|
-
},
|
|
2936
|
-
getSortedRows: function getSortedRows() {
|
|
2937
|
-
return instance.getSortedRowModel().rows;
|
|
2938
|
-
},
|
|
2939
|
-
getSortedFlatRows: function getSortedFlatRows() {
|
|
2940
|
-
return instance.getSortedRowModel().flatRows;
|
|
2941
|
-
},
|
|
2942
|
-
getSortedRowsById: function getSortedRowsById() {
|
|
2943
|
-
return instance.getSortedRowModel().rowsById;
|
|
2944
|
-
}
|
|
2945
|
-
};
|
|
2946
|
-
}
|
|
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
|
-
|
|
2957
|
-
//
|
|
2958
|
-
function getInitialState$3() {
|
|
2959
|
-
return {
|
|
2960
|
-
expanded: {}
|
|
2961
|
-
};
|
|
2962
|
-
}
|
|
2963
|
-
function getDefaultOptions$3(instance) {
|
|
2964
|
-
return {
|
|
2965
|
-
onExpandedChange: makeStateUpdater('expanded', instance),
|
|
2966
|
-
autoResetExpanded: true,
|
|
2967
|
-
getIsRowExpanded: function getIsRowExpanded(row) {
|
|
2968
|
-
return !!(row == null ? void 0 : row.original).expanded;
|
|
2969
|
-
},
|
|
2970
|
-
expandSubRows: true,
|
|
2971
|
-
paginateExpandedRows: true
|
|
2972
|
-
};
|
|
2973
|
-
}
|
|
2974
|
-
function getInstance$3(instance) {
|
|
2975
|
-
var registered = false;
|
|
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
|
-
},
|
|
2991
|
-
setExpanded: function setExpanded(updater) {
|
|
2992
|
-
return instance.options.onExpandedChange == null ? void 0 : instance.options.onExpandedChange(updater, functionalUpdate(updater, instance.getState().expanded));
|
|
2993
|
-
},
|
|
2994
|
-
toggleRowExpanded: function toggleRowExpanded(rowId, expanded) {
|
|
2995
|
-
if (!rowId) return;
|
|
2996
|
-
instance.setExpanded(function (old) {
|
|
2997
|
-
var _old, _expanded;
|
|
2998
|
-
|
|
2999
|
-
if (old === void 0) {
|
|
3000
|
-
old = {};
|
|
3001
|
-
}
|
|
3002
|
-
|
|
3003
|
-
var exists = old === true ? true : !!((_old = old) != null && _old[rowId]);
|
|
3004
|
-
var oldExpanded = {};
|
|
3005
|
-
|
|
3006
|
-
if (old === true) {
|
|
3007
|
-
Object.keys(instance.getRowsById()).forEach(function (rowId) {
|
|
3008
|
-
oldExpanded[rowId] = true;
|
|
3009
|
-
});
|
|
3010
|
-
} else {
|
|
3011
|
-
oldExpanded = old;
|
|
3012
|
-
}
|
|
3013
|
-
|
|
3014
|
-
expanded = (_expanded = expanded) != null ? _expanded : !exists;
|
|
3015
|
-
|
|
3016
|
-
if (!exists && expanded) {
|
|
3017
|
-
var _extends2;
|
|
3018
|
-
|
|
3019
|
-
return _extends({}, oldExpanded, (_extends2 = {}, _extends2[rowId] = true, _extends2));
|
|
3020
|
-
}
|
|
3021
|
-
|
|
3022
|
-
if (exists && !expanded) {
|
|
3023
|
-
var _oldExpanded = oldExpanded;
|
|
3024
|
-
_oldExpanded[rowId];
|
|
3025
|
-
var rest = _objectWithoutPropertiesLoose(_oldExpanded, [rowId].map(_toPropertyKey));
|
|
3026
|
-
|
|
3027
|
-
return rest;
|
|
3028
|
-
}
|
|
3029
|
-
|
|
3030
|
-
return old;
|
|
3031
|
-
});
|
|
3032
|
-
},
|
|
3033
|
-
toggleAllRowsExpanded: function toggleAllRowsExpanded(expanded) {
|
|
3034
|
-
if (expanded != null ? expanded : !instance.getIsAllRowsExpanded()) {
|
|
3035
|
-
instance.setExpanded(true);
|
|
3036
|
-
} else {
|
|
3037
|
-
instance.setExpanded({});
|
|
3038
|
-
}
|
|
3039
|
-
},
|
|
3040
|
-
resetExpanded: function resetExpanded() {
|
|
3041
|
-
var _instance$options$ini, _instance$options, _instance$options$ini2;
|
|
3042
|
-
|
|
3043
|
-
instance.setExpanded((_instance$options$ini = (_instance$options = instance.options) == null ? void 0 : (_instance$options$ini2 = _instance$options.initialState) == null ? void 0 : _instance$options$ini2.expanded) != null ? _instance$options$ini : {});
|
|
3044
|
-
},
|
|
3045
|
-
getIsRowExpanded: function getIsRowExpanded(rowId) {
|
|
3046
|
-
var _instance$options$get;
|
|
3047
|
-
|
|
3048
|
-
var row = instance.getRow(rowId);
|
|
3049
|
-
|
|
3050
|
-
if (!row) {
|
|
3051
|
-
{
|
|
3052
|
-
console.warn("[ReactTable] getIsRowExpanded: no row found with id " + rowId);
|
|
3053
|
-
}
|
|
3054
|
-
|
|
3055
|
-
throw new Error();
|
|
3056
|
-
}
|
|
3057
|
-
|
|
3058
|
-
var expanded = instance.getState().expanded;
|
|
3059
|
-
return !!((_instance$options$get = instance.options.getIsRowExpanded == null ? void 0 : instance.options.getIsRowExpanded(row)) != null ? _instance$options$get : expanded || (expanded == null ? void 0 : expanded[rowId]));
|
|
3060
|
-
},
|
|
3061
|
-
getRowCanExpand: function getRowCanExpand(rowId) {
|
|
3062
|
-
var _ref, _ref2, _instance$options$get2, _row$subRows;
|
|
3063
|
-
|
|
3064
|
-
var row = instance.getRow(rowId);
|
|
3065
|
-
|
|
3066
|
-
if (!row) {
|
|
3067
|
-
{
|
|
3068
|
-
console.warn("[ReactTable] getRowCanExpand: no row found with id " + rowId);
|
|
3069
|
-
}
|
|
3070
|
-
|
|
3071
|
-
throw new Error();
|
|
3072
|
-
}
|
|
3073
|
-
|
|
3074
|
-
return (_ref = (_ref2 = (_instance$options$get2 = instance.options.getRowCanExpand == null ? void 0 : instance.options.getRowCanExpand(row)) != null ? _instance$options$get2 : instance.options.enableExpanded) != null ? _ref2 : instance.options.defaultCanExpand) != null ? _ref : !!((_row$subRows = row.subRows) != null && _row$subRows.length);
|
|
3075
|
-
},
|
|
3076
|
-
getToggleExpandedProps: function getToggleExpandedProps(rowId, userProps) {
|
|
3077
|
-
var row = instance.getRow(rowId);
|
|
3078
|
-
|
|
3079
|
-
if (!row) {
|
|
3080
|
-
return;
|
|
3081
|
-
}
|
|
3082
|
-
|
|
3083
|
-
var canExpand = instance.getRowCanExpand(rowId);
|
|
3084
|
-
var initialProps = {
|
|
3085
|
-
title: canExpand ? 'Toggle Expanded' : undefined,
|
|
3086
|
-
onClick: canExpand ? function (e) {
|
|
3087
|
-
e.persist();
|
|
3088
|
-
instance.toggleRowExpanded(rowId);
|
|
3089
|
-
} : undefined
|
|
3090
|
-
};
|
|
3091
|
-
return propGetter(initialProps, userProps);
|
|
3092
|
-
},
|
|
3093
|
-
getToggleAllRowsExpandedProps: function getToggleAllRowsExpandedProps(userProps) {
|
|
3094
|
-
var initialProps = {
|
|
3095
|
-
title: 'Toggle All Expanded',
|
|
3096
|
-
onClick: function onClick(e) {
|
|
3097
|
-
e.persist();
|
|
3098
|
-
instance.toggleAllRowsExpanded();
|
|
3099
|
-
}
|
|
3100
|
-
};
|
|
3101
|
-
return propGetter(initialProps, userProps);
|
|
3102
|
-
},
|
|
3103
|
-
getIsAllRowsExpanded: function getIsAllRowsExpanded() {
|
|
3104
|
-
var expanded = instance.getState().expanded; // If expanded is true, save some cycles and return true
|
|
3105
|
-
|
|
3106
|
-
if (expanded === true) {
|
|
3107
|
-
return true;
|
|
3108
|
-
} // If any row is not expanded, return false
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
if (Object.keys(instance.getRowsById()).some(function (id) {
|
|
3112
|
-
return !instance.getIsRowExpanded(id);
|
|
3113
|
-
})) {
|
|
3114
|
-
return false;
|
|
3115
|
-
} // They must all be expanded :shrug:
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
return true;
|
|
3119
|
-
},
|
|
3120
|
-
getExpandedDepth: function getExpandedDepth() {
|
|
3121
|
-
var maxDepth = 0;
|
|
3122
|
-
var rowIds = instance.getState().expanded === true ? Object.keys(instance.getRowsById()) : Object.keys(instance.getState().expanded);
|
|
3123
|
-
rowIds.forEach(function (id) {
|
|
3124
|
-
var splitId = id.split('.');
|
|
3125
|
-
maxDepth = Math.max(maxDepth, splitId.length);
|
|
3126
|
-
});
|
|
3127
|
-
return maxDepth;
|
|
3128
|
-
},
|
|
3129
|
-
getExpandedRowModel: memo(function () {
|
|
3130
|
-
return [instance.getState().expanded, instance.getGroupedRowModel(), instance.options.expandRowsFn, instance.options.paginateExpandedRows];
|
|
3131
|
-
}, function (expanded, rowModel, expandRowsFn, paginateExpandedRows) {
|
|
3132
|
-
if (!expandRowsFn || // Do not expand if rows are not included in pagination
|
|
3133
|
-
!paginateExpandedRows || !Object.keys(expanded != null ? expanded : {}).length) {
|
|
3134
|
-
return rowModel;
|
|
3135
|
-
}
|
|
3136
|
-
|
|
3137
|
-
if (instance.options.debug) console.info('Expanding...');
|
|
3138
|
-
return expandRowsFn(instance, rowModel);
|
|
3139
|
-
}, {
|
|
3140
|
-
key: 'getExpandedRowModel',
|
|
3141
|
-
debug: instance.options.debug,
|
|
3142
|
-
onChange: function onChange() {
|
|
3143
|
-
return instance._notifyPageIndexReset();
|
|
3144
|
-
}
|
|
3145
|
-
}),
|
|
3146
|
-
getPreExpandedRows: function getPreExpandedRows() {
|
|
3147
|
-
return instance.getGroupedRowModel().rows;
|
|
3148
|
-
},
|
|
3149
|
-
getPreExpandedFlatRows: function getPreExpandedFlatRows() {
|
|
3150
|
-
return instance.getGroupedRowModel().flatRows;
|
|
3151
|
-
},
|
|
3152
|
-
getPreExpandedRowsById: function getPreExpandedRowsById() {
|
|
3153
|
-
return instance.getGroupedRowModel().rowsById;
|
|
3154
|
-
},
|
|
3155
|
-
getExpandedRows: function getExpandedRows() {
|
|
3156
|
-
return instance.getExpandedRowModel().rows;
|
|
3157
|
-
},
|
|
3158
|
-
getExpandedFlatRows: function getExpandedFlatRows() {
|
|
3159
|
-
return instance.getExpandedRowModel().flatRows;
|
|
3160
|
-
},
|
|
3161
|
-
getExpandedRowsById: function getExpandedRowsById() {
|
|
3162
|
-
return instance.getExpandedRowModel().rowsById;
|
|
3163
|
-
}
|
|
3164
|
-
};
|
|
3165
|
-
}
|
|
3166
|
-
function createRow$1(row, instance) {
|
|
3167
|
-
return {
|
|
3168
|
-
toggleExpanded: function toggleExpanded(expanded) {
|
|
3169
|
-
return void instance.toggleRowExpanded(row.id, expanded);
|
|
3170
|
-
},
|
|
3171
|
-
getIsExpanded: function getIsExpanded() {
|
|
3172
|
-
return instance.getIsRowExpanded(row.id);
|
|
3173
|
-
},
|
|
3174
|
-
getCanExpand: function getCanExpand() {
|
|
3175
|
-
return row.subRows && !!row.subRows.length;
|
|
3176
|
-
},
|
|
3177
|
-
getToggleExpandedProps: function getToggleExpandedProps(userProps) {
|
|
3178
|
-
var initialProps = {
|
|
3179
|
-
title: 'Toggle Row Expanded',
|
|
3180
|
-
onClick: function onClick(e) {
|
|
3181
|
-
e.stopPropagation();
|
|
3182
|
-
instance.toggleRowExpanded(row.id);
|
|
3183
|
-
}
|
|
3184
|
-
};
|
|
3185
|
-
return propGetter(initialProps, userProps);
|
|
3186
|
-
}
|
|
3187
|
-
};
|
|
3188
|
-
}
|
|
3189
|
-
|
|
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
|
-
});
|
|
3197
|
-
|
|
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;
|
|
3234
|
-
|
|
3235
|
-
instance.setColumnSizing((_instance$initialStat = instance.initialState.columnSizing) != null ? _instance$initialStat : {});
|
|
3236
|
-
},
|
|
3237
|
-
resetHeaderSizeInfo: function resetHeaderSizeInfo() {
|
|
3238
|
-
var _instance$initialStat2;
|
|
3239
|
-
|
|
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));
|
|
3246
|
-
|
|
3247
|
-
return rest;
|
|
3248
|
-
});
|
|
3249
|
-
},
|
|
3250
|
-
resetHeaderSize: function resetHeaderSize(headerId) {
|
|
3251
|
-
var header = instance.getHeader(headerId);
|
|
3252
|
-
|
|
3253
|
-
if (!header) {
|
|
3254
|
-
return;
|
|
3255
|
-
}
|
|
3256
|
-
|
|
3257
|
-
return instance.resetColumnSize(header.column.id);
|
|
3258
|
-
},
|
|
3259
|
-
getHeaderCanResize: function getHeaderCanResize(headerId) {
|
|
3260
|
-
var header = instance.getHeader(headerId);
|
|
3261
|
-
|
|
3262
|
-
if (!header) {
|
|
3263
|
-
throw new Error();
|
|
3264
|
-
}
|
|
3265
|
-
|
|
3266
|
-
return instance.getColumnCanResize(header.column.id);
|
|
3267
|
-
},
|
|
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;
|
|
3278
|
-
},
|
|
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;
|
|
3287
|
-
},
|
|
3288
|
-
getHeaderIsResizing: function getHeaderIsResizing(headerId) {
|
|
3289
|
-
var header = instance.getHeader(headerId);
|
|
3290
|
-
|
|
3291
|
-
if (!header) {
|
|
3292
|
-
throw new Error();
|
|
3293
|
-
}
|
|
3294
|
-
|
|
3295
|
-
return instance.getColumnIsResizing(header.column.id);
|
|
3296
|
-
},
|
|
3297
|
-
getColumnResizerProps: function getColumnResizerProps(headerId, userProps) {
|
|
3298
|
-
var header = instance.getHeader(headerId);
|
|
3299
|
-
|
|
3300
|
-
if (!header) {
|
|
3301
|
-
return;
|
|
3302
|
-
}
|
|
3303
|
-
|
|
3304
|
-
var column = instance.getColumn(header.column.id);
|
|
3305
|
-
|
|
3306
|
-
if (!column) {
|
|
3307
|
-
return;
|
|
3308
|
-
}
|
|
3309
|
-
|
|
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,
|
|
4292
|
-
value = _ref$value === void 0 ? '' : _ref$value;
|
|
4293
|
-
return typeof value === 'boolean' ? value.toString() : value;
|
|
4294
|
-
}
|
|
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
|
-
}),
|
|
4302
|
-
getColumnDefs: function getColumnDefs() {
|
|
4303
|
-
return instance.options.columns;
|
|
4304
|
-
},
|
|
4305
|
-
createColumn: function createColumn(columnDef, depth, parent) {
|
|
4306
|
-
var _ref2, _columnDef$id;
|
|
4307
|
-
|
|
4308
|
-
var defaultColumn = instance.getDefaultColumn();
|
|
4309
|
-
var id = (_ref2 = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref2 : typeof columnDef.header === 'string' ? columnDef.header : undefined;
|
|
4310
|
-
var accessorFn;
|
|
4311
|
-
|
|
4312
|
-
if (columnDef.accessorFn) {
|
|
4313
|
-
accessorFn = columnDef.accessorFn;
|
|
4314
|
-
} else if (columnDef.accessorKey) {
|
|
4315
|
-
accessorFn = function accessorFn(originalRow) {
|
|
4316
|
-
return originalRow[columnDef.accessorKey];
|
|
4317
|
-
};
|
|
4318
|
-
}
|
|
4319
|
-
|
|
4320
|
-
if (!id) {
|
|
4321
|
-
{
|
|
4322
|
-
throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
|
|
4323
|
-
}
|
|
4324
|
-
}
|
|
4325
|
-
|
|
4326
|
-
var column = _extends({}, defaultColumnSizing, defaultColumn, columnDef, {
|
|
4327
|
-
id: "" + id,
|
|
4328
|
-
accessorFn: accessorFn,
|
|
4329
|
-
parent: parent,
|
|
4330
|
-
depth: depth,
|
|
4331
|
-
columnDef: columnDef,
|
|
4332
|
-
columns: [],
|
|
4333
|
-
getWidth: function getWidth() {
|
|
4334
|
-
return instance.getColumnWidth(column.id);
|
|
4335
|
-
},
|
|
4336
|
-
getFlatColumns: memo(function () {
|
|
4337
|
-
return [true];
|
|
4338
|
-
}, function () {
|
|
4339
|
-
var _column$columns;
|
|
4340
|
-
|
|
4341
|
-
return [column].concat((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(function (d) {
|
|
4342
|
-
return d.getFlatColumns();
|
|
4343
|
-
}));
|
|
4344
|
-
}, {
|
|
4345
|
-
key: 'column.getFlatColumns',
|
|
4346
|
-
debug: instance.options.debug
|
|
4347
|
-
}),
|
|
4348
|
-
getLeafColumns: memo(function () {
|
|
4349
|
-
return [instance.getOrderColumnsFn()];
|
|
4350
|
-
}, function (orderColumns) {
|
|
4351
|
-
var _column$columns2;
|
|
4352
|
-
|
|
4353
|
-
if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
|
|
4354
|
-
var leafColumns = column.columns.flatMap(function (column) {
|
|
4355
|
-
return column.getLeafColumns();
|
|
4356
|
-
});
|
|
4357
|
-
return orderColumns(leafColumns);
|
|
4358
|
-
}
|
|
4359
|
-
|
|
4360
|
-
return [column];
|
|
4361
|
-
}, {
|
|
4362
|
-
key: 'column.getLeafColumns',
|
|
4363
|
-
debug: instance.options.debug
|
|
4364
|
-
})
|
|
4365
|
-
});
|
|
4366
|
-
|
|
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.
|
|
4370
|
-
|
|
4371
|
-
return column;
|
|
4372
|
-
},
|
|
4373
|
-
getAllColumns: memo(function () {
|
|
4374
|
-
return [instance.getColumnDefs()];
|
|
4375
|
-
}, function (columnDefs) {
|
|
4376
|
-
if (instance.options.debug) console.info('Building Columns...');
|
|
4377
|
-
|
|
4378
|
-
var recurseColumns = function recurseColumns(columnDefs, parent, depth) {
|
|
4379
|
-
if (depth === void 0) {
|
|
4380
|
-
depth = 0;
|
|
4381
|
-
}
|
|
4382
|
-
|
|
4383
|
-
return columnDefs.map(function (columnDef) {
|
|
4384
|
-
var column = instance.createColumn(columnDef, depth, parent);
|
|
4385
|
-
column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
|
|
4386
|
-
return column;
|
|
4387
|
-
});
|
|
4388
|
-
};
|
|
4389
|
-
|
|
4390
|
-
return recurseColumns(columnDefs);
|
|
4391
|
-
}, {
|
|
4392
|
-
key: 'getAllColumns',
|
|
4393
|
-
debug: instance.options.debug
|
|
4394
|
-
}),
|
|
4395
|
-
getAllFlatColumns: memo(function () {
|
|
4396
|
-
return [instance.getAllColumns()];
|
|
4397
|
-
}, function (allColumns) {
|
|
4398
|
-
return allColumns.flatMap(function (column) {
|
|
4399
|
-
return column.getFlatColumns();
|
|
4400
|
-
});
|
|
4401
|
-
}, {
|
|
4402
|
-
key: 'getAllFlatColumns',
|
|
4403
|
-
debug: instance.options.debug
|
|
4404
|
-
}),
|
|
4405
|
-
getAllFlatColumnsById: memo(function () {
|
|
4406
|
-
return [instance.getAllFlatColumns()];
|
|
4407
|
-
}, function (flatColumns) {
|
|
4408
|
-
return flatColumns.reduce(function (acc, column) {
|
|
4409
|
-
acc[column.id] = column;
|
|
4410
|
-
return acc;
|
|
4411
|
-
}, {});
|
|
4412
|
-
}, {
|
|
4413
|
-
key: 'getAllFlatColumnsById',
|
|
4414
|
-
debug: instance.options.debug
|
|
4415
|
-
}),
|
|
4416
|
-
getAllLeafColumns: memo(function () {
|
|
4417
|
-
return [instance.getAllColumns(), instance.getOrderColumnsFn()];
|
|
4418
|
-
}, function (allColumns, orderColumns) {
|
|
4419
|
-
var leafColumns = allColumns.flatMap(function (column) {
|
|
4420
|
-
return column.getLeafColumns();
|
|
4421
|
-
});
|
|
4422
|
-
return orderColumns(leafColumns);
|
|
4423
|
-
}, {
|
|
4424
|
-
key: 'getAllLeafColumns',
|
|
4425
|
-
debug: instance.options.debug
|
|
4426
|
-
}),
|
|
4427
|
-
getColumn: function getColumn(columnId) {
|
|
4428
|
-
var column = instance.getAllFlatColumnsById()[columnId];
|
|
4429
|
-
|
|
4430
|
-
if (!column) {
|
|
4431
|
-
{
|
|
4432
|
-
console.warn("[React Table] Column with id " + columnId + " does not exist.");
|
|
4433
|
-
}
|
|
4434
|
-
|
|
4435
|
-
throw new Error();
|
|
4436
|
-
}
|
|
4437
|
-
|
|
4438
|
-
return column;
|
|
4439
|
-
},
|
|
4440
|
-
getColumnWidth: function getColumnWidth(columnId) {
|
|
4441
|
-
var _column$minWidth, _ref3, _column$maxWidth;
|
|
4442
|
-
|
|
4443
|
-
var column = instance.getColumn(columnId);
|
|
4444
|
-
|
|
4445
|
-
if (!column) {
|
|
4446
|
-
throw new Error();
|
|
4447
|
-
}
|
|
4448
|
-
|
|
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);
|
|
4451
|
-
},
|
|
4452
|
-
createCell: function createCell(row, column, value) {
|
|
4453
|
-
var cell = {
|
|
4454
|
-
id: row.id + "_" + column.id,
|
|
4455
|
-
rowId: row.id,
|
|
4456
|
-
columnId: column.id,
|
|
4457
|
-
row: row,
|
|
4458
|
-
column: column,
|
|
4459
|
-
value: value,
|
|
4460
|
-
getCellProps: function getCellProps(userProps) {
|
|
4461
|
-
return instance.getCellProps(row.id, column.id, userProps);
|
|
4462
|
-
},
|
|
4463
|
-
renderCell: function renderCell() {
|
|
4464
|
-
return flexRender(column.cell, {
|
|
4465
|
-
instance: instance,
|
|
4466
|
-
column: column,
|
|
4467
|
-
row: row,
|
|
4468
|
-
cell: cell,
|
|
4469
|
-
value: value
|
|
4470
|
-
});
|
|
4471
|
-
}
|
|
4472
|
-
};
|
|
4473
|
-
features.forEach(function (feature) {
|
|
4474
|
-
Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
|
|
4475
|
-
}, {});
|
|
4476
|
-
return cell;
|
|
4477
|
-
},
|
|
4478
|
-
createRow: function createRow(id, original, rowIndex, depth, values) {
|
|
4479
|
-
var row = {
|
|
4480
|
-
id: id,
|
|
4481
|
-
index: rowIndex,
|
|
4482
|
-
original: original,
|
|
4483
|
-
depth: depth,
|
|
4484
|
-
values: values,
|
|
4485
|
-
subRows: [],
|
|
4486
|
-
leafRows: [],
|
|
4487
|
-
getRowProps: function getRowProps(userProps) {
|
|
4488
|
-
return instance.getRowProps(row.id, userProps);
|
|
4489
|
-
},
|
|
4490
|
-
getAllCells: undefined,
|
|
4491
|
-
getAllCellsByColumnId: undefined
|
|
4492
|
-
};
|
|
4493
|
-
row.getAllCells = memo(function () {
|
|
4494
|
-
return [instance.getAllLeafColumns()];
|
|
4495
|
-
}, function (leafColumns) {
|
|
4496
|
-
return leafColumns.map(function (column) {
|
|
4497
|
-
return instance.createCell(row, column, row.values[column.id]);
|
|
4498
|
-
});
|
|
4499
|
-
}, {
|
|
4500
|
-
key: 'row.getAllCells' ,
|
|
4501
|
-
debug: instance.options.debug
|
|
4502
|
-
});
|
|
4503
|
-
row.getAllCellsByColumnId = memo(function () {
|
|
4504
|
-
return [row.getAllCells()];
|
|
4505
|
-
}, function (allCells) {
|
|
4506
|
-
return allCells.reduce(function (acc, cell) {
|
|
4507
|
-
acc[cell.columnId] = cell;
|
|
4508
|
-
return acc;
|
|
4509
|
-
}, {});
|
|
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
|
-
});
|
|
4517
|
-
return row;
|
|
4518
|
-
},
|
|
4519
|
-
getCoreRowModel: memo(function () {
|
|
4520
|
-
return [instance.options.data];
|
|
4521
|
-
}, function (data) {
|
|
4522
|
-
if (instance.options.debug) console.info('Accessing...'); // Access the row model using initial columns
|
|
4523
|
-
|
|
4524
|
-
var rows = [];
|
|
4525
|
-
var flatRows = [];
|
|
4526
|
-
var rowsById = {};
|
|
4527
|
-
var leafColumns = instance.getAllLeafColumns();
|
|
4528
|
-
|
|
4529
|
-
var accessRow = function accessRow(originalRow, rowIndex, depth, parentRows, parent) {
|
|
4530
|
-
if (depth === void 0) {
|
|
4531
|
-
depth = 0;
|
|
4532
|
-
}
|
|
4533
|
-
|
|
4534
|
-
var id = instance.getRowId(originalRow, rowIndex, parent);
|
|
4535
|
-
|
|
4536
|
-
if (!id) {
|
|
4537
|
-
{
|
|
4538
|
-
throw new Error("getRowId expected an ID, but got " + id);
|
|
4539
|
-
}
|
|
4540
|
-
}
|
|
4541
|
-
|
|
4542
|
-
var values = {};
|
|
4543
|
-
|
|
4544
|
-
for (var i = 0; i < leafColumns.length; i++) {
|
|
4545
|
-
var _column = leafColumns[i];
|
|
4546
|
-
|
|
4547
|
-
if (_column && _column.accessorFn) {
|
|
4548
|
-
values[_column.id] = _column.accessorFn(originalRow, rowIndex);
|
|
4549
|
-
}
|
|
4550
|
-
} // Make the row
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
var row = instance.createRow(id, originalRow, rowIndex, depth, values); // Push instance row into the parentRows array
|
|
4554
|
-
|
|
4555
|
-
parentRows.push(row); // Keep track of every row in a flat array
|
|
4556
|
-
|
|
4557
|
-
flatRows.push(row); // Also keep track of every row by its ID
|
|
4558
|
-
|
|
4559
|
-
rowsById[id] = row; // Get the original subrows
|
|
4560
|
-
|
|
4561
|
-
if (instance.options.getSubRows) {
|
|
4562
|
-
var originalSubRows = instance.options.getSubRows(originalRow, rowIndex); // Then recursively access them
|
|
4563
|
-
|
|
4564
|
-
if (originalSubRows != null && originalSubRows.length) {
|
|
4565
|
-
row.originalSubRows = originalSubRows;
|
|
4566
|
-
var subRows = [];
|
|
4567
|
-
|
|
4568
|
-
for (var _i = 0; _i < row.originalSubRows.length; _i++) {
|
|
4569
|
-
accessRow(row.originalSubRows[_i], _i, depth + 1, subRows, row);
|
|
4570
|
-
} // Keep the new subRows array on the row
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
row.subRows = subRows;
|
|
4574
|
-
row.leafRows = flattenBy(subRows, function (d) {
|
|
4575
|
-
return d.leafRows;
|
|
4576
|
-
});
|
|
4577
|
-
}
|
|
4578
|
-
}
|
|
4579
|
-
};
|
|
4580
|
-
|
|
4581
|
-
for (var i = 0; i < data.length; i++) {
|
|
4582
|
-
accessRow(data[i], i, 0, rows);
|
|
4583
|
-
}
|
|
4584
|
-
|
|
4585
|
-
return {
|
|
4586
|
-
rows: rows,
|
|
4587
|
-
flatRows: flatRows,
|
|
4588
|
-
rowsById: rowsById
|
|
4589
|
-
};
|
|
4590
|
-
}, {
|
|
4591
|
-
key: 'getRowModel',
|
|
4592
|
-
debug: instance.options.debug,
|
|
4593
|
-
onChange: function onChange() {
|
|
4594
|
-
instance._notifyRowSelectionReset();
|
|
4595
|
-
|
|
4596
|
-
instance._notifyFiltersReset();
|
|
4597
|
-
}
|
|
4598
|
-
}),
|
|
4599
|
-
// The standard
|
|
4600
|
-
getCoreRows: function getCoreRows() {
|
|
4601
|
-
return instance.getCoreRowModel().rows;
|
|
4602
|
-
},
|
|
4603
|
-
getCoreFlatRows: function getCoreFlatRows() {
|
|
4604
|
-
return instance.getCoreRowModel().flatRows;
|
|
4605
|
-
},
|
|
4606
|
-
getCoreRowsById: function getCoreRowsById() {
|
|
4607
|
-
return instance.getCoreRowModel().rowsById;
|
|
4608
|
-
},
|
|
4609
|
-
// The final calls start at the bottom of the model,
|
|
4610
|
-
// expanded rows, which then work their way up
|
|
4611
|
-
getRowModel: function getRowModel() {
|
|
4612
|
-
return instance.getPaginationRowModel();
|
|
4613
|
-
},
|
|
4614
|
-
getRows: function getRows() {
|
|
4615
|
-
return instance.getRowModel().rows;
|
|
4616
|
-
},
|
|
4617
|
-
getFlatRows: function getFlatRows() {
|
|
4618
|
-
return instance.getRowModel().flatRows;
|
|
4619
|
-
},
|
|
4620
|
-
getRowsById: function getRowsById() {
|
|
4621
|
-
return instance.getRowModel().rowsById;
|
|
4622
|
-
},
|
|
4623
|
-
getRow: function getRow(id) {
|
|
4624
|
-
var row = instance.getRowsById()[id];
|
|
4625
|
-
|
|
4626
|
-
if (!row) {
|
|
4627
|
-
{
|
|
4628
|
-
throw new Error("getRow expected an ID, but got " + id);
|
|
4629
|
-
}
|
|
4630
|
-
}
|
|
4631
|
-
|
|
4632
|
-
return row;
|
|
4633
|
-
},
|
|
4634
|
-
getCell: function getCell(rowId, columnId) {
|
|
4635
|
-
var row = instance.getRow(rowId);
|
|
4636
|
-
|
|
4637
|
-
if (!row) {
|
|
4638
|
-
{
|
|
4639
|
-
throw new Error("[React Table] could not find row with id " + rowId);
|
|
4640
|
-
}
|
|
4641
|
-
}
|
|
4642
|
-
|
|
4643
|
-
var cell = row.getAllCellsByColumnId()[columnId];
|
|
4644
|
-
|
|
4645
|
-
if (!cell) {
|
|
4646
|
-
{
|
|
4647
|
-
throw new Error("[React Table] could not find cell " + columnId + " in row " + rowId);
|
|
4648
|
-
}
|
|
4649
|
-
}
|
|
4650
|
-
|
|
4651
|
-
return cell;
|
|
4652
|
-
},
|
|
4653
|
-
getTableProps: function getTableProps(userProps) {
|
|
4654
|
-
return propGetter({
|
|
4655
|
-
role: 'table'
|
|
4656
|
-
}, userProps);
|
|
4657
|
-
},
|
|
4658
|
-
getTableBodyProps: function getTableBodyProps(userProps) {
|
|
4659
|
-
return propGetter({
|
|
4660
|
-
role: 'rowgroup'
|
|
4661
|
-
}, userProps);
|
|
4662
|
-
},
|
|
4663
|
-
getRowProps: function getRowProps(rowId, userProps) {
|
|
4664
|
-
var row = instance.getRow(rowId);
|
|
4665
|
-
|
|
4666
|
-
if (!row) {
|
|
4667
|
-
return;
|
|
4668
|
-
}
|
|
4669
|
-
|
|
4670
|
-
return propGetter({
|
|
4671
|
-
key: row.id,
|
|
4672
|
-
role: 'row'
|
|
4673
|
-
}, userProps);
|
|
4674
|
-
},
|
|
4675
|
-
getCellProps: function getCellProps(rowId, columnId, userProps) {
|
|
4676
|
-
var cell = instance.getCell(rowId, columnId);
|
|
4677
|
-
|
|
4678
|
-
if (!cell) {
|
|
4679
|
-
return;
|
|
4680
|
-
}
|
|
4681
|
-
|
|
4682
|
-
return propGetter({
|
|
4683
|
-
key: cell.id,
|
|
4684
|
-
role: 'gridcell'
|
|
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;
|
|
4714
|
-
}
|
|
4715
|
-
});
|
|
4716
|
-
|
|
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;
|
|
4724
|
-
}
|
|
4725
|
-
|
|
4726
|
-
function createTable() {
|
|
4727
|
-
return {
|
|
4728
|
-
RowType: function RowType() {
|
|
4729
|
-
return createTable();
|
|
4730
|
-
},
|
|
4731
|
-
FilterFns: function FilterFns() {
|
|
4732
|
-
return createTable();
|
|
4733
|
-
},
|
|
4734
|
-
SortingFns: function SortingFns() {
|
|
4735
|
-
return createTable();
|
|
4736
|
-
},
|
|
4737
|
-
AggregationFns: function AggregationFns() {
|
|
4738
|
-
return createTable();
|
|
4739
|
-
},
|
|
4740
|
-
createColumns: function createColumns(columns) {
|
|
4741
|
-
return columns;
|
|
4742
|
-
},
|
|
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) {
|
|
4754
|
-
column = _extends({}, column, {
|
|
4755
|
-
id: column.id
|
|
4756
|
-
});
|
|
4757
|
-
|
|
4758
|
-
if (typeof accessor === 'string') {
|
|
4759
|
-
var _column$id;
|
|
4760
|
-
|
|
4761
|
-
return _extends({}, column, {
|
|
4762
|
-
id: (_column$id = column.id) != null ? _column$id : accessor,
|
|
4763
|
-
accessorKey: accessor,
|
|
4764
|
-
__generated: true
|
|
4765
|
-
});
|
|
4766
|
-
}
|
|
4767
|
-
|
|
4768
|
-
if (typeof accessor === 'function') {
|
|
4769
|
-
return _extends({}, column, {
|
|
4770
|
-
accessorFn: accessor,
|
|
4771
|
-
__generated: true
|
|
4772
|
-
});
|
|
4773
|
-
}
|
|
4774
|
-
|
|
4775
|
-
throw new Error('Invalid accessor');
|
|
4776
|
-
},
|
|
4777
|
-
useTable: function useTable(options) {
|
|
4778
|
-
var instanceRef = React__namespace.useRef(undefined);
|
|
4779
|
-
var rerender = React__namespace.useReducer(function () {
|
|
4780
|
-
return {};
|
|
4781
|
-
}, {})[1];
|
|
4782
|
-
|
|
4783
|
-
if (!instanceRef.current) {
|
|
4784
|
-
instanceRef.current = createTableInstance(options, rerender);
|
|
4785
|
-
}
|
|
4786
|
-
|
|
4787
|
-
instanceRef.current.updateOptions(options);
|
|
4788
|
-
return instanceRef.current;
|
|
4789
|
-
},
|
|
4790
|
-
types: undefined
|
|
4791
|
-
};
|
|
4792
|
-
}
|
|
4793
|
-
|
|
4794
|
-
exports.columnFilterRowsFn = columnFilterRowsFn;
|
|
4795
|
-
exports.createTable = createTable;
|
|
4796
|
-
exports.expandRowsFn = expandRowsFn;
|
|
4797
|
-
exports.globalFilterRowsFn = globalFilterRowsFn;
|
|
4798
|
-
exports.groupRowsFn = groupRowsFn;
|
|
4799
|
-
exports.paginateRowsFn = paginateRowsFn;
|
|
4800
|
-
exports.sortRowsFn = sortRowsFn;
|
|
4801
|
-
|
|
4802
134
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4803
135
|
|
|
4804
136
|
}));
|