{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "reveal",
  "title": "Reveal",
  "description": "Astro viewport entrance animations with fade-in and fade-up effects.",
  "dependencies": [
    "class-variance-authority",
    "cn"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "packages/ui/src/components/ui/reveal/index.ts",
      "content": "export { default as Reveal } from './reveal.astro'\nexport type { RevealProps } from './types.ts'\n",
      "type": "registry:file",
      "target": "~/src/components/ui/reveal/index.ts"
    },
    {
      "path": "packages/ui/src/components/ui/reveal/reveal.astro",
      "content": "---\nimport type { HTMLTag, Polymorphic } from \"astro/types\"\nimport { cva } from \"class-variance-authority\"\nimport { cn } from \"cn\"\nimport type { RevealProps } from \"./types.ts\"\n\ntype Props<Tag extends HTMLTag = \"div\"> = Polymorphic<{ as: Tag }> & RevealProps\n\nconst revealVariants = cva(\n  \"transition-[opacity,translate] delay-(--reveal-delay) duration-(--reveal-duration) focus-within:delay-0 focus-within:duration-0 data-[reveal-state=pending]:opacity-0 motion-reduce:transition-none motion-reduce:delay-0\",\n  {\n    variants: {\n      variant: {\n        \"fade-in\": \"\",\n        \"fade-up\": \"data-[reveal-state=pending]:translate-y-6\",\n      },\n    },\n    defaultVariants: { variant: \"fade-up\" },\n  },\n)\n\nconst {\n  as: Tag = \"div\",\n  variant = \"fade-up\",\n  duration = 600,\n  delay = 0,\n  once = true,\n  enabled = true,\n  class: className,\n  style,\n  ...props\n} = Astro.props\n\nconst timing = {\n  \"--reveal-duration\": `${Number.isFinite(duration) ? Math.max(0, duration) : 600}ms`,\n  \"--reveal-delay\": `${Number.isFinite(delay) ? Math.max(0, delay) : 0}ms`,\n}\nconst rootStyle =\n  typeof style === \"string\"\n    ? `--reveal-duration:${timing[\"--reveal-duration\"]};--reveal-delay:${timing[\"--reveal-delay\"]};${style}`\n    : { ...timing, ...style }\n---\n\n<Tag\n  {...props}\n  data-slot=\"reveal\"\n  data-variant={variant}\n  data-reveal-once={String(once)}\n  data-reveal-disabled={!enabled || undefined}\n  class={cn(revealVariants({ variant }), className)}\n  style={rootStyle}\n>\n  <slot />\n</Tag>\n\n<script>\n  import { observeReveals } from \"./reveal-controller.ts\"\n\n  observeReveals()\n</script>\n",
      "type": "registry:file",
      "target": "~/src/components/ui/reveal/reveal.astro"
    },
    {
      "path": "packages/ui/src/components/ui/reveal/reveal-controller.ts",
      "content": "/** Attach viewport behavior to one rendered Reveal element. */\nexport function createReveal(root: HTMLElement): () => void {\n    if (\n        root.hasAttribute('data-reveal-disabled') ||\n        typeof IntersectionObserver === 'undefined'\n    )\n        return () => {}\n\n    const reduced = matchMedia('(prefers-reduced-motion: reduce)')\n    const controller = new AbortController()\n    const once = root.dataset.revealOnce !== 'false'\n    let complete = false\n    const show = () => {\n        root.dataset.revealState = 'visible'\n        if (once) {\n            complete = true\n            observer.disconnect()\n        }\n    }\n    const observer = new IntersectionObserver(\n        (entries) => {\n            if (controller.signal.aborted || complete || reduced.matches) return\n            for (const entry of entries) {\n                if (\n                    entry.isIntersecting ||\n                    root.contains(root.ownerDocument.activeElement)\n                ) {\n                    show()\n                } else if (!once) {\n                    root.dataset.revealState = 'pending'\n                }\n            }\n        },\n        { threshold: 0.08 },\n    )\n\n    if (reduced.matches || root.contains(root.ownerDocument.activeElement)) {\n        show()\n    } else {\n        root.dataset.revealState = 'pending'\n    }\n    if (!reduced.matches && !complete) observer.observe(root)\n\n    root.addEventListener('focusin', show, { signal: controller.signal })\n    reduced.addEventListener(\n        'change',\n        () => {\n            if (reduced.matches) {\n                observer.disconnect()\n                show()\n            } else if (!complete) {\n                observer.observe(root)\n            }\n        },\n        { signal: controller.signal },\n    )\n\n    return () => {\n        controller.abort()\n        observer.disconnect()\n        delete root.dataset.revealState\n    }\n}\n\n/** Bind new instances and clean up removed instances, including Astro navigation. */\nexport function observeReveals(): () => void {\n    const selector = '[data-slot=\"reveal\"]'\n    const instances = new Map<HTMLElement, () => void>()\n    const controller = new AbortController()\n    const bind = (root: HTMLElement) => {\n        if (!instances.has(root)) instances.set(root, createReveal(root))\n    }\n    const scan = (parent: ParentNode) => {\n        parent.querySelectorAll<HTMLElement>(selector).forEach(bind)\n    }\n    const clear = () => {\n        instances.forEach((cleanup) => cleanup())\n        instances.clear()\n    }\n    const mutations = new MutationObserver((records) => {\n        for (const [root, cleanup] of instances) {\n            if (!root.isConnected) {\n                cleanup()\n                instances.delete(root)\n            }\n        }\n        for (const record of records) {\n            for (const node of record.addedNodes) {\n                if (!(node instanceof HTMLElement) || !node.isConnected)\n                    continue\n                if (node.matches(selector)) bind(node)\n                scan(node)\n            }\n        }\n    })\n\n    scan(document)\n    mutations.observe(document.documentElement, {\n        childList: true,\n        subtree: true,\n    })\n    document.addEventListener('astro:page-load', () => scan(document), {\n        signal: controller.signal,\n    })\n    document.addEventListener('astro:before-swap', clear, {\n        signal: controller.signal,\n    })\n\n    return () => {\n        controller.abort()\n        mutations.disconnect()\n        clear()\n    }\n}\n",
      "type": "registry:file",
      "target": "~/src/components/ui/reveal/reveal-controller.ts"
    },
    {
      "path": "packages/ui/src/components/ui/reveal/types.ts",
      "content": "/** Options for an element that appears when it enters the visible area. */\nexport interface RevealProps {\n    /**\n     * Entrance effect. Fade-up also moves the element up from its starting offset.\n     * @default 'fade-up'\n     */\n    variant?: 'fade-in' | 'fade-up'\n    /**\n     * Transition duration in milliseconds.\n     * @default 600\n     */\n    duration?: number\n    /**\n     * Delay before the transition, in milliseconds.\n     * @default 0\n     */\n    delay?: number\n    /**\n     * Reveal once. Set false to repeat when the element leaves and enters view.\n     * @default true\n     */\n    once?: boolean\n    /**\n     * Enable the reveal behavior. Disabled elements remain visible.\n     * @default true\n     */\n    enabled?: boolean\n}\n",
      "type": "registry:file",
      "target": "~/src/components/ui/reveal/types.ts"
    }
  ],
  "meta": {
    "framework": "astro",
    "source": "@gnostic/ui",
    "testedDependencies": {
      "class-variance-authority": "^0.7.1",
      "cn": "0.5.2"
    }
  },
  "docs": "https://ui.gnosticai.com/components/reveal",
  "categories": [
    "ui"
  ],
  "type": "registry:ui"
}
