Login test

This commit is contained in:
2025-03-20 17:50:28 +01:00
parent 1d7d24655f
commit 7ac279da8e
7 changed files with 147 additions and 5 deletions

View File

@@ -0,0 +1,57 @@
<script setup lang="ts">
const id = useId();
const props = defineProps({
value: {
type: String,
default: undefined,
},
type: {
type: String,
default: 'text',
},
name: {
type: String,
required: true,
},
label: {
type: String,
required: true,
}
});
// use `toRef` to create reactive references to `name` prop which is passed to `useField`
// this is important because vee-validte needs to know if the field name changes
// https://vee-validate.logaretm.com/v4/guide/composition-api/caveats
const name = toRef(props, 'name');
// we don't provide any rules here because we are using form-level validation
// https://vee-validate.logaretm.com/v4/guide/validation#form-level-validation
const {
value: inputValue,
errorMessage,
handleBlur,
handleChange,
} = useField(name, undefined, {
initialValue: props.value,
});
const invalid = computed(() => errorMessage.value ? true : undefined);
</script>
<template>
<div class="grid grid-cols-1 gap-2">
<FloatLabel variant="on">
<InputText
:id="id" v-model="inputValue" class="w-full" :invalid="invalid" @blur="handleBlur" @input="handleChange"
/>
<label :for="id">
{{ label }}
</label>
</FloatLabel>
<Message v-if="errorMessage" class="text-wrap">{{ errorMessage }}</Message>
</div>
</template>
<style scoped>
</style>