{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "confirm-dialog",
  "title": "Confirm Dialog",
  "description": "Confirm Dialog from the Get IT Done design system.",
  "dependencies": [],
  "registryDependencies": [
    "https://zero-design.itdone.de/r/button.json",
    "https://zero-design.itdone.de/r/dialog.json",
    "https://zero-design.itdone.de/r/input.json",
    "https://zero-design.itdone.de/r/label.json",
    "https://zero-design.itdone.de/r/labels-context.json",
    "https://zero-design.itdone.de/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/ui/confirm-dialog.tsx",
      "content": "'use client';\n\nimport * as React from 'react';\n\nimport { Button } from '@/components/ui/button';\nimport {\n  Dialog,\n  DialogContent,\n  DialogDescription,\n  DialogFeaturedIcon,\n  DialogFooter,\n  DialogHeader,\n  DialogTitle,\n  DialogTrigger,\n} from '@/components/ui/dialog';\nimport { Input } from '@/components/ui/input';\nimport { Label } from '@/components/ui/label';\nimport { useLabels } from '@/components/ui/labels-context';\n\ninterface ConfirmDialogProps {\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  // Optional trigger element, rendered with asChild.\n  trigger?: React.ReactNode;\n  title: React.ReactNode;\n  description?: React.ReactNode;\n  // Optional body between the text and the buttons. Omit for the compact title, text and buttons layout.\n  children?: React.ReactNode;\n  // Optional featured icon beside the title, for example an alert icon.\n  icon?: React.ReactNode;\n  // `destructive` (default) renders the destructive confirm button, `primary` the brand confirm button.\n  tone?: 'destructive' | 'primary';\n  // When set, the confirm button stays disabled until the user typed exactly this value, for example the name.\n  confirmValue?: string;\n  // Label of the confirm input. Defaults to the provider text \"Type {value} to confirm\".\n  confirmInputLabel?: string;\n  confirmInputPlaceholder?: string;\n  // Button texts. Win over the provider text.\n  confirmLabel?: string;\n  cancelLabel?: string;\n  onConfirm: () => void;\n  // Disables the actions while the confirmation runs.\n  pending?: boolean;\n  className?: string;\n}\n\n// Modal Type Destructive right aligned (Figma): title, text, optional body and confirm input, right aligned actions.\nconst ConfirmDialog = ({\n  open: openProp,\n  defaultOpen = false,\n  onOpenChange,\n  trigger,\n  title,\n  description,\n  children,\n  icon,\n  tone = 'destructive',\n  confirmValue,\n  confirmInputLabel,\n  confirmInputPlaceholder,\n  confirmLabel,\n  cancelLabel,\n  onConfirm,\n  pending = false,\n  className,\n}: ConfirmDialogProps) => {\n  const l = useLabels({ confirm: confirmLabel, cancel: cancelLabel });\n  const inputId = React.useId();\n  const [inner, setInner] = React.useState(defaultOpen);\n  const [typed, setTyped] = React.useState('');\n  const open = openProp ?? inner;\n  const needsInput = confirmValue !== undefined;\n  const matches = !needsInput || typed === confirmValue;\n\n  const handleOpenChange = (next: boolean) => {\n    if (openProp === undefined) setInner(next);\n    if (!next) setTyped('');\n    onOpenChange?.(next);\n  };\n  const confirm = () => {\n    if (!matches || pending) return;\n    onConfirm();\n  };\n\n  return (\n    <Dialog open={open} onOpenChange={handleOpenChange}>\n      {trigger && <DialogTrigger asChild>{trigger}</DialogTrigger>}\n      <DialogContent size=\"sm\" className={className}>\n        <DialogHeader orientation={icon ? 'horizontal' : 'vertical'}>\n          {icon && <DialogFeaturedIcon tone={tone === 'destructive' ? 'destructive' : 'brand'}>{icon}</DialogFeaturedIcon>}\n          <div className=\"flex flex-col gap-2\">\n            <DialogTitle>{title}</DialogTitle>\n            {description ? <DialogDescription>{description}</DialogDescription> : null}\n          </div>\n        </DialogHeader>\n        {children}\n        {needsInput && (\n          <div className=\"flex flex-col gap-2\">\n            <Label htmlFor={inputId}>{confirmInputLabel ?? l.typeToConfirm(confirmValue)}</Label>\n            <Input\n              id={inputId}\n              value={typed}\n              placeholder={confirmInputPlaceholder}\n              autoComplete=\"off\"\n              onChange={(event) => setTyped(event.target.value)}\n              onKeyDown={(event) => {\n                if (event.key === 'Enter') {\n                  event.preventDefault();\n                  confirm();\n                }\n              }}\n            />\n          </div>\n        )}\n        <DialogFooter>\n          <Button type=\"button\" variant=\"outline\" disabled={pending} onClick={() => handleOpenChange(false)}>\n            {l.cancel}\n          </Button>\n          <Button\n            type=\"button\"\n            variant={tone === 'destructive' ? 'destructive' : 'primary'}\n            disabled={!matches || pending}\n            onClick={confirm}\n          >\n            {l.confirm}\n          </Button>\n        </DialogFooter>\n      </DialogContent>\n    </Dialog>\n  );\n};\nConfirmDialog.displayName = 'ConfirmDialog';\n\nexport { ConfirmDialog, type ConfirmDialogProps };\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}