@tanstack/table-core 8.0.0-alpha.82 → 8.0.0-alpha.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/build/cjs/aggregationFns.js +50 -51
  2. package/build/cjs/aggregationFns.js.map +1 -1
  3. package/build/cjs/core/cell.js +38 -0
  4. package/build/cjs/core/cell.js.map +1 -0
  5. package/build/cjs/core/column.js +88 -0
  6. package/build/cjs/core/column.js.map +1 -0
  7. package/build/cjs/{features/Headers.js → core/headers.js} +54 -66
  8. package/build/cjs/core/headers.js.map +1 -0
  9. package/build/cjs/core/instance.js +255 -0
  10. package/build/cjs/core/instance.js.map +1 -0
  11. package/build/cjs/core/row.js +77 -0
  12. package/build/cjs/core/row.js.map +1 -0
  13. package/build/cjs/createTable.js +3 -2
  14. package/build/cjs/createTable.js.map +1 -1
  15. package/build/cjs/features/ColumnSizing.js +5 -5
  16. package/build/cjs/features/ColumnSizing.js.map +1 -1
  17. package/build/cjs/features/Expanding.js.map +1 -1
  18. package/build/cjs/features/Filters.js +11 -8
  19. package/build/cjs/features/Filters.js.map +1 -1
  20. package/build/cjs/features/Grouping.js +10 -10
  21. package/build/cjs/features/Grouping.js.map +1 -1
  22. package/build/cjs/features/Ordering.js.map +1 -1
  23. package/build/cjs/features/Pagination.js.map +1 -1
  24. package/build/cjs/features/Pinning.js +17 -11
  25. package/build/cjs/features/Pinning.js.map +1 -1
  26. package/build/cjs/features/RowSelection.js.map +1 -1
  27. package/build/cjs/features/Sorting.js +8 -8
  28. package/build/cjs/features/Sorting.js.map +1 -1
  29. package/build/cjs/features/Visibility.js +3 -3
  30. package/build/cjs/features/Visibility.js.map +1 -1
  31. package/build/cjs/index.js +9 -6
  32. package/build/cjs/index.js.map +1 -1
  33. package/build/cjs/utils/filterRowsUtils.js +23 -21
  34. package/build/cjs/utils/filterRowsUtils.js.map +1 -1
  35. package/build/cjs/utils/getCoreRowModel.js +9 -8
  36. package/build/cjs/utils/getCoreRowModel.js.map +1 -1
  37. package/build/cjs/utils/getGroupedRowModel.js +13 -20
  38. package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
  39. package/build/cjs/utils/getSortedRowModel.js +2 -2
  40. package/build/cjs/utils/getSortedRowModel.js.map +1 -1
  41. package/build/esm/index.js +764 -865
  42. package/build/esm/index.js.map +1 -1
  43. package/build/stats-html.html +1 -1
  44. package/build/stats-react.json +404 -381
  45. package/build/types/aggregationFns.d.ts +10 -19
  46. package/build/types/core/cell.d.ts +9 -0
  47. package/build/types/{features/Columns.d.ts → core/column.d.ts} +3 -17
  48. package/build/types/{features/Headers.d.ts → core/headers.d.ts} +26 -11
  49. package/build/types/core/instance.d.ts +57 -0
  50. package/build/types/core/row.d.ts +15 -0
  51. package/build/types/createTable.d.ts +4 -4
  52. package/build/types/features/ColumnSizing.d.ts +2 -1
  53. package/build/types/features/Expanding.d.ts +2 -1
  54. package/build/types/features/Filters.d.ts +2 -3
  55. package/build/types/features/Grouping.d.ts +8 -9
  56. package/build/types/features/Ordering.d.ts +2 -1
  57. package/build/types/features/Pagination.d.ts +2 -1
  58. package/build/types/features/Pinning.d.ts +3 -2
  59. package/build/types/features/RowSelection.d.ts +2 -1
  60. package/build/types/features/Sorting.d.ts +2 -1
  61. package/build/types/features/Visibility.d.ts +2 -1
  62. package/build/types/index.d.ts +4 -2
  63. package/build/types/sortingFns.d.ts +4 -4
  64. package/build/types/types.d.ts +12 -53
  65. package/build/umd/index.development.js +767 -863
  66. package/build/umd/index.development.js.map +1 -1
  67. package/build/umd/index.production.js +1 -1
  68. package/build/umd/index.production.js.map +1 -1
  69. package/package.json +1 -1
  70. package/src/aggregationFns.ts +44 -40
  71. package/src/core/cell.ts +47 -0
  72. package/src/core/column.ts +148 -0
  73. package/src/{features/Headers.ts → core/headers.ts} +98 -99
  74. package/src/core/instance.ts +361 -0
  75. package/src/core/row.ts +85 -0
  76. package/src/createTable.ts +7 -4
  77. package/src/features/ColumnSizing.ts +6 -6
  78. package/src/features/Expanding.ts +1 -2
  79. package/src/features/Filters.ts +9 -10
  80. package/src/features/Grouping.ts +20 -22
  81. package/src/features/Ordering.ts +1 -1
  82. package/src/features/Pagination.ts +1 -1
  83. package/src/features/Pinning.ts +18 -9
  84. package/src/features/RowSelection.ts +1 -1
  85. package/src/features/Sorting.ts +10 -10
  86. package/src/features/Visibility.ts +3 -3
  87. package/src/index.ts +4 -8
  88. package/src/types.ts +16 -64
  89. package/src/utils/filterRowsUtils.ts +4 -2
  90. package/src/utils/getCoreRowModel.ts +4 -2
  91. package/src/utils/getGroupedRowModel.ts +14 -22
  92. package/src/utils/getSortedRowModel.ts +2 -2
  93. package/build/cjs/core.js +0 -168
  94. package/build/cjs/core.js.map +0 -1
  95. package/build/cjs/features/Cells.js +0 -101
  96. package/build/cjs/features/Cells.js.map +0 -1
  97. package/build/cjs/features/Columns.js +0 -189
  98. package/build/cjs/features/Columns.js.map +0 -1
  99. package/build/cjs/features/Headers.js.map +0 -1
  100. package/build/cjs/features/Rows.js +0 -94
  101. package/build/cjs/features/Rows.js.map +0 -1
  102. package/build/types/core.d.ts +0 -30
  103. package/build/types/features/Cells.d.ts +0 -13
  104. package/build/types/features/Rows.d.ts +0 -28
  105. package/src/core.ts +0 -246
  106. package/src/features/Cells.ts +0 -128
  107. package/src/features/Columns.ts +0 -289
  108. package/src/features/Rows.ts +0 -142
@@ -91,327 +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
- getDefaultColumn: memo(() => [instance.options.defaultColumn], 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.getDefaultColumn == null ? void 0 : feature.getDefaultColumn());
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: 'getDefaultColumn'
122
- }),
123
- getColumnDefs: () => instance.options.columns,
124
- createColumn: (columnDef, depth, parent) => {
125
- var _ref, _columnDef$id;
126
-
127
- const defaultColumn = instance.getDefaultColumn();
128
- let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
129
- let accessorFn;
130
-
131
- if (columnDef.accessorFn) {
132
- accessorFn = columnDef.accessorFn;
133
- } else if (columnDef.accessorKey) {
134
- accessorFn = originalRow => originalRow[columnDef.accessorKey];
228
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
135
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;
136
238
 
137
- if (!id) {
138
- {
139
- throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
140
- }
239
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
141
240
  }
241
+ }),
242
+ getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
243
+ var _left$map$filter2;
142
244
 
143
- let column = { ...defaultColumn,
144
- ...columnDef,
145
- id: "" + id,
146
- accessorFn,
147
- parent: parent,
148
- depth,
149
- columnDef,
150
- columnDefType: columnDef.columnDefType,
151
- columns: [],
152
- getFlatColumns: memo(() => [true], () => {
153
- var _column$columns;
154
-
155
- return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
156
- }, {
157
- key: "development" === 'production' ,
158
- debug: () => {
159
- var _instance$options$deb2;
160
-
161
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
162
- }
163
- }),
164
- getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
165
- var _column$columns2;
166
-
167
- if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
168
- let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
169
- return orderColumns(leafColumns);
170
- }
171
-
172
- return [column];
173
- }, {
174
- key: "development" === 'production' ,
175
- debug: () => {
176
- var _instance$options$deb3;
177
-
178
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
179
- }
180
- })
181
- };
182
- column = instance._features.reduce((obj, feature) => {
183
- return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
184
- }, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
185
-
186
- return column;
187
- },
188
- getAllColumns: memo(() => [instance.getColumnDefs()], columnDefs => {
189
- const recurseColumns = function (columnDefs, parent, depth) {
190
- if (depth === void 0) {
191
- depth = 0;
192
- }
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;
193
251
 
194
- return columnDefs.map(columnDef => {
195
- const column = instance.createColumn(columnDef, depth, parent);
196
- column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
197
- return column;
198
- });
199
- };
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;
200
257
 
201
- 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');
202
260
  }, {
203
- key: 'getAllColumns',
261
+ key: 'getRightHeaderGroups',
204
262
  debug: () => {
205
263
  var _instance$options$deb4;
206
264
 
207
- 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;
208
266
  }
209
267
  }),
