@eturnity/eturnity_reusable_components 8.16.2 → 8.16.3
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,12 +138,11 @@
|
|
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
|
"
|
145
|
+
class="rc-select-dropdown"
|
151
146
|
:dropdown-position="dropdownPosition"
|
152
147
|
:font-color="
|
153
148
|
dropdownFontColor ||
|
@@ -167,10 +162,17 @@
|
|
167
162
|
:hovered-index="hoveredIndex"
|
168
163
|
:hovered-value="hoveredValue"
|
169
164
|
:is-active="isActive"
|
165
|
+
:is-fixed-dropdown-position="isFixedDropdownPosition"
|
166
|
+
:is-parent-modal="isParentModal"
|
170
167
|
:min-width="minWidth"
|
171
168
|
:no-relative="noRelative"
|
172
169
|
:option-width="getOptionWidth"
|
173
170
|
:selected-value="selectedValue"
|
171
|
+
:style="{
|
172
|
+
transform: `translate(${dropdownPosition?.left}px, ${
|
173
|
+
noRelative ? 'auto' : `${dropdownPosition?.top}px`
|
174
|
+
})`,
|
175
|
+
}"
|
174
176
|
@mouseleave="optionLeave"
|
175
177
|
@option-hovered="optionHovered"
|
176
178
|
@option-selected="optionSelected"
|
@@ -208,7 +210,7 @@
|
|
208
210
|
// </template>
|
209
211
|
// </Select>
|
210
212
|
|
211
|
-
import { Teleport } from 'vue'
|
213
|
+
import { Teleport, inject } from 'vue'
|
212
214
|
import styled from 'vue3-styled-components'
|
213
215
|
import InfoText from '../../infoText'
|
214
216
|
import Icon from '../../icon'
|
@@ -392,14 +394,17 @@
|
|
392
394
|
selectedValue: Number | String,
|
393
395
|
noRelative: Boolean,
|
394
396
|
minWidth: String,
|
397
|
+
isParentModal: Boolean,
|
398
|
+
isFixedDropdownPosition: Boolean,
|
395
399
|
}
|
396
400
|
const SelectDropdown = styled('div', selectDropdownAttrs)`
|
397
401
|
box-sizing: border-box;
|
398
|
-
z-index: ${(props) =>
|
399
|
-
|
400
|
-
|
401
|
-
props.
|
402
|
-
|
402
|
+
z-index: ${(props) =>
|
403
|
+
props.isActive ? '2' : props.isParentModal ? '9999999' : '99999'};
|
404
|
+
position: ${(props) =>
|
405
|
+
props.isFixedDropdownPosition ? 'fixed' : 'absolute'};
|
406
|
+
top: 0px;
|
407
|
+
left: 0px;
|
403
408
|
border: ${BORDER_WIDTH} solid ${(props) => props.theme.colors.grey4};
|
404
409
|
border-radius: 4px;
|
405
410
|
display: flex;
|
@@ -647,6 +652,11 @@
|
|
647
652
|
type: String,
|
648
653
|
required: false,
|
649
654
|
},
|
655
|
+
isFixedDropdownPosition: {
|
656
|
+
type: Boolean,
|
657
|
+
required: false,
|
658
|
+
default: false,
|
659
|
+
},
|
650
660
|
},
|
651
661
|
|
652
662
|
data() {
|
@@ -664,6 +674,17 @@
|
|
664
674
|
},
|
665
675
|
dropdownWidth: null,
|
666
676
|
hoveredValue: null,
|
677
|
+
isDisplayedAtBottom: true,
|
678
|
+
selectTopPosition: 0,
|
679
|
+
selectAndDropdownDistance: 0,
|
680
|
+
animationFrameId: null,
|
681
|
+
}
|
682
|
+
},
|
683
|
+
setup() {
|
684
|
+
const modalRef = inject('modalRef')
|
685
|
+
|
686
|
+
return {
|
687
|
+
modalRef,
|
667
688
|
}
|
668
689
|
},
|
669
690
|
computed: {
|
@@ -721,6 +742,9 @@
|
|
721
742
|
/windows phone/i.test(userAgent)
|
722
743
|
)
|
723
744
|
},
|
745
|
+
isParentModal() {
|
746
|
+
return !!this.modalRef
|
747
|
+
},
|
724
748
|
},
|
725
749
|
watch: {
|
726
750
|
value(val) {
|
@@ -734,8 +758,13 @@
|
|
734
758
|
}, 10)
|
735
759
|
await this.$nextTick()
|
736
760
|
this.handleSetDropdownOffet()
|
761
|
+
if (!this.isFixedDropdownPosition) this.calculateSelectTopPosition()
|
737
762
|
} else {
|
738
763
|
this.dropdownPosition.left = null
|
764
|
+
if (this.animationFrameId) {
|
765
|
+
cancelAnimationFrame(this.animationFrameId)
|
766
|
+
this.animationFrameId = null
|
767
|
+
}
|
739
768
|
setTimeout(() => {
|
740
769
|
this.isClickOutsideActive = false
|
741
770
|
}, 10)
|
@@ -748,11 +777,30 @@
|
|
748
777
|
})
|
749
778
|
}
|
750
779
|
},
|
780
|
+
isSelectDropdownShown(isShown) {
|
781
|
+
if (!isShown) return
|
782
|
+
// Need to wait for 1ms to make sure the dropdown menu is shown in the DOM
|
783
|
+
// before getting the distance between the select and the dropdown menu
|
784
|
+
setTimeout(() => {
|
785
|
+
this.getDistanceBetweenSelectAndDropdownMenu()
|
786
|
+
}, 100)
|
787
|
+
},
|
788
|
+
selectTopPosition() {
|
789
|
+
this.dropdownPosition.top =
|
790
|
+
this.selectTopPosition +
|
791
|
+
this.$refs.select.$el.clientHeight +
|
792
|
+
this.selectAndDropdownDistance
|
793
|
+
},
|
751
794
|
},
|
752
795
|
mounted() {
|
753
796
|
this.observeDropdownHeight()
|
754
797
|
this.observeSelectWidth()
|
755
798
|
window.addEventListener('resize', this.handleSetDropdownOffet)
|
799
|
+
if (!this.isFixedDropdownPosition)
|
800
|
+
document.body.addEventListener(
|
801
|
+
'scroll',
|
802
|
+
this.calculateSelectTopPosition
|
803
|
+
)
|
756
804
|
},
|
757
805
|
beforeMount() {
|
758
806
|
this.selectedValue = this.value
|
@@ -761,6 +809,12 @@
|
|
761
809
|
window.removeEventListener('resize', this.handleSetDropdownOffet)
|
762
810
|
if (this.dropdownResizeObserver) this.dropdownResizeObserver.disconnect()
|
763
811
|
if (this.selectResizeObserver) this.selectResizeObserver.disconnect()
|
812
|
+
if (!this.isFixedDropdownPosition) {
|
813
|
+
document.body.removeEventListener(
|
814
|
+
'scroll',
|
815
|
+
this.calculateSelectTopPosition
|
816
|
+
)
|
817
|
+
}
|
764
818
|
},
|
765
819
|
unmounted() {
|
766
820
|
document.removeEventListener('click', this.clickOutside)
|
@@ -866,11 +920,11 @@
|
|
866
920
|
return
|
867
921
|
}
|
868
922
|
await this.$nextTick()
|
869
|
-
|
923
|
+
this.isDisplayedAtBottom = await this.generateDropdownPosition()
|
870
924
|
// If the dropdown menu is going to be displayed at the bottom,
|
871
925
|
// we need reverify its position after a dom update (nextTick)
|
872
926
|
await this.$nextTick()
|
873
|
-
if (isDisplayedAtBottom) this.generateDropdownPosition()
|
927
|
+
if (this.isDisplayedAtBottom) this.generateDropdownPosition()
|
874
928
|
},
|
875
929
|
async generateDropdownPosition() {
|
876
930
|
const isDropdownNotCompletelyVisible =
|
@@ -963,6 +1017,25 @@
|
|
963
1017
|
}
|
964
1018
|
}
|
965
1019
|
},
|
1020
|
+
getDistanceBetweenSelectAndDropdownMenu() {
|
1021
|
+
const wholeSelectTopPosition =
|
1022
|
+
this.selectTopPosition + this.$refs.select.$el.clientHeight
|
1023
|
+
this.selectAndDropdownDistance =
|
1024
|
+
this.dropdownPosition.top - wholeSelectTopPosition
|
1025
|
+
},
|
1026
|
+
calculateSelectTopPosition() {
|
1027
|
+
const selectRef = this.$refs.select
|
1028
|
+
if (selectRef) {
|
1029
|
+
const currentTopPosition =
|
1030
|
+
selectRef.$el.getBoundingClientRect().top + window.scrollY
|
1031
|
+
if (this.selectTopPosition !== currentTopPosition) {
|
1032
|
+
this.selectTopPosition = currentTopPosition
|
1033
|
+
}
|
1034
|
+
}
|
1035
|
+
this.animationFrameId = requestAnimationFrame(
|
1036
|
+
this.calculateSelectTopPosition
|
1037
|
+
)
|
1038
|
+
},
|
966
1039
|
},
|
967
1040
|
}
|
968
1041
|
</script>
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<template>
|
2
2
|
<PageWrapper
|
3
3
|
v-if="isOpen"
|
4
|
+
ref="modalRef"
|
4
5
|
:add-padding-top="addPaddingTop"
|
5
6
|
:backdrop="backdrop"
|
6
7
|
:is-open="isOpen"
|
@@ -36,6 +37,7 @@
|
|
36
37
|
// <div>Data....</div>
|
37
38
|
// </modal>
|
38
39
|
|
40
|
+
import { ref, provide } from 'vue'
|
39
41
|
import styled from 'vue3-styled-components'
|
40
42
|
import CloseButton from '../../buttons/closeButton'
|
41
43
|
import Spinner from '../../spinner'
|
@@ -58,14 +60,14 @@
|
|
58
60
|
props.backdrop == 'dark'
|
59
61
|
? 'rgba(0, 0, 0, 0.4)'
|
60
62
|
: 'rgba(255, 255, 255, 0.9)'};
|
61
|
-
z-index:
|
63
|
+
z-index: 9999999;
|
62
64
|
overflow: auto;
|
63
65
|
padding-top: ${(props) => (props.addPaddingTop ? '80px' : '0')};
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
`
|
67
|
+
@media (max-width: 425px) {
|
68
|
+
background: white;
|
69
|
+
}
|
70
|
+
`
|
69
71
|
|
70
72
|
const modalContainerAttrs = { overflow: String, isLoading: Boolean }
|
71
73
|
const ModalContainer = styled('div', modalContainerAttrs)`
|
@@ -163,6 +165,14 @@
|
|
163
165
|
default: false,
|
164
166
|
},
|
165
167
|
},
|
168
|
+
setup() {
|
169
|
+
const modalRef = ref(null)
|
170
|
+
provide('modalRef', modalRef)
|
171
|
+
|
172
|
+
return {
|
173
|
+
modalRef,
|
174
|
+
}
|
175
|
+
},
|
166
176
|
watch: {
|
167
177
|
isOpen: {
|
168
178
|
immediate: true,
|