@tanstack/react-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.
@@ -97,335 +97,459 @@ function memo(getDeps, fn, opts) {
97
97
  };
98
98
  }
99
99
 
100
+ function createColumn(instance, columnDef, depth, parent) {
101
+ var _ref, _columnDef$id;
102
+
103
+ const defaultColumn = instance._getDefaultColumnDef();
104
+
105
+ columnDef = { ...defaultColumn,
106
+ ...columnDef
107
+ };
108
+ let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
109
+ let accessorFn;
110
+
111
+ if (columnDef.accessorFn) {
112
+ accessorFn = columnDef.accessorFn;
113
+ } else if (columnDef.accessorKey) {
114
+ accessorFn = originalRow => originalRow[columnDef.accessorKey];
115
+ }
116
+
117
+ if (!id) {
118
+ if (process.env.NODE_ENV !== 'production') {
119
+ throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
120
+ }
121
+
122
+ throw new Error();
123
+ }
124
+
125
+ let column = { ...columnDef,
126
+ id: "" + id,
127
+ accessorFn,
128
+ parent: parent,
129
+ depth,
130
+ columnDef,
131
+ columnDefType: columnDef.columnDefType,
132
+ columns: [],
133
+ getFlatColumns: memo(() => [true], () => {
134
+ var _column$columns;
135
+
136
+ return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
137
+ }, {
138
+ key: process.env.NODE_ENV === 'production' && 'column.getFlatColumns',
139
+ debug: () => {
140
+ var _instance$options$deb;
141
+
142
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
143
+ }
144
+ }),
145
+ getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
146
+ var _column$columns2;
147
+
148
+ if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
149
+ let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
150
+ return orderColumns(leafColumns);
151
+ }
152
+
153
+ return [column];
154
+ }, {
155
+ key: process.env.NODE_ENV === 'production' && 'column.getLeafColumns',
156
+ debug: () => {
157
+ var _instance$options$deb2;
158
+
159
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
160
+ }
161
+ })
162
+ };
163
+ column = instance._features.reduce((obj, feature) => {
164
+ return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
165
+ }, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
166
+
167
+ return column;
168
+ }
169
+
100
170
  //
101
- const Columns = {
171
+ function createHeader(instance, column, options) {
172
+ var _options$id;
173
+
174
+ const id = (_options$id = options.id) != null ? _options$id : column.id;
175
+ let header = {
176
+ id,
177
+ column,
178
+ index: options.index,
179
+ isPlaceholder: !!options.isPlaceholder,
180
+ placeholderId: options.placeholderId,
181
+ depth: options.depth,
182
+ subHeaders: [],
183
+ colSpan: 0,
184
+ rowSpan: 0,
185
+ headerGroup: null,
186
+ getLeafHeaders: () => {
187
+ const leafHeaders = [];
188
+
189
+ const recurseHeader = h => {
190
+ if (h.subHeaders && h.subHeaders.length) {
191
+ h.subHeaders.map(recurseHeader);
192
+ }
193
+
194
+ leafHeaders.push(h);
195
+ };
196
+
197
+ recurseHeader(header);
198
+ return leafHeaders;
199
+ },
200
+ renderHeader: () => column.columnDef.header ? instance._render(column.columnDef.header, {
201
+ instance,
202
+ header: header,
203
+ column
204
+ }) : null,
205
+ renderFooter: () => column.columnDef.footer ? instance._render(column.columnDef.footer, {
206
+ instance,
207
+ header: header,
208
+ column
209
+ }) : null
210
+ };
211
+
212
+ instance._features.forEach(feature => {
213
+ Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
214
+ });
215
+
216
+ return header;
217
+ }
218
+
219
+ const Headers = {
102
220
  createInstance: instance => {
103
221
  return {
104
- getDefaultColumn: memo(() => [instance.options.defaultColumn], defaultColumn => {
105
- var _defaultColumn;
106
-
107
- defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
108
- return {
109
- header: props => props.header.column.id,
110
- footer: props => props.header.column.id,
111
- cell: props => {
112
- var _props$getValue$toStr, _props$getValue$toStr2, _props$getValue;
113
-
114
- 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;
115
- },
116
- ...instance._features.reduce((obj, feature) => {
117
- return Object.assign(obj, feature.getDefaultColumn == null ? void 0 : feature.getDefaultColumn());
118
- }, {}),
119
- ...defaultColumn
120
- };
222
+ // Header Groups
223
+ getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
224
+ var _left$map$filter, _right$map$filter;
225
+
226
+ const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
227
+ const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
228
+ const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
229
+ const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
230
+ return headerGroups;
121
231
  }, {
232
+ key: process.env.NODE_ENV === 'development' && 'getHeaderGroups',
122
233
  debug: () => {
123
234
  var _instance$options$deb;
124
235
 
125
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
126
- },
127
- key: process.env.NODE_ENV === 'development' && 'getDefaultColumn'
236
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
237
+ }
128
238
  }),
129
- getColumnDefs: () => instance.options.columns,
130
- createColumn: (columnDef, depth, parent) => {
131
- var _ref, _columnDef$id;
132
-
133
- const defaultColumn = instance.getDefaultColumn();
134
- let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
135
- let accessorFn;
239
+ getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
240
+ leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
241
+ return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
242
+ }, {
243
+ key: process.env.NODE_ENV === 'development' && 'getCenterHeaderGroups',
244
+ debug: () => {
245
+ var _instance$options$deb2;
136
246
 
137
- if (columnDef.accessorFn) {
138
- accessorFn = columnDef.accessorFn;
139
- } else if (columnDef.accessorKey) {
140
- accessorFn = originalRow => originalRow[columnDef.accessorKey];
247
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
141
248
  }
249
+ }),
250
+ getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
251
+ var _left$map$filter2;
142
252
 
143
- if (!id) {
144
- if (process.env.NODE_ENV !== 'production') {
145
- throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
146
- }
253
+ const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
254
+ return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
255
+ }, {
256
+ key: process.env.NODE_ENV === 'development' && 'getLeftHeaderGroups',
257
+ debug: () => {
258
+ var _instance$options$deb3;
147
259
 
148
- throw new Error();
260
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
149
261
  }
262
+ }),
263
+ getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
264
+ var _right$map$filter2;
150
265
 
151
- let column = { ...defaultColumn,
152
- ...columnDef,
153
- id: "" + id,
154
- accessorFn,
155
- parent: parent,
156
- depth,
157
- columnDef,
158
- columnDefType: columnDef.columnDefType,
159
- columns: [],
160
- getFlatColumns: memo(() => [true], () => {
161
- var _column$columns;
162
-
163
- return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
164
- }, {
165
- key: process.env.NODE_ENV === 'production' && 'column.getFlatColumns',
166
- debug: () => {
167
- var _instance$options$deb2;
168
-
169
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
170
- }
171
- }),
172
- getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
173
- var _column$columns2;
174
-
175
- if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
176
- let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
177
- return orderColumns(leafColumns);
178
- }
179
-
180
- return [column];
181
- }, {
182
- key: process.env.NODE_ENV === 'production' && 'column.getLeafColumns',
183
- debug: () => {
184
- var _instance$options$deb3;
185
-
186
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
187
- }
188
- })
189
- };
190
- column = instance._features.reduce((obj, feature) => {
191
- return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
192
- }, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
193
-
194
- return column;
195
- },
196
- getAllColumns: memo(() => [instance.getColumnDefs()], columnDefs => {
197
- const recurseColumns = function (columnDefs, parent, depth) {
198
- if (depth === void 0) {
199
- depth = 0;
200
- }
201
-
202
- return columnDefs.map(columnDef => {
203
- const column = instance.createColumn(columnDef, depth, parent);
204
- column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
205
- return column;
206
- });
207
- };
208
-
209
- return recurseColumns(columnDefs);
266
+ const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
267
+ return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
210
268
  }, {
211
- key: process.env.NODE_ENV === 'development' && 'getAllColumns',
269
+ key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
212
270
  debug: () => {
213
271
  var _instance$options$deb4;
214
272
 
215
- return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
273
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
216
274
  }
217
275
  }),
