@eturnity/eturnity_reusable_components 1.0.30 → 1.0.34

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.34",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
@@ -87,7 +87,7 @@ const Container = styled("label", containerAttrs)`
87
87
  &:after {
88
88
  content: "";
89
89
  position: absolute;
90
- display: none;
90
+ display: ${(props) => (props.isChecked ? "block" : "none")};
91
91
  }
92
92
  }
93
93
 
@@ -124,10 +124,6 @@ const InputCheckbox = styled.input`
124
124
  cursor: pointer;
125
125
  height: 0;
126
126
  width: 0;
127
-
128
- &:checked ~ .checkmark:after {
129
- display: block;
130
- }
131
127
  `
132
128
 
133
129
  export default {
@@ -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,49 @@
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
+ item: child,
20
+ hasChildren: hasChildren(child),
21
+ })
22
+ "
23
+ @keyup.enter.stop="
24
+ onSelect({
25
+ item: child,
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="onSelect({ item: item, hasChildren: hasChildren(item) })"
39
+ @keyup.enter="
40
+ onSelect({ item: item, hasChildren: hasChildren(item) })
41
+ "
42
+ @mouseover="onItemHover({ index, item })"
43
+ >
44
+ <arrow-left :hasChildren="hasChildren(item)" />
45
+ <span>
46
+ {{ item.name }}
47
+ </span>
48
+ </option-item>
49
+ </options-container>
50
+ </dropdown-container>
42
51
  </page-container>
43
52
  </template>
44
53
 
@@ -100,7 +109,6 @@
100
109
  import styled from "vue-styled-components"
101
110
 
102
111
  const PageContainer = styled.div`
103
- position: relative;
104
112
  display: grid;
105
113
  align-items: center;
106
114
  `
@@ -131,10 +139,15 @@ const DotItem = styled.div`
131
139
  border-radius: 50%;
132
140
  `
133
141
 
134
- const OptionsContainer = styled.div`
142
+ const DropdownContainer = styled.div`
135
143
  z-index: 99;
136
- position: fixed;
137
- right: 60px;
144
+ position: absolute;
145
+ right: 20px;
146
+ display: grid;
147
+ grid-template-columns: auto auto;
148
+ `
149
+
150
+ const OptionsContainer = styled.div`
138
151
  border: 1px solid ${(props) => props.theme.colors.grey3};
139
152
  display: grid;
140
153
  grid-template-columns: 1fr;
@@ -142,9 +155,9 @@ const OptionsContainer = styled.div`
142
155
  width: max-content;
143
156
  border-radius: 4px;
144
157
  background-color: #fff;
145
- margin-top: 8px;
146
158
  max-height: 220px;
147
159
  overflow: auto;
160
+ height: max-content;
148
161
  `
149
162
 
150
163
  const OptionItem = styled.div`
@@ -190,19 +203,18 @@ const ArrowLeft = styled("span", arrowAttrs)`
190
203
  visibility: ${(props) => (props.hasChildren ? "visible" : "hidden")};
191
204
  `
192
205
 
193
- const ChildrenContainer = styled.div`
194
- position: fixed;
195
- right: 262px;
196
- border: 1px solid ${(props) => props.theme.colors.grey3};
206
+ const childAttrs = { isOpen: Boolean }
207
+ const ChildrenContainer = styled("div", childAttrs)`
208
+ border: ${(props) =>
209
+ props.isOpen ? "1px solid" + props.theme.colors.grey3 : "none"};
197
210
  display: grid;
198
211
  grid-template-columns: 1fr;
199
212
  min-width: 200px;
200
213
  width: max-content;
201
214
  border-radius: 4px;
202
215
  background-color: #fff;
203
- margin-top: -28px;
204
216
  margin-right: -1px;
205
- max-height: 220px;
217
+ height: max-content;
206
218
  overflow: auto;
207
219
  `
208
220
 
@@ -217,6 +229,7 @@ export default {
217
229
  ChildrenContainer,
218
230
  OptionChild,
219
231
  ArrowLeft,
232
+ DropdownContainer,
220
233
  },
221
234
  props: {
222
235
  options: {
@@ -227,6 +240,7 @@ export default {
227
240
  return {
228
241
  isOpen: false,
229
242
  hoverItem: null,
243
+ childOpen: null,
230
244
  }
231
245
  },
232
246
  methods: {
@@ -242,14 +256,16 @@ export default {
242
256
  hasChildren(item) {
243
257
  return !!item.children && !!item.children.length
244
258
  },
245
- onItemHover(index) {
246
- this.hoverItem = index
259
+ onItemHover({ index, item }) {
260
+ this.hoverItem = item.children && item.children.length ? index : null
261
+ this.childOpen =
262
+ item.children && item.children.length ? item.children : null
247
263
  },
248
- onSelect({ value, hasChildren }) {
264
+ onSelect({ item, hasChildren }) {
249
265
  if (hasChildren) {
250
266
  return
251
267
  }
252
- this.$emit("on-select", value)
268
+ this.$emit("on-select", item)
253
269
  this.isOpen = false
254
270
  },
255
271
  clickOutside(event) {