@tanstack/react-table 8.0.0-alpha.83 → 8.0.0-alpha.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -97,337 +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
- getDefaultColumnDef: memo(() => [instance.options.defaultColumnDef], 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.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
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' && 'getDefaultColumnDef'
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 defaultColumnDef = instance.getDefaultColumnDef();
134
- columnDef = { ...defaultColumnDef,
135
- ...columnDef
136
- };
137
- let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
138
- 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;
139
246
 
140
- if (columnDef.accessorFn) {
141
- accessorFn = columnDef.accessorFn;
142
- } else if (columnDef.accessorKey) {
143
- accessorFn = originalRow => originalRow[columnDef.accessorKey];
247
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
144
248
  }
249
+ }),
250
+ getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
251
+ var _left$map$filter2;
145
252
 
146
- if (!id) {
147
- if (process.env.NODE_ENV !== 'production') {
148
- throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
149
- }
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;
150
259
 
151
- throw new Error();
260
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
152
261
  }
262
+ }),
263
+ getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
264
+ var _right$map$filter2;
153
265
 
154
- let column = { ...columnDef,
155
- id: "" + id,
156
- accessorFn,
157
- parent: parent,
158
- depth,
159
- columnDef,
160
- columnDefType: columnDef.columnDefType,
161
- columns: [],
162
- getFlatColumns: memo(() => [true], () => {
163
- var _column$columns;
164
-
165
- return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
166
- }, {
167
- key: process.env.NODE_ENV === 'production' && 'column.getFlatColumns',
168
- debug: () => {
169
- var _instance$options$deb2;
170
-
171
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
172
- }
173
- }),
174
- getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
175
- var _column$columns2;
176
-
177
- if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
178
- let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
179
- return orderColumns(leafColumns);
180
- }
181
-
182
- return [column];
183
- }, {
184
- key: process.env.NODE_ENV === 'production' && 'column.getLeafColumns',
185
- debug: () => {
186
- var _instance$options$deb3;
187
-
188
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
189
- }
190
- })
191
- };
192
- column = instance._features.reduce((obj, feature) => {
193
- return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
194
- }, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
195
-
196
- return column;
197
- },
198
- getAllColumns: memo(() => [instance.getColumnDefs()], columnDefs => {
199
- const recurseColumns = function (columnDefs, parent, depth) {
200
- if (depth === void 0) {
201
- depth = 0;
202
- }
203
-
204
- return columnDefs.map(columnDef => {
205
- const column = instance.createColumn(columnDef, depth, parent);
206
- column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
207
- return column;
208
- });
209
- };
210
-
211
- 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');
212
268
  }, {
213
- key: process.env.NODE_ENV === 'development' && 'getAllColumns',
269
+ key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
214
270
  debug: () => {
215
271
  var _instance$options$deb4;
216
272
 
217
- 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;
218
274
  }
219
275
  }),
220
- getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
221
- return allColumns.flatMap(column => {
222
- return column.getFlatColumns();
223
- });
276
+ // Footer Groups
277
+ getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
278
+ return [...headerGroups].reverse();
224
279
  }, {
225
- key: process.env.NODE_ENV === 'development' && 'getAllFlatColumns',
280
+ key: process.env.NODE_ENV === 'development' && 'getFooterGroups',
226
281
  debug: () => {
227
282
  var _instance$options$deb5;
228
283
 
229
- 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;
230
285
  }
231
286
  }),
232
- getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
233
- return flatColumns.reduce((acc, column) => {
234
- acc[column.id] = column;
235
- return acc;
236
- }, {});
287
+ getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
288
+ return [...headerGroups].reverse();
237
289
  }, {
238
- key: process.env.NODE_ENV === 'development' && 'getAllFlatColumnsById',
290
+ key: process.env.NODE_ENV === 'development' && 'getLeftFooterGroups',
239
291
  debug: () => {
240
292
  var _instance$options$deb6;
241
293
 
242
- 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;
243
295
  }
244
296
  }),
245
- getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
246
- let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
247
- return orderColumns(leafColumns);
297
+ getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
298
+ return [...headerGroups].reverse();
248
299
  }, {
249
- key: process.env.NODE_ENV === 'development' && 'getAllLeafColumns',
300
+ key: process.env.NODE_ENV === 'development' && 'getCenterFooterGroups',
250
301
  debug: () => {
251
302
  var _instance$options$deb7;
252
303
 
253
- 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;
254
305
  }
255
306
  }),
