@eturnity/eturnity_reusable_components 6.46.3 → 6.46.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "6.46.3",
3
+ "version": "6.46.5",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
@@ -68,7 +68,8 @@ const wrapperAttrs = { fullWidth: Boolean }
68
68
  const TableWrapper = styled('div', wrapperAttrs)`
69
69
  width: ${(props) => (props.fullWidth ? '100%' : 'fit-content')};
70
70
  max-width: 100%;
71
- overflow: visible;
71
+ overflow-x: auto;
72
+ overflow-y: hidden;
72
73
 
73
74
  ::-webkit-scrollbar {
74
75
  height: 5px; //height of the whole scrollbar area
@@ -1,64 +1,65 @@
1
1
  <template>
2
- <page-container @click="toggleButton()">
2
+ <page-container @click="toggleButton()" ref="pageContainer" :activated="isOpen">
3
3
  <button-container ref="dropdownItem">
4
4
  <dot-item />
5
5
  <dot-item />
6
6
  <dot-item />
7
7
  </button-container>
8
8
  <dropdown-container
9
- v-if="isOpen"
10
9
  @click.stop
11
10
  :containerWidth="childOpen ? 440 : 240"
12
11
  ref="dropdownContainer"
13
12
  >
14
- <loading-container v-if="isLoading">
15
- <spinner />
16
- </loading-container>
17
- <children-container
18
- class="child"
19
- :isOpen="hoverItem !== null"
20
- v-if="hoverItem !== null && !isLoading"
21
- >
22
- <option-child
23
- v-for="child in childOpen"
24
- :key="child.value"
25
- @click.stop="
13
+ <template v-if="isOpen">
14
+ <loading-container v-if="isLoading">
15
+ <spinner />
16
+ </loading-container>
17
+ <children-container
18
+ class="child"
19
+ :isOpen="hoverItem !== null"
20
+ v-if="hoverItem !== null && !isLoading"
21
+ >
22
+ <option-child
23
+ v-for="child in childOpen"
24
+ :key="child.value"
25
+ @click.stop="
26
26
  onSelect({
27
27
  item: child,
28
28
  hasChildren: hasChildren(child)
29
29
  })
30
30
  "
31
- @keyup.enter.stop="
31
+ @keyup.enter.stop="
32
32
  onSelect({
33
33
  item: child,
34
34
  hasChildren: hasChildren(child)
35
35
  })
36
36
  "
37
- >
38
- {{ child.name }}
39
- </option-child>
40
- </children-container>
41
- <options-container v-if="!isLoading">
42
- <option-item
43
- v-for="(item, index) in options"
44
- :key="item.value"
45
- tabindex="0"
46
- @click.stop="onSelect({ item: item, hasChildren: hasChildren(item) })"
47
- @keyup.enter="
37
+ >
38
+ {{ child.name }}
39
+ </option-child>
40
+ </children-container>
41
+ <options-container v-if="!isLoading">
42
+ <option-item
43
+ v-for="(item, index) in options"
44
+ :key="item.value"
45
+ tabindex="0"
46
+ @click.stop="onSelect({ item: item, hasChildren: hasChildren(item) })"
47
+ @keyup.enter="
48
48
  onSelect({ item: item, hasChildren: hasChildren(item) })
49
49
  "
50
- @mouseover="onItemHover({ index, item })"
51
- :isDisabled="item.disabled"
52
- >
53
- <arrow-left
54
- :hasChildren="hasChildren(item)"
55
- v-if="hasChildren(item)"
56
- />
57
- <span>
50
+ @mouseover="onItemHover({ index, item })"
51
+ :isDisabled="item.disabled"
52
+ >
53
+ <arrow-left
54
+ :hasChildren="hasChildren(item)"
55
+ v-if="hasChildren(item)"
56
+ />
57
+ <span>
58
58
  {{ item.name }}
59
59
  </span>
60
- </option-item>
61
- </options-container>
60
+ </option-item>
61
+ </options-container>
62
+ </template>
62
63
  </dropdown-container>
63
64
  </page-container>
64
65
  </template>
@@ -122,17 +123,20 @@
122
123
  import styled from 'vue-styled-components'
123
124
  import Spinner from '../spinner'
124
125
 
125
- const PageContainer = styled.div`
126
+ const PageContainerAttrs = {
127
+ activated: Boolean
128
+ }
129
+ const PageContainer = styled('div', PageContainerAttrs)`
126
130
  display: grid;
127
131
  align-items: center;
128
132
  justify-items: center;
129
133
  width: 30px;
130
134
  height: 30px;
131
- position: relative;
135
+ border-radius: 4px;
136
+ background-color: ${(props) => props.activated ? props.theme.colors.grey5 : ''};
132
137
 
133
138
  &:hover {
134
139
  background-color: ${(props) => props.theme.colors.grey5};
135
- border-radius: 4px;
136
140
  }
137
141
  `
