Skip to content

Commit 9b9a020

Browse files
committed
addressing feedback
1 parent 6373c25 commit 9b9a020

15 files changed

Lines changed: 100 additions & 104 deletions

packages/react-core/src/next/components/Wizard/Wizard.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface WizardProps extends React.HTMLProps<HTMLDivElement> {
3030
header?: React.ReactNode;
3131
/** Wizard footer */
3232
footer?: WizardFooterType;
33-
/** Wizard nav */
33+
/** Wizard navigation */
3434
nav?: WizardNavType;
3535
/** The initial index the wizard is to start on (1 or higher). Defaults to 1. */
3636
startIndex?: number;
@@ -40,11 +40,11 @@ export interface WizardProps extends React.HTMLProps<HTMLDivElement> {
4040
width?: number | string;
4141
/** Custom height of the wizard */
4242
height?: number | string;
43-
/** Disables nav items that haven't been visited. Defaults to false */
44-
forceStepVisit?: boolean;
43+
/** Disables navigation items that haven't been visited. Defaults to false */
44+
isStepVisitRequired?: boolean;
4545
/** Flag to unmount inactive steps instead of hiding. Defaults to true */
46-
unmountInactiveSteps?: boolean;
47-
/** Callback function when a step in the nav is clicked */
46+
hasUnmountedSteps?: boolean;
47+
/** Callback function when a step in the navigation is clicked */
4848
onNavByIndex?: WizardNavStepFunction;
4949
/** Callback function after next button is clicked */
5050
onNext?: WizardNavStepFunction;
@@ -65,8 +65,8 @@ export const Wizard = ({
6565
header,
6666
nav,
6767
startIndex = 1,
68-
forceStepVisit = false,
69-
unmountInactiveSteps = true,
68+
isStepVisitRequired = false,
69+
hasUnmountedSteps = true,
7070
onNavByIndex,
7171
onNext,
7272
onBack,
@@ -159,7 +159,7 @@ export const Wizard = ({
159159
steps={initialSteps}
160160
currentStepIndex={currentStepIndex}
161161
footer={footer}
162-
forceStepVisit={forceStepVisit}
162+
isStepVisitRequired={isStepVisitRequired}
163163
onNext={goToNextStep}
164164
onBack={goToPrevStep}
165165
onClose={onClose}
@@ -176,17 +176,17 @@ export const Wizard = ({
176176
{...wrapperProps}
177177
>
178178
{header}
179-
<WizardInternal nav={nav} unmountInactiveSteps={unmountInactiveSteps} forceStepVisit={forceStepVisit} />
179+
<WizardInternal nav={nav} hasUnmountedSteps={hasUnmountedSteps} isStepVisitRequired={isStepVisitRequired} />
180180
</div>
181181
</WizardContextProvider>
182182
);
183183
};
184184

185185
const WizardInternal = ({
186186
nav,
187-
unmountInactiveSteps,
188-
forceStepVisit
189-
}: Pick<WizardProps, 'nav' | 'unmountInactiveSteps' | 'forceStepVisit'>) => {
187+
hasUnmountedSteps,
188+
isStepVisitRequired
189+
}: Pick<WizardProps, 'nav' | 'hasUnmountedSteps' | 'isStepVisitRequired'>) => {
190190
const { currentStep, steps, footer, goToStepByIndex } = useWizardContext();
191191
const [isNavExpanded, setIsNavExpanded] = React.useState(false);
192192

@@ -195,8 +195,8 @@ const WizardInternal = ({
195195
return typeof nav === 'function' ? nav(isNavExpanded, steps, currentStep, goToStepByIndex) : nav;
196196
}
197197

198-
return <WizardNavInternal nav={nav} isNavExpanded={isNavExpanded} forceStepVisit={forceStepVisit} />;
199-
}, [currentStep, forceStepVisit, goToStepByIndex, isNavExpanded, nav, steps]);
198+
return <WizardNavInternal nav={nav} isNavExpanded={isNavExpanded} isStepVisitRequired={isStepVisitRequired} />;
199+
}, [currentStep, isStepVisitRequired, goToStepByIndex, isNavExpanded, nav, steps]);
200200

201201
return (
202202
<WizardToggle
@@ -206,7 +206,7 @@ const WizardInternal = ({
206206
currentStep={currentStep}
207207
isNavExpanded={isNavExpanded}
208208
toggleNavExpanded={() => setIsNavExpanded(prevIsExpanded => !prevIsExpanded)}
209-
unmountInactiveSteps={unmountInactiveSteps}
209+
hasUnmountedSteps={hasUnmountedSteps}
210210
/>
211211
);
212212
};

packages/react-core/src/next/components/Wizard/WizardContext.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface WizardContextProviderProps {
4141
steps: WizardControlStep[];
4242
currentStepIndex: number;
4343
footer: WizardFooterType;
44-
forceStepVisit: boolean;
44+
isStepVisitRequired: boolean;
4545
children: React.ReactElement;
4646
onNext(steps: WizardControlStep[]): void;
4747
onBack(steps: WizardControlStep[]): void;
@@ -55,7 +55,7 @@ export const WizardContextProvider: React.FunctionComponent<WizardContextProvide
5555
steps: initialSteps,
5656
footer: initialFooter,
5757
currentStepIndex,
58-
forceStepVisit,
58+
isStepVisitRequired,
5959
children,
6060
onNext,
6161
onBack,
@@ -90,7 +90,7 @@ export const WizardContextProvider: React.FunctionComponent<WizardContextProvide
9090
onNext={goToNextStep}
9191
onBack={goToPrevStep}
9292
onClose={onClose}
93-
disableBackButton={currentStep?.id === steps[0]?.id}
93+
isBackDisabled={currentStep?.id === steps[0]?.id}
9494
{...wizardFooter}
9595
/>
9696
);
@@ -134,10 +134,10 @@ export const WizardContextProvider: React.FunctionComponent<WizardContextProvide
134134
return stepToHide;
135135
}
136136

137-
// When forceStepVisit is enabled, if the step was previously hidden and not visited yet,
137+
// When isStepVisitRequired is enabled, if the step was previously hidden and not visited yet,
138138
// when it is shown, all steps beyond it should be disabled to ensure it is visited.
139139
if (
140-
forceStepVisit &&
140+
isStepVisitRequired &&
141141
stepToHide?.isHidden === false &&
142142
!stepToHide?.isVisited &&
143143
prevSteps.indexOf(stepToHide) < prevSteps.indexOf(prevStep)
@@ -148,7 +148,7 @@ export const WizardContextProvider: React.FunctionComponent<WizardContextProvide
148148
return prevStep;
149149
});
150150
}),
151-
[currentStep.id, forceStepVisit]
151+
[currentStep.id, isStepVisitRequired]
152152
);
153153

