Skip to content

Commit

Permalink
fixed: support for passing 'title' prop added to inline mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Srdjan committed Feb 12, 2023
1 parent 8626b25 commit ee3b823
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 161 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Step:
There are two ways to configure Multistep, with external array:

(* **this is the old way, which is `deprecated` and will be removed in the next major version**)

```javascript
const steps = [
{title: 'StepOne', component: <StepOne/>},
Expand All @@ -60,14 +61,14 @@ const steps = [
<Multistep activeStep={1} showNavigation={true} steps={steps}/>
```

or, inline (to suport disabling moving to the next step if form validation is not passing):
or, inline, to support disabling moving to the next step if form validation is not passing:

```javascript
<Multistep activeStep={1} showNavigation={true}>
<StepOne/>
<StepTwo/>
<StepThree/>
<StepFour/>
<StepOne title: 'StepOne'/>
<StepTwo title: 'StepTwo'/>
<StepThree title: 'StepThree'/>
<StepFour title: 'StepFour'/>
</Multistep>
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"react": "18.2.0"
},
"scripts": {
"build": "tsc && cp -f ./build/** ./example/node_modules/MultiStep/",
"build": "tsc && mkdir -p ./example/node_modules/MultiStep && cp -f ./build/** ./example/node_modules/MultiStep/",
"bundle": "esbuild ./build/index.js \"--define:process.env.NODE_ENV='production'\" --external:react --bundle --format=cjs --loader:.js=jsx --outdir=dist",
"publish": "npm publish ./"
}
Expand Down
152 changes: 0 additions & 152 deletions src/MultiStep.js

This file was deleted.

7 changes: 4 additions & 3 deletions src/MultiStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ const getButtonsState = (indx, length, isValidState) => {
}

export default function MultiStep (props: MultiStepPropsBase) {
const {children} = props
const { children } = props

let stepsArray = props.steps

if (!stepsArray && !children) {
Expand All @@ -135,8 +136,8 @@ export default function MultiStep (props: MultiStepPropsBase) {
})
// for backward compatibility we preserve 'steps' with components array:
steps = childrenWithProps.map(childComponent => (
{
title: childComponent.title,
{
title: childComponent.props.title,
component: childComponent
})
)
Expand Down

0 comments on commit ee3b823

Please sign in to comment.