@vaadin/menu-bar 25.0.0-alpha6 → 25.0.0-alpha8
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/package.json +16 -14
- package/src/styles/vaadin-menu-bar-base-styles.d.ts +8 -0
- package/src/styles/vaadin-menu-bar-base-styles.js +56 -0
- package/src/styles/vaadin-menu-bar-button-base-styles.d.ts +8 -0
- package/src/styles/vaadin-menu-bar-button-base-styles.js +47 -0
- package/src/styles/vaadin-menu-bar-item-base-styles.d.ts +8 -0
- package/src/styles/vaadin-menu-bar-item-base-styles.js +8 -0
- package/src/styles/vaadin-menu-bar-item-core-styles.d.ts +8 -0
- package/src/styles/vaadin-menu-bar-item-core-styles.js +8 -0
- package/src/styles/vaadin-menu-bar-overlay-base-styles.d.ts +8 -0
- package/src/styles/vaadin-menu-bar-overlay-base-styles.js +9 -0
- package/src/vaadin-menu-bar-item.js +3 -3
- package/src/vaadin-menu-bar-list-box.js +1 -1
- package/src/vaadin-menu-bar-mixin.js +86 -113
- package/src/vaadin-menu-bar-overlay.js +1 -1
- package/src/vaadin-menu-bar-submenu-mixin.js +1 -1
- package/src/vaadin-menu-bar.d.ts +2 -2
- package/src/vaadin-menu-bar.js +6 -5
- package/web-types.json +2 -2
- package/web-types.lit.json +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/menu-bar",
|
|
3
|
-
"version": "25.0.0-
|
|
3
|
+
"version": "25.0.0-alpha8",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
"type": "module",
|
|
22
22
|
"files": [
|
|
23
23
|
"src",
|
|
24
|
+
"!src/styles/*-base-styles.d.ts",
|
|
25
|
+
"!src/styles/*-base-styles.js",
|
|
24
26
|
"theme",
|
|
25
27
|
"vaadin-*.d.ts",
|
|
26
28
|
"vaadin-*.js",
|
|
@@ -35,21 +37,21 @@
|
|
|
35
37
|
],
|
|
36
38
|
"dependencies": {
|
|
37
39
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
38
|
-
"@vaadin/a11y-base": "25.0.0-
|
|
39
|
-
"@vaadin/button": "25.0.0-
|
|
40
|
-
"@vaadin/component-base": "25.0.0-
|
|
41
|
-
"@vaadin/context-menu": "25.0.0-
|
|
42
|
-
"@vaadin/item": "25.0.0-
|
|
43
|
-
"@vaadin/list-box": "25.0.0-
|
|
44
|
-
"@vaadin/overlay": "25.0.0-
|
|
45
|
-
"@vaadin/vaadin-lumo-styles": "25.0.0-
|
|
46
|
-
"@vaadin/vaadin-themable-mixin": "25.0.0-
|
|
40
|
+
"@vaadin/a11y-base": "25.0.0-alpha8",
|
|
41
|
+
"@vaadin/button": "25.0.0-alpha8",
|
|
42
|
+
"@vaadin/component-base": "25.0.0-alpha8",
|
|
43
|
+
"@vaadin/context-menu": "25.0.0-alpha8",
|
|
44
|
+
"@vaadin/item": "25.0.0-alpha8",
|
|
45
|
+
"@vaadin/list-box": "25.0.0-alpha8",
|
|
46
|
+
"@vaadin/overlay": "25.0.0-alpha8",
|
|
47
|
+
"@vaadin/vaadin-lumo-styles": "25.0.0-alpha8",
|
|
48
|
+
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha8",
|
|
47
49
|
"lit": "^3.0.0"
|
|
48
50
|
},
|
|
49
51
|
"devDependencies": {
|
|
50
|
-
"@vaadin/chai-plugins": "25.0.0-
|
|
51
|
-
"@vaadin/icon": "25.0.0-
|
|
52
|
-
"@vaadin/test-runner-commands": "25.0.0-
|
|
52
|
+
"@vaadin/chai-plugins": "25.0.0-alpha8",
|
|
53
|
+
"@vaadin/icon": "25.0.0-alpha8",
|
|
54
|
+
"@vaadin/test-runner-commands": "25.0.0-alpha8",
|
|
53
55
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
54
56
|
"sinon": "^18.0.0"
|
|
55
57
|
},
|
|
@@ -57,5 +59,5 @@
|
|
|
57
59
|
"web-types.json",
|
|
58
60
|
"web-types.lit.json"
|
|
59
61
|
],
|
|
60
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "ebf53673d5f639d2b1b6f2b31f640f530643ee2f"
|
|
61
63
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2019 - 2025 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { css } from 'lit';
|
|
7
|
+
|
|
8
|
+
export const menuBarStyles = css`
|
|
9
|
+
:host {
|
|
10
|
+
display: block;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
:host([hidden]) {
|
|
14
|
+
display: none !important;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[part='container'] {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-wrap: nowrap;
|
|
20
|
+
margin: calc((var(--vaadin-focus-ring-width) + 1px) * -1);
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
padding: calc(var(--vaadin-focus-ring-width) + 1px);
|
|
23
|
+
position: relative;
|
|
24
|
+
width: 100%;
|
|
25
|
+
/* stylelint-disable length-zero-no-unit */
|
|
26
|
+
--_gap: var(--vaadin-menu-bar-gap, 0px);
|
|
27
|
+
--_bw: var(--vaadin-button-border-width, 1px);
|
|
28
|
+
gap: var(--_gap);
|
|
29
|
+
--_rad-button: var(--vaadin-button-border-radius, var(--vaadin-radius-m));
|
|
30
|
+
--_rad: min(var(--_gap) * 1000, var(--_rad-button));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
::slotted(vaadin-menu-bar-button:not(:first-of-type)) {
|
|
34
|
+
margin-inline-start: min(var(--_bw) * -1 + var(--_gap) * 1000, 0px);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
::slotted(vaadin-menu-bar-button) {
|
|
38
|
+
border-radius: var(--_rad);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
::slotted([first-visible]),
|
|
42
|
+
:host([has-single-button]) ::slotted([slot='overflow']) {
|
|
43
|
+
border-start-start-radius: var(--_rad-button);
|
|
44
|
+
border-end-start-radius: var(--_rad-button);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
::slotted(:is([last-visible], [slot='overflow'])) {
|
|
48
|
+
border-start-end-radius: var(--_rad-button);
|
|
49
|
+
border-end-end-radius: var(--_rad-button);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
:host([theme~='end-aligned']) ::slotted(vaadin-menu-bar-button[first-visible]),
|
|
53
|
+
:host([theme~='end-aligned'][has-single-button]) ::slotted(vaadin-menu-bar-button) {
|
|
54
|
+
margin-inline-start: auto;
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2019 - 2025 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { css } from 'lit';
|
|
7
|
+
|
|
8
|
+
export const menuBarButtonStyles = css`
|
|
9
|
+
:host {
|
|
10
|
+
flex-shrink: 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
:host([focus-ring]) {
|
|
14
|
+
z-index: 1;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
:host([slot='overflow']) {
|
|
18
|
+
margin-inline-end: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.vaadin-button-container {
|
|
22
|
+
gap: inherit;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
:host(:not([slot='overflow']):not([theme~='icon'])[aria-haspopup]) [part='suffix'] {
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
gap: inherit;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
:host(:not([slot='overflow']):not([theme~='icon'])[aria-haspopup]) [part='suffix']::after {
|
|
32
|
+
background: currentColor;
|
|
33
|
+
content: '';
|
|
34
|
+
height: var(--vaadin-icon-size, 1lh);
|
|
35
|
+
mask-image: var(--_vaadin-icon-chevron-down);
|
|
36
|
+
width: var(--vaadin-icon-size, 1lh);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
::slotted(vaadin-menu-bar-item) {
|
|
40
|
+
padding: 0;
|
|
41
|
+
gap: 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
::slotted(vaadin-menu-bar-item)::after {
|
|
45
|
+
display: none;
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2019 - 2025 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { contextMenuItemStyles } from '@vaadin/context-menu/src/styles/vaadin-context-menu-item-base-styles.js';
|
|
7
|
+
|
|
8
|
+
export const menuBarItemStyles = contextMenuItemStyles;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2019 - 2025 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { itemStyles } from '@vaadin/item/src/styles/vaadin-item-core-styles.js';
|
|
7
|
+
|
|
8
|
+
export const menuBarItemStyles = [itemStyles];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2025 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { menuOverlayStyles } from '@vaadin/context-menu/src/styles/vaadin-menu-overlay-base-styles.js';
|
|
7
|
+
import { overlayStyles } from '@vaadin/overlay/src/styles/vaadin-overlay-base-styles.js';
|
|
8
|
+
|
|
9
|
+
export const menuBarOverlayStyles = [overlayStyles, menuOverlayStyles];
|
|
@@ -7,10 +7,10 @@ import { html, LitElement } from 'lit';
|
|
|
7
7
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
8
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
9
9
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
10
|
-
import { itemStyles } from '@vaadin/item/src/styles/vaadin-item-core-styles.js';
|
|
11
10
|
import { ItemMixin } from '@vaadin/item/src/vaadin-item-mixin.js';
|
|
12
11
|
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
13
12
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
13
|
+
import { menuBarItemStyles } from './styles/vaadin-menu-bar-item-core-styles.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* An element used internally by `<vaadin-menu-bar>`. Not intended to be used separately.
|
|
@@ -22,13 +22,13 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
22
22
|
* @mixes ThemableMixin
|
|
23
23
|
* @protected
|
|
24
24
|
*/
|
|
25
|
-
class MenuBarItem extends ItemMixin(ThemableMixin(DirMixin(LumoInjectionMixin(
|
|
25
|
+
class MenuBarItem extends ItemMixin(ThemableMixin(DirMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
|
|
26
26
|
static get is() {
|
|
27
27
|
return 'vaadin-menu-bar-item';
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
static get styles() {
|
|
31
|
-
return
|
|
31
|
+
return menuBarItemStyles;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/** @protected */
|
|
@@ -22,7 +22,7 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
22
22
|
* @mixes ThemableMixin
|
|
23
23
|
* @protected
|
|
24
24
|
*/
|
|
25
|
-
class MenuBarListBox extends ListMixin(ThemableMixin(DirMixin(LumoInjectionMixin(
|
|
25
|
+
class MenuBarListBox extends ListMixin(ThemableMixin(DirMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
|
|
26
26
|
static get is() {
|
|
27
27
|
return 'vaadin-menu-bar-list-box';
|
|
28
28
|
}
|
|
@@ -191,41 +191,9 @@ export const MenuBarMixin = (superClass) =>
|
|
|
191
191
|
type: Boolean,
|
|
192
192
|
sync: true,
|
|
193
193
|
},
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* @type {boolean}
|
|
197
|
-
* @protected
|
|
198
|
-
*/
|
|
199
|
-
_hasOverflow: {
|
|
200
|
-
type: Boolean,
|
|
201
|
-
value: false,
|
|
202
|
-
sync: true,
|
|
203
|
-
},
|
|
204
|
-
|
|
205
|
-
/** @protected */
|
|
206
|
-
_overflow: {
|
|
207
|
-
type: Object,
|
|
208
|
-
},
|
|
209
|
-
|
|
210
|
-
/** @protected */
|
|
211
|
-
_container: {
|
|
212
|
-
type: Object,
|
|
213
|
-
sync: true,
|
|
214
|
-
},
|
|
215
194
|
};
|
|
216
195
|
}
|
|
217
196
|
|
|
218
|
-
static get observers() {
|
|
219
|
-
return [
|
|
220
|
-
'_themeChanged(_theme, _overflow, _container)',
|
|
221
|
-
'__hasOverflowChanged(_hasOverflow, _overflow)',
|
|
222
|
-
'__i18nChanged(__effectiveI18n, _overflow)',
|
|
223
|
-
'__updateButtons(items, disabled, _overflow, _container)',
|
|
224
|
-
'_reverseCollapseChanged(reverseCollapse, _overflow, _container)',
|
|
225
|
-
'_tabNavigationChanged(tabNavigation, _overflow, _container)',
|
|
226
|
-
];
|
|
227
|
-
}
|
|
228
|
-
|
|
229
197
|
/**
|
|
230
198
|
* The object used to localize this component. To change the default
|
|
231
199
|
* localization, replace this with an object that provides all properties, or
|
|
@@ -307,8 +275,15 @@ export const MenuBarMixin = (superClass) =>
|
|
|
307
275
|
}
|
|
308
276
|
|
|
309
277
|
/** @private */
|
|
310
|
-
get
|
|
311
|
-
return this.
|
|
278
|
+
get _hasOverflow() {
|
|
279
|
+
return this._overflow && !this._overflow.hasAttribute('hidden');
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** @private */
|
|
283
|
+
set _hasOverflow(hasOverflow) {
|
|
284
|
+
if (this._overflow) {
|
|
285
|
+
this._overflow.toggleAttribute('hidden', !hasOverflow);
|
|
286
|
+
}
|
|
312
287
|
}
|
|
313
288
|
|
|
314
289
|
/** @protected */
|
|
@@ -317,6 +292,20 @@ export const MenuBarMixin = (superClass) =>
|
|
|
317
292
|
|
|
318
293
|
this.setAttribute('role', 'menubar');
|
|
319
294
|
|
|
295
|
+
this._subMenuController = new SlotController(this, 'submenu', 'vaadin-menu-bar-submenu', {
|
|
296
|
+
initializer: (menu) => {
|
|
297
|
+
menu.setAttribute('is-root', '');
|
|
298
|
+
|
|
299
|
+
menu.addEventListener('item-selected', this.__onItemSelected.bind(this));
|
|
300
|
+
menu.addEventListener('close-all-menus', this.__onEscapeClose.bind(this));
|
|
301
|
+
|
|
302
|
+
const overlay = menu._overlayElement;
|
|
303
|
+
overlay.addEventListener('keydown', this.__boundOnContextMenuKeydown);
|
|
304
|
+
|
|
305
|
+
this._subMenu = menu;
|
|
306
|
+
},
|
|
307
|
+
});
|
|
308
|
+
|
|
320
309
|
this._overflowController = new SlotController(this, 'overflow', 'vaadin-menu-bar-button', {
|
|
321
310
|
initializer: (btn) => {
|
|
322
311
|
btn.setAttribute('hidden', '');
|
|
@@ -333,21 +322,51 @@ export const MenuBarMixin = (superClass) =>
|
|
|
333
322
|
this._overflow = btn;
|
|
334
323
|
},
|
|
335
324
|
});
|
|
325
|
+
|
|
326
|
+
this.addController(this._subMenuController);
|
|
336
327
|
this.addController(this._overflowController);
|
|
337
328
|
|
|
338
329
|
this.addEventListener('mousedown', () => this._hideTooltip(true));
|
|
339
330
|
this.addEventListener('mouseleave', () => this._hideTooltip());
|
|
340
331
|
|
|
341
|
-
this.
|
|
342
|
-
|
|
332
|
+
this._container = this.shadowRoot.querySelector('[part="container"]');
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/** @protected */
|
|
336
|
+
updated(props) {
|
|
337
|
+
super.updated(props);
|
|
343
338
|
|
|
344
|
-
|
|
345
|
-
|
|
339
|
+
if (props.has('items') || props.has('_theme') || props.has('disabled')) {
|
|
340
|
+
this.__renderButtons(this.items);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (props.has('items') || props.has('_theme') || props.has('reverseCollapse')) {
|
|
344
|
+
this.__scheduleOverflow();
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (props.has('items')) {
|
|
348
|
+
this.__updateSubMenu();
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (props.has('overlayClass')) {
|
|
352
|
+
this._subMenu.overlayClass = this.overlayClass;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (props.has('_theme')) {
|
|
356
|
+
this._themeChanged(this._theme);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (props.has('disabled')) {
|
|
360
|
+
this._overflow.toggleAttribute('disabled', this.disabled);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (props.has('tabNavigation')) {
|
|
364
|
+
this._tabNavigationChanged(this.tabNavigation);
|
|
365
|
+
}
|
|
346
366
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
this._container = container;
|
|
367
|
+
if (props.has('__effectiveI18n')) {
|
|
368
|
+
this.__i18nChanged(this.__effectiveI18n);
|
|
369
|
+
}
|
|
351
370
|
}
|
|
352
371
|
|
|
353
372
|
/**
|
|
@@ -379,81 +398,34 @@ export const MenuBarMixin = (superClass) =>
|
|
|
379
398
|
this.__scheduleOverflow();
|
|
380
399
|
}
|
|
381
400
|
|
|
382
|
-
/**
|
|
383
|
-
* A callback for the `_theme` property observer.
|
|
384
|
-
* It propagates the host theme to the buttons and the sub menu.
|
|
385
|
-
*
|
|
386
|
-
* @param {string | null} theme
|
|
387
|
-
* @private
|
|
388
|
-
*/
|
|
389
|
-
_themeChanged(theme, overflow, container) {
|
|
390
|
-
if (overflow && container) {
|
|
391
|
-
this.__renderButtons(this.items);
|
|
392
|
-
this.__scheduleOverflow();
|
|
393
|
-
|
|
394
|
-
if (theme) {
|
|
395
|
-
overflow.setAttribute('theme', theme);
|
|
396
|
-
this._subMenu.setAttribute('theme', theme);
|
|
397
|
-
} else {
|
|
398
|
-
overflow.removeAttribute('theme');
|
|
399
|
-
this._subMenu.removeAttribute('theme');
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
* A callback for the 'reverseCollapse' property observer.
|
|
406
|
-
*
|
|
407
|
-
* @param {boolean | null} _reverseCollapse
|
|
408
|
-
* @private
|
|
409
|
-
*/
|
|
410
|
-
_reverseCollapseChanged(_reverseCollapse, overflow, container) {
|
|
411
|
-
if (overflow && container) {
|
|
412
|
-
this.__scheduleOverflow();
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
401
|
/** @private */
|
|
417
|
-
|
|
418
|
-
if (
|
|
419
|
-
|
|
420
|
-
this.
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
this._setTabindex(btn, false);
|
|
425
|
-
}
|
|
426
|
-
btn.setAttribute('role', tabNavigation ? 'button' : 'menuitem');
|
|
427
|
-
});
|
|
402
|
+
_themeChanged(theme) {
|
|
403
|
+
if (theme) {
|
|
404
|
+
this._overflow.setAttribute('theme', theme);
|
|
405
|
+
this._subMenu.setAttribute('theme', theme);
|
|
406
|
+
} else {
|
|
407
|
+
this._overflow.removeAttribute('theme');
|
|
408
|
+
this._subMenu.removeAttribute('theme');
|
|
428
409
|
}
|
|
429
|
-
this.setAttribute('role', tabNavigation ? 'group' : 'menubar');
|
|
430
410
|
}
|
|
431
411
|
|
|
432
412
|
/** @private */
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
413
|
+
_tabNavigationChanged(tabNavigation) {
|
|
414
|
+
const target = this.querySelector('[tabindex="0"]');
|
|
415
|
+
this._buttons.forEach((btn) => {
|
|
416
|
+
if (target) {
|
|
417
|
+
this._setTabindex(btn, btn === target);
|
|
418
|
+
} else {
|
|
419
|
+
this._setTabindex(btn, false);
|
|
420
|
+
}
|
|
421
|
+
btn.setAttribute('role', tabNavigation ? 'button' : 'menuitem');
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
this.setAttribute('role', tabNavigation ? 'group' : 'menubar');
|
|
437
425
|
}
|
|
438
426
|
|
|
439
427
|
/** @private */
|
|
440
|
-
|
|
441
|
-
if (!overflow || !container) {
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
if (items !== this._oldItems) {
|
|
446
|
-
this._oldItems = items;
|
|
447
|
-
this.__renderButtons(items);
|
|
448
|
-
this.__scheduleOverflow();
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
if (disabled !== this._oldDisabled) {
|
|
452
|
-
this._oldDisabled = disabled;
|
|
453
|
-
this.__renderButtons(items);
|
|
454
|
-
overflow.toggleAttribute('disabled', disabled);
|
|
455
|
-
}
|
|
456
|
-
|
|
428
|
+
__updateSubMenu() {
|
|
457
429
|
const subMenu = this._subMenu;
|
|
458
430
|
if (subMenu && subMenu.opened) {
|
|
459
431
|
const button = subMenu._overlayElement.positionTarget;
|
|
@@ -467,12 +439,12 @@ export const MenuBarMixin = (superClass) =>
|
|
|
467
439
|
}
|
|
468
440
|
|
|
469
441
|
/** @private */
|
|
470
|
-
__i18nChanged(effectiveI18n
|
|
471
|
-
if (
|
|
442
|
+
__i18nChanged(effectiveI18n) {
|
|
443
|
+
if (effectiveI18n && effectiveI18n.moreOptions !== undefined) {
|
|
472
444
|
if (effectiveI18n.moreOptions) {
|
|
473
|
-
|
|
445
|
+
this._overflow.setAttribute('aria-label', effectiveI18n.moreOptions);
|
|
474
446
|
} else {
|
|
475
|
-
|
|
447
|
+
this._overflow.removeAttribute('aria-label');
|
|
476
448
|
}
|
|
477
449
|
}
|
|
478
450
|
}
|
|
@@ -706,6 +678,7 @@ export const MenuBarMixin = (superClass) =>
|
|
|
706
678
|
_hideTooltip(immediate) {
|
|
707
679
|
const tooltip = this._tooltipController && this._tooltipController.node;
|
|
708
680
|
if (tooltip) {
|
|
681
|
+
this._tooltipController.setContext({ item: null });
|
|
709
682
|
tooltip._stateController.close(immediate);
|
|
710
683
|
}
|
|
711
684
|
}
|
|
@@ -25,7 +25,7 @@ import { menuBarOverlayStyles } from './styles/vaadin-menu-bar-overlay-core-styl
|
|
|
25
25
|
* @protected
|
|
26
26
|
*/
|
|
27
27
|
export class MenuBarOverlay extends MenuOverlayMixin(
|
|
28
|
-
OverlayMixin(DirMixin(ThemableMixin(LumoInjectionMixin(
|
|
28
|
+
OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))),
|
|
29
29
|
) {
|
|
30
30
|
static get is() {
|
|
31
31
|
return 'vaadin-menu-bar-overlay';
|
package/src/vaadin-menu-bar.d.ts
CHANGED
|
@@ -30,13 +30,13 @@ export interface MenuBarEventMap<TItem extends MenuBarItem = MenuBarItem>
|
|
|
30
30
|
*
|
|
31
31
|
* To create the menu bar, first add the component to the page:
|
|
32
32
|
*
|
|
33
|
-
* ```
|
|
33
|
+
* ```html
|
|
34
34
|
* <vaadin-menu-bar></vaadin-menu-bar>
|
|
35
35
|
* ```
|
|
36
36
|
*
|
|
37
37
|
* And then use [`items`](#/elements/vaadin-menu-bar#property-items) property to initialize the structure:
|
|
38
38
|
*
|
|
39
|
-
* ```
|
|
39
|
+
* ```js
|
|
40
40
|
* document.querySelector('vaadin-menu-bar').items = [{text: 'File'}, {text: 'Edit'}];
|
|
41
41
|
* ```
|
|
42
42
|
*
|
package/src/vaadin-menu-bar.js
CHANGED
|
@@ -22,13 +22,13 @@ import { MenuBarMixin } from './vaadin-menu-bar-mixin.js';
|
|
|
22
22
|
*
|
|
23
23
|
* To create the menu bar, first add the component to the page:
|
|
24
24
|
*
|
|
25
|
-
* ```
|
|
25
|
+
* ```html
|
|
26
26
|
* <vaadin-menu-bar></vaadin-menu-bar>
|
|
27
27
|
* ```
|
|
28
28
|
*
|
|
29
29
|
* And then use [`items`](#/elements/vaadin-menu-bar#property-items) property to initialize the structure:
|
|
30
30
|
*
|
|
31
|
-
* ```
|
|
31
|
+
* ```js
|
|
32
32
|
* document.querySelector('vaadin-menu-bar').items = [{text: 'File'}, {text: 'Edit'}];
|
|
33
33
|
* ```
|
|
34
34
|
*
|
|
@@ -77,7 +77,7 @@ import { MenuBarMixin } from './vaadin-menu-bar-mixin.js';
|
|
|
77
77
|
* @mixes MenuBarMixin
|
|
78
78
|
* @mixes ThemableMixin
|
|
79
79
|
*/
|
|
80
|
-
class MenuBar extends MenuBarMixin(ElementMixin(ThemableMixin(LumoInjectionMixin(
|
|
80
|
+
class MenuBar extends MenuBarMixin(ElementMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
|
|
81
81
|
static get is() {
|
|
82
82
|
return 'vaadin-menu-bar';
|
|
83
83
|
}
|
|
@@ -89,11 +89,12 @@ class MenuBar extends MenuBarMixin(ElementMixin(ThemableMixin(LumoInjectionMixin
|
|
|
89
89
|
/** @protected */
|
|
90
90
|
render() {
|
|
91
91
|
return html`
|
|
92
|
-
<div part="container">
|
|
92
|
+
<div part="container" @click="${this.__onButtonClick}" @mouseover="${this._onMouseOver}">
|
|
93
93
|
<slot></slot>
|
|
94
94
|
<slot name="overflow"></slot>
|
|
95
95
|
</div>
|
|
96
|
-
|
|
96
|
+
|
|
97
|
+
<slot name="submenu"></slot>
|
|
97
98
|
|
|
98
99
|
<slot name="tooltip"></slot>
|
|
99
100
|
`;
|
package/web-types.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/menu-bar",
|
|
4
|
-
"version": "25.0.0-
|
|
4
|
+
"version": "25.0.0-alpha8",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
8
8
|
"elements": [
|
|
9
9
|
{
|
|
10
10
|
"name": "vaadin-menu-bar",
|
|
11
|
-
"description": "`<vaadin-menu-bar>` is a Web Component providing a set of horizontally stacked buttons offering\nthe user quick access to a consistent set of commands. Each button can toggle a submenu with\nsupport for additional levels of nested menus.\n\nTo create the menu bar, first add the component to the page:\n\n
|
|
11
|
+
"description": "`<vaadin-menu-bar>` is a Web Component providing a set of horizontally stacked buttons offering\nthe user quick access to a consistent set of commands. Each button can toggle a submenu with\nsupport for additional levels of nested menus.\n\nTo create the menu bar, first add the component to the page:\n\n```html\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha8/#/elements/vaadin-menu-bar#property-items) property to initialize the structure:\n\n```js\ndocument.querySelector('vaadin-menu-bar').items = [{text: 'File'}, {text: 'Edit'}];\n```\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n------------------|----------------\n`container` | The container wrapping menu bar buttons.\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n--------------------|----------------------------------\n`disabled` | Set when the menu bar is disabled\n`has-single-button` | Set when there is only one button visible\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-menu-bar>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-menu-bar-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha8/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha8/#/elements/vaadin-item).\n- `<vaadin-menu-bar-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha8/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha8/#/elements/vaadin-overlay).\n\nThe `<vaadin-menu-bar-item>` sub-menu elements have the following additional state attributes\non top of the built-in `<vaadin-item>` state attributes:\n\nAttribute | Description\n---------- |-------------\n`expanded` | Expanded parent item.\n\nNote: the `theme` attribute value set on `<vaadin-menu-bar>` is\npropagated to the internal components listed above.",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "disabled",
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/menu-bar",
|
|
4
|
-
"version": "25.0.0-
|
|
4
|
+
"version": "25.0.0-alpha8",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"elements": [
|
|
17
17
|
{
|
|
18
18
|
"name": "vaadin-menu-bar",
|
|
19
|
-
"description": "`<vaadin-menu-bar>` is a Web Component providing a set of horizontally stacked buttons offering\nthe user quick access to a consistent set of commands. Each button can toggle a submenu with\nsupport for additional levels of nested menus.\n\nTo create the menu bar, first add the component to the page:\n\n
|
|
19
|
+
"description": "`<vaadin-menu-bar>` is a Web Component providing a set of horizontally stacked buttons offering\nthe user quick access to a consistent set of commands. Each button can toggle a submenu with\nsupport for additional levels of nested menus.\n\nTo create the menu bar, first add the component to the page:\n\n```html\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha8/#/elements/vaadin-menu-bar#property-items) property to initialize the structure:\n\n```js\ndocument.querySelector('vaadin-menu-bar').items = [{text: 'File'}, {text: 'Edit'}];\n```\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n------------------|----------------\n`container` | The container wrapping menu bar buttons.\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n--------------------|----------------------------------\n`disabled` | Set when the menu bar is disabled\n`has-single-button` | Set when there is only one button visible\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-menu-bar>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-menu-bar-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha8/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha8/#/elements/vaadin-item).\n- `<vaadin-menu-bar-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha8/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha8/#/elements/vaadin-overlay).\n\nThe `<vaadin-menu-bar-item>` sub-menu elements have the following additional state attributes\non top of the built-in `<vaadin-item>` state attributes:\n\nAttribute | Description\n---------- |-------------\n`expanded` | Expanded parent item.\n\nNote: the `theme` attribute value set on `<vaadin-menu-bar>` is\npropagated to the internal components listed above.",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|