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

calendar-29.tsx — ui Source File

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

File tsx ComponentRegistry ChartRegistry 8 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  c83cb43b_8a36_ba12_e115_76f14effaff2["calendar-29.tsx"]
  1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"]
  c83cb43b_8a36_ba12_e115_76f14effaff2 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2
  bac616a4_a8b3_e9e6_4624_ced1fc9bc31d["chrono-node"]
  c83cb43b_8a36_ba12_e115_76f14effaff2 --> bac616a4_a8b3_e9e6_4624_ced1fc9bc31d
  d39cd1e4_1b2d_9aa2_1d29_fd0b4bfb61c3["lucide-react"]
  c83cb43b_8a36_ba12_e115_76f14effaff2 --> d39cd1e4_1b2d_9aa2_1d29_fd0b4bfb61c3
  d418ad18_b947_f4e5_6e4c_01100d7a63e4["button"]
  c83cb43b_8a36_ba12_e115_76f14effaff2 --> d418ad18_b947_f4e5_6e4c_01100d7a63e4
  9296b496_7dcb_ebca_2184_14782807983b["calendar"]
  c83cb43b_8a36_ba12_e115_76f14effaff2 --> 9296b496_7dcb_ebca_2184_14782807983b
  163b5f6f_1cd3_6d8d_5305_80eec4895f60["input"]
  c83cb43b_8a36_ba12_e115_76f14effaff2 --> 163b5f6f_1cd3_6d8d_5305_80eec4895f60
  f826d306_7d63_5ba3_6a53_387904d37a9f["label"]
  c83cb43b_8a36_ba12_e115_76f14effaff2 --> f826d306_7d63_5ba3_6a53_387904d37a9f
  d1761ea6_65b9_f5fd_76e0_66663b00b300["popover"]
  c83cb43b_8a36_ba12_e115_76f14effaff2 --> d1761ea6_65b9_f5fd_76e0_66663b00b300
  style c83cb43b_8a36_ba12_e115_76f14effaff2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"use client"

import * as React from "react"
import { parseDate } from "chrono-node"
import { CalendarIcon } from "lucide-react"

import { Button } from "@/registry/default/ui/button"
import { Calendar } from "@/registry/default/ui/calendar"
import { Input } from "@/registry/default/ui/input"
import { Label } from "@/registry/default/ui/label"
import {
  Popover,
  PopoverContent,
  PopoverTrigger,
} from "@/registry/default/ui/popover"

function formatDate(date: Date | undefined) {
  if (!date) {
    return ""
  }

  return date.toLocaleDateString("en-US", {
    day: "2-digit",
    month: "long",
    year: "numeric",
  })
}

export default function Calendar29() {
  const [open, setOpen] = React.useState(false)
  const [value, setValue] = React.useState("In 2 days")
  const [date, setDate] = React.useState<Date | undefined>(
    parseDate(value) || undefined
  )
  const [month, setMonth] = React.useState<Date | undefined>(date)

  return (
    <div className="flex flex-col gap-3">
      <Label htmlFor="date" className="px-1">
        Schedule Date
      </Label>
      <div className="relative flex gap-2">
        <Input
          id="date"
          value={value}
          placeholder="Tomorrow or next week"
          className="bg-background pr-10"
          onChange={(e) => {
            setValue(e.target.value)
            const date = parseDate(e.target.value)
            if (date) {
              setDate(date)
              setMonth(date)
            }
          }}
          onKeyDown={(e) => {
            if (e.key === "ArrowDown") {
              e.preventDefault()
              setOpen(true)
            }
          }}
        />
        <Popover open={open} onOpenChange={setOpen}>
          <PopoverTrigger asChild>
            <Button
              id="date-picker"
              variant="ghost"
              className="absolute top-1/2 right-2 size-6 -translate-y-1/2"
            >
              <CalendarIcon className="size-3.5" />
              <span className="sr-only">Select date</span>
            </Button>
          </PopoverTrigger>
          <PopoverContent className="w-auto overflow-hidden p-0" align="end">
            <Calendar
              mode="single"
              selected={date}
              captionLayout="dropdown"
              month={month}
              onMonthChange={setMonth}
              onSelect={(date) => {
                setDate(date)
                setValue(formatDate(date))
                setOpen(false)
              }}
            />
          </PopoverContent>
        </Popover>
      </div>
      <div className="text-muted-foreground px-1 text-sm">
        Your post will be published on{" "}
        <span className="font-medium">{formatDate(date)}</span>.
      </div>
    </div>
  )
}

Subdomains

Dependencies

  • button
  • calendar
  • chrono-node
  • input
  • label
  • lucide-react
  • popover
  • react

Frequently Asked Questions

What does calendar-29.tsx do?
calendar-29.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-29.tsx?
calendar-29.tsx defines 2 function(s): Calendar29, formatDate.
What does calendar-29.tsx depend on?
calendar-29.tsx imports 8 module(s): button, calendar, chrono-node, input, label, lucide-react, popover, react.
Where is calendar-29.tsx in the architecture?
calendar-29.tsx is located at deprecated/www/__registry__/default/blocks/calendar-29.tsx (domain: ComponentRegistry, subdomain: ChartRegistry, directory: deprecated/www/__registry__/default/blocks).

Analyze Your Own Codebase

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

Try Supermodel Free