138
142
 
@@ -162,10 +166,6 @@ const dropdownAttrs = {
162
166
  }
163
167
  const DropdownContainer = styled('div', dropdownAttrs)`
164
168
  z-index: 99;
165
- height: 200px;
166
- top: 0;
167
- right: 27px;
168
-
169
169
  position: absolute;
170
170
  display: grid;
171
171
  grid-template-columns: auto auto;
@@ -175,8 +175,8 @@ const LoadingContainer = styled.div`
175
175
  border: 1px solid ${(props) => props.theme.colors.grey3};
176
176
  display: grid;
177
177
  grid-template-columns: 1fr;
178
- min-width: 200px;
179
- height: 200px;
178
+ min-width: 100px;
179
+ height: 100px;
180
180
  align-items: center;
181
181
  justify-items: center;
182
182
  background: #fff;
@@ -257,6 +257,9 @@ const ChildrenContainer = styled('div', childAttrs)`
257
257
  height: max-content;
258
258
  max-height: 200px;
259
259
  overflow: auto;
260
+ position: absolute;
261
+ top: 0;
262
+ right: 100%;
260
263
  `
261
264
 
262
265
  export default {
@@ -296,11 +299,65 @@ export default {
296
299
  this.isOpen = !this.isOpen
297
300
 
298
301
  if (this.isOpen) {
302
+ this.setContextMenuPosition()
303
+ window.addEventListener('resize', this.toggleButton)
299
304
  document.addEventListener('click', this.clickOutside)
300
305
  } else {
306
+ window.removeEventListener('resize', this.toggleButton)
301
307
  document.removeEventListener('click', this.clickOutside)
302
308
  }
303
309
  },
310
+ setContextMenuPosition() {
311
+ const contextMenu = this.$refs.dropdownContainer.$el
312
+ const button = this.$refs.pageContainer.$el
313
+ const rectButton = button.getBoundingClientRect()
314
+ const relativeParent = this.findRelativeParent(contextMenu)
315
+ const rectRelativeParent = relativeParent.getBoundingClientRect()
316
+
317
+ const positionArray = this.determineElementQuarter(button, rectButton)
318
+ contextMenu.style.transform = ''
319
+ if (positionArray.includes('left')) {
320
+ contextMenu.style.left = (rectButton.right - rectRelativeParent.left + 5) + 'px'
321
+ } else {
322
+ contextMenu.style.left = (rectButton.left - rectRelativeParent.left - 5) + 'px'
323
+ contextMenu.style.transform = 'translateX(-100%)'
324
+ }
325
+ if (positionArray.includes('top')) {
326
+ contextMenu.style.top = (rectButton.top - rectRelativeParent.top) + 'px'
327
+ } else {
328
+ contextMenu.style.top = (rectButton.bottom - rectRelativeParent.top) + 'px'
329
+ contextMenu.style.transform += ' translateY(-100%)'
330
+ }
331
+ },
332
+ findRelativeParent(element) {
333
+ while (element.parentElement) {
334
+ if (window.getComputedStyle(element.parentElement).position === 'relative') {
335
+ return element.parentElement
336
+ }
337
+ element = element.parentElement
338
+ }
339
+ return null
340
+ },
341
+ determineElementQuarter(element, rect) {
342
+ const viewportWidth = window.innerWidth
343
+ const viewportHeight = window.innerHeight
344
+
345
+ const horizontalMidpoint = viewportWidth / 2
346
+ const verticalMidpoint = viewportHeight / 2
347
+
348
+ const isLeft = rect.left + rect.width / 2 < horizontalMidpoint
349
+ const isTop = rect.top + rect.height / 2 < verticalMidpoint
350
+
351
+ if (isLeft && isTop) {
352
+ return ['left', 'top']
353
+ } else if (isLeft && !isTop) {
354
+ return ['left', 'bottom']
355
+ } else if (!isLeft && isTop) {
356
+ return ['right', 'top']
357
+ } else {
358
+ return ['right', 'bottom']
359
+ }
360
+ },
304
361
  hasChildren(item) {
305
362
  return !!item.children && !!item.children.length
306
363
  },