pingcrm/resources/js/Shared/TextInput.vue

40 lines
864 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>
2021-02-27 11:00:09 -03:00
<input :id="id" ref="input" v-bind="$attrs" class="form-input" :class="{ error: error }" :type="type" :value="value" @input="$emit('input', $event.target.value)" />
2020-09-08 17:14:52 -03:00
<div v-if="error" class="form-error">{{ error }}</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,
2020-09-08 17:14:52 -03:00
error: String,
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>