@tanstack/table-core 8.0.0-alpha.80 → 8.0.0-alpha.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/build/cjs/core/cell.js +38 -0
  2. package/build/cjs/core/cell.js.map +1 -0
  3. package/build/cjs/core/column.js +88 -0
  4. package/build/cjs/core/column.js.map +1 -0
  5. package/build/cjs/{features/Headers.js → core/headers.js} +54 -66
  6. package/build/cjs/core/headers.js.map +1 -0
  7. package/build/cjs/core/instance.js +255 -0
  8. package/build/cjs/core/instance.js.map +1 -0
  9. package/build/cjs/core/row.js +77 -0
  10. package/build/cjs/core/row.js.map +1 -0
  11. package/build/cjs/createTable.js +4 -2
  12. package/build/cjs/createTable.js.map +1 -1
  13. package/build/cjs/features/ColumnSizing.js +5 -5
  14. package/build/cjs/features/ColumnSizing.js.map +1 -1
  15. package/build/cjs/features/Expanding.js.map +1 -1
  16. package/build/cjs/features/Filters.js +12 -7
  17. package/build/cjs/features/Filters.js.map +1 -1
  18. package/build/cjs/features/Grouping.js +5 -5
  19. package/build/cjs/features/Grouping.js.map +1 -1
  20. package/build/cjs/features/Ordering.js.map +1 -1
  21. package/build/cjs/features/Pagination.js.map +1 -1
  22. package/build/cjs/features/Pinning.js +17 -11
  23. package/build/cjs/features/Pinning.js.map +1 -1
  24. package/build/cjs/features/RowSelection.js.map +1 -1
  25. package/build/cjs/features/Sorting.js +9 -9
  26. package/build/cjs/features/Sorting.js.map +1 -1
  27. package/build/cjs/features/Visibility.js +3 -3
  28. package/build/cjs/features/Visibility.js.map +1 -1
  29. package/build/cjs/index.js +17 -5
  30. package/build/cjs/index.js.map +1 -1
  31. package/build/cjs/utils/filterRowsUtils.js +23 -21
  32. package/build/cjs/utils/filterRowsUtils.js.map +1 -1
  33. package/build/cjs/utils/getCoreRowModel.js +9 -8
  34. package/build/cjs/utils/getCoreRowModel.js.map +1 -1
  35. package/build/cjs/utils/getFacetedRowModel.js +1 -1
  36. package/build/cjs/utils/getFacetedRowModel.js.map +1 -1
  37. package/build/cjs/utils/getFilteredRowModel.js +20 -9
  38. package/build/cjs/utils/getFilteredRowModel.js.map +1 -1
  39. package/build/cjs/utils/getGroupedRowModel.js +14 -13
  40. package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
  41. package/build/cjs/utils/getSortedRowModel.js +2 -2
  42. package/build/cjs/utils/getSortedRowModel.js.map +1 -1
  43. package/build/esm/index.js +731 -810
  44. package/build/esm/index.js.map +1 -1
  45. package/build/stats-html.html +1 -1
  46. package/build/stats-react.json +418 -377
  47. package/build/types/core/cell.d.ts +9 -0
  48. package/build/types/{features/Columns.d.ts → core/column.d.ts} +3 -17
  49. package/build/types/{features/Headers.d.ts → core/headers.d.ts} +26 -11
  50. package/build/types/core/instance.d.ts +57 -0
  51. package/build/types/core/row.d.ts +15 -0
  52. package/build/types/createTable.d.ts +8 -5
  53. package/build/types/features/ColumnSizing.d.ts +2 -1
  54. package/build/types/features/Expanding.d.ts +2 -1
  55. package/build/types/features/Filters.d.ts +5 -3
  56. package/build/types/features/Grouping.d.ts +3 -2
  57. package/build/types/features/Ordering.d.ts +2 -1
  58. package/build/types/features/Pagination.d.ts +2 -1
  59. package/build/types/features/Pinning.d.ts +3 -2
  60. package/build/types/features/RowSelection.d.ts +2 -1
  61. package/build/types/features/Sorting.d.ts +2 -1
  62. package/build/types/features/Visibility.d.ts +2 -1
  63. package/build/types/index.d.ts +7 -2
  64. package/build/types/sortingFns.d.ts +4 -4
  65. package/build/types/types.d.ts +13 -53
  66. package/build/umd/index.development.js +738 -806
  67. package/build/umd/index.development.js.map +1 -1
  68. package/build/umd/index.production.js +1 -1
  69. package/build/umd/index.production.js.map +1 -1
  70. package/package.json +1 -1
  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 +14 -7
  77. package/src/features/ColumnSizing.ts +6 -6
  78. package/src/features/Expanding.ts +1 -2
  79. package/src/features/Filters.ts +20 -8
  80. package/src/features/Grouping.ts +7 -6
  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 +11 -11
  86. package/src/features/Visibility.ts +3 -3
  87. package/src/index.ts +7 -8
  88. package/src/types.ts +17 -64
  89. package/src/utils/filterRowsUtils.ts +5 -3
  90. package/src/utils/getCoreRowModel.ts +4 -2
  91. package/src/utils/getFacetedRowModel.ts +1 -1
  92. package/src/utils/getFilteredRowModel.ts +24 -13
  93. package/src/utils/getGroupedRowModel.ts +9 -8
  94. package/src/utils/getSortedRowModel.ts +2 -2
  95. package/build/cjs/core.js +0 -168
  96. package/build/cjs/core.js.map +0 -1
  97. package/build/cjs/features/Cells.js +0 -101
  98. package/build/cjs/features/Cells.js.map +0 -1
  99. package/build/cjs/features/Columns.js +0 -189
  100. package/build/cjs/features/Columns.js.map +0 -1
  101. package/build/cjs/features/Headers.js.map +0 -1
  102. package/build/cjs/features/Rows.js +0 -94
  103. package/build/cjs/features/Rows.js.map +0 -1
  104. package/build/types/core.d.ts +0 -30
  105. package/build/types/features/Cells.d.ts +0 -13
  106. package/build/types/features/Rows.d.ts +0 -28
  107. package/src/core.ts +0 -246
  108. package/src/features/Cells.ts +0 -128
  109. package/src/features/Columns.ts +0 -289
  110. package/src/features/Rows.ts +0 -142
@@ -85,335 +85,459 @@ function memo(getDeps, fn, opts) {
85
85
  };
86
86
  }
87
87
 
88
+ function createColumn(instance, columnDef, depth, parent) {
89
+ var _ref, _columnDef$id;
90
+
91
+ const defaultColumn = instance._getDefaultColumnDef();
92
+
93
+ columnDef = { ...defaultColumn,
94
+ ...columnDef
95
+ };
96
+ let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
97
+ let accessorFn;
98
+
99
+ if (columnDef.accessorFn) {
100
+ accessorFn = columnDef.accessorFn;
101
+ } else if (columnDef.accessorKey) {
102
+ accessorFn = originalRow => originalRow[columnDef.accessorKey];
103
+ }
104
+
105
+ if (!id) {
106
+ if (process.env.NODE_ENV !== 'production') {
107
+ throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
108
+ }
109
+
110
+ throw new Error();
111
+ }
112
+
113
+ let column = { ...columnDef,
114
+ id: "" + id,
115
+ accessorFn,
116
+ parent: parent,
117
+ depth,
118
+ columnDef,
119
+ columnDefType: columnDef.columnDefType,
120
+ columns: [],
121
+ getFlatColumns: memo(() => [true], () => {
122
+ var _column$columns;
123
+
124
+ return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
125
+ }, {
126
+ key: process.env.NODE_ENV === 'production' && 'column.getFlatColumns',
127
+ debug: () => {
128
+ var _instance$options$deb;
129
+
130
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
131
+ }
132
+ }),
133
+ getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
134
+ var _column$columns2;
135
+
136
+ if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
137
+ let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
138
+ return orderColumns(leafColumns);
139
+ }
140
+
141
+ return [column];
142
+ }, {
143
+ key: process.env.NODE_ENV === 'production' && 'column.getLeafColumns',
144
+ debug: () => {
145
+ var _instance$options$deb2;
146
+
147
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
148
+ }
149
+ })
150
+ };
151
+ column = instance._features.reduce((obj, feature) => {
152
+ return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
153
+ }, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
154
+
155
+ return column;
156
+ }
157
+
88
158
  //
