{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "alert-dialog",
  "type": "registry:ui",
  "title": "Alert Dialog",
  "description": "A confirmation dialog that cannot be dismissed by accident: focus starts on Cancel, a click outside does nothing, the confirm button names the action. Built on Dialog.",
  "dependencies": [],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/button.json",
    "https://ui.klarhimmel.com/r/dialog.json",
    "https://ui.klarhimmel.com/r/theme.json"
  ],
  "files": [
    {
      "path": "src/ui/alert-dialog.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/ui/alert-dialog.tsx",
      "content": "import type { ReactNode } from 'react';\nimport { Button } from './button';\nimport { Dialog, DialogClose } from './dialog';\n\nexport interface AlertDialogProps {\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  /** The element that opens it (a Button). Omit for a controlled dialog. */\n  trigger?: ReactNode;\n  /** Required: the question, written as one (\"Delete the Garden room?\"). */\n  title: string;\n  /** What happens if they say yes. Read out with the title. */\n  description: string;\n  /** The label of the yes button. Name the action (\"Delete room\"), never \"OK\". */\n  confirmLabel: string;\n  cancelLabel?: string;\n  /** Called when the confirm button is pressed; the dialog closes after it. */\n  onConfirm: () => void;\n  /** Styles the confirm button in the danger colour. */\n  destructive?: boolean;\n}\n\n/**\n * A confirmation that cannot be dismissed by accident: role=alertdialog, a click outside does nothing, Escape cancels, and focus starts on Cancel.\n * Built on Dialog. Two buttons, the question in the title and the consequence in the description.\n */\nexport function AlertDialog({ confirmLabel, cancelLabel = 'Cancel', onConfirm, destructive, ...rest }: AlertDialogProps) {\n  return (\n    <Dialog\n      alert\n      {...rest}\n      footer={\n        <>\n          <DialogClose><Button variant=\"secondary\" data-kh-autofocus=\"\">{cancelLabel}</Button></DialogClose>\n          <DialogClose>\n            <Button onClick={onConfirm} className={destructive ? 'bg-kh-danger text-kh-on-ink hover:bg-kh-danger hover:brightness-95 active:bg-kh-danger' : undefined}>\n              {confirmLabel}\n            </Button>\n          </DialogClose>\n        </>\n      }\n    />\n  );\n}\n"
    }
  ]
}
