@vaadin/menu-bar 23.1.0-alpha4 → 23.1.0-beta3

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.1.0-alpha4",
3
+ "version": "23.1.0-beta3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -35,18 +35,18 @@
35
35
  "dependencies": {
36
36
  "@open-wc/dedupe-mixin": "^1.3.0",
37
37
  "@polymer/polymer": "^3.0.0",
38
- "@vaadin/button": "23.1.0-alpha4",
39
- "@vaadin/component-base": "23.1.0-alpha4",
40
- "@vaadin/vaadin-context-menu": "23.1.0-alpha4",
41
- "@vaadin/vaadin-lumo-styles": "23.1.0-alpha4",
42
- "@vaadin/vaadin-material-styles": "23.1.0-alpha4",
43
- "@vaadin/vaadin-themable-mixin": "23.1.0-alpha4"
38
+ "@vaadin/button": "23.1.0-beta3",
39
+ "@vaadin/component-base": "23.1.0-beta3",
40
+ "@vaadin/vaadin-context-menu": "23.1.0-beta3",
41
+ "@vaadin/vaadin-lumo-styles": "23.1.0-beta3",
42
+ "@vaadin/vaadin-material-styles": "23.1.0-beta3",
43
+ "@vaadin/vaadin-themable-mixin": "23.1.0-beta3"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@esm-bundle/chai": "^4.3.4",
47
- "@vaadin/icon": "23.1.0-alpha4",
47
+ "@vaadin/icon": "23.1.0-beta3",
48
48
  "@vaadin/testing-helpers": "^0.3.2",
49
49
  "sinon": "^13.0.2"
50
50
  },
51
- "gitHead": "aacdb7fe09811894751f0378ff7fb66071892c71"
51
+ "gitHead": "c787ceb8a312f88631c6d429ff320d5f89b1b838"
52
52
  }
@@ -28,6 +28,16 @@ export const ButtonsMixin = (superClass) =>
28
28
  return ['_menuItemsChanged(items, items.splices)'];
29
29
  }
30
30
 
31
+ /**
32
+ * Override getter from `ResizeMixin` to observe parent.
33
+ *
34
+ * @protected
35
+ * @override
36
+ */
37
+ get _observeParent() {
38
+ return true;
39
+ }
40
+
31
41
  /** @protected */
32
42
  ready() {
33
43
  super.ready();
@@ -88,15 +98,20 @@ export const ButtonsMixin = (superClass) =>
88
98
  btn.style.visibility = '';
89
99
  btn.style.position = '';
90
100
 
91
- // teleport item component back from "overflow" sub-menu
101
+ // Teleport item component back from "overflow" sub-menu
92
102
  const item = btn.item && btn.item.component;
93
103
  if (item instanceof HTMLElement && item.classList.contains('vaadin-menu-item')) {
94
104
  btn.appendChild(item);
95
105
  item.classList.remove('vaadin-menu-item');
96
106
  }
97
107
  }
98
- this._overflow.item = { children: [] };
99
- this._hasOverflow = false;
108
+ this.__updateOverflow([]);
109
+ }
110
+
111
+ /** @private */
112
+ __updateOverflow(items) {
113
+ this._overflow.item = { children: items };
114
+ this._hasOverflow = items.length > 0;
100
115
  }
101
116
 
102
117
  /** @private */
@@ -113,7 +128,7 @@ export const ButtonsMixin = (superClass) =>
113
128
  const btn = buttons[i - 1];
114
129
  const btnStyle = getComputedStyle(btn);
115
130
 
116
- // if this button isn't overflowing, then the rest aren't either
131
+ // If this button isn't overflowing, then the rest aren't either
117
132
  if (
118
133
  (!isRTL && btn.offsetLeft + btn.offsetWidth < container.offsetWidth - overflow.offsetWidth) ||
119
134
  (isRTL && btn.offsetLeft >= overflow.offsetWidth)
@@ -124,12 +139,11 @@ export const ButtonsMixin = (superClass) =>
124
139
  btn.disabled = true;
125
140
  btn.style.visibility = 'hidden';
126
141
  btn.style.position = 'absolute';
127
- // save width for buttons with component
142
+ // Save width for buttons with component
128
143
  btn.style.width = btnStyle.width;
129
144
  }
