@patternfly/react-core 4.274.0 → 4.275.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/components/Menu/MenuGroup.d.ts +1 -1
- package/components/Menu/MenuGroup.d.ts.map +1 -1
- package/components/Menu/MenuGroup.js.map +1 -1
- package/components/Select/Select.d.ts +2 -0
- package/components/Select/Select.d.ts.map +1 -1
- package/components/Select/Select.js +3 -3
- package/components/Select/Select.js.map +1 -1
- package/components/Select/SelectToggle.d.ts +4 -14
- package/components/Select/SelectToggle.d.ts.map +1 -1
- package/components/Select/SelectToggle.js +11 -5
- package/components/Select/SelectToggle.js.map +1 -1
- package/dist/esm/components/Menu/MenuGroup.d.ts +1 -1
- package/dist/esm/components/Menu/MenuGroup.d.ts.map +1 -1
- package/dist/esm/components/Menu/MenuGroup.js.map +1 -1
- package/dist/esm/components/Select/Select.d.ts +2 -0
- package/dist/esm/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/components/Select/Select.js +3 -3
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/Select/SelectToggle.d.ts +4 -14
- package/dist/esm/components/Select/SelectToggle.d.ts.map +1 -1
- package/dist/esm/components/Select/SelectToggle.js +11 -5
- package/dist/esm/components/Select/SelectToggle.js.map +1 -1
- package/dist/esm/next/components/Wizard/Wizard.d.ts +11 -14
- package/dist/esm/next/components/Wizard/Wizard.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/Wizard.js +30 -23
- package/dist/esm/next/components/Wizard/Wizard.js.map +1 -1
- package/dist/esm/next/components/Wizard/WizardContext.d.ts +16 -16
- package/dist/esm/next/components/Wizard/WizardContext.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardContext.js +17 -19
- package/dist/esm/next/components/Wizard/WizardContext.js.map +1 -1
- package/dist/esm/next/components/Wizard/WizardFooter.d.ts +8 -5
- package/dist/esm/next/components/Wizard/WizardFooter.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardFooter.js +1 -1
- package/dist/esm/next/components/Wizard/WizardFooter.js.map +1 -1
- package/dist/esm/next/components/Wizard/WizardHeader.d.ts +1 -1
- package/dist/esm/next/components/Wizard/WizardHeader.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardNavInternal.d.ts +2 -2
- package/dist/esm/next/components/Wizard/WizardNavInternal.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardNavInternal.js +15 -9
- package/dist/esm/next/components/Wizard/WizardNavInternal.js.map +1 -1
- package/dist/esm/next/components/Wizard/WizardNavItem.d.ts +10 -4
- package/dist/esm/next/components/Wizard/WizardNavItem.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardNavItem.js +10 -9
- package/dist/esm/next/components/Wizard/WizardNavItem.js.map +1 -1
- package/dist/esm/next/components/Wizard/WizardStep.d.ts +3 -3
- package/dist/esm/next/components/Wizard/WizardStep.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardStep.js +4 -2
- package/dist/esm/next/components/Wizard/WizardStep.js.map +1 -1
- package/dist/esm/next/components/Wizard/WizardToggle.d.ts +4 -4
- package/dist/esm/next/components/Wizard/WizardToggle.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardToggle.js +1 -1
- package/dist/esm/next/components/Wizard/WizardToggle.js.map +1 -1
- package/dist/esm/next/components/Wizard/hooks/index.d.ts +1 -0
- package/dist/esm/next/components/Wizard/hooks/index.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/hooks/index.js +1 -0
- package/dist/esm/next/components/Wizard/hooks/index.js.map +1 -1
- package/dist/esm/next/components/Wizard/hooks/useGetMergedSteps.d.ts +9 -0
- package/dist/esm/next/components/Wizard/hooks/useGetMergedSteps.d.ts.map +1 -0
- package/dist/esm/next/components/Wizard/hooks/useGetMergedSteps.js +33 -0
- package/dist/esm/next/components/Wizard/hooks/useGetMergedSteps.js.map +1 -0
- package/dist/esm/next/components/Wizard/index.d.ts +2 -2
- package/dist/esm/next/components/Wizard/index.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/index.js +2 -2
- package/dist/esm/next/components/Wizard/index.js.map +1 -1
- package/dist/esm/next/components/Wizard/types.d.ts +13 -19
- package/dist/esm/next/components/Wizard/types.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/types.js +6 -0
- package/dist/esm/next/components/Wizard/types.js.map +1 -1
- package/dist/esm/next/components/Wizard/utils.d.ts +5 -6
- package/dist/esm/next/components/Wizard/utils.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/utils.js +15 -22
- package/dist/esm/next/components/Wizard/utils.js.map +1 -1
- package/dist/js/components/Menu/MenuGroup.d.ts +1 -1
- package/dist/js/components/Menu/MenuGroup.d.ts.map +1 -1
- package/dist/js/components/Menu/MenuGroup.js.map +1 -1
- package/dist/js/components/Select/Select.d.ts +2 -0
- package/dist/js/components/Select/Select.d.ts.map +1 -1
- package/dist/js/components/Select/Select.js +3 -3
- package/dist/js/components/Select/Select.js.map +1 -1
- package/dist/js/components/Select/SelectToggle.d.ts +4 -14
- package/dist/js/components/Select/SelectToggle.d.ts.map +1 -1
- package/dist/js/components/Select/SelectToggle.js +11 -6
- package/dist/js/components/Select/SelectToggle.js.map +1 -1
- package/dist/js/next/components/Wizard/Wizard.d.ts +11 -14
- package/dist/js/next/components/Wizard/Wizard.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/Wizard.js +28 -21
- package/dist/js/next/components/Wizard/Wizard.js.map +1 -1
- package/dist/js/next/components/Wizard/WizardContext.d.ts +16 -16
- package/dist/js/next/components/Wizard/WizardContext.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardContext.js +16 -17
- package/dist/js/next/components/Wizard/WizardContext.js.map +1 -1
- package/dist/js/next/components/Wizard/WizardFooter.d.ts +8 -5
- package/dist/js/next/components/Wizard/WizardFooter.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardFooter.js +1 -1
- package/dist/js/next/components/Wizard/WizardFooter.js.map +1 -1
- package/dist/js/next/components/Wizard/WizardHeader.d.ts +1 -1
- package/dist/js/next/components/Wizard/WizardHeader.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardNavInternal.d.ts +2 -2
- package/dist/js/next/components/Wizard/WizardNavInternal.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardNavInternal.js +15 -9
- package/dist/js/next/components/Wizard/WizardNavInternal.js.map +1 -1
- package/dist/js/next/components/Wizard/WizardNavItem.d.ts +10 -4
- package/dist/js/next/components/Wizard/WizardNavItem.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardNavItem.js +10 -8
- package/dist/js/next/components/Wizard/WizardNavItem.js.map +1 -1
- package/dist/js/next/components/Wizard/WizardStep.d.ts +3 -3
- package/dist/js/next/components/Wizard/WizardStep.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardStep.js +4 -2
- package/dist/js/next/components/Wizard/WizardStep.js.map +1 -1
- package/dist/js/next/components/Wizard/WizardToggle.d.ts +4 -4
- package/dist/js/next/components/Wizard/WizardToggle.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardToggle.js +1 -1
- package/dist/js/next/components/Wizard/WizardToggle.js.map +1 -1
- package/dist/js/next/components/Wizard/hooks/index.d.ts +1 -0
- package/dist/js/next/components/Wizard/hooks/index.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/hooks/index.js +3 -1
- package/dist/js/next/components/Wizard/hooks/index.js.map +1 -1
- package/dist/js/next/components/Wizard/hooks/useGetMergedSteps.d.ts +9 -0
- package/dist/js/next/components/Wizard/hooks/useGetMergedSteps.d.ts.map +1 -0
- package/dist/js/next/components/Wizard/hooks/useGetMergedSteps.js +38 -0
- package/dist/js/next/components/Wizard/hooks/useGetMergedSteps.js.map +1 -0
- package/dist/js/next/components/Wizard/index.d.ts +2 -2
- package/dist/js/next/components/Wizard/index.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/index.js +4 -2
- package/dist/js/next/components/Wizard/index.js.map +1 -1
- package/dist/js/next/components/Wizard/types.d.ts +13 -19
- package/dist/js/next/components/Wizard/types.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/types.js +7 -1
- package/dist/js/next/components/Wizard/types.js.map +1 -1
- package/dist/js/next/components/Wizard/utils.d.ts +5 -6
- package/dist/js/next/components/Wizard/utils.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/utils.js +17 -25
- package/dist/js/next/components/Wizard/utils.js.map +1 -1
- package/dist/umd/react-core.min.js +2 -2
- package/next/components/Wizard/Wizard.d.ts +11 -14
- package/next/components/Wizard/Wizard.d.ts.map +1 -1
- package/next/components/Wizard/Wizard.js +30 -23
- package/next/components/Wizard/Wizard.js.map +1 -1
- package/next/components/Wizard/WizardContext.d.ts +16 -16
- package/next/components/Wizard/WizardContext.d.ts.map +1 -1
- package/next/components/Wizard/WizardContext.js +17 -19
- package/next/components/Wizard/WizardContext.js.map +1 -1
- package/next/components/Wizard/WizardFooter.d.ts +8 -5
- package/next/components/Wizard/WizardFooter.d.ts.map +1 -1
- package/next/components/Wizard/WizardFooter.js +1 -1
- package/next/components/Wizard/WizardFooter.js.map +1 -1
- package/next/components/Wizard/WizardHeader.d.ts +1 -1
- package/next/components/Wizard/WizardHeader.d.ts.map +1 -1
- package/next/components/Wizard/WizardNavInternal.d.ts +2 -2
- package/next/components/Wizard/WizardNavInternal.d.ts.map +1 -1
- package/next/components/Wizard/WizardNavInternal.js +15 -9
- package/next/components/Wizard/WizardNavInternal.js.map +1 -1
- package/next/components/Wizard/WizardNavItem.d.ts +10 -4
- package/next/components/Wizard/WizardNavItem.d.ts.map +1 -1
- package/next/components/Wizard/WizardNavItem.js +10 -9
- package/next/components/Wizard/WizardNavItem.js.map +1 -1
- package/next/components/Wizard/WizardStep.d.ts +3 -3
- package/next/components/Wizard/WizardStep.d.ts.map +1 -1
- package/next/components/Wizard/WizardStep.js +4 -2
- package/next/components/Wizard/WizardStep.js.map +1 -1
- package/next/components/Wizard/WizardToggle.d.ts +4 -4
- package/next/components/Wizard/WizardToggle.d.ts.map +1 -1
- package/next/components/Wizard/WizardToggle.js +1 -1
- package/next/components/Wizard/WizardToggle.js.map +1 -1
- package/next/components/Wizard/hooks/index.d.ts +1 -0
- package/next/components/Wizard/hooks/index.d.ts.map +1 -1
- package/next/components/Wizard/hooks/index.js +1 -0
- package/next/components/Wizard/hooks/index.js.map +1 -1
- package/next/components/Wizard/hooks/useGetMergedSteps.d.ts +9 -0
- package/next/components/Wizard/hooks/useGetMergedSteps.d.ts.map +1 -0
- package/next/components/Wizard/hooks/useGetMergedSteps.js +33 -0
- package/next/components/Wizard/hooks/useGetMergedSteps.js.map +1 -0
- package/next/components/Wizard/index.d.ts +2 -2
- package/next/components/Wizard/index.d.ts.map +1 -1
- package/next/components/Wizard/index.js +2 -2
- package/next/components/Wizard/index.js.map +1 -1
- package/next/components/Wizard/types.d.ts +13 -19
- package/next/components/Wizard/types.d.ts.map +1 -1
- package/next/components/Wizard/types.js +6 -0
- package/next/components/Wizard/types.js.map +1 -1
- package/next/components/Wizard/utils.d.ts +5 -6
- package/next/components/Wizard/utils.d.ts.map +1 -1
- package/next/components/Wizard/utils.js +15 -22
- package/next/components/Wizard/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Menu/MenuGroup.tsx +2 -2
- package/src/components/Select/Select.tsx +4 -0
- package/src/components/Select/SelectToggle.tsx +14 -3
- package/src/components/Select/examples/Select.md +28 -0
- package/src/next/components/Wizard/Wizard.tsx +71 -46
- package/src/next/components/Wizard/WizardContext.tsx +38 -43
- package/src/next/components/Wizard/WizardFooter.tsx +10 -6
- package/src/next/components/Wizard/WizardHeader.tsx +1 -1
- package/src/next/components/Wizard/WizardNavInternal.tsx +51 -43
- package/src/next/components/Wizard/WizardNavItem.tsx +21 -14
- package/src/next/components/Wizard/WizardStep.tsx +8 -6
- package/src/next/components/Wizard/WizardToggle.tsx +5 -5
- package/src/next/components/Wizard/__tests__/Wizard.test.tsx +129 -26
- package/src/next/components/Wizard/__tests__/WizardStep.test.tsx +5 -5
- package/src/next/components/Wizard/__tests__/WizardToggle.test.tsx +2 -2
- package/src/next/components/Wizard/__tests__/utils.test.tsx +3 -17
- package/src/next/components/Wizard/examples/Wizard.md +69 -41
- package/src/next/components/Wizard/examples/WizardBasic.tsx +6 -12
- package/src/next/components/Wizard/examples/WizardBasicDisabledSteps.tsx +22 -0
- package/src/next/components/Wizard/examples/WizardEnabledOnFormValidation.tsx +84 -0
- package/src/next/components/Wizard/examples/WizardExpandableSteps.tsx +42 -0
- package/src/next/components/Wizard/examples/WizardGetCurrentStep.tsx +53 -0
- package/src/next/components/Wizard/examples/WizardProgressiveSteps.tsx +31 -0
- package/src/next/components/Wizard/examples/WizardStepDrawerContent.tsx +80 -0
- package/src/next/components/Wizard/examples/WizardStepErrorStatus.tsx +55 -0
- package/src/next/components/Wizard/examples/WizardStepVisitRequired.tsx +22 -0
- package/src/next/components/Wizard/examples/WizardToggleStepVisibility.tsx +57 -0
- package/src/next/components/Wizard/examples/WizardValidateOnButtonPress.tsx +183 -0
- package/src/next/components/Wizard/examples/WizardWithCustomFooter.tsx +107 -0
- package/src/next/components/Wizard/examples/{WizardCustomNav.tsx → WizardWithCustomNav.tsx} +11 -11
- package/src/next/components/Wizard/examples/WizardWithCustomNavItem.tsx +22 -0
- package/src/next/components/Wizard/examples/WizardWithHeader.tsx +26 -0
- package/src/next/components/Wizard/examples/WizardWithNavAnchors.tsx +46 -0
- package/src/next/components/Wizard/examples/WizardWithSubmitProgress.tsx +86 -0
- package/src/next/components/Wizard/examples/WizardWithinModal.tsx +41 -0
- package/src/next/components/Wizard/hooks/index.ts +1 -0
- package/src/next/components/Wizard/hooks/useGetMergedSteps.tsx +45 -0
- package/src/next/components/Wizard/index.ts +2 -2
- package/src/next/components/Wizard/types.tsx +19 -29
- package/src/next/components/Wizard/utils.ts +27 -33
- package/src/next/components/Wizard/examples/WizardKitchenSink.tsx +0 -243
|
@@ -8,7 +8,7 @@ import { PickOptional } from '../../helpers/typeUtils';
|
|
|
8
8
|
import { findTabbableElements } from '../../helpers/util';
|
|
9
9
|
import { KeyTypes } from '../../helpers/constants';
|
|
10
10
|
|
|
11
|
-
export interface SelectToggleProps extends React.HTMLProps<HTMLElement> {
|
|
11
|
+
export interface SelectToggleProps extends Omit<React.HTMLProps<HTMLElement>, 'ref'> {
|
|
12
12
|
/** HTML ID of dropdown toggle */
|
|
13
13
|
id: string;
|
|
14
14
|
/** Anything which can be rendered as dropdown toggle */
|
|
@@ -59,9 +59,11 @@ export interface SelectToggleProps extends React.HTMLProps<HTMLElement> {
|
|
|
59
59
|
hasFooter?: boolean;
|
|
60
60
|
/** @hide Internal callback for handling focus when typeahead toggle button clicked. */
|
|
61
61
|
onClickTypeaheadToggleButton?: () => void;
|
|
62
|
+
/** @hide Internal ref for the select toggle */
|
|
63
|
+
innerRef?: React.Ref<any>;
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
|
|
66
|
+
class SelectToggleBase extends React.Component<SelectToggleProps> {
|
|
65
67
|
static displayName = 'SelectToggle';
|
|
66
68
|
private toggle: React.RefObject<HTMLDivElement> | React.RefObject<HTMLButtonElement>;
|
|
67
69
|
|
|
@@ -88,7 +90,11 @@ export class SelectToggle extends React.Component<SelectToggleProps> {
|
|
|
88
90
|
super(props);
|
|
89
91
|
const { variant } = props;
|
|
90
92
|
const isTypeahead = variant === SelectVariant.typeahead || variant === SelectVariant.typeaheadMulti;
|
|
91
|
-
this.
|
|
93
|
+
if (this.props.innerRef) {
|
|
94
|
+
this.toggle = this.props.innerRef as React.RefObject<HTMLButtonElement> | React.RefObject<HTMLDivElement>;
|
|
95
|
+
} else {
|
|
96
|
+
this.toggle = isTypeahead ? React.createRef<HTMLDivElement>() : React.createRef<HTMLButtonElement>();
|
|
97
|
+
}
|
|
92
98
|
}
|
|
93
99
|
|
|
94
100
|
componentDidMount() {
|
|
@@ -265,6 +271,7 @@ export class SelectToggle extends React.Component<SelectToggleProps> {
|
|
|
265
271
|
hasFooter,
|
|
266
272
|
footerRef,
|
|
267
273
|
toggleIndicator,
|
|
274
|
+
innerRef,
|
|
268
275
|
...props
|
|
269
276
|
} = this.props;
|
|
270
277
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
@@ -363,3 +370,7 @@ export class SelectToggle extends React.Component<SelectToggleProps> {
|
|
|
363
370
|
);
|
|
364
371
|
}
|
|
365
372
|
}
|
|
373
|
+
|
|
374
|
+
export const SelectToggle = React.forwardRef((props: SelectToggleProps, ref: React.Ref<any>) => (
|
|
375
|
+
<SelectToggleBase innerRef={ref} {...props} />
|
|
376
|
+
));
|
|
@@ -31,6 +31,8 @@ class SingleSelectInput extends React.Component {
|
|
|
31
31
|
<SelectOption key={7} value="Other" />
|
|
32
32
|
];
|
|
33
33
|
|
|
34
|
+
this.toggleRef = React.createRef();
|
|
35
|
+
|
|
34
36
|
this.state = {
|
|
35
37
|
isToggleIcon: false,
|
|
36
38
|
isOpen: false,
|
|
@@ -53,6 +55,7 @@ class SingleSelectInput extends React.Component {
|
|
|
53
55
|
isOpen: false
|
|
54
56
|
});
|
|
55
57
|
console.log('selected:', selection);
|
|
58
|
+
this.toggleRef.current.focus();
|
|
56
59
|
}
|
|
57
60
|
};
|
|
58
61
|
|
|
@@ -97,6 +100,7 @@ class SingleSelectInput extends React.Component {
|
|
|
97
100
|
Title
|
|
98
101
|
</span>
|
|
99
102
|
<Select
|
|
103
|
+
toggleRef={this.toggleRef}
|
|
100
104
|
toggleIcon={isToggleIcon && <CubeIcon />}
|
|
101
105
|
variant={SelectVariant.single}
|
|
102
106
|
aria-label="Select Input"
|
|
@@ -158,6 +162,8 @@ class SingleSelectDescription extends React.Component {
|
|
|
158
162
|
{ value: 'Other', disabled: false }
|
|
159
163
|
];
|
|
160
164
|
|
|
165
|
+
this.toggleRef = React.createRef();
|
|
166
|
+
|
|
161
167
|
this.state = {
|
|
162
168
|
isOpen: false,
|
|
163
169
|
selected: null,
|
|
@@ -178,6 +184,7 @@ class SingleSelectDescription extends React.Component {
|
|
|
178
184
|
isOpen: false
|
|
179
185
|
});
|
|
180
186
|
console.log('selected:', selection);
|
|
187
|
+
this.toggleRef.current.focus();
|
|
181
188
|
}
|
|
182
189
|
};
|
|
183
190
|
|
|
@@ -202,6 +209,7 @@ class SingleSelectDescription extends React.Component {
|
|
|
202
209
|
placeholderText="Select an option"
|
|
203
210
|
aria-label="Select Input with descriptions"
|
|
204
211
|
onToggle={this.onToggle}
|
|
212
|
+
toggleRef={this.toggleRef}
|
|
205
213
|
onSelect={this.onSelect}
|
|
206
214
|
selections={selected}
|
|
207
215
|
isOpen={isOpen}
|
|
@@ -238,6 +246,8 @@ class GroupedSingleSelectInput extends React.Component {
|
|
|
238
246
|
selected: null
|
|
239
247
|
};
|
|
240
248
|
|
|
249
|
+
this.toggleRef = React.createRef();
|
|
250
|
+
|
|
241
251
|
this.onToggle = isOpen => {
|
|
242
252
|
this.setState({
|
|
243
253
|
isOpen
|
|
@@ -249,6 +259,7 @@ class GroupedSingleSelectInput extends React.Component {
|
|
|
249
259
|
selected: selection,
|
|
250
260
|
isOpen: false
|
|
251
261
|
});
|
|
262
|
+
this.toggleRef.current.focus();
|
|
252
263
|
};
|
|
253
264
|
|
|
254
265
|
this.clearSelection = () => {
|
|
@@ -284,6 +295,7 @@ class GroupedSingleSelectInput extends React.Component {
|
|
|
284
295
|
</span>
|
|
285
296
|
<Select
|
|
286
297
|
variant={SelectVariant.single}
|
|
298
|
+
toggleRef={this.toggleRef}
|
|
287
299
|
onToggle={this.onToggle}
|
|
288
300
|
onSelect={this.onSelect}
|
|
289
301
|
selections={selected}
|
|
@@ -319,6 +331,8 @@ class ValidatedSelect extends React.Component {
|
|
|
319
331
|
<SelectOption key={6} value="Other" />
|
|
320
332
|
];
|
|
321
333
|
|
|
334
|
+
this.toggleRef = React.createRef();
|
|
335
|
+
|
|
322
336
|
this.state = {
|
|
323
337
|
isOpen: false,
|
|
324
338
|
selected: null,
|
|
@@ -352,6 +366,7 @@ class ValidatedSelect extends React.Component {
|
|
|
352
366
|
this.setState({
|
|
353
367
|
validated: validatedState
|
|
354
368
|
});
|
|
369
|
+
this.toggleRef.current.focus();
|
|
355
370
|
};
|
|
356
371
|
|
|
357
372
|
this.clearSelection = () => {
|
|
@@ -372,6 +387,7 @@ class ValidatedSelect extends React.Component {
|
|
|
372
387
|
</span>
|
|
373
388
|
<Select
|
|
374
389
|
variant={SelectVariant.single}
|
|
390
|
+
toggleRef={this.toggleRef}
|
|
375
391
|
placeholderText="Select an option"
|
|
376
392
|
aria-label="Select Input with validation"
|
|
377
393
|
onToggle={this.onToggle}
|
|
@@ -728,6 +744,8 @@ class FilteringSingleSelectInput extends React.Component {
|
|
|
728
744
|
isInputFilterPersisted: false
|
|
729
745
|
};
|
|
730
746
|
|
|
747
|
+
this.toggleRef = React.createRef();
|
|
748
|
+
|
|
731
749
|
this.options = [
|
|
732
750
|
<SelectGroup label="Status" key="group1">
|
|
733
751
|
<SelectOption key={0} value="Running" />
|
|
@@ -749,6 +767,7 @@ class FilteringSingleSelectInput extends React.Component {
|
|
|
749
767
|
|
|
750
768
|
this.onSelect = (event, selection) => {
|
|
751
769
|
this.setState({ selected: selection, isOpen: false }), console.log('selected: ', selection);
|
|
770
|
+
this.toggleRef.current.focus();
|
|
752
771
|
};
|
|
753
772
|
|
|
754
773
|
this.onFilter = (_, textInput) => {
|
|
@@ -805,6 +824,7 @@ class FilteringSingleSelectInput extends React.Component {
|
|
|
805
824
|
</span>
|
|
806
825
|
<Select
|
|
807
826
|
variant={SelectVariant.single}
|
|
827
|
+
toggleRef={this.toggleRef}
|
|
808
828
|
onToggle={this.onToggle}
|
|
809
829
|
onSelect={this.onSelect}
|
|
810
830
|
selections={selected}
|
|
@@ -2460,6 +2480,8 @@ class SelectWithFooter extends React.Component {
|
|
|
2460
2480
|
<SelectOption key={7} value="Other" />
|
|
2461
2481
|
];
|
|
2462
2482
|
|
|
2483
|
+
this.toggleRef = React.createRef();
|
|
2484
|
+
|
|
2463
2485
|
this.state = {
|
|
2464
2486
|
isToggleIcon: false,
|
|
2465
2487
|
isOpen: false,
|
|
@@ -2482,6 +2504,7 @@ class SelectWithFooter extends React.Component {
|
|
|
2482
2504
|
isOpen: false
|
|
2483
2505
|
});
|
|
2484
2506
|
console.log('selected:', selection);
|
|
2507
|
+
this.toggleRef.current.focus();
|
|
2485
2508
|
}
|
|
2486
2509
|
};
|
|
2487
2510
|
|
|
@@ -2503,6 +2526,7 @@ class SelectWithFooter extends React.Component {
|
|
|
2503
2526
|
</span>
|
|
2504
2527
|
<Select
|
|
2505
2528
|
toggleIcon={isToggleIcon && <CubeIcon />}
|
|
2529
|
+
toggleRef={this.toggleRef}
|
|
2506
2530
|
variant={SelectVariant.single}
|
|
2507
2531
|
aria-label="Select Input"
|
|
2508
2532
|
onToggle={this.onToggle}
|
|
@@ -2630,6 +2654,8 @@ class SelectViewMore extends React.Component {
|
|
|
2630
2654
|
<SelectOption key={6} value="Other" />
|
|
2631
2655
|
];
|
|
2632
2656
|
|
|
2657
|
+
this.toggleRef = React.createRef();
|
|
2658
|
+
|
|
2633
2659
|
this.state = {
|
|
2634
2660
|
isOpen: false,
|
|
2635
2661
|
selected: null,
|
|
@@ -2651,6 +2677,7 @@ class SelectViewMore extends React.Component {
|
|
|
2651
2677
|
isOpen: false
|
|
2652
2678
|
});
|
|
2653
2679
|
console.log('selected:', selection);
|
|
2680
|
+
this.toggleRef.current.focus();
|
|
2654
2681
|
}
|
|
2655
2682
|
};
|
|
2656
2683
|
|
|
@@ -2686,6 +2713,7 @@ class SelectViewMore extends React.Component {
|
|
|
2686
2713
|
</span>
|
|
2687
2714
|
<Select
|
|
2688
2715
|
variant={SelectVariant.single}
|
|
2716
|
+
toggleRef={this.toggleRef}
|
|
2689
2717
|
aria-label="Select Input"
|
|
2690
2718
|
onToggle={this.onToggle}
|
|
2691
2719
|
onSelect={this.onSelect}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import findLastIndex from 'lodash/findLastIndex';
|
|
3
2
|
|
|
4
3
|
import { css } from '@patternfly/react-styles';
|
|
5
4
|
import styles from '@patternfly/react-styles/css/components/Wizard/wizard';
|
|
6
5
|
|
|
7
6
|
import {
|
|
8
7
|
isWizardParentStep,
|
|
9
|
-
|
|
10
|
-
WizardControlStep,
|
|
8
|
+
WizardStepType,
|
|
11
9
|
isCustomWizardNav,
|
|
12
10
|
WizardFooterType,
|
|
13
|
-
WizardNavType
|
|
11
|
+
WizardNavType,
|
|
12
|
+
WizardStepChangeScope
|
|
14
13
|
} from './types';
|
|
15
|
-
import { buildSteps
|
|
14
|
+
import { buildSteps } from './utils';
|
|
16
15
|
import { useWizardContext, WizardContextProvider } from './WizardContext';
|
|
17
|
-
import { WizardStepProps } from './WizardStep';
|
|
18
16
|
import { WizardToggle } from './WizardToggle';
|
|
19
17
|
import { WizardNavInternal } from './WizardNavInternal';
|
|
20
18
|
|
|
@@ -25,7 +23,7 @@ import { WizardNavInternal } from './WizardNavInternal';
|
|
|
25
23
|
|
|
26
24
|
export interface WizardProps extends React.HTMLProps<HTMLDivElement> {
|
|
27
25
|
/** Step components */
|
|
28
|
-
children: React.
|
|
26
|
+
children: React.ReactNode | React.ReactNode[];
|
|
29
27
|
/** Wizard header */
|
|
30
28
|
header?: React.ReactNode;
|
|
31
29
|
/** Wizard footer */
|
|
@@ -40,18 +38,21 @@ export interface WizardProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
40
38
|
width?: number | string;
|
|
41
39
|
/** Custom height of the wizard */
|
|
42
40
|
height?: number | string;
|
|
43
|
-
/** Disables
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
/** Callback function
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
/** Disables steps that haven't been visited. Defaults to false. */
|
|
42
|
+
isVisitRequired?: boolean;
|
|
43
|
+
/** Progressively shows steps, where all steps following the active step are hidden. Defaults to false. */
|
|
44
|
+
isProgressive?: boolean;
|
|
45
|
+
/** Callback function when navigating between steps */
|
|
46
|
+
onStepChange?: (
|
|
47
|
+
event: React.MouseEvent<HTMLButtonElement>,
|
|
48
|
+
currentStep: WizardStepType,
|
|
49
|
+
prevStep: WizardStepType,
|
|
50
|
+
scope: WizardStepChangeScope
|
|
51
|
+
) => void | Promise<void>;
|
|
51
52
|
/** Callback function to save at the end of the wizard, if not specified uses onClose */
|
|
52
|
-
onSave?: () => void | Promise<void>;
|
|
53
|
+
onSave?: (event: React.MouseEvent<HTMLButtonElement>) => void | Promise<void>;
|
|
53
54
|
/** Callback function to close the wizard */
|
|
54
|
-
onClose?: () => void;
|
|
55
|
+
onClose?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
export const Wizard = ({
|
|
@@ -63,48 +64,61 @@ export const Wizard = ({
|
|
|
63
64
|
header,
|
|
64
65
|
nav,
|
|
65
66
|
startIndex = 1,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
onBack,
|
|
67
|
+
isVisitRequired = false,
|
|
68
|
+
isProgressive = false,
|
|
69
|
+
onStepChange,
|
|
70
70
|
onSave,
|
|
71
71
|
onClose,
|
|
72
72
|
...wrapperProps
|
|
73
73
|
}: WizardProps) => {
|
|
74
74
|
const [activeStepIndex, setActiveStepIndex] = React.useState(startIndex);
|
|
75
75
|
const initialSteps = buildSteps(children);
|
|
76
|
+
const firstStepRef = React.useRef(initialSteps[startIndex - 1]);
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
// When the startIndex maps to a parent step, focus on the first sub-step
|
|
79
|
+
React.useEffect(() => {
|
|
80
|
+
if (isWizardParentStep(firstStepRef.current)) {
|
|
81
|
+
setActiveStepIndex(startIndex + 1);
|
|
82
|
+
}
|
|
83
|
+
}, [startIndex]);
|
|
84
|
+
|
|
85
|
+
const goToNextStep = (event: React.MouseEvent<HTMLButtonElement>, steps: WizardStepType[] = initialSteps) => {
|
|
86
|
+
const newStep = steps.find(
|
|
87
|
+
step => step.index > activeStepIndex && !step.isHidden && !step.isDisabled && !isWizardParentStep(step)
|
|
88
|
+
);
|
|
80
89
|
|
|
81
|
-
if (activeStepIndex >= steps.length || !
|
|
82
|
-
return onSave ? onSave() : onClose?.();
|
|
90
|
+
if (activeStepIndex >= steps.length || !newStep?.index) {
|
|
91
|
+
return onSave ? onSave(event) : onClose?.(event);
|
|
83
92
|
}
|
|
84
93
|
|
|
85
94
|
const currStep = isWizardParentStep(steps[activeStepIndex]) ? steps[activeStepIndex + 1] : steps[activeStepIndex];
|
|
86
95
|
const prevStep = steps[activeStepIndex - 1];
|
|
87
96
|
|
|
88
|
-
setActiveStepIndex(
|
|
89
|
-
|
|
97
|
+
setActiveStepIndex(newStep?.index);
|
|
98
|
+
onStepChange?.(event, currStep, prevStep, WizardStepChangeScope.Next);
|
|
90
99
|
};
|
|
91
100
|
|
|
92
|
-
const goToPrevStep = (steps:
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
(step:
|
|
97
|
-
|
|
101
|
+
const goToPrevStep = (event: React.MouseEvent<HTMLButtonElement>, steps: WizardStepType[] = initialSteps) => {
|
|
102
|
+
const newStep = [...steps]
|
|
103
|
+
.reverse()
|
|
104
|
+
.find(
|
|
105
|
+
(step: WizardStepType) =>
|
|
106
|
+
step.index < activeStepIndex && !step.isHidden && !step.isDisabled && !isWizardParentStep(step)
|
|
107
|
+
);
|
|
98
108
|
const currStep = isWizardParentStep(steps[activeStepIndex - 2])
|
|
99
109
|
? steps[activeStepIndex - 3]
|
|
100
110
|
: steps[activeStepIndex - 2];
|
|
101
111
|
const prevStep = steps[activeStepIndex - 1];
|
|
102
112
|
|
|
103
|
-
setActiveStepIndex(
|
|
104
|
-
|
|
113
|
+
setActiveStepIndex(newStep?.index);
|
|
114
|
+
onStepChange?.(event, currStep, prevStep, WizardStepChangeScope.Back);
|
|
105
115
|
};
|
|
106
116
|
|
|
107
|
-
const goToStepByIndex = (
|
|
117
|
+
const goToStepByIndex = (
|
|
118
|
+
event: React.MouseEvent<HTMLButtonElement>,
|
|
119
|
+
steps: WizardStepType[] = initialSteps,
|
|
120
|
+
index: number
|
|
121
|
+
) => {
|
|
108
122
|
const lastStepIndex = steps.length + 1;
|
|
109
123
|
|
|
110
124
|
// Handle index when out of bounds or hidden
|
|
@@ -118,25 +132,25 @@ export const Wizard = ({
|
|
|
118
132
|
const prevStep = steps[activeStepIndex - 1];
|
|
119
133
|
|
|
120
134
|
setActiveStepIndex(index);
|
|
121
|
-
|
|
135
|
+
onStepChange?.(event, currStep, prevStep, WizardStepChangeScope.Nav);
|
|
122
136
|
};
|
|
123
137
|
|
|
124
|
-
const goToStepById = (steps:
|
|
138
|
+
const goToStepById = (steps: WizardStepType[] = initialSteps, id: number | string) => {
|
|
125
139
|
const step = steps.find(step => step.id === id);
|
|
126
140
|
const stepIndex = step?.index;
|
|
127
141
|
const lastStepIndex = steps.length + 1;
|
|
128
142
|
|
|
129
|
-
if (stepIndex > 0 && stepIndex < lastStepIndex && !step.isHidden) {
|
|
143
|
+
if (stepIndex > 0 && stepIndex < lastStepIndex && !step.isDisabled && !step.isHidden) {
|
|
130
144
|
setActiveStepIndex(stepIndex);
|
|
131
145
|
}
|
|
132
146
|
};
|
|
133
147
|
|
|
134
|
-
const goToStepByName = (steps:
|
|
148
|
+
const goToStepByName = (steps: WizardStepType[] = initialSteps, name: string) => {
|
|
135
149
|
const step = steps.find(step => step.name === name);
|
|
136
150
|
const stepIndex = step?.index;
|
|
137
151
|
const lastStepIndex = steps.length + 1;
|
|
138
152
|
|
|
139
|
-
if (stepIndex > 0 && stepIndex < lastStepIndex && !step.isHidden) {
|
|
153
|
+
if (stepIndex > 0 && stepIndex < lastStepIndex && !step.isDisabled && !step.isHidden) {
|
|
140
154
|
setActiveStepIndex(stepIndex);
|
|
141
155
|
}
|
|
142
156
|
};
|
|
@@ -162,13 +176,17 @@ export const Wizard = ({
|
|
|
162
176
|
{...wrapperProps}
|
|
163
177
|
>
|
|
164
178
|
{header}
|
|
165
|
-
<WizardInternal nav={nav}
|
|
179
|
+
<WizardInternal nav={nav} isVisitRequired={isVisitRequired} isProgressive={isProgressive} />
|
|
166
180
|
</div>
|
|
167
181
|
</WizardContextProvider>
|
|
168
182
|
);
|
|
169
183
|
};
|
|
170
184
|
|
|
171
|
-
const WizardInternal = ({
|
|
185
|
+
const WizardInternal = ({
|
|
186
|
+
nav,
|
|
187
|
+
isVisitRequired,
|
|
188
|
+
isProgressive
|
|
189
|
+
}: Pick<WizardProps, 'nav' | 'isVisitRequired' | 'isProgressive'>) => {
|
|
172
190
|
const { activeStep, steps, footer, goToStepByIndex } = useWizardContext();
|
|
173
191
|
const [isNavExpanded, setIsNavExpanded] = React.useState(false);
|
|
174
192
|
|
|
@@ -177,8 +195,15 @@ const WizardInternal = ({ nav, isStepVisitRequired }: Pick<WizardProps, 'nav' |
|
|
|
177
195
|
return typeof nav === 'function' ? nav(isNavExpanded, steps, activeStep, goToStepByIndex) : nav;
|
|
178
196
|
}
|
|
179
197
|
|
|
180
|
-
return
|
|
181
|
-
|
|
198
|
+
return (
|
|
199
|
+
<WizardNavInternal
|
|
200
|
+
nav={nav}
|
|
201
|
+
isNavExpanded={isNavExpanded}
|
|
202
|
+
isVisitRequired={isVisitRequired}
|
|
203
|
+
isProgressive={isProgressive}
|
|
204
|
+
/>
|
|
205
|
+
);
|
|
206
|
+
}, [activeStep, isVisitRequired, isProgressive, goToStepByIndex, isNavExpanded, nav, steps]);
|
|
182
207
|
|
|
183
208
|
return (
|
|
184
209
|
<WizardToggle
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import { isCustomWizardFooter,
|
|
3
|
+
import { isCustomWizardFooter, isWizardSubStep, WizardStepType, WizardFooterType } from './types';
|
|
4
4
|
import { getActiveStep } from './utils';
|
|
5
|
+
import { useGetMergedSteps } from './hooks';
|
|
5
6
|
import { WizardFooter, WizardFooterProps } from './WizardFooter';
|
|
6
7
|
|
|
7
8
|
export interface WizardContextProps {
|
|
8
9
|
/** List of steps */
|
|
9
|
-
steps:
|
|
10
|
+
steps: WizardStepType[];
|
|
10
11
|
/** Current step */
|
|
11
|
-
activeStep:
|
|
12
|
+
activeStep: WizardStepType;
|
|
12
13
|
/** Footer element */
|
|
13
14
|
footer: React.ReactElement;
|
|
15
|
+
/** Close the wizard */
|
|
16
|
+
close: () => void;
|
|
14
17
|
/** Navigate to the next step */
|
|
15
|
-
|
|
18
|
+
goToNextStep: () => void | Promise<void>;
|
|
16
19
|
/** Navigate to the previous step */
|
|
17
|
-
|
|
18
|
-
/** Close the wizard */
|
|
19
|
-
onClose: () => void;
|
|
20
|
+
goToPrevStep: () => void | Promise<void>;
|
|
20
21
|
/** Navigate to step by ID */
|
|
21
22
|
goToStepById: (id: number | string) => void;
|
|
22
23
|
/** Navigate to step by name */
|
|
@@ -26,24 +27,28 @@ export interface WizardContextProps {
|
|
|
26
27
|
/** Update the footer with any react element */
|
|
27
28
|
setFooter: (footer: React.ReactElement | Partial<WizardFooterProps>) => void;
|
|
28
29
|
/** Get step by ID */
|
|
29
|
-
getStep: (stepId: number | string) =>
|
|
30
|
+
getStep: (stepId: number | string) => WizardStepType;
|
|
30
31
|
/** Set step by ID */
|
|
31
|
-
setStep: (step: Pick<
|
|
32
|
+
setStep: (step: Pick<WizardStepType, 'id'> & Partial<WizardStepType>) => void;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
export const WizardContext = React.createContext({} as WizardContextProps);
|
|
35
36
|
|
|
36
37
|
export interface WizardContextProviderProps {
|
|
37
|
-
steps:
|
|
38
|
+
steps: WizardStepType[];
|
|
38
39
|
activeStepIndex: number;
|
|
39
40
|
footer: WizardFooterType;
|
|
40
41
|
children: React.ReactElement;
|
|
41
|
-
onNext(steps:
|
|
42
|
-
onBack(steps:
|
|
43
|
-
onClose(): void;
|
|
44
|
-
goToStepById(steps:
|
|
45
|
-
goToStepByName(steps:
|
|
46
|
-
goToStepByIndex(
|
|
42
|
+
onNext(event: React.MouseEvent<HTMLButtonElement>, steps: WizardStepType[]): void;
|
|
43
|
+
onBack(event: React.MouseEvent<HTMLButtonElement>, steps: WizardStepType[]): void;
|
|
44
|
+
onClose(event: React.MouseEvent<HTMLButtonElement>): void;
|
|
45
|
+
goToStepById(steps: WizardStepType[], id: number | string): void;
|
|
46
|
+
goToStepByName(steps: WizardStepType[], name: string): void;
|
|
47
|
+
goToStepByIndex(
|
|
48
|
+
event: React.MouseEvent<HTMLButtonElement> | React.MouseEvent<HTMLAnchorElement>,
|
|
49
|
+
steps: WizardStepType[],
|
|
50
|
+
index: number
|
|
51
|
+
): void;
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
export const WizardContextProvider: React.FunctionComponent<WizardContextProviderProps> = ({
|
|
@@ -62,25 +67,12 @@ export const WizardContextProvider: React.FunctionComponent<WizardContextProvide
|
|
|
62
67
|
const [currentFooter, setCurrentFooter] = React.useState(
|
|
63
68
|
typeof initialFooter !== 'function' ? initialFooter : undefined
|
|
64
69
|
);
|
|
70
|
+
const steps = useGetMergedSteps(initialSteps, currentSteps);
|
|
71
|
+
const activeStep = React.useMemo(() => getActiveStep(steps, activeStepIndex), [activeStepIndex, steps]);
|
|
65
72
|
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
currentSteps.map((currentStepProps, index) => {
|
|
70
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
71
|
-
const { isVisited, ...initialStepProps } = initialSteps[index];
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
...currentStepProps,
|
|
75
|
-
...initialStepProps
|
|
76
|
-
};
|
|
77
|
-
}),
|
|
78
|
-
[initialSteps, currentSteps]
|
|
79
|
-
);
|
|
80
|
-
const activeStep = getActiveStep(steps, activeStepIndex);
|
|
81
|
-
|
|
82
|
-
const goToNextStep = React.useCallback(() => onNext(steps), [onNext, steps]);
|
|
83
|
-
const goToPrevStep = React.useCallback(() => onBack(steps), [onBack, steps]);
|
|
73
|
+
const close = React.useCallback(() => onClose(null), [onClose]);
|
|
74
|
+
const goToNextStep = React.useCallback(() => onNext(null, steps), [onNext, steps]);
|
|
75
|
+
const goToPrevStep = React.useCallback(() => onBack(null, steps), [onBack, steps]);
|
|
84
76
|
|
|
85
77
|
const footer = React.useMemo(() => {
|
|
86
78
|
const wizardFooter = activeStep?.footer || currentFooter || initialFooter;
|
|
@@ -89,7 +81,7 @@ export const WizardContextProvider: React.FunctionComponent<WizardContextProvide
|
|
|
89
81
|
const customFooter = wizardFooter;
|
|
90
82
|
|
|
91
83
|
return typeof customFooter === 'function'
|
|
92
|
-
? customFooter(activeStep, goToNextStep, goToPrevStep,
|
|
84
|
+
? customFooter(activeStep, goToNextStep, goToPrevStep, close)
|
|
93
85
|
: customFooter;
|
|
94
86
|
}
|
|
95
87
|
|
|
@@ -98,17 +90,17 @@ export const WizardContextProvider: React.FunctionComponent<WizardContextProvide
|
|
|
98
90
|
activeStep={activeStep}
|
|
99
91
|
onNext={goToNextStep}
|
|
100
92
|
onBack={goToPrevStep}
|
|
101
|
-
onClose={
|
|
102
|
-
isBackDisabled={activeStep?.
|
|
93
|
+
onClose={close}
|
|
94
|
+
isBackDisabled={activeStep?.index === 1 || (isWizardSubStep(activeStep) && activeStep?.index === 2)}
|
|
103
95
|
{...wizardFooter}
|
|
104
96
|
/>
|
|
105
97
|
);
|
|
106
|
-
}, [currentFooter, initialFooter, activeStep, goToNextStep, goToPrevStep,
|
|
98
|
+
}, [currentFooter, initialFooter, activeStep, goToNextStep, goToPrevStep, close]);
|
|
107
99
|
|
|
108
100
|
const getStep = React.useCallback((stepId: string | number) => steps.find(step => step.id === stepId), [steps]);
|
|
109
101
|
|
|
110
102
|
const setStep = React.useCallback(
|
|
111
|
-
(step: Pick<
|
|
103
|
+
(step: Pick<WizardStepType, 'id'> & Partial<WizardStepType>) =>
|
|
112
104
|
setCurrentSteps(prevSteps =>
|
|
113
105
|
prevSteps.map(prevStep => {
|
|
114
106
|
if (prevStep.id === step.id) {
|
|
@@ -127,15 +119,18 @@ export const WizardContextProvider: React.FunctionComponent<WizardContextProvide
|
|
|
127
119
|
steps,
|
|
128
120
|
activeStep,
|
|
129
121
|
footer,
|
|
130
|
-
|
|
122
|
+
close,
|
|
131
123
|
getStep,
|
|
132
124
|
setStep,
|
|
125
|
+
goToNextStep,
|
|
126
|
+
goToPrevStep,
|
|
133
127
|
setFooter: setCurrentFooter,
|
|
134
|
-
onNext: goToNextStep,
|
|
135
|
-
onBack: goToPrevStep,
|
|
136
128
|
goToStepById: React.useCallback(id => goToStepById(steps, id), [goToStepById, steps]),
|
|
137
129
|
goToStepByName: React.useCallback(name => goToStepByName(steps, name), [goToStepByName, steps]),
|
|
138
|
-
goToStepByIndex: React.useCallback(index => goToStepByIndex(steps, index), [
|
|
130
|
+
goToStepByIndex: React.useCallback((index: number) => goToStepByIndex(null, steps, index), [
|
|
131
|
+
goToStepByIndex,
|
|
132
|
+
steps
|
|
133
|
+
])
|
|
139
134
|
}}
|
|
140
135
|
>
|
|
141
136
|
{children}
|
|
@@ -4,7 +4,7 @@ import { css } from '@patternfly/react-styles';
|
|
|
4
4
|
import styles from '@patternfly/react-styles/css/components/Wizard/wizard';
|
|
5
5
|
|
|
6
6
|
import { Button, ButtonVariant } from '../../../components/Button';
|
|
7
|
-
import { isCustomWizardFooter,
|
|
7
|
+
import { isCustomWizardFooter, WizardStepType } from './types';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Hosts the standard structure of a footer with ties to the active step so that text for buttons can vary from step to step.
|
|
@@ -12,13 +12,13 @@ import { isCustomWizardFooter, WizardControlStep, WizardNavStepFunction } from '
|
|
|
12
12
|
|
|
13
13
|
export interface WizardFooterProps {
|
|
14
14
|
/** The active step */
|
|
15
|
-
activeStep:
|
|
15
|
+
activeStep: WizardStepType;
|
|
16
16
|
/** Next button callback */
|
|
17
|
-
onNext: () =>
|
|
17
|
+
onNext: (event: React.MouseEvent<HTMLButtonElement>) => void | Promise<void>;
|
|
18
18
|
/** Back button callback */
|
|
19
|
-
onBack: () =>
|
|
19
|
+
onBack: (event: React.MouseEvent<HTMLButtonElement>) => void | Promise<void>;
|
|
20
20
|
/** Cancel link callback */
|
|
21
|
-
onClose: () => void;
|
|
21
|
+
onClose: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
22
22
|
/** Custom text for the Next button. The current step's nextButtonText takes precedence. */
|
|
23
23
|
nextButtonText?: React.ReactNode;
|
|
24
24
|
/** Custom text for the Back button */
|
|
@@ -35,6 +35,10 @@ export interface WizardFooterProps {
|
|
|
35
35
|
isCancelHidden?: boolean;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Applies default wizard footer styling any number of child elements.
|
|
40
|
+
*/
|
|
41
|
+
|
|
38
42
|
interface WizardFooterWrapperProps {
|
|
39
43
|
children: React.ReactNode;
|
|
40
44
|
}
|
|
@@ -44,7 +48,7 @@ export const WizardFooterWrapper = ({ children }: WizardFooterWrapperProps) => (
|
|
|
44
48
|
);
|
|
45
49
|
|
|
46
50
|
export const WizardFooter = ({ activeStep, ...internalProps }: WizardFooterProps) => {
|
|
47
|
-
const activeStepFooter = !isCustomWizardFooter(activeStep
|
|
51
|
+
const activeStepFooter = !isCustomWizardFooter(activeStep?.footer) && activeStep?.footer;
|
|
48
52
|
return <InternalWizardFooter {...internalProps} {...activeStepFooter} />;
|
|
49
53
|
};
|
|
50
54
|
|
|
@@ -7,7 +7,7 @@ import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
|
|
|
7
7
|
|
|
8
8
|
export interface WizardHeaderProps {
|
|
9
9
|
/** Callback function called when the X (Close) button is clicked */
|
|
10
|
-
onClose?: () => void;
|
|
10
|
+
onClose?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
11
11
|
/** Title of the wizard */
|
|
12
12
|
title: string;
|
|
13
13
|
/** Description of the wizard */
|