@tanstack/svelte-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.
@@ -101,327 +101,457 @@
101
101
  };
102
102
  }
103
103
 
104
+ function createColumn(instance, columnDef, depth, parent) {
105
+ var _ref, _columnDef$id;
106
+
107
+ const defaultColumn = instance._getDefaultColumnDef();
108
+
109
+ columnDef = { ...defaultColumn,
110
+ ...columnDef
111
+ };
112
+ let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
113
+ let accessorFn;
114
+
115
+ if (columnDef.accessorFn) {
116
+ accessorFn = columnDef.accessorFn;
117
+ } else if (columnDef.accessorKey) {
118
+ accessorFn = originalRow => originalRow[columnDef.accessorKey];
119
+ }
120
+
121
+ if (!id) {
122
+ {
123
+ throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
124
+ }
125
+ }
126
+
127
+ let column = { ...columnDef,
128
+ id: "" + id,
129
+ accessorFn,
130
+ parent: parent,
131
+ depth,
132
+ columnDef,
133
+ columnDefType: columnDef.columnDefType,
134
+ columns: [],
135
+ getFlatColumns: memo(() => [true], () => {
136
+ var _column$columns;
137
+
138
+ return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
139
+ }, {
140
+ key: "development" === 'production' ,
141
+ debug: () => {
142
+ var _instance$options$deb;
143
+
144
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
145
+ }
146
+ }),
147
+ getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
148
+ var _column$columns2;
149
+
150
+ if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
151
+ let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
152
+ return orderColumns(leafColumns);
153
+ }
154
+
155
+ return [column];
156
+ }, {
157
+ key: "development" === 'production' ,
158
+ debug: () => {
159
+ var _instance$options$deb2;
160
+
161
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
162
+ }
163
+ })
164
+ };
165
+ column = instance._features.reduce((obj, feature) => {
166
+ return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
167
+ }, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
168
+
169
+ return column;
170
+ }
171
+
104
172
  //
105
- const Columns = {
173
+ function createHeader(instance, column, options) {
174
+ var _options$id;
175
+
176
+ const id = (_options$id = options.id) != null ? _options$id : column.id;
177
+ let header = {
178
+ id,
179
+ column,
180
+ index: options.index,
181
+ isPlaceholder: !!options.isPlaceholder,
182
+ placeholderId: options.placeholderId,
183
+ depth: options.depth,
184
+ subHeaders: [],
185
+ colSpan: 0,
186
+ rowSpan: 0,
187
+ headerGroup: null,
188
+ getLeafHeaders: () => {
189
+ const leafHeaders = [];
190
+
191
+ const recurseHeader = h => {
192
+ if (h.subHeaders && h.subHeaders.length) {
193
+ h.subHeaders.map(recurseHeader);
194
+ }
195
+
196
+ leafHeaders.push(h);
197
+ };
198
+
199
+ recurseHeader(header);
200
+ return leafHeaders;
201
+ },
202
+ renderHeader: () => column.columnDef.header ? instance._render(column.columnDef.header, {
203
+ instance,
204
+ header: header,
205
+ column
206
+ }) : null,
207
+ renderFooter: () => column.columnDef.footer ? instance._render(column.columnDef.footer, {
208
+ instance,
209
+ header: header,
210
+ column
211
+ }) : null
212
+ };
213
+
214
+ instance._features.forEach(feature => {
215
+ Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
216
+ });
217
+
218
+ return header;
219
+ }
220
+
221
+ const Headers = {
106
222
  createInstance: instance => {
107
223
  return {
108
- getDefaultColumn: memo(() => [instance.options.defaultColumn], defaultColumn => {
109
- var _defaultColumn;
110
-
111
- defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
112
- return {
113
- header: props => props.header.column.id,
114
- footer: props => props.header.column.id,
115
- cell: props => {
116
- var _props$getValue$toStr, _props$getValue$toStr2, _props$getValue;
224
+ // Header Groups
225
+ getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
226
+ var _left$map$filter, _right$map$filter;
117
227
 
118
- 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;
119
- },
120
- ...instance._features.reduce((obj, feature) => {
121
- return Object.assign(obj, feature.getDefaultColumn == null ? void 0 : feature.getDefaultColumn());
122
- }, {}),
123
- ...defaultColumn
124
- };
228
+ const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
229
+ const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
230
+ const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
231
+ const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
232
+ return headerGroups;
125
233
  }, {
234
+ key: 'getHeaderGroups',
126
235
  debug: () => {
127
236
  var _instance$options$deb;
128
237
 
129
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
130
- },
131
- key: 'getDefaultColumn'
132
- }),
133
- getColumnDefs: () => instance.options.columns,
134
- createColumn: (columnDef, depth, parent) => {
135
- var _ref, _columnDef$id;
136
-
137
- const defaultColumn = instance.getDefaultColumn();
138
- let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
139
- let accessorFn;
140
-
141
- if (columnDef.accessorFn) {
142
- accessorFn = columnDef.accessorFn;
143
- } else if (columnDef.accessorKey) {
144
- accessorFn = originalRow => originalRow[columnDef.accessorKey];
238
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
145
239
  }
240
+ }),
241
+ getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
242
+ leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
243
+ return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
244
+ }, {
245
+ key: 'getCenterHeaderGroups',
246
+ debug: () => {
247
+ var _instance$options$deb2;
146
248
 
147
- if (!id) {
148
- {
149
- throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
150
- }
249
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
151
250
  }
251
+ }),
252
+ getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
253
+ var _left$map$filter2;
152
254
 
153
- let column = { ...defaultColumn,
154
- ...columnDef,
155
- id: "" + id,
156
- accessorFn,
157
- parent: parent,
158
- depth,
159
- columnDef,
160
- columnDefType: columnDef.columnDefType,
161
- columns: [],
162
- getFlatColumns: memo(() => [true], () => {
163
- var _column$columns;
164
-
165
- return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
166
- }, {
167
- key: "development" === 'production' ,
168
- debug: () => {
169
- var _instance$options$deb2;
170
-
171
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
172
- }
173
- }),
174
- getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
175
- var _column$columns2;
176
-
177
- if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
178
- let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
179
- return orderColumns(leafColumns);
180
- }
181
-
182
- return [column];
183
- }, {
184
- key: "development" === 'production' ,
185
- debug: () => {
186
- var _instance$options$deb3;
187
-
188
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
189
- }
190
- })
191
- };
192
- column = instance._features.reduce((obj, feature) => {
193
- return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
194
- }, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
195
-
196
- return column;
197
- },
198
- getAllColumns: memo(() => [instance.getColumnDefs()], columnDefs => {
199
- const recurseColumns = function (columnDefs, parent, depth) {
200
- if (depth === void 0) {
201
- depth = 0;
202
- }
255
+ const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
256
+ return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
257
+ }, {
258
+ key: 'getLeftHeaderGroups',
259
+ debug: () => {
260
+ var _instance$options$deb3;
203
261
 
204
- return columnDefs.map(columnDef => {
205
- const column = instance.createColumn(columnDef, depth, parent);
206
- column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
207
- return column;
208
- });
209
- };
262
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
263
+ }
264
+ }),
265
+ getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
266
+ var _right$map$filter2;
210
267
 
211
- return recurseColumns(columnDefs);
268
+ const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
269
+ return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
212
270
  }, {
213
- key: 'getAllColumns',
271
+ key: 'getRightHeaderGroups',
214
272
  debug: () => {
215
273
  var _instance$options$deb4;
216
274
 
217
- return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
275
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
218
276
  }
219
277
  }),
220
- getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
221
- return allColumns.flatMap(column => {
222
- return column.getFlatColumns();
223
- });
278
+ // Footer Groups
279
+ getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
280
+ return [...headerGroups].reverse();
224
281
  }, {
225
- key: 'getAllFlatColumns',
282
+ key: 'getFooterGroups',
226
283
  debug: () => {
227
284
  var _instance$options$deb5;
228
285
 
229
- return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
286
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
230
287
  }
231
288
  }),
232
- getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
233
- return flatColumns.reduce((acc, column) => {
234
- acc[column.id] = column;
235
- return acc;
236
- }, {});
289
+ getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
290
+ return [...headerGroups].reverse();
237
291
  }, {
238
- key: 'getAllFlatColumnsById',
292
+ key: 'getLeftFooterGroups',
239
293
  debug: () => {
240
294
  var _instance$options$deb6;
241
295
 
242
- return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugColumns;
296
+ return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
243
297
  }
244
298
  }),
