65 lines
1.7 KiB
Vue
65 lines
1.7 KiB
Vue
<script setup lang="ts">
|
|
import { Button } from '@/lib/registry/new-york/ui/button'
|
|
import {
|
|
FormControl,
|
|
FormDescription,
|
|
FormField,
|
|
FormItem,
|
|
FormLabel,
|
|
FormMessage,
|
|
} from '@/lib/registry/new-york/ui/form'
|
|
import { Textarea } from '@/lib/registry/new-york/ui/textarea'
|
|
import { toast } from '@/lib/registry/new-york/ui/toast'
|
|
|
|
import { toTypedSchema } from '@vee-validate/zod'
|
|
import { useForm } from 'vee-validate'
|
|
import { h } from 'vue'
|
|
import * as z from 'zod'
|
|
|
|
const formSchema = toTypedSchema(z.object({
|
|
bio: z
|
|
.string()
|
|
.min(10, {
|
|
message: 'Bio must be at least 10 characters.',
|
|
})
|
|
.max(160, {
|
|
message: 'Bio must not be longer than 30 characters.',
|
|
}),
|
|
}))
|
|
|
|
const { handleSubmit } = useForm({
|
|
validationSchema: formSchema,
|
|
})
|
|
|
|
const onSubmit = handleSubmit((values) => {
|
|
toast({
|
|
title: 'You submitted the following values:',
|
|
description: h('pre', { class: 'mt-2 w-[340px] rounded-md bg-slate-950 p-4' }, h('code', { class: 'text-white' }, JSON.stringify(values, null, 2))),
|
|
})
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<form class="w-full space-y-6" @submit="onSubmit">
|
|
<FormField v-slot="{ componentField }" name="bio">
|
|
<FormItem>
|
|
<FormLabel>Bio</FormLabel>
|
|
<FormControl>
|
|
<Textarea
|
|
placeholder="Tell us a little bit about yourself"
|
|
class="resize-none"
|
|
v-bind="componentField"
|
|
/>
|
|
</FormControl>
|
|
<FormDescription>
|
|
You can <span>@mention</span> other users and organizations.
|
|
</FormDescription>
|
|
<FormMessage />
|
|
</FormItem>
|
|
</FormField>
|
|
<Button type="submit">
|
|
Submit
|
|
</Button>
|
|
</form>
|
|
</template>
|