diff --git a/apps/www/src/examples/forms/components/AccountForm.vue b/apps/www/src/examples/forms/components/AccountForm.vue index df6ddb21..8c5e755b 100644 --- a/apps/www/src/examples/forms/components/AccountForm.vue +++ b/apps/www/src/examples/forms/components/AccountForm.vue @@ -4,22 +4,21 @@ import * as z from 'zod' import { format } from 'date-fns' import { toTypedSchema } from '@vee-validate/zod' import { configure } from 'vee-validate' +import { Check, ChevronsUpDown } from 'lucide-vue-next' import { cn } from '@/lib/utils' import RadixIconsCalendar from '~icons/radix-icons/calendar' -import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/lib/registry/default/ui/form' +import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '@/lib/registry/default/ui/form' import { Input } from '@/lib/registry/new-york/ui/input' -import { Label } from '@/lib/registry/new-york/ui/label' import { Separator } from '@/lib/registry/new-york/ui/separator' import { - Select, - SelectContent, - SelectGroup, - SelectItem, - SelectTrigger, - SelectValue, -} from '@/lib/registry/new-york/ui/select' + Command, + CommandEmpty, + CommandGroup, + CommandInput, + CommandItem, +} from '@/lib/registry/default/ui/command' import { Button } from '@/lib/registry/new-york/ui/button' import { Popover, @@ -28,11 +27,7 @@ import { } from '@/lib/registry/default/ui/popover' import { Calendar } from '@/lib/registry/new-york/ui/calendar' -const accountForm = ref({ - name: '', - dob: null, - language: '', -}) +const open = ref(false) const languages = [ { label: 'English', value: 'en' }, @@ -47,37 +42,31 @@ const languages = [ ] as const const accountFormSchema = toTypedSchema(z.object({ - // name: z - // .string() - // .min(2, { - // message: 'Name must be at least 2 characters.', - // }) - // .max(30, { - // message: 'Name must not be longer than 30 characters.', - // }), - // dob: z.date({ - // required_error: 'A date of birth is required.', - // }), - // language: z.string().nonempty({ - // message: 'Please select a language.', - // }), - example: z.string().nonempty({ + name: z + .string() + .min(2, { + message: 'Name must be at least 2 characters.', + }) + .max(30, { + message: 'Name must not be longer than 30 characters.', + }), + dob: z.date({ + required_error: 'A date of birth is required.', + }), + language: z.string().nonempty({ message: 'Please select a language.', - }).min(5), + }), })) // type AccountFormValues = z.infer // const errors = ref | null>(null) -async function handleSubmit() { - // const result = accountFormSchema.safeParse(accountForm.value) - // if (!result.success) { - // errors.value = result.error.format() - // console.log(errors.value) - // return - // } +const filterFunction = (list: typeof languages, search: string) => list.filter(i => i.value.toLowerCase().includes(search.toLowerCase())) - // console.log('Form submitted!', accountForm.value) +// https://github.com/logaretm/vee-validate/issues/3521 +// https://github.com/logaretm/vee-validate/discussions/3571 +async function handleSubmit(values: any) { + console.log('Form submitted!', values) } @@ -91,82 +80,113 @@ async function handleSubmit() {

-
- + + Name + + This is your public display name. It can be your real name or a + pseudonym. You can only change this once every 30 days. + - + + + Date of birth + + + + + + + + + + + + Your date of birth is used to calculate your age. + + + + - -