245
- getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
246
- let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
247
- return orderColumns(leafColumns);
299
+ getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
300
+ return [...headerGroups].reverse();
248
301
  }, {
249
- key: 'getAllLeafColumns',
302
+ key: 'getCenterFooterGroups',
250
303
  debug: () => {
251
304
  var _instance$options$deb7;
252
305
 
253
- return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugColumns;
306
+ return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
254
307
  }
255
308
  }),
256
- getColumn: columnId => {
257
- const column = instance.getAllFlatColumnsById()[columnId];
258
-
259
- if (!column) {
260
- {
261
- console.warn("[Table] Column with id " + columnId + " does not exist.");
262
- }
309
+ getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
310
+ return [...headerGroups].reverse();
311
+ }, {
312
+ key: 'getRightFooterGroups',
313
+ debug: () => {
314
+ var _instance$options$deb8;
263
315
 
264
- throw new Error();
316
+ return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
265
317
  }
318
+ }),
319
+ // Flat Headers
320
+ getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
321
+ return headerGroups.map(headerGroup => {
322
+ return headerGroup.headers;
323
+ }).flat();
324
+ }, {
325
+ key: 'getFlatHeaders',
326
+ debug: () => {
327
+ var _instance$options$deb9;
266
328
 
267
- return column;
268
- }
269
- };
270
- }
271
- };
272
-
273
- //
274
- const Rows = {
275
- // createRow: <TGenerics extends TableGenerics>(
276
- // row: Row<TGenerics>,
277
- // instance: TableInstance<TGenerics>
278
- // ): CellsRow<TGenerics> => {
279
- // return {}
280
- // },
281
- createInstance: instance => {
282
- return {
283
- getRowId: (row, index, parent) => {
284
- var _instance$options$get;
285
-
286
- 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);
287
- },
288
- createRow: (id, original, rowIndex, depth, subRows) => {
289
- let row = {
290
- id,
291
- index: rowIndex,
292
- original,
293
- depth,
294
- valuesCache: {},
295
- getValue: columnId => {
296
- if (row.valuesCache.hasOwnProperty(columnId)) {
297
- return row.valuesCache[columnId];
298
- }
299
-
300
- const column = instance.getColumn(columnId);
301
-
302
- if (!column.accessorFn) {
303
- return undefined;
304
- }
305
-
306
- row.valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
307
- return row.valuesCache[columnId];
308
- },
309
- subRows: subRows != null ? subRows : [],
310
- getLeafRows: () => flattenBy(row.subRows, d => d.subRows)
311
- };
312
-
313
- for (let i = 0; i < instance._features.length; i++) {
314
- const feature = instance._features[i];
315
- Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
329
+ return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
316
330
  }
331
+ }),
332
+ getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
333
+ return left.map(headerGroup => {
334
+ return headerGroup.headers;
335
+ }).flat();
336
+ }, {
337
+ key: 'getLeftFlatHeaders',
338
+ debug: () => {
339
+ var _instance$options$deb10;
317
340
 
318
- return row;
319
- },
320
- getCoreRowModel: () => {
321
- if (!instance._getCoreRowModel) {
322
- instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
341
+ return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
323
342
  }
343
+ }),
344
+ getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
345
+ return left.map(headerGroup => {
346
+ return headerGroup.headers;
347
+ }).flat();
348
+ }, {
349
+ key: 'getCenterFlatHeaders',
350
+ debug: () => {
351
+ var _instance$options$deb11;
324
352
 
325
- return instance._getCoreRowModel();
326
- },
327
- // The final calls start at the bottom of the model,
328
- // expanded rows, which then work their way up
329
- getRowModel: () => {
330
- return instance.getPaginationRowModel();
331
- },
332
- getRow: id => {
333
- const row = instance.getRowModel().rowsById[id];
334
-
335
- if (!row) {
336
- {
337
- throw new Error("getRow expected an ID, but got " + id);
338
- }
353
+ return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
339
354
  }
355
+ }),
356
+ getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
357
+ return left.map(headerGroup => {
358
+ return headerGroup.headers;
359
+ }).flat();
360
+ }, {
361
+ key: 'getRightFlatHeaders',
362
+ debug: () => {
363
+ var _instance$options$deb12;
340
364
 
341
- return row;
342
- }
343
- };
344
- }
345
- };
365
+ return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
366
+ }
367
+ }),
368
+ // Leaf Headers
369
+ getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
370
+ return flatHeaders.filter(header => {
371
+ var _header$subHeaders;
346
372
 
347
- //
348
- const Cells = {
349
- createRow: (row, instance) => {
350
- return {
351
- getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
352
- return leafColumns.map(column => {
353
- return instance.createCell(row, column, column.id);
373
+ return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
354
374
  });
355
375
  }, {
356
- key: 'row.getAllCells',
376
+ key: 'getCenterLeafHeaders',
357
377
  debug: () => {
358
- var _instance$options$deb;
378
+ var _instance$options$deb13;
359
379
 
360
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
380
+ return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
361
381
  }
362
382
  }),
363
- getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
364
- return allCells.reduce((acc, cell) => {
365
- acc[cell.columnId] = cell;
366
- return acc;
367
- }, {});
383
+ getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
384
+ return flatHeaders.filter(header => {
385
+ var _header$subHeaders2;
386
+
387
+ return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
388
+ });
368
389
  }, {
369
- key: "development" === 'production' ,
390
+ key: 'getLeftLeafHeaders',
370
391
  debug: () => {
371
- var _instance$options$deb2;
392
+ var _instance$options$deb14;
372
393
 
373
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
394
+ return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
374
395
  }
375
- })
376
- };
377
- },
378
- createInstance: instance => {
379
- return {
380
- createCell: (row, column, columnId) => {
381
- const cell = {
382
- id: row.id + "_" + column.id,
383
- rowId: row.id,
384
- columnId,
385
- row,
386
- column,
387
- getValue: () => row.getValue(columnId),
388
- renderCell: () => column.cell ? instance._render(column.cell, {
389
- instance,
390
- column,
391
- row,
392
- cell: cell,
393
- getValue: cell.getValue
394
- }) : null
395
- };
396
-
397
- instance._features.forEach(feature => {
398
- Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
399
- }, {});
396
+ }),
397
+ getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
398
+ return flatHeaders.filter(header => {
399
+ var _header$subHeaders3;
400
400
 
401
- return cell;
402
- },
403
- getCell: (rowId, columnId) => {
404
- const row = instance.getRow(rowId);
401
+ return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
402
+ });
403
+ }, {
404
+ key: 'getRightLeafHeaders',
405
+ debug: () => {
406
+ var _instance$options$deb15;
405
407
 
406
- if (!row) {
407
- {
408
- throw new Error("[Table] could not find row with id " + rowId);
409
- }
408
+ return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
410
409
  }
410
+ }),
411
+ getLeafHeaders: memo(() => [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()], (left, center, right) => {
412
+ var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
411
413
 
412
- const cell = row.getAllCellsByColumnId()[columnId];
414
+ 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 => {
415
+ return header.getLeafHeaders();
416
+ }).flat();
417
+ }, {
418
+ key: 'getLeafHeaders',
419
+ debug: () => {
420
+ var _instance$options$deb16;
413
421
 
414
- if (!cell) {
415
- {
416
- throw new Error("[Table] could not find cell " + columnId + " in row " + rowId);
417
- }
422
+ return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
418
423
  }
419
-
420
- return cell;
421
- }
424
+ })
422
425
  };
423
426
  }
424
427
  };
