diff --git a/src/app/ui/forms/Checkboxdemo.tsx b/src/app/ui/forms/Checkboxdemo.tsx deleted file mode 100644 index 50cdb29..0000000 --- a/src/app/ui/forms/Checkboxdemo.tsx +++ /dev/null @@ -1,128 +0,0 @@ -"use client" - -import { zodResolver } from "@hookform/resolvers/zod" -import { useForm } from "react-hook-form" -import { z } from "zod" - -import { Button } from "@/components/ui/button" -import { Checkbox } from "@/components/ui/checkbox" -import { - Form, - FormControl, - FormDescription, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "@/components/ui/form" -import { toast } from "@/components/ui/use-toast" - -const items = [ - { - id: "recents", - label: "Recents", - }, - { - id: "home", - label: "Home", - }, - { - id: "applications", - label: "Applications", - }, - { - id: "desktop", - label: "Desktop", - }, - { - id: "downloads", - label: "Downloads", - }, - { - id: "documents", - label: "Documents", - }, -] as const - -const FormSchema = z.object({ - items: z.array(z.string()).refine((value) => value.some((item) => item), { - message: "You have to select at least one item.", - }), -}) - -export function CheckboxReactHookFormMultiple() { - const form = useForm>({ - resolver: zodResolver(FormSchema), - defaultValues: { - items: ["recents", "home"], - }, - }) - - function onSubmit(data: z.infer) { - toast({ - title: "You submitted the following values:", - description: ( -
-					{JSON.stringify(data, null, 2)}
-				
- ), - }) - } - - return ( -
- - ( - -
- Sidebar - - Select the items you want to display in the sidebar. - -
- {items.map((item) => ( - { - return ( - - - { - return checked - ? field.onChange([...field.value, item.id]) - : field.onChange( - field.value?.filter( - (value) => value !== item.id - ) - ) - }} - /> - - - {item.label} - - - ) - }} - /> - ))} - -
- )} - /> - - - - ) -} - diff --git a/src/app/ui/forms/datePickerDemo.tsx b/src/app/ui/forms/datePickerDemo.tsx deleted file mode 100644 index f51de2b..0000000 --- a/src/app/ui/forms/datePickerDemo.tsx +++ /dev/null @@ -1,103 +0,0 @@ -"use client" - -import { zodResolver } from "@hookform/resolvers/zod" -import { CalendarIcon } from "@radix-ui/react-icons" -import { format } from "date-fns" -import { useForm } from "react-hook-form" -import { z } from "zod" - -import { cn } from "@/lib/utils" -import { Button } from "@/components/ui/button" -import { Calendar } from "@/components/ui/calendar" -import { - Form, - FormControl, - FormDescription, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "@/components/ui/form" -import { - Popover, - PopoverContent, - PopoverTrigger, -} from "@/components/ui/popover" -import { toast } from "@/components/ui/use-toast" - -const FormSchema = z.object({ - dob: z.date({ - required_error: "A date of birth is required.", - }), -}) - -export function DatePickerForm() { - const form = useForm>({ - resolver: zodResolver(FormSchema), - }) - - function onSubmit(data: z.infer) { - toast({ - title: "You submitted the following values:", - description: ( -
-					{JSON.stringify(data, null, 2)}
-				
- ), - }) - } - - return ( -
- - ( - - Date of birth - - - - - - - - - date > new Date() || date < new Date("1900-01-01") - } - initialFocus - /> - - - - Your date of birth is used to calculate your age. - - - - )} - /> - - - - - ) -} - diff --git a/src/app/ui/forms/genrePicker.tsx b/src/app/ui/forms/genrePicker.tsx deleted file mode 100644 index 4c071c6..0000000 --- a/src/app/ui/forms/genrePicker.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { forwardRef } from "react"; -import { FormField, FormItem, FormMessage } from "@/components/ui/form"; -import { Popover, PopoverContent, PopoverPortal, PopoverTrigger } from "@radix-ui/react-popover"; -import GenresTrigger from "./genresTrigger"; -import GenreCheckbox from "./genreCheckbox"; - -export const GenrePicker = forwardRef( - ({ form, genres }, ref) => ( - ( - - - - - {genres.map((item) => ( - { - return ( - - ) - }} - /> - ))} - - - - - )} - /> - ) -) diff --git a/src/app/ui/forms/selectDemo.tsx b/src/app/ui/forms/selectDemo.tsx deleted file mode 100644 index e589d74..0000000 --- a/src/app/ui/forms/selectDemo.tsx +++ /dev/null @@ -1,86 +0,0 @@ -"use client" - -import Link from "next/link" -import { zodResolver } from "@hookform/resolvers/zod" -import { useForm } from "react-hook-form" -import { z } from "zod" - -import { Button } from "@/components/ui/button" -import { - Form, - FormControl, - FormDescription, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "@/components/ui/form" -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@/components/ui/select" -import { toast } from "@/components/ui/use-toast" - -const FormSchema = z.object({ - email: z - .string({ - required_error: "Please select an email to display.", - }) - .email(), -}) - -export function SelectForm() { - const form = useForm>({ - resolver: zodResolver(FormSchema), - }) - - function onSubmit(data: z.infer) { - toast({ - title: "You submitted the following values:", - description: ( -
-					{JSON.stringify(data, null, 2)}
-				
- ), - }) - } - - - return ( -
- - ( - - Email - - - You can manage email addresses in your{" "} - email settings. - - - - )} - /> - - - - ) -} -