{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "retro-alert-dialog",
  "title": "RetroAlertDialog",
  "description": "A Mac OS 9 styled alert dialog with OS9 window shadow, striped title bar, caution icon, and modal behavior. Zooms out of its trigger with Finder zoom rects. Built on UI SDK Alert Dialog.",
  "dependencies": [
    "@ui-sdk/core@0.1.0-beta.1",
    "@ui-sdk/react@0.1.0-beta.1"
  ],
  "registryDependencies": [
    "https://nostalgia-ui.com/r/nostalgia-theme.json",
    "https://nostalgia-ui.com/r/retro-icons.json",
    "https://nostalgia-ui.com/r/retro-motion.json"
  ],
  "files": [
    {
      "path": "registry/new-york/ui/retro-alert-dialog.tsx",
      "content": "\"use client\"\n\n/*\n * RetroAlertDialog: a Mac OS 9 alert (Caution / Stop / Note) on UI SDK.\n *\n * Crafted moment: zoom rects. The alert grows out of the button that raised\n * it as a trail of outlines, then appears; answering it flies the outlines\n * back. Modern flair eases the rects, classic steps them, reduced motion\n * skips them.\n *\n * No dimmed backdrop: OS 9 never darkened the desktop behind a window. An\n * outside click leaves the alert open; Escape and the buttons answer it.\n */\n\nimport * as React from \"react\"\nimport {\n  AlertDialog as AlertDialogPrimitive,\n  AlertDialogBackdrop as AlertDialogBackdropPrimitive,\n  AlertDialogClose as AlertDialogClosePrimitive,\n  AlertDialogContent as AlertDialogContentPrimitive,\n  AlertDialogDescription as AlertDialogDescriptionPrimitive,\n  AlertDialogTitle as AlertDialogTitlePrimitive,\n  AlertDialogTrigger as AlertDialogTriggerPrimitive,\n} from \"@ui-sdk/react/alert-dialog\"\n\nimport { cn } from \"@/lib/utils\"\nimport { ZOOM_CONTENT_CLASS, popupClass, useMergedRef, useZoomRects } from \"@/registry/new-york/lib/retro-motion\"\nimport {\n  RetroIconAlert,\n  RetroIconInfo,\n  RetroIconStop,\n} from \"@/registry/new-york/ui/retro-icons\"\n\ntype WithClassName<P> = Omit<P, \"className\"> & { className?: string }\n\n/* ------------------------------------------------------------------ */\n/*  Root & Trigger                                                     */\n/* ------------------------------------------------------------------ */\n\ntype ZoomContextValue = ReturnType<typeof useZoomRects>\n\nconst ZoomContext = React.createContext<ZoomContextValue | null>(null)\n\nfunction useZoom() {\n  const ctx = React.useContext(ZoomContext)\n  if (!ctx) throw new Error(\"RetroAlertDialog parts must be inside <RetroAlertDialog>\")\n  return ctx\n}\n\nfunction RetroAlertDialog({ onOpenChange, ...props }: React.ComponentProps<typeof AlertDialogPrimitive>) {\n  const zoom = useZoomRects()\n  return (\n    <ZoomContext.Provider value={zoom}>\n      <AlertDialogPrimitive\n        onOpenChange={(open, details) => {\n          onOpenChange?.(open, details)\n          /* closing: the alert vanishes at once and the rects fly home */\n          zoom.onOpenChange(open)\n        }}\n        {...props}\n      />\n    </ZoomContext.Provider>\n  )\n}\n\nfunction RetroAlertDialogTrigger({ ref, ...props }: React.ComponentProps<typeof AlertDialogTriggerPrimitive>) {\n  const { triggerRef } = useZoom()\n  return <AlertDialogTriggerPrimitive ref={useMergedRef(ref, triggerRef)} {...props} />\n}\n\n/* ------------------------------------------------------------------ */\n/*  Alert icons (Caution / Stop / Note)                                */\n/* ------------------------------------------------------------------ */\n\ntype RetroAlertDialogVariant = \"caution\" | \"stop\" | \"note\"\n\nconst alertIcons: Record<\n  RetroAlertDialogVariant,\n  React.ComponentType<{ className?: string }>\n> = {\n  caution: RetroIconAlert,\n  stop: RetroIconStop,\n  note: RetroIconInfo,\n}\n\n/* ------------------------------------------------------------------ */\n/*  Content                                                            */\n/* ------------------------------------------------------------------ */\n\nfunction RetroAlertDialogContent({\n  className,\n  children,\n  ref,\n  ...props\n}: WithClassName<React.ComponentProps<typeof AlertDialogContentPrimitive>>) {\n  const { contentRef } = useZoom()\n  return (\n    <>\n      {/* OS 9 never dimmed the desktop behind a window */}\n      <AlertDialogBackdropPrimitive className=\"fixed! inset-0! z-50 bg-transparent!\" />\n      <AlertDialogContentPrimitive\n        ref={useMergedRef(ref, contentRef)}\n        className={popupClass(\n          cn(\n            /* Box properties carry `!` so UI SDK's popup reset can't strip them\n             * in apps that haven't declared `@layer ui-sdk;` first. */\n            \"fixed! inset-auto! left-1/2! top-1/2! z-50 m-0! p-0! w-[calc(100%-2rem)]! max-w-[420px]! h-auto! max-h-[calc(100dvh-2rem)]!\",\n            \"-translate-x-1/2 -translate-y-1/2 flex flex-col outline-none overflow-visible!\",\n            /* OS9 window frame */\n            \"border! border-os9-black! bg-os9-gray-200! text-os9-black! shadow-[var(--os9-shadow-window)]\",\n            /* appear in one frame once the zoom rects land; vanish at once on close */\n            ZOOM_CONTENT_CLASS\n          ),\n          className\n        )}\n        {...props}\n      >\n        {children}\n      </AlertDialogContentPrimitive>\n    </>\n  )\n}\n\n/* ------------------------------------------------------------------ */\n/*  Header (OS9 title bar style)                                       */\n/* ------------------------------------------------------------------ */\n\nfunction RetroAlertDialogHeader({\n  className,\n  children,\n  ...props\n}: React.HTMLAttributes<HTMLDivElement>) {\n  return (\n    <div\n      className={cn(\n        \"relative flex h-[19px] items-center bg-os9-gray-400\",\n        className\n      )}\n      {...props}\n    >\n      {/* Stripes left */}\n      <span\n        className=\"os9-stripes flex-1 min-w-[4px] h-[13px] ml-[4px]\"\n        style={{\n          boxShadow: \"inset 1px 0 0 #eee, inset -1px 0 0 #c5c5c5\",\n        }}\n        aria-hidden\n      />\n\n      {/* Title (rendered via RetroAlertDialogTitle inside children) */}\n      {children}\n\n      {/* Stripes right */}\n      <span\n        className=\"os9-stripes flex-1 min-w-[4px] h-[13px] mr-[4px]\"\n        style={{\n          boxShadow: \"inset 1px 0 0 #eee, inset -1px 0 0 #c5c5c5\",\n        }}\n        aria-hidden\n      />\n    </div>\n  )\n}\n\n/* ------------------------------------------------------------------ */\n/*  Title                                                              */\n/* ------------------------------------------------------------------ */\n\nfunction RetroAlertDialogTitle({\n  className,\n  ...props\n}: WithClassName<React.ComponentProps<typeof AlertDialogTitlePrimitive>>) {\n  return (\n    <AlertDialogTitlePrimitive\n      className={cn(\n        \"shrink-0 whitespace-nowrap text-[12px] tracking-[0.42px] leading-[0.98]\",\n        \"font-[family-name:var(--os9-font-heading)] text-os9-black\",\n        \"max-w-[60%] overflow-hidden text-ellipsis\",\n        \"px-[4px]\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\n/* ------------------------------------------------------------------ */\n/*  Description                                                        */\n/* ------------------------------------------------------------------ */\n\nfunction RetroAlertDialogDescription({\n  className,\n  ...props\n}: WithClassName<React.ComponentProps<typeof AlertDialogDescriptionPrimitive>>) {\n  return (\n    <AlertDialogDescriptionPrimitive\n      className={cn(\n        \"text-[10px] leading-[1.4] text-os9-black\",\n        \"font-[family-name:var(--os9-font-sans)]\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\n/* ------------------------------------------------------------------ */\n/*  Body (content area with icon + description)                        */\n/* ------------------------------------------------------------------ */\n\ninterface RetroAlertDialogBodyProps\n  extends React.HTMLAttributes<HTMLDivElement> {\n  /** Which OS9 alert icon to show: caution (default), stop, or note. */\n  variant?: RetroAlertDialogVariant\n  /** Custom icon — overrides the variant icon. Pass `null` to hide it. */\n  icon?: React.ReactNode\n}\n\nfunction RetroAlertDialogBody({\n  className,\n  children,\n  variant = \"caution\",\n  icon,\n  ...props\n}: RetroAlertDialogBodyProps) {\n  const Icon = alertIcons[variant]\n  return (\n    <div\n      className={cn(\n        \"flex gap-3 px-4 py-3 shadow-[-1px_-1px_0_rgba(38,38,38,0.4)]\",\n        className\n      )}\n      {...props}\n    >\n      {/* Alert icon area */}\n      {icon !== null && (\n        <div className=\"flex-shrink-0 pt-0.5\">\n          {icon !== undefined ? icon : <Icon />}\n        </div>\n      )}\n      {/* Description content */}\n      <div className=\"flex-1 flex flex-col justify-center\">{children}</div>\n    </div>\n  )\n}\n\n/* ------------------------------------------------------------------ */\n/*  Footer                                                             */\n/* ------------------------------------------------------------------ */\n\nfunction RetroAlertDialogFooter({\n  className,\n  ...props\n}: React.HTMLAttributes<HTMLDivElement>) {\n  return (\n    <div\n      className={cn(\n        \"flex items-center justify-between gap-2 px-4 pb-3\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\n/* ------------------------------------------------------------------ */\n/*  Action & Cancel                                                    */\n/* ------------------------------------------------------------------ */\n\nconst alertButtonClass = cn(\n  \"inline-flex items-center justify-center whitespace-nowrap\",\n  \"font-[family-name:var(--os9-font-heading)] text-[12px] tracking-[0.42px] leading-[0.98]\",\n  \"cursor-pointer select-none transition-none\",\n  \"h-[24px] px-4 py-0\",\n  \"bg-os9-gray-300 text-os9-black\",\n  \"shadow-[inset_1px_1px_0_var(--os9-white),inset_-1px_-1px_0_var(--os9-gray-700)]\",\n  \"active:bg-os9-gray-800 active:text-os9-white\",\n  \"active:shadow-[inset_1px_1px_0_var(--os9-gray-700),inset_-1px_-1px_0_var(--os9-white)]\",\n  \"data-pending:cursor-progress\",\n  \"focus-visible:os9-focus-ring\"\n)\n\n/** The default answer: a heavy 2px border, and it reports `value=\"confirm\"`. */\nfunction RetroAlertDialogAction({\n  className,\n  value = \"confirm\",\n  ...props\n}: WithClassName<React.ComponentProps<typeof AlertDialogClosePrimitive>>) {\n  return (\n    <AlertDialogClosePrimitive\n      value={value}\n      className={cn(alertButtonClass, \"border-[2px] border-os9-black\", className)}\n      {...props}\n    />\n  )\n}\n\nfunction RetroAlertDialogCancel({\n  className,\n  value = \"cancel\",\n  ...props\n}: WithClassName<React.ComponentProps<typeof AlertDialogClosePrimitive>>) {\n  return (\n    <AlertDialogClosePrimitive\n      value={value}\n      className={cn(alertButtonClass, \"border border-os9-black\", className)}\n      {...props}\n    />\n  )\n}\n\n/* ------------------------------------------------------------------ */\n/*  Exports                                                            */\n/* ------------------------------------------------------------------ */\n\nexport {\n  RetroAlertDialog,\n  RetroAlertDialogTrigger,\n  RetroAlertDialogContent,\n  RetroAlertDialogHeader,\n  RetroAlertDialogTitle,\n  RetroAlertDialogDescription,\n  RetroAlertDialogBody,\n  RetroAlertDialogFooter,\n  RetroAlertDialogAction,\n  RetroAlertDialogCancel,\n}\n\nexport type { RetroAlertDialogVariant, RetroAlertDialogBodyProps }\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}