@ember-lattice/ember 0.0.0-stage → 1.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 (34) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE.md +21 -0
  3. package/NOTICE +30 -0
  4. package/README.md +139 -2
  5. package/addon-main.cjs +4 -0
  6. package/declarations/board/lattice-board.d.ts +122 -0
  7. package/declarations/board/lattice-board.d.ts.map +1 -0
  8. package/declarations/grid/alignment.d.ts +30 -0
  9. package/declarations/grid/alignment.d.ts.map +1 -0
  10. package/declarations/grid/auto-columns.d.ts +22 -0
  11. package/declarations/grid/auto-columns.d.ts.map +1 -0
  12. package/declarations/grid/cell-state.d.ts +17 -0
  13. package/declarations/grid/cell-state.d.ts.map +1 -0
  14. package/declarations/grid/clipboard.d.ts +7 -0
  15. package/declarations/grid/clipboard.d.ts.map +1 -0
  16. package/declarations/grid/keyboard.d.ts +24 -0
  17. package/declarations/grid/keyboard.d.ts.map +1 -0
  18. package/declarations/grid/lattice-grid.d.ts +741 -0
  19. package/declarations/grid/lattice-grid.d.ts.map +1 -0
  20. package/declarations/grid/row-number.d.ts +24 -0
  21. package/declarations/grid/row-number.d.ts.map +1 -0
  22. package/declarations/grid/selection.d.ts +24 -0
  23. package/declarations/grid/selection.d.ts.map +1 -0
  24. package/declarations/grid/state-host.d.ts +52 -0
  25. package/declarations/grid/state-host.d.ts.map +1 -0
  26. package/declarations/grid/types.d.ts +376 -0
  27. package/declarations/grid/types.d.ts.map +1 -0
  28. package/declarations/index.d.ts +19 -0
  29. package/declarations/index.d.ts.map +1 -0
  30. package/declarations/list/lattice-list.d.ts +184 -0
  31. package/declarations/list/lattice-list.d.ts.map +1 -0
  32. package/dist/index.js +4031 -0
  33. package/dist/index.js.map +1 -0
  34. package/package.json +92 -3
