69 lines
No EOL
1.2 KiB
Vue
69 lines
No EOL
1.2 KiB
Vue
<template>
|
|
<div class="input-wrapper">
|
|
<label v-if="label" :for="id">{{ label }}</label>
|
|
<input
|
|
:id="id"
|
|
:type="type"
|
|
:value="modelValue"
|
|
@input="$emit('update:modelValue', $event.target.value)"
|
|
@blur="$emit('blur', $event)"
|
|
@focus="$emit('focus', $event)"
|
|
@change="$emit('change', $event)"
|
|
v-bind="$attrs"
|
|
/>
|
|
<p v-if="error" class="error-message">{{ error }}</p>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
defineProps({
|
|
id: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
label: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
type: {
|
|
type: String,
|
|
default: 'text'
|
|
},
|
|
modelValue: {
|
|
type: [String, Number],
|
|
default: ''
|
|
},
|
|
error: {
|
|
type: String,
|
|
default: ''
|
|
}
|
|
})
|
|
|
|
defineEmits(['update:modelValue', 'blur', 'focus', 'change'])
|
|
</script>
|
|
|
|
<style scoped>
|
|
.input-wrapper {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.5rem;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.input-wrapper label {
|
|
font-weight: 500;
|
|
}
|
|
|
|
.input-wrapper input {
|
|
padding: 0.5rem;
|
|
border: 1px solid #ccc;
|
|
border-radius: 4px;
|
|
font-size: 1rem;
|
|
}
|
|
|
|
.error-message {
|
|
color: #ff4444;
|
|
font-size: 0.875rem;
|
|
margin-top: 0.25rem;
|
|
}
|
|
</style> |