@eturnity/eturnity_reusable_components 7.24.3-EPDM-11320.2 → 7.24.3-qa-elisee-7.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/.prettierrc +6 -8
  2. package/package.json +21 -9
  3. package/public/favicon.ico +0 -0
  4. package/public/index.html +17 -0
  5. package/src/App.vue +78 -79
  6. package/src/assets/svgIcons/adjust_roof.svg +6 -0
  7. package/src/assets/svgIcons/copy.svg +10 -0
  8. package/src/assets/theme.js +3 -3
  9. package/src/components/addNewButton/AddNewButton.stories.js +2 -2
  10. package/src/components/addNewButton/index.vue +51 -48
  11. package/src/components/banner/actionBanner/index.vue +55 -54
  12. package/src/components/banner/banner/banner.stories.js +5 -5
  13. package/src/components/banner/banner/index.vue +159 -159
  14. package/src/components/banner/infoBanner/index.vue +53 -41
  15. package/src/components/buttons/buttonIcon/index.vue +122 -125
  16. package/src/components/buttons/closeButton/CloseButton.stories.js +3 -3
  17. package/src/components/buttons/closeButton/index.vue +49 -49
  18. package/src/components/buttons/mainButton/index.vue +119 -119
  19. package/src/components/card/index.vue +70 -70
  20. package/src/components/collapsableInfoText/index.vue +94 -96
  21. package/src/components/deleteIcon/DeleteIcon.stories.js +4 -4
  22. package/src/components/deleteIcon/index.vue +54 -54
  23. package/src/components/draggableInputHandle/index.vue +37 -37
  24. package/src/components/dropdown/Dropdown.stories.js +10 -9
  25. package/src/components/dropdown/index.vue +106 -106
  26. package/src/components/errorMessage/index.vue +52 -52
  27. package/src/components/filter/filterSettings.vue +433 -439
  28. package/src/components/filter/index.vue +135 -135
  29. package/src/components/filter/parentDropdown.vue +73 -73
  30. package/src/components/icon/Icons.stories.js +7 -7
  31. package/src/components/icon/iconCollection.vue +53 -53
  32. package/src/components/icon/index.vue +121 -121
  33. package/src/components/iconWrapper/index.vue +156 -156
  34. package/src/components/infoCard/index.vue +26 -26
  35. package/src/components/infoText/index.vue +132 -133
  36. package/src/components/inputs/checkbox/Checkbox.stories.js +8 -8
  37. package/src/components/inputs/checkbox/index.vue +180 -190
  38. package/src/components/inputs/inputNumber/InputNumber.stories.js +41 -41
  39. package/src/components/inputs/inputNumber/index.vue +644 -647
  40. package/src/components/inputs/inputNumberQuestion/index.vue +182 -185
  41. package/src/components/inputs/inputText/InputText.stories.js +22 -22
  42. package/src/components/inputs/inputText/index.vue +336 -337
  43. package/src/components/inputs/radioButton/RadioButton.stories.js +16 -16
  44. package/src/components/inputs/radioButton/index.vue +219 -221
  45. package/src/components/inputs/searchInput/SearchInput.stories.js +8 -8
  46. package/src/components/inputs/searchInput/index.vue +126 -126
  47. package/src/components/inputs/select/index.vue +776 -778
  48. package/src/components/inputs/select/option/index.vue +124 -124
  49. package/src/components/inputs/select/select.stories.js +32 -31
  50. package/src/components/inputs/slider/index.vue +99 -99
  51. package/src/components/inputs/switchField/index.vue +222 -220
  52. package/src/components/inputs/textAreaInput/TextAreaInput.stories.js +57 -57
  53. package/src/components/inputs/textAreaInput/index.vue +173 -171
  54. package/src/components/inputs/toggle/Toggle.stories.js +14 -14
  55. package/src/components/inputs/toggle/index.vue +217 -214
  56. package/src/components/label/index.vue +82 -82
  57. package/src/components/markerItem/index.vue +66 -68
  58. package/src/components/modals/actionModal/index.vue +54 -54
  59. package/src/components/modals/infoModal/index.vue +36 -39
  60. package/src/components/modals/modal/index.vue +134 -134
  61. package/src/components/modals/modal/modal.stories.js +5 -5
  62. package/src/components/navigationTabs/index.vue +94 -96
  63. package/src/components/pageSubtitle/index.vue +49 -55
  64. package/src/components/pageTitle/index.vue +56 -56
  65. package/src/components/pagination/index.vue +89 -92
  66. package/src/components/progressBar/index.vue +107 -107
  67. package/src/components/projectMarker/index.vue +244 -246
  68. package/src/components/rangeSlider/Slider.vue +465 -491
  69. package/src/components/rangeSlider/index.vue +410 -410
  70. package/src/components/rangeSlider/utils/dom.js +5 -5
  71. package/src/components/selectedOptions/index.vue +119 -119
  72. package/src/components/sideMenu/index.vue +199 -199
  73. package/src/components/spinner/index.vue +57 -57
  74. package/src/components/tableDropdown/index.vue +520 -520
  75. package/src/components/tables/mainTable/index.vue +362 -366
  76. package/src/components/tables/viewTable/index.vue +171 -171
  77. package/src/components/threeDots/index.vue +334 -340
  78. package/src/components/videoThumbnail/index.vue +86 -86
  79. package/src/components/videoThumbnail/videoThumbnail.stories.js +16 -14
  80. package/src/helpers/numberConverter.js +2 -2
  81. package/src/helpers/translateLang.js +9 -9
  82. package/src/mixins/inputValidations.js +5 -5
  83. package/.eslintrc.js +0 -184
