: React.MouseEvent, steps: WizardStepType[] = initialSteps) => { const newStep = [...steps] .reverse() .find((step: WizardStepType) => step.index < activeStepIndex && isStepEnabled(steps, step)); setActiveStepIndex(newStep?.index); onStepChange?.(event, newStep, steps[activeStepIndex - 1], WizardStepChangeScope.Back); shouldFocusContent && focusMainContentElement(); }; const goToStepByIndex = ( event: React.MouseEvent, steps: WizardStepType[] = initialSteps, index: number ) => { const lastStepIndex = steps.length + 1; // Handle index when out of bounds or hidden if (index < 1) { index = 1; } else if (index > lastStepIndex) { index = lastStepIndex; } const currStep = steps[index - 1]; const prevStep = steps[activeStepIndex - 1]; setActiveStepIndex(index); onStepChange?.(event, currStep, prevStep, WizardStepChangeScope.Nav); }; const goToStepById = (steps: WizardStepType[] = initialSteps, id: number | string) => { const step = steps.find((step) => step.id === id); const stepIndex = step?.index; const lastStepIndex = steps.length + 1; if (stepIndex > 0 && stepIndex < lastStepIndex && !step.isDisabled && !step.isHidden) { setActiveStepIndex(stepIndex); } }; const goToStepByName = (steps: WizardStepType[] = initialSteps, name: string) => { const step = steps.find((step) => step.name === name); const stepIndex = step?.index; const lastStepIndex = steps.length + 1; if (stepIndex > 0 && stepIndex < lastStepIndex && !step.isDisabled && !step.isHidden) { setActiveStepIndex(stepIndex); } }; return (
{header}
); }; const WizardInternal = ({ nav, navAriaLabel, isVisitRequired, isProgressive }: Pick) => { const { activeStep, steps, footer, goToStepByIndex } = useWizardContext(); const [isNavExpanded, setIsNavExpanded] = React.useState(false); const wizardNav = React.useMemo(() => { if (isCustomWizardNav(nav)) { return typeof nav === 'function' ? nav(isNavExpanded, steps, activeStep, goToStepByIndex) : nav; } return ( ); }, [activeStep, isVisitRequired, isProgressive, goToStepByIndex, isNavExpanded, nav, navAriaLabel, steps]); return ( setIsNavExpanded((prevIsExpanded) => !prevIsExpanded)} /> ); }; Wizard.displayName = 'Wizard';