/
form-select.vue
executable file
·66 lines (63 loc) · 1.72 KB
/
form-select.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<template>
<select :class="inputClass"
:name="name"
:id="id || null"
v-model="localValue"
:disabled="disabled"
:required="required"
:aria-required="required ? 'true' : null"
:aria-invalid="ariaInvalid"
ref="input"
>
<option v-for="option in formOptions"
:value="option.value"
v-html="option.text"
:disabled="option.disabled"
></option>
</select>
</template>
<script>
import {formMixin, formOptionsMixin, formCustomMixin} from '../mixins';
export default {
mixins: [formMixin, formCustomMixin, formOptionsMixin],
data() {
return {
localValue: this.value
};
},
computed: {
inputClass() {
return [
'form-control',
this.size ? `form-control-${this.size}` : null,
this.custom ? 'custom-select' : null
];
},
ariaInvalid() {
if (this.invalid === true || this.invalid === 'true') {
return 'true';
}
return null;
}
},
props: {
value: {},
invalid: {
type: [Boolean, String],
default: false
},
size: {
type: String,
default: null
},
options: {
type: [Array, Object],
required: true
},
returnObject: {
type: Boolean,
default: false
}
}
};
</script>