@@ -173,37 +173,36 @@ You can also customize the progress stepper by passing a custom component in the
173
173
``` tsx
174
174
import React from ' react' ;
175
175
import { Create , TextInput , required } from ' react-admin' ;
176
- import { WizardForm , WizardForm . Step } from ' @react-admin/ra-form-layout' ;
176
+ import { WizardForm , WizardFormProgressProps , useWizardFormContext } from ' @react-admin/ra-form-layout' ;
177
177
178
- const MyProgress = ({ currentStep , onStepClick , steps } ) => (
179
- < ul >
180
- { steps . map (( step , index ) => {
181
- const label = React . cloneElement ( step , { intent: ' label ' });
182
-
183
- return (
184
- < li key = { ` step_${ index } ` } >
185
- { ! onStepClick ? (
178
+ const MyProgress = (props : WizardFormProgressProps ) => {
179
+ const { currentStep, steps } = useWizardFormContext ( props );
180
+ return (
181
+ < ul >
182
+ { steps . map (( step , index ) => {
183
+ const label = React . cloneElement ( step , { intent: ' label ' });
184
+ return (
185
+ < li key = { ` step_${ index } ` } >
186
186
<span
187
- className = {
188
- currentStep === index ? ' active' : undefined
189
- }
187
+ style = { {
188
+ textDecoration:
189
+ currentStep === index
190
+ ? ' underline'
191
+ : undefined ,
192
+ }}
190
193
>
191
194
{ label }
192
195
</span >
193
- ) : (
194
- <button onClick = { () => onStepClick (index )} >
195
- { label }
196
- </button >
197
- )}
198
- </li >
199
- );
200
- })}
201
- </ul >
202
- );
196
+ </li >
197
+ );
198
+ })}
199
+ </ul >
200
+ );
201
+ };
203
202
204
203
const PostCreate = () => (
205
204
<Create >
206
- <WizardForm progress = { MyProgress } >
205
+ <WizardForm progress = { < MyProgress /> } >
207
206
<WizardForm.Step label = " First step" >
208
207
<TextInput source = " title" validate = { required ()} />
209
208
</WizardForm.Step >
0 commit comments