256
- getColumn: columnId => {
257
- const column = instance.getAllFlatColumnsById()[columnId];
258
-
259
- if (!column) {
260
- if (process.env.NODE_ENV !== 'production') {
261
- console.warn("[Table] Column with id " + columnId + " does not exist.");
262
- }
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;
263
313
 
264
- throw new Error();
314
+ return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
265
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;
266
326
 
267
- return column;
268
- }
269
- };
270
- }
271
- };
272
-
273
- //
274
- const Rows = {
275
- // createRow: <TGenerics extends TableGenerics>(
276
- // row: Row<TGenerics>,
277
- // instance: TableInstance<TGenerics>
278
- // ): CellsRow<TGenerics> => {
279
- // return {}
280
- // },
281
- createInstance: instance => {
282
- return {
283
- getRowId: (row, index, parent) => {
284
- var _instance$options$get;
285
-
286
- return (_instance$options$get = instance.options.getRowId == null ? void 0 : instance.options.getRowId(row, index, parent)) != null ? _instance$options$get : "" + (parent ? [parent.id, index].join('.') : index);
287
- },
288
- createRow: (id, original, rowIndex, depth, subRows) => {
289
- let row = {
290
- id,
291
- index: rowIndex,
292
- original,
293
- depth,
294
- valuesCache: {},
295
- getValue: columnId => {
296
- if (row.valuesCache.hasOwnProperty(columnId)) {
297
- return row.valuesCache[columnId];
298
- }
299
-
300
- const column = instance.getColumn(columnId);
301
-
302
- if (!column.accessorFn) {
303
- return undefined;
304
- }
305
-
306
- row.valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
307
- return row.valuesCache[columnId];
308
- },
309
- subRows: subRows != null ? subRows : [],
310
- getLeafRows: () => flattenBy(row.subRows, d => d.subRows)
311
- };
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;
312
338
 
313
- for (let i = 0; i < instance._features.length; i++) {
314
- const feature = instance._features[i];
315
- Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
339
+ return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
316
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;
317
350
 
318
- return row;
319
- },
320
- getCoreRowModel: () => {
321
- if (!instance._getCoreRowModel) {
322
- instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
351
+ return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
323
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;
324
362
 
325
- return instance._getCoreRowModel();
326
- },
327
- // The final calls start at the bottom of the model,
328
- // expanded rows, which then work their way up
329
- getRowModel: () => {
330
- return instance.getPaginationRowModel();
331
- },
332
- getRow: id => {
333
- const row = instance.getRowModel().rowsById[id];
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;
334
370
 
335
- if (!row) {
336
- if (process.env.NODE_ENV !== 'production') {
337
- throw new Error("getRow expected an ID, but got " + id);
338
- }
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;
339
377
 
340
- throw new Error();
378
+ return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
341
379
  }
380
+ }),
381
+ getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
382
+ return flatHeaders.filter(header => {
383
+ var _header$subHeaders2;
342
384
 
343
- return row;
344
- }
345
- };
346
- }
347
- };
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;
348
391
 
349
- //
350
- const Cells = {
351
- createRow: (row, instance) => {
352
- return {
353
- getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
354
- return leafColumns.map(column => {
355
- 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);
356
400
  });
357
401
  }, {
358
- key: process.env.NODE_ENV === 'development' && 'row.getAllCells',
402
+ key: process.env.NODE_ENV === 'development' && 'getRightLeafHeaders',
359
403
  debug: () => {
360
- var _instance$options$deb;
404
+ var _instance$options$deb15;
361
405
 
362
- 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;
363
407
  }
364
408
  }),
365
- getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
366
- return allCells.reduce((acc, cell) => {
367
- acc[cell.columnId] = cell;
368
- return acc;
369
- }, {});
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();
370
415
  }, {
371
- key: process.env.NODE_ENV === 'production' && 'row.getAllCellsByColumnId',
416
+ key: process.env.NODE_ENV === 'development' && 'getLeafHeaders',
372
417
  debug: () => {
373
- var _instance$options$deb2;
418
+ var _instance$options$deb16;
374
419
 
375
- 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;
376
421
  }
377
422
  })
378
423
  };
379
- },
380
- createInstance: instance => {
381
- return {
382
- createCell: (row, column, columnId) => {
383
- const cell = {
384
- id: row.id + "_" + column.id,
385
- rowId: row.id,
386
- columnId,
387
- row,
388
- column,
389
- getValue: () => row.getValue(columnId),
390
- renderCell: () => column.columnDef.cell ? instance._render(column.columnDef.cell, {
391
- instance,
392
- column,
393
- row,
394
- cell: cell,
395
- getValue: cell.getValue
396
- }) : null
397
- };
424
+ }
425
+ };
426
+ function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
427
+ var _headerGroups$0$heade, _headerGroups$;
398
428
 
399
- instance._features.forEach(feature => {
400
- Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
401
- }, {});
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;
402
435
 
403
- return cell;
404
- },
405
- getCell: (rowId, columnId) => {
406
- const row = instance.getRow(rowId);
436
+ const findMaxDepth = function (columns, depth) {
437
+ if (depth === void 0) {
438
+ depth = 1;
439
+ }
407
440
 
408
- if (!row) {
409
- if (process.env.NODE_ENV !== 'production') {
410
- throw new Error("[Table] could not find row with id " + rowId);
411
- }
441
+ maxDepth = Math.max(maxDepth, depth);
442
+ columns.filter(column => column.getIsVisible()).forEach(column => {
443
+ var _column$columns;
412
444
 
413
- throw new Error();
414
- }
445
+ if ((_column$columns = column.columns) != null && _column$columns.length) {
446
+ findMaxDepth(column.columns, depth + 1);
447
+ }
448
+ }, 0);
449
+ };
450
+
451
+ findMaxDepth(allColumns);
452
+ let headerGroups = [];
415
453
 
416
- const cell = row.getAllCellsByColumnId()[columnId];
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
417
461
 
418
- if (!cell) {
419
- if (process.env.NODE_ENV !== 'production') {
420
- throw new Error("[Table] could not find cell " + columnId + " in row " + rowId);
421
- }
462
+ const pendingParentHeaders = []; // Scan each column for parents
422
463
 
423
- throw new Error();
424
- }
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;
470
+
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;
478
+ }
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
425
495
 
