@tanstack/react-table 8.0.0-alpha.80 → 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.
@@ -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
- const Columns = {
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
- getDefaultColumn: memo(() => [instance.options.defaultColumn], defaultColumn => {
129
- var _defaultColumn;
130
-
131
- defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
132
- return {
133
- header: props => props.header.column.id,
134
- footer: props => props.header.column.id,
135
- cell: props => {
136
- var _props$getValue$toStr, _props$getValue$toStr2, _props$getValue;
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.debugColumns;
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
- if (!id) {
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
- let column = { ...defaultColumn,
174
- ...columnDef,
175
- id: "" + id,
176
- accessorFn,
177
- parent: parent,
178
- depth,
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 columnDefs.map(columnDef => {
225
- const column = instance.createColumn(columnDef, depth, parent);
226
- column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
227
- return column;
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
- return recurseColumns(columnDefs);
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: 'getAllColumns',
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.debugColumns;
295
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
238
296
  }
239
297
  }),
240
- getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
241
- return allColumns.flatMap(column => {
242
- return column.getFlatColumns();
243
- });
298
+ // Footer Groups
299
+ getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
300
+ return [...headerGroups].reverse();
244
301
  }, {
245
- key: 'getAllFlatColumns',
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.debugColumns;
306
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
250
307
  }
251
308
  }),
252
- getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
253
- return flatColumns.reduce((acc, column) => {
254
- acc[column.id] = column;
255
- return acc;
256
- }, {});
309
+ getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
310
+ return [...headerGroups].reverse();
257
311
  }, {
258
- key: 'getAllFlatColumnsById',
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.debugColumns;
316
+ return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
263
317
  }
264
318
  }),
265
- getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
266
- let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
267
- return orderColumns(leafColumns);
319
+ getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
320
+ return [...headerGroups].reverse();
268
321
  }, {
269
- key: 'getAllLeafColumns',
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.debugColumns;
326
+ return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
274
327
  }
275
328
  }),