210
- getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
211
- return allColumns.flatMap(column => {
212
- return column.getFlatColumns();
213
- });
268
+ // Footer Groups
269
+ getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
270
+ return [...headerGroups].reverse();
214
271
  }, {
215
- key: 'getAllFlatColumns',
272
+ key: 'getFooterGroups',
216
273
  debug: () => {
217
274
  var _instance$options$deb5;
218
275
 
219
- 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;
220
277
  }
221
278
  }),
222
- getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
223
- return flatColumns.reduce((acc, column) => {
224
- acc[column.id] = column;
225
- return acc;
226
- }, {});
279
+ getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
280
+ return [...headerGroups].reverse();
227
281
  }, {
228
- key: 'getAllFlatColumnsById',
282
+ key: 'getLeftFooterGroups',
229
283
  debug: () => {
230
284
  var _instance$options$deb6;
231
285
 
232
- 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;
233
287
  }
234
288
  }),
235
- getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
236
- let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
237
- return orderColumns(leafColumns);
289
+ getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
290
+ return [...headerGroups].reverse();
238
291
  }, {
239
- key: 'getAllLeafColumns',
292
+ key: 'getCenterFooterGroups',
240
293
  debug: () => {
241
294
  var _instance$options$deb7;
242
295
 
243
- 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;
244
297
  }
245
298
  }),
246
- getColumn: columnId => {
247
- const column = instance.getAllFlatColumnsById()[columnId];
248
-
249
- if (!column) {
250
- {
251
- console.warn("[Table] Column with id " + columnId + " does not exist.");
252
- }
299
+ getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
300
+ return [...headerGroups].reverse();
301
+ }, {
302
+ key: 'getRightFooterGroups',
303
+ debug: () => {
304
+ var _instance$options$deb8;
253
305
 
254
- throw new Error();
306
+ return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
255
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;
256
318
 
257
- return column;
258
- }
259
- };
260
- }
261
- };
262
-
263
- //
264
- const Rows = {
265
- // createRow: <TGenerics extends TableGenerics>(
266
- // row: Row<TGenerics>,
267
- // instance: TableInstance<TGenerics>
268
- // ): CellsRow<TGenerics> => {
269
- // return {}
270
- // },
271
- createInstance: instance => {
272
- return {
273
- getRowId: (row, index, parent) => {
274
- var _instance$options$get;
275
-
276
- 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);
277
- },
278
- createRow: (id, original, rowIndex, depth, subRows) => {
279
- let row = {
280
- id,
281
- index: rowIndex,
282
- original,
283
- depth,
284
- valuesCache: {},
285
- getValue: columnId => {
286
- if (row.valuesCache.hasOwnProperty(columnId)) {
287
- return row.valuesCache[columnId];
288
- }
289
-
290
- const column = instance.getColumn(columnId);
291
-
292
- if (!column.accessorFn) {
293
- return undefined;
294
- }
295
-
296
- row.valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
297
- return row.valuesCache[columnId];
298
- },
299
- subRows: subRows != null ? subRows : [],
300
- getLeafRows: () => flattenBy(row.subRows, d => d.subRows)
301
- };
302
-
303
- for (let i = 0; i < instance._features.length; i++) {
304
- const feature = instance._features[i];
305
- 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;
306
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;
307
330
 
308
- return row;
309
- },
310
- getCoreRowModel: () => {
311
- if (!instance._getCoreRowModel) {
312
- instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
331
+ return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
313
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;
314
342
 
315
- return instance._getCoreRowModel();
316
- },
317
- // The final calls start at the bottom of the model,
318
- // expanded rows, which then work their way up
319
- getRowModel: () => {
320
- return instance.getPaginationRowModel();
321
- },
322
- getRow: id => {
323
- const row = instance.getRowModel().rowsById[id];
324
-
325
- if (!row) {
326
- {
327
- throw new Error("getRow expected an ID, but got " + id);
328
- }
343
+ return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
329
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;
330
354
 
331
- return row;
332
- }
333
- };
334
- }
335
- };
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;
336
362
 
337
- //
338
- const Cells = {
339
- createRow: (row, instance) => {
340
- return {
341
- getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
342
- return leafColumns.map(column => {
343
- return instance.createCell(row, column, column.id);
363
+ return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
344
364
  });
345
365
  }, {
346
- key: 'row.getAllCells',
366
+ key: 'getCenterLeafHeaders',
347
367
  debug: () => {
348
- var _instance$options$deb;
368
+ var _instance$options$deb13;
349
369
 
350
- 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;
351
371
  }
352
372
  }),
353
- getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
354
- return allCells.reduce((acc, cell) => {
355
- acc[cell.columnId] = cell;
356
- return acc;
357
- }, {});
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
+ });
358
379
  }, {
359
- key: "development" === 'production' ,
380
+ key: 'getLeftLeafHeaders',
360
381
  debug: () => {
361
- var _instance$options$deb2;
382
+ var _instance$options$deb14;
362
383
 
363
- 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;
364
385
  }
365
- })
366
- };
367
- },
368
- createInstance: instance => {
369
- return {
370
- createCell: (row, column, columnId) => {
371
- const cell = {
372
- id: row.id + "_" + column.id,
373
- rowId: row.id,
374
- columnId,
375
- row,
376
- column,
377
- getValue: () => row.getValue(columnId),
378
- renderCell: () => column.cell ? instance._render(column.cell, {
379
- instance,
380
- column,
381
- row,
382
- cell: cell,
383
- getValue: cell.getValue
384
- }) : null
385
- };
386
-
387
- instance._features.forEach(feature => {
388
- Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
389
- }, {});
386
+ }),
387
+ getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
388
+ return flatHeaders.filter(header => {
389
+ var _header$subHeaders3;
390
390
 
391
- return cell;
392
- },
393
- getCell: (rowId, columnId) => {
394
- 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;
395
397
 
396
- if (!row) {
397
- {
398
- throw new Error("[Table] could not find row with id " + rowId);
399
- }
398
+ return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
400
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$;
401
403
 
402
- 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;
403
411
 
404
- if (!cell) {
405
- {
406
- throw new Error("[Table] could not find cell " + columnId + " in row " + rowId);
407
- }
412
+ return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
408
413
  }
409
-
410
- return cell;
411
- }
414
+ })
412
415
  };
413
416
  }
414
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
+ }
415
545
 
416
546
  //
417
547
  const defaultColumnSizing = {
@@ -430,7 +560,7 @@
430
560
  });
431
561
 
