{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "entrance-reveal",
  "title": "Entrance Reveal",
  "description": "A wrapper that reveals its content as it scrolls into view: children (or the words of a heading) appear one after another, rising from behind a mask, fading up, sharpening out of a blur, scaling or sliding in, once or every time.",
  "dependencies": [
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/entrance-reveal/entrance-reveal.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport type RevealVariant = \"fade-up\" | \"blur\" | \"rise\" | \"scale\" | \"slide\";\n\nexport interface EntranceRevealProps extends Omit<React.ComponentPropsWithoutRef<\"div\">, \"children\"> {\n  children: React.ReactNode;\n  variant?: RevealVariant;\n  /** Split a string child into words (or letters) that reveal one after another. */\n  split?: \"none\" | \"words\" | \"letters\";\n  /** Delay between children (or words), in ms. */\n  stagger?: number;\n  /** Delay before the first item, in ms. */\n  delay?: number;\n  /** Duration of each item's reveal, in ms. */\n  duration?: number;\n  /** Reveal only the first time; otherwise it hides again when it leaves the screen. */\n  once?: boolean;\n  /** Share of the element that must be visible before it reveals (0–1). */\n  threshold?: number;\n  as?: \"div\" | \"section\" | \"ul\" | \"ol\" | \"h1\" | \"h2\" | \"h3\" | \"p\" | \"span\";\n}\n\nconst EASE = \"cubic-bezier(.16,1,.3,1)\";\n\nfunction hidden(variant: RevealVariant): React.CSSProperties {\n  switch (variant) {\n    case \"blur\":\n      return { opacity: 0, filter: \"blur(14px)\", transform: \"translateY(10px)\" };\n    case \"rise\":\n      return { transform: \"translateY(110%)\" };\n    case \"scale\":\n      return { opacity: 0, transform: \"scale(0.9)\" };\n    case \"slide\":\n      return { opacity: 0, transform: \"translateX(-28px)\" };\n    default:\n      return { opacity: 0, transform: \"translateY(26px)\" };\n  }\n}\n\nfunction useReducedMotion() {\n  return React.useSyncExternalStore(\n    (callback) => {\n      const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n      query.addEventListener(\"change\", callback);\n      return () => query.removeEventListener(\"change\", callback);\n    },\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\n}\n\nexport function EntranceReveal({\n  children,\n  variant = \"fade-up\",\n  split = \"none\",\n  stagger = 80,\n  delay = 0,\n  duration = 900,\n  once = true,\n  threshold = 0.25,\n  as = \"div\",\n  className,\n  style,\n  ...props\n}: EntranceRevealProps) {\n  const reduce = useReducedMotion();\n  const ref = React.useRef<HTMLElement>(null);\n  const [shown, setShown] = React.useState(false);\n\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    // A root of null still respects scroll containers: what they clip away counts as not visible.\n    const observer = new IntersectionObserver(\n      ([entry]) => {\n        if (entry.isIntersecting) {\n          setShown(true);\n          if (once) observer.disconnect();\n        } else if (!once && entry.boundingClientRect.top > 0) {\n          // Hide again only when it drops off below, so scrolling past doesn't flicker it.\n          setShown(false);\n        }\n      },\n      { threshold },\n    );\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, [once, threshold]);\n\n  const visible = shown || reduce;\n  const masked = variant === \"rise\";\n  const itemStyle = (i: number): React.CSSProperties => ({\n    display: \"inline-block\",\n    willChange: visible ? undefined : \"transform, opacity\",\n    transition: reduce ? \"none\" : `opacity ${duration}ms ${EASE} ${delay + i * stagger}ms, transform ${duration}ms ${EASE} ${delay + i * stagger}ms, filter ${duration}ms ${EASE} ${delay + i * stagger}ms`,\n    ...(visible ? { opacity: 1, transform: \"none\", filter: \"none\" } : hidden(variant)),\n  });\n  // \"rise\" slides each item up from behind a mask, like type set into a slot.\n  const wrap = (node: React.ReactNode, i: number, key: React.Key, block: boolean) =>\n    masked ? (\n      <span key={key} className={cn(\"overflow-hidden align-bottom\", block ? \"block\" : \"inline-block\")} style={{ paddingBottom: \"0.08em\", marginBottom: \"-0.08em\" }}>\n        <span style={{ ...itemStyle(i), display: block ? \"block\" : \"inline-block\" }}>{node}</span>\n      </span>\n    ) : (\n      <span key={key} style={{ ...itemStyle(i), display: block ? \"block\" : \"inline-block\" }}>\n        {node}\n      </span>\n    );\n\n  let content: React.ReactNode;\n  if (split !== \"none\" && typeof children === \"string\") {\n    const parts = split === \"words\" ? children.split(/(\\s+)/) : Array.from(children);\n    let n = 0;\n    content = (\n      <>\n        <span className=\"sr-only\">{children}</span>\n        <span aria-hidden=\"true\">{parts.map((part, i) => (/^\\s+$/.test(part) ? part : wrap(part, n++, i, false)))}</span>\n      </>\n    );\n  } else {\n    content = React.Children.toArray(children).map((child, i) => {\n      // Elements get the reveal styles directly, so <li> stays a direct child of <ul>. For \"rise\" a clip-path\n      // stands in for the mask: the element wipes up into view while it slides up.\n      if (React.isValidElement<{ style?: React.CSSProperties }>(child)) {\n        const { display: _display, ...motion } = itemStyle(i);\n        void _display;\n        const rise: React.CSSProperties = masked\n          ? {\n              clipPath: visible ? \"inset(0% 0% 0% 0%)\" : \"inset(0% 0% 100% 0%)\",\n              transform: visible ? \"none\" : \"translateY(40px)\",\n              transition: reduce ? \"none\" : `clip-path ${duration}ms ${EASE} ${delay + i * stagger}ms, transform ${duration}ms ${EASE} ${delay + i * stagger}ms`,\n            }\n          : motion;\n        return React.cloneElement(child, { style: { ...child.props.style, ...rise } });\n      }\n      return wrap(child, i, (React.isValidElement(child) && child.key) || i, true);\n    });\n  }\n\n  const Tag = as as React.ElementType;\n  return (\n    <Tag ref={ref} data-shown={visible ? \"\" : undefined} className={className} style={style} {...props}>\n      {content}\n    </Tag>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}