276
- getColumn: columnId => {
277
- const column = instance.getAllFlatColumnsById()[columnId];
278
-
279
- if (!column) {
280
- {
281
- console.warn("[Table] Column with id " + columnId + " does not exist.");
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
- throw new Error();
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
- return column;
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
- return row;
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
- return instance._getCoreRowModel();
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
- return row;
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: 'row.getAllCells',
396
+ key: 'getCenterLeafHeaders',
377
397
  debug: () => {
378
- var _instance$options$deb;
398
+ var _instance$options$deb13;
379
399
 
380
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
400
+ return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
381
401
  }
382
402
  }),
383
- getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
384
- return allCells.reduce((acc, cell) => {
385
- acc[cell.columnId] = cell;
386
- return acc;
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: "development" === 'production' ,
410
+ key: 'getLeftLeafHeaders',
390
411
  debug: () => {
391
- var _instance$options$deb2;
412
+ var _instance$options$deb14;
392
413
 
393
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
414
+ return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
394
415
  }
395
- })
396
- };
397
- },
398
- createInstance: instance => {
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
- return cell;
422
- },
423
- getCell: (rowId, columnId) => {
424
- const row = instance.getRow(rowId);
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
- if (!row) {
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
- const cell = row.getAllCellsByColumnId()[columnId];
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
- if (!cell) {
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
- getDefaultColumn: () => {
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$minSize, _ref, _column$maxSize;
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$minSize = column.minSize) != null ? _column$minSize : defaultColumnSizing.minSize, (_ref = columnSize != null ? columnSize : column.size) != null ? _ref : defaultColumnSizing.size), (_column$maxSize = column.maxSize) != null ? _column$maxSize : defaultColumnSizing.maxSize);
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$enableResizin, _instance$options$ena;
639
+ var _column$columnDef$ena, _instance$options$ena;
510
640
 
511
- return ((_column$enableResizin = column.enableResizing) != null ? _column$enableResizin : true) && ((_instance$options$ena = instance.options.enableColumnResizing) != null ? _instance$options$ena : true);
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
- getDefaultColumn: () => {
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.getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreRowM2.getValue();
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$enableColumnF, _instance$options$ena, _instance$options$ena2;
1162
+ var _column$columnDef$ena, _instance$options$ena, _instance$options$ena2;
1029
1163
 
1030
- return ((_column$enableColumnF = column.enableColumnFilter) != null ? _column$enableColumnF : 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;
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$enableGlobalF, _instance$options$ena3, _instance$options$ena4, _instance$options$get;
1167
+ var _column$columnDef$ena2, _instance$options$ena3, _instance$options$ena4, _instance$options$get;
1034
1168
 
1035
- return ((_column$enableGlobalF = column.enableGlobalFilter) != null ? _column$enableGlobalF : 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;
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: () => {
@@ -1111,7 +1245,8 @@
1111
1245
  },
1112
1246
  createRow: (row, instance) => {
1113
1247
  return {
1114
- columnFilterMap: {},
1248
+ columnFilters: {},
1249
+ columnFiltersMeta: {},
1115
1250
  subRowsByFacetId: {}
1116
1251
  };
1117
1252
  },
@@ -1309,7 +1444,7 @@
1309
1444
 
1310
1445
  //
1311
1446
  const Grouping = {
1312
- getDefaultColumn: () => {
1447
+ getDefaultColumnDef: () => {
1313
1448
  return {
1314
1449
  aggregationFn: 'auto'
1315
1450
  };
@@ -1339,9 +1474,9 @@
1339
1474
  });
1340
1475
  },
1341
1476
  getCanGroup: () => {
1342
- var _ref, _ref2, _ref3, _column$enableGroupin;
1477
+ var _ref, _ref2, _ref3, _column$columnDef$ena;
1343
1478
 
1344
- return (_ref = (_ref2 = (_ref3 = (_column$enableGroupin = column.enableGrouping) != null ? _column$enableGroupin : true) != null ? _ref3 : instance.options.enableGrouping) != null ? _ref2 : true) != null ? _ref : !!column.accessorFn;
1479
+ 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;
1345
1480
  },
1346
1481
  getIsGrouped: () => {
1347
1482
  var _instance$getState$gr;
@@ -1425,9 +1560,9 @@
1425
1560
  return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
1426
1561
  },
1427
1562
  renderAggregatedCell: () => {
1428
- var _column$aggregatedCel;
1563
+ var _column$columnDef$agg;
1429
1564
 
1430
- const template = (_column$aggregatedCel = column.aggregatedCell) != null ? _column$aggregatedCel : column.cell;
1565
+ const template = (_column$columnDef$agg = column.columnDef.aggregatedCell) != null ? _column$columnDef$agg : column.columnDef.cell;
1431
1566
  return template ? instance._render(template, {
1432
1567
  instance,
1433
1568
  column,
@@ -1734,9 +1869,9 @@
1734
1869
  getCanPin: () => {
1735
1870
  const leafColumns = column.getLeafColumns();
1736
1871
  return leafColumns.some(d => {
1737
- var _d$enablePinning, _instance$options$ena;
1872
+ var _d$columnDef$enablePi, _instance$options$ena;
1738
1873
 
1739
- return ((_d$enablePinning = d.enablePinning) != null ? _d$enablePinning : true) && ((_instance$options$ena = instance.options.enablePinning) != null ? _instance$options$ena : true);
1874
+ return ((_d$columnDef$enablePi = d.columnDef.enablePinning) != null ? _d$columnDef$enablePi : true) && ((_instance$options$ena = instance.options.enablePinning) != null ? _instance$options$ena : true);
1740
1875
  });
1741
1876
  },
1742
1877
  getIsPinned: () => {
@@ -1761,7 +1896,7 @@
1761
1896
  return {
1762
1897
  getCenterVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allCells, left, right) => {
1763
1898
  const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
1764
- return allCells.filter(d => !leftAndRight.includes(d.columnId));
1899
+ return allCells.filter(d => !leftAndRight.includes(d.column.id));
1765
1900
  }, {
1766
1901
  key: "development" === 'production' ,
1767
1902
  debug: () => {
@@ -1771,7 +1906,7 @@
1771
1906
  }
1772
1907
  }),
1773
1908
  getLeftVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left,,], (allCells, left) => {
1774
- const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.columnId === columnId)).filter(Boolean).map(d => ({ ...d,
1909
+ const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
1775
1910
  position: 'left'
1776
1911
  }));
1777
1912
  return cells;
@@ -1784,7 +1919,7 @@
1784
1919
  }
1785
1920
  }),
1786
1921
  getRightVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.right], (allCells, right) => {
1787
- const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.columnId === columnId)).filter(Boolean).map(d => ({ ...d,
1922
+ const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
1788
1923
  position: 'left'
1789
1924
  }));
1790
1925
  return cells;
@@ -1806,12 +1941,18 @@
1806
1941
 
1807
1942
  return instance.setColumnPinning(defaultState ? getDefaultPinningState() : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.columnPinning) != null ? _instance$initialStat : getDefaultPinningState());
1808
1943
  },
