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