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
  d136a4ed_20d6_20e1_e2c9_e71276bc7ea4["calendar-form.tsx"]
  3d40a3bf_c062_4304_329a_00b1b72e8523["zod"]
  d136a4ed_20d6_20e1_e2c9_e71276bc7ea4 --> 3d40a3bf_c062_4304_329a_00b1b72e8523
  f9e8c1ea_9de4_3e04_ca27_b15cada2e81e["date-fns"]
  d136a4ed_20d6_20e1_e2c9_e71276bc7ea4 --> f9e8c1ea_9de4_3e04_ca27_b15cada2e81e
  d39cd1e4_1b2d_9aa2_1d29_fd0b4bfb61c3["lucide-react"]
  d136a4ed_20d6_20e1_e2c9_e71276bc7ea4 --> d39cd1e4_1b2d_9aa2_1d29_fd0b4bfb61c3
  6d65354d_8f59_2cfc_4783_24b2eb870bc4["react-hook-form"]
  d136a4ed_20d6_20e1_e2c9_e71276bc7ea4 --> 6d65354d_8f59_2cfc_4783_24b2eb870bc4
  6802ce19_522d_e5fb_e458_8826d9f6952e["zod"]
  d136a4ed_20d6_20e1_e2c9_e71276bc7ea4 --> 6802ce19_522d_e5fb_e458_8826d9f6952e
  79081a1f_55a3_945a_fb8c_d53d6d3eab81["utils"]
  d136a4ed_20d6_20e1_e2c9_e71276bc7ea4 --> 79081a1f_55a3_945a_fb8c_d53d6d3eab81
  64d95022_f8e1_3e94_bb97_22b3ebca757e["use-toast"]
  d136a4ed_20d6_20e1_e2c9_e71276bc7ea4 --> 64d95022_f8e1_3e94_bb97_22b3ebca757e
  aa2f3ec6_f291_3763_88ec_65a3f5ad5939["button"]
  d136a4ed_20d6_20e1_e2c9_e71276bc7ea4 --> aa2f3ec6_f291_3763_88ec_65a3f5ad5939
  5000e233_363d_e409_8b5c_7e80d38646fe["calendar"]
  d136a4ed_20d6_20e1_e2c9_e71276bc7ea4 --> 5000e233_363d_e409_8b5c_7e80d38646fe
  7a6b0be4_eca5_4970_1a93_79d670ef529e["form"]
  d136a4ed_20d6_20e1_e2c9_e71276bc7ea4 --> 7a6b0be4_eca5_4970_1a93_79d670ef529e
  e33b0d79_0534_28ec_a112_ac16ee736e09["popover"]
  d136a4ed_20d6_20e1_e2c9_e71276bc7ea4 --> e33b0d79_0534_28ec_a112_ac16ee736e09
  style d136a4ed_20d6_20e1_e2c9_e71276bc7ea4 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/new-york/hooks/use-toast"
import { Button } from "@/registry/new-york/ui/button"
import { Calendar } from "@/registry/new-york/ui/calendar"
import {
  Form,
  FormControl,
  FormDescription,
  FormField,
  FormItem,
  FormLabel,
  FormMessage,
} from "@/registry/new-york/ui/form"
import {
  Popover,
  PopoverContent,
  PopoverTrigger,
} from "@/registry/new-york/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/new-york/examples/calendar-form.tsx (domain: ComponentRegistry, subdomain: ChartRegistry, directory: deprecated/www/registry/new-york/examples).

Analyze Your Own Codebase

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

Try Supermodel Free