@tanstack/svelte-table 8.0.0-alpha.82 → 8.0.0-alpha.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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: () => {
@@ -1092,8 +1226,7 @@
1092
1226
  createRow: (row, instance) => {
1093
1227
  return {
1094
1228
  columnFilters: {},
1095
- columnFiltersMeta: {},
1096
- subRowsByFacetId: {}
1229
+ columnFiltersMeta: {}
1097
1230
  };
1098
1231
  },
1099
1232
  createInstance: instance => {
@@ -1184,53 +1317,42 @@
1184
1317
  return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
1185
1318
  }
1186
1319
 
1187
- const aggregationFns = {
1188
- sum,
1189
- min,
1190
- max,
1191
- extent,
1192
- mean,
1193
- median,
1194
- unique,
1195
- uniqueCount,
1196
- count
1197
- };
1198
-
1199
- function sum(_getLeafValues, getChildValues) {
1320
+ const sum = (columnId, _leafRows, childRows) => {
1200
1321
  // It's faster to just add the aggregations together instead of
1201
1322
  // process leaf nodes individually
1202
- return getChildValues().reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
1203
- }
1323
+ return childRows.reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
1324
+ };
1204
1325
 
1205
- function min(_getLeafValues, getChildValues) {
1326
+ const min = (columnId, _leafRows, childRows) => {
1206
1327
  let min;
1328
+ childRows.forEach(row => {
1329
+ const value = row.getValue(columnId);
1207
1330
 
1208
- for (const value of getChildValues()) {
1209
1331
  if (value != null && (min > value || min === undefined && value >= value)) {
1210
1332
  min = value;
1211
1333
  }
1212
- }
1213
-
1334
+ });
1214
1335
  return min;
1215
- }
1336
+ };
1216
1337
 
1217
- function max(_getLeafValues, getChildValues) {
1338
+ const max = (columnId, _leafRows, childRows) => {
1218
1339
  let max;
1340
+ childRows.forEach(row => {
1341
+ const value = row.getValue(columnId);
1219
1342
 
1220
- for (const value of getChildValues()) {
1221
1343
  if (value != null && (max < value || max === undefined && value >= value)) {
1222
1344
  max = value;
1223
1345
  }
1224
- }
1225
-
1346
+ });
1226
1347
  return max;
1227
- }
1348
+ };
1228
1349
 
1229
- function extent(_getLeafValues, getChildValues) {
1350
+ const extent = (columnId, _leafRows, childRows) => {
1230
1351
  let min;
1231
1352
  let max;
1353
+ childRows.forEach(row => {
1354
+ const value = row.getValue(columnId);
1232
1355
 
1233
- for (const value of getChildValues()) {
1234
1356
  if (value != null) {
1235
1357
  if (min === undefined) {
1236
1358
  if (value >= value) min = max = value;
@@ -1239,58 +1361,69 @@
1239
1361
  if (max < value) max = value;
1240
1362
  }
1241
1363
  }
1242
- }
1243
-
1364
+ });
1244
1365
  return [min, max];
1245
- }
1366
+ };
1246
1367
 
1247
- function mean(getLeafValues) {
1368
+ const mean = (columnId, leafRows) => {
1248
1369
  let count = 0;
1249
1370
  let sum = 0;
1371
+ leafRows.forEach(row => {
1372
+ let value = row.getValue(columnId);
1250
1373
 
1251
- for (let value of getLeafValues()) {
1252
1374
  if (value != null && (value = +value) >= value) {
1253
1375
  ++count, sum += value;
1254
1376
  }
1255
- }
1256
-
1377
+ });
1257
1378
  if (count) return sum / count;
1258
1379
  return;
1259
- }
1260
-
1261
- function median(getLeafValues) {
1262
- const leafValues = getLeafValues();
1380
+ };
1263
1381
 
1264
- if (!leafValues.length) {
1382
+ const median = (columnId, leafRows) => {
1383
+ if (!leafRows.length) {
1265
1384
  return;
1266
1385
  }
1267
1386
 
1268
1387
  let min = 0;
1269
1388
  let max = 0;
1270
- leafValues.forEach(value => {
1389
+ leafRows.forEach(row => {
1390
+ let value = row.getValue(columnId);
1391
+
1271
1392
  if (typeof value === 'number') {
1272
1393
  min = Math.min(min, value);
1273
1394
  max = Math.max(max, value);
1274
1395
  }
1275
1396
  });
1276
1397
  return (min + max) / 2;
1277
- }
1398
+ };
1278
1399
 
1279
- function unique(getLeafValues) {
1280
- return Array.from(new Set(getLeafValues()).values());
1281
- }
1400
+ const unique = (columnId, leafRows) => {
1401
+ return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
1402
+ };
1282
1403
 
1283
- function uniqueCount(getLeafValues) {
1284
- return new Set(getLeafValues()).size;
1285
- }
1404
+ const uniqueCount = (columnId, leafRows) => {
1405
+ return new Set(leafRows.map(d => d.getValue(columnId))).size;
1406
+ };
1286
1407
 
1287
- function count(getLeafValues) {
1288
- return getLeafValues().length;
1289
- }
1408
+ const count = (_columnId, leafRows) => {
1409
+ return leafRows.length;
1410
+ };
1411
+
1412
+ const aggregationFns = {
1413
+ sum,
1414
+ min,
1415
+ max,
1416
+ extent,
1417
+ mean,
1418
+ median,
1419
+ unique,
1420
+ uniqueCount,
1421
+ count
1422
+ };
1290
1423
 
1291
1424
  //
1292
1425
  const Grouping = {
1293
- getDefaultColumn: () => {
1426
+ getDefaultColumnDef: () => {
1294
1427
  return {
1295
1428
  aggregationFn: 'auto'
1296
1429
  };
@@ -1320,9 +1453,9 @@
1320
1453
  });
1321
1454
  },
1322
1455
  getCanGroup: () => {
1323
- var _ref, _ref2, _ref3, _column$enableGroupin;
1456
+ var _ref, _ref2, _ref3, _column$columnDef$ena;
1324
1457
 
1325
- return (_ref = (_ref2 = (_ref3 = (_column$enableGroupin = column.enableGrouping) != null ? _column$enableGroupin : true) != null ? _ref3 : instance.options.enableGrouping) != null ? _ref2 : true) != null ? _ref : !!column.accessorFn;
1458
+ 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;
1326
1459
  },
1327
1460
  getIsGrouped: () => {
1328
1461
  var _instance$getState$gr;
@@ -1341,7 +1474,7 @@
1341
1474
  column.toggleGrouping();
1342
1475
  };
1343
1476
  },
1344
- getColumnAutoAggregationFn: () => {
1477
+ getAutoAggregationFn: () => {
1345
1478
  const firstRow = instance.getCoreRowModel().flatRows[0];
1346
1479
  const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
1347
1480
 
@@ -1355,7 +1488,7 @@
1355
1488
 
1356
1489
  return aggregationFns.count;
1357
1490
  },
1358
- getColumnAggregationFn: () => {
1491
+ getAggregationFn: () => {
1359
1492
  var _ref4;
1360
1493
 
1361
1494
  const userAggregationFns = instance.options.aggregationFns;
@@ -1364,7 +1497,7 @@
1364
1497
  throw new Error();
1365
1498
  }
1366
1499
 
1367
- return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.getColumnAutoAggregationFn() : (_ref4 = userAggregationFns == null ? void 0 : userAggregationFns[column.aggregationFn]) != null ? _ref4 : aggregationFns[column.aggregationFn];
1500
+ return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_ref4 = userAggregationFns == null ? void 0 : userAggregationFns[column.aggregationFn]) != null ? _ref4 : aggregationFns[column.aggregationFn];
1368
1501
  }
1369
1502
  };
1370
1503
  },
@@ -1390,10 +1523,10 @@
1390
1523
  }
