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