@eturnity/eturnity_reusable_components 1.0.28 → 1.0.32
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
package/src/App.vue
CHANGED
|
@@ -83,6 +83,20 @@ export default {
|
|
|
83
83
|
{
|
|
84
84
|
name: "Option 3",
|
|
85
85
|
value: "option_3",
|
|
86
|
+
children: [
|
|
87
|
+
{
|
|
88
|
+
name: "Option 3 Child",
|
|
89
|
+
value: "option_3_child",
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "Option 4 Child",
|
|
93
|
+
value: "option_4_child",
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "Option 5 Child",
|
|
97
|
+
value: "option_5_child",
|
|
98
|
+
},
|
|
99
|
+
],
|
|
86
100
|
},
|
|
87
101
|
{
|
|
88
102
|
name: "Option 4",
|
|
@@ -33,7 +33,7 @@ const Container = styled.div`
|
|
|
33
33
|
margin-bottom: 20px;
|
|
34
34
|
`
|
|
35
35
|
|
|
36
|
-
const inputProps = { isError: Boolean }
|
|
36
|
+
const inputProps = { isError: Boolean, disabled: Boolean }
|
|
37
37
|
const InputContainer = styled("textarea", inputProps)`
|
|
38
38
|
border: ${(props) =>
|
|
39
39
|
props.isError
|
|
@@ -47,6 +47,7 @@ const InputContainer = styled("textarea", inputProps)`
|
|
|
47
47
|
width: 100%;
|
|
48
48
|
max-width: 100%;
|
|
49
49
|
box-sizing: border-box; // to allow width of 100% with padding
|
|
50
|
+
cursor: ${(props) => (props.disabled ? "not-allowed" : "inherit")};
|
|
50
51
|
|
|
51
52
|
&::placeholder {
|
|
52
53
|
color: ${(props) =>
|
|
@@ -5,26 +5,51 @@
|
|
|
5
5
|
<dot-item />
|
|
6
6
|
<dot-item />
|
|
7
7
|
</button-container>
|
|
8
|
-
<
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
:
|
|
12
|
-
|
|
13
|
-
@click="onSelect(item.value)"
|
|
14
|
-
@keyup.enter="onSelect(item.value)"
|
|
15
|
-
@mouseover="onItemHover(index)"
|
|
8
|
+
<dropdown-container v-if="isOpen">
|
|
9
|
+
<children-container
|
|
10
|
+
class="child"
|
|
11
|
+
:isOpen="hoverItem !== null"
|
|
12
|
+
v-if="hoverItem !== null"
|
|
16
13
|
>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
+
"
|
|
21
29
|
>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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>
|
|
28
53
|
</page-container>
|
|
29
54
|
</template>
|
|
30
55
|
|
|
@@ -37,28 +62,55 @@
|
|
|
37
62
|
// />
|
|
38
63
|
// options to pass:
|
|
39
64
|
// listOptions: [
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
//
|
|
65
|
+
// {
|
|
66
|
+
// name: "Option 1",
|
|
67
|
+
// value: "option_1",
|
|
68
|
+
// children: [
|
|
69
|
+
// {
|
|
70
|
+
// name: "Option 1 Child",
|
|
71
|
+
// value: "option_1_child",
|
|
72
|
+
// },
|
|
73
|
+
// {
|
|
74
|
+
// name: "Option 2 Child",
|
|
75
|
+
// value: "option_2_child",
|
|
76
|
+
// },
|
|
77
|
+
// {
|
|
78
|
+
// name: "Option 3 Child",
|
|
79
|
+
// value: "option_3_child",
|
|
80
|
+
// },
|
|
81
|
+
// ],
|
|
82
|
+
// },
|
|
83
|
+
// {
|
|
84
|
+
// name: "Option 2",
|
|
85
|
+
// value: "option_2",
|
|
86
|
+
// },
|
|
87
|
+
// {
|
|
88
|
+
// name: "Option 3",
|
|
89
|
+
// value: "option_3",
|
|
90
|
+
// children: [
|
|
91
|
+
// {
|
|
92
|
+
// name: "Option 3 Child",
|
|
93
|
+
// value: "option_3_child",
|
|
94
|
+
// },
|
|
95
|
+
// {
|
|
96
|
+
// name: "Option 4 Child",
|
|
97
|
+
// value: "option_4_child",
|
|
98
|
+
// },
|
|
99
|
+
// {
|
|
100
|
+
// name: "Option 5 Child",
|
|
101
|
+
// value: "option_5_child",
|
|
102
|
+
// },
|
|
103
|
+
// ],
|
|
104
|
+
// },
|
|
105
|
+
// {
|
|
106
|
+
// name: "Option 4",
|
|
107
|
+
// value: "option_4",
|
|
108
|
+
// },
|
|
109
|
+
// ],
|
|
57
110
|
|
|
58
111
|
import styled from "vue-styled-components"
|
|
59
112
|
|
|
60
113
|
const PageContainer = styled.div`
|
|
61
|
-
position: relative;
|
|
62
114
|
display: grid;
|
|
63
115
|
align-items: center;
|
|
64
116
|
`
|
|
@@ -89,10 +141,15 @@ const DotItem = styled.div`
|
|
|
89
141
|
border-radius: 50%;
|
|
90
142
|
`
|
|
91
143
|
|
|
92
|
-
const
|
|
144
|
+
const DropdownContainer = styled.div`
|
|
93
145
|
z-index: 99;
|
|
94
|
-
position:
|
|
95
|
-
right:
|
|
146
|
+
position: absolute;
|
|
147
|
+
right: 20px;
|
|
148
|
+
display: grid;
|
|
149
|
+
grid-template-columns: auto auto;
|
|
150
|
+
`
|
|
151
|
+
|
|
152
|
+
const OptionsContainer = styled.div`
|
|
96
153
|
border: 1px solid ${(props) => props.theme.colors.grey3};
|
|
97
154
|
display: grid;
|
|
98
155
|
grid-template-columns: 1fr;
|
|
@@ -100,9 +157,9 @@ const OptionsContainer = styled.div`
|
|
|
100
157
|
width: max-content;
|
|
101
158
|
border-radius: 4px;
|
|
102
159
|
background-color: #fff;
|
|
103
|
-
margin-top: 8px;
|
|
104
160
|
max-height: 220px;
|
|
105
161
|
overflow: auto;
|
|
162
|
+
height: max-content;
|
|
106
163
|
`
|
|
107
164
|
|
|
108
165
|
const OptionItem = styled.div`
|
|
@@ -136,19 +193,30 @@ const OptionChild = styled.div`
|
|
|
136
193
|
}
|
|
137
194
|
`
|
|
138
195
|
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
border:
|
|
143
|
-
|
|
196
|
+
const arrowAttrs = { hasChildren: Boolean }
|
|
197
|
+
const ArrowLeft = styled("span", arrowAttrs)`
|
|
198
|
+
border: solid #9f9f9f;
|
|
199
|
+
border-width: 0 1.5px 1.5px 0;
|
|
200
|
+
display: inline-block;
|
|
201
|
+
padding: 3px;
|
|
202
|
+
margin-bottom: 1px;
|
|
203
|
+
transform: rotate(135deg);
|
|
204
|
+
margin-right: 3px;
|
|
205
|
+
visibility: ${(props) => (props.hasChildren ? "visible" : "hidden")};
|
|
206
|
+
`
|
|
207
|
+
|
|
208
|
+
const childAttrs = { isOpen: Boolean }
|
|
209
|
+
const ChildrenContainer = styled("div", childAttrs)`
|
|
210
|
+
border: ${(props) =>
|
|
211
|
+
props.isOpen ? "1px solid" + props.theme.colors.grey3 : "none"};
|
|
144
212
|
display: grid;
|
|
145
213
|
grid-template-columns: 1fr;
|
|
146
214
|
min-width: 200px;
|
|
147
215
|
width: max-content;
|
|
148
216
|
border-radius: 4px;
|
|
149
217
|
background-color: #fff;
|
|
150
|
-
margin-
|
|
151
|
-
|
|
218
|
+
margin-right: -1px;
|
|
219
|
+
height: max-content;
|
|
152
220
|
overflow: auto;
|
|
153
221
|
`
|
|
154
222
|
|
|
@@ -162,6 +230,8 @@ export default {
|
|
|
162
230
|
OptionItem,
|
|
163
231
|
ChildrenContainer,
|
|
164
232
|
OptionChild,
|
|
233
|
+
ArrowLeft,
|
|
234
|
+
DropdownContainer,
|
|
165
235
|
},
|
|
166
236
|
props: {
|
|
167
237
|
options: {
|
|
@@ -172,6 +242,7 @@ export default {
|
|
|
172
242
|
return {
|
|
173
243
|
isOpen: false,
|
|
174
244
|
hoverItem: null,
|
|
245
|
+
childOpen: null,
|
|
175
246
|
}
|
|
176
247
|
},
|
|
177
248
|
methods: {
|
|
@@ -184,11 +255,18 @@ export default {
|
|
|
184
255
|
document.removeEventListener("click", this.clickOutside)
|
|
185
256
|
}
|
|
186
257
|
},
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
this.hoverItem = index
|
|
258
|
+
hasChildren(item) {
|
|
259
|
+
return !!item.children && !!item.children.length
|
|
190
260
|
},
|
|
191
|
-
|
|
261
|
+
onItemHover({ index, item }) {
|
|
262
|
+
this.hoverItem = item.children && item.children.length ? index : null
|
|
263
|
+
this.childOpen =
|
|
264
|
+
item.children && item.children.length ? item.children : null
|
|
265
|
+
},
|
|
266
|
+
onSelect({ value, hasChildren }) {
|
|
267
|
+
if (hasChildren) {
|
|
268
|
+
return
|
|
269
|
+
}
|
|
192
270
|
this.$emit("on-select", value)
|
|
193
271
|
this.isOpen = false
|
|
194
272
|
},
|