1809
- getIsSomeColumnsPinned: () => {
1810
- const {
1811
- left,
1812
- right
1813
- } = instance.getState().columnPinning;
1814
- return Boolean((left == null ? void 0 : left.length) || (right == null ? void 0 : right.length));
1944
+ getIsSomeColumnsPinned: position => {
1945
+ var _pinningState$positio;
1946
+
1947
+ const pinningState = instance.getState().columnPinning;
1948
+
1949
+ if (!position) {
1950
+ var _pinningState$left, _pinningState$right;
1951
+
1952
+ return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
1953
+ }
1954
+
1955
+ return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
1815
1956
  },
1816
1957
  getLeftLeafColumns: memo(() => [instance.getAllLeafColumns(), instance.getState().columnPinning.left], (allColumns, left) => {
1817
1958
  return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
@@ -2337,7 +2478,7 @@
2337
2478
  ...state
2338
2479
  };
2339
2480
  },
2340
- getDefaultColumn: () => {
2481
+ getDefaultColumnDef: () => {
2341
2482
  return {
2342
2483
  sortingFn: 'auto'
2343
2484
  };
@@ -2353,7 +2494,7 @@
2353
2494
  createColumn: (column, instance) => {
2354
2495
  return {
2355
2496
  getAutoSortingFn: () => {
2356
- const firstRows = instance.getFilteredRowModel().flatRows.slice(100);
2497
+ const firstRows = instance.getFilteredRowModel().flatRows.slice(10);
2357
2498
  let isString = false;
2358
2499
 
2359
2500
  for (const row of firstRows) {
@@ -2397,7 +2538,7 @@
2397
2538
  throw new Error();
2398
2539
  }
2399
2540
 
2400
- return isFunction(column.sortingFn) ? column.sortingFn : column.sortingFn === 'auto' ? column.getAutoSortingFn() : (_ref = userSortingFn == null ? void 0 : userSortingFn[column.sortingFn]) != null ? _ref : sortingFns[column.sortingFn];
2541
+ 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];
2401
2542
  },
2402
2543
  toggleSorting: (desc, multi) => {
2403
2544
  // if (column.columns.length) {
@@ -2409,7 +2550,7 @@
2409
2550
  // return
2410
2551
  // }
2411
2552
  instance.setSorting(old => {
2412
- var _ref2, _column$sortDescFirst, _instance$options$ena, _instance$options$ena2;
2553
+ var _ref2, _column$columnDef$sor, _instance$options$ena, _instance$options$ena2;
2413
2554
 
2414
2555
  // Find any existing sorting for this column
2415
2556
  const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
@@ -2436,7 +2577,7 @@
2436
2577
  }
2437
2578
  }
2438
2579
 
2439
- const sortDescFirst = (_ref2 = (_column$sortDescFirst = column.sortDescFirst) != null ? _column$sortDescFirst : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc'; // Handle toggle states that will remove the sorting
2580
+ 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
2440
2581
 
2441
2582
  if (sortAction === 'toggle' && ( // Must be toggling
2442
2583
  (_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
@@ -2480,14 +2621,14 @@
2480
2621
  });
2481
2622
  },
2482
2623
  getCanSort: () => {
2483
- var _column$enableSorting, _instance$options$ena3;
2624
+ var _column$columnDef$ena, _instance$options$ena3;
2484
2625
 
2485
- return ((_column$enableSorting = column.enableSorting) != null ? _column$enableSorting : true) && ((_instance$options$ena3 = instance.options.enableSorting) != null ? _instance$options$ena3 : true) && !!column.accessorFn;
2626
+ 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;
2486
2627
  },
2487
2628
  getCanMultiSort: () => {
2488
- var _ref3, _column$enableMultiSo;
2629
+ var _ref3, _column$columnDef$ena2;
2489
2630
 
2490
- return (_ref3 = (_column$enableMultiSo = column.enableMultiSort) != null ? _column$enableMultiSo : instance.options.enableMultiSort) != null ? _ref3 : !!column.accessorFn;
2631
+ return (_ref3 = (_column$columnDef$ena2 = column.columnDef.enableMultiSort) != null ? _column$columnDef$ena2 : instance.options.enableMultiSort) != null ? _ref3 : !!column.accessorFn;
2491
2632
  },
2492
2633
  getIsSorted: () => {
2493
2634
  var _instance$getState$so;
@@ -2551,7 +2692,7 @@
2551
2692
  onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
2552
2693
  };
2553
2694
  },
2554
- getDefaultColumn: () => {
2695
+ getDefaultColumnDef: () => {
2555
2696
  return {
2556
2697
  defaultIsVisible: true
2557
2698
  };
@@ -2571,9 +2712,9 @@
2571
2712
  return (_instance$getState$co = (_instance$getState$co2 = instance.getState().columnVisibility) == null ? void 0 : _instance$getState$co2[column.id]) != null ? _instance$getState$co : true;
2572
2713
  },
2573
2714
  getCanHide: () => {
2574
- var _column$enableHiding, _instance$options$ena;
2715
+ var _column$columnDef$ena, _instance$options$ena;
2575
2716
 
2576
- return ((_column$enableHiding = column.enableHiding) != null ? _column$enableHiding : true) && ((_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : true);
2717
+ return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : true);
2577
2718
  },
2578
2719
  getToggleVisibilityHandler: () => {
2579
2720
  return e => {
@@ -2589,475 +2730,70 @@
2589
2730
  }, {
2590
2731
  key: "development" === 'production' ,
2591
2732
  debug: () => {
2592
- var _instance$options$deb;
2593
-
2594
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
2595
- }
2596
- }),
2597
- getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
2598
- key: 'row.getVisibleCells',
2599
- debug: () => {
2600
- var _instance$options$deb2;
2601
-
2602
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
2603
- }
2604
- })
2605
- };
2606
- },
2607
- createInstance: instance => {
2608
- const makeVisibleColumnsMethod = (key, getColumns) => {
2609
- return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
2610
- return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
2611
- }, {
2612
- key,
2613
- debug: () => {
2614
- var _instance$options$deb3;
2615
-
2616
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2617
- }
2618
- });
2619
- };
2620
-
2621
- return {
2622
- getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
2623
- getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
2624
- getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
2625
- getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
2626
- getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
2627
- setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
2628
- resetColumnVisibility: defaultState => {
2629
- var _instance$initialStat;
2630
-
2631
- instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
2632
- },
2633
- toggleAllColumnsVisible: value => {
2634
- var _value;
2635
-
2636
- value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
2637
- instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
2638
- [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
2639
- }), {}));
2640
- },
2641
- getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
2642
- getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
2643
- getToggleAllColumnsVisibilityHandler: () => {
2644
- return e => {
2645
- var _target;
2646
-
2647
- instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
2648
- };
2649
- }
2650
- };
2651
- }
2652
- };
2653
-
2654
- //
2655
- const Headers = {
2656
- createInstance: instance => {
2657
- return {
2658
- createHeader: (column, options) => {
2659
- var _options$id;
2660
-
2661
- const id = (_options$id = options.id) != null ? _options$id : column.id;
2662
- let header = {
2663
- id,
2664
- column,
2665
- index: options.index,
2666
- isPlaceholder: options.isPlaceholder,
2667
- placeholderId: options.placeholderId,
2668
- depth: options.depth,
2669
- subHeaders: [],
2670
- colSpan: 0,
2671
- rowSpan: 0,
2672
- headerGroup: null,
2673
- getLeafHeaders: () => {
2674
- const leafHeaders = [];
2675
-
2676
- const recurseHeader = h => {
2677
- if (h.subHeaders && h.subHeaders.length) {
2678
- h.subHeaders.map(recurseHeader);
2679
- }
2680
-
2681
- leafHeaders.push(h);
2682
- };
2683
-
2684
- recurseHeader(header);
2685
- return leafHeaders;
2686
- },
2687
- renderHeader: () => column.header ? instance._render(column.header, {
2688
- instance,
2689
- header: header,
2690
- column
2691
- }) : null,
2692
- renderFooter: () => column.footer ? instance._render(column.footer, {
2693
- instance,
2694
- header: header,
2695
- column
2696
- }) : null
2697
- };
2698
-
2699
- instance._features.forEach(feature => {
2700
- Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
2701
- });
2702
-
2703
- return header;
2704
- },
2705
- // Header Groups
2706
- getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2707
- var _left$map$filter, _right$map$filter;
2708
-
2709
- const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
2710
- const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
2711
- const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2712
- const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
2713
- return headerGroups;
2714
- }, {
2715
- key: 'getHeaderGroups',
2716
- debug: () => {
2717
- var _instance$options$deb;
2718
-
2719
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
2720
- }
2721
- }),
2722
- getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2723
- leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2724
- return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
2725
- }, {
2726
- key: 'getCenterHeaderGroups',
2727
- debug: () => {
2728
- var _instance$options$deb2;
2729
-
2730
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
2731
- }
2732
- }),
2733
- getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
2734
- var _left$map$filter2;
2735
-
2736
- const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
2737
- return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
2738
- }, {
2739
- key: 'getLeftHeaderGroups',
2740
- debug: () => {
2741
- var _instance$options$deb3;
2742
-
2743
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
2744
- }
2745
- }),
2746
- getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
2747
- var _right$map$filter2;
2748
-
2749
- const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
2750
- return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
2751
- }, {
2752
- key: 'getRightHeaderGroups',
2753
- debug: () => {
2754
- var _instance$options$deb4;
2755
-
2756
- return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
2757
- }
2758
- }),
2759
- // Footer Groups
2760
- getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
2761
- return [...headerGroups].reverse();
2762
- }, {
2763
- key: 'getFooterGroups',
2764
- debug: () => {
2765
- var _instance$options$deb5;
2766
-
2767
- return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
2768
- }
2769
- }),
2770
- getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
2771
- return [...headerGroups].reverse();
2772
- }, {
2773
- key: 'getLeftFooterGroups',
2774
- debug: () => {
2775
- var _instance$options$deb6;
2776
-
2777
- return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
2778
- }
2779
- }),
2780
- getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
2781
- return [...headerGroups].reverse();
2782
- }, {
2783
- key: 'getCenterFooterGroups',
2784
- debug: () => {
2785
- var _instance$options$deb7;
2786
-
2787
- return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
2788
- }
2789
- }),
2790
- getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
2791
- return [...headerGroups].reverse();
2792
- }, {
2793
- key: 'getRightFooterGroups',
2794
- debug: () => {
2795
- var _instance$options$deb8;
2796
-
2797
- return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
2798
- }
2799
- }),
2800
- // Flat Headers
2801
- getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
2802
- return headerGroups.map(headerGroup => {
2803
- return headerGroup.headers;
2804
- }).flat();
2805
- }, {
2806
- key: 'getFlatHeaders',
2807
- debug: () => {
2808
- var _instance$options$deb9;
2809
-
2810
- return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
2811
- }
2812
- }),
2813
- getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
2814
- return left.map(headerGroup => {
2815
- return headerGroup.headers;
2816
- }).flat();
2817
- }, {
2818
- key: 'getLeftFlatHeaders',
2819
- debug: () => {
2820
- var _instance$options$deb10;
2821
-
2822
- return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
2823
- }
2824
- }),
2825
- getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
2826
- return left.map(headerGroup => {
2827
- return headerGroup.headers;
2828
- }).flat();
2829
- }, {
2830
- key: 'getCenterFlatHeaders',
2831
- debug: () => {
2832
- var _instance$options$deb11;
2833
-
2834
- return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
2835
- }
2836
- }),
2837
- getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
2838
- return left.map(headerGroup => {
2839
- return headerGroup.headers;
2840
- }).flat();
2841
- }, {
2842
- key: 'getRightFlatHeaders',
2843
- debug: () => {
2844
- var _instance$options$deb12;
2845
-
2846
- return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
2847
- }
2848
- }),
2849
- // Leaf Headers
2850
- getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
2851
- return flatHeaders.filter(header => {
2852
- var _header$subHeaders;
2853
-
2854
- return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
2855
- });
2856
- }, {
2857
- key: 'getCenterLeafHeaders',
2858
- debug: () => {
2859
- var _instance$options$deb13;
2860
-
2861
- return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
2862
- }
2863
- }),
2864
- getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
2865
- return flatHeaders.filter(header => {
2866
- var _header$subHeaders2;
2867
-
2868
- return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
2869
- });
2870
- }, {
2871
- key: 'getLeftLeafHeaders',
2872
- debug: () => {
2873
- var _instance$options$deb14;
2874
-
2875
- return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
2876
- }
2877
- }),
2878
- getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
2879
- return flatHeaders.filter(header => {
2880
- var _header$subHeaders3;
2881
-
2882
- return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
2883
- });
2884
- }, {
2885
- key: 'getRightLeafHeaders',
2886
- debug: () => {
2887
- var _instance$options$deb15;
2733
+ var _instance$options$deb;
2888
2734
 
2889
- return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
2735
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
2890
2736
  }
2891
2737
  }),
