@osdk/react-components 0.1.0-beta.2 → 0.1.0-beta.3
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/CHANGELOG.md +18 -0
- package/README.md +51 -1
- package/build/browser/base-components/checkbox/Checkbox.js +40 -0
- package/build/browser/base-components/checkbox/Checkbox.js.map +1 -0
- package/build/browser/base-components/checkbox/Checkbox.module.css +71 -0
- package/build/browser/css-modules.d.ts +20 -0
- package/build/browser/object-table/SelectionCells.js +11 -33
- package/build/browser/object-table/SelectionCells.js.map +1 -1
- package/build/browser/object-table/TableCell.js.map +1 -1
- package/build/browser/object-table/TableHeader.js.map +1 -1
- package/build/cjs/public/experimental.cjs +100 -3663
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.css +48 -0
- package/build/cjs/public/experimental.css.map +1 -0
- package/build/esm/base-components/checkbox/Checkbox.js +40 -0
- package/build/esm/base-components/checkbox/Checkbox.js.map +1 -0
- package/build/esm/base-components/checkbox/Checkbox.module.css +71 -0
- package/build/esm/css-modules.d.ts +20 -0
- package/build/esm/object-table/SelectionCells.js +11 -33
- package/build/esm/object-table/SelectionCells.js.map +1 -1
- package/build/esm/object-table/TableCell.js.map +1 -1
- package/build/esm/object-table/TableHeader.js.map +1 -1
- package/build/types/base-components/checkbox/Checkbox.d.ts +10 -0
- package/build/types/base-components/checkbox/Checkbox.d.ts.map +1 -0
- package/build/types/css-modules.d.d.ts +6 -0
- package/build/types/css-modules.d.d.ts.map +1 -0
- package/build/types/object-table/SelectionCells.d.ts.map +1 -1
- package/build/types/object-table/TableCell.d.ts.map +1 -1
- package/build/types/object-table/TableHeader.d.ts.map +1 -1
- package/package.json +11 -6
|
@@ -1,2706 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var reactTable = require('@tanstack/react-table');
|
|
4
|
+
var React = require('react');
|
|
4
5
|
var react = require('@osdk/react');
|
|
5
6
|
var experimental = require('@osdk/react/experimental');
|
|
7
|
+
var checkbox = require('@base-ui/react/checkbox');
|
|
8
|
+
var icons = require('@blueprintjs/icons');
|
|
9
|
+
var classnames = require('classnames');
|
|
10
|
+
var reactVirtual = require('@tanstack/react-virtual');
|
|
6
11
|
var reactDom = require('react-dom');
|
|
7
12
|
|
|
8
|
-
function
|
|
9
|
-
if (e && e.__esModule) return e;
|
|
10
|
-
var n = Object.create(null);
|
|
11
|
-
if (e) {
|
|
12
|
-
Object.keys(e).forEach(function (k) {
|
|
13
|
-
if (k !== 'default') {
|
|
14
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () { return e[k]; }
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
n.default = e;
|
|
23
|
-
return Object.freeze(n);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
|
|
27
|
-
|
|
28
|
-
// ../../node_modules/.pnpm/@tanstack+react-table@8.21.3_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@tanstack/react-table/build/lib/index.mjs
|
|
29
|
-
|
|
30
|
-
// ../../node_modules/.pnpm/@tanstack+table-core@8.21.3/node_modules/@tanstack/table-core/build/lib/index.mjs
|
|
31
|
-
function functionalUpdate(updater, input) {
|
|
32
|
-
return typeof updater === "function" ? updater(input) : updater;
|
|
33
|
-
}
|
|
34
|
-
function makeStateUpdater(key, instance) {
|
|
35
|
-
return (updater) => {
|
|
36
|
-
instance.setState((old) => {
|
|
37
|
-
return {
|
|
38
|
-
...old,
|
|
39
|
-
[key]: functionalUpdate(updater, old[key])
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function isFunction(d) {
|
|
45
|
-
return d instanceof Function;
|
|
46
|
-
}
|
|
47
|
-
function isNumberArray(d) {
|
|
48
|
-
return Array.isArray(d) && d.every((val) => typeof val === "number");
|
|
49
|
-
}
|
|
50
|
-
function flattenBy(arr, getChildren) {
|
|
51
|
-
const flat = [];
|
|
52
|
-
const recurse = (subArr) => {
|
|
53
|
-
subArr.forEach((item) => {
|
|
54
|
-
flat.push(item);
|
|
55
|
-
const children = getChildren(item);
|
|
56
|
-
if (children != null && children.length) {
|
|
57
|
-
recurse(children);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
recurse(arr);
|
|
62
|
-
return flat;
|
|
63
|
-
}
|
|
64
|
-
function memo(getDeps, fn, opts) {
|
|
65
|
-
let deps = [];
|
|
66
|
-
let result;
|
|
67
|
-
return (depArgs) => {
|
|
68
|
-
let depTime;
|
|
69
|
-
if (opts.key && opts.debug) depTime = Date.now();
|
|
70
|
-
const newDeps = getDeps(depArgs);
|
|
71
|
-
const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
|
|
72
|
-
if (!depsChanged) {
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
75
|
-
deps = newDeps;
|
|
76
|
-
let resultTime;
|
|
77
|
-
if (opts.key && opts.debug) resultTime = Date.now();
|
|
78
|
-
result = fn(...newDeps);
|
|
79
|
-
opts == null || opts.onChange == null || opts.onChange(result);
|
|
80
|
-
if (opts.key && opts.debug) {
|
|
81
|
-
if (opts != null && opts.debug()) {
|
|
82
|
-
const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
|
|
83
|
-
const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
|
|
84
|
-
const resultFpsPercentage = resultEndTime / 16;
|
|
85
|
-
const pad = (str, num) => {
|
|
86
|
-
str = String(str);
|
|
87
|
-
while (str.length < num) {
|
|
88
|
-
str = " " + str;
|
|
89
|
-
}
|
|
90
|
-
return str;
|
|
91
|
-
};
|
|
92
|
-
console.info(`%c\u23F1 ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`, `
|
|
93
|
-
font-size: .6rem;
|
|
94
|
-
font-weight: bold;
|
|
95
|
-
color: hsl(${Math.max(0, Math.min(120 - 120 * resultFpsPercentage, 120))}deg 100% 31%);`, opts == null ? void 0 : opts.key);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return result;
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
function getMemoOptions(tableOptions, debugLevel, key, onChange) {
|
|
102
|
-
return {
|
|
103
|
-
debug: () => {
|
|
104
|
-
var _tableOptions$debugAl;
|
|
105
|
-
return (_tableOptions$debugAl = tableOptions == null ? void 0 : tableOptions.debugAll) != null ? _tableOptions$debugAl : tableOptions[debugLevel];
|
|
106
|
-
},
|
|
107
|
-
key: process.env.NODE_ENV === "development" && key,
|
|
108
|
-
onChange
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
function createCell(table, row, column, columnId) {
|
|
112
|
-
const getRenderValue = () => {
|
|
113
|
-
var _cell$getValue;
|
|
114
|
-
return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : table.options.renderFallbackValue;
|
|
115
|
-
};
|
|
116
|
-
const cell = {
|
|
117
|
-
id: `${row.id}_${column.id}`,
|
|
118
|
-
row,
|
|
119
|
-
column,
|
|
120
|
-
getValue: () => row.getValue(columnId),
|
|
121
|
-
renderValue: getRenderValue,
|
|
122
|
-
getContext: memo(() => [table, column, row, cell], (table2, column2, row2, cell2) => ({
|
|
123
|
-
table: table2,
|
|
124
|
-
column: column2,
|
|
125
|
-
row: row2,
|
|
126
|
-
cell: cell2,
|
|
127
|
-
getValue: cell2.getValue,
|
|
128
|
-
renderValue: cell2.renderValue
|
|
129
|
-
}), getMemoOptions(table.options, "debugCells", "cell.getContext"))
|
|
130
|
-
};
|
|
131
|
-
table._features.forEach((feature) => {
|
|
132
|
-
feature.createCell == null || feature.createCell(cell, column, row, table);
|
|
133
|
-
}, {});
|
|
134
|
-
return cell;
|
|
135
|
-
}
|
|
136
|
-
function createColumn(table, columnDef, depth, parent) {
|
|
137
|
-
var _ref, _resolvedColumnDef$id;
|
|
138
|
-
const defaultColumn = table._getDefaultColumnDef();
|
|
139
|
-
const resolvedColumnDef = {
|
|
140
|
-
...defaultColumn,
|
|
141
|
-
...columnDef
|
|
142
|
-
};
|
|
143
|
-
const accessorKey = resolvedColumnDef.accessorKey;
|
|
144
|
-
let id = (_ref = (_resolvedColumnDef$id = resolvedColumnDef.id) != null ? _resolvedColumnDef$id : accessorKey ? typeof String.prototype.replaceAll === "function" ? accessorKey.replaceAll(".", "_") : accessorKey.replace(/\./g, "_") : void 0) != null ? _ref : typeof resolvedColumnDef.header === "string" ? resolvedColumnDef.header : void 0;
|
|
145
|
-
let accessorFn;
|
|
146
|
-
if (resolvedColumnDef.accessorFn) {
|
|
147
|
-
accessorFn = resolvedColumnDef.accessorFn;
|
|
148
|
-
} else if (accessorKey) {
|
|
149
|
-
if (accessorKey.includes(".")) {
|
|
150
|
-
accessorFn = (originalRow) => {
|
|
151
|
-
let result = originalRow;
|
|
152
|
-
for (const key of accessorKey.split(".")) {
|
|
153
|
-
var _result;
|
|
154
|
-
result = (_result = result) == null ? void 0 : _result[key];
|
|
155
|
-
if (process.env.NODE_ENV !== "production" && result === void 0) {
|
|
156
|
-
console.warn(`"${key}" in deeply nested key "${accessorKey}" returned undefined.`);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return result;
|
|
160
|
-
};
|
|
161
|
-
} else {
|
|
162
|
-
accessorFn = (originalRow) => originalRow[resolvedColumnDef.accessorKey];
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
if (!id) {
|
|
166
|
-
if (process.env.NODE_ENV !== "production") {
|
|
167
|
-
throw new Error(resolvedColumnDef.accessorFn ? `Columns require an id when using an accessorFn` : `Columns require an id when using a non-string header`);
|
|
168
|
-
}
|
|
169
|
-
throw new Error();
|
|
170
|
-
}
|
|
171
|
-
let column = {
|
|
172
|
-
id: `${String(id)}`,
|
|
173
|
-
accessorFn,
|
|
174
|
-
parent,
|
|
175
|
-
depth,
|
|
176
|
-
columnDef: resolvedColumnDef,
|
|
177
|
-
columns: [],
|
|
178
|
-
getFlatColumns: memo(() => [true], () => {
|
|
179
|
-
var _column$columns;
|
|
180
|
-
return [column, ...(_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap((d) => d.getFlatColumns())];
|
|
181
|
-
}, getMemoOptions(table.options, "debugColumns", "column.getFlatColumns")),
|
|
182
|
-
getLeafColumns: memo(() => [table._getOrderColumnsFn()], (orderColumns2) => {
|
|
183
|
-
var _column$columns2;
|
|
184
|
-
if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
|
|
185
|
-
let leafColumns = column.columns.flatMap((column2) => column2.getLeafColumns());
|
|
186
|
-
return orderColumns2(leafColumns);
|
|
187
|
-
}
|
|
188
|
-
return [column];
|
|
189
|
-
}, getMemoOptions(table.options, "debugColumns", "column.getLeafColumns"))
|
|
190
|
-
};
|
|
191
|
-
for (const feature of table._features) {
|
|
192
|
-
feature.createColumn == null || feature.createColumn(column, table);
|
|
193
|
-
}
|
|
194
|
-
return column;
|
|
195
|
-
}
|
|
196
|
-
var debug = "debugHeaders";
|
|
197
|
-
function createHeader(table, column, options) {
|
|
198
|
-
var _options$id;
|
|
199
|
-
const id = (_options$id = options.id) != null ? _options$id : column.id;
|
|
200
|
-
let header = {
|
|
201
|
-
id,
|
|
202
|
-
column,
|
|
203
|
-
index: options.index,
|
|
204
|
-
isPlaceholder: !!options.isPlaceholder,
|
|
205
|
-
placeholderId: options.placeholderId,
|
|
206
|
-
depth: options.depth,
|
|
207
|
-
subHeaders: [],
|
|
208
|
-
colSpan: 0,
|
|
209
|
-
rowSpan: 0,
|
|
210
|
-
headerGroup: null,
|
|
211
|
-
getLeafHeaders: () => {
|
|
212
|
-
const leafHeaders = [];
|
|
213
|
-
const recurseHeader = (h) => {
|
|
214
|
-
if (h.subHeaders && h.subHeaders.length) {
|
|
215
|
-
h.subHeaders.map(recurseHeader);
|
|
216
|
-
}
|
|
217
|
-
leafHeaders.push(h);
|
|
218
|
-
};
|
|
219
|
-
recurseHeader(header);
|
|
220
|
-
return leafHeaders;
|
|
221
|
-
},
|
|
222
|
-
getContext: () => ({
|
|
223
|
-
table,
|
|
224
|
-
header,
|
|
225
|
-
column
|
|
226
|
-
})
|
|
227
|
-
};
|
|
228
|
-
table._features.forEach((feature) => {
|
|
229
|
-
feature.createHeader == null || feature.createHeader(header, table);
|
|
230
|
-
});
|
|
231
|
-
return header;
|
|
232
|
-
}
|
|
233
|
-
var Headers = {
|
|
234
|
-
createTable: (table) => {
|
|
235
|
-
table.getHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
236
|
-
var _left$map$filter, _right$map$filter;
|
|
237
|
-
const leftColumns = (_left$map$filter = left == null ? void 0 : left.map((columnId) => leafColumns.find((d) => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
|
|
238
|
-
const rightColumns = (_right$map$filter = right == null ? void 0 : right.map((columnId) => leafColumns.find((d) => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
|
|
239
|
-
const centerColumns = leafColumns.filter((column) => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
240
|
-
const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], table);
|
|
241
|
-
return headerGroups;
|
|
242
|
-
}, getMemoOptions(table.options, debug, "getHeaderGroups"));
|
|
243
|
-
table.getCenterHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
244
|
-
leafColumns = leafColumns.filter((column) => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
245
|
-
return buildHeaderGroups(allColumns, leafColumns, table, "center");
|
|
246
|
-
}, getMemoOptions(table.options, debug, "getCenterHeaderGroups"));
|
|
247
|
-
table.getLeftHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
248
|
-
var _left$map$filter2;
|
|
249
|
-
const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map((columnId) => leafColumns.find((d) => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
|
|
250
|
-
return buildHeaderGroups(allColumns, orderedLeafColumns, table, "left");
|
|
251
|
-
}, getMemoOptions(table.options, debug, "getLeftHeaderGroups"));
|
|
252
|
-
table.getRightHeaderGroups = memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
253
|
-
var _right$map$filter2;
|
|
254
|
-
const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map((columnId) => leafColumns.find((d) => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
|
|
255
|
-
return buildHeaderGroups(allColumns, orderedLeafColumns, table, "right");
|
|
256
|
-
}, getMemoOptions(table.options, debug, "getRightHeaderGroups"));
|
|
257
|
-
table.getFooterGroups = memo(() => [table.getHeaderGroups()], (headerGroups) => {
|
|
258
|
-
return [...headerGroups].reverse();
|
|
259
|
-
}, getMemoOptions(table.options, debug, "getFooterGroups"));
|
|
260
|
-
table.getLeftFooterGroups = memo(() => [table.getLeftHeaderGroups()], (headerGroups) => {
|
|
261
|
-
return [...headerGroups].reverse();
|
|
262
|
-
}, getMemoOptions(table.options, debug, "getLeftFooterGroups"));
|
|
263
|
-
table.getCenterFooterGroups = memo(() => [table.getCenterHeaderGroups()], (headerGroups) => {
|
|
264
|
-
return [...headerGroups].reverse();
|
|
265
|
-
}, getMemoOptions(table.options, debug, "getCenterFooterGroups"));
|
|
266
|
-
table.getRightFooterGroups = memo(() => [table.getRightHeaderGroups()], (headerGroups) => {
|
|
267
|
-
return [...headerGroups].reverse();
|
|
268
|
-
}, getMemoOptions(table.options, debug, "getRightFooterGroups"));
|
|
269
|
-
table.getFlatHeaders = memo(() => [table.getHeaderGroups()], (headerGroups) => {
|
|
270
|
-
return headerGroups.map((headerGroup) => {
|
|
271
|
-
return headerGroup.headers;
|
|
272
|
-
}).flat();
|
|
273
|
-
}, getMemoOptions(table.options, debug, "getFlatHeaders"));
|
|
274
|
-
table.getLeftFlatHeaders = memo(() => [table.getLeftHeaderGroups()], (left) => {
|
|
275
|
-
return left.map((headerGroup) => {
|
|
276
|
-
return headerGroup.headers;
|
|
277
|
-
}).flat();
|
|
278
|
-
}, getMemoOptions(table.options, debug, "getLeftFlatHeaders"));
|
|
279
|
-
table.getCenterFlatHeaders = memo(() => [table.getCenterHeaderGroups()], (left) => {
|
|
280
|
-
return left.map((headerGroup) => {
|
|
281
|
-
return headerGroup.headers;
|
|
282
|
-
}).flat();
|
|
283
|
-
}, getMemoOptions(table.options, debug, "getCenterFlatHeaders"));
|
|
284
|
-
table.getRightFlatHeaders = memo(() => [table.getRightHeaderGroups()], (left) => {
|
|
285
|
-
return left.map((headerGroup) => {
|
|
286
|
-
return headerGroup.headers;
|
|
287
|
-
}).flat();
|
|
288
|
-
}, getMemoOptions(table.options, debug, "getRightFlatHeaders"));
|
|
289
|
-
table.getCenterLeafHeaders = memo(() => [table.getCenterFlatHeaders()], (flatHeaders) => {
|
|
290
|
-
return flatHeaders.filter((header) => {
|
|
291
|
-
var _header$subHeaders;
|
|
292
|
-
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
|
293
|
-
});
|
|
294
|
-
}, getMemoOptions(table.options, debug, "getCenterLeafHeaders"));
|
|
295
|
-
table.getLeftLeafHeaders = memo(() => [table.getLeftFlatHeaders()], (flatHeaders) => {
|
|
296
|
-
return flatHeaders.filter((header) => {
|
|
297
|
-
var _header$subHeaders2;
|
|
298
|
-
return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
|
|
299
|
-
});
|
|
300
|
-
}, getMemoOptions(table.options, debug, "getLeftLeafHeaders"));
|
|
301
|
-
table.getRightLeafHeaders = memo(() => [table.getRightFlatHeaders()], (flatHeaders) => {
|
|
302
|
-
return flatHeaders.filter((header) => {
|
|
303
|
-
var _header$subHeaders3;
|
|
304
|
-
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
|
305
|
-
});
|
|
306
|
-
}, getMemoOptions(table.options, debug, "getRightLeafHeaders"));
|
|
307
|
-
table.getLeafHeaders = memo(() => [table.getLeftHeaderGroups(), table.getCenterHeaderGroups(), table.getRightHeaderGroups()], (left, center, right) => {
|
|
308
|
-
var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
|
|
309
|
-
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) => {
|
|
310
|
-
return header.getLeafHeaders();
|
|
311
|
-
}).flat();
|
|
312
|
-
}, getMemoOptions(table.options, debug, "getLeafHeaders"));
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
function buildHeaderGroups(allColumns, columnsToGroup, table, headerFamily) {
|
|
316
|
-
var _headerGroups$0$heade, _headerGroups$;
|
|
317
|
-
let maxDepth = 0;
|
|
318
|
-
const findMaxDepth = function(columns, depth) {
|
|
319
|
-
if (depth === void 0) {
|
|
320
|
-
depth = 1;
|
|
321
|
-
}
|
|
322
|
-
maxDepth = Math.max(maxDepth, depth);
|
|
323
|
-
columns.filter((column) => column.getIsVisible()).forEach((column) => {
|
|
324
|
-
var _column$columns;
|
|
325
|
-
if ((_column$columns = column.columns) != null && _column$columns.length) {
|
|
326
|
-
findMaxDepth(column.columns, depth + 1);
|
|
327
|
-
}
|
|
328
|
-
}, 0);
|
|
329
|
-
};
|
|
330
|
-
findMaxDepth(allColumns);
|
|
331
|
-
let headerGroups = [];
|
|
332
|
-
const createHeaderGroup = (headersToGroup, depth) => {
|
|
333
|
-
const headerGroup = {
|
|
334
|
-
depth,
|
|
335
|
-
id: [headerFamily, `${depth}`].filter(Boolean).join("_"),
|
|
336
|
-
headers: []
|
|
337
|
-
};
|
|
338
|
-
const pendingParentHeaders = [];
|
|
339
|
-
headersToGroup.forEach((headerToGroup) => {
|
|
340
|
-
const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
|
|
341
|
-
const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
|
|
342
|
-
let column;
|
|
343
|
-
let isPlaceholder = false;
|
|
344
|
-
if (isLeafHeader && headerToGroup.column.parent) {
|
|
345
|
-
column = headerToGroup.column.parent;
|
|
346
|
-
} else {
|
|
347
|
-
column = headerToGroup.column;
|
|
348
|
-
isPlaceholder = true;
|
|
349
|
-
}
|
|
350
|
-
if (latestPendingParentHeader && (latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
|
|
351
|
-
latestPendingParentHeader.subHeaders.push(headerToGroup);
|
|
352
|
-
} else {
|
|
353
|
-
const header = createHeader(table, column, {
|
|
354
|
-
id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join("_"),
|
|
355
|
-
isPlaceholder,
|
|
356
|
-
placeholderId: isPlaceholder ? `${pendingParentHeaders.filter((d) => d.column === column).length}` : void 0,
|
|
357
|
-
depth,
|
|
358
|
-
index: pendingParentHeaders.length
|
|
359
|
-
});
|
|
360
|
-
header.subHeaders.push(headerToGroup);
|
|
361
|
-
pendingParentHeaders.push(header);
|
|
362
|
-
}
|
|
363
|
-
headerGroup.headers.push(headerToGroup);
|
|
364
|
-
headerToGroup.headerGroup = headerGroup;
|
|
365
|
-
});
|
|
366
|
-
headerGroups.push(headerGroup);
|
|
367
|
-
if (depth > 0) {
|
|
368
|
-
createHeaderGroup(pendingParentHeaders, depth - 1);
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
const bottomHeaders = columnsToGroup.map((column, index) => createHeader(table, column, {
|
|
372
|
-
depth: maxDepth,
|
|
373
|
-
index
|
|
374
|
-
}));
|
|
375
|
-
createHeaderGroup(bottomHeaders, maxDepth - 1);
|
|
376
|
-
headerGroups.reverse();
|
|
377
|
-
const recurseHeadersForSpans = (headers) => {
|
|
378
|
-
const filteredHeaders = headers.filter((header) => header.column.getIsVisible());
|
|
379
|
-
return filteredHeaders.map((header) => {
|
|
380
|
-
let colSpan = 0;
|
|
381
|
-
let rowSpan = 0;
|
|
382
|
-
let childRowSpans = [0];
|
|
383
|
-
if (header.subHeaders && header.subHeaders.length) {
|
|
384
|
-
childRowSpans = [];
|
|
385
|
-
recurseHeadersForSpans(header.subHeaders).forEach((_ref) => {
|
|
386
|
-
let {
|
|
387
|
-
colSpan: childColSpan,
|
|
388
|
-
rowSpan: childRowSpan
|
|
389
|
-
} = _ref;
|
|
390
|
-
colSpan += childColSpan;
|
|
391
|
-
childRowSpans.push(childRowSpan);
|
|
392
|
-
});
|
|
393
|
-
} else {
|
|
394
|
-
colSpan = 1;
|
|
395
|
-
}
|
|
396
|
-
const minChildRowSpan = Math.min(...childRowSpans);
|
|
397
|
-
rowSpan = rowSpan + minChildRowSpan;
|
|
398
|
-
header.colSpan = colSpan;
|
|
399
|
-
header.rowSpan = rowSpan;
|
|
400
|
-
return {
|
|
401
|
-
colSpan,
|
|
402
|
-
rowSpan
|
|
403
|
-
};
|
|
404
|
-
});
|
|
405
|
-
};
|
|
406
|
-
recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
|
|
407
|
-
return headerGroups;
|
|
408
|
-
}
|
|
409
|
-
var createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
|
410
|
-
let row = {
|
|
411
|
-
id,
|
|
412
|
-
index: rowIndex,
|
|
413
|
-
original,
|
|
414
|
-
depth,
|
|
415
|
-
parentId,
|
|
416
|
-
_valuesCache: {},
|
|
417
|
-
_uniqueValuesCache: {},
|
|
418
|
-
getValue: (columnId) => {
|
|
419
|
-
if (row._valuesCache.hasOwnProperty(columnId)) {
|
|
420
|
-
return row._valuesCache[columnId];
|
|
421
|
-
}
|
|
422
|
-
const column = table.getColumn(columnId);
|
|
423
|
-
if (!(column != null && column.accessorFn)) {
|
|
424
|
-
return void 0;
|
|
425
|
-
}
|
|
426
|
-
row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
|
427
|
-
return row._valuesCache[columnId];
|
|
428
|
-
},
|
|
429
|
-
getUniqueValues: (columnId) => {
|
|
430
|
-
if (row._uniqueValuesCache.hasOwnProperty(columnId)) {
|
|
431
|
-
return row._uniqueValuesCache[columnId];
|
|
432
|
-
}
|
|
433
|
-
const column = table.getColumn(columnId);
|
|
434
|
-
if (!(column != null && column.accessorFn)) {
|
|
435
|
-
return void 0;
|
|
436
|
-
}
|
|
437
|
-
if (!column.columnDef.getUniqueValues) {
|
|
438
|
-
row._uniqueValuesCache[columnId] = [row.getValue(columnId)];
|
|
439
|
-
return row._uniqueValuesCache[columnId];
|
|
440
|
-
}
|
|
441
|
-
row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(row.original, rowIndex);
|
|
442
|
-
return row._uniqueValuesCache[columnId];
|
|
443
|
-
},
|
|
444
|
-
renderValue: (columnId) => {
|
|
445
|
-
var _row$getValue;
|
|
446
|
-
return (_row$getValue = row.getValue(columnId)) != null ? _row$getValue : table.options.renderFallbackValue;
|
|
447
|
-
},
|
|
448
|
-
subRows: [],
|
|
449
|
-
getLeafRows: () => flattenBy(row.subRows, (d) => d.subRows),
|
|
450
|
-
getParentRow: () => row.parentId ? table.getRow(row.parentId, true) : void 0,
|
|
451
|
-
getParentRows: () => {
|
|
452
|
-
let parentRows = [];
|
|
453
|
-
let currentRow = row;
|
|
454
|
-
while (true) {
|
|
455
|
-
const parentRow = currentRow.getParentRow();
|
|
456
|
-
if (!parentRow) break;
|
|
457
|
-
parentRows.push(parentRow);
|
|
458
|
-
currentRow = parentRow;
|
|
459
|
-
}
|
|
460
|
-
return parentRows.reverse();
|
|
461
|
-
},
|
|
462
|
-
getAllCells: memo(() => [table.getAllLeafColumns()], (leafColumns) => {
|
|
463
|
-
return leafColumns.map((column) => {
|
|
464
|
-
return createCell(table, row, column, column.id);
|
|
465
|
-
});
|
|
466
|
-
}, getMemoOptions(table.options, "debugRows", "getAllCells")),
|
|
467
|
-
_getAllCellsByColumnId: memo(() => [row.getAllCells()], (allCells) => {
|
|
468
|
-
return allCells.reduce((acc, cell) => {
|
|
469
|
-
acc[cell.column.id] = cell;
|
|
470
|
-
return acc;
|
|
471
|
-
}, {});
|
|
472
|
-
}, getMemoOptions(table.options, "debugRows", "getAllCellsByColumnId"))
|
|
473
|
-
};
|
|
474
|
-
for (let i = 0; i < table._features.length; i++) {
|
|
475
|
-
const feature = table._features[i];
|
|
476
|
-
feature == null || feature.createRow == null || feature.createRow(row, table);
|
|
477
|
-
}
|
|
478
|
-
return row;
|
|
479
|
-
};
|
|
480
|
-
var ColumnFaceting = {
|
|
481
|
-
createColumn: (column, table) => {
|
|
482
|
-
column._getFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, column.id);
|
|
483
|
-
column.getFacetedRowModel = () => {
|
|
484
|
-
if (!column._getFacetedRowModel) {
|
|
485
|
-
return table.getPreFilteredRowModel();
|
|
486
|
-
}
|
|
487
|
-
return column._getFacetedRowModel();
|
|
488
|
-
};
|
|
489
|
-
column._getFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, column.id);
|
|
490
|
-
column.getFacetedUniqueValues = () => {
|
|
491
|
-
if (!column._getFacetedUniqueValues) {
|
|
492
|
-
return /* @__PURE__ */ new Map();
|
|
493
|
-
}
|
|
494
|
-
return column._getFacetedUniqueValues();
|
|
495
|
-
};
|
|
496
|
-
column._getFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, column.id);
|
|
497
|
-
column.getFacetedMinMaxValues = () => {
|
|
498
|
-
if (!column._getFacetedMinMaxValues) {
|
|
499
|
-
return void 0;
|
|
500
|
-
}
|
|
501
|
-
return column._getFacetedMinMaxValues();
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
var includesString = (row, columnId, filterValue) => {
|
|
506
|
-
var _filterValue$toString, _row$getValue;
|
|
507
|
-
const search = filterValue == null || (_filterValue$toString = filterValue.toString()) == null ? void 0 : _filterValue$toString.toLowerCase();
|
|
508
|
-
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));
|
|
509
|
-
};
|
|
510
|
-
includesString.autoRemove = (val) => testFalsey(val);
|
|
511
|
-
var includesStringSensitive = (row, columnId, filterValue) => {
|
|
512
|
-
var _row$getValue2;
|
|
513
|
-
return Boolean((_row$getValue2 = row.getValue(columnId)) == null || (_row$getValue2 = _row$getValue2.toString()) == null ? void 0 : _row$getValue2.includes(filterValue));
|
|
514
|
-
};
|
|
515
|
-
includesStringSensitive.autoRemove = (val) => testFalsey(val);
|
|
516
|
-
var equalsString = (row, columnId, filterValue) => {
|
|
517
|
-
var _row$getValue3;
|
|
518
|
-
return ((_row$getValue3 = row.getValue(columnId)) == null || (_row$getValue3 = _row$getValue3.toString()) == null ? void 0 : _row$getValue3.toLowerCase()) === (filterValue == null ? void 0 : filterValue.toLowerCase());
|
|
519
|
-
};
|
|
520
|
-
equalsString.autoRemove = (val) => testFalsey(val);
|
|
521
|
-
var arrIncludes = (row, columnId, filterValue) => {
|
|
522
|
-
var _row$getValue4;
|
|
523
|
-
return (_row$getValue4 = row.getValue(columnId)) == null ? void 0 : _row$getValue4.includes(filterValue);
|
|
524
|
-
};
|
|
525
|
-
arrIncludes.autoRemove = (val) => testFalsey(val);
|
|
526
|
-
var arrIncludesAll = (row, columnId, filterValue) => {
|
|
527
|
-
return !filterValue.some((val) => {
|
|
528
|
-
var _row$getValue5;
|
|
529
|
-
return !((_row$getValue5 = row.getValue(columnId)) != null && _row$getValue5.includes(val));
|
|
530
|
-
});
|
|
531
|
-
};
|
|
532
|
-
arrIncludesAll.autoRemove = (val) => testFalsey(val) || !(val != null && val.length);
|
|
533
|
-
var arrIncludesSome = (row, columnId, filterValue) => {
|
|
534
|
-
return filterValue.some((val) => {
|
|
535
|
-
var _row$getValue6;
|
|
536
|
-
return (_row$getValue6 = row.getValue(columnId)) == null ? void 0 : _row$getValue6.includes(val);
|
|
537
|
-
});
|
|
538
|
-
};
|
|
539
|
-
arrIncludesSome.autoRemove = (val) => testFalsey(val) || !(val != null && val.length);
|
|
540
|
-
var equals = (row, columnId, filterValue) => {
|
|
541
|
-
return row.getValue(columnId) === filterValue;
|
|
542
|
-
};
|
|
543
|
-
equals.autoRemove = (val) => testFalsey(val);
|
|
544
|
-
var weakEquals = (row, columnId, filterValue) => {
|
|
545
|
-
return row.getValue(columnId) == filterValue;
|
|
546
|
-
};
|
|
547
|
-
weakEquals.autoRemove = (val) => testFalsey(val);
|
|
548
|
-
var inNumberRange = (row, columnId, filterValue) => {
|
|
549
|
-
let [min2, max2] = filterValue;
|
|
550
|
-
const rowValue = row.getValue(columnId);
|
|
551
|
-
return rowValue >= min2 && rowValue <= max2;
|
|
552
|
-
};
|
|
553
|
-
inNumberRange.resolveFilterValue = (val) => {
|
|
554
|
-
let [unsafeMin, unsafeMax] = val;
|
|
555
|
-
let parsedMin = typeof unsafeMin !== "number" ? parseFloat(unsafeMin) : unsafeMin;
|
|
556
|
-
let parsedMax = typeof unsafeMax !== "number" ? parseFloat(unsafeMax) : unsafeMax;
|
|
557
|
-
let min2 = unsafeMin === null || Number.isNaN(parsedMin) ? -Infinity : parsedMin;
|
|
558
|
-
let max2 = unsafeMax === null || Number.isNaN(parsedMax) ? Infinity : parsedMax;
|
|
559
|
-
if (min2 > max2) {
|
|
560
|
-
const temp = min2;
|
|
561
|
-
min2 = max2;
|
|
562
|
-
max2 = temp;
|
|
563
|
-
}
|
|
564
|
-
return [min2, max2];
|
|
565
|
-
};
|
|
566
|
-
inNumberRange.autoRemove = (val) => testFalsey(val) || testFalsey(val[0]) && testFalsey(val[1]);
|
|
567
|
-
var filterFns = {
|
|
568
|
-
includesString,
|
|
569
|
-
includesStringSensitive,
|
|
570
|
-
equalsString,
|
|
571
|
-
arrIncludes,
|
|
572
|
-
arrIncludesAll,
|
|
573
|
-
arrIncludesSome,
|
|
574
|
-
equals,
|
|
575
|
-
weakEquals,
|
|
576
|
-
inNumberRange
|
|
577
|
-
};
|
|
578
|
-
function testFalsey(val) {
|
|
579
|
-
return val === void 0 || val === null || val === "";
|
|
580
|
-
}
|
|
581
|
-
var ColumnFiltering = {
|
|
582
|
-
getDefaultColumnDef: () => {
|
|
583
|
-
return {
|
|
584
|
-
filterFn: "auto"
|
|
585
|
-
};
|
|
586
|
-
},
|
|
587
|
-
getInitialState: (state) => {
|
|
588
|
-
return {
|
|
589
|
-
columnFilters: [],
|
|
590
|
-
...state
|
|
591
|
-
};
|
|
592
|
-
},
|
|
593
|
-
getDefaultOptions: (table) => {
|
|
594
|
-
return {
|
|
595
|
-
onColumnFiltersChange: makeStateUpdater("columnFilters", table),
|
|
596
|
-
filterFromLeafRows: false,
|
|
597
|
-
maxLeafRowFilterDepth: 100
|
|
598
|
-
};
|
|
599
|
-
},
|
|
600
|
-
createColumn: (column, table) => {
|
|
601
|
-
column.getAutoFilterFn = () => {
|
|
602
|
-
const firstRow = table.getCoreRowModel().flatRows[0];
|
|
603
|
-
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
|
604
|
-
if (typeof value === "string") {
|
|
605
|
-
return filterFns.includesString;
|
|
606
|
-
}
|
|
607
|
-
if (typeof value === "number") {
|
|
608
|
-
return filterFns.inNumberRange;
|
|
609
|
-
}
|
|
610
|
-
if (typeof value === "boolean") {
|
|
611
|
-
return filterFns.equals;
|
|
612
|
-
}
|
|
613
|
-
if (value !== null && typeof value === "object") {
|
|
614
|
-
return filterFns.equals;
|
|
615
|
-
}
|
|
616
|
-
if (Array.isArray(value)) {
|
|
617
|
-
return filterFns.arrIncludes;
|
|
618
|
-
}
|
|
619
|
-
return filterFns.weakEquals;
|
|
620
|
-
};
|
|
621
|
-
column.getFilterFn = () => {
|
|
622
|
-
var _table$options$filter, _table$options$filter2;
|
|
623
|
-
return isFunction(column.columnDef.filterFn) ? column.columnDef.filterFn : column.columnDef.filterFn === "auto" ? column.getAutoFilterFn() : (
|
|
624
|
-
// @ts-ignore
|
|
625
|
-
(_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]
|
|
626
|
-
);
|
|
627
|
-
};
|
|
628
|
-
column.getCanFilter = () => {
|
|
629
|
-
var _column$columnDef$ena, _table$options$enable, _table$options$enable2;
|
|
630
|
-
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;
|
|
631
|
-
};
|
|
632
|
-
column.getIsFiltered = () => column.getFilterIndex() > -1;
|
|
633
|
-
column.getFilterValue = () => {
|
|
634
|
-
var _table$getState$colum;
|
|
635
|
-
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;
|
|
636
|
-
};
|
|
637
|
-
column.getFilterIndex = () => {
|
|
638
|
-
var _table$getState$colum2, _table$getState$colum3;
|
|
639
|
-
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;
|
|
640
|
-
};
|
|
641
|
-
column.setFilterValue = (value) => {
|
|
642
|
-
table.setColumnFilters((old) => {
|
|
643
|
-
const filterFn = column.getFilterFn();
|
|
644
|
-
const previousFilter = old == null ? void 0 : old.find((d) => d.id === column.id);
|
|
645
|
-
const newFilter = functionalUpdate(value, previousFilter ? previousFilter.value : void 0);
|
|
646
|
-
if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {
|
|
647
|
-
var _old$filter;
|
|
648
|
-
return (_old$filter = old == null ? void 0 : old.filter((d) => d.id !== column.id)) != null ? _old$filter : [];
|
|
649
|
-
}
|
|
650
|
-
const newFilterObj = {
|
|
651
|
-
id: column.id,
|
|
652
|
-
value: newFilter
|
|
653
|
-
};
|
|
654
|
-
if (previousFilter) {
|
|
655
|
-
var _old$map;
|
|
656
|
-
return (_old$map = old == null ? void 0 : old.map((d) => {
|
|
657
|
-
if (d.id === column.id) {
|
|
658
|
-
return newFilterObj;
|
|
659
|
-
}
|
|
660
|
-
return d;
|
|
661
|
-
})) != null ? _old$map : [];
|
|
662
|
-
}
|
|
663
|
-
if (old != null && old.length) {
|
|
664
|
-
return [...old, newFilterObj];
|
|
665
|
-
}
|
|
666
|
-
return [newFilterObj];
|
|
667
|
-
});
|
|
668
|
-
};
|
|
669
|
-
},
|
|
670
|
-
createRow: (row, _table) => {
|
|
671
|
-
row.columnFilters = {};
|
|
672
|
-
row.columnFiltersMeta = {};
|
|
673
|
-
},
|
|
674
|
-
createTable: (table) => {
|
|
675
|
-
table.setColumnFilters = (updater) => {
|
|
676
|
-
const leafColumns = table.getAllLeafColumns();
|
|
677
|
-
const updateFn = (old) => {
|
|
678
|
-
var _functionalUpdate;
|
|
679
|
-
return (_functionalUpdate = functionalUpdate(updater, old)) == null ? void 0 : _functionalUpdate.filter((filter) => {
|
|
680
|
-
const column = leafColumns.find((d) => d.id === filter.id);
|
|
681
|
-
if (column) {
|
|
682
|
-
const filterFn = column.getFilterFn();
|
|
683
|
-
if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {
|
|
684
|
-
return false;
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
return true;
|
|
688
|
-
});
|
|
689
|
-
};
|
|
690
|
-
table.options.onColumnFiltersChange == null || table.options.onColumnFiltersChange(updateFn);
|
|
691
|
-
};
|
|
692
|
-
table.resetColumnFilters = (defaultState) => {
|
|
693
|
-
var _table$initialState$c, _table$initialState;
|
|
694
|
-
table.setColumnFilters(defaultState ? [] : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnFilters) != null ? _table$initialState$c : []);
|
|
695
|
-
};
|
|
696
|
-
table.getPreFilteredRowModel = () => table.getCoreRowModel();
|
|
697
|
-
table.getFilteredRowModel = () => {
|
|
698
|
-
if (!table._getFilteredRowModel && table.options.getFilteredRowModel) {
|
|
699
|
-
table._getFilteredRowModel = table.options.getFilteredRowModel(table);
|
|
700
|
-
}
|
|
701
|
-
if (table.options.manualFiltering || !table._getFilteredRowModel) {
|
|
702
|
-
return table.getPreFilteredRowModel();
|
|
703
|
-
}
|
|
704
|
-
return table._getFilteredRowModel();
|
|
705
|
-
};
|
|
706
|
-
}
|
|
707
|
-
};
|
|
708
|
-
function shouldAutoRemoveFilter(filterFn, value, column) {
|
|
709
|
-
return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === "undefined" || typeof value === "string" && !value;
|
|
710
|
-
}
|
|
711
|
-
var sum = (columnId, _leafRows, childRows) => {
|
|
712
|
-
return childRows.reduce((sum2, next) => {
|
|
713
|
-
const nextValue = next.getValue(columnId);
|
|
714
|
-
return sum2 + (typeof nextValue === "number" ? nextValue : 0);
|
|
715
|
-
}, 0);
|
|
716
|
-
};
|
|
717
|
-
var min = (columnId, _leafRows, childRows) => {
|
|
718
|
-
let min2;
|
|
719
|
-
childRows.forEach((row) => {
|
|
720
|
-
const value = row.getValue(columnId);
|
|
721
|
-
if (value != null && (min2 > value || min2 === void 0 && value >= value)) {
|
|
722
|
-
min2 = value;
|
|
723
|
-
}
|
|
724
|
-
});
|
|
725
|
-
return min2;
|
|
726
|
-
};
|
|
727
|
-
var max = (columnId, _leafRows, childRows) => {
|
|
728
|
-
let max2;
|
|
729
|
-
childRows.forEach((row) => {
|
|
730
|
-
const value = row.getValue(columnId);
|
|
731
|
-
if (value != null && (max2 < value || max2 === void 0 && value >= value)) {
|
|
732
|
-
max2 = value;
|
|
733
|
-
}
|
|
734
|
-
});
|
|
735
|
-
return max2;
|
|
736
|
-
};
|
|
737
|
-
var extent = (columnId, _leafRows, childRows) => {
|
|
738
|
-
let min2;
|
|
739
|
-
let max2;
|
|
740
|
-
childRows.forEach((row) => {
|
|
741
|
-
const value = row.getValue(columnId);
|
|
742
|
-
if (value != null) {
|
|
743
|
-
if (min2 === void 0) {
|
|
744
|
-
if (value >= value) min2 = max2 = value;
|
|
745
|
-
} else {
|
|
746
|
-
if (min2 > value) min2 = value;
|
|
747
|
-
if (max2 < value) max2 = value;
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
});
|
|
751
|
-
return [min2, max2];
|
|
752
|
-
};
|
|
753
|
-
var mean = (columnId, leafRows) => {
|
|
754
|
-
let count2 = 0;
|
|
755
|
-
let sum2 = 0;
|
|
756
|
-
leafRows.forEach((row) => {
|
|
757
|
-
let value = row.getValue(columnId);
|
|
758
|
-
if (value != null && (value = +value) >= value) {
|
|
759
|
-
++count2, sum2 += value;
|
|
760
|
-
}
|
|
761
|
-
});
|
|
762
|
-
if (count2) return sum2 / count2;
|
|
763
|
-
return;
|
|
764
|
-
};
|
|
765
|
-
var median = (columnId, leafRows) => {
|
|
766
|
-
if (!leafRows.length) {
|
|
767
|
-
return;
|
|
768
|
-
}
|
|
769
|
-
const values = leafRows.map((row) => row.getValue(columnId));
|
|
770
|
-
if (!isNumberArray(values)) {
|
|
771
|
-
return;
|
|
772
|
-
}
|
|
773
|
-
if (values.length === 1) {
|
|
774
|
-
return values[0];
|
|
775
|
-
}
|
|
776
|
-
const mid = Math.floor(values.length / 2);
|
|
777
|
-
const nums = values.sort((a, b) => a - b);
|
|
778
|
-
return values.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
|
|
779
|
-
};
|
|
780
|
-
var unique = (columnId, leafRows) => {
|
|
781
|
-
return Array.from(new Set(leafRows.map((d) => d.getValue(columnId))).values());
|
|
782
|
-
};
|
|
783
|
-
var uniqueCount = (columnId, leafRows) => {
|
|
784
|
-
return new Set(leafRows.map((d) => d.getValue(columnId))).size;
|
|
785
|
-
};
|
|
786
|
-
var count = (_columnId, leafRows) => {
|
|
787
|
-
return leafRows.length;
|
|
788
|
-
};
|
|
789
|
-
var aggregationFns = {
|
|
790
|
-
sum,
|
|
791
|
-
min,
|
|
792
|
-
max,
|
|
793
|
-
extent,
|
|
794
|
-
mean,
|
|
795
|
-
median,
|
|
796
|
-
unique,
|
|
797
|
-
uniqueCount,
|
|
798
|
-
count
|
|
799
|
-
};
|
|
800
|
-
var ColumnGrouping = {
|
|
801
|
-
getDefaultColumnDef: () => {
|
|
802
|
-
return {
|
|
803
|
-
aggregatedCell: (props) => {
|
|
804
|
-
var _toString, _props$getValue;
|
|
805
|
-
return (_toString = (_props$getValue = props.getValue()) == null || _props$getValue.toString == null ? void 0 : _props$getValue.toString()) != null ? _toString : null;
|
|
806
|
-
},
|
|
807
|
-
aggregationFn: "auto"
|
|
808
|
-
};
|
|
809
|
-
},
|
|
810
|
-
getInitialState: (state) => {
|
|
811
|
-
return {
|
|
812
|
-
grouping: [],
|
|
813
|
-
...state
|
|
814
|
-
};
|
|
815
|
-
},
|
|
816
|
-
getDefaultOptions: (table) => {
|
|
817
|
-
return {
|
|
818
|
-
onGroupingChange: makeStateUpdater("grouping", table),
|
|
819
|
-
groupedColumnMode: "reorder"
|
|
820
|
-
};
|
|
821
|
-
},
|
|
822
|
-
createColumn: (column, table) => {
|
|
823
|
-
column.toggleGrouping = () => {
|
|
824
|
-
table.setGrouping((old) => {
|
|
825
|
-
if (old != null && old.includes(column.id)) {
|
|
826
|
-
return old.filter((d) => d !== column.id);
|
|
827
|
-
}
|
|
828
|
-
return [...old != null ? old : [], column.id];
|
|
829
|
-
});
|
|
830
|
-
};
|
|
831
|
-
column.getCanGroup = () => {
|
|
832
|
-
var _column$columnDef$ena, _table$options$enable;
|
|
833
|
-
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);
|
|
834
|
-
};
|
|
835
|
-
column.getIsGrouped = () => {
|
|
836
|
-
var _table$getState$group;
|
|
837
|
-
return (_table$getState$group = table.getState().grouping) == null ? void 0 : _table$getState$group.includes(column.id);
|
|
838
|
-
};
|
|
839
|
-
column.getGroupedIndex = () => {
|
|
840
|
-
var _table$getState$group2;
|
|
841
|
-
return (_table$getState$group2 = table.getState().grouping) == null ? void 0 : _table$getState$group2.indexOf(column.id);
|
|
842
|
-
};
|
|
843
|
-
column.getToggleGroupingHandler = () => {
|
|
844
|
-
const canGroup = column.getCanGroup();
|
|
845
|
-
return () => {
|
|
846
|
-
if (!canGroup) return;
|
|
847
|
-
column.toggleGrouping();
|
|
848
|
-
};
|
|
849
|
-
};
|
|
850
|
-
column.getAutoAggregationFn = () => {
|
|
851
|
-
const firstRow = table.getCoreRowModel().flatRows[0];
|
|
852
|
-
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
|
853
|
-
if (typeof value === "number") {
|
|
854
|
-
return aggregationFns.sum;
|
|
855
|
-
}
|
|
856
|
-
if (Object.prototype.toString.call(value) === "[object Date]") {
|
|
857
|
-
return aggregationFns.extent;
|
|
858
|
-
}
|
|
859
|
-
};
|
|
860
|
-
column.getAggregationFn = () => {
|
|
861
|
-
var _table$options$aggreg, _table$options$aggreg2;
|
|
862
|
-
if (!column) {
|
|
863
|
-
throw new Error();
|
|
864
|
-
}
|
|
865
|
-
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];
|
|
866
|
-
};
|
|
867
|
-
},
|
|
868
|
-
createTable: (table) => {
|
|
869
|
-
table.setGrouping = (updater) => table.options.onGroupingChange == null ? void 0 : table.options.onGroupingChange(updater);
|
|
870
|
-
table.resetGrouping = (defaultState) => {
|
|
871
|
-
var _table$initialState$g, _table$initialState;
|
|
872
|
-
table.setGrouping(defaultState ? [] : (_table$initialState$g = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.grouping) != null ? _table$initialState$g : []);
|
|
873
|
-
};
|
|
874
|
-
table.getPreGroupedRowModel = () => table.getFilteredRowModel();
|
|
875
|
-
table.getGroupedRowModel = () => {
|
|
876
|
-
if (!table._getGroupedRowModel && table.options.getGroupedRowModel) {
|
|
877
|
-
table._getGroupedRowModel = table.options.getGroupedRowModel(table);
|
|
878
|
-
}
|
|
879
|
-
if (table.options.manualGrouping || !table._getGroupedRowModel) {
|
|
880
|
-
return table.getPreGroupedRowModel();
|
|
881
|
-
}
|
|
882
|
-
return table._getGroupedRowModel();
|
|
883
|
-
};
|
|
884
|
-
},
|
|
885
|
-
createRow: (row, table) => {
|
|
886
|
-
row.getIsGrouped = () => !!row.groupingColumnId;
|
|
887
|
-
row.getGroupingValue = (columnId) => {
|
|
888
|
-
if (row._groupingValuesCache.hasOwnProperty(columnId)) {
|
|
889
|
-
return row._groupingValuesCache[columnId];
|
|
890
|
-
}
|
|
891
|
-
const column = table.getColumn(columnId);
|
|
892
|
-
if (!(column != null && column.columnDef.getGroupingValue)) {
|
|
893
|
-
return row.getValue(columnId);
|
|
894
|
-
}
|
|
895
|
-
row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(row.original);
|
|
896
|
-
return row._groupingValuesCache[columnId];
|
|
897
|
-
};
|
|
898
|
-
row._groupingValuesCache = {};
|
|
899
|
-
},
|
|
900
|
-
createCell: (cell, column, row, table) => {
|
|
901
|
-
cell.getIsGrouped = () => column.getIsGrouped() && column.id === row.groupingColumnId;
|
|
902
|
-
cell.getIsPlaceholder = () => !cell.getIsGrouped() && column.getIsGrouped();
|
|
903
|
-
cell.getIsAggregated = () => {
|
|
904
|
-
var _row$subRows;
|
|
905
|
-
return !cell.getIsGrouped() && !cell.getIsPlaceholder() && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
|
|
906
|
-
};
|
|
907
|
-
}
|
|
908
|
-
};
|
|
909
|
-
function orderColumns(leafColumns, grouping, groupedColumnMode) {
|
|
910
|
-
if (!(grouping != null && grouping.length) || !groupedColumnMode) {
|
|
911
|
-
return leafColumns;
|
|
912
|
-
}
|
|
913
|
-
const nonGroupingColumns = leafColumns.filter((col) => !grouping.includes(col.id));
|
|
914
|
-
if (groupedColumnMode === "remove") {
|
|
915
|
-
return nonGroupingColumns;
|
|
916
|
-
}
|
|
917
|
-
const groupingColumns = grouping.map((g) => leafColumns.find((col) => col.id === g)).filter(Boolean);
|
|
918
|
-
return [...groupingColumns, ...nonGroupingColumns];
|
|
919
|
-
}
|
|
920
|
-
var ColumnOrdering = {
|
|
921
|
-
getInitialState: (state) => {
|
|
922
|
-
return {
|
|
923
|
-
columnOrder: [],
|
|
924
|
-
...state
|
|
925
|
-
};
|
|
926
|
-
},
|
|
927
|
-
getDefaultOptions: (table) => {
|
|
928
|
-
return {
|
|
929
|
-
onColumnOrderChange: makeStateUpdater("columnOrder", table)
|
|
930
|
-
};
|
|
931
|
-
},
|
|
932
|
-
createColumn: (column, table) => {
|
|
933
|
-
column.getIndex = memo((position) => [_getVisibleLeafColumns(table, position)], (columns) => columns.findIndex((d) => d.id === column.id), getMemoOptions(table.options, "debugColumns", "getIndex"));
|
|
934
|
-
column.getIsFirstColumn = (position) => {
|
|
935
|
-
var _columns$;
|
|
936
|
-
const columns = _getVisibleLeafColumns(table, position);
|
|
937
|
-
return ((_columns$ = columns[0]) == null ? void 0 : _columns$.id) === column.id;
|
|
938
|
-
};
|
|
939
|
-
column.getIsLastColumn = (position) => {
|
|
940
|
-
var _columns;
|
|
941
|
-
const columns = _getVisibleLeafColumns(table, position);
|
|
942
|
-
return ((_columns = columns[columns.length - 1]) == null ? void 0 : _columns.id) === column.id;
|
|
943
|
-
};
|
|
944
|
-
},
|
|
945
|
-
createTable: (table) => {
|
|
946
|
-
table.setColumnOrder = (updater) => table.options.onColumnOrderChange == null ? void 0 : table.options.onColumnOrderChange(updater);
|
|
947
|
-
table.resetColumnOrder = (defaultState) => {
|
|
948
|
-
var _table$initialState$c;
|
|
949
|
-
table.setColumnOrder(defaultState ? [] : (_table$initialState$c = table.initialState.columnOrder) != null ? _table$initialState$c : []);
|
|
950
|
-
};
|
|
951
|
-
table._getOrderColumnsFn = memo(() => [table.getState().columnOrder, table.getState().grouping, table.options.groupedColumnMode], (columnOrder, grouping, groupedColumnMode) => (columns) => {
|
|
952
|
-
let orderedColumns = [];
|
|
953
|
-
if (!(columnOrder != null && columnOrder.length)) {
|
|
954
|
-
orderedColumns = columns;
|
|
955
|
-
} else {
|
|
956
|
-
const columnOrderCopy = [...columnOrder];
|
|
957
|
-
const columnsCopy = [...columns];
|
|
958
|
-
while (columnsCopy.length && columnOrderCopy.length) {
|
|
959
|
-
const targetColumnId = columnOrderCopy.shift();
|
|
960
|
-
const foundIndex = columnsCopy.findIndex((d) => d.id === targetColumnId);
|
|
961
|
-
if (foundIndex > -1) {
|
|
962
|
-
orderedColumns.push(columnsCopy.splice(foundIndex, 1)[0]);
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
orderedColumns = [...orderedColumns, ...columnsCopy];
|
|
966
|
-
}
|
|
967
|
-
return orderColumns(orderedColumns, grouping, groupedColumnMode);
|
|
968
|
-
}, getMemoOptions(table.options, "debugTable", "_getOrderColumnsFn"));
|
|
969
|
-
}
|
|
970
|
-
};
|
|
971
|
-
var getDefaultColumnPinningState = () => ({
|
|
972
|
-
left: [],
|
|
973
|
-
right: []
|
|
974
|
-
});
|
|
975
|
-
var ColumnPinning = {
|
|
976
|
-
getInitialState: (state) => {
|
|
977
|
-
return {
|
|
978
|
-
columnPinning: getDefaultColumnPinningState(),
|
|
979
|
-
...state
|
|
980
|
-
};
|
|
981
|
-
},
|
|
982
|
-
getDefaultOptions: (table) => {
|
|
983
|
-
return {
|
|
984
|
-
onColumnPinningChange: makeStateUpdater("columnPinning", table)
|
|
985
|
-
};
|
|
986
|
-
},
|
|
987
|
-
createColumn: (column, table) => {
|
|
988
|
-
column.pin = (position) => {
|
|
989
|
-
const columnIds = column.getLeafColumns().map((d) => d.id).filter(Boolean);
|
|
990
|
-
table.setColumnPinning((old) => {
|
|
991
|
-
var _old$left3, _old$right3;
|
|
992
|
-
if (position === "right") {
|
|
993
|
-
var _old$left, _old$right;
|
|
994
|
-
return {
|
|
995
|
-
left: ((_old$left = old == null ? void 0 : old.left) != null ? _old$left : []).filter((d) => !(columnIds != null && columnIds.includes(d))),
|
|
996
|
-
right: [...((_old$right = old == null ? void 0 : old.right) != null ? _old$right : []).filter((d) => !(columnIds != null && columnIds.includes(d))), ...columnIds]
|
|
997
|
-
};
|
|
998
|
-
}
|
|
999
|
-
if (position === "left") {
|
|
1000
|
-
var _old$left2, _old$right2;
|
|
1001
|
-
return {
|
|
1002
|
-
left: [...((_old$left2 = old == null ? void 0 : old.left) != null ? _old$left2 : []).filter((d) => !(columnIds != null && columnIds.includes(d))), ...columnIds],
|
|
1003
|
-
right: ((_old$right2 = old == null ? void 0 : old.right) != null ? _old$right2 : []).filter((d) => !(columnIds != null && columnIds.includes(d)))
|
|
1004
|
-
};
|
|
1005
|
-
}
|
|
1006
|
-
return {
|
|
1007
|
-
left: ((_old$left3 = old == null ? void 0 : old.left) != null ? _old$left3 : []).filter((d) => !(columnIds != null && columnIds.includes(d))),
|
|
1008
|
-
right: ((_old$right3 = old == null ? void 0 : old.right) != null ? _old$right3 : []).filter((d) => !(columnIds != null && columnIds.includes(d)))
|
|
1009
|
-
};
|
|
1010
|
-
});
|
|
1011
|
-
};
|
|
1012
|
-
column.getCanPin = () => {
|
|
1013
|
-
const leafColumns = column.getLeafColumns();
|
|
1014
|
-
return leafColumns.some((d) => {
|
|
1015
|
-
var _d$columnDef$enablePi, _ref, _table$options$enable;
|
|
1016
|
-
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);
|
|
1017
|
-
});
|
|
1018
|
-
};
|
|
1019
|
-
column.getIsPinned = () => {
|
|
1020
|
-
const leafColumnIds = column.getLeafColumns().map((d) => d.id);
|
|
1021
|
-
const {
|
|
1022
|
-
left,
|
|
1023
|
-
right
|
|
1024
|
-
} = table.getState().columnPinning;
|
|
1025
|
-
const isLeft = leafColumnIds.some((d) => left == null ? void 0 : left.includes(d));
|
|
1026
|
-
const isRight = leafColumnIds.some((d) => right == null ? void 0 : right.includes(d));
|
|
1027
|
-
return isLeft ? "left" : isRight ? "right" : false;
|
|
1028
|
-
};
|
|
1029
|
-
column.getPinnedIndex = () => {
|
|
1030
|
-
var _table$getState$colum, _table$getState$colum2;
|
|
1031
|
-
const position = column.getIsPinned();
|
|
1032
|
-
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;
|
|
1033
|
-
};
|
|
1034
|
-
},
|
|
1035
|
-
createRow: (row, table) => {
|
|
1036
|
-
row.getCenterVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allCells, left, right) => {
|
|
1037
|
-
const leftAndRight = [...left != null ? left : [], ...right != null ? right : []];
|
|
1038
|
-
return allCells.filter((d) => !leftAndRight.includes(d.column.id));
|
|
1039
|
-
}, getMemoOptions(table.options, "debugRows", "getCenterVisibleCells"));
|
|
1040
|
-
row.getLeftVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left], (allCells, left) => {
|
|
1041
|
-
const cells = (left != null ? left : []).map((columnId) => allCells.find((cell) => cell.column.id === columnId)).filter(Boolean).map((d) => ({
|
|
1042
|
-
...d,
|
|
1043
|
-
position: "left"
|
|
1044
|
-
}));
|
|
1045
|
-
return cells;
|
|
1046
|
-
}, getMemoOptions(table.options, "debugRows", "getLeftVisibleCells"));
|
|
1047
|
-
row.getRightVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.right], (allCells, right) => {
|
|
1048
|
-
const cells = (right != null ? right : []).map((columnId) => allCells.find((cell) => cell.column.id === columnId)).filter(Boolean).map((d) => ({
|
|
1049
|
-
...d,
|
|
1050
|
-
position: "right"
|
|
1051
|
-
}));
|
|
1052
|
-
return cells;
|
|
1053
|
-
}, getMemoOptions(table.options, "debugRows", "getRightVisibleCells"));
|
|
1054
|
-
},
|
|
1055
|
-
createTable: (table) => {
|
|
1056
|
-
table.setColumnPinning = (updater) => table.options.onColumnPinningChange == null ? void 0 : table.options.onColumnPinningChange(updater);
|
|
1057
|
-
table.resetColumnPinning = (defaultState) => {
|
|
1058
|
-
var _table$initialState$c, _table$initialState;
|
|
1059
|
-
return table.setColumnPinning(defaultState ? getDefaultColumnPinningState() : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnPinning) != null ? _table$initialState$c : getDefaultColumnPinningState());
|
|
1060
|
-
};
|
|
1061
|
-
table.getIsSomeColumnsPinned = (position) => {
|
|
1062
|
-
var _pinningState$positio;
|
|
1063
|
-
const pinningState = table.getState().columnPinning;
|
|
1064
|
-
if (!position) {
|
|
1065
|
-
var _pinningState$left, _pinningState$right;
|
|
1066
|
-
return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
|
|
1067
|
-
}
|
|
1068
|
-
return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
|
|
1069
|
-
};
|
|
1070
|
-
table.getLeftLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left], (allColumns, left) => {
|
|
1071
|
-
return (left != null ? left : []).map((columnId) => allColumns.find((column) => column.id === columnId)).filter(Boolean);
|
|
1072
|
-
}, getMemoOptions(table.options, "debugColumns", "getLeftLeafColumns"));
|
|
1073
|
-
table.getRightLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.right], (allColumns, right) => {
|
|
1074
|
-
return (right != null ? right : []).map((columnId) => allColumns.find((column) => column.id === columnId)).filter(Boolean);
|
|
1075
|
-
}, getMemoOptions(table.options, "debugColumns", "getRightLeafColumns"));
|
|
1076
|
-
table.getCenterLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, left, right) => {
|
|
1077
|
-
const leftAndRight = [...left != null ? left : [], ...right != null ? right : []];
|
|
1078
|
-
return allColumns.filter((d) => !leftAndRight.includes(d.id));
|
|
1079
|
-
}, getMemoOptions(table.options, "debugColumns", "getCenterLeafColumns"));
|
|
1080
|
-
}
|
|
1081
|
-
};
|
|
1082
|
-
function safelyAccessDocument(_document) {
|
|
1083
|
-
return _document || (typeof document !== "undefined" ? document : null);
|
|
1084
|
-
}
|
|
1085
|
-
var defaultColumnSizing = {
|
|
1086
|
-
size: 150,
|
|
1087
|
-
minSize: 20,
|
|
1088
|
-
maxSize: Number.MAX_SAFE_INTEGER
|
|
1089
|
-
};
|
|
1090
|
-
var getDefaultColumnSizingInfoState = () => ({
|
|
1091
|
-
startOffset: null,
|
|
1092
|
-
startSize: null,
|
|
1093
|
-
deltaOffset: null,
|
|
1094
|
-
deltaPercentage: null,
|
|
1095
|
-
isResizingColumn: false,
|
|
1096
|
-
columnSizingStart: []
|
|
1097
|
-
});
|
|
1098
|
-
var ColumnSizing = {
|
|
1099
|
-
getDefaultColumnDef: () => {
|
|
1100
|
-
return defaultColumnSizing;
|
|
1101
|
-
},
|
|
1102
|
-
getInitialState: (state) => {
|
|
1103
|
-
return {
|
|
1104
|
-
columnSizing: {},
|
|
1105
|
-
columnSizingInfo: getDefaultColumnSizingInfoState(),
|
|
1106
|
-
...state
|
|
1107
|
-
};
|
|
1108
|
-
},
|
|
1109
|
-
getDefaultOptions: (table) => {
|
|
1110
|
-
return {
|
|
1111
|
-
columnResizeMode: "onEnd",
|
|
1112
|
-
columnResizeDirection: "ltr",
|
|
1113
|
-
onColumnSizingChange: makeStateUpdater("columnSizing", table),
|
|
1114
|
-
onColumnSizingInfoChange: makeStateUpdater("columnSizingInfo", table)
|
|
1115
|
-
};
|
|
1116
|
-
},
|
|
1117
|
-
createColumn: (column, table) => {
|
|
1118
|
-
column.getSize = () => {
|
|
1119
|
-
var _column$columnDef$min, _ref, _column$columnDef$max;
|
|
1120
|
-
const columnSize = table.getState().columnSizing[column.id];
|
|
1121
|
-
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);
|
|
1122
|
-
};
|
|
1123
|
-
column.getStart = memo((position) => [position, _getVisibleLeafColumns(table, position), table.getState().columnSizing], (position, columns) => columns.slice(0, column.getIndex(position)).reduce((sum2, column2) => sum2 + column2.getSize(), 0), getMemoOptions(table.options, "debugColumns", "getStart"));
|
|
1124
|
-
column.getAfter = memo((position) => [position, _getVisibleLeafColumns(table, position), table.getState().columnSizing], (position, columns) => columns.slice(column.getIndex(position) + 1).reduce((sum2, column2) => sum2 + column2.getSize(), 0), getMemoOptions(table.options, "debugColumns", "getAfter"));
|
|
1125
|
-
column.resetSize = () => {
|
|
1126
|
-
table.setColumnSizing((_ref2) => {
|
|
1127
|
-
let {
|
|
1128
|
-
[column.id]: _,
|
|
1129
|
-
...rest
|
|
1130
|
-
} = _ref2;
|
|
1131
|
-
return rest;
|
|
1132
|
-
});
|
|
1133
|
-
};
|
|
1134
|
-
column.getCanResize = () => {
|
|
1135
|
-
var _column$columnDef$ena, _table$options$enable;
|
|
1136
|
-
return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnResizing) != null ? _table$options$enable : true);
|
|
1137
|
-
};
|
|
1138
|
-
column.getIsResizing = () => {
|
|
1139
|
-
return table.getState().columnSizingInfo.isResizingColumn === column.id;
|
|
1140
|
-
};
|
|
1141
|
-
},
|
|
1142
|
-
createHeader: (header, table) => {
|
|
1143
|
-
header.getSize = () => {
|
|
1144
|
-
let sum2 = 0;
|
|
1145
|
-
const recurse = (header2) => {
|
|
1146
|
-
if (header2.subHeaders.length) {
|
|
1147
|
-
header2.subHeaders.forEach(recurse);
|
|
1148
|
-
} else {
|
|
1149
|
-
var _header$column$getSiz;
|
|
1150
|
-
sum2 += (_header$column$getSiz = header2.column.getSize()) != null ? _header$column$getSiz : 0;
|
|
1151
|
-
}
|
|
1152
|
-
};
|
|
1153
|
-
recurse(header);
|
|
1154
|
-
return sum2;
|
|
1155
|
-
};
|
|
1156
|
-
header.getStart = () => {
|
|
1157
|
-
if (header.index > 0) {
|
|
1158
|
-
const prevSiblingHeader = header.headerGroup.headers[header.index - 1];
|
|
1159
|
-
return prevSiblingHeader.getStart() + prevSiblingHeader.getSize();
|
|
1160
|
-
}
|
|
1161
|
-
return 0;
|
|
1162
|
-
};
|
|
1163
|
-
header.getResizeHandler = (_contextDocument) => {
|
|
1164
|
-
const column = table.getColumn(header.column.id);
|
|
1165
|
-
const canResize = column == null ? void 0 : column.getCanResize();
|
|
1166
|
-
return (e) => {
|
|
1167
|
-
if (!column || !canResize) {
|
|
1168
|
-
return;
|
|
1169
|
-
}
|
|
1170
|
-
e.persist == null || e.persist();
|
|
1171
|
-
if (isTouchStartEvent(e)) {
|
|
1172
|
-
if (e.touches && e.touches.length > 1) {
|
|
1173
|
-
return;
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
const startSize = header.getSize();
|
|
1177
|
-
const columnSizingStart = header ? header.getLeafHeaders().map((d) => [d.column.id, d.column.getSize()]) : [[column.id, column.getSize()]];
|
|
1178
|
-
const clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
|
|
1179
|
-
const newColumnSizing = {};
|
|
1180
|
-
const updateOffset = (eventType, clientXPos) => {
|
|
1181
|
-
if (typeof clientXPos !== "number") {
|
|
1182
|
-
return;
|
|
1183
|
-
}
|
|
1184
|
-
table.setColumnSizingInfo((old) => {
|
|
1185
|
-
var _old$startOffset, _old$startSize;
|
|
1186
|
-
const deltaDirection = table.options.columnResizeDirection === "rtl" ? -1 : 1;
|
|
1187
|
-
const deltaOffset = (clientXPos - ((_old$startOffset = old == null ? void 0 : old.startOffset) != null ? _old$startOffset : 0)) * deltaDirection;
|
|
1188
|
-
const deltaPercentage = Math.max(deltaOffset / ((_old$startSize = old == null ? void 0 : old.startSize) != null ? _old$startSize : 0), -0.999999);
|
|
1189
|
-
old.columnSizingStart.forEach((_ref3) => {
|
|
1190
|
-
let [columnId, headerSize] = _ref3;
|
|
1191
|
-
newColumnSizing[columnId] = Math.round(Math.max(headerSize + headerSize * deltaPercentage, 0) * 100) / 100;
|
|
1192
|
-
});
|
|
1193
|
-
return {
|
|
1194
|
-
...old,
|
|
1195
|
-
deltaOffset,
|
|
1196
|
-
deltaPercentage
|
|
1197
|
-
};
|
|
1198
|
-
});
|
|
1199
|
-
if (table.options.columnResizeMode === "onChange" || eventType === "end") {
|
|
1200
|
-
table.setColumnSizing((old) => ({
|
|
1201
|
-
...old,
|
|
1202
|
-
...newColumnSizing
|
|
1203
|
-
}));
|
|
1204
|
-
}
|
|
1205
|
-
};
|
|
1206
|
-
const onMove = (clientXPos) => updateOffset("move", clientXPos);
|
|
1207
|
-
const onEnd = (clientXPos) => {
|
|
1208
|
-
updateOffset("end", clientXPos);
|
|
1209
|
-
table.setColumnSizingInfo((old) => ({
|
|
1210
|
-
...old,
|
|
1211
|
-
isResizingColumn: false,
|
|
1212
|
-
startOffset: null,
|
|
1213
|
-
startSize: null,
|
|
1214
|
-
deltaOffset: null,
|
|
1215
|
-
deltaPercentage: null,
|
|
1216
|
-
columnSizingStart: []
|
|
1217
|
-
}));
|
|
1218
|
-
};
|
|
1219
|
-
const contextDocument = safelyAccessDocument(_contextDocument);
|
|
1220
|
-
const mouseEvents = {
|
|
1221
|
-
moveHandler: (e2) => onMove(e2.clientX),
|
|
1222
|
-
upHandler: (e2) => {
|
|
1223
|
-
contextDocument == null || contextDocument.removeEventListener("mousemove", mouseEvents.moveHandler);
|
|
1224
|
-
contextDocument == null || contextDocument.removeEventListener("mouseup", mouseEvents.upHandler);
|
|
1225
|
-
onEnd(e2.clientX);
|
|
1226
|
-
}
|
|
1227
|
-
};
|
|
1228
|
-
const touchEvents = {
|
|
1229
|
-
moveHandler: (e2) => {
|
|
1230
|
-
if (e2.cancelable) {
|
|
1231
|
-
e2.preventDefault();
|
|
1232
|
-
e2.stopPropagation();
|
|
1233
|
-
}
|
|
1234
|
-
onMove(e2.touches[0].clientX);
|
|
1235
|
-
return false;
|
|
1236
|
-
},
|
|
1237
|
-
upHandler: (e2) => {
|
|
1238
|
-
var _e$touches$;
|
|
1239
|
-
contextDocument == null || contextDocument.removeEventListener("touchmove", touchEvents.moveHandler);
|
|
1240
|
-
contextDocument == null || contextDocument.removeEventListener("touchend", touchEvents.upHandler);
|
|
1241
|
-
if (e2.cancelable) {
|
|
1242
|
-
e2.preventDefault();
|
|
1243
|
-
e2.stopPropagation();
|
|
1244
|
-
}
|
|
1245
|
-
onEnd((_e$touches$ = e2.touches[0]) == null ? void 0 : _e$touches$.clientX);
|
|
1246
|
-
}
|
|
1247
|
-
};
|
|
1248
|
-
const passiveIfSupported = passiveEventSupported() ? {
|
|
1249
|
-
passive: false
|
|
1250
|
-
} : false;
|
|
1251
|
-
if (isTouchStartEvent(e)) {
|
|
1252
|
-
contextDocument == null || contextDocument.addEventListener("touchmove", touchEvents.moveHandler, passiveIfSupported);
|
|
1253
|
-
contextDocument == null || contextDocument.addEventListener("touchend", touchEvents.upHandler, passiveIfSupported);
|
|
1254
|
-
} else {
|
|
1255
|
-
contextDocument == null || contextDocument.addEventListener("mousemove", mouseEvents.moveHandler, passiveIfSupported);
|
|
1256
|
-
contextDocument == null || contextDocument.addEventListener("mouseup", mouseEvents.upHandler, passiveIfSupported);
|
|
1257
|
-
}
|
|
1258
|
-
table.setColumnSizingInfo((old) => ({
|
|
1259
|
-
...old,
|
|
1260
|
-
startOffset: clientX,
|
|
1261
|
-
startSize,
|
|
1262
|
-
deltaOffset: 0,
|
|
1263
|
-
deltaPercentage: 0,
|
|
1264
|
-
columnSizingStart,
|
|
1265
|
-
isResizingColumn: column.id
|
|
1266
|
-
}));
|
|
1267
|
-
};
|
|
1268
|
-
};
|
|
1269
|
-
},
|
|
1270
|
-
createTable: (table) => {
|
|
1271
|
-
table.setColumnSizing = (updater) => table.options.onColumnSizingChange == null ? void 0 : table.options.onColumnSizingChange(updater);
|
|
1272
|
-
table.setColumnSizingInfo = (updater) => table.options.onColumnSizingInfoChange == null ? void 0 : table.options.onColumnSizingInfoChange(updater);
|
|
1273
|
-
table.resetColumnSizing = (defaultState) => {
|
|
1274
|
-
var _table$initialState$c;
|
|
1275
|
-
table.setColumnSizing(defaultState ? {} : (_table$initialState$c = table.initialState.columnSizing) != null ? _table$initialState$c : {});
|
|
1276
|
-
};
|
|
1277
|
-
table.resetHeaderSizeInfo = (defaultState) => {
|
|
1278
|
-
var _table$initialState$c2;
|
|
1279
|
-
table.setColumnSizingInfo(defaultState ? getDefaultColumnSizingInfoState() : (_table$initialState$c2 = table.initialState.columnSizingInfo) != null ? _table$initialState$c2 : getDefaultColumnSizingInfoState());
|
|
1280
|
-
};
|
|
1281
|
-
table.getTotalSize = () => {
|
|
1282
|
-
var _table$getHeaderGroup, _table$getHeaderGroup2;
|
|
1283
|
-
return (_table$getHeaderGroup = (_table$getHeaderGroup2 = table.getHeaderGroups()[0]) == null ? void 0 : _table$getHeaderGroup2.headers.reduce((sum2, header) => {
|
|
1284
|
-
return sum2 + header.getSize();
|
|
1285
|
-
}, 0)) != null ? _table$getHeaderGroup : 0;
|
|
1286
|
-
};
|
|
1287
|
-
table.getLeftTotalSize = () => {
|
|
1288
|
-
var _table$getLeftHeaderG, _table$getLeftHeaderG2;
|
|
1289
|
-
return (_table$getLeftHeaderG = (_table$getLeftHeaderG2 = table.getLeftHeaderGroups()[0]) == null ? void 0 : _table$getLeftHeaderG2.headers.reduce((sum2, header) => {
|
|
1290
|
-
return sum2 + header.getSize();
|
|
1291
|
-
}, 0)) != null ? _table$getLeftHeaderG : 0;
|
|
1292
|
-
};
|
|
1293
|
-
table.getCenterTotalSize = () => {
|
|
1294
|
-
var _table$getCenterHeade, _table$getCenterHeade2;
|
|
1295
|
-
return (_table$getCenterHeade = (_table$getCenterHeade2 = table.getCenterHeaderGroups()[0]) == null ? void 0 : _table$getCenterHeade2.headers.reduce((sum2, header) => {
|
|
1296
|
-
return sum2 + header.getSize();
|
|
1297
|
-
}, 0)) != null ? _table$getCenterHeade : 0;
|
|
1298
|
-
};
|
|
1299
|
-
table.getRightTotalSize = () => {
|
|
1300
|
-
var _table$getRightHeader, _table$getRightHeader2;
|
|
1301
|
-
return (_table$getRightHeader = (_table$getRightHeader2 = table.getRightHeaderGroups()[0]) == null ? void 0 : _table$getRightHeader2.headers.reduce((sum2, header) => {
|
|
1302
|
-
return sum2 + header.getSize();
|
|
1303
|
-
}, 0)) != null ? _table$getRightHeader : 0;
|
|
1304
|
-
};
|
|
1305
|
-
}
|
|
1306
|
-
};
|
|
1307
|
-
var passiveSupported = null;
|
|
1308
|
-
function passiveEventSupported() {
|
|
1309
|
-
if (typeof passiveSupported === "boolean") return passiveSupported;
|
|
1310
|
-
let supported = false;
|
|
1311
|
-
try {
|
|
1312
|
-
const options = {
|
|
1313
|
-
get passive() {
|
|
1314
|
-
supported = true;
|
|
1315
|
-
return false;
|
|
1316
|
-
}
|
|
1317
|
-
};
|
|
1318
|
-
const noop2 = () => {
|
|
1319
|
-
};
|
|
1320
|
-
window.addEventListener("test", noop2, options);
|
|
1321
|
-
window.removeEventListener("test", noop2);
|
|
1322
|
-
} catch (err) {
|
|
1323
|
-
supported = false;
|
|
1324
|
-
}
|
|
1325
|
-
passiveSupported = supported;
|
|
1326
|
-
return passiveSupported;
|
|
1327
|
-
}
|
|
1328
|
-
function isTouchStartEvent(e) {
|
|
1329
|
-
return e.type === "touchstart";
|
|
1330
|
-
}
|
|
1331
|
-
var ColumnVisibility = {
|
|
1332
|
-
getInitialState: (state) => {
|
|
1333
|
-
return {
|
|
1334
|
-
columnVisibility: {},
|
|
1335
|
-
...state
|
|
1336
|
-
};
|
|
1337
|
-
},
|
|
1338
|
-
getDefaultOptions: (table) => {
|
|
1339
|
-
return {
|
|
1340
|
-
onColumnVisibilityChange: makeStateUpdater("columnVisibility", table)
|
|
1341
|
-
};
|
|
1342
|
-
},
|
|
1343
|
-
createColumn: (column, table) => {
|
|
1344
|
-
column.toggleVisibility = (value) => {
|
|
1345
|
-
if (column.getCanHide()) {
|
|
1346
|
-
table.setColumnVisibility((old) => ({
|
|
1347
|
-
...old,
|
|
1348
|
-
[column.id]: value != null ? value : !column.getIsVisible()
|
|
1349
|
-
}));
|
|
1350
|
-
}
|
|
1351
|
-
};
|
|
1352
|
-
column.getIsVisible = () => {
|
|
1353
|
-
var _ref, _table$getState$colum;
|
|
1354
|
-
const childColumns = column.columns;
|
|
1355
|
-
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;
|
|
1356
|
-
};
|
|
1357
|
-
column.getCanHide = () => {
|
|
1358
|
-
var _column$columnDef$ena, _table$options$enable;
|
|
1359
|
-
return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableHiding) != null ? _table$options$enable : true);
|
|
1360
|
-
};
|
|
1361
|
-
column.getToggleVisibilityHandler = () => {
|
|
1362
|
-
return (e) => {
|
|
1363
|
-
column.toggleVisibility == null || column.toggleVisibility(e.target.checked);
|
|
1364
|
-
};
|
|
1365
|
-
};
|
|
1366
|
-
},
|
|
1367
|
-
createRow: (row, table) => {
|
|
1368
|
-
row._getAllVisibleCells = memo(() => [row.getAllCells(), table.getState().columnVisibility], (cells) => {
|
|
1369
|
-
return cells.filter((cell) => cell.column.getIsVisible());
|
|
1370
|
-
}, getMemoOptions(table.options, "debugRows", "_getAllVisibleCells"));
|
|
1371
|
-
row.getVisibleCells = memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], getMemoOptions(table.options, "debugRows", "getVisibleCells"));
|
|
1372
|
-
},
|
|
1373
|
-
createTable: (table) => {
|
|
1374
|
-
const makeVisibleColumnsMethod = (key, getColumns) => {
|
|
1375
|
-
return memo(() => [getColumns(), getColumns().filter((d) => d.getIsVisible()).map((d) => d.id).join("_")], (columns) => {
|
|
1376
|
-
return columns.filter((d) => d.getIsVisible == null ? void 0 : d.getIsVisible());
|
|
1377
|
-
}, getMemoOptions(table.options, "debugColumns", key));
|
|
1378
|
-
};
|
|
1379
|
-
table.getVisibleFlatColumns = makeVisibleColumnsMethod("getVisibleFlatColumns", () => table.getAllFlatColumns());
|
|
1380
|
-
table.getVisibleLeafColumns = makeVisibleColumnsMethod("getVisibleLeafColumns", () => table.getAllLeafColumns());
|
|
1381
|
-
table.getLeftVisibleLeafColumns = makeVisibleColumnsMethod("getLeftVisibleLeafColumns", () => table.getLeftLeafColumns());
|
|
1382
|
-
table.getRightVisibleLeafColumns = makeVisibleColumnsMethod("getRightVisibleLeafColumns", () => table.getRightLeafColumns());
|
|
1383
|
-
table.getCenterVisibleLeafColumns = makeVisibleColumnsMethod("getCenterVisibleLeafColumns", () => table.getCenterLeafColumns());
|
|
1384
|
-
table.setColumnVisibility = (updater) => table.options.onColumnVisibilityChange == null ? void 0 : table.options.onColumnVisibilityChange(updater);
|
|
1385
|
-
table.resetColumnVisibility = (defaultState) => {
|
|
1386
|
-
var _table$initialState$c;
|
|
1387
|
-
table.setColumnVisibility(defaultState ? {} : (_table$initialState$c = table.initialState.columnVisibility) != null ? _table$initialState$c : {});
|
|
1388
|
-
};
|
|
1389
|
-
table.toggleAllColumnsVisible = (value) => {
|
|
1390
|
-
var _value;
|
|
1391
|
-
value = (_value = value) != null ? _value : !table.getIsAllColumnsVisible();
|
|
1392
|
-
table.setColumnVisibility(table.getAllLeafColumns().reduce((obj, column) => ({
|
|
1393
|
-
...obj,
|
|
1394
|
-
[column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
|
|
1395
|
-
}), {}));
|
|
1396
|
-
};
|
|
1397
|
-
table.getIsAllColumnsVisible = () => !table.getAllLeafColumns().some((column) => !(column.getIsVisible != null && column.getIsVisible()));
|
|
1398
|
-
table.getIsSomeColumnsVisible = () => table.getAllLeafColumns().some((column) => column.getIsVisible == null ? void 0 : column.getIsVisible());
|
|
1399
|
-
table.getToggleAllColumnsVisibilityHandler = () => {
|
|
1400
|
-
return (e) => {
|
|
1401
|
-
var _target;
|
|
1402
|
-
table.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
|
|
1403
|
-
};
|
|
1404
|
-
};
|
|
1405
|
-
}
|
|
1406
|
-
};
|
|
1407
|
-
function _getVisibleLeafColumns(table, position) {
|
|
1408
|
-
return !position ? table.getVisibleLeafColumns() : position === "center" ? table.getCenterVisibleLeafColumns() : position === "left" ? table.getLeftVisibleLeafColumns() : table.getRightVisibleLeafColumns();
|
|
1409
|
-
}
|
|
1410
|
-
var GlobalFaceting = {
|
|
1411
|
-
createTable: (table) => {
|
|
1412
|
-
table._getGlobalFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, "__global__");
|
|
1413
|
-
table.getGlobalFacetedRowModel = () => {
|
|
1414
|
-
if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {
|
|
1415
|
-
return table.getPreFilteredRowModel();
|
|
1416
|
-
}
|
|
1417
|
-
return table._getGlobalFacetedRowModel();
|
|
1418
|
-
};
|
|
1419
|
-
table._getGlobalFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, "__global__");
|
|
1420
|
-
table.getGlobalFacetedUniqueValues = () => {
|
|
1421
|
-
if (!table._getGlobalFacetedUniqueValues) {
|
|
1422
|
-
return /* @__PURE__ */ new Map();
|
|
1423
|
-
}
|
|
1424
|
-
return table._getGlobalFacetedUniqueValues();
|
|
1425
|
-
};
|
|
1426
|
-
table._getGlobalFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, "__global__");
|
|
1427
|
-
table.getGlobalFacetedMinMaxValues = () => {
|
|
1428
|
-
if (!table._getGlobalFacetedMinMaxValues) {
|
|
1429
|
-
return;
|
|
1430
|
-
}
|
|
1431
|
-
return table._getGlobalFacetedMinMaxValues();
|
|
1432
|
-
};
|
|
1433
|
-
}
|
|
1434
|
-
};
|
|
1435
|
-
var GlobalFiltering = {
|
|
1436
|
-
getInitialState: (state) => {
|
|
1437
|
-
return {
|
|
1438
|
-
globalFilter: void 0,
|
|
1439
|
-
...state
|
|
1440
|
-
};
|
|
1441
|
-
},
|
|
1442
|
-
getDefaultOptions: (table) => {
|
|
1443
|
-
return {
|
|
1444
|
-
onGlobalFilterChange: makeStateUpdater("globalFilter", table),
|
|
1445
|
-
globalFilterFn: "auto",
|
|
1446
|
-
getColumnCanGlobalFilter: (column) => {
|
|
1447
|
-
var _table$getCoreRowMode;
|
|
1448
|
-
const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) == null || (_table$getCoreRowMode = _table$getCoreRowMode._getAllCellsByColumnId()[column.id]) == null ? void 0 : _table$getCoreRowMode.getValue();
|
|
1449
|
-
return typeof value === "string" || typeof value === "number";
|
|
1450
|
-
}
|
|
1451
|
-
};
|
|
1452
|
-
},
|
|
1453
|
-
createColumn: (column, table) => {
|
|
1454
|
-
column.getCanGlobalFilter = () => {
|
|
1455
|
-
var _column$columnDef$ena, _table$options$enable, _table$options$enable2, _table$options$getCol;
|
|
1456
|
-
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;
|
|
1457
|
-
};
|
|
1458
|
-
},
|
|
1459
|
-
createTable: (table) => {
|
|
1460
|
-
table.getGlobalAutoFilterFn = () => {
|
|
1461
|
-
return filterFns.includesString;
|
|
1462
|
-
};
|
|
1463
|
-
table.getGlobalFilterFn = () => {
|
|
1464
|
-
var _table$options$filter, _table$options$filter2;
|
|
1465
|
-
const {
|
|
1466
|
-
globalFilterFn
|
|
1467
|
-
} = table.options;
|
|
1468
|
-
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];
|
|
1469
|
-
};
|
|
1470
|
-
table.setGlobalFilter = (updater) => {
|
|
1471
|
-
table.options.onGlobalFilterChange == null || table.options.onGlobalFilterChange(updater);
|
|
1472
|
-
};
|
|
1473
|
-
table.resetGlobalFilter = (defaultState) => {
|
|
1474
|
-
table.setGlobalFilter(defaultState ? void 0 : table.initialState.globalFilter);
|
|
1475
|
-
};
|
|
1476
|
-
}
|
|
1477
|
-
};
|
|
1478
|
-
var RowExpanding = {
|
|
1479
|
-
getInitialState: (state) => {
|
|
1480
|
-
return {
|
|
1481
|
-
expanded: {},
|
|
1482
|
-
...state
|
|
1483
|
-
};
|
|
1484
|
-
},
|
|
1485
|
-
getDefaultOptions: (table) => {
|
|
1486
|
-
return {
|
|
1487
|
-
onExpandedChange: makeStateUpdater("expanded", table),
|
|
1488
|
-
paginateExpandedRows: true
|
|
1489
|
-
};
|
|
1490
|
-
},
|
|
1491
|
-
createTable: (table) => {
|
|
1492
|
-
let registered = false;
|
|
1493
|
-
let queued = false;
|
|
1494
|
-
table._autoResetExpanded = () => {
|
|
1495
|
-
var _ref, _table$options$autoRe;
|
|
1496
|
-
if (!registered) {
|
|
1497
|
-
table._queue(() => {
|
|
1498
|
-
registered = true;
|
|
1499
|
-
});
|
|
1500
|
-
return;
|
|
1501
|
-
}
|
|
1502
|
-
if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetExpanded) != null ? _ref : !table.options.manualExpanding) {
|
|
1503
|
-
if (queued) return;
|
|
1504
|
-
queued = true;
|
|
1505
|
-
table._queue(() => {
|
|
1506
|
-
table.resetExpanded();
|
|
1507
|
-
queued = false;
|
|
1508
|
-
});
|
|
1509
|
-
}
|
|
1510
|
-
};
|
|
1511
|
-
table.setExpanded = (updater) => table.options.onExpandedChange == null ? void 0 : table.options.onExpandedChange(updater);
|
|
1512
|
-
table.toggleAllRowsExpanded = (expanded) => {
|
|
1513
|
-
if (expanded != null ? expanded : !table.getIsAllRowsExpanded()) {
|
|
1514
|
-
table.setExpanded(true);
|
|
1515
|
-
} else {
|
|
1516
|
-
table.setExpanded({});
|
|
1517
|
-
}
|
|
1518
|
-
};
|
|
1519
|
-
table.resetExpanded = (defaultState) => {
|
|
1520
|
-
var _table$initialState$e, _table$initialState;
|
|
1521
|
-
table.setExpanded(defaultState ? {} : (_table$initialState$e = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.expanded) != null ? _table$initialState$e : {});
|
|
1522
|
-
};
|
|
1523
|
-
table.getCanSomeRowsExpand = () => {
|
|
1524
|
-
return table.getPrePaginationRowModel().flatRows.some((row) => row.getCanExpand());
|
|
1525
|
-
};
|
|
1526
|
-
table.getToggleAllRowsExpandedHandler = () => {
|
|
1527
|
-
return (e) => {
|
|
1528
|
-
e.persist == null || e.persist();
|
|
1529
|
-
table.toggleAllRowsExpanded();
|
|
1530
|
-
};
|
|
1531
|
-
};
|
|
1532
|
-
table.getIsSomeRowsExpanded = () => {
|
|
1533
|
-
const expanded = table.getState().expanded;
|
|
1534
|
-
return expanded === true || Object.values(expanded).some(Boolean);
|
|
1535
|
-
};
|
|
1536
|
-
table.getIsAllRowsExpanded = () => {
|
|
1537
|
-
const expanded = table.getState().expanded;
|
|
1538
|
-
if (typeof expanded === "boolean") {
|
|
1539
|
-
return expanded === true;
|
|
1540
|
-
}
|
|
1541
|
-
if (!Object.keys(expanded).length) {
|
|
1542
|
-
return false;
|
|
1543
|
-
}
|
|
1544
|
-
if (table.getRowModel().flatRows.some((row) => !row.getIsExpanded())) {
|
|
1545
|
-
return false;
|
|
1546
|
-
}
|
|
1547
|
-
return true;
|
|
1548
|
-
};
|
|
1549
|
-
table.getExpandedDepth = () => {
|
|
1550
|
-
let maxDepth = 0;
|
|
1551
|
-
const rowIds = table.getState().expanded === true ? Object.keys(table.getRowModel().rowsById) : Object.keys(table.getState().expanded);
|
|
1552
|
-
rowIds.forEach((id) => {
|
|
1553
|
-
const splitId = id.split(".");
|
|
1554
|
-
maxDepth = Math.max(maxDepth, splitId.length);
|
|
1555
|
-
});
|
|
1556
|
-
return maxDepth;
|
|
1557
|
-
};
|
|
1558
|
-
table.getPreExpandedRowModel = () => table.getSortedRowModel();
|
|
1559
|
-
table.getExpandedRowModel = () => {
|
|
1560
|
-
if (!table._getExpandedRowModel && table.options.getExpandedRowModel) {
|
|
1561
|
-
table._getExpandedRowModel = table.options.getExpandedRowModel(table);
|
|
1562
|
-
}
|
|
1563
|
-
if (table.options.manualExpanding || !table._getExpandedRowModel) {
|
|
1564
|
-
return table.getPreExpandedRowModel();
|
|
1565
|
-
}
|
|
1566
|
-
return table._getExpandedRowModel();
|
|
1567
|
-
};
|
|
1568
|
-
},
|
|
1569
|
-
createRow: (row, table) => {
|
|
1570
|
-
row.toggleExpanded = (expanded) => {
|
|
1571
|
-
table.setExpanded((old) => {
|
|
1572
|
-
var _expanded;
|
|
1573
|
-
const exists = old === true ? true : !!(old != null && old[row.id]);
|
|
1574
|
-
let oldExpanded = {};
|
|
1575
|
-
if (old === true) {
|
|
1576
|
-
Object.keys(table.getRowModel().rowsById).forEach((rowId) => {
|
|
1577
|
-
oldExpanded[rowId] = true;
|
|
1578
|
-
});
|
|
1579
|
-
} else {
|
|
1580
|
-
oldExpanded = old;
|
|
1581
|
-
}
|
|
1582
|
-
expanded = (_expanded = expanded) != null ? _expanded : !exists;
|
|
1583
|
-
if (!exists && expanded) {
|
|
1584
|
-
return {
|
|
1585
|
-
...oldExpanded,
|
|
1586
|
-
[row.id]: true
|
|
1587
|
-
};
|
|
1588
|
-
}
|
|
1589
|
-
if (exists && !expanded) {
|
|
1590
|
-
const {
|
|
1591
|
-
[row.id]: _,
|
|
1592
|
-
...rest
|
|
1593
|
-
} = oldExpanded;
|
|
1594
|
-
return rest;
|
|
1595
|
-
}
|
|
1596
|
-
return old;
|
|
1597
|
-
});
|
|
1598
|
-
};
|
|
1599
|
-
row.getIsExpanded = () => {
|
|
1600
|
-
var _table$options$getIsR;
|
|
1601
|
-
const expanded = table.getState().expanded;
|
|
1602
|
-
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]));
|
|
1603
|
-
};
|
|
1604
|
-
row.getCanExpand = () => {
|
|
1605
|
-
var _table$options$getRow, _table$options$enable, _row$subRows;
|
|
1606
|
-
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);
|
|
1607
|
-
};
|
|
1608
|
-
row.getIsAllParentsExpanded = () => {
|
|
1609
|
-
let isFullyExpanded = true;
|
|
1610
|
-
let currentRow = row;
|
|
1611
|
-
while (isFullyExpanded && currentRow.parentId) {
|
|
1612
|
-
currentRow = table.getRow(currentRow.parentId, true);
|
|
1613
|
-
isFullyExpanded = currentRow.getIsExpanded();
|
|
1614
|
-
}
|
|
1615
|
-
return isFullyExpanded;
|
|
1616
|
-
};
|
|
1617
|
-
row.getToggleExpandedHandler = () => {
|
|
1618
|
-
const canExpand = row.getCanExpand();
|
|
1619
|
-
return () => {
|
|
1620
|
-
if (!canExpand) return;
|
|
1621
|
-
row.toggleExpanded();
|
|
1622
|
-
};
|
|
1623
|
-
};
|
|
1624
|
-
}
|
|
1625
|
-
};
|
|
1626
|
-
var defaultPageIndex = 0;
|
|
1627
|
-
var defaultPageSize = 10;
|
|
1628
|
-
var getDefaultPaginationState = () => ({
|
|
1629
|
-
pageIndex: defaultPageIndex,
|
|
1630
|
-
pageSize: defaultPageSize
|
|
1631
|
-
});
|
|
1632
|
-
var RowPagination = {
|
|
1633
|
-
getInitialState: (state) => {
|
|
1634
|
-
return {
|
|
1635
|
-
...state,
|
|
1636
|
-
pagination: {
|
|
1637
|
-
...getDefaultPaginationState(),
|
|
1638
|
-
...state == null ? void 0 : state.pagination
|
|
1639
|
-
}
|
|
1640
|
-
};
|
|
1641
|
-
},
|
|
1642
|
-
getDefaultOptions: (table) => {
|
|
1643
|
-
return {
|
|
1644
|
-
onPaginationChange: makeStateUpdater("pagination", table)
|
|
1645
|
-
};
|
|
1646
|
-
},
|
|
1647
|
-
createTable: (table) => {
|
|
1648
|
-
let registered = false;
|
|
1649
|
-
let queued = false;
|
|
1650
|
-
table._autoResetPageIndex = () => {
|
|
1651
|
-
var _ref, _table$options$autoRe;
|
|
1652
|
-
if (!registered) {
|
|
1653
|
-
table._queue(() => {
|
|
1654
|
-
registered = true;
|
|
1655
|
-
});
|
|
1656
|
-
return;
|
|
1657
|
-
}
|
|
1658
|
-
if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetPageIndex) != null ? _ref : !table.options.manualPagination) {
|
|
1659
|
-
if (queued) return;
|
|
1660
|
-
queued = true;
|
|
1661
|
-
table._queue(() => {
|
|
1662
|
-
table.resetPageIndex();
|
|
1663
|
-
queued = false;
|
|
1664
|
-
});
|
|
1665
|
-
}
|
|
1666
|
-
};
|
|
1667
|
-
table.setPagination = (updater) => {
|
|
1668
|
-
const safeUpdater = (old) => {
|
|
1669
|
-
let newState = functionalUpdate(updater, old);
|
|
1670
|
-
return newState;
|
|
1671
|
-
};
|
|
1672
|
-
return table.options.onPaginationChange == null ? void 0 : table.options.onPaginationChange(safeUpdater);
|
|
1673
|
-
};
|
|
1674
|
-
table.resetPagination = (defaultState) => {
|
|
1675
|
-
var _table$initialState$p;
|
|
1676
|
-
table.setPagination(defaultState ? getDefaultPaginationState() : (_table$initialState$p = table.initialState.pagination) != null ? _table$initialState$p : getDefaultPaginationState());
|
|
1677
|
-
};
|
|
1678
|
-
table.setPageIndex = (updater) => {
|
|
1679
|
-
table.setPagination((old) => {
|
|
1680
|
-
let pageIndex = functionalUpdate(updater, old.pageIndex);
|
|
1681
|
-
const maxPageIndex = typeof table.options.pageCount === "undefined" || table.options.pageCount === -1 ? Number.MAX_SAFE_INTEGER : table.options.pageCount - 1;
|
|
1682
|
-
pageIndex = Math.max(0, Math.min(pageIndex, maxPageIndex));
|
|
1683
|
-
return {
|
|
1684
|
-
...old,
|
|
1685
|
-
pageIndex
|
|
1686
|
-
};
|
|
1687
|
-
});
|
|
1688
|
-
};
|
|
1689
|
-
table.resetPageIndex = (defaultState) => {
|
|
1690
|
-
var _table$initialState$p2, _table$initialState;
|
|
1691
|
-
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);
|
|
1692
|
-
};
|
|
1693
|
-
table.resetPageSize = (defaultState) => {
|
|
1694
|
-
var _table$initialState$p3, _table$initialState2;
|
|
1695
|
-
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);
|
|
1696
|
-
};
|
|
1697
|
-
table.setPageSize = (updater) => {
|
|
1698
|
-
table.setPagination((old) => {
|
|
1699
|
-
const pageSize = Math.max(1, functionalUpdate(updater, old.pageSize));
|
|
1700
|
-
const topRowIndex = old.pageSize * old.pageIndex;
|
|
1701
|
-
const pageIndex = Math.floor(topRowIndex / pageSize);
|
|
1702
|
-
return {
|
|
1703
|
-
...old,
|
|
1704
|
-
pageIndex,
|
|
1705
|
-
pageSize
|
|
1706
|
-
};
|
|
1707
|
-
});
|
|
1708
|
-
};
|
|
1709
|
-
table.setPageCount = (updater) => table.setPagination((old) => {
|
|
1710
|
-
var _table$options$pageCo;
|
|
1711
|
-
let newPageCount = functionalUpdate(updater, (_table$options$pageCo = table.options.pageCount) != null ? _table$options$pageCo : -1);
|
|
1712
|
-
if (typeof newPageCount === "number") {
|
|
1713
|
-
newPageCount = Math.max(-1, newPageCount);
|
|
1714
|
-
}
|
|
1715
|
-
return {
|
|
1716
|
-
...old,
|
|
1717
|
-
pageCount: newPageCount
|
|
1718
|
-
};
|
|
1719
|
-
});
|
|
1720
|
-
table.getPageOptions = memo(() => [table.getPageCount()], (pageCount) => {
|
|
1721
|
-
let pageOptions = [];
|
|
1722
|
-
if (pageCount && pageCount > 0) {
|
|
1723
|
-
pageOptions = [...new Array(pageCount)].fill(null).map((_, i) => i);
|
|
1724
|
-
}
|
|
1725
|
-
return pageOptions;
|
|
1726
|
-
}, getMemoOptions(table.options, "debugTable", "getPageOptions"));
|
|
1727
|
-
table.getCanPreviousPage = () => table.getState().pagination.pageIndex > 0;
|
|
1728
|
-
table.getCanNextPage = () => {
|
|
1729
|
-
const {
|
|
1730
|
-
pageIndex
|
|
1731
|
-
} = table.getState().pagination;
|
|
1732
|
-
const pageCount = table.getPageCount();
|
|
1733
|
-
if (pageCount === -1) {
|
|
1734
|
-
return true;
|
|
1735
|
-
}
|
|
1736
|
-
if (pageCount === 0) {
|
|
1737
|
-
return false;
|
|
1738
|
-
}
|
|
1739
|
-
return pageIndex < pageCount - 1;
|
|
1740
|
-
};
|
|
1741
|
-
table.previousPage = () => {
|
|
1742
|
-
return table.setPageIndex((old) => old - 1);
|
|
1743
|
-
};
|
|
1744
|
-
table.nextPage = () => {
|
|
1745
|
-
return table.setPageIndex((old) => {
|
|
1746
|
-
return old + 1;
|
|
1747
|
-
});
|
|
1748
|
-
};
|
|
1749
|
-
table.firstPage = () => {
|
|
1750
|
-
return table.setPageIndex(0);
|
|
1751
|
-
};
|
|
1752
|
-
table.lastPage = () => {
|
|
1753
|
-
return table.setPageIndex(table.getPageCount() - 1);
|
|
1754
|
-
};
|
|
1755
|
-
table.getPrePaginationRowModel = () => table.getExpandedRowModel();
|
|
1756
|
-
table.getPaginationRowModel = () => {
|
|
1757
|
-
if (!table._getPaginationRowModel && table.options.getPaginationRowModel) {
|
|
1758
|
-
table._getPaginationRowModel = table.options.getPaginationRowModel(table);
|
|
1759
|
-
}
|
|
1760
|
-
if (table.options.manualPagination || !table._getPaginationRowModel) {
|
|
1761
|
-
return table.getPrePaginationRowModel();
|
|
1762
|
-
}
|
|
1763
|
-
return table._getPaginationRowModel();
|
|
1764
|
-
};
|
|
1765
|
-
table.getPageCount = () => {
|
|
1766
|
-
var _table$options$pageCo2;
|
|
1767
|
-
return (_table$options$pageCo2 = table.options.pageCount) != null ? _table$options$pageCo2 : Math.ceil(table.getRowCount() / table.getState().pagination.pageSize);
|
|
1768
|
-
};
|
|
1769
|
-
table.getRowCount = () => {
|
|
1770
|
-
var _table$options$rowCou;
|
|
1771
|
-
return (_table$options$rowCou = table.options.rowCount) != null ? _table$options$rowCou : table.getPrePaginationRowModel().rows.length;
|
|
1772
|
-
};
|
|
1773
|
-
}
|
|
1774
|
-
};
|
|
1775
|
-
var getDefaultRowPinningState = () => ({
|
|
1776
|
-
top: [],
|
|
1777
|
-
bottom: []
|
|
1778
|
-
});
|
|
1779
|
-
var RowPinning = {
|
|
1780
|
-
getInitialState: (state) => {
|
|
1781
|
-
return {
|
|
1782
|
-
rowPinning: getDefaultRowPinningState(),
|
|
1783
|
-
...state
|
|
1784
|
-
};
|
|
1785
|
-
},
|
|
1786
|
-
getDefaultOptions: (table) => {
|
|
1787
|
-
return {
|
|
1788
|
-
onRowPinningChange: makeStateUpdater("rowPinning", table)
|
|
1789
|
-
};
|
|
1790
|
-
},
|
|
1791
|
-
createRow: (row, table) => {
|
|
1792
|
-
row.pin = (position, includeLeafRows, includeParentRows) => {
|
|
1793
|
-
const leafRowIds = includeLeafRows ? row.getLeafRows().map((_ref) => {
|
|
1794
|
-
let {
|
|
1795
|
-
id
|
|
1796
|
-
} = _ref;
|
|
1797
|
-
return id;
|
|
1798
|
-
}) : [];
|
|
1799
|
-
const parentRowIds = includeParentRows ? row.getParentRows().map((_ref2) => {
|
|
1800
|
-
let {
|
|
1801
|
-
id
|
|
1802
|
-
} = _ref2;
|
|
1803
|
-
return id;
|
|
1804
|
-
}) : [];
|
|
1805
|
-
const rowIds = /* @__PURE__ */ new Set([...parentRowIds, row.id, ...leafRowIds]);
|
|
1806
|
-
table.setRowPinning((old) => {
|
|
1807
|
-
var _old$top3, _old$bottom3;
|
|
1808
|
-
if (position === "bottom") {
|
|
1809
|
-
var _old$top, _old$bottom;
|
|
1810
|
-
return {
|
|
1811
|
-
top: ((_old$top = old == null ? void 0 : old.top) != null ? _old$top : []).filter((d) => !(rowIds != null && rowIds.has(d))),
|
|
1812
|
-
bottom: [...((_old$bottom = old == null ? void 0 : old.bottom) != null ? _old$bottom : []).filter((d) => !(rowIds != null && rowIds.has(d))), ...Array.from(rowIds)]
|
|
1813
|
-
};
|
|
1814
|
-
}
|
|
1815
|
-
if (position === "top") {
|
|
1816
|
-
var _old$top2, _old$bottom2;
|
|
1817
|
-
return {
|
|
1818
|
-
top: [...((_old$top2 = old == null ? void 0 : old.top) != null ? _old$top2 : []).filter((d) => !(rowIds != null && rowIds.has(d))), ...Array.from(rowIds)],
|
|
1819
|
-
bottom: ((_old$bottom2 = old == null ? void 0 : old.bottom) != null ? _old$bottom2 : []).filter((d) => !(rowIds != null && rowIds.has(d)))
|
|
1820
|
-
};
|
|
1821
|
-
}
|
|
1822
|
-
return {
|
|
1823
|
-
top: ((_old$top3 = old == null ? void 0 : old.top) != null ? _old$top3 : []).filter((d) => !(rowIds != null && rowIds.has(d))),
|
|
1824
|
-
bottom: ((_old$bottom3 = old == null ? void 0 : old.bottom) != null ? _old$bottom3 : []).filter((d) => !(rowIds != null && rowIds.has(d)))
|
|
1825
|
-
};
|
|
1826
|
-
});
|
|
1827
|
-
};
|
|
1828
|
-
row.getCanPin = () => {
|
|
1829
|
-
var _ref3;
|
|
1830
|
-
const {
|
|
1831
|
-
enableRowPinning,
|
|
1832
|
-
enablePinning
|
|
1833
|
-
} = table.options;
|
|
1834
|
-
if (typeof enableRowPinning === "function") {
|
|
1835
|
-
return enableRowPinning(row);
|
|
1836
|
-
}
|
|
1837
|
-
return (_ref3 = enableRowPinning != null ? enableRowPinning : enablePinning) != null ? _ref3 : true;
|
|
1838
|
-
};
|
|
1839
|
-
row.getIsPinned = () => {
|
|
1840
|
-
const rowIds = [row.id];
|
|
1841
|
-
const {
|
|
1842
|
-
top,
|
|
1843
|
-
bottom
|
|
1844
|
-
} = table.getState().rowPinning;
|
|
1845
|
-
const isTop = rowIds.some((d) => top == null ? void 0 : top.includes(d));
|
|
1846
|
-
const isBottom = rowIds.some((d) => bottom == null ? void 0 : bottom.includes(d));
|
|
1847
|
-
return isTop ? "top" : isBottom ? "bottom" : false;
|
|
1848
|
-
};
|
|
1849
|
-
row.getPinnedIndex = () => {
|
|
1850
|
-
var _ref4, _visiblePinnedRowIds$;
|
|
1851
|
-
const position = row.getIsPinned();
|
|
1852
|
-
if (!position) return -1;
|
|
1853
|
-
const visiblePinnedRowIds = (_ref4 = position === "top" ? table.getTopRows() : table.getBottomRows()) == null ? void 0 : _ref4.map((_ref5) => {
|
|
1854
|
-
let {
|
|
1855
|
-
id
|
|
1856
|
-
} = _ref5;
|
|
1857
|
-
return id;
|
|
1858
|
-
});
|
|
1859
|
-
return (_visiblePinnedRowIds$ = visiblePinnedRowIds == null ? void 0 : visiblePinnedRowIds.indexOf(row.id)) != null ? _visiblePinnedRowIds$ : -1;
|
|
1860
|
-
};
|
|
1861
|
-
},
|
|
1862
|
-
createTable: (table) => {
|
|
1863
|
-
table.setRowPinning = (updater) => table.options.onRowPinningChange == null ? void 0 : table.options.onRowPinningChange(updater);
|
|
1864
|
-
table.resetRowPinning = (defaultState) => {
|
|
1865
|
-
var _table$initialState$r, _table$initialState;
|
|
1866
|
-
return table.setRowPinning(defaultState ? getDefaultRowPinningState() : (_table$initialState$r = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.rowPinning) != null ? _table$initialState$r : getDefaultRowPinningState());
|
|
1867
|
-
};
|
|
1868
|
-
table.getIsSomeRowsPinned = (position) => {
|
|
1869
|
-
var _pinningState$positio;
|
|
1870
|
-
const pinningState = table.getState().rowPinning;
|
|
1871
|
-
if (!position) {
|
|
1872
|
-
var _pinningState$top, _pinningState$bottom;
|
|
1873
|
-
return Boolean(((_pinningState$top = pinningState.top) == null ? void 0 : _pinningState$top.length) || ((_pinningState$bottom = pinningState.bottom) == null ? void 0 : _pinningState$bottom.length));
|
|
1874
|
-
}
|
|
1875
|
-
return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
|
|
1876
|
-
};
|
|
1877
|
-
table._getPinnedRows = (visibleRows, pinnedRowIds, position) => {
|
|
1878
|
-
var _table$options$keepPi;
|
|
1879
|
-
const rows = ((_table$options$keepPi = table.options.keepPinnedRows) != null ? _table$options$keepPi : true) ? (
|
|
1880
|
-
//get all rows that are pinned even if they would not be otherwise visible
|
|
1881
|
-
//account for expanded parent rows, but not pagination or filtering
|
|
1882
|
-
(pinnedRowIds != null ? pinnedRowIds : []).map((rowId) => {
|
|
1883
|
-
const row = table.getRow(rowId, true);
|
|
1884
|
-
return row.getIsAllParentsExpanded() ? row : null;
|
|
1885
|
-
})
|
|
1886
|
-
) : (
|
|
1887
|
-
//else get only visible rows that are pinned
|
|
1888
|
-
(pinnedRowIds != null ? pinnedRowIds : []).map((rowId) => visibleRows.find((row) => row.id === rowId))
|
|
1889
|
-
);
|
|
1890
|
-
return rows.filter(Boolean).map((d) => ({
|
|
1891
|
-
...d,
|
|
1892
|
-
position
|
|
1893
|
-
}));
|
|
1894
|
-
};
|
|
1895
|
-
table.getTopRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.top], (allRows, topPinnedRowIds) => table._getPinnedRows(allRows, topPinnedRowIds, "top"), getMemoOptions(table.options, "debugRows", "getTopRows"));
|
|
1896
|
-
table.getBottomRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.bottom], (allRows, bottomPinnedRowIds) => table._getPinnedRows(allRows, bottomPinnedRowIds, "bottom"), getMemoOptions(table.options, "debugRows", "getBottomRows"));
|
|
1897
|
-
table.getCenterRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.top, table.getState().rowPinning.bottom], (allRows, top, bottom) => {
|
|
1898
|
-
const topAndBottom = /* @__PURE__ */ new Set([...top != null ? top : [], ...bottom != null ? bottom : []]);
|
|
1899
|
-
return allRows.filter((d) => !topAndBottom.has(d.id));
|
|
1900
|
-
}, getMemoOptions(table.options, "debugRows", "getCenterRows"));
|
|
1901
|
-
}
|
|
1902
|
-
};
|
|
1903
|
-
var RowSelection = {
|
|
1904
|
-
getInitialState: (state) => {
|
|
1905
|
-
return {
|
|
1906
|
-
rowSelection: {},
|
|
1907
|
-
...state
|
|
1908
|
-
};
|
|
1909
|
-
},
|
|
1910
|
-
getDefaultOptions: (table) => {
|
|
1911
|
-
return {
|
|
1912
|
-
onRowSelectionChange: makeStateUpdater("rowSelection", table),
|
|
1913
|
-
enableRowSelection: true,
|
|
1914
|
-
enableMultiRowSelection: true,
|
|
1915
|
-
enableSubRowSelection: true
|
|
1916
|
-
// enableGroupingRowSelection: false,
|
|
1917
|
-
// isAdditiveSelectEvent: (e: unknown) => !!e.metaKey,
|
|
1918
|
-
// isInclusiveSelectEvent: (e: unknown) => !!e.shiftKey,
|
|
1919
|
-
};
|
|
1920
|
-
},
|
|
1921
|
-
createTable: (table) => {
|
|
1922
|
-
table.setRowSelection = (updater) => table.options.onRowSelectionChange == null ? void 0 : table.options.onRowSelectionChange(updater);
|
|
1923
|
-
table.resetRowSelection = (defaultState) => {
|
|
1924
|
-
var _table$initialState$r;
|
|
1925
|
-
return table.setRowSelection(defaultState ? {} : (_table$initialState$r = table.initialState.rowSelection) != null ? _table$initialState$r : {});
|
|
1926
|
-
};
|
|
1927
|
-
table.toggleAllRowsSelected = (value) => {
|
|
1928
|
-
table.setRowSelection((old) => {
|
|
1929
|
-
value = typeof value !== "undefined" ? value : !table.getIsAllRowsSelected();
|
|
1930
|
-
const rowSelection = {
|
|
1931
|
-
...old
|
|
1932
|
-
};
|
|
1933
|
-
const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows;
|
|
1934
|
-
if (value) {
|
|
1935
|
-
preGroupedFlatRows.forEach((row) => {
|
|
1936
|
-
if (!row.getCanSelect()) {
|
|
1937
|
-
return;
|
|
1938
|
-
}
|
|
1939
|
-
rowSelection[row.id] = true;
|
|
1940
|
-
});
|
|
1941
|
-
} else {
|
|
1942
|
-
preGroupedFlatRows.forEach((row) => {
|
|
1943
|
-
delete rowSelection[row.id];
|
|
1944
|
-
});
|
|
1945
|
-
}
|
|
1946
|
-
return rowSelection;
|
|
1947
|
-
});
|
|
1948
|
-
};
|
|
1949
|
-
table.toggleAllPageRowsSelected = (value) => table.setRowSelection((old) => {
|
|
1950
|
-
const resolvedValue = typeof value !== "undefined" ? value : !table.getIsAllPageRowsSelected();
|
|
1951
|
-
const rowSelection = {
|
|
1952
|
-
...old
|
|
1953
|
-
};
|
|
1954
|
-
table.getRowModel().rows.forEach((row) => {
|
|
1955
|
-
mutateRowIsSelected(rowSelection, row.id, resolvedValue, true, table);
|
|
1956
|
-
});
|
|
1957
|
-
return rowSelection;
|
|
1958
|
-
});
|
|
1959
|
-
table.getPreSelectedRowModel = () => table.getCoreRowModel();
|
|
1960
|
-
table.getSelectedRowModel = memo(() => [table.getState().rowSelection, table.getCoreRowModel()], (rowSelection, rowModel) => {
|
|
1961
|
-
if (!Object.keys(rowSelection).length) {
|
|
1962
|
-
return {
|
|
1963
|
-
rows: [],
|
|
1964
|
-
flatRows: [],
|
|
1965
|
-
rowsById: {}
|
|
1966
|
-
};
|
|
1967
|
-
}
|
|
1968
|
-
return selectRowsFn(table, rowModel);
|
|
1969
|
-
}, getMemoOptions(table.options, "debugTable", "getSelectedRowModel"));
|
|
1970
|
-
table.getFilteredSelectedRowModel = memo(() => [table.getState().rowSelection, table.getFilteredRowModel()], (rowSelection, rowModel) => {
|
|
1971
|
-
if (!Object.keys(rowSelection).length) {
|
|
1972
|
-
return {
|
|
1973
|
-
rows: [],
|
|
1974
|
-
flatRows: [],
|
|
1975
|
-
rowsById: {}
|
|
1976
|
-
};
|
|
1977
|
-
}
|
|
1978
|
-
return selectRowsFn(table, rowModel);
|
|
1979
|
-
}, getMemoOptions(table.options, "debugTable", "getFilteredSelectedRowModel"));
|
|
1980
|
-
table.getGroupedSelectedRowModel = memo(() => [table.getState().rowSelection, table.getSortedRowModel()], (rowSelection, rowModel) => {
|
|
1981
|
-
if (!Object.keys(rowSelection).length) {
|
|
1982
|
-
return {
|
|
1983
|
-
rows: [],
|
|
1984
|
-
flatRows: [],
|
|
1985
|
-
rowsById: {}
|
|
1986
|
-
};
|
|
1987
|
-
}
|
|
1988
|
-
return selectRowsFn(table, rowModel);
|
|
1989
|
-
}, getMemoOptions(table.options, "debugTable", "getGroupedSelectedRowModel"));
|
|
1990
|
-
table.getIsAllRowsSelected = () => {
|
|
1991
|
-
const preGroupedFlatRows = table.getFilteredRowModel().flatRows;
|
|
1992
|
-
const {
|
|
1993
|
-
rowSelection
|
|
1994
|
-
} = table.getState();
|
|
1995
|
-
let isAllRowsSelected = Boolean(preGroupedFlatRows.length && Object.keys(rowSelection).length);
|
|
1996
|
-
if (isAllRowsSelected) {
|
|
1997
|
-
if (preGroupedFlatRows.some((row) => row.getCanSelect() && !rowSelection[row.id])) {
|
|
1998
|
-
isAllRowsSelected = false;
|
|
1999
|
-
}
|
|
2000
|
-
}
|
|
2001
|
-
return isAllRowsSelected;
|
|
2002
|
-
};
|
|
2003
|
-
table.getIsAllPageRowsSelected = () => {
|
|
2004
|
-
const paginationFlatRows = table.getPaginationRowModel().flatRows.filter((row) => row.getCanSelect());
|
|
2005
|
-
const {
|
|
2006
|
-
rowSelection
|
|
2007
|
-
} = table.getState();
|
|
2008
|
-
let isAllPageRowsSelected = !!paginationFlatRows.length;
|
|
2009
|
-
if (isAllPageRowsSelected && paginationFlatRows.some((row) => !rowSelection[row.id])) {
|
|
2010
|
-
isAllPageRowsSelected = false;
|
|
2011
|
-
}
|
|
2012
|
-
return isAllPageRowsSelected;
|
|
2013
|
-
};
|
|
2014
|
-
table.getIsSomeRowsSelected = () => {
|
|
2015
|
-
var _table$getState$rowSe;
|
|
2016
|
-
const totalSelected = Object.keys((_table$getState$rowSe = table.getState().rowSelection) != null ? _table$getState$rowSe : {}).length;
|
|
2017
|
-
return totalSelected > 0 && totalSelected < table.getFilteredRowModel().flatRows.length;
|
|
2018
|
-
};
|
|
2019
|
-
table.getIsSomePageRowsSelected = () => {
|
|
2020
|
-
const paginationFlatRows = table.getPaginationRowModel().flatRows;
|
|
2021
|
-
return table.getIsAllPageRowsSelected() ? false : paginationFlatRows.filter((row) => row.getCanSelect()).some((d) => d.getIsSelected() || d.getIsSomeSelected());
|
|
2022
|
-
};
|
|
2023
|
-
table.getToggleAllRowsSelectedHandler = () => {
|
|
2024
|
-
return (e) => {
|
|
2025
|
-
table.toggleAllRowsSelected(e.target.checked);
|
|
2026
|
-
};
|
|
2027
|
-
};
|
|
2028
|
-
table.getToggleAllPageRowsSelectedHandler = () => {
|
|
2029
|
-
return (e) => {
|
|
2030
|
-
table.toggleAllPageRowsSelected(e.target.checked);
|
|
2031
|
-
};
|
|
2032
|
-
};
|
|
2033
|
-
},
|
|
2034
|
-
createRow: (row, table) => {
|
|
2035
|
-
row.toggleSelected = (value, opts) => {
|
|
2036
|
-
const isSelected = row.getIsSelected();
|
|
2037
|
-
table.setRowSelection((old) => {
|
|
2038
|
-
var _opts$selectChildren;
|
|
2039
|
-
value = typeof value !== "undefined" ? value : !isSelected;
|
|
2040
|
-
if (row.getCanSelect() && isSelected === value) {
|
|
2041
|
-
return old;
|
|
2042
|
-
}
|
|
2043
|
-
const selectedRowIds = {
|
|
2044
|
-
...old
|
|
2045
|
-
};
|
|
2046
|
-
mutateRowIsSelected(selectedRowIds, row.id, value, (_opts$selectChildren = opts == null ? void 0 : opts.selectChildren) != null ? _opts$selectChildren : true, table);
|
|
2047
|
-
return selectedRowIds;
|
|
2048
|
-
});
|
|
2049
|
-
};
|
|
2050
|
-
row.getIsSelected = () => {
|
|
2051
|
-
const {
|
|
2052
|
-
rowSelection
|
|
2053
|
-
} = table.getState();
|
|
2054
|
-
return isRowSelected(row, rowSelection);
|
|
2055
|
-
};
|
|
2056
|
-
row.getIsSomeSelected = () => {
|
|
2057
|
-
const {
|
|
2058
|
-
rowSelection
|
|
2059
|
-
} = table.getState();
|
|
2060
|
-
return isSubRowSelected(row, rowSelection) === "some";
|
|
2061
|
-
};
|
|
2062
|
-
row.getIsAllSubRowsSelected = () => {
|
|
2063
|
-
const {
|
|
2064
|
-
rowSelection
|
|
2065
|
-
} = table.getState();
|
|
2066
|
-
return isSubRowSelected(row, rowSelection) === "all";
|
|
2067
|
-
};
|
|
2068
|
-
row.getCanSelect = () => {
|
|
2069
|
-
var _table$options$enable;
|
|
2070
|
-
if (typeof table.options.enableRowSelection === "function") {
|
|
2071
|
-
return table.options.enableRowSelection(row);
|
|
2072
|
-
}
|
|
2073
|
-
return (_table$options$enable = table.options.enableRowSelection) != null ? _table$options$enable : true;
|
|
2074
|
-
};
|
|
2075
|
-
row.getCanSelectSubRows = () => {
|
|
2076
|
-
var _table$options$enable2;
|
|
2077
|
-
if (typeof table.options.enableSubRowSelection === "function") {
|
|
2078
|
-
return table.options.enableSubRowSelection(row);
|
|
2079
|
-
}
|
|
2080
|
-
return (_table$options$enable2 = table.options.enableSubRowSelection) != null ? _table$options$enable2 : true;
|
|
2081
|
-
};
|
|
2082
|
-
row.getCanMultiSelect = () => {
|
|
2083
|
-
var _table$options$enable3;
|
|
2084
|
-
if (typeof table.options.enableMultiRowSelection === "function") {
|
|
2085
|
-
return table.options.enableMultiRowSelection(row);
|
|
2086
|
-
}
|
|
2087
|
-
return (_table$options$enable3 = table.options.enableMultiRowSelection) != null ? _table$options$enable3 : true;
|
|
2088
|
-
};
|
|
2089
|
-
row.getToggleSelectedHandler = () => {
|
|
2090
|
-
const canSelect = row.getCanSelect();
|
|
2091
|
-
return (e) => {
|
|
2092
|
-
var _target;
|
|
2093
|
-
if (!canSelect) return;
|
|
2094
|
-
row.toggleSelected((_target = e.target) == null ? void 0 : _target.checked);
|
|
2095
|
-
};
|
|
2096
|
-
};
|
|
2097
|
-
}
|
|
2098
|
-
};
|
|
2099
|
-
var mutateRowIsSelected = (selectedRowIds, id, value, includeChildren, table) => {
|
|
2100
|
-
var _row$subRows;
|
|
2101
|
-
const row = table.getRow(id, true);
|
|
2102
|
-
if (value) {
|
|
2103
|
-
if (!row.getCanMultiSelect()) {
|
|
2104
|
-
Object.keys(selectedRowIds).forEach((key) => delete selectedRowIds[key]);
|
|
2105
|
-
}
|
|
2106
|
-
if (row.getCanSelect()) {
|
|
2107
|
-
selectedRowIds[id] = true;
|
|
2108
|
-
}
|
|
2109
|
-
} else {
|
|
2110
|
-
delete selectedRowIds[id];
|
|
2111
|
-
}
|
|
2112
|
-
if (includeChildren && (_row$subRows = row.subRows) != null && _row$subRows.length && row.getCanSelectSubRows()) {
|
|
2113
|
-
row.subRows.forEach((row2) => mutateRowIsSelected(selectedRowIds, row2.id, value, includeChildren, table));
|
|
2114
|
-
}
|
|
2115
|
-
};
|
|
2116
|
-
function selectRowsFn(table, rowModel) {
|
|
2117
|
-
const rowSelection = table.getState().rowSelection;
|
|
2118
|
-
const newSelectedFlatRows = [];
|
|
2119
|
-
const newSelectedRowsById = {};
|
|
2120
|
-
const recurseRows = function(rows, depth) {
|
|
2121
|
-
return rows.map((row) => {
|
|
2122
|
-
var _row$subRows2;
|
|
2123
|
-
const isSelected = isRowSelected(row, rowSelection);
|
|
2124
|
-
if (isSelected) {
|
|
2125
|
-
newSelectedFlatRows.push(row);
|
|
2126
|
-
newSelectedRowsById[row.id] = row;
|
|
2127
|
-
}
|
|
2128
|
-
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
|
|
2129
|
-
row = {
|
|
2130
|
-
...row,
|
|
2131
|
-
subRows: recurseRows(row.subRows)
|
|
2132
|
-
};
|
|
2133
|
-
}
|
|
2134
|
-
if (isSelected) {
|
|
2135
|
-
return row;
|
|
2136
|
-
}
|
|
2137
|
-
}).filter(Boolean);
|
|
2138
|
-
};
|
|
2139
|
-
return {
|
|
2140
|
-
rows: recurseRows(rowModel.rows),
|
|
2141
|
-
flatRows: newSelectedFlatRows,
|
|
2142
|
-
rowsById: newSelectedRowsById
|
|
2143
|
-
};
|
|
2144
|
-
}
|
|
2145
|
-
function isRowSelected(row, selection) {
|
|
2146
|
-
var _selection$row$id;
|
|
2147
|
-
return (_selection$row$id = selection[row.id]) != null ? _selection$row$id : false;
|
|
2148
|
-
}
|
|
2149
|
-
function isSubRowSelected(row, selection, table) {
|
|
2150
|
-
var _row$subRows3;
|
|
2151
|
-
if (!((_row$subRows3 = row.subRows) != null && _row$subRows3.length)) return false;
|
|
2152
|
-
let allChildrenSelected = true;
|
|
2153
|
-
let someSelected = false;
|
|
2154
|
-
row.subRows.forEach((subRow) => {
|
|
2155
|
-
if (someSelected && !allChildrenSelected) {
|
|
2156
|
-
return;
|
|
2157
|
-
}
|
|
2158
|
-
if (subRow.getCanSelect()) {
|
|
2159
|
-
if (isRowSelected(subRow, selection)) {
|
|
2160
|
-
someSelected = true;
|
|
2161
|
-
} else {
|
|
2162
|
-
allChildrenSelected = false;
|
|
2163
|
-
}
|
|
2164
|
-
}
|
|
2165
|
-
if (subRow.subRows && subRow.subRows.length) {
|
|
2166
|
-
const subRowChildrenSelected = isSubRowSelected(subRow, selection);
|
|
2167
|
-
if (subRowChildrenSelected === "all") {
|
|
2168
|
-
someSelected = true;
|
|
2169
|
-
} else if (subRowChildrenSelected === "some") {
|
|
2170
|
-
someSelected = true;
|
|
2171
|
-
allChildrenSelected = false;
|
|
2172
|
-
} else {
|
|
2173
|
-
allChildrenSelected = false;
|
|
2174
|
-
}
|
|
2175
|
-
}
|
|
2176
|
-
});
|
|
2177
|
-
return allChildrenSelected ? "all" : someSelected ? "some" : false;
|
|
2178
|
-
}
|
|
2179
|
-
var reSplitAlphaNumeric = /([0-9]+)/gm;
|
|
2180
|
-
var alphanumeric = (rowA, rowB, columnId) => {
|
|
2181
|
-
return compareAlphanumeric(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2182
|
-
};
|
|
2183
|
-
var alphanumericCaseSensitive = (rowA, rowB, columnId) => {
|
|
2184
|
-
return compareAlphanumeric(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
2185
|
-
};
|
|
2186
|
-
var text = (rowA, rowB, columnId) => {
|
|
2187
|
-
return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2188
|
-
};
|
|
2189
|
-
var textCaseSensitive = (rowA, rowB, columnId) => {
|
|
2190
|
-
return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
2191
|
-
};
|
|
2192
|
-
var datetime = (rowA, rowB, columnId) => {
|
|
2193
|
-
const a = rowA.getValue(columnId);
|
|
2194
|
-
const b = rowB.getValue(columnId);
|
|
2195
|
-
return a > b ? 1 : a < b ? -1 : 0;
|
|
2196
|
-
};
|
|
2197
|
-
var basic = (rowA, rowB, columnId) => {
|
|
2198
|
-
return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
|
|
2199
|
-
};
|
|
2200
|
-
function compareBasic(a, b) {
|
|
2201
|
-
return a === b ? 0 : a > b ? 1 : -1;
|
|
2202
|
-
}
|
|
2203
|
-
function toString(a) {
|
|
2204
|
-
if (typeof a === "number") {
|
|
2205
|
-
if (isNaN(a) || a === Infinity || a === -Infinity) {
|
|
2206
|
-
return "";
|
|
2207
|
-
}
|
|
2208
|
-
return String(a);
|
|
2209
|
-
}
|
|
2210
|
-
if (typeof a === "string") {
|
|
2211
|
-
return a;
|
|
2212
|
-
}
|
|
2213
|
-
return "";
|
|
2214
|
-
}
|
|
2215
|
-
function compareAlphanumeric(aStr, bStr) {
|
|
2216
|
-
const a = aStr.split(reSplitAlphaNumeric).filter(Boolean);
|
|
2217
|
-
const b = bStr.split(reSplitAlphaNumeric).filter(Boolean);
|
|
2218
|
-
while (a.length && b.length) {
|
|
2219
|
-
const aa = a.shift();
|
|
2220
|
-
const bb = b.shift();
|
|
2221
|
-
const an = parseInt(aa, 10);
|
|
2222
|
-
const bn = parseInt(bb, 10);
|
|
2223
|
-
const combo = [an, bn].sort();
|
|
2224
|
-
if (isNaN(combo[0])) {
|
|
2225
|
-
if (aa > bb) {
|
|
2226
|
-
return 1;
|
|
2227
|
-
}
|
|
2228
|
-
if (bb > aa) {
|
|
2229
|
-
return -1;
|
|
2230
|
-
}
|
|
2231
|
-
continue;
|
|
2232
|
-
}
|
|
2233
|
-
if (isNaN(combo[1])) {
|
|
2234
|
-
return isNaN(an) ? -1 : 1;
|
|
2235
|
-
}
|
|
2236
|
-
if (an > bn) {
|
|
2237
|
-
return 1;
|
|
2238
|
-
}
|
|
2239
|
-
if (bn > an) {
|
|
2240
|
-
return -1;
|
|
2241
|
-
}
|
|
2242
|
-
}
|
|
2243
|
-
return a.length - b.length;
|
|
2244
|
-
}
|
|
2245
|
-
var sortingFns = {
|
|
2246
|
-
alphanumeric,
|
|
2247
|
-
alphanumericCaseSensitive,
|
|
2248
|
-
text,
|
|
2249
|
-
textCaseSensitive,
|
|
2250
|
-
datetime,
|
|
2251
|
-
basic
|
|
2252
|
-
};
|
|
2253
|
-
var RowSorting = {
|
|
2254
|
-
getInitialState: (state) => {
|
|
2255
|
-
return {
|
|
2256
|
-
sorting: [],
|
|
2257
|
-
...state
|
|
2258
|
-
};
|
|
2259
|
-
},
|
|
2260
|
-
getDefaultColumnDef: () => {
|
|
2261
|
-
return {
|
|
2262
|
-
sortingFn: "auto",
|
|
2263
|
-
sortUndefined: 1
|
|
2264
|
-
};
|
|
2265
|
-
},
|
|
2266
|
-
getDefaultOptions: (table) => {
|
|
2267
|
-
return {
|
|
2268
|
-
onSortingChange: makeStateUpdater("sorting", table),
|
|
2269
|
-
isMultiSortEvent: (e) => {
|
|
2270
|
-
return e.shiftKey;
|
|
2271
|
-
}
|
|
2272
|
-
};
|
|
2273
|
-
},
|
|
2274
|
-
createColumn: (column, table) => {
|
|
2275
|
-
column.getAutoSortingFn = () => {
|
|
2276
|
-
const firstRows = table.getFilteredRowModel().flatRows.slice(10);
|
|
2277
|
-
let isString = false;
|
|
2278
|
-
for (const row of firstRows) {
|
|
2279
|
-
const value = row == null ? void 0 : row.getValue(column.id);
|
|
2280
|
-
if (Object.prototype.toString.call(value) === "[object Date]") {
|
|
2281
|
-
return sortingFns.datetime;
|
|
2282
|
-
}
|
|
2283
|
-
if (typeof value === "string") {
|
|
2284
|
-
isString = true;
|
|
2285
|
-
if (value.split(reSplitAlphaNumeric).length > 1) {
|
|
2286
|
-
return sortingFns.alphanumeric;
|
|
2287
|
-
}
|
|
2288
|
-
}
|
|
2289
|
-
}
|
|
2290
|
-
if (isString) {
|
|
2291
|
-
return sortingFns.text;
|
|
2292
|
-
}
|
|
2293
|
-
return sortingFns.basic;
|
|
2294
|
-
};
|
|
2295
|
-
column.getAutoSortDir = () => {
|
|
2296
|
-
const firstRow = table.getFilteredRowModel().flatRows[0];
|
|
2297
|
-
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
|
2298
|
-
if (typeof value === "string") {
|
|
2299
|
-
return "asc";
|
|
2300
|
-
}
|
|
2301
|
-
return "desc";
|
|
2302
|
-
};
|
|
2303
|
-
column.getSortingFn = () => {
|
|
2304
|
-
var _table$options$sortin, _table$options$sortin2;
|
|
2305
|
-
if (!column) {
|
|
2306
|
-
throw new Error();
|
|
2307
|
-
}
|
|
2308
|
-
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];
|
|
2309
|
-
};
|
|
2310
|
-
column.toggleSorting = (desc, multi) => {
|
|
2311
|
-
const nextSortingOrder = column.getNextSortingOrder();
|
|
2312
|
-
const hasManualValue = typeof desc !== "undefined" && desc !== null;
|
|
2313
|
-
table.setSorting((old) => {
|
|
2314
|
-
const existingSorting = old == null ? void 0 : old.find((d) => d.id === column.id);
|
|
2315
|
-
const existingIndex = old == null ? void 0 : old.findIndex((d) => d.id === column.id);
|
|
2316
|
-
let newSorting = [];
|
|
2317
|
-
let sortAction;
|
|
2318
|
-
let nextDesc = hasManualValue ? desc : nextSortingOrder === "desc";
|
|
2319
|
-
if (old != null && old.length && column.getCanMultiSort() && multi) {
|
|
2320
|
-
if (existingSorting) {
|
|
2321
|
-
sortAction = "toggle";
|
|
2322
|
-
} else {
|
|
2323
|
-
sortAction = "add";
|
|
2324
|
-
}
|
|
2325
|
-
} else {
|
|
2326
|
-
if (old != null && old.length && existingIndex !== old.length - 1) {
|
|
2327
|
-
sortAction = "replace";
|
|
2328
|
-
} else if (existingSorting) {
|
|
2329
|
-
sortAction = "toggle";
|
|
2330
|
-
} else {
|
|
2331
|
-
sortAction = "replace";
|
|
2332
|
-
}
|
|
2333
|
-
}
|
|
2334
|
-
if (sortAction === "toggle") {
|
|
2335
|
-
if (!hasManualValue) {
|
|
2336
|
-
if (!nextSortingOrder) {
|
|
2337
|
-
sortAction = "remove";
|
|
2338
|
-
}
|
|
2339
|
-
}
|
|
2340
|
-
}
|
|
2341
|
-
if (sortAction === "add") {
|
|
2342
|
-
var _table$options$maxMul;
|
|
2343
|
-
newSorting = [...old, {
|
|
2344
|
-
id: column.id,
|
|
2345
|
-
desc: nextDesc
|
|
2346
|
-
}];
|
|
2347
|
-
newSorting.splice(0, newSorting.length - ((_table$options$maxMul = table.options.maxMultiSortColCount) != null ? _table$options$maxMul : Number.MAX_SAFE_INTEGER));
|
|
2348
|
-
} else if (sortAction === "toggle") {
|
|
2349
|
-
newSorting = old.map((d) => {
|
|
2350
|
-
if (d.id === column.id) {
|
|
2351
|
-
return {
|
|
2352
|
-
...d,
|
|
2353
|
-
desc: nextDesc
|
|
2354
|
-
};
|
|
2355
|
-
}
|
|
2356
|
-
return d;
|
|
2357
|
-
});
|
|
2358
|
-
} else if (sortAction === "remove") {
|
|
2359
|
-
newSorting = old.filter((d) => d.id !== column.id);
|
|
2360
|
-
} else {
|
|
2361
|
-
newSorting = [{
|
|
2362
|
-
id: column.id,
|
|
2363
|
-
desc: nextDesc
|
|
2364
|
-
}];
|
|
2365
|
-
}
|
|
2366
|
-
return newSorting;
|
|
2367
|
-
});
|
|
2368
|
-
};
|
|
2369
|
-
column.getFirstSortDir = () => {
|
|
2370
|
-
var _ref, _column$columnDef$sor;
|
|
2371
|
-
const sortDescFirst = (_ref = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : table.options.sortDescFirst) != null ? _ref : column.getAutoSortDir() === "desc";
|
|
2372
|
-
return sortDescFirst ? "desc" : "asc";
|
|
2373
|
-
};
|
|
2374
|
-
column.getNextSortingOrder = (multi) => {
|
|
2375
|
-
var _table$options$enable, _table$options$enable2;
|
|
2376
|
-
const firstSortDirection = column.getFirstSortDir();
|
|
2377
|
-
const isSorted = column.getIsSorted();
|
|
2378
|
-
if (!isSorted) {
|
|
2379
|
-
return firstSortDirection;
|
|
2380
|
-
}
|
|
2381
|
-
if (isSorted !== firstSortDirection && ((_table$options$enable = table.options.enableSortingRemoval) != null ? _table$options$enable : true) && // If enableSortRemove, enable in general
|
|
2382
|
-
(multi ? (_table$options$enable2 = table.options.enableMultiRemove) != null ? _table$options$enable2 : true : true)) {
|
|
2383
|
-
return false;
|
|
2384
|
-
}
|
|
2385
|
-
return isSorted === "desc" ? "asc" : "desc";
|
|
2386
|
-
};
|
|
2387
|
-
column.getCanSort = () => {
|
|
2388
|
-
var _column$columnDef$ena, _table$options$enable3;
|
|
2389
|
-
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;
|
|
2390
|
-
};
|
|
2391
|
-
column.getCanMultiSort = () => {
|
|
2392
|
-
var _ref2, _column$columnDef$ena2;
|
|
2393
|
-
return (_ref2 = (_column$columnDef$ena2 = column.columnDef.enableMultiSort) != null ? _column$columnDef$ena2 : table.options.enableMultiSort) != null ? _ref2 : !!column.accessorFn;
|
|
2394
|
-
};
|
|
2395
|
-
column.getIsSorted = () => {
|
|
2396
|
-
var _table$getState$sorti;
|
|
2397
|
-
const columnSort = (_table$getState$sorti = table.getState().sorting) == null ? void 0 : _table$getState$sorti.find((d) => d.id === column.id);
|
|
2398
|
-
return !columnSort ? false : columnSort.desc ? "desc" : "asc";
|
|
2399
|
-
};
|
|
2400
|
-
column.getSortIndex = () => {
|
|
2401
|
-
var _table$getState$sorti2, _table$getState$sorti3;
|
|
2402
|
-
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;
|
|
2403
|
-
};
|
|
2404
|
-
column.clearSorting = () => {
|
|
2405
|
-
table.setSorting((old) => old != null && old.length ? old.filter((d) => d.id !== column.id) : []);
|
|
2406
|
-
};
|
|
2407
|
-
column.getToggleSortingHandler = () => {
|
|
2408
|
-
const canSort = column.getCanSort();
|
|
2409
|
-
return (e) => {
|
|
2410
|
-
if (!canSort) return;
|
|
2411
|
-
e.persist == null || e.persist();
|
|
2412
|
-
column.toggleSorting == null || column.toggleSorting(void 0, column.getCanMultiSort() ? table.options.isMultiSortEvent == null ? void 0 : table.options.isMultiSortEvent(e) : false);
|
|
2413
|
-
};
|
|
2414
|
-
};
|
|
2415
|
-
},
|
|
2416
|
-
createTable: (table) => {
|
|
2417
|
-
table.setSorting = (updater) => table.options.onSortingChange == null ? void 0 : table.options.onSortingChange(updater);
|
|
2418
|
-
table.resetSorting = (defaultState) => {
|
|
2419
|
-
var _table$initialState$s, _table$initialState;
|
|
2420
|
-
table.setSorting(defaultState ? [] : (_table$initialState$s = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.sorting) != null ? _table$initialState$s : []);
|
|
2421
|
-
};
|
|
2422
|
-
table.getPreSortedRowModel = () => table.getGroupedRowModel();
|
|
2423
|
-
table.getSortedRowModel = () => {
|
|
2424
|
-
if (!table._getSortedRowModel && table.options.getSortedRowModel) {
|
|
2425
|
-
table._getSortedRowModel = table.options.getSortedRowModel(table);
|
|
2426
|
-
}
|
|
2427
|
-
if (table.options.manualSorting || !table._getSortedRowModel) {
|
|
2428
|
-
return table.getPreSortedRowModel();
|
|
2429
|
-
}
|
|
2430
|
-
return table._getSortedRowModel();
|
|
2431
|
-
};
|
|
2432
|
-
}
|
|
2433
|
-
};
|
|
2434
|
-
var builtInFeatures = [
|
|
2435
|
-
Headers,
|
|
2436
|
-
ColumnVisibility,
|
|
2437
|
-
ColumnOrdering,
|
|
2438
|
-
ColumnPinning,
|
|
2439
|
-
ColumnFaceting,
|
|
2440
|
-
ColumnFiltering,
|
|
2441
|
-
GlobalFaceting,
|
|
2442
|
-
//depends on ColumnFaceting
|
|
2443
|
-
GlobalFiltering,
|
|
2444
|
-
//depends on ColumnFiltering
|
|
2445
|
-
RowSorting,
|
|
2446
|
-
ColumnGrouping,
|
|
2447
|
-
//depends on RowSorting
|
|
2448
|
-
RowExpanding,
|
|
2449
|
-
RowPagination,
|
|
2450
|
-
RowPinning,
|
|
2451
|
-
RowSelection,
|
|
2452
|
-
ColumnSizing
|
|
2453
|
-
];
|
|
2454
|
-
function createTable(options) {
|
|
2455
|
-
var _options$_features, _options$initialState;
|
|
2456
|
-
if (process.env.NODE_ENV !== "production" && (options.debugAll || options.debugTable)) {
|
|
2457
|
-
console.info("Creating Table Instance...");
|
|
2458
|
-
}
|
|
2459
|
-
const _features = [...builtInFeatures, ...(_options$_features = options._features) != null ? _options$_features : []];
|
|
2460
|
-
let table = {
|
|
2461
|
-
_features
|
|
2462
|
-
};
|
|
2463
|
-
const defaultOptions = table._features.reduce((obj, feature) => {
|
|
2464
|
-
return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(table));
|
|
2465
|
-
}, {});
|
|
2466
|
-
const mergeOptions = (options2) => {
|
|
2467
|
-
if (table.options.mergeOptions) {
|
|
2468
|
-
return table.options.mergeOptions(defaultOptions, options2);
|
|
2469
|
-
}
|
|
2470
|
-
return {
|
|
2471
|
-
...defaultOptions,
|
|
2472
|
-
...options2
|
|
2473
|
-
};
|
|
2474
|
-
};
|
|
2475
|
-
const coreInitialState = {};
|
|
2476
|
-
let initialState = {
|
|
2477
|
-
...coreInitialState,
|
|
2478
|
-
...(_options$initialState = options.initialState) != null ? _options$initialState : {}
|
|
2479
|
-
};
|
|
2480
|
-
table._features.forEach((feature) => {
|
|
2481
|
-
var _feature$getInitialSt;
|
|
2482
|
-
initialState = (_feature$getInitialSt = feature.getInitialState == null ? void 0 : feature.getInitialState(initialState)) != null ? _feature$getInitialSt : initialState;
|
|
2483
|
-
});
|
|
2484
|
-
const queued = [];
|
|
2485
|
-
let queuedTimeout = false;
|
|
2486
|
-
const coreInstance = {
|
|
2487
|
-
_features,
|
|
2488
|
-
options: {
|
|
2489
|
-
...defaultOptions,
|
|
2490
|
-
...options
|
|
2491
|
-
},
|
|
2492
|
-
initialState,
|
|
2493
|
-
_queue: (cb) => {
|
|
2494
|
-
queued.push(cb);
|
|
2495
|
-
if (!queuedTimeout) {
|
|
2496
|
-
queuedTimeout = true;
|
|
2497
|
-
Promise.resolve().then(() => {
|
|
2498
|
-
while (queued.length) {
|
|
2499
|
-
queued.shift()();
|
|
2500
|
-
}
|
|
2501
|
-
queuedTimeout = false;
|
|
2502
|
-
}).catch((error) => setTimeout(() => {
|
|
2503
|
-
throw error;
|
|
2504
|
-
}));
|
|
2505
|
-
}
|
|
2506
|
-
},
|
|
2507
|
-
reset: () => {
|
|
2508
|
-
table.setState(table.initialState);
|
|
2509
|
-
},
|
|
2510
|
-
setOptions: (updater) => {
|
|
2511
|
-
const newOptions = functionalUpdate(updater, table.options);
|
|
2512
|
-
table.options = mergeOptions(newOptions);
|
|
2513
|
-
},
|
|
2514
|
-
getState: () => {
|
|
2515
|
-
return table.options.state;
|
|
2516
|
-
},
|
|
2517
|
-
setState: (updater) => {
|
|
2518
|
-
table.options.onStateChange == null || table.options.onStateChange(updater);
|
|
2519
|
-
},
|
|
2520
|
-
_getRowId: (row, index, parent) => {
|
|
2521
|
-
var _table$options$getRow;
|
|
2522
|
-
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}`;
|
|
2523
|
-
},
|
|
2524
|
-
getCoreRowModel: () => {
|
|
2525
|
-
if (!table._getCoreRowModel) {
|
|
2526
|
-
table._getCoreRowModel = table.options.getCoreRowModel(table);
|
|
2527
|
-
}
|
|
2528
|
-
return table._getCoreRowModel();
|
|
2529
|
-
},
|
|
2530
|
-
// The final calls start at the bottom of the model,
|
|
2531
|
-
// expanded rows, which then work their way up
|
|
2532
|
-
getRowModel: () => {
|
|
2533
|
-
return table.getPaginationRowModel();
|
|
2534
|
-
},
|
|
2535
|
-
//in next version, we should just pass in the row model as the optional 2nd arg
|
|
2536
|
-
getRow: (id, searchAll) => {
|
|
2537
|
-
let row = (searchAll ? table.getPrePaginationRowModel() : table.getRowModel()).rowsById[id];
|
|
2538
|
-
if (!row) {
|
|
2539
|
-
row = table.getCoreRowModel().rowsById[id];
|
|
2540
|
-
if (!row) {
|
|
2541
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2542
|
-
throw new Error(`getRow could not find row with ID: ${id}`);
|
|
2543
|
-
}
|
|
2544
|
-
throw new Error();
|
|
2545
|
-
}
|
|
2546
|
-
}
|
|
2547
|
-
return row;
|
|
2548
|
-
},
|
|
2549
|
-
_getDefaultColumnDef: memo(() => [table.options.defaultColumn], (defaultColumn) => {
|
|
2550
|
-
var _defaultColumn;
|
|
2551
|
-
defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
|
|
2552
|
-
return {
|
|
2553
|
-
header: (props) => {
|
|
2554
|
-
const resolvedColumnDef = props.header.column.columnDef;
|
|
2555
|
-
if (resolvedColumnDef.accessorKey) {
|
|
2556
|
-
return resolvedColumnDef.accessorKey;
|
|
2557
|
-
}
|
|
2558
|
-
if (resolvedColumnDef.accessorFn) {
|
|
2559
|
-
return resolvedColumnDef.id;
|
|
2560
|
-
}
|
|
2561
|
-
return null;
|
|
2562
|
-
},
|
|
2563
|
-
// footer: props => props.header.column.id,
|
|
2564
|
-
cell: (props) => {
|
|
2565
|
-
var _props$renderValue$to, _props$renderValue;
|
|
2566
|
-
return (_props$renderValue$to = (_props$renderValue = props.renderValue()) == null || _props$renderValue.toString == null ? void 0 : _props$renderValue.toString()) != null ? _props$renderValue$to : null;
|
|
2567
|
-
},
|
|
2568
|
-
...table._features.reduce((obj, feature) => {
|
|
2569
|
-
return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
|
|
2570
|
-
}, {}),
|
|
2571
|
-
...defaultColumn
|
|
2572
|
-
};
|
|
2573
|
-
}, getMemoOptions(options, "debugColumns", "_getDefaultColumnDef")),
|
|
2574
|
-
_getColumnDefs: () => table.options.columns,
|
|
2575
|
-
getAllColumns: memo(() => [table._getColumnDefs()], (columnDefs) => {
|
|
2576
|
-
const recurseColumns = function(columnDefs2, parent, depth) {
|
|
2577
|
-
if (depth === void 0) {
|
|
2578
|
-
depth = 0;
|
|
2579
|
-
}
|
|
2580
|
-
return columnDefs2.map((columnDef) => {
|
|
2581
|
-
const column = createColumn(table, columnDef, depth, parent);
|
|
2582
|
-
const groupingColumnDef = columnDef;
|
|
2583
|
-
column.columns = groupingColumnDef.columns ? recurseColumns(groupingColumnDef.columns, column, depth + 1) : [];
|
|
2584
|
-
return column;
|
|
2585
|
-
});
|
|
2586
|
-
};
|
|
2587
|
-
return recurseColumns(columnDefs);
|
|
2588
|
-
}, getMemoOptions(options, "debugColumns", "getAllColumns")),
|
|
2589
|
-
getAllFlatColumns: memo(() => [table.getAllColumns()], (allColumns) => {
|
|
2590
|
-
return allColumns.flatMap((column) => {
|
|
2591
|
-
return column.getFlatColumns();
|
|
2592
|
-
});
|
|
2593
|
-
}, getMemoOptions(options, "debugColumns", "getAllFlatColumns")),
|
|
2594
|
-
_getAllFlatColumnsById: memo(() => [table.getAllFlatColumns()], (flatColumns) => {
|
|
2595
|
-
return flatColumns.reduce((acc, column) => {
|
|
2596
|
-
acc[column.id] = column;
|
|
2597
|
-
return acc;
|
|
2598
|
-
}, {});
|
|
2599
|
-
}, getMemoOptions(options, "debugColumns", "getAllFlatColumnsById")),
|
|
2600
|
-
getAllLeafColumns: memo(() => [table.getAllColumns(), table._getOrderColumnsFn()], (allColumns, orderColumns2) => {
|
|
2601
|
-
let leafColumns = allColumns.flatMap((column) => column.getLeafColumns());
|
|
2602
|
-
return orderColumns2(leafColumns);
|
|
2603
|
-
}, getMemoOptions(options, "debugColumns", "getAllLeafColumns")),
|
|
2604
|
-
getColumn: (columnId) => {
|
|
2605
|
-
const column = table._getAllFlatColumnsById()[columnId];
|
|
2606
|
-
if (process.env.NODE_ENV !== "production" && !column) {
|
|
2607
|
-
console.error(`[Table] Column with id '${columnId}' does not exist.`);
|
|
2608
|
-
}
|
|
2609
|
-
return column;
|
|
2610
|
-
}
|
|
2611
|
-
};
|
|
2612
|
-
Object.assign(table, coreInstance);
|
|
2613
|
-
for (let index = 0; index < table._features.length; index++) {
|
|
2614
|
-
const feature = table._features[index];
|
|
2615
|
-
feature == null || feature.createTable == null || feature.createTable(table);
|
|
2616
|
-
}
|
|
2617
|
-
return table;
|
|
2618
|
-
}
|
|
2619
|
-
function getCoreRowModel() {
|
|
2620
|
-
return (table) => memo(() => [table.options.data], (data) => {
|
|
2621
|
-
const rowModel = {
|
|
2622
|
-
rows: [],
|
|
2623
|
-
flatRows: [],
|
|
2624
|
-
rowsById: {}
|
|
2625
|
-
};
|
|
2626
|
-
const accessRows = function(originalRows, depth, parentRow) {
|
|
2627
|
-
if (depth === void 0) {
|
|
2628
|
-
depth = 0;
|
|
2629
|
-
}
|
|
2630
|
-
const rows = [];
|
|
2631
|
-
for (let i = 0; i < originalRows.length; i++) {
|
|
2632
|
-
const row = createRow(table, table._getRowId(originalRows[i], i, parentRow), originalRows[i], i, depth, void 0, parentRow == null ? void 0 : parentRow.id);
|
|
2633
|
-
rowModel.flatRows.push(row);
|
|
2634
|
-
rowModel.rowsById[row.id] = row;
|
|
2635
|
-
rows.push(row);
|
|
2636
|
-
if (table.options.getSubRows) {
|
|
2637
|
-
var _row$originalSubRows;
|
|
2638
|
-
row.originalSubRows = table.options.getSubRows(originalRows[i], i);
|
|
2639
|
-
if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
|
|
2640
|
-
row.subRows = accessRows(row.originalSubRows, depth + 1, row);
|
|
2641
|
-
}
|
|
2642
|
-
}
|
|
2643
|
-
}
|
|
2644
|
-
return rows;
|
|
2645
|
-
};
|
|
2646
|
-
rowModel.rows = accessRows(data);
|
|
2647
|
-
return rowModel;
|
|
2648
|
-
}, getMemoOptions(table.options, "debugTable", "getRowModel", () => table._autoResetPageIndex()));
|
|
2649
|
-
}
|
|
13
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
2650
14
|
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
function isReactComponent(component) {
|
|
2656
|
-
return isClassComponent(component) || typeof component === "function" || isExoticComponent(component);
|
|
2657
|
-
}
|
|
2658
|
-
function isClassComponent(component) {
|
|
2659
|
-
return typeof component === "function" && (() => {
|
|
2660
|
-
const proto = Object.getPrototypeOf(component);
|
|
2661
|
-
return proto.prototype && proto.prototype.isReactComponent;
|
|
2662
|
-
})();
|
|
2663
|
-
}
|
|
2664
|
-
function isExoticComponent(component) {
|
|
2665
|
-
return typeof component === "object" && typeof component.$$typeof === "symbol" && ["react.memo", "react.forward_ref"].includes(component.$$typeof.description);
|
|
2666
|
-
}
|
|
2667
|
-
function useReactTable(options) {
|
|
2668
|
-
const resolvedOptions = {
|
|
2669
|
-
state: {},
|
|
2670
|
-
// Dummy state
|
|
2671
|
-
onStateChange: () => {
|
|
2672
|
-
},
|
|
2673
|
-
// noop
|
|
2674
|
-
renderFallbackValue: null,
|
|
2675
|
-
...options
|
|
2676
|
-
};
|
|
2677
|
-
const [tableRef] = React2__namespace.useState(() => ({
|
|
2678
|
-
current: createTable(resolvedOptions)
|
|
2679
|
-
}));
|
|
2680
|
-
const [state, setState] = React2__namespace.useState(() => tableRef.current.initialState);
|
|
2681
|
-
tableRef.current.setOptions((prev) => ({
|
|
2682
|
-
...prev,
|
|
2683
|
-
...options,
|
|
2684
|
-
state: {
|
|
2685
|
-
...state,
|
|
2686
|
-
...options.state
|
|
2687
|
-
},
|
|
2688
|
-
// Similarly, we'll maintain both our internal state and any user-provided
|
|
2689
|
-
// state.
|
|
2690
|
-
onStateChange: (updater) => {
|
|
2691
|
-
setState(updater);
|
|
2692
|
-
options.onStateChange == null || options.onStateChange(updater);
|
|
2693
|
-
}
|
|
2694
|
-
}));
|
|
2695
|
-
return tableRef.current;
|
|
2696
|
-
}
|
|
15
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
16
|
+
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
17
|
+
|
|
18
|
+
// src/object-table/ObjectTable.tsx
|
|
2697
19
|
function useColumnDefs(objectType, columnDefinitions) {
|
|
2698
20
|
const {
|
|
2699
21
|
metadata,
|
|
2700
22
|
loading,
|
|
2701
23
|
error
|
|
2702
24
|
} = react.useOsdkMetadata(objectType);
|
|
2703
|
-
const columns =
|
|
25
|
+
const columns = React.useMemo(() => {
|
|
2704
26
|
const objectProperties = metadata?.properties;
|
|
2705
27
|
if (columnDefinitions) {
|
|
2706
28
|
return getColumnsFromColumnDefinitions(columnDefinitions, objectProperties);
|
|
@@ -2759,7 +81,7 @@ function getDefaultColumns(objectProperties) {
|
|
|
2759
81
|
var useDefaultTableStates = ({
|
|
2760
82
|
columnDefinitions
|
|
2761
83
|
}) => {
|
|
2762
|
-
const columnVisibility =
|
|
84
|
+
const columnVisibility = React.useMemo(() => {
|
|
2763
85
|
if (columnDefinitions) {
|
|
2764
86
|
const colVisibility = columnDefinitions.reduce((acc, colDef) => {
|
|
2765
87
|
if (colDef.isVisible !== void 0) {
|
|
@@ -2783,7 +105,7 @@ var useDefaultTableStates = ({
|
|
|
2783
105
|
};
|
|
2784
106
|
var PAGE_SIZE = 50;
|
|
2785
107
|
function useObjectTableData(objectSet, columnDefinitions, filter) {
|
|
2786
|
-
const withProperties =
|
|
108
|
+
const withProperties = React.useMemo(() => {
|
|
2787
109
|
if (!columnDefinitions) {
|
|
2788
110
|
return;
|
|
2789
111
|
}
|
|
@@ -2817,11 +139,11 @@ function useRowSelection({
|
|
|
2817
139
|
onRowSelection,
|
|
2818
140
|
data
|
|
2819
141
|
}) {
|
|
2820
|
-
const [internalRowSelection, setInternalRowSelection] =
|
|
2821
|
-
const [lastSelectedRowIndex, setLastSelectedRowIndex] =
|
|
142
|
+
const [internalRowSelection, setInternalRowSelection] = React.useState({});
|
|
143
|
+
const [lastSelectedRowIndex, setLastSelectedRowIndex] = React.useState(null);
|
|
2822
144
|
const isControlled = selectedRows !== void 0;
|
|
2823
145
|
const isSelectionEnabled = selectionMode !== "none";
|
|
2824
|
-
const rowSelectionState =
|
|
146
|
+
const rowSelectionState = React.useMemo(() => {
|
|
2825
147
|
if (!isSelectionEnabled) return {};
|
|
2826
148
|
if (isControlled && selectedRows) {
|
|
2827
149
|
return getRowSelectionState(selectedRows);
|
|
@@ -2832,7 +154,7 @@ function useRowSelection({
|
|
|
2832
154
|
const totalCount = data?.length ?? 0;
|
|
2833
155
|
const isAllSelected = totalCount > 0 && selectedCount === totalCount;
|
|
2834
156
|
const hasSelection = selectedCount > 0;
|
|
2835
|
-
const onToggleAll =
|
|
157
|
+
const onToggleAll = React.useCallback(() => {
|
|
2836
158
|
if (!isSelectionEnabled || !data) return;
|
|
2837
159
|
const newSelectedRows = isAllSelected ? [] : data.map((item) => item.$primaryKey);
|
|
2838
160
|
if (!isControlled) {
|
|
@@ -2840,7 +162,7 @@ function useRowSelection({
|
|
|
2840
162
|
}
|
|
2841
163
|
onRowSelection?.(newSelectedRows);
|
|
2842
164
|
}, [isSelectionEnabled, data, isAllSelected, isControlled, onRowSelection]);
|
|
2843
|
-
const onToggleRow =
|
|
165
|
+
const onToggleRow = React.useCallback((rowId, rowIndex, isShiftClick = false) => {
|
|
2844
166
|
if (!isSelectionEnabled || !data) return;
|
|
2845
167
|
let newSelectedRows = [];
|
|
2846
168
|
if (selectionMode === "single") {
|
|
@@ -2942,53 +264,64 @@ function getRowSelectionState(primaryKeys) {
|
|
|
2942
264
|
function getSelectedPrimaryKeys(selectionState, data) {
|
|
2943
265
|
return data.filter((item) => selectionState[getRowId(item)]).map((item) => item.$primaryKey);
|
|
2944
266
|
}
|
|
267
|
+
|
|
268
|
+
// src/base-components/checkbox/Checkbox.module.css
|
|
269
|
+
var Checkbox_default = {};
|
|
270
|
+
|
|
271
|
+
// src/base-components/checkbox/Checkbox.tsx
|
|
272
|
+
function _extends() {
|
|
273
|
+
return _extends = Object.assign ? Object.assign.bind() : function(n) {
|
|
274
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
275
|
+
var t = arguments[e];
|
|
276
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
277
|
+
}
|
|
278
|
+
return n;
|
|
279
|
+
}, _extends.apply(null, arguments);
|
|
280
|
+
}
|
|
281
|
+
function Checkbox({
|
|
282
|
+
indeterminate,
|
|
283
|
+
className,
|
|
284
|
+
indicatorProps,
|
|
285
|
+
...rest
|
|
286
|
+
}) {
|
|
287
|
+
return /* @__PURE__ */ React__default.default.createElement(checkbox.Checkbox.Root, _extends({
|
|
288
|
+
className: classnames__default.default(Checkbox_default.osdkCheckboxRoot, className),
|
|
289
|
+
indeterminate
|
|
290
|
+
}, rest), /* @__PURE__ */ React__default.default.createElement(checkbox.Checkbox.Indicator, _extends({}, indicatorProps, {
|
|
291
|
+
className: classnames__default.default(Checkbox_default.osdkCheckboxIndicator, indicatorProps?.className)
|
|
292
|
+
}), indeterminate ? /* @__PURE__ */ React__default.default.createElement(icons.Minus, {
|
|
293
|
+
color: "currentColor"
|
|
294
|
+
}) : /* @__PURE__ */ React__default.default.createElement(icons.Tick, {
|
|
295
|
+
color: "currentColor"
|
|
296
|
+
})));
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// src/object-table/SelectionCells.tsx
|
|
2945
300
|
function SelectionHeaderCell({
|
|
2946
301
|
isAllSelected,
|
|
2947
302
|
hasSelection,
|
|
2948
303
|
onToggleAll
|
|
2949
304
|
}) {
|
|
2950
|
-
return /* @__PURE__ */
|
|
2951
|
-
|
|
2952
|
-
display: "flex",
|
|
2953
|
-
alignItems: "center",
|
|
2954
|
-
justifyContent: "center",
|
|
2955
|
-
width: "100%"
|
|
2956
|
-
}
|
|
2957
|
-
}, /* @__PURE__ */ React2__namespace.default.createElement("input", {
|
|
2958
|
-
type: "checkbox",
|
|
305
|
+
return /* @__PURE__ */ React__default.default.createElement(Checkbox, {
|
|
306
|
+
indeterminate: hasSelection && !isAllSelected,
|
|
2959
307
|
checked: isAllSelected,
|
|
2960
|
-
|
|
2961
|
-
if (input) input.indeterminate = hasSelection && !isAllSelected;
|
|
2962
|
-
},
|
|
2963
|
-
onChange: onToggleAll,
|
|
308
|
+
onCheckedChange: onToggleAll,
|
|
2964
309
|
"aria-label": "Select all rows"
|
|
2965
|
-
})
|
|
310
|
+
});
|
|
2966
311
|
}
|
|
2967
|
-
var noop = () => {
|
|
2968
|
-
};
|
|
2969
312
|
function SelectionCell({
|
|
2970
313
|
row,
|
|
2971
314
|
onToggleRow
|
|
2972
315
|
}) {
|
|
2973
|
-
const
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
onToggleRow(row.id, row.index, e.shiftKey);
|
|
316
|
+
const handleClick = React.useCallback((event) => {
|
|
317
|
+
const isShiftClick = event.shiftKey;
|
|
318
|
+
onToggleRow(row.id, row.index, isShiftClick);
|
|
2977
319
|
}, [row, onToggleRow]);
|
|
2978
|
-
return /* @__PURE__ */
|
|
2979
|
-
|
|
2980
|
-
display: "flex",
|
|
2981
|
-
alignItems: "center",
|
|
2982
|
-
justifyContent: "center",
|
|
2983
|
-
width: "100%"
|
|
2984
|
-
}
|
|
2985
|
-
}, /* @__PURE__ */ React2__namespace.default.createElement("input", {
|
|
2986
|
-
type: "checkbox",
|
|
2987
|
-
checked: isSelected,
|
|
320
|
+
return /* @__PURE__ */ React__default.default.createElement(Checkbox, {
|
|
321
|
+
checked: row.getIsSelected(),
|
|
2988
322
|
onClick: handleClick,
|
|
2989
|
-
onChange: noop,
|
|
2990
323
|
"aria-label": `Select row ${row.index + 1}`
|
|
2991
|
-
})
|
|
324
|
+
});
|
|
2992
325
|
}
|
|
2993
326
|
|
|
2994
327
|
// src/object-table/hooks/useSelectionColumn.tsx
|
|
@@ -3000,18 +333,18 @@ var useSelectionColumn = ({
|
|
|
3000
333
|
onToggleAll,
|
|
3001
334
|
onToggleRow
|
|
3002
335
|
}) => {
|
|
3003
|
-
const selectionColumn =
|
|
336
|
+
const selectionColumn = React.useMemo(() => {
|
|
3004
337
|
if (selectionMode === "none") return null;
|
|
3005
338
|
return {
|
|
3006
339
|
id: SELECTION_COLUMN_ID,
|
|
3007
|
-
header: () => selectionMode === "multiple" ? /* @__PURE__ */
|
|
340
|
+
header: () => selectionMode === "multiple" ? /* @__PURE__ */ React__default.default.createElement(SelectionHeaderCell, {
|
|
3008
341
|
isAllSelected,
|
|
3009
342
|
hasSelection,
|
|
3010
343
|
onToggleAll
|
|
3011
344
|
}) : null,
|
|
3012
345
|
cell: ({
|
|
3013
346
|
row
|
|
3014
|
-
}) => /* @__PURE__ */
|
|
347
|
+
}) => /* @__PURE__ */ React__default.default.createElement(SelectionCell, {
|
|
3015
348
|
row,
|
|
3016
349
|
onToggleRow
|
|
3017
350
|
}),
|
|
@@ -3024,884 +357,14 @@ var useSelectionColumn = ({
|
|
|
3024
357
|
}, [selectionMode, isAllSelected, hasSelection, onToggleAll, onToggleRow]);
|
|
3025
358
|
return selectionColumn;
|
|
3026
359
|
};
|
|
3027
|
-
|
|
3028
|
-
// ../../node_modules/.pnpm/@tanstack+virtual-core@3.13.17/node_modules/@tanstack/virtual-core/dist/esm/utils.js
|
|
3029
|
-
function memo2(getDeps, fn, opts) {
|
|
3030
|
-
let deps = opts.initialDeps ?? [];
|
|
3031
|
-
let result;
|
|
3032
|
-
let isInitial = true;
|
|
3033
|
-
function memoizedFunction() {
|
|
3034
|
-
var _a, _b, _c;
|
|
3035
|
-
let depTime;
|
|
3036
|
-
if (opts.key && ((_a = opts.debug) == null ? void 0 : _a.call(opts))) depTime = Date.now();
|
|
3037
|
-
const newDeps = getDeps();
|
|
3038
|
-
const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
|
|
3039
|
-
if (!depsChanged) {
|
|
3040
|
-
return result;
|
|
3041
|
-
}
|
|
3042
|
-
deps = newDeps;
|
|
3043
|
-
let resultTime;
|
|
3044
|
-
if (opts.key && ((_b = opts.debug) == null ? void 0 : _b.call(opts))) resultTime = Date.now();
|
|
3045
|
-
result = fn(...newDeps);
|
|
3046
|
-
if (opts.key && ((_c = opts.debug) == null ? void 0 : _c.call(opts))) {
|
|
3047
|
-
const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
|
|
3048
|
-
const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
|
|
3049
|
-
const resultFpsPercentage = resultEndTime / 16;
|
|
3050
|
-
const pad = (str, num) => {
|
|
3051
|
-
str = String(str);
|
|
3052
|
-
while (str.length < num) {
|
|
3053
|
-
str = " " + str;
|
|
3054
|
-
}
|
|
3055
|
-
return str;
|
|
3056
|
-
};
|
|
3057
|
-
console.info(`%c\u23F1 ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`, `
|
|
3058
|
-
font-size: .6rem;
|
|
3059
|
-
font-weight: bold;
|
|
3060
|
-
color: hsl(${Math.max(0, Math.min(120 - 120 * resultFpsPercentage, 120))}deg 100% 31%);`, opts == null ? void 0 : opts.key);
|
|
3061
|
-
}
|
|
3062
|
-
if ((opts == null ? void 0 : opts.onChange) && !(isInitial && opts.skipInitialOnChange)) {
|
|
3063
|
-
opts.onChange(result);
|
|
3064
|
-
}
|
|
3065
|
-
isInitial = false;
|
|
3066
|
-
return result;
|
|
3067
|
-
}
|
|
3068
|
-
memoizedFunction.updateDeps = (newDeps) => {
|
|
3069
|
-
deps = newDeps;
|
|
3070
|
-
};
|
|
3071
|
-
return memoizedFunction;
|
|
3072
|
-
}
|
|
3073
|
-
function notUndefined(value, msg) {
|
|
3074
|
-
if (value === void 0) {
|
|
3075
|
-
throw new Error(`Unexpected undefined${""}`);
|
|
3076
|
-
} else {
|
|
3077
|
-
return value;
|
|
3078
|
-
}
|
|
3079
|
-
}
|
|
3080
|
-
var approxEqual = (a, b) => Math.abs(a - b) < 1.01;
|
|
3081
|
-
var debounce = (targetWindow, fn, ms) => {
|
|
3082
|
-
let timeoutId;
|
|
3083
|
-
return function(...args) {
|
|
3084
|
-
targetWindow.clearTimeout(timeoutId);
|
|
3085
|
-
timeoutId = targetWindow.setTimeout(() => fn.apply(this, args), ms);
|
|
3086
|
-
};
|
|
3087
|
-
};
|
|
3088
|
-
|
|
3089
|
-
// ../../node_modules/.pnpm/@tanstack+virtual-core@3.13.17/node_modules/@tanstack/virtual-core/dist/esm/index.js
|
|
3090
|
-
var getRect = (element) => {
|
|
3091
|
-
const {
|
|
3092
|
-
offsetWidth,
|
|
3093
|
-
offsetHeight
|
|
3094
|
-
} = element;
|
|
3095
|
-
return {
|
|
3096
|
-
width: offsetWidth,
|
|
3097
|
-
height: offsetHeight
|
|
3098
|
-
};
|
|
3099
|
-
};
|
|
3100
|
-
var defaultKeyExtractor = (index) => index;
|
|
3101
|
-
var defaultRangeExtractor = (range) => {
|
|
3102
|
-
const start = Math.max(range.startIndex - range.overscan, 0);
|
|
3103
|
-
const end = Math.min(range.endIndex + range.overscan, range.count - 1);
|
|
3104
|
-
const arr = [];
|
|
3105
|
-
for (let i = start; i <= end; i++) {
|
|
3106
|
-
arr.push(i);
|
|
3107
|
-
}
|
|
3108
|
-
return arr;
|
|
3109
|
-
};
|
|
3110
|
-
var observeElementRect = (instance, cb) => {
|
|
3111
|
-
const element = instance.scrollElement;
|
|
3112
|
-
if (!element) {
|
|
3113
|
-
return;
|
|
3114
|
-
}
|
|
3115
|
-
const targetWindow = instance.targetWindow;
|
|
3116
|
-
if (!targetWindow) {
|
|
3117
|
-
return;
|
|
3118
|
-
}
|
|
3119
|
-
const handler = (rect) => {
|
|
3120
|
-
const {
|
|
3121
|
-
width,
|
|
3122
|
-
height
|
|
3123
|
-
} = rect;
|
|
3124
|
-
cb({
|
|
3125
|
-
width: Math.round(width),
|
|
3126
|
-
height: Math.round(height)
|
|
3127
|
-
});
|
|
3128
|
-
};
|
|
3129
|
-
handler(getRect(element));
|
|
3130
|
-
if (!targetWindow.ResizeObserver) {
|
|
3131
|
-
return () => {
|
|
3132
|
-
};
|
|
3133
|
-
}
|
|
3134
|
-
const observer = new targetWindow.ResizeObserver((entries) => {
|
|
3135
|
-
const run = () => {
|
|
3136
|
-
const entry = entries[0];
|
|
3137
|
-
if (entry == null ? void 0 : entry.borderBoxSize) {
|
|
3138
|
-
const box = entry.borderBoxSize[0];
|
|
3139
|
-
if (box) {
|
|
3140
|
-
handler({
|
|
3141
|
-
width: box.inlineSize,
|
|
3142
|
-
height: box.blockSize
|
|
3143
|
-
});
|
|
3144
|
-
return;
|
|
3145
|
-
}
|
|
3146
|
-
}
|
|
3147
|
-
handler(getRect(element));
|
|
3148
|
-
};
|
|
3149
|
-
instance.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
|
|
3150
|
-
});
|
|
3151
|
-
observer.observe(element, {
|
|
3152
|
-
box: "border-box"
|
|
3153
|
-
});
|
|
3154
|
-
return () => {
|
|
3155
|
-
observer.unobserve(element);
|
|
3156
|
-
};
|
|
3157
|
-
};
|
|
3158
|
-
var addEventListenerOptions = {
|
|
3159
|
-
passive: true
|
|
3160
|
-
};
|
|
3161
|
-
var supportsScrollend = typeof window == "undefined" ? true : "onscrollend" in window;
|
|
3162
|
-
var observeElementOffset = (instance, cb) => {
|
|
3163
|
-
const element = instance.scrollElement;
|
|
3164
|
-
if (!element) {
|
|
3165
|
-
return;
|
|
3166
|
-
}
|
|
3167
|
-
const targetWindow = instance.targetWindow;
|
|
3168
|
-
if (!targetWindow) {
|
|
3169
|
-
return;
|
|
3170
|
-
}
|
|
3171
|
-
let offset = 0;
|
|
3172
|
-
const fallback = instance.options.useScrollendEvent && supportsScrollend ? () => void 0 : debounce(targetWindow, () => {
|
|
3173
|
-
cb(offset, false);
|
|
3174
|
-
}, instance.options.isScrollingResetDelay);
|
|
3175
|
-
const createHandler = (isScrolling) => () => {
|
|
3176
|
-
const {
|
|
3177
|
-
horizontal,
|
|
3178
|
-
isRtl
|
|
3179
|
-
} = instance.options;
|
|
3180
|
-
offset = horizontal ? element["scrollLeft"] * (isRtl && -1 || 1) : element["scrollTop"];
|
|
3181
|
-
fallback();
|
|
3182
|
-
cb(offset, isScrolling);
|
|
3183
|
-
};
|
|
3184
|
-
const handler = createHandler(true);
|
|
3185
|
-
const endHandler = createHandler(false);
|
|
3186
|
-
element.addEventListener("scroll", handler, addEventListenerOptions);
|
|
3187
|
-
const registerScrollendEvent = instance.options.useScrollendEvent && supportsScrollend;
|
|
3188
|
-
if (registerScrollendEvent) {
|
|
3189
|
-
element.addEventListener("scrollend", endHandler, addEventListenerOptions);
|
|
3190
|
-
}
|
|
3191
|
-
return () => {
|
|
3192
|
-
element.removeEventListener("scroll", handler);
|
|
3193
|
-
if (registerScrollendEvent) {
|
|
3194
|
-
element.removeEventListener("scrollend", endHandler);
|
|
3195
|
-
}
|
|
3196
|
-
};
|
|
3197
|
-
};
|
|
3198
|
-
var measureElement = (element, entry, instance) => {
|
|
3199
|
-
if (entry == null ? void 0 : entry.borderBoxSize) {
|
|
3200
|
-
const box = entry.borderBoxSize[0];
|
|
3201
|
-
if (box) {
|
|
3202
|
-
const size = Math.round(box[instance.options.horizontal ? "inlineSize" : "blockSize"]);
|
|
3203
|
-
return size;
|
|
3204
|
-
}
|
|
3205
|
-
}
|
|
3206
|
-
return element[instance.options.horizontal ? "offsetWidth" : "offsetHeight"];
|
|
3207
|
-
};
|
|
3208
|
-
var elementScroll = (offset, {
|
|
3209
|
-
adjustments = 0,
|
|
3210
|
-
behavior
|
|
3211
|
-
}, instance) => {
|
|
3212
|
-
var _a, _b;
|
|
3213
|
-
const toOffset = offset + adjustments;
|
|
3214
|
-
(_b = (_a = instance.scrollElement) == null ? void 0 : _a.scrollTo) == null ? void 0 : _b.call(_a, {
|
|
3215
|
-
[instance.options.horizontal ? "left" : "top"]: toOffset,
|
|
3216
|
-
behavior
|
|
3217
|
-
});
|
|
3218
|
-
};
|
|
3219
|
-
var Virtualizer = class {
|
|
3220
|
-
constructor(opts) {
|
|
3221
|
-
this.unsubs = [];
|
|
3222
|
-
this.scrollElement = null;
|
|
3223
|
-
this.targetWindow = null;
|
|
3224
|
-
this.isScrolling = false;
|
|
3225
|
-
this.currentScrollToIndex = null;
|
|
3226
|
-
this.measurementsCache = [];
|
|
3227
|
-
this.itemSizeCache = /* @__PURE__ */ new Map();
|
|
3228
|
-
this.laneAssignments = /* @__PURE__ */ new Map();
|
|
3229
|
-
this.pendingMeasuredCacheIndexes = [];
|
|
3230
|
-
this.prevLanes = void 0;
|
|
3231
|
-
this.lanesChangedFlag = false;
|
|
3232
|
-
this.lanesSettling = false;
|
|
3233
|
-
this.scrollRect = null;
|
|
3234
|
-
this.scrollOffset = null;
|
|
3235
|
-
this.scrollDirection = null;
|
|
3236
|
-
this.scrollAdjustments = 0;
|
|
3237
|
-
this.elementsCache = /* @__PURE__ */ new Map();
|
|
3238
|
-
this.observer = /* @__PURE__ */ (() => {
|
|
3239
|
-
let _ro = null;
|
|
3240
|
-
const get = () => {
|
|
3241
|
-
if (_ro) {
|
|
3242
|
-
return _ro;
|
|
3243
|
-
}
|
|
3244
|
-
if (!this.targetWindow || !this.targetWindow.ResizeObserver) {
|
|
3245
|
-
return null;
|
|
3246
|
-
}
|
|
3247
|
-
return _ro = new this.targetWindow.ResizeObserver((entries) => {
|
|
3248
|
-
entries.forEach((entry) => {
|
|
3249
|
-
const run = () => {
|
|
3250
|
-
this._measureElement(entry.target, entry);
|
|
3251
|
-
};
|
|
3252
|
-
this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
|
|
3253
|
-
});
|
|
3254
|
-
});
|
|
3255
|
-
};
|
|
3256
|
-
return {
|
|
3257
|
-
disconnect: () => {
|
|
3258
|
-
var _a;
|
|
3259
|
-
(_a = get()) == null ? void 0 : _a.disconnect();
|
|
3260
|
-
_ro = null;
|
|
3261
|
-
},
|
|
3262
|
-
observe: (target) => {
|
|
3263
|
-
var _a;
|
|
3264
|
-
return (_a = get()) == null ? void 0 : _a.observe(target, {
|
|
3265
|
-
box: "border-box"
|
|
3266
|
-
});
|
|
3267
|
-
},
|
|
3268
|
-
unobserve: (target) => {
|
|
3269
|
-
var _a;
|
|
3270
|
-
return (_a = get()) == null ? void 0 : _a.unobserve(target);
|
|
3271
|
-
}
|
|
3272
|
-
};
|
|
3273
|
-
})();
|
|
3274
|
-
this.range = null;
|
|
3275
|
-
this.setOptions = (opts2) => {
|
|
3276
|
-
Object.entries(opts2).forEach(([key, value]) => {
|
|
3277
|
-
if (typeof value === "undefined") delete opts2[key];
|
|
3278
|
-
});
|
|
3279
|
-
this.options = {
|
|
3280
|
-
debug: false,
|
|
3281
|
-
initialOffset: 0,
|
|
3282
|
-
overscan: 1,
|
|
3283
|
-
paddingStart: 0,
|
|
3284
|
-
paddingEnd: 0,
|
|
3285
|
-
scrollPaddingStart: 0,
|
|
3286
|
-
scrollPaddingEnd: 0,
|
|
3287
|
-
horizontal: false,
|
|
3288
|
-
getItemKey: defaultKeyExtractor,
|
|
3289
|
-
rangeExtractor: defaultRangeExtractor,
|
|
3290
|
-
onChange: () => {
|
|
3291
|
-
},
|
|
3292
|
-
measureElement,
|
|
3293
|
-
initialRect: {
|
|
3294
|
-
width: 0,
|
|
3295
|
-
height: 0
|
|
3296
|
-
},
|
|
3297
|
-
scrollMargin: 0,
|
|
3298
|
-
gap: 0,
|
|
3299
|
-
indexAttribute: "data-index",
|
|
3300
|
-
initialMeasurementsCache: [],
|
|
3301
|
-
lanes: 1,
|
|
3302
|
-
isScrollingResetDelay: 150,
|
|
3303
|
-
enabled: true,
|
|
3304
|
-
isRtl: false,
|
|
3305
|
-
useScrollendEvent: false,
|
|
3306
|
-
useAnimationFrameWithResizeObserver: false,
|
|
3307
|
-
...opts2
|
|
3308
|
-
};
|
|
3309
|
-
};
|
|
3310
|
-
this.notify = (sync) => {
|
|
3311
|
-
var _a, _b;
|
|
3312
|
-
(_b = (_a = this.options).onChange) == null ? void 0 : _b.call(_a, this, sync);
|
|
3313
|
-
};
|
|
3314
|
-
this.maybeNotify = memo2(() => {
|
|
3315
|
-
this.calculateRange();
|
|
3316
|
-
return [this.isScrolling, this.range ? this.range.startIndex : null, this.range ? this.range.endIndex : null];
|
|
3317
|
-
}, (isScrolling) => {
|
|
3318
|
-
this.notify(isScrolling);
|
|
3319
|
-
}, {
|
|
3320
|
-
key: process.env.NODE_ENV !== "production" && "maybeNotify",
|
|
3321
|
-
debug: () => this.options.debug,
|
|
3322
|
-
initialDeps: [this.isScrolling, this.range ? this.range.startIndex : null, this.range ? this.range.endIndex : null]
|
|
3323
|
-
});
|
|
3324
|
-
this.cleanup = () => {
|
|
3325
|
-
this.unsubs.filter(Boolean).forEach((d) => d());
|
|
3326
|
-
this.unsubs = [];
|
|
3327
|
-
this.observer.disconnect();
|
|
3328
|
-
this.scrollElement = null;
|
|
3329
|
-
this.targetWindow = null;
|
|
3330
|
-
};
|
|
3331
|
-
this._didMount = () => {
|
|
3332
|
-
return () => {
|
|
3333
|
-
this.cleanup();
|
|
3334
|
-
};
|
|
3335
|
-
};
|
|
3336
|
-
this._willUpdate = () => {
|
|
3337
|
-
var _a;
|
|
3338
|
-
const scrollElement = this.options.enabled ? this.options.getScrollElement() : null;
|
|
3339
|
-
if (this.scrollElement !== scrollElement) {
|
|
3340
|
-
this.cleanup();
|
|
3341
|
-
if (!scrollElement) {
|
|
3342
|
-
this.maybeNotify();
|
|
3343
|
-
return;
|
|
3344
|
-
}
|
|
3345
|
-
this.scrollElement = scrollElement;
|
|
3346
|
-
if (this.scrollElement && "ownerDocument" in this.scrollElement) {
|
|
3347
|
-
this.targetWindow = this.scrollElement.ownerDocument.defaultView;
|
|
3348
|
-
} else {
|
|
3349
|
-
this.targetWindow = ((_a = this.scrollElement) == null ? void 0 : _a.window) ?? null;
|
|
3350
|
-
}
|
|
3351
|
-
this.elementsCache.forEach((cached) => {
|
|
3352
|
-
this.observer.observe(cached);
|
|
3353
|
-
});
|
|
3354
|
-
this.unsubs.push(this.options.observeElementRect(this, (rect) => {
|
|
3355
|
-
this.scrollRect = rect;
|
|
3356
|
-
this.maybeNotify();
|
|
3357
|
-
}));
|
|
3358
|
-
this.unsubs.push(this.options.observeElementOffset(this, (offset, isScrolling) => {
|
|
3359
|
-
this.scrollAdjustments = 0;
|
|
3360
|
-
this.scrollDirection = isScrolling ? this.getScrollOffset() < offset ? "forward" : "backward" : null;
|
|
3361
|
-
this.scrollOffset = offset;
|
|
3362
|
-
this.isScrolling = isScrolling;
|
|
3363
|
-
this.maybeNotify();
|
|
3364
|
-
}));
|
|
3365
|
-
this._scrollToOffset(this.getScrollOffset(), {
|
|
3366
|
-
adjustments: void 0,
|
|
3367
|
-
behavior: void 0
|
|
3368
|
-
});
|
|
3369
|
-
}
|
|
3370
|
-
};
|
|
3371
|
-
this.getSize = () => {
|
|
3372
|
-
if (!this.options.enabled) {
|
|
3373
|
-
this.scrollRect = null;
|
|
3374
|
-
return 0;
|
|
3375
|
-
}
|
|
3376
|
-
this.scrollRect = this.scrollRect ?? this.options.initialRect;
|
|
3377
|
-
return this.scrollRect[this.options.horizontal ? "width" : "height"];
|
|
3378
|
-
};
|
|
3379
|
-
this.getScrollOffset = () => {
|
|
3380
|
-
if (!this.options.enabled) {
|
|
3381
|
-
this.scrollOffset = null;
|
|
3382
|
-
return 0;
|
|
3383
|
-
}
|
|
3384
|
-
this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset === "function" ? this.options.initialOffset() : this.options.initialOffset);
|
|
3385
|
-
return this.scrollOffset;
|
|
3386
|
-
};
|
|
3387
|
-
this.getFurthestMeasurement = (measurements, index) => {
|
|
3388
|
-
const furthestMeasurementsFound = /* @__PURE__ */ new Map();
|
|
3389
|
-
const furthestMeasurements = /* @__PURE__ */ new Map();
|
|
3390
|
-
for (let m = index - 1; m >= 0; m--) {
|
|
3391
|
-
const measurement = measurements[m];
|
|
3392
|
-
if (furthestMeasurementsFound.has(measurement.lane)) {
|
|
3393
|
-
continue;
|
|
3394
|
-
}
|
|
3395
|
-
const previousFurthestMeasurement = furthestMeasurements.get(measurement.lane);
|
|
3396
|
-
if (previousFurthestMeasurement == null || measurement.end > previousFurthestMeasurement.end) {
|
|
3397
|
-
furthestMeasurements.set(measurement.lane, measurement);
|
|
3398
|
-
} else if (measurement.end < previousFurthestMeasurement.end) {
|
|
3399
|
-
furthestMeasurementsFound.set(measurement.lane, true);
|
|
3400
|
-
}
|
|
3401
|
-
if (furthestMeasurementsFound.size === this.options.lanes) {
|
|
3402
|
-
break;
|
|
3403
|
-
}
|
|
3404
|
-
}
|
|
3405
|
-
return furthestMeasurements.size === this.options.lanes ? Array.from(furthestMeasurements.values()).sort((a, b) => {
|
|
3406
|
-
if (a.end === b.end) {
|
|
3407
|
-
return a.index - b.index;
|
|
3408
|
-
}
|
|
3409
|
-
return a.end - b.end;
|
|
3410
|
-
})[0] : void 0;
|
|
3411
|
-
};
|
|
3412
|
-
this.getMeasurementOptions = memo2(() => [this.options.count, this.options.paddingStart, this.options.scrollMargin, this.options.getItemKey, this.options.enabled, this.options.lanes], (count2, paddingStart, scrollMargin, getItemKey, enabled, lanes) => {
|
|
3413
|
-
const lanesChanged = this.prevLanes !== void 0 && this.prevLanes !== lanes;
|
|
3414
|
-
if (lanesChanged) {
|
|
3415
|
-
this.lanesChangedFlag = true;
|
|
3416
|
-
}
|
|
3417
|
-
this.prevLanes = lanes;
|
|
3418
|
-
this.pendingMeasuredCacheIndexes = [];
|
|
3419
|
-
return {
|
|
3420
|
-
count: count2,
|
|
3421
|
-
paddingStart,
|
|
3422
|
-
scrollMargin,
|
|
3423
|
-
getItemKey,
|
|
3424
|
-
enabled,
|
|
3425
|
-
lanes
|
|
3426
|
-
};
|
|
3427
|
-
}, {
|
|
3428
|
-
key: false,
|
|
3429
|
-
skipInitialOnChange: true,
|
|
3430
|
-
onChange: () => {
|
|
3431
|
-
this.notify(this.isScrolling);
|
|
3432
|
-
}
|
|
3433
|
-
});
|
|
3434
|
-
this.getMeasurements = memo2(() => [this.getMeasurementOptions(), this.itemSizeCache], ({
|
|
3435
|
-
count: count2,
|
|
3436
|
-
paddingStart,
|
|
3437
|
-
scrollMargin,
|
|
3438
|
-
getItemKey,
|
|
3439
|
-
enabled,
|
|
3440
|
-
lanes
|
|
3441
|
-
}, itemSizeCache) => {
|
|
3442
|
-
if (!enabled) {
|
|
3443
|
-
this.measurementsCache = [];
|
|
3444
|
-
this.itemSizeCache.clear();
|
|
3445
|
-
this.laneAssignments.clear();
|
|
3446
|
-
return [];
|
|
3447
|
-
}
|
|
3448
|
-
if (this.laneAssignments.size > count2) {
|
|
3449
|
-
for (const index of this.laneAssignments.keys()) {
|
|
3450
|
-
if (index >= count2) {
|
|
3451
|
-
this.laneAssignments.delete(index);
|
|
3452
|
-
}
|
|
3453
|
-
}
|
|
3454
|
-
}
|
|
3455
|
-
if (this.lanesChangedFlag) {
|
|
3456
|
-
this.lanesChangedFlag = false;
|
|
3457
|
-
this.lanesSettling = true;
|
|
3458
|
-
this.measurementsCache = [];
|
|
3459
|
-
this.itemSizeCache.clear();
|
|
3460
|
-
this.laneAssignments.clear();
|
|
3461
|
-
this.pendingMeasuredCacheIndexes = [];
|
|
3462
|
-
}
|
|
3463
|
-
if (this.measurementsCache.length === 0 && !this.lanesSettling) {
|
|
3464
|
-
this.measurementsCache = this.options.initialMeasurementsCache;
|
|
3465
|
-
this.measurementsCache.forEach((item) => {
|
|
3466
|
-
this.itemSizeCache.set(item.key, item.size);
|
|
3467
|
-
});
|
|
3468
|
-
}
|
|
3469
|
-
const min2 = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
|
|
3470
|
-
this.pendingMeasuredCacheIndexes = [];
|
|
3471
|
-
if (this.lanesSettling && this.measurementsCache.length === count2) {
|
|
3472
|
-
this.lanesSettling = false;
|
|
3473
|
-
}
|
|
3474
|
-
const measurements = this.measurementsCache.slice(0, min2);
|
|
3475
|
-
const laneLastIndex = new Array(lanes).fill(void 0);
|
|
3476
|
-
for (let m = 0; m < min2; m++) {
|
|
3477
|
-
const item = measurements[m];
|
|
3478
|
-
if (item) {
|
|
3479
|
-
laneLastIndex[item.lane] = m;
|
|
3480
|
-
}
|
|
3481
|
-
}
|
|
3482
|
-
for (let i = min2; i < count2; i++) {
|
|
3483
|
-
const key = getItemKey(i);
|
|
3484
|
-
const cachedLane = this.laneAssignments.get(i);
|
|
3485
|
-
let lane;
|
|
3486
|
-
let start;
|
|
3487
|
-
if (cachedLane !== void 0 && this.options.lanes > 1) {
|
|
3488
|
-
lane = cachedLane;
|
|
3489
|
-
const prevIndex = laneLastIndex[lane];
|
|
3490
|
-
const prevInLane = prevIndex !== void 0 ? measurements[prevIndex] : void 0;
|
|
3491
|
-
start = prevInLane ? prevInLane.end + this.options.gap : paddingStart + scrollMargin;
|
|
3492
|
-
} else {
|
|
3493
|
-
const furthestMeasurement = this.options.lanes === 1 ? measurements[i - 1] : this.getFurthestMeasurement(measurements, i);
|
|
3494
|
-
start = furthestMeasurement ? furthestMeasurement.end + this.options.gap : paddingStart + scrollMargin;
|
|
3495
|
-
lane = furthestMeasurement ? furthestMeasurement.lane : i % this.options.lanes;
|
|
3496
|
-
if (this.options.lanes > 1) {
|
|
3497
|
-
this.laneAssignments.set(i, lane);
|
|
3498
|
-
}
|
|
3499
|
-
}
|
|
3500
|
-
const measuredSize = itemSizeCache.get(key);
|
|
3501
|
-
const size = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i);
|
|
3502
|
-
const end = start + size;
|
|
3503
|
-
measurements[i] = {
|
|
3504
|
-
index: i,
|
|
3505
|
-
start,
|
|
3506
|
-
size,
|
|
3507
|
-
end,
|
|
3508
|
-
key,
|
|
3509
|
-
lane
|
|
3510
|
-
};
|
|
3511
|
-
laneLastIndex[lane] = i;
|
|
3512
|
-
}
|
|
3513
|
-
this.measurementsCache = measurements;
|
|
3514
|
-
return measurements;
|
|
3515
|
-
}, {
|
|
3516
|
-
key: process.env.NODE_ENV !== "production" && "getMeasurements",
|
|
3517
|
-
debug: () => this.options.debug
|
|
3518
|
-
});
|
|
3519
|
-
this.calculateRange = memo2(() => [this.getMeasurements(), this.getSize(), this.getScrollOffset(), this.options.lanes], (measurements, outerSize, scrollOffset, lanes) => {
|
|
3520
|
-
return this.range = measurements.length > 0 && outerSize > 0 ? calculateRange({
|
|
3521
|
-
measurements,
|
|
3522
|
-
outerSize,
|
|
3523
|
-
scrollOffset,
|
|
3524
|
-
lanes
|
|
3525
|
-
}) : null;
|
|
3526
|
-
}, {
|
|
3527
|
-
key: process.env.NODE_ENV !== "production" && "calculateRange",
|
|
3528
|
-
debug: () => this.options.debug
|
|
3529
|
-
});
|
|
3530
|
-
this.getVirtualIndexes = memo2(() => {
|
|
3531
|
-
let startIndex = null;
|
|
3532
|
-
let endIndex = null;
|
|
3533
|
-
const range = this.calculateRange();
|
|
3534
|
-
if (range) {
|
|
3535
|
-
startIndex = range.startIndex;
|
|
3536
|
-
endIndex = range.endIndex;
|
|
3537
|
-
}
|
|
3538
|
-
this.maybeNotify.updateDeps([this.isScrolling, startIndex, endIndex]);
|
|
3539
|
-
return [this.options.rangeExtractor, this.options.overscan, this.options.count, startIndex, endIndex];
|
|
3540
|
-
}, (rangeExtractor, overscan, count2, startIndex, endIndex) => {
|
|
3541
|
-
return startIndex === null || endIndex === null ? [] : rangeExtractor({
|
|
3542
|
-
startIndex,
|
|
3543
|
-
endIndex,
|
|
3544
|
-
overscan,
|
|
3545
|
-
count: count2
|
|
3546
|
-
});
|
|
3547
|
-
}, {
|
|
3548
|
-
key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
|
|
3549
|
-
debug: () => this.options.debug
|
|
3550
|
-
});
|
|
3551
|
-
this.indexFromElement = (node) => {
|
|
3552
|
-
const attributeName = this.options.indexAttribute;
|
|
3553
|
-
const indexStr = node.getAttribute(attributeName);
|
|
3554
|
-
if (!indexStr) {
|
|
3555
|
-
console.warn(`Missing attribute name '${attributeName}={index}' on measured element.`);
|
|
3556
|
-
return -1;
|
|
3557
|
-
}
|
|
3558
|
-
return parseInt(indexStr, 10);
|
|
3559
|
-
};
|
|
3560
|
-
this._measureElement = (node, entry) => {
|
|
3561
|
-
const index = this.indexFromElement(node);
|
|
3562
|
-
const item = this.measurementsCache[index];
|
|
3563
|
-
if (!item) {
|
|
3564
|
-
return;
|
|
3565
|
-
}
|
|
3566
|
-
const key = item.key;
|
|
3567
|
-
const prevNode = this.elementsCache.get(key);
|
|
3568
|
-
if (prevNode !== node) {
|
|
3569
|
-
if (prevNode) {
|
|
3570
|
-
this.observer.unobserve(prevNode);
|
|
3571
|
-
}
|
|
3572
|
-
this.observer.observe(node);
|
|
3573
|
-
this.elementsCache.set(key, node);
|
|
3574
|
-
}
|
|
3575
|
-
if (node.isConnected) {
|
|
3576
|
-
this.resizeItem(index, this.options.measureElement(node, entry, this));
|
|
3577
|
-
}
|
|
3578
|
-
};
|
|
3579
|
-
this.resizeItem = (index, size) => {
|
|
3580
|
-
const item = this.measurementsCache[index];
|
|
3581
|
-
if (!item) {
|
|
3582
|
-
return;
|
|
3583
|
-
}
|
|
3584
|
-
const itemSize = this.itemSizeCache.get(item.key) ?? item.size;
|
|
3585
|
-
const delta = size - itemSize;
|
|
3586
|
-
if (delta !== 0) {
|
|
3587
|
-
if (this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(item, delta, this) : item.start < this.getScrollOffset() + this.scrollAdjustments) {
|
|
3588
|
-
if (process.env.NODE_ENV !== "production" && this.options.debug) {
|
|
3589
|
-
console.info("correction", delta);
|
|
3590
|
-
}
|
|
3591
|
-
this._scrollToOffset(this.getScrollOffset(), {
|
|
3592
|
-
adjustments: this.scrollAdjustments += delta,
|
|
3593
|
-
behavior: void 0
|
|
3594
|
-
});
|
|
3595
|
-
}
|
|
3596
|
-
this.pendingMeasuredCacheIndexes.push(item.index);
|
|
3597
|
-
this.itemSizeCache = new Map(this.itemSizeCache.set(item.key, size));
|
|
3598
|
-
this.notify(false);
|
|
3599
|
-
}
|
|
3600
|
-
};
|
|
3601
|
-
this.measureElement = (node) => {
|
|
3602
|
-
if (!node) {
|
|
3603
|
-
this.elementsCache.forEach((cached, key) => {
|
|
3604
|
-
if (!cached.isConnected) {
|
|
3605
|
-
this.observer.unobserve(cached);
|
|
3606
|
-
this.elementsCache.delete(key);
|
|
3607
|
-
}
|
|
3608
|
-
});
|
|
3609
|
-
return;
|
|
3610
|
-
}
|
|
3611
|
-
this._measureElement(node, void 0);
|
|
3612
|
-
};
|
|
3613
|
-
this.getVirtualItems = memo2(() => [this.getVirtualIndexes(), this.getMeasurements()], (indexes, measurements) => {
|
|
3614
|
-
const virtualItems = [];
|
|
3615
|
-
for (let k = 0, len = indexes.length; k < len; k++) {
|
|
3616
|
-
const i = indexes[k];
|
|
3617
|
-
const measurement = measurements[i];
|
|
3618
|
-
virtualItems.push(measurement);
|
|
3619
|
-
}
|
|
3620
|
-
return virtualItems;
|
|
3621
|
-
}, {
|
|
3622
|
-
key: process.env.NODE_ENV !== "production" && "getVirtualItems",
|
|
3623
|
-
debug: () => this.options.debug
|
|
3624
|
-
});
|
|
3625
|
-
this.getVirtualItemForOffset = (offset) => {
|
|
3626
|
-
const measurements = this.getMeasurements();
|
|
3627
|
-
if (measurements.length === 0) {
|
|
3628
|
-
return void 0;
|
|
3629
|
-
}
|
|
3630
|
-
return notUndefined(measurements[findNearestBinarySearch(0, measurements.length - 1, (index) => notUndefined(measurements[index]).start, offset)]);
|
|
3631
|
-
};
|
|
3632
|
-
this.getMaxScrollOffset = () => {
|
|
3633
|
-
if (!this.scrollElement) return 0;
|
|
3634
|
-
if ("scrollHeight" in this.scrollElement) {
|
|
3635
|
-
return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
|
|
3636
|
-
} else {
|
|
3637
|
-
const doc = this.scrollElement.document.documentElement;
|
|
3638
|
-
return this.options.horizontal ? doc.scrollWidth - this.scrollElement.innerWidth : doc.scrollHeight - this.scrollElement.innerHeight;
|
|
3639
|
-
}
|
|
3640
|
-
};
|
|
3641
|
-
this.getOffsetForAlignment = (toOffset, align, itemSize = 0) => {
|
|
3642
|
-
if (!this.scrollElement) return 0;
|
|
3643
|
-
const size = this.getSize();
|
|
3644
|
-
const scrollOffset = this.getScrollOffset();
|
|
3645
|
-
if (align === "auto") {
|
|
3646
|
-
align = toOffset >= scrollOffset + size ? "end" : "start";
|
|
3647
|
-
}
|
|
3648
|
-
if (align === "center") {
|
|
3649
|
-
toOffset += (itemSize - size) / 2;
|
|
3650
|
-
} else if (align === "end") {
|
|
3651
|
-
toOffset -= size;
|
|
3652
|
-
}
|
|
3653
|
-
const maxOffset = this.getMaxScrollOffset();
|
|
3654
|
-
return Math.max(Math.min(maxOffset, toOffset), 0);
|
|
3655
|
-
};
|
|
3656
|
-
this.getOffsetForIndex = (index, align = "auto") => {
|
|
3657
|
-
index = Math.max(0, Math.min(index, this.options.count - 1));
|
|
3658
|
-
const item = this.measurementsCache[index];
|
|
3659
|
-
if (!item) {
|
|
3660
|
-
return void 0;
|
|
3661
|
-
}
|
|
3662
|
-
const size = this.getSize();
|
|
3663
|
-
const scrollOffset = this.getScrollOffset();
|
|
3664
|
-
if (align === "auto") {
|
|
3665
|
-
if (item.end >= scrollOffset + size - this.options.scrollPaddingEnd) {
|
|
3666
|
-
align = "end";
|
|
3667
|
-
} else if (item.start <= scrollOffset + this.options.scrollPaddingStart) {
|
|
3668
|
-
align = "start";
|
|
3669
|
-
} else {
|
|
3670
|
-
return [scrollOffset, align];
|
|
3671
|
-
}
|
|
3672
|
-
}
|
|
3673
|
-
if (align === "end" && index === this.options.count - 1) {
|
|
3674
|
-
return [this.getMaxScrollOffset(), align];
|
|
3675
|
-
}
|
|
3676
|
-
const toOffset = align === "end" ? item.end + this.options.scrollPaddingEnd : item.start - this.options.scrollPaddingStart;
|
|
3677
|
-
return [this.getOffsetForAlignment(toOffset, align, item.size), align];
|
|
3678
|
-
};
|
|
3679
|
-
this.isDynamicMode = () => this.elementsCache.size > 0;
|
|
3680
|
-
this.scrollToOffset = (toOffset, {
|
|
3681
|
-
align = "start",
|
|
3682
|
-
behavior
|
|
3683
|
-
} = {}) => {
|
|
3684
|
-
if (behavior === "smooth" && this.isDynamicMode()) {
|
|
3685
|
-
console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");
|
|
3686
|
-
}
|
|
3687
|
-
this._scrollToOffset(this.getOffsetForAlignment(toOffset, align), {
|
|
3688
|
-
adjustments: void 0,
|
|
3689
|
-
behavior
|
|
3690
|
-
});
|
|
3691
|
-
};
|
|
3692
|
-
this.scrollToIndex = (index, {
|
|
3693
|
-
align: initialAlign = "auto",
|
|
3694
|
-
behavior
|
|
3695
|
-
} = {}) => {
|
|
3696
|
-
if (behavior === "smooth" && this.isDynamicMode()) {
|
|
3697
|
-
console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");
|
|
3698
|
-
}
|
|
3699
|
-
index = Math.max(0, Math.min(index, this.options.count - 1));
|
|
3700
|
-
this.currentScrollToIndex = index;
|
|
3701
|
-
let attempts = 0;
|
|
3702
|
-
const maxAttempts = 10;
|
|
3703
|
-
const tryScroll = (currentAlign) => {
|
|
3704
|
-
if (!this.targetWindow) return;
|
|
3705
|
-
const offsetInfo = this.getOffsetForIndex(index, currentAlign);
|
|
3706
|
-
if (!offsetInfo) {
|
|
3707
|
-
console.warn("Failed to get offset for index:", index);
|
|
3708
|
-
return;
|
|
3709
|
-
}
|
|
3710
|
-
const [offset, align] = offsetInfo;
|
|
3711
|
-
this._scrollToOffset(offset, {
|
|
3712
|
-
adjustments: void 0,
|
|
3713
|
-
behavior
|
|
3714
|
-
});
|
|
3715
|
-
this.targetWindow.requestAnimationFrame(() => {
|
|
3716
|
-
const verify = () => {
|
|
3717
|
-
if (this.currentScrollToIndex !== index) return;
|
|
3718
|
-
const currentOffset = this.getScrollOffset();
|
|
3719
|
-
const afterInfo = this.getOffsetForIndex(index, align);
|
|
3720
|
-
if (!afterInfo) {
|
|
3721
|
-
console.warn("Failed to get offset for index:", index);
|
|
3722
|
-
return;
|
|
3723
|
-
}
|
|
3724
|
-
if (!approxEqual(afterInfo[0], currentOffset)) {
|
|
3725
|
-
scheduleRetry(align);
|
|
3726
|
-
}
|
|
3727
|
-
};
|
|
3728
|
-
if (this.isDynamicMode()) {
|
|
3729
|
-
this.targetWindow.requestAnimationFrame(verify);
|
|
3730
|
-
} else {
|
|
3731
|
-
verify();
|
|
3732
|
-
}
|
|
3733
|
-
});
|
|
3734
|
-
};
|
|
3735
|
-
const scheduleRetry = (align) => {
|
|
3736
|
-
if (!this.targetWindow) return;
|
|
3737
|
-
if (this.currentScrollToIndex !== index) return;
|
|
3738
|
-
attempts++;
|
|
3739
|
-
if (attempts < maxAttempts) {
|
|
3740
|
-
if (process.env.NODE_ENV !== "production" && this.options.debug) {
|
|
3741
|
-
console.info("Schedule retry", attempts, maxAttempts);
|
|
3742
|
-
}
|
|
3743
|
-
this.targetWindow.requestAnimationFrame(() => tryScroll(align));
|
|
3744
|
-
} else {
|
|
3745
|
-
console.warn(`Failed to scroll to index ${index} after ${maxAttempts} attempts.`);
|
|
3746
|
-
}
|
|
3747
|
-
};
|
|
3748
|
-
tryScroll(initialAlign);
|
|
3749
|
-
};
|
|
3750
|
-
this.scrollBy = (delta, {
|
|
3751
|
-
behavior
|
|
3752
|
-
} = {}) => {
|
|
3753
|
-
if (behavior === "smooth" && this.isDynamicMode()) {
|
|
3754
|
-
console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");
|
|
3755
|
-
}
|
|
3756
|
-
this._scrollToOffset(this.getScrollOffset() + delta, {
|
|
3757
|
-
adjustments: void 0,
|
|
3758
|
-
behavior
|
|
3759
|
-
});
|
|
3760
|
-
};
|
|
3761
|
-
this.getTotalSize = () => {
|
|
3762
|
-
var _a;
|
|
3763
|
-
const measurements = this.getMeasurements();
|
|
3764
|
-
let end;
|
|
3765
|
-
if (measurements.length === 0) {
|
|
3766
|
-
end = this.options.paddingStart;
|
|
3767
|
-
} else if (this.options.lanes === 1) {
|
|
3768
|
-
end = ((_a = measurements[measurements.length - 1]) == null ? void 0 : _a.end) ?? 0;
|
|
3769
|
-
} else {
|
|
3770
|
-
const endByLane = Array(this.options.lanes).fill(null);
|
|
3771
|
-
let endIndex = measurements.length - 1;
|
|
3772
|
-
while (endIndex >= 0 && endByLane.some((val) => val === null)) {
|
|
3773
|
-
const item = measurements[endIndex];
|
|
3774
|
-
if (endByLane[item.lane] === null) {
|
|
3775
|
-
endByLane[item.lane] = item.end;
|
|
3776
|
-
}
|
|
3777
|
-
endIndex--;
|
|
3778
|
-
}
|
|
3779
|
-
end = Math.max(...endByLane.filter((val) => val !== null));
|
|
3780
|
-
}
|
|
3781
|
-
return Math.max(end - this.options.scrollMargin + this.options.paddingEnd, 0);
|
|
3782
|
-
};
|
|
3783
|
-
this._scrollToOffset = (offset, {
|
|
3784
|
-
adjustments,
|
|
3785
|
-
behavior
|
|
3786
|
-
}) => {
|
|
3787
|
-
this.options.scrollToFn(offset, {
|
|
3788
|
-
behavior,
|
|
3789
|
-
adjustments
|
|
3790
|
-
}, this);
|
|
3791
|
-
};
|
|
3792
|
-
this.measure = () => {
|
|
3793
|
-
this.itemSizeCache = /* @__PURE__ */ new Map();
|
|
3794
|
-
this.laneAssignments = /* @__PURE__ */ new Map();
|
|
3795
|
-
this.notify(false);
|
|
3796
|
-
};
|
|
3797
|
-
this.setOptions(opts);
|
|
3798
|
-
}
|
|
3799
|
-
};
|
|
3800
|
-
var findNearestBinarySearch = (low, high, getCurrentValue, value) => {
|
|
3801
|
-
while (low <= high) {
|
|
3802
|
-
const middle = (low + high) / 2 | 0;
|
|
3803
|
-
const currentValue = getCurrentValue(middle);
|
|
3804
|
-
if (currentValue < value) {
|
|
3805
|
-
low = middle + 1;
|
|
3806
|
-
} else if (currentValue > value) {
|
|
3807
|
-
high = middle - 1;
|
|
3808
|
-
} else {
|
|
3809
|
-
return middle;
|
|
3810
|
-
}
|
|
3811
|
-
}
|
|
3812
|
-
if (low > 0) {
|
|
3813
|
-
return low - 1;
|
|
3814
|
-
} else {
|
|
3815
|
-
return 0;
|
|
3816
|
-
}
|
|
3817
|
-
};
|
|
3818
|
-
function calculateRange({
|
|
3819
|
-
measurements,
|
|
3820
|
-
outerSize,
|
|
3821
|
-
scrollOffset,
|
|
3822
|
-
lanes
|
|
3823
|
-
}) {
|
|
3824
|
-
const lastIndex = measurements.length - 1;
|
|
3825
|
-
const getOffset = (index) => measurements[index].start;
|
|
3826
|
-
if (measurements.length <= lanes) {
|
|
3827
|
-
return {
|
|
3828
|
-
startIndex: 0,
|
|
3829
|
-
endIndex: lastIndex
|
|
3830
|
-
};
|
|
3831
|
-
}
|
|
3832
|
-
let startIndex = findNearestBinarySearch(0, lastIndex, getOffset, scrollOffset);
|
|
3833
|
-
let endIndex = startIndex;
|
|
3834
|
-
if (lanes === 1) {
|
|
3835
|
-
while (endIndex < lastIndex && measurements[endIndex].end < scrollOffset + outerSize) {
|
|
3836
|
-
endIndex++;
|
|
3837
|
-
}
|
|
3838
|
-
} else if (lanes > 1) {
|
|
3839
|
-
const endPerLane = Array(lanes).fill(0);
|
|
3840
|
-
while (endIndex < lastIndex && endPerLane.some((pos) => pos < scrollOffset + outerSize)) {
|
|
3841
|
-
const item = measurements[endIndex];
|
|
3842
|
-
endPerLane[item.lane] = item.end;
|
|
3843
|
-
endIndex++;
|
|
3844
|
-
}
|
|
3845
|
-
const startPerLane = Array(lanes).fill(scrollOffset + outerSize);
|
|
3846
|
-
while (startIndex >= 0 && startPerLane.some((pos) => pos >= scrollOffset)) {
|
|
3847
|
-
const item = measurements[startIndex];
|
|
3848
|
-
startPerLane[item.lane] = item.start;
|
|
3849
|
-
startIndex--;
|
|
3850
|
-
}
|
|
3851
|
-
startIndex = Math.max(0, startIndex - startIndex % lanes);
|
|
3852
|
-
endIndex = Math.min(lastIndex, endIndex + (lanes - 1 - endIndex % lanes));
|
|
3853
|
-
}
|
|
3854
|
-
return {
|
|
3855
|
-
startIndex,
|
|
3856
|
-
endIndex
|
|
3857
|
-
};
|
|
3858
|
-
}
|
|
3859
|
-
|
|
3860
|
-
// ../../node_modules/.pnpm/@tanstack+react-virtual@3.13.17_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@tanstack/react-virtual/dist/esm/index.js
|
|
3861
|
-
var useIsomorphicLayoutEffect = typeof document !== "undefined" ? React2__namespace.useLayoutEffect : React2__namespace.useEffect;
|
|
3862
|
-
function useVirtualizerBase({
|
|
3863
|
-
useFlushSync = true,
|
|
3864
|
-
...options
|
|
3865
|
-
}) {
|
|
3866
|
-
const rerender = React2__namespace.useReducer(() => ({}), {})[1];
|
|
3867
|
-
const resolvedOptions = {
|
|
3868
|
-
...options,
|
|
3869
|
-
onChange: (instance2, sync) => {
|
|
3870
|
-
var _a;
|
|
3871
|
-
if (useFlushSync && sync) {
|
|
3872
|
-
reactDom.flushSync(rerender);
|
|
3873
|
-
} else {
|
|
3874
|
-
rerender();
|
|
3875
|
-
}
|
|
3876
|
-
(_a = options.onChange) == null ? void 0 : _a.call(options, instance2, sync);
|
|
3877
|
-
}
|
|
3878
|
-
};
|
|
3879
|
-
const [instance] = React2__namespace.useState(() => new Virtualizer(resolvedOptions));
|
|
3880
|
-
instance.setOptions(resolvedOptions);
|
|
3881
|
-
useIsomorphicLayoutEffect(() => {
|
|
3882
|
-
return instance._didMount();
|
|
3883
|
-
}, []);
|
|
3884
|
-
useIsomorphicLayoutEffect(() => {
|
|
3885
|
-
return instance._willUpdate();
|
|
3886
|
-
});
|
|
3887
|
-
return instance;
|
|
3888
|
-
}
|
|
3889
|
-
function useVirtualizer(options) {
|
|
3890
|
-
return useVirtualizerBase({
|
|
3891
|
-
observeElementRect,
|
|
3892
|
-
observeElementOffset,
|
|
3893
|
-
scrollToFn: elementScroll,
|
|
3894
|
-
...options
|
|
3895
|
-
});
|
|
3896
|
-
}
|
|
3897
360
|
function CellContextMenu({
|
|
3898
361
|
cell,
|
|
3899
362
|
position,
|
|
3900
363
|
onClose,
|
|
3901
364
|
renderContent
|
|
3902
365
|
}) {
|
|
3903
|
-
const ref =
|
|
3904
|
-
|
|
366
|
+
const ref = React.useRef(null);
|
|
367
|
+
React.useEffect(() => {
|
|
3905
368
|
const handleClickOutside = (event) => {
|
|
3906
369
|
if (ref.current && !ref.current.contains(event.target)) {
|
|
3907
370
|
onClose();
|
|
@@ -3912,7 +375,7 @@ function CellContextMenu({
|
|
|
3912
375
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
3913
376
|
};
|
|
3914
377
|
}, [onClose]);
|
|
3915
|
-
return /* @__PURE__ */ reactDom.createPortal(/* @__PURE__ */
|
|
378
|
+
return /* @__PURE__ */ reactDom.createPortal(/* @__PURE__ */ React__default.default.createElement("div", {
|
|
3916
379
|
ref,
|
|
3917
380
|
style: {
|
|
3918
381
|
position: "fixed",
|
|
@@ -3926,9 +389,9 @@ function CellContextMenu({
|
|
|
3926
389
|
var useCellContextMenu = ({
|
|
3927
390
|
tdRef
|
|
3928
391
|
}) => {
|
|
3929
|
-
const [popoverPosition, setPopoverPosition] =
|
|
3930
|
-
const [isContextMenuOpen, setIsContextMenuOpen] =
|
|
3931
|
-
const handleOpenContextMenu =
|
|
392
|
+
const [popoverPosition, setPopoverPosition] = React.useState(null);
|
|
393
|
+
const [isContextMenuOpen, setIsContextMenuOpen] = React.useState(false);
|
|
394
|
+
const handleOpenContextMenu = React.useCallback((event) => {
|
|
3932
395
|
event.preventDefault();
|
|
3933
396
|
event.stopPropagation();
|
|
3934
397
|
if (tdRef.current) {
|
|
@@ -3942,7 +405,7 @@ var useCellContextMenu = ({
|
|
|
3942
405
|
setIsContextMenuOpen(true);
|
|
3943
406
|
}
|
|
3944
407
|
}, [tdRef]);
|
|
3945
|
-
const handleCloseContextMenu =
|
|
408
|
+
const handleCloseContextMenu = React.useCallback(() => {
|
|
3946
409
|
setIsContextMenuOpen(false);
|
|
3947
410
|
setPopoverPosition(null);
|
|
3948
411
|
}, []);
|
|
@@ -3959,7 +422,7 @@ function TableCell({
|
|
|
3959
422
|
cell,
|
|
3960
423
|
renderCellContextMenu
|
|
3961
424
|
}) {
|
|
3962
|
-
const tdRef =
|
|
425
|
+
const tdRef = React.useRef(null);
|
|
3963
426
|
const isSelectColumn = cell.column.id === SELECTION_COLUMN_ID;
|
|
3964
427
|
const {
|
|
3965
428
|
isContextMenuOpen,
|
|
@@ -3970,7 +433,7 @@ function TableCell({
|
|
|
3970
433
|
tdRef
|
|
3971
434
|
});
|
|
3972
435
|
const shouldRenderContextMenu = !isSelectColumn && isContextMenuOpen && !!popoverPosition && !!renderCellContextMenu;
|
|
3973
|
-
return /* @__PURE__ */
|
|
436
|
+
return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement("td", {
|
|
3974
437
|
ref: tdRef,
|
|
3975
438
|
style: {
|
|
3976
439
|
display: "flex",
|
|
@@ -3978,7 +441,7 @@ function TableCell({
|
|
|
3978
441
|
width: cell.column.getSize()
|
|
3979
442
|
},
|
|
3980
443
|
onContextMenu: handleOpenContextMenu
|
|
3981
|
-
}, flexRender(cell.column.columnDef.cell, cell.getContext())), shouldRenderContextMenu && /* @__PURE__ */
|
|
444
|
+
}, reactTable.flexRender(cell.column.columnDef.cell, cell.getContext())), shouldRenderContextMenu && /* @__PURE__ */ React__default.default.createElement(CellContextMenu, {
|
|
3982
445
|
cell,
|
|
3983
446
|
position: popoverPosition,
|
|
3984
447
|
onClose: handleCloseContextMenu,
|
|
@@ -3993,10 +456,10 @@ function TableRow({
|
|
|
3993
456
|
onRowClick,
|
|
3994
457
|
renderCellContextMenu
|
|
3995
458
|
}) {
|
|
3996
|
-
const handleClick =
|
|
459
|
+
const handleClick = React.useCallback(() => {
|
|
3997
460
|
onRowClick?.(row.original);
|
|
3998
461
|
}, [onRowClick, row.original]);
|
|
3999
|
-
return /* @__PURE__ */
|
|
462
|
+
return /* @__PURE__ */ React__default.default.createElement("tr", {
|
|
4000
463
|
style: {
|
|
4001
464
|
position: "absolute",
|
|
4002
465
|
height: `${virtualRow.size}px`,
|
|
@@ -4004,7 +467,7 @@ function TableRow({
|
|
|
4004
467
|
display: "flex"
|
|
4005
468
|
},
|
|
4006
469
|
onClick: handleClick
|
|
4007
|
-
}, row.getVisibleCells().map((cell) => /* @__PURE__ */
|
|
470
|
+
}, row.getVisibleCells().map((cell) => /* @__PURE__ */ React__default.default.createElement(TableCell, {
|
|
4008
471
|
key: cell.id,
|
|
4009
472
|
cell,
|
|
4010
473
|
renderCellContextMenu
|
|
@@ -4019,16 +482,16 @@ function TableBody({
|
|
|
4019
482
|
renderCellContextMenu,
|
|
4020
483
|
rowHeight = 40
|
|
4021
484
|
}) {
|
|
4022
|
-
const rowVirtualizer = useVirtualizer({
|
|
485
|
+
const rowVirtualizer = reactVirtual.useVirtualizer({
|
|
4023
486
|
count: rows.length,
|
|
4024
487
|
estimateSize: () => rowHeight,
|
|
4025
488
|
getScrollElement: () => tableContainerRef.current,
|
|
4026
489
|
overscan: 5
|
|
4027
490
|
});
|
|
4028
|
-
|
|
491
|
+
React.useLayoutEffect(() => {
|
|
4029
492
|
rowVirtualizer.measure();
|
|
4030
493
|
}, [rowVirtualizer, rows.length]);
|
|
4031
|
-
return /* @__PURE__ */
|
|
494
|
+
return /* @__PURE__ */ React__default.default.createElement("tbody", {
|
|
4032
495
|
style: {
|
|
4033
496
|
display: "grid",
|
|
4034
497
|
position: "relative",
|
|
@@ -4036,7 +499,7 @@ function TableBody({
|
|
|
4036
499
|
}
|
|
4037
500
|
}, rowVirtualizer.getVirtualItems().map((virtualRow) => {
|
|
4038
501
|
const row = rows[virtualRow.index];
|
|
4039
|
-
return /* @__PURE__ */
|
|
502
|
+
return /* @__PURE__ */ React__default.default.createElement(TableRow, {
|
|
4040
503
|
key: row.id,
|
|
4041
504
|
row,
|
|
4042
505
|
virtualRow,
|
|
@@ -4048,21 +511,21 @@ function TableBody({
|
|
|
4048
511
|
function TableHeader({
|
|
4049
512
|
table
|
|
4050
513
|
}) {
|
|
4051
|
-
return /* @__PURE__ */
|
|
514
|
+
return /* @__PURE__ */ React__default.default.createElement("thead", {
|
|
4052
515
|
style: {
|
|
4053
516
|
display: "grid",
|
|
4054
517
|
position: "sticky",
|
|
4055
518
|
top: 0,
|
|
4056
519
|
zIndex: 1
|
|
4057
520
|
}
|
|
4058
|
-
}, table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */
|
|
521
|
+
}, table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ React__default.default.createElement("tr", {
|
|
4059
522
|
key: headerGroup.id,
|
|
4060
523
|
style: {
|
|
4061
524
|
display: "flex"
|
|
4062
525
|
}
|
|
4063
526
|
}, headerGroup.headers.map((header) => (
|
|
4064
527
|
// TODO: Move inline styling to CSS file
|
|
4065
|
-
/* @__PURE__ */
|
|
528
|
+
/* @__PURE__ */ React__default.default.createElement("th", {
|
|
4066
529
|
key: header.id,
|
|
4067
530
|
style: {
|
|
4068
531
|
display: "flex",
|
|
@@ -4071,7 +534,7 @@ function TableHeader({
|
|
|
4071
534
|
alignItems: "center",
|
|
4072
535
|
position: "relative"
|
|
4073
536
|
}
|
|
4074
|
-
}, header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()), header.column.getCanResize() && /* @__PURE__ */
|
|
537
|
+
}, header.isPlaceholder ? null : reactTable.flexRender(header.column.columnDef.header, header.getContext()), header.column.getCanResize() && /* @__PURE__ */ React__default.default.createElement("div", {
|
|
4075
538
|
onDoubleClick: () => header.column.resetSize(),
|
|
4076
539
|
onMouseDown: header.getResizeHandler(),
|
|
4077
540
|
onTouchStart: header.getResizeHandler(),
|
|
@@ -4099,9 +562,9 @@ function Table({
|
|
|
4099
562
|
rowHeight,
|
|
4100
563
|
renderCellContextMenu
|
|
4101
564
|
}) {
|
|
4102
|
-
const tableContainerRef =
|
|
4103
|
-
const fetchingRef =
|
|
4104
|
-
const fetchMoreOnEndReached =
|
|
565
|
+
const tableContainerRef = React.useRef(null);
|
|
566
|
+
const fetchingRef = React.useRef(false);
|
|
567
|
+
const fetchMoreOnEndReached = React.useCallback(async (containerRefElement) => {
|
|
4105
568
|
if (containerRefElement && !fetchingRef.current) {
|
|
4106
569
|
const {
|
|
4107
570
|
scrollHeight,
|
|
@@ -4118,10 +581,10 @@ function Table({
|
|
|
4118
581
|
}
|
|
4119
582
|
}
|
|
4120
583
|
}, [fetchNextPage, isLoading]);
|
|
4121
|
-
const handleScroll =
|
|
584
|
+
const handleScroll = React.useCallback(async (e) => {
|
|
4122
585
|
await fetchMoreOnEndReached(e.currentTarget);
|
|
4123
586
|
}, [fetchMoreOnEndReached]);
|
|
4124
|
-
return /* @__PURE__ */
|
|
587
|
+
return /* @__PURE__ */ React__default.default.createElement("div", {
|
|
4125
588
|
ref: tableContainerRef,
|
|
4126
589
|
style: {
|
|
4127
590
|
position: "relative",
|
|
@@ -4133,13 +596,13 @@ function Table({
|
|
|
4133
596
|
userSelect: table.getState().columnSizingInfo?.isResizingColumn ? "none" : "auto"
|
|
4134
597
|
},
|
|
4135
598
|
onScroll: handleScroll
|
|
4136
|
-
}, /* @__PURE__ */
|
|
599
|
+
}, /* @__PURE__ */ React__default.default.createElement("table", {
|
|
4137
600
|
style: {
|
|
4138
601
|
display: "grid"
|
|
4139
602
|
}
|
|
4140
|
-
}, /* @__PURE__ */
|
|
603
|
+
}, /* @__PURE__ */ React__default.default.createElement(TableHeader, {
|
|
4141
604
|
table
|
|
4142
|
-
}), /* @__PURE__ */
|
|
605
|
+
}), /* @__PURE__ */ React__default.default.createElement(TableBody, {
|
|
4143
606
|
rows: table.getRowModel().rows,
|
|
4144
607
|
tableContainerRef,
|
|
4145
608
|
onRowClick,
|
|
@@ -4174,7 +637,7 @@ function ObjectTable({
|
|
|
4174
637
|
} = useDefaultTableStates({
|
|
4175
638
|
columnDefinitions
|
|
4176
639
|
});
|
|
4177
|
-
const [columnSizing, setColumnSizing] =
|
|
640
|
+
const [columnSizing, setColumnSizing] = React.useState({});
|
|
4178
641
|
const {
|
|
4179
642
|
rowSelection,
|
|
4180
643
|
isAllSelected,
|
|
@@ -4194,13 +657,13 @@ function ObjectTable({
|
|
|
4194
657
|
onToggleAll,
|
|
4195
658
|
onToggleRow
|
|
4196
659
|
});
|
|
4197
|
-
const allColumns =
|
|
660
|
+
const allColumns = React.useMemo(() => {
|
|
4198
661
|
return selectionColumn ? [selectionColumn, ...columns] : columns;
|
|
4199
662
|
}, [selectionColumn, columns]);
|
|
4200
|
-
const table = useReactTable({
|
|
663
|
+
const table = reactTable.useReactTable({
|
|
4201
664
|
data: data ?? [],
|
|
4202
665
|
columns: allColumns,
|
|
4203
|
-
getCoreRowModel: getCoreRowModel(),
|
|
666
|
+
getCoreRowModel: reactTable.getCoreRowModel(),
|
|
4204
667
|
state: {
|
|
4205
668
|
columnVisibility,
|
|
4206
669
|
rowSelection,
|
|
@@ -4215,11 +678,11 @@ function ObjectTable({
|
|
|
4215
678
|
},
|
|
4216
679
|
getRowId
|
|
4217
680
|
});
|
|
4218
|
-
const onRenderCellContextMenu =
|
|
681
|
+
const onRenderCellContextMenu = React.useCallback((row, cell) => {
|
|
4219
682
|
return renderCellContextMenu?.(row, cell.getValue());
|
|
4220
683
|
}, [renderCellContextMenu]);
|
|
4221
684
|
const isTableLoading = isLoading || isColumnsLoading;
|
|
4222
|
-
return /* @__PURE__ */
|
|
685
|
+
return /* @__PURE__ */ React__default.default.createElement(Table, {
|
|
4223
686
|
table,
|
|
4224
687
|
isLoading: isTableLoading,
|
|
4225
688
|
fetchNextPage: fetchMore,
|
|
@@ -4228,32 +691,6 @@ function ObjectTable({
|
|
|
4228
691
|
renderCellContextMenu: onRenderCellContextMenu
|
|
4229
692
|
});
|
|
4230
693
|
}
|
|
4231
|
-
/*! Bundled license information:
|
|
4232
|
-
|
|
4233
|
-
@tanstack/table-core/build/lib/index.mjs:
|
|
4234
|
-
(**
|
|
4235
|
-
* table-core
|
|
4236
|
-
*
|
|
4237
|
-
* Copyright (c) TanStack
|
|
4238
|
-
*
|
|
4239
|
-
* This source code is licensed under the MIT license found in the
|
|
4240
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
4241
|
-
*
|
|
4242
|
-
* @license MIT
|
|
4243
|
-
*)
|
|
4244
|
-
|
|
4245
|
-
@tanstack/react-table/build/lib/index.mjs:
|
|
4246
|
-
(**
|
|
4247
|
-
* react-table
|
|
4248
|
-
*
|
|
4249
|
-
* Copyright (c) TanStack
|
|
4250
|
-
*
|
|
4251
|
-
* This source code is licensed under the MIT license found in the
|
|
4252
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
4253
|
-
*
|
|
4254
|
-
* @license MIT
|
|
4255
|
-
*)
|
|
4256
|
-
*/
|
|
4257
694
|
|
|
4258
695
|
exports.ObjectTable = ObjectTable;
|
|
4259
696
|
//# sourceMappingURL=experimental.cjs.map
|