428
+ function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
429
+ var _headerGroups$0$heade, _headerGroups$;
430
+
431
+ // Find the max depth of the columns:
432
+ // build the leaf column row
433
+ // build each buffer row going up
434
+ // placeholder for non-existent level
435
+ // real column for existing level
436
+ let maxDepth = 0;
437
+
438
+ const findMaxDepth = function (columns, depth) {
439
+ if (depth === void 0) {
440
+ depth = 1;
441
+ }
442
+
443
+ maxDepth = Math.max(maxDepth, depth);
444
+ columns.filter(column => column.getIsVisible()).forEach(column => {
445
+ var _column$columns;
446
+
447
+ if ((_column$columns = column.columns) != null && _column$columns.length) {
448
+ findMaxDepth(column.columns, depth + 1);
449
+ }
450
+ }, 0);
451
+ };
452
+
453
+ findMaxDepth(allColumns);
454
+ let headerGroups = [];
455
+
456
+ const createHeaderGroup = (headersToGroup, depth) => {
457
+ // The header group we are creating
458
+ const headerGroup = {
459
+ depth,
460
+ id: [headerFamily, "" + depth].filter(Boolean).join('_'),
461
+ headers: []
462
+ }; // The parent columns we're going to scan next
463
+
464
+ const pendingParentHeaders = []; // Scan each column for parents
465
+
466
+ headersToGroup.forEach(headerToGroup => {
467
+ // What is the latest (last) parent column?
468
+ const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
469
+ const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
470
+ let column;
471
+ let isPlaceholder = false;
472
+
473
+ if (isLeafHeader && headerToGroup.column.parent) {
474
+ // The parent header is new
475
+ column = headerToGroup.column.parent;
476
+ } else {
477
+ // The parent header is repeated
478
+ column = headerToGroup.column;
479
+ isPlaceholder = true;
480
+ }
481
+
482
+ if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
483
+ // This column is repeated. Add it as a sub header to the next batch
484
+ latestPendingParentHeader.subHeaders.push(headerToGroup);
485
+ } else {
486
+ // This is a new header. Let's create it
487
+ const header = createHeader(instance, column, {
488
+ id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
489
+ isPlaceholder,
490
+ placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
491
+ depth,
492
+ index: pendingParentHeaders.length
493
+ }); // Add the headerToGroup as a subHeader of the new header
494
+
495
+ header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
496
+ // in the next batch
497
+
498
+ pendingParentHeaders.push(header);
499
+ }
500
+
501
+ headerGroup.headers.push(headerToGroup);
502
+ headerToGroup.headerGroup = headerGroup;
503
+ });
504
+ headerGroups.push(headerGroup);
505
+
506
+ if (depth > 0) {
507
+ createHeaderGroup(pendingParentHeaders, depth - 1);
508
+ }
509
+ };
510
+
511
+ const bottomHeaders = columnsToGroup.map((column, index) => createHeader(instance, column, {
512
+ depth: maxDepth,
513
+ index
514
+ }));
515
+ createHeaderGroup(bottomHeaders, maxDepth - 1);
516
+ headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
517
+ // return !headerGroup.headers.every(header => header.isPlaceholder)
518
+ // })
519
+
520
+ const recurseHeadersForSpans = headers => {
521
+ const filteredHeaders = headers.filter(header => header.column.getIsVisible());
522
+ return filteredHeaders.map(header => {
523
+ let colSpan = 0;
524
+ let rowSpan = 0;
525
+ let childRowSpans = [0];
526
+
527
+ if (header.subHeaders && header.subHeaders.length) {
528
+ childRowSpans = [];
529
+ recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
530
+ let {
531
+ colSpan: childColSpan,
532
+ rowSpan: childRowSpan
533
+ } = _ref;
534
+ colSpan += childColSpan;
535
+ childRowSpans.push(childRowSpan);
536
+ });
537
+ } else {
538
+ colSpan = 1;
539
+ }
540
+
541
+ const minChildRowSpan = Math.min(...childRowSpans);
542
+ rowSpan = rowSpan + minChildRowSpan;
543
+ header.colSpan = colSpan;
544
+ header.rowSpan = rowSpan;
545
+ return {
546
+ colSpan,
547
+ rowSpan
548
+ };
549
+ });
550
+ };
551
+
552
+ recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
553
+ return headerGroups;
554
+ }
425
555
 
426
556
  //
427
557
  const defaultColumnSizing = {
@@ -440,7 +570,7 @@
440
570
  });
441
571
 
442
572
  const ColumnSizing = {
443
- getDefaultColumn: () => {
573
+ getDefaultColumnDef: () => {
444
574
  return defaultColumnSizing;
445
575
  },
446
576
  getInitialState: state => {
@@ -460,10 +590,10 @@
460
590
  createColumn: (column, instance) => {
461
591
  return {
462
592
  getSize: () => {
463
- var _column$minSize, _ref, _column$maxSize;
593
+ var _column$columnDef$min, _ref, _column$columnDef$max;
464
594
 
465
595
  const columnSize = instance.getState().columnSizing[column.id];
466
- 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);
596
+ 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);
467
597
  },
468
598
  getStart: position => {
469
599
  const columns = !position ? instance.getVisibleLeafColumns() : position === 'left' ? instance.getLeftVisibleLeafColumns() : instance.getRightVisibleLeafColumns();
@@ -486,9 +616,9 @@
486
616
  });
487
617
  },
488
618
  getCanResize: () => {
489
- var _column$enableResizin, _instance$options$ena;
619
+ var _column$columnDef$ena, _instance$options$ena;
490
620
 
491
- return ((_column$enableResizin = column.enableResizing) != null ? _column$enableResizin : true) && ((_instance$options$ena = instance.options.enableColumnResizing) != null ? _instance$options$ena : true);
621
+ return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableColumnResizing) != null ? _instance$options$ena : true);
492
622
  },
493
623
  getIsResizing: () => {
494
624
  return instance.getState().columnSizingInfo.isResizingColumn === column.id;
@@ -945,7 +1075,7 @@
945
1075
 
946
1076
  //
947
1077
  const Filters = {
948
- getDefaultColumn: () => {
1078
+ getDefaultColumnDef: () => {
949
1079
  return {
950
1080
  filterFn: 'auto'
951
1081
  };
@@ -968,7 +1098,7 @@
968
1098
  getColumnCanGlobalFilter: column => {
969
1099
  var _instance$getCoreRowM, _instance$getCoreRowM2;
970
1100
 
971
- const value = (_instance$getCoreRowM = instance.getCoreRowModel().flatRows[0]) == null ? void 0 : (_instance$getCoreRowM2 = _instance$getCoreRowM.getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreRowM2.getValue();
1101
+ const value = (_instance$getCoreRowM = instance.getCoreRowModel().flatRows[0]) == null ? void 0 : (_instance$getCoreRowM2 = _instance$getCoreRowM._getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreRowM2.getValue();
972
1102
  return typeof value === 'string';
973
1103
  }
974
1104
  };
@@ -988,6 +1118,10 @@
988
1118
  return filterFns.inNumberRange;
989
1119
  }
990
1120
 
1121
+ if (typeof value === 'boolean') {
1122
+ return filterFns.equals;
1123
+ }
1124
+
991
1125
  if (value !== null && typeof value === 'object') {
992
1126
  return filterFns.equals;
993
1127
  }
@@ -1005,14 +1139,14 @@
1005
1139
  return isFunction(column.filterFn) ? column.filterFn : column.filterFn === 'auto' ? column.getAutoFilterFn() : (_ref = userFilterFns == null ? void 0 : userFilterFns[column.filterFn]) != null ? _ref : filterFns[column.filterFn];
1006
1140
  },
1007
1141
  getCanFilter: () => {
1008
- var _column$enableColumnF, _instance$options$ena, _instance$options$ena2;
1142
+ var _column$columnDef$ena, _instance$options$ena, _instance$options$ena2;
1009
1143
 
1010
- 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;
1144
+ 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;
1011
1145
  },
1012
1146
  getCanGlobalFilter: () => {
1013
- var _column$enableGlobalF, _instance$options$ena3, _instance$options$ena4, _instance$options$get;
1147
+ var _column$columnDef$ena2, _instance$options$ena3, _instance$options$ena4, _instance$options$get;
1014
1148
 
1015
- 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;
1149
+ 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;
1016
1150
  },
1017
1151
  getIsFiltered: () => column.getFilterIndex() > -1,
1018
1152
  getFilterValue: () => {
@@ -1091,7 +1225,8 @@
1091
1225
  },
1092
1226
  createRow: (row, instance) => {
1093
1227
  return {
1094
- columnFilterMap: {},
1228
+ columnFilters: {},
1229
+ columnFiltersMeta: {},
1095
1230
  subRowsByFacetId: {}
1096
1231
  };
1097
1232
  },
@@ -1289,7 +1424,7 @@
1289
1424
 
1290
1425
  //
1291
1426
  const Grouping = {
1292
- getDefaultColumn: () => {
1427
+ getDefaultColumnDef: () => {
1293
1428
  return {
1294
1429
  aggregationFn: 'auto'
1295
1430
  };
@@ -1319,9 +1454,9 @@
1319
1454
  });
1320
1455
  },
1321
1456
  getCanGroup: () => {
1322
- var _ref, _ref2, _ref3, _column$enableGroupin;
1457
+ var _ref, _ref2, _ref3, _column$columnDef$ena;
1323
1458
 
1324
- return (_ref = (_ref2 = (_ref3 = (_column$enableGroupin = column.enableGrouping) != null ? _column$enableGroupin : true) != null ? _ref3 : instance.options.enableGrouping) != null ? _ref2 : true) != null ? _ref : !!column.accessorFn;
1459
+ 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;
1325
1460
  },
1326
1461
  getIsGrouped: () => {
1327
1462
  var _instance$getState$gr;
@@ -1405,9 +1540,9 @@
1405
1540
  return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
1406
1541
  },
1407
1542
  renderAggregatedCell: () => {
1408
- var _column$aggregatedCel;
1543
+ var _column$columnDef$agg;
1409
1544
 
1410
- const template = (_column$aggregatedCel = column.aggregatedCell) != null ? _column$aggregatedCel : column.cell;
1545
+ const template = (_column$columnDef$agg = column.columnDef.aggregatedCell) != null ? _column$columnDef$agg : column.columnDef.cell;
1411
1546
  return template ? instance._render(template, {
1412
1547
  instance,
1413
1548
  column,
@@ -1714,9 +1849,9 @@
1714
1849
  getCanPin: () => {
1715
1850
  const leafColumns = column.getLeafColumns();
1716
1851
  return leafColumns.some(d => {
1717
- var _d$enablePinning, _instance$options$ena;
1852
+ var _d$columnDef$enablePi, _instance$options$ena;
1718
1853
 
1719
- return ((_d$enablePinning = d.enablePinning) != null ? _d$enablePinning : true) && ((_instance$options$ena = instance.options.enablePinning) != null ? _instance$options$ena : true);
1854
+ return ((_d$columnDef$enablePi = d.columnDef.enablePinning) != null ? _d$columnDef$enablePi : true) && ((_instance$options$ena = instance.options.enablePinning) != null ? _instance$options$ena : true);
1720
1855
  });
1721
1856
  },
1722
1857
  getIsPinned: () => {
@@ -1741,7 +1876,7 @@
1741
1876
  return {
1742
1877
  getCenterVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allCells, left, right) => {
1743
1878
  const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
1744
- return allCells.filter(d => !leftAndRight.includes(d.columnId));
1879
+ return allCells.filter(d => !leftAndRight.includes(d.column.id));
1745
1880
  }, {
1746
1881
  key: "development" === 'production' ,
1747
1882
  debug: () => {
@@ -1751,7 +1886,7 @@
1751
1886
  }
1752
1887
  }),
1753
1888
  getLeftVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left,,], (allCells, left) => {
1754
- const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.columnId === columnId)).filter(Boolean).map(d => ({ ...d,
1889
+ const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
1755
1890
  position: 'left'
1756
1891
  }));
1757
1892
  return cells;
@@ -1764,7 +1899,7 @@
1764
1899
  }
1765
1900
  }),
1766
1901
  getRightVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.right], (allCells, right) => {
1767
- const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.columnId === columnId)).filter(Boolean).map(d => ({ ...d,
1902
+ const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
1768
1903
  position: 'left'
1769
1904
  }));