2892
- getLeafHeaders: memo(() => [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()], (left, center, right) => {
2893
- var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
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;
2894
2742
 
2895
- 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 => {
2896
- return header.getLeafHeaders();
2897
- }).flat();
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());
2898
2752
  }, {
2899
- key: 'getLeafHeaders',
2753
+ key,
2900
2754
  debug: () => {
2901
- var _instance$options$deb16;
2755
+ var _instance$options$deb3;
2902
2756
 
2903
- return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
2757
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2904
2758
  }
2905
- }),
2906
- getHeader: id => {
2907
- const header = [...instance.getFlatHeaders(), ...instance.getCenterFlatHeaders(), ...instance.getLeftFlatHeaders(), ...instance.getRightFlatHeaders()].find(d => d.id === id);
2759
+ });
2760
+ };
2908
2761
 
2909
- if (!header) {
2910
- {
2911
- console.warn("Could not find header with id: " + id);
2912
- }
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;
2913
2771
 
2914
- throw new Error();
2915
- }
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;
2916
2787
 
2917
- return header;
2788
+ instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
2789
+ };
2918
2790
  }
2919
2791
  };
2920
2792
  }
2921
2793
  };
2922
- function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
2923
- var _headerGroups$0$heade, _headerGroups$;
2924
-
2925
- // Find the max depth of the columns:
2926
- // build the leaf column row
2927
- // build each buffer row going up
2928
- // placeholder for non-existent level
2929
- // real column for existing level
2930
- let maxDepth = 0;
2931
-
2932
- const findMaxDepth = function (columns, depth) {
2933
- if (depth === void 0) {
2934
- depth = 1;
2935
- }
2936
-
2937
- maxDepth = Math.max(maxDepth, depth);
2938
- columns.filter(column => column.getIsVisible()).forEach(column => {
2939
- var _column$columns;
2940
-
2941
- if ((_column$columns = column.columns) != null && _column$columns.length) {
2942
- findMaxDepth(column.columns, depth + 1);
2943
- }
2944
- }, 0);
2945
- };
2946
-
2947
- findMaxDepth(allColumns);
2948
- let headerGroups = [];
2949
-
2950
- const createHeaderGroup = (headersToGroup, depth) => {
2951
- // The header group we are creating
2952
- const headerGroup = {
2953
- depth,
2954
- id: [headerFamily, "" + depth].filter(Boolean).join('_'),
2955
- headers: []
2956
- }; // The parent columns we're going to scan next
2957
-
2958
- const pendingParentHeaders = []; // Scan each column for parents
2959
-
2960
- headersToGroup.forEach(headerToGroup => {
2961
- // What is the latest (last) parent column?
2962
- const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
2963
- const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
2964
- let column;
2965
- let isPlaceholder = false;
2966
-
2967
- if (isLeafHeader && headerToGroup.column.parent) {
2968
- // The parent header is new
2969
- column = headerToGroup.column.parent;
2970
- } else {
2971
- // The parent header is repeated
2972
- column = headerToGroup.column;
2973
- isPlaceholder = true;
2974
- }
2975
-
2976
- if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
2977
- // This column is repeated. Add it as a sub header to the next batch
2978
- latestPendingParentHeader.subHeaders.push(headerToGroup);
2979
- } else {
2980
- // This is a new header. Let's create it
2981
- const header = instance.createHeader(column, {
2982
- id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
2983
- isPlaceholder,
2984
- placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
2985
- depth,
2986
- index: pendingParentHeaders.length
2987
- }); // Add the headerToGroup as a subHeader of the new header
2988
-
2989
- header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
2990
- // in the next batch
2991
2794
 
2992
- pendingParentHeaders.push(header);
2993
- }
2994
-
2995
- headerGroup.headers.push(headerToGroup);
2996
- headerToGroup.headerGroup = headerGroup;
2997
- });
2998
- headerGroups.push(headerGroup);
2999
-
3000
- if (depth > 0) {
3001
- createHeaderGroup(pendingParentHeaders, depth - 1);
3002
- }
3003
- };
3004
-
3005
- const bottomHeaders = columnsToGroup.map((column, index) => instance.createHeader(column, {
3006
- depth: maxDepth,
3007
- index
3008
- }));
3009
- createHeaderGroup(bottomHeaders, maxDepth - 1);
3010
- headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
3011
- // return !headerGroup.headers.every(header => header.isPlaceholder)
3012
- // })
3013
-
3014
- const recurseHeadersForSpans = headers => {
3015
- const filteredHeaders = headers.filter(header => header.column.getIsVisible());
3016
- return filteredHeaders.map(header => {
3017
- let colSpan = 0;
3018
- let rowSpan = 0;
3019
- let childRowSpans = [0];
3020
-
3021
- if (header.subHeaders && header.subHeaders.length) {
3022
- childRowSpans = [];
3023
- recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
3024
- let {
3025
- colSpan: childColSpan,
3026
- rowSpan: childRowSpan
3027
- } = _ref;
3028
- colSpan += childColSpan;
3029
- childRowSpans.push(childRowSpan);
3030
- });
3031
- } else {
3032
- colSpan = 1;
3033
- }
3034
-
3035
- const minChildRowSpan = Math.min(...childRowSpans);
3036
- rowSpan = rowSpan + minChildRowSpan;
3037
- header.colSpan = colSpan > 0 ? colSpan : undefined;
3038
- header.rowSpan = rowSpan > 0 ? rowSpan : undefined;
3039
- return {
3040
- colSpan,
3041
- rowSpan
3042
- };
3043
- });
3044
- };
3045
-
3046
- recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
3047
- return headerGroups;
3048
- }
2795
+ const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]; //
3049
2796
 
