import { VisuallyHidden } from "../visually-hidden/visually-hidden"; import styles from "./stepper.module.css"; import type { StepStatus, StepperStep } from "./build-steps"; const statusText: Readonly> = { complete: "выполнен", current: "текущий шаг", upcoming: "впереди", }; type StepperProps = { /** Accessible name of the step list, for example "Шаги регистрации". */ label: string; steps: readonly StepperStep[]; }; /** * Progress through a multi-step flow: a visible "step N of M" line and an * ordered list joined by a trace. The current step has aria-current="step"; * each step states its status in text, so the shape and color only repeat it. */ export function Stepper({ label, steps }: StepperProps) { const currentIndex = steps.findIndex((step) => step.status === "current"); const completed = steps.filter((step) => step.status === "complete").length; const position = currentIndex === -1 ? completed : currentIndex + 1; return (

{currentIndex === -1 && completed === steps.length ? `Все шаги выполнены: ${steps.length} из ${steps.length}` : `Шаг ${position} из ${steps.length}`}

    {steps.map((step, index) => (
  1. {step.label} {`, ${statusText[step.status]}`}
  2. ))}
); }