1770
1905
  return cells;
@@ -1786,12 +1921,18 @@
1786
1921
 
1787
1922
  return instance.setColumnPinning(defaultState ? getDefaultPinningState() : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.columnPinning) != null ? _instance$initialStat : getDefaultPinningState());
1788
1923
  },
1789
- getIsSomeColumnsPinned: () => {
1790
- const {
1791
- left,
1792
- right
1793
- } = instance.getState().columnPinning;
1794
- return Boolean((left == null ? void 0 : left.length) || (right == null ? void 0 : right.length));
1924
+ getIsSomeColumnsPinned: position => {
1925
+ var _pinningState$positio;
1926
+
1927
+ const pinningState = instance.getState().columnPinning;
1928
+
1929
+ if (!position) {
1930
+ var _pinningState$left, _pinningState$right;
1931
+
1932
+ return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
1933
+ }
1934
+
1935
+ return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
1795
1936
  },
1796
1937
  getLeftLeafColumns: memo(() => [instance.getAllLeafColumns(), instance.getState().columnPinning.left], (allColumns, left) => {
1797
1938
  return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
@@ -2317,7 +2458,7 @@
2317
2458
  ...state
2318
2459
  };
2319
2460
  },
2320
- getDefaultColumn: () => {
2461
+ getDefaultColumnDef: () => {
2321
2462
  return {
2322
2463
  sortingFn: 'auto'
2323
2464
  };
@@ -2333,7 +2474,7 @@
2333
2474
  createColumn: (column, instance) => {
2334
2475
  return {
2335
2476
  getAutoSortingFn: () => {
2336
- const firstRows = instance.getFilteredRowModel().flatRows.slice(100);
2477
+ const firstRows = instance.getFilteredRowModel().flatRows.slice(10);
2337
2478
  let isString = false;
2338
2479
 
2339
2480
  for (const row of firstRows) {
@@ -2377,7 +2518,7 @@
2377
2518
  throw new Error();
2378
2519
  }
2379
2520
 
2380
- return isFunction(column.sortingFn) ? column.sortingFn : column.sortingFn === 'auto' ? column.getAutoSortingFn() : (_ref = userSortingFn == null ? void 0 : userSortingFn[column.sortingFn]) != null ? _ref : sortingFns[column.sortingFn];
2521
+ 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];
2381
2522
  },
2382
2523
  toggleSorting: (desc, multi) => {
2383
2524
  // if (column.columns.length) {
@@ -2389,7 +2530,7 @@
2389
2530
  // return
2390
2531
  // }
2391
2532
  instance.setSorting(old => {
2392
- var _ref2, _column$sortDescFirst, _instance$options$ena, _instance$options$ena2;
2533
+ var _ref2, _column$columnDef$sor, _instance$options$ena, _instance$options$ena2;
2393
2534
 
2394
2535
  // Find any existing sorting for this column
2395
2536
  const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
@@ -2416,7 +2557,7 @@
2416
2557
  }
2417
2558
  }
2418
2559
 
2419
- 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
2560
+ 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
2420
2561
 
2421
2562
  if (sortAction === 'toggle' && ( // Must be toggling
2422
2563
  (_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
@@ -2460,14 +2601,14 @@
2460
2601
  });
2461
2602
  },
2462
2603
  getCanSort: () => {
2463
- var _column$enableSorting, _instance$options$ena3;
2604
+ var _column$columnDef$ena, _instance$options$ena3;
2464
2605
 
2465
- return ((_column$enableSorting = column.enableSorting) != null ? _column$enableSorting : true) && ((_instance$options$ena3 = instance.options.enableSorting) != null ? _instance$options$ena3 : true) && !!column.accessorFn;
2606
+ 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;
2466
2607
  },
2467
2608
  getCanMultiSort: () => {
2468
- var _ref3, _column$enableMultiSo;
2609
+ var _ref3, _column$columnDef$ena2;
2469
2610
 
2470
- return (_ref3 = (_column$enableMultiSo = column.enableMultiSort) != null ? _column$enableMultiSo : instance.options.enableMultiSort) != null ? _ref3 : !!column.accessorFn;
2611
+ return (_ref3 = (_column$columnDef$ena2 = column.columnDef.enableMultiSort) != null ? _column$columnDef$ena2 : instance.options.enableMultiSort) != null ? _ref3 : !!column.accessorFn;
2471
2612
  },
2472
2613
  getIsSorted: () => {
2473
2614
  var _instance$getState$so;
@@ -2531,7 +2672,7 @@
2531
2672
  onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
2532
2673
  };
2533
2674
  },
2534
- getDefaultColumn: () => {
2675
+ getDefaultColumnDef: () => {
2535
2676
  return {
2536
2677
  defaultIsVisible: true
2537
2678
  };
@@ -2551,9 +2692,9 @@
2551
2692
  return (_instance$getState$co = (_instance$getState$co2 = instance.getState().columnVisibility) == null ? void 0 : _instance$getState$co2[column.id]) != null ? _instance$getState$co : true;
2552
2693
  },
2553
2694
  getCanHide: () => {
2554
- var _column$enableHiding, _instance$options$ena;
2695
+ var _column$columnDef$ena, _instance$options$ena;
2555
2696
 
2556
- return ((_column$enableHiding = column.enableHiding) != null ? _column$enableHiding : true) && ((_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : true);
2697
+ return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : true);
2557
2698
  },
2558
2699
  getToggleVisibilityHandler: () => {
2559
2700
  return e => {
@@ -2569,475 +2710,70 @@
2569
2710
  }, {
2570
2711
  key: "development" === 'production' ,
2571
2712
  debug: () => {
2572
- var _instance$options$deb;
2573
-
2574
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
2575
- }
2576
- }),
2577
- getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
2578
- key: 'row.getVisibleCells',
2579
- debug: () => {
2580
- var _instance$options$deb2;
2581
-
2582
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
2583
- }
2584
- })
2585
- };
2586
- },
2587
- createInstance: instance => {
2588
- const makeVisibleColumnsMethod = (key, getColumns) => {
2589
- return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
2590
- return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
2591
- }, {
2592
- key,
2593
- debug: () => {
2594
- var _instance$options$deb3;
2595
-
2596
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2597
- }
2598
- });
2599
- };
2600
-
2601
- return {
2602
- getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
2603
- getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
2604
- getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
2605
- getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
2606
- getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
2607
- setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
2608
- resetColumnVisibility: defaultState => {
2609
- var _instance$initialStat;
2610
-
2611
- instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
2612
- },
2613
- toggleAllColumnsVisible: value => {
2614
- var _value;
2615
-
2616
- value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
2617
- instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
2618
- [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
2619
- }), {}));
2620
- },
2621
- getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
2622
- getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
2623
- getToggleAllColumnsVisibilityHandler: () => {
2624
- return e => {
2625
- var _target;
2626
-
2627
- instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
2628
- };
2629
- }
2630
- };
2631
- }
2632
- };
2633
-
2634
- //
2635
- const Headers = {
2636
- createInstance: instance => {
2637
- return {
2638
- createHeader: (column, options) => {
2639
- var _options$id;
2640
-
2641
- const id = (_options$id = options.id) != null ? _options$id : column.id;
2642
- let header = {
2643
- id,
2644
- column,
2645
- index: options.index,
2646
- isPlaceholder: options.isPlaceholder,
2647
- placeholderId: options.placeholderId,
2648
- depth: options.depth,
2649
- subHeaders: [],
2650
- colSpan: 0,
2651
- rowSpan: 0,
2652
- headerGroup: null,
2653
- getLeafHeaders: () => {
2654
- const leafHeaders = [];
2655
-
2656
- const recurseHeader = h => {
2657
- if (h.subHeaders && h.subHeaders.length) {
2658
- h.subHeaders.map(recurseHeader);
2659
- }
2660
-
2661
- leafHeaders.push(h);
2662
- };
2663
-
2664
- recurseHeader(header);
2665
- return leafHeaders;
2666
- },
2667
- renderHeader: () => column.header ? instance._render(column.header, {
2668
- instance,
2669
- header: header,
2670
- column
2671
- }) : null,
2672
- renderFooter: () => column.footer ? instance._render(column.footer, {
2673
- instance,
2674
- header: header,
2675
- column
2676
- }) : null
2677
- };
2678
-
2679
- instance._features.forEach(feature => {
2680
- Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
2681
- });
2682
-
2683
- return header;
2684
- },
2685
- // Header Groups
2686
- getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2687
- var _left$map$filter, _right$map$filter;
2688
-
2689
- const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
2690
- const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
2691
- const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2692
- const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
2693
- return headerGroups;
2694
- }, {
2695
- key: 'getHeaderGroups',
2696
- debug: () => {
2697
- var _instance$options$deb;
2698
-
2699
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
2700
- }
2701
- }),
2702
- getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2703
- leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2704
- return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
2705
- }, {
2706
- key: 'getCenterHeaderGroups',
2707
- debug: () => {
2708
- var _instance$options$deb2;
2709
-
2710
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
2711
- }
2712
- }),
2713
- getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
2714
- var _left$map$filter2;
2715
-
2716
- const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
2717
- return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
2718
- }, {
2719
- key: 'getLeftHeaderGroups',
2720
- debug: () => {
2721
- var _instance$options$deb3;
2722
-
2723
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
2724
- }
2725
- }),
2726
- getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
2727
- var _right$map$filter2;
2728
-
2729
- const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
2730
- return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
2731
- }, {
2732
- key: 'getRightHeaderGroups',
2733
- debug: () => {
2734
- var _instance$options$deb4;
2735
-
2736
- return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
2737
- }
2738
- }),
2739
- // Footer Groups
2740
- getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
2741
- return [...headerGroups].reverse();
2742
- }, {
2743
- key: 'getFooterGroups',
2744
- debug: () => {
2745
- var _instance$options$deb5;
2746
-
2747
- return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
2748
- }
2749
- }),
2750
- getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
2751
- return [...headerGroups].reverse();
2752
- }, {
2753
- key: 'getLeftFooterGroups',
2754
- debug: () => {
2755
- var _instance$options$deb6;
2756
-
2757
- return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
2758
- }
2759
- }),
2760
- getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
2761
- return [...headerGroups].reverse();
2762
- }, {
2763
- key: 'getCenterFooterGroups',
2764
- debug: () => {
2765
- var _instance$options$deb7;
2766
-
2767
- return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
2768
- }
2769
- }),
2770
- getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
2771
- return [...headerGroups].reverse();
2772
- }, {
2773
- key: 'getRightFooterGroups',
2774
- debug: () => {
2775
- var _instance$options$deb8;
2776
-
2777
- return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
2778
- }
2779
- }),
2780
- // Flat Headers
2781
- getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
2782
- return headerGroups.map(headerGroup => {
2783
- return headerGroup.headers;
2784
- }).flat();
2785
- }, {
2786
- key: 'getFlatHeaders',
2787
- debug: () => {
2788
- var _instance$options$deb9;
2789
-
2790
- return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
2791
- }
2792
- }),
2793
- getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
2794
- return left.map(headerGroup => {
2795
- return headerGroup.headers;
2796
- }).flat();
2797
- }, {
2798
- key: 'getLeftFlatHeaders',
2799
- debug: () => {
2800
- var _instance$options$deb10;
2801
-
2802
- return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
2803
- }
2804
- }),
2805
- getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
2806
- return left.map(headerGroup => {
2807
- return headerGroup.headers;
2808
- }).flat();
2809
- }, {
2810
- key: 'getCenterFlatHeaders',
2811
- debug: () => {
2812
- var _instance$options$deb11;
2813
-
2814
- return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
2815
- }
2816
- }),
2817
- getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
2818
- return left.map(headerGroup => {
2819
- return headerGroup.headers;
2820
- }).flat();
2821
- }, {
2822
- key: 'getRightFlatHeaders',
2823
- debug: () => {
2824
- var _instance$options$deb12;
2825
-
2826
- return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
2827
- }
2828
- }),
2829
- // Leaf Headers
2830
- getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
2831
- return flatHeaders.filter(header => {
2832
- var _header$subHeaders;
2833
-
2834
- return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
2835
- });
2836
- }, {
2837
- key: 'getCenterLeafHeaders',
2838
- debug: () => {
2839
- var _instance$options$deb13;
2840
-
2841
- return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
2842
- }
2843
- }),
2844
- getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
2845
- return flatHeaders.filter(header => {
2846
- var _header$subHeaders2;
2847
-
2848
- return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
2849
- });
2850
- }, {
2851
- key: 'getLeftLeafHeaders',
2852
- debug: () => {
2853
- var _instance$options$deb14;
2854
-
2855
- return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
2856
- }
2857
- }),
2858
- getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
2859
- return flatHeaders.filter(header => {
2860
- var _header$subHeaders3;
2861
-
2862
- return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
2863
- });
2864
- }, {
2865
- key: 'getRightLeafHeaders',
2866
- debug: () => {
2867
- var _instance$options$deb15;
2713
+ var _instance$options$deb;
2868
2714
 
2869
- return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
2715
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
2870
2716
  }
2871
2717
  }),
