@tanstack/table-core 8.0.0-alpha.83 → 8.0.0-alpha.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/aggregationFns.js +50 -51
- package/build/cjs/aggregationFns.js.map +1 -1
- package/build/cjs/core/cell.js +38 -0
- package/build/cjs/core/cell.js.map +1 -0
- package/build/cjs/core/column.js +88 -0
- package/build/cjs/core/column.js.map +1 -0
- package/build/cjs/{features/Headers.js → core/headers.js} +54 -66
- package/build/cjs/core/headers.js.map +1 -0
- package/build/cjs/core/instance.js +255 -0
- package/build/cjs/core/instance.js.map +1 -0
- package/build/cjs/core/row.js +77 -0
- package/build/cjs/core/row.js.map +1 -0
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Expanding.js +0 -1
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js +2 -3
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +5 -5
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Ordering.js.map +1 -1
- package/build/cjs/features/Pagination.js.map +1 -1
- package/build/cjs/features/Pinning.js +3 -3
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +0 -5
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/index.js +9 -6
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/utils/filterRowsUtils.js +23 -21
- package/build/cjs/utils/filterRowsUtils.js.map +1 -1
- package/build/cjs/utils/getCoreRowModel.js +9 -8
- package/build/cjs/utils/getCoreRowModel.js.map +1 -1
- package/build/cjs/utils/getExpandedRowModel.js +2 -2
- package/build/cjs/utils/getExpandedRowModel.js.map +1 -1
- package/build/cjs/utils/getGroupedRowModel.js +13 -20
- package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
- package/build/cjs/utils/getPaginationRowModel.js +1 -1
- package/build/cjs/utils/getPaginationRowModel.js.map +1 -1
- package/build/esm/index.js +718 -838
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +403 -380
- package/build/types/aggregationFns.d.ts +10 -19
- package/build/types/core/cell.d.ts +9 -0
- package/build/types/{features/Columns.d.ts → core/column.d.ts} +3 -17
- package/build/types/{features/Headers.d.ts → core/headers.d.ts} +26 -11
- package/build/types/core/instance.d.ts +57 -0
- package/build/types/core/row.d.ts +15 -0
- package/build/types/features/ColumnSizing.d.ts +2 -1
- package/build/types/features/Expanding.d.ts +2 -2
- package/build/types/features/Filters.d.ts +2 -3
- package/build/types/features/Grouping.d.ts +8 -9
- package/build/types/features/Ordering.d.ts +2 -1
- package/build/types/features/Pagination.d.ts +2 -1
- package/build/types/features/Pinning.d.ts +2 -1
- package/build/types/features/RowSelection.d.ts +2 -1
- package/build/types/features/Sorting.d.ts +2 -1
- package/build/types/features/Visibility.d.ts +7 -7
- package/build/types/index.d.ts +4 -2
- package/build/types/sortingFns.d.ts +4 -4
- package/build/types/types.d.ts +10 -53
- package/build/umd/index.development.js +721 -836
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/aggregationFns.ts +44 -40
- package/src/core/cell.ts +47 -0
- package/src/core/column.ts +148 -0
- package/src/{features/Headers.ts → core/headers.ts} +98 -99
- package/src/core/instance.ts +361 -0
- package/src/core/row.ts +85 -0
- package/src/features/ColumnSizing.ts +1 -1
- package/src/features/Expanding.ts +1 -4
- package/src/features/Filters.ts +2 -7
- package/src/features/Grouping.ts +16 -19
- package/src/features/Ordering.ts +1 -1
- package/src/features/Pagination.ts +1 -1
- package/src/features/Pinning.ts +8 -4
- package/src/features/RowSelection.ts +1 -1
- package/src/features/Sorting.ts +1 -1
- package/src/features/Visibility.ts +8 -17
- package/src/index.ts +4 -8
- package/src/types.ts +9 -61
- package/src/utils/filterRowsUtils.ts +4 -2
- package/src/utils/getCoreRowModel.ts +4 -2
- package/src/utils/getExpandedRowModel.ts +1 -5
- package/src/utils/getGroupedRowModel.ts +14 -23
- package/build/cjs/core.js +0 -168
- package/build/cjs/core.js.map +0 -1
- package/build/cjs/features/Cells.js +0 -101
- package/build/cjs/features/Cells.js.map +0 -1
- package/build/cjs/features/Columns.js +0 -191
- package/build/cjs/features/Columns.js.map +0 -1
- package/build/cjs/features/Headers.js.map +0 -1
- package/build/cjs/features/Rows.js +0 -94
- package/build/cjs/features/Rows.js.map +0 -1
- package/build/types/core.d.ts +0 -30
- package/build/types/features/Cells.d.ts +0 -13
- package/build/types/features/Rows.d.ts +0 -28
- package/src/core.ts +0 -246
- package/src/features/Cells.ts +0 -128
- package/src/features/Columns.ts +0 -293
- package/src/features/Rows.ts +0 -142
|
@@ -91,329 +91,457 @@
|
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
function createColumn(instance, columnDef, depth, parent) {
|
|
95
|
+
var _ref, _columnDef$id;
|
|
96
|
+
|
|
97
|
+
const defaultColumn = instance._getDefaultColumnDef();
|
|
98
|
+
|
|
99
|
+
columnDef = { ...defaultColumn,
|
|
100
|
+
...columnDef
|
|
101
|
+
};
|
|
102
|
+
let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
|
|
103
|
+
let accessorFn;
|
|
104
|
+
|
|
105
|
+
if (columnDef.accessorFn) {
|
|
106
|
+
accessorFn = columnDef.accessorFn;
|
|
107
|
+
} else if (columnDef.accessorKey) {
|
|
108
|
+
accessorFn = originalRow => originalRow[columnDef.accessorKey];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (!id) {
|
|
112
|
+
{
|
|
113
|
+
throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
let column = { ...columnDef,
|
|
118
|
+
id: "" + id,
|
|
119
|
+
accessorFn,
|
|
120
|
+
parent: parent,
|
|
121
|
+
depth,
|
|
122
|
+
columnDef,
|
|
123
|
+
columnDefType: columnDef.columnDefType,
|
|
124
|
+
columns: [],
|
|
125
|
+
getFlatColumns: memo(() => [true], () => {
|
|
126
|
+
var _column$columns;
|
|
127
|
+
|
|
128
|
+
return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
|
|
129
|
+
}, {
|
|
130
|
+
key: "development" === 'production' ,
|
|
131
|
+
debug: () => {
|
|
132
|
+
var _instance$options$deb;
|
|
133
|
+
|
|
134
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
|
|
135
|
+
}
|
|
136
|
+
}),
|
|
137
|
+
getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
|
|
138
|
+
var _column$columns2;
|
|
139
|
+
|
|
140
|
+
if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
|
|
141
|
+
let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
|
|
142
|
+
return orderColumns(leafColumns);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return [column];
|
|
146
|
+
}, {
|
|
147
|
+
key: "development" === 'production' ,
|
|
148
|
+
debug: () => {
|
|
149
|
+
var _instance$options$deb2;
|
|
150
|
+
|
|
151
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
};
|
|
155
|
+
column = instance._features.reduce((obj, feature) => {
|
|
156
|
+
return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
|
|
157
|
+
}, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
158
|
+
|
|
159
|
+
return column;
|
|
160
|
+
}
|
|
161
|
+
|
|
94
162
|
//
|
|
95
|
-
|
|
163
|
+
function createHeader(instance, column, options) {
|
|
164
|
+
var _options$id;
|
|
165
|
+
|
|
166
|
+
const id = (_options$id = options.id) != null ? _options$id : column.id;
|
|
167
|
+
let header = {
|
|
168
|
+
id,
|
|
169
|
+
column,
|
|
170
|
+
index: options.index,
|
|
171
|
+
isPlaceholder: !!options.isPlaceholder,
|
|
172
|
+
placeholderId: options.placeholderId,
|
|
173
|
+
depth: options.depth,
|
|
174
|
+
subHeaders: [],
|
|
175
|
+
colSpan: 0,
|
|
176
|
+
rowSpan: 0,
|
|
177
|
+
headerGroup: null,
|
|
178
|
+
getLeafHeaders: () => {
|
|
179
|
+
const leafHeaders = [];
|
|
180
|
+
|
|
181
|
+
const recurseHeader = h => {
|
|
182
|
+
if (h.subHeaders && h.subHeaders.length) {
|
|
183
|
+
h.subHeaders.map(recurseHeader);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
leafHeaders.push(h);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
recurseHeader(header);
|
|
190
|
+
return leafHeaders;
|
|
191
|
+
},
|
|
192
|
+
renderHeader: () => column.columnDef.header ? instance._render(column.columnDef.header, {
|
|
193
|
+
instance,
|
|
194
|
+
header: header,
|
|
195
|
+
column
|
|
196
|
+
}) : null,
|
|
197
|
+
renderFooter: () => column.columnDef.footer ? instance._render(column.columnDef.footer, {
|
|
198
|
+
instance,
|
|
199
|
+
header: header,
|
|
200
|
+
column
|
|
201
|
+
}) : null
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
instance._features.forEach(feature => {
|
|
205
|
+
Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
return header;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const Headers = {
|
|
96
212
|
createInstance: instance => {
|
|
97
213
|
return {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
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;
|
|
109
|
-
},
|
|
110
|
-
...instance._features.reduce((obj, feature) => {
|
|
111
|
-
return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
|
|
112
|
-
}, {}),
|
|
113
|
-
...defaultColumn
|
|
114
|
-
};
|
|
214
|
+
// Header Groups
|
|
215
|
+
getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
216
|
+
var _left$map$filter, _right$map$filter;
|
|
217
|
+
|
|
218
|
+
const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
|
|
219
|
+
const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
|
|
220
|
+
const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
221
|
+
const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
|
|
222
|
+
return headerGroups;
|
|
115
223
|
}, {
|
|
224
|
+
key: 'getHeaderGroups',
|
|
116
225
|
debug: () => {
|
|
117
226
|
var _instance$options$deb;
|
|
118
227
|
|
|
119
|
-
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.
|
|
120
|
-
},
|
|
121
|
-
key: 'getDefaultColumnDef'
|
|
122
|
-
}),
|
|
123
|
-
getColumnDefs: () => instance.options.columns,
|
|
124
|
-
createColumn: (columnDef, depth, parent) => {
|
|
125
|
-
var _ref, _columnDef$id;
|
|
126
|
-
|
|
127
|
-
const defaultColumnDef = instance.getDefaultColumnDef();
|
|
128
|
-
columnDef = { ...defaultColumnDef,
|
|
129
|
-
...columnDef
|
|
130
|
-
};
|
|
131
|
-
let id = (_ref = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref : typeof columnDef.header === 'string' ? columnDef.header : undefined;
|
|
132
|
-
let accessorFn;
|
|
133
|
-
|
|
134
|
-
if (columnDef.accessorFn) {
|
|
135
|
-
accessorFn = columnDef.accessorFn;
|
|
136
|
-
} else if (columnDef.accessorKey) {
|
|
137
|
-
accessorFn = originalRow => originalRow[columnDef.accessorKey];
|
|
228
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
|
|
138
229
|
}
|
|
230
|
+
}),
|
|
231
|
+
getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
232
|
+
leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
233
|
+
return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
|
|
234
|
+
}, {
|
|
235
|
+
key: 'getCenterHeaderGroups',
|
|
236
|
+
debug: () => {
|
|
237
|
+
var _instance$options$deb2;
|
|
139
238
|
|
|
140
|
-
|
|
141
|
-
{
|
|
142
|
-
throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
|
|
143
|
-
}
|
|
239
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
|
|
144
240
|
}
|
|
241
|
+
}),
|
|
242
|
+
getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
243
|
+
var _left$map$filter2;
|
|
145
244
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
columnDefType: columnDef.columnDefType,
|
|
153
|
-
columns: [],
|
|
154
|
-
getFlatColumns: memo(() => [true], () => {
|
|
155
|
-
var _column$columns;
|
|
156
|
-
|
|
157
|
-
return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
|
|
158
|
-
}, {
|
|
159
|
-
key: "development" === 'production' ,
|
|
160
|
-
debug: () => {
|
|
161
|
-
var _instance$options$deb2;
|
|
162
|
-
|
|
163
|
-
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
|
|
164
|
-
}
|
|
165
|
-
}),
|
|
166
|
-
getLeafColumns: memo(() => [instance._getOrderColumnsFn()], orderColumns => {
|
|
167
|
-
var _column$columns2;
|
|
168
|
-
|
|
169
|
-
if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
|
|
170
|
-
let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
|
|
171
|
-
return orderColumns(leafColumns);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return [column];
|
|
175
|
-
}, {
|
|
176
|
-
key: "development" === 'production' ,
|
|
177
|
-
debug: () => {
|
|
178
|
-
var _instance$options$deb3;
|
|
179
|
-
|
|
180
|
-
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
181
|
-
}
|
|
182
|
-
})
|
|
183
|
-
};
|
|
184
|
-
column = instance._features.reduce((obj, feature) => {
|
|
185
|
-
return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
|
|
186
|
-
}, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
187
|
-
|
|
188
|
-
return column;
|
|
189
|
-
},
|
|
190
|
-
getAllColumns: memo(() => [instance.getColumnDefs()], columnDefs => {
|
|
191
|
-
const recurseColumns = function (columnDefs, parent, depth) {
|
|
192
|
-
if (depth === void 0) {
|
|
193
|
-
depth = 0;
|
|
194
|
-
}
|
|
245
|
+
const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
|
|
246
|
+
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
|
|
247
|
+
}, {
|
|
248
|
+
key: 'getLeftHeaderGroups',
|
|
249
|
+
debug: () => {
|
|
250
|
+
var _instance$options$deb3;
|
|
195
251
|
|
|
196
|
-
return
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
};
|
|
252
|
+
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
|
|
253
|
+
}
|
|
254
|
+
}),
|
|
255
|
+
getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
256
|
+
var _right$map$filter2;
|
|
202
257
|
|
|
203
|
-
|
|
258
|
+
const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
|
|
259
|
+
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
|
|
204
260
|
}, {
|
|
205
|
-
key: '
|
|
261
|
+
key: 'getRightHeaderGroups',
|
|
206
262
|
debug: () => {
|
|
207
263
|
var _instance$options$deb4;
|
|
208
264
|
|
|
209
|
-
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.
|
|
265
|
+
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
|
|
210
266
|
}
|
|
211
267
|
}),
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
});
|
|
268
|
+
// Footer Groups
|
|
269
|
+
getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
270
|
+
return [...headerGroups].reverse();
|
|
216
271
|
}, {
|
|
217
|
-
key: '
|
|
272
|
+
key: 'getFooterGroups',
|
|
218
273
|
debug: () => {
|
|
219
274
|
var _instance$options$deb5;
|
|
220
275
|
|
|
221
|
-
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.
|
|
276
|
+
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
|
|
222
277
|
}
|
|
223
278
|
}),
|
|
224
|
-
|
|
225
|
-
return
|
|
226
|
-
acc[column.id] = column;
|
|
227
|
-
return acc;
|
|
228
|
-
}, {});
|
|
279
|
+
getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
|
|
280
|
+
return [...headerGroups].reverse();
|
|
229
281
|
}, {
|
|
230
|
-
key: '
|
|
282
|
+
key: 'getLeftFooterGroups',
|
|
231
283
|
debug: () => {
|
|
232
284
|
var _instance$options$deb6;
|
|
233
285
|
|
|
234
|
-
return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.
|
|
286
|
+
return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
|
|
235
287
|
}
|
|
236
288
|
}),
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
return orderColumns(leafColumns);
|
|
289
|
+
getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
|
|
290
|
+
return [...headerGroups].reverse();
|
|
240
291
|
}, {
|
|
241
|
-
key: '
|
|
292
|
+
key: 'getCenterFooterGroups',
|
|
242
293
|
debug: () => {
|
|
243
294
|
var _instance$options$deb7;
|
|
244
295
|
|
|
245
|
-
return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.
|
|
296
|
+
return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
|
|
246
297
|
}
|
|
247
298
|
}),
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
299
|
+
getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
|
|
300
|
+
return [...headerGroups].reverse();
|
|
301
|
+
}, {
|
|
302
|
+
key: 'getRightFooterGroups',
|
|
303
|
+
debug: () => {
|
|
304
|
+
var _instance$options$deb8;
|
|
255
305
|
|
|
256
|
-
|
|
306
|
+
return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
|
|
257
307
|
}
|
|
308
|
+
}),
|
|
309
|
+
// Flat Headers
|
|
310
|
+
getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
311
|
+
return headerGroups.map(headerGroup => {
|
|
312
|
+
return headerGroup.headers;
|
|
313
|
+
}).flat();
|
|
314
|
+
}, {
|
|
315
|
+
key: 'getFlatHeaders',
|
|
316
|
+
debug: () => {
|
|
317
|
+
var _instance$options$deb9;
|
|
258
318
|
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
//
|
|
266
|
-
const Rows = {
|
|
267
|
-
// createRow: <TGenerics extends TableGenerics>(
|
|
268
|
-
// row: Row<TGenerics>,
|
|
269
|
-
// instance: TableInstance<TGenerics>
|
|
270
|
-
// ): CellsRow<TGenerics> => {
|
|
271
|
-
// return {}
|
|
272
|
-
// },
|
|
273
|
-
createInstance: instance => {
|
|
274
|
-
return {
|
|
275
|
-
getRowId: (row, index, parent) => {
|
|
276
|
-
var _instance$options$get;
|
|
277
|
-
|
|
278
|
-
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);
|
|
279
|
-
},
|
|
280
|
-
createRow: (id, original, rowIndex, depth, subRows) => {
|
|
281
|
-
let row = {
|
|
282
|
-
id,
|
|
283
|
-
index: rowIndex,
|
|
284
|
-
original,
|
|
285
|
-
depth,
|
|
286
|
-
valuesCache: {},
|
|
287
|
-
getValue: columnId => {
|
|
288
|
-
if (row.valuesCache.hasOwnProperty(columnId)) {
|
|
289
|
-
return row.valuesCache[columnId];
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
const column = instance.getColumn(columnId);
|
|
293
|
-
|
|
294
|
-
if (!column.accessorFn) {
|
|
295
|
-
return undefined;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
row.valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
|
299
|
-
return row.valuesCache[columnId];
|
|
300
|
-
},
|
|
301
|
-
subRows: subRows != null ? subRows : [],
|
|
302
|
-
getLeafRows: () => flattenBy(row.subRows, d => d.subRows)
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
for (let i = 0; i < instance._features.length; i++) {
|
|
306
|
-
const feature = instance._features[i];
|
|
307
|
-
Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
|
|
319
|
+
return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
|
|
308
320
|
}
|
|
321
|
+
}),
|
|
322
|
+
getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
|
|
323
|
+
return left.map(headerGroup => {
|
|
324
|
+
return headerGroup.headers;
|
|
325
|
+
}).flat();
|
|
326
|
+
}, {
|
|
327
|
+
key: 'getLeftFlatHeaders',
|
|
328
|
+
debug: () => {
|
|
329
|
+
var _instance$options$deb10;
|
|
309
330
|
|
|
310
|
-
|
|
311
|
-
},
|
|
312
|
-
getCoreRowModel: () => {
|
|
313
|
-
if (!instance._getCoreRowModel) {
|
|
314
|
-
instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
|
|
331
|
+
return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
|
|
315
332
|
}
|
|
333
|
+
}),
|
|
334
|
+
getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
|
|
335
|
+
return left.map(headerGroup => {
|
|
336
|
+
return headerGroup.headers;
|
|
337
|
+
}).flat();
|
|
338
|
+
}, {
|
|
339
|
+
key: 'getCenterFlatHeaders',
|
|
340
|
+
debug: () => {
|
|
341
|
+
var _instance$options$deb11;
|
|
316
342
|
|
|
317
|
-
|
|
318
|
-
},
|
|
319
|
-
// The final calls start at the bottom of the model,
|
|
320
|
-
// expanded rows, which then work their way up
|
|
321
|
-
getRowModel: () => {
|
|
322
|
-
return instance.getPaginationRowModel();
|
|
323
|
-
},
|
|
324
|
-
getRow: id => {
|
|
325
|
-
const row = instance.getRowModel().rowsById[id];
|
|
326
|
-
|
|
327
|
-
if (!row) {
|
|
328
|
-
{
|
|
329
|
-
throw new Error("getRow expected an ID, but got " + id);
|
|
330
|
-
}
|
|
343
|
+
return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
|
|
331
344
|
}
|
|
345
|
+
}),
|
|
346
|
+
getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
|
|
347
|
+
return left.map(headerGroup => {
|
|
348
|
+
return headerGroup.headers;
|
|
349
|
+
}).flat();
|
|
350
|
+
}, {
|
|
351
|
+
key: 'getRightFlatHeaders',
|
|
352
|
+
debug: () => {
|
|
353
|
+
var _instance$options$deb12;
|
|
332
354
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
355
|
+
return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
|
|
356
|
+
}
|
|
357
|
+
}),
|
|
358
|
+
// Leaf Headers
|
|
359
|
+
getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
|
|
360
|
+
return flatHeaders.filter(header => {
|
|
361
|
+
var _header$subHeaders;
|
|
338
362
|
|
|
339
|
-
|
|
340
|
-
const Cells = {
|
|
341
|
-
createRow: (row, instance) => {
|
|
342
|
-
return {
|
|
343
|
-
getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
|
|
344
|
-
return leafColumns.map(column => {
|
|
345
|
-
return instance.createCell(row, column, column.id);
|
|
363
|
+
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
|
346
364
|
});
|
|
347
365
|
}, {
|
|
348
|
-
key: '
|
|
366
|
+
key: 'getCenterLeafHeaders',
|
|
349
367
|
debug: () => {
|
|
350
|
-
var _instance$options$
|
|
368
|
+
var _instance$options$deb13;
|
|
351
369
|
|
|
352
|
-
return (_instance$options$
|
|
370
|
+
return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
|
|
353
371
|
}
|
|
354
372
|
}),
|
|
355
|
-
|
|
356
|
-
return
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
373
|
+
getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
|
|
374
|
+
return flatHeaders.filter(header => {
|
|
375
|
+
var _header$subHeaders2;
|
|
376
|
+
|
|
377
|
+
return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
|
|
378
|
+
});
|
|
360
379
|
}, {
|
|
361
|
-
key:
|
|
380
|
+
key: 'getLeftLeafHeaders',
|
|
362
381
|
debug: () => {
|
|
363
|
-
var _instance$options$
|
|
382
|
+
var _instance$options$deb14;
|
|
364
383
|
|
|
365
|
-
return (_instance$options$
|
|
384
|
+
return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
|
|
366
385
|
}
|
|
367
|
-
})
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
return {
|
|
372
|
-
createCell: (row, column, columnId) => {
|
|
373
|
-
const cell = {
|
|
374
|
-
id: row.id + "_" + column.id,
|
|
375
|
-
rowId: row.id,
|
|
376
|
-
columnId,
|
|
377
|
-
row,
|
|
378
|
-
column,
|
|
379
|
-
getValue: () => row.getValue(columnId),
|
|
380
|
-
renderCell: () => column.columnDef.cell ? instance._render(column.columnDef.cell, {
|
|
381
|
-
instance,
|
|
382
|
-
column,
|
|
383
|
-
row,
|
|
384
|
-
cell: cell,
|
|
385
|
-
getValue: cell.getValue
|
|
386
|
-
}) : null
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
instance._features.forEach(feature => {
|
|
390
|
-
Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
|
|
391
|
-
}, {});
|
|
386
|
+
}),
|
|
387
|
+
getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
|
|
388
|
+
return flatHeaders.filter(header => {
|
|
389
|
+
var _header$subHeaders3;
|
|
392
390
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
391
|
+
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
|
392
|
+
});
|
|
393
|
+
}, {
|
|
394
|
+
key: 'getRightLeafHeaders',
|
|
395
|
+
debug: () => {
|
|
396
|
+
var _instance$options$deb15;
|
|
397
397
|
|
|
398
|
-
|
|
399
|
-
{
|
|
400
|
-
throw new Error("[Table] could not find row with id " + rowId);
|
|
401
|
-
}
|
|
398
|
+
return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
|
|
402
399
|
}
|
|
400
|
+
}),
|
|
401
|
+
getLeafHeaders: memo(() => [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()], (left, center, right) => {
|
|
402
|
+
var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
|
|
403
403
|
|
|
404
|
-
|
|
404
|
+
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 => {
|
|
405
|
+
return header.getLeafHeaders();
|
|
406
|
+
}).flat();
|
|
407
|
+
}, {
|
|
408
|
+
key: 'getLeafHeaders',
|
|
409
|
+
debug: () => {
|
|
410
|
+
var _instance$options$deb16;
|
|
405
411
|
|
|
406
|
-
|
|
407
|
-
{
|
|
408
|
-
throw new Error("[Table] could not find cell " + columnId + " in row " + rowId);
|
|
409
|
-
}
|
|
412
|
+
return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
|
|
410
413
|
}
|
|
411
|
-
|
|
412
|
-
return cell;
|
|
413
|
-
}
|
|
414
|
+
})
|
|
414
415
|
};
|
|
415
416
|
}
|
|
416
417
|
};
|
|
418
|
+
function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
|
|
419
|
+
var _headerGroups$0$heade, _headerGroups$;
|
|
420
|
+
|
|
421
|
+
// Find the max depth of the columns:
|
|
422
|
+
// build the leaf column row
|
|
423
|
+
// build each buffer row going up
|
|
424
|
+
// placeholder for non-existent level
|
|
425
|
+
// real column for existing level
|
|
426
|
+
let maxDepth = 0;
|
|
427
|
+
|
|
428
|
+
const findMaxDepth = function (columns, depth) {
|
|
429
|
+
if (depth === void 0) {
|
|
430
|
+
depth = 1;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
maxDepth = Math.max(maxDepth, depth);
|
|
434
|
+
columns.filter(column => column.getIsVisible()).forEach(column => {
|
|
435
|
+
var _column$columns;
|
|
436
|
+
|
|
437
|
+
if ((_column$columns = column.columns) != null && _column$columns.length) {
|
|
438
|
+
findMaxDepth(column.columns, depth + 1);
|
|
439
|
+
}
|
|
440
|
+
}, 0);
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
findMaxDepth(allColumns);
|
|
444
|
+
let headerGroups = [];
|
|
445
|
+
|
|
446
|
+
const createHeaderGroup = (headersToGroup, depth) => {
|
|
447
|
+
// The header group we are creating
|
|
448
|
+
const headerGroup = {
|
|
449
|
+
depth,
|
|
450
|
+
id: [headerFamily, "" + depth].filter(Boolean).join('_'),
|
|
451
|
+
headers: []
|
|
452
|
+
}; // The parent columns we're going to scan next
|
|
453
|
+
|
|
454
|
+
const pendingParentHeaders = []; // Scan each column for parents
|
|
455
|
+
|
|
456
|
+
headersToGroup.forEach(headerToGroup => {
|
|
457
|
+
// What is the latest (last) parent column?
|
|
458
|
+
const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
|
|
459
|
+
const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
|
|
460
|
+
let column;
|
|
461
|
+
let isPlaceholder = false;
|
|
462
|
+
|
|
463
|
+
if (isLeafHeader && headerToGroup.column.parent) {
|
|
464
|
+
// The parent header is new
|
|
465
|
+
column = headerToGroup.column.parent;
|
|
466
|
+
} else {
|
|
467
|
+
// The parent header is repeated
|
|
468
|
+
column = headerToGroup.column;
|
|
469
|
+
isPlaceholder = true;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
|
|
473
|
+
// This column is repeated. Add it as a sub header to the next batch
|
|
474
|
+
latestPendingParentHeader.subHeaders.push(headerToGroup);
|
|
475
|
+
} else {
|
|
476
|
+
// This is a new header. Let's create it
|
|
477
|
+
const header = createHeader(instance, column, {
|
|
478
|
+
id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
|
|
479
|
+
isPlaceholder,
|
|
480
|
+
placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
|
|
481
|
+
depth,
|
|
482
|
+
index: pendingParentHeaders.length
|
|
483
|
+
}); // Add the headerToGroup as a subHeader of the new header
|
|
484
|
+
|
|
485
|
+
header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
|
|
486
|
+
// in the next batch
|
|
487
|
+
|
|
488
|
+
pendingParentHeaders.push(header);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
headerGroup.headers.push(headerToGroup);
|
|
492
|
+
headerToGroup.headerGroup = headerGroup;
|
|
493
|
+
});
|
|
494
|
+
headerGroups.push(headerGroup);
|
|
495
|
+
|
|
496
|
+
if (depth > 0) {
|
|
497
|
+
createHeaderGroup(pendingParentHeaders, depth - 1);
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
const bottomHeaders = columnsToGroup.map((column, index) => createHeader(instance, column, {
|
|
502
|
+
depth: maxDepth,
|
|
503
|
+
index
|
|
504
|
+
}));
|
|
505
|
+
createHeaderGroup(bottomHeaders, maxDepth - 1);
|
|
506
|
+
headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
|
|
507
|
+
// return !headerGroup.headers.every(header => header.isPlaceholder)
|
|
508
|
+
// })
|
|
509
|
+
|
|
510
|
+
const recurseHeadersForSpans = headers => {
|
|
511
|
+
const filteredHeaders = headers.filter(header => header.column.getIsVisible());
|
|
512
|
+
return filteredHeaders.map(header => {
|
|
513
|
+
let colSpan = 0;
|
|
514
|
+
let rowSpan = 0;
|
|
515
|
+
let childRowSpans = [0];
|
|
516
|
+
|
|
517
|
+
if (header.subHeaders && header.subHeaders.length) {
|
|
518
|
+
childRowSpans = [];
|
|
519
|
+
recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
|
|
520
|
+
let {
|
|
521
|
+
colSpan: childColSpan,
|
|
522
|
+
rowSpan: childRowSpan
|
|
523
|
+
} = _ref;
|
|
524
|
+
colSpan += childColSpan;
|
|
525
|
+
childRowSpans.push(childRowSpan);
|
|
526
|
+
});
|
|
527
|
+
} else {
|
|
528
|
+
colSpan = 1;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
const minChildRowSpan = Math.min(...childRowSpans);
|
|
532
|
+
rowSpan = rowSpan + minChildRowSpan;
|
|
533
|
+
header.colSpan = colSpan;
|
|
534
|
+
header.rowSpan = rowSpan;
|
|
535
|
+
return {
|
|
536
|
+
colSpan,
|
|
537
|
+
rowSpan
|
|
538
|
+
};
|
|
539
|
+
});
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
|
|
543
|
+
return headerGroups;
|
|
544
|
+
}
|
|
417
545
|
|
|
418
546
|
//
|
|
419
547
|
const defaultColumnSizing = {
|
|
@@ -691,7 +819,6 @@
|
|
|
691
819
|
return {
|
|
692
820
|
onExpandedChange: makeStateUpdater('expanded', instance),
|
|
693
821
|
autoResetExpanded: true,
|
|
694
|
-
expandSubRows: true,
|
|
695
822
|
paginateExpandedRows: true
|
|
696
823
|
};
|
|
697
824
|
},
|
|
@@ -960,7 +1087,7 @@
|
|
|
960
1087
|
getColumnCanGlobalFilter: column => {
|
|
961
1088
|
var _instance$getCoreRowM, _instance$getCoreRowM2;
|
|
962
1089
|
|
|
963
|
-
const value = (_instance$getCoreRowM = instance.getCoreRowModel().flatRows[0]) == null ? void 0 : (_instance$getCoreRowM2 = _instance$getCoreRowM.
|
|
1090
|
+
const value = (_instance$getCoreRowM = instance.getCoreRowModel().flatRows[0]) == null ? void 0 : (_instance$getCoreRowM2 = _instance$getCoreRowM._getAllCellsByColumnId()[column.id]) == null ? void 0 : _instance$getCoreRowM2.getValue();
|
|
964
1091
|
return typeof value === 'string';
|
|
965
1092
|
}
|
|
966
1093
|
};
|
|
@@ -1088,8 +1215,7 @@
|
|
|
1088
1215
|
createRow: (row, instance) => {
|
|
1089
1216
|
return {
|
|
1090
1217
|
columnFilters: {},
|
|
1091
|
-
columnFiltersMeta: {}
|
|
1092
|
-
subRowsByFacetId: {}
|
|
1218
|
+
columnFiltersMeta: {}
|
|
1093
1219
|
};
|
|
1094
1220
|
},
|
|
1095
1221
|
createInstance: instance => {
|
|
@@ -1180,53 +1306,42 @@
|
|
|
1180
1306
|
return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
|
|
1181
1307
|
}
|
|
1182
1308
|
|
|
1183
|
-
const
|
|
1184
|
-
sum,
|
|
1185
|
-
min,
|
|
1186
|
-
max,
|
|
1187
|
-
extent,
|
|
1188
|
-
mean,
|
|
1189
|
-
median,
|
|
1190
|
-
unique,
|
|
1191
|
-
uniqueCount,
|
|
1192
|
-
count
|
|
1193
|
-
};
|
|
1194
|
-
|
|
1195
|
-
function sum(_getLeafValues, getChildValues) {
|
|
1309
|
+
const sum = (columnId, _leafRows, childRows) => {
|
|
1196
1310
|
// It's faster to just add the aggregations together instead of
|
|
1197
1311
|
// process leaf nodes individually
|
|
1198
|
-
return
|
|
1199
|
-
}
|
|
1312
|
+
return childRows.reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
|
|
1313
|
+
};
|
|
1200
1314
|
|
|
1201
|
-
|
|
1315
|
+
const min = (columnId, _leafRows, childRows) => {
|
|
1202
1316
|
let min;
|
|
1317
|
+
childRows.forEach(row => {
|
|
1318
|
+
const value = row.getValue(columnId);
|
|
1203
1319
|
|
|
1204
|
-
for (const value of getChildValues()) {
|
|
1205
1320
|
if (value != null && (min > value || min === undefined && value >= value)) {
|
|
1206
1321
|
min = value;
|
|
1207
1322
|
}
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1323
|
+
});
|
|
1210
1324
|
return min;
|
|
1211
|
-
}
|
|
1325
|
+
};
|
|
1212
1326
|
|
|
1213
|
-
|
|
1327
|
+
const max = (columnId, _leafRows, childRows) => {
|
|
1214
1328
|
let max;
|
|
1329
|
+
childRows.forEach(row => {
|
|
1330
|
+
const value = row.getValue(columnId);
|
|
1215
1331
|
|
|
1216
|
-
for (const value of getChildValues()) {
|
|
1217
1332
|
if (value != null && (max < value || max === undefined && value >= value)) {
|
|
1218
1333
|
max = value;
|
|
1219
1334
|
}
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1335
|
+
});
|
|
1222
1336
|
return max;
|
|
1223
|
-
}
|
|
1337
|
+
};
|
|
1224
1338
|
|
|
1225
|
-
|
|
1339
|
+
const extent = (columnId, _leafRows, childRows) => {
|
|
1226
1340
|
let min;
|
|
1227
1341
|
let max;
|
|
1342
|
+
childRows.forEach(row => {
|
|
1343
|
+
const value = row.getValue(columnId);
|
|
1228
1344
|
|
|
1229
|
-
for (const value of getChildValues()) {
|
|
1230
1345
|
if (value != null) {
|
|
1231
1346
|
if (min === undefined) {
|
|
1232
1347
|
if (value >= value) min = max = value;
|
|
@@ -1235,54 +1350,65 @@
|
|
|
1235
1350
|
if (max < value) max = value;
|
|
1236
1351
|
}
|
|
1237
1352
|
}
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1353
|
+
});
|
|
1240
1354
|
return [min, max];
|
|
1241
|
-
}
|
|
1355
|
+
};
|
|
1242
1356
|
|
|
1243
|
-
|
|
1357
|
+
const mean = (columnId, leafRows) => {
|
|
1244
1358
|
let count = 0;
|
|
1245
1359
|
let sum = 0;
|
|
1360
|
+
leafRows.forEach(row => {
|
|
1361
|
+
let value = row.getValue(columnId);
|
|
1246
1362
|
|
|
1247
|
-
for (let value of getLeafValues()) {
|
|
1248
1363
|
if (value != null && (value = +value) >= value) {
|
|
1249
1364
|
++count, sum += value;
|
|
1250
1365
|
}
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1366
|
+
});
|
|
1253
1367
|
if (count) return sum / count;
|
|
1254
1368
|
return;
|
|
1255
|
-
}
|
|
1256
|
-
|
|
1257
|
-
function median(getLeafValues) {
|
|
1258
|
-
const leafValues = getLeafValues();
|
|
1369
|
+
};
|
|
1259
1370
|
|
|
1260
|
-
|
|
1371
|
+
const median = (columnId, leafRows) => {
|
|
1372
|
+
if (!leafRows.length) {
|
|
1261
1373
|
return;
|
|
1262
1374
|
}
|
|
1263
1375
|
|
|
1264
1376
|
let min = 0;
|
|
1265
1377
|
let max = 0;
|
|
1266
|
-
|
|
1378
|
+
leafRows.forEach(row => {
|
|
1379
|
+
let value = row.getValue(columnId);
|
|
1380
|
+
|
|
1267
1381
|
if (typeof value === 'number') {
|
|
1268
1382
|
min = Math.min(min, value);
|
|
1269
1383
|
max = Math.max(max, value);
|
|
1270
1384
|
}
|
|
1271
1385
|
});
|
|
1272
1386
|
return (min + max) / 2;
|
|
1273
|
-
}
|
|
1387
|
+
};
|
|
1274
1388
|
|
|
1275
|
-
|
|
1276
|
-
return Array.from(new Set(
|
|
1277
|
-
}
|
|
1389
|
+
const unique = (columnId, leafRows) => {
|
|
1390
|
+
return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
|
|
1391
|
+
};
|
|
1278
1392
|
|
|
1279
|
-
|
|
1280
|
-
return new Set(
|
|
1281
|
-
}
|
|
1393
|
+
const uniqueCount = (columnId, leafRows) => {
|
|
1394
|
+
return new Set(leafRows.map(d => d.getValue(columnId))).size;
|
|
1395
|
+
};
|
|
1282
1396
|
|
|
1283
|
-
|
|
1284
|
-
return
|
|
1285
|
-
}
|
|
1397
|
+
const count = (_columnId, leafRows) => {
|
|
1398
|
+
return leafRows.length;
|
|
1399
|
+
};
|
|
1400
|
+
|
|
1401
|
+
const aggregationFns = {
|
|
1402
|
+
sum,
|
|
1403
|
+
min,
|
|
1404
|
+
max,
|
|
1405
|
+
extent,
|
|
1406
|
+
mean,
|
|
1407
|
+
median,
|
|
1408
|
+
unique,
|
|
1409
|
+
uniqueCount,
|
|
1410
|
+
count
|
|
1411
|
+
};
|
|
1286
1412
|
|
|
1287
1413
|
//
|
|
1288
1414
|
const Grouping = {
|
|
@@ -1337,7 +1463,7 @@
|
|
|
1337
1463
|
column.toggleGrouping();
|
|
1338
1464
|
};
|
|
1339
1465
|
},
|
|
1340
|
-
|
|
1466
|
+
getAutoAggregationFn: () => {
|
|
1341
1467
|
const firstRow = instance.getCoreRowModel().flatRows[0];
|
|
1342
1468
|
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
|
1343
1469
|
|
|
@@ -1351,7 +1477,7 @@
|
|
|
1351
1477
|
|
|
1352
1478
|
return aggregationFns.count;
|
|
1353
1479
|
},
|
|
1354
|
-
|
|
1480
|
+
getAggregationFn: () => {
|
|
1355
1481
|
var _ref4;
|
|
1356
1482
|
|
|
1357
1483
|
const userAggregationFns = instance.options.aggregationFns;
|
|
@@ -1360,7 +1486,7 @@
|
|
|
1360
1486
|
throw new Error();
|
|
1361
1487
|
}
|
|
1362
1488
|
|
|
1363
|
-
return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.
|
|
1489
|
+
return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_ref4 = userAggregationFns == null ? void 0 : userAggregationFns[column.aggregationFn]) != null ? _ref4 : aggregationFns[column.aggregationFn];
|
|
1364
1490
|
}
|
|
1365
1491
|
};
|
|
1366
1492
|
},
|
|
@@ -1386,10 +1512,10 @@
|
|
|
1386
1512
|
}
|
|
1387
1513
|
};
|
|
1388
1514
|
},
|
|
1389
|
-
createRow:
|
|
1515
|
+
createRow: row => {
|
|
1390
1516
|
return {
|
|
1391
1517
|
getIsGrouped: () => !!row.groupingColumnId,
|
|
1392
|
-
|
|
1518
|
+
_groupingValuesCache: {}
|
|
1393
1519
|
};
|
|
1394
1520
|
},
|
|
1395
1521
|
createCell: (cell, column, row, instance) => {
|
|
@@ -1738,7 +1864,7 @@
|
|
|
1738
1864
|
return {
|
|
1739
1865
|
getCenterVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allCells, left, right) => {
|
|
1740
1866
|
const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
|
|
1741
|
-
return allCells.filter(d => !leftAndRight.includes(d.
|
|
1867
|
+
return allCells.filter(d => !leftAndRight.includes(d.column.id));
|
|
1742
1868
|
}, {
|
|
1743
1869
|
key: "development" === 'production' ,
|
|
1744
1870
|
debug: () => {
|
|
@@ -1748,7 +1874,7 @@
|
|
|
1748
1874
|
}
|
|
1749
1875
|
}),
|
|
1750
1876
|
getLeftVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.left,,], (allCells, left) => {
|
|
1751
|
-
const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.
|
|
1877
|
+
const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
|
|
1752
1878
|
position: 'left'
|
|
1753
1879
|
}));
|
|
1754
1880
|
return cells;
|
|
@@ -1761,7 +1887,7 @@
|
|
|
1761
1887
|
}
|
|
1762
1888
|
}),
|
|
1763
1889
|
getRightVisibleCells: memo(() => [row._getAllVisibleCells(), instance.getState().columnPinning.right], (allCells, right) => {
|
|
1764
|
-
const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.
|
|
1890
|
+
const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({ ...d,
|
|
1765
1891
|
position: 'left'
|
|
1766
1892
|
}));
|
|
1767
1893
|
return cells;
|
|
@@ -2534,11 +2660,6 @@
|
|
|
2534
2660
|
onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
|
|
2535
2661
|
};
|
|
2536
2662
|
},
|
|
2537
|
-
getDefaultColumnDef: () => {
|
|
2538
|
-
return {
|
|
2539
|
-
defaultIsVisible: true
|
|
2540
|
-
};
|
|
2541
|
-
},
|
|
2542
2663
|
createColumn: (column, instance) => {
|
|
2543
2664
|
return {
|
|
2544
2665
|
toggleVisibility: value => {
|
|
@@ -2570,477 +2691,72 @@
|
|
|
2570
2691
|
_getAllVisibleCells: memo(() => [row.getAllCells().filter(cell => cell.column.getIsVisible()).map(d => d.id).join('_')], _ => {
|
|
2571
2692
|
return row.getAllCells().filter(cell => cell.column.getIsVisible());
|
|
2572
2693
|
}, {
|
|
2573
|
-
key: "development" === 'production' ,
|
|
2574
|
-
debug: () => {
|
|
2575
|
-
var _instance$options$deb;
|
|
2576
|
-
|
|
2577
|
-
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
|
|
2578
|
-
}
|
|
2579
|
-
}),
|
|
2580
|
-
getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
|
|
2581
|
-
key: 'row.getVisibleCells',
|
|
2582
|
-
debug: () => {
|
|
2583
|
-
var _instance$options$deb2;
|
|
2584
|
-
|
|
2585
|
-
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
|
|
2586
|
-
}
|
|
2587
|
-
})
|
|
2588
|
-
};
|
|
2589
|
-
},
|
|
2590
|
-
createInstance: instance => {
|
|
2591
|
-
const makeVisibleColumnsMethod = (key, getColumns) => {
|
|
2592
|
-
return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
|
|
2593
|
-
return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
|
|
2594
|
-
}, {
|
|
2595
|
-
key,
|
|
2596
|
-
debug: () => {
|
|
2597
|
-
var _instance$options$deb3;
|
|
2598
|
-
|
|
2599
|
-
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
2600
|
-
}
|
|
2601
|
-
});
|
|
2602
|
-
};
|
|
2603
|
-
|
|
2604
|
-
return {
|
|
2605
|
-
getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
|
|
2606
|
-
getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
|
|
2607
|
-
getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
|
|
2608
|
-
getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
|
|
2609
|
-
getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
|
|
2610
|
-
setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
|
|
2611
|
-
resetColumnVisibility: defaultState => {
|
|
2612
|
-
var _instance$initialStat;
|
|
2613
|
-
|
|
2614
|
-
instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
|
|
2615
|
-
},
|
|
2616
|
-
toggleAllColumnsVisible: value => {
|
|
2617
|
-
var _value;
|
|
2618
|
-
|
|
2619
|
-
value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
|
|
2620
|
-
instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
|
|
2621
|
-
[column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
|
|
2622
|
-
}), {}));
|
|
2623
|
-
},
|
|
2624
|
-
getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
|
|
2625
|
-
getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
|
|
2626
|
-
getToggleAllColumnsVisibilityHandler: () => {
|
|
2627
|
-
return e => {
|
|
2628
|
-
var _target;
|
|
2629
|
-
|
|
2630
|
-
instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
|
|
2631
|
-
};
|
|
2632
|
-
}
|
|
2633
|
-
};
|
|
2634
|
-
}
|
|
2635
|
-
};
|
|
2636
|
-
|
|
2637
|
-
//
|
|
2638
|
-
const Headers = {
|
|
2639
|
-
createInstance: instance => {
|
|
2640
|
-
return {
|
|
2641
|
-
createHeader: (column, options) => {
|
|
2642
|
-
var _options$id;
|
|
2643
|
-
|
|
2644
|
-
const id = (_options$id = options.id) != null ? _options$id : column.id;
|
|
2645
|
-
let header = {
|
|
2646
|
-
id,
|
|
2647
|
-
column,
|
|
2648
|
-
index: options.index,
|
|
2649
|
-
isPlaceholder: options.isPlaceholder,
|
|
2650
|
-
placeholderId: options.placeholderId,
|
|
2651
|
-
depth: options.depth,
|
|
2652
|
-
subHeaders: [],
|
|
2653
|
-
colSpan: 0,
|
|
2654
|
-
rowSpan: 0,
|
|
2655
|
-
headerGroup: null,
|
|
2656
|
-
getLeafHeaders: () => {
|
|
2657
|
-
const leafHeaders = [];
|
|
2658
|
-
|
|
2659
|
-
const recurseHeader = h => {
|
|
2660
|
-
if (h.subHeaders && h.subHeaders.length) {
|
|
2661
|
-
h.subHeaders.map(recurseHeader);
|
|
2662
|
-
}
|
|
2663
|
-
|
|
2664
|
-
leafHeaders.push(h);
|
|
2665
|
-
};
|
|
2666
|
-
|
|
2667
|
-
recurseHeader(header);
|
|
2668
|
-
return leafHeaders;
|
|
2669
|
-
},
|
|
2670
|
-
renderHeader: () => column.columnDef.header ? instance._render(column.columnDef.header, {
|
|
2671
|
-
instance,
|
|
2672
|
-
header: header,
|
|
2673
|
-
column
|
|
2674
|
-
}) : null,
|
|
2675
|
-
renderFooter: () => column.columnDef.footer ? instance._render(column.columnDef.footer, {
|
|
2676
|
-
instance,
|
|
2677
|
-
header: header,
|
|
2678
|
-
column
|
|
2679
|
-
}) : null
|
|
2680
|
-
};
|
|
2681
|
-
|
|
2682
|
-
instance._features.forEach(feature => {
|
|
2683
|
-
Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
|
|
2684
|
-
});
|
|
2685
|
-
|
|
2686
|
-
return header;
|
|
2687
|
-
},
|
|
2688
|
-
// Header Groups
|
|
2689
|
-
getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
2690
|
-
var _left$map$filter, _right$map$filter;
|
|
2691
|
-
|
|
2692
|
-
const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
|
|
2693
|
-
const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
|
|
2694
|
-
const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
2695
|
-
const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
|
|
2696
|
-
return headerGroups;
|
|
2697
|
-
}, {
|
|
2698
|
-
key: 'getHeaderGroups',
|
|
2699
|
-
debug: () => {
|
|
2700
|
-
var _instance$options$deb;
|
|
2701
|
-
|
|
2702
|
-
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
|
|
2703
|
-
}
|
|
2704
|
-
}),
|
|
2705
|
-
getCenterHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
2706
|
-
leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
2707
|
-
return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
|
|
2708
|
-
}, {
|
|
2709
|
-
key: 'getCenterHeaderGroups',
|
|
2710
|
-
debug: () => {
|
|
2711
|
-
var _instance$options$deb2;
|
|
2712
|
-
|
|
2713
|
-
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
|
|
2714
|
-
}
|
|
2715
|
-
}),
|
|
2716
|
-
getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
2717
|
-
var _left$map$filter2;
|
|
2718
|
-
|
|
2719
|
-
const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
|
|
2720
|
-
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
|
|
2721
|
-
}, {
|
|
2722
|
-
key: 'getLeftHeaderGroups',
|
|
2723
|
-
debug: () => {
|
|
2724
|
-
var _instance$options$deb3;
|
|
2725
|
-
|
|
2726
|
-
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
|
|
2727
|
-
}
|
|
2728
|
-
}),
|
|
2729
|
-
getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
2730
|
-
var _right$map$filter2;
|
|
2731
|
-
|
|
2732
|
-
const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
|
|
2733
|
-
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
|
|
2734
|
-
}, {
|
|
2735
|
-
key: 'getRightHeaderGroups',
|
|
2736
|
-
debug: () => {
|
|
2737
|
-
var _instance$options$deb4;
|
|
2738
|
-
|
|
2739
|
-
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
|
|
2740
|
-
}
|
|
2741
|
-
}),
|
|
2742
|
-
// Footer Groups
|
|
2743
|
-
getFooterGroups: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
2744
|
-
return [...headerGroups].reverse();
|
|
2745
|
-
}, {
|
|
2746
|
-
key: 'getFooterGroups',
|
|
2747
|
-
debug: () => {
|
|
2748
|
-
var _instance$options$deb5;
|
|
2749
|
-
|
|
2750
|
-
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
|
|
2751
|
-
}
|
|
2752
|
-
}),
|
|
2753
|
-
getLeftFooterGroups: memo(() => [instance.getLeftHeaderGroups()], headerGroups => {
|
|
2754
|
-
return [...headerGroups].reverse();
|
|
2755
|
-
}, {
|
|
2756
|
-
key: 'getLeftFooterGroups',
|
|
2757
|
-
debug: () => {
|
|
2758
|
-
var _instance$options$deb6;
|
|
2759
|
-
|
|
2760
|
-
return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
|
|
2761
|
-
}
|
|
2762
|
-
}),
|
|
2763
|
-
getCenterFooterGroups: memo(() => [instance.getCenterHeaderGroups()], headerGroups => {
|
|
2764
|
-
return [...headerGroups].reverse();
|
|
2765
|
-
}, {
|
|
2766
|
-
key: 'getCenterFooterGroups',
|
|
2767
|
-
debug: () => {
|
|
2768
|
-
var _instance$options$deb7;
|
|
2769
|
-
|
|
2770
|
-
return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
|
|
2771
|
-
}
|
|
2772
|
-
}),
|
|
2773
|
-
getRightFooterGroups: memo(() => [instance.getRightHeaderGroups()], headerGroups => {
|
|
2774
|
-
return [...headerGroups].reverse();
|
|
2775
|
-
}, {
|
|
2776
|
-
key: 'getRightFooterGroups',
|
|
2777
|
-
debug: () => {
|
|
2778
|
-
var _instance$options$deb8;
|
|
2779
|
-
|
|
2780
|
-
return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
|
|
2781
|
-
}
|
|
2782
|
-
}),
|
|
2783
|
-
// Flat Headers
|
|
2784
|
-
getFlatHeaders: memo(() => [instance.getHeaderGroups()], headerGroups => {
|
|
2785
|
-
return headerGroups.map(headerGroup => {
|
|
2786
|
-
return headerGroup.headers;
|
|
2787
|
-
}).flat();
|
|
2788
|
-
}, {
|
|
2789
|
-
key: 'getFlatHeaders',
|
|
2790
|
-
debug: () => {
|
|
2791
|
-
var _instance$options$deb9;
|
|
2792
|
-
|
|
2793
|
-
return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
|
|
2794
|
-
}
|
|
2795
|
-
}),
|
|
2796
|
-
getLeftFlatHeaders: memo(() => [instance.getLeftHeaderGroups()], left => {
|
|
2797
|
-
return left.map(headerGroup => {
|
|
2798
|
-
return headerGroup.headers;
|
|
2799
|
-
}).flat();
|
|
2800
|
-
}, {
|
|
2801
|
-
key: 'getLeftFlatHeaders',
|
|
2802
|
-
debug: () => {
|
|
2803
|
-
var _instance$options$deb10;
|
|
2804
|
-
|
|
2805
|
-
return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
|
|
2806
|
-
}
|
|
2807
|
-
}),
|
|
2808
|
-
getCenterFlatHeaders: memo(() => [instance.getCenterHeaderGroups()], left => {
|
|
2809
|
-
return left.map(headerGroup => {
|
|
2810
|
-
return headerGroup.headers;
|
|
2811
|
-
}).flat();
|
|
2812
|
-
}, {
|
|
2813
|
-
key: 'getCenterFlatHeaders',
|
|
2814
|
-
debug: () => {
|
|
2815
|
-
var _instance$options$deb11;
|
|
2816
|
-
|
|
2817
|
-
return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
|
|
2818
|
-
}
|
|
2819
|
-
}),
|
|
2820
|
-
getRightFlatHeaders: memo(() => [instance.getRightHeaderGroups()], left => {
|
|
2821
|
-
return left.map(headerGroup => {
|
|
2822
|
-
return headerGroup.headers;
|
|
2823
|
-
}).flat();
|
|
2824
|
-
}, {
|
|
2825
|
-
key: 'getRightFlatHeaders',
|
|
2826
|
-
debug: () => {
|
|
2827
|
-
var _instance$options$deb12;
|
|
2828
|
-
|
|
2829
|
-
return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
|
|
2830
|
-
}
|
|
2831
|
-
}),
|
|
2832
|
-
// Leaf Headers
|
|
2833
|
-
getCenterLeafHeaders: memo(() => [instance.getCenterFlatHeaders()], flatHeaders => {
|
|
2834
|
-
return flatHeaders.filter(header => {
|
|
2835
|
-
var _header$subHeaders;
|
|
2836
|
-
|
|
2837
|
-
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
|
2838
|
-
});
|
|
2839
|
-
}, {
|
|
2840
|
-
key: 'getCenterLeafHeaders',
|
|
2841
|
-
debug: () => {
|
|
2842
|
-
var _instance$options$deb13;
|
|
2843
|
-
|
|
2844
|
-
return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
|
|
2845
|
-
}
|
|
2846
|
-
}),
|
|
2847
|
-
getLeftLeafHeaders: memo(() => [instance.getLeftFlatHeaders()], flatHeaders => {
|
|
2848
|
-
return flatHeaders.filter(header => {
|
|
2849
|
-
var _header$subHeaders2;
|
|
2850
|
-
|
|
2851
|
-
return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
|
|
2852
|
-
});
|
|
2853
|
-
}, {
|
|
2854
|
-
key: 'getLeftLeafHeaders',
|
|
2855
|
-
debug: () => {
|
|
2856
|
-
var _instance$options$deb14;
|
|
2857
|
-
|
|
2858
|
-
return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
|
|
2859
|
-
}
|
|
2860
|
-
}),
|
|
2861
|
-
getRightLeafHeaders: memo(() => [instance.getRightFlatHeaders()], flatHeaders => {
|
|
2862
|
-
return flatHeaders.filter(header => {
|
|
2863
|
-
var _header$subHeaders3;
|
|
2864
|
-
|
|
2865
|
-
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
|
2866
|
-
});
|
|
2867
|
-
}, {
|
|
2868
|
-
key: 'getRightLeafHeaders',
|
|
2694
|
+
key: "development" === 'production' ,
|
|
2869
2695
|
debug: () => {
|
|
2870
|
-
var _instance$options$
|
|
2696
|
+
var _instance$options$deb;
|
|
2871
2697
|
|
|
2872
|
-
return (_instance$options$
|
|
2698
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
|
|
2873
2699
|
}
|
|
2874
2700
|
}),
|
|
2875
|
-
|
|
2876
|
-
|
|
2701
|
+
getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
|
|
2702
|
+
key: 'row.getVisibleCells',
|
|
2703
|
+
debug: () => {
|
|
2704
|
+
var _instance$options$deb2;
|
|
2877
2705
|
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2706
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
|
|
2707
|
+
}
|
|
2708
|
+
})
|
|
2709
|
+
};
|
|
2710
|
+
},
|
|
2711
|
+
createInstance: instance => {
|
|
2712
|
+
const makeVisibleColumnsMethod = (key, getColumns) => {
|
|
2713
|
+
return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
|
|
2714
|
+
return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
|
|
2881
2715
|
}, {
|
|
2882
|
-
key
|
|
2716
|
+
key,
|
|
2883
2717
|
debug: () => {
|
|
2884
|
-
var _instance$options$
|
|
2718
|
+
var _instance$options$deb3;
|
|
2885
2719
|
|
|
2886
|
-
return (_instance$options$
|
|
2720
|
+
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
2887
2721
|
}
|
|
2888
|
-
})
|
|
2889
|
-
|
|
2890
|
-
const header = [...instance.getFlatHeaders(), ...instance.getCenterFlatHeaders(), ...instance.getLeftFlatHeaders(), ...instance.getRightFlatHeaders()].find(d => d.id === id);
|
|
2722
|
+
});
|
|
2723
|
+
};
|
|
2891
2724
|
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2725
|
+
return {
|
|
2726
|
+
getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', () => instance.getAllFlatColumns()),
|
|
2727
|
+
getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', () => instance.getAllLeafColumns()),
|
|
2728
|
+
getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => instance.getLeftLeafColumns()),
|
|
2729
|
+
getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => instance.getRightLeafColumns()),
|
|
2730
|
+
getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => instance.getCenterLeafColumns()),
|
|
2731
|
+
setColumnVisibility: updater => instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater),
|
|
2732
|
+
resetColumnVisibility: defaultState => {
|
|
2733
|
+
var _instance$initialStat;
|
|
2896
2734
|
|
|
2897
|
-
|
|
2898
|
-
|
|
2735
|
+
instance.setColumnVisibility(defaultState ? {} : (_instance$initialStat = instance.initialState.columnVisibility) != null ? _instance$initialStat : {});
|
|
2736
|
+
},
|
|
2737
|
+
toggleAllColumnsVisible: value => {
|
|
2738
|
+
var _value;
|
|
2739
|
+
|
|
2740
|
+
value = (_value = value) != null ? _value : !instance.getIsAllColumnsVisible();
|
|
2741
|
+
instance.setColumnVisibility(instance.getAllLeafColumns().reduce((obj, column) => ({ ...obj,
|
|
2742
|
+
[column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
|
|
2743
|
+
}), {}));
|
|
2744
|
+
},
|
|
2745
|
+
getIsAllColumnsVisible: () => !instance.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible())),
|
|
2746
|
+
getIsSomeColumnsVisible: () => instance.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible()),
|
|
2747
|
+
getToggleAllColumnsVisibilityHandler: () => {
|
|
2748
|
+
return e => {
|
|
2749
|
+
var _target;
|
|
2899
2750
|
|
|
2900
|
-
|
|
2751
|
+
instance.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
|
|
2752
|
+
};
|
|
2901
2753
|
}
|
|
2902
2754
|
};
|
|
2903
2755
|
}
|
|
2904
2756
|
};
|
|
2905
|
-
function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
|
|
2906
|
-
var _headerGroups$0$heade, _headerGroups$;
|
|
2907
|
-
|
|
2908
|
-
// Find the max depth of the columns:
|
|
2909
|
-
// build the leaf column row
|
|
2910
|
-
// build each buffer row going up
|
|
2911
|
-
// placeholder for non-existent level
|
|
2912
|
-
// real column for existing level
|
|
2913
|
-
let maxDepth = 0;
|
|
2914
|
-
|
|
2915
|
-
const findMaxDepth = function (columns, depth) {
|
|
2916
|
-
if (depth === void 0) {
|
|
2917
|
-
depth = 1;
|
|
2918
|
-
}
|
|
2919
|
-
|
|
2920
|
-
maxDepth = Math.max(maxDepth, depth);
|
|
2921
|
-
columns.filter(column => column.getIsVisible()).forEach(column => {
|
|
2922
|
-
var _column$columns;
|
|
2923
|
-
|
|
2924
|
-
if ((_column$columns = column.columns) != null && _column$columns.length) {
|
|
2925
|
-
findMaxDepth(column.columns, depth + 1);
|
|
2926
|
-
}
|
|
2927
|
-
}, 0);
|
|
2928
|
-
};
|
|
2929
|
-
|
|
2930
|
-
findMaxDepth(allColumns);
|
|
2931
|
-
let headerGroups = [];
|
|
2932
|
-
|
|
2933
|
-
const createHeaderGroup = (headersToGroup, depth) => {
|
|
2934
|
-
// The header group we are creating
|
|
2935
|
-
const headerGroup = {
|
|
2936
|
-
depth,
|
|
2937
|
-
id: [headerFamily, "" + depth].filter(Boolean).join('_'),
|
|
2938
|
-
headers: []
|
|
2939
|
-
}; // The parent columns we're going to scan next
|
|
2940
|
-
|
|
2941
|
-
const pendingParentHeaders = []; // Scan each column for parents
|
|
2942
|
-
|
|
2943
|
-
headersToGroup.forEach(headerToGroup => {
|
|
2944
|
-
// What is the latest (last) parent column?
|
|
2945
|
-
const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
|
|
2946
|
-
const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
|
|
2947
|
-
let column;
|
|
2948
|
-
let isPlaceholder = false;
|
|
2949
|
-
|
|
2950
|
-
if (isLeafHeader && headerToGroup.column.parent) {
|
|
2951
|
-
// The parent header is new
|
|
2952
|
-
column = headerToGroup.column.parent;
|
|
2953
|
-
} else {
|
|
2954
|
-
// The parent header is repeated
|
|
2955
|
-
column = headerToGroup.column;
|
|
2956
|
-
isPlaceholder = true;
|
|
2957
|
-
}
|
|
2958
|
-
|
|
2959
|
-
if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
|
|
2960
|
-
// This column is repeated. Add it as a sub header to the next batch
|
|
2961
|
-
latestPendingParentHeader.subHeaders.push(headerToGroup);
|
|
2962
|
-
} else {
|
|
2963
|
-
// This is a new header. Let's create it
|
|
2964
|
-
const header = instance.createHeader(column, {
|
|
2965
|
-
id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
|
|
2966
|
-
isPlaceholder,
|
|
2967
|
-
placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(d => d.column === column).length : undefined,
|
|
2968
|
-
depth,
|
|
2969
|
-
index: pendingParentHeaders.length
|
|
2970
|
-
}); // Add the headerToGroup as a subHeader of the new header
|
|
2971
|
-
|
|
2972
|
-
header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
|
|
2973
|
-
// in the next batch
|
|
2974
|
-
|
|
2975
|
-
pendingParentHeaders.push(header);
|
|
2976
|
-
}
|
|
2977
|
-
|
|
2978
|
-
headerGroup.headers.push(headerToGroup);
|
|
2979
|
-
headerToGroup.headerGroup = headerGroup;
|
|
2980
|
-
});
|
|
2981
|
-
headerGroups.push(headerGroup);
|
|
2982
|
-
|
|
2983
|
-
if (depth > 0) {
|
|
2984
|
-
createHeaderGroup(pendingParentHeaders, depth - 1);
|
|
2985
|
-
}
|
|
2986
|
-
};
|
|
2987
|
-
|
|
2988
|
-
const bottomHeaders = columnsToGroup.map((column, index) => instance.createHeader(column, {
|
|
2989
|
-
depth: maxDepth,
|
|
2990
|
-
index
|
|
2991
|
-
}));
|
|
2992
|
-
createHeaderGroup(bottomHeaders, maxDepth - 1);
|
|
2993
|
-
headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
|
|
2994
|
-
// return !headerGroup.headers.every(header => header.isPlaceholder)
|
|
2995
|
-
// })
|
|
2996
|
-
|
|
2997
|
-
const recurseHeadersForSpans = headers => {
|
|
2998
|
-
const filteredHeaders = headers.filter(header => header.column.getIsVisible());
|
|
2999
|
-
return filteredHeaders.map(header => {
|
|
3000
|
-
let colSpan = 0;
|
|
3001
|
-
let rowSpan = 0;
|
|
3002
|
-
let childRowSpans = [0];
|
|
3003
|
-
|
|
3004
|
-
if (header.subHeaders && header.subHeaders.length) {
|
|
3005
|
-
childRowSpans = [];
|
|
3006
|
-
recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
|
|
3007
|
-
let {
|
|
3008
|
-
colSpan: childColSpan,
|
|
3009
|
-
rowSpan: childRowSpan
|
|
3010
|
-
} = _ref;
|
|
3011
|
-
colSpan += childColSpan;
|
|
3012
|
-
childRowSpans.push(childRowSpan);
|
|
3013
|
-
});
|
|
3014
|
-
} else {
|
|
3015
|
-
colSpan = 1;
|
|
3016
|
-
}
|
|
3017
|
-
|
|
3018
|
-
const minChildRowSpan = Math.min(...childRowSpans);
|
|
3019
|
-
rowSpan = rowSpan + minChildRowSpan;
|
|
3020
|
-
header.colSpan = colSpan > 0 ? colSpan : undefined;
|
|
3021
|
-
header.rowSpan = rowSpan > 0 ? rowSpan : undefined;
|
|
3022
|
-
return {
|
|
3023
|
-
colSpan,
|
|
3024
|
-
rowSpan
|
|
3025
|
-
};
|
|
3026
|
-
});
|
|
3027
|
-
};
|
|
3028
2757
|
|
|
3029
|
-
|
|
3030
|
-
return headerGroups;
|
|
3031
|
-
}
|
|
2758
|
+
const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing]; //
|
|
3032
2759
|
|
|
3033
|
-
// export type Batch = {
|
|
3034
|
-
// id: number
|
|
3035
|
-
// priority: keyof CoreBatches
|
|
3036
|
-
// tasks: (() => void)[]
|
|
3037
|
-
// schedule: (cb: () => void) => void
|
|
3038
|
-
// cancel: () => void
|
|
3039
|
-
// }
|
|
3040
|
-
// type CoreBatches = {
|
|
3041
|
-
// data: Batch[]
|
|
3042
|
-
// facets: Batch[]
|
|
3043
|
-
// }
|
|
3044
2760
|
function createTableInstance(options) {
|
|
3045
2761
|
var _options$initialState;
|
|
3046
2762
|
|
|
@@ -3049,7 +2765,7 @@
|
|
|
3049
2765
|
}
|
|
3050
2766
|
|
|
3051
2767
|
let instance = {
|
|
3052
|
-
_features:
|
|
2768
|
+
_features: features
|
|
3053
2769
|
};
|
|
3054
2770
|
|
|
3055
2771
|
const defaultOptions = instance._features.reduce((obj, feature) => {
|
|
@@ -3066,8 +2782,7 @@
|
|
|
3066
2782
|
};
|
|
3067
2783
|
};
|
|
3068
2784
|
|
|
3069
|
-
const coreInitialState = {
|
|
3070
|
-
};
|
|
2785
|
+
const coreInitialState = {};
|
|
3071
2786
|
let initialState = { ...coreInitialState,
|
|
3072
2787
|
...((_options$initialState = options.initialState) != null ? _options$initialState : {})
|
|
3073
2788
|
};
|
|
@@ -3080,16 +2795,8 @@
|
|
|
3080
2795
|
|
|
3081
2796
|
const queued = [];
|
|
3082
2797
|
let queuedTimeout = false;
|
|
3083
|
-
const
|
|
3084
|
-
|
|
3085
|
-
// startWork()
|
|
3086
|
-
// },
|
|
3087
|
-
// willUpdate: () => {
|
|
3088
|
-
// startWork()
|
|
3089
|
-
// },
|
|
3090
|
-
// destroy: () => {
|
|
3091
|
-
// stopWork()
|
|
3092
|
-
// },
|
|
2798
|
+
const coreInstance = {
|
|
2799
|
+
_features: features,
|
|
3093
2800
|
options: { ...defaultOptions,
|
|
3094
2801
|
...options
|
|
3095
2802
|
},
|
|
@@ -3135,29 +2842,134 @@
|
|
|
3135
2842
|
},
|
|
3136
2843
|
setState: updater => {
|
|
3137
2844
|
instance.options.onStateChange == null ? void 0 : instance.options.onStateChange(updater);
|
|
3138
|
-
}
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
//
|
|
3152
|
-
//
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
2845
|
+
},
|
|
2846
|
+
_getRowId: (row, index, parent) => {
|
|
2847
|
+
var _instance$options$get;
|
|
2848
|
+
|
|
2849
|
+
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);
|
|
2850
|
+
},
|
|
2851
|
+
getCoreRowModel: () => {
|
|
2852
|
+
if (!instance._getCoreRowModel) {
|
|
2853
|
+
instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
|
|
2854
|
+
}
|
|
2855
|
+
|
|
2856
|
+
return instance._getCoreRowModel();
|
|
2857
|
+
},
|
|
2858
|
+
// The final calls start at the bottom of the model,
|
|
2859
|
+
// expanded rows, which then work their way up
|
|
2860
|
+
getRowModel: () => {
|
|
2861
|
+
return instance.getPaginationRowModel();
|
|
2862
|
+
},
|
|
2863
|
+
getRow: id => {
|
|
2864
|
+
const row = instance.getRowModel().rowsById[id];
|
|
3158
2865
|
|
|
2866
|
+
if (!row) {
|
|
2867
|
+
{
|
|
2868
|
+
throw new Error("getRow expected an ID, but got " + id);
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2872
|
+
return row;
|
|
2873
|
+
},
|
|
2874
|
+
_getDefaultColumnDef: memo(() => [instance.options.defaultColumn], defaultColumn => {
|
|
2875
|
+
var _defaultColumn;
|
|
2876
|
+
|
|
2877
|
+
defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
|
|
2878
|
+
return {
|
|
2879
|
+
header: props => props.header.column.id,
|
|
2880
|
+
footer: props => props.header.column.id,
|
|
2881
|
+
cell: props => {
|
|
2882
|
+
var _props$getValue$toStr, _props$getValue$toStr2, _props$getValue;
|
|
2883
|
+
|
|
2884
|
+
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;
|
|
2885
|
+
},
|
|
2886
|
+
...instance._features.reduce((obj, feature) => {
|
|
2887
|
+
return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
|
|
2888
|
+
}, {}),
|
|
2889
|
+
...defaultColumn
|
|
2890
|
+
};
|
|
2891
|
+
}, {
|
|
2892
|
+
debug: () => {
|
|
2893
|
+
var _instance$options$deb;
|
|
2894
|
+
|
|
2895
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
|
|
2896
|
+
},
|
|
2897
|
+
key: 'getDefaultColumnDef'
|
|
2898
|
+
}),
|
|
2899
|
+
_getColumnDefs: () => instance.options.columns,
|
|
2900
|
+
getAllColumns: memo(() => [instance._getColumnDefs()], columnDefs => {
|
|
2901
|
+
const recurseColumns = function (columnDefs, parent, depth) {
|
|
2902
|
+
if (depth === void 0) {
|
|
2903
|
+
depth = 0;
|
|
2904
|
+
}
|
|
2905
|
+
|
|
2906
|
+
return columnDefs.map(columnDef => {
|
|
2907
|
+
const column = createColumn(instance, columnDef, depth, parent);
|
|
2908
|
+
column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
|
|
2909
|
+
return column;
|
|
2910
|
+
});
|
|
2911
|
+
};
|
|
2912
|
+
|
|
2913
|
+
return recurseColumns(columnDefs);
|
|
2914
|
+
}, {
|
|
2915
|
+
key: 'getAllColumns',
|
|
2916
|
+
debug: () => {
|
|
2917
|
+
var _instance$options$deb2;
|
|
2918
|
+
|
|
2919
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
|
|
2920
|
+
}
|
|
2921
|
+
}),
|
|
2922
|
+
getAllFlatColumns: memo(() => [instance.getAllColumns()], allColumns => {
|
|
2923
|
+
return allColumns.flatMap(column => {
|
|
2924
|
+
return column.getFlatColumns();
|
|
2925
|
+
});
|
|
2926
|
+
}, {
|
|
2927
|
+
key: 'getAllFlatColumns',
|
|
2928
|
+
debug: () => {
|
|
2929
|
+
var _instance$options$deb3;
|
|
2930
|
+
|
|
2931
|
+
return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
|
|
2932
|
+
}
|
|
2933
|
+
}),
|
|
2934
|
+
_getAllFlatColumnsById: memo(() => [instance.getAllFlatColumns()], flatColumns => {
|
|
2935
|
+
return flatColumns.reduce((acc, column) => {
|
|
2936
|
+
acc[column.id] = column;
|
|
2937
|
+
return acc;
|
|
2938
|
+
}, {});
|
|
2939
|
+
}, {
|
|
2940
|
+
key: 'getAllFlatColumnsById',
|
|
2941
|
+
debug: () => {
|
|
2942
|
+
var _instance$options$deb4;
|
|
2943
|
+
|
|
2944
|
+
return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
|
|
2945
|
+
}
|
|
2946
|
+
}),
|
|
2947
|
+
getAllLeafColumns: memo(() => [instance.getAllColumns(), instance._getOrderColumnsFn()], (allColumns, orderColumns) => {
|
|
2948
|
+
let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
|
|
2949
|
+
return orderColumns(leafColumns);
|
|
2950
|
+
}, {
|
|
2951
|
+
key: 'getAllLeafColumns',
|
|
2952
|
+
debug: () => {
|
|
2953
|
+
var _instance$options$deb5;
|
|
2954
|
+
|
|
2955
|
+
return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
|
|
2956
|
+
}
|
|
2957
|
+
}),
|
|
2958
|
+
getColumn: columnId => {
|
|
2959
|
+
const column = instance._getAllFlatColumnsById()[columnId];
|
|
2960
|
+
|
|
2961
|
+
if (!column) {
|
|
2962
|
+
{
|
|
2963
|
+
console.warn("[Table] Column with id " + columnId + " does not exist.");
|
|
2964
|
+
}
|
|
2965
|
+
|
|
2966
|
+
throw new Error();
|
|
2967
|
+
}
|
|
2968
|
+
|
|
2969
|
+
return column;
|
|
2970
|
+
}
|
|
3159
2971
|
};
|
|
3160
|
-
|
|
2972
|
+
Object.assign(instance, coreInstance);
|
|
3161
2973
|
|
|
3162
2974
|
instance._features.forEach(feature => {
|
|
3163
2975
|
return Object.assign(instance, feature.createInstance == null ? void 0 : feature.createInstance(instance));
|
|
@@ -3222,6 +3034,86 @@
|
|
|
3222
3034
|
return table;
|
|
3223
3035
|
}
|
|
3224
3036
|
|
|
3037
|
+
function createCell(instance, row, column, columnId) {
|
|
3038
|
+
const cell = {
|
|
3039
|
+
id: row.id + "_" + column.id,
|
|
3040
|
+
row,
|
|
3041
|
+
column,
|
|
3042
|
+
getValue: () => row.getValue(columnId),
|
|
3043
|
+
renderCell: () => column.columnDef.cell ? instance._render(column.columnDef.cell, {
|
|
3044
|
+
instance,
|
|
3045
|
+
column,
|
|
3046
|
+
row,
|
|
3047
|
+
cell: cell,
|
|
3048
|
+
getValue: cell.getValue
|
|
3049
|
+
}) : null
|
|
3050
|
+
};
|
|
3051
|
+
|
|
3052
|
+
instance._features.forEach(feature => {
|
|
3053
|
+
Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
|
|
3054
|
+
}, {});
|
|
3055
|
+
|
|
3056
|
+
return cell;
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
const createRow = (instance, id, original, rowIndex, depth, subRows) => {
|
|
3060
|
+
let row = {
|
|
3061
|
+
id,
|
|
3062
|
+
index: rowIndex,
|
|
3063
|
+
original,
|
|
3064
|
+
depth,
|
|
3065
|
+
_valuesCache: {},
|
|
3066
|
+
getValue: columnId => {
|
|
3067
|
+
if (row._valuesCache.hasOwnProperty(columnId)) {
|
|
3068
|
+
return row._valuesCache[columnId];
|
|
3069
|
+
}
|
|
3070
|
+
|
|
3071
|
+
const column = instance.getColumn(columnId);
|
|
3072
|
+
|
|
3073
|
+
if (!column.accessorFn) {
|
|
3074
|
+
return undefined;
|
|
3075
|
+
}
|
|
3076
|
+
|
|
3077
|
+
row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
|
3078
|
+
return row._valuesCache[columnId];
|
|
3079
|
+
},
|
|
3080
|
+
subRows: subRows != null ? subRows : [],
|
|
3081
|
+
getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
|
|
3082
|
+
getAllCells: memo(() => [instance.getAllLeafColumns()], leafColumns => {
|
|
3083
|
+
return leafColumns.map(column => {
|
|
3084
|
+
return createCell(instance, row, column, column.id);
|
|
3085
|
+
});
|
|
3086
|
+
}, {
|
|
3087
|
+
key: 'row.getAllCells',
|
|
3088
|
+
debug: () => {
|
|
3089
|
+
var _instance$options$deb;
|
|
3090
|
+
|
|
3091
|
+
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
|
|
3092
|
+
}
|
|
3093
|
+
}),
|
|
3094
|
+
_getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
|
|
3095
|
+
return allCells.reduce((acc, cell) => {
|
|
3096
|
+
acc[cell.column.id] = cell;
|
|
3097
|
+
return acc;
|
|
3098
|
+
}, {});
|
|
3099
|
+
}, {
|
|
3100
|
+
key: "development" === 'production' ,
|
|
3101
|
+
debug: () => {
|
|
3102
|
+
var _instance$options$deb2;
|
|
3103
|
+
|
|
3104
|
+
return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
|
|
3105
|
+
}
|
|
3106
|
+
})
|
|
3107
|
+
};
|
|
3108
|
+
|
|
3109
|
+
for (let i = 0; i < instance._features.length; i++) {
|
|
3110
|
+
const feature = instance._features[i];
|
|
3111
|
+
Object.assign(row, feature == null ? void 0 : feature.createRow == null ? void 0 : feature.createRow(row, instance));
|
|
3112
|
+
}
|
|
3113
|
+
|
|
3114
|
+
return row;
|
|
3115
|
+
};
|
|
3116
|
+
|
|
3225
3117
|
function getCoreRowModel() {
|
|
3226
3118
|
return instance => memo(() => [instance.options.data], data => {
|
|
3227
3119
|
const rowModel = {
|
|
@@ -3249,7 +3141,7 @@
|
|
|
3249
3141
|
// }
|
|
3250
3142
|
// Make the row
|
|
3251
3143
|
|
|
3252
|
-
row =
|
|
3144
|
+
row = createRow(instance, instance._getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
|
|
3253
3145
|
|
|
3254
3146
|
rowModel.flatRows.push(row); // Also keep track of every row by its ID
|
|
3255
3147
|
|
|
@@ -3312,7 +3204,7 @@
|
|
|
3312
3204
|
row = rowsToFilter[i];
|
|
3313
3205
|
|
|
3314
3206
|
if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
|
|
3315
|
-
newRow =
|
|
3207
|
+
newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3316
3208
|
newRow.columnFilters = row.columnFilters;
|
|
3317
3209
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3318
3210
|
|
|
@@ -3362,7 +3254,7 @@
|
|
|
3362
3254
|
var _row$subRows2;
|
|
3363
3255
|
|
|
3364
3256
|
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
|
|
3365
|
-
newRow =
|
|
3257
|
+
newRow = createRow(instance, row.id, row.original, row.index, row.depth);
|
|
3366
3258
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3367
3259
|
row = newRow;
|
|
3368
3260
|
}
|
|
@@ -3729,7 +3621,7 @@
|
|
|
3729
3621
|
const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
|
|
3730
3622
|
|
|
3731
3623
|
const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
|
|
3732
|
-
const row =
|
|
3624
|
+
const row = createRow(instance, id, undefined, index, depth);
|
|
3733
3625
|
Object.assign(row, {
|
|
3734
3626
|
groupingColumnId: columnId,
|
|
3735
3627
|
groupingValue,
|
|
@@ -3738,38 +3630,30 @@
|
|
|
3738
3630
|
getValue: columnId => {
|
|
3739
3631
|
// Don't aggregate columns that are in the grouping
|
|
3740
3632
|
if (existingGrouping.includes(columnId)) {
|
|
3741
|
-
if (row.
|
|
3742
|
-
return row.
|
|
3633
|
+
if (row._valuesCache.hasOwnProperty(columnId)) {
|
|
3634
|
+
return row._valuesCache[columnId];
|
|
3743
3635
|
}
|
|
3744
3636
|
|
|
3745
3637
|
if (groupedRows[0]) {
|
|
3746
3638
|
var _groupedRows$0$getVal;
|
|
3747
3639
|
|
|
3748
|
-
row.
|
|
3640
|
+
row._valuesCache[columnId] = (_groupedRows$0$getVal = groupedRows[0].getValue(columnId)) != null ? _groupedRows$0$getVal : undefined;
|
|
3749
3641
|
}
|
|
3750
3642
|
|
|
3751
|
-
return row.
|
|
3643
|
+
return row._valuesCache[columnId];
|
|
3752
3644
|
}
|
|
3753
3645
|
|
|
3754
|
-
if (row.
|
|
3755
|
-
return row.
|
|
3646
|
+
if (row._groupingValuesCache.hasOwnProperty(columnId)) {
|
|
3647
|
+
return row._groupingValuesCache[columnId];
|
|
3756
3648
|
} // Aggregate the values
|
|
3757
3649
|
|
|
3758
3650
|
|
|
3759
3651
|
const column = instance.getColumn(columnId);
|
|
3760
|
-
const aggregateFn = column.
|
|
3652
|
+
const aggregateFn = column.getAggregationFn();
|
|
3761
3653
|
|
|
3762
3654
|
if (aggregateFn) {
|
|
3763
|
-
row.
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
if (!depth && column.columnDef.aggregateValue) {
|
|
3767
|
-
columnValue = column.columnDef.aggregateValue(columnValue);
|
|
3768
|
-
}
|
|
3769
|
-
|
|
3770
|
-
return columnValue;
|
|
3771
|
-
}), () => groupedRows.map(row => row.getValue(columnId)));
|
|
3772
|
-
return row.groupingValuesCache[columnId];
|
|
3655
|
+
row._groupingValuesCache[columnId] = aggregateFn(columnId, leafRows, groupedRows);
|
|
3656
|
+
return row._groupingValuesCache[columnId];
|
|
3773
3657
|
} else if (column.aggregationFn) {
|
|
3774
3658
|
console.info({
|
|
3775
3659
|
column
|
|
@@ -3849,7 +3733,7 @@
|
|
|
3849
3733
|
return rowModel;
|
|
3850
3734
|
}
|
|
3851
3735
|
|
|
3852
|
-
return expandRows(rowModel
|
|
3736
|
+
return expandRows(rowModel);
|
|
3853
3737
|
}, {
|
|
3854
3738
|
key: 'getExpandedRowModel',
|
|
3855
3739
|
debug: () => {
|
|
@@ -3867,7 +3751,7 @@
|
|
|
3867
3751
|
|
|
3868
3752
|
expandedRows.push(row);
|
|
3869
3753
|
|
|
3870
|
-
if (
|
|
3754
|
+
if ((_row$subRows = row.subRows) != null && _row$subRows.length && row.getIsExpanded()) {
|
|
3871
3755
|
row.subRows.forEach(handleRow);
|
|
3872
3756
|
}
|
|
3873
3757
|
};
|
|
@@ -3904,7 +3788,7 @@
|
|
|
3904
3788
|
rows,
|
|
3905
3789
|
flatRows,
|
|
3906
3790
|
rowsById
|
|
3907
|
-
}
|
|
3791
|
+
});
|
|
3908
3792
|
}
|
|
3909
3793
|
|
|
3910
3794
|
return {
|
|
@@ -3935,6 +3819,8 @@
|
|
|
3935
3819
|
exports.Visibility = Visibility;
|
|
3936
3820
|
exports.aggregationFns = aggregationFns;
|
|
3937
3821
|
exports.buildHeaderGroups = buildHeaderGroups;
|
|
3822
|
+
exports.createColumn = createColumn;
|
|
3823
|
+
exports.createRow = createRow;
|
|
3938
3824
|
exports.createTableFactory = createTableFactory;
|
|
3939
3825
|
exports.createTableInstance = createTableInstance;
|
|
3940
3826
|
exports.defaultColumnSizing = defaultColumnSizing;
|
|
@@ -3954,7 +3840,6 @@
|
|
|
3954
3840
|
exports.isFunction = isFunction;
|
|
3955
3841
|
exports.isRowSelected = isRowSelected;
|
|
3956
3842
|
exports.makeStateUpdater = makeStateUpdater;
|
|
3957
|
-
exports.mean = mean;
|
|
3958
3843
|
exports.memo = memo;
|
|
3959
3844
|
exports.noop = noop;
|
|
3960
3845
|
exports.orderColumns = orderColumns;
|