2019-03-18 08:53:00 -03:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<label v-if="label" class="form-label" :for="id">{{ label }}:</label>
|
2019-04-15 22:18:29 -03:00
|
|
|
<input :id="id" ref="input" v-bind="$attrs" class="form-input" :class="{ error: errors.length }" :type="type" :value="value" @input="$emit('input', $event.target.value)">
|
|
|
|
<div v-if="errors.length" class="form-error">{{ errors[0] }}</div>
|
2019-03-18 08:53:00 -03:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
inheritAttrs: false,
|
|
|
|
props: {
|
|
|
|
id: {
|
|
|
|
type: String,
|
|
|
|
default() {
|
|
|
|
return `text-input-${this._uid}`
|
|
|
|
},
|
|
|
|
},
|
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
default: 'text',
|
|
|
|
},
|
|
|
|
value: String,
|
|
|
|
label: String,
|
2019-04-15 22:18:29 -03:00
|
|
|
errors: {
|
|
|
|
type: Array,
|
|
|
|
default: () => [],
|
|
|
|
},
|
2019-03-18 08:53:00 -03:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
focus() {
|
|
|
|
this.$refs.input.focus()
|
|
|
|
},
|
|
|
|
select() {
|
|
|
|
this.$refs.input.select()
|
|
|
|
},
|
|
|
|
setSelectionRange(start, end) {
|
|
|
|
this.$refs.input.setSelectionRange(start, end)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|