mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 12:14:41 +01:00
37 lines
818 B
Vue
37 lines
818 B
Vue
<script setup lang="ts">
|
|
import { object, string, nonempty, type Infer } from 'superstruct'
|
|
import type { FormSubmitEvent } from '#ui/types'
|
|
|
|
const schema = object({
|
|
email: nonempty(string()),
|
|
password: nonempty(string())
|
|
})
|
|
|
|
const state = reactive({
|
|
email: '',
|
|
password: ''
|
|
})
|
|
|
|
type Schema = Infer<typeof schema>
|
|
|
|
async function onSubmit(event: FormSubmitEvent<Schema>) {
|
|
console.log(event.data)
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<UForm :schema="schema" :state="state" class="space-y-4" @submit="onSubmit">
|
|
<UFormGroup label="Email" name="email">
|
|
<UInput v-model="state.email" />
|
|
</UFormGroup>
|
|
|
|
<UFormGroup label="Password" name="password">
|
|
<UInput v-model="state.password" type="password" />
|
|
</UFormGroup>
|
|
|
|
<UButton type="submit">
|
|
Submit
|
|
</UButton>
|
|
</UForm>
|
|
</template>
|