45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
Vue.component('tt-input', {
|
|
props: {
|
|
label: String,
|
|
type: String,
|
|
placeholder: String,
|
|
required: Boolean,
|
|
row: Boolean,
|
|
value: [String, Number],
|
|
hint: String,
|
|
additionalProps: Object,
|
|
sm: {type: Boolean, default: false},
|
|
},
|
|
data() {
|
|
return {
|
|
inputValue: this.value,
|
|
};
|
|
},
|
|
watch: {
|
|
value(val) {
|
|
this.inputValue = val;
|
|
}
|
|
},
|
|
template: `
|
|
<div class="form-group" :class="{'row': row}">
|
|
<slot name="prepend"></slot>
|
|
<label
|
|
:class="{'col-form-label': row, 'col-sm-4': row, 'col-form-label-sm': sm && row}"
|
|
v-if="label"
|
|
:for="label">{{ label }}</label>
|
|
<input :type="type"
|
|
:id="label"
|
|
:name="label"
|
|
class="form-control"
|
|
:class="{'form-control-sm': sm, 'col-sm-8': row}"
|
|
:placeholder="placeholder"
|
|
:required="required"
|
|
v-bind="additionalProps"
|
|
v-model="inputValue"
|
|
@input="$emit('input', $event.target.value)"
|
|
>
|
|
<small v-if="hint" class="form-text text-muted">{{ hint }}</small>
|
|
</div>
|
|
`
|
|
});
|