@@ -1,55 +1,53 @@
1
1
  <template>
2
- <PageContainer
2
+ <page-container
3
+ @click="toggleButton()"
3
4
  ref="pageContainer"
4
5
  :activated="isOpen"
5
- @click="toggleButton()"
6
6
  >
7
- <ButtonContainer ref="dropdownItem">
8
- <DotItem />
9
- <DotItem />
10
- <DotItem />
11
- </ButtonContainer>
12
- <DropdownContainer
13
- ref="dropdownContainer"
14
- :container-width="childOpen ? 440 : 240"
7
+ <button-container ref="dropdownItem">
8
+ <dot-item />
9
+ <dot-item />
10
+ <dot-item />
11
+ </button-container>
12
+ <dropdown-container
15
13
  @click.stop
14
+ :containerWidth="childOpen ? 440 : 240"
15
+ ref="dropdownContainer"
16
16
  >
17
17
  <template v-if="isOpen">
18
- <LoadingContainer v-if="isLoading">
19
- <Spinner />
20
- </LoadingContainer>
21
- <ChildrenContainer
22
- v-if="hoverItem !== null && !isLoading"
18
+ <loading-container v-if="isLoading">
19
+ <spinner />
20
+ </loading-container>
21
+ <children-container
23
22
  class="child"
24
- :is-open="hoverItem !== null"
23
+ :isOpen="hoverItem !== null"
24
+ v-if="hoverItem !== null && !isLoading"
25
25
  >
26
- <OptionChild
26
+ <option-child
27
27
  v-for="child in childOpen"
28
28
  :key="child.value"
29
29
  @click.stop="
30
30
  onSelect({
31
31
  item: child,
32
- hasChildren: hasChildren(child),
32
+ hasChildren: hasChildren(child)
33
33
  })
34
34
  "
35
35
  @keyup.enter.stop="
36
36
  onSelect({
37
37
  item: child,
38
- hasChildren: hasChildren(child),
38
+ hasChildren: hasChildren(child)
39
39
  })
40
40
  "
41
41
  >
42
42
  {{ child.name }}
