{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sheets",
  "title": "Sheets",
  "description": "Promise-based sheet registry: await openSheet(key, props) for a typed result, with lazy-loaded contents, stacking, minimizing and draft retention.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "button",
    "input",
    "sheet"
  ],
  "files": [
    {
      "path": "components/dentil/sheets/contents/edit-details.tsx",
      "content": "'use client';\n\nimport type { ReactNode } from 'react';\n\nimport { Button } from '@/components/ui/button';\nimport { Input } from '@/components/ui/input';\nimport { SheetDescription, SheetFooter, SheetHeader, SheetTitle } from '@/components/ui/sheet';\n\nimport type { SheetContentProps } from '../types';\nimport { useSheetDraft } from '../use-sheet-draft';\n\ninterface Details {\n  name: string;\n  notes: string;\n}\n\ntype EditDetailsSheetProps = SheetContentProps<Details> & {\n  title?: string;\n  description?: string;\n  /** Starting values. A retained draft takes precedence. */\n  defaultValues?: Partial<Details>;\n  /** Extra controls in the footer, for example a button that opens another sheet. */\n  actions?: ReactNode;\n};\n\nexport default function EditDetailsSheet({\n  sheetId,\n  close,\n  title = 'Edit details',\n  description,\n  defaultValues,\n  actions,\n}: EditDetailsSheetProps) {\n  const [details, setDetails] = useSheetDraft<Details>(sheetId, () => ({\n    name: defaultValues?.name ?? '',\n    notes: defaultValues?.notes ?? '',\n  }));\n\n  return (\n    <form\n      className=\"flex flex-1 flex-col\"\n      onSubmit={(event) => {\n        event.preventDefault();\n        close(details);\n      }}>\n      <SheetHeader>\n        <SheetTitle>{title}</SheetTitle>\n        {description && <SheetDescription>{description}</SheetDescription>}\n      </SheetHeader>\n      <div className=\"flex flex-col gap-4 px-4\">\n        <label className=\"flex flex-col gap-2 text-sm font-medium\">\n          Name\n          <Input\n            value={details.name}\n            onChange={(event) => setDetails((prev) => ({ ...prev, name: event.target.value }))}\n            required\n            autoFocus\n          />\n        </label>\n        <label className=\"flex flex-col gap-2 text-sm font-medium\">\n          Notes\n          <textarea\n            value={details.notes}\n            onChange={(event) => setDetails((prev) => ({ ...prev, notes: event.target.value }))}\n            rows={5}\n            className=\"border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 dark:bg-input/30 rounded-md border bg-transparent px-3 py-2 text-sm font-normal shadow-xs outline-none focus-visible:ring-[3px]\"\n          />\n        </label>\n      </div>\n      <SheetFooter className=\"flex-row justify-end\">\n        {actions && <div className=\"mr-auto\">{actions}</div>}\n        <Button type=\"button\" variant=\"outline\" onClick={() => close()}>\n          Cancel\n        </Button>\n        <Button type=\"submit\">Save</Button>\n      </SheetFooter>\n    </form>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/dentil/sheets/contents/edit-details.tsx"
    },
    {
      "path": "components/dentil/sheets/context.tsx",
      "content": "'use client';\n\nimport { createContext, use, useEffect, useMemo, useState, type ReactNode } from 'react';\n\nimport { SheetHost } from './host';\nimport { MinimizedSheetsDock } from './minimized-dock';\nimport type { SheetKey, SheetPropsMap, SheetReturnMap } from './registry';\nimport type { CloseReason, SheetOptions, SheetSize, SheetStacking } from './types';\n\n/** Matches the sheet's exit animation, so closing sheets slide out before they unmount. */\nconst EXIT_DURATION_MS = 300;\n\nexport interface SheetDescriptor {\n  id: string;\n  key: SheetKey;\n  props: object;\n  size: SheetSize;\n  stacking: SheetStacking;\n  rounded: boolean;\n  title?: string;\n  dismissible: boolean;\n  minimizable: boolean;\n  /** False while the sheet plays its exit animation. */\n  open: boolean;\n  minimized: boolean;\n  close: (value?: unknown, reason?: CloseReason) => void;\n}\n\n/** Props are optional when the sheet has no required props. */\ntype OpenSheetArgs<K extends SheetKey> =\n  Partial<SheetPropsMap[K]> extends SheetPropsMap[K]\n    ? [props?: SheetPropsMap[K], options?: SheetOptions]\n    : [props: SheetPropsMap[K], options?: SheetOptions];\n\nexport interface SheetContextValue {\n  /** Open, minimized and closing sheets, bottom to top. */\n  stack: SheetDescriptor[];\n  /**\n   * Opens a sheet on top of the stack. Resolves with the value it closes with, or `undefined` if dismissed.\n   * If a sheet with the same key is already open, it's restored and its pending result is returned instead, unless\n   * the `multiple` option is set.\n   */\n  openSheet<K extends SheetKey>(key: K, ...args: OpenSheetArgs<K>): Promise<SheetReturnMap[K] | undefined>;\n  closeSheet(id: string, value?: unknown, reason?: CloseReason): void;\n  minimizeSheet(id: string): void;\n  restoreSheet(id: string): void;\n}\n\nexport interface SheetCloseInfo {\n  /** `undefined` when the sheet was dismissed. */\n  value: unknown;\n  reason: CloseReason;\n  durationMs: number;\n  /** Whether the sheet was minimized at any point. */\n  minimized: boolean;\n}\n\ninterface SheetProviderProps {\n  children: ReactNode;\n  /** Called whenever a sheet opens, e.g. for analytics. */\n  onOpen?: (key: SheetKey) => void;\n  /** Called whenever a sheet closes, e.g. for analytics. */\n  onClose?: (key: SheetKey, info: SheetCloseInfo) => void;\n}\n\ntype Callbacks = Pick<SheetProviderProps, 'onOpen' | 'onClose'>;\ntype SetStack = (update: (prev: SheetDescriptor[]) => SheetDescriptor[]) => void;\n\nexport interface SheetDrafts {\n  get(sheetId: string): unknown;\n  set(sheetId: string, value: unknown): void;\n  clear(sheetId: string): void;\n}\n\ninterface PendingSheet {\n  key: SheetKey;\n  openedAt: number;\n  retainDraft: boolean;\n  wasMinimized: boolean;\n  promise: Promise<unknown>;\n  resolve: (value: unknown) => void;\n}\n\nconst SheetContext = createContext<SheetContextValue | null>(null);\nconst SheetDraftsContext = createContext<SheetDrafts | null>(null);\n\nexport function useSheet(): SheetContextValue {\n  const context = use(SheetContext);\n  if (!context) {\n    throw new Error('useSheet must be used within a SheetProvider');\n  }\n  return context;\n}\n\nexport function useSheetDrafts(): SheetDrafts {\n  const context = use(SheetDraftsContext);\n  if (!context) {\n    throw new Error('useSheetDraft must be used within a SheetProvider');\n  }\n  return context;\n}\n\n// Created once per provider, so every action keeps a stable identity.\nfunction createSheetActions(setStack: SetStack) {\n  let callbacks: Callbacks = {};\n  const pending = new Map<string, PendingSheet>();\n  const drafts = new Map<string, unknown>();\n  const timers = new Set<ReturnType<typeof setTimeout>>();\n\n  // Retained drafts are stored by key so the next sheet with that key picks them up; others by sheet id.\n  const draftKey = (sheetId: string) => {\n    const sheet = pending.get(sheetId);\n    return sheet?.retainDraft ? `key:${sheet.key}` : sheetId;\n  };\n\n  const updateSheet = (id: string, patch: Partial<SheetDescriptor>) =>\n    setStack((prev) => prev.map((descriptor) => (descriptor.id === id ? { ...descriptor, ...patch } : descriptor)));\n\n  const closeSheet = (id: string, value?: unknown, reason: CloseReason = 'button') => {\n    const sheet = pending.get(id);\n    // Already closed: a second close (e.g. a button and Escape in the same tick) is a no-op.\n    if (!sheet) return;\n\n    if (!(sheet.retainDraft && reason !== 'button' && value === undefined)) {\n      drafts.delete(draftKey(id));\n    }\n    drafts.delete(id);\n    pending.delete(id);\n\n    sheet.resolve(value);\n    callbacks.onClose?.(sheet.key, {\n      value,\n      reason,\n      durationMs: Date.now() - sheet.openedAt,\n      minimized: sheet.wasMinimized,\n    });\n\n    updateSheet(id, { open: false });\n    const timer = setTimeout(() => {\n      timers.delete(timer);\n      setStack((prev) => prev.filter((descriptor) => descriptor.id !== id));\n    }, EXIT_DURATION_MS);\n    timers.add(timer);\n  };\n\n  const minimizeSheet = (id: string) => {\n    const sheet = pending.get(id);\n    if (sheet) sheet.wasMinimized = true;\n    updateSheet(id, { minimized: true });\n  };\n\n  const restoreSheet = (id: string) => {\n    // A minimized sheet is unmounted, so restoring remounts it on top: move it to the top of the stack to match.\n    setStack((prev) => {\n      const descriptor = prev.find((d) => d.id === id);\n      if (!descriptor?.minimized) return prev;\n      return [...prev.filter((d) => d.id !== id), { ...descriptor, minimized: false }];\n    });\n  };\n\n  const openSheet = <K extends SheetKey>(key: K, ...args: OpenSheetArgs<K>) => {\n    const [props, options] = args;\n    const existing = options?.multiple ? undefined : [...pending.entries()].find(([, sheet]) => sheet.key === key);\n    if (existing) {\n      const [id, sheet] = existing;\n      restoreSheet(id);\n      return sheet.promise as Promise<SheetReturnMap[K] | undefined>;\n    }\n\n    const id = crypto.randomUUID();\n    let resolve!: (value: unknown) => void;\n    const promise = new Promise<unknown>((r) => {\n      resolve = r;\n    });\n\n    pending.set(id, {\n      key,\n      openedAt: Date.now(),\n      retainDraft: options?.retainDraft ?? false,\n      wasMinimized: false,\n      promise,\n      resolve,\n    });\n    callbacks.onOpen?.(key);\n\n    const stacking = options?.stacking ?? 'inset';\n    const descriptor: SheetDescriptor = {\n      id,\n      key,\n      props: props ?? {},\n      size: options?.size ?? 'default',\n      stacking,\n      rounded: options?.rounded ?? stacking === 'inset',\n      title: options?.title,\n      dismissible: options?.dismissible ?? true,\n      minimizable: options?.minimizable ?? false,\n      open: true,\n      minimized: false,\n      close: (value, reason) => closeSheet(id, value, reason),\n    };\n    setStack((prev) => [...prev, descriptor]);\n\n    return promise as Promise<SheetReturnMap[K] | undefined>;\n  };\n\n  const sheetDrafts: SheetDrafts = {\n    get: (sheetId) => drafts.get(draftKey(sheetId)),\n    set: (sheetId, value) => {\n      if (pending.has(sheetId)) drafts.set(draftKey(sheetId), value);\n    },\n    clear: (sheetId) => {\n      drafts.delete(draftKey(sheetId));\n    },\n  };\n\n  const setCallbacks = (next: Callbacks) => {\n    callbacks = next;\n  };\n\n  const dispose = () => {\n    timers.forEach((timer) => clearTimeout(timer));\n    timers.clear();\n  };\n\n  return { openSheet, closeSheet, minimizeSheet, restoreSheet, drafts: sheetDrafts, setCallbacks, dispose };\n}\n\nexport function SheetProvider({ children, onOpen, onClose }: SheetProviderProps) {\n  const [stack, setStack] = useState<SheetDescriptor[]>([]);\n  const [{ openSheet, closeSheet, minimizeSheet, restoreSheet, drafts, setCallbacks, dispose }] = useState(() =>\n    createSheetActions(setStack)\n  );\n\n  useEffect(() => {\n    setCallbacks({ onOpen, onClose });\n  }, [setCallbacks, onOpen, onClose]);\n\n  useEffect(() => dispose, [dispose]);\n\n  const value = useMemo<SheetContextValue>(\n    () => ({ stack, openSheet, closeSheet, minimizeSheet, restoreSheet }),\n    [stack, openSheet, closeSheet, minimizeSheet, restoreSheet]\n  );\n\n  return (\n    <SheetContext value={value}>\n      <SheetDraftsContext value={drafts}>\n        {children}\n        <SheetHost stack={stack} onMinimize={minimizeSheet} />\n        <MinimizedSheetsDock stack={stack} onRestore={restoreSheet} />\n      </SheetDraftsContext>\n    </SheetContext>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/dentil/sheets/context.tsx"
    },
    {
      "path": "components/dentil/sheets/host.tsx",
      "content": "'use client';\n\nimport { Suspense } from 'react';\n\nimport type { SheetDescriptor } from './context';\nimport { sheetRegistry } from './registry';\nimport { SheetLoading, SheetShell } from './shell';\n\nexport function SheetHost({ stack, onMinimize }: { stack: SheetDescriptor[]; onMinimize: (id: string) => void }) {\n  // Minimized sheets unmount; closing sheets still render (for the exit animation) but don't count towards depth.\n  const visible = stack.filter((descriptor) => !descriptor.minimized);\n  const open = visible.filter((descriptor) => descriptor.open);\n\n  return visible.map((descriptor) => {\n    const Content = sheetRegistry[descriptor.key];\n    const index = open.indexOf(descriptor);\n    const depth = index === -1 ? 0 : open.length - 1 - index;\n\n    return (\n      <SheetShell\n        key={descriptor.id}\n        descriptor={descriptor}\n        depth={depth}\n        onMinimize={() => onMinimize(descriptor.id)}>\n        <Suspense fallback={<SheetLoading />}>\n          <Content {...descriptor.props} sheetId={descriptor.id} close={descriptor.close} />\n        </Suspense>\n      </SheetShell>\n    );\n  });\n}\n",
      "type": "registry:component",
      "target": "components/dentil/sheets/host.tsx"
    },
    {
      "path": "components/dentil/sheets/index.ts",
      "content": "export { SheetProvider, useSheet } from './context';\nexport type { SheetCloseInfo, SheetContextValue, SheetDescriptor } from './context';\nexport { sheetRegistry } from './registry';\nexport type { SheetKey, SheetPropsMap, SheetReturnMap } from './registry';\nexport type { CloseReason, SheetContentProps, SheetOptions, SheetSize, SheetStacking } from './types';\nexport { useSheetDraft } from './use-sheet-draft';\n",
      "type": "registry:lib",
      "target": "components/dentil/sheets/index.ts"
    },
    {
      "path": "components/dentil/sheets/minimized-dock.tsx",
      "content": "'use client';\n\nimport { Minus, X } from 'lucide-react';\n\nimport { Button } from '@/components/ui/button';\n\nimport type { SheetDescriptor } from './context';\nimport { sheetMaxWidths } from './shell';\n\n/** `billing.invoices-create` → `Billing invoices create` */\nfunction humanize(key: string) {\n  const text = key\n    .split(/[.\\-_]/)\n    .filter(Boolean)\n    .join(' ')\n    .toLowerCase();\n  return text.charAt(0).toUpperCase() + text.slice(1);\n}\n\ninterface MinimizedSheetsDockProps {\n  stack: SheetDescriptor[];\n  onRestore: (id: string) => void;\n}\n\nexport function MinimizedSheetsDock({ stack, onRestore }: MinimizedSheetsDockProps) {\n  const minimized = stack.filter((sheet) => sheet.minimized && sheet.open);\n  if (minimized.length === 0) return null;\n\n  // Sit beside the open sheet rather than underneath it. The stock sheet is 75vw wide up to its max width.\n  const top = [...stack].reverse().find((sheet) => !sheet.minimized && sheet.open);\n  const width = top ? sheetMaxWidths[top.size] : 0;\n  const right = !top ? '1rem' : width === Infinity ? 'calc(75vw + 1rem)' : `calc(min(75vw, ${width}px) + 1rem)`;\n\n  // Number repeated titles so they can be told apart.\n  const seen = new Map<string, number>();\n  const labelled = minimized.map((sheet) => {\n    const title = sheet.title ?? humanize(sheet.key);\n    const count = seen.get(title) ?? 0;\n    seen.set(title, count + 1);\n    return { sheet, label: count === 0 ? title : `${title} (${count + 1})` };\n  });\n\n  return (\n    <div\n      data-slot=\"sheet-dock\"\n      // Modal sheets disable pointer events on the body, so the dock opts back in.\n      className=\"pointer-events-auto fixed bottom-4 z-50 flex flex-col gap-2 transition-[right] duration-200\"\n      style={{ right }}>\n      {labelled.map(({ sheet, label }) => (\n        <div\n          key={sheet.id}\n          className=\"bg-card text-card-foreground flex items-center gap-2 rounded-md border py-1.5 pr-1.5 pl-3 shadow-lg transition-shadow hover:shadow-xl\">\n          <button\n            type=\"button\"\n            onClick={() => onRestore(sheet.id)}\n            className=\"flex flex-1 items-center gap-2 text-left text-sm font-medium\">\n            <Minus className=\"text-muted-foreground size-4\" />\n            {label}\n          </button>\n          <Button\n            variant=\"ghost\"\n            size=\"icon-xs\"\n            className=\"hover:bg-destructive/10 hover:text-destructive\"\n            aria-label={`Close ${label}`}\n            onClick={() => sheet.close()}>\n            <X />\n          </Button>\n        </div>\n      ))}\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/dentil/sheets/minimized-dock.tsx"
    },
    {
      "path": "components/dentil/sheets/registry.tsx",
      "content": "import { lazy, type ComponentProps, type ComponentType, type LazyExoticComponent } from 'react';\n\n// Add a sheet: write a component typed with SheetContentProps<TReturn> in ./contents, then add a loader here.\n// Each entry is code-split, so the sheet's module (and its heavy deps) is only downloaded when it's first opened.\nconst sheetLoaders = {\n  'edit-details': () => import('./contents/edit-details'),\n} as const;\n\n// Everything below is inferred from the loaders.\n\nexport type SheetKey = keyof typeof sheetLoaders;\n\ntype SheetComponent<K extends SheetKey> = Awaited<ReturnType<(typeof sheetLoaders)[K]>>['default'];\n\n/** Props you pass to `openSheet(key, props)`: the component's props minus the injected ones. */\nexport type SheetPropsMap = {\n  [K in SheetKey]: Omit<ComponentProps<SheetComponent<K>>, 'sheetId' | 'close'>;\n};\n\n/** What `openSheet(key)` resolves to when the sheet closes with a value. */\nexport type SheetReturnMap = {\n  [K in SheetKey]: ComponentProps<SheetComponent<K>> extends { close: (value?: infer R) => void } ? R : never;\n};\n\nexport const sheetRegistry = Object.fromEntries(\n  Object.entries(sheetLoaders).map(([key, loader]) => [\n    key,\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    lazy(loader as () => Promise<{ default: ComponentType<any> }>),\n  ])\n) as {\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  [K in SheetKey]: LazyExoticComponent<ComponentType<any>>;\n};\n",
      "type": "registry:component",
      "target": "components/dentil/sheets/registry.tsx"
    },
    {
      "path": "components/dentil/sheets/shell.tsx",
      "content": "'use client';\n\nimport { AlertTriangle, Loader2, RefreshCw } from 'lucide-react';\nimport * as React from 'react';\n\nimport { Button } from '@/components/ui/button';\nimport { Sheet, SheetContent, SheetDescription, SheetTitle } from '@/components/ui/sheet';\nimport { cn } from '@/lib/utils';\n\nimport type { SheetDescriptor } from './context';\nimport type { CloseReason, SheetSize } from './types';\n\n// `default` keeps the stock sheet width (sm:max-w-sm). Newer styles (radix-*, base-*) set it with a `data-[side=right]:`\n// variant, which outranks a plain `sm:` class, so each size sets both and tailwind-merge drops the stock one.\nconst sizeClasses: Record<SheetSize, string> = {\n  default: '',\n  md: 'sm:max-w-xl data-[side=right]:sm:max-w-xl',\n  lg: 'sm:max-w-2xl data-[side=right]:sm:max-w-2xl',\n  xl: 'sm:max-w-4xl data-[side=right]:sm:max-w-4xl',\n  full: 'sm:max-w-full data-[side=right]:sm:max-w-full',\n};\n\n/** Max width in px for each size, used to place the minimized dock beside the open sheet. */\nexport const sheetMaxWidths: Record<SheetSize, number> = {\n  default: 384,\n  md: 576,\n  lg: 672,\n  xl: 896,\n  full: Infinity,\n};\n\n// Overlays (modals, popovers, menus, selects) portal to the body, so interacting with one stacked on top of a sheet\n// counts as an outside interaction on the sheet. These markers detect that case so the sheet underneath stays open.\nconst STACKED_OVERLAY_SELECTOR = [\n  '[data-slot=\"dialog-content\"]',\n  '[data-slot=\"dialog-overlay\"]',\n  '[data-slot=\"popover-content\"]',\n  '[data-slot=\"dropdown-menu-content\"]',\n  '[data-slot=\"context-menu-content\"]',\n  '[data-slot=\"select-content\"]',\n  '[data-slot=\"sheet-dock\"]',\n].join(',');\n\ninterface SheetShellProps {\n  descriptor: SheetDescriptor;\n  /** 0 for the top sheet, 1 for the one beneath it, and so on. */\n  depth: number;\n  onMinimize: () => void;\n  children: React.ReactNode;\n}\n\ninterface Dismissal {\n  reason: CloseReason;\n  target: Element | null;\n}\n\nconst baseUIReasons: Record<string, CloseReason> = {\n  'close-press': 'button',\n  'escape-key': 'escape',\n  'outside-press': 'backdrop',\n};\n\nfunction toElement(target: EventTarget | null | undefined) {\n  return target instanceof Element ? target : null;\n}\n\n/**\n * Why the sheet is being asked to close. Base UI passes the reason and event to `onOpenChange`. Radix passes nothing,\n * so for Radix this records the last pointer or key press, in the capture phase so it runs before Radix's own listeners.\n */\nfunction useDismissal(id: string, enabled: boolean) {\n  const last = React.useRef<Dismissal | null>(null);\n\n  React.useEffect(() => {\n    if (!enabled) return;\n    const onPointerDown = (event: PointerEvent) => {\n      const target = toElement(event.target);\n      const inside = target?.closest('[data-sheet-id]')?.getAttribute('data-sheet-id') === id;\n      last.current = { reason: inside ? 'button' : 'backdrop', target };\n    };\n    const onKeyDown = (event: KeyboardEvent) => {\n      last.current = { reason: event.key === 'Escape' ? 'escape' : 'button', target: toElement(event.target) };\n    };\n    window.addEventListener('pointerdown', onPointerDown, true);\n    window.addEventListener('keydown', onKeyDown, true);\n    return () => {\n      window.removeEventListener('pointerdown', onPointerDown, true);\n      window.removeEventListener('keydown', onKeyDown, true);\n    };\n  }, [id, enabled]);\n\n  return (details?: { reason?: string; event?: Event }): Dismissal | null => {\n    if (!details?.reason) return last.current;\n    const reason = baseUIReasons[details.reason];\n    return reason ? { reason, target: toElement(details.event?.target) } : null;\n  };\n}\n\nexport function SheetShell({ descriptor, depth, onMinimize, children }: SheetShellProps) {\n  const { id, open, size, stacking, rounded, dismissible, minimizable, close } = descriptor;\n  const interactive = open && depth === 0;\n  const getDismissal = useDismissal(id, interactive);\n\n  // `open` is controlled, so returning without calling `close` keeps the sheet open.\n  const onOpenChange = (next: boolean, details?: { reason?: string; event?: Event }) => {\n    if (next || !interactive) return;\n    const dismissal = getDismissal(details);\n    if (!dismissal) return;\n    const { reason, target } = dismissal;\n    if (reason !== 'button') {\n      if (target?.closest(STACKED_OVERLAY_SELECTOR) || !dismissible) return;\n      if (reason === 'backdrop' && minimizable) {\n        onMinimize();\n        return;\n      }\n    }\n    close(undefined, reason);\n  };\n\n  return (\n    <Sheet open={open} onOpenChange={onOpenChange}>\n      <SheetContent\n        side=\"right\"\n        showCloseButton={interactive}\n        data-sheet-id={id}\n        className={cn('overflow-y-auto', rounded && 'rounded-l-xl', sizeClasses[size])}\n        // Sheets beneath the top one recede. The slide animation uses `transform` (Radix) or `translate` (Base UI), so\n        // this uses the separate `scale` property and the `right` offset. Base UI sheets slide and fade with transitions,\n        // which an inline `transition` would otherwise replace.\n        style={{\n          scale: depth > 0 && stacking === 'inset' ? 1 - depth * 0.01 : undefined,\n          right: depth > 0 ? depth * 12 : undefined,\n          transformOrigin: 'left center',\n          transition:\n            'scale 150ms ease-out, right 150ms ease-out, translate 200ms ease-in-out, opacity 200ms ease-in-out',\n        }}>\n        <SheetErrorBoundary onClose={() => close()}>{children}</SheetErrorBoundary>\n      </SheetContent>\n    </Sheet>\n  );\n}\n\n/** Suspense fallback while a sheet's code loads. Includes a hidden title and description for screen readers. */\nexport function SheetLoading() {\n  return (\n    <div className=\"flex flex-1 items-center justify-center\">\n      <SheetTitle className=\"sr-only\">Loading</SheetTitle>\n      <SheetDescription className=\"sr-only\">Loading sheet</SheetDescription>\n      <Loader2 className=\"text-muted-foreground size-5 animate-spin\" />\n    </div>\n  );\n}\n\ninterface SheetErrorBoundaryProps {\n  children: React.ReactNode;\n  onClose: () => void;\n}\n\nclass SheetErrorBoundary extends React.Component<SheetErrorBoundaryProps, { error: Error | null }> {\n  state: { error: Error | null } = { error: null };\n\n  static getDerivedStateFromError(error: Error) {\n    return { error };\n  }\n\n  componentDidCatch(error: Error, info: React.ErrorInfo) {\n    console.error('[Sheet]', error, info.componentStack);\n  }\n\n  render() {\n    const { error } = this.state;\n    if (!error) return this.props.children;\n\n    return (\n      <div role=\"alert\" className=\"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center\">\n        <div className=\"bg-destructive/10 text-destructive flex size-9 items-center justify-center rounded-full\">\n          <AlertTriangle className=\"size-4\" />\n        </div>\n        <div className=\"flex flex-col gap-1\">\n          <SheetTitle className=\"text-sm font-medium\">This sheet failed to render</SheetTitle>\n          <SheetDescription className=\"max-w-md text-xs\">\n            {error.message || 'An unexpected error occurred.'}\n          </SheetDescription>\n        </div>\n        <div className=\"flex items-center gap-2\">\n          <Button size=\"sm\" variant=\"outline\" onClick={() => this.setState({ error: null })}>\n            <RefreshCw className=\"size-3.5\" />\n            Try again\n          </Button>\n          <Button size=\"sm\" variant=\"ghost\" onClick={this.props.onClose}>\n            Dismiss\n          </Button>\n        </div>\n      </div>\n    );\n  }\n}\n",
      "type": "registry:component",
      "target": "components/dentil/sheets/shell.tsx"
    },
    {
      "path": "components/dentil/sheets/types.ts",
      "content": "export type SheetSize = 'default' | 'md' | 'lg' | 'xl' | 'full';\n\n/**\n * How a sheet recedes when another opens on top. `inset` scales it down so it floats with a gap above and below;\n * `flush` keeps it full height and only shifts it left.\n */\nexport type SheetStacking = 'inset' | 'flush';\n\n/** How a sheet was closed: the close button or `close()`, the Escape key, or a click outside. */\nexport type CloseReason = 'button' | 'escape' | 'backdrop';\n\nexport interface SheetOptions {\n  /** Max width from the sm breakpoint up. `default` keeps the stock sheet width. */\n  size?: SheetSize;\n  /** How this sheet recedes when another opens on top. Default `inset`. */\n  stacking?: SheetStacking;\n  /** Round the sheet's exposed corners. Defaults to true for `inset` stacking and false for `flush`. */\n  rounded?: boolean;\n  /** Label in the minimized dock. Defaults to the sheet key in sentence case. */\n  title?: string;\n  /** Set to false to ignore outside clicks and Escape. The close button and `close()` still work. Default true. */\n  dismissible?: boolean;\n  /** Clicking outside minimizes the sheet to a dock instead of closing it. */\n  minimizable?: boolean;\n  /**\n   * Allow more than one sheet with this key at a time. By default, opening a key that's already open restores that\n   * sheet and returns its pending result instead.\n   */\n  multiple?: boolean;\n  /**\n   * Keep the `useSheetDraft` state when the sheet is dismissed with Escape or an outside click, and restore it the\n   * next time a sheet with this key opens. Closing with the button or with a value clears it.\n   */\n  retainDraft?: boolean;\n}\n\n/**\n * Props every sheet content receives. Intersect with your own props; `TReturn` is what `openSheet` resolves to.\n *\n * ```tsx\n * type Props = SheetContentProps<{ id: string }> & { customerId: string };\n * ```\n */\nexport interface SheetContentProps<TReturn = void> {\n  sheetId: string;\n  /** Closes this sheet and resolves its `openSheet` promise. Call with no value to cancel. */\n  close: (value?: TReturn) => void;\n}\n",
      "type": "registry:lib",
      "target": "components/dentil/sheets/types.ts"
    },
    {
      "path": "components/dentil/sheets/use-sheet-draft.ts",
      "content": "'use client';\n\nimport { useCallback, useState } from 'react';\n\nimport { useSheetDrafts } from './context';\n\n/**\n * `useState` that survives the sheet being minimized, and (with the `retainDraft` option) being dismissed and\n * reopened. Returns the value, a setter and `clear`, which resets the stored draft (not the current value).\n */\nexport function useSheetDraft<T>(sheetId: string, initial: T | (() => T)) {\n  const drafts = useSheetDrafts();\n  const [value, setValue] = useState<T>(() => {\n    const stored = drafts.get(sheetId) as T | undefined;\n    if (stored !== undefined) return stored;\n    return typeof initial === 'function' ? (initial as () => T)() : initial;\n  });\n\n  const update = useCallback(\n    (next: T | ((prev: T) => T)) =>\n      setValue((prev) => {\n        const resolved = typeof next === 'function' ? (next as (prev: T) => T)(prev) : next;\n        drafts.set(sheetId, resolved);\n        return resolved;\n      }),\n    [drafts, sheetId]\n  );\n\n  const clear = useCallback(() => drafts.clear(sheetId), [drafts, sheetId]);\n\n  return [value, update, clear] as const;\n}\n",
      "type": "registry:lib",
      "target": "components/dentil/sheets/use-sheet-draft.ts"
    }
  ],
  "type": "registry:block"
}
