Skip to content

Commit

Permalink
fix import prop-types
Browse files Browse the repository at this point in the history
  • Loading branch information
smanousopoulos committed Oct 20, 2017
1 parent 27ab4f1 commit 284fd5a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 56 deletions.
58 changes: 31 additions & 27 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _reactAddonsShallowCompare = require('react-addons-shallow-compare');

var _reactAddonsShallowCompare2 = _interopRequireDefault(_reactAddonsShallowCompare);
Expand Down Expand Up @@ -415,13 +419,13 @@ var createWizard = function createWizard() {
};

Wizard.propTypes = {
onComplete: _react2.default.PropTypes.func, //onComplete callback function to execute
promiseOnNext: _react2.default.PropTypes.bool, //option to return promise in onNextClicked function
validateLive: _react2.default.PropTypes.bool, //option to validate on user-input, otherwise only on next
initialActive: _react2.default.PropTypes.string, // pass step id to start from step other than first.
initialValues: _react2.default.PropTypes.object, // alternative way to pass initialValues for children
childrenProps: _react2.default.PropTypes.object, //pass extra properties to all children
children: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.arrayOf(_react2.default.PropTypes.element), _react2.default.PropTypes.object]).isRequired
onComplete: _propTypes2.default.func, //onComplete callback function to execute
promiseOnNext: _propTypes2.default.bool, //option to return promise in onNextClicked function
validateLive: _propTypes2.default.bool, //option to validate on user-input, otherwise only on next
initialActive: _propTypes2.default.string, // pass step id to start from step other than first.
initialValues: _propTypes2.default.object, // alternative way to pass initialValues for children
childrenProps: _propTypes2.default.object, //pass extra properties to all children
children: _propTypes2.default.oneOfType([_propTypes2.default.arrayOf(_propTypes2.default.element), _propTypes2.default.object]).isRequired
};

return Wizard;
Expand Down Expand Up @@ -487,33 +491,33 @@ var createWizardItem = function createWizardItem(WizardItemInner, WizardItemWrap
;

WizardItem.propTypes = {
id: _react2.default.PropTypes.string.isRequired, // id is required
title: _react2.default.PropTypes.string,
description: _react2.default.PropTypes.string,
initialValue: _react2.default.PropTypes.any, //initialValue defines return value expected type
validate: _react2.default.PropTypes.func, // ex. value => !value ? throw 'Error' : null
next: _react2.default.PropTypes.func // ex. value => value == 1 ? 'id1' : 'id2'
id: _propTypes2.default.string.isRequired, // id is required
title: _propTypes2.default.string,
description: _propTypes2.default.string,
initialValue: _propTypes2.default.any, //initialValue defines return value expected type
validate: _propTypes2.default.func, // ex. value => !value ? throw 'Error' : null
next: _propTypes2.default.func // ex. value => value == 1 ? 'id1' : 'id2'
};

return WizardItem;
};

//provided to render wrapper (if provided) and each component
var renderPropTypes = {
onNextClicked: _react2.default.PropTypes.func, //next click handler
onPreviousClicked: _react2.default.PropTypes.func, //previous clicked handler
onComplete: _react2.default.PropTypes.func, //on complete handler with values object, ex. values => handleValues(values)
reset: _react2.default.PropTypes.func, //reset handler
setValue: _react2.default.PropTypes.func, //the callback function to set the wizard item value, ex. () => setValue('check'), or setValue([1,2,3]), or setValue({a:1, b:2})
value: _react2.default.PropTypes.any, //the value set by setValue (initially initialValue)
values: _react2.default.PropTypes.object, //the cleared wizard values as a dict with wizard items ids as keys, ex. {'step1': 'check', 'step2': [1,2,3]},
errors: _react2.default.PropTypes.string, //any validation errors
completed: _react2.default.PropTypes.bool, //wizard completed
step: _react2.default.PropTypes.number, // the wizard step based on how many next clicked
isActive: _react2.default.PropTypes.bool, //is wizard item active (by default only active is displayed)
isLast: _react2.default.PropTypes.bool, //is last wizard item
hasNext: _react2.default.PropTypes.bool, //wizard item has next
hasPrevious: _react2.default.PropTypes.bool //wizard item has previous
onNextClicked: _propTypes2.default.func, //next click handler
onPreviousClicked: _propTypes2.default.func, //previous clicked handler
onComplete: _propTypes2.default.func, //on complete handler with values object, ex. values => handleValues(values)
reset: _propTypes2.default.func, //reset handler
setValue: _propTypes2.default.func, //the callback function to set the wizard item value, ex. () => setValue('check'), or setValue([1,2,3]), or setValue({a:1, b:2})
value: _propTypes2.default.any, //the value set by setValue (initially initialValue)
values: _propTypes2.default.object, //the cleared wizard values as a dict with wizard items ids as keys, ex. {'step1': 'check', 'step2': [1,2,3]},
errors: _propTypes2.default.string, //any validation errors
completed: _propTypes2.default.bool, //wizard completed
step: _propTypes2.default.number, // the wizard step based on how many next clicked
isActive: _propTypes2.default.bool, //is wizard item active (by default only active is displayed)
isLast: _propTypes2.default.bool, //is last wizard item
hasNext: _propTypes2.default.bool, //wizard item has next
hasPrevious: _propTypes2.default.bool //wizard item has previous
};