89
- const Columns = {
159
+ function createHeader(instance, column, options) {
160
+ var _options$id;
161
+
162
+ const id = (_options$id = options.id) != null ? _options$id : column.id;
163
+ let header = {
164
+ id,
165
+ column,
166
+ index: options.index,
167
+ isPlaceholder: !!options.isPlaceholder,
168
+ placeholderId: options.placeholderId,
169
+ depth: options.depth,
170
+ subHeaders: [],
171
+ colSpan: 0,
172
+ rowSpan: 0,
173
+ headerGroup: null,
174
+ getLeafHeaders: () => {
175
+ const leafHeaders = [];
176
+
177
+ const recurseHeader = h => {
178
+ if (h.subHeaders && h.subHeaders.length) {
179
+ h.subHeaders.map(recurseHeader);
180
+ }
181
+
182
+ leafHeaders.push(h);
183
+ };
184
+
185
+ recurseHeader(header);
186
+ return leafHeaders;
187
+ },
188
+ renderHeader: () => column.columnDef.header ? instance._render(column.columnDef.header, {
189
+ instance,
190
+ header: header,
191
+ column
192
+ }) : null,
193
+ renderFooter: () => column.columnDef.footer ? instance._render(column.columnDef.footer, {
194
+ instance,
195
+ header: header,
196
+ column
197
+ }) : null
198
+ };
199
+
200
+ instance._features.forEach(feature => {
201
+ Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
202
+ });
203
+
204
+ return header;
205
+ }
206
+
207
+ const Headers = {
90
208
  createInstance: instance => {
91
209
  return {
92
- getDefaultColumn: memo(() => [instance.options.defaultColumn], defaultColumn => {
93
- var _defaultColumn;
94
-
95
- defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
96
- return {
97
- header: props => props.header.column.id,
98
- footer: props => props.header.column.id,
99
- cell: props => {
100
- var _props$getValue$toStr, _props$getValue$toStr2, _props$getValue;
101
-
102
- 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;
103
- },
104
- ...instance._features.reduce((obj, feature) => {
105
- return Object.assign(obj, feature.getDefaultColumn == null ? void 0 : feature.getDefaultColumn());
106
- }, {}),
107
- ...defaultColumn
108
- };
210
+ // Header Groups
211
+ getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
212
+ var _left$map$filter, _right$map$filter;
213
+
214
+ const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
215
+ const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
216
+ const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
217
+ const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
218
+ return headerGroups;
109
219
  }, {
220
+ key: process.env.NODE_ENV === 'development' && 'getHeaderGroups',
110
221
  debug: () => {
111
222
  var _instance$options$deb;
112
223
 
113
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
114
- },
115
- key: process.env.NODE_ENV === 'development' && 'getDefaultColumn'
224
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
225
+ }
116
226
  }),
117
- getColumnDefs: () => instance.options.columns,
118
- createColumn: (columnDef, depth, parent) => {
119
- var _ref, _columnDef$id;
120
-
121
- const defaultColumn = instance.getDefaultColumn();
122
- let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
123
- let accessorFn;
227
+ getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
228
+ leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
229
+ return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
230
+ }, {
231
+ key: process.env.NODE_ENV === 'development' && 'getCenterHeaderGroups',
232
+ debug: () => {
233
+ var _instance$options$deb2;
124
234
 
125
- if (columnDef.accessorFn) {
126
- accessorFn = columnDef.accessorFn;
127
- } else if (columnDef.accessorKey) {
128
- accessorFn = originalRow => originalRow[columnDef.accessorKey];
235
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
129
236
  }
237
+ }),
238
+ getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
239
+ var _left$map$filter2;
130
240
 
131
- if (!id) {
132
- if (process.env.NODE_ENV !== 'production') {
133
- throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
134
- }
241
+ const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
242
+ return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
243
+ }, {
244
+ key: process.env.NODE_ENV === 'development' && 'getLeftHeaderGroups',
245
+ debug: () => {
246
+ var _instance$options$deb3;
135
247
 
136
- throw new Error();
248
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
137
249
  }
250
+ }),
251
+ getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
252
+ var _right$map$filter2;
138
253
 
139
- let column = { ...defaultColumn,
140
- ...columnDef,
141
- id: "" + id,
142
- accessorFn,
143
- parent: parent,
144
- depth,
145
- columnDef,
146
- columnDefType: columnDef.columnDefType,
147
- columns: [],
148
- getFlatColumns: memo(() => [true], () => {
149
- var _column$columns;
150
-
151
- return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
152
- }, {
153
- key: process.env.NODE_ENV === 'production' && 'column.getFlatColumns',
154
- debug: () => {
155
- var _instance$options$deb2;
156
-
157
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
158
- }
159
- }),
160
- getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
161
- var _column$columns2;
162
-
163
- if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
164
- let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
165
- return orderColumns(leafColumns);
166
- }
167
-
168
- return [column];
169
- }, {
170
- key: process.env.NODE_ENV === 'production' && 'column.getLeafColumns',
171
- debug: () => {
172
- var _instance$options$deb3;
173
-
174
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
175
- }
176
- })
177
- };
178
- column = instance._features.reduce((obj, feature) => {
179
- return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
180
- }, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
181
-
182
- return column;
183
- },
184
- getAllColumns: memo(() => [instance.getColumnDefs()], columnDefs => {
185
- const recurseColumns = function (columnDefs, parent, depth) {
186
- if (depth === void 0) {
187
- depth = 0;
188
- }
189
-
190
- return columnDefs.map(columnDef => {
191
- const column = instance.createColumn(columnDef, depth, parent);
192
- column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
193
- return column;
194
- });
195
- };
196
-
197
- return recurseColumns(columnDefs);
254
+ const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
255
+ return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
198
256
  }, {
199
- key: process.env.NODE_ENV === 'development' && 'getAllColumns',
257
+ key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
200
258
  debug: () => {
201
259
  var _instance$options$deb4;
202
260
 
203
- return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
261
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
204
262
  }
205
263
  }),
206
- getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
207
- return allColumns.flatMap(column => {
208
- return column.getFlatColumns();
209
- });
264
+ // Footer Groups
265
+ getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
266
+ return [...headerGroups].reverse();
210
267
  }, {
211
- key: process.env.NODE_ENV === 'development' && 'getAllFlatColumns',
268
+ key: process.env.NODE_ENV === 'development' && 'getFooterGroups',
212
269
  debug: () => {
213
270
  var _instance$options$deb5;
214
271
 
215
- return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
272
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
216
273
  }
217
274
  }),
218
- getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
219
- return flatColumns.reduce((acc, column) => {
220
- acc[column.id] = column;
221
- return acc;
222
- }, {});
275
+ getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
276
+ return [...headerGroups].reverse();
223
277
  }, {
224
- key: process.env.NODE_ENV === 'development' && 'getAllFlatColumnsById',
278
+ key: process.env.NODE_ENV === 'development' && 'getLeftFooterGroups',
225
279
  debug: () => {
226
280
  var _instance$options$deb6;
227
281
 
228
- return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugColumns;
282
+ return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
229
283
  }
230
284
  }),
231
- getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
232
- let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
233
- return orderColumns(leafColumns);
285
+ getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
286
+ return [...headerGroups].reverse();
234
287
  }, {
235
- key: process.env.NODE_ENV === 'development' && 'getAllLeafColumns',
288
+ key: process.env.NODE_ENV === 'development' && 'getCenterFooterGroups',
236
289
  debug: () => {
237
290
  var _instance$options$deb7;
238
291
 
239
- return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugColumns;
292
+ return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
240
293
  }
241
294
  }),
242
- getColumn: columnId => {
243
- const column = instance.getAllFlatColumnsById()[columnId];
244
-
245
- if (!column) {
246
- if (process.env.NODE_ENV !== 'production') {
247
- console.warn("[Table] Column with id " + columnId + " does not exist.");
248
- }
295
+ getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
296
+ return [...headerGroups].reverse();
297
+ }, {
298
+ key: process.env.NODE_ENV === 'development' && 'getRightFooterGroups',
299
+ debug: () => {
300
+ var _instance$options$deb8;
249
301
 
250
- throw new Error();
302
+ return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
251
303
  }
304
+ }),
305
+ // Flat Headers
306
+ getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
307
+ return headerGroups.map(headerGroup => {
308
+ return headerGroup.headers;
309
+ }).flat();
310
+ }, {
311
+ key: process.env.NODE_ENV === 'development' && 'getFlatHeaders',
312
+ debug: () => {
313
+ var _instance$options$deb9;
252
314
 
253
- return column;
254
- }
255
- };
256
- }
257
- };
258
-
259
- //
260
- const Rows = {
261
- // createRow: <TGenerics extends TableGenerics>(
262
- // row: Row<TGenerics>,
263
- // instance: TableInstance<TGenerics>
264
- // ): CellsRow<TGenerics> => {
265
- // return {}
266
- // },
267
- createInstance: instance => {
268
- return {
269
- getRowId: (row, index, parent) => {
270
- var _instance$options$get;
271
-
272
- 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);
273
- },
274
- createRow: (id, original, rowIndex, depth, subRows) => {
275
- let row = {
276
- id,
277
- index: rowIndex,
278
- original,
279
- depth,
280
- valuesCache: {},
281
- getValue: columnId => {
282
- if (row.valuesCache.hasOwnProperty(columnId)) {
283
- return row.valuesCache[columnId];
284
- }
285
-
286
- const column = instance.getColumn(columnId);
287
-
288
- if (!column.accessorFn) {
289
- return undefined;
290
- }
291
-
292
- row.valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
293
- return row.valuesCache[columnId];
294
- },
295
- subRows: subRows != null ? subRows : [],
296
- getLeafRows: () => flattenBy(row.subRows, d => d.subRows)
297
- };
315
+ return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
316
+ }
317
+ }),
318
+ getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
319
+ return left.map(headerGroup => {
320
+ return headerGroup.headers;
321
+ }).flat();
322
+ }, {
323
+ key: process.env.NODE_ENV === 'development' && 'getLeftFlatHeaders',
324
+ debug: () => {
325
+ var _instance$options$deb10;
298
326
 
299
- for (let i = 0; i < instance._features.length; i++) {
300
- const feature = instance._features[i];
301
- Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
327
+ return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
302
328
  }
329
+ }),
330
+ getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
331
+ return left.map(headerGroup => {
332
+ return headerGroup.headers;
333
+ }).flat();
334
+ }, {
335
+ key: process.env.NODE_ENV === 'development' && 'getCenterFlatHeaders',
336
+ debug: () => {
337
+ var _instance$options$deb11;
303
338
 
304
- return row;
305
- },
306
- getCoreRowModel: () => {
307
- if (!instance._getCoreRowModel) {
308
- instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
339
+ return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
309
340
  }
341
+ }),
342
+ getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
343
+ return left.map(headerGroup => {
344
+ return headerGroup.headers;
345
+ }).flat();
346
+ }, {
347
+ key: process.env.NODE_ENV === 'development' && 'getRightFlatHeaders',
348
+ debug: () => {
349
+ var _instance$options$deb12;
310
350
 
311
- return instance._getCoreRowModel();
312
- },
313
- // The final calls start at the bottom of the model,
314
- // expanded rows, which then work their way up
315
- getRowModel: () => {
316
- return instance.getPaginationRowModel();
317
- },
318
- getRow: id => {
319
- const row = instance.getRowModel().rowsById[id];
351
+ return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
352
+ }
353
+ }),
354
+ // Leaf Headers
355
+ getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
356
+ return flatHeaders.filter(header => {
357
+ var _header$subHeaders;
320
358
 
321
- if (!row) {
322
- if (process.env.NODE_ENV !== 'production') {
323
- throw new Error("getRow expected an ID, but got " + id);
324
- }
359
+ return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
360
+ });
361
+ }, {
362
+ key: process.env.NODE_ENV === 'development' && 'getCenterLeafHeaders',
363
+ debug: () => {
364
+ var _instance$options$deb13;
325
365
 
326
- throw new Error();
366
+ return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
327
367
  }
368
+ }),
369
+ getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
370
+ return flatHeaders.filter(header => {
371
+ var _header$subHeaders2;
328
372
 
329
- return row;
330
- }
331
- };
332
- }
333
- };
373
+ return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
374
+ });
375
+ }, {
376
+ key: process.env.NODE_ENV === 'development' && 'getLeftLeafHeaders',
377
+ debug: () => {
378
+ var _instance$options$deb14;
334
379
 
335
- //
336
- const Cells = {
337
- createRow: (row, instance) => {
338
- return {
339
- getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
340
- return leafColumns.map(column => {
341
- return instance.createCell(row, column, column.id);
380
+ return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
381
+ }
382
+ }),
383
+ getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
384
+ return flatHeaders.filter(header => {
385
+ var _header$subHeaders3;
386
+
387
+ return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
342
388
  });
343
389
  }, {
344
- key: process.env.NODE_ENV === 'development' && 'row.getAllCells',
390
+ key: process.env.NODE_ENV === 'development' && 'getRightLeafHeaders',
345
391
  debug: () => {
346
- var _instance$options$deb;
392
+ var _instance$options$deb15;
347
393
 
348
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
394
+ return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
349
395
  }
350
396
  }),
351
- getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
352
- return allCells.reduce((acc, cell) => {
353
- acc[cell.columnId] = cell;
354
- return acc;
355
- }, {});
397
+ getLeafHeaders: memo(() => [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()], (left, center, right) => {
398
+ var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
399
+
400
+ 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 => {
401
+ return header.getLeafHeaders();
402
+ }).flat();
356
403
  }, {
357
- key: process.env.NODE_ENV === 'production' && 'row.getAllCellsByColumnId',
404
+ key: process.env.NODE_ENV === 'development' && 'getLeafHeaders',
358
405
  debug: () => {
359
- var _instance$options$deb2;
406
+ var _instance$options$deb16;
360
407
 
361
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
408
+ return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
362
409
  }
363
410
  })
364
411
  };
