{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "alert-dialog-styled",
  "title": "Dialog-styled alert",
  "description": "Styled alert: the Dialog-styled set. 5 decorative alert variations (ConfirmAlert, DestructiveAlert, InfoAlert, SuccessAlert, IconAlert) on the ai2 token system, powered by framer-motion, reduced-motion aware and sized sm to xl. Part of the free styled layer.",
  "dependencies": [
    "motion@^12.42.2",
    "lucide-react@^1.23.0"
  ],
  "registryDependencies": [
    "@ai2/tokens"
  ],
  "files": [
    {
      "path": "registry/ai2/styled/alert-dialog-styled.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { AlertTriangle, CheckCircle, Info, Trash2 } from \"lucide-react\"\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\n/* Styled alert-dialog family: 5 decorative confirmation modals. Each export is a\n   complete modal: internal open state (uncontrolled defaultOpen / controlled\n   open+onOpenChange), SELF-CONTAINED (no radix, no portal) - fixed backdrop +\n   centered fixed panel. A backdrop click, Escape or Cancel closes it; Confirm\n   calls onConfirm first and then closes. The panel takes focus on open.\n   AnimatePresence handles enter/exit, and under reduced motion it fades or\n   switches instantly. Color comes ONLY from tokens, via alpha color-mix. Size =\n   panel width. The tone tokens drive the icon and the confirm button. */\n\nexport type StyledSize = \"sm\" | \"md\" | \"lg\" | \"xl\"\n\nexport type StyledTone = \"info\" | \"success\" | \"warning\" | \"danger\"\n\nconst panelWidth: Record<StyledSize, string> = {\n  sm: \"max-w-sm\",\n  md: \"max-w-md\",\n  lg: \"max-w-lg\",\n  xl: \"max-w-xl\",\n}\n\nconst bodyPad: Record<StyledSize, string> = {\n  sm: \"p-4\",\n  md: \"p-5\",\n  lg: \"p-6\",\n  xl: \"p-7\",\n}\n\n/* Confirm button tone mapping - the tone token drives it directly. */\nconst confirmTone: Record<StyledTone, string> = {\n  info: \"bg-info text-info-foreground hover:bg-info/90\",\n  success: \"bg-success text-success-foreground hover:bg-success/90\",\n  warning: \"bg-warning text-warning-foreground hover:bg-warning/90\",\n  danger: \"bg-danger text-danger-foreground hover:bg-danger/90\",\n}\n\nconst cancelBtn =\n  \"inline-flex h-9 items-center justify-center rounded-md border border-border bg-transparent px-4 text-sm font-medium text-foreground transition-colors hover:bg-secondary focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 [&_svg]:size-4 [&_svg]:shrink-0 [&_i]:text-base [&_i]:leading-none\"\n\nconst confirmBtn =\n  \"inline-flex h-9 items-center justify-center gap-1.5 rounded-md px-4 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 [&_svg]:size-4 [&_svg]:shrink-0 [&_i]:text-base [&_i]:leading-none\"\n\ntype StyledAlertPublicProps = {\n  size?: StyledSize\n  trigger?: React.ReactNode\n  title?: React.ReactNode\n  description?: React.ReactNode\n  confirmLabel?: string\n  cancelLabel?: string\n  onConfirm?: () => void\n  className?: string\n  open?: boolean\n  defaultOpen?: boolean\n  onOpenChange?: (o: boolean) => void\n}\n\ntype StyledAlertCoreProps = StyledAlertPublicProps & {\n  tone: StyledTone\n  confirmClassName: string\n  icon: React.ReactNode\n  iconClassName: string\n  centered?: boolean\n}\n\n/* Ortak modal cekirdegi: durum yonetimi, backdrop, panel, escape, odak, motion. */\nfunction StyledAlertDialog({\n  size = \"md\",\n  trigger,\n  title,\n  description,\n  confirmLabel = \"Confirm\",\n  cancelLabel = \"Cancel\",\n  onConfirm,\n  className,\n  open,\n  defaultOpen,\n  onOpenChange,\n  tone,\n  confirmClassName,\n  icon,\n  iconClassName,\n  centered = false,\n}: StyledAlertCoreProps) {\n  const reduce = useReducedMotion()\n  const isControlled = open !== undefined\n  const [internalOpen, setInternalOpen] = React.useState(defaultOpen ?? false)\n  const actualOpen = isControlled ? open : internalOpen\n  const panelRef = React.useRef<HTMLDivElement>(null)\n\n  const setOpen = React.useCallback(\n    (next: boolean) => {\n      if (!isControlled) setInternalOpen(next)\n      onOpenChange?.(next)\n    },\n    [isControlled, onOpenChange]\n  )\n\n  React.useEffect(() => {\n    if (!actualOpen) return\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key === \"Escape\") setOpen(false)\n    }\n    document.addEventListener(\"keydown\", onKey)\n    const raf = window.requestAnimationFrame(() => panelRef.current?.focus())\n    return () => {\n      document.removeEventListener(\"keydown\", onKey)\n      window.cancelAnimationFrame(raf)\n    }\n  }, [actualOpen, setOpen])\n\n  const handleConfirm = () => {\n    onConfirm?.()\n    setOpen(false)\n  }\n\n  return (\n    <span data-slot=\"styled-alert-dialog\" className=\"contents\">\n      {/* ARIA durumu tetikleyicinin KENDISINDE. Once yoktu: ekran okuyucu\n\n          kullanicisi butonun bir dialog actigini ve acik olup olmadigini\n\n          HIC bilmiyordu. Canli AX taramasiyla bulundu (grep gostermemisti). */}\n\n      <span data-slot=\"styled-alert-dialog-trigger\" className=\"inline-flex\">\n\n        {React.isValidElement<React.ButtonHTMLAttributes<HTMLButtonElement>>(trigger) ? (\n\n          React.cloneElement(trigger, {\n\n            \"aria-haspopup\": \"dialog\",\n\n            \"aria-expanded\": actualOpen,\n\n            onClick: (event: React.MouseEvent<HTMLButtonElement>) => {\n\n              trigger.props.onClick?.(event)\n\n              setOpen(true)\n\n            },\n\n          })\n\n        ) : (\n\n          <button\n\n            type=\"button\"\n\n            aria-haspopup=\"dialog\"\n\n            aria-expanded={actualOpen}\n\n            onClick={() => setOpen(true)}\n\n            className=\"inline-flex h-9 items-center justify-center rounded-md border border-border bg-secondary px-4 text-sm font-medium text-secondary-foreground transition-colors hover:bg-secondary/80 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50\"\n\n          >\n\n            {trigger ?? \"Open\"}\n\n          </button>\n\n        )}\n\n      </span>\n\n      <AnimatePresence>\n        {actualOpen ? (\n          <>\n            <motion.div\n              data-slot=\"styled-alert-dialog-backdrop\"\n              className=\"fixed inset-0 z-50 bg-[color-mix(in_oklab,var(--color-foreground)_45%,transparent)] supports-[backdrop-filter]:backdrop-blur-sm\"\n              onClick={() => setOpen(false)}\n              initial={reduce ? false : { opacity: 0 }}\n              animate={{ opacity: 1 }}\n              exit={reduce ? { opacity: 1 } : { opacity: 0 }}\n              transition={{ duration: 0.2, ease: \"easeOut\" }}\n            />\n            <div className=\"pointer-events-none fixed inset-0 z-50 flex items-center justify-center p-4\">\n              <motion.div\n                ref={panelRef}\n                role=\"alertdialog\"\n                aria-modal=\"true\"\n                tabIndex={-1}\n                onClick={(e) => e.stopPropagation()}\n                className={cn(\n                  \"pointer-events-auto w-full rounded-xl border border-border bg-popover text-popover-foreground shadow-lg outline-none\",\n                  panelWidth[size],\n                  className\n                )}\n                initial={reduce ? false : { opacity: 0, scale: 0.96, y: 8 }}\n                animate={{ opacity: 1, scale: 1, y: 0 }}\n                exit={reduce ? { opacity: 1 } : { opacity: 0, scale: 0.96, y: 8 }}\n                transition={{ duration: 0.2, ease: \"easeOut\" }}\n              >\n                <div\n                  data-tone={tone}\n                  className={cn(\"flex flex-col\", bodyPad[size])}\n                >\n                  {centered ? (\n                    <div className=\"flex flex-col items-center text-center\">\n                      <span\n                        data-slot=\"styled-alert-dialog-icon\"\n                        className={cn(\n                          \"mb-3 flex size-12 items-center justify-center rounded-full bg-[color-mix(in_oklab,currentColor_12%,transparent)] [&_svg]:size-6 [&_svg]:shrink-0 [&_i]:text-2xl [&_i]:leading-none\",\n                          iconClassName\n                        )}\n                      >\n                        {icon}\n                      </span>\n                      {title ? (\n                        <h2\n                          data-slot=\"styled-alert-dialog-title\"\n                          className=\"text-base font-semibold tracking-tight text-foreground\"\n                        >\n                          {title}\n                        </h2>\n                      ) : null}\n                      {description ? (\n                        <p\n                          data-slot=\"styled-alert-dialog-description\"\n                          className=\"mt-1 text-sm text-muted-foreground\"\n                        >\n                          {description}\n                        </p>\n                      ) : null}\n                    </div>\n                  ) : (\n                    <div className=\"flex gap-3\">\n                      <span\n                        data-slot=\"styled-alert-dialog-icon\"\n                        className={cn(\n                          \"mt-0.5 flex shrink-0 items-center [&_svg]:size-5 [&_svg]:shrink-0 [&_i]:text-xl [&_i]:leading-none\",\n                          iconClassName\n                        )}\n                      >\n                        {icon}\n                      </span>\n                      <div className=\"min-w-0 flex-1\">\n                        {title ? (\n                          <h2\n                            data-slot=\"styled-alert-dialog-title\"\n                            className=\"text-base font-semibold tracking-tight text-foreground\"\n                          >\n                            {title}\n                          </h2>\n                        ) : null}\n                        {description ? (\n                          <p\n                            data-slot=\"styled-alert-dialog-description\"\n                            className=\"mt-1 text-sm text-muted-foreground\"\n                          >\n                            {description}\n                          </p>\n                        ) : null}\n                      </div>\n                    </div>\n                  )}\n\n                  <div\n                    data-slot=\"styled-alert-dialog-footer\"\n                    className={cn(\n                      \"mt-5 flex gap-2\",\n                      centered\n                        ? \"flex-col-reverse sm:flex-row sm:justify-center\"\n                        : \"justify-end\"\n                    )}\n                  >\n                    <button\n                      type=\"button\"\n                      data-slot=\"styled-alert-dialog-cancel\"\n                      className={cancelBtn}\n                      onClick={() => setOpen(false)}\n                    >\n                      {cancelLabel}\n                    </button>\n                    <button\n                      type=\"button\"\n                      data-slot=\"styled-alert-dialog-confirm\"\n                      className={cn(confirmBtn, confirmClassName)}\n                      onClick={handleConfirm}\n                    >\n                      {confirmLabel}\n                    </button>\n                  </div>\n                </div>\n              </motion.div>\n            </div>\n          </>\n        ) : null}\n      </AnimatePresence>\n    </span>\n  )\n}\n\n/* ConfirmAlert: notr onay, primary confirm butonu. Genel amacli evet/hayir. */\nexport function ConfirmAlert({\n  title = \"Are you sure?\",\n  description = \"Please confirm you want to continue with this action.\",\n  ...props\n}: StyledAlertPublicProps) {\n  return (\n    <StyledAlertDialog\n      tone=\"info\"\n      icon={<Info />}\n      iconClassName=\"text-foreground\"\n      confirmClassName=\"bg-primary text-primary-foreground hover:bg-primary/90\"\n      title={title}\n      description={description}\n      {...props}\n    />\n  )\n}\n\n/* DestructiveAlert: the danger tone, a Trash icon plus a danger confirm button. For irreversible delete flows. */\nexport function DestructiveAlert({\n  title = \"Delete this item?\",\n  description = \"This action cannot be undone. The item will be permanently removed.\",\n  confirmLabel = \"Delete\",\n  ...props\n}: StyledAlertPublicProps) {\n  return (\n    <StyledAlertDialog\n      tone=\"danger\"\n      icon={<Trash2 />}\n      iconClassName=\"text-danger\"\n      confirmClassName={confirmTone.danger}\n      title={title}\n      description={description}\n      confirmLabel={confirmLabel}\n      {...props}\n    />\n  )\n}\n\n/* InfoAlert: info tone + Info ikonu. Bilgilendirici onay. */\nexport function InfoAlert({\n  title = \"Heads up\",\n  description = \"Review the details below before you continue.\",\n  ...props\n}: StyledAlertPublicProps) {\n  return (\n    <StyledAlertDialog\n      tone=\"info\"\n      icon={<Info />}\n      iconClassName=\"text-info\"\n      confirmClassName={confirmTone.info}\n      title={title}\n      description={description}\n      {...props}\n    />\n  )\n}\n\n/* SuccessAlert: success tone + CheckCircle. Basari / tamamlama onayi. */\nexport function SuccessAlert({\n  title = \"All set\",\n  description = \"Your changes have been applied. Confirm to continue.\",\n  ...props\n}: StyledAlertPublicProps) {\n  return (\n    <StyledAlertDialog\n      tone=\"success\"\n      icon={<CheckCircle />}\n      iconClassName=\"text-success\"\n      confirmClassName={confirmTone.success}\n      title={title}\n      description={description}\n      {...props}\n    />\n  )\n}\n\n/* IconAlert: buyuk ortalanmis tone ikon, ustte; altinda ortalanmis baslik /\n   aciklama, en altta butonlar. */\nexport function IconAlert({\n  title = \"Confirm action\",\n  description = \"Take a moment to confirm before this action is applied.\",\n  ...props\n}: StyledAlertPublicProps) {\n  return (\n    <StyledAlertDialog\n      tone=\"warning\"\n      icon={<AlertTriangle />}\n      iconClassName=\"text-warning-soft-foreground\"\n      confirmClassName={confirmTone.warning}\n      title={title}\n      description={description}\n      centered\n      {...props}\n    />\n  )\n}\n",
      "type": "registry:component",
      "target": "components/ui/alert-dialog-styled.tsx"
    }
  ],
  "categories": [
    "styled",
    "alert"
  ],
  "type": "registry:component"
}