426
- return cell;
496
+ pendingParentHeaders.push(header);
427
497
  }
428
- };
429
- }
430
- };
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
+ }
431
553
 
432
554
  //
433
555
  const defaultColumnSizing = {
@@ -974,7 +1096,7 @@ const Filters = {
974
1096
  getColumnCanGlobalFilter: column => {
975
1097
  var _instance$getCoreRowM, _instance$getCoreRowM2;
976
1098
 
977
- 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();
978
1100
  return typeof value === 'string';
979
1101
  }
980
1102
  };
@@ -1752,7 +1874,7 @@ const Pinning = {
1752
1874
  return {
1753
1875
  getCenterVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allCells, left, right) => {
1754
1876
  const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
1755
- return allCells.filter(d => !leftAndRight.includes(d.columnId));
1877
+ return allCells.filter(d => !leftAndRight.includes(d.column.id));
1756
1878
  }, {
1757
1879
  key: process.env.NODE_ENV === 'production' && 'row.getCenterVisibleCells',
1758
1880
  debug: () => {
@@ -1762,7 +1884,7 @@ const Pinning = {
1762
1884
  }
1763
1885
  }),
1764
1886
  getLeftVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left,,], (allCells, left) => {
1765
- const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.columnId === columnId)).filter(Boolean).map(d => ({ ...d,
1887
+ const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
1766
1888
  position: 'left'
1767
1889
  }));
1768
1890
  return cells;
@@ -1775,7 +1897,7 @@ const Pinning = {
1775
1897
  }
1776
1898
  }),
1777
1899
  getRightVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.right], (allCells, right) => {
1778
- const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.columnId === columnId)).filter(Boolean).map(d => ({ ...d,
1900
+ const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
1779
1901
  position: 'left'
1780
1902
  }));
1781
1903
  return cells;
@@ -2581,480 +2703,75 @@ const Visibility = {
2581
2703
  },