218
- getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
219
- return allColumns.flatMap(column => {
220
- return column.getFlatColumns();
221
- });
276
+ // Footer Groups
277
+ getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
278
+ return [...headerGroups].reverse();
222
279
  }, {
223
- key: process.env.NODE_ENV === 'development' && 'getAllFlatColumns',
280
+ key: process.env.NODE_ENV === 'development' && 'getFooterGroups',
224
281
  debug: () => {
225
282
  var _instance$options$deb5;
226
283
 
227
- return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
284
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
228
285
  }
229
286
  }),
230
- getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
231
- return flatColumns.reduce((acc, column) => {
232
- acc[column.id] = column;
233
- return acc;
234
- }, {});
287
+ getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
288
+ return [...headerGroups].reverse();
235
289
  }, {
236
- key: process.env.NODE_ENV === 'development' && 'getAllFlatColumnsById',
290
+ key: process.env.NODE_ENV === 'development' && 'getLeftFooterGroups',
237
291
  debug: () => {
238
292
  var _instance$options$deb6;
239
293
 
240
- return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugColumns;
294
+ return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
241
295
  }
242
296
  }),
243
- getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
244
- let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
245
- return orderColumns(leafColumns);
297
+ getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
298
+ return [...headerGroups].reverse();
246
299
  }, {
247
- key: process.env.NODE_ENV === 'development' && 'getAllLeafColumns',
300
+ key: process.env.NODE_ENV === 'development' && 'getCenterFooterGroups',
248
301
  debug: () => {
249
302
  var _instance$options$deb7;
250
303
 
251
- return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugColumns;
304
+ return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
252
305
  }
253
306
  }),
254
- getColumn: columnId => {
255
- const column = instance.getAllFlatColumnsById()[columnId];
256
-
257
- if (!column) {
258
- if (process.env.NODE_ENV !== 'production') {
259
- console.warn("[Table] Column with id " + columnId + " does not exist.");
260
- }
307
+ getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
308
+ return [...headerGroups].reverse();
309
+ }, {
310
+ key: process.env.NODE_ENV === 'development' && 'getRightFooterGroups',
311
+ debug: () => {
312
+ var _instance$options$deb8;
261
313
 
262
- throw new Error();
314
+ return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
263
315
  }
316
+ }),
317
+ // Flat Headers
318
+ getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
319
+ return headerGroups.map(headerGroup => {
320
+ return headerGroup.headers;
321
+ }).flat();
322
+ }, {
323
+ key: process.env.NODE_ENV === 'development' && 'getFlatHeaders',
324
+ debug: () => {
325
+ var _instance$options$deb9;
264
326
 
265
- return column;
266
- }
267
- };
268
- }
269
- };
270
-
271
- //
272
- const Rows = {
273
- // createRow: <TGenerics extends TableGenerics>(
274
- // row: Row<TGenerics>,
275
- // instance: TableInstance<TGenerics>
276
- // ): CellsRow<TGenerics> => {
277
- // return {}
278
- // },
279
- createInstance: instance => {
280
- return {
281
- getRowId: (row, index, parent) => {
282
- var _instance$options$get;
283
-
284
- 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);
285
- },
286
- createRow: (id, original, rowIndex, depth, subRows) => {
287
- let row = {
288
- id,
289
- index: rowIndex,
290
- original,
291
- depth,
292
- valuesCache: {},
293
- getValue: columnId => {
294
- if (row.valuesCache.hasOwnProperty(columnId)) {
295
- return row.valuesCache[columnId];
296
- }
297
-
298
- const column = instance.getColumn(columnId);
299
-
300
- if (!column.accessorFn) {
301
- return undefined;
302
- }
303
-
304
- row.valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
305
- return row.valuesCache[columnId];
306
- },
307
- subRows: subRows != null ? subRows : [],
308
- getLeafRows: () => flattenBy(row.subRows, d => d.subRows)
309
- };
327
+ return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
328
+ }
329
+ }),
330
+ getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
331
+ return left.map(headerGroup => {
332
+ return headerGroup.headers;
333
+ }).flat();
334
+ }, {
335
+ key: process.env.NODE_ENV === 'development' && 'getLeftFlatHeaders',
336
+ debug: () => {
337
+ var _instance$options$deb10;
310
338
 
311
- for (let i = 0; i < instance._features.length; i++) {
312
- const feature = instance._features[i];
313
- Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
339
+ return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
314
340
  }
341
+ }),
342
+ getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
343
+ return left.map(headerGroup => {
344
+ return headerGroup.headers;
345
+ }).flat();
346
+ }, {
347
+ key: process.env.NODE_ENV === 'development' && 'getCenterFlatHeaders',
348
+ debug: () => {
349
+ var _instance$options$deb11;
315
350
 
316
- return row;
317
- },
318
- getCoreRowModel: () => {
319
- if (!instance._getCoreRowModel) {
320
- instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
351
+ return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
321
352
  }
353
+ }),
354
+ getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
355
+ return left.map(headerGroup => {
356
+ return headerGroup.headers;
357
+ }).flat();
358
+ }, {
359
+ key: process.env.NODE_ENV === 'development' && 'getRightFlatHeaders',
360
+ debug: () => {
361
+ var _instance$options$deb12;
322
362
 
323
- return instance._getCoreRowModel();
324
- },
325
- // The final calls start at the bottom of the model,
326
- // expanded rows, which then work their way up
327
- getRowModel: () => {
328
- return instance.getPaginationRowModel();
329
- },
330
- getRow: id => {
331
- const row = instance.getRowModel().rowsById[id];
363
+ return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
364
+ }
365
+ }),
366
+ // Leaf Headers
367
+ getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
368
+ return flatHeaders.filter(header => {
369
+ var _header$subHeaders;
332
370
 
333
- if (!row) {
334
- if (process.env.NODE_ENV !== 'production') {
335
- throw new Error("getRow expected an ID, but got " + id);
336
- }
371
+ return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
372
+ });
373
+ }, {
374
+ key: process.env.NODE_ENV === 'development' && 'getCenterLeafHeaders',
375
+ debug: () => {
376
+ var _instance$options$deb13;
337
377
 
338
- throw new Error();
378
+ return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
339
379
  }
380
+ }),
381
+ getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
382
+ return flatHeaders.filter(header => {
383
+ var _header$subHeaders2;
340
384
 
341
- return row;
342
- }
343
- };
344
- }
345
- };
385
+ return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
386
+ });
387
+ }, {
388
+ key: process.env.NODE_ENV === 'development' && 'getLeftLeafHeaders',
389
+ debug: () => {
390
+ var _instance$options$deb14;
346
391
 
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);
392
+ return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
393
+ }
394
+ }),
395
+ getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
396
+ return flatHeaders.filter(header => {
397
+ var _header$subHeaders3;
398
+
399
+ return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
354
400
  });
