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