44 lines
1.2 KiB
Vue
44 lines
1.2 KiB
Vue
<template>
|
|
<div class="flex flex-col">
|
|
<label v-if="label" :for="inputId" class="mb-1 text-sm font-medium text-gray-700">
|
|
{{ label }}
|
|
</label>
|
|
<input
|
|
:id="inputId"
|
|
:type="type"
|
|
:value="modelValue"
|
|
:placeholder="placeholder"
|
|
:disabled="disabled"
|
|
:required="required"
|
|
class="px-4 py-3 border border-gray-200 rounded-xl focus:outline-none focus:ring-2 focus:ring-blue-400 focus:border-blue-400 disabled:bg-gray-50 disabled:cursor-not-allowed transition-all bg-white/90 backdrop-blur-sm text-gray-900 placeholder:text-gray-400"
|
|
@input="$emit('update:modelValue', ($event.target as HTMLInputElement).value)"
|
|
/>
|
|
<span v-if="error" class="mt-1 text-sm text-red-600">{{ error }}</span>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
interface Props {
|
|
modelValue: string
|
|
type?: string
|
|
label?: string
|
|
placeholder?: string
|
|
disabled?: boolean
|
|
required?: boolean
|
|
error?: string
|
|
}
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
type: 'text',
|
|
disabled: false,
|
|
required: false
|
|
})
|
|
|
|
defineEmits<{
|
|
'update:modelValue': [value: string]
|
|
}>()
|
|
|
|
const inputId = computed(() => `input-${Math.random().toString(36).substr(2, 9)}`)
|
|
</script>
|
|
|