@tanstack/table-core 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.
Files changed (93) hide show
  1. package/build/cjs/core/cell.js +38 -0
  2. package/build/cjs/core/cell.js.map +1 -0
  3. package/build/cjs/core/column.js +88 -0
  4. package/build/cjs/core/column.js.map +1 -0
  5. package/build/cjs/{features/Headers.js → core/headers.js} +54 -66
  6. package/build/cjs/core/headers.js.map +1 -0
  7. package/build/cjs/core/instance.js +255 -0
  8. package/build/cjs/core/instance.js.map +1 -0
  9. package/build/cjs/core/row.js +77 -0
  10. package/build/cjs/core/row.js.map +1 -0
  11. package/build/cjs/features/ColumnSizing.js.map +1 -1
  12. package/build/cjs/features/Expanding.js.map +1 -1
  13. package/build/cjs/features/Filters.js +1 -1
  14. package/build/cjs/features/Filters.js.map +1 -1
  15. package/build/cjs/features/Grouping.js.map +1 -1
  16. package/build/cjs/features/Ordering.js.map +1 -1
  17. package/build/cjs/features/Pagination.js.map +1 -1
  18. package/build/cjs/features/Pinning.js +3 -3
  19. package/build/cjs/features/Pinning.js.map +1 -1
  20. package/build/cjs/features/RowSelection.js.map +1 -1
  21. package/build/cjs/features/Sorting.js.map +1 -1
  22. package/build/cjs/features/Visibility.js.map +1 -1
  23. package/build/cjs/index.js +9 -5
  24. package/build/cjs/index.js.map +1 -1
  25. package/build/cjs/utils/filterRowsUtils.js +23 -21
  26. package/build/cjs/utils/filterRowsUtils.js.map +1 -1
  27. package/build/cjs/utils/getCoreRowModel.js +9 -8
  28. package/build/cjs/utils/getCoreRowModel.js.map +1 -1
  29. package/build/cjs/utils/getGroupedRowModel.js +12 -11
  30. package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
  31. package/build/esm/index.js +656 -761
  32. package/build/esm/index.js.map +1 -1
  33. package/build/stats-html.html +1 -1
  34. package/build/stats-react.json +391 -368
  35. package/build/types/core/cell.d.ts +9 -0
  36. package/build/types/{features/Columns.d.ts → core/column.d.ts} +3 -17
  37. package/build/types/{features/Headers.d.ts → core/headers.d.ts} +26 -11
  38. package/build/types/core/instance.d.ts +57 -0
  39. package/build/types/core/row.d.ts +15 -0
  40. package/build/types/features/ColumnSizing.d.ts +2 -1
  41. package/build/types/features/Expanding.d.ts +2 -1
  42. package/build/types/features/Filters.d.ts +2 -1
  43. package/build/types/features/Grouping.d.ts +2 -1
  44. package/build/types/features/Ordering.d.ts +2 -1
  45. package/build/types/features/Pagination.d.ts +2 -1
  46. package/build/types/features/Pinning.d.ts +2 -1
  47. package/build/types/features/RowSelection.d.ts +2 -1
  48. package/build/types/features/Sorting.d.ts +2 -1
  49. package/build/types/features/Visibility.d.ts +2 -1
  50. package/build/types/index.d.ts +4 -2
  51. package/build/types/sortingFns.d.ts +4 -4
  52. package/build/types/types.d.ts +10 -53
  53. package/build/umd/index.development.js +660 -759
  54. package/build/umd/index.development.js.map +1 -1
  55. package/build/umd/index.production.js +1 -1
  56. package/build/umd/index.production.js.map +1 -1
  57. package/package.json +1 -1
  58. package/src/core/cell.ts +47 -0
  59. package/src/core/column.ts +148 -0
  60. package/src/{features/Headers.ts → core/headers.ts} +98 -99
  61. package/src/core/instance.ts +361 -0
  62. package/src/core/row.ts +85 -0
  63. package/src/features/ColumnSizing.ts +1 -1
  64. package/src/features/Expanding.ts +1 -2
  65. package/src/features/Filters.ts +2 -2
  66. package/src/features/Grouping.ts +1 -1
  67. package/src/features/Ordering.ts +1 -1
  68. package/src/features/Pagination.ts +1 -1
  69. package/src/features/Pinning.ts +8 -4
  70. package/src/features/RowSelection.ts +1 -1
  71. package/src/features/Sorting.ts +1 -1
  72. package/src/features/Visibility.ts +1 -1
  73. package/src/index.ts +4 -8
  74. package/src/types.ts +9 -61
  75. package/src/utils/filterRowsUtils.ts +4 -2
  76. package/src/utils/getCoreRowModel.ts +4 -2
  77. package/src/utils/getGroupedRowModel.ts +6 -6
  78. package/build/cjs/core.js +0 -168
  79. package/build/cjs/core.js.map +0 -1
  80. package/build/cjs/features/Cells.js +0 -101
  81. package/build/cjs/features/Cells.js.map +0 -1
  82. package/build/cjs/features/Columns.js +0 -191
  83. package/build/cjs/features/Columns.js.map +0 -1
  84. package/build/cjs/features/Headers.js.map +0 -1
  85. package/build/cjs/features/Rows.js +0 -94
  86. package/build/cjs/features/Rows.js.map +0 -1
  87. package/build/types/core.d.ts +0 -30
  88. package/build/types/features/Cells.d.ts +0 -13
  89. package/build/types/features/Rows.d.ts +0 -28
  90. package/src/core.ts +0 -246
  91. package/src/features/Cells.ts +0 -128
  92. package/src/features/Columns.ts +0 -293
  93. package/src/features/Rows.ts +0 -142
@@ -91,329 +91,457 @@
91
91
  };
92
92
  }
93
93
 
94
+ function createColumn(instance, columnDef, depth, parent) {
95
+ var _ref, _columnDef$id;
96
+
97
+ const defaultColumn = instance._getDefaultColumnDef();
98
+
99
+ columnDef = { ...defaultColumn,
100
+ ...columnDef
101
+ };
102
+ let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
103
+ let accessorFn;
104
+
105
+ if (columnDef.accessorFn) {
106
+ accessorFn = columnDef.accessorFn;
107
+ } else if (columnDef.accessorKey) {
108
+ accessorFn = originalRow => originalRow[columnDef.accessorKey];
109
+ }
110
+
111
+ if (!id) {
112
+ {
113
+ throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
114
+ }
115
+ }
116
+
117
+ let column = { ...columnDef,
118
+ id: "" + id,
119
+ accessorFn,
120
+ parent: parent,
121
+ depth,
122
+ columnDef,
123
+ columnDefType: columnDef.columnDefType,
124
+ columns: [],
125
+ getFlatColumns: memo(() => [true], () => {
126
+ var _column$columns;
127
+
128
+ return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
129
+ }, {
130
+ key: "development" === 'production' ,
131
+ debug: () => {
132
+ var _instance$options$deb;
133
+
134
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
135
+ }
136
+ }),
137
+ getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
138
+ var _column$columns2;
139
+
140
+ if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
141
+ let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
142
+ return orderColumns(leafColumns);
143
+ }
144
+
145
+ return [column];
146
+ }, {
147
+ key: "development" === 'production' ,
148
+ debug: () => {
149
+ var _instance$options$deb2;
150
+
151
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
152
+ }
153
+ })
154
+ };
155
+ column = instance._features.reduce((obj, feature) => {
156
+ return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
157
+ }, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
158
+
159
+ return column;
160
+ }
161
+
94
162
  //
