@everchron/ec-shards 3.4.2 → 3.4.4
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/dist/ec-shards.common.js +110 -35
- package/dist/ec-shards.common.js.map +1 -1
- package/dist/ec-shards.css +1 -1
- package/dist/ec-shards.umd.js +110 -35
- package/dist/ec-shards.umd.js.map +1 -1
- package/dist/ec-shards.umd.min.js +1 -1
- package/dist/ec-shards.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/assets/.DS_Store +0 -0
- package/src/components/select/select.vue +34 -3
- package/src/stories/select/select.stories.js +14 -1
package/package.json
CHANGED
package/src/assets/.DS_Store
CHANGED
|
Binary file
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="ecs-form-select" :class="[sizeClass, typeClass, disabled ? `disabled` : null]">
|
|
3
|
-
<select
|
|
3
|
+
<select ref="select"
|
|
4
|
+
@change="onChange"
|
|
4
5
|
@focus="$emit('focus', $event)"
|
|
5
6
|
@blur="$emit('blur', $event)"
|
|
6
7
|
v-bind="{ id, name, disabled, required }"
|
|
@@ -36,16 +37,23 @@ export default {
|
|
|
36
37
|
type: Boolean,
|
|
37
38
|
default: false
|
|
38
39
|
},
|
|
40
|
+
/** Adds a preselected, disabled <option> to the select which can serve as a placeholder. */
|
|
39
41
|
placeholder: {
|
|
40
42
|
type: String
|
|
41
43
|
},
|
|
44
|
+
/** Sets the `id` attribute. */
|
|
42
45
|
id: String,
|
|
43
|
-
name
|
|
46
|
+
/** Sets the `name` attribute. */
|
|
47
|
+
name: String,
|
|
48
|
+
/** Allows to programmatically select a specific option item via it's value. */
|
|
49
|
+
value: String
|
|
44
50
|
},
|
|
45
51
|
|
|
46
52
|
data() {
|
|
47
53
|
return {
|
|
48
|
-
hasPlaceholder: false
|
|
54
|
+
hasPlaceholder: false,
|
|
55
|
+
currentValue: this.value || '',
|
|
56
|
+
setValue: this.value || ''
|
|
49
57
|
}
|
|
50
58
|
},
|
|
51
59
|
|
|
@@ -66,6 +74,29 @@ export default {
|
|
|
66
74
|
mounted: function () {
|
|
67
75
|
if (this.placeholder && this.placeholder !== '')
|
|
68
76
|
this.hasPlaceholder = true
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
methods: {
|
|
80
|
+
onChange(event) {
|
|
81
|
+
this.currentValue = event.target.value;
|
|
82
|
+
this.hasPlaceholder = false
|
|
83
|
+
this.$emit('change', event)
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
watch: {
|
|
88
|
+
value: function(newValue) {
|
|
89
|
+
const select = this.$refs.select;
|
|
90
|
+
|
|
91
|
+
const option = Array.from(select.options).find((option) => option.value === newValue);
|
|
92
|
+
if (option) {
|
|
93
|
+
option.selected = true
|
|
94
|
+
if (newValue !== this.currentValue) {
|
|
95
|
+
this.currentValue = newValue
|
|
96
|
+
this.$emit('change', { target: { value: newValue } });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
69
100
|
}
|
|
70
101
|
}
|
|
71
102
|
</script>
|
|
@@ -7,8 +7,21 @@ export default {
|
|
|
7
7
|
|
|
8
8
|
export const select = () => ({
|
|
9
9
|
components: { EcsSelect },
|
|
10
|
+
data() {
|
|
11
|
+
return {
|
|
12
|
+
value: 'guest'
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
methods: {
|
|
16
|
+
update(value) {
|
|
17
|
+
this.value = value;
|
|
18
|
+
}
|
|
19
|
+
},
|
|
10
20
|
template: `<div>
|
|
11
|
-
<
|
|
21
|
+
Set to: <button @click="value = 'admin'">admin</button>
|
|
22
|
+
<button @click="value = 'basic'">basic</button>
|
|
23
|
+
<button @click="value = 'guest'">guest</button>
|
|
24
|
+
<ecs-select class="mb-4" :value="value" @change="update($event.target.value)">
|
|
12
25
|
<option value="admin">Admin</option>
|
|
13
26
|
<option value="basic">Basic</option>
|
|
14
27
|
<option value="guest">Guest</option>
|