@eturnity/eturnity_reusable_components 7.12.7-EPDM-10335.0 → 7.12.7-EPDM-10528.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/.storybook/preview.js +1 -1
- package/package.json +23 -19
- package/src/App.vue +2 -2
- package/src/assets/svgIcons/house_3d-1.svg +8 -0
- package/src/assets/svgIcons/house_3d.svg +8 -0
- package/src/components/addNewButton/index.vue +3 -5
- package/src/components/buttons/buttonIcon/index.vue +1 -1
- package/src/components/buttons/closeButton/index.vue +1 -1
- package/src/components/buttons/mainButton/index.vue +8 -7
- package/src/components/deleteIcon/DeleteIcon.stories.js +7 -7
- package/src/components/deleteIcon/index.vue +21 -25
- package/src/components/draggableInputHandle/index.vue +25 -24
- package/src/components/dropdown/index.vue +110 -129
- package/src/components/errorMessage/index.vue +5 -10
- package/src/components/filter/filterSettings.vue +97 -58
- package/src/components/filter/index.vue +3 -3
- package/src/components/filter/parentDropdown.vue +2 -2
- package/src/components/icon/iconCollection.vue +2 -2
- package/src/components/icon/index.vue +70 -67
- package/src/components/iconWrapper/index.vue +4 -1
- package/src/components/infoCard/index.vue +3 -2
- package/src/components/infoText/index.vue +1 -1
- package/src/components/inputs/checkbox/index.vue +6 -21
- package/src/components/inputs/inputNumber/index.vue +11 -8
- package/src/components/inputs/inputNumberQuestion/index.vue +1 -1
- package/src/components/inputs/inputText/index.vue +3 -3
- package/src/components/inputs/radioButton/index.vue +1 -1
- package/src/components/inputs/searchInput/index.vue +11 -28
- package/src/components/inputs/select/index.vue +67 -195
- package/src/components/inputs/select/option/index.vue +11 -36
- package/src/components/inputs/slider/index.vue +16 -16
- package/src/components/inputs/switchField/index.vue +2 -2
- package/src/components/inputs/textAreaInput/index.vue +1 -1
- package/src/components/inputs/toggle/index.vue +2 -2
- package/src/components/label/index.vue +31 -27
- package/src/components/modals/modal/index.vue +6 -2
- package/src/components/navigationTabs/index.vue +20 -27
- package/src/components/pageSubtitle/index.vue +1 -1
- package/src/components/pageTitle/index.vue +4 -4
- package/src/components/pagination/index.vue +1 -1
- package/src/components/progressBar/index.vue +1 -1
- package/src/components/projectMarker/index.vue +9 -16
- package/src/components/sideMenu/index.vue +1 -1
- package/src/components/spinner/index.vue +11 -7
- package/src/components/tableDropdown/index.vue +37 -30
- package/src/components/tables/mainTable/exampleNested.vue +1 -1
- package/src/components/tables/mainTable/index.vue +9 -10
- package/src/components/tables/viewTable/index.vue +2 -2
- package/src/components/threeDots/index.vue +1 -1
- package/src/components/videoThumbnail/index.vue +100 -95
- package/src/main.js +11 -4
- package/src/components/icon/iconCache.js +0 -23
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
:fontSize="fontSize"
|
|
48
48
|
:fontColor="fontColor"
|
|
49
49
|
:backgroundColor="backgroundColor"
|
|
50
|
+
v-on="$listeners"
|
|
50
51
|
:hasSlot="hasSlot"
|
|
51
52
|
:hasLabelSlot="hasLabelSlot"
|
|
52
53
|
:slotSize="slotSize"
|
|
@@ -100,7 +101,7 @@
|
|
|
100
101
|
// >
|
|
101
102
|
//<template name=label><img>....</template>
|
|
102
103
|
//</inputNumber>
|
|
103
|
-
import styled from '
|
|
104
|
+
import styled from 'vue-styled-components'
|
|
104
105
|
import {
|
|
105
106
|
stringToNumber,
|
|
106
107
|
numberToString
|
|
@@ -468,7 +469,7 @@ export default {
|
|
|
468
469
|
}
|
|
469
470
|
},
|
|
470
471
|
methods: {
|
|
471
|
-
onEnterPress()
|
|
472
|
+
onEnterPress(){
|
|
472
473
|
this.$emit('on-enter-click')
|
|
473
474
|
this.$refs.inputField1.$el.blur()
|
|
474
475
|
},
|
|
@@ -487,10 +488,9 @@ export default {
|
|
|
487
488
|
// Need to return an integer rather than a string
|
|
488
489
|
this.$emit('input-change', event)
|
|
489
490
|
},
|
|
490
|
-
onEvaluateCode(
|
|
491
|
+
onEvaluateCode(val) {
|
|
491
492
|
// function to perform math on the code
|
|
492
493
|
// filter the string in case of any malicious content
|
|
493
|
-
const val = event.target.value
|
|
494
494
|
let filtered = val.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
|
|
495
495
|
filtered = filtered.split(/([-+*/()])/)
|
|
496
496
|
let formatted = filtered.map((item) => {
|
|
@@ -548,17 +548,20 @@ export default {
|
|
|
548
548
|
}
|
|
549
549
|
return array
|
|
550
550
|
},
|
|
551
|
-
onInput(
|
|
551
|
+
onInput(value) {
|
|
552
|
+
// if(!this.isFocused){
|
|
553
|
+
// return
|
|
554
|
+
// }
|
|
552
555
|
if (this.isBlurred) {
|
|
553
556
|
this.isBlurred = false
|
|
554
557
|
return
|
|
555
558
|
}
|
|
556
|
-
if (
|
|
559
|
+
if (value === '') {
|
|
557
560
|
this.$emit('on-input', '')
|
|
558
561
|
}
|
|
559
562
|
let evaluatedVal
|
|
560
563
|
try {
|
|
561
|
-
evaluatedVal = this.onEvaluateCode(
|
|
564
|
+
evaluatedVal = this.onEvaluateCode(value)
|
|
562
565
|
} finally {
|
|
563
566
|
if (evaluatedVal) {
|
|
564
567
|
this.$emit('on-input', evaluatedVal)
|
|
@@ -570,7 +573,7 @@ export default {
|
|
|
570
573
|
// setting isBlurred so we don't trigger onInput as well
|
|
571
574
|
this.isBlurred = true
|
|
572
575
|
let value = e.target.value
|
|
573
|
-
let evaluatedInput = this.onEvaluateCode(
|
|
576
|
+
let evaluatedInput = this.onEvaluateCode(value)
|
|
574
577
|
this.onChangeHandler(evaluatedInput ? evaluatedInput : value)
|
|
575
578
|
if ((evaluatedInput && value.length) || this.minNumber !== null) {
|
|
576
579
|
this.textInput = numberToString({
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
</template>
|
|
67
67
|
|
|
68
68
|
<script>
|
|
69
|
-
import styled from '
|
|
69
|
+
import styled from 'vue-styled-components'
|
|
70
70
|
import InfoText from '../../infoText'
|
|
71
71
|
import Icon from '../../icon'
|
|
72
72
|
import ErrorMessage from '../../errorMessage'
|
|
@@ -332,8 +332,8 @@ export default {
|
|
|
332
332
|
this.$emit('on-enter-click')
|
|
333
333
|
this.$refs.inputElement.$el.blur()
|
|
334
334
|
},
|
|
335
|
-
onChangeHandler(event) {
|
|
336
|
-
this.$emit('input-change', event
|
|
335
|
+
onChangeHandler($event) {
|
|
336
|
+
this.$emit('input-change', $event)
|
|
337
337
|
},
|
|
338
338
|
onInputBlur($event) {
|
|
339
339
|
this.$emit('input-blur', $event.target.value)
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<container :inputWidth="inputWidth">
|
|
3
|
-
<input-wrapper
|
|
4
|
-
<SearchIconSvg class="search-icn" />
|
|
3
|
+
<input-wrapper>
|
|
5
4
|
<input-container
|
|
6
5
|
ref="inputElement"
|
|
7
6
|
:placeholder="placeholder"
|
|
@@ -14,6 +13,10 @@
|
|
|
14
13
|
:hasFocus="hasFocus"
|
|
15
14
|
:data-id="dataId"
|
|
16
15
|
/>
|
|
16
|
+
<img
|
|
17
|
+
class="search-icn"
|
|
18
|
+
:src="require('../../../assets/icons/search_icon_black.svg')"
|
|
19
|
+
/>
|
|
17
20
|
</input-wrapper>
|
|
18
21
|
</container>
|
|
19
22
|
</template>
|
|
@@ -29,11 +32,8 @@
|
|
|
29
32
|
// @on-change="function($event)"
|
|
30
33
|
// :isFilter="true" // to set the height at 30px
|
|
31
34
|
// data-id="test-data-id"
|
|
32
|
-
// iconPosition="left"
|
|
33
|
-
// iconColor="grey2"
|
|
34
35
|
// />
|
|
35
|
-
import styled from '
|
|
36
|
-
import SearchIconSvg from '../../../assets/icons/search_icon_black.svg'
|
|
36
|
+
import styled from 'vue-styled-components'
|
|
37
37
|
|
|
38
38
|
const inputAttrs = {
|
|
39
39
|
isDisabled: Boolean,
|
|
@@ -68,18 +68,11 @@ const InputContainer = styled('input', inputAttrs)`
|
|
|
68
68
|
const InputWrapper = styled.span`
|
|
69
69
|
position: relative;
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
img {
|
|
72
72
|
position: absolute;
|
|
73
|
-
|
|
73
|
+
right: 10px;
|
|
74
74
|
top: 50%;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
path {
|
|
78
|
-
fill: ${(props) =>
|
|
79
|
-
props.theme.colors[props.iconColor]
|
|
80
|
-
? props.theme.colors[props.iconColor]
|
|
81
|
-
: props.iconColor};
|
|
82
|
-
}
|
|
75
|
+
transform: translateY(-50%);
|
|
83
76
|
}
|
|
84
77
|
`
|
|
85
78
|
|
|
@@ -88,8 +81,7 @@ export default {
|
|
|
88
81
|
components: {
|
|
89
82
|
InputContainer,
|
|
90
83
|
InputWrapper,
|
|
91
|
-
Container
|
|
92
|
-
SearchIconSvg
|
|
84
|
+
Container
|
|
93
85
|
},
|
|
94
86
|
props: {
|
|
95
87
|
value: {
|
|
@@ -118,20 +110,11 @@ export default {
|
|
|
118
110
|
dataId: {
|
|
119
111
|
required: false,
|
|
120
112
|
default: ''
|
|
121
|
-
},
|
|
122
|
-
iconPosition: {
|
|
123
|
-
type: String,
|
|
124
|
-
default: 'right'
|
|
125
|
-
},
|
|
126
|
-
iconColor: {
|
|
127
|
-
type: String,
|
|
128
|
-
default: 'black'
|
|
129
113
|
}
|
|
130
114
|
},
|
|
131
|
-
emits: ['on-change'],
|
|
132
115
|
methods: {
|
|
133
116
|
onChangeHandler(event) {
|
|
134
|
-
this.$emit('on-change', event
|
|
117
|
+
this.$emit('on-change', event)
|
|
135
118
|
},
|
|
136
119
|
focusInputElement() {
|
|
137
120
|
this.$nextTick(() => {
|
|
@@ -28,9 +28,7 @@
|
|
|
28
28
|
<select-button-wrapper :disabled="disabled">
|
|
29
29
|
<selectButton
|
|
30
30
|
ref="select"
|
|
31
|
-
class="select-button"
|
|
32
31
|
@click="toggleDropdown"
|
|
33
|
-
:selectWidth="selectWidth"
|
|
34
32
|
:selectHeight="selectHeight"
|
|
35
33
|
:height="height"
|
|
36
34
|
:selectMinHeight="selectMinHeight"
|
|
@@ -41,9 +39,9 @@
|
|
|
41
39
|
buttonFontColor || colorMode == 'dark' ? 'white' : 'black'
|
|
42
40
|
"
|
|
43
41
|
:hasError="hasError"
|
|
44
|
-
:
|
|
42
|
+
:isSearchBarVisible="isSearchBarVisible"
|
|
45
43
|
:disabled="disabled"
|
|
46
|
-
@keydown="onKeyDown"
|
|
44
|
+
@keydown.native="onKeyDown"
|
|
47
45
|
:showBorder="showBorder"
|
|
48
46
|
:data-id="dataId"
|
|
49
47
|
:paddingLeft="paddingLeft"
|
|
@@ -66,7 +64,7 @@
|
|
|
66
64
|
:value="textSearch"
|
|
67
65
|
@keydown.stop="onKeyDown"
|
|
68
66
|
@input-change="searchChange"
|
|
69
|
-
@click.stop
|
|
67
|
+
@click.native.stop
|
|
70
68
|
/>
|
|
71
69
|
<selector
|
|
72
70
|
v-else
|
|
@@ -99,33 +97,28 @@
|
|
|
99
97
|
/>
|
|
100
98
|
</Caret>
|
|
101
99
|
</selectButton>
|
|
102
|
-
<DropdownWrapper
|
|
103
|
-
<
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
@option-hovered="optionHovered"
|
|
125
|
-
>
|
|
126
|
-
<slot name="dropdown"></slot>
|
|
127
|
-
</selectDropdown>
|
|
128
|
-
</Teleport>
|
|
100
|
+
<DropdownWrapper>
|
|
101
|
+
<selectDropdown
|
|
102
|
+
ref="dropdown"
|
|
103
|
+
v-show="isDropdownOpen"
|
|
104
|
+
:position="dropdownPosition"
|
|
105
|
+
:offset="dropdownOffset"
|
|
106
|
+
:hoveredIndex="hoveredIndex"
|
|
107
|
+
:hoveredValue="hoveredValue"
|
|
108
|
+
:isActive="isActive"
|
|
109
|
+
:optionWidth="optionWidth"
|
|
110
|
+
:hoveredBgColor="colorMode == 'dark' ? '#000000' : dropdownBgColor"
|
|
111
|
+
:bgColor="colorMode == 'dark' ? 'black' : dropdownBgColor"
|
|
112
|
+
:fontColor="
|
|
113
|
+
dropdownFontColor || colorMode == 'dark' ? 'white' : 'black'
|
|
114
|
+
"
|
|
115
|
+
:selectedValue="selectedValue"
|
|
116
|
+
@option-selected="optionSelected"
|
|
117
|
+
@option-hovered="optionHovered"
|
|
118
|
+
@mouseleave="optionLeave"
|
|
119
|
+
>
|
|
120
|
+
<slot name="dropdown"></slot>
|
|
121
|
+
</selectDropdown>
|
|
129
122
|
</DropdownWrapper>
|
|
130
123
|
</select-button-wrapper>
|
|
131
124
|
</input-wrapper>
|
|
@@ -140,9 +133,8 @@
|
|
|
140
133
|
// optionWidth="50%"
|
|
141
134
|
// label="that is a label"
|
|
142
135
|
// alignItems="vertical"
|
|
143
|
-
// label-data-id="test-
|
|
136
|
+
// label-data-id="test-label0data-id"
|
|
144
137
|
// data-id="test-data-id"
|
|
145
|
-
// :hasSelectButtonPadding="false"
|
|
146
138
|
// >
|
|
147
139
|
// <template #selector="{selectedValue}">
|
|
148
140
|
// value selected: {{selectedValue}}
|
|
@@ -155,8 +147,7 @@
|
|
|
155
147
|
// </template>
|
|
156
148
|
// </Select>
|
|
157
149
|
|
|
158
|
-
import
|
|
159
|
-
import styled from 'vue3-styled-components'
|
|
150
|
+
import styled from 'vue-styled-components'
|
|
160
151
|
import InfoText from '../../infoText'
|
|
161
152
|
import icon from '../../icon'
|
|
162
153
|
import inputText from '../inputText'
|
|
@@ -172,7 +163,7 @@ const Caret = styled.div`
|
|
|
172
163
|
width: ${CARET_WIDTH};
|
|
173
164
|
min-width: ${CARET_WIDTH};
|
|
174
165
|
height: 100%;
|
|
175
|
-
align-items:
|
|
166
|
+
align-items: stretch;
|
|
176
167
|
cursor: pointer;
|
|
177
168
|
margin-left: auto;
|
|
178
169
|
`
|
|
@@ -210,10 +201,7 @@ const InputLabel = styled('div', labelAttrs)`
|
|
|
210
201
|
const optionalLabel = styled.span`
|
|
211
202
|
font-weight: 300;
|
|
212
203
|
`
|
|
213
|
-
const inputProps = {
|
|
214
|
-
selectWidth: String,
|
|
215
|
-
optionWidth: String
|
|
216
|
-
}
|
|
204
|
+
const inputProps = { selectWidth: String, optionWidth: String }
|
|
217
205
|
const Container = styled('div', inputProps)`
|
|
218
206
|
width: ${(props) => props.selectWidth};
|
|
219
207
|
position: relative;
|
|
@@ -240,10 +228,9 @@ const selectButtonAttrs = {
|
|
|
240
228
|
hasError: Boolean,
|
|
241
229
|
disabled: Boolean,
|
|
242
230
|
selectHeight: String,
|
|
243
|
-
selectWidth: String,
|
|
244
231
|
height: String,
|
|
245
232
|
selectMinHeight: String,
|
|
246
|
-
|
|
233
|
+
isSearchBarVisible: Boolean,
|
|
247
234
|
showBorder: Boolean,
|
|
248
235
|
paddingLeft: String
|
|
249
236
|
}
|
|
@@ -251,9 +238,8 @@ const selectButton = styled('div', selectButtonAttrs)`
|
|
|
251
238
|
position: relative;
|
|
252
239
|
box-sizing: border-box;
|
|
253
240
|
border-radius: 4px;
|
|
254
|
-
max-width: ${(props) => (props.selectWidth ? props.selectWidth : '100%')};
|
|
255
241
|
${(props) =>
|
|
256
|
-
props.
|
|
242
|
+
props.isSearchBarVisible ? '' : `padding-left: ${props.paddingLeft}`};
|
|
257
243
|
text-align: left;
|
|
258
244
|
min-height: ${(props) =>
|
|
259
245
|
props.selectHeight
|
|
@@ -265,7 +251,7 @@ const selectButton = styled('div', selectButtonAttrs)`
|
|
|
265
251
|
: '36px'};
|
|
266
252
|
display: flex;
|
|
267
253
|
align-items: center;
|
|
268
|
-
height: ${(props) => props.selectHeight};
|
|
254
|
+
max-height: ${(props) => props.selectHeight};
|
|
269
255
|
${({ showBorder, theme, hasError }) =>
|
|
270
256
|
showBorder &&
|
|
271
257
|
`
|
|
@@ -297,17 +283,18 @@ const selectDropdownAttrs = {
|
|
|
297
283
|
fontColor: String,
|
|
298
284
|
optionWidth: String,
|
|
299
285
|
hoveredIndex: Number,
|
|
300
|
-
fontSize: String,
|
|
301
|
-
dropdownPosition: Object,
|
|
302
286
|
hoveredValue: Number | String,
|
|
303
|
-
selectedValue: Number | String
|
|
287
|
+
selectedValue: Number | String,
|
|
288
|
+
position: String,
|
|
289
|
+
offset: String
|
|
304
290
|
}
|
|
305
291
|
const selectDropdown = styled('div', selectDropdownAttrs)`
|
|
306
292
|
box-sizing: border-box;
|
|
307
|
-
z-index: ${(props) => (props.isActive ? '2' : '
|
|
293
|
+
z-index: ${(props) => (props.isActive ? '2' : '1')};
|
|
308
294
|
position: absolute;
|
|
309
|
-
top: ${(props) => props.
|
|
310
|
-
|
|
295
|
+
top: ${(props) => (props.position === 'bottom' ? props.offset : 'auto')};
|
|
296
|
+
bottom: ${(props) =>
|
|
297
|
+
props.position === 'top' ? `calc(100% + ${props.offset})` : 'auto'};
|
|
311
298
|
border: ${BORDER_WIDTH} solid ${(props) => props.theme.colors.grey4};
|
|
312
299
|
border-radius: 4px;
|
|
313
300
|
display: flex;
|
|
@@ -332,9 +319,7 @@ const selectDropdown = styled('div', selectDropdownAttrs)`
|
|
|
332
319
|
? props.theme.colors[props.hoveredBgColor]
|
|
333
320
|
: props.hoveredBgColor};
|
|
334
321
|
}
|
|
335
|
-
font-size: ${(props) => props.fontSize};
|
|
336
322
|
`
|
|
337
|
-
selectDropdown.emits = ['option-hovered', 'option-selected']
|
|
338
323
|
const DropdownWrapper = styled('div')`
|
|
339
324
|
position: relative;
|
|
340
325
|
`
|
|
@@ -347,10 +332,6 @@ const InputWrapper = styled('div', inputAttrs)`
|
|
|
347
332
|
grid-template-columns: ${(props) =>
|
|
348
333
|
props.alignItems === 'vertical' || !props.hasLabel ? '1fr' : 'auto 1fr'};
|
|
349
334
|
`
|
|
350
|
-
|
|
351
|
-
const DROPDOWN_HEIGHT_OFFSET = 4
|
|
352
|
-
const DROPDOWN_TOP_OFFSET = 21
|
|
353
|
-
|
|
354
335
|
export default {
|
|
355
336
|
name: 'RCselect',
|
|
356
337
|
|
|
@@ -417,6 +398,14 @@ export default {
|
|
|
417
398
|
buttonFontColor: {
|
|
418
399
|
required: false
|
|
419
400
|
},
|
|
401
|
+
dropdownPosition: {
|
|
402
|
+
required: false,
|
|
403
|
+
default: 'bottom'
|
|
404
|
+
},
|
|
405
|
+
dropdownOffset: {
|
|
406
|
+
required: false,
|
|
407
|
+
default: '5px'
|
|
408
|
+
},
|
|
420
409
|
dropdownBgColor: {
|
|
421
410
|
required: false,
|
|
422
411
|
default: 'grey5'
|
|
@@ -462,10 +451,6 @@ export default {
|
|
|
462
451
|
type: String,
|
|
463
452
|
default: ''
|
|
464
453
|
},
|
|
465
|
-
hasSelectButtonPadding: {
|
|
466
|
-
type: Boolean,
|
|
467
|
-
default: true
|
|
468
|
-
},
|
|
469
454
|
isDraggable: {
|
|
470
455
|
type: Boolean,
|
|
471
456
|
default: false
|
|
@@ -487,7 +472,6 @@ export default {
|
|
|
487
472
|
Caret,
|
|
488
473
|
Selector,
|
|
489
474
|
inputText,
|
|
490
|
-
Teleport,
|
|
491
475
|
draggableInputHandle
|
|
492
476
|
},
|
|
493
477
|
|
|
@@ -499,38 +483,23 @@ export default {
|
|
|
499
483
|
isActive: false,
|
|
500
484
|
textSearch: '',
|
|
501
485
|
hoveredIndex: 0,
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
left: null,
|
|
505
|
-
top: null
|
|
506
|
-
},
|
|
507
|
-
dropdownWidth: null,
|
|
508
|
-
hoveredValue: null
|
|
486
|
+
hoveredValue: null,
|
|
487
|
+
isClickOutsideActive: false
|
|
509
488
|
}
|
|
510
489
|
},
|
|
511
490
|
mounted() {
|
|
512
|
-
this.observeDropdownHeight()
|
|
513
|
-
this.observeSelectWidth()
|
|
514
|
-
window.addEventListener('resize', this.handleSetDropdownOffet)
|
|
515
|
-
},
|
|
516
|
-
beforeMount() {
|
|
517
491
|
this.selectedValue = this.value
|
|
518
492
|
document.addEventListener('click', this.clickOutside)
|
|
519
|
-
this.getDropdownPosition()
|
|
520
|
-
window.removeEventListener('resize', this.handleSetDropdownOffet)
|
|
521
|
-
if (this.dropdownResizeObserver) this.dropdownResizeObserver.disconnect()
|
|
522
|
-
if (this.selectResizeObserver) this.selectResizeObserver.disconnect()
|
|
523
493
|
},
|
|
524
|
-
|
|
494
|
+
beforeDestroy() {
|
|
525
495
|
document.removeEventListener('click', this.clickOutside)
|
|
526
496
|
},
|
|
527
497
|
methods: {
|
|
528
498
|
focus() {
|
|
529
499
|
this.isActive = true
|
|
530
500
|
},
|
|
531
|
-
blur(
|
|
501
|
+
blur() {
|
|
532
502
|
this.isActive = false
|
|
533
|
-
this.$emit('blur', e)
|
|
534
503
|
},
|
|
535
504
|
toggleDropdown() {
|
|
536
505
|
this.isDropdownOpen = !this.isDropdownOpen
|
|
@@ -546,9 +515,6 @@ export default {
|
|
|
546
515
|
this.blur()
|
|
547
516
|
this.isDropdownOpen = false
|
|
548
517
|
},
|
|
549
|
-
clearSearch() {
|
|
550
|
-
this.textSearch = ''
|
|
551
|
-
},
|
|
552
518
|
optionSelected(e) {
|
|
553
519
|
this.selectedValue = e
|
|
554
520
|
this.closeDropdown()
|
|
@@ -577,15 +543,15 @@ export default {
|
|
|
577
543
|
searchChange(value) {
|
|
578
544
|
this.textSearch = value
|
|
579
545
|
this.$emit('search-change', value)
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
el.
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
546
|
+
this.$refs.dropdown.$children
|
|
547
|
+
.map((component) => component.$el)
|
|
548
|
+
.forEach((el) => {
|
|
549
|
+
if (!el.textContent.toLowerCase().includes(value.toLowerCase())) {
|
|
550
|
+
el.style.display = 'none'
|
|
551
|
+
} else {
|
|
552
|
+
el.style.display = 'inherit'
|
|
553
|
+
}
|
|
554
|
+
})
|
|
589
555
|
},
|
|
590
556
|
clickOutside(event) {
|
|
591
557
|
const dropdownRef = this.$refs.dropdown
|
|
@@ -595,7 +561,6 @@ export default {
|
|
|
595
561
|
if (
|
|
596
562
|
this.$refs.select.$el == event.target ||
|
|
597
563
|
this.$refs.select.$el.contains(event.target) ||
|
|
598
|
-
event.target.id === 'more-button' ||
|
|
599
564
|
event.target.parentNode === dropdownRef.$el
|
|
600
565
|
) {
|
|
601
566
|
return
|
|
@@ -609,92 +574,13 @@ export default {
|
|
|
609
574
|
} else if (e.key == 'ArrowUp') {
|
|
610
575
|
this.onArrowPress(-1)
|
|
611
576
|
} else if (e.key == 'Enter') {
|
|
612
|
-
const optionHoveredComponent =
|
|
613
|
-
|
|
614
|
-
|
|
577
|
+
const optionHoveredComponent =
|
|
578
|
+
this.$refs.dropdown.$children[
|
|
579
|
+
(this.hoveredIndex - 1 + this.optionLength) % this.optionLength
|
|
580
|
+
]
|
|
615
581
|
this.optionSelected(optionHoveredComponent.$el.dataset.value)
|
|
616
582
|
}
|
|
617
583
|
},
|
|
618
|
-
// If some part of the dropdown menu is outside viewport of the bottom of the screen,
|
|
619
|
-
// we need to offset it and display it at the top of the select dropdown instead
|
|
620
|
-
async getDropdownPosition() {
|
|
621
|
-
if (
|
|
622
|
-
!this.$refs.dropdownWrapperRef ||
|
|
623
|
-
!this.$refs.select ||
|
|
624
|
-
!this.$refs.dropdown
|
|
625
|
-
) {
|
|
626
|
-
return
|
|
627
|
-
}
|
|
628
|
-
await this.$nextTick()
|
|
629
|
-
const isDisplayedAtBottom = await this.generateDropdownPosition()
|
|
630
|
-
await this.$nextTick()
|
|
631
|
-
// If the dropdown menu is going to be displayed at the bottom,
|
|
632
|
-
// we need reverify its position after a dom update (nextTick)
|
|
633
|
-
if (isDisplayedAtBottom) this.generateDropdownPosition()
|
|
634
|
-
},
|
|
635
|
-
async generateDropdownPosition() {
|
|
636
|
-
const isDropdownNotCompletelyVisible =
|
|
637
|
-
await this.isBottomOfDropdownOutOfViewport()
|
|
638
|
-
const dropdownWrapperEl = this.$refs.dropdownWrapperRef.$el
|
|
639
|
-
const selectButtonHeight = this.$refs.select.$el.clientHeight
|
|
640
|
-
const dropdownHeight = this.$refs.dropdown.$el.clientHeight
|
|
641
|
-
const dropdownWrapperRelativeHeight =
|
|
642
|
-
dropdownWrapperEl.getBoundingClientRect().top +
|
|
643
|
-
window.scrollY +
|
|
644
|
-
DROPDOWN_HEIGHT_OFFSET
|
|
645
|
-
|
|
646
|
-
const top = isDropdownNotCompletelyVisible
|
|
647
|
-
? dropdownWrapperRelativeHeight
|
|
648
|
-
: dropdownWrapperRelativeHeight -
|
|
649
|
-
dropdownHeight -
|
|
650
|
-
selectButtonHeight -
|
|
651
|
-
DROPDOWN_TOP_OFFSET
|
|
652
|
-
const left = this.dropdownPosition.left
|
|
653
|
-
? this.dropdownPosition.left
|
|
654
|
-
: dropdownWrapperEl.getBoundingClientRect().left + window.scrollX
|
|
655
|
-
|
|
656
|
-
this.dropdownPosition = { left: Math.floor(left), top: Math.floor(top) }
|
|
657
|
-
|
|
658
|
-
return isDropdownNotCompletelyVisible
|
|
659
|
-
},
|
|
660
|
-
async isBottomOfDropdownOutOfViewport() {
|
|
661
|
-
if (!this.$refs.dropdown) {
|
|
662
|
-
return false
|
|
663
|
-
}
|
|
664
|
-
await this.$nextTick()
|
|
665
|
-
const rect = this.$refs.dropdown.$el.getBoundingClientRect()
|
|
666
|
-
const windowHeight =
|
|
667
|
-
window.innerHeight || document.documentElement.clientHeight
|
|
668
|
-
|
|
669
|
-
// using Math.floor because the offsets may contain decimals we are not going to consider here
|
|
670
|
-
return Math.floor(rect.top) + Math.floor(rect.height) <= windowHeight
|
|
671
|
-
},
|
|
672
|
-
observeDropdownHeight() {
|
|
673
|
-
if (!this.$refs.dropdown) return
|
|
674
|
-
this.dropdownResizeObserver = new ResizeObserver(() => {
|
|
675
|
-
this.$nextTick(() => this.getDropdownPosition())
|
|
676
|
-
})
|
|
677
|
-
this.dropdownResizeObserver.observe(this.$refs.dropdown.$el)
|
|
678
|
-
},
|
|
679
|
-
handleSetDropdownOffet() {
|
|
680
|
-
if (!this.$refs.select) return
|
|
681
|
-
this.dropdownPosition.left = Math.floor(
|
|
682
|
-
this.$refs.select.$el.getBoundingClientRect().left
|
|
683
|
-
)
|
|
684
|
-
this.getDropdownWidth()
|
|
685
|
-
},
|
|
686
|
-
observeSelectWidth() {
|
|
687
|
-
if (!this.$refs.select) return
|
|
688
|
-
this.selectResizeObserver = new ResizeObserver(() =>
|
|
689
|
-
this.$nextTick(() => this.getDropdownWidth())
|
|
690
|
-
)
|
|
691
|
-
this.selectResizeObserver.observe(this.$refs.dropdown.$el)
|
|
692
|
-
},
|
|
693
|
-
async getDropdownWidth() {
|
|
694
|
-
if (!this.$refs.select) return
|
|
695
|
-
await this.$nextTick()
|
|
696
|
-
this.dropdownWidth = `${this.$refs.select.$el.clientWidth}px`
|
|
697
|
-
},
|
|
698
584
|
onArrowPress(dir) {
|
|
699
585
|
let newHoveredElem
|
|
700
586
|
const currentHoveredElem = this.$refs.dropdown.$el.querySelector(
|
|
@@ -726,34 +612,20 @@ export default {
|
|
|
726
612
|
return 0
|
|
727
613
|
},
|
|
728
614
|
isSearchBarVisible() {
|
|
729
|
-
return this.isSearchable && this.
|
|
730
|
-
},
|
|
731
|
-
getOptionWidth() {
|
|
732
|
-
if (this.optionWidth) return this.optionWidth
|
|
733
|
-
|
|
734
|
-
return this.dropdownWidth
|
|
735
|
-
},
|
|
736
|
-
isSelectDropdownShown() {
|
|
737
|
-
return (
|
|
738
|
-
this.isDropdownOpen &&
|
|
739
|
-
this.dropdownPosition.left !== null &&
|
|
740
|
-
(!this.isSearchable || this.isSearchable)
|
|
741
|
-
)
|
|
615
|
+
return this.isSearchable && this.isDropdownOpen
|
|
742
616
|
}
|
|
743
617
|
},
|
|
744
618
|
watch: {
|
|
745
619
|
value(val) {
|
|
746
620
|
this.selectedValue = val
|
|
747
621
|
},
|
|
748
|
-
|
|
622
|
+
isDropdownOpen(val) {
|
|
623
|
+
this.$emit('is-dropdown-open', val)
|
|
749
624
|
if (val) {
|
|
750
625
|
setTimeout(() => {
|
|
751
626
|
this.isClickOutsideActive = true
|
|
752
627
|
}, 10)
|
|
753
|
-
await this.$nextTick()
|
|
754
|
-
this.handleSetDropdownOffet()
|
|
755
628
|
} else {
|
|
756
|
-
this.dropdownPosition.left = null
|
|
757
629
|
setTimeout(() => {
|
|
758
630
|
this.isClickOutsideActive = false
|
|
759
631
|
}, 10)
|