365
- },
366
- createInstance: instance => {
367
- return {
368
- createCell: (row, column, columnId) => {
369
- const cell = {
370
- id: row.id + "_" + column.id,
371
- rowId: row.id,
372
- columnId,
373
- row,
374
- column,
375
- getValue: () => row.getValue(columnId),
376
- renderCell: () => column.cell ? instance._render(column.cell, {
377
- instance,
378
- column,
379
- row,
380
- cell: cell,
381
- getValue: cell.getValue
382
- }) : null
383
- };
384
-
385
- instance._features.forEach(feature => {
386
- Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
387
- }, {});
412
+ }
413
+ };
414
+ function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
415
+ var _headerGroups$0$heade, _headerGroups$;
388
416
 
389
- return cell;
390
- },
391
- getCell: (rowId, columnId) => {
392
- const row = instance.getRow(rowId);
417
+ // Find the max depth of the columns:
418
+ // build the leaf column row
419
+ // build each buffer row going up
420
+ // placeholder for non-existent level
421
+ // real column for existing level
422
+ let maxDepth = 0;
393
423
 
394
- if (!row) {
395
- if (process.env.NODE_ENV !== 'production') {
396
- throw new Error("[Table] could not find row with id " + rowId);
397
- }
424
+ const findMaxDepth = function (columns, depth) {
425
+ if (depth === void 0) {
426
+ depth = 1;
427
+ }
398
428
 
399
- throw new Error();
400
- }
429
+ maxDepth = Math.max(maxDepth, depth);
430
+ columns.filter(column => column.getIsVisible()).forEach(column => {
431
+ var _column$columns;
401
432
 
402
- const cell = row.getAllCellsByColumnId()[columnId];
433
+ if ((_column$columns = column.columns) != null && _column$columns.length) {
434
+ findMaxDepth(column.columns, depth + 1);
435
+ }
436
+ }, 0);
437
+ };
403
438
 
404
- if (!cell) {
405
- if (process.env.NODE_ENV !== 'production') {
406
- throw new Error("[Table] could not find cell " + columnId + " in row " + rowId);
407
- }
439
+ findMaxDepth(allColumns);
440
+ let headerGroups = [];
408
441
 
409
- throw new Error();
410
- }
442
+ const createHeaderGroup = (headersToGroup, depth) => {
443
+ // The header group we are creating
444
+ const headerGroup = {
445
+ depth,
446
+ id: [headerFamily, "" + depth].filter(Boolean).join('_'),
447
+ headers: []
448
+ }; // The parent columns we're going to scan next
449
+
450
+ const pendingParentHeaders = []; // Scan each column for parents
411
451
 
412
- return cell;
452
+ headersToGroup.forEach(headerToGroup => {
453
+ // What is the latest (last) parent column?
454
+ const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
455
+ const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
456
+ let column;
457
+ let isPlaceholder = false;
458
+
459
+ if (isLeafHeader && headerToGroup.column.parent) {
460
+ // The parent header is new
461
+ column = headerToGroup.column.parent;
462
+ } else {
463
+ // The parent header is repeated
464
+ column = headerToGroup.column;
465
+ isPlaceholder = true;
466
+ }
467
+
468
+ if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
469
+ // This column is repeated. Add it as a sub header to the next batch
470
+ latestPendingParentHeader.subHeaders.push(headerToGroup);
471
+ } else {
472
+ // This is a new header. Let's create it
473
+ const header = createHeader(instance, column, {
474
+ id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
475
+ isPlaceholder,
476
+ placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
477
+ depth,
478
+ index: pendingParentHeaders.length
479
+ }); // Add the headerToGroup as a subHeader of the new header
480
+
481
+ header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
482
+ // in the next batch
483
+
484
+ pendingParentHeaders.push(header);
485
+ }
486
+
487
+ headerGroup.headers.push(headerToGroup);
488
+ headerToGroup.headerGroup = headerGroup;
489
+ });
490
+ headerGroups.push(headerGroup);
491
+
492
+ if (depth > 0) {
493
+ createHeaderGroup(pendingParentHeaders, depth - 1);
494
+ }
495
+ };
496
+
497
+ const bottomHeaders = columnsToGroup.map((column, index) => createHeader(instance, column, {
498
+ depth: maxDepth,
499
+ index
500
+ }));
501
+ createHeaderGroup(bottomHeaders, maxDepth - 1);
502
+ headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
503
+ // return !headerGroup.headers.every(header => header.isPlaceholder)
504
+ // })
505
+
506
+ const recurseHeadersForSpans = headers => {
507
+ const filteredHeaders = headers.filter(header => header.column.getIsVisible());
508
+ return filteredHeaders.map(header => {
509
+ let colSpan = 0;
510
+ let rowSpan = 0;
511
+ let childRowSpans = [0];
512
+
513
+ if (header.subHeaders && header.subHeaders.length) {
514
+ childRowSpans = [];
515
+ recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
516
+ let {
517
+ colSpan: childColSpan,
518
+ rowSpan: childRowSpan
519
+ } = _ref;
520
+ colSpan += childColSpan;
521
+ childRowSpans.push(childRowSpan);
522
+ });
523
+ } else {
524
+ colSpan = 1;
413
525
  }
414
- };
415
- }
416
- };
526
+
527
+ const minChildRowSpan = Math.min(...childRowSpans);
528
+ rowSpan = rowSpan + minChildRowSpan;
529
+ header.colSpan = colSpan;
530
+ header.rowSpan = rowSpan;
531
+ return {
532
+ colSpan,
533
+ rowSpan
534
+ };
535
+ });
536
+ };
537
+
538
+ recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
539
+ return headerGroups;
540
+ }
417
541
 
418
542
  //
