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