2021-09-01 20:07:11 -05:00
|
|
|
<template>
|
2021-11-19 10:14:36 -06:00
|
|
|
<div class="relative">
|
2023-01-29 13:19:06 -06:00
|
|
|
<input v-model="input" ref="input" autofocus :type="type" :disabled="disabled" :readonly="readonly" autocorrect="off" autocapitalize="none" autocomplete="off" :placeholder="placeholder" class="py-2 w-full outline-none bg-primary" :class="inputClass" @keyup="keyup" />
|
2021-11-19 10:14:36 -06:00
|
|
|
<div v-if="prependIcon" class="absolute top-0 left-0 h-full px-2 flex items-center justify-center">
|
|
|
|
<span class="material-icons text-lg">{{ prependIcon }}</span>
|
|
|
|
</div>
|
2023-01-16 17:44:32 -06:00
|
|
|
<div v-if="clearable && input" class="absolute top-0 right-0 h-full px-2 flex items-center justify-center" @click.stop="clear">
|
|
|
|
<span class="material-icons text-lg">close</span>
|
|
|
|
</div>
|
2023-01-29 13:19:06 -06:00
|
|
|
<div v-else-if="!clearable && appendIcon" class="absolute top-0 right-0 h-full px-2 flex items-center justify-center">
|
|
|
|
<span class="material-icons text-lg">{{ appendIcon }}</span>
|
|
|
|
</div>
|
2021-11-19 10:14:36 -06:00
|
|
|
</div>
|
2021-09-01 20:07:11 -05:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
value: [String, Number],
|
|
|
|
placeholder: String,
|
|
|
|
type: String,
|
2021-11-19 10:14:36 -06:00
|
|
|
disabled: Boolean,
|
2023-01-29 13:19:06 -06:00
|
|
|
readonly: Boolean,
|
2021-11-19 10:14:36 -06:00
|
|
|
borderless: Boolean,
|
|
|
|
bg: {
|
|
|
|
type: String,
|
|
|
|
default: 'bg'
|
|
|
|
},
|
|
|
|
rounded: {
|
|
|
|
type: String,
|
|
|
|
default: 'sm'
|
|
|
|
},
|
|
|
|
prependIcon: {
|
|
|
|
type: String,
|
|
|
|
default: null
|
2023-01-16 17:44:32 -06:00
|
|
|
},
|
2023-01-29 13:19:06 -06:00
|
|
|
appendIcon: {
|
|
|
|
type: String,
|
|
|
|
default: null
|
|
|
|
},
|
2023-01-16 17:44:32 -06:00
|
|
|
clearable: Boolean
|
2021-09-01 20:07:11 -05:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
input: {
|
|
|
|
get() {
|
|
|
|
return this.value
|
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.$emit('input', val)
|
|
|
|
}
|
2021-11-19 10:14:36 -06:00
|
|
|
},
|
|
|
|
inputClass() {
|
2022-12-08 17:54:56 -06:00
|
|
|
var classes = [`bg-${this.bg}`, `rounded-${this.rounded}`]
|
2021-11-19 10:14:36 -06:00
|
|
|
if (this.disabled) classes.push('text-gray-300')
|
|
|
|
else classes.push('text-white')
|
|
|
|
|
|
|
|
if (this.prependIcon) classes.push('pl-10 pr-2')
|
|
|
|
else classes.push('px-2')
|
|
|
|
|
|
|
|
if (!this.borderless) classes.push('border border-gray-600')
|
|
|
|
return classes.join(' ')
|
2021-09-01 20:07:11 -05:00
|
|
|
}
|
|
|
|
},
|
2021-09-05 15:22:30 -05:00
|
|
|
methods: {
|
2023-01-16 17:44:32 -06:00
|
|
|
clear() {
|
|
|
|
this.input = ''
|
|
|
|
},
|
2021-09-05 15:22:30 -05:00
|
|
|
focus() {
|
|
|
|
if (this.$refs.input) {
|
|
|
|
this.$refs.input.focus()
|
|
|
|
this.$refs.input.click()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
keyup() {
|
|
|
|
if (this.$refs.input) {
|
|
|
|
this.input = this.$refs.input.value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-09-01 20:07:11 -05:00
|
|
|
mounted() {}
|
|
|
|
}
|
2023-01-29 13:19:06 -06:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
input[type='time']::-webkit-calendar-picker-indicator {
|
|
|
|
filter: invert(100%);
|
|
|
|
}
|
|
|
|
</style>
|