@eturnity/eturnity_reusable_components 7.48.1-EPDM-10964.0 → 7.48.1-EPDM-12680.12
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 +2 -3
- package/src/assets/svgIcons/collapse_all.svg +4 -0
- package/src/assets/svgIcons/hybrid.svg +4 -0
- package/src/assets/svgIcons/module.svg +3 -0
- package/src/assets/svgIcons/move_down.svg +3 -0
- package/src/assets/svgIcons/move_up.svg +3 -0
- package/src/assets/svgIcons/optimizer.svg +6 -0
- package/src/assets/svgIcons/string_design.svg +5 -0
- package/src/components/buttons/buttonIcon/index.vue +3 -1
- package/src/components/buttons/mainButton/index.vue +10 -0
- package/src/components/icon/index.vue +1 -0
- package/src/components/infoText/index.vue +289 -125
- package/src/components/infoText/placeholder.vue +225 -0
- package/src/components/inputs/inputNumber/index.vue +185 -11
- package/src/components/inputs/inputText/index.vue +23 -2
- package/src/components/inputs/radioButton/index.vue +27 -6
- package/src/components/inputs/radioButton/radioButton.spec.js +99 -62
- package/src/components/inputs/select/index.vue +69 -21
- package/src/components/inputs/select/option/index.vue +11 -2
- package/src/components/markerItem/index.vue +8 -1
- package/src/components/spinner/index.vue +11 -0
- package/src/components/stringDesign/DropdownMenu/index.vue +711 -0
- package/src/components/tables/mainTable/index.vue +4 -12
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@eturnity/eturnity_reusable_components",
|
3
|
-
"version": "7.48.1-EPDM-
|
3
|
+
"version": "7.48.1-EPDM-12680.12",
|
4
4
|
"files": [
|
5
5
|
"dist",
|
6
6
|
"src"
|
@@ -16,8 +16,7 @@
|
|
16
16
|
"build-storybook": "storybook build",
|
17
17
|
"prettier": "prettier --write 'src/**/*.{js,vue}'",
|
18
18
|
"test": "jest",
|
19
|
-
"test-coverage": "jest --coverage"
|
20
|
-
"prepublishOnly": "npm run test"
|
19
|
+
"test-coverage": "jest --coverage"
|
21
20
|
},
|
22
21
|
"dependencies": {
|
23
22
|
"@originjs/vite-plugin-commonjs": "1.0.3",
|
@@ -0,0 +1,4 @@
|
|
1
|
+
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.22998 11.8962H10.5006H12.2505V10.1463V8.97906H14.0004V5.47917H12.2505V4.31283V2.56289V2.55151H10.5006V2.56289H8.58218L7.76617 4.31283H10.5006V10.1463H5.04599L4.22998 11.8962Z" fill="white"/>
|
3
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.2622 4.79738C6.91629 4.63687 6.53076 4.54729 6.12431 4.54729C4.63054 4.54729 3.41919 5.75796 3.41919 7.25241C3.41919 8.33588 4.05591 9.26984 4.97534 9.70158L7.2622 4.79738ZM5.44786 3.11681C5.44786 3.49042 5.7507 3.79326 6.12431 3.79326C6.49793 3.79326 6.80077 3.49042 6.80077 3.11681V1.76459C6.80077 1.39097 6.49793 1.08813 6.12431 1.08813C5.7507 1.08813 5.44786 1.39097 5.44786 1.76459V3.11681ZM2.02818 7.88939H0.675962C0.302349 7.88939 -0.000488281 7.58655 -0.000488281 7.21294C-0.000488281 6.83932 0.302349 6.53649 0.675962 6.53649H2.02818C2.4018 6.53649 2.70463 6.83932 2.70463 7.21294C2.70463 7.58655 2.4018 7.88939 2.02818 7.88939ZM3.7057 10.5877L2.74955 11.5439C2.4855 11.8079 2.05745 11.8079 1.7934 11.5439C1.52935 11.2798 1.52935 10.8518 1.7934 10.5877L2.74955 9.63155C3.0136 9.36751 3.44165 9.36751 3.7057 9.63155C3.96975 9.8956 3.96975 10.3237 3.7057 10.5877ZM2.74955 4.79432L1.7934 3.83817C1.52935 3.57412 1.52935 3.14607 1.7934 2.88202C2.05745 2.61797 2.4855 2.61797 2.74955 2.88202L3.7057 3.83817C3.96975 4.10222 3.96975 4.53027 3.7057 4.79432C3.44165 5.05837 3.0136 5.05837 2.74955 4.79432Z" fill="white"/>
|
4
|
+
</svg>
|
@@ -0,0 +1,3 @@
|
|
1
|
+
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.0722 3.6H1.6V10.4H11.0722L7.87332 7.60217L7.18484 7L7.87332 6.39783L11.0722 3.6ZM12.4 9.43572V4.56428L9.61516 7L12.4 9.43572ZM0 2H1.6H12.4H14V3.6V10.4V12H12.4H1.6H0V10.4V3.6V2Z" fill="white"/>
|
3
|
+
</svg>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<rect x="3.11079" y="3.10981" width="7.77778" height="7.77778" stroke="white" stroke-width="1.55556"/>
|
3
|
+
<line x1="3.72749" y1="10.3387" x2="10.7275" y2="3.3387" stroke="white" stroke-width="1.55556"/>
|
4
|
+
<line x1="-0.000366211" y1="7.05425" x2="2.99963" y2="7.05425" stroke="white" stroke-width="1.55556"/>
|
5
|
+
<line x1="10.9994" y1="6.99957" x2="13.9994" y2="6.99957" stroke="white" stroke-width="1.55556"/>
|
6
|
+
</svg>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<svg width="10" height="11" viewBox="0 0 10 11" fill="none" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<path d="M2.85714 1.92857C2.85714 2.71755 2.21755 3.35714 1.42857 3.35714C0.639593 3.35714 0 2.71755 0 1.92857C0 1.13959 0.639593 0.5 1.42857 0.5C2.21755 0.5 2.85714 1.13959 2.85714 1.92857Z" fill="white"/>
|
3
|
+
<path d="M10 9.07143C10 9.86041 9.36041 10.5 8.57143 10.5C7.78245 10.5 7.14286 9.86041 7.14286 9.07143C7.14286 8.28245 7.78245 7.64286 8.57143 7.64286C9.36041 7.64286 10 8.28245 10 9.07143Z" fill="white"/>
|
4
|
+
<path d="M5.71429 3C5.71429 2.40827 6.19398 1.92857 6.78571 1.92857C7.37745 1.92857 7.85714 2.40827 7.85714 3V6.21429H9.28571V3C9.28571 1.61929 8.16643 0.5 6.78571 0.5C5.405 0.5 4.28571 1.61929 4.28571 3V8C4.28571 8.59173 3.80602 9.07143 3.21429 9.07143C2.62255 9.07143 2.14286 8.59173 2.14286 8V4.78571H0.714286V8C0.714286 9.38071 1.83357 10.5 3.21429 10.5C4.595 10.5 5.71429 9.38071 5.71429 8V3Z" fill="white"/>
|
5
|
+
</svg>
|
@@ -52,7 +52,9 @@
|
|
52
52
|
props.isDisabled
|
53
53
|
? props.theme.colors.disabled
|
54
54
|
: props.customColor
|
55
|
-
? props.customColor
|
55
|
+
? props.theme.colors[props.customColor]
|
56
|
+
? props.theme.colors[props.customColor]
|
57
|
+
: props.customColor
|
56
58
|
: props.theme.colors.yellow};
|
57
59
|
cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'pointer')};
|
58
60
|
user-select: none;
|
@@ -5,6 +5,7 @@
|
|
5
5
|
:custom-color="customColor"
|
6
6
|
:data-id="dataId"
|
7
7
|
:font-color="fontColor"
|
8
|
+
:height="height"
|
8
9
|
:is-disabled="isDisabled"
|
9
10
|
:min-width="minWidth"
|
10
11
|
:no-wrap="noWrap"
|
@@ -43,8 +44,11 @@
|
|
43
44
|
customColor: String,
|
44
45
|
fontColor: String,
|
45
46
|
noWrap: Boolean,
|
47
|
+
height: String,
|
46
48
|
}
|
47
49
|
const ButtonContainer = styled('div', ButtonAttrs)`
|
50
|
+
display: flex;
|
51
|
+
justify-content: center;
|
48
52
|
padding: 7px 15px;
|
49
53
|
font-size: 13px;
|
50
54
|
color: ${(props) =>
|
@@ -67,6 +71,7 @@
|
|
67
71
|
user-select: none;
|
68
72
|
${(props) => (props.minWidth ? `min-width: ${props.minWidth};` : '')};
|
69
73
|
${(props) => (props.noWrap ? `white-space: nowrap;` : '')};
|
74
|
+
height: ${(props) => props.height};
|
70
75
|
|
71
76
|
&:hover {
|
72
77
|
opacity: ${(props) => (props.isDisabled ? '1' : '0.8')};
|
@@ -136,6 +141,11 @@
|
|
136
141
|
default: null,
|
137
142
|
type: String,
|
138
143
|
},
|
144
|
+
height: {
|
145
|
+
required: false,
|
146
|
+
default: 'auto',
|
147
|
+
type: String,
|
148
|
+
},
|
139
149
|
id: {
|
140
150
|
required: false,
|
141
151
|
default: null,
|
@@ -1,32 +1,35 @@
|
|
1
1
|
<template>
|
2
|
-
<
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
:
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
2
|
+
<PageContainer ref="container">
|
3
|
+
<div
|
4
|
+
ref="icon"
|
5
|
+
data-test-id="infoText_trigger"
|
6
|
+
@click="openTrigger === 'onClick' && toggleInfo()"
|
7
|
+
@mouseenter="openTrigger === 'onHover' && showInfo()"
|
8
|
+
@mouseleave="openTrigger === 'onHover' && hideInfo()"
|
9
|
+
>
|
10
|
+
<IconComponent
|
11
|
+
:color="iconColor"
|
12
|
+
cursor="pointer"
|
13
|
+
name="info"
|
14
|
+
:size="size"
|
15
|
+
/>
|
16
|
+
</div>
|
17
|
+
<Teleport v-if="isVisible" to="body">
|
18
|
+
<TextWrapper :style="wrapperStyle">
|
19
|
+
<TextOverlay ref="infoBox" :image="image" :style="boxStyle">
|
20
|
+
<OverlayImage
|
21
|
+
v-if="image"
|
22
|
+
ref="infoImage"
|
23
|
+
alt="Info Image"
|
24
|
+
:src="image"
|
25
|
+
@load="onImageLoad"
|
26
|
+
/>
|
27
|
+
<span ref="textContent" :style="textStyle" v-html="text"></span>
|
28
|
+
</TextOverlay>
|
29
|
+
<Arrow :image="image" :style="arrowStyle" />
|
30
|
+
</TextWrapper>
|
31
|
+
</Teleport>
|
32
|
+
</PageContainer>
|
30
33
|
</template>
|
31
34
|
|
32
35
|
<script>
|
@@ -35,90 +38,77 @@
|
|
35
38
|
// <info-text
|
36
39
|
// text="Veritatis et quasi architecto beatae vitae"
|
37
40
|
// size="20px"
|
38
|
-
//
|
41
|
+
// openTrigger="onClick"
|
42
|
+
// buttonType="error"
|
43
|
+
// image="path/to/image.jpg"
|
39
44
|
// />
|
40
|
-
import
|
41
|
-
import styled from 'vue3-styled-components'
|
45
|
+
import { ref, onMounted, onUnmounted, watch, nextTick, computed } from 'vue'
|
42
46
|
import IconComponent from '../icon'
|
47
|
+
import styled from 'vue3-styled-components'
|
48
|
+
import theme from '../../assets/theme.js'
|
43
49
|
|
44
|
-
const
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
}
|
51
|
-
const TextOverlay = styled('div', textAttrs)`
|
52
|
-
position: absolute;
|
53
|
-
${(props) =>
|
54
|
-
props.infoPosition == 'top'
|
55
|
-
? 'bottom : calc(' + props.iconSize + ' + 15px)'
|
56
|
-
: 'top : calc(' + props.iconSize + ' + 15px)'};
|
57
|
-
${(props) =>
|
58
|
-
props.alignArrow === 'left'
|
59
|
-
? 'left: calc(' + props.iconSize + ' /2 - 18px)'
|
60
|
-
: props.alignArrow === 'center'
|
61
|
-
? 'left: calc((-' + props.width + ' + ' + props.iconSize + ') /2 + 2px)'
|
62
|
-
: 'right: calc(' + props.iconSize + ' /2 - 17px)'};
|
63
|
-
text-align: left;
|
64
|
-
background: ${(props) => props.theme.colors.black};
|
65
|
-
padding: 10px;
|
66
|
-
width: ${(props) => props.width};
|
67
|
-
max-width: ${(props) => props.maxWidth};
|
68
|
-
font-size: 13px;
|
69
|
-
font-weight: 400;
|
70
|
-
line-height: normal;
|
50
|
+
const TextOverlay = styled('div')`
|
51
|
+
background-color: ${(props) =>
|
52
|
+
props.image ? props.theme.colors.white : props.theme.colors.black};
|
53
|
+
color: ${(props) =>
|
54
|
+
props.image ? props.theme.colors.grey1 : props.theme.colors.white};
|
55
|
+
font-size: ${(props) => (props.image ? '12px' : '13px')};
|
71
56
|
border-radius: 4px;
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
:
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
${(props) =>
|
81
|
-
props.infoPosition == 'top' ? 'bottom : -10px' : 'top: 2px'};
|
57
|
+
padding: 10px;
|
58
|
+
word-wrap: break-word;
|
59
|
+
overflow-wrap: break-word;
|
60
|
+
white-space: normal;
|
61
|
+
width: 100%; // Ensure the TextOverlay takes full width of its parent
|
62
|
+
box-shadow: ${(props) =>
|
63
|
+
props.image ? '0 2px 10px rgba(0, 0, 0, 0.1)' : 'none'};
|
82
64
|
|
83
|
-
|
84
|
-
|
85
|
-
? 'left:40px;'
|
86
|
-
: props.alignArrow == 'center'
|
87
|
-
? 'left: calc(50% + 19px);'
|
88
|
-
: 'right:-13px;'};
|
89
|
-
height: 8px;
|
90
|
-
width: 8px;
|
91
|
-
transform-origin: center center;
|
92
|
-
transform: translate(-2em, -0.5em) rotate(45deg);
|
65
|
+
a {
|
66
|
+
color: ${(props) => props.theme.colors.blue};
|
93
67
|
}
|
94
68
|
|
95
|
-
span
|
96
|
-
|
69
|
+
img + span {
|
70
|
+
margin-top: 10px;
|
71
|
+
display: block;
|
97
72
|
}
|
98
73
|
`
|
99
74
|
|
100
|
-
const
|
101
|
-
|
75
|
+
const Arrow = styled('div')`
|
76
|
+
position: absolute;
|
77
|
+
width: 0;
|
78
|
+
height: 0;
|
79
|
+
border-left: 8px solid transparent;
|
80
|
+
border-right: 8px solid transparent;
|
81
|
+
border-top: 8px solid
|
82
|
+
${(props) =>
|
83
|
+
props.image ? props.theme.colors.white : props.theme.colors.black};
|
84
|
+
filter: ${(props) =>
|
85
|
+
props.image ? 'drop-shadow(0 2px 2px rgba(0, 0, 0, 0.1))' : 'none'};
|
86
|
+
`
|
87
|
+
|
88
|
+
const PageContainer = styled('div')`
|
89
|
+
display: inline-block;
|
102
90
|
position: relative;
|
103
|
-
height: ${(props) => props.size};
|
104
91
|
`
|
105
92
|
|
106
|
-
const
|
107
|
-
|
93
|
+
const TextWrapper = styled('div')`
|
94
|
+
z-index: 99999;
|
95
|
+
position: absolute;
|
108
96
|
`
|
109
97
|
|
110
|
-
const
|
111
|
-
|
98
|
+
const OverlayImage = styled('img')`
|
99
|
+
width: 100%;
|
100
|
+
height: auto;
|
112
101
|
`
|
113
102
|
|
114
103
|
export default {
|
115
104
|
name: 'InfoText',
|
116
105
|
components: {
|
117
|
-
IconWrapper,
|
118
|
-
TextOverlay,
|
119
|
-
ComponentWrapper,
|
120
|
-
IconImg,
|
121
106
|
IconComponent,
|
107
|
+
TextOverlay,
|
108
|
+
Arrow,
|
109
|
+
PageContainer,
|
110
|
+
TextWrapper,
|
111
|
+
OverlayImage,
|
122
112
|
},
|
123
113
|
props: {
|
124
114
|
text: {
|
@@ -127,7 +117,7 @@
|
|
127
117
|
type: String,
|
128
118
|
},
|
129
119
|
size: {
|
130
|
-
|
120
|
+
type: String,
|
131
121
|
default: '14px',
|
132
122
|
type: String,
|
133
123
|
},
|
@@ -136,54 +126,228 @@
|
|
136
126
|
default: 'bottom',
|
137
127
|
type: String,
|
138
128
|
},
|
139
|
-
|
140
|
-
|
141
|
-
default: 'center',
|
129
|
+
maxWidth: {
|
130
|
+
default: '400px',
|
142
131
|
type: String,
|
143
132
|
},
|
144
133
|
openTrigger: {
|
145
|
-
required: false,
|
146
|
-
default: 'onHover', // onHover, onClick
|
147
134
|
type: String,
|
135
|
+
default: 'onHover',
|
136
|
+
validator: (value) => ['onHover', 'onClick'].includes(value),
|
148
137
|
},
|
149
|
-
|
150
|
-
required: false,
|
151
|
-
default: '165px',
|
138
|
+
buttonType: {
|
152
139
|
type: String,
|
140
|
+
default: 'regular',
|
141
|
+
validator: (value) => ['regular', 'error'].includes(value),
|
153
142
|
},
|
154
|
-
|
155
|
-
default: '400px',
|
143
|
+
image: {
|
156
144
|
type: String,
|
145
|
+
default: '',
|
157
146
|
},
|
158
147
|
},
|
159
|
-
|
148
|
+
setup(props) {
|
149
|
+
const isVisible = ref(false)
|
150
|
+
const container = ref(null)
|
151
|
+
const icon = ref(null)
|
152
|
+
const infoBox = ref(null)
|
153
|
+
const textContent = ref(null)
|
154
|
+
const infoImage = ref(null)
|
155
|
+
const infoBoxWidth = ref(0)
|
156
|
+
const infoBoxHeight = ref(0)
|
157
|
+
const boxStyle = ref({})
|
158
|
+
const arrowStyle = ref({})
|
159
|
+
const wrapperStyle = ref({})
|
160
|
+
|
161
|
+
const textStyle = computed(() => ({
|
162
|
+
fontSize: props.image ? '12px' : '13px',
|
163
|
+
color: props.image ? theme.colors.grey1 : theme.colors.white,
|
164
|
+
textAlign: props.image ? 'right' : 'left',
|
165
|
+
}))
|
166
|
+
|
167
|
+
const calculatePosition = (width) => {
|
168
|
+
if (!icon.value) return {}
|
169
|
+
|
170
|
+
const iconRect = icon.value.getBoundingClientRect()
|
171
|
+
const windowHeight = window.innerHeight
|
172
|
+
const windowWidth = window.innerWidth
|
173
|
+
|
174
|
+
let top = iconRect.bottom + 10
|
175
|
+
let left = iconRect.left
|
176
|
+
|
177
|
+
// Adjust left based on the infoBoxWidth
|
178
|
+
if (left + width > windowWidth) {
|
179
|
+
left = windowWidth - width - 10
|
180
|
+
}
|
181
|
+
|
182
|
+
// Ensure there's enough space below or place above if not
|
183
|
+
const isAbove = top + infoBoxHeight.value > windowHeight
|
184
|
+
if (isAbove) {
|
185
|
+
top = iconRect.top - infoBoxHeight.value - 10
|
186
|
+
}
|
187
|
+
|
188
|
+
// Calculate arrow position
|
189
|
+
let arrowLeft = iconRect.left - left + iconRect.width / 2 - 8
|
190
|
+
|
191
|
+
// Adjust arrow position if it's too close to the edges
|
192
|
+
const edgeThreshold = 2 // pixels from the edge to start adjusting
|
193
|
+
if (arrowLeft < edgeThreshold) {
|
194
|
+
arrowLeft = edgeThreshold
|
195
|
+
} else if (arrowLeft > width - 16 - edgeThreshold) {
|
196
|
+
arrowLeft = width - 16 - edgeThreshold
|
197
|
+
}
|
198
|
+
|
199
|
+
const arrowTop = isAbove ? 'auto' : '-7px'
|
200
|
+
const arrowBottom = isAbove ? '-7px' : 'auto'
|
201
|
+
|
202
|
+
arrowStyle.value = {
|
203
|
+
left: `${arrowLeft}px`,
|
204
|
+
top: arrowTop,
|
205
|
+
bottom: arrowBottom,
|
206
|
+
transform: isAbove ? 'none' : 'rotate(180deg)',
|
207
|
+
}
|
208
|
+
|
209
|
+
wrapperStyle.value = {
|
210
|
+
position: 'fixed',
|
211
|
+
top: `${top}px`,
|
212
|
+
left: `${left}px`,
|
213
|
+
transform: 'none',
|
214
|
+
width: `${width}px`, // Set a fixed width for the wrapper
|
215
|
+
}
|
216
|
+
|
217
|
+
return {
|
218
|
+
width: '100%', // Always use 100% width for the TextOverlay
|
219
|
+
maxWidth: props.maxWidth,
|
220
|
+
overflowY: 'auto',
|
221
|
+
backgroundColor: props.image
|
222
|
+
? theme.colors.white
|
223
|
+
: theme.colors.black,
|
224
|
+
}
|
225
|
+
}
|
226
|
+
|
227
|
+
const showInfo = async () => {
|
228
|
+
isVisible.value = true
|
229
|
+
await nextTick()
|
230
|
+
updatePosition()
|
231
|
+
}
|
232
|
+
|
233
|
+
const hideInfo = () => {
|
234
|
+
isVisible.value = false
|
235
|
+
}
|
236
|
+
|
237
|
+
const toggleInfo = () => {
|
238
|
+
isVisible.value ? hideInfo() : showInfo()
|
239
|
+
}
|
240
|
+
|
241
|
+
const handleScroll = () => {
|
242
|
+
if (isVisible.value) {
|
243
|
+
hideInfo()
|
244
|
+
}
|
245
|
+
updatePosition()
|
246
|
+
}
|
247
|
+
|
248
|
+
const isIconInView = () => {
|
249
|
+
if (!icon.value) return false
|
250
|
+
const rect = icon.value.getBoundingClientRect()
|
251
|
+
return (
|
252
|
+
rect.top >= 0 &&
|
253
|
+
rect.left >= 0 &&
|
254
|
+
rect.bottom <=
|
255
|
+
(window.innerHeight || document.documentElement.clientHeight) &&
|
256
|
+
rect.right <=
|
257
|
+
(window.innerWidth || document.documentElement.clientWidth)
|
258
|
+
)
|
259
|
+
}
|
260
|
+
|
261
|
+
const updatePosition = async () => {
|
262
|
+
if (infoBox.value && textContent.value) {
|
263
|
+
await nextTick()
|
264
|
+
|
265
|
+
if (isIconInView()) {
|
266
|
+
const contentWidth = textContent.value.offsetWidth
|
267
|
+
infoBoxWidth.value = Math.min(
|
268
|
+
Math.max(contentWidth, 200), // Set a minimum width of 200px
|
269
|
+
parseInt(props.maxWidth, 10)
|
270
|
+
)
|
271
|
+
infoBoxHeight.value = infoBox.value.$el.offsetHeight
|
272
|
+
boxStyle.value = calculatePosition(infoBoxWidth.value)
|
273
|
+
|
274
|
+
// Now make it visible if it should be
|
275
|
+
if (isVisible.value) {
|
276
|
+
infoBox.value.$el.style.visibility = 'visible'
|
277
|
+
}
|
278
|
+
} else if (isVisible.value) {
|
279
|
+
hideInfo()
|
280
|
+
}
|
281
|
+
}
|
282
|
+
}
|
283
|
+
|
284
|
+
const onImageLoad = () => {
|
285
|
+
if (infoImage.value) {
|
286
|
+
infoBoxHeight.value = infoBox.value.$el.offsetHeight
|
287
|
+
updatePosition()
|
288
|
+
}
|
289
|
+
}
|
290
|
+
|
291
|
+
const handleClickOutside = (event) => {
|
292
|
+
if (props.openTrigger === 'onClick' && isVisible.value) {
|
293
|
+
const clickedElement = event.target
|
294
|
+
if (
|
295
|
+
infoBox.value &&
|
296
|
+
!infoBox.value.$el.contains(clickedElement) &&
|
297
|
+
!icon.value.contains(clickedElement)
|
298
|
+
) {
|
299
|
+
hideInfo()
|
300
|
+
}
|
301
|
+
}
|
302
|
+
}
|
303
|
+
|
304
|
+
onMounted(() => {
|
305
|
+
window.addEventListener('scroll', handleScroll, { passive: true })
|
306
|
+
window.addEventListener('resize', updatePosition)
|
307
|
+
document.addEventListener('scroll', handleScroll, {
|
308
|
+
passive: true,
|
309
|
+
capture: true,
|
310
|
+
})
|
311
|
+
document.addEventListener('click', handleClickOutside)
|
312
|
+
})
|
313
|
+
|
314
|
+
onUnmounted(() => {
|
315
|
+
window.removeEventListener('scroll', handleScroll)
|
316
|
+
window.removeEventListener('resize', updatePosition)
|
317
|
+
document.removeEventListener('scroll', handleScroll, { capture: true })
|
318
|
+
document.removeEventListener('click', handleClickOutside)
|
319
|
+
})
|
320
|
+
|
321
|
+
watch(isVisible, (newValue) => {
|
322
|
+
if (newValue) {
|
323
|
+
updatePosition()
|
324
|
+
}
|
325
|
+
})
|
326
|
+
|
160
327
|
return {
|
161
|
-
|
328
|
+
isVisible,
|
329
|
+
boxStyle,
|
330
|
+
arrowStyle,
|
331
|
+
showInfo,
|
332
|
+
hideInfo,
|
333
|
+
toggleInfo,
|
334
|
+
container,
|
335
|
+
icon,
|
336
|
+
infoBox,
|
337
|
+
textContent,
|
338
|
+
infoImage,
|
339
|
+
infoBoxWidth,
|
340
|
+
infoBoxHeight,
|
341
|
+
wrapperStyle,
|
342
|
+
textStyle,
|
343
|
+
onImageLoad,
|
162
344
|
}
|
163
345
|
},
|
164
346
|
computed: {
|
165
347
|
iconColor() {
|
166
|
-
return
|
167
|
-
|
168
|
-
|
169
|
-
return parseInt(this.width) / 2
|
170
|
-
},
|
171
|
-
},
|
172
|
-
methods: {
|
173
|
-
toggleShowInfo() {
|
174
|
-
this.showInfo = !this.showInfo
|
175
|
-
|
176
|
-
if (this.showInfo) {
|
177
|
-
document.addEventListener('click', this.clickOutside)
|
178
|
-
} else {
|
179
|
-
document.removeEventListener('click', this.clickOutside)
|
180
|
-
}
|
181
|
-
},
|
182
|
-
clickOutside(event) {
|
183
|
-
if (this.$el.contains(event.target)) {
|
184
|
-
return
|
185
|
-
}
|
186
|
-
this.toggleShowInfo()
|
348
|
+
return this.buttonType === 'error'
|
349
|
+
? theme.colors.red
|
350
|
+
: theme.colors.mediumGray
|
187
351
|
},
|
188
352
|
},
|
189
353
|
}
|