419
543
  const defaultColumnSizing = {
@@ -432,7 +556,7 @@ const getDefaultColumnSizingInfoState = () => ({
432
556
  });
433
557
 
434
558
  const ColumnSizing = {
435
- getDefaultColumn: () => {
559
+ getDefaultColumnDef: () => {
436
560
  return defaultColumnSizing;
437
561
  },
438
562
  getInitialState: state => {
@@ -452,10 +576,10 @@ const ColumnSizing = {
452
576
  createColumn: (column, instance) => {
453
577
  return {
454
578
  getSize: () => {
455
- var _column$minSize, _ref, _column$maxSize;
579
+ var _column$columnDef$min, _ref, _column$columnDef$max;
456
580
 
457
581
  const columnSize = instance.getState().columnSizing[column.id];
458
- 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);
582
+ 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);
459
583
  },
460
584
  getStart: position => {
461
585
  const columns = !position ? instance.getVisibleLeafColumns() : position === 'left' ? instance.getLeftVisibleLeafColumns() : instance.getRightVisibleLeafColumns();
@@ -478,9 +602,9 @@ const ColumnSizing = {
478
602
  });
479
603
  },
480
604
  getCanResize: () => {
481
- var _column$enableResizin, _instance$options$ena;
605
+ var _column$columnDef$ena, _instance$options$ena;
482
606
 
483
- return ((_column$enableResizin = column.enableResizing) != null ? _column$enableResizin : true) && ((_instance$options$ena = instance.options.enableColumnResizing) != null ? _instance$options$ena : true);
607
+ return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableColumnResizing) != null ? _instance$options$ena : true);
484
608
  },
485
609
  getIsResizing: () => {
486
610
  return instance.getState().columnSizingInfo.isResizingColumn === column.id;
@@ -937,7 +1061,7 @@ function testFalsey(val) {
937
1061
 
938
1062
  //
939
1063
  const Filters = {
940
- getDefaultColumn: () => {
1064
+ getDefaultColumnDef: () => {
941
1065
  return {
942
1066
  filterFn: 'auto'
943
1067
  };
@@ -960,7 +1084,7 @@ const Filters = {
960
1084
  getColumnCanGlobalFilter: column => {
961
1085
  var _instance$getCoreRowM, _instance$getCoreRowM2;
962
1086
 
963
- const value = (_instance$getCoreRowM = instance.getCoreRowModel().flatRows[0]) == null ? void 0 : (_instance$getCoreRowM2 = _instance$getCoreRowM.getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreRowM2.getValue();
1087
+ const value = (_instance$getCoreRowM = instance.getCoreRowModel().flatRows[0]) == null ? void 0 : (_instance$getCoreRowM2 = _instance$getCoreRowM._getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreRowM2.getValue();
964
1088
  return typeof value === 'string';
965
1089
  }
966
1090
  };
@@ -980,6 +1104,10 @@ const Filters = {
980
1104
  return filterFns.inNumberRange;
981
1105
  }
982
1106
 
1107
+ if (typeof value === 'boolean') {
1108
+ return filterFns.equals;
1109
+ }
1110
+
983
1111
  if (value !== null && typeof value === 'object') {
984
1112
  return filterFns.equals;
985
1113
  }
@@ -997,14 +1125,14 @@ const Filters = {
997
1125
  return isFunction(column.filterFn) ? column.filterFn : column.filterFn === 'auto' ? column.getAutoFilterFn() : (_ref = userFilterFns == null ? void 0 : userFilterFns[column.filterFn]) != null ? _ref : filterFns[column.filterFn];
998
1126
  },
999
1127
  getCanFilter: () => {
1000
- var _column$enableColumnF, _instance$options$ena, _instance$options$ena2;
1128
+ var _column$columnDef$ena, _instance$options$ena, _instance$options$ena2;
1001
1129
 
1002
- 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;
1130
+ 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;
1003
1131
  },
1004
1132
  getCanGlobalFilter: () => {
1005
- var _column$enableGlobalF, _instance$options$ena3, _instance$options$ena4, _instance$options$get;
1133
+ var _column$columnDef$ena2, _instance$options$ena3, _instance$options$ena4, _instance$options$get;
1006
1134
 
1007
- 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;
1135
+ 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;
1008
1136
  },
1009
1137
  getIsFiltered: () => column.getFilterIndex() > -1,
1010
1138
  getFilterValue: () => {
@@ -1083,7 +1211,8 @@ const Filters = {
1083
1211
  },
1084
1212
  createRow: (row, instance) => {
1085
1213
  return {
1086
- columnFilterMap: {},
1214
+ columnFilters: {},
1215
+ columnFiltersMeta: {},
1087
1216
  subRowsByFacetId: {}
1088
1217
  };
1089
1218
  },
@@ -1281,7 +1410,7 @@ function count(getLeafValues) {
1281
1410
 
1282
1411
  //
1283
1412
  const Grouping = {
1284
- getDefaultColumn: () => {
1413
+ getDefaultColumnDef: () => {
1285
1414
  return {
1286
1415
  aggregationFn: 'auto'
1287
1416
  };
@@ -1311,9 +1440,9 @@ const Grouping = {
1311
1440
  });
1312
1441
  },
1313
1442
  getCanGroup: () => {
1314
- var _ref, _ref2, _ref3, _column$enableGroupin;
1443
+ var _ref, _ref2, _ref3, _column$columnDef$ena;
1315
1444
 
1316
- return (_ref = (_ref2 = (_ref3 = (_column$enableGroupin = column.enableGrouping) != null ? _column$enableGroupin : true) != null ? _ref3 : instance.options.enableGrouping) != null ? _ref2 : true) != null ? _ref : !!column.accessorFn;
1445
+ 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;
1317
1446
  },
1318
1447
  getIsGrouped: () => {
1319
1448
  var _instance$getState$gr;
@@ -1397,9 +1526,9 @@ const Grouping = {
1397
1526
  return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
1398
1527
  },
1399
1528
  renderAggregatedCell: () => {
1400
- var _column$aggregatedCel;
1529
+ var _column$columnDef$agg;
1401
1530
 
1402
- const template = (_column$aggregatedCel = column.aggregatedCell) != null ? _column$aggregatedCel : column.cell;
1531
+ const template = (_column$columnDef$agg = column.columnDef.aggregatedCell) != null ? _column$columnDef$agg : column.columnDef.cell;
1403
1532
  return template ? instance._render(template, {
1404
1533
  instance,
1405
1534
  column,
@@ -1706,9 +1835,9 @@ const Pinning = {
1706
1835
  getCanPin: () => {
1707
1836
  const leafColumns = column.getLeafColumns();
1708
1837
  return leafColumns.some(d => {
1709
- var _d$enablePinning, _instance$options$ena;
1838
+ var _d$columnDef$enablePi, _instance$options$ena;
1710
1839
 
1711
- return ((_d$enablePinning = d.enablePinning) != null ? _d$enablePinning : true) && ((_instance$options$ena = instance.options.enablePinning) != null ? _instance$options$ena : true);
1840
+ return ((_d$columnDef$enablePi = d.columnDef.enablePinning) != null ? _d$columnDef$enablePi : true) && ((_instance$options$ena = instance.options.enablePinning) != null ? _instance$options$ena : true);
1712
1841
  });
1713
1842
  },
1714
1843
  getIsPinned: () => {
@@ -1733,7 +1862,7 @@ const Pinning = {
1733
1862
  return {
1734
1863
  getCenterVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allCells, left, right) => {
1735
1864
  const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
1736
- return allCells.filter(d => !leftAndRight.includes(d.columnId));
1865
+ return allCells.filter(d => !leftAndRight.includes(d.column.id));
1737
1866
  }, {
1738
1867
  key: process.env.NODE_ENV === 'production' && 'row.getCenterVisibleCells',
1739
1868
  debug: () => {
@@ -1743,7 +1872,7 @@ const Pinning = {
1743
1872
  }
1744
1873
  }),
1745
1874
  getLeftVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left,,], (allCells, left) => {
1746
- const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.columnId === columnId)).filter(Boolean).map(d => ({ ...d,
1875
+ const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
1747
1876
  position: 'left'
1748
1877
  }));
1749
1878
  return cells;
@@ -1756,7 +1885,7 @@ const Pinning = {
1756
1885
  }
1757
1886
  }),
1758
1887
  getRightVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.right], (allCells, right) => {
1759
- const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.columnId === columnId)).filter(Boolean).map(d => ({ ...d,
1888
+ const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
1760
1889
  position: 'left'
1761
1890
  }));
1762
1891
  return cells;
@@ -1778,12 +1907,18 @@ const Pinning = {
1778
1907
 
1779
1908
  return instance.setColumnPinning(defaultState ? getDefaultPinningState() : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.columnPinning) != null ? _instance$initialStat : getDefaultPinningState());
1780
1909
  },
1781
- getIsSomeColumnsPinned: () => {
1782
- const {
1783
- left,
1784
- right
1785
- } = instance.getState().columnPinning;
1786
- return Boolean((left == null ? void 0 : left.length) || (right == null ? void 0 : right.length));
1910
+ getIsSomeColumnsPinned: position => {
1911
+ var _pinningState$positio;
1912
+
1913
+ const pinningState = instance.getState().columnPinning;
1914
+
1915
+ if (!position) {
1916
+ var _pinningState$left, _pinningState$right;
1917
+
1918
+ return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
1919
+ }
1920
+
1921
+ return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
1787
1922
  },
1788
1923
  getLeftLeafColumns: memo(() => [instance.getAllLeafColumns(), instance.getState().columnPinning.left], (allColumns, left) => {
1789
1924
  return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
@@ -2309,7 +2444,7 @@ const Sorting = {
2309
2444
  ...state
2310
2445
  };
2311
2446
  },
2312
- getDefaultColumn: () => {
2447
+ getDefaultColumnDef: () => {
2313
2448
  return {
2314
2449
  sortingFn: 'auto'
2315
2450
  };
@@ -2325,7 +2460,7 @@ const Sorting = {
2325
2460
  createColumn: (column, instance) => {
2326
2461
  return {
2327
2462
  getAutoSortingFn: () => {
2328
- const firstRows = instance.getFilteredRowModel().flatRows.slice(100);
2463
+ const firstRows = instance.getFilteredRowModel().flatRows.slice(10);
2329
2464
  let isString = false;
2330
2465
 
2331
2466
  for (const row of firstRows) {
@@ -2369,7 +2504,7 @@ const Sorting = {
2369
2504
  throw new Error();
2370
2505
  }
2371
2506
 
2372
- return isFunction(column.sortingFn) ? column.sortingFn : column.sortingFn === 'auto' ? column.getAutoSortingFn() : (_ref = userSortingFn == null ? void 0 : userSortingFn[column.sortingFn]) != null ? _ref : sortingFns[column.sortingFn];
2507
+ 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];
2373
2508
  },
2374
2509
  toggleSorting: (desc, multi) => {
2375
2510
  // if (column.columns.length) {
@@ -2381,7 +2516,7 @@ const Sorting = {
2381
2516
  // return
2382
2517
  // }
2383
2518
  instance.setSorting(old => {
2384
- var _ref2, _column$sortDescFirst, _instance$options$ena, _instance$options$ena2;
2519
+ var _ref2, _column$columnDef$sor, _instance$options$ena, _instance$options$ena2;
2385
2520
 
2386
2521
  // Find any existing sorting for this column
2387
2522
  const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
@@ -2408,7 +2543,7 @@ const Sorting = {
2408
2543
  }
2409
2544
  }
2410
2545
 
2411
- 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
2546
+ 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
2412
2547
 
2413
2548
  if (sortAction === 'toggle' && ( // Must be toggling
2414
2549
  (_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
@@ -2452,14 +2587,14 @@ const Sorting = {
2452
2587
  });
2453
2588
  },
2454
2589
  getCanSort: () => {
2455
- var _column$enableSorting, _instance$options$ena3;
2590
+ var _column$columnDef$ena, _instance$options$ena3;
2456
2591
 
2457
- return ((_column$enableSorting = column.enableSorting) != null ? _column$enableSorting : true) && ((_instance$options$ena3 = instance.options.enableSorting) != null ? _instance$options$ena3 : true) && !!column.accessorFn;
2592
+ 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;
2458
2593
  },
2459
2594
  getCanMultiSort: () => {
2460
- var _ref3, _column$enableMultiSo;
2595
+ var _ref3, _column$columnDef$ena2;
2461
2596
 
2462
- return (_ref3 = (_column$enableMultiSo = column.enableMultiSort) != null ? _column$enableMultiSo : instance.options.enableMultiSort) != null ? _ref3 : !!column.accessorFn;
2597
+ return (_ref3 = (_column$columnDef$ena2 = column.columnDef.enableMultiSort) != null ? _column$columnDef$ena2 : instance.options.enableMultiSort) != null ? _ref3 : !!column.accessorFn;
2463
2598
  },
2464
2599
  getIsSorted: () => {
2465
2600
  var _instance$getState$so;
@@ -2523,7 +2658,7 @@ const Visibility = {
2523
2658
  onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
2524
2659
  };
2525
2660
  },
2526
- getDefaultColumn: () => {
2661
+ getDefaultColumnDef: () => {
2527
2662
  return {
2528
2663
  defaultIsVisible: true
2529
2664
  };
@@ -2543,9 +2678,9 @@ const Visibility = {
2543
2678
  return (_instance$getState$co = (_instance$getState$co2 = instance.getState().columnVisibility) == null ? void 0 : _instance$getState$co2[column.id]) != null ? _instance$getState$co : true;
2544
2679
  },
2545
2680
  getCanHide: () => {
2546
- var _column$enableHiding, _instance$options$ena;
2681
+ var _column$columnDef$ena, _instance$options$ena;
2547
2682
 
2548
- return ((_column$enableHiding = column.enableHiding) != null ? _column$enableHiding : true) && ((_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : true);
2683
+ return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : true);
2549
2684
  },
2550
2685
  getToggleVisibilityHandler: () => {
2551
2686
  return e => {
@@ -2561,475 +2696,70 @@ const Visibility = {
2561
2696
  }, {
2562
2697
  key: process.env.NODE_ENV === 'production' && 'row._getAllVisibleCells',
2563
2698
  debug: () => {
2564
- var _instance$options$deb;
2565
-
2566
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
2567
- }
2568
- }),
2569
- getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
2570
- key: process.env.NODE_ENV === 'development' && 'row.getVisibleCells',
2571
- debug: () => {
2572
- var _instance$options$deb2;
2573
-
2574
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
2575
- }
2576
- })
2577
- };
2578
- },
2579
- createInstance: instance => {
2580
- const makeVisibleColumnsMethod = (key, getColumns) => {
2581
- return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
2582
- return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
2583
- }, {
2584
- key,
2585
- debug: () => {
2586
- var _instance$options$deb3;
2587
-
2588
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2589
- }
2590
- });
2591
- };
2592
-
2593
- return {
2594
- getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
2595
- getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
2596
- getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
2597
- getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
2598
- getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
2599
- setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
2600
- resetColumnVisibility: defaultState => {
2601
- var _instance$initialStat;
2602
-
2603
- instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
2604
- },
2605
- toggleAllColumnsVisible: value => {
2606
- var _value;
2607
-
2608
- value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
2609
- instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
2610
- [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
2611
- }), {}));
2612
- },
2613
- getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
2614
- getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
2615
- getToggleAllColumnsVisibilityHandler: () => {
2616
- return e => {
2617
- var _target;
2618
-
2619
- instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
2620
- };
2621
- }
2622
- };
2623
- }
2624
- };
2625
-
2626
- //
2627
- const Headers = {
2628
- createInstance: instance => {
2629
- return {
2630
- createHeader: (column, options) => {
2631
- var _options$id;
2632
-
2633
- const id = (_options$id = options.id) != null ? _options$id : column.id;
2634
- let header = {
2635
- id,
2636
- column,
2637
- index: options.index,
2638
- isPlaceholder: options.isPlaceholder,
2639
- placeholderId: options.placeholderId,
2640
- depth: options.depth,
2641
- subHeaders: [],
2642
- colSpan: 0,
2643
- rowSpan: 0,
2644
- headerGroup: null,
2645
- getLeafHeaders: () => {
2646
- const leafHeaders = [];
2647
-
2648
- const recurseHeader = h => {
2649
- if (h.subHeaders && h.subHeaders.length) {
2650
- h.subHeaders.map(recurseHeader);
2651
- }
2652
-
2653
- leafHeaders.push(h);
2654
- };
2655
-
2656
- recurseHeader(header);
2657
- return leafHeaders;
2658
- },
2659
- renderHeader: () => column.header ? instance._render(column.header, {
2660
- instance,
2661
- header: header,
2662
- column
2663
- }) : null,
2664
- renderFooter: () => column.footer ? instance._render(column.footer, {
2665
- instance,
2666
- header: header,
2667
- column
2668
- }) : null
2669
- };
2670
-
2671
- instance._features.forEach(feature => {
2672
- Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
2673
- });
2674
-
2675
- return header;
2676
- },
2677
- // Header Groups
2678
- getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2679
- var _left$map$filter, _right$map$filter;
2680
-
2681
- const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
2682
- const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
2683
- const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2684
- const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
2685
- return headerGroups;
2686
- }, {
2687
- key: process.env.NODE_ENV === 'development' && 'getHeaderGroups',
2688
- debug: () => {
2689
- var _instance$options$deb;
2690
-
2691
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
2692
- }
2693
- }),
2694
- getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2695
- leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2696
- return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
2697
- }, {
2698
- key: process.env.NODE_ENV === 'development' && 'getCenterHeaderGroups',
2699
- debug: () => {
2700
- var _instance$options$deb2;
2701
-
2702
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
2703
- }
2704
- }),
2705
- getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
2706
- var _left$map$filter2;
2707
-
2708
- const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
2709
- return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
2710
- }, {
2711
- key: process.env.NODE_ENV === 'development' && 'getLeftHeaderGroups',
2712
- debug: () => {
2713
- var _instance$options$deb3;
2714
-
2715
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
2716
- }
2717
- }),
2718
- getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
2719
- var _right$map$filter2;
2720
-
2721
- const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
2722
- return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
2723
- }, {
2724
- key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
2725
- debug: () => {
2726
- var _instance$options$deb4;
2727
-
2728
- return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
2729
- }
2730
- }),
2731
- // Footer Groups
2732
- getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
2733
- return [...headerGroups].reverse();
2734
- }, {
2735
- key: process.env.NODE_ENV === 'development' && 'getFooterGroups',
2736
- debug: () => {
2737
- var _instance$options$deb5;
2738
-
2739
- return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
2740
- }
2741
- }),
2742
- getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
2743
- return [...headerGroups].reverse();
2744
- }, {
2745
- key: process.env.NODE_ENV === 'development' && 'getLeftFooterGroups',
2746
- debug: () => {
2747
- var _instance$options$deb6;
2748
-
2749
- return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
2750
- }
2751
- }),
2752
- getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
2753
- return [...headerGroups].reverse();
2754
- }, {
2755
- key: process.env.NODE_ENV === 'development' && 'getCenterFooterGroups',
2756
- debug: () => {
2757
- var _instance$options$deb7;
2758
-
2759
- return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
2760
- }
2761
- }),
2762
- getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
2763
- return [...headerGroups].reverse();
2764
- }, {
2765
- key: process.env.NODE_ENV === 'development' && 'getRightFooterGroups',
2766
- debug: () => {
2767
- var _instance$options$deb8;
2768
-
2769
- return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
2770
- }
2771
- }),
2772
- // Flat Headers
2773
- getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
2774
- return headerGroups.map(headerGroup => {
2775
- return headerGroup.headers;
2776
- }).flat();
2777
- }, {
2778
- key: process.env.NODE_ENV === 'development' && 'getFlatHeaders',
2779
- debug: () => {
2780
- var _instance$options$deb9;
2781
-
2782
- return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
2783
- }
2784
- }),
2785
- getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
2786
- return left.map(headerGroup => {
2787
- return headerGroup.headers;
2788
- }).flat();
2789
- }, {
2790
- key: process.env.NODE_ENV === 'development' && 'getLeftFlatHeaders',
2791
- debug: () => {
2792
- var _instance$options$deb10;
2793
-
2794
- return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
2795
- }
2796
- }),
2797
- getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
2798
- return left.map(headerGroup => {
2799
- return headerGroup.headers;
2800
- }).flat();
2801
- }, {
2802
- key: process.env.NODE_ENV === 'development' && 'getCenterFlatHeaders',
2803
- debug: () => {
2804
- var _instance$options$deb11;
2805
-
2806
- return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
2807
- }
2808
- }),
2809
- getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
2810
- return left.map(headerGroup => {
2811
- return headerGroup.headers;
2812
- }).flat();
2813
- }, {
2814
- key: process.env.NODE_ENV === 'development' && 'getRightFlatHeaders',
2815
- debug: () => {
2816
- var _instance$options$deb12;
2817
-
2818
- return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
2819
- }
2820
- }),
2821
- // Leaf Headers
2822
- getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
2823
- return flatHeaders.filter(header => {
2824
- var _header$subHeaders;
2825
-
2826
- return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
2827
- });
2828
- }, {
2829
- key: process.env.NODE_ENV === 'development' && 'getCenterLeafHeaders',
2830
- debug: () => {
2831
- var _instance$options$deb13;
2832
-
2833
- return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
2834
- }
2835
- }),
2836
- getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
2837
- return flatHeaders.filter(header => {
2838
- var _header$subHeaders2;
2839
-
2840
- return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
2841
- });
2842
- }, {
2843
- key: process.env.NODE_ENV === 'development' && 'getLeftLeafHeaders',
2844
- debug: () => {
2845
- var _instance$options$deb14;
2846
-
2847
- return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
2848
- }
2849
- }),
2850
- getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
2851
- return flatHeaders.filter(header => {
2852
- var _header$subHeaders3;
2853
-
2854
- return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
2855
- });
2856
- }, {
2857
- key: process.env.NODE_ENV === 'development' && 'getRightLeafHeaders',
2858
- debug: () => {
2859
- var _instance$options$deb15;
2699
+ var _instance$options$deb;
2860
2700
 
2861
- return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
2701
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
2862
2702
  }
2863
2703
  }),
