diff --git a/lib/index.js b/lib/index.js index a0315f0..7c63f68 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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); @@ -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; @@ -487,12 +491,12 @@ 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; @@ -500,20 +504,20 @@ var createWizardItem = function createWizardItem(WizardItemInner, WizardItemWrap //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; \ No newline at end of file diff --git a/package.json b/package.json index f6d61b9..4f6d854 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/src/index.jsx b/src/index.jsx index f2feea9..ba76ae3 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -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) => () => { @@ -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 }; @@ -385,12 +387,12 @@ 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; @@ -398,20 +400,20 @@ const createWizardItem = (WizardItemInner, WizardItemWrapper) => { //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 };