23 lines
605 B
TypeScript
23 lines
605 B
TypeScript
export type StepStatus = "complete" | "current" | "upcoming";
|
|
|
|
export type StepperStep = {
|
|
id: string;
|
|
label: string;
|
|
status: StepStatus;
|
|
};
|
|
|
|
/**
|
|
* Builds the statuses of a linear flow: steps before the current one are
|
|
* complete, the rest are upcoming. A current index past the end marks every
|
|
* step complete.
|
|
*/
|
|
export function buildSteps(
|
|
steps: readonly { id: string; label: string }[],
|
|
currentIndex: number,
|
|
): StepperStep[] {
|
|
return steps.map((step, index) => ({
|
|
...step,
|
|
status: index < currentIndex ? "complete" : index === currentIndex ? "current" : "upcoming",
|
|
}));
|
|
}
|