2864
- getLeafHeaders: memo(() => [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()], (left, center, right) => {
2865
- var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
2704
+ getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
2705
+ key: process.env.NODE_ENV === 'development' && 'row.getVisibleCells',
2706
+ debug: () => {
2707
+ var _instance$options$deb2;
2866
2708
 
2867
- 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 => {
2868
- return header.getLeafHeaders();
2869
- }).flat();
2709
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
2710
+ }
2711
+ })
2712
+ };
2713
+ },
2714
+ createInstance: instance => {
2715
+ const makeVisibleColumnsMethod = (key, getColumns) => {
2716
+ return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
2717
+ return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
2870
2718
  }, {
2871
- key: process.env.NODE_ENV === 'development' && 'getLeafHeaders',
2719
+ key,
2872
2720
  debug: () => {
2873
- var _instance$options$deb16;
2721
+ var _instance$options$deb3;
2874
2722
 
2875
- return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
2723
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2876
2724
  }
2877
- }),
2878
- getHeader: id => {
2879
- const header = [...instance.getFlatHeaders(), ...instance.getCenterFlatHeaders(), ...instance.getLeftFlatHeaders(), ...instance.getRightFlatHeaders()].find(d => d.id === id);
2725
+ });
2726
+ };
2880
2727
 
2881
- if (!header) {
2882
- if (process.env.NODE_ENV !== 'production') {
2883
- console.warn("Could not find header with id: " + id);
2884
- }
2728
+ return {
2729
+ getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
2730
+ getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
2731
+ getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
2732
+ getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
2733
+ getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
2734
+ setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
2735
+ resetColumnVisibility: defaultState => {
2736
+ var _instance$initialStat;
2885
2737
 
2886
- throw new Error();
2887
- }
2738
+ instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
2739
+ },
2740
+ toggleAllColumnsVisible: value => {
2741
+ var _value;
2742
+
2743
+ value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
2744
+ instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
2745
+ [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
2746
+ }), {}));
2747
+ },
2748
+ getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
2749
+ getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
2750
+ getToggleAllColumnsVisibilityHandler: () => {
2751
+ return e => {
2752
+ var _target;
2888
2753
 
2889
- return header;
2754
+ instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
2755
+ };
2890
2756
  }
