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