95
- const Columns = {
163
+ function createHeader(instance, column, options) {
164
+ var _options$id;
165
+
166
+ const id = (_options$id = options.id) != null ? _options$id : column.id;
167
+ let header = {
168
+ id,
169
+ column,
170
+ index: options.index,
171
+ isPlaceholder: !!options.isPlaceholder,
172
+ placeholderId: options.placeholderId,
173
+ depth: options.depth,
174
+ subHeaders: [],
175
+ colSpan: 0,
176
+ rowSpan: 0,
177
+ headerGroup: null,
178
+ getLeafHeaders: () => {
179
+ const leafHeaders = [];
180
+
181
+ const recurseHeader = h => {
182
+ if (h.subHeaders && h.subHeaders.length) {
183
+ h.subHeaders.map(recurseHeader);
184
+ }
185
+
186
+ leafHeaders.push(h);
187
+ };
188
+
189
+ recurseHeader(header);
190
+ return leafHeaders;
191
+ },
192
+ renderHeader: () => column.columnDef.header ? instance._render(column.columnDef.header, {
193
+ instance,
194
+ header: header,
195
+ column
196
+ }) : null,
197
+ renderFooter: () => column.columnDef.footer ? instance._render(column.columnDef.footer, {
198
+ instance,
199
+ header: header,
200
+ column
201
+ }) : null
202
+ };
203
+
204
+ instance._features.forEach(feature => {
205
+ Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
206
+ });
207
+
208
+ return header;
209
+ }
210
+
211
+ const Headers = {
96
212
  createInstance: instance => {
97
213
  return {
98
- getDefaultColumnDef: memo(() => [instance.options.defaultColumnDef], defaultColumn => {
99
- var _defaultColumn;
100
-
101
- defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
102
- return {
103
- header: props => props.header.column.id,
104
- footer: props => props.header.column.id,
105
- cell: props => {
106
- var _props$getValue$toStr, _props$getValue$toStr2, _props$getValue;
107
-
108
- 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;
109
- },
110
- ...instance._features.reduce((obj, feature) => {
111
- return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
112
- }, {}),
113
- ...defaultColumn
114
- };
214
+ // Header Groups
215
+ getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
216
+ var _left$map$filter, _right$map$filter;
217
+
218
+ const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
219
+ const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
220
+ const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
221
+ const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
222
+ return headerGroups;
115
223
  }, {
224
+ key: 'getHeaderGroups',
116
225
  debug: () => {
117
226
  var _instance$options$deb;
118
227
 
119
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
120
- },
121
- key: 'getDefaultColumnDef'
122
- }),
123
- getColumnDefs: () => instance.options.columns,
124
- createColumn: (columnDef, depth, parent) => {
125
- var _ref, _columnDef$id;
126
-
127
- const defaultColumnDef = instance.getDefaultColumnDef();
128
- columnDef = { ...defaultColumnDef,
129
- ...columnDef
130
- };
131
- let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
132
- let accessorFn;
133
-
134
- if (columnDef.accessorFn) {
135
- accessorFn = columnDef.accessorFn;
136
- } else if (columnDef.accessorKey) {
137
- accessorFn = originalRow => originalRow[columnDef.accessorKey];
228
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
138
229
  }
230
+ }),
231
+ getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
232
+ leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
233
+ return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
234
+ }, {
235
+ key: 'getCenterHeaderGroups',
236
+ debug: () => {
237
+ var _instance$options$deb2;
139
238
 
140
- if (!id) {
141
- {
142
- throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
143
- }
239
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
144
240
  }
241
+ }),
242
+ getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
243
+ var _left$map$filter2;
145
244
 
146
- let column = { ...columnDef,
147
- id: "" + id,
148
- accessorFn,
149
- parent: parent,
150
- depth,
151
- columnDef,
152
- columnDefType: columnDef.columnDefType,
153
- columns: [],
154
- getFlatColumns: memo(() => [true], () => {
155
- var _column$columns;
156
-
157
- return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
158
- }, {
159
- key: "development" === 'production' ,
160
- debug: () => {
161
- var _instance$options$deb2;
162
-
163
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
164
- }
165
- }),
166
- getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
167
- var _column$columns2;
168
-
169
- if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
170
- let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
171
- return orderColumns(leafColumns);
172
- }
173
-
174
- return [column];
175
- }, {
176
- key: "development" === 'production' ,
177
- debug: () => {
178
- var _instance$options$deb3;
179
-
180
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
181
- }
182
- })
183
- };
184
- column = instance._features.reduce((obj, feature) => {
185
- return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
186
- }, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
187
-
188
- return column;
189
- },
190
- getAllColumns: memo(() => [instance.getColumnDefs()], columnDefs => {
191
- const recurseColumns = function (columnDefs, parent, depth) {
192
- if (depth === void 0) {
193
- depth = 0;
194
- }
245
+ const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
246
+ return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
247
+ }, {
248
+ key: 'getLeftHeaderGroups',
249
+ debug: () => {
250
+ var _instance$options$deb3;
195
251
 
196
- return columnDefs.map(columnDef => {
197
- const column = instance.createColumn(columnDef, depth, parent);
198
- column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
199
- return column;
200
- });
201
- };
252
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
253
+ }
254
+ }),
255
+ getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
256
+ var _right$map$filter2;
202
257
 
203
- return recurseColumns(columnDefs);
258
+ const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
259
+ return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
204
260
  }, {
205
- key: 'getAllColumns',
261
+ key: 'getRightHeaderGroups',
206
262
  debug: () => {
207
263
  var _instance$options$deb4;
208
264
 
209
- return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
265
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
210
266
  }
211
267
  }),
212
- getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
213
- return allColumns.flatMap(column => {
214
- return column.getFlatColumns();
215
- });
268
+ // Footer Groups
269
+ getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
270
+ return [...headerGroups].reverse();
216
271
  }, {
217
- key: 'getAllFlatColumns',
272
+ key: 'getFooterGroups',
218
273
  debug: () => {
219
274
  var _instance$options$deb5;
220
275
 
221
- return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
276
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
222
277
  }
223
278
  }),
