@vaadin/menu-bar 23.2.0 → 23.3.0-alpha1
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/menu-bar",
|
|
3
|
-
"version": "23.
|
|
3
|
+
"version": "23.3.0-alpha1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -37,16 +37,16 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
39
39
|
"@polymer/polymer": "^3.0.0",
|
|
40
|
-
"@vaadin/button": "
|
|
41
|
-
"@vaadin/component-base": "
|
|
42
|
-
"@vaadin/context-menu": "
|
|
43
|
-
"@vaadin/vaadin-lumo-styles": "
|
|
44
|
-
"@vaadin/vaadin-material-styles": "
|
|
45
|
-
"@vaadin/vaadin-themable-mixin": "
|
|
40
|
+
"@vaadin/button": "23.3.0-alpha1",
|
|
41
|
+
"@vaadin/component-base": "23.3.0-alpha1",
|
|
42
|
+
"@vaadin/context-menu": "23.3.0-alpha1",
|
|
43
|
+
"@vaadin/vaadin-lumo-styles": "23.3.0-alpha1",
|
|
44
|
+
"@vaadin/vaadin-material-styles": "23.3.0-alpha1",
|
|
45
|
+
"@vaadin/vaadin-themable-mixin": "23.3.0-alpha1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@esm-bundle/chai": "^4.3.4",
|
|
49
|
-
"@vaadin/icon": "
|
|
49
|
+
"@vaadin/icon": "23.3.0-alpha1",
|
|
50
50
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
51
51
|
"sinon": "^13.0.2"
|
|
52
52
|
},
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"web-types.json",
|
|
55
55
|
"web-types.lit.json"
|
|
56
56
|
],
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "beabc527d4b1274eb798ff701d406fed45cfe638"
|
|
58
58
|
}
|
|
@@ -4,10 +4,17 @@
|
|
|
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';
|
|
7
|
+
import type { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
|
|
8
|
+
import type { KeyboardDirectionMixinClass } from '@vaadin/component-base/src/keyboard-direction-mixin.js';
|
|
9
|
+
import type { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
7
10
|
|
|
8
11
|
export declare function InteractionsMixin<T extends Constructor<HTMLElement>>(
|
|
9
12
|
base: T,
|
|
10
|
-
): Constructor<
|
|
13
|
+
): Constructor<FocusMixinClass> &
|
|
14
|
+
Constructor<InteractionsMixinClass> &
|
|
15
|
+
Constructor<KeyboardDirectionMixinClass> &
|
|
16
|
+
Constructor<KeyboardMixinClass> &
|
|
17
|
+
T;
|
|
11
18
|
|
|
12
19
|
export declare class InteractionsMixinClass {
|
|
13
20
|
/**
|
|
@@ -3,12 +3,17 @@
|
|
|
3
3
|
* Copyright (c) 2019 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
+
import { FocusMixin } from '@vaadin/component-base/src/focus-mixin.js';
|
|
7
|
+
import { isKeyboardActive } from '@vaadin/component-base/src/focus-utils.js';
|
|
8
|
+
import { KeyboardDirectionMixin } from '@vaadin/component-base/src/keyboard-direction-mixin.js';
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* @polymerMixin
|
|
12
|
+
* @mixes FocusMixin
|
|
13
|
+
* @mixes KeyboardDirectionMixinClass
|
|
9
14
|
*/
|
|
10
15
|
export const InteractionsMixin = (superClass) =>
|
|
11
|
-
class InteractionsMixin extends superClass {
|
|
16
|
+
class InteractionsMixin extends KeyboardDirectionMixin(FocusMixin(superClass)) {
|
|
12
17
|
static get properties() {
|
|
13
18
|
return {
|
|
14
19
|
/**
|
|
@@ -34,8 +39,8 @@ export const InteractionsMixin = (superClass) =>
|
|
|
34
39
|
ready() {
|
|
35
40
|
super.ready();
|
|
36
41
|
|
|
37
|
-
this.addEventListener('
|
|
38
|
-
this.addEventListener('
|
|
42
|
+
this.addEventListener('mousedown', () => this._hideTooltip());
|
|
43
|
+
this.addEventListener('mouseleave', () => this._hideTooltip());
|
|
39
44
|
|
|
40
45
|
this._subMenu.addEventListener('item-selected', this.__onItemSelected.bind(this));
|
|
41
46
|
this._subMenu.addEventListener('close-all-menus', this.__onEscapeClose.bind(this));
|
|
@@ -49,11 +54,71 @@ export const InteractionsMixin = (superClass) =>
|
|
|
49
54
|
container.addEventListener('mouseover', (e) => this._onMouseOver(e));
|
|
50
55
|
}
|
|
51
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Override getter from `KeyboardDirectionMixin`
|
|
59
|
+
* to look for activeElement in shadow root, or
|
|
60
|
+
* use the expanded button as a fallback.
|
|
61
|
+
*
|
|
62
|
+
* @return {Element | null}
|
|
63
|
+
* @protected
|
|
64
|
+
* @override
|
|
65
|
+
*/
|
|
66
|
+
get focused() {
|
|
67
|
+
return this.shadowRoot.activeElement || this._expandedButton;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Override getter from `KeyboardDirectionMixin`.
|
|
72
|
+
*
|
|
73
|
+
* @return {boolean}
|
|
74
|
+
* @protected
|
|
75
|
+
* @override
|
|
76
|
+
*/
|
|
77
|
+
get _vertical() {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Override method inherited from `KeyboardDirectionMixin`
|
|
83
|
+
* to use the list of menu-bar buttons as items.
|
|
84
|
+
*
|
|
85
|
+
* @return {Element[]}
|
|
86
|
+
* @protected
|
|
87
|
+
* @override
|
|
88
|
+
*/
|
|
89
|
+
_getItems() {
|
|
90
|
+
return this._buttons;
|
|
91
|
+
}
|
|
92
|
+
|
|
52
93
|
/** @private */
|
|
53
94
|
get __isRTL() {
|
|
54
95
|
return this.getAttribute('dir') === 'rtl';
|
|
55
96
|
}
|
|
56
97
|
|
|
98
|
+
/** @protected */
|
|
99
|
+
disconnectedCallback() {
|
|
100
|
+
super.disconnectedCallback();
|
|
101
|
+
this._hideTooltip();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @param {HTMLElement} button
|
|
106
|
+
* @protected
|
|
107
|
+
*/
|
|
108
|
+
_showTooltip(button) {
|
|
109
|
+
// Check if there is a slotted vaadin-tooltip element.
|
|
110
|
+
if (this._tooltipController.node && this._tooltipController.node.isConnected && !this._subMenu.opened) {
|
|
111
|
+
this._tooltipController.setTarget(button);
|
|
112
|
+
this._tooltipController.setContext({ item: button.item });
|
|
113
|
+
this._tooltipController.setOpened(true);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** @protected */
|
|
118
|
+
_hideTooltip() {
|
|
119
|
+
this._tooltipController.setOpened(false);
|
|
120
|
+
}
|
|
121
|
+
|
|
57
122
|
/** @protected */
|
|
58
123
|
_setExpanded(button, expanded) {
|
|
59
124
|
button.toggleAttribute('expanded', expanded);
|
|
@@ -66,135 +131,135 @@ export const InteractionsMixin = (superClass) =>
|
|
|
66
131
|
button.setAttribute('tabindex', focused ? '0' : '-1');
|
|
67
132
|
}
|
|
68
133
|
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Override method inherited from `KeyboardDirectionMixin`
|
|
136
|
+
* to close the submenu for the previously focused button
|
|
137
|
+
* and open another one for the newly focused button.
|
|
138
|
+
*
|
|
139
|
+
* @param {Element} item
|
|
140
|
+
* @param {boolean} navigating
|
|
141
|
+
* @protected
|
|
142
|
+
* @override
|
|
143
|
+
*/
|
|
144
|
+
_focusItem(item, navigating) {
|
|
145
|
+
const wasExpanded = navigating && this.focused === this._expandedButton;
|
|
146
|
+
if (wasExpanded) {
|
|
147
|
+
this._close();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
super._focusItem(item, navigating);
|
|
151
|
+
|
|
73
152
|
this._buttons.forEach((btn) => {
|
|
74
|
-
this._setTabindex(btn, btn ===
|
|
153
|
+
this._setTabindex(btn, btn === item);
|
|
75
154
|
});
|
|
76
|
-
}
|
|
77
155
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
156
|
+
if (wasExpanded && item.item && item.item.children) {
|
|
157
|
+
this.__openSubMenu(item, true, { keepFocus: true });
|
|
158
|
+
} else if (item === this._overflow) {
|
|
159
|
+
this._hideTooltip();
|
|
160
|
+
} else {
|
|
161
|
+
this._showTooltip(item);
|
|
162
|
+
}
|
|
81
163
|
}
|
|
82
164
|
|
|
83
165
|
/** @private */
|
|
84
|
-
|
|
85
|
-
return
|
|
166
|
+
_getButtonFromEvent(e) {
|
|
167
|
+
return Array.from(e.composedPath()).find((el) => el.localName === 'vaadin-menu-bar-button');
|
|
86
168
|
}
|
|
87
169
|
|
|
88
170
|
/**
|
|
89
|
-
*
|
|
171
|
+
* Override method inherited from `FocusMixin`
|
|
172
|
+
*
|
|
173
|
+
* @param {boolean} focused
|
|
174
|
+
* @override
|
|
90
175
|
* @protected
|
|
91
176
|
*/
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
this.
|
|
97
|
-
|
|
177
|
+
_setFocused(focused) {
|
|
178
|
+
if (focused) {
|
|
179
|
+
const target = this.shadowRoot.querySelector('[part$="button"][tabindex="0"]');
|
|
180
|
+
if (target) {
|
|
181
|
+
this._buttons.forEach((btn) => {
|
|
182
|
+
this._setTabindex(btn, btn === target);
|
|
183
|
+
if (btn === target && btn !== this._overflow && isKeyboardActive()) {
|
|
184
|
+
this._showTooltip(btn);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
this._hideTooltip();
|
|
98
190
|
}
|
|
99
191
|
}
|
|
100
192
|
|
|
101
193
|
/**
|
|
102
194
|
* @param {!KeyboardEvent} event
|
|
103
|
-
* @
|
|
195
|
+
* @private
|
|
104
196
|
*/
|
|
105
|
-
|
|
197
|
+
_onArrowDown(event) {
|
|
198
|
+
// Prevent page scroll.
|
|
199
|
+
event.preventDefault();
|
|
200
|
+
|
|
106
201
|
const button = this._getButtonFromEvent(event);
|
|
107
|
-
if (button) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
// Menu opened previously, focus first item
|
|
113
|
-
this._focusFirstItem();
|
|
114
|
-
} else {
|
|
115
|
-
this.__openSubMenu(button, event);
|
|
116
|
-
}
|
|
117
|
-
} else if (event.keyCode === 38) {
|
|
118
|
-
// ArrowUp, prevent page scroll
|
|
119
|
-
event.preventDefault();
|
|
120
|
-
if (button === this._expandedButton) {
|
|
121
|
-
// Menu opened previously, focus last item
|
|
122
|
-
this._focusLastItem();
|
|
123
|
-
} else {
|
|
124
|
-
this.__openSubMenu(button, event, { focusLast: true });
|
|
125
|
-
}
|
|
126
|
-
} else if (event.keyCode === 27 && button === this._expandedButton) {
|
|
127
|
-
this._close(true);
|
|
128
|
-
} else {
|
|
129
|
-
this._navigateByKey(event);
|
|
130
|
-
}
|
|
202
|
+
if (button === this._expandedButton) {
|
|
203
|
+
// Menu opened previously, focus first item
|
|
204
|
+
this._focusFirstItem();
|
|
205
|
+
} else {
|
|
206
|
+
this.__openSubMenu(button, true);
|
|
131
207
|
}
|
|
132
208
|
}
|
|
133
209
|
|
|
134
|
-
/**
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
let idx;
|
|
142
|
-
let increment;
|
|
143
|
-
const dirIncrement = this.__isRTL ? -1 : 1;
|
|
144
|
-
|
|
145
|
-
switch (key) {
|
|
146
|
-
case 'Left':
|
|
147
|
-
increment = -dirIncrement;
|
|
148
|
-
idx = currentIdx - dirIncrement;
|
|
149
|
-
break;
|
|
150
|
-
case 'Right':
|
|
151
|
-
increment = dirIncrement;
|
|
152
|
-
idx = currentIdx + dirIncrement;
|
|
153
|
-
break;
|
|
154
|
-
case 'Home':
|
|
155
|
-
increment = 1;
|
|
156
|
-
idx = 0;
|
|
157
|
-
break;
|
|
158
|
-
case 'End':
|
|
159
|
-
increment = -1;
|
|
160
|
-
idx = buttons.length - 1;
|
|
161
|
-
break;
|
|
162
|
-
default:
|
|
163
|
-
// Do nothing.
|
|
164
|
-
}
|
|
210
|
+
/**
|
|
211
|
+
* @param {!KeyboardEvent} event
|
|
212
|
+
* @private
|
|
213
|
+
*/
|
|
214
|
+
_onArrowUp(event) {
|
|
215
|
+
// Prevent page scroll.
|
|
216
|
+
event.preventDefault();
|
|
165
217
|
|
|
166
|
-
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
this._close();
|
|
173
|
-
}
|
|
174
|
-
this._focusButton(btn);
|
|
175
|
-
if (wasExpanded && btn.item && btn.item.children) {
|
|
176
|
-
this.__openSubMenu(btn, event, { keepFocus: true });
|
|
177
|
-
}
|
|
218
|
+
const button = this._getButtonFromEvent(event);
|
|
219
|
+
if (button === this._expandedButton) {
|
|
220
|
+
// Menu opened previously, focus last item
|
|
221
|
+
this._focusLastItem();
|
|
222
|
+
} else {
|
|
223
|
+
this.__openSubMenu(button, true, { focusLast: true });
|
|
178
224
|
}
|
|
179
225
|
}
|
|
180
226
|
|
|
181
|
-
/**
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
227
|
+
/**
|
|
228
|
+
* Override an event listener from `KeyboardMixin`:
|
|
229
|
+
* - to close the sub-menu for expanded button,
|
|
230
|
+
* - to close a tooltip for collapsed button.
|
|
231
|
+
*
|
|
232
|
+
* @param {!KeyboardEvent} event
|
|
233
|
+
* @protected
|
|
234
|
+
* @override
|
|
235
|
+
*/
|
|
236
|
+
_onEscape(event) {
|
|
237
|
+
if (event.composedPath().includes(this._expandedButton)) {
|
|
238
|
+
this._close(true);
|
|
239
|
+
}
|
|
191
240
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
241
|
+
this._hideTooltip();
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Override an event listener from `KeyboardMixin`.
|
|
246
|
+
*
|
|
247
|
+
* @param {!KeyboardEvent} event
|
|
248
|
+
* @protected
|
|
249
|
+
* @override
|
|
250
|
+
*/
|
|
251
|
+
_onKeyDown(event) {
|
|
252
|
+
switch (event.key) {
|
|
253
|
+
case 'ArrowDown':
|
|
254
|
+
this._onArrowDown(event);
|
|
255
|
+
break;
|
|
256
|
+
case 'ArrowUp':
|
|
257
|
+
this._onArrowUp(event);
|
|
258
|
+
break;
|
|
259
|
+
default:
|
|
260
|
+
super._onKeyDown(event);
|
|
261
|
+
break;
|
|
196
262
|
}
|
|
197
|
-
return -1;
|
|
198
263
|
}
|
|
199
264
|
|
|
200
265
|
/** @private */
|
|
@@ -243,16 +308,22 @@ export const InteractionsMixin = (superClass) =>
|
|
|
243
308
|
if (button && button !== this._expandedButton) {
|
|
244
309
|
const isOpened = this._subMenu.opened;
|
|
245
310
|
if (button.item.children && (this.openOnHover || isOpened)) {
|
|
246
|
-
this.__openSubMenu(button,
|
|
311
|
+
this.__openSubMenu(button, false);
|
|
247
312
|
} else if (isOpened) {
|
|
248
313
|
this._close();
|
|
249
314
|
}
|
|
315
|
+
|
|
316
|
+
if (button === this._overflow || (this.openOnHover && button.item.children)) {
|
|
317
|
+
this._hideTooltip();
|
|
318
|
+
} else {
|
|
319
|
+
this._showTooltip(button);
|
|
320
|
+
}
|
|
250
321
|
}
|
|
251
322
|
}
|
|
252
323
|
|
|
253
324
|
/** @private */
|
|
254
325
|
__onContextMenuKeydown(e) {
|
|
255
|
-
const item = Array.from(e.composedPath()).
|
|
326
|
+
const item = Array.from(e.composedPath()).find((el) => el._item);
|
|
256
327
|
if (item) {
|
|
257
328
|
const list = item.parentNode;
|
|
258
329
|
if (e.keyCode === 38 && item === list.items[0]) {
|
|
@@ -262,11 +333,7 @@ export const InteractionsMixin = (superClass) =>
|
|
|
262
333
|
if (e.keyCode === 37 || (e.keyCode === 39 && !item._item.children)) {
|
|
263
334
|
// Prevent ArrowLeft from being handled in context-menu
|
|
264
335
|
e.stopImmediatePropagation();
|
|
265
|
-
this.
|
|
266
|
-
const button = this.shadowRoot.activeElement;
|
|
267
|
-
if (button && button.item && button.item.children) {
|
|
268
|
-
this.__openSubMenu(button, e, { keepFocus: true });
|
|
269
|
-
}
|
|
336
|
+
this._onKeyDown(e);
|
|
270
337
|
}
|
|
271
338
|
}
|
|
272
339
|
}
|
|
@@ -281,12 +348,12 @@ export const InteractionsMixin = (superClass) =>
|
|
|
281
348
|
e.stopPropagation();
|
|
282
349
|
const button = this._getButtonFromEvent(e);
|
|
283
350
|
if (button) {
|
|
284
|
-
this.__openSubMenu(button,
|
|
351
|
+
this.__openSubMenu(button, false);
|
|
285
352
|
}
|
|
286
353
|
}
|
|
287
354
|
|
|
288
355
|
/** @private */
|
|
289
|
-
__openSubMenu(button,
|
|
356
|
+
__openSubMenu(button, keydown, options = {}) {
|
|
290
357
|
const subMenu = this._subMenu;
|
|
291
358
|
const item = button.item;
|
|
292
359
|
|
|
@@ -319,27 +386,33 @@ export const InteractionsMixin = (superClass) =>
|
|
|
319
386
|
},
|
|
320
387
|
}),
|
|
321
388
|
);
|
|
389
|
+
this._hideTooltip();
|
|
322
390
|
|
|
323
391
|
this._setExpanded(button, true);
|
|
324
392
|
});
|
|
325
393
|
|
|
326
|
-
|
|
327
|
-
this.__onceOpened(() => this._focusLastItem());
|
|
328
|
-
}
|
|
394
|
+
this.style.pointerEvents = 'auto';
|
|
329
395
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
396
|
+
overlay.addEventListener(
|
|
397
|
+
'vaadin-overlay-open',
|
|
398
|
+
() => {
|
|
399
|
+
if (options.focusLast) {
|
|
400
|
+
this._focusLastItem();
|
|
401
|
+
}
|
|
335
402
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
403
|
+
if (options.keepFocus) {
|
|
404
|
+
this._focusItem(this._expandedButton, false);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// Do not focus item when open not from keyboard
|
|
408
|
+
if (!keydown) {
|
|
409
|
+
overlay.$.overlay.focus();
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
overlay._updatePosition();
|
|
413
|
+
},
|
|
414
|
+
{ once: true },
|
|
415
|
+
);
|
|
343
416
|
}
|
|
344
417
|
|
|
345
418
|
/** @private */
|
|
@@ -357,17 +430,6 @@ export const InteractionsMixin = (superClass) =>
|
|
|
357
430
|
}
|
|
358
431
|
}
|
|
359
432
|
|
|
360
|
-
/** @private */
|
|
361
|
-
__onceOpened(cb) {
|
|
362
|
-
this.style.pointerEvents = 'auto';
|
|
363
|
-
const overlay = this._subMenu.$.overlay;
|
|
364
|
-
const listener = () => {
|
|
365
|
-
cb();
|
|
366
|
-
overlay.removeEventListener('vaadin-overlay-open', listener);
|
|
367
|
-
};
|
|
368
|
-
overlay.addEventListener('vaadin-overlay-open', listener);
|
|
369
|
-
}
|
|
370
|
-
|
|
371
433
|
/** @private */
|
|
372
434
|
__onItemSelected(e) {
|
|
373
435
|
e.stopPropagation();
|
|
@@ -386,7 +448,7 @@ export const InteractionsMixin = (superClass) =>
|
|
|
386
448
|
if (button && button.hasAttribute('expanded')) {
|
|
387
449
|
this._setExpanded(button, false);
|
|
388
450
|
if (restoreFocus) {
|
|
389
|
-
this.
|
|
451
|
+
this._focusItem(button, false);
|
|
390
452
|
}
|
|
391
453
|
this._expandedButton = null;
|
|
392
454
|
}
|
package/src/vaadin-menu-bar.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright (c) 2019 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
+
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
6
7
|
import { DisabledMixin } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
7
8
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
8
9
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
@@ -89,7 +90,9 @@ export interface MenuBarEventMap extends HTMLElementEventMap, MenuBarCustomEvent
|
|
|
89
90
|
*
|
|
90
91
|
* @fires {CustomEvent} item-selected - Fired when a submenu item or menu bar button without children is clicked.
|
|
91
92
|
*/
|
|
92
|
-
declare class MenuBar extends ButtonsMixin(
|
|
93
|
+
declare class MenuBar extends ButtonsMixin(
|
|
94
|
+
DisabledMixin(InteractionsMixin(ElementMixin(ThemableMixin(ControllerMixin(HTMLElement))))),
|
|
95
|
+
) {
|
|
93
96
|
/**
|
|
94
97
|
* Defines a hierarchical structure, where root level items represent menu bar buttons,
|
|
95
98
|
* and `children` property configures a submenu with items to be opened below
|
package/src/vaadin-menu-bar.js
CHANGED
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
import './vaadin-menu-bar-submenu.js';
|
|
7
7
|
import './vaadin-menu-bar-button.js';
|
|
8
8
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
9
|
+
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
9
10
|
import { DisabledMixin } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
10
11
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
12
|
+
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
11
13
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
12
14
|
import { ButtonsMixin } from './vaadin-menu-bar-buttons-mixin.js';
|
|
13
15
|
import { InteractionsMixin } from './vaadin-menu-bar-interactions-mixin.js';
|
|
@@ -61,13 +63,16 @@ import { InteractionsMixin } from './vaadin-menu-bar-interactions-mixin.js';
|
|
|
61
63
|
* @fires {CustomEvent<boolean>} item-selected - Fired when a submenu item or menu bar button without children is clicked.
|
|
62
64
|
*
|
|
63
65
|
* @extends HTMLElement
|
|
66
|
+
* @mixes ControllerMixin
|
|
64
67
|
* @mixes ButtonsMixin
|
|
65
68
|
* @mixes InteractionsMixin
|
|
66
69
|
* @mixes DisabledMixin
|
|
67
70
|
* @mixes ElementMixin
|
|
68
71
|
* @mixes ThemableMixin
|
|
69
72
|
*/
|
|
70
|
-
class MenuBar extends ButtonsMixin(
|
|
73
|
+
class MenuBar extends ButtonsMixin(
|
|
74
|
+
DisabledMixin(InteractionsMixin(ElementMixin(ThemableMixin(ControllerMixin(PolymerElement))))),
|
|
75
|
+
) {
|
|
71
76
|
static get template() {
|
|
72
77
|
return html`
|
|
73
78
|
<style>
|
|
@@ -109,6 +114,8 @@ class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(ElementMixin(
|
|
|
109
114
|
</vaadin-menu-bar-button>
|
|
110
115
|
</div>
|
|
111
116
|
<vaadin-menu-bar-submenu is-root=""></vaadin-menu-bar-submenu>
|
|
117
|
+
|
|
118
|
+
<slot name="tooltip"></slot>
|
|
112
119
|
`;
|
|
113
120
|
}
|
|
114
121
|
|
|
@@ -213,6 +220,15 @@ class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(ElementMixin(
|
|
|
213
220
|
return ['_themeChanged(_theme)'];
|
|
214
221
|
}
|
|
215
222
|
|
|
223
|
+
/** @protected */
|
|
224
|
+
ready() {
|
|
225
|
+
super.ready();
|
|
226
|
+
|
|
227
|
+
this._tooltipController = new TooltipController(this);
|
|
228
|
+
this._tooltipController.setManual(true);
|
|
229
|
+
this.addController(this._tooltipController);
|
|
230
|
+
}
|
|
231
|
+
|
|
216
232
|
/**
|
|
217
233
|
* Override method inherited from `DisabledMixin`
|
|
218
234
|
* to update the `disabled` property for the buttons
|
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": "23.
|
|
4
|
+
"version": "23.3.0-alpha1",
|
|
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/23.
|
|
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/23.3.0-alpha1/#/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`menu-bar-button` | The menu bar button.\n`overflow-button` | The \"overflow\" button appearing when menu bar width is not enough to fit all the 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/custom-theme/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/23.3.0-alpha1/#/elements/vaadin-button).\n- `<vaadin-context-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha1/#/elements/vaadin-item).\n- `<vaadin-context-menu-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha1/#/elements/vaadin-list-box).\n- `<vaadin-context-menu-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha1/#/elements/vaadin-overlay).",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "open-on-hover",
|
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": "23.
|
|
4
|
+
"version": "23.3.0-alpha1",
|
|
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/23.
|
|
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/23.3.0-alpha1/#/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`menu-bar-button` | The menu bar button.\n`overflow-button` | The \"overflow\" button appearing when menu bar width is not enough to fit all the 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/custom-theme/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/23.3.0-alpha1/#/elements/vaadin-button).\n- `<vaadin-context-menu-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha1/#/elements/vaadin-item).\n- `<vaadin-context-menu-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha1/#/elements/vaadin-list-box).\n- `<vaadin-context-menu-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha1/#/elements/vaadin-overlay).",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|