import React, { useMemo } from "react"; type Step = { id: string; label: string; description?: string; icon?: React.ReactNode; }; type StepperProps = { steps: Step[]; currentStep: string; }; export const Stepper: React.FC = ({ steps, currentStep }) => { const stepIndex = useMemo( () => steps.findIndex((s) => s.id === currentStep), [currentStep, steps], ); const percent = useMemo(() => { return steps.length === 1 ? 100 : Math.round((stepIndex / (steps.length - 1)) * 100); }, [stepIndex, steps.length]); return (
{steps.map((step, idx) => (
{/* Step circle */}
{idx < stepIndex ? ( // Check icon for completed steps ) : ( (step.icon ?? {idx + 1}) )}
{/* Step label */}
{step.label} {step.description && ( {step.description} )}
{/* {idx < steps.length - 1 && (
)} */}
))}
); };