@vaadin/menu-bar 25.0.0-alpha6 → 25.0.0-alpha7
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 +14 -14
- package/src/vaadin-menu-bar-mixin.js +70 -107
- package/src/vaadin-menu-bar.js +1 -1
- 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-alpha7",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -35,21 +35,21 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@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-
|
|
38
|
+
"@vaadin/a11y-base": "25.0.0-alpha7",
|
|
39
|
+
"@vaadin/button": "25.0.0-alpha7",
|
|
40
|
+
"@vaadin/component-base": "25.0.0-alpha7",
|
|
41
|
+
"@vaadin/context-menu": "25.0.0-alpha7",
|
|
42
|
+
"@vaadin/item": "25.0.0-alpha7",
|
|
43
|
+
"@vaadin/list-box": "25.0.0-alpha7",
|
|
44
|
+
"@vaadin/overlay": "25.0.0-alpha7",
|
|
45
|
+
"@vaadin/vaadin-lumo-styles": "25.0.0-alpha7",
|
|
46
|
+
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha7",
|
|
47
47
|
"lit": "^3.0.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@vaadin/chai-plugins": "25.0.0-
|
|
51
|
-
"@vaadin/icon": "25.0.0-
|
|
52
|
-
"@vaadin/test-runner-commands": "25.0.0-
|
|
50
|
+
"@vaadin/chai-plugins": "25.0.0-alpha7",
|
|
51
|
+
"@vaadin/icon": "25.0.0-alpha7",
|
|
52
|
+
"@vaadin/test-runner-commands": "25.0.0-alpha7",
|
|
53
53
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
54
54
|
"sinon": "^18.0.0"
|
|
55
55
|
},
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"web-types.json",
|
|
58
58
|
"web-types.lit.json"
|
|
59
59
|
],
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "87f72707ce6866892f8be5782fa0da008e87dcbc"
|
|
61
61
|
}
|
|
@@ -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
|
|
@@ -311,6 +279,18 @@ export const MenuBarMixin = (superClass) =>
|
|
|
311
279
|
return this.shadowRoot.querySelector('vaadin-menu-bar-submenu');
|
|
312
280
|
}
|
|
313
281
|
|
|
282
|
+
/** @private */
|
|
283
|
+
get _hasOverflow() {
|
|
284
|
+
return this._overflow && !this._overflow.hasAttribute('hidden');
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** @private */
|
|
288
|
+
set _hasOverflow(hasOverflow) {
|
|
289
|
+
if (this._overflow) {
|
|
290
|
+
this._overflow.toggleAttribute('hidden', !hasOverflow);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
314
294
|
/** @protected */
|
|
315
295
|
ready() {
|
|
316
296
|
super.ready();
|
|
@@ -344,10 +324,40 @@ export const MenuBarMixin = (superClass) =>
|
|
|
344
324
|
const overlay = this._subMenu._overlayElement;
|
|
345
325
|
overlay.addEventListener('keydown', this.__boundOnContextMenuKeydown);
|
|
346
326
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
327
|
+
this._container = this.shadowRoot.querySelector('[part="container"]');
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/** @protected */
|
|
331
|
+
updated(props) {
|
|
332
|
+
super.updated(props);
|
|
333
|
+
|
|
334
|
+
if (props.has('items') || props.has('_theme') || props.has('disabled')) {
|
|
335
|
+
this.__renderButtons(this.items);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (props.has('items') || props.has('_theme') || props.has('reverseCollapse')) {
|
|
339
|
+
this.__scheduleOverflow();
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if (props.has('items')) {
|
|
343
|
+
this.__updateSubMenu();
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (props.has('_theme')) {
|
|
347
|
+
this._themeChanged(this._theme);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (props.has('disabled')) {
|
|
351
|
+
this._overflow.toggleAttribute('disabled', this.disabled);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if (props.has('tabNavigation')) {
|
|
355
|
+
this._tabNavigationChanged(this.tabNavigation);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (props.has('__effectiveI18n')) {
|
|
359
|
+
this.__i18nChanged(this.__effectiveI18n);
|
|
360
|
+
}
|
|
351
361
|
}
|
|
352
362
|
|
|
353
363
|
/**
|
|
@@ -379,81 +389,34 @@ export const MenuBarMixin = (superClass) =>
|
|
|
379
389
|
this.__scheduleOverflow();
|
|
380
390
|
}
|
|
381
391
|
|
|
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
392
|
/** @private */
|
|
417
|
-
|
|
418
|
-
if (
|
|
419
|
-
|
|
420
|
-
this.
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
this._setTabindex(btn, false);
|
|
425
|
-
}
|
|
426
|
-
btn.setAttribute('role', tabNavigation ? 'button' : 'menuitem');
|
|
427
|
-
});
|
|
393
|
+
_themeChanged(theme) {
|
|
394
|
+
if (theme) {
|
|
395
|
+
this._overflow.setAttribute('theme', theme);
|
|
396
|
+
this._subMenu.setAttribute('theme', theme);
|
|
397
|
+
} else {
|
|
398
|
+
this._overflow.removeAttribute('theme');
|
|
399
|
+
this._subMenu.removeAttribute('theme');
|
|
428
400
|
}
|
|
429
|
-
this.setAttribute('role', tabNavigation ? 'group' : 'menubar');
|
|
430
401
|
}
|
|
431
402
|
|
|
432
403
|
/** @private */
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
404
|
+
_tabNavigationChanged(tabNavigation) {
|
|
405
|
+
const target = this.querySelector('[tabindex="0"]');
|
|
406
|
+
this._buttons.forEach((btn) => {
|
|
407
|
+
if (target) {
|
|
408
|
+
this._setTabindex(btn, btn === target);
|
|
409
|
+
} else {
|
|
410
|
+
this._setTabindex(btn, false);
|
|
411
|
+
}
|
|
412
|
+
btn.setAttribute('role', tabNavigation ? 'button' : 'menuitem');
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
this.setAttribute('role', tabNavigation ? 'group' : 'menubar');
|
|
437
416
|
}
|
|
438
417
|
|
|
439
418
|
/** @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
|
-
|
|
419
|
+
__updateSubMenu() {
|
|
457
420
|
const subMenu = this._subMenu;
|
|
458
421
|
if (subMenu && subMenu.opened) {
|
|
459
422
|
const button = subMenu._overlayElement.positionTarget;
|
|
@@ -467,12 +430,12 @@ export const MenuBarMixin = (superClass) =>
|
|
|
467
430
|
}
|
|
468
431
|
|
|
469
432
|
/** @private */
|
|
470
|
-
__i18nChanged(effectiveI18n
|
|
471
|
-
if (
|
|
433
|
+
__i18nChanged(effectiveI18n) {
|
|
434
|
+
if (effectiveI18n && effectiveI18n.moreOptions !== undefined) {
|
|
472
435
|
if (effectiveI18n.moreOptions) {
|
|
473
|
-
|
|
436
|
+
this._overflow.setAttribute('aria-label', effectiveI18n.moreOptions);
|
|
474
437
|
} else {
|
|
475
|
-
|
|
438
|
+
this._overflow.removeAttribute('aria-label');
|
|
476
439
|
}
|
|
477
440
|
}
|
|
478
441
|
}
|
package/src/vaadin-menu-bar.js
CHANGED
|
@@ -89,7 +89,7 @@ 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>
|
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-alpha7",
|
|
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```\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-
|
|
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```\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha7/#/elements/vaadin-menu-bar#property-items) property to initialize the structure:\n\n```\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-alpha7/#/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-alpha7/#/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-alpha7/#/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-alpha7/#/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-alpha7",
|
|
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```\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-
|
|
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```\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha7/#/elements/vaadin-menu-bar#property-items) property to initialize the structure:\n\n```\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-alpha7/#/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-alpha7/#/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-alpha7/#/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-alpha7/#/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
|
{
|