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