224
- getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
225
- return flatColumns.reduce((acc, column) => {
226
- acc[column.id] = column;
227
- return acc;
228
- }, {});
279
+ getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
280
+ return [...headerGroups].reverse();
229
281
  }, {
230
- key: 'getAllFlatColumnsById',
282
+ key: 'getLeftFooterGroups',
231
283
  debug: () => {
232
284
  var _instance$options$deb6;
233
285
 
234
- return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugColumns;
286
+ return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
235
287
  }
236
288
  }),
237
- getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
238
- let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
239
- return orderColumns(leafColumns);
289
+ getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
290
+ return [...headerGroups].reverse();
240
291
  }, {
241
- key: 'getAllLeafColumns',
292
+ key: 'getCenterFooterGroups',
242
293
  debug: () => {
243
294
  var _instance$options$deb7;
244
295
 
245
- return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugColumns;
296
+ return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
246
297
  }
247
298
  }),
248
- getColumn: columnId => {
249
- const column = instance.getAllFlatColumnsById()[columnId];
250
-
251
- if (!column) {
252
- {
253
- console.warn("[Table] Column with id " + columnId + " does not exist.");
254
- }
299
+ getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
300
+ return [...headerGroups].reverse();
301
+ }, {
302
+ key: 'getRightFooterGroups',
303
+ debug: () => {
304
+ var _instance$options$deb8;
255
305
 
256
- throw new Error();
306
+ return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
257
307
  }
308
+ }),
309
+ // Flat Headers
310
+ getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
311
+ return headerGroups.map(headerGroup => {
312
+ return headerGroup.headers;
313
+ }).flat();
314
+ }, {
315
+ key: 'getFlatHeaders',
316
+ debug: () => {
317
+ var _instance$options$deb9;
258
318
 
259
- return column;
260
- }
261
- };
262
- }
263
- };
264
-
265
- //
266
- const Rows = {
267
- // createRow: <TGenerics extends TableGenerics>(
268
- // row: Row<TGenerics>,
269
- // instance: TableInstance<TGenerics>
270
- // ): CellsRow<TGenerics> => {
271
- // return {}
272
- // },
273
- createInstance: instance => {
274
- return {
275
- getRowId: (row, index, parent) => {
276
- var _instance$options$get;
277
-
278
- 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);
279
- },
280
- createRow: (id, original, rowIndex, depth, subRows) => {
281
- let row = {
282
- id,
283
- index: rowIndex,
284
- original,
285
- depth,
286
- valuesCache: {},
287
- getValue: columnId => {
288
- if (row.valuesCache.hasOwnProperty(columnId)) {
289
- return row.valuesCache[columnId];
290
- }
291
-
292
- const column = instance.getColumn(columnId);
293
-
294
- if (!column.accessorFn) {
295
- return undefined;
296
- }
297
-
298
- row.valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
299
- return row.valuesCache[columnId];
300
- },
301
- subRows: subRows != null ? subRows : [],
302
- getLeafRows: () => flattenBy(row.subRows, d => d.subRows)
303
- };
304
-
305
- for (let i = 0; i < instance._features.length; i++) {
306
- const feature = instance._features[i];
307
- Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
319
+ return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
308
320
  }
321
+ }),
322
+ getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
323
+ return left.map(headerGroup => {
324
+ return headerGroup.headers;
325
+ }).flat();
326
+ }, {
327
+ key: 'getLeftFlatHeaders',
328
+ debug: () => {
329
+ var _instance$options$deb10;
309
330
 
310
- return row;
311
- },
312
- getCoreRowModel: () => {
313
- if (!instance._getCoreRowModel) {
314
- instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
331
+ return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
315
332
  }
333
+ }),
334
+ getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
335
+ return left.map(headerGroup => {
336
+ return headerGroup.headers;
337
+ }).flat();
338
+ }, {
339
+ key: 'getCenterFlatHeaders',
340
+ debug: () => {
341
+ var _instance$options$deb11;
316
342
 
317
- return instance._getCoreRowModel();
318
- },
319
- // The final calls start at the bottom of the model,
320
- // expanded rows, which then work their way up
321
- getRowModel: () => {
322
- return instance.getPaginationRowModel();
323
- },
324
- getRow: id => {
325
- const row = instance.getRowModel().rowsById[id];
326
-
327
- if (!row) {
328
- {
329
- throw new Error("getRow expected an ID, but got " + id);
330
- }
343
+ return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
331
344
  }
345
+ }),
346
+ getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
347
+ return left.map(headerGroup => {
348
+ return headerGroup.headers;
349
+ }).flat();
350
+ }, {
351
+ key: 'getRightFlatHeaders',
352
+ debug: () => {
353
+ var _instance$options$deb12;
332
354
 
333
- return row;
334
- }
335
- };
336
- }
337
- };
355
+ return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
356
+ }
357
+ }),
358
+ // Leaf Headers
359
+ getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
360
+ return flatHeaders.filter(header => {
361
+ var _header$subHeaders;
338
362
 
339
- //
340
- const Cells = {
341
- createRow: (row, instance) => {
342
- return {
343
- getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
344
- return leafColumns.map(column => {
345
- return instance.createCell(row, column, column.id);
363
+ return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
346
364
  });
347
365
  }, {
348
- key: 'row.getAllCells',
366
+ key: 'getCenterLeafHeaders',
349
367
  debug: () => {
350
- var _instance$options$deb;
368
+ var _instance$options$deb13;
351
369
 
352
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
370
+ return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
353
371
  }
354
372
  }),
355
- getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
356
- return allCells.reduce((acc, cell) => {
357
- acc[cell.columnId] = cell;
358
- return acc;
359
- }, {});
373
+ getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
374
+ return flatHeaders.filter(header => {
375
+ var _header$subHeaders2;
376
+
377
+ return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
378
+ });
360
379
  }, {
361
- key: "development" === 'production' ,
380
+ key: 'getLeftLeafHeaders',
362
381
  debug: () => {
363
- var _instance$options$deb2;
382
+ var _instance$options$deb14;
364
383
 
365
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
384
+ return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
366
385
  }
367
- })
368
- };
369
- },
370
- createInstance: instance => {
371
- return {
372
- createCell: (row, column, columnId) => {
373
- const cell = {
374
- id: row.id + "_" + column.id,
375
- rowId: row.id,
376
- columnId,
377
- row,
378
- column,
379
- getValue: () => row.getValue(columnId),
380
- renderCell: () => column.columnDef.cell ? instance._render(column.columnDef.cell, {
381
- instance,
382
- column,
383
- row,
384
- cell: cell,
385
- getValue: cell.getValue
386
- }) : null
387
- };
388
-
389
- instance._features.forEach(feature => {
390
- Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
391
- }, {});
386
+ }),
387
+ getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
388
+ return flatHeaders.filter(header => {
389
+ var _header$subHeaders3;
392
390
 
393
- return cell;
394
- },
395
- getCell: (rowId, columnId) => {
396
- const row = instance.getRow(rowId);
391
+ return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
392
+ });
393
+ }, {
394
+ key: 'getRightLeafHeaders',
395
+ debug: () => {
396
+ var _instance$options$deb15;
397
397
 
398
- if (!row) {
399
- {
400
- throw new Error("[Table] could not find row with id " + rowId);
401
- }
398
+ return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
402
399
  }
400
+ }),
401
+ getLeafHeaders: memo(() => [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()], (left, center, right) => {
402
+ var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
403
403
 
404
- const cell = row.getAllCellsByColumnId()[columnId];
404
+ 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 => {
405
+ return header.getLeafHeaders();
406
+ }).flat();
407
+ }, {
408
+ key: 'getLeafHeaders',
409
+ debug: () => {
410
+ var _instance$options$deb16;
405
411
 
406
- if (!cell) {
407
- {
408
- throw new Error("[Table] could not find cell " + columnId + " in row " + rowId);
409
- }
412
+ return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
410
413
  }
411
-
412
- return cell;
413
- }
414
+ })
414
415
  };