3050
- // export type Batch = {
3051
- // id: number
3052
- // priority: keyof CoreBatches
3053
- // tasks: (() => void)[]
3054
- // schedule: (cb: () => void) => void
3055
- // cancel: () => void
3056
- // }
3057
- // type CoreBatches = {
3058
- // data: Batch[]
3059
- // facets: Batch[]
3060
- // }
3061
2797
  function createTableInstance(options) {
3062
2798
  var _options$initialState;
3063
2799
 
@@ -3066,7 +2802,7 @@
3066
2802
  }
3067
2803
 
3068
2804
  let instance = {
3069
- _features: [Columns, Rows, Cells, Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]
2805
+ _features: features
3070
2806
  };
3071
2807
 
3072
2808
  const defaultOptions = instance._features.reduce((obj, feature) => {
@@ -3083,8 +2819,7 @@
3083
2819
  };
3084
2820
  };
3085
2821
 
3086
- const coreInitialState = {// coreProgress: 1,
3087
- };
2822
+ const coreInitialState = {};
3088
2823
  let initialState = { ...coreInitialState,
3089
2824
  ...((_options$initialState = options.initialState) != null ? _options$initialState : {})
3090
2825
  };
@@ -3097,16 +2832,8 @@
3097
2832
 
3098
2833
  const queued = [];