2891
2757
  };
2892
2758
  }
2893
2759
  };
2894
- function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
2895
- var _headerGroups$0$heade, _headerGroups$;
2896
-
2897
- // Find the max depth of the columns:
2898
- // build the leaf column row
2899
- // build each buffer row going up
2900
- // placeholder for non-existent level
2901
- // real column for existing level
2902
- let maxDepth = 0;
2903
-
2904
- const findMaxDepth = function (columns, depth) {
2905
- if (depth === void 0) {
2906
- depth = 1;
2907
- }
2908
-
2909
- maxDepth = Math.max(maxDepth, depth);
2910
- columns.filter(column => column.getIsVisible()).forEach(column => {
2911
- var _column$columns;
2912
-
2913
- if ((_column$columns = column.columns) != null && _column$columns.length) {
2914
- findMaxDepth(column.columns, depth + 1);
2915
- }
2916
- }, 0);
2917
- };
2918
-
2919
- findMaxDepth(allColumns);
2920
- let headerGroups = [];
2921
-
2922
- const createHeaderGroup = (headersToGroup, depth) => {
2923
- // The header group we are creating
2924
- const headerGroup = {
2925
- depth,
2926
- id: [headerFamily, "" + depth].filter(Boolean).join('_'),
2927
- headers: []
2928
- }; // The parent columns we're going to scan next
2929
-
2930
- const pendingParentHeaders = []; // Scan each column for parents
2931
-
2932
- headersToGroup.forEach(headerToGroup => {
2933
- // What is the latest (last) parent column?
2934
- const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
2935
- const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
2936
- let column;
2937
- let isPlaceholder = false;
2938
-
2939
- if (isLeafHeader && headerToGroup.column.parent) {
2940
- // The parent header is new
2941
- column = headerToGroup.column.parent;
2942
- } else {
2943
- // The parent header is repeated
2944
- column = headerToGroup.column;
2945
- isPlaceholder = true;
2946
- }
2947
-
2948
- if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
2949
- // This column is repeated. Add it as a sub header to the next batch
2950
- latestPendingParentHeader.subHeaders.push(headerToGroup);
2951
- } else {
2952
- // This is a new header. Let's create it
2953
- const header = instance.createHeader(column, {
2954
- id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
2955
- isPlaceholder,
2956
- placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
2957
- depth,
2958
- index: pendingParentHeaders.length
2959
- }); // Add the headerToGroup as a subHeader of the new header
2960
-
2961
- header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
2962
- // in the next batch
2963
-
2964
- pendingParentHeaders.push(header);
2965
- }
2966
-
2967
- headerGroup.headers.push(headerToGroup);
2968
- headerToGroup.headerGroup = headerGroup;
2969
- });
2970
- headerGroups.push(headerGroup);
2971
-
2972
- if (depth > 0) {
2973
- createHeaderGroup(pendingParentHeaders, depth - 1);
2974
- }
2975
- };
2976
-
2977
- const bottomHeaders = columnsToGroup.map((column, index) => instance.createHeader(column, {
2978
- depth: maxDepth,
2979
- index
2980
- }));
2981
- createHeaderGroup(bottomHeaders, maxDepth - 1);
2982
- headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
2983
- // return !headerGroup.headers.every(header => header.isPlaceholder)
2984
- // })
2985
-
2986
- const recurseHeadersForSpans = headers => {
2987
- const filteredHeaders = headers.filter(header => header.column.getIsVisible());
2988
- return filteredHeaders.map(header => {
2989
- let colSpan = 0;
2990
- let rowSpan = 0;
2991
- let childRowSpans = [0];
2992
-
2993
- if (header.subHeaders && header.subHeaders.length) {
2994
- childRowSpans = [];
2995
- recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
2996
- let {
2997
- colSpan: childColSpan,
2998
- rowSpan: childRowSpan
2999
- } = _ref;
3000
- colSpan += childColSpan;
3001
- childRowSpans.push(childRowSpan);
3002
- });
3003
- } else {
3004
- colSpan = 1;
3005
- }
3006
-
3007
- const minChildRowSpan = Math.min(...childRowSpans);
3008
- rowSpan = rowSpan + minChildRowSpan;
3009
- header.colSpan = colSpan > 0 ? colSpan : undefined;
3010
- header.rowSpan = rowSpan > 0 ? rowSpan : undefined;
3011
- return {
3012
- colSpan,
3013
- rowSpan
3014
- };
3015
- });
3016
- };
3017
2760
 
3018
- recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
3019
- return headerGroups;
3020
- }
2761
+ const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]; //
3021
2762
 