415
416
  }
416
417
  };
418
+ function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
419
+ var _headerGroups$0$heade, _headerGroups$;
420
+
421
+ // Find the max depth of the columns:
422
+ // build the leaf column row
423
+ // build each buffer row going up
424
+ // placeholder for non-existent level
425
+ // real column for existing level
426
+ let maxDepth = 0;
427
+
428
+ const findMaxDepth = function (columns, depth) {
429
+ if (depth === void 0) {
430
+ depth = 1;
431
+ }
432
+
433
+ maxDepth = Math.max(maxDepth, depth);
434
+ columns.filter(column => column.getIsVisible()).forEach(column => {
435
+ var _column$columns;
436
+
437
+ if ((_column$columns = column.columns) != null && _column$columns.length) {
438
+ findMaxDepth(column.columns, depth + 1);
439
+ }
440
+ }, 0);
441
+ };
442
+
443
+ findMaxDepth(allColumns);
444
+ let headerGroups = [];
445
+
446
+ const createHeaderGroup = (headersToGroup, depth) => {
447
+ // The header group we are creating
448
+ const headerGroup = {
449
+ depth,
450
+ id: [headerFamily, "" + depth].filter(Boolean).join('_'),
451
+ headers: []
452
+ }; // The parent columns we're going to scan next
453
+
454
+ const pendingParentHeaders = []; // Scan each column for parents
455
+
456
+ headersToGroup.forEach(headerToGroup => {
457
+ // What is the latest (last) parent column?
458
+ const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
459
+ const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
460
+ let column;
461
+ let isPlaceholder = false;
462
+
463
+ if (isLeafHeader && headerToGroup.column.parent) {
464
+ // The parent header is new
465
+ column = headerToGroup.column.parent;
466
+ } else {
467
+ // The parent header is repeated
468
+ column = headerToGroup.column;
469
+ isPlaceholder = true;
470
+ }
471
+
472
+ if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
473
+ // This column is repeated. Add it as a sub header to the next batch
474
+ latestPendingParentHeader.subHeaders.push(headerToGroup);
475
+ } else {
476
+ // This is a new header. Let's create it
477
+ const header = createHeader(instance, column, {
478
+ id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
479
+ isPlaceholder,
480
+ placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
481
+ depth,
482
+ index: pendingParentHeaders.length
483
+ }); // Add the headerToGroup as a subHeader of the new header
484
+
485
+ header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
486
+ // in the next batch
487
+
488
+ pendingParentHeaders.push(header);
489
+ }
490
+
491
+ headerGroup.headers.push(headerToGroup);
492
+ headerToGroup.headerGroup = headerGroup;
493
+ });
494
+ headerGroups.push(headerGroup);
495
+
496
+ if (depth > 0) {
497
+ createHeaderGroup(pendingParentHeaders, depth - 1);
498
+ }
499
+ };
500
+
501
+ const bottomHeaders = columnsToGroup.map((column, index) => createHeader(instance, column, {
502
+ depth: maxDepth,
503
+ index
504
+ }));
505
+ createHeaderGroup(bottomHeaders, maxDepth - 1);
506
+ headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
507
+ // return !headerGroup.headers.every(header => header.isPlaceholder)
508
+ // })
509
+
510
+ const recurseHeadersForSpans = headers => {
511
+ const filteredHeaders = headers.filter(header => header.column.getIsVisible());
512
+ return filteredHeaders.map(header => {
513
+ let colSpan = 0;
514
+ let rowSpan = 0;
515
+ let childRowSpans = [0];
516
+
517
+ if (header.subHeaders && header.subHeaders.length) {
518
+ childRowSpans = [];
519
+ recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
520
+ let {
521
+ colSpan: childColSpan,
522
+ rowSpan: childRowSpan
523
+ } = _ref;
524
+ colSpan += childColSpan;
525
+ childRowSpans.push(childRowSpan);
526
+ });
527
+ } else {
528
+ colSpan = 1;
529
+ }
530
+
531
+ const minChildRowSpan = Math.min(...childRowSpans);
532
+ rowSpan = rowSpan + minChildRowSpan;
533
+ header.colSpan = colSpan;
534
+ header.rowSpan = rowSpan;
535
+ return {
536
+ colSpan,
537
+ rowSpan
538
+ };
539
+ });
540
+ };
541
+
542
+ recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
543
+ return headerGroups;
544
+ }
417
545
 
418
546
  //
419
547
  const defaultColumnSizing = {
@@ -960,7 +1088,7 @@
960
1088
  getColumnCanGlobalFilter: column => {
961
1089
  var _instance$getCoreRowM, _instance$getCoreRowM2;
962
1090
 
963
- const value = (_instance$getCoreRowM = instance.getCoreRowModel().flatRows[0]) == null ? void 0 : (_instance$getCoreRowM2 = _instance$getCoreRowM.getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreRowM2.getValue();
1091
+ const value = (_instance$getCoreRowM = instance.getCoreRowModel().flatRows[0]) == null ? void 0 : (_instance$getCoreRowM2 = _instance$getCoreRowM._getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreRowM2.getValue();
964
1092
  return typeof value === 'string';
965
1093
  }
966
1094
  };
@@ -1738,7 +1866,7 @@
1738
1866
  return {
1739
1867
  getCenterVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allCells, left, right) => {
1740
1868
  const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
1741
- return allCells.filter(d => !leftAndRight.includes(d.columnId));
1869
+ return allCells.filter(d => !leftAndRight.includes(d.column.id));
1742
1870
  }, {
1743
1871
  key: "development" === 'production' ,
1744
1872
  debug: () => {
@@ -1748,7 +1876,7 @@
1748
1876
  }
1749
1877
  }),
1750
1878
  getLeftVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left,,], (allCells, left) => {
1751
- const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.columnId === columnId)).filter(Boolean).map(d => ({ ...d,
1879
+ const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
1752
1880
  position: 'left'
1753
1881
  }));
1754
1882
  return cells;
@@ -1761,7 +1889,7 @@
1761
1889
  }
1762
1890
  }),
