Probably final version of FloatInputTextField
This commit is contained in:
@@ -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>
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user