{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "wall-calendar",
  "title": "Wall Calendar",
  "author": "VenusUI",
  "description": "A hanging calendar whose pages flip from the binding, with single-day or range selection.",
  "dependencies": [
    "lucide-react"
  ],
  "files": [
    {
      "path": "registry/default/ui/wall-calendar.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { ChevronLeft, ChevronRight } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\n\nexport interface CalendarSelection {\n  from: Date | null\n  to: Date | null\n}\n\ninterface WallCalendarProps extends Omit<React.ComponentProps<\"div\">, \"onChange\"> {\n  /** Month shown first. Required so the server and browser render the same page. */\n  defaultMonth: Date\n  mode?: \"single\" | \"range\"\n  selected?: CalendarSelection\n  defaultSelected?: CalendarSelection\n  onSelectedChange?: (selection: CalendarSelection) => void\n  /** One photo per month, repeating if there are fewer than twelve. */\n  photos?: { src: string; alt: string }[]\n  /** Return true for days that can't be picked. */\n  isDateDisabled?: (date: Date) => boolean\n  /** 0 is Sunday, 1 is Monday. */\n  weekStartsOn?: 0 | 1\n  locale?: string\n}\n\nconst key = (d: Date) => `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`\nconst startOfDay = (d: Date) => new Date(d.getFullYear(), d.getMonth(), d.getDate())\nconst addDays = (d: Date, days: number) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + days)\nconst sameMonth = (a: Date, b: Date) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth()\n\n/**\n * A hanging wall calendar. Pages flip over from the binding as you change\n * month, and days can be picked singly or as a range, by pointer or keyboard.\n */\nfunction WallCalendar({\n  defaultMonth,\n  mode = \"single\",\n  selected: selectedProp,\n  defaultSelected = { from: null, to: null },\n  onSelectedChange,\n  photos,\n  isDateDisabled,\n  weekStartsOn = 1,\n  locale = \"en-US\",\n  className,\n  ...props\n}: WallCalendarProps) {\n  const [month, setMonth] = React.useState(() => new Date(defaultMonth.getFullYear(), defaultMonth.getMonth(), 1))\n  const [internal, setInternal] = React.useState(defaultSelected)\n  const [cursor, setCursor] = React.useState(() => startOfDay(defaultSelected.from ?? new Date(defaultMonth.getFullYear(), defaultMonth.getMonth(), 1)))\n  const [flipped, setFlipped] = React.useState(false)\n  const moveFocus = React.useRef(false)\n  const grid = React.useRef<HTMLTableElement>(null)\n  const selected = selectedProp ?? internal\n  const year = month.getFullYear()\n  const photo = photos?.length ? photos[month.getMonth() % photos.length] : null\n  const title = new Intl.DateTimeFormat(locale, { month: \"long\" }).format(month)\n  const fullDate = new Intl.DateTimeFormat(locale, { dateStyle: \"full\" })\n  const weekday = new Intl.DateTimeFormat(locale, { weekday: \"short\" })\n  const lead = (month.getDay() - weekStartsOn + 7) % 7\n  const cells = Array.from({ length: 42 }, (_, i) => addDays(month, i - lead))\n  const weeks = Array.from({ length: 6 }, (_, i) => cells.slice(i * 7, i * 7 + 7))\n  const tabDate = sameMonth(cursor, month) ? cursor : month\n\n  React.useEffect(() => {\n    if (!moveFocus.current) return\n    moveFocus.current = false\n    grid.current?.querySelector<HTMLButtonElement>(`[data-date=\"${key(cursor)}\"]`)?.focus()\n  }, [cursor, month])\n\n  const showMonth = (next: Date) => {\n    setFlipped(true)\n    setMonth(new Date(next.getFullYear(), next.getMonth(), 1))\n  }\n\n  const moveCursor = (next: Date) => {\n    moveFocus.current = true\n    setCursor(next)\n    if (!sameMonth(next, month)) showMonth(next)\n  }\n\n  const choose = (date: Date) => {\n    setCursor(date)\n    let next: CalendarSelection = { from: date, to: null }\n    if (mode === \"range\" && selected.from && !selected.to) {\n      next = date < selected.from ? { from: date, to: selected.from } : { from: selected.from, to: date }\n    }\n    setInternal(next)\n    onSelectedChange?.(next)\n  }\n\n  const onGridKey = (event: React.KeyboardEvent) => {\n    const moves: Record<string, Date> = {\n      ArrowLeft: addDays(cursor, -1),\n      ArrowRight: addDays(cursor, 1),\n      ArrowUp: addDays(cursor, -7),\n      ArrowDown: addDays(cursor, 7),\n      PageUp: new Date(cursor.getFullYear(), cursor.getMonth() - 1, Math.min(cursor.getDate(), 28)),\n      PageDown: new Date(cursor.getFullYear(), cursor.getMonth() + 1, Math.min(cursor.getDate(), 28)),\n    }\n    const next = moves[event.key]\n    if (!next) return\n    event.preventDefault()\n    moveCursor(next)\n  }\n\n  return (\n    <div data-slot=\"wall-calendar\" className={cn(\"relative w-80 max-w-full pt-3 [perspective:1100px]\", className)} {...props}>\n      <div aria-hidden=\"true\" className=\"absolute inset-x-6 top-0 z-10 flex justify-between\">\n        {Array.from({ length: 12 }, (_, i) => (\n          <span key={i} className=\"h-6 w-1 rounded-full bg-linear-to-b from-neutral-300 via-neutral-500 to-neutral-700 shadow-sm\" />\n        ))}\n      </div>\n      <div\n        key={`${year}-${month.getMonth()}`}\n        className={cn(\"origin-top overflow-hidden rounded-b-md rounded-t-sm bg-white text-neutral-900 shadow-[0_18px_34px_-16px_rgb(0_0_0/0.55)] ring-1 ring-black/10\", flipped && \"animate-wall-calendar-flip motion-reduce:animate-none\")}\n      >\n        {photo ? (\n          <img src={photo.src} alt={photo.alt} className=\"aspect-[2/1] w-full bg-neutral-200 object-cover\" />\n        ) : (\n          <div aria-hidden=\"true\" className=\"h-8 bg-neutral-900\" />\n        )}\n        <div className=\"px-4 pt-3 pb-4\">\n          <div className=\"flex items-center justify-between\">\n            <button type=\"button\" aria-label=\"Previous month\" onClick={() => showMonth(new Date(year, month.getMonth() - 1, 1))} className=\"grid size-8 place-items-center rounded-md text-neutral-500 outline-none hover:bg-neutral-100 focus-visible:ring-3 focus-visible:ring-neutral-400\">\n              <ChevronLeft aria-hidden=\"true\" className=\"size-4\" />\n            </button>\n            <p aria-live=\"polite\" className=\"text-center font-serif text-lg font-semibold\">\n              {title} <span className=\"font-normal text-neutral-500\">{year}</span>\n            </p>\n            <button type=\"button\" aria-label=\"Next month\" onClick={() => showMonth(new Date(year, month.getMonth() + 1, 1))} className=\"grid size-8 place-items-center rounded-md text-neutral-500 outline-none hover:bg-neutral-100 focus-visible:ring-3 focus-visible:ring-neutral-400\">\n              <ChevronRight aria-hidden=\"true\" className=\"size-4\" />\n            </button>\n          </div>\n          <table ref={grid} role=\"grid\" aria-label={`${title} ${year}`} onKeyDown={onGridKey} className=\"mt-2 w-full table-fixed border-collapse text-center text-sm\">\n            <thead>\n              <tr>\n                {weeks[0].map((day) => (\n                  <th key={day.getDay()} scope=\"col\" className={cn(\"pb-1 text-[10px] font-medium tracking-wide uppercase\", day.getDay() === 0 ? \"text-red-700\" : \"text-neutral-500\")}>\n                    {weekday.format(day)}\n                  </th>\n                ))}\n              </tr>\n            </thead>\n            <tbody>\n              {weeks.map((week) => (\n                <tr key={key(week[0])}>\n                  {week.map((day) => {\n                    if (!sameMonth(day, month)) return <td key={key(day)} aria-hidden=\"true\" className=\"h-9\" />\n                    const dayKey = key(day)\n                    const from = selected.from && key(selected.from) === dayKey\n                    const to = selected.to && key(selected.to) === dayKey\n                    const inside = selected.from && selected.to && day > selected.from && day < selected.to\n                    const disabled = isDateDisabled?.(day) ?? false\n                    return (\n                      <td key={dayKey} className={cn(\"h-9 p-0\", inside && \"bg-neutral-100\", from && selected.to && \"rounded-l-full bg-neutral-100\", to && \"rounded-r-full bg-neutral-100\")}>\n                        <button\n                          type=\"button\"\n                          data-date={dayKey}\n                          disabled={disabled}\n                          tabIndex={dayKey === key(tabDate) ? 0 : -1}\n                          aria-pressed={Boolean(from || to || inside)}\n                          aria-label={fullDate.format(day)}\n                          onClick={() => choose(day)}\n                          className={cn(\n                            \"mx-auto grid size-8 place-items-center rounded-full tabular-nums outline-none hover:bg-neutral-200 focus-visible:ring-3 focus-visible:ring-neutral-400 disabled:text-neutral-300 disabled:line-through disabled:hover:bg-transparent\",\n                            day.getDay() === 0 && \"text-red-700\",\n                            (from || to) && \"bg-neutral-900 text-white hover:bg-neutral-800\"\n                          )}\n                        >\n                          {day.getDate()}\n                        </button>\n                      </td>\n                    )\n                  })}\n                </tr>\n              ))}\n            </tbody>\n          </table>\n        </div>\n      </div>\n    </div>\n  )\n}\n\nexport { WallCalendar }\n",
      "type": "registry:ui"
    }
  ],
  "cssVars": {
    "theme": {
      "animate-wall-calendar-flip": "wall-calendar-flip 0.45s ease-out both"
    }
  },
  "css": {
    "@keyframes wall-calendar-flip": {
      "from": {
        "transform": "rotateX(-72deg)",
        "opacity": "0.4"
      },
      "to": {
        "transform": "rotateX(0)",
        "opacity": "1"
      }
    }
  },
  "meta": {
    "version": "0.1.0"
  },
  "categories": [
    "inputs",
    "interactive"
  ],
  "type": "registry:ui"
}