1763
1891
  getRightVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.right], (allCells, right) => {
1764
- const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.columnId === columnId)).filter(Boolean).map(d => ({ ...d,
1892
+ const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
1765
1893
  position: 'left'
1766
1894
  }));
1767
1895
  return cells;
@@ -2566,481 +2694,76 @@
2566
2694
  };
2567
2695
  },
2568
2696
  createRow: (row, instance) => {
2569
- return {
2570
- _getAllVisibleCells: memo(() => [row.getAllCells().filter(cell => cell.column.getIsVisible()).map(d => d.id).join('_')], _ => {
2571
- return row.getAllCells().filter(cell => cell.column.getIsVisible());
2572
- }, {
2573
- key: "development" === 'production' ,
2574
- debug: () => {
2575
- var _instance$options$deb;
2576
-
2577
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
2578
- }
2579
- }),
2580
- getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
2581
- key: 'row.getVisibleCells',
2582
- debug: () => {
2583
- var _instance$options$deb2;
2584
-
2585
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
2586
- }
2587
- })
2588
- };
2589
- },
2590
- createInstance: instance => {
2591
- const makeVisibleColumnsMethod = (key, getColumns) => {
2592
- return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
2593
- return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
2594
- }, {
2595
- key,
2596
- debug: () => {
2597
- var _instance$options$deb3;
2598
-
2599
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2600
- }
2601
- });
2602
- };
2603
-
2604
- return {
2605
- getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
2606
- getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
2607
- getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
2608
- getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
2609
- getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
2610
- setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
2611
- resetColumnVisibility: defaultState => {
2612
- var _instance$initialStat;
2613
-
2614
- instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
2615
- },
2616
- toggleAllColumnsVisible: value => {
2617
- var _value;
2618
-
2619
- value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
2620
- instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
2621
- [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
2622
- }), {}));
2623
- },
2624
- getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
2625
- getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
2626
- getToggleAllColumnsVisibilityHandler: () => {
2627
- return e => {
2628
- var _target;
2629
-
2630
- instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
2631
- };
2632
- }
2633
- };
2634
- }
2635
- };
2636
-
2637
- //
2638
- const Headers = {
2639
- createInstance: instance => {
2640
- return {
2641
- createHeader: (column, options) => {
2642
- var _options$id;
2643
-
2644
- const id = (_options$id = options.id) != null ? _options$id : column.id;
2645
- let header = {
2646
- id,
2647
- column,
2648
- index: options.index,
2649
- isPlaceholder: options.isPlaceholder,
2650
- placeholderId: options.placeholderId,
2651
- depth: options.depth,
2652
- subHeaders: [],
2653
- colSpan: 0,
2654
- rowSpan: 0,
2655
- headerGroup: null,
2656
- getLeafHeaders: () => {
2657
- const leafHeaders = [];
2658
-
2659
- const recurseHeader = h => {
2660
- if (h.subHeaders && h.subHeaders.length) {
2661
- h.subHeaders.map(recurseHeader);
2662
- }
2663
-
2664
- leafHeaders.push(h);
2665
- };
2666
-
2667
- recurseHeader(header);
2668
- return leafHeaders;
2669
- },
2670
- renderHeader: () => column.columnDef.header ? instance._render(column.columnDef.header, {
2671
- instance,
2672
- header: header,
2673
- column
2674
- }) : null,
2675
- renderFooter: () => column.columnDef.footer ? instance._render(column.columnDef.footer, {
2676
- instance,
2677
- header: header,
2678
- column
2679
- }) : null
2680
- };
2681
-
2682
- instance._features.forEach(feature => {
2683
- Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
2684
- });
2685
-
2686
- return header;
2687
- },
2688
- // Header Groups
2689
- getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2690
- var _left$map$filter, _right$map$filter;
2691
-
2692
- const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
2693
- const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
2694
- const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2695
- const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
2696
- return headerGroups;
2697
- }, {
2698
- key: 'getHeaderGroups',
2699
- debug: () => {
2700
- var _instance$options$deb;
2701
-
2702
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
2703
- }
2704
- }),
2705
- getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2706
- leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2707
- return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
2708
- }, {
2709
- key: 'getCenterHeaderGroups',
2710
- debug: () => {
2711
- var _instance$options$deb2;
2712
-
2713
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
2714
- }
2715
- }),
2716
- getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
2717
- var _left$map$filter2;
2718
-
2719
- const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
2720
- return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
2721
- }, {
2722
- key: 'getLeftHeaderGroups',
2723
- debug: () => {
2724
- var _instance$options$deb3;
2725
-
2726
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
2727
- }
2728
- }),
2729
- getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
2730
- var _right$map$filter2;
2731
-
2732
- const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
2733
- return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
2734
- }, {
2735
- key: 'getRightHeaderGroups',
2736
- debug: () => {
2737
- var _instance$options$deb4;
2738
-
2739
- return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
2740
- }
2741
- }),
2742
- // Footer Groups
2743
- getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
2744
- return [...headerGroups].reverse();
2745
- }, {
2746
- key: 'getFooterGroups',
2747
- debug: () => {
2748
- var _instance$options$deb5;
2749
-
2750
- return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
2751
- }
2752
- }),
2753
- getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
2754
- return [...headerGroups].reverse();
2755
- }, {
2756
- key: 'getLeftFooterGroups',
2757
- debug: () => {
2758
- var _instance$options$deb6;
2759
-
2760
- return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
2761
- }
2762
- }),
2763
- getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
2764
- return [...headerGroups].reverse();
2765
- }, {
2766
- key: 'getCenterFooterGroups',
2767
- debug: () => {
2768
- var _instance$options$deb7;
2769
-
2770
- return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
2771
- }
2772
- }),
2773
- getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
2774
- return [...headerGroups].reverse();
2775
- }, {
2776
- key: 'getRightFooterGroups',
2777
- debug: () => {
2778
- var _instance$options$deb8;
2779
-
2780
- return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
2781
- }
2782
- }),
2783
- // Flat Headers
2784
- getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
2785
- return headerGroups.map(headerGroup => {
2786
- return headerGroup.headers;
2787
- }).flat();
2788
- }, {
2789
- key: 'getFlatHeaders',
2790
- debug: () => {
2791
- var _instance$options$deb9;
2792
-
2793
- return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
2794
- }
2795
- }),
2796
- getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
2797
- return left.map(headerGroup => {
2798
- return headerGroup.headers;
2799
- }).flat();
2800
- }, {
2801
- key: 'getLeftFlatHeaders',
2802
- debug: () => {
2803
- var _instance$options$deb10;
2804
-
2805
- return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
2806
- }
2807
- }),
2808
- getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
2809
- return left.map(headerGroup => {
2810
- return headerGroup.headers;
2811
- }).flat();
2812
- }, {
2813
- key: 'getCenterFlatHeaders',
2814
- debug: () => {
2815
- var _instance$options$deb11;
2816
-
2817
- return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
2818
- }
2819
- }),
2820
- getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
2821
- return left.map(headerGroup => {
2822
- return headerGroup.headers;
2823
- }).flat();
2824
- }, {
2825
- key: 'getRightFlatHeaders',
2826
- debug: () => {
2827
- var _instance$options$deb12;
2828
-
2829
- return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
2830
- }
2831
- }),
2832
- // Leaf Headers
2833
- getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
2834
- return flatHeaders.filter(header => {
2835
- var _header$subHeaders;
2836
-
2837
- return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
2838
- });
2839
- }, {
2840
- key: 'getCenterLeafHeaders',
2841
- debug: () => {
2842
- var _instance$options$deb13;
2843
-
2844
- return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
2845
- }
2846
- }),
2847
- getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
2848
- return flatHeaders.filter(header => {
2849
- var _header$subHeaders2;
2850
-
2851
- return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
2852
- });
2853
- }, {
2854
- key: 'getLeftLeafHeaders',
2855
- debug: () => {
2856
- var _instance$options$deb14;
2857
-
2858
- return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
2859
- }
2860
- }),
2861
- getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
2862
- return flatHeaders.filter(header => {
2863
- var _header$subHeaders3;
2864
-
2865
- return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
2866
- });
2697
+ return {
2698
+ _getAllVisibleCells: memo(() => [row.getAllCells().filter(cell => cell.column.getIsVisible()).map(d => d.id).join('_')], _ => {
2699
+ return row.getAllCells().filter(cell => cell.column.getIsVisible());
2867
2700
  }, {
2868
- key: 'getRightLeafHeaders',
2701
+ key: "development" === 'production' ,
2869
2702
  debug: () => {
2870
- var _instance$options$deb15;
2703
+ var _instance$options$deb;
2871
2704
 
2872
- return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
2705
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
2873
2706
  }
2874
2707
  }),
2875
- getLeafHeaders: memo(() => [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()], (left, center, right) => {
2876
- var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
2708
+ getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
2709
+ key: 'row.getVisibleCells',
2710
+ debug: () => {
2711
+ var _instance$options$deb2;
2877
2712
 
2878
- 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 => {
2879
- return header.getLeafHeaders();
2880
- }).flat();
2713
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
2714
+ }
2715
+ })
2716
+ };
2717
+ },
2718
+ createInstance: instance => {
2719
+ const makeVisibleColumnsMethod = (key, getColumns) => {
2720
+ return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
2721
+ return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
2881
2722
  }, {
2882
- key: 'getLeafHeaders',
2723
+ key,
2883
2724
  debug: () => {
2884
- var _instance$options$deb16;
2725
+ var _instance$options$deb3;
2885
2726
 
2886
- return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
2727
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2887
2728
  }
2888
- }),
2889
- getHeader: id => {
2890
- const header = [...instance.getFlatHeaders(), ...instance.getCenterFlatHeaders(), ...instance.getLeftFlatHeaders(), ...instance.getRightFlatHeaders()].find(d => d.id === id);
2729
+ });
2730
+ };
2891
2731
 
