@tanstack/table-core 8.5.13 → 8.5.16
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/aggregationFns.js +0 -15
- package/build/cjs/aggregationFns.js.map +1 -1
- package/build/cjs/columnHelper.js +10 -2
- package/build/cjs/columnHelper.js.map +1 -1
- package/build/cjs/core/cell.js +2 -9
- package/build/cjs/core/cell.js.map +1 -1
- package/build/cjs/core/column.js +9 -27
- package/build/cjs/core/column.js.map +1 -1
- package/build/cjs/core/headers.js +45 -129
- package/build/cjs/core/headers.js.map +1 -1
- package/build/cjs/core/row.js +4 -21
- package/build/cjs/core/row.js.map +1 -1
- package/build/cjs/core/table.js +26 -73
- package/build/cjs/core/table.js.map +1 -1
- package/build/cjs/features/ColumnSizing.js +56 -67
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Expanding.js +18 -34
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js +19 -55
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +9 -26
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Ordering.js +14 -13
- package/build/cjs/features/Ordering.js.map +1 -1
- package/build/cjs/features/Pagination.js +20 -43
- package/build/cjs/features/Pagination.js.map +1 -1
- package/build/cjs/features/Pinning.js +26 -66
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js +44 -74
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Sorting.js +25 -50
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +14 -32
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/filterFns.js +3 -28
- package/build/cjs/filterFns.js.map +1 -1
- package/build/cjs/sortingFns.js +24 -31
- package/build/cjs/sortingFns.js.map +1 -1
- package/build/cjs/utils/filterRowsUtils.js +7 -19
- package/build/cjs/utils/filterRowsUtils.js.map +1 -1
- package/build/cjs/utils/getCoreRowModel.js +12 -18
- package/build/cjs/utils/getCoreRowModel.js.map +1 -1
- package/build/cjs/utils/getExpandedRowModel.js +2 -12
- package/build/cjs/utils/getExpandedRowModel.js.map +1 -1
- package/build/cjs/utils/getFacetedMinMaxValues.js +1 -11
- package/build/cjs/utils/getFacetedMinMaxValues.js.map +1 -1
- package/build/cjs/utils/getFacetedRowModel.js +1 -9
- package/build/cjs/utils/getFacetedRowModel.js.map +1 -1
- package/build/cjs/utils/getFacetedUniqueValues.js +2 -12
- package/build/cjs/utils/getFacetedUniqueValues.js.map +1 -1
- package/build/cjs/utils/getFilteredRowModel.js +14 -34
- package/build/cjs/utils/getFilteredRowModel.js.map +1 -1
- package/build/cjs/utils/getGroupedRowModel.js +25 -35
- package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
- package/build/cjs/utils/getPaginationRowModel.js +1 -11
- package/build/cjs/utils/getPaginationRowModel.js.map +1 -1
- package/build/cjs/utils/getSortedRowModel.js +8 -23
- package/build/cjs/utils/getSortedRowModel.js.map +1 -1
- package/build/cjs/utils.js +11 -14
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +452 -993
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +44 -34
- package/build/stats-react.json +371 -371
- package/build/umd/index.development.js +452 -991
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/features/ColumnSizing.ts +11 -1
- package/src/features/Expanding.ts +1 -1
|
@@ -15,17 +15,22 @@
|
|
|
15
15
|
})(this, (function (exports) { 'use strict';
|
|
16
16
|
|
|
17
17
|
// Is this type a tuple?
|
|
18
|
+
|
|
18
19
|
// If this type is a tuple, what indices are allowed?
|
|
20
|
+
|
|
19
21
|
///
|
|
22
|
+
|
|
20
23
|
function functionalUpdate(updater, input) {
|
|
21
24
|
return typeof updater === 'function' ? updater(input) : updater;
|
|
22
25
|
}
|
|
23
|
-
function noop() {
|
|
26
|
+
function noop() {
|
|
27
|
+
//
|
|
24
28
|
}
|
|
25
29
|
function makeStateUpdater(key, instance) {
|
|
26
30
|
return updater => {
|
|
27
31
|
instance.setState(old => {
|
|
28
|
-
return {
|
|
32
|
+
return {
|
|
33
|
+
...old,
|
|
29
34
|
[key]: functionalUpdate(updater, old[key])
|
|
30
35
|
};
|
|
31
36
|
});
|
|
@@ -36,18 +41,15 @@
|
|
|
36
41
|
}
|
|
37
42
|
function flattenBy(arr, getChildren) {
|
|
38
43
|
const flat = [];
|
|
39
|
-
|
|
40
44
|
const recurse = subArr => {
|
|
41
45
|
subArr.forEach(item => {
|
|
42
46
|
flat.push(item);
|
|
43
47
|
const children = getChildren(item);
|
|
44
|
-
|
|
45
48
|
if (children != null && children.length) {
|
|
46
49
|
recurse(children);
|
|
47
50
|
}
|
|
48
51
|
});
|
|
49
52
|
};
|
|
50
|
-
|
|
51
53
|
recurse(arr);
|
|
52
54
|
return flat;
|
|
53
55
|
}
|
|
@@ -59,53 +61,45 @@
|
|
|
59
61
|
if (opts.key && opts.debug) depTime = Date.now();
|
|
60
62
|
const newDeps = getDeps();
|
|
61
63
|
const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
|
|
62
|
-
|
|
63
64
|
if (!depsChanged) {
|
|
64
65
|
return result;
|
|
65
66
|
}
|
|
66
|
-
|
|
67
67
|
deps = newDeps;
|
|
68
68
|
let resultTime;
|
|
69
69
|
if (opts.key && opts.debug) resultTime = Date.now();
|
|
70
70
|
result = fn(...newDeps);
|
|
71
71
|
opts == null ? void 0 : opts.onChange == null ? void 0 : opts.onChange(result);
|
|
72
|
-
|
|
73
72
|
if (opts.key && opts.debug) {
|
|
74
73
|
if (opts != null && opts.debug()) {
|
|
75
74
|
const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
|
|
76
75
|
const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
|
|
77
76
|
const resultFpsPercentage = resultEndTime / 16;
|
|
78
|
-
|
|
79
77
|
const pad = (str, num) => {
|
|
80
78
|
str = String(str);
|
|
81
|
-
|
|
82
79
|
while (str.length < num) {
|
|
83
80
|
str = ' ' + str;
|
|
84
81
|
}
|
|
85
|
-
|
|
86
82
|
return str;
|
|
87
83
|
};
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
console.info(`%c⏱ ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`, `
|
|
85
|
+
font-size: .6rem;
|
|
86
|
+
font-weight: bold;
|
|
87
|
+
color: hsl(${Math.max(0, Math.min(120 - 120 * resultFpsPercentage, 120))}deg 100% 31%);`, opts == null ? void 0 : opts.key);
|
|
90
88
|
}
|
|
91
89
|
}
|
|
92
|
-
|
|
93
90
|
return result;
|
|
94
91
|
};
|
|
95
92
|
}
|
|
96
93
|
|
|
97
94
|
function createColumn(table, columnDef, depth, parent) {
|
|
98
|
-
var _ref, _resolvedColumnDef$id;
|
|
99
|
-
|
|
100
95
|
const defaultColumn = table._getDefaultColumnDef();
|
|
101
|
-
|
|
102
|
-
|
|
96
|
+
const resolvedColumnDef = {
|
|
97
|
+
...defaultColumn,
|
|
103
98
|
...columnDef
|
|
104
99
|
};
|
|
105
100
|
const accessorKey = resolvedColumnDef.accessorKey;
|
|
106
|
-
let id =
|
|
101
|
+
let id = resolvedColumnDef.id ?? (accessorKey ? accessorKey.replace('.', '_') : undefined) ?? (typeof resolvedColumnDef.header === 'string' ? resolvedColumnDef.header : undefined);
|
|
107
102
|
let accessorFn;
|
|
108
|
-
|
|
109
103
|
if (resolvedColumnDef.accessorFn) {
|
|
110
104
|
accessorFn = resolvedColumnDef.accessorFn;
|
|
111
105
|
} else if (accessorKey) {
|
|
@@ -113,26 +107,22 @@
|
|
|
113
107
|
if (accessorKey.includes('.')) {
|
|
114
108
|
accessorFn = originalRow => {
|
|
115
109
|
let result = originalRow;
|
|
116
|
-
|
|
117
110
|
for (const key of accessorKey.split('.')) {
|
|
118
111
|
result = result[key];
|
|
119
112
|
}
|
|
120
|
-
|
|
121
113
|
return result;
|
|
122
114
|
};
|
|
123
115
|
} else {
|
|
124
116
|
accessorFn = originalRow => originalRow[resolvedColumnDef.accessorKey];
|
|
125
117
|
}
|
|
126
118
|
}
|
|
127
|
-
|
|
128
119
|
if (!id) {
|
|
129
120
|
{
|
|
130
|
-
throw new Error(resolvedColumnDef.accessorFn ?
|
|
121
|
+
throw new Error(resolvedColumnDef.accessorFn ? `Columns require an id when using an accessorFn` : `Columns require an id when using a non-string header`);
|
|
131
122
|
}
|
|
132
123
|
}
|
|
133
|
-
|
|
134
124
|
let column = {
|
|
135
|
-
id:
|
|
125
|
+
id: `${String(id)}`,
|
|
136
126
|
accessorFn,
|
|
137
127
|
parent: parent,
|
|
138
128
|
depth,
|
|
@@ -140,46 +130,35 @@
|
|
|
140
130
|
columns: [],
|
|
141
131
|
getFlatColumns: memo(() => [true], () => {
|
|
142
132
|
var _column$columns;
|
|
143
|
-
|
|
144
133
|
return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
|
|
145
134
|
}, {
|
|
146
135
|
key: "development" === 'production' ,
|
|
147
|
-
debug: () =>
|
|
148
|
-
var _table$options$debugA;
|
|
149
|
-
|
|
150
|
-
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugColumns;
|
|
151
|
-
}
|
|
136
|
+
debug: () => table.options.debugAll ?? table.options.debugColumns
|
|
152
137
|
}),
|
|
153
138
|
getLeafColumns: memo(() => [table._getOrderColumnsFn()], orderColumns => {
|
|
154
139
|
var _column$columns2;
|
|
155
|
-
|
|
156
140
|
if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
|
|
157
141
|
let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
|
|
158
142
|
return orderColumns(leafColumns);
|
|
159
143
|
}
|
|
160
|
-
|
|
161
144
|
return [column];
|
|
162
145
|
}, {
|
|
163
146
|
key: "development" === 'production' ,
|
|
164
|
-
debug: () =>
|
|
165
|
-
var _table$options$debugA2;
|
|
166
|
-
|
|
167
|
-
return (_table$options$debugA2 = table.options.debugAll) != null ? _table$options$debugA2 : table.options.debugColumns;
|
|
168
|
-
}
|
|
147
|
+
debug: () => table.options.debugAll ?? table.options.debugColumns
|
|
169
148
|
})
|
|
170
149
|
};
|
|
171
150
|
column = table._features.reduce((obj, feature) => {
|
|
172
151
|
return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, table));
|
|
173
|
-
}, column);
|
|
152
|
+
}, column);
|
|
174
153
|
|
|
154
|
+
// Yes, we have to convert table to uknown, because we know more than the compiler here.
|
|
175
155
|
return column;
|
|
176
156
|
}
|
|
177
157
|
|
|
178
158
|
//
|
|
179
|
-
function createHeader(table, column, options) {
|
|
180
|
-
var _options$id;
|
|
181
159
|
|
|
182
|
-
|
|
160
|
+
function createHeader(table, column, options) {
|
|
161
|
+
const id = options.id ?? column.id;
|
|
183
162
|
let header = {
|
|
184
163
|
id,
|
|
185
164
|
column,
|
|
@@ -193,15 +172,12 @@
|
|
|
193
172
|
headerGroup: null,
|
|
194
173
|
getLeafHeaders: () => {
|
|
195
174
|
const leafHeaders = [];
|
|
196
|
-
|
|
197
175
|
const recurseHeader = h => {
|
|
198
176
|
if (h.subHeaders && h.subHeaders.length) {
|
|
199
177
|
h.subHeaders.map(recurseHeader);
|
|
200
178
|
}
|
|
201
|
-
|
|
202
179
|
leafHeaders.push(h);
|
|
203
180
|
};
|
|
204
|
-
|
|
205
181
|
recurseHeader(header);
|
|
206
182
|
return leafHeaders;
|
|
207
183
|
},
|
|
@@ -211,124 +187,82 @@
|
|
|
211
187
|
column
|
|
212
188
|
})
|
|
213
189
|
};
|
|
214
|
-
|
|
215
190
|
table._features.forEach(feature => {
|
|
216
191
|
Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, table));
|
|
217
192
|
});
|
|
218
|
-
|
|
219
193
|
return header;
|
|
220
194
|
}
|
|
221
|
-
|
|
222
195
|
const Headers = {
|
|
223
196
|
createTable: table => {
|
|
224
197
|
return {
|
|
225
198
|
// Header Groups
|
|
226
|
-
getHeaderGroups: memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
227
|
-
var _left$map$filter, _right$map$filter;
|
|
228
199
|
|
|
229
|
-
|
|
230
|
-
const
|
|
200
|
+
getHeaderGroups: memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
201
|
+
const leftColumns = (left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) ?? [];
|
|
202
|
+
const rightColumns = (right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) ?? [];
|
|
231
203
|
const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
232
204
|
const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], table);
|
|
233
205
|
return headerGroups;
|
|
234
206
|
}, {
|
|
235
207
|
key: 'getHeaderGroups',
|
|
236
|
-
debug: () =>
|
|
237
|
-
var _table$options$debugA;
|
|
238
|
-
|
|
239
|
-
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugHeaders;
|
|
240
|
-
}
|
|
208
|
+
debug: () => table.options.debugAll ?? table.options.debugHeaders
|
|
241
209
|
}),
|
|
242
210
|
getCenterHeaderGroups: memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
243
211
|
leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
244
212
|
return buildHeaderGroups(allColumns, leafColumns, table, 'center');
|
|
245
213
|
}, {
|
|
246
214
|
key: 'getCenterHeaderGroups',
|
|
247
|
-
debug: () =>
|
|
248
|
-
var _table$options$debugA2;
|
|
249
|
-
|
|
250
|
-
return (_table$options$debugA2 = table.options.debugAll) != null ? _table$options$debugA2 : table.options.debugHeaders;
|
|
251
|
-
}
|
|
215
|
+
debug: () => table.options.debugAll ?? table.options.debugHeaders
|
|
252
216
|
}),
|
|
253
217
|
getLeftHeaderGroups: memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
|
|
218
|
+
const orderedLeafColumns = (left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) ?? [];
|
|
257
219
|
return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'left');
|
|
258
220
|
}, {
|
|
259
221
|
key: 'getLeftHeaderGroups',
|
|
260
|
-
debug: () =>
|
|
261
|
-
var _table$options$debugA3;
|
|
262
|
-
|
|
263
|
-
return (_table$options$debugA3 = table.options.debugAll) != null ? _table$options$debugA3 : table.options.debugHeaders;
|
|
264
|
-
}
|
|
222
|
+
debug: () => table.options.debugAll ?? table.options.debugHeaders
|
|
265
223
|
}),
|
|
266
224
|
getRightHeaderGroups: memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
|
|
225
|
+
const orderedLeafColumns = (right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) ?? [];
|
|
270
226
|
return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'right');
|
|
271
227
|
}, {
|
|
272
228
|
key: 'getRightHeaderGroups',
|
|
273
|
-
debug: () =>
|
|
274
|
-
var _table$options$debugA4;
|
|
275
|
-
|
|
276
|
-
return (_table$options$debugA4 = table.options.debugAll) != null ? _table$options$debugA4 : table.options.debugHeaders;
|
|
277
|
-
}
|
|
229
|
+
debug: () => table.options.debugAll ?? table.options.debugHeaders
|
|
278
230
|
}),
|
|
279
231
|
// Footer Groups
|
|
232
|
+
|
|
280
233
|
getFooterGroups: memo(() => [table.getHeaderGroups()], headerGroups => {
|
|
281
234
|
return [...headerGroups].reverse();
|
|
282
235
|
}, {
|
|
283
236
|
key: 'getFooterGroups',
|
|
284
|
-
debug: () =>
|
|
285
|
-
var _table$options$debugA5;
|
|
286
|
-
|
|
287
|
-
return (_table$options$debugA5 = table.options.debugAll) != null ? _table$options$debugA5 : table.options.debugHeaders;
|
|
288
|
-
}
|
|
237
|
+
debug: () => table.options.debugAll ?? table.options.debugHeaders
|
|
289
238
|
}),
|
|
290
239
|
getLeftFooterGroups: memo(() => [table.getLeftHeaderGroups()], headerGroups => {
|
|
291
240
|
return [...headerGroups].reverse();
|
|
292
241
|
}, {
|
|
293
242
|
key: 'getLeftFooterGroups',
|
|
294
|
-
debug: () =>
|
|
295
|
-
var _table$options$debugA6;
|
|
296
|
-
|
|
297
|
-
return (_table$options$debugA6 = table.options.debugAll) != null ? _table$options$debugA6 : table.options.debugHeaders;
|
|
298
|
-
}
|
|
243
|
+
debug: () => table.options.debugAll ?? table.options.debugHeaders
|
|
299
244
|
}),
|
|
300
245
|
getCenterFooterGroups: memo(() => [table.getCenterHeaderGroups()], headerGroups => {
|
|
301
246
|
return [...headerGroups].reverse();
|
|
302
247
|
}, {
|
|
303
248
|
key: 'getCenterFooterGroups',
|
|
304
|
-
debug: () =>
|
|
305
|
-
var _table$options$debugA7;
|
|
306
|
-
|
|
307
|
-
return (_table$options$debugA7 = table.options.debugAll) != null ? _table$options$debugA7 : table.options.debugHeaders;
|
|
308
|
-
}
|
|
249
|
+
debug: () => table.options.debugAll ?? table.options.debugHeaders
|
|
309
250
|
}),
|
|
310
251
|
getRightFooterGroups: memo(() => [table.getRightHeaderGroups()], headerGroups => {
|
|
311
252
|
return [...headerGroups].reverse();
|
|
312
253
|
}, {
|
|
313
254
|
key: 'getRightFooterGroups',
|
|
314
|
-
debug: () =>
|
|
315
|
-
var _table$options$debugA8;
|
|
316
|
-
|
|
317
|
-
return (_table$options$debugA8 = table.options.debugAll) != null ? _table$options$debugA8 : table.options.debugHeaders;
|
|
318
|
-
}
|
|
255
|
+
debug: () => table.options.debugAll ?? table.options.debugHeaders
|
|
319
256
|
}),
|
|
320
257
|
// Flat Headers
|
|
258
|
+
|
|
321
259
|
getFlatHeaders: memo(() => [table.getHeaderGroups()], headerGroups => {
|
|
322
260
|
return headerGroups.map(headerGroup => {
|
|
323
261
|
return headerGroup.headers;
|
|
324
262
|
}).flat();
|
|
325
263
|
}, {
|
|
326
264
|
key: 'getFlatHeaders',
|
|
327
|
-
debug: () =>
|
|
328
|
-
var _table$options$debugA9;
|
|
329
|
-
|
|
330
|
-
return (_table$options$debugA9 = table.options.debugAll) != null ? _table$options$debugA9 : table.options.debugHeaders;
|
|
331
|
-
}
|
|
265
|
+
debug: () => table.options.debugAll ?? table.options.debugHeaders
|
|
332
266
|
}),
|
|
333
267
|
getLeftFlatHeaders: memo(() => [table.getLeftHeaderGroups()], left => {
|
|
334
268
|
return left.map(headerGroup => {
|
|
@@ -336,11 +270,7 @@
|
|
|
336
270
|
}).flat();
|
|
337
271
|
}, {
|
|
338
272
|
key: 'getLeftFlatHeaders',
|
|
339
|
-
debug: () =>
|
|
340
|
-
var _table$options$debugA10;
|
|
341
|
-
|
|
342
|
-
return (_table$options$debugA10 = table.options.debugAll) != null ? _table$options$debugA10 : table.options.debugHeaders;
|
|
343
|
-
}
|
|
273
|
+
debug: () => table.options.debugAll ?? table.options.debugHeaders
|
|
344
274
|
}),
|
|
345
275
|
getCenterFlatHeaders: memo(() => [table.getCenterHeaderGroups()], left => {
|
|
346
276
|
return left.map(headerGroup => {
|
|
@@ -348,11 +278,7 @@
|
|
|
348
278
|
}).flat();
|
|
349
279
|
}, {
|
|
350
280
|
key: 'getCenterFlatHeaders',
|
|
351
|
-
debug: () =>
|
|
352
|
-
var _table$options$debugA11;
|
|
353
|
-
|
|
354
|
-
return (_table$options$debugA11 = table.options.debugAll) != null ? _table$options$debugA11 : table.options.debugHeaders;
|
|
355
|
-
}
|
|
281
|
+
debug: () => table.options.debugAll ?? table.options.debugHeaders
|
|
356
282
|
}),
|
|
357
283
|
getRightFlatHeaders: memo(() => [table.getRightHeaderGroups()], left => {
|
|
358
284
|
return left.map(headerGroup => {
|
|
@@ -360,117 +286,91 @@
|
|
|
360
286
|
}).flat();
|
|
361
287
|
}, {
|
|
362
288
|
key: 'getRightFlatHeaders',
|
|
363
|
-
debug: () =>
|
|
364
|
-
var _table$options$debugA12;
|
|
365
|
-
|
|
366
|
-
return (_table$options$debugA12 = table.options.debugAll) != null ? _table$options$debugA12 : table.options.debugHeaders;
|
|
367
|
-
}
|
|
289
|
+
debug: () => table.options.debugAll ?? table.options.debugHeaders
|
|
368
290
|
}),
|
|
369
291
|
// Leaf Headers
|
|
292
|
+
|
|
370
293
|
getCenterLeafHeaders: memo(() => [table.getCenterFlatHeaders()], flatHeaders => {
|
|
371
294
|
return flatHeaders.filter(header => {
|
|
372
295
|
var _header$subHeaders;
|
|
373
|
-
|
|
374
296
|
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
|
375
297
|
});
|
|
376
298
|
}, {
|
|
377
299
|
key: 'getCenterLeafHeaders',
|
|
378
|
-
debug: () =>
|
|
379
|
-
var _table$options$debugA13;
|
|
380
|
-
|
|
381
|
-
return (_table$options$debugA13 = table.options.debugAll) != null ? _table$options$debugA13 : table.options.debugHeaders;
|
|
382
|
-
}
|
|
300
|
+
debug: () => table.options.debugAll ?? table.options.debugHeaders
|
|
383
301
|
}),
|
|
384
302
|
getLeftLeafHeaders: memo(() => [table.getLeftFlatHeaders()], flatHeaders => {
|
|
385
303
|
return flatHeaders.filter(header => {
|
|
386
304
|
var _header$subHeaders2;
|
|
387
|
-
|
|
388
305
|
return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
|
|
389
306
|
});
|
|
390
307
|
}, {
|
|
391
308
|
key: 'getLeftLeafHeaders',
|
|
392
|
-
debug: () =>
|
|
393
|
-
var _table$options$debugA14;
|
|
394
|
-
|
|
395
|
-
return (_table$options$debugA14 = table.options.debugAll) != null ? _table$options$debugA14 : table.options.debugHeaders;
|
|
396
|
-
}
|
|
309
|
+
debug: () => table.options.debugAll ?? table.options.debugHeaders
|
|
397
310
|
}),
|
|
398
311
|
getRightLeafHeaders: memo(() => [table.getRightFlatHeaders()], flatHeaders => {
|
|
399
312
|
return flatHeaders.filter(header => {
|
|
400
313
|
var _header$subHeaders3;
|
|
401
|
-
|
|
402
314
|
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
|
403
315
|
});
|
|
404
316
|
}, {
|
|
405
317
|
key: 'getRightLeafHeaders',
|
|
406
|
-
debug: () =>
|
|
407
|
-
var _table$options$debugA15;
|
|
408
|
-
|
|
409
|
-
return (_table$options$debugA15 = table.options.debugAll) != null ? _table$options$debugA15 : table.options.debugHeaders;
|
|
410
|
-
}
|
|
318
|
+
debug: () => table.options.debugAll ?? table.options.debugHeaders
|
|
411
319
|
}),
|
|
412
320
|
getLeafHeaders: memo(() => [table.getLeftHeaderGroups(), table.getCenterHeaderGroups(), table.getRightHeaderGroups()], (left, center, right) => {
|
|
413
|
-
var _left
|
|
414
|
-
|
|
415
|
-
return [...((_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(header => {
|
|
321
|
+
var _left$, _center$, _right$;
|
|
322
|
+
return [...(((_left$ = left[0]) == null ? void 0 : _left$.headers) ?? []), ...(((_center$ = center[0]) == null ? void 0 : _center$.headers) ?? []), ...(((_right$ = right[0]) == null ? void 0 : _right$.headers) ?? [])].map(header => {
|
|
416
323
|
return header.getLeafHeaders();
|
|
417
324
|
}).flat();
|
|
418
325
|
}, {
|
|
419
326
|
key: 'getLeafHeaders',
|
|
420
|
-
debug: () =>
|
|
421
|
-
var _table$options$debugA16;
|
|
422
|
-
|
|
423
|
-
return (_table$options$debugA16 = table.options.debugAll) != null ? _table$options$debugA16 : table.options.debugHeaders;
|
|
424
|
-
}
|
|
327
|
+
debug: () => table.options.debugAll ?? table.options.debugHeaders
|
|
425
328
|
})
|
|
426
329
|
};
|
|
427
330
|
}
|
|
428
331
|
};
|
|
429
332
|
function buildHeaderGroups(allColumns, columnsToGroup, table, headerFamily) {
|
|
430
|
-
var _headerGroups
|
|
431
|
-
|
|
333
|
+
var _headerGroups$;
|
|
432
334
|
// Find the max depth of the columns:
|
|
433
335
|
// build the leaf column row
|
|
434
336
|
// build each buffer row going up
|
|
435
337
|
// placeholder for non-existent level
|
|
436
338
|
// real column for existing level
|
|
437
|
-
let maxDepth = 0;
|
|
438
339
|
|
|
340
|
+
let maxDepth = 0;
|
|
439
341
|
const findMaxDepth = function (columns, depth) {
|
|
440
342
|
if (depth === void 0) {
|
|
441
343
|
depth = 1;
|
|
442
344
|
}
|
|
443
|
-
|
|
444
345
|
maxDepth = Math.max(maxDepth, depth);
|
|
445
346
|
columns.filter(column => column.getIsVisible()).forEach(column => {
|
|
446
347
|
var _column$columns;
|
|
447
|
-
|
|
448
348
|
if ((_column$columns = column.columns) != null && _column$columns.length) {
|
|
449
349
|
findMaxDepth(column.columns, depth + 1);
|
|
450
350
|
}
|
|
451
351
|
}, 0);
|
|
452
352
|
};
|
|
453
|
-
|
|
454
353
|
findMaxDepth(allColumns);
|
|
455
354
|
let headerGroups = [];
|
|
456
|
-
|
|
457
355
|
const createHeaderGroup = (headersToGroup, depth) => {
|
|
458
356
|
// The header group we are creating
|
|
459
357
|
const headerGroup = {
|
|
460
358
|
depth,
|
|
461
|
-
id: [headerFamily,
|
|
359
|
+
id: [headerFamily, `${depth}`].filter(Boolean).join('_'),
|
|
462
360
|
headers: []
|
|
463
|
-
};
|
|
361
|
+
};
|
|
464
362
|
|
|
465
|
-
|
|
363
|
+
// The parent columns we're going to scan next
|
|
364
|
+
const pendingParentHeaders = [];
|
|
466
365
|
|
|
366
|
+
// Scan each column for parents
|
|
467
367
|
headersToGroup.forEach(headerToGroup => {
|
|
468
368
|
// What is the latest (last) parent column?
|
|
369
|
+
|
|
469
370
|
const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
|
|
470
371
|
const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
|
|
471
372
|
let column;
|
|
472
373
|
let isPlaceholder = false;
|
|
473
|
-
|
|
474
374
|
if (isLeafHeader && headerToGroup.column.parent) {
|
|
475
375
|
// The parent header is new
|
|
476
376
|
column = headerToGroup.column.parent;
|
|
@@ -479,7 +379,6 @@
|
|
|
479
379
|
column = headerToGroup.column;
|
|
480
380
|
isPlaceholder = true;
|
|
481
381
|
}
|
|
482
|
-
|
|
483
382
|
if (latestPendingParentHeader && (latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
|
|
484
383
|
// This column is repeated. Add it as a sub header to the next batch
|
|
485
384
|
latestPendingParentHeader.subHeaders.push(headerToGroup);
|
|
@@ -488,33 +387,33 @@
|
|
|
488
387
|
const header = createHeader(table, column, {
|
|
489
388
|
id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
|
|
490
389
|
isPlaceholder,
|
|
491
|
-
placeholderId: isPlaceholder ?
|
|
390
|
+
placeholderId: isPlaceholder ? `${pendingParentHeaders.filter(d => d.column === column).length}` : undefined,
|
|
492
391
|
depth,
|
|
493
392
|
index: pendingParentHeaders.length
|
|
494
|
-
});
|
|
393
|
+
});
|
|
495
394
|
|
|
496
|
-
|
|
395
|
+
// Add the headerToGroup as a subHeader of the new header
|
|
396
|
+
header.subHeaders.push(headerToGroup);
|
|
397
|
+
// Add the new header to the pendingParentHeaders to get grouped
|
|
497
398
|
// in the next batch
|
|
498
|
-
|
|
499
399
|
pendingParentHeaders.push(header);
|
|
500
400
|
}
|
|
501
|
-
|
|
502
401
|
headerGroup.headers.push(headerToGroup);
|
|
503
402
|
headerToGroup.headerGroup = headerGroup;
|
|
504
403
|
});
|
|
505
404
|
headerGroups.push(headerGroup);
|
|
506
|
-
|
|
507
405
|
if (depth > 0) {
|
|
508
406
|
createHeaderGroup(pendingParentHeaders, depth - 1);
|
|
509
407
|
}
|
|
510
408
|
};
|
|
511
|
-
|
|
512
409
|
const bottomHeaders = columnsToGroup.map((column, index) => createHeader(table, column, {
|
|
513
410
|
depth: maxDepth,
|
|
514
411
|
index
|
|
515
412
|
}));
|
|
516
413
|
createHeaderGroup(bottomHeaders, maxDepth - 1);
|
|
517
|
-
headerGroups.reverse();
|
|
414
|
+
headerGroups.reverse();
|
|
415
|
+
|
|
416
|
+
// headerGroups = headerGroups.filter(headerGroup => {
|
|
518
417
|
// return !headerGroup.headers.every(header => header.isPlaceholder)
|
|
519
418
|
// })
|
|
520
419
|
|
|
@@ -524,7 +423,6 @@
|
|
|
524
423
|
let colSpan = 0;
|
|
525
424
|
let rowSpan = 0;
|
|
526
425
|
let childRowSpans = [0];
|
|
527
|
-
|
|
528
426
|
if (header.subHeaders && header.subHeaders.length) {
|
|
529
427
|
childRowSpans = [];
|
|
530
428
|
recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
|
|
@@ -538,7 +436,6 @@
|
|
|
538
436
|
} else {
|
|
539
437
|
colSpan = 1;
|
|
540
438
|
}
|
|
541
|
-
|
|
542
439
|
const minChildRowSpan = Math.min(...childRowSpans);
|
|
543
440
|
rowSpan = rowSpan + minChildRowSpan;
|
|
544
441
|
header.colSpan = colSpan;
|
|
@@ -549,18 +446,17 @@
|
|
|
549
446
|
};
|
|
550
447
|
});
|
|
551
448
|
};
|
|
552
|
-
|
|
553
|
-
recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
|
|
449
|
+
recurseHeadersForSpans(((_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) ?? []);
|
|
554
450
|
return headerGroups;
|
|
555
451
|
}
|
|
556
452
|
|
|
557
453
|
//
|
|
454
|
+
|
|
558
455
|
const defaultColumnSizing = {
|
|
559
456
|
size: 150,
|
|
560
457
|
minSize: 20,
|
|
561
458
|
maxSize: Number.MAX_SAFE_INTEGER
|
|
562
459
|
};
|
|
563
|
-
|
|
564
460
|
const getDefaultColumnSizingInfoState = () => ({
|
|
565
461
|
startOffset: null,
|
|
566
462
|
startSize: null,
|
|
@@ -569,7 +465,6 @@
|
|
|
569
465
|
isResizingColumn: false,
|
|
570
466
|
columnSizingStart: []
|
|
571
467
|
});
|
|
572
|
-
|
|
573
468
|
const ColumnSizing = {
|
|
574
469
|
getDefaultColumnDef: () => {
|
|
575
470
|
return defaultColumnSizing;
|
|
@@ -591,35 +486,29 @@
|
|
|
591
486
|
createColumn: (column, table) => {
|
|
592
487
|
return {
|
|
593
488
|
getSize: () => {
|
|
594
|
-
var _column$columnDef$min, _ref, _column$columnDef$max;
|
|
595
|
-
|
|
596
489
|
const columnSize = table.getState().columnSizing[column.id];
|
|
597
|
-
return Math.min(Math.max(
|
|
490
|
+
return Math.min(Math.max(column.columnDef.minSize ?? defaultColumnSizing.minSize, columnSize ?? column.columnDef.size ?? defaultColumnSizing.size), column.columnDef.maxSize ?? defaultColumnSizing.maxSize);
|
|
598
491
|
},
|
|
599
492
|
getStart: position => {
|
|
600
493
|
const columns = !position ? table.getVisibleLeafColumns() : position === 'left' ? table.getLeftVisibleLeafColumns() : table.getRightVisibleLeafColumns();
|
|
601
494
|
const index = columns.findIndex(d => d.id === column.id);
|
|
602
|
-
|
|
603
495
|
if (index > 0) {
|
|
604
496
|
const prevSiblingColumn = columns[index - 1];
|
|
605
497
|
return prevSiblingColumn.getStart(position) + prevSiblingColumn.getSize();
|
|
606
498
|
}
|
|
607
|
-
|
|
608
499
|
return 0;
|
|
609
500
|
},
|
|
610
501
|
resetSize: () => {
|
|
611
|
-
table.setColumnSizing(
|
|
502
|
+
table.setColumnSizing(_ref => {
|
|
612
503
|
let {
|
|
613
504
|
[column.id]: _,
|
|
614
505
|
...rest
|
|
615
|
-
} =
|
|
506
|
+
} = _ref;
|
|
616
507
|
return rest;
|
|
617
508
|
});
|
|
618
509
|
},
|
|
619
510
|
getCanResize: () => {
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnResizing) != null ? _table$options$enable : true);
|
|
511
|
+
return (column.columnDef.enableResizing ?? true) && (table.options.enableColumnResizing ?? true);
|
|
623
512
|
},
|
|
624
513
|
getIsResizing: () => {
|
|
625
514
|
return table.getState().columnSizingInfo.isResizingColumn === column.id;
|
|
@@ -630,17 +519,13 @@
|
|
|
630
519
|
return {
|
|
631
520
|
getSize: () => {
|
|
632
521
|
let sum = 0;
|
|
633
|
-
|
|
634
522
|
const recurse = header => {
|
|
635
523
|
if (header.subHeaders.length) {
|
|
636
524
|
header.subHeaders.forEach(recurse);
|
|
637
525
|
} else {
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
sum += (_header$column$getSiz = header.column.getSize()) != null ? _header$column$getSiz : 0;
|
|
526
|
+
sum += header.column.getSize() ?? 0;
|
|
641
527
|
}
|
|
642
528
|
};
|
|
643
|
-
|
|
644
529
|
recurse(header);
|
|
645
530
|
return sum;
|
|
646
531
|
},
|
|
@@ -649,7 +534,6 @@
|
|
|
649
534
|
const prevSiblingHeader = header.headerGroup.headers[header.index - 1];
|
|
650
535
|
return prevSiblingHeader.getStart() + prevSiblingHeader.getSize();
|
|
651
536
|
}
|
|
652
|
-
|
|
653
537
|
return 0;
|
|
654
538
|
},
|
|
655
539
|
getResizeHandler: () => {
|
|
@@ -660,51 +544,45 @@
|
|
|
660
544
|
return;
|
|
661
545
|
}
|
|
662
546
|
e.persist == null ? void 0 : e.persist();
|
|
663
|
-
|
|
664
547
|
if (isTouchStartEvent(e)) {
|
|
665
548
|
// lets not respond to multiple touches (e.g. 2 or 3 fingers)
|
|
666
549
|
if (e.touches && e.touches.length > 1) {
|
|
667
550
|
return;
|
|
668
551
|
}
|
|
669
552
|
}
|
|
670
|
-
|
|
671
553
|
const startSize = header.getSize();
|
|
672
554
|
const columnSizingStart = header ? header.getLeafHeaders().map(d => [d.column.id, d.column.getSize()]) : [[column.id, column.getSize()]];
|
|
673
555
|
const clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
|
|
674
|
-
|
|
675
556
|
const updateOffset = (eventType, clientXPos) => {
|
|
676
557
|
if (typeof clientXPos !== 'number') {
|
|
677
558
|
return;
|
|
678
559
|
}
|
|
679
|
-
|
|
680
560
|
let newColumnSizing = {};
|
|
681
561
|
table.setColumnSizingInfo(old => {
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
old.columnSizingStart.forEach(_ref3 => {
|
|
687
|
-
let [columnId, headerSize] = _ref3;
|
|
562
|
+
const deltaOffset = clientXPos - ((old == null ? void 0 : old.startOffset) ?? 0);
|
|
563
|
+
const deltaPercentage = Math.max(deltaOffset / ((old == null ? void 0 : old.startSize) ?? 0), -0.999999);
|
|
564
|
+
old.columnSizingStart.forEach(_ref2 => {
|
|
565
|
+
let [columnId, headerSize] = _ref2;
|
|
688
566
|
newColumnSizing[columnId] = Math.round(Math.max(headerSize + headerSize * deltaPercentage, 0) * 100) / 100;
|
|
689
567
|
});
|
|
690
|
-
return {
|
|
568
|
+
return {
|
|
569
|
+
...old,
|
|
691
570
|
deltaOffset,
|
|
692
571
|
deltaPercentage
|
|
693
572
|
};
|
|
694
573
|
});
|
|
695
|
-
|
|
696
574
|
if (table.options.columnResizeMode === 'onChange' || eventType === 'end') {
|
|
697
|
-
table.setColumnSizing(old => ({
|
|
575
|
+
table.setColumnSizing(old => ({
|
|
576
|
+
...old,
|
|
698
577
|
...newColumnSizing
|
|
699
578
|
}));
|
|
700
579
|
}
|
|
701
580
|
};
|
|
702
|
-
|
|
703
581
|
const onMove = clientXPos => updateOffset('move', clientXPos);
|
|
704
|
-
|
|
705
582
|
const onEnd = clientXPos => {
|
|
706
583
|
updateOffset('end', clientXPos);
|
|
707
|
-
table.setColumnSizingInfo(old => ({
|
|
584
|
+
table.setColumnSizingInfo(old => ({
|
|
585
|
+
...old,
|
|
708
586
|
isResizingColumn: false,
|
|
709
587
|
startOffset: null,
|
|
710
588
|
startSize: null,
|
|
@@ -713,7 +591,6 @@
|
|
|
713
591
|
columnSizingStart: []
|
|
714
592
|
}));
|
|
715
593
|
};
|
|
716
|
-
|
|
717
594
|
const mouseEvents = {
|
|
718
595
|
moveHandler: e => onMove(e.clientX),
|
|
719
596
|
upHandler: e => {
|
|
@@ -722,16 +599,38 @@
|
|
|
722
599
|
onEnd(e.clientX);
|
|
723
600
|
}
|
|
724
601
|
};
|
|
602
|
+
const touchEvents = {
|
|
603
|
+
moveHandler: e => {
|
|
604
|
+
if (e.cancelable) {
|
|
605
|
+
e.preventDefault();
|
|
606
|
+
e.stopPropagation();
|
|
607
|
+
}
|
|
608
|
+
onMove(e.touches[0].clientX);
|
|
609
|
+
return false;
|
|
610
|
+
},
|
|
611
|
+
upHandler: e => {
|
|
612
|
+
var _e$touches$;
|
|
613
|
+
document.removeEventListener('touchmove', touchEvents.moveHandler);
|
|
614
|
+
document.removeEventListener('touchend', touchEvents.upHandler);
|
|
615
|
+
if (e.cancelable) {
|
|
616
|
+
e.preventDefault();
|
|
617
|
+
e.stopPropagation();
|
|
618
|
+
}
|
|
619
|
+
onEnd((_e$touches$ = e.touches[0]) == null ? void 0 : _e$touches$.clientX);
|
|
620
|
+
}
|
|
621
|
+
};
|
|
725
622
|
const passiveIfSupported = passiveEventSupported() ? {
|
|
726
623
|
passive: false
|
|
727
624
|
} : false;
|
|
728
|
-
|
|
729
|
-
|
|
625
|
+
if (isTouchStartEvent(e)) {
|
|
626
|
+
document.addEventListener('touchmove', touchEvents.moveHandler, passiveIfSupported);
|
|
627
|
+
document.addEventListener('touchend', touchEvents.upHandler, passiveIfSupported);
|
|
628
|
+
} else {
|
|
730
629
|
document.addEventListener('mousemove', mouseEvents.moveHandler, passiveIfSupported);
|
|
731
630
|
document.addEventListener('mouseup', mouseEvents.upHandler, passiveIfSupported);
|
|
732
631
|
}
|
|
733
|
-
|
|
734
|
-
|
|
632
|
+
table.setColumnSizingInfo(old => ({
|
|
633
|
+
...old,
|
|
735
634
|
startOffset: clientX,
|
|
736
635
|
startSize,
|
|
737
636
|
deltaOffset: 0,
|
|
@@ -748,42 +647,34 @@
|
|
|
748
647
|
setColumnSizing: updater => table.options.onColumnSizingChange == null ? void 0 : table.options.onColumnSizingChange(updater),
|
|
749
648
|
setColumnSizingInfo: updater => table.options.onColumnSizingInfoChange == null ? void 0 : table.options.onColumnSizingInfoChange(updater),
|
|
750
649
|
resetColumnSizing: defaultState => {
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
table.setColumnSizing(defaultState ? {} : (_table$initialState$c = table.initialState.columnSizing) != null ? _table$initialState$c : {});
|
|
650
|
+
table.setColumnSizing(defaultState ? {} : table.initialState.columnSizing ?? {});
|
|
754
651
|
},
|
|
755
652
|
resetHeaderSizeInfo: defaultState => {
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
table.setColumnSizingInfo(defaultState ? getDefaultColumnSizingInfoState() : (_table$initialState$c2 = table.initialState.columnSizingInfo) != null ? _table$initialState$c2 : getDefaultColumnSizingInfoState());
|
|
653
|
+
table.setColumnSizingInfo(defaultState ? getDefaultColumnSizingInfoState() : table.initialState.columnSizingInfo ?? getDefaultColumnSizingInfoState());
|
|
759
654
|
},
|
|
760
655
|
getTotalSize: () => {
|
|
761
|
-
var _table$getHeaderGroup
|
|
762
|
-
|
|
763
|
-
return (_table$getHeaderGroup = (_table$getHeaderGroup2 = table.getHeaderGroups()[0]) == null ? void 0 : _table$getHeaderGroup2.headers.reduce((sum, header) => {
|
|
656
|
+
var _table$getHeaderGroup;
|
|
657
|
+
return ((_table$getHeaderGroup = table.getHeaderGroups()[0]) == null ? void 0 : _table$getHeaderGroup.headers.reduce((sum, header) => {
|
|
764
658
|
return sum + header.getSize();
|
|
765
|
-
}, 0))
|
|
659
|
+
}, 0)) ?? 0;
|
|
766
660
|
},
|
|
767
661
|
getLeftTotalSize: () => {
|
|
768
|
-
var _table$getLeftHeaderG
|
|
769
|
-
|
|
770
|
-
return (_table$getLeftHeaderG = (_table$getLeftHeaderG2 = table.getLeftHeaderGroups()[0]) == null ? void 0 : _table$getLeftHeaderG2.headers.reduce((sum, header) => {
|
|
662
|
+
var _table$getLeftHeaderG;
|
|
663
|
+
return ((_table$getLeftHeaderG = table.getLeftHeaderGroups()[0]) == null ? void 0 : _table$getLeftHeaderG.headers.reduce((sum, header) => {
|
|
771
664
|
return sum + header.getSize();
|
|
772
|
-
}, 0))
|
|
665
|
+
}, 0)) ?? 0;
|
|
773
666
|
},
|
|
774
667
|
getCenterTotalSize: () => {
|
|
775
|
-
var _table$getCenterHeade
|
|
776
|
-
|
|
777
|
-
return (_table$getCenterHeade = (_table$getCenterHeade2 = table.getCenterHeaderGroups()[0]) == null ? void 0 : _table$getCenterHeade2.headers.reduce((sum, header) => {
|
|
668
|
+
var _table$getCenterHeade;
|
|
669
|
+
return ((_table$getCenterHeade = table.getCenterHeaderGroups()[0]) == null ? void 0 : _table$getCenterHeade.headers.reduce((sum, header) => {
|
|
778
670
|
return sum + header.getSize();
|
|
779
|
-
}, 0))
|
|
671
|
+
}, 0)) ?? 0;
|
|
780
672
|
},
|
|
781
673
|
getRightTotalSize: () => {
|
|
782
|
-
var _table$getRightHeader
|
|
783
|
-
|
|
784
|
-
return (_table$getRightHeader = (_table$getRightHeader2 = table.getRightHeaderGroups()[0]) == null ? void 0 : _table$getRightHeader2.headers.reduce((sum, header) => {
|
|
674
|
+
var _table$getRightHeader;
|
|
675
|
+
return ((_table$getRightHeader = table.getRightHeaderGroups()[0]) == null ? void 0 : _table$getRightHeader.headers.reduce((sum, header) => {
|
|
785
676
|
return sum + header.getSize();
|
|
786
|
-
}, 0))
|
|
677
|
+
}, 0)) ?? 0;
|
|
787
678
|
}
|
|
788
679
|
};
|
|
789
680
|
}
|
|
@@ -792,33 +683,28 @@
|
|
|
792
683
|
function passiveEventSupported() {
|
|
793
684
|
if (typeof passiveSupported === 'boolean') return passiveSupported;
|
|
794
685
|
let supported = false;
|
|
795
|
-
|
|
796
686
|
try {
|
|
797
687
|
const options = {
|
|
798
688
|
get passive() {
|
|
799
689
|
supported = true;
|
|
800
690
|
return false;
|
|
801
691
|
}
|
|
802
|
-
|
|
803
692
|
};
|
|
804
|
-
|
|
805
693
|
const noop = () => {};
|
|
806
|
-
|
|
807
694
|
window.addEventListener('test', noop, options);
|
|
808
695
|
window.removeEventListener('test', noop);
|
|
809
696
|
} catch (err) {
|
|
810
697
|
supported = false;
|
|
811
698
|
}
|
|
812
|
-
|
|
813
699
|
passiveSupported = supported;
|
|
814
700
|
return passiveSupported;
|
|
815
701
|
}
|
|
816
|
-
|
|
817
702
|
function isTouchStartEvent(e) {
|
|
818
703
|
return e.type === 'touchstart';
|
|
819
704
|
}
|
|
820
705
|
|
|
821
706
|
//
|
|
707
|
+
|
|
822
708
|
const Expanding = {
|
|
823
709
|
getInitialState: state => {
|
|
824
710
|
return {
|
|
@@ -837,20 +723,15 @@
|
|
|
837
723
|
let queued = false;
|
|
838
724
|
return {
|
|
839
725
|
_autoResetExpanded: () => {
|
|
840
|
-
var _ref, _table$options$autoRe;
|
|
841
|
-
|
|
842
726
|
if (!registered) {
|
|
843
727
|
table._queue(() => {
|
|
844
728
|
registered = true;
|
|
845
729
|
});
|
|
846
|
-
|
|
847
730
|
return;
|
|
848
731
|
}
|
|
849
|
-
|
|
850
|
-
if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetExpanded) != null ? _ref : !table.options.manualExpanding) {
|
|
732
|
+
if (table.options.autoResetAll ?? table.options.autoResetExpanded ?? !table.options.manualExpanding) {
|
|
851
733
|
if (queued) return;
|
|
852
734
|
queued = true;
|
|
853
|
-
|
|
854
735
|
table._queue(() => {
|
|
855
736
|
table.resetExpanded();
|
|
856
737
|
queued = false;
|
|
@@ -859,16 +740,15 @@
|
|
|
859
740
|
},
|
|
860
741
|
setExpanded: updater => table.options.onExpandedChange == null ? void 0 : table.options.onExpandedChange(updater),
|
|
861
742
|
toggleAllRowsExpanded: expanded => {
|
|
862
|
-
if (expanded
|
|
743
|
+
if (expanded ?? !table.getIsAllRowsExpanded()) {
|
|
863
744
|
table.setExpanded(true);
|
|
864
745
|
} else {
|
|
865
746
|
table.setExpanded({});
|
|
866
747
|
}
|
|
867
748
|
},
|
|
868
749
|
resetExpanded: defaultState => {
|
|
869
|
-
var _table$initialState
|
|
870
|
-
|
|
871
|
-
table.setExpanded(defaultState ? {} : (_table$initialState$e = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.expanded) != null ? _table$initialState$e : {});
|
|
750
|
+
var _table$initialState;
|
|
751
|
+
table.setExpanded(defaultState ? {} : ((_table$initialState = table.initialState) == null ? void 0 : _table$initialState.expanded) ?? {});
|
|
872
752
|
},
|
|
873
753
|
getCanSomeRowsExpand: () => {
|
|
874
754
|
return table.getRowModel().flatRows.some(row => row.getCanExpand());
|
|
@@ -884,22 +764,22 @@
|
|
|
884
764
|
return expanded === true || Object.values(expanded).some(Boolean);
|
|
885
765
|
},
|
|
886
766
|
getIsAllRowsExpanded: () => {
|
|
887
|
-
const expanded = table.getState().expanded;
|
|
767
|
+
const expanded = table.getState().expanded;
|
|
888
768
|
|
|
769
|
+
// If expanded is true, save some cycles and return true
|
|
889
770
|
if (typeof expanded === 'boolean') {
|
|
890
771
|
return expanded === true;
|
|
891
772
|
}
|
|
892
|
-
|
|
893
773
|
if (!Object.keys(expanded).length) {
|
|
894
774
|
return false;
|
|
895
|
-
}
|
|
896
|
-
|
|
775
|
+
}
|
|
897
776
|
|
|
898
|
-
|
|
777
|
+
// If any row is not expanded, return false
|
|
778
|
+
if (table.getRowModel().flatRows.some(row => !row.getIsExpanded())) {
|
|
899
779
|
return false;
|
|
900
|
-
}
|
|
901
|
-
|
|
780
|
+
}
|
|
902
781
|
|
|
782
|
+
// They must all be expanded :shrug:
|
|
903
783
|
return true;
|
|
904
784
|
},
|
|
905
785
|
getExpandedDepth: () => {
|
|
@@ -916,11 +796,9 @@
|
|
|
916
796
|
if (!table._getExpandedRowModel && table.options.getExpandedRowModel) {
|
|
917
797
|
table._getExpandedRowModel = table.options.getExpandedRowModel(table);
|
|
918
798
|
}
|
|
919
|
-
|
|
920
799
|
if (table.options.manualExpanding || !table._getExpandedRowModel) {
|
|
921
800
|
return table.getPreExpandedRowModel();
|
|
922
801
|
}
|
|
923
|
-
|
|
924
802
|
return table._getExpandedRowModel();
|
|
925
803
|
}
|
|
926
804
|
};
|
|
@@ -929,11 +807,8 @@
|
|
|
929
807
|
return {
|
|
930
808
|
toggleExpanded: expanded => {
|
|
931
809
|
table.setExpanded(old => {
|
|
932
|
-
var _expanded;
|
|
933
|
-
|
|
934
810
|
const exists = old === true ? true : !!(old != null && old[row.id]);
|
|
935
811
|
let oldExpanded = {};
|
|
936
|
-
|
|
937
812
|
if (old === true) {
|
|
938
813
|
Object.keys(table.getRowModel().rowsById).forEach(rowId => {
|
|
939
814
|
oldExpanded[rowId] = true;
|
|
@@ -941,15 +816,13 @@
|
|
|
941
816
|
} else {
|
|
942
817
|
oldExpanded = old;
|
|
943
818
|
}
|
|
944
|
-
|
|
945
|
-
expanded = (_expanded = expanded) != null ? _expanded : !exists;
|
|
946
|
-
|
|
819
|
+
expanded = expanded ?? !exists;
|
|
947
820
|
if (!exists && expanded) {
|
|
948
|
-
return {
|
|
821
|
+
return {
|
|
822
|
+
...oldExpanded,
|
|
949
823
|
[row.id]: true
|
|
950
824
|
};
|
|
951
825
|
}
|
|
952
|
-
|
|
953
826
|
if (exists && !expanded) {
|
|
954
827
|
const {
|
|
955
828
|
[row.id]: _,
|
|
@@ -957,20 +830,16 @@
|
|
|
957
830
|
} = oldExpanded;
|
|
958
831
|
return rest;
|
|
959
832
|
}
|
|
960
|
-
|
|
961
833
|
return old;
|
|
962
834
|
});
|
|
963
835
|
},
|
|
964
836
|
getIsExpanded: () => {
|
|
965
|
-
var _table$options$getIsR;
|
|
966
|
-
|
|
967
837
|
const expanded = table.getState().expanded;
|
|
968
|
-
return !!((
|
|
838
|
+
return !!((table.options.getIsRowExpanded == null ? void 0 : table.options.getIsRowExpanded(row)) ?? (expanded === true || expanded != null && expanded[row.id]));
|
|
969
839
|
},
|
|
970
840
|
getCanExpand: () => {
|
|
971
|
-
var
|
|
972
|
-
|
|
973
|
-
return (_table$options$getRow = table.options.getRowCanExpand == null ? void 0 : table.options.getRowCanExpand(row)) != null ? _table$options$getRow : ((_table$options$enable = table.options.enableExpanding) != null ? _table$options$enable : true) && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
|
|
841
|
+
var _row$subRows;
|
|
842
|
+
return (table.options.getRowCanExpand == null ? void 0 : table.options.getRowCanExpand(row)) ?? ((table.options.enableExpanding ?? true) && !!((_row$subRows = row.subRows) != null && _row$subRows.length));
|
|
974
843
|
},
|
|
975
844
|
getToggleExpandedHandler: () => {
|
|
976
845
|
const canExpand = row.getCanExpand();
|
|
@@ -985,93 +854,68 @@
|
|
|
985
854
|
|
|
986
855
|
const includesString = (row, columnId, filterValue) => {
|
|
987
856
|
var _row$getValue;
|
|
988
|
-
|
|
989
857
|
const search = filterValue.toLowerCase();
|
|
990
858
|
return (_row$getValue = row.getValue(columnId)) == null ? void 0 : _row$getValue.toLowerCase().includes(search);
|
|
991
859
|
};
|
|
992
|
-
|
|
993
860
|
includesString.autoRemove = val => testFalsey(val);
|
|
994
|
-
|
|
995
861
|
const includesStringSensitive = (row, columnId, filterValue) => {
|
|
996
862
|
var _row$getValue2;
|
|
997
|
-
|
|
998
863
|
return (_row$getValue2 = row.getValue(columnId)) == null ? void 0 : _row$getValue2.includes(filterValue);
|
|
999
864
|
};
|
|
1000
|
-
|
|
1001
865
|
includesStringSensitive.autoRemove = val => testFalsey(val);
|
|
1002
|
-
|
|
1003
866
|
const equalsString = (row, columnId, filterValue) => {
|
|
1004
867
|
var _row$getValue3;
|
|
1005
|
-
|
|
1006
868
|
return ((_row$getValue3 = row.getValue(columnId)) == null ? void 0 : _row$getValue3.toLowerCase()) === filterValue.toLowerCase();
|
|
1007
869
|
};
|
|
1008
|
-
|
|
1009
870
|
equalsString.autoRemove = val => testFalsey(val);
|
|
1010
|
-
|
|
1011
871
|
const arrIncludes = (row, columnId, filterValue) => {
|
|
1012
872
|
var _row$getValue4;
|
|
1013
|
-
|
|
1014
873
|
return (_row$getValue4 = row.getValue(columnId)) == null ? void 0 : _row$getValue4.includes(filterValue);
|
|
1015
874
|
};
|
|
1016
|
-
|
|
1017
875
|
arrIncludes.autoRemove = val => testFalsey(val) || !(val != null && val.length);
|
|
1018
|
-
|
|
1019
876
|
const arrIncludesAll = (row, columnId, filterValue) => {
|
|
1020
877
|
return !filterValue.some(val => {
|
|
1021
878
|
var _row$getValue5;
|
|
1022
|
-
|
|
1023
879
|
return !((_row$getValue5 = row.getValue(columnId)) != null && _row$getValue5.includes(val));
|
|
1024
880
|
});
|
|
1025
881
|
};
|
|
1026
|
-
|
|
1027
882
|
arrIncludesAll.autoRemove = val => testFalsey(val) || !(val != null && val.length);
|
|
1028
|
-
|
|
1029
883
|
const arrIncludesSome = (row, columnId, filterValue) => {
|
|
1030
884
|
return filterValue.some(val => {
|
|
1031
885
|
var _row$getValue6;
|
|
1032
|
-
|
|
1033
886
|
return (_row$getValue6 = row.getValue(columnId)) == null ? void 0 : _row$getValue6.includes(val);
|
|
1034
887
|
});
|
|
1035
888
|
};
|
|
1036
|
-
|
|
1037
889
|
arrIncludesSome.autoRemove = val => testFalsey(val) || !(val != null && val.length);
|
|
1038
|
-
|
|
1039
890
|
const equals = (row, columnId, filterValue) => {
|
|
1040
891
|
return row.getValue(columnId) === filterValue;
|
|
1041
892
|
};
|
|
1042
|
-
|
|
1043
893
|
equals.autoRemove = val => testFalsey(val);
|
|
1044
|
-
|
|
1045
894
|
const weakEquals = (row, columnId, filterValue) => {
|
|
1046
895
|
return row.getValue(columnId) == filterValue;
|
|
1047
896
|
};
|
|
1048
|
-
|
|
1049
897
|
weakEquals.autoRemove = val => testFalsey(val);
|
|
1050
|
-
|
|
1051
898
|
const inNumberRange = (row, columnId, filterValue) => {
|
|
1052
899
|
let [min, max] = filterValue;
|
|
1053
900
|
const rowValue = row.getValue(columnId);
|
|
1054
901
|
return rowValue >= min && rowValue <= max;
|
|
1055
902
|
};
|
|
1056
|
-
|
|
1057
903
|
inNumberRange.resolveFilterValue = val => {
|
|
1058
904
|
let [unsafeMin, unsafeMax] = val;
|
|
1059
905
|
let parsedMin = typeof unsafeMin !== 'number' ? parseFloat(unsafeMin) : unsafeMin;
|
|
1060
906
|
let parsedMax = typeof unsafeMax !== 'number' ? parseFloat(unsafeMax) : unsafeMax;
|
|
1061
907
|
let min = unsafeMin === null || Number.isNaN(parsedMin) ? -Infinity : parsedMin;
|
|
1062
908
|
let max = unsafeMax === null || Number.isNaN(parsedMax) ? Infinity : parsedMax;
|
|
1063
|
-
|
|
1064
909
|
if (min > max) {
|
|
1065
910
|
const temp = min;
|
|
1066
911
|
min = max;
|
|
1067
912
|
max = temp;
|
|
1068
913
|
}
|
|
1069
|
-
|
|
1070
914
|
return [min, max];
|
|
1071
915
|
};
|
|
916
|
+
inNumberRange.autoRemove = val => testFalsey(val) || testFalsey(val[0]) && testFalsey(val[1]);
|
|
1072
917
|
|
|
1073
|
-
|
|
1074
|
-
|
|
918
|
+
// Export
|
|
1075
919
|
|
|
1076
920
|
const filterFns = {
|
|
1077
921
|
includesString,
|
|
@@ -1084,13 +928,14 @@
|
|
|
1084
928
|
weakEquals,
|
|
1085
929
|
inNumberRange
|
|
1086
930
|
};
|
|
1087
|
-
|
|
1088
931
|
// Utils
|
|
932
|
+
|
|
1089
933
|
function testFalsey(val) {
|
|
1090
934
|
return val === undefined || val === null || val === '';
|
|
1091
935
|
}
|
|
1092
936
|
|
|
1093
937
|
//
|
|
938
|
+
|
|
1094
939
|
const Filters = {
|
|
1095
940
|
getDefaultColumnDef: () => {
|
|
1096
941
|
return {
|
|
@@ -1114,7 +959,6 @@
|
|
|
1114
959
|
globalFilterFn: 'auto',
|
|
1115
960
|
getColumnCanGlobalFilter: column => {
|
|
1116
961
|
var _table$getCoreRowMode, _table$getCoreRowMode2;
|
|
1117
|
-
|
|
1118
962
|
const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) == null ? void 0 : (_table$getCoreRowMode2 = _table$getCoreRowMode._getAllCellsByColumnId()[column.id]) == null ? void 0 : _table$getCoreRowMode2.getValue();
|
|
1119
963
|
return typeof value === 'string' || typeof value === 'number';
|
|
1120
964
|
}
|
|
@@ -1125,88 +969,67 @@
|
|
|
1125
969
|
getAutoFilterFn: () => {
|
|
1126
970
|
const firstRow = table.getCoreRowModel().flatRows[0];
|
|
1127
971
|
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
|
1128
|
-
|
|
1129
972
|
if (typeof value === 'string') {
|
|
1130
973
|
return filterFns.includesString;
|
|
1131
974
|
}
|
|
1132
|
-
|
|
1133
975
|
if (typeof value === 'number') {
|
|
1134
976
|
return filterFns.inNumberRange;
|
|
1135
977
|
}
|
|
1136
|
-
|
|
1137
978
|
if (typeof value === 'boolean') {
|
|
1138
979
|
return filterFns.equals;
|
|
1139
980
|
}
|
|
1140
|
-
|
|
1141
981
|
if (value !== null && typeof value === 'object') {
|
|
1142
982
|
return filterFns.equals;
|
|
1143
983
|
}
|
|
1144
|
-
|
|
1145
984
|
if (Array.isArray(value)) {
|
|
1146
985
|
return filterFns.arrIncludes;
|
|
1147
986
|
}
|
|
1148
|
-
|
|
1149
987
|
return filterFns.weakEquals;
|
|
1150
988
|
},
|
|
1151
989
|
getFilterFn: () => {
|
|
1152
|
-
var _table$options$filter
|
|
1153
|
-
|
|
1154
|
-
return isFunction(column.columnDef.filterFn) ? column.columnDef.filterFn : column.columnDef.filterFn === 'auto' ? column.getAutoFilterFn() : (_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[column.columnDef.filterFn]) != null ? _table$options$filter : filterFns[column.columnDef.filterFn];
|
|
990
|
+
var _table$options$filter;
|
|
991
|
+
return isFunction(column.columnDef.filterFn) ? column.columnDef.filterFn : column.columnDef.filterFn === 'auto' ? column.getAutoFilterFn() : ((_table$options$filter = table.options.filterFns) == null ? void 0 : _table$options$filter[column.columnDef.filterFn]) ?? filterFns[column.columnDef.filterFn];
|
|
1155
992
|
},
|
|
1156
993
|
getCanFilter: () => {
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
return ((_column$columnDef$ena = column.columnDef.enableColumnFilter) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnFilters) != null ? _table$options$enable : true) && ((_table$options$enable2 = table.options.enableFilters) != null ? _table$options$enable2 : true) && !!column.accessorFn;
|
|
994
|
+
return (column.columnDef.enableColumnFilter ?? true) && (table.options.enableColumnFilters ?? true) && (table.options.enableFilters ?? true) && !!column.accessorFn;
|
|
1160
995
|
},
|
|
1161
996
|
getCanGlobalFilter: () => {
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
return ((_column$columnDef$ena2 = column.columnDef.enableGlobalFilter) != null ? _column$columnDef$ena2 : true) && ((_table$options$enable3 = table.options.enableGlobalFilter) != null ? _table$options$enable3 : true) && ((_table$options$enable4 = table.options.enableFilters) != null ? _table$options$enable4 : true) && ((_table$options$getCol = table.options.getColumnCanGlobalFilter == null ? void 0 : table.options.getColumnCanGlobalFilter(column)) != null ? _table$options$getCol : true) && !!column.accessorFn;
|
|
997
|
+
return (column.columnDef.enableGlobalFilter ?? true) && (table.options.enableGlobalFilter ?? true) && (table.options.enableFilters ?? true) && ((table.options.getColumnCanGlobalFilter == null ? void 0 : table.options.getColumnCanGlobalFilter(column)) ?? true) && !!column.accessorFn;
|
|
1165
998
|
},
|
|
1166
999
|
getIsFiltered: () => column.getFilterIndex() > -1,
|
|
1167
1000
|
getFilterValue: () => {
|
|
1168
1001
|
var _table$getState$colum, _table$getState$colum2;
|
|
1169
|
-
|
|
1170
1002
|
return (_table$getState$colum = table.getState().columnFilters) == null ? void 0 : (_table$getState$colum2 = _table$getState$colum.find(d => d.id === column.id)) == null ? void 0 : _table$getState$colum2.value;
|
|
1171
1003
|
},
|
|
1172
1004
|
getFilterIndex: () => {
|
|
1173
|
-
var _table$getState$colum3
|
|
1174
|
-
|
|
1175
|
-
return (_table$getState$colum3 = (_table$getState$colum4 = table.getState().columnFilters) == null ? void 0 : _table$getState$colum4.findIndex(d => d.id === column.id)) != null ? _table$getState$colum3 : -1;
|
|
1005
|
+
var _table$getState$colum3;
|
|
1006
|
+
return ((_table$getState$colum3 = table.getState().columnFilters) == null ? void 0 : _table$getState$colum3.findIndex(d => d.id === column.id)) ?? -1;
|
|
1176
1007
|
},
|
|
1177
1008
|
setFilterValue: value => {
|
|
1178
1009
|
table.setColumnFilters(old => {
|
|
1179
1010
|
const filterFn = column.getFilterFn();
|
|
1180
1011
|
const previousfilter = old == null ? void 0 : old.find(d => d.id === column.id);
|
|
1181
|
-
const newFilter = functionalUpdate(value, previousfilter ? previousfilter.value : undefined);
|
|
1012
|
+
const newFilter = functionalUpdate(value, previousfilter ? previousfilter.value : undefined);
|
|
1182
1013
|
|
|
1014
|
+
//
|
|
1183
1015
|
if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
return (_old$filter = old == null ? void 0 : old.filter(d => d.id !== column.id)) != null ? _old$filter : [];
|
|
1016
|
+
return (old == null ? void 0 : old.filter(d => d.id !== column.id)) ?? [];
|
|
1187
1017
|
}
|
|
1188
|
-
|
|
1189
1018
|
const newFilterObj = {
|
|
1190
1019
|
id: column.id,
|
|
1191
1020
|
value: newFilter
|
|
1192
1021
|
};
|
|
1193
|
-
|
|
1194
1022
|
if (previousfilter) {
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
return (_old$map = old == null ? void 0 : old.map(d => {
|
|
1023
|
+
return (old == null ? void 0 : old.map(d => {
|
|
1198
1024
|
if (d.id === column.id) {
|
|
1199
1025
|
return newFilterObj;
|
|
1200
1026
|
}
|
|
1201
|
-
|
|
1202
1027
|
return d;
|
|
1203
|
-
}))
|
|
1028
|
+
})) ?? [];
|
|
1204
1029
|
}
|
|
1205
|
-
|
|
1206
1030
|
if (old != null && old.length) {
|
|
1207
1031
|
return [...old, newFilterObj];
|
|
1208
1032
|
}
|
|
1209
|
-
|
|
1210
1033
|
return [newFilterObj];
|
|
1211
1034
|
});
|
|
1212
1035
|
},
|
|
@@ -1215,7 +1038,6 @@
|
|
|
1215
1038
|
if (!column._getFacetedRowModel) {
|
|
1216
1039
|
return table.getPreFilteredRowModel();
|
|
1217
1040
|
}
|
|
1218
|
-
|
|
1219
1041
|
return column._getFacetedRowModel();
|
|
1220
1042
|
},
|
|
1221
1043
|
_getFacetedUniqueValues: table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, column.id),
|
|
@@ -1223,7 +1045,6 @@
|
|
|
1223
1045
|
if (!column._getFacetedUniqueValues) {
|
|
1224
1046
|
return new Map();
|
|
1225
1047
|
}
|
|
1226
|
-
|
|
1227
1048
|
return column._getFacetedUniqueValues();
|
|
1228
1049
|
},
|
|
1229
1050
|
_getFacetedMinMaxValues: table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, column.id),
|
|
@@ -1231,13 +1052,13 @@
|
|
|
1231
1052
|
if (!column._getFacetedMinMaxValues) {
|
|
1232
1053
|
return undefined;
|
|
1233
1054
|
}
|
|
1234
|
-
|
|
1235
1055
|
return column._getFacetedMinMaxValues();
|
|
1236
|
-
}
|
|
1056
|
+
}
|
|
1057
|
+
// () => [column.getFacetedRowModel()],
|
|
1237
1058
|
// facetedRowModel => getRowModelMinMaxValues(facetedRowModel, column.id),
|
|
1238
|
-
|
|
1239
1059
|
};
|
|
1240
1060
|
},
|
|
1061
|
+
|
|
1241
1062
|
createRow: (row, table) => {
|
|
1242
1063
|
return {
|
|
1243
1064
|
columnFilters: {},
|
|
@@ -1250,34 +1071,27 @@
|
|
|
1250
1071
|
return filterFns.includesString;
|
|
1251
1072
|
},
|
|
1252
1073
|
getGlobalFilterFn: () => {
|
|
1253
|
-
var _table$options$
|
|
1254
|
-
|
|
1074
|
+
var _table$options$filter2;
|
|
1255
1075
|
const {
|
|
1256
1076
|
globalFilterFn: globalFilterFn
|
|
1257
1077
|
} = table.options;
|
|
1258
|
-
return isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === 'auto' ? table.getGlobalAutoFilterFn() : (
|
|
1078
|
+
return isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === 'auto' ? table.getGlobalAutoFilterFn() : ((_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[globalFilterFn]) ?? filterFns[globalFilterFn];
|
|
1259
1079
|
},
|
|
1260
1080
|
setColumnFilters: updater => {
|
|
1261
1081
|
const leafColumns = table.getAllLeafColumns();
|
|
1262
|
-
|
|
1263
1082
|
const updateFn = old => {
|
|
1264
1083
|
var _functionalUpdate;
|
|
1265
|
-
|
|
1266
1084
|
return (_functionalUpdate = functionalUpdate(updater, old)) == null ? void 0 : _functionalUpdate.filter(filter => {
|
|
1267
1085
|
const column = leafColumns.find(d => d.id === filter.id);
|
|
1268
|
-
|
|
1269
1086
|
if (column) {
|
|
1270
1087
|
const filterFn = column.getFilterFn();
|
|
1271
|
-
|
|
1272
1088
|
if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {
|
|
1273
1089
|
return false;
|
|
1274
1090
|
}
|
|
1275
1091
|
}
|
|
1276
|
-
|
|
1277
1092
|
return true;
|
|
1278
1093
|
});
|
|
1279
1094
|
};
|
|
1280
|
-
|
|
1281
1095
|
table.options.onColumnFiltersChange == null ? void 0 : table.options.onColumnFiltersChange(updateFn);
|
|
1282
1096
|
},
|
|
1283
1097
|
setGlobalFilter: updater => {
|
|
@@ -1287,20 +1101,17 @@
|
|
|
1287
1101
|
table.setGlobalFilter(defaultState ? undefined : table.initialState.globalFilter);
|
|
1288
1102
|
},
|
|
1289
1103
|
resetColumnFilters: defaultState => {
|
|
1290
|
-
var _table$initialState
|
|
1291
|
-
|
|
1292
|
-
table.setColumnFilters(defaultState ? [] : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnFilters) != null ? _table$initialState$c : []);
|
|
1104
|
+
var _table$initialState;
|
|
1105
|
+
table.setColumnFilters(defaultState ? [] : ((_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnFilters) ?? []);
|
|
1293
1106
|
},
|
|
1294
1107
|
getPreFilteredRowModel: () => table.getCoreRowModel(),
|
|
1295
1108
|
getFilteredRowModel: () => {
|
|
1296
1109
|
if (!table._getFilteredRowModel && table.options.getFilteredRowModel) {
|
|
1297
1110
|
table._getFilteredRowModel = table.options.getFilteredRowModel(table);
|
|
1298
1111
|
}
|
|
1299
|
-
|
|
1300
1112
|
if (table.options.manualFiltering || !table._getFilteredRowModel) {
|
|
1301
1113
|
return table.getPreFilteredRowModel();
|
|
1302
1114
|
}
|
|
1303
|
-
|
|
1304
1115
|
return table._getFilteredRowModel();
|
|
1305
1116
|
},
|
|
1306
1117
|
_getGlobalFacetedRowModel: table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, '__global__'),
|
|
@@ -1308,7 +1119,6 @@
|
|
|
1308
1119
|
if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {
|
|
1309
1120
|
return table.getPreFilteredRowModel();
|
|
1310
1121
|
}
|
|
1311
|
-
|
|
1312
1122
|
return table._getGlobalFacetedRowModel();
|
|
1313
1123
|
},
|
|
1314
1124
|
_getGlobalFacetedUniqueValues: table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, '__global__'),
|
|
@@ -1316,7 +1126,6 @@
|
|
|
1316
1126
|
if (!table._getGlobalFacetedUniqueValues) {
|
|
1317
1127
|
return new Map();
|
|
1318
1128
|
}
|
|
1319
|
-
|
|
1320
1129
|
return table._getGlobalFacetedUniqueValues();
|
|
1321
1130
|
},
|
|
1322
1131
|
_getGlobalFacetedMinMaxValues: table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, '__global__'),
|
|
@@ -1324,7 +1133,6 @@
|
|
|
1324
1133
|
if (!table._getGlobalFacetedMinMaxValues) {
|
|
1325
1134
|
return;
|
|
1326
1135
|
}
|
|
1327
|
-
|
|
1328
1136
|
return table._getGlobalFacetedMinMaxValues();
|
|
1329
1137
|
}
|
|
1330
1138
|
};
|
|
@@ -1342,37 +1150,31 @@
|
|
|
1342
1150
|
return sum + (typeof nextValue === 'number' ? nextValue : 0);
|
|
1343
1151
|
}, 0);
|
|
1344
1152
|
};
|
|
1345
|
-
|
|
1346
1153
|
const min = (columnId, _leafRows, childRows) => {
|
|
1347
1154
|
let min;
|
|
1348
1155
|
childRows.forEach(row => {
|
|
1349
1156
|
const value = row.getValue(columnId);
|
|
1350
|
-
|
|
1351
1157
|
if (value != null && (min > value || min === undefined && value >= value)) {
|
|
1352
1158
|
min = value;
|
|
1353
1159
|
}
|
|
1354
1160
|
});
|
|
1355
1161
|
return min;
|
|
1356
1162
|
};
|
|
1357
|
-
|
|
1358
1163
|
const max = (columnId, _leafRows, childRows) => {
|
|
1359
1164
|
let max;
|
|
1360
1165
|
childRows.forEach(row => {
|
|
1361
1166
|
const value = row.getValue(columnId);
|
|
1362
|
-
|
|
1363
1167
|
if (value != null && (max < value || max === undefined && value >= value)) {
|
|
1364
1168
|
max = value;
|
|
1365
1169
|
}
|
|
1366
1170
|
});
|
|
1367
1171
|
return max;
|
|
1368
1172
|
};
|
|
1369
|
-
|
|
1370
1173
|
const extent = (columnId, _leafRows, childRows) => {
|
|
1371
1174
|
let min;
|
|
1372
1175
|
let max;
|
|
1373
1176
|
childRows.forEach(row => {
|
|
1374
1177
|
const value = row.getValue(columnId);
|
|
1375
|
-
|
|
1376
1178
|
if (value != null) {
|
|
1377
1179
|
if (min === undefined) {
|
|
1378
1180
|
if (value >= value) min = max = value;
|
|
@@ -1384,13 +1186,11 @@
|
|
|
1384
1186
|
});
|
|
1385
1187
|
return [min, max];
|
|
1386
1188
|
};
|
|
1387
|
-
|
|
1388
1189
|
const mean = (columnId, leafRows) => {
|
|
1389
1190
|
let count = 0;
|
|
1390
1191
|
let sum = 0;
|
|
1391
1192
|
leafRows.forEach(row => {
|
|
1392
1193
|
let value = row.getValue(columnId);
|
|
1393
|
-
|
|
1394
1194
|
if (value != null && (value = +value) >= value) {
|
|
1395
1195
|
++count, sum += value;
|
|
1396
1196
|
}
|
|
@@ -1398,17 +1198,14 @@
|
|
|
1398
1198
|
if (count) return sum / count;
|
|
1399
1199
|
return;
|
|
1400
1200
|
};
|
|
1401
|
-
|
|
1402
1201
|
const median = (columnId, leafRows) => {
|
|
1403
1202
|
if (!leafRows.length) {
|
|
1404
1203
|
return;
|
|
1405
1204
|
}
|
|
1406
|
-
|
|
1407
1205
|
let min = 0;
|
|
1408
1206
|
let max = 0;
|
|
1409
1207
|
leafRows.forEach(row => {
|
|
1410
1208
|
let value = row.getValue(columnId);
|
|
1411
|
-
|
|
1412
1209
|
if (typeof value === 'number') {
|
|
1413
1210
|
min = Math.min(min, value);
|
|
1414
1211
|
max = Math.max(max, value);
|
|
@@ -1416,19 +1213,15 @@
|
|
|
1416
1213
|
});
|
|
1417
1214
|
return (min + max) / 2;
|
|
1418
1215
|
};
|
|
1419
|
-
|
|
1420
1216
|
const unique = (columnId, leafRows) => {
|
|
1421
1217
|
return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
|
|
1422
1218
|
};
|
|
1423
|
-
|
|
1424
1219
|
const uniqueCount = (columnId, leafRows) => {
|
|
1425
1220
|
return new Set(leafRows.map(d => d.getValue(columnId))).size;
|
|
1426
1221
|
};
|
|
1427
|
-
|
|
1428
1222
|
const count = (_columnId, leafRows) => {
|
|
1429
1223
|
return leafRows.length;
|
|
1430
1224
|
};
|
|
1431
|
-
|
|
1432
1225
|
const aggregationFns = {
|
|
1433
1226
|
sum,
|
|
1434
1227
|
min,
|
|
@@ -1442,13 +1235,13 @@
|
|
|
1442
1235
|
};
|
|
1443
1236
|
|
|
1444
1237
|
//
|
|
1238
|
+
|
|
1445
1239
|
const Grouping = {
|
|
1446
1240
|
getDefaultColumnDef: () => {
|
|
1447
1241
|
return {
|
|
1448
1242
|
aggregatedCell: props => {
|
|
1449
|
-
var
|
|
1450
|
-
|
|
1451
|
-
return (_toString = (_props$getValue = props.getValue()) == null ? void 0 : _props$getValue.toString == null ? void 0 : _props$getValue.toString()) != null ? _toString : null;
|
|
1243
|
+
var _props$getValue;
|
|
1244
|
+
return ((_props$getValue = props.getValue()) == null ? void 0 : _props$getValue.toString == null ? void 0 : _props$getValue.toString()) ?? null;
|
|
1452
1245
|
},
|
|
1453
1246
|
aggregationFn: 'auto'
|
|
1454
1247
|
};
|
|
@@ -1473,23 +1266,18 @@
|
|
|
1473
1266
|
if (old != null && old.includes(column.id)) {
|
|
1474
1267
|
return old.filter(d => d !== column.id);
|
|
1475
1268
|
}
|
|
1476
|
-
|
|
1477
|
-
return [...(old != null ? old : []), column.id];
|
|
1269
|
+
return [...(old ?? []), column.id];
|
|
1478
1270
|
});
|
|
1479
1271
|
},
|
|
1480
1272
|
getCanGroup: () => {
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
return (_ref = (_ref2 = (_ref3 = (_column$columnDef$ena = column.columnDef.enableGrouping) != null ? _column$columnDef$ena : true) != null ? _ref3 : table.options.enableGrouping) != null ? _ref2 : true) != null ? _ref : !!column.accessorFn;
|
|
1273
|
+
return column.columnDef.enableGrouping ?? true ?? table.options.enableGrouping ?? true ?? !!column.accessorFn;
|
|
1484
1274
|
},
|
|
1485
1275
|
getIsGrouped: () => {
|
|
1486
1276
|
var _table$getState$group;
|
|
1487
|
-
|
|
1488
1277
|
return (_table$getState$group = table.getState().grouping) == null ? void 0 : _table$getState$group.includes(column.id);
|
|
1489
1278
|
},
|
|
1490
1279
|
getGroupedIndex: () => {
|
|
1491
1280
|
var _table$getState$group2;
|
|
1492
|
-
|
|
1493
1281
|
return (_table$getState$group2 = table.getState().grouping) == null ? void 0 : _table$getState$group2.indexOf(column.id);
|
|
1494
1282
|
},
|
|
1495
1283
|
getToggleGroupingHandler: () => {
|
|
@@ -1502,23 +1290,19 @@
|
|
|
1502
1290
|
getAutoAggregationFn: () => {
|
|
1503
1291
|
const firstRow = table.getCoreRowModel().flatRows[0];
|
|
1504
1292
|
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
|
1505
|
-
|
|
1506
1293
|
if (typeof value === 'number') {
|
|
1507
1294
|
return aggregationFns.sum;
|
|
1508
1295
|
}
|
|
1509
|
-
|
|
1510
1296
|
if (Object.prototype.toString.call(value) === '[object Date]') {
|
|
1511
1297
|
return aggregationFns.extent;
|
|
1512
1298
|
}
|
|
1513
1299
|
},
|
|
1514
1300
|
getAggregationFn: () => {
|
|
1515
|
-
var _table$options$aggreg
|
|
1516
|
-
|
|
1301
|
+
var _table$options$aggreg;
|
|
1517
1302
|
if (!column) {
|
|
1518
1303
|
throw new Error();
|
|
1519
1304
|
}
|
|
1520
|
-
|
|
1521
|
-
return isFunction(column.columnDef.aggregationFn) ? column.columnDef.aggregationFn : column.columnDef.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_table$options$aggreg = (_table$options$aggreg2 = table.options.aggregationFns) == null ? void 0 : _table$options$aggreg2[column.columnDef.aggregationFn]) != null ? _table$options$aggreg : aggregationFns[column.columnDef.aggregationFn];
|
|
1305
|
+
return isFunction(column.columnDef.aggregationFn) ? column.columnDef.aggregationFn : column.columnDef.aggregationFn === 'auto' ? column.getAutoAggregationFn() : ((_table$options$aggreg = table.options.aggregationFns) == null ? void 0 : _table$options$aggreg[column.columnDef.aggregationFn]) ?? aggregationFns[column.columnDef.aggregationFn];
|
|
1522
1306
|
}
|
|
1523
1307
|
};
|
|
1524
1308
|
},
|
|
@@ -1526,20 +1310,17 @@
|
|
|
1526
1310
|
return {
|
|
1527
1311
|
setGrouping: updater => table.options.onGroupingChange == null ? void 0 : table.options.onGroupingChange(updater),
|
|
1528
1312
|
resetGrouping: defaultState => {
|
|
1529
|
-
var _table$initialState
|
|
1530
|
-
|
|
1531
|
-
table.setGrouping(defaultState ? [] : (_table$initialState$g = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.grouping) != null ? _table$initialState$g : []);
|
|
1313
|
+
var _table$initialState;
|
|
1314
|
+
table.setGrouping(defaultState ? [] : ((_table$initialState = table.initialState) == null ? void 0 : _table$initialState.grouping) ?? []);
|
|
1532
1315
|
},
|
|
1533
1316
|
getPreGroupedRowModel: () => table.getFilteredRowModel(),
|
|
1534
1317
|
getGroupedRowModel: () => {
|
|
1535
1318
|
if (!table._getGroupedRowModel && table.options.getGroupedRowModel) {
|
|
1536
1319
|
table._getGroupedRowModel = table.options.getGroupedRowModel(table);
|
|
1537
1320
|
}
|
|
1538
|
-
|
|
1539
1321
|
if (table.options.manualGrouping || !table._getGroupedRowModel) {
|
|
1540
1322
|
return table.getPreGroupedRowModel();
|
|
1541
1323
|
}
|
|
1542
|
-
|
|
1543
1324
|
return table._getGroupedRowModel();
|
|
1544
1325
|
}
|
|
1545
1326
|
};
|
|
@@ -1551,13 +1332,11 @@
|
|
|
1551
1332
|
};
|
|
1552
1333
|
},
|
|
1553
1334
|
createCell: (cell, column, row, table) => {
|
|
1554
|
-
|
|
1555
1335
|
return {
|
|
1556
1336
|
getIsGrouped: () => column.getIsGrouped() && column.id === row.groupingColumnId,
|
|
1557
1337
|
getIsPlaceholder: () => !cell.getIsGrouped() && column.getIsGrouped(),
|
|
1558
1338
|
getIsAggregated: () => {
|
|
1559
1339
|
var _row$subRows;
|
|
1560
|
-
|
|
1561
1340
|
return !cell.getIsGrouped() && !cell.getIsPlaceholder() && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
|
|
1562
1341
|
}
|
|
1563
1342
|
};
|
|
@@ -1567,18 +1346,16 @@
|
|
|
1567
1346
|
if (!(grouping != null && grouping.length) || !groupedColumnMode) {
|
|
1568
1347
|
return leafColumns;
|
|
1569
1348
|
}
|
|
1570
|
-
|
|
1571
1349
|
const nonGroupingColumns = leafColumns.filter(col => !grouping.includes(col.id));
|
|
1572
|
-
|
|
1573
1350
|
if (groupedColumnMode === 'remove') {
|
|
1574
1351
|
return nonGroupingColumns;
|
|
1575
1352
|
}
|
|
1576
|
-
|
|
1577
1353
|
const groupingColumns = grouping.map(g => leafColumns.find(col => col.id === g)).filter(Boolean);
|
|
1578
1354
|
return [...groupingColumns, ...nonGroupingColumns];
|
|
1579
1355
|
}
|
|
1580
1356
|
|
|
1581
1357
|
//
|
|
1358
|
+
|
|
1582
1359
|
const Ordering = {
|
|
1583
1360
|
getInitialState: state => {
|
|
1584
1361
|
return {
|
|
@@ -1595,58 +1372,59 @@
|
|
|
1595
1372
|
return {
|
|
1596
1373
|
setColumnOrder: updater => table.options.onColumnOrderChange == null ? void 0 : table.options.onColumnOrderChange(updater),
|
|
1597
1374
|
resetColumnOrder: defaultState => {
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
table.setColumnOrder(defaultState ? [] : (_table$initialState$c = table.initialState.columnOrder) != null ? _table$initialState$c : []);
|
|
1375
|
+
table.setColumnOrder(defaultState ? [] : table.initialState.columnOrder ?? []);
|
|
1601
1376
|
},
|
|
1602
1377
|
_getOrderColumnsFn: memo(() => [table.getState().columnOrder, table.getState().grouping, table.options.groupedColumnMode], (columnOrder, grouping, groupedColumnMode) => columns => {
|
|
1603
1378
|
// Sort grouped columns to the start of the column list
|
|
1604
1379
|
// before the headers are built
|
|
1605
|
-
let orderedColumns = [];
|
|
1380
|
+
let orderedColumns = [];
|
|
1606
1381
|
|
|
1382
|
+
// If there is no order, return the normal columns
|
|
1607
1383
|
if (!(columnOrder != null && columnOrder.length)) {
|
|
1608
1384
|
orderedColumns = columns;
|
|
1609
1385
|
} else {
|
|
1610
|
-
const columnOrderCopy = [...columnOrder];
|
|
1386
|
+
const columnOrderCopy = [...columnOrder];
|
|
1611
1387
|
|
|
1612
|
-
|
|
1613
|
-
|
|
1388
|
+
// If there is an order, make a copy of the columns
|
|
1389
|
+
const columnsCopy = [...columns];
|
|
1614
1390
|
|
|
1391
|
+
// And make a new ordered array of the columns
|
|
1392
|
+
|
|
1393
|
+
// Loop over the columns and place them in order into the new array
|
|
1615
1394
|
while (columnsCopy.length && columnOrderCopy.length) {
|
|
1616
1395
|
const targetColumnId = columnOrderCopy.shift();
|
|
1617
1396
|
const foundIndex = columnsCopy.findIndex(d => d.id === targetColumnId);
|
|
1618
|
-
|
|
1619
1397
|
if (foundIndex > -1) {
|
|
1620
1398
|
orderedColumns.push(columnsCopy.splice(foundIndex, 1)[0]);
|
|
1621
1399
|
}
|
|
1622
|
-
}
|
|
1623
|
-
|
|
1400
|
+
}
|
|
1624
1401
|
|
|
1402
|
+
// If there are any columns left, add them to the end
|
|
1625
1403
|
orderedColumns = [...orderedColumns, ...columnsCopy];
|
|
1626
1404
|
}
|
|
1627
|
-
|
|
1628
1405
|
return orderColumns(orderedColumns, grouping, groupedColumnMode);
|
|
1629
1406
|
}, {
|
|
1630
|
-
key: 'getOrderColumnsFn'
|
|
1631
|
-
|
|
1407
|
+
key: 'getOrderColumnsFn'
|
|
1408
|
+
// debug: () => table.options.debugAll ?? table.options.debugTable,
|
|
1632
1409
|
})
|
|
1633
1410
|
};
|
|
1634
1411
|
}
|
|
1635
1412
|
};
|
|
1636
1413
|
|
|
1637
1414
|
//
|
|
1415
|
+
|
|
1638
1416
|
const defaultPageIndex = 0;
|
|
1639
1417
|
const defaultPageSize = 10;
|
|
1640
|
-
|
|
1641
1418
|
const getDefaultPaginationState = () => ({
|
|
1642
1419
|
pageIndex: defaultPageIndex,
|
|
1643
1420
|
pageSize: defaultPageSize
|
|
1644
1421
|
});
|
|
1645
|
-
|
|
1646
1422
|
const Pagination = {
|
|
1647
1423
|
getInitialState: state => {
|
|
1648
|
-
return {
|
|
1649
|
-
|
|
1424
|
+
return {
|
|
1425
|
+
...state,
|
|
1426
|
+
pagination: {
|
|
1427
|
+
...getDefaultPaginationState(),
|
|
1650
1428
|
...(state == null ? void 0 : state.pagination)
|
|
1651
1429
|
}
|
|
1652
1430
|
};
|
|
@@ -1661,20 +1439,15 @@
|
|
|
1661
1439
|
let queued = false;
|
|
1662
1440
|
return {
|
|
1663
1441
|
_autoResetPageIndex: () => {
|
|
1664
|
-
var _ref, _table$options$autoRe;
|
|
1665
|
-
|
|
1666
1442
|
if (!registered) {
|
|
1667
1443
|
table._queue(() => {
|
|
1668
1444
|
registered = true;
|
|
1669
1445
|
});
|
|
1670
|
-
|
|
1671
1446
|
return;
|
|
1672
1447
|
}
|
|
1673
|
-
|
|
1674
|
-
if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetPageIndex) != null ? _ref : !table.options.manualPagination) {
|
|
1448
|
+
if (table.options.autoResetAll ?? table.options.autoResetPageIndex ?? !table.options.manualPagination) {
|
|
1675
1449
|
if (queued) return;
|
|
1676
1450
|
queued = true;
|
|
1677
|
-
|
|
1678
1451
|
table._queue(() => {
|
|
1679
1452
|
table.resetPageIndex();
|
|
1680
1453
|
queued = false;
|
|
@@ -1686,73 +1459,61 @@
|
|
|
1686
1459
|
let newState = functionalUpdate(updater, old);
|
|
1687
1460
|
return newState;
|
|
1688
1461
|
};
|
|
1689
|
-
|
|
1690
1462
|
return table.options.onPaginationChange == null ? void 0 : table.options.onPaginationChange(safeUpdater);
|
|
1691
1463
|
},
|
|
1692
1464
|
resetPagination: defaultState => {
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
table.setPagination(defaultState ? getDefaultPaginationState() : (_table$initialState$p = table.initialState.pagination) != null ? _table$initialState$p : getDefaultPaginationState());
|
|
1465
|
+
table.setPagination(defaultState ? getDefaultPaginationState() : table.initialState.pagination ?? getDefaultPaginationState());
|
|
1696
1466
|
},
|
|
1697
1467
|
setPageIndex: updater => {
|
|
1698
1468
|
table.setPagination(old => {
|
|
1699
1469
|
let pageIndex = functionalUpdate(updater, old.pageIndex);
|
|
1700
1470
|
const maxPageIndex = typeof table.options.pageCount === 'undefined' || table.options.pageCount === -1 ? Number.MAX_SAFE_INTEGER : table.options.pageCount - 1;
|
|
1701
1471
|
pageIndex = Math.min(Math.max(0, pageIndex), maxPageIndex);
|
|
1702
|
-
return {
|
|
1472
|
+
return {
|
|
1473
|
+
...old,
|
|
1703
1474
|
pageIndex
|
|
1704
1475
|
};
|
|
1705
1476
|
});
|
|
1706
1477
|
},
|
|
1707
1478
|
resetPageIndex: defaultState => {
|
|
1708
|
-
var _table$initialState
|
|
1709
|
-
|
|
1710
|
-
table.setPageIndex(defaultState ? defaultPageIndex : (_table$initialState$p2 = (_table$initialState = table.initialState) == null ? void 0 : (_table$initialState$p3 = _table$initialState.pagination) == null ? void 0 : _table$initialState$p3.pageIndex) != null ? _table$initialState$p2 : defaultPageIndex);
|
|
1479
|
+
var _table$initialState, _table$initialState$p;
|
|
1480
|
+
table.setPageIndex(defaultState ? defaultPageIndex : ((_table$initialState = table.initialState) == null ? void 0 : (_table$initialState$p = _table$initialState.pagination) == null ? void 0 : _table$initialState$p.pageIndex) ?? defaultPageIndex);
|
|
1711
1481
|
},
|
|
1712
1482
|
resetPageSize: defaultState => {
|
|
1713
|
-
var _table$
|
|
1714
|
-
|
|
1715
|
-
table.setPageSize(defaultState ? defaultPageSize : (_table$initialState$p4 = (_table$initialState2 = table.initialState) == null ? void 0 : (_table$initialState2$ = _table$initialState2.pagination) == null ? void 0 : _table$initialState2$.pageSize) != null ? _table$initialState$p4 : defaultPageSize);
|
|
1483
|
+
var _table$initialState2, _table$initialState2$;
|
|
1484
|
+
table.setPageSize(defaultState ? defaultPageSize : ((_table$initialState2 = table.initialState) == null ? void 0 : (_table$initialState2$ = _table$initialState2.pagination) == null ? void 0 : _table$initialState2$.pageSize) ?? defaultPageSize);
|
|
1716
1485
|
},
|
|
1717
1486
|
setPageSize: updater => {
|
|
1718
1487
|
table.setPagination(old => {
|
|
1719
1488
|
const pageSize = Math.max(1, functionalUpdate(updater, old.pageSize));
|
|
1720
1489
|
const topRowIndex = old.pageSize * old.pageIndex;
|
|
1721
1490
|
const pageIndex = Math.floor(topRowIndex / pageSize);
|
|
1722
|
-
return {
|
|
1491
|
+
return {
|
|
1492
|
+
...old,
|
|
1723
1493
|
pageIndex,
|
|
1724
1494
|
pageSize
|
|
1725
1495
|
};
|
|
1726
1496
|
});
|
|
1727
1497
|
},
|
|
1728
1498
|
setPageCount: updater => table.setPagination(old => {
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
let newPageCount = functionalUpdate(updater, (_table$options$pageCo = table.options.pageCount) != null ? _table$options$pageCo : -1);
|
|
1732
|
-
|
|
1499
|
+
let newPageCount = functionalUpdate(updater, table.options.pageCount ?? -1);
|
|
1733
1500
|
if (typeof newPageCount === 'number') {
|
|
1734
1501
|
newPageCount = Math.max(-1, newPageCount);
|
|
1735
1502
|
}
|
|
1736
|
-
|
|
1737
|
-
|
|
1503
|
+
return {
|
|
1504
|
+
...old,
|
|
1738
1505
|
pageCount: newPageCount
|
|
1739
1506
|
};
|
|
1740
1507
|
}),
|
|
1741
1508
|
getPageOptions: memo(() => [table.getPageCount()], pageCount => {
|
|
1742
1509
|
let pageOptions = [];
|
|
1743
|
-
|
|
1744
1510
|
if (pageCount && pageCount > 0) {
|
|
1745
1511
|
pageOptions = [...new Array(pageCount)].fill(null).map((_, i) => i);
|
|
1746
1512
|
}
|
|
1747
|
-
|
|
1748
1513
|
return pageOptions;
|
|
1749
1514
|
}, {
|
|
1750
1515
|
key: 'getPageOptions',
|
|
1751
|
-
debug: () =>
|
|
1752
|
-
var _table$options$debugA;
|
|
1753
|
-
|
|
1754
|
-
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugTable;
|
|
1755
|
-
}
|
|
1516
|
+
debug: () => table.options.debugAll ?? table.options.debugTable
|
|
1756
1517
|
}),
|
|
1757
1518
|
getCanPreviousPage: () => table.getState().pagination.pageIndex > 0,
|
|
1758
1519
|
getCanNextPage: () => {
|
|
@@ -1760,15 +1521,12 @@
|
|
|
1760
1521
|
pageIndex
|
|
1761
1522
|
} = table.getState().pagination;
|
|
1762
1523
|
const pageCount = table.getPageCount();
|
|
1763
|
-
|
|
1764
1524
|
if (pageCount === -1) {
|
|
1765
1525
|
return true;
|
|
1766
1526
|
}
|
|
1767
|
-
|
|
1768
1527
|
if (pageCount === 0) {
|
|
1769
1528
|
return false;
|
|
1770
1529
|
}
|
|
1771
|
-
|
|
1772
1530
|
return pageIndex < pageCount - 1;
|
|
1773
1531
|
},
|
|
1774
1532
|
previousPage: () => {
|
|
@@ -1784,28 +1542,24 @@
|
|
|
1784
1542
|
if (!table._getPaginationRowModel && table.options.getPaginationRowModel) {
|
|
1785
1543
|
table._getPaginationRowModel = table.options.getPaginationRowModel(table);
|
|
1786
1544
|
}
|
|
1787
|
-
|
|
1788
1545
|
if (table.options.manualPagination || !table._getPaginationRowModel) {
|
|
1789
1546
|
return table.getPrePaginationRowModel();
|
|
1790
1547
|
}
|
|
1791
|
-
|
|
1792
1548
|
return table._getPaginationRowModel();
|
|
1793
1549
|
},
|
|
1794
1550
|
getPageCount: () => {
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
return (_table$options$pageCo2 = table.options.pageCount) != null ? _table$options$pageCo2 : Math.ceil(table.getPrePaginationRowModel().rows.length / table.getState().pagination.pageSize);
|
|
1551
|
+
return table.options.pageCount ?? Math.ceil(table.getPrePaginationRowModel().rows.length / table.getState().pagination.pageSize);
|
|
1798
1552
|
}
|
|
1799
1553
|
};
|
|
1800
1554
|
}
|
|
1801
1555
|
};
|
|
1802
1556
|
|
|
1803
1557
|
//
|
|
1558
|
+
|
|
1804
1559
|
const getDefaultPinningState = () => ({
|
|
1805
1560
|
left: [],
|
|
1806
1561
|
right: []
|
|
1807
1562
|
});
|
|
1808
|
-
|
|
1809
1563
|
const Pinning = {
|
|
1810
1564
|
getInitialState: state => {
|
|
1811
1565
|
return {
|
|
@@ -1823,39 +1577,27 @@
|
|
|
1823
1577
|
pin: position => {
|
|
1824
1578
|
const columnIds = column.getLeafColumns().map(d => d.id).filter(Boolean);
|
|
1825
1579
|
table.setColumnPinning(old => {
|
|
1826
|
-
var _old$left3, _old$right3;
|
|
1827
|
-
|
|
1828
1580
|
if (position === 'right') {
|
|
1829
|
-
var _old$left, _old$right;
|
|
1830
|
-
|
|
1831
1581
|
return {
|
|
1832
|
-
left: ((
|
|
1833
|
-
right: [...((
|
|
1582
|
+
left: ((old == null ? void 0 : old.left) ?? []).filter(d => !(columnIds != null && columnIds.includes(d))),
|
|
1583
|
+
right: [...((old == null ? void 0 : old.right) ?? []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds]
|
|
1834
1584
|
};
|
|
1835
1585
|
}
|
|
1836
|
-
|
|
1837
1586
|
if (position === 'left') {
|
|
1838
|
-
var _old$left2, _old$right2;
|
|
1839
|
-
|
|
1840
1587
|
return {
|
|
1841
|
-
left: [...((
|
|
1842
|
-
right: ((
|
|
1588
|
+
left: [...((old == null ? void 0 : old.left) ?? []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds],
|
|
1589
|
+
right: ((old == null ? void 0 : old.right) ?? []).filter(d => !(columnIds != null && columnIds.includes(d)))
|
|
1843
1590
|
};
|
|
1844
1591
|
}
|
|
1845
|
-
|
|
1846
1592
|
return {
|
|
1847
|
-
left: ((
|
|
1848
|
-
right: ((
|
|
1593
|
+
left: ((old == null ? void 0 : old.left) ?? []).filter(d => !(columnIds != null && columnIds.includes(d))),
|
|
1594
|
+
right: ((old == null ? void 0 : old.right) ?? []).filter(d => !(columnIds != null && columnIds.includes(d)))
|
|
1849
1595
|
};
|
|
1850
1596
|
});
|
|
1851
1597
|
},
|
|
1852
1598
|
getCanPin: () => {
|
|
1853
1599
|
const leafColumns = column.getLeafColumns();
|
|
1854
|
-
return leafColumns.some(d =>
|
|
1855
|
-
var _d$columnDef$enablePi, _table$options$enable;
|
|
1856
|
-
|
|
1857
|
-
return ((_d$columnDef$enablePi = d.columnDef.enablePinning) != null ? _d$columnDef$enablePi : true) && ((_table$options$enable = table.options.enablePinning) != null ? _table$options$enable : true);
|
|
1858
|
-
});
|
|
1600
|
+
return leafColumns.some(d => (d.columnDef.enablePinning ?? true) && (table.options.enablePinning ?? true));
|
|
1859
1601
|
},
|
|
1860
1602
|
getIsPinned: () => {
|
|
1861
1603
|
const leafColumnIds = column.getLeafColumns().map(d => d.id);
|
|
@@ -1868,51 +1610,40 @@
|
|
|
1868
1610
|
return isLeft ? 'left' : isRight ? 'right' : false;
|
|
1869
1611
|
},
|
|
1870
1612
|
getPinnedIndex: () => {
|
|
1871
|
-
var _table$getState$colum, _table$getState$colum2
|
|
1872
|
-
|
|
1613
|
+
var _table$getState$colum, _table$getState$colum2;
|
|
1873
1614
|
const position = column.getIsPinned();
|
|
1874
|
-
return position ? (_table$getState$colum =
|
|
1615
|
+
return position ? ((_table$getState$colum = table.getState().columnPinning) == null ? void 0 : (_table$getState$colum2 = _table$getState$colum[position]) == null ? void 0 : _table$getState$colum2.indexOf(column.id)) ?? -1 : 0;
|
|
1875
1616
|
}
|
|
1876
1617
|
};
|
|
1877
1618
|
},
|
|
1878
1619
|
createRow: (row, table) => {
|
|
1879
1620
|
return {
|
|
1880
1621
|
getCenterVisibleCells: memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allCells, left, right) => {
|
|
1881
|
-
const leftAndRight = [...(left
|
|
1622
|
+
const leftAndRight = [...(left ?? []), ...(right ?? [])];
|
|
1882
1623
|
return allCells.filter(d => !leftAndRight.includes(d.column.id));
|
|
1883
1624
|
}, {
|
|
1884
1625
|
key: "development" === 'production' ,
|
|
1885
|
-
debug: () =>
|
|
1886
|
-
var _table$options$debugA;
|
|
1887
|
-
|
|
1888
|
-
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugRows;
|
|
1889
|
-
}
|
|
1626
|
+
debug: () => table.options.debugAll ?? table.options.debugRows
|
|
1890
1627
|
}),
|
|
1891
1628
|
getLeftVisibleCells: memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left,,], (allCells, left) => {
|
|
1892
|
-
const cells = (left
|
|
1629
|
+
const cells = (left ?? []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
|
|
1630
|
+
...d,
|
|
1893
1631
|
position: 'left'
|
|
1894
1632
|
}));
|
|
1895
1633
|
return cells;
|
|
1896
1634
|
}, {
|
|
1897
1635
|
key: "development" === 'production' ,
|
|
1898
|
-
debug: () =>
|
|
1899
|
-
var _table$options$debugA2;
|
|
1900
|
-
|
|
1901
|
-
return (_table$options$debugA2 = table.options.debugAll) != null ? _table$options$debugA2 : table.options.debugRows;
|
|
1902
|
-
}
|
|
1636
|
+
debug: () => table.options.debugAll ?? table.options.debugRows
|
|
1903
1637
|
}),
|
|
1904
1638
|
getRightVisibleCells: memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.right], (allCells, right) => {
|
|
1905
|
-
const cells = (right
|
|
1639
|
+
const cells = (right ?? []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
|
|
1640
|
+
...d,
|
|
1906
1641
|
position: 'right'
|
|
1907
1642
|
}));
|
|
1908
1643
|
return cells;
|
|
1909
1644
|
}, {
|
|
1910
1645
|
key: "development" === 'production' ,
|
|
1911
|
-
debug: () =>
|
|
1912
|
-
var _table$options$debugA3;
|
|
1913
|
-
|
|
1914
|
-
return (_table$options$debugA3 = table.options.debugAll) != null ? _table$options$debugA3 : table.options.debugRows;
|
|
1915
|
-
}
|
|
1646
|
+
debug: () => table.options.debugAll ?? table.options.debugRows
|
|
1916
1647
|
})
|
|
1917
1648
|
};
|
|
1918
1649
|
},
|
|
@@ -1920,59 +1651,43 @@
|
|
|
1920
1651
|
return {
|
|
1921
1652
|
setColumnPinning: updater => table.options.onColumnPinningChange == null ? void 0 : table.options.onColumnPinningChange(updater),
|
|
1922
1653
|
resetColumnPinning: defaultState => {
|
|
1923
|
-
var _table$initialState
|
|
1924
|
-
|
|
1925
|
-
return table.setColumnPinning(defaultState ? getDefaultPinningState() : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnPinning) != null ? _table$initialState$c : getDefaultPinningState());
|
|
1654
|
+
var _table$initialState;
|
|
1655
|
+
return table.setColumnPinning(defaultState ? getDefaultPinningState() : ((_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnPinning) ?? getDefaultPinningState());
|
|
1926
1656
|
},
|
|
1927
1657
|
getIsSomeColumnsPinned: position => {
|
|
1928
1658
|
var _pinningState$positio;
|
|
1929
|
-
|
|
1930
1659
|
const pinningState = table.getState().columnPinning;
|
|
1931
|
-
|
|
1932
1660
|
if (!position) {
|
|
1933
1661
|
var _pinningState$left, _pinningState$right;
|
|
1934
|
-
|
|
1935
1662
|
return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
|
|
1936
1663
|
}
|
|
1937
|
-
|
|
1938
1664
|
return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
|
|
1939
1665
|
},
|
|
1940
1666
|
getLeftLeafColumns: memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left], (allColumns, left) => {
|
|
1941
|
-
return (left
|
|
1667
|
+
return (left ?? []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
|
|
1942
1668
|
}, {
|
|
1943
1669
|
key: 'getLeftLeafColumns',
|
|
1944
|
-
debug: () =>
|
|
1945
|
-
var _table$options$debugA4;
|
|
1946
|
-
|
|
1947
|
-
return (_table$options$debugA4 = table.options.debugAll) != null ? _table$options$debugA4 : table.options.debugColumns;
|
|
1948
|
-
}
|
|
1670
|
+
debug: () => table.options.debugAll ?? table.options.debugColumns
|
|
1949
1671
|
}),
|
|
1950
1672
|
getRightLeafColumns: memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.right], (allColumns, right) => {
|
|
1951
|
-
return (right
|
|
1673
|
+
return (right ?? []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
|
|
1952
1674
|
}, {
|
|
1953
1675
|
key: 'getRightLeafColumns',
|
|
1954
|
-
debug: () =>
|
|
1955
|
-
var _table$options$debugA5;
|
|
1956
|
-
|
|
1957
|
-
return (_table$options$debugA5 = table.options.debugAll) != null ? _table$options$debugA5 : table.options.debugColumns;
|
|
1958
|
-
}
|
|
1676
|
+
debug: () => table.options.debugAll ?? table.options.debugColumns
|
|
1959
1677
|
}),
|
|
1960
1678
|
getCenterLeafColumns: memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, left, right) => {
|
|
1961
|
-
const leftAndRight = [...(left
|
|
1679
|
+
const leftAndRight = [...(left ?? []), ...(right ?? [])];
|
|
1962
1680
|
return allColumns.filter(d => !leftAndRight.includes(d.id));
|
|
1963
1681
|
}, {
|
|
1964
1682
|
key: 'getCenterLeafColumns',
|
|
1965
|
-
debug: () =>
|
|
1966
|
-
var _table$options$debugA6;
|
|
1967
|
-
|
|
1968
|
-
return (_table$options$debugA6 = table.options.debugAll) != null ? _table$options$debugA6 : table.options.debugColumns;
|
|
1969
|
-
}
|
|
1683
|
+
debug: () => table.options.debugAll ?? table.options.debugColumns
|
|
1970
1684
|
})
|
|
1971
1685
|
};
|
|
1972
1686
|
}
|
|
1973
1687
|
};
|
|
1974
1688
|
|
|
1975
1689
|
//
|
|
1690
|
+
|
|
1976
1691
|
const RowSelection = {
|
|
1977
1692
|
getInitialState: state => {
|
|
1978
1693
|
return {
|
|
@@ -1985,34 +1700,32 @@
|
|
|
1985
1700
|
onRowSelectionChange: makeStateUpdater('rowSelection', table),
|
|
1986
1701
|
enableRowSelection: true,
|
|
1987
1702
|
enableMultiRowSelection: true,
|
|
1988
|
-
enableSubRowSelection: true
|
|
1703
|
+
enableSubRowSelection: true
|
|
1704
|
+
// enableGroupingRowSelection: false,
|
|
1989
1705
|
// isAdditiveSelectEvent: (e: unknown) => !!e.metaKey,
|
|
1990
1706
|
// isInclusiveSelectEvent: (e: unknown) => !!e.shiftKey,
|
|
1991
|
-
|
|
1992
1707
|
};
|
|
1993
1708
|
},
|
|
1709
|
+
|
|
1994
1710
|
createTable: table => {
|
|
1995
1711
|
return {
|
|
1996
1712
|
setRowSelection: updater => table.options.onRowSelectionChange == null ? void 0 : table.options.onRowSelectionChange(updater),
|
|
1997
|
-
resetRowSelection: defaultState => {
|
|
1998
|
-
var _table$initialState$r;
|
|
1999
|
-
|
|
2000
|
-
return table.setRowSelection(defaultState ? {} : (_table$initialState$r = table.initialState.rowSelection) != null ? _table$initialState$r : {});
|
|
2001
|
-
},
|
|
1713
|
+
resetRowSelection: defaultState => table.setRowSelection(defaultState ? {} : table.initialState.rowSelection ?? {}),
|
|
2002
1714
|
toggleAllRowsSelected: value => {
|
|
2003
1715
|
table.setRowSelection(old => {
|
|
2004
1716
|
value = typeof value !== 'undefined' ? value : !table.getIsAllRowsSelected();
|
|
2005
|
-
const rowSelection = {
|
|
1717
|
+
const rowSelection = {
|
|
1718
|
+
...old
|
|
2006
1719
|
};
|
|
2007
|
-
const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows;
|
|
2008
|
-
// All of the rows are flat already, so it wouldn't be worth it
|
|
1720
|
+
const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows;
|
|
2009
1721
|
|
|
1722
|
+
// We don't use `mutateRowIsSelected` here for performance reasons.
|
|
1723
|
+
// All of the rows are flat already, so it wouldn't be worth it
|
|
2010
1724
|
if (value) {
|
|
2011
1725
|
preGroupedFlatRows.forEach(row => {
|
|
2012
1726
|
if (!row.getCanSelect()) {
|
|
2013
1727
|
return;
|
|
2014
1728
|
}
|
|
2015
|
-
|
|
2016
1729
|
rowSelection[row.id] = true;
|
|
2017
1730
|
});
|
|
2018
1731
|
} else {
|
|
@@ -2020,13 +1733,13 @@
|
|
|
2020
1733
|
delete rowSelection[row.id];
|
|
2021
1734
|
});
|
|
2022
1735
|
}
|
|
2023
|
-
|
|
2024
1736
|
return rowSelection;
|
|
2025
1737
|
});
|
|
2026
1738
|
},
|
|
2027
1739
|
toggleAllPageRowsSelected: value => table.setRowSelection(old => {
|
|
2028
1740
|
const resolvedValue = typeof value !== 'undefined' ? value : !table.getIsAllPageRowsSelected();
|
|
2029
|
-
const rowSelection = {
|
|
1741
|
+
const rowSelection = {
|
|
1742
|
+
...old
|
|
2030
1743
|
};
|
|
2031
1744
|
table.getRowModel().rows.forEach(row => {
|
|
2032
1745
|
mutateRowIsSelected(rowSelection, row.id, resolvedValue, table);
|
|
@@ -2039,6 +1752,7 @@
|
|
|
2039
1752
|
// rowsById,
|
|
2040
1753
|
// options: { selectGroupingRows, selectSubRows },
|
|
2041
1754
|
// } = table
|
|
1755
|
+
|
|
2042
1756
|
// const findSelectedRow = (rows: Row[]) => {
|
|
2043
1757
|
// let found
|
|
2044
1758
|
// rows.find(d => {
|
|
@@ -2055,10 +1769,13 @@
|
|
|
2055
1769
|
// })
|
|
2056
1770
|
// return found
|
|
2057
1771
|
// }
|
|
1772
|
+
|
|
2058
1773
|
// const firstRow = findSelectedRow(rows) || rows[0]
|
|
2059
1774
|
// const lastRow = rowsById[rowId]
|
|
1775
|
+
|
|
2060
1776
|
// let include = false
|
|
2061
1777
|
// const selectedRowIds = {}
|
|
1778
|
+
|
|
2062
1779
|
// const addRow = (row: Row) => {
|
|
2063
1780
|
// mutateRowIsSelected(selectedRowIds, row.id, true, {
|
|
2064
1781
|
// rowsById,
|
|
@@ -2066,9 +1783,11 @@
|
|
|
2066
1783
|
// selectSubRows: selectSubRows!,
|
|
2067
1784
|
// })
|
|
2068
1785
|
// }
|
|
1786
|
+
|
|
2069
1787
|
// table.rows.forEach(row => {
|
|
2070
1788
|
// const isFirstRow = row.id === firstRow.id
|
|
2071
1789
|
// const isLastRow = row.id === lastRow.id
|
|
1790
|
+
|
|
2072
1791
|
// if (isFirstRow || isLastRow) {
|
|
2073
1792
|
// if (!include) {
|
|
2074
1793
|
// include = true
|
|
@@ -2077,10 +1796,12 @@
|
|
|
2077
1796
|
// include = false
|
|
2078
1797
|
// }
|
|
2079
1798
|
// }
|
|
1799
|
+
|
|
2080
1800
|
// if (include) {
|
|
2081
1801
|
// addRow(row)
|
|
2082
1802
|
// }
|
|
2083
1803
|
// })
|
|
1804
|
+
|
|
2084
1805
|
// table.setRowSelection(selectedRowIds)
|
|
2085
1806
|
// },
|
|
2086
1807
|
getPreSelectedRowModel: () => table.getCoreRowModel(),
|
|
@@ -2092,15 +1813,10 @@
|
|
|
2092
1813
|
rowsById: {}
|
|
2093
1814
|
};
|
|
2094
1815
|
}
|
|
2095
|
-
|
|
2096
1816
|
return selectRowsFn(table, rowModel);
|
|
2097
1817
|
}, {
|
|
2098
1818
|
key: 'getSelectedRowModel',
|
|
2099
|
-
debug: () =>
|
|
2100
|
-
var _table$options$debugA;
|
|
2101
|
-
|
|
2102
|
-
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugTable;
|
|
2103
|
-
}
|
|
1819
|
+
debug: () => table.options.debugAll ?? table.options.debugTable
|
|
2104
1820
|
}),
|
|
2105
1821
|
getFilteredSelectedRowModel: memo(() => [table.getState().rowSelection, table.getFilteredRowModel()], (rowSelection, rowModel) => {
|
|
2106
1822
|
if (!Object.keys(rowSelection).length) {
|
|
@@ -2110,15 +1826,10 @@
|
|
|
2110
1826
|
rowsById: {}
|
|
2111
1827
|
};
|
|
2112
1828
|
}
|
|
2113
|
-
|
|
2114
1829
|
return selectRowsFn(table, rowModel);
|
|
2115
1830
|
}, {
|
|
2116
1831
|
key: "development" === 'production' ,
|
|
2117
|
-
debug: () =>
|
|
2118
|
-
var _table$options$debugA2;
|
|
2119
|
-
|
|
2120
|
-
return (_table$options$debugA2 = table.options.debugAll) != null ? _table$options$debugA2 : table.options.debugTable;
|
|
2121
|
-
}
|
|
1832
|
+
debug: () => table.options.debugAll ?? table.options.debugTable
|
|
2122
1833
|
}),
|
|
2123
1834
|
getGroupedSelectedRowModel: memo(() => [table.getState().rowSelection, table.getSortedRowModel()], (rowSelection, rowModel) => {
|
|
2124
1835
|
if (!Object.keys(rowSelection).length) {
|
|
@@ -2128,40 +1839,38 @@
|
|
|
2128
1839
|
rowsById: {}
|
|
2129
1840
|
};
|
|
2130
1841
|
}
|
|
2131
|
-
|
|
2132
1842
|
return selectRowsFn(table, rowModel);
|
|
2133
1843
|
}, {
|
|
2134
1844
|
key: "development" === 'production' ,
|
|
2135
|
-
debug: () =>
|
|
2136
|
-
var _table$options$debugA3;
|
|
2137
|
-
|
|
2138
|
-
return (_table$options$debugA3 = table.options.debugAll) != null ? _table$options$debugA3 : table.options.debugTable;
|
|
2139
|
-
}
|
|
1845
|
+
debug: () => table.options.debugAll ?? table.options.debugTable
|
|
2140
1846
|
}),
|
|
2141
1847
|
///
|
|
1848
|
+
|
|
2142
1849
|
// getGroupingRowCanSelect: rowId => {
|
|
2143
1850
|
// const row = table.getRow(rowId)
|
|
1851
|
+
|
|
2144
1852
|
// if (!row) {
|
|
2145
1853
|
// throw new Error()
|
|
2146
1854
|
// }
|
|
1855
|
+
|
|
2147
1856
|
// if (typeof table.options.enableGroupingRowSelection === 'function') {
|
|
2148
1857
|
// return table.options.enableGroupingRowSelection(row)
|
|
2149
1858
|
// }
|
|
1859
|
+
|
|
2150
1860
|
// return table.options.enableGroupingRowSelection ?? false
|
|
2151
1861
|
// },
|
|
1862
|
+
|
|
2152
1863
|
getIsAllRowsSelected: () => {
|
|
2153
1864
|
const preGroupedFlatRows = table.getFilteredRowModel().flatRows;
|
|
2154
1865
|
const {
|
|
2155
1866
|
rowSelection
|
|
2156
1867
|
} = table.getState();
|
|
2157
1868
|
let isAllRowsSelected = Boolean(preGroupedFlatRows.length && Object.keys(rowSelection).length);
|
|
2158
|
-
|
|
2159
1869
|
if (isAllRowsSelected) {
|
|
2160
1870
|
if (preGroupedFlatRows.some(row => row.getCanSelect() && !rowSelection[row.id])) {
|
|
2161
1871
|
isAllRowsSelected = false;
|
|
2162
1872
|
}
|
|
2163
1873
|
}
|
|
2164
|
-
|
|
2165
1874
|
return isAllRowsSelected;
|
|
2166
1875
|
},
|
|
2167
1876
|
getIsAllPageRowsSelected: () => {
|
|
@@ -2170,17 +1879,13 @@
|
|
|
2170
1879
|
rowSelection
|
|
2171
1880
|
} = table.getState();
|
|
2172
1881
|
let isAllPageRowsSelected = !!paginationFlatRows.length;
|
|
2173
|
-
|
|
2174
1882
|
if (isAllPageRowsSelected && paginationFlatRows.some(row => !rowSelection[row.id])) {
|
|
2175
1883
|
isAllPageRowsSelected = false;
|
|
2176
1884
|
}
|
|
2177
|
-
|
|
2178
1885
|
return isAllPageRowsSelected;
|
|
2179
1886
|
},
|
|
2180
1887
|
getIsSomeRowsSelected: () => {
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
const totalSelected = Object.keys((_table$getState$rowSe = table.getState().rowSelection) != null ? _table$getState$rowSe : {}).length;
|
|
1888
|
+
const totalSelected = Object.keys(table.getState().rowSelection ?? {}).length;
|
|
2184
1889
|
return totalSelected > 0 && totalSelected < table.getFilteredRowModel().flatRows.length;
|
|
2185
1890
|
},
|
|
2186
1891
|
getIsSomePageRowsSelected: () => {
|
|
@@ -2205,12 +1910,11 @@
|
|
|
2205
1910
|
const isSelected = row.getIsSelected();
|
|
2206
1911
|
table.setRowSelection(old => {
|
|
2207
1912
|
value = typeof value !== 'undefined' ? value : !isSelected;
|
|
2208
|
-
|
|
2209
1913
|
if (isSelected === value) {
|
|
2210
1914
|
return old;
|
|
2211
1915
|
}
|
|
2212
|
-
|
|
2213
|
-
|
|
1916
|
+
const selectedRowIds = {
|
|
1917
|
+
...old
|
|
2214
1918
|
};
|
|
2215
1919
|
mutateRowIsSelected(selectedRowIds, row.id, value, table);
|
|
2216
1920
|
return selectedRowIds;
|
|
@@ -2235,37 +1939,27 @@
|
|
|
2235
1939
|
return isSubRowSelected(row, rowSelection) === 'all';
|
|
2236
1940
|
},
|
|
2237
1941
|
getCanSelect: () => {
|
|
2238
|
-
var _table$options$enable;
|
|
2239
|
-
|
|
2240
1942
|
if (typeof table.options.enableRowSelection === 'function') {
|
|
2241
1943
|
return table.options.enableRowSelection(row);
|
|
2242
1944
|
}
|
|
2243
|
-
|
|
2244
|
-
return (_table$options$enable = table.options.enableRowSelection) != null ? _table$options$enable : true;
|
|
1945
|
+
return table.options.enableRowSelection ?? true;
|
|
2245
1946
|
},
|
|
2246
1947
|
getCanSelectSubRows: () => {
|
|
2247
|
-
var _table$options$enable2;
|
|
2248
|
-
|
|
2249
1948
|
if (typeof table.options.enableSubRowSelection === 'function') {
|
|
2250
1949
|
return table.options.enableSubRowSelection(row);
|
|
2251
1950
|
}
|
|
2252
|
-
|
|
2253
|
-
return (_table$options$enable2 = table.options.enableSubRowSelection) != null ? _table$options$enable2 : true;
|
|
1951
|
+
return table.options.enableSubRowSelection ?? true;
|
|
2254
1952
|
},
|
|
2255
1953
|
getCanMultiSelect: () => {
|
|
2256
|
-
var _table$options$enable3;
|
|
2257
|
-
|
|
2258
1954
|
if (typeof table.options.enableMultiRowSelection === 'function') {
|
|
2259
1955
|
return table.options.enableMultiRowSelection(row);
|
|
2260
1956
|
}
|
|
2261
|
-
|
|
2262
|
-
return (_table$options$enable3 = table.options.enableMultiRowSelection) != null ? _table$options$enable3 : true;
|
|
1957
|
+
return table.options.enableMultiRowSelection ?? true;
|
|
2263
1958
|
},
|
|
2264
1959
|
getToggleSelectedHandler: () => {
|
|
2265
1960
|
const canSelect = row.getCanSelect();
|
|
2266
1961
|
return e => {
|
|
2267
1962
|
var _target;
|
|
2268
|
-
|
|
2269
1963
|
if (!canSelect) return;
|
|
2270
1964
|
row.toggleSelected((_target = e.target) == null ? void 0 : _target.checked);
|
|
2271
1965
|
};
|
|
@@ -2273,63 +1967,57 @@
|
|
|
2273
1967
|
};
|
|
2274
1968
|
}
|
|
2275
1969
|
};
|
|
2276
|
-
|
|
2277
1970
|
const mutateRowIsSelected = (selectedRowIds, id, value, table) => {
|
|
2278
1971
|
var _row$subRows;
|
|
1972
|
+
const row = table.getRow(id);
|
|
1973
|
+
|
|
1974
|
+
// const isGrouped = row.getIsGrouped()
|
|
2279
1975
|
|
|
2280
|
-
const row = table.getRow(id); // const isGrouped = row.getIsGrouped()
|
|
2281
1976
|
// if ( // TODO: enforce grouping row selection rules
|
|
2282
1977
|
// !isGrouped ||
|
|
2283
1978
|
// (isGrouped && table.options.enableGroupingRowSelection)
|
|
2284
1979
|
// ) {
|
|
2285
|
-
|
|
2286
1980
|
if (value) {
|
|
2287
1981
|
if (!row.getCanMultiSelect()) {
|
|
2288
1982
|
Object.keys(selectedRowIds).forEach(key => delete selectedRowIds[key]);
|
|
2289
1983
|
}
|
|
2290
|
-
|
|
2291
1984
|
if (row.getCanSelect()) {
|
|
2292
1985
|
selectedRowIds[id] = true;
|
|
2293
1986
|
}
|
|
2294
1987
|
} else {
|
|
2295
1988
|
delete selectedRowIds[id];
|
|
2296
|
-
}
|
|
2297
|
-
|
|
1989
|
+
}
|
|
1990
|
+
// }
|
|
2298
1991
|
|
|
2299
1992
|
if ((_row$subRows = row.subRows) != null && _row$subRows.length && row.getCanSelectSubRows()) {
|
|
2300
1993
|
row.subRows.forEach(row => mutateRowIsSelected(selectedRowIds, row.id, value, table));
|
|
2301
1994
|
}
|
|
2302
1995
|
};
|
|
2303
|
-
|
|
2304
1996
|
function selectRowsFn(table, rowModel) {
|
|
2305
1997
|
const rowSelection = table.getState().rowSelection;
|
|
2306
1998
|
const newSelectedFlatRows = [];
|
|
2307
|
-
const newSelectedRowsById = {};
|
|
1999
|
+
const newSelectedRowsById = {};
|
|
2308
2000
|
|
|
2001
|
+
// Filters top level and nested rows
|
|
2309
2002
|
const recurseRows = function (rows, depth) {
|
|
2310
|
-
|
|
2311
2003
|
return rows.map(row => {
|
|
2312
2004
|
var _row$subRows2;
|
|
2313
|
-
|
|
2314
2005
|
const isSelected = isRowSelected(row, rowSelection);
|
|
2315
|
-
|
|
2316
2006
|
if (isSelected) {
|
|
2317
2007
|
newSelectedFlatRows.push(row);
|
|
2318
2008
|
newSelectedRowsById[row.id] = row;
|
|
2319
2009
|
}
|
|
2320
|
-
|
|
2321
2010
|
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
|
|
2322
|
-
row = {
|
|
2011
|
+
row = {
|
|
2012
|
+
...row,
|
|
2323
2013
|
subRows: recurseRows(row.subRows)
|
|
2324
2014
|
};
|
|
2325
2015
|
}
|
|
2326
|
-
|
|
2327
2016
|
if (isSelected) {
|
|
2328
2017
|
return row;
|
|
2329
2018
|
}
|
|
2330
2019
|
}).filter(Boolean);
|
|
2331
2020
|
};
|
|
2332
|
-
|
|
2333
2021
|
return {
|
|
2334
2022
|
rows: recurseRows(rowModel.rows),
|
|
2335
2023
|
flatRows: newSelectedFlatRows,
|
|
@@ -2337,9 +2025,7 @@
|
|
|
2337
2025
|
};
|
|
2338
2026
|
}
|
|
2339
2027
|
function isRowSelected(row, selection) {
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
return (_selection$row$id = selection[row.id]) != null ? _selection$row$id : false;
|
|
2028
|
+
return selection[row.id] ?? false;
|
|
2343
2029
|
}
|
|
2344
2030
|
function isSubRowSelected(row, selection, table) {
|
|
2345
2031
|
if (row.subRows && row.subRows.length) {
|
|
@@ -2350,7 +2036,6 @@
|
|
|
2350
2036
|
if (someSelected && !allChildrenSelected) {
|
|
2351
2037
|
return;
|
|
2352
2038
|
}
|
|
2353
|
-
|
|
2354
2039
|
if (isRowSelected(subRow, selection)) {
|
|
2355
2040
|
someSelected = true;
|
|
2356
2041
|
} else {
|
|
@@ -2359,112 +2044,104 @@
|
|
|
2359
2044
|
});
|
|
2360
2045
|
return allChildrenSelected ? 'all' : someSelected ? 'some' : false;
|
|
2361
2046
|
}
|
|
2362
|
-
|
|
2363
2047
|
return false;
|
|
2364
2048
|
}
|
|
2365
2049
|
|
|
2366
2050
|
const reSplitAlphaNumeric = /([0-9]+)/gm;
|
|
2367
|
-
|
|
2368
2051
|
const alphanumeric = (rowA, rowB, columnId) => {
|
|
2369
2052
|
return compareAlphanumeric(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2370
2053
|
};
|
|
2371
|
-
|
|
2372
2054
|
const alphanumericCaseSensitive = (rowA, rowB, columnId) => {
|
|
2373
2055
|
return compareAlphanumeric(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
2374
|
-
};
|
|
2375
|
-
// but is much faster
|
|
2376
|
-
|
|
2056
|
+
};
|
|
2377
2057
|
|
|
2058
|
+
// The text filter is more basic (less numeric support)
|
|
2059
|
+
// but is much faster
|
|
2378
2060
|
const text = (rowA, rowB, columnId) => {
|
|
2379
2061
|
return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2380
|
-
};
|
|
2381
|
-
// but is much faster
|
|
2382
|
-
|
|
2062
|
+
};
|
|
2383
2063
|
|
|
2064
|
+
// The text filter is more basic (less numeric support)
|
|
2065
|
+
// but is much faster
|
|
2384
2066
|
const textCaseSensitive = (rowA, rowB, columnId) => {
|
|
2385
2067
|
return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
2386
2068
|
};
|
|
2387
|
-
|
|
2388
2069
|
const datetime = (rowA, rowB, columnId) => {
|
|
2389
2070
|
const a = rowA.getValue(columnId);
|
|
2390
|
-
const b = rowB.getValue(columnId);
|
|
2071
|
+
const b = rowB.getValue(columnId);
|
|
2072
|
+
|
|
2073
|
+
// Can handle nullish values
|
|
2391
2074
|
// Use > and < because == (and ===) doesn't work with
|
|
2392
2075
|
// Date objects (would require calling getTime()).
|
|
2393
|
-
|
|
2394
2076
|
return a > b ? 1 : a < b ? -1 : 0;
|
|
2395
2077
|
};
|
|
2396
|
-
|
|
2397
2078
|
const basic = (rowA, rowB, columnId) => {
|
|
2398
2079
|
return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
|
|
2399
|
-
};
|
|
2080
|
+
};
|
|
2400
2081
|
|
|
2082
|
+
// Utils
|
|
2401
2083
|
|
|
2402
2084
|
function compareBasic(a, b) {
|
|
2403
2085
|
return a === b ? 0 : a > b ? 1 : -1;
|
|
2404
2086
|
}
|
|
2405
|
-
|
|
2406
2087
|
function toString(a) {
|
|
2407
2088
|
if (typeof a === 'number') {
|
|
2408
2089
|
if (isNaN(a) || a === Infinity || a === -Infinity) {
|
|
2409
2090
|
return '';
|
|
2410
2091
|
}
|
|
2411
|
-
|
|
2412
2092
|
return String(a);
|
|
2413
2093
|
}
|
|
2414
|
-
|
|
2415
2094
|
if (typeof a === 'string') {
|
|
2416
2095
|
return a;
|
|
2417
2096
|
}
|
|
2418
|
-
|
|
2419
2097
|
return '';
|
|
2420
|
-
}
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
// Mixed sorting is slow, but very inclusive of many edge cases.
|
|
2421
2101
|
// It handles numbers, mixed alphanumeric combinations, and even
|
|
2422
2102
|
// null, undefined, and Infinity
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
2103
|
function compareAlphanumeric(aStr, bStr) {
|
|
2426
2104
|
// Split on number groups, but keep the delimiter
|
|
2427
2105
|
// Then remove falsey split values
|
|
2428
2106
|
const a = aStr.split(reSplitAlphaNumeric).filter(Boolean);
|
|
2429
|
-
const b = bStr.split(reSplitAlphaNumeric).filter(Boolean);
|
|
2107
|
+
const b = bStr.split(reSplitAlphaNumeric).filter(Boolean);
|
|
2430
2108
|
|
|
2109
|
+
// While
|
|
2431
2110
|
while (a.length && b.length) {
|
|
2432
2111
|
const aa = a.shift();
|
|
2433
2112
|
const bb = b.shift();
|
|
2434
2113
|
const an = parseInt(aa, 10);
|
|
2435
2114
|
const bn = parseInt(bb, 10);
|
|
2436
|
-
const combo = [an, bn].sort();
|
|
2115
|
+
const combo = [an, bn].sort();
|
|
2437
2116
|
|
|
2117
|
+
// Both are string
|
|
2438
2118
|
if (isNaN(combo[0])) {
|
|
2439
2119
|
if (aa > bb) {
|
|
2440
2120
|
return 1;
|
|
2441
2121
|
}
|
|
2442
|
-
|
|
2443
2122
|
if (bb > aa) {
|
|
2444
2123
|
return -1;
|
|
2445
2124
|
}
|
|
2446
|
-
|
|
2447
2125
|
continue;
|
|
2448
|
-
}
|
|
2449
|
-
|
|
2126
|
+
}
|
|
2450
2127
|
|
|
2128
|
+
// One is a string, one is a number
|
|
2451
2129
|
if (isNaN(combo[1])) {
|
|
2452
2130
|
return isNaN(an) ? -1 : 1;
|
|
2453
|
-
}
|
|
2454
|
-
|
|
2131
|
+
}
|
|
2455
2132
|
|
|
2133
|
+
// Both are numbers
|
|
2456
2134
|
if (an > bn) {
|
|
2457
2135
|
return 1;
|
|
2458
2136
|
}
|
|
2459
|
-
|
|
2460
2137
|
if (bn > an) {
|
|
2461
2138
|
return -1;
|
|
2462
2139
|
}
|
|
2463
2140
|
}
|
|
2464
|
-
|
|
2465
2141
|
return a.length - b.length;
|
|
2466
|
-
}
|
|
2142
|
+
}
|
|
2467
2143
|
|
|
2144
|
+
// Exports
|
|
2468
2145
|
|
|
2469
2146
|
const sortingFns = {
|
|
2470
2147
|
alphanumeric,
|
|
@@ -2476,6 +2153,7 @@
|
|
|
2476
2153
|
};
|
|
2477
2154
|
|
|
2478
2155
|
//
|
|
2156
|
+
|
|
2479
2157
|
const Sorting = {
|
|
2480
2158
|
getInitialState: state => {
|
|
2481
2159
|
return {
|
|
@@ -2501,47 +2179,37 @@
|
|
|
2501
2179
|
getAutoSortingFn: () => {
|
|
2502
2180
|
const firstRows = table.getFilteredRowModel().flatRows.slice(10);
|
|
2503
2181
|
let isString = false;
|
|
2504
|
-
|
|
2505
2182
|
for (const row of firstRows) {
|
|
2506
2183
|
const value = row == null ? void 0 : row.getValue(column.id);
|
|
2507
|
-
|
|
2508
2184
|
if (Object.prototype.toString.call(value) === '[object Date]') {
|
|
2509
2185
|
return sortingFns.datetime;
|
|
2510
2186
|
}
|
|
2511
|
-
|
|
2512
2187
|
if (typeof value === 'string') {
|
|
2513
2188
|
isString = true;
|
|
2514
|
-
|
|
2515
2189
|
if (value.split(reSplitAlphaNumeric).length > 1) {
|
|
2516
2190
|
return sortingFns.alphanumeric;
|
|
2517
2191
|
}
|
|
2518
2192
|
}
|
|
2519
2193
|
}
|
|
2520
|
-
|
|
2521
2194
|
if (isString) {
|
|
2522
2195
|
return sortingFns.text;
|
|
2523
2196
|
}
|
|
2524
|
-
|
|
2525
2197
|
return sortingFns.basic;
|
|
2526
2198
|
},
|
|
2527
2199
|
getAutoSortDir: () => {
|
|
2528
2200
|
const firstRow = table.getFilteredRowModel().flatRows[0];
|
|
2529
2201
|
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
|
2530
|
-
|
|
2531
2202
|
if (typeof value === 'string') {
|
|
2532
2203
|
return 'asc';
|
|
2533
2204
|
}
|
|
2534
|
-
|
|
2535
2205
|
return 'desc';
|
|
2536
2206
|
},
|
|
2537
2207
|
getSortingFn: () => {
|
|
2538
|
-
var _table$options$sortin
|
|
2539
|
-
|
|
2208
|
+
var _table$options$sortin;
|
|
2540
2209
|
if (!column) {
|
|
2541
2210
|
throw new Error();
|
|
2542
2211
|
}
|
|
2543
|
-
|
|
2544
|
-
return isFunction(column.columnDef.sortingFn) ? column.columnDef.sortingFn : column.columnDef.sortingFn === 'auto' ? column.getAutoSortingFn() : (_table$options$sortin = (_table$options$sortin2 = table.options.sortingFns) == null ? void 0 : _table$options$sortin2[column.columnDef.sortingFn]) != null ? _table$options$sortin : sortingFns[column.columnDef.sortingFn];
|
|
2212
|
+
return isFunction(column.columnDef.sortingFn) ? column.columnDef.sortingFn : column.columnDef.sortingFn === 'auto' ? column.getAutoSortingFn() : ((_table$options$sortin = table.options.sortingFns) == null ? void 0 : _table$options$sortin[column.columnDef.sortingFn]) ?? sortingFns[column.columnDef.sortingFn];
|
|
2545
2213
|
},
|
|
2546
2214
|
toggleSorting: (desc, multi) => {
|
|
2547
2215
|
// if (column.columns.length) {
|
|
@@ -2552,6 +2220,7 @@
|
|
|
2552
2220
|
// })
|
|
2553
2221
|
// return
|
|
2554
2222
|
// }
|
|
2223
|
+
|
|
2555
2224
|
// this needs to be outside of table.setSorting to be in sync with rerender
|
|
2556
2225
|
const nextSortingOrder = column.getNextSortingOrder();
|
|
2557
2226
|
const hasManualValue = typeof desc !== 'undefined' && desc !== null;
|
|
@@ -2559,11 +2228,13 @@
|
|
|
2559
2228
|
// Find any existing sorting for this column
|
|
2560
2229
|
const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
|
|
2561
2230
|
const existingIndex = old == null ? void 0 : old.findIndex(d => d.id === column.id);
|
|
2562
|
-
let newSorting = [];
|
|
2231
|
+
let newSorting = [];
|
|
2563
2232
|
|
|
2233
|
+
// What should we do with this sort action?
|
|
2564
2234
|
let sortAction;
|
|
2565
|
-
let nextDesc = hasManualValue ? desc : nextSortingOrder === 'desc';
|
|
2235
|
+
let nextDesc = hasManualValue ? desc : nextSortingOrder === 'desc';
|
|
2566
2236
|
|
|
2237
|
+
// Multi-mode
|
|
2567
2238
|
if (old != null && old.length && column.getCanMultiSort() && multi) {
|
|
2568
2239
|
if (existingSorting) {
|
|
2569
2240
|
sortAction = 'toggle';
|
|
@@ -2579,9 +2250,9 @@
|
|
|
2579
2250
|
} else {
|
|
2580
2251
|
sortAction = 'replace';
|
|
2581
2252
|
}
|
|
2582
|
-
}
|
|
2583
|
-
|
|
2253
|
+
}
|
|
2584
2254
|
|
|
2255
|
+
// Handle toggle states that will remove the sorting
|
|
2585
2256
|
if (sortAction === 'toggle') {
|
|
2586
2257
|
// If we are "actually" toggling (not a manual set value), should we remove the sorting?
|
|
2587
2258
|
if (!hasManualValue) {
|
|
@@ -2591,25 +2262,22 @@
|
|
|
2591
2262
|
}
|
|
2592
2263
|
}
|
|
2593
2264
|
}
|
|
2594
|
-
|
|
2595
2265
|
if (sortAction === 'add') {
|
|
2596
|
-
var _table$options$maxMul;
|
|
2597
|
-
|
|
2598
2266
|
newSorting = [...old, {
|
|
2599
2267
|
id: column.id,
|
|
2600
2268
|
desc: nextDesc
|
|
2601
|
-
}];
|
|
2602
|
-
|
|
2603
|
-
newSorting.splice(0, newSorting.length - (
|
|
2269
|
+
}];
|
|
2270
|
+
// Take latest n columns
|
|
2271
|
+
newSorting.splice(0, newSorting.length - (table.options.maxMultiSortColCount ?? Number.MAX_SAFE_INTEGER));
|
|
2604
2272
|
} else if (sortAction === 'toggle') {
|
|
2605
2273
|
// This flips (or sets) the
|
|
2606
2274
|
newSorting = old.map(d => {
|
|
2607
2275
|
if (d.id === column.id) {
|
|
2608
|
-
return {
|
|
2276
|
+
return {
|
|
2277
|
+
...d,
|
|
2609
2278
|
desc: nextDesc
|
|
2610
2279
|
};
|
|
2611
2280
|
}
|
|
2612
|
-
|
|
2613
2281
|
return d;
|
|
2614
2282
|
});
|
|
2615
2283
|
} else if (sortAction === 'remove') {
|
|
@@ -2620,54 +2288,41 @@
|
|
|
2620
2288
|
desc: nextDesc
|
|
2621
2289
|
}];
|
|
2622
2290
|
}
|
|
2623
|
-
|
|
2624
2291
|
return newSorting;
|
|
2625
2292
|
});
|
|
2626
2293
|
},
|
|
2627
2294
|
getFirstSortDir: () => {
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
const sortDescFirst = (_ref = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : table.options.sortDescFirst) != null ? _ref : column.getAutoSortDir() === 'desc';
|
|
2295
|
+
const sortDescFirst = column.columnDef.sortDescFirst ?? table.options.sortDescFirst ?? column.getAutoSortDir() === 'desc';
|
|
2631
2296
|
return sortDescFirst ? 'desc' : 'asc';
|
|
2632
2297
|
},
|
|
2633
2298
|
getNextSortingOrder: multi => {
|
|
2634
|
-
var _table$options$enable, _table$options$enable2;
|
|
2635
|
-
|
|
2636
2299
|
const firstSortDirection = column.getFirstSortDir();
|
|
2637
2300
|
const isSorted = column.getIsSorted();
|
|
2638
|
-
|
|
2639
2301
|
if (!isSorted) {
|
|
2640
2302
|
return firstSortDirection;
|
|
2641
2303
|
}
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
multi ?
|
|
2304
|
+
if (isSorted !== firstSortDirection && (table.options.enableSortingRemoval ?? true) && (
|
|
2305
|
+
// If enableSortRemove, enable in general
|
|
2306
|
+
multi ? table.options.enableMultiRemove ?? true : true) // If multi, don't allow if enableMultiRemove))
|
|
2645
2307
|
) {
|
|
2646
2308
|
return false;
|
|
2647
2309
|
}
|
|
2648
|
-
|
|
2649
2310
|
return isSorted === 'desc' ? 'asc' : 'desc';
|
|
2650
2311
|
},
|
|
2651
2312
|
getCanSort: () => {
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
return ((_column$columnDef$ena = column.columnDef.enableSorting) != null ? _column$columnDef$ena : true) && ((_table$options$enable3 = table.options.enableSorting) != null ? _table$options$enable3 : true) && !!column.accessorFn;
|
|
2313
|
+
return (column.columnDef.enableSorting ?? true) && (table.options.enableSorting ?? true) && !!column.accessorFn;
|
|
2655
2314
|
},
|
|
2656
2315
|
getCanMultiSort: () => {
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
return (_ref2 = (_column$columnDef$ena2 = column.columnDef.enableMultiSort) != null ? _column$columnDef$ena2 : table.options.enableMultiSort) != null ? _ref2 : !!column.accessorFn;
|
|
2316
|
+
return column.columnDef.enableMultiSort ?? table.options.enableMultiSort ?? !!column.accessorFn;
|
|
2660
2317
|
},
|
|
2661
2318
|
getIsSorted: () => {
|
|
2662
2319
|
var _table$getState$sorti;
|
|
2663
|
-
|
|
2664
2320
|
const columnSort = (_table$getState$sorti = table.getState().sorting) == null ? void 0 : _table$getState$sorti.find(d => d.id === column.id);
|
|
2665
2321
|
return !columnSort ? false : columnSort.desc ? 'desc' : 'asc';
|
|
2666
2322
|
},
|
|
2667
2323
|
getSortIndex: () => {
|
|
2668
|
-
var _table$getState$sorti2
|
|
2669
|
-
|
|
2670
|
-
return (_table$getState$sorti2 = (_table$getState$sorti3 = table.getState().sorting) == null ? void 0 : _table$getState$sorti3.findIndex(d => d.id === column.id)) != null ? _table$getState$sorti2 : -1;
|
|
2324
|
+
var _table$getState$sorti2;
|
|
2325
|
+
return ((_table$getState$sorti2 = table.getState().sorting) == null ? void 0 : _table$getState$sorti2.findIndex(d => d.id === column.id)) ?? -1;
|
|
2671
2326
|
},
|
|
2672
2327
|
clearSorting: () => {
|
|
2673
2328
|
//clear sorting for just 1 column
|
|
@@ -2687,20 +2342,17 @@
|
|
|
2687
2342
|
return {
|
|
2688
2343
|
setSorting: updater => table.options.onSortingChange == null ? void 0 : table.options.onSortingChange(updater),
|
|
2689
2344
|
resetSorting: defaultState => {
|
|
2690
|
-
var _table$initialState
|
|
2691
|
-
|
|
2692
|
-
table.setSorting(defaultState ? [] : (_table$initialState$s = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.sorting) != null ? _table$initialState$s : []);
|
|
2345
|
+
var _table$initialState;
|
|
2346
|
+
table.setSorting(defaultState ? [] : ((_table$initialState = table.initialState) == null ? void 0 : _table$initialState.sorting) ?? []);
|
|
2693
2347
|
},
|
|
2694
2348
|
getPreSortedRowModel: () => table.getGroupedRowModel(),
|
|
2695
2349
|
getSortedRowModel: () => {
|
|
2696
2350
|
if (!table._getSortedRowModel && table.options.getSortedRowModel) {
|
|
2697
2351
|
table._getSortedRowModel = table.options.getSortedRowModel(table);
|
|
2698
2352
|
}
|
|
2699
|
-
|
|
2700
2353
|
if (table.options.manualSorting || !table._getSortedRowModel) {
|
|
2701
2354
|
return table.getPreSortedRowModel();
|
|
2702
2355
|
}
|
|
2703
|
-
|
|
2704
2356
|
return table._getSortedRowModel();
|
|
2705
2357
|
}
|
|
2706
2358
|
};
|
|
@@ -2708,6 +2360,7 @@
|
|
|
2708
2360
|
};
|
|
2709
2361
|
|
|
2710
2362
|
//
|
|
2363
|
+
|
|
2711
2364
|
const Visibility = {
|
|
2712
2365
|
getInitialState: state => {
|
|
2713
2366
|
return {
|
|
@@ -2724,20 +2377,18 @@
|
|
|
2724
2377
|
return {
|
|
2725
2378
|
toggleVisibility: value => {
|
|
2726
2379
|
if (column.getCanHide()) {
|
|
2727
|
-
table.setColumnVisibility(old => ({
|
|
2728
|
-
|
|
2380
|
+
table.setColumnVisibility(old => ({
|
|
2381
|
+
...old,
|
|
2382
|
+
[column.id]: value ?? !column.getIsVisible()
|
|
2729
2383
|
}));
|
|
2730
2384
|
}
|
|
2731
2385
|
},
|
|
2732
2386
|
getIsVisible: () => {
|
|
2733
|
-
var _table$getState$colum
|
|
2734
|
-
|
|
2735
|
-
return (_table$getState$colum = (_table$getState$colum2 = table.getState().columnVisibility) == null ? void 0 : _table$getState$colum2[column.id]) != null ? _table$getState$colum : true;
|
|
2387
|
+
var _table$getState$colum;
|
|
2388
|
+
return ((_table$getState$colum = table.getState().columnVisibility) == null ? void 0 : _table$getState$colum[column.id]) ?? true;
|
|
2736
2389
|
},
|
|
2737
2390
|
getCanHide: () => {
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableHiding) != null ? _table$options$enable : true);
|
|
2391
|
+
return (column.columnDef.enableHiding ?? true) && (table.options.enableHiding ?? true);
|
|
2741
2392
|
},
|
|
2742
2393
|
getToggleVisibilityHandler: () => {
|
|
2743
2394
|
return e => {
|
|
@@ -2752,19 +2403,11 @@
|
|
|
2752
2403
|
return cells.filter(cell => cell.column.getIsVisible());
|
|
2753
2404
|
}, {
|
|
2754
2405
|
key: "development" === 'production' ,
|
|
2755
|
-
debug: () =>
|
|
2756
|
-
var _table$options$debugA;
|
|
2757
|
-
|
|
2758
|
-
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugRows;
|
|
2759
|
-
}
|
|
2406
|
+
debug: () => table.options.debugAll ?? table.options.debugRows
|
|
2760
2407
|
}),
|
|
2761
2408
|
getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
|
|
2762
2409
|
key: 'row.getVisibleCells',
|
|
2763
|
-
debug: () =>
|
|
2764
|
-
var _table$options$debugA2;
|
|
2765
|
-
|
|
2766
|
-
return (_table$options$debugA2 = table.options.debugAll) != null ? _table$options$debugA2 : table.options.debugRows;
|
|
2767
|
-
}
|
|
2410
|
+
debug: () => table.options.debugAll ?? table.options.debugRows
|
|
2768
2411
|
})
|
|
2769
2412
|
};
|
|
2770
2413
|
},
|
|
@@ -2774,14 +2417,9 @@
|
|
|
2774
2417
|
return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
|
|
2775
2418
|
}, {
|
|
2776
2419
|
key,
|
|
2777
|
-
debug: () =>
|
|
2778
|
-
var _table$options$debugA3;
|
|
2779
|
-
|
|
2780
|
-
return (_table$options$debugA3 = table.options.debugAll) != null ? _table$options$debugA3 : table.options.debugColumns;
|
|
2781
|
-
}
|
|
2420
|
+
debug: () => table.options.debugAll ?? table.options.debugColumns
|
|
2782
2421
|
});
|
|
2783
2422
|
};
|
|
2784
|
-
|
|
2785
2423
|
return {
|
|
2786
2424
|
getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => table.getAllFlatColumns()),
|
|
2787
2425
|
getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => table.getAllLeafColumns()),
|
|
@@ -2790,15 +2428,12 @@
|
|
|
2790
2428
|
getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => table.getCenterLeafColumns()),
|
|
2791
2429
|
setColumnVisibility: updater => table.options.onColumnVisibilityChange == null ? void 0 : table.options.onColumnVisibilityChange(updater),
|
|
2792
2430
|
resetColumnVisibility: defaultState => {
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
table.setColumnVisibility(defaultState ? {} : (_table$initialState$c = table.initialState.columnVisibility) != null ? _table$initialState$c : {});
|
|
2431
|
+
table.setColumnVisibility(defaultState ? {} : table.initialState.columnVisibility ?? {});
|
|
2796
2432
|
},
|
|
2797
2433
|
toggleAllColumnsVisible: value => {
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
table.setColumnVisibility(table.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
|
|
2434
|
+
value = value ?? !table.getIsAllColumnsVisible();
|
|
2435
|
+
table.setColumnVisibility(table.getAllLeafColumns().reduce((obj, column) => ({
|
|
2436
|
+
...obj,
|
|
2802
2437
|
[column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
|
|
2803
2438
|
}), {}));
|
|
2804
2439
|
},
|
|
@@ -2807,7 +2442,6 @@
|
|
|
2807
2442
|
getToggleAllColumnsVisibilityHandler: () => {
|
|
2808
2443
|
return e => {
|
|
2809
2444
|
var _target;
|
|
2810
|
-
|
|
2811
2445
|
table.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
|
|
2812
2446
|
};
|
|
2813
2447
|
}
|
|
@@ -2815,64 +2449,57 @@
|
|
|
2815
2449
|
}
|
|
2816
2450
|
};
|
|
2817
2451
|
|
|
2818
|
-
const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing];
|
|
2452
|
+
const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing];
|
|
2819
2453
|
|
|
2820
|
-
|
|
2821
|
-
var _options$initialState;
|
|
2454
|
+
//
|
|
2822
2455
|
|
|
2456
|
+
function createTable(options) {
|
|
2823
2457
|
if (options.debugAll || options.debugTable) {
|
|
2824
2458
|
console.info('Creating Table Instance...');
|
|
2825
2459
|
}
|
|
2826
|
-
|
|
2827
2460
|
let table = {
|
|
2828
2461
|
_features: features
|
|
2829
2462
|
};
|
|
2830
|
-
|
|
2831
2463
|
const defaultOptions = table._features.reduce((obj, feature) => {
|
|
2832
2464
|
return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(table));
|
|
2833
2465
|
}, {});
|
|
2834
|
-
|
|
2835
2466
|
const mergeOptions = options => {
|
|
2836
2467
|
if (table.options.mergeOptions) {
|
|
2837
2468
|
return table.options.mergeOptions(defaultOptions, options);
|
|
2838
2469
|
}
|
|
2839
|
-
|
|
2840
|
-
|
|
2470
|
+
return {
|
|
2471
|
+
...defaultOptions,
|
|
2841
2472
|
...options
|
|
2842
2473
|
};
|
|
2843
2474
|
};
|
|
2844
|
-
|
|
2845
2475
|
const coreInitialState = {};
|
|
2846
|
-
let initialState = {
|
|
2847
|
-
...
|
|
2476
|
+
let initialState = {
|
|
2477
|
+
...coreInitialState,
|
|
2478
|
+
...(options.initialState ?? {})
|
|
2848
2479
|
};
|
|
2849
|
-
|
|
2850
2480
|
table._features.forEach(feature => {
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
initialState = (_feature$getInitialSt = feature.getInitialState == null ? void 0 : feature.getInitialState(initialState)) != null ? _feature$getInitialSt : initialState;
|
|
2481
|
+
initialState = (feature.getInitialState == null ? void 0 : feature.getInitialState(initialState)) ?? initialState;
|
|
2854
2482
|
});
|
|
2855
|
-
|
|
2856
2483
|
const queued = [];
|
|
2857
2484
|
let queuedTimeout = false;
|
|
2858
2485
|
const coreInstance = {
|
|
2859
2486
|
_features: features,
|
|
2860
|
-
options: {
|
|
2487
|
+
options: {
|
|
2488
|
+
...defaultOptions,
|
|
2861
2489
|
...options
|
|
2862
2490
|
},
|
|
2863
2491
|
initialState,
|
|
2864
2492
|
_queue: cb => {
|
|
2865
2493
|
queued.push(cb);
|
|
2866
|
-
|
|
2867
2494
|
if (!queuedTimeout) {
|
|
2868
|
-
queuedTimeout = true;
|
|
2869
|
-
// the current call stack (render, etc) has finished.
|
|
2495
|
+
queuedTimeout = true;
|
|
2870
2496
|
|
|
2497
|
+
// Schedule a microtask to run the queued callbacks after
|
|
2498
|
+
// the current call stack (render, etc) has finished.
|
|
2871
2499
|
Promise.resolve().then(() => {
|
|
2872
2500
|
while (queued.length) {
|
|
2873
2501
|
queued.shift()();
|
|
2874
2502
|
}
|
|
2875
|
-
|
|
2876
2503
|
queuedTimeout = false;
|
|
2877
2504
|
}).catch(error => setTimeout(() => {
|
|
2878
2505
|
throw error;
|
|
@@ -2892,57 +2519,45 @@
|
|
|
2892
2519
|
setState: updater => {
|
|
2893
2520
|
table.options.onStateChange == null ? void 0 : table.options.onStateChange(updater);
|
|
2894
2521
|
},
|
|
2895
|
-
_getRowId: (row, index, parent) => {
|
|
2896
|
-
var _table$options$getRow;
|
|
2897
|
-
|
|
2898
|
-
return (_table$options$getRow = table.options.getRowId == null ? void 0 : table.options.getRowId(row, index, parent)) != null ? _table$options$getRow : "" + (parent ? [parent.id, index].join('.') : index);
|
|
2899
|
-
},
|
|
2522
|
+
_getRowId: (row, index, parent) => (table.options.getRowId == null ? void 0 : table.options.getRowId(row, index, parent)) ?? `${parent ? [parent.id, index].join('.') : index}`,
|
|
2900
2523
|
getCoreRowModel: () => {
|
|
2901
2524
|
if (!table._getCoreRowModel) {
|
|
2902
2525
|
table._getCoreRowModel = table.options.getCoreRowModel(table);
|
|
2903
2526
|
}
|
|
2904
|
-
|
|
2905
2527
|
return table._getCoreRowModel();
|
|
2906
2528
|
},
|
|
2907
2529
|
// The final calls start at the bottom of the model,
|
|
2908
2530
|
// expanded rows, which then work their way up
|
|
2531
|
+
|
|
2909
2532
|
getRowModel: () => {
|
|
2910
2533
|
return table.getPaginationRowModel();
|
|
2911
2534
|
},
|
|
2912
2535
|
getRow: id => {
|
|
2913
2536
|
const row = table.getRowModel().rowsById[id];
|
|
2914
|
-
|
|
2915
2537
|
if (!row) {
|
|
2916
2538
|
{
|
|
2917
|
-
throw new Error(
|
|
2539
|
+
throw new Error(`getRow expected an ID, but got ${id}`);
|
|
2918
2540
|
}
|
|
2919
2541
|
}
|
|
2920
|
-
|
|
2921
2542
|
return row;
|
|
2922
2543
|
},
|
|
2923
2544
|
_getDefaultColumnDef: memo(() => [table.options.defaultColumn], defaultColumn => {
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
|
|
2545
|
+
defaultColumn = defaultColumn ?? {};
|
|
2927
2546
|
return {
|
|
2928
2547
|
header: props => {
|
|
2929
2548
|
const resolvedColumnDef = props.header.column.columnDef;
|
|
2930
|
-
|
|
2931
2549
|
if (resolvedColumnDef.accessorKey) {
|
|
2932
2550
|
return resolvedColumnDef.accessorKey;
|
|
2933
2551
|
}
|
|
2934
|
-
|
|
2935
2552
|
if (resolvedColumnDef.accessorFn) {
|
|
2936
2553
|
return resolvedColumnDef.id;
|
|
2937
2554
|
}
|
|
2938
|
-
|
|
2939
2555
|
return null;
|
|
2940
2556
|
},
|
|
2941
2557
|
// footer: props => props.header.column.id,
|
|
2942
2558
|
cell: props => {
|
|
2943
|
-
var _props$renderValue
|
|
2944
|
-
|
|
2945
|
-
return (_props$renderValue$to = (_props$renderValue = props.renderValue()) == null ? void 0 : _props$renderValue.toString == null ? void 0 : _props$renderValue.toString()) != null ? _props$renderValue$to : null;
|
|
2559
|
+
var _props$renderValue;
|
|
2560
|
+
return ((_props$renderValue = props.renderValue()) == null ? void 0 : _props$renderValue.toString == null ? void 0 : _props$renderValue.toString()) ?? null;
|
|
2946
2561
|
},
|
|
2947
2562
|
...table._features.reduce((obj, feature) => {
|
|
2948
2563
|
return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
|
|
@@ -2950,11 +2565,7 @@
|
|
|
2950
2565
|
...defaultColumn
|
|
2951
2566
|
};
|
|
2952
2567
|
}, {
|
|
2953
|
-
debug: () =>
|
|
2954
|
-
var _table$options$debugA;
|
|
2955
|
-
|
|
2956
|
-
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugColumns;
|
|
2957
|
-
},
|
|
2568
|
+
debug: () => table.options.debugAll ?? table.options.debugColumns,
|
|
2958
2569
|
key: 'getDefaultColumnDef'
|
|
2959
2570
|
}),
|
|
2960
2571
|
_getColumnDefs: () => table.options.columns,
|
|
@@ -2963,7 +2574,6 @@
|
|
|
2963
2574
|
if (depth === void 0) {
|
|
2964
2575
|
depth = 0;
|
|
2965
2576
|
}
|
|
2966
|
-
|
|
2967
2577
|
return columnDefs.map(columnDef => {
|
|
2968
2578
|
const column = createColumn(table, columnDef, depth, parent);
|
|
2969
2579
|
const groupingColumnDef = columnDef;
|
|
@@ -2971,15 +2581,10 @@
|
|
|
2971
2581
|
return column;
|
|
2972
2582
|
});
|
|
2973
2583
|
};
|
|
2974
|
-
|
|
2975
2584
|
return recurseColumns(columnDefs);
|
|
2976
2585
|
}, {
|
|
2977
2586
|
key: 'getAllColumns',
|
|
2978
|
-
debug: () =>
|
|
2979
|
-
var _table$options$debugA2;
|
|
2980
|
-
|
|
2981
|
-
return (_table$options$debugA2 = table.options.debugAll) != null ? _table$options$debugA2 : table.options.debugColumns;
|
|
2982
|
-
}
|
|
2587
|
+
debug: () => table.options.debugAll ?? table.options.debugColumns
|
|
2983
2588
|
}),
|
|
2984
2589
|
getAllFlatColumns: memo(() => [table.getAllColumns()], allColumns => {
|
|
2985
2590
|
return allColumns.flatMap(column => {
|
|
@@ -2987,11 +2592,7 @@
|
|
|
2987
2592
|
});
|
|
2988
2593
|
}, {
|
|
2989
2594
|
key: 'getAllFlatColumns',
|
|
2990
|
-
debug: () =>
|
|
2991
|
-
var _table$options$debugA3;
|
|
2992
|
-
|
|
2993
|
-
return (_table$options$debugA3 = table.options.debugAll) != null ? _table$options$debugA3 : table.options.debugColumns;
|
|
2994
|
-
}
|
|
2595
|
+
debug: () => table.options.debugAll ?? table.options.debugColumns
|
|
2995
2596
|
}),
|
|
2996
2597
|
_getAllFlatColumnsById: memo(() => [table.getAllFlatColumns()], flatColumns => {
|
|
2997
2598
|
return flatColumns.reduce((acc, column) => {
|
|
@@ -3000,55 +2601,37 @@
|
|
|
3000
2601
|
}, {});
|
|
3001
2602
|
}, {
|
|
3002
2603
|
key: 'getAllFlatColumnsById',
|
|
3003
|
-
debug: () =>
|
|
3004
|
-
var _table$options$debugA4;
|
|
3005
|
-
|
|
3006
|
-
return (_table$options$debugA4 = table.options.debugAll) != null ? _table$options$debugA4 : table.options.debugColumns;
|
|
3007
|
-
}
|
|
2604
|
+
debug: () => table.options.debugAll ?? table.options.debugColumns
|
|
3008
2605
|
}),
|
|
3009
2606
|
getAllLeafColumns: memo(() => [table.getAllColumns(), table._getOrderColumnsFn()], (allColumns, orderColumns) => {
|
|
3010
2607
|
let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
|
|
3011
2608
|
return orderColumns(leafColumns);
|
|
3012
2609
|
}, {
|
|
3013
2610
|
key: 'getAllLeafColumns',
|
|
3014
|
-
debug: () =>
|
|
3015
|
-
var _table$options$debugA5;
|
|
3016
|
-
|
|
3017
|
-
return (_table$options$debugA5 = table.options.debugAll) != null ? _table$options$debugA5 : table.options.debugColumns;
|
|
3018
|
-
}
|
|
2611
|
+
debug: () => table.options.debugAll ?? table.options.debugColumns
|
|
3019
2612
|
}),
|
|
3020
2613
|
getColumn: columnId => {
|
|
3021
2614
|
const column = table._getAllFlatColumnsById()[columnId];
|
|
3022
|
-
|
|
3023
2615
|
if (!column) {
|
|
3024
2616
|
{
|
|
3025
|
-
console.warn(
|
|
2617
|
+
console.warn(`[Table] Column with id ${columnId} does not exist.`);
|
|
3026
2618
|
}
|
|
3027
|
-
|
|
3028
2619
|
throw new Error();
|
|
3029
2620
|
}
|
|
3030
|
-
|
|
3031
2621
|
return column;
|
|
3032
2622
|
}
|
|
3033
2623
|
};
|
|
3034
2624
|
Object.assign(table, coreInstance);
|
|
3035
|
-
|
|
3036
2625
|
table._features.forEach(feature => {
|
|
3037
2626
|
return Object.assign(table, feature.createTable == null ? void 0 : feature.createTable(table));
|
|
3038
2627
|
});
|
|
3039
|
-
|
|
3040
2628
|
return table;
|
|
3041
2629
|
}
|
|
3042
2630
|
|
|
3043
2631
|
function createCell(table, row, column, columnId) {
|
|
3044
|
-
const getRenderValue = () =>
|
|
3045
|
-
var _cell$getValue;
|
|
3046
|
-
|
|
3047
|
-
return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : table.options.renderFallbackValue;
|
|
3048
|
-
};
|
|
3049
|
-
|
|
2632
|
+
const getRenderValue = () => cell.getValue() ?? table.options.renderFallbackValue;
|
|
3050
2633
|
const cell = {
|
|
3051
|
-
id: row.id
|
|
2634
|
+
id: `${row.id}_${column.id}`,
|
|
3052
2635
|
row,
|
|
3053
2636
|
column,
|
|
3054
2637
|
getValue: () => row.getValue(columnId),
|
|
@@ -3065,11 +2648,9 @@
|
|
|
3065
2648
|
debug: () => table.options.debugAll
|
|
3066
2649
|
})
|
|
3067
2650
|
};
|
|
3068
|
-
|
|
3069
2651
|
table._features.forEach(feature => {
|
|
3070
2652
|
Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, table));
|
|
3071
2653
|
}, {});
|
|
3072
|
-
|
|
3073
2654
|
return cell;
|
|
3074
2655
|
}
|
|
3075
2656
|
|
|
@@ -3084,22 +2665,15 @@
|
|
|
3084
2665
|
if (row._valuesCache.hasOwnProperty(columnId)) {
|
|
3085
2666
|
return row._valuesCache[columnId];
|
|
3086
2667
|
}
|
|
3087
|
-
|
|
3088
2668
|
const column = table.getColumn(columnId);
|
|
3089
|
-
|
|
3090
2669
|
if (!column.accessorFn) {
|
|
3091
2670
|
return undefined;
|
|
3092
2671
|
}
|
|
3093
|
-
|
|
3094
2672
|
row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
|
3095
2673
|
return row._valuesCache[columnId];
|
|
3096
2674
|
},
|
|
3097
|
-
renderValue: columnId =>
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
return (_row$getValue = row.getValue(columnId)) != null ? _row$getValue : table.options.renderFallbackValue;
|
|
3101
|
-
},
|
|
3102
|
-
subRows: subRows != null ? subRows : [],
|
|
2675
|
+
renderValue: columnId => row.getValue(columnId) ?? table.options.renderFallbackValue,
|
|
2676
|
+
subRows: subRows ?? [],
|
|
3103
2677
|
getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
|
|
3104
2678
|
getAllCells: memo(() => [table.getAllLeafColumns()], leafColumns => {
|
|
3105
2679
|
return leafColumns.map(column => {
|
|
@@ -3107,11 +2681,7 @@
|
|
|
3107
2681
|
});
|
|
3108
2682
|
}, {
|
|
3109
2683
|
key: 'row.getAllCells',
|
|
3110
|
-
debug: () =>
|
|
3111
|
-
var _table$options$debugA;
|
|
3112
|
-
|
|
3113
|
-
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugRows;
|
|
3114
|
-
}
|
|
2684
|
+
debug: () => table.options.debugAll ?? table.options.debugRows
|
|
3115
2685
|
}),
|
|
3116
2686
|
_getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
|
|
3117
2687
|
return allCells.reduce((acc, cell) => {
|
|
@@ -3120,19 +2690,13 @@
|
|
|
3120
2690
|
}, {});
|
|
3121
2691
|
}, {
|
|
3122
2692
|
key: "development" === 'production' ,
|
|
3123
|
-
debug: () =>
|
|
3124
|
-
var _table$options$debugA2;
|
|
3125
|
-
|
|
3126
|
-
return (_table$options$debugA2 = table.options.debugAll) != null ? _table$options$debugA2 : table.options.debugRows;
|
|
3127
|
-
}
|
|
2693
|
+
debug: () => table.options.debugAll ?? table.options.debugRows
|
|
3128
2694
|
})
|
|
3129
2695
|
};
|
|
3130
|
-
|
|
3131
2696
|
for (let i = 0; i < table._features.length; i++) {
|
|
3132
2697
|
const feature = table._features[i];
|
|
3133
2698
|
Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, table));
|
|
3134
2699
|
}
|
|
3135
|
-
|
|
3136
2700
|
return row;
|
|
3137
2701
|
};
|
|
3138
2702
|
|
|
@@ -3159,24 +2723,32 @@
|
|
|
3159
2723
|
// }
|
|
3160
2724
|
// }
|
|
3161
2725
|
// }
|
|
2726
|
+
|
|
3162
2727
|
// const test: DeepKeys<Person> = 'nested.foo.0.bar'
|
|
3163
2728
|
// const test2: DeepKeys<Person> = 'nested.bar'
|
|
2729
|
+
|
|
3164
2730
|
// const helper = createColumnHelper<Person>()
|
|
2731
|
+
|
|
3165
2732
|
// helper.accessor('nested.foo', {
|
|
3166
2733
|
// cell: info => info.getValue(),
|
|
3167
2734
|
// })
|
|
2735
|
+
|
|
3168
2736
|
// helper.accessor('nested.foo.0.bar', {
|
|
3169
2737
|
// cell: info => info.getValue(),
|
|
3170
2738
|
// })
|
|
2739
|
+
|
|
3171
2740
|
// helper.accessor('nested.bar', {
|
|
3172
2741
|
// cell: info => info.getValue(),
|
|
3173
2742
|
// })
|
|
2743
|
+
|
|
3174
2744
|
function createColumnHelper() {
|
|
3175
2745
|
return {
|
|
3176
2746
|
accessor: (accessor, column) => {
|
|
3177
|
-
return typeof accessor === 'function' ? {
|
|
2747
|
+
return typeof accessor === 'function' ? {
|
|
2748
|
+
...column,
|
|
3178
2749
|
accessorFn: accessor
|
|
3179
|
-
} : {
|
|
2750
|
+
} : {
|
|
2751
|
+
...column,
|
|
3180
2752
|
accessorKey: accessor
|
|
3181
2753
|
};
|
|
3182
2754
|
},
|
|
@@ -3192,14 +2764,11 @@
|
|
|
3192
2764
|
flatRows: [],
|
|
3193
2765
|
rowsById: {}
|
|
3194
2766
|
};
|
|
3195
|
-
|
|
3196
2767
|
const accessRows = function (originalRows, depth, parent) {
|
|
3197
2768
|
if (depth === void 0) {
|
|
3198
2769
|
depth = 0;
|
|
3199
2770
|
}
|
|
3200
|
-
|
|
3201
2771
|
const rows = [];
|
|
3202
|
-
|
|
3203
2772
|
for (let i = 0; i < originalRows.length; i++) {
|
|
3204
2773
|
// This could be an expensive check at scale, so we should move it somewhere else, but where?
|
|
3205
2774
|
// if (!id) {
|
|
@@ -3207,38 +2776,35 @@
|
|
|
3207
2776
|
// throw new Error(`getRowId expected an ID, but got ${id}`)
|
|
3208
2777
|
// }
|
|
3209
2778
|
// }
|
|
3210
|
-
// Make the row
|
|
3211
|
-
const row = createRow(table, table._getRowId(originalRows[i], i, parent), originalRows[i], i, depth); // Keep track of every row in a flat array
|
|
3212
2779
|
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
rowModel.rowsById[row.id] = row; // Push table row into parent
|
|
2780
|
+
// Make the row
|
|
2781
|
+
const row = createRow(table, table._getRowId(originalRows[i], i, parent), originalRows[i], i, depth);
|
|
3216
2782
|
|
|
3217
|
-
|
|
2783
|
+
// Keep track of every row in a flat array
|
|
2784
|
+
rowModel.flatRows.push(row);
|
|
2785
|
+
// Also keep track of every row by its ID
|
|
2786
|
+
rowModel.rowsById[row.id] = row;
|
|
2787
|
+
// Push table row into parent
|
|
2788
|
+
rows.push(row);
|
|
3218
2789
|
|
|
2790
|
+
// Get the original subrows
|
|
3219
2791
|
if (table.options.getSubRows) {
|
|
3220
2792
|
var _row$originalSubRows;
|
|
2793
|
+
row.originalSubRows = table.options.getSubRows(originalRows[i], i);
|
|
3221
2794
|
|
|
3222
|
-
|
|
3223
|
-
|
|
2795
|
+
// Then recursively access them
|
|
3224
2796
|
if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
|
|
3225
2797
|
row.subRows = accessRows(row.originalSubRows, depth + 1, row);
|
|
3226
2798
|
}
|
|
3227
2799
|
}
|
|
3228
2800
|
}
|
|
3229
|
-
|
|
3230
2801
|
return rows;
|
|
3231
2802
|
};
|
|
3232
|
-
|
|
3233
2803
|
rowModel.rows = accessRows(data);
|
|
3234
2804
|
return rowModel;
|
|
3235
2805
|
}, {
|
|
3236
2806
|
key: 'getRowModel',
|
|
3237
|
-
debug: () =>
|
|
3238
|
-
var _table$options$debugA;
|
|
3239
|
-
|
|
3240
|
-
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugTable;
|
|
3241
|
-
},
|
|
2807
|
+
debug: () => table.options.debugAll ?? table.options.debugTable,
|
|
3242
2808
|
onChange: () => {
|
|
3243
2809
|
table._autoResetPageIndex();
|
|
3244
2810
|
}
|
|
@@ -3249,44 +2815,35 @@
|
|
|
3249
2815
|
if (table.options.filterFromLeafRows) {
|
|
3250
2816
|
return filterRowModelFromLeafs(rows, filterRowImpl, table);
|
|
3251
2817
|
}
|
|
3252
|
-
|
|
3253
2818
|
return filterRowModelFromRoot(rows, filterRowImpl, table);
|
|
3254
2819
|
}
|
|
3255
2820
|
function filterRowModelFromLeafs(rowsToFilter, filterRow, table) {
|
|
3256
2821
|
const newFilteredFlatRows = [];
|
|
3257
2822
|
const newFilteredRowsById = {};
|
|
3258
|
-
|
|
3259
2823
|
const recurseFilterRows = function (rowsToFilter, depth) {
|
|
2824
|
+
const rows = [];
|
|
3260
2825
|
|
|
3261
|
-
|
|
3262
|
-
|
|
2826
|
+
// Filter from children up first
|
|
3263
2827
|
for (let i = 0; i < rowsToFilter.length; i++) {
|
|
3264
2828
|
var _row$subRows;
|
|
3265
|
-
|
|
3266
2829
|
let row = rowsToFilter[i];
|
|
3267
|
-
|
|
3268
2830
|
if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
|
|
3269
2831
|
const newRow = createRow(table, row.id, row.original, row.index, row.depth);
|
|
3270
2832
|
newRow.columnFilters = row.columnFilters;
|
|
3271
2833
|
newRow.subRows = recurseFilterRows(row.subRows);
|
|
3272
|
-
|
|
3273
2834
|
if (!newRow.subRows.length) {
|
|
3274
2835
|
continue;
|
|
3275
2836
|
}
|
|
3276
|
-
|
|
3277
2837
|
row = newRow;
|
|
3278
2838
|
}
|
|
3279
|
-
|
|
3280
2839
|
if (filterRow(row)) {
|
|
3281
2840
|
rows.push(row);
|
|
3282
2841
|
newFilteredRowsById[row.id] = row;
|
|
3283
2842
|
newFilteredRowsById[i] = row;
|
|
3284
2843
|
}
|
|
3285
2844
|
}
|
|
3286
|
-
|
|
3287
2845
|
return rows;
|
|
3288
2846
|
};
|
|
3289
|
-
|
|
3290
2847
|
return {
|
|
3291
2848
|
rows: recurseFilterRows(rowsToFilter),
|
|
3292
2849
|
flatRows: newFilteredFlatRows,
|
|
@@ -3295,35 +2852,32 @@
|
|
|
3295
2852
|
}
|
|
3296
2853
|
function filterRowModelFromRoot(rowsToFilter, filterRow, table) {
|
|
3297
2854
|
const newFilteredFlatRows = [];
|
|
3298
|
-
const newFilteredRowsById = {};
|
|
2855
|
+
const newFilteredRowsById = {};
|
|
3299
2856
|
|
|
2857
|
+
// Filters top level and nested rows
|
|
3300
2858
|
const recurseFilterRows = function (rowsToFilter, depth) {
|
|
3301
|
-
|
|
3302
2859
|
// Filter from parents downward first
|
|
3303
|
-
const rows = []; // Apply the filter to any subRows
|
|
3304
2860
|
|
|
2861
|
+
const rows = [];
|
|
2862
|
+
|
|
2863
|
+
// Apply the filter to any subRows
|
|
3305
2864
|
for (let i = 0; i < rowsToFilter.length; i++) {
|
|
3306
2865
|
let row = rowsToFilter[i];
|
|
3307
2866
|
const pass = filterRow(row);
|
|
3308
|
-
|
|
3309
2867
|
if (pass) {
|
|
3310
2868
|
var _row$subRows2;
|
|
3311
|
-
|
|
3312
2869
|
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
|
|
3313
2870
|
const newRow = createRow(table, row.id, row.original, row.index, row.depth);
|
|
3314
2871
|
newRow.subRows = recurseFilterRows(row.subRows);
|
|
3315
2872
|
row = newRow;
|
|
3316
2873
|
}
|
|
3317
|
-
|
|
3318
2874
|
rows.push(row);
|
|
3319
2875
|
newFilteredFlatRows.push(row);
|
|
3320
2876
|
newFilteredRowsById[row.id] = row;
|
|
3321
2877
|
}
|
|
3322
2878
|
}
|
|
3323
|
-
|
|
3324
2879
|
return rows;
|
|
3325
2880
|
};
|
|
3326
|
-
|
|
3327
2881
|
return {
|
|
3328
2882
|
rows: recurseFilterRows(rowsToFilter),
|
|
3329
2883
|
flatRows: newFilteredFlatRows,
|
|
@@ -3338,79 +2892,66 @@
|
|
|
3338
2892
|
rowModel.flatRows[i].columnFilters = {};
|
|
3339
2893
|
rowModel.flatRows[i].columnFiltersMeta = {};
|
|
3340
2894
|
}
|
|
3341
|
-
|
|
3342
2895
|
return rowModel;
|
|
3343
2896
|
}
|
|
3344
|
-
|
|
3345
2897
|
const resolvedColumnFilters = [];
|
|
3346
2898
|
const resolvedGlobalFilters = [];
|
|
3347
|
-
(columnFilters
|
|
3348
|
-
var _filterFn$resolveFilt;
|
|
3349
|
-
|
|
2899
|
+
(columnFilters ?? []).forEach(d => {
|
|
3350
2900
|
const column = table.getColumn(d.id);
|
|
3351
|
-
|
|
3352
2901
|
if (!column) {
|
|
3353
2902
|
{
|
|
3354
|
-
console.warn(
|
|
2903
|
+
console.warn(`Table: Could not find a column to filter with columnId: ${d.id}`);
|
|
3355
2904
|
}
|
|
3356
2905
|
}
|
|
3357
|
-
|
|
3358
2906
|
const filterFn = column.getFilterFn();
|
|
3359
|
-
|
|
3360
2907
|
if (!filterFn) {
|
|
3361
2908
|
{
|
|
3362
|
-
console.warn(
|
|
2909
|
+
console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${column.id}.`);
|
|
3363
2910
|
}
|
|
3364
|
-
|
|
3365
2911
|
return;
|
|
3366
2912
|
}
|
|
3367
|
-
|
|
3368
2913
|
resolvedColumnFilters.push({
|
|
3369
2914
|
id: d.id,
|
|
3370
2915
|
filterFn,
|
|
3371
|
-
resolvedValue: (
|
|
2916
|
+
resolvedValue: (filterFn.resolveFilterValue == null ? void 0 : filterFn.resolveFilterValue(d.value)) ?? d.value
|
|
3372
2917
|
});
|
|
3373
2918
|
});
|
|
3374
2919
|
const filterableIds = columnFilters.map(d => d.id);
|
|
3375
2920
|
const globalFilterFn = table.getGlobalFilterFn();
|
|
3376
2921
|
const globallyFilterableColumns = table.getAllLeafColumns().filter(column => column.getCanGlobalFilter());
|
|
3377
|
-
|
|
3378
2922
|
if (globalFilter && globalFilterFn && globallyFilterableColumns.length) {
|
|
3379
2923
|
filterableIds.push('__global__');
|
|
3380
2924
|
globallyFilterableColumns.forEach(column => {
|
|
3381
|
-
var _globalFilterFn$resol;
|
|
3382
|
-
|
|
3383
2925
|
resolvedGlobalFilters.push({
|
|
3384
2926
|
id: column.id,
|
|
3385
2927
|
filterFn: globalFilterFn,
|
|
3386
|
-
resolvedValue: (
|
|
2928
|
+
resolvedValue: (globalFilterFn.resolveFilterValue == null ? void 0 : globalFilterFn.resolveFilterValue(globalFilter)) ?? globalFilter
|
|
3387
2929
|
});
|
|
3388
2930
|
});
|
|
3389
2931
|
}
|
|
3390
|
-
|
|
3391
2932
|
let currentColumnFilter;
|
|
3392
|
-
let currentGlobalFilter;
|
|
2933
|
+
let currentGlobalFilter;
|
|
3393
2934
|
|
|
2935
|
+
// Flag the prefiltered row model with each filter state
|
|
3394
2936
|
for (let j = 0; j < rowModel.flatRows.length; j++) {
|
|
3395
2937
|
const row = rowModel.flatRows[j];
|
|
3396
2938
|
row.columnFilters = {};
|
|
3397
|
-
|
|
3398
2939
|
if (resolvedColumnFilters.length) {
|
|
3399
2940
|
for (let i = 0; i < resolvedColumnFilters.length; i++) {
|
|
3400
2941
|
currentColumnFilter = resolvedColumnFilters[i];
|
|
3401
|
-
const id = currentColumnFilter.id;
|
|
2942
|
+
const id = currentColumnFilter.id;
|
|
3402
2943
|
|
|
2944
|
+
// Tag the row with the column filter state
|
|
3403
2945
|
row.columnFilters[id] = currentColumnFilter.filterFn(row, id, currentColumnFilter.resolvedValue, filterMeta => {
|
|
3404
2946
|
row.columnFiltersMeta[id] = filterMeta;
|
|
3405
2947
|
});
|
|
3406
2948
|
}
|
|
3407
2949
|
}
|
|
3408
|
-
|
|
3409
2950
|
if (resolvedGlobalFilters.length) {
|
|
3410
2951
|
for (let i = 0; i < resolvedGlobalFilters.length; i++) {
|
|
3411
2952
|
currentGlobalFilter = resolvedGlobalFilters[i];
|
|
3412
|
-
const id = currentGlobalFilter.id;
|
|
3413
|
-
|
|
2953
|
+
const id = currentGlobalFilter.id;
|
|
2954
|
+
// Tag the row with the first truthy global filter state
|
|
3414
2955
|
if (currentGlobalFilter.filterFn(row, id, currentGlobalFilter.resolvedValue, filterMeta => {
|
|
3415
2956
|
row.columnFiltersMeta[id] = filterMeta;
|
|
3416
2957
|
})) {
|
|
@@ -3418,13 +2959,11 @@
|
|
|
3418
2959
|
break;
|
|
3419
2960
|
}
|
|
3420
2961
|
}
|
|
3421
|
-
|
|
3422
2962
|
if (row.columnFilters.__global__ !== true) {
|
|
3423
2963
|
row.columnFilters.__global__ = false;
|
|
3424
2964
|
}
|
|
3425
2965
|
}
|
|
3426
2966
|
}
|
|
3427
|
-
|
|
3428
2967
|
const filterRowsImpl = row => {
|
|
3429
2968
|
// Horizontally filter rows through each column
|
|
3430
2969
|
for (let i = 0; i < filterableIds.length; i++) {
|
|
@@ -3432,19 +2971,14 @@
|
|
|
3432
2971
|
return false;
|
|
3433
2972
|
}
|
|
3434
2973
|
}
|
|
3435
|
-
|
|
3436
2974
|
return true;
|
|
3437
|
-
};
|
|
3438
|
-
|
|
2975
|
+
};
|
|
3439
2976
|
|
|
2977
|
+
// Filter final rows using all of the active filters
|
|
3440
2978
|
return filterRows(rowModel.rows, filterRowsImpl, table);
|
|
3441
2979
|
}, {
|
|
3442
2980
|
key: 'getFilteredRowModel',
|
|
3443
|
-
debug: () =>
|
|
3444
|
-
var _table$options$debugA;
|
|
3445
|
-
|
|
3446
|
-
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugTable;
|
|
3447
|
-
},
|
|
2981
|
+
debug: () => table.options.debugAll ?? table.options.debugTable,
|
|
3448
2982
|
onChange: () => {
|
|
3449
2983
|
table._autoResetPageIndex();
|
|
3450
2984
|
}
|
|
@@ -3456,9 +2990,7 @@
|
|
|
3456
2990
|
if (!preRowModel.rows.length || !(columnFilters != null && columnFilters.length) && !globalFilter) {
|
|
3457
2991
|
return preRowModel;
|
|
3458
2992
|
}
|
|
3459
|
-
|
|
3460
2993
|
const filterableIds = [...columnFilters.map(d => d.id).filter(d => d !== columnId), globalFilter ? '__global__' : undefined].filter(Boolean);
|
|
3461
|
-
|
|
3462
2994
|
const filterRowsImpl = row => {
|
|
3463
2995
|
// Horizontally filter rows through each column
|
|
3464
2996
|
for (let i = 0; i < filterableIds.length; i++) {
|
|
@@ -3466,18 +2998,12 @@
|
|
|
3466
2998
|
return false;
|
|
3467
2999
|
}
|
|
3468
3000
|
}
|
|
3469
|
-
|
|
3470
3001
|
return true;
|
|
3471
3002
|
};
|
|
3472
|
-
|
|
3473
3003
|
return filterRows(preRowModel.rows, filterRowsImpl, table);
|
|
3474
3004
|
}, {
|
|
3475
3005
|
key: 'getFacetedRowModel_' + columnId,
|
|
3476
|
-
debug: () =>
|
|
3477
|
-
var _table$options$debugA;
|
|
3478
|
-
|
|
3479
|
-
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugTable;
|
|
3480
|
-
},
|
|
3006
|
+
debug: () => table.options.debugAll ?? table.options.debugTable,
|
|
3481
3007
|
onChange: () => {}
|
|
3482
3008
|
});
|
|
3483
3009
|
}
|
|
@@ -3485,29 +3011,19 @@
|
|
|
3485
3011
|
function getFacetedUniqueValues() {
|
|
3486
3012
|
return (table, columnId) => memo(() => [table.getColumn(columnId).getFacetedRowModel()], facetedRowModel => {
|
|
3487
3013
|
let facetedUniqueValues = new Map();
|
|
3488
|
-
|
|
3489
3014
|
for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
|
|
3490
3015
|
var _facetedRowModel$flat;
|
|
3491
|
-
|
|
3492
3016
|
const value = (_facetedRowModel$flat = facetedRowModel.flatRows[i]) == null ? void 0 : _facetedRowModel$flat.getValue(columnId);
|
|
3493
|
-
|
|
3494
3017
|
if (facetedUniqueValues.has(value)) {
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
facetedUniqueValues.set(value, ((_facetedUniqueValues$ = facetedUniqueValues.get(value)) != null ? _facetedUniqueValues$ : 0) + 1);
|
|
3018
|
+
facetedUniqueValues.set(value, (facetedUniqueValues.get(value) ?? 0) + 1);
|
|
3498
3019
|
} else {
|
|
3499
3020
|
facetedUniqueValues.set(value, 1);
|
|
3500
3021
|
}
|
|
3501
3022
|
}
|
|
3502
|
-
|
|
3503
3023
|
return facetedUniqueValues;
|
|
3504
3024
|
}, {
|
|
3505
3025
|
key: 'getFacetedUniqueValues_' + columnId,
|
|
3506
|
-
debug: () =>
|
|
3507
|
-
var _table$options$debugA;
|
|
3508
|
-
|
|
3509
|
-
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugTable;
|
|
3510
|
-
},
|
|
3026
|
+
debug: () => table.options.debugAll ?? table.options.debugTable,
|
|
3511
3027
|
onChange: () => {}
|
|
3512
3028
|
});
|
|
3513
3029
|
}
|
|
@@ -3515,33 +3031,23 @@
|
|
|
3515
3031
|
function getFacetedMinMaxValues() {
|
|
3516
3032
|
return (table, columnId) => memo(() => [table.getColumn(columnId).getFacetedRowModel()], facetedRowModel => {
|
|
3517
3033
|
var _facetedRowModel$flat;
|
|
3518
|
-
|
|
3519
3034
|
const firstValue = (_facetedRowModel$flat = facetedRowModel.flatRows[0]) == null ? void 0 : _facetedRowModel$flat.getValue(columnId);
|
|
3520
|
-
|
|
3521
3035
|
if (typeof firstValue === 'undefined') {
|
|
3522
3036
|
return undefined;
|
|
3523
3037
|
}
|
|
3524
|
-
|
|
3525
3038
|
let facetedMinMaxValues = [firstValue, firstValue];
|
|
3526
|
-
|
|
3527
3039
|
for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
|
|
3528
3040
|
const value = facetedRowModel.flatRows[i].getValue(columnId);
|
|
3529
|
-
|
|
3530
3041
|
if (value < facetedMinMaxValues[0]) {
|
|
3531
3042
|
facetedMinMaxValues[0] = value;
|
|
3532
3043
|
} else if (value > facetedMinMaxValues[1]) {
|
|
3533
3044
|
facetedMinMaxValues[1] = value;
|
|
3534
3045
|
}
|
|
3535
3046
|
}
|
|
3536
|
-
|
|
3537
3047
|
return facetedMinMaxValues;
|
|
3538
3048
|
}, {
|
|
3539
3049
|
key: 'getFacetedMinMaxValues_' + columnId,
|
|
3540
|
-
debug: () =>
|
|
3541
|
-
var _table$options$debugA;
|
|
3542
|
-
|
|
3543
|
-
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugTable;
|
|
3544
|
-
},
|
|
3050
|
+
debug: () => table.options.debugAll ?? table.options.debugTable,
|
|
3545
3051
|
onChange: () => {}
|
|
3546
3052
|
});
|
|
3547
3053
|
}
|
|
@@ -3551,10 +3057,10 @@
|
|
|
3551
3057
|
if (!rowModel.rows.length || !(sorting != null && sorting.length)) {
|
|
3552
3058
|
return rowModel;
|
|
3553
3059
|
}
|
|
3554
|
-
|
|
3555
3060
|
const sortingState = table.getState().sorting;
|
|
3556
|
-
const sortedFlatRows = [];
|
|
3061
|
+
const sortedFlatRows = [];
|
|
3557
3062
|
|
|
3063
|
+
// Filter out sortings that correspond to non existing columns
|
|
3558
3064
|
const availableSorting = sortingState.filter(sort => table.getColumn(sort.id).getCanSort());
|
|
3559
3065
|
const columnInfoById = {};
|
|
3560
3066
|
availableSorting.forEach(sortEntry => {
|
|
@@ -3565,61 +3071,50 @@
|
|
|
3565
3071
|
sortingFn: column.getSortingFn()
|
|
3566
3072
|
};
|
|
3567
3073
|
});
|
|
3568
|
-
|
|
3569
3074
|
const sortData = rows => {
|
|
3570
3075
|
// This will also perform a stable sorting using the row index
|
|
3571
3076
|
// if needed.
|
|
3572
3077
|
const sortedData = rows.slice();
|
|
3573
3078
|
sortedData.sort((rowA, rowB) => {
|
|
3574
3079
|
for (let i = 0; i < availableSorting.length; i += 1) {
|
|
3575
|
-
var _sortEntry$desc;
|
|
3576
|
-
|
|
3577
3080
|
const sortEntry = availableSorting[i];
|
|
3578
3081
|
const columnInfo = columnInfoById[sortEntry.id];
|
|
3579
|
-
const isDesc = (
|
|
3580
|
-
|
|
3082
|
+
const isDesc = (sortEntry == null ? void 0 : sortEntry.desc) ?? false;
|
|
3581
3083
|
if (columnInfo.sortUndefined) {
|
|
3582
3084
|
const aValue = rowA.getValue(sortEntry.id);
|
|
3583
3085
|
const bValue = rowB.getValue(sortEntry.id);
|
|
3584
3086
|
const aUndefined = typeof aValue === 'undefined';
|
|
3585
3087
|
const bUndefined = typeof bValue === 'undefined';
|
|
3586
|
-
|
|
3587
3088
|
if (aUndefined || bUndefined) {
|
|
3588
3089
|
return aUndefined && bUndefined ? 0 : aUndefined ? columnInfo.sortUndefined : -columnInfo.sortUndefined;
|
|
3589
3090
|
}
|
|
3590
|
-
}
|
|
3591
|
-
|
|
3091
|
+
}
|
|
3592
3092
|
|
|
3093
|
+
// This function should always return in ascending order
|
|
3593
3094
|
let sortInt = columnInfo.sortingFn(rowA, rowB, sortEntry.id);
|
|
3594
|
-
|
|
3595
3095
|
if (sortInt !== 0) {
|
|
3596
3096
|
if (isDesc) {
|
|
3597
3097
|
sortInt *= -1;
|
|
3598
3098
|
}
|
|
3599
|
-
|
|
3600
3099
|
if (columnInfo.invertSorting) {
|
|
3601
3100
|
sortInt *= -1;
|
|
3602
3101
|
}
|
|
3603
|
-
|
|
3604
3102
|
return sortInt;
|
|
3605
3103
|
}
|
|
3606
3104
|
}
|
|
3607
|
-
|
|
3608
3105
|
return rowA.index - rowB.index;
|
|
3609
|
-
});
|
|
3106
|
+
});
|
|
3610
3107
|
|
|
3108
|
+
// If there are sub-rows, sort them
|
|
3611
3109
|
sortedData.forEach(row => {
|
|
3612
3110
|
sortedFlatRows.push(row);
|
|
3613
|
-
|
|
3614
3111
|
if (!row.subRows || row.subRows.length <= 1) {
|
|
3615
3112
|
return;
|
|
3616
3113
|
}
|
|
3617
|
-
|
|
3618
3114
|
row.subRows = sortData(row.subRows);
|
|
3619
3115
|
});
|
|
3620
3116
|
return sortedData;
|
|
3621
3117
|
};
|
|
3622
|
-
|
|
3623
3118
|
return {
|
|
3624
3119
|
rows: sortData(rowModel.rows),
|
|
3625
3120
|
flatRows: sortedFlatRows,
|
|
@@ -3627,11 +3122,7 @@
|
|
|
3627
3122
|
};
|
|
3628
3123
|
}, {
|
|
3629
3124
|
key: 'getSortedRowModel',
|
|
3630
|
-
debug: () =>
|
|
3631
|
-
var _table$options$debugA;
|
|
3632
|
-
|
|
3633
|
-
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugTable;
|
|
3634
|
-
},
|
|
3125
|
+
debug: () => table.options.debugAll ?? table.options.debugTable,
|
|
3635
3126
|
onChange: () => {
|
|
3636
3127
|
table._autoResetPageIndex();
|
|
3637
3128
|
}
|
|
@@ -3642,22 +3133,22 @@
|
|
|
3642
3133
|
return table => memo(() => [table.getState().grouping, table.getPreGroupedRowModel()], (grouping, rowModel) => {
|
|
3643
3134
|
if (!rowModel.rows.length || !grouping.length) {
|
|
3644
3135
|
return rowModel;
|
|
3645
|
-
}
|
|
3646
|
-
|
|
3136
|
+
}
|
|
3647
3137
|
|
|
3138
|
+
// Filter the grouping list down to columns that exist
|
|
3648
3139
|
const existingGrouping = grouping.filter(columnId => table.getColumn(columnId));
|
|
3649
3140
|
const groupedFlatRows = [];
|
|
3650
|
-
const groupedRowsById = {};
|
|
3141
|
+
const groupedRowsById = {};
|
|
3142
|
+
// const onlyGroupedFlatRows: Row[] = [];
|
|
3651
3143
|
// const onlyGroupedRowsById: Record<RowId, Row> = {};
|
|
3652
3144
|
// const nonGroupedFlatRows: Row[] = [];
|
|
3653
3145
|
// const nonGroupedRowsById: Record<RowId, Row> = {};
|
|
3654
|
-
// Recursively group the data
|
|
3655
3146
|
|
|
3147
|
+
// Recursively group the data
|
|
3656
3148
|
const groupUpRecursively = function (rows, depth, parentId) {
|
|
3657
3149
|
if (depth === void 0) {
|
|
3658
3150
|
depth = 0;
|
|
3659
3151
|
}
|
|
3660
|
-
|
|
3661
3152
|
// Grouping depth has been been met
|
|
3662
3153
|
// Stop grouping and simply rewrite thd depth and row relationships
|
|
3663
3154
|
if (depth >= existingGrouping.length) {
|
|
@@ -3665,26 +3156,27 @@
|
|
|
3665
3156
|
row.depth = depth;
|
|
3666
3157
|
groupedFlatRows.push(row);
|
|
3667
3158
|
groupedRowsById[row.id] = row;
|
|
3668
|
-
|
|
3669
3159
|
if (row.subRows) {
|
|
3670
3160
|
row.subRows = groupUpRecursively(row.subRows, depth + 1);
|
|
3671
3161
|
}
|
|
3672
|
-
|
|
3673
3162
|
return row;
|
|
3674
3163
|
});
|
|
3675
3164
|
}
|
|
3165
|
+
const columnId = existingGrouping[depth];
|
|
3676
3166
|
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
const rowGroupsMap = groupBy(rows, columnId); // Peform aggregations for each group
|
|
3167
|
+
// Group the rows together for this level
|
|
3168
|
+
const rowGroupsMap = groupBy(rows, columnId);
|
|
3680
3169
|
|
|
3170
|
+
// Peform aggregations for each group
|
|
3681
3171
|
const aggregatedGroupedRows = Array.from(rowGroupsMap.entries()).map((_ref, index) => {
|
|
3682
3172
|
let [groupingValue, groupedRows] = _ref;
|
|
3683
|
-
let id = columnId
|
|
3684
|
-
id = parentId ? parentId
|
|
3173
|
+
let id = `${columnId}:${groupingValue}`;
|
|
3174
|
+
id = parentId ? `${parentId}>${id}` : id;
|
|
3685
3175
|
|
|
3686
|
-
|
|
3176
|
+
// First, Recurse to group sub rows before aggregation
|
|
3177
|
+
const subRows = groupUpRecursively(groupedRows, depth + 1, id);
|
|
3687
3178
|
|
|
3179
|
+
// Flatten the leaf rows of the rows in this group
|
|
3688
3180
|
const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
|
|
3689
3181
|
const row = createRow(table, id, leafRows[0].original, index, depth);
|
|
3690
3182
|
Object.assign(row, {
|
|
@@ -3698,24 +3190,18 @@
|
|
|
3698
3190
|
if (row._valuesCache.hasOwnProperty(columnId)) {
|
|
3699
3191
|
return row._valuesCache[columnId];
|
|
3700
3192
|
}
|
|
3701
|
-
|
|
3702
3193
|
if (groupedRows[0]) {
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
row._valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
|
|
3194
|
+
row._valuesCache[columnId] = groupedRows[0].getValue(columnId) ?? undefined;
|
|
3706
3195
|
}
|
|
3707
|
-
|
|
3708
3196
|
return row._valuesCache[columnId];
|
|
3709
3197
|
}
|
|
3710
|
-
|
|
3711
3198
|
if (row._groupingValuesCache.hasOwnProperty(columnId)) {
|
|
3712
3199
|
return row._groupingValuesCache[columnId];
|
|
3713
|
-
}
|
|
3714
|
-
|
|
3200
|
+
}
|
|
3715
3201
|
|
|
3202
|
+
// Aggregate the values
|
|
3716
3203
|
const column = table.getColumn(columnId);
|
|
3717
3204
|
const aggregateFn = column.getAggregationFn();
|
|
3718
|
-
|
|
3719
3205
|
if (aggregateFn) {
|
|
3720
3206
|
row._groupingValuesCache[columnId] = aggregateFn(columnId, leafRows, groupedRows);
|
|
3721
3207
|
return row._groupingValuesCache[columnId];
|
|
@@ -3724,7 +3210,8 @@
|
|
|
3724
3210
|
});
|
|
3725
3211
|
subRows.forEach(subRow => {
|
|
3726
3212
|
groupedFlatRows.push(subRow);
|
|
3727
|
-
groupedRowsById[subRow.id] = subRow;
|
|
3213
|
+
groupedRowsById[subRow.id] = subRow;
|
|
3214
|
+
// if (subRow.getIsGrouped?.()) {
|
|
3728
3215
|
// onlyGroupedFlatRows.push(subRow);
|
|
3729
3216
|
// onlyGroupedRowsById[subRow.id] = subRow;
|
|
3730
3217
|
// } else {
|
|
@@ -3732,15 +3219,16 @@
|
|
|
3732
3219
|
// nonGroupedRowsById[subRow.id] = subRow;
|
|
3733
3220
|
// }
|
|
3734
3221
|
});
|
|
3222
|
+
|
|
3735
3223
|
return row;
|
|
3736
3224
|
});
|
|
3737
3225
|
return aggregatedGroupedRows;
|
|
3738
3226
|
};
|
|
3739
|
-
|
|
3740
3227
|
const groupedRows = groupUpRecursively(rowModel.rows, 0, '');
|
|
3741
3228
|
groupedRows.forEach(subRow => {
|
|
3742
3229
|
groupedFlatRows.push(subRow);
|
|
3743
|
-
groupedRowsById[subRow.id] = subRow;
|
|
3230
|
+
groupedRowsById[subRow.id] = subRow;
|
|
3231
|
+
// if (subRow.getIsGrouped?.()) {
|
|
3744
3232
|
// onlyGroupedFlatRows.push(subRow);
|
|
3745
3233
|
// onlyGroupedRowsById[subRow.id] = subRow;
|
|
3746
3234
|
// } else {
|
|
@@ -3748,6 +3236,7 @@
|
|
|
3748
3236
|
// nonGroupedRowsById[subRow.id] = subRow;
|
|
3749
3237
|
// }
|
|
3750
3238
|
});
|
|
3239
|
+
|
|
3751
3240
|
return {
|
|
3752
3241
|
rows: groupedRows,
|
|
3753
3242
|
flatRows: groupedFlatRows,
|
|
@@ -3755,71 +3244,53 @@
|
|
|
3755
3244
|
};
|
|
3756
3245
|
}, {
|
|
3757
3246
|
key: 'getGroupedRowModel',
|
|
3758
|
-
debug: () =>
|
|
3759
|
-
var _table$options$debugA;
|
|
3760
|
-
|
|
3761
|
-
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugTable;
|
|
3762
|
-
},
|
|
3247
|
+
debug: () => table.options.debugAll ?? table.options.debugTable,
|
|
3763
3248
|
onChange: () => {
|
|
3764
3249
|
table._queue(() => {
|
|
3765
3250
|
table._autoResetExpanded();
|
|
3766
|
-
|
|
3767
3251
|
table._autoResetPageIndex();
|
|
3768
3252
|
});
|
|
3769
3253
|
}
|
|
3770
3254
|
});
|
|
3771
3255
|
}
|
|
3772
|
-
|
|
3773
3256
|
function groupBy(rows, columnId) {
|
|
3774
3257
|
const groupMap = new Map();
|
|
3775
3258
|
return rows.reduce((map, row) => {
|
|
3776
|
-
const resKey =
|
|
3259
|
+
const resKey = `${row.getValue(columnId)}`;
|
|
3777
3260
|
const previous = map.get(resKey);
|
|
3778
|
-
|
|
3779
3261
|
if (!previous) {
|
|
3780
3262
|
map.set(resKey, [row]);
|
|
3781
3263
|
} else {
|
|
3782
3264
|
map.set(resKey, [...previous, row]);
|
|
3783
3265
|
}
|
|
3784
|
-
|
|
3785
3266
|
return map;
|
|
3786
3267
|
}, groupMap);
|
|
3787
3268
|
}
|
|
3788
3269
|
|
|
3789
3270
|
function getExpandedRowModel() {
|
|
3790
3271
|
return table => memo(() => [table.getState().expanded, table.getPreExpandedRowModel(), table.options.paginateExpandedRows], (expanded, rowModel, paginateExpandedRows) => {
|
|
3791
|
-
if (!rowModel.rows.length || expanded !== true && !Object.keys(expanded
|
|
3272
|
+
if (!rowModel.rows.length || expanded !== true && !Object.keys(expanded ?? {}).length) {
|
|
3792
3273
|
return rowModel;
|
|
3793
3274
|
}
|
|
3794
|
-
|
|
3795
3275
|
if (!paginateExpandedRows) {
|
|
3796
3276
|
// Only expand rows at this point if they are being paginated
|
|
3797
3277
|
return rowModel;
|
|
3798
3278
|
}
|
|
3799
|
-
|
|
3800
3279
|
return expandRows(rowModel);
|
|
3801
3280
|
}, {
|
|
3802
3281
|
key: 'getExpandedRowModel',
|
|
3803
|
-
debug: () =>
|
|
3804
|
-
var _table$options$debugA;
|
|
3805
|
-
|
|
3806
|
-
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugTable;
|
|
3807
|
-
}
|
|
3282
|
+
debug: () => table.options.debugAll ?? table.options.debugTable
|
|
3808
3283
|
});
|
|
3809
3284
|
}
|
|
3810
3285
|
function expandRows(rowModel) {
|
|
3811
3286
|
const expandedRows = [];
|
|
3812
|
-
|
|
3813
3287
|
const handleRow = row => {
|
|
3814
3288
|
var _row$subRows;
|
|
3815
|
-
|
|
3816
3289
|
expandedRows.push(row);
|
|
3817
|
-
|
|
3818
3290
|
if ((_row$subRows = row.subRows) != null && _row$subRows.length && row.getIsExpanded()) {
|
|
3819
3291
|
row.subRows.forEach(handleRow);
|
|
3820
3292
|
}
|
|
3821
3293
|
};
|
|
3822
|
-
|
|
3823
3294
|
rowModel.rows.forEach(handleRow);
|
|
3824
3295
|
return {
|
|
3825
3296
|
rows: expandedRows,
|
|
@@ -3833,7 +3304,6 @@
|
|
|
3833
3304
|
if (!rowModel.rows.length) {
|
|
3834
3305
|
return rowModel;
|
|
3835
3306
|
}
|
|
3836
|
-
|
|
3837
3307
|
const {
|
|
3838
3308
|
pageSize,
|
|
3839
3309
|
pageIndex
|
|
@@ -3847,7 +3317,6 @@
|
|
|
3847
3317
|
const pageEnd = pageStart + pageSize;
|
|
3848
3318
|
rows = rows.slice(pageStart, pageEnd);
|
|
3849
3319
|
let paginatedRowModel;
|
|
3850
|
-
|
|
3851
3320
|
if (!table.options.paginateExpandedRows) {
|
|
3852
3321
|
paginatedRowModel = expandRows({
|
|
3853
3322
|
rows,
|
|
@@ -3861,26 +3330,18 @@
|
|
|
3861
3330
|
rowsById
|
|
3862
3331
|
};
|
|
3863
3332
|
}
|
|
3864
|
-
|
|
3865
3333
|
paginatedRowModel.flatRows = [];
|
|
3866
|
-
|
|
3867
3334
|
const handleRow = row => {
|
|
3868
3335
|
paginatedRowModel.flatRows.push(row);
|
|
3869
|
-
|
|
3870
3336
|
if (row.subRows.length) {
|
|
3871
3337
|
row.subRows.forEach(handleRow);
|
|
3872
3338
|
}
|
|
3873
3339
|
};
|
|
3874
|
-
|
|
3875
3340
|
paginatedRowModel.rows.forEach(handleRow);
|
|
3876
3341
|
return paginatedRowModel;
|
|
3877
3342
|
}, {
|
|
3878
3343
|
key: 'getPaginationRowModel',
|
|
3879
|
-
debug: () =>
|
|
3880
|
-
var _table$options$debugA;
|
|
3881
|
-
|
|
3882
|
-
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugTable;
|
|
3883
|
-
}
|
|
3344
|
+
debug: () => table.options.debugAll ?? table.options.debugTable
|
|
3884
3345
|
});
|
|
3885
3346
|
}
|
|
3886
3347
|
|