pingcrm/resources/js/Shared/TextareaInput.vue

41 lines
842 B
Vue
Raw Normal View History

2019-03-18 08:53:00 -03:00
<template>
<div>
<label v-if="label" class="form-label" :for="id">{{ label }}:</label>
<textarea :id="id" ref="input" v-bind="$attrs" class="form-textarea" :class="{ error: error }" :value="value" @input="$emit('input', $event.target.value)" />
<div v-if="error" class="form-error">{{ error }}</div>
</div>
</template>
<script>
import autosize from 'autosize'
export default {
inheritAttrs: false,
props: {
id: {
type: String,
default() {
return `textarea-input-${this._uid}`
},
},
value: String,
label: String,
error: String,
autosize: Boolean,
},
mounted() {
if (this.autosize) {
autosize(this.$refs.input)
}
},
methods: {
focus() {
this.$refs.input.focus()
},
select() {
this.$refs.input.select()
},
},
}
</script>