@vaadin/vaadin-menu-bar
Advanced tools
Comparing version 2.0.0-alpha1 to 2.0.0
{ | ||
"name": "@vaadin/vaadin-menu-bar", | ||
"version": "2.0.0-alpha1", | ||
"version": "2.0.0", | ||
"description": "vaadin-menu-bar", | ||
@@ -62,3 +62,3 @@ "main": "vaadin-menu-bar.js", | ||
"@vaadin/vaadin-button": "^2.4.0", | ||
"@vaadin/vaadin-context-menu": "^5.0.0-alpha1", | ||
"@vaadin/vaadin-context-menu": "^5.0.0", | ||
"@vaadin/vaadin-lumo-styles": "^1.6.1", | ||
@@ -65,0 +65,0 @@ "@vaadin/vaadin-material-styles": "^1.3.2" |
@@ -83,5 +83,26 @@ /** | ||
const overflow = buttons.pop(); | ||
const containerWidth = container.offsetWidth; | ||
const isRTL = this.getAttribute('dir') === 'rtl'; | ||
// reset all buttons in the menu bar and the overflow button | ||
for (let i = 0; i < buttons.length; i++) { | ||
const btn = buttons[i]; | ||
btn.disabled = btn.item.disabled; | ||
btn.style.visibility = ''; | ||
btn.style.position = ''; | ||
// teleport item component back from "overflow" sub-menu | ||
const item = btn.item && btn.item.component; | ||
if (item instanceof HTMLElement && item.classList.contains('vaadin-menu-item')) { | ||
btn.appendChild(item); | ||
item.classList.remove('vaadin-menu-item'); | ||
} | ||
} | ||
overflow.item = { children: [] }; | ||
this._hasOverflow = false; | ||
if (this._subMenu.opened) { | ||
this._subMenu.close(); | ||
} | ||
// hide any overflowing buttons and put them in the 'overflow' button | ||
if (container.offsetWidth < container.scrollWidth) { | ||
@@ -94,9 +115,7 @@ this._hasOverflow = true; | ||
const btnStyle = getComputedStyle(btn); | ||
if (btnStyle.visibility === 'hidden') { | ||
continue; | ||
} | ||
const btnWidth = btn.offsetWidth; | ||
// if this button isn't overflowing, then the rest aren't either | ||
if ( | ||
(!isRTL && btn.offsetLeft + btnWidth < containerWidth - overflow.offsetWidth) || | ||
(!isRTL && btn.offsetLeft + btnWidth < container.offsetWidth - overflow.offsetWidth) || | ||
(isRTL && btn.offsetLeft >= overflow.offsetWidth) | ||
@@ -116,43 +135,2 @@ ) { | ||
}; | ||
} else if (this._hasOverflow) { | ||
if (this._subMenu.opened) { | ||
this._subMenu.close(); | ||
} | ||
for (let i = 0; i < buttons.length; i++) { | ||
const btn = buttons[i]; | ||
const btnWidth = btn.getBoundingClientRect().width; | ||
if (getComputedStyle(btn).visibility !== 'hidden') { | ||
continue; | ||
} | ||
if ( | ||
(!isRTL && overflow.offsetLeft + overflow.offsetWidth + btnWidth < containerWidth) || | ||
(isRTL && btnWidth < overflow.offsetLeft) | ||
) { | ||
btn.disabled = btn.item.disabled; | ||
btn.style.visibility = ''; | ||
btn.style.position = ''; | ||
btn.style.width = ''; | ||
// teleport item component back from "overflow" sub-menu | ||
const item = btn.item && btn.item.component; | ||
if (item instanceof HTMLElement && item.classList.contains('vaadin-menu-item')) { | ||
btn.appendChild(item); | ||
item.classList.remove('vaadin-menu-item'); | ||
} | ||
overflow.item = { | ||
children: buttons.filter((b, idx) => idx >= i + 1).map((b) => b.item) | ||
}; | ||
if (btn === buttons[buttons.length - 1]) { | ||
this._hasOverflow = false; | ||
overflow.item = { children: [] }; | ||
} | ||
} else { | ||
break; | ||
} | ||
} | ||
} | ||
@@ -159,0 +137,0 @@ } |
@@ -64,12 +64,2 @@ /** | ||
/** | ||
* Can be called to manually notify a resizable and its descendant | ||
* resizables of a resize change. | ||
*/ | ||
notifyResize() { | ||
// NOTE: we have this method here to include it to TypeScript definitions. | ||
// gen-typescript-declarations does not generate types for `mixinBehaviors` | ||
super.notifyResize(); | ||
} | ||
/** @private */ | ||
@@ -224,3 +214,3 @@ get __isRTL() { | ||
__alignOverlayPosition(e) { | ||
/* istanbul ignore if */ | ||
/* c8 ignore next */ | ||
if (!this._expandedButton) { | ||
@@ -227,0 +217,0 @@ // When `openOnHover` is true, quickly moving cursor can close submenu, |
@@ -101,3 +101,3 @@ /** | ||
static get version() { | ||
return '2.0.0-alpha1'; | ||
return '2.0.0'; | ||
} | ||
@@ -104,0 +104,0 @@ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
57355
1196