1391
1524
  };
1392
1525
  },
1393
- createRow: (row, instance) => {
1526
+ createRow: row => {
1394
1527
  return {
1395
1528
  getIsGrouped: () => !!row.groupingColumnId,
1396
- groupingValuesCache: {}
1529
+ _groupingValuesCache: {}
1397
1530
  };
1398
1531
  },
1399
1532
  createCell: (cell, column, row, instance) => {
@@ -1406,9 +1539,9 @@
1406
1539
  return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
1407
1540
  },
1408
1541
  renderAggregatedCell: () => {
1409
- var _column$aggregatedCel;
1542
+ var _column$columnDef$agg;
1410
1543
 
1411
- const template = (_column$aggregatedCel = column.aggregatedCell) != null ? _column$aggregatedCel : column.cell;
1544
+ const template = (_column$columnDef$agg = column.columnDef.aggregatedCell) != null ? _column$columnDef$agg : column.columnDef.cell;
1412
1545
  return template ? instance._render(template, {
1413
1546
  instance,
1414
1547
  column,
@@ -1715,9 +1848,9 @@
1715
1848
  getCanPin: () => {
1716
1849
  const leafColumns = column.getLeafColumns();
1717
1850
  return leafColumns.some(d => {
1718
- var _d$enablePinning, _instance$options$ena;
1851
+ var _d$columnDef$enablePi, _instance$options$ena;
1719
1852
 
1720
- return ((_d$enablePinning = d.enablePinning) != null ? _d$enablePinning : true) && ((_instance$options$ena = instance.options.enablePinning) != null ? _instance$options$ena : true);
1853
+ return ((_d$columnDef$enablePi = d.columnDef.enablePinning) != null ? _d$columnDef$enablePi : true) && ((_instance$options$ena = instance.options.enablePinning) != null ? _instance$options$ena : true);
1721
1854
  });
1722
1855
  },
1723
1856
  getIsPinned: () => {
@@ -1742,7 +1875,7 @@
1742
1875
  return {
1743
1876
  getCenterVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allCells, left, right) => {
1744
1877
  const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
1745
- return allCells.filter(d => !leftAndRight.includes(d.columnId));
1878
+ return allCells.filter(d => !leftAndRight.includes(d.column.id));
1746
1879
  }, {
1747
1880
  key: "development" === 'production' ,
1748
1881
  debug: () => {
@@ -1752,7 +1885,7 @@
1752
1885
  }
1753
1886
  }),
1754
1887
  getLeftVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left,,], (allCells, left) => {
1755
- const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.columnId === columnId)).filter(Boolean).map(d => ({ ...d,
1888
+ const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
1756
1889
  position: 'left'
1757
1890
  }));
1758
1891
  return cells;
@@ -1765,7 +1898,7 @@
1765
1898
  }
1766
1899
  }),
1767
1900
  getRightVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.right], (allCells, right) => {
1768
- const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.columnId === columnId)).filter(Boolean).map(d => ({ ...d,
1901
+ const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
1769
1902
  position: 'left'
1770
1903
  }));
1771
1904
  return cells;
@@ -1787,12 +1920,18 @@
1787
1920
 
1788
1921
  return instance.setColumnPinning(defaultState ? getDefaultPinningState() : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.columnPinning) != null ? _instance$initialStat : getDefaultPinningState());
1789
1922
  },
