Home / File/ calendar-form.tsx — ui Source File

calendar-form.tsx — ui Source File

Architecture documentation for calendar-form.tsx, a tsx file in the ui codebase. 11 imports, 0 dependents.

File tsx ComponentRegistry ChartRegistry 11 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  04172d7a_d7a8_1dd2_c30c_ff2be1ffeb44["calendar-form.tsx"]
  3d40a3bf_c062_4304_329a_00b1b72e8523["zod"]
  04172d7a_d7a8_1dd2_c30c_ff2be1ffeb44 --> 3d40a3bf_c062_4304_329a_00b1b72e8523
  f9e8c1ea_9de4_3e04_ca27_b15cada2e81e["date-fns"]
  04172d7a_d7a8_1dd2_c30c_ff2be1ffeb44 --> f9e8c1ea_9de4_3e04_ca27_b15cada2e81e
  d39cd1e4_1b2d_9aa2_1d29_fd0b4bfb61c3["lucide-react"]
  04172d7a_d7a8_1dd2_c30c_ff2be1ffeb44 --> d39cd1e4_1b2d_9aa2_1d29_fd0b4bfb61c3
  6d65354d_8f59_2cfc_4783_24b2eb870bc4["react-hook-form"]
  04172d7a_d7a8_1dd2_c30c_ff2be1ffeb44 --> 6d65354d_8f59_2cfc_4783_24b2eb870bc4
  6802ce19_522d_e5fb_e458_8826d9f6952e["zod"]
  04172d7a_d7a8_1dd2_c30c_ff2be1ffeb44 --> 6802ce19_522d_e5fb_e458_8826d9f6952e
  79081a1f_55a3_945a_fb8c_d53d6d3eab81["utils"]
  04172d7a_d7a8_1dd2_c30c_ff2be1ffeb44 --> 79081a1f_55a3_945a_fb8c_d53d6d3eab81
  1d9c6c27_a443_c5fd_35f3_e80b7125bc9f["use-toast"]
  04172d7a_d7a8_1dd2_c30c_ff2be1ffeb44 --> 1d9c6c27_a443_c5fd_35f3_e80b7125bc9f
  d418ad18_b947_f4e5_6e4c_01100d7a63e4["button"]
  04172d7a_d7a8_1dd2_c30c_ff2be1ffeb44 --> d418ad18_b947_f4e5_6e4c_01100d7a63e4
  9296b496_7dcb_ebca_2184_14782807983b["calendar"]
  04172d7a_d7a8_1dd2_c30c_ff2be1ffeb44 --> 9296b496_7dcb_ebca_2184_14782807983b
  2f59b429_1e60_57e1_0581_cc5440e0bd30["form"]
  04172d7a_d7a8_1dd2_c30c_ff2be1ffeb44 --> 2f59b429_1e60_57e1_0581_cc5440e0bd30
  d1761ea6_65b9_f5fd_76e0_66663b00b300["popover"]
  04172d7a_d7a8_1dd2_c30c_ff2be1ffeb44 --> d1761ea6_65b9_f5fd_76e0_66663b00b300
  style 04172d7a_d7a8_1dd2_c30c_ff2be1ffeb44 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"use client"

import { zodResolver } from "@hookform/resolvers/zod"
import { format } from "date-fns"
import { CalendarIcon } from "lucide-react"
import { useForm } from "react-hook-form"
import { z } from "zod"

import { cn } from "@/lib/utils"
import { toast } from "@/registry/default/hooks/use-toast"
import { Button } from "@/registry/default/ui/button"
import { Calendar } from "@/registry/default/ui/calendar"
import {
  Form,
  FormControl,
  FormDescription,
  FormField,
  FormItem,
  FormLabel,
  FormMessage,
} from "@/registry/default/ui/form"
import {
  Popover,
  PopoverContent,
  PopoverTrigger,
} from "@/registry/default/ui/popover"

const FormSchema = z.object({
  dob: z.date({
    required_error: "A date of birth is required.",
  }),
})

export default function CalendarForm() {
  const form = useForm<z.infer<typeof FormSchema>>({
    resolver: zodResolver(FormSchema),
  })

  function onSubmit(data: z.infer<typeof FormSchema>) {
    toast({
      title: "You submitted the following values:",
      description: (
        <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
          <code className="text-white">{JSON.stringify(data, null, 2)}</code>
        </pre>
      ),
    })
  }

  return (
    <Form {...form}>
      <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
        <FormField
          control={form.control}
          name="dob"
          render={({ field }) => (
            <FormItem className="flex flex-col">
              <FormLabel>Date of birth</FormLabel>
              <Popover>
                <PopoverTrigger asChild>
                  <FormControl>
                    <Button
                      variant={"outline"}
                      className={cn(
                        "w-[240px] pl-3 text-left font-normal",
                        !field.value && "text-muted-foreground"
                      )}
                    >
                      {field.value ? (
                        format(field.value, "PPP")
                      ) : (
                        <span>Pick a date</span>
                      )}
                      <CalendarIcon className="ml-auto h-4 w-4 opacity-50" />
                    </Button>
                  </FormControl>
                </PopoverTrigger>
                <PopoverContent className="w-auto p-0" align="start">
                  <Calendar
                    mode="single"
                    selected={field.value}
                    onSelect={field.onChange}
                    disabled={(date) =>
                      date > new Date() || date < new Date("1900-01-01")
                    }
                    initialFocus
                  />
                </PopoverContent>
              </Popover>
              <FormDescription>
                Your date of birth is used to calculate your age.
              </FormDescription>
              <FormMessage />
            </FormItem>
          )}
        />
        <Button type="submit">Submit</Button>
      </form>
    </Form>
  )
}

Subdomains

Functions

Dependencies

  • button
  • calendar
  • date-fns
  • form
  • lucide-react
  • popover
  • react-hook-form
  • use-toast
  • utils
  • zod
  • zod

Frequently Asked Questions

What does calendar-form.tsx do?
calendar-form.tsx is a source file in the ui codebase, written in tsx. It belongs to the ComponentRegistry domain, ChartRegistry subdomain.
What functions are defined in calendar-form.tsx?
calendar-form.tsx defines 1 function(s): CalendarForm.
What does calendar-form.tsx depend on?
calendar-form.tsx imports 11 module(s): button, calendar, date-fns, form, lucide-react, popover, react-hook-form, use-toast, and 3 more.
Where is calendar-form.tsx in the architecture?
calendar-form.tsx is located at deprecated/www/registry/default/examples/calendar-form.tsx (domain: ComponentRegistry, subdomain: ChartRegistry, directory: deprecated/www/registry/default/examples).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free