{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "adaptive-date-input",
  "title": "Adaptive Date Input",
  "description": "A date input that uses the phone's native date picker on touch devices and the segmented date field with a calendar on desktop, with one ISO value. Use this when the same form runs on phones and desktops and each should get the date control it is best at.",
  "registryDependencies": [
    "@tealmac/date-field",
    "@tealmac/date-time-core"
  ],
  "files": [
    {
      "path": "registry/patterns/adaptive-date-input/adaptive-date-input.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { DateField } from \"@/components/ui/date-field\"\nimport { resolveLocale } from \"@/components/ui/date-time-core\"\n\nexport interface AdaptiveDateInputProps {\n  value?: string | null\n  defaultValue?: string | null\n  onValueChange?: (value: string | null) => void\n  min?: string\n  max?: string\n  forceNative?: boolean\n  label?: string\n  locale?: string\n}\n\n/** True on a device whose main pointer is a finger. */\nfunction useCoarsePointer(force?: boolean) {\n  const [coarse, setCoarse] = React.useState(false)\n  React.useEffect(() => {\n    if (force !== undefined) return\n    const mq = window.matchMedia(\"(pointer: coarse)\")\n    setCoarse(mq.matches)\n    const on = (e: MediaQueryListEvent) => setCoarse(e.matches)\n    mq.addEventListener(\"change\", on)\n    return () => mq.removeEventListener(\"change\", on)\n  }, [force])\n  return force ?? coarse\n}\n\nexport function AdaptiveDateInput({\n  value,\n  defaultValue = null,\n  onValueChange,\n  min,\n  max,\n  forceNative,\n  label = \"Date\",\n  locale,\n}: AdaptiveDateInputProps) {\n  const loc = resolveLocale(locale)\n  const native = useCoarsePointer(forceNative)\n  const [inner, setInner] = React.useState<string | null>(defaultValue)\n  const date = value === undefined ? inner : value\n  function change(next: string | null) {\n    if (value === undefined) setInner(next)\n    onValueChange?.(next)\n  }\n\n  return native ? (\n    <input\n      type=\"date\"\n      aria-label={label}\n      min={min}\n      max={max}\n      value={date ?? \"\"}\n      onChange={(e) => change(e.target.value || null)}\n      className=\"border-input bg-background focus-visible:border-ring focus-visible:ring-ring/50 h-11 w-full max-w-60 rounded-md border px-3 text-base shadow-xs outline-none focus-visible:ring-[3px]\"\n    />\n  ) : (\n    <DateField\n      label={label}\n      locale={loc}\n      min={min}\n      max={max}\n      value={date}\n      onValueChange={change}\n    />\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "type": "registry:block"
}