1790
- getIsSomeColumnsPinned: () => {
1791
- const {
1792
- left,
1793
- right
1794
- } = instance.getState().columnPinning;
1795
- return Boolean((left == null ? void 0 : left.length) || (right == null ? void 0 : right.length));
1923
+ getIsSomeColumnsPinned: position => {
1924
+ var _pinningState$positio;
1925
+
1926
+ const pinningState = instance.getState().columnPinning;
1927
+
1928
+ if (!position) {
1929
+ var _pinningState$left, _pinningState$right;
1930
+
1931
+ return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
1932
+ }
1933
+
1934
+ return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
1796
1935
  },
1797
1936
  getLeftLeafColumns: memo(() => [instance.getAllLeafColumns(), instance.getState().columnPinning.left], (allColumns, left) => {
1798
1937
  return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
@@ -2318,7 +2457,7 @@
2318
2457
  ...state
2319
2458
  };
2320
2459
  },
2321
- getDefaultColumn: () => {
2460
+ getDefaultColumnDef: () => {
2322
2461
  return {
2323
2462
  sortingFn: 'auto'
2324
2463
  };
@@ -2378,7 +2517,7 @@
2378
2517
  throw new Error();
2379
2518
  }
2380
2519
 
2381
- return isFunction(column.sortingFn) ? column.sortingFn : column.sortingFn === 'auto' ? column.getAutoSortingFn() : (_ref = userSortingFn == null ? void 0 : userSortingFn[column.sortingFn]) != null ? _ref : sortingFns[column.sortingFn];
2520
+ 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];
2382
2521
  },
2383
2522
  toggleSorting: (desc, multi) => {
2384
2523
  // if (column.columns.length) {
@@ -2390,7 +2529,7 @@
2390
2529
  // return
2391
2530
  // }
2392
2531
  instance.setSorting(old => {
2393
- var _ref2, _column$sortDescFirst, _instance$options$ena, _instance$options$ena2;
2532
+ var _ref2, _column$columnDef$sor, _instance$options$ena, _instance$options$ena2;
2394
2533
 
2395
2534
  // Find any existing sorting for this column
2396
2535
  const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
@@ -2417,7 +2556,7 @@
2417
2556
  }
2418
2557
  }
2419
2558
 
2420
- 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
2559
+ 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
2421
2560
 
2422
2561
  if (sortAction === 'toggle' && ( // Must be toggling
2423
2562
  (_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
@@ -2461,14 +2600,14 @@
2461
2600
  });
2462
2601
  },
2463
2602
  getCanSort: () => {
2464
- var _column$enableSorting, _instance$options$ena3;
2603
+ var _column$columnDef$ena, _instance$options$ena3;
2465
2604
 
2466
- return ((_column$enableSorting = column.enableSorting) != null ? _column$enableSorting : true) && ((_instance$options$ena3 = instance.options.enableSorting) != null ? _instance$options$ena3 : true) && !!column.accessorFn;
2605
+ 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;
2467
2606
  },
2468
2607
  getCanMultiSort: () => {
2469
- var _ref3, _column$enableMultiSo;
2608
+ var _ref3, _column$columnDef$ena2;
2470
2609
 
2471
- return (_ref3 = (_column$enableMultiSo = column.enableMultiSort) != null ? _column$enableMultiSo : instance.options.enableMultiSort) != null ? _ref3 : !!column.accessorFn;
2610
+ return (_ref3 = (_column$columnDef$ena2 = column.columnDef.enableMultiSort) != null ? _column$columnDef$ena2 : instance.options.enableMultiSort) != null ? _ref3 : !!column.accessorFn;
2472
2611
  },
2473
2612
  getIsSorted: () => {
2474
2613
  var _instance$getState$so;
@@ -2532,7 +2671,7 @@
2532
2671
  onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
2533
2672
  };
2534
2673
  },
