@vaadin/menu-bar 23.3.0-alpha1 → 23.3.0-alpha3
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.0-
|
|
3
|
+
"version": "23.3.0-alpha3",
|
|
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": "23.3.0-
|
|
41
|
-
"@vaadin/component-base": "23.3.0-
|
|
42
|
-
"@vaadin/context-menu": "23.3.0-
|
|
43
|
-
"@vaadin/vaadin-lumo-styles": "23.3.0-
|
|
44
|
-
"@vaadin/vaadin-material-styles": "23.3.0-
|
|
45
|
-
"@vaadin/vaadin-themable-mixin": "23.3.0-
|
|
40
|
+
"@vaadin/button": "23.3.0-alpha3",
|
|
41
|
+
"@vaadin/component-base": "23.3.0-alpha3",
|
|
42
|
+
"@vaadin/context-menu": "23.3.0-alpha3",
|
|
43
|
+
"@vaadin/vaadin-lumo-styles": "23.3.0-alpha3",
|
|
44
|
+
"@vaadin/vaadin-material-styles": "23.3.0-alpha3",
|
|
45
|
+
"@vaadin/vaadin-themable-mixin": "23.3.0-alpha3"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@esm-bundle/chai": "^4.3.4",
|
|
49
|
-
"@vaadin/icon": "23.3.0-
|
|
49
|
+
"@vaadin/icon": "23.3.0-alpha3",
|
|
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": "e86cd2abf3e28bade37711291331415d92c454ec"
|
|
58
58
|
}
|
|
@@ -47,7 +47,6 @@ export const InteractionsMixin = (superClass) =>
|
|
|
47
47
|
|
|
48
48
|
const overlay = this._subMenu.$.overlay;
|
|
49
49
|
overlay.addEventListener('keydown', this.__boundOnContextMenuKeydown);
|
|
50
|
-
overlay.addEventListener('vaadin-overlay-open', this.__alignOverlayPosition.bind(this));
|
|
51
50
|
|
|
52
51
|
const container = this._container;
|
|
53
52
|
container.addEventListener('click', this.__onButtonClick.bind(this));
|
|
@@ -98,25 +97,42 @@ export const InteractionsMixin = (superClass) =>
|
|
|
98
97
|
/** @protected */
|
|
99
98
|
disconnectedCallback() {
|
|
100
99
|
super.disconnectedCallback();
|
|
101
|
-
this._hideTooltip();
|
|
100
|
+
this._hideTooltip(true);
|
|
102
101
|
}
|
|
103
102
|
|
|
104
103
|
/**
|
|
105
104
|
* @param {HTMLElement} button
|
|
106
105
|
* @protected
|
|
107
106
|
*/
|
|
108
|
-
_showTooltip(button) {
|
|
107
|
+
_showTooltip(button, isHover) {
|
|
109
108
|
// Check if there is a slotted vaadin-tooltip element.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
const tooltip = this._tooltipController.node;
|
|
110
|
+
if (tooltip && tooltip.isConnected) {
|
|
111
|
+
// If the tooltip element doesn't have a generator assigned, use a default one
|
|
112
|
+
// that reads the `tooltip` property of an item.
|
|
113
|
+
if (tooltip.generator === undefined) {
|
|
114
|
+
tooltip.generator = ({ item }) => item && item.tooltip;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (!this._subMenu.opened) {
|
|
118
|
+
this._tooltipController.setTarget(button);
|
|
119
|
+
this._tooltipController.setContext({ item: button.item });
|
|
120
|
+
|
|
121
|
+
// Trigger opening using the corresponding delay.
|
|
122
|
+
tooltip._stateController.open({
|
|
123
|
+
hover: isHover,
|
|
124
|
+
focus: !isHover,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
114
127
|
}
|
|
115
128
|
}
|
|
116
129
|
|
|
117
130
|
/** @protected */
|
|
118
|
-
_hideTooltip() {
|
|
119
|
-
this._tooltipController.
|
|
131
|
+
_hideTooltip(immediate) {
|
|
132
|
+
const tooltip = this._tooltipController.node;
|
|
133
|
+
if (tooltip) {
|
|
134
|
+
tooltip._stateController.close(immediate);
|
|
135
|
+
}
|
|
120
136
|
}
|
|
121
137
|
|
|
122
138
|
/** @protected */
|
|
@@ -238,7 +254,7 @@ export const InteractionsMixin = (superClass) =>
|
|
|
238
254
|
this._close(true);
|
|
239
255
|
}
|
|
240
256
|
|
|
241
|
-
this._hideTooltip();
|
|
257
|
+
this._hideTooltip(true);
|
|
242
258
|
}
|
|
243
259
|
|
|
244
260
|
/**
|
|
@@ -267,30 +283,6 @@ export const InteractionsMixin = (superClass) =>
|
|
|
267
283
|
return this.shadowRoot.querySelector('vaadin-menu-bar-submenu');
|
|
268
284
|
}
|
|
269
285
|
|
|
270
|
-
/** @private */
|
|
271
|
-
__alignOverlayPosition(e) {
|
|
272
|
-
/* c8 ignore next */
|
|
273
|
-
if (!this._expandedButton) {
|
|
274
|
-
// When `openOnHover` is true, quickly moving cursor can close submenu,
|
|
275
|
-
// so by the time when event listener gets executed button is null.
|
|
276
|
-
// See https://github.com/vaadin/vaadin-menu-bar/issues/85
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
const overlay = e.target;
|
|
280
|
-
const { width, height, left } = this._expandedButton.getBoundingClientRect();
|
|
281
|
-
if (overlay.hasAttribute('bottom-aligned')) {
|
|
282
|
-
overlay.style.bottom = `${parseInt(getComputedStyle(overlay).bottom) + height}px`;
|
|
283
|
-
}
|
|
284
|
-
const endAligned = overlay.hasAttribute('end-aligned');
|
|
285
|
-
if (endAligned) {
|
|
286
|
-
if (this.__isRTL) {
|
|
287
|
-
overlay.style.left = `${left}px`;
|
|
288
|
-
} else {
|
|
289
|
-
overlay.style.right = `${parseInt(getComputedStyle(overlay).right) - width}px`;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
286
|
/** @private */
|
|
295
287
|
_itemsChanged() {
|
|
296
288
|
const subMenu = this._subMenu;
|
|
@@ -305,7 +297,10 @@ export const InteractionsMixin = (superClass) =>
|
|
|
305
297
|
*/
|
|
306
298
|
_onMouseOver(e) {
|
|
307
299
|
const button = this._getButtonFromEvent(e);
|
|
308
|
-
if (button
|
|
300
|
+
if (!button) {
|
|
301
|
+
// Hide tooltip on mouseover to disabled button
|
|
302
|
+
this._hideTooltip();
|
|
303
|
+
} else if (button !== this._expandedButton) {
|
|
309
304
|
const isOpened = this._subMenu.opened;
|
|
310
305
|
if (button.item.children && (this.openOnHover || isOpened)) {
|
|
311
306
|
this.__openSubMenu(button, false);
|
|
@@ -316,7 +311,7 @@ export const InteractionsMixin = (superClass) =>
|
|
|
316
311
|
if (button === this._overflow || (this.openOnHover && button.item.children)) {
|
|
317
312
|
this._hideTooltip();
|
|
318
313
|
} else {
|
|
319
|
-
this._showTooltip(button);
|
|
314
|
+
this._showTooltip(button, true);
|
|
320
315
|
}
|
|
321
316
|
}
|
|
322
317
|
}
|
|
@@ -386,7 +381,7 @@ export const InteractionsMixin = (superClass) =>
|
|
|
386
381
|
},
|
|
387
382
|
}),
|
|
388
383
|
);
|
|
389
|
-
this._hideTooltip();
|
|
384
|
+
this._hideTooltip(true);
|
|
390
385
|
|
|
391
386
|
this._setExpanded(button, true);
|
|
392
387
|
});
|
package/src/vaadin-menu-bar.d.ts
CHANGED
|
@@ -11,10 +11,31 @@ import { ButtonsMixin } from './vaadin-menu-bar-buttons-mixin.js';
|
|
|
11
11
|
import { InteractionsMixin } from './vaadin-menu-bar-interactions-mixin.js';
|
|
12
12
|
|
|
13
13
|
export interface MenuBarItem {
|
|
14
|
+
/**
|
|
15
|
+
* Text to be set as the menu button component's textContent.
|
|
16
|
+
*/
|
|
14
17
|
text?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Text to be set as the menu button's tooltip.
|
|
20
|
+
* Requires a `<vaadin-tooltip slot="tooltip">` element to be added inside the `<vaadin-menu-bar>`.
|
|
21
|
+
*/
|
|
22
|
+
tooltip?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The component to represent the button content.
|
|
25
|
+
* Either a tagName or an element instance. Defaults to "vaadin-context-menu-item".
|
|
26
|
+
*/
|
|
15
27
|
component?: HTMLElement | string;
|
|
28
|
+
/**
|
|
29
|
+
* If true, the button is disabled and cannot be activated.
|
|
30
|
+
*/
|
|
16
31
|
disabled?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Theme(s) to be set as the theme attribute of the button, overriding any theme set on the menu bar.
|
|
34
|
+
*/
|
|
17
35
|
theme?: string[] | string;
|
|
36
|
+
/**
|
|
37
|
+
* Array of submenu items.
|
|
38
|
+
*/
|
|
18
39
|
children?: SubMenuItem[];
|
|
19
40
|
}
|
|
20
41
|
|
package/src/vaadin-menu-bar.js
CHANGED
|
@@ -129,6 +129,8 @@ class MenuBar extends ButtonsMixin(
|
|
|
129
129
|
* @typedef MenuBarItem
|
|
130
130
|
* @type {object}
|
|
131
131
|
* @property {string} text - Text to be set as the menu button component's textContent.
|
|
132
|
+
* @property {string} tooltip - Text to be set as the menu button's tooltip.
|
|
133
|
+
* Requires a `<vaadin-tooltip slot="tooltip">` element to be added inside the `<vaadin-menu-bar>`.
|
|
132
134
|
* @property {union: string | object} component - The component to represent the button content.
|
|
133
135
|
* Either a tagName or an element instance. Defaults to "vaadin-context-menu-item".
|
|
134
136
|
* @property {boolean} disabled - If true, the button is disabled and cannot be activated.
|
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.3.0-
|
|
4
|
+
"version": "23.3.0-alpha3",
|
|
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.3.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/23.3.0-alpha3/#/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-alpha3/#/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-alpha3/#/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-alpha3/#/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-alpha3/#/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.3.0-
|
|
4
|
+
"version": "23.3.0-alpha3",
|
|
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.3.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/23.3.0-alpha3/#/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-alpha3/#/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-alpha3/#/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-alpha3/#/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-alpha3/#/elements/vaadin-overlay).",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|