2582
2704
  createRow: (row, instance) => {
2583
2705
  return {
2584
- _getAllVisibleCells: memo(() => [row.getAllCells().filter(cell => cell.column.getIsVisible()).map(d => d.id).join('_')], _ => {
2585
- return row.getAllCells().filter(cell => cell.column.getIsVisible());
2586
- }, {
2587
- key: process.env.NODE_ENV === 'production' && 'row._getAllVisibleCells',
2588
- debug: () => {
2589
- var _instance$options$deb;
2590
-
2591
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
2592
- }
2593
- }),
2594
- getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
2595
- key: process.env.NODE_ENV === 'development' && 'row.getVisibleCells',
2596
- debug: () => {
2597
- var _instance$options$deb2;
2598
-
2599
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
2600
- }
2601
- })
2602
- };
2603
- },
2604
- createInstance: instance => {
2605
- const makeVisibleColumnsMethod = (key, getColumns) => {
2606
- return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
2607
- return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
2608
- }, {
2609
- key,
2610
- debug: () => {
2611
- var _instance$options$deb3;
2612
-
2613
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2614
- }
2615
- });
2616
- };
2617
-
2618
- return {
2619
- getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
2620
- getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
2621
- getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
2622
- getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
2623
- getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
2624
- setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
2625
- resetColumnVisibility: defaultState => {
2626
- var _instance$initialStat;
2627
-
2628
- instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
2629
- },
2630
- toggleAllColumnsVisible: value => {
2631
- var _value;
2632
-
2633
- value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
2634
- instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
2635
- [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
2636
- }), {}));
2637
- },
2638
- getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
2639
- getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
2640
- getToggleAllColumnsVisibilityHandler: () => {
2641
- return e => {
2642
- var _target;
2643
-
2644
- instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
2645
- };
2646
- }
2647
- };
2648
- }
2649
- };
2650
-
2651
- //
2652
- const Headers = {
2653
- createInstance: instance => {
2654
- return {
2655
- createHeader: (column, options) => {
2656
- var _options$id;
2657
-
2658
- const id = (_options$id = options.id) != null ? _options$id : column.id;
2659
- let header = {
2660
- id,
2661
- column,
2662
- index: options.index,
2663
- isPlaceholder: options.isPlaceholder,
2664
- placeholderId: options.placeholderId,
2665
- depth: options.depth,
2666
- subHeaders: [],
2667
- colSpan: 0,
2668
- rowSpan: 0,
2669
- headerGroup: null,
2670
- getLeafHeaders: () => {
2671
- const leafHeaders = [];
2672
-
2673
- const recurseHeader = h => {
2674
- if (h.subHeaders && h.subHeaders.length) {
2675
- h.subHeaders.map(recurseHeader);
2676
- }
2677
-
2678
- leafHeaders.push(h);
2679
- };
2680
-
2681
- recurseHeader(header);
2682
- return leafHeaders;
2683
- },
2684
- renderHeader: () => column.columnDef.header ? instance._render(column.columnDef.header, {
2685
- instance,
2686
- header: header,
2687
- column
2688
- }) : null,
2689
- renderFooter: () => column.columnDef.footer ? instance._render(column.columnDef.footer, {
2690
- instance,
2691
- header: header,
2692
- column
2693
- }) : null
2694
- };
2695
-
2696
- instance._features.forEach(feature => {
2697
- Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
2698
- });
2699
-
2700
- return header;
2701
- },
2702
- // Header Groups
2703
- getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2704
- var _left$map$filter, _right$map$filter;
2705
-
2706
- const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
2707
- const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
2708
- const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2709
- const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
2710
- return headerGroups;
2711
- }, {
2712
- key: process.env.NODE_ENV === 'development' && 'getHeaderGroups',
2713
- debug: () => {
2714
- var _instance$options$deb;
2715
-
2716
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
2717
- }
2718
- }),
2719
- getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2720
- leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2721
- return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
2722
- }, {
2723
- key: process.env.NODE_ENV === 'development' && 'getCenterHeaderGroups',
2724
- debug: () => {
2725
- var _instance$options$deb2;
2726
-
2727
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
2728
- }
2729
- }),
2730
- getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
2731
- var _left$map$filter2;
2732
-
2733
- const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
2734
- return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
2735
- }, {
2736
- key: process.env.NODE_ENV === 'development' && 'getLeftHeaderGroups',
2737
- debug: () => {
2738
- var _instance$options$deb3;
2739
-
2740
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
2741
- }
2742
- }),
2743
- getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
2744
- var _right$map$filter2;
2745
-
2746
- const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
2747
- return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
2748
- }, {
2749
- key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
2750
- debug: () => {
2751
- var _instance$options$deb4;
2752
-
2753
- return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
2754
- }
2755
- }),
2756
- // Footer Groups
2757
- getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
2758
- return [...headerGroups].reverse();
2759
- }, {
2760
- key: process.env.NODE_ENV === 'development' && 'getFooterGroups',
2761
- debug: () => {
2762
- var _instance$options$deb5;
2763
-
2764
- return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
2765
- }
2766
- }),
2767
- getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
2768
- return [...headerGroups].reverse();
2769
- }, {
2770
- key: process.env.NODE_ENV === 'development' && 'getLeftFooterGroups',
2771
- debug: () => {
2772
- var _instance$options$deb6;
2773
-
2774
- return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
2775
- }
2776
- }),
2777
- getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
2778
- return [...headerGroups].reverse();
2779
- }, {
2780
- key: process.env.NODE_ENV === 'development' && 'getCenterFooterGroups',
2781
- debug: () => {
2782
- var _instance$options$deb7;
2783
-
2784
- return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
2785
- }
2786
- }),
2787
- getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
2788
- return [...headerGroups].reverse();
2789
- }, {
2790
- key: process.env.NODE_ENV === 'development' && 'getRightFooterGroups',
2791
- debug: () => {
2792
- var _instance$options$deb8;
2793
-
2794
- return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
2795
- }
2796
- }),
2797
- // Flat Headers
2798
- getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
2799
- return headerGroups.map(headerGroup => {
2800
- return headerGroup.headers;
2801
- }).flat();
2802
- }, {
2803
- key: process.env.NODE_ENV === 'development' && 'getFlatHeaders',
2804
- debug: () => {
2805
- var _instance$options$deb9;
2806
-
2807
- return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
2808
- }
2809
- }),
2810
- getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
2811
- return left.map(headerGroup => {
2812
- return headerGroup.headers;
2813
- }).flat();
2814
- }, {
2815
- key: process.env.NODE_ENV === 'development' && 'getLeftFlatHeaders',
2816
- debug: () => {
2817
- var _instance$options$deb10;
2818
-
2819
- return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
2820
- }
2821
- }),
2822
- getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
2823
- return left.map(headerGroup => {
2824
- return headerGroup.headers;
2825
- }).flat();
2826
- }, {
2827
- key: process.env.NODE_ENV === 'development' && 'getCenterFlatHeaders',
2828
- debug: () => {
2829
- var _instance$options$deb11;
2830
-
2831
- return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
2832
- }
2833
- }),
2834
- getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
2835
- return left.map(headerGroup => {
2836
- return headerGroup.headers;
2837
- }).flat();
2838
- }, {
2839
- key: process.env.NODE_ENV === 'development' && 'getRightFlatHeaders',
2840
- debug: () => {
2841
- var _instance$options$deb12;
2842
-
2843
- return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
2844
- }
2845
- }),
2846
- // Leaf Headers
2847
- getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
2848
- return flatHeaders.filter(header => {
2849
- var _header$subHeaders;
2850
-
2851
- return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
2852
- });
2853
- }, {
2854
- key: process.env.NODE_ENV === 'development' && 'getCenterLeafHeaders',
2855
- debug: () => {
2856
- var _instance$options$deb13;
2857
-
2858
- return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
2859
- }
2860
- }),
2861
- getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
2862
- return flatHeaders.filter(header => {
2863
- var _header$subHeaders2;
2864
-
2865
- return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
2866
- });
2867
- }, {
2868
- key: process.env.NODE_ENV === 'development' && 'getLeftLeafHeaders',
2869
- debug: () => {
2870
- var _instance$options$deb14;
2871
-
2872
- return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
2873
- }
2874
- }),
2875
- getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
2876
- return flatHeaders.filter(header => {
2877
- var _header$subHeaders3;
2878
-
2879
- return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
2880
- });
2706
+ _getAllVisibleCells: memo(() => [row.getAllCells().filter(cell => cell.column.getIsVisible()).map(d => d.id).join('_')], _ => {
2707
+ return row.getAllCells().filter(cell => cell.column.getIsVisible());
2881
2708
  }, {
2882
- key: process.env.NODE_ENV === 'development' && 'getRightLeafHeaders',
2709
+ key: process.env.NODE_ENV === 'production' && 'row._getAllVisibleCells',
2883
2710
  debug: () => {
2884
- var _instance$options$deb15;
2711
+ var _instance$options$deb;
2885
2712
 
2886
- return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
2713
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
2887
2714
  }
2888
2715
  }),
