@universal-material/data-grid 0.0.0-stage → 0.2.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 +172 -2
- package/custom-elements.json +4652 -0
- package/dist/attribute-converters.d.ts +53 -0
- package/dist/attribute-converters.js +98 -0
- package/dist/attribute-converters.js.map +1 -0
- package/dist/change-source.d.ts +3 -0
- package/dist/change-source.js +2 -0
- package/dist/change-source.js.map +1 -0
- package/dist/data/data-source.d.ts +164 -0
- package/dist/data/data-source.js +75 -0
- package/dist/data/data-source.js.map +1 -0
- package/dist/data/local-source.d.ts +20 -0
- package/dist/data/local-source.js +94 -0
- package/dist/data/local-source.js.map +1 -0
- package/dist/data/remote-loader.d.ts +190 -0
- package/dist/data/remote-loader.js +608 -0
- package/dist/data/remote-loader.js.map +1 -0
- package/dist/export/csv.d.ts +28 -0
- package/dist/export/csv.js +61 -0
- package/dist/export/csv.js.map +1 -0
- package/dist/export/download.d.ts +7 -0
- package/dist/export/download.js +17 -0
- package/dist/export/download.js.map +1 -0
- package/dist/export/rows.d.ts +75 -0
- package/dist/export/rows.js +134 -0
- package/dist/export/rows.js.map +1 -0
- package/dist/export/slice.d.ts +15 -0
- package/dist/export/slice.js +35 -0
- package/dist/export/slice.js.map +1 -0
- package/dist/export/types.d.ts +155 -0
- package/dist/export/types.js +2 -0
- package/dist/export/types.js.map +1 -0
- package/dist/export/write.d.ts +38 -0
- package/dist/export/write.js +178 -0
- package/dist/export/write.js.map +1 -0
- package/dist/export-pdf/client.d.ts +75 -0
- package/dist/export-pdf/client.js +155 -0
- package/dist/export-pdf/client.js.map +1 -0
- package/dist/export-pdf/engine.d.ts +73 -0
- package/dist/export-pdf/engine.js +131 -0
- package/dist/export-pdf/engine.js.map +1 -0
- package/dist/export-pdf/grid-pdf.wasm +0 -0
- package/dist/export-pdf/index.d.ts +27 -0
- package/dist/export-pdf/index.js +566 -0
- package/dist/export-pdf/index.js.map +1 -0
- package/dist/export-pdf/serialize.d.ts +23 -0
- package/dist/export-pdf/serialize.js +127 -0
- package/dist/export-pdf/serialize.js.map +1 -0
- package/dist/export-pdf/types.d.ts +150 -0
- package/dist/export-pdf/types.js +2 -0
- package/dist/export-pdf/types.js.map +1 -0
- package/dist/export-pdf/worker.d.ts +2 -0
- package/dist/export-pdf/worker.js +81 -0
- package/dist/export-pdf/worker.js.map +1 -0
- package/dist/export-xlsx/formats.d.ts +14 -0
- package/dist/export-xlsx/formats.js +40 -0
- package/dist/export-xlsx/formats.js.map +1 -0
- package/dist/export-xlsx/index.d.ts +74 -0
- package/dist/export-xlsx/index.js +137 -0
- package/dist/export-xlsx/index.js.map +1 -0
- package/dist/features/adaptive.d.ts +25 -0
- package/dist/features/adaptive.js +47 -0
- package/dist/features/adaptive.js.map +1 -0
- package/dist/features/cell-content-focus.d.ts +29 -0
- package/dist/features/cell-content-focus.js +95 -0
- package/dist/features/cell-content-focus.js.map +1 -0
- package/dist/features/cell-range.d.ts +97 -0
- package/dist/features/cell-range.js +75 -0
- package/dist/features/cell-range.js.map +1 -0
- package/dist/features/clipboard.d.ts +28 -0
- package/dist/features/clipboard.js +48 -0
- package/dist/features/clipboard.js.map +1 -0
- package/dist/features/column-chooser.d.ts +91 -0
- package/dist/features/column-chooser.js +451 -0
- package/dist/features/column-chooser.js.map +1 -0
- package/dist/features/column-dnd.d.ts +10 -0
- package/dist/features/column-dnd.js +126 -0
- package/dist/features/column-dnd.js.map +1 -0
- package/dist/features/context-menu.d.ts +122 -0
- package/dist/features/context-menu.js +153 -0
- package/dist/features/context-menu.js.map +1 -0
- package/dist/features/drag-helper.d.ts +39 -0
- package/dist/features/drag-helper.js +108 -0
- package/dist/features/drag-helper.js.map +1 -0
- package/dist/features/drop-position.d.ts +15 -0
- package/dist/features/drop-position.js +24 -0
- package/dist/features/drop-position.js.map +1 -0
- package/dist/features/editing.d.ts +111 -0
- package/dist/features/editing.js +244 -0
- package/dist/features/editing.js.map +1 -0
- package/dist/features/filter-row.d.ts +80 -0
- package/dist/features/filter-row.js +538 -0
- package/dist/features/filter-row.js.map +1 -0
- package/dist/features/filtering.d.ts +55 -0
- package/dist/features/filtering.js +209 -0
- package/dist/features/filtering.js.map +1 -0
- package/dist/features/group-dnd.d.ts +11 -0
- package/dist/features/group-dnd.js +119 -0
- package/dist/features/group-dnd.js.map +1 -0
- package/dist/features/header-filter.d.ts +100 -0
- package/dist/features/header-filter.js +588 -0
- package/dist/features/header-filter.js.map +1 -0
- package/dist/features/host-label.d.ts +36 -0
- package/dist/features/host-label.js +184 -0
- package/dist/features/host-label.js.map +1 -0
- package/dist/features/keyboard.d.ts +59 -0
- package/dist/features/keyboard.js +127 -0
- package/dist/features/keyboard.js.map +1 -0
- package/dist/features/menu.d.ts +113 -0
- package/dist/features/menu.js +491 -0
- package/dist/features/menu.js.map +1 -0
- package/dist/features/resize.d.ts +82 -0
- package/dist/features/resize.js +214 -0
- package/dist/features/resize.js.map +1 -0
- package/dist/features/scroll-port.d.ts +51 -0
- package/dist/features/scroll-port.js +329 -0
- package/dist/features/scroll-port.js.map +1 -0
- package/dist/features/search.d.ts +45 -0
- package/dist/features/search.js +123 -0
- package/dist/features/search.js.map +1 -0
- package/dist/features/selection.d.ts +37 -0
- package/dist/features/selection.js +103 -0
- package/dist/features/selection.js.map +1 -0
- package/dist/features/sorting.d.ts +39 -0
- package/dist/features/sorting.js +53 -0
- package/dist/features/sorting.js.map +1 -0
- package/dist/features/toolbar.d.ts +125 -0
- package/dist/features/toolbar.js +135 -0
- package/dist/features/toolbar.js.map +1 -0
- package/dist/features/tree.d.ts +53 -0
- package/dist/features/tree.js +94 -0
- package/dist/features/tree.js.map +1 -0
- package/dist/features/validation.d.ts +48 -0
- package/dist/features/validation.js +172 -0
- package/dist/features/validation.js.map +1 -0
- package/dist/grid-column-def.d.ts +521 -0
- package/dist/grid-column-def.js +32 -0
- package/dist/grid-column-def.js.map +1 -0
- package/dist/grid-column.d.ts +173 -0
- package/dist/grid-column.js +382 -0
- package/dist/grid-column.js.map +1 -0
- package/dist/grid-i18n.d.ts +469 -0
- package/dist/grid-i18n.js +3222 -0
- package/dist/grid-i18n.js.map +1 -0
- package/dist/grid.d.ts +1510 -0
- package/dist/grid.js +15972 -0
- package/dist/grid.js.map +1 -0
- package/dist/grid.min.js +3966 -0
- package/dist/grid.styles.d.ts +2 -0
- package/dist/grid.styles.js +2849 -0
- package/dist/grid.styles.js.map +1 -0
- package/dist/render/cell.d.ts +16 -0
- package/dist/render/cell.js +78 -0
- package/dist/render/cell.js.map +1 -0
- package/dist/render/column-window.d.ts +18 -0
- package/dist/render/column-window.js +50 -0
- package/dist/render/column-window.js.map +1 -0
- package/dist/render/content.d.ts +45 -0
- package/dist/render/content.js +140 -0
- package/dist/render/content.js.map +1 -0
- package/dist/render/editors.d.ts +28 -0
- package/dist/render/editors.js +41 -0
- package/dist/render/editors.js.map +1 -0
- package/dist/render/footer.d.ts +61 -0
- package/dist/render/footer.js +61 -0
- package/dist/render/footer.js.map +1 -0
- package/dist/render/group-row.d.ts +35 -0
- package/dist/render/group-row.js +60 -0
- package/dist/render/group-row.js.map +1 -0
- package/dist/render/header.d.ts +108 -0
- package/dist/render/header.js +124 -0
- package/dist/render/header.js.map +1 -0
- package/dist/render/keyed-rows.d.ts +25 -0
- package/dist/render/keyed-rows.js +98 -0
- package/dist/render/keyed-rows.js.map +1 -0
- package/dist/render/virtualizer.d.ts +158 -0
- package/dist/render/virtualizer.js +721 -0
- package/dist/render/virtualizer.js.map +1 -0
- package/dist/row-model/added-rows.d.ts +32 -0
- package/dist/row-model/added-rows.js +95 -0
- package/dist/row-model/added-rows.js.map +1 -0
- package/dist/row-model/cell-range.d.ts +71 -0
- package/dist/row-model/cell-range.js +187 -0
- package/dist/row-model/cell-range.js.map +1 -0
- package/dist/row-model/columns.d.ts +102 -0
- package/dist/row-model/columns.js +222 -0
- package/dist/row-model/columns.js.map +1 -0
- package/dist/row-model/compare.d.ts +40 -0
- package/dist/row-model/compare.js +590 -0
- package/dist/row-model/compare.js.map +1 -0
- package/dist/row-model/distinct.d.ts +39 -0
- package/dist/row-model/distinct.js +105 -0
- package/dist/row-model/distinct.js.map +1 -0
- package/dist/row-model/filter.d.ts +80 -0
- package/dist/row-model/filter.js +582 -0
- package/dist/row-model/filter.js.map +1 -0
- package/dist/row-model/flatten.d.ts +129 -0
- package/dist/row-model/flatten.js +511 -0
- package/dist/row-model/flatten.js.map +1 -0
- package/dist/row-model/fold.d.ts +25 -0
- package/dist/row-model/fold.js +104 -0
- package/dist/row-model/fold.js.map +1 -0
- package/dist/row-model/format.d.ts +58 -0
- package/dist/row-model/format.js +239 -0
- package/dist/row-model/format.js.map +1 -0
- package/dist/row-model/group.d.ts +30 -0
- package/dist/row-model/group.js +173 -0
- package/dist/row-model/group.js.map +1 -0
- package/dist/row-model/lru.d.ts +19 -0
- package/dist/row-model/lru.js +48 -0
- package/dist/row-model/lru.js.map +1 -0
- package/dist/row-model/sort.d.ts +30 -0
- package/dist/row-model/sort.js +107 -0
- package/dist/row-model/sort.js.map +1 -0
- package/dist/row-model/summary.d.ts +64 -0
- package/dist/row-model/summary.js +213 -0
- package/dist/row-model/summary.js.map +1 -0
- package/dist/row-model/tree.d.ts +116 -0
- package/dist/row-model/tree.js +478 -0
- package/dist/row-model/tree.js.map +1 -0
- package/dist/row-model/types.d.ts +109 -0
- package/dist/row-model/types.js +5 -0
- package/dist/row-model/types.js.map +1 -0
- package/dist/row-model/value.d.ts +20 -0
- package/dist/row-model/value.js +57 -0
- package/dist/row-model/value.js.map +1 -0
- package/dist/state/grid-state.d.ts +147 -0
- package/dist/state/grid-state.js +295 -0
- package/dist/state/grid-state.js.map +1 -0
- package/dist/state/storage.d.ts +33 -0
- package/dist/state/storage.js +62 -0
- package/dist/state/storage.js.map +1 -0
- package/dist/state/versioned.d.ts +18 -0
- package/dist/state/versioned.js +56 -0
- package/dist/state/versioned.js.map +1 -0
- package/package.json +145 -6
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { type ReactiveController, type ReactiveControllerHost, type TemplateResult } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Motor único dos menus do grid (frente 18): menu de contexto (cabeçalho,
|
|
4
|
+
* painel de grupos, linhas, linhas de grupo) e menus da barra ("mais",
|
|
5
|
+
* exportar). Padrão "menu" da APG: ↑/↓ circulares, Home/End, letra digitada,
|
|
6
|
+
* Enter/Espaço, Esc e Tab fecham devolvendo o foco; clique fora fecha sem
|
|
7
|
+
* roubar o foco (spec 17). Popover manual (camada do topo), posicionado no
|
|
8
|
+
* ponto do clique ou sob o elemento de origem, preso à janela e espelhado em
|
|
9
|
+
* RTL.
|
|
10
|
+
*
|
|
11
|
+
* Submenu (um nível, "Fixar coluna ▸"): painel irmão do menu (um `menu` não
|
|
12
|
+
* fica dentro de outro na árvore ARIA), aberto por →/Enter/Espaço (← em RTL)
|
|
13
|
+
* com o foco no primeiro item; ←/Esc (→ em RTL) fecham e devolvem o foco ao
|
|
14
|
+
* item pai; Tab fecha a cadeia toda.
|
|
15
|
+
*/
|
|
16
|
+
export interface MenuHost extends ReactiveControllerHost {
|
|
17
|
+
readonly renderRoot: HTMLElement | DocumentFragment;
|
|
18
|
+
_isRtl(): boolean;
|
|
19
|
+
}
|
|
20
|
+
/** Para onde o foco volta ao fechar: o elemento ou quem o acha na hora (a célula pode ter sido reciclada). */
|
|
21
|
+
export type MenuReturnFocus = HTMLElement | null | (() => HTMLElement | null);
|
|
22
|
+
export interface MenuAnchor<D = unknown> {
|
|
23
|
+
/** Recebe o foco de volta ao fechar (Esc, Tab, ação). */
|
|
24
|
+
returnFocus: MenuReturnFocus;
|
|
25
|
+
/** Ponto do clique direito/toque; sem ele, abre sob `positionTarget` (ou o `returnFocus`). */
|
|
26
|
+
x?: number;
|
|
27
|
+
y?: number;
|
|
28
|
+
positionTarget?: HTMLElement | null;
|
|
29
|
+
/** Botão que abriu (`aria-expanded`): clicar nele com o menu aberto fecha, não reabre. */
|
|
30
|
+
opener?: HTMLElement | null;
|
|
31
|
+
/** Abre com o foco no último item (↑ no botão de menu). */
|
|
32
|
+
focusLast?: boolean;
|
|
33
|
+
/** O que o grid precisa para desenhar e agir (alvo, itens). */
|
|
34
|
+
data: D;
|
|
35
|
+
}
|
|
36
|
+
/** Teclas que abrem um menu de contexto pelo teclado. */
|
|
37
|
+
export declare const isContextMenuKey: (event: KeyboardEvent) => boolean;
|
|
38
|
+
export declare class MenuController<D = unknown> implements ReactiveController {
|
|
39
|
+
#private;
|
|
40
|
+
constructor(host: MenuHost, panelClass: string);
|
|
41
|
+
get open(): boolean;
|
|
42
|
+
get data(): D | undefined;
|
|
43
|
+
get opener(): HTMLElement | null;
|
|
44
|
+
/** Chave do item cujo submenu está aberto (`null`: nenhum). */
|
|
45
|
+
get submenu(): string | null;
|
|
46
|
+
/** Timer da busca por letra pendente (diagnóstico de memória). */
|
|
47
|
+
get timers(): number;
|
|
48
|
+
show(anchor: MenuAnchor<D>): void;
|
|
49
|
+
/** Fecha; com `restoreFocus`, o foco volta ao disparador depois do render. */
|
|
50
|
+
hide(restoreFocus?: boolean): void;
|
|
51
|
+
/**
|
|
52
|
+
* Fecha e devolve o foco JÁ (no mesmo gesto: a ação do hospedeiro roda com
|
|
53
|
+
* o foco no disparador e a ativação do usuário ainda vale).
|
|
54
|
+
*/
|
|
55
|
+
hideAndFocus(): void;
|
|
56
|
+
/** Abre o submenu do item `key`; com `focusFirst` (teclado), o foco vai ao primeiro item dele. */
|
|
57
|
+
openSubmenu(key: string, focusFirst?: boolean): void;
|
|
58
|
+
/** Fecha o submenu; com `focusParent`, o foco volta ao item que o abriu. */
|
|
59
|
+
closeSubmenu(focusParent?: boolean): void;
|
|
60
|
+
/** Ponteiro sobre um item do menu de cima: abre o submenu dele (sem foco) ou fecha o aberto. */
|
|
61
|
+
hoverItem(key: string, hasSubmenu: boolean): void;
|
|
62
|
+
hostUpdated(): void;
|
|
63
|
+
hostDisconnected(): void;
|
|
64
|
+
/** Foca o item `index` (os itens do painel atual). */
|
|
65
|
+
focusItem(index: number): void;
|
|
66
|
+
readonly onKeyDown: (event: KeyboardEvent) => void;
|
|
67
|
+
}
|
|
68
|
+
/** Uma entrada do menu desenhado (sem estado). */
|
|
69
|
+
export interface MenuEntry {
|
|
70
|
+
/** Identidade (posição na lista de itens do grid). */
|
|
71
|
+
key: string;
|
|
72
|
+
label: string;
|
|
73
|
+
/** Visível e focável pelas setas, mas sem efeito (APG: `aria-disabled`). */
|
|
74
|
+
disabled?: boolean;
|
|
75
|
+
separatorBefore?: boolean;
|
|
76
|
+
/** Texto oculto depois do rótulo (ex.: a coluna de "Desagrupar"). */
|
|
77
|
+
hiddenSuffix?: string;
|
|
78
|
+
/** Idioma do texto oculto (o rótulo da coluna é do hospedeiro). */
|
|
79
|
+
suffixLang?: string;
|
|
80
|
+
/** Idioma do texto: o da i18n nos embutidos; o do conteúdo do hospedeiro (ou `''`) nos dele. */
|
|
81
|
+
lang?: string;
|
|
82
|
+
/** O item abre um diálogo (seletor de colunas pelo "mais" e pelo menu do cabeçalho). */
|
|
83
|
+
hasPopup?: 'dialog';
|
|
84
|
+
/** `menuitemradio` com este `aria-checked` (itens do submenu de fixar); ausente = `menuitem`. */
|
|
85
|
+
checked?: boolean;
|
|
86
|
+
/** Submenu: o item abre um `menu` com estes itens num `group` com o nome do item. */
|
|
87
|
+
children?: readonly MenuEntry[];
|
|
88
|
+
}
|
|
89
|
+
export interface MenuRenderContext {
|
|
90
|
+
/** Classe do painel (a do controlador) e classes extras. */
|
|
91
|
+
className: string;
|
|
92
|
+
/** `part` do painel: `menu` + a do menu. */
|
|
93
|
+
part: string;
|
|
94
|
+
/** Nome do menu (texto da i18n) ou id do botão que o nomeia. */
|
|
95
|
+
label?: string;
|
|
96
|
+
labelledBy?: string;
|
|
97
|
+
/** Idioma do nome (`aria-label`). */
|
|
98
|
+
labelLang?: string;
|
|
99
|
+
entries: readonly MenuEntry[];
|
|
100
|
+
onAction: (key: string) => void;
|
|
101
|
+
/** Ativação de um item `aria-disabled` (não age; o grid pode anunciar o porquê). */
|
|
102
|
+
onDisabledAction?: (key: string) => void;
|
|
103
|
+
onKeyDown: (event: KeyboardEvent) => void;
|
|
104
|
+
/** Controlador do menu (submenu aberto, ponteiro sobre os itens); sem ele, nada de submenu. */
|
|
105
|
+
controller?: MenuController<any>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* O menu (sem estado): itens com foco móvel e separadores. O submenu aberto
|
|
109
|
+
* vem como painel irmão (`role="menu"` com um `group` nomeado pelo item pai),
|
|
110
|
+
* também na camada do topo.
|
|
111
|
+
*/
|
|
112
|
+
export declare const renderMenu: (context: MenuRenderContext) => TemplateResult;
|
|
113
|
+
//# sourceMappingURL=menu.d.ts.map
|
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
import { html, nothing, svg } from 'lit';
|
|
2
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
3
|
+
import { map } from 'lit/directives/map.js';
|
|
4
|
+
/** Teclas que abrem um menu de contexto pelo teclado. */
|
|
5
|
+
export const isContextMenuKey = (event) => event.key === 'ContextMenu' || (event.key === 'F10' && event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey);
|
|
6
|
+
/** Espera entre letras da busca por digitação (APG). */
|
|
7
|
+
const TYPEAHEAD_MS = 500;
|
|
8
|
+
/** Texto comparável da busca por letra: sem diacríticos, caixa pelo idioma. */
|
|
9
|
+
const foldMenuText = (text, lang) => {
|
|
10
|
+
const plain = text.normalize('NFD').replace(/\p{M}/gu, '')
|
|
11
|
+
.trim();
|
|
12
|
+
try {
|
|
13
|
+
return plain.toLocaleLowerCase(lang || undefined);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return plain.toLowerCase();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const resolveTarget = (target) => typeof target === 'function' ? target() : target;
|
|
20
|
+
const isEnabled = (item) => item.getAttribute('aria-disabled') !== 'true';
|
|
21
|
+
export class MenuController {
|
|
22
|
+
#host;
|
|
23
|
+
#panelClass;
|
|
24
|
+
#anchor;
|
|
25
|
+
#shown;
|
|
26
|
+
#restoreFocus;
|
|
27
|
+
#typeahead;
|
|
28
|
+
#typeaheadTimer;
|
|
29
|
+
/** Item pai (chave) do submenu aberto. */
|
|
30
|
+
#submenu;
|
|
31
|
+
#submenuShown;
|
|
32
|
+
/** O submenu abriu pelo teclado: o foco vai ao primeiro item dele. */
|
|
33
|
+
#submenuFocus;
|
|
34
|
+
constructor(host, panelClass) {
|
|
35
|
+
this.#anchor = null;
|
|
36
|
+
this.#shown = false;
|
|
37
|
+
this.#restoreFocus = null;
|
|
38
|
+
this.#typeahead = '';
|
|
39
|
+
/** Item pai (chave) do submenu aberto. */
|
|
40
|
+
this.#submenu = null;
|
|
41
|
+
this.#submenuShown = false;
|
|
42
|
+
/** O submenu abriu pelo teclado: o foco vai ao primeiro item dele. */
|
|
43
|
+
this.#submenuFocus = false;
|
|
44
|
+
this.onKeyDown = (event) => {
|
|
45
|
+
if (event.isComposing) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const target = event.composedPath()[0];
|
|
49
|
+
const submenu = this.#submenuPanel;
|
|
50
|
+
const inSubmenu = !!submenu?.contains(target);
|
|
51
|
+
const items = inSubmenu ? this.#itemsOf(submenu) : this.#items;
|
|
52
|
+
const index = items.indexOf(target);
|
|
53
|
+
const parentKey = inSubmenu ? undefined : target.getAttribute?.('data-submenu') ?? undefined;
|
|
54
|
+
// As setas de abrir/fechar o submenu seguem a direção do texto (RTL troca).
|
|
55
|
+
const rtl = this.#host._isRtl();
|
|
56
|
+
const openKey = rtl ? 'ArrowLeft' : 'ArrowRight';
|
|
57
|
+
const closeKey = rtl ? 'ArrowRight' : 'ArrowLeft';
|
|
58
|
+
let next;
|
|
59
|
+
if (parentKey !== undefined && (event.key === openKey || event.key === 'Enter' || event.key === ' ')) {
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
this.openSubmenu(parentKey, true);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (inSubmenu && (event.key === closeKey || event.key === 'Escape')) {
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
event.stopPropagation();
|
|
67
|
+
this.closeSubmenu(true);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
switch (event.key) {
|
|
71
|
+
case 'ArrowDown':
|
|
72
|
+
next = (index + 1) % items.length;
|
|
73
|
+
break;
|
|
74
|
+
case 'ArrowUp':
|
|
75
|
+
next = (index - 1 + items.length) % items.length;
|
|
76
|
+
break;
|
|
77
|
+
case 'Home':
|
|
78
|
+
next = 0;
|
|
79
|
+
break;
|
|
80
|
+
case 'End':
|
|
81
|
+
next = items.length - 1;
|
|
82
|
+
break;
|
|
83
|
+
case 'Escape':
|
|
84
|
+
event.preventDefault();
|
|
85
|
+
event.stopPropagation();
|
|
86
|
+
this.hide(true);
|
|
87
|
+
return;
|
|
88
|
+
case 'Tab':
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
this.hide(true);
|
|
91
|
+
return;
|
|
92
|
+
default:
|
|
93
|
+
next = this.#typeaheadTarget(event, items, index);
|
|
94
|
+
if (next === undefined) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
const item = items[next];
|
|
100
|
+
// Andar no menu de cima fecha o submenu aberto (o foco sai do item pai).
|
|
101
|
+
if (!inSubmenu && item !== target) {
|
|
102
|
+
this.closeSubmenu();
|
|
103
|
+
}
|
|
104
|
+
item?.focus();
|
|
105
|
+
};
|
|
106
|
+
this.#outsidePointerDown = (event) => {
|
|
107
|
+
const opener = this.#anchor?.opener;
|
|
108
|
+
// O botão que abriu (aria-expanded) trata o próprio clique: fecha, não reabre.
|
|
109
|
+
const keep = event.composedPath().some(target => target instanceof HTMLElement
|
|
110
|
+
&& (target.classList.contains(this.#panelClass)
|
|
111
|
+
|| target.classList.contains(`${this.#panelClass}-submenu`)
|
|
112
|
+
|| (!!opener && target === opener && target.getAttribute('aria-expanded') === 'true')));
|
|
113
|
+
if (!keep) {
|
|
114
|
+
this.hide();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
this.#host = host;
|
|
118
|
+
this.#panelClass = panelClass;
|
|
119
|
+
host.addController(this);
|
|
120
|
+
}
|
|
121
|
+
get open() {
|
|
122
|
+
return this.#anchor !== null;
|
|
123
|
+
}
|
|
124
|
+
get data() {
|
|
125
|
+
return this.#anchor?.data;
|
|
126
|
+
}
|
|
127
|
+
get opener() {
|
|
128
|
+
return this.#anchor?.opener ?? null;
|
|
129
|
+
}
|
|
130
|
+
/** Chave do item cujo submenu está aberto (`null`: nenhum). */
|
|
131
|
+
get submenu() {
|
|
132
|
+
return this.#submenu;
|
|
133
|
+
}
|
|
134
|
+
/** Timer da busca por letra pendente (diagnóstico de memória). */
|
|
135
|
+
get timers() {
|
|
136
|
+
return this.#typeaheadTimer === undefined ? 0 : 1;
|
|
137
|
+
}
|
|
138
|
+
show(anchor) {
|
|
139
|
+
if (this.#anchor) {
|
|
140
|
+
// Outro menu deste controlador: o painel novo se posiciona e recebe o foco de novo.
|
|
141
|
+
this.#submenuPanel?.hidePopover?.();
|
|
142
|
+
this.#panel?.hidePopover?.();
|
|
143
|
+
}
|
|
144
|
+
this.#anchor = anchor;
|
|
145
|
+
this.#shown = false;
|
|
146
|
+
this.#restoreFocus = null;
|
|
147
|
+
this.#resetSubmenu();
|
|
148
|
+
this.#host.requestUpdate();
|
|
149
|
+
}
|
|
150
|
+
/** Fecha; com `restoreFocus`, o foco volta ao disparador depois do render. */
|
|
151
|
+
hide(restoreFocus = false) {
|
|
152
|
+
if (!this.#anchor) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
this.#restoreFocus = restoreFocus ? this.#anchor.returnFocus : null;
|
|
156
|
+
this.#close();
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Fecha e devolve o foco JÁ (no mesmo gesto: a ação do hospedeiro roda com
|
|
160
|
+
* o foco no disparador e a ativação do usuário ainda vale).
|
|
161
|
+
*/
|
|
162
|
+
hideAndFocus() {
|
|
163
|
+
const anchor = this.#anchor;
|
|
164
|
+
if (!anchor) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
this.#restoreFocus = null;
|
|
168
|
+
this.#close();
|
|
169
|
+
const target = resolveTarget(anchor.returnFocus);
|
|
170
|
+
if (target?.isConnected) {
|
|
171
|
+
target.focus();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/** Abre o submenu do item `key`; com `focusFirst` (teclado), o foco vai ao primeiro item dele. */
|
|
175
|
+
openSubmenu(key, focusFirst = false) {
|
|
176
|
+
if (!this.#anchor) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (this.#submenu === key) {
|
|
180
|
+
if (focusFirst) {
|
|
181
|
+
if (this.#submenuShown) {
|
|
182
|
+
this.#focusFirstIn(this.#submenuPanel);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
this.#submenuFocus = true;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
this.#submenuPanel?.hidePopover?.();
|
|
191
|
+
this.#submenu = key;
|
|
192
|
+
this.#submenuShown = false;
|
|
193
|
+
this.#submenuFocus = focusFirst;
|
|
194
|
+
this.#host.requestUpdate();
|
|
195
|
+
}
|
|
196
|
+
/** Fecha o submenu; com `focusParent`, o foco volta ao item que o abriu. */
|
|
197
|
+
closeSubmenu(focusParent = false) {
|
|
198
|
+
const key = this.#submenu;
|
|
199
|
+
if (key === null) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const parent = this.#parentItem(key);
|
|
203
|
+
const submenu = this.#submenuPanel;
|
|
204
|
+
const active = this.#host.renderRoot.activeElement;
|
|
205
|
+
// O foco estava no submenu (que sai do DOM): volta ao pai, nunca ao <body> (fechado pelo ponteiro também).
|
|
206
|
+
const hadFocus = !!active && !!submenu?.contains(active);
|
|
207
|
+
submenu?.hidePopover?.();
|
|
208
|
+
this.#resetSubmenu();
|
|
209
|
+
this.#host.requestUpdate();
|
|
210
|
+
if (focusParent || hadFocus) {
|
|
211
|
+
parent?.focus();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/** Ponteiro sobre um item do menu de cima: abre o submenu dele (sem foco) ou fecha o aberto. */
|
|
215
|
+
hoverItem(key, hasSubmenu) {
|
|
216
|
+
if (hasSubmenu) {
|
|
217
|
+
this.openSubmenu(key);
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
this.closeSubmenu();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
#resetSubmenu() {
|
|
224
|
+
this.#submenu = null;
|
|
225
|
+
this.#submenuShown = false;
|
|
226
|
+
this.#submenuFocus = false;
|
|
227
|
+
}
|
|
228
|
+
#close() {
|
|
229
|
+
this.#anchor = null;
|
|
230
|
+
this.#clearTypeahead();
|
|
231
|
+
this.#submenuPanel?.hidePopover?.();
|
|
232
|
+
this.#resetSubmenu();
|
|
233
|
+
this.#panel?.hidePopover?.();
|
|
234
|
+
document.removeEventListener('pointerdown', this.#outsidePointerDown, true);
|
|
235
|
+
this.#host.requestUpdate();
|
|
236
|
+
}
|
|
237
|
+
get #panel() {
|
|
238
|
+
return this.#host.renderRoot.querySelector(`.${this.#panelClass}`);
|
|
239
|
+
}
|
|
240
|
+
get #submenuPanel() {
|
|
241
|
+
return this.#host.renderRoot.querySelector(`.${this.#panelClass}-submenu`);
|
|
242
|
+
}
|
|
243
|
+
/** Itens de um painel: `menuitem` e `menuitemradio` (também dentro de `group`). */
|
|
244
|
+
#itemsOf(panel) {
|
|
245
|
+
return [...panel?.querySelectorAll('[role^=menuitem]') ?? []];
|
|
246
|
+
}
|
|
247
|
+
get #items() {
|
|
248
|
+
return this.#itemsOf(this.#panel);
|
|
249
|
+
}
|
|
250
|
+
#parentItem(key) {
|
|
251
|
+
return this.#items.find(item => item.getAttribute('data-submenu') === key) ?? null;
|
|
252
|
+
}
|
|
253
|
+
#focusFirstIn(panel) {
|
|
254
|
+
const items = this.#itemsOf(panel);
|
|
255
|
+
(items.find(isEnabled) ?? items[0])?.focus();
|
|
256
|
+
}
|
|
257
|
+
hostUpdated() {
|
|
258
|
+
if (!this.#anchor) {
|
|
259
|
+
const target = resolveTarget(this.#restoreFocus);
|
|
260
|
+
this.#restoreFocus = null;
|
|
261
|
+
if (target?.isConnected) {
|
|
262
|
+
target.focus();
|
|
263
|
+
}
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const panel = this.#panel;
|
|
267
|
+
if (!panel) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (!this.#shown) {
|
|
271
|
+
this.#shown = true;
|
|
272
|
+
if (typeof panel.showPopover === 'function' && !panel.matches(':popover-open')) {
|
|
273
|
+
panel.showPopover();
|
|
274
|
+
}
|
|
275
|
+
this.#position(panel, this.#anchor);
|
|
276
|
+
document.addEventListener('pointerdown', this.#outsidePointerDown, true);
|
|
277
|
+
const items = this.#items;
|
|
278
|
+
const enabled = items.filter(isEnabled);
|
|
279
|
+
((this.#anchor.focusLast ? enabled[enabled.length - 1] : enabled[0]) ?? items[0])?.focus();
|
|
280
|
+
}
|
|
281
|
+
this.#showSubmenu();
|
|
282
|
+
}
|
|
283
|
+
/** Submenu pedido e ainda não mostrado: camada do topo, ao lado do item pai, foco (teclado). */
|
|
284
|
+
#showSubmenu() {
|
|
285
|
+
const key = this.#submenu;
|
|
286
|
+
if (key === null || this.#submenuShown) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const submenu = this.#submenuPanel;
|
|
290
|
+
const parent = this.#parentItem(key);
|
|
291
|
+
// O item pai não existe neste menu: nada a abrir.
|
|
292
|
+
if (!submenu || !parent) {
|
|
293
|
+
this.#resetSubmenu();
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
this.#submenuShown = true;
|
|
297
|
+
if (typeof submenu.showPopover === 'function' && !submenu.matches(':popover-open')) {
|
|
298
|
+
submenu.showPopover();
|
|
299
|
+
}
|
|
300
|
+
this.#positionSubmenu(submenu, parent);
|
|
301
|
+
if (this.#submenuFocus) {
|
|
302
|
+
this.#submenuFocus = false;
|
|
303
|
+
this.#focusFirstIn(submenu);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
hostDisconnected() {
|
|
307
|
+
document.removeEventListener('pointerdown', this.#outsidePointerDown, true);
|
|
308
|
+
this.#anchor = null;
|
|
309
|
+
this.#shown = false;
|
|
310
|
+
this.#restoreFocus = null;
|
|
311
|
+
this.#resetSubmenu();
|
|
312
|
+
this.#clearTypeahead();
|
|
313
|
+
}
|
|
314
|
+
/** Foca o item `index` (os itens do painel atual). */
|
|
315
|
+
focusItem(index) {
|
|
316
|
+
const items = this.#items;
|
|
317
|
+
items[(index + items.length) % items.length]?.focus();
|
|
318
|
+
}
|
|
319
|
+
/** Busca por letra (APG): sem modificadores, Espaço fora; várias letras em 500 ms; sem achar, não move. */
|
|
320
|
+
#typeaheadTarget(event, items, index) {
|
|
321
|
+
if (event.key.length !== 1 || event.key === ' ' || event.ctrlKey || event.altKey || event.metaKey || !items.length) {
|
|
322
|
+
return undefined;
|
|
323
|
+
}
|
|
324
|
+
const panel = items[0].closest('[role=menu]') ?? this.#panel;
|
|
325
|
+
const lang = panel?.closest('[lang]')?.getAttribute('lang') ?? undefined;
|
|
326
|
+
const char = foldMenuText(event.key, lang);
|
|
327
|
+
clearTimeout(this.#typeaheadTimer);
|
|
328
|
+
this.#typeahead += char;
|
|
329
|
+
this.#typeaheadTimer = setTimeout(() => this.#clearTypeahead(), TYPEAHEAD_MS);
|
|
330
|
+
const buffer = this.#typeahead;
|
|
331
|
+
// A mesma letra repetida circula entre os itens que começam com ela.
|
|
332
|
+
const repeated = buffer.length > 1 && buffer.split(char).every(part => part === '');
|
|
333
|
+
const search = repeated ? char : buffer;
|
|
334
|
+
const start = buffer.length === 1 || repeated ? index + 1 : index;
|
|
335
|
+
for (let offset = 0; offset < items.length; offset++) {
|
|
336
|
+
const candidate = (start + offset + items.length) % items.length;
|
|
337
|
+
const item = items[candidate];
|
|
338
|
+
const text = foldMenuText(item.querySelector('.menu-item-text')?.textContent ?? item.textContent ?? '', item.closest('[lang]')?.getAttribute('lang') ?? lang);
|
|
339
|
+
if (text.startsWith(search)) {
|
|
340
|
+
return candidate;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
// `undefined` deixaria a tecla seguir; sem achar, o foco fica onde está.
|
|
344
|
+
return index >= 0 ? index : 0;
|
|
345
|
+
}
|
|
346
|
+
#clearTypeahead() {
|
|
347
|
+
clearTimeout(this.#typeaheadTimer);
|
|
348
|
+
this.#typeaheadTimer = undefined;
|
|
349
|
+
this.#typeahead = '';
|
|
350
|
+
}
|
|
351
|
+
#position(panel, anchor) {
|
|
352
|
+
const margin = 8;
|
|
353
|
+
const width = panel.offsetWidth;
|
|
354
|
+
const height = panel.offsetHeight;
|
|
355
|
+
const viewportWidth = document.documentElement.clientWidth;
|
|
356
|
+
const viewportHeight = document.documentElement.clientHeight;
|
|
357
|
+
let left;
|
|
358
|
+
let top;
|
|
359
|
+
if (anchor.x !== undefined && anchor.y !== undefined) {
|
|
360
|
+
left = this.#host._isRtl() ? anchor.x - width : anchor.x;
|
|
361
|
+
top = anchor.y;
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
const target = anchor.positionTarget ?? resolveTarget(anchor.returnFocus) ?? this.#host;
|
|
365
|
+
const rect = target.getBoundingClientRect();
|
|
366
|
+
left = this.#host._isRtl() ? rect.right - width : rect.left;
|
|
367
|
+
top = rect.bottom + 4;
|
|
368
|
+
// Sem espaço embaixo: abre acima do disparador.
|
|
369
|
+
if (top + height > viewportHeight - margin && rect.top - height - 4 >= margin) {
|
|
370
|
+
top = rect.top - height - 4;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
panel.style.left = `${Math.round(Math.max(margin, Math.min(left, viewportWidth - width - margin)))}px`;
|
|
374
|
+
panel.style.top = `${Math.round(Math.max(margin, Math.min(top, viewportHeight - height - margin)))}px`;
|
|
375
|
+
}
|
|
376
|
+
/** Ao lado do item pai (no lado do fim; sem espaço, no outro), preso à janela. */
|
|
377
|
+
#positionSubmenu(submenu, parent) {
|
|
378
|
+
const margin = 8;
|
|
379
|
+
const rect = parent.getBoundingClientRect();
|
|
380
|
+
const width = submenu.offsetWidth;
|
|
381
|
+
const height = submenu.offsetHeight;
|
|
382
|
+
const viewportWidth = document.documentElement.clientWidth;
|
|
383
|
+
const viewportHeight = document.documentElement.clientHeight;
|
|
384
|
+
const rtl = this.#host._isRtl();
|
|
385
|
+
let left = rtl ? rect.left - width : rect.right;
|
|
386
|
+
if (!rtl && left + width > viewportWidth - margin && rect.left - width >= margin) {
|
|
387
|
+
left = rect.left - width;
|
|
388
|
+
}
|
|
389
|
+
else if (rtl && left < margin && rect.right + width <= viewportWidth - margin) {
|
|
390
|
+
left = rect.right;
|
|
391
|
+
}
|
|
392
|
+
// O 1º item na altura do pai (o painel tem 8px de respiro em cima).
|
|
393
|
+
const top = rect.top - 8;
|
|
394
|
+
submenu.style.left = `${Math.round(Math.max(margin, Math.min(left, viewportWidth - width - margin)))}px`;
|
|
395
|
+
submenu.style.top = `${Math.round(Math.max(margin, Math.min(top, viewportHeight - height - margin)))}px`;
|
|
396
|
+
}
|
|
397
|
+
#outsidePointerDown;
|
|
398
|
+
}
|
|
399
|
+
/** Seta do item com submenu (espelhada em RTL pelo CSS). */
|
|
400
|
+
const submenuArrow = svg `<path d="M9.3 6.7 10.7 5.3l6.7 6.7-6.7 6.7-1.4-1.4 5.3-5.3z"/>`;
|
|
401
|
+
/** Marca do `menuitemradio` marcado. */
|
|
402
|
+
const checkMark = svg `<path d="M9.5 16.2 5.3 12l-1.4 1.4 5.6 5.6 11-11-1.4-1.4z"/>`;
|
|
403
|
+
const renderItem = (entry, context, submenuId, inSubmenu) => {
|
|
404
|
+
const { onAction, onDisabledAction, controller } = context;
|
|
405
|
+
const parent = !inSubmenu && !!entry.children?.length && !!controller;
|
|
406
|
+
const expanded = parent && controller.submenu === entry.key;
|
|
407
|
+
const radio = entry.checked !== undefined;
|
|
408
|
+
return html `<button
|
|
409
|
+
class="menu-item group-panel-menu-item ${parent ? 'menu-item-parent' : ''} ${radio ? 'menu-item-radio' : ''}"
|
|
410
|
+
part="menu-item"
|
|
411
|
+
type="button"
|
|
412
|
+
role=${radio ? 'menuitemradio' : 'menuitem'}
|
|
413
|
+
tabindex="-1"
|
|
414
|
+
lang=${ifDefined(entry.lang)}
|
|
415
|
+
data-submenu=${ifDefined(parent ? entry.key : undefined)}
|
|
416
|
+
aria-haspopup=${ifDefined(parent ? 'menu' : entry.hasPopup)}
|
|
417
|
+
aria-expanded=${ifDefined(parent ? (expanded ? 'true' : 'false') : undefined)}
|
|
418
|
+
aria-controls=${ifDefined(expanded ? submenuId : undefined)}
|
|
419
|
+
aria-checked=${ifDefined(radio ? (entry.checked ? 'true' : 'false') : undefined)}
|
|
420
|
+
aria-disabled=${entry.disabled ? 'true' : 'false'}
|
|
421
|
+
@pointerenter=${!inSubmenu && controller
|
|
422
|
+
? (event) => {
|
|
423
|
+
if (event.pointerType !== 'touch') {
|
|
424
|
+
controller.hoverItem(entry.key, parent);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
: nothing}
|
|
428
|
+
@click=${() => {
|
|
429
|
+
if (parent) {
|
|
430
|
+
if (expanded) {
|
|
431
|
+
controller.closeSubmenu();
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
controller.openSubmenu(entry.key);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
else if (entry.disabled) {
|
|
438
|
+
onDisabledAction?.(entry.key);
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
onAction(entry.key);
|
|
442
|
+
}
|
|
443
|
+
}}>${radio
|
|
444
|
+
? html `<svg class="menu-item-check" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="18" height="18" fill="currentColor" aria-hidden="true">${entry.checked ? checkMark : nothing}</svg>`
|
|
445
|
+
: nothing}<span class="menu-item-text">${entry.label}</span>${entry.hiddenSuffix
|
|
446
|
+
? html `<span class="visually-hidden" lang=${ifDefined(entry.suffixLang)}> ${entry.hiddenSuffix}</span>`
|
|
447
|
+
: nothing}${parent
|
|
448
|
+
? html `<svg class="menu-item-arrow" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="18" height="18" fill="currentColor" aria-hidden="true">${submenuArrow}</svg>`
|
|
449
|
+
: nothing}</button>`;
|
|
450
|
+
};
|
|
451
|
+
const renderEntries = (entries, context, submenuId, inSubmenu) => map(entries, (entry, index) => html `${entry.separatorBefore && index > 0
|
|
452
|
+
? html `<div class="menu-separator" part="menu-separator" role="separator"></div>`
|
|
453
|
+
: nothing}${renderItem(entry, context, submenuId, inSubmenu)}`);
|
|
454
|
+
/**
|
|
455
|
+
* O menu (sem estado): itens com foco móvel e separadores. O submenu aberto
|
|
456
|
+
* vem como painel irmão (`role="menu"` com um `group` nomeado pelo item pai),
|
|
457
|
+
* também na camada do topo.
|
|
458
|
+
*/
|
|
459
|
+
export const renderMenu = (context) => {
|
|
460
|
+
const { className, part, label, labelledBy, labelLang, entries, onKeyDown, controller } = context;
|
|
461
|
+
const submenuId = `${className.split(' ')[0]}-submenu`;
|
|
462
|
+
const open = controller?.submenu ?? null;
|
|
463
|
+
const parent = open === null ? undefined : entries.find(entry => entry.key === open && entry.children?.length);
|
|
464
|
+
return html `
|
|
465
|
+
<div
|
|
466
|
+
class="grid-menu ${className}"
|
|
467
|
+
part=${part}
|
|
468
|
+
.popover=${'manual'}
|
|
469
|
+
role="menu"
|
|
470
|
+
lang=${ifDefined(labelLang)}
|
|
471
|
+
aria-label=${ifDefined(label)}
|
|
472
|
+
aria-labelledby=${ifDefined(labelledBy)}
|
|
473
|
+
@contextmenu=${(event) => event.preventDefault()}
|
|
474
|
+
@keydown=${onKeyDown}>
|
|
475
|
+
${renderEntries(entries, context, submenuId, false)}
|
|
476
|
+
</div>${parent
|
|
477
|
+
? html `<div
|
|
478
|
+
class="grid-menu grid-submenu ${submenuId}"
|
|
479
|
+
id=${submenuId}
|
|
480
|
+
part=${part}
|
|
481
|
+
.popover=${'manual'}
|
|
482
|
+
role="menu"
|
|
483
|
+
lang=${ifDefined(labelLang)}
|
|
484
|
+
aria-label=${parent.label}
|
|
485
|
+
@contextmenu=${(event) => event.preventDefault()}
|
|
486
|
+
@keydown=${onKeyDown}>
|
|
487
|
+
<div class="menu-group" role="group" aria-label=${parent.label} lang=${ifDefined(parent.lang)}>${renderEntries(parent.children, context, submenuId, true)}</div>
|
|
488
|
+
</div>`
|
|
489
|
+
: nothing}`;
|
|
490
|
+
};
|
|
491
|
+
//# sourceMappingURL=menu.js.map
|