@patternfly/react-core 4.235.4 → 4.235.7
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 +30 -0
- package/dist/esm/components/DualListSelector/DualListSelectorControl.d.ts.map +1 -1
- package/dist/esm/components/DualListSelector/DualListSelectorControl.js +2 -1
- package/dist/esm/components/DualListSelector/DualListSelectorControl.js.map +1 -1
- package/dist/esm/components/DualListSelector/DualListSelectorControlsWrapper.d.ts.map +1 -1
- package/dist/esm/components/DualListSelector/DualListSelectorControlsWrapper.js +2 -1
- package/dist/esm/components/DualListSelector/DualListSelectorControlsWrapper.js.map +1 -1
- package/dist/esm/components/DualListSelector/DualListSelectorListItem.d.ts.map +1 -1
- package/dist/esm/components/DualListSelector/DualListSelectorListItem.js +2 -1
- package/dist/esm/components/DualListSelector/DualListSelectorListItem.js.map +1 -1
- package/dist/esm/components/DualListSelector/DualListSelectorListWrapper.d.ts.map +1 -1
- package/dist/esm/components/DualListSelector/DualListSelectorListWrapper.js +2 -1
- package/dist/esm/components/DualListSelector/DualListSelectorListWrapper.js.map +1 -1
- package/dist/esm/components/InputGroup/InputGroup.d.ts.map +1 -1
- package/dist/esm/components/InputGroup/InputGroup.js +2 -1
- package/dist/esm/components/InputGroup/InputGroup.js.map +1 -1
- package/dist/esm/components/NumberInput/NumberInput.d.ts +1 -1
- package/dist/esm/components/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/esm/components/NumberInput/NumberInput.js +2 -1
- package/dist/esm/components/NumberInput/NumberInput.js.map +1 -1
- package/dist/esm/components/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/esm/components/SearchInput/SearchInput.js +2 -1
- package/dist/esm/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroup.d.ts.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroup.js +2 -1
- package/dist/esm/components/TextInputGroup/TextInputGroup.js.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -1
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.js +2 -1
- package/dist/esm/components/TextInputGroup/TextInputGroupMain.js.map +1 -1
- package/dist/esm/next/components/Wizard/WizardToggle.d.ts.map +1 -1
- package/dist/esm/next/components/Wizard/WizardToggle.js +32 -31
- package/dist/esm/next/components/Wizard/WizardToggle.js.map +1 -1
- package/dist/js/components/DualListSelector/DualListSelectorControl.d.ts.map +1 -1
- package/dist/js/components/DualListSelector/DualListSelectorControl.js +2 -1
- package/dist/js/components/DualListSelector/DualListSelectorControl.js.map +1 -1
- package/dist/js/components/DualListSelector/DualListSelectorControlsWrapper.d.ts.map +1 -1
- package/dist/js/components/DualListSelector/DualListSelectorControlsWrapper.js +2 -1
- package/dist/js/components/DualListSelector/DualListSelectorControlsWrapper.js.map +1 -1
- package/dist/js/components/DualListSelector/DualListSelectorListItem.d.ts.map +1 -1
- package/dist/js/components/DualListSelector/DualListSelectorListItem.js +2 -1
- package/dist/js/components/DualListSelector/DualListSelectorListItem.js.map +1 -1
- package/dist/js/components/DualListSelector/DualListSelectorListWrapper.d.ts.map +1 -1
- package/dist/js/components/DualListSelector/DualListSelectorListWrapper.js +2 -1
- package/dist/js/components/DualListSelector/DualListSelectorListWrapper.js.map +1 -1
- package/dist/js/components/InputGroup/InputGroup.d.ts.map +1 -1
- package/dist/js/components/InputGroup/InputGroup.js +2 -1
- package/dist/js/components/InputGroup/InputGroup.js.map +1 -1
- package/dist/js/components/NumberInput/NumberInput.d.ts +1 -1
- package/dist/js/components/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/js/components/NumberInput/NumberInput.js +2 -1
- package/dist/js/components/NumberInput/NumberInput.js.map +1 -1
- package/dist/js/components/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/js/components/SearchInput/SearchInput.js +2 -1
- package/dist/js/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroup.d.ts.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroup.js +2 -1
- package/dist/js/components/TextInputGroup/TextInputGroup.js.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -1
- package/dist/js/components/TextInputGroup/TextInputGroupMain.js +2 -1
- package/dist/js/components/TextInputGroup/TextInputGroupMain.js.map +1 -1
- package/dist/js/next/components/Wizard/WizardToggle.d.ts.map +1 -1
- package/dist/js/next/components/Wizard/WizardToggle.js +32 -31
- package/dist/js/next/components/Wizard/WizardToggle.js.map +1 -1
- package/dist/umd/react-core.min.css +2268 -2268
- package/dist/umd/react-core.min.js +2 -2
- package/package.json +5 -5
- package/src/components/DualListSelector/DualListSelectorControl.tsx +2 -1
- package/src/components/DualListSelector/DualListSelectorControlsWrapper.tsx +2 -1
- package/src/components/DualListSelector/DualListSelectorListItem.tsx +2 -1
- package/src/components/DualListSelector/DualListSelectorListWrapper.tsx +2 -1
- package/src/components/InputGroup/InputGroup.tsx +2 -1
- package/src/components/NumberInput/NumberInput.tsx +3 -2
- package/src/components/NumberInput/__tests__/NumberInput.test.tsx +52 -15
- package/src/components/SearchInput/SearchInput.tsx +2 -1
- package/src/components/TextInputGroup/TextInputGroup.tsx +2 -1
- package/src/components/TextInputGroup/TextInputGroupMain.tsx +2 -1
- package/src/next/components/Wizard/WizardToggle.tsx +87 -85
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.235.
|
|
3
|
+
"version": "4.235.7",
|
|
4
4
|
"description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"generate": "node scripts/copyStyles.js"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@patternfly/react-icons": "^4.86.
|
|
48
|
-
"@patternfly/react-styles": "^4.85.
|
|
49
|
-
"@patternfly/react-tokens": "^4.87.
|
|
47
|
+
"@patternfly/react-icons": "^4.86.7",
|
|
48
|
+
"@patternfly/react-styles": "^4.85.7",
|
|
49
|
+
"@patternfly/react-tokens": "^4.87.7",
|
|
50
50
|
"focus-trap": "6.9.2",
|
|
51
51
|
"react-dropzone": "9.0.0",
|
|
52
52
|
"tippy.js": "5.1.2",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"react": "^16.8.0 || ^17.0.0",
|
|
71
71
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "87397c498b2fb5bf5425336fd14da3864dd9334d"
|
|
74
74
|
}
|
|
@@ -37,7 +37,8 @@ export const DualListSelectorControlBase: React.FunctionComponent<DualListSelect
|
|
|
37
37
|
tooltipProps = {} as any,
|
|
38
38
|
...props
|
|
39
39
|
}: DualListSelectorControlProps) => {
|
|
40
|
-
const
|
|
40
|
+
const privateRef = React.useRef(null);
|
|
41
|
+
const ref = innerRef || privateRef;
|
|
41
42
|
return (
|
|
42
43
|
<div className={css('pf-c-dual-list-selector__controls-item', className)} {...props}>
|
|
43
44
|
<Button
|
|
@@ -23,7 +23,8 @@ export const DualListSelectorControlsWrapperBase: React.FunctionComponent<DualLi
|
|
|
23
23
|
'aria-label': ariaLabel = 'Controls for moving options between lists',
|
|
24
24
|
...props
|
|
25
25
|
}: DualListSelectorControlsWrapperProps) => {
|
|
26
|
-
const
|
|
26
|
+
const ref = React.useRef(null);
|
|
27
|
+
const wrapperRef = innerRef || ref;
|
|
27
28
|
// Adds keyboard navigation to the dynamically built dual list selector controls. Works when controls are dynamically built
|
|
28
29
|
// as well as when they are passed in via children.
|
|
29
30
|
const handleKeys = (event: KeyboardEvent) => {
|
|
@@ -47,7 +47,8 @@ export const DualListSelectorListItemBase: React.FunctionComponent<DualListSelec
|
|
|
47
47
|
draggableButtonAriaLabel = 'Reorder option',
|
|
48
48
|
...props
|
|
49
49
|
}: DualListSelectorListItemProps) => {
|
|
50
|
-
const
|
|
50
|
+
const privateRef = React.useRef<HTMLLIElement>(null);
|
|
51
|
+
const ref = innerRef || privateRef;
|
|
51
52
|
const { setFocusedOption } = React.useContext(DualListSelectorListContext);
|
|
52
53
|
|
|
53
54
|
return (
|
|
@@ -42,7 +42,8 @@ export const DualListSelectorListWrapperBase: React.FunctionComponent<DualListSe
|
|
|
42
42
|
...props
|
|
43
43
|
}: DualListSelectorListWrapperProps) => {
|
|
44
44
|
const [focusedOption, setFocusedOption] = React.useState('');
|
|
45
|
-
const
|
|
45
|
+
const ref = React.useRef(null);
|
|
46
|
+
const menuRef = innerRef || ref;
|
|
46
47
|
const { isTree } = React.useContext(DualListSelectorContext);
|
|
47
48
|
|
|
48
49
|
// sets up keyboard focus handling for the dual list selector menu child of the pane. This keyboard
|
|
@@ -25,7 +25,8 @@ export const InputGroup: React.FunctionComponent<InputGroupProps> = ({
|
|
|
25
25
|
(child: any) => !formCtrls.includes(child.type.displayName) && child.props.id
|
|
26
26
|
) as React.ReactElement<{ id: string }>;
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const ref = React.useRef(null);
|
|
29
|
+
const inputGroupRef = innerRef || ref;
|
|
29
30
|
|
|
30
31
|
return (
|
|
31
32
|
<div ref={inputGroupRef} className={css(styles.inputGroup, className)} {...props}>
|
|
@@ -10,7 +10,7 @@ import { TextInput } from '../TextInput';
|
|
|
10
10
|
|
|
11
11
|
export interface NumberInputProps extends React.HTMLProps<HTMLDivElement> {
|
|
12
12
|
/** Value of the number input */
|
|
13
|
-
value?: number;
|
|
13
|
+
value?: number | null;
|
|
14
14
|
/** Additional classes added to the number input */
|
|
15
15
|
className?: string;
|
|
16
16
|
/** Sets the width of the number input to a number of characters */
|
|
@@ -89,6 +89,7 @@ export const NumberInput: React.FunctionComponent<NumberInputProps> = ({
|
|
|
89
89
|
plusBtnProps,
|
|
90
90
|
...props
|
|
91
91
|
}: NumberInputProps) => {
|
|
92
|
+
value = value || 0;
|
|
92
93
|
const numberInputUnit = <div className={css(styles.numberInputUnit)}>{unit}</div>;
|
|
93
94
|
const keyDownHandler =
|
|
94
95
|
inputProps && inputProps.onKeyDown ? inputProps.onKeyDown : defaultKeyDownHandler({ inputName, onMinus, onPlus });
|
|
@@ -128,6 +129,7 @@ export const NumberInput: React.FunctionComponent<NumberInputProps> = ({
|
|
|
128
129
|
</span>
|
|
129
130
|
</Button>
|
|
130
131
|
<TextInput
|
|
132
|
+
{...inputProps}
|
|
131
133
|
type="number"
|
|
132
134
|
value={value}
|
|
133
135
|
name={inputName}
|
|
@@ -138,7 +140,6 @@ export const NumberInput: React.FunctionComponent<NumberInputProps> = ({
|
|
|
138
140
|
{...(!onChange && { isReadOnly: true })}
|
|
139
141
|
onKeyDown={keyDownHandler}
|
|
140
142
|
validated={validated}
|
|
141
|
-
{...inputProps}
|
|
142
143
|
/>
|
|
143
144
|
<Button
|
|
144
145
|
variant="control"
|
|
@@ -10,19 +10,19 @@ describe('numberInput', () => {
|
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
test('renders success validated', () => {
|
|
13
|
-
const { asFragment } = render(<NumberInput validated=
|
|
13
|
+
const { asFragment } = render(<NumberInput validated="success" />);
|
|
14
14
|
expect(asFragment()).toMatchSnapshot();
|
|
15
|
-
})
|
|
15
|
+
});
|
|
16
16
|
|
|
17
17
|
test('renders error validated', () => {
|
|
18
|
-
const { asFragment } = render(<NumberInput validated=
|
|
18
|
+
const { asFragment } = render(<NumberInput validated="error" />);
|
|
19
19
|
expect(asFragment()).toMatchSnapshot();
|
|
20
|
-
})
|
|
20
|
+
});
|
|
21
21
|
|
|
22
22
|
test('renders warning validated', () => {
|
|
23
|
-
const { asFragment } = render(<NumberInput validated=
|
|
23
|
+
const { asFragment } = render(<NumberInput validated="warning" />);
|
|
24
24
|
expect(asFragment()).toMatchSnapshot();
|
|
25
|
-
})
|
|
25
|
+
});
|
|
26
26
|
|
|
27
27
|
test('renders value', () => {
|
|
28
28
|
const { asFragment } = render(<NumberInput value={90} />);
|
|
@@ -136,37 +136,74 @@ describe('numberInput', () => {
|
|
|
136
136
|
|
|
137
137
|
test('removes leading zeros from a positive whole number', () => {
|
|
138
138
|
render(<NumberInput value={10} onChange={() => {}} />);
|
|
139
|
-
|
|
139
|
+
|
|
140
140
|
const input = screen.getByRole('spinbutton');
|
|
141
141
|
userEvent.type(input, '{arrowleft}{arrowleft}0');
|
|
142
142
|
expect(input).toHaveDisplayValue('010');
|
|
143
|
-
|
|
143
|
+
|
|
144
144
|
userEvent.click(document.body);
|
|
145
|
-
|
|
145
|
+
|
|
146
146
|
expect(input).toHaveDisplayValue('10');
|
|
147
147
|
});
|
|
148
148
|
|
|
149
149
|
test('removes leading zeros from a negative whole number', () => {
|
|
150
150
|
render(<NumberInput value={-18} onChange={() => {}} />);
|
|
151
|
-
|
|
151
|
+
|
|
152
152
|
const input = screen.getByRole('spinbutton');
|
|
153
153
|
userEvent.type(input, '{arrowleft}{arrowleft}0');
|
|
154
154
|
expect(input).toHaveDisplayValue('-018');
|
|
155
|
-
|
|
155
|
+
|
|
156
156
|
userEvent.click(document.body);
|
|
157
|
-
|
|
157
|
+
|
|
158
158
|
expect(input).toHaveDisplayValue('-18');
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
test('removes leading zeros from a decimal number', () => {
|
|
162
162
|
render(<NumberInput value={47.01} onChange={() => {}} />);
|
|
163
|
-
|
|
163
|
+
|
|
164
164
|
const input = screen.getByRole('spinbutton');
|
|
165
165
|
userEvent.type(input, '{arrowleft}{arrowleft}{arrowleft}{arrowleft}{arrowleft}0');
|
|
166
166
|
expect(input).toHaveDisplayValue('047.01');
|
|
167
|
-
|
|
167
|
+
|
|
168
168
|
userEvent.click(document.body);
|
|
169
|
-
|
|
169
|
+
|
|
170
170
|
expect(input).toHaveDisplayValue('47.01');
|
|
171
171
|
});
|
|
172
|
+
|
|
173
|
+
test('renders 0 if no value passed', () => {
|
|
174
|
+
render(<NumberInput />);
|
|
175
|
+
const input = screen.getByRole('spinbutton');
|
|
176
|
+
expect(input).toHaveDisplayValue('0');
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test('renders 0 if undefined value passed', () => {
|
|
180
|
+
render(<NumberInput value={undefined} />);
|
|
181
|
+
const input = screen.getByRole('spinbutton');
|
|
182
|
+
expect(input).toHaveDisplayValue('0');
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
test('renders 0 if null value passed', () => {
|
|
186
|
+
render(<NumberInput value={null} />);
|
|
187
|
+
const input = screen.getByRole('spinbutton');
|
|
188
|
+
expect(input).toHaveDisplayValue('0');
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test('does not throw an error if onChange is passed via inputProps as well as the onChange prop', () => {
|
|
192
|
+
const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
193
|
+
|
|
194
|
+
const NumberInputWrapper = () => {
|
|
195
|
+
const [value, setValue] = React.useState(0);
|
|
196
|
+
const onChange = event => setValue(event.currentTarget.value);
|
|
197
|
+
const inputProps = { onChange: onChange };
|
|
198
|
+
|
|
199
|
+
return <NumberInput value={value} onChange={onChange} inputProps={{ ...inputProps }} />;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
render(<NumberInputWrapper />);
|
|
203
|
+
|
|
204
|
+
const input = screen.getByRole('spinbutton');
|
|
205
|
+
userEvent.type(input, '0');
|
|
206
|
+
|
|
207
|
+
expect(consoleSpy).not.toHaveBeenCalled();
|
|
208
|
+
});
|
|
172
209
|
});
|
|
@@ -125,7 +125,8 @@ const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
|
|
|
125
125
|
const [isSearchMenuOpen, setIsSearchMenuOpen] = React.useState(false);
|
|
126
126
|
const [searchValue, setSearchValue] = React.useState(value);
|
|
127
127
|
const searchInputRef = React.useRef(null);
|
|
128
|
-
const
|
|
128
|
+
const ref = React.useRef(null);
|
|
129
|
+
const searchInputInputRef = innerRef || ref;
|
|
129
130
|
|
|
130
131
|
React.useEffect(() => {
|
|
131
132
|
setSearchValue(value);
|
|
@@ -27,7 +27,8 @@ export const TextInputGroup: React.FunctionComponent<TextInputGroupProps> = ({
|
|
|
27
27
|
innerRef,
|
|
28
28
|
...props
|
|
29
29
|
}: TextInputGroupProps) => {
|
|
30
|
-
const
|
|
30
|
+
const ref = React.useRef(null);
|
|
31
|
+
const textInputGroupRef = innerRef || ref;
|
|
31
32
|
|
|
32
33
|
return (
|
|
33
34
|
<TextInputGroupContext.Provider value={{ isDisabled }}>
|
|
@@ -57,7 +57,8 @@ export const TextInputGroupMain: React.FunctionComponent<TextInputGroupMainProps
|
|
|
57
57
|
...props
|
|
58
58
|
}: TextInputGroupMainProps) => {
|
|
59
59
|
const { isDisabled } = React.useContext(TextInputGroupContext);
|
|
60
|
-
const
|
|
60
|
+
const ref = React.useRef(null);
|
|
61
|
+
const textInputGroupInputInputRef = innerRef || ref;
|
|
61
62
|
|
|
62
63
|
const handleChange = (event: React.FormEvent<HTMLInputElement>) => {
|
|
63
64
|
onChange(event.currentTarget.value, event);
|
|
@@ -84,95 +84,97 @@ export const WizardToggle = ({
|
|
|
84
84
|
);
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
const wizardNav =
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
87
|
+
const wizardNav = React.useMemo(() => {
|
|
88
|
+
if (isCustomWizardNav(nav)) {
|
|
89
|
+
return nav(isNavOpen, steps, activeStep, goToStepByIndex);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const props = {
|
|
93
|
+
isOpen: isNavOpen,
|
|
94
|
+
'aria-label': nav?.ariaLabel || 'Wizard nav',
|
|
95
|
+
...(nav?.ariaLabelledBy && { 'aria-labelledby': nav?.ariaLabelledBy })
|
|
96
|
+
};
|
|
95
97
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (activeStep?.id === subStep.id) {
|
|
115
|
-
hasActiveChild = true;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return subStep.navItem ? (
|
|
119
|
-
<React.Fragment key={subStep.id}>{subStep.navItem}</React.Fragment>
|
|
120
|
-
) : (
|
|
121
|
-
<WizardNavItem
|
|
122
|
-
key={subStep.id}
|
|
123
|
-
id={subStep.id}
|
|
124
|
-
content={subStep.name}
|
|
125
|
-
isCurrent={activeStep?.id === subStep.id}
|
|
126
|
-
isDisabled={subStep.isDisabled || (nav?.forceStepVisit && !subStep.visited)}
|
|
127
|
-
step={subStepIndex}
|
|
128
|
-
onNavItemClick={goToStepByIndex}
|
|
129
|
-
/>
|
|
130
|
-
);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
const hasEnabledChildren = React.Children.toArray(subNavItems).some(
|
|
134
|
-
child => React.isValidElement(child) && !child.props.isDisabled
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
return (
|
|
138
|
-
stepNavItem || (
|
|
139
|
-
<WizardNavItem
|
|
140
|
-
key={step.id}
|
|
141
|
-
id={step.id}
|
|
142
|
-
content={step.name}
|
|
143
|
-
isExpandable={nav?.isExpandable}
|
|
144
|
-
isCurrent={hasActiveChild}
|
|
145
|
-
isDisabled={!hasEnabledChildren}
|
|
146
|
-
step={firstSubStepIndex}
|
|
147
|
-
onNavItemClick={goToStepByIndex}
|
|
148
|
-
>
|
|
149
|
-
<WizardNav {...props} returnList>
|
|
150
|
-
{subNavItems}
|
|
151
|
-
</WizardNav>
|
|
152
|
-
</WizardNavItem>
|
|
153
|
-
)
|
|
154
|
-
);
|
|
98
|
+
return (
|
|
99
|
+
<WizardNav {...props}>
|
|
100
|
+
{steps.map((step, index) => {
|
|
101
|
+
const stepIndex = index + 1;
|
|
102
|
+
const stepNavItem = step.navItem && <React.Fragment key={step.id}>{step.navItem}</React.Fragment>;
|
|
103
|
+
|
|
104
|
+
if (isWizardParentStep(step)) {
|
|
105
|
+
let firstSubStepIndex;
|
|
106
|
+
let hasActiveChild = false;
|
|
107
|
+
|
|
108
|
+
const subNavItems = step.subStepIds?.map((subStepId, index) => {
|
|
109
|
+
const subStep = steps.find(step => step.id === subStepId);
|
|
110
|
+
const subStepIndex = steps.indexOf(subStep) + 1;
|
|
111
|
+
|
|
112
|
+
if (index === 0) {
|
|
113
|
+
firstSubStepIndex = subStepIndex;
|
|
155
114
|
}
|
|
156
115
|
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
stepNavItem || (
|
|
160
|
-
<WizardNavItem
|
|
161
|
-
key={step.id}
|
|
162
|
-
id={step.id}
|
|
163
|
-
content={step.name}
|
|
164
|
-
isCurrent={activeStep?.id === step.id}
|
|
165
|
-
isDisabled={step.isDisabled || (nav?.forceStepVisit && !step.visited)}
|
|
166
|
-
step={stepIndex}
|
|
167
|
-
onNavItemClick={goToStepByIndex}
|
|
168
|
-
/>
|
|
169
|
-
)
|
|
170
|
-
);
|
|
116
|
+
if (activeStep?.id === subStep.id) {
|
|
117
|
+
hasActiveChild = true;
|
|
171
118
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
119
|
+
|
|
120
|
+
return subStep.navItem ? (
|
|
121
|
+
<React.Fragment key={subStep.id}>{subStep.navItem}</React.Fragment>
|
|
122
|
+
) : (
|
|
123
|
+
<WizardNavItem
|
|
124
|
+
key={subStep.id}
|
|
125
|
+
id={subStep.id}
|
|
126
|
+
content={subStep.name}
|
|
127
|
+
isCurrent={activeStep?.id === subStep.id}
|
|
128
|
+
isDisabled={subStep.isDisabled || (nav?.forceStepVisit && !subStep.visited)}
|
|
129
|
+
step={subStepIndex}
|
|
130
|
+
onNavItemClick={goToStepByIndex}
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const hasEnabledChildren = React.Children.toArray(subNavItems).some(
|
|
136
|
+
child => React.isValidElement(child) && !child.props.isDisabled
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
stepNavItem || (
|
|
141
|
+
<WizardNavItem
|
|
142
|
+
key={step.id}
|
|
143
|
+
id={step.id}
|
|
144
|
+
content={step.name}
|
|
145
|
+
isExpandable={nav?.isExpandable}
|
|
146
|
+
isCurrent={hasActiveChild}
|
|
147
|
+
isDisabled={!hasEnabledChildren}
|
|
148
|
+
step={firstSubStepIndex}
|
|
149
|
+
onNavItemClick={goToStepByIndex}
|
|
150
|
+
>
|
|
151
|
+
<WizardNav {...props} returnList>
|
|
152
|
+
{subNavItems}
|
|
153
|
+
</WizardNav>
|
|
154
|
+
</WizardNavItem>
|
|
155
|
+
)
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (isWizardBasicStep(step)) {
|
|
160
|
+
return (
|
|
161
|
+
stepNavItem || (
|
|
162
|
+
<WizardNavItem
|
|
163
|
+
key={step.id}
|
|
164
|
+
id={step.id}
|
|
165
|
+
content={step.name}
|
|
166
|
+
isCurrent={activeStep?.id === step.id}
|
|
167
|
+
isDisabled={step.isDisabled || (nav?.forceStepVisit && !step.visited)}
|
|
168
|
+
step={stepIndex}
|
|
169
|
+
onNavItemClick={goToStepByIndex}
|
|
170
|
+
/>
|
|
171
|
+
)
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
})}
|
|
175
|
+
</WizardNav>
|
|
176
|
+
);
|
|
177
|
+
}, [activeStep?.id, goToStepByIndex, isNavOpen, nav, steps]);
|
|
176
178
|
|
|
177
179
|
return (
|
|
178
180
|
<>
|