2872
- getLeafHeaders: memo(() => [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()], (left, center, right) => {
2873
- var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
2718
+ getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
2719
+ key: 'row.getVisibleCells',
2720
+ debug: () => {
2721
+ var _instance$options$deb2;
2874
2722
 
2875
- 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 => {
2876
- return header.getLeafHeaders();
2877
- }).flat();
2723
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
2724
+ }
2725
+ })
2726
+ };
2727
+ },
2728
+ createInstance: instance => {
2729
+ const makeVisibleColumnsMethod = (key, getColumns) => {
2730
+ return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
2731
+ return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
2878
2732
  }, {
2879
- key: 'getLeafHeaders',
2733
+ key,
2880
2734
  debug: () => {
2881
- var _instance$options$deb16;
2735
+ var _instance$options$deb3;
2882
2736
 
2883
- return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
2737
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2884
2738
  }
2885
- }),
2886
- getHeader: id => {
2887
- const header = [...instance.getFlatHeaders(), ...instance.getCenterFlatHeaders(), ...instance.getLeftFlatHeaders(), ...instance.getRightFlatHeaders()].find(d => d.id === id);
2739
+ });
2740
+ };
2888
2741
 
2889
- if (!header) {
2890
- {
2891
- console.warn("Could not find header with id: " + id);
2892
- }
2742
+ return {
2743
+ getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
2744
+ getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
2745
+ getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
2746
+ getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
2747
+ getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
2748
+ setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
2749
+ resetColumnVisibility: defaultState => {
2750
+ var _instance$initialStat;
2893
2751
 
2894
- throw new Error();
2895
- }
2752
+ instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
2753
+ },
2754
+ toggleAllColumnsVisible: value => {
2755
+ var _value;
2756
+
2757
+ value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
2758
+ instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
2759
+ [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
2760
+ }), {}));
2761
+ },
2762
+ getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
2763
+ getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
2764
+ getToggleAllColumnsVisibilityHandler: () => {
2765
+ return e => {
2766
+ var _target;
2896
2767
 
2897
- return header;
2768
+ instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
2769
+ };
2898
2770
  }
