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