@visa/nova-react
Version:
Visa Product Design System Nova React library
84 lines (83 loc) • 3.1 kB
TypeScript
/**
* Copyright (c) 2025 Visa, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**/
type UseWizardOptions = {
/** Auto progress on complete */
autoProgressComplete?: boolean;
/** Auto progress on error */
autoProgressError?: boolean;
/** Current step */
defaultActiveStep?: number;
/** If the complete and error sets are mutually exclusive */
isExclusiveSets?: boolean;
/** Length of steps */
length: number;
};
type WizardEventOptions = {
/** Auto progress */
autoProgress?: boolean;
};
/**
* @docs {@link https://design.visa.com/react/hooks/use-wizard | See Docs}
* @description This hook is used to control the state of a wizard component.
* @related wizard
* @vgar TODO
* @wcag TODO
*/
export declare const useWizard: {
(useWizardOptions: UseWizardOptions): {
/** Return the current step of the wizard */
currentStep: number;
/** Check if the wizard has any error step */
hasError: () => boolean;
/** Check if the step is available */
isStepAvailable: (index: number) => boolean;
/** Check if the current step is the first step */
isFirstStep: (index: number) => index is 0;
/** Check if the current step is the last step */
isLastStep: (index: number) => boolean;
/** Check if the step is completed */
isStepComplete: (index: number) => boolean;
/** Check if the step has an error */
isStepError: (index: number) => boolean;
/** Check if the wizard is complete */
isWizardComplete: () => boolean;
/** Return the maximum available step of the wizard */
maxStep: number;
/** Move to the selected step */
onStepChange: (index: number) => void;
/** Move to the next step */
onStepNext: () => void;
/** Move to the previous step */
onStepPrevious: () => void;
/** Mark the step as complete */
onStepComplete: (index: number, { autoProgress }?: WizardEventOptions) => void;
/** Mark the step as error */
onStepError: (index: number, { autoProgress }?: WizardEventOptions) => void;
/** Reset the step status */
onStepReset: (index: number) => void;
/** Reset the wizard status */
onWizardReset: (index?: number) => void;
};
displayName: string;
defaultProps: {
autoProgressComplete: boolean;
autoProgressError: boolean;
defaultActiveStep: number;
isExclusiveSets: boolean;
};
};
export default useWizard;