2892
- if (!header) {
2893
- {
2894
- console.warn("Could not find header with id: " + id);
2895
- }
2732
+ return {
2733
+ getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
2734
+ getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
2735
+ getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
2736
+ getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
2737
+ getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
2738
+ setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
2739
+ resetColumnVisibility: defaultState => {
2740
+ var _instance$initialStat;
2896
2741
 
2897
- throw new Error();
2898
- }
2742
+ instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
2743
+ },
2744
+ toggleAllColumnsVisible: value => {
2745
+ var _value;
2746
+
2747
+ value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
2748
+ instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
2749
+ [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
2750
+ }), {}));
2751
+ },
2752
+ getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
2753
+ getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
2754
+ getToggleAllColumnsVisibilityHandler: () => {
2755
+ return e => {
2756
+ var _target;
2899
2757
 
2900
- return header;
2758
+ instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
2759
+ };
2901
2760
  }
2902
2761
  };
2903
2762
  }
2904
2763
  };
2905
- function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
2906
- var _headerGroups$0$heade, _headerGroups$;
2907
-
2908
- // Find the max depth of the columns:
2909
- // build the leaf column row
2910
- // build each buffer row going up
2911
- // placeholder for non-existent level
2912
- // real column for existing level
2913
- let maxDepth = 0;
2914
-
2915
- const findMaxDepth = function (columns, depth) {
2916
- if (depth === void 0) {
2917
- depth = 1;
2918
- }
2919
-
2920
- maxDepth = Math.max(maxDepth, depth);
2921
- columns.filter(column => column.getIsVisible()).forEach(column => {
2922
- var _column$columns;
2923
-
2924
- if ((_column$columns = column.columns) != null && _column$columns.length) {
2925
- findMaxDepth(column.columns, depth + 1);
2926
- }
2927
- }, 0);
2928
- };
2929
-
2930
- findMaxDepth(allColumns);
2931
- let headerGroups = [];
2932
-
2933
- const createHeaderGroup = (headersToGroup, depth) => {
2934
- // The header group we are creating
2935
- const headerGroup = {
2936
- depth,
2937
- id: [headerFamily, "" + depth].filter(Boolean).join('_'),
2938
- headers: []
2939
- }; // The parent columns we're going to scan next
2940
-
2941
- const pendingParentHeaders = []; // Scan each column for parents
2942
-
2943
- headersToGroup.forEach(headerToGroup => {
2944
- // What is the latest (last) parent column?
2945
- const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
2946
- const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
2947
- let column;
2948
- let isPlaceholder = false;
2949
-
2950
- if (isLeafHeader && headerToGroup.column.parent) {
2951
- // The parent header is new
2952
- column = headerToGroup.column.parent;
2953
- } else {
2954
- // The parent header is repeated
2955
- column = headerToGroup.column;
2956
- isPlaceholder = true;
2957
- }
2958
-
2959
- if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
2960
- // This column is repeated. Add it as a sub header to the next batch
2961
- latestPendingParentHeader.subHeaders.push(headerToGroup);
2962
- } else {
2963
- // This is a new header. Let's create it
2964
- const header = instance.createHeader(column, {
2965
- id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
2966
- isPlaceholder,
2967
- placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
2968
- depth,
2969
- index: pendingParentHeaders.length
2970
- }); // Add the headerToGroup as a subHeader of the new header
2971
-
2972
- header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
2973
- // in the next batch
2974
-
2975
- pendingParentHeaders.push(header);
2976
- }
2977
-
2978
- headerGroup.headers.push(headerToGroup);
2979
- headerToGroup.headerGroup = headerGroup;
2980
- });
2981
- headerGroups.push(headerGroup);
2982
-
2983
- if (depth > 0) {
2984
- createHeaderGroup(pendingParentHeaders, depth - 1);
2985
- }
2986
- };
2987
-
2988
- const bottomHeaders = columnsToGroup.map((column, index) => instance.createHeader(column, {
2989
- depth: maxDepth,
2990
- index
2991
- }));
2992
- createHeaderGroup(bottomHeaders, maxDepth - 1);
2993
- headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
2994
- // return !headerGroup.headers.every(header => header.isPlaceholder)
2995
- // })
2996
-
2997
- const recurseHeadersForSpans = headers => {
2998
- const filteredHeaders = headers.filter(header => header.column.getIsVisible());
2999
- return filteredHeaders.map(header => {
3000
- let colSpan = 0;
3001
- let rowSpan = 0;
3002
- let childRowSpans = [0];
3003
-
3004
- if (header.subHeaders && header.subHeaders.length) {
3005
- childRowSpans = [];
3006
- recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
3007
- let {
3008
- colSpan: childColSpan,
3009
- rowSpan: childRowSpan
3010
- } = _ref;
3011
- colSpan += childColSpan;
3012
- childRowSpans.push(childRowSpan);
3013
- });
3014
- } else {
3015
- colSpan = 1;
3016
- }
3017
-
3018
- const minChildRowSpan = Math.min(...childRowSpans);
3019
- rowSpan = rowSpan + minChildRowSpan;
3020
- header.colSpan = colSpan > 0 ? colSpan : undefined;
3021
- header.rowSpan = rowSpan > 0 ? rowSpan : undefined;
3022
- return {
3023
- colSpan,
3024
- rowSpan
3025
- };
3026
- });
3027
- };
3028
2764
 
