@vaadin/menu-bar 24.4.0-dev.4b20a0c55.3 → 24.4.0-rc1

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": "24.4.0-dev.4b20a0c55.3",
3
+ "version": "24.4.0-rc1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -39,21 +39,21 @@
39
39
  "dependencies": {
40
40
  "@open-wc/dedupe-mixin": "^1.3.0",
41
41
  "@polymer/polymer": "^3.0.0",
42
- "@vaadin/a11y-base": "24.4.0-dev.4b20a0c55.3",
43
- "@vaadin/button": "24.4.0-dev.4b20a0c55.3",
44
- "@vaadin/component-base": "24.4.0-dev.4b20a0c55.3",
45
- "@vaadin/context-menu": "24.4.0-dev.4b20a0c55.3",
46
- "@vaadin/item": "24.4.0-dev.4b20a0c55.3",
47
- "@vaadin/list-box": "24.4.0-dev.4b20a0c55.3",
48
- "@vaadin/overlay": "24.4.0-dev.4b20a0c55.3",
49
- "@vaadin/vaadin-lumo-styles": "24.4.0-dev.4b20a0c55.3",
50
- "@vaadin/vaadin-material-styles": "24.4.0-dev.4b20a0c55.3",
51
- "@vaadin/vaadin-themable-mixin": "24.4.0-dev.4b20a0c55.3",
42
+ "@vaadin/a11y-base": "24.4.0-rc1",
43
+ "@vaadin/button": "24.4.0-rc1",
44
+ "@vaadin/component-base": "24.4.0-rc1",
45
+ "@vaadin/context-menu": "24.4.0-rc1",
46
+ "@vaadin/item": "24.4.0-rc1",
47
+ "@vaadin/list-box": "24.4.0-rc1",
48
+ "@vaadin/overlay": "24.4.0-rc1",
49
+ "@vaadin/vaadin-lumo-styles": "24.4.0-rc1",
50
+ "@vaadin/vaadin-material-styles": "24.4.0-rc1",
51
+ "@vaadin/vaadin-themable-mixin": "24.4.0-rc1",
52
52
  "lit": "^3.0.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@esm-bundle/chai": "^4.3.4",
56
- "@vaadin/icon": "24.4.0-dev.4b20a0c55.3",
56
+ "@vaadin/icon": "24.4.0-rc1",
57
57
  "@vaadin/testing-helpers": "^0.6.0",
58
58
  "sinon": "^13.0.2"
59
59
  },
@@ -61,5 +61,5 @@
61
61
  "web-types.json",
62
62
  "web-types.lit.json"
63
63
  ],
64
- "gitHead": "41cf17453d7506fb635c088a0425e20b6e82b89b"
64
+ "gitHead": "a81e3b927d44c56613fa4e1307494a2acc81005f"
65
65
  }
@@ -179,6 +179,7 @@ export const MenuBarMixin = (superClass) =>
179
179
  constructor() {
180
180
  super();
181
181
  this.__boundOnContextMenuKeydown = this.__onContextMenuKeydown.bind(this);
182
+ this.__boundOnTooltipMouseLeave = this.__onTooltipOverlayMouseLeave.bind(this);
182
183
  }
183
184
 
184
185
  /**
@@ -262,7 +263,12 @@ export const MenuBarMixin = (superClass) =>
262
263
  container.addEventListener('click', this.__onButtonClick.bind(this));
263
264
  container.addEventListener('mouseover', (e) => this._onMouseOver(e));
264
265
 
265
- this._container = container;
266
+ // Delay setting container to avoid rendering buttons immediately,
267
+ // which would also trigger detecting overflow and force re-layout
268
+ // See https://github.com/vaadin/web-components/issues/7271
269
+ queueMicrotask(() => {
270
+ this._container = container;
271
+ });
266
272
  }
267
273
 
268
274
  /**
@@ -431,12 +437,12 @@ export const MenuBarMixin = (superClass) =>
431
437
  this._hasOverflow = true;
432
438
 
433
439
  const isRTL = this.__isRTL;
434
- const containerLeft = container.getBoundingClientRect().left;
440
+ const containerLeft = container.offsetLeft;
435
441
 
436
442
  const remaining = [...buttons];
437
443
  while (remaining.length) {
438
444
  const lastButton = remaining[remaining.length - 1];
439
- const btnLeft = lastButton.getBoundingClientRect().left - containerLeft;
445
+ const btnLeft = lastButton.offsetLeft - containerLeft;
440
446
 
441
447
  // If this button isn't overflowing, then the rest aren't either
442
448
  if (
@@ -468,6 +474,10 @@ export const MenuBarMixin = (superClass) =>
468
474
 
469
475
  /** @private */
470
476
  __detectOverflow() {
477
+ if (!this._container) {
478
+ return;
479
+ }
480
+
471
481
  const overflow = this._overflow;
472
482
  const buttons = this._buttons.filter((btn) => btn !== overflow);
473
483
  const oldOverflowCount = this.__getOverflowCount(overflow);
@@ -615,6 +625,11 @@ export const MenuBarMixin = (superClass) =>
615
625
  tooltip.generator = ({ item }) => item && item.tooltip;
616
626
  }
