{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ds-morphing-dialog",
  "description": "Morphing Dialog using framer-motion.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "@lema-ds/button"
  ],
  "files": [
    {
      "path": "components/ds/ds-morphing-dialog.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { XIcon } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Button } from \"@/components/ui/button\"\n\n// ── Types ──\n\nexport interface MorphingDialogProps {\n  children: React.ReactNode\n}\n\ninterface MorphingDialogContextType {\n  isOpen: boolean\n  setIsOpen: (open: boolean) => void\n  uniqueId: string\n}\n\nconst MorphingDialogContext =\n  React.createContext<MorphingDialogContextType | null>(null)\n\nfunction useMorphingDialog() {\n  const context = React.useContext(MorphingDialogContext)\n  if (!context) {\n    throw new Error(\n      \"MorphingDialog components must be used within a MorphingDialog provider\"\n    )\n  }\n  return context\n}\n\n// ── Context Provider ──\n\nexport function MorphingDialog({ children }: MorphingDialogProps) {\n  const [isOpen, setIsOpen] = React.useState(false)\n  const uniqueId = React.useId()\n\n  React.useEffect(() => {\n    const handleKeyDown = (e: KeyboardEvent) => {\n      if (e.key === \"Escape\") {\n        setIsOpen(false)\n      }\n    }\n    if (isOpen) {\n      document.addEventListener(\"keydown\", handleKeyDown)\n      document.body.style.overflow = \"hidden\"\n    } else {\n      document.body.style.overflow = \"\"\n    }\n    return () => {\n      document.removeEventListener(\"keydown\", handleKeyDown)\n      document.body.style.overflow = \"\"\n    }\n  }, [isOpen])\n\n  return (\n    <MorphingDialogContext.Provider value={{ isOpen, setIsOpen, uniqueId }}>\n      {children}\n    </MorphingDialogContext.Provider>\n  )\n}\n\n// ── Components ──\n\nexport const MorphingDialogTrigger = React.forwardRef<\n  HTMLDivElement,\n  React.HTMLAttributes<HTMLDivElement>\n>(({ className, children, ...props }, ref) => {\n  const { setIsOpen } = useMorphingDialog()\n\n  return (\n    <div\n      ref={ref}\n      className={cn(\"cursor-pointer\", className)}\n      onClick={() => setIsOpen(true)}\n      {...props}\n    >\n      {children}\n    </div>\n  )\n})\nMorphingDialogTrigger.displayName = \"MorphingDialogTrigger\"\n\nexport const MorphingDialogContainer = React.forwardRef<\n  HTMLDivElement,\n  React.HTMLAttributes<HTMLDivElement>\n>(({ className, children, ...props }, ref) => {\n  const { isOpen, setIsOpen } = useMorphingDialog()\n\n  if (!isOpen) return null\n\n  return (\n    <>\n      <div\n        className=\"fixed inset-0 z-50 animate-in bg-foreground/40 backdrop-blur-sm duration-200 fade-in-0\"\n        onClick={() => setIsOpen(false)}\n      />\n      <div className=\"pointer-events-none fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6\">\n        <div\n          ref={ref}\n          className={cn(\n            \"pointer-events-auto relative flex w-full max-w-lg animate-in flex-col overflow-hidden rounded-2xl border bg-background shadow-2xl duration-200 fade-in-0 zoom-in-95 focus:outline-none\",\n            className\n          )}\n          {...props}\n        >\n          {children}\n        </div>\n      </div>\n    </>\n  )\n})\nMorphingDialogContainer.displayName = \"MorphingDialogContainer\"\n\nexport const MorphingDialogTitle = React.forwardRef<\n  HTMLHeadingElement,\n  React.HTMLAttributes<HTMLHeadingElement>\n>(({ className, ...props }, ref) => {\n  return (\n    <h2\n      ref={ref}\n      className={cn(\"text-xl font-semibold tracking-tight\", className)}\n      {...props}\n    />\n  )\n})\nMorphingDialogTitle.displayName = \"MorphingDialogTitle\"\n\nexport const MorphingDialogSubtitle = React.forwardRef<\n  HTMLParagraphElement,\n  React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => {\n  return (\n    <p\n      ref={ref}\n      className={cn(\"text-sm text-muted-foreground\", className)}\n      {...props}\n    />\n  )\n})\nMorphingDialogSubtitle.displayName = \"MorphingDialogSubtitle\"\n\nexport const MorphingDialogDescription = React.forwardRef<\n  HTMLParagraphElement,\n  React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => {\n  return (\n    <div\n      ref={ref}\n      className={cn(\n        \"animate-in text-sm text-muted-foreground duration-200 fade-in-0 slide-in-from-bottom-1\",\n        className\n      )}\n      {...props}\n    />\n  )\n})\nMorphingDialogDescription.displayName = \"MorphingDialogDescription\"\n\nexport const MorphingDialogImage = React.forwardRef<\n  HTMLImageElement,\n  React.ImgHTMLAttributes<HTMLImageElement>\n>(({ className, alt = \"\", ...props }, ref) => {\n  return (\n    // eslint-disable-next-line @next/next/no-img-element\n    <img\n      ref={ref}\n      alt={alt}\n      loading=\"lazy\"\n      decoding=\"async\"\n      className={cn(\"object-cover\", className)}\n      {...props}\n    />\n  )\n})\nMorphingDialogImage.displayName = \"MorphingDialogImage\"\n\nexport const MorphingDialogClose = React.forwardRef<\n  HTMLButtonElement,\n  React.ComponentPropsWithoutRef<typeof Button>\n>(({ className, ...props }, ref) => {\n  const { setIsOpen } = useMorphingDialog()\n\n  return (\n    <Button\n      ref={ref}\n      variant=\"ghost\"\n      size=\"icon\"\n      className={cn(\"rounded-full\", className)}\n      onClick={() => setIsOpen(false)}\n      {...props}\n    >\n      <XIcon className=\"size-4\" />\n      <span className=\"sr-only\">Close</span>\n    </Button>\n  )\n})\nMorphingDialogClose.displayName = \"MorphingDialogClose\"\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}
