{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sheet",
  "type": "registry:ui",
  "title": "Sheet",
  "description": "A modal side sheet from the inline end: right in English, left in Arabic. Traps focus and swipes back to close.",
  "registryDependencies": [
    "https://dualkit.dev/r/base.json"
  ],
  "files": [
    {
      "path": "components/Sheet.tsx",
      "type": "registry:ui",
      "target": "components/dualkit/Sheet.tsx",
      "content": "import { useEffect, useId, useRef, type KeyboardEvent, type ReactNode } from 'react'\nimport { cx } from './direction'\nimport { Icon } from './icons'\nimport { useSwipeDismiss } from './useSwipeDismiss'\n\nexport type SheetProps = {\n  open: boolean\n  onClose: () => void\n  title: ReactNode\n  children: ReactNode\n  footer?: ReactNode\n  /** The close button's name for screen readers, in the page language. */\n  closeLabel?: string\n  className?: string\n}\n\nconst FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])'\n\n/**\n * A modal side sheet. It opens from the inline end (right in English, left in Arabic),\n * keeps focus inside, closes on Escape, the scrim or a swipe back towards its edge,\n * and gives focus back to whatever opened it. It renders in place, so it keeps the\n * dir and lang of the subtree it sits in.\n */\nexport function Sheet({ open, onClose, title, children, footer, closeLabel = 'Close', className }: SheetProps) {\n  const panel = useRef<HTMLDivElement>(null)\n  const titleId = useId()\n  const swipe = useSwipeDismiss(onClose)\n\n  useEffect(() => {\n    if (!open) return\n    const opener = document.activeElement as HTMLElement | null\n    const overflow = document.body.style.overflow\n    document.body.style.overflow = 'hidden'\n    panel.current?.querySelector<HTMLElement>(FOCUSABLE)?.focus()\n    return () => {\n      document.body.style.overflow = overflow\n      opener?.focus?.()\n    }\n  }, [open])\n\n  if (!open) return null\n\n  const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n    if (e.key === 'Escape') {\n      e.stopPropagation()\n      onClose()\n      return\n    }\n    if (e.key !== 'Tab' || !panel.current) return\n    const items = [...panel.current.querySelectorAll<HTMLElement>(FOCUSABLE)]\n    const first = items[0], last = items[items.length - 1]\n    if (!first || !last) return\n    if (e.shiftKey && document.activeElement === first) { e.preventDefault(); last.focus() }\n    else if (!e.shiftKey && document.activeElement === last) { e.preventDefault(); first.focus() }\n  }\n\n  return (\n    <div className={cx('dk-sheet', className)} onKeyDown={onKeyDown}>\n      <div className=\"dk-sheet__scrim\" aria-hidden=\"true\" onClick={onClose} />\n      <div ref={panel} role=\"dialog\" aria-modal=\"true\" aria-labelledby={titleId}\n        className={cx('dk-sheet__panel', swipe.dragging && 'dk-is-dragging')}\n        style={swipe.offset ? { translate: `${swipe.offset}px 0` } : undefined} {...swipe.handlers}>\n        <div className=\"dk-sheet__header\">\n          <h2 id={titleId} className=\"dk-title\">{title}</h2>\n          <button type=\"button\" className=\"dk-sheet__close\" aria-label={closeLabel} onClick={onClose}><Icon name=\"close\" /></button>\n        </div>\n        <div className=\"dk-sheet__body\">{children}</div>\n        {footer != null && <div className=\"dk-sheet__footer\">{footer}</div>}\n      </div>\n    </div>\n  )\n}\n\n/** A label and value on one line. Identifiers such as an IBAN go in mono and stay left to right. */\nexport function SheetRow({ label, value, mono = false }: { label: ReactNode; value: ReactNode; mono?: boolean }) {\n  return (\n    <div className=\"dk-sheet__row\">\n      <span className=\"dk-body dk-secondary\">{label}</span>\n      {mono ? <span className=\"dk-mono\" dir=\"ltr\">{value}</span> : <bdi className=\"dk-body\">{value}</bdi>}\n    </div>\n  )\n}\n"
    }
  ]
}