432
562
  const ColumnSizing = {
433
- getDefaultColumn: () => {
563
+ getDefaultColumnDef: () => {
434
564
  return defaultColumnSizing;
435
565
  },
436
566
  getInitialState: state => {
@@ -450,10 +580,10 @@
450
580
  createColumn: (column, instance) => {
451
581
  return {
452
582
  getSize: () => {
453
- var _column$minSize, _ref, _column$maxSize;
583
+ var _column$columnDef$min, _ref, _column$columnDef$max;
454
584
 
455
585
  const columnSize = instance.getState().columnSizing[column.id];
456
- return Math.min(Math.max((_column$minSize = column.minSize) != null ? _column$minSize : defaultColumnSizing.minSize, (_ref = columnSize != null ? columnSize : column.size) != null ? _ref : defaultColumnSizing.size), (_column$maxSize = column.maxSize) != null ? _column$maxSize : defaultColumnSizing.maxSize);
586
+ return Math.min(Math.max((_column$columnDef$min = column.columnDef.minSize) != null ? _column$columnDef$min : defaultColumnSizing.minSize, (_ref = columnSize != null ? columnSize : column.columnDef.size) != null ? _ref : defaultColumnSizing.size), (_column$columnDef$max = column.columnDef.maxSize) != null ? _column$columnDef$max : defaultColumnSizing.maxSize);
457
587
  },
458
588
  getStart: position => {
459
589
  const columns = !position ? instance.getVisibleLeafColumns() : position === 'left' ? instance.getLeftVisibleLeafColumns() : instance.getRightVisibleLeafColumns();
@@ -476,9 +606,9 @@
476
606
  });
477
607
  },
478
608
  getCanResize: () => {
479
- var _column$enableResizin, _instance$options$ena;
609
+ var _column$columnDef$ena, _instance$options$ena;
480
610
 
481
- return ((_column$enableResizin = column.enableResizing) != null ? _column$enableResizin : true) && ((_instance$options$ena = instance.options.enableColumnResizing) != null ? _instance$options$ena : true);
611
+ return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableColumnResizing) != null ? _instance$options$ena : true);
482
612
  },
483
613
  getIsResizing: () => {
484
614
  return instance.getState().columnSizingInfo.isResizingColumn === column.id;
@@ -935,7 +1065,7 @@
935
1065
 
936
1066
  //
937
1067
  const Filters = {
938
- getDefaultColumn: () => {
1068
+ getDefaultColumnDef: () => {
939
1069
  return {
940
1070
  filterFn: 'auto'
941
1071
  };
@@ -958,7 +1088,7 @@
958
1088
  getColumnCanGlobalFilter: column => {
959
1089
  var _instance$getCoreRowM, _instance$getCoreRowM2;
960
1090
 
961
- 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();
962
1092
  return typeof value === 'string';
963
1093
  }
964
1094
  };
@@ -978,6 +1108,10 @@
978
1108
  return filterFns.inNumberRange;
979
1109
  }
980
1110
 
1111
+ if (typeof value === 'boolean') {
1112
+ return filterFns.equals;
1113
+ }
1114
+
981
1115
  if (value !== null && typeof value === 'object') {
982
1116
  return filterFns.equals;
983
1117
  }
@@ -995,14 +1129,14 @@
995
1129
  return isFunction(column.filterFn) ? column.filterFn : column.filterFn === 'auto' ? column.getAutoFilterFn() : (_ref = userFilterFns == null ? void 0 : userFilterFns[column.filterFn]) != null ? _ref : filterFns[column.filterFn];
996
1130
  },
997
1131
  getCanFilter: () => {
998
- var _column$enableColumnF, _instance$options$ena, _instance$options$ena2;
1132
+ var _column$columnDef$ena, _instance$options$ena, _instance$options$ena2;
999
1133
 
1000
- return ((_column$enableColumnF = column.enableColumnFilter) != null ? _column$enableColumnF : true) && ((_instance$options$ena = instance.options.enableColumnFilters) != null ? _instance$options$ena : true) && ((_instance$options$ena2 = instance.options.enableFilters) != null ? _instance$options$ena2 : true) && !!column.accessorFn;
1134
+ return ((_column$columnDef$ena = column.columnDef.enableColumnFilter) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableColumnFilters) != null ? _instance$options$ena : true) && ((_instance$options$ena2 = instance.options.enableFilters) != null ? _instance$options$ena2 : true) && !!column.accessorFn;
1001
1135
  },
1002
1136
  getCanGlobalFilter: () => {
1003
- var _column$enableGlobalF, _instance$options$ena3, _instance$options$ena4, _instance$options$get;
1137
+ var _column$columnDef$ena2, _instance$options$ena3, _instance$options$ena4, _instance$options$get;
1004
1138
 
1005
- return ((_column$enableGlobalF = column.enableGlobalFilter) != null ? _column$enableGlobalF : true) && ((_instance$options$ena3 = instance.options.enableGlobalFilter) != null ? _instance$options$ena3 : true) && ((_instance$options$ena4 = instance.options.enableFilters) != null ? _instance$options$ena4 : true) && ((_instance$options$get = instance.options.getColumnCanGlobalFilter == null ? void 0 : instance.options.getColumnCanGlobalFilter(column)) != null ? _instance$options$get : true) && !!column.accessorFn;
1139
+ return ((_column$columnDef$ena2 = column.columnDef.enableGlobalFilter) != null ? _column$columnDef$ena2 : true) && ((_instance$options$ena3 = instance.options.enableGlobalFilter) != null ? _instance$options$ena3 : true) && ((_instance$options$ena4 = instance.options.enableFilters) != null ? _instance$options$ena4 : true) && ((_instance$options$get = instance.options.getColumnCanGlobalFilter == null ? void 0 : instance.options.getColumnCanGlobalFilter(column)) != null ? _instance$options$get : true) && !!column.accessorFn;
1006
1140
  },
1007
1141
  getIsFiltered: () => column.getFilterIndex() > -1,
1008
1142
  getFilterValue: () => {
@@ -1082,8 +1216,7 @@
1082
1216
  createRow: (row, instance) => {
1083
1217
  return {
1084
1218
  columnFilters: {},
1085
- columnFiltersMeta: {},
1086
- subRowsByFacetId: {}
1219
+ columnFiltersMeta: {}
1087
1220
  };
1088
1221
  },
1089
1222
  createInstance: instance => {
@@ -1174,53 +1307,42 @@
1174
1307
  return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
1175
1308
  }
1176
1309
 
1177
- const aggregationFns = {
1178
- sum,
1179
- min,
1180
- max,
1181
- extent,
1182
- mean,
1183
- median,
1184
- unique,
1185
- uniqueCount,
1186
- count
1187
- };
1188
-
1189
- function sum(_getLeafValues, getChildValues) {
1310
+ const sum = (columnId, _leafRows, childRows) => {
1190
1311
  // It's faster to just add the aggregations together instead of
1191
1312
  // process leaf nodes individually
1192
- return getChildValues().reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
1193
- }
1313
+ return childRows.reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
1314
+ };
1194
1315
 
1195
- function min(_getLeafValues, getChildValues) {
1316
+ const min = (columnId, _leafRows, childRows) => {
1196
1317
  let min;
1318
+ childRows.forEach(row => {
1319
+ const value = row.getValue(columnId);
1197
1320
 
1198
- for (const value of getChildValues()) {
1199
1321
  if (value != null && (min > value || min === undefined && value >= value)) {
1200
1322
  min = value;
1201
1323
  }
1202
- }
1203
-
1324
+ });
1204
1325
  return min;
1205
- }
1326
+ };
1206
1327
 
1207
- function max(_getLeafValues, getChildValues) {
1328
+ const max = (columnId, _leafRows, childRows) => {
1208
1329
  let max;
1330
+ childRows.forEach(row => {
1331
+ const value = row.getValue(columnId);
1209
1332
 
1210
- for (const value of getChildValues()) {
1211
1333
  if (value != null && (max < value || max === undefined && value >= value)) {
1212
1334
  max = value;
1213
1335
  }
1214
- }
1215
-
1336
+ });
1216
1337
  return max;
1217
- }
1338
+ };
1218
1339
 
1219
- function extent(_getLeafValues, getChildValues) {
1340
+ const extent = (columnId, _leafRows, childRows) => {
1220
1341
  let min;
1221
1342
  let max;
1343
+ childRows.forEach(row => {
1344
+ const value = row.getValue(columnId);
1222
1345
 
1223
- for (const value of getChildValues()) {
1224
1346
  if (value != null) {
1225
1347
  if (min === undefined) {
1226
1348
  if (value >= value) min = max = value;
@@ -1229,58 +1351,69 @@
1229
1351
  if (max < value) max = value;
1230
1352
  }
1231
1353
  }
1232
- }
1233
-
1354
+ });
1234
1355
  return [min, max];
1235
- }
1356
+ };
1236
1357
 
1237
- function mean(getLeafValues) {
1358
+ const mean = (columnId, leafRows) => {
1238
1359
  let count = 0;
1239
1360
  let sum = 0;
1361
+ leafRows.forEach(row => {
1362
+ let value = row.getValue(columnId);
1240
1363
 
1241
- for (let value of getLeafValues()) {
1242
1364
  if (value != null && (value = +value) >= value) {
1243
1365
  ++count, sum += value;
1244
1366
  }
1245
- }
1246
-
1367
+ });
1247
1368
  if (count) return sum / count;
1248
1369
  return;
1249
- }
1250
-
1251
- function median(getLeafValues) {
1252
- const leafValues = getLeafValues();
1370
+ };
1253
1371
 
1254
- if (!leafValues.length) {
1372
+ const median = (columnId, leafRows) => {
1373
+ if (!leafRows.length) {
1255
1374
  return;
1256
1375
  }
1257
1376
 
1258
1377
  let min = 0;
1259
1378
  let max = 0;
1260
- leafValues.forEach(value => {
1379
+ leafRows.forEach(row => {
1380
+ let value = row.getValue(columnId);
1381
+
1261
1382
  if (typeof value === 'number') {
1262
1383
  min = Math.min(min, value);
1263
1384
  max = Math.max(max, value);
1264
1385
  }
1265
1386
  });
1266
1387
  return (min + max) / 2;
1267
- }
1388
+ };
1268
1389
 
1269
- function unique(getLeafValues) {
1270
- return Array.from(new Set(getLeafValues()).values());
1271
- }
1390
+ const unique = (columnId, leafRows) => {
1391
+ return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
1392
+ };
1272
1393
 
1273
- function uniqueCount(getLeafValues) {
1274
- return new Set(getLeafValues()).size;
1275
- }
1394
+ const uniqueCount = (columnId, leafRows) => {
1395
+ return new Set(leafRows.map(d => d.getValue(columnId))).size;
1396
+ };
1276
1397
 
1277
- function count(getLeafValues) {
1278
- return getLeafValues().length;
1279
- }
1398
+ const count = (_columnId, leafRows) => {
1399
+ return leafRows.length;
1400
+ };
1401
+
1402
+ const aggregationFns = {
1403
+ sum,
1404
+ min,
1405
+ max,
1406
+ extent,
1407
+ mean,
1408
+ median,
1409
+ unique,
1410
+ uniqueCount,
1411
+ count
1412
+ };
1280
1413
 
1281
1414
  //
1282
1415
  const Grouping = {
1283
- getDefaultColumn: () => {
1416
+ getDefaultColumnDef: () => {
1284
1417
  return {
1285
1418
  aggregationFn: 'auto'
1286
1419
  };
@@ -1310,9 +1443,9 @@
1310
1443
  });
1311
1444
  },
1312
1445
  getCanGroup: () => {
1313
- var _ref, _ref2, _ref3, _column$enableGroupin;
1446
+ var _ref, _ref2, _ref3, _column$columnDef$ena;
1314
1447
 
1315
- return (_ref = (_ref2 = (_ref3 = (_column$enableGroupin = column.enableGrouping) != null ? _column$enableGroupin : true) != null ? _ref3 : instance.options.enableGrouping) != null ? _ref2 : true) != null ? _ref : !!column.accessorFn;
1448
+ return (_ref = (_ref2 = (_ref3 = (_column$columnDef$ena = column.columnDef.enableGrouping) != null ? _column$columnDef$ena : true) != null ? _ref3 : instance.options.enableGrouping) != null ? _ref2 : true) != null ? _ref : !!column.accessorFn;
1316
1449
  },
1317
1450
  getIsGrouped: () => {
1318
1451
  var _instance$getState$gr;
@@ -1331,7 +1464,7 @@
1331
1464
  column.toggleGrouping();
1332
1465
  };
1333
1466
  },
1334
- getColumnAutoAggregationFn: () => {
1467
+ getAutoAggregationFn: () => {
1335
1468
  const firstRow = instance.getCoreRowModel().flatRows[0];
1336
1469
  const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
1337
1470
 
@@ -1345,7 +1478,7 @@
1345
1478
 
1346
1479
  return aggregationFns.count;
1347
1480
  },
1348
- getColumnAggregationFn: () => {
1481
+ getAggregationFn: () => {
1349
1482
  var _ref4;
1350
1483
 
1351
1484
  const userAggregationFns = instance.options.aggregationFns;
@@ -1354,7 +1487,7 @@
1354
1487
  throw new Error();
1355
1488
  }
1356
1489
 
1357
- return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.getColumnAutoAggregationFn() : (_ref4 = userAggregationFns == null ? void 0 : userAggregationFns[column.aggregationFn]) != null ? _ref4 : aggregationFns[column.aggregationFn];
1490
+ return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_ref4 = userAggregationFns == null ? void 0 : userAggregationFns[column.aggregationFn]) != null ? _ref4 : aggregationFns[column.aggregationFn];
1358
1491
  }
1359
1492
  };
1360
1493
  },
@@ -1380,10 +1513,10 @@
1380
1513
  }
1381
1514
  };