2535
- getDefaultColumn: () => {
2674
+ getDefaultColumnDef: () => {
2536
2675
  return {
2537
2676
  defaultIsVisible: true
2538
2677
  };
@@ -2552,9 +2691,9 @@
2552
2691
  return (_instance$getState$co = (_instance$getState$co2 = instance.getState().columnVisibility) == null ? void 0 : _instance$getState$co2[column.id]) != null ? _instance$getState$co : true;
2553
2692
  },
2554
2693
  getCanHide: () => {
2555
- var _column$enableHiding, _instance$options$ena;
2694
+ var _column$columnDef$ena, _instance$options$ena;
2556
2695
 
2557
- return ((_column$enableHiding = column.enableHiding) != null ? _column$enableHiding : true) && ((_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : true);
2696
+ return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : true);
2558
2697
  },
2559
2698
  getToggleVisibilityHandler: () => {
2560
2699
  return e => {
@@ -2568,477 +2707,72 @@
2568
2707
  _getAllVisibleCells: memo(() => [row.getAllCells().filter(cell => cell.column.getIsVisible()).map(d => d.id).join('_')], _ => {
2569
2708
  return row.getAllCells().filter(cell => cell.column.getIsVisible());
2570
2709
  }, {
2571
- key: "development" === 'production' ,
2572
- debug: () => {
2573
- var _instance$options$deb;
2574
-
2575
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
2576
- }
2577
- }),
2578
- getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
2579
- key: 'row.getVisibleCells',
2580
- debug: () => {
2581
- var _instance$options$deb2;
2582
-
2583
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
2584
- }
2585
- })
2586
- };
2587
- },
2588
- createInstance: instance => {
2589
- const makeVisibleColumnsMethod = (key, getColumns) => {
2590
- return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
2591
- return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
2592
- }, {
2593
- key,
2594
- debug: () => {
2595
- var _instance$options$deb3;
2596
-
2597
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2598
- }
2599
- });
2600
- };
2601
-
2602
- return {
2603
- getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
2604
- getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
2605
- getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
2606
- getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
2607
- getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
2608
- setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
2609
- resetColumnVisibility: defaultState => {
2610
- var _instance$initialStat;
2611
-
2612
- instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
2613
- },
2614
- toggleAllColumnsVisible: value => {
2615
- var _value;
2616
-
2617
- value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
2618
- instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
2619
- [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
2620
- }), {}));
2621
- },
2622
- getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
2623
- getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
2624
- getToggleAllColumnsVisibilityHandler: () => {
2625
- return e => {
2626
- var _target;
2627
-
2628
- instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
2629
- };
2630
- }
2631
- };
2632
- }
2633
- };
2634
-
2635
- //
2636
- const Headers = {
2637
- createInstance: instance => {
2638
- return {
2639
- createHeader: (column, options) => {
2640
- var _options$id;
2641
-
2642
- const id = (_options$id = options.id) != null ? _options$id : column.id;
2643
- let header = {
2644
- id,
2645
- column,
2646
- index: options.index,
2647
- isPlaceholder: options.isPlaceholder,
2648
- placeholderId: options.placeholderId,
2649
- depth: options.depth,
2650
- subHeaders: [],
2651
- colSpan: 0,
2652
- rowSpan: 0,
2653
- headerGroup: null,
2654
- getLeafHeaders: () => {
2655
- const leafHeaders = [];
2656
-
2657
- const recurseHeader = h => {
2658
- if (h.subHeaders && h.subHeaders.length) {
2659
- h.subHeaders.map(recurseHeader);
2660
- }
2661
-
2662
- leafHeaders.push(h);
2663
- };
2664
-
2665
- recurseHeader(header);
2666
- return leafHeaders;
2667
- },
2668
- renderHeader: () => column.header ? instance._render(column.header, {
2669
- instance,
2670
- header: header,
2671
- column
2672
- }) : null,
2673
- renderFooter: () => column.footer ? instance._render(column.footer, {
2674
- instance,
2675
- header: header,
2676
- column
2677
- }) : null
2678
- };
2679
-
2680
- instance._features.forEach(feature => {
2681
- Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
2682
- });
2683
-
2684
- return header;
2685
- },
2686
- // Header Groups
2687
- getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2688
- var _left$map$filter, _right$map$filter;
2689
-
2690
- const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
2691
- const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
2692
- const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2693
- const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
2694
- return headerGroups;
2695
- }, {
2696
- key: 'getHeaderGroups',
2697
- debug: () => {
2698
- var _instance$options$deb;
2699
-
2700
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
2701
- }
2702
- }),
2703
- getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2704
- leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2705
- return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
2706
- }, {
2707
- key: 'getCenterHeaderGroups',
2708
- debug: () => {
2709
- var _instance$options$deb2;
2710
-
2711
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
2712
- }
2713
- }),
2714
- getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
2715
- var _left$map$filter2;
2716
-
2717
- const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
2718
- return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
2719
- }, {
2720
- key: 'getLeftHeaderGroups',
2721
- debug: () => {
2722
- var _instance$options$deb3;
2723
-
2724
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
2725
- }
2726
- }),
2727
- getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
2728
- var _right$map$filter2;
2729
-
2730
- const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
2731
- return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
2732
- }, {
2733
- key: 'getRightHeaderGroups',
2734
- debug: () => {
2735
- var _instance$options$deb4;
2736
-
2737
- return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
2738
- }
2739
- }),
2740
- // Footer Groups
2741
- getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
2742
- return [...headerGroups].reverse();
2743
- }, {
2744
- key: 'getFooterGroups',
2745
- debug: () => {
2746
- var _instance$options$deb5;
2747
-
2748
- return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
2749
- }
2750
- }),
2751
- getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
2752
- return [...headerGroups].reverse();
2753
- }, {
2754
- key: 'getLeftFooterGroups',
2755
- debug: () => {
2756
- var _instance$options$deb6;
2757
-
2758
- return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
2759
- }
2760
- }),
2761
- getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
2762
- return [...headerGroups].reverse();
2763
- }, {
2764
- key: 'getCenterFooterGroups',
2765
- debug: () => {
2766
- var _instance$options$deb7;
2767
-
2768
- return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
2769
- }
2770
- }),
2771
- getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
2772
- return [...headerGroups].reverse();
2773
- }, {
2774
- key: 'getRightFooterGroups',
2775
- debug: () => {
2776
- var _instance$options$deb8;
2777
-
2778
- return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
2779
- }
2780
- }),
2781
- // Flat Headers
2782
- getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
2783
- return headerGroups.map(headerGroup => {
2784
- return headerGroup.headers;
2785
- }).flat();
2786
- }, {
2787
- key: 'getFlatHeaders',
2788
- debug: () => {
2789
- var _instance$options$deb9;
2790
-
2791
- return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
2792
- }
2793
- }),
2794
- getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
2795
- return left.map(headerGroup => {
2796
- return headerGroup.headers;
2797
- }).flat();
2798
- }, {
2799
- key: 'getLeftFlatHeaders',
2800
- debug: () => {
2801
- var _instance$options$deb10;
2802
-
2803
- return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
2804
- }
2805
- }),
2806
- getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
2807
- return left.map(headerGroup => {
2808
- return headerGroup.headers;
2809
- }).flat();
2810
- }, {
2811
- key: 'getCenterFlatHeaders',
2812
- debug: () => {
2813
- var _instance$options$deb11;
2814
-
2815
- return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
2816
- }
2817
- }),
2818
- getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
2819
- return left.map(headerGroup => {
2820
- return headerGroup.headers;
2821
- }).flat();
2822
- }, {
2823
- key: 'getRightFlatHeaders',
2824
- debug: () => {
2825
- var _instance$options$deb12;
2826
-
2827
- return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
2828
- }
2829
- }),
2830
- // Leaf Headers
2831
- getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
2832
- return flatHeaders.filter(header => {
2833
- var _header$subHeaders;
2834
-
2835
- return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
2836
- });
2837
- }, {
2838
- key: 'getCenterLeafHeaders',
2839
- debug: () => {
2840
- var _instance$options$deb13;
2841
-
2842
- return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
2843
- }
2844
- }),
2845
- getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
2846
- return flatHeaders.filter(header => {
2847
- var _header$subHeaders2;
2848
-
2849
- return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
2850
- });
2851
- }, {
2852
- key: 'getLeftLeafHeaders',
2853
- debug: () => {
2854
- var _instance$options$deb14;
2855
-
2856
- return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
2857
- }
2858
- }),
2859
- getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
2860
- return flatHeaders.filter(header => {
2861
- var _header$subHeaders3;
2862
-
2863
- return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
2864
- });
2865
- }, {
2866
- key: 'getRightLeafHeaders',
2710
+ key: "development" === 'production' ,
2867
2711
  debug: () => {
2868
- var _instance$options$deb15;
2712
+ var _instance$options$deb;
2869
2713
 
2870
- return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
2714
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
2871
2715
  }
2872
2716
  }),
