From 5ee0a4641eb1e0da546ee8f03f3f0ee61c8c1165 Mon Sep 17 00:00:00 2001
From: Sadegh Barati
Date: Mon, 25 Sep 2023 19:21:19 +0330
Subject: [PATCH] chore: update `AccountForm` example
- add `FormDescription` component
- include `src` in tsconfig
---
.../examples/forms/components/AccountForm.vue | 226 ++++++++++--------
.../default/ui/form/FormDescription.vue | 15 ++
.../registry/default/ui/form/FormLabel.vue | 4 +-
.../src/lib/registry/default/ui/form/index.ts | 1 +
apps/www/tsconfig.json | 28 +--
5 files changed, 155 insertions(+), 119 deletions(-)
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() {
-