Probably final version of FloatInputTextField

This commit is contained in:
2025-03-24 12:31:07 +01:00
parent 7ac279da8e
commit 0c48df239e
2 changed files with 5 additions and 5 deletions

View File

@@ -30,9 +30,9 @@ const {
value: inputValue, value: inputValue,
errorMessage, errorMessage,
handleBlur, handleBlur,
handleChange, meta
} = useField(name, undefined, { } = useField(name, undefined, {
initialValue: props.value, initialValue: props.value
}); });
const invalid = computed(() => errorMessage.value ? true : undefined); const invalid = computed(() => errorMessage.value ? true : undefined);
@@ -42,13 +42,13 @@ const invalid = computed(() => errorMessage.value ? true : undefined);
<div class="grid grid-cols-1 gap-2"> <div class="grid grid-cols-1 gap-2">
<FloatLabel variant="on"> <FloatLabel variant="on">
<InputText <InputText
:id="id" v-model="inputValue" class="w-full" :invalid="invalid" @blur="handleBlur" @input="handleChange" :id="id" v-model="inputValue" class="w-full" :invalid="invalid" @blur="handleBlur"
/> />
<label :for="id"> <label :for="id">
{{ label }} {{ label }}
</label> </label>
</FloatLabel> </FloatLabel>
<Message v-if="errorMessage" class="text-wrap">{{ errorMessage }}</Message> <Message v-if="errorMessage && meta.touched" class="text-wrap">{{ errorMessage }}</Message>
</div> </div>
</template> </template>

View File

@@ -4,7 +4,7 @@ import * as zod from 'zod';
const zodSchema = zod.object({ const zodSchema = zod.object({
username: zod.string().min(1, { message: 'This is required' }), username: zod.string().min(1, { message: 'This is required' }),
password: zod.string().min(3), password: zod.string().min(3, { message: 'Password is required longer than 3' }),
}); });
const schema = toTypedSchema(zodSchema); const schema = toTypedSchema(zodSchema);