@vaadin/menu-bar 24.6.5 → 24.7.0-alpha10
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-lit-menu-bar-button.js +15 -1
- package/src/vaadin-lit-menu-bar-item.js +1 -1
- package/src/vaadin-lit-menu-bar-list-box.js +1 -1
- package/src/vaadin-lit-menu-bar-overlay.js +1 -1
- package/src/vaadin-lit-menu-bar-submenu.js +1 -1
- package/src/vaadin-lit-menu-bar.js +1 -1
- package/src/vaadin-menu-bar-button.js +15 -1
- package/src/vaadin-menu-bar-item.d.ts +1 -1
- package/src/vaadin-menu-bar-item.js +1 -1
- package/src/vaadin-menu-bar-list-box.d.ts +1 -1
- package/src/vaadin-menu-bar-list-box.js +1 -1
- package/src/vaadin-menu-bar-mixin.d.ts +37 -11
- package/src/vaadin-menu-bar-mixin.js +48 -16
- package/src/vaadin-menu-bar-overlay.d.ts +1 -1
- package/src/vaadin-menu-bar-overlay.js +1 -1
- package/src/vaadin-menu-bar-submenu-mixin.js +1 -1
- package/src/vaadin-menu-bar-submenu.js +1 -1
- package/src/vaadin-menu-bar.d.ts +22 -14
- package/src/vaadin-menu-bar.js +1 -1
- package/web-types.json +3 -3
- package/web-types.lit.json +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/menu-bar",
|
|
3
|
-
"version": "24.
|
|
3
|
+
"version": "24.7.0-alpha10",
|
|
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": "
|
|
41
|
-
"@vaadin/button": "
|
|
42
|
-
"@vaadin/component-base": "
|
|
43
|
-
"@vaadin/context-menu": "
|
|
44
|
-
"@vaadin/item": "
|
|
45
|
-
"@vaadin/list-box": "
|
|
46
|
-
"@vaadin/overlay": "
|
|
47
|
-
"@vaadin/vaadin-lumo-styles": "
|
|
48
|
-
"@vaadin/vaadin-material-styles": "
|
|
49
|
-
"@vaadin/vaadin-themable-mixin": "
|
|
40
|
+
"@vaadin/a11y-base": "24.7.0-alpha10",
|
|
41
|
+
"@vaadin/button": "24.7.0-alpha10",
|
|
42
|
+
"@vaadin/component-base": "24.7.0-alpha10",
|
|
43
|
+
"@vaadin/context-menu": "24.7.0-alpha10",
|
|
44
|
+
"@vaadin/item": "24.7.0-alpha10",
|
|
45
|
+
"@vaadin/list-box": "24.7.0-alpha10",
|
|
46
|
+
"@vaadin/overlay": "24.7.0-alpha10",
|
|
47
|
+
"@vaadin/vaadin-lumo-styles": "24.7.0-alpha10",
|
|
48
|
+
"@vaadin/vaadin-material-styles": "24.7.0-alpha10",
|
|
49
|
+
"@vaadin/vaadin-themable-mixin": "24.7.0-alpha10",
|
|
50
50
|
"lit": "^3.0.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@vaadin/chai-plugins": "
|
|
54
|
-
"@vaadin/icon": "
|
|
55
|
-
"@vaadin/test-runner-commands": "
|
|
53
|
+
"@vaadin/chai-plugins": "24.7.0-alpha10",
|
|
54
|
+
"@vaadin/icon": "24.7.0-alpha10",
|
|
55
|
+
"@vaadin/test-runner-commands": "24.7.0-alpha10",
|
|
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": "c0f8933df2a6a40648d3fb9cfbae6bbf86a8aa90"
|
|
64
64
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2019 -
|
|
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
6
|
import { Button } from '@vaadin/button/src/vaadin-lit-button.js';
|
|
@@ -48,6 +48,20 @@ class MenuBarButton extends Button {
|
|
|
48
48
|
super._onKeyDown(event);
|
|
49
49
|
this.__triggeredWithActiveKeys = null;
|
|
50
50
|
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Override method inherited from `ButtonMixin` to allow keyboard navigation with
|
|
54
|
+
* arrow keys in the menu bar when the button is focusable in the disabled state.
|
|
55
|
+
*
|
|
56
|
+
* @override
|
|
57
|
+
*/
|
|
58
|
+
__shouldSuppressInteractionEvent(event) {
|
|
59
|
+
if (event.type === 'keydown' && ['ArrowLeft', 'ArrowRight'].includes(event.key)) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return super.__shouldSuppressInteractionEvent(event);
|
|
64
|
+
}
|
|
51
65
|
}
|
|
52
66
|
|
|
53
67
|
defineCustomElement(MenuBarButton);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2019 -
|
|
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
6
|
import { Button } from '@vaadin/button/src/vaadin-button.js';
|
|
@@ -45,6 +45,20 @@ class MenuBarButton extends Button {
|
|
|
45
45
|
super._onKeyDown(event);
|
|
46
46
|
this.__triggeredWithActiveKeys = null;
|
|
47
47
|
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Override method inherited from `ButtonMixin` to allow keyboard navigation with
|
|
51
|
+
* arrow keys in the menu bar when the button is focusable in the disabled state.
|
|
52
|
+
*
|
|
53
|
+
* @override
|
|
54
|
+
*/
|
|
55
|
+
__shouldSuppressInteractionEvent(event) {
|
|
56
|
+
if (event.type === 'keydown' && ['ArrowLeft', 'ArrowRight'].includes(event.key)) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return super.__shouldSuppressInteractionEvent(event);
|
|
61
|
+
}
|
|
48
62
|
}
|
|
49
63
|
|
|
50
64
|
defineCustomElement(MenuBarButton);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2019 -
|
|
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
6
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2019 -
|
|
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
6
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2019 -
|
|
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
6
|
import { ListMixin } from '@vaadin/a11y-base/src/list-mixin.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2019 -
|
|
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
6
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2019 -
|
|
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
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
@@ -11,7 +11,7 @@ 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
12
|
import type { ResizeMixinClass } from '@vaadin/component-base/src/resize-mixin.js';
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export type MenuBarItem<TItemData extends object = object> = {
|
|
15
15
|
/**
|
|
16
16
|
* Text to be set as the menu button component's textContent.
|
|
17
17
|
*/
|
|
@@ -37,40 +37,40 @@ export interface MenuBarItem {
|
|
|
37
37
|
/**
|
|
38
38
|
* Array of submenu items.
|
|
39
39
|
*/
|
|
40
|
-
children?: SubMenuItem
|
|
40
|
+
children?: Array<SubMenuItem<TItemData>>;
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* Class/classes to be set to the class attribute of the button.
|
|
44
44
|
*/
|
|
45
45
|
className?: string;
|
|
46
|
-
}
|
|
46
|
+
} & TItemData;
|
|
47
47
|
|
|
48
|
-
export
|
|
48
|
+
export type SubMenuItem<TItemData extends object = object> = {
|
|
49
49
|
text?: string;
|
|
50
50
|
component?: HTMLElement | string;
|
|
51
51
|
disabled?: boolean;
|
|
52
52
|
theme?: string[] | string;
|
|
53
53
|
checked?: boolean;
|
|
54
54
|
className?: string;
|
|
55
|
-
children?: SubMenuItem
|
|
56
|
-
}
|
|
55
|
+
children?: Array<SubMenuItem<TItemData>>;
|
|
56
|
+
} & TItemData;
|
|
57
57
|
|
|
58
58
|
export interface MenuBarI18n {
|
|
59
59
|
moreOptions: string;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
export declare function MenuBarMixin<T extends Constructor<HTMLElement
|
|
62
|
+
export declare function MenuBarMixin<T extends Constructor<HTMLElement>, TItem extends MenuBarItem = MenuBarItem>(
|
|
63
63
|
base: T,
|
|
64
64
|
): Constructor<ControllerMixinClass> &
|
|
65
65
|
Constructor<DisabledMixinClass> &
|
|
66
66
|
Constructor<FocusMixinClass> &
|
|
67
67
|
Constructor<KeyboardDirectionMixinClass> &
|
|
68
68
|
Constructor<KeyboardMixinClass> &
|
|
69
|
-
Constructor<MenuBarMixinClass
|
|
69
|
+
Constructor<MenuBarMixinClass<TItem>> &
|
|
70
70
|
Constructor<ResizeMixinClass> &
|
|
71
71
|
T;
|
|
72
72
|
|
|
73
|
-
export declare class MenuBarMixinClass {
|
|
73
|
+
export declare class MenuBarMixinClass<TItem extends MenuBarItem = MenuBarItem> {
|
|
74
74
|
/**
|
|
75
75
|
* Defines a hierarchical structure, where root level items represent menu bar buttons,
|
|
76
76
|
* and `children` property configures a submenu with items to be opened below
|
|
@@ -99,8 +99,26 @@ export declare class MenuBarMixinClass {
|
|
|
99
99
|
* {text: 'Help'}
|
|
100
100
|
* ];
|
|
101
101
|
* ```
|
|
102
|
+
*
|
|
103
|
+
* #### Disabled buttons
|
|
104
|
+
*
|
|
105
|
+
* When disabled, menu bar buttons (root-level items) are rendered
|
|
106
|
+
* as "dimmed" and prevent all user interactions (mouse and keyboard).
|
|
107
|
+
*
|
|
108
|
+
* Since disabled buttons are not focusable and cannot react to hover
|
|
109
|
+
* events by default, it can cause accessibility issues by making them
|
|
110
|
+
* entirely invisible to assistive technologies, and prevents the use
|
|
111
|
+
* of Tooltips to explain why the action is not available. This can be
|
|
112
|
+
* addressed by enabling the feature flag `accessibleDisabledButtons`,
|
|
113
|
+
* which makes disabled buttons focusable and hoverable, while still
|
|
114
|
+
* preventing them from being triggered:
|
|
115
|
+
*
|
|
116
|
+
* ```
|
|
117
|
+
* // Set before any menu bar is attached to the DOM.
|
|
118
|
+
* window.Vaadin.featureFlags.accessibleDisabledButtons = true;
|
|
119
|
+
* ```
|
|
102
120
|
*/
|
|
103
|
-
items:
|
|
121
|
+
items: TItem[];
|
|
104
122
|
|
|
105
123
|
/**
|
|
106
124
|
* The object used to localize this component.
|
|
@@ -165,3 +183,11 @@ export declare class MenuBarMixinClass {
|
|
|
165
183
|
|
|
166
184
|
protected _hasOverflow: boolean;
|
|
167
185
|
}
|
|
186
|
+
|
|
187
|
+
export declare interface MenuBarMixinClass
|
|
188
|
+
extends ControllerMixinClass,
|
|
189
|
+
DisabledMixinClass,
|
|
190
|
+
FocusMixinClass,
|
|
191
|
+
KeyboardDirectionMixinClass,
|
|
192
|
+
KeyboardMixinClass,
|
|
193
|
+
ResizeMixinClass {}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2019 -
|
|
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
6
|
import { DisabledMixin } from '@vaadin/a11y-base/src/disabled-mixin.js';
|
|
@@ -78,6 +78,29 @@ export const MenuBarMixin = (superClass) =>
|
|
|
78
78
|
* ];
|
|
79
79
|
* ```
|
|
80
80
|
*
|
|
81
|
+
* #### Disabled buttons
|
|
82
|
+
*
|
|
83
|
+
* When disabled, menu bar buttons (root-level items) are rendered
|
|
84
|
+
* as "dimmed" and prevent all user interactions (mouse and keyboard).
|
|
85
|
+
*
|
|
86
|
+
* Since disabled buttons are not focusable and cannot react to hover
|
|
87
|
+
* events by default, it can cause accessibility issues by making them
|
|
88
|
+
* entirely invisible to assistive technologies, and prevents the use
|
|
89
|
+
* of Tooltips to explain why the action is not available. This can be
|
|
90
|
+
* addressed by enabling the feature flag `accessibleDisabledButtons`,
|
|
91
|
+
* which makes disabled buttons focusable and hoverable, while still
|
|
92
|
+
* preventing them from being triggered:
|
|
93
|
+
*
|
|
94
|
+
* ```
|
|
95
|
+
* // Set before any menu bar is attached to the DOM.
|
|
96
|
+
* window.Vaadin.featureFlags.accessibleDisabledButtons = true;
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* ```
|
|
100
|
+
* // Set before any menu bar is attached to the DOM.
|
|
101
|
+
* window.Vaadin.featureFlags.accessibleDisabledButtons = true;
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
81
104
|
* @type {!Array<!MenuBarItem>}
|
|
82
105
|
*/
|
|
83
106
|
items: {
|
|
@@ -561,6 +584,8 @@ export const MenuBarMixin = (superClass) =>
|
|
|
561
584
|
button.className = item.className;
|
|
562
585
|
}
|
|
563
586
|
|
|
587
|
+
button.disabled = item.disabled;
|
|
588
|
+
|
|
564
589
|
return button;
|
|
565
590
|
}
|
|
566
591
|
|
|
@@ -574,12 +599,6 @@ export const MenuBarMixin = (superClass) =>
|
|
|
574
599
|
}
|
|
575
600
|
}
|
|
576
601
|
|
|
577
|
-
/** @protected */
|
|
578
|
-
_setButtonDisabled(button, disabled) {
|
|
579
|
-
button.disabled = disabled;
|
|
580
|
-
button.setAttribute('tabindex', disabled ? '-1' : '0');
|
|
581
|
-
}
|
|
582
|
-
|
|
583
602
|
/** @protected */
|
|
584
603
|
_setButtonTheme(btn, hostTheme) {
|
|
585
604
|
let theme = hostTheme;
|
|
@@ -629,7 +648,6 @@ export const MenuBarMixin = (superClass) =>
|
|
|
629
648
|
items.forEach((item) => {
|
|
630
649
|
const button = this._initButton(item);
|
|
631
650
|
this.insertBefore(button, this._overflow);
|
|
632
|
-
this._setButtonDisabled(button, item.disabled);
|
|
633
651
|
this._initButtonAttrs(button);
|
|
634
652
|
this._setButtonTheme(button, this._theme);
|
|
635
653
|
});
|
|
@@ -693,7 +711,7 @@ export const MenuBarMixin = (superClass) =>
|
|
|
693
711
|
|
|
694
712
|
/** @protected */
|
|
695
713
|
_setTabindex(button, focused) {
|
|
696
|
-
if (this.tabNavigation &&
|
|
714
|
+
if (this.tabNavigation && this._isItemFocusable(button)) {
|
|
697
715
|
button.setAttribute('tabindex', '0');
|
|
698
716
|
} else {
|
|
699
717
|
button.setAttribute('tabindex', focused ? '0' : '-1');
|
|
@@ -912,6 +930,10 @@ export const MenuBarMixin = (superClass) =>
|
|
|
912
930
|
|
|
913
931
|
/** @private */
|
|
914
932
|
__openSubMenu(button, keydown, options = {}) {
|
|
933
|
+
if (button.disabled) {
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
|
|
915
937
|
const subMenu = this._subMenu;
|
|
916
938
|
const item = button.item;
|
|
917
939
|
|
|
@@ -935,7 +957,7 @@ export const MenuBarMixin = (superClass) =>
|
|
|
935
957
|
|
|
936
958
|
this._expandedButton = button;
|
|
937
959
|
|
|
938
|
-
requestAnimationFrame(
|
|
960
|
+
requestAnimationFrame(() => {
|
|
939
961
|
// After changing items, buttons are recreated so the old button is
|
|
940
962
|
// no longer in the DOM. Reset position target to null to prevent
|
|
941
963
|
// overlay from closing due to target width / height equal to 0.
|
|
@@ -954,12 +976,6 @@ export const MenuBarMixin = (superClass) =>
|
|
|
954
976
|
|
|
955
977
|
this._setExpanded(button, true);
|
|
956
978
|
|
|
957
|
-
// Delay setting position target until overlay is rendered
|
|
958
|
-
// to correctly measure item content in Lit based version.
|
|
959
|
-
if (overlay.updateComplete) {
|
|
960
|
-
await overlay.updateComplete;
|
|
961
|
-
}
|
|
962
|
-
|
|
963
979
|
overlay.positionTarget = button;
|
|
964
980
|
});
|
|
965
981
|
|
|
@@ -1041,4 +1057,20 @@ export const MenuBarMixin = (superClass) =>
|
|
|
1041
1057
|
close() {
|
|
1042
1058
|
this._close();
|
|
1043
1059
|
}
|
|
1060
|
+
|
|
1061
|
+
/**
|
|
1062
|
+
* Override method inherited from `KeyboardDirectionMixin` to allow
|
|
1063
|
+
* focusing disabled buttons that are configured so.
|
|
1064
|
+
*
|
|
1065
|
+
* @param {Element} button
|
|
1066
|
+
* @protected
|
|
1067
|
+
* @override
|
|
1068
|
+
*/
|
|
1069
|
+
_isItemFocusable(button) {
|
|
1070
|
+
if (button.disabled && button.__shouldAllowFocusWhenDisabled) {
|
|
1071
|
+
return button.__shouldAllowFocusWhenDisabled();
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
return super._isItemFocusable(button);
|
|
1075
|
+
}
|
|
1044
1076
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2019 -
|
|
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
6
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2019 -
|
|
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
6
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2019 -
|
|
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
6
|
import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
|
package/src/vaadin-menu-bar.d.ts
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2019 -
|
|
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 {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import type { DisabledMixinClass } from '@vaadin/a11y-base/src/disabled-mixin.js';
|
|
7
|
+
import type { ElementMixinClass } from '@vaadin/component-base/src/element-mixin.js';
|
|
8
|
+
import type { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
|
+
import type { MenuBarItem, MenuBarMixinClass } from './vaadin-menu-bar-mixin.js';
|
|
10
10
|
|
|
11
11
|
export { MenuBarItem, MenuBarI18n, SubMenuItem } from './vaadin-menu-bar-mixin.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Fired when a submenu item or menu bar button without children is clicked.
|
|
15
15
|
*/
|
|
16
|
-
export type MenuBarItemSelectedEvent = CustomEvent<{ value:
|
|
16
|
+
export type MenuBarItemSelectedEvent<TItem extends MenuBarItem = MenuBarItem> = CustomEvent<{ value: TItem }>;
|
|
17
17
|
|
|
18
|
-
export interface MenuBarCustomEventMap {
|
|
19
|
-
'item-selected': MenuBarItemSelectedEvent
|
|
18
|
+
export interface MenuBarCustomEventMap<TItem extends MenuBarItem = MenuBarItem> {
|
|
19
|
+
'item-selected': MenuBarItemSelectedEvent<TItem>;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export interface MenuBarEventMap extends
|
|
22
|
+
export interface MenuBarEventMap<TItem extends MenuBarItem = MenuBarItem>
|
|
23
|
+
extends HTMLElementEventMap,
|
|
24
|
+
MenuBarCustomEventMap<TItem> {}
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* `<vaadin-menu-bar>` is a Web Component providing a set of horizontally stacked buttons offering
|
|
@@ -77,20 +79,26 @@ export interface MenuBarEventMap extends HTMLElementEventMap, MenuBarCustomEvent
|
|
|
77
79
|
*
|
|
78
80
|
* @fires {CustomEvent} item-selected - Fired when a submenu item or menu bar button without children is clicked.
|
|
79
81
|
*/
|
|
80
|
-
declare class MenuBar extends
|
|
81
|
-
addEventListener<K extends keyof MenuBarEventMap
|
|
82
|
+
declare class MenuBar<TItem extends MenuBarItem = MenuBarItem> extends HTMLElement {
|
|
83
|
+
addEventListener<K extends keyof MenuBarEventMap<TItem>>(
|
|
82
84
|
type: K,
|
|
83
|
-
listener: (this: MenuBar
|
|
85
|
+
listener: (this: MenuBar<TItem>, ev: MenuBarEventMap<TItem>[K]) => void,
|
|
84
86
|
options?: AddEventListenerOptions | boolean,
|
|
85
87
|
): void;
|
|
86
88
|
|
|
87
|
-
removeEventListener<K extends keyof MenuBarEventMap
|
|
89
|
+
removeEventListener<K extends keyof MenuBarEventMap<TItem>>(
|
|
88
90
|
type: K,
|
|
89
|
-
listener: (this: MenuBar
|
|
91
|
+
listener: (this: MenuBar<TItem>, ev: MenuBarEventMap<TItem>[K]) => void,
|
|
90
92
|
options?: EventListenerOptions | boolean,
|
|
91
93
|
): void;
|
|
92
94
|
}
|
|
93
95
|
|
|
96
|
+
interface MenuBar<TItem extends MenuBarItem = MenuBarItem>
|
|
97
|
+
extends MenuBarMixinClass<TItem>,
|
|
98
|
+
DisabledMixinClass,
|
|
99
|
+
ElementMixinClass,
|
|
100
|
+
ThemableMixinClass {}
|
|
101
|
+
|
|
94
102
|
declare global {
|
|
95
103
|
interface HTMLElementTagNameMap {
|
|
96
104
|
'vaadin-menu-bar': MenuBar;
|
package/src/vaadin-menu-bar.js
CHANGED
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.
|
|
4
|
+
"version": "24.7.0-alpha10",
|
|
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.
|
|
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.7.0-alpha10/#/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.7.0-alpha10/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha10/#/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.7.0-alpha10/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha10/#/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",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
},
|
|
93
93
|
{
|
|
94
94
|
"name": "items",
|
|
95
|
-
"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```",
|
|
95
|
+
"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```",
|
|
96
96
|
"value": {
|
|
97
97
|
"type": [
|
|
98
98
|
"Array.<MenuBarItem>"
|
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.
|
|
4
|
+
"version": "24.7.0-alpha10",
|
|
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.
|
|
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.7.0-alpha10/#/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.7.0-alpha10/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha10/#/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.7.0-alpha10/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.7.0-alpha10/#/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
|
{
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
"name": ".items",
|
|
52
|
-
"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```",
|
|
52
|
+
"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```",
|
|
53
53
|
"value": {
|
|
54
54
|
"kind": "expression"
|
|
55
55
|
}
|