{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "cavemio-dropdown-menu",
  "title": "Dropdown menu",
  "description": "Actions behind a button: the menu rises off the trigger, one highlight glides between rows, and checkbox rows draw their tick in place.",
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/components/dropdown-menu.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport {\n  enterStyle,\n  themeVars,\n  useDismiss,\n  useFloating,\n  usePresence,\n  type Align,\n  type Side,\n} from \"./floating\";\nimport { MenuList, type MenuEntry } from \"./menu-list\";\nimport { useInteractionReducedMotion } from \"./imported-ui-interaction-motion\";\n\n/* ─────────────────────────────────────────────────────────\n * DROPDOWN MENU: actions behind a button\n *\n *   open     the menu rises off the trigger out of a blur, from\n *            the point on the trigger nearest to it; it flips\n *            above when there's no room below\n *   move     one highlight glides between rows\n *   pick     the menu closes and focus goes back to the trigger;\n *            checkbox rows draw their tick and stay open\n *\n * Opening from the keyboard (Enter, Space, ↓) focuses the first\n * row; ↑ focuses the last. Escape or a press outside closes it.\n * ───────────────────────────────────────────────────────── */\n\nexport type { MenuEntry } from \"./menu-list\";\n\nexport interface DropdownMenuProps {\n  /** The button that opens it. It gets aria-haspopup, aria-expanded and the click. */\n  trigger: React.ReactElement<React.HTMLAttributes<HTMLElement>>;\n  items: MenuEntry[];\n  side?: Side;\n  align?: Align;\n  open?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  /** Accessible name of the menu. */\n  label?: string;\n  /** Minimum width in px; never narrower than the trigger. */\n  minWidth?: number;\n}\n\nexport function DropdownMenu({\n  trigger,\n  items,\n  side = \"bottom\",\n  align = \"start\",\n  open: controlled,\n  onOpenChange,\n  label,\n  minWidth = 200,\n}: DropdownMenuProps) {\n  const reduced = useInteractionReducedMotion();\n  const anchor = React.useRef<HTMLSpanElement>(null);\n  const surface = React.useRef<HTMLDivElement>(null);\n  const [own, setOwn] = React.useState(false);\n  const [focusOn, setFocusOn] = React.useState<\"first\" | \"last\" | \"none\">(\n    \"none\",\n  );\n  const open = controlled ?? own;\n  const { mounted, shown } = usePresence(open, 180);\n  const place = useFloating({\n    open: mounted,\n    anchor,\n    floating: surface,\n    side,\n    align,\n    offset: 6,\n  });\n  const [vars, setVars] = React.useState<React.CSSProperties>({});\n  const id = React.useId();\n  const triggerId = React.useId();\n\n  const setOpen = (next: boolean, refocus = false) => {\n    if (controlled === undefined) setOwn(next);\n    onOpenChange?.(next);\n    // By id rather than a ref: this runs from handlers that are created while rendering.\n    if (!next && refocus)\n      document.getElementById(trigger.props.id ?? triggerId)?.focus();\n  };\n\n  useDismiss(open, (reason) => setOpen(false, reason === \"escape\"), [\n    anchor,\n    surface,\n  ]);\n\n  const [width, setWidth] = React.useState(minWidth);\n  React.useLayoutEffect(() => {\n    if (!mounted) return;\n    setVars(themeVars(anchor.current));\n    setWidth(Math.max(minWidth, anchor.current?.offsetWidth ?? 0));\n  }, [mounted, minWidth]);\n\n  return (\n    <>\n      <span ref={anchor} className=\"inline-flex\">\n        {React.cloneElement(trigger, {\n          id: trigger.props.id ?? triggerId,\n          \"aria-haspopup\": \"menu\",\n          \"aria-expanded\": open,\n          \"aria-controls\": open ? id : undefined,\n          onClick: (e: React.MouseEvent<HTMLElement>) => {\n            trigger.props.onClick?.(e);\n            setFocusOn(e.detail === 0 ? \"first\" : \"none\");\n            setOpen(!open);\n          },\n          onKeyDown: (e: React.KeyboardEvent<HTMLElement>) => {\n            trigger.props.onKeyDown?.(e);\n            if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n              e.preventDefault();\n              setFocusOn(e.key === \"ArrowDown\" ? \"first\" : \"last\");\n              setOpen(true);\n            }\n          },\n        })}\n      </span>\n      {mounted &&\n        createPortal(\n          <div\n            ref={surface}\n            id={id}\n            className=\"fixed left-0 top-0 z-[55] overflow-hidden rounded-[14px] bg-popover text-popover-foreground shadow-[0_0_0_1px_var(--border)]\"\n            style={{\n              ...vars,\n              left: place.x,\n              top: place.y,\n              minWidth: width,\n              transformOrigin: place.origin,\n              ...enterStyle(shown, place.side, reduced),\n            }}\n          >\n            <MenuList\n              items={items}\n              label={label}\n              autoFocus={focusOn}\n              onClose={() => setOpen(false, true)}\n            />\n          </div>,\n          document.body,\n        )}\n    </>\n  );\n}\n\nexport default DropdownMenu;\n",
      "type": "registry:component"
    },
    {
      "path": "registry/components/floating.ts",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\n/* ─────────────────────────────────────────────────────────\n * FLOATING: what every popover, menu and tooltip shares\n *\n *   place     beside an anchor on a side, lined up start, centre\n *             or end; flips to the other side when it doesn't fit\n *             and shifts to stay `padding` inside the viewport;\n *             follows scroll and resize\n *   presence  mounts on open, shows a frame later (so the entry\n *             transitions run), hides, then unmounts after `exit`\n *   dismiss   Escape and a press outside both close it\n *   theme     the portal carries the anchor's theme tokens, so a\n *             light specimen on a dark page stays light\n * ───────────────────────────────────────────────────────── */\n\nexport type Side = \"top\" | \"bottom\" | \"left\" | \"right\";\nexport type Align = \"start\" | \"center\" | \"end\";\n\nconst TOKENS = [\n  \"--background\",\n  \"--foreground\",\n  \"--popover\",\n  \"--popover-foreground\",\n  \"--border\",\n  \"--accent\",\n  \"--accent-foreground\",\n  \"--primary\",\n  \"--primary-foreground\",\n  \"--muted\",\n  \"--muted-foreground\",\n  \"--ring\",\n  \"--card\",\n];\n\n/** The anchor's theme tokens as inline styles for something portalled out of its tree. */\nexport function themeVars(anchor: Element | null): React.CSSProperties {\n  if (!anchor) return {};\n  const style = getComputedStyle(anchor);\n  const vars: Record<string, string> = {};\n  for (const t of TOKENS) {\n    const v = style.getPropertyValue(t);\n    if (v) vars[t] = v;\n  }\n  return vars as React.CSSProperties;\n}\n\nconst OPPOSITE: Record<Side, Side> = {\n  top: \"bottom\",\n  bottom: \"top\",\n  left: \"right\",\n  right: \"left\",\n};\n\nexport interface Placement {\n  x: number;\n  y: number;\n  side: Side;\n  /** Where the surface grows from, for transform-origin. */\n  origin: string;\n  ready: boolean;\n}\n\n/** Positions `floating` (position: fixed) next to `anchor` while `open`. Pass a point instead of an anchor for context menus. */\nexport function useFloating({\n  open,\n  anchor,\n  point,\n  floating,\n  side = \"bottom\",\n  align = \"center\",\n  offset = 8,\n  padding = 8,\n}: {\n  open: boolean;\n  anchor?: React.RefObject<Element | null>;\n  point?: { x: number; y: number } | null;\n  floating: React.RefObject<HTMLElement | null>;\n  side?: Side;\n  align?: Align;\n  offset?: number;\n  padding?: number;\n}): Placement {\n  const [place, setPlace] = React.useState<Placement>({\n    x: -9999,\n    y: -9999,\n    side,\n    origin: \"center\",\n    ready: false,\n  });\n\n  React.useLayoutEffect(() => {\n    if (!open) return;\n    let frame = 0;\n    const measure = () => {\n      const el = floating.current;\n      if (!el) return;\n      const a = point\n        ? {\n            left: point.x,\n            right: point.x,\n            top: point.y,\n            bottom: point.y,\n            width: 0,\n            height: 0,\n          }\n        : anchor?.current?.getBoundingClientRect();\n      if (!a) return;\n      const w = el.offsetWidth;\n      const h = el.offsetHeight;\n      const vw = window.innerWidth;\n      const vh = window.innerHeight;\n      const room: Record<Side, number> = {\n        top: a.top - padding,\n        bottom: vh - a.bottom - padding,\n        left: a.left - padding,\n        right: vw - a.right - padding,\n      };\n      const need =\n        side === \"top\" || side === \"bottom\" ? h + offset : w + offset;\n      const s =\n        room[side] < need && room[OPPOSITE[side]] > room[side]\n          ? OPPOSITE[side]\n          : side;\n      let x: number;\n      let y: number;\n      if (s === \"top\" || s === \"bottom\") {\n        y = s === \"bottom\" ? a.bottom + offset : a.top - offset - h;\n        x =\n          align === \"start\"\n            ? a.left\n            : align === \"end\"\n              ? a.right - w\n              : a.left + a.width / 2 - w / 2;\n        if (point) x = a.left;\n      } else {\n        x = s === \"right\" ? a.right + offset : a.left - offset - w;\n        y =\n          align === \"start\"\n            ? a.top\n            : align === \"end\"\n              ? a.bottom - h\n              : a.top + a.height / 2 - h / 2;\n      }\n      x = Math.max(padding, Math.min(vw - padding - w, x));\n      y = Math.max(padding, Math.min(vh - padding - h, y));\n      // Grow from the point on the anchor's edge nearest the surface.\n      const ox =\n        s === \"left\"\n          ? \"100%\"\n          : s === \"right\"\n            ? \"0%\"\n            : `${Math.max(0, Math.min(w, a.left + a.width / 2 - x))}px`;\n      const oy =\n        s === \"top\"\n          ? \"100%\"\n          : s === \"bottom\"\n            ? \"0%\"\n            : `${Math.max(0, Math.min(h, a.top + a.height / 2 - y))}px`;\n      const next = {\n        x: Math.round(x),\n        y: Math.round(y),\n        side: s,\n        origin: `${ox} ${oy}`,\n        ready: true,\n      };\n      setPlace((p) =>\n        p.x === next.x &&\n        p.y === next.y &&\n        p.side === next.side &&\n        p.origin === next.origin &&\n        p.ready\n          ? p\n          : next,\n      );\n    };\n    const schedule = () => {\n      cancelAnimationFrame(frame);\n      frame = requestAnimationFrame(measure);\n    };\n    measure();\n    const ro = new ResizeObserver(schedule);\n    if (floating.current) ro.observe(floating.current);\n    window.addEventListener(\"scroll\", schedule, {\n      capture: true,\n      passive: true,\n    });\n    window.addEventListener(\"resize\", schedule);\n    return () => {\n      cancelAnimationFrame(frame);\n      ro.disconnect();\n      window.removeEventListener(\"scroll\", schedule, { capture: true });\n      window.removeEventListener(\"resize\", schedule);\n    };\n  }, [open, anchor, point, floating, side, align, offset, padding]);\n\n  return open ? place : { ...place, ready: false };\n}\n\n/** Mount → show next frame → hide → unmount after `exit` ms. */\nexport function usePresence(open: boolean, exit = 160) {\n  const [mounted, setMounted] = React.useState(open);\n  const [shown, setShown] = React.useState(false);\n  if (open && !mounted) setMounted(true);\n  React.useEffect(() => {\n    if (open) {\n      let inner = 0;\n      const outer = requestAnimationFrame(() => {\n        inner = requestAnimationFrame(() => setShown(true));\n      });\n      return () => {\n        cancelAnimationFrame(outer);\n        cancelAnimationFrame(inner);\n      };\n    }\n    const timer = window.setTimeout(() => {\n      setMounted(false);\n      setShown(false);\n    }, exit);\n    return () => window.clearTimeout(timer);\n  }, [open, exit]);\n  return { mounted: mounted || open, shown: open && shown };\n}\n\n/** Escape and presses outside `refs` call onDismiss while `open`. */\nexport function useDismiss(\n  open: boolean,\n  onDismiss: (reason: \"escape\" | \"outside\") => void,\n  refs: React.RefObject<Element | null>[],\n) {\n  const latest = React.useRef({ onDismiss, refs });\n  React.useEffect(() => {\n    latest.current = { onDismiss, refs };\n  });\n  React.useEffect(() => {\n    if (!open) return;\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key !== \"Escape\") return;\n      e.stopPropagation();\n      latest.current.onDismiss(\"escape\");\n    };\n    const onDown = (e: PointerEvent) => {\n      const target = e.target as Node;\n      if (latest.current.refs.some((r) => r.current?.contains(target))) return;\n      latest.current.onDismiss(\"outside\");\n    };\n    document.addEventListener(\"keydown\", onKey);\n    document.addEventListener(\"pointerdown\", onDown, true);\n    return () => {\n      document.removeEventListener(\"keydown\", onKey);\n      document.removeEventListener(\"pointerdown\", onDown, true);\n    };\n  }, [open]);\n}\n\n/** The entry pose for a surface on `side`: it comes 6px from the anchor, 0.96 and blurred. */\nexport function enterStyle(\n  shown: boolean,\n  side: Side,\n  reduced: boolean,\n  ease = \"cubic-bezier(0.16,1,0.3,1)\",\n): React.CSSProperties {\n  const d = 6;\n  const shift =\n    side === \"top\"\n      ? `0 ${d}px`\n      : side === \"bottom\"\n        ? `0 -${d}px`\n        : side === \"left\"\n          ? `${d}px 0`\n          : `-${d}px 0`;\n  return {\n    opacity: shown ? 1 : 0,\n    translate: shown || reduced ? \"0 0\" : shift,\n    scale: shown || reduced ? \"1\" : \"0.96\",\n    filter: shown || reduced ? \"blur(0px)\" : \"blur(4px)\",\n    transition: reduced\n      ? \"opacity 120ms ease-out\"\n      : shown\n        ? `opacity 220ms ${ease}, translate 320ms ${ease}, scale 320ms ${ease}, filter 220ms ${ease}`\n        : `opacity 140ms ${ease}, translate 180ms ${ease}, scale 180ms ${ease}, filter 140ms ${ease}`,\n  };\n}\n",
      "type": "registry:component"
    },
    {
      "path": "registry/components/menu-list.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport {\n  EASE_OUT,\n  useInteractionReducedMotion,\n} from \"./imported-ui-interaction-motion\";\n\n/* ─────────────────────────────────────────────────────────\n * MENU LIST: the rows inside a dropdown or context menu\n *\n *   highlight  one fill glides between rows as the pointer or\n *              arrow keys move; it never blinks off and on\n *   keys       arrows (wrapping), Home/End, typing a few letters\n *              jumps to a row, Enter/Space picks\n *   check      checkbox rows draw their tick in place and keep\n *              the menu open\n * ───────────────────────────────────────────────────────── */\n\nexport type MenuEntry =\n  | {\n      type?: \"item\";\n      id: string;\n      label: string;\n      icon?: React.ReactNode;\n      shortcut?: string;\n      destructive?: boolean;\n      disabled?: boolean;\n      onSelect?: () => void;\n    }\n  | {\n      type: \"checkbox\";\n      id: string;\n      label: string;\n      icon?: React.ReactNode;\n      checked: boolean;\n      onCheckedChange: (checked: boolean) => void;\n      disabled?: boolean;\n    }\n  | { type: \"label\"; label: string }\n  | { type: \"separator\" };\n\ntype Row = Extract<MenuEntry, { id: string }>;\n\nexport interface MenuListProps {\n  items: MenuEntry[];\n  /** Called after an item (not a checkbox) is picked. */\n  onClose: () => void;\n  /** Focus the first row on mount (keyboard open). */\n  autoFocus?: \"first\" | \"last\" | \"none\";\n  label?: string;\n}\n\nfunction Tick({ on, reduced }: { on: boolean; reduced: boolean }) {\n  return (\n    <svg viewBox=\"0 0 16 16\" fill=\"none\" className=\"size-3.5\">\n      <path\n        d=\"M3.5 8.5 6.5 11.5 12.5 4.5\"\n        stroke=\"currentColor\"\n        strokeWidth=\"1.8\"\n        strokeLinecap=\"round\"\n        strokeLinejoin=\"round\"\n        pathLength={1}\n        strokeDasharray={1}\n        style={{\n          strokeDashoffset: on ? 0 : 1,\n          transition: reduced\n            ? \"none\"\n            : `stroke-dashoffset ${on ? 280 : 140}ms ${EASE_OUT}`,\n        }}\n      />\n    </svg>\n  );\n}\n\nexport function MenuList({\n  items,\n  onClose,\n  autoFocus = \"none\",\n  label,\n}: MenuListProps) {\n  const reduced = useInteractionReducedMotion();\n  const listRef = React.useRef<HTMLDivElement>(null);\n  const rows = items.filter((i): i is Row => \"id\" in i && !i.disabled);\n  const [active, setActive] = React.useState<string | null>(() =>\n    autoFocus === \"none\"\n      ? null\n      : ((autoFocus === \"first\" ? rows[0] : rows[rows.length - 1])?.id ?? null),\n  );\n  const [mark, setMark] = React.useState<{ y: number; h: number } | null>(null);\n  const [ready, setReady] = React.useState(false);\n  const typed = React.useRef({ text: \"\", at: 0 });\n\n  const focusRow = (id: string | null) => {\n    setActive(id);\n    if (id)\n      listRef.current\n        ?.querySelector<HTMLElement>(`[data-menu-row=\"${CSS.escape(id)}\"]`)\n        ?.focus({ preventScroll: true });\n  };\n\n  // On mount: focus the starting row (keyboard open) or the list itself.\n  React.useEffect(() => {\n    const list = listRef.current;\n    const row = active\n      ? list?.querySelector<HTMLElement>(\n          `[data-menu-row=\"${CSS.escape(active)}\"]`,\n        )\n      : null;\n    (row ?? list)?.focus({ preventScroll: true });\n  }, []);\n\n  React.useLayoutEffect(() => {\n    const list = listRef.current;\n    if (!list) return;\n    const measure = () => {\n      const el = active\n        ? list.querySelector<HTMLElement>(\n            `[data-menu-row=\"${CSS.escape(active)}\"]`,\n          )\n        : null;\n      setMark((p) =>\n        el\n          ? p && p.y === el.offsetTop && p.h === el.offsetHeight\n            ? p\n            : { y: el.offsetTop, h: el.offsetHeight }\n          : null,\n      );\n    };\n    measure();\n    const ro = new ResizeObserver(measure);\n    ro.observe(list);\n    return () => ro.disconnect();\n  }, [active]);\n  React.useEffect(() => {\n    if (!mark || ready) return;\n    const frame = requestAnimationFrame(() => setReady(true));\n    return () => cancelAnimationFrame(frame);\n  }, [mark, ready]);\n\n  const pick = (row: Row) => {\n    if (row.type === \"checkbox\") return row.onCheckedChange(!row.checked);\n    onClose();\n    row.onSelect?.();\n  };\n\n  const onKeyDown = (e: React.KeyboardEvent) => {\n    const index = rows.findIndex((r) => r.id === active);\n    let next: Row | undefined;\n    if (e.key === \"ArrowDown\") next = rows[(index + 1) % rows.length];\n    else if (e.key === \"ArrowUp\")\n      next = rows[(index - 1 + rows.length) % rows.length];\n    else if (e.key === \"Home\") next = rows[0];\n    else if (e.key === \"End\") next = rows[rows.length - 1];\n    else if ((e.key === \"Enter\" || e.key === \" \") && index >= 0) {\n      e.preventDefault();\n      return pick(rows[index]);\n    } else if (e.key === \"Tab\") return onClose();\n    else if (e.key.length === 1 && /\\S/.test(e.key)) {\n      const now = e.timeStamp;\n      typed.current = {\n        text:\n          (now - typed.current.at < 600 ? typed.current.text : \"\") +\n          e.key.toLowerCase(),\n        at: now,\n      };\n      next = rows.find((r) =>\n        r.label.toLowerCase().startsWith(typed.current.text),\n      );\n    }\n    if (!next) return;\n    e.preventDefault();\n    focusRow(next.id);\n  };\n\n  return (\n    <div\n      ref={listRef}\n      role=\"menu\"\n      aria-label={label}\n      tabIndex={-1}\n      onKeyDown={onKeyDown}\n      onPointerLeave={() => setActive(null)}\n      className=\"relative flex flex-col p-1 outline-none\"\n    >\n      <span\n        aria-hidden=\"true\"\n        className=\"pointer-events-none absolute inset-x-1 top-0 rounded-[10px] bg-accent\"\n        style={{\n          transform: `translateY(${mark?.y ?? 0}px)`,\n          height: mark?.h ?? 0,\n          opacity: mark ? 1 : 0,\n          transition:\n            reduced || !ready\n              ? \"opacity 120ms\"\n              : `transform 220ms ${EASE_OUT}, height 220ms ${EASE_OUT}, opacity 160ms ${EASE_OUT}`,\n        }}\n      />\n      {items.map((item, i) => {\n        if (item.type === \"separator\")\n          return (\n            <div\n              key={`s${i}`}\n              role=\"separator\"\n              className=\"mx-2 my-1 h-px bg-border\"\n            />\n          );\n        if (item.type === \"label\")\n          return (\n            <div\n              key={`l${i}`}\n              className=\"px-2.5 pb-1 pt-2 text-[11.5px] font-medium text-muted-foreground\"\n            >\n              {item.label}\n            </div>\n          );\n        const row = item as Row;\n        const check = row.type === \"checkbox\";\n        const destructive = !check && \"destructive\" in row && row.destructive;\n        return (\n          <div\n            key={row.id}\n            data-menu-row={row.id}\n            role={check ? \"menuitemcheckbox\" : \"menuitem\"}\n            aria-checked={check ? row.checked : undefined}\n            aria-disabled={row.disabled || undefined}\n            tabIndex={-1}\n            onPointerMove={() =>\n              !row.disabled && active !== row.id && focusRow(row.id)\n            }\n            onClick={() => !row.disabled && pick(row)}\n            className={`relative flex h-8 select-none items-center gap-2.5 rounded-[10px] px-2.5 text-[13px] outline-none ${\n              row.disabled ? \"cursor-default opacity-40\" : \"cursor-pointer\"\n            } ${destructive ? \"text-red-600 dark:text-red-400\" : active === row.id ? \"text-foreground\" : \"text-foreground/85\"}`}\n          >\n            {check ? (\n              <span className=\"flex size-4 items-center justify-center text-foreground\">\n                <Tick on={row.checked} reduced={reduced} />\n              </span>\n            ) : (\n              row.icon && (\n                <span\n                  className={`flex size-4 items-center justify-center [&_svg]:size-3.5 ${destructive ? \"\" : \"text-muted-foreground\"}`}\n                >\n                  {row.icon}\n                </span>\n              )\n            )}\n            <span className=\"flex-1 truncate\">{row.label}</span>\n            {!check && \"shortcut\" in row && row.shortcut && (\n              <kbd className=\"font-mono text-[11px] text-muted-foreground\">\n                {row.shortcut}\n              </kbd>\n            )}\n          </div>\n        );\n      })}\n    </div>\n  );\n}\n\nexport default MenuList;\n",
      "type": "registry:component"
    },
    {
      "path": "registry/components/imported-ui-interaction-motion.ts",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport const EASE_OUT = \"cubic-bezier(0.16, 1, 0.3, 1)\";\nexport const EASE_SETTLE = \"cubic-bezier(0.22, 1.18, 0.36, 1)\";\n/** Thrown things (indicators, thumbs): a slight overshoot on transform only. */\nexport const EASE_THROW = \"cubic-bezier(0.34, 1.36, 0.64, 1)\";\n/**\n * The press every button primitive shares: a 3% give that eases in and settles back.\n * Tailwind v4's scale-* writes the `scale` property, so `scale` has to be in the list\n * or the press snaps.\n */\nexport const INTERACTION_PRESS =\n  \"transition-[background-color,color,box-shadow,opacity,scale] duration-200 ease-[cubic-bezier(0.16,1,0.3,1)] active:scale-[0.97] motion-reduce:transition-none motion-reduce:active:scale-100\";\nexport const INTERACTION_FOCUS =\n  \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background\";\n\nconst query = \"(prefers-reduced-motion: reduce)\";\nconst subscribe = (notify: () => void) => {\n  const media = window.matchMedia(query);\n  media.addEventListener(\"change\", notify);\n  return () => media.removeEventListener(\"change\", notify);\n};\nexport const useInteractionReducedMotion = () =>\n  React.useSyncExternalStore(\n    subscribe,\n    () => window.matchMedia(query).matches,\n    () => false,\n  );\n\nexport function useInteractionActivity<T extends Element>() {\n  const ref = React.useRef<T>(null);\n  const [visible, setVisible] = React.useState(false);\n  const [hidden, setHidden] = React.useState(false);\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const observer = new IntersectionObserver(([entry]) =>\n      setVisible(entry.isIntersecting),\n    );\n    observer.observe(el);\n    const visibility = () => setHidden(document.hidden);\n    visibility();\n    document.addEventListener(\"visibilitychange\", visibility);\n    return () => {\n      observer.disconnect();\n      document.removeEventListener(\"visibilitychange\", visibility);\n    };\n  }, []);\n  return { ref, active: visible && !hidden };\n}\n\nexport function interactionIcon(\n  on: boolean,\n  reduced: boolean,\n): React.CSSProperties {\n  return {\n    opacity: on ? 1 : 0,\n    transform: on ? \"none\" : \"scale(0.6)\",\n    filter: on ? \"blur(0px)\" : \"blur(3px)\",\n    transition: reduced\n      ? \"none\"\n      : `opacity 220ms ${EASE_OUT}, transform 380ms ${EASE_OUT}, filter 220ms ${EASE_OUT}`,\n  };\n}\n\n/** Sample recent movement rather than averaging a long drag and losing its release velocity. */\nexport type PointerSample = { x: number; time: number };\nexport function samplePointer(\n  samples: PointerSample[],\n  x: number,\n  time: number,\n) {\n  samples.push({ x, time });\n  while (samples.length > 2 && time - samples[0].time > 100) samples.shift();\n}\nexport function releaseVelocity(samples: PointerSample[], now: number) {\n  if (samples.length < 2 || now - samples[samples.length - 1].time > 100)\n    return 0;\n  const first = samples[0],\n    last = samples[samples.length - 1];\n  return (last.x - first.x) / Math.max(1, last.time - first.time);\n}\n\n/** Smooth Apple/rational rubber-band curve: continuous exponential-like resistance without linear kinks. */\nexport function rubberBand(\n  overshoot: number,\n  dimension = 320,\n  constant = 0.55,\n): number {\n  const d = dimension || 320;\n  const abs = Math.abs(overshoot);\n  return Math.sign(overshoot) * (1 - 1 / ((abs * constant) / d + 1)) * d;\n}\n\n/** Projects resting travel from release velocity (velocity in px/ms; time in seconds). */\nexport function projectInertia(\n  distance: number,\n  velocity: number,\n  time = 0.12,\n): number {\n  return distance + velocity * 1000 * time;\n}\n\n/** Smooths incoming release velocity toward a boundary so springs don't slam or clip into walls. */\nexport function softenVelocity(\n  velocity: number,\n  distanceToTarget: number,\n  factor = 10,\n): number {\n  const maxAllowed = Math.abs(distanceToTarget) * factor;\n  return Math.sign(velocity) * Math.min(Math.abs(velocity), maxAllowed);\n}\n\n/** A damped spring sampled by WAAPI: tuned for organic lightness with a hint of life (3% breath). */\nexport function springFrames(\n  from: number,\n  to: number,\n  velocity = 0,\n  duration = 480,\n  config: { omega?: number; damping?: number; steps?: number } = {},\n) {\n  const { omega = 16, damping = 0.74, steps = 36 } = config;\n  const damped = omega * Math.sqrt(Math.max(0.001, 1 - damping * damping));\n  const displacement = from - to;\n  const coefficient =\n    (velocity * 1000 + damping * omega * displacement) / damped;\n  return Array.from({ length: steps + 1 }, (_, i) => {\n    const t = (i / steps) * (duration / 1000);\n    const value =\n      to +\n      Math.exp(-damping * omega * t) *\n        (displacement * Math.cos(damped * t) +\n          coefficient * Math.sin(damped * t));\n    return { value: i === steps ? to : value, offset: i / steps };\n  });\n}\n",
      "type": "registry:component"
    }
  ],
  "css": {},
  "meta": {
    "cavemio": {
      "component": "dropdown-menu",
      "exportName": "DropdownMenu",
      "categories": [
        "overlays"
      ],
      "isNew": true,
      "usage": "import { DropdownMenu } from \"@/components/dropdown-menu\";\n\n<DropdownMenu\n  trigger={<button aria-label=\"More\">…</button>}\n  items={[\n    { id: \"rename\", label: \"Rename\", shortcut: \"F2\", onSelect: rename },\n    { type: \"separator\" },\n    { id: \"delete\", label: \"Delete\", destructive: true, onSelect: remove },\n  ]}\n/>",
      "accessibility": "- Placement, presence and dismissal live in floating.ts, shared by tooltip, popover, dropdown and context menus: they all flip, shift, enter and leave the same way.\n- role=\"menu\" with menuitem and menuitemcheckbox rows.\n- Reduced motion: the menu fades; the highlight jumps.",
      "previewNote": "Interactive local fixture. Data and async results are simulated in the preview; the caller supplies application services.",
      "documentation": {
        "props": [
          {
            "name": "trigger",
            "type": "ReactElement",
            "description": "– · The button that opens it."
          },
          {
            "name": "items",
            "type": "MenuEntry[]",
            "description": "– · Rows ({ id, label, icon, shortcut, destructive, disabled, onSelect }), { type: \"checkbox\", checked, onCheckedChange }, { type: \"label\" } and { type: \"separator\" }."
          },
          {
            "name": "side / align",
            "type": "Side / Align",
            "description": "\"bottom\" / \"start\" · Where it sits."
          },
          {
            "name": "open / onOpenChange",
            "type": "boolean / (open) => void",
            "description": "– · Control it."
          },
          {
            "name": "minWidth",
            "type": "number",
            "description": "200 · Never narrower than the trigger."
          },
          {
            "name": "label",
            "type": "string",
            "description": "– · Accessible name of the menu."
          }
        ],
        "useCases": [
          {
            "title": "Row actions",
            "description": "Edit, duplicate, delete on a \"…\" button."
          },
          {
            "title": "Account menus",
            "description": "Profile, settings, sign out under an avatar."
          },
          {
            "title": "View options",
            "description": "Checkable columns or display settings."
          },
          {
            "title": "Create menus",
            "description": "New doc, new folder, upload."
          }
        ],
        "features": [
          {
            "title": "Gliding highlight",
            "description": "One fill moves between rows (220ms) for pointer and keys alike."
          },
          {
            "title": "Keyboard",
            "description": "Enter/Space/↓ open on the first row, ↑ on the last; arrows wrap; typing jumps."
          },
          {
            "title": "Checkable rows",
            "description": "A drawn tick, aria-checked, menu stays open."
          },
          {
            "title": "Plain data",
            "description": "items: rows, labels and separators as objects."
          }
        ],
        "states": [
          {
            "title": "open",
            "description": "Rises off the trigger (320ms); flips above if needed."
          },
          {
            "title": "move",
            "description": "The highlight glides to the row under the pointer or the key."
          },
          {
            "title": "pick",
            "description": "Closes (180ms) and focus returns to the trigger; checkbox rows stay open and draw their tick (280ms)."
          }
        ]
      }
    }
  },
  "type": "registry:component"
}