-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathOptionboxView.vue
More file actions
69 lines (66 loc) · 1.49 KB
/
OptionboxView.vue
File metadata and controls
69 lines (66 loc) · 1.49 KB
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
67
68
69
<template>
<div :aria-label="$attrs['aria-label']">
<div v-for="(option, index) in options" :key="getOptionValue(option)" :class="divClass" role="radio">
<input
v-model="selected"
v-uni-id="getOptionId(option, index)"
:class="inputClass"
type="radio"
:name="inputName"
:value="emitObjects ? option : getOptionValue(option)"
v-bind="$attrs"
:disabled="isReadOnly"
:aria-label="getOptionAriaLabel(option)"
/>
<label v-uni-for="getOptionId(option, index)" :class="labelClass">
{{ getOptionContent(option) }}
</label>
</div>
</div>
</template>
<script>
import { createUniqIdsMixin } from "vue-uniq-ids";
import ValidationMixin from "../mixins/validation";
import checkbox from "../mixins/checkbox";
const uniqIdsMixin = createUniqIdsMixin();
export default {
mixins: [uniqIdsMixin, ValidationMixin, checkbox],
inheritAttrs: false,
props: [
"value",
"optionValue",
"optionContent",
"optionAriaLabel",
"options",
"optionsExtra",
"error",
"helper",
"name",
"controlClass",
"emitObjects",
"emitArray",
"allowMultiselect"
],
data() {
return {
selected: []
};
},
computed: {
inputName() {
return `${this.name}-${this._uid}`;
}
},
watch: {
value(val) {
this.selected = val;
},
selected() {
this.$emit("input", this.selected);
}
},
mounted() {
this.selected = this.value;
}
};
</script>