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