{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sheet",
  "type": "registry:ui",
  "title": "Sheet",
  "description": "A modal side panel (right, left or bottom) for filters, details or a cart: titled, focus-trapped, Escape closes. Built on Dialog.",
  "dependencies": [
    "lucide-react@^1.49.0",
    "radix-ui@^1.6.7"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/icon-button.json",
    "https://ui.klarhimmel.com/r/theme.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/ui/sheet.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/ui/sheet.tsx",
      "content": "import type { ReactNode } from 'react';\nimport { Dialog as D } from 'radix-ui';\nimport { X } from 'lucide-react';\nimport { ThemeRootScope, useThemeRoot } from '../lib/theme-root';\nimport { cn } from '../lib/utils';\nimport { IconButton } from './icon-button';\n\nexport interface SheetProps {\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  /** The element that opens it (a Button). Focus returns to it on close. */\n  trigger?: ReactNode;\n  /** Required: names the panel. */\n  title: string;\n  description?: string;\n  /** Which edge it slides from. On a narrow screen a left or right sheet takes the full width. */\n  side?: 'right' | 'left' | 'bottom';\n  children?: ReactNode;\n  /** Buttons, pinned under the body. */\n  footer?: ReactNode;\n  /** Replaces the title row (the title still names the panel for screen readers); it draws its own close (SheetClose). */\n  header?: ReactNode;\n  /** The body has no padding or gap: its content sets its own (a document page). */\n  flush?: boolean;\n  /** The close button's name for screen readers, in the page's language ('Stäng'). Default 'Close'. */\n  closeLabel?: string;\n  className?: string;\n}\n\nconst sides = {\n  right: 'inset-y-0 right-0 h-dvh w-[min(26rem,100vw)] border-l',\n  left: 'inset-y-0 left-0 h-dvh w-[min(26rem,100vw)] border-r',\n  bottom: 'inset-x-0 bottom-0 max-h-[85dvh] rounded-t-kh-xl border-t',\n};\n\n/** A side panel for a task that keeps the page in view: filters, details, a cart. Same behaviour as Dialog: modal, Escape closes, focus returns. */\nexport function Sheet({ open, defaultOpen, onOpenChange, trigger, ...panel }: SheetProps) {\n  return (\n    <ThemeRootScope>\n      <D.Root open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange}>\n        {trigger && <D.Trigger asChild>{trigger}</D.Trigger>}\n        <Panel {...panel} />\n      </D.Root>\n    </ThemeRootScope>\n  );\n}\n\nfunction Panel({ title, description, side = 'right', children, footer, header, flush, closeLabel = 'Close', className }: Omit<SheetProps, 'open' | 'defaultOpen' | 'onOpenChange' | 'trigger'>) {\n  const root = useThemeRoot();\n  return (\n    <D.Portal container={root}>\n      <D.Overlay className=\"fixed inset-0 z-50 bg-(--kh-scrim)\" />\n      <D.Content\n        tabIndex={-1}\n        data-side={side}\n        onOpenAutoFocus={(e) => {\n          e.preventDefault();\n          (e.currentTarget as HTMLElement).focus();\n        }}\n        // Escape inside an open Select or Combobox closes its list first, not the sheet.\n        onEscapeKeyDown={(e) => { if ((document.activeElement as HTMLElement | null)?.matches?.('[role=combobox][aria-expanded=true]')) e.preventDefault(); }}\n        className={cn('fixed z-50 flex flex-col overflow-hidden border-kh-line bg-kh-surface text-kh-ink shadow-kh-3 outline-none', !header && 'gap-4 pt-5', sides[side], className)}\n      >\n        {header ? <>\n          <D.Title className=\"sr-only\">{title}</D.Title>\n          {description ? <D.Description className=\"sr-only\">{description}</D.Description> : <D.Description className=\"sr-only\">{title}</D.Description>}\n          {header}\n        </> : <div className=\"flex items-start justify-between gap-4 px-5\">\n          <div className=\"flex flex-col gap-1\">\n            <D.Title className=\"text-kh-heading font-semibold\">{title}</D.Title>\n            {description ? <D.Description className=\"text-kh-small text-kh-muted\">{description}</D.Description> : <D.Description className=\"sr-only\">{title}</D.Description>}\n          </div>\n          <D.Close asChild>\n            <IconButton label={closeLabel} size=\"sm\" noTooltip className=\"-mr-2 -mt-1\">\n              <X aria-hidden className=\"size-4\" />\n            </IconButton>\n          </D.Close>\n        </div>}\n        <div className={cn('flex min-h-0 flex-1 flex-col overflow-y-auto text-kh-body', !flush && 'gap-4 px-5 pb-5')}>{children}</div>\n        {footer && <div className=\"flex flex-wrap justify-end gap-3 border-t border-kh-line bg-kh-surface px-5 py-4\">{footer}</div>}\n      </D.Content>\n    </D.Portal>\n  );\n}\n\n/** Closes the sheet it sits in. Wrap a footer Button. */\nexport function SheetClose({ children }: { children: ReactNode }) {\n  return <D.Close asChild>{children}</D.Close>;\n}\n"
    }
  ]
}
