@tanstack/react-table 8.0.0-alpha.82 → 8.0.0-alpha.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/react-table/src/index.js +2 -1
- package/build/cjs/react-table/src/index.js.map +1 -1
- package/build/cjs/table-core/build/esm/index.js +765 -865
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +764 -865
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +17 -17
- package/build/types/index.d.ts +2 -2
- package/build/umd/index.development.js +767 -863
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +3 -5
|
@@ -121,327 +121,457 @@
|
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
function createColumn(instance, columnDef, depth, parent) {
|
|
125
|
+
var _ref, _columnDef$id;
|
|
126
|
+
|
|
127
|
+
const defaultColumn = instance._getDefaultColumnDef();
|
|
128
|
+
|
|
129
|
+
columnDef = { ...defaultColumn,
|
|
130
|
+
...columnDef
|
|
131
|
+
};
|
|
132
|
+
let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
|
|
133
|
+
let accessorFn;
|
|
134
|
+
|
|
135
|
+
if (columnDef.accessorFn) {
|
|
136
|
+
accessorFn = columnDef.accessorFn;
|
|
137
|
+
} else if (columnDef.accessorKey) {
|
|
138
|
+
accessorFn = originalRow => originalRow[columnDef.accessorKey];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (!id) {
|
|
142
|
+
{
|
|
143
|
+
throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
let column = { ...columnDef,
|
|
148
|
+
id: "" + id,
|
|
149
|
+
accessorFn,
|
|
150
|
+
parent: parent,
|
|
151
|
+
depth,
|
|
152
|
+
columnDef,
|
|
153
|
+
columnDefType: columnDef.columnDefType,
|
|
154
|
+
columns: [],
|
|
155
|
+
getFlatColumns: memo(() => [true], () => {
|
|
156
|
+
var _column$columns;
|
|
157
|
+
|
|
158
|
+
return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
|
|
159
|
+
}, {
|
|
160
|
+
key: "development" === 'production' ,
|
|
161
|
+
debug: () => {
|
|
162
|
+
var _instance$options$deb;
|
|
163
|
+
|
|
164
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
|
|
165
|
+
}
|
|
166
|
+
}),
|
|
167
|
+
getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
|
|
168
|
+
var _column$columns2;
|
|
169
|
+
|
|
170
|
+
if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
|
|
171
|
+
let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
|
|
172
|
+
return orderColumns(leafColumns);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return [column];
|
|
176
|
+
}, {
|
|
177
|
+
key: "development" === 'production' ,
|
|
178
|
+
debug: () => {
|
|
179
|
+
var _instance$options$deb2;
|
|
180
|
+
|
|
181
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
};
|
|
185
|
+
column = instance._features.reduce((obj, feature) => {
|
|
186
|
+
return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
|
|
187
|
+
}, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
188
|
+
|
|
189
|
+
return column;
|
|
190
|
+
}
|
|
191
|
+
|
|
124
192
|
//
|
|
125
|
-
|
|
193
|
+
function createHeader(instance, column, options) {
|
|
194
|
+
var _options$id;
|
|
195
|
+
|
|
196
|
+
const id = (_options$id = options.id) != null ? _options$id : column.id;
|
|
197
|
+
let header = {
|
|
198
|
+
id,
|
|
199
|
+
column,
|
|
200
|
+
index: options.index,
|
|
201
|
+
isPlaceholder: !!options.isPlaceholder,
|
|
202
|
+
placeholderId: options.placeholderId,
|
|
203
|
+
depth: options.depth,
|
|
204
|
+
subHeaders: [],
|
|
205
|
+
colSpan: 0,
|
|
206
|
+
rowSpan: 0,
|
|
207
|
+
headerGroup: null,
|
|
208
|
+
getLeafHeaders: () => {
|
|
209
|
+
const leafHeaders = [];
|
|
210
|
+
|
|
211
|
+
const recurseHeader = h => {
|
|
212
|
+
if (h.subHeaders && h.subHeaders.length) {
|
|
213
|
+
h.subHeaders.map(recurseHeader);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
leafHeaders.push(h);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
recurseHeader(header);
|
|
220
|
+
return leafHeaders;
|
|
221
|
+
},
|
|
222
|
+
renderHeader: () => column.columnDef.header ? instance._render(column.columnDef.header, {
|
|
223
|
+
instance,
|
|
224
|
+
header: header,
|
|
225
|
+
column
|
|
226
|
+
}) : null,
|
|
227
|
+
renderFooter: () => column.columnDef.footer ? instance._render(column.columnDef.footer, {
|
|
228
|
+
instance,
|
|
229
|
+
header: header,
|
|
230
|
+
column
|
|
231
|
+
}) : null
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
instance._features.forEach(feature => {
|
|
235
|
+
Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
return header;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const Headers = {
|
|
126
242
|
createInstance: instance => {
|
|
127
243
|
return {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return (_props$getValue$toStr = (_props$getValue$toStr2 = (_props$getValue = props.getValue()).toString) == null ? void 0 : _props$getValue$toStr2.call(_props$getValue)) != null ? _props$getValue$toStr : null;
|
|
139
|
-
},
|
|
140
|
-
...instance._features.reduce((obj, feature) => {
|
|
141
|
-
return Object.assign(obj, feature.getDefaultColumn == null ? void 0 : feature.getDefaultColumn());
|
|
142
|
-
}, {}),
|
|
143
|
-
...defaultColumn
|
|
144
|
-
};
|
|
244
|
+
// Header Groups
|
|
245
|
+
getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
246
|
+
var _left$map$filter, _right$map$filter;
|
|
247
|
+
|
|
248
|
+
const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
|
|
249
|
+
const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
|
|
250
|
+
const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
251
|
+
const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
|
|
252
|
+
return headerGroups;
|
|
145
253
|
}, {
|
|
254
|
+
key: 'getHeaderGroups',
|
|
146
255
|
debug: () => {
|
|
147
256
|
var _instance$options$deb;
|
|
148
257
|
|
|
149
|
-
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.
|
|
150
|
-
},
|
|
151
|
-
key: 'getDefaultColumn'
|
|
152
|
-
}),
|
|
153
|
-
getColumnDefs: () => instance.options.columns,
|
|
154
|
-
createColumn: (columnDef, depth, parent) => {
|
|
155
|
-
var _ref, _columnDef$id;
|
|
156
|
-
|
|
157
|
-
const defaultColumn = instance.getDefaultColumn();
|
|
158
|
-
let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
|
|
159
|
-
let accessorFn;
|
|
160
|
-
|
|
161
|
-
if (columnDef.accessorFn) {
|
|
162
|
-
accessorFn = columnDef.accessorFn;
|
|
163
|
-
} else if (columnDef.accessorKey) {
|
|
164
|
-
accessorFn = originalRow => originalRow[columnDef.accessorKey];
|
|
258
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
|
|
165
259
|
}
|
|
260
|
+
}),
|
|
261
|
+
getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
262
|
+
leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
263
|
+
return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
|
|
264
|
+
}, {
|
|
265
|
+
key: 'getCenterHeaderGroups',
|
|
266
|
+
debug: () => {
|
|
267
|
+
var _instance$options$deb2;
|
|
166
268
|
|
|
167
|
-
|
|
168
|
-
{
|
|
169
|
-
throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
|
|
170
|
-
}
|
|
269
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
|
|
171
270
|
}
|
|
271
|
+
}),
|
|
272
|
+
getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
273
|
+
var _left$map$filter2;
|
|
172
274
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
columnDef,
|
|
180
|
-
columnDefType: columnDef.columnDefType,
|
|
181
|
-
columns: [],
|
|
182
|
-
getFlatColumns: memo(() => [true], () => {
|
|
183
|
-
var _column$columns;
|
|
184
|
-
|
|
185
|
-
return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
|
|
186
|
-
}, {
|
|
187
|
-
key: "development" === 'production' ,
|
|
188
|
-
debug: () => {
|
|
189
|
-
var _instance$options$deb2;
|
|
190
|
-
|
|
191
|
-
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
|
|
192
|
-
}
|
|
193
|
-
}),
|
|
194
|
-
getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
|
|
195
|
-
var _column$columns2;
|
|
196
|
-
|
|
197
|
-
if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
|
|
198
|
-
let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
|
|
199
|
-
return orderColumns(leafColumns);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return [column];
|
|
203
|
-
}, {
|
|
204
|
-
key: "development" === 'production' ,
|
|
205
|
-
debug: () => {
|
|
206
|
-
var _instance$options$deb3;
|
|
207
|
-
|
|
208
|
-
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
209
|
-
}
|
|
210
|
-
})
|
|
211
|
-
};
|
|
212
|
-
column = instance._features.reduce((obj, feature) => {
|
|
213
|
-
return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
|
|
214
|
-
}, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
215
|
-
|
|
216
|
-
return column;
|
|
217
|
-
},
|
|
218
|
-
getAllColumns: memo(() => [instance.getColumnDefs()], columnDefs => {
|
|
219
|
-
const recurseColumns = function (columnDefs, parent, depth) {
|
|
220
|
-
if (depth === void 0) {
|
|
221
|
-
depth = 0;
|
|
222
|
-
}
|
|
275
|
+
const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
|
|
276
|
+
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
|
|
277
|
+
}, {
|
|
278
|
+
key: 'getLeftHeaderGroups',
|
|
279
|
+
debug: () => {
|
|
280
|
+
var _instance$options$deb3;
|
|
223
281
|
|
|
224
|
-
return
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
};
|
|
282
|
+
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
|
|
283
|
+
}
|
|
284
|
+
}),
|
|
285
|
+
getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
286
|
+
var _right$map$filter2;
|
|
230
287
|
|
|
231
|
-
|
|
288
|
+
const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
|
|
289
|
+
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
|
|
232
290
|
}, {
|
|
233
|
-
key: '
|
|
291
|
+
key: 'getRightHeaderGroups',
|
|
234
292
|
debug: () => {
|
|
235
293
|
var _instance$options$deb4;
|
|
236
294
|
|
|
237
|
-
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.
|
|
295
|
+
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
|
|
238
296
|
}
|
|
239
297
|
}),
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
});
|
|
298
|
+
// Footer Groups
|
|
299
|
+
getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
300
|
+
return [...headerGroups].reverse();
|
|
244
301
|
}, {
|
|
245
|
-
key: '
|
|
302
|
+
key: 'getFooterGroups',
|
|
246
303
|
debug: () => {
|
|
247
304
|
var _instance$options$deb5;
|
|
248
305
|
|
|
249
|
-
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.
|
|
306
|
+
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
|
|
250
307
|
}
|
|
251
308
|
}),
|
|
252
|
-
|
|
253
|
-
return
|
|
254
|
-
acc[column.id] = column;
|
|
255
|
-
return acc;
|
|
256
|
-
}, {});
|
|
309
|
+
getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
|
|
310
|
+
return [...headerGroups].reverse();
|
|
257
311
|
}, {
|
|
258
|
-
key: '
|
|
312
|
+
key: 'getLeftFooterGroups',
|
|
259
313
|
debug: () => {
|
|
260
314
|
var _instance$options$deb6;
|
|
261
315
|
|
|
262
|
-
return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.
|
|
316
|
+
return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
|
|
263
317
|
}
|
|
264
318
|
}),
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
return orderColumns(leafColumns);
|
|
319
|
+
getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
|
|
320
|
+
return [...headerGroups].reverse();
|
|
268
321
|
}, {
|
|
269
|
-
key: '
|
|
322
|
+
key: 'getCenterFooterGroups',
|
|
270
323
|
debug: () => {
|
|
271
324
|
var _instance$options$deb7;
|
|
272
325
|
|
|
273
|
-
return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.
|
|
326
|
+
return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
|
|
274
327
|
}
|
|
275
328
|
}),
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
329
|
+
getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
|
|
330
|
+
return [...headerGroups].reverse();
|
|
331
|
+
}, {
|
|
332
|
+
key: 'getRightFooterGroups',
|
|
333
|
+
debug: () => {
|
|
334
|
+
var _instance$options$deb8;
|
|
283
335
|
|
|
284
|
-
|
|
336
|
+
return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
|
|
285
337
|
}
|
|
338
|
+
}),
|
|
339
|
+
// Flat Headers
|
|
340
|
+
getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
341
|
+
return headerGroups.map(headerGroup => {
|
|
342
|
+
return headerGroup.headers;
|
|
343
|
+
}).flat();
|
|
344
|
+
}, {
|
|
345
|
+
key: 'getFlatHeaders',
|
|
346
|
+
debug: () => {
|
|
347
|
+
var _instance$options$deb9;
|
|
286
348
|
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
//
|
|
294
|
-
const Rows = {
|
|
295
|
-
// createRow: <TGenerics extends TableGenerics>(
|
|
296
|
-
// row: Row<TGenerics>,
|
|
297
|
-
// instance: TableInstance<TGenerics>
|
|
298
|
-
// ): CellsRow<TGenerics> => {
|
|
299
|
-
// return {}
|
|
300
|
-
// },
|
|
301
|
-
createInstance: instance => {
|
|
302
|
-
return {
|
|
303
|
-
getRowId: (row, index, parent) => {
|
|
304
|
-
var _instance$options$get;
|
|
305
|
-
|
|
306
|
-
return (_instance$options$get = instance.options.getRowId == null ? void 0 : instance.options.getRowId(row, index, parent)) != null ? _instance$options$get : "" + (parent ? [parent.id, index].join('.') : index);
|
|
307
|
-
},
|
|
308
|
-
createRow: (id, original, rowIndex, depth, subRows) => {
|
|
309
|
-
let row = {
|
|
310
|
-
id,
|
|
311
|
-
index: rowIndex,
|
|
312
|
-
original,
|
|
313
|
-
depth,
|
|
314
|
-
valuesCache: {},
|
|
315
|
-
getValue: columnId => {
|
|
316
|
-
if (row.valuesCache.hasOwnProperty(columnId)) {
|
|
317
|
-
return row.valuesCache[columnId];
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
const column = instance.getColumn(columnId);
|
|
321
|
-
|
|
322
|
-
if (!column.accessorFn) {
|
|
323
|
-
return undefined;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
row.valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
|
327
|
-
return row.valuesCache[columnId];
|
|
328
|
-
},
|
|
329
|
-
subRows: subRows != null ? subRows : [],
|
|
330
|
-
getLeafRows: () => flattenBy(row.subRows, d => d.subRows)
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
for (let i = 0; i < instance._features.length; i++) {
|
|
334
|
-
const feature = instance._features[i];
|
|
335
|
-
Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
|
|
349
|
+
return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
|
|
336
350
|
}
|
|
351
|
+
}),
|
|
352
|
+
getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
|
|
353
|
+
return left.map(headerGroup => {
|
|
354
|
+
return headerGroup.headers;
|
|
355
|
+
}).flat();
|
|
356
|
+
}, {
|
|
357
|
+
key: 'getLeftFlatHeaders',
|
|
358
|
+
debug: () => {
|
|
359
|
+
var _instance$options$deb10;
|
|
337
360
|
|
|
338
|
-
|
|
339
|
-
},
|
|
340
|
-
getCoreRowModel: () => {
|
|
341
|
-
if (!instance._getCoreRowModel) {
|
|
342
|
-
instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
|
|
361
|
+
return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
|
|
343
362
|
}
|
|
363
|
+
}),
|
|
364
|
+
getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
|
|
365
|
+
return left.map(headerGroup => {
|
|
366
|
+
return headerGroup.headers;
|
|
367
|
+
}).flat();
|
|
368
|
+
}, {
|
|
369
|
+
key: 'getCenterFlatHeaders',
|
|
370
|
+
debug: () => {
|
|
371
|
+
var _instance$options$deb11;
|
|
344
372
|
|
|
345
|
-
|
|
346
|
-
},
|
|
347
|
-
// The final calls start at the bottom of the model,
|
|
348
|
-
// expanded rows, which then work their way up
|
|
349
|
-
getRowModel: () => {
|
|
350
|
-
return instance.getPaginationRowModel();
|
|
351
|
-
},
|
|
352
|
-
getRow: id => {
|
|
353
|
-
const row = instance.getRowModel().rowsById[id];
|
|
354
|
-
|
|
355
|
-
if (!row) {
|
|
356
|
-
{
|
|
357
|
-
throw new Error("getRow expected an ID, but got " + id);
|
|
358
|
-
}
|
|
373
|
+
return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
|
|
359
374
|
}
|
|
375
|
+
}),
|
|
376
|
+
getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
|
|
377
|
+
return left.map(headerGroup => {
|
|
378
|
+
return headerGroup.headers;
|
|
379
|
+
}).flat();
|
|
380
|
+
}, {
|
|
381
|
+
key: 'getRightFlatHeaders',
|
|
382
|
+
debug: () => {
|
|
383
|
+
var _instance$options$deb12;
|
|
360
384
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
385
|
+
return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
|
|
386
|
+
}
|
|
387
|
+
}),
|
|
388
|
+
// Leaf Headers
|
|
389
|
+
getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
|
|
390
|
+
return flatHeaders.filter(header => {
|
|
391
|
+
var _header$subHeaders;
|
|
366
392
|
|
|
367
|
-
|
|
368
|
-
const Cells = {
|
|
369
|
-
createRow: (row, instance) => {
|
|
370
|
-
return {
|
|
371
|
-
getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
|
|
372
|
-
return leafColumns.map(column => {
|
|
373
|
-
return instance.createCell(row, column, column.id);
|
|
393
|
+
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
|
374
394
|
});
|
|
375
395
|
}, {
|
|
376
|
-
key: '
|
|
396
|
+
key: 'getCenterLeafHeaders',
|
|
377
397
|
debug: () => {
|
|
378
|
-
var _instance$options$
|
|
398
|
+
var _instance$options$deb13;
|
|
379
399
|
|
|
380
|
-
return (_instance$options$
|
|
400
|
+
return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
|
|
381
401
|
}
|
|
382
402
|
}),
|
|
383
|
-
|
|
384
|
-
return
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
403
|
+
getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
|
|
404
|
+
return flatHeaders.filter(header => {
|
|
405
|
+
var _header$subHeaders2;
|
|
406
|
+
|
|
407
|
+
return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
|
|
408
|
+
});
|
|
388
409
|
}, {
|
|
389
|
-
key:
|
|
410
|
+
key: 'getLeftLeafHeaders',
|
|
390
411
|
debug: () => {
|
|
391
|
-
var _instance$options$
|
|
412
|
+
var _instance$options$deb14;
|
|
392
413
|
|
|
393
|
-
return (_instance$options$
|
|
414
|
+
return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
|
|
394
415
|
}
|
|
395
|
-
})
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
return {
|
|
400
|
-
createCell: (row, column, columnId) => {
|
|
401
|
-
const cell = {
|
|
402
|
-
id: row.id + "_" + column.id,
|
|
403
|
-
rowId: row.id,
|
|
404
|
-
columnId,
|
|
405
|
-
row,
|
|
406
|
-
column,
|
|
407
|
-
getValue: () => row.getValue(columnId),
|
|
408
|
-
renderCell: () => column.cell ? instance._render(column.cell, {
|
|
409
|
-
instance,
|
|
410
|
-
column,
|
|
411
|
-
row,
|
|
412
|
-
cell: cell,
|
|
413
|
-
getValue: cell.getValue
|
|
414
|
-
}) : null
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
instance._features.forEach(feature => {
|
|
418
|
-
Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
|
|
419
|
-
}, {});
|
|
416
|
+
}),
|
|
417
|
+
getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
|
|
418
|
+
return flatHeaders.filter(header => {
|
|
419
|
+
var _header$subHeaders3;
|
|
420
420
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
421
|
+
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
|
422
|
+
});
|
|
423
|
+
}, {
|
|
424
|
+
key: 'getRightLeafHeaders',
|
|
425
|
+
debug: () => {
|
|
426
|
+
var _instance$options$deb15;
|
|
425
427
|
|
|
426
|
-
|
|
427
|
-
{
|
|
428
|
-
throw new Error("[Table] could not find row with id " + rowId);
|
|
429
|
-
}
|
|
428
|
+
return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
|
|
430
429
|
}
|
|
430
|
+
}),
|
|
431
|
+
getLeafHeaders: memo(() => [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()], (left, center, right) => {
|
|
432
|
+
var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
|
|
431
433
|
|
|
432
|
-
|
|
434
|
+
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 => {
|
|
435
|
+
return header.getLeafHeaders();
|
|
436
|
+
}).flat();
|
|
437
|
+
}, {
|
|
438
|
+
key: 'getLeafHeaders',
|
|
439
|
+
debug: () => {
|
|
440
|
+
var _instance$options$deb16;
|
|
433
441
|
|
|
434
|
-
|
|
435
|
-
{
|
|
436
|
-
throw new Error("[Table] could not find cell " + columnId + " in row " + rowId);
|
|
437
|
-
}
|
|
442
|
+
return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
|
|
438
443
|
}
|
|
439
|
-
|
|
440
|
-
return cell;
|
|
441
|
-
}
|
|
444
|
+
})
|
|
442
445
|
};
|
|
443
446
|
}
|
|
444
447
|
};
|
|
448
|
+
function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
|
|
449
|
+
var _headerGroups$0$heade, _headerGroups$;
|
|
450
|
+
|
|
451
|
+
// Find the max depth of the columns:
|
|
452
|
+
// build the leaf column row
|
|
453
|
+
// build each buffer row going up
|
|
454
|
+
// placeholder for non-existent level
|
|
455
|
+
// real column for existing level
|
|
456
|
+
let maxDepth = 0;
|
|
457
|
+
|
|
458
|
+
const findMaxDepth = function (columns, depth) {
|
|
459
|
+
if (depth === void 0) {
|
|
460
|
+
depth = 1;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
maxDepth = Math.max(maxDepth, depth);
|
|
464
|
+
columns.filter(column => column.getIsVisible()).forEach(column => {
|
|
465
|
+
var _column$columns;
|
|
466
|
+
|
|
467
|
+
if ((_column$columns = column.columns) != null && _column$columns.length) {
|
|
468
|
+
findMaxDepth(column.columns, depth + 1);
|
|
469
|
+
}
|
|
470
|
+
}, 0);
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
findMaxDepth(allColumns);
|
|
474
|
+
let headerGroups = [];
|
|
475
|
+
|
|
476
|
+
const createHeaderGroup = (headersToGroup, depth) => {
|
|
477
|
+
// The header group we are creating
|
|
478
|
+
const headerGroup = {
|
|
479
|
+
depth,
|
|
480
|
+
id: [headerFamily, "" + depth].filter(Boolean).join('_'),
|
|
481
|
+
headers: []
|
|
482
|
+
}; // The parent columns we're going to scan next
|
|
483
|
+
|
|
484
|
+
const pendingParentHeaders = []; // Scan each column for parents
|
|
485
|
+
|
|
486
|
+
headersToGroup.forEach(headerToGroup => {
|
|
487
|
+
// What is the latest (last) parent column?
|
|
488
|
+
const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
|
|
489
|
+
const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
|
|
490
|
+
let column;
|
|
491
|
+
let isPlaceholder = false;
|
|
492
|
+
|
|
493
|
+
if (isLeafHeader && headerToGroup.column.parent) {
|
|
494
|
+
// The parent header is new
|
|
495
|
+
column = headerToGroup.column.parent;
|
|
496
|
+
} else {
|
|
497
|
+
// The parent header is repeated
|
|
498
|
+
column = headerToGroup.column;
|
|
499
|
+
isPlaceholder = true;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
|
|
503
|
+
// This column is repeated. Add it as a sub header to the next batch
|
|
504
|
+
latestPendingParentHeader.subHeaders.push(headerToGroup);
|
|
505
|
+
} else {
|
|
506
|
+
// This is a new header. Let's create it
|
|
507
|
+
const header = createHeader(instance, column, {
|
|
508
|
+
id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
|
|
509
|
+
isPlaceholder,
|
|
510
|
+
placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
|
|
511
|
+
depth,
|
|
512
|
+
index: pendingParentHeaders.length
|
|
513
|
+
}); // Add the headerToGroup as a subHeader of the new header
|
|
514
|
+
|
|
515
|
+
header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
|
|
516
|
+
// in the next batch
|
|
517
|
+
|
|
518
|
+
pendingParentHeaders.push(header);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
headerGroup.headers.push(headerToGroup);
|
|
522
|
+
headerToGroup.headerGroup = headerGroup;
|
|
523
|
+
});
|
|
524
|
+
headerGroups.push(headerGroup);
|
|
525
|
+
|
|
526
|
+
if (depth > 0) {
|
|
527
|
+
createHeaderGroup(pendingParentHeaders, depth - 1);
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
const bottomHeaders = columnsToGroup.map((column, index) => createHeader(instance, column, {
|
|
532
|
+
depth: maxDepth,
|
|
533
|
+
index
|
|
534
|
+
}));
|
|
535
|
+
createHeaderGroup(bottomHeaders, maxDepth - 1);
|
|
536
|
+
headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
|
|
537
|
+
// return !headerGroup.headers.every(header => header.isPlaceholder)
|
|
538
|
+
// })
|
|
539
|
+
|
|
540
|
+
const recurseHeadersForSpans = headers => {
|
|
541
|
+
const filteredHeaders = headers.filter(header => header.column.getIsVisible());
|
|
542
|
+
return filteredHeaders.map(header => {
|
|
543
|
+
let colSpan = 0;
|
|
544
|
+
let rowSpan = 0;
|
|
545
|
+
let childRowSpans = [0];
|
|
546
|
+
|
|
547
|
+
if (header.subHeaders && header.subHeaders.length) {
|
|
548
|
+
childRowSpans = [];
|
|
549
|
+
recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
|
|
550
|
+
let {
|
|
551
|
+
colSpan: childColSpan,
|
|
552
|
+
rowSpan: childRowSpan
|
|
553
|
+
} = _ref;
|
|
554
|
+
colSpan += childColSpan;
|
|
555
|
+
childRowSpans.push(childRowSpan);
|
|
556
|
+
});
|
|
557
|
+
} else {
|
|
558
|
+
colSpan = 1;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
const minChildRowSpan = Math.min(...childRowSpans);
|
|
562
|
+
rowSpan = rowSpan + minChildRowSpan;
|
|
563
|
+
header.colSpan = colSpan;
|
|
564
|
+
header.rowSpan = rowSpan;
|
|
565
|
+
return {
|
|
566
|
+
colSpan,
|
|
567
|
+
rowSpan
|
|
568
|
+
};
|
|
569
|
+
});
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
|
|
573
|
+
return headerGroups;
|
|
574
|
+
}
|
|
445
575
|
|
|
446
576
|
//
|
|
447
577
|
const defaultColumnSizing = {
|
|
@@ -460,7 +590,7 @@
|
|
|
460
590
|
});
|
|
461
591
|
|
|
462
592
|
const ColumnSizing = {
|
|
463
|
-
|
|
593
|
+
getDefaultColumnDef: () => {
|
|
464
594
|
return defaultColumnSizing;
|
|
465
595
|
},
|
|
466
596
|
getInitialState: state => {
|
|
@@ -480,10 +610,10 @@
|
|
|
480
610
|
createColumn: (column, instance) => {
|
|
481
611
|
return {
|
|
482
612
|
getSize: () => {
|
|
483
|
-
var _column$
|
|
613
|
+
var _column$columnDef$min, _ref, _column$columnDef$max;
|
|
484
614
|
|
|
485
615
|
const columnSize = instance.getState().columnSizing[column.id];
|
|
486
|
-
return Math.min(Math.max((_column$
|
|
616
|
+
return Math.min(Math.max((_column$columnDef$min = column.columnDef.minSize) != null ? _column$columnDef$min : defaultColumnSizing.minSize, (_ref = columnSize != null ? columnSize : column.columnDef.size) != null ? _ref : defaultColumnSizing.size), (_column$columnDef$max = column.columnDef.maxSize) != null ? _column$columnDef$max : defaultColumnSizing.maxSize);
|
|
487
617
|
},
|
|
488
618
|
getStart: position => {
|
|
489
619
|
const columns = !position ? instance.getVisibleLeafColumns() : position === 'left' ? instance.getLeftVisibleLeafColumns() : instance.getRightVisibleLeafColumns();
|
|
@@ -506,9 +636,9 @@
|
|
|
506
636
|
});
|
|
507
637
|
},
|
|
508
638
|
getCanResize: () => {
|
|
509
|
-
var _column$
|
|
639
|
+
var _column$columnDef$ena, _instance$options$ena;
|
|
510
640
|
|
|
511
|
-
return ((_column$
|
|
641
|
+
return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableColumnResizing) != null ? _instance$options$ena : true);
|
|
512
642
|
},
|
|
513
643
|
getIsResizing: () => {
|
|
514
644
|
return instance.getState().columnSizingInfo.isResizingColumn === column.id;
|
|
@@ -965,7 +1095,7 @@
|
|
|
965
1095
|
|
|
966
1096
|
//
|
|
967
1097
|
const Filters = {
|
|
968
|
-
|
|
1098
|
+
getDefaultColumnDef: () => {
|
|
969
1099
|
return {
|
|
970
1100
|
filterFn: 'auto'
|
|
971
1101
|
};
|
|
@@ -988,7 +1118,7 @@
|
|
|
988
1118
|
getColumnCanGlobalFilter: column => {
|
|
989
1119
|
var _instance$getCoreRowM, _instance$getCoreRowM2;
|
|
990
1120
|
|
|
991
|
-
const value = (_instance$getCoreRowM = instance.getCoreRowModel().flatRows[0]) == null ? void 0 : (_instance$getCoreRowM2 = _instance$getCoreRowM.
|
|
1121
|
+
const value = (_instance$getCoreRowM = instance.getCoreRowModel().flatRows[0]) == null ? void 0 : (_instance$getCoreRowM2 = _instance$getCoreRowM._getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreRowM2.getValue();
|
|
992
1122
|
return typeof value === 'string';
|
|
993
1123
|
}
|
|
994
1124
|
};
|
|
@@ -1008,6 +1138,10 @@
|
|
|
1008
1138
|
return filterFns.inNumberRange;
|
|
1009
1139
|
}
|
|
1010
1140
|
|
|
1141
|
+
if (typeof value === 'boolean') {
|
|
1142
|
+
return filterFns.equals;
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1011
1145
|
if (value !== null && typeof value === 'object') {
|
|
1012
1146
|
return filterFns.equals;
|
|
1013
1147
|
}
|
|
@@ -1025,14 +1159,14 @@
|
|
|
1025
1159
|
return isFunction(column.filterFn) ? column.filterFn : column.filterFn === 'auto' ? column.getAutoFilterFn() : (_ref = userFilterFns == null ? void 0 : userFilterFns[column.filterFn]) != null ? _ref : filterFns[column.filterFn];
|
|
1026
1160
|
},
|
|
1027
1161
|
getCanFilter: () => {
|
|
1028
|
-
var _column$
|
|
1162
|
+
var _column$columnDef$ena, _instance$options$ena, _instance$options$ena2;
|
|
1029
1163
|
|
|
1030
|
-
return ((_column$
|
|
1164
|
+
return ((_column$columnDef$ena = column.columnDef.enableColumnFilter) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableColumnFilters) != null ? _instance$options$ena : true) && ((_instance$options$ena2 = instance.options.enableFilters) != null ? _instance$options$ena2 : true) && !!column.accessorFn;
|
|
1031
1165
|
},
|
|
1032
1166
|
getCanGlobalFilter: () => {
|
|
1033
|
-
var _column$
|
|
1167
|
+
var _column$columnDef$ena2, _instance$options$ena3, _instance$options$ena4, _instance$options$get;
|
|
1034
1168
|
|
|
1035
|
-
return ((_column$
|
|
1169
|
+
return ((_column$columnDef$ena2 = column.columnDef.enableGlobalFilter) != null ? _column$columnDef$ena2 : true) && ((_instance$options$ena3 = instance.options.enableGlobalFilter) != null ? _instance$options$ena3 : true) && ((_instance$options$ena4 = instance.options.enableFilters) != null ? _instance$options$ena4 : true) && ((_instance$options$get = instance.options.getColumnCanGlobalFilter == null ? void 0 : instance.options.getColumnCanGlobalFilter(column)) != null ? _instance$options$get : true) && !!column.accessorFn;
|
|
1036
1170
|
},
|
|
1037
1171
|
getIsFiltered: () => column.getFilterIndex() > -1,
|
|
1038
1172
|
getFilterValue: () => {
|
|
@@ -1112,8 +1246,7 @@
|
|
|
1112
1246
|
createRow: (row, instance) => {
|
|
1113
1247
|
return {
|
|
1114
1248
|
columnFilters: {},
|
|
1115
|
-
columnFiltersMeta: {}
|
|
1116
|
-
subRowsByFacetId: {}
|
|
1249
|
+
columnFiltersMeta: {}
|
|
1117
1250
|
};
|
|
1118
1251
|
},
|
|
1119
1252
|
createInstance: instance => {
|
|
@@ -1204,53 +1337,42 @@
|
|
|
1204
1337
|
return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
|
|
1205
1338
|
}
|
|
1206
1339
|
|
|
1207
|
-
const
|
|
1208
|
-
sum,
|
|
1209
|
-
min,
|
|
1210
|
-
max,
|
|
1211
|
-
extent,
|
|
1212
|
-
mean,
|
|
1213
|
-
median,
|
|
1214
|
-
unique,
|
|
1215
|
-
uniqueCount,
|
|
1216
|
-
count
|
|
1217
|
-
};
|
|
1218
|
-
|
|
1219
|
-
function sum(_getLeafValues, getChildValues) {
|
|
1340
|
+
const sum = (columnId, _leafRows, childRows) => {
|
|
1220
1341
|
// It's faster to just add the aggregations together instead of
|
|
1221
1342
|
// process leaf nodes individually
|
|
1222
|
-
return
|
|
1223
|
-
}
|
|
1343
|
+
return childRows.reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
|
|
1344
|
+
};
|
|
1224
1345
|
|
|
1225
|
-
|
|
1346
|
+
const min = (columnId, _leafRows, childRows) => {
|
|
1226
1347
|
let min;
|
|
1348
|
+
childRows.forEach(row => {
|
|
1349
|
+
const value = row.getValue(columnId);
|
|
1227
1350
|
|
|
1228
|
-
for (const value of getChildValues()) {
|
|
1229
1351
|
if (value != null && (min > value || min === undefined && value >= value)) {
|
|
1230
1352
|
min = value;
|
|
1231
1353
|
}
|
|
1232
|
-
}
|
|
1233
|
-
|
|
1354
|
+
});
|
|
1234
1355
|
return min;
|
|
1235
|
-
}
|
|
1356
|
+
};
|
|
1236
1357
|
|
|
1237
|
-
|
|
1358
|
+
const max = (columnId, _leafRows, childRows) => {
|
|
1238
1359
|
let max;
|
|
1360
|
+
childRows.forEach(row => {
|
|
1361
|
+
const value = row.getValue(columnId);
|
|
1239
1362
|
|
|
1240
|
-
for (const value of getChildValues()) {
|
|
1241
1363
|
if (value != null && (max < value || max === undefined && value >= value)) {
|
|
1242
1364
|
max = value;
|
|
1243
1365
|
}
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1366
|
+
});
|
|
1246
1367
|
return max;
|
|
1247
|
-
}
|
|
1368
|
+
};
|
|
1248
1369
|
|
|
1249
|
-
|
|
1370
|
+
const extent = (columnId, _leafRows, childRows) => {
|
|
1250
1371
|
let min;
|
|
1251
1372
|
let max;
|
|
1373
|
+
childRows.forEach(row => {
|
|
1374
|
+
const value = row.getValue(columnId);
|
|
1252
1375
|
|
|
1253
|
-
for (const value of getChildValues()) {
|
|
1254
1376
|
if (value != null) {
|
|
1255
1377
|
if (min === undefined) {
|
|
1256
1378
|
if (value >= value) min = max = value;
|
|
@@ -1259,58 +1381,69 @@
|
|
|
1259
1381
|
if (max < value) max = value;
|
|
1260
1382
|
}
|
|
1261
1383
|
}
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1384
|
+
});
|
|
1264
1385
|
return [min, max];
|
|
1265
|
-
}
|
|
1386
|
+
};
|
|
1266
1387
|
|
|
1267
|
-
|
|
1388
|
+
const mean = (columnId, leafRows) => {
|
|
1268
1389
|
let count = 0;
|
|
1269
1390
|
let sum = 0;
|
|
1391
|
+
leafRows.forEach(row => {
|
|
1392
|
+
let value = row.getValue(columnId);
|
|
1270
1393
|
|
|
1271
|
-
for (let value of getLeafValues()) {
|
|
1272
1394
|
if (value != null && (value = +value) >= value) {
|
|
1273
1395
|
++count, sum += value;
|
|
1274
1396
|
}
|
|
1275
|
-
}
|
|
1276
|
-
|
|
1397
|
+
});
|
|
1277
1398
|
if (count) return sum / count;
|
|
1278
1399
|
return;
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
function median(getLeafValues) {
|
|
1282
|
-
const leafValues = getLeafValues();
|
|
1400
|
+
};
|
|
1283
1401
|
|
|
1284
|
-
|
|
1402
|
+
const median = (columnId, leafRows) => {
|
|
1403
|
+
if (!leafRows.length) {
|
|
1285
1404
|
return;
|
|
1286
1405
|
}
|
|
1287
1406
|
|
|
1288
1407
|
let min = 0;
|
|
1289
1408
|
let max = 0;
|
|
1290
|
-
|
|
1409
|
+
leafRows.forEach(row => {
|
|
1410
|
+
let value = row.getValue(columnId);
|
|
1411
|
+
|
|
1291
1412
|
if (typeof value === 'number') {
|
|
1292
1413
|
min = Math.min(min, value);
|
|
1293
1414
|
max = Math.max(max, value);
|
|
1294
1415
|
}
|
|
1295
1416
|
});
|
|
1296
1417
|
return (min + max) / 2;
|
|
1297
|
-
}
|
|
1418
|
+
};
|
|
1298
1419
|
|
|
1299
|
-
|
|
1300
|
-
return Array.from(new Set(
|
|
1301
|
-
}
|
|
1420
|
+
const unique = (columnId, leafRows) => {
|
|
1421
|
+
return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
|
|
1422
|
+
};
|
|
1302
1423
|
|
|
1303
|
-
|
|
1304
|
-
return new Set(
|
|
1305
|
-
}
|
|
1424
|
+
const uniqueCount = (columnId, leafRows) => {
|
|
1425
|
+
return new Set(leafRows.map(d => d.getValue(columnId))).size;
|
|
1426
|
+
};
|
|
1306
1427
|
|
|
1307
|
-
|
|
1308
|
-
return
|
|
1309
|
-
}
|
|
1428
|
+
const count = (_columnId, leafRows) => {
|
|
1429
|
+
return leafRows.length;
|
|
1430
|
+
};
|
|
1431
|
+
|
|
1432
|
+
const aggregationFns = {
|
|
1433
|
+
sum,
|
|
1434
|
+
min,
|
|
1435
|
+
max,
|
|
1436
|
+
extent,
|
|
1437
|
+
mean,
|
|
1438
|
+
median,
|
|
1439
|
+
unique,
|
|
1440
|
+
uniqueCount,
|
|
1441
|
+
count
|
|
1442
|
+
};
|
|
1310
1443
|
|
|
1311
1444
|
//
|
|
1312
1445
|
const Grouping = {
|
|
1313
|
-
|
|
1446
|
+
getDefaultColumnDef: () => {
|
|
1314
1447
|
return {
|
|
1315
1448
|
aggregationFn: 'auto'
|
|
1316
1449
|
};
|
|
@@ -1340,9 +1473,9 @@
|
|
|
1340
1473
|
});
|
|
1341
1474
|
},
|
|
1342
1475
|
getCanGroup: () => {
|
|
1343
|
-
var _ref, _ref2, _ref3, _column$
|
|
1476
|
+
var _ref, _ref2, _ref3, _column$columnDef$ena;
|
|
1344
1477
|
|
|
1345
|
-
return (_ref = (_ref2 = (_ref3 = (_column$
|
|
1478
|
+
return (_ref = (_ref2 = (_ref3 = (_column$columnDef$ena = column.columnDef.enableGrouping) != null ? _column$columnDef$ena : true) != null ? _ref3 : instance.options.enableGrouping) != null ? _ref2 : true) != null ? _ref : !!column.accessorFn;
|
|
1346
1479
|
},
|
|
1347
1480
|
getIsGrouped: () => {
|
|
1348
1481
|
var _instance$getState$gr;
|
|
@@ -1361,7 +1494,7 @@
|
|
|
1361
1494
|
column.toggleGrouping();
|
|
1362
1495
|
};
|
|
1363
1496
|
},
|
|
1364
|
-
|
|
1497
|
+
getAutoAggregationFn: () => {
|
|
1365
1498
|
const firstRow = instance.getCoreRowModel().flatRows[0];
|
|
1366
1499
|
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
|
1367
1500
|
|
|
@@ -1375,7 +1508,7 @@
|
|
|
1375
1508
|
|
|
1376
1509
|
return aggregationFns.count;
|
|
1377
1510
|
},
|
|
1378
|
-
|
|
1511
|
+
getAggregationFn: () => {
|
|
1379
1512
|
var _ref4;
|
|
1380
1513
|
|
|
1381
1514
|
const userAggregationFns = instance.options.aggregationFns;
|
|
@@ -1384,7 +1517,7 @@
|
|
|
1384
1517
|
throw new Error();
|
|
1385
1518
|
}
|
|
1386
1519
|
|
|
1387
|
-
return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.
|
|
1520
|
+
return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_ref4 = userAggregationFns == null ? void 0 : userAggregationFns[column.aggregationFn]) != null ? _ref4 : aggregationFns[column.aggregationFn];
|
|
1388
1521
|
}
|
|
1389
1522
|
};
|
|
1390
1523
|
},
|
|
@@ -1410,10 +1543,10 @@
|
|
|
1410
1543
|
}
|
|
1411
1544
|
};
|
|
1412
1545
|
},
|
|
1413
|
-
createRow:
|
|
1546
|
+
createRow: row => {
|
|
1414
1547
|
return {
|
|
1415
1548
|
getIsGrouped: () => !!row.groupingColumnId,
|
|
1416
|
-
|
|
1549
|
+
_groupingValuesCache: {}
|
|
1417
1550
|
};
|
|
1418
1551
|
},
|
|
1419
1552
|
createCell: (cell, column, row, instance) => {
|
|
@@ -1426,9 +1559,9 @@
|
|
|
1426
1559
|
return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
|
|
1427
1560
|
},
|
|
1428
1561
|
renderAggregatedCell: () => {
|
|
1429
|
-
var _column$
|
|
1562
|
+
var _column$columnDef$agg;
|
|
1430
1563
|
|
|
1431
|
-
const template = (_column$
|
|
1564
|
+
const template = (_column$columnDef$agg = column.columnDef.aggregatedCell) != null ? _column$columnDef$agg : column.columnDef.cell;
|
|
1432
1565
|
return template ? instance._render(template, {
|
|
1433
1566
|
instance,
|
|
1434
1567
|
column,
|
|
@@ -1735,9 +1868,9 @@
|
|
|
1735
1868
|
getCanPin: () => {
|
|
1736
1869
|
const leafColumns = column.getLeafColumns();
|
|
1737
1870
|
return leafColumns.some(d => {
|
|
1738
|
-
var _d$
|
|
1871
|
+
var _d$columnDef$enablePi, _instance$options$ena;
|
|
1739
1872
|
|
|
1740
|
-
return ((_d$
|
|
1873
|
+
return ((_d$columnDef$enablePi = d.columnDef.enablePinning) != null ? _d$columnDef$enablePi : true) && ((_instance$options$ena = instance.options.enablePinning) != null ? _instance$options$ena : true);
|
|
1741
1874
|
});
|
|
1742
1875
|
},
|
|
1743
1876
|
getIsPinned: () => {
|
|
@@ -1762,7 +1895,7 @@
|
|
|
1762
1895
|
return {
|
|
1763
1896
|
getCenterVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allCells, left, right) => {
|
|
1764
1897
|
const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
|
|
1765
|
-
return allCells.filter(d => !leftAndRight.includes(d.
|
|
1898
|
+
return allCells.filter(d => !leftAndRight.includes(d.column.id));
|
|
1766
1899
|
}, {
|
|
1767
1900
|
key: "development" === 'production' ,
|
|
1768
1901
|
debug: () => {
|
|
@@ -1772,7 +1905,7 @@
|
|
|
1772
1905
|
}
|
|
1773
1906
|
}),
|
|
1774
1907
|
getLeftVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left,,], (allCells, left) => {
|
|
1775
|
-
const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.
|
|
1908
|
+
const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
|
|
1776
1909
|
position: 'left'
|
|
1777
1910
|
}));
|
|
1778
1911
|
return cells;
|
|
@@ -1785,7 +1918,7 @@
|
|
|
1785
1918
|
}
|
|
1786
1919
|
}),
|
|
1787
1920
|
getRightVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.right], (allCells, right) => {
|
|
1788
|
-
const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.
|
|
1921
|
+
const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
|
|
1789
1922
|
position: 'left'
|
|
1790
1923
|
}));
|
|
1791
1924
|
return cells;
|
|
@@ -1807,12 +1940,18 @@
|
|
|
1807
1940
|
|
|
1808
1941
|
return instance.setColumnPinning(defaultState ? getDefaultPinningState() : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.columnPinning) != null ? _instance$initialStat : getDefaultPinningState());
|
|
1809
1942
|
},
|
|
1810
|
-
getIsSomeColumnsPinned:
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1943
|
+
getIsSomeColumnsPinned: position => {
|
|
1944
|
+
var _pinningState$positio;
|
|
1945
|
+
|
|
1946
|
+
const pinningState = instance.getState().columnPinning;
|
|
1947
|
+
|
|
1948
|
+
if (!position) {
|
|
1949
|
+
var _pinningState$left, _pinningState$right;
|
|
1950
|
+
|
|
1951
|
+
return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
|
|
1816
1955
|
},
|
|
1817
1956
|
getLeftLeafColumns: memo(() => [instance.getAllLeafColumns(), instance.getState().columnPinning.left], (allColumns, left) => {
|
|
1818
1957
|
return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
|
|
@@ -2338,7 +2477,7 @@
|
|
|
2338
2477
|
...state
|
|
2339
2478
|
};
|
|
2340
2479
|
},
|
|
2341
|
-
|
|
2480
|
+
getDefaultColumnDef: () => {
|
|
2342
2481
|
return {
|
|
2343
2482
|
sortingFn: 'auto'
|
|
2344
2483
|
};
|
|
@@ -2398,7 +2537,7 @@
|
|
|
2398
2537
|
throw new Error();
|
|
2399
2538
|
}
|
|
2400
2539
|
|
|
2401
|
-
return isFunction(column.sortingFn) ? column.sortingFn : column.sortingFn === 'auto' ? column.getAutoSortingFn() : (_ref = userSortingFn == null ? void 0 : userSortingFn[column.sortingFn]) != null ? _ref : sortingFns[column.sortingFn];
|
|
2540
|
+
return isFunction(column.columnDef.sortingFn) ? column.columnDef.sortingFn : column.columnDef.sortingFn === 'auto' ? column.getAutoSortingFn() : (_ref = userSortingFn == null ? void 0 : userSortingFn[column.columnDef.sortingFn]) != null ? _ref : sortingFns[column.columnDef.sortingFn];
|
|
2402
2541
|
},
|
|
2403
2542
|
toggleSorting: (desc, multi) => {
|
|
2404
2543
|
// if (column.columns.length) {
|
|
@@ -2410,7 +2549,7 @@
|
|
|
2410
2549
|
// return
|
|
2411
2550
|
// }
|
|
2412
2551
|
instance.setSorting(old => {
|
|
2413
|
-
var _ref2, _column$
|
|
2552
|
+
var _ref2, _column$columnDef$sor, _instance$options$ena, _instance$options$ena2;
|
|
2414
2553
|
|
|
2415
2554
|
// Find any existing sorting for this column
|
|
2416
2555
|
const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
|
|
@@ -2437,7 +2576,7 @@
|
|
|
2437
2576
|
}
|
|
2438
2577
|
}
|
|
2439
2578
|
|
|
2440
|
-
const sortDescFirst = (_ref2 = (_column$
|
|
2579
|
+
const sortDescFirst = (_ref2 = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc'; // Handle toggle states that will remove the sorting
|
|
2441
2580
|
|
|
2442
2581
|
if (sortAction === 'toggle' && ( // Must be toggling
|
|
2443
2582
|
(_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
|
|
@@ -2481,14 +2620,14 @@
|
|
|
2481
2620
|
});
|
|
2482
2621
|
},
|
|
2483
2622
|
getCanSort: () => {
|
|
2484
|
-
var _column$
|
|
2623
|
+
var _column$columnDef$ena, _instance$options$ena3;
|
|
2485
2624
|
|
|
2486
|
-
return ((_column$
|
|
2625
|
+
return ((_column$columnDef$ena = column.columnDef.enableSorting) != null ? _column$columnDef$ena : true) && ((_instance$options$ena3 = instance.options.enableSorting) != null ? _instance$options$ena3 : true) && !!column.accessorFn;
|
|
2487
2626
|
},
|
|
2488
2627
|
getCanMultiSort: () => {
|
|
2489
|
-
var _ref3, _column$
|
|
2628
|
+
var _ref3, _column$columnDef$ena2;
|
|
2490
2629
|
|
|
2491
|
-
return (_ref3 = (_column$
|
|
2630
|
+
return (_ref3 = (_column$columnDef$ena2 = column.columnDef.enableMultiSort) != null ? _column$columnDef$ena2 : instance.options.enableMultiSort) != null ? _ref3 : !!column.accessorFn;
|
|
2492
2631
|
},
|
|
2493
2632
|
getIsSorted: () => {
|
|
2494
2633
|
var _instance$getState$so;
|
|
@@ -2552,7 +2691,7 @@
|
|
|
2552
2691
|
onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
|
|
2553
2692
|
};
|
|
2554
2693
|
},
|
|
2555
|
-
|
|
2694
|
+
getDefaultColumnDef: () => {
|
|
2556
2695
|
return {
|
|
2557
2696
|
defaultIsVisible: true
|
|
2558
2697
|
};
|
|
@@ -2572,9 +2711,9 @@
|
|
|
2572
2711
|
return (_instance$getState$co = (_instance$getState$co2 = instance.getState().columnVisibility) == null ? void 0 : _instance$getState$co2[column.id]) != null ? _instance$getState$co : true;
|
|
2573
2712
|
},
|
|
2574
2713
|
getCanHide: () => {
|
|
2575
|
-
var _column$
|
|
2714
|
+
var _column$columnDef$ena, _instance$options$ena;
|
|
2576
2715
|
|
|
2577
|
-
return ((_column$
|
|
2716
|
+
return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : true);
|
|
2578
2717
|
},
|
|
2579
2718
|
getToggleVisibilityHandler: () => {
|
|
2580
2719
|
return e => {
|
|
@@ -2588,477 +2727,72 @@
|
|
|
2588
2727
|
_getAllVisibleCells: memo(() => [row.getAllCells().filter(cell => cell.column.getIsVisible()).map(d => d.id).join('_')], _ => {
|
|
2589
2728
|
return row.getAllCells().filter(cell => cell.column.getIsVisible());
|
|
2590
2729
|
}, {
|
|
2591
|
-
key: "development" === 'production' ,
|
|
2592
|
-
debug: () => {
|
|
2593
|
-
var _instance$options$deb;
|
|
2594
|
-
|
|
2595
|
-
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
|
|
2596
|
-
}
|
|
2597
|
-
}),
|
|
2598
|
-
getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
|
|
2599
|
-
key: 'row.getVisibleCells',
|
|
2600
|
-
debug: () => {
|
|
2601
|
-
var _instance$options$deb2;
|
|
2602
|
-
|
|
2603
|
-
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
|
|
2604
|
-
}
|
|
2605
|
-
})
|
|
2606
|
-
};
|
|
2607
|
-
},
|
|
2608
|
-
createInstance: instance => {
|
|
2609
|
-
const makeVisibleColumnsMethod = (key, getColumns) => {
|
|
2610
|
-
return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
|
|
2611
|
-
return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
|
|
2612
|
-
}, {
|
|
2613
|
-
key,
|
|
2614
|
-
debug: () => {
|
|
2615
|
-
var _instance$options$deb3;
|
|
2616
|
-
|
|
2617
|
-
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
2618
|
-
}
|
|
2619
|
-
});
|
|
2620
|
-
};
|
|
2621
|
-
|
|
2622
|
-
return {
|
|
2623
|
-
getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
|
|
2624
|
-
getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
|
|
2625
|
-
getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
|
|
2626
|
-
getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
|
|
2627
|
-
getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
|
|
2628
|
-
setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
|
|
2629
|
-
resetColumnVisibility: defaultState => {
|
|
2630
|
-
var _instance$initialStat;
|
|
2631
|
-
|
|
2632
|
-
instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
|
|
2633
|
-
},
|
|
2634
|
-
toggleAllColumnsVisible: value => {
|
|
2635
|
-
var _value;
|
|
2636
|
-
|
|
2637
|
-
value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
|
|
2638
|
-
instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
|
|
2639
|
-
[column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
|
|
2640
|
-
}), {}));
|
|
2641
|
-
},
|
|
2642
|
-
getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
|
|
2643
|
-
getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
|
|
2644
|
-
getToggleAllColumnsVisibilityHandler: () => {
|
|
2645
|
-
return e => {
|
|
2646
|
-
var _target;
|
|
2647
|
-
|
|
2648
|
-
instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
|
|
2649
|
-
};
|
|
2650
|
-
}
|
|
2651
|
-
};
|
|
2652
|
-
}
|
|
2653
|
-
};
|
|
2654
|
-
|
|
2655
|
-
//
|
|
2656
|
-
const Headers = {
|
|
2657
|
-
createInstance: instance => {
|
|
2658
|
-
return {
|
|
2659
|
-
createHeader: (column, options) => {
|
|
2660
|
-
var _options$id;
|
|
2661
|
-
|
|
2662
|
-
const id = (_options$id = options.id) != null ? _options$id : column.id;
|
|
2663
|
-
let header = {
|
|
2664
|
-
id,
|
|
2665
|
-
column,
|
|
2666
|
-
index: options.index,
|
|
2667
|
-
isPlaceholder: options.isPlaceholder,
|
|
2668
|
-
placeholderId: options.placeholderId,
|
|
2669
|
-
depth: options.depth,
|
|
2670
|
-
subHeaders: [],
|
|
2671
|
-
colSpan: 0,
|
|
2672
|
-
rowSpan: 0,
|
|
2673
|
-
headerGroup: null,
|
|
2674
|
-
getLeafHeaders: () => {
|
|
2675
|
-
const leafHeaders = [];
|
|
2676
|
-
|
|
2677
|
-
const recurseHeader = h => {
|
|
2678
|
-
if (h.subHeaders && h.subHeaders.length) {
|
|
2679
|
-
h.subHeaders.map(recurseHeader);
|
|
2680
|
-
}
|
|
2681
|
-
|
|
2682
|
-
leafHeaders.push(h);
|
|
2683
|
-
};
|
|
2684
|
-
|
|
2685
|
-
recurseHeader(header);
|
|
2686
|
-
return leafHeaders;
|
|
2687
|
-
},
|
|
2688
|
-
renderHeader: () => column.header ? instance._render(column.header, {
|
|
2689
|
-
instance,
|
|
2690
|
-
header: header,
|
|
2691
|
-
column
|
|
2692
|
-
}) : null,
|
|
2693
|
-
renderFooter: () => column.footer ? instance._render(column.footer, {
|
|
2694
|
-
instance,
|
|
2695
|
-
header: header,
|
|
2696
|
-
column
|
|
2697
|
-
}) : null
|
|
2698
|
-
};
|
|
2699
|
-
|
|
2700
|
-
instance._features.forEach(feature => {
|
|
2701
|
-
Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
|
|
2702
|
-
});
|
|
2703
|
-
|
|
2704
|
-
return header;
|
|
2705
|
-
},
|
|
2706
|
-
// Header Groups
|
|
2707
|
-
getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
2708
|
-
var _left$map$filter, _right$map$filter;
|
|
2709
|
-
|
|
2710
|
-
const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
|
|
2711
|
-
const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
|
|
2712
|
-
const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
2713
|
-
const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
|
|
2714
|
-
return headerGroups;
|
|
2715
|
-
}, {
|
|
2716
|
-
key: 'getHeaderGroups',
|
|
2717
|
-
debug: () => {
|
|
2718
|
-
var _instance$options$deb;
|
|
2719
|
-
|
|
2720
|
-
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
|
|
2721
|
-
}
|
|
2722
|
-
}),
|
|
2723
|
-
getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
2724
|
-
leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
2725
|
-
return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
|
|
2726
|
-
}, {
|
|
2727
|
-
key: 'getCenterHeaderGroups',
|
|
2728
|
-
debug: () => {
|
|
2729
|
-
var _instance$options$deb2;
|
|
2730
|
-
|
|
2731
|
-
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
|
|
2732
|
-
}
|
|
2733
|
-
}),
|
|
2734
|
-
getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
2735
|
-
var _left$map$filter2;
|
|
2736
|
-
|
|
2737
|
-
const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
|
|
2738
|
-
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
|
|
2739
|
-
}, {
|
|
2740
|
-
key: 'getLeftHeaderGroups',
|
|
2741
|
-
debug: () => {
|
|
2742
|
-
var _instance$options$deb3;
|
|
2743
|
-
|
|
2744
|
-
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
|
|
2745
|
-
}
|
|
2746
|
-
}),
|
|
2747
|
-
getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
2748
|
-
var _right$map$filter2;
|
|
2749
|
-
|
|
2750
|
-
const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
|
|
2751
|
-
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
|
|
2752
|
-
}, {
|
|
2753
|
-
key: 'getRightHeaderGroups',
|
|
2754
|
-
debug: () => {
|
|
2755
|
-
var _instance$options$deb4;
|
|
2756
|
-
|
|
2757
|
-
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
|
|
2758
|
-
}
|
|
2759
|
-
}),
|
|
2760
|
-
// Footer Groups
|
|
2761
|
-
getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
2762
|
-
return [...headerGroups].reverse();
|
|
2763
|
-
}, {
|
|
2764
|
-
key: 'getFooterGroups',
|
|
2765
|
-
debug: () => {
|
|
2766
|
-
var _instance$options$deb5;
|
|
2767
|
-
|
|
2768
|
-
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
|
|
2769
|
-
}
|
|
2770
|
-
}),
|
|
2771
|
-
getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
|
|
2772
|
-
return [...headerGroups].reverse();
|
|
2773
|
-
}, {
|
|
2774
|
-
key: 'getLeftFooterGroups',
|
|
2775
|
-
debug: () => {
|
|
2776
|
-
var _instance$options$deb6;
|
|
2777
|
-
|
|
2778
|
-
return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
|
|
2779
|
-
}
|
|
2780
|
-
}),
|
|
2781
|
-
getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
|
|
2782
|
-
return [...headerGroups].reverse();
|
|
2783
|
-
}, {
|
|
2784
|
-
key: 'getCenterFooterGroups',
|
|
2785
|
-
debug: () => {
|
|
2786
|
-
var _instance$options$deb7;
|
|
2787
|
-
|
|
2788
|
-
return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
|
|
2789
|
-
}
|
|
2790
|
-
}),
|
|
2791
|
-
getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
|
|
2792
|
-
return [...headerGroups].reverse();
|
|
2793
|
-
}, {
|
|
2794
|
-
key: 'getRightFooterGroups',
|
|
2795
|
-
debug: () => {
|
|
2796
|
-
var _instance$options$deb8;
|
|
2797
|
-
|
|
2798
|
-
return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
|
|
2799
|
-
}
|
|
2800
|
-
}),
|
|
2801
|
-
// Flat Headers
|
|
2802
|
-
getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
2803
|
-
return headerGroups.map(headerGroup => {
|
|
2804
|
-
return headerGroup.headers;
|
|
2805
|
-
}).flat();
|
|
2806
|
-
}, {
|
|
2807
|
-
key: 'getFlatHeaders',
|
|
2808
|
-
debug: () => {
|
|
2809
|
-
var _instance$options$deb9;
|
|
2810
|
-
|
|
2811
|
-
return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
|
|
2812
|
-
}
|
|
2813
|
-
}),
|
|
2814
|
-
getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
|
|
2815
|
-
return left.map(headerGroup => {
|
|
2816
|
-
return headerGroup.headers;
|
|
2817
|
-
}).flat();
|
|
2818
|
-
}, {
|
|
2819
|
-
key: 'getLeftFlatHeaders',
|
|
2820
|
-
debug: () => {
|
|
2821
|
-
var _instance$options$deb10;
|
|
2822
|
-
|
|
2823
|
-
return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
|
|
2824
|
-
}
|
|
2825
|
-
}),
|
|
2826
|
-
getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
|
|
2827
|
-
return left.map(headerGroup => {
|
|
2828
|
-
return headerGroup.headers;
|
|
2829
|
-
}).flat();
|
|
2830
|
-
}, {
|
|
2831
|
-
key: 'getCenterFlatHeaders',
|
|
2832
|
-
debug: () => {
|
|
2833
|
-
var _instance$options$deb11;
|
|
2834
|
-
|
|
2835
|
-
return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
|
|
2836
|
-
}
|
|
2837
|
-
}),
|
|
2838
|
-
getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
|
|
2839
|
-
return left.map(headerGroup => {
|
|
2840
|
-
return headerGroup.headers;
|
|
2841
|
-
}).flat();
|
|
2842
|
-
}, {
|
|
2843
|
-
key: 'getRightFlatHeaders',
|
|
2844
|
-
debug: () => {
|
|
2845
|
-
var _instance$options$deb12;
|
|
2846
|
-
|
|
2847
|
-
return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
|
|
2848
|
-
}
|
|
2849
|
-
}),
|
|
2850
|
-
// Leaf Headers
|
|
2851
|
-
getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
|
|
2852
|
-
return flatHeaders.filter(header => {
|
|
2853
|
-
var _header$subHeaders;
|
|
2854
|
-
|
|
2855
|
-
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
|
2856
|
-
});
|
|
2857
|
-
}, {
|
|
2858
|
-
key: 'getCenterLeafHeaders',
|
|
2859
|
-
debug: () => {
|
|
2860
|
-
var _instance$options$deb13;
|
|
2861
|
-
|
|
2862
|
-
return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
|
|
2863
|
-
}
|
|
2864
|
-
}),
|
|
2865
|
-
getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
|
|
2866
|
-
return flatHeaders.filter(header => {
|
|
2867
|
-
var _header$subHeaders2;
|
|
2868
|
-
|
|
2869
|
-
return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
|
|
2870
|
-
});
|
|
2871
|
-
}, {
|
|
2872
|
-
key: 'getLeftLeafHeaders',
|
|
2873
|
-
debug: () => {
|
|
2874
|
-
var _instance$options$deb14;
|
|
2875
|
-
|
|
2876
|
-
return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
|
|
2877
|
-
}
|
|
2878
|
-
}),
|
|
2879
|
-
getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
|
|
2880
|
-
return flatHeaders.filter(header => {
|
|
2881
|
-
var _header$subHeaders3;
|
|
2882
|
-
|
|
2883
|
-
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
|
2884
|
-
});
|
|
2885
|
-
}, {
|
|
2886
|
-
key: 'getRightLeafHeaders',
|
|
2730
|
+
key: "development" === 'production' ,
|
|
2887
2731
|
debug: () => {
|
|
2888
|
-
var _instance$options$
|
|
2732
|
+
var _instance$options$deb;
|
|
2889
2733
|
|
|
2890
|
-
return (_instance$options$
|
|
2734
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
|
|
2891
2735
|
}
|
|
2892
2736
|
}),
|
|
2893
|
-
|
|
2894
|
-
|
|
2737
|
+
getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
|
|
2738
|
+
key: 'row.getVisibleCells',
|
|
2739
|
+
debug: () => {
|
|
2740
|
+
var _instance$options$deb2;
|
|
2895
2741
|
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2742
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
|
|
2743
|
+
}
|
|
2744
|
+
})
|
|
2745
|
+
};
|
|
2746
|
+
},
|
|
2747
|
+
createInstance: instance => {
|
|
2748
|
+
const makeVisibleColumnsMethod = (key, getColumns) => {
|
|
2749
|
+
return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
|
|
2750
|
+
return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
|
|
2899
2751
|
}, {
|
|
2900
|
-
key
|
|
2752
|
+
key,
|
|
2901
2753
|
debug: () => {
|
|
2902
|
-
var _instance$options$
|
|
2754
|
+
var _instance$options$deb3;
|
|
2903
2755
|
|
|
2904
|
-
return (_instance$options$
|
|
2756
|
+
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
2905
2757
|
}
|
|
2906
|
-
})
|
|
2907
|
-
|
|
2908
|
-
const header = [...instance.getFlatHeaders(), ...instance.getCenterFlatHeaders(), ...instance.getLeftFlatHeaders(), ...instance.getRightFlatHeaders()].find(d => d.id === id);
|
|
2758
|
+
});
|
|
2759
|
+
};
|
|
2909
2760
|
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2761
|
+
return {
|
|
2762
|
+
getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
|
|
2763
|
+
getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
|
|
2764
|
+
getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
|
|
2765
|
+
getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
|
|
2766
|
+
getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
|
|
2767
|
+
setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
|
|
2768
|
+
resetColumnVisibility: defaultState => {
|
|
2769
|
+
var _instance$initialStat;
|
|
2914
2770
|
|
|
2915
|
-
|
|
2916
|
-
|
|
2771
|
+
instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
|
|
2772
|
+
},
|
|
2773
|
+
toggleAllColumnsVisible: value => {
|
|
2774
|
+
var _value;
|
|
2917
2775
|
|
|
2918
|
-
|
|
2776
|
+
value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
|
|
2777
|
+
instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
|
|
2778
|
+
[column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
|
|
2779
|
+
}), {}));
|
|
2780
|
+
},
|
|
2781
|
+
getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
|
|
2782
|
+
getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
|
|
2783
|
+
getToggleAllColumnsVisibilityHandler: () => {
|
|
2784
|
+
return e => {
|
|
2785
|
+
var _target;
|
|
2786
|
+
|
|
2787
|
+
instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
|
|
2788
|
+
};
|
|
2919
2789
|
}
|
|
2920
2790
|
};
|
|
2921
2791
|
}
|
|
2922
2792
|
};
|
|
2923
|
-
function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
|
|
2924
|
-
var _headerGroups$0$heade, _headerGroups$;
|
|
2925
|
-
|
|
2926
|
-
// Find the max depth of the columns:
|
|
2927
|
-
// build the leaf column row
|
|
2928
|
-
// build each buffer row going up
|
|
2929
|
-
// placeholder for non-existent level
|
|
2930
|
-
// real column for existing level
|
|
2931
|
-
let maxDepth = 0;
|
|
2932
|
-
|
|
2933
|
-
const findMaxDepth = function (columns, depth) {
|
|
2934
|
-
if (depth === void 0) {
|
|
2935
|
-
depth = 1;
|
|
2936
|
-
}
|
|
2937
|
-
|
|
2938
|
-
maxDepth = Math.max(maxDepth, depth);
|
|
2939
|
-
columns.filter(column => column.getIsVisible()).forEach(column => {
|
|
2940
|
-
var _column$columns;
|
|
2941
|
-
|
|
2942
|
-
if ((_column$columns = column.columns) != null && _column$columns.length) {
|
|
2943
|
-
findMaxDepth(column.columns, depth + 1);
|
|
2944
|
-
}
|
|
2945
|
-
}, 0);
|
|
2946
|
-
};
|
|
2947
|
-
|
|
2948
|
-
findMaxDepth(allColumns);
|
|
2949
|
-
let headerGroups = [];
|
|
2950
|
-
|
|
2951
|
-
const createHeaderGroup = (headersToGroup, depth) => {
|
|
2952
|
-
// The header group we are creating
|
|
2953
|
-
const headerGroup = {
|
|
2954
|
-
depth,
|
|
2955
|
-
id: [headerFamily, "" + depth].filter(Boolean).join('_'),
|
|
2956
|
-
headers: []
|
|
2957
|
-
}; // The parent columns we're going to scan next
|
|
2958
|
-
|
|
2959
|
-
const pendingParentHeaders = []; // Scan each column for parents
|
|
2960
|
-
|
|
2961
|
-
headersToGroup.forEach(headerToGroup => {
|
|
2962
|
-
// What is the latest (last) parent column?
|
|
2963
|
-
const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
|
|
2964
|
-
const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
|
|
2965
|
-
let column;
|
|
2966
|
-
let isPlaceholder = false;
|
|
2967
|
-
|
|
2968
|
-
if (isLeafHeader && headerToGroup.column.parent) {
|
|
2969
|
-
// The parent header is new
|
|
2970
|
-
column = headerToGroup.column.parent;
|
|
2971
|
-
} else {
|
|
2972
|
-
// The parent header is repeated
|
|
2973
|
-
column = headerToGroup.column;
|
|
2974
|
-
isPlaceholder = true;
|
|
2975
|
-
}
|
|
2976
|
-
|
|
2977
|
-
if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
|
|
2978
|
-
// This column is repeated. Add it as a sub header to the next batch
|
|
2979
|
-
latestPendingParentHeader.subHeaders.push(headerToGroup);
|
|
2980
|
-
} else {
|
|
2981
|
-
// This is a new header. Let's create it
|
|
2982
|
-
const header = instance.createHeader(column, {
|
|
2983
|
-
id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
|
|
2984
|
-
isPlaceholder,
|
|
2985
|
-
placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
|
|
2986
|
-
depth,
|
|
2987
|
-
index: pendingParentHeaders.length
|
|
2988
|
-
}); // Add the headerToGroup as a subHeader of the new header
|
|
2989
|
-
|
|
2990
|
-
header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
|
|
2991
|
-
// in the next batch
|
|
2992
|
-
|
|
2993
|
-
pendingParentHeaders.push(header);
|
|
2994
|
-
}
|
|
2995
|
-
|
|
2996
|
-
headerGroup.headers.push(headerToGroup);
|
|
2997
|
-
headerToGroup.headerGroup = headerGroup;
|
|
2998
|
-
});
|
|
2999
|
-
headerGroups.push(headerGroup);
|
|
3000
|
-
|
|
3001
|
-
if (depth > 0) {
|
|
3002
|
-
createHeaderGroup(pendingParentHeaders, depth - 1);
|
|
3003
|
-
}
|
|
3004
|
-
};
|
|
3005
|
-
|
|
3006
|
-
const bottomHeaders = columnsToGroup.map((column, index) => instance.createHeader(column, {
|
|
3007
|
-
depth: maxDepth,
|
|
3008
|
-
index
|
|
3009
|
-
}));
|
|
3010
|
-
createHeaderGroup(bottomHeaders, maxDepth - 1);
|
|
3011
|
-
headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
|
|
3012
|
-
// return !headerGroup.headers.every(header => header.isPlaceholder)
|
|
3013
|
-
// })
|
|
3014
|
-
|
|
3015
|
-
const recurseHeadersForSpans = headers => {
|
|
3016
|
-
const filteredHeaders = headers.filter(header => header.column.getIsVisible());
|
|
3017
|
-
return filteredHeaders.map(header => {
|
|
3018
|
-
let colSpan = 0;
|
|
3019
|
-
let rowSpan = 0;
|
|
3020
|
-
let childRowSpans = [0];
|
|
3021
|
-
|
|
3022
|
-
if (header.subHeaders && header.subHeaders.length) {
|
|
3023
|
-
childRowSpans = [];
|
|
3024
|
-
recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
|
|
3025
|
-
let {
|
|
3026
|
-
colSpan: childColSpan,
|
|
3027
|
-
rowSpan: childRowSpan
|
|
3028
|
-
} = _ref;
|
|
3029
|
-
colSpan += childColSpan;
|
|
3030
|
-
childRowSpans.push(childRowSpan);
|
|
3031
|
-
});
|
|
3032
|
-
} else {
|
|
3033
|
-
colSpan = 1;
|
|
3034
|
-
}
|
|
3035
|
-
|
|
3036
|
-
const minChildRowSpan = Math.min(...childRowSpans);
|
|
3037
|
-
rowSpan = rowSpan + minChildRowSpan;
|
|
3038
|
-
header.colSpan = colSpan > 0 ? colSpan : undefined;
|
|
3039
|
-
header.rowSpan = rowSpan > 0 ? rowSpan : undefined;
|
|
3040
|
-
return {
|
|
3041
|
-
colSpan,
|
|
3042
|
-
rowSpan
|
|
3043
|
-
};
|
|
3044
|
-
});
|
|
3045
|
-
};
|
|
3046
2793
|
|
|
3047
|
-
|
|
3048
|
-
return headerGroups;
|
|
3049
|
-
}
|
|
2794
|
+
const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]; //
|
|
3050
2795
|
|
|
3051
|
-
// export type Batch = {
|
|
3052
|
-
// id: number
|
|
3053
|
-
// priority: keyof CoreBatches
|
|
3054
|
-
// tasks: (() => void)[]
|
|
3055
|
-
// schedule: (cb: () => void) => void
|
|
3056
|
-
// cancel: () => void
|
|
3057
|
-
// }
|
|
3058
|
-
// type CoreBatches = {
|
|
3059
|
-
// data: Batch[]
|
|
3060
|
-
// facets: Batch[]
|
|
3061
|
-
// }
|
|
3062
2796
|
function createTableInstance(options) {
|
|
3063
2797
|
var _options$initialState;
|
|
3064
2798
|
|
|
@@ -3067,7 +2801,7 @@
|
|
|
3067
2801
|
}
|
|
3068
2802
|
|
|
3069
2803
|
let instance = {
|
|
3070
|
-
_features:
|
|
2804
|
+
_features: features
|
|
3071
2805
|
};
|
|
3072
2806
|
|
|
3073
2807
|
const defaultOptions = instance._features.reduce((obj, feature) => {
|
|
@@ -3084,8 +2818,7 @@
|
|
|
3084
2818
|
};
|
|
3085
2819
|
};
|
|
3086
2820
|
|
|
3087
|
-
const coreInitialState = {
|
|
3088
|
-
};
|
|
2821
|
+
const coreInitialState = {};
|
|
3089
2822
|
let initialState = { ...coreInitialState,
|
|
3090
2823
|
...((_options$initialState = options.initialState) != null ? _options$initialState : {})
|
|
3091
2824
|
};
|
|
@@ -3098,16 +2831,8 @@
|
|
|
3098
2831
|
|
|
3099
2832
|
const queued = [];
|
|
3100
2833
|
let queuedTimeout = false;
|
|
3101
|
-
const
|
|
3102
|
-
|
|
3103
|
-
// startWork()
|
|
3104
|
-
// },
|
|
3105
|
-
// willUpdate: () => {
|
|
3106
|
-
// startWork()
|
|
3107
|
-
// },
|
|
3108
|
-
// destroy: () => {
|
|
3109
|
-
// stopWork()
|
|
3110
|
-
// },
|
|
2834
|
+
const coreInstance = {
|
|
2835
|
+
_features: features,
|
|
3111
2836
|
options: { ...defaultOptions,
|
|
3112
2837
|
...options
|
|
3113
2838
|
},
|
|
@@ -3153,29 +2878,134 @@
|
|
|
3153
2878
|
},
|
|
3154
2879
|
setState: updater => {
|
|
3155
2880
|
instance.options.onStateChange == null ? void 0 : instance.options.onStateChange(updater);
|
|
3156
|
-
}
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
//
|
|
3170
|
-
//
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
2881
|
+
},
|
|
2882
|
+
_getRowId: (row, index, parent) => {
|
|
2883
|
+
var _instance$options$get;
|
|
2884
|
+
|
|
2885
|
+
return (_instance$options$get = instance.options.getRowId == null ? void 0 : instance.options.getRowId(row, index, parent)) != null ? _instance$options$get : "" + (parent ? [parent.id, index].join('.') : index);
|
|
2886
|
+
},
|
|
2887
|
+
getCoreRowModel: () => {
|
|
2888
|
+
if (!instance._getCoreRowModel) {
|
|
2889
|
+
instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2892
|
+
return instance._getCoreRowModel();
|
|
2893
|
+
},
|
|
2894
|
+
// The final calls start at the bottom of the model,
|
|
2895
|
+
// expanded rows, which then work their way up
|
|
2896
|
+
getRowModel: () => {
|
|
2897
|
+
return instance.getPaginationRowModel();
|
|
2898
|
+
},
|
|
2899
|
+
getRow: id => {
|
|
2900
|
+
const row = instance.getRowModel().rowsById[id];
|
|
2901
|
+
|
|
2902
|
+
if (!row) {
|
|
2903
|
+
{
|
|
2904
|
+
throw new Error("getRow expected an ID, but got " + id);
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
|
|
2908
|
+
return row;
|
|
2909
|
+
},
|
|
2910
|
+
_getDefaultColumnDef: memo(() => [instance.options.defaultColumn], defaultColumn => {
|
|
2911
|
+
var _defaultColumn;
|
|
2912
|
+
|
|
2913
|
+
defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
|
|
2914
|
+
return {
|
|
2915
|
+
header: props => props.header.column.id,
|
|
2916
|
+
footer: props => props.header.column.id,
|
|
2917
|
+
cell: props => {
|
|
2918
|
+
var _props$getValue$toStr, _props$getValue$toStr2, _props$getValue;
|
|
2919
|
+
|
|
2920
|
+
return (_props$getValue$toStr = (_props$getValue$toStr2 = (_props$getValue = props.getValue()).toString) == null ? void 0 : _props$getValue$toStr2.call(_props$getValue)) != null ? _props$getValue$toStr : null;
|
|
2921
|
+
},
|
|
2922
|
+
...instance._features.reduce((obj, feature) => {
|
|
2923
|
+
return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
|
|
2924
|
+
}, {}),
|
|
2925
|
+
...defaultColumn
|
|
2926
|
+
};
|
|
2927
|
+
}, {
|
|
2928
|
+
debug: () => {
|
|
2929
|
+
var _instance$options$deb;
|
|
2930
|
+
|
|
2931
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
|
|
2932
|
+
},
|
|
2933
|
+
key: 'getDefaultColumnDef'
|
|
2934
|
+
}),
|
|
2935
|
+
_getColumnDefs: () => instance.options.columns,
|
|
2936
|
+
getAllColumns: memo(() => [instance._getColumnDefs()], columnDefs => {
|
|
2937
|
+
const recurseColumns = function (columnDefs, parent, depth) {
|
|
2938
|
+
if (depth === void 0) {
|
|
2939
|
+
depth = 0;
|
|
2940
|
+
}
|
|
2941
|
+
|
|
2942
|
+
return columnDefs.map(columnDef => {
|
|
2943
|
+
const column = createColumn(instance, columnDef, depth, parent);
|
|
2944
|
+
column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
|
|
2945
|
+
return column;
|
|
2946
|
+
});
|
|
2947
|
+
};
|
|
2948
|
+
|
|
2949
|
+
return recurseColumns(columnDefs);
|
|
2950
|
+
}, {
|
|
2951
|
+
key: 'getAllColumns',
|
|
2952
|
+
debug: () => {
|
|
2953
|
+
var _instance$options$deb2;
|
|
2954
|
+
|
|
2955
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
|
|
2956
|
+
}
|
|
2957
|
+
}),
|
|
2958
|
+
getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
|
|
2959
|
+
return allColumns.flatMap(column => {
|
|
2960
|
+
return column.getFlatColumns();
|
|
2961
|
+
});
|
|
2962
|
+
}, {
|
|
2963
|
+
key: 'getAllFlatColumns',
|
|
2964
|
+
debug: () => {
|
|
2965
|
+
var _instance$options$deb3;
|
|
2966
|
+
|
|
2967
|
+
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
2968
|
+
}
|
|
2969
|
+
}),
|
|
2970
|
+
_getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
|
|
2971
|
+
return flatColumns.reduce((acc, column) => {
|
|
2972
|
+
acc[column.id] = column;
|
|
2973
|
+
return acc;
|
|
2974
|
+
}, {});
|
|
2975
|
+
}, {
|
|
2976
|
+
key: 'getAllFlatColumnsById',
|
|
2977
|
+
debug: () => {
|
|
2978
|
+
var _instance$options$deb4;
|
|
2979
|
+
|
|
2980
|
+
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
|
|
2981
|
+
}
|
|
2982
|
+
}),
|
|
2983
|
+
getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
|
|
2984
|
+
let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
|
|
2985
|
+
return orderColumns(leafColumns);
|
|
2986
|
+
}, {
|
|
2987
|
+
key: 'getAllLeafColumns',
|
|
2988
|
+
debug: () => {
|
|
2989
|
+
var _instance$options$deb5;
|
|
2990
|
+
|
|
2991
|
+
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
|
|
2992
|
+
}
|
|
2993
|
+
}),
|
|
2994
|
+
getColumn: columnId => {
|
|
2995
|
+
const column = instance._getAllFlatColumnsById()[columnId];
|
|
2996
|
+
|
|
2997
|
+
if (!column) {
|
|
2998
|
+
{
|
|
2999
|
+
console.warn("[Table] Column with id " + columnId + " does not exist.");
|
|
3000
|
+
}
|
|
3001
|
+
|
|
3002
|
+
throw new Error();
|
|
3003
|
+
}
|
|
3176
3004
|
|
|
3005
|
+
return column;
|
|
3006
|
+
}
|
|
3177
3007
|
};
|
|
3178
|
-
|
|
3008
|
+
Object.assign(instance, coreInstance);
|
|
3179
3009
|
|
|
3180
3010
|
instance._features.forEach(feature => {
|
|
3181
3011
|
return Object.assign(instance, feature.createInstance == null ? void 0 : feature.createInstance(instance));
|
|
@@ -3198,7 +3028,7 @@
|
|
|
3198
3028
|
throw new Error('');
|
|
3199
3029
|
})()
|
|
3200
3030
|
},
|
|
3201
|
-
setGenerics: () => table,
|
|
3031
|
+
// setGenerics: () => table as any,
|
|
3202
3032
|
setRowType: () => table,
|
|
3203
3033
|
setTableMetaType: () => table,
|
|
3204
3034
|
setColumnMetaType: () => table,
|
|
@@ -3234,11 +3064,92 @@
|
|
|
3234
3064
|
}
|
|
3235
3065
|
|
|
3236
3066
|
throw new Error('Invalid accessor');
|
|
3237
|
-
}
|
|
3067
|
+
},
|
|
3068
|
+
createOptions: options => options
|
|
3238
3069
|
};
|
|
3239
3070
|
return table;
|
|
3240
3071
|
}
|
|
3241
3072
|
|
|
3073
|
+
function createCell(instance, row, column, columnId) {
|
|
3074
|
+
const cell = {
|
|
3075
|
+
id: row.id + "_" + column.id,
|
|
3076
|
+
row,
|
|
3077
|
+
column,
|
|
3078
|
+
getValue: () => row.getValue(columnId),
|
|
3079
|
+
renderCell: () => column.columnDef.cell ? instance._render(column.columnDef.cell, {
|
|
3080
|
+
instance,
|
|
3081
|
+
column,
|
|
3082
|
+
row,
|
|
3083
|
+
cell: cell,
|
|
3084
|
+
getValue: cell.getValue
|
|
3085
|
+
}) : null
|
|
3086
|
+
};
|
|
3087
|
+
|
|
3088
|
+
instance._features.forEach(feature => {
|
|
3089
|
+
Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
|
|
3090
|
+
}, {});
|
|
3091
|
+
|
|
3092
|
+
return cell;
|
|
3093
|
+
}
|
|
3094
|
+
|
|
3095
|
+
const createRow = (instance, id, original, rowIndex, depth, subRows) => {
|
|
3096
|
+
let row = {
|
|
3097
|
+
id,
|
|
3098
|
+
index: rowIndex,
|
|
3099
|
+
original,
|
|
3100
|
+
depth,
|
|
3101
|
+
_valuesCache: {},
|
|
3102
|
+
getValue: columnId => {
|
|
3103
|
+
if (row._valuesCache.hasOwnProperty(columnId)) {
|
|
3104
|
+
return row._valuesCache[columnId];
|
|
3105
|
+
}
|
|
3106
|
+
|
|
3107
|
+
const column = instance.getColumn(columnId);
|
|
3108
|
+
|
|
3109
|
+
if (!column.accessorFn) {
|
|
3110
|
+
return undefined;
|
|
3111
|
+
}
|
|
3112
|
+
|
|
3113
|
+
row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
|
3114
|
+
return row._valuesCache[columnId];
|
|
3115
|
+
},
|
|
3116
|
+
subRows: subRows != null ? subRows : [],
|
|
3117
|
+
getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
|
|
3118
|
+
getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
|
|
3119
|
+
return leafColumns.map(column => {
|
|
3120
|
+
return createCell(instance, row, column, column.id);
|
|
3121
|
+
});
|
|
3122
|
+
}, {
|
|
3123
|
+
key: 'row.getAllCells',
|
|
3124
|
+
debug: () => {
|
|
3125
|
+
var _instance$options$deb;
|
|
3126
|
+
|
|
3127
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
|
|
3128
|
+
}
|
|
3129
|
+
}),
|
|
3130
|
+
_getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
|
|
3131
|
+
return allCells.reduce((acc, cell) => {
|
|
3132
|
+
acc[cell.column.id] = cell;
|
|
3133
|
+
return acc;
|
|
3134
|
+
}, {});
|
|
3135
|
+
}, {
|
|
3136
|
+
key: "development" === 'production' ,
|
|
3137
|
+
debug: () => {
|
|
3138
|
+
var _instance$options$deb2;
|
|
3139
|
+
|
|
3140
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
|
|
3141
|
+
}
|
|
3142
|
+
})
|
|
3143
|
+
};
|
|
3144
|
+
|
|
3145
|
+
for (let i = 0; i < instance._features.length; i++) {
|
|
3146
|
+
const feature = instance._features[i];
|
|
3147
|
+
Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
|
|
3148
|
+
}
|
|
3149
|
+
|
|
3150
|
+
return row;
|
|
3151
|
+
};
|
|
3152
|
+
|
|
3242
3153
|
function getCoreRowModel() {
|
|
3243
3154
|
return instance => memo(() => [instance.options.data], data => {
|
|
3244
3155
|
const rowModel = {
|
|
@@ -3266,7 +3177,7 @@
|
|
|
3266
3177
|
// }
|
|
3267
3178
|
// Make the row
|
|
3268
3179
|
|
|
3269
|
-
row =
|
|
3180
|
+
row = createRow(instance, instance._getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
|
|
3270
3181
|
|
|
3271
3182
|
rowModel.flatRows.push(row); // Also keep track of every row by its ID
|
|
3272
3183
|
|
|
@@ -3329,7 +3240,7 @@
|
|
|
3329
3240
|
row = rowsToFilter[i];
|
|
3330
3241
|
|
|
3331
3242
|
if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
|
|
3332
|
-
newRow =
|
|
3243
|
+
newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3333
3244
|
newRow.columnFilters = row.columnFilters;
|
|
3334
3245
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3335
3246
|
|
|
@@ -3379,7 +3290,7 @@
|
|
|
3379
3290
|
var _row$subRows2;
|
|
3380
3291
|
|
|
3381
3292
|
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
|
|
3382
|
-
newRow =
|
|
3293
|
+
newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3383
3294
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3384
3295
|
row = newRow;
|
|
3385
3296
|
}
|
|
@@ -3631,8 +3542,8 @@
|
|
|
3631
3542
|
availableSorting.forEach(sortEntry => {
|
|
3632
3543
|
const column = instance.getColumn(sortEntry.id);
|
|
3633
3544
|
columnInfoById[sortEntry.id] = {
|
|
3634
|
-
sortUndefined: column.sortUndefined,
|
|
3635
|
-
invertSorting: column.invertSorting,
|
|
3545
|
+
sortUndefined: column.columnDef.sortUndefined,
|
|
3546
|
+
invertSorting: column.columnDef.invertSorting,
|
|
3636
3547
|
sortingFn: column.getSortingFn()
|
|
3637
3548
|
};
|
|
3638
3549
|
});
|
|
@@ -3746,7 +3657,7 @@
|
|
|
3746
3657
|
const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
|
|
3747
3658
|
|
|
3748
3659
|
const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
|
|
3749
|
-
const row =
|
|
3660
|
+
const row = createRow(instance, id, undefined, index, depth);
|
|
3750
3661
|
Object.assign(row, {
|
|
3751
3662
|
groupingColumnId: columnId,
|
|
3752
3663
|
groupingValue,
|
|
@@ -3755,38 +3666,30 @@
|
|
|
3755
3666
|
getValue: columnId => {
|
|
3756
3667
|
// Don't aggregate columns that are in the grouping
|
|
3757
3668
|
if (existingGrouping.includes(columnId)) {
|
|
3758
|
-
if (row.
|
|
3759
|
-
return row.
|
|
3669
|
+
if (row._valuesCache.hasOwnProperty(columnId)) {
|
|
3670
|
+
return row._valuesCache[columnId];
|
|
3760
3671
|
}
|
|
3761
3672
|
|
|
3762
3673
|
if (groupedRows[0]) {
|
|
3763
3674
|
var _groupedRows$0$getVal;
|
|
3764
3675
|
|
|
3765
|
-
row.
|
|
3676
|
+
row._valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
|
|
3766
3677
|
}
|
|
3767
3678
|
|
|
3768
|
-
return row.
|
|
3679
|
+
return row._valuesCache[columnId];
|
|
3769
3680
|
}
|
|
3770
3681
|
|
|
3771
|
-
if (row.
|
|
3772
|
-
return row.
|
|
3682
|
+
if (row._groupingValuesCache.hasOwnProperty(columnId)) {
|
|
3683
|
+
return row._groupingValuesCache[columnId];
|
|
3773
3684
|
} // Aggregate the values
|
|
3774
3685
|
|
|
3775
3686
|
|
|
3776
3687
|
const column = instance.getColumn(columnId);
|
|
3777
|
-
const aggregateFn = column.
|
|
3688
|
+
const aggregateFn = column.getAggregationFn();
|
|
3778
3689
|
|
|
3779
3690
|
if (aggregateFn) {
|
|
3780
|
-
row.
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
if (!depth && column.aggregateValue) {
|
|
3784
|
-
columnValue = column.aggregateValue(columnValue);
|
|
3785
|
-
}
|
|
3786
|
-
|
|
3787
|
-
return columnValue;
|
|
3788
|
-
}), () => groupedRows.map(row => row.getValue(columnId)));
|
|
3789
|
-
return row.groupingValuesCache[columnId];
|
|
3691
|
+
row._groupingValuesCache[columnId] = aggregateFn(columnId, leafRows, groupedRows);
|
|
3692
|
+
return row._groupingValuesCache[columnId];
|
|
3790
3693
|
} else if (column.aggregationFn) {
|
|
3791
3694
|
console.info({
|
|
3792
3695
|
column
|
|
@@ -4008,6 +3911,8 @@
|
|
|
4008
3911
|
exports.Visibility = Visibility;
|
|
4009
3912
|
exports.aggregationFns = aggregationFns;
|
|
4010
3913
|
exports.buildHeaderGroups = buildHeaderGroups;
|
|
3914
|
+
exports.createColumn = createColumn;
|
|
3915
|
+
exports.createRow = createRow;
|
|
4011
3916
|
exports.createTable = createTable;
|
|
4012
3917
|
exports.createTableFactory = createTableFactory;
|
|
4013
3918
|
exports.createTableInstance = createTableInstance;
|
|
@@ -4028,7 +3933,6 @@
|
|
|
4028
3933
|
exports.isFunction = isFunction;
|
|
4029
3934
|
exports.isRowSelected = isRowSelected;
|
|
4030
3935
|
exports.makeStateUpdater = makeStateUpdater;
|
|
4031
|
-
exports.mean = mean;
|
|
4032
3936
|
exports.memo = memo;
|
|
4033
3937
|
exports.noop = noop;
|
|
4034
3938
|
exports.orderColumns = orderColumns;
|