@ornery/ui-grid-vanilla 1.0.7 → 5.0.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.
Files changed (79) hide show
  1. package/README.md +1 -1
  2. package/dist/adopt-styles.d.ts +2 -0
  3. package/dist/adopt-styles.d.ts.map +1 -0
  4. package/dist/attribute-bridge.d.ts +39 -0
  5. package/dist/attribute-bridge.d.ts.map +1 -0
  6. package/dist/browser/ui-grid-element.js +4 -4
  7. package/dist/browser.d.ts +3 -0
  8. package/dist/browser.d.ts.map +1 -0
  9. package/dist/components/grid-body-cell/grid-body-cell.d.ts +19 -0
  10. package/dist/components/grid-body-cell/grid-body-cell.d.ts.map +1 -0
  11. package/dist/components/grid-body-cell/index.d.ts +2 -0
  12. package/dist/components/grid-body-cell/index.d.ts.map +1 -0
  13. package/dist/components/grid-cell-editor/grid-cell-editor.d.ts +28 -0
  14. package/dist/components/grid-cell-editor/grid-cell-editor.d.ts.map +1 -0
  15. package/dist/components/grid-cell-editor/index.d.ts +2 -0
  16. package/dist/components/grid-cell-editor/index.d.ts.map +1 -0
  17. package/dist/components/grid-filter-cell/grid-filter-cell.d.ts +32 -0
  18. package/dist/components/grid-filter-cell/grid-filter-cell.d.ts.map +1 -0
  19. package/dist/components/grid-filter-cell/grid-filter-cell.template.d.ts +8 -0
  20. package/dist/components/grid-filter-cell/grid-filter-cell.template.d.ts.map +1 -0
  21. package/dist/components/grid-filter-cell/index.d.ts +2 -0
  22. package/dist/components/grid-filter-cell/index.d.ts.map +1 -0
  23. package/dist/components/grid-group-row/grid-group-row.d.ts +55 -0
  24. package/dist/components/grid-group-row/grid-group-row.d.ts.map +1 -0
  25. package/dist/components/grid-group-row/grid-group-row.template.d.ts +12 -0
  26. package/dist/components/grid-group-row/grid-group-row.template.d.ts.map +1 -0
  27. package/dist/components/grid-group-row/index.d.ts +2 -0
  28. package/dist/components/grid-group-row/index.d.ts.map +1 -0
  29. package/dist/components/grid-header-cell/grid-header-cell.d.ts +13 -0
  30. package/dist/components/grid-header-cell/grid-header-cell.d.ts.map +1 -0
  31. package/dist/components/grid-header-cell/index.d.ts +2 -0
  32. package/dist/components/grid-header-cell/index.d.ts.map +1 -0
  33. package/dist/components/grid-pagination/grid-pagination.d.ts +45 -0
  34. package/dist/components/grid-pagination/grid-pagination.d.ts.map +1 -0
  35. package/dist/components/grid-pagination/grid-pagination.template.d.ts +17 -0
  36. package/dist/components/grid-pagination/grid-pagination.template.d.ts.map +1 -0
  37. package/dist/components/grid-pagination/index.d.ts +2 -0
  38. package/dist/components/grid-pagination/index.d.ts.map +1 -0
  39. package/dist/components/grid-template/grid-template.d.ts +31 -0
  40. package/dist/components/grid-template/grid-template.d.ts.map +1 -0
  41. package/dist/components/grid-template/index.d.ts +2 -0
  42. package/dist/components/grid-template/index.d.ts.map +1 -0
  43. package/dist/events.d.ts +43 -0
  44. package/dist/events.d.ts.map +1 -0
  45. package/dist/focus.d.ts +100 -0
  46. package/dist/focus.d.ts.map +1 -0
  47. package/dist/framework-slots.d.ts +170 -0
  48. package/dist/framework-slots.d.ts.map +1 -0
  49. package/dist/grid-controller.d.ts +363 -0
  50. package/dist/grid-controller.d.ts.map +1 -0
  51. package/dist/icons.d.ts +34 -0
  52. package/dist/icons.d.ts.map +1 -0
  53. package/dist/index.d.ts +11 -902
  54. package/dist/index.d.ts.map +1 -0
  55. package/dist/index.js +4 -4
  56. package/dist/index.mjs +4 -4
  57. package/dist/patch.d.ts +88 -0
  58. package/dist/patch.d.ts.map +1 -0
  59. package/dist/render.d.ts +62 -0
  60. package/dist/render.d.ts.map +1 -0
  61. package/dist/templates/index.d.ts +24 -0
  62. package/dist/templates/index.d.ts.map +1 -0
  63. package/dist/ui-grid-empty.template.d.ts +8 -0
  64. package/dist/ui-grid-empty.template.d.ts.map +1 -0
  65. package/dist/ui-grid-shell.template.d.ts +17 -0
  66. package/dist/ui-grid-shell.template.d.ts.map +1 -0
  67. package/dist/ui-grid-standalone.element.d.ts +309 -0
  68. package/dist/ui-grid-standalone.element.d.ts.map +1 -0
  69. package/dist/utils/cell-class.d.ts +9 -0
  70. package/dist/utils/cell-class.d.ts.map +1 -0
  71. package/dist/utils/display-items.d.ts +11 -0
  72. package/dist/utils/display-items.d.ts.map +1 -0
  73. package/dist/utils/dom.d.ts +22 -0
  74. package/dist/utils/dom.d.ts.map +1 -0
  75. package/package.json +13 -10
  76. package/tsconfig.dts.json +15 -0
  77. package/tsconfig.json +0 -1
  78. package/tsup.config.ts +1 -1
  79. package/dist/index.d.mts +0 -904