3029
- recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
3030
- return headerGroups;
3031
- }
2765
+ const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]; //
3032
2766
 
3033
- // export type Batch = {
3034
- // id: number
3035
- // priority: keyof CoreBatches
3036
- // tasks: (() => void)[]
3037
- // schedule: (cb: () => void) => void
3038
- // cancel: () => void
3039
- // }
3040
- // type CoreBatches = {
3041
- // data: Batch[]
3042
- // facets: Batch[]
3043
- // }
3044
2767
  function createTableInstance(options) {
3045
2768
  var _options$initialState;
3046
2769
 
@@ -3049,7 +2772,7 @@
3049
2772
  }
3050
2773
 
3051
2774
  let instance = {
3052
- _features: [Columns, Rows, Cells, Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]
2775
+ _features: features
3053
2776
  };
3054
2777
 
3055
2778
  const defaultOptions = instance._features.reduce((obj, feature) => {
@@ -3066,8 +2789,7 @@
3066
2789
  };
3067
2790
  };
3068
2791
 
3069
- const coreInitialState = {// coreProgress: 1,
3070
- };
2792
+ const coreInitialState = {};
3071
2793
  let initialState = { ...coreInitialState,
3072
2794
  ...((_options$initialState = options.initialState) != null ? _options$initialState : {})
3073
2795
  };
@@ -3080,16 +2802,8 @@
3080
2802
 
3081
2803
  const queued = [];
3082
2804
  let queuedTimeout = false;
3083
- const midInstance = { ...instance,
3084
- // init: () => {
3085
- // startWork()
3086
- // },
3087
- // willUpdate: () => {
3088
- // startWork()
3089
- // },
3090
- // destroy: () => {
3091
- // stopWork()
3092
- // },
2805
+ const coreInstance = {
2806
+ _features: features,
3093
2807
  options: { ...defaultOptions,
3094
2808
  ...options
3095
2809
  },
@@ -3135,29 +2849,134 @@
3135
2849
  },
3136
2850
  setState: updater => {
3137
2851
  instance.options.onStateChange == null ? void 0 : instance.options.onStateChange(updater);
3138
- } // getOverallProgress: () => {
3139
- // const { coreProgress, filtersProgress, facetProgress } =
3140
- // instance.getState()
3141
- // return mean(() =>
3142
- // [coreProgress, filtersProgress].filter(d => d < 1)
3143
- // ) as number
3144
- // },
3145
- // getProgressStage: () => {
3146
- // const { coreProgress, filtersProgress, facetProgress } =
3147
- // instance.getState()
3148
- // if (coreProgress < 1) {
3149
- // return 'coreRowModel'
3150
- // }
3151
- // if (filtersProgress < 1) {
3152
- // return 'filteredRowModel'
3153
- // }
3154
- // if (Object.values(facetProgress).some(d => d < 1)) {
3155
- // return 'facetedRowModel'
3156
- // }
3157
- // },
2852
+ },
2853
+ _getRowId: (row, index, parent) => {
2854
+ var _instance$options$get;
2855
+
2856
+ 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);
2857
+ },
2858
+ getCoreRowModel: () => {
2859
+ if (!instance._getCoreRowModel) {
2860
+ instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
2861
+ }
3158
2862
 
2863
+ return instance._getCoreRowModel();
2864
+ },
2865
+ // The final calls start at the bottom of the model,
2866
+ // expanded rows, which then work their way up
2867
+ getRowModel: () => {
2868
+ return instance.getPaginationRowModel();
2869
+ },
2870
+ getRow: id => {
2871
+ const row = instance.getRowModel().rowsById[id];
2872
+
2873
+ if (!row) {
2874
+ {
2875
+ throw new Error("getRow expected an ID, but got " + id);
2876
+ }
2877
+ }
2878
+
2879
+ return row;
2880
+ },
2881
+ _getDefaultColumnDef: memo(() => [instance.options.defaultColumn], defaultColumn => {
2882
+ var _defaultColumn;
2883
+
2884
+ defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
2885
+ return {
2886
+ header: props => props.header.column.id,
2887
+ footer: props => props.header.column.id,
2888
+ cell: props => {
2889
+ var _props$getValue$toStr, _props$getValue$toStr2, _props$getValue;
2890
+
2891
+ 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;
2892
+ },
2893
+ ...instance._features.reduce((obj, feature) => {
2894
+ return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
2895
+ }, {}),
2896
+ ...defaultColumn
2897
+ };
2898
+ }, {
2899
+ debug: () => {
2900
+ var _instance$options$deb;
2901
+
2902
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
2903
+ },
2904
+ key: 'getDefaultColumnDef'
2905
+ }),
2906
+ _getColumnDefs: () => instance.options.columns,
2907
+ getAllColumns: memo(() => [instance._getColumnDefs()], columnDefs => {
2908
+ const recurseColumns = function (columnDefs, parent, depth) {
2909
+ if (depth === void 0) {
2910
+ depth = 0;
2911
+ }
2912
+
2913
+ return columnDefs.map(columnDef => {
2914
+ const column = createColumn(instance, columnDef, depth, parent);
2915
+ column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
2916
+ return column;
2917
+ });
2918
+ };
2919
+
2920
+ return recurseColumns(columnDefs);
2921
+ }, {
2922
+ key: 'getAllColumns',
2923
+ debug: () => {
2924
+ var _instance$options$deb2;
2925
+
2926
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
2927
+ }
2928
+ }),
2929
+ getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
2930
+ return allColumns.flatMap(column => {
2931
+ return column.getFlatColumns();
2932
+ });
2933
+ }, {
2934
+ key: 'getAllFlatColumns',
2935
+ debug: () => {
2936
+ var _instance$options$deb3;
2937
+
2938
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2939
+ }
2940
+ }),
2941
+ _getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
2942
+ return flatColumns.reduce((acc, column) => {
2943
+ acc[column.id] = column;
2944
+ return acc;
2945
+ }, {});
2946
+ }, {
2947
+ key: 'getAllFlatColumnsById',
2948
+ debug: () => {
2949
+ var _instance$options$deb4;
2950
+
2951
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
2952
+ }
2953
+ }),
2954
+ getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
2955
+ let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
2956
+ return orderColumns(leafColumns);
2957
+ }, {
2958
+ key: 'getAllLeafColumns',
2959
+ debug: () => {
2960
+ var _instance$options$deb5;
2961
+
2962
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
2963
+ }
2964
+ }),
2965
+ getColumn: columnId => {
2966
+ const column = instance._getAllFlatColumnsById()[columnId];
2967
+
2968
+ if (!column) {
2969
+ {
2970
+ console.warn("[Table] Column with id " + columnId + " does not exist.");
2971
+ }
2972
+
2973
+ throw new Error();
2974
+ }
2975
+
2976
+ return column;
2977
+ }
3159
2978
  };
