@vaadin/vaadin-select 2.4.3 → 2.4.4
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
|
@@ -15,6 +15,22 @@ $_documentContainer.innerHTML = `<dom-module id="vaadin-select-overlay-styles" t
|
|
|
15
15
|
align-items: flex-start;
|
|
16
16
|
justify-content: flex-start;
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
:host([bottom-aligned]) {
|
|
20
|
+
justify-content: flex-end;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
:host([right-aligned]) {
|
|
24
|
+
align-items: flex-end;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
:host([dir="rtl"]) {
|
|
28
|
+
align-items: flex-end;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
:host([dir="rtl"][right-aligned]) {
|
|
32
|
+
align-items: flex-start;
|
|
33
|
+
}
|
|
18
34
|
</style>
|
|
19
35
|
</template>
|
|
20
36
|
</dom-module>`;
|
package/src/vaadin-select.js
CHANGED
|
@@ -178,7 +178,7 @@ class SelectElement extends
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
static get version() {
|
|
181
|
-
return '2.4.
|
|
181
|
+
return '2.4.4';
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
static get properties() {
|
|
@@ -680,17 +680,22 @@ class SelectElement extends
|
|
|
680
680
|
/** @private */
|
|
681
681
|
_setPosition() {
|
|
682
682
|
const inputRect = this._inputElement.shadowRoot.querySelector('[part~="input-field"]').getBoundingClientRect();
|
|
683
|
+
const viewportWidth = Math.min(window.innerWidth, document.documentElement.clientWidth);
|
|
683
684
|
const viewportHeight = Math.min(window.innerHeight, document.documentElement.clientHeight);
|
|
684
|
-
const
|
|
685
|
+
const shouldAlignRight = this.__shouldAlignRight(inputRect, viewportWidth);
|
|
686
|
+
const shouldAlignBottom = this.__shouldAlignBottom(inputRect, viewportHeight);
|
|
685
687
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
this._overlayElement.style.right =
|
|
688
|
+
if (shouldAlignRight) {
|
|
689
|
+
this._overlayElement.setAttribute('right-aligned', '');
|
|
690
|
+
this._overlayElement.style.right = (viewportWidth - inputRect.right) + 'px';
|
|
691
|
+
this._overlayElement.style.removeProperty('left');
|
|
689
692
|
} else {
|
|
693
|
+
this._overlayElement.removeAttribute('right-aligned');
|
|
690
694
|
this._overlayElement.style.left = inputRect.left + 'px';
|
|
695
|
+
this._overlayElement.style.removeProperty('right');
|
|
691
696
|
}
|
|
692
697
|
|
|
693
|
-
if (
|
|
698
|
+
if (shouldAlignBottom) {
|
|
694
699
|
this._overlayElement.setAttribute('bottom-aligned', '');
|
|
695
700
|
this._overlayElement.style.removeProperty('top');
|
|
696
701
|
this._overlayElement.style.bottom = (viewportHeight - inputRect.bottom) + 'px';
|
|
@@ -703,6 +708,42 @@ class SelectElement extends
|
|
|
703
708
|
this._overlayElement.updateStyles({'--vaadin-select-text-field-width': inputRect.width + 'px'});
|
|
704
709
|
}
|
|
705
710
|
|
|
711
|
+
/** @private */
|
|
712
|
+
__shouldAlignRight(targetRect, viewportWidth) {
|
|
713
|
+
const isRTL = this.getAttribute('dir') === 'rtl';
|
|
714
|
+
const spaceLeft = targetRect.left / viewportWidth;
|
|
715
|
+
const spaceRight = (viewportWidth - targetRect.right) / viewportWidth;
|
|
716
|
+
|
|
717
|
+
if (isRTL) {
|
|
718
|
+
// When RTL mode, should align the dropdown right
|
|
719
|
+
// as long as there is enough space on the left side.
|
|
720
|
+
//
|
|
721
|
+
// Default alignment for RTL:
|
|
722
|
+
//
|
|
723
|
+
// _____Select_____
|
|
724
|
+
// ––––––––––––––––––––––––––
|
|
725
|
+
// | Dropdown |
|
|
726
|
+
// ––––––––––––––––––––––––––
|
|
727
|
+
return spaceLeft > 0.3;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
// When LTL mode, should align the dropdown right
|
|
731
|
+
// only when there is not enough space on the right side.
|
|
732
|
+
//
|
|
733
|
+
// Default alignment for LTL:
|
|
734
|
+
//
|
|
735
|
+
// _____Select_____
|
|
736
|
+
// ––––––––––––––––––––––––––
|
|
737
|
+
// | Dropdown |
|
|
738
|
+
// ––––––––––––––––––––––––––
|
|
739
|
+
return spaceRight < 0.3;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/** @private */
|
|
743
|
+
__shouldAlignBottom(targetRect, viewportHeight) {
|
|
744
|
+
return targetRect.top > (viewportHeight - targetRect.height) / 2;
|
|
745
|
+
}
|
|
746
|
+
|
|
706
747
|
/**
|
|
707
748
|
* Returns true if `value` is valid, and sets the `invalid` flag appropriately.
|
|
708
749
|
*
|
|
@@ -105,10 +105,6 @@ const $_documentContainer = html`<dom-module id="lumo-select" theme-for="vaadin-
|
|
|
105
105
|
--_lumo-item-selected-icon-display: block;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
:host([bottom-aligned]) {
|
|
109
|
-
justify-content: flex-end;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
108
|
[part~="overlay"] {
|
|
113
109
|
min-width: var(--vaadin-select-text-field-width);
|
|
114
110
|
}
|
|
@@ -55,10 +55,6 @@ const $_documentContainer = html`<dom-module id="material-select" theme-for="vaa
|
|
|
55
55
|
</dom-module><dom-module id="material-select-overlay" theme-for="vaadin-select-overlay">
|
|
56
56
|
<template>
|
|
57
57
|
<style include="material-menu-overlay">
|
|
58
|
-
:host([bottom-aligned]) {
|
|
59
|
-
justify-content: flex-end;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
58
|
[part="overlay"] {
|
|
63
59
|
min-width: var(--vaadin-select-text-field-width);
|
|
64
60
|
}
|