43
- </OptionChild>
44
- </ChildrenContainer>
45
- <OptionsContainer v-if="!isLoading" :text-wrap="textWrap">
46
- <OptionItem
43
+ </option-child>
44
+ </children-container>
45
+ <options-container v-if="!isLoading" :textWrap="textWrap">
46
+ <option-item
47
47
  v-for="(item, index) in options"
48
48
  :key="item.value"
49
49
  :data-id="item.dataId"
50
- :is-disabled="item.disabled"
51
50
  tabindex="0"
52
- :title="item.title"
53
51
  @click.stop="
54
52
  onSelect({ item: item, hasChildren: hasChildren(item) })
55
53
  "
@@ -57,357 +55,353 @@
57
55
  onSelect({ item: item, hasChildren: hasChildren(item) })
58
56
  "
59
57
  @mouseover="onItemHover({ index, item })"
58
+ :isDisabled="item.disabled"
59
+ :title="item.title"
60
60
  >
61
- <ArrowLeft
61
+ <arrow-left
62
+ :hasChildren="hasChildren(item)"
62
63
  v-if="hasChildren(item)"
63
- :has-children="hasChildren(item)"
64
64
  />
65
65
  <span>
66
66
  {{ item.name }}
67
67
  </span>
68
- </OptionItem>
69
- </OptionsContainer>
68
+ </option-item>
69
+ </options-container>
70
70
  </template>
71
- </DropdownContainer>
72
- </PageContainer>
71
+ </dropdown-container>
72
+ </page-container>
73
73
  </template>
74
74
 
75
75
  <script>
76
- // import ThreeDots from "@eturnity/eturnity_reusable_components/src/components/threeDots"
77
- // To use:
78
- // <three-dots
79
- // :isLoading="true"
80
- // :options="listOptions"
81
- // @on-click="onClick($event)"
82
- // @on-select="onSelect($event)"
83
- // />
84
- // options to pass:
85
- // listOptions: [
86
- // {
87
- // name: "Option 1",
88
- // value: "option_1",
89
- // children: [
90
- // {
91
- // name: "Option 1 Child",
92
- // value: "option_1_child",
93
- // },
94
- // {
95
- // name: "Option 2 Child",
96
- // value: "option_2_child",
97
- // },
98
- // {
99
- // name: "Option 3 Child",
100
- // value: "option_3_child",
101
- // },
102
- // ],
103
- // },
104
- // {
105
- // name: "Option 2",
106
- // value: "option_2",
107
- // },
108
- // {
109
- // name: "Option 3",
110
- // value: "option_3",
111
- // children: [
112
- // {
113
- // name: "Option 3 Child",
114
- // value: "option_3_child",
115
- // },
116
- // {
117
- // name: "Option 4 Child",
118
- // value: "option_4_child",
119
- // },
120
- // {
121
- // name: "Option 5 Child",
122
- // value: "option_5_child",
123
- // },
124
- // ],
125
- // },
126
- // {
127
- // name: "Option 4",
128
- // value: "option_4",
129
- // },
130
- // ],
76
+ // import ThreeDots from "@eturnity/eturnity_reusable_components/src/components/threeDots"
77
+ // To use:
78
+ // <three-dots
79
+ // :isLoading="true"
80
+ // :options="listOptions"
81
+ // @on-click="onClick($event)"
82
+ // @on-select="onSelect($event)"
83
+ // />
84
+ // options to pass:
85
+ // listOptions: [
86
+ // {
87
+ // name: "Option 1",
88
+ // value: "option_1",
89
+ // children: [
90
+ // {
91
+ // name: "Option 1 Child",
92
+ // value: "option_1_child",
93
+ // },
94
+ // {
95
+ // name: "Option 2 Child",
96
+ // value: "option_2_child",
97
+ // },
98
+ // {
99
+ // name: "Option 3 Child",
100
+ // value: "option_3_child",
101
+ // },
102
+ // ],
103
+ // },
104
+ // {
105
+ // name: "Option 2",
106
+ // value: "option_2",
107
+ // },
108
+ // {
109
+ // name: "Option 3",
110
+ // value: "option_3",
111
+ // children: [
112
+ // {
113
+ // name: "Option 3 Child",
114
+ // value: "option_3_child",
115
+ // },
116
+ // {
117
+ // name: "Option 4 Child",
118
+ // value: "option_4_child",
119
+ // },
120
+ // {
121
+ // name: "Option 5 Child",
122
+ // value: "option_5_child",
123
+ // },
124
+ // ],
125
+ // },
126
+ // {
127
+ // name: "Option 4",
128
+ // value: "option_4",
129
+ // },
130
+ // ],
131
131
 
