{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "responsive-dialog",
  "title": "Responsive Dialog",
  "description": "A dialog that becomes a bottom drawer on small screens, where a centered panel is out of thumb reach. Same title, description and content in both. mode forces 'dialog' or 'drawer'; 'auto' switches on a media query (below 640px by default). Used by the wallet picker and the token picker. Built on the shadcn Dialog and Drawer. Exports useMediaQuery, which is false on the server and where matchMedia is missing.",
  "registryDependencies": [
    "dialog",
    "drawer"
  ],
  "files": [
    {
      "path": "registry/default/components/responsive-dialog.tsx",
      "content": "// Docs: https://0xui.io/components/responsive-dialog.md\nimport {\n  useCallback,\n  useSyncExternalStore,\n  type KeyboardEventHandler,\n  type ReactNode,\n} from \"react\";\nimport {\n  Dialog,\n  DialogContent,\n  DialogDescription,\n  DialogHeader,\n  DialogTitle,\n} from \"@/components/ui/dialog\";\nimport {\n  Drawer,\n  DrawerContent,\n  DrawerDescription,\n  DrawerHeader,\n  DrawerTitle,\n} from \"@/components/ui/drawer\";\n\n/**\n * Whether a media query matches, kept up to date. False on the server and\n * where `matchMedia` is missing, such as jsdom.\n */\nexport function useMediaQuery(query: string) {\n  const subscribe = useCallback(\n    (onChange: () => void) => {\n      if (typeof window.matchMedia !== \"function\") return () => {};\n      const media = window.matchMedia(query);\n      media.addEventListener(\"change\", onChange);\n      return () => media.removeEventListener(\"change\", onChange);\n    },\n    [query],\n  );\n  return useSyncExternalStore(\n    subscribe,\n    () => typeof window.matchMedia === \"function\" && window.matchMedia(query).matches,\n    () => false,\n  );\n}\n\nexport type ResponsiveDialogMode = \"auto\" | \"dialog\" | \"drawer\";\n\nexport type ResponsiveDialogProps = {\n  open: boolean;\n  onOpenChange: (open: boolean) => void;\n  title: ReactNode;\n  /** What the dialog is for. Read by screen readers, not shown. */\n  description: ReactNode;\n  /**\n   * `auto` is a bottom drawer on small screens and a centered dialog on\n   * larger ones. `dialog` and `drawer` force one.\n   */\n  mode?: ResponsiveDialogMode;\n  /** Media query that picks the drawer in `auto` mode. */\n  drawerQuery?: string;\n  /** Class for the dialog panel. The drawer sizes itself. */\n  className?: string;\n  onKeyDown?: KeyboardEventHandler<HTMLDivElement>;\n  \"data-phase\"?: string;\n  \"data-error\"?: string;\n  children: ReactNode;\n};\n\n/**\n * A dialog that becomes a bottom drawer on small screens, where a centered\n * panel is out of thumb reach. Same title, description and content either\n * way. Switching between the two keeps `open`, but remounts the content.\n */\nexport function ResponsiveDialog({\n  open,\n  onOpenChange,\n  title,\n  description,\n  mode = \"auto\",\n  drawerQuery = \"(max-width: 639px)\",\n  className,\n  onKeyDown,\n  \"data-phase\": phase,\n  \"data-error\": error,\n  children,\n}: ResponsiveDialogProps) {\n  const small = useMediaQuery(drawerQuery);\n  const drawer = mode === \"drawer\" || (mode === \"auto\" && small);\n\n  if (drawer) {\n    return (\n      <Drawer open={open} onOpenChange={onOpenChange} showSwipeHandle>\n        <DrawerContent data-phase={phase} data-error={error} onKeyDown={onKeyDown}>\n          <DrawerHeader>\n            <DrawerTitle>{title}</DrawerTitle>\n            <DrawerDescription className=\"sr-only\">{description}</DrawerDescription>\n          </DrawerHeader>\n          <div className=\"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4 pb-[max(1rem,env(safe-area-inset-bottom))]\">\n            {children}\n          </div>\n        </DrawerContent>\n      </Drawer>\n    );\n  }\n\n  return (\n    <Dialog open={open} onOpenChange={onOpenChange}>\n      <DialogContent\n        className={className}\n        data-phase={phase}\n        data-error={error}\n        onKeyDown={onKeyDown}\n      >\n        <DialogHeader>\n          <DialogTitle>{title}</DialogTitle>\n          <DialogDescription className=\"sr-only\">{description}</DialogDescription>\n        </DialogHeader>\n        {children}\n      </DialogContent>\n    </Dialog>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "docs": "Docs: https://0xui.io/components/responsive-dialog.md",
  "categories": [
    "utilities"
  ],
  "type": "registry:component"
}