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