@eturnity/eturnity_reusable_components 1.0.30 → 1.0.31

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": "1.0.30",
3
+ "version": "1.0.31",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
@@ -133,6 +133,8 @@ const TableContainer = styled.table`
133
133
  }
134
134
 
135
135
  tr {
136
+ position: relative;
137
+
136
138
  &.disabled {
137
139
  cursor: not-allowed;
138
140
  }
@@ -5,40 +5,51 @@
5
5
  <dot-item />
6
6
  <dot-item />
7
7
  </button-container>
8
- <options-container v-if="isOpen">
9
- <option-item
10
- v-for="(item, index) in options"
11
- :key="item.value"
12
- tabindex="0"
13
- @click="onSelect({ value: item.value, hasChildren: hasChildren(item) })"
14
- @keyup.enter="
15
- onSelect({ value: item.value, hasChildren: hasChildren(item) })
16
- "
17
- @mouseover="onItemHover(index)"
8
+ <dropdown-container v-if="isOpen">
9
+ <children-container
10
+ class="child"
11
+ :isOpen="hoverItem !== null"
12
+ v-if="hoverItem !== null"
18
13
  >
19
- <arrow-left :hasChildren="hasChildren(item)" />
20
- <span>
21
- {{ item.name }}
22
- </span>
23
- <children-container
24
- class="child"
25
- v-if="hasChildren(item) && hoverItem === index"
14
+ <option-child
15
+ v-for="child in childOpen"
16
+ :key="child.value"
17
+ @click.stop="
18
+ onSelect({
19
+ value: child.value,
20
+ hasChildren: hasChildren(child),
21
+ })
22
+ "
23
+ @keyup.enter.stop="
24
+ onSelect({
25
+ value: child.value,
26
+ hasChildren: hasChildren(child),
27
+ })
28
+ "
26
29
  >
27
- <option-child
28
- v-for="child in item.children"
29
- :key="child.value"
30
- @click.stop="
31
- onSelect({ value: child.value, hasChildren: hasChildren(child) })
32
- "
33
- @keyup.enter.stop="
34
- onSelect({ value: child.value, hasChildren: hasChildren(child) })
35
- "
36
- >
37
- {{ child.name }}
38
- </option-child>
39
- </children-container>
40
- </option-item>
41
- </options-container>
30
+ {{ child.name }}
31
+ </option-child>
32
+ </children-container>
33
+ <options-container>
34
+ <option-item
35
+ v-for="(item, index) in options"
36
+ :key="item.value"
37
+ tabindex="0"
38
+ @click="
39
+ onSelect({ value: item.value, hasChildren: hasChildren(item) })
40
+ "
41
+ @keyup.enter="
42
+ onSelect({ value: item.value, hasChildren: hasChildren(item) })
43
+ "
44
+ @mouseover="onItemHover({ index, item })"
45
+ >
46
+ <arrow-left :hasChildren="hasChildren(item)" />
47
+ <span>
48
+ {{ item.name }}
49
+ </span>
50
+ </option-item>
51
+ </options-container>
52
+ </dropdown-container>
42
53
  </page-container>
43
54
  </template>
44
55
 
@@ -100,7 +111,6 @@
100
111
  import styled from "vue-styled-components"
101
112
 
102
113
  const PageContainer = styled.div`
103
- position: relative;
104
114
  display: grid;
105
115
  align-items: center;
106
116
  `
@@ -131,10 +141,15 @@ const DotItem = styled.div`
131
141
  border-radius: 50%;
132
142
  `
133
143
 
134
- const OptionsContainer = styled.div`
144
+ const DropdownContainer = styled.div`
135
145
  z-index: 99;
136
- position: fixed;
137
- right: 60px;
146
+ position: absolute;
147
+ right: 20px;
148
+ display: grid;
149
+ grid-template-columns: auto auto;
150
+ `
151
+
152
+ const OptionsContainer = styled.div`
138
153
  border: 1px solid ${(props) => props.theme.colors.grey3};
139
154
  display: grid;
140
155
  grid-template-columns: 1fr;
@@ -142,7 +157,6 @@ const OptionsContainer = styled.div`
142
157
  width: max-content;
143
158
  border-radius: 4px;
144
159
  background-color: #fff;
145
- margin-top: 8px;
146
160
  max-height: 220px;
147
161
  overflow: auto;
148
162
  `
@@ -190,19 +204,18 @@ const ArrowLeft = styled("span", arrowAttrs)`
190
204
  visibility: ${(props) => (props.hasChildren ? "visible" : "hidden")};
191
205
  `
192
206
 
193
- const ChildrenContainer = styled.div`
194
- position: fixed;
195
- right: 262px;
196
- border: 1px solid ${(props) => props.theme.colors.grey3};
207
+ const childAttrs = { isOpen: Boolean }
208
+ const ChildrenContainer = styled("div", childAttrs)`
209
+ border: ${(props) =>
210
+ props.isOpen ? "1px solid" + props.theme.colors.grey3 : "none"};
197
211
  display: grid;
198
212
  grid-template-columns: 1fr;
199
213
  min-width: 200px;
200
214
  width: max-content;
201
215
  border-radius: 4px;
202
216
  background-color: #fff;
203
- margin-top: -28px;
204
217
  margin-right: -1px;
205
- max-height: 220px;
218
+ height: max-content;
206
219
  overflow: auto;
207
220
  `
208
221
 
@@ -217,6 +230,7 @@ export default {
217
230
  ChildrenContainer,
218
231
  OptionChild,
219
232
  ArrowLeft,
233
+ DropdownContainer,
220
234
  },
221
235
  props: {
222
236
  options: {
@@ -227,6 +241,7 @@ export default {
227
241
  return {
228
242
  isOpen: false,
229
243
  hoverItem: null,
244
+ childOpen: null,
230
245
  }
231
246
  },
232
247
  methods: {
@@ -242,8 +257,10 @@ export default {
242
257
  hasChildren(item) {
243
258
  return !!item.children && !!item.children.length
244
259
  },
245
- onItemHover(index) {
246
- this.hoverItem = index
260
+ onItemHover({ index, item }) {
261
+ this.hoverItem = item.children && item.children.length ? index : null
262
+ this.childOpen =
263
+ item.children && item.children.length ? item.children : null
247
264
  },
248
265
  onSelect({ value, hasChildren }) {
249
266
  if (hasChildren) {