132
- import styled from 'vue3-styled-components'
133
- import Spinner from '../spinner'
132
+ import styled from 'vue3-styled-components'
133
+ import Spinner from '../spinner'
134
134
 
135
- const PageContainerAttrs = {
136
- activated: Boolean,
137
- }
138
- const PageContainer = styled('div', PageContainerAttrs)`
139
- display: grid;
140
- align-items: center;
141
- justify-items: center;
142
- width: 30px;
143
- height: 30px;
144
- border-radius: 4px;
145
- background-color: ${(props) =>
146
- props.activated ? props.theme.colors.grey5 : ''};
135
+ const PageContainerAttrs = {
136
+ activated: Boolean
137
+ }
138
+ const PageContainer = styled('div', PageContainerAttrs)`
139
+ display: grid;
140
+ align-items: center;
141
+ justify-items: center;
142
+ width: 30px;
143
+ height: 30px;
144
+ border-radius: 4px;
145
+ background-color: ${(props) =>
146
+ props.activated ? props.theme.colors.grey5 : ''};
147
147
 
148
- &:hover {
149
- background-color: ${(props) => props.theme.colors.grey5};
150
- }
151
- `
148
+ &:hover {
149
+ background-color: ${(props) => props.theme.colors.grey5};
150
+ }
151
+ `
152
152
 
153
- const ButtonContainer = styled.div`
154
- display: flex;
155
- flex-direction: column;
156
- align-items: center;
157
- justify-content: center;
158
- padding: 5px;
159
- cursor: pointer;
153
+ const ButtonContainer = styled.div`
154
+ display: flex;
155
+ flex-direction: column;
156
+ align-items: center;
157
+ justify-content: center;
158
+ padding: 5px;
159
+ cursor: pointer;
160
160
 
161
- div {
162
- // This is the dot color
163
- background-color: #263238;
164
- }
165
- `
161
+ div {
162
+ // This is the dot color
163
+ background-color: #263238;
164
+ }
165
+ `
166
166
 
167
- const DotItem = styled.div`
168
- width: 4px;
169
- height: 4px;
170
- margin: 1px;
171
- border-radius: 50%;
172
- `
167
+ const DotItem = styled.div`
168
+ width: 4px;
169
+ height: 4px;
170
+ margin: 1px;
171
+ border-radius: 50%;
172
+ `
173
173
 
174
- const dropdownAttrs = {
175
- containerWidth: Number,
176
- }
177
- const DropdownContainer = styled('div', dropdownAttrs)`
178
- z-index: 99;
179
- position: absolute;
180
- display: grid;
181
- grid-template-columns: auto auto;
182
- `
174
+ const dropdownAttrs = {
175
+ containerWidth: Number
176
+ }
177
+ const DropdownContainer = styled('div', dropdownAttrs)`
178
+ z-index: 99;
179
+ position: absolute;
180
+ display: grid;
181
+ grid-template-columns: auto auto;
182
+ `
183
183
 
