@eturnity/eturnity_reusable_components 7.12.6-EPDM-7951.6 → 7.12.7--EPDM-5518.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.
Files changed (51) hide show
  1. package/.storybook/preview.js +1 -1
  2. package/package.json +23 -18
  3. package/src/App.vue +2 -2
  4. package/src/components/addNewButton/index.vue +3 -5
  5. package/src/components/buttons/buttonIcon/index.vue +1 -1
  6. package/src/components/buttons/closeButton/index.vue +1 -1
  7. package/src/components/buttons/mainButton/index.vue +1 -6
  8. package/src/components/deleteIcon/DeleteIcon.stories.js +7 -7
  9. package/src/components/deleteIcon/index.vue +21 -25
  10. package/src/components/draggableInputHandle/index.vue +25 -24
  11. package/src/components/dropdown/index.vue +110 -129
  12. package/src/components/errorMessage/index.vue +1 -1
  13. package/src/components/filter/filterSettings.vue +97 -55
  14. package/src/components/filter/index.vue +3 -3
  15. package/src/components/filter/parentDropdown.vue +2 -2
  16. package/src/components/icon/iconCollection.vue +2 -2
  17. package/src/components/icon/index.vue +69 -76
  18. package/src/components/iconWrapper/index.vue +4 -1
  19. package/src/components/infoCard/index.vue +3 -2
  20. package/src/components/infoText/index.vue +1 -1
  21. package/src/components/inputs/checkbox/index.vue +16 -24
  22. package/src/components/inputs/inputNumber/index.vue +10 -7
  23. package/src/components/inputs/inputNumberQuestion/index.vue +1 -1
  24. package/src/components/inputs/inputText/index.vue +4 -4
  25. package/src/components/inputs/radioButton/index.vue +1 -1
  26. package/src/components/inputs/searchInput/index.vue +8 -7
  27. package/src/components/inputs/select/index.vue +69 -197
  28. package/src/components/inputs/select/option/index.vue +5 -5
  29. package/src/components/inputs/slider/index.vue +16 -16
  30. package/src/components/inputs/switchField/index.vue +2 -2
  31. package/src/components/inputs/textAreaInput/index.vue +2 -2
  32. package/src/components/inputs/toggle/index.vue +2 -2
  33. package/src/components/label/index.vue +31 -27
  34. package/src/components/markerItem/index.vue +96 -0
  35. package/src/components/modals/modal/index.vue +6 -2
  36. package/src/components/navigationTabs/index.vue +20 -27
  37. package/src/components/pageSubtitle/index.vue +1 -1
  38. package/src/components/pageTitle/index.vue +4 -4
  39. package/src/components/pagination/index.vue +3 -5
  40. package/src/components/progressBar/index.vue +1 -1
  41. package/src/components/projectMarker/index.vue +8 -11
  42. package/src/components/selectedOptions/index.vue +145 -0
  43. package/src/components/sideMenu/index.vue +1 -1
  44. package/src/components/spinner/index.vue +11 -6
  45. package/src/components/tableDropdown/index.vue +26 -21
  46. package/src/components/tables/mainTable/exampleNested.vue +1 -1
  47. package/src/components/tables/mainTable/index.vue +9 -10
  48. package/src/components/tables/viewTable/index.vue +2 -2
  49. package/src/components/threeDots/index.vue +1 -1
  50. package/src/components/videoThumbnail/index.vue +100 -95
  51. package/src/main.js +11 -4
