@tanstack/react-table 8.0.0-alpha.82 → 8.0.0-alpha.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/react-table/src/index.js +2 -1
- package/build/cjs/react-table/src/index.js.map +1 -1
- package/build/cjs/table-core/build/esm/index.js +765 -865
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +764 -865
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +17 -17
- package/build/types/index.d.ts +2 -2
- package/build/umd/index.development.js +767 -863
- 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
- package/src/index.tsx +3 -5
|
@@ -99,335 +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.getDefaultColumn == null ? void 0 : feature.getDefaultColumn());
|
|
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' && 'getDefaultColumn'
|
|
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
|
-
|
|
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;
|
|
138
248
|
|
|
139
|
-
|
|
140
|
-
accessorFn = columnDef.accessorFn;
|
|
141
|
-
} else if (columnDef.accessorKey) {
|
|
142
|
-
accessorFn = originalRow => originalRow[columnDef.accessorKey];
|
|
249
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
|
|
143
250
|
}
|
|
251
|
+
}),
|
|
252
|
+
getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
253
|
+
var _left$map$filter2;
|
|
144
254
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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;
|
|
149
261
|
|
|
150
|
-
|
|
262
|
+
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
|
|
151
263
|
}
|
|
264
|
+
}),
|
|
265
|
+
getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
266
|
+
var _right$map$filter2;
|
|
152
267
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
id: "" + id,
|
|
156
|
-
accessorFn,
|
|
157
|
-
parent: parent,
|
|
158
|
-
depth,
|
|
159
|
-
columnDef,
|
|
160
|
-
columnDefType: columnDef.columnDefType,
|
|
161
|
-
columns: [],
|
|
162
|
-
getFlatColumns: memo(() => [true], () => {
|
|
163
|
-
var _column$columns;
|
|
164
|
-
|
|
165
|
-
return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
|
|
166
|
-
}, {
|
|
167
|
-
key: process.env.NODE_ENV === 'production' && 'column.getFlatColumns',
|
|
168
|
-
debug: () => {
|
|
169
|
-
var _instance$options$deb2;
|
|
170
|
-
|
|
171
|
-
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
|
|
172
|
-
}
|
|
173
|
-
}),
|
|
174
|
-
getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
|
|
175
|
-
var _column$columns2;
|
|
176
|
-
|
|
177
|
-
if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
|
|
178
|
-
let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
|
|
179
|
-
return orderColumns(leafColumns);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return [column];
|
|
183
|
-
}, {
|
|
184
|
-
key: process.env.NODE_ENV === 'production' && 'column.getLeafColumns',
|
|
185
|
-
debug: () => {
|
|
186
|
-
var _instance$options$deb3;
|
|
187
|
-
|
|
188
|
-
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
189
|
-
}
|
|
190
|
-
})
|
|
191
|
-
};
|
|
192
|
-
column = instance._features.reduce((obj, feature) => {
|
|
193
|
-
return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
|
|
194
|
-
}, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
195
|
-
|
|
196
|
-
return column;
|
|
197
|
-
},
|
|
198
|
-
getAllColumns: memo(() => [instance.getColumnDefs()], columnDefs => {
|
|
199
|
-
const recurseColumns = function (columnDefs, parent, depth) {
|
|
200
|
-
if (depth === void 0) {
|
|
201
|
-
depth = 0;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return columnDefs.map(columnDef => {
|
|
205
|
-
const column = instance.createColumn(columnDef, depth, parent);
|
|
206
|
-
column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
|
|
207
|
-
return column;
|
|
208
|
-
});
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
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');
|
|
212
270
|
}, {
|
|
213
|
-
key: process.env.NODE_ENV === 'development' && '
|
|
271
|
+
key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
|
|
214
272
|
debug: () => {
|
|
215
273
|
var _instance$options$deb4;
|
|
216
274
|
|
|
217
|
-
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;
|
|
218
276
|
}
|
|
219
277
|
}),
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
});
|
|
278
|
+
// Footer Groups
|
|
279
|
+
getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
280
|
+
return [...headerGroups].reverse();
|
|
224
281
|
}, {
|
|
225
|
-
key: process.env.NODE_ENV === 'development' && '
|
|
282
|
+
key: process.env.NODE_ENV === 'development' && 'getFooterGroups',
|
|
226
283
|
debug: () => {
|
|
227
284
|
var _instance$options$deb5;
|
|
228
285
|
|
|
229
|
-
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;
|
|
230
287
|
}
|
|
231
288
|
}),
|
|
232
|
-
|
|
233
|
-
return
|
|
234
|
-
acc[column.id] = column;
|
|
235
|
-
return acc;
|
|
236
|
-
}, {});
|
|
289
|
+
getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
|
|
290
|
+
return [...headerGroups].reverse();
|
|
237
291
|
}, {
|
|
238
|
-
key: process.env.NODE_ENV === 'development' && '
|
|
292
|
+
key: process.env.NODE_ENV === 'development' && 'getLeftFooterGroups',
|
|
239
293
|
debug: () => {
|
|
240
294
|
var _instance$options$deb6;
|
|
241
295
|
|
|
242
|
-
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;
|
|
243
297
|
}
|
|
244
298
|
}),
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
return orderColumns(leafColumns);
|
|
299
|
+
getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
|
|
300
|
+
return [...headerGroups].reverse();
|
|
248
301
|
}, {
|
|
249
|
-
key: process.env.NODE_ENV === 'development' && '
|
|
302
|
+
key: process.env.NODE_ENV === 'development' && 'getCenterFooterGroups',
|
|
250
303
|
debug: () => {
|
|
251
304
|
var _instance$options$deb7;
|
|
252
305
|
|
|
253
|
-
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;
|
|
254
307
|
}
|
|
255
308
|
}),
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}
|
|
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;
|
|
263
315
|
|
|
264
|
-
|
|
316
|
+
return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
|
|
265
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;
|
|
266
328
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
// ): CellsRow<TGenerics> => {
|
|
279
|
-
// return {}
|
|
280
|
-
// },
|
|
281
|
-
createInstance: instance => {
|
|
282
|
-
return {
|
|
283
|
-
getRowId: (row, index, parent) => {
|
|
284
|
-
var _instance$options$get;
|
|
285
|
-
|
|
286
|
-
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);
|
|
287
|
-
},
|
|
288
|
-
createRow: (id, original, rowIndex, depth, subRows) => {
|
|
289
|
-
let row = {
|
|
290
|
-
id,
|
|
291
|
-
index: rowIndex,
|
|
292
|
-
original,
|
|
293
|
-
depth,
|
|
294
|
-
valuesCache: {},
|
|
295
|
-
getValue: columnId => {
|
|
296
|
-
if (row.valuesCache.hasOwnProperty(columnId)) {
|
|
297
|
-
return row.valuesCache[columnId];
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
const column = instance.getColumn(columnId);
|
|
301
|
-
|
|
302
|
-
if (!column.accessorFn) {
|
|
303
|
-
return undefined;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
row.valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
|
307
|
-
return row.valuesCache[columnId];
|
|
308
|
-
},
|
|
309
|
-
subRows: subRows != null ? subRows : [],
|
|
310
|
-
getLeafRows: () => flattenBy(row.subRows, d => d.subRows)
|
|
311
|
-
};
|
|
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;
|
|
312
340
|
|
|
313
|
-
|
|
314
|
-
const feature = instance._features[i];
|
|
315
|
-
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;
|
|
316
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;
|
|
317
352
|
|
|
318
|
-
|
|
319
|
-
},
|
|
320
|
-
getCoreRowModel: () => {
|
|
321
|
-
if (!instance._getCoreRowModel) {
|
|
322
|
-
instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
|
|
353
|
+
return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
|
|
323
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;
|
|
324
364
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
//
|
|
329
|
-
|
|
330
|
-
return
|
|
331
|
-
|
|
332
|
-
getRow: id => {
|
|
333
|
-
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;
|
|
334
372
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
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;
|
|
339
379
|
|
|
340
|
-
|
|
380
|
+
return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
|
|
341
381
|
}
|
|
382
|
+
}),
|
|
383
|
+
getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
|
|
384
|
+
return flatHeaders.filter(header => {
|
|
385
|
+
var _header$subHeaders2;
|
|
342
386
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
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;
|
|
348
393
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
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);
|
|
356
402
|
});
|
|
357
403
|
}, {
|
|
358
|
-
key: process.env.NODE_ENV === 'development' && '
|
|
404
|
+
key: process.env.NODE_ENV === 'development' && 'getRightLeafHeaders',
|
|
359
405
|
debug: () => {
|
|
360
|
-
var _instance$options$
|
|
406
|
+
var _instance$options$deb15;
|
|
361
407
|
|
|
362
|
-
return (_instance$options$
|
|
408
|
+
return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
|
|
363
409
|
}
|
|
364
410
|
}),
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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();
|
|
370
417
|
}, {
|
|
371
|
-
key: process.env.NODE_ENV === '
|
|
418
|
+
key: process.env.NODE_ENV === 'development' && 'getLeafHeaders',
|
|
372
419
|
debug: () => {
|
|
373
|
-
var _instance$options$
|
|
420
|
+
var _instance$options$deb16;
|
|
374
421
|
|
|
375
|
-
return (_instance$options$
|
|
422
|
+
return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
|
|
376
423
|
}
|
|
377
424
|
})
|
|
378
425
|
};
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
const cell = {
|
|
384
|
-
id: row.id + "_" + column.id,
|
|
385
|
-
rowId: row.id,
|
|
386
|
-
columnId,
|
|
387
|
-
row,
|
|
388
|
-
column,
|
|
389
|
-
getValue: () => row.getValue(columnId),
|
|
390
|
-
renderCell: () => column.cell ? instance._render(column.cell, {
|
|
391
|
-
instance,
|
|
392
|
-
column,
|
|
393
|
-
row,
|
|
394
|
-
cell: cell,
|
|
395
|
-
getValue: cell.getValue
|
|
396
|
-
}) : null
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
instance._features.forEach(feature => {
|
|
400
|
-
Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
|
|
401
|
-
}, {});
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
|
|
429
|
+
var _headerGroups$0$heade, _headerGroups$;
|
|
402
430
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
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;
|
|
407
437
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
438
|
+
const findMaxDepth = function (columns, depth) {
|
|
439
|
+
if (depth === void 0) {
|
|
440
|
+
depth = 1;
|
|
441
|
+
}
|
|
412
442
|
|
|
413
|
-
|
|
414
|
-
|
|
443
|
+
maxDepth = Math.max(maxDepth, depth);
|
|
444
|
+
columns.filter(column => column.getIsVisible()).forEach(column => {
|
|
445
|
+
var _column$columns;
|
|
415
446
|
|
|
416
|
-
|
|
447
|
+
if ((_column$columns = column.columns) != null && _column$columns.length) {
|
|
448
|
+
findMaxDepth(column.columns, depth + 1);
|
|
449
|
+
}
|
|
450
|
+
}, 0);
|
|
451
|
+
};
|
|
417
452
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
throw new Error("[Table] could not find cell " + columnId + " in row " + rowId);
|
|
421
|
-
}
|
|
453
|
+
findMaxDepth(allColumns);
|
|
454
|
+
let headerGroups = [];
|
|
422
455
|
|
|
423
|
-
|
|
424
|
-
|
|
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
|
|
463
|
+
|
|
464
|
+
const pendingParentHeaders = []; // Scan each column for parents
|
|
465
|
+
|
|
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;
|
|
425
472
|
|
|
426
|
-
|
|
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;
|
|
427
480
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
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
|
|
497
|
+
|
|
498
|
+
pendingParentHeaders.push(header);
|
|
499
|
+
}
|
|
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
|
+
}
|
|
431
555
|
|
|
432
556
|
//
|
|
433
557
|
const defaultColumnSizing = {
|
|
@@ -446,7 +570,7 @@ const getDefaultColumnSizingInfoState = () => ({
|
|
|
446
570
|
});
|
|
447
571
|
|
|
448
572
|
const ColumnSizing = {
|
|
449
|
-
|
|
573
|
+
getDefaultColumnDef: () => {
|
|
450
574
|
return defaultColumnSizing;
|
|
451
575
|
},
|
|
452
576
|
getInitialState: state => {
|
|
@@ -466,10 +590,10 @@ const ColumnSizing = {
|
|
|
466
590
|
createColumn: (column, instance) => {
|
|
467
591
|
return {
|
|
468
592
|
getSize: () => {
|
|
469
|
-
var _column$
|
|
593
|
+
var _column$columnDef$min, _ref, _column$columnDef$max;
|
|
470
594
|
|
|
471
595
|
const columnSize = instance.getState().columnSizing[column.id];
|
|
472
|
-
return Math.min(Math.max((_column$
|
|
596
|
+
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);
|
|
473
597
|
},
|
|
474
598
|
getStart: position => {
|
|
475
599
|
const columns = !position ? instance.getVisibleLeafColumns() : position === 'left' ? instance.getLeftVisibleLeafColumns() : instance.getRightVisibleLeafColumns();
|
|
@@ -492,9 +616,9 @@ const ColumnSizing = {
|
|
|
492
616
|
});
|
|
493
617
|
},
|
|
494
618
|
getCanResize: () => {
|
|
495
|
-
var _column$
|
|
619
|
+
var _column$columnDef$ena, _instance$options$ena;
|
|
496
620
|
|
|
497
|
-
return ((_column$
|
|
621
|
+
return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableColumnResizing) != null ? _instance$options$ena : true);
|
|
498
622
|
},
|
|
499
623
|
getIsResizing: () => {
|
|
500
624
|
return instance.getState().columnSizingInfo.isResizingColumn === column.id;
|
|
@@ -951,7 +1075,7 @@ function testFalsey(val) {
|
|
|
951
1075
|
|
|
952
1076
|
//
|
|
953
1077
|
const Filters = {
|
|
954
|
-
|
|
1078
|
+
getDefaultColumnDef: () => {
|
|
955
1079
|
return {
|
|
956
1080
|
filterFn: 'auto'
|
|
957
1081
|
};
|
|
@@ -974,7 +1098,7 @@ const Filters = {
|
|
|
974
1098
|
getColumnCanGlobalFilter: column => {
|
|
975
1099
|
var _instance$getCoreRowM, _instance$getCoreRowM2;
|
|
976
1100
|
|
|
977
|
-
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();
|
|
978
1102
|
return typeof value === 'string';
|
|
979
1103
|
}
|
|
980
1104
|
};
|
|
@@ -994,6 +1118,10 @@ const Filters = {
|
|
|
994
1118
|
return filterFns.inNumberRange;
|
|
995
1119
|
}
|
|
996
1120
|
|
|
1121
|
+
if (typeof value === 'boolean') {
|
|
1122
|
+
return filterFns.equals;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
997
1125
|
if (value !== null && typeof value === 'object') {
|
|
998
1126
|
return filterFns.equals;
|
|
999
1127
|
}
|
|
@@ -1011,14 +1139,14 @@ const Filters = {
|
|
|
1011
1139
|
return isFunction(column.filterFn) ? column.filterFn : column.filterFn === 'auto' ? column.getAutoFilterFn() : (_ref = userFilterFns == null ? void 0 : userFilterFns[column.filterFn]) != null ? _ref : filterFns[column.filterFn];
|
|
1012
1140
|
},
|
|
1013
1141
|
getCanFilter: () => {
|
|
1014
|
-
var _column$
|
|
1142
|
+
var _column$columnDef$ena, _instance$options$ena, _instance$options$ena2;
|
|
1015
1143
|
|
|
1016
|
-
return ((_column$
|
|
1144
|
+
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;
|
|
1017
1145
|
},
|
|
1018
1146
|
getCanGlobalFilter: () => {
|
|
1019
|
-
var _column$
|
|
1147
|
+
var _column$columnDef$ena2, _instance$options$ena3, _instance$options$ena4, _instance$options$get;
|
|
1020
1148
|
|
|
1021
|
-
return ((_column$
|
|
1149
|
+
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;
|
|
1022
1150
|
},
|
|
1023
1151
|
getIsFiltered: () => column.getFilterIndex() > -1,
|
|
1024
1152
|
getFilterValue: () => {
|
|
@@ -1098,8 +1226,7 @@ const Filters = {
|
|
|
1098
1226
|
createRow: (row, instance) => {
|
|
1099
1227
|
return {
|
|
1100
1228
|
columnFilters: {},
|
|
1101
|
-
columnFiltersMeta: {}
|
|
1102
|
-
subRowsByFacetId: {}
|
|
1229
|
+
columnFiltersMeta: {}
|
|
1103
1230
|
};
|
|
1104
1231
|
},
|
|
1105
1232
|
createInstance: instance => {
|
|
@@ -1190,53 +1317,42 @@ function shouldAutoRemoveFilter(filterFn, value, column) {
|
|
|
1190
1317
|
return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
|
|
1191
1318
|
}
|
|
1192
1319
|
|
|
1193
|
-
const
|
|
1194
|
-
sum,
|
|
1195
|
-
min,
|
|
1196
|
-
max,
|
|
1197
|
-
extent,
|
|
1198
|
-
mean,
|
|
1199
|
-
median,
|
|
1200
|
-
unique,
|
|
1201
|
-
uniqueCount,
|
|
1202
|
-
count
|
|
1203
|
-
};
|
|
1204
|
-
|
|
1205
|
-
function sum(_getLeafValues, getChildValues) {
|
|
1320
|
+
const sum = (columnId, _leafRows, childRows) => {
|
|
1206
1321
|
// It's faster to just add the aggregations together instead of
|
|
1207
1322
|
// process leaf nodes individually
|
|
1208
|
-
return
|
|
1209
|
-
}
|
|
1323
|
+
return childRows.reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
|
|
1324
|
+
};
|
|
1210
1325
|
|
|
1211
|
-
|
|
1326
|
+
const min = (columnId, _leafRows, childRows) => {
|
|
1212
1327
|
let min;
|
|
1328
|
+
childRows.forEach(row => {
|
|
1329
|
+
const value = row.getValue(columnId);
|
|
1213
1330
|
|
|
1214
|
-
for (const value of getChildValues()) {
|
|
1215
1331
|
if (value != null && (min > value || min === undefined && value >= value)) {
|
|
1216
1332
|
min = value;
|
|
1217
1333
|
}
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1334
|
+
});
|
|
1220
1335
|
return min;
|
|
1221
|
-
}
|
|
1336
|
+
};
|
|
1222
1337
|
|
|
1223
|
-
|
|
1338
|
+
const max = (columnId, _leafRows, childRows) => {
|
|
1224
1339
|
let max;
|
|
1340
|
+
childRows.forEach(row => {
|
|
1341
|
+
const value = row.getValue(columnId);
|
|
1225
1342
|
|
|
1226
|
-
for (const value of getChildValues()) {
|
|
1227
1343
|
if (value != null && (max < value || max === undefined && value >= value)) {
|
|
1228
1344
|
max = value;
|
|
1229
1345
|
}
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1346
|
+
});
|
|
1232
1347
|
return max;
|
|
1233
|
-
}
|
|
1348
|
+
};
|
|
1234
1349
|
|
|
1235
|
-
|
|
1350
|
+
const extent = (columnId, _leafRows, childRows) => {
|
|
1236
1351
|
let min;
|
|
1237
1352
|
let max;
|
|
1353
|
+
childRows.forEach(row => {
|
|
1354
|
+
const value = row.getValue(columnId);
|
|
1238
1355
|
|
|
1239
|
-
for (const value of getChildValues()) {
|
|
1240
1356
|
if (value != null) {
|
|
1241
1357
|
if (min === undefined) {
|
|
1242
1358
|
if (value >= value) min = max = value;
|
|
@@ -1245,58 +1361,69 @@ function extent(_getLeafValues, getChildValues) {
|
|
|
1245
1361
|
if (max < value) max = value;
|
|
1246
1362
|
}
|
|
1247
1363
|
}
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1364
|
+
});
|
|
1250
1365
|
return [min, max];
|
|
1251
|
-
}
|
|
1366
|
+
};
|
|
1252
1367
|
|
|
1253
|
-
|
|
1368
|
+
const mean = (columnId, leafRows) => {
|
|
1254
1369
|
let count = 0;
|
|
1255
1370
|
let sum = 0;
|
|
1371
|
+
leafRows.forEach(row => {
|
|
1372
|
+
let value = row.getValue(columnId);
|
|
1256
1373
|
|
|
1257
|
-
for (let value of getLeafValues()) {
|
|
1258
1374
|
if (value != null && (value = +value) >= value) {
|
|
1259
1375
|
++count, sum += value;
|
|
1260
1376
|
}
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1377
|
+
});
|
|
1263
1378
|
if (count) return sum / count;
|
|
1264
1379
|
return;
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
function median(getLeafValues) {
|
|
1268
|
-
const leafValues = getLeafValues();
|
|
1380
|
+
};
|
|
1269
1381
|
|
|
1270
|
-
|
|
1382
|
+
const median = (columnId, leafRows) => {
|
|
1383
|
+
if (!leafRows.length) {
|
|
1271
1384
|
return;
|
|
1272
1385
|
}
|
|
1273
1386
|
|
|
1274
1387
|
let min = 0;
|
|
1275
1388
|
let max = 0;
|
|
1276
|
-
|
|
1389
|
+
leafRows.forEach(row => {
|
|
1390
|
+
let value = row.getValue(columnId);
|
|
1391
|
+
|
|
1277
1392
|
if (typeof value === 'number') {
|
|
1278
1393
|
min = Math.min(min, value);
|
|
1279
1394
|
max = Math.max(max, value);
|
|
1280
1395
|
}
|
|
1281
1396
|
});
|
|
1282
1397
|
return (min + max) / 2;
|
|
1283
|
-
}
|
|
1398
|
+
};
|
|
1284
1399
|
|
|
1285
|
-
|
|
1286
|
-
return Array.from(new Set(
|
|
1287
|
-
}
|
|
1400
|
+
const unique = (columnId, leafRows) => {
|
|
1401
|
+
return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
|
|
1402
|
+
};
|
|
1288
1403
|
|
|
1289
|
-
|
|
1290
|
-
return new Set(
|
|
1291
|
-
}
|
|
1404
|
+
const uniqueCount = (columnId, leafRows) => {
|
|
1405
|
+
return new Set(leafRows.map(d => d.getValue(columnId))).size;
|
|
1406
|
+
};
|
|
1292
1407
|
|
|
1293
|
-
|
|
1294
|
-
return
|
|
1295
|
-
}
|
|
1408
|
+
const count = (_columnId, leafRows) => {
|
|
1409
|
+
return leafRows.length;
|
|
1410
|
+
};
|
|
1411
|
+
|
|
1412
|
+
const aggregationFns = {
|
|
1413
|
+
sum,
|
|
1414
|
+
min,
|
|
1415
|
+
max,
|
|
1416
|
+
extent,
|
|
1417
|
+
mean,
|
|
1418
|
+
median,
|
|
1419
|
+
unique,
|
|
1420
|
+
uniqueCount,
|
|
1421
|
+
count
|
|
1422
|
+
};
|
|
1296
1423
|
|
|
1297
1424
|
//
|
|
1298
1425
|
const Grouping = {
|
|
1299
|
-
|
|
1426
|
+
getDefaultColumnDef: () => {
|
|
1300
1427
|
return {
|
|
1301
1428
|
aggregationFn: 'auto'
|
|
1302
1429
|
};
|
|
@@ -1326,9 +1453,9 @@ const Grouping = {
|
|
|
1326
1453
|
});
|
|
1327
1454
|
},
|
|
1328
1455
|
getCanGroup: () => {
|
|
1329
|
-
var _ref, _ref2, _ref3, _column$
|
|
1456
|
+
var _ref, _ref2, _ref3, _column$columnDef$ena;
|
|
1330
1457
|
|
|
1331
|
-
return (_ref = (_ref2 = (_ref3 = (_column$
|
|
1458
|
+
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;
|
|
1332
1459
|
},
|
|
1333
1460
|
getIsGrouped: () => {
|
|
1334
1461
|
var _instance$getState$gr;
|
|
@@ -1347,7 +1474,7 @@ const Grouping = {
|
|
|
1347
1474
|
column.toggleGrouping();
|
|
1348
1475
|
};
|
|
1349
1476
|
},
|
|
1350
|
-
|
|
1477
|
+
getAutoAggregationFn: () => {
|
|
1351
1478
|
const firstRow = instance.getCoreRowModel().flatRows[0];
|
|
1352
1479
|
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
|
1353
1480
|
|
|
@@ -1361,7 +1488,7 @@ const Grouping = {
|
|
|
1361
1488
|
|
|
1362
1489
|
return aggregationFns.count;
|
|
1363
1490
|
},
|
|
1364
|
-
|
|
1491
|
+
getAggregationFn: () => {
|
|
1365
1492
|
var _ref4;
|
|
1366
1493
|
|
|
1367
1494
|
const userAggregationFns = instance.options.aggregationFns;
|
|
@@ -1370,7 +1497,7 @@ const Grouping = {
|
|
|
1370
1497
|
throw new Error();
|
|
1371
1498
|
}
|
|
1372
1499
|
|
|
1373
|
-
return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.
|
|
1500
|
+
return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_ref4 = userAggregationFns == null ? void 0 : userAggregationFns[column.aggregationFn]) != null ? _ref4 : aggregationFns[column.aggregationFn];
|
|
1374
1501
|
}
|
|
1375
1502
|
};
|
|
1376
1503
|
},
|
|
@@ -1396,10 +1523,10 @@ const Grouping = {
|
|
|
1396
1523
|
}
|
|
1397
1524
|
};
|
|
1398
1525
|
},
|
|
1399
|
-
createRow:
|
|
1526
|
+
createRow: row => {
|
|
1400
1527
|
return {
|
|
1401
1528
|
getIsGrouped: () => !!row.groupingColumnId,
|
|
1402
|
-
|
|
1529
|
+
_groupingValuesCache: {}
|
|
1403
1530
|
};
|
|
1404
1531
|
},
|
|
1405
1532
|
createCell: (cell, column, row, instance) => {
|
|
@@ -1412,9 +1539,9 @@ const Grouping = {
|
|
|
1412
1539
|
return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
|
|
1413
1540
|
},
|
|
1414
1541
|
renderAggregatedCell: () => {
|
|
1415
|
-
var _column$
|
|
1542
|
+
var _column$columnDef$agg;
|
|
1416
1543
|
|
|
1417
|
-
const template = (_column$
|
|
1544
|
+
const template = (_column$columnDef$agg = column.columnDef.aggregatedCell) != null ? _column$columnDef$agg : column.columnDef.cell;
|
|
1418
1545
|
return template ? instance._render(template, {
|
|
1419
1546
|
instance,
|
|
1420
1547
|
column,
|
|
@@ -1721,9 +1848,9 @@ const Pinning = {
|
|
|
1721
1848
|
getCanPin: () => {
|
|
1722
1849
|
const leafColumns = column.getLeafColumns();
|
|
1723
1850
|
return leafColumns.some(d => {
|
|
1724
|
-
var _d$
|
|
1851
|
+
var _d$columnDef$enablePi, _instance$options$ena;
|
|
1725
1852
|
|
|
1726
|
-
return ((_d$
|
|
1853
|
+
return ((_d$columnDef$enablePi = d.columnDef.enablePinning) != null ? _d$columnDef$enablePi : true) && ((_instance$options$ena = instance.options.enablePinning) != null ? _instance$options$ena : true);
|
|
1727
1854
|
});
|
|
1728
1855
|
},
|
|
1729
1856
|
getIsPinned: () => {
|
|
@@ -1748,7 +1875,7 @@ const Pinning = {
|
|
|
1748
1875
|
return {
|
|
1749
1876
|
getCenterVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allCells, left, right) => {
|
|
1750
1877
|
const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
|
|
1751
|
-
return allCells.filter(d => !leftAndRight.includes(d.
|
|
1878
|
+
return allCells.filter(d => !leftAndRight.includes(d.column.id));
|
|
1752
1879
|
}, {
|
|
1753
1880
|
key: process.env.NODE_ENV === 'production' && 'row.getCenterVisibleCells',
|
|
1754
1881
|
debug: () => {
|
|
@@ -1758,7 +1885,7 @@ const Pinning = {
|
|
|
1758
1885
|
}
|
|
1759
1886
|
}),
|
|
1760
1887
|
getLeftVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left,,], (allCells, left) => {
|
|
1761
|
-
const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.
|
|
1888
|
+
const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
|
|
1762
1889
|
position: 'left'
|
|
1763
1890
|
}));
|
|
1764
1891
|
return cells;
|
|
@@ -1771,7 +1898,7 @@ const Pinning = {
|
|
|
1771
1898
|
}
|
|
1772
1899
|
}),
|
|
1773
1900
|
getRightVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.right], (allCells, right) => {
|
|
1774
|
-
const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.
|
|
1901
|
+
const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
|
|
1775
1902
|
position: 'left'
|
|
1776
1903
|
}));
|
|
1777
1904
|
return cells;
|
|
@@ -1793,12 +1920,18 @@ const Pinning = {
|
|
|
1793
1920
|
|
|
1794
1921
|
return instance.setColumnPinning(defaultState ? getDefaultPinningState() : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.columnPinning) != null ? _instance$initialStat : getDefaultPinningState());
|
|
1795
1922
|
},
|
|
1796
|
-
getIsSomeColumnsPinned:
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1923
|
+
getIsSomeColumnsPinned: position => {
|
|
1924
|
+
var _pinningState$positio;
|
|
1925
|
+
|
|
1926
|
+
const pinningState = instance.getState().columnPinning;
|
|
1927
|
+
|
|
1928
|
+
if (!position) {
|
|
1929
|
+
var _pinningState$left, _pinningState$right;
|
|
1930
|
+
|
|
1931
|
+
return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
|
|
1802
1935
|
},
|
|
1803
1936
|
getLeftLeafColumns: memo(() => [instance.getAllLeafColumns(), instance.getState().columnPinning.left], (allColumns, left) => {
|
|
1804
1937
|
return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
|
|
@@ -2324,7 +2457,7 @@ const Sorting = {
|
|
|
2324
2457
|
...state
|
|
2325
2458
|
};
|
|
2326
2459
|
},
|
|
2327
|
-
|
|
2460
|
+
getDefaultColumnDef: () => {
|
|
2328
2461
|
return {
|
|
2329
2462
|
sortingFn: 'auto'
|
|
2330
2463
|
};
|
|
@@ -2384,7 +2517,7 @@ const Sorting = {
|
|
|
2384
2517
|
throw new Error();
|
|
2385
2518
|
}
|
|
2386
2519
|
|
|
2387
|
-
return isFunction(column.sortingFn) ? column.sortingFn : column.sortingFn === 'auto' ? column.getAutoSortingFn() : (_ref = userSortingFn == null ? void 0 : userSortingFn[column.sortingFn]) != null ? _ref : sortingFns[column.sortingFn];
|
|
2520
|
+
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];
|
|
2388
2521
|
},
|
|
2389
2522
|
toggleSorting: (desc, multi) => {
|
|
2390
2523
|
// if (column.columns.length) {
|
|
@@ -2396,7 +2529,7 @@ const Sorting = {
|
|
|
2396
2529
|
// return
|
|
2397
2530
|
// }
|
|
2398
2531
|
instance.setSorting(old => {
|
|
2399
|
-
var _ref2, _column$
|
|
2532
|
+
var _ref2, _column$columnDef$sor, _instance$options$ena, _instance$options$ena2;
|
|
2400
2533
|
|
|
2401
2534
|
// Find any existing sorting for this column
|
|
2402
2535
|
const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
|
|
@@ -2423,7 +2556,7 @@ const Sorting = {
|
|
|
2423
2556
|
}
|
|
2424
2557
|
}
|
|
2425
2558
|
|
|
2426
|
-
const sortDescFirst = (_ref2 = (_column$
|
|
2559
|
+
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
|
|
2427
2560
|
|
|
2428
2561
|
if (sortAction === 'toggle' && ( // Must be toggling
|
|
2429
2562
|
(_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
|
|
@@ -2467,14 +2600,14 @@ const Sorting = {
|
|
|
2467
2600
|
});
|
|
2468
2601
|
},
|
|
2469
2602
|
getCanSort: () => {
|
|
2470
|
-
var _column$
|
|
2603
|
+
var _column$columnDef$ena, _instance$options$ena3;
|
|
2471
2604
|
|
|
2472
|
-
return ((_column$
|
|
2605
|
+
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;
|
|
2473
2606
|
},
|
|
2474
2607
|
getCanMultiSort: () => {
|
|
2475
|
-
var _ref3, _column$
|
|
2608
|
+
var _ref3, _column$columnDef$ena2;
|
|
2476
2609
|
|
|
2477
|
-
return (_ref3 = (_column$
|
|
2610
|
+
return (_ref3 = (_column$columnDef$ena2 = column.columnDef.enableMultiSort) != null ? _column$columnDef$ena2 : instance.options.enableMultiSort) != null ? _ref3 : !!column.accessorFn;
|
|
2478
2611
|
},
|
|
2479
2612
|
getIsSorted: () => {
|
|
2480
2613
|
var _instance$getState$so;
|
|
@@ -2538,7 +2671,7 @@ const Visibility = {
|
|
|
2538
2671
|
onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
|
|
2539
2672
|
};
|
|
2540
2673
|
},
|
|
2541
|
-
|
|
2674
|
+
getDefaultColumnDef: () => {
|
|
2542
2675
|
return {
|
|
2543
2676
|
defaultIsVisible: true
|
|
2544
2677
|
};
|
|
@@ -2558,9 +2691,9 @@ const Visibility = {
|
|
|
2558
2691
|
return (_instance$getState$co = (_instance$getState$co2 = instance.getState().columnVisibility) == null ? void 0 : _instance$getState$co2[column.id]) != null ? _instance$getState$co : true;
|
|
2559
2692
|
},
|
|
2560
2693
|
getCanHide: () => {
|
|
2561
|
-
var _column$
|
|
2694
|
+
var _column$columnDef$ena, _instance$options$ena;
|
|
2562
2695
|
|
|
2563
|
-
return ((_column$
|
|
2696
|
+
return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : true);
|
|
2564
2697
|
},
|
|
2565
2698
|
getToggleVisibilityHandler: () => {
|
|
2566
2699
|
return e => {
|
|
@@ -2576,475 +2709,70 @@ const Visibility = {
|
|
|
2576
2709
|
}, {
|
|
2577
2710
|
key: process.env.NODE_ENV === 'production' && 'row._getAllVisibleCells',
|
|
2578
2711
|
debug: () => {
|
|
2579
|
-
var _instance$options$deb;
|
|
2580
|
-
|
|
2581
|
-
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
|
|
2582
|
-
}
|
|
2583
|
-
}),
|
|
2584
|
-
getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
|
|
2585
|
-
key: process.env.NODE_ENV === 'development' && 'row.getVisibleCells',
|
|
2586
|
-
debug: () => {
|
|
2587
|
-
var _instance$options$deb2;
|
|
2588
|
-
|
|
2589
|
-
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
|
|
2590
|
-
}
|
|
2591
|
-
})
|
|
2592
|
-
};
|
|
2593
|
-
},
|
|
2594
|
-
createInstance: instance => {
|
|
2595
|
-
const makeVisibleColumnsMethod = (key, getColumns) => {
|
|
2596
|
-
return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
|
|
2597
|
-
return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
|
|
2598
|
-
}, {
|
|
2599
|
-
key,
|
|
2600
|
-
debug: () => {
|
|
2601
|
-
var _instance$options$deb3;
|
|
2602
|
-
|
|
2603
|
-
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
2604
|
-
}
|
|
2605
|
-
});
|
|
2606
|
-
};
|
|
2607
|
-
|
|
2608
|
-
return {
|
|
2609
|
-
getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
|
|
2610
|
-
getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
|
|
2611
|
-
getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
|
|
2612
|
-
getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
|
|
2613
|
-
getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
|
|
2614
|
-
setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
|
|
2615
|
-
resetColumnVisibility: defaultState => {
|
|
2616
|
-
var _instance$initialStat;
|
|
2617
|
-
|
|
2618
|
-
instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
|
|
2619
|
-
},
|
|
2620
|
-
toggleAllColumnsVisible: value => {
|
|
2621
|
-
var _value;
|
|
2622
|
-
|
|
2623
|
-
value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
|
|
2624
|
-
instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
|
|
2625
|
-
[column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
|
|
2626
|
-
}), {}));
|
|
2627
|
-
},
|
|
2628
|
-
getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
|
|
2629
|
-
getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
|
|
2630
|
-
getToggleAllColumnsVisibilityHandler: () => {
|
|
2631
|
-
return e => {
|
|
2632
|
-
var _target;
|
|
2633
|
-
|
|
2634
|
-
instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
|
|
2635
|
-
};
|
|
2636
|
-
}
|
|
2637
|
-
};
|
|
2638
|
-
}
|
|
2639
|
-
};
|
|
2640
|
-
|
|
2641
|
-
//
|
|
2642
|
-
const Headers = {
|
|
2643
|
-
createInstance: instance => {
|
|
2644
|
-
return {
|
|
2645
|
-
createHeader: (column, options) => {
|
|
2646
|
-
var _options$id;
|
|
2647
|
-
|
|
2648
|
-
const id = (_options$id = options.id) != null ? _options$id : column.id;
|
|
2649
|
-
let header = {
|
|
2650
|
-
id,
|
|
2651
|
-
column,
|
|
2652
|
-
index: options.index,
|
|
2653
|
-
isPlaceholder: options.isPlaceholder,
|
|
2654
|
-
placeholderId: options.placeholderId,
|
|
2655
|
-
depth: options.depth,
|
|
2656
|
-
subHeaders: [],
|
|
2657
|
-
colSpan: 0,
|
|
2658
|
-
rowSpan: 0,
|
|
2659
|
-
headerGroup: null,
|
|
2660
|
-
getLeafHeaders: () => {
|
|
2661
|
-
const leafHeaders = [];
|
|
2662
|
-
|
|
2663
|
-
const recurseHeader = h => {
|
|
2664
|
-
if (h.subHeaders && h.subHeaders.length) {
|
|
2665
|
-
h.subHeaders.map(recurseHeader);
|
|
2666
|
-
}
|
|
2667
|
-
|
|
2668
|
-
leafHeaders.push(h);
|
|
2669
|
-
};
|
|
2670
|
-
|
|
2671
|
-
recurseHeader(header);
|
|
2672
|
-
return leafHeaders;
|
|
2673
|
-
},
|
|
2674
|
-
renderHeader: () => column.header ? instance._render(column.header, {
|
|
2675
|
-
instance,
|
|
2676
|
-
header: header,
|
|
2677
|
-
column
|
|
2678
|
-
}) : null,
|
|
2679
|
-
renderFooter: () => column.footer ? instance._render(column.footer, {
|
|
2680
|
-
instance,
|
|
2681
|
-
header: header,
|
|
2682
|
-
column
|
|
2683
|
-
}) : null
|
|
2684
|
-
};
|
|
2685
|
-
|
|
2686
|
-
instance._features.forEach(feature => {
|
|
2687
|
-
Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
|
|
2688
|
-
});
|
|
2689
|
-
|
|
2690
|
-
return header;
|
|
2691
|
-
},
|
|
2692
|
-
// Header Groups
|
|
2693
|
-
getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
2694
|
-
var _left$map$filter, _right$map$filter;
|
|
2695
|
-
|
|
2696
|
-
const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
|
|
2697
|
-
const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
|
|
2698
|
-
const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
2699
|
-
const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
|
|
2700
|
-
return headerGroups;
|
|
2701
|
-
}, {
|
|
2702
|
-
key: process.env.NODE_ENV === 'development' && 'getHeaderGroups',
|
|
2703
|
-
debug: () => {
|
|
2704
|
-
var _instance$options$deb;
|
|
2705
|
-
|
|
2706
|
-
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
|
|
2707
|
-
}
|
|
2708
|
-
}),
|
|
2709
|
-
getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
2710
|
-
leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
2711
|
-
return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
|
|
2712
|
-
}, {
|
|
2713
|
-
key: process.env.NODE_ENV === 'development' && 'getCenterHeaderGroups',
|
|
2714
|
-
debug: () => {
|
|
2715
|
-
var _instance$options$deb2;
|
|
2716
|
-
|
|
2717
|
-
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
|
|
2718
|
-
}
|
|
2719
|
-
}),
|
|
2720
|
-
getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
2721
|
-
var _left$map$filter2;
|
|
2722
|
-
|
|
2723
|
-
const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
|
|
2724
|
-
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
|
|
2725
|
-
}, {
|
|
2726
|
-
key: process.env.NODE_ENV === 'development' && 'getLeftHeaderGroups',
|
|
2727
|
-
debug: () => {
|
|
2728
|
-
var _instance$options$deb3;
|
|
2729
|
-
|
|
2730
|
-
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
|
|
2731
|
-
}
|
|
2732
|
-
}),
|
|
2733
|
-
getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
2734
|
-
var _right$map$filter2;
|
|
2735
|
-
|
|
2736
|
-
const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
|
|
2737
|
-
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
|
|
2738
|
-
}, {
|
|
2739
|
-
key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
|
|
2740
|
-
debug: () => {
|
|
2741
|
-
var _instance$options$deb4;
|
|
2742
|
-
|
|
2743
|
-
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
|
|
2744
|
-
}
|
|
2745
|
-
}),
|
|
2746
|
-
// Footer Groups
|
|
2747
|
-
getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
2748
|
-
return [...headerGroups].reverse();
|
|
2749
|
-
}, {
|
|
2750
|
-
key: process.env.NODE_ENV === 'development' && 'getFooterGroups',
|
|
2751
|
-
debug: () => {
|
|
2752
|
-
var _instance$options$deb5;
|
|
2753
|
-
|
|
2754
|
-
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
|
|
2755
|
-
}
|
|
2756
|
-
}),
|
|
2757
|
-
getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
|
|
2758
|
-
return [...headerGroups].reverse();
|
|
2759
|
-
}, {
|
|
2760
|
-
key: process.env.NODE_ENV === 'development' && 'getLeftFooterGroups',
|
|
2761
|
-
debug: () => {
|
|
2762
|
-
var _instance$options$deb6;
|
|
2763
|
-
|
|
2764
|
-
return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
|
|
2765
|
-
}
|
|
2766
|
-
}),
|
|
2767
|
-
getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
|
|
2768
|
-
return [...headerGroups].reverse();
|
|
2769
|
-
}, {
|
|
2770
|
-
key: process.env.NODE_ENV === 'development' && 'getCenterFooterGroups',
|
|
2771
|
-
debug: () => {
|
|
2772
|
-
var _instance$options$deb7;
|
|
2773
|
-
|
|
2774
|
-
return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
|
|
2775
|
-
}
|
|
2776
|
-
}),
|
|
2777
|
-
getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
|
|
2778
|
-
return [...headerGroups].reverse();
|
|
2779
|
-
}, {
|
|
2780
|
-
key: process.env.NODE_ENV === 'development' && 'getRightFooterGroups',
|
|
2781
|
-
debug: () => {
|
|
2782
|
-
var _instance$options$deb8;
|
|
2783
|
-
|
|
2784
|
-
return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
|
|
2785
|
-
}
|
|
2786
|
-
}),
|
|
2787
|
-
// Flat Headers
|
|
2788
|
-
getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
2789
|
-
return headerGroups.map(headerGroup => {
|
|
2790
|
-
return headerGroup.headers;
|
|
2791
|
-
}).flat();
|
|
2792
|
-
}, {
|
|
2793
|
-
key: process.env.NODE_ENV === 'development' && 'getFlatHeaders',
|
|
2794
|
-
debug: () => {
|
|
2795
|
-
var _instance$options$deb9;
|
|
2796
|
-
|
|
2797
|
-
return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
|
|
2798
|
-
}
|
|
2799
|
-
}),
|
|
2800
|
-
getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
|
|
2801
|
-
return left.map(headerGroup => {
|
|
2802
|
-
return headerGroup.headers;
|
|
2803
|
-
}).flat();
|
|
2804
|
-
}, {
|
|
2805
|
-
key: process.env.NODE_ENV === 'development' && 'getLeftFlatHeaders',
|
|
2806
|
-
debug: () => {
|
|
2807
|
-
var _instance$options$deb10;
|
|
2808
|
-
|
|
2809
|
-
return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
|
|
2810
|
-
}
|
|
2811
|
-
}),
|
|
2812
|
-
getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
|
|
2813
|
-
return left.map(headerGroup => {
|
|
2814
|
-
return headerGroup.headers;
|
|
2815
|
-
}).flat();
|
|
2816
|
-
}, {
|
|
2817
|
-
key: process.env.NODE_ENV === 'development' && 'getCenterFlatHeaders',
|
|
2818
|
-
debug: () => {
|
|
2819
|
-
var _instance$options$deb11;
|
|
2820
|
-
|
|
2821
|
-
return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
|
|
2822
|
-
}
|
|
2823
|
-
}),
|
|
2824
|
-
getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
|
|
2825
|
-
return left.map(headerGroup => {
|
|
2826
|
-
return headerGroup.headers;
|
|
2827
|
-
}).flat();
|
|
2828
|
-
}, {
|
|
2829
|
-
key: process.env.NODE_ENV === 'development' && 'getRightFlatHeaders',
|
|
2830
|
-
debug: () => {
|
|
2831
|
-
var _instance$options$deb12;
|
|
2832
|
-
|
|
2833
|
-
return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
|
|
2834
|
-
}
|
|
2835
|
-
}),
|
|
2836
|
-
// Leaf Headers
|
|
2837
|
-
getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
|
|
2838
|
-
return flatHeaders.filter(header => {
|
|
2839
|
-
var _header$subHeaders;
|
|
2840
|
-
|
|
2841
|
-
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
|
2842
|
-
});
|
|
2843
|
-
}, {
|
|
2844
|
-
key: process.env.NODE_ENV === 'development' && 'getCenterLeafHeaders',
|
|
2845
|
-
debug: () => {
|
|
2846
|
-
var _instance$options$deb13;
|
|
2847
|
-
|
|
2848
|
-
return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
|
|
2849
|
-
}
|
|
2850
|
-
}),
|
|
2851
|
-
getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
|
|
2852
|
-
return flatHeaders.filter(header => {
|
|
2853
|
-
var _header$subHeaders2;
|
|
2854
|
-
|
|
2855
|
-
return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
|
|
2856
|
-
});
|
|
2857
|
-
}, {
|
|
2858
|
-
key: process.env.NODE_ENV === 'development' && 'getLeftLeafHeaders',
|
|
2859
|
-
debug: () => {
|
|
2860
|
-
var _instance$options$deb14;
|
|
2861
|
-
|
|
2862
|
-
return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
|
|
2863
|
-
}
|
|
2864
|
-
}),
|
|
2865
|
-
getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
|
|
2866
|
-
return flatHeaders.filter(header => {
|
|
2867
|
-
var _header$subHeaders3;
|
|
2868
|
-
|
|
2869
|
-
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
|
2870
|
-
});
|
|
2871
|
-
}, {
|
|
2872
|
-
key: process.env.NODE_ENV === 'development' && 'getRightLeafHeaders',
|
|
2873
|
-
debug: () => {
|
|
2874
|
-
var _instance$options$deb15;
|
|
2712
|
+
var _instance$options$deb;
|
|
2875
2713
|
|
|
2876
|
-
return (_instance$options$
|
|
2714
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
|
|
2877
2715
|
}
|
|
2878
2716
|
}),
|
|
2879
|
-
|
|
2880
|
-
|
|
2717
|
+
getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
|
|
2718
|
+
key: process.env.NODE_ENV === 'development' && 'row.getVisibleCells',
|
|
2719
|
+
debug: () => {
|
|
2720
|
+
var _instance$options$deb2;
|
|
2881
2721
|
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2722
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
|
|
2723
|
+
}
|
|
2724
|
+
})
|
|
2725
|
+
};
|
|
2726
|
+
},
|
|
2727
|
+
createInstance: instance => {
|
|
2728
|
+
const makeVisibleColumnsMethod = (key, getColumns) => {
|
|
2729
|
+
return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
|
|
2730
|
+
return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
|
|
2885
2731
|
}, {
|
|
2886
|
-
key
|
|
2732
|
+
key,
|
|
2887
2733
|
debug: () => {
|
|
2888
|
-
var _instance$options$
|
|
2734
|
+
var _instance$options$deb3;
|
|
2889
2735
|
|
|
2890
|
-
return (_instance$options$
|
|
2736
|
+
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
2891
2737
|
}
|
|
2892
|
-
})
|
|
2893
|
-
|
|
2894
|
-
const header = [...instance.getFlatHeaders(), ...instance.getCenterFlatHeaders(), ...instance.getLeftFlatHeaders(), ...instance.getRightFlatHeaders()].find(d => d.id === id);
|
|
2738
|
+
});
|
|
2739
|
+
};
|
|
2895
2740
|
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2741
|
+
return {
|
|
2742
|
+
getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
|
|
2743
|
+
getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
|
|
2744
|
+
getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
|
|
2745
|
+
getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
|
|
2746
|
+
getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
|
|
2747
|
+
setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
|
|
2748
|
+
resetColumnVisibility: defaultState => {
|
|
2749
|
+
var _instance$initialStat;
|
|
2900
2750
|
|
|
2901
|
-
|
|
2902
|
-
|
|
2751
|
+
instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
|
|
2752
|
+
},
|
|
2753
|
+
toggleAllColumnsVisible: value => {
|
|
2754
|
+
var _value;
|
|
2755
|
+
|
|
2756
|
+
value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
|
|
2757
|
+
instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
|
|
2758
|
+
[column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
|
|
2759
|
+
}), {}));
|
|
2760
|
+
},
|
|
2761
|
+
getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
|
|
2762
|
+
getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
|
|
2763
|
+
getToggleAllColumnsVisibilityHandler: () => {
|
|
2764
|
+
return e => {
|
|
2765
|
+
var _target;
|
|
2903
2766
|
|
|
2904
|
-
|
|
2767
|
+
instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
|
|
2768
|
+
};
|
|
2905
2769
|
}
|
|
2906
2770
|
};
|
|
2907
2771
|
}
|
|
2908
2772
|
};
|
|
2909
|
-
function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
|
|
2910
|
-
var _headerGroups$0$heade, _headerGroups$;
|
|
2911
|
-
|
|
2912
|
-
// Find the max depth of the columns:
|
|
2913
|
-
// build the leaf column row
|
|
2914
|
-
// build each buffer row going up
|
|
2915
|
-
// placeholder for non-existent level
|
|
2916
|
-
// real column for existing level
|
|
2917
|
-
let maxDepth = 0;
|
|
2918
|
-
|
|
2919
|
-
const findMaxDepth = function (columns, depth) {
|
|
2920
|
-
if (depth === void 0) {
|
|
2921
|
-
depth = 1;
|
|
2922
|
-
}
|
|
2923
|
-
|
|
2924
|
-
maxDepth = Math.max(maxDepth, depth);
|
|
2925
|
-
columns.filter(column => column.getIsVisible()).forEach(column => {
|
|
2926
|
-
var _column$columns;
|
|
2927
|
-
|
|
2928
|
-
if ((_column$columns = column.columns) != null && _column$columns.length) {
|
|
2929
|
-
findMaxDepth(column.columns, depth + 1);
|
|
2930
|
-
}
|
|
2931
|
-
}, 0);
|
|
2932
|
-
};
|
|
2933
|
-
|
|
2934
|
-
findMaxDepth(allColumns);
|
|
2935
|
-
let headerGroups = [];
|
|
2936
|
-
|
|
2937
|
-
const createHeaderGroup = (headersToGroup, depth) => {
|
|
2938
|
-
// The header group we are creating
|
|
2939
|
-
const headerGroup = {
|
|
2940
|
-
depth,
|
|
2941
|
-
id: [headerFamily, "" + depth].filter(Boolean).join('_'),
|
|
2942
|
-
headers: []
|
|
2943
|
-
}; // The parent columns we're going to scan next
|
|
2944
|
-
|
|
2945
|
-
const pendingParentHeaders = []; // Scan each column for parents
|
|
2946
|
-
|
|
2947
|
-
headersToGroup.forEach(headerToGroup => {
|
|
2948
|
-
// What is the latest (last) parent column?
|
|
2949
|
-
const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
|
|
2950
|
-
const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
|
|
2951
|
-
let column;
|
|
2952
|
-
let isPlaceholder = false;
|
|
2953
|
-
|
|
2954
|
-
if (isLeafHeader && headerToGroup.column.parent) {
|
|
2955
|
-
// The parent header is new
|
|
2956
|
-
column = headerToGroup.column.parent;
|
|
2957
|
-
} else {
|
|
2958
|
-
// The parent header is repeated
|
|
2959
|
-
column = headerToGroup.column;
|
|
2960
|
-
isPlaceholder = true;
|
|
2961
|
-
}
|
|
2962
|
-
|
|
2963
|
-
if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
|
|
2964
|
-
// This column is repeated. Add it as a sub header to the next batch
|
|
2965
|
-
latestPendingParentHeader.subHeaders.push(headerToGroup);
|
|
2966
|
-
} else {
|
|
2967
|
-
// This is a new header. Let's create it
|
|
2968
|
-
const header = instance.createHeader(column, {
|
|
2969
|
-
id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
|
|
2970
|
-
isPlaceholder,
|
|
2971
|
-
placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
|
|
2972
|
-
depth,
|
|
2973
|
-
index: pendingParentHeaders.length
|
|
2974
|
-
}); // Add the headerToGroup as a subHeader of the new header
|
|
2975
|
-
|
|
2976
|
-
header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
|
|
2977
|
-
// in the next batch
|
|
2978
2773
|
|
|
2979
|
-
|
|
2980
|
-
}
|
|
2981
|
-
|
|
2982
|
-
headerGroup.headers.push(headerToGroup);
|
|
2983
|
-
headerToGroup.headerGroup = headerGroup;
|
|
2984
|
-
});
|
|
2985
|
-
headerGroups.push(headerGroup);
|
|
2986
|
-
|
|
2987
|
-
if (depth > 0) {
|
|
2988
|
-
createHeaderGroup(pendingParentHeaders, depth - 1);
|
|
2989
|
-
}
|
|
2990
|
-
};
|
|
2991
|
-
|
|
2992
|
-
const bottomHeaders = columnsToGroup.map((column, index) => instance.createHeader(column, {
|
|
2993
|
-
depth: maxDepth,
|
|
2994
|
-
index
|
|
2995
|
-
}));
|
|
2996
|
-
createHeaderGroup(bottomHeaders, maxDepth - 1);
|
|
2997
|
-
headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
|
|
2998
|
-
// return !headerGroup.headers.every(header => header.isPlaceholder)
|
|
2999
|
-
// })
|
|
3000
|
-
|
|
3001
|
-
const recurseHeadersForSpans = headers => {
|
|
3002
|
-
const filteredHeaders = headers.filter(header => header.column.getIsVisible());
|
|
3003
|
-
return filteredHeaders.map(header => {
|
|
3004
|
-
let colSpan = 0;
|
|
3005
|
-
let rowSpan = 0;
|
|
3006
|
-
let childRowSpans = [0];
|
|
3007
|
-
|
|
3008
|
-
if (header.subHeaders && header.subHeaders.length) {
|
|
3009
|
-
childRowSpans = [];
|
|
3010
|
-
recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
|
|
3011
|
-
let {
|
|
3012
|
-
colSpan: childColSpan,
|
|
3013
|
-
rowSpan: childRowSpan
|
|
3014
|
-
} = _ref;
|
|
3015
|
-
colSpan += childColSpan;
|
|
3016
|
-
childRowSpans.push(childRowSpan);
|
|
3017
|
-
});
|
|
3018
|
-
} else {
|
|
3019
|
-
colSpan = 1;
|
|
3020
|
-
}
|
|
3021
|
-
|
|
3022
|
-
const minChildRowSpan = Math.min(...childRowSpans);
|
|
3023
|
-
rowSpan = rowSpan + minChildRowSpan;
|
|
3024
|
-
header.colSpan = colSpan > 0 ? colSpan : undefined;
|
|
3025
|
-
header.rowSpan = rowSpan > 0 ? rowSpan : undefined;
|
|
3026
|
-
return {
|
|
3027
|
-
colSpan,
|
|
3028
|
-
rowSpan
|
|
3029
|
-
};
|
|
3030
|
-
});
|
|
3031
|
-
};
|
|
3032
|
-
|
|
3033
|
-
recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
|
|
3034
|
-
return headerGroups;
|
|
3035
|
-
}
|
|
2774
|
+
const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]; //
|
|
3036
2775
|
|
|
3037
|
-
// export type Batch = {
|
|
3038
|
-
// id: number
|
|
3039
|
-
// priority: keyof CoreBatches
|
|
3040
|
-
// tasks: (() => void)[]
|
|
3041
|
-
// schedule: (cb: () => void) => void
|
|
3042
|
-
// cancel: () => void
|
|
3043
|
-
// }
|
|
3044
|
-
// type CoreBatches = {
|
|
3045
|
-
// data: Batch[]
|
|
3046
|
-
// facets: Batch[]
|
|
3047
|
-
// }
|
|
3048
2776
|
function createTableInstance(options) {
|
|
3049
2777
|
var _options$initialState;
|
|
3050
2778
|
|
|
@@ -3053,7 +2781,7 @@ function createTableInstance(options) {
|
|
|
3053
2781
|
}
|
|
3054
2782
|
|
|
3055
2783
|
let instance = {
|
|
3056
|
-
_features:
|
|
2784
|
+
_features: features
|
|
3057
2785
|
};
|
|
3058
2786
|
|
|
3059
2787
|
const defaultOptions = instance._features.reduce((obj, feature) => {
|
|
@@ -3070,8 +2798,7 @@ function createTableInstance(options) {
|
|
|
3070
2798
|
};
|
|
3071
2799
|
};
|
|
3072
2800
|
|
|
3073
|
-
const coreInitialState = {
|
|
3074
|
-
};
|
|
2801
|
+
const coreInitialState = {};
|
|
3075
2802
|
let initialState = { ...coreInitialState,
|
|
3076
2803
|
...((_options$initialState = options.initialState) != null ? _options$initialState : {})
|
|
3077
2804
|
};
|
|
@@ -3084,16 +2811,8 @@ function createTableInstance(options) {
|
|
|
3084
2811
|
|
|
3085
2812
|
const queued = [];
|
|
3086
2813
|
let queuedTimeout = false;
|
|
3087
|
-
const
|
|
3088
|
-
|
|
3089
|
-
// startWork()
|
|
3090
|
-
// },
|
|
3091
|
-
// willUpdate: () => {
|
|
3092
|
-
// startWork()
|
|
3093
|
-
// },
|
|
3094
|
-
// destroy: () => {
|
|
3095
|
-
// stopWork()
|
|
3096
|
-
// },
|
|
2814
|
+
const coreInstance = {
|
|
2815
|
+
_features: features,
|
|
3097
2816
|
options: { ...defaultOptions,
|
|
3098
2817
|
...options
|
|
3099
2818
|
},
|
|
@@ -3139,29 +2858,136 @@ function createTableInstance(options) {
|
|
|
3139
2858
|
},
|
|
3140
2859
|
setState: updater => {
|
|
3141
2860
|
instance.options.onStateChange == null ? void 0 : instance.options.onStateChange(updater);
|
|
3142
|
-
}
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
//
|
|
3156
|
-
//
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
2861
|
+
},
|
|
2862
|
+
_getRowId: (row, index, parent) => {
|
|
2863
|
+
var _instance$options$get;
|
|
2864
|
+
|
|
2865
|
+
return (_instance$options$get = instance.options.getRowId == null ? void 0 : instance.options.getRowId(row, index, parent)) != null ? _instance$options$get : "" + (parent ? [parent.id, index].join('.') : index);
|
|
2866
|
+
},
|
|
2867
|
+
getCoreRowModel: () => {
|
|
2868
|
+
if (!instance._getCoreRowModel) {
|
|
2869
|
+
instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2872
|
+
return instance._getCoreRowModel();
|
|
2873
|
+
},
|
|
2874
|
+
// The final calls start at the bottom of the model,
|
|
2875
|
+
// expanded rows, which then work their way up
|
|
2876
|
+
getRowModel: () => {
|
|
2877
|
+
return instance.getPaginationRowModel();
|
|
2878
|
+
},
|
|
2879
|
+
getRow: id => {
|
|
2880
|
+
const row = instance.getRowModel().rowsById[id];
|
|
2881
|
+
|
|
2882
|
+
if (!row) {
|
|
2883
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2884
|
+
throw new Error("getRow expected an ID, but got " + id);
|
|
2885
|
+
}
|
|
2886
|
+
|
|
2887
|
+
throw new Error();
|
|
2888
|
+
}
|
|
2889
|
+
|
|
2890
|
+
return row;
|
|
2891
|
+
},
|
|
2892
|
+
_getDefaultColumnDef: memo(() => [instance.options.defaultColumn], defaultColumn => {
|
|
2893
|
+
var _defaultColumn;
|
|
2894
|
+
|
|
2895
|
+
defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
|
|
2896
|
+
return {
|
|
2897
|
+
header: props => props.header.column.id,
|
|
2898
|
+
footer: props => props.header.column.id,
|
|
2899
|
+
cell: props => {
|
|
2900
|
+
var _props$getValue$toStr, _props$getValue$toStr2, _props$getValue;
|
|
2901
|
+
|
|
2902
|
+
return (_props$getValue$toStr = (_props$getValue$toStr2 = (_props$getValue = props.getValue()).toString) == null ? void 0 : _props$getValue$toStr2.call(_props$getValue)) != null ? _props$getValue$toStr : null;
|
|
2903
|
+
},
|
|
2904
|
+
...instance._features.reduce((obj, feature) => {
|
|
2905
|
+
return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
|
|
2906
|
+
}, {}),
|
|
2907
|
+
...defaultColumn
|
|
2908
|
+
};
|
|
2909
|
+
}, {
|
|
2910
|
+
debug: () => {
|
|
2911
|
+
var _instance$options$deb;
|
|
2912
|
+
|
|
2913
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
|
|
2914
|
+
},
|
|
2915
|
+
key: process.env.NODE_ENV === 'development' && 'getDefaultColumnDef'
|
|
2916
|
+
}),
|
|
2917
|
+
_getColumnDefs: () => instance.options.columns,
|
|
2918
|
+
getAllColumns: memo(() => [instance._getColumnDefs()], columnDefs => {
|
|
2919
|
+
const recurseColumns = function (columnDefs, parent, depth) {
|
|
2920
|
+
if (depth === void 0) {
|
|
2921
|
+
depth = 0;
|
|
2922
|
+
}
|
|
2923
|
+
|
|
2924
|
+
return columnDefs.map(columnDef => {
|
|
2925
|
+
const column = createColumn(instance, columnDef, depth, parent);
|
|
2926
|
+
column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
|
|
2927
|
+
return column;
|
|
2928
|
+
});
|
|
2929
|
+
};
|
|
2930
|
+
|
|
2931
|
+
return recurseColumns(columnDefs);
|
|
2932
|
+
}, {
|
|
2933
|
+
key: process.env.NODE_ENV === 'development' && 'getAllColumns',
|
|
2934
|
+
debug: () => {
|
|
2935
|
+
var _instance$options$deb2;
|
|
2936
|
+
|
|
2937
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
|
|
2938
|
+
}
|
|
2939
|
+
}),
|
|
2940
|
+
getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
|
|
2941
|
+
return allColumns.flatMap(column => {
|
|
2942
|
+
return column.getFlatColumns();
|
|
2943
|
+
});
|
|
2944
|
+
}, {
|
|
2945
|
+
key: process.env.NODE_ENV === 'development' && 'getAllFlatColumns',
|
|
2946
|
+
debug: () => {
|
|
2947
|
+
var _instance$options$deb3;
|
|
2948
|
+
|
|
2949
|
+
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
2950
|
+
}
|
|
2951
|
+
}),
|
|
2952
|
+
_getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
|
|
2953
|
+
return flatColumns.reduce((acc, column) => {
|
|
2954
|
+
acc[column.id] = column;
|
|
2955
|
+
return acc;
|
|
2956
|
+
}, {});
|
|
2957
|
+
}, {
|
|
2958
|
+
key: process.env.NODE_ENV === 'development' && 'getAllFlatColumnsById',
|
|
2959
|
+
debug: () => {
|
|
2960
|
+
var _instance$options$deb4;
|
|
2961
|
+
|
|
2962
|
+
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
|
|
2963
|
+
}
|
|
2964
|
+
}),
|
|
2965
|
+
getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
|
|
2966
|
+
let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
|
|
2967
|
+
return orderColumns(leafColumns);
|
|
2968
|
+
}, {
|
|
2969
|
+
key: process.env.NODE_ENV === 'development' && 'getAllLeafColumns',
|
|
2970
|
+
debug: () => {
|
|
2971
|
+
var _instance$options$deb5;
|
|
2972
|
+
|
|
2973
|
+
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
|
|
2974
|
+
}
|
|
2975
|
+
}),
|
|
2976
|
+
getColumn: columnId => {
|
|
2977
|
+
const column = instance._getAllFlatColumnsById()[columnId];
|
|
2978
|
+
|
|
2979
|
+
if (!column) {
|
|
2980
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2981
|
+
console.warn("[Table] Column with id " + columnId + " does not exist.");
|
|
2982
|
+
}
|
|
2983
|
+
|
|
2984
|
+
throw new Error();
|
|
2985
|
+
}
|
|
3162
2986
|
|
|
2987
|
+
return column;
|
|
2988
|
+
}
|
|
3163
2989
|
};
|
|
3164
|
-
|
|
2990
|
+
Object.assign(instance, coreInstance);
|
|
3165
2991
|
|
|
3166
2992
|
instance._features.forEach(feature => {
|
|
3167
2993
|
return Object.assign(instance, feature.createInstance == null ? void 0 : feature.createInstance(instance));
|
|
@@ -3184,7 +3010,7 @@ function createTable(_, __, options) {
|
|
|
3184
3010
|
throw new Error('');
|
|
3185
3011
|
})()
|
|
3186
3012
|
},
|
|
3187
|
-
setGenerics: () => table,
|
|
3013
|
+
// setGenerics: () => table as any,
|
|
3188
3014
|
setRowType: () => table,
|
|
3189
3015
|
setTableMetaType: () => table,
|
|
3190
3016
|
setColumnMetaType: () => table,
|
|
@@ -3220,11 +3046,92 @@ function createTable(_, __, options) {
|
|
|
3220
3046
|
}
|
|
3221
3047
|
|
|
3222
3048
|
throw new Error('Invalid accessor');
|
|
3223
|
-
}
|
|
3049
|
+
},
|
|
3050
|
+
createOptions: options => options
|
|
3224
3051
|
};
|
|
3225
3052
|
return table;
|
|
3226
3053
|
}
|
|
3227
3054
|
|
|
3055
|
+
function createCell(instance, row, column, columnId) {
|
|
3056
|
+
const cell = {
|
|
3057
|
+
id: row.id + "_" + column.id,
|
|
3058
|
+
row,
|
|
3059
|
+
column,
|
|
3060
|
+
getValue: () => row.getValue(columnId),
|
|
3061
|
+
renderCell: () => column.columnDef.cell ? instance._render(column.columnDef.cell, {
|
|
3062
|
+
instance,
|
|
3063
|
+
column,
|
|
3064
|
+
row,
|
|
3065
|
+
cell: cell,
|
|
3066
|
+
getValue: cell.getValue
|
|
3067
|
+
}) : null
|
|
3068
|
+
};
|
|
3069
|
+
|
|
3070
|
+
instance._features.forEach(feature => {
|
|
3071
|
+
Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
|
|
3072
|
+
}, {});
|
|
3073
|
+
|
|
3074
|
+
return cell;
|
|
3075
|
+
}
|
|
3076
|
+
|
|
3077
|
+
const createRow = (instance, id, original, rowIndex, depth, subRows) => {
|
|
3078
|
+
let row = {
|
|
3079
|
+
id,
|
|
3080
|
+
index: rowIndex,
|
|
3081
|
+
original,
|
|
3082
|
+
depth,
|
|
3083
|
+
_valuesCache: {},
|
|
3084
|
+
getValue: columnId => {
|
|
3085
|
+
if (row._valuesCache.hasOwnProperty(columnId)) {
|
|
3086
|
+
return row._valuesCache[columnId];
|
|
3087
|
+
}
|
|
3088
|
+
|
|
3089
|
+
const column = instance.getColumn(columnId);
|
|
3090
|
+
|
|
3091
|
+
if (!column.accessorFn) {
|
|
3092
|
+
return undefined;
|
|
3093
|
+
}
|
|
3094
|
+
|
|
3095
|
+
row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
|
3096
|
+
return row._valuesCache[columnId];
|
|
3097
|
+
},
|
|
3098
|
+
subRows: subRows != null ? subRows : [],
|
|
3099
|
+
getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
|
|
3100
|
+
getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
|
|
3101
|
+
return leafColumns.map(column => {
|
|
3102
|
+
return createCell(instance, row, column, column.id);
|
|
3103
|
+
});
|
|
3104
|
+
}, {
|
|
3105
|
+
key: process.env.NODE_ENV === 'development' && 'row.getAllCells',
|
|
3106
|
+
debug: () => {
|
|
3107
|
+
var _instance$options$deb;
|
|
3108
|
+
|
|
3109
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
|
|
3110
|
+
}
|
|
3111
|
+
}),
|
|
3112
|
+
_getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
|
|
3113
|
+
return allCells.reduce((acc, cell) => {
|
|
3114
|
+
acc[cell.column.id] = cell;
|
|
3115
|
+
return acc;
|
|
3116
|
+
}, {});
|
|
3117
|
+
}, {
|
|
3118
|
+
key: process.env.NODE_ENV === 'production' && 'row.getAllCellsByColumnId',
|
|
3119
|
+
debug: () => {
|
|
3120
|
+
var _instance$options$deb2;
|
|
3121
|
+
|
|
3122
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
|
|
3123
|
+
}
|
|
3124
|
+
})
|
|
3125
|
+
};
|
|
3126
|
+
|
|
3127
|
+
for (let i = 0; i < instance._features.length; i++) {
|
|
3128
|
+
const feature = instance._features[i];
|
|
3129
|
+
Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
|
|
3130
|
+
}
|
|
3131
|
+
|
|
3132
|
+
return row;
|
|
3133
|
+
};
|
|
3134
|
+
|
|
3228
3135
|
function getCoreRowModel() {
|
|
3229
3136
|
return instance => memo(() => [instance.options.data], data => {
|
|
3230
3137
|
const rowModel = {
|
|
@@ -3252,7 +3159,7 @@ function getCoreRowModel() {
|
|
|
3252
3159
|
// }
|
|
3253
3160
|
// Make the row
|
|
3254
3161
|
|
|
3255
|
-
row =
|
|
3162
|
+
row = createRow(instance, instance._getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
|
|
3256
3163
|
|
|
3257
3164
|
rowModel.flatRows.push(row); // Also keep track of every row by its ID
|
|
3258
3165
|
|
|
@@ -3315,7 +3222,7 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
|
|
|
3315
3222
|
row = rowsToFilter[i];
|
|
3316
3223
|
|
|
3317
3224
|
if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
|
|
3318
|
-
newRow =
|
|
3225
|
+
newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3319
3226
|
newRow.columnFilters = row.columnFilters;
|
|
3320
3227
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3321
3228
|
|
|
@@ -3365,7 +3272,7 @@ function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
|
|
|
3365
3272
|
var _row$subRows2;
|
|
3366
3273
|
|
|
3367
3274
|
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
|
|
3368
|
-
newRow =
|
|
3275
|
+
newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3369
3276
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3370
3277
|
row = newRow;
|
|
3371
3278
|
}
|
|
@@ -3617,8 +3524,8 @@ function getSortedRowModel() {
|
|
|
3617
3524
|
availableSorting.forEach(sortEntry => {
|
|
3618
3525
|
const column = instance.getColumn(sortEntry.id);
|
|
3619
3526
|
columnInfoById[sortEntry.id] = {
|
|
3620
|
-
sortUndefined: column.sortUndefined,
|
|
3621
|
-
invertSorting: column.invertSorting,
|
|
3527
|
+
sortUndefined: column.columnDef.sortUndefined,
|
|
3528
|
+
invertSorting: column.columnDef.invertSorting,
|
|
3622
3529
|
sortingFn: column.getSortingFn()
|
|
3623
3530
|
};
|
|
3624
3531
|
});
|
|
@@ -3732,7 +3639,7 @@ function getGroupedRowModel() {
|
|
|
3732
3639
|
const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
|
|
3733
3640
|
|
|
3734
3641
|
const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
|
|
3735
|
-
const row =
|
|
3642
|
+
const row = createRow(instance, id, undefined, index, depth);
|
|
3736
3643
|
Object.assign(row, {
|
|
3737
3644
|
groupingColumnId: columnId,
|
|
3738
3645
|
groupingValue,
|
|
@@ -3741,38 +3648,30 @@ function getGroupedRowModel() {
|
|
|
3741
3648
|
getValue: columnId => {
|
|
3742
3649
|
// Don't aggregate columns that are in the grouping
|
|
3743
3650
|
if (existingGrouping.includes(columnId)) {
|
|
3744
|
-
if (row.
|
|
3745
|
-
return row.
|
|
3651
|
+
if (row._valuesCache.hasOwnProperty(columnId)) {
|
|
3652
|
+
return row._valuesCache[columnId];
|
|
3746
3653
|
}
|
|
3747
3654
|
|
|
3748
3655
|
if (groupedRows[0]) {
|
|
3749
3656
|
var _groupedRows$0$getVal;
|
|
3750
3657
|
|
|
3751
|
-
row.
|
|
3658
|
+
row._valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
|
|
3752
3659
|
}
|
|
3753
3660
|
|
|
3754
|
-
return row.
|
|
3661
|
+
return row._valuesCache[columnId];
|
|
3755
3662
|
}
|
|
3756
3663
|
|
|
3757
|
-
if (row.
|
|
3758
|
-
return row.
|
|
3664
|
+
if (row._groupingValuesCache.hasOwnProperty(columnId)) {
|
|
3665
|
+
return row._groupingValuesCache[columnId];
|
|
3759
3666
|
} // Aggregate the values
|
|
3760
3667
|
|
|
3761
3668
|
|
|
3762
3669
|
const column = instance.getColumn(columnId);
|
|
3763
|
-
const aggregateFn = column.
|
|
3670
|
+
const aggregateFn = column.getAggregationFn();
|
|
3764
3671
|
|
|
3765
3672
|
if (aggregateFn) {
|
|
3766
|
-
row.
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
if (!depth && column.aggregateValue) {
|
|
3770
|
-
columnValue = column.aggregateValue(columnValue);
|
|
3771
|
-
}
|
|
3772
|
-
|
|
3773
|
-
return columnValue;
|
|
3774
|
-
}), () => groupedRows.map(row => row.getValue(columnId)));
|
|
3775
|
-
return row.groupingValuesCache[columnId];
|
|
3673
|
+
row._groupingValuesCache[columnId] = aggregateFn(columnId, leafRows, groupedRows);
|
|
3674
|
+
return row._groupingValuesCache[columnId];
|
|
3776
3675
|
} else if (column.aggregationFn) {
|
|
3777
3676
|
console.info({
|
|
3778
3677
|
column
|
|
@@ -3938,6 +3837,8 @@ exports.Sorting = Sorting;
|
|
|
3938
3837
|
exports.Visibility = Visibility;
|
|
3939
3838
|
exports.aggregationFns = aggregationFns;
|
|
3940
3839
|
exports.buildHeaderGroups = buildHeaderGroups;
|
|
3840
|
+
exports.createColumn = createColumn;
|
|
3841
|
+
exports.createRow = createRow;
|
|
3941
3842
|
exports.createTableFactory = createTableFactory;
|
|
3942
3843
|
exports.createTableInstance = createTableInstance;
|
|
3943
3844
|
exports.defaultColumnSizing = defaultColumnSizing;
|
|
@@ -3957,7 +3858,6 @@ exports.getSortedRowModel = getSortedRowModel;
|
|
|
3957
3858
|
exports.isFunction = isFunction;
|
|
3958
3859
|
exports.isRowSelected = isRowSelected;
|
|
3959
3860
|
exports.makeStateUpdater = makeStateUpdater;
|
|
3960
|
-
exports.mean = mean;
|
|
3961
3861
|
exports.memo = memo;
|
|
3962
3862
|
exports.noop = noop;
|
|
3963
3863
|
exports.orderColumns = orderColumns;
|