Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redux-form

Package Overview
Dependencies
Maintainers
1
Versions
236
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-form - npm Package Compare versions

Comparing version 0.0.5 to 0.0.7

.idea/dictionaries/erik.xml

906

dist/react-redux.js

@@ -10,3 +10,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

root["ReduxForm"] = factory(root["React"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_4__) {
})(this, function(__WEBPACK_EXTERNAL_MODULE_6__) {
return /******/ (function(modules) { // webpackBootstrap

@@ -64,12 +64,22 @@ /******/ // The module cache

var _createFormReducer = __webpack_require__(6);
var _createFormReducer = __webpack_require__(3);
var _createFormReducer2 = _interopRequireDefault(_createFormReducer);
var _reduxForm = __webpack_require__(7);
var _reduxForm = __webpack_require__(4);
var _reduxForm2 = _interopRequireDefault(_reduxForm);
var _actions = __webpack_require__(2);
exports['default'] = _reduxForm2['default'];
exports.createFormReducer = _createFormReducer2['default'];
exports.blur = _actions.blur;
exports.change = _actions.change;
exports.initialize = _actions.initialize;
exports.reset = _actions.reset;
exports.touch = _actions.touch;
exports.touchAll = _actions.touchAll;
exports.untouch = _actions.untouch;
exports.untouchAll = _actions.untouchAll;

@@ -83,51 +93,21 @@ /***/ },

exports.__esModule = true;
var CHANGE = 'REDUX_FORM_CHANGE';
var BLUR = 'redux-form/blur';
exports.BLUR = BLUR;
var CHANGE = 'redux-form/change';
exports.CHANGE = CHANGE;
var SHOW_ALL = 'REDUX_FORM_SHOW_ALL';
exports.SHOW_ALL = SHOW_ALL;
var RESET = 'REDUX_FORM_RESET';
var INITIALIZE = 'redux-form/initialize';
exports.INITIALIZE = INITIALIZE;
var RESET = 'redux-form/reset';
exports.RESET = RESET;
var TOUCH = 'redux-form/touch';
exports.TOUCH = TOUCH;
var TOUCH_ALL = 'redux-form/touch-all';
exports.TOUCH_ALL = TOUCH_ALL;
var UNTOUCH = 'redux-form/untouch';
exports.UNTOUCH = UNTOUCH;
var UNTOUCH_ALL = 'redux-form/untouch-all';
exports.UNTOUCH_ALL = UNTOUCH_ALL;
/***/ },
/* 2 */
/***/ function(module, exports) {
"use strict";
exports.__esModule = true;
exports["default"] = createStoreShape;
function createStoreShape(PropTypes) {
return PropTypes.shape({
subscribe: PropTypes.func.isRequired,
dispatch: PropTypes.func.isRequired,
getState: PropTypes.func.isRequired
});
}
module.exports = exports["default"];
/***/ },
/* 3 */
/***/ function(module, exports) {
'use strict';
exports.__esModule = true;
exports['default'] = getDisplayName;
function getDisplayName(Component) {
return Component.displayName || Component.name || 'Component';
}
module.exports = exports['default'];
/***/ },
/* 4 */
/***/ function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_4__;
/***/ },
/* 5 */
/***/ function(module, exports, __webpack_require__) {

@@ -138,8 +118,22 @@

exports.__esModule = true;
exports.blur = blur;
exports.change = change;
exports.showAll = showAll;
exports.initialize = initialize;
exports.reset = reset;
exports.touch = touch;
exports.touchAll = touchAll;
exports.untouch = untouch;
exports.untouchAll = untouchAll;
var _actionTypes = __webpack_require__(1);
function blur(form, field, value) {
return {
type: _actionTypes.BLUR,
form: form,
field: field,
value: value
};
}
function change(form, field, value) {

@@ -154,6 +148,7 @@ return {

function showAll(form) {
function initialize(form, data) {
return {
type: _actionTypes.SHOW_ALL,
form: form
type: _actionTypes.INITIALIZE,
form: form,
data: data
};

@@ -169,4 +164,42 @@ }

function touch(form) {
for (var _len = arguments.length, fields = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
fields[_key - 1] = arguments[_key];
}
return {
type: _actionTypes.TOUCH,
form: form,
fields: fields
};
}
function touchAll(form) {
return {
type: _actionTypes.TOUCH_ALL,
form: form
};
}
function untouch(form) {
for (var _len2 = arguments.length, fields = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
fields[_key2 - 1] = arguments[_key2];
}
return {
type: _actionTypes.UNTOUCH,
form: form,
fields: fields
};
}
function untouchAll(form) {
return {
type: _actionTypes.UNTOUCH_ALL,
form: form
};
}
/***/ },
/* 6 */
/* 3 */
/***/ function(module, exports, __webpack_require__) {

@@ -187,2 +220,6 @@

* {
* initial: {
* field1: 'value1',
* field2: 'value2'
* },
* data: {

@@ -192,3 +229,3 @@ * field1: 'value1',

* },
* visited: {
* touched: {
* field1: true,

@@ -199,7 +236,8 @@ * field2: false

*
* A field has been "visited" if its value has been updated since the creation of the reducer.
*
* @param name the name of the "state slice" where the data is stored
* @param fields an array of field names, used when showing all values
* @param initialData initial data to populate the state with
* @param config {
* touchOnBlur: [defaults to true],
* touchOnChange: [defaults to false]
* }
* @returns {Function} a form reducer

@@ -209,9 +247,13 @@ */

function createFormReducer(name, fields) {
var initialData = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var _ref = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var initialState = { data: initialData, visited: {} };
var _ref$touchOnBlur = _ref.touchOnBlur;
var touchOnBlur = _ref$touchOnBlur === undefined ? true : _ref$touchOnBlur;
var _ref$touchOnChange = _ref.touchOnChange;
var touchOnChange = _ref$touchOnChange === undefined ? false : _ref$touchOnChange;
return function () {
var state = arguments.length <= 0 || arguments[0] === undefined ? initialState : arguments[0];
var state = arguments.length <= 0 || arguments[0] === undefined ? { initial: {}, data: {}, touched: {} } : arguments[0];
var _extends2, _extends3;
var _extends2, _extends4;

@@ -224,18 +266,68 @@ var action = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

switch (action.type) {
case _actionTypes.BLUR:
var blurDiff = {
data: _extends({}, state.data, (_extends2 = {}, _extends2[action.field] = action.value, _extends2))
};
if (touchOnBlur) {
var _extends3;
blurDiff.touched = _extends({}, state.touched, (_extends3 = {}, _extends3[action.field] = true, _extends3));
}
return _extends({}, state, blurDiff);
case _actionTypes.CHANGE:
var data = _extends({}, state.data, (_extends2 = {}, _extends2[action.field] = action.value, _extends2));
var changeDiff = {
data: _extends({}, state.data, (_extends4 = {}, _extends4[action.field] = action.value, _extends4))
};
if (touchOnChange) {
var _extends5;
changeDiff.touched = _extends({}, state.touched, (_extends5 = {}, _extends5[action.field] = true, _extends5));
}
return _extends({}, state, changeDiff);
case _actionTypes.INITIALIZE:
return {
initial: action.data,
data: action.data,
touched: {}
};
case _actionTypes.RESET:
return {
initial: state.initial,
data: state.initial,
touched: {}
};
case _actionTypes.TOUCH:
var touchDiff = {};
action.fields.forEach(function (field) {
if (typeof field !== 'string') {
throw new Error('fields passed to touch() must be strings');
}
touchDiff[field] = true;
});
return _extends({}, state, {
data: data,
visited: _extends({}, state.visited, (_extends3 = {}, _extends3[action.field] = true, _extends3))
touched: _extends({}, state.touched, touchDiff)
});
case _actionTypes.SHOW_ALL:
var visited = {};
fields.forEach(function (key) {
return visited[key] = true;
}); // mark all as visited
case _actionTypes.TOUCH_ALL:
var touchAllDiff = {};
fields.forEach(function (field) {
return touchAllDiff[field] = true;
}); // mark all as touched
return _extends({}, state, {
visited: visited
touched: touchAllDiff
});
case _actionTypes.RESET:
return initialState;
case _actionTypes.UNTOUCH:
var untouchDiff = {};
action.fields.forEach(function (field) {
if (typeof field !== 'string') {
throw new Error('fields passed to untouch() must be strings');
}
untouchDiff[field] = false;
});
return _extends({}, state, {
touched: _extends({}, state.touched, untouchDiff)
});
case _actionTypes.UNTOUCH_ALL:
return _extends({}, state, {
touched: {}
});
default:

@@ -250,3 +342,3 @@ return state;

/***/ },
/* 7 */
/* 4 */
/***/ function(module, exports, __webpack_require__) {

@@ -266,2 +358,4 @@

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

@@ -271,20 +365,20 @@

var _react = __webpack_require__(4);
var _react = __webpack_require__(6);
var _react2 = _interopRequireDefault(_react);
var _reactRedux = __webpack_require__(13);
var _actions = __webpack_require__(2);
var _actions = __webpack_require__(5);
var _util = __webpack_require__(5);
var getDisplayName = function getDisplayName(Comp) {
return Comp.displayName || Comp.name || 'Component';
};
/**
* @param sliceName The key in the state corresponding to the data in this form
* @param validate A validation function that takes all the data and returns all the errors
* @param validate [optional] A validation function that takes all the data and returns all the errors
*/
function reduxForm(sliceName, validate) {
function reduxForm(sliceName) {
var validate = arguments.length <= 1 || arguments[1] === undefined ? function () {
return {};
} : arguments[1];
return function (DecoratedComponent) {

@@ -295,3 +389,3 @@ return (function (_Component) {

function ReduxForm() {
_classCallCheck(this, _ReduxForm);
_classCallCheck(this, ReduxForm);

@@ -303,8 +397,15 @@ _Component.apply(this, arguments);

var _props = this.props;
var slice = _props.slice;
// eslint-disable-line no-shadow
var form = _props.form;
var sliceName = _props.sliceName;
var dispatch = _props.dispatch;
var passableProps = _extends({}, this.props);
delete passableProps.slice;
delete passableProps.dispatch;
var passableProps = _objectWithoutProperties(_props, ['form', 'sliceName', 'dispatch']);
passableProps.dispatch = dispatch; // we want to allow dispatch through
var handleBlur = function handleBlur(name) {
return function (event) {
return dispatch(_actions.blur(sliceName, name, event.target.value));
};
};
var handleChange = function handleChange(name) {

@@ -315,13 +416,41 @@ return function (event) {

};
var pristine = _util.isPristine(form.initial, form.data);
var errors = validate(form.data);
var valid = !Object.keys(errors).length;
return _react2['default'].createElement(DecoratedComponent, _extends({
data: form.data,
dirty: !pristine,
errors: errors,
handleBlur: handleBlur,
handleChange: handleChange,
showAll: function () {
return dispatch(_actions.showAll(sliceName));
initializeForm: function (data) {
return dispatch(_actions.initialize(sliceName, data));
},
reset: function () {
invalid: !valid,
pristine: pristine,
resetForm: function () {
return dispatch(_actions.reset(sliceName));
},
errors: validate(slice.data),
data: slice.data,
visited: slice.visited
touch: function () {
for (var _len = arguments.length, fields = Array(_len), _key = 0; _key < _len; _key++) {
fields[_key] = arguments[_key];
}
return dispatch(_actions.touch.apply(undefined, [sliceName].concat(fields)));
},
touched: form.touched,
touchAll: function () {
return dispatch(_actions.touchAll(sliceName));
},
untouch: function () {
for (var _len2 = arguments.length, fields = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
fields[_key2] = arguments[_key2];
}
return dispatch(_actions.untouch.apply(undefined, [sliceName].concat(fields)));
},
untouchAll: function () {
return dispatch(_actions.untouchAll(sliceName));
},
valid: valid
}, passableProps)); // pass other props

@@ -332,3 +461,3 @@ };

key: 'displayName',
value: 'ReduxForm(' + getDisplayName(DecoratedComponent) + ')',
value: 'ReduxForm(' + _util.getDisplayName(DecoratedComponent) + ')',
enumerable: true

@@ -342,14 +471,15 @@ }, {

value: {
slice: _react.PropTypes.object,
sliceName: _react.PropTypes.string,
form: _react.PropTypes.object.isRequired,
dispatch: _react.PropTypes.func.isRequired
},
enumerable: true
}, {
key: 'defaultProps',
value: {
sliceName: sliceName
},
enumerable: true
}]);
var _ReduxForm = ReduxForm;
ReduxForm = _reactRedux.connect(function (state) {
return {
slice: state[sliceName]
};
})(ReduxForm) || ReduxForm;
return ReduxForm;

@@ -363,432 +493,3 @@ })(_react.Component);

/***/ },
/* 8 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
exports['default'] = createAll;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _createProvider = __webpack_require__(12);
var _createProvider2 = _interopRequireDefault(_createProvider);
var _createProvideDecorator = __webpack_require__(11);
var _createProvideDecorator2 = _interopRequireDefault(_createProvideDecorator);
var _createConnector = __webpack_require__(10);
var _createConnector2 = _interopRequireDefault(_createConnector);
var _createConnectDecorator = __webpack_require__(9);
var _createConnectDecorator2 = _interopRequireDefault(_createConnectDecorator);
function createAll(React) {
// Wrapper components
var Provider = _createProvider2['default'](React);
var Connector = _createConnector2['default'](React);
// Higher-order components (decorators)
var provide = _createProvideDecorator2['default'](React, Provider);
var connect = _createConnectDecorator2['default'](React, Connector);
return { Provider: Provider, Connector: Connector, provide: provide, connect: connect };
}
module.exports = exports['default'];
/***/ },
/* 9 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
exports['default'] = createConnectDecorator;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _utilsGetDisplayName = __webpack_require__(3);
var _utilsGetDisplayName2 = _interopRequireDefault(_utilsGetDisplayName);
var _utilsShallowEqualScalar = __webpack_require__(16);
var _utilsShallowEqualScalar2 = _interopRequireDefault(_utilsShallowEqualScalar);
function createConnectDecorator(React, Connector) {
var Component = React.Component;
return function connect(select) {
return function (DecoratedComponent) {
return (function (_Component) {
function ConnectorDecorator() {
_classCallCheck(this, ConnectorDecorator);
_Component.apply(this, arguments);
}
_inherits(ConnectorDecorator, _Component);
ConnectorDecorator.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
return !_utilsShallowEqualScalar2['default'](this.props, nextProps);
};
ConnectorDecorator.prototype.render = function render() {
var _this = this;
return React.createElement(
Connector,
{ select: function (state) {
return select(state, _this.props);
} },
function (stuff) {
return React.createElement(DecoratedComponent, _extends({}, stuff, _this.props));
}
);
};
_createClass(ConnectorDecorator, null, [{
key: 'displayName',
value: 'Connector(' + _utilsGetDisplayName2['default'](DecoratedComponent) + ')',
enumerable: true
}, {
key: 'DecoratedComponent',
value: DecoratedComponent,
enumerable: true
}]);
return ConnectorDecorator;
})(Component);
};
};
}
module.exports = exports['default'];
/***/ },
/* 10 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
exports['default'] = createConnector;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _utilsCreateStoreShape = __webpack_require__(2);
var _utilsCreateStoreShape2 = _interopRequireDefault(_utilsCreateStoreShape);
var _utilsShallowEqual = __webpack_require__(15);
var _utilsShallowEqual2 = _interopRequireDefault(_utilsShallowEqual);
var _utilsIsPlainObject = __webpack_require__(14);
var _utilsIsPlainObject2 = _interopRequireDefault(_utilsIsPlainObject);
var _invariant = __webpack_require__(17);
var _invariant2 = _interopRequireDefault(_invariant);
function createConnector(React) {
var Component = React.Component;
var PropTypes = React.PropTypes;
var storeShape = _utilsCreateStoreShape2['default'](PropTypes);
return (function (_Component) {
function Connector(props, context) {
_classCallCheck(this, Connector);
_Component.call(this, props, context);
this.state = this.selectState(props, context);
}
_inherits(Connector, _Component);
Connector.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
return !this.isSliceEqual(this.state.slice, nextState.slice) || !_utilsShallowEqual2['default'](this.props, nextProps);
};
Connector.prototype.isSliceEqual = function isSliceEqual(slice, nextSlice) {
var isRefEqual = slice === nextSlice;
if (isRefEqual) {
return true;
} else if (typeof slice !== 'object' || typeof nextSlice !== 'object') {
return isRefEqual;
}
return _utilsShallowEqual2['default'](slice, nextSlice);
};
Connector.prototype.componentDidMount = function componentDidMount() {
this.unsubscribe = this.context.store.subscribe(this.handleChange.bind(this));
this.handleChange();
};
Connector.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if (nextProps.select !== this.props.select) {
// Force the state slice recalculation
this.handleChange(nextProps);
}
};
Connector.prototype.componentWillUnmount = function componentWillUnmount() {
this.unsubscribe();
};
Connector.prototype.handleChange = function handleChange() {
var props = arguments[0] === undefined ? this.props : arguments[0];
var nextState = this.selectState(props, this.context);
if (!this.isSliceEqual(this.state.slice, nextState.slice)) {
this.setState(nextState);
}
};
Connector.prototype.selectState = function selectState(props, context) {
var state = context.store.getState();
var slice = props.select(state);
_invariant2['default'](_utilsIsPlainObject2['default'](slice), 'The return value of `select` prop must be an object. Instead received %s.', slice);
return { slice: slice };
};
Connector.prototype.render = function render() {
var children = this.props.children;
var slice = this.state.slice;
var dispatch = this.context.store.dispatch;
return children(_extends({ dispatch: dispatch }, slice));
};
_createClass(Connector, null, [{
key: 'contextTypes',
value: {
store: storeShape.isRequired
},
enumerable: true
}, {
key: 'propTypes',
value: {
children: PropTypes.func.isRequired,
select: PropTypes.func.isRequired
},
enumerable: true
}, {
key: 'defaultProps',
value: {
select: function select(state) {
return state;
}
},
enumerable: true
}]);
return Connector;
})(Component);
}
module.exports = exports['default'];
/***/ },
/* 11 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
exports['default'] = createProvideDecorator;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _utilsGetDisplayName = __webpack_require__(3);
var _utilsGetDisplayName2 = _interopRequireDefault(_utilsGetDisplayName);
function createProvideDecorator(React, Provider) {
var Component = React.Component;
return function provide(store) {
return function (DecoratedComponent) {
return (function (_Component) {
function ProviderDecorator() {
_classCallCheck(this, ProviderDecorator);
_Component.apply(this, arguments);
}
_inherits(ProviderDecorator, _Component);
ProviderDecorator.prototype.render = function render() {
var _this = this;
return React.createElement(
Provider,
{ store: store },
function () {
return React.createElement(DecoratedComponent, _this.props);
}
);
};
_createClass(ProviderDecorator, null, [{
key: 'displayName',
value: 'Provider(' + _utilsGetDisplayName2['default'](DecoratedComponent) + ')',
enumerable: true
}, {
key: 'DecoratedComponent',
value: DecoratedComponent,
enumerable: true
}]);
return ProviderDecorator;
})(Component);
};
};
}
module.exports = exports['default'];
/***/ },
/* 12 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
exports['default'] = createProvider;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
var _utilsCreateStoreShape = __webpack_require__(2);
var _utilsCreateStoreShape2 = _interopRequireDefault(_utilsCreateStoreShape);
function createProvider(React) {
var Component = React.Component;
var PropTypes = React.PropTypes;
var storeShape = _utilsCreateStoreShape2['default'](PropTypes);
return (function (_Component) {
function Provider(props, context) {
_classCallCheck(this, Provider);
_Component.call(this, props, context);
this.state = { store: props.store };
}
_inherits(Provider, _Component);
Provider.prototype.getChildContext = function getChildContext() {
return { store: this.state.store };
};
Provider.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
var store = this.state.store;
var nextStore = nextProps.store;
if (store !== nextStore) {
var nextReducer = nextStore.getReducer();
store.replaceReducer(nextReducer);
}
};
Provider.prototype.render = function render() {
var children = this.props.children;
return children();
};
_createClass(Provider, null, [{
key: 'childContextTypes',
value: {
store: storeShape.isRequired
},
enumerable: true
}, {
key: 'propTypes',
value: {
children: PropTypes.func.isRequired
},
enumerable: true
}]);
return Provider;
})(Component);
}
module.exports = exports['default'];
/***/ },
/* 13 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _react = __webpack_require__(4);
var _react2 = _interopRequireDefault(_react);
var _componentsCreateAll = __webpack_require__(8);
var _componentsCreateAll2 = _interopRequireDefault(_componentsCreateAll);
var _createAll = _componentsCreateAll2['default'](_react2['default']);
var Provider = _createAll.Provider;
var Connector = _createAll.Connector;
var provide = _createAll.provide;
var connect = _createAll.connect;
exports.Provider = Provider;
exports.Connector = Connector;
exports.provide = provide;
exports.connect = connect;
/***/ },
/* 14 */
/* 5 */
/***/ function(module, exports) {

@@ -799,148 +500,31 @@

exports.__esModule = true;
exports['default'] = isPlainObject;
exports.getDisplayName = getDisplayName;
exports.isPristine = isPristine;
function isPlainObject(obj) {
return obj ? typeof obj === 'object' && Object.getPrototypeOf(obj) === Object.prototype : false;
function getDisplayName(Comp) {
return Comp.displayName || Comp.name || 'Component';
}
module.exports = exports['default'];
/***/ },
/* 15 */
/***/ function(module, exports) {
"use strict";
exports.__esModule = true;
exports["default"] = shallowEqual;
function shallowEqual(objA, objB) {
if (objA === objB) {
function isPristine(initial, data) {
if (initial === data) {
return true;
}
var keysA = Object.keys(objA);
var keysB = Object.keys(objB);
if (keysA.length !== keysB.length) {
return false;
}
// Test for A's keys different from B.
var hasOwn = Object.prototype.hasOwnProperty;
for (var i = 0; i < keysA.length; i++) {
if (!hasOwn.call(objB, keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
var dataKeys = Object.keys(data);
for (var i = 0; i < dataKeys.length; i++) {
var key = dataKeys[i];
var value = data[key];
var initialValue = initial[key];
if ((value || initialValue) && /* allow '' to equate to undefined or null */value !== initialValue) {
return false;
}
}
return true;
}
module.exports = exports["default"];
/***/ },
/* 16 */
/* 6 */
/***/ function(module, exports) {
'use strict';
module.exports = __WEBPACK_EXTERNAL_MODULE_6__;
exports.__esModule = true;
exports['default'] = shallowEqualScalar;
function shallowEqualScalar(objA, objB) {
if (objA === objB) {
return true;
}
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
return false;
}
var keysA = Object.keys(objA);
var keysB = Object.keys(objB);
if (keysA.length !== keysB.length) {
return false;
}
// Test for A's keys different from B.
var hasOwn = Object.prototype.hasOwnProperty;
for (var i = 0; i < keysA.length; i++) {
if (!hasOwn.call(objB, keysA[i])) {
return false;
}
var valA = objA[keysA[i]];
var valB = objB[keysA[i]];
if (valA !== valB || typeof valA === 'object' || typeof valB === 'object') {
return false;
}
}
return true;
}
module.exports = exports['default'];
/***/ },
/* 17 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule invariant
*/
'use strict';
/**
* Use invariant() to assert state which your program assumes to be true.
*
* Provide sprintf-style format (only %s is supported) and arguments
* to provide information about what broke and what you were
* expecting.
*
* The invariant message will be stripped in production, but the invariant
* will remain to ensure logic does not differ in production.
*/
var invariant = function(condition, format, a, b, c, d, e, f) {
if ((undefined) !== 'production') {
if (format === undefined) {
throw new Error('invariant requires an error message argument');
}
}
if (!condition) {
var error;
if (format === undefined) {
error = new Error(
'Minified exception occurred; use the non-minified dev environment ' +
'for the full error message and additional helpful warnings.'
);
} else {
var args = [a, b, c, d, e, f];
var argIndex = 0;
error = new Error(
'Invariant Violation: ' +
format.replace(/%s/g, function() { return args[argIndex++]; })
);
}
error.framesToPop = 1; // we don't care about invariant's own frame
throw error;
}
};
module.exports = invariant;
/***/ }

@@ -947,0 +531,0 @@ /******/ ])

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReduxForm=t(require("react")):e.ReduxForm=t(e.React)}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=r(6),u=n(o),a=r(7),i=n(a);t.default=i.default,t.createFormReducer=u.default},function(e,t){"use strict";t.__esModule=!0;var r="REDUX_FORM_CHANGE";t.CHANGE=r;var n="REDUX_FORM_SHOW_ALL";t.SHOW_ALL=n;var o="REDUX_FORM_RESET";t.RESET=o},function(e,t){"use strict";function r(e){return e.shape({subscribe:e.func.isRequired,dispatch:e.func.isRequired,getState:e.func.isRequired})}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t){"use strict";function r(e){return e.displayName||e.name||"Component"}t.__esModule=!0,t.default=r,e.exports=t.default},function(t,r){t.exports=e},function(e,t,r){"use strict";function n(e,t,r){return{type:a.CHANGE,form:e,field:t,value:r}}function o(e){return{type:a.SHOW_ALL,form:e}}function u(e){return{type:a.RESET,form:e}}t.__esModule=!0,t.change=n,t.showAll=o,t.reset=u;var a=r(1)},function(e,t,r){"use strict";function n(e,t){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],n={data:r,visited:{}};return function(){var r,a,i=arguments.length<=0||void 0===arguments[0]?n:arguments[0],c=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if(c.form!==e)return i;switch(c.type){case u.CHANGE:var s=o({},i.data,(r={},r[c.field]=c.value,r));return o({},i,{data:s,visited:o({},i.visited,(a={},a[c.field]=!0,a))});case u.SHOW_ALL:var l={};return t.forEach(function(e){return l[e]=!0}),o({},i,{visited:l});case u.RESET:return n;default:return i}}}t.__esModule=!0;var o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};t.default=n;var u=r(1);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e,t){return function(r){return function(n){function a(){o(this,y),n.apply(this,arguments)}u(a,n),a.prototype.render=function(){var n=this.props,o=n.slice,u=n.dispatch,a=i({},this.props);delete a.slice,delete a.dispatch;var c=function(t){return function(r){return u(p.change(e,t,r.target.value))}};return l.default.createElement(r,i({handleChange:c,showAll:function(){return u(p.showAll(e))},reset:function(){return u(p.reset(e))},errors:t(o.data),data:o.data,visited:o.visited},a))},c(a,null,[{key:"displayName",value:"ReduxForm("+d(r)+")",enumerable:!0},{key:"DecoratedComponent",value:r,enumerable:!0},{key:"propTypes",value:{slice:s.PropTypes.object,dispatch:s.PropTypes.func.isRequired},enumerable:!0}]);var y=a;return a=f.connect(function(t){return{slice:t[e]}})(a)||a}(s.Component)}}t.__esModule=!0;var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},c=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.default=a;var s=r(4),l=n(s),f=r(13),p=r(5),d=function(e){return e.displayName||e.name||"Component"};e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e){var t=a.default(e),r=l.default(e),n=c.default(e,t),o=p.default(e,r);return{Provider:t,Connector:r,provide:n,connect:o}}t.__esModule=!0,t.default=o;var u=r(12),a=n(u),i=r(11),c=n(i),s=r(10),l=n(s),f=r(9),p=n(f);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function a(e,t){var r=e.Component;return function(n){return function(a){return function(r){function s(){o(this,s),r.apply(this,arguments)}return u(s,r),s.prototype.shouldComponentUpdate=function(e){return!p.default(this.props,e)},s.prototype.render=function(){var r=this;return e.createElement(t,{select:function(e){return n(e,r.props)}},function(t){return e.createElement(a,i({},t,r.props))})},c(s,null,[{key:"displayName",value:"Connector("+l.default(a)+")",enumerable:!0},{key:"DecoratedComponent",value:a,enumerable:!0}]),s}(r)}}}t.__esModule=!0;var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},c=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.default=a;var s=r(3),l=n(s),f=r(16),p=n(f);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function a(e){var t=e.Component,r=e.PropTypes,n=l.default(r);return function(e){function t(r,n){o(this,t),e.call(this,r,n),this.state=this.selectState(r,n)}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){return!this.isSliceEqual(this.state.slice,t.slice)||!p.default(this.props,e)},t.prototype.isSliceEqual=function(e,t){var r=e===t;return r?!0:"object"!=typeof e||"object"!=typeof t?r:p.default(e,t)},t.prototype.componentDidMount=function(){this.unsubscribe=this.context.store.subscribe(this.handleChange.bind(this)),this.handleChange()},t.prototype.componentWillReceiveProps=function(e){e.select!==this.props.select&&this.handleChange(e)},t.prototype.componentWillUnmount=function(){this.unsubscribe()},t.prototype.handleChange=function(){var e=void 0===arguments[0]?this.props:arguments[0],t=this.selectState(e,this.context);this.isSliceEqual(this.state.slice,t.slice)||this.setState(t)},t.prototype.selectState=function(e,t){var r=t.store.getState(),n=e.select(r);return h.default(y.default(n),"The return value of `select` prop must be an object. Instead received %s.",n),{slice:n}},t.prototype.render=function(){var e=this.props.children,t=this.state.slice,r=this.context.store.dispatch;return e(i({dispatch:r},t))},c(t,null,[{key:"contextTypes",value:{store:n.isRequired},enumerable:!0},{key:"propTypes",value:{children:r.func.isRequired,select:r.func.isRequired},enumerable:!0},{key:"defaultProps",value:{select:function(e){return e}},enumerable:!0}]),t}(t)}t.__esModule=!0;var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},c=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.default=a;var s=r(2),l=n(s),f=r(15),p=n(f),d=r(14),y=n(d),v=r(17),h=n(v);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function a(e,t){var r=e.Component;return function(n){return function(a){return function(r){function c(){o(this,c),r.apply(this,arguments)}return u(c,r),c.prototype.render=function(){var r=this;return e.createElement(t,{store:n},function(){return e.createElement(a,r.props)})},i(c,null,[{key:"displayName",value:"Provider("+s.default(a)+")",enumerable:!0},{key:"DecoratedComponent",value:a,enumerable:!0}]),c}(r)}}}t.__esModule=!0;var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.default=a;var c=r(3),s=n(c);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function a(e){var t=e.Component,r=e.PropTypes,n=s.default(r);return function(e){function t(r,n){o(this,t),e.call(this,r,n),this.state={store:r.store}}return u(t,e),t.prototype.getChildContext=function(){return{store:this.state.store}},t.prototype.componentWillReceiveProps=function(e){var t=this.state.store,r=e.store;if(t!==r){var n=r.getReducer();t.replaceReducer(n)}},t.prototype.render=function(){var e=this.props.children;return e()},i(t,null,[{key:"childContextTypes",value:{store:n.isRequired},enumerable:!0},{key:"propTypes",value:{children:r.func.isRequired},enumerable:!0}]),t}(t)}t.__esModule=!0;var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.default=a;var c=r(2),s=n(c);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=r(4),u=n(o),a=r(8),i=n(a),c=i.default(u.default),s=c.Provider,l=c.Connector,f=c.provide,p=c.connect;t.Provider=s,t.Connector=l,t.provide=f,t.connect=p},function(e,t){"use strict";function r(e){return e?"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype:!1}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t){"use strict";function r(e,t){if(e===t)return!0;var r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(var o=Object.prototype.hasOwnProperty,u=0;u<r.length;u++)if(!o.call(t,r[u])||e[r[u]]!==t[r[u]])return!1;return!0}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t){"use strict";function r(e,t){if(e===t)return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(var o=Object.prototype.hasOwnProperty,u=0;u<r.length;u++){if(!o.call(t,r[u]))return!1;var a=e[r[u]],i=t[r[u]];if(a!==i||"object"==typeof a||"object"==typeof i)return!1}return!0}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t,r){"use strict";var n=function(e,t,r,n,o,u,a,i){if(!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=[r,n,o,u,a,i],l=0;c=new Error("Invariant Violation: "+t.replace(/%s/g,function(){return s[l++]}))}throw c.framesToPop=1,c}};e.exports=n}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReduxForm=t(require("react")):e.ReduxForm=t(e.React)}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var u=r[n]={exports:{},id:n,loaded:!1};return e[n].call(u.exports,u,u.exports,t),u.loaded=!0,u.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var u=r(3),o=n(u),a=r(4),i=n(a),c=r(2);t.default=i.default,t.createFormReducer=o.default,t.blur=c.blur,t.change=c.change,t.initialize=c.initialize,t.reset=c.reset,t.touch=c.touch,t.touchAll=c.touchAll,t.untouch=c.untouch,t.untouchAll=c.untouchAll},function(e,t){"use strict";t.__esModule=!0;var r="redux-form/blur";t.BLUR=r;var n="redux-form/change";t.CHANGE=n;var u="redux-form/initialize";t.INITIALIZE=u;var o="redux-form/reset";t.RESET=o;var a="redux-form/touch";t.TOUCH=a;var i="redux-form/touch-all";t.TOUCH_ALL=i;var c="redux-form/untouch";t.UNTOUCH=c;var l="redux-form/untouch-all";t.UNTOUCH_ALL=l},function(e,t,r){"use strict";function n(e,t,r){return{type:s.BLUR,form:e,field:t,value:r}}function u(e,t,r){return{type:s.CHANGE,form:e,field:t,value:r}}function o(e,t){return{type:s.INITIALIZE,form:e,data:t}}function a(e){return{type:s.RESET,form:e}}function i(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;t>n;n++)r[n-1]=arguments[n];return{type:s.TOUCH,form:e,fields:r}}function c(e){return{type:s.TOUCH_ALL,form:e}}function l(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;t>n;n++)r[n-1]=arguments[n];return{type:s.UNTOUCH,form:e,fields:r}}function f(e){return{type:s.UNTOUCH_ALL,form:e}}t.__esModule=!0,t.blur=n,t.change=u,t.initialize=o,t.reset=a,t.touch=i,t.touchAll=c,t.untouch=l,t.untouchAll=f;var s=r(1)},function(e,t,r){"use strict";function n(e,t){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],n=r.touchOnBlur,a=void 0===n?!0:n,i=r.touchOnChange,c=void 0===i?!1:i;return function(){var r,n,i=arguments.length<=0||void 0===arguments[0]?{initial:{},data:{},touched:{}}:arguments[0],l=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if(l.form!==e)return i;switch(l.type){case o.BLUR:var f={data:u({},i.data,(r={},r[l.field]=l.value,r))};if(a){var s;f.touched=u({},i.touched,(s={},s[l.field]=!0,s))}return u({},i,f);case o.CHANGE:var d={data:u({},i.data,(n={},n[l.field]=l.value,n))};if(c){var p;d.touched=u({},i.touched,(p={},p[l.field]=!0,p))}return u({},i,d);case o.INITIALIZE:return{initial:l.data,data:l.data,touched:{}};case o.RESET:return{initial:i.initial,data:i.initial,touched:{}};case o.TOUCH:var h={};return l.fields.forEach(function(e){if("string"!=typeof e)throw new Error("fields passed to touch() must be strings");h[e]=!0}),u({},i,{touched:u({},i.touched,h)});case o.TOUCH_ALL:var m={};return t.forEach(function(e){return m[e]=!0}),u({},i,{touched:m});case o.UNTOUCH:var v={};return l.fields.forEach(function(e){if("string"!=typeof e)throw new Error("fields passed to untouch() must be strings");v[e]=!1}),u({},i,{touched:u({},i.touched,v)});case o.UNTOUCH_ALL:return u({},i,{touched:{}});default:return i}}}t.__esModule=!0;var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};t.default=n;var o=r(1);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function u(e,t){var r={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e){var t=arguments.length<=1||void 0===arguments[1]?function(){return{}}:arguments[1];return function(r){return function(n){function i(){o(this,i),n.apply(this,arguments)}return a(i,n),i.prototype.render=function(){var e=this.props,n=e.form,o=e.sliceName,a=e.dispatch,i=u(e,["form","sliceName","dispatch"]);i.dispatch=a;var l=function(e){return function(t){return a(d.blur(o,e,t.target.value))}},f=function(e){return function(t){return a(d.change(o,e,t.target.value))}},h=p.isPristine(n.initial,n.data),m=t(n.data),v=!Object.keys(m).length;return s.default.createElement(r,c({data:n.data,dirty:!h,errors:m,handleBlur:l,handleChange:f,initializeForm:function(e){return a(d.initialize(o,e))},invalid:!v,pristine:h,resetForm:function(){return a(d.reset(o))},touch:function(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];return a(d.touch.apply(void 0,[o].concat(t)))},touched:n.touched,touchAll:function(){return a(d.touchAll(o))},untouch:function(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];return a(d.untouch.apply(void 0,[o].concat(t)))},untouchAll:function(){return a(d.untouchAll(o))},valid:v},i))},l(i,null,[{key:"displayName",value:"ReduxForm("+p.getDisplayName(r)+")",enumerable:!0},{key:"DecoratedComponent",value:r,enumerable:!0},{key:"propTypes",value:{sliceName:f.PropTypes.string,form:f.PropTypes.object.isRequired,dispatch:f.PropTypes.func.isRequired},enumerable:!0},{key:"defaultProps",value:{sliceName:e},enumerable:!0}]),i}(f.Component)}}t.__esModule=!0;var c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},l=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.default=i;var f=r(6),s=n(f),d=r(2),p=r(5);e.exports=t.default},function(e,t){"use strict";function r(e){return e.displayName||e.name||"Component"}function n(e,t){if(e===t)return!0;for(var r=Object.keys(t),n=0;n<r.length;n++){var u=r[n],o=t[u],a=e[u];if((o||a)&&o!==a)return!1}return!0}t.__esModule=!0,t.getDisplayName=r,t.isPristine=n},function(t,r){t.exports=e}])});
'use strict';
exports.__esModule = true;
exports.blur = blur;
exports.change = change;
exports.showAll = showAll;
exports.initialize = initialize;
exports.reset = reset;
exports.touch = touch;
exports.touchAll = touchAll;
exports.untouch = untouch;
exports.untouchAll = untouchAll;
var _actionTypes = require('./actionTypes');
function blur(form, field, value) {
return {
type: _actionTypes.BLUR,
form: form,
field: field,
value: value
};
}
function change(form, field, value) {

@@ -19,6 +33,7 @@ return {

function showAll(form) {
function initialize(form, data) {
return {
type: _actionTypes.SHOW_ALL,
form: form
type: _actionTypes.INITIALIZE,
form: form,
data: data
};

@@ -32,2 +47,40 @@ }

};
}
function touch(form) {
for (var _len = arguments.length, fields = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
fields[_key - 1] = arguments[_key];
}
return {
type: _actionTypes.TOUCH,
form: form,
fields: fields
};
}
function touchAll(form) {
return {
type: _actionTypes.TOUCH_ALL,
form: form
};
}
function untouch(form) {
for (var _len2 = arguments.length, fields = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
fields[_key2 - 1] = arguments[_key2];
}
return {
type: _actionTypes.UNTOUCH,
form: form,
fields: fields
};
}
function untouchAll(form) {
return {
type: _actionTypes.UNTOUCH_ALL,
form: form
};
}
'use strict';
exports.__esModule = true;
var CHANGE = 'REDUX_FORM_CHANGE';
var BLUR = 'redux-form/blur';
exports.BLUR = BLUR;
var CHANGE = 'redux-form/change';
exports.CHANGE = CHANGE;
var SHOW_ALL = 'REDUX_FORM_SHOW_ALL';
exports.SHOW_ALL = SHOW_ALL;
var RESET = 'REDUX_FORM_RESET';
exports.RESET = RESET;
var INITIALIZE = 'redux-form/initialize';
exports.INITIALIZE = INITIALIZE;
var RESET = 'redux-form/reset';
exports.RESET = RESET;
var TOUCH = 'redux-form/touch';
exports.TOUCH = TOUCH;
var TOUCH_ALL = 'redux-form/touch-all';
exports.TOUCH_ALL = TOUCH_ALL;
var UNTOUCH = 'redux-form/untouch';
exports.UNTOUCH = UNTOUCH;
var UNTOUCH_ALL = 'redux-form/untouch-all';
exports.UNTOUCH_ALL = UNTOUCH_ALL;

@@ -14,2 +14,6 @@ 'use strict';

* {
* initial: {
* field1: 'value1',
* field2: 'value2'
* },
* data: {

@@ -19,3 +23,3 @@ * field1: 'value1',

* },
* visited: {
* touched: {
* field1: true,

@@ -26,7 +30,8 @@ * field2: false

*
* A field has been "visited" if its value has been updated since the creation of the reducer.
*
* @param name the name of the "state slice" where the data is stored
* @param fields an array of field names, used when showing all values
* @param initialData initial data to populate the state with
* @param config {
* touchOnBlur: [defaults to true],
* touchOnChange: [defaults to false]
* }
* @returns {Function} a form reducer

@@ -36,9 +41,13 @@ */

function createFormReducer(name, fields) {
var initialData = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var _ref = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var initialState = { data: initialData, visited: {} };
var _ref$touchOnBlur = _ref.touchOnBlur;
var touchOnBlur = _ref$touchOnBlur === undefined ? true : _ref$touchOnBlur;
var _ref$touchOnChange = _ref.touchOnChange;
var touchOnChange = _ref$touchOnChange === undefined ? false : _ref$touchOnChange;
return function () {
var state = arguments.length <= 0 || arguments[0] === undefined ? initialState : arguments[0];
var state = arguments.length <= 0 || arguments[0] === undefined ? { initial: {}, data: {}, touched: {} } : arguments[0];
var _extends2, _extends3;
var _extends2, _extends4;

@@ -51,18 +60,68 @@ var action = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

switch (action.type) {
case _actionTypes.BLUR:
var blurDiff = {
data: _extends({}, state.data, (_extends2 = {}, _extends2[action.field] = action.value, _extends2))
};
if (touchOnBlur) {
var _extends3;
blurDiff.touched = _extends({}, state.touched, (_extends3 = {}, _extends3[action.field] = true, _extends3));
}
return _extends({}, state, blurDiff);
case _actionTypes.CHANGE:
var data = _extends({}, state.data, (_extends2 = {}, _extends2[action.field] = action.value, _extends2));
var changeDiff = {
data: _extends({}, state.data, (_extends4 = {}, _extends4[action.field] = action.value, _extends4))
};
if (touchOnChange) {
var _extends5;
changeDiff.touched = _extends({}, state.touched, (_extends5 = {}, _extends5[action.field] = true, _extends5));
}
return _extends({}, state, changeDiff);
case _actionTypes.INITIALIZE:
return {
initial: action.data,
data: action.data,
touched: {}
};
case _actionTypes.RESET:
return {
initial: state.initial,
data: state.initial,
touched: {}
};
case _actionTypes.TOUCH:
var touchDiff = {};
action.fields.forEach(function (field) {
if (typeof field !== 'string') {
throw new Error('fields passed to touch() must be strings');
}
touchDiff[field] = true;
});
return _extends({}, state, {
data: data,
visited: _extends({}, state.visited, (_extends3 = {}, _extends3[action.field] = true, _extends3))
touched: _extends({}, state.touched, touchDiff)
});
case _actionTypes.SHOW_ALL:
var visited = {};
fields.forEach(function (key) {
return visited[key] = true;
}); // mark all as visited
case _actionTypes.TOUCH_ALL:
var touchAllDiff = {};
fields.forEach(function (field) {
return touchAllDiff[field] = true;
}); // mark all as touched
return _extends({}, state, {
visited: visited
touched: touchAllDiff
});
case _actionTypes.RESET:
return initialState;
case _actionTypes.UNTOUCH:
var untouchDiff = {};
action.fields.forEach(function (field) {
if (typeof field !== 'string') {
throw new Error('fields passed to untouch() must be strings');
}
untouchDiff[field] = false;
});
return _extends({}, state, {
touched: _extends({}, state.touched, untouchDiff)
});
case _actionTypes.UNTOUCH_ALL:
return _extends({}, state, {
touched: {}
});
default:

@@ -69,0 +128,0 @@ return state;

@@ -15,3 +15,13 @@ 'use strict';

var _actions = require('./actions');
exports['default'] = _reduxForm2['default'];
exports.createFormReducer = _createFormReducer2['default'];
exports.createFormReducer = _createFormReducer2['default'];
exports.blur = _actions.blur;
exports.change = _actions.change;
exports.initialize = _actions.initialize;
exports.reset = _actions.reset;
exports.touch = _actions.touch;
exports.touchAll = _actions.touchAll;
exports.untouch = _actions.untouch;
exports.untouchAll = _actions.untouchAll;

@@ -13,2 +13,4 @@ 'use strict';

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

@@ -22,16 +24,16 @@

var _reactRedux = require('react-redux');
var _actions = require('./actions');
var getDisplayName = function getDisplayName(Comp) {
return Comp.displayName || Comp.name || 'Component';
};
var _util = require('./util');
/**
* @param sliceName The key in the state corresponding to the data in this form
* @param validate A validation function that takes all the data and returns all the errors
* @param validate [optional] A validation function that takes all the data and returns all the errors
*/
function reduxForm(sliceName, validate) {
function reduxForm(sliceName) {
var validate = arguments.length <= 1 || arguments[1] === undefined ? function () {
return {};
} : arguments[1];
return function (DecoratedComponent) {

@@ -42,3 +44,3 @@ return (function (_Component) {

function ReduxForm() {
_classCallCheck(this, _ReduxForm);
_classCallCheck(this, ReduxForm);

@@ -50,8 +52,15 @@ _Component.apply(this, arguments);

var _props = this.props;
var slice = _props.slice;
// eslint-disable-line no-shadow
var form = _props.form;
var sliceName = _props.sliceName;
var dispatch = _props.dispatch;
var passableProps = _extends({}, this.props);
delete passableProps.slice;
delete passableProps.dispatch;
var passableProps = _objectWithoutProperties(_props, ['form', 'sliceName', 'dispatch']);
passableProps.dispatch = dispatch; // we want to allow dispatch through
var handleBlur = function handleBlur(name) {
return function (event) {
return dispatch(_actions.blur(sliceName, name, event.target.value));
};
};
var handleChange = function handleChange(name) {

@@ -62,13 +71,41 @@ return function (event) {

};
var pristine = _util.isPristine(form.initial, form.data);
var errors = validate(form.data);
var valid = !Object.keys(errors).length;
return _react2['default'].createElement(DecoratedComponent, _extends({
data: form.data,
dirty: !pristine,
errors: errors,
handleBlur: handleBlur,
handleChange: handleChange,
showAll: function () {
return dispatch(_actions.showAll(sliceName));
initializeForm: function (data) {
return dispatch(_actions.initialize(sliceName, data));
},
reset: function () {
invalid: !valid,
pristine: pristine,
resetForm: function () {
return dispatch(_actions.reset(sliceName));
},
errors: validate(slice.data),
data: slice.data,
visited: slice.visited
touch: function () {
for (var _len = arguments.length, fields = Array(_len), _key = 0; _key < _len; _key++) {
fields[_key] = arguments[_key];
}
return dispatch(_actions.touch.apply(undefined, [sliceName].concat(fields)));
},
touched: form.touched,
touchAll: function () {
return dispatch(_actions.touchAll(sliceName));
},
untouch: function () {
for (var _len2 = arguments.length, fields = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
fields[_key2] = arguments[_key2];
}
return dispatch(_actions.untouch.apply(undefined, [sliceName].concat(fields)));
},
untouchAll: function () {
return dispatch(_actions.untouchAll(sliceName));
},
valid: valid
}, passableProps)); // pass other props

@@ -79,3 +116,3 @@ };

key: 'displayName',
value: 'ReduxForm(' + getDisplayName(DecoratedComponent) + ')',
value: 'ReduxForm(' + _util.getDisplayName(DecoratedComponent) + ')',
enumerable: true

@@ -89,14 +126,15 @@ }, {

value: {
slice: _react.PropTypes.object,
sliceName: _react.PropTypes.string,
form: _react.PropTypes.object.isRequired,
dispatch: _react.PropTypes.func.isRequired
},
enumerable: true
}, {
key: 'defaultProps',
value: {
sliceName: sliceName
},
enumerable: true
}]);
var _ReduxForm = ReduxForm;
ReduxForm = _reactRedux.connect(function (state) {
return {
slice: state[sliceName]
};
})(ReduxForm) || ReduxForm;
return ReduxForm;

@@ -103,0 +141,0 @@ })(_react.Component);

{
"name": "redux-form",
"version": "0.0.5",
"description": "An ES7 decorator for forms using Redux and React",
"version": "0.0.7",
"description": "A higher order component generator for forms using Redux and React",
"main": "./lib/index.js",

@@ -43,7 +43,3 @@ "repository": {

"webpack": "^1.10.5"
},
"dependencies": {
"react-redux": "^0.2.2",
"redux": "^1.0.0-rc"
}
}
#redux-form
`@reduxForm` is an ES7 decorator to for enabling a form in [React](https://github.com/facebook/react) to use [Redux](https://github.com/gaearon/redux) to store all of
its state.
`redux-form` works with [React Redux](https://github.com/gaearon/react-redux) to enable an html form in [React](https://github.com/facebook/react) to use [Redux](https://github.com/gaearon/redux) to store all of its state.

@@ -44,2 +43,6 @@ ## Installation

`reduxForm()` creates a Higher Order Component that expects a `dispatch` prop and a slice of the Redux store where its data is stored as a `form` prop. These should be provided by [React Redux](https://github.com/gaearon/react-redux)'s `connect()` function.
Let's look at an example:
Then, on your form component, add the `@reduxForm('contacts')` decorator.

@@ -49,13 +52,25 @@

import React, {Component, PropTypes} from 'react';
import {connect} from 'react-redux';
import reduxForm from 'redux-form';
import contactValidation from './contactValidation';
@reduxForm('contacts', contactValidation)
export default class ContactForm extends Component {
class ContactForm extends Component {
// you don't need all to define all these props,
// only the ones you intend to use
static propTypes = {
data: PropTypes.object.isRequired,
dirty: PropTypes.bool.isRequired,
errors: PropTypes.object.isRequired,
handleBlur: PropTypes.func.isRequired,
handleChange: PropTypes.func.isRequired,
showAll: PropTypes.func.isRequired,
reset: PropTypes.func.isRequired
initializeForm: PropTypes.func.isRequired,
invalid: PropTypes.bool.isRequired,
pristine: PropTypes.bool.isRequired,
resetForm: PropTypes.func.isRequired,
touch: PropTypes.func.isRequired,
touched: PropTypes.object.isRequired,
touchAll: PropTypes.func.isRequired,
untouch: PropTypes.func.isRequired,
untouchAll: PropTypes.func.isRequired,
valid: PropTypes.bool.isRequired
}

@@ -67,2 +82,3 @@

errors: {name: nameError, address: addressError, phone: phoneError},
touched: {name: nameTouched, address: addressTouched, phone: phoneTouched},
handleChange

@@ -74,11 +90,11 @@ } = this.props;

<input type="text" value={name} onChange={handleChange('name')}/>
{nameError ? <div>{nameError}</div>}
{nameError && nameTouched ? <div>{nameError}</div>}
<label>Address</label>
<input type="text" value={address} onChange={handleChange('address')}/>
{addressError ? <div>{addressError}</div>}
{addressError && addressTouched ? <div>{addressError}</div>}
<label>Phone</label>
<input type="text" value={phone} onChange={handleChange('phone')}/>
{phoneError ? <div>{phoneError}</div>}
{phoneError && phoneTouched ? <div>{phoneError}</div>}
</form>

@@ -88,9 +104,30 @@ );

}
// ------- HERE'S THE IMPORTANT BIT -------
function mapStateToProps(state) {
return { form: state.contacts };
}
export default
connect(mapStateToProps)
(reduxForm('contacts', contactValidation)
(ContactForm))
```
Notice that we're just using vanilla `<input>` elements there is no state in the `ContactForm` component. I have left handling `onSubmit` as an excercise for the reader. Hint: your data is in `this.props.data`.
Notice that we're just using vanilla `<input>` elements there is no state in the `ContactForm` component. I have left handling `onSubmit` as an exercise for the reader. Hint: your data is in `this.props.data`.
### ES7 Decorator Sugar
Using ES7 decorators, the example above could be written as:
```javascript
@connect(state => ({ form: state.contacts }))
@reduxForm('contacts', contactValidation)
export default class ContactForm extends Component {
```
Much nicer, don't you think?
## Validation
You will need to supply your own validation function, which is in the form `({}) => {}` and takes in all your data and spits out error messages. For example:
You may optionally supply a validation function, which is in the form `({}) => {}` and takes in all your data and spits out error messages. For example:

@@ -120,3 +157,3 @@ ```javascript

### createFormReducer(sliceName:string, fields:Array&lt;string&gt;, initialData:Object)
### createFormReducer(sliceName:string, fields:Array&lt;string&gt;, config:Object)

@@ -131,6 +168,14 @@ ##### -`sliceName` : string

##### - initialData: Object
##### - config: Object [optional]
> initial data to populate the state with
> some control over when to mark fields as "touched" in the form:
###### config.touchOnBlur : boolean [optional]
> marks fields to touched when the blur action is fired. defaults to `true`
###### config.touchOnChange : boolean [optional]
> marks fields to touched when the change action is fired. defaults to `false`
### @reduxForm(sliceName:string, validate:Function)

@@ -142,3 +187,3 @@

##### - validation : Function
##### - validation : Function [optional]

@@ -151,26 +196,63 @@ > your [validation function](#validation)

##### -`data:Object`
> The form data, in the form `{ field1: <string>, field2: <string> }`
##### -`dirty:boolean`
> `true` if the form data has changed from its initialized values. Opposite of `pristine`.
##### -`errors:Object`
> All the errors, in the form `{ field1: <string>, field2: <string> }`
##### -`handleBlur(field:string) : Function`
> Returns a `handleBlur` function for the field passed.
##### -`handleChange(field:string) : Function`
> returns a `handleChange` function for the field passed.
> Returns a `handleChange` function for the field passed.
##### -`showAll() : Function`
##### -`initializeForm(data:Object) : Function`
> marks all fields as "visited" to show errors. should be called on form submission.
> Initializes the form data to the given values. All `dirty` and `pristine` state will be determined by comparing the current data with these initialized values.
##### -`reset() : Function`
##### -`invalid:boolean`
> clears all the values in the form
> `true` if the form has validation errors. Opposite of `valid`.
##### -`data:Object`
##### -`pristine:boolean`
> the form data, in the form `{ field1: <string>, field2: <string> }`
> `true` if the form data is the same as its initialized values. Opposite of `dirty`.
##### -`errors:Object`
##### -`resetForm() : Function`
> all the errors, in the form `{ field1: <string>, field2: <string> }`
> Resets all the values in the form to the initialized state, making it pristine again.
##### -`visited:Object`
##### -`touch(...field:string) : Function`
> the visited flags for each field, in the form `{ field1: <boolean>, field2: <boolean> }`
> Marks the given fields as "touched" to show errors.
##### -`touched:Object`
> the touched flags for each field, in the form `{ field1: <boolean>, field2: <boolean> }`
##### -`touchAll() : Function`
> Marks all fields as "touched" to show errors. should be called on form submission.
##### -`untouch(...field:string) : Function`
> Clears the "touched" flag for the given fields
##### -`untouchAll() : Function`
> Clears the "touched" flag for the all fields
##### -`valid:boolean`
> `true` if the form passes validation (has no validation errors). Opposite of `invalid`.
## Running Example

@@ -177,0 +259,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc