import type { ReactNode } from 'react'; import { useMemo } from 'react'; import { styles } from './styles'; import { toElementArray } from './utils'; interface StepChildProps { title?: ReactNode; children?: ReactNode; } export function Step({ children }: StepChildProps) { return <>{children}; } export interface StepsProps { children?: ReactNode; } export function Steps({ children }: StepsProps) { const steps = useMemo(() => { return toElementArray(children).map((child, index) => { return { title: child.props.title || `Step ${index + 1}`, content: child.props.children, }; }); }, [children]); if (!steps.length) { return null; } return (
{steps.map((step, index) => ( // biome-ignore lint/suspicious/noArrayIndexKey: steps are static MDX content
{index + 1}
{step.title}
{step.content}
))}
); }