@tanstack/react-table 8.0.0-alpha.80 → 8.0.0-alpha.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/react-table/src/index.js +7 -0
- package/build/cjs/react-table/src/index.js.map +1 -1
- package/build/cjs/table-core/build/esm/index.js +737 -809
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +731 -810
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +17 -17
- package/build/types/index.d.ts +2 -2
- package/build/umd/index.development.js +738 -806
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +3 -5
package/build/esm/index.js
CHANGED
|
@@ -97,335 +97,459 @@ function memo(getDeps, fn, opts) {
|
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
function createColumn(instance, columnDef, depth, parent) {
|
|
101
|
+
var _ref, _columnDef$id;
|
|
102
|
+
|
|
103
|
+
const defaultColumn = instance._getDefaultColumnDef();
|
|
104
|
+
|
|
105
|
+
columnDef = { ...defaultColumn,
|
|
106
|
+
...columnDef
|
|
107
|
+
};
|
|
108
|
+
let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
|
|
109
|
+
let accessorFn;
|
|
110
|
+
|
|
111
|
+
if (columnDef.accessorFn) {
|
|
112
|
+
accessorFn = columnDef.accessorFn;
|
|
113
|
+
} else if (columnDef.accessorKey) {
|
|
114
|
+
accessorFn = originalRow => originalRow[columnDef.accessorKey];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (!id) {
|
|
118
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
119
|
+
throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
throw new Error();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
let column = { ...columnDef,
|
|
126
|
+
id: "" + id,
|
|
127
|
+
accessorFn,
|
|
128
|
+
parent: parent,
|
|
129
|
+
depth,
|
|
130
|
+
columnDef,
|
|
131
|
+
columnDefType: columnDef.columnDefType,
|
|
132
|
+
columns: [],
|
|
133
|
+
getFlatColumns: memo(() => [true], () => {
|
|
134
|
+
var _column$columns;
|
|
135
|
+
|
|
136
|
+
return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
|
|
137
|
+
}, {
|
|
138
|
+
key: process.env.NODE_ENV === 'production' && 'column.getFlatColumns',
|
|
139
|
+
debug: () => {
|
|
140
|
+
var _instance$options$deb;
|
|
141
|
+
|
|
142
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
|
|
143
|
+
}
|
|
144
|
+
}),
|
|
145
|
+
getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
|
|
146
|
+
var _column$columns2;
|
|
147
|
+
|
|
148
|
+
if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
|
|
149
|
+
let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
|
|
150
|
+
return orderColumns(leafColumns);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return [column];
|
|
154
|
+
}, {
|
|
155
|
+
key: process.env.NODE_ENV === 'production' && 'column.getLeafColumns',
|
|
156
|
+
debug: () => {
|
|
157
|
+
var _instance$options$deb2;
|
|
158
|
+
|
|
159
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
};
|
|
163
|
+
column = instance._features.reduce((obj, feature) => {
|
|
164
|
+
return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
|
|
165
|
+
}, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
166
|
+
|
|
167
|
+
return column;
|
|
168
|
+
}
|
|
169
|
+
|
|
100
170
|
//
|
|
101
|
-
|
|
171
|
+
function createHeader(instance, column, options) {
|
|
172
|
+
var _options$id;
|
|
173
|
+
|
|
174
|
+
const id = (_options$id = options.id) != null ? _options$id : column.id;
|
|
175
|
+
let header = {
|
|
176
|
+
id,
|
|
177
|
+
column,
|
|
178
|
+
index: options.index,
|
|
179
|
+
isPlaceholder: !!options.isPlaceholder,
|
|
180
|
+
placeholderId: options.placeholderId,
|
|
181
|
+
depth: options.depth,
|
|
182
|
+
subHeaders: [],
|
|
183
|
+
colSpan: 0,
|
|
184
|
+
rowSpan: 0,
|
|
185
|
+
headerGroup: null,
|
|
186
|
+
getLeafHeaders: () => {
|
|
187
|
+
const leafHeaders = [];
|
|
188
|
+
|
|
189
|
+
const recurseHeader = h => {
|
|
190
|
+
if (h.subHeaders && h.subHeaders.length) {
|
|
191
|
+
h.subHeaders.map(recurseHeader);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
leafHeaders.push(h);
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
recurseHeader(header);
|
|
198
|
+
return leafHeaders;
|
|
199
|
+
},
|
|
200
|
+
renderHeader: () => column.columnDef.header ? instance._render(column.columnDef.header, {
|
|
201
|
+
instance,
|
|
202
|
+
header: header,
|
|
203
|
+
column
|
|
204
|
+
}) : null,
|
|
205
|
+
renderFooter: () => column.columnDef.footer ? instance._render(column.columnDef.footer, {
|
|
206
|
+
instance,
|
|
207
|
+
header: header,
|
|
208
|
+
column
|
|
209
|
+
}) : null
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
instance._features.forEach(feature => {
|
|
213
|
+
Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
return header;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const Headers = {
|
|
102
220
|
createInstance: instance => {
|
|
103
221
|
return {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
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;
|
|
115
|
-
},
|
|
116
|
-
...instance._features.reduce((obj, feature) => {
|
|
117
|
-
return Object.assign(obj, feature.getDefaultColumn == null ? void 0 : feature.getDefaultColumn());
|
|
118
|
-
}, {}),
|
|
119
|
-
...defaultColumn
|
|
120
|
-
};
|
|
222
|
+
// Header Groups
|
|
223
|
+
getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
224
|
+
var _left$map$filter, _right$map$filter;
|
|
225
|
+
|
|
226
|
+
const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
|
|
227
|
+
const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
|
|
228
|
+
const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
229
|
+
const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
|
|
230
|
+
return headerGroups;
|
|
121
231
|
}, {
|
|
232
|
+
key: process.env.NODE_ENV === 'development' && 'getHeaderGroups',
|
|
122
233
|
debug: () => {
|
|
123
234
|
var _instance$options$deb;
|
|
124
235
|
|
|
125
|
-
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.
|
|
126
|
-
}
|
|
127
|
-
key: process.env.NODE_ENV === 'development' && 'getDefaultColumn'
|
|
236
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
|
|
237
|
+
}
|
|
128
238
|
}),
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
239
|
+
getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
240
|
+
leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
241
|
+
return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
|
|
242
|
+
}, {
|
|
243
|
+
key: process.env.NODE_ENV === 'development' && 'getCenterHeaderGroups',
|
|
244
|
+
debug: () => {
|
|
245
|
+
var _instance$options$deb2;
|
|
136
246
|
|
|
137
|
-
|
|
138
|
-
accessorFn = columnDef.accessorFn;
|
|
139
|
-
} else if (columnDef.accessorKey) {
|
|
140
|
-
accessorFn = originalRow => originalRow[columnDef.accessorKey];
|
|
247
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
|
|
141
248
|
}
|
|
249
|
+
}),
|
|
250
|
+
getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
251
|
+
var _left$map$filter2;
|
|
142
252
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
253
|
+
const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
|
|
254
|
+
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
|
|
255
|
+
}, {
|
|
256
|
+
key: process.env.NODE_ENV === 'development' && 'getLeftHeaderGroups',
|
|
257
|
+
debug: () => {
|
|
258
|
+
var _instance$options$deb3;
|
|
147
259
|
|
|
148
|
-
|
|
260
|
+
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
|
|
149
261
|
}
|
|
262
|
+
}),
|
|
263
|
+
getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
264
|
+
var _right$map$filter2;
|
|
150
265
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
id: "" + id,
|
|
154
|
-
accessorFn,
|
|
155
|
-
parent: parent,
|
|
156
|
-
depth,
|
|
157
|
-
columnDef,
|
|
158
|
-
columnDefType: columnDef.columnDefType,
|
|
159
|
-
columns: [],
|
|
160
|
-
getFlatColumns: memo(() => [true], () => {
|
|
161
|
-
var _column$columns;
|
|
162
|
-
|
|
163
|
-
return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
|
|
164
|
-
}, {
|
|
165
|
-
key: process.env.NODE_ENV === 'production' && 'column.getFlatColumns',
|
|
166
|
-
debug: () => {
|
|
167
|
-
var _instance$options$deb2;
|
|
168
|
-
|
|
169
|
-
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
|
|
170
|
-
}
|
|
171
|
-
}),
|
|
172
|
-
getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
|
|
173
|
-
var _column$columns2;
|
|
174
|
-
|
|
175
|
-
if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
|
|
176
|
-
let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
|
|
177
|
-
return orderColumns(leafColumns);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return [column];
|
|
181
|
-
}, {
|
|
182
|
-
key: process.env.NODE_ENV === 'production' && 'column.getLeafColumns',
|
|
183
|
-
debug: () => {
|
|
184
|
-
var _instance$options$deb3;
|
|
185
|
-
|
|
186
|
-
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
187
|
-
}
|
|
188
|
-
})
|
|
189
|
-
};
|
|
190
|
-
column = instance._features.reduce((obj, feature) => {
|
|
191
|
-
return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
|
|
192
|
-
}, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
193
|
-
|
|
194
|
-
return column;
|
|
195
|
-
},
|
|
196
|
-
getAllColumns: memo(() => [instance.getColumnDefs()], columnDefs => {
|
|
197
|
-
const recurseColumns = function (columnDefs, parent, depth) {
|
|
198
|
-
if (depth === void 0) {
|
|
199
|
-
depth = 0;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return columnDefs.map(columnDef => {
|
|
203
|
-
const column = instance.createColumn(columnDef, depth, parent);
|
|
204
|
-
column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
|
|
205
|
-
return column;
|
|
206
|
-
});
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
return recurseColumns(columnDefs);
|
|
266
|
+
const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
|
|
267
|
+
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
|
|
210
268
|
}, {
|
|
211
|
-
key: process.env.NODE_ENV === 'development' && '
|
|
269
|
+
key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
|
|
212
270
|
debug: () => {
|
|
213
271
|
var _instance$options$deb4;
|
|
214
272
|
|
|
215
|
-
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.
|
|
273
|
+
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
|
|
216
274
|
}
|
|
217
275
|
}),
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
});
|
|
276
|
+
// Footer Groups
|
|
277
|
+
getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
278
|
+
return [...headerGroups].reverse();
|
|
222
279
|
}, {
|
|
223
|
-
key: process.env.NODE_ENV === 'development' && '
|
|
280
|
+
key: process.env.NODE_ENV === 'development' && 'getFooterGroups',
|
|
224
281
|
debug: () => {
|
|
225
282
|
var _instance$options$deb5;
|
|
226
283
|
|
|
227
|
-
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.
|
|
284
|
+
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
|
|
228
285
|
}
|
|
229
286
|
}),
|
|
230
|
-
|
|
231
|
-
return
|
|
232
|
-
acc[column.id] = column;
|
|
233
|
-
return acc;
|
|
234
|
-
}, {});
|
|
287
|
+
getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
|
|
288
|
+
return [...headerGroups].reverse();
|
|
235
289
|
}, {
|
|
236
|
-
key: process.env.NODE_ENV === 'development' && '
|
|
290
|
+
key: process.env.NODE_ENV === 'development' && 'getLeftFooterGroups',
|
|
237
291
|
debug: () => {
|
|
238
292
|
var _instance$options$deb6;
|
|
239
293
|
|
|
240
|
-
return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.
|
|
294
|
+
return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
|
|
241
295
|
}
|
|
242
296
|
}),
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
return orderColumns(leafColumns);
|
|
297
|
+
getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
|
|
298
|
+
return [...headerGroups].reverse();
|
|
246
299
|
}, {
|
|
247
|
-
key: process.env.NODE_ENV === 'development' && '
|
|
300
|
+
key: process.env.NODE_ENV === 'development' && 'getCenterFooterGroups',
|
|
248
301
|
debug: () => {
|
|
249
302
|
var _instance$options$deb7;
|
|
250
303
|
|
|
251
|
-
return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.
|
|
304
|
+
return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
|
|
252
305
|
}
|
|
253
306
|
}),
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
307
|
+
getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
|
|
308
|
+
return [...headerGroups].reverse();
|
|
309
|
+
}, {
|
|
310
|
+
key: process.env.NODE_ENV === 'development' && 'getRightFooterGroups',
|
|
311
|
+
debug: () => {
|
|
312
|
+
var _instance$options$deb8;
|
|
261
313
|
|
|
262
|
-
|
|
314
|
+
return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
|
|
263
315
|
}
|
|
316
|
+
}),
|
|
317
|
+
// Flat Headers
|
|
318
|
+
getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
319
|
+
return headerGroups.map(headerGroup => {
|
|
320
|
+
return headerGroup.headers;
|
|
321
|
+
}).flat();
|
|
322
|
+
}, {
|
|
323
|
+
key: process.env.NODE_ENV === 'development' && 'getFlatHeaders',
|
|
324
|
+
debug: () => {
|
|
325
|
+
var _instance$options$deb9;
|
|
264
326
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
// ): CellsRow<TGenerics> => {
|
|
277
|
-
// return {}
|
|
278
|
-
// },
|
|
279
|
-
createInstance: instance => {
|
|
280
|
-
return {
|
|
281
|
-
getRowId: (row, index, parent) => {
|
|
282
|
-
var _instance$options$get;
|
|
283
|
-
|
|
284
|
-
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);
|
|
285
|
-
},
|
|
286
|
-
createRow: (id, original, rowIndex, depth, subRows) => {
|
|
287
|
-
let row = {
|
|
288
|
-
id,
|
|
289
|
-
index: rowIndex,
|
|
290
|
-
original,
|
|
291
|
-
depth,
|
|
292
|
-
valuesCache: {},
|
|
293
|
-
getValue: columnId => {
|
|
294
|
-
if (row.valuesCache.hasOwnProperty(columnId)) {
|
|
295
|
-
return row.valuesCache[columnId];
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
const column = instance.getColumn(columnId);
|
|
299
|
-
|
|
300
|
-
if (!column.accessorFn) {
|
|
301
|
-
return undefined;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
row.valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
|
305
|
-
return row.valuesCache[columnId];
|
|
306
|
-
},
|
|
307
|
-
subRows: subRows != null ? subRows : [],
|
|
308
|
-
getLeafRows: () => flattenBy(row.subRows, d => d.subRows)
|
|
309
|
-
};
|
|
327
|
+
return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
|
|
328
|
+
}
|
|
329
|
+
}),
|
|
330
|
+
getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
|
|
331
|
+
return left.map(headerGroup => {
|
|
332
|
+
return headerGroup.headers;
|
|
333
|
+
}).flat();
|
|
334
|
+
}, {
|
|
335
|
+
key: process.env.NODE_ENV === 'development' && 'getLeftFlatHeaders',
|
|
336
|
+
debug: () => {
|
|
337
|
+
var _instance$options$deb10;
|
|
310
338
|
|
|
311
|
-
|
|
312
|
-
const feature = instance._features[i];
|
|
313
|
-
Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
|
|
339
|
+
return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
|
|
314
340
|
}
|
|
341
|
+
}),
|
|
342
|
+
getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
|
|
343
|
+
return left.map(headerGroup => {
|
|
344
|
+
return headerGroup.headers;
|
|
345
|
+
}).flat();
|
|
346
|
+
}, {
|
|
347
|
+
key: process.env.NODE_ENV === 'development' && 'getCenterFlatHeaders',
|
|
348
|
+
debug: () => {
|
|
349
|
+
var _instance$options$deb11;
|
|
315
350
|
|
|
316
|
-
|
|
317
|
-
},
|
|
318
|
-
getCoreRowModel: () => {
|
|
319
|
-
if (!instance._getCoreRowModel) {
|
|
320
|
-
instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
|
|
351
|
+
return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
|
|
321
352
|
}
|
|
353
|
+
}),
|
|
354
|
+
getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
|
|
355
|
+
return left.map(headerGroup => {
|
|
356
|
+
return headerGroup.headers;
|
|
357
|
+
}).flat();
|
|
358
|
+
}, {
|
|
359
|
+
key: process.env.NODE_ENV === 'development' && 'getRightFlatHeaders',
|
|
360
|
+
debug: () => {
|
|
361
|
+
var _instance$options$deb12;
|
|
322
362
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
//
|
|
327
|
-
|
|
328
|
-
return
|
|
329
|
-
|
|
330
|
-
getRow: id => {
|
|
331
|
-
const row = instance.getRowModel().rowsById[id];
|
|
363
|
+
return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
|
|
364
|
+
}
|
|
365
|
+
}),
|
|
366
|
+
// Leaf Headers
|
|
367
|
+
getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
|
|
368
|
+
return flatHeaders.filter(header => {
|
|
369
|
+
var _header$subHeaders;
|
|
332
370
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
371
|
+
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
|
372
|
+
});
|
|
373
|
+
}, {
|
|
374
|
+
key: process.env.NODE_ENV === 'development' && 'getCenterLeafHeaders',
|
|
375
|
+
debug: () => {
|
|
376
|
+
var _instance$options$deb13;
|
|
337
377
|
|
|
338
|
-
|
|
378
|
+
return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
|
|
339
379
|
}
|
|
380
|
+
}),
|
|
381
|
+
getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
|
|
382
|
+
return flatHeaders.filter(header => {
|
|
383
|
+
var _header$subHeaders2;
|
|
340
384
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
385
|
+
return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
|
|
386
|
+
});
|
|
387
|
+
}, {
|
|
388
|
+
key: process.env.NODE_ENV === 'development' && 'getLeftLeafHeaders',
|
|
389
|
+
debug: () => {
|
|
390
|
+
var _instance$options$deb14;
|
|
346
391
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
392
|
+
return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
|
|
393
|
+
}
|
|
394
|
+
}),
|
|
395
|
+
getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
|
|
396
|
+
return flatHeaders.filter(header => {
|
|
397
|
+
var _header$subHeaders3;
|
|
398
|
+
|
|
399
|
+
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
|
354
400
|
});
|
|
355
401
|
}, {
|
|
356
|
-
key: process.env.NODE_ENV === 'development' && '
|
|
402
|
+
key: process.env.NODE_ENV === 'development' && 'getRightLeafHeaders',
|
|
357
403
|
debug: () => {
|
|
358
|
-
var _instance$options$
|
|
404
|
+
var _instance$options$deb15;
|
|
359
405
|
|
|
360
|
-
return (_instance$options$
|
|
406
|
+
return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
|
|
361
407
|
}
|
|
362
408
|
}),
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
409
|
+
getLeafHeaders: memo(() => [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()], (left, center, right) => {
|
|
410
|
+
var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
|
|
411
|
+
|
|
412
|
+
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 => {
|
|
413
|
+
return header.getLeafHeaders();
|
|
414
|
+
}).flat();
|
|
368
415
|
}, {
|
|
369
|
-
key: process.env.NODE_ENV === '
|
|
416
|
+
key: process.env.NODE_ENV === 'development' && 'getLeafHeaders',
|
|
370
417
|
debug: () => {
|
|
371
|
-
var _instance$options$
|
|
418
|
+
var _instance$options$deb16;
|
|
372
419
|
|
|
373
|
-
return (_instance$options$
|
|
420
|
+
return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
|
|
374
421
|
}
|
|
375
422
|
})
|
|
376
423
|
};
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
const cell = {
|
|
382
|
-
id: row.id + "_" + column.id,
|
|
383
|
-
rowId: row.id,
|
|
384
|
-
columnId,
|
|
385
|
-
row,
|
|
386
|
-
column,
|
|
387
|
-
getValue: () => row.getValue(columnId),
|
|
388
|
-
renderCell: () => column.cell ? instance._render(column.cell, {
|
|
389
|
-
instance,
|
|
390
|
-
column,
|
|
391
|
-
row,
|
|
392
|
-
cell: cell,
|
|
393
|
-
getValue: cell.getValue
|
|
394
|
-
}) : null
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
instance._features.forEach(feature => {
|
|
398
|
-
Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
|
|
399
|
-
}, {});
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
|
|
427
|
+
var _headerGroups$0$heade, _headerGroups$;
|
|
400
428
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
429
|
+
// Find the max depth of the columns:
|
|
430
|
+
// build the leaf column row
|
|
431
|
+
// build each buffer row going up
|
|
432
|
+
// placeholder for non-existent level
|
|
433
|
+
// real column for existing level
|
|
434
|
+
let maxDepth = 0;
|
|
405
435
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
436
|
+
const findMaxDepth = function (columns, depth) {
|
|
437
|
+
if (depth === void 0) {
|
|
438
|
+
depth = 1;
|
|
439
|
+
}
|
|
410
440
|
|
|
411
|
-
|
|
412
|
-
|
|
441
|
+
maxDepth = Math.max(maxDepth, depth);
|
|
442
|
+
columns.filter(column => column.getIsVisible()).forEach(column => {
|
|
443
|
+
var _column$columns;
|
|
413
444
|
|
|
414
|
-
|
|
445
|
+
if ((_column$columns = column.columns) != null && _column$columns.length) {
|
|
446
|
+
findMaxDepth(column.columns, depth + 1);
|
|
447
|
+
}
|
|
448
|
+
}, 0);
|
|
449
|
+
};
|
|
415
450
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
throw new Error("[Table] could not find cell " + columnId + " in row " + rowId);
|
|
419
|
-
}
|
|
451
|
+
findMaxDepth(allColumns);
|
|
452
|
+
let headerGroups = [];
|
|
420
453
|
|
|
421
|
-
|
|
422
|
-
|
|
454
|
+
const createHeaderGroup = (headersToGroup, depth) => {
|
|
455
|
+
// The header group we are creating
|
|
456
|
+
const headerGroup = {
|
|
457
|
+
depth,
|
|
458
|
+
id: [headerFamily, "" + depth].filter(Boolean).join('_'),
|
|
459
|
+
headers: []
|
|
460
|
+
}; // The parent columns we're going to scan next
|
|
461
|
+
|
|
462
|
+
const pendingParentHeaders = []; // Scan each column for parents
|
|
423
463
|
|
|
424
|
-
|
|
464
|
+
headersToGroup.forEach(headerToGroup => {
|
|
465
|
+
// What is the latest (last) parent column?
|
|
466
|
+
const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
|
|
467
|
+
const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
|
|
468
|
+
let column;
|
|
469
|
+
let isPlaceholder = false;
|
|
470
|
+
|
|
471
|
+
if (isLeafHeader && headerToGroup.column.parent) {
|
|
472
|
+
// The parent header is new
|
|
473
|
+
column = headerToGroup.column.parent;
|
|
474
|
+
} else {
|
|
475
|
+
// The parent header is repeated
|
|
476
|
+
column = headerToGroup.column;
|
|
477
|
+
isPlaceholder = true;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
|
|
481
|
+
// This column is repeated. Add it as a sub header to the next batch
|
|
482
|
+
latestPendingParentHeader.subHeaders.push(headerToGroup);
|
|
483
|
+
} else {
|
|
484
|
+
// This is a new header. Let's create it
|
|
485
|
+
const header = createHeader(instance, column, {
|
|
486
|
+
id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
|
|
487
|
+
isPlaceholder,
|
|
488
|
+
placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
|
|
489
|
+
depth,
|
|
490
|
+
index: pendingParentHeaders.length
|
|
491
|
+
}); // Add the headerToGroup as a subHeader of the new header
|
|
492
|
+
|
|
493
|
+
header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
|
|
494
|
+
// in the next batch
|
|
495
|
+
|
|
496
|
+
pendingParentHeaders.push(header);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
headerGroup.headers.push(headerToGroup);
|
|
500
|
+
headerToGroup.headerGroup = headerGroup;
|
|
501
|
+
});
|
|
502
|
+
headerGroups.push(headerGroup);
|
|
503
|
+
|
|
504
|
+
if (depth > 0) {
|
|
505
|
+
createHeaderGroup(pendingParentHeaders, depth - 1);
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
const bottomHeaders = columnsToGroup.map((column, index) => createHeader(instance, column, {
|
|
510
|
+
depth: maxDepth,
|
|
511
|
+
index
|
|
512
|
+
}));
|
|
513
|
+
createHeaderGroup(bottomHeaders, maxDepth - 1);
|
|
514
|
+
headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
|
|
515
|
+
// return !headerGroup.headers.every(header => header.isPlaceholder)
|
|
516
|
+
// })
|
|
517
|
+
|
|
518
|
+
const recurseHeadersForSpans = headers => {
|
|
519
|
+
const filteredHeaders = headers.filter(header => header.column.getIsVisible());
|
|
520
|
+
return filteredHeaders.map(header => {
|
|
521
|
+
let colSpan = 0;
|
|
522
|
+
let rowSpan = 0;
|
|
523
|
+
let childRowSpans = [0];
|
|
524
|
+
|
|
525
|
+
if (header.subHeaders && header.subHeaders.length) {
|
|
526
|
+
childRowSpans = [];
|
|
527
|
+
recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
|
|
528
|
+
let {
|
|
529
|
+
colSpan: childColSpan,
|
|
530
|
+
rowSpan: childRowSpan
|
|
531
|
+
} = _ref;
|
|
532
|
+
colSpan += childColSpan;
|
|
533
|
+
childRowSpans.push(childRowSpan);
|
|
534
|
+
});
|
|
535
|
+
} else {
|
|
536
|
+
colSpan = 1;
|
|
425
537
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
538
|
+
|
|
539
|
+
const minChildRowSpan = Math.min(...childRowSpans);
|
|
540
|
+
rowSpan = rowSpan + minChildRowSpan;
|
|
541
|
+
header.colSpan = colSpan;
|
|
542
|
+
header.rowSpan = rowSpan;
|
|
543
|
+
return {
|
|
544
|
+
colSpan,
|
|
545
|
+
rowSpan
|
|
546
|
+
};
|
|
547
|
+
});
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
|
|
551
|
+
return headerGroups;
|
|
552
|
+
}
|
|
429
553
|
|
|
430
554
|
//
|
|
431
555
|
const defaultColumnSizing = {
|
|
@@ -444,7 +568,7 @@ const getDefaultColumnSizingInfoState = () => ({
|
|
|
444
568
|
});
|
|
445
569
|
|
|
446
570
|
const ColumnSizing = {
|
|
447
|
-
|
|
571
|
+
getDefaultColumnDef: () => {
|
|
448
572
|
return defaultColumnSizing;
|
|
449
573
|
},
|
|
450
574
|
getInitialState: state => {
|
|
@@ -464,10 +588,10 @@ const ColumnSizing = {
|
|
|
464
588
|
createColumn: (column, instance) => {
|
|
465
589
|
return {
|
|
466
590
|
getSize: () => {
|
|
467
|
-
var _column$
|
|
591
|
+
var _column$columnDef$min, _ref, _column$columnDef$max;
|
|
468
592
|
|
|
469
593
|
const columnSize = instance.getState().columnSizing[column.id];
|
|
470
|
-
return Math.min(Math.max((_column$
|
|
594
|
+
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);
|
|
471
595
|
},
|
|
472
596
|
getStart: position => {
|
|
473
597
|
const columns = !position ? instance.getVisibleLeafColumns() : position === 'left' ? instance.getLeftVisibleLeafColumns() : instance.getRightVisibleLeafColumns();
|
|
@@ -490,9 +614,9 @@ const ColumnSizing = {
|
|
|
490
614
|
});
|
|
491
615
|
},
|
|
492
616
|
getCanResize: () => {
|
|
493
|
-
var _column$
|
|
617
|
+
var _column$columnDef$ena, _instance$options$ena;
|
|
494
618
|
|
|
495
|
-
return ((_column$
|
|
619
|
+
return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_instance$options$ena = instance.options.enableColumnResizing) != null ? _instance$options$ena : true);
|
|
496
620
|
},
|
|
497
621
|
getIsResizing: () => {
|
|
498
622
|
return instance.getState().columnSizingInfo.isResizingColumn === column.id;
|
|
@@ -949,7 +1073,7 @@ function testFalsey(val) {
|
|
|
949
1073
|
|
|
950
1074
|
//
|
|
951
1075
|
const Filters = {
|
|
952
|
-
|
|
1076
|
+
getDefaultColumnDef: () => {
|
|
953
1077
|
return {
|
|
954
1078
|
filterFn: 'auto'
|
|
955
1079
|
};
|
|
@@ -972,7 +1096,7 @@ const Filters = {
|
|
|
972
1096
|
getColumnCanGlobalFilter: column => {
|
|
973
1097
|
var _instance$getCoreRowM, _instance$getCoreRowM2;
|
|
974
1098
|
|
|
975
|
-
const value = (_instance$getCoreRowM = instance.getCoreRowModel().flatRows[0]) == null ? void 0 : (_instance$getCoreRowM2 = _instance$getCoreRowM.
|
|
1099
|
+
const value = (_instance$getCoreRowM = instance.getCoreRowModel().flatRows[0]) == null ? void 0 : (_instance$getCoreRowM2 = _instance$getCoreRowM._getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreRowM2.getValue();
|
|
976
1100
|
return typeof value === 'string';
|
|
977
1101
|
}
|
|
978
1102
|
};
|
|
@@ -992,6 +1116,10 @@ const Filters = {
|
|
|
992
1116
|
return filterFns.inNumberRange;
|
|
993
1117
|
}
|
|
994
1118
|
|
|
1119
|
+
if (typeof value === 'boolean') {
|
|
1120
|
+
return filterFns.equals;
|
|
1121
|
+
}
|
|
1122
|
+
|
|
995
1123
|
if (value !== null && typeof value === 'object') {
|
|
996
1124
|
return filterFns.equals;
|
|
997
1125
|
}
|
|
@@ -1009,14 +1137,14 @@ const Filters = {
|
|
|
1009
1137
|
return isFunction(column.filterFn) ? column.filterFn : column.filterFn === 'auto' ? column.getAutoFilterFn() : (_ref = userFilterFns == null ? void 0 : userFilterFns[column.filterFn]) != null ? _ref : filterFns[column.filterFn];
|
|
1010
1138
|
},
|
|
1011
1139
|
getCanFilter: () => {
|
|
1012
|
-
var _column$
|
|
1140
|
+
var _column$columnDef$ena, _instance$options$ena, _instance$options$ena2;
|
|
1013
1141
|
|
|
1014
|
-
return ((_column$
|
|
1142
|
+
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;
|
|
1015
1143
|
},
|
|
1016
1144
|
getCanGlobalFilter: () => {
|
|
1017
|
-
var _column$
|
|
1145
|
+
var _column$columnDef$ena2, _instance$options$ena3, _instance$options$ena4, _instance$options$get;
|
|
1018
1146
|
|
|
1019
|
-
return ((_column$
|
|
1147
|
+
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;
|
|
1020
1148
|
},
|
|
1021
1149
|
getIsFiltered: () => column.getFilterIndex() > -1,
|
|
1022
1150
|
getFilterValue: () => {
|
|
@@ -1095,7 +1223,8 @@ const Filters = {
|
|
|
1095
1223
|
},
|
|
1096
1224
|
createRow: (row, instance) => {
|
|
1097
1225
|
return {
|
|
1098
|
-
|
|
1226
|
+
columnFilters: {},
|
|
1227
|
+
columnFiltersMeta: {},
|
|
1099
1228
|
subRowsByFacetId: {}
|
|
1100
1229
|
};
|
|
1101
1230
|
},
|
|
@@ -1293,7 +1422,7 @@ function count(getLeafValues) {
|
|
|
1293
1422
|
|
|
1294
1423
|
//
|
|
1295
1424
|
const Grouping = {
|
|
1296
|
-
|
|
1425
|
+
getDefaultColumnDef: () => {
|
|
1297
1426
|
return {
|
|
1298
1427
|
aggregationFn: 'auto'
|
|
1299
1428
|
};
|
|
@@ -1323,9 +1452,9 @@ const Grouping = {
|
|
|
1323
1452
|
});
|
|
1324
1453
|
},
|
|
1325
1454
|
getCanGroup: () => {
|
|
1326
|
-
var _ref, _ref2, _ref3, _column$
|
|
1455
|
+
var _ref, _ref2, _ref3, _column$columnDef$ena;
|
|
1327
1456
|
|
|
1328
|
-
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;
|
|
1329
1458
|
},
|
|
1330
1459
|
getIsGrouped: () => {
|
|
1331
1460
|
var _instance$getState$gr;
|
|
@@ -1409,9 +1538,9 @@ const Grouping = {
|
|
|
1409
1538
|
return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
|
|
1410
1539
|
},
|
|
1411
1540
|
renderAggregatedCell: () => {
|
|
1412
|
-
var _column$
|
|
1541
|
+
var _column$columnDef$agg;
|
|
1413
1542
|
|
|
1414
|
-
const template = (_column$
|
|
1543
|
+
const template = (_column$columnDef$agg = column.columnDef.aggregatedCell) != null ? _column$columnDef$agg : column.columnDef.cell;
|
|
1415
1544
|
return template ? instance._render(template, {
|
|
1416
1545
|
instance,
|
|
1417
1546
|
column,
|
|
@@ -1718,9 +1847,9 @@ const Pinning = {
|
|
|
1718
1847
|
getCanPin: () => {
|
|
1719
1848
|
const leafColumns = column.getLeafColumns();
|
|
1720
1849
|
return leafColumns.some(d => {
|
|
1721
|
-
var _d$
|
|
1850
|
+
var _d$columnDef$enablePi, _instance$options$ena;
|
|
1722
1851
|
|
|
1723
|
-
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);
|
|
1724
1853
|
});
|
|
1725
1854
|
},
|
|
1726
1855
|
getIsPinned: () => {
|
|
@@ -1745,7 +1874,7 @@ const Pinning = {
|
|
|
1745
1874
|
return {
|
|
1746
1875
|
getCenterVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allCells, left, right) => {
|
|
1747
1876
|
const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
|
|
1748
|
-
return allCells.filter(d => !leftAndRight.includes(d.
|
|
1877
|
+
return allCells.filter(d => !leftAndRight.includes(d.column.id));
|
|
1749
1878
|
}, {
|
|
1750
1879
|
key: process.env.NODE_ENV === 'production' && 'row.getCenterVisibleCells',
|
|
1751
1880
|
debug: () => {
|
|
@@ -1755,7 +1884,7 @@ const Pinning = {
|
|
|
1755
1884
|
}
|
|
1756
1885
|
}),
|
|
1757
1886
|
getLeftVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left,,], (allCells, left) => {
|
|
1758
|
-
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,
|
|
1759
1888
|
position: 'left'
|
|
1760
1889
|
}));
|
|
1761
1890
|
return cells;
|
|
@@ -1768,7 +1897,7 @@ const Pinning = {
|
|
|
1768
1897
|
}
|
|
1769
1898
|
}),
|
|
1770
1899
|
getRightVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.right], (allCells, right) => {
|
|
1771
|
-
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,
|
|
1772
1901
|
position: 'left'
|
|
1773
1902
|
}));
|
|
1774
1903
|
return cells;
|
|
@@ -1790,12 +1919,18 @@ const Pinning = {
|
|
|
1790
1919
|
|
|
1791
1920
|
return instance.setColumnPinning(defaultState ? getDefaultPinningState() : (_instance$initialStat = (_instance$initialStat2 = instance.initialState) == null ? void 0 : _instance$initialStat2.columnPinning) != null ? _instance$initialStat : getDefaultPinningState());
|
|
1792
1921
|
},
|
|
1793
|
-
getIsSomeColumnsPinned:
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
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);
|
|
1799
1934
|
},
|
|
1800
1935
|
getLeftLeafColumns: memo(() => [instance.getAllLeafColumns(), instance.getState().columnPinning.left], (allColumns, left) => {
|
|
1801
1936
|
return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
|
|
@@ -2321,7 +2456,7 @@ const Sorting = {
|
|
|
2321
2456
|
...state
|
|
2322
2457
|
};
|
|
2323
2458
|
},
|
|
2324
|
-
|
|
2459
|
+
getDefaultColumnDef: () => {
|
|
2325
2460
|
return {
|
|
2326
2461
|
sortingFn: 'auto'
|
|
2327
2462
|
};
|
|
@@ -2337,7 +2472,7 @@ const Sorting = {
|
|
|
2337
2472
|
createColumn: (column, instance) => {
|
|
2338
2473
|
return {
|
|
2339
2474
|
getAutoSortingFn: () => {
|
|
2340
|
-
const firstRows = instance.getFilteredRowModel().flatRows.slice(
|
|
2475
|
+
const firstRows = instance.getFilteredRowModel().flatRows.slice(10);
|
|
2341
2476
|
let isString = false;
|
|
2342
2477
|
|
|
2343
2478
|
for (const row of firstRows) {
|
|
@@ -2381,7 +2516,7 @@ const Sorting = {
|
|
|
2381
2516
|
throw new Error();
|
|
2382
2517
|
}
|
|
2383
2518
|
|
|
2384
|
-
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];
|
|
2385
2520
|
},
|
|
2386
2521
|
toggleSorting: (desc, multi) => {
|
|
2387
2522
|
// if (column.columns.length) {
|
|
@@ -2393,7 +2528,7 @@ const Sorting = {
|
|
|
2393
2528
|
// return
|
|
2394
2529
|
// }
|
|
2395
2530
|
instance.setSorting(old => {
|
|
2396
|
-
var _ref2, _column$
|
|
2531
|
+
var _ref2, _column$columnDef$sor, _instance$options$ena, _instance$options$ena2;
|
|
2397
2532
|
|
|
2398
2533
|
// Find any existing sorting for this column
|
|
2399
2534
|
const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
|
|
@@ -2420,7 +2555,7 @@ const Sorting = {
|
|
|
2420
2555
|
}
|
|
2421
2556
|
}
|
|
2422
2557
|
|
|
2423
|
-
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
|
|
2424
2559
|
|
|
2425
2560
|
if (sortAction === 'toggle' && ( // Must be toggling
|
|
2426
2561
|
(_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
|
|
@@ -2464,14 +2599,14 @@ const Sorting = {
|
|
|
2464
2599
|
});
|
|
2465
2600
|
},
|
|
2466
2601
|
getCanSort: () => {
|
|
2467
|
-
var _column$
|
|
2602
|
+
var _column$columnDef$ena, _instance$options$ena3;
|
|
2468
2603
|
|
|
2469
|
-
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;
|
|
2470
2605
|
},
|
|
2471
2606
|
getCanMultiSort: () => {
|
|
2472
|
-
var _ref3, _column$
|
|
2607
|
+
var _ref3, _column$columnDef$ena2;
|
|
2473
2608
|
|
|
2474
|
-
return (_ref3 = (_column$
|
|
2609
|
+
return (_ref3 = (_column$columnDef$ena2 = column.columnDef.enableMultiSort) != null ? _column$columnDef$ena2 : instance.options.enableMultiSort) != null ? _ref3 : !!column.accessorFn;
|
|
2475
2610
|
},
|
|
2476
2611
|
getIsSorted: () => {
|
|
2477
2612
|
var _instance$getState$so;
|
|
@@ -2535,7 +2670,7 @@ const Visibility = {
|
|
|
2535
2670
|
onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
|
|
2536
2671
|
};
|
|
2537
2672
|
},
|
|
2538
|
-
|
|
2673
|
+
getDefaultColumnDef: () => {
|
|
2539
2674
|
return {
|
|
2540
2675
|
defaultIsVisible: true
|
|
2541
2676
|
};
|
|
@@ -2555,9 +2690,9 @@ const Visibility = {
|
|
|
2555
2690
|
return (_instance$getState$co = (_instance$getState$co2 = instance.getState().columnVisibility) == null ? void 0 : _instance$getState$co2[column.id]) != null ? _instance$getState$co : true;
|
|
2556
2691
|
},
|
|
2557
2692
|
getCanHide: () => {
|
|
2558
|
-
var _column$
|
|
2693
|
+
var _column$columnDef$ena, _instance$options$ena;
|
|
2559
2694
|
|
|
2560
|
-
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);
|
|
2561
2696
|
},
|
|
2562
2697
|
getToggleVisibilityHandler: () => {
|
|
2563
2698
|
return e => {
|
|
@@ -2573,475 +2708,70 @@ const Visibility = {
|
|
|
2573
2708
|
}, {
|
|
2574
2709
|
key: process.env.NODE_ENV === 'production' && 'row._getAllVisibleCells',
|
|
2575
2710
|
debug: () => {
|
|
2576
|
-
var _instance$options$deb;
|
|
2577
|
-
|
|
2578
|
-
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
|
|
2579
|
-
}
|
|
2580
|
-
}),
|
|
2581
|
-
getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
|
|
2582
|
-
key: process.env.NODE_ENV === 'development' && 'row.getVisibleCells',
|
|
2583
|
-
debug: () => {
|
|
2584
|
-
var _instance$options$deb2;
|
|
2585
|
-
|
|
2586
|
-
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
|
|
2587
|
-
}
|
|
2588
|
-
})
|
|
2589
|
-
};
|
|
2590
|
-
},
|
|
2591
|
-
createInstance: instance => {
|
|
2592
|
-
const makeVisibleColumnsMethod = (key, getColumns) => {
|
|
2593
|
-
return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
|
|
2594
|
-
return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
|
|
2595
|
-
}, {
|
|
2596
|
-
key,
|
|
2597
|
-
debug: () => {
|
|
2598
|
-
var _instance$options$deb3;
|
|
2599
|
-
|
|
2600
|
-
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
2601
|
-
}
|
|
2602
|
-
});
|
|
2603
|
-
};
|
|
2604
|
-
|
|
2605
|
-
return {
|
|
2606
|
-
getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
|
|
2607
|
-
getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
|
|
2608
|
-
getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
|
|
2609
|
-
getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
|
|
2610
|
-
getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
|
|
2611
|
-
setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
|
|
2612
|
-
resetColumnVisibility: defaultState => {
|
|
2613
|
-
var _instance$initialStat;
|
|
2614
|
-
|
|
2615
|
-
instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
|
|
2616
|
-
},
|
|
2617
|
-
toggleAllColumnsVisible: value => {
|
|
2618
|
-
var _value;
|
|
2619
|
-
|
|
2620
|
-
value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
|
|
2621
|
-
instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
|
|
2622
|
-
[column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
|
|
2623
|
-
}), {}));
|
|
2624
|
-
},
|
|
2625
|
-
getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
|
|
2626
|
-
getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
|
|
2627
|
-
getToggleAllColumnsVisibilityHandler: () => {
|
|
2628
|
-
return e => {
|
|
2629
|
-
var _target;
|
|
2630
|
-
|
|
2631
|
-
instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
|
|
2632
|
-
};
|
|
2633
|
-
}
|
|
2634
|
-
};
|
|
2635
|
-
}
|
|
2636
|
-
};
|
|
2637
|
-
|
|
2638
|
-
//
|
|
2639
|
-
const Headers = {
|
|
2640
|
-
createInstance: instance => {
|
|
2641
|
-
return {
|
|
2642
|
-
createHeader: (column, options) => {
|
|
2643
|
-
var _options$id;
|
|
2644
|
-
|
|
2645
|
-
const id = (_options$id = options.id) != null ? _options$id : column.id;
|
|
2646
|
-
let header = {
|
|
2647
|
-
id,
|
|
2648
|
-
column,
|
|
2649
|
-
index: options.index,
|
|
2650
|
-
isPlaceholder: options.isPlaceholder,
|
|
2651
|
-
placeholderId: options.placeholderId,
|
|
2652
|
-
depth: options.depth,
|
|
2653
|
-
subHeaders: [],
|
|
2654
|
-
colSpan: 0,
|
|
2655
|
-
rowSpan: 0,
|
|
2656
|
-
headerGroup: null,
|
|
2657
|
-
getLeafHeaders: () => {
|
|
2658
|
-
const leafHeaders = [];
|
|
2659
|
-
|
|
2660
|
-
const recurseHeader = h => {
|
|
2661
|
-
if (h.subHeaders && h.subHeaders.length) {
|
|
2662
|
-
h.subHeaders.map(recurseHeader);
|
|
2663
|
-
}
|
|
2664
|
-
|
|
2665
|
-
leafHeaders.push(h);
|
|
2666
|
-
};
|
|
2667
|
-
|
|
2668
|
-
recurseHeader(header);
|
|
2669
|
-
return leafHeaders;
|
|
2670
|
-
},
|
|
2671
|
-
renderHeader: () => column.header ? instance._render(column.header, {
|
|
2672
|
-
instance,
|
|
2673
|
-
header: header,
|
|
2674
|
-
column
|
|
2675
|
-
}) : null,
|
|
2676
|
-
renderFooter: () => column.footer ? instance._render(column.footer, {
|
|
2677
|
-
instance,
|
|
2678
|
-
header: header,
|
|
2679
|
-
column
|
|
2680
|
-
}) : null
|
|
2681
|
-
};
|
|
2682
|
-
|
|
2683
|
-
instance._features.forEach(feature => {
|
|
2684
|
-
Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
|
|
2685
|
-
});
|
|
2686
|
-
|
|
2687
|
-
return header;
|
|
2688
|
-
},
|
|
2689
|
-
// Header Groups
|
|
2690
|
-
getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
2691
|
-
var _left$map$filter, _right$map$filter;
|
|
2692
|
-
|
|
2693
|
-
const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
|
|
2694
|
-
const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
|
|
2695
|
-
const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
2696
|
-
const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
|
|
2697
|
-
return headerGroups;
|
|
2698
|
-
}, {
|
|
2699
|
-
key: process.env.NODE_ENV === 'development' && 'getHeaderGroups',
|
|
2700
|
-
debug: () => {
|
|
2701
|
-
var _instance$options$deb;
|
|
2702
|
-
|
|
2703
|
-
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
|
|
2704
|
-
}
|
|
2705
|
-
}),
|
|
2706
|
-
getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
2707
|
-
leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
2708
|
-
return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
|
|
2709
|
-
}, {
|
|
2710
|
-
key: process.env.NODE_ENV === 'development' && 'getCenterHeaderGroups',
|
|
2711
|
-
debug: () => {
|
|
2712
|
-
var _instance$options$deb2;
|
|
2713
|
-
|
|
2714
|
-
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
|
|
2715
|
-
}
|
|
2716
|
-
}),
|
|
2717
|
-
getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
2718
|
-
var _left$map$filter2;
|
|
2719
|
-
|
|
2720
|
-
const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
|
|
2721
|
-
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
|
|
2722
|
-
}, {
|
|
2723
|
-
key: process.env.NODE_ENV === 'development' && 'getLeftHeaderGroups',
|
|
2724
|
-
debug: () => {
|
|
2725
|
-
var _instance$options$deb3;
|
|
2726
|
-
|
|
2727
|
-
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
|
|
2728
|
-
}
|
|
2729
|
-
}),
|
|
2730
|
-
getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
2731
|
-
var _right$map$filter2;
|
|
2732
|
-
|
|
2733
|
-
const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
|
|
2734
|
-
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
|
|
2735
|
-
}, {
|
|
2736
|
-
key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
|
|
2737
|
-
debug: () => {
|
|
2738
|
-
var _instance$options$deb4;
|
|
2739
|
-
|
|
2740
|
-
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
|
|
2741
|
-
}
|
|
2742
|
-
}),
|
|
2743
|
-
// Footer Groups
|
|
2744
|
-
getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
2745
|
-
return [...headerGroups].reverse();
|
|
2746
|
-
}, {
|
|
2747
|
-
key: process.env.NODE_ENV === 'development' && 'getFooterGroups',
|
|
2748
|
-
debug: () => {
|
|
2749
|
-
var _instance$options$deb5;
|
|
2750
|
-
|
|
2751
|
-
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
|
|
2752
|
-
}
|
|
2753
|
-
}),
|
|
2754
|
-
getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
|
|
2755
|
-
return [...headerGroups].reverse();
|
|
2756
|
-
}, {
|
|
2757
|
-
key: process.env.NODE_ENV === 'development' && 'getLeftFooterGroups',
|
|
2758
|
-
debug: () => {
|
|
2759
|
-
var _instance$options$deb6;
|
|
2760
|
-
|
|
2761
|
-
return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
|
|
2762
|
-
}
|
|
2763
|
-
}),
|
|
2764
|
-
getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
|
|
2765
|
-
return [...headerGroups].reverse();
|
|
2766
|
-
}, {
|
|
2767
|
-
key: process.env.NODE_ENV === 'development' && 'getCenterFooterGroups',
|
|
2768
|
-
debug: () => {
|
|
2769
|
-
var _instance$options$deb7;
|
|
2770
|
-
|
|
2771
|
-
return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
|
|
2772
|
-
}
|
|
2773
|
-
}),
|
|
2774
|
-
getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
|
|
2775
|
-
return [...headerGroups].reverse();
|
|
2776
|
-
}, {
|
|
2777
|
-
key: process.env.NODE_ENV === 'development' && 'getRightFooterGroups',
|
|
2778
|
-
debug: () => {
|
|
2779
|
-
var _instance$options$deb8;
|
|
2780
|
-
|
|
2781
|
-
return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
|
|
2782
|
-
}
|
|
2783
|
-
}),
|
|
2784
|
-
// Flat Headers
|
|
2785
|
-
getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
2786
|
-
return headerGroups.map(headerGroup => {
|
|
2787
|
-
return headerGroup.headers;
|
|
2788
|
-
}).flat();
|
|
2789
|
-
}, {
|
|
2790
|
-
key: process.env.NODE_ENV === 'development' && 'getFlatHeaders',
|
|
2791
|
-
debug: () => {
|
|
2792
|
-
var _instance$options$deb9;
|
|
2793
|
-
|
|
2794
|
-
return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
|
|
2795
|
-
}
|
|
2796
|
-
}),
|
|
2797
|
-
getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
|
|
2798
|
-
return left.map(headerGroup => {
|
|
2799
|
-
return headerGroup.headers;
|
|
2800
|
-
}).flat();
|
|
2801
|
-
}, {
|
|
2802
|
-
key: process.env.NODE_ENV === 'development' && 'getLeftFlatHeaders',
|
|
2803
|
-
debug: () => {
|
|
2804
|
-
var _instance$options$deb10;
|
|
2805
|
-
|
|
2806
|
-
return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
|
|
2807
|
-
}
|
|
2808
|
-
}),
|
|
2809
|
-
getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
|
|
2810
|
-
return left.map(headerGroup => {
|
|
2811
|
-
return headerGroup.headers;
|
|
2812
|
-
}).flat();
|
|
2813
|
-
}, {
|
|
2814
|
-
key: process.env.NODE_ENV === 'development' && 'getCenterFlatHeaders',
|
|
2815
|
-
debug: () => {
|
|
2816
|
-
var _instance$options$deb11;
|
|
2817
|
-
|
|
2818
|
-
return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
|
|
2819
|
-
}
|
|
2820
|
-
}),
|
|
2821
|
-
getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
|
|
2822
|
-
return left.map(headerGroup => {
|
|
2823
|
-
return headerGroup.headers;
|
|
2824
|
-
}).flat();
|
|
2825
|
-
}, {
|
|
2826
|
-
key: process.env.NODE_ENV === 'development' && 'getRightFlatHeaders',
|
|
2827
|
-
debug: () => {
|
|
2828
|
-
var _instance$options$deb12;
|
|
2829
|
-
|
|
2830
|
-
return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
|
|
2831
|
-
}
|
|
2832
|
-
}),
|
|
2833
|
-
// Leaf Headers
|
|
2834
|
-
getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
|
|
2835
|
-
return flatHeaders.filter(header => {
|
|
2836
|
-
var _header$subHeaders;
|
|
2837
|
-
|
|
2838
|
-
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
|
2839
|
-
});
|
|
2840
|
-
}, {
|
|
2841
|
-
key: process.env.NODE_ENV === 'development' && 'getCenterLeafHeaders',
|
|
2842
|
-
debug: () => {
|
|
2843
|
-
var _instance$options$deb13;
|
|
2844
|
-
|
|
2845
|
-
return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
|
|
2846
|
-
}
|
|
2847
|
-
}),
|
|
2848
|
-
getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
|
|
2849
|
-
return flatHeaders.filter(header => {
|
|
2850
|
-
var _header$subHeaders2;
|
|
2851
|
-
|
|
2852
|
-
return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
|
|
2853
|
-
});
|
|
2854
|
-
}, {
|
|
2855
|
-
key: process.env.NODE_ENV === 'development' && 'getLeftLeafHeaders',
|
|
2856
|
-
debug: () => {
|
|
2857
|
-
var _instance$options$deb14;
|
|
2858
|
-
|
|
2859
|
-
return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
|
|
2860
|
-
}
|
|
2861
|
-
}),
|
|
2862
|
-
getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
|
|
2863
|
-
return flatHeaders.filter(header => {
|
|
2864
|
-
var _header$subHeaders3;
|
|
2865
|
-
|
|
2866
|
-
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
|
2867
|
-
});
|
|
2868
|
-
}, {
|
|
2869
|
-
key: process.env.NODE_ENV === 'development' && 'getRightLeafHeaders',
|
|
2870
|
-
debug: () => {
|
|
2871
|
-
var _instance$options$deb15;
|
|
2711
|
+
var _instance$options$deb;
|
|
2872
2712
|
|
|
2873
|
-
return (_instance$options$
|
|
2713
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
|
|
2874
2714
|
}
|
|
2875
2715
|
}),
|
|
2876
|
-
|
|
2877
|
-
|
|
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;
|
|
2878
2720
|
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
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());
|
|
2882
2730
|
}, {
|
|
2883
|
-
key
|
|
2731
|
+
key,
|
|
2884
2732
|
debug: () => {
|
|
2885
|
-
var _instance$options$
|
|
2733
|
+
var _instance$options$deb3;
|
|
2886
2734
|
|
|
2887
|
-
return (_instance$options$
|
|
2735
|
+
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
2888
2736
|
}
|
|
2889
|
-
})
|
|
2890
|
-
|
|
2891
|
-
const header = [...instance.getFlatHeaders(), ...instance.getCenterFlatHeaders(), ...instance.getLeftFlatHeaders(), ...instance.getRightFlatHeaders()].find(d => d.id === id);
|
|
2737
|
+
});
|
|
2738
|
+
};
|
|
2892
2739
|
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
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;
|
|
2897
2749
|
|
|
2898
|
-
|
|
2899
|
-
|
|
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;
|
|
2900
2765
|
|
|
2901
|
-
|
|
2766
|
+
instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
|
|
2767
|
+
};
|
|
2902
2768
|
}
|
|
2903
2769
|
};
|
|
2904
2770
|
}
|
|
2905
2771
|
};
|
|
2906
|
-
function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
|
|
2907
|
-
var _headerGroups$0$heade, _headerGroups$;
|
|
2908
|
-
|
|
2909
|
-
// Find the max depth of the columns:
|
|
2910
|
-
// build the leaf column row
|
|
2911
|
-
// build each buffer row going up
|
|
2912
|
-
// placeholder for non-existent level
|
|
2913
|
-
// real column for existing level
|
|
2914
|
-
let maxDepth = 0;
|
|
2915
|
-
|
|
2916
|
-
const findMaxDepth = function (columns, depth) {
|
|
2917
|
-
if (depth === void 0) {
|
|
2918
|
-
depth = 1;
|
|
2919
|
-
}
|
|
2920
|
-
|
|
2921
|
-
maxDepth = Math.max(maxDepth, depth);
|
|
2922
|
-
columns.filter(column => column.getIsVisible()).forEach(column => {
|
|
2923
|
-
var _column$columns;
|
|
2924
|
-
|
|
2925
|
-
if ((_column$columns = column.columns) != null && _column$columns.length) {
|
|
2926
|
-
findMaxDepth(column.columns, depth + 1);
|
|
2927
|
-
}
|
|
2928
|
-
}, 0);
|
|
2929
|
-
};
|
|
2930
|
-
|
|
2931
|
-
findMaxDepth(allColumns);
|
|
2932
|
-
let headerGroups = [];
|
|
2933
|
-
|
|
2934
|
-
const createHeaderGroup = (headersToGroup, depth) => {
|
|
2935
|
-
// The header group we are creating
|
|
2936
|
-
const headerGroup = {
|
|
2937
|
-
depth,
|
|
2938
|
-
id: [headerFamily, "" + depth].filter(Boolean).join('_'),
|
|
2939
|
-
headers: []
|
|
2940
|
-
}; // The parent columns we're going to scan next
|
|
2941
|
-
|
|
2942
|
-
const pendingParentHeaders = []; // Scan each column for parents
|
|
2943
|
-
|
|
2944
|
-
headersToGroup.forEach(headerToGroup => {
|
|
2945
|
-
// What is the latest (last) parent column?
|
|
2946
|
-
const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
|
|
2947
|
-
const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
|
|
2948
|
-
let column;
|
|
2949
|
-
let isPlaceholder = false;
|
|
2950
|
-
|
|
2951
|
-
if (isLeafHeader && headerToGroup.column.parent) {
|
|
2952
|
-
// The parent header is new
|
|
2953
|
-
column = headerToGroup.column.parent;
|
|
2954
|
-
} else {
|
|
2955
|
-
// The parent header is repeated
|
|
2956
|
-
column = headerToGroup.column;
|
|
2957
|
-
isPlaceholder = true;
|
|
2958
|
-
}
|
|
2959
|
-
|
|
2960
|
-
if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
|
|
2961
|
-
// This column is repeated. Add it as a sub header to the next batch
|
|
2962
|
-
latestPendingParentHeader.subHeaders.push(headerToGroup);
|
|
2963
|
-
} else {
|
|
2964
|
-
// This is a new header. Let's create it
|
|
2965
|
-
const header = instance.createHeader(column, {
|
|
2966
|
-
id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
|
|
2967
|
-
isPlaceholder,
|
|
2968
|
-
placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
|
|
2969
|
-
depth,
|
|
2970
|
-
index: pendingParentHeaders.length
|
|
2971
|
-
}); // Add the headerToGroup as a subHeader of the new header
|
|
2972
|
-
|
|
2973
|
-
header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
|
|
2974
|
-
// in the next batch
|
|
2975
|
-
|
|
2976
|
-
pendingParentHeaders.push(header);
|
|
2977
|
-
}
|
|
2978
|
-
|
|
2979
|
-
headerGroup.headers.push(headerToGroup);
|
|
2980
|
-
headerToGroup.headerGroup = headerGroup;
|
|
2981
|
-
});
|
|
2982
|
-
headerGroups.push(headerGroup);
|
|
2983
|
-
|
|
2984
|
-
if (depth > 0) {
|
|
2985
|
-
createHeaderGroup(pendingParentHeaders, depth - 1);
|
|
2986
|
-
}
|
|
2987
|
-
};
|
|
2988
|
-
|
|
2989
|
-
const bottomHeaders = columnsToGroup.map((column, index) => instance.createHeader(column, {
|
|
2990
|
-
depth: maxDepth,
|
|
2991
|
-
index
|
|
2992
|
-
}));
|
|
2993
|
-
createHeaderGroup(bottomHeaders, maxDepth - 1);
|
|
2994
|
-
headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
|
|
2995
|
-
// return !headerGroup.headers.every(header => header.isPlaceholder)
|
|
2996
|
-
// })
|
|
2997
|
-
|
|
2998
|
-
const recurseHeadersForSpans = headers => {
|
|
2999
|
-
const filteredHeaders = headers.filter(header => header.column.getIsVisible());
|
|
3000
|
-
return filteredHeaders.map(header => {
|
|
3001
|
-
let colSpan = 0;
|
|
3002
|
-
let rowSpan = 0;
|
|
3003
|
-
let childRowSpans = [0];
|
|
3004
|
-
|
|
3005
|
-
if (header.subHeaders && header.subHeaders.length) {
|
|
3006
|
-
childRowSpans = [];
|
|
3007
|
-
recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
|
|
3008
|
-
let {
|
|
3009
|
-
colSpan: childColSpan,
|
|
3010
|
-
rowSpan: childRowSpan
|
|
3011
|
-
} = _ref;
|
|
3012
|
-
colSpan += childColSpan;
|
|
3013
|
-
childRowSpans.push(childRowSpan);
|
|
3014
|
-
});
|
|
3015
|
-
} else {
|
|
3016
|
-
colSpan = 1;
|
|
3017
|
-
}
|
|
3018
|
-
|
|
3019
|
-
const minChildRowSpan = Math.min(...childRowSpans);
|
|
3020
|
-
rowSpan = rowSpan + minChildRowSpan;
|
|
3021
|
-
header.colSpan = colSpan > 0 ? colSpan : undefined;
|
|
3022
|
-
header.rowSpan = rowSpan > 0 ? rowSpan : undefined;
|
|
3023
|
-
return {
|
|
3024
|
-
colSpan,
|
|
3025
|
-
rowSpan
|
|
3026
|
-
};
|
|
3027
|
-
});
|
|
3028
|
-
};
|
|
3029
2772
|
|
|
3030
|
-
|
|
3031
|
-
return headerGroups;
|
|
3032
|
-
}
|
|
2773
|
+
const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]; //
|
|
3033
2774
|
|
|
3034
|
-
// export type Batch = {
|
|
3035
|
-
// id: number
|
|
3036
|
-
// priority: keyof CoreBatches
|
|
3037
|
-
// tasks: (() => void)[]
|
|
3038
|
-
// schedule: (cb: () => void) => void
|
|
3039
|
-
// cancel: () => void
|
|
3040
|
-
// }
|
|
3041
|
-
// type CoreBatches = {
|
|
3042
|
-
// data: Batch[]
|
|
3043
|
-
// facets: Batch[]
|
|
3044
|
-
// }
|
|
3045
2775
|
function createTableInstance(options) {
|
|
3046
2776
|
var _options$initialState;
|
|
3047
2777
|
|
|
@@ -3050,7 +2780,7 @@ function createTableInstance(options) {
|
|
|
3050
2780
|
}
|
|
3051
2781
|
|
|
3052
2782
|
let instance = {
|
|
3053
|
-
_features:
|
|
2783
|
+
_features: features
|
|
3054
2784
|
};
|
|
3055
2785
|
|
|
3056
2786
|
const defaultOptions = instance._features.reduce((obj, feature) => {
|
|
@@ -3067,8 +2797,7 @@ function createTableInstance(options) {
|
|
|
3067
2797
|
};
|
|
3068
2798
|
};
|
|
3069
2799
|
|
|
3070
|
-
const coreInitialState = {
|
|
3071
|
-
};
|
|
2800
|
+
const coreInitialState = {};
|
|
3072
2801
|
let initialState = { ...coreInitialState,
|
|
3073
2802
|
...((_options$initialState = options.initialState) != null ? _options$initialState : {})
|
|
3074
2803
|
};
|
|
@@ -3081,16 +2810,8 @@ function createTableInstance(options) {
|
|
|
3081
2810
|
|
|
3082
2811
|
const queued = [];
|
|
3083
2812
|
let queuedTimeout = false;
|
|
3084
|
-
const
|
|
3085
|
-
|
|
3086
|
-
// startWork()
|
|
3087
|
-
// },
|
|
3088
|
-
// willUpdate: () => {
|
|
3089
|
-
// startWork()
|
|
3090
|
-
// },
|
|
3091
|
-
// destroy: () => {
|
|
3092
|
-
// stopWork()
|
|
3093
|
-
// },
|
|
2813
|
+
const coreInstance = {
|
|
2814
|
+
_features: features,
|
|
3094
2815
|
options: { ...defaultOptions,
|
|
3095
2816
|
...options
|
|
3096
2817
|
},
|
|
@@ -3136,29 +2857,136 @@ function createTableInstance(options) {
|
|
|
3136
2857
|
},
|
|
3137
2858
|
setState: updater => {
|
|
3138
2859
|
instance.options.onStateChange == null ? void 0 : instance.options.onStateChange(updater);
|
|
3139
|
-
}
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
//
|
|
3153
|
-
//
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
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
|
+
}
|
|
3159
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
|
+
}
|
|
2985
|
+
|
|
2986
|
+
return column;
|
|
2987
|
+
}
|
|
3160
2988
|
};
|
|
3161
|
-
|
|
2989
|
+
Object.assign(instance, coreInstance);
|
|
3162
2990
|
|
|
3163
2991
|
instance._features.forEach(feature => {
|
|
3164
2992
|
return Object.assign(instance, feature.createInstance == null ? void 0 : feature.createInstance(instance));
|
|
@@ -3181,10 +3009,11 @@ function createTable$1(_, __, options) {
|
|
|
3181
3009
|
throw new Error('');
|
|
3182
3010
|
})()
|
|
3183
3011
|
},
|
|
3184
|
-
setGenerics: () => table,
|
|
3012
|
+
// setGenerics: () => table as any,
|
|
3185
3013
|
setRowType: () => table,
|
|
3186
3014
|
setTableMetaType: () => table,
|
|
3187
3015
|
setColumnMetaType: () => table,
|
|
3016
|
+
setFilterMetaType: () => table,
|
|
3188
3017
|
setOptions: newOptions => createTable$1(_, __, { ...options,
|
|
3189
3018
|
...newOptions
|
|
3190
3019
|
}),
|
|
@@ -3216,11 +3045,92 @@ function createTable$1(_, __, options) {
|
|
|
3216
3045
|
}
|
|
3217
3046
|
|
|
3218
3047
|
throw new Error('Invalid accessor');
|
|
3219
|
-
}
|
|
3048
|
+
},
|
|
3049
|
+
createOptions: options => options
|
|
3220
3050
|
};
|
|
3221
3051
|
return table;
|
|
3222
3052
|
}
|
|
3223
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
|
+
|
|
3224
3134
|
function getCoreRowModel() {
|
|
3225
3135
|
return instance => memo(() => [instance.options.data], data => {
|
|
3226
3136
|
const rowModel = {
|
|
@@ -3248,7 +3158,7 @@ function getCoreRowModel() {
|
|
|
3248
3158
|
// }
|
|
3249
3159
|
// Make the row
|
|
3250
3160
|
|
|
3251
|
-
row =
|
|
3161
|
+
row = createRow(instance, instance._getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
|
|
3252
3162
|
|
|
3253
3163
|
rowModel.flatRows.push(row); // Also keep track of every row by its ID
|
|
3254
3164
|
|
|
@@ -3311,8 +3221,8 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, instance) {
|
|
|
3311
3221
|
row = rowsToFilter[i];
|
|
3312
3222
|
|
|
3313
3223
|
if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
|
|
3314
|
-
newRow =
|
|
3315
|
-
newRow.
|
|
3224
|
+
newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3225
|
+
newRow.columnFilters = row.columnFilters;
|
|
3316
3226
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3317
3227
|
|
|
3318
3228
|
if (!newRow.subRows.length) {
|
|
@@ -3361,7 +3271,7 @@ function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
|
|
|
3361
3271
|
var _row$subRows2;
|
|
3362
3272
|
|
|
3363
3273
|
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
|
|
3364
|
-
newRow =
|
|
3274
|
+
newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3365
3275
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3366
3276
|
row = newRow;
|
|
3367
3277
|
}
|
|
@@ -3385,6 +3295,11 @@ function filterRowModelFromRoot(rowsToFilter, filterRow, instance) {
|
|
|
3385
3295
|
function getFilteredRowModel() {
|
|
3386
3296
|
return instance => memo(() => [instance.getPreFilteredRowModel(), instance.getState().columnFilters, instance.getState().globalFilter], (rowModel, columnFilters, globalFilter) => {
|
|
3387
3297
|
if (!rowModel.rows.length || !(columnFilters != null && columnFilters.length) && !globalFilter) {
|
|
3298
|
+
for (let i = 0; i < rowModel.flatRows.length; i++) {
|
|
3299
|
+
rowModel.flatRows[i].columnFilters = {};
|
|
3300
|
+
rowModel.flatRows[i].columnFiltersMeta = {};
|
|
3301
|
+
}
|
|
3302
|
+
|
|
3388
3303
|
return rowModel;
|
|
3389
3304
|
}
|
|
3390
3305
|
|
|
@@ -3439,28 +3354,34 @@ function getFilteredRowModel() {
|
|
|
3439
3354
|
|
|
3440
3355
|
for (let j = 0; j < rowModel.flatRows.length; j++) {
|
|
3441
3356
|
const row = rowModel.flatRows[j];
|
|
3442
|
-
row.
|
|
3357
|
+
row.columnFilters = {};
|
|
3443
3358
|
|
|
3444
3359
|
if (resolvedColumnFilters.length) {
|
|
3445
3360
|
for (let i = 0; i < resolvedColumnFilters.length; i++) {
|
|
3446
|
-
currentColumnFilter = resolvedColumnFilters[i];
|
|
3361
|
+
currentColumnFilter = resolvedColumnFilters[i];
|
|
3362
|
+
const id = currentColumnFilter.id; // Tag the row with the column filter state
|
|
3447
3363
|
|
|
3448
|
-
row.
|
|
3364
|
+
row.columnFilters[id] = currentColumnFilter.filterFn(row, id, currentColumnFilter.resolvedValue, filterMeta => {
|
|
3365
|
+
row.columnFiltersMeta[id] = filterMeta;
|
|
3366
|
+
});
|
|
3449
3367
|
}
|
|
3450
3368
|
}
|
|
3451
3369
|
|
|
3452
3370
|
if (resolvedGlobalFilters.length) {
|
|
3453
3371
|
for (let i = 0; i < resolvedGlobalFilters.length; i++) {
|
|
3454
|
-
currentGlobalFilter = resolvedGlobalFilters[i];
|
|
3372
|
+
currentGlobalFilter = resolvedGlobalFilters[i];
|
|
3373
|
+
const id = currentGlobalFilter.id; // Tag the row with the first truthy global filter state
|
|
3455
3374
|
|
|
3456
|
-
if (currentGlobalFilter.filterFn(row,
|
|
3457
|
-
row.
|
|
3375
|
+
if (currentGlobalFilter.filterFn(row, id, currentGlobalFilter.resolvedValue, filterMeta => {
|
|
3376
|
+
row.columnFiltersMeta[id] = filterMeta;
|
|
3377
|
+
})) {
|
|
3378
|
+
row.columnFilters.__global__ = true;
|
|
3458
3379
|
break;
|
|
3459
3380
|
}
|
|
3460
3381
|
}
|
|
3461
3382
|
|
|
3462
|
-
if (row.
|
|
3463
|
-
row.
|
|
3383
|
+
if (row.columnFilters.__global__ !== true) {
|
|
3384
|
+
row.columnFilters.__global__ = false;
|
|
3464
3385
|
}
|
|
3465
3386
|
}
|
|
3466
3387
|
}
|
|
@@ -3468,7 +3389,7 @@ function getFilteredRowModel() {
|
|
|
3468
3389
|
const filterRowsImpl = row => {
|
|
3469
3390
|
// Horizontally filter rows through each column
|
|
3470
3391
|
for (let i = 0; i < filterableIds.length; i++) {
|
|
3471
|
-
if (row.
|
|
3392
|
+
if (row.columnFilters[filterableIds[i]] === false) {
|
|
3472
3393
|
return false;
|
|
3473
3394
|
}
|
|
3474
3395
|
}
|
|
@@ -3502,7 +3423,7 @@ function getFacetedRowModel() {
|
|
|
3502
3423
|
const filterRowsImpl = row => {
|
|
3503
3424
|
// Horizontally filter rows through each column
|
|
3504
3425
|
for (let i = 0; i < filterableIds.length; i++) {
|
|
3505
|
-
if (row.
|
|
3426
|
+
if (row.columnFilters[filterableIds[i]] === false) {
|
|
3506
3427
|
return false;
|
|
3507
3428
|
}
|
|
3508
3429
|
}
|
|
@@ -3602,8 +3523,8 @@ function getSortedRowModel() {
|
|
|
3602
3523
|
availableSorting.forEach(sortEntry => {
|
|
3603
3524
|
const column = instance.getColumn(sortEntry.id);
|
|
3604
3525
|
columnInfoById[sortEntry.id] = {
|
|
3605
|
-
sortUndefined: column.sortUndefined,
|
|
3606
|
-
invertSorting: column.invertSorting,
|
|
3526
|
+
sortUndefined: column.columnDef.sortUndefined,
|
|
3527
|
+
invertSorting: column.columnDef.invertSorting,
|
|
3607
3528
|
sortingFn: column.getSortingFn()
|
|
3608
3529
|
};
|
|
3609
3530
|
});
|
|
@@ -3717,7 +3638,7 @@ function getGroupedRowModel() {
|
|
|
3717
3638
|
const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
|
|
3718
3639
|
|
|
3719
3640
|
const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
|
|
3720
|
-
const row =
|
|
3641
|
+
const row = createRow(instance, id, undefined, index, depth);
|
|
3721
3642
|
Object.assign(row, {
|
|
3722
3643
|
groupingColumnId: columnId,
|
|
3723
3644
|
groupingValue,
|
|
@@ -3726,17 +3647,17 @@ function getGroupedRowModel() {
|
|
|
3726
3647
|
getValue: columnId => {
|
|
3727
3648
|
// Don't aggregate columns that are in the grouping
|
|
3728
3649
|
if (existingGrouping.includes(columnId)) {
|
|
3729
|
-
if (row.
|
|
3730
|
-
return row.
|
|
3650
|
+
if (row._valuesCache.hasOwnProperty(columnId)) {
|
|
3651
|
+
return row._valuesCache[columnId];
|
|
3731
3652
|
}
|
|
3732
3653
|
|
|
3733
3654
|
if (groupedRows[0]) {
|
|
3734
3655
|
var _groupedRows$0$getVal;
|
|
3735
3656
|
|
|
3736
|
-
row.
|
|
3657
|
+
row._valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
|
|
3737
3658
|
}
|
|
3738
3659
|
|
|
3739
|
-
return row.
|
|
3660
|
+
return row._valuesCache[columnId];
|
|
3740
3661
|
}
|
|
3741
3662
|
|
|
3742
3663
|
if (row.groupingValuesCache.hasOwnProperty(columnId)) {
|
|
@@ -3751,8 +3672,8 @@ function getGroupedRowModel() {
|
|
|
3751
3672
|
row.groupingValuesCache[columnId] = aggregateFn(() => leafRows.map(row => {
|
|
3752
3673
|
let columnValue = row.getValue(columnId);
|
|
3753
3674
|
|
|
3754
|
-
if (!depth && column.aggregateValue) {
|
|
3755
|
-
columnValue = column.aggregateValue(columnValue);
|
|
3675
|
+
if (!depth && column.columnDef.aggregateValue) {
|
|
3676
|
+
columnValue = column.columnDef.aggregateValue(columnValue);
|
|
3756
3677
|
}
|
|
3757
3678
|
|
|
3758
3679
|
return columnValue;
|
|
@@ -3966,5 +3887,5 @@ function useTableInstance(table, options) {
|
|
|
3966
3887
|
return instanceRef.current;
|
|
3967
3888
|
}
|
|
3968
3889
|
|
|
3969
|
-
export { ColumnSizing, Expanding, Filters, Grouping, Headers, Ordering, Pagination, Pinning, RowSelection, Sorting, Visibility, buildHeaderGroups, createTable, createTableFactory, createTableInstance, defaultColumnSizing, expandRows, flattenBy, functionalUpdate, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, isFunction, isRowSelected, makeStateUpdater, memo, noop, orderColumns, passiveEventSupported, render, selectRowsFn, shouldAutoRemoveFilter, useTableInstance };
|
|
3890
|
+
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, mean, memo, noop, orderColumns, passiveEventSupported, reSplitAlphaNumeric, render, selectRowsFn, shouldAutoRemoveFilter, sortingFns, useTableInstance };
|
|
3970
3891
|
//# sourceMappingURL=index.js.map
|