{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "calendar-29", "type": "registry:block", "author": "shadcn (https://ui.shadcn.com)", "description": "Natural language date picker", "dependencies": [ "chrono-node" ], "registryDependencies": [ "calendar", "input", "label", "popover", "button" ], "files": [ { "path": "blocks/calendar-29.tsx", "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { parseDate } from \"chrono-node\"\nimport { CalendarIcon } from \"lucide-react\"\n\nimport { Button } from \"@/registry/default/ui/button\"\nimport { Calendar } from \"@/registry/default/ui/calendar\"\nimport { Input } from \"@/registry/default/ui/input\"\nimport { Label } from \"@/registry/default/ui/label\"\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"@/registry/default/ui/popover\"\n\nfunction formatDate(date: Date | undefined) {\n if (!date) {\n return \"\"\n }\n\n return date.toLocaleDateString(\"en-US\", {\n day: \"2-digit\",\n month: \"long\",\n year: \"numeric\",\n })\n}\n\nexport default function Calendar29() {\n const [open, setOpen] = React.useState(false)\n const [value, setValue] = React.useState(\"In 2 days\")\n const [date, setDate] = React.useState(\n parseDate(value) || undefined\n )\n const [month, setMonth] = React.useState(date)\n\n return (\n
\n \n
\n {\n setValue(e.target.value)\n const date = parseDate(e.target.value)\n if (date) {\n setDate(date)\n setMonth(date)\n }\n }}\n onKeyDown={(e) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault()\n setOpen(true)\n }\n }}\n />\n \n \n \n \n Select date\n \n \n \n {\n setDate(date)\n setValue(formatDate(date))\n setOpen(false)\n }}\n />\n \n \n
\n
\n Your post will be published on{\" \"}\n {formatDate(date)}.\n
\n
\n )\n}\n", "type": "registry:component", "target": "" } ], "meta": { "iframeHeight": "600px", "container": "w-full bg-surface min-h-svh flex px-6 py-12 items-start md:pt-20 justify-center min-w-0 xl:py-24", "mobile": "component" }, "categories": [ "calendar", "date" ] }