1382
1515
  },
1383
- createRow: (row, instance) => {
1516
+ createRow: row => {
1384
1517
  return {
1385
1518
  getIsGrouped: () => !!row.groupingColumnId,
1386
- groupingValuesCache: {}
1519
+ _groupingValuesCache: {}
1387
1520
  };
1388
1521
  },
1389
1522
  createCell: (cell, column, row, instance) => {
@@ -1396,9 +1529,9 @@
1396
1529
  return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
1397
1530
  },
1398
1531
  renderAggregatedCell: () => {
1399
- var _column$aggregatedCel;
1532
+ var _column$columnDef$agg;
1400
1533
 
1401
- const template = (_column$aggregatedCel = column.aggregatedCell) != null ? _column$aggregatedCel : column.cell;
1534
+ const template = (_column$columnDef$agg = column.columnDef.aggregatedCell) != null ? _column$columnDef$agg : column.columnDef.cell;
1402
1535
  return template ? instance._render(template, {
1403
1536
  instance,
1404
1537
  column,
@@ -1705,9 +1838,9 @@
1705
1838
  getCanPin: () => {
1706
1839
  const leafColumns = column.getLeafColumns();
1707
1840
  return leafColumns.some(d => {
1708
- var _d$enablePinning, _instance$options$ena;
1841
+ var _d$columnDef$enablePi, _instance$options$ena;
1709
1842
 
1710
- return ((_d$enablePinning = d.enablePinning) != null ? _d$enablePinning : true) && ((_instance$options$ena = instance.options.enablePinning) != null ? _instance$options$ena : true);
1843
+ return ((_d$columnDef$enablePi = d.columnDef.enablePinning) != null ? _d$columnDef$enablePi : true) && ((_instance$options$ena = instance.options.enablePinning) != null ? _instance$options$ena : true);
1711
1844
  });
1712
1845
  },
1713
1846
  getIsPinned: () => {
@@ -1732,7 +1865,7 @@
1732
1865
  return {
1733
1866
  getCenterVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allCells, left, right) => {
1734
1867
  const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
1735
- return allCells.filter(d => !leftAndRight.includes(d.columnId));
1868
+ return allCells.filter(d => !leftAndRight.includes(d.column.id));
1736
1869
  }, {
1737
1870
  key: "development" === 'production' ,
1738
1871
  debug: () => {
@@ -1742,7 +1875,7 @@
1742
1875
  }
1743
1876
  }),
1744
1877
  getLeftVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left,,], (allCells, left) => {
1745
- const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.columnId === columnId)).filter(Boolean).map(d => ({ ...d,
1878
+ const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
1746
1879
  position: 'left'
1747
1880
  }));
1748
1881
  return cells;
@@ -1755,7 +1888,7 @@
1755
1888
  }
1756
1889
  }),
1757
1890
  getRightVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.right], (allCells, right) => {
1758
- const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.columnId === columnId)).filter(Boolean).map(d => ({ ...d,
1891
+ const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
1759
1892
  position: 'left'
1760
1893
  }));
1761
1894
  return cells;
@@ -1777,12 +1910,18 @@
1777
1910
 
1778
1911
  return instance.setColumnPinning(defaultState ? getDefaultPinningState() : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.columnPinning) != null ? _instance$initialStat : getDefaultPinningState());
1779
1912
  },