3099
2834
  let queuedTimeout = false;
3100
- const midInstance = { ...instance,
3101
- // init: () => {
3102
- // startWork()
3103
- // },
3104
- // willUpdate: () => {
3105
- // startWork()
3106
- // },
3107
- // destroy: () => {
3108
- // stopWork()
3109
- // },
2835
+ const coreInstance = {
2836
+ _features: features,
3110
2837
  options: { ...defaultOptions,
3111
2838
  ...options
3112
2839
  },
@@ -3152,29 +2879,134 @@
3152
2879
  },
3153
2880
  setState: updater => {
3154
2881
  instance.options.onStateChange == null ? void 0 : instance.options.onStateChange(updater);
3155
- } // getOverallProgress: () => {
3156
- // const { coreProgress, filtersProgress, facetProgress } =
3157
- // instance.getState()
3158
- // return mean(() =>
3159
- // [coreProgress, filtersProgress].filter(d => d < 1)
3160
- // ) as number
3161
- // },
3162
- // getProgressStage: () => {
3163
- // const { coreProgress, filtersProgress, facetProgress } =
3164
- // instance.getState()
3165
- // if (coreProgress < 1) {
3166
- // return 'coreRowModel'
3167
- // }
3168
- // if (filtersProgress < 1) {
3169
- // return 'filteredRowModel'
3170
- // }
3171
- // if (Object.values(facetProgress).some(d => d < 1)) {
3172
- // return 'facetedRowModel'
3173
- // }
3174
- // },
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
+ }
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
+ }
3175
3002
 
3003
+ throw new Error();
3004
+ }
3005
+
3006
+ return column;
3007
+ }
3176
3008
  };
3177
- instance = Object.assign(instance, midInstance);
3009
+ Object.assign(instance, coreInstance);
3178
3010
 
3179
3011
  instance._features.forEach(feature => {
3180
3012
  return Object.assign(instance, feature.createInstance == null ? void 0 : feature.createInstance(instance));
@@ -3197,10 +3029,11 @@
3197
3029
  throw new Error('');
3198
3030
  })()
3199
3031
  },
