{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dialog-bordered",
  "title": "Bordered dialog",
  "description": "Styled dialog: the Bordered set. 5 decorative dialog variations (RingDialog, GlowDialog, GradientBorderDialog, InsetDialog, AccentBarDialog) 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-bordered.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/* Bordered dialog family: 5 decorative modals with an emphasized panel frame/edge.\n   Each export is a complete dialog: internal open/closed state (uncontrolled\n   defaultOpen or controlled open/onOpenChange), NO radix or portal - a\n   self-contained fixed backdrop + fixed panel. It closes on a backdrop click,\n   Escape or the close button. The panel takes focus on open. AnimatePresence\n   handles enter/exit; the animation is a plain center fade+scale in all of them,\n   with no transform under reduced motion (only a fade). Color comes ONLY from\n   tokens; transparency ONLY via color-mix(in oklab, var(--color-x) N%,\n   transparent). */\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 z-10 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/* Bordered ailesinin ortak animasyonu: ortada fade + scale. */\nconst centerMotion = {\n  initial: { opacity: 0, scale: 0.94 },\n  animate: { opacity: 1, scale: 1 },\n  exit: { opacity: 0, scale: 0.94 },\n  transition: { duration: 0.2, ease: \"easeOut\" as const },\n}\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. panelClassName carries the panel's frame and border styling; an extra decorative layer above the children (such as an accent strip) is added through the accent prop. */\nfunction DialogShell({\n  props,\n  panelClassName,\n  accent,\n}: {\n  props: DialogProps\n  panelClassName?: string\n  accent?: React.ReactNode\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 ? fade : centerMotion\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            className={backdropClass}\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              data-slot=\"styled-dialog\"\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={reduce ? { duration: 0.2, ease: \"easeOut\" } : centerMotion.transition}\n              onClick={(e) => e.stopPropagation()}\n            >\n              {accent}\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/* Ring: a double ring. The panel border plus two token box-shadow lines from outside, like a ring-offset (the ring token, thinning through color-mix). */\nexport function RingDialog(props: DialogProps) {\n  return (\n    <DialogShell\n      props={props}\n      panelClassName=\"border-border shadow-[0_0_0_1px_color-mix(in_oklab,var(--color-ring)_45%,transparent),0_0_0_5px_color-mix(in_oklab,var(--color-ring)_18%,transparent)]\"\n    />\n  )\n}\n\n/* Glow: panel etrafinda primary token glow (dusuk yogunluklu buyuk box-shadow). */\nexport function GlowDialog(props: DialogProps) {\n  return (\n    <DialogShell\n      props={props}\n      panelClassName=\"border-[color-mix(in_oklab,var(--color-primary)_35%,transparent)] shadow-[0_0_45px_color-mix(in_oklab,var(--color-primary)_28%,transparent),0_0_0_1px_color-mix(in_oklab,var(--color-primary)_20%,transparent)]\"\n    />\n  )\n}\n\n/* GradientBorder: a layered gradient frame. The before pseudo extends 1px outside\n   the panel (-inset-px, -z-10) and paints a gradient from tokens; the panel's opaque\n   bg-popover surface covers the inside, so only the 1px frame is visible. No\n   mask/compose needed. */\nexport function GradientBorderDialog(props: DialogProps) {\n  return (\n    <DialogShell\n      props={props}\n      panelClassName=\"border-transparent shadow-lg before:absolute before:-inset-px before:-z-10 before:rounded-[inherit] before:bg-[linear-gradient(135deg,color-mix(in_oklab,var(--color-primary)_70%,transparent),color-mix(in_oklab,var(--color-ring)_45%,transparent))] before:content-['']\"\n    />\n  )\n}\n\n/* Inset: an inset highlight (top line) on the panel's inner edge plus a thin inner border, both from a token colour via inset box-shadow. */\nexport function InsetDialog(props: DialogProps) {\n  return (\n    <DialogShell\n      props={props}\n      panelClassName=\"border-border shadow-[inset_0_1px_0_0_color-mix(in_oklab,var(--color-foreground)_18%,transparent),inset_0_0_0_1px_color-mix(in_oklab,var(--color-foreground)_8%,transparent)]\"\n    />\n  )\n}\n\n/* AccentBar: a full-width primary token accent strip above the panel (h-1, its top corners rounded to match the panel). */\nexport function AccentBarDialog(props: DialogProps) {\n  return (\n    <DialogShell\n      props={props}\n      panelClassName=\"overflow-hidden\"\n      accent={\n        <span\n          aria-hidden=\"true\"\n          className=\"pointer-events-none absolute inset-x-0 top-0 h-1 rounded-t-xl bg-primary\"\n        />\n      }\n    />\n  )\n}\n",
      "type": "registry:component",
      "target": "components/ui/dialog-bordered.tsx"
    }
  ],
  "categories": [
    "styled",
    "dialog"
  ],
  "type": "registry:component"
}