2889
- getLeafHeaders: memo(() => [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()], (left, center, right) => {
2890
- var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
2716
+ getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
2717
+ key: process.env.NODE_ENV === 'development' && 'row.getVisibleCells',
2718
+ debug: () => {
2719
+ var _instance$options$deb2;
2891
2720
 
2892
- 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 => {
2893
- return header.getLeafHeaders();
2894
- }).flat();
2721
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
2722
+ }
2723
+ })
2724
+ };
2725
+ },
2726
+ createInstance: instance => {
2727
+ const makeVisibleColumnsMethod = (key, getColumns) => {
2728
+ return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
2729
+ return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
2895
2730
  }, {
2896
- key: process.env.NODE_ENV === 'development' && 'getLeafHeaders',
2731
+ key,
2897
2732
  debug: () => {
2898
- var _instance$options$deb16;
2733
+ var _instance$options$deb3;
2899
2734
 
2900
- return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
2735
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2901
2736
  }
2902
- }),
2903
- getHeader: id => {
2904
- const header = [...instance.getFlatHeaders(), ...instance.getCenterFlatHeaders(), ...instance.getLeftFlatHeaders(), ...instance.getRightFlatHeaders()].find(d => d.id === id);
2737
+ });
2738
+ };
2905
2739
 
2906
- if (!header) {
2907
- if (process.env.NODE_ENV !== 'production') {
2908
- console.warn("Could not find header with id: " + id);
2909
- }
2740
+ return {
2741
+ getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
2742
+ getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
2743
+ getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
2744
+ getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
2745
+ getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
2746
+ setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
2747
+ resetColumnVisibility: defaultState => {
2748
+ var _instance$initialStat;
2910
2749
 
2911
- throw new Error();
2912
- }
2750
+ instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
2751
+ },
2752
+ toggleAllColumnsVisible: value => {
2753
+ var _value;
2754
+
2755
+ value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
2756
+ instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
2757
+ [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
2758
+ }), {}));
2759
+ },
2760
+ getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
2761
+ getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
2762
+ getToggleAllColumnsVisibilityHandler: () => {
2763
+ return e => {
2764
+ var _target;
2913
2765
 
2914
- return header;
2766
+ instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
2767
+ };
2915
2768
  }
2916
2769
  };
2917
2770
  }
2918
2771
  };
2919
- function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
2920
- var _headerGroups$0$heade, _headerGroups$;
2921
-
2922
- // Find the max depth of the columns:
2923
- // build the leaf column row
2924
- // build each buffer row going up
2925
- // placeholder for non-existent level
2926
- // real column for existing level
2927
- let maxDepth = 0;
2928
-
2929
- const findMaxDepth = function (columns, depth) {
2930
- if (depth === void 0) {
2931
- depth = 1;
2932
- }
2933
-
2934
- maxDepth = Math.max(maxDepth, depth);
2935
- columns.filter(column => column.getIsVisible()).forEach(column => {
2936
- var _column$columns;
2937
-
2938
- if ((_column$columns = column.columns) != null && _column$columns.length) {
2939
- findMaxDepth(column.columns, depth + 1);
2940
- }
2941
- }, 0);
2942
- };
2943
-
2944
- findMaxDepth(allColumns);
2945
- let headerGroups = [];
2946
-
2947
- const createHeaderGroup = (headersToGroup, depth) => {
2948
- // The header group we are creating
2949
- const headerGroup = {
2950
- depth,
2951
- id: [headerFamily, "" + depth].filter(Boolean).join('_'),
2952
- headers: []
2953
- }; // The parent columns we're going to scan next
2954
-
2955
- const pendingParentHeaders = []; // Scan each column for parents
2956
-
2957
- headersToGroup.forEach(headerToGroup => {
2958
- // What is the latest (last) parent column?
2959
- const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
2960
- const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
2961
- let column;
2962
- let isPlaceholder = false;
2963
-
2964
- if (isLeafHeader && headerToGroup.column.parent) {
2965
- // The parent header is new
2966
- column = headerToGroup.column.parent;
2967
- } else {
2968
- // The parent header is repeated
2969
- column = headerToGroup.column;
2970
- isPlaceholder = true;
2971
- }
2972
-
2973
- if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
2974
- // This column is repeated. Add it as a sub header to the next batch
2975
- latestPendingParentHeader.subHeaders.push(headerToGroup);
2976
- } else {
2977
- // This is a new header. Let's create it
2978
- const header = instance.createHeader(column, {
2979
- id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
2980
- isPlaceholder,
2981
- placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
2982
- depth,
2983
- index: pendingParentHeaders.length
2984
- }); // Add the headerToGroup as a subHeader of the new header
2985
-
2986
- header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
2987
- // in the next batch
2988
-
2989
- pendingParentHeaders.push(header);
2990
- }
2991
-
2992
- headerGroup.headers.push(headerToGroup);
2993
- headerToGroup.headerGroup = headerGroup;
2994
- });
2995
- headerGroups.push(headerGroup);
2996
-
2997
- if (depth > 0) {
2998
- createHeaderGroup(pendingParentHeaders, depth - 1);
2999
- }
3000
- };
3001
-
3002
- const bottomHeaders = columnsToGroup.map((column, index) => instance.createHeader(column, {
3003
- depth: maxDepth,
3004
- index
3005
- }));
3006
- createHeaderGroup(bottomHeaders, maxDepth - 1);
3007
- headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
3008
- // return !headerGroup.headers.every(header => header.isPlaceholder)
3009
- // })
3010
-
3011
- const recurseHeadersForSpans = headers => {
3012
- const filteredHeaders = headers.filter(header => header.column.getIsVisible());
3013
- return filteredHeaders.map(header => {
3014
- let colSpan = 0;
3015
- let rowSpan = 0;
3016
- let childRowSpans = [0];
3017
2772
 
3018
- if (header.subHeaders && header.subHeaders.length) {
3019
- childRowSpans = [];
3020
- recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
3021
- let {
3022
- colSpan: childColSpan,
3023
- rowSpan: childRowSpan
3024
- } = _ref;
3025
- colSpan += childColSpan;
3026
- childRowSpans.push(childRowSpan);
3027
- });
3028
- } else {
3029
- colSpan = 1;
3030
- }
3031
-
3032
- const minChildRowSpan = Math.min(...childRowSpans);
3033
- rowSpan = rowSpan + minChildRowSpan;
3034
- header.colSpan = colSpan > 0 ? colSpan : undefined;
3035
- header.rowSpan = rowSpan > 0 ? rowSpan : undefined;
3036
- return {
3037
- colSpan,
3038
- rowSpan
3039
- };
3040
- });
3041
- };
3042
-
3043
- recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
3044
- return headerGroups;
3045
- }
2773
+ const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]; //
3046
2774
 