2899
2771
  };
2900
2772
  }
2901
2773
  };
2902
- function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
2903
- var _headerGroups$0$heade, _headerGroups$;
2904
-
2905
- // Find the max depth of the columns:
2906
- // build the leaf column row
2907
- // build each buffer row going up
2908
- // placeholder for non-existent level
2909
- // real column for existing level
2910
- let maxDepth = 0;
2911
-
2912
- const findMaxDepth = function (columns, depth) {
2913
- if (depth === void 0) {
2914
- depth = 1;
2915
- }
2916
-
2917
- maxDepth = Math.max(maxDepth, depth);
2918
- columns.filter(column => column.getIsVisible()).forEach(column => {
2919
- var _column$columns;
2920
-
2921
- if ((_column$columns = column.columns) != null && _column$columns.length) {
2922
- findMaxDepth(column.columns, depth + 1);
2923
- }
2924
- }, 0);
2925
- };
2926
-
2927
- findMaxDepth(allColumns);
2928
- let headerGroups = [];
2929
-
2930
- const createHeaderGroup = (headersToGroup, depth) => {
2931
- // The header group we are creating
2932
- const headerGroup = {
2933
- depth,
2934
- id: [headerFamily, "" + depth].filter(Boolean).join('_'),
2935
- headers: []
2936
- }; // The parent columns we're going to scan next
2937
-
2938
- const pendingParentHeaders = []; // Scan each column for parents
2939
-
2940
- headersToGroup.forEach(headerToGroup => {
2941
- // What is the latest (last) parent column?
2942
- const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
2943
- const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
2944
- let column;
2945
- let isPlaceholder = false;
2946
-
2947
- if (isLeafHeader && headerToGroup.column.parent) {
2948
- // The parent header is new
2949
- column = headerToGroup.column.parent;
2950
- } else {
2951
- // The parent header is repeated
2952
- column = headerToGroup.column;
2953
- isPlaceholder = true;
2954
- }
2955
-
2956
- if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
2957
- // This column is repeated. Add it as a sub header to the next batch
2958
- latestPendingParentHeader.subHeaders.push(headerToGroup);
2959
- } else {
2960
- // This is a new header. Let's create it
2961
- const header = instance.createHeader(column, {
2962
- id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
2963
- isPlaceholder,
2964
- placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
2965
- depth,
2966
- index: pendingParentHeaders.length
2967
- }); // Add the headerToGroup as a subHeader of the new header
2968
-
2969
- header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
2970
- // in the next batch
2971
2774
 
2972
- pendingParentHeaders.push(header);
2973
- }
2974
-
2975
- headerGroup.headers.push(headerToGroup);
2976
- headerToGroup.headerGroup = headerGroup;
2977
- });
2978
- headerGroups.push(headerGroup);
2979
-
2980
- if (depth > 0) {
2981
- createHeaderGroup(pendingParentHeaders, depth - 1);
2982
- }
2983
- };
2984
-
2985
- const bottomHeaders = columnsToGroup.map((column, index) => instance.createHeader(column, {
2986
- depth: maxDepth,
2987
- index
2988
- }));
2989
- createHeaderGroup(bottomHeaders, maxDepth - 1);
2990
- headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
2991
- // return !headerGroup.headers.every(header => header.isPlaceholder)
2992
- // })
2993
-
2994
- const recurseHeadersForSpans = headers => {
2995
- const filteredHeaders = headers.filter(header => header.column.getIsVisible());
2996
- return filteredHeaders.map(header => {
2997
- let colSpan = 0;
2998
- let rowSpan = 0;
2999
- let childRowSpans = [0];
3000
-
3001
- if (header.subHeaders && header.subHeaders.length) {
3002
- childRowSpans = [];
3003
- recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
3004
- let {
3005
- colSpan: childColSpan,
3006
- rowSpan: childRowSpan
3007
- } = _ref;
3008
- colSpan += childColSpan;
3009
- childRowSpans.push(childRowSpan);
3010
- });
3011
- } else {
3012
- colSpan = 1;
3013
- }
3014
-
3015
- const minChildRowSpan = Math.min(...childRowSpans);
3016
- rowSpan = rowSpan + minChildRowSpan;
3017
- header.colSpan = colSpan > 0 ? colSpan : undefined;
3018
- header.rowSpan = rowSpan > 0 ? rowSpan : undefined;
3019
- return {
3020
- colSpan,
3021
- rowSpan
3022
- };
3023
- });
3024
- };
3025
-
3026
- recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
3027
- return headerGroups;
3028
- }
2775
+ const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]; //
3029
2776
 
3030
- // export type Batch = {
3031
- // id: number
3032
- // priority: keyof CoreBatches
3033
- // tasks: (() => void)[]
3034
- // schedule: (cb: () => void) => void
3035
- // cancel: () => void
3036
- // }
3037
- // type CoreBatches = {
3038
- // data: Batch[]
3039
- // facets: Batch[]
3040
- // }
3041
2777
  function createTableInstance$1(options) {
3042
2778
  var _options$initialState;
3043
2779
 
@@ -3046,7 +2782,7 @@
3046
2782
  }
3047
2783
 
3048
2784
  let instance = {
3049
- _features: [Columns, Rows, Cells, Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]
2785
+ _features: features
3050
2786
  };
3051
2787
 
3052
2788
  const defaultOptions = instance._features.reduce((obj, feature) => {
@@ -3063,8 +2799,7 @@
3063
2799
  };
3064
2800
  };
3065
2801
 
3066
- const coreInitialState = {// coreProgress: 1,
3067
- };
2802
+ const coreInitialState = {};
3068
2803
  let initialState = { ...coreInitialState,
3069
2804
  ...((_options$initialState = options.initialState) != null ? _options$initialState : {})
3070
2805
  };
@@ -3077,16 +2812,8 @@
3077
2812
 
3078
2813
  const queued = [];
3079
2814
  let queuedTimeout = false;
