| 1 |
import { Component } from 'react'; |
| 2 |
import { WizardNavItemProps } from './WizardNavItem'; |
| 3 |
import { PickOptional } from '../../../helpers/typeUtils'; |
| 4 |
export interface WizardStep { |
| 5 |
/** Optional identifier */ |
| 6 |
id?: string | number; |
| 7 |
/** The name of the step */ |
| 8 |
name: React.ReactNode; |
| 9 |
/** The component to render in the main body */ |
| 10 |
component?: any; |
| 11 |
/** The content to render in the drawer panel (use when hasDrawer prop is set on the wizard). */ |
| 12 |
drawerPanelContent?: any; |
| 13 |
/** Custom drawer toggle button that opens the drawer. */ |
| 14 |
drawerToggleButton?: React.ReactNode; |
| 15 |
/** Setting to true hides the side nav and footer */ |
| 16 |
isFinishedStep?: boolean; |
| 17 |
/** Enables or disables the step in the navigation. Enabled by default. */ |
| 18 |
canJumpTo?: boolean; |
| 19 |
/** Sub steps */ |
| 20 |
steps?: WizardStep[]; |
| 21 |
/** Props to pass to the WizardNavItem */ |
| 22 |
stepNavItemProps?: React.HTMLProps<HTMLButtonElement | HTMLAnchorElement> | WizardNavItemProps; |
| 23 |
/** (Unused if footer is controlled) Can change the Next button text. If nextButtonText is also set for the Wizard, this step specific one overrides it. */ |
| 24 |
nextButtonText?: React.ReactNode; |
| 25 |
/** (Unused if footer is controlled) The condition needed to enable the Next button */ |
| 26 |
enableNext?: boolean; |
| 27 |
/** (Unused if footer is controlled) True to hide the Cancel button */ |
| 28 |
hideCancelButton?: boolean; |
| 29 |
/** (Unused if footer is controlled) True to hide the Back button */ |
| 30 |
hideBackButton?: boolean; |
| 31 |
/** Flag to disable the step in the navigation */ |
| 32 |
isDisabled?: boolean; |
| 33 |
} |
| 34 |
export type WizardStepFunctionType = (newStep: { |
| 35 |
id?: string | number; |
| 36 |
name: React.ReactNode; |
| 37 |
}, prevStep: { |
| 38 |
prevId?: string | number; |
| 39 |
prevName: React.ReactNode; |
| 40 |
}) => void; |
| 41 |
export interface WizardProps extends React.HTMLProps<HTMLDivElement> { |
| 42 |
/** Custom width of the wizard */ |
| 43 |
width?: number | string; |
| 44 |
/** Custom height of the wizard */ |
| 45 |
height?: number | string; |
| 46 |
/** The wizard title to display if header is desired */ |
| 47 |
title?: string; |
| 48 |
/** An optional id for the title */ |
| 49 |
titleId?: string; |
| 50 |
/** An optional id for the description */ |
| 51 |
descriptionId?: string; |
| 52 |
/** The wizard description */ |
| 53 |
description?: React.ReactNode; |
| 54 |
/** Component type of the description */ |
| 55 |
descriptionComponent?: 'div' | 'p'; |
| 56 |
/** Flag indicating whether the close button should be in the header */ |
| 57 |
hideClose?: boolean; |
| 58 |
/** Callback function to close the wizard */ |
| 59 |
onClose?: () => void; |
| 60 |
/** Callback function when a step in the nav is clicked */ |
| 61 |
onGoToStep?: WizardStepFunctionType; |
| 62 |
/** Additional classes spread to the Wizard */ |
| 63 |
className?: string; |
| 64 |
/** The wizard steps configuration object */ |
| 65 |
steps: WizardStep[]; |
| 66 |
/** The current step the wizard is on (1 or higher) */ |
| 67 |
startAtStep?: number; |
| 68 |
/** Aria-label for the Nav */ |
| 69 |
navAriaLabel?: string; |
| 70 |
/** Sets aria-labelledby on nav element */ |
| 71 |
navAriaLabelledBy?: string; |
| 72 |
/** Adds an accessible name to the wizard body when the body content overflows and renders |
| 73 |
* a scrollbar. |
| 74 |
*/ |
| 75 |
mainAriaLabel?: string; |
| 76 |
/** Adds an accessible name to the wizard body by passing the the id of one or more elements. |
| 77 |
* The aria-labelledby will only be applied when the body content overflows and renders a scrollbar. |
| 78 |
*/ |
| 79 |
mainAriaLabelledBy?: string; |
| 80 |
/** Can remove the default padding around the main body content by setting this to true */ |
| 81 |
hasNoBodyPadding?: boolean; |
| 82 |
/** (Use to control the footer) Passing in a footer component lets you control the buttons yourself */ |
| 83 |
footer?: React.ReactNode; |
| 84 |
/** (Unused if footer is controlled) Callback function to save at the end of the wizard, if not specified uses onClose */ |
| 85 |
onSave?: () => void; |
| 86 |
/** (Unused if footer is controlled) Callback function after Next button is clicked */ |
| 87 |
onNext?: WizardStepFunctionType; |
| 88 |
/** (Unused if footer is controlled) Callback function after Back button is clicked */ |
| 89 |
onBack?: WizardStepFunctionType; |
| 90 |
/** (Unused if footer is controlled) The Next button text */ |
| 91 |
nextButtonText?: React.ReactNode; |
| 92 |
/** (Unused if footer is controlled) The Back button text */ |
| 93 |
backButtonText?: React.ReactNode; |
| 94 |
/** (Unused if footer is controlled) The Cancel button text */ |
| 95 |
cancelButtonText?: React.ReactNode; |
| 96 |
/** (Unused if footer is controlled) aria-label for the close button */ |
| 97 |
closeButtonAriaLabel?: string; |
| 98 |
/** The parent container to append the modal to. Defaults to document.body */ |
| 99 |
appendTo?: HTMLElement | (() => HTMLElement); |
| 100 |
/** Flag indicating Wizard modal is open. Wizard will be placed into a modal if this prop is provided */ |
| 101 |
isOpen?: boolean; |
| 102 |
/** Flag indicating nav items with sub steps are expandable */ |
| 103 |
isNavExpandable?: boolean; |
| 104 |
/** Callback function to signal the current step in the wizard */ |
| 105 |
onCurrentStepChanged?: (step: WizardStep) => void; |
| 106 |
/** Flag indicating the wizard has a drawer for at least one of the wizard steps */ |
| 107 |
hasDrawer?: boolean; |
| 108 |
/** Flag indicating the wizard drawer is expanded */ |
| 109 |
isDrawerExpanded?: boolean; |
| 110 |
/** Callback function for when the drawer is toggled. Can be used to set browser focus in the drawer. */ |
| 111 |
onExpandDrawer?: () => void; |
| 112 |
} |
| 113 |
interface WizardState { |
| 114 |
currentStep: number; |
| 115 |
isNavOpen: boolean; |
| 116 |
} |
| 117 |
declare class Wizard extends Component<WizardProps, WizardState> { |
| 118 |
static displayName: string; |
| 119 |
private static currentId; |
| 120 |
static defaultProps: PickOptional<WizardProps>; |
| 121 |
private titleId; |
| 122 |
private descriptionId; |
| 123 |
private drawerRef; |
| 124 |
constructor(props: WizardProps); |
| 125 |
private handleKeyClicks; |
| 126 |
private onNext; |
| 127 |
private onBack; |
| 128 |
private goToStep; |
| 129 |
private goToStepById; |
| 130 |
private goToStepByName; |
| 131 |
private getFlattenedSteps; |
| 132 |
private getFlattenedStepsIndex; |
| 133 |
private initSteps; |
| 134 |
getElement: (appendTo: HTMLElement | (() => HTMLElement)) => HTMLElement; |
| 135 |
private setCurrentStep; |
| 136 |
componentDidMount(): void; |
| 137 |
componentWillUnmount(): void; |
| 138 |
componentDidUpdate(prevProps: Readonly<WizardProps>): void; |
| 139 |
render(): import("react/jsx-runtime").JSX.Element; |
| 140 |
} |
| 141 |
export { Wizard }; |
| 142 |
//# sourceMappingURL=Wizard.d.ts.map |