3047
- // export type Batch = {
3048
- // id: number
3049
- // priority: keyof CoreBatches
3050
- // tasks: (() => void)[]
3051
- // schedule: (cb: () => void) => void
3052
- // cancel: () => void
3053
- // }
3054
- // type CoreBatches = {
3055
- // data: Batch[]
3056
- // facets: Batch[]
3057
- // }
3058
2775
  function createTableInstance(options) {
3059
2776
  var _options$initialState;
3060
2777
 
@@ -3063,7 +2780,7 @@ function createTableInstance(options) {
3063
2780
  }
3064
2781
 
3065
2782
  let instance = {
3066
- _features: [Columns, Rows, Cells, Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]
2783
+ _features: features
3067
2784
  };
3068
2785
 
3069
2786
  const defaultOptions = instance._features.reduce((obj, feature) => {
@@ -3080,8 +2797,7 @@ function createTableInstance(options) {
3080
2797
  };
3081
2798
  };
3082
2799
 
3083
- const coreInitialState = {// coreProgress: 1,
3084
- };
2800
+ const coreInitialState = {};
3085
2801
  let initialState = { ...coreInitialState,
3086
2802
  ...((_options$initialState = options.initialState) != null ? _options$initialState : {})
3087
2803
  };
@@ -3094,16 +2810,8 @@ function createTableInstance(options) {
3094
2810
 
3095
2811
  const queued = [];
3096
2812
  let queuedTimeout = false;
3097
- const midInstance = { ...instance,
3098
- // init: () => {
3099
- // startWork()
3100
- // },
3101
- // willUpdate: () => {
3102
- // startWork()
3103
- // },
3104
- // destroy: () => {
3105
- // stopWork()
3106
- // },
2813
+ const coreInstance = {
2814
+ _features: features,
3107
2815
  options: { ...defaultOptions,
3108
2816
  ...options
3109
2817
  },
@@ -3149,29 +2857,136 @@ function createTableInstance(options) {
3149
2857
  },
3150
2858
  setState: updater => {
3151
2859
  instance.options.onStateChange == null ? void 0 : instance.options.onStateChange(updater);
3152
- } // getOverallProgress: () => {
3153
- // const { coreProgress, filtersProgress, facetProgress } =
3154
- // instance.getState()
3155
- // return mean(() =>
3156
- // [coreProgress, filtersProgress].filter(d => d < 1)
3157
- // ) as number
3158
- // },
3159
- // getProgressStage: () => {
3160
- // const { coreProgress, filtersProgress, facetProgress } =
3161
- // instance.getState()
3162
- // if (coreProgress < 1) {
3163
- // return 'coreRowModel'
3164
- // }
3165
- // if (filtersProgress < 1) {
3166
- // return 'filteredRowModel'
3167
- // }
3168
- // if (Object.values(facetProgress).some(d => d < 1)) {
3169
- // return 'facetedRowModel'
3170
- // }
3171
- // },
2860
+ },
2861
+ _getRowId: (row, index, parent) => {
2862
+ var _instance$options$get;
2863
+
2864
+ 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);
2865
+ },
2866
+ getCoreRowModel: () => {
2867
+ if (!instance._getCoreRowModel) {
2868
+ instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
2869
+ }
2870
+
2871
+ return instance._getCoreRowModel();
2872
+ },
2873
+ // The final calls start at the bottom of the model,
2874
+ // expanded rows, which then work their way up
2875
+ getRowModel: () => {
2876
+ return instance.getPaginationRowModel();
2877
+ },
2878
+ getRow: id => {
2879
+ const row = instance.getRowModel().rowsById[id];
2880
+
2881
+ if (!row) {
2882
+ if (process.env.NODE_ENV !== 'production') {
2883
+ throw new Error("getRow expected an ID, but got " + id);
2884
+ }
2885
+
2886
+ throw new Error();
2887
+ }
2888
+
2889
+ return row;
2890
+ },
2891
+ _getDefaultColumnDef: memo(() => [instance.options.defaultColumn], defaultColumn => {
2892
+ var _defaultColumn;
2893
+
2894
+ defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
2895
+ return {
2896
+ header: props => props.header.column.id,
2897
+ footer: props => props.header.column.id,
2898
+ cell: props => {
2899
+ var _props$getValue$toStr, _props$getValue$toStr2, _props$getValue;
2900
+
2901
+ return (_props$getValue$toStr = (_props$getValue$toStr2 = (_props$getValue = props.getValue()).toString) == null ? void 0 : _props$getValue$toStr2.call(_props$getValue)) != null ? _props$getValue$toStr : null;
2902
+ },
2903
+ ...instance._features.reduce((obj, feature) => {
2904
+ return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
2905
+ }, {}),
2906
+ ...defaultColumn
2907
+ };
2908
+ }, {
2909
+ debug: () => {
2910
+ var _instance$options$deb;
2911
+
2912
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
2913
+ },
2914
+ key: process.env.NODE_ENV === 'development' && 'getDefaultColumnDef'
2915
+ }),
2916
+ _getColumnDefs: () => instance.options.columns,
2917
+ getAllColumns: memo(() => [instance._getColumnDefs()], columnDefs => {
2918
+ const recurseColumns = function (columnDefs, parent, depth) {
2919
+ if (depth === void 0) {
2920
+ depth = 0;
2921
+ }
2922
+
2923
+ return columnDefs.map(columnDef => {
2924
+ const column = createColumn(instance, columnDef, depth, parent);
2925
+ column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
2926
+ return column;
2927
+ });
2928
+ };
2929
+
2930
+ return recurseColumns(columnDefs);
2931
+ }, {
2932
+ key: process.env.NODE_ENV === 'development' && 'getAllColumns',
2933
+ debug: () => {
2934
+ var _instance$options$deb2;
2935
+
2936
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
2937
+ }
2938
+ }),
2939
+ getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
2940
+ return allColumns.flatMap(column => {
2941
+ return column.getFlatColumns();
2942
+ });
2943
+ }, {
2944
+ key: process.env.NODE_ENV === 'development' && 'getAllFlatColumns',
2945
+ debug: () => {
2946
+ var _instance$options$deb3;
2947
+
2948
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2949
+ }
2950
+ }),
2951
+ _getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
2952
+ return flatColumns.reduce((acc, column) => {
2953
+ acc[column.id] = column;
2954
+ return acc;
2955
+ }, {});
2956
+ }, {
2957
+ key: process.env.NODE_ENV === 'development' && 'getAllFlatColumnsById',
2958
+ debug: () => {
2959
+ var _instance$options$deb4;
2960
+
2961
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
2962
+ }
2963
+ }),
2964
+ getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
2965
+ let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
2966
+ return orderColumns(leafColumns);
2967
+ }, {
2968
+ key: process.env.NODE_ENV === 'development' && 'getAllLeafColumns',
2969
+ debug: () => {
2970
+ var _instance$options$deb5;
2971
+
2972
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
2973
+ }
2974
+ }),
2975
+ getColumn: columnId => {
2976
+ const column = instance._getAllFlatColumnsById()[columnId];
2977
+
2978
+ if (!column) {
2979
+ if (process.env.NODE_ENV !== 'production') {
2980
+ console.warn("[Table] Column with id " + columnId + " does not exist.");
2981
+ }
2982
+
2983
+ throw new Error();
2984
+ }
3172
2985
 
2986
+ return column;
2987
+ }
3173
2988
  };