1780
- getIsSomeColumnsPinned: () => {
1781
- const {
1782
- left,
1783
- right
1784
- } = instance.getState().columnPinning;
1785
- return Boolean((left == null ? void 0 : left.length) || (right == null ? void 0 : right.length));
1913
+ getIsSomeColumnsPinned: position => {
1914
+ var _pinningState$positio;
1915
+
1916
+ const pinningState = instance.getState().columnPinning;
1917
+
1918
+ if (!position) {
1919
+ var _pinningState$left, _pinningState$right;
1920
+
1921
+ return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
1922
+ }
1923
+
1924
+ return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
1786
1925
  },
1787
1926
  getLeftLeafColumns: memo(() => [instance.getAllLeafColumns(), instance.getState().columnPinning.left], (allColumns, left) => {
1788
1927
  return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
@@ -2308,7 +2447,7 @@
2308
2447
  ...state
2309
2448
  };
2310
2449
  },
2311
- getDefaultColumn: () => {
2450
+ getDefaultColumnDef: () => {
2312
2451
  return {
2313
2452
  sortingFn: 'auto'
2314
2453
  };
@@ -2368,7 +2507,7 @@
2368
2507
  throw new Error();
2369
2508
  }
2370
2509
 
2371
- return isFunction(column.sortingFn) ? column.sortingFn : column.sortingFn === 'auto' ? column.getAutoSortingFn() : (_ref = userSortingFn == null ? void 0 : userSortingFn[column.sortingFn]) != null ? _ref : sortingFns[column.sortingFn];
2510
+ return isFunction(column.columnDef.sortingFn) ? column.columnDef.sortingFn : column.columnDef.sortingFn === 'auto' ? column.getAutoSortingFn() : (_ref = userSortingFn == null ? void 0 : userSortingFn[column.columnDef.sortingFn]) != null ? _ref : sortingFns[column.columnDef.sortingFn];
2372
2511
  },
2373
2512
  toggleSorting: (desc, multi) => {
2374
2513
  // if (column.columns.length) {
@@ -2380,7 +2519,7 @@
2380
2519
  // return
2381
2520
  // }
2382
2521
  instance.setSorting(old => {
2383
- var _ref2, _column$sortDescFirst, _instance$options$ena, _instance$options$ena2;
2522
+ var _ref2, _column$columnDef$sor, _instance$options$ena, _instance$options$ena2;
2384
2523
 
2385
2524
  // Find any existing sorting for this column
2386
2525
  const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
@@ -2407,7 +2546,7 @@
2407
2546
  }
2408
2547
  }
2409
2548
 
2410
- const sortDescFirst = (_ref2 = (_column$sortDescFirst = column.sortDescFirst) != null ? _column$sortDescFirst : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc'; // Handle toggle states that will remove the sorting
2549
+ const sortDescFirst = (_ref2 = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc'; // Handle toggle states that will remove the sorting
2411
2550
 
2412
2551
  if (sortAction === 'toggle' && ( // Must be toggling
2413
2552
  (_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
@@ -2451,14 +2590,14 @@
2451
2590
  });
2452
2591
  },
2453
2592
  getCanSort: () => {
2454
- var _column$enableSorting, _instance$options$ena3;
2593
+ var _column$columnDef$ena, _instance$options$ena3;
2455
2594
 
2456
- return ((_column$enableSorting = column.enableSorting) != null ? _column$enableSorting : true) && ((_instance$options$ena3 = instance.options.enableSorting) != null ? _instance$options$ena3 : true) && !!column.accessorFn;
2595
+ return ((_column$columnDef$ena = column.columnDef.enableSorting) != null ? _column$columnDef$ena : true) && ((_instance$options$ena3 = instance.options.enableSorting) != null ? _instance$options$ena3 : true) && !!column.accessorFn;
2457
2596
  },
2458
2597
  getCanMultiSort: () => {
2459
- var _ref3, _column$enableMultiSo;
2598
+ var _ref3, _column$columnDef$ena2;
2460
2599
 
2461
- return (_ref3 = (_column$enableMultiSo = column.enableMultiSort) != null ? _column$enableMultiSo : instance.options.enableMultiSort) != null ? _ref3 : !!column.accessorFn;
2600
+ return (_ref3 = (_column$columnDef$ena2 = column.columnDef.enableMultiSort) != null ? _column$columnDef$ena2 : instance.options.enableMultiSort) != null ? _ref3 : !!column.accessorFn;
2462
2601
  },
2463
2602
  getIsSorted: () => {
2464
2603
  var _instance$getState$so;
@@ -2522,7 +2661,7 @@
2522
2661
  onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
2523
2662
  };
2524
2663
  },
2525
- getDefaultColumn: () => {
2664
+ getDefaultColumnDef: () => {
2526
2665
  return {
2527
2666
  defaultIsVisible: true
2528
2667
  };
@@ -2542,9 +2681,9 @@
2542
2681
  return (_instance$getState$co = (_instance$getState$co2 = instance.getState().columnVisibility) == null ? void 0 : _instance$getState$co2[column.id]) != null ? _instance$getState$co : true;
2543
2682
  },
2544
2683
  getCanHide: () => {
2545
- var _column$enableHiding, _instance$options$ena;
2684
+ var _column$columnDef$ena, _instance$options$ena;
2546
2685
 
2547
- return ((_column$enableHiding = column.enableHiding) != null ? _column$enableHiding : true) && ((_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : true);
2686
+ return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : true);
2548
2687
  },
2549
2688
  getToggleVisibilityHandler: () => {
2550
2689
  return e => {
@@ -2558,477 +2697,72 @@
2558
2697
  _getAllVisibleCells: memo(() => [row.getAllCells().filter(cell => cell.column.getIsVisible()).map(d => d.id).join('_')], _ => {
2559
2698
  return row.getAllCells().filter(cell => cell.column.getIsVisible());
2560
2699
  }, {
2561
- key: "development" === 'production' ,
2562
- debug: () => {
2563
- var _instance$options$deb;
2564
-
2565
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
2566
- }
2567
- }),
2568
- getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
2569
- key: 'row.getVisibleCells',
2570
- debug: () => {
2571
- var _instance$options$deb2;
2572
-
2573
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
2574
- }
2575
- })
2576
- };
2577
- },
2578
- createInstance: instance => {
2579
- const makeVisibleColumnsMethod = (key, getColumns) => {
2580
- return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
2581
- return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
2582
- }, {
2583
- key,
2584
- debug: () => {
2585
- var _instance$options$deb3;
2586
-
2587
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2588
- }
2589
- });
2590
- };
2591
-
2592
- return {
2593
- getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
2594
- getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
2595
- getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
2596
- getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
2597
- getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
2598
- setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
2599
- resetColumnVisibility: defaultState => {
2600
- var _instance$initialStat;
2601
-
2602
- instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
2603
- },
2604
- toggleAllColumnsVisible: value => {
2605
- var _value;
2606
-
2607
- value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
2608
- instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
2609
- [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
2610
- }), {}));
2611
- },
2612
- getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
2613
- getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
2614
- getToggleAllColumnsVisibilityHandler: () => {
2615
- return e => {
2616
- var _target;
2617
-
2618
- instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
2619
- };
2620
- }
2621
- };
2622
- }
2623
- };
2624
-
2625
- //
2626
- const Headers = {
2627
- createInstance: instance => {
2628
- return {
2629
- createHeader: (column, options) => {
2630
- var _options$id;
2631
-
2632
- const id = (_options$id = options.id) != null ? _options$id : column.id;
2633
- let header = {
2634
- id,
2635
- column,
2636
- index: options.index,
2637
- isPlaceholder: options.isPlaceholder,
2638
- placeholderId: options.placeholderId,
2639
- depth: options.depth,
2640
- subHeaders: [],
2641
- colSpan: 0,
2642
- rowSpan: 0,
2643
- headerGroup: null,
2644
- getLeafHeaders: () => {
2645
- const leafHeaders = [];
2646
-
2647
- const recurseHeader = h => {
2648
- if (h.subHeaders && h.subHeaders.length) {
2649
- h.subHeaders.map(recurseHeader);
2650
- }
2651
-
2652
- leafHeaders.push(h);
2653
- };
2654
-
2655
- recurseHeader(header);
2656
- return leafHeaders;
2657
- },
2658
- renderHeader: () => column.header ? instance._render(column.header, {
2659
- instance,
2660
- header: header,
2661
- column
2662
- }) : null,
2663
- renderFooter: () => column.footer ? instance._render(column.footer, {
2664
- instance,
2665
- header: header,
2666
- column
2667
- }) : null
2668
- };
2669
-
2670
- instance._features.forEach(feature => {
2671
- Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
2672
- });
2673
-
2674
- return header;
2675
- },
2676
- // Header Groups
2677
- getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2678
- var _left$map$filter, _right$map$filter;
2679
-
2680
- const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
2681
- const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
2682
- const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2683
- const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
2684
- return headerGroups;
2685
- }, {
2686
- key: 'getHeaderGroups',
2687
- debug: () => {
2688
- var _instance$options$deb;
2689
-
2690
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
2691
- }
2692
- }),
2693
- getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2694
- leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2695
- return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
2696
- }, {
2697
- key: 'getCenterHeaderGroups',
2698
- debug: () => {
2699
- var _instance$options$deb2;
2700
-
2701
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
2702
- }
2703
- }),
2704
- getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
2705
- var _left$map$filter2;
2706
-
2707
- const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
2708
- return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
2709
- }, {
2710
- key: 'getLeftHeaderGroups',
2711
- debug: () => {
2712
- var _instance$options$deb3;
2713
-
2714
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
2715
- }
2716
- }),
2717
- getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
2718
- var _right$map$filter2;
2719
-
2720
- const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
2721
- return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
2722
- }, {
2723
- key: 'getRightHeaderGroups',
2724
- debug: () => {
2725
- var _instance$options$deb4;
2726
-
2727
- return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
2728
- }
2729
- }),
2730
- // Footer Groups
2731
- getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
2732
- return [...headerGroups].reverse();
2733
- }, {
2734
- key: 'getFooterGroups',
2735
- debug: () => {
2736
- var _instance$options$deb5;
2737
-
2738
- return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
2739
- }
2740
- }),
2741
- getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
2742
- return [...headerGroups].reverse();
2743
- }, {
2744
- key: 'getLeftFooterGroups',
2745
- debug: () => {
2746
- var _instance$options$deb6;
2747
-
2748
- return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
2749
- }
2750
- }),
2751
- getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
2752
- return [...headerGroups].reverse();
2753
- }, {
2754
- key: 'getCenterFooterGroups',
2755
- debug: () => {
2756
- var _instance$options$deb7;
2757
-
2758
- return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
2759
- }
2760
- }),
2761
- getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
2762
- return [...headerGroups].reverse();
2763
- }, {
2764
- key: 'getRightFooterGroups',
2765
- debug: () => {
2766
- var _instance$options$deb8;
2767
-
2768
- return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
2769
- }
2770
- }),
2771
- // Flat Headers
2772
- getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
2773
- return headerGroups.map(headerGroup => {
2774
- return headerGroup.headers;
2775
- }).flat();
2776
- }, {
2777
- key: 'getFlatHeaders',
2778
- debug: () => {
2779
- var _instance$options$deb9;
2780
-
2781
- return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
2782
- }
2783
- }),
2784
- getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
2785
- return left.map(headerGroup => {
2786
- return headerGroup.headers;
2787
- }).flat();
2788
- }, {
2789
- key: 'getLeftFlatHeaders',
2790
- debug: () => {
2791
- var _instance$options$deb10;
2792
-
2793
- return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
2794
- }
2795
- }),
2796
- getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
2797
- return left.map(headerGroup => {
2798
- return headerGroup.headers;
2799
- }).flat();
2800
- }, {
2801
- key: 'getCenterFlatHeaders',
2802
- debug: () => {
2803
- var _instance$options$deb11;
2804
-
2805
- return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
2806
- }
2807
- }),
2808
- getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
2809
- return left.map(headerGroup => {
2810
- return headerGroup.headers;
2811
- }).flat();
2812
- }, {
2813
- key: 'getRightFlatHeaders',
2814
- debug: () => {
2815
- var _instance$options$deb12;
2816
-
2817
- return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
2818
- }
2819
- }),
2820
- // Leaf Headers
2821
- getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
2822
- return flatHeaders.filter(header => {
2823
- var _header$subHeaders;
2824
-
2825
- return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
2826
- });
2827
- }, {
2828
- key: 'getCenterLeafHeaders',
2829
- debug: () => {
2830
- var _instance$options$deb13;
2831
-
2832
- return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
2833
- }
2834
- }),
2835
- getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
2836
- return flatHeaders.filter(header => {
2837
- var _header$subHeaders2;
2838
-
2839
- return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
2840
- });
2841
- }, {
2842
- key: 'getLeftLeafHeaders',
2843
- debug: () => {
2844
- var _instance$options$deb14;
2845
-
2846
- return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
2847
- }
2848
- }),
2849
- getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
2850
- return flatHeaders.filter(header => {
2851
- var _header$subHeaders3;
2852
-
2853
- return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
2854
- });
2855
- }, {
2856
- key: 'getRightLeafHeaders',
2700
+ key: "development" === 'production' ,
2857
2701
  debug: () => {
2858
- var _instance$options$deb15;
2702
+ var _instance$options$deb;
2859
2703
 
2860
- return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
2704
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
2861
2705
  }
2862
2706
  }),
