@tanstack/react-table 8.0.0-alpha.83 → 8.0.0-alpha.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/react-table/src/index.js +2 -1
- package/build/cjs/react-table/src/index.js.map +1 -1
- package/build/cjs/table-core/build/esm/index.js +719 -838
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +718 -838
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +17 -17
- package/build/umd/index.development.js +721 -836
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
|
@@ -99,337 +99,459 @@ function memo(getDeps, fn, opts) {
|
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
function createColumn(instance, columnDef, depth, parent) {
|
|
103
|
+
var _ref, _columnDef$id;
|
|
104
|
+
|
|
105
|
+
const defaultColumn = instance._getDefaultColumnDef();
|
|
106
|
+
|
|
107
|
+
columnDef = { ...defaultColumn,
|
|
108
|
+
...columnDef
|
|
109
|
+
};
|
|
110
|
+
let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
|
|
111
|
+
let accessorFn;
|
|
112
|
+
|
|
113
|
+
if (columnDef.accessorFn) {
|
|
114
|
+
accessorFn = columnDef.accessorFn;
|
|
115
|
+
} else if (columnDef.accessorKey) {
|
|
116
|
+
accessorFn = originalRow => originalRow[columnDef.accessorKey];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (!id) {
|
|
120
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
121
|
+
throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
throw new Error();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let column = { ...columnDef,
|
|
128
|
+
id: "" + id,
|
|
129
|
+
accessorFn,
|
|
130
|
+
parent: parent,
|
|
131
|
+
depth,
|
|
132
|
+
columnDef,
|
|
133
|
+
columnDefType: columnDef.columnDefType,
|
|
134
|
+
columns: [],
|
|
135
|
+
getFlatColumns: memo(() => [true], () => {
|
|
136
|
+
var _column$columns;
|
|
137
|
+
|
|
138
|
+
return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
|
|
139
|
+
}, {
|
|
140
|
+
key: process.env.NODE_ENV === 'production' && 'column.getFlatColumns',
|
|
141
|
+
debug: () => {
|
|
142
|
+
var _instance$options$deb;
|
|
143
|
+
|
|
144
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
|
|
145
|
+
}
|
|
146
|
+
}),
|
|
147
|
+
getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
|
|
148
|
+
var _column$columns2;
|
|
149
|
+
|
|
150
|
+
if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
|
|
151
|
+
let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
|
|
152
|
+
return orderColumns(leafColumns);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return [column];
|
|
156
|
+
}, {
|
|
157
|
+
key: process.env.NODE_ENV === 'production' && 'column.getLeafColumns',
|
|
158
|
+
debug: () => {
|
|
159
|
+
var _instance$options$deb2;
|
|
160
|
+
|
|
161
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
|
|
162
|
+
}
|
|
163
|
+
})
|
|
164
|
+
};
|
|
165
|
+
column = instance._features.reduce((obj, feature) => {
|
|
166
|
+
return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
|
|
167
|
+
}, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
168
|
+
|
|
169
|
+
return column;
|
|
170
|
+
}
|
|
171
|
+
|
|
102
172
|
//
|
|
103
|
-
|
|
173
|
+
function createHeader(instance, column, options) {
|
|
174
|
+
var _options$id;
|
|
175
|
+
|
|
176
|
+
const id = (_options$id = options.id) != null ? _options$id : column.id;
|
|
177
|
+
let header = {
|
|
178
|
+
id,
|
|
179
|
+
column,
|
|
180
|
+
index: options.index,
|
|
181
|
+
isPlaceholder: !!options.isPlaceholder,
|
|
182
|
+
placeholderId: options.placeholderId,
|
|
183
|
+
depth: options.depth,
|
|
184
|
+
subHeaders: [],
|
|
185
|
+
colSpan: 0,
|
|
186
|
+
rowSpan: 0,
|
|
187
|
+
headerGroup: null,
|
|
188
|
+
getLeafHeaders: () => {
|
|
189
|
+
const leafHeaders = [];
|
|
190
|
+
|
|
191
|
+
const recurseHeader = h => {
|
|
192
|
+
if (h.subHeaders && h.subHeaders.length) {
|
|
193
|
+
h.subHeaders.map(recurseHeader);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
leafHeaders.push(h);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
recurseHeader(header);
|
|
200
|
+
return leafHeaders;
|
|
201
|
+
},
|
|
202
|
+
renderHeader: () => column.columnDef.header ? instance._render(column.columnDef.header, {
|
|
203
|
+
instance,
|
|
204
|
+
header: header,
|
|
205
|
+
column
|
|
206
|
+
}) : null,
|
|
207
|
+
renderFooter: () => column.columnDef.footer ? instance._render(column.columnDef.footer, {
|
|
208
|
+
instance,
|
|
209
|
+
header: header,
|
|
210
|
+
column
|
|
211
|
+
}) : null
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
instance._features.forEach(feature => {
|
|
215
|
+
Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
return header;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const Headers = {
|
|
104
222
|
createInstance: instance => {
|
|
105
223
|
return {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return (_props$getValue$toStr = (_props$getValue$toStr2 = (_props$getValue = props.getValue()).toString) == null ? void 0 : _props$getValue$toStr2.call(_props$getValue)) != null ? _props$getValue$toStr : null;
|
|
117
|
-
},
|
|
118
|
-
...instance._features.reduce((obj, feature) => {
|
|
119
|
-
return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
|
|
120
|
-
}, {}),
|
|
121
|
-
...defaultColumn
|
|
122
|
-
};
|
|
224
|
+
// Header Groups
|
|
225
|
+
getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
226
|
+
var _left$map$filter, _right$map$filter;
|
|
227
|
+
|
|
228
|
+
const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
|
|
229
|
+
const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
|
|
230
|
+
const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
231
|
+
const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
|
|
232
|
+
return headerGroups;
|
|
123
233
|
}, {
|
|
234
|
+
key: process.env.NODE_ENV === 'development' && 'getHeaderGroups',
|
|
124
235
|
debug: () => {
|
|
125
236
|
var _instance$options$deb;
|
|
126
237
|
|
|
127
|
-
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.
|
|
128
|
-
}
|
|
129
|
-
key: process.env.NODE_ENV === 'development' && 'getDefaultColumnDef'
|
|
238
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
|
|
239
|
+
}
|
|
130
240
|
}),
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
};
|
|
139
|
-
let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
|
|
140
|
-
let accessorFn;
|
|
241
|
+
getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
242
|
+
leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
243
|
+
return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
|
|
244
|
+
}, {
|
|
245
|
+
key: process.env.NODE_ENV === 'development' && 'getCenterHeaderGroups',
|
|
246
|
+
debug: () => {
|
|
247
|
+
var _instance$options$deb2;
|
|
141
248
|
|
|
142
|
-
|
|
143
|
-
accessorFn = columnDef.accessorFn;
|
|
144
|
-
} else if (columnDef.accessorKey) {
|
|
145
|
-
accessorFn = originalRow => originalRow[columnDef.accessorKey];
|
|
249
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
|
|
146
250
|
}
|
|
251
|
+
}),
|
|
252
|
+
getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
253
|
+
var _left$map$filter2;
|
|
147
254
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
255
|
+
const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
|
|
256
|
+
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
|
|
257
|
+
}, {
|
|
258
|
+
key: process.env.NODE_ENV === 'development' && 'getLeftHeaderGroups',
|
|
259
|
+
debug: () => {
|
|
260
|
+
var _instance$options$deb3;
|
|
152
261
|
|
|
153
|
-
|
|
262
|
+
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
|
|
154
263
|
}
|
|
264
|
+
}),
|
|
265
|
+
getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
266
|
+
var _right$map$filter2;
|
|
155
267
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
accessorFn,
|
|
159
|
-
parent: parent,
|
|
160
|
-
depth,
|
|
161
|
-
columnDef,
|
|
162
|
-
columnDefType: columnDef.columnDefType,
|
|
163
|
-
columns: [],
|
|
164
|
-
getFlatColumns: memo(() => [true], () => {
|
|
165
|
-
var _column$columns;
|
|
166
|
-
|
|
167
|
-
return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
|
|
168
|
-
}, {
|
|
169
|
-
key: process.env.NODE_ENV === 'production' && 'column.getFlatColumns',
|
|
170
|
-
debug: () => {
|
|
171
|
-
var _instance$options$deb2;
|
|
172
|
-
|
|
173
|
-
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
|
|
174
|
-
}
|
|
175
|
-
}),
|
|
176
|
-
getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
|
|
177
|
-
var _column$columns2;
|
|
178
|
-
|
|
179
|
-
if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
|
|
180
|
-
let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
|
|
181
|
-
return orderColumns(leafColumns);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return [column];
|
|
185
|
-
}, {
|
|
186
|
-
key: process.env.NODE_ENV === 'production' && 'column.getLeafColumns',
|
|
187
|
-
debug: () => {
|
|
188
|
-
var _instance$options$deb3;
|
|
189
|
-
|
|
190
|
-
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
191
|
-
}
|
|
192
|
-
})
|
|
193
|
-
};
|
|
194
|
-
column = instance._features.reduce((obj, feature) => {
|
|
195
|
-
return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
|
|
196
|
-
}, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
197
|
-
|
|
198
|
-
return column;
|
|
199
|
-
},
|
|
200
|
-
getAllColumns: memo(() => [instance.getColumnDefs()], columnDefs => {
|
|
201
|
-
const recurseColumns = function (columnDefs, parent, depth) {
|
|
202
|
-
if (depth === void 0) {
|
|
203
|
-
depth = 0;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return columnDefs.map(columnDef => {
|
|
207
|
-
const column = instance.createColumn(columnDef, depth, parent);
|
|
208
|
-
column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
|
|
209
|
-
return column;
|
|
210
|
-
});
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
return recurseColumns(columnDefs);
|
|
268
|
+
const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
|
|
269
|
+
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
|
|
214
270
|
}, {
|
|
215
|
-
key: process.env.NODE_ENV === 'development' && '
|
|
271
|
+
key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
|
|
216
272
|
debug: () => {
|
|
217
273
|
var _instance$options$deb4;
|
|
218
274
|
|
|
219
|
-
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.
|
|
275
|
+
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
|
|
220
276
|
}
|
|
221
277
|
}),
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
});
|
|
278
|
+
// Footer Groups
|
|
279
|
+
getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
280
|
+
return [...headerGroups].reverse();
|
|
226
281
|
}, {
|
|
227
|
-
key: process.env.NODE_ENV === 'development' && '
|
|
282
|
+
key: process.env.NODE_ENV === 'development' && 'getFooterGroups',
|
|
228
283
|
debug: () => {
|
|
229
284
|
var _instance$options$deb5;
|
|
230
285
|
|
|
231
|
-
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.
|
|
286
|
+
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
|
|
232
287
|
}
|
|
233
288
|
}),
|
|
234
|
-
|
|
235
|
-
return
|
|
236
|
-
acc[column.id] = column;
|
|
237
|
-
return acc;
|
|
238
|
-
}, {});
|
|
289
|
+
getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
|
|
290
|
+
return [...headerGroups].reverse();
|
|
239
291
|
}, {
|
|
240
|
-
key: process.env.NODE_ENV === 'development' && '
|
|
292
|
+
key: process.env.NODE_ENV === 'development' && 'getLeftFooterGroups',
|
|
241
293
|
debug: () => {
|
|
242
294
|
var _instance$options$deb6;
|
|
243
295
|
|
|
244
|
-
return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.
|
|
296
|
+
return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
|
|
245
297
|
}
|
|
246
298
|
}),
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
return orderColumns(leafColumns);
|
|
299
|
+
getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
|
|
300
|
+
return [...headerGroups].reverse();
|
|
250
301
|
}, {
|
|
251
|
-
key: process.env.NODE_ENV === 'development' && '
|
|
302
|
+
key: process.env.NODE_ENV === 'development' && 'getCenterFooterGroups',
|
|
252
303
|
debug: () => {
|
|
253
304
|
var _instance$options$deb7;
|
|
254
305
|
|
|
255
|
-
return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.
|
|
306
|
+
return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
|
|
256
307
|
}
|
|
257
308
|
}),
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
}
|
|
309
|
+
getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
|
|
310
|
+
return [...headerGroups].reverse();
|
|
311
|
+
}, {
|
|
312
|
+
key: process.env.NODE_ENV === 'development' && 'getRightFooterGroups',
|
|
313
|
+
debug: () => {
|
|
314
|
+
var _instance$options$deb8;
|
|
265
315
|
|
|
266
|
-
|
|
316
|
+
return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
|
|
267
317
|
}
|
|
318
|
+
}),
|
|
319
|
+
// Flat Headers
|
|
320
|
+
getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
321
|
+
return headerGroups.map(headerGroup => {
|
|
322
|
+
return headerGroup.headers;
|
|
323
|
+
}).flat();
|
|
324
|
+
}, {
|
|
325
|
+
key: process.env.NODE_ENV === 'development' && 'getFlatHeaders',
|
|
326
|
+
debug: () => {
|
|
327
|
+
var _instance$options$deb9;
|
|
268
328
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
// ): CellsRow<TGenerics> => {
|
|
281
|
-
// return {}
|
|
282
|
-
// },
|
|
283
|
-
createInstance: instance => {
|
|
284
|
-
return {
|
|
285
|
-
getRowId: (row, index, parent) => {
|
|
286
|
-
var _instance$options$get;
|
|
287
|
-
|
|
288
|
-
return (_instance$options$get = instance.options.getRowId == null ? void 0 : instance.options.getRowId(row, index, parent)) != null ? _instance$options$get : "" + (parent ? [parent.id, index].join('.') : index);
|
|
289
|
-
},
|
|
290
|
-
createRow: (id, original, rowIndex, depth, subRows) => {
|
|
291
|
-
let row = {
|
|
292
|
-
id,
|
|
293
|
-
index: rowIndex,
|
|
294
|
-
original,
|
|
295
|
-
depth,
|
|
296
|
-
valuesCache: {},
|
|
297
|
-
getValue: columnId => {
|
|
298
|
-
if (row.valuesCache.hasOwnProperty(columnId)) {
|
|
299
|
-
return row.valuesCache[columnId];
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
const column = instance.getColumn(columnId);
|
|
303
|
-
|
|
304
|
-
if (!column.accessorFn) {
|
|
305
|
-
return undefined;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
row.valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
|
309
|
-
return row.valuesCache[columnId];
|
|
310
|
-
},
|
|
311
|
-
subRows: subRows != null ? subRows : [],
|
|
312
|
-
getLeafRows: () => flattenBy(row.subRows, d => d.subRows)
|
|
313
|
-
};
|
|
329
|
+
return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
|
|
330
|
+
}
|
|
331
|
+
}),
|
|
332
|
+
getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
|
|
333
|
+
return left.map(headerGroup => {
|
|
334
|
+
return headerGroup.headers;
|
|
335
|
+
}).flat();
|
|
336
|
+
}, {
|
|
337
|
+
key: process.env.NODE_ENV === 'development' && 'getLeftFlatHeaders',
|
|
338
|
+
debug: () => {
|
|
339
|
+
var _instance$options$deb10;
|
|
314
340
|
|
|
315
|
-
|
|
316
|
-
const feature = instance._features[i];
|
|
317
|
-
Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
|
|
341
|
+
return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
|
|
318
342
|
}
|
|
343
|
+
}),
|
|
344
|
+
getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
|
|
345
|
+
return left.map(headerGroup => {
|
|
346
|
+
return headerGroup.headers;
|
|
347
|
+
}).flat();
|
|
348
|
+
}, {
|
|
349
|
+
key: process.env.NODE_ENV === 'development' && 'getCenterFlatHeaders',
|
|
350
|
+
debug: () => {
|
|
351
|
+
var _instance$options$deb11;
|
|
319
352
|
|
|
320
|
-
|
|
321
|
-
},
|
|
322
|
-
getCoreRowModel: () => {
|
|
323
|
-
if (!instance._getCoreRowModel) {
|
|
324
|
-
instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
|
|
353
|
+
return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
|
|
325
354
|
}
|
|
355
|
+
}),
|
|
356
|
+
getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
|
|
357
|
+
return left.map(headerGroup => {
|
|
358
|
+
return headerGroup.headers;
|
|
359
|
+
}).flat();
|
|
360
|
+
}, {
|
|
361
|
+
key: process.env.NODE_ENV === 'development' && 'getRightFlatHeaders',
|
|
362
|
+
debug: () => {
|
|
363
|
+
var _instance$options$deb12;
|
|
326
364
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
//
|
|
331
|
-
|
|
332
|
-
return
|
|
333
|
-
|
|
334
|
-
getRow: id => {
|
|
335
|
-
const row = instance.getRowModel().rowsById[id];
|
|
365
|
+
return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
|
|
366
|
+
}
|
|
367
|
+
}),
|
|
368
|
+
// Leaf Headers
|
|
369
|
+
getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
|
|
370
|
+
return flatHeaders.filter(header => {
|
|
371
|
+
var _header$subHeaders;
|
|
336
372
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
373
|
+
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
|
374
|
+
});
|
|
375
|
+
}, {
|
|
376
|
+
key: process.env.NODE_ENV === 'development' && 'getCenterLeafHeaders',
|
|
377
|
+
debug: () => {
|
|
378
|
+
var _instance$options$deb13;
|
|
341
379
|
|
|
342
|
-
|
|
380
|
+
return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
|
|
343
381
|
}
|
|
382
|
+
}),
|
|
383
|
+
getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
|
|
384
|
+
return flatHeaders.filter(header => {
|
|
385
|
+
var _header$subHeaders2;
|
|
344
386
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
387
|
+
return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
|
|
388
|
+
});
|
|
389
|
+
}, {
|
|
390
|
+
key: process.env.NODE_ENV === 'development' && 'getLeftLeafHeaders',
|
|
391
|
+
debug: () => {
|
|
392
|
+
var _instance$options$deb14;
|
|
350
393
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
394
|
+
return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
|
|
395
|
+
}
|
|
396
|
+
}),
|
|
397
|
+
getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
|
|
398
|
+
return flatHeaders.filter(header => {
|
|
399
|
+
var _header$subHeaders3;
|
|
400
|
+
|
|
401
|
+
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
|
358
402
|
});
|
|
359
403
|
}, {
|
|
360
|
-
key: process.env.NODE_ENV === 'development' && '
|
|
404
|
+
key: process.env.NODE_ENV === 'development' && 'getRightLeafHeaders',
|
|
361
405
|
debug: () => {
|
|
362
|
-
var _instance$options$
|
|
406
|
+
var _instance$options$deb15;
|
|
363
407
|
|
|
364
|
-
return (_instance$options$
|
|
408
|
+
return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
|
|
365
409
|
}
|
|
366
410
|
}),
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
411
|
+
getLeafHeaders: memo(() => [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()], (left, center, right) => {
|
|
412
|
+
var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
|
|
413
|
+
|
|
414
|
+
return [...((_left$0$headers = (_left$ = left[0]) == null ? void 0 : _left$.headers) != null ? _left$0$headers : []), ...((_center$0$headers = (_center$ = center[0]) == null ? void 0 : _center$.headers) != null ? _center$0$headers : []), ...((_right$0$headers = (_right$ = right[0]) == null ? void 0 : _right$.headers) != null ? _right$0$headers : [])].map(header => {
|
|
415
|
+
return header.getLeafHeaders();
|
|
416
|
+
}).flat();
|
|
372
417
|
}, {
|
|
373
|
-
key: process.env.NODE_ENV === '
|
|
418
|
+
key: process.env.NODE_ENV === 'development' && 'getLeafHeaders',
|
|
374
419
|
debug: () => {
|
|
375
|
-
var _instance$options$
|
|
420
|
+
var _instance$options$deb16;
|
|
376
421
|
|
|
377
|
-
return (_instance$options$
|
|
422
|
+
return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
|
|
378
423
|
}
|
|
379
424
|
})
|
|
380
425
|
};
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
const cell = {
|
|
386
|
-
id: row.id + "_" + column.id,
|
|
387
|
-
rowId: row.id,
|
|
388
|
-
columnId,
|
|
389
|
-
row,
|
|
390
|
-
column,
|
|
391
|
-
getValue: () => row.getValue(columnId),
|
|
392
|
-
renderCell: () => column.columnDef.cell ? instance._render(column.columnDef.cell, {
|
|
393
|
-
instance,
|
|
394
|
-
column,
|
|
395
|
-
row,
|
|
396
|
-
cell: cell,
|
|
397
|
-
getValue: cell.getValue
|
|
398
|
-
}) : null
|
|
399
|
-
};
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
|
|
429
|
+
var _headerGroups$0$heade, _headerGroups$;
|
|
400
430
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
431
|
+
// Find the max depth of the columns:
|
|
432
|
+
// build the leaf column row
|
|
433
|
+
// build each buffer row going up
|
|
434
|
+
// placeholder for non-existent level
|
|
435
|
+
// real column for existing level
|
|
436
|
+
let maxDepth = 0;
|
|
404
437
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
438
|
+
const findMaxDepth = function (columns, depth) {
|
|
439
|
+
if (depth === void 0) {
|
|
440
|
+
depth = 1;
|
|
441
|
+
}
|
|
409
442
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}
|
|
443
|
+
maxDepth = Math.max(maxDepth, depth);
|
|
444
|
+
columns.filter(column => column.getIsVisible()).forEach(column => {
|
|
445
|
+
var _column$columns;
|
|
414
446
|
|
|
415
|
-
|
|
416
|
-
|
|
447
|
+
if ((_column$columns = column.columns) != null && _column$columns.length) {
|
|
448
|
+
findMaxDepth(column.columns, depth + 1);
|
|
449
|
+
}
|
|
450
|
+
}, 0);
|
|
451
|
+
};
|
|
417
452
|
|
|
418
|
-
|
|
453
|
+
findMaxDepth(allColumns);
|
|
454
|
+
let headerGroups = [];
|
|
419
455
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
456
|
+
const createHeaderGroup = (headersToGroup, depth) => {
|
|
457
|
+
// The header group we are creating
|
|
458
|
+
const headerGroup = {
|
|
459
|
+
depth,
|
|
460
|
+
id: [headerFamily, "" + depth].filter(Boolean).join('_'),
|
|
461
|
+
headers: []
|
|
462
|
+
}; // The parent columns we're going to scan next
|
|
424
463
|
|
|
425
|
-
|
|
426
|
-
|
|
464
|
+
const pendingParentHeaders = []; // Scan each column for parents
|
|
465
|
+
|
|
466
|
+
headersToGroup.forEach(headerToGroup => {
|
|
467
|
+
// What is the latest (last) parent column?
|
|
468
|
+
const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
|
|
469
|
+
const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
|
|
470
|
+
let column;
|
|
471
|
+
let isPlaceholder = false;
|
|
427
472
|
|
|
428
|
-
|
|
473
|
+
if (isLeafHeader && headerToGroup.column.parent) {
|
|
474
|
+
// The parent header is new
|
|
475
|
+
column = headerToGroup.column.parent;
|
|
476
|
+
} else {
|
|
477
|
+
// The parent header is repeated
|
|
478
|
+
column = headerToGroup.column;
|
|
479
|
+
isPlaceholder = true;
|
|
429
480
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
481
|
+
|
|
482
|
+
if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
|
|
483
|
+
// This column is repeated. Add it as a sub header to the next batch
|
|
484
|
+
latestPendingParentHeader.subHeaders.push(headerToGroup);
|
|
485
|
+
} else {
|
|
486
|
+
// This is a new header. Let's create it
|
|
487
|
+
const header = createHeader(instance, column, {
|
|
488
|
+
id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
|
|
489
|
+
isPlaceholder,
|
|
490
|
+
placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
|
|
491
|
+
depth,
|
|
492
|
+
index: pendingParentHeaders.length
|
|
493
|
+
}); // Add the headerToGroup as a subHeader of the new header
|
|
494
|
+
|
|
495
|
+
header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
|
|
496
|
+
// in the next batch
|
|
497
|
+
|
|
498
|
+
pendingParentHeaders.push(header);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
headerGroup.headers.push(headerToGroup);
|
|
502
|
+
headerToGroup.headerGroup = headerGroup;
|
|
503
|
+
});
|
|
504
|
+
headerGroups.push(headerGroup);
|
|
505
|
+
|
|
506
|
+
if (depth > 0) {
|
|
507
|
+
createHeaderGroup(pendingParentHeaders, depth - 1);
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
const bottomHeaders = columnsToGroup.map((column, index) => createHeader(instance, column, {
|
|
512
|
+
depth: maxDepth,
|
|
513
|
+
index
|
|
514
|
+
}));
|
|
515
|
+
createHeaderGroup(bottomHeaders, maxDepth - 1);
|
|
516
|
+
headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
|
|
517
|
+
// return !headerGroup.headers.every(header => header.isPlaceholder)
|
|
518
|
+
// })
|
|
519
|
+
|
|
520
|
+
const recurseHeadersForSpans = headers => {
|
|
521
|
+
const filteredHeaders = headers.filter(header => header.column.getIsVisible());
|
|
522
|
+
return filteredHeaders.map(header => {
|
|
523
|
+
let colSpan = 0;
|
|
524
|
+
let rowSpan = 0;
|
|
525
|
+
let childRowSpans = [0];
|
|
526
|
+
|
|
527
|
+
if (header.subHeaders && header.subHeaders.length) {
|
|
528
|
+
childRowSpans = [];
|
|
529
|
+
recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
|
|
530
|
+
let {
|
|
531
|
+
colSpan: childColSpan,
|
|
532
|
+
rowSpan: childRowSpan
|
|
533
|
+
} = _ref;
|
|
534
|
+
colSpan += childColSpan;
|
|
535
|
+
childRowSpans.push(childRowSpan);
|
|
536
|
+
});
|
|
537
|
+
} else {
|
|
538
|
+
colSpan = 1;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
const minChildRowSpan = Math.min(...childRowSpans);
|
|
542
|
+
rowSpan = rowSpan + minChildRowSpan;
|
|
543
|
+
header.colSpan = colSpan;
|
|
544
|
+
header.rowSpan = rowSpan;
|
|
545
|
+
return {
|
|
546
|
+
colSpan,
|
|
547
|
+
rowSpan
|
|
548
|
+
};
|
|
549
|
+
});
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
|
|
553
|
+
return headerGroups;
|
|
554
|
+
}
|
|
433
555
|
|
|
434
556
|
//
|
|
435
557
|
const defaultColumnSizing = {
|
|
@@ -707,7 +829,6 @@ const Expanding = {
|
|
|
707
829
|
return {
|
|
708
830
|
onExpandedChange: makeStateUpdater('expanded', instance),
|
|
709
831
|
autoResetExpanded: true,
|
|
710
|
-
expandSubRows: true,
|
|
711
832
|
paginateExpandedRows: true
|
|
712
833
|
};
|
|
713
834
|
},
|
|
@@ -976,7 +1097,7 @@ const Filters = {
|
|
|
976
1097
|
getColumnCanGlobalFilter: column => {
|
|
977
1098
|
var _instance$getCoreRowM, _instance$getCoreRowM2;
|
|
978
1099
|
|
|
979
|
-
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();
|
|
980
1101
|
return typeof value === 'string';
|
|
981
1102
|
}
|
|
982
1103
|
};
|
|
@@ -1104,8 +1225,7 @@ const Filters = {
|
|
|
1104
1225
|
createRow: (row, instance) => {
|
|
1105
1226
|
return {
|
|
1106
1227
|
columnFilters: {},
|
|
1107
|
-
columnFiltersMeta: {}
|
|
1108
|
-
subRowsByFacetId: {}
|
|
1228
|
+
columnFiltersMeta: {}
|
|
1109
1229
|
};
|
|
1110
1230
|
},
|
|
1111
1231
|
createInstance: instance => {
|
|
@@ -1196,53 +1316,42 @@ function shouldAutoRemoveFilter(filterFn, value, column) {
|
|
|
1196
1316
|
return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
|
|
1197
1317
|
}
|
|
1198
1318
|
|
|
1199
|
-
const
|
|
1200
|
-
sum,
|
|
1201
|
-
min,
|
|
1202
|
-
max,
|
|
1203
|
-
extent,
|
|
1204
|
-
mean,
|
|
1205
|
-
median,
|
|
1206
|
-
unique,
|
|
1207
|
-
uniqueCount,
|
|
1208
|
-
count
|
|
1209
|
-
};
|
|
1210
|
-
|
|
1211
|
-
function sum(_getLeafValues, getChildValues) {
|
|
1319
|
+
const sum = (columnId, _leafRows, childRows) => {
|
|
1212
1320
|
// It's faster to just add the aggregations together instead of
|
|
1213
1321
|
// process leaf nodes individually
|
|
1214
|
-
return
|
|
1215
|
-
}
|
|
1322
|
+
return childRows.reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
|
|
1323
|
+
};
|
|
1216
1324
|
|
|
1217
|
-
|
|
1325
|
+
const min = (columnId, _leafRows, childRows) => {
|
|
1218
1326
|
let min;
|
|
1327
|
+
childRows.forEach(row => {
|
|
1328
|
+
const value = row.getValue(columnId);
|
|
1219
1329
|
|
|
1220
|
-
for (const value of getChildValues()) {
|
|
1221
1330
|
if (value != null && (min > value || min === undefined && value >= value)) {
|
|
1222
1331
|
min = value;
|
|
1223
1332
|
}
|
|
1224
|
-
}
|
|
1225
|
-
|
|
1333
|
+
});
|
|
1226
1334
|
return min;
|
|
1227
|
-
}
|
|
1335
|
+
};
|
|
1228
1336
|
|
|
1229
|
-
|
|
1337
|
+
const max = (columnId, _leafRows, childRows) => {
|
|
1230
1338
|
let max;
|
|
1339
|
+
childRows.forEach(row => {
|
|
1340
|
+
const value = row.getValue(columnId);
|
|
1231
1341
|
|
|
1232
|
-
for (const value of getChildValues()) {
|
|
1233
1342
|
if (value != null && (max < value || max === undefined && value >= value)) {
|
|
1234
1343
|
max = value;
|
|
1235
1344
|
}
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1345
|
+
});
|
|
1238
1346
|
return max;
|
|
1239
|
-
}
|
|
1347
|
+
};
|
|
1240
1348
|
|
|
1241
|
-
|
|
1349
|
+
const extent = (columnId, _leafRows, childRows) => {
|
|
1242
1350
|
let min;
|
|
1243
1351
|
let max;
|
|
1352
|
+
childRows.forEach(row => {
|
|
1353
|
+
const value = row.getValue(columnId);
|
|
1244
1354
|
|
|
1245
|
-
for (const value of getChildValues()) {
|
|
1246
1355
|
if (value != null) {
|
|
1247
1356
|
if (min === undefined) {
|
|
1248
1357
|
if (value >= value) min = max = value;
|
|
@@ -1251,54 +1360,65 @@ function extent(_getLeafValues, getChildValues) {
|
|
|
1251
1360
|
if (max < value) max = value;
|
|
1252
1361
|
}
|
|
1253
1362
|
}
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1363
|
+
});
|
|
1256
1364
|
return [min, max];
|
|
1257
|
-
}
|
|
1365
|
+
};
|
|
1258
1366
|
|
|
1259
|
-
|
|
1367
|
+
const mean = (columnId, leafRows) => {
|
|
1260
1368
|
let count = 0;
|
|
1261
1369
|
let sum = 0;
|
|
1370
|
+
leafRows.forEach(row => {
|
|
1371
|
+
let value = row.getValue(columnId);
|
|
1262
1372
|
|
|
1263
|
-
for (let value of getLeafValues()) {
|
|
1264
1373
|
if (value != null && (value = +value) >= value) {
|
|
1265
1374
|
++count, sum += value;
|
|
1266
1375
|
}
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1376
|
+
});
|
|
1269
1377
|
if (count) return sum / count;
|
|
1270
1378
|
return;
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
function median(getLeafValues) {
|
|
1274
|
-
const leafValues = getLeafValues();
|
|
1379
|
+
};
|
|
1275
1380
|
|
|
1276
|
-
|
|
1381
|
+
const median = (columnId, leafRows) => {
|
|
1382
|
+
if (!leafRows.length) {
|
|
1277
1383
|
return;
|
|
1278
1384
|
}
|
|
1279
1385
|
|
|
1280
1386
|
let min = 0;
|
|
1281
1387
|
let max = 0;
|
|
1282
|
-
|
|
1388
|
+
leafRows.forEach(row => {
|
|
1389
|
+
let value = row.getValue(columnId);
|
|
1390
|
+
|
|
1283
1391
|
if (typeof value === 'number') {
|
|
1284
1392
|
min = Math.min(min, value);
|
|
1285
1393
|
max = Math.max(max, value);
|
|
1286
1394
|
}
|
|
1287
1395
|
});
|
|
1288
1396
|
return (min + max) / 2;
|
|
1289
|
-
}
|
|
1397
|
+
};
|
|
1290
1398
|
|
|
1291
|
-
|
|
1292
|
-
return Array.from(new Set(
|
|
1293
|
-
}
|
|
1399
|
+
const unique = (columnId, leafRows) => {
|
|
1400
|
+
return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
|
|
1401
|
+
};
|
|
1294
1402
|
|
|
1295
|
-
|
|
1296
|
-
return new Set(
|
|
1297
|
-
}
|
|
1403
|
+
const uniqueCount = (columnId, leafRows) => {
|
|
1404
|
+
return new Set(leafRows.map(d => d.getValue(columnId))).size;
|
|
1405
|
+
};
|
|
1298
1406
|
|
|
1299
|
-
|
|
1300
|
-
return
|
|
1301
|
-
}
|
|
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
|
+
};
|
|
1302
1422
|
|
|
1303
1423
|
//
|
|
1304
1424
|
const Grouping = {
|
|
@@ -1353,7 +1473,7 @@ const Grouping = {
|
|
|
1353
1473
|
column.toggleGrouping();
|
|
1354
1474
|
};
|
|
1355
1475
|
},
|
|
1356
|
-
|
|
1476
|
+
getAutoAggregationFn: () => {
|
|
1357
1477
|
const firstRow = instance.getCoreRowModel().flatRows[0];
|
|
1358
1478
|
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
|
1359
1479
|
|
|
@@ -1367,7 +1487,7 @@ const Grouping = {
|
|
|
1367
1487
|
|
|
1368
1488
|
return aggregationFns.count;
|
|
1369
1489
|
},
|
|
1370
|
-
|
|
1490
|
+
getAggregationFn: () => {
|
|
1371
1491
|
var _ref4;
|
|
1372
1492
|
|
|
1373
1493
|
const userAggregationFns = instance.options.aggregationFns;
|
|
@@ -1376,7 +1496,7 @@ const Grouping = {
|
|
|
1376
1496
|
throw new Error();
|
|
1377
1497
|
}
|
|
1378
1498
|
|
|
1379
|
-
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];
|
|
1380
1500
|
}
|
|
1381
1501
|
};
|
|
1382
1502
|
},
|
|
@@ -1402,10 +1522,10 @@ const Grouping = {
|
|
|
1402
1522
|
}
|
|
1403
1523
|
};
|
|
1404
1524
|
},
|
|
1405
|
-
createRow:
|
|
1525
|
+
createRow: row => {
|
|
1406
1526
|
return {
|
|
1407
1527
|
getIsGrouped: () => !!row.groupingColumnId,
|
|
1408
|
-
|
|
1528
|
+
_groupingValuesCache: {}
|
|
1409
1529
|
};
|
|
1410
1530
|
},
|
|
1411
1531
|
createCell: (cell, column, row, instance) => {
|
|
@@ -1754,7 +1874,7 @@ const Pinning = {
|
|
|
1754
1874
|
return {
|
|
1755
1875
|
getCenterVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allCells, left, right) => {
|
|
1756
1876
|
const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
|
|
1757
|
-
return allCells.filter(d => !leftAndRight.includes(d.
|
|
1877
|
+
return allCells.filter(d => !leftAndRight.includes(d.column.id));
|
|
1758
1878
|
}, {
|
|
1759
1879
|
key: process.env.NODE_ENV === 'production' && 'row.getCenterVisibleCells',
|
|
1760
1880
|
debug: () => {
|
|
@@ -1764,7 +1884,7 @@ const Pinning = {
|
|
|
1764
1884
|
}
|
|
1765
1885
|
}),
|
|
1766
1886
|
getLeftVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left,,], (allCells, left) => {
|
|
1767
|
-
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,
|
|
1768
1888
|
position: 'left'
|
|
1769
1889
|
}));
|
|
1770
1890
|
return cells;
|
|
@@ -1777,7 +1897,7 @@ const Pinning = {
|
|
|
1777
1897
|
}
|
|
1778
1898
|
}),
|
|
1779
1899
|
getRightVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.right], (allCells, right) => {
|
|
1780
|
-
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,
|
|
1781
1901
|
position: 'left'
|
|
1782
1902
|
}));
|
|
1783
1903
|
return cells;
|
|
@@ -2550,11 +2670,6 @@ const Visibility = {
|
|
|
2550
2670
|
onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
|
|
2551
2671
|
};
|
|
2552
2672
|
},
|
|
2553
|
-
getDefaultColumnDef: () => {
|
|
2554
|
-
return {
|
|
2555
|
-
defaultIsVisible: true
|
|
2556
|
-
};
|
|
2557
|
-
},
|
|
2558
2673
|
createColumn: (column, instance) => {
|
|
2559
2674
|
return {
|
|
2560
2675
|
toggleVisibility: value => {
|
|
@@ -2586,477 +2701,72 @@ const Visibility = {
|
|
|
2586
2701
|
_getAllVisibleCells: memo(() => [row.getAllCells().filter(cell => cell.column.getIsVisible()).map(d => d.id).join('_')], _ => {
|
|
2587
2702
|
return row.getAllCells().filter(cell => cell.column.getIsVisible());
|
|
2588
2703
|
}, {
|
|
2589
|
-
key: process.env.NODE_ENV === 'production' && 'row._getAllVisibleCells',
|
|
2590
|
-
debug: () => {
|
|
2591
|
-
var _instance$options$deb;
|
|
2592
|
-
|
|
2593
|
-
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
|
|
2594
|
-
}
|
|
2595
|
-
}),
|
|
2596
|
-
getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
|
|
2597
|
-
key: process.env.NODE_ENV === 'development' && 'row.getVisibleCells',
|
|
2598
|
-
debug: () => {
|
|
2599
|
-
var _instance$options$deb2;
|
|
2600
|
-
|
|
2601
|
-
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
|
|
2602
|
-
}
|
|
2603
|
-
})
|
|
2604
|
-
};
|
|
2605
|
-
},
|
|
2606
|
-
createInstance: instance => {
|
|
2607
|
-
const makeVisibleColumnsMethod = (key, getColumns) => {
|
|
2608
|
-
return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
|
|
2609
|
-
return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
|
|
2610
|
-
}, {
|
|
2611
|
-
key,
|
|
2612
|
-
debug: () => {
|
|
2613
|
-
var _instance$options$deb3;
|
|
2614
|
-
|
|
2615
|
-
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
2616
|
-
}
|
|
2617
|
-
});
|
|
2618
|
-
};
|
|
2619
|
-
|
|
2620
|
-
return {
|
|
2621
|
-
getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
|
|
2622
|
-
getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
|
|
2623
|
-
getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
|
|
2624
|
-
getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
|
|
2625
|
-
getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
|
|
2626
|
-
setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
|
|
2627
|
-
resetColumnVisibility: defaultState => {
|
|
2628
|
-
var _instance$initialStat;
|
|
2629
|
-
|
|
2630
|
-
instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
|
|
2631
|
-
},
|
|
2632
|
-
toggleAllColumnsVisible: value => {
|
|
2633
|
-
var _value;
|
|
2634
|
-
|
|
2635
|
-
value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
|
|
2636
|
-
instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
|
|
2637
|
-
[column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
|
|
2638
|
-
}), {}));
|
|
2639
|
-
},
|
|
2640
|
-
getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
|
|
2641
|
-
getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
|
|
2642
|
-
getToggleAllColumnsVisibilityHandler: () => {
|
|
2643
|
-
return e => {
|
|
2644
|
-
var _target;
|
|
2645
|
-
|
|
2646
|
-
instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
|
|
2647
|
-
};
|
|
2648
|
-
}
|
|
2649
|
-
};
|
|
2650
|
-
}
|
|
2651
|
-
};
|
|
2652
|
-
|
|
2653
|
-
//
|
|
2654
|
-
const Headers = {
|
|
2655
|
-
createInstance: instance => {
|
|
2656
|
-
return {
|
|
2657
|
-
createHeader: (column, options) => {
|
|
2658
|
-
var _options$id;
|
|
2659
|
-
|
|
2660
|
-
const id = (_options$id = options.id) != null ? _options$id : column.id;
|
|
2661
|
-
let header = {
|
|
2662
|
-
id,
|
|
2663
|
-
column,
|
|
2664
|
-
index: options.index,
|
|
2665
|
-
isPlaceholder: options.isPlaceholder,
|
|
2666
|
-
placeholderId: options.placeholderId,
|
|
2667
|
-
depth: options.depth,
|
|
2668
|
-
subHeaders: [],
|
|
2669
|
-
colSpan: 0,
|
|
2670
|
-
rowSpan: 0,
|
|
2671
|
-
headerGroup: null,
|
|
2672
|
-
getLeafHeaders: () => {
|
|
2673
|
-
const leafHeaders = [];
|
|
2674
|
-
|
|
2675
|
-
const recurseHeader = h => {
|
|
2676
|
-
if (h.subHeaders && h.subHeaders.length) {
|
|
2677
|
-
h.subHeaders.map(recurseHeader);
|
|
2678
|
-
}
|
|
2679
|
-
|
|
2680
|
-
leafHeaders.push(h);
|
|
2681
|
-
};
|
|
2682
|
-
|
|
2683
|
-
recurseHeader(header);
|
|
2684
|
-
return leafHeaders;
|
|
2685
|
-
},
|
|
2686
|
-
renderHeader: () => column.columnDef.header ? instance._render(column.columnDef.header, {
|
|
2687
|
-
instance,
|
|
2688
|
-
header: header,
|
|
2689
|
-
column
|
|
2690
|
-
}) : null,
|
|
2691
|
-
renderFooter: () => column.columnDef.footer ? instance._render(column.columnDef.footer, {
|
|
2692
|
-
instance,
|
|
2693
|
-
header: header,
|
|
2694
|
-
column
|
|
2695
|
-
}) : null
|
|
2696
|
-
};
|
|
2697
|
-
|
|
2698
|
-
instance._features.forEach(feature => {
|
|
2699
|
-
Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
|
|
2700
|
-
});
|
|
2701
|
-
|
|
2702
|
-
return header;
|
|
2703
|
-
},
|
|
2704
|
-
// Header Groups
|
|
2705
|
-
getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
2706
|
-
var _left$map$filter, _right$map$filter;
|
|
2707
|
-
|
|
2708
|
-
const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
|
|
2709
|
-
const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
|
|
2710
|
-
const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
2711
|
-
const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
|
|
2712
|
-
return headerGroups;
|
|
2713
|
-
}, {
|
|
2714
|
-
key: process.env.NODE_ENV === 'development' && 'getHeaderGroups',
|
|
2715
|
-
debug: () => {
|
|
2716
|
-
var _instance$options$deb;
|
|
2717
|
-
|
|
2718
|
-
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
|
|
2719
|
-
}
|
|
2720
|
-
}),
|
|
2721
|
-
getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
2722
|
-
leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
2723
|
-
return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
|
|
2724
|
-
}, {
|
|
2725
|
-
key: process.env.NODE_ENV === 'development' && 'getCenterHeaderGroups',
|
|
2726
|
-
debug: () => {
|
|
2727
|
-
var _instance$options$deb2;
|
|
2728
|
-
|
|
2729
|
-
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
|
|
2730
|
-
}
|
|
2731
|
-
}),
|
|
2732
|
-
getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
2733
|
-
var _left$map$filter2;
|
|
2734
|
-
|
|
2735
|
-
const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
|
|
2736
|
-
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
|
|
2737
|
-
}, {
|
|
2738
|
-
key: process.env.NODE_ENV === 'development' && 'getLeftHeaderGroups',
|
|
2739
|
-
debug: () => {
|
|
2740
|
-
var _instance$options$deb3;
|
|
2741
|
-
|
|
2742
|
-
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
|
|
2743
|
-
}
|
|
2744
|
-
}),
|
|
2745
|
-
getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
2746
|
-
var _right$map$filter2;
|
|
2747
|
-
|
|
2748
|
-
const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
|
|
2749
|
-
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
|
|
2750
|
-
}, {
|
|
2751
|
-
key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
|
|
2752
|
-
debug: () => {
|
|
2753
|
-
var _instance$options$deb4;
|
|
2754
|
-
|
|
2755
|
-
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
|
|
2756
|
-
}
|
|
2757
|
-
}),
|
|
2758
|
-
// Footer Groups
|
|
2759
|
-
getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
2760
|
-
return [...headerGroups].reverse();
|
|
2761
|
-
}, {
|
|
2762
|
-
key: process.env.NODE_ENV === 'development' && 'getFooterGroups',
|
|
2763
|
-
debug: () => {
|
|
2764
|
-
var _instance$options$deb5;
|
|
2765
|
-
|
|
2766
|
-
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
|
|
2767
|
-
}
|
|
2768
|
-
}),
|
|
2769
|
-
getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
|
|
2770
|
-
return [...headerGroups].reverse();
|
|
2771
|
-
}, {
|
|
2772
|
-
key: process.env.NODE_ENV === 'development' && 'getLeftFooterGroups',
|
|
2773
|
-
debug: () => {
|
|
2774
|
-
var _instance$options$deb6;
|
|
2775
|
-
|
|
2776
|
-
return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
|
|
2777
|
-
}
|
|
2778
|
-
}),
|
|
2779
|
-
getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
|
|
2780
|
-
return [...headerGroups].reverse();
|
|
2781
|
-
}, {
|
|
2782
|
-
key: process.env.NODE_ENV === 'development' && 'getCenterFooterGroups',
|
|
2783
|
-
debug: () => {
|
|
2784
|
-
var _instance$options$deb7;
|
|
2785
|
-
|
|
2786
|
-
return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
|
|
2787
|
-
}
|
|
2788
|
-
}),
|
|
2789
|
-
getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
|
|
2790
|
-
return [...headerGroups].reverse();
|
|
2791
|
-
}, {
|
|
2792
|
-
key: process.env.NODE_ENV === 'development' && 'getRightFooterGroups',
|
|
2793
|
-
debug: () => {
|
|
2794
|
-
var _instance$options$deb8;
|
|
2795
|
-
|
|
2796
|
-
return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
|
|
2797
|
-
}
|
|
2798
|
-
}),
|
|
2799
|
-
// Flat Headers
|
|
2800
|
-
getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
2801
|
-
return headerGroups.map(headerGroup => {
|
|
2802
|
-
return headerGroup.headers;
|
|
2803
|
-
}).flat();
|
|
2804
|
-
}, {
|
|
2805
|
-
key: process.env.NODE_ENV === 'development' && 'getFlatHeaders',
|
|
2806
|
-
debug: () => {
|
|
2807
|
-
var _instance$options$deb9;
|
|
2808
|
-
|
|
2809
|
-
return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
|
|
2810
|
-
}
|
|
2811
|
-
}),
|
|
2812
|
-
getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
|
|
2813
|
-
return left.map(headerGroup => {
|
|
2814
|
-
return headerGroup.headers;
|
|
2815
|
-
}).flat();
|
|
2816
|
-
}, {
|
|
2817
|
-
key: process.env.NODE_ENV === 'development' && 'getLeftFlatHeaders',
|
|
2818
|
-
debug: () => {
|
|
2819
|
-
var _instance$options$deb10;
|
|
2820
|
-
|
|
2821
|
-
return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
|
|
2822
|
-
}
|
|
2823
|
-
}),
|
|
2824
|
-
getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
|
|
2825
|
-
return left.map(headerGroup => {
|
|
2826
|
-
return headerGroup.headers;
|
|
2827
|
-
}).flat();
|
|
2828
|
-
}, {
|
|
2829
|
-
key: process.env.NODE_ENV === 'development' && 'getCenterFlatHeaders',
|
|
2830
|
-
debug: () => {
|
|
2831
|
-
var _instance$options$deb11;
|
|
2832
|
-
|
|
2833
|
-
return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
|
|
2834
|
-
}
|
|
2835
|
-
}),
|
|
2836
|
-
getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
|
|
2837
|
-
return left.map(headerGroup => {
|
|
2838
|
-
return headerGroup.headers;
|
|
2839
|
-
}).flat();
|
|
2840
|
-
}, {
|
|
2841
|
-
key: process.env.NODE_ENV === 'development' && 'getRightFlatHeaders',
|
|
2842
|
-
debug: () => {
|
|
2843
|
-
var _instance$options$deb12;
|
|
2844
|
-
|
|
2845
|
-
return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
|
|
2846
|
-
}
|
|
2847
|
-
}),
|
|
2848
|
-
// Leaf Headers
|
|
2849
|
-
getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
|
|
2850
|
-
return flatHeaders.filter(header => {
|
|
2851
|
-
var _header$subHeaders;
|
|
2852
|
-
|
|
2853
|
-
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
|
2854
|
-
});
|
|
2855
|
-
}, {
|
|
2856
|
-
key: process.env.NODE_ENV === 'development' && 'getCenterLeafHeaders',
|
|
2857
|
-
debug: () => {
|
|
2858
|
-
var _instance$options$deb13;
|
|
2859
|
-
|
|
2860
|
-
return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
|
|
2861
|
-
}
|
|
2862
|
-
}),
|
|
2863
|
-
getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
|
|
2864
|
-
return flatHeaders.filter(header => {
|
|
2865
|
-
var _header$subHeaders2;
|
|
2866
|
-
|
|
2867
|
-
return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
|
|
2868
|
-
});
|
|
2869
|
-
}, {
|
|
2870
|
-
key: process.env.NODE_ENV === 'development' && 'getLeftLeafHeaders',
|
|
2871
|
-
debug: () => {
|
|
2872
|
-
var _instance$options$deb14;
|
|
2873
|
-
|
|
2874
|
-
return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
|
|
2875
|
-
}
|
|
2876
|
-
}),
|
|
2877
|
-
getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
|
|
2878
|
-
return flatHeaders.filter(header => {
|
|
2879
|
-
var _header$subHeaders3;
|
|
2880
|
-
|
|
2881
|
-
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
|
2882
|
-
});
|
|
2883
|
-
}, {
|
|
2884
|
-
key: process.env.NODE_ENV === 'development' && 'getRightLeafHeaders',
|
|
2704
|
+
key: process.env.NODE_ENV === 'production' && 'row._getAllVisibleCells',
|
|
2885
2705
|
debug: () => {
|
|
2886
|
-
var _instance$options$
|
|
2706
|
+
var _instance$options$deb;
|
|
2887
2707
|
|
|
2888
|
-
return (_instance$options$
|
|
2708
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
|
|
2889
2709
|
}
|
|
2890
2710
|
}),
|
|
2891
|
-
|
|
2892
|
-
|
|
2711
|
+
getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
|
|
2712
|
+
key: process.env.NODE_ENV === 'development' && 'row.getVisibleCells',
|
|
2713
|
+
debug: () => {
|
|
2714
|
+
var _instance$options$deb2;
|
|
2893
2715
|
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2716
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
|
|
2717
|
+
}
|
|
2718
|
+
})
|
|
2719
|
+
};
|
|
2720
|
+
},
|
|
2721
|
+
createInstance: instance => {
|
|
2722
|
+
const makeVisibleColumnsMethod = (key, getColumns) => {
|
|
2723
|
+
return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
|
|
2724
|
+
return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
|
|
2897
2725
|
}, {
|
|
2898
|
-
key
|
|
2726
|
+
key,
|
|
2899
2727
|
debug: () => {
|
|
2900
|
-
var _instance$options$
|
|
2728
|
+
var _instance$options$deb3;
|
|
2901
2729
|
|
|
2902
|
-
return (_instance$options$
|
|
2730
|
+
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
2903
2731
|
}
|
|
2904
|
-
})
|
|
2905
|
-
|
|
2906
|
-
const header = [...instance.getFlatHeaders(), ...instance.getCenterFlatHeaders(), ...instance.getLeftFlatHeaders(), ...instance.getRightFlatHeaders()].find(d => d.id === id);
|
|
2732
|
+
});
|
|
2733
|
+
};
|
|
2907
2734
|
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2735
|
+
return {
|
|
2736
|
+
getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
|
|
2737
|
+
getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
|
|
2738
|
+
getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
|
|
2739
|
+
getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
|
|
2740
|
+
getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
|
|
2741
|
+
setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
|
|
2742
|
+
resetColumnVisibility: defaultState => {
|
|
2743
|
+
var _instance$initialStat;
|
|
2912
2744
|
|
|
2913
|
-
|
|
2914
|
-
|
|
2745
|
+
instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
|
|
2746
|
+
},
|
|
2747
|
+
toggleAllColumnsVisible: value => {
|
|
2748
|
+
var _value;
|
|
2915
2749
|
|
|
2916
|
-
|
|
2750
|
+
value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
|
|
2751
|
+
instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
|
|
2752
|
+
[column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
|
|
2753
|
+
}), {}));
|
|
2754
|
+
},
|
|
2755
|
+
getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
|
|
2756
|
+
getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
|
|
2757
|
+
getToggleAllColumnsVisibilityHandler: () => {
|
|
2758
|
+
return e => {
|
|
2759
|
+
var _target;
|
|
2760
|
+
|
|
2761
|
+
instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
|
|
2762
|
+
};
|
|
2917
2763
|
}
|
|
2918
2764
|
};
|
|
2919
2765
|
}
|
|
2920
2766
|
};
|
|
2921
|
-
function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
|
|
2922
|
-
var _headerGroups$0$heade, _headerGroups$;
|
|
2923
|
-
|
|
2924
|
-
// Find the max depth of the columns:
|
|
2925
|
-
// build the leaf column row
|
|
2926
|
-
// build each buffer row going up
|
|
2927
|
-
// placeholder for non-existent level
|
|
2928
|
-
// real column for existing level
|
|
2929
|
-
let maxDepth = 0;
|
|
2930
|
-
|
|
2931
|
-
const findMaxDepth = function (columns, depth) {
|
|
2932
|
-
if (depth === void 0) {
|
|
2933
|
-
depth = 1;
|
|
2934
|
-
}
|
|
2935
|
-
|
|
2936
|
-
maxDepth = Math.max(maxDepth, depth);
|
|
2937
|
-
columns.filter(column => column.getIsVisible()).forEach(column => {
|
|
2938
|
-
var _column$columns;
|
|
2939
|
-
|
|
2940
|
-
if ((_column$columns = column.columns) != null && _column$columns.length) {
|
|
2941
|
-
findMaxDepth(column.columns, depth + 1);
|
|
2942
|
-
}
|
|
2943
|
-
}, 0);
|
|
2944
|
-
};
|
|
2945
|
-
|
|
2946
|
-
findMaxDepth(allColumns);
|
|
2947
|
-
let headerGroups = [];
|
|
2948
|
-
|
|
2949
|
-
const createHeaderGroup = (headersToGroup, depth) => {
|
|
2950
|
-
// The header group we are creating
|
|
2951
|
-
const headerGroup = {
|
|
2952
|
-
depth,
|
|
2953
|
-
id: [headerFamily, "" + depth].filter(Boolean).join('_'),
|
|
2954
|
-
headers: []
|
|
2955
|
-
}; // The parent columns we're going to scan next
|
|
2956
|
-
|
|
2957
|
-
const pendingParentHeaders = []; // Scan each column for parents
|
|
2958
|
-
|
|
2959
|
-
headersToGroup.forEach(headerToGroup => {
|
|
2960
|
-
// What is the latest (last) parent column?
|
|
2961
|
-
const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
|
|
2962
|
-
const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
|
|
2963
|
-
let column;
|
|
2964
|
-
let isPlaceholder = false;
|
|
2965
|
-
|
|
2966
|
-
if (isLeafHeader && headerToGroup.column.parent) {
|
|
2967
|
-
// The parent header is new
|
|
2968
|
-
column = headerToGroup.column.parent;
|
|
2969
|
-
} else {
|
|
2970
|
-
// The parent header is repeated
|
|
2971
|
-
column = headerToGroup.column;
|
|
2972
|
-
isPlaceholder = true;
|
|
2973
|
-
}
|
|
2974
|
-
|
|
2975
|
-
if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
|
|
2976
|
-
// This column is repeated. Add it as a sub header to the next batch
|
|
2977
|
-
latestPendingParentHeader.subHeaders.push(headerToGroup);
|
|
2978
|
-
} else {
|
|
2979
|
-
// This is a new header. Let's create it
|
|
2980
|
-
const header = instance.createHeader(column, {
|
|
2981
|
-
id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
|
|
2982
|
-
isPlaceholder,
|
|
2983
|
-
placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
|
|
2984
|
-
depth,
|
|
2985
|
-
index: pendingParentHeaders.length
|
|
2986
|
-
}); // Add the headerToGroup as a subHeader of the new header
|
|
2987
|
-
|
|
2988
|
-
header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
|
|
2989
|
-
// in the next batch
|
|
2990
|
-
|
|
2991
|
-
pendingParentHeaders.push(header);
|
|
2992
|
-
}
|
|
2993
|
-
|
|
2994
|
-
headerGroup.headers.push(headerToGroup);
|
|
2995
|
-
headerToGroup.headerGroup = headerGroup;
|
|
2996
|
-
});
|
|
2997
|
-
headerGroups.push(headerGroup);
|
|
2998
|
-
|
|
2999
|
-
if (depth > 0) {
|
|
3000
|
-
createHeaderGroup(pendingParentHeaders, depth - 1);
|
|
3001
|
-
}
|
|
3002
|
-
};
|
|
3003
|
-
|
|
3004
|
-
const bottomHeaders = columnsToGroup.map((column, index) => instance.createHeader(column, {
|
|
3005
|
-
depth: maxDepth,
|
|
3006
|
-
index
|
|
3007
|
-
}));
|
|
3008
|
-
createHeaderGroup(bottomHeaders, maxDepth - 1);
|
|
3009
|
-
headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
|
|
3010
|
-
// return !headerGroup.headers.every(header => header.isPlaceholder)
|
|
3011
|
-
// })
|
|
3012
|
-
|
|
3013
|
-
const recurseHeadersForSpans = headers => {
|
|
3014
|
-
const filteredHeaders = headers.filter(header => header.column.getIsVisible());
|
|
3015
|
-
return filteredHeaders.map(header => {
|
|
3016
|
-
let colSpan = 0;
|
|
3017
|
-
let rowSpan = 0;
|
|
3018
|
-
let childRowSpans = [0];
|
|
3019
|
-
|
|
3020
|
-
if (header.subHeaders && header.subHeaders.length) {
|
|
3021
|
-
childRowSpans = [];
|
|
3022
|
-
recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
|
|
3023
|
-
let {
|
|
3024
|
-
colSpan: childColSpan,
|
|
3025
|
-
rowSpan: childRowSpan
|
|
3026
|
-
} = _ref;
|
|
3027
|
-
colSpan += childColSpan;
|
|
3028
|
-
childRowSpans.push(childRowSpan);
|
|
3029
|
-
});
|
|
3030
|
-
} else {
|
|
3031
|
-
colSpan = 1;
|
|
3032
|
-
}
|
|
3033
|
-
|
|
3034
|
-
const minChildRowSpan = Math.min(...childRowSpans);
|
|
3035
|
-
rowSpan = rowSpan + minChildRowSpan;
|
|
3036
|
-
header.colSpan = colSpan > 0 ? colSpan : undefined;
|
|
3037
|
-
header.rowSpan = rowSpan > 0 ? rowSpan : undefined;
|
|
3038
|
-
return {
|
|
3039
|
-
colSpan,
|
|
3040
|
-
rowSpan
|
|
3041
|
-
};
|
|
3042
|
-
});
|
|
3043
|
-
};
|
|
3044
2767
|
|
|
3045
|
-
|
|
3046
|
-
return headerGroups;
|
|
3047
|
-
}
|
|
2768
|
+
const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]; //
|
|
3048
2769
|
|
|
3049
|
-
// export type Batch = {
|
|
3050
|
-
// id: number
|
|
3051
|
-
// priority: keyof CoreBatches
|
|
3052
|
-
// tasks: (() => void)[]
|
|
3053
|
-
// schedule: (cb: () => void) => void
|
|
3054
|
-
// cancel: () => void
|
|
3055
|
-
// }
|
|
3056
|
-
// type CoreBatches = {
|
|
3057
|
-
// data: Batch[]
|
|
3058
|
-
// facets: Batch[]
|
|
3059
|
-
// }
|
|
3060
2770
|
function createTableInstance(options) {
|
|
3061
2771
|
var _options$initialState;
|
|
3062
2772
|
|
|
@@ -3065,7 +2775,7 @@ function createTableInstance(options) {
|
|
|
3065
2775
|
}
|
|
3066
2776
|
|
|
3067
2777
|
let instance = {
|
|
3068
|
-
_features:
|
|
2778
|
+
_features: features
|
|
3069
2779
|
};
|
|
3070
2780
|
|
|
3071
2781
|
const defaultOptions = instance._features.reduce((obj, feature) => {
|
|
@@ -3082,8 +2792,7 @@ function createTableInstance(options) {
|
|
|
3082
2792
|
};
|
|
3083
2793
|
};
|
|
3084
2794
|
|
|
3085
|
-
const coreInitialState = {
|
|
3086
|
-
};
|
|
2795
|
+
const coreInitialState = {};
|
|
3087
2796
|
let initialState = { ...coreInitialState,
|
|
3088
2797
|
...((_options$initialState = options.initialState) != null ? _options$initialState : {})
|
|
3089
2798
|
};
|
|
@@ -3096,16 +2805,8 @@ function createTableInstance(options) {
|
|
|
3096
2805
|
|
|
3097
2806
|
const queued = [];
|
|
3098
2807
|
let queuedTimeout = false;
|
|
3099
|
-
const
|
|
3100
|
-
|
|
3101
|
-
// startWork()
|
|
3102
|
-
// },
|
|
3103
|
-
// willUpdate: () => {
|
|
3104
|
-
// startWork()
|
|
3105
|
-
// },
|
|
3106
|
-
// destroy: () => {
|
|
3107
|
-
// stopWork()
|
|
3108
|
-
// },
|
|
2808
|
+
const coreInstance = {
|
|
2809
|
+
_features: features,
|
|
3109
2810
|
options: { ...defaultOptions,
|
|
3110
2811
|
...options
|
|
3111
2812
|
},
|
|
@@ -3151,29 +2852,136 @@ function createTableInstance(options) {
|
|
|
3151
2852
|
},
|
|
3152
2853
|
setState: updater => {
|
|
3153
2854
|
instance.options.onStateChange == null ? void 0 : instance.options.onStateChange(updater);
|
|
3154
|
-
}
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
//
|
|
3168
|
-
//
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
2855
|
+
},
|
|
2856
|
+
_getRowId: (row, index, parent) => {
|
|
2857
|
+
var _instance$options$get;
|
|
2858
|
+
|
|
2859
|
+
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);
|
|
2860
|
+
},
|
|
2861
|
+
getCoreRowModel: () => {
|
|
2862
|
+
if (!instance._getCoreRowModel) {
|
|
2863
|
+
instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
|
|
2864
|
+
}
|
|
2865
|
+
|
|
2866
|
+
return instance._getCoreRowModel();
|
|
2867
|
+
},
|
|
2868
|
+
// The final calls start at the bottom of the model,
|
|
2869
|
+
// expanded rows, which then work their way up
|
|
2870
|
+
getRowModel: () => {
|
|
2871
|
+
return instance.getPaginationRowModel();
|
|
2872
|
+
},
|
|
2873
|
+
getRow: id => {
|
|
2874
|
+
const row = instance.getRowModel().rowsById[id];
|
|
2875
|
+
|
|
2876
|
+
if (!row) {
|
|
2877
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2878
|
+
throw new Error("getRow expected an ID, but got " + id);
|
|
2879
|
+
}
|
|
2880
|
+
|
|
2881
|
+
throw new Error();
|
|
2882
|
+
}
|
|
2883
|
+
|
|
2884
|
+
return row;
|
|
2885
|
+
},
|
|
2886
|
+
_getDefaultColumnDef: memo(() => [instance.options.defaultColumn], defaultColumn => {
|
|
2887
|
+
var _defaultColumn;
|
|
2888
|
+
|
|
2889
|
+
defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
|
|
2890
|
+
return {
|
|
2891
|
+
header: props => props.header.column.id,
|
|
2892
|
+
footer: props => props.header.column.id,
|
|
2893
|
+
cell: props => {
|
|
2894
|
+
var _props$getValue$toStr, _props$getValue$toStr2, _props$getValue;
|
|
2895
|
+
|
|
2896
|
+
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;
|
|
2897
|
+
},
|
|
2898
|
+
...instance._features.reduce((obj, feature) => {
|
|
2899
|
+
return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
|
|
2900
|
+
}, {}),
|
|
2901
|
+
...defaultColumn
|
|
2902
|
+
};
|
|
2903
|
+
}, {
|
|
2904
|
+
debug: () => {
|
|
2905
|
+
var _instance$options$deb;
|
|
2906
|
+
|
|
2907
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
|
|
2908
|
+
},
|
|
2909
|
+
key: process.env.NODE_ENV === 'development' && 'getDefaultColumnDef'
|
|
2910
|
+
}),
|
|
2911
|
+
_getColumnDefs: () => instance.options.columns,
|
|
2912
|
+
getAllColumns: memo(() => [instance._getColumnDefs()], columnDefs => {
|
|
2913
|
+
const recurseColumns = function (columnDefs, parent, depth) {
|
|
2914
|
+
if (depth === void 0) {
|
|
2915
|
+
depth = 0;
|
|
2916
|
+
}
|
|
2917
|
+
|
|
2918
|
+
return columnDefs.map(columnDef => {
|
|
2919
|
+
const column = createColumn(instance, columnDef, depth, parent);
|
|
2920
|
+
column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
|
|
2921
|
+
return column;
|
|
2922
|
+
});
|
|
2923
|
+
};
|
|
2924
|
+
|
|
2925
|
+
return recurseColumns(columnDefs);
|
|
2926
|
+
}, {
|
|
2927
|
+
key: process.env.NODE_ENV === 'development' && 'getAllColumns',
|
|
2928
|
+
debug: () => {
|
|
2929
|
+
var _instance$options$deb2;
|
|
2930
|
+
|
|
2931
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
|
|
2932
|
+
}
|
|
2933
|
+
}),
|
|
2934
|
+
getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
|
|
2935
|
+
return allColumns.flatMap(column => {
|
|
2936
|
+
return column.getFlatColumns();
|
|
2937
|
+
});
|
|
2938
|
+
}, {
|
|
2939
|
+
key: process.env.NODE_ENV === 'development' && 'getAllFlatColumns',
|
|
2940
|
+
debug: () => {
|
|
2941
|
+
var _instance$options$deb3;
|
|
2942
|
+
|
|
2943
|
+
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
2944
|
+
}
|
|
2945
|
+
}),
|
|
2946
|
+
_getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
|
|
2947
|
+
return flatColumns.reduce((acc, column) => {
|
|
2948
|
+
acc[column.id] = column;
|
|
2949
|
+
return acc;
|
|
2950
|
+
}, {});
|
|
2951
|
+
}, {
|
|
2952
|
+
key: process.env.NODE_ENV === 'development' && 'getAllFlatColumnsById',
|
|
2953
|
+
debug: () => {
|
|
2954
|
+
var _instance$options$deb4;
|
|
2955
|
+
|
|
2956
|
+
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
|
|
2957
|
+
}
|
|
2958
|
+
}),
|
|
2959
|
+
getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
|
|
2960
|
+
let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
|
|
2961
|
+
return orderColumns(leafColumns);
|
|
2962
|
+
}, {
|
|
2963
|
+
key: process.env.NODE_ENV === 'development' && 'getAllLeafColumns',
|
|
2964
|
+
debug: () => {
|
|
2965
|
+
var _instance$options$deb5;
|
|
2966
|
+
|
|
2967
|
+
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
|
|
2968
|
+
}
|
|
2969
|
+
}),
|
|
2970
|
+
getColumn: columnId => {
|
|
2971
|
+
const column = instance._getAllFlatColumnsById()[columnId];
|
|
2972
|
+
|
|
2973
|
+
if (!column) {
|
|
2974
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2975
|
+
console.warn("[Table] Column with id " + columnId + " does not exist.");
|
|
2976
|
+
}
|
|
2977
|
+
|
|
2978
|
+
throw new Error();
|
|
2979
|
+
}
|
|
3174
2980
|
|
|
2981
|
+
return column;
|
|
2982
|
+
}
|
|
3175
2983
|
};
|
|
3176
|
-
|
|
2984
|
+
Object.assign(instance, coreInstance);
|
|
3177
2985
|
|
|
3178
2986
|
instance._features.forEach(feature => {
|
|
3179
2987
|
return Object.assign(instance, feature.createInstance == null ? void 0 : feature.createInstance(instance));
|
|
@@ -3238,6 +3046,86 @@ function createTable(_, __, options) {
|
|
|
3238
3046
|
return table;
|
|
3239
3047
|
}
|
|
3240
3048
|
|
|
3049
|
+
function createCell(instance, row, column, columnId) {
|
|
3050
|
+
const cell = {
|
|
3051
|
+
id: row.id + "_" + column.id,
|
|
3052
|
+
row,
|
|
3053
|
+
column,
|
|
3054
|
+
getValue: () => row.getValue(columnId),
|
|
3055
|
+
renderCell: () => column.columnDef.cell ? instance._render(column.columnDef.cell, {
|
|
3056
|
+
instance,
|
|
3057
|
+
column,
|
|
3058
|
+
row,
|
|
3059
|
+
cell: cell,
|
|
3060
|
+
getValue: cell.getValue
|
|
3061
|
+
}) : null
|
|
3062
|
+
};
|
|
3063
|
+
|
|
3064
|
+
instance._features.forEach(feature => {
|
|
3065
|
+
Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
|
|
3066
|
+
}, {});
|
|
3067
|
+
|
|
3068
|
+
return cell;
|
|
3069
|
+
}
|
|
3070
|
+
|
|
3071
|
+
const createRow = (instance, id, original, rowIndex, depth, subRows) => {
|
|
3072
|
+
let row = {
|
|
3073
|
+
id,
|
|
3074
|
+
index: rowIndex,
|
|
3075
|
+
original,
|
|
3076
|
+
depth,
|
|
3077
|
+
_valuesCache: {},
|
|
3078
|
+
getValue: columnId => {
|
|
3079
|
+
if (row._valuesCache.hasOwnProperty(columnId)) {
|
|
3080
|
+
return row._valuesCache[columnId];
|
|
3081
|
+
}
|
|
3082
|
+
|
|
3083
|
+
const column = instance.getColumn(columnId);
|
|
3084
|
+
|
|
3085
|
+
if (!column.accessorFn) {
|
|
3086
|
+
return undefined;
|
|
3087
|
+
}
|
|
3088
|
+
|
|
3089
|
+
row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
|
3090
|
+
return row._valuesCache[columnId];
|
|
3091
|
+
},
|
|
3092
|
+
subRows: subRows != null ? subRows : [],
|
|
3093
|
+
getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
|
|
3094
|
+
getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
|
|
3095
|
+
return leafColumns.map(column => {
|
|
3096
|
+
return createCell(instance, row, column, column.id);
|
|
3097
|
+
});
|
|
3098
|
+
}, {
|
|
3099
|
+
key: process.env.NODE_ENV === 'development' && 'row.getAllCells',
|
|
3100
|
+
debug: () => {
|
|
3101
|
+
var _instance$options$deb;
|
|
3102
|
+
|
|
3103
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
|
|
3104
|
+
}
|
|
3105
|
+
}),
|
|
3106
|
+
_getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
|
|
3107
|
+
return allCells.reduce((acc, cell) => {
|
|
3108
|
+
acc[cell.column.id] = cell;
|
|
3109
|
+
return acc;
|
|
3110
|
+
}, {});
|
|
3111
|
+
}, {
|
|
3112
|
+
key: process.env.NODE_ENV === 'production' && 'row.getAllCellsByColumnId',
|
|
3113
|
+
debug: () => {
|
|
3114
|
+
var _instance$options$deb2;
|
|
3115
|
+
|
|
3116
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
|
|
3117
|
+
}
|
|
3118
|
+
})
|
|
3119
|
+
};
|
|
3120
|
+
|
|
3121
|
+
for (let i = 0; i < instance._features.length; i++) {
|
|
3122
|
+
const feature = instance._features[i];
|
|
3123
|
+
Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
|
|
3124
|
+
}
|
|
3125
|
+
|
|
3126
|
+
return row;
|
|
3127
|
+
};
|
|
3128
|
+
|
|
3241
3129
|
function getCoreRowModel() {
|
|
3242
3130
|
return instance => memo(() => [instance.options.data], data => {
|
|
3243
3131
|
const rowModel = {
|
|
@@ -3265,7 +3153,7 @@ function getCoreRowModel() {
|
|
|
3265
3153
|
// }
|
|
3266
3154
|
// Make the row
|
|
3267
3155
|
|
|
3268
|
-
row =
|
|
3156
|
+
row = createRow(instance, instance._getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
|
|
3269
3157
|
|
|
3270
3158
|
rowModel.flatRows.push(row); // Also keep track of every row by its ID
|
|
3271
3159
|
|
|
@@ -3328,7 +3216,7 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
|
|
|
3328
3216
|
row = rowsToFilter[i];
|
|
3329
3217
|
|
|
3330
3218
|
if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
|
|
3331
|
-
newRow =
|
|
3219
|
+
newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3332
3220
|
newRow.columnFilters = row.columnFilters;
|
|
3333
3221
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3334
3222
|
|
|
@@ -3378,7 +3266,7 @@ function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
|
|
|
3378
3266
|
var _row$subRows2;
|
|
3379
3267
|
|
|
3380
3268
|
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
|
|
3381
|
-
newRow =
|
|
3269
|
+
newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3382
3270
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3383
3271
|
row = newRow;
|
|
3384
3272
|
}
|
|
@@ -3745,7 +3633,7 @@ function getGroupedRowModel() {
|
|
|
3745
3633
|
const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
|
|
3746
3634
|
|
|
3747
3635
|
const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
|
|
3748
|
-
const row =
|
|
3636
|
+
const row = createRow(instance, id, undefined, index, depth);
|
|
3749
3637
|
Object.assign(row, {
|
|
3750
3638
|
groupingColumnId: columnId,
|
|
3751
3639
|
groupingValue,
|
|
@@ -3754,38 +3642,30 @@ function getGroupedRowModel() {
|
|
|
3754
3642
|
getValue: columnId => {
|
|
3755
3643
|
// Don't aggregate columns that are in the grouping
|
|
3756
3644
|
if (existingGrouping.includes(columnId)) {
|
|
3757
|
-
if (row.
|
|
3758
|
-
return row.
|
|
3645
|
+
if (row._valuesCache.hasOwnProperty(columnId)) {
|
|
3646
|
+
return row._valuesCache[columnId];
|
|
3759
3647
|
}
|
|
3760
3648
|
|
|
3761
3649
|
if (groupedRows[0]) {
|
|
3762
3650
|
var _groupedRows$0$getVal;
|
|
3763
3651
|
|
|
3764
|
-
row.
|
|
3652
|
+
row._valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
|
|
3765
3653
|
}
|
|
3766
3654
|
|
|
3767
|
-
return row.
|
|
3655
|
+
return row._valuesCache[columnId];
|
|
3768
3656
|
}
|
|
3769
3657
|
|
|
3770
|
-
if (row.
|
|
3771
|
-
return row.
|
|
3658
|
+
if (row._groupingValuesCache.hasOwnProperty(columnId)) {
|
|
3659
|
+
return row._groupingValuesCache[columnId];
|
|
3772
3660
|
} // Aggregate the values
|
|
3773
3661
|
|
|
3774
3662
|
|
|
3775
3663
|
const column = instance.getColumn(columnId);
|
|
3776
|
-
const aggregateFn = column.
|
|
3664
|
+
const aggregateFn = column.getAggregationFn();
|
|
3777
3665
|
|
|
3778
3666
|
if (aggregateFn) {
|
|
3779
|
-
row.
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
if (!depth && column.columnDef.aggregateValue) {
|
|
3783
|
-
columnValue = column.columnDef.aggregateValue(columnValue);
|
|
3784
|
-
}
|
|
3785
|
-
|
|
3786
|
-
return columnValue;
|
|
3787
|
-
}), () => groupedRows.map(row => row.getValue(columnId)));
|
|
3788
|
-
return row.groupingValuesCache[columnId];
|
|
3667
|
+
row._groupingValuesCache[columnId] = aggregateFn(columnId, leafRows, groupedRows);
|
|
3668
|
+
return row._groupingValuesCache[columnId];
|
|
3789
3669
|
} else if (column.aggregationFn) {
|
|
3790
3670
|
console.info({
|
|
3791
3671
|
column
|
|
@@ -3865,7 +3745,7 @@ function getExpandedRowModel() {
|
|
|
3865
3745
|
return rowModel;
|
|
3866
3746
|
}
|
|
3867
3747
|
|
|
3868
|
-
return expandRows(rowModel
|
|
3748
|
+
return expandRows(rowModel);
|
|
3869
3749
|
}, {
|
|
3870
3750
|
key: process.env.NODE_ENV === 'development' && 'getExpandedRowModel',
|
|
3871
3751
|
debug: () => {
|
|
@@ -3883,7 +3763,7 @@ function expandRows(rowModel, instance) {
|
|
|
3883
3763
|
|
|
3884
3764
|
expandedRows.push(row);
|
|
3885
3765
|
|
|
3886
|
-
if (
|
|
3766
|
+
if ((_row$subRows = row.subRows) != null && _row$subRows.length && row.getIsExpanded()) {
|
|
3887
3767
|
row.subRows.forEach(handleRow);
|
|
3888
3768
|
}
|
|
3889
3769
|
};
|
|
@@ -3920,7 +3800,7 @@ function getPaginationRowModel(opts) {
|
|
|
3920
3800
|
rows,
|
|
3921
3801
|
flatRows,
|
|
3922
3802
|
rowsById
|
|
3923
|
-
}
|
|
3803
|
+
});
|
|
3924
3804
|
}
|
|
3925
3805
|
|
|
3926
3806
|
return {
|
|
@@ -3951,6 +3831,8 @@ exports.Sorting = Sorting;
|
|
|
3951
3831
|
exports.Visibility = Visibility;
|
|
3952
3832
|
exports.aggregationFns = aggregationFns;
|
|
3953
3833
|
exports.buildHeaderGroups = buildHeaderGroups;
|
|
3834
|
+
exports.createColumn = createColumn;
|
|
3835
|
+
exports.createRow = createRow;
|
|
3954
3836
|
exports.createTableFactory = createTableFactory;
|
|
3955
3837
|
exports.createTableInstance = createTableInstance;
|
|
3956
3838
|
exports.defaultColumnSizing = defaultColumnSizing;
|
|
@@ -3970,7 +3852,6 @@ exports.getSortedRowModel = getSortedRowModel;
|
|
|
3970
3852
|
exports.isFunction = isFunction;
|
|
3971
3853
|
exports.isRowSelected = isRowSelected;
|
|
3972
3854
|
exports.makeStateUpdater = makeStateUpdater;
|
|
3973
|
-
exports.mean = mean;
|
|
3974
3855
|
exports.memo = memo;
|
|
3975
3856
|
exports.noop = noop;
|
|
3976
3857
|
exports.orderColumns = orderColumns;
|