2873
- getLeafHeaders: memo(() => [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()], (left, center, right) => {
2874
- var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
2717
+ getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
2718
+ key: 'row.getVisibleCells',
2719
+ debug: () => {
2720
+ var _instance$options$deb2;
2875
2721
 
2876
- 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 => {
2877
- return header.getLeafHeaders();
2878
- }).flat();
2722
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
2723
+ }
2724
+ })
2725
+ };
2726
+ },
2727
+ createInstance: instance => {
2728
+ const makeVisibleColumnsMethod = (key, getColumns) => {
2729
+ return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
2730
+ return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
2879
2731
  }, {
2880
- key: 'getLeafHeaders',
2732
+ key,
2881
2733
  debug: () => {
2882
- var _instance$options$deb16;
2734
+ var _instance$options$deb3;
2883
2735
 
2884
- return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
2736
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2885
2737
  }
2886
- }),
2887
- getHeader: id => {
2888
- const header = [...instance.getFlatHeaders(), ...instance.getCenterFlatHeaders(), ...instance.getLeftFlatHeaders(), ...instance.getRightFlatHeaders()].find(d => d.id === id);
2738
+ });
2739
+ };
2889
2740
 
2890
- if (!header) {
2891
- {
2892
- console.warn("Could not find header with id: " + id);
2893
- }
2741
+ return {
2742
+ getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
2743
+ getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
2744
+ getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
2745
+ getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
2746
+ getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
2747
+ setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
2748
+ resetColumnVisibility: defaultState => {
2749
+ var _instance$initialStat;
2894
2750
 
2895
- throw new Error();
2896
- }
2751
+ instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
2752
+ },
2753
+ toggleAllColumnsVisible: value => {
2754
+ var _value;
2897
2755
 
2898
- return header;
2756
+ value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
2757
+ instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
2758
+ [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
2759
+ }), {}));
2760
+ },
2761
+ getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
2762
+ getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
2763
+ getToggleAllColumnsVisibilityHandler: () => {
2764
+ return e => {
2765
+ var _target;
2766
+
2767
+ instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
2768
+ };
2899
2769
  }
2900
2770
  };
2901
2771
  }
2902
2772
  };
2903
- function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
2904
- var _headerGroups$0$heade, _headerGroups$;
2905
-
2906
- // Find the max depth of the columns:
2907
- // build the leaf column row
2908
- // build each buffer row going up
2909
- // placeholder for non-existent level
2910
- // real column for existing level
2911
- let maxDepth = 0;
2912
-
2913
- const findMaxDepth = function (columns, depth) {
2914
- if (depth === void 0) {
2915
- depth = 1;
2916
- }
2917
-
2918
- maxDepth = Math.max(maxDepth, depth);
2919
- columns.filter(column => column.getIsVisible()).forEach(column => {
2920
- var _column$columns;
2921
-
2922
- if ((_column$columns = column.columns) != null && _column$columns.length) {
2923
- findMaxDepth(column.columns, depth + 1);
2924
- }
2925
- }, 0);
2926
- };
2927
-
2928
- findMaxDepth(allColumns);
2929
- let headerGroups = [];
2930
-
2931
- const createHeaderGroup = (headersToGroup, depth) => {
2932
- // The header group we are creating
2933
- const headerGroup = {
2934
- depth,
2935
- id: [headerFamily, "" + depth].filter(Boolean).join('_'),
2936
- headers: []
2937
- }; // The parent columns we're going to scan next
2938
-
2939
- const pendingParentHeaders = []; // Scan each column for parents
2940
-
2941
- headersToGroup.forEach(headerToGroup => {
2942
- // What is the latest (last) parent column?
2943
- const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
2944
- const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
2945
- let column;
2946
- let isPlaceholder = false;
2947
-
2948
- if (isLeafHeader && headerToGroup.column.parent) {
2949
- // The parent header is new
2950
- column = headerToGroup.column.parent;
2951
- } else {
2952
- // The parent header is repeated
2953
- column = headerToGroup.column;
2954
- isPlaceholder = true;
2955
- }
2956
-
2957
- if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
2958
- // This column is repeated. Add it as a sub header to the next batch
2959
- latestPendingParentHeader.subHeaders.push(headerToGroup);
2960
- } else {
2961
- // This is a new header. Let's create it
2962
- const header = instance.createHeader(column, {
2963
- id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
2964
- isPlaceholder,
2965
- placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
2966
- depth,
2967
- index: pendingParentHeaders.length
2968
- }); // Add the headerToGroup as a subHeader of the new header
2969
-
2970
- header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
2971
- // in the next batch
2972
-
2973
- pendingParentHeaders.push(header);
2974
- }
2975
-
2976
- headerGroup.headers.push(headerToGroup);
2977
- headerToGroup.headerGroup = headerGroup;
2978
- });
2979
- headerGroups.push(headerGroup);
2980
-
2981
- if (depth > 0) {
2982
- createHeaderGroup(pendingParentHeaders, depth - 1);
2983
- }
2984
- };
2985
-
2986
- const bottomHeaders = columnsToGroup.map((column, index) => instance.createHeader(column, {
2987
- depth: maxDepth,
2988
- index
2989
- }));
2990
- createHeaderGroup(bottomHeaders, maxDepth - 1);
2991
- headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
2992
- // return !headerGroup.headers.every(header => header.isPlaceholder)
2993
- // })
2994
-
2995
- const recurseHeadersForSpans = headers => {
2996
- const filteredHeaders = headers.filter(header => header.column.getIsVisible());
2997
- return filteredHeaders.map(header => {
2998
- let colSpan = 0;
2999
- let rowSpan = 0;
3000
- let childRowSpans = [0];
3001
-
3002
- if (header.subHeaders && header.subHeaders.length) {
3003
- childRowSpans = [];
3004
- recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
3005
- let {
3006
- colSpan: childColSpan,
3007
- rowSpan: childRowSpan
3008
- } = _ref;
3009
- colSpan += childColSpan;
3010
- childRowSpans.push(childRowSpan);
3011
- });
3012
- } else {
3013
- colSpan = 1;
3014
- }
3015
-
3016
- const minChildRowSpan = Math.min(...childRowSpans);
3017
- rowSpan = rowSpan + minChildRowSpan;
3018
- header.colSpan = colSpan > 0 ? colSpan : undefined;
3019
- header.rowSpan = rowSpan > 0 ? rowSpan : undefined;
3020
- return {
3021
- colSpan,
3022
- rowSpan
3023
- };
3024
- });
3025
- };
3026
2773
 