3080
- const midInstance = { ...instance,
3081
- // init: () => {
3082
- // startWork()
3083
- // },
3084
- // willUpdate: () => {
3085
- // startWork()
3086
- // },
3087
- // destroy: () => {
3088
- // stopWork()
3089
- // },
2815
+ const coreInstance = {
2816
+ _features: features,
3090
2817
  options: { ...defaultOptions,
3091
2818
  ...options
3092
2819
  },
@@ -3132,29 +2859,134 @@
3132
2859
  },
3133
2860
  setState: updater => {
3134
2861
  instance.options.onStateChange == null ? void 0 : instance.options.onStateChange(updater);
3135
- } // getOverallProgress: () => {
3136
- // const { coreProgress, filtersProgress, facetProgress } =
3137
- // instance.getState()
3138
- // return mean(() =>
3139
- // [coreProgress, filtersProgress].filter(d => d < 1)
3140
- // ) as number
3141
- // },
3142
- // getProgressStage: () => {
3143
- // const { coreProgress, filtersProgress, facetProgress } =
3144
- // instance.getState()
3145
- // if (coreProgress < 1) {
3146
- // return 'coreRowModel'
3147
- // }
3148
- // if (filtersProgress < 1) {
3149
- // return 'filteredRowModel'
3150
- // }
3151
- // if (Object.values(facetProgress).some(d => d < 1)) {
3152
- // return 'facetedRowModel'
3153
- // }
3154
- // },
2862
+ },
2863
+ _getRowId: (row, index, parent) => {
2864
+ var _instance$options$get;
2865
+
2866
+ 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);
2867
+ },
2868
+ getCoreRowModel: () => {
2869
+ if (!instance._getCoreRowModel) {
2870
+ instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
2871
+ }
2872
+
2873
+ return instance._getCoreRowModel();
2874
+ },
2875
+ // The final calls start at the bottom of the model,
2876
+ // expanded rows, which then work their way up
2877
+ getRowModel: () => {
2878
+ return instance.getPaginationRowModel();
2879
+ },
2880
+ getRow: id => {
2881
+ const row = instance.getRowModel().rowsById[id];
2882
+
2883
+ if (!row) {
2884
+ {
2885
+ throw new Error("getRow expected an ID, but got " + id);
2886
+ }
2887
+ }
2888
+
2889
+ return row;
2890
+ },
2891
+ _getDefaultColumnDef: memo(() => [instance.options.defaultColumn], defaultColumn => {
2892
+ var _defaultColumn;
2893
+
2894
+ defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
2895
+ return {
2896
+ header: props => props.header.column.id,
2897
+ footer: props => props.header.column.id,
2898
+ cell: props => {
2899
+ var _props$getValue$toStr, _props$getValue$toStr2, _props$getValue;
2900
+
2901
+ 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;
2902
+ },
2903
+ ...instance._features.reduce((obj, feature) => {
2904
+ return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
2905
+ }, {}),
2906
+ ...defaultColumn
2907
+ };
2908
+ }, {
2909
+ debug: () => {
2910
+ var _instance$options$deb;
2911
+
2912
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
2913
+ },
2914
+ key: 'getDefaultColumnDef'
2915
+ }),
2916
+ _getColumnDefs: () => instance.options.columns,
2917
+ getAllColumns: memo(() => [instance._getColumnDefs()], columnDefs => {
2918
+ const recurseColumns = function (columnDefs, parent, depth) {
2919
+ if (depth === void 0) {
2920
+ depth = 0;
2921
+ }
2922
+
2923
+ return columnDefs.map(columnDef => {
2924
+ const column = createColumn(instance, columnDef, depth, parent);
2925
+ column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
2926
+ return column;
2927
+ });
2928
+ };
2929
+
2930
+ return recurseColumns(columnDefs);
2931
+ }, {
2932
+ key: 'getAllColumns',
2933
+ debug: () => {
2934
+ var _instance$options$deb2;
2935
+
2936
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
2937
+ }
2938
+ }),
2939
+ getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
2940
+ return allColumns.flatMap(column => {
2941
+ return column.getFlatColumns();
2942
+ });
2943
+ }, {
2944
+ key: 'getAllFlatColumns',
2945
+ debug: () => {
2946
+ var _instance$options$deb3;
2947
+
2948
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2949
+ }
2950
+ }),
2951
+ _getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
2952
+ return flatColumns.reduce((acc, column) => {
2953
+ acc[column.id] = column;
2954
+ return acc;
2955
+ }, {});
2956
+ }, {
2957
+ key: 'getAllFlatColumnsById',
2958
+ debug: () => {
2959
+ var _instance$options$deb4;
2960
+
2961
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
2962
+ }
2963
+ }),
2964
+ getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
2965
+ let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
2966
+ return orderColumns(leafColumns);
2967
+ }, {
2968
+ key: 'getAllLeafColumns',
2969
+ debug: () => {
2970
+ var _instance$options$deb5;
2971
+
2972
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
2973
+ }
2974
+ }),
2975
+ getColumn: columnId => {
2976
+ const column = instance._getAllFlatColumnsById()[columnId];
2977
+
2978
+ if (!column) {
2979
+ {
2980
+ console.warn("[Table] Column with id " + columnId + " does not exist.");
2981
+ }
3155
2982
 
2983
+ throw new Error();
2984
+ }
2985
+
2986
+ return column;
2987
+ }
3156
2988
  };
3157
- instance = Object.assign(instance, midInstance);
2989
+ Object.assign(instance, coreInstance);
3158
2990
 
3159
2991
  instance._features.forEach(feature => {
3160
2992
  return Object.assign(instance, feature.createInstance == null ? void 0 : feature.createInstance(instance));
@@ -3177,10 +3009,11 @@
3177
3009
  throw new Error('');
3178
3010
  })()
3179
3011
  },
3180
- setGenerics: () => table,
3012
+ // setGenerics: () => table as any,
3181
3013
  setRowType: () => table,
3182
3014
  setTableMetaType: () => table,
3183
3015
  setColumnMetaType: () => table,
3016
+ setFilterMetaType: () => table,
3184
3017
  setOptions: newOptions => createTable$1(_, __, { ...options,
3185
3018
  ...newOptions
3186
3019
  }),
@@ -3212,11 +3045,92 @@
3212
3045
  }
3213
3046
 
3214
3047
  throw new Error('Invalid accessor');
3215
- }
3048
+ },
3049
+ createOptions: options => options
3216
3050
  };
3217
3051
  return table;
3218
3052
  }
3219
3053
 
