UNPKG

@kubit-ui-web/react-components

Version:

Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience

22 lines 768 B
import { StepperNumberStateType } from '../types/state'; export const mapToStepState = (steps, currentStep) => { if (!steps?.length) { return []; } const currentStepInBounds = Math.max(0, Math.min(currentStep, steps.length)); const res = steps?.reduce((prev, current, index) => { const isCompleted = index < currentStepInBounds ? StepperNumberStateType.COMPLETED : StepperNumberStateType.INACTIVE; const stateStep = index === currentStepInBounds ? StepperNumberStateType.ACTIVE : isCompleted; return [ ...prev, { name: current, state: stateStep, }, ]; }, []); return res; }; //# sourceMappingURL=stepState.js.map