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