* docs: improve the api reference of all the components * docs(app): #152 add new-york theme This pull request is intended to add the new-york theme for the newly created component examples. Closes: #152 * chore: build registry * chore: change usage of lucide icon in new-york --------- Co-authored-by: zernonia <zernonia@gmail.com>
85 lines
2.1 KiB
Vue
85 lines
2.1 KiB
Vue
<script setup lang="ts">
|
|
import { h } from 'vue'
|
|
import { useForm } from 'vee-validate'
|
|
import { toTypedSchema } from '@vee-validate/zod'
|
|
import * as z from 'zod'
|
|
|
|
import { Button } from '@/lib/registry/default/ui/button'
|
|
import {
|
|
FormControl,
|
|
FormDescription,
|
|
FormField,
|
|
FormItem,
|
|
FormLabel,
|
|
FormMessage,
|
|
} from '@/lib/registry/default/ui/form'
|
|
import {
|
|
Select,
|
|
SelectContent,
|
|
SelectGroup,
|
|
SelectItem,
|
|
SelectTrigger,
|
|
SelectValue,
|
|
} from '@/lib/registry/default/ui/select'
|
|
import { toast } from '@/lib/registry/default/ui/toast'
|
|
|
|
const formSchema = toTypedSchema(z.object({
|
|
email: z
|
|
.string({
|
|
required_error: 'Please select an email to display.',
|
|
})
|
|
.email(),
|
|
}))
|
|
|
|
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-2/3 space-y-6" @submit="onSubmit">
|
|
<FormField v-slot="{ componentField }" name="email">
|
|
<FormItem>
|
|
<FormLabel>Email</FormLabel>
|
|
|
|
<Select v-bind="componentField">
|
|
<FormControl>
|
|
<SelectTrigger>
|
|
<SelectValue placeholder="Select a verified email to display" />
|
|
</SelectTrigger>
|
|
</FormControl>
|
|
<SelectContent>
|
|
<SelectGroup>
|
|
<SelectItem value="m@example.com">
|
|
m@example.com
|
|
</SelectItem>
|
|
<SelectItem value="m@google.com">
|
|
m@google.com
|
|
</SelectItem>
|
|
<SelectItem value="m@support.com">
|
|
m@support.com
|
|
</SelectItem>
|
|
</SelectGroup>
|
|
</SelectContent>
|
|
</Select>
|
|
<FormDescription>
|
|
You can manage email addresses in your
|
|
<a href="/examples/forms">email settings</a>.
|
|
</FormDescription>
|
|
<FormMessage />
|
|
</FormItem>
|
|
</FormField>
|
|
|
|
<Button type="submit">
|
|
Submit
|
|
</Button>
|
|
</form>
|
|
</template>
|