{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "dependencies": [
    "@base-ui/react@1.9.0"
  ],
  "description": "A calendar popover on a field trigger: a roving-tabindex month grid and ISO values.",
  "docs": "Two steps after installing: import the copied stylesheet once at your app entry — it lands at `styles/liquefy-ui.css` — or `@import` it from your global CSS *before* `tailwindcss`, so Tailwind utilities keep winning over component styles. Then wrap the tree in `<LiquefyProvider>`, which is where every component reads its tokens from. Every copied file already carries its own 'use client' directive. Full documentation: https://liquefy-ui.com/#/docs/installation",
  "files": [
    {
      "content": "'use client'\n\nimport { Popover } from '@base-ui/react/popover'\nimport {\n  forwardRef,\n  useEffect,\n  useId,\n  useRef,\n  useState,\n  type ButtonHTMLAttributes,\n  type KeyboardEvent,\n} from 'react'\nimport { CalendarGlyph, ChevronLeftGlyph, ChevronRightGlyph } from '@/lib/internal-glyphs'\nimport { useLiquefyConfig, useLiquefyPortalContainer } from '@/lib/provider'\nimport { useLiquidStyles, type LiquidStyleProps } from '@/lib/styles-prop'\nimport { useLiquidGlass } from '@/hooks/use-liquid-glass'\n\n// Base UI has no calendar, so the month grid is this file's own: a roving-tabindex\n// grid with the key map WAI-ARIA asks for — arrows by a day and a week, Home/End\n// to the ends of the week, PageUp/PageDown by a month and with Shift by a year.\n// Base UI still owns the parts a hand-rolled picker gets wrong: the popup flips to\n// stay on screen, Escape closes it, and focus returns to the trigger.\n\nconst ISO_DATE = /^\\d{4}-\\d{2}-\\d{2}$/\n\nconst pad = (value: number) => String(value).padStart(2, '0')\n\n/** Local midnight for a `yyyy-mm-dd` string, or null when it is not one. */\nconst parseISO = (value?: string | null): Date | null => {\n  if (!value || !ISO_DATE.test(value)) return null\n  const year = Number(value.slice(0, 4))\n  const month = Number(value.slice(5, 7))\n  const day = Number(value.slice(8, 10))\n  const date = new Date(year, month - 1, day)\n  // `2026-02-31` builds a perfectly valid Date in March. A picker that takes one\n  // and then shows a different day than it was handed is worse than one that\n  // ignores it, so a date that rolled over is not a date.\n  return date.getMonth() === month - 1 && date.getDate() === day ? date : null\n}\n\n/**\n * The day a Date falls on, read in local time. `toISOString()` answers in UTC,\n * which is already tomorrow through a Tokyo evening and still yesterday through a\n * New York one — the off-by-one every hand-rolled picker ships at least once.\n */\nconst toISO = (date: Date) => `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`\n\nconst addDays = (date: Date, days: number) =>\n  new Date(date.getFullYear(), date.getMonth(), date.getDate() + days)\n\n/** Clamped to the end of the target month, so 31 Jan a month on is 28 Feb, not 3 Mar. */\nconst addMonths = (date: Date, months: number) => {\n  const target = new Date(date.getFullYear(), date.getMonth() + months, 1)\n  const lastDay = new Date(target.getFullYear(), target.getMonth() + 1, 0).getDate()\n  target.setDate(Math.min(date.getDate(), lastDay))\n  return target\n}\n\n/** How far into its week a date sits, once the week starts where the caller says. */\nconst weekIndex = (date: Date, weekStartsOn: number) => (date.getDay() - weekStartsOn + 7) % 7\n\n/** The first day of the week the month starts in, which is where the grid begins. */\nconst startOfGrid = (month: Date, weekStartsOn: number) => {\n  const first = new Date(month.getFullYear(), month.getMonth(), 1)\n  return addDays(first, -weekIndex(first, weekStartsOn))\n}\n\n/**\n * Six weeks from there. Always six, even when five would cover the month: a grid\n * that changes height re-lays the popup out under the pointer, and the next\n * month's arrow moves out from under the click.\n */\nconst weeksFrom = (start: Date): Date[][] => Array.from({ length: 6 }, (_, week) =>\n  Array.from({ length: 7 }, (_, day) => addDays(start, week * 7 + day)))\n\nexport type LiquidDatePickerProps = Omit<\n  ButtonHTMLAttributes<HTMLButtonElement>, 'defaultValue' | 'onChange' | 'value'\n> & LiquidStyleProps & {\n  /** Initial `yyyy-mm-dd` value when uncontrolled. */\n  defaultValue?: string\n  /** How the chosen date reads on the trigger. Defaults to the ISO value itself. */\n  format?: (value: string) => string\n  hint?: string\n  label?: string\n  /**\n   * BCP 47 tag for the month, weekday and day names. Fixed rather than taken from\n   * the environment so that a server and a browser format the same markup.\n   */\n  locale?: string\n  /** Latest selectable date, `yyyy-mm-dd`. */\n  max?: string\n  /** Earliest selectable date, `yyyy-mm-dd`. */\n  min?: string\n  /** Names a hidden input carrying the ISO value, for a plain form submit. */\n  name?: string\n  nextMonthLabel?: string\n  /** Called when the calendar opens or closes — a sheet holding the picker needs to know. */\n  onOpenChange?: (open: boolean) => void\n  onValueChange?: (value: string) => void\n  placeholder?: string\n  previousMonthLabel?: string\n  /** Controlled `yyyy-mm-dd` value. */\n  value?: string\n  /** 0 is Sunday through 6 is Saturday. */\n  weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6\n}\n\nexport const LiquidDatePicker = forwardRef<HTMLButtonElement, LiquidDatePickerProps>(({\n  className,\n  defaultValue,\n  disabled,\n  format,\n  hint,\n  label,\n  locale = 'en-US',\n  max,\n  min,\n  name,\n  nextMonthLabel = 'Next month',\n  onOpenChange,\n  onValueChange,\n  placeholder = 'Select a date…',\n  previousMonthLabel = 'Previous month',\n  style,\n  styles,\n  value,\n  weekStartsOn = 0,\n  ...props\n}, forwardedRef) => {\n  const config = useLiquefyConfig()\n  const portalContainer = useLiquefyPortalContainer()\n\n  const [glassRef, canvasRef, pulse] = useLiquidGlass<HTMLButtonElement>(forwardedRef, {\n    bounce: 0.05,\n    disabled,\n    glow: config.glow,\n    intensity: config.intensity,\n    lens: config.lens && config.transparency,\n    lensStrength: config.refraction,\n    motion: config.motion,\n    ripple: config.ripple,\n    shimmer: config.shimmer,\n    sparkle: config.sparkle,\n    tilt: 2,\n    tint: config.tint,\n    webgl: config.webgl,\n    wobbliness: config.wobbliness,\n  })\n\n  const id = useId()\n  const captionId = `${id}-caption`\n  const hintId = `${id}-hint`\n  const labelId = `${id}-label`\n  const valueId = `${id}-value`\n\n  const [uncontrolled, setUncontrolled] = useState(defaultValue ?? '')\n  const selected = value ?? uncontrolled\n\n  const [open, setOpen] = useState(false)\n  // Which day the arrow keys are standing on, and therefore which month is drawn.\n  const [focusedISO, setFocusedISO] = useState(() => selected || toISO(new Date()))\n\n  const focusedCell = useRef<HTMLButtonElement>(null)\n  // Set only by a key press. Clicking the month arrows must leave focus on the\n  // arrow, or the second click of a run lands on a button that moved away.\n  const takeFocus = useRef(false)\n\n  useEffect(() => {\n    if (!takeFocus.current) return\n    takeFocus.current = false\n    focusedCell.current?.focus()\n  }, [focusedISO])\n\n  const minDate = parseISO(min)\n  const maxDate = parseISO(max)\n  const clamp = (date: Date) => {\n    if (minDate && date < minDate) return minDate\n    if (maxDate && date > maxDate) return maxDate\n    return date\n  }\n\n  const focused = parseISO(focusedISO) ?? new Date()\n  const todayISO = toISO(new Date())\n  const gridStart = startOfGrid(focused, weekStartsOn)\n  const weeks = weeksFrom(gridStart)\n\n  const monthName = new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' })\n  const dayName = new Intl.DateTimeFormat(locale, { day: 'numeric', month: 'long', weekday: 'long', year: 'numeric' })\n  const weekdayName = new Intl.DateTimeFormat(locale, { weekday: 'long' })\n  const weekdayShort = new Intl.DateTimeFormat(locale, { weekday: 'short' })\n\n  const setOpenState = (next: boolean) => {\n    if (next) {\n      pulse(0.8)\n      // Re-entering always starts from the chosen day, not wherever the arrows\n      // were left the time before.\n      setFocusedISO(selected || todayISO)\n    }\n    setOpen(next)\n    onOpenChange?.(next)\n  }\n\n  const moveFocus = (date: Date) => {\n    takeFocus.current = true\n    setFocusedISO(toISO(clamp(date)))\n  }\n\n  const select = (date: Date) => {\n    pulse(1)\n    const iso = toISO(date)\n    if (value === undefined) setUncontrolled(iso)\n    onValueChange?.(iso)\n    setOpenState(false)\n  }\n\n  const handleGridKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n    const from = parseISO(focusedISO)\n    if (!from) return\n    const step: Record<string, () => Date> = {\n      ArrowDown: () => addDays(from, 7),\n      ArrowLeft: () => addDays(from, -1),\n      ArrowRight: () => addDays(from, 1),\n      ArrowUp: () => addDays(from, -7),\n      End: () => addDays(from, 6 - weekIndex(from, weekStartsOn)),\n      Home: () => addDays(from, -weekIndex(from, weekStartsOn)),\n      PageDown: () => addMonths(from, event.shiftKey ? 12 : 1),\n      PageUp: () => addMonths(from, event.shiftKey ? -12 : -1),\n    }\n    const next = step[event.key]\n    if (!next) return\n    // Otherwise the arrows scroll the popup and PageDown scrolls the page behind it.\n    event.preventDefault()\n    moveFocus(next())\n  }\n\n  const root = useLiquidStyles('lq-date-picker', { className, style, styles })\n\n  return (\n    <div className={root.className} style={root.style}>\n      <Popover.Root onOpenChange={(next) => setOpenState(next)} open={open}>\n        {label && <span className=\"lq-control-label\" id={labelId}>{label}</span>}\n        <Popover.Trigger\n          aria-describedby={hint ? hintId : undefined}\n          // The value is part of the name so the trigger reads as \"Date, 2026-09-15\"\n          // rather than leaving a screen reader to find the current value itself.\n          aria-labelledby={label ? `${labelId} ${valueId}` : undefined}\n          className=\"lq-date-picker__trigger\"\n          disabled={disabled}\n          ref={glassRef}\n          {...props}\n        >\n          {config.webgl && <canvas aria-hidden=\"true\" className=\"lq-surface__shader\" ref={canvasRef} />}\n          <span\n            className=\"lq-date-picker__value\"\n            data-placeholder={selected ? undefined : ''}\n            id={valueId}\n          >\n            {selected ? format?.(selected) ?? selected : placeholder}\n          </span>\n          <span className=\"lq-date-picker__icon\"><CalendarGlyph size={16} /></span>\n        </Popover.Trigger>\n        <Popover.Portal container={portalContainer ?? undefined}>\n          <Popover.Positioner align=\"start\" className=\"lq-date-picker__positioner\" sideOffset={7}>\n            <Popover.Popup\n              aria-label={label ?? 'Choose date'}\n              className=\"lq-date-picker__panel lq-popover\"\n              // Opening on the day the arrows will move from, rather than on the\n              // month arrow that happens to be first in the DOM.\n              initialFocus={focusedCell}\n            >\n              <div className=\"lq-date-picker__header\">\n                <button\n                  aria-label={previousMonthLabel}\n                  className=\"lq-date-picker__nav\"\n                  onClick={() => setFocusedISO(toISO(clamp(addMonths(focused, -1))))}\n                  type=\"button\"\n                >\n                  <ChevronLeftGlyph size={15} />\n                </button>\n                {/* Polite rather than silent: the arrows change the month without\n                    moving focus, and nothing else would announce it. */}\n                <div aria-live=\"polite\" className=\"lq-date-picker__caption\" id={captionId}>\n                  {monthName.format(focused)}\n                </div>\n                <button\n                  aria-label={nextMonthLabel}\n                  className=\"lq-date-picker__nav\"\n                  onClick={() => setFocusedISO(toISO(clamp(addMonths(focused, 1))))}\n                  type=\"button\"\n                >\n                  <ChevronRightGlyph size={15} />\n                </button>\n              </div>\n              <div\n                aria-labelledby={captionId}\n                className=\"lq-date-picker__grid\"\n                onKeyDown={handleGridKeyDown}\n                role=\"grid\"\n              >\n                <div className=\"lq-date-picker__weekdays\" role=\"row\">\n                  {Array.from({ length: 7 }, (_, day) => addDays(gridStart, day)).map((date) => (\n                    <span\n                      aria-label={weekdayName.format(date)}\n                      className=\"lq-date-picker__weekday\"\n                      key={date.getDay()}\n                      role=\"columnheader\"\n                    >\n                      {weekdayShort.format(date)}\n                    </span>\n                  ))}\n                </div>\n                {weeks.map((week, index) => (\n                  <div className=\"lq-date-picker__week\" key={index} role=\"row\">\n                    {week.map((date) => {\n                      const iso = toISO(date)\n                      const isSelected = iso === selected\n                      return (\n                        <button\n                          aria-current={iso === todayISO ? 'date' : undefined}\n                          // The number alone leaves a screen reader to guess the month.\n                          aria-label={dayName.format(date)}\n                          aria-selected={isSelected}\n                          className=\"lq-date-picker__day\"\n                          data-outside={date.getMonth() === focused.getMonth() ? undefined : ''}\n                          data-selected={isSelected ? '' : undefined}\n                          data-today={iso === todayISO ? '' : undefined}\n                          disabled={(minDate != null && date < minDate) || (maxDate != null && date > maxDate)}\n                          key={iso}\n                          onClick={() => select(date)}\n                          ref={iso === focusedISO ? focusedCell : undefined}\n                          role=\"gridcell\"\n                          // A roving tabindex: the whole grid is one tab stop and the\n                          // arrows move inside it.\n                          tabIndex={iso === focusedISO ? 0 : -1}\n                          type=\"button\"\n                        >\n                          {date.getDate()}\n                        </button>\n                      )\n                    })}\n                  </div>\n                ))}\n              </div>\n            </Popover.Popup>\n          </Popover.Positioner>\n        </Popover.Portal>\n      </Popover.Root>\n      {hint && <span className=\"lq-control-hint\" id={hintId}>{hint}</span>}\n      {name && <input name={name} type=\"hidden\" value={selected} />}\n    </div>\n  )\n})\n\nLiquidDatePicker.displayName = 'LiquidDatePicker'\n",
      "path": "registry/liquid-date-picker.tsx",
      "type": "registry:ui"
    }
  ],
  "name": "liquid-date-picker",
  "registryDependencies": [
    "https://liquefy-ui.com/r/liquefy-ui.json",
    "https://liquefy-ui.com/r/internal-glyphs.json",
    "https://liquefy-ui.com/r/provider.json",
    "https://liquefy-ui.com/r/styles-prop.json",
    "https://liquefy-ui.com/r/use-liquid-glass.json"
  ],
  "title": "LiquidDatePicker",
  "type": "registry:ui"
}