3022
- // export type Batch = {
3023
- // id: number
3024
- // priority: keyof CoreBatches
3025
- // tasks: (() => void)[]
3026
- // schedule: (cb: () => void) => void
3027
- // cancel: () => void
3028
- // }
3029
- // type CoreBatches = {
3030
- // data: Batch[]
3031
- // facets: Batch[]
3032
- // }
3033
2763
  function createTableInstance(options) {
3034
2764
  var _options$initialState;
3035
2765
 
@@ -3038,7 +2768,7 @@ function createTableInstance(options) {
3038
2768
  }
3039
2769
 
3040
2770
  let instance = {
3041
- _features: [Columns, Rows, Cells, Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]
2771
+ _features: features
3042
2772
  };
3043
2773
 
3044
2774
  const defaultOptions = instance._features.reduce((obj, feature) => {
@@ -3055,8 +2785,7 @@ function createTableInstance(options) {
3055
2785
  };
3056
2786
  };
3057
2787
 
3058
- const coreInitialState = {// coreProgress: 1,
3059
- };
2788
+ const coreInitialState = {};
3060
2789
  let initialState = { ...coreInitialState,
3061
2790
  ...((_options$initialState = options.initialState) != null ? _options$initialState : {})
3062
2791
  };
@@ -3069,16 +2798,8 @@ function createTableInstance(options) {
3069
2798
 
3070
2799
  const queued = [];
3071
2800
  let queuedTimeout = false;
3072
- const midInstance = { ...instance,
3073
- // init: () => {
3074
- // startWork()
3075
- // },
3076
- // willUpdate: () => {
3077
- // startWork()
3078
- // },
3079
- // destroy: () => {
3080
- // stopWork()
3081
- // },
2801
+ const coreInstance = {
2802
+ _features: features,
3082
2803
  options: { ...defaultOptions,
3083
2804
  ...options
3084
2805
  },
@@ -3124,29 +2845,136 @@ function createTableInstance(options) {
3124
2845
  },
3125
2846
  setState: updater => {
3126
2847
  instance.options.onStateChange == null ? void 0 : instance.options.onStateChange(updater);
3127
- } // getOverallProgress: () => {
3128
- // const { coreProgress, filtersProgress, facetProgress } =
3129
- // instance.getState()
3130
- // return mean(() =>
3131
- // [coreProgress, filtersProgress].filter(d => d < 1)
3132
- // ) as number
3133
- // },
3134
- // getProgressStage: () => {
3135
- // const { coreProgress, filtersProgress, facetProgress } =
3136
- // instance.getState()
3137
- // if (coreProgress < 1) {
3138
- // return 'coreRowModel'
3139
- // }
3140
- // if (filtersProgress < 1) {
3141
- // return 'filteredRowModel'
3142
- // }
3143
- // if (Object.values(facetProgress).some(d => d < 1)) {
3144
- // return 'facetedRowModel'
3145
- // }
3146
- // },
2848
+ },
2849
+ _getRowId: (row, index, parent) => {
2850
+ var _instance$options$get;
2851
+
2852
+ 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);
2853
+ },
2854
+ getCoreRowModel: () => {
2855
+ if (!instance._getCoreRowModel) {
2856
+ instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
2857
+ }
2858
+
2859
+ return instance._getCoreRowModel();
2860
+ },
2861
+ // The final calls start at the bottom of the model,
2862
+ // expanded rows, which then work their way up
2863
+ getRowModel: () => {
2864
+ return instance.getPaginationRowModel();
2865
+ },
2866
+ getRow: id => {
2867
+ const row = instance.getRowModel().rowsById[id];
2868
+
2869
+ if (!row) {
2870
+ if (process.env.NODE_ENV !== 'production') {
2871
+ throw new Error("getRow expected an ID, but got " + id);
2872
+ }
3147
2873
 
2874
+ throw new Error();
2875
+ }
2876
+
2877
+ return row;
2878
+ },
2879
+ _getDefaultColumnDef: memo(() => [instance.options.defaultColumn], defaultColumn => {
2880
+ var _defaultColumn;
2881
+
2882
+ defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
2883
+ return {
2884
+ header: props => props.header.column.id,
2885
+ footer: props => props.header.column.id,
2886
+ cell: props => {
2887
+ var _props$getValue$toStr, _props$getValue$toStr2, _props$getValue;
2888
+
2889
+ 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;
2890
+ },
2891
+ ...instance._features.reduce((obj, feature) => {
2892
+ return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
2893
+ }, {}),
2894
+ ...defaultColumn
2895
+ };
2896
+ }, {
2897
+ debug: () => {
2898
+ var _instance$options$deb;
2899
+
2900
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
2901
+ },
2902
+ key: process.env.NODE_ENV === 'development' && 'getDefaultColumnDef'
2903
+ }),
2904
+ _getColumnDefs: () => instance.options.columns,
2905
+ getAllColumns: memo(() => [instance._getColumnDefs()], columnDefs => {
2906
+ const recurseColumns = function (columnDefs, parent, depth) {
2907
+ if (depth === void 0) {
2908
+ depth = 0;
2909
+ }
2910
+
2911
+ return columnDefs.map(columnDef => {
2912
+ const column = createColumn(instance, columnDef, depth, parent);
2913
+ column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
2914
+ return column;
2915
+ });
2916
+ };
2917
+
2918
+ return recurseColumns(columnDefs);
2919
+ }, {
2920
+ key: process.env.NODE_ENV === 'development' && 'getAllColumns',
2921
+ debug: () => {
2922
+ var _instance$options$deb2;
2923
+
2924
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
2925
+ }
2926
+ }),
2927
+ getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
2928
+ return allColumns.flatMap(column => {
2929
+ return column.getFlatColumns();
2930
+ });
2931
+ }, {
2932
+ key: process.env.NODE_ENV === 'development' && 'getAllFlatColumns',
2933
+ debug: () => {
2934
+ var _instance$options$deb3;
2935
+
2936
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
2937
+ }
2938
+ }),
2939
+ _getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
2940
+ return flatColumns.reduce((acc, column) => {
2941
+ acc[column.id] = column;
2942
+ return acc;
2943
+ }, {});
2944
+ }, {
2945
+ key: process.env.NODE_ENV === 'development' && 'getAllFlatColumnsById',
2946
+ debug: () => {
2947
+ var _instance$options$deb4;
2948
+
2949
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
2950
+ }
2951
+ }),
2952
+ getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
2953
+ let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
2954
+ return orderColumns(leafColumns);
2955
+ }, {
2956
+ key: process.env.NODE_ENV === 'development' && 'getAllLeafColumns',
2957
+ debug: () => {
2958
+ var _instance$options$deb5;
2959
+
2960
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
2961
+ }
2962
+ }),
2963
+ getColumn: columnId => {
2964
+ const column = instance._getAllFlatColumnsById()[columnId];
2965
+
2966
+ if (!column) {
2967
+ if (process.env.NODE_ENV !== 'production') {
2968
+ console.warn("[Table] Column with id " + columnId + " does not exist.");
2969
+ }
2970
+
2971
+ throw new Error();
2972
+ }
2973
+
2974
+ return column;
2975
+ }
3148
2976
  };
3149
- instance = Object.assign(instance, midInstance);
2977
+ Object.assign(instance, coreInstance);
3150
2978
 
3151
2979
  instance._features.forEach(feature => {
3152
2980
  return Object.assign(instance, feature.createInstance == null ? void 0 : feature.createInstance(instance));
@@ -3169,10 +2997,11 @@ function createTable(_, __, options) {
3169
2997
  throw new Error('');
3170
2998
  })()
3171
2999
  },
3172
- setGenerics: () => table,
3000
+ // setGenerics: () => table as any,
3173
3001
  setRowType: () => table,
3174
3002
  setTableMetaType: () => table,
3175
3003
  setColumnMetaType: () => table,
3004
+ setFilterMetaType: () => table,
3176
3005
  setOptions: newOptions => createTable(_, __, { ...options,
3177
3006
  ...newOptions
3178
3007
  }),
@@ -3204,11 +3033,92 @@ function createTable(_, __, options) {
3204
3033
  }
3205
3034
 
3206
3035
  throw new Error('Invalid accessor');
3207
- }
3036
+ },
3037
+ createOptions: options => options
3208
3038
  };
3209
3039
  return table;
3210
3040
  }
3211
3041
 
