{ "name": "text-morph", "type": "registry:ui", "registryDependencies": [], "dependencies": [ "motion" ], "devDependencies": [], "tailwind": {}, "cssVars": { "light": {}, "dark": {} }, "files": [ { "path": "text-morph.tsx", "content": "'use client';\nimport { cn } from '@/lib/utils';\nimport { AnimatePresence, motion, Transition, Variants } from 'motion/react';\nimport { useMemo, useId } from 'react';\n\nexport type TextMorphProps = {\n children: string;\n as?: React.ElementType;\n className?: string;\n style?: React.CSSProperties;\n variants?: Variants;\n transition?: Transition;\n};\n\nexport function TextMorph({\n children,\n as: Component = 'p',\n className,\n style,\n variants,\n transition,\n}: TextMorphProps) {\n const uniqueId = useId();\n\n const characters = useMemo(() => {\n const charCounts: Record = {};\n\n return children.split('').map((char) => {\n const lowerChar = char.toLowerCase();\n charCounts[lowerChar] = (charCounts[lowerChar] || 0) + 1;\n\n return {\n id: `${uniqueId}-${lowerChar}${charCounts[lowerChar]}`,\n label: char === ' ' ? '\\u00A0' : char,\n };\n });\n }, [children, uniqueId]);\n\n const defaultVariants: Variants = {\n initial: { opacity: 0 },\n animate: { opacity: 1 },\n exit: { opacity: 0 },\n };\n\n const defaultTransition: Transition = {\n type: 'spring',\n stiffness: 280,\n damping: 18,\n mass: 0.3,\n };\n\n return (\n \n \n {characters.map((character) => (\n \n \n );\n}\n", "type": "registry:ui" } ] }