module.exports = createWizard;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"webpack-dev-server": "^2.4.5"
},
"dependencies": {
"prop-types": "^15.6.0",
"react": "^15.0.0",
"react-addons-shallow-compare": "^15.3.2"
},
Expand Down
60 changes: 31 additions & 29 deletions src/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';
import shallowCompare from 'react-addons-shallow-compare';


import { filterObjByKeys } from './utils';

const defaultNext = (children, idx) => () => {
Expand Down Expand Up @@ -316,15 +318,15 @@ const createWizard = (WizardItemWrapper=null) => {
};

Wizard.propTypes = {
onComplete: React.PropTypes.func, //onComplete callback function to execute
promiseOnNext: React.PropTypes.bool, //option to return promise in onNextClicked function
validateLive: React.PropTypes.bool, //option to validate on user-input, otherwise only on next
initialActive: React.PropTypes.string, // pass step id to start from step other than first.
initialValues: React.PropTypes.object, // alternative way to pass initialValues for children
childrenProps: React.PropTypes.object, //pass extra properties to all children
children: React.PropTypes.oneOfType([
React.PropTypes.arrayOf(React.PropTypes.element),
React.PropTypes.object
onComplete: PropTypes.func, //onComplete callback function to execute
promiseOnNext: PropTypes.bool, //option to return promise in onNextClicked function
validateLive: PropTypes.bool, //option to validate on user-input, otherwise only on next
initialActive: PropTypes.string, // pass step id to start from step other than first.
initialValues: PropTypes.object, // alternative way to pass initialValues for children
childrenProps: PropTypes.object, //pass extra properties to all children
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.element),
PropTypes.object
]).isRequired
};

Expand Down Expand Up @@ -385,33 +387,33 @@ const createWizardItem = (WizardItemInner, WizardItemWrapper) => {
};

WizardItem.propTypes = {
id: React.PropTypes.string.isRequired, // id is required
title: React.PropTypes.string,
description: React.PropTypes.string,
initialValue: React.PropTypes.any, //initialValue defines return value expected type
validate: React.PropTypes.func, // ex. value => !value ? throw 'Error' : null
next: React.PropTypes.func, // ex. value => value == 1 ? 'id1' : 'id2'
id: PropTypes.string.isRequired, // id is required
title: PropTypes.string,
description: PropTypes.string,
initialValue: PropTypes.any, //initialValue defines return value expected type
validate: PropTypes.func, // ex. value => !value ? throw 'Error' : null
next: PropTypes.func, // ex. value => value == 1 ? 'id1' : 'id2'
};

return WizardItem;
}

//provided to render wrapper (if provided) and each component
const renderPropTypes = {
onNextClicked: React.PropTypes.func, //next click handler
onPreviousClicked: React.PropTypes.func, //previous clicked handler
onComplete: React.PropTypes.func, //on complete handler with values object, ex. values => handleValues(values)
reset: React.PropTypes.func, //reset handler
setValue: React.PropTypes.func, //the callback function to set the wizard item value, ex. () => setValue('check'), or setValue([1,2,3]), or setValue({a:1, b:2})
value: React.PropTypes.any, //the value set by setValue (initially initialValue)
values: React.PropTypes.object, //the cleared wizard values as a dict with wizard items ids as keys, ex. {'step1': 'check', 'step2': [1,2,3]},
errors: React.PropTypes.string, //any validation errors
completed: React.PropTypes.bool, //wizard completed
step: React.PropTypes.number, // the wizard step based on how many next clicked
isActive: React.PropTypes.bool, //is wizard item active (by default only active is displayed)
isLast: React.PropTypes.bool, //is last wizard item
hasNext: React.PropTypes.bool, //wizard item has next
hasPrevious: React.PropTypes.bool, //wizard item has previous
onNextClicked: PropTypes.func, //next click handler
onPreviousClicked: PropTypes.func, //previous clicked handler
onComplete: PropTypes.func, //on complete handler with values object, ex. values => handleValues(values)
reset: PropTypes.func, //reset handler
setValue: PropTypes.func, //the callback function to set the wizard item value, ex. () => setValue('check'), or setValue([1,2,3]), or setValue({a:1, b:2})
value: PropTypes.any, //the value set by setValue (initially initialValue)
values: PropTypes.object, //the cleared wizard values as a dict with wizard items ids as keys, ex. {'step1': 'check', 'step2': [1,2,3]},
errors: PropTypes.string, //any validation errors
completed: PropTypes.bool, //wizard completed
step: PropTypes.number, // the wizard step based on how many next clicked
isActive: PropTypes.bool, //is wizard item active (by default only active is displayed)
isLast: PropTypes.bool, //is last wizard item
hasNext: PropTypes.bool, //wizard item has next
hasPrevious: PropTypes.bool, //wizard item has previous
};


Expand Down

0 comments on commit 284fd5a

Please sign in to comment.