Comparing version 0.8.3 to 0.8.4
@@ -156,2 +156,5 @@ import { Component, createElement } from 'react'; | ||
_this.runValidations = function (values$$1) { | ||
if (validationSchema) { | ||
_this.runValidationSchema(values$$1); | ||
} | ||
if (validate) { | ||
@@ -168,5 +171,2 @@ var maybePromisedErrors = validate(values$$1, _this.props); | ||
} | ||
if (validationSchema) { | ||
_this.runValidationSchema(values$$1); | ||
} | ||
}; | ||
@@ -236,7 +236,8 @@ _this.handleChange = function (e) { | ||
else { | ||
var isValid = Object.keys(maybePromisedErrors).length === 0; | ||
_this.setState({ | ||
errors: maybePromisedErrors, | ||
isSubmitting: Object.keys(maybePromisedErrors).length > 0, | ||
isSubmitting: isValid, | ||
}); | ||
if (Object.keys(maybePromisedErrors).length === 0) { | ||
if (isValid) { | ||
_this.executeSubmit(); | ||
@@ -243,0 +244,0 @@ } |
@@ -159,2 +159,5 @@ 'use strict'; | ||
_this.runValidations = function (values$$1) { | ||
if (validationSchema) { | ||
_this.runValidationSchema(values$$1); | ||
} | ||
if (validate) { | ||
@@ -171,5 +174,2 @@ var maybePromisedErrors = validate(values$$1, _this.props); | ||
} | ||
if (validationSchema) { | ||
_this.runValidationSchema(values$$1); | ||
} | ||
}; | ||
@@ -239,7 +239,8 @@ _this.handleChange = function (e) { | ||
else { | ||
var isValid = Object.keys(maybePromisedErrors).length === 0; | ||
_this.setState({ | ||
errors: maybePromisedErrors, | ||
isSubmitting: Object.keys(maybePromisedErrors).length > 0, | ||
isSubmitting: isValid, | ||
}); | ||
if (Object.keys(maybePromisedErrors).length === 0) { | ||
if (isValid) { | ||
_this.executeSubmit(); | ||
@@ -246,0 +247,0 @@ } |
@@ -159,2 +159,5 @@ (function (global, factory) { | ||
_this.runValidations = function (values$$1) { | ||
if (validationSchema) { | ||
_this.runValidationSchema(values$$1); | ||
} | ||
if (validate) { | ||
@@ -171,5 +174,2 @@ var maybePromisedErrors = validate(values$$1, _this.props); | ||
} | ||
if (validationSchema) { | ||
_this.runValidationSchema(values$$1); | ||
} | ||
}; | ||
@@ -239,7 +239,8 @@ _this.handleChange = function (e) { | ||
else { | ||
var isValid = Object.keys(maybePromisedErrors).length === 0; | ||
_this.setState({ | ||
errors: maybePromisedErrors, | ||
isSubmitting: Object.keys(maybePromisedErrors).length > 0, | ||
isSubmitting: isValid, | ||
}); | ||
if (Object.keys(maybePromisedErrors).length === 0) { | ||
if (isValid) { | ||
_this.executeSubmit(); | ||
@@ -246,0 +247,0 @@ } |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e(t.Formik={},t.React)}(this,function(t,e){"use strict";function r(t,e){function r(){this.constructor=t}l(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function n(t){return null!==t&&"object"==typeof t&&(t&&"function"==typeof t.then)}function o(t){var e=[];for(var r in t)t.hasOwnProperty(r)&&e.push(t[r]);return e}function a(t,e,r){if("string"!=typeof e){if(v){var n=m(e);n&&n!==v&&a(t,n,r)}var o=S(e);f&&(o=o.concat(f(e)));for(var s=0;s<o.length;++s){var i=o[s];if(!(h[i]||r&&r[i])&&(p.call(e,i)||"function"==typeof e[i]))try{t[i]=e[i]}catch(t){}}return t}return t}function s(t){for(var e={},r=0,n=t.inner;r<n.length;r++){var o=n[r];e[o.path]||(e[o.path]=o.message)}return e}function i(t,e){var r={};for(var n in t)if(t.hasOwnProperty(n)){var o=String(n);r[o]=""!==t[o]?t[o]:void 0}return e.validate(r,{abortEarly:!1})}function u(t){for(var e={},r=0,n=Object.keys(t);r<n.length;r++)e[n[r]]=!0;return e}var l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},c=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},d="undefined"!=typeof window&&window.navigator&&window.navigator.product&&"ReactNative"===window.navigator.product,h={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},f=Object.getOwnPropertySymbols,p=Object.prototype.propertyIsEnumerable,m=Object.getPrototypeOf,v=m&&m(Object),S=Object.getOwnPropertyNames;t.Formik=function(t){var l=t.displayName,h=t.mapPropsToValues,f=void 0===h?function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&"function"!=typeof t[r]&&(e[r]=t[r]);return e}:h,p=t.mapValuesToPayload,m=t.validate,v=t.validationSchema,S=t.handleSubmit,b=t.validateOnChange,g=void 0!==b&&b,y=t.validateOnBlur,F=void 0===y||y;return function(t){var h=function(a){function l(t){var e=a.call(this,t)||this;return e.setErrors=function(t){e.setState({errors:t})},e.setTouched=function(t){e.setState({touched:t}),F&&e.runValidations(e.state.values)},e.setValues=function(t){e.setState({values:t}),g&&e.runValidations(t)},e.setStatus=function(t){e.setState({status:t})},e.setError=function(t){e.setState({error:t})},e.setSubmitting=function(t){e.setState({isSubmitting:t})},e.runValidationSchema=function(t,r){i(t,v).then(function(){e.setState({errors:{}}),r&&r()},function(t){return e.setState({errors:s(t),isSubmitting:!1})})},e.runValidations=function(t){if(m){var r=m(t,e.props);n(r)?m(t,e.props).then(function(){e.setState({errors:{}})},function(t){return e.setState({errors:t,isSubmitting:!1})}):e.setErrors(r)}v&&e.runValidationSchema(t)},e.handleChange=function(t){if(d)console.error("Warning: Formik's handleChange does not work with React Native. Use setFieldValue and within a callback instead. For more info see https://github.com/jaredpalmer/formikhttps://github.com/jaredpalmer/formik#react-native");else{t.persist();var r=t.target,n=r.type,o=r.name,a=r.id,s=r.value,i=r.checked,u=(r.outerHTML,o||a),l=/number|range/.test(n)?parseFloat(s):/checkbox/.test(n)?i:s;e.setState(function(t){return c({},t,{values:c({},t.values,(e={},e[u]=l,e))});var e}),g&&e.runValidations(c({},e.state.values,(h={},h[u]=s,h)));var h}},e.handleChangeValue=function(t,r){e.setState(function(e){return c({},e,{values:c({},e.values,(n={},n[t]=r,n)),touched:c({},e.touched,(o={},o[t]=!0,o))});var n,o}),e.runValidationSchema(c({},e.state.values,(n={},n[t]=r,n)));var n},e.setFieldValue=function(t,r){e.setState(function(e){return c({},e,{values:c({},e.values,(n={},n[t]=r,n))});var n}),g&&e.runValidations(c({},e.state.values,(n={},n[t]=r,n)));var n},e.handleSubmit=function(t){t.preventDefault(),e.submitForm()},e.submitForm=function(){if(e.setState({touched:u(e.state.values),isSubmitting:!0}),m){var t=m(e.state.values,e.props)||{};if(n(t))return void m(e.state.values,e.props).then(function(){e.setState({errors:{}}),e.executeSubmit()},function(t){return e.setState({errors:t,isSubmitting:!1})});e.setState({errors:t,isSubmitting:Object.keys(t).length>0}),0===Object.keys(t).length&&e.executeSubmit()}else v?e.runValidationSchema(e.state.values,e.executeSubmit):e.executeSubmit()},e.executeSubmit=function(){var t=p?p(e.state.values):e.state.values;S(t,{setStatus:e.setStatus,setTouched:e.setTouched,setErrors:e.setErrors,setError:e.setError,setValues:e.setValues,setFieldError:e.setFieldError,setFieldValue:e.setFieldValue,setFieldTouched:e.setFieldTouched,setSubmitting:e.setSubmitting,resetForm:e.resetForm,submitForm:e.submitForm,props:e.props})},e.handleBlur=function(t){if(d)console.error("Warning: Formik's handleBlur does not work with React Native. Use setFieldTouched(field, isTouched) within a callback instead. For more info see https://github.com/jaredpalmer/formik#setfieldtouched-field-string-istouched-boolean--void");else{t.persist();var r=t.target,n=r.name,o=r.id,a=n||o;e.setState(function(t){return{touched:c({},t.touched,(e={},e[a]=!0,e))};var e}),F&&e.runValidations(e.state.values)}},e.setFieldTouched=function(t,r){void 0===r&&(r=!0),e.setState(function(e){return c({},e,{touched:c({},e.touched,(n={},n[t]=r,n))});var n}),F&&e.runValidations(e.state.values)},e.setFieldError=function(t,r){e.setState(function(e){return c({},e,{errors:c({},e.errors,(n={},n[t]=r,n))});var n})},e.resetForm=function(t){e.setState({isSubmitting:!1,errors:{},touched:{},error:void 0,values:f(t||e.props)})},e.handleReset=function(){e.setState({isSubmitting:!1,errors:{},touched:{},error:void 0,values:f(e.props)})},e.state={values:f(t),errors:{},touched:{},isSubmitting:!1},p&&console.warn("Warning: Formik's mapValuesToPayload is deprecated and may be removed in future releases. Move that function to the first line of `handleSubmit` instead."),e}return r(l,a),l.prototype.render=function(){return e.createElement(t,c({},this.props,this.state,{dirty:o(this.state.touched).filter(Boolean).length>0,setStatus:this.setStatus,setError:this.setError,setFieldError:this.setFieldError,setErrors:this.setErrors,setSubmitting:this.setSubmitting,setTouched:this.setTouched,setFieldTouched:this.setFieldTouched,setValues:this.setValues,setFieldValue:this.setFieldValue,resetForm:this.resetForm,submitForm:this.submitForm,handleReset:this.handleReset,handleSubmit:this.handleSubmit,handleChange:this.handleChange,handleBlur:this.handleBlur,handleChangeValue:this.handleChangeValue}))},l}(e.Component);return h.displayName="Formik("+(l||t.displayName||t.name||"Component")+")",h.WrappedComponent=t,a(h,t)}},t.yupToFormErrors=s,t.validateYupSchema=i,t.touchAllFields=u,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e(t.Formik={},t.React)}(this,function(t,e){"use strict";function r(t,e){function r(){this.constructor=t}l(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function n(t){return null!==t&&"object"==typeof t&&(t&&"function"==typeof t.then)}function o(t){var e=[];for(var r in t)t.hasOwnProperty(r)&&e.push(t[r]);return e}function a(t,e,r){if("string"!=typeof e){if(v){var n=m(e);n&&n!==v&&a(t,n,r)}var o=S(e);f&&(o=o.concat(f(e)));for(var s=0;s<o.length;++s){var i=o[s];if(!(h[i]||r&&r[i])&&(p.call(e,i)||"function"==typeof e[i]))try{t[i]=e[i]}catch(t){}}return t}return t}function s(t){for(var e={},r=0,n=t.inner;r<n.length;r++){var o=n[r];e[o.path]||(e[o.path]=o.message)}return e}function i(t,e){var r={};for(var n in t)if(t.hasOwnProperty(n)){var o=String(n);r[o]=""!==t[o]?t[o]:void 0}return e.validate(r,{abortEarly:!1})}function u(t){for(var e={},r=0,n=Object.keys(t);r<n.length;r++)e[n[r]]=!0;return e}var l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},c=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},d="undefined"!=typeof window&&window.navigator&&window.navigator.product&&"ReactNative"===window.navigator.product,h={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},f=Object.getOwnPropertySymbols,p=Object.prototype.propertyIsEnumerable,m=Object.getPrototypeOf,v=m&&m(Object),S=Object.getOwnPropertyNames;t.Formik=function(t){var l=t.displayName,h=t.mapPropsToValues,f=void 0===h?function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&"function"!=typeof t[r]&&(e[r]=t[r]);return e}:h,p=t.mapValuesToPayload,m=t.validate,v=t.validationSchema,S=t.handleSubmit,b=t.validateOnChange,g=void 0!==b&&b,y=t.validateOnBlur,F=void 0===y||y;return function(t){var h=function(a){function l(t){var e=a.call(this,t)||this;return e.setErrors=function(t){e.setState({errors:t})},e.setTouched=function(t){e.setState({touched:t}),F&&e.runValidations(e.state.values)},e.setValues=function(t){e.setState({values:t}),g&&e.runValidations(t)},e.setStatus=function(t){e.setState({status:t})},e.setError=function(t){e.setState({error:t})},e.setSubmitting=function(t){e.setState({isSubmitting:t})},e.runValidationSchema=function(t,r){i(t,v).then(function(){e.setState({errors:{}}),r&&r()},function(t){return e.setState({errors:s(t),isSubmitting:!1})})},e.runValidations=function(t){if(v&&e.runValidationSchema(t),m){var r=m(t,e.props);n(r)?m(t,e.props).then(function(){e.setState({errors:{}})},function(t){return e.setState({errors:t,isSubmitting:!1})}):e.setErrors(r)}},e.handleChange=function(t){if(d)console.error("Warning: Formik's handleChange does not work with React Native. Use setFieldValue and within a callback instead. For more info see https://github.com/jaredpalmer/formikhttps://github.com/jaredpalmer/formik#react-native");else{t.persist();var r=t.target,n=r.type,o=r.name,a=r.id,s=r.value,i=r.checked,u=(r.outerHTML,o||a),l=/number|range/.test(n)?parseFloat(s):/checkbox/.test(n)?i:s;e.setState(function(t){return c({},t,{values:c({},t.values,(e={},e[u]=l,e))});var e}),g&&e.runValidations(c({},e.state.values,(h={},h[u]=s,h)));var h}},e.handleChangeValue=function(t,r){e.setState(function(e){return c({},e,{values:c({},e.values,(n={},n[t]=r,n)),touched:c({},e.touched,(o={},o[t]=!0,o))});var n,o}),e.runValidationSchema(c({},e.state.values,(n={},n[t]=r,n)));var n},e.setFieldValue=function(t,r){e.setState(function(e){return c({},e,{values:c({},e.values,(n={},n[t]=r,n))});var n}),g&&e.runValidations(c({},e.state.values,(n={},n[t]=r,n)));var n},e.handleSubmit=function(t){t.preventDefault(),e.submitForm()},e.submitForm=function(){if(e.setState({touched:u(e.state.values),isSubmitting:!0}),m){var t=m(e.state.values,e.props)||{};if(n(t))return void m(e.state.values,e.props).then(function(){e.setState({errors:{}}),e.executeSubmit()},function(t){return e.setState({errors:t,isSubmitting:!1})});var r=0===Object.keys(t).length;e.setState({errors:t,isSubmitting:r}),r&&e.executeSubmit()}else v?e.runValidationSchema(e.state.values,e.executeSubmit):e.executeSubmit()},e.executeSubmit=function(){var t=p?p(e.state.values):e.state.values;S(t,{setStatus:e.setStatus,setTouched:e.setTouched,setErrors:e.setErrors,setError:e.setError,setValues:e.setValues,setFieldError:e.setFieldError,setFieldValue:e.setFieldValue,setFieldTouched:e.setFieldTouched,setSubmitting:e.setSubmitting,resetForm:e.resetForm,submitForm:e.submitForm,props:e.props})},e.handleBlur=function(t){if(d)console.error("Warning: Formik's handleBlur does not work with React Native. Use setFieldTouched(field, isTouched) within a callback instead. For more info see https://github.com/jaredpalmer/formik#setfieldtouched-field-string-istouched-boolean--void");else{t.persist();var r=t.target,n=r.name,o=r.id,a=n||o;e.setState(function(t){return{touched:c({},t.touched,(e={},e[a]=!0,e))};var e}),F&&e.runValidations(e.state.values)}},e.setFieldTouched=function(t,r){void 0===r&&(r=!0),e.setState(function(e){return c({},e,{touched:c({},e.touched,(n={},n[t]=r,n))});var n}),F&&e.runValidations(e.state.values)},e.setFieldError=function(t,r){e.setState(function(e){return c({},e,{errors:c({},e.errors,(n={},n[t]=r,n))});var n})},e.resetForm=function(t){e.setState({isSubmitting:!1,errors:{},touched:{},error:void 0,values:f(t||e.props)})},e.handleReset=function(){e.setState({isSubmitting:!1,errors:{},touched:{},error:void 0,values:f(e.props)})},e.state={values:f(t),errors:{},touched:{},isSubmitting:!1},p&&console.warn("Warning: Formik's mapValuesToPayload is deprecated and may be removed in future releases. Move that function to the first line of `handleSubmit` instead."),e}return r(l,a),l.prototype.render=function(){return e.createElement(t,c({},this.props,this.state,{dirty:o(this.state.touched).filter(Boolean).length>0,setStatus:this.setStatus,setError:this.setError,setFieldError:this.setFieldError,setErrors:this.setErrors,setSubmitting:this.setSubmitting,setTouched:this.setTouched,setFieldTouched:this.setFieldTouched,setValues:this.setValues,setFieldValue:this.setFieldValue,resetForm:this.resetForm,submitForm:this.submitForm,handleReset:this.handleReset,handleSubmit:this.handleSubmit,handleChange:this.handleChange,handleBlur:this.handleBlur,handleChangeValue:this.handleChangeValue}))},l}(e.Component);return h.displayName="Formik("+(l||t.displayName||t.name||"Component")+")",h.WrappedComponent=t,a(h,t)}},t.yupToFormErrors=s,t.validateYupSchema=i,t.touchAllFields=u,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=formik.umd.min.js.map |
{ | ||
"name": "formik", | ||
"description": "Forms in React, without tears", | ||
"version": "0.8.3", | ||
"version": "0.8.4", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "author": "Jared Palmer <jared@palmer.net>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1232
259306