2863
- getLeafHeaders: memo(() => [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()], (left, center, right) => {
2864
- var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
2707
+ getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
2708
+ key: 'row.getVisibleCells',
2709
+ debug: () => {
2710
+ var _instance$options$deb2;
2865
2711
 
2866
- 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 => {
2867
- return header.getLeafHeaders();
2868
- }).flat();
2712
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
2713
+ }
2714
+ })
2715
+ };
2716
+ },
2717
+ createInstance: instance => {
2718
+ const makeVisibleColumnsMethod = (key, getColumns) => {
2719
+ return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
2720
+ return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
2869
2721
  }, {
2870
- key: 'getLeafHeaders',
2722
+ key,
2871
2723
  debug: () => {
2872
- var _instance$options$deb16;
2724
+ var _instance$options$deb3;
2873
2725
 
2874
- return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
2726
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2875
2727
  }
2876
- }),
2877
- getHeader: id => {
2878
- const header = [...instance.getFlatHeaders(), ...instance.getCenterFlatHeaders(), ...instance.getLeftFlatHeaders(), ...instance.getRightFlatHeaders()].find(d => d.id === id);
2728
+ });
2729
+ };
2879
2730
 
2880
- if (!header) {
2881
- {
2882
- console.warn("Could not find header with id: " + id);
2883
- }
2731
+ return {
2732
+ getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
2733
+ getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
2734
+ getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
2735
+ getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
2736
+ getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
2737
+ setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
2738
+ resetColumnVisibility: defaultState => {
2739
+ var _instance$initialStat;
2884
2740
 
2885
- throw new Error();
2886
- }
2741
+ instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
2742
+ },
2743
+ toggleAllColumnsVisible: value => {
2744
+ var _value;
2887
2745
 
2888
- return header;
2746
+ value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
2747
+ instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
2748
+ [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
2749
+ }), {}));
2750
+ },
2751
+ getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
2752
+ getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
2753
+ getToggleAllColumnsVisibilityHandler: () => {
2754
+ return e => {
2755
+ var _target;
2756
+
2757
+ instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
2758
+ };
2889
2759
  }
2890
2760
  };
2891
2761
  }
2892
2762
  };
2893
- function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
2894
- var _headerGroups$0$heade, _headerGroups$;
2895
-
2896
- // Find the max depth of the columns:
2897
- // build the leaf column row
2898
- // build each buffer row going up
2899
- // placeholder for non-existent level
2900
- // real column for existing level
2901
- let maxDepth = 0;
2902
-
2903
- const findMaxDepth = function (columns, depth) {
2904
- if (depth === void 0) {
2905
- depth = 1;
2906
- }
2907
-
2908
- maxDepth = Math.max(maxDepth, depth);
2909
- columns.filter(column => column.getIsVisible()).forEach(column => {
2910
- var _column$columns;
2911
-
2912
- if ((_column$columns = column.columns) != null && _column$columns.length) {
2913
- findMaxDepth(column.columns, depth + 1);
2914
- }
2915
- }, 0);
2916
- };
2917
-
2918
- findMaxDepth(allColumns);
2919
- let headerGroups = [];
2920
-
2921
- const createHeaderGroup = (headersToGroup, depth) => {
2922
- // The header group we are creating
2923
- const headerGroup = {
2924
- depth,
2925
- id: [headerFamily, "" + depth].filter(Boolean).join('_'),
2926
- headers: []
2927
- }; // The parent columns we're going to scan next
2928
-
2929
- const pendingParentHeaders = []; // Scan each column for parents
2930
-
2931
- headersToGroup.forEach(headerToGroup => {
2932
- // What is the latest (last) parent column?
2933
- const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
2934
- const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
2935
- let column;
2936
- let isPlaceholder = false;
2937
-
2938
- if (isLeafHeader && headerToGroup.column.parent) {
2939
- // The parent header is new
2940
- column = headerToGroup.column.parent;
2941
- } else {
2942
- // The parent header is repeated
2943
- column = headerToGroup.column;
2944
- isPlaceholder = true;
2945
- }
2946
-
2947
- if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
2948
- // This column is repeated. Add it as a sub header to the next batch
2949
- latestPendingParentHeader.subHeaders.push(headerToGroup);
2950
- } else {
2951
- // This is a new header. Let's create it
2952
- const header = instance.createHeader(column, {
2953
- id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
2954
- isPlaceholder,
2955
- placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
2956
- depth,
2957
- index: pendingParentHeaders.length
2958
- }); // Add the headerToGroup as a subHeader of the new header
2959
-
2960
- header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
2961
- // in the next batch
2962
-
2963
- pendingParentHeaders.push(header);
2964
- }
2965
-
2966
- headerGroup.headers.push(headerToGroup);
2967
- headerToGroup.headerGroup = headerGroup;
2968
- });
2969
- headerGroups.push(headerGroup);
2970
-
2971
- if (depth > 0) {
2972
- createHeaderGroup(pendingParentHeaders, depth - 1);
2973
- }
2974
- };
2975
-
2976
- const bottomHeaders = columnsToGroup.map((column, index) => instance.createHeader(column, {
2977
- depth: maxDepth,
2978
- index
2979
- }));
2980
- createHeaderGroup(bottomHeaders, maxDepth - 1);
2981
- headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
2982
- // return !headerGroup.headers.every(header => header.isPlaceholder)
2983
- // })
2984
-
2985
- const recurseHeadersForSpans = headers => {
2986
- const filteredHeaders = headers.filter(header => header.column.getIsVisible());
2987
- return filteredHeaders.map(header => {
2988
- let colSpan = 0;
2989
- let rowSpan = 0;
2990
- let childRowSpans = [0];
2991
-
2992
- if (header.subHeaders && header.subHeaders.length) {
2993
- childRowSpans = [];
2994
- recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
2995
- let {
2996
- colSpan: childColSpan,
2997
- rowSpan: childRowSpan
2998
- } = _ref;
2999
- colSpan += childColSpan;
3000
- childRowSpans.push(childRowSpan);
3001
- });
3002
- } else {
3003
- colSpan = 1;
3004
- }
3005
-
3006
- const minChildRowSpan = Math.min(...childRowSpans);
3007
- rowSpan = rowSpan + minChildRowSpan;
3008
- header.colSpan = colSpan > 0 ? colSpan : undefined;
3009
- header.rowSpan = rowSpan > 0 ? rowSpan : undefined;
3010
- return {
3011
- colSpan,
3012
- rowSpan
3013
- };
3014
- });
3015
- };
3016
2763
 
