{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "alert-dialog-motion",
  "title": "Dialog-motion alert",
  "description": "Styled alert: the Dialog-motion set. 5 decorative alert variations (ShakeAlert, PopAlert, DropAlert, ZoomAlert, SlideAlert) 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-motion.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { AlertTriangle, ArrowDown, ArrowUp, Sparkles, Zap } from \"lucide-react\"\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\n/* Motion alert-dialog family: 5 showy confirmation modals. The panel itself is\n   plain; the DIFFERENCE is in the enter/exit animation. Each export is a complete\n   modal: internal open/closed state (uncontrolled defaultOpen or controlled\n   open/onOpenChange), NO radix or portal - a self-contained fixed backdrop +\n   centered fixed panel. It closes on a backdrop click, Escape or Cancel; Confirm\n   calls onConfirm first and then closes. The panel takes focus on open.\n   AnimatePresence handles enter/exit; under reduced motion ALL transforms drop\n   away and only an opacity fade remains. Color comes ONLY from tokens, via alpha\n   color-mix. Size = panel width. The tone tokens drive the icon and the confirm\n   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\n/* Per-variant enter/exit animation. Value arrays (e.g. shake) are supported. */\ntype PanelMotion = {\n  initial: Record<string, number | number[]>\n  animate: Record<string, number | number[]>\n  exit: Record<string, number | number[]>\n  transition?: Record<string, unknown>\n}\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  panelMotion: PanelMotion\n}\n\n/* Shared modal core: state management, backdrop, panel, escape, focus, motion. panelMotion carries the enter/exit animation supplied from outside; it differs in every export. Under reduced motion panelMotion is ignored and only a fade is applied. */\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  panelMotion,\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  /* reduced motion: no transform, only an opacity fade. */\n  const fade: PanelMotion = {\n    initial: { opacity: 0 },\n    animate: { opacity: 1 },\n    exit: { opacity: 0 },\n    transition: { duration: 0.2, ease: \"easeOut\" },\n  }\n  const m = reduce ? fade : panelMotion\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={{ opacity: 0 }}\n              animate={{ opacity: 1 }}\n              exit={{ 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={m.initial}\n                animate={m.animate}\n                exit={m.exit}\n                transition={m.transition ?? { duration: 0.2, ease: \"easeOut\" }}\n              >\n                <div data-tone={tone} className={cn(\"flex flex-col\", bodyPad[size])}>\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                  <div\n                    data-slot=\"styled-alert-dialog-footer\"\n                    className=\"mt-5 flex justify-end gap-2\"\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/* ShakeAlert: the danger tone. The panel enters shaking horizontally (an x keyframe sequence) - an attention-grabbing warning. For irreversible or dangerous flows. */\nexport function ShakeAlert({\n  title = \"Heads up\",\n  description = \"This action needs your attention before it runs.\",\n  confirmLabel = \"Proceed\",\n  ...props\n}: StyledAlertPublicProps) {\n  return (\n    <StyledAlertDialog\n      tone=\"danger\"\n      icon={<AlertTriangle />}\n      iconClassName=\"text-danger\"\n      confirmClassName={confirmTone.danger}\n      title={title}\n      description={description}\n      confirmLabel={confirmLabel}\n      panelMotion={{\n        initial: { opacity: 0, x: 0 },\n        animate: { opacity: 1, x: [0, -10, 10, -8, 8, -4, 4, 0] },\n        exit: { opacity: 0, x: 0 },\n        transition: { duration: 0.5, ease: \"easeOut\" },\n      }}\n      {...props}\n    />\n  )\n}\n\n/* PopAlert: dusuk damping yay ile olceklenerek asirtili (overshoot) patlar. */\nexport function PopAlert({\n  title = \"Quick confirm\",\n  description = \"Confirm you want to continue with this action.\",\n  ...props\n}: StyledAlertPublicProps) {\n  return (\n    <StyledAlertDialog\n      tone=\"info\"\n      icon={<Sparkles />}\n      iconClassName=\"text-info\"\n      confirmClassName={confirmTone.info}\n      title={title}\n      description={description}\n      panelMotion={{\n        initial: { opacity: 0, scale: 0.8 },\n        animate: { opacity: 1, scale: 1 },\n        exit: { opacity: 0, scale: 0.9 },\n        transition: { type: \"spring\", stiffness: 520, damping: 12 },\n      }}\n      {...props}\n    />\n  )\n}\n\n/* DropAlert: it falls from above and settles with a spring bounce. */\nexport function DropAlert({\n  title = \"Before you continue\",\n  description = \"Review the details, then confirm to apply the change.\",\n  ...props\n}: StyledAlertPublicProps) {\n  return (\n    <StyledAlertDialog\n      tone=\"warning\"\n      icon={<ArrowDown />}\n      iconClassName=\"text-warning-soft-foreground\"\n      confirmClassName={confirmTone.warning}\n      title={title}\n      description={description}\n      panelMotion={{\n        initial: { opacity: 0, y: -320 },\n        animate: { opacity: 1, y: 0 },\n        exit: { opacity: 0, y: -120 },\n        transition: { type: \"spring\", stiffness: 260, damping: 20 },\n      }}\n      {...props}\n    />\n  )\n}\n\n/* ZoomAlert: agresif buyume ile ortaya patlar (scale 0.4 -> 1). */\nexport function ZoomAlert({\n  title = \"Confirm action\",\n  description = \"This will take effect as soon as you confirm.\",\n  ...props\n}: StyledAlertPublicProps) {\n  return (\n    <StyledAlertDialog\n      tone=\"success\"\n      icon={<Zap />}\n      iconClassName=\"text-success\"\n      confirmClassName={confirmTone.success}\n      title={title}\n      description={description}\n      panelMotion={{\n        initial: { opacity: 0, scale: 0.4 },\n        animate: { opacity: 1, scale: 1 },\n        exit: { opacity: 0, scale: 0.4 },\n        transition: { type: \"spring\", stiffness: 360, damping: 24 },\n      }}\n      {...props}\n    />\n  )\n}\n\n/* SlideAlert: alttan yukari kayarak girer (y 40 -> 0). */\nexport function SlideAlert({\n  title = \"One more step\",\n  description = \"Confirm below to finish and apply your changes.\",\n  ...props\n}: StyledAlertPublicProps) {\n  return (\n    <StyledAlertDialog\n      tone=\"info\"\n      icon={<ArrowUp />}\n      iconClassName=\"text-info\"\n      confirmClassName={confirmTone.info}\n      title={title}\n      description={description}\n      panelMotion={{\n        initial: { opacity: 0, y: 44 },\n        animate: { opacity: 1, y: 0 },\n        exit: { opacity: 0, y: 28 },\n        transition: { type: \"spring\", stiffness: 320, damping: 26 },\n      }}\n      {...props}\n    />\n  )\n}\n",
      "type": "registry:component",
      "target": "components/ui/alert-dialog-motion.tsx"
    }
  ],
  "categories": [
    "styled",
    "alert"
  ],
  "type": "registry:component"
}