@eturnity/eturnity_reusable_components 7.24.3-EPDM-11320.3 → 7.24.3-qa-elisee-7.32.0
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/.prettierrc +6 -8
- package/package.json +21 -9
- package/public/favicon.ico +0 -0
- package/public/index.html +17 -0
- package/src/App.vue +78 -79
- package/src/assets/svgIcons/adjust_roof.svg +6 -0
- package/src/assets/svgIcons/copy.svg +10 -0
- package/src/assets/theme.js +3 -3
- package/src/components/addNewButton/AddNewButton.stories.js +2 -2
- package/src/components/addNewButton/index.vue +51 -48
- package/src/components/banner/actionBanner/index.vue +55 -54
- package/src/components/banner/banner/banner.stories.js +5 -5
- package/src/components/banner/banner/index.vue +159 -159
- package/src/components/banner/infoBanner/index.vue +53 -41
- package/src/components/buttons/buttonIcon/index.vue +122 -125
- package/src/components/buttons/closeButton/CloseButton.stories.js +3 -3
- package/src/components/buttons/closeButton/index.vue +49 -49
- package/src/components/buttons/mainButton/index.vue +119 -119
- package/src/components/card/index.vue +70 -70
- package/src/components/collapsableInfoText/index.vue +94 -96
- package/src/components/deleteIcon/DeleteIcon.stories.js +4 -4
- package/src/components/deleteIcon/index.vue +54 -54
- package/src/components/draggableInputHandle/index.vue +37 -37
- package/src/components/dropdown/Dropdown.stories.js +10 -9
- package/src/components/dropdown/index.vue +106 -106
- package/src/components/errorMessage/index.vue +52 -52
- package/src/components/filter/filterSettings.vue +433 -439
- package/src/components/filter/index.vue +135 -135
- package/src/components/filter/parentDropdown.vue +73 -73
- package/src/components/icon/Icons.stories.js +7 -7
- package/src/components/icon/iconCollection.vue +53 -53
- package/src/components/icon/index.vue +121 -121
- package/src/components/iconWrapper/index.vue +156 -156
- package/src/components/infoCard/index.vue +26 -26
- package/src/components/infoText/index.vue +132 -133
- package/src/components/inputs/checkbox/Checkbox.stories.js +8 -8
- package/src/components/inputs/checkbox/index.vue +180 -190
- package/src/components/inputs/inputNumber/InputNumber.stories.js +41 -41
- package/src/components/inputs/inputNumber/index.vue +644 -647
- package/src/components/inputs/inputNumberQuestion/index.vue +182 -185
- package/src/components/inputs/inputText/InputText.stories.js +22 -22
- package/src/components/inputs/inputText/index.vue +336 -337
- package/src/components/inputs/radioButton/RadioButton.stories.js +16 -16
- package/src/components/inputs/radioButton/index.vue +219 -221
- package/src/components/inputs/searchInput/SearchInput.stories.js +8 -8
- package/src/components/inputs/searchInput/index.vue +126 -127
- package/src/components/inputs/select/index.vue +776 -778
- package/src/components/inputs/select/option/index.vue +124 -124
- package/src/components/inputs/select/select.stories.js +32 -31
- package/src/components/inputs/slider/index.vue +99 -99
- package/src/components/inputs/switchField/index.vue +222 -220
- package/src/components/inputs/textAreaInput/TextAreaInput.stories.js +57 -57
- package/src/components/inputs/textAreaInput/index.vue +173 -171
- package/src/components/inputs/toggle/Toggle.stories.js +14 -14
- package/src/components/inputs/toggle/index.vue +217 -214
- package/src/components/label/index.vue +82 -82
- package/src/components/markerItem/index.vue +66 -68
- package/src/components/modals/actionModal/index.vue +54 -54
- package/src/components/modals/infoModal/index.vue +36 -39
- package/src/components/modals/modal/index.vue +134 -134
- package/src/components/modals/modal/modal.stories.js +5 -5
- package/src/components/navigationTabs/index.vue +94 -96
- package/src/components/pageSubtitle/index.vue +49 -55
- package/src/components/pageTitle/index.vue +56 -56
- package/src/components/pagination/index.vue +89 -92
- package/src/components/progressBar/index.vue +107 -107
- package/src/components/projectMarker/index.vue +244 -246
- package/src/components/rangeSlider/Slider.vue +465 -491
- package/src/components/rangeSlider/index.vue +410 -410
- package/src/components/rangeSlider/utils/dom.js +5 -5
- package/src/components/selectedOptions/index.vue +119 -119
- package/src/components/sideMenu/index.vue +199 -199
- package/src/components/spinner/index.vue +57 -57
- package/src/components/tableDropdown/index.vue +520 -520
- package/src/components/tables/mainTable/index.vue +362 -366
- package/src/components/tables/viewTable/index.vue +171 -171
- package/src/components/threeDots/index.vue +334 -340
- package/src/components/videoThumbnail/index.vue +86 -86
- package/src/components/videoThumbnail/videoThumbnail.stories.js +16 -14
- package/src/helpers/numberConverter.js +2 -2
- package/src/helpers/translateLang.js +9 -9
- package/src/mixins/inputValidations.js +5 -5
- package/.eslintrc.js +0 -184
@@ -1,55 +1,53 @@
|
|
1
1
|
<template>
|
2
|
-
<
|
2
|
+
<page-container
|
3
|
+
@click="toggleButton()"
|
3
4
|
ref="pageContainer"
|
4
5
|
:activated="isOpen"
|
5
|
-
@click="toggleButton()"
|
6
6
|
>
|
7
|
-
<
|
8
|
-
<
|
9
|
-
<
|
10
|
-
<
|
11
|
-
</
|
12
|
-
<
|
13
|
-
ref="dropdownContainer"
|
14
|
-
:container-width="childOpen ? 440 : 240"
|
7
|
+
<button-container ref="dropdownItem">
|
8
|
+
<dot-item />
|
9
|
+
<dot-item />
|
10
|
+
<dot-item />
|
11
|
+
</button-container>
|
12
|
+
<dropdown-container
|
15
13
|
@click.stop
|
14
|
+
:containerWidth="childOpen ? 440 : 240"
|
15
|
+
ref="dropdownContainer"
|
16
16
|
>
|
17
17
|
<template v-if="isOpen">
|
18
|
-
<
|
19
|
-
<
|
20
|
-
</
|
21
|
-
<
|
22
|
-
v-if="hoverItem !== null && !isLoading"
|
18
|
+
<loading-container v-if="isLoading">
|
19
|
+
<spinner />
|
20
|
+
</loading-container>
|
21
|
+
<children-container
|
23
22
|
class="child"
|
24
|
-
:
|
23
|
+
:isOpen="hoverItem !== null"
|
24
|
+
v-if="hoverItem !== null && !isLoading"
|
25
25
|
>
|
26
|
-
<
|
26
|
+
<option-child
|
27
27
|
v-for="child in childOpen"
|
28
28
|
:key="child.value"
|
29
29
|
@click.stop="
|
30
30
|
onSelect({
|
31
31
|
item: child,
|
32
|
-
hasChildren: hasChildren(child)
|
32
|
+
hasChildren: hasChildren(child)
|
33
33
|
})
|
34
34
|
"
|
35
35
|
@keyup.enter.stop="
|
36
36
|
onSelect({
|
37
37
|
item: child,
|
38
|
-
hasChildren: hasChildren(child)
|
38
|
+
hasChildren: hasChildren(child)
|
39
39
|
})
|
40
40
|
"
|
41
41
|
>
|
42
42
|
{{ child.name }}
|
43
|
-
</
|
44
|
-
</
|
45
|
-
<
|
46
|
-
<
|
43
|
+
</option-child>
|
44
|
+
</children-container>
|
45
|
+
<options-container v-if="!isLoading" :textWrap="textWrap">
|
46
|
+
<option-item
|
47
47
|
v-for="(item, index) in options"
|
48
48
|
:key="item.value"
|
49
49
|
:data-id="item.dataId"
|
50
|
-
:is-disabled="item.disabled"
|
51
50
|
tabindex="0"
|
52
|
-
:title="item.title"
|
53
51
|
@click.stop="
|
54
52
|
onSelect({ item: item, hasChildren: hasChildren(item) })
|
55
53
|
"
|
@@ -57,357 +55,353 @@
|
|
57
55
|
onSelect({ item: item, hasChildren: hasChildren(item) })
|
58
56
|
"
|
59
57
|
@mouseover="onItemHover({ index, item })"
|
58
|
+
:isDisabled="item.disabled"
|
59
|
+
:title="item.title"
|
60
60
|
>
|
61
|
-
<
|
61
|
+
<arrow-left
|
62
|
+
:hasChildren="hasChildren(item)"
|
62
63
|
v-if="hasChildren(item)"
|
63
|
-
:has-children="hasChildren(item)"
|
64
64
|
/>
|
65
65
|
<span>
|
66
66
|
{{ item.name }}
|
67
67
|
</span>
|
68
|
-
</
|
69
|
-
</
|
68
|
+
</option-item>
|
69
|
+
</options-container>
|
70
70
|
</template>
|
71
|
-
</
|
72
|
-
</
|
71
|
+
</dropdown-container>
|
72
|
+
</page-container>
|
73
73
|
</template>
|
74
74
|
|
75
75
|
<script>
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
76
|
+
// import ThreeDots from "@eturnity/eturnity_reusable_components/src/components/threeDots"
|
77
|
+
// To use:
|
78
|
+
// <three-dots
|
79
|
+
// :isLoading="true"
|
80
|
+
// :options="listOptions"
|
81
|
+
// @on-click="onClick($event)"
|
82
|
+
// @on-select="onSelect($event)"
|
83
|
+
// />
|
84
|
+
// options to pass:
|
85
|
+
// listOptions: [
|
86
|
+
// {
|
87
|
+
// name: "Option 1",
|
88
|
+
// value: "option_1",
|
89
|
+
// children: [
|
90
|
+
// {
|
91
|
+
// name: "Option 1 Child",
|
92
|
+
// value: "option_1_child",
|
93
|
+
// },
|
94
|
+
// {
|
95
|
+
// name: "Option 2 Child",
|
96
|
+
// value: "option_2_child",
|
97
|
+
// },
|
98
|
+
// {
|
99
|
+
// name: "Option 3 Child",
|
100
|
+
// value: "option_3_child",
|
101
|
+
// },
|
102
|
+
// ],
|
103
|
+
// },
|
104
|
+
// {
|
105
|
+
// name: "Option 2",
|
106
|
+
// value: "option_2",
|
107
|
+
// },
|
108
|
+
// {
|
109
|
+
// name: "Option 3",
|
110
|
+
// value: "option_3",
|
111
|
+
// children: [
|
112
|
+
// {
|
113
|
+
// name: "Option 3 Child",
|
114
|
+
// value: "option_3_child",
|
115
|
+
// },
|
116
|
+
// {
|
117
|
+
// name: "Option 4 Child",
|
118
|
+
// value: "option_4_child",
|
119
|
+
// },
|
120
|
+
// {
|
121
|
+
// name: "Option 5 Child",
|
122
|
+
// value: "option_5_child",
|
123
|
+
// },
|
124
|
+
// ],
|
125
|
+
// },
|
126
|
+
// {
|
127
|
+
// name: "Option 4",
|
128
|
+
// value: "option_4",
|
129
|
+
// },
|
130
|
+
// ],
|
131
131
|
|
132
|
-
|
133
|
-
|
132
|
+
import styled from 'vue3-styled-components'
|
133
|
+
import Spinner from '../spinner'
|
134
134
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
135
|
+
const PageContainerAttrs = {
|
136
|
+
activated: Boolean
|
137
|
+
}
|
138
|
+
const PageContainer = styled('div', PageContainerAttrs)`
|
139
|
+
display: grid;
|
140
|
+
align-items: center;
|
141
|
+
justify-items: center;
|
142
|
+
width: 30px;
|
143
|
+
height: 30px;
|
144
|
+
border-radius: 4px;
|
145
|
+
background-color: ${(props) =>
|
146
|
+
props.activated ? props.theme.colors.grey5 : ''};
|
147
147
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
148
|
+
&:hover {
|
149
|
+
background-color: ${(props) => props.theme.colors.grey5};
|
150
|
+
}
|
151
|
+
`
|
152
152
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
153
|
+
const ButtonContainer = styled.div`
|
154
|
+
display: flex;
|
155
|
+
flex-direction: column;
|
156
|
+
align-items: center;
|
157
|
+
justify-content: center;
|
158
|
+
padding: 5px;
|
159
|
+
cursor: pointer;
|
160
160
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
161
|
+
div {
|
162
|
+
// This is the dot color
|
163
|
+
background-color: #263238;
|
164
|
+
}
|
165
|
+
`
|
166
166
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
167
|
+
const DotItem = styled.div`
|
168
|
+
width: 4px;
|
169
|
+
height: 4px;
|
170
|
+
margin: 1px;
|
171
|
+
border-radius: 50%;
|
172
|
+
`
|
173
173
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
174
|
+
const dropdownAttrs = {
|
175
|
+
containerWidth: Number
|
176
|
+
}
|
177
|
+
const DropdownContainer = styled('div', dropdownAttrs)`
|
178
|
+
z-index: 99;
|
179
|
+
position: absolute;
|
180
|
+
display: grid;
|
181
|
+
grid-template-columns: auto auto;
|
182
|
+
`
|
183
183
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
184
|
+
const LoadingContainer = styled.div`
|
185
|
+
border: 1px solid ${(props) => props.theme.colors.grey3};
|
186
|
+
display: grid;
|
187
|
+
grid-template-columns: 1fr;
|
188
|
+
min-width: 100px;
|
189
|
+
height: 100px;
|
190
|
+
align-items: center;
|
191
|
+
justify-items: center;
|
192
|
+
background: #fff;
|
193
|
+
`
|
194
194
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
`
|
195
|
+
const OptionsContainerAttrs = { textWrap: Boolean }
|
196
|
+
const OptionsContainer = styled('div', OptionsContainerAttrs)`
|
197
|
+
border: 1px solid ${(props) => props.theme.colors.grey3};
|
198
|
+
display: grid;
|
199
|
+
grid-template-columns: 1fr;
|
200
|
+
${(props) => props.textWrap ? 'width: 220px' : 'width: max-content' };
|
201
|
+
border-radius: 4px;
|
202
|
+
background-color: #fff;
|
203
|
+
max-height: 220px;
|
204
|
+
overflow: auto;
|
205
|
+
height: max-content;
|
206
|
+
${(props) => props.textWrap ? 'white-space: normal' : 'white-space: nowrap'};
|
207
|
+
`
|
209
208
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
? `background-color: ${props.theme.colors.grey5}!important`
|
219
|
-
: ''};
|
220
|
-
${(props) =>
|
221
|
-
props.isDisabled ? `color: ${props.theme.colors.grey2}` : ''};
|
209
|
+
const optionAttrs = { isDisabled: Boolean }
|
210
|
+
const OptionItem = styled('div', optionAttrs)`
|
211
|
+
padding: 12px;
|
212
|
+
cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'pointer')};
|
213
|
+
font-size: 13px;
|
214
|
+
position: relative;
|
215
|
+
${(props) => (props.isDisabled ? `background-color: ${ props.theme.colors.grey5 }!important` : '')};
|
216
|
+
${(props) => (props.isDisabled ? `color: ${ props.theme.colors.grey2 }` : '')};
|
222
217
|
|
223
|
-
|
224
|
-
|
225
|
-
|
218
|
+
&:hover {
|
219
|
+
background-color: #ebeef4;
|
220
|
+
}
|
226
221
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
222
|
+
&:focus-visible {
|
223
|
+
outline: none;
|
224
|
+
background-color: #ebeef4;
|
225
|
+
}
|
226
|
+
`
|
227
|
+
const OptionChild = styled.div`
|
228
|
+
padding: 12px;
|
229
|
+
cursor: pointer;
|
230
|
+
font-size: 13px;
|
231
|
+
position: relative;
|
237
232
|
|
238
|
-
|
239
|
-
|
240
|
-
|
233
|
+
&:hover {
|
234
|
+
background-color: #ebeef4;
|
235
|
+
}
|
241
236
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
237
|
+
&:focus-visible {
|
238
|
+
outline: none;
|
239
|
+
background-color: #ebeef4;
|
240
|
+
}
|
241
|
+
`
|
247
242
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
243
|
+
const arrowAttrs = { hasChildren: Boolean }
|
244
|
+
const ArrowLeft = styled('span', arrowAttrs)`
|
245
|
+
border: solid #9f9f9f;
|
246
|
+
border-width: 0 1.5px 1.5px 0;
|
247
|
+
display: inline-block;
|
248
|
+
padding: 3px;
|
249
|
+
margin-bottom: 1px;
|
250
|
+
transform: rotate(135deg);
|
251
|
+
margin-right: 3px;
|
252
|
+
visibility: ${(props) => (props.hasChildren ? 'visible' : 'hidden')};
|
253
|
+
`
|
259
254
|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
255
|
+
const childAttrs = { isOpen: Boolean }
|
256
|
+
const ChildrenContainer = styled('div', childAttrs)`
|
257
|
+
border: ${(props) =>
|
258
|
+
props.isOpen ? '1px solid' + props.theme.colors.grey3 : 'none'};
|
259
|
+
display: grid;
|
260
|
+
grid-template-columns: 1fr;
|
261
|
+
min-width: 200px;
|
262
|
+
max-width: 200px;
|
263
|
+
white-space: normal;
|
264
|
+
width: max-content;
|
265
|
+
border-radius: 4px;
|
266
|
+
background-color: #fff;
|
267
|
+
margin-right: -1px;
|
268
|
+
height: max-content;
|
269
|
+
max-height: 200px;
|
270
|
+
overflow: auto;
|
271
|
+
position: absolute;
|
272
|
+
top: 0;
|
273
|
+
right: 100%;
|
274
|
+
`
|
280
275
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
276
|
+
export default {
|
277
|
+
name: 'three-dots',
|
278
|
+
components: {
|
279
|
+
PageContainer,
|
280
|
+
ButtonContainer,
|
281
|
+
DotItem,
|
282
|
+
OptionsContainer,
|
283
|
+
OptionItem,
|
284
|
+
ChildrenContainer,
|
285
|
+
OptionChild,
|
286
|
+
ArrowLeft,
|
287
|
+
DropdownContainer,
|
288
|
+
Spinner,
|
289
|
+
LoadingContainer
|
290
|
+
},
|
291
|
+
props: {
|
292
|
+
options: {
|
293
|
+
required: true
|
295
294
|
},
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
},
|
300
|
-
isLoading: {
|
301
|
-
required: false,
|
302
|
-
default: false,
|
303
|
-
},
|
304
|
-
textWrap: {
|
305
|
-
required: false,
|
306
|
-
default: true,
|
307
|
-
},
|
295
|
+
isLoading: {
|
296
|
+
required: false,
|
297
|
+
default: false
|
308
298
|
},
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
299
|
+
textWrap: {
|
300
|
+
required: false,
|
301
|
+
default: true
|
302
|
+
}
|
303
|
+
},
|
304
|
+
data() {
|
305
|
+
return {
|
306
|
+
isOpen: false,
|
307
|
+
hoverItem: null,
|
308
|
+
childOpen: null,
|
309
|
+
containerWidth: 16
|
310
|
+
}
|
311
|
+
},
|
312
|
+
methods: {
|
313
|
+
toggleButton() {
|
314
|
+
this.isOpen = !this.isOpen
|
315
|
+
|
316
|
+
if (this.isOpen) {
|
317
|
+
this.setContextMenuPosition()
|
318
|
+
window.addEventListener('resize', this.toggleButton)
|
319
|
+
document.addEventListener('click', this.clickOutside)
|
320
|
+
} else {
|
321
|
+
window.removeEventListener('resize', this.toggleButton)
|
322
|
+
document.removeEventListener('click', this.clickOutside)
|
315
323
|
}
|
316
324
|
},
|
317
|
-
|
318
|
-
|
319
|
-
|
325
|
+
setContextMenuPosition() {
|
326
|
+
const contextMenu = this.$refs.dropdownContainer.$el
|
327
|
+
const button = this.$refs.pageContainer.$el
|
328
|
+
const rectButton = button.getBoundingClientRect()
|
329
|
+
const relativeParent = this.findRelativeParent(contextMenu)
|
330
|
+
const rectRelativeParent = relativeParent.getBoundingClientRect()
|
320
331
|
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
if (positionArray.includes('top')) {
|
348
|
-
contextMenu.style.top = rectButton.top - rectRelativeParent.top + 'px'
|
349
|
-
} else {
|
350
|
-
contextMenu.style.top =
|
351
|
-
rectButton.bottom - rectRelativeParent.top + 'px'
|
352
|
-
contextMenu.style.transform += ' translateY(-100%)'
|
353
|
-
}
|
354
|
-
},
|
355
|
-
findRelativeParent(element) {
|
356
|
-
while (element.parentElement) {
|
357
|
-
if (
|
358
|
-
window.getComputedStyle(element.parentElement).position ===
|
359
|
-
'relative' ||
|
360
|
-
window.getComputedStyle(element.parentElement).position ===
|
361
|
-
'absolute'
|
362
|
-
) {
|
363
|
-
return element.parentElement
|
364
|
-
}
|
365
|
-
element = element.parentElement
|
332
|
+
const positionArray = this.determineElementQuarter(button, rectButton)
|
333
|
+
contextMenu.style.transform = ''
|
334
|
+
if (positionArray.includes('left')) {
|
335
|
+
contextMenu.style.left =
|
336
|
+
rectButton.right - rectRelativeParent.left + 5 + 'px'
|
337
|
+
} else {
|
338
|
+
contextMenu.style.left =
|
339
|
+
rectButton.left - rectRelativeParent.left - 5 + 'px'
|
340
|
+
contextMenu.style.transform = 'translateX(-100%)'
|
341
|
+
}
|
342
|
+
if (positionArray.includes('top')) {
|
343
|
+
contextMenu.style.top = rectButton.top - rectRelativeParent.top + 'px'
|
344
|
+
} else {
|
345
|
+
contextMenu.style.top =
|
346
|
+
rectButton.bottom - rectRelativeParent.top + 'px'
|
347
|
+
contextMenu.style.transform += ' translateY(-100%)'
|
348
|
+
}
|
349
|
+
},
|
350
|
+
findRelativeParent(element) {
|
351
|
+
while (element.parentElement) {
|
352
|
+
if (
|
353
|
+
window.getComputedStyle(element.parentElement).position ===
|
354
|
+
'relative' ||
|
355
|
+
window.getComputedStyle(element.parentElement).position === 'absolute'
|
356
|
+
) {
|
357
|
+
return element.parentElement
|
366
358
|
}
|
367
|
-
|
368
|
-
}
|
369
|
-
|
370
|
-
|
371
|
-
|
359
|
+
element = element.parentElement
|
360
|
+
}
|
361
|
+
return null
|
362
|
+
},
|
363
|
+
determineElementQuarter(element, rect) {
|
364
|
+
const viewportWidth = window.innerWidth
|
365
|
+
const viewportHeight = window.innerHeight
|
372
366
|
|
373
|
-
|
374
|
-
|
367
|
+
const horizontalMidpoint = viewportWidth / 2
|
368
|
+
const verticalMidpoint = viewportHeight / 2
|
375
369
|
|
376
|
-
|
377
|
-
|
370
|
+
const isLeft = rect.left + rect.width / 2 < horizontalMidpoint
|
371
|
+
const isTop = rect.top + rect.height / 2 < verticalMidpoint
|
378
372
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
},
|
392
|
-
onItemHover({ index, item }) {
|
393
|
-
this.hoverItem = item.children && item.children.length ? index : null
|
394
|
-
this.childOpen =
|
395
|
-
item.children && item.children.length ? item.children : null
|
396
|
-
},
|
397
|
-
onSelect({ item, hasChildren }) {
|
398
|
-
if (hasChildren || item.disabled) {
|
399
|
-
this.$emit('on-click', item)
|
400
|
-
return
|
401
|
-
}
|
402
|
-
this.$emit('on-select', item)
|
403
|
-
this.isOpen = false
|
404
|
-
},
|
405
|
-
clickOutside(event) {
|
406
|
-
if (this.$el.contains(event.target) || !this.isOpen) {
|
407
|
-
return
|
408
|
-
}
|
409
|
-
this.toggleButton()
|
410
|
-
},
|
373
|
+
if (isLeft && isTop) {
|
374
|
+
return ['left', 'top']
|
375
|
+
} else if (isLeft && !isTop) {
|
376
|
+
return ['left', 'bottom']
|
377
|
+
} else if (!isLeft && isTop) {
|
378
|
+
return ['right', 'top']
|
379
|
+
} else {
|
380
|
+
return ['right', 'bottom']
|
381
|
+
}
|
382
|
+
},
|
383
|
+
hasChildren(item) {
|
384
|
+
return !!item.children && !!item.children.length
|
411
385
|
},
|
386
|
+
onItemHover({ index, item }) {
|
387
|
+
this.hoverItem = item.children && item.children.length ? index : null
|
388
|
+
this.childOpen =
|
389
|
+
item.children && item.children.length ? item.children : null
|
390
|
+
},
|
391
|
+
onSelect({ item, hasChildren }) {
|
392
|
+
if (hasChildren || item.disabled) {
|
393
|
+
this.$emit('on-click', item)
|
394
|
+
return
|
395
|
+
}
|
396
|
+
this.$emit('on-select', item)
|
397
|
+
this.isOpen = false
|
398
|
+
},
|
399
|
+
clickOutside(event) {
|
400
|
+
if (this.$el.contains(event.target) || !this.isOpen) {
|
401
|
+
return
|
402
|
+
}
|
403
|
+
this.toggleButton()
|
404
|
+
}
|
412
405
|
}
|
406
|
+
}
|
413
407
|
</script>
|