3027
- recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
3028
- return headerGroups;
3029
- }
2774
+ const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]; //
3030
2775
 
3031
- // export type Batch = {
3032
- // id: number
3033
- // priority: keyof CoreBatches
3034
- // tasks: (() => void)[]
3035
- // schedule: (cb: () => void) => void
3036
- // cancel: () => void
3037
- // }
3038
- // type CoreBatches = {
3039
- // data: Batch[]
3040
- // facets: Batch[]
3041
- // }
3042
2776
  function createTableInstance$1(options) {
3043
2777
  var _options$initialState;
3044
2778
 
@@ -3047,7 +2781,7 @@
3047
2781
  }
3048
2782
 
3049
2783
  let instance = {
3050
- _features: [Columns, Rows, Cells, Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]
2784
+ _features: features
3051
2785
  };
3052
2786
 
3053
2787
  const defaultOptions = instance._features.reduce((obj, feature) => {
@@ -3064,8 +2798,7 @@
3064
2798
  };
3065
2799
  };
3066
2800
 
3067
- const coreInitialState = {// coreProgress: 1,
3068
- };
2801
+ const coreInitialState = {};
3069
2802
  let initialState = { ...coreInitialState,
3070
2803
  ...((_options$initialState = options.initialState) != null ? _options$initialState : {})
3071
2804
  };
@@ -3078,16 +2811,8 @@
3078
2811
 
3079
2812
  const queued = [];
3080
2813
  let queuedTimeout = false;