3017
- recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
3018
- return headerGroups;
3019
- }
2764
+ const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]; //
3020
2765
 
3021
- // export type Batch = {
3022
- // id: number
3023
- // priority: keyof CoreBatches
3024
- // tasks: (() => void)[]
3025
- // schedule: (cb: () => void) => void
3026
- // cancel: () => void
3027
- // }
3028
- // type CoreBatches = {
3029
- // data: Batch[]
3030
- // facets: Batch[]
3031
- // }
3032
2766
  function createTableInstance(options) {
3033
2767
  var _options$initialState;
3034
2768
 
@@ -3037,7 +2771,7 @@
3037
2771
  }
3038
2772
 
3039
2773
  let instance = {
3040
- _features: [Columns, Rows, Cells, Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]
2774
+ _features: features
3041
2775
  };
3042
2776
 
3043
2777
  const defaultOptions = instance._features.reduce((obj, feature) => {
@@ -3054,8 +2788,7 @@
3054
2788
  };
3055
2789
  };
3056
2790
 
3057
- const coreInitialState = {// coreProgress: 1,
3058
- };
2791
+ const coreInitialState = {};
3059
2792
  let initialState = { ...coreInitialState,
3060
2793
  ...((_options$initialState = options.initialState) != null ? _options$initialState : {})
3061
2794
  };
@@ -3068,16 +2801,8 @@
3068
2801
 
3069
2802
  const queued = [];
3070
2803
  let queuedTimeout = false;
3071
- const midInstance = { ...instance,
3072
- // init: () => {
3073
- // startWork()
3074
- // },
3075
- // willUpdate: () => {
3076
- // startWork()
3077
- // },
3078
- // destroy: () => {
3079
- // stopWork()
3080
- // },
2804
+ const coreInstance = {
2805
+ _features: features,
3081
2806
  options: { ...defaultOptions,
3082
2807
  ...options
3083
2808
  },
@@ -3123,29 +2848,134 @@
3123
2848
  },
3124
2849
  setState: updater => {
3125
2850
  instance.options.onStateChange == null ? void 0 : instance.options.onStateChange(updater);
3126
- } // getOverallProgress: () => {
3127
- // const { coreProgress, filtersProgress, facetProgress } =
3128
- // instance.getState()
3129
- // return mean(() =>
3130
- // [coreProgress, filtersProgress].filter(d => d < 1)
3131
- // ) as number
3132
- // },
3133
- // getProgressStage: () => {
3134
- // const { coreProgress, filtersProgress, facetProgress } =
3135
- // instance.getState()
3136
- // if (coreProgress < 1) {
3137
- // return 'coreRowModel'
3138
- // }
3139
- // if (filtersProgress < 1) {
3140
- // return 'filteredRowModel'
3141
- // }
3142
- // if (Object.values(facetProgress).some(d => d < 1)) {
3143
- // return 'facetedRowModel'
3144
- // }
3145
- // },
2851
+ },
2852
+ _getRowId: (row, index, parent) => {
2853
+ var _instance$options$get;
2854
+
2855
+ 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);
2856
+ },
2857
+ getCoreRowModel: () => {
2858
+ if (!instance._getCoreRowModel) {
2859
+ instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
2860
+ }
2861
+
2862
+ return instance._getCoreRowModel();
2863
+ },
2864
+ // The final calls start at the bottom of the model,
2865
+ // expanded rows, which then work their way up
2866
+ getRowModel: () => {
2867
+ return instance.getPaginationRowModel();
2868
+ },
2869
+ getRow: id => {
2870
+ const row = instance.getRowModel().rowsById[id];
2871
+
2872
+ if (!row) {
2873
+ {
2874
+ throw new Error("getRow expected an ID, but got " + id);
2875
+ }
2876
+ }
2877
+
2878
+ return row;
2879
+ },
2880
+ _getDefaultColumnDef: memo(() => [instance.options.defaultColumn], defaultColumn => {
2881
+ var _defaultColumn;
2882
+
2883
+ defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
2884
+ return {
2885
+ header: props => props.header.column.id,
2886
+ footer: props => props.header.column.id,
2887
+ cell: props => {
2888
+ var _props$getValue$toStr, _props$getValue$toStr2, _props$getValue;
2889
+
2890
+ 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;
2891
+ },
2892
+ ...instance._features.reduce((obj, feature) => {
2893
+ return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
2894
+ }, {}),
2895
+ ...defaultColumn
2896
+ };
2897
+ }, {
2898
+ debug: () => {
2899
+ var _instance$options$deb;
2900
+
2901
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
2902
+ },
2903
+ key: 'getDefaultColumnDef'
2904
+ }),
2905
+ _getColumnDefs: () => instance.options.columns,
2906
+ getAllColumns: memo(() => [instance._getColumnDefs()], columnDefs => {
2907
+ const recurseColumns = function (columnDefs, parent, depth) {
2908
+ if (depth === void 0) {
2909
+ depth = 0;
2910
+ }
2911
+
2912
+ return columnDefs.map(columnDef => {
2913
+ const column = createColumn(instance, columnDef, depth, parent);
2914
+ column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
2915
+ return column;
2916
+ });
2917
+ };
2918
+
2919
+ return recurseColumns(columnDefs);
2920
+ }, {
2921
+ key: 'getAllColumns',
2922
+ debug: () => {
2923
+ var _instance$options$deb2;
2924
+
2925
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
2926
+ }
2927
+ }),
2928
+ getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
2929
+ return allColumns.flatMap(column => {
2930
+ return column.getFlatColumns();
2931
+ });
2932
+ }, {
2933
+ key: 'getAllFlatColumns',
2934
+ debug: () => {
2935
+ var _instance$options$deb3;
2936
+
2937
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2938
+ }
2939
+ }),
2940
+ _getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
2941
+ return flatColumns.reduce((acc, column) => {
2942
+ acc[column.id] = column;
2943
+ return acc;
2944
+ }, {});
2945
+ }, {
2946
+ key: 'getAllFlatColumnsById',
2947
+ debug: () => {
2948
+ var _instance$options$deb4;
2949
+
2950
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
2951
+ }
2952
+ }),
2953
+ getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
2954
+ let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
2955
+ return orderColumns(leafColumns);
2956
+ }, {
2957
+ key: 'getAllLeafColumns',
2958
+ debug: () => {
2959
+ var _instance$options$deb5;
2960
+
2961
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
2962
+ }
2963
+ }),
2964
+ getColumn: columnId => {
2965
+ const column = instance._getAllFlatColumnsById()[columnId];
2966
+
2967
+ if (!column) {
2968
+ {
2969
+ console.warn("[Table] Column with id " + columnId + " does not exist.");
2970
+ }
2971
+
2972
+ throw new Error();
2973
+ }
3146
2974
 
2975
+ return column;
2976
+ }
3147
2977
  };
