import type { ReactNode } from "react"; import { cx } from "../../utils/cx"; import { CheckIcon } from "../../utils/icons"; import { VisuallyHidden } from "../../utils/VisuallyHidden"; export interface StepperStep { id: string; label: ReactNode; description?: ReactNode; } export interface StepperProps { steps: StepperStep[]; /** Zero-based index of the step the user is on. */ currentStep: number; /** * Lets users jump back to completed steps. When provided, completed steps render as buttons. * Upcoming steps are never clickable, so users can't skip required work. */ onStepClick?: (index: number) => void; orientation?: "horizontal" | "vertical"; /** Accessible name for the list. Default "Progress". */ "aria-label"?: string; className?: string; } type StepStatus = "complete" | "current" | "upcoming"; const statusText: Record = { complete: "Completed", current: "Current step", upcoming: "Not started" }; export function Stepper({ steps, currentStep, onStepClick, orientation = "horizontal", "aria-label": ariaLabel = "Progress", className }: StepperProps) { return (
    {steps.map((step, index) => { const status: StepStatus = index < currentStep ? "complete" : index === currentStep ? "current" : "upcoming"; const content = ( <> {step.label} {`, step ${index + 1} of ${steps.length}, ${statusText[status]}`} {step.description && {step.description}} ); return (
  1. {onStepClick && status === "complete" ? ( ) : (
    {content}
    )}
  2. ); })}
); }