3081
- const midInstance = { ...instance,
3082
- // init: () => {
3083
- // startWork()
3084
- // },
3085
- // willUpdate: () => {
3086
- // startWork()
3087
- // },
3088
- // destroy: () => {
3089
- // stopWork()
3090
- // },
2814
+ const coreInstance = {
2815
+ _features: features,
3091
2816
  options: { ...defaultOptions,
3092
2817
  ...options
3093
2818
  },
@@ -3133,29 +2858,134 @@
3133
2858
  },
3134
2859
  setState: updater => {
3135
2860
  instance.options.onStateChange == null ? void 0 : instance.options.onStateChange(updater);
3136
- } // getOverallProgress: () => {
3137
- // const { coreProgress, filtersProgress, facetProgress } =
3138
- // instance.getState()
3139
- // return mean(() =>
3140
- // [coreProgress, filtersProgress].filter(d => d < 1)
3141
- // ) as number
3142
- // },
3143
- // getProgressStage: () => {
3144
- // const { coreProgress, filtersProgress, facetProgress } =
3145
- // instance.getState()
3146
- // if (coreProgress < 1) {
3147
- // return 'coreRowModel'
3148
- // }
3149
- // if (filtersProgress < 1) {
3150
- // return 'filteredRowModel'
3151
- // }
3152
- // if (Object.values(facetProgress).some(d => d < 1)) {
3153
- // return 'facetedRowModel'
3154
- // }
3155
- // },
2861
+ },
2862
+ _getRowId: (row, index, parent) => {
2863
+ var _instance$options$get;
2864
+
2865
+ 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);
2866
+ },
2867
+ getCoreRowModel: () => {
2868
+ if (!instance._getCoreRowModel) {
2869
+ instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
2870
+ }
2871
+
2872
+ return instance._getCoreRowModel();
2873
+ },
2874
+ // The final calls start at the bottom of the model,
2875
+ // expanded rows, which then work their way up
2876
+ getRowModel: () => {
2877
+ return instance.getPaginationRowModel();
2878
+ },
2879
+ getRow: id => {
2880
+ const row = instance.getRowModel().rowsById[id];
2881
+
2882
+ if (!row) {
2883
+ {
2884
+ throw new Error("getRow expected an ID, but got " + id);
2885
+ }
2886
+ }
2887
+
2888
+ return row;
2889
+ },
2890
+ _getDefaultColumnDef: memo(() => [instance.options.defaultColumn], defaultColumn => {
2891
+ var _defaultColumn;
2892
+
2893
+ defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
2894
+ return {
2895
+ header: props => props.header.column.id,
2896
+ footer: props => props.header.column.id,
2897
+ cell: props => {
2898
+ var _props$getValue$toStr, _props$getValue$toStr2, _props$getValue;
2899
+
2900
+ 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;
2901
+ },
2902
+ ...instance._features.reduce((obj, feature) => {
2903
+ return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
2904
+ }, {}),
2905
+ ...defaultColumn
2906
+ };
2907
+ }, {
2908
+ debug: () => {
2909
+ var _instance$options$deb;
2910
+
2911
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
2912
+ },
2913
+ key: 'getDefaultColumnDef'
2914
+ }),
2915
+ _getColumnDefs: () => instance.options.columns,
2916
+ getAllColumns: memo(() => [instance._getColumnDefs()], columnDefs => {
2917
+ const recurseColumns = function (columnDefs, parent, depth) {
2918
+ if (depth === void 0) {
2919
+ depth = 0;
2920
+ }
2921
+
2922
+ return columnDefs.map(columnDef => {
2923
+ const column = createColumn(instance, columnDef, depth, parent);
2924
+ column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
2925
+ return column;
2926
+ });
2927
+ };
2928
+
2929
+ return recurseColumns(columnDefs);
2930
+ }, {
2931
+ key: 'getAllColumns',
2932
+ debug: () => {
2933
+ var _instance$options$deb2;
2934
+
2935
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
2936
+ }
2937
+ }),
2938
+ getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
2939
+ return allColumns.flatMap(column => {
2940
+ return column.getFlatColumns();
2941
+ });
2942
+ }, {
2943
+ key: 'getAllFlatColumns',
2944
+ debug: () => {
2945
+ var _instance$options$deb3;
2946
+
2947
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2948
+ }
2949
+ }),
2950
+ _getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
2951
+ return flatColumns.reduce((acc, column) => {
2952
+ acc[column.id] = column;
2953
+ return acc;
2954
+ }, {});
2955
+ }, {
2956
+ key: 'getAllFlatColumnsById',
2957
+ debug: () => {
2958
+ var _instance$options$deb4;
2959
+
2960
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
2961
+ }
2962
+ }),
2963
+ getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
2964
+ let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
2965
+ return orderColumns(leafColumns);
2966
+ }, {
2967
+ key: 'getAllLeafColumns',
2968
+ debug: () => {
2969
+ var _instance$options$deb5;
2970
+
2971
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
2972
+ }
2973
+ }),
2974
+ getColumn: columnId => {
2975
+ const column = instance._getAllFlatColumnsById()[columnId];
2976
+
2977
+ if (!column) {
2978
+ {
2979
+ console.warn("[Table] Column with id " + columnId + " does not exist.");
2980
+ }
2981
+
2982
+ throw new Error();
2983
+ }
3156
2984
 
2985
+ return column;
2986
+ }
3157
2987
  };
3158
- instance = Object.assign(instance, midInstance);
2988
+ Object.assign(instance, coreInstance);
3159
2989
 
3160
2990
  instance._features.forEach(feature => {
3161
2991
  return Object.assign(instance, feature.createInstance == null ? void 0 : feature.createInstance(instance));
@@ -3178,7 +3008,7 @@
3178
3008
  throw new Error('');
3179
3009
  })()
3180
3010
  },
3181
- setGenerics: () => table,
3011
+ // setGenerics: () => table as any,
3182
3012
  setRowType: () => table,
3183
3013
  setTableMetaType: () => table,
3184
3014
  setColumnMetaType: () => table,
@@ -3214,11 +3044,92 @@
3214
3044
  }
3215
3045
 
3216
3046
  throw new Error('Invalid accessor');
3217
- }
3047
+ },
3048
+ createOptions: options => options
3218
3049
  };
3219
3050
  return table;
3220
3051
  }
3221
3052
 