@@ -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 'vue3-styled-components'
104
+ import styled from 'vue-styled-components'
104
105
  import {
105
106
  stringToNumber,
106
107
  numberToString
@@ -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(event) {
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(event) {
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 (event.target.value === '') {
559
+ if (value === '') {
557
560
  this.$emit('on-input', '')
558
561
  }
559
562
  let evaluatedVal
560
563
  try {
561
- evaluatedVal = this.onEvaluateCode(event)
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(e)
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({
@@ -44,7 +44,7 @@
44
44
  // number_max_allowed: 10,
45
45
  // unit_short_name: "cm",
46
46
  // },
47
- import styled from "vue3-styled-components"
47
+ import styled from "vue-styled-components"
48
48
  import {
49
49
  stringToNumber,
50
50
  numberToString,
@@ -66,7 +66,7 @@
66
66
  </template>
67
67
 
68
68
  <script>
69
- import styled from 'vue3-styled-components'
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'
@@ -328,12 +328,12 @@ export default {
328
328
  }
329
329
  },
330
330
  methods: {
331
- onEnterPress(event){
331
+ onEnterPress() {
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.target.value)
335
+ onChangeHandler($event) {
336
+ this.$emit('input-change', $event)
337
337
  },
338
338
  onInputBlur($event) {
339
339
  this.$emit('input-blur', $event.target.value)
@@ -60,7 +60,7 @@
60
60
  // { label: 'Button 4', value: 'button_4', disabled: true }
61
61
  // ]
62
62
 
63
- import styled from 'vue3-styled-components'
63
+ import styled from 'vue-styled-components'
64
64
  import Modal from '../../modals/modal'
65
65
  import InfoText from '../../infoText'
66
66
 
@@ -13,7 +13,10 @@
13
13
  :hasFocus="hasFocus"
14
14
  :data-id="dataId"
15
15
  />
16
- <SearchIconSvg class="search-icn" />
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>
@@ -30,8 +33,7 @@
30
33
  // :isFilter="true" // to set the height at 30px
31
34
  // data-id="test-data-id"
32
35
  // />
33
- import styled from 'vue3-styled-components'
34
- import SearchIconSvg from '../../../assets/icons/search_icon_black.svg'
36
+ import styled from 'vue-styled-components'
35
37
 
36
38
  const inputAttrs = {
37
39
  isDisabled: Boolean,
@@ -66,7 +68,7 @@ const InputContainer = styled('input', inputAttrs)`
66
68
  const InputWrapper = styled.span`
67
69
  position: relative;
68
70
 
69
- svg {
71
+ img {
70
72
  position: absolute;
71
73
  right: 10px;
72
74
  top: 50%;
@@ -79,8 +81,7 @@ export default {
79
81
  components: {
80
82
  InputContainer,
81
83
  InputWrapper,
82
- Container,
83
- SearchIconSvg
84
+ Container
84
85
  },
85
86
  props: {
86
87
  value: {
@@ -113,7 +114,7 @@ export default {
113
114
  },
114
115
  methods: {
115
116
  onChangeHandler(event) {
116
- this.$emit('on-change', event.target.value)
117
+ this.$emit('on-change', event)
117
118
  },
118
119
  focusInputElement() {
119
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
- :hasNoPadding="isSearchBarVisible || !hasSelectButtonPadding"
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,12 +64,14 @@
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
73
71
  :selectWidth="selectWidth"
74
72
  :paddingLeft="paddingLeft"
73
+ :noMaxWidth="noMaxWidth"
74
+ :showBorder="showBorder"
75
75
  >
76
76
  <slot name="selector" :selectedValue="selectedValue"></slot>
77
77
  </selector>
@@ -98,33 +98,26 @@
98
98
  />
99
99
  </Caret>
100
100
  </selectButton>
101
- <DropdownWrapper ref="dropdownWrapperRef">
102
- <Teleport to="#portal-target">
103
- <selectDropdown
104
- ref="dropdown"
105
- v-show="isSelectDropdownShown"
106
- :dropdownPosition="dropdownPosition"
107
- :hoveredIndex="hoveredIndex"
108
- :hoveredValue="hoveredValue"
109
- :isActive="isActive"
110
- :optionWidth="getOptionWidth"
111
- :hoveredBgColor="
112
- colorMode == 'dark' ? '#000000' : dropdownBgColor
113
- "
114
- :bgColor="
115
- dropdownBgColor || colorMode == 'dark' ? 'black' : 'white'
116
- "
117
- :fontColor="
118
- dropdownFontColor || colorMode == 'dark' ? 'white' : 'black'
119
- "
120
- :fontSize="fontSize"
121
- :selectedValue="selectedValue"
122
- @option-selected="optionSelected"
123
- @option-hovered="optionHovered"
124
- >
125
- <slot name="dropdown"></slot>
126
- </selectDropdown>
127
- </Teleport>
101
+ <DropdownWrapper>
102
+ <selectDropdown
103
+ ref="dropdown"
104
+ v-show="isDropdownOpen"
105
+ :hoveredIndex="hoveredIndex"
106
+ :hoveredValue="hoveredValue"
107
+ :isActive="isActive"
108
+ :optionWidth="optionWidth"
109
+ :hoveredBgColor="colorMode == 'dark' ? '#000000' : dropdownBgColor"
110
+ :bgColor="colorMode == 'dark' ? 'black' : dropdownBgColor"
111
+ :fontColor="
112
+ dropdownFontColor || colorMode == 'dark' ? 'white' : 'black'
113
+ "
114
+ :selectedValue="selectedValue"
115
+ @option-selected="optionSelected"
116
+ @option-hovered="optionHovered"
117
+ @mouseleave="optionLeave"
118
+ >
119
+ <slot name="dropdown"></slot>
120
+ </selectDropdown>
128
121
  </DropdownWrapper>
129
122
  </select-button-wrapper>
130
123
  </input-wrapper>
@@ -139,9 +132,8 @@
139
132
  // optionWidth="50%"
140
133
  // label="that is a label"
141
134
  // alignItems="vertical"
142
- // label-data-id="test-label-data-id"
135
+ // label-data-id="test-label0data-id"
143
136
  // data-id="test-data-id"
144
- // :hasSelectButtonPadding="false"
145
137
  // >
146
138
  // <template #selector="{selectedValue}">
147
139
  // value selected: {{selectedValue}}
@@ -154,8 +146,7 @@
154
146
  // </template>
155
147
  // </Select>
156
148
 
157
- import { Teleport } from 'vue'
158
- import styled from 'vue3-styled-components'
149
+ import styled from 'vue-styled-components'
159
150
  import InfoText from '../../infoText'
160
151
  import icon from '../../icon'
161
152
  import inputText from '../inputText'
@@ -171,14 +162,22 @@ const Caret = styled.div`
171
162
  width: ${CARET_WIDTH};
172
163
  min-width: ${CARET_WIDTH};
173
164
  height: 100%;
174
- align-items: center;
165
+ align-items: stretch;
175
166
  cursor: pointer;
176
167
  margin-left: auto;
177
168
  `
178
169
 
179
- const Selector = styled('div', { selectWidth: String, paddingLeft: String })`
180
- width: ${(props) =>
181
- `calc(${props.selectWidth} - (${CARET_WIDTH} + ${props.paddingLeft} + (${BORDER_WIDTH} * 2)))`};
170
+ const selectorProps = {
171
+ selectWidth: String,
172
+ paddingLeft: String,
173
+ showBorder: Boolean,
174
+ noMaxWidth: Boolean
175
+ }
176
+ const Selector = styled('div', selectorProps)`
177
+ max-width: ${(props) =>
178
+ props.noMaxWidth
179
+ ? '100%'
180
+ : `calc(${props.selectWidth} - (${CARET_WIDTH} + ${props.paddingLeft} + (${BORDER_WIDTH} * 2)))`};
182
181
  white-space: nowrap;
183
182
  text-overflow: ellipsis;
184
183
  overflow: hidden;
@@ -196,10 +195,7 @@ const InputLabel = styled('div', labelAttrs)`
196
195
  const optionalLabel = styled.span`
197
196
  font-weight: 300;
198
197
  `
199
- const inputProps = {
200
- selectWidth: String,
201
- optionWidth: String
202
- }
198
+ const inputProps = { selectWidth: String, optionWidth: String }
203
199
  const Container = styled('div', inputProps)`
204
200
  width: ${(props) => props.selectWidth};
205
201
  position: relative;
@@ -226,10 +222,9 @@ const selectButtonAttrs = {
226
222
  hasError: Boolean,
227
223
  disabled: Boolean,
228
224
  selectHeight: String,
229
- selectWidth: String,
230
225
  height: String,
231
226
  selectMinHeight: String,
232
- hasNoPadding: Boolean,
227
+ isSearchBarVisible: Boolean,
233
228
  showBorder: Boolean,
234
229
  paddingLeft: String
235
230
  }
@@ -237,9 +232,8 @@ const selectButton = styled('div', selectButtonAttrs)`
237
232
  position: relative;
238
233
  box-sizing: border-box;
239
234
  border-radius: 4px;
240
- max-width: ${(props) => (props.selectWidth ? props.selectWidth : '100%')};
241
235
  ${(props) =>
242
- props.hasNoPadding ? '' : `padding-left: ${props.paddingLeft}`};
236
+ props.isSearchBarVisible ? '' : `padding-left: ${props.paddingLeft}`};
243
237
  text-align: left;
244
238
  min-height: ${(props) =>
245
239
  props.selectHeight
@@ -251,7 +245,7 @@ const selectButton = styled('div', selectButtonAttrs)`
251
245
  : '36px'};
252
246
  display: flex;
253
247
  align-items: center;
254
- height: ${(props) => props.selectHeight};
248
+ max-height: ${(props) => props.selectHeight};
255
249
  ${({ showBorder, theme, hasError }) =>
256
250
  showBorder &&
257
251
  `
@@ -283,17 +277,14 @@ const selectDropdownAttrs = {
283
277
  fontColor: String,
284
278
  optionWidth: String,
285
279
  hoveredIndex: Number,
286
- fontSize: String,
287
- dropdownPosition: Object,
288
280
  hoveredValue: Number | String,
289
281
  selectedValue: Number | String
290
282
  }
291
283
  const selectDropdown = styled('div', selectDropdownAttrs)`
292
284
  box-sizing: border-box;
293
- z-index: ${(props) => (props.isActive ? '2' : '99999')};
285
+ z-index: ${(props) => (props.isActive ? '2' : '1')};
294
286
  position: absolute;
295
- top: ${(props) => props.dropdownPosition?.top}px;
296
- left: ${(props) => props.dropdownPosition?.left}px;
287
+ top: 5px;
297
288
  border: ${BORDER_WIDTH} solid ${(props) => props.theme.colors.grey4};
298
289
  border-radius: 4px;
299
290
  display: flex;
@@ -301,7 +292,7 @@ const selectDropdown = styled('div', selectDropdownAttrs)`
301
292
  align-items: flex-start;
302
293
  padding: 0px;
303
294
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
304
- width: ${(props) => props.optionWidth};
295
+ width: ${(props) => (props.optionWidth ? props.optionWidth : '100%')};
305
296
  background-color: ${(props) =>
306
297
  props.theme.colors[props.bgColor]
307
298
  ? props.theme.colors[props.bgColor]
@@ -318,9 +309,7 @@ const selectDropdown = styled('div', selectDropdownAttrs)`
318
309
  ? props.theme.colors[props.hoveredBgColor]
319
310
  : props.hoveredBgColor};
320
311
  }
321
- font-size: ${(props) => props.fontSize};
322
312
  `
323
- selectDropdown.emits = ['option-hovered', 'option-selected']
324
313
  const DropdownWrapper = styled('div')`
325
314
  position: relative;
326
315
  `
@@ -333,10 +322,6 @@ const InputWrapper = styled('div', inputAttrs)`
333
322
  grid-template-columns: ${(props) =>
334
323
  props.alignItems === 'vertical' || !props.hasLabel ? '1fr' : 'auto 1fr'};
335
324
  `
336
-
337
- const DROPDOWN_HEIGHT_OFFSET = 4
338
- const DROPDOWN_TOP_OFFSET = 21
339
-
340
325
  export default {
341
326
  name: 'RCselect',
342
327
 
@@ -448,11 +433,11 @@ export default {
448
433
  type: String,
449
434
  default: ''
450
435
  },
451
- hasSelectButtonPadding: {
436
+ isDraggable: {
452
437
  type: Boolean,
453
- default: true
438
+ default: false
454
439
  },
455
- isDraggable: {
440
+ noMaxWidth: {
456
441
  type: Boolean,
457
442
  default: false
458
443
  }
@@ -473,7 +458,6 @@ export default {
473
458
  Caret,
474
459
  Selector,
475
460
  inputText,
476
- Teleport,
477
461
  draggableInputHandle
478
462
  },
479
463
 
@@ -485,38 +469,23 @@ export default {
485
469
  isActive: false,
486
470
  textSearch: '',
487
471
  hoveredIndex: 0,
488
- isClickOutsideActive: false,
489
- dropdownPosition: {
490
- left: null,
491
- top: null
492
- },
493
- dropdownWidth: null,
494
- hoveredValue: null
472
+ hoveredValue: null,
473
+ isClickOutsideActive: false
495
474
  }
496
475
  },
497
476
  mounted() {
498
- this.observeDropdownHeight()
499
- this.observeSelectWidth()
500
- window.addEventListener('resize', this.handleSetDropdownOffet)
501
- },
502
- beforeMount() {
503
477
  this.selectedValue = this.value
504
478
  document.addEventListener('click', this.clickOutside)
505
- this.getDropdownPosition()
506
- window.removeEventListener('resize', this.handleSetDropdownOffet)
507
- if (this.dropdownResizeObserver) this.dropdownResizeObserver.disconnect()
508
- if (this.selectResizeObserver) this.selectResizeObserver.disconnect()
509
479
  },
510
- unmounted() {
480
+ beforeDestroy() {
511
481
  document.removeEventListener('click', this.clickOutside)
512
482
  },
513
483
  methods: {
514
484
  focus() {
515
485
  this.isActive = true
516
486
  },
517
- blur(e) {
487
+ blur() {
518
488
  this.isActive = false
519
- this.$emit('blur', e)
520
489
  },
521
490
  toggleDropdown() {
522
491
  this.isDropdownOpen = !this.isDropdownOpen
@@ -532,9 +501,6 @@ export default {
532
501
  this.blur()
533
502
  this.isDropdownOpen = false
534
503
  },
535
- clearSearch() {
536
- this.textSearch = ''
537
- },
538
504
  optionSelected(e) {
539
505
  this.selectedValue = e
540
506
  this.closeDropdown()
@@ -563,15 +529,15 @@ export default {
563
529
  searchChange(value) {
564
530
  this.textSearch = value
565
531
  this.$emit('search-change', value)
566
- const dropdownChildren = [...this.$refs.dropdown.$el.children]
567
- dropdownChildren.forEach((el) => {
568
- if (!el.textContent.toLowerCase().includes(value.toLowerCase())) {
569
- el.style.display = 'none'
570
-
571
- return
572
- }
573
- el.style.display = 'inherit'
574
- })
532
+ this.$refs.dropdown.$children
533
+ .map((component) => component.$el)
534
+ .forEach((el) => {
535
+ if (!el.textContent.toLowerCase().includes(value.toLowerCase())) {
536
+ el.style.display = 'none'
537
+ } else {
538
+ el.style.display = 'grid'
539
+ }
540
+ })
575
541
  },
576
542
  clickOutside(event) {
577
543
  const dropdownRef = this.$refs.dropdown
@@ -581,7 +547,6 @@ export default {
581
547
  if (
582
548
  this.$refs.select.$el == event.target ||
583
549
  this.$refs.select.$el.contains(event.target) ||
584
- event.target.id === 'more-button' ||
585
550
  event.target.parentNode === dropdownRef.$el
586
551
  ) {
587
552
  return
@@ -595,92 +560,13 @@ export default {
595
560
  } else if (e.key == 'ArrowUp') {
596
561
  this.onArrowPress(-1)
597
562
  } else if (e.key == 'Enter') {
598
- const optionHoveredComponent = [...this.$refs.dropdown.$el.children][
599
- (this.hoveredIndex - 1 + this.optionLength) % this.optionLength
600
- ]
563
+ const optionHoveredComponent =
564
+ this.$refs.dropdown.$children[
565
+ (this.hoveredIndex - 1 + this.optionLength) % this.optionLength
566
+ ]
601
567
  this.optionSelected(optionHoveredComponent.$el.dataset.value)
602
568
  }
603
569
  },
604
- // If some part of the dropdown menu is outside viewport of the bottom of the screen,
605
- // we need to offset it and display it at the top of the select dropdown instead
606
- async getDropdownPosition() {
607
- if (
608
- !this.$refs.dropdownWrapperRef ||
609
- !this.$refs.select ||
610
- !this.$refs.dropdown
611
- ) {
612
- return
613
- }
614
- await this.$nextTick()
615
- const isDisplayedAtBottom = await this.generateDropdownPosition()
616
- await this.$nextTick()
617
- // If the dropdown menu is going to be displayed at the bottom,
618
- // we need reverify its position after a dom update (nextTick)
619
- if (isDisplayedAtBottom) this.generateDropdownPosition()
620
- },
621
- async generateDropdownPosition() {
622
- const isDropdownNotCompletelyVisible =
623
- await this.isBottomOfDropdownOutOfViewport()
624
- const dropdownWrapperEl = this.$refs.dropdownWrapperRef.$el
625
- const selectButtonHeight = this.$refs.select.$el.clientHeight
626
- const dropdownHeight = this.$refs.dropdown.$el.clientHeight
627
- const dropdownWrapperRelativeHeight =
628
- dropdownWrapperEl.getBoundingClientRect().top +
629
- window.scrollY +
630
- DROPDOWN_HEIGHT_OFFSET
631
-
632
- const top = isDropdownNotCompletelyVisible
633
- ? dropdownWrapperRelativeHeight
634
- : dropdownWrapperRelativeHeight -
635
- dropdownHeight -
636
- selectButtonHeight -
637
- DROPDOWN_TOP_OFFSET
638
- const left = this.dropdownPosition.left
639
- ? this.dropdownPosition.left
640
- : dropdownWrapperEl.getBoundingClientRect().left + window.scrollX
641
-
642
- this.dropdownPosition = { left: Math.floor(left), top: Math.floor(top) }
643
-
644
- return isDropdownNotCompletelyVisible
645
- },
646
- async isBottomOfDropdownOutOfViewport() {
647
- if (!this.$refs.dropdown) {
648
- return false
649
- }
650
- await this.$nextTick()
651
- const rect = this.$refs.dropdown.$el.getBoundingClientRect()
652
- const windowHeight =
653
- window.innerHeight || document.documentElement.clientHeight
654
-
655
- // using Math.floor because the offsets may contain decimals we are not going to consider here
656
- return Math.floor(rect.top) + Math.floor(rect.height) <= windowHeight
657
- },
658
- observeDropdownHeight() {
659
- if (!this.$refs.dropdown) return
660
- this.dropdownResizeObserver = new ResizeObserver(() => {
661
- this.$nextTick(() => this.getDropdownPosition())
662
- })
663
- this.dropdownResizeObserver.observe(this.$refs.dropdown.$el)
664
- },
665
- handleSetDropdownOffet() {
666
- if (!this.$refs.select) return
667
- this.dropdownPosition.left = Math.floor(
668
- this.$refs.select.$el.getBoundingClientRect().left
669
- )
670
- this.getDropdownWidth()
671
- },
672
- observeSelectWidth() {
673
- if (!this.$refs.select) return
674
- this.selectResizeObserver = new ResizeObserver(() =>
675
- this.$nextTick(() => this.getDropdownWidth())
676
- )
677
- this.selectResizeObserver.observe(this.$refs.dropdown.$el)
678
- },
679
- async getDropdownWidth() {
680
- if (!this.$refs.select) return
681
- await this.$nextTick()
682
- this.dropdownWidth = `${this.$refs.select.$el.clientWidth}px`
683
- },
684
570
  onArrowPress(dir) {
685
571
  let newHoveredElem
686
572
  const currentHoveredElem = this.$refs.dropdown.$el.querySelector(
@@ -712,34 +598,20 @@ export default {
712
598
  return 0
713
599
  },
714
600
  isSearchBarVisible() {
715
- return this.isSearchable && this.optionLength >= 5 && this.isDropdownOpen
716
- },
717
- getOptionWidth() {
718
- if (this.optionWidth) return this.optionWidth
719
-
720
- return this.dropdownWidth
721
- },
722
- isSelectDropdownShown() {
723
- return (
724
- this.isDropdownOpen &&
725
- this.dropdownPosition.left !== null &&
726
- (!this.isSearchable || this.isSearchable)
727
- )
601
+ return this.isSearchable && this.isDropdownOpen
728
602
  }
729
603
  },
730
604
  watch: {
731
605
  value(val) {
732
606
  this.selectedValue = val
733
607
  },
734
- async isDropdownOpen(val) {
608
+ isDropdownOpen(val) {
609
+ this.$emit('is-dropdown-open', val)
735
610
  if (val) {
736
611
  setTimeout(() => {
737
612
  this.isClickOutsideActive = true
738
613
  }, 10)
739
- await this.$nextTick()
740
- this.handleSetDropdownOffet()
741
614
  } else {
742
- this.dropdownPosition.left = null
743
615
  setTimeout(() => {
744
616
  this.isClickOutsideActive = false
745
617
  }, 10)
@@ -22,7 +22,7 @@
22
22
  <script>
23
23
  // import selectButton from './selectButton'
24
24
  // import selectDropdown from './selectDropDown'
25
- import styled from 'vue3-styled-components'
25
+ import styled from 'vue-styled-components'
26
26
  const optionProps = {
27
27
  isDisabled: Boolean,
28
28
  hoveredBgColor: String,
@@ -59,7 +59,7 @@ const optionContainer = styled('div', optionProps)`
59
59
 
60
60
  export default {
61
61
  name: 'RCoption',
62
- emits: ['option-hovered', 'option-selected'],
62
+
63
63
  props: {
64
64
  value: {
65
65
  required: true
@@ -73,7 +73,7 @@ export default {
73
73
  },
74
74
  cursorType: {
75
75
  required: false,
76
- default: 'pointer'
76
+ default: 'cursor'
77
77
  },
78
78
  backgroundColor: {
79
79
  required: false,
@@ -94,12 +94,12 @@ export default {
94
94
  return {}
95
95
  },
96
96
  methods: {
97
- clickHandler(e) {
97
+ clickHandler() {
98
98
  if (this.isDisabled) {
99
99
  // prevent emitter if the option is disabled
100
100
  return
101
101
  } else {
102
- this.$parent.$emit('option-selected', this.value, e)
102
+ this.$parent.$emit('option-selected', this.value)
103
103
  }
104
104
  },
105
105
  hoverHandler() {