{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dialog-styled",
  "title": "Dialog essentials",
  "description": "Styled dialog: the essentials set. 5 decorative dialog variations (CenterDialog, SlideUpDialog, GlassDialog, FullscreenDialog, DropDialog) 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/dialog-styled.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { X } from \"lucide-react\"\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\n/* Dialog family: 5 decorative modals. Every export is a complete dialog: internal open/closed state (uncontrolled defaultOpen or controlled open/onOpenChange), NO radix and no portal - a self-contained fixed backdrop plus a fixed panel. It closes on a backdrop click, Escape or the close button. The panel takes focus on open. AnimatePresence enter/exit; no transform under reduced motion (fade only). Colour comes ONLY from tokens, alpha via color-mix. */\n\nexport type StyledSize = \"sm\" | \"md\" | \"lg\" | \"xl\"\n\nconst panelSize: Record<StyledSize, string> = {\n  sm: \"max-w-sm\",\n  md: \"max-w-md\",\n  lg: \"max-w-lg\",\n  xl: \"max-w-2xl\",\n}\n\ninterface DialogProps {\n  size?: StyledSize\n  trigger?: React.ReactNode\n  title?: React.ReactNode\n  children?: React.ReactNode\n  className?: string\n  open?: boolean\n  defaultOpen?: boolean\n  onOpenChange?: (o: boolean) => void\n}\n\nconst backdropClass =\n  \"fixed inset-0 z-50 flex items-center justify-center p-4 bg-[color-mix(in_oklab,var(--color-foreground)_50%,transparent)]\"\n\nconst panelBase =\n  \"relative w-full rounded-xl border border-border bg-popover text-popover-foreground shadow-lg outline-none\"\n\nconst closeBtn =\n  \"absolute right-3 top-3 inline-flex size-8 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-[color-mix(in_oklab,var(--color-foreground)_8%,transparent)] hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 [&_svg]:size-4 [&_svg]:shrink-0 [&_i]:text-base [&_i]:leading-none\"\n\nconst triggerBtn =\n  \"inline-flex h-9 shrink-0 select-none items-center justify-center gap-2 whitespace-nowrap rounded-lg border border-border bg-secondary px-4 text-sm font-medium text-secondary-foreground outline-none transition-colors hover:bg-[color-mix(in_oklab,var(--color-foreground)_6%,transparent)] focus-visible:ring-[3px] focus-visible:ring-ring/50\"\n\n/* Controlled/uncontrolled acik durum yonetimi. */\nfunction useDialogState(props: DialogProps) {\n  const { open, defaultOpen, onOpenChange } = props\n  const isControlled = open !== undefined\n  const [internal, setInternal] = React.useState(defaultOpen ?? false)\n  const isOpen = isControlled ? open : internal\n\n  const setOpen = React.useCallback(\n    (next: boolean) => {\n      if (!isControlled) setInternal(next)\n      onOpenChange?.(next)\n    },\n    [isControlled, onOpenChange]\n  )\n\n  return { isOpen, setOpen }\n}\n\n/* Shared shell: trigger plus an AnimatePresence backdrop plus panel. panelProps carries the enter/exit animation supplied from outside. */\nfunction DialogShell({\n  props,\n  panelClassName,\n  panelMotion,\n  backdropClassName,\n}: {\n  props: DialogProps\n  panelClassName?: string\n  panelMotion?: {\n    initial: Record<string, number>\n    animate: Record<string, number>\n    exit: Record<string, number>\n    transition?: Record<string, unknown>\n  }\n  backdropClassName?: string\n}) {\n  const { size = \"md\", trigger, title, children, className } = props\n  const { isOpen, setOpen } = useDialogState(props)\n  const reduce = useReducedMotion()\n  const panelRef = React.useRef<HTMLDivElement>(null)\n\n  React.useEffect(() => {\n    if (!isOpen) return\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key === \"Escape\") setOpen(false)\n    }\n    window.addEventListener(\"keydown\", onKey)\n    const id = window.requestAnimationFrame(() => panelRef.current?.focus())\n    return () => {\n      window.removeEventListener(\"keydown\", onKey)\n      window.cancelAnimationFrame(id)\n    }\n  }, [isOpen, setOpen])\n\n  const fade = { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 } }\n  const motionProps = reduce || !panelMotion ? fade : panelMotion\n\n  return (\n    <>\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-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\": isOpen,\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={isOpen}\n\n            onClick={() => setOpen(true)}\n\n            className={triggerBtn}\n\n          >\n\n            {trigger ?? \"Open dialog\"}\n\n          </button>\n\n        )}\n\n      </span>\n\n      <AnimatePresence>\n        {isOpen ? (\n          <motion.div\n            data-slot=\"styled-dialog\"\n            className={cn(backdropClass, backdropClassName)}\n            initial={{ opacity: 0 }}\n            animate={{ opacity: 1 }}\n            exit={{ opacity: 0 }}\n            transition={{ duration: 0.2, ease: \"easeOut\" }}\n            onClick={() => setOpen(false)}\n          >\n            <motion.div\n              ref={panelRef}\n              role=\"dialog\"\n              aria-modal=\"true\"\n              tabIndex={-1}\n              className={cn(panelBase, panelSize[size], panelClassName, className)}\n              initial={motionProps.initial}\n              animate={motionProps.animate}\n              exit={motionProps.exit}\n              transition={panelMotion?.transition ?? { duration: 0.2, ease: \"easeOut\" }}\n              onClick={(e) => e.stopPropagation()}\n            >\n              <button\n                type=\"button\"\n                aria-label=\"Close\"\n                className={closeBtn}\n                onClick={() => setOpen(false)}\n              >\n                <X />\n              </button>\n              {title ? (\n                <div className=\"border-b border-border px-6 py-4 pr-12 text-base font-semibold\">\n                  {title}\n                </div>\n              ) : null}\n              <div className=\"px-6 py-5 text-sm text-muted-foreground\">{children}</div>\n            </motion.div>\n          </motion.div>\n        ) : null}\n      </AnimatePresence>\n    </>\n  )\n}\n\n/* Center: ortada fade + scale ile buyuyerek girer. */\nexport function CenterDialog(props: DialogProps) {\n  return (\n    <DialogShell\n      props={props}\n      panelMotion={{\n        initial: { opacity: 0, scale: 0.94 },\n        animate: { opacity: 1, scale: 1 },\n        exit: { opacity: 0, scale: 0.94 },\n        transition: { type: \"spring\", stiffness: 320, damping: 26 },\n      }}\n    />\n  )\n}\n\n/* SlideUp: viewport alt kenarindan yukari kayarak ortaya gelir. */\nexport function SlideUpDialog(props: DialogProps) {\n  return (\n    <DialogShell\n      props={props}\n      panelMotion={{\n        initial: { opacity: 0, y: 48 },\n        animate: { opacity: 1, y: 0 },\n        exit: { opacity: 0, y: 48 },\n        transition: { type: \"spring\", stiffness: 300, damping: 30 },\n      }}\n    />\n  )\n}\n\n/* Glass: buzlu cam panel + backdrop-blur. */\nexport function GlassDialog(props: DialogProps) {\n  return (\n    <DialogShell\n      props={props}\n      backdropClassName=\"bg-[color-mix(in_oklab,var(--color-foreground)_40%,transparent)] supports-[backdrop-filter]:backdrop-blur-sm\"\n      panelClassName=\"border-border bg-[color-mix(in_oklab,var(--color-popover)_75%,transparent)] supports-[backdrop-filter]:bg-[color-mix(in_oklab,var(--color-popover)_55%,transparent)] supports-[backdrop-filter]:backdrop-blur-xl shadow-[inset_0_1px_0_color-mix(in_oklab,var(--color-foreground)_12%,transparent)]\"\n      panelMotion={{\n        initial: { opacity: 0, scale: 0.96 },\n        animate: { opacity: 1, scale: 1 },\n        exit: { opacity: 0, scale: 0.96 },\n        transition: { duration: 0.22, ease: \"easeOut\" },\n      }}\n    />\n  )\n}\n\n/* Fullscreen: neredeyse tam ekran genis panel. */\nexport function FullscreenDialog(props: DialogProps) {\n  return (\n    <DialogShell\n      props={props}\n      backdropClassName=\"p-0 sm:p-6\"\n      panelClassName=\"!max-w-none h-full w-full rounded-none sm:h-[calc(100vh-3rem)] sm:rounded-xl\"\n      panelMotion={{\n        initial: { opacity: 0, scale: 0.98 },\n        animate: { opacity: 1, scale: 1 },\n        exit: { opacity: 0, scale: 0.98 },\n        transition: { duration: 0.24, ease: \"easeOut\" },\n      }}\n    />\n  )\n}\n\n/* Drop: ustten hafif ziplama ile duser. */\nexport function DropDialog(props: DialogProps) {\n  return (\n    <DialogShell\n      props={props}\n      panelMotion={{\n        initial: { opacity: 0, y: -56 },\n        animate: { opacity: 1, y: 0 },\n        exit: { opacity: 0, y: -32 },\n        transition: { type: \"spring\", stiffness: 420, damping: 18 },\n      }}\n    />\n  )\n}\n",
      "type": "registry:component",
      "target": "components/ui/dialog-styled.tsx"
    }
  ],
  "categories": [
    "styled",
    "dialog"
  ],
  "type": "registry:component"
}