3174
- instance = Object.assign(instance, midInstance);
2989
+ Object.assign(instance, coreInstance);
3175
2990
 
3176
2991
  instance._features.forEach(feature => {
3177
2992
  return Object.assign(instance, feature.createInstance == null ? void 0 : feature.createInstance(instance));
@@ -3236,6 +3051,86 @@ function createTable$1(_, __, options) {
3236
3051
  return table;
3237
3052
  }
3238
3053
 
3054
+ function createCell(instance, row, column, columnId) {
3055
+ const cell = {
3056
+ id: row.id + "_" + column.id,
3057
+ row,
3058
+ column,
3059
+ getValue: () => row.getValue(columnId),
3060
+ renderCell: () => column.columnDef.cell ? instance._render(column.columnDef.cell, {
3061
+ instance,
3062
+ column,
3063
+ row,
3064
+ cell: cell,
3065
+ getValue: cell.getValue
3066
+ }) : null
3067
+ };
3068
+
3069
+ instance._features.forEach(feature => {
3070
+ Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
3071
+ }, {});
3072
+
3073
+ return cell;
3074
+ }
3075
+
3076
+ const createRow = (instance, id, original, rowIndex, depth, subRows) => {
3077
+ let row = {
3078
+ id,
3079
+ index: rowIndex,
3080
+ original,
3081
+ depth,
3082
+ _valuesCache: {},
3083
+ getValue: columnId => {
3084
+ if (row._valuesCache.hasOwnProperty(columnId)) {
3085
+ return row._valuesCache[columnId];
3086
+ }
3087
+
3088
+ const column = instance.getColumn(columnId);
3089
+
3090
+ if (!column.accessorFn) {
3091
+ return undefined;
3092
+ }
3093
+
3094
+ row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
3095
+ return row._valuesCache[columnId];
3096
+ },
3097
+ subRows: subRows != null ? subRows : [],
3098
+ getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
3099
+ getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
3100
+ return leafColumns.map(column => {
3101
+ return createCell(instance, row, column, column.id);
3102
+ });
3103
+ }, {
3104
+ key: process.env.NODE_ENV === 'development' && 'row.getAllCells',
3105
+ debug: () => {
3106
+ var _instance$options$deb;
3107
+
3108
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
3109
+ }
3110
+ }),
3111
+ _getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
3112
+ return allCells.reduce((acc, cell) => {
3113
+ acc[cell.column.id] = cell;
3114
+ return acc;
3115
+ }, {});
3116
+ }, {
3117
+ key: process.env.NODE_ENV === 'production' && 'row.getAllCellsByColumnId',
3118
+ debug: () => {
3119
+ var _instance$options$deb2;
3120
+
3121
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
3122
+ }
3123
+ })
3124
+ };
3125
+
3126
+ for (let i = 0; i < instance._features.length; i++) {
3127
+ const feature = instance._features[i];
3128
+ Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
3129
+ }
3130
+
3131
+ return row;
3132
+ };
3133
+
3239
3134
  function getCoreRowModel() {
3240
3135
  return instance => memo(() => [instance.options.data], data => {
3241
3136
  const rowModel = {
@@ -3263,7 +3158,7 @@ function getCoreRowModel() {
3263
3158
  // }
3264
3159
  // Make the row
3265
3160
 
3266
- row = instance.createRow(instance.getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3161
+ row = createRow(instance, instance._getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3267
3162
 
3268
3163
  rowModel.flatRows.push(row); // Also keep track of every row by its ID
3269
3164
 
@@ -3326,7 +3221,7 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
3326
3221
  row = rowsToFilter[i];
3327
3222
 
3328
3223
  if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
3329
- newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3224
+ newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3330
3225
  newRow.columnFilters = row.columnFilters;
3331
3226
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3332
3227
 
@@ -3376,7 +3271,7 @@ function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
3376
3271
  var _row$subRows2;
3377
3272
 
3378
3273
  if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
3379
- newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3274
+ newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3380
3275
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3381
3276
  row = newRow;
3382
3277
  }
@@ -3743,7 +3638,7 @@ function getGroupedRowModel() {
3743
3638
  const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
3744
3639
 
3745
3640
  const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
3746
- const row = instance.createRow(id, undefined, index, depth);
3641
+ const row = createRow(instance, id, undefined, index, depth);
3747
3642
  Object.assign(row, {
3748
3643
  groupingColumnId: columnId,
3749
3644
  groupingValue,
@@ -3752,17 +3647,17 @@ function getGroupedRowModel() {
3752
3647
  getValue: columnId => {
3753
3648
  // Don't aggregate columns that are in the grouping
3754
3649
  if (existingGrouping.includes(columnId)) {
3755
- if (row.valuesCache.hasOwnProperty(columnId)) {
3756
- return row.valuesCache[columnId];
3650
+ if (row._valuesCache.hasOwnProperty(columnId)) {
3651
+ return row._valuesCache[columnId];
3757
3652
  }
3758
3653
 
3759
3654
  if (groupedRows[0]) {
3760
3655
  var _groupedRows$0$getVal;
3761
3656
 
3762
- row.valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
3657
+ row._valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
3763
3658
  }
3764
3659
 
3765
- return row.valuesCache[columnId];
3660
+ return row._valuesCache[columnId];
3766
3661
  }
3767
3662
 
3768
3663
  if (row.groupingValuesCache.hasOwnProperty(columnId)) {
@@ -3992,5 +3887,5 @@ function useTableInstance(table, options) {
3992
3887
  return instanceRef.current;
3993
3888
  }
3994
3889
 
3995
- 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 };
3890
+ export { ColumnSizing, Expanding, Filters, Grouping, Headers, Ordering, Pagination, Pinning, RowSelection, Sorting, Visibility, aggregationFns, buildHeaderGroups, createColumn, createRow, createTable, createTableFactory, createTableInstance, defaultColumnSizing, expandRows, filterFns, flattenBy, functionalUpdate, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, isFunction, isRowSelected, makeStateUpdater, mean, memo, noop, orderColumns, passiveEventSupported, reSplitAlphaNumeric, render, selectRowsFn, shouldAutoRemoveFilter, sortingFns, useTableInstance };
3996
3891
  //# sourceMappingURL=index.js.map