@eturnity/eturnity_reusable_components 8.7.5-EPDM-6306.0 → 8.7.5-qa-16-02-21.1
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
@@ -109,11 +109,7 @@
|
|
109
109
|
>
|
110
110
|
<slot name="selector" :selected-value="selectedValue"></slot>
|
111
111
|
</Selector>
|
112
|
-
<Caret
|
113
|
-
class="caret_dropdown"
|
114
|
-
:color-mode="colorMode"
|
115
|
-
@click.stop="toggleCaretDropdown"
|
116
|
-
>
|
112
|
+
<Caret class="caret_dropdown" :color-mode="colorMode">
|
117
113
|
<Icon
|
118
114
|
v-if="isDropdownOpen"
|
119
115
|
:color="
|
@@ -142,9 +138,7 @@
|
|
142
138
|
v-show="isSelectDropdownShown"
|
143
139
|
ref="dropdown"
|
144
140
|
:bg-color="
|
145
|
-
|
146
|
-
colorMode == 'dark' ||
|
147
|
-
colorMode == 'transparent'
|
141
|
+
colorMode == 'dark' || colorMode == 'transparent'
|
148
142
|
? 'black'
|
149
143
|
: 'white'
|
150
144
|
"
|
@@ -171,6 +165,11 @@
|
|
171
165
|
:no-relative="noRelative"
|
172
166
|
:option-width="getOptionWidth"
|
173
167
|
:selected-value="selectedValue"
|
168
|
+
:style="{
|
169
|
+
transform: `translate(${dropdownPosition?.left}px, ${
|
170
|
+
noRelative ? 'auto' : `${dropdownPosition?.top}px`
|
171
|
+
})`,
|
172
|
+
}"
|
174
173
|
@mouseleave="optionLeave"
|
175
174
|
@option-hovered="optionHovered"
|
176
175
|
@option-selected="optionSelected"
|
@@ -397,9 +396,8 @@
|
|
397
396
|
box-sizing: border-box;
|
398
397
|
z-index: ${(props) => (props.isActive ? '2' : '99999')};
|
399
398
|
position: absolute;
|
400
|
-
top:
|
401
|
-
|
402
|
-
left: ${(props) => props.dropdownPosition?.left}px;
|
399
|
+
top: 0px;
|
400
|
+
left: 0px;
|
403
401
|
border: ${BORDER_WIDTH} solid ${(props) => props.theme.colors.grey4};
|
404
402
|
border-radius: 4px;
|
405
403
|
display: flex;
|
@@ -664,6 +662,10 @@
|
|
664
662
|
},
|
665
663
|
dropdownWidth: null,
|
666
664
|
hoveredValue: null,
|
665
|
+
isDisplayedAtBottom: true,
|
666
|
+
selectTopPosition: 0,
|
667
|
+
selectAndDropdownDistance: 0,
|
668
|
+
animationFrameId: null,
|
667
669
|
}
|
668
670
|
},
|
669
671
|
computed: {
|
@@ -734,8 +736,13 @@
|
|
734
736
|
}, 10)
|
735
737
|
await this.$nextTick()
|
736
738
|
this.handleSetDropdownOffet()
|
739
|
+
this.calculateSelectTopPosition()
|
737
740
|
} else {
|
738
741
|
this.dropdownPosition.left = null
|
742
|
+
if (this.animationFrameId) {
|
743
|
+
cancelAnimationFrame(this.animationFrameId)
|
744
|
+
this.animationFrameId = null
|
745
|
+
}
|
739
746
|
setTimeout(() => {
|
740
747
|
this.isClickOutsideActive = false
|
741
748
|
}, 10)
|
@@ -748,11 +755,26 @@
|
|
748
755
|
})
|
749
756
|
}
|
750
757
|
},
|
758
|
+
isSelectDropdownShown(isShown) {
|
759
|
+
if (!isShown) return
|
760
|
+
// Need to wait for 1ms to make sure the dropdown menu is shown in the DOM
|
761
|
+
// before getting the distance between the select and the dropdown menu
|
762
|
+
setTimeout(() => {
|
763
|
+
this.getDistanceBetweenSelectAndDropdownMenu()
|
764
|
+
}, 100)
|
765
|
+
},
|
766
|
+
selectTopPosition() {
|
767
|
+
this.dropdownPosition.top =
|
768
|
+
this.selectTopPosition +
|
769
|
+
this.$refs.select.$el.clientHeight +
|
770
|
+
this.selectAndDropdownDistance
|
771
|
+
},
|
751
772
|
},
|
752
773
|
mounted() {
|
753
774
|
this.observeDropdownHeight()
|
754
775
|
this.observeSelectWidth()
|
755
776
|
window.addEventListener('resize', this.handleSetDropdownOffet)
|
777
|
+
document.body.addEventListener('scroll', this.calculateSelectTopPosition)
|
756
778
|
},
|
757
779
|
beforeMount() {
|
758
780
|
this.selectedValue = this.value
|
@@ -761,6 +783,10 @@
|
|
761
783
|
window.removeEventListener('resize', this.handleSetDropdownOffet)
|
762
784
|
if (this.dropdownResizeObserver) this.dropdownResizeObserver.disconnect()
|
763
785
|
if (this.selectResizeObserver) this.selectResizeObserver.disconnect()
|
786
|
+
document.body.removeEventListener(
|
787
|
+
'scroll',
|
788
|
+
this.calculateSelectTopPosition
|
789
|
+
)
|
764
790
|
},
|
765
791
|
unmounted() {
|
766
792
|
document.removeEventListener('click', this.clickOutside)
|
@@ -828,6 +854,7 @@
|
|
828
854
|
})
|
829
855
|
},
|
830
856
|
clickOutside(event) {
|
857
|
+
console.log('clickOutside')
|
831
858
|
const dropdownRef = this.$refs.dropdown
|
832
859
|
// we need to prevent closing on selecting an option, because in the case of
|
833
860
|
// a disabled option, we don't want to close the dropdown
|
@@ -866,11 +893,11 @@
|
|
866
893
|
return
|
867
894
|
}
|
868
895
|
await this.$nextTick()
|
869
|
-
|
896
|
+
this.isDisplayedAtBottom = await this.generateDropdownPosition()
|
870
897
|
// If the dropdown menu is going to be displayed at the bottom,
|
871
898
|
// we need reverify its position after a dom update (nextTick)
|
872
899
|
await this.$nextTick()
|
873
|
-
if (isDisplayedAtBottom) this.generateDropdownPosition()
|
900
|
+
if (this.isDisplayedAtBottom) this.generateDropdownPosition()
|
874
901
|
},
|
875
902
|
async generateDropdownPosition() {
|
876
903
|
const isDropdownNotCompletelyVisible =
|
@@ -963,6 +990,25 @@
|
|
963
990
|
}
|
964
991
|
}
|
965
992
|
},
|
993
|
+
getDistanceBetweenSelectAndDropdownMenu() {
|
994
|
+
const wholeSelectTopPosition =
|
995
|
+
this.selectTopPosition + this.$refs.select.$el.clientHeight
|
996
|
+
this.selectAndDropdownDistance =
|
997
|
+
this.dropdownPosition.top - wholeSelectTopPosition
|
998
|
+
},
|
999
|
+
calculateSelectTopPosition() {
|
1000
|
+
const selectRef = this.$refs.select
|
1001
|
+
if (selectRef) {
|
1002
|
+
const currentTopPosition =
|
1003
|
+
selectRef.$el.getBoundingClientRect().top + window.scrollY
|
1004
|
+
if (this.selectTopPosition !== currentTopPosition) {
|
1005
|
+
this.selectTopPosition = currentTopPosition
|
1006
|
+
}
|
1007
|
+
}
|
1008
|
+
this.animationFrameId = requestAnimationFrame(
|
1009
|
+
this.calculateSelectTopPosition
|
1010
|
+
)
|
1011
|
+
},
|
966
1012
|
},
|
967
1013
|
}
|
968
1014
|
</script>
|