3054
+ function createCell(instance, row, column, columnId) {
3055
+ const cell = {
3056
+ id: row.id + "_" + column.id,
3057
+ row,
3058
+ column,
3059
+ getValue: () => row.getValue(columnId),
3060
+ renderCell: () => column.columnDef.cell ? instance._render(column.columnDef.cell, {
3061
+ instance,
3062
+ column,
3063
+ row,
3064
+ cell: cell,
3065
+ getValue: cell.getValue
3066
+ }) : null
3067
+ };
3068
+
3069
+ instance._features.forEach(feature => {
3070
+ Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
3071
+ }, {});
3072
+
3073
+ return cell;
3074
+ }
3075
+
3076
+ const createRow = (instance, id, original, rowIndex, depth, subRows) => {
3077
+ let row = {
3078
+ id,
3079
+ index: rowIndex,
3080
+ original,
3081
+ depth,
3082
+ _valuesCache: {},
3083
+ getValue: columnId => {
3084
+ if (row._valuesCache.hasOwnProperty(columnId)) {
3085
+ return row._valuesCache[columnId];
3086
+ }
3087
+
3088
+ const column = instance.getColumn(columnId);
3089
+
3090
+ if (!column.accessorFn) {
3091
+ return undefined;
3092
+ }
3093
+
3094
+ row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
3095
+ return row._valuesCache[columnId];
3096
+ },
3097
+ subRows: subRows != null ? subRows : [],
3098
+ getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
3099
+ getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
3100
+ return leafColumns.map(column => {
3101
+ return createCell(instance, row, column, column.id);
3102
+ });
3103
+ }, {
3104
+ key: 'row.getAllCells',
3105
+ debug: () => {
3106
+ var _instance$options$deb;
3107
+
3108
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
3109
+ }
3110
+ }),
3111
+ _getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
3112
+ return allCells.reduce((acc, cell) => {
3113
+ acc[cell.column.id] = cell;
3114
+ return acc;
3115
+ }, {});
3116
+ }, {
3117
+ key: "development" === 'production' ,
3118
+ debug: () => {
3119
+ var _instance$options$deb2;
3120
+
3121
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
3122
+ }
3123
+ })
3124
+ };
3125
+
3126
+ for (let i = 0; i < instance._features.length; i++) {
3127
+ const feature = instance._features[i];
3128
+ Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
3129
+ }
3130
+
3131
+ return row;
3132
+ };
3133
+
3220
3134
  function getCoreRowModel() {
3221
3135
  return instance => memo(() => [instance.options.data], data => {
3222
3136
  const rowModel = {
@@ -3244,7 +3158,7 @@
3244
3158
  // }
3245
3159
  // Make the row
3246
3160
 
3247
- row = instance.createRow(instance.getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3161
+ row = createRow(instance, instance._getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3248
3162
 
3249
3163
  rowModel.flatRows.push(row); // Also keep track of every row by its ID
3250
3164
 
@@ -3307,8 +3221,8 @@
3307
3221
  row = rowsToFilter[i];
3308
3222
 
3309
3223
  if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
3310
- newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3311
- newRow.columnFilterMap = row.columnFilterMap;
3224
+ newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3225
+ newRow.columnFilters = row.columnFilters;
3312
3226
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3313
3227
 
3314
3228
  if (!newRow.subRows.length) {
@@ -3357,7 +3271,7 @@
3357
3271
  var _row$subRows2;
3358
3272
 
3359
3273
  if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
3360
- newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3274
+ newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3361
3275
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3362
3276
  row = newRow;
3363
3277
  }
@@ -3381,6 +3295,11 @@
3381
3295
  function getFilteredRowModel() {
3382
3296
  return instance => memo(() => [instance.getPreFilteredRowModel(), instance.getState().columnFilters, instance.getState().globalFilter], (rowModel, columnFilters, globalFilter) => {
3383
3297
  if (!rowModel.rows.length || !(columnFilters != null && columnFilters.length) && !globalFilter) {
3298
+ for (let i = 0; i < rowModel.flatRows.length; i++) {
3299
+ rowModel.flatRows[i].columnFilters = {};
3300
+ rowModel.flatRows[i].columnFiltersMeta = {};
3301
+ }
3302
+
3384
3303
  return rowModel;
3385
3304
  }
3386
3305
 
@@ -3435,28 +3354,34 @@
3435
3354
 
3436
3355
  for (let j = 0; j < rowModel.flatRows.length; j++) {
3437
3356
  const row = rowModel.flatRows[j];
3438
- row.columnFilterMap = {};
3357
+ row.columnFilters = {};
3439
3358
 
3440
3359
  if (resolvedColumnFilters.length) {
3441
3360
  for (let i = 0; i < resolvedColumnFilters.length; i++) {
3442
- currentColumnFilter = resolvedColumnFilters[i]; // Tag the row with the column filter state
3361
+ currentColumnFilter = resolvedColumnFilters[i];
3362
+ const id = currentColumnFilter.id; // Tag the row with the column filter state
3443
3363
 
3444
- row.columnFilterMap[currentColumnFilter.id] = currentColumnFilter.filterFn(row, currentColumnFilter.id, currentColumnFilter.resolvedValue);
3364
+ row.columnFilters[id] = currentColumnFilter.filterFn(row, id, currentColumnFilter.resolvedValue, filterMeta => {
3365
+ row.columnFiltersMeta[id] = filterMeta;
3366
+ });
3445
3367
  }
3446
3368
  }
3447
3369
 
3448
3370
  if (resolvedGlobalFilters.length) {
3449
3371
  for (let i = 0; i < resolvedGlobalFilters.length; i++) {
3450
- currentGlobalFilter = resolvedGlobalFilters[i]; // Tag the row with the first truthy global filter state
3372
+ currentGlobalFilter = resolvedGlobalFilters[i];
3373
+ const id = currentGlobalFilter.id; // Tag the row with the first truthy global filter state
3451
3374
 
3452
- if (currentGlobalFilter.filterFn(row, currentGlobalFilter.id, currentGlobalFilter.resolvedValue)) {
3453
- row.columnFilterMap.__global__ = true;
3375
+ if (currentGlobalFilter.filterFn(row, id, currentGlobalFilter.resolvedValue, filterMeta => {
3376
+ row.columnFiltersMeta[id] = filterMeta;
3377
+ })) {
3378
+ row.columnFilters.__global__ = true;
3454
3379
  break;
3455
3380
  }
3456
3381
  }
3457
3382
 
3458
- if (row.columnFilterMap.__global__ !== true) {
3459
- row.columnFilterMap.__global__ = false;
3383
+ if (row.columnFilters.__global__ !== true) {
3384
+ row.columnFilters.__global__ = false;
3460
3385
  }
3461
3386
  }
3462
3387
  }
@@ -3464,7 +3389,7 @@
3464
3389
  const filterRowsImpl = row => {
3465
3390
  // Horizontally filter rows through each column
3466
3391
  for (let i = 0; i < filterableIds.length; i++) {
3467
- if (row.columnFilterMap[filterableIds[i]] === false) {
3392
+ if (row.columnFilters[filterableIds[i]] === false) {
3468
3393
  return false;
3469
3394
  }
3470
3395
  }
@@ -3498,7 +3423,7 @@
3498
3423
  const filterRowsImpl = row => {
3499
3424
  // Horizontally filter rows through each column
3500
3425
  for (let i = 0; i < filterableIds.length; i++) {
3501
- if (row.columnFilterMap[filterableIds[i]] === false) {
3426
+ if (row.columnFilters[filterableIds[i]] === false) {
3502
3427
  return false;
3503
3428
  }
3504
3429
  }
@@ -3598,8 +3523,8 @@
3598
3523
  availableSorting.forEach(sortEntry => {
3599
3524
  const column = instance.getColumn(sortEntry.id);
3600
3525
  columnInfoById[sortEntry.id] = {
3601
- sortUndefined: column.sortUndefined,
3602
- invertSorting: column.invertSorting,
3526
+ sortUndefined: column.columnDef.sortUndefined,
3527
+ invertSorting: column.columnDef.invertSorting,
3603
3528
  sortingFn: column.getSortingFn()
3604
3529
  };
3605
3530
  });
@@ -3713,7 +3638,7 @@
3713
3638
  const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
3714
3639
 
3715
3640
  const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
3716
- const row = instance.createRow(id, undefined, index, depth);
3641
+ const row = createRow(instance, id, undefined, index, depth);
3717
3642
  Object.assign(row, {
3718
3643
  groupingColumnId: columnId,
3719
3644
  groupingValue,
@@ -3722,17 +3647,17 @@
3722
3647
  getValue: columnId => {
3723
3648
  // Don't aggregate columns that are in the grouping
3724
3649
  if (existingGrouping.includes(columnId)) {
3725
- if (row.valuesCache.hasOwnProperty(columnId)) {
3726
- return row.valuesCache[columnId];
3650
+ if (row._valuesCache.hasOwnProperty(columnId)) {
3651
+ return row._valuesCache[columnId];
3727
3652
  }
3728
3653
 
3729
3654
  if (groupedRows[0]) {
3730
3655
  var _groupedRows$0$getVal;
3731
3656
 
3732
- row.valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
3657
+ row._valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
3733
3658
  }
3734
3659
 
3735
- return row.valuesCache[columnId];
3660
+ return row._valuesCache[columnId];
3736
3661
  }
3737
3662
 
3738
3663
  if (row.groupingValuesCache.hasOwnProperty(columnId)) {
@@ -3747,8 +3672,8 @@
3747
3672
  row.groupingValuesCache[columnId] = aggregateFn(() => leafRows.map(row => {
3748
3673
  let columnValue = row.getValue(columnId);
3749
3674
 
3750
- if (!depth && column.aggregateValue) {
3751
- columnValue = column.aggregateValue(columnValue);
3675
+ if (!depth && column.columnDef.aggregateValue) {
3676
+ columnValue = column.columnDef.aggregateValue(columnValue);
3752
3677
  }
3753
3678
 
3754
3679
  return columnValue;
@@ -4113,12 +4038,16 @@
4113
4038
  exports.RowSelection = RowSelection;
4114
4039
  exports.Sorting = Sorting;
4115
4040
  exports.Visibility = Visibility;
4041
+ exports.aggregationFns = aggregationFns;
4116
4042
  exports.buildHeaderGroups = buildHeaderGroups;
4043
+ exports.createColumn = createColumn;
4044
+ exports.createRow = createRow;
4117
4045
  exports.createTable = createTable;
4118
4046
  exports.createTableFactory = createTableFactory;
4119
4047
  exports.createTableInstance = createTableInstance;
4120
4048
  exports.defaultColumnSizing = defaultColumnSizing;
4121
4049
  exports.expandRows = expandRows;
4050
+ exports.filterFns = filterFns;
4122
4051
  exports.flattenBy = flattenBy;
4123
4052
  exports.functionalUpdate = functionalUpdate;
4124
4053
  exports.getCoreRowModel = getCoreRowModel;
@@ -4133,14 +4062,17 @@
4133
4062
  exports.isFunction = isFunction;
4134
4063
  exports.isRowSelected = isRowSelected;
4135
4064
  exports.makeStateUpdater = makeStateUpdater;
4065
+ exports.mean = mean;
4136
4066
  exports.memo = memo;
4137
4067
  exports.noop = noop;
4138
4068
  exports.orderColumns = orderColumns;
4139
4069
  exports.passiveEventSupported = passiveEventSupported;
4070
+ exports.reSplitAlphaNumeric = reSplitAlphaNumeric;
4140
4071
  exports.render = render;
4141
4072
  exports.renderComponent = renderComponent;
4142
4073
  exports.selectRowsFn = selectRowsFn;
4143
4074
  exports.shouldAutoRemoveFilter = shouldAutoRemoveFilter;
4075
+ exports.sortingFns = sortingFns;
4144
4076
 
4145
4077
  Object.defineProperty(exports, '__esModule', { value: true });
4146
4078