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