355
401
  }, {
356
- key: process.env.NODE_ENV === 'development' && 'row.getAllCells',
402
+ key: process.env.NODE_ENV === 'development' && 'getRightLeafHeaders',
357
403
  debug: () => {
358
- var _instance$options$deb;
404
+ var _instance$options$deb15;
359
405
 
360
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
406
+ return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
361
407
  }
362
408
  }),
363
- getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
364
- return allCells.reduce((acc, cell) => {
365
- acc[cell.columnId] = cell;
366
- return acc;
367
- }, {});
409
+ getLeafHeaders: memo(() => [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()], (left, center, right) => {
410
+ var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
411
+
412
+ 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 => {
413
+ return header.getLeafHeaders();
414
+ }).flat();
368
415
  }, {
369
- key: process.env.NODE_ENV === 'production' && 'row.getAllCellsByColumnId',
416
+ key: process.env.NODE_ENV === 'development' && 'getLeafHeaders',
370
417
  debug: () => {
371
- var _instance$options$deb2;
418
+ var _instance$options$deb16;
372
419
 
373
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
420
+ return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
374
421
  }
375
422
  })
376
423
  };
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
- }, {});
424
+ }
425
+ };
426
+ function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
427
+ var _headerGroups$0$heade, _headerGroups$;
400
428
 
401
- return cell;
402
- },
403
- getCell: (rowId, columnId) => {
404
- const row = instance.getRow(rowId);
429
+ // Find the max depth of the columns:
430
+ // build the leaf column row
431
+ // build each buffer row going up
432
+ // placeholder for non-existent level
433
+ // real column for existing level
434
+ let maxDepth = 0;
405
435
 
406
- if (!row) {
407
- if (process.env.NODE_ENV !== 'production') {
408
- throw new Error("[Table] could not find row with id " + rowId);
409
- }
436
+ const findMaxDepth = function (columns, depth) {
437
+ if (depth === void 0) {
438
+ depth = 1;
439
+ }
410
440
 
411
- throw new Error();
412
- }
441
+ maxDepth = Math.max(maxDepth, depth);
442
+ columns.filter(column => column.getIsVisible()).forEach(column => {
443
+ var _column$columns;
413
444
 
414
- const cell = row.getAllCellsByColumnId()[columnId];
445
+ if ((_column$columns = column.columns) != null && _column$columns.length) {
446
+ findMaxDepth(column.columns, depth + 1);
447
+ }
448
+ }, 0);
449
+ };
415
450
 
416
- if (!cell) {
417
- if (process.env.NODE_ENV !== 'production') {
418
- throw new Error("[Table] could not find cell " + columnId + " in row " + rowId);
419
- }
451
+ findMaxDepth(allColumns);
452
+ let headerGroups = [];
420
453
 
421
- throw new Error();
422
- }
454
+ const createHeaderGroup = (headersToGroup, depth) => {
455
+ // The header group we are creating
456
+ const headerGroup = {
457
+ depth,
458
+ id: [headerFamily, "" + depth].filter(Boolean).join('_'),
459
+ headers: []
460
+ }; // The parent columns we're going to scan next
461
+
462
+ const pendingParentHeaders = []; // Scan each column for parents
463
+
464
+ headersToGroup.forEach(headerToGroup => {
465
+ // What is the latest (last) parent column?
466
+ const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
467
+ const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
468
+ let column;
469
+ let isPlaceholder = false;
423
470
 
424
- return cell;
471
+ if (isLeafHeader && headerToGroup.column.parent) {
472
+ // The parent header is new
473
+ column = headerToGroup.column.parent;
474
+ } else {
475
+ // The parent header is repeated
476
+ column = headerToGroup.column;
477
+ isPlaceholder = true;
425
478
  }
426
- };
427
- }
428
- };
479
+
480
+ if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
481
+ // This column is repeated. Add it as a sub header to the next batch
482
+ latestPendingParentHeader.subHeaders.push(headerToGroup);
483
+ } else {
484
+ // This is a new header. Let's create it
485
+ const header = createHeader(instance, column, {
486
+ id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
487
+ isPlaceholder,
488
+ placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
489
+ depth,
490
+ index: pendingParentHeaders.length
491
+ }); // Add the headerToGroup as a subHeader of the new header
492
+
493
+ header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
494
+ // in the next batch
495
+
496
+ pendingParentHeaders.push(header);
497
+ }
498
+
499
+ headerGroup.headers.push(headerToGroup);
500
+ headerToGroup.headerGroup = headerGroup;
501
+ });
502
+ headerGroups.push(headerGroup);
503
+
504
+ if (depth > 0) {
505
+ createHeaderGroup(pendingParentHeaders, depth - 1);
506
+ }
507
+ };
508
+
509
+ const bottomHeaders = columnsToGroup.map((column, index) => createHeader(instance, column, {
510
+ depth: maxDepth,
511
+ index
512
+ }));
513
+ createHeaderGroup(bottomHeaders, maxDepth - 1);
514
+ headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
515
+ // return !headerGroup.headers.every(header => header.isPlaceholder)
516
+ // })
517
+
518
+ const recurseHeadersForSpans = headers => {
519
+ const filteredHeaders = headers.filter(header => header.column.getIsVisible());
520
+ return filteredHeaders.map(header => {
521
+ let colSpan = 0;
522
+ let rowSpan = 0;
523
+ let childRowSpans = [0];
524
+
525
+ if (header.subHeaders && header.subHeaders.length) {
526
+ childRowSpans = [];
527
+ recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
528
+ let {
529
+ colSpan: childColSpan,
530
+ rowSpan: childRowSpan
531
+ } = _ref;
532
+ colSpan += childColSpan;
533
+ childRowSpans.push(childRowSpan);
534
+ });
535
+ } else {
536
+ colSpan = 1;
537
+ }
538
+
539
+ const minChildRowSpan = Math.min(...childRowSpans);
540
+ rowSpan = rowSpan + minChildRowSpan;
541
+ header.colSpan = colSpan;
542
+ header.rowSpan = rowSpan;
543
+ return {
544
+ colSpan,
545
+ rowSpan
546
+ };
547
+ });
548
+ };
549
+
550
+ recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
551
+ return headerGroups;
552
+ }
429
553
 