3148
- instance = Object.assign(instance, midInstance);
2978
+ Object.assign(instance, coreInstance);
3149
2979
 
3150
2980
  instance._features.forEach(feature => {
3151
2981
  return Object.assign(instance, feature.createInstance == null ? void 0 : feature.createInstance(instance));
@@ -3168,7 +2998,7 @@
3168
2998
  throw new Error('');
3169
2999
  })()
3170
3000
  },
3171
- setGenerics: () => table,
3001
+ // setGenerics: () => table as any,
3172
3002
  setRowType: () => table,
3173
3003
  setTableMetaType: () => table,
3174
3004
  setColumnMetaType: () => table,
@@ -3204,11 +3034,92 @@
3204
3034
  }
3205
3035
 
3206
3036
  throw new Error('Invalid accessor');
3207
- }
3037
+ },
3038
+ createOptions: options => options
3208
3039
  };
3209
3040
  return table;
3210
3041
  }
3211
3042
 
3043
+ function createCell(instance, row, column, columnId) {
3044
+ const cell = {
3045
+ id: row.id + "_" + column.id,
3046
+ row,
3047
+ column,
3048
+ getValue: () => row.getValue(columnId),
3049
+ renderCell: () => column.columnDef.cell ? instance._render(column.columnDef.cell, {
3050
+ instance,
3051
+ column,
3052
+ row,
3053
+ cell: cell,
3054
+ getValue: cell.getValue
3055
+ }) : null
3056
+ };
3057
+
3058
+ instance._features.forEach(feature => {
3059
+ Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
3060
+ }, {});
3061
+
3062
+ return cell;
3063
+ }
3064
+
3065
+ const createRow = (instance, id, original, rowIndex, depth, subRows) => {
3066
+ let row = {
3067
+ id,
3068
+ index: rowIndex,
3069
+ original,
3070
+ depth,
3071
+ _valuesCache: {},
3072
+ getValue: columnId => {
3073
+ if (row._valuesCache.hasOwnProperty(columnId)) {
3074
+ return row._valuesCache[columnId];
3075
+ }
3076
+
3077
+ const column = instance.getColumn(columnId);
3078
+
3079
+ if (!column.accessorFn) {
3080
+ return undefined;
3081
+ }
3082
+
3083
+ row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
3084
+ return row._valuesCache[columnId];
3085
+ },
3086
+ subRows: subRows != null ? subRows : [],
3087
+ getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
3088
+ getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
3089
+ return leafColumns.map(column => {
3090
+ return createCell(instance, row, column, column.id);
3091
+ });
3092
+ }, {
3093
+ key: 'row.getAllCells',
3094
+ debug: () => {
3095
+ var _instance$options$deb;
3096
+
3097
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
3098
+ }
3099
+ }),
3100
+ _getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
3101
+ return allCells.reduce((acc, cell) => {
3102
+ acc[cell.column.id] = cell;
3103
+ return acc;
3104
+ }, {});
3105
+ }, {
3106
+ key: "development" === 'production' ,
3107
+ debug: () => {
3108
+ var _instance$options$deb2;
3109
+
3110
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
3111
+ }
3112
+ })
3113
+ };
3114
+
3115
+ for (let i = 0; i < instance._features.length; i++) {
3116
+ const feature = instance._features[i];
3117
+ Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
3118
+ }
3119
+
3120
+ return row;
3121
+ };
3122
+
3212
3123
  function getCoreRowModel() {
3213
3124
  return instance => memo(() => [instance.options.data], data => {
3214
3125
  const rowModel = {
@@ -3236,7 +3147,7 @@
3236
3147
  // }
3237
3148
  // Make the row
3238
3149
 
3239
- row = instance.createRow(instance.getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3150
+ row = createRow(instance, instance._getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3240
3151
 
3241
3152
  rowModel.flatRows.push(row); // Also keep track of every row by its ID
3242
3153
 
@@ -3299,7 +3210,7 @@
3299
3210
  row = rowsToFilter[i];
3300
3211
 
3301
3212
  if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
3302
- newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3213
+ newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3303
3214
  newRow.columnFilters = row.columnFilters;
3304
3215
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3305
3216
 
@@ -3349,7 +3260,7 @@
3349
3260
  var _row$subRows2;
3350
3261
 
3351
3262
  if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
3352
- newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3263
+ newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3353
3264
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3354
3265
  row = newRow;
3355
3266
  }
@@ -3601,8 +3512,8 @@
3601
3512
  availableSorting.forEach(sortEntry => {
3602
3513
  const column = instance.getColumn(sortEntry.id);
3603
3514
  columnInfoById[sortEntry.id] = {
3604
- sortUndefined: column.sortUndefined,
3605
- invertSorting: column.invertSorting,
3515
+ sortUndefined: column.columnDef.sortUndefined,
3516
+ invertSorting: column.columnDef.invertSorting,
3606
3517
  sortingFn: column.getSortingFn()
3607
3518
  };
3608
3519
  });
@@ -3716,7 +3627,7 @@
3716
3627
  const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
3717
3628
 
3718
3629
  const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
3719
- const row = instance.createRow(id, undefined, index, depth);
3630
+ const row = createRow(instance, id, undefined, index, depth);
3720
3631
  Object.assign(row, {
3721
3632
  groupingColumnId: columnId,
3722
3633
  groupingValue,
@@ -3725,38 +3636,30 @@
3725
3636
  getValue: columnId => {
3726
3637
  // Don't aggregate columns that are in the grouping
3727
3638
  if (existingGrouping.includes(columnId)) {
3728
- if (row.valuesCache.hasOwnProperty(columnId)) {
3729
- return row.valuesCache[columnId];
3639
+ if (row._valuesCache.hasOwnProperty(columnId)) {
3640
+ return row._valuesCache[columnId];
3730
3641
  }
3731
3642
 
3732
3643
  if (groupedRows[0]) {
3733
3644
  var _groupedRows$0$getVal;
3734
3645
 
3735
- row.valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
3646
+ row._valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
3736
3647
  }
3737
3648
 
3738
- return row.valuesCache[columnId];
3649
+ return row._valuesCache[columnId];
3739
3650
  }
3740
3651
 
3741
- if (row.groupingValuesCache.hasOwnProperty(columnId)) {
3742
- return row.groupingValuesCache[columnId];
3652
+ if (row._groupingValuesCache.hasOwnProperty(columnId)) {
3653
+ return row._groupingValuesCache[columnId];
3743
3654
  } // Aggregate the values
3744
3655
 
3745
3656
 
3746
3657
  const column = instance.getColumn(columnId);
3747
- const aggregateFn = column.getColumnAggregationFn();
3658
+ const aggregateFn = column.getAggregationFn();
3748
3659
 
3749
3660
  if (aggregateFn) {
3750
- row.groupingValuesCache[columnId] = aggregateFn(() => leafRows.map(row => {
3751
- let columnValue = row.getValue(columnId);
3752
-
3753
- if (!depth && column.aggregateValue) {
3754
- columnValue = column.aggregateValue(columnValue);
3755
- }
3756
-
3757
- return columnValue;
3758
- }), () => groupedRows.map(row => row.getValue(columnId)));
3759
- return row.groupingValuesCache[columnId];
3661
+ row._groupingValuesCache[columnId] = aggregateFn(columnId, leafRows, groupedRows);
3662
+ return row._groupingValuesCache[columnId];
3760
3663
  } else if (column.aggregationFn) {
3761
3664
  console.info({
3762
3665
  column
@@ -3922,6 +3825,8 @@
3922
3825
  exports.Visibility = Visibility;
3923
3826
  exports.aggregationFns = aggregationFns;
3924
3827
  exports.buildHeaderGroups = buildHeaderGroups;
3828
+ exports.createColumn = createColumn;
3829
+ exports.createRow = createRow;
3925
3830
  exports.createTableFactory = createTableFactory;
3926
3831
  exports.createTableInstance = createTableInstance;
3927
3832
  exports.defaultColumnSizing = defaultColumnSizing;
@@ -3941,7 +3846,6 @@
3941
3846
  exports.isFunction = isFunction;
3942
3847
  exports.isRowSelected = isRowSelected;
3943
3848
  exports.makeStateUpdater = makeStateUpdater;
3944
- exports.mean = mean;
3945
3849
  exports.memo = memo;
3946
3850
  exports.noop = noop;
3947
3851
  exports.orderColumns = orderColumns;