{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "drawer",
  "title": "Drawer",
  "author": "Zubeyr <https://zubeyr.dev>",
  "description": "A side or bottom drawer for record details and quick edits: header with actions, scrolling body, sticky footer, focus trap, Escape and outside-click close, scroll lock and a bottom sheet on phones.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "https://tomei.zubeyr.dev/ui/r/dialog.json"
  ],
  "files": [
    {
      "path": "registry/dashboard/components/drawer/drawer.tsx",
      "content": "'use client'\n\nimport { useId } from 'react'\nimport { createPortal } from 'react-dom'\nimport { X } from 'lucide-react'\n\nimport { cn } from '@/lib/utils'\nimport { useModal, usePresence } from '@/registry/dashboard/components/dialog/modal'\n\nconst sides = {\n  right: {\n    wrap: 'justify-end',\n    panel: 'h-full w-full border-l sm:rounded-l-2xl',\n    hidden: 'translate-x-full',\n  },\n  left: {\n    wrap: 'justify-start',\n    panel: 'h-full w-full border-r sm:rounded-r-2xl',\n    hidden: '-translate-x-full',\n  },\n  bottom: {\n    wrap: 'items-end',\n    panel: 'max-h-[90svh] w-full rounded-t-2xl border-t',\n    hidden: 'translate-y-full',\n  },\n}\n\nconst widths = { sm: 'sm:max-w-sm', md: 'sm:max-w-md', lg: 'sm:max-w-xl', xl: 'sm:max-w-3xl' }\n\nexport type DrawerProps = {\n  open: boolean\n  onOpenChange: (open: boolean) => void\n  title: React.ReactNode\n  description?: React.ReactNode\n  actions?: React.ReactNode\n  footer?: React.ReactNode\n  side?: keyof typeof sides\n  size?: keyof typeof widths\n  dismissible?: boolean\n  initialFocus?: React.RefObject<HTMLElement | null>\n  closeLabel?: string\n  className?: string\n  children?: React.ReactNode\n}\n\nexport function Drawer({\n  open,\n  onOpenChange,\n  title,\n  description,\n  actions,\n  footer,\n  side = 'right',\n  size = 'md',\n  dismissible = true,\n  initialFocus,\n  closeLabel = 'Close',\n  className,\n  children,\n}: DrawerProps) {\n  const titleId = useId()\n  const descriptionId = useId()\n  const { present, visible } = usePresence(open, 220)\n  const { panel } = useModal({\n    open,\n    onClose: () => onOpenChange(false),\n    dismissible,\n    initialFocus,\n  })\n  const s = sides[side]\n\n  if (!present || typeof document === 'undefined') return null\n\n  return createPortal(\n    <div className={cn('fixed inset-0 z-[150] flex', s.wrap)}>\n      <div\n        aria-hidden\n        className={cn(\n          'absolute inset-0 bg-black/40 transition-opacity duration-200 motion-reduce:transition-none',\n          visible ? 'opacity-100' : 'opacity-0',\n        )}\n        onPointerDown={() => dismissible && onOpenChange(false)}\n      />\n      <div\n        ref={panel}\n        role=\"dialog\"\n        aria-modal=\"true\"\n        aria-labelledby={titleId}\n        aria-describedby={description ? descriptionId : undefined}\n        tabIndex={-1}\n        className={cn(\n          'relative flex flex-col bg-card text-card-foreground shadow-(--shadow-overlay) transition-transform duration-200 ease-out outline-none motion-reduce:transition-none',\n          s.panel,\n          side !== 'bottom' && widths[size],\n          visible ? 'translate-none' : s.hidden,\n          className,\n        )}\n      >\n        {side === 'bottom' && (\n          <span aria-hidden className=\"mx-auto mt-2 h-1 w-10 shrink-0 rounded-full bg-muted\" />\n        )}\n        <header className=\"flex items-start gap-3 border-b px-5 py-4\">\n          <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\n            <h2 id={titleId} className=\"truncate text-base font-semibold\">\n              {title}\n            </h2>\n            {description && (\n              <p id={descriptionId} className=\"text-sm text-muted-foreground\">\n                {description}\n              </p>\n            )}\n          </div>\n          {actions && <div className=\"flex shrink-0 items-center gap-1.5\">{actions}</div>}\n          <button\n            type=\"button\"\n            aria-label={closeLabel}\n            onClick={() => onOpenChange(false)}\n            className=\"-mr-2 flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-muted hover:text-foreground [&_svg]:size-4\"\n          >\n            <X />\n          </button>\n        </header>\n        <div className=\"min-h-0 flex-1 overflow-y-auto px-5 py-4\">{children}</div>\n        {footer && (\n          <footer className=\"flex flex-wrap items-center justify-end gap-2 border-t px-5 py-3\">\n            {footer}\n          </footer>\n        )}\n      </div>\n    </div>,\n    document.body,\n  )\n}\n",
      "type": "registry:component",
      "target": "components/dashboard/drawer.tsx"
    }
  ],
  "meta": {
    "scenario": "dashboard",
    "kind": "components"
  },
  "categories": [
    "dashboard",
    "overlays"
  ],
  "type": "registry:component"
}