msw-dev-tool 1.1.4 → 1.1.5
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/dist/cjs/index.js +28242 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/msw-dev-tool.css +1 -1
- package/dist/esm/index.js +28226 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/msw-dev-tool.css +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +6 -2
- package/dist/cjs/_virtual/_commonjsHelpers.js +0 -6
- package/dist/cjs/_virtual/_commonjsHelpers.js.map +0 -1
- package/dist/cjs/_virtual/lodash.js +0 -6
- package/dist/cjs/_virtual/lodash.js.map +0 -1
- package/dist/cjs/const/handler.js +0 -10
- package/dist/cjs/const/handler.js.map +0 -1
- package/dist/cjs/hook/useFlattenHandlersTable.js +0 -71
- package/dist/cjs/hook/useFlattenHandlersTable.js.map +0 -1
- package/dist/cjs/lib/handlerStore.js +0 -66
- package/dist/cjs/lib/handlerStore.js.map +0 -1
- package/dist/cjs/lib/util.js +0 -64
- package/dist/cjs/lib/util.js.map +0 -1
- package/dist/cjs/node_modules/.pnpm/@tanstack_react-table@8.20.6_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@tanstack/react-table/build/lib/index.js +0 -137
- package/dist/cjs/node_modules/.pnpm/@tanstack_react-table@8.20.6_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@tanstack/react-table/build/lib/index.js.map +0 -1
- package/dist/cjs/node_modules/.pnpm/@tanstack_table-core@8.20.5/node_modules/@tanstack/table-core/build/lib/index.js +0 -3012
- package/dist/cjs/node_modules/.pnpm/@tanstack_table-core@8.20.5/node_modules/@tanstack/table-core/build/lib/index.js.map +0 -1
- package/dist/cjs/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js +0 -17209
- package/dist/cjs/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js.map +0 -1
- package/dist/cjs/store/uiControlStore.js +0 -13
- package/dist/cjs/store/uiControlStore.js.map +0 -1
- package/dist/cjs/ui/DevToolContent/DevToolContentContainer.js +0 -18
- package/dist/cjs/ui/DevToolContent/DevToolContentContainer.js.map +0 -1
- package/dist/cjs/ui/DevToolContent/HttpControl.js +0 -21
- package/dist/cjs/ui/DevToolContent/HttpControl.js.map +0 -1
- package/dist/cjs/ui/MSWDevTool.js +0 -16
- package/dist/cjs/ui/MSWDevTool.js.map +0 -1
- package/dist/cjs/ui/Table/PreviewHandler/KeyValueInputList.js +0 -73
- package/dist/cjs/ui/Table/PreviewHandler/KeyValueInputList.js.map +0 -1
- package/dist/cjs/ui/Table/PreviewHandler/PathParamSetter.js +0 -22
- package/dist/cjs/ui/Table/PreviewHandler/PathParamSetter.js.map +0 -1
- package/dist/cjs/ui/Table/PreviewHandler/RequestPreview.js +0 -68
- package/dist/cjs/ui/Table/PreviewHandler/RequestPreview.js.map +0 -1
- package/dist/cjs/ui/Table/PreviewHandler/index.js +0 -61
- package/dist/cjs/ui/Table/PreviewHandler/index.js.map +0 -1
- package/dist/cjs/utils/url.js +0 -43
- package/dist/cjs/utils/url.js.map +0 -1
- package/dist/esm/_virtual/_commonjsHelpers.js +0 -4
- package/dist/esm/_virtual/_commonjsHelpers.js.map +0 -1
- package/dist/esm/_virtual/lodash.js +0 -4
- package/dist/esm/_virtual/lodash.js.map +0 -1
- package/dist/esm/const/handler.js +0 -7
- package/dist/esm/const/handler.js.map +0 -1
- package/dist/esm/hook/useFlattenHandlersTable.js +0 -69
- package/dist/esm/hook/useFlattenHandlersTable.js.map +0 -1
- package/dist/esm/lib/handlerStore.js +0 -63
- package/dist/esm/lib/handlerStore.js.map +0 -1
- package/dist/esm/lib/util.js +0 -58
- package/dist/esm/lib/util.js.map +0 -1
- package/dist/esm/node_modules/.pnpm/@tanstack_react-table@8.20.6_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@tanstack/react-table/build/lib/index.js +0 -75
- package/dist/esm/node_modules/.pnpm/@tanstack_react-table@8.20.6_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@tanstack/react-table/build/lib/index.js.map +0 -1
- package/dist/esm/node_modules/.pnpm/@tanstack_table-core@8.20.5/node_modules/@tanstack/table-core/build/lib/index.js +0 -2970
- package/dist/esm/node_modules/.pnpm/@tanstack_table-core@8.20.5/node_modules/@tanstack/table-core/build/lib/index.js.map +0 -1
- package/dist/esm/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js +0 -17207
- package/dist/esm/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js.map +0 -1
- package/dist/esm/store/uiControlStore.js +0 -11
- package/dist/esm/store/uiControlStore.js.map +0 -1
- package/dist/esm/ui/DevToolContent/DevToolContentContainer.js +0 -16
- package/dist/esm/ui/DevToolContent/DevToolContentContainer.js.map +0 -1
- package/dist/esm/ui/DevToolContent/HttpControl.js +0 -19
- package/dist/esm/ui/DevToolContent/HttpControl.js.map +0 -1
- package/dist/esm/ui/MSWDevTool.js +0 -14
- package/dist/esm/ui/MSWDevTool.js.map +0 -1
- package/dist/esm/ui/Table/PreviewHandler/KeyValueInputList.js +0 -71
- package/dist/esm/ui/Table/PreviewHandler/KeyValueInputList.js.map +0 -1
- package/dist/esm/ui/Table/PreviewHandler/PathParamSetter.js +0 -20
- package/dist/esm/ui/Table/PreviewHandler/PathParamSetter.js.map +0 -1
- package/dist/esm/ui/Table/PreviewHandler/RequestPreview.js +0 -66
- package/dist/esm/ui/Table/PreviewHandler/RequestPreview.js.map +0 -1
- package/dist/esm/ui/Table/PreviewHandler/index.js +0 -59
- package/dist/esm/ui/Table/PreviewHandler/index.js.map +0 -1
- package/dist/esm/utils/url.js +0 -39
- package/dist/esm/utils/url.js.map +0 -1
@@ -1,2970 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* table-core
|
3
|
-
*
|
4
|
-
* Copyright (c) TanStack
|
5
|
-
*
|
6
|
-
* This source code is licensed under the MIT license found in the
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
8
|
-
*
|
9
|
-
* @license MIT
|
10
|
-
*/
|
11
|
-
// type Person = {
|
12
|
-
// firstName: string
|
13
|
-
// lastName: string
|
14
|
-
// age: number
|
15
|
-
// visits: number
|
16
|
-
// status: string
|
17
|
-
// progress: number
|
18
|
-
// createdAt: Date
|
19
|
-
// nested: {
|
20
|
-
// foo: [
|
21
|
-
// {
|
22
|
-
// bar: 'bar'
|
23
|
-
// }
|
24
|
-
// ]
|
25
|
-
// bar: { subBar: boolean }[]
|
26
|
-
// baz: {
|
27
|
-
// foo: 'foo'
|
28
|
-
// bar: {
|
29
|
-
// baz: 'baz'
|
30
|
-
// }
|
31
|
-
// }
|
32
|
-
// }
|
33
|
-
// }
|
34
|
-
|
35
|
-
// const test: DeepKeys<Person> = 'nested.foo.0.bar'
|
36
|
-
// const test2: DeepKeys<Person> = 'nested.bar'
|
37
|
-
|
38
|
-
// const helper = createColumnHelper<Person>()
|
39
|
-
|
40
|
-
// helper.accessor('nested.foo', {
|
41
|
-
// cell: info => info.getValue(),
|
42
|
-
// })
|
43
|
-
|
44
|
-
// helper.accessor('nested.foo.0.bar', {
|
45
|
-
// cell: info => info.getValue(),
|
46
|
-
// })
|
47
|
-
|
48
|
-
// helper.accessor('nested.bar', {
|
49
|
-
// cell: info => info.getValue(),
|
50
|
-
// })
|
51
|
-
|
52
|
-
function createColumnHelper() {
|
53
|
-
return {
|
54
|
-
accessor: (accessor, column) => {
|
55
|
-
return typeof accessor === 'function' ? {
|
56
|
-
...column,
|
57
|
-
accessorFn: accessor
|
58
|
-
} : {
|
59
|
-
...column,
|
60
|
-
accessorKey: accessor
|
61
|
-
};
|
62
|
-
},
|
63
|
-
display: column => column,
|
64
|
-
group: column => column
|
65
|
-
};
|
66
|
-
}
|
67
|
-
|
68
|
-
// Is this type a tuple?
|
69
|
-
|
70
|
-
// If this type is a tuple, what indices are allowed?
|
71
|
-
|
72
|
-
///
|
73
|
-
|
74
|
-
function functionalUpdate(updater, input) {
|
75
|
-
return typeof updater === 'function' ? updater(input) : updater;
|
76
|
-
}
|
77
|
-
function makeStateUpdater(key, instance) {
|
78
|
-
return updater => {
|
79
|
-
instance.setState(old => {
|
80
|
-
return {
|
81
|
-
...old,
|
82
|
-
[key]: functionalUpdate(updater, old[key])
|
83
|
-
};
|
84
|
-
});
|
85
|
-
};
|
86
|
-
}
|
87
|
-
function isFunction(d) {
|
88
|
-
return d instanceof Function;
|
89
|
-
}
|
90
|
-
function isNumberArray(d) {
|
91
|
-
return Array.isArray(d) && d.every(val => typeof val === 'number');
|
92
|
-
}
|
93
|
-
function flattenBy(arr, getChildren) {
|
94
|
-
const flat = [];
|
95
|
-
const recurse = subArr => {
|
96
|
-
subArr.forEach(item => {
|
97
|
-
flat.push(item);
|
98
|
-
const children = getChildren(item);
|
99
|
-
if (children != null && children.length) {
|
100
|
-
recurse(children);
|
101
|
-
}
|
102
|
-
});
|
103
|
-
};
|
104
|
-
recurse(arr);
|
105
|
-
return flat;
|
106
|
-
}
|
107
|
-
function memo(getDeps, fn, opts) {
|
108
|
-
let deps = [];
|
109
|
-
let result;
|
110
|
-
return depArgs => {
|
111
|
-
let depTime;
|
112
|
-
if (opts.key && opts.debug) depTime = Date.now();
|
113
|
-
const newDeps = getDeps(depArgs);
|
114
|
-
const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
|
115
|
-
if (!depsChanged) {
|
116
|
-
return result;
|
117
|
-
}
|
118
|
-
deps = newDeps;
|
119
|
-
let resultTime;
|
120
|
-
if (opts.key && opts.debug) resultTime = Date.now();
|
121
|
-
result = fn(...newDeps);
|
122
|
-
opts == null || opts.onChange == null || opts.onChange(result);
|
123
|
-
if (opts.key && opts.debug) {
|
124
|
-
if (opts != null && opts.debug()) {
|
125
|
-
const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
|
126
|
-
const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
|
127
|
-
const resultFpsPercentage = resultEndTime / 16;
|
128
|
-
const pad = (str, num) => {
|
129
|
-
str = String(str);
|
130
|
-
while (str.length < num) {
|
131
|
-
str = ' ' + str;
|
132
|
-
}
|
133
|
-
return str;
|
134
|
-
};
|
135
|
-
console.info(`%c⏱ ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`, `
|
136
|
-
font-size: .6rem;
|
137
|
-
font-weight: bold;
|
138
|
-
color: hsl(${Math.max(0, Math.min(120 - 120 * resultFpsPercentage, 120))}deg 100% 31%);`, opts == null ? void 0 : opts.key);
|
139
|
-
}
|
140
|
-
}
|
141
|
-
return result;
|
142
|
-
};
|
143
|
-
}
|
144
|
-
function getMemoOptions(tableOptions, debugLevel, key, onChange) {
|
145
|
-
return {
|
146
|
-
debug: () => {
|
147
|
-
var _tableOptions$debugAl;
|
148
|
-
return (_tableOptions$debugAl = tableOptions == null ? void 0 : tableOptions.debugAll) != null ? _tableOptions$debugAl : tableOptions[debugLevel];
|
149
|
-
},
|
150
|
-
key: process.env.NODE_ENV === 'development' && key,
|
151
|
-
onChange
|
152
|
-
};
|
153
|
-
}
|
154
|
-
|
155
|
-
function createCell(table, row, column, columnId) {
|
156
|
-
const getRenderValue = () => {
|
157
|
-
var _cell$getValue;
|
158
|
-
return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : table.options.renderFallbackValue;
|
159
|
-
};
|
160
|
-
const cell = {
|
161
|
-
id: `${row.id}_${column.id}`,
|
162
|
-
row,
|
163
|
-
column,
|
164
|
-
getValue: () => row.getValue(columnId),
|
165
|
-
renderValue: getRenderValue,
|
166
|
-
getContext: memo(() => [table, column, row, cell], (table, column, row, cell) => ({
|
167
|
-
table,
|
168
|
-
column,
|
169
|
-
row,
|
170
|
-
cell: cell,
|
171
|
-
getValue: cell.getValue,
|
172
|
-
renderValue: cell.renderValue
|
173
|
-
}), getMemoOptions(table.options, 'debugCells', 'cell.getContext'))
|
174
|
-
};
|
175
|
-
table._features.forEach(feature => {
|
176
|
-
feature.createCell == null || feature.createCell(cell, column, row, table);
|
177
|
-
}, {});
|
178
|
-
return cell;
|
179
|
-
}
|
180
|
-
|
181
|
-
function createColumn(table, columnDef, depth, parent) {
|
182
|
-
var _ref, _resolvedColumnDef$id;
|
183
|
-
const defaultColumn = table._getDefaultColumnDef();
|
184
|
-
const resolvedColumnDef = {
|
185
|
-
...defaultColumn,
|
186
|
-
...columnDef
|
187
|
-
};
|
188
|
-
const accessorKey = resolvedColumnDef.accessorKey;
|
189
|
-
let id = (_ref = (_resolvedColumnDef$id = resolvedColumnDef.id) != null ? _resolvedColumnDef$id : accessorKey ? typeof String.prototype.replaceAll === 'function' ? accessorKey.replaceAll('.', '_') : accessorKey.replace(/\./g, '_') : undefined) != null ? _ref : typeof resolvedColumnDef.header === 'string' ? resolvedColumnDef.header : undefined;
|
190
|
-
let accessorFn;
|
191
|
-
if (resolvedColumnDef.accessorFn) {
|
192
|
-
accessorFn = resolvedColumnDef.accessorFn;
|
193
|
-
} else if (accessorKey) {
|
194
|
-
// Support deep accessor keys
|
195
|
-
if (accessorKey.includes('.')) {
|
196
|
-
accessorFn = originalRow => {
|
197
|
-
let result = originalRow;
|
198
|
-
for (const key of accessorKey.split('.')) {
|
199
|
-
var _result;
|
200
|
-
result = (_result = result) == null ? void 0 : _result[key];
|
201
|
-
if (process.env.NODE_ENV !== 'production' && result === undefined) {
|
202
|
-
console.warn(`"${key}" in deeply nested key "${accessorKey}" returned undefined.`);
|
203
|
-
}
|
204
|
-
}
|
205
|
-
return result;
|
206
|
-
};
|
207
|
-
} else {
|
208
|
-
accessorFn = originalRow => originalRow[resolvedColumnDef.accessorKey];
|
209
|
-
}
|
210
|
-
}
|
211
|
-
if (!id) {
|
212
|
-
if (process.env.NODE_ENV !== 'production') {
|
213
|
-
throw new Error(resolvedColumnDef.accessorFn ? `Columns require an id when using an accessorFn` : `Columns require an id when using a non-string header`);
|
214
|
-
}
|
215
|
-
throw new Error();
|
216
|
-
}
|
217
|
-
let column = {
|
218
|
-
id: `${String(id)}`,
|
219
|
-
accessorFn,
|
220
|
-
parent: parent,
|
221
|
-
depth,
|
222
|
-
columnDef: resolvedColumnDef,
|
223
|
-
columns: [],
|
224
|
-
getFlatColumns: memo(() => [true], () => {
|
225
|
-
var _column$columns;
|
226
|
-
return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
|
227
|
-
}, getMemoOptions(table.options, 'debugColumns', 'column.getFlatColumns')),
|
228
|
-
getLeafColumns: memo(() => [table._getOrderColumnsFn()], orderColumns => {
|
229
|
-
var _column$columns2;
|
230
|
-
if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
|
231
|
-
let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
|
232
|
-
return orderColumns(leafColumns);
|
233
|
-
}
|
234
|
-
return [column];
|
235
|
-
}, getMemoOptions(table.options, 'debugColumns', 'column.getLeafColumns'))
|
236
|
-
};
|
237
|
-
for (const feature of table._features) {
|
238
|
-
feature.createColumn == null || feature.createColumn(column, table);
|
239
|
-
}
|
240
|
-
|
241
|
-
// Yes, we have to convert table to unknown, because we know more than the compiler here.
|
242
|
-
return column;
|
243
|
-
}
|
244
|
-
|
245
|
-
const debug = 'debugHeaders';
|
246
|
-
//
|
247
|
-
|
248
|
-
function createHeader(table, column, options) {
|
249
|
-
var _options$id;
|
250
|
-
const id = (_options$id = options.id) != null ? _options$id : column.id;
|
251
|
-
let header = {
|
252
|
-
id,
|
253
|
-
column,
|
254
|
-
index: options.index,
|
255
|
-
isPlaceholder: !!options.isPlaceholder,
|
256
|
-
placeholderId: options.placeholderId,
|
257
|
-
depth: options.depth,
|
258
|
-
subHeaders: [],
|
259
|
-
colSpan: 0,
|
260
|
-
rowSpan: 0,
|
261
|
-
headerGroup: null,
|
262
|
-
getLeafHeaders: () => {
|
263
|
-
const leafHeaders = [];
|
264
|
-
const recurseHeader = h => {
|
265
|
-
if (h.subHeaders && h.subHeaders.length) {
|
266
|
-
h.subHeaders.map(recurseHeader);
|
267
|
-
}
|
268
|
-
leafHeaders.push(h);
|
269
|
-
};
|
270
|
-
recurseHeader(header);
|
271
|
-
return leafHeaders;
|
272
|
-
},
|
273
|
-
getContext: () => ({
|
274
|
-
table,
|
275
|
-
header: header,
|
276
|
-
column
|
277
|
-
})
|
278
|
-
};
|
279
|
-
table._features.forEach(feature => {
|
280
|
-
feature.createHeader == null || feature.createHeader(header, table);
|
281
|
-
});
|
282
|
-
return header;
|
283
|
-
}
|
284
|
-
const Headers = {
|
285
|
-
createTable: table => {
|
286
|
-
// Header Groups
|
287
|
-
|
288
|
-
table.getHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
289
|
-
var _left$map$filter, _right$map$filter;
|
290
|
-
const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
|
291
|
-
const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
|
292
|
-
const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
293
|
-
const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], table);
|
294
|
-
return headerGroups;
|
295
|
-
}, getMemoOptions(table.options, debug, 'getHeaderGroups'));
|
296
|
-
table.getCenterHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
297
|
-
leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
298
|
-
return buildHeaderGroups(allColumns, leafColumns, table, 'center');
|
299
|
-
}, getMemoOptions(table.options, debug, 'getCenterHeaderGroups'));
|
300
|
-
table.getLeftHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
301
|
-
var _left$map$filter2;
|
302
|
-
const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
|
303
|
-
return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'left');
|
304
|
-
}, getMemoOptions(table.options, debug, 'getLeftHeaderGroups'));
|
305
|
-
table.getRightHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
306
|
-
var _right$map$filter2;
|
307
|
-
const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
|
308
|
-
return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'right');
|
309
|
-
}, getMemoOptions(table.options, debug, 'getRightHeaderGroups'));
|
310
|
-
|
311
|
-
// Footer Groups
|
312
|
-
|
313
|
-
table.getFooterGroups = memo(() => [table.getHeaderGroups()], headerGroups => {
|
314
|
-
return [...headerGroups].reverse();
|
315
|
-
}, getMemoOptions(table.options, debug, 'getFooterGroups'));
|
316
|
-
table.getLeftFooterGroups = memo(() => [table.getLeftHeaderGroups()], headerGroups => {
|
317
|
-
return [...headerGroups].reverse();
|
318
|
-
}, getMemoOptions(table.options, debug, 'getLeftFooterGroups'));
|
319
|
-
table.getCenterFooterGroups = memo(() => [table.getCenterHeaderGroups()], headerGroups => {
|
320
|
-
return [...headerGroups].reverse();
|
321
|
-
}, getMemoOptions(table.options, debug, 'getCenterFooterGroups'));
|
322
|
-
table.getRightFooterGroups = memo(() => [table.getRightHeaderGroups()], headerGroups => {
|
323
|
-
return [...headerGroups].reverse();
|
324
|
-
}, getMemoOptions(table.options, debug, 'getRightFooterGroups'));
|
325
|
-
|
326
|
-
// Flat Headers
|
327
|
-
|
328
|
-
table.getFlatHeaders = memo(() => [table.getHeaderGroups()], headerGroups => {
|
329
|
-
return headerGroups.map(headerGroup => {
|
330
|
-
return headerGroup.headers;
|
331
|
-
}).flat();
|
332
|
-
}, getMemoOptions(table.options, debug, 'getFlatHeaders'));
|
333
|
-
table.getLeftFlatHeaders = memo(() => [table.getLeftHeaderGroups()], left => {
|
334
|
-
return left.map(headerGroup => {
|
335
|
-
return headerGroup.headers;
|
336
|
-
}).flat();
|
337
|
-
}, getMemoOptions(table.options, debug, 'getLeftFlatHeaders'));
|
338
|
-
table.getCenterFlatHeaders = memo(() => [table.getCenterHeaderGroups()], left => {
|
339
|
-
return left.map(headerGroup => {
|
340
|
-
return headerGroup.headers;
|
341
|
-
}).flat();
|
342
|
-
}, getMemoOptions(table.options, debug, 'getCenterFlatHeaders'));
|
343
|
-
table.getRightFlatHeaders = memo(() => [table.getRightHeaderGroups()], left => {
|
344
|
-
return left.map(headerGroup => {
|
345
|
-
return headerGroup.headers;
|
346
|
-
}).flat();
|
347
|
-
}, getMemoOptions(table.options, debug, 'getRightFlatHeaders'));
|
348
|
-
|
349
|
-
// Leaf Headers
|
350
|
-
|
351
|
-
table.getCenterLeafHeaders = memo(() => [table.getCenterFlatHeaders()], flatHeaders => {
|
352
|
-
return flatHeaders.filter(header => {
|
353
|
-
var _header$subHeaders;
|
354
|
-
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
355
|
-
});
|
356
|
-
}, getMemoOptions(table.options, debug, 'getCenterLeafHeaders'));
|
357
|
-
table.getLeftLeafHeaders = memo(() => [table.getLeftFlatHeaders()], flatHeaders => {
|
358
|
-
return flatHeaders.filter(header => {
|
359
|
-
var _header$subHeaders2;
|
360
|
-
return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
|
361
|
-
});
|
362
|
-
}, getMemoOptions(table.options, debug, 'getLeftLeafHeaders'));
|
363
|
-
table.getRightLeafHeaders = memo(() => [table.getRightFlatHeaders()], flatHeaders => {
|
364
|
-
return flatHeaders.filter(header => {
|
365
|
-
var _header$subHeaders3;
|
366
|
-
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
367
|
-
});
|
368
|
-
}, getMemoOptions(table.options, debug, 'getRightLeafHeaders'));
|
369
|
-
table.getLeafHeaders = memo(() => [table.getLeftHeaderGroups(), table.getCenterHeaderGroups(), table.getRightHeaderGroups()], (left, center, right) => {
|
370
|
-
var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
|
371
|
-
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 => {
|
372
|
-
return header.getLeafHeaders();
|
373
|
-
}).flat();
|
374
|
-
}, getMemoOptions(table.options, debug, 'getLeafHeaders'));
|
375
|
-
}
|
376
|
-
};
|
377
|
-
function buildHeaderGroups(allColumns, columnsToGroup, table, headerFamily) {
|
378
|
-
var _headerGroups$0$heade, _headerGroups$;
|
379
|
-
// Find the max depth of the columns:
|
380
|
-
// build the leaf column row
|
381
|
-
// build each buffer row going up
|
382
|
-
// placeholder for non-existent level
|
383
|
-
// real column for existing level
|
384
|
-
|
385
|
-
let maxDepth = 0;
|
386
|
-
const findMaxDepth = function (columns, depth) {
|
387
|
-
if (depth === void 0) {
|
388
|
-
depth = 1;
|
389
|
-
}
|
390
|
-
maxDepth = Math.max(maxDepth, depth);
|
391
|
-
columns.filter(column => column.getIsVisible()).forEach(column => {
|
392
|
-
var _column$columns;
|
393
|
-
if ((_column$columns = column.columns) != null && _column$columns.length) {
|
394
|
-
findMaxDepth(column.columns, depth + 1);
|
395
|
-
}
|
396
|
-
}, 0);
|
397
|
-
};
|
398
|
-
findMaxDepth(allColumns);
|
399
|
-
let headerGroups = [];
|
400
|
-
const createHeaderGroup = (headersToGroup, depth) => {
|
401
|
-
// The header group we are creating
|
402
|
-
const headerGroup = {
|
403
|
-
depth,
|
404
|
-
id: [headerFamily, `${depth}`].filter(Boolean).join('_'),
|
405
|
-
headers: []
|
406
|
-
};
|
407
|
-
|
408
|
-
// The parent columns we're going to scan next
|
409
|
-
const pendingParentHeaders = [];
|
410
|
-
|
411
|
-
// Scan each column for parents
|
412
|
-
headersToGroup.forEach(headerToGroup => {
|
413
|
-
// What is the latest (last) parent column?
|
414
|
-
|
415
|
-
const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
|
416
|
-
const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
|
417
|
-
let column;
|
418
|
-
let isPlaceholder = false;
|
419
|
-
if (isLeafHeader && headerToGroup.column.parent) {
|
420
|
-
// The parent header is new
|
421
|
-
column = headerToGroup.column.parent;
|
422
|
-
} else {
|
423
|
-
// The parent header is repeated
|
424
|
-
column = headerToGroup.column;
|
425
|
-
isPlaceholder = true;
|
426
|
-
}
|
427
|
-
if (latestPendingParentHeader && (latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
|
428
|
-
// This column is repeated. Add it as a sub header to the next batch
|
429
|
-
latestPendingParentHeader.subHeaders.push(headerToGroup);
|
430
|
-
} else {
|
431
|
-
// This is a new header. Let's create it
|
432
|
-
const header = createHeader(table, column, {
|
433
|
-
id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
|
434
|
-
isPlaceholder,
|
435
|
-
placeholderId: isPlaceholder ? `${pendingParentHeaders.filter(d => d.column === column).length}` : undefined,
|
436
|
-
depth,
|
437
|
-
index: pendingParentHeaders.length
|
438
|
-
});
|
439
|
-
|
440
|
-
// Add the headerToGroup as a subHeader of the new header
|
441
|
-
header.subHeaders.push(headerToGroup);
|
442
|
-
// Add the new header to the pendingParentHeaders to get grouped
|
443
|
-
// in the next batch
|
444
|
-
pendingParentHeaders.push(header);
|
445
|
-
}
|
446
|
-
headerGroup.headers.push(headerToGroup);
|
447
|
-
headerToGroup.headerGroup = headerGroup;
|
448
|
-
});
|
449
|
-
headerGroups.push(headerGroup);
|
450
|
-
if (depth > 0) {
|
451
|
-
createHeaderGroup(pendingParentHeaders, depth - 1);
|
452
|
-
}
|
453
|
-
};
|
454
|
-
const bottomHeaders = columnsToGroup.map((column, index) => createHeader(table, column, {
|
455
|
-
depth: maxDepth,
|
456
|
-
index
|
457
|
-
}));
|
458
|
-
createHeaderGroup(bottomHeaders, maxDepth - 1);
|
459
|
-
headerGroups.reverse();
|
460
|
-
|
461
|
-
// headerGroups = headerGroups.filter(headerGroup => {
|
462
|
-
// return !headerGroup.headers.every(header => header.isPlaceholder)
|
463
|
-
// })
|
464
|
-
|
465
|
-
const recurseHeadersForSpans = headers => {
|
466
|
-
const filteredHeaders = headers.filter(header => header.column.getIsVisible());
|
467
|
-
return filteredHeaders.map(header => {
|
468
|
-
let colSpan = 0;
|
469
|
-
let rowSpan = 0;
|
470
|
-
let childRowSpans = [0];
|
471
|
-
if (header.subHeaders && header.subHeaders.length) {
|
472
|
-
childRowSpans = [];
|
473
|
-
recurseHeadersForSpans(header.subHeaders).forEach(_ref => {
|
474
|
-
let {
|
475
|
-
colSpan: childColSpan,
|
476
|
-
rowSpan: childRowSpan
|
477
|
-
} = _ref;
|
478
|
-
colSpan += childColSpan;
|
479
|
-
childRowSpans.push(childRowSpan);
|
480
|
-
});
|
481
|
-
} else {
|
482
|
-
colSpan = 1;
|
483
|
-
}
|
484
|
-
const minChildRowSpan = Math.min(...childRowSpans);
|
485
|
-
rowSpan = rowSpan + minChildRowSpan;
|
486
|
-
header.colSpan = colSpan;
|
487
|
-
header.rowSpan = rowSpan;
|
488
|
-
return {
|
489
|
-
colSpan,
|
490
|
-
rowSpan
|
491
|
-
};
|
492
|
-
});
|
493
|
-
};
|
494
|
-
recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
|
495
|
-
return headerGroups;
|
496
|
-
}
|
497
|
-
|
498
|
-
const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
499
|
-
let row = {
|
500
|
-
id,
|
501
|
-
index: rowIndex,
|
502
|
-
original,
|
503
|
-
depth,
|
504
|
-
parentId,
|
505
|
-
_valuesCache: {},
|
506
|
-
_uniqueValuesCache: {},
|
507
|
-
getValue: columnId => {
|
508
|
-
if (row._valuesCache.hasOwnProperty(columnId)) {
|
509
|
-
return row._valuesCache[columnId];
|
510
|
-
}
|
511
|
-
const column = table.getColumn(columnId);
|
512
|
-
if (!(column != null && column.accessorFn)) {
|
513
|
-
return undefined;
|
514
|
-
}
|
515
|
-
row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
516
|
-
return row._valuesCache[columnId];
|
517
|
-
},
|
518
|
-
getUniqueValues: columnId => {
|
519
|
-
if (row._uniqueValuesCache.hasOwnProperty(columnId)) {
|
520
|
-
return row._uniqueValuesCache[columnId];
|
521
|
-
}
|
522
|
-
const column = table.getColumn(columnId);
|
523
|
-
if (!(column != null && column.accessorFn)) {
|
524
|
-
return undefined;
|
525
|
-
}
|
526
|
-
if (!column.columnDef.getUniqueValues) {
|
527
|
-
row._uniqueValuesCache[columnId] = [row.getValue(columnId)];
|
528
|
-
return row._uniqueValuesCache[columnId];
|
529
|
-
}
|
530
|
-
row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(row.original, rowIndex);
|
531
|
-
return row._uniqueValuesCache[columnId];
|
532
|
-
},
|
533
|
-
renderValue: columnId => {
|
534
|
-
var _row$getValue;
|
535
|
-
return (_row$getValue = row.getValue(columnId)) != null ? _row$getValue : table.options.renderFallbackValue;
|
536
|
-
},
|
537
|
-
subRows: subRows != null ? subRows : [],
|
538
|
-
getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
|
539
|
-
getParentRow: () => row.parentId ? table.getRow(row.parentId, true) : undefined,
|
540
|
-
getParentRows: () => {
|
541
|
-
let parentRows = [];
|
542
|
-
let currentRow = row;
|
543
|
-
while (true) {
|
544
|
-
const parentRow = currentRow.getParentRow();
|
545
|
-
if (!parentRow) break;
|
546
|
-
parentRows.push(parentRow);
|
547
|
-
currentRow = parentRow;
|
548
|
-
}
|
549
|
-
return parentRows.reverse();
|
550
|
-
},
|
551
|
-
getAllCells: memo(() => [table.getAllLeafColumns()], leafColumns => {
|
552
|
-
return leafColumns.map(column => {
|
553
|
-
return createCell(table, row, column, column.id);
|
554
|
-
});
|
555
|
-
}, getMemoOptions(table.options, 'debugRows', 'getAllCells')),
|
556
|
-
_getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
|
557
|
-
return allCells.reduce((acc, cell) => {
|
558
|
-
acc[cell.column.id] = cell;
|
559
|
-
return acc;
|
560
|
-
}, {});
|
561
|
-
}, getMemoOptions(table.options, 'debugRows', 'getAllCellsByColumnId'))
|
562
|
-
};
|
563
|
-
for (let i = 0; i < table._features.length; i++) {
|
564
|
-
const feature = table._features[i];
|
565
|
-
feature == null || feature.createRow == null || feature.createRow(row, table);
|
566
|
-
}
|
567
|
-
return row;
|
568
|
-
};
|
569
|
-
|
570
|
-
//
|
571
|
-
|
572
|
-
const ColumnFaceting = {
|
573
|
-
createColumn: (column, table) => {
|
574
|
-
column._getFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, column.id);
|
575
|
-
column.getFacetedRowModel = () => {
|
576
|
-
if (!column._getFacetedRowModel) {
|
577
|
-
return table.getPreFilteredRowModel();
|
578
|
-
}
|
579
|
-
return column._getFacetedRowModel();
|
580
|
-
};
|
581
|
-
column._getFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, column.id);
|
582
|
-
column.getFacetedUniqueValues = () => {
|
583
|
-
if (!column._getFacetedUniqueValues) {
|
584
|
-
return new Map();
|
585
|
-
}
|
586
|
-
return column._getFacetedUniqueValues();
|
587
|
-
};
|
588
|
-
column._getFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, column.id);
|
589
|
-
column.getFacetedMinMaxValues = () => {
|
590
|
-
if (!column._getFacetedMinMaxValues) {
|
591
|
-
return undefined;
|
592
|
-
}
|
593
|
-
return column._getFacetedMinMaxValues();
|
594
|
-
};
|
595
|
-
}
|
596
|
-
};
|
597
|
-
|
598
|
-
const includesString = (row, columnId, filterValue) => {
|
599
|
-
var _filterValue$toString, _row$getValue;
|
600
|
-
const search = filterValue == null || (_filterValue$toString = filterValue.toString()) == null ? void 0 : _filterValue$toString.toLowerCase();
|
601
|
-
return Boolean((_row$getValue = row.getValue(columnId)) == null || (_row$getValue = _row$getValue.toString()) == null || (_row$getValue = _row$getValue.toLowerCase()) == null ? void 0 : _row$getValue.includes(search));
|
602
|
-
};
|
603
|
-
includesString.autoRemove = val => testFalsey(val);
|
604
|
-
const includesStringSensitive = (row, columnId, filterValue) => {
|
605
|
-
var _row$getValue2;
|
606
|
-
return Boolean((_row$getValue2 = row.getValue(columnId)) == null || (_row$getValue2 = _row$getValue2.toString()) == null ? void 0 : _row$getValue2.includes(filterValue));
|
607
|
-
};
|
608
|
-
includesStringSensitive.autoRemove = val => testFalsey(val);
|
609
|
-
const equalsString = (row, columnId, filterValue) => {
|
610
|
-
var _row$getValue3;
|
611
|
-
return ((_row$getValue3 = row.getValue(columnId)) == null || (_row$getValue3 = _row$getValue3.toString()) == null ? void 0 : _row$getValue3.toLowerCase()) === (filterValue == null ? void 0 : filterValue.toLowerCase());
|
612
|
-
};
|
613
|
-
equalsString.autoRemove = val => testFalsey(val);
|
614
|
-
const arrIncludes = (row, columnId, filterValue) => {
|
615
|
-
var _row$getValue4;
|
616
|
-
return (_row$getValue4 = row.getValue(columnId)) == null ? void 0 : _row$getValue4.includes(filterValue);
|
617
|
-
};
|
618
|
-
arrIncludes.autoRemove = val => testFalsey(val) || !(val != null && val.length);
|
619
|
-
const arrIncludesAll = (row, columnId, filterValue) => {
|
620
|
-
return !filterValue.some(val => {
|
621
|
-
var _row$getValue5;
|
622
|
-
return !((_row$getValue5 = row.getValue(columnId)) != null && _row$getValue5.includes(val));
|
623
|
-
});
|
624
|
-
};
|
625
|
-
arrIncludesAll.autoRemove = val => testFalsey(val) || !(val != null && val.length);
|
626
|
-
const arrIncludesSome = (row, columnId, filterValue) => {
|
627
|
-
return filterValue.some(val => {
|
628
|
-
var _row$getValue6;
|
629
|
-
return (_row$getValue6 = row.getValue(columnId)) == null ? void 0 : _row$getValue6.includes(val);
|
630
|
-
});
|
631
|
-
};
|
632
|
-
arrIncludesSome.autoRemove = val => testFalsey(val) || !(val != null && val.length);
|
633
|
-
const equals = (row, columnId, filterValue) => {
|
634
|
-
return row.getValue(columnId) === filterValue;
|
635
|
-
};
|
636
|
-
equals.autoRemove = val => testFalsey(val);
|
637
|
-
const weakEquals = (row, columnId, filterValue) => {
|
638
|
-
return row.getValue(columnId) == filterValue;
|
639
|
-
};
|
640
|
-
weakEquals.autoRemove = val => testFalsey(val);
|
641
|
-
const inNumberRange = (row, columnId, filterValue) => {
|
642
|
-
let [min, max] = filterValue;
|
643
|
-
const rowValue = row.getValue(columnId);
|
644
|
-
return rowValue >= min && rowValue <= max;
|
645
|
-
};
|
646
|
-
inNumberRange.resolveFilterValue = val => {
|
647
|
-
let [unsafeMin, unsafeMax] = val;
|
648
|
-
let parsedMin = typeof unsafeMin !== 'number' ? parseFloat(unsafeMin) : unsafeMin;
|
649
|
-
let parsedMax = typeof unsafeMax !== 'number' ? parseFloat(unsafeMax) : unsafeMax;
|
650
|
-
let min = unsafeMin === null || Number.isNaN(parsedMin) ? -Infinity : parsedMin;
|
651
|
-
let max = unsafeMax === null || Number.isNaN(parsedMax) ? Infinity : parsedMax;
|
652
|
-
if (min > max) {
|
653
|
-
const temp = min;
|
654
|
-
min = max;
|
655
|
-
max = temp;
|
656
|
-
}
|
657
|
-
return [min, max];
|
658
|
-
};
|
659
|
-
inNumberRange.autoRemove = val => testFalsey(val) || testFalsey(val[0]) && testFalsey(val[1]);
|
660
|
-
|
661
|
-
// Export
|
662
|
-
|
663
|
-
const filterFns = {
|
664
|
-
includesString,
|
665
|
-
includesStringSensitive,
|
666
|
-
equalsString,
|
667
|
-
arrIncludes,
|
668
|
-
arrIncludesAll,
|
669
|
-
arrIncludesSome,
|
670
|
-
equals,
|
671
|
-
weakEquals,
|
672
|
-
inNumberRange
|
673
|
-
};
|
674
|
-
// Utils
|
675
|
-
|
676
|
-
function testFalsey(val) {
|
677
|
-
return val === undefined || val === null || val === '';
|
678
|
-
}
|
679
|
-
|
680
|
-
//
|
681
|
-
|
682
|
-
const ColumnFiltering = {
|
683
|
-
getDefaultColumnDef: () => {
|
684
|
-
return {
|
685
|
-
filterFn: 'auto'
|
686
|
-
};
|
687
|
-
},
|
688
|
-
getInitialState: state => {
|
689
|
-
return {
|
690
|
-
columnFilters: [],
|
691
|
-
...state
|
692
|
-
};
|
693
|
-
},
|
694
|
-
getDefaultOptions: table => {
|
695
|
-
return {
|
696
|
-
onColumnFiltersChange: makeStateUpdater('columnFilters', table),
|
697
|
-
filterFromLeafRows: false,
|
698
|
-
maxLeafRowFilterDepth: 100
|
699
|
-
};
|
700
|
-
},
|
701
|
-
createColumn: (column, table) => {
|
702
|
-
column.getAutoFilterFn = () => {
|
703
|
-
const firstRow = table.getCoreRowModel().flatRows[0];
|
704
|
-
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
705
|
-
if (typeof value === 'string') {
|
706
|
-
return filterFns.includesString;
|
707
|
-
}
|
708
|
-
if (typeof value === 'number') {
|
709
|
-
return filterFns.inNumberRange;
|
710
|
-
}
|
711
|
-
if (typeof value === 'boolean') {
|
712
|
-
return filterFns.equals;
|
713
|
-
}
|
714
|
-
if (value !== null && typeof value === 'object') {
|
715
|
-
return filterFns.equals;
|
716
|
-
}
|
717
|
-
if (Array.isArray(value)) {
|
718
|
-
return filterFns.arrIncludes;
|
719
|
-
}
|
720
|
-
return filterFns.weakEquals;
|
721
|
-
};
|
722
|
-
column.getFilterFn = () => {
|
723
|
-
var _table$options$filter, _table$options$filter2;
|
724
|
-
return isFunction(column.columnDef.filterFn) ? column.columnDef.filterFn : column.columnDef.filterFn === 'auto' ? column.getAutoFilterFn() : // @ts-ignore
|
725
|
-
(_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[column.columnDef.filterFn]) != null ? _table$options$filter : filterFns[column.columnDef.filterFn];
|
726
|
-
};
|
727
|
-
column.getCanFilter = () => {
|
728
|
-
var _column$columnDef$ena, _table$options$enable, _table$options$enable2;
|
729
|
-
return ((_column$columnDef$ena = column.columnDef.enableColumnFilter) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnFilters) != null ? _table$options$enable : true) && ((_table$options$enable2 = table.options.enableFilters) != null ? _table$options$enable2 : true) && !!column.accessorFn;
|
730
|
-
};
|
731
|
-
column.getIsFiltered = () => column.getFilterIndex() > -1;
|
732
|
-
column.getFilterValue = () => {
|
733
|
-
var _table$getState$colum;
|
734
|
-
return (_table$getState$colum = table.getState().columnFilters) == null || (_table$getState$colum = _table$getState$colum.find(d => d.id === column.id)) == null ? void 0 : _table$getState$colum.value;
|
735
|
-
};
|
736
|
-
column.getFilterIndex = () => {
|
737
|
-
var _table$getState$colum2, _table$getState$colum3;
|
738
|
-
return (_table$getState$colum2 = (_table$getState$colum3 = table.getState().columnFilters) == null ? void 0 : _table$getState$colum3.findIndex(d => d.id === column.id)) != null ? _table$getState$colum2 : -1;
|
739
|
-
};
|
740
|
-
column.setFilterValue = value => {
|
741
|
-
table.setColumnFilters(old => {
|
742
|
-
const filterFn = column.getFilterFn();
|
743
|
-
const previousFilter = old == null ? void 0 : old.find(d => d.id === column.id);
|
744
|
-
const newFilter = functionalUpdate(value, previousFilter ? previousFilter.value : undefined);
|
745
|
-
|
746
|
-
//
|
747
|
-
if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {
|
748
|
-
var _old$filter;
|
749
|
-
return (_old$filter = old == null ? void 0 : old.filter(d => d.id !== column.id)) != null ? _old$filter : [];
|
750
|
-
}
|
751
|
-
const newFilterObj = {
|
752
|
-
id: column.id,
|
753
|
-
value: newFilter
|
754
|
-
};
|
755
|
-
if (previousFilter) {
|
756
|
-
var _old$map;
|
757
|
-
return (_old$map = old == null ? void 0 : old.map(d => {
|
758
|
-
if (d.id === column.id) {
|
759
|
-
return newFilterObj;
|
760
|
-
}
|
761
|
-
return d;
|
762
|
-
})) != null ? _old$map : [];
|
763
|
-
}
|
764
|
-
if (old != null && old.length) {
|
765
|
-
return [...old, newFilterObj];
|
766
|
-
}
|
767
|
-
return [newFilterObj];
|
768
|
-
});
|
769
|
-
};
|
770
|
-
},
|
771
|
-
createRow: (row, _table) => {
|
772
|
-
row.columnFilters = {};
|
773
|
-
row.columnFiltersMeta = {};
|
774
|
-
},
|
775
|
-
createTable: table => {
|
776
|
-
table.setColumnFilters = updater => {
|
777
|
-
const leafColumns = table.getAllLeafColumns();
|
778
|
-
const updateFn = old => {
|
779
|
-
var _functionalUpdate;
|
780
|
-
return (_functionalUpdate = functionalUpdate(updater, old)) == null ? void 0 : _functionalUpdate.filter(filter => {
|
781
|
-
const column = leafColumns.find(d => d.id === filter.id);
|
782
|
-
if (column) {
|
783
|
-
const filterFn = column.getFilterFn();
|
784
|
-
if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {
|
785
|
-
return false;
|
786
|
-
}
|
787
|
-
}
|
788
|
-
return true;
|
789
|
-
});
|
790
|
-
};
|
791
|
-
table.options.onColumnFiltersChange == null || table.options.onColumnFiltersChange(updateFn);
|
792
|
-
};
|
793
|
-
table.resetColumnFilters = defaultState => {
|
794
|
-
var _table$initialState$c, _table$initialState;
|
795
|
-
table.setColumnFilters(defaultState ? [] : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnFilters) != null ? _table$initialState$c : []);
|
796
|
-
};
|
797
|
-
table.getPreFilteredRowModel = () => table.getCoreRowModel();
|
798
|
-
table.getFilteredRowModel = () => {
|
799
|
-
if (!table._getFilteredRowModel && table.options.getFilteredRowModel) {
|
800
|
-
table._getFilteredRowModel = table.options.getFilteredRowModel(table);
|
801
|
-
}
|
802
|
-
if (table.options.manualFiltering || !table._getFilteredRowModel) {
|
803
|
-
return table.getPreFilteredRowModel();
|
804
|
-
}
|
805
|
-
return table._getFilteredRowModel();
|
806
|
-
};
|
807
|
-
}
|
808
|
-
};
|
809
|
-
function shouldAutoRemoveFilter(filterFn, value, column) {
|
810
|
-
return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
|
811
|
-
}
|
812
|
-
|
813
|
-
const sum = (columnId, _leafRows, childRows) => {
|
814
|
-
// It's faster to just add the aggregations together instead of
|
815
|
-
// process leaf nodes individually
|
816
|
-
return childRows.reduce((sum, next) => {
|
817
|
-
const nextValue = next.getValue(columnId);
|
818
|
-
return sum + (typeof nextValue === 'number' ? nextValue : 0);
|
819
|
-
}, 0);
|
820
|
-
};
|
821
|
-
const min = (columnId, _leafRows, childRows) => {
|
822
|
-
let min;
|
823
|
-
childRows.forEach(row => {
|
824
|
-
const value = row.getValue(columnId);
|
825
|
-
if (value != null && (min > value || min === undefined && value >= value)) {
|
826
|
-
min = value;
|
827
|
-
}
|
828
|
-
});
|
829
|
-
return min;
|
830
|
-
};
|
831
|
-
const max = (columnId, _leafRows, childRows) => {
|
832
|
-
let max;
|
833
|
-
childRows.forEach(row => {
|
834
|
-
const value = row.getValue(columnId);
|
835
|
-
if (value != null && (max < value || max === undefined && value >= value)) {
|
836
|
-
max = value;
|
837
|
-
}
|
838
|
-
});
|
839
|
-
return max;
|
840
|
-
};
|
841
|
-
const extent = (columnId, _leafRows, childRows) => {
|
842
|
-
let min;
|
843
|
-
let max;
|
844
|
-
childRows.forEach(row => {
|
845
|
-
const value = row.getValue(columnId);
|
846
|
-
if (value != null) {
|
847
|
-
if (min === undefined) {
|
848
|
-
if (value >= value) min = max = value;
|
849
|
-
} else {
|
850
|
-
if (min > value) min = value;
|
851
|
-
if (max < value) max = value;
|
852
|
-
}
|
853
|
-
}
|
854
|
-
});
|
855
|
-
return [min, max];
|
856
|
-
};
|
857
|
-
const mean = (columnId, leafRows) => {
|
858
|
-
let count = 0;
|
859
|
-
let sum = 0;
|
860
|
-
leafRows.forEach(row => {
|
861
|
-
let value = row.getValue(columnId);
|
862
|
-
if (value != null && (value = +value) >= value) {
|
863
|
-
++count, sum += value;
|
864
|
-
}
|
865
|
-
});
|
866
|
-
if (count) return sum / count;
|
867
|
-
return;
|
868
|
-
};
|
869
|
-
const median = (columnId, leafRows) => {
|
870
|
-
if (!leafRows.length) {
|
871
|
-
return;
|
872
|
-
}
|
873
|
-
const values = leafRows.map(row => row.getValue(columnId));
|
874
|
-
if (!isNumberArray(values)) {
|
875
|
-
return;
|
876
|
-
}
|
877
|
-
if (values.length === 1) {
|
878
|
-
return values[0];
|
879
|
-
}
|
880
|
-
const mid = Math.floor(values.length / 2);
|
881
|
-
const nums = values.sort((a, b) => a - b);
|
882
|
-
return values.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
|
883
|
-
};
|
884
|
-
const unique = (columnId, leafRows) => {
|
885
|
-
return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
|
886
|
-
};
|
887
|
-
const uniqueCount = (columnId, leafRows) => {
|
888
|
-
return new Set(leafRows.map(d => d.getValue(columnId))).size;
|
889
|
-
};
|
890
|
-
const count = (_columnId, leafRows) => {
|
891
|
-
return leafRows.length;
|
892
|
-
};
|
893
|
-
const aggregationFns = {
|
894
|
-
sum,
|
895
|
-
min,
|
896
|
-
max,
|
897
|
-
extent,
|
898
|
-
mean,
|
899
|
-
median,
|
900
|
-
unique,
|
901
|
-
uniqueCount,
|
902
|
-
count
|
903
|
-
};
|
904
|
-
|
905
|
-
//
|
906
|
-
|
907
|
-
const ColumnGrouping = {
|
908
|
-
getDefaultColumnDef: () => {
|
909
|
-
return {
|
910
|
-
aggregatedCell: props => {
|
911
|
-
var _toString, _props$getValue;
|
912
|
-
return (_toString = (_props$getValue = props.getValue()) == null || _props$getValue.toString == null ? void 0 : _props$getValue.toString()) != null ? _toString : null;
|
913
|
-
},
|
914
|
-
aggregationFn: 'auto'
|
915
|
-
};
|
916
|
-
},
|
917
|
-
getInitialState: state => {
|
918
|
-
return {
|
919
|
-
grouping: [],
|
920
|
-
...state
|
921
|
-
};
|
922
|
-
},
|
923
|
-
getDefaultOptions: table => {
|
924
|
-
return {
|
925
|
-
onGroupingChange: makeStateUpdater('grouping', table),
|
926
|
-
groupedColumnMode: 'reorder'
|
927
|
-
};
|
928
|
-
},
|
929
|
-
createColumn: (column, table) => {
|
930
|
-
column.toggleGrouping = () => {
|
931
|
-
table.setGrouping(old => {
|
932
|
-
// Find any existing grouping for this column
|
933
|
-
if (old != null && old.includes(column.id)) {
|
934
|
-
return old.filter(d => d !== column.id);
|
935
|
-
}
|
936
|
-
return [...(old != null ? old : []), column.id];
|
937
|
-
});
|
938
|
-
};
|
939
|
-
column.getCanGroup = () => {
|
940
|
-
var _column$columnDef$ena, _table$options$enable;
|
941
|
-
return ((_column$columnDef$ena = column.columnDef.enableGrouping) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableGrouping) != null ? _table$options$enable : true) && (!!column.accessorFn || !!column.columnDef.getGroupingValue);
|
942
|
-
};
|
943
|
-
column.getIsGrouped = () => {
|
944
|
-
var _table$getState$group;
|
945
|
-
return (_table$getState$group = table.getState().grouping) == null ? void 0 : _table$getState$group.includes(column.id);
|
946
|
-
};
|
947
|
-
column.getGroupedIndex = () => {
|
948
|
-
var _table$getState$group2;
|
949
|
-
return (_table$getState$group2 = table.getState().grouping) == null ? void 0 : _table$getState$group2.indexOf(column.id);
|
950
|
-
};
|
951
|
-
column.getToggleGroupingHandler = () => {
|
952
|
-
const canGroup = column.getCanGroup();
|
953
|
-
return () => {
|
954
|
-
if (!canGroup) return;
|
955
|
-
column.toggleGrouping();
|
956
|
-
};
|
957
|
-
};
|
958
|
-
column.getAutoAggregationFn = () => {
|
959
|
-
const firstRow = table.getCoreRowModel().flatRows[0];
|
960
|
-
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
961
|
-
if (typeof value === 'number') {
|
962
|
-
return aggregationFns.sum;
|
963
|
-
}
|
964
|
-
if (Object.prototype.toString.call(value) === '[object Date]') {
|
965
|
-
return aggregationFns.extent;
|
966
|
-
}
|
967
|
-
};
|
968
|
-
column.getAggregationFn = () => {
|
969
|
-
var _table$options$aggreg, _table$options$aggreg2;
|
970
|
-
if (!column) {
|
971
|
-
throw new Error();
|
972
|
-
}
|
973
|
-
return isFunction(column.columnDef.aggregationFn) ? column.columnDef.aggregationFn : column.columnDef.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_table$options$aggreg = (_table$options$aggreg2 = table.options.aggregationFns) == null ? void 0 : _table$options$aggreg2[column.columnDef.aggregationFn]) != null ? _table$options$aggreg : aggregationFns[column.columnDef.aggregationFn];
|
974
|
-
};
|
975
|
-
},
|
976
|
-
createTable: table => {
|
977
|
-
table.setGrouping = updater => table.options.onGroupingChange == null ? void 0 : table.options.onGroupingChange(updater);
|
978
|
-
table.resetGrouping = defaultState => {
|
979
|
-
var _table$initialState$g, _table$initialState;
|
980
|
-
table.setGrouping(defaultState ? [] : (_table$initialState$g = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.grouping) != null ? _table$initialState$g : []);
|
981
|
-
};
|
982
|
-
table.getPreGroupedRowModel = () => table.getFilteredRowModel();
|
983
|
-
table.getGroupedRowModel = () => {
|
984
|
-
if (!table._getGroupedRowModel && table.options.getGroupedRowModel) {
|
985
|
-
table._getGroupedRowModel = table.options.getGroupedRowModel(table);
|
986
|
-
}
|
987
|
-
if (table.options.manualGrouping || !table._getGroupedRowModel) {
|
988
|
-
return table.getPreGroupedRowModel();
|
989
|
-
}
|
990
|
-
return table._getGroupedRowModel();
|
991
|
-
};
|
992
|
-
},
|
993
|
-
createRow: (row, table) => {
|
994
|
-
row.getIsGrouped = () => !!row.groupingColumnId;
|
995
|
-
row.getGroupingValue = columnId => {
|
996
|
-
if (row._groupingValuesCache.hasOwnProperty(columnId)) {
|
997
|
-
return row._groupingValuesCache[columnId];
|
998
|
-
}
|
999
|
-
const column = table.getColumn(columnId);
|
1000
|
-
if (!(column != null && column.columnDef.getGroupingValue)) {
|
1001
|
-
return row.getValue(columnId);
|
1002
|
-
}
|
1003
|
-
row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(row.original);
|
1004
|
-
return row._groupingValuesCache[columnId];
|
1005
|
-
};
|
1006
|
-
row._groupingValuesCache = {};
|
1007
|
-
},
|
1008
|
-
createCell: (cell, column, row, table) => {
|
1009
|
-
cell.getIsGrouped = () => column.getIsGrouped() && column.id === row.groupingColumnId;
|
1010
|
-
cell.getIsPlaceholder = () => !cell.getIsGrouped() && column.getIsGrouped();
|
1011
|
-
cell.getIsAggregated = () => {
|
1012
|
-
var _row$subRows;
|
1013
|
-
return !cell.getIsGrouped() && !cell.getIsPlaceholder() && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
|
1014
|
-
};
|
1015
|
-
}
|
1016
|
-
};
|
1017
|
-
function orderColumns(leafColumns, grouping, groupedColumnMode) {
|
1018
|
-
if (!(grouping != null && grouping.length) || !groupedColumnMode) {
|
1019
|
-
return leafColumns;
|
1020
|
-
}
|
1021
|
-
const nonGroupingColumns = leafColumns.filter(col => !grouping.includes(col.id));
|
1022
|
-
if (groupedColumnMode === 'remove') {
|
1023
|
-
return nonGroupingColumns;
|
1024
|
-
}
|
1025
|
-
const groupingColumns = grouping.map(g => leafColumns.find(col => col.id === g)).filter(Boolean);
|
1026
|
-
return [...groupingColumns, ...nonGroupingColumns];
|
1027
|
-
}
|
1028
|
-
|
1029
|
-
//
|
1030
|
-
|
1031
|
-
const ColumnOrdering = {
|
1032
|
-
getInitialState: state => {
|
1033
|
-
return {
|
1034
|
-
columnOrder: [],
|
1035
|
-
...state
|
1036
|
-
};
|
1037
|
-
},
|
1038
|
-
getDefaultOptions: table => {
|
1039
|
-
return {
|
1040
|
-
onColumnOrderChange: makeStateUpdater('columnOrder', table)
|
1041
|
-
};
|
1042
|
-
},
|
1043
|
-
createColumn: (column, table) => {
|
1044
|
-
column.getIndex = memo(position => [_getVisibleLeafColumns(table, position)], columns => columns.findIndex(d => d.id === column.id), getMemoOptions(table.options, 'debugColumns', 'getIndex'));
|
1045
|
-
column.getIsFirstColumn = position => {
|
1046
|
-
var _columns$;
|
1047
|
-
const columns = _getVisibleLeafColumns(table, position);
|
1048
|
-
return ((_columns$ = columns[0]) == null ? void 0 : _columns$.id) === column.id;
|
1049
|
-
};
|
1050
|
-
column.getIsLastColumn = position => {
|
1051
|
-
var _columns;
|
1052
|
-
const columns = _getVisibleLeafColumns(table, position);
|
1053
|
-
return ((_columns = columns[columns.length - 1]) == null ? void 0 : _columns.id) === column.id;
|
1054
|
-
};
|
1055
|
-
},
|
1056
|
-
createTable: table => {
|
1057
|
-
table.setColumnOrder = updater => table.options.onColumnOrderChange == null ? void 0 : table.options.onColumnOrderChange(updater);
|
1058
|
-
table.resetColumnOrder = defaultState => {
|
1059
|
-
var _table$initialState$c;
|
1060
|
-
table.setColumnOrder(defaultState ? [] : (_table$initialState$c = table.initialState.columnOrder) != null ? _table$initialState$c : []);
|
1061
|
-
};
|
1062
|
-
table._getOrderColumnsFn = memo(() => [table.getState().columnOrder, table.getState().grouping, table.options.groupedColumnMode], (columnOrder, grouping, groupedColumnMode) => columns => {
|
1063
|
-
// Sort grouped columns to the start of the column list
|
1064
|
-
// before the headers are built
|
1065
|
-
let orderedColumns = [];
|
1066
|
-
|
1067
|
-
// If there is no order, return the normal columns
|
1068
|
-
if (!(columnOrder != null && columnOrder.length)) {
|
1069
|
-
orderedColumns = columns;
|
1070
|
-
} else {
|
1071
|
-
const columnOrderCopy = [...columnOrder];
|
1072
|
-
|
1073
|
-
// If there is an order, make a copy of the columns
|
1074
|
-
const columnsCopy = [...columns];
|
1075
|
-
|
1076
|
-
// And make a new ordered array of the columns
|
1077
|
-
|
1078
|
-
// Loop over the columns and place them in order into the new array
|
1079
|
-
while (columnsCopy.length && columnOrderCopy.length) {
|
1080
|
-
const targetColumnId = columnOrderCopy.shift();
|
1081
|
-
const foundIndex = columnsCopy.findIndex(d => d.id === targetColumnId);
|
1082
|
-
if (foundIndex > -1) {
|
1083
|
-
orderedColumns.push(columnsCopy.splice(foundIndex, 1)[0]);
|
1084
|
-
}
|
1085
|
-
}
|
1086
|
-
|
1087
|
-
// If there are any columns left, add them to the end
|
1088
|
-
orderedColumns = [...orderedColumns, ...columnsCopy];
|
1089
|
-
}
|
1090
|
-
return orderColumns(orderedColumns, grouping, groupedColumnMode);
|
1091
|
-
}, getMemoOptions(table.options, 'debugTable', '_getOrderColumnsFn'));
|
1092
|
-
}
|
1093
|
-
};
|
1094
|
-
|
1095
|
-
//
|
1096
|
-
|
1097
|
-
const getDefaultColumnPinningState = () => ({
|
1098
|
-
left: [],
|
1099
|
-
right: []
|
1100
|
-
});
|
1101
|
-
const ColumnPinning = {
|
1102
|
-
getInitialState: state => {
|
1103
|
-
return {
|
1104
|
-
columnPinning: getDefaultColumnPinningState(),
|
1105
|
-
...state
|
1106
|
-
};
|
1107
|
-
},
|
1108
|
-
getDefaultOptions: table => {
|
1109
|
-
return {
|
1110
|
-
onColumnPinningChange: makeStateUpdater('columnPinning', table)
|
1111
|
-
};
|
1112
|
-
},
|
1113
|
-
createColumn: (column, table) => {
|
1114
|
-
column.pin = position => {
|
1115
|
-
const columnIds = column.getLeafColumns().map(d => d.id).filter(Boolean);
|
1116
|
-
table.setColumnPinning(old => {
|
1117
|
-
var _old$left3, _old$right3;
|
1118
|
-
if (position === 'right') {
|
1119
|
-
var _old$left, _old$right;
|
1120
|
-
return {
|
1121
|
-
left: ((_old$left = old == null ? void 0 : old.left) != null ? _old$left : []).filter(d => !(columnIds != null && columnIds.includes(d))),
|
1122
|
-
right: [...((_old$right = old == null ? void 0 : old.right) != null ? _old$right : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds]
|
1123
|
-
};
|
1124
|
-
}
|
1125
|
-
if (position === 'left') {
|
1126
|
-
var _old$left2, _old$right2;
|
1127
|
-
return {
|
1128
|
-
left: [...((_old$left2 = old == null ? void 0 : old.left) != null ? _old$left2 : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds],
|
1129
|
-
right: ((_old$right2 = old == null ? void 0 : old.right) != null ? _old$right2 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
|
1130
|
-
};
|
1131
|
-
}
|
1132
|
-
return {
|
1133
|
-
left: ((_old$left3 = old == null ? void 0 : old.left) != null ? _old$left3 : []).filter(d => !(columnIds != null && columnIds.includes(d))),
|
1134
|
-
right: ((_old$right3 = old == null ? void 0 : old.right) != null ? _old$right3 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
|
1135
|
-
};
|
1136
|
-
});
|
1137
|
-
};
|
1138
|
-
column.getCanPin = () => {
|
1139
|
-
const leafColumns = column.getLeafColumns();
|
1140
|
-
return leafColumns.some(d => {
|
1141
|
-
var _d$columnDef$enablePi, _ref, _table$options$enable;
|
1142
|
-
return ((_d$columnDef$enablePi = d.columnDef.enablePinning) != null ? _d$columnDef$enablePi : true) && ((_ref = (_table$options$enable = table.options.enableColumnPinning) != null ? _table$options$enable : table.options.enablePinning) != null ? _ref : true);
|
1143
|
-
});
|
1144
|
-
};
|
1145
|
-
column.getIsPinned = () => {
|
1146
|
-
const leafColumnIds = column.getLeafColumns().map(d => d.id);
|
1147
|
-
const {
|
1148
|
-
left,
|
1149
|
-
right
|
1150
|
-
} = table.getState().columnPinning;
|
1151
|
-
const isLeft = leafColumnIds.some(d => left == null ? void 0 : left.includes(d));
|
1152
|
-
const isRight = leafColumnIds.some(d => right == null ? void 0 : right.includes(d));
|
1153
|
-
return isLeft ? 'left' : isRight ? 'right' : false;
|
1154
|
-
};
|
1155
|
-
column.getPinnedIndex = () => {
|
1156
|
-
var _table$getState$colum, _table$getState$colum2;
|
1157
|
-
const position = column.getIsPinned();
|
1158
|
-
return position ? (_table$getState$colum = (_table$getState$colum2 = table.getState().columnPinning) == null || (_table$getState$colum2 = _table$getState$colum2[position]) == null ? void 0 : _table$getState$colum2.indexOf(column.id)) != null ? _table$getState$colum : -1 : 0;
|
1159
|
-
};
|
1160
|
-
},
|
1161
|
-
createRow: (row, table) => {
|
1162
|
-
row.getCenterVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allCells, left, right) => {
|
1163
|
-
const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
|
1164
|
-
return allCells.filter(d => !leftAndRight.includes(d.column.id));
|
1165
|
-
}, getMemoOptions(table.options, 'debugRows', 'getCenterVisibleCells'));
|
1166
|
-
row.getLeftVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left], (allCells, left) => {
|
1167
|
-
const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
|
1168
|
-
...d,
|
1169
|
-
position: 'left'
|
1170
|
-
}));
|
1171
|
-
return cells;
|
1172
|
-
}, getMemoOptions(table.options, 'debugRows', 'getLeftVisibleCells'));
|
1173
|
-
row.getRightVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.right], (allCells, right) => {
|
1174
|
-
const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
|
1175
|
-
...d,
|
1176
|
-
position: 'right'
|
1177
|
-
}));
|
1178
|
-
return cells;
|
1179
|
-
}, getMemoOptions(table.options, 'debugRows', 'getRightVisibleCells'));
|
1180
|
-
},
|
1181
|
-
createTable: table => {
|
1182
|
-
table.setColumnPinning = updater => table.options.onColumnPinningChange == null ? void 0 : table.options.onColumnPinningChange(updater);
|
1183
|
-
table.resetColumnPinning = defaultState => {
|
1184
|
-
var _table$initialState$c, _table$initialState;
|
1185
|
-
return table.setColumnPinning(defaultState ? getDefaultColumnPinningState() : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnPinning) != null ? _table$initialState$c : getDefaultColumnPinningState());
|
1186
|
-
};
|
1187
|
-
table.getIsSomeColumnsPinned = position => {
|
1188
|
-
var _pinningState$positio;
|
1189
|
-
const pinningState = table.getState().columnPinning;
|
1190
|
-
if (!position) {
|
1191
|
-
var _pinningState$left, _pinningState$right;
|
1192
|
-
return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
|
1193
|
-
}
|
1194
|
-
return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
|
1195
|
-
};
|
1196
|
-
table.getLeftLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left], (allColumns, left) => {
|
1197
|
-
return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
|
1198
|
-
}, getMemoOptions(table.options, 'debugColumns', 'getLeftLeafColumns'));
|
1199
|
-
table.getRightLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.right], (allColumns, right) => {
|
1200
|
-
return (right != null ? right : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
|
1201
|
-
}, getMemoOptions(table.options, 'debugColumns', 'getRightLeafColumns'));
|
1202
|
-
table.getCenterLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, left, right) => {
|
1203
|
-
const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
|
1204
|
-
return allColumns.filter(d => !leftAndRight.includes(d.id));
|
1205
|
-
}, getMemoOptions(table.options, 'debugColumns', 'getCenterLeafColumns'));
|
1206
|
-
}
|
1207
|
-
};
|
1208
|
-
|
1209
|
-
//
|
1210
|
-
|
1211
|
-
//
|
1212
|
-
|
1213
|
-
const defaultColumnSizing = {
|
1214
|
-
size: 150,
|
1215
|
-
minSize: 20,
|
1216
|
-
maxSize: Number.MAX_SAFE_INTEGER
|
1217
|
-
};
|
1218
|
-
const getDefaultColumnSizingInfoState = () => ({
|
1219
|
-
startOffset: null,
|
1220
|
-
startSize: null,
|
1221
|
-
deltaOffset: null,
|
1222
|
-
deltaPercentage: null,
|
1223
|
-
isResizingColumn: false,
|
1224
|
-
columnSizingStart: []
|
1225
|
-
});
|
1226
|
-
const ColumnSizing = {
|
1227
|
-
getDefaultColumnDef: () => {
|
1228
|
-
return defaultColumnSizing;
|
1229
|
-
},
|
1230
|
-
getInitialState: state => {
|
1231
|
-
return {
|
1232
|
-
columnSizing: {},
|
1233
|
-
columnSizingInfo: getDefaultColumnSizingInfoState(),
|
1234
|
-
...state
|
1235
|
-
};
|
1236
|
-
},
|
1237
|
-
getDefaultOptions: table => {
|
1238
|
-
return {
|
1239
|
-
columnResizeMode: 'onEnd',
|
1240
|
-
columnResizeDirection: 'ltr',
|
1241
|
-
onColumnSizingChange: makeStateUpdater('columnSizing', table),
|
1242
|
-
onColumnSizingInfoChange: makeStateUpdater('columnSizingInfo', table)
|
1243
|
-
};
|
1244
|
-
},
|
1245
|
-
createColumn: (column, table) => {
|
1246
|
-
column.getSize = () => {
|
1247
|
-
var _column$columnDef$min, _ref, _column$columnDef$max;
|
1248
|
-
const columnSize = table.getState().columnSizing[column.id];
|
1249
|
-
return Math.min(Math.max((_column$columnDef$min = column.columnDef.minSize) != null ? _column$columnDef$min : defaultColumnSizing.minSize, (_ref = columnSize != null ? columnSize : column.columnDef.size) != null ? _ref : defaultColumnSizing.size), (_column$columnDef$max = column.columnDef.maxSize) != null ? _column$columnDef$max : defaultColumnSizing.maxSize);
|
1250
|
-
};
|
1251
|
-
column.getStart = memo(position => [position, _getVisibleLeafColumns(table, position), table.getState().columnSizing], (position, columns) => columns.slice(0, column.getIndex(position)).reduce((sum, column) => sum + column.getSize(), 0), getMemoOptions(table.options, 'debugColumns', 'getStart'));
|
1252
|
-
column.getAfter = memo(position => [position, _getVisibleLeafColumns(table, position), table.getState().columnSizing], (position, columns) => columns.slice(column.getIndex(position) + 1).reduce((sum, column) => sum + column.getSize(), 0), getMemoOptions(table.options, 'debugColumns', 'getAfter'));
|
1253
|
-
column.resetSize = () => {
|
1254
|
-
table.setColumnSizing(_ref2 => {
|
1255
|
-
let {
|
1256
|
-
[column.id]: _,
|
1257
|
-
...rest
|
1258
|
-
} = _ref2;
|
1259
|
-
return rest;
|
1260
|
-
});
|
1261
|
-
};
|
1262
|
-
column.getCanResize = () => {
|
1263
|
-
var _column$columnDef$ena, _table$options$enable;
|
1264
|
-
return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnResizing) != null ? _table$options$enable : true);
|
1265
|
-
};
|
1266
|
-
column.getIsResizing = () => {
|
1267
|
-
return table.getState().columnSizingInfo.isResizingColumn === column.id;
|
1268
|
-
};
|
1269
|
-
},
|
1270
|
-
createHeader: (header, table) => {
|
1271
|
-
header.getSize = () => {
|
1272
|
-
let sum = 0;
|
1273
|
-
const recurse = header => {
|
1274
|
-
if (header.subHeaders.length) {
|
1275
|
-
header.subHeaders.forEach(recurse);
|
1276
|
-
} else {
|
1277
|
-
var _header$column$getSiz;
|
1278
|
-
sum += (_header$column$getSiz = header.column.getSize()) != null ? _header$column$getSiz : 0;
|
1279
|
-
}
|
1280
|
-
};
|
1281
|
-
recurse(header);
|
1282
|
-
return sum;
|
1283
|
-
};
|
1284
|
-
header.getStart = () => {
|
1285
|
-
if (header.index > 0) {
|
1286
|
-
const prevSiblingHeader = header.headerGroup.headers[header.index - 1];
|
1287
|
-
return prevSiblingHeader.getStart() + prevSiblingHeader.getSize();
|
1288
|
-
}
|
1289
|
-
return 0;
|
1290
|
-
};
|
1291
|
-
header.getResizeHandler = _contextDocument => {
|
1292
|
-
const column = table.getColumn(header.column.id);
|
1293
|
-
const canResize = column == null ? void 0 : column.getCanResize();
|
1294
|
-
return e => {
|
1295
|
-
if (!column || !canResize) {
|
1296
|
-
return;
|
1297
|
-
}
|
1298
|
-
e.persist == null || e.persist();
|
1299
|
-
if (isTouchStartEvent(e)) {
|
1300
|
-
// lets not respond to multiple touches (e.g. 2 or 3 fingers)
|
1301
|
-
if (e.touches && e.touches.length > 1) {
|
1302
|
-
return;
|
1303
|
-
}
|
1304
|
-
}
|
1305
|
-
const startSize = header.getSize();
|
1306
|
-
const columnSizingStart = header ? header.getLeafHeaders().map(d => [d.column.id, d.column.getSize()]) : [[column.id, column.getSize()]];
|
1307
|
-
const clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
|
1308
|
-
const newColumnSizing = {};
|
1309
|
-
const updateOffset = (eventType, clientXPos) => {
|
1310
|
-
if (typeof clientXPos !== 'number') {
|
1311
|
-
return;
|
1312
|
-
}
|
1313
|
-
table.setColumnSizingInfo(old => {
|
1314
|
-
var _old$startOffset, _old$startSize;
|
1315
|
-
const deltaDirection = table.options.columnResizeDirection === 'rtl' ? -1 : 1;
|
1316
|
-
const deltaOffset = (clientXPos - ((_old$startOffset = old == null ? void 0 : old.startOffset) != null ? _old$startOffset : 0)) * deltaDirection;
|
1317
|
-
const deltaPercentage = Math.max(deltaOffset / ((_old$startSize = old == null ? void 0 : old.startSize) != null ? _old$startSize : 0), -0.999999);
|
1318
|
-
old.columnSizingStart.forEach(_ref3 => {
|
1319
|
-
let [columnId, headerSize] = _ref3;
|
1320
|
-
newColumnSizing[columnId] = Math.round(Math.max(headerSize + headerSize * deltaPercentage, 0) * 100) / 100;
|
1321
|
-
});
|
1322
|
-
return {
|
1323
|
-
...old,
|
1324
|
-
deltaOffset,
|
1325
|
-
deltaPercentage
|
1326
|
-
};
|
1327
|
-
});
|
1328
|
-
if (table.options.columnResizeMode === 'onChange' || eventType === 'end') {
|
1329
|
-
table.setColumnSizing(old => ({
|
1330
|
-
...old,
|
1331
|
-
...newColumnSizing
|
1332
|
-
}));
|
1333
|
-
}
|
1334
|
-
};
|
1335
|
-
const onMove = clientXPos => updateOffset('move', clientXPos);
|
1336
|
-
const onEnd = clientXPos => {
|
1337
|
-
updateOffset('end', clientXPos);
|
1338
|
-
table.setColumnSizingInfo(old => ({
|
1339
|
-
...old,
|
1340
|
-
isResizingColumn: false,
|
1341
|
-
startOffset: null,
|
1342
|
-
startSize: null,
|
1343
|
-
deltaOffset: null,
|
1344
|
-
deltaPercentage: null,
|
1345
|
-
columnSizingStart: []
|
1346
|
-
}));
|
1347
|
-
};
|
1348
|
-
const contextDocument = _contextDocument || typeof document !== 'undefined' ? document : null;
|
1349
|
-
const mouseEvents = {
|
1350
|
-
moveHandler: e => onMove(e.clientX),
|
1351
|
-
upHandler: e => {
|
1352
|
-
contextDocument == null || contextDocument.removeEventListener('mousemove', mouseEvents.moveHandler);
|
1353
|
-
contextDocument == null || contextDocument.removeEventListener('mouseup', mouseEvents.upHandler);
|
1354
|
-
onEnd(e.clientX);
|
1355
|
-
}
|
1356
|
-
};
|
1357
|
-
const touchEvents = {
|
1358
|
-
moveHandler: e => {
|
1359
|
-
if (e.cancelable) {
|
1360
|
-
e.preventDefault();
|
1361
|
-
e.stopPropagation();
|
1362
|
-
}
|
1363
|
-
onMove(e.touches[0].clientX);
|
1364
|
-
return false;
|
1365
|
-
},
|
1366
|
-
upHandler: e => {
|
1367
|
-
var _e$touches$;
|
1368
|
-
contextDocument == null || contextDocument.removeEventListener('touchmove', touchEvents.moveHandler);
|
1369
|
-
contextDocument == null || contextDocument.removeEventListener('touchend', touchEvents.upHandler);
|
1370
|
-
if (e.cancelable) {
|
1371
|
-
e.preventDefault();
|
1372
|
-
e.stopPropagation();
|
1373
|
-
}
|
1374
|
-
onEnd((_e$touches$ = e.touches[0]) == null ? void 0 : _e$touches$.clientX);
|
1375
|
-
}
|
1376
|
-
};
|
1377
|
-
const passiveIfSupported = passiveEventSupported() ? {
|
1378
|
-
passive: false
|
1379
|
-
} : false;
|
1380
|
-
if (isTouchStartEvent(e)) {
|
1381
|
-
contextDocument == null || contextDocument.addEventListener('touchmove', touchEvents.moveHandler, passiveIfSupported);
|
1382
|
-
contextDocument == null || contextDocument.addEventListener('touchend', touchEvents.upHandler, passiveIfSupported);
|
1383
|
-
} else {
|
1384
|
-
contextDocument == null || contextDocument.addEventListener('mousemove', mouseEvents.moveHandler, passiveIfSupported);
|
1385
|
-
contextDocument == null || contextDocument.addEventListener('mouseup', mouseEvents.upHandler, passiveIfSupported);
|
1386
|
-
}
|
1387
|
-
table.setColumnSizingInfo(old => ({
|
1388
|
-
...old,
|
1389
|
-
startOffset: clientX,
|
1390
|
-
startSize,
|
1391
|
-
deltaOffset: 0,
|
1392
|
-
deltaPercentage: 0,
|
1393
|
-
columnSizingStart,
|
1394
|
-
isResizingColumn: column.id
|
1395
|
-
}));
|
1396
|
-
};
|
1397
|
-
};
|
1398
|
-
},
|
1399
|
-
createTable: table => {
|
1400
|
-
table.setColumnSizing = updater => table.options.onColumnSizingChange == null ? void 0 : table.options.onColumnSizingChange(updater);
|
1401
|
-
table.setColumnSizingInfo = updater => table.options.onColumnSizingInfoChange == null ? void 0 : table.options.onColumnSizingInfoChange(updater);
|
1402
|
-
table.resetColumnSizing = defaultState => {
|
1403
|
-
var _table$initialState$c;
|
1404
|
-
table.setColumnSizing(defaultState ? {} : (_table$initialState$c = table.initialState.columnSizing) != null ? _table$initialState$c : {});
|
1405
|
-
};
|
1406
|
-
table.resetHeaderSizeInfo = defaultState => {
|
1407
|
-
var _table$initialState$c2;
|
1408
|
-
table.setColumnSizingInfo(defaultState ? getDefaultColumnSizingInfoState() : (_table$initialState$c2 = table.initialState.columnSizingInfo) != null ? _table$initialState$c2 : getDefaultColumnSizingInfoState());
|
1409
|
-
};
|
1410
|
-
table.getTotalSize = () => {
|
1411
|
-
var _table$getHeaderGroup, _table$getHeaderGroup2;
|
1412
|
-
return (_table$getHeaderGroup = (_table$getHeaderGroup2 = table.getHeaderGroups()[0]) == null ? void 0 : _table$getHeaderGroup2.headers.reduce((sum, header) => {
|
1413
|
-
return sum + header.getSize();
|
1414
|
-
}, 0)) != null ? _table$getHeaderGroup : 0;
|
1415
|
-
};
|
1416
|
-
table.getLeftTotalSize = () => {
|
1417
|
-
var _table$getLeftHeaderG, _table$getLeftHeaderG2;
|
1418
|
-
return (_table$getLeftHeaderG = (_table$getLeftHeaderG2 = table.getLeftHeaderGroups()[0]) == null ? void 0 : _table$getLeftHeaderG2.headers.reduce((sum, header) => {
|
1419
|
-
return sum + header.getSize();
|
1420
|
-
}, 0)) != null ? _table$getLeftHeaderG : 0;
|
1421
|
-
};
|
1422
|
-
table.getCenterTotalSize = () => {
|
1423
|
-
var _table$getCenterHeade, _table$getCenterHeade2;
|
1424
|
-
return (_table$getCenterHeade = (_table$getCenterHeade2 = table.getCenterHeaderGroups()[0]) == null ? void 0 : _table$getCenterHeade2.headers.reduce((sum, header) => {
|
1425
|
-
return sum + header.getSize();
|
1426
|
-
}, 0)) != null ? _table$getCenterHeade : 0;
|
1427
|
-
};
|
1428
|
-
table.getRightTotalSize = () => {
|
1429
|
-
var _table$getRightHeader, _table$getRightHeader2;
|
1430
|
-
return (_table$getRightHeader = (_table$getRightHeader2 = table.getRightHeaderGroups()[0]) == null ? void 0 : _table$getRightHeader2.headers.reduce((sum, header) => {
|
1431
|
-
return sum + header.getSize();
|
1432
|
-
}, 0)) != null ? _table$getRightHeader : 0;
|
1433
|
-
};
|
1434
|
-
}
|
1435
|
-
};
|
1436
|
-
let passiveSupported = null;
|
1437
|
-
function passiveEventSupported() {
|
1438
|
-
if (typeof passiveSupported === 'boolean') return passiveSupported;
|
1439
|
-
let supported = false;
|
1440
|
-
try {
|
1441
|
-
const options = {
|
1442
|
-
get passive() {
|
1443
|
-
supported = true;
|
1444
|
-
return false;
|
1445
|
-
}
|
1446
|
-
};
|
1447
|
-
const noop = () => {};
|
1448
|
-
window.addEventListener('test', noop, options);
|
1449
|
-
window.removeEventListener('test', noop);
|
1450
|
-
} catch (err) {
|
1451
|
-
supported = false;
|
1452
|
-
}
|
1453
|
-
passiveSupported = supported;
|
1454
|
-
return passiveSupported;
|
1455
|
-
}
|
1456
|
-
function isTouchStartEvent(e) {
|
1457
|
-
return e.type === 'touchstart';
|
1458
|
-
}
|
1459
|
-
|
1460
|
-
//
|
1461
|
-
|
1462
|
-
const ColumnVisibility = {
|
1463
|
-
getInitialState: state => {
|
1464
|
-
return {
|
1465
|
-
columnVisibility: {},
|
1466
|
-
...state
|
1467
|
-
};
|
1468
|
-
},
|
1469
|
-
getDefaultOptions: table => {
|
1470
|
-
return {
|
1471
|
-
onColumnVisibilityChange: makeStateUpdater('columnVisibility', table)
|
1472
|
-
};
|
1473
|
-
},
|
1474
|
-
createColumn: (column, table) => {
|
1475
|
-
column.toggleVisibility = value => {
|
1476
|
-
if (column.getCanHide()) {
|
1477
|
-
table.setColumnVisibility(old => ({
|
1478
|
-
...old,
|
1479
|
-
[column.id]: value != null ? value : !column.getIsVisible()
|
1480
|
-
}));
|
1481
|
-
}
|
1482
|
-
};
|
1483
|
-
column.getIsVisible = () => {
|
1484
|
-
var _ref, _table$getState$colum;
|
1485
|
-
const childColumns = column.columns;
|
1486
|
-
return (_ref = childColumns.length ? childColumns.some(c => c.getIsVisible()) : (_table$getState$colum = table.getState().columnVisibility) == null ? void 0 : _table$getState$colum[column.id]) != null ? _ref : true;
|
1487
|
-
};
|
1488
|
-
column.getCanHide = () => {
|
1489
|
-
var _column$columnDef$ena, _table$options$enable;
|
1490
|
-
return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableHiding) != null ? _table$options$enable : true);
|
1491
|
-
};
|
1492
|
-
column.getToggleVisibilityHandler = () => {
|
1493
|
-
return e => {
|
1494
|
-
column.toggleVisibility == null || column.toggleVisibility(e.target.checked);
|
1495
|
-
};
|
1496
|
-
};
|
1497
|
-
},
|
1498
|
-
createRow: (row, table) => {
|
1499
|
-
row._getAllVisibleCells = memo(() => [row.getAllCells(), table.getState().columnVisibility], cells => {
|
1500
|
-
return cells.filter(cell => cell.column.getIsVisible());
|
1501
|
-
}, getMemoOptions(table.options, 'debugRows', '_getAllVisibleCells'));
|
1502
|
-
row.getVisibleCells = memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], getMemoOptions(table.options, 'debugRows', 'getVisibleCells'));
|
1503
|
-
},
|
1504
|
-
createTable: table => {
|
1505
|
-
const makeVisibleColumnsMethod = (key, getColumns) => {
|
1506
|
-
return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
|
1507
|
-
return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
|
1508
|
-
}, getMemoOptions(table.options, 'debugColumns', key));
|
1509
|
-
};
|
1510
|
-
table.getVisibleFlatColumns = makeVisibleColumnsMethod('getVisibleFlatColumns', () => table.getAllFlatColumns());
|
1511
|
-
table.getVisibleLeafColumns = makeVisibleColumnsMethod('getVisibleLeafColumns', () => table.getAllLeafColumns());
|
1512
|
-
table.getLeftVisibleLeafColumns = makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => table.getLeftLeafColumns());
|
1513
|
-
table.getRightVisibleLeafColumns = makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => table.getRightLeafColumns());
|
1514
|
-
table.getCenterVisibleLeafColumns = makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => table.getCenterLeafColumns());
|
1515
|
-
table.setColumnVisibility = updater => table.options.onColumnVisibilityChange == null ? void 0 : table.options.onColumnVisibilityChange(updater);
|
1516
|
-
table.resetColumnVisibility = defaultState => {
|
1517
|
-
var _table$initialState$c;
|
1518
|
-
table.setColumnVisibility(defaultState ? {} : (_table$initialState$c = table.initialState.columnVisibility) != null ? _table$initialState$c : {});
|
1519
|
-
};
|
1520
|
-
table.toggleAllColumnsVisible = value => {
|
1521
|
-
var _value;
|
1522
|
-
value = (_value = value) != null ? _value : !table.getIsAllColumnsVisible();
|
1523
|
-
table.setColumnVisibility(table.getAllLeafColumns().reduce((obj, column) => ({
|
1524
|
-
...obj,
|
1525
|
-
[column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
|
1526
|
-
}), {}));
|
1527
|
-
};
|
1528
|
-
table.getIsAllColumnsVisible = () => !table.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible()));
|
1529
|
-
table.getIsSomeColumnsVisible = () => table.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible());
|
1530
|
-
table.getToggleAllColumnsVisibilityHandler = () => {
|
1531
|
-
return e => {
|
1532
|
-
var _target;
|
1533
|
-
table.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
|
1534
|
-
};
|
1535
|
-
};
|
1536
|
-
}
|
1537
|
-
};
|
1538
|
-
function _getVisibleLeafColumns(table, position) {
|
1539
|
-
return !position ? table.getVisibleLeafColumns() : position === 'center' ? table.getCenterVisibleLeafColumns() : position === 'left' ? table.getLeftVisibleLeafColumns() : table.getRightVisibleLeafColumns();
|
1540
|
-
}
|
1541
|
-
|
1542
|
-
//
|
1543
|
-
|
1544
|
-
const GlobalFaceting = {
|
1545
|
-
createTable: table => {
|
1546
|
-
table._getGlobalFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, '__global__');
|
1547
|
-
table.getGlobalFacetedRowModel = () => {
|
1548
|
-
if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {
|
1549
|
-
return table.getPreFilteredRowModel();
|
1550
|
-
}
|
1551
|
-
return table._getGlobalFacetedRowModel();
|
1552
|
-
};
|
1553
|
-
table._getGlobalFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, '__global__');
|
1554
|
-
table.getGlobalFacetedUniqueValues = () => {
|
1555
|
-
if (!table._getGlobalFacetedUniqueValues) {
|
1556
|
-
return new Map();
|
1557
|
-
}
|
1558
|
-
return table._getGlobalFacetedUniqueValues();
|
1559
|
-
};
|
1560
|
-
table._getGlobalFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, '__global__');
|
1561
|
-
table.getGlobalFacetedMinMaxValues = () => {
|
1562
|
-
if (!table._getGlobalFacetedMinMaxValues) {
|
1563
|
-
return;
|
1564
|
-
}
|
1565
|
-
return table._getGlobalFacetedMinMaxValues();
|
1566
|
-
};
|
1567
|
-
}
|
1568
|
-
};
|
1569
|
-
|
1570
|
-
//
|
1571
|
-
|
1572
|
-
const GlobalFiltering = {
|
1573
|
-
getInitialState: state => {
|
1574
|
-
return {
|
1575
|
-
globalFilter: undefined,
|
1576
|
-
...state
|
1577
|
-
};
|
1578
|
-
},
|
1579
|
-
getDefaultOptions: table => {
|
1580
|
-
return {
|
1581
|
-
onGlobalFilterChange: makeStateUpdater('globalFilter', table),
|
1582
|
-
globalFilterFn: 'auto',
|
1583
|
-
getColumnCanGlobalFilter: column => {
|
1584
|
-
var _table$getCoreRowMode;
|
1585
|
-
const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) == null || (_table$getCoreRowMode = _table$getCoreRowMode._getAllCellsByColumnId()[column.id]) == null ? void 0 : _table$getCoreRowMode.getValue();
|
1586
|
-
return typeof value === 'string' || typeof value === 'number';
|
1587
|
-
}
|
1588
|
-
};
|
1589
|
-
},
|
1590
|
-
createColumn: (column, table) => {
|
1591
|
-
column.getCanGlobalFilter = () => {
|
1592
|
-
var _column$columnDef$ena, _table$options$enable, _table$options$enable2, _table$options$getCol;
|
1593
|
-
return ((_column$columnDef$ena = column.columnDef.enableGlobalFilter) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableGlobalFilter) != null ? _table$options$enable : true) && ((_table$options$enable2 = table.options.enableFilters) != null ? _table$options$enable2 : true) && ((_table$options$getCol = table.options.getColumnCanGlobalFilter == null ? void 0 : table.options.getColumnCanGlobalFilter(column)) != null ? _table$options$getCol : true) && !!column.accessorFn;
|
1594
|
-
};
|
1595
|
-
},
|
1596
|
-
createTable: table => {
|
1597
|
-
table.getGlobalAutoFilterFn = () => {
|
1598
|
-
return filterFns.includesString;
|
1599
|
-
};
|
1600
|
-
table.getGlobalFilterFn = () => {
|
1601
|
-
var _table$options$filter, _table$options$filter2;
|
1602
|
-
const {
|
1603
|
-
globalFilterFn: globalFilterFn
|
1604
|
-
} = table.options;
|
1605
|
-
return isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === 'auto' ? table.getGlobalAutoFilterFn() : (_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[globalFilterFn]) != null ? _table$options$filter : filterFns[globalFilterFn];
|
1606
|
-
};
|
1607
|
-
table.setGlobalFilter = updater => {
|
1608
|
-
table.options.onGlobalFilterChange == null || table.options.onGlobalFilterChange(updater);
|
1609
|
-
};
|
1610
|
-
table.resetGlobalFilter = defaultState => {
|
1611
|
-
table.setGlobalFilter(defaultState ? undefined : table.initialState.globalFilter);
|
1612
|
-
};
|
1613
|
-
}
|
1614
|
-
};
|
1615
|
-
|
1616
|
-
//
|
1617
|
-
|
1618
|
-
const RowExpanding = {
|
1619
|
-
getInitialState: state => {
|
1620
|
-
return {
|
1621
|
-
expanded: {},
|
1622
|
-
...state
|
1623
|
-
};
|
1624
|
-
},
|
1625
|
-
getDefaultOptions: table => {
|
1626
|
-
return {
|
1627
|
-
onExpandedChange: makeStateUpdater('expanded', table),
|
1628
|
-
paginateExpandedRows: true
|
1629
|
-
};
|
1630
|
-
},
|
1631
|
-
createTable: table => {
|
1632
|
-
let registered = false;
|
1633
|
-
let queued = false;
|
1634
|
-
table._autoResetExpanded = () => {
|
1635
|
-
var _ref, _table$options$autoRe;
|
1636
|
-
if (!registered) {
|
1637
|
-
table._queue(() => {
|
1638
|
-
registered = true;
|
1639
|
-
});
|
1640
|
-
return;
|
1641
|
-
}
|
1642
|
-
if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetExpanded) != null ? _ref : !table.options.manualExpanding) {
|
1643
|
-
if (queued) return;
|
1644
|
-
queued = true;
|
1645
|
-
table._queue(() => {
|
1646
|
-
table.resetExpanded();
|
1647
|
-
queued = false;
|
1648
|
-
});
|
1649
|
-
}
|
1650
|
-
};
|
1651
|
-
table.setExpanded = updater => table.options.onExpandedChange == null ? void 0 : table.options.onExpandedChange(updater);
|
1652
|
-
table.toggleAllRowsExpanded = expanded => {
|
1653
|
-
if (expanded != null ? expanded : !table.getIsAllRowsExpanded()) {
|
1654
|
-
table.setExpanded(true);
|
1655
|
-
} else {
|
1656
|
-
table.setExpanded({});
|
1657
|
-
}
|
1658
|
-
};
|
1659
|
-
table.resetExpanded = defaultState => {
|
1660
|
-
var _table$initialState$e, _table$initialState;
|
1661
|
-
table.setExpanded(defaultState ? {} : (_table$initialState$e = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.expanded) != null ? _table$initialState$e : {});
|
1662
|
-
};
|
1663
|
-
table.getCanSomeRowsExpand = () => {
|
1664
|
-
return table.getPrePaginationRowModel().flatRows.some(row => row.getCanExpand());
|
1665
|
-
};
|
1666
|
-
table.getToggleAllRowsExpandedHandler = () => {
|
1667
|
-
return e => {
|
1668
|
-
e.persist == null || e.persist();
|
1669
|
-
table.toggleAllRowsExpanded();
|
1670
|
-
};
|
1671
|
-
};
|
1672
|
-
table.getIsSomeRowsExpanded = () => {
|
1673
|
-
const expanded = table.getState().expanded;
|
1674
|
-
return expanded === true || Object.values(expanded).some(Boolean);
|
1675
|
-
};
|
1676
|
-
table.getIsAllRowsExpanded = () => {
|
1677
|
-
const expanded = table.getState().expanded;
|
1678
|
-
|
1679
|
-
// If expanded is true, save some cycles and return true
|
1680
|
-
if (typeof expanded === 'boolean') {
|
1681
|
-
return expanded === true;
|
1682
|
-
}
|
1683
|
-
if (!Object.keys(expanded).length) {
|
1684
|
-
return false;
|
1685
|
-
}
|
1686
|
-
|
1687
|
-
// If any row is not expanded, return false
|
1688
|
-
if (table.getRowModel().flatRows.some(row => !row.getIsExpanded())) {
|
1689
|
-
return false;
|
1690
|
-
}
|
1691
|
-
|
1692
|
-
// They must all be expanded :shrug:
|
1693
|
-
return true;
|
1694
|
-
};
|
1695
|
-
table.getExpandedDepth = () => {
|
1696
|
-
let maxDepth = 0;
|
1697
|
-
const rowIds = table.getState().expanded === true ? Object.keys(table.getRowModel().rowsById) : Object.keys(table.getState().expanded);
|
1698
|
-
rowIds.forEach(id => {
|
1699
|
-
const splitId = id.split('.');
|
1700
|
-
maxDepth = Math.max(maxDepth, splitId.length);
|
1701
|
-
});
|
1702
|
-
return maxDepth;
|
1703
|
-
};
|
1704
|
-
table.getPreExpandedRowModel = () => table.getSortedRowModel();
|
1705
|
-
table.getExpandedRowModel = () => {
|
1706
|
-
if (!table._getExpandedRowModel && table.options.getExpandedRowModel) {
|
1707
|
-
table._getExpandedRowModel = table.options.getExpandedRowModel(table);
|
1708
|
-
}
|
1709
|
-
if (table.options.manualExpanding || !table._getExpandedRowModel) {
|
1710
|
-
return table.getPreExpandedRowModel();
|
1711
|
-
}
|
1712
|
-
return table._getExpandedRowModel();
|
1713
|
-
};
|
1714
|
-
},
|
1715
|
-
createRow: (row, table) => {
|
1716
|
-
row.toggleExpanded = expanded => {
|
1717
|
-
table.setExpanded(old => {
|
1718
|
-
var _expanded;
|
1719
|
-
const exists = old === true ? true : !!(old != null && old[row.id]);
|
1720
|
-
let oldExpanded = {};
|
1721
|
-
if (old === true) {
|
1722
|
-
Object.keys(table.getRowModel().rowsById).forEach(rowId => {
|
1723
|
-
oldExpanded[rowId] = true;
|
1724
|
-
});
|
1725
|
-
} else {
|
1726
|
-
oldExpanded = old;
|
1727
|
-
}
|
1728
|
-
expanded = (_expanded = expanded) != null ? _expanded : !exists;
|
1729
|
-
if (!exists && expanded) {
|
1730
|
-
return {
|
1731
|
-
...oldExpanded,
|
1732
|
-
[row.id]: true
|
1733
|
-
};
|
1734
|
-
}
|
1735
|
-
if (exists && !expanded) {
|
1736
|
-
const {
|
1737
|
-
[row.id]: _,
|
1738
|
-
...rest
|
1739
|
-
} = oldExpanded;
|
1740
|
-
return rest;
|
1741
|
-
}
|
1742
|
-
return old;
|
1743
|
-
});
|
1744
|
-
};
|
1745
|
-
row.getIsExpanded = () => {
|
1746
|
-
var _table$options$getIsR;
|
1747
|
-
const expanded = table.getState().expanded;
|
1748
|
-
return !!((_table$options$getIsR = table.options.getIsRowExpanded == null ? void 0 : table.options.getIsRowExpanded(row)) != null ? _table$options$getIsR : expanded === true || (expanded == null ? void 0 : expanded[row.id]));
|
1749
|
-
};
|
1750
|
-
row.getCanExpand = () => {
|
1751
|
-
var _table$options$getRow, _table$options$enable, _row$subRows;
|
1752
|
-
return (_table$options$getRow = table.options.getRowCanExpand == null ? void 0 : table.options.getRowCanExpand(row)) != null ? _table$options$getRow : ((_table$options$enable = table.options.enableExpanding) != null ? _table$options$enable : true) && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
|
1753
|
-
};
|
1754
|
-
row.getIsAllParentsExpanded = () => {
|
1755
|
-
let isFullyExpanded = true;
|
1756
|
-
let currentRow = row;
|
1757
|
-
while (isFullyExpanded && currentRow.parentId) {
|
1758
|
-
currentRow = table.getRow(currentRow.parentId, true);
|
1759
|
-
isFullyExpanded = currentRow.getIsExpanded();
|
1760
|
-
}
|
1761
|
-
return isFullyExpanded;
|
1762
|
-
};
|
1763
|
-
row.getToggleExpandedHandler = () => {
|
1764
|
-
const canExpand = row.getCanExpand();
|
1765
|
-
return () => {
|
1766
|
-
if (!canExpand) return;
|
1767
|
-
row.toggleExpanded();
|
1768
|
-
};
|
1769
|
-
};
|
1770
|
-
}
|
1771
|
-
};
|
1772
|
-
|
1773
|
-
//
|
1774
|
-
|
1775
|
-
const defaultPageIndex = 0;
|
1776
|
-
const defaultPageSize = 10;
|
1777
|
-
const getDefaultPaginationState = () => ({
|
1778
|
-
pageIndex: defaultPageIndex,
|
1779
|
-
pageSize: defaultPageSize
|
1780
|
-
});
|
1781
|
-
const RowPagination = {
|
1782
|
-
getInitialState: state => {
|
1783
|
-
return {
|
1784
|
-
...state,
|
1785
|
-
pagination: {
|
1786
|
-
...getDefaultPaginationState(),
|
1787
|
-
...(state == null ? void 0 : state.pagination)
|
1788
|
-
}
|
1789
|
-
};
|
1790
|
-
},
|
1791
|
-
getDefaultOptions: table => {
|
1792
|
-
return {
|
1793
|
-
onPaginationChange: makeStateUpdater('pagination', table)
|
1794
|
-
};
|
1795
|
-
},
|
1796
|
-
createTable: table => {
|
1797
|
-
let registered = false;
|
1798
|
-
let queued = false;
|
1799
|
-
table._autoResetPageIndex = () => {
|
1800
|
-
var _ref, _table$options$autoRe;
|
1801
|
-
if (!registered) {
|
1802
|
-
table._queue(() => {
|
1803
|
-
registered = true;
|
1804
|
-
});
|
1805
|
-
return;
|
1806
|
-
}
|
1807
|
-
if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetPageIndex) != null ? _ref : !table.options.manualPagination) {
|
1808
|
-
if (queued) return;
|
1809
|
-
queued = true;
|
1810
|
-
table._queue(() => {
|
1811
|
-
table.resetPageIndex();
|
1812
|
-
queued = false;
|
1813
|
-
});
|
1814
|
-
}
|
1815
|
-
};
|
1816
|
-
table.setPagination = updater => {
|
1817
|
-
const safeUpdater = old => {
|
1818
|
-
let newState = functionalUpdate(updater, old);
|
1819
|
-
return newState;
|
1820
|
-
};
|
1821
|
-
return table.options.onPaginationChange == null ? void 0 : table.options.onPaginationChange(safeUpdater);
|
1822
|
-
};
|
1823
|
-
table.resetPagination = defaultState => {
|
1824
|
-
var _table$initialState$p;
|
1825
|
-
table.setPagination(defaultState ? getDefaultPaginationState() : (_table$initialState$p = table.initialState.pagination) != null ? _table$initialState$p : getDefaultPaginationState());
|
1826
|
-
};
|
1827
|
-
table.setPageIndex = updater => {
|
1828
|
-
table.setPagination(old => {
|
1829
|
-
let pageIndex = functionalUpdate(updater, old.pageIndex);
|
1830
|
-
const maxPageIndex = typeof table.options.pageCount === 'undefined' || table.options.pageCount === -1 ? Number.MAX_SAFE_INTEGER : table.options.pageCount - 1;
|
1831
|
-
pageIndex = Math.max(0, Math.min(pageIndex, maxPageIndex));
|
1832
|
-
return {
|
1833
|
-
...old,
|
1834
|
-
pageIndex
|
1835
|
-
};
|
1836
|
-
});
|
1837
|
-
};
|
1838
|
-
table.resetPageIndex = defaultState => {
|
1839
|
-
var _table$initialState$p2, _table$initialState;
|
1840
|
-
table.setPageIndex(defaultState ? defaultPageIndex : (_table$initialState$p2 = (_table$initialState = table.initialState) == null || (_table$initialState = _table$initialState.pagination) == null ? void 0 : _table$initialState.pageIndex) != null ? _table$initialState$p2 : defaultPageIndex);
|
1841
|
-
};
|
1842
|
-
table.resetPageSize = defaultState => {
|
1843
|
-
var _table$initialState$p3, _table$initialState2;
|
1844
|
-
table.setPageSize(defaultState ? defaultPageSize : (_table$initialState$p3 = (_table$initialState2 = table.initialState) == null || (_table$initialState2 = _table$initialState2.pagination) == null ? void 0 : _table$initialState2.pageSize) != null ? _table$initialState$p3 : defaultPageSize);
|
1845
|
-
};
|
1846
|
-
table.setPageSize = updater => {
|
1847
|
-
table.setPagination(old => {
|
1848
|
-
const pageSize = Math.max(1, functionalUpdate(updater, old.pageSize));
|
1849
|
-
const topRowIndex = old.pageSize * old.pageIndex;
|
1850
|
-
const pageIndex = Math.floor(topRowIndex / pageSize);
|
1851
|
-
return {
|
1852
|
-
...old,
|
1853
|
-
pageIndex,
|
1854
|
-
pageSize
|
1855
|
-
};
|
1856
|
-
});
|
1857
|
-
};
|
1858
|
-
//deprecated
|
1859
|
-
table.setPageCount = updater => table.setPagination(old => {
|
1860
|
-
var _table$options$pageCo;
|
1861
|
-
let newPageCount = functionalUpdate(updater, (_table$options$pageCo = table.options.pageCount) != null ? _table$options$pageCo : -1);
|
1862
|
-
if (typeof newPageCount === 'number') {
|
1863
|
-
newPageCount = Math.max(-1, newPageCount);
|
1864
|
-
}
|
1865
|
-
return {
|
1866
|
-
...old,
|
1867
|
-
pageCount: newPageCount
|
1868
|
-
};
|
1869
|
-
});
|
1870
|
-
table.getPageOptions = memo(() => [table.getPageCount()], pageCount => {
|
1871
|
-
let pageOptions = [];
|
1872
|
-
if (pageCount && pageCount > 0) {
|
1873
|
-
pageOptions = [...new Array(pageCount)].fill(null).map((_, i) => i);
|
1874
|
-
}
|
1875
|
-
return pageOptions;
|
1876
|
-
}, getMemoOptions(table.options, 'debugTable', 'getPageOptions'));
|
1877
|
-
table.getCanPreviousPage = () => table.getState().pagination.pageIndex > 0;
|
1878
|
-
table.getCanNextPage = () => {
|
1879
|
-
const {
|
1880
|
-
pageIndex
|
1881
|
-
} = table.getState().pagination;
|
1882
|
-
const pageCount = table.getPageCount();
|
1883
|
-
if (pageCount === -1) {
|
1884
|
-
return true;
|
1885
|
-
}
|
1886
|
-
if (pageCount === 0) {
|
1887
|
-
return false;
|
1888
|
-
}
|
1889
|
-
return pageIndex < pageCount - 1;
|
1890
|
-
};
|
1891
|
-
table.previousPage = () => {
|
1892
|
-
return table.setPageIndex(old => old - 1);
|
1893
|
-
};
|
1894
|
-
table.nextPage = () => {
|
1895
|
-
return table.setPageIndex(old => {
|
1896
|
-
return old + 1;
|
1897
|
-
});
|
1898
|
-
};
|
1899
|
-
table.firstPage = () => {
|
1900
|
-
return table.setPageIndex(0);
|
1901
|
-
};
|
1902
|
-
table.lastPage = () => {
|
1903
|
-
return table.setPageIndex(table.getPageCount() - 1);
|
1904
|
-
};
|
1905
|
-
table.getPrePaginationRowModel = () => table.getExpandedRowModel();
|
1906
|
-
table.getPaginationRowModel = () => {
|
1907
|
-
if (!table._getPaginationRowModel && table.options.getPaginationRowModel) {
|
1908
|
-
table._getPaginationRowModel = table.options.getPaginationRowModel(table);
|
1909
|
-
}
|
1910
|
-
if (table.options.manualPagination || !table._getPaginationRowModel) {
|
1911
|
-
return table.getPrePaginationRowModel();
|
1912
|
-
}
|
1913
|
-
return table._getPaginationRowModel();
|
1914
|
-
};
|
1915
|
-
table.getPageCount = () => {
|
1916
|
-
var _table$options$pageCo2;
|
1917
|
-
return (_table$options$pageCo2 = table.options.pageCount) != null ? _table$options$pageCo2 : Math.ceil(table.getRowCount() / table.getState().pagination.pageSize);
|
1918
|
-
};
|
1919
|
-
table.getRowCount = () => {
|
1920
|
-
var _table$options$rowCou;
|
1921
|
-
return (_table$options$rowCou = table.options.rowCount) != null ? _table$options$rowCou : table.getPrePaginationRowModel().rows.length;
|
1922
|
-
};
|
1923
|
-
}
|
1924
|
-
};
|
1925
|
-
|
1926
|
-
//
|
1927
|
-
|
1928
|
-
const getDefaultRowPinningState = () => ({
|
1929
|
-
top: [],
|
1930
|
-
bottom: []
|
1931
|
-
});
|
1932
|
-
const RowPinning = {
|
1933
|
-
getInitialState: state => {
|
1934
|
-
return {
|
1935
|
-
rowPinning: getDefaultRowPinningState(),
|
1936
|
-
...state
|
1937
|
-
};
|
1938
|
-
},
|
1939
|
-
getDefaultOptions: table => {
|
1940
|
-
return {
|
1941
|
-
onRowPinningChange: makeStateUpdater('rowPinning', table)
|
1942
|
-
};
|
1943
|
-
},
|
1944
|
-
createRow: (row, table) => {
|
1945
|
-
row.pin = (position, includeLeafRows, includeParentRows) => {
|
1946
|
-
const leafRowIds = includeLeafRows ? row.getLeafRows().map(_ref => {
|
1947
|
-
let {
|
1948
|
-
id
|
1949
|
-
} = _ref;
|
1950
|
-
return id;
|
1951
|
-
}) : [];
|
1952
|
-
const parentRowIds = includeParentRows ? row.getParentRows().map(_ref2 => {
|
1953
|
-
let {
|
1954
|
-
id
|
1955
|
-
} = _ref2;
|
1956
|
-
return id;
|
1957
|
-
}) : [];
|
1958
|
-
const rowIds = new Set([...parentRowIds, row.id, ...leafRowIds]);
|
1959
|
-
table.setRowPinning(old => {
|
1960
|
-
var _old$top3, _old$bottom3;
|
1961
|
-
if (position === 'bottom') {
|
1962
|
-
var _old$top, _old$bottom;
|
1963
|
-
return {
|
1964
|
-
top: ((_old$top = old == null ? void 0 : old.top) != null ? _old$top : []).filter(d => !(rowIds != null && rowIds.has(d))),
|
1965
|
-
bottom: [...((_old$bottom = old == null ? void 0 : old.bottom) != null ? _old$bottom : []).filter(d => !(rowIds != null && rowIds.has(d))), ...Array.from(rowIds)]
|
1966
|
-
};
|
1967
|
-
}
|
1968
|
-
if (position === 'top') {
|
1969
|
-
var _old$top2, _old$bottom2;
|
1970
|
-
return {
|
1971
|
-
top: [...((_old$top2 = old == null ? void 0 : old.top) != null ? _old$top2 : []).filter(d => !(rowIds != null && rowIds.has(d))), ...Array.from(rowIds)],
|
1972
|
-
bottom: ((_old$bottom2 = old == null ? void 0 : old.bottom) != null ? _old$bottom2 : []).filter(d => !(rowIds != null && rowIds.has(d)))
|
1973
|
-
};
|
1974
|
-
}
|
1975
|
-
return {
|
1976
|
-
top: ((_old$top3 = old == null ? void 0 : old.top) != null ? _old$top3 : []).filter(d => !(rowIds != null && rowIds.has(d))),
|
1977
|
-
bottom: ((_old$bottom3 = old == null ? void 0 : old.bottom) != null ? _old$bottom3 : []).filter(d => !(rowIds != null && rowIds.has(d)))
|
1978
|
-
};
|
1979
|
-
});
|
1980
|
-
};
|
1981
|
-
row.getCanPin = () => {
|
1982
|
-
var _ref3;
|
1983
|
-
const {
|
1984
|
-
enableRowPinning,
|
1985
|
-
enablePinning
|
1986
|
-
} = table.options;
|
1987
|
-
if (typeof enableRowPinning === 'function') {
|
1988
|
-
return enableRowPinning(row);
|
1989
|
-
}
|
1990
|
-
return (_ref3 = enableRowPinning != null ? enableRowPinning : enablePinning) != null ? _ref3 : true;
|
1991
|
-
};
|
1992
|
-
row.getIsPinned = () => {
|
1993
|
-
const rowIds = [row.id];
|
1994
|
-
const {
|
1995
|
-
top,
|
1996
|
-
bottom
|
1997
|
-
} = table.getState().rowPinning;
|
1998
|
-
const isTop = rowIds.some(d => top == null ? void 0 : top.includes(d));
|
1999
|
-
const isBottom = rowIds.some(d => bottom == null ? void 0 : bottom.includes(d));
|
2000
|
-
return isTop ? 'top' : isBottom ? 'bottom' : false;
|
2001
|
-
};
|
2002
|
-
row.getPinnedIndex = () => {
|
2003
|
-
var _ref4, _visiblePinnedRowIds$;
|
2004
|
-
const position = row.getIsPinned();
|
2005
|
-
if (!position) return -1;
|
2006
|
-
const visiblePinnedRowIds = (_ref4 = position === 'top' ? table.getTopRows() : table.getBottomRows()) == null ? void 0 : _ref4.map(_ref5 => {
|
2007
|
-
let {
|
2008
|
-
id
|
2009
|
-
} = _ref5;
|
2010
|
-
return id;
|
2011
|
-
});
|
2012
|
-
return (_visiblePinnedRowIds$ = visiblePinnedRowIds == null ? void 0 : visiblePinnedRowIds.indexOf(row.id)) != null ? _visiblePinnedRowIds$ : -1;
|
2013
|
-
};
|
2014
|
-
},
|
2015
|
-
createTable: table => {
|
2016
|
-
table.setRowPinning = updater => table.options.onRowPinningChange == null ? void 0 : table.options.onRowPinningChange(updater);
|
2017
|
-
table.resetRowPinning = defaultState => {
|
2018
|
-
var _table$initialState$r, _table$initialState;
|
2019
|
-
return table.setRowPinning(defaultState ? getDefaultRowPinningState() : (_table$initialState$r = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.rowPinning) != null ? _table$initialState$r : getDefaultRowPinningState());
|
2020
|
-
};
|
2021
|
-
table.getIsSomeRowsPinned = position => {
|
2022
|
-
var _pinningState$positio;
|
2023
|
-
const pinningState = table.getState().rowPinning;
|
2024
|
-
if (!position) {
|
2025
|
-
var _pinningState$top, _pinningState$bottom;
|
2026
|
-
return Boolean(((_pinningState$top = pinningState.top) == null ? void 0 : _pinningState$top.length) || ((_pinningState$bottom = pinningState.bottom) == null ? void 0 : _pinningState$bottom.length));
|
2027
|
-
}
|
2028
|
-
return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
|
2029
|
-
};
|
2030
|
-
table._getPinnedRows = (visibleRows, pinnedRowIds, position) => {
|
2031
|
-
var _table$options$keepPi;
|
2032
|
-
const rows = ((_table$options$keepPi = table.options.keepPinnedRows) != null ? _table$options$keepPi : true) ?
|
2033
|
-
//get all rows that are pinned even if they would not be otherwise visible
|
2034
|
-
//account for expanded parent rows, but not pagination or filtering
|
2035
|
-
(pinnedRowIds != null ? pinnedRowIds : []).map(rowId => {
|
2036
|
-
const row = table.getRow(rowId, true);
|
2037
|
-
return row.getIsAllParentsExpanded() ? row : null;
|
2038
|
-
}) :
|
2039
|
-
//else get only visible rows that are pinned
|
2040
|
-
(pinnedRowIds != null ? pinnedRowIds : []).map(rowId => visibleRows.find(row => row.id === rowId));
|
2041
|
-
return rows.filter(Boolean).map(d => ({
|
2042
|
-
...d,
|
2043
|
-
position
|
2044
|
-
}));
|
2045
|
-
};
|
2046
|
-
table.getTopRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.top], (allRows, topPinnedRowIds) => table._getPinnedRows(allRows, topPinnedRowIds, 'top'), getMemoOptions(table.options, 'debugRows', 'getTopRows'));
|
2047
|
-
table.getBottomRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.bottom], (allRows, bottomPinnedRowIds) => table._getPinnedRows(allRows, bottomPinnedRowIds, 'bottom'), getMemoOptions(table.options, 'debugRows', 'getBottomRows'));
|
2048
|
-
table.getCenterRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.top, table.getState().rowPinning.bottom], (allRows, top, bottom) => {
|
2049
|
-
const topAndBottom = new Set([...(top != null ? top : []), ...(bottom != null ? bottom : [])]);
|
2050
|
-
return allRows.filter(d => !topAndBottom.has(d.id));
|
2051
|
-
}, getMemoOptions(table.options, 'debugRows', 'getCenterRows'));
|
2052
|
-
}
|
2053
|
-
};
|
2054
|
-
|
2055
|
-
//
|
2056
|
-
|
2057
|
-
const RowSelection = {
|
2058
|
-
getInitialState: state => {
|
2059
|
-
return {
|
2060
|
-
rowSelection: {},
|
2061
|
-
...state
|
2062
|
-
};
|
2063
|
-
},
|
2064
|
-
getDefaultOptions: table => {
|
2065
|
-
return {
|
2066
|
-
onRowSelectionChange: makeStateUpdater('rowSelection', table),
|
2067
|
-
enableRowSelection: true,
|
2068
|
-
enableMultiRowSelection: true,
|
2069
|
-
enableSubRowSelection: true
|
2070
|
-
// enableGroupingRowSelection: false,
|
2071
|
-
// isAdditiveSelectEvent: (e: unknown) => !!e.metaKey,
|
2072
|
-
// isInclusiveSelectEvent: (e: unknown) => !!e.shiftKey,
|
2073
|
-
};
|
2074
|
-
},
|
2075
|
-
createTable: table => {
|
2076
|
-
table.setRowSelection = updater => table.options.onRowSelectionChange == null ? void 0 : table.options.onRowSelectionChange(updater);
|
2077
|
-
table.resetRowSelection = defaultState => {
|
2078
|
-
var _table$initialState$r;
|
2079
|
-
return table.setRowSelection(defaultState ? {} : (_table$initialState$r = table.initialState.rowSelection) != null ? _table$initialState$r : {});
|
2080
|
-
};
|
2081
|
-
table.toggleAllRowsSelected = value => {
|
2082
|
-
table.setRowSelection(old => {
|
2083
|
-
value = typeof value !== 'undefined' ? value : !table.getIsAllRowsSelected();
|
2084
|
-
const rowSelection = {
|
2085
|
-
...old
|
2086
|
-
};
|
2087
|
-
const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows;
|
2088
|
-
|
2089
|
-
// We don't use `mutateRowIsSelected` here for performance reasons.
|
2090
|
-
// All of the rows are flat already, so it wouldn't be worth it
|
2091
|
-
if (value) {
|
2092
|
-
preGroupedFlatRows.forEach(row => {
|
2093
|
-
if (!row.getCanSelect()) {
|
2094
|
-
return;
|
2095
|
-
}
|
2096
|
-
rowSelection[row.id] = true;
|
2097
|
-
});
|
2098
|
-
} else {
|
2099
|
-
preGroupedFlatRows.forEach(row => {
|
2100
|
-
delete rowSelection[row.id];
|
2101
|
-
});
|
2102
|
-
}
|
2103
|
-
return rowSelection;
|
2104
|
-
});
|
2105
|
-
};
|
2106
|
-
table.toggleAllPageRowsSelected = value => table.setRowSelection(old => {
|
2107
|
-
const resolvedValue = typeof value !== 'undefined' ? value : !table.getIsAllPageRowsSelected();
|
2108
|
-
const rowSelection = {
|
2109
|
-
...old
|
2110
|
-
};
|
2111
|
-
table.getRowModel().rows.forEach(row => {
|
2112
|
-
mutateRowIsSelected(rowSelection, row.id, resolvedValue, true, table);
|
2113
|
-
});
|
2114
|
-
return rowSelection;
|
2115
|
-
});
|
2116
|
-
|
2117
|
-
// addRowSelectionRange: rowId => {
|
2118
|
-
// const {
|
2119
|
-
// rows,
|
2120
|
-
// rowsById,
|
2121
|
-
// options: { selectGroupingRows, selectSubRows },
|
2122
|
-
// } = table
|
2123
|
-
|
2124
|
-
// const findSelectedRow = (rows: Row[]) => {
|
2125
|
-
// let found
|
2126
|
-
// rows.find(d => {
|
2127
|
-
// if (d.getIsSelected()) {
|
2128
|
-
// found = d
|
2129
|
-
// return true
|
2130
|
-
// }
|
2131
|
-
// const subFound = findSelectedRow(d.subRows || [])
|
2132
|
-
// if (subFound) {
|
2133
|
-
// found = subFound
|
2134
|
-
// return true
|
2135
|
-
// }
|
2136
|
-
// return false
|
2137
|
-
// })
|
2138
|
-
// return found
|
2139
|
-
// }
|
2140
|
-
|
2141
|
-
// const firstRow = findSelectedRow(rows) || rows[0]
|
2142
|
-
// const lastRow = rowsById[rowId]
|
2143
|
-
|
2144
|
-
// let include = false
|
2145
|
-
// const selectedRowIds = {}
|
2146
|
-
|
2147
|
-
// const addRow = (row: Row) => {
|
2148
|
-
// mutateRowIsSelected(selectedRowIds, row.id, true, {
|
2149
|
-
// rowsById,
|
2150
|
-
// selectGroupingRows: selectGroupingRows!,
|
2151
|
-
// selectSubRows: selectSubRows!,
|
2152
|
-
// })
|
2153
|
-
// }
|
2154
|
-
|
2155
|
-
// table.rows.forEach(row => {
|
2156
|
-
// const isFirstRow = row.id === firstRow.id
|
2157
|
-
// const isLastRow = row.id === lastRow.id
|
2158
|
-
|
2159
|
-
// if (isFirstRow || isLastRow) {
|
2160
|
-
// if (!include) {
|
2161
|
-
// include = true
|
2162
|
-
// } else if (include) {
|
2163
|
-
// addRow(row)
|
2164
|
-
// include = false
|
2165
|
-
// }
|
2166
|
-
// }
|
2167
|
-
|
2168
|
-
// if (include) {
|
2169
|
-
// addRow(row)
|
2170
|
-
// }
|
2171
|
-
// })
|
2172
|
-
|
2173
|
-
// table.setRowSelection(selectedRowIds)
|
2174
|
-
// },
|
2175
|
-
table.getPreSelectedRowModel = () => table.getCoreRowModel();
|
2176
|
-
table.getSelectedRowModel = memo(() => [table.getState().rowSelection, table.getCoreRowModel()], (rowSelection, rowModel) => {
|
2177
|
-
if (!Object.keys(rowSelection).length) {
|
2178
|
-
return {
|
2179
|
-
rows: [],
|
2180
|
-
flatRows: [],
|
2181
|
-
rowsById: {}
|
2182
|
-
};
|
2183
|
-
}
|
2184
|
-
return selectRowsFn(table, rowModel);
|
2185
|
-
}, getMemoOptions(table.options, 'debugTable', 'getSelectedRowModel'));
|
2186
|
-
table.getFilteredSelectedRowModel = memo(() => [table.getState().rowSelection, table.getFilteredRowModel()], (rowSelection, rowModel) => {
|
2187
|
-
if (!Object.keys(rowSelection).length) {
|
2188
|
-
return {
|
2189
|
-
rows: [],
|
2190
|
-
flatRows: [],
|
2191
|
-
rowsById: {}
|
2192
|
-
};
|
2193
|
-
}
|
2194
|
-
return selectRowsFn(table, rowModel);
|
2195
|
-
}, getMemoOptions(table.options, 'debugTable', 'getFilteredSelectedRowModel'));
|
2196
|
-
table.getGroupedSelectedRowModel = memo(() => [table.getState().rowSelection, table.getSortedRowModel()], (rowSelection, rowModel) => {
|
2197
|
-
if (!Object.keys(rowSelection).length) {
|
2198
|
-
return {
|
2199
|
-
rows: [],
|
2200
|
-
flatRows: [],
|
2201
|
-
rowsById: {}
|
2202
|
-
};
|
2203
|
-
}
|
2204
|
-
return selectRowsFn(table, rowModel);
|
2205
|
-
}, getMemoOptions(table.options, 'debugTable', 'getGroupedSelectedRowModel'));
|
2206
|
-
|
2207
|
-
///
|
2208
|
-
|
2209
|
-
// getGroupingRowCanSelect: rowId => {
|
2210
|
-
// const row = table.getRow(rowId)
|
2211
|
-
|
2212
|
-
// if (!row) {
|
2213
|
-
// throw new Error()
|
2214
|
-
// }
|
2215
|
-
|
2216
|
-
// if (typeof table.options.enableGroupingRowSelection === 'function') {
|
2217
|
-
// return table.options.enableGroupingRowSelection(row)
|
2218
|
-
// }
|
2219
|
-
|
2220
|
-
// return table.options.enableGroupingRowSelection ?? false
|
2221
|
-
// },
|
2222
|
-
|
2223
|
-
table.getIsAllRowsSelected = () => {
|
2224
|
-
const preGroupedFlatRows = table.getFilteredRowModel().flatRows;
|
2225
|
-
const {
|
2226
|
-
rowSelection
|
2227
|
-
} = table.getState();
|
2228
|
-
let isAllRowsSelected = Boolean(preGroupedFlatRows.length && Object.keys(rowSelection).length);
|
2229
|
-
if (isAllRowsSelected) {
|
2230
|
-
if (preGroupedFlatRows.some(row => row.getCanSelect() && !rowSelection[row.id])) {
|
2231
|
-
isAllRowsSelected = false;
|
2232
|
-
}
|
2233
|
-
}
|
2234
|
-
return isAllRowsSelected;
|
2235
|
-
};
|
2236
|
-
table.getIsAllPageRowsSelected = () => {
|
2237
|
-
const paginationFlatRows = table.getPaginationRowModel().flatRows.filter(row => row.getCanSelect());
|
2238
|
-
const {
|
2239
|
-
rowSelection
|
2240
|
-
} = table.getState();
|
2241
|
-
let isAllPageRowsSelected = !!paginationFlatRows.length;
|
2242
|
-
if (isAllPageRowsSelected && paginationFlatRows.some(row => !rowSelection[row.id])) {
|
2243
|
-
isAllPageRowsSelected = false;
|
2244
|
-
}
|
2245
|
-
return isAllPageRowsSelected;
|
2246
|
-
};
|
2247
|
-
table.getIsSomeRowsSelected = () => {
|
2248
|
-
var _table$getState$rowSe;
|
2249
|
-
const totalSelected = Object.keys((_table$getState$rowSe = table.getState().rowSelection) != null ? _table$getState$rowSe : {}).length;
|
2250
|
-
return totalSelected > 0 && totalSelected < table.getFilteredRowModel().flatRows.length;
|
2251
|
-
};
|
2252
|
-
table.getIsSomePageRowsSelected = () => {
|
2253
|
-
const paginationFlatRows = table.getPaginationRowModel().flatRows;
|
2254
|
-
return table.getIsAllPageRowsSelected() ? false : paginationFlatRows.filter(row => row.getCanSelect()).some(d => d.getIsSelected() || d.getIsSomeSelected());
|
2255
|
-
};
|
2256
|
-
table.getToggleAllRowsSelectedHandler = () => {
|
2257
|
-
return e => {
|
2258
|
-
table.toggleAllRowsSelected(e.target.checked);
|
2259
|
-
};
|
2260
|
-
};
|
2261
|
-
table.getToggleAllPageRowsSelectedHandler = () => {
|
2262
|
-
return e => {
|
2263
|
-
table.toggleAllPageRowsSelected(e.target.checked);
|
2264
|
-
};
|
2265
|
-
};
|
2266
|
-
},
|
2267
|
-
createRow: (row, table) => {
|
2268
|
-
row.toggleSelected = (value, opts) => {
|
2269
|
-
const isSelected = row.getIsSelected();
|
2270
|
-
table.setRowSelection(old => {
|
2271
|
-
var _opts$selectChildren;
|
2272
|
-
value = typeof value !== 'undefined' ? value : !isSelected;
|
2273
|
-
if (row.getCanSelect() && isSelected === value) {
|
2274
|
-
return old;
|
2275
|
-
}
|
2276
|
-
const selectedRowIds = {
|
2277
|
-
...old
|
2278
|
-
};
|
2279
|
-
mutateRowIsSelected(selectedRowIds, row.id, value, (_opts$selectChildren = opts == null ? void 0 : opts.selectChildren) != null ? _opts$selectChildren : true, table);
|
2280
|
-
return selectedRowIds;
|
2281
|
-
});
|
2282
|
-
};
|
2283
|
-
row.getIsSelected = () => {
|
2284
|
-
const {
|
2285
|
-
rowSelection
|
2286
|
-
} = table.getState();
|
2287
|
-
return isRowSelected(row, rowSelection);
|
2288
|
-
};
|
2289
|
-
row.getIsSomeSelected = () => {
|
2290
|
-
const {
|
2291
|
-
rowSelection
|
2292
|
-
} = table.getState();
|
2293
|
-
return isSubRowSelected(row, rowSelection) === 'some';
|
2294
|
-
};
|
2295
|
-
row.getIsAllSubRowsSelected = () => {
|
2296
|
-
const {
|
2297
|
-
rowSelection
|
2298
|
-
} = table.getState();
|
2299
|
-
return isSubRowSelected(row, rowSelection) === 'all';
|
2300
|
-
};
|
2301
|
-
row.getCanSelect = () => {
|
2302
|
-
var _table$options$enable;
|
2303
|
-
if (typeof table.options.enableRowSelection === 'function') {
|
2304
|
-
return table.options.enableRowSelection(row);
|
2305
|
-
}
|
2306
|
-
return (_table$options$enable = table.options.enableRowSelection) != null ? _table$options$enable : true;
|
2307
|
-
};
|
2308
|
-
row.getCanSelectSubRows = () => {
|
2309
|
-
var _table$options$enable2;
|
2310
|
-
if (typeof table.options.enableSubRowSelection === 'function') {
|
2311
|
-
return table.options.enableSubRowSelection(row);
|
2312
|
-
}
|
2313
|
-
return (_table$options$enable2 = table.options.enableSubRowSelection) != null ? _table$options$enable2 : true;
|
2314
|
-
};
|
2315
|
-
row.getCanMultiSelect = () => {
|
2316
|
-
var _table$options$enable3;
|
2317
|
-
if (typeof table.options.enableMultiRowSelection === 'function') {
|
2318
|
-
return table.options.enableMultiRowSelection(row);
|
2319
|
-
}
|
2320
|
-
return (_table$options$enable3 = table.options.enableMultiRowSelection) != null ? _table$options$enable3 : true;
|
2321
|
-
};
|
2322
|
-
row.getToggleSelectedHandler = () => {
|
2323
|
-
const canSelect = row.getCanSelect();
|
2324
|
-
return e => {
|
2325
|
-
var _target;
|
2326
|
-
if (!canSelect) return;
|
2327
|
-
row.toggleSelected((_target = e.target) == null ? void 0 : _target.checked);
|
2328
|
-
};
|
2329
|
-
};
|
2330
|
-
}
|
2331
|
-
};
|
2332
|
-
const mutateRowIsSelected = (selectedRowIds, id, value, includeChildren, table) => {
|
2333
|
-
var _row$subRows;
|
2334
|
-
const row = table.getRow(id, true);
|
2335
|
-
|
2336
|
-
// const isGrouped = row.getIsGrouped()
|
2337
|
-
|
2338
|
-
// if ( // TODO: enforce grouping row selection rules
|
2339
|
-
// !isGrouped ||
|
2340
|
-
// (isGrouped && table.options.enableGroupingRowSelection)
|
2341
|
-
// ) {
|
2342
|
-
if (value) {
|
2343
|
-
if (!row.getCanMultiSelect()) {
|
2344
|
-
Object.keys(selectedRowIds).forEach(key => delete selectedRowIds[key]);
|
2345
|
-
}
|
2346
|
-
if (row.getCanSelect()) {
|
2347
|
-
selectedRowIds[id] = true;
|
2348
|
-
}
|
2349
|
-
} else {
|
2350
|
-
delete selectedRowIds[id];
|
2351
|
-
}
|
2352
|
-
// }
|
2353
|
-
|
2354
|
-
if (includeChildren && (_row$subRows = row.subRows) != null && _row$subRows.length && row.getCanSelectSubRows()) {
|
2355
|
-
row.subRows.forEach(row => mutateRowIsSelected(selectedRowIds, row.id, value, includeChildren, table));
|
2356
|
-
}
|
2357
|
-
};
|
2358
|
-
function selectRowsFn(table, rowModel) {
|
2359
|
-
const rowSelection = table.getState().rowSelection;
|
2360
|
-
const newSelectedFlatRows = [];
|
2361
|
-
const newSelectedRowsById = {};
|
2362
|
-
|
2363
|
-
// Filters top level and nested rows
|
2364
|
-
const recurseRows = function (rows, depth) {
|
2365
|
-
return rows.map(row => {
|
2366
|
-
var _row$subRows2;
|
2367
|
-
const isSelected = isRowSelected(row, rowSelection);
|
2368
|
-
if (isSelected) {
|
2369
|
-
newSelectedFlatRows.push(row);
|
2370
|
-
newSelectedRowsById[row.id] = row;
|
2371
|
-
}
|
2372
|
-
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
|
2373
|
-
row = {
|
2374
|
-
...row,
|
2375
|
-
subRows: recurseRows(row.subRows)
|
2376
|
-
};
|
2377
|
-
}
|
2378
|
-
if (isSelected) {
|
2379
|
-
return row;
|
2380
|
-
}
|
2381
|
-
}).filter(Boolean);
|
2382
|
-
};
|
2383
|
-
return {
|
2384
|
-
rows: recurseRows(rowModel.rows),
|
2385
|
-
flatRows: newSelectedFlatRows,
|
2386
|
-
rowsById: newSelectedRowsById
|
2387
|
-
};
|
2388
|
-
}
|
2389
|
-
function isRowSelected(row, selection) {
|
2390
|
-
var _selection$row$id;
|
2391
|
-
return (_selection$row$id = selection[row.id]) != null ? _selection$row$id : false;
|
2392
|
-
}
|
2393
|
-
function isSubRowSelected(row, selection, table) {
|
2394
|
-
var _row$subRows3;
|
2395
|
-
if (!((_row$subRows3 = row.subRows) != null && _row$subRows3.length)) return false;
|
2396
|
-
let allChildrenSelected = true;
|
2397
|
-
let someSelected = false;
|
2398
|
-
row.subRows.forEach(subRow => {
|
2399
|
-
// Bail out early if we know both of these
|
2400
|
-
if (someSelected && !allChildrenSelected) {
|
2401
|
-
return;
|
2402
|
-
}
|
2403
|
-
if (subRow.getCanSelect()) {
|
2404
|
-
if (isRowSelected(subRow, selection)) {
|
2405
|
-
someSelected = true;
|
2406
|
-
} else {
|
2407
|
-
allChildrenSelected = false;
|
2408
|
-
}
|
2409
|
-
}
|
2410
|
-
|
2411
|
-
// Check row selection of nested subrows
|
2412
|
-
if (subRow.subRows && subRow.subRows.length) {
|
2413
|
-
const subRowChildrenSelected = isSubRowSelected(subRow, selection);
|
2414
|
-
if (subRowChildrenSelected === 'all') {
|
2415
|
-
someSelected = true;
|
2416
|
-
} else if (subRowChildrenSelected === 'some') {
|
2417
|
-
someSelected = true;
|
2418
|
-
allChildrenSelected = false;
|
2419
|
-
} else {
|
2420
|
-
allChildrenSelected = false;
|
2421
|
-
}
|
2422
|
-
}
|
2423
|
-
});
|
2424
|
-
return allChildrenSelected ? 'all' : someSelected ? 'some' : false;
|
2425
|
-
}
|
2426
|
-
|
2427
|
-
const reSplitAlphaNumeric = /([0-9]+)/gm;
|
2428
|
-
const alphanumeric = (rowA, rowB, columnId) => {
|
2429
|
-
return compareAlphanumeric(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
2430
|
-
};
|
2431
|
-
const alphanumericCaseSensitive = (rowA, rowB, columnId) => {
|
2432
|
-
return compareAlphanumeric(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
2433
|
-
};
|
2434
|
-
|
2435
|
-
// The text filter is more basic (less numeric support)
|
2436
|
-
// but is much faster
|
2437
|
-
const text = (rowA, rowB, columnId) => {
|
2438
|
-
return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
2439
|
-
};
|
2440
|
-
|
2441
|
-
// The text filter is more basic (less numeric support)
|
2442
|
-
// but is much faster
|
2443
|
-
const textCaseSensitive = (rowA, rowB, columnId) => {
|
2444
|
-
return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
2445
|
-
};
|
2446
|
-
const datetime = (rowA, rowB, columnId) => {
|
2447
|
-
const a = rowA.getValue(columnId);
|
2448
|
-
const b = rowB.getValue(columnId);
|
2449
|
-
|
2450
|
-
// Can handle nullish values
|
2451
|
-
// Use > and < because == (and ===) doesn't work with
|
2452
|
-
// Date objects (would require calling getTime()).
|
2453
|
-
return a > b ? 1 : a < b ? -1 : 0;
|
2454
|
-
};
|
2455
|
-
const basic = (rowA, rowB, columnId) => {
|
2456
|
-
return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
|
2457
|
-
};
|
2458
|
-
|
2459
|
-
// Utils
|
2460
|
-
|
2461
|
-
function compareBasic(a, b) {
|
2462
|
-
return a === b ? 0 : a > b ? 1 : -1;
|
2463
|
-
}
|
2464
|
-
function toString(a) {
|
2465
|
-
if (typeof a === 'number') {
|
2466
|
-
if (isNaN(a) || a === Infinity || a === -Infinity) {
|
2467
|
-
return '';
|
2468
|
-
}
|
2469
|
-
return String(a);
|
2470
|
-
}
|
2471
|
-
if (typeof a === 'string') {
|
2472
|
-
return a;
|
2473
|
-
}
|
2474
|
-
return '';
|
2475
|
-
}
|
2476
|
-
|
2477
|
-
// Mixed sorting is slow, but very inclusive of many edge cases.
|
2478
|
-
// It handles numbers, mixed alphanumeric combinations, and even
|
2479
|
-
// null, undefined, and Infinity
|
2480
|
-
function compareAlphanumeric(aStr, bStr) {
|
2481
|
-
// Split on number groups, but keep the delimiter
|
2482
|
-
// Then remove falsey split values
|
2483
|
-
const a = aStr.split(reSplitAlphaNumeric).filter(Boolean);
|
2484
|
-
const b = bStr.split(reSplitAlphaNumeric).filter(Boolean);
|
2485
|
-
|
2486
|
-
// While
|
2487
|
-
while (a.length && b.length) {
|
2488
|
-
const aa = a.shift();
|
2489
|
-
const bb = b.shift();
|
2490
|
-
const an = parseInt(aa, 10);
|
2491
|
-
const bn = parseInt(bb, 10);
|
2492
|
-
const combo = [an, bn].sort();
|
2493
|
-
|
2494
|
-
// Both are string
|
2495
|
-
if (isNaN(combo[0])) {
|
2496
|
-
if (aa > bb) {
|
2497
|
-
return 1;
|
2498
|
-
}
|
2499
|
-
if (bb > aa) {
|
2500
|
-
return -1;
|
2501
|
-
}
|
2502
|
-
continue;
|
2503
|
-
}
|
2504
|
-
|
2505
|
-
// One is a string, one is a number
|
2506
|
-
if (isNaN(combo[1])) {
|
2507
|
-
return isNaN(an) ? -1 : 1;
|
2508
|
-
}
|
2509
|
-
|
2510
|
-
// Both are numbers
|
2511
|
-
if (an > bn) {
|
2512
|
-
return 1;
|
2513
|
-
}
|
2514
|
-
if (bn > an) {
|
2515
|
-
return -1;
|
2516
|
-
}
|
2517
|
-
}
|
2518
|
-
return a.length - b.length;
|
2519
|
-
}
|
2520
|
-
|
2521
|
-
// Exports
|
2522
|
-
|
2523
|
-
const sortingFns = {
|
2524
|
-
alphanumeric,
|
2525
|
-
alphanumericCaseSensitive,
|
2526
|
-
text,
|
2527
|
-
textCaseSensitive,
|
2528
|
-
datetime,
|
2529
|
-
basic
|
2530
|
-
};
|
2531
|
-
|
2532
|
-
//
|
2533
|
-
|
2534
|
-
const RowSorting = {
|
2535
|
-
getInitialState: state => {
|
2536
|
-
return {
|
2537
|
-
sorting: [],
|
2538
|
-
...state
|
2539
|
-
};
|
2540
|
-
},
|
2541
|
-
getDefaultColumnDef: () => {
|
2542
|
-
return {
|
2543
|
-
sortingFn: 'auto',
|
2544
|
-
sortUndefined: 1
|
2545
|
-
};
|
2546
|
-
},
|
2547
|
-
getDefaultOptions: table => {
|
2548
|
-
return {
|
2549
|
-
onSortingChange: makeStateUpdater('sorting', table),
|
2550
|
-
isMultiSortEvent: e => {
|
2551
|
-
return e.shiftKey;
|
2552
|
-
}
|
2553
|
-
};
|
2554
|
-
},
|
2555
|
-
createColumn: (column, table) => {
|
2556
|
-
column.getAutoSortingFn = () => {
|
2557
|
-
const firstRows = table.getFilteredRowModel().flatRows.slice(10);
|
2558
|
-
let isString = false;
|
2559
|
-
for (const row of firstRows) {
|
2560
|
-
const value = row == null ? void 0 : row.getValue(column.id);
|
2561
|
-
if (Object.prototype.toString.call(value) === '[object Date]') {
|
2562
|
-
return sortingFns.datetime;
|
2563
|
-
}
|
2564
|
-
if (typeof value === 'string') {
|
2565
|
-
isString = true;
|
2566
|
-
if (value.split(reSplitAlphaNumeric).length > 1) {
|
2567
|
-
return sortingFns.alphanumeric;
|
2568
|
-
}
|
2569
|
-
}
|
2570
|
-
}
|
2571
|
-
if (isString) {
|
2572
|
-
return sortingFns.text;
|
2573
|
-
}
|
2574
|
-
return sortingFns.basic;
|
2575
|
-
};
|
2576
|
-
column.getAutoSortDir = () => {
|
2577
|
-
const firstRow = table.getFilteredRowModel().flatRows[0];
|
2578
|
-
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
2579
|
-
if (typeof value === 'string') {
|
2580
|
-
return 'asc';
|
2581
|
-
}
|
2582
|
-
return 'desc';
|
2583
|
-
};
|
2584
|
-
column.getSortingFn = () => {
|
2585
|
-
var _table$options$sortin, _table$options$sortin2;
|
2586
|
-
if (!column) {
|
2587
|
-
throw new Error();
|
2588
|
-
}
|
2589
|
-
return isFunction(column.columnDef.sortingFn) ? column.columnDef.sortingFn : column.columnDef.sortingFn === 'auto' ? column.getAutoSortingFn() : (_table$options$sortin = (_table$options$sortin2 = table.options.sortingFns) == null ? void 0 : _table$options$sortin2[column.columnDef.sortingFn]) != null ? _table$options$sortin : sortingFns[column.columnDef.sortingFn];
|
2590
|
-
};
|
2591
|
-
column.toggleSorting = (desc, multi) => {
|
2592
|
-
// if (column.columns.length) {
|
2593
|
-
// column.columns.forEach((c, i) => {
|
2594
|
-
// if (c.id) {
|
2595
|
-
// table.toggleColumnSorting(c.id, undefined, multi || !!i)
|
2596
|
-
// }
|
2597
|
-
// })
|
2598
|
-
// return
|
2599
|
-
// }
|
2600
|
-
|
2601
|
-
// this needs to be outside of table.setSorting to be in sync with rerender
|
2602
|
-
const nextSortingOrder = column.getNextSortingOrder();
|
2603
|
-
const hasManualValue = typeof desc !== 'undefined' && desc !== null;
|
2604
|
-
table.setSorting(old => {
|
2605
|
-
// Find any existing sorting for this column
|
2606
|
-
const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
|
2607
|
-
const existingIndex = old == null ? void 0 : old.findIndex(d => d.id === column.id);
|
2608
|
-
let newSorting = [];
|
2609
|
-
|
2610
|
-
// What should we do with this sort action?
|
2611
|
-
let sortAction;
|
2612
|
-
let nextDesc = hasManualValue ? desc : nextSortingOrder === 'desc';
|
2613
|
-
|
2614
|
-
// Multi-mode
|
2615
|
-
if (old != null && old.length && column.getCanMultiSort() && multi) {
|
2616
|
-
if (existingSorting) {
|
2617
|
-
sortAction = 'toggle';
|
2618
|
-
} else {
|
2619
|
-
sortAction = 'add';
|
2620
|
-
}
|
2621
|
-
} else {
|
2622
|
-
// Normal mode
|
2623
|
-
if (old != null && old.length && existingIndex !== old.length - 1) {
|
2624
|
-
sortAction = 'replace';
|
2625
|
-
} else if (existingSorting) {
|
2626
|
-
sortAction = 'toggle';
|
2627
|
-
} else {
|
2628
|
-
sortAction = 'replace';
|
2629
|
-
}
|
2630
|
-
}
|
2631
|
-
|
2632
|
-
// Handle toggle states that will remove the sorting
|
2633
|
-
if (sortAction === 'toggle') {
|
2634
|
-
// If we are "actually" toggling (not a manual set value), should we remove the sorting?
|
2635
|
-
if (!hasManualValue) {
|
2636
|
-
// Is our intention to remove?
|
2637
|
-
if (!nextSortingOrder) {
|
2638
|
-
sortAction = 'remove';
|
2639
|
-
}
|
2640
|
-
}
|
2641
|
-
}
|
2642
|
-
if (sortAction === 'add') {
|
2643
|
-
var _table$options$maxMul;
|
2644
|
-
newSorting = [...old, {
|
2645
|
-
id: column.id,
|
2646
|
-
desc: nextDesc
|
2647
|
-
}];
|
2648
|
-
// Take latest n columns
|
2649
|
-
newSorting.splice(0, newSorting.length - ((_table$options$maxMul = table.options.maxMultiSortColCount) != null ? _table$options$maxMul : Number.MAX_SAFE_INTEGER));
|
2650
|
-
} else if (sortAction === 'toggle') {
|
2651
|
-
// This flips (or sets) the
|
2652
|
-
newSorting = old.map(d => {
|
2653
|
-
if (d.id === column.id) {
|
2654
|
-
return {
|
2655
|
-
...d,
|
2656
|
-
desc: nextDesc
|
2657
|
-
};
|
2658
|
-
}
|
2659
|
-
return d;
|
2660
|
-
});
|
2661
|
-
} else if (sortAction === 'remove') {
|
2662
|
-
newSorting = old.filter(d => d.id !== column.id);
|
2663
|
-
} else {
|
2664
|
-
newSorting = [{
|
2665
|
-
id: column.id,
|
2666
|
-
desc: nextDesc
|
2667
|
-
}];
|
2668
|
-
}
|
2669
|
-
return newSorting;
|
2670
|
-
});
|
2671
|
-
};
|
2672
|
-
column.getFirstSortDir = () => {
|
2673
|
-
var _ref, _column$columnDef$sor;
|
2674
|
-
const sortDescFirst = (_ref = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : table.options.sortDescFirst) != null ? _ref : column.getAutoSortDir() === 'desc';
|
2675
|
-
return sortDescFirst ? 'desc' : 'asc';
|
2676
|
-
};
|
2677
|
-
column.getNextSortingOrder = multi => {
|
2678
|
-
var _table$options$enable, _table$options$enable2;
|
2679
|
-
const firstSortDirection = column.getFirstSortDir();
|
2680
|
-
const isSorted = column.getIsSorted();
|
2681
|
-
if (!isSorted) {
|
2682
|
-
return firstSortDirection;
|
2683
|
-
}
|
2684
|
-
if (isSorted !== firstSortDirection && ((_table$options$enable = table.options.enableSortingRemoval) != null ? _table$options$enable : true) && (
|
2685
|
-
// If enableSortRemove, enable in general
|
2686
|
-
multi ? (_table$options$enable2 = table.options.enableMultiRemove) != null ? _table$options$enable2 : true : true) // If multi, don't allow if enableMultiRemove))
|
2687
|
-
) {
|
2688
|
-
return false;
|
2689
|
-
}
|
2690
|
-
return isSorted === 'desc' ? 'asc' : 'desc';
|
2691
|
-
};
|
2692
|
-
column.getCanSort = () => {
|
2693
|
-
var _column$columnDef$ena, _table$options$enable3;
|
2694
|
-
return ((_column$columnDef$ena = column.columnDef.enableSorting) != null ? _column$columnDef$ena : true) && ((_table$options$enable3 = table.options.enableSorting) != null ? _table$options$enable3 : true) && !!column.accessorFn;
|
2695
|
-
};
|
2696
|
-
column.getCanMultiSort = () => {
|
2697
|
-
var _ref2, _column$columnDef$ena2;
|
2698
|
-
return (_ref2 = (_column$columnDef$ena2 = column.columnDef.enableMultiSort) != null ? _column$columnDef$ena2 : table.options.enableMultiSort) != null ? _ref2 : !!column.accessorFn;
|
2699
|
-
};
|
2700
|
-
column.getIsSorted = () => {
|
2701
|
-
var _table$getState$sorti;
|
2702
|
-
const columnSort = (_table$getState$sorti = table.getState().sorting) == null ? void 0 : _table$getState$sorti.find(d => d.id === column.id);
|
2703
|
-
return !columnSort ? false : columnSort.desc ? 'desc' : 'asc';
|
2704
|
-
};
|
2705
|
-
column.getSortIndex = () => {
|
2706
|
-
var _table$getState$sorti2, _table$getState$sorti3;
|
2707
|
-
return (_table$getState$sorti2 = (_table$getState$sorti3 = table.getState().sorting) == null ? void 0 : _table$getState$sorti3.findIndex(d => d.id === column.id)) != null ? _table$getState$sorti2 : -1;
|
2708
|
-
};
|
2709
|
-
column.clearSorting = () => {
|
2710
|
-
//clear sorting for just 1 column
|
2711
|
-
table.setSorting(old => old != null && old.length ? old.filter(d => d.id !== column.id) : []);
|
2712
|
-
};
|
2713
|
-
column.getToggleSortingHandler = () => {
|
2714
|
-
const canSort = column.getCanSort();
|
2715
|
-
return e => {
|
2716
|
-
if (!canSort) return;
|
2717
|
-
e.persist == null || e.persist();
|
2718
|
-
column.toggleSorting == null || column.toggleSorting(undefined, column.getCanMultiSort() ? table.options.isMultiSortEvent == null ? void 0 : table.options.isMultiSortEvent(e) : false);
|
2719
|
-
};
|
2720
|
-
};
|
2721
|
-
},
|
2722
|
-
createTable: table => {
|
2723
|
-
table.setSorting = updater => table.options.onSortingChange == null ? void 0 : table.options.onSortingChange(updater);
|
2724
|
-
table.resetSorting = defaultState => {
|
2725
|
-
var _table$initialState$s, _table$initialState;
|
2726
|
-
table.setSorting(defaultState ? [] : (_table$initialState$s = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.sorting) != null ? _table$initialState$s : []);
|
2727
|
-
};
|
2728
|
-
table.getPreSortedRowModel = () => table.getGroupedRowModel();
|
2729
|
-
table.getSortedRowModel = () => {
|
2730
|
-
if (!table._getSortedRowModel && table.options.getSortedRowModel) {
|
2731
|
-
table._getSortedRowModel = table.options.getSortedRowModel(table);
|
2732
|
-
}
|
2733
|
-
if (table.options.manualSorting || !table._getSortedRowModel) {
|
2734
|
-
return table.getPreSortedRowModel();
|
2735
|
-
}
|
2736
|
-
return table._getSortedRowModel();
|
2737
|
-
};
|
2738
|
-
}
|
2739
|
-
};
|
2740
|
-
|
2741
|
-
const builtInFeatures = [Headers, ColumnVisibility, ColumnOrdering, ColumnPinning, ColumnFaceting, ColumnFiltering, GlobalFaceting,
|
2742
|
-
//depends on ColumnFaceting
|
2743
|
-
GlobalFiltering,
|
2744
|
-
//depends on ColumnFiltering
|
2745
|
-
RowSorting, ColumnGrouping,
|
2746
|
-
//depends on RowSorting
|
2747
|
-
RowExpanding, RowPagination, RowPinning, RowSelection, ColumnSizing];
|
2748
|
-
|
2749
|
-
//
|
2750
|
-
|
2751
|
-
function createTable(options) {
|
2752
|
-
var _options$_features, _options$initialState;
|
2753
|
-
if (process.env.NODE_ENV !== 'production' && (options.debugAll || options.debugTable)) {
|
2754
|
-
console.info('Creating Table Instance...');
|
2755
|
-
}
|
2756
|
-
const _features = [...builtInFeatures, ...((_options$_features = options._features) != null ? _options$_features : [])];
|
2757
|
-
let table = {
|
2758
|
-
_features
|
2759
|
-
};
|
2760
|
-
const defaultOptions = table._features.reduce((obj, feature) => {
|
2761
|
-
return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(table));
|
2762
|
-
}, {});
|
2763
|
-
const mergeOptions = options => {
|
2764
|
-
if (table.options.mergeOptions) {
|
2765
|
-
return table.options.mergeOptions(defaultOptions, options);
|
2766
|
-
}
|
2767
|
-
return {
|
2768
|
-
...defaultOptions,
|
2769
|
-
...options
|
2770
|
-
};
|
2771
|
-
};
|
2772
|
-
const coreInitialState = {};
|
2773
|
-
let initialState = {
|
2774
|
-
...coreInitialState,
|
2775
|
-
...((_options$initialState = options.initialState) != null ? _options$initialState : {})
|
2776
|
-
};
|
2777
|
-
table._features.forEach(feature => {
|
2778
|
-
var _feature$getInitialSt;
|
2779
|
-
initialState = (_feature$getInitialSt = feature.getInitialState == null ? void 0 : feature.getInitialState(initialState)) != null ? _feature$getInitialSt : initialState;
|
2780
|
-
});
|
2781
|
-
const queued = [];
|
2782
|
-
let queuedTimeout = false;
|
2783
|
-
const coreInstance = {
|
2784
|
-
_features,
|
2785
|
-
options: {
|
2786
|
-
...defaultOptions,
|
2787
|
-
...options
|
2788
|
-
},
|
2789
|
-
initialState,
|
2790
|
-
_queue: cb => {
|
2791
|
-
queued.push(cb);
|
2792
|
-
if (!queuedTimeout) {
|
2793
|
-
queuedTimeout = true;
|
2794
|
-
|
2795
|
-
// Schedule a microtask to run the queued callbacks after
|
2796
|
-
// the current call stack (render, etc) has finished.
|
2797
|
-
Promise.resolve().then(() => {
|
2798
|
-
while (queued.length) {
|
2799
|
-
queued.shift()();
|
2800
|
-
}
|
2801
|
-
queuedTimeout = false;
|
2802
|
-
}).catch(error => setTimeout(() => {
|
2803
|
-
throw error;
|
2804
|
-
}));
|
2805
|
-
}
|
2806
|
-
},
|
2807
|
-
reset: () => {
|
2808
|
-
table.setState(table.initialState);
|
2809
|
-
},
|
2810
|
-
setOptions: updater => {
|
2811
|
-
const newOptions = functionalUpdate(updater, table.options);
|
2812
|
-
table.options = mergeOptions(newOptions);
|
2813
|
-
},
|
2814
|
-
getState: () => {
|
2815
|
-
return table.options.state;
|
2816
|
-
},
|
2817
|
-
setState: updater => {
|
2818
|
-
table.options.onStateChange == null || table.options.onStateChange(updater);
|
2819
|
-
},
|
2820
|
-
_getRowId: (row, index, parent) => {
|
2821
|
-
var _table$options$getRow;
|
2822
|
-
return (_table$options$getRow = table.options.getRowId == null ? void 0 : table.options.getRowId(row, index, parent)) != null ? _table$options$getRow : `${parent ? [parent.id, index].join('.') : index}`;
|
2823
|
-
},
|
2824
|
-
getCoreRowModel: () => {
|
2825
|
-
if (!table._getCoreRowModel) {
|
2826
|
-
table._getCoreRowModel = table.options.getCoreRowModel(table);
|
2827
|
-
}
|
2828
|
-
return table._getCoreRowModel();
|
2829
|
-
},
|
2830
|
-
// The final calls start at the bottom of the model,
|
2831
|
-
// expanded rows, which then work their way up
|
2832
|
-
|
2833
|
-
getRowModel: () => {
|
2834
|
-
return table.getPaginationRowModel();
|
2835
|
-
},
|
2836
|
-
//in next version, we should just pass in the row model as the optional 2nd arg
|
2837
|
-
getRow: (id, searchAll) => {
|
2838
|
-
let row = (searchAll ? table.getPrePaginationRowModel() : table.getRowModel()).rowsById[id];
|
2839
|
-
if (!row) {
|
2840
|
-
row = table.getCoreRowModel().rowsById[id];
|
2841
|
-
if (!row) {
|
2842
|
-
if (process.env.NODE_ENV !== 'production') {
|
2843
|
-
throw new Error(`getRow could not find row with ID: ${id}`);
|
2844
|
-
}
|
2845
|
-
throw new Error();
|
2846
|
-
}
|
2847
|
-
}
|
2848
|
-
return row;
|
2849
|
-
},
|
2850
|
-
_getDefaultColumnDef: memo(() => [table.options.defaultColumn], defaultColumn => {
|
2851
|
-
var _defaultColumn;
|
2852
|
-
defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
|
2853
|
-
return {
|
2854
|
-
header: props => {
|
2855
|
-
const resolvedColumnDef = props.header.column.columnDef;
|
2856
|
-
if (resolvedColumnDef.accessorKey) {
|
2857
|
-
return resolvedColumnDef.accessorKey;
|
2858
|
-
}
|
2859
|
-
if (resolvedColumnDef.accessorFn) {
|
2860
|
-
return resolvedColumnDef.id;
|
2861
|
-
}
|
2862
|
-
return null;
|
2863
|
-
},
|
2864
|
-
// footer: props => props.header.column.id,
|
2865
|
-
cell: props => {
|
2866
|
-
var _props$renderValue$to, _props$renderValue;
|
2867
|
-
return (_props$renderValue$to = (_props$renderValue = props.renderValue()) == null || _props$renderValue.toString == null ? void 0 : _props$renderValue.toString()) != null ? _props$renderValue$to : null;
|
2868
|
-
},
|
2869
|
-
...table._features.reduce((obj, feature) => {
|
2870
|
-
return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
|
2871
|
-
}, {}),
|
2872
|
-
...defaultColumn
|
2873
|
-
};
|
2874
|
-
}, getMemoOptions(options, 'debugColumns', '_getDefaultColumnDef')),
|
2875
|
-
_getColumnDefs: () => table.options.columns,
|
2876
|
-
getAllColumns: memo(() => [table._getColumnDefs()], columnDefs => {
|
2877
|
-
const recurseColumns = function (columnDefs, parent, depth) {
|
2878
|
-
if (depth === void 0) {
|
2879
|
-
depth = 0;
|
2880
|
-
}
|
2881
|
-
return columnDefs.map(columnDef => {
|
2882
|
-
const column = createColumn(table, columnDef, depth, parent);
|
2883
|
-
const groupingColumnDef = columnDef;
|
2884
|
-
column.columns = groupingColumnDef.columns ? recurseColumns(groupingColumnDef.columns, column, depth + 1) : [];
|
2885
|
-
return column;
|
2886
|
-
});
|
2887
|
-
};
|
2888
|
-
return recurseColumns(columnDefs);
|
2889
|
-
}, getMemoOptions(options, 'debugColumns', 'getAllColumns')),
|
2890
|
-
getAllFlatColumns: memo(() => [table.getAllColumns()], allColumns => {
|
2891
|
-
return allColumns.flatMap(column => {
|
2892
|
-
return column.getFlatColumns();
|
2893
|
-
});
|
2894
|
-
}, getMemoOptions(options, 'debugColumns', 'getAllFlatColumns')),
|
2895
|
-
_getAllFlatColumnsById: memo(() => [table.getAllFlatColumns()], flatColumns => {
|
2896
|
-
return flatColumns.reduce((acc, column) => {
|
2897
|
-
acc[column.id] = column;
|
2898
|
-
return acc;
|
2899
|
-
}, {});
|
2900
|
-
}, getMemoOptions(options, 'debugColumns', 'getAllFlatColumnsById')),
|
2901
|
-
getAllLeafColumns: memo(() => [table.getAllColumns(), table._getOrderColumnsFn()], (allColumns, orderColumns) => {
|
2902
|
-
let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
|
2903
|
-
return orderColumns(leafColumns);
|
2904
|
-
}, getMemoOptions(options, 'debugColumns', 'getAllLeafColumns')),
|
2905
|
-
getColumn: columnId => {
|
2906
|
-
const column = table._getAllFlatColumnsById()[columnId];
|
2907
|
-
if (process.env.NODE_ENV !== 'production' && !column) {
|
2908
|
-
console.error(`[Table] Column with id '${columnId}' does not exist.`);
|
2909
|
-
}
|
2910
|
-
return column;
|
2911
|
-
}
|
2912
|
-
};
|
2913
|
-
Object.assign(table, coreInstance);
|
2914
|
-
for (let index = 0; index < table._features.length; index++) {
|
2915
|
-
const feature = table._features[index];
|
2916
|
-
feature == null || feature.createTable == null || feature.createTable(table);
|
2917
|
-
}
|
2918
|
-
return table;
|
2919
|
-
}
|
2920
|
-
|
2921
|
-
function getCoreRowModel() {
|
2922
|
-
return table => memo(() => [table.options.data], data => {
|
2923
|
-
const rowModel = {
|
2924
|
-
rows: [],
|
2925
|
-
flatRows: [],
|
2926
|
-
rowsById: {}
|
2927
|
-
};
|
2928
|
-
const accessRows = function (originalRows, depth, parentRow) {
|
2929
|
-
if (depth === void 0) {
|
2930
|
-
depth = 0;
|
2931
|
-
}
|
2932
|
-
const rows = [];
|
2933
|
-
for (let i = 0; i < originalRows.length; i++) {
|
2934
|
-
// This could be an expensive check at scale, so we should move it somewhere else, but where?
|
2935
|
-
// if (!id) {
|
2936
|
-
// if (process.env.NODE_ENV !== 'production') {
|
2937
|
-
// throw new Error(`getRowId expected an ID, but got ${id}`)
|
2938
|
-
// }
|
2939
|
-
// }
|
2940
|
-
|
2941
|
-
// Make the row
|
2942
|
-
const row = createRow(table, table._getRowId(originalRows[i], i, parentRow), originalRows[i], i, depth, undefined, parentRow == null ? void 0 : parentRow.id);
|
2943
|
-
|
2944
|
-
// Keep track of every row in a flat array
|
2945
|
-
rowModel.flatRows.push(row);
|
2946
|
-
// Also keep track of every row by its ID
|
2947
|
-
rowModel.rowsById[row.id] = row;
|
2948
|
-
// Push table row into parent
|
2949
|
-
rows.push(row);
|
2950
|
-
|
2951
|
-
// Get the original subrows
|
2952
|
-
if (table.options.getSubRows) {
|
2953
|
-
var _row$originalSubRows;
|
2954
|
-
row.originalSubRows = table.options.getSubRows(originalRows[i], i);
|
2955
|
-
|
2956
|
-
// Then recursively access them
|
2957
|
-
if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
|
2958
|
-
row.subRows = accessRows(row.originalSubRows, depth + 1, row);
|
2959
|
-
}
|
2960
|
-
}
|
2961
|
-
}
|
2962
|
-
return rows;
|
2963
|
-
};
|
2964
|
-
rowModel.rows = accessRows(data);
|
2965
|
-
return rowModel;
|
2966
|
-
}, getMemoOptions(table.options, 'debugTable', 'getRowModel', () => table._autoResetPageIndex()));
|
2967
|
-
}
|
2968
|
-
|
2969
|
-
export { ColumnFaceting, ColumnFiltering, ColumnGrouping, ColumnOrdering, ColumnPinning, ColumnSizing, ColumnVisibility, GlobalFaceting, GlobalFiltering, Headers, RowExpanding, RowPagination, RowPinning, RowSelection, RowSorting, _getVisibleLeafColumns, aggregationFns, buildHeaderGroups, createCell, createColumn, createColumnHelper, createRow, createTable, defaultColumnSizing, filterFns, flattenBy, functionalUpdate, getCoreRowModel, getMemoOptions, isFunction, isNumberArray, isRowSelected, isSubRowSelected, makeStateUpdater, memo, orderColumns, passiveEventSupported, reSplitAlphaNumeric, selectRowsFn, shouldAutoRemoveFilter, sortingFns };
|
2970
|
-
//# sourceMappingURL=index.js.map
|