@vaadin/menu-bar 24.8.0-alpha3 → 24.8.0-alpha4
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 +15 -15
- package/src/vaadin-menu-bar-mixin.d.ts +6 -12
- package/src/vaadin-menu-bar-mixin.js +95 -120
- package/web-types.json +17 -8
- package/web-types.lit.json +6 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/menu-bar",
|
|
3
|
-
"version": "24.8.0-
|
|
3
|
+
"version": "24.8.0-alpha4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -37,22 +37,22 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
39
39
|
"@polymer/polymer": "^3.0.0",
|
|
40
|
-
"@vaadin/a11y-base": "24.8.0-
|
|
41
|
-
"@vaadin/button": "24.8.0-
|
|
42
|
-
"@vaadin/component-base": "24.8.0-
|
|
43
|
-
"@vaadin/context-menu": "24.8.0-
|
|
44
|
-
"@vaadin/item": "24.8.0-
|
|
45
|
-
"@vaadin/list-box": "24.8.0-
|
|
46
|
-
"@vaadin/overlay": "24.8.0-
|
|
47
|
-
"@vaadin/vaadin-lumo-styles": "24.8.0-
|
|
48
|
-
"@vaadin/vaadin-material-styles": "24.8.0-
|
|
49
|
-
"@vaadin/vaadin-themable-mixin": "24.8.0-
|
|
40
|
+
"@vaadin/a11y-base": "24.8.0-alpha4",
|
|
41
|
+
"@vaadin/button": "24.8.0-alpha4",
|
|
42
|
+
"@vaadin/component-base": "24.8.0-alpha4",
|
|
43
|
+
"@vaadin/context-menu": "24.8.0-alpha4",
|
|
44
|
+
"@vaadin/item": "24.8.0-alpha4",
|
|
45
|
+
"@vaadin/list-box": "24.8.0-alpha4",
|
|
46
|
+
"@vaadin/overlay": "24.8.0-alpha4",
|
|
47
|
+
"@vaadin/vaadin-lumo-styles": "24.8.0-alpha4",
|
|
48
|
+
"@vaadin/vaadin-material-styles": "24.8.0-alpha4",
|
|
49
|
+
"@vaadin/vaadin-themable-mixin": "24.8.0-alpha4",
|
|
50
50
|
"lit": "^3.0.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@vaadin/chai-plugins": "24.8.0-
|
|
54
|
-
"@vaadin/icon": "24.8.0-
|
|
55
|
-
"@vaadin/test-runner-commands": "24.8.0-
|
|
53
|
+
"@vaadin/chai-plugins": "24.8.0-alpha4",
|
|
54
|
+
"@vaadin/icon": "24.8.0-alpha4",
|
|
55
|
+
"@vaadin/test-runner-commands": "24.8.0-alpha4",
|
|
56
56
|
"@vaadin/testing-helpers": "^1.1.0",
|
|
57
57
|
"sinon": "^18.0.0"
|
|
58
58
|
},
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"web-types.json",
|
|
61
61
|
"web-types.lit.json"
|
|
62
62
|
],
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "88251b4c84ebb8849dde982acb62cc2b20eeec31"
|
|
64
64
|
}
|
|
@@ -9,6 +9,7 @@ import type { FocusMixinClass } from '@vaadin/a11y-base/src/focus-mixin.js';
|
|
|
9
9
|
import type { KeyboardDirectionMixinClass } from '@vaadin/a11y-base/src/keyboard-direction-mixin.js';
|
|
10
10
|
import type { KeyboardMixinClass } from '@vaadin/a11y-base/src/keyboard-mixin.js';
|
|
11
11
|
import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
|
|
12
|
+
import type { I18nMixinClass } from '@vaadin/component-base/src/i18n-mixin.js';
|
|
12
13
|
import type { ResizeMixinClass } from '@vaadin/component-base/src/resize-mixin.js';
|
|
13
14
|
|
|
14
15
|
export type MenuBarItem<TItemData extends object = object> = {
|
|
@@ -56,7 +57,7 @@ export type SubMenuItem<TItemData extends object = object> = {
|
|
|
56
57
|
} & TItemData;
|
|
57
58
|
|
|
58
59
|
export interface MenuBarI18n {
|
|
59
|
-
moreOptions
|
|
60
|
+
moreOptions?: string;
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
export declare function MenuBarMixin<T extends Constructor<HTMLElement>, TItem extends MenuBarItem = MenuBarItem>(
|
|
@@ -64,6 +65,7 @@ export declare function MenuBarMixin<T extends Constructor<HTMLElement>, TItem e
|
|
|
64
65
|
): Constructor<ControllerMixinClass> &
|
|
65
66
|
Constructor<DisabledMixinClass> &
|
|
66
67
|
Constructor<FocusMixinClass> &
|
|
68
|
+
Constructor<I18nMixinClass<MenuBarI18n>> &
|
|
67
69
|
Constructor<KeyboardDirectionMixinClass> &
|
|
68
70
|
Constructor<KeyboardMixinClass> &
|
|
69
71
|
Constructor<MenuBarMixinClass<TItem>> &
|
|
@@ -121,17 +123,9 @@ export declare class MenuBarMixinClass<TItem extends MenuBarItem = MenuBarItem>
|
|
|
121
123
|
items: TItem[];
|
|
122
124
|
|
|
123
125
|
/**
|
|
124
|
-
* The object used to localize this component.
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
* To update individual properties, extend the existing i18n object like so:
|
|
129
|
-
* ```
|
|
130
|
-
* menuBar.i18n = {
|
|
131
|
-
* ...menuBar.i18n,
|
|
132
|
-
* moreOptions: 'More options'
|
|
133
|
-
* }
|
|
134
|
-
* ```
|
|
126
|
+
* The object used to localize this component. To change the default
|
|
127
|
+
* localization, replace this with an object that provides all properties, or
|
|
128
|
+
* just the individual properties you want to change.
|
|
135
129
|
*
|
|
136
130
|
* The object has the following JSON structure and default values:
|
|
137
131
|
* ```
|
|
@@ -3,25 +3,34 @@
|
|
|
3
3
|
* Copyright (c) 2019 - 2025 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
+
import { html, nothing, render } from 'lit';
|
|
7
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
6
8
|
import { DisabledMixin } from '@vaadin/a11y-base/src/disabled-mixin.js';
|
|
7
9
|
import { FocusMixin } from '@vaadin/a11y-base/src/focus-mixin.js';
|
|
8
10
|
import { isElementFocused, isElementHidden, isKeyboardActive } from '@vaadin/a11y-base/src/focus-utils.js';
|
|
9
11
|
import { KeyboardDirectionMixin } from '@vaadin/a11y-base/src/keyboard-direction-mixin.js';
|
|
10
12
|
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
13
|
+
import { I18nMixin } from '@vaadin/component-base/src/i18n-mixin.js';
|
|
11
14
|
import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
|
|
12
15
|
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
13
16
|
|
|
17
|
+
const DEFAULT_I18N = {
|
|
18
|
+
moreOptions: 'More options',
|
|
19
|
+
};
|
|
20
|
+
|
|
14
21
|
/**
|
|
15
22
|
* @polymerMixin
|
|
16
|
-
* @mixes DisabledMixin
|
|
17
23
|
* @mixes ControllerMixin
|
|
24
|
+
* @mixes DisabledMixin
|
|
18
25
|
* @mixes FocusMixin
|
|
26
|
+
* @mixes I18nMixin
|
|
19
27
|
* @mixes KeyboardDirectionMixin
|
|
20
28
|
* @mixes ResizeMixin
|
|
21
29
|
*/
|
|
22
30
|
export const MenuBarMixin = (superClass) =>
|
|
23
|
-
class MenuBarMixinClass extends
|
|
24
|
-
|
|
31
|
+
class MenuBarMixinClass extends I18nMixin(
|
|
32
|
+
DEFAULT_I18N,
|
|
33
|
+
KeyboardDirectionMixin(ResizeMixin(FocusMixin(DisabledMixin(ControllerMixin(superClass))))),
|
|
25
34
|
) {
|
|
26
35
|
static get properties() {
|
|
27
36
|
return {
|
|
@@ -108,38 +117,6 @@ export const MenuBarMixin = (superClass) =>
|
|
|
108
117
|
value: () => [],
|
|
109
118
|
},
|
|
110
119
|
|
|
111
|
-
/**
|
|
112
|
-
* The object used to localize this component.
|
|
113
|
-
* To change the default localization, replace the entire
|
|
114
|
-
* `i18n` object with a custom one.
|
|
115
|
-
*
|
|
116
|
-
* To update individual properties, extend the existing i18n object like so:
|
|
117
|
-
* ```
|
|
118
|
-
* menuBar.i18n = {
|
|
119
|
-
* ...menuBar.i18n,
|
|
120
|
-
* moreOptions: 'More options'
|
|
121
|
-
* }
|
|
122
|
-
* ```
|
|
123
|
-
*
|
|
124
|
-
* The object has the following JSON structure and default values:
|
|
125
|
-
* ```
|
|
126
|
-
* {
|
|
127
|
-
* moreOptions: 'More options'
|
|
128
|
-
* }
|
|
129
|
-
* ```
|
|
130
|
-
*
|
|
131
|
-
* @type {!MenuBarI18n}
|
|
132
|
-
* @default {English/US}
|
|
133
|
-
*/
|
|
134
|
-
i18n: {
|
|
135
|
-
type: Object,
|
|
136
|
-
value: () => {
|
|
137
|
-
return {
|
|
138
|
-
moreOptions: 'More options',
|
|
139
|
-
};
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
|
|
143
120
|
/**
|
|
144
121
|
* A space-delimited list of CSS class names
|
|
145
122
|
* to set on each sub-menu overlay element.
|
|
@@ -202,13 +179,34 @@ export const MenuBarMixin = (superClass) =>
|
|
|
202
179
|
return [
|
|
203
180
|
'_themeChanged(_theme, _overflow, _container)',
|
|
204
181
|
'__hasOverflowChanged(_hasOverflow, _overflow)',
|
|
205
|
-
'__i18nChanged(
|
|
182
|
+
'__i18nChanged(__effectiveI18n, _overflow)',
|
|
206
183
|
'_menuItemsChanged(items, _overflow, _container)',
|
|
207
184
|
'_reverseCollapseChanged(reverseCollapse, _overflow, _container)',
|
|
208
185
|
'_tabNavigationChanged(tabNavigation, _overflow, _container)',
|
|
209
186
|
];
|
|
210
187
|
}
|
|
211
188
|
|
|
189
|
+
/**
|
|
190
|
+
* The object used to localize this component. To change the default
|
|
191
|
+
* localization, replace this with an object that provides all properties, or
|
|
192
|
+
* just the individual properties you want to change.
|
|
193
|
+
*
|
|
194
|
+
* The object has the following JSON structure and default values:
|
|
195
|
+
* ```
|
|
196
|
+
* {
|
|
197
|
+
* moreOptions: 'More options'
|
|
198
|
+
* }
|
|
199
|
+
* ```
|
|
200
|
+
* @return {!MenuBarI18n}
|
|
201
|
+
*/
|
|
202
|
+
get i18n() {
|
|
203
|
+
return super.i18n;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
set i18n(value) {
|
|
207
|
+
super.i18n = value;
|
|
208
|
+
}
|
|
209
|
+
|
|
212
210
|
constructor() {
|
|
213
211
|
super();
|
|
214
212
|
this.__boundOnContextMenuKeydown = this.__onContextMenuKeydown.bind(this);
|
|
@@ -277,8 +275,11 @@ export const MenuBarMixin = (superClass) =>
|
|
|
277
275
|
dots.innerHTML = '·'.repeat(3);
|
|
278
276
|
btn.appendChild(dots);
|
|
279
277
|
|
|
278
|
+
btn.setAttribute('aria-haspopup', 'true');
|
|
279
|
+
btn.setAttribute('aria-expanded', 'false');
|
|
280
|
+
btn.setAttribute('role', this.tabNavigation ? 'button' : 'menuitem');
|
|
281
|
+
|
|
280
282
|
this._overflow = btn;
|
|
281
|
-
this._initButtonAttrs(btn);
|
|
282
283
|
},
|
|
283
284
|
});
|
|
284
285
|
this.addController(this._overflowController);
|
|
@@ -359,14 +360,16 @@ export const MenuBarMixin = (superClass) =>
|
|
|
359
360
|
*/
|
|
360
361
|
_themeChanged(theme, overflow, container) {
|
|
361
362
|
if (overflow && container) {
|
|
362
|
-
this.
|
|
363
|
+
this.__renderButtons(this.items);
|
|
363
364
|
this.__detectOverflow();
|
|
364
|
-
}
|
|
365
365
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
366
|
+
if (theme) {
|
|
367
|
+
overflow.setAttribute('theme', theme);
|
|
368
|
+
this._subMenu.setAttribute('theme', theme);
|
|
369
|
+
} else {
|
|
370
|
+
overflow.removeAttribute('theme');
|
|
371
|
+
this._subMenu.removeAttribute('theme');
|
|
372
|
+
}
|
|
370
373
|
}
|
|
371
374
|
}
|
|
372
375
|
|
|
@@ -418,15 +421,21 @@ export const MenuBarMixin = (superClass) =>
|
|
|
418
421
|
|
|
419
422
|
const subMenu = this._subMenu;
|
|
420
423
|
if (subMenu && subMenu.opened) {
|
|
421
|
-
subMenu.
|
|
424
|
+
const button = subMenu._overlayElement.positionTarget;
|
|
425
|
+
|
|
426
|
+
// Close sub-menu if the corresponding button is no longer in the DOM,
|
|
427
|
+
// or if the item on it has been changed to no longer have children.
|
|
428
|
+
if (!button.isConnected || !Array.isArray(button.item.children) || button.item.children.length === 0) {
|
|
429
|
+
subMenu.close();
|
|
430
|
+
}
|
|
422
431
|
}
|
|
423
432
|
}
|
|
424
433
|
|
|
425
434
|
/** @private */
|
|
426
|
-
__i18nChanged(
|
|
427
|
-
if (overflow &&
|
|
428
|
-
if (
|
|
429
|
-
overflow.setAttribute('aria-label',
|
|
435
|
+
__i18nChanged(effectiveI18n, overflow) {
|
|
436
|
+
if (overflow && effectiveI18n && effectiveI18n.moreOptions !== undefined) {
|
|
437
|
+
if (effectiveI18n.moreOptions) {
|
|
438
|
+
overflow.setAttribute('aria-label', effectiveI18n.moreOptions);
|
|
430
439
|
} else {
|
|
431
440
|
overflow.removeAttribute('aria-label');
|
|
432
441
|
}
|
|
@@ -554,66 +563,17 @@ export const MenuBarMixin = (superClass) =>
|
|
|
554
563
|
});
|
|
555
564
|
}
|
|
556
565
|
|
|
557
|
-
/** @
|
|
558
|
-
|
|
559
|
-
this._buttons.forEach((button) => {
|
|
560
|
-
if (button !== this._overflow) {
|
|
561
|
-
this.removeChild(button);
|
|
562
|
-
}
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
/** @protected */
|
|
567
|
-
_initButton(item) {
|
|
568
|
-
const button = document.createElement('vaadin-menu-bar-button');
|
|
569
|
-
|
|
570
|
-
const itemCopy = { ...item };
|
|
571
|
-
button.item = itemCopy;
|
|
572
|
-
|
|
573
|
-
if (item.component) {
|
|
574
|
-
const component = this.__getComponent(itemCopy);
|
|
575
|
-
itemCopy.component = component;
|
|
576
|
-
// Save item for overflow menu
|
|
577
|
-
component.item = itemCopy;
|
|
578
|
-
button.appendChild(component);
|
|
579
|
-
} else if (item.text) {
|
|
580
|
-
button.textContent = item.text;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
if (item.className) {
|
|
584
|
-
button.className = item.className;
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
button.disabled = item.disabled;
|
|
588
|
-
|
|
589
|
-
return button;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
/** @protected */
|
|
593
|
-
_initButtonAttrs(button) {
|
|
594
|
-
button.setAttribute('role', this.tabNavigation ? 'button' : 'menuitem');
|
|
595
|
-
|
|
596
|
-
if (button === this._overflow || (button.item && button.item.children)) {
|
|
597
|
-
button.setAttribute('aria-haspopup', 'true');
|
|
598
|
-
button.setAttribute('aria-expanded', 'false');
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
/** @protected */
|
|
603
|
-
_setButtonTheme(btn, hostTheme) {
|
|
566
|
+
/** @private */
|
|
567
|
+
__getButtonTheme(item, hostTheme) {
|
|
604
568
|
let theme = hostTheme;
|
|
605
569
|
|
|
606
570
|
// Item theme takes precedence over host theme even if it's empty, as long as it's not undefined or null
|
|
607
|
-
const itemTheme =
|
|
571
|
+
const itemTheme = item && item.theme;
|
|
608
572
|
if (itemTheme != null) {
|
|
609
573
|
theme = Array.isArray(itemTheme) ? itemTheme.join(' ') : itemTheme;
|
|
610
574
|
}
|
|
611
575
|
|
|
612
|
-
|
|
613
|
-
btn.setAttribute('theme', theme);
|
|
614
|
-
} else {
|
|
615
|
-
btn.removeAttribute('theme');
|
|
616
|
-
}
|
|
576
|
+
return theme;
|
|
617
577
|
}
|
|
618
578
|
|
|
619
579
|
/** @private */
|
|
@@ -638,19 +598,41 @@ export const MenuBarMixin = (superClass) =>
|
|
|
638
598
|
|
|
639
599
|
/** @private */
|
|
640
600
|
__renderButtons(items = []) {
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
601
|
+
const renderContent = (item) => {
|
|
602
|
+
if (item.component) {
|
|
603
|
+
const component = this.__getComponent(item);
|
|
604
|
+
item.component = component;
|
|
605
|
+
// Save item for overflow menu
|
|
606
|
+
component.item = item;
|
|
607
|
+
return component;
|
|
608
|
+
} else if (item.text) {
|
|
609
|
+
return item.text;
|
|
610
|
+
}
|
|
611
|
+
};
|
|
647
612
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
613
|
+
render(
|
|
614
|
+
html`
|
|
615
|
+
${items.map((item) => {
|
|
616
|
+
const itemCopy = { ...item };
|
|
617
|
+
const hasChildren = Boolean(item && item.children);
|
|
618
|
+
|
|
619
|
+
return html`
|
|
620
|
+
<vaadin-menu-bar-button
|
|
621
|
+
.item="${itemCopy}"
|
|
622
|
+
.disabled="${item.disabled}"
|
|
623
|
+
role="${this.tabNavigation ? 'button' : 'menuitem'}"
|
|
624
|
+
aria-haspopup="${ifDefined(hasChildren ? 'true' : nothing)}"
|
|
625
|
+
aria-expanded="${ifDefined(hasChildren ? 'false' : nothing)}"
|
|
626
|
+
class="${ifDefined(item.className)}"
|
|
627
|
+
theme="${ifDefined(this.__getButtonTheme(itemCopy, this._theme) || nothing)}"
|
|
628
|
+
>${renderContent(itemCopy)}</vaadin-menu-bar-button
|
|
629
|
+
>
|
|
630
|
+
`;
|
|
631
|
+
})}
|
|
632
|
+
`,
|
|
633
|
+
this,
|
|
634
|
+
{ renderBefore: this._overflow },
|
|
635
|
+
);
|
|
654
636
|
|
|
655
637
|
this.__detectOverflow();
|
|
656
638
|
}
|
|
@@ -958,13 +940,6 @@ export const MenuBarMixin = (superClass) =>
|
|
|
958
940
|
this._expandedButton = button;
|
|
959
941
|
|
|
960
942
|
requestAnimationFrame(() => {
|
|
961
|
-
// After changing items, buttons are recreated so the old button is
|
|
962
|
-
// no longer in the DOM. Reset position target to null to prevent
|
|
963
|
-
// overlay from closing due to target width / height equal to 0.
|
|
964
|
-
if (overlay.positionTarget && !overlay.positionTarget.isConnected) {
|
|
965
|
-
overlay.positionTarget = null;
|
|
966
|
-
}
|
|
967
|
-
|
|
968
943
|
button.dispatchEvent(
|
|
969
944
|
new CustomEvent('opensubmenu', {
|
|
970
945
|
detail: {
|
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": "24.8.0-
|
|
4
|
+
"version": "24.8.0-alpha4",
|
|
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/24.8.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/24.8.0-alpha4/#/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/24.8.0-alpha4/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.8.0-alpha4/#/elements/vaadin-item).\n- `<vaadin-menu-bar-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/24.8.0-alpha4/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.8.0-alpha4/#/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",
|
|
@@ -21,6 +21,15 @@
|
|
|
21
21
|
]
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
+
{
|
|
25
|
+
"name": "i18n",
|
|
26
|
+
"description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nShould be overridden by subclasses to provide a custom JSDoc with the\ndefault I18N properties.",
|
|
27
|
+
"value": {
|
|
28
|
+
"type": [
|
|
29
|
+
"Object"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
24
33
|
{
|
|
25
34
|
"name": "overlay-class",
|
|
26
35
|
"description": "A space-delimited list of CSS class names\nto set on each sub-menu overlay element.",
|
|
@@ -91,20 +100,20 @@
|
|
|
91
100
|
}
|
|
92
101
|
},
|
|
93
102
|
{
|
|
94
|
-
"name": "
|
|
95
|
-
"description": "
|
|
103
|
+
"name": "i18n",
|
|
104
|
+
"description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n```\n{\n moreOptions: 'More options'\n}\n```",
|
|
96
105
|
"value": {
|
|
97
106
|
"type": [
|
|
98
|
-
"
|
|
107
|
+
"MenuBarI18n"
|
|
99
108
|
]
|
|
100
109
|
}
|
|
101
110
|
},
|
|
102
111
|
{
|
|
103
|
-
"name": "
|
|
104
|
-
"description": "
|
|
112
|
+
"name": "items",
|
|
113
|
+
"description": "Defines a hierarchical structure, where root level items represent menu bar buttons,\nand `children` property configures a submenu with items to be opened below\nthe button on click, Enter, Space, Up and Down arrow keys.\n\n#### Example\n\n```js\nmenubar.items = [\n {\n text: 'File',\n className: 'file',\n children: [\n {text: 'Open', className: 'file open'}\n {text: 'Auto Save', checked: true},\n ]\n },\n {component: 'hr'},\n {\n text: 'Edit',\n children: [\n {text: 'Undo', disabled: true},\n {text: 'Redo'}\n ]\n },\n {text: 'Help'}\n];\n```\n\n#### Disabled buttons\n\nWhen disabled, menu bar buttons (root-level items) are rendered\nas \"dimmed\" and prevent all user interactions (mouse and keyboard).\n\nSince disabled buttons are not focusable and cannot react to hover\nevents by default, it can cause accessibility issues by making them\nentirely invisible to assistive technologies, and prevents the use\nof Tooltips to explain why the action is not available. This can be\naddressed by enabling the feature flag `accessibleDisabledButtons`,\nwhich makes disabled buttons focusable and hoverable, while still\npreventing them from being triggered:\n\n```\n// Set before any menu bar is attached to the DOM.\nwindow.Vaadin.featureFlags.accessibleDisabledButtons = true;\n```\n```\n// Set before any menu bar is attached to the DOM.\nwindow.Vaadin.featureFlags.accessibleDisabledButtons = true;\n```",
|
|
105
114
|
"value": {
|
|
106
115
|
"type": [
|
|
107
|
-
"
|
|
116
|
+
"Array.<MenuBarItem>"
|
|
108
117
|
]
|
|
109
118
|
}
|
|
110
119
|
},
|
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": "24.8.0-
|
|
4
|
+
"version": "24.8.0-alpha4",
|
|
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/24.8.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/24.8.0-alpha4/#/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/24.8.0-alpha4/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.8.0-alpha4/#/elements/vaadin-item).\n- `<vaadin-menu-bar-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/24.8.0-alpha4/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.8.0-alpha4/#/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
|
{
|
|
@@ -48,15 +48,15 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
|
-
"name": ".
|
|
52
|
-
"description": "
|
|
51
|
+
"name": ".i18n",
|
|
52
|
+
"description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n```\n{\n moreOptions: 'More options'\n}\n```",
|
|
53
53
|
"value": {
|
|
54
54
|
"kind": "expression"
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
|
-
"name": ".
|
|
59
|
-
"description": "
|
|
58
|
+
"name": ".items",
|
|
59
|
+
"description": "Defines a hierarchical structure, where root level items represent menu bar buttons,\nand `children` property configures a submenu with items to be opened below\nthe button on click, Enter, Space, Up and Down arrow keys.\n\n#### Example\n\n```js\nmenubar.items = [\n {\n text: 'File',\n className: 'file',\n children: [\n {text: 'Open', className: 'file open'}\n {text: 'Auto Save', checked: true},\n ]\n },\n {component: 'hr'},\n {\n text: 'Edit',\n children: [\n {text: 'Undo', disabled: true},\n {text: 'Redo'}\n ]\n },\n {text: 'Help'}\n];\n```\n\n#### Disabled buttons\n\nWhen disabled, menu bar buttons (root-level items) are rendered\nas \"dimmed\" and prevent all user interactions (mouse and keyboard).\n\nSince disabled buttons are not focusable and cannot react to hover\nevents by default, it can cause accessibility issues by making them\nentirely invisible to assistive technologies, and prevents the use\nof Tooltips to explain why the action is not available. This can be\naddressed by enabling the feature flag `accessibleDisabledButtons`,\nwhich makes disabled buttons focusable and hoverable, while still\npreventing them from being triggered:\n\n```\n// Set before any menu bar is attached to the DOM.\nwindow.Vaadin.featureFlags.accessibleDisabledButtons = true;\n```\n```\n// Set before any menu bar is attached to the DOM.\nwindow.Vaadin.featureFlags.accessibleDisabledButtons = true;\n```",
|
|
60
60
|
"value": {
|
|
61
61
|
"kind": "expression"
|
|
62
62
|
}
|