redux-form
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.ReduxForm=e(require("react")):t.ReduxForm=e(t.React)}(this,function(t){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function o(t){return t&&t.__esModule?t:{"default":t}}e.__esModule=!0;var u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},i=r(5),a=o(i),s=r(6),c=o(s),f=r(14),l=o(f),d=r(1),p=o(d),h=r(4),y=o(h),v=r(3),m=n(v),g=u({},p.default(u({},m,{initializeWithKey:function(t,e){return y.default(m.initialize,{key:t})(e)}}),function(t){return function(e){for(var r=arguments.length,n=Array(r>1?r-1:0),o=1;r>o;o++)n[o-1]=arguments[o];return y.default(t,{form:e}).apply(void 0,n)}})),b=g.blur,_=g.change,O=g.initialize,T=g.initializeWithKey,w=g.reset,S=g.startAsyncValidation,A=g.stopAsyncValidation,x=g.touch,P=g.untouch;e.blur=b,e.change=_,e.connectReduxForm=l.default,e.reducer=a.default,e.initialize=O,e.initializeWithKey=T,e.reset=w,e.startAsyncValidation=S,e.stopAsyncValidation=A,e.touch=x,e.untouch=P,e.default=c.default},function(t,e){"use strict";function r(t,e){return Object.keys(t).reduce(function(r,o){var u;return n({},r,(u={},u[o]=e(t[o],o),u))},{})}e.__esModule=!0;var n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t};e.default=r,t.exports=e.default},function(t,e){"use strict";e.__esModule=!0;var r="redux-form/BLUR";e.BLUR=r;var n="redux-form/CHANGE";e.CHANGE=n;var o="redux-form/INITIALIZE";e.INITIALIZE=o;var u="redux-form/RESET";e.RESET=u;var i="redux-form/START_ASYNC_VALIDATION";e.START_ASYNC_VALIDATION=i;var a="redux-form/START_SUBMIT";e.START_SUBMIT=a;var s="redux-form/STOP_ASYNC_VALIDATION";e.STOP_ASYNC_VALIDATION=s;var c="redux-form/STOP_SUBMIT";e.STOP_SUBMIT=c;var f="redux-form/TOUCH";e.TOUCH=f;var l="redux-form/UNTOUCH";e.UNTOUCH=l},function(t,e,r){"use strict";function n(t,e){return{type:p.BLUR,field:t,value:e}}function o(t,e){return{type:p.CHANGE,field:t,value:e}}function u(t){return{type:p.INITIALIZE,data:t}}function i(){return{type:p.RESET}}function a(){return{type:p.START_ASYNC_VALIDATION}}function s(){return{type:p.START_SUBMIT}}function c(t){return{type:p.STOP_ASYNC_VALIDATION,errors:t}}function f(){return{type:p.STOP_SUBMIT}}function l(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return{type:p.TOUCH,fields:e}}function d(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return{type:p.UNTOUCH,fields:e}}e.__esModule=!0,e.blur=n,e.change=o,e.initialize=u,e.reset=i,e.startAsyncValidation=a,e.startSubmit=s,e.stopAsyncValidation=c,e.stopSubmit=f,e.touch=l,e.untouch=d;var p=r(2)},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){return"function"==typeof t?function(){return u({},t.apply(void 0,arguments),e)}:a.default(t,function(t){return o(t,e)})}e.__esModule=!0;var u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t};e.default=o;var i=r(1),a=n(i);t.exports=e.default},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){var r={};for(var n in t)e.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n]);return r}function u(){var t,e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],n=r.form,u=r.key,a=o(r,["form","key"]);if(!n)return e;if(u){var s,c;return i({},e,(c={},c[n]=i({},e[n],(s={},s[u]=l((e[n]||{})[u],a),s)),c))}return i({},e,(t={},t[n]=l(e[n],a),t))}e.__esModule=!0;var i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},a=r(2),s=r(1),c=n(s),f={asyncErrors:{valid:!0},asyncValidating:!1,data:{},initial:{},submitting:!1,touched:{}};e.initialState=f;var l=function(){var t,e,r=arguments.length<=0||void 0===arguments[0]?f:arguments[0],n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];switch(n.type){case a.BLUR:var u={data:i({},r.data,(t={},t[n.field]=n.value,t))};if(n.touch){var s;u.touched=i({},r.touched,(s={},s[n.field]=!0,s))}return i({},r,u);case a.CHANGE:var c=r.asyncErrors,l=(c[n.field],c.valid,o(c,[n.field,"valid"])),d={data:i({},r.data,(e={},e[n.field]=n.value,e)),asyncErrors:i({},l,{valid:!Object.keys(l).length})};if(delete d.asyncErrors[n.field],n.touch){var p;d.touched=i({},r.touched,(p={},p[n.field]=!0,p))}return i({},r,d);case a.INITIALIZE:return{asyncErrors:{},asyncValidating:!1,data:n.data,initial:n.data,submitting:!1,touched:{}};case a.RESET:return{asyncErrors:{},asyncValidating:!1,data:r.initial,initial:r.initial,submitting:!1,touched:{}};case a.START_ASYNC_VALIDATION:return i({},r,{asyncValidating:!0});case a.START_SUBMIT:return i({},r,{submitting:!0});case a.STOP_ASYNC_VALIDATION:return i({},r,{asyncValidating:!1,asyncErrors:n.errors});case a.STOP_SUBMIT:return i({},r,{submitting:!1});case a.TOUCH:var h={};return n.fields.forEach(function(t){if("string"!=typeof t)throw new Error("fields passed to touch() must be strings");h[t]=!0}),i({},r,{touched:i({},r.touched,h)});case a.UNTOUCH:var y={};return n.fields.forEach(function(t){if("string"!=typeof t)throw new Error("fields passed to untouch() must be strings");y[t]=!1}),i({},r,{touched:i({},r.touched,y)});default:return r}};u.plugin=function(t){return function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],n=u(e,r);return i({},n,c.default(t,function(t,e){return t(n[e]||f,r)}))}},e.default=u},function(t,e,r){"use strict";function n(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function o(t){return t&&t.__esModule?t:{"default":t}}function u(t,e){var r={};for(var n in t)e.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n]);return r}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function s(t,e,r){if(t&&t[e]){if(!r)return t[e];if(t[e][r])return t[e][r]}return O.initialState}function c(t,e){if(void 0!==t||!e)return t;var r=e.target,n=r.type,o=r.value,u=r.checked;return"checkbox"===n?u:o}function f(t,e,r,n,o,f,l){function v(t){var e=r(t.data),n=p({valid:!0},t.asyncErrors),o=!(!e.valid||!n.valid);return p({},e,n,{valid:o})}return function(b){return function(O){function T(){i(this,T),O.apply(this,arguments)}return a(T,O),T.prototype.render=function(){var t=this,i=this.props,a=i.formName,d=i.form,h=i.formKey,O=i.dispatch,T=u(i,["formName","form","formKey","dispatch"]),w=s(d,a,h),S=h?_.default(m,{form:a,key:h}):_.default(m,{form:a}),A=S.blur,x=S.change,P=S.initialize,j=S.reset,I=S.startAsyncValidation,E=S.startSubmit,M=S.stopAsyncValidation,N=S.stopSubmit,C=S.touch,R=S.untouch,k=f?function(){O(I(h));var t=f(w.data);if(!t||"function"!=typeof t.then)throw new Error("asyncValidate function passed to reduxForm must return a promise!");return t.then(function(t){return O(M(t)),!!t.valid})}:void 0,U=function(t,e){return function(o){var u=c(e,o),i=_.default(A,{touch:n});if(O(i(t,u)),k&&~l.indexOf(t)){var a,s=r(p({},w.data,(a={},a[t]=u,a)))[t];s||k()}}},V=g.isPristine(w.initial,w.data),D=v(w),L=D.valid,B=u(D,["valid"]),H=function(t,e){return function(r){var n=_.default(x,{touch:o});O(n(t,c(e,r)))}},z=function(r){var n=function(t){return function(r){r&&r.preventDefault();var n=function(){var e=t(w.data);if(e&&"function"==typeof e.then){var r=function(t){return O(N()),t};O(E()),e.then(r,r)}};return O(C.apply(void 0,e)),k?k().then(function(t){return L&&t?n(w.data):void 0}):L?n(w.data):void 0}};if("function"==typeof r)return n(r);var o=t.props.onSubmit;if(!o)throw new Error("You must either pass handleSubmit() an onSubmit function or pass onSubmit as a prop");n(o)(r)};return y.default.createElement(b,p({asyncValidate:k,asyncValidating:w.asyncValidating,data:w.data,dirty:!V,dispatch:O,errors:B,formKey:h,handleBlur:U,handleChange:H,handleSubmit:z,initializeForm:function(t){return O(P(t))},invalid:!L,isDirty:function(t){return!g.isPristine(w.data[t],w.initial[t])},isPristine:function(t){return g.isPristine(w.data[t],w.initial[t])},pristine:V,resetForm:function(){return O(j())},submitting:w.submitting,touch:function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return O(C.apply(void 0,e))},touched:w.touched,touchAll:function(){return O(C.apply(void 0,e))},untouch:function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return O(R.apply(void 0,e))},untouchAll:function(){return O(untouchAll.apply(void 0,e))},valid:L},T))},d(T,null,[{key:"displayName",value:"ReduxForm("+g.getDisplayName(b)+")",enumerable:!0},{key:"DecoratedComponent",value:b,enumerable:!0},{key:"propTypes",value:{formName:h.PropTypes.string,formKey:h.PropTypes.string,form:h.PropTypes.object,onSubmit:h.PropTypes.func,dispatch:h.PropTypes.func.isRequired},enumerable:!0},{key:"defaultProps",value:{formName:t},enumerable:!0}]),T}(h.Component)}}function l(t,e){var r=arguments.length<=2||void 0===arguments[2]?function(){return{valid:!0}}:arguments[2],n=arguments.length<=3||void 0===arguments[3]?!0:arguments[3],o=arguments.length<=4||void 0===arguments[4]?!1:arguments[4],u=f(t,e,r,!!n,!!o);return u.async=function(u){for(var i=arguments.length,a=Array(i>1?i-1:0),s=1;i>s;s++)a[s-1]=arguments[s];return f(t,e,r,!!n,!!o,u,Array.isArray(a[0])?a[0]:a)},u}e.__esModule=!0;var d=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),p=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t};e.default=l;var h=r(13),y=o(h),v=r(3),m=n(v),g=r(15),b=r(4),_=o(b),O=r(5);t.exports=e.default},function(t,e){"use strict";function r(t){return t.shape({subscribe:t.func.isRequired,dispatch:t.func.isRequired,getState:t.func.isRequired})}e.__esModule=!0,e.default=r,t.exports=e.default},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){function r(){return f}function n(t){return l.push(t),function(){var e=l.indexOf(t);l.splice(e,1)}}function o(t){if(!i.default(t))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(d)throw new Error("Reducers may not dispatch actions.");try{d=!0,f=c(f,t)}finally{d=!1}return l.slice().forEach(function(t){return t()}),t}function u(){return c}function s(t){c=t,o({type:a.INIT})}if("function"!=typeof t)throw new Error("Expected the reducer to be a function.");var c=t,f=e,l=[],d=!1;return o({type:a.INIT}),{dispatch:o,subscribe:n,getState:r,getReducer:u,replaceReducer:s}}e.__esModule=!0,e.default=o;var u=r(10),i=n(u),a={INIT:"@@redux/INIT"};e.ActionTypes=a},function(t,e){"use strict";function r(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return e.reduceRight(function(t,e){return e(t)})}e.__esModule=!0,e.default=r,t.exports=e.default},function(t,e){"use strict";function r(t){if(!t||"object"!=typeof t)return!1;var e="function"==typeof t.constructor?Object.getPrototypeOf(t):Object.prototype;if(null===e)return!0;var r=e.constructor;return"function"==typeof r&&r instanceof r&&n(r)===n(Object)}e.__esModule=!0,e.default=r;var n=function(t){return Function.prototype.toString.call(t)};t.exports=e.default},function(t,e){"use strict";function r(t,e){return Object.keys(t).reduce(function(r,n){return r[n]=e(t[n],n),r},{})}e.__esModule=!0,e.default=r,t.exports=e.default},function(t,e){function r(){c=!1,i.length?s=i.concat(s):f=-1,s.length&&n()}function n(){if(!c){var t=setTimeout(r);c=!0;for(var e=s.length;e;){for(i=s,s=[];++f<e;)i[f].run();f=-1,e=s.length}i=null,c=!1,clearTimeout(t)}}function o(t,e){this.fun=t,this.array=e}function u(){}var i,a=t.exports={},s=[],c=!1,f=-1;a.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];s.push(new o(t,e)),1!==s.length||c||setTimeout(n,0)},o.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=u,a.addListener=u,a.once=u,a.off=u,a.removeListener=u,a.removeAllListeners=u,a.emit=u,a.binding=function(t){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(t){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},function(e,r){e.exports=t},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return function(t){return e.reduce(function(t,e){return e(t)},t)}}function u(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];var n=o(s.default.apply(void 0,e),c);return n.async=function(){var t;return o((t=s.default.apply(void 0,e)).async.apply(t,arguments),c)},n}e.__esModule=!0,e.default=u;var i=r(19),a=r(6),s=n(a),c=i.connect(function(t){return{form:t.form}});t.exports=e.default},function(t,e){"use strict";function r(t){return t.displayName||t.name||"Component"}function n(t,e){if(t===e)return!0;if("object"==typeof t){if("object"!=typeof e)return!1;for(var r=Object.keys(e),o=0;o<r.length;o++){var u=r[o];if(!n(t[u],e[u]))return!1}}else if((t||e)&&t!==e)return!1;return!0}e.__esModule=!0,e.getDisplayName=r,e.isPristine=n},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t){var e=i.default(t),r=s.default(t);return{Provider:e,connect:r}}e.__esModule=!0,e.default=o;var u=r(18),i=n(u),a=r(17),s=n(a);t.exports=e.default},function(t,e,r){(function(n){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function a(t){return t.displayName||t.name||"Component"}function s(t){var e=t.Component,r=t.PropTypes,o=d.default(r);return function(r,s,l){function d(t,e){var r=t.getState(),n=P?b(r,e):b(r);return _.default(v.default(n),"`mapStateToProps` must return an object. Instead received %s.",n),n}function p(t,e){var r=t.dispatch,n=j?A(r,e):A(r);return _.default(v.default(n),"`mapDispatchToProps` must return an object. Instead received %s.",n),n}function y(t,e,r){var n=x(t,e,r);return _.default(v.default(n),"`mergeProps` must return an object. Instead received %s.",n),n}var m=Boolean(r),b=r||O,A=v.default(s)?g.default(s):s||T,x=l||w,P=b.length>1,j=A.length>1,I=S++;return function(r){var s=function(e){function n(t,r){u(this,n),e.call(this,t,r),this.version=I,this.store=t.store||r.store,_.default(this.store,'Could not find "store" in either the context or '+('props of "'+this.constructor.displayName+'". ')+"Either wrap the root component in a <Provider>, "+('or explicitly pass "store" as a prop to "'+this.constructor.displayName+'".')),this.stateProps=d(this.store,t),this.dispatchProps=p(this.store,t),this.state={props:this.computeNextState()}}return i(n,e),n.prototype.shouldComponentUpdate=function(t,e){return!h.default(this.state.props,e.props)},c(n,null,[{key:"displayName",value:"Connect("+a(r)+")",enumerable:!0},{key:"WrappedComponent",value:r,enumerable:!0},{key:"contextTypes",value:{store:o},enumerable:!0},{key:"propTypes",value:{store:o},enumerable:!0}]),n.prototype.computeNextState=function(){var t=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0];return y(this.stateProps,this.dispatchProps,t)},n.prototype.updateStateProps=function(){var t=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0],e=d(this.store,t);return h.default(e,this.stateProps)?!1:(this.stateProps=e,!0)},n.prototype.updateDispatchProps=function(){var t=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0],e=p(this.store,t);return h.default(e,this.dispatchProps)?!1:(this.dispatchProps=e,!0)},n.prototype.updateState=function(){var t=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0],e=this.computeNextState(t);h.default(e,this.state.props)||this.setState({props:e})},n.prototype.isSubscribed=function(){return"function"==typeof this.unsubscribe},n.prototype.trySubscribe=function(){m&&!this.unsubscribe&&(this.unsubscribe=this.store.subscribe(this.handleChange.bind(this)),this.handleChange())},n.prototype.tryUnsubscribe=function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)},n.prototype.componentDidMount=function(){this.trySubscribe()},n.prototype.componentWillReceiveProps=function(t){h.default(t,this.props)||(P&&this.updateStateProps(t),j&&this.updateDispatchProps(t),this.updateState(t))},n.prototype.componentWillUnmount=function(){this.tryUnsubscribe()},n.prototype.handleChange=function(){this.updateStateProps()&&this.updateState()},n.prototype.getWrappedInstance=function(){return this.refs.wrappedInstance},n.prototype.render=function(){return t.createElement(r,f({ref:"wrappedInstance"},this.state.props))},n}(e);return"undefined"!=typeof n&&"undefined"!=typeof n.env,"undefined"!=typeof __DEV__&&__DEV__&&(s.prototype.componentWillUpdate=function(){this.version!==I&&(this.version=I,this.trySubscribe(),this.updateStateProps(),this.updateDispatchProps(),this.updateState())}),s}}}e.__esModule=!0;var c=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),f=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t};e.default=s;var l=r(7),d=o(l),p=r(21),h=o(p),y=r(20),v=o(y),m=r(22),g=o(m),b=r(23),_=o(b),O=function(){return{}},T=function(t){return{dispatch:t}},w=function(t,e,r){return f({},r,t,e)},S=0;t.exports=e.default}).call(e,r(12))},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function i(t){var e=t.version;if("string"!=typeof e)return!1;var r=e.split("."),n=parseInt(r[0],10),o=parseInt(r[1],10);return 0===n&&13===o}function a(t){function e(){p||d||(p=!0,console.error("With React 0.14 and later versions, you no longer need to wrap <Provider> child into a function."))}function r(){!p&&d&&(p=!0,console.error("With React 0.13, you need to wrap <Provider> child into a function. This restriction will be removed with React 0.14."))}var n=t.Component,a=t.PropTypes,c=t.Children,l=f.default(a),d=i(t),p=!1;return function(t){function n(e,r){o(this,n),t.call(this,e,r),this.state={store:e.store}}return u(n,t),n.prototype.getChildContext=function(){return{store:this.state.store}},s(n,null,[{key:"childContextTypes",value:{store:l.isRequired},enumerable:!0},{key:"propTypes",value:{store:l.isRequired,children:(d?a.func:a.element).isRequired},enumerable:!0}]),n.prototype.componentWillReceiveProps=function(t){var e=this.state.store,r=t.store;if(e!==r){var n=r.getReducer();e.replaceReducer(n)}},n.prototype.render=function(){var t=this.props.children;return"function"==typeof t?(e(),t=t()):r(),c.only(t)},n}(n)}e.__esModule=!0;var s=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}();e.default=a;var c=r(7),f=n(c);t.exports=e.default},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}e.__esModule=!0;var o=r(13),u=n(o),i=r(16),a=n(i),s=a.default(u.default),c=s.Provider,f=s.connect;e.Provider=c,e.connect=f},function(t,e){"use strict";function r(t){if(!t||"object"!=typeof t)return!1;var e="function"==typeof t.constructor?Object.getPrototypeOf(t):Object.prototype;if(null===e)return!0;var r=e.constructor;return"function"==typeof r&&r instanceof r&&n(r)===n(Object)}e.__esModule=!0,e.default=r;var n=function(t){return Function.prototype.toString.call(t)};t.exports=e.default},function(t,e){"use strict";function r(t,e){if(t===e)return!0;var r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(var o=Object.prototype.hasOwnProperty,u=0;u<r.length;u++)if(!o.call(e,r[u])||t[r[u]]!==e[r[u]])return!1;return!0}e.__esModule=!0,e.default=r,t.exports=e.default},function(t,e,r){"use strict";function n(t){return function(e){return o.bindActionCreators(t,e)}}e.__esModule=!0,e.default=n;var o=r(24);t.exports=e.default},function(t,e,r){"use strict";var n=function(t,e,r,n,o,u,i,a){if(!t){var s;if(void 0===e)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[r,n,o,u,i,a],f=0;s=new Error("Invariant Violation: "+e.replace(/%s/g,function(){return c[f++]}))}throw s.framesToPop=1,s}};t.exports=n},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}e.__esModule=!0;var o=r(8),u=n(o),i=r(27),a=n(i),s=r(26),c=n(s),f=r(25),l=n(f),d=r(9),p=n(d);e.createStore=u.default,e.combineReducers=a.default,e.bindActionCreators=c.default,e.applyMiddleware=l.default,e.compose=p.default},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return function(t){return function(r,n){var o=t(r,n),i=o.dispatch,s=[],c={getState:o.getState,dispatch:function(t){return i(t)}};return s=e.map(function(t){return t(c)}),i=a.default.apply(void 0,s.concat([o.dispatch])),u({},o,{dispatch:i})}}}e.__esModule=!0;var u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t};e.default=o;var i=r(9),a=n(i);t.exports=e.default},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){return function(){return e(t.apply(void 0,arguments))}}function u(t,e){if("function"==typeof t)return o(t,e);if("object"!=typeof t||null==t)throw new Error("bindActionCreators expected an object or a function, instead received "+typeof t+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');return a.default(t,function(t){return o(t,e)})}e.__esModule=!0,e.default=u;var i=r(11),a=n(i);t.exports=e.default},function(t,e,r){(function(n){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function u(t,e){var r=e&&e.type,n=r&&'"'+r.toString()+'"'||"an action";return'Reducer "'+t+'" returned undefined handling '+n+". To ignore an action, you must explicitly return the previous state."}function i(t,e){var r=Object.keys(e);if(0===r.length)return void console.error("Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.");if(!f.default(t))return void console.error('initialState has unexpected type of "'+{}.toString.call(t).match(/\s([a-z|A-Z]+)/)[1]+'". Expected initialState to be an object with the following '+('keys: "'+r.join('", "')+'"'));var n=Object.keys(t).filter(function(t){return r.indexOf(t)<0});n.length>0&&console.error("Unexpected "+(n.length>1?"keys":"key")+" "+('"'+n.join('", "')+'" in initialState will be ignored. ')+('Expected to find one of the known reducer keys instead: "'+r.join('", "')+'"'))}function a(t){var e=h.default(t,function(t){return"function"==typeof t});Object.keys(e).forEach(function(t){var r=e[t];if("undefined"==typeof r(void 0,{type:s.ActionTypes.INIT}))throw new Error('Reducer "'+t+'" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined.');var n=Math.random().toString(36).substring(7).split("").join(".");if("undefined"==typeof r(void 0,{type:n}))throw new Error('Reducer "'+t+'" returned undefined when probed with a random type. '+("Don't try to handle "+s.ActionTypes.INIT+' or other actions in "redux/*" ')+"namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined.")});var r,o=d.default(e,function(){return void 0});return function(t,a){void 0===t&&(t=o);var s=d.default(e,function(e,r){var n=e(t[r],a);if("undefined"==typeof n)throw new Error(u(r,a));return n});return"undefined"!=typeof n&&"undefined"!=typeof n.env,"undefined"!=typeof __DEV__&&__DEV__&&(r||(i(t,s),r=!0)),s}}e.__esModule=!0,e.default=a;var s=r(8),c=r(10),f=o(c),l=r(11),d=o(l),p=r(28),h=o(p);t.exports=e.default}).call(e,r(12))},function(t,e){"use strict";function r(t,e){return Object.keys(t).reduce(function(r,n){return e(t[n])&&(r[n]=t[n]),r},{})}e.__esModule=!0,e.default=r,t.exports=e.default}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.ReduxForm=e(require("react")):t.ReduxForm=e(t.React)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function o(t){return t&&t.__esModule?t:{"default":t}}e.__esModule=!0;var u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},i=n(5),a=o(i),s=n(6),c=o(s),f=n(14),l=o(f),d=n(1),p=o(d),h=n(4),y=o(h),v=n(3),m=r(v),g=u({},p.default(u({},m,{initializeWithKey:function(t,e){return y.default(m.initialize,{key:t})(e)}}),function(t){return function(e){for(var n=arguments.length,r=Array(n>1?n-1:0),o=1;n>o;o++)r[o-1]=arguments[o];return y.default(t,{form:e}).apply(void 0,r)}})),b=g.blur,_=g.change,O=g.initialize,T=g.initializeWithKey,w=g.reset,S=g.startAsyncValidation,x=g.stopAsyncValidation,A=g.touch,P=g.untouch;e.blur=b,e.change=_,e.connectReduxForm=l.default,e.reducer=a.default,e.initialize=O,e.initializeWithKey=T,e.reset=w,e.startAsyncValidation=S,e.stopAsyncValidation=x,e.touch=A,e.untouch=P,e.default=c.default},function(t,e){"use strict";function n(t,e){return Object.keys(t).reduce(function(n,o){var u;return r({},n,(u={},u[o]=e(t[o],o),u))},{})}e.__esModule=!0;var r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};e.default=n,t.exports=e.default},function(t,e){"use strict";e.__esModule=!0;var n="redux-form/BLUR";e.BLUR=n;var r="redux-form/CHANGE";e.CHANGE=r;var o="redux-form/INITIALIZE";e.INITIALIZE=o;var u="redux-form/RESET";e.RESET=u;var i="redux-form/START_ASYNC_VALIDATION";e.START_ASYNC_VALIDATION=i;var a="redux-form/START_SUBMIT";e.START_SUBMIT=a;var s="redux-form/STOP_ASYNC_VALIDATION";e.STOP_ASYNC_VALIDATION=s;var c="redux-form/STOP_SUBMIT";e.STOP_SUBMIT=c;var f="redux-form/TOUCH";e.TOUCH=f;var l="redux-form/UNTOUCH";e.UNTOUCH=l},function(t,e,n){"use strict";function r(t,e){return{type:p.BLUR,field:t,value:e}}function o(t,e){return{type:p.CHANGE,field:t,value:e}}function u(t){return{type:p.INITIALIZE,data:t}}function i(){return{type:p.RESET}}function a(){return{type:p.START_ASYNC_VALIDATION}}function s(){return{type:p.START_SUBMIT}}function c(t){return{type:p.STOP_ASYNC_VALIDATION,errors:t}}function f(){return{type:p.STOP_SUBMIT}}function l(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return{type:p.TOUCH,fields:e}}function d(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return{type:p.UNTOUCH,fields:e}}e.__esModule=!0,e.blur=r,e.change=o,e.initialize=u,e.reset=i,e.startAsyncValidation=a,e.startSubmit=s,e.stopAsyncValidation=c,e.stopSubmit=f,e.touch=l,e.untouch=d;var p=n(2)},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){return"function"==typeof t?function(){return u({},t.apply(void 0,arguments),e)}:a.default(t,function(t){return o(t,e)})}e.__esModule=!0;var u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};e.default=o;var i=n(1),a=r(i);t.exports=e.default},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){var n={};for(var r in t)e.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n}function u(){var t,e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=n.form,u=n.key,i=o(n,["form","key"]);if(!r)return e;if(u){var s,c;return a({},e,(c={},c[r]=a({},e[r],(s={},s[u]=p((e[r]||{})[u],i),s)),c))}return a({},e,(t={},t[r]=p(e[r],i),t))}function i(t){return t.plugin=function(t){var e=this;return i(function(){var n=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],o=e(n,r);return a({},o,f.default(t,function(t,e){return t(o[e]||l,r)}))})},t.normalize=function(t){var e=this;return i(function(){var n=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],o=e(n,r);return a({},o,f.default(t,function(t,e){return a({},o[e],f.default(t,function(t,r){return a({},o[e][r],{value:t(o[e][r]?o[e][r].value:void 0,n[e]&&n[e][r]?n[e][r].value:void 0,d(o[e]))})}))}))})},t}e.__esModule=!0;var a=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},s=n(2),c=n(1),f=r(c),l={_asyncValidating:!1,_submitting:!1};e.initialState=l;var d=function(t){return Object.keys(t).reduce(function(e,n){var r;return"_"===n[0]?e:a({},e,(r={},r[n]=t[n].value,r))},{})},p=function(){var t,e,n=arguments.length<=0||void 0===arguments[0]?l:arguments[0],r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];switch(r.type){case s.BLUR:return a({},n,(t={},t[r.field]=a({},n[r.field],{value:r.value,touched:r.touch||(n[r.field]||{}).touched}),t));case s.CHANGE:return a({},n,(e={},e[r.field]=a({},n[r.field],{value:r.value,touched:r.touch||(n[r.field]||{}).touched,asyncError:null}),e));case s.INITIALIZE:return a({},f.default(r.data,function(t){return{initial:t,value:t}}),{_asyncValidating:!1,_submitting:!1});case s.RESET:return a({},f.default(n,function(t,e){return"_"===e[0]?t:{initial:t.initial,value:t.initial}}),{_asyncValidating:!1,_submitting:!1});case s.START_ASYNC_VALIDATION:return a({},n,{_asyncValidating:!0});case s.START_SUBMIT:return a({},n,{_submitting:!0});case s.STOP_ASYNC_VALIDATION:return a({},n,f.default(r.errors,function(t,e){return a({},n[e],{asyncError:t})}),{_asyncValidating:!1});case s.STOP_SUBMIT:return a({},n,{_submitting:!1});case s.TOUCH:return a({},n,r.fields.reduce(function(t,e){var r;return a({},t,(r={},r[e]=a({},n[e],{touched:!0}),r))},{}));case s.UNTOUCH:return a({},n,r.fields.reduce(function(t,e){var r;return a({},t,(r={},r[e]=a({},n[e],{touched:!1}),r))},{}));default:return n}};e.default=i(u)},function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function o(t){return t&&t.__esModule?t:{"default":t}}function u(t,e){var n={};for(var r in t)e.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function s(t,e,n){if(t&&t[e]){if(!n)return t[e];if(t[e][n])return t[e][n]}return T.initialState}function c(t,e){if(void 0!==t||!e)return t;var n=e.target,r=n.type,o=n.value,u=n.checked;return"checkbox"===r?u:o}function f(t){return function(e){for(var n=arguments.length,r=Array(n>1?n-1:0),o=1;n>o;o++)r[o-1]=arguments[o];return e&&e.preventDefault?(e.preventDefault(),e.stopPropagation(),t.apply(void 0,r)):t.apply(void 0,[e].concat(r))}}function l(t,e,n,r,o,l,d){return function(m){return function(_){function T(){i(this,T),_.apply(this,arguments)}return a(T,_),T.prototype.render=function(){function t(){T(C(_));var t=l(P);if(!t||"function"!=typeof t.then)throw new Error("asyncValidate function passed to reduxForm must return a promise!");return t.then(function(t){return T(k(t)),!!t.valid},function(t){throw T(k({})),new Error("redux-form: Asynchronous validation failed: "+t)})}var i=this,a=this.props,h=a.formName,y=a.form,_=a.formKey,T=a.dispatch,w=u(a,["formName","form","formKey","dispatch"]),S=s(y,h,_),x=!0,A=!0,P=e.reduce(function(t,e){var n;return p({},t,(n={},n[e]=S[e]?S[e].value:void 0,n))},{}),j=_?O.default(g,{form:h,key:_}):O.default(g,{form:h}),I=j.blur,M=j.change,E=j.initialize,N=j.reset,C=j.startAsyncValidation,R=j.startSubmit,k=j.stopAsyncValidation,U=j.stopSubmit,V=j.touch,D=j.untouch,L=function(e,o){return function(u){var i=c(o,u),a=O.default(I,{touch:r});if(T(a(e,i)),l&&~d.indexOf(e)){var s,f=n(p({},P,(s={},s[e]=i,s)))[e];f||t()}}},B=function(t,e){return function(n){var r=O.default(M,{touch:o});T(r(t,c(e,n)))}},z=function(n){var r=function(n){return function(r){r&&(r.preventDefault(),r.stopPropagation());var o=function(){var t=n(P);if(t&&"function"==typeof t.then){var e=function(t){return T(U()),t};T(R()),t.then(e,e)}};return T(V.apply(void 0,e)),x?l?t().then(function(t){return x&&t?o(P):void 0}):o(P):void 0}};if("function"==typeof n)return r(n);var o=i.props.onSubmit;if(!o)throw new Error("You must either pass handleSubmit() an onSubmit function or pass onSubmit as a prop");r(o)(n)},H=n(P),W=e.reduce(function(t,e){var n,r=S[e]||{},o=b.isPristine(r.value,r.initial),u=H[e]||r.asyncError;return u&&(x=!1),o||(A=!1),p({},t,(n={},n[e]={checked:"boolean"==typeof r.value?r.value:void 0,dirty:!o,error:u,handleBlur:L(e),handleChange:B(e),invalid:!!u,onBlur:L(e),onChange:B(e),pristine:o,touched:r.touched,valid:!u,value:r.value},n))},{});return v.default.createElement(m,p({asyncValidating:S._asyncValidating,dirty:!A,fields:W,formKey:_,invalid:!x,pristine:A,submitting:S._submitting,valid:x,values:P,asyncValidate:f(t),handleBlur:f(L),handleChange:f(B),handleSubmit:f(z),initializeForm:f(function(t){return T(E(t))}),resetForm:f(function(){return T(N())}),touch:f(function(){return T(V.apply(void 0,arguments))}),touchAll:f(function(){return T(V.apply(void 0,e))}),untouch:f(function(){return T(D.apply(void 0,arguments))}),untouchAll:f(function(){return T(untouchAll.apply(void 0,e))}),dispatch:T},w))},h(T,null,[{key:"displayName",value:"ReduxForm("+b.getDisplayName(m)+")",enumerable:!0},{key:"DecoratedComponent",value:m,enumerable:!0},{key:"propTypes",value:{formName:y.PropTypes.string,formKey:y.PropTypes.string,form:y.PropTypes.object,onSubmit:y.PropTypes.func,dispatch:y.PropTypes.func.isRequired},enumerable:!0},{key:"defaultProps",value:{formName:t},enumerable:!0}]),T}(y.Component)}}function d(t,e){var n=arguments.length<=2||void 0===arguments[2]?function(){return{valid:!0}}:arguments[2],r=arguments.length<=3||void 0===arguments[3]?!0:arguments[3],o=arguments.length<=4||void 0===arguments[4]?!1:arguments[4],u=l(t,e,n,!!r,!!o);return u.async=function(u){for(var i=arguments.length,a=Array(i>1?i-1:0),s=1;i>s;s++)a[s-1]=arguments[s];return l(t,e,n,!!r,!!o,u,Array.isArray(a[0])?a[0]:a)},u}e.__esModule=!0;var p=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},h=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();e.default=d;var y=n(13),v=o(y),m=n(3),g=r(m),b=n(15),_=n(4),O=o(_),T=n(5);t.exports=e.default},function(t,e){"use strict";function n(t){return t.shape({subscribe:t.func.isRequired,dispatch:t.func.isRequired,getState:t.func.isRequired})}e.__esModule=!0,e.default=n,t.exports=e.default},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){function n(){return f}function r(t){return l.push(t),function(){var e=l.indexOf(t);l.splice(e,1)}}function o(t){if(!i.default(t))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(d)throw new Error("Reducers may not dispatch actions.");try{d=!0,f=c(f,t)}finally{d=!1}return l.slice().forEach(function(t){return t()}),t}function u(){return c}function s(t){c=t,o({type:a.INIT})}if("function"!=typeof t)throw new Error("Expected the reducer to be a function.");var c=t,f=e,l=[],d=!1;return o({type:a.INIT}),{dispatch:o,subscribe:r,getState:n,getReducer:u,replaceReducer:s}}e.__esModule=!0,e.default=o;var u=n(10),i=r(u),a={INIT:"@@redux/INIT"};e.ActionTypes=a},function(t,e){"use strict";function n(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return e.reduceRight(function(t,e){return e(t)})}e.__esModule=!0,e.default=n,t.exports=e.default},function(t,e){"use strict";function n(t){if(!t||"object"!=typeof t)return!1;var e="function"==typeof t.constructor?Object.getPrototypeOf(t):Object.prototype;if(null===e)return!0;var n=e.constructor;return"function"==typeof n&&n instanceof n&&r(n)===r(Object)}e.__esModule=!0,e.default=n;var r=function(t){return Function.prototype.toString.call(t)};t.exports=e.default},function(t,e){"use strict";function n(t,e){return Object.keys(t).reduce(function(n,r){return n[r]=e(t[r],r),n},{})}e.__esModule=!0,e.default=n,t.exports=e.default},function(t,e){function n(){c=!1,i.length?s=i.concat(s):f=-1,s.length&&r()}function r(){if(!c){var t=setTimeout(n);c=!0;for(var e=s.length;e;){for(i=s,s=[];++f<e;)i[f].run();f=-1,e=s.length}i=null,c=!1,clearTimeout(t)}}function o(t,e){this.fun=t,this.array=e}function u(){}var i,a=t.exports={},s=[],c=!1,f=-1;a.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];s.push(new o(t,e)),1!==s.length||c||setTimeout(r,0)},o.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=u,a.addListener=u,a.once=u,a.off=u,a.removeListener=u,a.removeAllListeners=u,a.emit=u,a.binding=function(t){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(t){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},function(e,n){e.exports=t},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return function(t){return e.reduce(function(t,e){return e(t)},t)}}function u(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=o(s.default.apply(void 0,e),c);return r.async=function(){var t;return o((t=s.default.apply(void 0,e)).async.apply(t,arguments),c)},r}e.__esModule=!0,e.default=u;var i=n(19),a=n(6),s=r(a),c=i.connect(function(t){return{form:t.form}});t.exports=e.default},function(t,e){"use strict";function n(t){return t.displayName||t.name||"Component"}function r(t,e){if(t===e)return!0;if("object"==typeof t){if("object"!=typeof e)return!1;for(var n=Object.keys(e),o=0;o<n.length;o++){var u=n[o];if(!r(t[u],e[u]))return!1}}else if((t||e)&&t!==e)return!1;return!0}e.__esModule=!0,e.getDisplayName=n,e.isPristine=r},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t){var e=i.default(t),n=s.default(t);return{Provider:e,connect:n}}e.__esModule=!0,e.default=o;var u=n(18),i=r(u),a=n(17),s=r(a);t.exports=e.default},function(t,e,n){(function(r){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function a(t){return t.displayName||t.name||"Component"}function s(t){var e=t.Component,n=t.PropTypes,o=d.default(n);return function(n,s,l){function d(t,e){var n=t.getState(),r=P?b(n,e):b(n);return _.default(v.default(r),"`mapStateToProps` must return an object. Instead received %s.",r),r}function p(t,e){var n=t.dispatch,r=j?x(n,e):x(n);return _.default(v.default(r),"`mapDispatchToProps` must return an object. Instead received %s.",r),r}function y(t,e,n){var r=A(t,e,n);return _.default(v.default(r),"`mergeProps` must return an object. Instead received %s.",r),r}var m=Boolean(n),b=n||O,x=v.default(s)?g.default(s):s||T,A=l||w,P=b.length>1,j=x.length>1,I=S++;return function(n){var s=function(e){function r(t,n){u(this,r),e.call(this,t,n),this.version=I,this.store=t.store||n.store,_.default(this.store,'Could not find "store" in either the context or '+('props of "'+this.constructor.displayName+'". ')+"Either wrap the root component in a <Provider>, "+('or explicitly pass "store" as a prop to "'+this.constructor.displayName+'".')),this.stateProps=d(this.store,t),this.dispatchProps=p(this.store,t),this.state={props:this.computeNextState()}}return i(r,e),r.prototype.shouldComponentUpdate=function(t,e){return!h.default(this.state.props,e.props)},c(r,null,[{key:"displayName",value:"Connect("+a(n)+")",enumerable:!0},{key:"WrappedComponent",value:n,enumerable:!0},{key:"contextTypes",value:{store:o},enumerable:!0},{key:"propTypes",value:{store:o},enumerable:!0}]),r.prototype.computeNextState=function(){var t=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0];return y(this.stateProps,this.dispatchProps,t)},r.prototype.updateStateProps=function(){var t=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0],e=d(this.store,t);return h.default(e,this.stateProps)?!1:(this.stateProps=e,!0)},r.prototype.updateDispatchProps=function(){var t=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0],e=p(this.store,t);return h.default(e,this.dispatchProps)?!1:(this.dispatchProps=e,!0)},r.prototype.updateState=function(){var t=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0],e=this.computeNextState(t);h.default(e,this.state.props)||this.setState({props:e})},r.prototype.isSubscribed=function(){return"function"==typeof this.unsubscribe},r.prototype.trySubscribe=function(){m&&!this.unsubscribe&&(this.unsubscribe=this.store.subscribe(this.handleChange.bind(this)),this.handleChange())},r.prototype.tryUnsubscribe=function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)},r.prototype.componentDidMount=function(){this.trySubscribe()},r.prototype.componentWillReceiveProps=function(t){h.default(t,this.props)||(P&&this.updateStateProps(t),j&&this.updateDispatchProps(t),this.updateState(t))},r.prototype.componentWillUnmount=function(){this.tryUnsubscribe()},r.prototype.handleChange=function(){this.updateStateProps()&&this.updateState()},r.prototype.getWrappedInstance=function(){return this.refs.wrappedInstance},r.prototype.render=function(){return t.createElement(n,f({ref:"wrappedInstance"},this.state.props))},r}(e);return"undefined"!=typeof r&&"undefined"!=typeof r.env,"undefined"!=typeof __DEV__&&__DEV__&&(s.prototype.componentWillUpdate=function(){this.version!==I&&(this.version=I,this.trySubscribe(),this.updateStateProps(),this.updateDispatchProps(),this.updateState())}),s}}}e.__esModule=!0;var c=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),f=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};e.default=s;var l=n(7),d=o(l),p=n(21),h=o(p),y=n(20),v=o(y),m=n(22),g=o(m),b=n(23),_=o(b),O=function(){return{}},T=function(t){return{dispatch:t}},w=function(t,e,n){return f({},n,t,e)},S=0;t.exports=e.default}).call(e,n(12))},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function i(t){var e=t.version;if("string"!=typeof e)return!1;var n=e.split("."),r=parseInt(n[0],10),o=parseInt(n[1],10);return 0===r&&13===o}function a(t){function e(){p||d||(p=!0,console.error("With React 0.14 and later versions, you no longer need to wrap <Provider> child into a function."))}function n(){!p&&d&&(p=!0,console.error("With React 0.13, you need to wrap <Provider> child into a function. This restriction will be removed with React 0.14."))}var r=t.Component,a=t.PropTypes,c=t.Children,l=f.default(a),d=i(t),p=!1;return function(t){function r(e,n){o(this,r),t.call(this,e,n),this.state={store:e.store}}return u(r,t),r.prototype.getChildContext=function(){return{store:this.state.store}},s(r,null,[{key:"childContextTypes",value:{store:l.isRequired},enumerable:!0},{key:"propTypes",value:{store:l.isRequired,children:(d?a.func:a.element).isRequired},enumerable:!0}]),r.prototype.componentWillReceiveProps=function(t){var e=this.state.store,n=t.store;if(e!==n){var r=n.getReducer();e.replaceReducer(r)}},r.prototype.render=function(){var t=this.props.children;return"function"==typeof t?(e(),t=t()):n(),c.only(t)},r}(r)}e.__esModule=!0;var s=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();e.default=a;var c=n(7),f=r(c);t.exports=e.default},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}e.__esModule=!0;var o=n(13),u=r(o),i=n(16),a=r(i),s=a.default(u.default),c=s.Provider,f=s.connect;e.Provider=c,e.connect=f},function(t,e){"use strict";function n(t){if(!t||"object"!=typeof t)return!1;var e="function"==typeof t.constructor?Object.getPrototypeOf(t):Object.prototype;if(null===e)return!0;var n=e.constructor;return"function"==typeof n&&n instanceof n&&r(n)===r(Object)}e.__esModule=!0,e.default=n;var r=function(t){return Function.prototype.toString.call(t)};t.exports=e.default},function(t,e){"use strict";function n(t,e){if(t===e)return!0;var n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(var o=Object.prototype.hasOwnProperty,u=0;u<n.length;u++)if(!o.call(e,n[u])||t[n[u]]!==e[n[u]])return!1;return!0}e.__esModule=!0,e.default=n,t.exports=e.default},function(t,e,n){"use strict";function r(t){return function(e){return o.bindActionCreators(t,e)}}e.__esModule=!0,e.default=r;var o=n(24);t.exports=e.default},function(t,e,n){"use strict";var r=function(t,e,n,r,o,u,i,a){if(!t){var s;if(void 0===e)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,o,u,i,a],f=0;s=new Error("Invariant Violation: "+e.replace(/%s/g,function(){return c[f++]}))}throw s.framesToPop=1,s}};t.exports=r},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}e.__esModule=!0;var o=n(8),u=r(o),i=n(27),a=r(i),s=n(26),c=r(s),f=n(25),l=r(f),d=n(9),p=r(d);e.createStore=u.default,e.combineReducers=a.default,e.bindActionCreators=c.default,e.applyMiddleware=l.default,e.compose=p.default},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return function(t){return function(n,r){var o=t(n,r),i=o.dispatch,s=[],c={getState:o.getState,dispatch:function(t){return i(t)}};return s=e.map(function(t){return t(c)}),i=a.default.apply(void 0,s.concat([o.dispatch])),u({},o,{dispatch:i})}}}e.__esModule=!0;var u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};e.default=o;var i=n(9),a=r(i);t.exports=e.default},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){return function(){return e(t.apply(void 0,arguments))}}function u(t,e){if("function"==typeof t)return o(t,e);if("object"!=typeof t||null==t)throw new Error("bindActionCreators expected an object or a function, instead received "+typeof t+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');return a.default(t,function(t){return o(t,e)})}e.__esModule=!0,e.default=u;var i=n(11),a=r(i);t.exports=e.default},function(t,e,n){(function(r){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function u(t,e){var n=e&&e.type,r=n&&'"'+n.toString()+'"'||"an action";return'Reducer "'+t+'" returned undefined handling '+r+". To ignore an action, you must explicitly return the previous state."}function i(t,e){var n=Object.keys(e);if(0===n.length)return void console.error("Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.");if(!f.default(t))return void console.error('initialState has unexpected type of "'+{}.toString.call(t).match(/\s([a-z|A-Z]+)/)[1]+'". Expected initialState to be an object with the following '+('keys: "'+n.join('", "')+'"'));var r=Object.keys(t).filter(function(t){return n.indexOf(t)<0});r.length>0&&console.error("Unexpected "+(r.length>1?"keys":"key")+" "+('"'+r.join('", "')+'" in initialState will be ignored. ')+('Expected to find one of the known reducer keys instead: "'+n.join('", "')+'"'))}function a(t){var e=h.default(t,function(t){return"function"==typeof t});Object.keys(e).forEach(function(t){var n=e[t];if("undefined"==typeof n(void 0,{type:s.ActionTypes.INIT}))throw new Error('Reducer "'+t+'" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined.');var r=Math.random().toString(36).substring(7).split("").join(".");if("undefined"==typeof n(void 0,{type:r}))throw new Error('Reducer "'+t+'" returned undefined when probed with a random type. '+("Don't try to handle "+s.ActionTypes.INIT+' or other actions in "redux/*" ')+"namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined.")});var n,o=d.default(e,function(){return void 0});return function(t,a){void 0===t&&(t=o);var s=d.default(e,function(e,n){var r=e(t[n],a);if("undefined"==typeof r)throw new Error(u(n,a));return r});return"undefined"!=typeof r&&"undefined"!=typeof r.env,"undefined"!=typeof __DEV__&&__DEV__&&(n||(i(t,s),n=!0)),s}}e.__esModule=!0,e.default=a;var s=n(8),c=n(10),f=o(c),l=n(11),d=o(l),p=n(28),h=o(p);t.exports=e.default}).call(e,n(12))},function(t,e){"use strict";function n(t,e){return Object.keys(t).reduce(function(n,r){return e(t[r])&&(n[r]=t[r]),n},{})}e.__esModule=!0,e.default=n,t.exports=e.default}])}); |
@@ -18,15 +18,19 @@ 'use strict'; | ||
var initialState = { | ||
asyncErrors: { valid: true }, | ||
asyncValidating: false, | ||
data: {}, | ||
initial: {}, | ||
submitting: false, | ||
touched: {} | ||
_asyncValidating: false, | ||
_submitting: false | ||
}; | ||
exports.initialState = initialState; | ||
var getValues = function getValues(state) { | ||
return Object.keys(state).reduce(function (accumulator, name) { | ||
var _extends2; | ||
return name[0] === '_' ? accumulator : _extends({}, accumulator, (_extends2 = {}, _extends2[name] = state[name].value, _extends2)); | ||
}, {}); | ||
}; | ||
var reducer = function reducer() { | ||
var state = arguments.length <= 0 || arguments[0] === undefined ? initialState : arguments[0]; | ||
var _extends2, _extends4; | ||
var _extends3, _extends4; | ||
@@ -37,88 +41,68 @@ var action = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
case _actionTypes.BLUR: | ||
var blurDiff = { | ||
data: _extends({}, state.data, (_extends2 = {}, _extends2[action.field] = action.value, _extends2)) | ||
}; | ||
if (action.touch) { | ||
var _extends3; | ||
blurDiff.touched = _extends({}, state.touched, (_extends3 = {}, _extends3[action.field] = true, _extends3)); | ||
} | ||
return _extends({}, state, blurDiff); | ||
return _extends({}, state, (_extends3 = {}, _extends3[action.field] = _extends({}, state[action.field], { | ||
value: action.value, | ||
touched: action.touch || (state[action.field] || {}).touched | ||
}), _extends3)); | ||
case _actionTypes.CHANGE: | ||
var _state$asyncErrors = state.asyncErrors, | ||
oldError = _state$asyncErrors[action.field], | ||
valid = _state$asyncErrors.valid, | ||
otherErrors = _objectWithoutProperties(_state$asyncErrors, [action.field, 'valid']); | ||
var changeDiff = { | ||
data: _extends({}, state.data, (_extends4 = {}, _extends4[action.field] = action.value, _extends4)), | ||
asyncErrors: _extends({}, otherErrors, { | ||
valid: !Object.keys(otherErrors).length | ||
}) | ||
}; | ||
delete changeDiff.asyncErrors[action.field]; | ||
if (action.touch) { | ||
var _extends5; | ||
changeDiff.touched = _extends({}, state.touched, (_extends5 = {}, _extends5[action.field] = true, _extends5)); | ||
} | ||
return _extends({}, state, changeDiff); | ||
return _extends({}, state, (_extends4 = {}, _extends4[action.field] = _extends({}, state[action.field], { | ||
value: action.value, | ||
touched: action.touch || (state[action.field] || {}).touched, | ||
asyncError: null | ||
}), _extends4)); | ||
case _actionTypes.INITIALIZE: | ||
return { | ||
asyncErrors: {}, | ||
asyncValidating: false, | ||
data: action.data, | ||
initial: action.data, | ||
submitting: false, | ||
touched: {} | ||
}; | ||
return _extends({}, _mapValues2['default'](action.data, function (value) { | ||
return { | ||
initial: value, | ||
value: value | ||
}; | ||
}), { | ||
_asyncValidating: false, | ||
_submitting: false | ||
}); | ||
case _actionTypes.RESET: | ||
return { | ||
asyncErrors: {}, | ||
asyncValidating: false, | ||
data: state.initial, | ||
initial: state.initial, | ||
submitting: false, | ||
touched: {} | ||
}; | ||
return _extends({}, _mapValues2['default'](state, function (field, name) { | ||
return name[0] === '_' ? field : { | ||
initial: field.initial, | ||
value: field.initial | ||
}; | ||
}), { | ||
_asyncValidating: false, | ||
_submitting: false | ||
}); | ||
case _actionTypes.START_ASYNC_VALIDATION: | ||
return _extends({}, state, { | ||
asyncValidating: true | ||
_asyncValidating: true | ||
}); | ||
case _actionTypes.START_SUBMIT: | ||
return _extends({}, state, { | ||
submitting: true | ||
_submitting: true | ||
}); | ||
case _actionTypes.STOP_ASYNC_VALIDATION: | ||
return _extends({}, state, { | ||
asyncValidating: false, | ||
asyncErrors: action.errors | ||
return _extends({}, state, _mapValues2['default'](action.errors, function (error, key) { | ||
return _extends({}, state[key], { | ||
asyncError: error | ||
}); | ||
}), { | ||
_asyncValidating: false | ||
}); | ||
case _actionTypes.STOP_SUBMIT: | ||
return _extends({}, state, { | ||
submitting: false | ||
_submitting: false | ||
}); | ||
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, { | ||
touched: _extends({}, state.touched, touchDiff) | ||
}); | ||
return _extends({}, state, action.fields.reduce(function (accumulator, field) { | ||
var _extends5; | ||
return _extends({}, accumulator, (_extends5 = {}, _extends5[field] = _extends({}, state[field], { | ||
touched: true | ||
}), _extends5)); | ||
}, {})); | ||
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) | ||
}); | ||
return _extends({}, state, action.fields.reduce(function (accumulator, field) { | ||
var _extends6; | ||
return _extends({}, accumulator, (_extends6 = {}, _extends6[field] = _extends({}, state[field], { | ||
touched: false | ||
}), _extends6)); | ||
}, {})); | ||
default: | ||
@@ -132,3 +116,3 @@ return state; | ||
var _extends8; | ||
var _extends9; | ||
@@ -145,21 +129,50 @@ var action = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
if (key) { | ||
var _extends6, _extends7; | ||
var _extends7, _extends8; | ||
return _extends({}, state, (_extends7 = {}, _extends7[form] = _extends({}, state[form], (_extends6 = {}, _extends6[key] = reducer((state[form] || {})[key], rest), _extends6)), _extends7)); | ||
return _extends({}, state, (_extends8 = {}, _extends8[form] = _extends({}, state[form], (_extends7 = {}, _extends7[key] = reducer((state[form] || {})[key], rest), _extends7)), _extends8)); | ||
} | ||
return _extends({}, state, (_extends8 = {}, _extends8[form] = reducer(state[form], rest), _extends8)); | ||
return _extends({}, state, (_extends9 = {}, _extends9[form] = reducer(state[form], rest), _extends9)); | ||
} | ||
formReducer.plugin = function (reducers) { | ||
return function () { | ||
var state = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var action = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
/** | ||
* Adds additional functionality to the reducer | ||
*/ | ||
function decorate(target) { | ||
target.plugin = function plugin(reducers) { | ||
var _this = this; | ||
var result = formReducer(state, action); | ||
return _extends({}, result, _mapValues2['default'](reducers, function (red, key) { | ||
return red(result[key] || initialState, action); | ||
})); | ||
return decorate(function () { | ||
var state = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var action = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var result = _this(state, action); | ||
return _extends({}, result, _mapValues2['default'](reducers, function (red, key) { | ||
return red(result[key] || initialState, action); | ||
})); | ||
}); | ||
}; | ||
}; | ||
exports['default'] = formReducer; | ||
target.normalize = function normalize(normalizers) { | ||
var _this2 = this; | ||
return decorate(function () { | ||
var state = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var action = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var result = _this2(state, action); | ||
return _extends({}, result, _mapValues2['default'](normalizers, function (formNormalizers, form) { | ||
return _extends({}, result[form], _mapValues2['default'](formNormalizers, function (fieldNormalizer, field) { | ||
return _extends({}, result[form][field], { | ||
value: fieldNormalizer(result[form][field] ? result[form][field].value : undefined, // value | ||
state[form] && state[form][field] ? state[form][field].value : undefined, // previous value | ||
getValues(result[form])) // all field values | ||
}); | ||
})); | ||
})); | ||
}); | ||
}; | ||
return target; | ||
} | ||
exports['default'] = decorate(formReducer); |
@@ -5,6 +5,6 @@ 'use strict'; | ||
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; }; })(); | ||
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; }; | ||
exports['default'] = reduxForm; | ||
@@ -66,12 +66,18 @@ | ||
function silenceEvents(fn) { | ||
return function (event) { | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
if (event && event.preventDefault) { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
return fn.apply(undefined, args); | ||
} | ||
return fn.apply(undefined, [event].concat(args)); | ||
}; | ||
} | ||
function createReduxFormDecorator(formName, fields, syncValidate, touchOnBlur, touchOnChange, asyncValidate, asyncBlurFields) { | ||
function combineValidationErrors(form) { | ||
var syncErrors = syncValidate(form.data); | ||
var asyncErrors = _extends({ valid: true }, form.asyncErrors); | ||
var valid = !!(syncErrors.valid && asyncErrors.valid); // !! to convert falsy to boolean | ||
return _extends({}, syncErrors, asyncErrors, { | ||
valid: valid | ||
}); | ||
} | ||
return function (DecoratedComponent) { | ||
@@ -90,2 +96,3 @@ return (function (_Component) { | ||
// Read props | ||
var _props = this.props; | ||
@@ -102,2 +109,13 @@ var formName = _props.formName; | ||
// Calculate calculable state | ||
var allValid = true; | ||
var allPristine = true; | ||
var values = fields.reduce(function (accumulator, field) { | ||
var _extends2; | ||
return _extends({}, accumulator, (_extends2 = {}, _extends2[field] = subForm[field] ? subForm[field].value : undefined, _extends2)); | ||
}, {}); | ||
// Create actions | ||
var _ref = formKey ? _bindActionData2['default'](formActions, { form: formName, key: formKey }) : _bindActionData2['default'](formActions, { form: formName }); | ||
@@ -116,5 +134,5 @@ | ||
var runAsyncValidation = asyncValidate ? function () { | ||
function runAsyncValidation() { | ||
dispatch(startAsyncValidation(formKey)); | ||
var promise = asyncValidate(subForm.data); | ||
var promise = asyncValidate(values); | ||
if (!promise || typeof promise.then !== 'function') { | ||
@@ -126,4 +144,8 @@ throw new Error('asyncValidate function passed to reduxForm must return a promise!'); | ||
return !!asyncErrors.valid; | ||
}, function (err) { | ||
dispatch(stopAsyncValidation({})); | ||
throw new Error('redux-form: Asynchronous validation failed: ' + err); | ||
}); | ||
} : undefined; | ||
} | ||
var handleBlur = function handleBlur(name, value) { | ||
@@ -134,6 +156,6 @@ return function (event) { | ||
dispatch(doBlur(name, fieldValue)); | ||
if (runAsyncValidation && ~asyncBlurFields.indexOf(name)) { | ||
var _extends2; | ||
if (asyncValidate && ~asyncBlurFields.indexOf(name)) { | ||
var _extends3; | ||
var syncError = syncValidate(_extends({}, subForm.data, (_extends2 = {}, _extends2[name] = fieldValue, _extends2)))[name]; | ||
var syncError = syncValidate(_extends({}, values, (_extends3 = {}, _extends3[name] = fieldValue, _extends3)))[name]; | ||
// only dispatch async call if all synchronous client-side validation passes for this field | ||
@@ -146,10 +168,2 @@ if (!syncError) { | ||
}; | ||
var pristine = _util.isPristine(subForm.initial, subForm.data); | ||
var _combineValidationErrors = combineValidationErrors(subForm); | ||
var valid = _combineValidationErrors.valid; | ||
var errors = _objectWithoutProperties(_combineValidationErrors, ['valid']); | ||
var handleChange = function handleChange(name, value) { | ||
@@ -166,5 +180,6 @@ return function (event) { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
} | ||
var submitWithPromiseCheck = function submitWithPromiseCheck() { | ||
var result = submit(subForm.data); | ||
var result = submit(values); | ||
if (result && typeof result.then === 'function') { | ||
@@ -181,10 +196,11 @@ // you're showing real promise, kid! | ||
dispatch(touch.apply(undefined, fields)); | ||
if (runAsyncValidation) { | ||
return runAsyncValidation().then(function (asyncValid) { | ||
if (valid && asyncValid) { | ||
return submitWithPromiseCheck(subForm.data); | ||
} | ||
}); | ||
} else if (valid) { | ||
return submitWithPromiseCheck(subForm.data); | ||
if (allValid) { | ||
if (asyncValidate) { | ||
return runAsyncValidation().then(function (asyncValid) { | ||
if (allValid && asyncValid) { | ||
return submitWithPromiseCheck(values); | ||
} | ||
}); | ||
} | ||
return submitWithPromiseCheck(values); | ||
} | ||
@@ -203,51 +219,73 @@ }; | ||
}; | ||
return _react2['default'].createElement(DecoratedComponent, _extends({ | ||
asyncValidate: runAsyncValidation, | ||
asyncValidating: subForm.asyncValidating, | ||
data: subForm.data, | ||
dirty: !pristine, | ||
dispatch: dispatch, | ||
errors: errors, | ||
// Define fields | ||
var syncErrors = syncValidate(values); | ||
var allFields = fields.reduce(function (accumulator, name) { | ||
var _extends4; | ||
var field = subForm[name] || {}; | ||
var pristine = _util.isPristine(field.value, field.initial); | ||
var error = syncErrors[name] || field.asyncError; | ||
if (error) { | ||
allValid = false; | ||
} | ||
if (!pristine) { | ||
allPristine = false; | ||
} | ||
return _extends({}, accumulator, (_extends4 = {}, _extends4[name] = { | ||
checked: typeof field.value === 'boolean' ? field.value : undefined, | ||
dirty: !pristine, | ||
error: error, | ||
handleBlur: handleBlur(name), | ||
handleChange: handleChange(name), | ||
invalid: !!error, | ||
onBlur: handleBlur(name), | ||
onChange: handleChange(name), | ||
pristine: pristine, | ||
touched: field.touched, | ||
valid: !error, | ||
value: field.value | ||
}, _extends4)); | ||
}, {}); | ||
// Return decorated component | ||
return _react2['default'].createElement(DecoratedComponent, | ||
// State: | ||
_extends({ asyncValidating: subForm._asyncValidating, | ||
dirty: !allPristine, | ||
fields: allFields, | ||
formKey: formKey, | ||
handleBlur: handleBlur, | ||
handleChange: handleChange, | ||
handleSubmit: handleSubmit, | ||
initializeForm: function (data) { | ||
return dispatch(initialize(data)); | ||
}, | ||
invalid: !valid, | ||
isDirty: function (field) { | ||
return !_util.isPristine(subForm.data[field], subForm.initial[field]); | ||
}, | ||
isPristine: function (field) { | ||
return _util.isPristine(subForm.data[field], subForm.initial[field]); | ||
}, | ||
pristine: pristine, | ||
resetForm: function () { | ||
invalid: !allValid, | ||
pristine: allPristine, | ||
submitting: subForm._submitting, | ||
valid: allValid, | ||
values: values, | ||
// Actions: | ||
asyncValidate: silenceEvents(runAsyncValidation), | ||
handleBlur: silenceEvents(handleBlur), | ||
handleChange: silenceEvents(handleChange), | ||
handleSubmit: silenceEvents(handleSubmit), | ||
initializeForm: silenceEvents(function (initialValues) { | ||
return dispatch(initialize(initialValues)); | ||
}), | ||
resetForm: silenceEvents(function () { | ||
return dispatch(reset()); | ||
}, | ||
submitting: subForm.submitting, | ||
touch: function () { | ||
for (var _len = arguments.length, touchFields = Array(_len), _key = 0; _key < _len; _key++) { | ||
touchFields[_key] = arguments[_key]; | ||
} | ||
return dispatch(touch.apply(undefined, touchFields)); | ||
}, | ||
touched: subForm.touched, | ||
touchAll: function () { | ||
}), | ||
touch: silenceEvents(function () { | ||
return dispatch(touch.apply(undefined, arguments)); | ||
}), | ||
touchAll: silenceEvents(function () { | ||
return dispatch(touch.apply(undefined, fields)); | ||
}, | ||
untouch: function () { | ||
for (var _len2 = arguments.length, untouchFields = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
untouchFields[_key2] = arguments[_key2]; | ||
} | ||
}), | ||
untouch: silenceEvents(function () { | ||
return dispatch(untouch.apply(undefined, arguments)); | ||
}), | ||
untouchAll: silenceEvents(function () { | ||
return dispatch(untouchAll.apply(undefined, fields)); | ||
}), | ||
return dispatch(untouch.apply(undefined, untouchFields)); | ||
}, | ||
untouchAll: function () { | ||
return dispatch(untouchAll.apply(undefined, fields)); | ||
}, | ||
valid: valid | ||
}, passableProps)); // pass other props | ||
// Other: | ||
dispatch: dispatch | ||
}, passableProps)); | ||
}; | ||
@@ -295,4 +333,4 @@ | ||
decorator.async = function (asyncValidate) { | ||
for (var _len3 = arguments.length, blurFields = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { | ||
blurFields[_key3 - 1] = arguments[_key3]; | ||
for (var _len2 = arguments.length, blurFields = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
blurFields[_key2 - 1] = arguments[_key2]; | ||
} | ||
@@ -299,0 +337,0 @@ |
{ | ||
"name": "redux-form", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "A higher order component generator for forms using Redux and React", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
328
README.md
#redux-form | ||
--- | ||
[![NPM Version](https://img.shields.io/npm/v/redux-form.svg?style=flat-square)](https://www.npmjs.com/package/redux-form) | ||
[![NPM Downloads](https://img.shields.io/npm/dm/redux-form.svg?style=flat-square)](https://www.npmjs.com/package/redux-form) | ||
[![Build Status](https://img.shields.io/travis/erikras/redux-form/master.svg?style=flat-square)](https://travis-ci.org/erikras/redux-form) | ||
[![NPM Version](https://img.shields.io/npm/v/redux-form.svg?style=flat)](https://www.npmjs.com/package/redux-form) | ||
[![NPM Downloads](https://img.shields.io/npm/dm/redux-form.svg?style=flat)](https://www.npmjs.com/package/redux-form) | ||
[![Build Status](https://img.shields.io/travis/erikras/redux-form/master.svg?style=flat)](https://travis-ci.org/erikras/redux-form) | ||
[![devDependency Status](https://david-dm.org/erikras/redux-form/dev-status.svg)](https://david-dm.org/erikras/redux-form#info=devDependencies) | ||
[![redux-form channel on slack](https://img.shields.io/badge/slack-redux--form%40reactiflux-blue.svg)](http://www.reactiflux.com) | ||
[![PayPal donate button](http://img.shields.io/paypal/donate.png?color=yellowgreen)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3QQPTMLGV6GU2) | ||
@@ -27,2 +28,3 @@ `redux-form` works with [React Redux](https://github.com/gaearon/react-redux) to enable an html form in | ||
* [Responding to Other Actions](#responding-to-other-actions) | ||
* [Normalizing Form Data](#normalizing-form-data) | ||
* [Editing Multiple Records](#editing-multiple-records) | ||
@@ -38,2 +40,5 @@ * [Calculating `props` from Form Data](#calculating-props-from-form-data) | ||
* [`reduxForm().async()`](#reduxformasync) | ||
* [`reducer`](#reducer) | ||
* [`reducer.plugin(Object<String, Function>)`](#reducerpluginobjectstring-function) | ||
* [`reducer.normalize(Object<String, Function>)`](#reducerpluginobjectstring-function) | ||
* [`props`](#props) - The props passed in to your form component by `redux-form` | ||
@@ -109,10 +114,7 @@ * [Action Creators](#action-creators) - Advanced | ||
import {connectReduxForm} from 'redux-form'; | ||
import contactValidation from './contactValidation'; | ||
import validateContact from './validateContact'; | ||
class ContactForm extends Component { | ||
static propTypes = { | ||
data: PropTypes.object.isRequired, | ||
errors: PropTypes.object.isRequired, | ||
handleBlur: PropTypes.func.isRequired, | ||
handleChange: PropTypes.func.isRequired, | ||
fields: PropTypes.object.isRequired, | ||
handleSubmit: PropTypes.func.isRequired | ||
@@ -122,28 +124,16 @@ } | ||
render() { | ||
const { | ||
data: {name, address, phone}, | ||
errors, touched, handleBlur, handleChange, handleSubmit | ||
} = this.props; | ||
const { fields: {name, address, phone}, handleSubmit } = this.props; | ||
return ( | ||
<form onSubmit={handleSubmit}> | ||
<label>Name</label> | ||
<input type="text" | ||
value={name} | ||
onChange={handleChange('name')} | ||
onBlur={handleBlur('name')}/> | ||
{errors.name && touched.name ? <div>{errors.name}</div>} | ||
<input type="text" {...name}/> // will pass value, onBlur and onChange | ||
{name.error && name.touched ? <div>{name.error}</div>} | ||
<label>Address</label> | ||
<input type="text" | ||
value={address} | ||
onChange={handleChange('address')} | ||
onBlur={handleBlur('address')}/> | ||
{errors.address && touched.address ? <div>{errors.address}</div>} | ||
<input type="text" {...address}/> // will pass value, onBlur and onChange | ||
{address.error && addresss.touched ? <div>{address.error}</div>} | ||
<label>Phone</label> | ||
<input type="text" | ||
value={phone} | ||
onChange={handleChange('phone')} | ||
onBlur={handleBlur('phone')}/> | ||
{errors.phone && touched.phone ? <div>{errors.phone}</div>} | ||
<input type="text" {...phone}/> // will pass value, onBlur and onChange | ||
{phone.error && phone.touched ? <div>{phone.error}</div>} | ||
@@ -157,3 +147,10 @@ <button onClick={handleSubmit}>Submit</button> | ||
// apply connectReduxForm() and include synchronous validation | ||
ContactForm = connectReduxForm('contact', ['name', 'address', 'phone'], contactValidation)(ContactForm); | ||
ContactForm = connectReduxForm( | ||
// the name of your form and the key to where your form's state will be mounted | ||
'contact', | ||
// a list of all your fields in your form | ||
['name', 'address', 'phone'], | ||
// a synchronous validation function | ||
validateContact | ||
)(ContactForm); | ||
@@ -174,3 +171,3 @@ // export the wrapped component | ||
```javascript | ||
@connectReduxForm('contact', ['name', 'address', 'phone'], contactValidation) | ||
@connectReduxForm('contact', ['name', 'address', 'phone'], validateContact) | ||
export default class ContactForm extends Component { | ||
@@ -190,3 +187,3 @@ ``` | ||
```javascript | ||
function contactValidation(data) { | ||
function validateContact(data) { | ||
const errors = { valid: true }; | ||
@@ -224,7 +221,11 @@ if(!data.name) { | ||
// apply connectReduxForm() and include synchronous validation | ||
ContactForm = connectReduxForm('contact', ['name', 'address', 'phone'], contactValidation)(ContactForm); | ||
ContactForm = connectReduxForm( | ||
'contact', | ||
['name', 'address', 'phone'], | ||
validateContact | ||
)(ContactForm); | ||
``` | ||
...changes to this: | ||
```javascript | ||
function asyncValidation(data) { | ||
function validateContactAsync(data) { | ||
return new Promise((resolve, reject) => { | ||
@@ -238,4 +239,9 @@ const errors = {valid: true}; | ||
// apply connectReduxForm() and include synchronous AND asynchronous validation | ||
ContactForm = connectReduxForm('contact', ['name', 'address', 'phone'], contactValidation) | ||
.async(asyncValidation)(ContactForm); | ||
ContactForm = connectReduxForm( | ||
'contact', | ||
['name', 'address', 'phone'], | ||
validateContact | ||
).async( | ||
validateContactAsync | ||
)(ContactForm); | ||
``` | ||
@@ -249,4 +255,11 @@ | ||
// will only run async validation when 'name' or 'phone' is blurred | ||
ContactForm = connectReduxForm('contact', ['name', 'address', 'phone'], contactValidation) | ||
.async(asyncValidation, 'name', 'phone')(ContactForm); | ||
ContactForm = connectReduxForm( | ||
'contact', | ||
['name', 'address', 'phone'], | ||
validateContact | ||
).async( | ||
validateContactAsync, | ||
'name', | ||
'phone' | ||
)(ContactForm); | ||
``` | ||
@@ -259,3 +272,8 @@ With that call, the asynchronous validation will be called when either `name` or `phone` is blurred. | ||
```javascript | ||
ContactForm = connectReduxForm('contact', ['name', 'address', 'phone']).async(asyncValidation)(ContactForm); | ||
ContactForm = connectReduxForm( | ||
'contact', | ||
['name', 'address', 'phone'] | ||
).async( | ||
validateContactAsync | ||
)(ContactForm); | ||
``` | ||
@@ -338,3 +356,2 @@ | ||
import {AUTH_LOGIN_FAIL} from '../actions/actionTypes'; | ||
const loginFormReducer = createFormReducer('loginForm', ['email', 'password']); | ||
@@ -349,10 +366,3 @@ const reducers = { | ||
...state, | ||
data: { | ||
...state.data, | ||
password: '' // <----- clear password field | ||
}, | ||
touched: { | ||
...state.touched, | ||
password: false // <------ also set password to 'untouched' | ||
} | ||
password: {} // <----- clear password field | ||
}; | ||
@@ -369,2 +379,33 @@ default: | ||
### Normalizing Form Data | ||
Let's say that you have a form field that only accepts uppercase letters and another one where you want the value to | ||
be formatted in the `999-999-9999` United States phone number format. `redux-form` gives you a way to normalize your | ||
data on every action to the reducer by calling the `normalize()` function on the default reducer. | ||
```javascript | ||
import {reducer as formReducer} from 'redux-form'; | ||
const reducers = { | ||
// ... your other reducers here ... | ||
form: formReducer.normalize({ | ||
contact: { // <--- the form name | ||
licensePlate: (value, previousValue, allValues) => // <--- field normalizer | ||
value && value.toUpperCase(), | ||
phone: (value, previousValue, allValues) => { // <--- field normalizer | ||
if (value) { | ||
const match = value.match(/(\d{3})-?(\d{3})-?(\d{4})/); | ||
if (match) { | ||
return `${match[1]}-${match[2]}-${match[3]}`; | ||
} | ||
} | ||
return value; | ||
} | ||
} | ||
}) | ||
} | ||
const reducer = combineReducers(reducers); | ||
const store = createStore(reducer); | ||
``` | ||
### Editing Multiple Records | ||
@@ -445,8 +486,12 @@ | ||
ContactForm = mapProps({ | ||
hasName: props => !!props.data.name | ||
hasPhone: props => !!props.data.phone | ||
hasName: props => !!props.name.value | ||
hasPhone: props => !!props.phone.value | ||
})(ContactForm); | ||
// THEN apply connectReduxForm() and include synchronous validation | ||
ContactForm = connectReduxForm('contact', ['name', 'address', 'phone'], contactValidation)(ContactForm); | ||
ContactForm = connectReduxForm( | ||
'contact', | ||
['name', 'address', 'phone'], | ||
validateContact | ||
)(ContactForm); | ||
... | ||
@@ -456,9 +501,14 @@ ``` | ||
```javascript | ||
@connectReduxForm('contact', ['name', 'address', 'phone'], contactValidation) | ||
@connectReduxForm( | ||
'contact', | ||
['name', 'address', 'phone'], | ||
validateContact | ||
) | ||
@mapProps({ | ||
hasName: props => !!props.data.name | ||
hasPhone: props => !!props.data.phone | ||
hasName: props => !!props.name.value | ||
hasPhone: props => !!props.phone.value | ||
}) | ||
export default class ContactForm extends Component { | ||
``` | ||
--- | ||
@@ -479,3 +529,3 @@ ## Advanced Usage | ||
import reduxForm from 'redux-form'; | ||
import contactValidation from './contactValidation'; | ||
import validateContact from './validateContact'; | ||
@@ -487,8 +537,18 @@ class ContactForm extends Component { | ||
// apply reduxForm() and include synchronous validation | ||
ContactForm = reduxForm('contact', ['name', 'address', 'phone'], contactValidation)(ContactForm); | ||
// note: we're using reduxForm, not connectReduxForm | ||
ContactForm = reduxForm( | ||
'contact', | ||
['name', 'address', 'phone'], | ||
validateContact | ||
)(ContactForm); | ||
// ------- HERE'S THE IMPORTANT BIT ------- | ||
function mapStateToProps(state) { | ||
return { form: state.placeWhereYouMountedFormReducer }; | ||
function mapStateToProps(state, ownProps) { | ||
// this is React Redux API: https://github.com/rackt/react-redux | ||
// for example, you may use ownProps here to refer to the props passed from parent. | ||
return { | ||
form: state.placeWhereYouMountedFormReducer[ownProps.something] | ||
}; | ||
} | ||
// apply connect() to bind it to Redux state | ||
@@ -501,2 +561,4 @@ ContactForm = connect(mapStateToProps)(ContactForm); | ||
As you can see, `connectReduxForm()` is a tiny wrapper over `reduxForm()` that applies `connect()` for you. | ||
##### Binding Action Creators | ||
@@ -512,7 +574,13 @@ | ||
import {bindActionCreators} from `redux`; | ||
... | ||
function mapDispatchToProps(dispatch) { | ||
return bindActionCreators(actionCreators, dispatch); | ||
} | ||
ContactForm = connect(mapStateToProps, mapDispatchToProps)(ContactForm); | ||
ContactForm = connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(ContactForm); | ||
``` | ||
@@ -524,3 +592,5 @@ | ||
import {bindActionCreators} from `redux`; | ||
... | ||
function mapDispatchToProps(dispatch) { | ||
@@ -532,3 +602,7 @@ return { | ||
} | ||
ContactForm = connect(mapStateToProps, mapDispatchToProps)(ContactForm); | ||
ContactForm = connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(ContactForm); | ||
``` | ||
@@ -587,2 +661,31 @@ | ||
### `reducer` | ||
> The form reducer. Should be given to mounted to your Redux state at `form`. | ||
### `reducer.plugin(Object<String, Function>)` | ||
> Returns a form reducer that will also pass each action through additional reducers specified. The parameter should | ||
be an object mapping from `formName` to a `(state, action) => nextState` reducer. **The `state` passed to each reducer | ||
will only be the slice that pertains to that form.** See [Responding to Other Actions](#responding-to-other-actions). | ||
### `reducer.normalize(Object<String, Object<String, Function>>)` | ||
> Returns a form reducer that will also pass each form value through the normalizing functions provided. The | ||
parameter is an object mapping from `formName` to an object mapping from `fieldName` to a normalizer function. The | ||
normalizer function is given three parameters and expected to return the normalized value of the field. | ||
See [Normalizing Form Data](#normalizing-form-data). | ||
##### -`value : string` | ||
> The current value of the field | ||
##### -`previousValue : string` | ||
> The previous value of the field before the current action was dispatched | ||
##### -`allValues : Object<string, string>` | ||
> All the values of the current form | ||
### props | ||
@@ -592,32 +695,85 @@ | ||
##### -`asyncValidate : Function` | ||
#### -`asyncValidate : Function` | ||
> a function that may be called to initiate asynchronous validation if asynchronous validation is enabled | ||
##### -`asyncValidating : boolean` | ||
#### -`asyncValidating : boolean` | ||
> `true` if the asynchronous validation function has been called but has not yet returned. | ||
##### -`data : Object` | ||
#### -`dirty : boolean` | ||
> The form data, in the form `{ field1: <string>, field2: <string> }` | ||
> `true` if the form data has changed from its initialized values. Opposite of `pristine`. | ||
##### -`dirty : boolean` | ||
#### -`fields : Object` | ||
> `true` if the form data has changed from its initialized values. Opposite of `pristine`. | ||
> The form data, in the form `{ field1: <Object>, field2: <Object> }`, where each field `Object` has the following | ||
properties: | ||
##### -`errors : Object` | ||
##### ---`checked : boolean?` | ||
> All the errors, in the form `{ field1: <string>, field2: <string> }` | ||
> An alias for `value` _only when `value` is a boolean_. Provided for convenience of destructuring the whole field | ||
object into the props of a form element. | ||
##### -`handleBlur(field:string) : Function` | ||
##### ---`dirty : boolean` | ||
> Returns a `handleBlur` function for the field passed. | ||
> `true` if the field value has changed from its initialized value. Opposite of `pristine`. | ||
##### -`handleChange(field:string) : Function` | ||
##### ---`error : String?` | ||
> Returns a `handleChange` function for the field passed. | ||
> The error for this field if its value is not passing validation. Both synchronous and asynchronous validation | ||
errors will be reported here. | ||
##### -`handleSubmit : Function` | ||
##### ---`handleBlur : Function` | ||
> A function to call when the form field is blurred. It expects to receive the | ||
[React SyntheticEvent](http://facebook.github.io/react/docs/events.html) and is meant to be passed to the form | ||
element's `onBlur` prop. | ||
##### ---`handleChange : Function` | ||
> A function to call when the form field is blurred. It expects to receive the | ||
[React SyntheticEvent](http://facebook.github.io/react/docs/events.html) and is meant to be passed to the form | ||
element's `onChange` prop. | ||
##### ---`invalid : boolean` | ||
> `true` if the field value fails validation (has a validation error). Opposite of `valid`. | ||
##### ---`onBlur : Function` | ||
> An alias for `handleBlur`. Provided for convenience of destructuring the whole field object into the props of a | ||
form element. | ||
##### ---`onChange : Function` | ||
> An alias for `handleChange`. Provided for convenience of destructuring the whole field object into the props of a | ||
form element. | ||
##### ---`pristine : boolean` | ||
> `true` if the field value is the same as its initialized value. Opposite of `dirty`. | ||
##### ---`touched : boolean` | ||
> `true` if the field has been touched. | ||
##### ---`valid : boolean` | ||
> `true` if the field value passes validation (has no validation errors). Opposite of `invalid`. | ||
##### ---`value: any` | ||
> The value of this form field. It will be a boolean for checkboxes, and a string for all other input types. | ||
#### -`handleBlur(field:string) : Function` | ||
> Returns a `handleBlur` function for the field passed. `handleBlur('age')` returns `fields.age.handleBlur`. | ||
### -`handleChange(field:string) : Function` | ||
> Returns a `handleChange` function for the field passed. `handleChange('age')` returns `fields.age.handleChange`. | ||
#### -`handleSubmit : Function` | ||
> a function meant to be passed to `<form onSubmit={handleSubmit}>` or to `<button onClick={handleSubmit}>`. | ||
@@ -630,3 +786,3 @@ It will run validation, both sync and async, and, if the form is valid, it will call `this.props.onSubmit(data)` | ||
##### -`initializeForm(data:Object) : Function` | ||
#### -`initializeForm(data:Object) : Function` | ||
@@ -636,31 +792,19 @@ > Initializes the form data to the given values. All `dirty` and `pristine` state will be determined by | ||
##### -`invalid : boolean` | ||
#### -`invalid : boolean` | ||
> `true` if the form has validation errors. Opposite of `valid`. | ||
##### -`isDirty : Function` | ||
#### -`pristine: boolean` | ||
> a function that takes field name and returns whether or not that field is dirty (i.e. has a different value than | ||
the one passed in to `initialize`). Good for only showing errors when a field has changed | ||
(e.g. `{errors.name && touched.name && isDirty('name') && <div>{errors.name}</div>}`). | ||
Opposite of `isPristine`. | ||
##### -`isPristine : Function` | ||
> a function that takes field name and returns whether or not that field is pristine (i.e. has the same value that | ||
was passed in with `initialize`). Opposite of `isDirty`. | ||
##### -`pristine: boolean` | ||
> `true` if the form data is the same as its initialized values. Opposite of `dirty`. | ||
##### -`resetForm() : Function` | ||
#### -`resetForm() : Function` | ||
> Resets all the values in the form to the initialized state, making it pristine again. | ||
##### -`formKey : String` | ||
#### -`formKey : String` | ||
> The same `formKey` prop that was passed in. See [Editing Multiple Records](#editing-multiple-records). | ||
##### -`submitting : boolean` | ||
#### -`submitting : boolean` | ||
@@ -670,10 +814,6 @@ > Whether or not your form is currently submitting. This prop will only work if you have passed an | ||
##### -`touch(...field:string) : Function` | ||
#### -`touch(...field:string) : Function` | ||
> 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` | ||
@@ -680,0 +820,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
247642
2869
859