@eturnity/eturnity_reusable_components 7.18.0--EPDM-5518.4 → 7.18.0-EPDM-10335.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 +19 -23
- package/src/App.vue +2 -2
- package/src/components/addNewButton/index.vue +5 -3
- 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 +6 -1
- package/src/components/deleteIcon/DeleteIcon.stories.js +7 -7
- package/src/components/deleteIcon/index.vue +25 -21
- package/src/components/draggableInputHandle/index.vue +24 -25
- package/src/components/dropdown/index.vue +129 -110
- package/src/components/errorMessage/index.vue +10 -5
- package/src/components/filter/filterSettings.vue +57 -113
- package/src/components/filter/index.vue +3 -3
- package/src/components/filter/parentDropdown.vue +2 -2
- package/src/components/icon/iconCache.js +23 -0
- package/src/components/icon/iconCollection.vue +2 -2
- package/src/components/icon/index.vue +67 -75
- package/src/components/iconWrapper/index.vue +1 -4
- package/src/components/infoCard/index.vue +2 -3
- package/src/components/infoText/index.vue +1 -1
- package/src/components/inputs/checkbox/index.vue +24 -16
- package/src/components/inputs/inputNumber/index.vue +7 -10
- package/src/components/inputs/inputNumberQuestion/index.vue +1 -1
- package/src/components/inputs/inputText/index.vue +4 -4
- package/src/components/inputs/radioButton/index.vue +1 -1
- package/src/components/inputs/searchInput/index.vue +28 -11
- package/src/components/inputs/select/index.vue +212 -91
- package/src/components/inputs/select/option/index.vue +36 -11
- 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 +2 -2
- package/src/components/inputs/toggle/index.vue +2 -2
- package/src/components/label/index.vue +27 -31
- package/src/components/modals/modal/index.vue +2 -6
- package/src/components/navigationTabs/index.vue +27 -20
- package/src/components/pageSubtitle/index.vue +1 -1
- package/src/components/pageTitle/index.vue +4 -4
- package/src/components/pagination/index.vue +6 -7
- package/src/components/progressBar/index.vue +1 -1
- package/src/components/projectMarker/index.vue +17 -10
- package/src/components/sideMenu/index.vue +1 -1
- package/src/components/spinner/index.vue +7 -11
- package/src/components/tableDropdown/index.vue +30 -37
- package/src/components/tables/mainTable/exampleNested.vue +1 -1
- package/src/components/tables/mainTable/index.vue +10 -9
- package/src/components/tables/viewTable/index.vue +2 -2
- package/src/components/threeDots/index.vue +1 -1
- package/src/components/videoThumbnail/index.vue +95 -100
- package/src/main.js +4 -11
- package/src/assets/svgIcons/clock_full.svg +0 -3
- package/src/components/markerItem/index.vue +0 -96
- package/src/components/selectedOptions/index.vue +0 -145
@@ -8,11 +8,7 @@
|
|
8
8
|
:hasLabel="!!label && label.length > 0"
|
9
9
|
:alignItems="alignItems"
|
10
10
|
>
|
11
|
-
<label-wrapper
|
12
|
-
v-if="label"
|
13
|
-
:data-id="labelDataId"
|
14
|
-
:shownDropdown="shownDropdown"
|
15
|
-
>
|
11
|
+
<label-wrapper v-if="label" :data-id="labelDataId">
|
16
12
|
<input-label
|
17
13
|
:fontColor="
|
18
14
|
labelFontColor || colorMode == 'dark' ? 'white' : 'eturnityGrey'
|
@@ -32,7 +28,9 @@
|
|
32
28
|
<select-button-wrapper :disabled="disabled">
|
33
29
|
<selectButton
|
34
30
|
ref="select"
|
31
|
+
class="select-button"
|
35
32
|
@click="toggleDropdown"
|
33
|
+
:selectWidth="selectWidth"
|
36
34
|
:selectHeight="selectHeight"
|
37
35
|
:height="height"
|
38
36
|
:selectMinHeight="selectMinHeight"
|
@@ -43,13 +41,12 @@
|
|
43
41
|
buttonFontColor || colorMode == 'dark' ? 'white' : 'black'
|
44
42
|
"
|
45
43
|
:hasError="hasError"
|
46
|
-
:
|
44
|
+
:hasNoPadding="isSearchBarVisible || !hasSelectButtonPadding"
|
47
45
|
:disabled="disabled"
|
48
|
-
@keydown
|
46
|
+
@keydown="onKeyDown"
|
49
47
|
:showBorder="showBorder"
|
50
48
|
:data-id="dataId"
|
51
49
|
:paddingLeft="paddingLeft"
|
52
|
-
:shownDropdown="shownDropdown"
|
53
50
|
>
|
54
51
|
<draggableInputHandle
|
55
52
|
v-if="isDraggable && !isSearchBarVisible"
|
@@ -69,14 +66,13 @@
|
|
69
66
|
:value="textSearch"
|
70
67
|
@keydown.stop="onKeyDown"
|
71
68
|
@input-change="searchChange"
|
72
|
-
@click.
|
69
|
+
@click.stop
|
73
70
|
/>
|
74
71
|
<selector
|
75
72
|
v-else
|
73
|
+
:showBorder="showBorder"
|
76
74
|
:selectWidth="selectWidth"
|
77
75
|
:paddingLeft="paddingLeft"
|
78
|
-
:noMaxWidth="noMaxWidth"
|
79
|
-
:showBorder="showBorder"
|
80
76
|
>
|
81
77
|
<slot name="selector" :selectedValue="selectedValue"></slot>
|
82
78
|
</selector>
|
@@ -103,26 +99,33 @@
|
|
103
99
|
/>
|
104
100
|
</Caret>
|
105
101
|
</selectButton>
|
106
|
-
<DropdownWrapper>
|
107
|
-
<
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
102
|
+
<DropdownWrapper ref="dropdownWrapperRef">
|
103
|
+
<Teleport to="#portal-target">
|
104
|
+
<selectDropdown
|
105
|
+
ref="dropdown"
|
106
|
+
v-show="isSelectDropdownShown"
|
107
|
+
:dropdownPosition="dropdownPosition"
|
108
|
+
:hoveredIndex="hoveredIndex"
|
109
|
+
:hoveredValue="hoveredValue"
|
110
|
+
:isActive="isActive"
|
111
|
+
:optionWidth="getOptionWidth"
|
112
|
+
:hoveredBgColor="
|
113
|
+
colorMode == 'dark' ? '#000000' : dropdownBgColor
|
114
|
+
"
|
115
|
+
:bgColor="
|
116
|
+
dropdownBgColor || colorMode == 'dark' ? 'black' : 'white'
|
117
|
+
"
|
118
|
+
:fontColor="
|
119
|
+
dropdownFontColor || colorMode == 'dark' ? 'white' : 'black'
|
120
|
+
"
|
121
|
+
:fontSize="fontSize"
|
122
|
+
:selectedValue="selectedValue"
|
123
|
+
@option-selected="optionSelected"
|
124
|
+
@option-hovered="optionHovered"
|
125
|
+
>
|
126
|
+
<slot name="dropdown"></slot>
|
127
|
+
</selectDropdown>
|
128
|
+
</Teleport>
|
126
129
|
</DropdownWrapper>
|
127
130
|
</select-button-wrapper>
|
128
131
|
</input-wrapper>
|
@@ -137,8 +140,9 @@
|
|
137
140
|
// optionWidth="50%"
|
138
141
|
// label="that is a label"
|
139
142
|
// alignItems="vertical"
|
140
|
-
// label-data-id="test-
|
143
|
+
// label-data-id="test-label-data-id"
|
141
144
|
// data-id="test-data-id"
|
145
|
+
// :hasSelectButtonPadding="false"
|
142
146
|
// >
|
143
147
|
// <template #selector="{selectedValue}">
|
144
148
|
// value selected: {{selectedValue}}
|
@@ -151,7 +155,8 @@
|
|
151
155
|
// </template>
|
152
156
|
// </Select>
|
153
157
|
|
154
|
-
import
|
158
|
+
import { Teleport } from 'vue'
|
159
|
+
import styled from 'vue3-styled-components'
|
155
160
|
import InfoText from '../../infoText'
|
156
161
|
import icon from '../../icon'
|
157
162
|
import inputText from '../inputText'
|
@@ -167,7 +172,7 @@ const Caret = styled.div`
|
|
167
172
|
width: ${CARET_WIDTH};
|
168
173
|
min-width: ${CARET_WIDTH};
|
169
174
|
height: 100%;
|
170
|
-
align-items:
|
175
|
+
align-items: center;
|
171
176
|
cursor: pointer;
|
172
177
|
margin-left: auto;
|
173
178
|
`
|
@@ -175,17 +180,22 @@ const Caret = styled.div`
|
|
175
180
|
const selectorProps = {
|
176
181
|
selectWidth: String,
|
177
182
|
paddingLeft: String,
|
178
|
-
showBorder: Boolean
|
179
|
-
noMaxWidth: Boolean
|
183
|
+
showBorder: Boolean
|
180
184
|
}
|
181
185
|
const Selector = styled('div', selectorProps)`
|
182
|
-
|
183
|
-
props.
|
184
|
-
? '100
|
185
|
-
: `calc(${props.selectWidth} -
|
186
|
-
|
187
|
-
|
188
|
-
|
186
|
+
${(props) =>
|
187
|
+
props.selectWidth === '100%'
|
188
|
+
? 'width: 100%;'
|
189
|
+
: `width: calc(${props.selectWidth} -
|
190
|
+
(
|
191
|
+
${CARET_WIDTH} +
|
192
|
+
${props.paddingLeft}
|
193
|
+
${props.showBorder ? `+ (${BORDER_WIDTH} * 2)` : ''}
|
194
|
+
)
|
195
|
+
);
|
196
|
+
white-space: nowrap;
|
197
|
+
text-overflow: ellipsis;
|
198
|
+
overflow: hidden;`}
|
189
199
|
`
|
190
200
|
|
191
201
|
const labelAttrs = { fontSize: String, fontColor: String }
|
@@ -200,18 +210,19 @@ const InputLabel = styled('div', labelAttrs)`
|
|
200
210
|
const optionalLabel = styled.span`
|
201
211
|
font-weight: 300;
|
202
212
|
`
|
203
|
-
const inputProps = {
|
213
|
+
const inputProps = {
|
214
|
+
selectWidth: String,
|
215
|
+
optionWidth: String
|
216
|
+
}
|
204
217
|
const Container = styled('div', inputProps)`
|
205
218
|
width: ${(props) => props.selectWidth};
|
206
219
|
position: relative;
|
207
220
|
display: inline-block;
|
208
221
|
`
|
209
|
-
|
210
|
-
const LabelAttrs = { shownDropdown: Boolean }
|
211
|
-
const LabelWrapper = styled('div', LabelAttrs)`
|
222
|
+
const LabelWrapper = styled.div`
|
212
223
|
display: inline-grid;
|
213
224
|
grid-template-columns: auto auto;
|
214
|
-
grid-gap:
|
225
|
+
grid-gap: 12px;
|
215
226
|
align-items: center;
|
216
227
|
justify-content: start;
|
217
228
|
`
|
@@ -229,21 +240,20 @@ const selectButtonAttrs = {
|
|
229
240
|
hasError: Boolean,
|
230
241
|
disabled: Boolean,
|
231
242
|
selectHeight: String,
|
243
|
+
selectWidth: String,
|
232
244
|
height: String,
|
233
245
|
selectMinHeight: String,
|
234
|
-
|
246
|
+
hasNoPadding: Boolean,
|
235
247
|
showBorder: Boolean,
|
236
|
-
paddingLeft: String
|
237
|
-
shownDropdown: Boolean
|
248
|
+
paddingLeft: String
|
238
249
|
}
|
239
250
|
const selectButton = styled('div', selectButtonAttrs)`
|
240
251
|
position: relative;
|
241
252
|
box-sizing: border-box;
|
242
253
|
border-radius: 4px;
|
254
|
+
max-width: ${(props) => (props.selectWidth ? props.selectWidth : '100%')};
|
243
255
|
${(props) =>
|
244
|
-
props.
|
245
|
-
? ''
|
246
|
-
: `padding-left: ${props.shownDropdown ? '0' : props.paddingLeft}`};
|
256
|
+
props.hasNoPadding ? '' : `padding-left: ${props.paddingLeft}`};
|
247
257
|
text-align: left;
|
248
258
|
min-height: ${(props) =>
|
249
259
|
props.selectHeight
|
@@ -255,7 +265,7 @@ const selectButton = styled('div', selectButtonAttrs)`
|
|
255
265
|
: '36px'};
|
256
266
|
display: flex;
|
257
267
|
align-items: center;
|
258
|
-
|
268
|
+
height: ${(props) => props.selectHeight};
|
259
269
|
${({ showBorder, theme, hasError }) =>
|
260
270
|
showBorder &&
|
261
271
|
`
|
@@ -287,14 +297,17 @@ const selectDropdownAttrs = {
|
|
287
297
|
fontColor: String,
|
288
298
|
optionWidth: String,
|
289
299
|
hoveredIndex: Number,
|
300
|
+
fontSize: String,
|
301
|
+
dropdownPosition: Object,
|
290
302
|
hoveredValue: Number | String,
|
291
303
|
selectedValue: Number | String
|
292
304
|
}
|
293
305
|
const selectDropdown = styled('div', selectDropdownAttrs)`
|
294
306
|
box-sizing: border-box;
|
295
|
-
z-index: ${(props) => (props.isActive ? '2' : '
|
307
|
+
z-index: ${(props) => (props.isActive ? '2' : '99999')};
|
296
308
|
position: absolute;
|
297
|
-
top:
|
309
|
+
top: ${(props) => props.dropdownPosition?.top}px;
|
310
|
+
left: ${(props) => props.dropdownPosition?.left}px;
|
298
311
|
border: ${BORDER_WIDTH} solid ${(props) => props.theme.colors.grey4};
|
299
312
|
border-radius: 4px;
|
300
313
|
display: flex;
|
@@ -319,7 +332,9 @@ const selectDropdown = styled('div', selectDropdownAttrs)`
|
|
319
332
|
? props.theme.colors[props.hoveredBgColor]
|
320
333
|
: props.hoveredBgColor};
|
321
334
|
}
|
335
|
+
font-size: ${(props) => props.fontSize};
|
322
336
|
`
|
337
|
+
selectDropdown.emits = ['option-hovered', 'option-selected']
|
323
338
|
const DropdownWrapper = styled('div')`
|
324
339
|
position: relative;
|
325
340
|
`
|
@@ -332,6 +347,10 @@ const InputWrapper = styled('div', inputAttrs)`
|
|
332
347
|
grid-template-columns: ${(props) =>
|
333
348
|
props.alignItems === 'vertical' || !props.hasLabel ? '1fr' : 'auto 1fr'};
|
334
349
|
`
|
350
|
+
|
351
|
+
const DROPDOWN_HEIGHT_OFFSET = 4
|
352
|
+
const DROPDOWN_TOP_OFFSET = 21
|
353
|
+
|
335
354
|
export default {
|
336
355
|
name: 'RCselect',
|
337
356
|
|
@@ -443,15 +462,11 @@ export default {
|
|
443
462
|
type: String,
|
444
463
|
default: ''
|
445
464
|
},
|
446
|
-
|
447
|
-
type: Boolean,
|
448
|
-
default: false
|
449
|
-
},
|
450
|
-
noMaxWidth: {
|
465
|
+
hasSelectButtonPadding: {
|
451
466
|
type: Boolean,
|
452
|
-
default:
|
467
|
+
default: true
|
453
468
|
},
|
454
|
-
|
469
|
+
isDraggable: {
|
455
470
|
type: Boolean,
|
456
471
|
default: false
|
457
472
|
}
|
@@ -472,6 +487,7 @@ export default {
|
|
472
487
|
Caret,
|
473
488
|
Selector,
|
474
489
|
inputText,
|
490
|
+
Teleport,
|
475
491
|
draggableInputHandle
|
476
492
|
},
|
477
493
|
|
@@ -483,23 +499,38 @@ export default {
|
|
483
499
|
isActive: false,
|
484
500
|
textSearch: '',
|
485
501
|
hoveredIndex: 0,
|
486
|
-
|
487
|
-
|
502
|
+
isClickOutsideActive: false,
|
503
|
+
dropdownPosition: {
|
504
|
+
left: null,
|
505
|
+
top: null
|
506
|
+
},
|
507
|
+
dropdownWidth: null,
|
508
|
+
hoveredValue: null
|
488
509
|
}
|
489
510
|
},
|
490
511
|
mounted() {
|
512
|
+
this.observeDropdownHeight()
|
513
|
+
this.observeSelectWidth()
|
514
|
+
window.addEventListener('resize', this.handleSetDropdownOffet)
|
515
|
+
},
|
516
|
+
beforeMount() {
|
491
517
|
this.selectedValue = this.value
|
492
518
|
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()
|
493
523
|
},
|
494
|
-
|
524
|
+
unmounted() {
|
495
525
|
document.removeEventListener('click', this.clickOutside)
|
496
526
|
},
|
497
527
|
methods: {
|
498
528
|
focus() {
|
499
529
|
this.isActive = true
|
500
530
|
},
|
501
|
-
blur() {
|
531
|
+
blur(e) {
|
502
532
|
this.isActive = false
|
533
|
+
this.$emit('blur', e)
|
503
534
|
},
|
504
535
|
toggleDropdown() {
|
505
536
|
this.isDropdownOpen = !this.isDropdownOpen
|
@@ -515,6 +546,9 @@ export default {
|
|
515
546
|
this.blur()
|
516
547
|
this.isDropdownOpen = false
|
517
548
|
},
|
549
|
+
clearSearch() {
|
550
|
+
this.textSearch = ''
|
551
|
+
},
|
518
552
|
optionSelected(e) {
|
519
553
|
this.selectedValue = e
|
520
554
|
this.closeDropdown()
|
@@ -543,22 +577,15 @@ export default {
|
|
543
577
|
searchChange(value) {
|
544
578
|
this.textSearch = value
|
545
579
|
this.$emit('search-change', value)
|
546
|
-
const
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
.forEach((el) => {
|
556
|
-
if (!el.textContent.toLowerCase().includes(value.toLowerCase())) {
|
557
|
-
el.style.display = 'none'
|
558
|
-
} else {
|
559
|
-
el.style.display = 'grid'
|
560
|
-
}
|
561
|
-
})
|
580
|
+
const dropdownChildren = [...this.$refs.dropdown.$el.children]
|
581
|
+
dropdownChildren.forEach((el) => {
|
582
|
+
if (!el.textContent.toLowerCase().includes(value.toLowerCase())) {
|
583
|
+
el.style.display = 'none'
|
584
|
+
|
585
|
+
return
|
586
|
+
}
|
587
|
+
el.style.display = 'inherit'
|
588
|
+
})
|
562
589
|
},
|
563
590
|
clickOutside(event) {
|
564
591
|
const dropdownRef = this.$refs.dropdown
|
@@ -568,6 +595,7 @@ export default {
|
|
568
595
|
if (
|
569
596
|
this.$refs.select.$el == event.target ||
|
570
597
|
this.$refs.select.$el.contains(event.target) ||
|
598
|
+
event.target.id === 'more-button' ||
|
571
599
|
event.target.parentNode === dropdownRef.$el
|
572
600
|
) {
|
573
601
|
return
|
@@ -581,13 +609,92 @@ export default {
|
|
581
609
|
} else if (e.key == 'ArrowUp') {
|
582
610
|
this.onArrowPress(-1)
|
583
611
|
} else if (e.key == 'Enter') {
|
584
|
-
const optionHoveredComponent =
|
585
|
-
this
|
586
|
-
|
587
|
-
]
|
612
|
+
const optionHoveredComponent = [...this.$refs.dropdown.$el.children][
|
613
|
+
(this.hoveredIndex - 1 + this.optionLength) % this.optionLength
|
614
|
+
]
|
588
615
|
this.optionSelected(optionHoveredComponent.$el.dataset.value)
|
589
616
|
}
|
590
617
|
},
|
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
|
+
},
|
591
698
|
onArrowPress(dir) {
|
592
699
|
let newHoveredElem
|
593
700
|
const currentHoveredElem = this.$refs.dropdown.$el.querySelector(
|
@@ -619,20 +726,34 @@ export default {
|
|
619
726
|
return 0
|
620
727
|
},
|
621
728
|
isSearchBarVisible() {
|
622
|
-
return this.isSearchable && this.isDropdownOpen
|
729
|
+
return this.isSearchable && this.optionLength >= 5 && this.isDropdownOpen
|
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
|
+
)
|
623
742
|
}
|
624
743
|
},
|
625
744
|
watch: {
|
626
745
|
value(val) {
|
627
746
|
this.selectedValue = val
|
628
747
|
},
|
629
|
-
isDropdownOpen(val) {
|
630
|
-
this.$emit('is-dropdown-open', val)
|
748
|
+
async isDropdownOpen(val) {
|
631
749
|
if (val) {
|
632
750
|
setTimeout(() => {
|
633
751
|
this.isClickOutsideActive = true
|
634
752
|
}, 10)
|
753
|
+
await this.$nextTick()
|
754
|
+
this.handleSetDropdownOffet()
|
635
755
|
} else {
|
756
|
+
this.dropdownPosition.left = null
|
636
757
|
setTimeout(() => {
|
637
758
|
this.isClickOutsideActive = false
|
638
759
|
}, 10)
|
@@ -12,6 +12,8 @@
|
|
12
12
|
@mouseover="hoverHandler"
|
13
13
|
:cursorType="cursorType"
|
14
14
|
:isDisabled="isDisabled"
|
15
|
+
:disabledBgColor="disabledBgColor"
|
16
|
+
:disabledTextColor="disabledTextColor"
|
15
17
|
:backgroundColor="colorMode == 'dark' ? '#000000' : backgroundColor"
|
16
18
|
:title="hoverText"
|
17
19
|
>
|
@@ -22,12 +24,14 @@
|
|
22
24
|
<script>
|
23
25
|
// import selectButton from './selectButton'
|
24
26
|
// import selectDropdown from './selectDropDown'
|
25
|
-
import styled from '
|
27
|
+
import styled from 'vue3-styled-components'
|
26
28
|
const optionProps = {
|
27
29
|
isDisabled: Boolean,
|
28
30
|
hoveredBgColor: String,
|
29
31
|
cursorType: String,
|
30
|
-
backgroundColor: String
|
32
|
+
backgroundColor: String,
|
33
|
+
disabledBgColor: String,
|
34
|
+
disabledTextColor: String
|
31
35
|
}
|
32
36
|
const optionContainer = styled('div', optionProps)`
|
33
37
|
display: flex;
|
@@ -39,19 +43,33 @@ const optionContainer = styled('div', optionProps)`
|
|
39
43
|
gap: 14px;
|
40
44
|
width: 100%;
|
41
45
|
background-color: ${(props) =>
|
42
|
-
props.
|
46
|
+
props.isDisabled
|
47
|
+
? props.theme.colors[props.disabledBgColor]
|
48
|
+
? props.theme.colors[props.disabledBgColor]
|
49
|
+
: props.disabledBgColor
|
50
|
+
: props.theme.colors[props.backgroundColor]
|
43
51
|
? props.theme.colors[props.backgroundColor]
|
44
|
-
: props.backgroundColor};
|
52
|
+
: props.backgroundColor} !important;
|
45
53
|
box-sizing: inherit;
|
46
54
|
background-color: ${(props) =>
|
47
55
|
props.theme.colors[props.backgroundColor]
|
48
56
|
? props.theme.colors[props.backgroundColor]
|
49
57
|
: props.backgroundColor};
|
50
58
|
color: ${(props) =>
|
51
|
-
props.isDisabled
|
59
|
+
props.isDisabled
|
60
|
+
? !!props.disabledTextColor
|
61
|
+
? props.theme.colors[props.disabledTextColor]
|
62
|
+
? props.theme.colors[props.disabledTextColor]
|
63
|
+
: props.disabledTextColor
|
64
|
+
: props.theme.colors.grey3
|
65
|
+
: 'inherit'};
|
52
66
|
&:hover {
|
53
67
|
background-color: ${(props) =>
|
54
|
-
props.
|
68
|
+
!!props.disabledTextColor && props.isDisabled
|
69
|
+
? props.theme.colors[props.disabledBgColor]
|
70
|
+
? props.theme.colors[props.disabledBgColor]
|
71
|
+
: props.disabledBgColor
|
72
|
+
: props.theme.colors[props.hoveredBgColor]
|
55
73
|
? props.theme.colors[props.hoveredBgColor]
|
56
74
|
: props.hoveredBgColor} !important;
|
57
75
|
}
|
@@ -59,7 +77,7 @@ const optionContainer = styled('div', optionProps)`
|
|
59
77
|
|
60
78
|
export default {
|
61
79
|
name: 'RCoption',
|
62
|
-
|
80
|
+
emits: ['option-hovered', 'option-selected'],
|
63
81
|
props: {
|
64
82
|
value: {
|
65
83
|
required: true
|
@@ -73,7 +91,7 @@ export default {
|
|
73
91
|
},
|
74
92
|
cursorType: {
|
75
93
|
required: false,
|
76
|
-
default: '
|
94
|
+
default: 'pointer'
|
77
95
|
},
|
78
96
|
backgroundColor: {
|
79
97
|
required: false,
|
@@ -85,21 +103,28 @@ export default {
|
|
85
103
|
isDisabled: {
|
86
104
|
required: false,
|
87
105
|
default: false
|
106
|
+
},
|
107
|
+
disabledBgColor: {
|
108
|
+
required: false,
|
109
|
+
default: 'white'
|
110
|
+
},
|
111
|
+
disabledTextColor: {
|
112
|
+
required: false,
|
113
|
+
default: null
|
88
114
|
}
|
89
115
|
},
|
90
116
|
|
91
117
|
components: { optionContainer },
|
92
|
-
|
93
118
|
data() {
|
94
119
|
return {}
|
95
120
|
},
|
96
121
|
methods: {
|
97
|
-
clickHandler() {
|
122
|
+
clickHandler(e) {
|
98
123
|
if (this.isDisabled) {
|
99
124
|
// prevent emitter if the option is disabled
|
100
125
|
return
|
101
126
|
} else {
|
102
|
-
this.$parent.$emit('option-selected', this.value)
|
127
|
+
this.$parent.$emit('option-selected', this.value, e)
|
103
128
|
}
|
104
129
|
},
|
105
130
|
hoverHandler() {
|