3042
+ function createCell(instance, row, column, columnId) {
3043
+ const cell = {
3044
+ id: row.id + "_" + column.id,
3045
+ row,
3046
+ column,
3047
+ getValue: () => row.getValue(columnId),
3048
+ renderCell: () => column.columnDef.cell ? instance._render(column.columnDef.cell, {
3049
+ instance,
3050
+ column,
3051
+ row,
3052
+ cell: cell,
3053
+ getValue: cell.getValue
3054
+ }) : null
3055
+ };
3056
+
3057
+ instance._features.forEach(feature => {
3058
+ Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
3059
+ }, {});
3060
+
3061
+ return cell;
3062
+ }
3063
+
3064
+ const createRow = (instance, id, original, rowIndex, depth, subRows) => {
3065
+ let row = {
3066
+ id,
3067
+ index: rowIndex,
3068
+ original,
3069
+ depth,
3070
+ _valuesCache: {},
3071
+ getValue: columnId => {
3072
+ if (row._valuesCache.hasOwnProperty(columnId)) {
3073
+ return row._valuesCache[columnId];
3074
+ }
3075
+
3076
+ const column = instance.getColumn(columnId);
3077
+
3078
+ if (!column.accessorFn) {
3079
+ return undefined;
3080
+ }
3081
+
3082
+ row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
3083
+ return row._valuesCache[columnId];
3084
+ },
3085
+ subRows: subRows != null ? subRows : [],
3086
+ getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
3087
+ getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
3088
+ return leafColumns.map(column => {
3089
+ return createCell(instance, row, column, column.id);
3090
+ });
3091
+ }, {
3092
+ key: process.env.NODE_ENV === 'development' && 'row.getAllCells',
3093
+ debug: () => {
3094
+ var _instance$options$deb;
3095
+
3096
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
3097
+ }
3098
+ }),
3099
+ _getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
3100
+ return allCells.reduce((acc, cell) => {
3101
+ acc[cell.column.id] = cell;
3102
+ return acc;
3103
+ }, {});
3104
+ }, {
3105
+ key: process.env.NODE_ENV === 'production' && 'row.getAllCellsByColumnId',
3106
+ debug: () => {
3107
+ var _instance$options$deb2;
3108
+
3109
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
3110
+ }
3111
+ })
3112
+ };
3113
+
3114
+ for (let i = 0; i < instance._features.length; i++) {
3115
+ const feature = instance._features[i];
3116
+ Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
3117
+ }
3118
+
3119
+ return row;
3120
+ };
3121
+
3212
3122
  function getCoreRowModel() {
3213
3123
  return instance => memo(() => [instance.options.data], data => {
3214
3124
  const rowModel = {
@@ -3236,7 +3146,7 @@ function getCoreRowModel() {
3236
3146
  // }
3237
3147
  // Make the row
3238
3148
 
3239
- row = instance.createRow(instance.getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3149
+ row = createRow(instance, instance._getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3240
3150
 
3241
3151
  rowModel.flatRows.push(row); // Also keep track of every row by its ID
3242
3152
 
@@ -3299,8 +3209,8 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
3299
3209
  row = rowsToFilter[i];
3300
3210
 
3301
3211
  if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
3302
- newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3303
- newRow.columnFilterMap = row.columnFilterMap;
3212
+ newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3213
+ newRow.columnFilters = row.columnFilters;
3304
3214
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3305
3215
 
3306
3216
  if (!newRow.subRows.length) {
@@ -3349,7 +3259,7 @@ function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
3349
3259
  var _row$subRows2;
3350
3260
 
3351
3261
  if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
3352
- newRow = instance.createRow(row.id, row.original, row.index, row.depth);
3262
+ newRow = createRow(instance, row.id, row.original, row.index, row.depth);
3353
3263
  newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
3354
3264
  row = newRow;
3355
3265
  }
@@ -3373,6 +3283,11 @@ function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
3373
3283
  function getFilteredRowModel() {
3374
3284
  return instance => memo(() => [instance.getPreFilteredRowModel(), instance.getState().columnFilters, instance.getState().globalFilter], (rowModel, columnFilters, globalFilter) => {
3375
3285
  if (!rowModel.rows.length || !(columnFilters != null && columnFilters.length) && !globalFilter) {
3286
+ for (let i = 0; i < rowModel.flatRows.length; i++) {
3287
+ rowModel.flatRows[i].columnFilters = {};
3288
+ rowModel.flatRows[i].columnFiltersMeta = {};
3289
+ }
3290
+
3376
3291
  return rowModel;
3377
3292
  }
3378
3293
 
@@ -3427,28 +3342,34 @@ function getFilteredRowModel() {
3427
3342
 
3428
3343
  for (let j = 0; j < rowModel.flatRows.length; j++) {
3429
3344
  const row = rowModel.flatRows[j];
3430
- row.columnFilterMap = {};
3345
+ row.columnFilters = {};
3431
3346
 
3432
3347
  if (resolvedColumnFilters.length) {
3433
3348
  for (let i = 0; i < resolvedColumnFilters.length; i++) {
3434
- currentColumnFilter = resolvedColumnFilters[i]; // Tag the row with the column filter state
3349
+ currentColumnFilter = resolvedColumnFilters[i];
3350
+ const id = currentColumnFilter.id; // Tag the row with the column filter state
3435
3351
 
3436
- row.columnFilterMap[currentColumnFilter.id] = currentColumnFilter.filterFn(row, currentColumnFilter.id, currentColumnFilter.resolvedValue);
3352
+ row.columnFilters[id] = currentColumnFilter.filterFn(row, id, currentColumnFilter.resolvedValue, filterMeta => {
3353
+ row.columnFiltersMeta[id] = filterMeta;
3354
+ });
3437
3355
  }
3438
3356
  }
3439
3357
 
3440
3358
  if (resolvedGlobalFilters.length) {
3441
3359
  for (let i = 0; i < resolvedGlobalFilters.length; i++) {
3442
- currentGlobalFilter = resolvedGlobalFilters[i]; // Tag the row with the first truthy global filter state
3360
+ currentGlobalFilter = resolvedGlobalFilters[i];
3361
+ const id = currentGlobalFilter.id; // Tag the row with the first truthy global filter state
3443
3362
 
3444
- if (currentGlobalFilter.filterFn(row, currentGlobalFilter.id, currentGlobalFilter.resolvedValue)) {
3445
- row.columnFilterMap.__global__ = true;
3363
+ if (currentGlobalFilter.filterFn(row, id, currentGlobalFilter.resolvedValue, filterMeta => {
3364
+ row.columnFiltersMeta[id] = filterMeta;
3365
+ })) {
3366
+ row.columnFilters.__global__ = true;
3446
3367
  break;
3447
3368
  }
3448
3369
  }
3449
3370
 
3450
- if (row.columnFilterMap.__global__ !== true) {
3451
- row.columnFilterMap.__global__ = false;
3371
+ if (row.columnFilters.__global__ !== true) {
3372
+ row.columnFilters.__global__ = false;
3452
3373
  }
3453
3374
  }
3454
3375
  }
@@ -3456,7 +3377,7 @@ function getFilteredRowModel() {
3456
3377
  const filterRowsImpl = row => {
3457
3378
  // Horizontally filter rows through each column
3458
3379
  for (let i = 0; i < filterableIds.length; i++) {
3459
- if (row.columnFilterMap[filterableIds[i]] === false) {
3380
+ if (row.columnFilters[filterableIds[i]] === false) {
3460
3381
  return false;
3461
3382
  }
3462
3383
  }
@@ -3490,7 +3411,7 @@ function getFacetedRowModel() {
3490
3411
  const filterRowsImpl = row => {
3491
3412
  // Horizontally filter rows through each column
3492
3413
  for (let i = 0; i < filterableIds.length; i++) {
3493
- if (row.columnFilterMap[filterableIds[i]] === false) {
3414
+ if (row.columnFilters[filterableIds[i]] === false) {
3494
3415
  return false;
3495
3416
  }
3496
3417
  }
@@ -3590,8 +3511,8 @@ function getSortedRowModel() {
3590
3511
  availableSorting.forEach(sortEntry => {
3591
3512
  const column = instance.getColumn(sortEntry.id);
3592
3513
  columnInfoById[sortEntry.id] = {
3593
- sortUndefined: column.sortUndefined,
3594
- invertSorting: column.invertSorting,
3514
+ sortUndefined: column.columnDef.sortUndefined,
3515
+ invertSorting: column.columnDef.invertSorting,
3595
3516
  sortingFn: column.getSortingFn()
3596
3517
  };
3597
3518
  });
@@ -3705,7 +3626,7 @@ function getGroupedRowModel() {
3705
3626
  const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
3706
3627
 
3707
3628
  const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
3708
- const row = instance.createRow(id, undefined, index, depth);
3629
+ const row = createRow(instance, id, undefined, index, depth);
3709
3630
  Object.assign(row, {
3710
3631
  groupingColumnId: columnId,
3711
3632
  groupingValue,
@@ -3714,17 +3635,17 @@ function getGroupedRowModel() {
3714
3635
  getValue: columnId => {
3715
3636
  // Don't aggregate columns that are in the grouping
3716
3637
  if (existingGrouping.includes(columnId)) {
3717
- if (row.valuesCache.hasOwnProperty(columnId)) {
3718
- return row.valuesCache[columnId];
3638
+ if (row._valuesCache.hasOwnProperty(columnId)) {
3639
+ return row._valuesCache[columnId];
3719
3640
  }
3720
3641
 
3721
3642
  if (groupedRows[0]) {
3722
3643
  var _groupedRows$0$getVal;
3723
3644
 
3724
- row.valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
3645
+ row._valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
3725
3646
  }
3726
3647
 
3727
- return row.valuesCache[columnId];
3648
+ return row._valuesCache[columnId];
3728
3649
  }
3729
3650
 
3730
3651
  if (row.groupingValuesCache.hasOwnProperty(columnId)) {
@@ -3739,8 +3660,8 @@ function getGroupedRowModel() {
3739
3660
  row.groupingValuesCache[columnId] = aggregateFn(() => leafRows.map(row => {
3740
3661
  let columnValue = row.getValue(columnId);
3741
3662
 
3742
- if (!depth && column.aggregateValue) {
3743
- columnValue = column.aggregateValue(columnValue);
3663
+ if (!depth && column.columnDef.aggregateValue) {
3664
+ columnValue = column.columnDef.aggregateValue(columnValue);
3744
3665
  }
3745
3666
 
3746
3667
  return columnValue;
@@ -3898,5 +3819,5 @@ function getPaginationRowModel(opts) {
3898
3819
  });
3899
3820
  }
3900
3821
 
3901
- export { ColumnSizing, Expanding, Filters, Grouping, Headers, Ordering, Pagination, Pinning, RowSelection, Sorting, Visibility, buildHeaderGroups, createTableFactory, createTableInstance, defaultColumnSizing, expandRows, flattenBy, functionalUpdate, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, isFunction, isRowSelected, makeStateUpdater, memo, noop, orderColumns, passiveEventSupported, selectRowsFn, shouldAutoRemoveFilter };
3822
+ export { ColumnSizing, Expanding, Filters, Grouping, Headers, Ordering, Pagination, Pinning, RowSelection, Sorting, Visibility, aggregationFns, buildHeaderGroups, createColumn, createRow, createTableFactory, createTableInstance, defaultColumnSizing, expandRows, filterFns, flattenBy, functionalUpdate, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, isFunction, isRowSelected, makeStateUpdater, mean, memo, noop, orderColumns, passiveEventSupported, reSplitAlphaNumeric, selectRowsFn, shouldAutoRemoveFilter, sortingFns };
3902
3823
  //# sourceMappingURL=index.js.map