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