3053
+ function createCell(instance, row, column, columnId) {
3054
+ const cell = {
3055
+ id: row.id + "_" + column.id,
3056
+ row,
3057
+ column,
3058
+ getValue: () => row.getValue(columnId),
3059
+ renderCell: () => column.columnDef.cell ? instance._render(column.columnDef.cell, {
3060
+ instance,
3061
+ column,
3062
+ row,
3063
+ cell: cell,
3064
+ getValue: cell.getValue
3065
+ }) : null
3066
+ };
3067
+
3068
+ instance._features.forEach(feature => {
3069
+ Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
3070
+ }, {});
3071
+
3072
+ return cell;
3073
+ }
3074
+
3075
+ const createRow = (instance, id, original, rowIndex, depth, subRows) => {
3076
+ let row = {
3077
+ id,
3078
+ index: rowIndex,
3079
+ original,
3080
+ depth,
3081
+ _valuesCache: {},
3082
+ getValue: columnId => {
3083
+ if (row._valuesCache.hasOwnProperty(columnId)) {
3084
+ return row._valuesCache[columnId];
3085
+ }
3086
+
3087
+ const column = instance.getColumn(columnId);
3088
+
3089
+ if (!column.accessorFn) {
3090
+ return undefined;
3091
+ }
3092
+
3093
+ row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
3094
+ return row._valuesCache[columnId];
3095
+ },
3096
+ subRows: subRows != null ? subRows : [],
3097
+ getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
3098
+ getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
3099
+ return leafColumns.map(column => {
3100
+ return createCell(instance, row, column, column.id);
3101
+ });
3102
+ }, {
3103
+ key: 'row.getAllCells',
3104
+ debug: () => {
3105
+ var _instance$options$deb;
3106
+
3107
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
3108
+ }
3109
+ }),
3110
+ _getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
3111
+ return allCells.reduce((acc, cell) => {
3112
+ acc[cell.column.id] = cell;
3113
+ return acc;
3114
+ }, {});
3115
+ }, {
3116
+ key: "development" === 'production' ,
3117
+ debug: () => {
3118
+ var _instance$options$deb2;
3119
+
3120
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
3121
+ }
3122
+ })
3123
+ };
3124
+
3125
+ for (let i = 0; i < instance._features.length; i++) {
3126
+ const feature = instance._features[i];
3127
+ Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
3128
+ }
3129
+
3130
+ return row;
3131
+ };
3132
+
3222
3133
  function getCoreRowModel() {
3223
3134
  return instance => memo(() => [instance.options.data], data => {
3224
3135
  const rowModel = {
@@ -3246,7 +3157,7 @@
3246
3157
  // }
3247
3158
  // Make the row
3248
3159
 
3249
- row = instance.createRow(instance.getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3160
+ row = createRow(instance, instance._getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3250
3161
 
3251
3162
  rowModel.flatRows.push(row); // Also keep track of every row by its ID
3252
3163
 
@@ -3309,7 +3220,7 @@
3309
3220
  row = rowsToFilter[i];
3310
3221
 
3311
3222
  if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
3312
- newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3223
+ newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3313
3224
  newRow.columnFilters = row.columnFilters;
3314
3225
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3315
3226
 
@@ -3359,7 +3270,7 @@
3359
3270
  var _row$subRows2;
3360
3271
 
3361
3272
  if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
3362
- newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3273
+ newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3363
3274
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3364
3275
  row = newRow;
3365
3276
  }
@@ -3611,8 +3522,8 @@
3611
3522
  availableSorting.forEach(sortEntry => {
3612
3523
  const column = instance.getColumn(sortEntry.id);
3613
3524
  columnInfoById[sortEntry.id] = {
3614
- sortUndefined: column.sortUndefined,
3615
- invertSorting: column.invertSorting,
3525
+ sortUndefined: column.columnDef.sortUndefined,
3526
+ invertSorting: column.columnDef.invertSorting,
3616
3527
  sortingFn: column.getSortingFn()
3617
3528
  };
3618
3529
  });
@@ -3726,7 +3637,7 @@
3726
3637
  const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
3727
3638
 
3728
3639
  const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
3729
- const row = instance.createRow(id, undefined, index, depth);
3640
+ const row = createRow(instance, id, undefined, index, depth);
3730
3641
  Object.assign(row, {
3731
3642
  groupingColumnId: columnId,
3732
3643
  groupingValue,
@@ -3735,38 +3646,30 @@
3735
3646
  getValue: columnId => {
3736
3647
  // Don't aggregate columns that are in the grouping
3737
3648
  if (existingGrouping.includes(columnId)) {
3738
- if (row.valuesCache.hasOwnProperty(columnId)) {
3739
- return row.valuesCache[columnId];
3649
+ if (row._valuesCache.hasOwnProperty(columnId)) {
3650
+ return row._valuesCache[columnId];
3740
3651
  }
3741
3652
 
3742
3653
  if (groupedRows[0]) {
3743
3654
  var _groupedRows$0$getVal;
3744
3655
 
3745
- row.valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
3656
+ row._valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
3746
3657
  }
3747
3658
 
3748
- return row.valuesCache[columnId];
3659
+ return row._valuesCache[columnId];
3749
3660
  }
3750
3661
 
3751
- if (row.groupingValuesCache.hasOwnProperty(columnId)) {
3752
- return row.groupingValuesCache[columnId];
3662
+ if (row._groupingValuesCache.hasOwnProperty(columnId)) {
3663
+ return row._groupingValuesCache[columnId];
3753
3664
  } // Aggregate the values
3754
3665
 
3755
3666
 
3756
3667
  const column = instance.getColumn(columnId);
3757
- const aggregateFn = column.getColumnAggregationFn();
3668
+ const aggregateFn = column.getAggregationFn();
3758
3669
 
3759
3670
  if (aggregateFn) {
3760
- row.groupingValuesCache[columnId] = aggregateFn(() => leafRows.map(row => {
3761
- let columnValue = row.getValue(columnId);
3762
-
3763
- if (!depth && column.aggregateValue) {
3764
- columnValue = column.aggregateValue(columnValue);
3765
- }
3766
-
3767
- return columnValue;
3768
- }), () => groupedRows.map(row => row.getValue(columnId)));
3769
- return row.groupingValuesCache[columnId];
3671
+ row._groupingValuesCache[columnId] = aggregateFn(columnId, leafRows, groupedRows);
3672
+ return row._groupingValuesCache[columnId];
3770
3673
  } else if (column.aggregationFn) {
3771
3674
  console.info({
3772
3675
  column
@@ -4128,6 +4031,8 @@
4128
4031
  exports.Visibility = Visibility;
4129
4032
  exports.aggregationFns = aggregationFns;
4130
4033
  exports.buildHeaderGroups = buildHeaderGroups;
4034
+ exports.createColumn = createColumn;
4035
+ exports.createRow = createRow;
4131
4036
  exports.createTable = createTable;
4132
4037
  exports.createTableFactory = createTableFactory;
4133
4038
  exports.createTableInstance = createTableInstance;
@@ -4148,7 +4053,6 @@
4148
4053
  exports.isFunction = isFunction;
4149
4054
  exports.isRowSelected = isRowSelected;
4150
4055
  exports.makeStateUpdater = makeStateUpdater;
4151
- exports.mean = mean;
4152
4056
  exports.memo = memo;
4153
4057
  exports.noop = noop;
4154
4058
  exports.orderColumns = orderColumns;