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