package/dist/index.d.mts DELETED
@@ -1,904 +0,0 @@
1
- import { GridCellTemplateContext, GridLabels, GridExpandableTemplateContext, GridColumnDef, GridHeaderTemplateContext, GridRow, GroupItem, GridOptions, PipelineResult, SortState, PinnedColumnState, GridCellPosition, UiGridApi, GridRecord, DisplayItem, SortDirection, PinDirection, GridSelectionState, resolveGridSelectionOptions, GridBenchmarkResult, GridInfiniteScrollState, GridValidatorRegistry } from '@ornery/ui-grid-core';
2
- export { GridOptions, UiGridApi } from '@ornery/ui-grid-core';
3
-
4
- /**
5
- * Framework-rendered slot bridge for the vanilla grid element.
6
- *
7
- * The vanilla grid renders every cell / header / filter / group / expandable
8
- * / empty-state via string-interpolated templates by default. When a
9
- * framework wrapper (Angular, React, or any other consumer) wants to own
10
- * rendering of a slot with its own templating engine, it calls
11
- * `setFrameworkRenderedSlots()` on the element to flip slot kinds into
12
- * "slot placeholder" mode.
13
- *
14
- * In that mode the element emits `<slot name="…">` placeholders at the
15
- * usual render sites. The wrapper listens for the `*SlotsChanged` event
16
- * this module dispatches and inserts light-DOM nodes with matching `slot`
17
- * attributes carrying its framework-rendered content. Slot projection then
18
- * composes the wrapper's view back into the shadow tree without the
19
- * wrapper ever touching the shadow DOM directly.
20
- *
21
- * Slot naming conventions:
22
- * - `cell-<columnName>-<rowId>` per-cell (one slot per rendered body cell)
23
- * - `header-<columnName>` per-column, singleton
24
- * - `filter-<columnName>` per-column, singleton
25
- * - `group-row-<groupId>` per-group
26
- * - `expandable-row-<rowId>` per-row
27
- * - `empty` singleton
28
- */
29
-
30
- /** Which slot kinds the element should render as `<slot>` placeholders. */
31
- interface FrameworkRenderedSlotsConfig {
32
- /** Column names whose body cells are framework-rendered. Everything else
33
- * continues to use the vanilla interpolation path. */
34
- cells?: readonly string[];
35
- /** Column names whose header cells are framework-rendered. */
36
- headers?: readonly string[];
37
- /** Column names whose filter cells are framework-rendered. */
38
- filters?: readonly string[];
39
- /** When true, group rows are emitted as slot placeholders. */
40
- groupRow?: boolean;
41
- /** When true, expandable detail rows are emitted as slot placeholders. */
42
- expandableRow?: boolean;
43
- /** When true, the empty-state panel is emitted as a slot placeholder. */
44
- emptyState?: boolean;
45
- }
46
- interface FrameworkCellSlot {
47
- slotName: string;
48
- columnName: string;
49
- rowId: string;
50
- rowIndex: number;
51
- context: GridCellTemplateContext;
52
- }
53
- interface FrameworkHeaderSlot {
54
- slotName: string;
55
- columnName: string;
56
- context: GridHeaderTemplateContext;
57
- }
58
- interface FrameworkFilterSlot {
59
- slotName: string;
60
- columnName: string;
61
- value: string;
62
- placeholder: string;
63
- disabled: boolean;
64
- column: GridColumnDef;
65
- }
66
- interface FrameworkGroupRowSlot {
67
- slotName: string;
68
- groupId: string;
69
- field: string;
70
- label: string;
71
- count: number;
72
- depth: number;
73
- collapsed: boolean;
74
- }
75
- interface FrameworkExpandableRowSlot {
76
- slotName: string;
77
- rowId: string;
78
- rowIndex: number;
79
- context: GridExpandableTemplateContext;
80
- }
81
- interface FrameworkEmptyStateSlot {
82
- slotName: 'empty';
83
- heading: string;
84
- description: string;
85
- labels: GridLabels;
86
- }
87
- interface FrameworkSlotDelta<TSlot> {
88
- added: TSlot[];
89
- removed: TSlot[];
90
- }
91
- /**
92
- * Bridge state + behavior. The element creates one instance, reads the
93
- * `has*` methods during render to decide which path to take, calls the
94
- * `stage*` methods as it emits slot placeholders, and calls `flush()` at
95
- * the end of each render pass to emit the add/remove delta.
96
- */
97
- declare class FrameworkSlotBridge {
98
- private readonly host;
99
- private flaggedCells;
100
- private flaggedHeaders;
101
- private flaggedFilters;
102
- private flaggedGroupRow;
103
- private flaggedExpandableRow;
104
- private flaggedEmptyState;
105
- private lastCellSlots;
106
- private lastExpandableRowSlots;
107
- private lastGroupRowSlots;
108
- private lastHeaderSlots;
109
- private lastFilterSlots;
110
- private lastEmptyStateSlot;
111
- private pendingCellSlots;
112
- private pendingExpandableRowSlots;
113
- private pendingGroupRowSlots;
114
- private pendingHeaderSlots;
115
- private pendingFilterSlots;
116
- private pendingEmptyStateSlot;
117
- constructor(host: EventTarget);
118
- /**
119
- * Apply a slots config. Returns true when the structural set changed (and
120
- * therefore a re-render is required), false when the config is a no-op.
121
- */
122
- configure(config: FrameworkRenderedSlotsConfig): boolean;
123
- hasCell(columnName: string): boolean;
124
- hasHeader(columnName: string): boolean;
125
- hasFilter(columnName: string): boolean;
126
- hasGroupRow(): boolean;
127
- hasExpandableRow(): boolean;
128
- hasEmptyState(): boolean;
129
- stageCell(column: GridColumnDef, row: GridRow, rowIndex: number): void;
130
- /**
131
- * Carry forward every previously-known cell slot for `rowId` into the
132
- * current pending set. Used by the structural patch path when a row's
133
- * fingerprint matches the previous render's: `stageCell` would normally
134
- * re-record the slot during cell rendering, but the fingerprint
135
- * short-circuit skips the render pass for unchanged rows. Without this,
136
- * `flush()` would diff pending (missing the row's slots) against last
137
- * (containing them) and emit a spurious `removed` for every cell of the
138
- * unchanged row, destroying the framework wrappers' projected content.
139
- */
140
- carryRowCells(rowId: string): void;
141
- stageExpandableRow(row: GridRow, rowIndex: number): void;
142
- stageGroupRow(group: GroupItem): void;
143
- stageHeader(column: GridColumnDef): void;
144
- stageFilter(column: GridColumnDef, value: string, placeholder: string, disabled: boolean): void;
145
- stageEmptyState(heading: string, description: string, labels: GridLabels): void;
146
- /**
147
- * Diff pending vs. last, dispatch `*SlotsChanged` events for every kind
148
- * that moved, then swap last = pending and reset pending. Called at the
149
- * end of every render pass.
150
- */
151
- flush(): void;
152
- /**
153
- * Data-only patch variant: merge pending entries into last without firing
154
- * events, since the slot structure hasn't changed (only cell contexts
155
- * refreshed). Wrappers that need context updates subscribe to
156
- * `rowsVisibleChanged`.
157
- */
158
- mergePendingIntoLast(): void;
159
- /**
160
- * On element teardown, emit `removed` for every remaining slot so wrappers
161
- * can destroy their views.
162
- */
163
- flushRemovals(): void;
164
- private diffAndEmit;
165
- private diffAndEmitSingleton;
166
- }
167
-
168
- /**
169
- * Icon registry for the vanilla grid element.
170
- *
171
- * The grid draws its own sort / group / tree / expand / pin / pagination
172
- * icons via inline SVGs. Consumers can override any individual icon by
173
- * passing an `iconOverrides` map in GridOptions or by writing to the
174
- * element's `controlIcons` property at runtime. This module owns the
175
- * icon registry class plus the SVG markup helpers so the element file
176
- * doesn't have to.
177
- */
178
- type UiGridControlIconKey = 'sortNone' | 'sortAsc' | 'sortDesc' | 'group' | 'groupExpanded' | 'groupCollapsed' | 'treeExpanded' | 'treeCollapsed' | 'expandExpanded' | 'expandCollapsed' | 'pin' | 'pinLeft' | 'pinRight' | 'paginationPrev' | 'paginationNext';
179
- interface UiGridIconDefinition {
180
- viewBox?: string;
181
- path: string;
182
- }
183
- type UiGridIconOverrides = Partial<Record<UiGridControlIconKey, UiGridIconDefinition>>;
184
- /**
185
- * Holds the active set of icons (defaults merged with consumer overrides)
186
- * and renders the inline SVG markup for each one. A single instance lives
187
- * on the element.
188
- */
189
- declare class IconRegistry {
190
- private overrides;
191
- private resolved;
192
- getOverrides(): UiGridIconOverrides;
193
- setOverrides(value: UiGridIconOverrides): void;
194
- resolve(key: UiGridControlIconKey): UiGridIconDefinition;
195
- /** Render the SVG markup for a control icon (sort, group, pin, …). */
196
- renderControlIcon(key: UiGridControlIconKey): string;
197
- /** Render the SVG markup with an arbitrary wrapper class. */
198
- renderIconWithClass(svgClass: string, key: UiGridControlIconKey): string;
199
- }
200
-
201
- /**
202
- * Complete grid save state — parity with the old `ui.grid.saveState`
203
- * module. Every field is optional so partial saves / restores work too.
204
- *
205
- * Opt-in/out behaviour mirrors the old module: by default save() serialises
206
- * everything; consumers can disable per-field capture via
207
- * `saveSort`/`saveFilter`/... options on `GridOptions`. Restore tolerates
208
- * missing fields.
209
- */
210
- interface GridSaveState {
211
- sortState?: SortState;
212
- activeFilters?: Record<string, string>;
213
- groupByColumns?: string[];
214
- collapsedGroups?: Record<string, boolean>;
215
- pinnedColumns?: PinnedColumnState;
216
- columnOrder?: string[];
217
- columnWidthOverrides?: Record<string, string>;
218
- currentPage?: number;
219
- pageSize?: number;
220
- selectedRowIds?: string[];
221
- focusedCell?: GridCellPosition | null;
222
- expandedRows?: Record<string, boolean>;
223
- expandedTreeRows?: Record<string, boolean>;
224
- scrollTop?: number;
225
- scrollLeft?: number;
226
- }
227
- interface GridControllerSnapshot {
228
- options: GridOptions;
229
- labels: GridLabels;
230
- rowSize: number;
231
- visibleColumns: GridColumnDef[];
232
- gridTemplateColumns: string;
233
- pipeline: PipelineResult;
234
- activeFilters: Record<string, string>;
235
- sortState: SortState;
236
- groupByColumns: string[];
237
- pinnedColumns: PinnedColumnState;
238
- currentPage: number;
239
- totalPages: number;
240
- firstRowIndex: number;
241
- lastRowIndex: number;
242
- pageSize: number;
243
- editingCell: GridCellPosition | null;
244
- editingValue: string;
245
- /** Row ids currently selected. A ReadonlySet for surgical DOM updates —
246
- * the renderer toggles the .ui-grid-row-selected class on every cell
247
- * whose data-row matches one of these ids. */
248
- selectedRowIds: ReadonlySet<string>;
249
- selectAll: boolean;
250
- focusedRowId: string | null;
251
- selectedCount: number;
252
- }
253
- type GridControllerSubscriber = (snapshot: GridControllerSnapshot) => void;
254
- declare class VanillaGridController {
255
- private options;
256
- private activeFilters;
257
- private sortState;
258
- private groupByColumns;
259
- private lastOptionsGroupBy;
260
- private lastOptionsPinnedState;
261
- private lastOptionsInfiniteScrollUp;
262
- private lastOptionsInfiniteScrollDown;
263
- private collapsedGroups;
264
- private hiddenRowReasons;
265
- private expandedRows;
266
- private expandedTreeRows;
267
- private pinnedColumns;
268
- private columnOrder;
269
- private columnWidthOverrides;
270
- private viewportWidth;
271
- private currentPage;
272
- private pageSize;
273
- private editingCell;
274
- private editingValue;
275
- private exporterOverrides;
276
- private validatorRegistry;
277
- private rowEditState;
278
- private rowEditTimers;
279
- private rowEditSavePromiseOverrides;
280
- private selectionState;
281
- /** cellNav state. Persists the last focused cell so the public API's
282
- * getFocusedCell returns the right value across re-renders, and tracks
283
- * the focused-cells history for getCurrentSelection. */
284
- private cellNavLastRowCol;
285
- private cellNavFocusedCells;
286
- /** Infinite-scroll state. Direction flags seed from options; dataLoading
287
- * + previousVisibleRows are runtime bookkeeping for saveScrollPercentage /
288
- * dataRemovedTop / dataRemovedBottom. */
289
- private infiniteScrollState;
290
- private pipeline;
291
- private labels;
292
- private visibleColumns;
293
- private apiRegistered;
294
- private disposed;
295
- private wasmEngineInitRequested;
296
- private readonly subscribers;
297
- readonly gridApi: UiGridApi;
298
- constructor(options: GridOptions);
299
- /** Disposer for the i18n language-change listener — cleared when the
300
- * controller is torn down (matches the pattern used for other global
301
- * subscriptions). */
302
- private disposeLanguageListener;
303
- dispose(): void;
304
- setOptions(options: GridOptions): void;
305
- /**
306
- * Fast-path: swap only the row data and rebuild the pipeline without
307
- * touching column state. Emits the new snapshot. The element uses this to
308
- * patch cell content in-place without rebuilding the full shadow DOM.
309
- */
310
- refreshData(data: readonly GridRecord[]): void;
311
- subscribe(subscriber: GridControllerSubscriber): () => void;
312
- getSnapshot(): GridControllerSnapshot;
313
- getDisplayItems(): DisplayItem[];
314
- setCollapsedGroup(groupId: string, collapsed: boolean): void;
315
- toggleSort(columnName: string): void;
316
- sortColumn(columnName: string, direction?: SortDirection): void;
317
- setFilter(columnName: string, value: string): void;
318
- clearAllFilters(): void;
319
- toggleGrouping(columnName: string): void;
320
- clearGrouping(): void;
321
- seekPage(page: number): void;
322
- setPageSize(pageSize: number): void;
323
- pinColumn(columnName: string, direction: PinDirection): void;
324
- moveVisibleColumn(columnName: string, targetColumnName: string): void;
325
- toggleRowExpansion(row: GridRow | GridRecord | string): void;
326
- expandAllRows(): void;
327
- collapseAllRows(): void;
328
- toggleTreeRow(row: GridRow | GridRecord | string): void;
329
- expandAllTreeRows(): void;
330
- collapseAllTreeRows(): void;
331
- setTreeRowExpanded(row: GridRow | GridRecord | string, expanded: boolean): void;
332
- beginCellEdit(row: GridRow | GridRecord | string, columnName: string, triggerEvent?: Event | KeyboardEvent | null, initialValue?: string): void;
333
- updateEditingValue(value: string): void;
334
- commitCellEdit(): void;
335
- cancelCellEdit(): void;
336
- /** Internal: run a core selection mutation, raise events, trigger a render. */
337
- private applySelectionChange;
338
- private allGridRows;
339
- toggleRowSelectionByEntity(rowEntity: GridRecord, evt?: Event | null): void;
340
- selectRow(rowEntity: GridRecord, evt?: Event | null): void;
341
- selectRowByVisibleIndex(rowNum: number, evt?: Event | null): void;
342
- selectRowByKey(isInEntity: boolean, key: string, comparator: unknown, evt?: Event | null, lookInRows?: readonly GridRow[]): void;
343
- unSelectRow(rowEntity: GridRecord, evt?: Event | null): void;
344
- unSelectRowByVisibleIndex(rowNum: number, evt?: Event | null): void;
345
- unSelectRowByKey(isInEntity: boolean, key: string, comparator: unknown, evt?: Event | null, lookInRows?: readonly GridRow[]): void;
346
- selectAllRows(evt?: Event | null): void;
347
- selectAllVisibleRows(evt?: Event | null): void;
348
- clearSelectedRows(evt?: Event | null): void;
349
- shiftSelectRow(rowEntity: GridRecord, evt?: Event | null): void;
350
- getSelectedRows(): GridRecord[];
351
- getUnSelectedRows(): GridRecord[];
352
- getSelectedGridRows(): GridRow[];
353
- getUnSelectedGridRows(): GridRow[];
354
- setMultiSelect(multiSelect: boolean): void;
355
- setModifierKeysToMultiSelect(value: boolean): void;
356
- /** Focus a row by id — the old module's `row.setFocused(true)` with all
357
- * the book-keeping. Raises rowFocusChanged and refreshes. */
358
- setRowFocused(rowId: string, focused: boolean, evt?: Event | null): void;
359
- getRowSelectionState(): Readonly<GridSelectionState>;
360
- /** Resolved/defaulted selection options — exposed for the element layer
361
- * so it can decide whether to wire pointer handlers without duplicating
362
- * default logic. */
363
- getResolvedSelectionOptions(): ReturnType<typeof resolveGridSelectionOptions>;
364
- /** Public analogue of findRowById — the element uses this during drag
365
- * painting to resolve a row-id back to its entity without calling the
366
- * selection API methods that would double-raise events. */
367
- findRowByIdPublic(rowId: string): GridRow | null;
368
- /** Record a navigation event. Pushes to the focused-cells history,
369
- * updates lastRowCol, and raises cellNav.navigate on the public API. */
370
- setCellNavFocus(rowId: string | null, columnName: string | null, opts?: {
371
- appendToSelection?: boolean;
372
- }): void;
373
- /** Raise viewPortKeyDown / viewPortKeyPress on behalf of the element.
374
- * Element gates this with `options.keyDownOverrides`. */
375
- raiseCellNavKeyEvent(type: 'keydown' | 'keypress', event: KeyboardEvent): void;
376
- private cellNavGetFocusedCell;
377
- private cellNavGetCurrentSelection;
378
- private cellNavRowColSelectIndex;
379
- private resolveCellNavRowCol;
380
- /** cellNav.scrollToFocus — resolves rowEntity + colDef into a logical
381
- * focus and delegates to the element (if attached) for actual scrolling.
382
- * When the element isn't wired (e.g. bare controller in tests), the
383
- * state still updates and the promise resolves immediately. */
384
- private cellNavScrollToFocus;
385
- /** Element registers its scroll-and-focus handler here so the API
386
- * binding above can delegate DOM work. Controller stays DOM-free. */
387
- private cellNavScrollRequest;
388
- setCellNavScrollHandler(handler: ((rowId: string | null, columnName: string | null) => void) | null): void;
389
- /** Read-only accessor for the current options. Used by the element to
390
- * inspect keyDownOverrides / modifierKeysToMultiSelectCells without
391
- * coupling it to a private field. */
392
- getOptions(): GridOptions;
393
- /** Evaluate whether the current scroll position should request more
394
- * data at the top or bottom. Called from the element's scroll frame. */
395
- evaluateInfiniteScroll(startIndex: number, visibleRows: number, viewportRows: number): void;
396
- private infiniteScrollDataLoaded;
397
- private infiniteScrollResetScroll;
398
- private infiniteScrollSavePercentage;
399
- private infiniteScrollDataRemovedTop;
400
- private infiniteScrollDataRemovedBottom;
401
- private infiniteScrollSetDirections;
402
- /** Element registers a scroll-to-top handler here so resetScroll can
403
- * bring the viewport back to 0. Keeps the controller DOM-free. */
404
- private infiniteScrollScrollToTopRequest;
405
- setInfiniteScrollResetHandler(handler: (() => void) | null): void;
406
- /** Element-owned render benchmark. When present, `core.benchmark()`
407
- * measures the actual render path instead of the controller-only
408
- * pipeline builder. */
409
- private benchmarkRequest;
410
- setBenchmarkHandler(handler: ((iterations?: number) => Promise<GridBenchmarkResult>) | null): void;
411
- getInfiniteScrollState(): Readonly<GridInfiniteScrollState>;
412
- canResizeColumns(): boolean;
413
- setViewportWidth(width: number): void;
414
- getViewportWidth(): number;
415
- setColumnWidthOverride(columnName: string, widthPx: number): void;
416
- /** Returns the grid-template-columns string as if `columnName` had the given width,
417
- * without triggering a full refresh. Used for smooth drag-resize DOM updates. */
418
- buildTemplateColumnsWithOverride(columnName: string, widthPx: number): string;
419
- isGroupingEnabled(): boolean;
420
- isSortingEnabled(): boolean;
421
- isFilteringEnabled(): boolean;
422
- isPaginationEnabled(): boolean;
423
- shouldShowPaginationControls(): boolean;
424
- isTreeEnabled(): boolean;
425
- isExpandableEnabled(): boolean;
426
- isColumnSortable(column: GridColumnDef): boolean;
427
- isColumnFilterable(column: GridColumnDef): boolean;
428
- isColumnGrouped(column: GridColumnDef): boolean;
429
- sortButtonLabel(column: GridColumnDef): string;
430
- groupingButtonLabel(column: GridColumnDef): string;
431
- filterPlaceholder(column: GridColumnDef): string;
432
- getSortDirection(column: GridColumnDef): SortDirection;
433
- isPinningEnabled(): boolean;
434
- isColumnPinnable(column: GridColumnDef): boolean;
435
- /** True when the given column is editable in principle — does NOT evaluate
436
- * a per-row `cellEditableCondition`. Use isCellEditable for that. */
437
- isColumnEditable(column: GridColumnDef): boolean;
438
- /** True when the (row, column) cell is editable, respecting both the
439
- * column's `enableCellEdit` flag and any `cellEditableCondition`. */
440
- isCellEditable(row: GridRow, column: GridColumnDef): boolean;
441
- isPinned(column: GridColumnDef): boolean;
442
- isPinnedLeftLast(column: GridColumnDef): boolean;
443
- isPinnedRightFirst(column: GridColumnDef): boolean;
444
- groupDisclosureLabel(group: GroupItem): string;
445
- pinnedOffset(column: GridColumnDef): {
446
- side: 'left' | 'right';
447
- offset: string;
448
- } | null;
449
- displayValue(row: GridRow, column: GridColumnDef): unknown;
450
- headerLabel(column: GridColumnDef): string;
451
- cellIndent(row: GridRow, column: GridColumnDef): string;
452
- showTreeToggle(row: GridRow, column: GridColumnDef): boolean;
453
- showExpandToggle(_row: GridRow, column: GridColumnDef): boolean;
454
- isTreeRowExpanded(row: GridRow): boolean;
455
- treeToggleLabel(row: GridRow): string;
456
- expandToggleLabel(row: GridRow): string;
457
- editorInputType(column: GridColumnDef): string;
458
- isEditingCell(rowId: string, columnName: string): boolean;
459
- /** Compact key for the editing cell, or null when no edit is in flight.
460
- * Used by the patch path to detect when the editing position moves so it
461
- * can force the affected cells through the slow rebuild path. */
462
- getEditingCellKey(): string | null;
463
- /**
464
- * Serialise the current grid state. Mirrors `ui.grid.saveState.save`:
465
- * every field is gated by an `options.save*` flag with the old grid's
466
- * defaults. A missing flag keeps the matching field out of the result.
467
- */
468
- getState(): GridSaveState;
469
- /**
470
- * Apply a previously saved state. All fields are optional — missing
471
- * fields are left at whatever the controller currently has. Matches the
472
- * old grid's `ui.grid.saveState.restore`.
473
- */
474
- setState(state: Partial<GridSaveState>): void;
475
- /** Element injects its scroll accessor so save() can capture scrollTop/
476
- * scrollLeft. Controller stays DOM-free. */
477
- private saveStateScrollSnapshot;
478
- private saveStateScrollRestore;
479
- setSaveStateScrollHandlers(snapshot: (() => {
480
- scrollTop: number;
481
- scrollLeft: number;
482
- }) | null, restore: ((scrollTop: number, scrollLeft: number) => void) | null): void;
483
- private refresh;
484
- private maybeEnableWasmEngine;
485
- private emit;
486
- private findRowById;
487
- private buildRowsFromData;
488
- private findColumnByName;
489
- private resolveRowId;
490
- private getRowSize;
491
- private getTotalPages;
492
- private getEffectivePageSize;
493
- private getCurrentPage;
494
- private getFirstRowIndex;
495
- private getLastRowIndex;
496
- private setRowInvisible;
497
- private clearRowInvisible;
498
- private benchmark;
499
- /** Returns the rows that match the requested exporter row-type. Mirrors
500
- * the old grid's row selection logic: `all` uses the full data set (or
501
- * `exporterAllDataFn` when provided), `visible` uses the current pipeline
502
- * output, `selected` uses the selection state. */
503
- private exporterRowsFor;
504
- private resolveExporterOptions;
505
- private buildCsv;
506
- private exportCsv;
507
- private buildPdfDocDefinition;
508
- private exportPdf;
509
- private buildExcelSheetData;
510
- private exportExcel;
511
- /** Runs the validators declared on `colDef.validators` against the new
512
- * value and flips `$$invalid<col>` / `$$errors<col>` on the entity. On
513
- * failure raises `validate.validationFailed`. Async validators are
514
- * awaited so the caller can `await` for complete results. */
515
- private validateRunValidators;
516
- private validateGetFormattedErrors;
517
- private validateGetTitleFormattedErrors;
518
- private validateGetInvalidRows;
519
- /** Test hook — exposes the validator registry so consumers can inspect or
520
- * extend it outside of the gridApi surface (e.g. from a controller-level
521
- * plugin). */
522
- getValidatorRegistry(): GridValidatorRegistry;
523
- /** Set by the element so `importAFile()` can trigger its file-picker flow.
524
- * Controller stays DOM-free: it just invokes whatever handler was wired. */
525
- private importerFilePickerRequest;
526
- setImporterFilePickerHandler(handler: (() => void) | null): void;
527
- private resolveImporterOptions;
528
- private importerRequestFile;
529
- private importerDispatchObjects;
530
- private importerImportText;
531
- private importerImportThisFile;
532
- private buildExporterMenuItems;
533
- /** Menu items the importer contributes. Just the single "Import"
534
- * entry when the feature is enabled; returns an empty array otherwise. */
535
- private buildImporterMenuItems;
536
- /** Menu items row-edit contributes: "Save changes" + "Retry errored
537
- * rows". Each entry is gated by both a gridOption flag and a runtime
538
- * predicate (`hasDirtyRows` / `hasErrorRows`) so the menu only surfaces
539
- * actions that have something to do. */
540
- private buildRowEditMenuItems;
541
- private rowEditSetSavePromise;
542
- private rowEditGetDirtyRows;
543
- private rowEditGetErrorRows;
544
- private rowEditFlushDirtyRows;
545
- /** Re-fires `saveRow` for every row currently in the error state. The
546
- * "Retry errored rows" menu entry funnels through here. Returns a
547
- * promise that resolves once every retry promise has settled. */
548
- private rowEditRetryErroredRows;
549
- private rowEditSetRowsDirty;
550
- private rowEditSetRowsClean;
551
- private considerSetRowEditTimer;
552
- private cancelRowEditTimer;
553
- private runRowEditSave;
554
- /** Test hook — reports the current row-edit dirty / error / saving state. */
555
- getRowEditState(): {
556
- dirtyRowIds: string[];
557
- errorRowIds: string[];
558
- savingRowIds: string[];
559
- };
560
- }
561
- declare function createVanillaGridController(options: GridOptions): VanillaGridController;
562
-
563
- type VanillaUiGridElement = HTMLElement & {
564
- options: GridOptions;
565
- getState(): GridSaveState | null;
566
- setState(state: Partial<GridSaveState>): void;
567
- /**
568
- * Fast-path data update: patches only visible cell content in the existing
569
- * shadow DOM. Does NOT rebuild the scroll container or header, so scrolling
570
- * remains completely smooth while data ticks in the background.
571
- */
572
- setData(rows: GridRecord[]): void;
573
- /**
574
- * Declare which slots the grid should emit as `<slot>` placeholders for a
575
- * framework wrapper to project into. See `FrameworkSlotBridge` for the
576
- * full contract.
577
- */
578
- setFrameworkRenderedSlots(config: FrameworkRenderedSlotsConfig): void;
579
- };
580
- type VanillaGridOptions = GridOptions & {
581
- iconOverrides?: UiGridIconOverrides;
582
- };
583
- declare class UiGridStandaloneElement extends HTMLElement {
584
- /** @internal */ controller: VanillaGridController | null;
585
- /** @internal */ snapshot: GridControllerSnapshot | null;
586
- /** @internal */ unsubscribe: (() => void) | null;
587
- /** @internal */ activeOptions: VanillaGridOptions | null;
588
- /** @internal */ attributeOptions: Partial<GridOptions>;
589
- /** @internal */ attributeSyncScheduled: boolean;
590
- /** @internal Owns the SVG-icon registry: defaults merged with consumer
591
- * overrides plus rendering helpers. See `./icons.ts`. */
592
- icons: IconRegistry;
593
- /** @internal */ templateObserver: MutationObserver | null;
594
- /** @internal */ openPinMenuColumn: string | null;
595
- /** @internal */ focusedCell: {
596
- rowId: string;
597
- columnName: string;
598
- } | null;
599
- /** @internal */ draggedColumnName: string | null;
600
- /** @internal */ dropTargetColumnName: string | null;
601
- /** @internal */ scrollPosition: number;
602
- /** @internal */ horizontalScrollPosition: number;
603
- /** @internal */ scrollFrame: number | null;
604
- /** @internal */ suppressScrollEvent: boolean;
605
- /** @internal */ lastVirtualStartIndex: number;
606
- /** @internal */ measuredHeaderStickyHeight: number;
607
- /** @internal */ measuredFilterStickyHeight: number;
608
- /** @internal */ stickyHeightRelayoutQueued: boolean;
609
- /** @internal */ benchmarkAverage: string;
610
- /** @internal */ skipNextRender: boolean;
611
- /** @internal */ autoResizeObserver: ResizeObserver | null;
612
- /** @internal */ autoResizeDebounceHandle: number | null;
613
- gridTitle: string;
614
- gridTableStyle: string;
615
- bodyViewportStyle: string;
616
- templateColumns: string;
617
- slotRegistry: string;
618
- headerContent: string;
619
- filterRowContent: string;
620
- bodyContent: string;
621
- paginationContent: string;
622
- /** @internal */ dataFrame: number | null;
623
- /** @internal */ pendingPatchedRowIds: Set<string> | null;
624
- /** @internal */ pendingDataRefreshMode: 'patch' | 'virtual' | 'full' | null;
625
- /** @internal */ lastScrollActivityAt: number;
626
- /** @internal */ lastStructureKey: string | null;
627
- /** @internal */ lastItemsFingerprint: string | null;
628
- /** @internal */ lastVirtualOffset: number;
629
- /** @internal */ lastTotalVirtualHeight: number;
630
- /**
631
- * @internal Per-row visual-state fingerprint from the previous patch pass.
632
- * The patch path uses this to skip cells whose row state hasn't changed
633
- * (selection, expand, dirty/saving/error flags) when the structure
634
- * fingerprint matches. Cleared on full re-render.
635
- */
636
- lastRowStateFingerprints: Map<string, {
637
- fingerprint: string;
638
- entity: unknown;
639
- }>;
640
- /** @internal */ lastEditingCellKey: string | null;
641
- /** @internal */ lastFocusedCellKey: string | null;
642
- /**
643
- * @internal Framework-rendered slot bridge. See `./framework-slots.ts`.
644
- */
645
- frameworkSlots: FrameworkSlotBridge;
646
- static get observedAttributes(): string[];
647
- get options(): GridOptions;
648
- set options(value: GridOptions);
649
- /**
650
- * Declare which slots are framework-rendered. When a slot is flagged, the
651
- * element renders a `<slot name="…">` placeholder at the usual site instead
652
- * of running its string-interpolation template, and dispatches
653
- * `*SlotsChanged` events so a wrapper can insert light-DOM content with a
654
- * matching `slot` attribute.
655
- *
656
- * Pass an empty object (or `{}`) to revert every slot kind back to the
657
- * default interpolation path. Individual fields behave the same way:
658
- * omitting `cells` means the cells list is unchanged; passing
659
- * `cells: []` clears it.
660
- *
661
- * This is the bridge the Angular / React wrappers use to project native
662
- * templates (ng-template, JSX render props) into the grid. Consumers of
663
- * the web component directly can ignore this method — the default
664
- * `<template slot="cell-columnName">` workflow still works.
665
- */
666
- setFrameworkRenderedSlots(config: FrameworkRenderedSlotsConfig): void;
667
- attributeChangedCallback(_name: string, _oldValue: string | null, _newValue: string | null): void;
668
- private syncAttributesToOptions;
669
- get controlIcons(): UiGridIconOverrides;
670
- set controlIcons(value: UiGridIconOverrides);
671
- private resolveIcon;
672
- get gridId(): string;
673
- set gridId(value: string);
674
- get title(): string;
675
- set title(value: string);
676
- get rowHeight(): number;
677
- set rowHeight(value: number);
678
- get headerRowHeight(): number;
679
- set headerRowHeight(value: number);
680
- get paginationPageSize(): number;
681
- set paginationPageSize(value: number);
682
- get paginationCurrentPage(): number;
683
- set paginationCurrentPage(value: number);
684
- get totalItems(): number | undefined;
685
- set totalItems(value: number | undefined);
686
- get virtualizationThreshold(): number;
687
- set virtualizationThreshold(value: number);
688
- get treeChildrenField(): string;
689
- set treeChildrenField(value: string);
690
- get treeIndent(): number;
691
- set treeIndent(value: number);
692
- get expandableRowHeight(): number;
693
- set expandableRowHeight(value: number);
694
- get expandableRowHeaderWidth(): number;
695
- set expandableRowHeaderWidth(value: number);
696
- get emptyMessage(): string;
697
- set emptyMessage(value: string);
698
- get infiniteScrollRowsFromEnd(): number;
699
- set infiniteScrollRowsFromEnd(value: number);
700
- get columnDefs(): readonly GridColumnDef[];
701
- set columnDefs(value: readonly GridColumnDef[]);
702
- get data(): readonly GridRecord[];
703
- set data(value: readonly GridRecord[]);
704
- get enableSorting(): boolean;
705
- set enableSorting(value: boolean);
706
- get enableFiltering(): boolean;
707
- set enableFiltering(value: boolean);
708
- get enableGrouping(): boolean;
709
- set enableGrouping(value: boolean);
710
- get enablePinning(): boolean;
711
- set enablePinning(value: boolean);
712
- get enableColumnMoving(): boolean;
713
- set enableColumnMoving(value: boolean);
714
- get enableColumnResizing(): boolean;
715
- set enableColumnResizing(value: boolean);
716
- get enableCellEdit(): boolean;
717
- set enableCellEdit(value: boolean);
718
- get enableCellEditOnFocus(): boolean;
719
- set enableCellEditOnFocus(value: boolean);
720
- get enablePagination(): boolean;
721
- set enablePagination(value: boolean);
722
- get enablePaginationControls(): boolean;
723
- set enablePaginationControls(value: boolean);
724
- get useExternalPagination(): boolean;
725
- set useExternalPagination(value: boolean);
726
- get enableExpandable(): boolean;
727
- set enableExpandable(value: boolean);
728
- get enableTreeView(): boolean;
729
- set enableTreeView(value: boolean);
730
- get showTreeExpandNoChildren(): boolean;
731
- set showTreeExpandNoChildren(value: boolean);
732
- get treeRowHeaderAlwaysVisible(): boolean;
733
- set treeRowHeaderAlwaysVisible(value: boolean);
734
- get enableAutoResize(): boolean;
735
- set enableAutoResize(value: boolean);
736
- get enableVirtualization(): boolean;
737
- set enableVirtualization(value: boolean);
738
- get infiniteScrollUp(): boolean;
739
- set infiniteScrollUp(value: boolean);
740
- get infiniteScrollDown(): boolean;
741
- set infiniteScrollDown(value: boolean);
742
- get grouping(): unknown;
743
- set grouping(value: unknown);
744
- get paginationPageSizes(): number[] | null | undefined;
745
- set paginationPageSizes(value: number[] | null | undefined);
746
- getState(): GridSaveState | null;
747
- setState(state: Partial<GridSaveState>): void;
748
- /**
749
- * Fast-path: update only row data without rebuilding the shadow DOM.
750
- * The pipeline is updated synchronously; DOM patching is deferred to the
751
- * next animation frame so it never interrupts an in-progress scroll paint.
752
- * If multiple ticks arrive before the frame fires, only the latest wins.
753
- * If a scroll-triggered full render fires first, the frame is cancelled
754
- * (the fresh innerHTML already reflects the latest data).
755
- */
756
- setData(rows: GridRecord[]): void;
757
- private flushPendingDataRefresh;
758
- private patchCells;
759
- connectedCallback(): void;
760
- disconnectedCallback(): void;
761
- private benchmarkRender;
762
- /** @internal */
763
- ensureShadowRoot(): ShadowRoot;
764
- /** @internal */
765
- ensureController(options: VanillaGridOptions): void;
766
- /** Hidden file input used by `gridApi.importer.importAFile()`. Lazily
767
- * created on first use and reused thereafter. */
768
- private importerFileInput;
769
- private openImporterFilePicker;
770
- private observeTemplateSlots;
771
- private bindEvents;
772
- private syncHeaderHorizontalScroll;
773
- private maybeTriggerInfiniteScroll;
774
- /** @internal */
775
- buildEffectiveOptions(options: VanillaGridOptions): VanillaGridOptions;
776
- /**
777
- * Ask the controller to evaluate whether the current scroll position
778
- * should request more data at the top or bottom — ports the old grid's
779
- * handleScroll → loadData check. The controller does the actual
780
- * needLoadMoreData / needLoadMoreDataTop raise.
781
- */
782
- /**
783
- * Mirror horizontal scroll from the body viewport onto the header + filter
784
- * strips by setting `scrollLeft` on them. Because those strips are real
785
- * scroll containers (with their scrollbars hidden), `position: sticky` on
786
- * pinned header / filter cells anchors to the strip's scroll position the
787
- * same way body cells anchor to `.grid-body-viewport`. This is the
788
- * imperative sync strategy the old ui-grid used in ui-grid-viewport.js.
789
- */
790
- /**
791
- * Targeted update for virtual scroll: replaces only the rendered rows inside
792
- * the existing `.grid-virtual-body` without touching the scroll container.
793
- * This preserves momentum/inertia scrolling because the `.grid-table` element
794
- * is never destroyed.
795
- */
796
- /** @internal */
797
- renderVirtualBody(): void;
798
- /** @internal */
799
- render(): void;
800
- /** @internal */
801
- private inAutoAdjust;
802
- private lastAutoHeight;
803
- private autoAdjustHeight;
804
- measuredPaginationHeight(): number;
805
- /** @internal */
806
- setupAutoResize(): void;
807
- /** @internal */
808
- teardownAutoResize(): void;
809
- private buildRenderPlan;
810
- private renderFull;
811
- private renderPatch;
812
- private reconcileBodyRoot;
813
- private reconcilePagination;
814
- private patchFilterCells;
815
- private fingerprintItems;
816
- private patchExistingRows;
817
- private patchGroupRow;
818
- private patchBodyCell;
819
- private patchPagination;
820
- private renderHeaderCell;
821
- private renderFilterCell;
822
- /**
823
- * Commit the in-flight edit, then move keyboard focus relative to the
824
- * committed cell. Splits commit + focus across two paint frames: commit
825
- * runs synchronously (editor unmounts, cell re-renders with the new value),
826
- * then focus moves to the adjacent cell. Scheduling the focus in a
827
- * microtask avoids racing the blur handler's re-entry guard and ensures
828
- * the destination cell is fully reattached in the DOM.
829
- *
830
- * If the source cell was being edited, the destination cell enters edit
831
- * mode too (provided the destination column is editable). This keeps
832
- * Tab/Enter nav inside an edit session continuous — you keep editing as
833
- * you move. Arrow nav outside an edit session does NOT auto-enter edit.
834
- */
835
- private commitAndMove;
836
- private moveGridFocus;
837
- private scrollFocusedRowIntoView;
838
- private handleRowSelectionClick;
839
- private handleRowHeaderCheckboxClick;
840
- private matchesKeyOverride;
841
- private applyFocusedCellClass;
842
- private focusCellElement;
843
- private measureAutoColumnWidth;
844
- private renderDisplayItem;
845
- private renderBodyCell;
846
- private renderPagination;
847
- private renderSlotRegistry;
848
- private renderCellTemplate;
849
- private renderCellTemplateFromMarkup;
850
- private renderExpandableTemplate;
851
- private getTemplateMarkup;
852
- /** @internal Used by the render module to interpolate consumer templates. */
853
- interpolateTemplate(templateMarkup: string, context: Record<string, unknown>): string;
854
- private rowIndexFor;
855
- private classifyDataRefresh;
856
- private getRenderedDisplayWindow;
857
- private cellSlotName;
858
- private renderEmptyState;
859
- /** @internal */
860
- downloadCsv(rowType?: 'all' | 'visible' | 'selected', colType?: 'all' | 'visible'): void;
861
- private renderControlIcon;
862
- private renderIconWithClass;
863
- }
864
- declare function defineStandaloneUiGridElement(tagName?: string): Promise<void>;
865
-
866
- /**
867
- * A declarative template element for defining reusable cell/row templates
868
- * without writing JavaScript.
869
- *
870
- * Supports both `${this.prop}` and `{{prop}}` binding syntax.
871
- *
872
- * @example
873
- * ```html
874
- * <template is="ui-grid-template" name="ui-status-badge" status="unknown">
875
- * <style>
876
- * :host { display: inline-block; }
877
- * .badge { padding: 2px 8px; border-radius: 4px; font-size: 0.8em; }
878
- * .badge-active { background: #d1fae5; color: #065f46; }
879
- * .badge-inactive { background: #fee2e2; color: #991b1b; }
880
- * </style>
881
- * <span class="badge badge-${this.status}">${this.status}</span>
882
- * </template>
883
- *
884
- * <ui-grid-element>
885
- * <template slot="cell-status">
886
- * <ui-status-badge status="{{value}}"></ui-status-badge>
887
- * </template>
888
- * </ui-grid-element>
889
- * ```
890
- */
891
- declare class UIGridTemplate extends HTMLTemplateElement {
892
- static readonly TAG = "ui-grid-template";
893
- connectedCallback(): void;
894
- static define(tagName?: string): void;
895
- }
896
-
897
- interface UiGridRustWebModule {
898
- default(input?: unknown): Promise<unknown>;
899
- }
900
-
901
- declare function registerVanillaUiGridRustModule(module: UiGridRustWebModule, input?: unknown): Promise<void>;
902
- declare function mountVanillaUiGrid(target: Element, options: GridOptions, rustModule?: UiGridRustWebModule, tagName?: string): Promise<VanillaUiGridElement>;
903
-
904
- export { type FrameworkCellSlot, type FrameworkEmptyStateSlot, type FrameworkExpandableRowSlot, type FrameworkFilterSlot, type FrameworkGroupRowSlot, type FrameworkHeaderSlot, type FrameworkRenderedSlotsConfig, type FrameworkSlotDelta, type GridControllerSnapshot, type GridSaveState, UIGridTemplate, type UiGridControlIconKey, type UiGridIconDefinition, type UiGridIconOverrides, type UiGridRustWebModule, UiGridStandaloneElement, VanillaGridController, type VanillaUiGridElement, createVanillaGridController, defineStandaloneUiGridElement, defineStandaloneUiGridElement as defineUiGridElement, mountVanillaUiGrid, registerVanillaUiGridRustModule };