154154
return (

packages/react-core/src/next/components/Wizard/WizardFooter.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ export interface WizardFooterProps {
2626
/** Custom text for the Cancel link */
2727
cancelButtonText?: React.ReactNode;
2828
/** Flag to disable the next button */
29-
disableNextButton?: boolean;
29+
isNextDisabled?: boolean;
3030
/** Flag to disable the back button */
31-
disableBackButton?: boolean;
32-
/** True to hide the Cancel button */
33-
hideCancelButton?: boolean;
31+
isBackDisabled?: boolean;
3432
/** True to hide the Back button */
35-
hideBackButton?: boolean;
33+
isBackHidden?: boolean;
34+
/** True to hide the Cancel button */
35+
isCancelHidden?: boolean;
3636
}
3737

3838
export const WizardFooterWrapper: React.FunctionComponent = ({ children }) => (
@@ -48,26 +48,26 @@ const InternalWizardFooter = ({
4848
onNext,
4949
onBack,
5050
onClose,
51-
disableNextButton,
52-
disableBackButton,
53-
hideBackButton,
54-
hideCancelButton,
51+
isNextDisabled,
52+
isBackDisabled,
53+
isBackHidden,
54+
isCancelHidden,
5555
nextButtonText = 'Next',
5656
backButtonText = 'Back',
5757
cancelButtonText = 'Cancel'
5858
}: Omit<WizardFooterProps, 'currentStep'>) => (
5959
<WizardFooterWrapper>
60-
<Button variant={ButtonVariant.primary} type="submit" onClick={onNext} isDisabled={disableNextButton}>
60+
<Button variant={ButtonVariant.primary} type="submit" onClick={onNext} isDisabled={isNextDisabled}>
6161
{nextButtonText}
6262
</Button>
6363

64-
{!hideBackButton && (
65-
<Button variant={ButtonVariant.secondary} onClick={onBack} isDisabled={disableBackButton}>
64+
{!isBackHidden && (
65+
<Button variant={ButtonVariant.secondary} onClick={onBack} isDisabled={isBackDisabled}>
6666
{backButtonText}
6767
</Button>
6868
)}
6969

70-
{!hideCancelButton && (
70+
{!isCancelHidden && (
7171
<div className={styles.wizardFooterCancel}>
7272
<Button variant={ButtonVariant.link} onClick={onClose}>
7373
{cancelButtonText}

packages/react-core/src/next/components/Wizard/WizardHeader.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface WizardHeaderProps {
1515
/** Component type of the description */
1616
descriptionComponent?: 'div' | 'p';
1717
/** Flag indicating whether the close button should be in the header */
18-
hideClose?: boolean;
18+
isCloseHidden?: boolean;
1919
/** Aria-label applied to the X (Close) button */
2020
closeButtonAriaLabel?: string;
2121
/** id for the title */
@@ -28,14 +28,14 @@ export const WizardHeader: React.FunctionComponent<WizardHeaderProps> = ({
2828
onClose = () => undefined,
2929
title,
3030
description,
31-
hideClose,
31+
isCloseHidden,
3232
closeButtonAriaLabel,
3333
titleId,
3434
descriptionComponent: Component = 'p',
3535
descriptionId
3636
}: WizardHeaderProps) => (
3737
<div className={css(styles.wizardHeader)}>
38-
{!hideClose && (
38+
{!isCloseHidden && (
3939
<Button variant="plain" className={css(styles.wizardClose)} aria-label={closeButtonAriaLabel} onClick={onClose}>
4040
<TimesIcon aria-hidden="true" />
4141
</Button>

packages/react-core/src/next/components/Wizard/WizardNav.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,25 @@ import { css } from '@patternfly/react-styles';
55
export interface WizardNavProps {
66
/** children should be WizardNavItem components */
77
children?: any;
8-
/** Aria-label applied to the nav element */
9-
ariaLabel?: string;
10-
/** Sets the aria-labelledby attribute on the nav element */
11-
ariaLabelledBy?: string;
12-
/** Whether the nav is expanded */
8+
/** Aria-label applied to the navigation element */
9+
'aria-label'?: string;
10+
/** Sets the aria-labelledby attribute on the navigation element */
11+
'aria-labelledby'?: string;
12+
/** Whether the navigation is expanded */
1313
isExpanded?: boolean;
14-
/** True to return the inner list without the wrapping nav element */
15-
returnList?: boolean;
14+
/** True to return the inner list without the wrapping navigation element */
15+
isInnerList?: boolean;
1616
}
1717

1818
export const WizardNav: React.FunctionComponent<WizardNavProps> = ({
1919
children,
20-
ariaLabel,
21-
ariaLabelledBy,
20+
'aria-label': ariaLabel,
21+
'aria-labelledby': ariaLabelledBy,
2222
isExpanded = false,
23-
returnList = false
23+
isInnerList = false
2424
}: WizardNavProps) => {
25-
const innerList = <ol className={css(styles.wizardNavList)}>{children}</ol>;
26-
27-
if (returnList) {
28-
return innerList;
25+
if (isInnerList) {
26+
return <ol className={css(styles.wizardNavList)}>{children}</ol>;
2927
}
3028

3129
return (

packages/react-core/src/next/components/Wizard/WizardNavInternal.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ import { WizardNavItem } from './WizardNavItem';
1111
* This component is not exposed to consumers.
1212
*/
1313

14-
interface WizardNavInternalProps extends Pick<WizardProps, 'forceStepVisit'> {
14+
interface WizardNavInternalProps extends Pick<WizardProps, 'isStepVisitRequired'> {
1515
nav: Partial<WizardNavProps>;
1616
isNavExpanded: boolean;
1717
}
1818

19-
export const WizardNavInternal = ({ nav, forceStepVisit, isNavExpanded }: WizardNavInternalProps) => {
19+
export const WizardNavInternal = ({ nav, isStepVisitRequired, isNavExpanded }: WizardNavInternalProps) => {
2020
const { currentStep, steps, goToStepByIndex } = useWizardContext();
2121

22-
const wizardNavProps = {
22+
const wizardNavProps: WizardNavProps = {
2323
isExpanded: isNavExpanded,
24-
ariaLabel: nav?.ariaLabel || 'Wizard nav',
25-
...(nav?.ariaLabelledBy && {
26-
ariaLabelledBy: nav?.ariaLabelledBy
24+
'aria-label': nav?.['aria-label'] || 'Wizard navigation',
25+
...(nav?.['aria-labelledby'] && {
26+
'aria-labelledby': nav['aria-labelledby']
2727
})
2828
};
2929

@@ -54,7 +54,7 @@ export const WizardNavInternal = ({ nav, forceStepVisit, isNavExpanded }: Wizard
5454
</React.Fragment>
5555
);
5656

57-
// Don't render the sub-step nav item if the hidden property is enabled
57+
// Don't render the sub-step navigation item if the hidden property is enabled
5858
if (subStep.isHidden) {
5959
return;
6060
}
@@ -76,7 +76,7 @@ export const WizardNavInternal = ({ nav, forceStepVisit, isNavExpanded }: Wizard
7676
id={subStep.id}
7777
content={subStep.name}
7878
isCurrent={currentStep?.id === subStep.id}
79-
isDisabled={subStep.isDisabled || (forceStepVisit && !subStep.isVisited)}
79+
isDisabled={subStep.isDisabled || (isStepVisitRequired && !subStep.isVisited)}
8080
isVisited={subStep.isVisited}
8181
stepIndex={subStepOrderIndex}
8282
onNavItemClick={goToStepByIndex}
@@ -105,7 +105,7 @@ export const WizardNavInternal = ({ nav, forceStepVisit, isNavExpanded }: Wizard
105105
status={step.status}
106106
{...step.navItem}
107107
>
108-
<WizardNav {...wizardNavProps} returnList>
108+
<WizardNav {...wizardNavProps} isInnerList>
109109
{subNavItems}
110110
</WizardNav>
111111
</WizardNavItem>
@@ -121,7 +121,7 @@ export const WizardNavInternal = ({ nav, forceStepVisit, isNavExpanded }: Wizard
121121
id={step.id}
122122
content={step.name}
123123
isCurrent={currentStep?.id === step.id}
124-
isDisabled={step.isDisabled || (forceStepVisit && !step.isVisited)}
124+
isDisabled={step.isDisabled || (isStepVisitRequired && !step.isVisited)}
125125
isVisited={step.isVisited}
126126
stepIndex={stepIndex}
127127
onNavItemClick={goToStepByIndex}

packages/react-core/src/next/components/Wizard/WizardNavItem.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@ import { WizardNavItemStatus } from './types';
1010
export interface WizardNavItemProps {
1111
/** Can nest a WizardNav component for substeps */
1212
children?: React.ReactNode;
13-
/** The content to display in the nav item */
13+
/** The content to display in the navigation item */
1414
content?: React.ReactNode;
15-
/** Whether the nav item is the currently active item */
15+
/** Whether the navigation item is the currently active item */
1616
isCurrent?: boolean;
17-
/** Whether the nav item is disabled */
17+
/** Whether the navigation item is disabled */
1818
isDisabled?: boolean;
19-
/** Whether the nav item has been visited */
19+
/** Whether the navigation item has been visited */
2020
isVisited?: boolean;
2121
/** The step index passed into the onNavItemClick callback */
2222
stepIndex: number;
23-
/** Callback for when the nav item is clicked */
23+
/** Callback for when the navigation item is clicked */
2424
onNavItemClick?: (stepIndex: number) => any;
2525
/** Component used to render WizardNavItem */
2626
navItemComponent?: 'button' | 'a';
2727
/** An optional url to use for when using an anchor component */
2828
href?: string;
2929
/** Flag indicating that this NavItem has child steps and is expandable */
3030
isExpandable?: boolean;
31-
/** The id for the nav item */
31+
/** The id for the navigation item */
3232
id?: string | number;
3333
/** Used to determine the icon displayed next to content. Default has no icon. */
3434
status?: 'default' | 'error';

packages/react-core/src/next/components/Wizard/WizardStep.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { WizardFooterProps } from './WizardFooter';
1111
*/
1212

1313
export interface WizardStepProps {
14-
/** Name of the step's nav item */
14+
/** Name of the step's navigation item */
1515
name: React.ReactNode;
1616
/** Unique identifier */
1717
id: string | number;
@@ -21,19 +21,17 @@ export interface WizardStepProps {
2121
body?: Omit<Omit<WizardBodyProps, 'children'>, 'children'> | null;
2222
/** Optional list of sub-steps */
2323
steps?: React.ReactElement<WizardStepProps>[];
24-
/** Flag to disable the step's nav item */
24+
/** Flag to disable the step's navigation item */
2525
isDisabled?: boolean;
2626
/** Flag to represent whether the step has been visited (navigated to) */
2727
isVisited?: boolean;
2828
/** Flag to determine whether the step is hidden */
2929
isHidden?: boolean;
30-
/** Content shown when the step's nav item is selected. When treated as a parent step, only sub-step content will be shown. */
31-
component?: React.ReactElement;
32-
/** Replaces the step's nav item or its properties. */
30+
/** Replaces the step's navigation item or its properties. */
3331
navItem?: WizardNavItemType;
3432
/** Replaces the step's footer. The step's footer takes precedance over the wizard's footer. */
3533
footer?: React.ReactElement | Partial<WizardFooterProps>;
36-
/** Used to determine icon next to the step's navItem */
34+
/** Used to determine icon next to the step's navigation item */
3735
status?: 'default' | 'error';
3836
}
3937

@@ -57,7 +55,7 @@ export const WizardStep = ({ children, body, id, footer, isHidden, isDisabled, n
5755
}, [id, setStep, currentStep?.id, isDisabled, navItem, status, currentStep?.isVisited]);
5856

5957
// Toggle visibility when the isHidden flag updates.
60-
// Wizard's unmountInactiveSteps prop must be set to false for visibility changes to take effect.
58+
// Wizard's hasUnmountedSteps prop must be set to false for visibility changes to take effect.
6159
React.useEffect(() => {
6260
if (isHidden !== undefined) {
6361
toggleStep(id, isHidden);

0 commit comments

Comments
 (0)