184
- const LoadingContainer = styled.div`
185
- border: 1px solid ${(props) => props.theme.colors.grey3};
186
- display: grid;
187
- grid-template-columns: 1fr;
188
- min-width: 100px;
189
- height: 100px;
190
- align-items: center;
191
- justify-items: center;
192
- background: #fff;
193
- `
184
+ const LoadingContainer = styled.div`
185
+ border: 1px solid ${(props) => props.theme.colors.grey3};
186
+ display: grid;
187
+ grid-template-columns: 1fr;
188
+ min-width: 100px;
189
+ height: 100px;
190
+ align-items: center;
191
+ justify-items: center;
192
+ background: #fff;
193
+ `
194
194
 
195
- const OptionsContainerAttrs = { textWrap: Boolean }
196
- const OptionsContainer = styled('div', OptionsContainerAttrs)`
197
- border: 1px solid ${(props) => props.theme.colors.grey3};
198
- display: grid;
199
- grid-template-columns: 1fr;
200
- ${(props) => (props.textWrap ? 'width: 220px' : 'width: max-content')};
201
- border-radius: 4px;
202
- background-color: #fff;
203
- max-height: 220px;
204
- overflow: auto;
205
- height: max-content;
206
- ${(props) =>
207
- props.textWrap ? 'white-space: normal' : 'white-space: nowrap'};
208
- `
195
+ const OptionsContainerAttrs = { textWrap: Boolean }
196
+ const OptionsContainer = styled('div', OptionsContainerAttrs)`
197
+ border: 1px solid ${(props) => props.theme.colors.grey3};
198
+ display: grid;
199
+ grid-template-columns: 1fr;
200
+ ${(props) => props.textWrap ? 'width: 220px' : 'width: max-content' };
201
+ border-radius: 4px;
202
+ background-color: #fff;
203
+ max-height: 220px;
204
+ overflow: auto;
205
+ height: max-content;
206
+ ${(props) => props.textWrap ? 'white-space: normal' : 'white-space: nowrap'};
207
+ `
209
208
 
210
- const optionAttrs = { isDisabled: Boolean }
211
- const OptionItem = styled('div', optionAttrs)`
212
- padding: 12px;
213
- cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'pointer')};
214
- font-size: 13px;
215
- position: relative;
216
- ${(props) =>
217
- props.isDisabled
218
- ? `background-color: ${props.theme.colors.grey5}!important`
219
- : ''};
220
- ${(props) =>
221
- props.isDisabled ? `color: ${props.theme.colors.grey2}` : ''};
209
+ const optionAttrs = { isDisabled: Boolean }
210
+ const OptionItem = styled('div', optionAttrs)`
211
+ padding: 12px;
212
+ cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'pointer')};
213
+ font-size: 13px;
214
+ position: relative;
215
+ ${(props) => (props.isDisabled ? `background-color: ${ props.theme.colors.grey5 }!important` : '')};
216
+ ${(props) => (props.isDisabled ? `color: ${ props.theme.colors.grey2 }` : '')};
222
217
 
223
- &:hover {
224
- background-color: #ebeef4;
225
- }
218
+ &:hover {
219
+ background-color: #ebeef4;
220
+ }
226
221
 
227
- &:focus-visible {
228
- outline: none;
229
- background-color: #ebeef4;
230
- }
231
- `
232
- const OptionChild = styled.div`
233
- padding: 12px;
234
- cursor: pointer;
235
- font-size: 13px;
236
- position: relative;
222
+ &:focus-visible {
223
+ outline: none;
224
+ background-color: #ebeef4;
225
+ }
226
+ `
227
+ const OptionChild = styled.div`
228
+ padding: 12px;
229
+ cursor: pointer;
230
+ font-size: 13px;
231
+ position: relative;
237
232
 
238
- &:hover {
239
- background-color: #ebeef4;
240
- }
233
+ &:hover {
234
+ background-color: #ebeef4;
235
+ }
241
236
 
