'use client'; import * as React from 'react'; import { motion, useInView, type Transition, type UseInViewOptions, } from 'motion/react'; type WritingTextProps = Omit, 'children'> & { transition?: Transition; inView?: boolean; inViewMargin?: UseInViewOptions['margin']; inViewOnce?: boolean; spacing?: number | string; text: string; }; function WritingText({ ref, inView = false, inViewMargin = '0px', inViewOnce = true, spacing = 5, text, transition = { type: 'spring', bounce: 0, duration: 2, delay: 0.5 }, ...props }: WritingTextProps) { const localRef = React.useRef(null); React.useImperativeHandle(ref, () => localRef.current as HTMLSpanElement); const inViewResult = useInView(localRef, { once: inViewOnce, margin: inViewMargin, }); const isInView = !inView || inViewResult; const words = React.useMemo(() => text.split(' '), [text]); return ( {words.map((word, index) => ( {word}{' '} ))} ); } export { WritingText, type WritingTextProps };