3200
- setGenerics: () => table,
3032
+ // setGenerics: () => table as any,
3201
3033
  setRowType: () => table,
3202
3034
  setTableMetaType: () => table,
3203
3035
  setColumnMetaType: () => table,
3036
+ setFilterMetaType: () => table,
3204
3037
  setOptions: newOptions => createTable$1(_, __, { ...options,
3205
3038
  ...newOptions
3206
3039
  }),
@@ -3232,11 +3065,92 @@
3232
3065
  }
3233
3066
 
3234
3067
  throw new Error('Invalid accessor');
3235
- }
3068
+ },
3069
+ createOptions: options => options
3236
3070
  };
3237
3071
  return table;
3238
3072
  }
3239
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
+
3240
3154
  function getCoreRowModel() {
3241
3155
  return instance => memo(() => [instance.options.data], data => {
3242
3156
  const rowModel = {
@@ -3264,7 +3178,7 @@
3264
3178
  // }
3265
3179
  // Make the row
3266
3180
 
3267
- row = instance.createRow(instance.getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3181
+ row = createRow(instance, instance._getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3268
3182
 
3269
3183
  rowModel.flatRows.push(row); // Also keep track of every row by its ID
3270
3184
 
@@ -3327,8 +3241,8 @@
3327
3241
  row = rowsToFilter[i];
3328
3242
 
3329
3243
  if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
3330
- newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3331
- newRow.columnFilterMap = row.columnFilterMap;
3244
+ newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3245
+ newRow.columnFilters = row.columnFilters;
3332
3246
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3333
3247
 
3334
3248
  if (!newRow.subRows.length) {
@@ -3377,7 +3291,7 @@
3377
3291
  var _row$subRows2;
3378
3292
 
3379
3293
  if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
3380
- newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3294
+ newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3381
3295
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3382
3296
  row = newRow;
3383
3297
  }
@@ -3401,6 +3315,11 @@
3401
3315
  function getFilteredRowModel() {
3402
3316
  return instance => memo(() => [instance.getPreFilteredRowModel(), instance.getState().columnFilters, instance.getState().globalFilter], (rowModel, columnFilters, globalFilter) => {
3403
3317
  if (!rowModel.rows.length || !(columnFilters != null && columnFilters.length) && !globalFilter) {
3318
+ for (let i = 0; i < rowModel.flatRows.length; i++) {
3319
+ rowModel.flatRows[i].columnFilters = {};
3320
+ rowModel.flatRows[i].columnFiltersMeta = {};
3321
+ }
3322
+
3404
3323
  return rowModel;
3405
3324
  }
3406
3325
 
@@ -3455,28 +3374,34 @@
3455
3374
 
3456
3375
  for (let j = 0; j < rowModel.flatRows.length; j++) {
3457
3376
  const row = rowModel.flatRows[j];
3458
- row.columnFilterMap = {};
3377
+ row.columnFilters = {};
3459
3378
 
3460
3379
  if (resolvedColumnFilters.length) {
3461
3380
  for (let i = 0; i < resolvedColumnFilters.length; i++) {
3462
- currentColumnFilter = resolvedColumnFilters[i]; // Tag the row with the column filter state
3381
+ currentColumnFilter = resolvedColumnFilters[i];
3382
+ const id = currentColumnFilter.id; // Tag the row with the column filter state
3463
3383
 
3464
- row.columnFilterMap[currentColumnFilter.id] = currentColumnFilter.filterFn(row, currentColumnFilter.id, currentColumnFilter.resolvedValue);
3384
+ row.columnFilters[id] = currentColumnFilter.filterFn(row, id, currentColumnFilter.resolvedValue, filterMeta => {
3385
+ row.columnFiltersMeta[id] = filterMeta;
3386
+ });
3465
3387
  }
3466
3388
  }
3467
3389
 
3468
3390
  if (resolvedGlobalFilters.length) {
3469
3391
  for (let i = 0; i < resolvedGlobalFilters.length; i++) {
3470
- currentGlobalFilter = resolvedGlobalFilters[i]; // Tag the row with the first truthy global filter state
3392
+ currentGlobalFilter = resolvedGlobalFilters[i];
3393
+ const id = currentGlobalFilter.id; // Tag the row with the first truthy global filter state
3471
3394
 
3472
- if (currentGlobalFilter.filterFn(row, currentGlobalFilter.id, currentGlobalFilter.resolvedValue)) {
3473
- row.columnFilterMap.__global__ = true;
3395
+ if (currentGlobalFilter.filterFn(row, id, currentGlobalFilter.resolvedValue, filterMeta => {
3396
+ row.columnFiltersMeta[id] = filterMeta;
3397
+ })) {
3398
+ row.columnFilters.__global__ = true;
3474
3399
  break;
3475
3400
  }
3476
3401
  }
3477
3402
 
3478
- if (row.columnFilterMap.__global__ !== true) {
3479
- row.columnFilterMap.__global__ = false;
3403
+ if (row.columnFilters.__global__ !== true) {
3404
+ row.columnFilters.__global__ = false;
3480
3405
  }
3481
3406
  }
3482
3407
  }
@@ -3484,7 +3409,7 @@
3484
3409
  const filterRowsImpl = row => {
3485
3410
  // Horizontally filter rows through each column
3486
3411
  for (let i = 0; i < filterableIds.length; i++) {
3487
- if (row.columnFilterMap[filterableIds[i]] === false) {
3412
+ if (row.columnFilters[filterableIds[i]] === false) {
3488
3413
  return false;
3489
3414
  }
3490
3415
  }
@@ -3518,7 +3443,7 @@
3518
3443
  const filterRowsImpl = row => {
3519
3444
  // Horizontally filter rows through each column
3520
3445
  for (let i = 0; i < filterableIds.length; i++) {
3521
- if (row.columnFilterMap[filterableIds[i]] === false) {
3446
+ if (row.columnFilters[filterableIds[i]] === false) {
3522
3447
  return false;
3523
3448
  }
3524
3449
  }
@@ -3618,8 +3543,8 @@
3618
3543
  availableSorting.forEach(sortEntry => {
3619
3544
  const column = instance.getColumn(sortEntry.id);
3620
3545
  columnInfoById[sortEntry.id] = {
3621
- sortUndefined: column.sortUndefined,
3622
- invertSorting: column.invertSorting,
3546
+ sortUndefined: column.columnDef.sortUndefined,
3547
+ invertSorting: column.columnDef.invertSorting,
3623
3548
  sortingFn: column.getSortingFn()
3624
3549
  };
3625
3550
  });
@@ -3733,7 +3658,7 @@
3733
3658
  const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
3734
3659
 
3735
3660
  const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
3736
- const row = instance.createRow(id, undefined, index, depth);
3661
+ const row = createRow(instance, id, undefined, index, depth);
3737
3662
  Object.assign(row, {
3738
3663
  groupingColumnId: columnId,
3739
3664
  groupingValue,
@@ -3742,17 +3667,17 @@
3742
3667
  getValue: columnId => {
3743
3668
  // Don't aggregate columns that are in the grouping
3744
3669
  if (existingGrouping.includes(columnId)) {
3745
- if (row.valuesCache.hasOwnProperty(columnId)) {
3746
- return row.valuesCache[columnId];
3670
+ if (row._valuesCache.hasOwnProperty(columnId)) {
3671
+ return row._valuesCache[columnId];
3747
3672
  }
3748
3673
 
3749
3674
  if (groupedRows[0]) {
3750
3675
  var _groupedRows$0$getVal;
3751
3676
 
3752
- row.valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
3677
+ row._valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
3753
3678
  }
3754
3679
 
3755
- return row.valuesCache[columnId];
3680
+ return row._valuesCache[columnId];
3756
3681
  }
3757
3682
 
3758
3683
  if (row.groupingValuesCache.hasOwnProperty(columnId)) {
@@ -3767,8 +3692,8 @@
3767
3692
  row.groupingValuesCache[columnId] = aggregateFn(() => leafRows.map(row => {
3768
3693
  let columnValue = row.getValue(columnId);
3769
3694
 
3770
- if (!depth && column.aggregateValue) {
3771
- columnValue = column.aggregateValue(columnValue);
3695
+ if (!depth && column.columnDef.aggregateValue) {
3696
+ columnValue = column.columnDef.aggregateValue(columnValue);
3772
3697
  }
3773
3698
 
3774
3699
  return columnValue;
@@ -3993,12 +3918,16 @@
3993
3918
  exports.RowSelection = RowSelection;
3994
3919
  exports.Sorting = Sorting;
3995
3920
  exports.Visibility = Visibility;
3921
+ exports.aggregationFns = aggregationFns;
3996
3922
  exports.buildHeaderGroups = buildHeaderGroups;
3923
+ exports.createColumn = createColumn;
3924
+ exports.createRow = createRow;
3997
3925
  exports.createTable = createTable;
3998
3926
  exports.createTableFactory = createTableFactory;
3999
3927
  exports.createTableInstance = createTableInstance;
4000
3928
  exports.defaultColumnSizing = defaultColumnSizing;
4001
3929
  exports.expandRows = expandRows;
3930
+ exports.filterFns = filterFns;
4002
3931
  exports.flattenBy = flattenBy;
4003
3932
  exports.functionalUpdate = functionalUpdate;
4004
3933
  exports.getCoreRowModel = getCoreRowModel;
@@ -4013,13 +3942,16 @@
4013
3942
  exports.isFunction = isFunction;
4014
3943
  exports.isRowSelected = isRowSelected;
4015
3944
  exports.makeStateUpdater = makeStateUpdater;
3945
+ exports.mean = mean;
4016
3946
  exports.memo = memo;
4017
3947
  exports.noop = noop;
4018
3948
  exports.orderColumns = orderColumns;
4019
3949
  exports.passiveEventSupported = passiveEventSupported;
3950
+ exports.reSplitAlphaNumeric = reSplitAlphaNumeric;
4020
3951
  exports.render = render;
4021
3952
  exports.selectRowsFn = selectRowsFn;
4022
3953
  exports.shouldAutoRemoveFilter = shouldAutoRemoveFilter;
3954
+ exports.sortingFns = sortingFns;
4023
3955
  exports.useTableInstance = useTableInstance;
4024
3956
 
4025
3957
  Object.defineProperty(exports, '__esModule', { value: true });