{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "popconfirm",
  "title": "Popconfirm",
  "description": "A small confirmation anchored to the control that opened it, with a title, a consequence line and Yes/No actions that stay busy while an async confirm runs.",
  "registryDependencies": [
    "button",
    "popover"
  ],
  "files": [
    {
      "path": "registry/tealmac/popconfirm.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n  Popover,\n  PopoverContent,\n  PopoverTrigger,\n} from \"@/components/ui/popover\"\n\nexport interface PopconfirmProps {\n  /** The element that opens the confirmation, usually a Button. */\n  children: React.ReactElement\n  /** The question, for example \"Delete this invoice?\". */\n  title: React.ReactNode\n  /** One line of consequence under the question. */\n  description?: React.ReactNode\n  /** Runs on confirm. A promise keeps the popover open and the button busy until it settles. */\n  onConfirm: () => void | Promise<void>\n  onCancel?: () => void\n  confirmLabel?: string\n  cancelLabel?: string\n  /** Paints the confirm button as destructive. */\n  destructive?: boolean\n  /** Disables the confirm button, for example until a reason is typed. */\n  confirmDisabled?: boolean\n  /** Controlled open state. */\n  open?: boolean\n  onOpenChange?: (open: boolean) => void\n  side?: \"top\" | \"right\" | \"bottom\" | \"left\"\n  className?: string\n}\n\n/**\n * A small confirmation anchored to the control that triggered it. It asks one\n * question, keeps focus inside, closes on Escape and returns focus to the\n * trigger. While an async confirm runs it cannot be dismissed by accident.\n */\nexport function Popconfirm({\n  children,\n  title,\n  description,\n  onConfirm,\n  onCancel,\n  confirmLabel = \"Yes\",\n  cancelLabel = \"No\",\n  destructive = false,\n  confirmDisabled = false,\n  open: openProp,\n  onOpenChange,\n  side = \"top\",\n  className,\n}: PopconfirmProps) {\n  const [inner, setInner] = React.useState(false)\n  const [pending, setPending] = React.useState(false)\n  const open = openProp ?? inner\n  const titleId = React.useId()\n  const descId = React.useId()\n\n  const setOpen = (next: boolean) => {\n    if (pending && !next) return\n    setInner(next)\n    onOpenChange?.(next)\n  }\n\n  const confirm = async () => {\n    setPending(true)\n    try {\n      await onConfirm()\n      setPending(false)\n      setInner(false)\n      onOpenChange?.(false)\n    } catch {\n      setPending(false)\n    }\n  }\n\n  return (\n    <Popover open={open} onOpenChange={setOpen}>\n      <PopoverTrigger asChild>{children}</PopoverTrigger>\n      <PopoverContent\n        side={side}\n        role=\"alertdialog\"\n        aria-labelledby={titleId}\n        aria-describedby={description ? descId : undefined}\n        className={cn(\"w-72 gap-3\", className)}\n        onEscapeKeyDown={(event) => pending && event.preventDefault()}\n        onInteractOutside={(event) => pending && event.preventDefault()}\n      >\n        <div className=\"space-y-1\">\n          <p id={titleId} className=\"text-sm leading-snug font-medium\">\n            {title}\n          </p>\n          {description ? (\n            <p id={descId} className=\"text-muted-foreground text-sm\">\n              {description}\n            </p>\n          ) : null}\n        </div>\n        <div className=\"flex justify-end gap-2\">\n          <Button\n            type=\"button\"\n            size=\"sm\"\n            variant=\"outline\"\n            disabled={pending}\n            onClick={() => {\n              onCancel?.()\n              setOpen(false)\n            }}\n          >\n            {cancelLabel}\n          </Button>\n          <Button\n            type=\"button\"\n            size=\"sm\"\n            variant={destructive ? \"destructive\" : \"default\"}\n            disabled={pending || confirmDisabled}\n            aria-busy={pending || undefined}\n            onClick={confirm}\n          >\n            {confirmLabel}\n          </Button>\n        </div>\n      </PopoverContent>\n    </Popover>\n  )\n}\n\nexport default Popconfirm\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}