form-fieldset.vue
1.82 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
<template>
<div :class="['form-group','row',inputState]" v-if="enabled">
<label :for="for_id" v-if="label" :class="['col-form-label',labelLayout]" v-html="label"/>
<div :class="inputLayout">
<slot></slot>
<div class="form-text text-muted" v-if="feedback" v-html="feedback"></div>
<small class="form-text text-muted" v-if="description" v-html="description"></small>
</div>
</div>
<div v-else>
<slot></slot>
</div>
</template>
<script>
import {uniqueId} from '../utils/helpers';
export default {
computed: {
inputState() {
return this.state ? `has-${this.state}` : '';
},
labelLayout() {
return this.horizontal ? ('col-sm-' + this.labelSize) : ('col-sm-' + (12 - this.labelSize));
},
inputLayout() {
return this.horizontal ? ('col-sm-' + (12 - this.labelSize)) : ('col-sm-' + this.labelSize);
}
},
props: {
for_id: {
type: String,
default: uniqueId
},
state: {
type: String,
default: null
},
horizontal: {
type: Boolean,
default: false
},
labelSize: {
type: Number,
default: 6
},
enabled: {
type: Boolean,
default: true
},
label: {
type: String,
default: null
},
description: {
type: String,
default: null
},
feedback: {
type: String,
default: null
}
}
};
</script>