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