@@ -0,0 +1,741 @@
1
+ import Component from '@glimmer/component';
2
+ import type { SafeString } from '@ember/template';
3
+ import { ScaledScroll, VirtualizerState } from '@ember-lattice/virtual';
4
+ import type { ComponentLike } from '@glint/template';
5
+ import { CellStateStore } from './cell-state.ts';
6
+ import { GridStateHandle } from './state-host.ts';
7
+ import { GridAlignment } from './alignment.ts';
8
+ import type { AlignedColumns, AlignedGrid } from './alignment.ts';
9
+ import type { LatticeLocale, LatticeLocaleTextOverride } from '@ember-lattice/core';
10
+ import type { GridHostState, GridStateTarget } from './state-host.ts';
11
+ import type { CellPosition } from './keyboard.ts';
12
+ import type { GridContextMenuApi, GridContextTarget, GridEditCell, GridColumn, GridEditing, GridEditTrigger, GridFind, GridGroupInfo, GridHeader, GridNotes, GridRange, GridRow, GridRowEditorField, GridRowComponentSignature, GridRowDrop, GridRowModel, GridRowMove, GridTable, LatticeCellSignature, LatticeHeaderLabelSignature, GridHeaderApi, LatticeColumnMeta, LatticeHeaderSignature, PinSide } from './types.ts';
13
+ export interface LatticeGridSignature {
14
+ Element: HTMLDivElement;
15
+ Args: {
16
+ /** A table from `@ember-lattice/core` `constructTable`. */
17
+ table: GridTable;
18
+ /** The accessible name of the grid. */
19
+ label: string;
20
+ /**
21
+ * The fixed row height in px. Default: the computed `--lt-row-height`. `'auto'`: each row
22
+ * has the measured height of its content.
23
+ */
24
+ rowHeight?: number | 'auto';
25
+ /** True for a row that renders one cell across all columns, with `@fullWidthRow`. */
26
+ isFullWidthRow?: (row: GridRow) => boolean;
27
+ /** The component of a full-width row. */
28
+ fullWidthRow?: ComponentLike<GridRowComponentSignature>;
29
+ /** Master/detail: each row gets a toggle that shows this component in a row under it. */
30
+ detailRow?: ComponentLike<GridRowComponentSignature>;
31
+ /** The rows that have a detail row. Default: all rows. */
32
+ hasDetail?: (row: GridRow) => boolean;
33
+ /** True while the rows load: the loading overlay shows and the grid is `aria-busy`. */
34
+ loading?: boolean;
35
+ /** Row drag: a drag handle (`meta.lattice.rowDrag`) or Alt+arrows move a row in this grid. */
36
+ onRowMove?: (move: GridRowMove) => void;
37
+ /** A row of another grid is dropped on this grid. */
38
+ onRowDrop?: (drop: GridRowDrop) => void;
39
+ /** The number of rows outside the view on each side. Default: 4. */
40
+ overscan?: number;
41
+ /** The ID of a row. Default: the table row ID. */
42
+ getRowId?: (row: GridRow) => string;
43
+ /** Called on Enter or a double click on a data cell that does not open an editor. */
44
+ onCellActivate?: (target: {
45
+ row: GridRow;
46
+ column: GridColumn;
47
+ }) => void;
48
+ /** A row model from `@ember-lattice/data`. Default: the rows of the table. */
49
+ rowModel?: GridRowModel;
50
+ /**
51
+ * The handle that saves and restores the scroll offset and the active cell, from
52
+ * `LatticeGrid.stateHost()`. Give the same handle to `persistGridState` as `host`.
53
+ */
54
+ stateHost?: GridStateHandle;
55
+ /** The editing plug-in: an `EditController` from `@ember-lattice/editing`. */
56
+ editing?: GridEditing;
57
+ /**
58
+ * The pointer action that opens a cell editor: `singleClick`, `doubleClick` or `none` (only the
59
+ * keys). A column `meta.lattice.editTrigger` wins. Default: `doubleClick`.
60
+ */
61
+ editTrigger?: GridEditTrigger;
62
+ /** True: when the focus leaves the editor for a place outside it, the edit saves. Default: false. */
63
+ stopEditingWhenCellsLoseFocus?: boolean;
64
+ /** The density preset on `.lt-grid` (`data-lt-density`). Default: `normal`. */
65
+ density?: 'compact' | 'normal' | 'comfortable';
66
+ /** The find hook: each cell gets `data-find-match` from `matchAt(rowId, columnId)`. */
67
+ find?: GridFind;
68
+ /** A floating filter for each column: the grid adds a header row with one for each column. */
69
+ floatingFilter?: ComponentLike<LatticeHeaderSignature>;
70
+ /** Called on a right click, Shift+F10 or the ContextMenu key on a body cell. */
71
+ onCellContextMenu?: (target: GridContextTarget) => void;
72
+ /** The external filter: client rows (not pinned rows) that give false do not show. */
73
+ externalFilter?: (row: GridRow) => boolean;
74
+ /** The notes hook: a cell with a note has a mark, and hover or focus shows the note. */
75
+ notes?: GridNotes;
76
+ /** The alignment of this grid with other grids (`LatticeGrid.alignment()`). */
77
+ aligned?: GridAlignment;
78
+ /** The locale of the column type formats (`meta.columnType`) and of the numbers in the text. Default: the owner locale. */
79
+ locale?: string;
80
+ /** Locale text that replaces the owner text and the English defaults for this grid (ADR 0024). */
81
+ localeText?: LatticeLocaleTextOverride;
82
+ };
83
+ Blocks: {
84
+ /** The side bar, at the inline end of `div.lt-grid-root`, outside `role=grid`. */
85
+ sideBar: [];
86
+ /** A context menu, in `.lt-overlay`. It gets the request target and the grid actions. */
87
+ contextMenu: [GridContextMenuApi];
88
+ };
89
+ }
90
+ /**
91
+ * One leaf column in a row. The list has all columns in their order, so a change of the column
92
+ * range never moves a cell element: it only adds or removes cells (focus stays on the cell).
93
+ */
94
+ interface ColumnSlot {
95
+ key: string;
96
+ column: GridColumn;
97
+ /** False for a center column outside the range: it has no element. */
98
+ rendered: boolean;
99
+ /** A spacer before the cell, for the center columns before it that are not rendered. */
100
+ gap: SafeString | null;
101
+ /** The 1-based `aria-colindex`. */
102
+ aria: number;
103
+ pin: PinSide;
104
+ size: number;
105
+ style: SafeString;
106
+ component: ComponentLike<LatticeCellSignature> | null;
107
+ full: boolean;
108
+ /** The header slot component (`meta.lattice.header`). */
109
+ headerSlot: ComponentLike<LatticeHeaderSignature> | null;
110
+ /** The component in place of the header label text (`meta.lattice.headerLabel`). */
111
+ headerLabel: ComponentLike<LatticeHeaderLabelSignature> | null;
112
+ /** The row number column: the cell shows the display position. */
113
+ rowNumber: boolean;
114
+ /** The cell has a row drag handle. */
115
+ rowDrag: boolean;
116
+ /** `meta.lattice.cellDescription` and `cellInvalid`. */
117
+ describe: LatticeColumnMeta['cellDescription'] | null;
118
+ invalid: LatticeColumnMeta['cellInvalid'] | null;
119
+ }
120
+ /** The cells of a row and the spacer after the center range when no column is end-pinned. */
121
+ interface RowLayout {
122
+ slots: ColumnSlot[];
123
+ tail: SafeString | null;
124
+ }
125
+ /** A header cell in a group row. */
126
+ interface GroupSlot {
127
+ key: string;
128
+ header: GridHeader;
129
+ label: string;
130
+ aria: number;
131
+ colSpan: number;
132
+ pin: PinSide;
133
+ style: SafeString;
134
+ }
135
+ /** A data row in a slot or in the held layer. */
136
+ interface RowView {
137
+ row: GridRow;
138
+ id: string;
139
+ /** The 0-based index in the row model. */
140
+ index: number;
141
+ /** True for the active row: it stays rendered also outside the range. */
142
+ held: boolean;
143
+ style: SafeString;
144
+ /** The 1-based `aria-level` in a treegrid. */
145
+ level: number | undefined;
146
+ group: GridGroupInfo | undefined;
147
+ /** `aria-expanded`: a group row or a tree row with sub rows. */
148
+ expanded: 'true' | 'false' | undefined;
149
+ /** True for a tree row with sub rows: its first cell has a toggle before the value. */
150
+ treeToggle: boolean;
151
+ /** True for an open group or tree row: it sticks under the header while its rows scroll. */
152
+ sticky: boolean;
153
+ /** A pinned row (the engine row pinning): it stays at the top or the bottom of the view. */
154
+ pinned: 'top' | 'bottom' | undefined;
155
+ /** True for a full-width row (`@isFullWidthRow`): one cell across all columns. */
156
+ fullWidth: boolean;
157
+ }
158
+ /** The detail row of a master row (`@detailRow`): one cell across all columns. */
159
+ interface DetailView {
160
+ row: undefined;
161
+ master: GridRow;
162
+ id: string;
163
+ index: number;
164
+ held: boolean;
165
+ style: SafeString;
166
+ }
167
+ /** A row that is not loaded: skeleton cells, `aria-busy`, or `data-failed`. */
168
+ interface SkeletonView {
169
+ row: undefined;
170
+ id: string;
171
+ index: number;
172
+ held: boolean;
173
+ failed: boolean;
174
+ style: SafeString;
175
+ level: number | undefined;
176
+ }
177
+ type AnyView = RowView | SkeletonView | DetailView;
178
+ export default class LatticeGrid extends Component<LatticeGridSignature> implements GridStateTarget, AlignedGrid {
179
+ /** A new `GridStateHost` for `persistGridState` and `@stateHost` (ADR 0011). */
180
+ static stateHost: () => GridStateHandle;
181
+ /** A new `GridAlignment`: give it to `@aligned` of each grid to align (contract section 11). */
182
+ static alignment: () => GridAlignment;
183
+ cellState: CellStateStore;
184
+ scale: ScaledScroll;
185
+ /** The active cell, as `aria-rowindex` and `aria-colindex`. Null: the first data cell. */
186
+ private _activeCell;
187
+ /** The text direction of the grid, read after it renders. Undefined before that. */
188
+ dir: 'ltr' | 'rtl' | undefined;
189
+ /** The locale text and the locale of this grid (ADR 0024): `@localeText`, then the owner. */
190
+ get l(): LatticeLocale;
191
+ get rtl(): boolean;
192
+ private get _active();
193
+ private set _active(value);
194
+ private pool;
195
+ private _element;
196
+ private _scroller;
197
+ private _suppressClick;
198
+ rowState: VirtualizerState<Element>;
199
+ colState: VirtualizerState<Element>;
200
+ /** The computed `--lt-row-height`, for the density presets when `@rowHeight` is not given. */
201
+ private _cssRowHeight;
202
+ get rowHeight(): number;
203
+ private readRowHeight;
204
+ get rows(): ReadonlyArray<GridRow>;
205
+ /** The pinned rows of the engine row pinning, and a function for the other rows. */
206
+ get pinnedRows(): {
207
+ top: readonly GridRow[];
208
+ bottom: readonly GridRow[];
209
+ center: () => readonly GridRow[];
210
+ };
211
+ /** The heights of the pinned top rows and bottom rows. */
212
+ get pinnedTopHeight(): number;
213
+ get pinnedBottomHeight(): number;
214
+ /** True when rows float: sticky group rows or pinned rows read the view offsets from CSS. */
215
+ get floats(): boolean;
216
+ /**
217
+ * The view top and the view bottom, in body px, as CSS variables on the scroller. The floating
218
+ * rows read them, so a scroll moves them with no render (ADR 0018).
219
+ */
220
+ private writeViewVars;
221
+ /** The number of body rows: the rows of the row model, or of the table, and detail rows. */
222
+ get rowCount(): number;
223
+ /** The row at a 0-based index, or undefined when it is not loaded (or a detail row). */
224
+ rowAt(index: number): GridRow | undefined;
225
+ /** Moves a row in this grid: the app moves it in its data. The live region says the move. */
226
+ private moveRow;
227
+ /** Alt+ArrowUp and Alt+ArrowDown move the row of the active cell, and the active cell. */
228
+ private moveKey;
229
+ /** A press on a drag handle: the drop row is under the pointer, in this grid or in another. */
230
+ onRowDragStart: (row: GridRow, fromIndex: number, event: PointerEvent) => void;
231
+ /** True when the table has the engine cell spanning feature (client rows only). */
232
+ get spanning(): boolean;
233
+ /**
234
+ * The span of a cell, or undefined for a cell of one row and one column. A cell that a cell
235
+ * above covers leaves a spacer of the width of its column span; a cell that a cell before it covers leaves
236
+ * nothing, because the spanning cell is as wide as all its columns.
237
+ */
238
+ spanOf: (row: GridRow, slot: ColumnSlot) => {
239
+ covered: boolean;
240
+ spacer: null;
241
+ rowSpan?: undefined;
242
+ colSpan?: undefined;
243
+ style?: undefined;
244
+ } | {
245
+ covered: boolean;
246
+ spacer: import("@ember/template").TrustedHTML;
247
+ rowSpan?: undefined;
248
+ colSpan?: undefined;
249
+ style?: undefined;
250
+ } | {
251
+ covered: boolean;
252
+ spacer: null;
253
+ rowSpan: number | undefined;
254
+ colSpan: number | undefined;
255
+ style: import("@ember/template").TrustedHTML;
256
+ } | undefined;
257
+ /** The first row of each row span that covers a row: it stays rendered with its merged cell. */
258
+ private spanAnchors;
259
+ /** A row with a cell that spans rows paints over the rows under it. */
260
+ private spansDown;
261
+ /** The IDs of the master rows with an open detail row. */
262
+ private _details;
263
+ hasDetail: (row: GridRow) => boolean;
264
+ isDetailOpen: (row: GridRow) => boolean;
265
+ toggleDetail: (row: GridRow) => void;
266
+ /** The client rows with a detail row after each open master row (a detail row is undefined). */
267
+ get display(): {
268
+ rows: ReadonlyArray<GridRow | undefined>;
269
+ details: ReadonlyMap<number, GridRow>;
270
+ };
271
+ get fullWidthComponent(): ComponentLike<GridRowComponentSignature> | undefined;
272
+ get detailComponent(): ComponentLike<GridRowComponentSignature> | undefined;
273
+ /** A full-width cell spans the rows: it is as wide as all columns. */
274
+ get fullWidthStyle(): import("@ember/template").TrustedHTML;
275
+ /** The tab stop of a full-width cell: it is the active cell for any column of its row. */
276
+ rowTabIndex: (ariaRow: number) => 0 | -1;
277
+ /** True when rows have measured heights: `@rowHeight="auto"`, or an open detail row. */
278
+ get measured(): boolean;
279
+ /** The key of a row for the measured sizes: its row ID, so a size stays with its row. */
280
+ private keyAt;
281
+ /** The virtual start of a row: measured, or the fixed row height. */
282
+ private startOf;
283
+ /** Measures a row element (ResizeObserver, through the virtualizer), as `LatticeList` does. */
284
+ measureRow: import("ember-modifier").FunctionBasedModifier<{
285
+ Args: {
286
+ Positional: [number, boolean];
287
+ Named: import("ember-modifier/-private/signature").EmptyObject;
288
+ };
289
+ Element: HTMLElement;
290
+ }>;
291
+ toggleGroup: (index: number) => void;
292
+ /** True for a row that Enter opens and closes: a group row, or a tree row with sub rows. */
293
+ private isToggleRow;
294
+ /** Client rows have levels when the table has the engine expanding feature (ADR 0018). */
295
+ get clientTree(): boolean;
296
+ /** The group of a client group row: the label is the group value and the leaf row count. */
297
+ private clientGroup;
298
+ get headerGroups(): readonly import("./types.ts").GridHeaderGroup[];
299
+ /** The header rows: the group rows, the leaf header row and the floating filter row. */
300
+ get headerRowCount(): number;
301
+ /** The `aria-rowindex` of the floating filter row, or 0 when there is none. */
302
+ get floatingRow(): number;
303
+ get headerHeight(): number;
304
+ get columns(): {
305
+ start: GridColumn[];
306
+ center: readonly GridColumn[];
307
+ end: readonly GridColumn[];
308
+ all: GridColumn[];
309
+ centerSizes: number[];
310
+ centerStarts: number[];
311
+ startWidth: number;
312
+ centerWidth: number;
313
+ endWidth: number;
314
+ };
315
+ get totalWidth(): number;
316
+ get colCount(): number;
317
+ /** The active cell, kept inside the grid when rows or columns go away. */
318
+ get activeCell(): CellPosition;
319
+ /** The 0-based data row of the active cell, or -1 when it is a header cell. */
320
+ get activeIndex(): number;
321
+ tabIndexFor: (ariaRow: number, ariaCol: number) => 0 | -1;
322
+ rowIdOf: (row: GridRow) => string;
323
+ valueFor: (row: GridRow, column: GridColumn) => unknown;
324
+ /** The text of a cheap cell: a staged or saving value of `@editing` first. */
325
+ textFor: (row: GridRow, column: GridColumn) => string;
326
+ isDirty: (row: GridRow, column: GridColumn) => boolean;
327
+ stateFor: (rowId: string, column: GridColumn) => import("./cell-state.ts").CellState;
328
+ findMatch: (row: GridRow, column: GridColumn) => "current" | "match" | undefined;
329
+ get density(): "compact" | "normal" | "comfortable";
330
+ contains: (element: Element) => boolean;
331
+ /** The cells of one row, in visual order: start-pinned, the center range, end-pinned. */
332
+ get layout(): RowLayout;
333
+ /** The leaf header cells, in the same layout as the rows. */
334
+ get leafHeaders(): Map<string, GridHeader>;
335
+ /** The group header rows, above the leaf header row. They are not virtualized. */
336
+ get groupRows(): Array<{
337
+ key: string;
338
+ aria: number;
339
+ cells: GroupSlot[];
340
+ }>;
341
+ /** The sticky inset of a pinned column: the sizes of the pinned columns nearer the edge. */
342
+ private insetOf;
343
+ headerLabelFor: (column: GridColumn) => string;
344
+ /** The `aria-rowindex` of the leaf header row: the last row of column headers. */
345
+ get leafHeaderRow(): number;
346
+ /** The size of the sizer element: the rows, scaled above the cap (ADR 0003). */
347
+ get sizerStyle(): import("@ember/template").TrustedHTML;
348
+ get bodyHeight(): number;
349
+ get bodyStyle(): import("@ember/template").TrustedHTML;
350
+ get rowWidthStyle(): import("@ember/template").TrustedHTML;
351
+ private view;
352
+ /**
353
+ * An open group row sticks under the header, one row height lower for each level, while its
354
+ * rows scroll. The last row of its group pushes it up. `--lt-view-top` is the scroll offset in
355
+ * body px: a scroll listener sets it, so a scroll moves the row with no render (ADR 0018).
356
+ */
357
+ private stickyStyle;
358
+ /**
359
+ * The last row of the group of each client row: the row before the next row that is not deeper.
360
+ * One pass over the rows when they change, so a scroll reads it with no scan (ADR 0018).
361
+ */
362
+ private get groupEnds();
363
+ /** `top` or `bottom` for a pinned row: the first rows and the last rows of the list. */
364
+ private pinnedAt;
365
+ /** A pinned row floats at the top or the bottom of the view, as a sticky row does. */
366
+ private pinnedStyle;
367
+ /** The index of each client row by its row ID, to find the parent rows of a row. */
368
+ private get clientIndexes();
369
+ /** The open parent rows of the rows in range: they stick at the top, so they stay rendered. */
370
+ private parentsOf;
371
+ /**
372
+ * The row slots. A row keeps its slot while it is in range, so the slot element and its
373
+ * cells stay. A row that comes into range takes a free slot. The active row keeps its slot
374
+ * also when it leaves the range: this is the held row (ADR 0002), with its DOM focus.
375
+ */
376
+ get slots(): Array<AnyView | null>;
377
+ setup: import("ember-modifier").FunctionBasedModifier<{
378
+ Args: {
379
+ Positional: unknown[];
380
+ Named: import("ember-modifier/-private/signature").EmptyObject;
381
+ };
382
+ Element: HTMLElement;
383
+ }>;
384
+ /** Give the row virtualizer the current row count and sizes. It runs after render. */
385
+ syncRows: import("ember-modifier").FunctionBasedModifier<{
386
+ Args: {
387
+ Positional: [number, number, number, number, number, number, number, boolean, unknown];
388
+ Named: import("ember-modifier/-private/signature").EmptyObject;
389
+ };
390
+ Element: HTMLElement;
391
+ }>;
392
+ /** Tell the row model the rows in view, and the query, after each render. */
393
+ syncModel: import("ember-modifier").FunctionBasedModifier<{
394
+ Args: {
395
+ Positional: [GridRowModel | undefined, number, number, string | undefined];
396
+ Named: import("ember-modifier/-private/signature").EmptyObject;
397
+ };
398
+ Element: HTMLElement;
399
+ }>;
400
+ /** The first row in view and the row after the last, for `syncModel`. */
401
+ get range(): [number, number];
402
+ private _warned;
403
+ /**
404
+ * In development, warn once when a full cell column is on a grid of more than 100,000 rows.
405
+ * Each new row in view then makes new components, which is slow (ADR 0002). `warn` is a no-op
406
+ * in production builds.
407
+ */
408
+ private warnFullCells;
409
+ /** Give the column virtualizer the center column sizes and the pinned widths. */
410
+ syncCols: import("ember-modifier").FunctionBasedModifier<{
411
+ Args: {
412
+ Positional: [readonly number[], number, number, boolean];
413
+ Named: import("ember-modifier/-private/signature").EmptyObject;
414
+ };
415
+ Element: HTMLElement;
416
+ }>;
417
+ private positionOf;
418
+ onFocusIn: (event: FocusEvent) => void;
419
+ private cellElement;
420
+ private focusActive;
421
+ /** Make a cell the active cell, scroll it into view, and focus it after the render. */
422
+ private activate;
423
+ private get pageRows();
424
+ onKeyDown: (event: KeyboardEvent) => void;
425
+ /** Shift+F10 and the ContextMenu key (APG). */
426
+ private menuKey;
427
+ /** F2 or Enter: focus the first control in a header slot or a floating filter cell. */
428
+ private enterWidget;
429
+ /** Escape in a header slot or a floating filter: the focus goes back to its cell. */
430
+ private leaveWidget;
431
+ /** The cell of the open context menu, for the `contextMenu` block. */
432
+ contextTarget: GridContextTarget | null;
433
+ /** True after a key opened the menu: the `contextmenu` event of the same key is ignored. */
434
+ private _keyMenu;
435
+ private openContextMenu;
436
+ /** A right click on a body cell. With no hook and no block, the browser menu opens. */
437
+ /** True when the grid has a context menu: the `contextMenu` block or `@onCellContextMenu`. */
438
+ private get _hasMenu();
439
+ private _menuBlock;
440
+ /** The template tells the grid when it has a `contextMenu` block. */
441
+ noteMenuBlock: import("ember-modifier").FunctionBasedModifier<{
442
+ Args: {
443
+ Positional: [boolean];
444
+ Named: import("ember-modifier/-private/signature").EmptyObject;
445
+ };
446
+ Element: HTMLElement;
447
+ }>;
448
+ onContextMenu: (hasMenu: boolean, event: MouseEvent) => void;
449
+ closeMenu: () => void;
450
+ /** The selection as TSV, for a menu "Copy". With headers: the header labels come first. */
451
+ copyText: (withHeaders?: boolean) => string;
452
+ /** Pastes TSV at the start corner of the last range, through `@editing` (one undo step). */
453
+ pasteText: (text: string) => Promise<void>;
454
+ /** The last grid message (a sort, a refused paste), for the live region. */
455
+ liveMessage: string;
456
+ get countMessage(): string;
457
+ private announceSort;
458
+ /** The index of a row by its ID (with a row model: of a loaded row), or -1. */
459
+ private indexOfRow;
460
+ scrollToCell(rowId: string, columnId: string): boolean;
461
+ /** Opens the editor of a cell, as F2 does (`GridStateHandle.startEditing`). */
462
+ startEditing(rowId: string, columnId: string): boolean;
463
+ private columnAt;
464
+ private activateCell;
465
+ onDoubleClick: (event: MouseEvent) => void;
466
+ /** A click opens the editor of a column with the `singleClick` trigger. */
467
+ onClick: (event: MouseEvent) => void;
468
+ /**
469
+ * Opens the editor for a pointer action, when it is the trigger of the column. A click with a
470
+ * modifier key (a range) or on a button or a link in the cell does not open it. A click on a
471
+ * display input (the stars of a rating) opens it. True: the editor opens.
472
+ */
473
+ private pointerEdit;
474
+ get selectable(): boolean;
475
+ get multiSelect(): boolean;
476
+ get multiselectable(): boolean;
477
+ /** True when the table has the cell selection feature: ranges of cells. */
478
+ get cellSelectable(): boolean;
479
+ /** Client rows use the engine ranges. With `@rowModel`, the grid owns one range. */
480
+ get engineRanges(): boolean;
481
+ /** The grid range with `@rowModel`: two corners as 0-based row and column indexes. */
482
+ private _range;
483
+ /** The cell ranges, or the active cell as a range when there is no range. */
484
+ get selection(): GridRange[];
485
+ /** `aria-selected` of a cell: in a range (or the active cell when there is no range). */
486
+ cellSelected: (index: number, ariaCol: number) => "true" | "false" | undefined;
487
+ /** The logical edges of the ranges that a cell sits on, for the range borders of the theme. */
488
+ rangeEdge: (index: number, ariaCol: number) => string | undefined;
489
+ /** The fill handle is on the end corner of the last range. */
490
+ isFillCorner: (index: number, ariaCol: number) => boolean;
491
+ /** The cell at 0-based display indexes, or undefined outside the loaded rows. */
492
+ cellRefAt(index: number, col: number): GridEditCell | undefined;
493
+ /** The cells of a range, row by row. */
494
+ private cellsOf;
495
+ /** Makes the cell at a position the one-cell range: a move with no Shift. */
496
+ private focusSelection;
497
+ /** Shift+arrows extend the last range; Ctrl+A selects all cells. */
498
+ private rangeKey;
499
+ /** Moves the focus corner of the grid range (`@rowModel`), from the active cell at first. */
500
+ private extendOwnRange;
501
+ /** The engine cell under a mouse event, for a press (a range start) or a drag. */
502
+ private engineCell;
503
+ /** A press starts a range; Shift extends the last range, Ctrl adds a range (the engine). */
504
+ onMouseDown: (event: MouseEvent) => void;
505
+ onMouseOver: (event: MouseEvent) => void;
506
+ onMouseOut: (event: MouseEvent) => void;
507
+ onFocusOut: (event: FocusEvent) => void;
508
+ /** The loading message, or "No rows" for an empty grid. Outside `role=grid`, as a status. */
509
+ get overlayMessage(): string;
510
+ tooltipId: string;
511
+ /** The cell of the tooltip, its text and its place in the viewport. */
512
+ tooltip: {
513
+ row: number;
514
+ col: number;
515
+ text: string;
516
+ style: SafeString;
517
+ } | null;
518
+ /**
519
+ * The `aria-describedby` of a cell: its own description (`meta.lattice.cellDescription`), then
520
+ * the open tooltip and the open note.
521
+ */
522
+ describedBy: (index: number, slot: ColumnSlot, row: GridRow) => string | undefined;
523
+ /** `aria-invalid` of a cell, from `meta.lattice.cellInvalid`. */
524
+ invalidFor: (row: GridRow, slot: ColumnSlot) => "true" | undefined;
525
+ private descriptionId;
526
+ /** The descriptions of the rendered cells, in a hidden list outside `role=grid`. */
527
+ get cellDescriptions(): Array<{
528
+ id: string;
529
+ text: string;
530
+ }>;
531
+ noteId: string;
532
+ /** The cell of the open note and its text. */
533
+ note: {
534
+ row: number;
535
+ col: number;
536
+ text: string;
537
+ } | null;
538
+ hasNote: (row: GridRow, column: GridColumn) => boolean;
539
+ private showNote;
540
+ private hideNote;
541
+ /**
542
+ * Puts the note under its cell, by measurement as in `placeEditor`, and again on each scroll.
543
+ * When the tooltip of the same cell is open, the note goes under the tooltip, so they do not
544
+ * overlap. When the cell is not rendered, the note hides.
545
+ */
546
+ placeNote: import("ember-modifier").FunctionBasedModifier<{
547
+ Args: {
548
+ Positional: [CellPosition | null, CellPosition | null];
549
+ Named: import("ember-modifier/-private/signature").EmptyObject;
550
+ };
551
+ Element: HTMLElement;
552
+ }>;
553
+ private showTooltip;
554
+ private hideTooltip;
555
+ /** A touch press that stays this long, in ms, opens the context menu. */
556
+ static LONG_PRESS: number;
557
+ /** A long press on a body cell opens the context menu, as a right click does. */
558
+ onPointerDown: (event: PointerEvent) => void;
559
+ /** Ends the long press that runs: a `contextmenu` event (Android) opens the menu in its place. */
560
+ private _stopPress;
561
+ private onBodyCell;
562
+ /** Puts the ranges on the clipboard as TSV and HTML. False: not a copy from a body cell. */
563
+ private writeClipboard;
564
+ onCopy: (event: ClipboardEvent) => void;
565
+ /** A copy, then a clear of the cells through `@editing` (one undo step). */
566
+ onCut: (event: ClipboardEvent) => void;
567
+ /** Pastes TSV at the start corner of the last range, through `@editing` (one undo step). */
568
+ onPaste: (event: ClipboardEvent) => void;
569
+ /** A drag of the fill handle: down or to the inline end, whichever is farther. */
570
+ onFillStart: (event: PointerEvent) => void;
571
+ private fill;
572
+ /**
573
+ * Ctrl+D copies the top row of the range into the rows under it, and Ctrl+R copies the first
574
+ * column into the columns at its inline end, as spreadsheets do. In one row (or one column),
575
+ * the source is the row above (or the column at the inline start). It is one undo step, through
576
+ * the same `fill` as the fill handle. A row number cell is never a source or a target.
577
+ */
578
+ private fillKey;
579
+ editorId: string;
580
+ /** The cell in edit, as `aria-rowindex` and `aria-colindex`. It can differ from the active cell. */
581
+ private _editPosition;
582
+ get editPosition(): CellPosition | null;
583
+ /** The edit mode of the edited column: `popup` puts the editor under the cell. */
584
+ get editMode(): "cell" | "popup";
585
+ /** The fields of a full-row edit: the rendered columns that `@editing` can edit. */
586
+ get rowEditFields(): GridRowEditorField[];
587
+ /** The 1-based number of the edited row, for the name of the row editor. */
588
+ get editRowNumber(): number;
589
+ get editInvalid(): boolean;
590
+ /** Enter or F2 opens the editor; a typed key opens it with the key; Ctrl+Z and Ctrl+Y. */
591
+ private editKey;
592
+ /** Opens the editor on the cell (or the row editor), then moves the focus into it. */
593
+ private startEdit;
594
+ /**
595
+ * Focuses the element with the editor ID. When that element cannot take the focus (a
596
+ * fieldset, the root of a calendar), the focus goes to its checked or current item, else to
597
+ * its first control.
598
+ */
599
+ private focusEditor;
600
+ /** The commit of a press or a focus change: only one at a time, and only while in edit. */
601
+ private _pressCommit;
602
+ private commitOnce;
603
+ /** With `@stopEditingWhenCellsLoseFocus`: the focus goes outside the overlay, so the edit saves. */
604
+ onEditorFocusOut: (event: FocusEvent) => void;
605
+ /** With `@stopEditingWhenCellsLoseFocus`: a press outside the grid saves the edit. */
606
+ saveOnOutsidePress: import("ember-modifier").FunctionBasedModifier<{
607
+ Args: {
608
+ Positional: [boolean | undefined];
609
+ Named: import("ember-modifier/-private/signature").EmptyObject;
610
+ };
611
+ Element: HTMLElement;
612
+ }>;
613
+ /** Escape cancels; Enter commits and moves down; Tab commits and moves to the inline end. */
614
+ onEditorKeyDown: (event: KeyboardEvent) => void;
615
+ /**
616
+ * Escape cancels the edit. It runs in the capture phase: a control can stop the key in the
617
+ * bubble phase (a closed combobox clears its text). A layer in the editor that Escape closes
618
+ * (a list, a popover) cancels the key first, and then the edit stays open.
619
+ */
620
+ onEditorEscape: (event: KeyboardEvent) => void;
621
+ private commitRowAndMove;
622
+ private commitAndMove;
623
+ /**
624
+ * Puts the editor on the edited cell. It measures where the editor lands and moves it by the
625
+ * difference, so it works in any containing block and with a scaled page. It does this again
626
+ * on each scroll, so the editor follows its cell. The edited row is held (ADR 0002, amendment 1):
627
+ * when the cell leaves the view, the editor is clipped, not hidden, so its control keeps focus.
628
+ */
629
+ placeEditor: import("ember-modifier").FunctionBasedModifier<{
630
+ Args: {
631
+ Positional: [CellPosition | null];
632
+ Named: import("ember-modifier/-private/signature").EmptyObject;
633
+ };
634
+ Element: HTMLElement;
635
+ }>;
636
+ /**
637
+ * Puts the row editor over the edited row, and each field over its cell, by measurement as in
638
+ * `placeEditor`. It does this again on each scroll.
639
+ */
640
+ placeRowEditor: import("ember-modifier").FunctionBasedModifier<{
641
+ Args: {
642
+ Positional: [CellPosition | null];
643
+ Named: import("ember-modifier/-private/signature").EmptyObject;
644
+ };
645
+ Element: HTMLElement;
646
+ }>;
647
+ /** The scroll offset (virtual px, ADR 0003) and the active cell that the user chose. */
648
+ readState(): Required<GridHostState>;
649
+ applyState(state: GridHostState): void;
650
+ private toggleSort;
651
+ private sortBy;
652
+ /** True for an event from a header slot or a control in the label: no sort and no drag. */
653
+ private inSlot;
654
+ onHeaderClick: (column: GridColumn, event: MouseEvent) => void;
655
+ /** A separator needs the column resizing feature, and `enableResizing` not false. */
656
+ canResize: (column: GridColumn) => boolean;
657
+ private resize;
658
+ onResizeKey: (column: GridColumn, event: KeyboardEvent) => void;
659
+ onResizeStart: (column: GridColumn, event: PointerEvent) => void;
660
+ stopClick: (event: MouseEvent) => void;
661
+ /** A double click on the separator sizes the column to its content. */
662
+ onResizeDoubleClick: (column: GridColumn, event: MouseEvent) => void;
663
+ /** The flex columns that a resize or an auto-size took out of flex. */
664
+ private _fixedFlex;
665
+ /** The width and the fixed sizes of the last flex pass: the same input needs no pass. */
666
+ private _flexKey;
667
+ private _flexFrame;
668
+ private isFlex;
669
+ /** The table as core `applyFlexWidths` and `autoSizeColumns` read it. */
670
+ private get sizingTable();
671
+ /** Runs a flex pass in the next frame: a size write in a ResizeObserver callback can loop. */
672
+ private scheduleFlex;
673
+ private applyFlex;
674
+ /**
675
+ * The grid API of the header slots and the floating filters (`@grid`). With no IDs, it sizes
676
+ * the columns that have a separator: a column that cannot resize keeps its size.
677
+ */
678
+ headerApi: GridHeaderApi;
679
+ /** Sizes columns to their widest rendered content (`GridStateHandle.autoSizeColumns`). */
680
+ autoSizeColumns(columnIds?: ReadonlyArray<string>): void;
681
+ /**
682
+ * The width of the widest rendered content of a column, in CSS px: the header label and slot,
683
+ * and the body and total cells. Undefined when no cell of the column is rendered.
684
+ */
685
+ private measureColumn;
686
+ /** True when the table has no columns and has rows: the grid makes columns from the rows. */
687
+ get wantsAutoColumns(): boolean;
688
+ /** Sets the auto columns after the render in which the first rows show. */
689
+ syncAutoColumns: import("ember-modifier").FunctionBasedModifier<{
690
+ Args: {
691
+ Positional: [boolean];
692
+ Named: import("ember-modifier/-private/signature").EmptyObject;
693
+ };
694
+ Element: HTMLElement;
695
+ }>;
696
+ /** A table with no columns gets a column for each key of its first rows. */
697
+ private setAutoColumns;
698
+ private _alignment;
699
+ private _leaveAlignment;
700
+ /** The column state that aligned grids share: a change of it runs `syncAligned`. */
701
+ get alignedKey(): string;
702
+ alignedColumns(): AlignedColumns;
703
+ alignColumns(state: AlignedColumns): void;
704
+ /** The offset that an aligned grid set: the scroll event of it is not sent back. */
705
+ private _alignedLeft;
706
+ alignScroll(left: number): void;
707
+ /** Sends a horizontal scroll to the aligned grids, but not one that came from them. */
708
+ private scrolledAligned;
709
+ /**
710
+ * Joins `@aligned` on the first run; later runs send a column change to the other grids. The
711
+ * work waits until the render ends: it reads and writes the other tables, and a modifier
712
+ * tracks what it reads.
713
+ */
714
+ syncAligned: import("ember-modifier").FunctionBasedModifier<{
715
+ Args: {
716
+ Positional: [GridAlignment | undefined, string | undefined];
717
+ Named: import("ember-modifier/-private/signature").EmptyObject;
718
+ };
719
+ Element: HTMLElement;
720
+ }>;
721
+ willDestroy(): void;
722
+ onHeaderPointerDown: (column: GridColumn, event: PointerEvent) => void;
723
+ private moveColumn;
724
+ get rowDraft(): Readonly<Record<string, unknown>>;
725
+ setRowValue: (columnId: string, value: unknown) => void | undefined;
726
+ get rangeStart(): number;
727
+ get rangeEnd(): number;
728
+ /** All rows plus the header rows, or -1 when the row model does not know the count (ARIA). */
729
+ get ariaRowCount(): number;
730
+ get footerHeight(): number;
731
+ /** The grand total row is after the last row. */
732
+ get totalAriaRow(): number;
733
+ /** The total row stays at the bottom of the view while the rows scroll. */
734
+ get footerStyle(): import("@ember/template").TrustedHTML;
735
+ get role(): "treegrid" | "grid";
736
+ get overscan(): number;
737
+ /** The row height when `@rowHeight` is given, and the flex size beside a side bar. */
738
+ gridStyle: (split: boolean) => import("@ember/template").TrustedHTML | undefined;
739
+ }
740
+ export {};
741
+ //# sourceMappingURL=lattice-grid.d.ts.map