@eturnity/eturnity_reusable_components 7.4.4-EPDM-7260.16 → 7.4.4-EPDM-7260.18
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/card/index.vue +25 -24
- package/src/components/deleteIcon/DeleteIcon.stories.js +7 -7
- package/src/components/deleteIcon/index.vue +47 -30
- 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 +59 -97
- 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 +59 -82
- 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 +21 -6
- package/src/components/inputs/inputNumber/index.vue +8 -11
- 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 +261 -60
- package/src/components/inputs/select/option/index.vue +43 -12
- 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 +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 +3 -3
- package/src/components/progressBar/index.vue +1 -1
- package/src/components/projectMarker/index.vue +16 -9
- package/src/components/rangeSlider/index.vue +9 -10
- package/src/components/selectedOptions/index.vue +1 -1
- package/src/components/sideMenu/index.vue +1 -1
- package/src/components/spinner/index.vue +7 -11
- package/src/components/tableDropdown/index.vue +35 -45
- 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 +3 -10
@@ -31,7 +31,9 @@
|
|
31
31
|
<select-button-wrapper :disabled="disabled">
|
32
32
|
<selectButton
|
33
33
|
ref="select"
|
34
|
+
class="select-button"
|
34
35
|
@click="toggleDropdown"
|
36
|
+
:selectWidth="selectWidth"
|
35
37
|
:selectHeight="selectHeight"
|
36
38
|
:height="height"
|
37
39
|
:selectMinHeight="selectMinHeight"
|
@@ -43,9 +45,9 @@
|
|
43
45
|
"
|
44
46
|
:fontSize="fontSize"
|
45
47
|
:hasError="hasError"
|
46
|
-
:
|
48
|
+
:hasNoPadding="isSearchBarVisible || !hasSelectButtonPadding"
|
47
49
|
:disabled="disabled"
|
48
|
-
@keydown
|
50
|
+
@keydown="onKeyDown"
|
49
51
|
:showBorder="showBorder"
|
50
52
|
:data-id="dataId"
|
51
53
|
:paddingLeft="paddingLeft"
|
@@ -66,9 +68,10 @@
|
|
66
68
|
buttonFontColor || colorMode == 'dark' ? 'white' : 'black'
|
67
69
|
"
|
68
70
|
:value="textSearch"
|
71
|
+
:inputWidth="computedWidth"
|
69
72
|
@keydown.stop="onKeyDown"
|
70
73
|
@input-change="searchChange"
|
71
|
-
@click.
|
74
|
+
@click.stop
|
72
75
|
/>
|
73
76
|
<selector
|
74
77
|
v-else
|
@@ -101,27 +104,33 @@
|
|
101
104
|
/>
|
102
105
|
</Caret>
|
103
106
|
</selectButton>
|
104
|
-
<DropdownWrapper>
|
105
|
-
<
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
107
|
+
<DropdownWrapper ref="dropdownWrapperRef">
|
108
|
+
<Teleport to="#portal-target">
|
109
|
+
<selectDropdown
|
110
|
+
ref="dropdown"
|
111
|
+
v-show="isSelectDropdownShown"
|
112
|
+
:dropdownPosition="dropdownPosition"
|
113
|
+
:hoveredIndex="hoveredIndex"
|
114
|
+
:hoveredValue="hoveredValue"
|
115
|
+
:isActive="isActive"
|
116
|
+
:optionWidth="getOptionWidth"
|
117
|
+
:hoveredBgColor="
|
118
|
+
colorMode == 'dark' ? '#000000' : dropdownBgColor
|
119
|
+
"
|
120
|
+
:bgColor="
|
121
|
+
dropdownBgColor || colorMode == 'dark' ? 'black' : 'white'
|
122
|
+
"
|
123
|
+
:fontColor="
|
124
|
+
dropdownFontColor || colorMode == 'dark' ? 'white' : 'black'
|
125
|
+
"
|
126
|
+
:fontSize="fontSize"
|
127
|
+
:selectedValue="selectedValue"
|
128
|
+
@option-selected="optionSelected"
|
129
|
+
@option-hovered="optionHovered"
|
130
|
+
>
|
131
|
+
<slot name="dropdown"></slot>
|
132
|
+
</selectDropdown>
|
133
|
+
</Teleport>
|
125
134
|
</DropdownWrapper>
|
126
135
|
</select-button-wrapper>
|
127
136
|
</input-wrapper>
|
@@ -137,8 +146,9 @@
|
|
137
146
|
// optionWidth="50%"
|
138
147
|
// label="that is a label"
|
139
148
|
// alignItems="vertical"
|
140
|
-
// label-data-id="test-
|
149
|
+
// label-data-id="test-label-data-id"
|
141
150
|
// data-id="test-data-id"
|
151
|
+
// :hasSelectButtonPadding="false"
|
142
152
|
// >
|
143
153
|
// <template #selector="{selectedValue}">
|
144
154
|
// value selected: {{selectedValue}}
|
@@ -151,7 +161,8 @@
|
|
151
161
|
// </template>
|
152
162
|
// </Select>
|
153
163
|
|
154
|
-
import
|
164
|
+
import { Teleport } from 'vue'
|
165
|
+
import styled from 'vue3-styled-components'
|
155
166
|
import InfoText from '../../infoText'
|
156
167
|
import icon from '../../icon'
|
157
168
|
import inputText from '../inputText'
|
@@ -167,7 +178,7 @@ const Caret = styled.div`
|
|
167
178
|
width: ${CARET_WIDTH};
|
168
179
|
min-width: ${CARET_WIDTH};
|
169
180
|
height: 100%;
|
170
|
-
align-items:
|
181
|
+
align-items: center;
|
171
182
|
cursor: pointer;
|
172
183
|
margin-left: auto;
|
173
184
|
`
|
@@ -237,9 +248,10 @@ const selectButtonAttrs = {
|
|
237
248
|
hasError: Boolean,
|
238
249
|
disabled: Boolean,
|
239
250
|
selectHeight: String,
|
251
|
+
selectWidth: String,
|
240
252
|
height: String,
|
241
253
|
selectMinHeight: String,
|
242
|
-
|
254
|
+
hasNoPadding: Boolean,
|
243
255
|
showBorder: Boolean,
|
244
256
|
paddingLeft: String
|
245
257
|
}
|
@@ -248,8 +260,9 @@ const selectButton = styled('div', selectButtonAttrs)`
|
|
248
260
|
position: relative;
|
249
261
|
box-sizing: border-box;
|
250
262
|
border-radius: 4px;
|
263
|
+
max-width: ${(props) => (props.selectWidth ? props.selectWidth : '100%')};
|
251
264
|
${(props) =>
|
252
|
-
props.
|
265
|
+
props.hasNoPadding ? '' : `padding-left: ${props.paddingLeft}`};
|
253
266
|
text-align: left;
|
254
267
|
min-height: ${(props) =>
|
255
268
|
props.selectHeight
|
@@ -261,7 +274,7 @@ const selectButton = styled('div', selectButtonAttrs)`
|
|
261
274
|
: '36px'};
|
262
275
|
display: flex;
|
263
276
|
align-items: center;
|
264
|
-
|
277
|
+
height: ${(props) => props.selectHeight};
|
265
278
|
${({ showBorder, theme, hasError }) =>
|
266
279
|
showBorder &&
|
267
280
|
`
|
@@ -293,15 +306,17 @@ const selectDropdownAttrs = {
|
|
293
306
|
fontColor: String,
|
294
307
|
optionWidth: String,
|
295
308
|
hoveredIndex: Number,
|
309
|
+
fontSize: String,
|
310
|
+
dropdownPosition: Object,
|
296
311
|
hoveredValue: Number | String,
|
297
|
-
selectedValue: Number | String
|
298
|
-
fontSize: String
|
312
|
+
selectedValue: Number | String
|
299
313
|
}
|
300
314
|
const selectDropdown = styled('div', selectDropdownAttrs)`
|
301
315
|
box-sizing: border-box;
|
302
|
-
z-index: ${(props) => (props.isActive ? '2' : '
|
316
|
+
z-index: ${(props) => (props.isActive ? '2' : '99999')};
|
303
317
|
position: absolute;
|
304
|
-
top:
|
318
|
+
top: ${(props) => props.dropdownPosition?.top}px;
|
319
|
+
left: ${(props) => props.dropdownPosition?.left}px;
|
305
320
|
border: ${BORDER_WIDTH} solid ${(props) => props.theme.colors.grey4};
|
306
321
|
border-radius: 4px;
|
307
322
|
display: flex;
|
@@ -326,7 +341,9 @@ const selectDropdown = styled('div', selectDropdownAttrs)`
|
|
326
341
|
? props.theme.colors[props.hoveredBgColor]
|
327
342
|
: props.hoveredBgColor};
|
328
343
|
}
|
344
|
+
font-size: ${(props) => props.fontSize};
|
329
345
|
`
|
346
|
+
selectDropdown.emits = ['option-hovered', 'option-selected']
|
330
347
|
const DropdownWrapper = styled('div')`
|
331
348
|
position: relative;
|
332
349
|
`
|
@@ -341,6 +358,16 @@ const InputWrapper = styled('div', inputAttrs)`
|
|
341
358
|
grid-template-columns: ${(props) =>
|
342
359
|
props.alignItems === 'vertical' || !props.hasLabel ? '1fr' : 'auto 1fr'};
|
343
360
|
`
|
361
|
+
|
362
|
+
const DROPDOWN_HEIGHT_OFFSET = 4
|
363
|
+
const DROPDOWN_TOP_OFFSET = 21
|
364
|
+
const MIN_OPTION_LENGTH = 5
|
365
|
+
|
366
|
+
const DROPDOWN_MENU_POSITIONS = {
|
367
|
+
Automatic: 'automatic',
|
368
|
+
Bottom: 'bottom'
|
369
|
+
}
|
370
|
+
|
344
371
|
export default {
|
345
372
|
name: 'RCselect',
|
346
373
|
|
@@ -462,9 +489,25 @@ export default {
|
|
462
489
|
type: String,
|
463
490
|
default: ''
|
464
491
|
},
|
492
|
+
hasSelectButtonPadding: {
|
493
|
+
type: Boolean,
|
494
|
+
default: true
|
495
|
+
},
|
465
496
|
isDraggable: {
|
466
497
|
type: Boolean,
|
467
498
|
default: false
|
499
|
+
},
|
500
|
+
leftPadding: {
|
501
|
+
type: String,
|
502
|
+
default: '15px'
|
503
|
+
},
|
504
|
+
minOptionLength: {
|
505
|
+
type: Number,
|
506
|
+
default: MIN_OPTION_LENGTH
|
507
|
+
},
|
508
|
+
dropdownMenuPosition: {
|
509
|
+
type: String,
|
510
|
+
default: DROPDOWN_MENU_POSITIONS.Automatic // options: ['automatic', bottom]
|
468
511
|
}
|
469
512
|
},
|
470
513
|
|
@@ -483,34 +526,54 @@ export default {
|
|
483
526
|
Caret,
|
484
527
|
Selector,
|
485
528
|
inputText,
|
529
|
+
Teleport,
|
486
530
|
draggableInputHandle
|
487
531
|
},
|
488
532
|
|
489
533
|
data() {
|
490
534
|
return {
|
491
535
|
selectedValue: null,
|
492
|
-
paddingLeft: this.isDraggable
|
536
|
+
paddingLeft: this.isDraggable
|
537
|
+
? '30px'
|
538
|
+
: this.leftPadding
|
539
|
+
? this.leftPadding
|
540
|
+
: '15px',
|
493
541
|
isDropdownOpen: false,
|
494
542
|
isActive: false,
|
495
543
|
textSearch: '',
|
496
544
|
hoveredIndex: 0,
|
497
|
-
|
498
|
-
|
545
|
+
isClickOutsideActive: false,
|
546
|
+
dropdownPosition: {
|
547
|
+
left: null,
|
548
|
+
top: null
|
549
|
+
},
|
550
|
+
dropdownWidth: null,
|
551
|
+
hoveredValue: null
|
499
552
|
}
|
500
553
|
},
|
501
554
|
mounted() {
|
555
|
+
this.observeDropdownHeight()
|
556
|
+
this.observeSelectWidth()
|
557
|
+
window.addEventListener('resize', this.handleSetDropdownOffet)
|
558
|
+
},
|
559
|
+
beforeMount() {
|
502
560
|
this.selectedValue = this.value
|
503
561
|
document.addEventListener('click', this.clickOutside)
|
562
|
+
this.getDropdownPosition()
|
563
|
+
window.removeEventListener('resize', this.handleSetDropdownOffet)
|
564
|
+
if (this.dropdownResizeObserver) this.dropdownResizeObserver.disconnect()
|
565
|
+
if (this.selectResizeObserver) this.selectResizeObserver.disconnect()
|
504
566
|
},
|
505
|
-
|
567
|
+
unmounted() {
|
506
568
|
document.removeEventListener('click', this.clickOutside)
|
507
569
|
},
|
508
570
|
methods: {
|
509
571
|
focus() {
|
510
572
|
this.isActive = true
|
511
573
|
},
|
512
|
-
blur() {
|
574
|
+
blur(e) {
|
513
575
|
this.isActive = false
|
576
|
+
this.$emit('blur', e)
|
514
577
|
},
|
515
578
|
toggleDropdown() {
|
516
579
|
this.isDropdownOpen = !this.isDropdownOpen
|
@@ -520,8 +583,13 @@ export default {
|
|
520
583
|
},
|
521
584
|
closeDropdown() {
|
522
585
|
this.blur()
|
586
|
+
this.clearSearch()
|
523
587
|
this.isDropdownOpen = false
|
524
588
|
},
|
589
|
+
clearSearch() {
|
590
|
+
this.textSearch = ''
|
591
|
+
this.searchChange('')
|
592
|
+
},
|
525
593
|
optionSelected(e) {
|
526
594
|
this.selectedValue = e
|
527
595
|
this.closeDropdown()
|
@@ -550,15 +618,15 @@ export default {
|
|
550
618
|
searchChange(value) {
|
551
619
|
this.textSearch = value
|
552
620
|
this.$emit('search-change', value)
|
553
|
-
this.$refs.dropdown.$children
|
554
|
-
|
555
|
-
.
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
621
|
+
const dropdownChildren = [...this.$refs.dropdown.$el.children]
|
622
|
+
dropdownChildren.forEach((el) => {
|
623
|
+
if (!el.textContent.toLowerCase().includes(value.toLowerCase())) {
|
624
|
+
el.style.display = 'none'
|
625
|
+
|
626
|
+
return
|
627
|
+
}
|
628
|
+
el.style.display = 'inherit'
|
629
|
+
})
|
562
630
|
},
|
563
631
|
clickOutside(event) {
|
564
632
|
const dropdownRef = this.$refs.dropdown
|
@@ -568,6 +636,7 @@ export default {
|
|
568
636
|
if (
|
569
637
|
this.$refs.select.$el == event.target ||
|
570
638
|
this.$refs.select.$el.contains(event.target) ||
|
639
|
+
event.target.id === 'more-button' ||
|
571
640
|
event.target.parentNode === dropdownRef.$el
|
572
641
|
) {
|
573
642
|
return
|
@@ -581,13 +650,102 @@ export default {
|
|
581
650
|
} else if (e.key == 'ArrowUp') {
|
582
651
|
this.onArrowPress(-1)
|
583
652
|
} else if (e.key == 'Enter') {
|
584
|
-
const optionHoveredComponent =
|
585
|
-
this
|
586
|
-
|
587
|
-
]
|
653
|
+
const optionHoveredComponent = [...this.$refs.dropdown.$el.children][
|
654
|
+
(this.hoveredIndex - 1 + this.optionLength) % this.optionLength
|
655
|
+
]
|
588
656
|
this.optionSelected(optionHoveredComponent.$el.dataset.value)
|
589
657
|
}
|
590
658
|
},
|
659
|
+
// If some part of the dropdown menu is outside viewport of the bottom of the screen,
|
660
|
+
// we need to offset it and display it at the top of the select dropdown instead
|
661
|
+
async getDropdownPosition() {
|
662
|
+
if (
|
663
|
+
!this.$refs.dropdownWrapperRef ||
|
664
|
+
!this.$refs.select ||
|
665
|
+
!this.$refs.dropdown
|
666
|
+
) {
|
667
|
+
return
|
668
|
+
}
|
669
|
+
await this.$nextTick()
|
670
|
+
const isDisplayedAtBottom = await this.generateDropdownPosition()
|
671
|
+
// If the dropdown menu is going to be displayed at the bottom,
|
672
|
+
// we need reverify its position after a dom update (nextTick)
|
673
|
+
await this.$nextTick()
|
674
|
+
if (isDisplayedAtBottom) this.generateDropdownPosition()
|
675
|
+
},
|
676
|
+
async generateDropdownPosition() {
|
677
|
+
const isDropdownNotCompletelyVisible =
|
678
|
+
await this.isBottomOfDropdownOutOfViewport()
|
679
|
+
const dropdownWrapperEl = this.$refs.dropdownWrapperRef.$el
|
680
|
+
const selectButtonHeight = this.$refs.select.$el.clientHeight
|
681
|
+
const dropdownHeight = this.$refs.dropdown.$el.clientHeight
|
682
|
+
const dropdownWrapperRelativeHeight =
|
683
|
+
dropdownWrapperEl.getBoundingClientRect().top +
|
684
|
+
window.scrollY +
|
685
|
+
DROPDOWN_HEIGHT_OFFSET
|
686
|
+
|
687
|
+
const top =
|
688
|
+
isDropdownNotCompletelyVisible ||
|
689
|
+
(!isDropdownNotCompletelyVisible &&
|
690
|
+
this.dropdownMenuPosition === DROPDOWN_MENU_POSITIONS.Bottom)
|
691
|
+
? dropdownWrapperRelativeHeight
|
692
|
+
: dropdownWrapperRelativeHeight -
|
693
|
+
dropdownHeight -
|
694
|
+
selectButtonHeight -
|
695
|
+
DROPDOWN_TOP_OFFSET
|
696
|
+
const left = this.dropdownPosition.left
|
697
|
+
? this.dropdownPosition.left
|
698
|
+
: dropdownWrapperEl.getBoundingClientRect().left + window.scrollX
|
699
|
+
|
700
|
+
this.dropdownPosition = { left: Math.floor(left), top: Math.floor(top) }
|
701
|
+
|
702
|
+
return isDropdownNotCompletelyVisible
|
703
|
+
},
|
704
|
+
async isBottomOfDropdownOutOfViewport() {
|
705
|
+
if (
|
706
|
+
!this.$refs.dropdown ||
|
707
|
+
this.dropdownMenuPosition === DROPDOWN_MENU_POSITIONS.Bottom
|
708
|
+
) {
|
709
|
+
return false
|
710
|
+
}
|
711
|
+
|
712
|
+
await this.$nextTick()
|
713
|
+
const rect = this.$refs.dropdown.$el.getBoundingClientRect()
|
714
|
+
const windowHeight =
|
715
|
+
window.innerHeight || document.documentElement.clientHeight
|
716
|
+
|
717
|
+
if (windowHeight <= 650) return true
|
718
|
+
|
719
|
+
// using Math.floor because the offsets may contain decimals we are not going to consider here
|
720
|
+
return Math.floor(rect.top) + Math.floor(rect.height) <= windowHeight
|
721
|
+
},
|
722
|
+
observeDropdownHeight() {
|
723
|
+
if (!this.$refs.dropdown) return
|
724
|
+
this.dropdownResizeObserver = new ResizeObserver(() => {
|
725
|
+
this.$nextTick(() => this.getDropdownPosition())
|
726
|
+
})
|
727
|
+
this.dropdownResizeObserver.observe(this.$refs.dropdown.$el)
|
728
|
+
},
|
729
|
+
handleSetDropdownOffet() {
|
730
|
+
if (!this.$refs.select) return
|
731
|
+
this.dropdownPosition.left = Math.floor(
|
732
|
+
this.$refs.select.$el.getBoundingClientRect().left
|
733
|
+
)
|
734
|
+
this.getDropdownWidth()
|
735
|
+
},
|
736
|
+
observeSelectWidth() {
|
737
|
+
if (!this.$refs.select) return
|
738
|
+
this.selectResizeObserver = new ResizeObserver(() =>
|
739
|
+
// eslint-disable-next-line vue/valid-next-tick
|
740
|
+
this.$nextTick(() => this.getDropdownWidth())
|
741
|
+
)
|
742
|
+
this.selectResizeObserver.observe(this.$refs.dropdown.$el)
|
743
|
+
},
|
744
|
+
async getDropdownWidth() {
|
745
|
+
if (!this.$refs.select) return
|
746
|
+
await this.$nextTick()
|
747
|
+
this.dropdownWidth = `${this.$refs.select.$el.clientWidth}px`
|
748
|
+
},
|
591
749
|
onArrowPress(dir) {
|
592
750
|
let newHoveredElem
|
593
751
|
const currentHoveredElem = this.$refs.dropdown.$el.querySelector(
|
@@ -605,42 +763,85 @@ export default {
|
|
605
763
|
this.$refs.dropdown.$el.scrollTop = topPos
|
606
764
|
}
|
607
765
|
}
|
608
|
-
},
|
609
|
-
clearSearch() {
|
610
|
-
this.textSearch = ''
|
611
766
|
}
|
612
767
|
},
|
613
768
|
computed: {
|
614
769
|
optionLength() {
|
615
770
|
if (this.isDropdownOpen) {
|
616
|
-
return this.$refs.dropdown.$el.childElementCount
|
771
|
+
return this.$refs.dropdown.$el.childElementCount > 1
|
772
|
+
? this.$refs.dropdown.$el.childElementCount
|
773
|
+
: this.$refs.dropdown.$el.children[0].childElementCount
|
617
774
|
}
|
618
775
|
|
619
776
|
return 0
|
620
777
|
},
|
621
778
|
isSearchBarVisible() {
|
622
|
-
return
|
779
|
+
return (
|
780
|
+
this.isSearchable &&
|
781
|
+
this.optionLength >= this.minOptionLength &&
|
782
|
+
this.isDropdownOpen
|
783
|
+
)
|
784
|
+
},
|
785
|
+
computedWidth() {
|
786
|
+
function removePX(item) {
|
787
|
+
return Number(item.replace('px', ''))
|
788
|
+
}
|
789
|
+
|
790
|
+
const value =
|
791
|
+
this.selectWidth === '100%'
|
792
|
+
? '100%'
|
793
|
+
: removePX(this.selectWidth) - removePX(CARET_WIDTH)
|
794
|
+
|
795
|
+
return value + 'px'
|
796
|
+
},
|
797
|
+
getOptionWidth() {
|
798
|
+
if (this.optionWidth) return this.optionWidth
|
799
|
+
|
800
|
+
return this.dropdownWidth
|
801
|
+
},
|
802
|
+
isSelectDropdownShown() {
|
803
|
+
return (
|
804
|
+
this.isDropdownOpen &&
|
805
|
+
this.dropdownPosition.left !== null &&
|
806
|
+
(!this.isSearchable || this.isSearchable)
|
807
|
+
)
|
808
|
+
},
|
809
|
+
isMobileDevice() {
|
810
|
+
const userAgent = navigator.userAgent || navigator.vendor || window.opera
|
811
|
+
const touchCapable =
|
812
|
+
'ontouchstart' in window ||
|
813
|
+
navigator.maxTouchPoints > 0 ||
|
814
|
+
navigator.msMaxTouchPoints > 0
|
815
|
+
|
816
|
+
return (
|
817
|
+
/Android/i.test(userAgent) ||
|
818
|
+
/iPad|iPhone|iPod/.test(userAgent) ||
|
819
|
+
(/Macintosh/.test(userAgent) && touchCapable) ||
|
820
|
+
/windows phone/i.test(userAgent)
|
821
|
+
)
|
623
822
|
}
|
624
823
|
},
|
625
824
|
watch: {
|
626
825
|
value(val) {
|
627
826
|
this.selectedValue = val
|
628
827
|
},
|
629
|
-
isDropdownOpen(val) {
|
630
|
-
this.$emit('is-dropdown-open', val)
|
828
|
+
async isDropdownOpen(val) {
|
631
829
|
if (val) {
|
632
830
|
this.$emit('on-dropdown-open')
|
633
831
|
setTimeout(() => {
|
634
832
|
this.isClickOutsideActive = true
|
635
833
|
}, 10)
|
834
|
+
await this.$nextTick()
|
835
|
+
this.handleSetDropdownOffet()
|
636
836
|
} else {
|
837
|
+
this.dropdownPosition.left = null
|
637
838
|
setTimeout(() => {
|
638
839
|
this.isClickOutsideActive = false
|
639
840
|
}, 10)
|
640
841
|
}
|
641
842
|
if (val && this.isSearchable) {
|
642
843
|
this.$nextTick(() => {
|
643
|
-
if (this.$refs.searchInput) {
|
844
|
+
if (this.$refs.searchInput && !this.isMobileDevice) {
|
644
845
|
this.$refs.searchInput.$el.querySelector('input').focus()
|
645
846
|
}
|
646
847
|
})
|
@@ -12,8 +12,11 @@
|
|
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"
|
19
|
+
:padding="padding"
|
17
20
|
>
|
18
21
|
<slot></slot>
|
19
22
|
</optionContainer>
|
@@ -22,12 +25,15 @@
|
|
22
25
|
<script>
|
23
26
|
// import selectButton from './selectButton'
|
24
27
|
// import selectDropdown from './selectDropDown'
|
25
|
-
import styled from '
|
28
|
+
import styled from 'vue3-styled-components'
|
26
29
|
const optionProps = {
|
27
30
|
isDisabled: Boolean,
|
28
31
|
hoveredBgColor: String,
|
29
32
|
cursorType: String,
|
30
|
-
backgroundColor: String
|
33
|
+
backgroundColor: String,
|
34
|
+
disabledBgColor: String,
|
35
|
+
disabledTextColor: String,
|
36
|
+
padding: String
|
31
37
|
}
|
32
38
|
const optionContainer = styled('div', optionProps)`
|
33
39
|
display: flex;
|
@@ -35,23 +41,37 @@ const optionContainer = styled('div', optionProps)`
|
|
35
41
|
flex-direction: row;
|
36
42
|
justify-content: space-between;
|
37
43
|
align-items: center;
|
38
|
-
padding:
|
44
|
+
padding: ${(props) => props.padding};
|
39
45
|
gap: 14px;
|
40
46
|
width: 100%;
|
41
47
|
background-color: ${(props) =>
|
42
|
-
props.
|
48
|
+
props.isDisabled
|
49
|
+
? props.theme.colors[props.disabledBgColor]
|
50
|
+
? props.theme.colors[props.disabledBgColor]
|
51
|
+
: props.disabledBgColor
|
52
|
+
: props.theme.colors[props.backgroundColor]
|
43
53
|
? props.theme.colors[props.backgroundColor]
|
44
|
-
: props.backgroundColor};
|
54
|
+
: props.backgroundColor} !important;
|
45
55
|
box-sizing: inherit;
|
46
56
|
background-color: ${(props) =>
|
47
57
|
props.theme.colors[props.backgroundColor]
|
48
58
|
? props.theme.colors[props.backgroundColor]
|
49
59
|
: props.backgroundColor};
|
50
60
|
color: ${(props) =>
|
51
|
-
props.isDisabled
|
61
|
+
props.isDisabled
|
62
|
+
? !!props.disabledTextColor
|
63
|
+
? props.theme.colors[props.disabledTextColor]
|
64
|
+
? props.theme.colors[props.disabledTextColor]
|
65
|
+
: props.disabledTextColor
|
66
|
+
: props.theme.colors.grey3
|
67
|
+
: 'inherit'};
|
52
68
|
&:hover {
|
53
69
|
background-color: ${(props) =>
|
54
|
-
props.
|
70
|
+
!!props.disabledTextColor && props.isDisabled
|
71
|
+
? props.theme.colors[props.disabledBgColor]
|
72
|
+
? props.theme.colors[props.disabledBgColor]
|
73
|
+
: props.disabledBgColor
|
74
|
+
: props.theme.colors[props.hoveredBgColor]
|
55
75
|
? props.theme.colors[props.hoveredBgColor]
|
56
76
|
: props.hoveredBgColor} !important;
|
57
77
|
}
|
@@ -59,7 +79,7 @@ const optionContainer = styled('div', optionProps)`
|
|
59
79
|
|
60
80
|
export default {
|
61
81
|
name: 'RCoption',
|
62
|
-
|
82
|
+
emits: ['option-hovered', 'option-selected'],
|
63
83
|
props: {
|
64
84
|
value: {
|
65
85
|
required: true
|
@@ -73,7 +93,7 @@ export default {
|
|
73
93
|
},
|
74
94
|
cursorType: {
|
75
95
|
required: false,
|
76
|
-
default: '
|
96
|
+
default: 'pointer'
|
77
97
|
},
|
78
98
|
backgroundColor: {
|
79
99
|
required: false,
|
@@ -85,21 +105,32 @@ export default {
|
|
85
105
|
isDisabled: {
|
86
106
|
required: false,
|
87
107
|
default: false
|
108
|
+
},
|
109
|
+
disabledBgColor: {
|
110
|
+
required: false,
|
111
|
+
default: 'white'
|
112
|
+
},
|
113
|
+
disabledTextColor: {
|
114
|
+
required: false,
|
115
|
+
default: null
|
116
|
+
},
|
117
|
+
padding: {
|
118
|
+
required: false,
|
119
|
+
default: '12px 10px'
|
88
120
|
}
|
89
121
|
},
|
90
122
|
|
91
123
|
components: { optionContainer },
|
92
|
-
|
93
124
|
data() {
|
94
125
|
return {}
|
95
126
|
},
|
96
127
|
methods: {
|
97
|
-
clickHandler() {
|
128
|
+
clickHandler(e) {
|
98
129
|
if (this.isDisabled) {
|
99
130
|
// prevent emitter if the option is disabled
|
100
131
|
return
|
101
132
|
} else {
|
102
|
-
this.$parent.$emit('option-selected', this.value)
|
133
|
+
this.$parent.$emit('option-selected', this.value, e)
|
103
134
|
}
|
104
135
|
},
|
105
136
|
hoverHandler() {
|