430
554
  //
431
555
  const defaultColumnSizing = {
@@ -444,7 +568,7 @@ const getDefaultColumnSizingInfoState = () => ({
444
568
  });
445
569
 
446
570
  const ColumnSizing = {
447
- getDefaultColumn: () => {
571
+ getDefaultColumnDef: () => {
448
572
  return defaultColumnSizing;
449
573
  },
450
574
  getInitialState: state => {
@@ -464,10 +588,10 @@ const ColumnSizing = {
464
588
  createColumn: (column, instance) => {
465
589
  return {
466
590
  getSize: () => {
467
- var _column$minSize, _ref, _column$maxSize;
591
+ var _column$columnDef$min, _ref, _column$columnDef$max;
468
592
 
469
593
  const columnSize = instance.getState().columnSizing[column.id];
470
- 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);
594
+ 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);
471
595
  },
472
596
  getStart: position => {
473
597
  const columns = !position ? instance.getVisibleLeafColumns() : position === 'left' ? instance.getLeftVisibleLeafColumns() : instance.getRightVisibleLeafColumns();
@@ -490,9 +614,9 @@ const ColumnSizing = {
490
614
  });
491
615
  },
492
616
  getCanResize: () => {
493
- var _column$enableResizin, _instance$options$ena;
617
+ var _column$columnDef$ena, _instance$options$ena;
494
618
 
495
- return ((_column$enableResizin = column.enableResizing) != null ? _column$enableResizin : true) && ((_instance$options$ena = instance.options.enableColumnResizing) != null ? _instance$options$ena : true);
619
+ return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableColumnResizing) != null ? _instance$options$ena : true);
496
620
  },
497
621
  getIsResizing: () => {
498
622
  return instance.getState().columnSizingInfo.isResizingColumn === column.id;
@@ -949,7 +1073,7 @@ function testFalsey(val) {
949
1073
 
950
1074
  //
951
1075
  const Filters = {
952
- getDefaultColumn: () => {
1076
+ getDefaultColumnDef: () => {
953
1077
  return {
954
1078
  filterFn: 'auto'
955
1079
  };
@@ -972,7 +1096,7 @@ const Filters = {
972
1096
  getColumnCanGlobalFilter: column => {
973
1097
  var _instance$getCoreRowM, _instance$getCoreRowM2;
974
1098
 
975
- const value = (_instance$getCoreRowM = instance.getCoreRowModel().flatRows[0]) == null ? void 0 : (_instance$getCoreRowM2 = _instance$getCoreRowM.getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreRowM2.getValue();
1099
+ const value = (_instance$getCoreRowM = instance.getCoreRowModel().flatRows[0]) == null ? void 0 : (_instance$getCoreRowM2 = _instance$getCoreRowM._getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreRowM2.getValue();
976
1100
  return typeof value === 'string';
977
1101
  }
978
1102
  };
@@ -992,6 +1116,10 @@ const Filters = {
992
1116
  return filterFns.inNumberRange;
993
1117
  }
994
1118
 
1119
+ if (typeof value === 'boolean') {
1120
+ return filterFns.equals;
1121
+ }
1122
+
995
1123
  if (value !== null && typeof value === 'object') {
996
1124
  return filterFns.equals;
997
1125
  }
@@ -1009,14 +1137,14 @@ const Filters = {
1009
1137
  return isFunction(column.filterFn) ? column.filterFn : column.filterFn === 'auto' ? column.getAutoFilterFn() : (_ref = userFilterFns == null ? void 0 : userFilterFns[column.filterFn]) != null ? _ref : filterFns[column.filterFn];
1010
1138
  },
1011
1139
  getCanFilter: () => {
1012
- var _column$enableColumnF, _instance$options$ena, _instance$options$ena2;
1140
+ var _column$columnDef$ena, _instance$options$ena, _instance$options$ena2;
1013
1141
 
1014
- 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;
1142
+ 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;
1015
1143
  },
1016
1144
  getCanGlobalFilter: () => {
1017
- var _column$enableGlobalF, _instance$options$ena3, _instance$options$ena4, _instance$options$get;
1145
+ var _column$columnDef$ena2, _instance$options$ena3, _instance$options$ena4, _instance$options$get;
1018
1146
 
1019
- 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;
1147
+ 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;
1020
1148
  },
1021
1149
  getIsFiltered: () => column.getFilterIndex() > -1,
1022
1150
  getFilterValue: () => {
@@ -1096,8 +1224,7 @@ const Filters = {
1096
1224
  createRow: (row, instance) => {
1097
1225
  return {
1098
1226
  columnFilters: {},
1099
- columnFiltersMeta: {},
1100
- subRowsByFacetId: {}
1227
+ columnFiltersMeta: {}
1101
1228
  };
1102
1229
  },
1103
1230
  createInstance: instance => {
@@ -1188,53 +1315,42 @@ function shouldAutoRemoveFilter(filterFn, value, column) {
1188
1315
  return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
1189
1316
  }
1190
1317
 
1191
- const aggregationFns = {
1192
- sum,
1193
- min,
1194
- max,
1195
- extent,
1196
- mean,
1197
- median,
1198
- unique,
1199
- uniqueCount,
1200
- count
1201
- };
1202
-
1203
- function sum(_getLeafValues, getChildValues) {
1318
+ const sum = (columnId, _leafRows, childRows) => {
1204
1319
  // It's faster to just add the aggregations together instead of
1205
1320
  // process leaf nodes individually
1206
- return getChildValues().reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
1207
- }
1321
+ return childRows.reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
1322
+ };
1208
1323
 
1209
- function min(_getLeafValues, getChildValues) {
1324
+ const min = (columnId, _leafRows, childRows) => {
1210
1325
  let min;
1326
+ childRows.forEach(row => {
1327
+ const value = row.getValue(columnId);
1211
1328
 
1212
- for (const value of getChildValues()) {
1213
1329
  if (value != null && (min > value || min === undefined && value >= value)) {
1214
1330
  min = value;
1215
1331
  }
1216
- }
1217
-
1332
+ });
1218
1333
  return min;
1219
- }
1334
+ };
1220
1335
 
1221
- function max(_getLeafValues, getChildValues) {
1336
+ const max = (columnId, _leafRows, childRows) => {
1222
1337
  let max;
1338
+ childRows.forEach(row => {
1339
+ const value = row.getValue(columnId);
1223
1340
 
1224
- for (const value of getChildValues()) {
1225
1341
  if (value != null && (max < value || max === undefined && value >= value)) {
1226
1342
  max = value;
1227
1343
  }
1228
- }
1229
-
1344
+ });
1230
1345
  return max;
1231
- }
1346
+ };
1232
1347
 
1233
- function extent(_getLeafValues, getChildValues) {
1348
+ const extent = (columnId, _leafRows, childRows) => {
1234
1349
  let min;
1235
1350
  let max;
1351
+ childRows.forEach(row => {
1352
+ const value = row.getValue(columnId);
1236
1353
 
1237
- for (const value of getChildValues()) {
1238
1354
  if (value != null) {
1239
1355
  if (min === undefined) {
1240
1356
  if (value >= value) min = max = value;
@@ -1243,58 +1359,69 @@ function extent(_getLeafValues, getChildValues) {
1243
1359
  if (max < value) max = value;
1244
1360
  }
1245
1361
  }
1246
- }
1247
-
1362
+ });
1248
1363
  return [min, max];
1249
- }
1364
+ };
1250
1365
 
1251
- function mean(getLeafValues) {
1366
+ const mean = (columnId, leafRows) => {
1252
1367
  let count = 0;
1253
1368
  let sum = 0;
1369
+ leafRows.forEach(row => {
1370
+ let value = row.getValue(columnId);
1254
1371
 
1255
- for (let value of getLeafValues()) {
1256
1372
  if (value != null && (value = +value) >= value) {
1257
1373
  ++count, sum += value;
1258
1374
  }
1259
- }
1260
-
1375
+ });
1261
1376
  if (count) return sum / count;
1262
1377
  return;
1263
- }
1264
-
1265
- function median(getLeafValues) {
1266
- const leafValues = getLeafValues();
1378
+ };
1267
1379
 
1268
- if (!leafValues.length) {
1380
+ const median = (columnId, leafRows) => {
1381
+ if (!leafRows.length) {
1269
1382
  return;
1270
1383
  }
1271
1384
 
1272
1385
  let min = 0;
1273
1386
  let max = 0;
1274
- leafValues.forEach(value => {
1387
+ leafRows.forEach(row => {
1388
+ let value = row.getValue(columnId);
1389
+
1275
1390
  if (typeof value === 'number') {
1276
1391
  min = Math.min(min, value);
1277
1392
  max = Math.max(max, value);
1278
1393
  }
1279
1394
  });
1280
1395
  return (min + max) / 2;
1281
- }
1396
+ };
1282
1397
 
1283
- function unique(getLeafValues) {
1284
- return Array.from(new Set(getLeafValues()).values());
1285
- }
1398
+ const unique = (columnId, leafRows) => {
1399
+ return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
1400
+ };
1286
1401
 
1287
- function uniqueCount(getLeafValues) {
1288
- return new Set(getLeafValues()).size;
1289
- }
1402
+ const uniqueCount = (columnId, leafRows) => {
1403
+ return new Set(leafRows.map(d => d.getValue(columnId))).size;
1404
+ };
1290
1405
 
1291
- function count(getLeafValues) {
1292
- return getLeafValues().length;
1293
- }
1406
+ const count = (_columnId, leafRows) => {
1407
+ return leafRows.length;
1408
+ };
1409
+
1410
+ const aggregationFns = {
1411
+ sum,
1412
+ min,
1413
+ max,
1414
+ extent,
1415
+ mean,
1416
+ median,
1417
+ unique,
1418
+ uniqueCount,
1419
+ count
1420
+ };
1294
1421
 
1295
1422
  //
1296
1423
  const Grouping = {
1297
- getDefaultColumn: () => {
1424
+ getDefaultColumnDef: () => {
1298
1425
  return {
1299
1426
  aggregationFn: 'auto'
1300
1427
  };
@@ -1324,9 +1451,9 @@ const Grouping = {
1324
1451
  });
1325
1452
  },
1326
1453
  getCanGroup: () => {
1327
- var _ref, _ref2, _ref3, _column$enableGroupin;
1454
+ var _ref, _ref2, _ref3, _column$columnDef$ena;
1328
1455
 
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;
1456
+ 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
1457
  },
1331
1458
  getIsGrouped: () => {
1332
1459
  var _instance$getState$gr;
@@ -1345,7 +1472,7 @@ const Grouping = {
1345
1472
  column.toggleGrouping();
1346
1473
  };
1347
1474
  },
1348
- getColumnAutoAggregationFn: () => {
1475
+ getAutoAggregationFn: () => {
1349
1476
  const firstRow = instance.getCoreRowModel().flatRows[0];
1350
1477
  const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
1351
1478
 
@@ -1359,7 +1486,7 @@ const Grouping = {
1359
1486
 
1360
1487
  return aggregationFns.count;
1361
1488
  },
1362
- getColumnAggregationFn: () => {
1489
+ getAggregationFn: () => {
1363
1490
  var _ref4;
1364
1491
 
1365
1492
  const userAggregationFns = instance.options.aggregationFns;
@@ -1368,7 +1495,7 @@ const Grouping = {
1368
1495
  throw new Error();
1369
1496
  }
1370
1497
 
1371
- return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.getColumnAutoAggregationFn() : (_ref4 = userAggregationFns == null ? void 0 : userAggregationFns[column.aggregationFn]) != null ? _ref4 : aggregationFns[column.aggregationFn];
1498
+ return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_ref4 = userAggregationFns == null ? void 0 : userAggregationFns[column.aggregationFn]) != null ? _ref4 : aggregationFns[column.aggregationFn];
1372
1499
  }
1373
1500
  };
1374
1501
  },
@@ -1394,10 +1521,10 @@ const Grouping = {
1394
1521
  }
1395
1522
  };
1396
1523
  },
1397
- createRow: (row, instance) => {
1524
+ createRow: row => {
1398
1525
  return {
1399
1526
  getIsGrouped: () => !!row.groupingColumnId,
1400
- groupingValuesCache: {}
1527
+ _groupingValuesCache: {}
1401
1528
  };
1402
1529
  },
1403
1530
  createCell: (cell, column, row, instance) => {
@@ -1410,9 +1537,9 @@ const Grouping = {
1410
1537
  return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
1411
1538
  },
1412
1539
  renderAggregatedCell: () => {
1413
- var _column$aggregatedCel;
1540
+ var _column$columnDef$agg;
1414
1541
 
1415
- const template = (_column$aggregatedCel = column.aggregatedCell) != null ? _column$aggregatedCel : column.cell;
1542
+ const template = (_column$columnDef$agg = column.columnDef.aggregatedCell) != null ? _column$columnDef$agg : column.columnDef.cell;
1416
1543
  return template ? instance._render(template, {
1417
1544
  instance,
1418
1545
  column,
@@ -1719,9 +1846,9 @@ const Pinning = {
1719
1846
  getCanPin: () => {
1720
1847
  const leafColumns = column.getLeafColumns();
1721
1848
  return leafColumns.some(d => {
1722
- var _d$enablePinning, _instance$options$ena;
1849
+ var _d$columnDef$enablePi, _instance$options$ena;
1723
1850
 
1724
- return ((_d$enablePinning = d.enablePinning) != null ? _d$enablePinning : true) && ((_instance$options$ena = instance.options.enablePinning) != null ? _instance$options$ena : true);
1851
+ return ((_d$columnDef$enablePi = d.columnDef.enablePinning) != null ? _d$columnDef$enablePi : true) && ((_instance$options$ena = instance.options.enablePinning) != null ? _instance$options$ena : true);
1725
1852
  });
1726
1853
  },
1727
1854
  getIsPinned: () => {
@@ -1746,7 +1873,7 @@ const Pinning = {
1746
1873
  return {
1747
1874
  getCenterVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allCells, left, right) => {
1748
1875
  const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
1749
- return allCells.filter(d => !leftAndRight.includes(d.columnId));
1876
+ return allCells.filter(d => !leftAndRight.includes(d.column.id));
1750
1877
  }, {
1751
1878
  key: process.env.NODE_ENV === 'production' && 'row.getCenterVisibleCells',
1752
1879
  debug: () => {
@@ -1756,7 +1883,7 @@ const Pinning = {
1756
1883
  }
1757
1884
  }),
1758
1885
  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,
1886
+ const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
1760
1887
  position: 'left'
1761
1888
  }));
1762
1889
  return cells;
@@ -1769,7 +1896,7 @@ const Pinning = {
1769
1896
  }
1770
1897
  }),
1771
1898
  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,
1899
+ const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
1773
1900
  position: 'left'
1774
1901
  }));
1775
1902
  return cells;
@@ -1791,12 +1918,18 @@ const Pinning = {
1791
1918
 
1792
1919
  return instance.setColumnPinning(defaultState ? getDefaultPinningState() : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.columnPinning) != null ? _instance$initialStat : getDefaultPinningState());
1793
1920
  },
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));
1921
+ getIsSomeColumnsPinned: position => {
1922
+ var _pinningState$positio;
1923
+
1924
+ const pinningState = instance.getState().columnPinning;
1925
+
1926
+ if (!position) {
1927
+ var _pinningState$left, _pinningState$right;
1928
+
1929
+ return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
1930
+ }
1931
+
1932
+ return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
1800
1933
  },
1801
1934
  getLeftLeafColumns: memo(() => [instance.getAllLeafColumns(), instance.getState().columnPinning.left], (allColumns, left) => {
1802
1935
  return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
@@ -2322,7 +2455,7 @@ const Sorting = {
2322
2455
  ...state
2323
2456
  };
2324
2457
  },
2325
- getDefaultColumn: () => {
2458
+ getDefaultColumnDef: () => {
2326
2459
  return {
2327
2460
  sortingFn: 'auto'
2328
2461
  };
@@ -2382,7 +2515,7 @@ const Sorting = {
2382
2515
  throw new Error();
2383
2516
  }
2384
2517
 
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];
2518
+ 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
2519
  },
2387
2520
  toggleSorting: (desc, multi) => {
2388
2521
  // if (column.columns.length) {
@@ -2394,7 +2527,7 @@ const Sorting = {
2394
2527
  // return
2395
2528
  // }
2396
2529
  instance.setSorting(old => {
2397
- var _ref2, _column$sortDescFirst, _instance$options$ena, _instance$options$ena2;
2530
+ var _ref2, _column$columnDef$sor, _instance$options$ena, _instance$options$ena2;
2398
2531
 
2399
2532
  // Find any existing sorting for this column
2400
2533
  const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
@@ -2421,7 +2554,7 @@ const Sorting = {
2421
2554
  }
2422
2555
  }
2423
2556
 
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
2557
+ 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
2558
 
2426
2559
  if (sortAction === 'toggle' && ( // Must be toggling
2427
2560
  (_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
@@ -2465,14 +2598,14 @@ const Sorting = {
2465
2598
  });
2466
2599
  },
2467
2600
  getCanSort: () => {
2468
- var _column$enableSorting, _instance$options$ena3;
2601
+ var _column$columnDef$ena, _instance$options$ena3;
2469
2602
 
2470
- return ((_column$enableSorting = column.enableSorting) != null ? _column$enableSorting : true) && ((_instance$options$ena3 = instance.options.enableSorting) != null ? _instance$options$ena3 : true) && !!column.accessorFn;
2603
+ 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
2604
  },
2472
2605
  getCanMultiSort: () => {
2473
- var _ref3, _column$enableMultiSo;
2606
+ var _ref3, _column$columnDef$ena2;
2474
2607
 
2475
- return (_ref3 = (_column$enableMultiSo = column.enableMultiSort) != null ? _column$enableMultiSo : instance.options.enableMultiSort) != null ? _ref3 : !!column.accessorFn;
2608
+ return (_ref3 = (_column$columnDef$ena2 = column.columnDef.enableMultiSort) != null ? _column$columnDef$ena2 : instance.options.enableMultiSort) != null ? _ref3 : !!column.accessorFn;
2476
2609
  },
2477
2610
  getIsSorted: () => {
2478
2611
  var _instance$getState$so;
@@ -2536,7 +2669,7 @@ const Visibility = {
2536
2669
  onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
2537
2670
  };
2538
2671
  },
2539
- getDefaultColumn: () => {
2672
+ getDefaultColumnDef: () => {
2540
2673
  return {
2541
2674
  defaultIsVisible: true
2542
2675
  };
@@ -2556,9 +2689,9 @@ const Visibility = {
2556
2689
  return (_instance$getState$co = (_instance$getState$co2 = instance.getState().columnVisibility) == null ? void 0 : _instance$getState$co2[column.id]) != null ? _instance$getState$co : true;
2557
2690
  },
2558
2691
  getCanHide: () => {
2559
- var _column$enableHiding, _instance$options$ena;
2692
+ var _column$columnDef$ena, _instance$options$ena;
2560
2693
 
2561
- return ((_column$enableHiding = column.enableHiding) != null ? _column$enableHiding : true) && ((_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : true);
2694
+ return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : true);
2562
2695
  },
2563
2696
  getToggleVisibilityHandler: () => {
2564
2697
  return e => {
@@ -2574,475 +2707,70 @@ const Visibility = {
2574
2707
  }, {
2575
2708
  key: process.env.NODE_ENV === 'production' && 'row._getAllVisibleCells',
2576
2709
  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;
2710
+ var _instance$options$deb;
2873
2711
 
2874
- return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
2712
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
2875
2713
  }
2876
2714
  }),
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$;
2715
+ getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
2716
+ key: process.env.NODE_ENV === 'development' && 'row.getVisibleCells',
2717
+ debug: () => {
2718
+ var _instance$options$deb2;
2879
2719
 
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();
2720
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
2721
+ }
2722
+ })
2723
+ };
2724
+ },
2725
+ createInstance: instance => {
2726
+ const makeVisibleColumnsMethod = (key, getColumns) => {
2727
+ return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
2728
+ return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
2883
2729
  }, {
2884
- key: process.env.NODE_ENV === 'development' && 'getLeafHeaders',
2730
+ key,
2885
2731
  debug: () => {
2886
- var _instance$options$deb16;
2732
+ var _instance$options$deb3;
2887
2733
 
2888
- return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
2734
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2889
2735
  }
2890
- }),
2891
- getHeader: id => {
2892
- const header = [...instance.getFlatHeaders(), ...instance.getCenterFlatHeaders(), ...instance.getLeftFlatHeaders(), ...instance.getRightFlatHeaders()].find(d => d.id === id);
2736
+ });
2737
+ };
2893
2738
 
2894
- if (!header) {
2895
- if (process.env.NODE_ENV !== 'production') {
2896
- console.warn("Could not find header with id: " + id);
2897
- }
2739
+ return {
2740
+ getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
2741
+ getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
2742
+ getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
2743
+ getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
2744
+ getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
2745
+ setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
2746
+ resetColumnVisibility: defaultState => {
2747
+ var _instance$initialStat;
2898
2748
 
2899
- throw new Error();
2900
- }
2749
+ instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
2750
+ },
2751
+ toggleAllColumnsVisible: value => {
2752
+ var _value;
2753
+
2754
+ value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
2755
+ instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
2756
+ [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
2757
+ }), {}));
2758
+ },
2759
+ getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
2760
+ getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
2761
+ getToggleAllColumnsVisibilityHandler: () => {
2762
+ return e => {
2763
+ var _target;
2901
2764
 
2902
- return header;
2765
+ instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
2766
+ };
2903
2767
  }
2904
2768
  };
2905
2769
  }
2906
2770
  };
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
2771
 
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
-
3031
- recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
3032
- return headerGroups;
3033
- }
2772
+ const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]; //
3034
2773
 
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
2774
  function createTableInstance(options) {
3047
2775
  var _options$initialState;
3048
2776
 
@@ -3051,7 +2779,7 @@ function createTableInstance(options) {
3051
2779
  }
3052
2780
 
3053
2781
  let instance = {
3054
- _features: [Columns, Rows, Cells, Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]
2782
+ _features: features
3055
2783
  };
3056
2784
 
3057
2785
  const defaultOptions = instance._features.reduce((obj, feature) => {
@@ -3068,8 +2796,7 @@ function createTableInstance(options) {
3068
2796
  };
3069
2797
  };
3070
2798
 
3071
- const coreInitialState = {// coreProgress: 1,
3072
- };
2799
+ const coreInitialState = {};
3073
2800
  let initialState = { ...coreInitialState,
3074
2801
  ...((_options$initialState = options.initialState) != null ? _options$initialState : {})
3075
2802
  };
@@ -3082,16 +2809,8 @@ function createTableInstance(options) {
3082
2809
 
3083
2810
  const queued = [];
3084
2811
  let queuedTimeout = false;
3085
- const midInstance = { ...instance,
3086
- // init: () => {
3087
- // startWork()
3088
- // },
3089
- // willUpdate: () => {
3090
- // startWork()
3091
- // },
3092
- // destroy: () => {
3093
- // stopWork()
3094
- // },
2812
+ const coreInstance = {
2813
+ _features: features,
3095
2814
  options: { ...defaultOptions,
3096
2815
  ...options
3097
2816
  },
@@ -3137,29 +2856,136 @@ function createTableInstance(options) {
3137
2856
  },
3138
2857
  setState: updater => {
3139
2858
  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
- // },
2859
+ },
2860
+ _getRowId: (row, index, parent) => {
2861
+ var _instance$options$get;
2862
+
2863
+ 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);
2864
+ },
2865
+ getCoreRowModel: () => {
2866
+ if (!instance._getCoreRowModel) {
2867
+ instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
2868
+ }
2869
+
2870
+ return instance._getCoreRowModel();
2871
+ },
2872
+ // The final calls start at the bottom of the model,
2873
+ // expanded rows, which then work their way up
2874
+ getRowModel: () => {
2875
+ return instance.getPaginationRowModel();
2876
+ },
2877
+ getRow: id => {
2878
+ const row = instance.getRowModel().rowsById[id];
2879
+
2880
+ if (!row) {
2881
+ if (process.env.NODE_ENV !== 'production') {
2882
+ throw new Error("getRow expected an ID, but got " + id);
2883
+ }
2884
+
2885
+ throw new Error();
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: process.env.NODE_ENV === 'development' && '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: process.env.NODE_ENV === 'development' && '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: process.env.NODE_ENV === 'development' && '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: process.env.NODE_ENV === 'development' && '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: process.env.NODE_ENV === 'development' && '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
+ if (process.env.NODE_ENV !== 'production') {
2979
+ console.warn("[Table] Column with id " + columnId + " does not exist.");
2980
+ }
2981
+
2982
+ throw new Error();
2983
+ }
3160
2984
 
2985
+ return column;
2986
+ }
3161
2987
  };
3162
- instance = Object.assign(instance, midInstance);
2988
+ Object.assign(instance, coreInstance);
3163
2989
 
3164
2990
  instance._features.forEach(feature => {
3165
2991
  return Object.assign(instance, feature.createInstance == null ? void 0 : feature.createInstance(instance));
@@ -3182,7 +3008,7 @@ function createTable$1(_, __, options) {
3182
3008
  throw new Error('');
3183
3009
  })()
3184
3010
  },
3185
- setGenerics: () => table,
3011
+ // setGenerics: () => table as any,
3186
3012
  setRowType: () => table,
3187
3013
  setTableMetaType: () => table,
3188
3014
  setColumnMetaType: () => table,
@@ -3218,11 +3044,92 @@ function createTable$1(_, __, options) {
3218
3044
  }
3219
3045
 
3220
3046
  throw new Error('Invalid accessor');
3221
- }
3047
+ },
3048
+ createOptions: options => options
3222
3049
  };
3223
3050
  return table;
3224
3051
  }
3225
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: process.env.NODE_ENV === 'development' && '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: process.env.NODE_ENV === 'production' && 'row.getAllCellsByColumnId',
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
+
3226
3133
  function getCoreRowModel() {
3227
3134
  return instance => memo(() => [instance.options.data], data => {
3228
3135
  const rowModel = {
@@ -3250,7 +3157,7 @@ function getCoreRowModel() {
3250
3157
  // }
3251
3158
  // Make the row
3252
3159
 
3253
- 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
3254
3161
 
3255
3162
  rowModel.flatRows.push(row); // Also keep track of every row by its ID
3256
3163
 
@@ -3313,7 +3220,7 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
3313
3220
  row = rowsToFilter[i];
3314
3221
 
3315
3222
  if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
3316
- newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3223
+ newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3317
3224
  newRow.columnFilters = row.columnFilters;
3318
3225
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3319
3226
 
@@ -3363,7 +3270,7 @@ function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
3363
3270
  var _row$subRows2;
3364
3271
 
3365
3272
  if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
3366
- newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3273
+ newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3367
3274
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3368
3275
  row = newRow;
3369
3276
  }
@@ -3615,8 +3522,8 @@ function getSortedRowModel() {
3615
3522
  availableSorting.forEach(sortEntry => {
3616
3523
  const column = instance.getColumn(sortEntry.id);
3617
3524
  columnInfoById[sortEntry.id] = {
3618
- sortUndefined: column.sortUndefined,
3619
- invertSorting: column.invertSorting,
3525
+ sortUndefined: column.columnDef.sortUndefined,
3526
+ invertSorting: column.columnDef.invertSorting,
3620
3527
  sortingFn: column.getSortingFn()
3621
3528
  };
3622
3529
  });
@@ -3730,7 +3637,7 @@ function getGroupedRowModel() {
3730
3637
  const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
3731
3638
 
3732
3639
  const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
3733
- const row = instance.createRow(id, undefined, index, depth);
3640
+ const row = createRow(instance, id, undefined, index, depth);
3734
3641
  Object.assign(row, {
3735
3642
  groupingColumnId: columnId,
3736
3643
  groupingValue,
@@ -3739,38 +3646,30 @@ function getGroupedRowModel() {
3739
3646
  getValue: columnId => {
3740
3647
  // Don't aggregate columns that are in the grouping
3741
3648
  if (existingGrouping.includes(columnId)) {
3742
- if (row.valuesCache.hasOwnProperty(columnId)) {
3743
- return row.valuesCache[columnId];
3649
+ if (row._valuesCache.hasOwnProperty(columnId)) {
3650
+ return row._valuesCache[columnId];
3744
3651
  }
3745
3652
 
3746
3653
  if (groupedRows[0]) {
3747
3654
  var _groupedRows$0$getVal;
3748
3655
 
3749
- 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;
3750
3657
  }
3751
3658
 
3752
- return row.valuesCache[columnId];
3659
+ return row._valuesCache[columnId];
3753
3660
  }
3754
3661
 
3755
- if (row.groupingValuesCache.hasOwnProperty(columnId)) {
3756
- return row.groupingValuesCache[columnId];
3662
+ if (row._groupingValuesCache.hasOwnProperty(columnId)) {
3663
+ return row._groupingValuesCache[columnId];
3757
3664
  } // Aggregate the values
3758
3665
 
3759
3666
 
3760
3667
  const column = instance.getColumn(columnId);
3761
- const aggregateFn = column.getColumnAggregationFn();
3668
+ const aggregateFn = column.getAggregationFn();
3762
3669
 
3763
3670
  if (aggregateFn) {
3764
- row.groupingValuesCache[columnId] = aggregateFn(() => leafRows.map(row => {
3765
- let columnValue = row.getValue(columnId);
3766
-
3767
- if (!depth && column.aggregateValue) {
3768
- columnValue = column.aggregateValue(columnValue);
3769
- }
3770
-
3771
- return columnValue;
3772
- }), () => groupedRows.map(row => row.getValue(columnId)));
3773
- return row.groupingValuesCache[columnId];
3671
+ row._groupingValuesCache[columnId] = aggregateFn(columnId, leafRows, groupedRows);
3672
+ return row._groupingValuesCache[columnId];
3774
3673
  } else if (column.aggregationFn) {
3775
3674
  console.info({
3776
3675
  column
@@ -3979,5 +3878,5 @@ function useTableInstance(table, options) {
3979
3878
  return instanceRef.current;
3980
3879
  }
3981
3880
 
3982
- export { ColumnSizing, Expanding, Filters, Grouping, Headers, Ordering, Pagination, Pinning, RowSelection, Sorting, Visibility, aggregationFns, buildHeaderGroups, 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, selectRowsFn, shouldAutoRemoveFilter, sortingFns, useTableInstance };
3881
+ 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, memo, noop, orderColumns, passiveEventSupported, reSplitAlphaNumeric, render, selectRowsFn, shouldAutoRemoveFilter, sortingFns, useTableInstance };
3983
3882
  //# sourceMappingURL=index.js.map