{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "morphing-dialog",
  "type": "registry:ui",
  "title": "Morphing Dialog",
  "author": "Rishabh Bose <https://theb0se.vercel.app/>",
  "description": "Origin-morphing modal overlay that expands seamlessly from its trigger button bounding box with spring layout projection and vertical drag-to-dismiss.",
  "dependencies": [
    "framer-motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "components/ui/morphing-dialog.tsx",
      "content": "\"use client\";\n\nimport React, { useEffect, useId, useRef, useState } from \"react\";\nimport {\n  AnimatePresence,\n  motion,\n  useReducedMotion,\n  type PanInfo,\n} from \"framer-motion\";\nimport { Sparkles, X, ArrowUpRight } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface MorphingDialogProps {\n  /** Trigger button title text. Default: \"Inspect Spring Telemetry\" */\n  triggerTitle?: string;\n  /** Subtitle shown inside the compact trigger card. Default: \"Click to expand shared-layout surface\" */\n  triggerSubtitle?: string;\n  /** Modal dialog heading. Default: \"Hooke's Law Telemetry Architecture\" */\n  dialogTitle?: string;\n  /** Modal dialog body description. */\n  dialogDescription?: string;\n  /** Controlled open state */\n  open?: boolean;\n  /** Callback when open state changes */\n  onOpenChange?: (open: boolean) => void;\n  /** Spring stiffness coefficient for shared layout projection. Default: 290 */\n  stiffness?: number;\n  /** Spring damping coefficient for shared layout projection. Default: 26 */\n  damping?: number;\n  /** Optional custom content inside the expanded dialog body */\n  children?: React.ReactNode;\n  className?: string;\n}\n\nexport function MorphingDialog({\n  triggerTitle = \"Inspect Spring Telemetry\",\n  triggerSubtitle = \"Click to expand shared-layout surface\",\n  dialogTitle = \"Hooke's Law Telemetry Architecture\",\n  dialogDescription = \"Every BoseUI overlay morphs directly from the bounding box of its origin trigger using GPU-accelerated layout projection, complete with vertical drag-to-dismiss elasticity.\",\n  open: controlledOpen,\n  onOpenChange,\n  stiffness = 290,\n  damping = 26,\n  children,\n  className,\n}: MorphingDialogProps) {\n  const shouldReduceMotion = useReducedMotion() ?? false;\n  const uniqueId = useId();\n  const layoutId = `morphing-dialog-${uniqueId}`;\n\n  const [internalOpen, setInternalOpen] = useState(false);\n  const isOpen = controlledOpen !== undefined ? controlledOpen : internalOpen;\n\n  const triggerRef = useRef<HTMLButtonElement | null>(null);\n  const closeButtonRef = useRef<HTMLButtonElement | null>(null);\n\n  const setOpen = (next: boolean) => {\n    if (controlledOpen === undefined) {\n      setInternalOpen(next);\n    }\n    onOpenChange?.(next);\n    if (!next) {\n      requestAnimationFrame(() => {\n        triggerRef.current?.focus();\n      });\n    }\n  };\n\n  useEffect(() => {\n    if (!isOpen) return;\n\n    const timer = requestAnimationFrame(() => {\n      closeButtonRef.current?.focus();\n    });\n\n    const handleKeyDown = (e: KeyboardEvent) => {\n      if (e.key === \"Escape\") {\n        e.preventDefault();\n        setOpen(false);\n      }\n    };\n\n    window.addEventListener(\"keydown\", handleKeyDown);\n    return () => {\n      cancelAnimationFrame(timer);\n      window.removeEventListener(\"keydown\", handleKeyDown);\n    };\n  });\n\n  const handleDragEnd = (\n    _event: MouseEvent | TouchEvent | PointerEvent,\n    info: PanInfo\n  ) => {\n    if (Math.abs(info.offset.y) > 85 || Math.abs(info.velocity.y) > 420) {\n      setOpen(false);\n    }\n  };\n\n  const springConfig = shouldReduceMotion\n    ? { duration: 0.01 }\n    : { type: \"spring\" as const, stiffness, damping };\n\n  return (\n    <div className={cn(\"relative inline-block\", className)}>\n      {/* Origin Trigger Card */}\n      <motion.button\n        ref={triggerRef}\n        type=\"button\"\n        layoutId={layoutId}\n        onClick={() => setOpen(true)}\n        aria-haspopup=\"dialog\"\n        aria-expanded={isOpen}\n        transition={springConfig}\n        className=\"group flex items-center gap-3.5 rounded-2xl border border-neutral-200 bg-white px-5 py-4 text-left shadow-sm transition-colors hover:border-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black dark:border-[#222222] dark:bg-[#0A0A0A] dark:hover:border-white dark:focus-visible:ring-white\"\n      >\n        <motion.div\n          layoutId={`${layoutId}-icon`}\n          transition={springConfig}\n          className=\"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border border-neutral-200 bg-neutral-50 text-black dark:border-[#262626] dark:bg-[#141414] dark:text-white\"\n        >\n          <Sparkles className=\"h-4 w-4\" />\n        </motion.div>\n\n        <div className=\"pr-2\">\n          <motion.div\n            layoutId={`${layoutId}-title`}\n            transition={springConfig}\n            className=\"text-sm font-semibold text-black dark:text-white\"\n          >\n            {triggerTitle}\n          </motion.div>\n          <motion.div\n            layoutId={`${layoutId}-subtitle`}\n            transition={springConfig}\n            className=\"mt-0.5 text-xs text-neutral-500 dark:text-neutral-400\"\n          >\n            {triggerSubtitle}\n          </motion.div>\n        </div>\n\n        <ArrowUpRight className=\"ml-auto h-4 w-4 text-neutral-400 transition-transform group-hover:-translate-y-0.5 group-hover:translate-x-0.5 group-hover:text-black dark:group-hover:text-white\" />\n      </motion.button>\n\n      {/* Shared-Element Expanded Modal Overlay */}\n      <AnimatePresence>\n        {isOpen && (\n          <div className=\"fixed inset-0 z-50 flex items-center justify-center p-4\">\n            {/* Backdrop */}\n            <motion.div\n              initial={{ opacity: 0 }}\n              animate={{ opacity: 1 }}\n              exit={{ opacity: 0 }}\n              transition={{ duration: 0.18 }}\n              onClick={() => setOpen(false)}\n              aria-hidden=\"true\"\n              className=\"fixed inset-0 bg-black/50 backdrop-blur-sm\"\n            />\n\n            {/* Dialog Surface */}\n            <motion.div\n              role=\"dialog\"\n              aria-modal=\"true\"\n              aria-labelledby={`${uniqueId}-heading`}\n              aria-describedby={`${uniqueId}-desc`}\n              layoutId={layoutId}\n              transition={springConfig}\n              drag={shouldReduceMotion ? false : \"y\"}\n              dragConstraints={{ top: 0, bottom: 0 }}\n              dragElastic={0.35}\n              onDragEnd={handleDragEnd}\n              className=\"relative z-10 w-full max-w-md overflow-hidden rounded-3xl border border-neutral-200 bg-white p-6 text-left shadow-2xl dark:border-[#262626] dark:bg-[#0D0D0D]\"\n            >\n              {/* Drag Handle Indicator */}\n              <div\n                aria-hidden=\"true\"\n                className=\"mx-auto mb-4 h-1 w-10 rounded-full bg-neutral-200 dark:bg-[#262626]\"\n              />\n\n              <div className=\"flex items-start justify-between gap-4\">\n                <div className=\"flex items-center gap-3\">\n                  <motion.div\n                    layoutId={`${layoutId}-icon`}\n                    transition={springConfig}\n                    className=\"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border border-neutral-200 bg-neutral-50 text-black dark:border-[#262626] dark:bg-[#141414] dark:text-white\"\n                  >\n                    <Sparkles className=\"h-4 w-4\" />\n                  </motion.div>\n                  <div>\n                    <motion.h3\n                      id={`${uniqueId}-heading`}\n                      layoutId={`${layoutId}-title`}\n                      transition={springConfig}\n                      className=\"text-base font-semibold text-black dark:text-white\"\n                    >\n                      {dialogTitle}\n                    </motion.h3>\n                    <motion.p\n                      layoutId={`${layoutId}-subtitle`}\n                      transition={springConfig}\n                      className=\"text-xs text-neutral-500 dark:text-neutral-400\"\n                    >\n                      Shared-element projection • Drag vertically to dismiss\n                    </motion.p>\n                  </div>\n                </div>\n\n                <button\n                  ref={closeButtonRef}\n                  type=\"button\"\n                  aria-label=\"Close dialog\"\n                  onClick={() => setOpen(false)}\n                  className=\"flex h-8 w-8 items-center justify-center rounded-full border border-neutral-200 text-neutral-500 transition-colors hover:border-black hover:text-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black dark:border-[#262626] dark:hover:border-white dark:hover:text-white dark:focus-visible:ring-white\"\n                >\n                  <X className=\"h-4 w-4\" />\n                </button>\n              </div>\n\n              <motion.div\n                initial={{ opacity: 0, y: 6 }}\n                animate={{ opacity: 1, y: 0 }}\n                exit={{ opacity: 0, y: 4 }}\n                transition={{ delay: 0.05, duration: 0.18 }}\n                className=\"mt-5\"\n              >\n                <p\n                  id={`${uniqueId}-desc`}\n                  className=\"text-xs leading-relaxed text-neutral-600 dark:text-neutral-300\"\n                >\n                  {dialogDescription}\n                </p>\n\n                {children || (\n                  <div className=\"mt-4 grid grid-cols-3 gap-2 rounded-2xl border border-neutral-200 bg-neutral-50 p-3 dark:border-[#1F1F1F] dark:bg-[#141414]\">\n                    <div>\n                      <div className=\"text-[10px] uppercase tracking-wider text-neutral-400\">\n                        Stiffness\n                      </div>\n                      <div className=\"mt-0.5 font-mono text-xs font-semibold text-black dark:text-white\">\n                        {stiffness} N/m\n                      </div>\n                    </div>\n                    <div>\n                      <div className=\"text-[10px] uppercase tracking-wider text-neutral-400\">\n                        Damping\n                      </div>\n                      <div className=\"mt-0.5 font-mono text-xs font-semibold text-black dark:text-white\">\n                        {damping} Ns/m\n                      </div>\n                    </div>\n                    <div>\n                      <div className=\"text-[10px] uppercase tracking-wider text-neutral-400\">\n                        Dismiss\n                      </div>\n                      <div className=\"mt-0.5 font-mono text-xs font-semibold text-black dark:text-white\">\n                        &gt;85px / Esc\n                      </div>\n                    </div>\n                  </div>\n                )}\n\n                <div className=\"mt-5 flex justify-end\">\n                  <button\n                    type=\"button\"\n                    onClick={() => setOpen(false)}\n                    className=\"rounded-xl bg-black px-4 py-2 text-xs font-semibold text-white transition-opacity hover:opacity-90 dark:bg-white dark:text-black\"\n                  >\n                    Done\n                  </button>\n                </div>\n              </motion.div>\n            </motion.div>\n          </div>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n\nexport default MorphingDialog;\n",
      "type": "registry:ui",
      "target": "components/ui/morphing-dialog.tsx"
    },
    {
      "path": "lib/utils.ts",
      "content": "import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport async function copyToClipboard(text: string): Promise<boolean> {\n  if (typeof window === \"undefined\") return false;\n\n  try {\n    if (navigator.clipboard && window.isSecureContext) {\n      await navigator.clipboard.writeText(text);\n      return true;\n    }\n\n    const textArea = document.createElement(\"textarea\");\n    textArea.value = text;\n    textArea.style.position = \"fixed\";\n    textArea.style.left = \"-999999px\";\n    textArea.style.top = \"-999999px\";\n    document.body.appendChild(textArea);\n    textArea.focus();\n    textArea.select();\n    const succeeded = document.execCommand(\"copy\");\n    textArea.remove();\n    return succeeded;\n  } catch {\n    return false;\n  }\n}\n",
      "type": "registry:lib",
      "target": "lib/utils.ts"
    }
  ]
}