242
- &:focus-visible {
243
- outline: none;
244
- background-color: #ebeef4;
245
- }
246
- `
237
+ &:focus-visible {
238
+ outline: none;
239
+ background-color: #ebeef4;
240
+ }
241
+ `
247
242
 
248
- const arrowAttrs = { hasChildren: Boolean }
249
- const ArrowLeft = styled('span', arrowAttrs)`
250
- border: solid #9f9f9f;
251
- border-width: 0 1.5px 1.5px 0;
252
- display: inline-block;
253
- padding: 3px;
254
- margin-bottom: 1px;
255
- transform: rotate(135deg);
256
- margin-right: 3px;
257
- visibility: ${(props) => (props.hasChildren ? 'visible' : 'hidden')};
258
- `
243
+ const arrowAttrs = { hasChildren: Boolean }
244
+ const ArrowLeft = styled('span', arrowAttrs)`
245
+ border: solid #9f9f9f;
246
+ border-width: 0 1.5px 1.5px 0;
247
+ display: inline-block;
248
+ padding: 3px;
249
+ margin-bottom: 1px;
250
+ transform: rotate(135deg);
251
+ margin-right: 3px;
252
+ visibility: ${(props) => (props.hasChildren ? 'visible' : 'hidden')};
253
+ `
259
254
 
260
- const childAttrs = { isOpen: Boolean }
261
- const ChildrenContainer = styled('div', childAttrs)`
262
- border: ${(props) =>
263
- props.isOpen ? '1px solid' + props.theme.colors.grey3 : 'none'};
264
- display: grid;
265
- grid-template-columns: 1fr;
266
- min-width: 200px;
267
- max-width: 200px;
268
- white-space: normal;
269
- width: max-content;
270
- border-radius: 4px;
271
- background-color: #fff;
272
- margin-right: -1px;
273
- height: max-content;
274
- max-height: 200px;
275
- overflow: auto;
276
- position: absolute;
277
- top: 0;
278
- right: 100%;
279
- `
255
+ const childAttrs = { isOpen: Boolean }
256
+ const ChildrenContainer = styled('div', childAttrs)`
257
+ border: ${(props) =>
258
+ props.isOpen ? '1px solid' + props.theme.colors.grey3 : 'none'};
259
+ display: grid;
260
+ grid-template-columns: 1fr;
261
+ min-width: 200px;
262
+ max-width: 200px;
263
+ white-space: normal;
264
+ width: max-content;
265
+ border-radius: 4px;
266
+ background-color: #fff;
267
+ margin-right: -1px;
268
+ height: max-content;
269
+ max-height: 200px;
270
+ overflow: auto;
271
+ position: absolute;
272
+ top: 0;
273
+ right: 100%;
274
+ `
280
275
 
