{
  "title": "Reveal Text",
  "description": "A smooth text reveals animation where each heading reveals related content on interaction.",
  "name": "motion-reveal-text",
  "dependencies": [
    "motion",
    "split-type"
  ],
  "registryDependencies": [],
  "type": "registry:component",
  "files": [
    {
      "path": "components/paceui/motion/reveal-text.tsx",
      "type": "registry:ui",
      "content": "import { type ComponentProps, useEffect, useRef } from \"react\";\n\nimport { type AnimationPlaybackControls, animate, stagger } from \"motion/react\";\nimport SplitType, { type SplitTypeOptions } from \"split-type\";\n\ntype SplitTypeKey = \"chars\" | \"words\" | \"lines\";\n\ntype RevealTextProps = {\n    type?: SplitTypeKey;\n    motionOptions?: Parameters<typeof animate>[2];\n    motionKeyframes?: Parameters<typeof animate>[1];\n    onSetup?: (elements: HTMLElement[]) => void;\n    splitOptions?: Partial<SplitTypeOptions>;\n} & ComponentProps<\"div\">;\n\nexport const RevealText = ({\n    type = \"chars\",\n    motionOptions = {},\n    motionKeyframes,\n    onSetup,\n    splitOptions = {},\n    children,\n    ...props\n}: RevealTextProps) => {\n    const wrapperRef = useRef<HTMLDivElement>(null);\n\n    useEffect(() => {\n        const element = wrapperRef.current;\n        if (!element) return;\n\n        const splitText = new SplitType(element, { types: type, ...splitOptions });\n        const targets = splitText[type];\n\n        if (!targets || targets.length === 0) return;\n\n        if (onSetup) {\n            onSetup(targets);\n        }\n\n        let animation: AnimationPlaybackControls | undefined;\n\n        if (motionKeyframes) {\n            animation = animate(targets, motionKeyframes, motionOptions);\n        } else if (type === \"chars\") {\n            animation = animate(\n                targets,\n                { x: [150, 0], opacity: [0, 1] },\n                { duration: 0.7, ease: \"easeOut\", delay: stagger(0.05), ...motionOptions },\n            );\n        } else if (type === \"words\") {\n            targets.forEach((el, i) => {\n                const randomRot = Math.sin(i * 4567) * 80;\n                el.style.transform = `translate(150px, -100px) rotate(${randomRot}deg)`;\n                el.style.opacity = \"0\";\n            });\n\n            animation = animate(\n                targets,\n                { x: 0, y: 0, opacity: 1, rotate: 0 },\n                { duration: 1, ease: \"easeOut\", delay: stagger(0.2), ...motionOptions },\n            );\n        } else if (type === \"lines\") {\n            animation = animate(\n                targets,\n                { y: [\"100%\", \"0%\"], opacity: [0, 1] },\n                { duration: 1, ease: \"circOut\", delay: stagger(0.4), ...motionOptions },\n            );\n        }\n\n        return () => {\n            if (animation) animation.stop();\n            splitText.revert();\n        };\n    }, [type, motionOptions, motionKeyframes, onSetup, splitOptions, children]);\n\n    return (\n        <div {...props} ref={wrapperRef}>\n            {children}\n        </div>\n    );\n};\n"
    }
  ],
  "mcp": {
    "description": "Provides refined UI interactions and accessible controls. A smooth text reveals animation where each heading reveals related content on interaction. Configurable props include: {; type?: SplitTypeKey;; motionOptions?: Parameters<typeof animate>[2];; motionKeyframes?: Parameters<typeof animate>[1];. Relies on motion, split-type. Optimal for building reusable interface elements and user input flows.",
    "tags": [
      "component",
      "motion",
      "animation"
    ]
  }
}