24 lines
2.9 KiB
JSON
24 lines
2.9 KiB
JSON
{
|
|
"name": "RadioGroupForm",
|
|
"type": "registry:example",
|
|
"dependencies": [
|
|
"vee-validate",
|
|
"@vee-validate/zod",
|
|
"zod"
|
|
],
|
|
"registryDependencies": [
|
|
"button",
|
|
"form",
|
|
"radio-group",
|
|
"toast"
|
|
],
|
|
"files": [
|
|
{
|
|
"path": "example/RadioGroupForm.vue",
|
|
"content": "<script setup lang=\"ts\">\nimport { Button } from '@/registry/default/ui/button'\nimport {\n FormControl,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n} from '@/registry/default/ui/form'\nimport { RadioGroup, RadioGroupItem } from '@/registry/default/ui/radio-group'\nimport { toast } from '@/registry/default/ui/toast'\n\nimport { toTypedSchema } from '@vee-validate/zod'\nimport { useForm } from 'vee-validate'\nimport { h } from 'vue'\nimport * as z from 'zod'\n\nconst formSchema = toTypedSchema(z.object({\n type: z.enum(['all', 'mentions', 'none'], {\n required_error: 'You need to select a notification type.',\n }),\n}))\n\nconst { handleSubmit } = useForm({\n validationSchema: formSchema,\n})\n\nconst onSubmit = handleSubmit((values) => {\n toast({\n title: 'You submitted the following values:',\n 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))),\n })\n})\n</script>\n\n<template>\n <form class=\"w-2/3 space-y-6\" @submit=\"onSubmit\">\n <FormField v-slot=\"{ componentField }\" type=\"radio\" name=\"type\">\n <FormItem class=\"space-y-3\">\n <FormLabel>Notify me about...</FormLabel>\n\n <FormControl>\n <RadioGroup\n class=\"flex flex-col space-y-1\"\n v-bind=\"componentField\"\n >\n <FormItem class=\"flex items-center space-y-0 gap-x-3\">\n <FormControl>\n <RadioGroupItem value=\"all\" />\n </FormControl>\n <FormLabel class=\"font-normal\">\n All new messages\n </FormLabel>\n </FormItem>\n <FormItem class=\"flex items-center space-y-0 gap-x-3\">\n <FormControl>\n <RadioGroupItem value=\"mentions\" />\n </FormControl>\n <FormLabel class=\"font-normal\">\n Direct messages and mentions\n </FormLabel>\n </FormItem>\n <FormItem class=\"flex items-center space-y-0 gap-x-3\">\n <FormControl>\n <RadioGroupItem value=\"none\" />\n </FormControl>\n <FormLabel class=\"font-normal\">\n Nothing\n </FormLabel>\n </FormItem>\n </RadioGroup>\n </FormControl>\n <FormMessage />\n </FormItem>\n </FormField>\n\n <Button type=\"submit\">\n Submit\n </Button>\n </form>\n</template>\n",
|
|
"type": "registry:example",
|
|
"target": ""
|
|
}
|
|
]
|
|
}
|