617
627
 
628
+ if (!tooltip._mouseLeaveListenerAdded) {
629
+ tooltip._overlayElement.addEventListener('mouseleave', this.__boundOnTooltipMouseLeave);
630
+ tooltip._mouseLeaveListenerAdded = true;
631
+ }
632
+
618
633
  if (!this._subMenu.opened) {
619
634
  this._tooltipController.setTarget(button);
620
635
  this._tooltipController.setContext({ item: button.item });
@@ -636,6 +651,13 @@ export const MenuBarMixin = (superClass) =>
636
651
  }
637
652
  }
638
653
 
654
+ /** @private */
655
+ __onTooltipOverlayMouseLeave(event) {
656
+ if (event.relatedTarget !== this._tooltipController.target) {
657
+ this._hideTooltip();
658
+ }
659
+ }
660
+
639
661
  /** @protected */
640
662
  _setExpanded(button, expanded) {
641
663
  button.toggleAttribute('expanded', expanded);
@@ -0,0 +1,6 @@
1
+ import './vaadin-menu-bar-button-styles.js';
2
+ import './vaadin-menu-bar-item-styles.js';
3
+ import './vaadin-menu-bar-list-box-styles.js';
4
+ import './vaadin-menu-bar-overlay-styles.js';
5
+ import './vaadin-menu-bar-styles.js';
6
+ import '../../src/vaadin-lit-menu-bar.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import './vaadin-menu-bar-button-styles.js';
2
+ import '../../src/vaadin-menu-bar-button.js';
@@ -0,0 +1,2 @@
1
+ import '@vaadin/vaadin-lumo-styles/sizing.js';
2
+ import '@vaadin/vaadin-lumo-styles/spacing.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ import '@vaadin/vaadin-lumo-styles/style.js';
@@ -0,0 +1,6 @@
1
+ import './vaadin-menu-bar-button.js';
2
+ import './vaadin-menu-bar-item-styles.js';
3
+ import './vaadin-menu-bar-list-box-styles.js';
4
+ import './vaadin-menu-bar-overlay-styles.js';
5
+ import './vaadin-menu-bar-styles.js';
6
+ import '../../src/vaadin-menu-bar.js';
@@ -0,0 +1,6 @@
1
+ import './vaadin-menu-bar-button-styles.js';
2
+ import './vaadin-menu-bar-item-styles.js';
3
+ import './vaadin-menu-bar-list-box-styles.js';
4
+ import './vaadin-menu-bar-overlay-styles.js';
5
+ import './vaadin-menu-bar-styles.js';
6
+ import '../../src/vaadin-lit-menu-bar.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import './vaadin-menu-bar-button-styles.js';
2
+ import '../../src/vaadin-menu-bar-button.js';
@@ -0,0 +1 @@
1
+ import '@vaadin/vaadin-material-styles/typography.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import './vaadin-menu-bar-button.js';
2
+ import './vaadin-menu-bar-item-styles.js';
3
+ import './vaadin-menu-bar-list-box-styles.js';
4
+ import './vaadin-menu-bar-styles.js';
5
+ import './vaadin-menu-bar-overlay-styles.js';
6
+ import '../../src/vaadin-menu-bar.js';
package/web-types.json ADDED
@@ -0,0 +1,145 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/web-types",
3
+ "name": "@vaadin/menu-bar",
4
+ "version": "24.4.0-rc1",
5
+ "description-markup": "markdown",
6
+ "contributions": {
7
+ "html": {
8
+ "elements": [
9
+ {
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.4.0-rc1/#/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.4.0-rc1/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-rc1/#/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.4.0-rc1/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-rc1/#/elements/vaadin-overlay).",
12
+ "attributes": [
13
+ {
14
+ "name": "disabled",
15
+ "description": "If true, the user cannot interact with this element.",
16
+ "value": {
17
+ "type": [
18
+ "boolean",
19
+ "null",
20
+ "undefined"
21
+ ]
22
+ }
23
+ },
24
+ {
25
+ "name": "overlay-class",
26
+ "description": "A space-delimited list of CSS class names\nto set on each sub-menu overlay element.",
27
+ "value": {
28
+ "type": [
29
+ "string",
30
+ "null",
31
+ "undefined"
32
+ ]
33
+ }
34
+ },
35
+ {
36
+ "name": "open-on-hover",
37
+ "description": "If true, the submenu will open on hover (mouseover) instead of click.",
38
+ "value": {
39
+ "type": [
40
+ "boolean",
41
+ "null",
42
+ "undefined"
43
+ ]
44
+ }
45
+ },
46
+ {
47
+ "name": "reverse-collapse",
48
+ "description": "If true, the buttons will be collapsed into the overflow menu\nstarting from the \"start\" end of the bar instead of the \"end\".",
49
+ "value": {
50
+ "type": [
51
+ "boolean",
52
+ "null",
53
+ "undefined"
54
+ ]
55
+ }
56
+ },
57
+ {
58
+ "name": "theme",
59
+ "description": "The theme variants to apply to the component.",
60
+ "value": {
61
+ "type": [
62
+ "string",
63
+ "null",
64
+ "undefined"
65
+ ]
66
+ }
67
+ }
68
+ ],
69
+ "js": {
70
+ "properties": [
71
+ {
72
+ "name": "disabled",
73
+ "description": "If true, the user cannot interact with this element.",
74
+ "value": {
75
+ "type": [
76
+ "boolean",
77
+ "null",
78
+ "undefined"
79
+ ]
80
+ }
81
+ },
82
+ {
83
+ "name": "items",
84
+ "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```",
85
+ "value": {
86
+ "type": [
87
+ "Array.<MenuBarItem>"
88
+ ]
89
+ }
90
+ },
91
+ {
92
+ "name": "i18n",
93
+ "description": "The object used to localize this component.\nTo change the default localization, replace the entire\n`i18n` object with a custom one.\n\nTo update individual properties, extend the existing i18n object like so:\n```\nmenuBar.i18n = {\n ...menuBar.i18n,\n moreOptions: 'More options'\n}\n```\n\nThe object has the following JSON structure and default values:\n```\n{\n moreOptions: 'More options'\n}\n```",
94
+ "value": {
95
+ "type": [
96
+ "MenuBarI18n"
97
+ ]
98
+ }
99
+ },
100
+ {
101
+ "name": "overlayClass",
102
+ "description": "A space-delimited list of CSS class names\nto set on each sub-menu overlay element.",
103
+ "value": {
104
+ "type": [
105
+ "string",
106
+ "null",
107
+ "undefined"
108
+ ]
109
+ }
110
+ },
111
+ {
112
+ "name": "openOnHover",
113
+ "description": "If true, the submenu will open on hover (mouseover) instead of click.",
114
+ "value": {
115
+ "type": [
116
+ "boolean",
117
+ "null",
118
+ "undefined"
119
+ ]
120
+ }
121
+ },
122
+ {
123
+ "name": "reverseCollapse",
124
+ "description": "If true, the buttons will be collapsed into the overflow menu\nstarting from the \"start\" end of the bar instead of the \"end\".",
125
+ "value": {
126
+ "type": [
127
+ "boolean",
128
+ "null",
129
+ "undefined"
130
+ ]
131
+ }
132
+ }
133
+ ],
134
+ "events": [
135
+ {
136
+ "name": "item-selected",
137
+ "description": "Fired when either a submenu item or menu bar button without nested children is clicked."
138
+ }
139
+ ]
140
+ }
141
+ }
142
+ ]
143
+ }
144
+ }
145
+ }
@@ -0,0 +1,76 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/web-types",
3
+ "name": "@vaadin/menu-bar",
4
+ "version": "24.4.0-rc1",
5
+ "description-markup": "markdown",
6
+ "framework": "lit",
7
+ "framework-config": {
8
+ "enable-when": {
9
+ "node-packages": [
10
+ "lit"
11
+ ]
12
+ }
13
+ },
14
+ "contributions": {
15
+ "html": {
16
+ "elements": [
17
+ {
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.4.0-rc1/#/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.4.0-rc1/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-rc1/#/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.4.0-rc1/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-rc1/#/elements/vaadin-overlay).",
20
+ "extension": true,
21
+ "attributes": [
22
+ {
23
+ "name": "?disabled",
24
+ "description": "If true, the user cannot interact with this element.",
25
+ "value": {
26
+ "kind": "expression"
27
+ }
28
+ },
29
+ {
30
+ "name": "?openOnHover",
31
+ "description": "If true, the submenu will open on hover (mouseover) instead of click.",
32
+ "value": {
33
+ "kind": "expression"
34
+ }
35
+ },
36
+ {
37
+ "name": "?reverseCollapse",
38
+ "description": "If true, the buttons will be collapsed into the overflow menu\nstarting from the \"start\" end of the bar instead of the \"end\".",
39
+ "value": {
40
+ "kind": "expression"
41
+ }
42
+ },
43
+ {
44
+ "name": ".items",
45
+ "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```",
46
+ "value": {
47
+ "kind": "expression"
48
+ }
49
+ },
50
+ {
51
+ "name": ".i18n",
52
+ "description": "The object used to localize this component.\nTo change the default localization, replace the entire\n`i18n` object with a custom one.\n\nTo update individual properties, extend the existing i18n object like so:\n```\nmenuBar.i18n = {\n ...menuBar.i18n,\n moreOptions: 'More options'\n}\n```\n\nThe object has the following JSON structure and default values:\n```\n{\n moreOptions: 'More options'\n}\n```",
53
+ "value": {
54
+ "kind": "expression"
55
+ }
56
+ },
57
+ {
58
+ "name": ".overlayClass",
59
+ "description": "A space-delimited list of CSS class names\nto set on each sub-menu overlay element.",
60
+ "value": {
61
+ "kind": "expression"
62
+ }
63
+ },
64
+ {
65
+ "name": "@item-selected",
66
+ "description": "Fired when either a submenu item or menu bar button without nested children is clicked.",
67
+ "value": {
68
+ "kind": "expression"
69
+ }
70
+ }
71
+ ]
72
+ }
73
+ ]
74
+ }
75
+ }
76
+ }