@tanstack/react-table 8.0.0-alpha.83 → 8.0.0-alpha.84
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 -0
- package/build/cjs/react-table/src/index.js.map +1 -1
- package/build/cjs/table-core/build/esm/index.js +657 -760
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +656 -761
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +17 -17
- package/build/umd/index.development.js +660 -759
- 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
|
@@ -121,329 +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.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
|
|
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: 'getDefaultColumnDef'
|
|
152
|
-
}),
|
|
153
|
-
getColumnDefs: () => instance.options.columns,
|
|
154
|
-
createColumn: (columnDef, depth, parent) => {
|
|
155
|
-
var _ref, _columnDef$id;
|
|
156
|
-
|
|
157
|
-
const defaultColumnDef = instance.getDefaultColumnDef();
|
|
158
|
-
columnDef = { ...defaultColumnDef,
|
|
159
|
-
...columnDef
|
|
160
|
-
};
|
|
161
|
-
let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
|
|
162
|
-
let accessorFn;
|
|
163
|
-
|
|
164
|
-
if (columnDef.accessorFn) {
|
|
165
|
-
accessorFn = columnDef.accessorFn;
|
|
166
|
-
} else if (columnDef.accessorKey) {
|
|
167
|
-
accessorFn = originalRow => originalRow[columnDef.accessorKey];
|
|
258
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
|
|
168
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;
|
|
169
268
|
|
|
170
|
-
|
|
171
|
-
{
|
|
172
|
-
throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
|
|
173
|
-
}
|
|
269
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
|
|
174
270
|
}
|
|
271
|
+
}),
|
|
272
|
+
getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
273
|
+
var _left$map$filter2;
|
|
175
274
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
columnDefType: columnDef.columnDefType,
|
|
183
|
-
columns: [],
|
|
184
|
-
getFlatColumns: memo(() => [true], () => {
|
|
185
|
-
var _column$columns;
|
|
186
|
-
|
|
187
|
-
return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
|
|
188
|
-
}, {
|
|
189
|
-
key: "development" === 'production' ,
|
|
190
|
-
debug: () => {
|
|
191
|
-
var _instance$options$deb2;
|
|
192
|
-
|
|
193
|
-
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
|
|
194
|
-
}
|
|
195
|
-
}),
|
|
196
|
-
getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
|
|
197
|
-
var _column$columns2;
|
|
198
|
-
|
|
199
|
-
if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
|
|
200
|
-
let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
|
|
201
|
-
return orderColumns(leafColumns);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return [column];
|
|
205
|
-
}, {
|
|
206
|
-
key: "development" === 'production' ,
|
|
207
|
-
debug: () => {
|
|
208
|
-
var _instance$options$deb3;
|
|
209
|
-
|
|
210
|
-
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
211
|
-
}
|
|
212
|
-
})
|
|
213
|
-
};
|
|
214
|
-
column = instance._features.reduce((obj, feature) => {
|
|
215
|
-
return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
|
|
216
|
-
}, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
217
|
-
|
|
218
|
-
return column;
|
|
219
|
-
},
|
|
220
|
-
getAllColumns: memo(() => [instance.getColumnDefs()], columnDefs => {
|
|
221
|
-
const recurseColumns = function (columnDefs, parent, depth) {
|
|
222
|
-
if (depth === void 0) {
|
|
223
|
-
depth = 0;
|
|
224
|
-
}
|
|
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;
|
|
225
281
|
|
|
226
|
-
return
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
};
|
|
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;
|
|
232
287
|
|
|
233
|
-
|
|
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');
|
|
234
290
|
}, {
|
|
235
|
-
key: '
|
|
291
|
+
key: 'getRightHeaderGroups',
|
|
236
292
|
debug: () => {
|
|
237
293
|
var _instance$options$deb4;
|
|
238
294
|
|
|
239
|
-
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;
|
|
240
296
|
}
|
|
241
297
|
}),
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
});
|
|
298
|
+
// Footer Groups
|
|
299
|
+
getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
300
|
+
return [...headerGroups].reverse();
|
|
246
301
|
}, {
|
|
247
|
-
key: '
|
|
302
|
+
key: 'getFooterGroups',
|
|
248
303
|
debug: () => {
|
|
249
304
|
var _instance$options$deb5;
|
|
250
305
|
|
|
251
|
-
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;
|
|
252
307
|
}
|
|
253
308
|
}),
|
|
254
|
-
|
|
255
|
-
return
|
|
256
|
-
acc[column.id] = column;
|
|
257
|
-
return acc;
|
|
258
|
-
}, {});
|
|
309
|
+
getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
|
|
310
|
+
return [...headerGroups].reverse();
|
|
259
311
|
}, {
|
|
260
|
-
key: '
|
|
312
|
+
key: 'getLeftFooterGroups',
|
|
261
313
|
debug: () => {
|
|
262
314
|
var _instance$options$deb6;
|
|
263
315
|
|
|
264
|
-
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;
|
|
265
317
|
}
|
|
266
318
|
}),
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
return orderColumns(leafColumns);
|
|
319
|
+
getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
|
|
320
|
+
return [...headerGroups].reverse();
|
|
270
321
|
}, {
|
|
271
|
-
key: '
|
|
322
|
+
key: 'getCenterFooterGroups',
|
|
272
323
|
debug: () => {
|
|
273
324
|
var _instance$options$deb7;
|
|
274
325
|
|
|
275
|
-
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;
|
|
276
327
|
}
|
|
277
328
|
}),
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
329
|
+
getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
|
|
330
|
+
return [...headerGroups].reverse();
|
|
331
|
+
}, {
|
|
332
|
+
key: 'getRightFooterGroups',
|
|
333
|
+
debug: () => {
|
|
334
|
+
var _instance$options$deb8;
|
|
285
335
|
|
|
286
|
-
|
|
336
|
+
return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
|
|
287
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;
|
|
288
348
|
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
//
|
|
296
|
-
const Rows = {
|
|
297
|
-
// createRow: <TGenerics extends TableGenerics>(
|
|
298
|
-
// row: Row<TGenerics>,
|
|
299
|
-
// instance: TableInstance<TGenerics>
|
|
300
|
-
// ): CellsRow<TGenerics> => {
|
|
301
|
-
// return {}
|
|
302
|
-
// },
|
|
303
|
-
createInstance: instance => {
|
|
304
|
-
return {
|
|
305
|
-
getRowId: (row, index, parent) => {
|
|
306
|
-
var _instance$options$get;
|
|
307
|
-
|
|
308
|
-
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);
|
|
309
|
-
},
|
|
310
|
-
createRow: (id, original, rowIndex, depth, subRows) => {
|
|
311
|
-
let row = {
|
|
312
|
-
id,
|
|
313
|
-
index: rowIndex,
|
|
314
|
-
original,
|
|
315
|
-
depth,
|
|
316
|
-
valuesCache: {},
|
|
317
|
-
getValue: columnId => {
|
|
318
|
-
if (row.valuesCache.hasOwnProperty(columnId)) {
|
|
319
|
-
return row.valuesCache[columnId];
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
const column = instance.getColumn(columnId);
|
|
323
|
-
|
|
324
|
-
if (!column.accessorFn) {
|
|
325
|
-
return undefined;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
row.valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
|
329
|
-
return row.valuesCache[columnId];
|
|
330
|
-
},
|
|
331
|
-
subRows: subRows != null ? subRows : [],
|
|
332
|
-
getLeafRows: () => flattenBy(row.subRows, d => d.subRows)
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
for (let i = 0; i < instance._features.length; i++) {
|
|
336
|
-
const feature = instance._features[i];
|
|
337
|
-
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;
|
|
338
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;
|
|
339
360
|
|
|
340
|
-
|
|
341
|
-
},
|
|
342
|
-
getCoreRowModel: () => {
|
|
343
|
-
if (!instance._getCoreRowModel) {
|
|
344
|
-
instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
|
|
361
|
+
return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
|
|
345
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;
|
|
346
372
|
|
|
347
|
-
|
|
348
|
-
},
|
|
349
|
-
// The final calls start at the bottom of the model,
|
|
350
|
-
// expanded rows, which then work their way up
|
|
351
|
-
getRowModel: () => {
|
|
352
|
-
return instance.getPaginationRowModel();
|
|
353
|
-
},
|
|
354
|
-
getRow: id => {
|
|
355
|
-
const row = instance.getRowModel().rowsById[id];
|
|
356
|
-
|
|
357
|
-
if (!row) {
|
|
358
|
-
{
|
|
359
|
-
throw new Error("getRow expected an ID, but got " + id);
|
|
360
|
-
}
|
|
373
|
+
return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
|
|
361
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;
|
|
362
384
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
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;
|
|
368
392
|
|
|
369
|
-
|
|
370
|
-
const Cells = {
|
|
371
|
-
createRow: (row, instance) => {
|
|
372
|
-
return {
|
|
373
|
-
getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
|
|
374
|
-
return leafColumns.map(column => {
|
|
375
|
-
return instance.createCell(row, column, column.id);
|
|
393
|
+
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
|
376
394
|
});
|
|
377
395
|
}, {
|
|
378
|
-
key: '
|
|
396
|
+
key: 'getCenterLeafHeaders',
|
|
379
397
|
debug: () => {
|
|
380
|
-
var _instance$options$
|
|
398
|
+
var _instance$options$deb13;
|
|
381
399
|
|
|
382
|
-
return (_instance$options$
|
|
400
|
+
return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
|
|
383
401
|
}
|
|
384
402
|
}),
|
|
385
|
-
|
|
386
|
-
return
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
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
|
+
});
|
|
390
409
|
}, {
|
|
391
|
-
key:
|
|
410
|
+
key: 'getLeftLeafHeaders',
|
|
392
411
|
debug: () => {
|
|
393
|
-
var _instance$options$
|
|
412
|
+
var _instance$options$deb14;
|
|
394
413
|
|
|
395
|
-
return (_instance$options$
|
|
414
|
+
return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
|
|
396
415
|
}
|
|
397
|
-
})
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
return {
|
|
402
|
-
createCell: (row, column, columnId) => {
|
|
403
|
-
const cell = {
|
|
404
|
-
id: row.id + "_" + column.id,
|
|
405
|
-
rowId: row.id,
|
|
406
|
-
columnId,
|
|
407
|
-
row,
|
|
408
|
-
column,
|
|
409
|
-
getValue: () => row.getValue(columnId),
|
|
410
|
-
renderCell: () => column.columnDef.cell ? instance._render(column.columnDef.cell, {
|
|
411
|
-
instance,
|
|
412
|
-
column,
|
|
413
|
-
row,
|
|
414
|
-
cell: cell,
|
|
415
|
-
getValue: cell.getValue
|
|
416
|
-
}) : null
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
instance._features.forEach(feature => {
|
|
420
|
-
Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
|
|
421
|
-
}, {});
|
|
416
|
+
}),
|
|
417
|
+
getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
|
|
418
|
+
return flatHeaders.filter(header => {
|
|
419
|
+
var _header$subHeaders3;
|
|
422
420
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
421
|
+
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
|
422
|
+
});
|
|
423
|
+
}, {
|
|
424
|
+
key: 'getRightLeafHeaders',
|
|
425
|
+
debug: () => {
|
|
426
|
+
var _instance$options$deb15;
|
|
427
427
|
|
|
428
|
-
|
|
429
|
-
{
|
|
430
|
-
throw new Error("[Table] could not find row with id " + rowId);
|
|
431
|
-
}
|
|
428
|
+
return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
|
|
432
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$;
|
|
433
433
|
|
|
434
|
-
|
|
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;
|
|
435
441
|
|
|
436
|
-
|
|
437
|
-
{
|
|
438
|
-
throw new Error("[Table] could not find cell " + columnId + " in row " + rowId);
|
|
439
|
-
}
|
|
442
|
+
return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
|
|
440
443
|
}
|
|
441
|
-
|
|
442
|
-
return cell;
|
|
443
|
-
}
|
|
444
|
+
})
|
|
444
445
|
};
|
|
445
446
|
}
|
|
446
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
|
+
}
|
|
447
575
|
|
|
448
576
|
//
|
|
449
577
|
const defaultColumnSizing = {
|
|
@@ -990,7 +1118,7 @@
|
|
|
990
1118
|
getColumnCanGlobalFilter: column => {
|
|
991
1119
|
var _instance$getCoreRowM, _instance$getCoreRowM2;
|
|
992
1120
|
|
|
993
|
-
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();
|
|
994
1122
|
return typeof value === 'string';
|
|
995
1123
|
}
|
|
996
1124
|
};
|
|
@@ -1768,7 +1896,7 @@
|
|
|
1768
1896
|
return {
|
|
1769
1897
|
getCenterVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allCells, left, right) => {
|
|
1770
1898
|
const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
|
|
1771
|
-
return allCells.filter(d => !leftAndRight.includes(d.
|
|
1899
|
+
return allCells.filter(d => !leftAndRight.includes(d.column.id));
|
|
1772
1900
|
}, {
|
|
1773
1901
|
key: "development" === 'production' ,
|
|
1774
1902
|
debug: () => {
|
|
@@ -1778,7 +1906,7 @@
|
|
|
1778
1906
|
}
|
|
1779
1907
|
}),
|
|
1780
1908
|
getLeftVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left,,], (allCells, left) => {
|
|
1781
|
-
const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.
|
|
1909
|
+
const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
|
|
1782
1910
|
position: 'left'
|
|
1783
1911
|
}));
|
|
1784
1912
|
return cells;
|
|
@@ -1791,7 +1919,7 @@
|
|
|
1791
1919
|
}
|
|
1792
1920
|
}),
|
|
1793
1921
|
getRightVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.right], (allCells, right) => {
|
|
1794
|
-
const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.
|
|
1922
|
+
const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
|
|
1795
1923
|
position: 'left'
|
|
1796
1924
|
}));
|
|
1797
1925
|
return cells;
|
|
@@ -2596,481 +2724,76 @@
|
|
|
2596
2724
|
};
|
|
2597
2725
|
},
|
|
2598
2726
|
createRow: (row, instance) => {
|
|
2599
|
-
return {
|
|
2600
|
-
_getAllVisibleCells: memo(() => [row.getAllCells().filter(cell => cell.column.getIsVisible()).map(d => d.id).join('_')], _ => {
|
|
2601
|
-
return row.getAllCells().filter(cell => cell.column.getIsVisible());
|
|
2602
|
-
}, {
|
|
2603
|
-
key: "development" === 'production' ,
|
|
2604
|
-
debug: () => {
|
|
2605
|
-
var _instance$options$deb;
|
|
2606
|
-
|
|
2607
|
-
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
|
|
2608
|
-
}
|
|
2609
|
-
}),
|
|
2610
|
-
getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
|
|
2611
|
-
key: 'row.getVisibleCells',
|
|
2612
|
-
debug: () => {
|
|
2613
|
-
var _instance$options$deb2;
|
|
2614
|
-
|
|
2615
|
-
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
|
|
2616
|
-
}
|
|
2617
|
-
})
|
|
2618
|
-
};
|
|
2619
|
-
},
|
|
2620
|
-
createInstance: instance => {
|
|
2621
|
-
const makeVisibleColumnsMethod = (key, getColumns) => {
|
|
2622
|
-
return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
|
|
2623
|
-
return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
|
|
2624
|
-
}, {
|
|
2625
|
-
key,
|
|
2626
|
-
debug: () => {
|
|
2627
|
-
var _instance$options$deb3;
|
|
2628
|
-
|
|
2629
|
-
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
2630
|
-
}
|
|
2631
|
-
});
|
|
2632
|
-
};
|
|
2633
|
-
|
|
2634
|
-
return {
|
|
2635
|
-
getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
|
|
2636
|
-
getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
|
|
2637
|
-
getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
|
|
2638
|
-
getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
|
|
2639
|
-
getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
|
|
2640
|
-
setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
|
|
2641
|
-
resetColumnVisibility: defaultState => {
|
|
2642
|
-
var _instance$initialStat;
|
|
2643
|
-
|
|
2644
|
-
instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
|
|
2645
|
-
},
|
|
2646
|
-
toggleAllColumnsVisible: value => {
|
|
2647
|
-
var _value;
|
|
2648
|
-
|
|
2649
|
-
value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
|
|
2650
|
-
instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
|
|
2651
|
-
[column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
|
|
2652
|
-
}), {}));
|
|
2653
|
-
},
|
|
2654
|
-
getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
|
|
2655
|
-
getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
|
|
2656
|
-
getToggleAllColumnsVisibilityHandler: () => {
|
|
2657
|
-
return e => {
|
|
2658
|
-
var _target;
|
|
2659
|
-
|
|
2660
|
-
instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
|
|
2661
|
-
};
|
|
2662
|
-
}
|
|
2663
|
-
};
|
|
2664
|
-
}
|
|
2665
|
-
};
|
|
2666
|
-
|
|
2667
|
-
//
|
|
2668
|
-
const Headers = {
|
|
2669
|
-
createInstance: instance => {
|
|
2670
|
-
return {
|
|
2671
|
-
createHeader: (column, options) => {
|
|
2672
|
-
var _options$id;
|
|
2673
|
-
|
|
2674
|
-
const id = (_options$id = options.id) != null ? _options$id : column.id;
|
|
2675
|
-
let header = {
|
|
2676
|
-
id,
|
|
2677
|
-
column,
|
|
2678
|
-
index: options.index,
|
|
2679
|
-
isPlaceholder: options.isPlaceholder,
|
|
2680
|
-
placeholderId: options.placeholderId,
|
|
2681
|
-
depth: options.depth,
|
|
2682
|
-
subHeaders: [],
|
|
2683
|
-
colSpan: 0,
|
|
2684
|
-
rowSpan: 0,
|
|
2685
|
-
headerGroup: null,
|
|
2686
|
-
getLeafHeaders: () => {
|
|
2687
|
-
const leafHeaders = [];
|
|
2688
|
-
|
|
2689
|
-
const recurseHeader = h => {
|
|
2690
|
-
if (h.subHeaders && h.subHeaders.length) {
|
|
2691
|
-
h.subHeaders.map(recurseHeader);
|
|
2692
|
-
}
|
|
2693
|
-
|
|
2694
|
-
leafHeaders.push(h);
|
|
2695
|
-
};
|
|
2696
|
-
|
|
2697
|
-
recurseHeader(header);
|
|
2698
|
-
return leafHeaders;
|
|
2699
|
-
},
|
|
2700
|
-
renderHeader: () => column.columnDef.header ? instance._render(column.columnDef.header, {
|
|
2701
|
-
instance,
|
|
2702
|
-
header: header,
|
|
2703
|
-
column
|
|
2704
|
-
}) : null,
|
|
2705
|
-
renderFooter: () => column.columnDef.footer ? instance._render(column.columnDef.footer, {
|
|
2706
|
-
instance,
|
|
2707
|
-
header: header,
|
|
2708
|
-
column
|
|
2709
|
-
}) : null
|
|
2710
|
-
};
|
|
2711
|
-
|
|
2712
|
-
instance._features.forEach(feature => {
|
|
2713
|
-
Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
|
|
2714
|
-
});
|
|
2715
|
-
|
|
2716
|
-
return header;
|
|
2717
|
-
},
|
|
2718
|
-
// Header Groups
|
|
2719
|
-
getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
2720
|
-
var _left$map$filter, _right$map$filter;
|
|
2721
|
-
|
|
2722
|
-
const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
|
|
2723
|
-
const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
|
|
2724
|
-
const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
2725
|
-
const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
|
|
2726
|
-
return headerGroups;
|
|
2727
|
-
}, {
|
|
2728
|
-
key: 'getHeaderGroups',
|
|
2729
|
-
debug: () => {
|
|
2730
|
-
var _instance$options$deb;
|
|
2731
|
-
|
|
2732
|
-
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
|
|
2733
|
-
}
|
|
2734
|
-
}),
|
|
2735
|
-
getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
2736
|
-
leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
2737
|
-
return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
|
|
2738
|
-
}, {
|
|
2739
|
-
key: 'getCenterHeaderGroups',
|
|
2740
|
-
debug: () => {
|
|
2741
|
-
var _instance$options$deb2;
|
|
2742
|
-
|
|
2743
|
-
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
|
|
2744
|
-
}
|
|
2745
|
-
}),
|
|
2746
|
-
getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
2747
|
-
var _left$map$filter2;
|
|
2748
|
-
|
|
2749
|
-
const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
|
|
2750
|
-
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
|
|
2751
|
-
}, {
|
|
2752
|
-
key: 'getLeftHeaderGroups',
|
|
2753
|
-
debug: () => {
|
|
2754
|
-
var _instance$options$deb3;
|
|
2755
|
-
|
|
2756
|
-
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
|
|
2757
|
-
}
|
|
2758
|
-
}),
|
|
2759
|
-
getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
2760
|
-
var _right$map$filter2;
|
|
2761
|
-
|
|
2762
|
-
const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
|
|
2763
|
-
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
|
|
2764
|
-
}, {
|
|
2765
|
-
key: 'getRightHeaderGroups',
|
|
2766
|
-
debug: () => {
|
|
2767
|
-
var _instance$options$deb4;
|
|
2768
|
-
|
|
2769
|
-
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
|
|
2770
|
-
}
|
|
2771
|
-
}),
|
|
2772
|
-
// Footer Groups
|
|
2773
|
-
getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
2774
|
-
return [...headerGroups].reverse();
|
|
2775
|
-
}, {
|
|
2776
|
-
key: 'getFooterGroups',
|
|
2777
|
-
debug: () => {
|
|
2778
|
-
var _instance$options$deb5;
|
|
2779
|
-
|
|
2780
|
-
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
|
|
2781
|
-
}
|
|
2782
|
-
}),
|
|
2783
|
-
getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
|
|
2784
|
-
return [...headerGroups].reverse();
|
|
2785
|
-
}, {
|
|
2786
|
-
key: 'getLeftFooterGroups',
|
|
2787
|
-
debug: () => {
|
|
2788
|
-
var _instance$options$deb6;
|
|
2789
|
-
|
|
2790
|
-
return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
|
|
2791
|
-
}
|
|
2792
|
-
}),
|
|
2793
|
-
getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
|
|
2794
|
-
return [...headerGroups].reverse();
|
|
2795
|
-
}, {
|
|
2796
|
-
key: 'getCenterFooterGroups',
|
|
2797
|
-
debug: () => {
|
|
2798
|
-
var _instance$options$deb7;
|
|
2799
|
-
|
|
2800
|
-
return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
|
|
2801
|
-
}
|
|
2802
|
-
}),
|
|
2803
|
-
getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
|
|
2804
|
-
return [...headerGroups].reverse();
|
|
2805
|
-
}, {
|
|
2806
|
-
key: 'getRightFooterGroups',
|
|
2807
|
-
debug: () => {
|
|
2808
|
-
var _instance$options$deb8;
|
|
2809
|
-
|
|
2810
|
-
return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
|
|
2811
|
-
}
|
|
2812
|
-
}),
|
|
2813
|
-
// Flat Headers
|
|
2814
|
-
getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
2815
|
-
return headerGroups.map(headerGroup => {
|
|
2816
|
-
return headerGroup.headers;
|
|
2817
|
-
}).flat();
|
|
2818
|
-
}, {
|
|
2819
|
-
key: 'getFlatHeaders',
|
|
2820
|
-
debug: () => {
|
|
2821
|
-
var _instance$options$deb9;
|
|
2822
|
-
|
|
2823
|
-
return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
|
|
2824
|
-
}
|
|
2825
|
-
}),
|
|
2826
|
-
getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
|
|
2827
|
-
return left.map(headerGroup => {
|
|
2828
|
-
return headerGroup.headers;
|
|
2829
|
-
}).flat();
|
|
2830
|
-
}, {
|
|
2831
|
-
key: 'getLeftFlatHeaders',
|
|
2832
|
-
debug: () => {
|
|
2833
|
-
var _instance$options$deb10;
|
|
2834
|
-
|
|
2835
|
-
return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
|
|
2836
|
-
}
|
|
2837
|
-
}),
|
|
2838
|
-
getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
|
|
2839
|
-
return left.map(headerGroup => {
|
|
2840
|
-
return headerGroup.headers;
|
|
2841
|
-
}).flat();
|
|
2842
|
-
}, {
|
|
2843
|
-
key: 'getCenterFlatHeaders',
|
|
2844
|
-
debug: () => {
|
|
2845
|
-
var _instance$options$deb11;
|
|
2846
|
-
|
|
2847
|
-
return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
|
|
2848
|
-
}
|
|
2849
|
-
}),
|
|
2850
|
-
getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
|
|
2851
|
-
return left.map(headerGroup => {
|
|
2852
|
-
return headerGroup.headers;
|
|
2853
|
-
}).flat();
|
|
2854
|
-
}, {
|
|
2855
|
-
key: 'getRightFlatHeaders',
|
|
2856
|
-
debug: () => {
|
|
2857
|
-
var _instance$options$deb12;
|
|
2858
|
-
|
|
2859
|
-
return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
|
|
2860
|
-
}
|
|
2861
|
-
}),
|
|
2862
|
-
// Leaf Headers
|
|
2863
|
-
getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
|
|
2864
|
-
return flatHeaders.filter(header => {
|
|
2865
|
-
var _header$subHeaders;
|
|
2866
|
-
|
|
2867
|
-
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
|
2868
|
-
});
|
|
2869
|
-
}, {
|
|
2870
|
-
key: 'getCenterLeafHeaders',
|
|
2871
|
-
debug: () => {
|
|
2872
|
-
var _instance$options$deb13;
|
|
2873
|
-
|
|
2874
|
-
return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
|
|
2875
|
-
}
|
|
2876
|
-
}),
|
|
2877
|
-
getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
|
|
2878
|
-
return flatHeaders.filter(header => {
|
|
2879
|
-
var _header$subHeaders2;
|
|
2880
|
-
|
|
2881
|
-
return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
|
|
2882
|
-
});
|
|
2883
|
-
}, {
|
|
2884
|
-
key: 'getLeftLeafHeaders',
|
|
2885
|
-
debug: () => {
|
|
2886
|
-
var _instance$options$deb14;
|
|
2887
|
-
|
|
2888
|
-
return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
|
|
2889
|
-
}
|
|
2890
|
-
}),
|
|
2891
|
-
getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
|
|
2892
|
-
return flatHeaders.filter(header => {
|
|
2893
|
-
var _header$subHeaders3;
|
|
2894
|
-
|
|
2895
|
-
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
|
2896
|
-
});
|
|
2727
|
+
return {
|
|
2728
|
+
_getAllVisibleCells: memo(() => [row.getAllCells().filter(cell => cell.column.getIsVisible()).map(d => d.id).join('_')], _ => {
|
|
2729
|
+
return row.getAllCells().filter(cell => cell.column.getIsVisible());
|
|
2897
2730
|
}, {
|
|
2898
|
-
key: '
|
|
2731
|
+
key: "development" === 'production' ,
|
|
2899
2732
|
debug: () => {
|
|
2900
|
-
var _instance$options$
|
|
2733
|
+
var _instance$options$deb;
|
|
2901
2734
|
|
|
2902
|
-
return (_instance$options$
|
|
2735
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
|
|
2903
2736
|
}
|
|
2904
2737
|
}),
|
|
2905
|
-
|
|
2906
|
-
|
|
2738
|
+
getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
|
|
2739
|
+
key: 'row.getVisibleCells',
|
|
2740
|
+
debug: () => {
|
|
2741
|
+
var _instance$options$deb2;
|
|
2907
2742
|
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2743
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
|
|
2744
|
+
}
|
|
2745
|
+
})
|
|
2746
|
+
};
|
|
2747
|
+
},
|
|
2748
|
+
createInstance: instance => {
|
|
2749
|
+
const makeVisibleColumnsMethod = (key, getColumns) => {
|
|
2750
|
+
return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
|
|
2751
|
+
return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
|
|
2911
2752
|
}, {
|
|
2912
|
-
key
|
|
2753
|
+
key,
|
|
2913
2754
|
debug: () => {
|
|
2914
|
-
var _instance$options$
|
|
2755
|
+
var _instance$options$deb3;
|
|
2915
2756
|
|
|
2916
|
-
return (_instance$options$
|
|
2757
|
+
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
2917
2758
|
}
|
|
2918
|
-
})
|
|
2919
|
-
|
|
2920
|
-
const header = [...instance.getFlatHeaders(), ...instance.getCenterFlatHeaders(), ...instance.getLeftFlatHeaders(), ...instance.getRightFlatHeaders()].find(d => d.id === id);
|
|
2759
|
+
});
|
|
2760
|
+
};
|
|
2921
2761
|
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2762
|
+
return {
|
|
2763
|
+
getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
|
|
2764
|
+
getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
|
|
2765
|
+
getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
|
|
2766
|
+
getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
|
|
2767
|
+
getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
|
|
2768
|
+
setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
|
|
2769
|
+
resetColumnVisibility: defaultState => {
|
|
2770
|
+
var _instance$initialStat;
|
|
2926
2771
|
|
|
2927
|
-
|
|
2928
|
-
|
|
2772
|
+
instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
|
|
2773
|
+
},
|
|
2774
|
+
toggleAllColumnsVisible: value => {
|
|
2775
|
+
var _value;
|
|
2776
|
+
|
|
2777
|
+
value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
|
|
2778
|
+
instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
|
|
2779
|
+
[column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
|
|
2780
|
+
}), {}));
|
|
2781
|
+
},
|
|
2782
|
+
getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
|
|
2783
|
+
getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
|
|
2784
|
+
getToggleAllColumnsVisibilityHandler: () => {
|
|
2785
|
+
return e => {
|
|
2786
|
+
var _target;
|
|
2929
2787
|
|
|
2930
|
-
|
|
2788
|
+
instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
|
|
2789
|
+
};
|
|
2931
2790
|
}
|
|
2932
2791
|
};
|
|
2933
2792
|
}
|
|
2934
2793
|
};
|
|
2935
|
-
function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
|
|
2936
|
-
var _headerGroups$0$heade, _headerGroups$;
|
|
2937
|
-
|
|
2938
|
-
// Find the max depth of the columns:
|
|
2939
|
-
// build the leaf column row
|
|
2940
|
-
// build each buffer row going up
|
|
2941
|
-
// placeholder for non-existent level
|
|
2942
|
-
// real column for existing level
|
|
2943
|
-
let maxDepth = 0;
|
|
2944
|
-
|
|
2945
|
-
const findMaxDepth = function (columns, depth) {
|
|
2946
|
-
if (depth === void 0) {
|
|
2947
|
-
depth = 1;
|
|
2948
|
-
}
|
|
2949
|
-
|
|
2950
|
-
maxDepth = Math.max(maxDepth, depth);
|
|
2951
|
-
columns.filter(column => column.getIsVisible()).forEach(column => {
|
|
2952
|
-
var _column$columns;
|
|
2953
|
-
|
|
2954
|
-
if ((_column$columns = column.columns) != null && _column$columns.length) {
|
|
2955
|
-
findMaxDepth(column.columns, depth + 1);
|
|
2956
|
-
}
|
|
2957
|
-
}, 0);
|
|
2958
|
-
};
|
|
2959
|
-
|
|
2960
|
-
findMaxDepth(allColumns);
|
|
2961
|
-
let headerGroups = [];
|
|
2962
|
-
|
|
2963
|
-
const createHeaderGroup = (headersToGroup, depth) => {
|
|
2964
|
-
// The header group we are creating
|
|
2965
|
-
const headerGroup = {
|
|
2966
|
-
depth,
|
|
2967
|
-
id: [headerFamily, "" + depth].filter(Boolean).join('_'),
|
|
2968
|
-
headers: []
|
|
2969
|
-
}; // The parent columns we're going to scan next
|
|
2970
|
-
|
|
2971
|
-
const pendingParentHeaders = []; // Scan each column for parents
|
|
2972
|
-
|
|
2973
|
-
headersToGroup.forEach(headerToGroup => {
|
|
2974
|
-
// What is the latest (last) parent column?
|
|
2975
|
-
const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
|
|
2976
|
-
const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
|
|
2977
|
-
let column;
|
|
2978
|
-
let isPlaceholder = false;
|
|
2979
|
-
|
|
2980
|
-
if (isLeafHeader && headerToGroup.column.parent) {
|
|
2981
|
-
// The parent header is new
|
|
2982
|
-
column = headerToGroup.column.parent;
|
|
2983
|
-
} else {
|
|
2984
|
-
// The parent header is repeated
|
|
2985
|
-
column = headerToGroup.column;
|
|
2986
|
-
isPlaceholder = true;
|
|
2987
|
-
}
|
|
2988
|
-
|
|
2989
|
-
if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
|
|
2990
|
-
// This column is repeated. Add it as a sub header to the next batch
|
|
2991
|
-
latestPendingParentHeader.subHeaders.push(headerToGroup);
|
|
2992
|
-
} else {
|
|
2993
|
-
// This is a new header. Let's create it
|
|
2994
|
-
const header = instance.createHeader(column, {
|
|
2995
|
-
id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
|
|
2996
|
-
isPlaceholder,
|
|
2997
|
-
placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
|
|
2998
|
-
depth,
|
|
2999
|
-
index: pendingParentHeaders.length
|
|
3000
|
-
}); // Add the headerToGroup as a subHeader of the new header
|
|
3001
|
-
|
|
3002
|
-
header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
|
|
3003
|
-
// in the next batch
|
|
3004
|
-
|
|
3005
|
-
pendingParentHeaders.push(header);
|
|
3006
|
-
}
|
|
3007
|
-
|
|
3008
|
-
headerGroup.headers.push(headerToGroup);
|
|
3009
|
-
headerToGroup.headerGroup = headerGroup;
|
|
3010
|
-
});
|
|
3011
|
-
headerGroups.push(headerGroup);
|
|
3012
|
-
|
|
3013
|
-
if (depth > 0) {
|
|
3014
|
-
createHeaderGroup(pendingParentHeaders, depth - 1);
|
|
3015
|
-
}
|
|
3016
|
-
};
|
|
3017
|
-
|
|
3018
|
-
const bottomHeaders = columnsToGroup.map((column, index) => instance.createHeader(column, {
|
|
3019
|
-
depth: maxDepth,
|
|
3020
|
-
index
|
|
3021
|
-
}));
|
|
3022
|
-
createHeaderGroup(bottomHeaders, maxDepth - 1);
|
|
3023
|
-
headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
|
|
3024
|
-
// return !headerGroup.headers.every(header => header.isPlaceholder)
|
|
3025
|
-
// })
|
|
3026
|
-
|
|
3027
|
-
const recurseHeadersForSpans = headers => {
|
|
3028
|
-
const filteredHeaders = headers.filter(header => header.column.getIsVisible());
|
|
3029
|
-
return filteredHeaders.map(header => {
|
|
3030
|
-
let colSpan = 0;
|
|
3031
|
-
let rowSpan = 0;
|
|
3032
|
-
let childRowSpans = [0];
|
|
3033
|
-
|
|
3034
|
-
if (header.subHeaders && header.subHeaders.length) {
|
|
3035
|
-
childRowSpans = [];
|
|
3036
|
-
recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
|
|
3037
|
-
let {
|
|
3038
|
-
colSpan: childColSpan,
|
|
3039
|
-
rowSpan: childRowSpan
|
|
3040
|
-
} = _ref;
|
|
3041
|
-
colSpan += childColSpan;
|
|
3042
|
-
childRowSpans.push(childRowSpan);
|
|
3043
|
-
});
|
|
3044
|
-
} else {
|
|
3045
|
-
colSpan = 1;
|
|
3046
|
-
}
|
|
3047
|
-
|
|
3048
|
-
const minChildRowSpan = Math.min(...childRowSpans);
|
|
3049
|
-
rowSpan = rowSpan + minChildRowSpan;
|
|
3050
|
-
header.colSpan = colSpan > 0 ? colSpan : undefined;
|
|
3051
|
-
header.rowSpan = rowSpan > 0 ? rowSpan : undefined;
|
|
3052
|
-
return {
|
|
3053
|
-
colSpan,
|
|
3054
|
-
rowSpan
|
|
3055
|
-
};
|
|
3056
|
-
});
|
|
3057
|
-
};
|
|
3058
2794
|
|
|
3059
|
-
|
|
3060
|
-
return headerGroups;
|
|
3061
|
-
}
|
|
2795
|
+
const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]; //
|
|
3062
2796
|
|
|
3063
|
-
// export type Batch = {
|
|
3064
|
-
// id: number
|
|
3065
|
-
// priority: keyof CoreBatches
|
|
3066
|
-
// tasks: (() => void)[]
|
|
3067
|
-
// schedule: (cb: () => void) => void
|
|
3068
|
-
// cancel: () => void
|
|
3069
|
-
// }
|
|
3070
|
-
// type CoreBatches = {
|
|
3071
|
-
// data: Batch[]
|
|
3072
|
-
// facets: Batch[]
|
|
3073
|
-
// }
|
|
3074
2797
|
function createTableInstance(options) {
|
|
3075
2798
|
var _options$initialState;
|
|
3076
2799
|
|
|
@@ -3079,7 +2802,7 @@
|
|
|
3079
2802
|
}
|
|
3080
2803
|
|
|
3081
2804
|
let instance = {
|
|
3082
|
-
_features:
|
|
2805
|
+
_features: features
|
|
3083
2806
|
};
|
|
3084
2807
|
|
|
3085
2808
|
const defaultOptions = instance._features.reduce((obj, feature) => {
|
|
@@ -3096,8 +2819,7 @@
|
|
|
3096
2819
|
};
|
|
3097
2820
|
};
|
|
3098
2821
|
|
|
3099
|
-
const coreInitialState = {
|
|
3100
|
-
};
|
|
2822
|
+
const coreInitialState = {};
|
|
3101
2823
|
let initialState = { ...coreInitialState,
|
|
3102
2824
|
...((_options$initialState = options.initialState) != null ? _options$initialState : {})
|
|
3103
2825
|
};
|
|
@@ -3110,16 +2832,8 @@
|
|
|
3110
2832
|
|
|
3111
2833
|
const queued = [];
|
|
3112
2834
|
let queuedTimeout = false;
|
|
3113
|
-
const
|
|
3114
|
-
|
|
3115
|
-
// startWork()
|
|
3116
|
-
// },
|
|
3117
|
-
// willUpdate: () => {
|
|
3118
|
-
// startWork()
|
|
3119
|
-
// },
|
|
3120
|
-
// destroy: () => {
|
|
3121
|
-
// stopWork()
|
|
3122
|
-
// },
|
|
2835
|
+
const coreInstance = {
|
|
2836
|
+
_features: features,
|
|
3123
2837
|
options: { ...defaultOptions,
|
|
3124
2838
|
...options
|
|
3125
2839
|
},
|
|
@@ -3165,29 +2879,134 @@
|
|
|
3165
2879
|
},
|
|
3166
2880
|
setState: updater => {
|
|
3167
2881
|
instance.options.onStateChange == null ? void 0 : instance.options.onStateChange(updater);
|
|
3168
|
-
}
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
// if (coreProgress < 1) {
|
|
3179
|
-
// return 'coreRowModel'
|
|
3180
|
-
// }
|
|
3181
|
-
// if (filtersProgress < 1) {
|
|
3182
|
-
// return 'filteredRowModel'
|
|
3183
|
-
// }
|
|
3184
|
-
// if (Object.values(facetProgress).some(d => d < 1)) {
|
|
3185
|
-
// return 'facetedRowModel'
|
|
3186
|
-
// }
|
|
3187
|
-
// },
|
|
2882
|
+
},
|
|
2883
|
+
_getRowId: (row, index, parent) => {
|
|
2884
|
+
var _instance$options$get;
|
|
2885
|
+
|
|
2886
|
+
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);
|
|
2887
|
+
},
|
|
2888
|
+
getCoreRowModel: () => {
|
|
2889
|
+
if (!instance._getCoreRowModel) {
|
|
2890
|
+
instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
|
|
2891
|
+
}
|
|
3188
2892
|
|
|
2893
|
+
return instance._getCoreRowModel();
|
|
2894
|
+
},
|
|
2895
|
+
// The final calls start at the bottom of the model,
|
|
2896
|
+
// expanded rows, which then work their way up
|
|
2897
|
+
getRowModel: () => {
|
|
2898
|
+
return instance.getPaginationRowModel();
|
|
2899
|
+
},
|
|
2900
|
+
getRow: id => {
|
|
2901
|
+
const row = instance.getRowModel().rowsById[id];
|
|
2902
|
+
|
|
2903
|
+
if (!row) {
|
|
2904
|
+
{
|
|
2905
|
+
throw new Error("getRow expected an ID, but got " + id);
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
|
|
2909
|
+
return row;
|
|
2910
|
+
},
|
|
2911
|
+
_getDefaultColumnDef: memo(() => [instance.options.defaultColumn], defaultColumn => {
|
|
2912
|
+
var _defaultColumn;
|
|
2913
|
+
|
|
2914
|
+
defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
|
|
2915
|
+
return {
|
|
2916
|
+
header: props => props.header.column.id,
|
|
2917
|
+
footer: props => props.header.column.id,
|
|
2918
|
+
cell: props => {
|
|
2919
|
+
var _props$getValue$toStr, _props$getValue$toStr2, _props$getValue;
|
|
2920
|
+
|
|
2921
|
+
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;
|
|
2922
|
+
},
|
|
2923
|
+
...instance._features.reduce((obj, feature) => {
|
|
2924
|
+
return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
|
|
2925
|
+
}, {}),
|
|
2926
|
+
...defaultColumn
|
|
2927
|
+
};
|
|
2928
|
+
}, {
|
|
2929
|
+
debug: () => {
|
|
2930
|
+
var _instance$options$deb;
|
|
2931
|
+
|
|
2932
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
|
|
2933
|
+
},
|
|
2934
|
+
key: 'getDefaultColumnDef'
|
|
2935
|
+
}),
|
|
2936
|
+
_getColumnDefs: () => instance.options.columns,
|
|
2937
|
+
getAllColumns: memo(() => [instance._getColumnDefs()], columnDefs => {
|
|
2938
|
+
const recurseColumns = function (columnDefs, parent, depth) {
|
|
2939
|
+
if (depth === void 0) {
|
|
2940
|
+
depth = 0;
|
|
2941
|
+
}
|
|
2942
|
+
|
|
2943
|
+
return columnDefs.map(columnDef => {
|
|
2944
|
+
const column = createColumn(instance, columnDef, depth, parent);
|
|
2945
|
+
column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
|
|
2946
|
+
return column;
|
|
2947
|
+
});
|
|
2948
|
+
};
|
|
2949
|
+
|
|
2950
|
+
return recurseColumns(columnDefs);
|
|
2951
|
+
}, {
|
|
2952
|
+
key: 'getAllColumns',
|
|
2953
|
+
debug: () => {
|
|
2954
|
+
var _instance$options$deb2;
|
|
2955
|
+
|
|
2956
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
|
|
2957
|
+
}
|
|
2958
|
+
}),
|
|
2959
|
+
getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
|
|
2960
|
+
return allColumns.flatMap(column => {
|
|
2961
|
+
return column.getFlatColumns();
|
|
2962
|
+
});
|
|
2963
|
+
}, {
|
|
2964
|
+
key: 'getAllFlatColumns',
|
|
2965
|
+
debug: () => {
|
|
2966
|
+
var _instance$options$deb3;
|
|
2967
|
+
|
|
2968
|
+
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
2969
|
+
}
|
|
2970
|
+
}),
|
|
2971
|
+
_getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
|
|
2972
|
+
return flatColumns.reduce((acc, column) => {
|
|
2973
|
+
acc[column.id] = column;
|
|
2974
|
+
return acc;
|
|
2975
|
+
}, {});
|
|
2976
|
+
}, {
|
|
2977
|
+
key: 'getAllFlatColumnsById',
|
|
2978
|
+
debug: () => {
|
|
2979
|
+
var _instance$options$deb4;
|
|
2980
|
+
|
|
2981
|
+
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
|
|
2982
|
+
}
|
|
2983
|
+
}),
|
|
2984
|
+
getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
|
|
2985
|
+
let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
|
|
2986
|
+
return orderColumns(leafColumns);
|
|
2987
|
+
}, {
|
|
2988
|
+
key: 'getAllLeafColumns',
|
|
2989
|
+
debug: () => {
|
|
2990
|
+
var _instance$options$deb5;
|
|
2991
|
+
|
|
2992
|
+
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
|
|
2993
|
+
}
|
|
2994
|
+
}),
|
|
2995
|
+
getColumn: columnId => {
|
|
2996
|
+
const column = instance._getAllFlatColumnsById()[columnId];
|
|
2997
|
+
|
|
2998
|
+
if (!column) {
|
|
2999
|
+
{
|
|
3000
|
+
console.warn("[Table] Column with id " + columnId + " does not exist.");
|
|
3001
|
+
}
|
|
3002
|
+
|
|
3003
|
+
throw new Error();
|
|
3004
|
+
}
|
|
3005
|
+
|
|
3006
|
+
return column;
|
|
3007
|
+
}
|
|
3189
3008
|
};
|
|
3190
|
-
|
|
3009
|
+
Object.assign(instance, coreInstance);
|
|
3191
3010
|
|
|
3192
3011
|
instance._features.forEach(feature => {
|
|
3193
3012
|
return Object.assign(instance, feature.createInstance == null ? void 0 : feature.createInstance(instance));
|
|
@@ -3252,6 +3071,86 @@
|
|
|
3252
3071
|
return table;
|
|
3253
3072
|
}
|
|
3254
3073
|
|
|
3074
|
+
function createCell(instance, row, column, columnId) {
|
|
3075
|
+
const cell = {
|
|
3076
|
+
id: row.id + "_" + column.id,
|
|
3077
|
+
row,
|
|
3078
|
+
column,
|
|
3079
|
+
getValue: () => row.getValue(columnId),
|
|
3080
|
+
renderCell: () => column.columnDef.cell ? instance._render(column.columnDef.cell, {
|
|
3081
|
+
instance,
|
|
3082
|
+
column,
|
|
3083
|
+
row,
|
|
3084
|
+
cell: cell,
|
|
3085
|
+
getValue: cell.getValue
|
|
3086
|
+
}) : null
|
|
3087
|
+
};
|
|
3088
|
+
|
|
3089
|
+
instance._features.forEach(feature => {
|
|
3090
|
+
Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
|
|
3091
|
+
}, {});
|
|
3092
|
+
|
|
3093
|
+
return cell;
|
|
3094
|
+
}
|
|
3095
|
+
|
|
3096
|
+
const createRow = (instance, id, original, rowIndex, depth, subRows) => {
|
|
3097
|
+
let row = {
|
|
3098
|
+
id,
|
|
3099
|
+
index: rowIndex,
|
|
3100
|
+
original,
|
|
3101
|
+
depth,
|
|
3102
|
+
_valuesCache: {},
|
|
3103
|
+
getValue: columnId => {
|
|
3104
|
+
if (row._valuesCache.hasOwnProperty(columnId)) {
|
|
3105
|
+
return row._valuesCache[columnId];
|
|
3106
|
+
}
|
|
3107
|
+
|
|
3108
|
+
const column = instance.getColumn(columnId);
|
|
3109
|
+
|
|
3110
|
+
if (!column.accessorFn) {
|
|
3111
|
+
return undefined;
|
|
3112
|
+
}
|
|
3113
|
+
|
|
3114
|
+
row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
|
3115
|
+
return row._valuesCache[columnId];
|
|
3116
|
+
},
|
|
3117
|
+
subRows: subRows != null ? subRows : [],
|
|
3118
|
+
getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
|
|
3119
|
+
getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
|
|
3120
|
+
return leafColumns.map(column => {
|
|
3121
|
+
return createCell(instance, row, column, column.id);
|
|
3122
|
+
});
|
|
3123
|
+
}, {
|
|
3124
|
+
key: 'row.getAllCells',
|
|
3125
|
+
debug: () => {
|
|
3126
|
+
var _instance$options$deb;
|
|
3127
|
+
|
|
3128
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
|
|
3129
|
+
}
|
|
3130
|
+
}),
|
|
3131
|
+
_getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
|
|
3132
|
+
return allCells.reduce((acc, cell) => {
|
|
3133
|
+
acc[cell.column.id] = cell;
|
|
3134
|
+
return acc;
|
|
3135
|
+
}, {});
|
|
3136
|
+
}, {
|
|
3137
|
+
key: "development" === 'production' ,
|
|
3138
|
+
debug: () => {
|
|
3139
|
+
var _instance$options$deb2;
|
|
3140
|
+
|
|
3141
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
|
|
3142
|
+
}
|
|
3143
|
+
})
|
|
3144
|
+
};
|
|
3145
|
+
|
|
3146
|
+
for (let i = 0; i < instance._features.length; i++) {
|
|
3147
|
+
const feature = instance._features[i];
|
|
3148
|
+
Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
|
|
3149
|
+
}
|
|
3150
|
+
|
|
3151
|
+
return row;
|
|
3152
|
+
};
|
|
3153
|
+
|
|
3255
3154
|
function getCoreRowModel() {
|
|
3256
3155
|
return instance => memo(() => [instance.options.data], data => {
|
|
3257
3156
|
const rowModel = {
|
|
@@ -3279,7 +3178,7 @@
|
|
|
3279
3178
|
// }
|
|
3280
3179
|
// Make the row
|
|
3281
3180
|
|
|
3282
|
-
row =
|
|
3181
|
+
row = createRow(instance, instance._getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
|
|
3283
3182
|
|
|
3284
3183
|
rowModel.flatRows.push(row); // Also keep track of every row by its ID
|
|
3285
3184
|
|
|
@@ -3342,7 +3241,7 @@
|
|
|
3342
3241
|
row = rowsToFilter[i];
|
|
3343
3242
|
|
|
3344
3243
|
if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
|
|
3345
|
-
newRow =
|
|
3244
|
+
newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3346
3245
|
newRow.columnFilters = row.columnFilters;
|
|
3347
3246
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3348
3247
|
|
|
@@ -3392,7 +3291,7 @@
|
|
|
3392
3291
|
var _row$subRows2;
|
|
3393
3292
|
|
|
3394
3293
|
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
|
|
3395
|
-
newRow =
|
|
3294
|
+
newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3396
3295
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3397
3296
|
row = newRow;
|
|
3398
3297
|
}
|
|
@@ -3759,7 +3658,7 @@
|
|
|
3759
3658
|
const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
|
|
3760
3659
|
|
|
3761
3660
|
const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
|
|
3762
|
-
const row =
|
|
3661
|
+
const row = createRow(instance, id, undefined, index, depth);
|
|
3763
3662
|
Object.assign(row, {
|
|
3764
3663
|
groupingColumnId: columnId,
|
|
3765
3664
|
groupingValue,
|
|
@@ -3768,17 +3667,17 @@
|
|
|
3768
3667
|
getValue: columnId => {
|
|
3769
3668
|
// Don't aggregate columns that are in the grouping
|
|
3770
3669
|
if (existingGrouping.includes(columnId)) {
|
|
3771
|
-
if (row.
|
|
3772
|
-
return row.
|
|
3670
|
+
if (row._valuesCache.hasOwnProperty(columnId)) {
|
|
3671
|
+
return row._valuesCache[columnId];
|
|
3773
3672
|
}
|
|
3774
3673
|
|
|
3775
3674
|
if (groupedRows[0]) {
|
|
3776
3675
|
var _groupedRows$0$getVal;
|
|
3777
3676
|
|
|
3778
|
-
row.
|
|
3677
|
+
row._valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
|
|
3779
3678
|
}
|
|
3780
3679
|
|
|
3781
|
-
return row.
|
|
3680
|
+
return row._valuesCache[columnId];
|
|
3782
3681
|
}
|
|
3783
3682
|
|
|
3784
3683
|
if (row.groupingValuesCache.hasOwnProperty(columnId)) {
|
|
@@ -4021,6 +3920,8 @@
|
|
|
4021
3920
|
exports.Visibility = Visibility;
|
|
4022
3921
|
exports.aggregationFns = aggregationFns;
|
|
4023
3922
|
exports.buildHeaderGroups = buildHeaderGroups;
|
|
3923
|
+
exports.createColumn = createColumn;
|
|
3924
|
+
exports.createRow = createRow;
|
|
4024
3925
|
exports.createTable = createTable;
|
|
4025
3926
|
exports.createTableFactory = createTableFactory;
|
|
4026
3927
|
exports.createTableInstance = createTableInstance;
|