281
- export default {
282
- name: 'ThreeDots',
283
- components: {
284
- PageContainer,
285
- ButtonContainer,
286
- DotItem,
287
- OptionsContainer,
288
- OptionItem,
289
- ChildrenContainer,
290
- OptionChild,
291
- ArrowLeft,
292
- DropdownContainer,
293
- Spinner,
294
- LoadingContainer,
276
+ export default {
277
+ name: 'three-dots',
278
+ components: {
279
+ PageContainer,
280
+ ButtonContainer,
281
+ DotItem,
282
+ OptionsContainer,
283
+ OptionItem,
284
+ ChildrenContainer,
285
+ OptionChild,
286
+ ArrowLeft,
287
+ DropdownContainer,
288
+ Spinner,
289
+ LoadingContainer
290
+ },
291
+ props: {
292
+ options: {
293
+ required: true
295
294
  },
296
- props: {
297
- options: {
298
- required: true,
299
- },
300
- isLoading: {
301
- required: false,
302
- default: false,
303
- },
304
- textWrap: {
305
- required: false,
306
- default: true,
307
- },
295
+ isLoading: {
296
+ required: false,
297
+ default: false
308
298
  },
309
- data() {
310
- return {
311
- isOpen: false,
312
- hoverItem: null,
313
- childOpen: null,
314
- containerWidth: 16,
299
+ textWrap: {
300
+ required: false,
301
+ default: true
302
+ }
303
+ },
304
+ data() {
305
+ return {
306
+ isOpen: false,
307
+ hoverItem: null,
308
+ childOpen: null,
309
+ containerWidth: 16
310
+ }
311
+ },
312
+ methods: {
313
+ toggleButton() {
314
+ this.isOpen = !this.isOpen
315
+
316
+ if (this.isOpen) {
317
+ this.setContextMenuPosition()
318
+ window.addEventListener('resize', this.toggleButton)
319
+ document.addEventListener('click', this.clickOutside)
320
+ } else {
321
+ window.removeEventListener('resize', this.toggleButton)
322
+ document.removeEventListener('click', this.clickOutside)
315
323
  }
316
324
  },
317
- methods: {
318
- toggleButton() {
319
- this.isOpen = !this.isOpen
325
+ setContextMenuPosition() {
326
+ const contextMenu = this.$refs.dropdownContainer.$el
327
+ const button = this.$refs.pageContainer.$el
328
+ const rectButton = button.getBoundingClientRect()
329
+ const relativeParent = this.findRelativeParent(contextMenu)
330
+ const rectRelativeParent = relativeParent.getBoundingClientRect()
320
331
 
321
- if (this.isOpen) {
322
- this.setContextMenuPosition()
323
- window.addEventListener('resize', this.toggleButton)
324
- document.addEventListener('click', this.clickOutside)
325
- } else {
326
- window.removeEventListener('resize', this.toggleButton)
327
- document.removeEventListener('click', this.clickOutside)
328
- }
329
- },
330
- setContextMenuPosition() {
331
- const contextMenu = this.$refs.dropdownContainer.$el
332
- const button = this.$refs.pageContainer.$el
333
- const rectButton = button.getBoundingClientRect()
334
- const relativeParent = this.findRelativeParent(contextMenu)
335
- const rectRelativeParent = relativeParent.getBoundingClientRect()
336
-
337
- const positionArray = this.determineElementQuarter(button, rectButton)
338
- contextMenu.style.transform = ''
339
- if (positionArray.includes('left')) {
340
- contextMenu.style.left =
341
- rectButton.right - rectRelativeParent.left + 5 + 'px'
342
- } else {
343
- contextMenu.style.left =
344
- rectButton.left - rectRelativeParent.left - 5 + 'px'
345
- contextMenu.style.transform = 'translateX(-100%)'
346
- }
347
- if (positionArray.includes('top')) {
348
- contextMenu.style.top = rectButton.top - rectRelativeParent.top + 'px'
349
- } else {
350
- contextMenu.style.top =
351
- rectButton.bottom - rectRelativeParent.top + 'px'
352
- contextMenu.style.transform += ' translateY(-100%)'
353
- }
354
- },
355
- findRelativeParent(element) {
356
- while (element.parentElement) {
357
- if (
358
- window.getComputedStyle(element.parentElement).position ===
359
- 'relative' ||
360
- window.getComputedStyle(element.parentElement).position ===
361
- 'absolute'
362
- ) {
363
- return element.parentElement
364
- }
365
- element = element.parentElement
332
+ const positionArray = this.determineElementQuarter(button, rectButton)
333
+ contextMenu.style.transform = ''
334
+ if (positionArray.includes('left')) {
335
+ contextMenu.style.left =
336
+ rectButton.right - rectRelativeParent.left + 5 + 'px'
337
+ } else {
338
+ contextMenu.style.left =
339
+ rectButton.left - rectRelativeParent.left - 5 + 'px'
340
+ contextMenu.style.transform = 'translateX(-100%)'
341
+ }
342
+ if (positionArray.includes('top')) {
343
+ contextMenu.style.top = rectButton.top - rectRelativeParent.top + 'px'
344
+ } else {
345
+ contextMenu.style.top =
346
+ rectButton.bottom - rectRelativeParent.top + 'px'
347
+ contextMenu.style.transform += ' translateY(-100%)'
348
+ }
349
+ },
350
+ findRelativeParent(element) {
351
+ while (element.parentElement) {
352
+ if (
353
+ window.getComputedStyle(element.parentElement).position ===
354
+ 'relative' ||
355
+ window.getComputedStyle(element.parentElement).position === 'absolute'
356
+ ) {
357
+ return element.parentElement
366
358
  }
367
- return null
368
- },
369
- determineElementQuarter(element, rect) {
370
- const viewportWidth = window.innerWidth
371
- const viewportHeight = window.innerHeight
359
+ element = element.parentElement
360
+ }
361
+ return null
362
+ },
363
+ determineElementQuarter(element, rect) {
364
+ const viewportWidth = window.innerWidth
365
+ const viewportHeight = window.innerHeight
372
366
 
373
- const horizontalMidpoint = viewportWidth / 2
374
- const verticalMidpoint = viewportHeight / 2
367
+ const horizontalMidpoint = viewportWidth / 2
368
+ const verticalMidpoint = viewportHeight / 2
375
369
 
376
- const isLeft = rect.left + rect.width / 2 < horizontalMidpoint
377
- const isTop = rect.top + rect.height / 2 < verticalMidpoint
370
+ const isLeft = rect.left + rect.width / 2 < horizontalMidpoint
371
+ const isTop = rect.top + rect.height / 2 < verticalMidpoint
378
372
 
379
- if (isLeft && isTop) {
380
- return ['left', 'top']
381
- } else if (isLeft && !isTop) {
382
- return ['left', 'bottom']
383
- } else if (!isLeft && isTop) {
384
- return ['right', 'top']
385
- } else {
386
- return ['right', 'bottom']
387
- }
388
- },
389
- hasChildren(item) {
390
- return !!item.children && !!item.children.length
391
- },
392
- onItemHover({ index, item }) {
393
- this.hoverItem = item.children && item.children.length ? index : null
394
- this.childOpen =
395
- item.children && item.children.length ? item.children : null
396
- },
397
- onSelect({ item, hasChildren }) {
398
- if (hasChildren || item.disabled) {
399
- this.$emit('on-click', item)
400
- return
401
- }
402
- this.$emit('on-select', item)
403
- this.isOpen = false
404
- },
405
- clickOutside(event) {
406
- if (this.$el.contains(event.target) || !this.isOpen) {
407
- return
408
- }
409
- this.toggleButton()
410
- },
373
+ if (isLeft && isTop) {
374
+ return ['left', 'top']
375
+ } else if (isLeft && !isTop) {
376
+ return ['left', 'bottom']
377
+ } else if (!isLeft && isTop) {
378
+ return ['right', 'top']
379
+ } else {
380
+ return ['right', 'bottom']
381
+ }
382
+ },
383
+ hasChildren(item) {
384
+ return !!item.children && !!item.children.length
411
385
  },
386
+ onItemHover({ index, item }) {
387
+ this.hoverItem = item.children && item.children.length ? index : null
388
+ this.childOpen =
389
+ item.children && item.children.length ? item.children : null
390
+ },
391
+ onSelect({ item, hasChildren }) {
392
+ if (hasChildren || item.disabled) {
393
+ this.$emit('on-click', item)
394
+ return
395
+ }
396
+ this.$emit('on-select', item)
397
+ this.isOpen = false
398
+ },
399
+ clickOutside(event) {
400
+ if (this.$el.contains(event.target) || !this.isOpen) {
401
+ return
402
+ }
403
+ this.toggleButton()
404
+ }
412
405
  }
406
+ }
413
407
  </script>