130
- overflow.item = {
131
- children: buttons.filter((b, idx) => idx >= i).map((b) => b.item),
132
- };
145
+ const items = buttons.filter((_, idx) => idx >= i).map((b) => b.item);
146
+ this.__updateOverflow(items);
133
147
  }
134
148
  }
135
149
 
@@ -139,10 +153,10 @@ export const ButtonsMixin = (superClass) =>
139
153
  const buttons = this._buttons.filter((btn) => btn !== overflow);
140
154
  const oldOverflowCount = this.__getOverflowCount(overflow);
141
155
 
142
- // reset all buttons in the menu bar and the overflow button
156
+ // Reset all buttons in the menu bar and the overflow button
143
157
  this.__restoreButtons(buttons);
144
158
 
145
- // hide any overflowing buttons and put them in the 'overflow' button
159
+ // Hide any overflowing buttons and put them in the 'overflow' button
146
160
  this.__setOverflowItems(buttons, overflow);
147
161
 
148
162
  const newOverflowCount = this.__getOverflowCount(overflow);
@@ -171,7 +185,7 @@ export const ButtonsMixin = (superClass) =>
171
185
  if (item.component) {
172
186
  const component = this.__getComponent(itemCopy);
173
187
  itemCopy.component = component;
174
- // save item for overflow menu
188
+ // Save item for overflow menu
175
189
  component.item = itemCopy;
176
190
  button.appendChild(component);
177
191
  } else if (item.text) {
@@ -201,7 +215,7 @@ export const ButtonsMixin = (superClass) =>
201
215
  _setButtonTheme(btn, hostTheme) {
202
216
  let theme = hostTheme;
203
217
 
204
- // item theme takes precedence over host theme even if it's empty, as long as it's not undefined or null
218
+ // Item theme takes precedence over host theme even if it's empty, as long as it's not undefined or null
205
219
  const itemTheme = btn.item && btn.item.theme;
206
220
  if (itemTheme != null) {
207
221
  theme = Array.isArray(itemTheme) ? itemTheme.join(' ') : itemTheme;
@@ -225,7 +239,7 @@ export const ButtonsMixin = (superClass) =>
225
239
  let component;
226
240
 
227
241
  const isElement = itemComponent instanceof HTMLElement;
228
- // use existing item component, if any
242
+ // Use existing item component, if any
229
243
  if (isElement && itemComponent.localName === 'vaadin-context-menu-item') {
230
244
  component = itemComponent;
231
245
  } else {
@@ -160,7 +160,7 @@ export const InteractionsMixin = (superClass) =>
160
160
  idx = buttons.length - 1;
161
161
  break;
162
162
  default:
163
- // do nothing.
163
+ // Do nothing.
164
164
  }
165
165
 
166
166
  idx = this._getAvailableIndex(idx, increment, buttons);
@@ -334,7 +334,7 @@ export const InteractionsMixin = (superClass) =>
334
334
  }
335
335
 
336
336
  this.__onceOpened(() => {
337
- // do not focus item when open not from keyboard
337
+ // Do not focus item when open not from keyboard
338
338
  if (event.type !== 'keydown') {
339
339
  subMenu.$.overlay.$.overlay.focus();
340
340
  }
@@ -35,7 +35,7 @@ class MenuBarSubmenu extends ContextMenu {
35
35
  close() {
36
36
  super.close();
37
37
 
38
- // only handle 1st level submenu
38
+ // Only handle 1st level submenu
39
39
  if (this.hasAttribute('is-root')) {
40
40
  this.getRootNode().host._close();
41
41
  }
@@ -245,7 +245,7 @@ class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(ElementMixin(
245
245
  /** @private */
246
246
  __updateButtonsDisabled(disabled) {
247
247
  this._buttons.forEach((btn) => {
248
- // disable the button if the entire menu-bar is disabled or the item alone is disabled
248
+ // Disable the button if the entire menu-bar is disabled or the item alone is disabled
249
249
  btn.disabled = disabled || (btn.item && btn.item.disabled);
250
250
  });
251
251
  }