3160
- instance = Object.assign(instance, midInstance);
2979
+ Object.assign(instance, coreInstance);
3161
2980
 
3162
2981
  instance._features.forEach(feature => {
3163
2982
  return Object.assign(instance, feature.createInstance == null ? void 0 : feature.createInstance(instance));
@@ -3222,6 +3041,86 @@
3222
3041
  return table;
3223
3042
  }
3224
3043
 
3044
+ function createCell(instance, row, column, columnId) {
3045
+ const cell = {
3046
+ id: row.id + "_" + column.id,
3047
+ row,
3048
+ column,
3049
+ getValue: () => row.getValue(columnId),
3050
+ renderCell: () => column.columnDef.cell ? instance._render(column.columnDef.cell, {
3051
+ instance,
3052
+ column,
3053
+ row,
3054
+ cell: cell,
3055
+ getValue: cell.getValue
3056
+ }) : null
3057
+ };
3058
+
3059
+ instance._features.forEach(feature => {
3060
+ Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
3061
+ }, {});
3062
+
3063
+ return cell;
3064
+ }
3065
+
3066
+ const createRow = (instance, id, original, rowIndex, depth, subRows) => {
3067
+ let row = {
3068
+ id,
3069
+ index: rowIndex,
3070
+ original,
3071
+ depth,
3072
+ _valuesCache: {},
3073
+ getValue: columnId => {
3074
+ if (row._valuesCache.hasOwnProperty(columnId)) {
3075
+ return row._valuesCache[columnId];
3076
+ }
3077
+
3078
+ const column = instance.getColumn(columnId);
3079
+
3080
+ if (!column.accessorFn) {
3081
+ return undefined;
3082
+ }
3083
+
3084
+ row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
3085
+ return row._valuesCache[columnId];
3086
+ },
3087
+ subRows: subRows != null ? subRows : [],
3088
+ getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
3089
+ getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
3090
+ return leafColumns.map(column => {
3091
+ return createCell(instance, row, column, column.id);
3092
+ });
3093
+ }, {
3094
+ key: 'row.getAllCells',
3095
+ debug: () => {
3096
+ var _instance$options$deb;
3097
+
3098
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
3099
+ }
3100
+ }),
3101
+ _getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
3102
+ return allCells.reduce((acc, cell) => {
3103
+ acc[cell.column.id] = cell;
3104
+ return acc;
3105
+ }, {});
3106
+ }, {
3107
+ key: "development" === 'production' ,
3108
+ debug: () => {
3109
+ var _instance$options$deb2;
3110
+
3111
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
3112
+ }
3113
+ })
3114
+ };
3115
+
3116
+ for (let i = 0; i < instance._features.length; i++) {
3117
+ const feature = instance._features[i];
3118
+ Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
3119
+ }
3120
+
3121
+ return row;
3122
+ };
3123
+
3225
3124
  function getCoreRowModel() {
3226
3125
  return instance => memo(() => [instance.options.data], data => {
3227
3126
  const rowModel = {
@@ -3249,7 +3148,7 @@
3249
3148
  // }
3250
3149
  // Make the row
3251
3150
 
3252
- row = instance.createRow(instance.getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3151
+ row = createRow(instance, instance._getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3253
3152
 
3254
3153
  rowModel.flatRows.push(row); // Also keep track of every row by its ID
3255
3154
 
@@ -3312,7 +3211,7 @@
3312
3211
  row = rowsToFilter[i];
3313
3212
 
3314
3213
  if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
3315
- newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3214
+ newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3316
3215
  newRow.columnFilters = row.columnFilters;
3317
3216
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3318
3217
 
@@ -3362,7 +3261,7 @@
3362
3261
  var _row$subRows2;
3363
3262
 
3364
3263
  if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
3365
- newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3264
+ newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3366
3265
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3367
3266
  row = newRow;
3368
3267
  }
@@ -3729,7 +3628,7 @@
3729
3628
  const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
3730
3629
 
3731
3630
  const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
3732
- const row = instance.createRow(id, undefined, index, depth);
3631
+ const row = createRow(instance, id, undefined, index, depth);
3733
3632
  Object.assign(row, {
3734
3633
  groupingColumnId: columnId,
3735
3634
  groupingValue,
@@ -3738,17 +3637,17 @@
3738
3637
  getValue: columnId => {
3739
3638
  // Don't aggregate columns that are in the grouping
3740
3639
  if (existingGrouping.includes(columnId)) {
3741
- if (row.valuesCache.hasOwnProperty(columnId)) {
3742
- return row.valuesCache[columnId];
3640
+ if (row._valuesCache.hasOwnProperty(columnId)) {
3641
+ return row._valuesCache[columnId];
3743
3642
  }
3744
3643
 
3745
3644
  if (groupedRows[0]) {
3746
3645
  var _groupedRows$0$getVal;
3747
3646
 
3748
- row.valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
3647
+ row._valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
3749
3648
  }
3750
3649
 
3751
- return row.valuesCache[columnId];
3650
+ return row._valuesCache[columnId];
3752
3651
  }
3753
3652
 
3754
3653
  if (row.groupingValuesCache.hasOwnProperty(columnId)) {
@@ -3935,6 +3834,8 @@
3935
3834
  exports.Visibility = Visibility;
3936
3835
  exports.aggregationFns = aggregationFns;
3937
3836
  exports.buildHeaderGroups = buildHeaderGroups;
3837
+ exports.createColumn = createColumn;
3838
+ exports.createRow = createRow;
3938
3839
  exports.createTableFactory = createTableFactory;
3939
3840
  exports.createTableInstance = createTableInstance;
3940
3841
  exports.defaultColumnSizing = defaultColumnSizing;