@open-grid/primitives 0.1.0
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/LICENSE +21 -0
- package/README.md +65 -0
- package/dist/index.d.ts +931 -0
- package/dist/index.js +2084 -0
- package/package.json +51 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2084 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var GRID_DENSITIES = ["compact", "standard", "comfortable"];
|
|
3
|
+
var GRID_PREFERENCES_VERSION = 1;
|
|
4
|
+
var DEFAULT_PAGINATION_PAGE_SIZE_OPTIONS = [25, 50, 100];
|
|
5
|
+
var HEADER_ACTION_MENU_ENABLED_ITEM_SELECTOR = '[role="menuitem"]:not(:disabled):not([aria-disabled="true"])';
|
|
6
|
+
var HEADER_ACTION_MENU_TRIGGER_TEXT = "...";
|
|
7
|
+
var GROUPING_PANEL_EMPTY_MESSAGE = "Drag column headers here to group";
|
|
8
|
+
var GRID_FOCUSED_CELL_SELECTOR = '[role="gridcell"][data-focused="true"]';
|
|
9
|
+
var GRID_INTERACTIVE_KEYBOARD_TARGET_SELECTOR = "button, input, select, textarea, a[href], [contenteditable]:not([contenteditable='false']), [role='button'], [role='menuitem'], [role='separator'], [role='slider'], [role='textbox'], [role='combobox'], [role='searchbox'], [role='spinbutton']";
|
|
10
|
+
function getGridProps(grid, options = {}) {
|
|
11
|
+
const headerRowCount = getGridHeaderRowCount(grid, options);
|
|
12
|
+
const rowCount = grid.getOptions().manualPagination ? -1 : headerRowCount + Math.max(1, grid.getPrePaginationRowModel().rows.length);
|
|
13
|
+
const columnCount = grid.getVisibleLeafColumns().length;
|
|
14
|
+
return {
|
|
15
|
+
role: "grid",
|
|
16
|
+
"aria-label": options.ariaLabel,
|
|
17
|
+
"aria-rowcount": rowCount,
|
|
18
|
+
"aria-colcount": columnCount,
|
|
19
|
+
"aria-busy": options.loading && !options.error || void 0,
|
|
20
|
+
"data-error": options.error || void 0,
|
|
21
|
+
"data-open-grid": true,
|
|
22
|
+
tabIndex: 0
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function getGridHeaderProps() {
|
|
26
|
+
return {
|
|
27
|
+
role: "rowgroup"
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function getGridLoadingOverlayProps() {
|
|
31
|
+
return {
|
|
32
|
+
role: "status",
|
|
33
|
+
"aria-live": "polite",
|
|
34
|
+
"aria-label": "Loading rows"
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function getGridLoadingText() {
|
|
38
|
+
return "Loading rows...";
|
|
39
|
+
}
|
|
40
|
+
function getGridErrorOverlayProps() {
|
|
41
|
+
return {
|
|
42
|
+
role: "alert",
|
|
43
|
+
"aria-live": "assertive",
|
|
44
|
+
"aria-atomic": true,
|
|
45
|
+
"aria-label": "Grid error"
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function getGridErrorText() {
|
|
49
|
+
return "Unable to load rows.";
|
|
50
|
+
}
|
|
51
|
+
function getGridErrorRetryButtonProps() {
|
|
52
|
+
return {
|
|
53
|
+
type: "button",
|
|
54
|
+
"aria-label": "Retry loading rows"
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function getGridErrorRetryButtonText() {
|
|
58
|
+
return "Retry";
|
|
59
|
+
}
|
|
60
|
+
function getGridHeaderRowProps(options = {}) {
|
|
61
|
+
return {
|
|
62
|
+
role: "row",
|
|
63
|
+
"aria-rowindex": (options.rowIndex ?? 0) + 1,
|
|
64
|
+
"data-column-virtualized": options.columnVirtualized || void 0
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function getGridHeaderRowCount(grid, options = {}) {
|
|
68
|
+
const headerRowCount = Number.isFinite(options.headerRowCount) ? Math.max(0, Math.floor(options.headerRowCount ?? 0)) : grid.getHeaderGroups().length;
|
|
69
|
+
const additionalHeaderRowCount = Number.isFinite(options.additionalHeaderRowCount) ? Math.max(0, Math.floor(options.additionalHeaderRowCount ?? 0)) : 0;
|
|
70
|
+
return headerRowCount + additionalHeaderRowCount;
|
|
71
|
+
}
|
|
72
|
+
function getGridBodyRowIndexOffset(grid, options = {}) {
|
|
73
|
+
const { pageIndex, pageSize } = grid.getState().pagination;
|
|
74
|
+
return getGridHeaderRowCount(grid, options) + pageIndex * pageSize;
|
|
75
|
+
}
|
|
76
|
+
function getColumnFilterCellProps(column, options) {
|
|
77
|
+
const pinned = options.pinned ?? column.getIsPinned();
|
|
78
|
+
return {
|
|
79
|
+
role: "gridcell",
|
|
80
|
+
"aria-colindex": options.columnIndex + 1,
|
|
81
|
+
"data-column-id": column.id,
|
|
82
|
+
"data-pinned": pinned || void 0,
|
|
83
|
+
"data-pinned-edge": options.pinnedEdge
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function getColumnFilterInputProps(column, options) {
|
|
87
|
+
return {
|
|
88
|
+
type: "search",
|
|
89
|
+
value: options.value == null ? "" : String(options.value),
|
|
90
|
+
placeholder: "Filter",
|
|
91
|
+
"aria-label": `Filter ${options.label}`,
|
|
92
|
+
"data-column-id": column.id,
|
|
93
|
+
autoComplete: "off"
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function getColumnFilterText(filters, columnId) {
|
|
97
|
+
const value = filters.find((filter) => filter.id === columnId)?.value;
|
|
98
|
+
return value == null ? "" : String(value);
|
|
99
|
+
}
|
|
100
|
+
function getQuickFilterProps() {
|
|
101
|
+
return {
|
|
102
|
+
role: "search",
|
|
103
|
+
"aria-label": "Search grid rows"
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function getQuickFilterInputProps(options) {
|
|
107
|
+
return {
|
|
108
|
+
type: "search",
|
|
109
|
+
value: options.value,
|
|
110
|
+
placeholder: "Search rows",
|
|
111
|
+
"aria-label": "Search all rows",
|
|
112
|
+
autoComplete: "off"
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function getQuickFilterClearButtonProps(value) {
|
|
116
|
+
return {
|
|
117
|
+
type: "button",
|
|
118
|
+
"aria-label": "Clear row search",
|
|
119
|
+
disabled: value.length === 0 || void 0
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function getQuickFilterClearButtonText() {
|
|
123
|
+
return "Clear";
|
|
124
|
+
}
|
|
125
|
+
function getRowSelectionControlsProps() {
|
|
126
|
+
return {
|
|
127
|
+
role: "group",
|
|
128
|
+
"aria-label": "Row selection"
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function getRowSelectionCheckboxProps(options = {}) {
|
|
132
|
+
return {
|
|
133
|
+
type: "checkbox",
|
|
134
|
+
checked: options.allSelected || false,
|
|
135
|
+
disabled: options.disabled || void 0,
|
|
136
|
+
"aria-checked": options.someSelected ? "mixed" : options.allSelected || false,
|
|
137
|
+
"aria-label": "Select all rows on current page"
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function getRowSelectionCheckboxText() {
|
|
141
|
+
return "Select page";
|
|
142
|
+
}
|
|
143
|
+
function getRowSelectionStatusProps() {
|
|
144
|
+
return {
|
|
145
|
+
role: "status",
|
|
146
|
+
"aria-live": "polite",
|
|
147
|
+
"aria-atomic": true
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function getRowSelectionStatusText(selectedCount) {
|
|
151
|
+
const count = Number.isFinite(selectedCount) ? Math.max(0, Math.floor(selectedCount)) : 0;
|
|
152
|
+
return `${count} ${count === 1 ? "row" : "rows"} selected`;
|
|
153
|
+
}
|
|
154
|
+
function getRowSelectionClearButtonProps(disabled = false) {
|
|
155
|
+
return {
|
|
156
|
+
type: "button",
|
|
157
|
+
disabled: disabled || void 0,
|
|
158
|
+
"aria-label": "Clear row selection"
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function getRowSelectionClearButtonText() {
|
|
162
|
+
return "Clear selection";
|
|
163
|
+
}
|
|
164
|
+
function setCheckboxIndeterminate(target, indeterminate) {
|
|
165
|
+
if (!target || typeof target !== "object" || !("indeterminate" in target)) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
target.indeterminate = indeterminate;
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
function getColumnVisibilityControlsProps() {
|
|
172
|
+
return {
|
|
173
|
+
"aria-label": "Grid columns"
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function getColumnVisibilitySummaryProps(visibleCount, totalCount) {
|
|
177
|
+
return {
|
|
178
|
+
"aria-label": `Manage columns, ${getColumnVisibilityStatusText(visibleCount, totalCount)}`
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function getColumnVisibilitySummaryText(visibleCount, totalCount) {
|
|
182
|
+
const { visible, total } = normalizeColumnVisibilityCounts(visibleCount, totalCount);
|
|
183
|
+
return `Columns ${visible}/${total}`;
|
|
184
|
+
}
|
|
185
|
+
function getColumnVisibilitySearchInputProps(value) {
|
|
186
|
+
return {
|
|
187
|
+
type: "search",
|
|
188
|
+
value,
|
|
189
|
+
placeholder: "Find columns",
|
|
190
|
+
"aria-label": "Find columns",
|
|
191
|
+
autoComplete: "off"
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function getColumnVisibilityListProps() {
|
|
195
|
+
return {
|
|
196
|
+
role: "group",
|
|
197
|
+
"aria-label": "Column visibility"
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function getColumnVisibilityCheckboxProps(options) {
|
|
201
|
+
const isFinalVisibleColumn = options.visible && Number.isFinite(options.visibleCount) && Math.max(0, Math.floor(options.visibleCount ?? 0)) <= 1;
|
|
202
|
+
return {
|
|
203
|
+
type: "checkbox",
|
|
204
|
+
checked: options.visible,
|
|
205
|
+
disabled: options.disabled || isFinalVisibleColumn || void 0,
|
|
206
|
+
"aria-label": options.label,
|
|
207
|
+
"data-column-id": options.columnId
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function getColumnVisibilityStatusProps() {
|
|
211
|
+
return {
|
|
212
|
+
role: "status",
|
|
213
|
+
"aria-live": "polite",
|
|
214
|
+
"aria-atomic": true
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function getColumnVisibilityStatusText(visibleCount, totalCount) {
|
|
218
|
+
const { visible, total } = normalizeColumnVisibilityCounts(visibleCount, totalCount);
|
|
219
|
+
return `${visible} of ${total} columns visible`;
|
|
220
|
+
}
|
|
221
|
+
function getColumnVisibilityEmptyText() {
|
|
222
|
+
return "No columns found";
|
|
223
|
+
}
|
|
224
|
+
function getColumnVisibilityResetButtonProps(hiddenCount) {
|
|
225
|
+
return {
|
|
226
|
+
type: "button",
|
|
227
|
+
disabled: !Number.isFinite(hiddenCount) || hiddenCount <= 0 || void 0,
|
|
228
|
+
"aria-label": "Show all columns"
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
function getColumnVisibilityResetButtonText() {
|
|
232
|
+
return "Show all";
|
|
233
|
+
}
|
|
234
|
+
function normalizeGridDensity(value, fallback = "standard") {
|
|
235
|
+
return GRID_DENSITIES.includes(value) ? value : fallback;
|
|
236
|
+
}
|
|
237
|
+
function getGridPreferenceRecord(value) {
|
|
238
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
239
|
+
}
|
|
240
|
+
function getGridPreferenceColumnIds(value, validColumnIds) {
|
|
241
|
+
if (!Array.isArray(value)) {
|
|
242
|
+
return [];
|
|
243
|
+
}
|
|
244
|
+
const validIds = validColumnIds ? new Set(validColumnIds) : null;
|
|
245
|
+
const seen = /* @__PURE__ */ new Set();
|
|
246
|
+
return value.filter((columnId) => {
|
|
247
|
+
if (typeof columnId !== "string" || seen.has(columnId) || validIds && !validIds.has(columnId)) {
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
seen.add(columnId);
|
|
251
|
+
return true;
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
function createGridPreferences(state = {}, density = "standard", options = {}) {
|
|
255
|
+
const validIds = options.validColumnIds ? new Set(options.validColumnIds) : null;
|
|
256
|
+
const columnVisibility = Object.fromEntries(
|
|
257
|
+
Object.entries(state.columnVisibility ?? {}).filter(([columnId, visible]) => typeof visible === "boolean" && (!validIds || validIds.has(columnId)))
|
|
258
|
+
);
|
|
259
|
+
const columnSizing = Object.fromEntries(
|
|
260
|
+
Object.entries(state.columnSizing ?? {}).filter(([columnId, size]) => typeof size === "number" && Number.isFinite(size) && size > 0 && (!validIds || validIds.has(columnId)))
|
|
261
|
+
);
|
|
262
|
+
const columnOrder = getGridPreferenceColumnIds(state.columnOrder, options.validColumnIds);
|
|
263
|
+
const left = getGridPreferenceColumnIds(state.columnPinning?.left, options.validColumnIds);
|
|
264
|
+
const leftIds = new Set(left);
|
|
265
|
+
const right = getGridPreferenceColumnIds(state.columnPinning?.right, options.validColumnIds).filter((columnId) => !leftIds.has(columnId));
|
|
266
|
+
if (options.validColumnIds?.length && options.validColumnIds.every((columnId) => columnVisibility[columnId] === false)) {
|
|
267
|
+
delete columnVisibility[options.validColumnIds[0]];
|
|
268
|
+
}
|
|
269
|
+
return {
|
|
270
|
+
version: GRID_PREFERENCES_VERSION,
|
|
271
|
+
density: normalizeGridDensity(density),
|
|
272
|
+
state: {
|
|
273
|
+
columnVisibility,
|
|
274
|
+
columnSizing,
|
|
275
|
+
columnOrder,
|
|
276
|
+
columnPinning: { left, right }
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
function serializeGridPreferences(preferences, options = {}) {
|
|
281
|
+
return JSON.stringify(createGridPreferences(preferences.state, preferences.density, options));
|
|
282
|
+
}
|
|
283
|
+
function parseGridPreferences(value, options = {}) {
|
|
284
|
+
try {
|
|
285
|
+
const parsed = getGridPreferenceRecord(JSON.parse(value));
|
|
286
|
+
if (!parsed || parsed.version !== GRID_PREFERENCES_VERSION) {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
const state = getGridPreferenceRecord(parsed.state);
|
|
290
|
+
if (!state) {
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
const columnPinning = getGridPreferenceRecord(state.columnPinning);
|
|
294
|
+
return createGridPreferences({
|
|
295
|
+
columnVisibility: getGridPreferenceRecord(state.columnVisibility) ?? {},
|
|
296
|
+
columnSizing: getGridPreferenceRecord(state.columnSizing) ?? {},
|
|
297
|
+
columnOrder: Array.isArray(state.columnOrder) ? state.columnOrder : [],
|
|
298
|
+
columnPinning: {
|
|
299
|
+
left: Array.isArray(columnPinning?.left) ? columnPinning.left : [],
|
|
300
|
+
right: Array.isArray(columnPinning?.right) ? columnPinning.right : []
|
|
301
|
+
}
|
|
302
|
+
}, normalizeGridDensity(parsed.density), options);
|
|
303
|
+
} catch {
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
function getBrowserGridPreferencesStorage(environment = globalThis) {
|
|
308
|
+
try {
|
|
309
|
+
return environment?.localStorage ?? null;
|
|
310
|
+
} catch {
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function readGridPreferences(storage, key, options = {}) {
|
|
315
|
+
if (!storage) {
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
try {
|
|
319
|
+
const value = storage.getItem(key);
|
|
320
|
+
return value === null ? null : parseGridPreferences(value, options);
|
|
321
|
+
} catch {
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
function writeGridPreferences(storage, key, state, density, options = {}) {
|
|
326
|
+
if (!storage) {
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
try {
|
|
330
|
+
storage.setItem(key, serializeGridPreferences(createGridPreferences(state, density, options), options));
|
|
331
|
+
return true;
|
|
332
|
+
} catch {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
function removeGridPreferences(storage, key) {
|
|
337
|
+
if (!storage) {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
try {
|
|
341
|
+
storage.removeItem(key);
|
|
342
|
+
return true;
|
|
343
|
+
} catch {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
function getGridDensityProps(density) {
|
|
348
|
+
return {
|
|
349
|
+
"data-density": normalizeGridDensity(density)
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
function getGridDensityRowHeight(density) {
|
|
353
|
+
const heights = {
|
|
354
|
+
compact: 32,
|
|
355
|
+
standard: 40,
|
|
356
|
+
comfortable: 48
|
|
357
|
+
};
|
|
358
|
+
return heights[normalizeGridDensity(density)];
|
|
359
|
+
}
|
|
360
|
+
function getDensityControlsProps() {
|
|
361
|
+
return {
|
|
362
|
+
role: "group",
|
|
363
|
+
"aria-label": "Row density"
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
function getDensityButtonProps(density, currentDensity) {
|
|
367
|
+
const normalizedDensity = normalizeGridDensity(density);
|
|
368
|
+
return {
|
|
369
|
+
type: "button",
|
|
370
|
+
"aria-label": `Use ${normalizedDensity} density`,
|
|
371
|
+
"aria-pressed": normalizedDensity === normalizeGridDensity(currentDensity),
|
|
372
|
+
"data-density": normalizedDensity
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
function getDensityButtonText(density) {
|
|
376
|
+
const labels = {
|
|
377
|
+
compact: "Compact",
|
|
378
|
+
standard: "Standard",
|
|
379
|
+
comfortable: "Comfortable"
|
|
380
|
+
};
|
|
381
|
+
return labels[normalizeGridDensity(density)];
|
|
382
|
+
}
|
|
383
|
+
function getFilteredColumnVisibilityColumns(columns, query) {
|
|
384
|
+
const normalizedQuery = query.trim().toLocaleLowerCase();
|
|
385
|
+
if (!normalizedQuery) {
|
|
386
|
+
return [...columns];
|
|
387
|
+
}
|
|
388
|
+
return columns.filter(
|
|
389
|
+
(column) => `${getColumnHeaderText(column)} ${column.id}`.toLocaleLowerCase().includes(normalizedQuery)
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
function normalizeColumnVisibilityCounts(visibleCount, totalCount) {
|
|
393
|
+
const normalizedTotal = Number.isFinite(totalCount) ? Math.max(0, Math.floor(totalCount)) : 0;
|
|
394
|
+
const normalizedVisible = Number.isFinite(visibleCount) ? Math.max(0, Math.floor(visibleCount)) : 0;
|
|
395
|
+
return {
|
|
396
|
+
visible: Math.min(normalizedVisible, normalizedTotal),
|
|
397
|
+
total: normalizedTotal
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
function getNextColumnFilters(filters, columnId, value) {
|
|
401
|
+
const existingIndex = filters.findIndex((filter) => filter.id === columnId);
|
|
402
|
+
if (value === "") {
|
|
403
|
+
return existingIndex < 0 ? filters : filters.filter((filter) => filter.id !== columnId);
|
|
404
|
+
}
|
|
405
|
+
if (existingIndex < 0) {
|
|
406
|
+
return [...filters, { id: columnId, value }];
|
|
407
|
+
}
|
|
408
|
+
return filters.map((filter, index) => index === existingIndex ? { id: columnId, value } : filter);
|
|
409
|
+
}
|
|
410
|
+
function getPaginationProps() {
|
|
411
|
+
return {
|
|
412
|
+
role: "navigation",
|
|
413
|
+
"aria-label": "Pagination"
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
function getPaginationButtonProps(options) {
|
|
417
|
+
const labels = {
|
|
418
|
+
first: "First page",
|
|
419
|
+
previous: "Previous page",
|
|
420
|
+
next: "Next page",
|
|
421
|
+
last: "Last page"
|
|
422
|
+
};
|
|
423
|
+
return {
|
|
424
|
+
type: "button",
|
|
425
|
+
"aria-label": labels[options.action],
|
|
426
|
+
disabled: options.disabled || void 0
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
function getPaginationButtonText(action) {
|
|
430
|
+
const text = {
|
|
431
|
+
first: "|<",
|
|
432
|
+
previous: "<",
|
|
433
|
+
next: ">",
|
|
434
|
+
last: ">|"
|
|
435
|
+
};
|
|
436
|
+
return text[action];
|
|
437
|
+
}
|
|
438
|
+
function getPaginationStatusProps() {
|
|
439
|
+
return {
|
|
440
|
+
role: "status",
|
|
441
|
+
"aria-live": "polite"
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
function getPaginationPageText(grid) {
|
|
445
|
+
const pageCount = grid.getPageCount();
|
|
446
|
+
const rawPageIndex = grid.getState().pagination.pageIndex;
|
|
447
|
+
const pageIndex = Math.min(
|
|
448
|
+
Number.isFinite(rawPageIndex) ? Math.max(0, Math.floor(rawPageIndex)) : 0,
|
|
449
|
+
pageCount - 1
|
|
450
|
+
);
|
|
451
|
+
return `Page ${pageIndex + 1} of ${pageCount}`;
|
|
452
|
+
}
|
|
453
|
+
function getPaginationPageSizeSelectProps(pageSize) {
|
|
454
|
+
return {
|
|
455
|
+
"aria-label": "Rows per page",
|
|
456
|
+
value: Number.isFinite(pageSize) && pageSize > 0 ? Math.max(1, Math.floor(pageSize)) : 1
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
function getPaginationPageSizeOptions(options = DEFAULT_PAGINATION_PAGE_SIZE_OPTIONS, currentPageSize) {
|
|
460
|
+
const normalized = options.flatMap(
|
|
461
|
+
(value) => Number.isFinite(value) && value > 0 ? [Math.max(1, Math.floor(value))] : []
|
|
462
|
+
);
|
|
463
|
+
const current = Number.isFinite(currentPageSize) && (currentPageSize ?? 0) > 0 ? Math.max(1, Math.floor(currentPageSize ?? 1)) : null;
|
|
464
|
+
return Array.from(new Set(current === null ? normalized : [...normalized, current])).sort((left, right) => left - right);
|
|
465
|
+
}
|
|
466
|
+
function getPaginationPageSizeOptionText(pageSize) {
|
|
467
|
+
return `${pageSize} rows`;
|
|
468
|
+
}
|
|
469
|
+
function getGridBodyProps(options = {}) {
|
|
470
|
+
return {
|
|
471
|
+
role: "rowgroup",
|
|
472
|
+
"data-virtualized": options.virtualized || void 0,
|
|
473
|
+
"data-column-order": options.columnOrder?.join(",")
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
function getGridEmptyRowProps(options = {}) {
|
|
477
|
+
return {
|
|
478
|
+
role: "row",
|
|
479
|
+
"aria-rowindex": (options.rowIndexOffset ?? 0) + 1
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
function getGridEmptyCellProps(options = {}) {
|
|
483
|
+
return {
|
|
484
|
+
role: "gridcell",
|
|
485
|
+
"aria-colindex": 1,
|
|
486
|
+
"aria-colspan": Math.max(1, options.columnCount ?? 1)
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
function getColumnSpacerProps() {
|
|
490
|
+
return {
|
|
491
|
+
"aria-hidden": true
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
function getHeaderCellProps(grid, column, columnIndex, options = {}) {
|
|
495
|
+
const sortDirection = grid.getColumnSortDirection(column.id);
|
|
496
|
+
const pinned = options.pinned ?? column.getIsPinned();
|
|
497
|
+
return {
|
|
498
|
+
role: "columnheader",
|
|
499
|
+
"aria-colindex": columnIndex + 1,
|
|
500
|
+
"aria-sort": sortDirection === "asc" ? "ascending" : sortDirection === "desc" ? "descending" : "none",
|
|
501
|
+
"data-column-id": column.id,
|
|
502
|
+
"data-pinned": pinned || void 0,
|
|
503
|
+
"data-sort": sortDirection || void 0
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
function getHeaderPlaceholderCellProps(column) {
|
|
507
|
+
return {
|
|
508
|
+
role: "presentation",
|
|
509
|
+
"aria-hidden": true,
|
|
510
|
+
"data-column-id": column.id
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
function getHeaderCellLayoutProps(options = {}) {
|
|
514
|
+
return {
|
|
515
|
+
"aria-colspan": options.placeholder ? void 0 : options.colSpan,
|
|
516
|
+
"aria-rowspan": options.placeholder ? void 0 : options.rowSpan,
|
|
517
|
+
"data-grouped": options.grouped || void 0,
|
|
518
|
+
"data-placeholder": options.placeholder || void 0,
|
|
519
|
+
"data-pinned-edge": options.pinnedEdge,
|
|
520
|
+
"data-column-draggable": options.draggable || void 0
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
function getHeaderButtonProps(options = {}) {
|
|
524
|
+
return {
|
|
525
|
+
type: "button",
|
|
526
|
+
disabled: options.disabled || void 0,
|
|
527
|
+
tabIndex: options.placeholder ? -1 : void 0
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
function getHeaderSortIndicatorProps() {
|
|
531
|
+
return {
|
|
532
|
+
"aria-hidden": true
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
function getHeaderSortIndicatorText(sortDirection, options = {}) {
|
|
536
|
+
if (!options.visible) {
|
|
537
|
+
return "";
|
|
538
|
+
}
|
|
539
|
+
if (sortDirection === "asc") {
|
|
540
|
+
return "\u25B2";
|
|
541
|
+
}
|
|
542
|
+
if (sortDirection === "desc") {
|
|
543
|
+
return "\u25BC";
|
|
544
|
+
}
|
|
545
|
+
return "";
|
|
546
|
+
}
|
|
547
|
+
function getHeaderKeyboardMoveDirection(event) {
|
|
548
|
+
if (!event.altKey || !event.shiftKey) {
|
|
549
|
+
return null;
|
|
550
|
+
}
|
|
551
|
+
if (event.key === "ArrowLeft") {
|
|
552
|
+
return "left";
|
|
553
|
+
}
|
|
554
|
+
if (event.key === "ArrowRight") {
|
|
555
|
+
return "right";
|
|
556
|
+
}
|
|
557
|
+
return null;
|
|
558
|
+
}
|
|
559
|
+
function getHeaderActionMenuTriggerFocusPosition(event) {
|
|
560
|
+
if (event.key === "ArrowDown") {
|
|
561
|
+
return "first";
|
|
562
|
+
}
|
|
563
|
+
if (event.key === "ArrowUp") {
|
|
564
|
+
return "last";
|
|
565
|
+
}
|
|
566
|
+
return null;
|
|
567
|
+
}
|
|
568
|
+
function getHeaderActionMenuKeyboardAction(event) {
|
|
569
|
+
if (event.key === "Escape") {
|
|
570
|
+
return { type: "close" };
|
|
571
|
+
}
|
|
572
|
+
if (event.key === "ArrowDown") {
|
|
573
|
+
return { type: "focus", position: "next" };
|
|
574
|
+
}
|
|
575
|
+
if (event.key === "ArrowUp") {
|
|
576
|
+
return { type: "focus", position: "previous" };
|
|
577
|
+
}
|
|
578
|
+
if (event.key === "Home") {
|
|
579
|
+
return { type: "focus", position: "first" };
|
|
580
|
+
}
|
|
581
|
+
if (event.key === "End") {
|
|
582
|
+
return { type: "focus", position: "last" };
|
|
583
|
+
}
|
|
584
|
+
if (event.key === "Tab") {
|
|
585
|
+
return { type: "tab-close" };
|
|
586
|
+
}
|
|
587
|
+
return null;
|
|
588
|
+
}
|
|
589
|
+
function isHeaderActionMenuCloseAction(action) {
|
|
590
|
+
return action?.type === "close";
|
|
591
|
+
}
|
|
592
|
+
function isHeaderActionMenuFocusAction(action) {
|
|
593
|
+
return action?.type === "focus";
|
|
594
|
+
}
|
|
595
|
+
function isHeaderActionMenuTabCloseAction(action) {
|
|
596
|
+
return action?.type === "tab-close";
|
|
597
|
+
}
|
|
598
|
+
function getGridKeyboardShortcutAction(event) {
|
|
599
|
+
const key = event.key.toLowerCase();
|
|
600
|
+
if ((event.ctrlKey || event.metaKey) && !event.altKey) {
|
|
601
|
+
if (!event.shiftKey && key === "c") {
|
|
602
|
+
return "copy";
|
|
603
|
+
}
|
|
604
|
+
if (!event.shiftKey && key === "v") {
|
|
605
|
+
return "paste";
|
|
606
|
+
}
|
|
607
|
+
if (key === "z") {
|
|
608
|
+
return event.shiftKey ? "redo-edit" : "undo-edit";
|
|
609
|
+
}
|
|
610
|
+
if (!event.shiftKey && key === "y") {
|
|
611
|
+
return "redo-edit";
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
if (!event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey && (event.key === " " || event.key === "Spacebar")) {
|
|
615
|
+
return "row-selection";
|
|
616
|
+
}
|
|
617
|
+
return null;
|
|
618
|
+
}
|
|
619
|
+
function getGridKeyboardEditAction(event) {
|
|
620
|
+
if (event.key === "Enter") {
|
|
621
|
+
return "start-edit";
|
|
622
|
+
}
|
|
623
|
+
if (event.key === "Escape") {
|
|
624
|
+
return "cancel-edit";
|
|
625
|
+
}
|
|
626
|
+
return null;
|
|
627
|
+
}
|
|
628
|
+
function getCellEditorKeyboardAction(event) {
|
|
629
|
+
if (event.key === "Enter") {
|
|
630
|
+
return "commit-edit";
|
|
631
|
+
}
|
|
632
|
+
if (event.key === "Escape") {
|
|
633
|
+
return "cancel-edit";
|
|
634
|
+
}
|
|
635
|
+
return null;
|
|
636
|
+
}
|
|
637
|
+
function getGridKeyboardFocusMove(event) {
|
|
638
|
+
const options = event.shiftKey ? { extendSelection: true } : {};
|
|
639
|
+
if (event.key === "ArrowUp") {
|
|
640
|
+
return { direction: "up", options };
|
|
641
|
+
}
|
|
642
|
+
if (event.key === "ArrowDown") {
|
|
643
|
+
return { direction: "down", options };
|
|
644
|
+
}
|
|
645
|
+
if (event.key === "ArrowLeft") {
|
|
646
|
+
return { direction: "left", options };
|
|
647
|
+
}
|
|
648
|
+
if (event.key === "ArrowRight") {
|
|
649
|
+
return { direction: "right", options };
|
|
650
|
+
}
|
|
651
|
+
if (event.key === "Home") {
|
|
652
|
+
return { direction: event.ctrlKey || event.metaKey ? "grid-start" : "home", options };
|
|
653
|
+
}
|
|
654
|
+
if (event.key === "End") {
|
|
655
|
+
return { direction: event.ctrlKey || event.metaKey ? "grid-end" : "end", options };
|
|
656
|
+
}
|
|
657
|
+
if (event.key === "PageUp") {
|
|
658
|
+
return { direction: "page-up", options };
|
|
659
|
+
}
|
|
660
|
+
if (event.key === "PageDown") {
|
|
661
|
+
return { direction: "page-down", options };
|
|
662
|
+
}
|
|
663
|
+
return null;
|
|
664
|
+
}
|
|
665
|
+
function getColumnResizeHandleProps(column, options = {}) {
|
|
666
|
+
return {
|
|
667
|
+
role: "separator",
|
|
668
|
+
"aria-orientation": "vertical",
|
|
669
|
+
"aria-label": `Resize ${column.id} column`,
|
|
670
|
+
"aria-valuenow": options.valueNow ?? column.getSize(),
|
|
671
|
+
"aria-valuemin": column.columnDef.minSize,
|
|
672
|
+
"aria-valuemax": column.columnDef.maxSize,
|
|
673
|
+
"data-column-id": column.id,
|
|
674
|
+
"data-resize-handle": true,
|
|
675
|
+
tabIndex: 0
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
function getColumnResizeStartSize(grid, column) {
|
|
679
|
+
return grid.getColumnSize(column.id) ?? column.getSize();
|
|
680
|
+
}
|
|
681
|
+
function getColumnResizeKeyboardSize(column, startSize, event, options = {}) {
|
|
682
|
+
const defaultStep = options.defaultStep ?? 10;
|
|
683
|
+
const largeStep = options.largeStep ?? 50;
|
|
684
|
+
const step = event.shiftKey ? largeStep : defaultStep;
|
|
685
|
+
if (event.key === "ArrowLeft") {
|
|
686
|
+
return startSize - step;
|
|
687
|
+
}
|
|
688
|
+
if (event.key === "ArrowRight") {
|
|
689
|
+
return startSize + step;
|
|
690
|
+
}
|
|
691
|
+
if (event.key === "Home" && typeof column.columnDef.minSize === "number") {
|
|
692
|
+
return column.columnDef.minSize;
|
|
693
|
+
}
|
|
694
|
+
if (event.key === "End" && typeof column.columnDef.maxSize === "number") {
|
|
695
|
+
return column.columnDef.maxSize;
|
|
696
|
+
}
|
|
697
|
+
return null;
|
|
698
|
+
}
|
|
699
|
+
function getColumnResizePointerSize(startSize, startX, event) {
|
|
700
|
+
return startSize + event.clientX - startX;
|
|
701
|
+
}
|
|
702
|
+
function getCanStartColumnResize(event) {
|
|
703
|
+
return !event.defaultPrevented;
|
|
704
|
+
}
|
|
705
|
+
function getCanApplyColumnResize(event) {
|
|
706
|
+
return !event.defaultPrevented;
|
|
707
|
+
}
|
|
708
|
+
function getColumnResizeFinalSize(startSize, event) {
|
|
709
|
+
return event.defaultPrevented ? startSize : event.size;
|
|
710
|
+
}
|
|
711
|
+
function isPointerCaptureTarget(target) {
|
|
712
|
+
return typeof target === "object" && target !== null && "setPointerCapture" in target && "releasePointerCapture" in target && typeof target.setPointerCapture === "function" && typeof target.releasePointerCapture === "function";
|
|
713
|
+
}
|
|
714
|
+
function getPointerCaptureTarget(event) {
|
|
715
|
+
return event.currentTarget;
|
|
716
|
+
}
|
|
717
|
+
function getCanUseDefaultPointerGlobalListenerTarget() {
|
|
718
|
+
if (typeof globalThis.addEventListener !== "function" || typeof globalThis.removeEventListener !== "function") {
|
|
719
|
+
return false;
|
|
720
|
+
}
|
|
721
|
+
return true;
|
|
722
|
+
}
|
|
723
|
+
function addDefaultPointerGlobalListener(type, listener) {
|
|
724
|
+
globalThis.addEventListener(type, listener);
|
|
725
|
+
}
|
|
726
|
+
function removeDefaultPointerGlobalListener(type, listener) {
|
|
727
|
+
globalThis.removeEventListener(type, listener);
|
|
728
|
+
}
|
|
729
|
+
function getDefaultPointerMoveUpListenerTarget() {
|
|
730
|
+
return getCanUseDefaultPointerGlobalListenerTarget() ? {
|
|
731
|
+
addEventListener: addDefaultPointerGlobalListener,
|
|
732
|
+
removeEventListener: removeDefaultPointerGlobalListener
|
|
733
|
+
} : null;
|
|
734
|
+
}
|
|
735
|
+
function getDefaultPointerUpCancelListenerTarget() {
|
|
736
|
+
return getCanUseDefaultPointerGlobalListenerTarget() ? {
|
|
737
|
+
addEventListener: addDefaultPointerGlobalListener,
|
|
738
|
+
removeEventListener: removeDefaultPointerGlobalListener
|
|
739
|
+
} : null;
|
|
740
|
+
}
|
|
741
|
+
function getDefaultPointerMoveUpCancelListenerTarget() {
|
|
742
|
+
return getCanUseDefaultPointerGlobalListenerTarget() ? {
|
|
743
|
+
addEventListener: addDefaultPointerGlobalListener,
|
|
744
|
+
removeEventListener: removeDefaultPointerGlobalListener
|
|
745
|
+
} : null;
|
|
746
|
+
}
|
|
747
|
+
function trySetPointerCapture(target, pointerId) {
|
|
748
|
+
if (!isPointerCaptureTarget(target)) {
|
|
749
|
+
return false;
|
|
750
|
+
}
|
|
751
|
+
try {
|
|
752
|
+
target.setPointerCapture(pointerId);
|
|
753
|
+
return true;
|
|
754
|
+
} catch {
|
|
755
|
+
return false;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
function tryReleasePointerCapture(target, pointerId) {
|
|
759
|
+
if (!isPointerCaptureTarget(target)) {
|
|
760
|
+
return false;
|
|
761
|
+
}
|
|
762
|
+
try {
|
|
763
|
+
target.releasePointerCapture(pointerId);
|
|
764
|
+
return true;
|
|
765
|
+
} catch {
|
|
766
|
+
return false;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
function addPointerMoveUpListeners(listeners, target = getDefaultPointerMoveUpListenerTarget()) {
|
|
770
|
+
if (!target) {
|
|
771
|
+
return () => void 0;
|
|
772
|
+
}
|
|
773
|
+
target.addEventListener("pointermove", listeners.move);
|
|
774
|
+
target.addEventListener("pointerup", listeners.up);
|
|
775
|
+
return () => {
|
|
776
|
+
target.removeEventListener("pointermove", listeners.move);
|
|
777
|
+
target.removeEventListener("pointerup", listeners.up);
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
function addPointerUpCancelListeners(listeners, target = getDefaultPointerUpCancelListenerTarget()) {
|
|
781
|
+
if (!target) {
|
|
782
|
+
return () => void 0;
|
|
783
|
+
}
|
|
784
|
+
target.addEventListener("pointerup", listeners.up);
|
|
785
|
+
target.addEventListener("pointercancel", listeners.cancel);
|
|
786
|
+
return () => {
|
|
787
|
+
target.removeEventListener("pointerup", listeners.up);
|
|
788
|
+
target.removeEventListener("pointercancel", listeners.cancel);
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
function addPointerMoveUpCancelListeners(listeners, target = getDefaultPointerMoveUpCancelListenerTarget()) {
|
|
792
|
+
if (!target) {
|
|
793
|
+
return () => void 0;
|
|
794
|
+
}
|
|
795
|
+
target.addEventListener("pointermove", listeners.move);
|
|
796
|
+
target.addEventListener("pointerup", listeners.up);
|
|
797
|
+
target.addEventListener("pointercancel", listeners.cancel);
|
|
798
|
+
return () => {
|
|
799
|
+
target.removeEventListener("pointermove", listeners.move);
|
|
800
|
+
target.removeEventListener("pointerup", listeners.up);
|
|
801
|
+
target.removeEventListener("pointercancel", listeners.cancel);
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
function addPassiveScrollListener(listener, target) {
|
|
805
|
+
target.addEventListener("scroll", listener, { passive: true });
|
|
806
|
+
return () => {
|
|
807
|
+
target.removeEventListener("scroll", listener);
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
function getColumnPinningControlsProps(column) {
|
|
811
|
+
return {
|
|
812
|
+
"aria-label": `${column.id} column pinning`
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
function getColumnPinningButtonText(position) {
|
|
816
|
+
if (position === "left") {
|
|
817
|
+
return "L";
|
|
818
|
+
}
|
|
819
|
+
if (position === "right") {
|
|
820
|
+
return "R";
|
|
821
|
+
}
|
|
822
|
+
return "-";
|
|
823
|
+
}
|
|
824
|
+
function getColumnPinningButtonProps(column, options) {
|
|
825
|
+
const label = options.position === "left" ? `Pin ${column.id} left` : options.position === "right" ? `Pin ${column.id} right` : `Unpin ${column.id}`;
|
|
826
|
+
return {
|
|
827
|
+
type: "button",
|
|
828
|
+
"aria-label": label,
|
|
829
|
+
"aria-pressed": options.active,
|
|
830
|
+
disabled: options.active
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
function getHeaderActionMenuTriggerProps(column, options) {
|
|
834
|
+
return {
|
|
835
|
+
type: "button",
|
|
836
|
+
"aria-label": `Open ${column.id} column menu`,
|
|
837
|
+
"aria-expanded": options.expanded,
|
|
838
|
+
"aria-haspopup": "menu",
|
|
839
|
+
"aria-controls": options.expanded ? options.controls : void 0
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
function getHeaderActionMenuId(columnId) {
|
|
843
|
+
return `og-grid-header-menu-${columnId.replace(/[^a-zA-Z0-9_-]+/g, "-")}`;
|
|
844
|
+
}
|
|
845
|
+
function getHeaderActionMenuTriggerId(columnId) {
|
|
846
|
+
return `${getHeaderActionMenuId(columnId)}-trigger`;
|
|
847
|
+
}
|
|
848
|
+
function getHeaderActionMenuProps(column) {
|
|
849
|
+
return {
|
|
850
|
+
role: "menu",
|
|
851
|
+
"aria-label": `${column.id} column menu`,
|
|
852
|
+
tabIndex: -1
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
function getHeaderActionMenuDefaultItemLabel(itemId, options = {}) {
|
|
856
|
+
if (itemId === "sort-asc") {
|
|
857
|
+
return "Sort ascending";
|
|
858
|
+
}
|
|
859
|
+
if (itemId === "sort-desc") {
|
|
860
|
+
return "Sort descending";
|
|
861
|
+
}
|
|
862
|
+
if (itemId === "clear-sort") {
|
|
863
|
+
return "Clear sort";
|
|
864
|
+
}
|
|
865
|
+
if (itemId === "move-left") {
|
|
866
|
+
return "Move left";
|
|
867
|
+
}
|
|
868
|
+
if (itemId === "move-right") {
|
|
869
|
+
return "Move right";
|
|
870
|
+
}
|
|
871
|
+
if (itemId === "pin-left") {
|
|
872
|
+
return "Pin left";
|
|
873
|
+
}
|
|
874
|
+
if (itemId === "unpin") {
|
|
875
|
+
return "Unpin";
|
|
876
|
+
}
|
|
877
|
+
if (itemId === "pin-right") {
|
|
878
|
+
return "Pin right";
|
|
879
|
+
}
|
|
880
|
+
return options.grouped ? "Ungroup column" : "Group by column";
|
|
881
|
+
}
|
|
882
|
+
function getHeaderActionMenuDefaultItemDescriptors(options) {
|
|
883
|
+
const descriptors = [
|
|
884
|
+
{
|
|
885
|
+
id: "sort-asc",
|
|
886
|
+
label: getHeaderActionMenuDefaultItemLabel("sort-asc")
|
|
887
|
+
},
|
|
888
|
+
{
|
|
889
|
+
id: "sort-desc",
|
|
890
|
+
label: getHeaderActionMenuDefaultItemLabel("sort-desc")
|
|
891
|
+
},
|
|
892
|
+
{
|
|
893
|
+
id: "clear-sort",
|
|
894
|
+
label: getHeaderActionMenuDefaultItemLabel("clear-sort"),
|
|
895
|
+
disabled: !options.sortDirection
|
|
896
|
+
},
|
|
897
|
+
{
|
|
898
|
+
id: "move-left",
|
|
899
|
+
label: getHeaderActionMenuDefaultItemLabel("move-left"),
|
|
900
|
+
disabled: !options.canMoveLeft
|
|
901
|
+
},
|
|
902
|
+
{
|
|
903
|
+
id: "move-right",
|
|
904
|
+
label: getHeaderActionMenuDefaultItemLabel("move-right"),
|
|
905
|
+
disabled: !options.canMoveRight
|
|
906
|
+
},
|
|
907
|
+
{
|
|
908
|
+
id: "pin-left",
|
|
909
|
+
label: getHeaderActionMenuDefaultItemLabel("pin-left"),
|
|
910
|
+
disabled: options.pinningPosition === "left"
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
id: "unpin",
|
|
914
|
+
label: getHeaderActionMenuDefaultItemLabel("unpin"),
|
|
915
|
+
disabled: options.pinningPosition === false
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
id: "pin-right",
|
|
919
|
+
label: getHeaderActionMenuDefaultItemLabel("pin-right"),
|
|
920
|
+
disabled: options.pinningPosition === "right"
|
|
921
|
+
}
|
|
922
|
+
];
|
|
923
|
+
if (options.canGroup) {
|
|
924
|
+
descriptors.push({
|
|
925
|
+
id: "toggle-group",
|
|
926
|
+
label: getHeaderActionMenuDefaultItemLabel("toggle-group", { grouped: options.isGrouped })
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
return descriptors;
|
|
930
|
+
}
|
|
931
|
+
function getHeaderActionMenuItemProps(options = {}) {
|
|
932
|
+
return {
|
|
933
|
+
type: "button",
|
|
934
|
+
role: "menuitem",
|
|
935
|
+
disabled: options.disabled || void 0
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
function getHeaderActionMenuCustomItemProps(options = {}) {
|
|
939
|
+
return {
|
|
940
|
+
role: "presentation",
|
|
941
|
+
"aria-label": options.label
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
function getHeaderActionMenuLabelProps() {
|
|
945
|
+
return {
|
|
946
|
+
role: "presentation"
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
function getHeaderActionMenuSeparatorProps(options = {}) {
|
|
950
|
+
return {
|
|
951
|
+
role: "separator",
|
|
952
|
+
"aria-label": options.label
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
function isHeaderActionMenuItem(item) {
|
|
956
|
+
return Boolean(item);
|
|
957
|
+
}
|
|
958
|
+
function isHeaderActionMenuActionItem(item) {
|
|
959
|
+
return item !== null && item !== false && item !== void 0 && (item.type === void 0 || item.type === "action");
|
|
960
|
+
}
|
|
961
|
+
function isHeaderActionMenuCustomItem(item) {
|
|
962
|
+
return item !== null && item !== false && item !== void 0 && item.type === "custom";
|
|
963
|
+
}
|
|
964
|
+
function isHeaderActionMenuLabelItem(item) {
|
|
965
|
+
return item !== null && item !== false && item !== void 0 && item.type === "label";
|
|
966
|
+
}
|
|
967
|
+
function isHeaderActionMenuSeparatorItem(item) {
|
|
968
|
+
return item !== null && item !== false && item !== void 0 && item.type === "separator";
|
|
969
|
+
}
|
|
970
|
+
function getHeaderActionMenuCustomItemUserProps(item) {
|
|
971
|
+
return item ? item.props ?? {} : {};
|
|
972
|
+
}
|
|
973
|
+
function getGroupingPanelProps(options = {}) {
|
|
974
|
+
return {
|
|
975
|
+
"aria-label": "Column grouping",
|
|
976
|
+
"data-empty": options.empty || void 0
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
function getGroupingPanelPlaceholderProps() {
|
|
980
|
+
return {
|
|
981
|
+
"data-empty-placeholder": true
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
function getGroupingPanelChipProps(column) {
|
|
985
|
+
return {
|
|
986
|
+
"data-column-id": column.id
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
function getGroupingPanelMoveButtonProps(column, options) {
|
|
990
|
+
return {
|
|
991
|
+
type: "button",
|
|
992
|
+
"aria-label": `Move ${column.id} grouping ${options.direction}`,
|
|
993
|
+
disabled: options.disabled || false
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
function getGroupingPanelRemoveButtonProps(column) {
|
|
997
|
+
return {
|
|
998
|
+
type: "button",
|
|
999
|
+
"aria-label": `Remove ${column.id} grouping`
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
function getIsGroupLabelCell(row, column, visibleColumns) {
|
|
1003
|
+
const firstVisibleColumnId = visibleColumns[0]?.id;
|
|
1004
|
+
if (!row.getIsGrouped()) {
|
|
1005
|
+
if (row.getIsGroupFooter()) {
|
|
1006
|
+
return column.id === firstVisibleColumnId;
|
|
1007
|
+
}
|
|
1008
|
+
return (row.depth > 0 || row.getCanExpand()) && column.id === firstVisibleColumnId;
|
|
1009
|
+
}
|
|
1010
|
+
return column.id === row.groupingColumnId || !visibleColumns.some((candidate) => candidate.id === row.groupingColumnId) && column.id === firstVisibleColumnId;
|
|
1011
|
+
}
|
|
1012
|
+
function getGroupValueText(value) {
|
|
1013
|
+
if (value instanceof Date) {
|
|
1014
|
+
return value.toISOString();
|
|
1015
|
+
}
|
|
1016
|
+
return value == null ? "(blank)" : String(value);
|
|
1017
|
+
}
|
|
1018
|
+
function getGroupRowLabel(row, column, options = {}) {
|
|
1019
|
+
if (row.getIsGroupFooter()) {
|
|
1020
|
+
return row.groupFooterLabel ?? "Total";
|
|
1021
|
+
}
|
|
1022
|
+
if (row.groupingColumnId) {
|
|
1023
|
+
return `${row.groupingColumnId}: ${getGroupValueText(row.groupingValue)}`;
|
|
1024
|
+
}
|
|
1025
|
+
return options.fallback ?? getGroupValueText(row.getValue(column.id));
|
|
1026
|
+
}
|
|
1027
|
+
function getGroupCellIndent(row, options = {}) {
|
|
1028
|
+
const depthSize = options.depthSize ?? 16;
|
|
1029
|
+
const footerOffset = options.footerOffset ?? 8;
|
|
1030
|
+
const offset = row.getIsGroupFooter() ? footerOffset : 0;
|
|
1031
|
+
return row.depth * depthSize - offset;
|
|
1032
|
+
}
|
|
1033
|
+
function getGroupCellIndentStyle(row, options = {}) {
|
|
1034
|
+
return {
|
|
1035
|
+
paddingLeft: getGroupCellIndent(row, options)
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
function getGroupCellIndentStyleText(row, options = {}) {
|
|
1039
|
+
return `padding-left: ${getGroupCellIndent(row, options)}px`;
|
|
1040
|
+
}
|
|
1041
|
+
function getGroupRowCountText(row) {
|
|
1042
|
+
return row.getIsGrouped() ? String(row.leafRows.length) : void 0;
|
|
1043
|
+
}
|
|
1044
|
+
function getRowProps(row, rowIndex, options = {}) {
|
|
1045
|
+
return {
|
|
1046
|
+
role: "row",
|
|
1047
|
+
"aria-rowindex": (options.rowIndexOffset ?? 0) + rowIndex + 1,
|
|
1048
|
+
"aria-selected": options.selected || void 0,
|
|
1049
|
+
"data-row-id": row.id,
|
|
1050
|
+
"data-selected": options.selected || void 0
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
function getRowLayoutProps(row, options = {}) {
|
|
1054
|
+
return {
|
|
1055
|
+
"data-grouped-row": row.getIsGrouped() || void 0,
|
|
1056
|
+
"data-group-footer-row": row.getIsGroupFooter() || void 0,
|
|
1057
|
+
"data-expanded": row.getCanExpand() ? options.expanded : void 0,
|
|
1058
|
+
"data-virtual-index": options.virtualIndex,
|
|
1059
|
+
"data-column-virtualized": options.columnVirtualized || void 0
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
function getRowExpansionToggleProps(row, options) {
|
|
1063
|
+
return {
|
|
1064
|
+
type: "button",
|
|
1065
|
+
"aria-label": `${options.expanded ? "Collapse" : "Expand"} ${options.label}`,
|
|
1066
|
+
"aria-expanded": options.expanded,
|
|
1067
|
+
"data-row-id": row.id,
|
|
1068
|
+
"data-expanded": options.expanded
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
function getRowExpansionToggleText(expanded) {
|
|
1072
|
+
return expanded ? "\u2212" : "+";
|
|
1073
|
+
}
|
|
1074
|
+
function getRowExpansionSpacerProps() {
|
|
1075
|
+
return {
|
|
1076
|
+
"aria-hidden": true
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
function getCellProps(row, column, _rowIndex, columnIndex, options = {}) {
|
|
1080
|
+
const focused = isFocusedCell(options.focusedCell ?? null, row.id, column.id);
|
|
1081
|
+
return {
|
|
1082
|
+
role: "gridcell",
|
|
1083
|
+
"aria-colindex": columnIndex + 1,
|
|
1084
|
+
"data-row-id": row.id,
|
|
1085
|
+
"data-column-id": column.id,
|
|
1086
|
+
"data-pinned": column.getIsPinned() || void 0,
|
|
1087
|
+
tabIndex: focused ? 0 : -1,
|
|
1088
|
+
"data-focused": focused || void 0,
|
|
1089
|
+
"data-editing": options.editing || void 0,
|
|
1090
|
+
"aria-selected": options.rangeSelected || void 0,
|
|
1091
|
+
"data-range-selected": options.rangeSelected || void 0
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
function getCellLayoutProps(options = {}) {
|
|
1095
|
+
return {
|
|
1096
|
+
"data-validation-invalid": options.invalid || void 0,
|
|
1097
|
+
"data-pinned-edge": options.pinnedEdge
|
|
1098
|
+
};
|
|
1099
|
+
}
|
|
1100
|
+
function getCellFillHandleProps() {
|
|
1101
|
+
return {
|
|
1102
|
+
"aria-hidden": true,
|
|
1103
|
+
"data-fill-handle": true
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
function getCanStartCellEdit(row, column) {
|
|
1107
|
+
return !row.getIsGrouped() && !row.getIsGroupFooter() && column.getCanEdit();
|
|
1108
|
+
}
|
|
1109
|
+
function getCanStartFocusedCellEdit(focusedCell, editingCell) {
|
|
1110
|
+
return Boolean(focusedCell) && !editingCell;
|
|
1111
|
+
}
|
|
1112
|
+
function getCanRestoreFocusedCell(options) {
|
|
1113
|
+
return options.shouldRestore && options.focusedCell != null && options.scroller != null && options.inProgress !== true;
|
|
1114
|
+
}
|
|
1115
|
+
function getShouldCancelFocusedCellRestoreOnFrameSync(options = {}) {
|
|
1116
|
+
return options.inProgress !== true;
|
|
1117
|
+
}
|
|
1118
|
+
function getCanCancelCellEdit(editingCell) {
|
|
1119
|
+
return Boolean(editingCell);
|
|
1120
|
+
}
|
|
1121
|
+
function getCanRunGridKeyboardShortcut(editingCell) {
|
|
1122
|
+
return !editingCell;
|
|
1123
|
+
}
|
|
1124
|
+
function getFocusedRowSelectionTarget(rows, focusedCell) {
|
|
1125
|
+
if (!focusedCell) {
|
|
1126
|
+
return null;
|
|
1127
|
+
}
|
|
1128
|
+
const rowIndex = rows.findIndex((row2) => row2.id === focusedCell.rowId);
|
|
1129
|
+
const row = rowIndex >= 0 ? rows[rowIndex] : void 0;
|
|
1130
|
+
return row ? { row, rowIndex } : null;
|
|
1131
|
+
}
|
|
1132
|
+
function getCanToggleRowSelection(event) {
|
|
1133
|
+
return !event.defaultPrevented;
|
|
1134
|
+
}
|
|
1135
|
+
function getCellEditText(value) {
|
|
1136
|
+
return value == null ? "" : String(value);
|
|
1137
|
+
}
|
|
1138
|
+
function getCellEditorTargetValue(target) {
|
|
1139
|
+
return target && typeof target === "object" && "value" in target ? target.value : void 0;
|
|
1140
|
+
}
|
|
1141
|
+
function getCellEditorEventValue(event) {
|
|
1142
|
+
const value = getCellEditorTargetValue(event.currentTarget) ?? getCellEditorTargetValue(event.target);
|
|
1143
|
+
return typeof value === "string" ? value : "";
|
|
1144
|
+
}
|
|
1145
|
+
function parseCellEditValue(grid, row, column, value) {
|
|
1146
|
+
return column.columnDef.editValueParser ? column.columnDef.editValueParser(value, {
|
|
1147
|
+
grid,
|
|
1148
|
+
row,
|
|
1149
|
+
column,
|
|
1150
|
+
previousValue: row.getValue(column.id)
|
|
1151
|
+
}) : value;
|
|
1152
|
+
}
|
|
1153
|
+
function getCellEditValidationMessage(event) {
|
|
1154
|
+
return event?.validation?.valid === false ? event.validation.message ?? "Invalid value" : null;
|
|
1155
|
+
}
|
|
1156
|
+
function getDefaultClipboardTextEnvironment() {
|
|
1157
|
+
const clipboardDocument = typeof document === "undefined" ? void 0 : {
|
|
1158
|
+
body: document.body ? {
|
|
1159
|
+
appendChild: (element) => document.body?.appendChild(element),
|
|
1160
|
+
removeChild: (element) => document.body?.removeChild(element)
|
|
1161
|
+
} : void 0,
|
|
1162
|
+
documentElement: {
|
|
1163
|
+
appendChild: (element) => document.documentElement.appendChild(element),
|
|
1164
|
+
removeChild: (element) => document.documentElement.removeChild(element)
|
|
1165
|
+
},
|
|
1166
|
+
createElement: () => document.createElement("textarea"),
|
|
1167
|
+
execCommand: (command) => document.execCommand(command)
|
|
1168
|
+
};
|
|
1169
|
+
return {
|
|
1170
|
+
document: clipboardDocument,
|
|
1171
|
+
navigator: typeof navigator === "undefined" ? void 0 : navigator
|
|
1172
|
+
};
|
|
1173
|
+
}
|
|
1174
|
+
function getDefaultBrowserDownloadEnvironment() {
|
|
1175
|
+
const downloadDocument = typeof document === "undefined" ? void 0 : {
|
|
1176
|
+
body: document.body ? {
|
|
1177
|
+
appendChild: (element) => document.body?.appendChild(element),
|
|
1178
|
+
removeChild: (element) => document.body?.removeChild(element)
|
|
1179
|
+
} : void 0,
|
|
1180
|
+
documentElement: {
|
|
1181
|
+
appendChild: (element) => document.documentElement.appendChild(element),
|
|
1182
|
+
removeChild: (element) => document.documentElement.removeChild(element)
|
|
1183
|
+
},
|
|
1184
|
+
createElement: () => document.createElement("a")
|
|
1185
|
+
};
|
|
1186
|
+
const BrowserBlob = typeof Blob === "undefined" ? void 0 : Blob;
|
|
1187
|
+
return {
|
|
1188
|
+
blob: BrowserBlob ? /* @__PURE__ */ (() => {
|
|
1189
|
+
const BlobConstructor = BrowserBlob;
|
|
1190
|
+
return class {
|
|
1191
|
+
constructor(blobParts, options) {
|
|
1192
|
+
return new BlobConstructor([...blobParts], options);
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
})() : void 0,
|
|
1196
|
+
document: downloadDocument,
|
|
1197
|
+
url: typeof URL === "undefined" ? void 0 : {
|
|
1198
|
+
createObjectURL: (blob) => URL.createObjectURL(blob),
|
|
1199
|
+
revokeObjectURL: (url) => URL.revokeObjectURL(url)
|
|
1200
|
+
}
|
|
1201
|
+
};
|
|
1202
|
+
}
|
|
1203
|
+
async function writeClipboardText(text, environment = getDefaultClipboardTextEnvironment()) {
|
|
1204
|
+
if (environment.navigator?.clipboard?.writeText) {
|
|
1205
|
+
try {
|
|
1206
|
+
await environment.navigator.clipboard.writeText(text);
|
|
1207
|
+
return true;
|
|
1208
|
+
} catch {
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
if (!environment.document) {
|
|
1212
|
+
return false;
|
|
1213
|
+
}
|
|
1214
|
+
const textarea = environment.document.createElement("textarea");
|
|
1215
|
+
textarea.value = text;
|
|
1216
|
+
textarea.setAttribute("readonly", "");
|
|
1217
|
+
textarea.style.position = "fixed";
|
|
1218
|
+
textarea.style.top = "-9999px";
|
|
1219
|
+
textarea.style.left = "-9999px";
|
|
1220
|
+
const parent = environment.document.body ?? environment.document.documentElement;
|
|
1221
|
+
parent.appendChild(textarea);
|
|
1222
|
+
textarea.select();
|
|
1223
|
+
try {
|
|
1224
|
+
return environment.document.execCommand("copy");
|
|
1225
|
+
} finally {
|
|
1226
|
+
parent.removeChild(textarea);
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
async function readClipboardText(environment = getDefaultClipboardTextEnvironment()) {
|
|
1230
|
+
if (!environment.navigator?.clipboard?.readText) {
|
|
1231
|
+
return "";
|
|
1232
|
+
}
|
|
1233
|
+
try {
|
|
1234
|
+
return await environment.navigator.clipboard.readText();
|
|
1235
|
+
} catch {
|
|
1236
|
+
return "";
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
function downloadBrowserExportFile(file, environment = getDefaultBrowserDownloadEnvironment()) {
|
|
1240
|
+
if (!environment.document || !environment.blob || !environment.url) {
|
|
1241
|
+
return false;
|
|
1242
|
+
}
|
|
1243
|
+
const blob = new environment.blob([file.text], { type: file.mimeType });
|
|
1244
|
+
const url = environment.url.createObjectURL(blob);
|
|
1245
|
+
const anchor = environment.document.createElement("a");
|
|
1246
|
+
anchor.href = url;
|
|
1247
|
+
anchor.download = file.filename;
|
|
1248
|
+
anchor.style.display = "none";
|
|
1249
|
+
const parent = environment.document.body ?? environment.document.documentElement;
|
|
1250
|
+
let appended = false;
|
|
1251
|
+
try {
|
|
1252
|
+
parent.appendChild(anchor);
|
|
1253
|
+
appended = true;
|
|
1254
|
+
anchor.click();
|
|
1255
|
+
return true;
|
|
1256
|
+
} finally {
|
|
1257
|
+
if (appended) {
|
|
1258
|
+
parent.removeChild(anchor);
|
|
1259
|
+
}
|
|
1260
|
+
environment.url.revokeObjectURL(url);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
function getCellDisplayText(value) {
|
|
1264
|
+
return value == null ? "" : String(value);
|
|
1265
|
+
}
|
|
1266
|
+
function escapeGridHtml(value) {
|
|
1267
|
+
return value.replace(/[&<"]/g, (character) => `&#${character.charCodeAt(0)};`);
|
|
1268
|
+
}
|
|
1269
|
+
function getColumnHeaderText(column) {
|
|
1270
|
+
const header = column.columnDef.header;
|
|
1271
|
+
return typeof header === "string" ? header : column.id;
|
|
1272
|
+
}
|
|
1273
|
+
function getCellFillHandleVisible(row, column, options) {
|
|
1274
|
+
return !row.getIsGrouped() && !row.getIsGroupFooter() && Boolean(options.rangeSelected) && !options.editing && !options.activeEditing && isCellCoordinateEqual(options.fillHandleCoordinate, { rowId: row.id, columnId: column.id });
|
|
1275
|
+
}
|
|
1276
|
+
function getCanStartCellPointerDrag(event, editingCell) {
|
|
1277
|
+
return isPrimaryPointerButton(event) && !editingCell;
|
|
1278
|
+
}
|
|
1279
|
+
function getCellEditorProps(column, options = {}) {
|
|
1280
|
+
return {
|
|
1281
|
+
"aria-label": `Edit ${column.id}`,
|
|
1282
|
+
"aria-invalid": options.invalid || void 0
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
function getCellEditorOptionProps(option) {
|
|
1286
|
+
return {
|
|
1287
|
+
value: option.value,
|
|
1288
|
+
disabled: option.disabled || void 0
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
function getCellEditorOptionText(option) {
|
|
1292
|
+
return option.label ?? option.value;
|
|
1293
|
+
}
|
|
1294
|
+
function getCellValidationMessageProps() {
|
|
1295
|
+
return {
|
|
1296
|
+
role: "alert"
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1299
|
+
function isFocusableElement(target) {
|
|
1300
|
+
return !!target && typeof target === "object" && "focus" in target && typeof target.focus === "function";
|
|
1301
|
+
}
|
|
1302
|
+
function getEnabledHeaderActionMenuItems(menu) {
|
|
1303
|
+
if (!menu) {
|
|
1304
|
+
return [];
|
|
1305
|
+
}
|
|
1306
|
+
const items = [];
|
|
1307
|
+
for (const item of Array.from(menu.querySelectorAll(HEADER_ACTION_MENU_ENABLED_ITEM_SELECTOR))) {
|
|
1308
|
+
if (isFocusableElement(item)) {
|
|
1309
|
+
items.push(item);
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
return items;
|
|
1313
|
+
}
|
|
1314
|
+
function getHeaderActionMenuActiveElement(menu, fallbackDocument = typeof document === "undefined" ? void 0 : document) {
|
|
1315
|
+
return menu?.ownerDocument?.activeElement ?? fallbackDocument?.activeElement ?? null;
|
|
1316
|
+
}
|
|
1317
|
+
function focusHeaderActionMenuItem(menu, position) {
|
|
1318
|
+
if (!menu) {
|
|
1319
|
+
return false;
|
|
1320
|
+
}
|
|
1321
|
+
const items = getEnabledHeaderActionMenuItems(menu);
|
|
1322
|
+
if (items.length === 0) {
|
|
1323
|
+
menu.focus();
|
|
1324
|
+
return true;
|
|
1325
|
+
}
|
|
1326
|
+
const activeElement = getHeaderActionMenuActiveElement(menu);
|
|
1327
|
+
const activeIndex = items.findIndex((item) => item === activeElement);
|
|
1328
|
+
if (position === "first") {
|
|
1329
|
+
items[0]?.focus();
|
|
1330
|
+
} else if (position === "last") {
|
|
1331
|
+
items[items.length - 1]?.focus();
|
|
1332
|
+
} else if (position === "next") {
|
|
1333
|
+
items[(activeIndex + 1 + items.length) % items.length]?.focus();
|
|
1334
|
+
} else {
|
|
1335
|
+
items[(activeIndex - 1 + items.length) % items.length]?.focus();
|
|
1336
|
+
}
|
|
1337
|
+
return true;
|
|
1338
|
+
}
|
|
1339
|
+
function isHeaderActionMenuFocusTarget(target) {
|
|
1340
|
+
return !!target && typeof target === "object" && "focus" in target && typeof target.focus === "function" && "querySelectorAll" in target && typeof target.querySelectorAll === "function";
|
|
1341
|
+
}
|
|
1342
|
+
function getHeaderActionMenuFocusTarget(event) {
|
|
1343
|
+
return isHeaderActionMenuFocusTarget(event.currentTarget) ? event.currentTarget : null;
|
|
1344
|
+
}
|
|
1345
|
+
function focusElement(element) {
|
|
1346
|
+
if (!isFocusableElement(element)) {
|
|
1347
|
+
return false;
|
|
1348
|
+
}
|
|
1349
|
+
element.focus();
|
|
1350
|
+
return true;
|
|
1351
|
+
}
|
|
1352
|
+
function focusCellEditorElement(element) {
|
|
1353
|
+
if (!element) {
|
|
1354
|
+
return false;
|
|
1355
|
+
}
|
|
1356
|
+
element.focus();
|
|
1357
|
+
element.select?.();
|
|
1358
|
+
return true;
|
|
1359
|
+
}
|
|
1360
|
+
function focusElementById(lookup, id) {
|
|
1361
|
+
return focusElement(lookup.getElementById(id));
|
|
1362
|
+
}
|
|
1363
|
+
function focusHeaderActionMenuTrigger(element) {
|
|
1364
|
+
return focusElement(element);
|
|
1365
|
+
}
|
|
1366
|
+
function focusHeaderActionMenuTriggerById(lookup, id) {
|
|
1367
|
+
return focusHeaderActionMenuTrigger(lookup.getElementById(id));
|
|
1368
|
+
}
|
|
1369
|
+
function focusHeaderActionMenuItemById(lookup, id, position) {
|
|
1370
|
+
return focusHeaderActionMenuItem(lookup.getElementById(id), position);
|
|
1371
|
+
}
|
|
1372
|
+
function focusFocusedCellInGrid(container) {
|
|
1373
|
+
return focusElement(container?.querySelector(GRID_FOCUSED_CELL_SELECTOR));
|
|
1374
|
+
}
|
|
1375
|
+
function scrollElementToPosition(element, position) {
|
|
1376
|
+
if (!element || !position) {
|
|
1377
|
+
return false;
|
|
1378
|
+
}
|
|
1379
|
+
element.scrollLeft = position.scrollLeft;
|
|
1380
|
+
element.scrollTop = position.scrollTop;
|
|
1381
|
+
return true;
|
|
1382
|
+
}
|
|
1383
|
+
function getScrollFrameOptionsFromElement(element, options = {}) {
|
|
1384
|
+
return {
|
|
1385
|
+
scrollTop: options.scrollTop ?? element.scrollTop,
|
|
1386
|
+
scrollLeft: options.scrollLeft ?? element.scrollLeft,
|
|
1387
|
+
viewportHeight: element.clientHeight,
|
|
1388
|
+
viewportWidth: element.clientWidth,
|
|
1389
|
+
stickyTopOffset: options.stickyTopOffset ?? 0
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1392
|
+
function getFocusedCellScrollOptionsFromElement(element, options) {
|
|
1393
|
+
return {
|
|
1394
|
+
...options,
|
|
1395
|
+
currentScrollLeft: element.scrollLeft,
|
|
1396
|
+
currentScrollTop: element.scrollTop,
|
|
1397
|
+
viewportWidth: element.clientWidth,
|
|
1398
|
+
viewportHeight: element.clientHeight
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1401
|
+
function isGridInteractiveKeyboardTarget(target, currentTarget) {
|
|
1402
|
+
if (!target || target === currentTarget || !("closest" in target) || typeof target.closest !== "function") {
|
|
1403
|
+
return false;
|
|
1404
|
+
}
|
|
1405
|
+
return Boolean(target.closest(GRID_INTERACTIVE_KEYBOARD_TARGET_SELECTOR));
|
|
1406
|
+
}
|
|
1407
|
+
function isGridInteractiveKeyboardEventTarget(event) {
|
|
1408
|
+
return isGridInteractiveKeyboardTarget(event.target, event.currentTarget);
|
|
1409
|
+
}
|
|
1410
|
+
function getShouldPreventEventDefault(event) {
|
|
1411
|
+
return event.defaultPrevented;
|
|
1412
|
+
}
|
|
1413
|
+
function preventDefaultAndStopPropagation(event) {
|
|
1414
|
+
event.preventDefault();
|
|
1415
|
+
event.stopPropagation();
|
|
1416
|
+
}
|
|
1417
|
+
function preventEventDefault(event) {
|
|
1418
|
+
event.preventDefault();
|
|
1419
|
+
}
|
|
1420
|
+
function stopEventPropagation(event) {
|
|
1421
|
+
event.stopPropagation();
|
|
1422
|
+
}
|
|
1423
|
+
function createClickSuppressionController() {
|
|
1424
|
+
let suppressed = false;
|
|
1425
|
+
return {
|
|
1426
|
+
suppress() {
|
|
1427
|
+
suppressed = true;
|
|
1428
|
+
},
|
|
1429
|
+
consume(event) {
|
|
1430
|
+
if (!suppressed) {
|
|
1431
|
+
return false;
|
|
1432
|
+
}
|
|
1433
|
+
suppressed = false;
|
|
1434
|
+
if (event) {
|
|
1435
|
+
preventDefaultAndStopPropagation(event);
|
|
1436
|
+
}
|
|
1437
|
+
return true;
|
|
1438
|
+
}
|
|
1439
|
+
};
|
|
1440
|
+
}
|
|
1441
|
+
function isPointerInsideElement(event, element) {
|
|
1442
|
+
if (!element) {
|
|
1443
|
+
return false;
|
|
1444
|
+
}
|
|
1445
|
+
const rect = element.getBoundingClientRect();
|
|
1446
|
+
return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
|
|
1447
|
+
}
|
|
1448
|
+
function hasPointerMovedPastDragThreshold(event, start, threshold = 4) {
|
|
1449
|
+
return Math.abs(event.clientX - start.startX) > threshold || Math.abs(event.clientY - start.startY) > threshold;
|
|
1450
|
+
}
|
|
1451
|
+
function updatePointerDragDidMovePastThreshold(drag, event, threshold = 4) {
|
|
1452
|
+
if (!drag.didDrag && hasPointerMovedPastDragThreshold(event, drag, threshold)) {
|
|
1453
|
+
drag.didDrag = true;
|
|
1454
|
+
}
|
|
1455
|
+
return Boolean(drag.didDrag);
|
|
1456
|
+
}
|
|
1457
|
+
function isPrimaryPointerButton(event) {
|
|
1458
|
+
return event.button === 0;
|
|
1459
|
+
}
|
|
1460
|
+
function isPrimaryPointerDragActive(event) {
|
|
1461
|
+
return (event.buttons & 1) === 1;
|
|
1462
|
+
}
|
|
1463
|
+
function getCanContinuePointerDrag(drag, event) {
|
|
1464
|
+
return drag != null && drag.pointerId === event.pointerId && isPrimaryPointerDragActive(event);
|
|
1465
|
+
}
|
|
1466
|
+
function getCanEndPointerDrag(drag, event) {
|
|
1467
|
+
return drag != null && drag.pointerId === event.pointerId;
|
|
1468
|
+
}
|
|
1469
|
+
function getHeaderDragEndAction(drag, options) {
|
|
1470
|
+
if (!drag.didDrag) {
|
|
1471
|
+
return null;
|
|
1472
|
+
}
|
|
1473
|
+
const droppedOnGroupingPanel = options.groupingPanel && isPointerInsideElement(options.event, options.groupingPanelElement);
|
|
1474
|
+
const sourceColumn = options.columns.find((column) => column.id === drag.sourceColumnId);
|
|
1475
|
+
if (droppedOnGroupingPanel && sourceColumn?.getCanGroup()) {
|
|
1476
|
+
return {
|
|
1477
|
+
type: "group",
|
|
1478
|
+
columnId: drag.sourceColumnId
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1481
|
+
return {
|
|
1482
|
+
type: "move",
|
|
1483
|
+
sourceColumnId: drag.sourceColumnId,
|
|
1484
|
+
targetColumnId: drag.targetColumnId
|
|
1485
|
+
};
|
|
1486
|
+
}
|
|
1487
|
+
function isHeaderDragGroupAction(action) {
|
|
1488
|
+
return action?.type === "group";
|
|
1489
|
+
}
|
|
1490
|
+
function isHeaderDragMoveAction(action) {
|
|
1491
|
+
return action?.type === "move";
|
|
1492
|
+
}
|
|
1493
|
+
function getMeasuredElementBlockSize(element, fallbackSize) {
|
|
1494
|
+
return Math.max(fallbackSize, element.scrollHeight);
|
|
1495
|
+
}
|
|
1496
|
+
function isMeasuredBlockElement(target) {
|
|
1497
|
+
return typeof target === "object" && target !== null && "scrollHeight" in target && typeof target.scrollHeight === "number";
|
|
1498
|
+
}
|
|
1499
|
+
function isMeasuredBlockRectElement(target) {
|
|
1500
|
+
return isMeasuredBlockElement(target) && "getBoundingClientRect" in target && typeof target.getBoundingClientRect === "function";
|
|
1501
|
+
}
|
|
1502
|
+
function isMeasuredBlockRectElementTarget(target) {
|
|
1503
|
+
return typeof Element !== "undefined" && target instanceof Element && isMeasuredBlockRectElement(target);
|
|
1504
|
+
}
|
|
1505
|
+
function isMeasuredInlineElement(target) {
|
|
1506
|
+
return typeof target === "object" && target !== null && "getBoundingClientRect" in target && typeof target.getBoundingClientRect === "function";
|
|
1507
|
+
}
|
|
1508
|
+
function isMeasuredInlineDatasetElementTarget(target) {
|
|
1509
|
+
return typeof Element !== "undefined" && target instanceof Element && isMeasuredInlineElement(target) && "dataset" in target && typeof target.dataset === "object" && target.dataset !== null;
|
|
1510
|
+
}
|
|
1511
|
+
function getMeasuredElementBlockSizeFromTarget(target, fallbackSize) {
|
|
1512
|
+
return isMeasuredBlockElement(target) ? getMeasuredElementBlockSize(target, fallbackSize) : fallbackSize;
|
|
1513
|
+
}
|
|
1514
|
+
function getMeasuredElementBlockSizeFromRect(element) {
|
|
1515
|
+
return getMeasuredElementBlockSize(element, element.getBoundingClientRect().height);
|
|
1516
|
+
}
|
|
1517
|
+
function getMeasuredElementInlineSize(element) {
|
|
1518
|
+
return element.getBoundingClientRect().width;
|
|
1519
|
+
}
|
|
1520
|
+
function getElementOffsetBlockSize(element, fallbackSize) {
|
|
1521
|
+
return element?.offsetHeight ?? fallbackSize;
|
|
1522
|
+
}
|
|
1523
|
+
function getResizeObserverEntryBlockSize(entry) {
|
|
1524
|
+
const borderBoxSize = Array.isArray(entry.borderBoxSize) ? entry.borderBoxSize[0] : entry.borderBoxSize;
|
|
1525
|
+
return getMeasuredElementBlockSizeFromTarget(entry.target, borderBoxSize?.blockSize ?? entry.contentRect.height);
|
|
1526
|
+
}
|
|
1527
|
+
function getResizeObserverEntryInlineSize(entry) {
|
|
1528
|
+
const borderBoxSize = Array.isArray(entry.borderBoxSize) ? entry.borderBoxSize[0] : entry.borderBoxSize;
|
|
1529
|
+
return borderBoxSize?.inlineSize ?? entry.contentRect.width;
|
|
1530
|
+
}
|
|
1531
|
+
function isResizeObserverDatasetTarget(target) {
|
|
1532
|
+
if (typeof target !== "object" || target === null) {
|
|
1533
|
+
return false;
|
|
1534
|
+
}
|
|
1535
|
+
if (!("dataset" in target)) {
|
|
1536
|
+
return true;
|
|
1537
|
+
}
|
|
1538
|
+
return typeof target.dataset === "object" && target.dataset !== null;
|
|
1539
|
+
}
|
|
1540
|
+
function getResizeObserverEntryDatasetId(entry, key) {
|
|
1541
|
+
const value = isResizeObserverDatasetTarget(entry.target) ? entry.target.dataset?.[key] : void 0;
|
|
1542
|
+
return value || null;
|
|
1543
|
+
}
|
|
1544
|
+
function setElementDatasetId(element, key, value) {
|
|
1545
|
+
element.dataset[key] = value;
|
|
1546
|
+
}
|
|
1547
|
+
function createResizeObserver(callback, ResizeObserverConstructor = typeof ResizeObserver === "undefined" ? void 0 : ResizeObserver) {
|
|
1548
|
+
return ResizeObserverConstructor ? new ResizeObserverConstructor(callback) : null;
|
|
1549
|
+
}
|
|
1550
|
+
function observeElements(observer, elements) {
|
|
1551
|
+
for (const element of elements) {
|
|
1552
|
+
observer.observe(element);
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
function disconnectResizeObserver(observer) {
|
|
1556
|
+
observer?.disconnect();
|
|
1557
|
+
}
|
|
1558
|
+
function removeObservedElement(observer, elements, id) {
|
|
1559
|
+
const previous = elements.get(id);
|
|
1560
|
+
if (previous) {
|
|
1561
|
+
observer?.unobserve(previous);
|
|
1562
|
+
elements.delete(id);
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
function replaceObservedElement(observer, elements, id, element) {
|
|
1566
|
+
const previous = elements.get(id);
|
|
1567
|
+
if (previous && previous !== element) {
|
|
1568
|
+
observer?.unobserve(previous);
|
|
1569
|
+
elements.delete(id);
|
|
1570
|
+
}
|
|
1571
|
+
elements.set(id, element);
|
|
1572
|
+
observer?.observe(element);
|
|
1573
|
+
}
|
|
1574
|
+
function applyResizeObserverMeasuredSizes(entries, options) {
|
|
1575
|
+
let changed = false;
|
|
1576
|
+
for (const entry of entries) {
|
|
1577
|
+
const id = getResizeObserverEntryDatasetId(entry, options.datasetKey);
|
|
1578
|
+
if (!id) {
|
|
1579
|
+
continue;
|
|
1580
|
+
}
|
|
1581
|
+
changed = options.cache.set(id, options.getSize(entry)) || changed;
|
|
1582
|
+
}
|
|
1583
|
+
return changed;
|
|
1584
|
+
}
|
|
1585
|
+
function getSizeOffset(index, getSize) {
|
|
1586
|
+
let offset = 0;
|
|
1587
|
+
for (let currentIndex = 0; currentIndex < index; currentIndex += 1) {
|
|
1588
|
+
offset += getSize(currentIndex);
|
|
1589
|
+
}
|
|
1590
|
+
return offset;
|
|
1591
|
+
}
|
|
1592
|
+
function getColumnLayoutTotalWidth(layout) {
|
|
1593
|
+
return layout.reduce((total, item) => Math.max(total, item.end), 0);
|
|
1594
|
+
}
|
|
1595
|
+
function getColumnLayoutById(layout) {
|
|
1596
|
+
return new Map(layout.map((item) => [item.id, item]));
|
|
1597
|
+
}
|
|
1598
|
+
function getColumnById(columnId, columns) {
|
|
1599
|
+
return columns.find((column) => column.id === columnId);
|
|
1600
|
+
}
|
|
1601
|
+
function getColumnIndexById(columnId, columns) {
|
|
1602
|
+
return columns.findIndex((column) => column.id === columnId);
|
|
1603
|
+
}
|
|
1604
|
+
function getRowById(rowId, rows) {
|
|
1605
|
+
return rows.find((row) => row.id === rowId);
|
|
1606
|
+
}
|
|
1607
|
+
function moveVisibleColumn(grid, columnId, direction) {
|
|
1608
|
+
const columns = grid.getVisibleLeafColumns();
|
|
1609
|
+
const columnIndex = columns.findIndex((column) => column.id === columnId);
|
|
1610
|
+
const targetColumn = columns[direction === "left" ? columnIndex - 1 : columnIndex + 1];
|
|
1611
|
+
if (columnIndex < 0 || !targetColumn) {
|
|
1612
|
+
return false;
|
|
1613
|
+
}
|
|
1614
|
+
grid.moveColumn(columnId, targetColumn.id, direction === "left" ? "before" : "after");
|
|
1615
|
+
return true;
|
|
1616
|
+
}
|
|
1617
|
+
function moveColumnToTarget(grid, sourceColumnId, targetColumnId) {
|
|
1618
|
+
if (sourceColumnId === targetColumnId) {
|
|
1619
|
+
return false;
|
|
1620
|
+
}
|
|
1621
|
+
const columns = grid.getVisibleLeafColumns();
|
|
1622
|
+
const sourceIndex = columns.findIndex((column) => column.id === sourceColumnId);
|
|
1623
|
+
const targetIndex = columns.findIndex((column) => column.id === targetColumnId);
|
|
1624
|
+
if (sourceIndex < 0 || targetIndex < 0) {
|
|
1625
|
+
return false;
|
|
1626
|
+
}
|
|
1627
|
+
grid.moveColumn(sourceColumnId, targetColumnId, sourceIndex < targetIndex ? "after" : "before");
|
|
1628
|
+
return true;
|
|
1629
|
+
}
|
|
1630
|
+
function moveGroupedColumn(grid, groupingColumns, columnId, direction) {
|
|
1631
|
+
const columnIndex = groupingColumns.findIndex((column) => column.id === columnId);
|
|
1632
|
+
const targetColumn = groupingColumns[direction === "left" ? columnIndex - 1 : columnIndex + 1];
|
|
1633
|
+
if (columnIndex < 0 || !targetColumn) {
|
|
1634
|
+
return false;
|
|
1635
|
+
}
|
|
1636
|
+
grid.moveGroupingColumn(columnId, targetColumn.id, direction === "left" ? "before" : "after");
|
|
1637
|
+
return true;
|
|
1638
|
+
}
|
|
1639
|
+
function resolveRowVirtualizationOptions(rowVirtualization) {
|
|
1640
|
+
if (rowVirtualization === true) {
|
|
1641
|
+
return {
|
|
1642
|
+
enabled: true,
|
|
1643
|
+
estimateRowHeight: 40,
|
|
1644
|
+
measureRowHeight: true,
|
|
1645
|
+
overscan: 6
|
|
1646
|
+
};
|
|
1647
|
+
}
|
|
1648
|
+
if (!rowVirtualization) {
|
|
1649
|
+
return {
|
|
1650
|
+
enabled: false,
|
|
1651
|
+
estimateRowHeight: 40,
|
|
1652
|
+
measureRowHeight: true,
|
|
1653
|
+
overscan: 6
|
|
1654
|
+
};
|
|
1655
|
+
}
|
|
1656
|
+
return {
|
|
1657
|
+
enabled: rowVirtualization.enabled ?? true,
|
|
1658
|
+
estimateRowHeight: rowVirtualization.estimateRowHeight ?? 40,
|
|
1659
|
+
measureRowHeight: rowVirtualization.measureRowHeight ?? true,
|
|
1660
|
+
overscan: rowVirtualization.overscan ?? 6
|
|
1661
|
+
};
|
|
1662
|
+
}
|
|
1663
|
+
function resolveColumnVirtualizationOptions(columnVirtualization) {
|
|
1664
|
+
if (columnVirtualization === true) {
|
|
1665
|
+
return {
|
|
1666
|
+
enabled: true,
|
|
1667
|
+
measureColumnWidth: true,
|
|
1668
|
+
overscan: 2
|
|
1669
|
+
};
|
|
1670
|
+
}
|
|
1671
|
+
if (!columnVirtualization) {
|
|
1672
|
+
return {
|
|
1673
|
+
enabled: false,
|
|
1674
|
+
measureColumnWidth: true,
|
|
1675
|
+
overscan: 2
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
return {
|
|
1679
|
+
enabled: columnVirtualization.enabled ?? true,
|
|
1680
|
+
measureColumnWidth: columnVirtualization.measureColumnWidth ?? true,
|
|
1681
|
+
overscan: columnVirtualization.overscan ?? 2
|
|
1682
|
+
};
|
|
1683
|
+
}
|
|
1684
|
+
function getScrollForFocusedCell(options) {
|
|
1685
|
+
const {
|
|
1686
|
+
focusedCell,
|
|
1687
|
+
layout,
|
|
1688
|
+
rows,
|
|
1689
|
+
currentScrollLeft,
|
|
1690
|
+
currentScrollTop,
|
|
1691
|
+
viewportWidth,
|
|
1692
|
+
viewportHeight,
|
|
1693
|
+
headerHeight,
|
|
1694
|
+
getRowSize,
|
|
1695
|
+
rowVirtualOptions,
|
|
1696
|
+
columnVirtualOptions
|
|
1697
|
+
} = options;
|
|
1698
|
+
let scrollLeft = currentScrollLeft;
|
|
1699
|
+
let scrollTop = currentScrollTop;
|
|
1700
|
+
if (columnVirtualOptions.enabled) {
|
|
1701
|
+
const columnLayout = layout.find((item) => item.id === focusedCell.columnId);
|
|
1702
|
+
if (columnLayout && columnLayout.pinned === false) {
|
|
1703
|
+
const leftPinnedWidth = layout.filter((item) => item.pinned === "left").reduce((total, item) => total + item.size, 0);
|
|
1704
|
+
const rightPinnedWidth = layout.filter((item) => item.pinned === "right").reduce((total, item) => total + item.size, 0);
|
|
1705
|
+
const visibleLeft = currentScrollLeft + leftPinnedWidth;
|
|
1706
|
+
const visibleRight = currentScrollLeft + viewportWidth - rightPinnedWidth;
|
|
1707
|
+
if (columnLayout.start < visibleLeft) {
|
|
1708
|
+
scrollLeft = Math.max(0, columnLayout.start - leftPinnedWidth);
|
|
1709
|
+
} else if (columnLayout.end > visibleRight) {
|
|
1710
|
+
scrollLeft = Math.max(0, columnLayout.end - viewportWidth + rightPinnedWidth);
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
if (rowVirtualOptions.enabled) {
|
|
1715
|
+
const rowIndex = rows.findIndex((row) => row.id === focusedCell.rowId);
|
|
1716
|
+
if (rowIndex >= 0) {
|
|
1717
|
+
const rowStart = headerHeight + getSizeOffset(rowIndex, getRowSize);
|
|
1718
|
+
const rowEnd = rowStart + getRowSize(rowIndex);
|
|
1719
|
+
const visibleTop = currentScrollTop;
|
|
1720
|
+
const visibleBottom = currentScrollTop + viewportHeight;
|
|
1721
|
+
if (rowStart < visibleTop) {
|
|
1722
|
+
scrollTop = Math.max(0, rowStart);
|
|
1723
|
+
} else if (rowEnd > visibleBottom) {
|
|
1724
|
+
scrollTop = Math.max(0, rowEnd - viewportHeight);
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
if (scrollLeft === currentScrollLeft && scrollTop === currentScrollTop) {
|
|
1729
|
+
return null;
|
|
1730
|
+
}
|
|
1731
|
+
return {
|
|
1732
|
+
scrollLeft,
|
|
1733
|
+
scrollTop
|
|
1734
|
+
};
|
|
1735
|
+
}
|
|
1736
|
+
function getVirtualRowStyle(virtualItem) {
|
|
1737
|
+
if (!virtualItem) {
|
|
1738
|
+
return void 0;
|
|
1739
|
+
}
|
|
1740
|
+
return {
|
|
1741
|
+
position: "absolute",
|
|
1742
|
+
top: 0,
|
|
1743
|
+
left: 0,
|
|
1744
|
+
right: 0,
|
|
1745
|
+
height: virtualItem.size,
|
|
1746
|
+
transform: `translateY(${virtualItem.start}px)`
|
|
1747
|
+
};
|
|
1748
|
+
}
|
|
1749
|
+
function getVirtualRowStyleText(virtualItem) {
|
|
1750
|
+
const style = getVirtualRowStyle(virtualItem);
|
|
1751
|
+
if (!style) {
|
|
1752
|
+
return void 0;
|
|
1753
|
+
}
|
|
1754
|
+
return [
|
|
1755
|
+
`position: ${style.position}`,
|
|
1756
|
+
`top: ${style.top}`,
|
|
1757
|
+
`left: ${style.left}`,
|
|
1758
|
+
`right: ${style.right}`,
|
|
1759
|
+
`height: ${style.height}px`,
|
|
1760
|
+
`transform: ${style.transform}`
|
|
1761
|
+
].join("; ");
|
|
1762
|
+
}
|
|
1763
|
+
function getVirtualBodyStyle(virtualRange) {
|
|
1764
|
+
if (!virtualRange) {
|
|
1765
|
+
return void 0;
|
|
1766
|
+
}
|
|
1767
|
+
return {
|
|
1768
|
+
height: virtualRange.totalSize
|
|
1769
|
+
};
|
|
1770
|
+
}
|
|
1771
|
+
function getVirtualBodyStyleText(virtualRange) {
|
|
1772
|
+
const style = getVirtualBodyStyle(virtualRange);
|
|
1773
|
+
if (!style) {
|
|
1774
|
+
return void 0;
|
|
1775
|
+
}
|
|
1776
|
+
return `height: ${style.height}px`;
|
|
1777
|
+
}
|
|
1778
|
+
function getInlineSizeStyle(size) {
|
|
1779
|
+
return {
|
|
1780
|
+
width: size
|
|
1781
|
+
};
|
|
1782
|
+
}
|
|
1783
|
+
function getInlineSizeStyleText(size) {
|
|
1784
|
+
return `width: ${size}px`;
|
|
1785
|
+
}
|
|
1786
|
+
function getVirtualizedInlineSizeStyle(size, enabled) {
|
|
1787
|
+
if (!enabled) {
|
|
1788
|
+
return void 0;
|
|
1789
|
+
}
|
|
1790
|
+
return {
|
|
1791
|
+
width: size,
|
|
1792
|
+
minWidth: size
|
|
1793
|
+
};
|
|
1794
|
+
}
|
|
1795
|
+
function getVirtualizedInlineSizeStyleText(size, enabled) {
|
|
1796
|
+
const style = getVirtualizedInlineSizeStyle(size, enabled);
|
|
1797
|
+
if (!style) {
|
|
1798
|
+
return void 0;
|
|
1799
|
+
}
|
|
1800
|
+
return `width: ${style.width}px; min-width: ${style.minWidth}px`;
|
|
1801
|
+
}
|
|
1802
|
+
function getPinnedColumnOffsetStyle(layout) {
|
|
1803
|
+
if (layout?.pinned === "left") {
|
|
1804
|
+
return {
|
|
1805
|
+
position: "sticky",
|
|
1806
|
+
left: layout.pinnedStart ?? 0
|
|
1807
|
+
};
|
|
1808
|
+
}
|
|
1809
|
+
if (layout?.pinned === "right") {
|
|
1810
|
+
return {
|
|
1811
|
+
position: "sticky",
|
|
1812
|
+
right: layout.pinnedStart ?? 0
|
|
1813
|
+
};
|
|
1814
|
+
}
|
|
1815
|
+
return void 0;
|
|
1816
|
+
}
|
|
1817
|
+
function getPinnedColumnOffsetStyleText(layout) {
|
|
1818
|
+
const style = getPinnedColumnOffsetStyle(layout);
|
|
1819
|
+
if (!style) {
|
|
1820
|
+
return void 0;
|
|
1821
|
+
}
|
|
1822
|
+
if ("left" in style) {
|
|
1823
|
+
return `position: sticky; left: ${style.left}px`;
|
|
1824
|
+
}
|
|
1825
|
+
return `position: sticky; right: ${style.right}px`;
|
|
1826
|
+
}
|
|
1827
|
+
function isCellCoordinateEqual(left, right) {
|
|
1828
|
+
return !!left && !!right && left.rowId === right.rowId && left.columnId === right.columnId;
|
|
1829
|
+
}
|
|
1830
|
+
function isFocusedCell(focusedCell, rowId, columnId) {
|
|
1831
|
+
return isCellCoordinateEqual(focusedCell, { rowId, columnId });
|
|
1832
|
+
}
|
|
1833
|
+
export {
|
|
1834
|
+
DEFAULT_PAGINATION_PAGE_SIZE_OPTIONS,
|
|
1835
|
+
GRID_DENSITIES,
|
|
1836
|
+
GRID_FOCUSED_CELL_SELECTOR,
|
|
1837
|
+
GRID_INTERACTIVE_KEYBOARD_TARGET_SELECTOR,
|
|
1838
|
+
GRID_PREFERENCES_VERSION,
|
|
1839
|
+
GROUPING_PANEL_EMPTY_MESSAGE,
|
|
1840
|
+
HEADER_ACTION_MENU_ENABLED_ITEM_SELECTOR,
|
|
1841
|
+
HEADER_ACTION_MENU_TRIGGER_TEXT,
|
|
1842
|
+
addPassiveScrollListener,
|
|
1843
|
+
addPointerMoveUpCancelListeners,
|
|
1844
|
+
addPointerMoveUpListeners,
|
|
1845
|
+
addPointerUpCancelListeners,
|
|
1846
|
+
applyResizeObserverMeasuredSizes,
|
|
1847
|
+
createClickSuppressionController,
|
|
1848
|
+
createGridPreferences,
|
|
1849
|
+
createResizeObserver,
|
|
1850
|
+
disconnectResizeObserver,
|
|
1851
|
+
downloadBrowserExportFile,
|
|
1852
|
+
escapeGridHtml,
|
|
1853
|
+
focusCellEditorElement,
|
|
1854
|
+
focusElement,
|
|
1855
|
+
focusElementById,
|
|
1856
|
+
focusFocusedCellInGrid,
|
|
1857
|
+
focusHeaderActionMenuItem,
|
|
1858
|
+
focusHeaderActionMenuItemById,
|
|
1859
|
+
focusHeaderActionMenuTrigger,
|
|
1860
|
+
focusHeaderActionMenuTriggerById,
|
|
1861
|
+
getBrowserGridPreferencesStorage,
|
|
1862
|
+
getCanApplyColumnResize,
|
|
1863
|
+
getCanCancelCellEdit,
|
|
1864
|
+
getCanContinuePointerDrag,
|
|
1865
|
+
getCanEndPointerDrag,
|
|
1866
|
+
getCanRestoreFocusedCell,
|
|
1867
|
+
getCanRunGridKeyboardShortcut,
|
|
1868
|
+
getCanStartCellEdit,
|
|
1869
|
+
getCanStartCellPointerDrag,
|
|
1870
|
+
getCanStartColumnResize,
|
|
1871
|
+
getCanStartFocusedCellEdit,
|
|
1872
|
+
getCanToggleRowSelection,
|
|
1873
|
+
getCellDisplayText,
|
|
1874
|
+
getCellEditText,
|
|
1875
|
+
getCellEditValidationMessage,
|
|
1876
|
+
getCellEditorEventValue,
|
|
1877
|
+
getCellEditorKeyboardAction,
|
|
1878
|
+
getCellEditorOptionProps,
|
|
1879
|
+
getCellEditorOptionText,
|
|
1880
|
+
getCellEditorProps,
|
|
1881
|
+
getCellEditorTargetValue,
|
|
1882
|
+
getCellFillHandleProps,
|
|
1883
|
+
getCellFillHandleVisible,
|
|
1884
|
+
getCellLayoutProps,
|
|
1885
|
+
getCellProps,
|
|
1886
|
+
getCellValidationMessageProps,
|
|
1887
|
+
getColumnById,
|
|
1888
|
+
getColumnFilterCellProps,
|
|
1889
|
+
getColumnFilterInputProps,
|
|
1890
|
+
getColumnFilterText,
|
|
1891
|
+
getColumnHeaderText,
|
|
1892
|
+
getColumnIndexById,
|
|
1893
|
+
getColumnLayoutById,
|
|
1894
|
+
getColumnLayoutTotalWidth,
|
|
1895
|
+
getColumnPinningButtonProps,
|
|
1896
|
+
getColumnPinningButtonText,
|
|
1897
|
+
getColumnPinningControlsProps,
|
|
1898
|
+
getColumnResizeFinalSize,
|
|
1899
|
+
getColumnResizeHandleProps,
|
|
1900
|
+
getColumnResizeKeyboardSize,
|
|
1901
|
+
getColumnResizePointerSize,
|
|
1902
|
+
getColumnResizeStartSize,
|
|
1903
|
+
getColumnSpacerProps,
|
|
1904
|
+
getColumnVisibilityCheckboxProps,
|
|
1905
|
+
getColumnVisibilityControlsProps,
|
|
1906
|
+
getColumnVisibilityEmptyText,
|
|
1907
|
+
getColumnVisibilityListProps,
|
|
1908
|
+
getColumnVisibilityResetButtonProps,
|
|
1909
|
+
getColumnVisibilityResetButtonText,
|
|
1910
|
+
getColumnVisibilitySearchInputProps,
|
|
1911
|
+
getColumnVisibilityStatusProps,
|
|
1912
|
+
getColumnVisibilityStatusText,
|
|
1913
|
+
getColumnVisibilitySummaryProps,
|
|
1914
|
+
getColumnVisibilitySummaryText,
|
|
1915
|
+
getDefaultBrowserDownloadEnvironment,
|
|
1916
|
+
getDefaultClipboardTextEnvironment,
|
|
1917
|
+
getDefaultPointerMoveUpCancelListenerTarget,
|
|
1918
|
+
getDefaultPointerMoveUpListenerTarget,
|
|
1919
|
+
getDefaultPointerUpCancelListenerTarget,
|
|
1920
|
+
getDensityButtonProps,
|
|
1921
|
+
getDensityButtonText,
|
|
1922
|
+
getDensityControlsProps,
|
|
1923
|
+
getElementOffsetBlockSize,
|
|
1924
|
+
getEnabledHeaderActionMenuItems,
|
|
1925
|
+
getFilteredColumnVisibilityColumns,
|
|
1926
|
+
getFocusedCellScrollOptionsFromElement,
|
|
1927
|
+
getFocusedRowSelectionTarget,
|
|
1928
|
+
getGridBodyProps,
|
|
1929
|
+
getGridBodyRowIndexOffset,
|
|
1930
|
+
getGridDensityProps,
|
|
1931
|
+
getGridDensityRowHeight,
|
|
1932
|
+
getGridEmptyCellProps,
|
|
1933
|
+
getGridEmptyRowProps,
|
|
1934
|
+
getGridErrorOverlayProps,
|
|
1935
|
+
getGridErrorRetryButtonProps,
|
|
1936
|
+
getGridErrorRetryButtonText,
|
|
1937
|
+
getGridErrorText,
|
|
1938
|
+
getGridHeaderProps,
|
|
1939
|
+
getGridHeaderRowCount,
|
|
1940
|
+
getGridHeaderRowProps,
|
|
1941
|
+
getGridKeyboardEditAction,
|
|
1942
|
+
getGridKeyboardFocusMove,
|
|
1943
|
+
getGridKeyboardShortcutAction,
|
|
1944
|
+
getGridLoadingOverlayProps,
|
|
1945
|
+
getGridLoadingText,
|
|
1946
|
+
getGridProps,
|
|
1947
|
+
getGroupCellIndent,
|
|
1948
|
+
getGroupCellIndentStyle,
|
|
1949
|
+
getGroupCellIndentStyleText,
|
|
1950
|
+
getGroupRowCountText,
|
|
1951
|
+
getGroupRowLabel,
|
|
1952
|
+
getGroupValueText,
|
|
1953
|
+
getGroupingPanelChipProps,
|
|
1954
|
+
getGroupingPanelMoveButtonProps,
|
|
1955
|
+
getGroupingPanelPlaceholderProps,
|
|
1956
|
+
getGroupingPanelProps,
|
|
1957
|
+
getGroupingPanelRemoveButtonProps,
|
|
1958
|
+
getHeaderActionMenuActiveElement,
|
|
1959
|
+
getHeaderActionMenuCustomItemProps,
|
|
1960
|
+
getHeaderActionMenuCustomItemUserProps,
|
|
1961
|
+
getHeaderActionMenuDefaultItemDescriptors,
|
|
1962
|
+
getHeaderActionMenuDefaultItemLabel,
|
|
1963
|
+
getHeaderActionMenuFocusTarget,
|
|
1964
|
+
getHeaderActionMenuId,
|
|
1965
|
+
getHeaderActionMenuItemProps,
|
|
1966
|
+
getHeaderActionMenuKeyboardAction,
|
|
1967
|
+
getHeaderActionMenuLabelProps,
|
|
1968
|
+
getHeaderActionMenuProps,
|
|
1969
|
+
getHeaderActionMenuSeparatorProps,
|
|
1970
|
+
getHeaderActionMenuTriggerFocusPosition,
|
|
1971
|
+
getHeaderActionMenuTriggerId,
|
|
1972
|
+
getHeaderActionMenuTriggerProps,
|
|
1973
|
+
getHeaderButtonProps,
|
|
1974
|
+
getHeaderCellLayoutProps,
|
|
1975
|
+
getHeaderCellProps,
|
|
1976
|
+
getHeaderDragEndAction,
|
|
1977
|
+
getHeaderKeyboardMoveDirection,
|
|
1978
|
+
getHeaderPlaceholderCellProps,
|
|
1979
|
+
getHeaderSortIndicatorProps,
|
|
1980
|
+
getHeaderSortIndicatorText,
|
|
1981
|
+
getInlineSizeStyle,
|
|
1982
|
+
getInlineSizeStyleText,
|
|
1983
|
+
getIsGroupLabelCell,
|
|
1984
|
+
getMeasuredElementBlockSize,
|
|
1985
|
+
getMeasuredElementBlockSizeFromRect,
|
|
1986
|
+
getMeasuredElementBlockSizeFromTarget,
|
|
1987
|
+
getMeasuredElementInlineSize,
|
|
1988
|
+
getNextColumnFilters,
|
|
1989
|
+
getPaginationButtonProps,
|
|
1990
|
+
getPaginationButtonText,
|
|
1991
|
+
getPaginationPageSizeOptionText,
|
|
1992
|
+
getPaginationPageSizeOptions,
|
|
1993
|
+
getPaginationPageSizeSelectProps,
|
|
1994
|
+
getPaginationPageText,
|
|
1995
|
+
getPaginationProps,
|
|
1996
|
+
getPaginationStatusProps,
|
|
1997
|
+
getPinnedColumnOffsetStyle,
|
|
1998
|
+
getPinnedColumnOffsetStyleText,
|
|
1999
|
+
getPointerCaptureTarget,
|
|
2000
|
+
getQuickFilterClearButtonProps,
|
|
2001
|
+
getQuickFilterClearButtonText,
|
|
2002
|
+
getQuickFilterInputProps,
|
|
2003
|
+
getQuickFilterProps,
|
|
2004
|
+
getResizeObserverEntryBlockSize,
|
|
2005
|
+
getResizeObserverEntryDatasetId,
|
|
2006
|
+
getResizeObserverEntryInlineSize,
|
|
2007
|
+
getRowById,
|
|
2008
|
+
getRowExpansionSpacerProps,
|
|
2009
|
+
getRowExpansionToggleProps,
|
|
2010
|
+
getRowExpansionToggleText,
|
|
2011
|
+
getRowLayoutProps,
|
|
2012
|
+
getRowProps,
|
|
2013
|
+
getRowSelectionCheckboxProps,
|
|
2014
|
+
getRowSelectionCheckboxText,
|
|
2015
|
+
getRowSelectionClearButtonProps,
|
|
2016
|
+
getRowSelectionClearButtonText,
|
|
2017
|
+
getRowSelectionControlsProps,
|
|
2018
|
+
getRowSelectionStatusProps,
|
|
2019
|
+
getRowSelectionStatusText,
|
|
2020
|
+
getScrollForFocusedCell,
|
|
2021
|
+
getScrollFrameOptionsFromElement,
|
|
2022
|
+
getShouldCancelFocusedCellRestoreOnFrameSync,
|
|
2023
|
+
getShouldPreventEventDefault,
|
|
2024
|
+
getSizeOffset,
|
|
2025
|
+
getVirtualBodyStyle,
|
|
2026
|
+
getVirtualBodyStyleText,
|
|
2027
|
+
getVirtualRowStyle,
|
|
2028
|
+
getVirtualRowStyleText,
|
|
2029
|
+
getVirtualizedInlineSizeStyle,
|
|
2030
|
+
getVirtualizedInlineSizeStyleText,
|
|
2031
|
+
hasPointerMovedPastDragThreshold,
|
|
2032
|
+
isCellCoordinateEqual,
|
|
2033
|
+
isFocusableElement,
|
|
2034
|
+
isFocusedCell,
|
|
2035
|
+
isGridInteractiveKeyboardEventTarget,
|
|
2036
|
+
isGridInteractiveKeyboardTarget,
|
|
2037
|
+
isHeaderActionMenuActionItem,
|
|
2038
|
+
isHeaderActionMenuCloseAction,
|
|
2039
|
+
isHeaderActionMenuCustomItem,
|
|
2040
|
+
isHeaderActionMenuFocusAction,
|
|
2041
|
+
isHeaderActionMenuFocusTarget,
|
|
2042
|
+
isHeaderActionMenuItem,
|
|
2043
|
+
isHeaderActionMenuLabelItem,
|
|
2044
|
+
isHeaderActionMenuSeparatorItem,
|
|
2045
|
+
isHeaderActionMenuTabCloseAction,
|
|
2046
|
+
isHeaderDragGroupAction,
|
|
2047
|
+
isHeaderDragMoveAction,
|
|
2048
|
+
isMeasuredBlockElement,
|
|
2049
|
+
isMeasuredBlockRectElement,
|
|
2050
|
+
isMeasuredBlockRectElementTarget,
|
|
2051
|
+
isMeasuredInlineDatasetElementTarget,
|
|
2052
|
+
isMeasuredInlineElement,
|
|
2053
|
+
isPointerCaptureTarget,
|
|
2054
|
+
isPointerInsideElement,
|
|
2055
|
+
isPrimaryPointerButton,
|
|
2056
|
+
isPrimaryPointerDragActive,
|
|
2057
|
+
isResizeObserverDatasetTarget,
|
|
2058
|
+
moveColumnToTarget,
|
|
2059
|
+
moveGroupedColumn,
|
|
2060
|
+
moveVisibleColumn,
|
|
2061
|
+
normalizeGridDensity,
|
|
2062
|
+
observeElements,
|
|
2063
|
+
parseCellEditValue,
|
|
2064
|
+
parseGridPreferences,
|
|
2065
|
+
preventDefaultAndStopPropagation,
|
|
2066
|
+
preventEventDefault,
|
|
2067
|
+
readClipboardText,
|
|
2068
|
+
readGridPreferences,
|
|
2069
|
+
removeGridPreferences,
|
|
2070
|
+
removeObservedElement,
|
|
2071
|
+
replaceObservedElement,
|
|
2072
|
+
resolveColumnVirtualizationOptions,
|
|
2073
|
+
resolveRowVirtualizationOptions,
|
|
2074
|
+
scrollElementToPosition,
|
|
2075
|
+
serializeGridPreferences,
|
|
2076
|
+
setCheckboxIndeterminate,
|
|
2077
|
+
setElementDatasetId,
|
|
2078
|
+
stopEventPropagation,
|
|
2079
|
+
tryReleasePointerCapture,
|
|
2080
|
+
trySetPointerCapture,
|
|
2081
|
+
updatePointerDragDidMovePastThreshold,
|
|
2082
|
+
writeClipboardText,
|
|
2083
|
+
writeGridPreferences
|
|
2084
|
+
};
|