Skip to content

Commit 16bc090

Browse files
supporting react-validation-mixin and fixes #15
1 parent 505754e commit 16bc090

File tree

11 files changed

+23935
-235
lines changed

11 files changed

+23935
-235
lines changed

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
is a multi-step, wizard component for sequential data collection. It basically lets you throw a bunch of react components at it (data forms, text / html components etc) and it will take the user through those components in steps. If it's a data-entry form it can tigger validation and only proceed if the data is valid.
33

44

5-
#### :tada::tada: whats new: react stepzilla now supports Pure Components!!! (as of v4.2.0) :tada::tada:
5+
:tada::tada::tada::tada::tada::tada::tada:
6+
#### whats new:
7+
- ... now supporting higer order component based validation via react-validation-mixin!!! (as of v4.3.0)
8+
- ... now supporting pure, dumb components!!! (as of v4.2.0)
9+
10+
:tada::tada::tada::tada::tada::tada::tada:
611

712

813
### what does it do?
@@ -74,6 +79,9 @@ startAtStep: [stepIndex]
7479
// specify what the Next button text should be in the step before the last (This is usually the last "Actionable" step. You can use this option to change the Next button to say Save - if you save the form data collected in previous steps)
7580
nextTextOnFinalActionStep: "Save"
7681
82+
// its recommended that you use basic javascript validation (i.e simple validation implemented inside your step component. But stepzilla steps can also use 'react-validation-mixin' which wraps your steps as higher order components. If you use this then you need to specify those steps indexes that use 'react-validation-mixin' below in this array)
83+
hocValidationAppliedTo: [1, 2]
84+
7785
```
7886

7987
example options usage:

dist/main.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,11 @@ var StepZilla = function (_Component) {
291291
if (this.props.dontValidate) {
292292
proceed = true;
293293
} else {
294-
// if its a form component, it should have implemeted a public isValidated class (also pure componenets wont even have refs - i.e. a empty object). If not then continue
295-
if (Object.keys(this.refs).length == 0 || typeof this.refs.activeComponent.isValidated == 'undefined') {
294+
if (this.props.hocValidationAppliedTo.length > 0 && this.props.hocValidationAppliedTo.indexOf(this.state.compState) > -1) {
295+
// the user is using a higer order component (HOC) for validation (e.g react-validation-mixin), this wraps the StepZilla steps as a HOC, so use hocValidationAppliedTo to determine if this step needs the aync validation as per react-validation-mixin interface
296+
proceed = this.refs.activeComponent.refs.component.isValidated();
297+
} else if (Object.keys(this.refs).length == 0 || typeof this.refs.activeComponent.isValidated == 'undefined') {
298+
// if its a form component, it should have implemeted a public isValidated class (also pure componenets wont even have refs - i.e. a empty object). If not then continue
296299
proceed = true;
297300
} else if (skipValidationExecution) {
298301
// we are moving backwards in steps, in this case dont validate as it means the user is not commiting to "save"
@@ -431,5 +434,6 @@ StepZilla.defaultProps = {
431434
dontValidate: false,
432435
preventEnterSubmission: false,
433436
startAtStep: 0,
434-
nextTextOnFinalActionStep: "Next"
437+
nextTextOnFinalActionStep: "Next",
438+
hocValidationAppliedTo: []
435439
};

0 commit comments

Comments
 (0)