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

formik

Package Overview
Dependencies
Maintainers
1
Versions
212
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

formik - npm Package Compare versions

Comparing version 2.2.3 to 2.2.4

6

CHANGELOG.md
# formik
## 2.2.4
### Patch Changes
- [`199e77a`](https://github.com/formium/formik/commit/199e77a3f69e9886d88fc7114c37769cd365d9c6) [#2882](https://github.com/formium/formik/pull/2882) Thanks [@umidbekkarimov](https://github.com/umidbekkarimov)! - Validate `setFieldTouched` with high priority
## 2.2.3

@@ -4,0 +10,0 @@

2

dist/formik.cjs.production.min.js

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

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("react"),t=e(require("react-fast-compare")),n=e(require("deepmerge")),i=e(require("lodash/isPlainObject")),a=e(require("lodash/clone")),o=e(require("lodash/toPath")),u=e(require("tiny-warning")),s=require("scheduler"),l=e(require("hoist-non-react-statics")),c=e(require("lodash/cloneDeep"));function p(){return(p=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function d(e,r){e.prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r}function f(e,r){if(null==e)return{};var t,n,i={},a=Object.keys(e);for(n=0;n<a.length;n++)r.indexOf(t=a[n])>=0||(i[t]=e[t]);return i}function v(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var h=function(e){return Array.isArray(e)&&0===e.length},m=function(e){return"function"==typeof e},y=function(e){return null!==e&&"object"==typeof e},E=function(e){return String(Math.floor(Number(e)))===e},S=function(e){return"[object String]"===Object.prototype.toString.call(e)},T=function(e){return 0===r.Children.count(e)},b=function(e){return y(e)&&m(e.then)};function g(e,r,t,n){void 0===n&&(n=0);for(var i=o(r);e&&n<i.length;)e=e[i[n++]];return void 0===e?t:e}function F(e,r,t){for(var n=a(e),i=n,u=0,s=o(r);u<s.length-1;u++){var l=s[u],c=g(e,s.slice(0,u+1));if(c&&(y(c)||Array.isArray(c)))i=i[l]=a(c);else{var p=s[u+1];i=i[l]=E(p)&&Number(p)>=0?[]:{}}}return(0===u?e:i)[s[u]]===t?e:(void 0===t?delete i[s[u]]:i[s[u]]=t,0===u&&void 0===t&&delete n[s[u]],n)}function _(e,r,t,n){void 0===t&&(t=new WeakMap),void 0===n&&(n={});for(var i=0,a=Object.keys(e);i<a.length;i++){var o=a[i],u=e[o];y(u)?t.get(u)||(t.set(u,!0),n[o]=Array.isArray(u)?[]:{},_(u,r,t,n[o])):n[o]=r}return n}var k=r.createContext(void 0),R=k.Provider,O=k.Consumer;function A(){var e=r.useContext(k);return e||u(!1),e}function I(e,r){switch(r.type){case"SET_VALUES":return p({},e,{values:r.payload});case"SET_TOUCHED":return p({},e,{touched:r.payload});case"SET_ERRORS":return t(e.errors,r.payload)?e:p({},e,{errors:r.payload});case"SET_LOW_PRIORITY_ERRORS":return t(e.errors,r.payload.errors)||!t(e.values,r.payload.values)?e:p({},e,{errors:r.payload.errors});case"SET_STATUS":return p({},e,{status:r.payload});case"SET_ISSUBMITTING":return p({},e,{isSubmitting:r.payload});case"SET_ISVALIDATING":return p({},e,{isValidating:r.payload});case"SET_FIELD_VALUE":return p({},e,{values:F(e.values,r.payload.field,r.payload.value)});case"SET_FIELD_TOUCHED":return p({},e,{touched:F(e.touched,r.payload.field,r.payload.value)});case"SET_FIELD_ERROR":return p({},e,{errors:F(e.errors,r.payload.field,r.payload.value)});case"RESET_FORM":return p({},e,r.payload);case"SET_FORMIK_STATE":return r.payload(e);case"SUBMIT_ATTEMPT":return p({},e,{touched:_(e.values,!0),isSubmitting:!0,submitCount:e.submitCount+1});case"SUBMIT_FAILURE":case"SUBMIT_SUCCESS":return p({},e,{isSubmitting:!1});default:return e}}var C={},P={};function x(e){var i=e.validateOnChange,a=void 0===i||i,o=e.validateOnBlur,u=void 0===o||o,l=e.validateOnMount,c=void 0!==l&&l,d=e.isInitialValid,v=e.enableReinitialize,h=void 0!==v&&v,E=e.onSubmit,T=f(e,["validateOnChange","validateOnBlur","validateOnMount","isInitialValid","enableReinitialize","onSubmit"]),_=p({validateOnChange:a,validateOnBlur:u,validateOnMount:c,onSubmit:E},T),k=r.useRef(_.initialValues),R=r.useRef(_.initialErrors||C),O=r.useRef(_.initialTouched||P),A=r.useRef(_.initialStatus),x=r.useRef(!1),U=r.useRef({});r.useEffect((function(){return x.current=!0,function(){x.current=!1}}),[]);var M=r.useReducer(I,{values:_.initialValues,errors:_.initialErrors||C,touched:_.initialTouched||P,status:_.initialStatus,isSubmitting:!1,isValidating:!1,submitCount:0}),L=M[0],N=M[1],B=r.useCallback((function(e,r){return new Promise((function(t,n){var i=_.validate(e,r);null==i?t(C):b(i)?i.then((function(e){t(e||C)}),(function(e){n(e)})):t(i)}))}),[_.validate]),q=r.useCallback((function(e,r){var t=_.validationSchema,n=m(t)?t(r):t,i=r&&n.validateAt?n.validateAt(r,e):D(e,n);return new Promise((function(e,r){i.then((function(){e(C)}),(function(t){"ValidationError"===t.name?e(V(t)):r(t)}))}))}),[_.validationSchema]),W=r.useCallback((function(e,r){return new Promise((function(t){return t(U.current[e].validate(r))}))}),[]),G=r.useCallback((function(e){var r=Object.keys(U.current).filter((function(e){return m(U.current[e].validate)})),t=r.length>0?r.map((function(r){return W(r,g(e,r))})):[Promise.resolve("DO_NOT_DELETE_YOU_WILL_BE_FIRED")];return Promise.all(t).then((function(e){return e.reduce((function(e,t,n){return"DO_NOT_DELETE_YOU_WILL_BE_FIRED"===t?e:(t&&(e=F(e,r[n],t)),e)}),{})}))}),[W]),H=r.useCallback((function(e){return Promise.all([G(e),_.validationSchema?q(e):{},_.validate?B(e):{}]).then((function(e){return n.all([e[0],e[1],e[2]],{arrayMerge:w})}))}),[_.validate,_.validationSchema,G,B,q]),Y=j((function(e){return void 0===e&&(e=L.values),r=function(){return H(e).then((function(r){return x.current&&N({type:"SET_LOW_PRIORITY_ERRORS",payload:{values:e,errors:r}}),r})).catch((function(e){}))},s.unstable_runWithPriority(s.unstable_LowPriority,(function(){return s.unstable_scheduleCallback(s.unstable_LowPriority,r)}));var r})),K=j((function(e){return void 0===e&&(e=L.values),N({type:"SET_ISVALIDATING",payload:!0}),H(e).then((function(e){return x.current&&(N({type:"SET_ISVALIDATING",payload:!1}),t(L.errors,e)||N({type:"SET_ERRORS",payload:e})),e}))}));r.useEffect((function(){c&&!0===x.current&&t(k.current,_.initialValues)&&Y(k.current)}),[c,Y]);var z=r.useCallback((function(e){var r=e&&e.values?e.values:k.current,t=e&&e.errors?e.errors:R.current?R.current:_.initialErrors||{},n=e&&e.touched?e.touched:O.current?O.current:_.initialTouched||{},i=e&&e.status?e.status:A.current?A.current:_.initialStatus;k.current=r,R.current=t,O.current=n,A.current=i;var a=function(){N({type:"RESET_FORM",payload:{isSubmitting:!!e&&!!e.isSubmitting,errors:t,touched:n,status:i,values:r,isValidating:!!e&&!!e.isValidating,submitCount:e&&e.submitCount&&"number"==typeof e.submitCount?e.submitCount:0}})};if(_.onReset){var o=_.onReset(L.values,fe);b(o)?o.then(a):a()}else a()}),[_.initialErrors,_.initialStatus,_.initialTouched]);r.useEffect((function(){!0!==x.current||t(k.current,_.initialValues)||(h&&(k.current=_.initialValues,z()),c&&Y(k.current))}),[h,_.initialValues,z,c,Y]),r.useEffect((function(){h&&!0===x.current&&!t(R.current,_.initialErrors)&&(R.current=_.initialErrors||C,N({type:"SET_ERRORS",payload:_.initialErrors||C}))}),[h,_.initialErrors]),r.useEffect((function(){h&&!0===x.current&&!t(O.current,_.initialTouched)&&(O.current=_.initialTouched||P,N({type:"SET_TOUCHED",payload:_.initialTouched||P}))}),[h,_.initialTouched]),r.useEffect((function(){h&&!0===x.current&&!t(A.current,_.initialStatus)&&(A.current=_.initialStatus,N({type:"SET_STATUS",payload:_.initialStatus}))}),[h,_.initialStatus,_.initialTouched]);var J=j((function(e){if(U.current[e]&&m(U.current[e].validate)){var r=g(L.values,e),t=U.current[e].validate(r);return b(t)?(N({type:"SET_ISVALIDATING",payload:!0}),t.then((function(e){return e})).then((function(r){N({type:"SET_FIELD_ERROR",payload:{field:e,value:r}}),N({type:"SET_ISVALIDATING",payload:!1})}))):(N({type:"SET_FIELD_ERROR",payload:{field:e,value:t}}),Promise.resolve(t))}return _.validationSchema?(N({type:"SET_ISVALIDATING",payload:!0}),q(L.values,e).then((function(e){return e})).then((function(r){N({type:"SET_FIELD_ERROR",payload:{field:e,value:r[e]}}),N({type:"SET_ISVALIDATING",payload:!1})}))):Promise.resolve()})),Q=r.useCallback((function(e,r){U.current[e]={validate:r.validate}}),[]),X=r.useCallback((function(e){delete U.current[e]}),[]),Z=j((function(e,r){return N({type:"SET_TOUCHED",payload:e}),(void 0===r?u:r)?Y(L.values):Promise.resolve()})),$=r.useCallback((function(e){N({type:"SET_ERRORS",payload:e})}),[]),ee=j((function(e,r){var t=m(e)?e(L.values):e;return N({type:"SET_VALUES",payload:t}),(void 0===r?a:r)?Y(t):Promise.resolve()})),re=r.useCallback((function(e,r){N({type:"SET_FIELD_ERROR",payload:{field:e,value:r}})}),[]),te=j((function(e,r,t){return N({type:"SET_FIELD_VALUE",payload:{field:e,value:r}}),(void 0===t?a:t)?Y(F(L.values,e,r)):Promise.resolve()})),ne=r.useCallback((function(e,r){var t,n=r,i=e;if(!S(e)){e.persist&&e.persist();var a=e.target?e.target:e.currentTarget,o=a.type,u=a.value,s=a.checked,l=a.options,c=a.multiple;n=r||a.name||a.id,i=/number|range/.test(o)?(t=parseFloat(u),isNaN(t)?"":t):/checkbox/.test(o)?function(e,r,t){if("boolean"==typeof e)return Boolean(r);var n=[],i=!1,a=-1;if(Array.isArray(e))n=e,i=(a=e.indexOf(t))>=0;else if(!t||"true"==t||"false"==t)return Boolean(r);return r&&t&&!i?n.concat(t):i?n.slice(0,a).concat(n.slice(a+1)):n}(g(L.values,n),s,u):c?function(e){return Array.from(e).filter((function(e){return e.selected})).map((function(e){return e.value}))}(l):u}n&&te(n,i)}),[te,L.values]),ie=j((function(e){if(S(e))return function(r){return ne(r,e)};ne(e)})),ae=j((function(e,r,t){return void 0===r&&(r=!0),N({type:"SET_FIELD_TOUCHED",payload:{field:e,value:r}}),(void 0===t?u:t)?Y(L.values):Promise.resolve()})),oe=r.useCallback((function(e,r){e.persist&&e.persist();var t=e.target;ae(r||t.name||t.id,!0)}),[ae]),ue=j((function(e){if(S(e))return function(r){return oe(r,e)};oe(e)})),se=r.useCallback((function(e){m(e)?N({type:"SET_FORMIK_STATE",payload:e}):N({type:"SET_FORMIK_STATE",payload:function(){return e}})}),[]),le=r.useCallback((function(e){N({type:"SET_STATUS",payload:e})}),[]),ce=r.useCallback((function(e){N({type:"SET_ISSUBMITTING",payload:e})}),[]),pe=j((function(){return N({type:"SUBMIT_ATTEMPT"}),K().then((function(e){var r=e instanceof Error;if(!r&&0===Object.keys(e).length){var t;try{if(void 0===(t=ve()))return}catch(e){throw e}return Promise.resolve(t).then((function(e){return x.current&&N({type:"SUBMIT_SUCCESS"}),e})).catch((function(e){if(x.current)throw N({type:"SUBMIT_FAILURE"}),e}))}if(x.current&&(N({type:"SUBMIT_FAILURE"}),r))throw e}))})),de=j((function(e){e&&e.preventDefault&&m(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&m(e.stopPropagation)&&e.stopPropagation(),pe().catch((function(e){console.warn("Warning: An unhandled error was caught from submitForm()",e)}))})),fe={resetForm:z,validateForm:K,validateField:J,setErrors:$,setFieldError:re,setFieldTouched:ae,setFieldValue:te,setStatus:le,setSubmitting:ce,setTouched:Z,setValues:ee,setFormikState:se,submitForm:pe},ve=j((function(){return E(L.values,fe)})),he=j((function(e){e&&e.preventDefault&&m(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&m(e.stopPropagation)&&e.stopPropagation(),z()})),me=r.useCallback((function(e){return{value:g(L.values,e),error:g(L.errors,e),touched:!!g(L.touched,e),initialValue:g(k.current,e),initialTouched:!!g(O.current,e),initialError:g(R.current,e)}}),[L.errors,L.touched,L.values]),ye=r.useCallback((function(e){return{setValue:function(r,t){return te(e,r,t)},setTouched:function(r,t){return ae(e,r,t)},setError:function(r){return re(e,r)}}}),[te,ae,re]),Ee=r.useCallback((function(e){var r=y(e),t=r?e.name:e,n=g(L.values,t),i={name:t,value:n,onChange:ie,onBlur:ue};if(r){var a=e.type,o=e.value,u=e.as,s=e.multiple;"checkbox"===a?void 0===o?i.checked=!!n:(i.checked=!(!Array.isArray(n)||!~n.indexOf(o)),i.value=o):"radio"===a?(i.checked=n===o,i.value=o):"select"===u&&s&&(i.value=i.value||[],i.multiple=!0)}return i}),[ue,ie,L.values]),Se=r.useMemo((function(){return!t(k.current,L.values)}),[k.current,L.values]),Te=r.useMemo((function(){return void 0!==d?Se?L.errors&&0===Object.keys(L.errors).length:!1!==d&&m(d)?d(_):d:L.errors&&0===Object.keys(L.errors).length}),[d,Se,L.errors,_]);return p({},L,{initialValues:k.current,initialErrors:R.current,initialTouched:O.current,initialStatus:A.current,handleBlur:ue,handleChange:ie,handleReset:he,handleSubmit:de,resetForm:z,setErrors:$,setFormikState:se,setFieldTouched:ae,setFieldValue:te,setFieldError:re,setStatus:le,setSubmitting:ce,setTouched:Z,setValues:ee,submitForm:pe,validateForm:K,validateField:J,isValid:Te,dirty:Se,unregisterField:X,registerField:Q,getFieldProps:Ee,getFieldMeta:me,getFieldHelpers:ye,validateOnBlur:u,validateOnChange:a,validateOnMount:c})}function U(e){var t=x(e),n=e.component,i=e.children,a=e.render;return r.useImperativeHandle(e.innerRef,(function(){return t})),r.createElement(R,{value:t},n?r.createElement(n,t):a?a(t):i?m(i)?i(t):T(i)?null:r.Children.only(i):null)}function V(e){var r={};if(e.inner){if(0===e.inner.length)return F(r,e.path,e.message);var t=e.inner,n=Array.isArray(t),i=0;for(t=n?t:t[Symbol.iterator]();;){var a;if(n){if(i>=t.length)break;a=t[i++]}else{if((i=t.next()).done)break;a=i.value}var o=a;g(r,o.path)||(r=F(r,o.path,o.message))}}return r}function D(e,r,t,n){void 0===t&&(t=!1),void 0===n&&(n={});var i=M(e);return r[t?"validateSync":"validate"](i,{abortEarly:!1,context:n})}function M(e){var r=Array.isArray(e)?[]:{};for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var n=String(t);r[n]=!0===Array.isArray(e[n])?e[n].map((function(e){return!0===Array.isArray(e)||i(e)?M(e):""!==e?e:void 0})):i(e[n])?M(e[n]):""!==e[n]?e[n]:void 0}return r}function w(e,r,t){var i=e.slice();return r.forEach((function(r,a){if(void 0===i[a]){var o=!1!==t.clone&&t.isMergeableObject(r);i[a]=o?n(Array.isArray(r)?[]:{},r,t):r}else t.isMergeableObject(r)?i[a]=n(e[a],r,t):-1===e.indexOf(r)&&i.push(r)})),i}var L="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?r.useLayoutEffect:r.useEffect;function j(e){var t=r.useRef(e);return L((function(){t.current=e})),r.useCallback((function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return t.current.apply(void 0,r)}),[])}var N=r.forwardRef((function(e,t){var n=e.action,i=f(e,["action"]),a=n||"#",o=A();return r.createElement("form",Object.assign({onSubmit:o.handleSubmit,ref:t,onReset:o.handleReset,action:a},i))}));function B(e){var t=function(t){return r.createElement(O,null,(function(n){return n||u(!1),r.createElement(e,Object.assign({},t,{formik:n}))}))},n=e.displayName||e.name||e.constructor&&e.constructor.name||"Component";return t.WrappedComponent=e,t.displayName="FormikConnect("+n+")",l(t,e)}N.displayName="Form";var q=function(e,r,t){var n=Y(e),i=n[r];return n.splice(r,1),n.splice(t,0,i),n},W=function(e,r,t){var n=Y(e),i=n[r];return n[r]=n[t],n[t]=i,n},G=function(e,r,t){var n=Y(e);return n.splice(r,0,t),n},H=function(e,r,t){var n=Y(e);return n[r]=t,n},Y=function(e){if(e){if(Array.isArray(e))return[].concat(e);var r=Object.keys(e).map((function(e){return parseInt(e)})).reduce((function(e,r){return r>e?r:e}),0);return Array.from(p({},e,{length:r+1}))}return[]},K=function(e){function n(r){var t;return(t=e.call(this,r)||this).updateArrayField=function(e,r,n){var i=t.props,a=i.name;(0,i.formik.setFormikState)((function(t){var i="function"==typeof n?n:e,o="function"==typeof r?r:e,u=F(t.values,a,e(g(t.values,a))),s=n?i(g(t.errors,a)):void 0,l=r?o(g(t.touched,a)):void 0;return h(s)&&(s=void 0),h(l)&&(l=void 0),p({},t,{values:u,errors:n?F(t.errors,a,s):t.errors,touched:r?F(t.touched,a,l):t.touched})}))},t.push=function(e){return t.updateArrayField((function(r){return[].concat(Y(r),[c(e)])}),!1,!1)},t.handlePush=function(e){return function(){return t.push(e)}},t.swap=function(e,r){return t.updateArrayField((function(t){return W(t,e,r)}),!0,!0)},t.handleSwap=function(e,r){return function(){return t.swap(e,r)}},t.move=function(e,r){return t.updateArrayField((function(t){return q(t,e,r)}),!0,!0)},t.handleMove=function(e,r){return function(){return t.move(e,r)}},t.insert=function(e,r){return t.updateArrayField((function(t){return G(t,e,r)}),(function(r){return G(r,e,null)}),(function(r){return G(r,e,null)}))},t.handleInsert=function(e,r){return function(){return t.insert(e,r)}},t.replace=function(e,r){return t.updateArrayField((function(t){return H(t,e,r)}),!1,!1)},t.handleReplace=function(e,r){return function(){return t.replace(e,r)}},t.unshift=function(e){var r=-1;return t.updateArrayField((function(t){var n=t?[e].concat(t):[e];return r<0&&(r=n.length),n}),(function(e){var t=e?[null].concat(e):[null];return r<0&&(r=t.length),t}),(function(e){var t=e?[null].concat(e):[null];return r<0&&(r=t.length),t})),r},t.handleUnshift=function(e){return function(){return t.unshift(e)}},t.handleRemove=function(e){return function(){return t.remove(e)}},t.handlePop=function(){return function(){return t.pop()}},t.remove=t.remove.bind(v(t)),t.pop=t.pop.bind(v(t)),t}d(n,e);var i=n.prototype;return i.componentDidUpdate=function(e){this.props.validateOnChange&&this.props.formik.validateOnChange&&!t(g(e.formik.values,e.name),g(this.props.formik.values,this.props.name))&&this.props.formik.validateForm(this.props.formik.values)},i.remove=function(e){var r;return this.updateArrayField((function(t){var n=t?Y(t):[];return r||(r=n[e]),m(n.splice)&&n.splice(e,1),n}),!0,!0),r},i.pop=function(){var e;return this.updateArrayField((function(r){var t=r;return e||(e=t&&t.pop&&t.pop()),t}),!0,!0),e},i.render=function(){var e=this.props,t=e.component,n=e.render,i=e.children,a=e.name,o=p({},{push:this.push,pop:this.pop,swap:this.swap,move:this.move,insert:this.insert,replace:this.replace,unshift:this.unshift,remove:this.remove,handlePush:this.handlePush,handlePop:this.handlePop,handleSwap:this.handleSwap,handleMove:this.handleMove,handleInsert:this.handleInsert,handleReplace:this.handleReplace,handleUnshift:this.handleUnshift,handleRemove:this.handleRemove},{form:f(e.formik,["validate","validationSchema"]),name:a});return t?r.createElement(t,o):n?n(o):i?"function"==typeof i?i(o):T(i)?null:r.Children.only(i):null},n}(r.Component);K.defaultProps={validateOnChange:!0};var z=B(K),J=B(function(e){function t(){return e.apply(this,arguments)||this}d(t,e);var n=t.prototype;return n.shouldComponentUpdate=function(e){return g(this.props.formik.errors,this.props.name)!==g(e.formik.errors,this.props.name)||g(this.props.formik.touched,this.props.name)!==g(e.formik.touched,this.props.name)||Object.keys(this.props).length!==Object.keys(e).length},n.render=function(){var e=this.props,t=e.component,n=e.formik,i=e.render,a=e.children,o=e.name,u=f(e,["component","formik","render","children","name"]),s=g(n.touched,o),l=g(n.errors,o);return s&&l?i?m(i)?i(l):null:a?m(a)?a(l):null:t?r.createElement(t,u,l):l:null},t}(r.Component)),Q=B(function(e){function t(r){var t;t=e.call(this,r)||this;var n=r.render,i=r.children,a=r.component,o=r.as;return n&&u(!1),a&&n&&u(!1),o&&i&&m(i)&&u(!1),a&&i&&m(i)&&u(!1),n&&i&&!T(i)&&u(!1),t}d(t,e);var n=t.prototype;return n.shouldComponentUpdate=function(e){return this.props.shouldUpdate?this.props.shouldUpdate(e,this.props):e.name!==this.props.name||g(e.formik.values,this.props.name)!==g(this.props.formik.values,this.props.name)||g(e.formik.errors,this.props.name)!==g(this.props.formik.errors,this.props.name)||g(e.formik.touched,this.props.name)!==g(this.props.formik.touched,this.props.name)||Object.keys(this.props).length!==Object.keys(e).length||e.formik.isSubmitting!==this.props.formik.isSubmitting},n.componentDidMount=function(){this.props.formik.registerField(this.props.name,{validate:this.props.validate})},n.componentDidUpdate=function(e){this.props.name!==e.name&&(this.props.formik.unregisterField(e.name),this.props.formik.registerField(this.props.name,{validate:this.props.validate})),this.props.validate!==e.validate&&this.props.formik.registerField(this.props.name,{validate:this.props.validate})},n.componentWillUnmount=function(){this.props.formik.unregisterField(this.props.name)},n.render=function(){var e=this.props,t=e.name,n=e.render,i=e.as,a=e.children,o=e.component,u=e.formik,s=f(e,["validate","name","render","as","children","component","shouldUpdate","formik"]),l=f(u,["validate","validationSchema"]),c=u.getFieldProps(p({name:t},s)),d={field:c,meta:{value:g(u.values,t),error:g(u.errors,t),touched:!!g(u.touched,t),initialValue:g(u.initialValues,t),initialTouched:!!g(u.initialTouched,t),initialError:g(u.initialErrors,t)},form:l};if(n)return n(d);if(m(a))return a(d);if(o){if("string"==typeof o){var v=s.innerRef,h=f(s,["innerRef"]);return r.createElement(o,p({ref:v},c,h),a)}return r.createElement(o,p({field:c,form:u},s),a)}var y=i||"input";if("string"==typeof y){var E=s.innerRef,S=f(s,["innerRef"]);return r.createElement(y,p({ref:E},c,S),a)}return r.createElement(y,p({},c,s),a)},t}(r.Component));exports.ErrorMessage=J,exports.FastField=Q,exports.Field=function(e){var t=e.validate,n=e.name,i=e.render,a=e.children,o=e.as,u=e.component,s=f(e,["validate","name","render","children","as","component"]),l=f(A(),["validate","validationSchema"]),c=l.registerField,d=l.unregisterField;r.useEffect((function(){return c(n,{validate:t}),function(){d(n)}}),[c,d,n,t]);var v=l.getFieldProps(p({name:n},s)),h=l.getFieldMeta(n),y={field:v,form:l};if(i)return i(p({},y,{meta:h}));if(m(a))return a(p({},y,{meta:h}));if(u){if("string"==typeof u){var E=s.innerRef,S=f(s,["innerRef"]);return r.createElement(u,p({ref:E},v,S),a)}return r.createElement(u,p({field:v,form:l},s),a)}var T=o||"input";if("string"==typeof T){var b=s.innerRef,g=f(s,["innerRef"]);return r.createElement(T,p({ref:b},v,g),a)}return r.createElement(T,p({},v,s),a)},exports.FieldArray=z,exports.Form=N,exports.Formik=U,exports.FormikConsumer=O,exports.FormikContext=k,exports.FormikProvider=R,exports.connect=B,exports.getActiveElement=function(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(r){return e.body}},exports.getIn=g,exports.insert=G,exports.isEmptyArray=h,exports.isEmptyChildren=T,exports.isFunction=m,exports.isInputEvent=function(e){return e&&y(e)&&y(e.target)},exports.isInteger=E,exports.isNaN=function(e){return e!=e},exports.isObject=y,exports.isPromise=b,exports.isString=S,exports.move=q,exports.prepareDataForValidation=M,exports.replace=H,exports.setIn=F,exports.setNestedObjectValues=_,exports.swap=W,exports.useField=function(e){var t=A(),n=t.getFieldProps,i=t.getFieldMeta,a=t.getFieldHelpers,o=t.registerField,s=t.unregisterField,l=y(e)?e:{name:e},c=l.name,p=l.validate;return r.useEffect((function(){return c&&o(c,{validate:p}),function(){c&&s(c)}}),[o,s,c,p]),c||u(!1),[n(l),i(c),a(c)]},exports.useFormik=x,exports.useFormikContext=A,exports.validateYupSchema=D,exports.withFormik=function(e){var t=e.mapPropsToValues,n=void 0===t?function(e){var r={};for(var t in e)e.hasOwnProperty(t)&&"function"!=typeof e[t]&&(r[t]=e[t]);return r}:t,i=f(e,["mapPropsToValues"]);return function(e){var t=e.displayName||e.name||e.constructor&&e.constructor.name||"Component",a=function(t){function a(){var n;return(n=t.apply(this,arguments)||this).validate=function(e){return i.validate(e,n.props)},n.validationSchema=function(){return m(i.validationSchema)?i.validationSchema(n.props):i.validationSchema},n.handleSubmit=function(e,r){return i.handleSubmit(e,p({},r,{props:n.props}))},n.renderFormComponent=function(t){return r.createElement(e,Object.assign({},n.props,t))},n}return d(a,t),a.prototype.render=function(){var e=f(this.props,["children"]);return r.createElement(U,Object.assign({},e,i,{validate:i.validate&&this.validate,validationSchema:i.validationSchema&&this.validationSchema,initialValues:n(this.props),initialStatus:i.mapPropsToStatus&&i.mapPropsToStatus(this.props),initialErrors:i.mapPropsToErrors&&i.mapPropsToErrors(this.props),initialTouched:i.mapPropsToTouched&&i.mapPropsToTouched(this.props),onSubmit:this.handleSubmit,children:this.renderFormComponent}))},a}(r.Component);return a.displayName="WithFormik("+t+")",l(a,e)}},exports.yupToFormErrors=V;
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("react"),t=e(require("react-fast-compare")),n=e(require("deepmerge")),i=e(require("lodash/isPlainObject")),a=e(require("lodash/clone")),o=e(require("lodash/toPath")),u=e(require("tiny-warning")),s=require("scheduler"),l=e(require("hoist-non-react-statics")),c=e(require("lodash/cloneDeep"));function p(){return(p=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function d(e,r){e.prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r}function f(e,r){if(null==e)return{};var t,n,i={},a=Object.keys(e);for(n=0;n<a.length;n++)r.indexOf(t=a[n])>=0||(i[t]=e[t]);return i}function v(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var h=function(e){return Array.isArray(e)&&0===e.length},m=function(e){return"function"==typeof e},y=function(e){return null!==e&&"object"==typeof e},E=function(e){return String(Math.floor(Number(e)))===e},S=function(e){return"[object String]"===Object.prototype.toString.call(e)},T=function(e){return 0===r.Children.count(e)},b=function(e){return y(e)&&m(e.then)};function g(e,r,t,n){void 0===n&&(n=0);for(var i=o(r);e&&n<i.length;)e=e[i[n++]];return void 0===e?t:e}function F(e,r,t){for(var n=a(e),i=n,u=0,s=o(r);u<s.length-1;u++){var l=s[u],c=g(e,s.slice(0,u+1));if(c&&(y(c)||Array.isArray(c)))i=i[l]=a(c);else{var p=s[u+1];i=i[l]=E(p)&&Number(p)>=0?[]:{}}}return(0===u?e:i)[s[u]]===t?e:(void 0===t?delete i[s[u]]:i[s[u]]=t,0===u&&void 0===t&&delete n[s[u]],n)}function _(e,r,t,n){void 0===t&&(t=new WeakMap),void 0===n&&(n={});for(var i=0,a=Object.keys(e);i<a.length;i++){var o=a[i],u=e[o];y(u)?t.get(u)||(t.set(u,!0),n[o]=Array.isArray(u)?[]:{},_(u,r,t,n[o])):n[o]=r}return n}var k=r.createContext(void 0),R=k.Provider,O=k.Consumer;function A(){var e=r.useContext(k);return e||u(!1),e}function I(e,r){switch(r.type){case"SET_VALUES":return p({},e,{values:r.payload});case"SET_TOUCHED":return p({},e,{touched:r.payload});case"SET_ERRORS":return t(e.errors,r.payload)?e:p({},e,{errors:r.payload});case"SET_LOW_PRIORITY_ERRORS":return t(e.errors,r.payload.errors)||!t(e.values,r.payload.values)?e:p({},e,{errors:r.payload.errors});case"SET_STATUS":return p({},e,{status:r.payload});case"SET_ISSUBMITTING":return p({},e,{isSubmitting:r.payload});case"SET_ISVALIDATING":return p({},e,{isValidating:r.payload});case"SET_FIELD_VALUE":return p({},e,{values:F(e.values,r.payload.field,r.payload.value)});case"SET_FIELD_TOUCHED":return p({},e,{touched:F(e.touched,r.payload.field,r.payload.value)});case"SET_FIELD_ERROR":return p({},e,{errors:F(e.errors,r.payload.field,r.payload.value)});case"RESET_FORM":return p({},e,r.payload);case"SET_FORMIK_STATE":return r.payload(e);case"SUBMIT_ATTEMPT":return p({},e,{touched:_(e.values,!0),isSubmitting:!0,submitCount:e.submitCount+1});case"SUBMIT_FAILURE":case"SUBMIT_SUCCESS":return p({},e,{isSubmitting:!1});default:return e}}var C={},P={};function x(e){var i=e.validateOnChange,a=void 0===i||i,o=e.validateOnBlur,u=void 0===o||o,l=e.validateOnMount,c=void 0!==l&&l,d=e.isInitialValid,v=e.enableReinitialize,h=void 0!==v&&v,E=e.onSubmit,T=f(e,["validateOnChange","validateOnBlur","validateOnMount","isInitialValid","enableReinitialize","onSubmit"]),_=p({validateOnChange:a,validateOnBlur:u,validateOnMount:c,onSubmit:E},T),k=r.useRef(_.initialValues),R=r.useRef(_.initialErrors||C),O=r.useRef(_.initialTouched||P),A=r.useRef(_.initialStatus),x=r.useRef(!1),U=r.useRef({});r.useEffect((function(){return x.current=!0,function(){x.current=!1}}),[]);var M=r.useReducer(I,{values:_.initialValues,errors:_.initialErrors||C,touched:_.initialTouched||P,status:_.initialStatus,isSubmitting:!1,isValidating:!1,submitCount:0}),L=M[0],N=M[1],B=r.useCallback((function(e,r){return new Promise((function(t,n){var i=_.validate(e,r);null==i?t(C):b(i)?i.then((function(e){t(e||C)}),(function(e){n(e)})):t(i)}))}),[_.validate]),q=r.useCallback((function(e,r){var t=_.validationSchema,n=m(t)?t(r):t,i=r&&n.validateAt?n.validateAt(r,e):D(e,n);return new Promise((function(e,r){i.then((function(){e(C)}),(function(t){"ValidationError"===t.name?e(V(t)):r(t)}))}))}),[_.validationSchema]),W=r.useCallback((function(e,r){return new Promise((function(t){return t(U.current[e].validate(r))}))}),[]),G=r.useCallback((function(e){var r=Object.keys(U.current).filter((function(e){return m(U.current[e].validate)})),t=r.length>0?r.map((function(r){return W(r,g(e,r))})):[Promise.resolve("DO_NOT_DELETE_YOU_WILL_BE_FIRED")];return Promise.all(t).then((function(e){return e.reduce((function(e,t,n){return"DO_NOT_DELETE_YOU_WILL_BE_FIRED"===t?e:(t&&(e=F(e,r[n],t)),e)}),{})}))}),[W]),H=r.useCallback((function(e){return Promise.all([G(e),_.validationSchema?q(e):{},_.validate?B(e):{}]).then((function(e){return n.all([e[0],e[1],e[2]],{arrayMerge:w})}))}),[_.validate,_.validationSchema,G,B,q]),Y=j((function(e){return void 0===e&&(e=L.values),r=function(){return H(e).then((function(r){return x.current&&N({type:"SET_LOW_PRIORITY_ERRORS",payload:{values:e,errors:r}}),r})).catch((function(e){}))},s.unstable_runWithPriority(s.unstable_LowPriority,(function(){return s.unstable_scheduleCallback(s.unstable_LowPriority,r)}));var r})),K=j((function(e){return void 0===e&&(e=L.values),N({type:"SET_ISVALIDATING",payload:!0}),H(e).then((function(e){return x.current&&(N({type:"SET_ISVALIDATING",payload:!1}),t(L.errors,e)||N({type:"SET_ERRORS",payload:e})),e}))}));r.useEffect((function(){c&&!0===x.current&&t(k.current,_.initialValues)&&Y(k.current)}),[c,Y]);var z=r.useCallback((function(e){var r=e&&e.values?e.values:k.current,t=e&&e.errors?e.errors:R.current?R.current:_.initialErrors||{},n=e&&e.touched?e.touched:O.current?O.current:_.initialTouched||{},i=e&&e.status?e.status:A.current?A.current:_.initialStatus;k.current=r,R.current=t,O.current=n,A.current=i;var a=function(){N({type:"RESET_FORM",payload:{isSubmitting:!!e&&!!e.isSubmitting,errors:t,touched:n,status:i,values:r,isValidating:!!e&&!!e.isValidating,submitCount:e&&e.submitCount&&"number"==typeof e.submitCount?e.submitCount:0}})};if(_.onReset){var o=_.onReset(L.values,fe);b(o)?o.then(a):a()}else a()}),[_.initialErrors,_.initialStatus,_.initialTouched]);r.useEffect((function(){!0!==x.current||t(k.current,_.initialValues)||(h&&(k.current=_.initialValues,z()),c&&Y(k.current))}),[h,_.initialValues,z,c,Y]),r.useEffect((function(){h&&!0===x.current&&!t(R.current,_.initialErrors)&&(R.current=_.initialErrors||C,N({type:"SET_ERRORS",payload:_.initialErrors||C}))}),[h,_.initialErrors]),r.useEffect((function(){h&&!0===x.current&&!t(O.current,_.initialTouched)&&(O.current=_.initialTouched||P,N({type:"SET_TOUCHED",payload:_.initialTouched||P}))}),[h,_.initialTouched]),r.useEffect((function(){h&&!0===x.current&&!t(A.current,_.initialStatus)&&(A.current=_.initialStatus,N({type:"SET_STATUS",payload:_.initialStatus}))}),[h,_.initialStatus,_.initialTouched]);var J=j((function(e){if(U.current[e]&&m(U.current[e].validate)){var r=g(L.values,e),t=U.current[e].validate(r);return b(t)?(N({type:"SET_ISVALIDATING",payload:!0}),t.then((function(e){return e})).then((function(r){N({type:"SET_FIELD_ERROR",payload:{field:e,value:r}}),N({type:"SET_ISVALIDATING",payload:!1})}))):(N({type:"SET_FIELD_ERROR",payload:{field:e,value:t}}),Promise.resolve(t))}return _.validationSchema?(N({type:"SET_ISVALIDATING",payload:!0}),q(L.values,e).then((function(e){return e})).then((function(r){N({type:"SET_FIELD_ERROR",payload:{field:e,value:r[e]}}),N({type:"SET_ISVALIDATING",payload:!1})}))):Promise.resolve()})),Q=r.useCallback((function(e,r){U.current[e]={validate:r.validate}}),[]),X=r.useCallback((function(e){delete U.current[e]}),[]),Z=j((function(e,r){return N({type:"SET_TOUCHED",payload:e}),(void 0===r?u:r)?Y(L.values):Promise.resolve()})),$=r.useCallback((function(e){N({type:"SET_ERRORS",payload:e})}),[]),ee=j((function(e,r){var t=m(e)?e(L.values):e;return N({type:"SET_VALUES",payload:t}),(void 0===r?a:r)?Y(t):Promise.resolve()})),re=r.useCallback((function(e,r){N({type:"SET_FIELD_ERROR",payload:{field:e,value:r}})}),[]),te=j((function(e,r,t){return N({type:"SET_FIELD_VALUE",payload:{field:e,value:r}}),(void 0===t?a:t)?Y(F(L.values,e,r)):Promise.resolve()})),ne=r.useCallback((function(e,r){var t,n=r,i=e;if(!S(e)){e.persist&&e.persist();var a=e.target?e.target:e.currentTarget,o=a.type,u=a.value,s=a.checked,l=a.options,c=a.multiple;n=r||a.name||a.id,i=/number|range/.test(o)?(t=parseFloat(u),isNaN(t)?"":t):/checkbox/.test(o)?function(e,r,t){if("boolean"==typeof e)return Boolean(r);var n=[],i=!1,a=-1;if(Array.isArray(e))n=e,i=(a=e.indexOf(t))>=0;else if(!t||"true"==t||"false"==t)return Boolean(r);return r&&t&&!i?n.concat(t):i?n.slice(0,a).concat(n.slice(a+1)):n}(g(L.values,n),s,u):c?function(e){return Array.from(e).filter((function(e){return e.selected})).map((function(e){return e.value}))}(l):u}n&&te(n,i)}),[te,L.values]),ie=j((function(e){if(S(e))return function(r){return ne(r,e)};ne(e)})),ae=j((function(e,r,t){return void 0===r&&(r=!0),N({type:"SET_FIELD_TOUCHED",payload:{field:e,value:r}}),(void 0===t?u:t)?K(L.values):Promise.resolve()})),oe=r.useCallback((function(e,r){e.persist&&e.persist();var t=e.target;ae(r||t.name||t.id,!0)}),[ae]),ue=j((function(e){if(S(e))return function(r){return oe(r,e)};oe(e)})),se=r.useCallback((function(e){m(e)?N({type:"SET_FORMIK_STATE",payload:e}):N({type:"SET_FORMIK_STATE",payload:function(){return e}})}),[]),le=r.useCallback((function(e){N({type:"SET_STATUS",payload:e})}),[]),ce=r.useCallback((function(e){N({type:"SET_ISSUBMITTING",payload:e})}),[]),pe=j((function(){return N({type:"SUBMIT_ATTEMPT"}),K().then((function(e){var r=e instanceof Error;if(!r&&0===Object.keys(e).length){var t;try{if(void 0===(t=ve()))return}catch(e){throw e}return Promise.resolve(t).then((function(e){return x.current&&N({type:"SUBMIT_SUCCESS"}),e})).catch((function(e){if(x.current)throw N({type:"SUBMIT_FAILURE"}),e}))}if(x.current&&(N({type:"SUBMIT_FAILURE"}),r))throw e}))})),de=j((function(e){e&&e.preventDefault&&m(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&m(e.stopPropagation)&&e.stopPropagation(),pe().catch((function(e){console.warn("Warning: An unhandled error was caught from submitForm()",e)}))})),fe={resetForm:z,validateForm:K,validateField:J,setErrors:$,setFieldError:re,setFieldTouched:ae,setFieldValue:te,setStatus:le,setSubmitting:ce,setTouched:Z,setValues:ee,setFormikState:se,submitForm:pe},ve=j((function(){return E(L.values,fe)})),he=j((function(e){e&&e.preventDefault&&m(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&m(e.stopPropagation)&&e.stopPropagation(),z()})),me=r.useCallback((function(e){return{value:g(L.values,e),error:g(L.errors,e),touched:!!g(L.touched,e),initialValue:g(k.current,e),initialTouched:!!g(O.current,e),initialError:g(R.current,e)}}),[L.errors,L.touched,L.values]),ye=r.useCallback((function(e){return{setValue:function(r,t){return te(e,r,t)},setTouched:function(r,t){return ae(e,r,t)},setError:function(r){return re(e,r)}}}),[te,ae,re]),Ee=r.useCallback((function(e){var r=y(e),t=r?e.name:e,n=g(L.values,t),i={name:t,value:n,onChange:ie,onBlur:ue};if(r){var a=e.type,o=e.value,u=e.as,s=e.multiple;"checkbox"===a?void 0===o?i.checked=!!n:(i.checked=!(!Array.isArray(n)||!~n.indexOf(o)),i.value=o):"radio"===a?(i.checked=n===o,i.value=o):"select"===u&&s&&(i.value=i.value||[],i.multiple=!0)}return i}),[ue,ie,L.values]),Se=r.useMemo((function(){return!t(k.current,L.values)}),[k.current,L.values]),Te=r.useMemo((function(){return void 0!==d?Se?L.errors&&0===Object.keys(L.errors).length:!1!==d&&m(d)?d(_):d:L.errors&&0===Object.keys(L.errors).length}),[d,Se,L.errors,_]);return p({},L,{initialValues:k.current,initialErrors:R.current,initialTouched:O.current,initialStatus:A.current,handleBlur:ue,handleChange:ie,handleReset:he,handleSubmit:de,resetForm:z,setErrors:$,setFormikState:se,setFieldTouched:ae,setFieldValue:te,setFieldError:re,setStatus:le,setSubmitting:ce,setTouched:Z,setValues:ee,submitForm:pe,validateForm:K,validateField:J,isValid:Te,dirty:Se,unregisterField:X,registerField:Q,getFieldProps:Ee,getFieldMeta:me,getFieldHelpers:ye,validateOnBlur:u,validateOnChange:a,validateOnMount:c})}function U(e){var t=x(e),n=e.component,i=e.children,a=e.render;return r.useImperativeHandle(e.innerRef,(function(){return t})),r.createElement(R,{value:t},n?r.createElement(n,t):a?a(t):i?m(i)?i(t):T(i)?null:r.Children.only(i):null)}function V(e){var r={};if(e.inner){if(0===e.inner.length)return F(r,e.path,e.message);var t=e.inner,n=Array.isArray(t),i=0;for(t=n?t:t[Symbol.iterator]();;){var a;if(n){if(i>=t.length)break;a=t[i++]}else{if((i=t.next()).done)break;a=i.value}var o=a;g(r,o.path)||(r=F(r,o.path,o.message))}}return r}function D(e,r,t,n){void 0===t&&(t=!1),void 0===n&&(n={});var i=M(e);return r[t?"validateSync":"validate"](i,{abortEarly:!1,context:n})}function M(e){var r=Array.isArray(e)?[]:{};for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var n=String(t);r[n]=!0===Array.isArray(e[n])?e[n].map((function(e){return!0===Array.isArray(e)||i(e)?M(e):""!==e?e:void 0})):i(e[n])?M(e[n]):""!==e[n]?e[n]:void 0}return r}function w(e,r,t){var i=e.slice();return r.forEach((function(r,a){if(void 0===i[a]){var o=!1!==t.clone&&t.isMergeableObject(r);i[a]=o?n(Array.isArray(r)?[]:{},r,t):r}else t.isMergeableObject(r)?i[a]=n(e[a],r,t):-1===e.indexOf(r)&&i.push(r)})),i}var L="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?r.useLayoutEffect:r.useEffect;function j(e){var t=r.useRef(e);return L((function(){t.current=e})),r.useCallback((function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return t.current.apply(void 0,r)}),[])}var N=r.forwardRef((function(e,t){var n=e.action,i=f(e,["action"]),a=n||"#",o=A();return r.createElement("form",Object.assign({onSubmit:o.handleSubmit,ref:t,onReset:o.handleReset,action:a},i))}));function B(e){var t=function(t){return r.createElement(O,null,(function(n){return n||u(!1),r.createElement(e,Object.assign({},t,{formik:n}))}))},n=e.displayName||e.name||e.constructor&&e.constructor.name||"Component";return t.WrappedComponent=e,t.displayName="FormikConnect("+n+")",l(t,e)}N.displayName="Form";var q=function(e,r,t){var n=Y(e),i=n[r];return n.splice(r,1),n.splice(t,0,i),n},W=function(e,r,t){var n=Y(e),i=n[r];return n[r]=n[t],n[t]=i,n},G=function(e,r,t){var n=Y(e);return n.splice(r,0,t),n},H=function(e,r,t){var n=Y(e);return n[r]=t,n},Y=function(e){if(e){if(Array.isArray(e))return[].concat(e);var r=Object.keys(e).map((function(e){return parseInt(e)})).reduce((function(e,r){return r>e?r:e}),0);return Array.from(p({},e,{length:r+1}))}return[]},K=function(e){function n(r){var t;return(t=e.call(this,r)||this).updateArrayField=function(e,r,n){var i=t.props,a=i.name;(0,i.formik.setFormikState)((function(t){var i="function"==typeof n?n:e,o="function"==typeof r?r:e,u=F(t.values,a,e(g(t.values,a))),s=n?i(g(t.errors,a)):void 0,l=r?o(g(t.touched,a)):void 0;return h(s)&&(s=void 0),h(l)&&(l=void 0),p({},t,{values:u,errors:n?F(t.errors,a,s):t.errors,touched:r?F(t.touched,a,l):t.touched})}))},t.push=function(e){return t.updateArrayField((function(r){return[].concat(Y(r),[c(e)])}),!1,!1)},t.handlePush=function(e){return function(){return t.push(e)}},t.swap=function(e,r){return t.updateArrayField((function(t){return W(t,e,r)}),!0,!0)},t.handleSwap=function(e,r){return function(){return t.swap(e,r)}},t.move=function(e,r){return t.updateArrayField((function(t){return q(t,e,r)}),!0,!0)},t.handleMove=function(e,r){return function(){return t.move(e,r)}},t.insert=function(e,r){return t.updateArrayField((function(t){return G(t,e,r)}),(function(r){return G(r,e,null)}),(function(r){return G(r,e,null)}))},t.handleInsert=function(e,r){return function(){return t.insert(e,r)}},t.replace=function(e,r){return t.updateArrayField((function(t){return H(t,e,r)}),!1,!1)},t.handleReplace=function(e,r){return function(){return t.replace(e,r)}},t.unshift=function(e){var r=-1;return t.updateArrayField((function(t){var n=t?[e].concat(t):[e];return r<0&&(r=n.length),n}),(function(e){var t=e?[null].concat(e):[null];return r<0&&(r=t.length),t}),(function(e){var t=e?[null].concat(e):[null];return r<0&&(r=t.length),t})),r},t.handleUnshift=function(e){return function(){return t.unshift(e)}},t.handleRemove=function(e){return function(){return t.remove(e)}},t.handlePop=function(){return function(){return t.pop()}},t.remove=t.remove.bind(v(t)),t.pop=t.pop.bind(v(t)),t}d(n,e);var i=n.prototype;return i.componentDidUpdate=function(e){this.props.validateOnChange&&this.props.formik.validateOnChange&&!t(g(e.formik.values,e.name),g(this.props.formik.values,this.props.name))&&this.props.formik.validateForm(this.props.formik.values)},i.remove=function(e){var r;return this.updateArrayField((function(t){var n=t?Y(t):[];return r||(r=n[e]),m(n.splice)&&n.splice(e,1),n}),!0,!0),r},i.pop=function(){var e;return this.updateArrayField((function(r){var t=r;return e||(e=t&&t.pop&&t.pop()),t}),!0,!0),e},i.render=function(){var e=this.props,t=e.component,n=e.render,i=e.children,a=e.name,o=p({},{push:this.push,pop:this.pop,swap:this.swap,move:this.move,insert:this.insert,replace:this.replace,unshift:this.unshift,remove:this.remove,handlePush:this.handlePush,handlePop:this.handlePop,handleSwap:this.handleSwap,handleMove:this.handleMove,handleInsert:this.handleInsert,handleReplace:this.handleReplace,handleUnshift:this.handleUnshift,handleRemove:this.handleRemove},{form:f(e.formik,["validate","validationSchema"]),name:a});return t?r.createElement(t,o):n?n(o):i?"function"==typeof i?i(o):T(i)?null:r.Children.only(i):null},n}(r.Component);K.defaultProps={validateOnChange:!0};var z=B(K),J=B(function(e){function t(){return e.apply(this,arguments)||this}d(t,e);var n=t.prototype;return n.shouldComponentUpdate=function(e){return g(this.props.formik.errors,this.props.name)!==g(e.formik.errors,this.props.name)||g(this.props.formik.touched,this.props.name)!==g(e.formik.touched,this.props.name)||Object.keys(this.props).length!==Object.keys(e).length},n.render=function(){var e=this.props,t=e.component,n=e.formik,i=e.render,a=e.children,o=e.name,u=f(e,["component","formik","render","children","name"]),s=g(n.touched,o),l=g(n.errors,o);return s&&l?i?m(i)?i(l):null:a?m(a)?a(l):null:t?r.createElement(t,u,l):l:null},t}(r.Component)),Q=B(function(e){function t(r){var t;t=e.call(this,r)||this;var n=r.render,i=r.children,a=r.component,o=r.as;return n&&u(!1),a&&n&&u(!1),o&&i&&m(i)&&u(!1),a&&i&&m(i)&&u(!1),n&&i&&!T(i)&&u(!1),t}d(t,e);var n=t.prototype;return n.shouldComponentUpdate=function(e){return this.props.shouldUpdate?this.props.shouldUpdate(e,this.props):e.name!==this.props.name||g(e.formik.values,this.props.name)!==g(this.props.formik.values,this.props.name)||g(e.formik.errors,this.props.name)!==g(this.props.formik.errors,this.props.name)||g(e.formik.touched,this.props.name)!==g(this.props.formik.touched,this.props.name)||Object.keys(this.props).length!==Object.keys(e).length||e.formik.isSubmitting!==this.props.formik.isSubmitting},n.componentDidMount=function(){this.props.formik.registerField(this.props.name,{validate:this.props.validate})},n.componentDidUpdate=function(e){this.props.name!==e.name&&(this.props.formik.unregisterField(e.name),this.props.formik.registerField(this.props.name,{validate:this.props.validate})),this.props.validate!==e.validate&&this.props.formik.registerField(this.props.name,{validate:this.props.validate})},n.componentWillUnmount=function(){this.props.formik.unregisterField(this.props.name)},n.render=function(){var e=this.props,t=e.name,n=e.render,i=e.as,a=e.children,o=e.component,u=e.formik,s=f(e,["validate","name","render","as","children","component","shouldUpdate","formik"]),l=f(u,["validate","validationSchema"]),c=u.getFieldProps(p({name:t},s)),d={field:c,meta:{value:g(u.values,t),error:g(u.errors,t),touched:!!g(u.touched,t),initialValue:g(u.initialValues,t),initialTouched:!!g(u.initialTouched,t),initialError:g(u.initialErrors,t)},form:l};if(n)return n(d);if(m(a))return a(d);if(o){if("string"==typeof o){var v=s.innerRef,h=f(s,["innerRef"]);return r.createElement(o,p({ref:v},c,h),a)}return r.createElement(o,p({field:c,form:u},s),a)}var y=i||"input";if("string"==typeof y){var E=s.innerRef,S=f(s,["innerRef"]);return r.createElement(y,p({ref:E},c,S),a)}return r.createElement(y,p({},c,s),a)},t}(r.Component));exports.ErrorMessage=J,exports.FastField=Q,exports.Field=function(e){var t=e.validate,n=e.name,i=e.render,a=e.children,o=e.as,u=e.component,s=f(e,["validate","name","render","children","as","component"]),l=f(A(),["validate","validationSchema"]),c=l.registerField,d=l.unregisterField;r.useEffect((function(){return c(n,{validate:t}),function(){d(n)}}),[c,d,n,t]);var v=l.getFieldProps(p({name:n},s)),h=l.getFieldMeta(n),y={field:v,form:l};if(i)return i(p({},y,{meta:h}));if(m(a))return a(p({},y,{meta:h}));if(u){if("string"==typeof u){var E=s.innerRef,S=f(s,["innerRef"]);return r.createElement(u,p({ref:E},v,S),a)}return r.createElement(u,p({field:v,form:l},s),a)}var T=o||"input";if("string"==typeof T){var b=s.innerRef,g=f(s,["innerRef"]);return r.createElement(T,p({ref:b},v,g),a)}return r.createElement(T,p({},v,s),a)},exports.FieldArray=z,exports.Form=N,exports.Formik=U,exports.FormikConsumer=O,exports.FormikContext=k,exports.FormikProvider=R,exports.connect=B,exports.getActiveElement=function(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(r){return e.body}},exports.getIn=g,exports.insert=G,exports.isEmptyArray=h,exports.isEmptyChildren=T,exports.isFunction=m,exports.isInputEvent=function(e){return e&&y(e)&&y(e.target)},exports.isInteger=E,exports.isNaN=function(e){return e!=e},exports.isObject=y,exports.isPromise=b,exports.isString=S,exports.move=q,exports.prepareDataForValidation=M,exports.replace=H,exports.setIn=F,exports.setNestedObjectValues=_,exports.swap=W,exports.useField=function(e){var t=A(),n=t.getFieldProps,i=t.getFieldMeta,a=t.getFieldHelpers,o=t.registerField,s=t.unregisterField,l=y(e)?e:{name:e},c=l.name,p=l.validate;return r.useEffect((function(){return c&&o(c,{validate:p}),function(){c&&s(c)}}),[o,s,c,p]),c||u(!1),[n(l),i(c),a(c)]},exports.useFormik=x,exports.useFormikContext=A,exports.validateYupSchema=D,exports.withFormik=function(e){var t=e.mapPropsToValues,n=void 0===t?function(e){var r={};for(var t in e)e.hasOwnProperty(t)&&"function"!=typeof e[t]&&(r[t]=e[t]);return r}:t,i=f(e,["mapPropsToValues"]);return function(e){var t=e.displayName||e.name||e.constructor&&e.constructor.name||"Component",a=function(t){function a(){var n;return(n=t.apply(this,arguments)||this).validate=function(e){return i.validate(e,n.props)},n.validationSchema=function(){return m(i.validationSchema)?i.validationSchema(n.props):i.validationSchema},n.handleSubmit=function(e,r){return i.handleSubmit(e,p({},r,{props:n.props}))},n.renderFormComponent=function(t){return r.createElement(e,Object.assign({},n.props,t))},n}return d(a,t),a.prototype.render=function(){var e=f(this.props,["children"]);return r.createElement(U,Object.assign({},e,i,{validate:i.validate&&this.validate,validationSchema:i.validationSchema&&this.validationSchema,initialValues:n(this.props),initialStatus:i.mapPropsToStatus&&i.mapPropsToStatus(this.props),initialErrors:i.mapPropsToErrors&&i.mapPropsToErrors(this.props),initialTouched:i.mapPropsToTouched&&i.mapPropsToTouched(this.props),onSubmit:this.handleSubmit,children:this.renderFormComponent}))},a}(r.Component);return a.displayName="WithFormik("+t+")",l(a,e)}},exports.yupToFormErrors=V;
//# sourceMappingURL=formik.cjs.production.min.js.map

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

/// <reference path="types/index.d.ts" />
import * as React from 'react';

@@ -21,9 +22,9 @@ import { FormikConfig, FormikErrors, FormikState, FormikTouched, FormikValues, FieldMetaProps, FieldHelperProps, FieldInputProps } from './types';

setFormikState: (stateOrCb: FormikState<Values> | ((state: FormikState<Values>) => FormikState<Values>)) => void;
setFieldTouched: (field: string, touched?: boolean, shouldValidate?: boolean | undefined) => any;
setFieldValue: (field: string, value: any, shouldValidate?: boolean | undefined) => any;
setFieldTouched: (field: string, touched?: boolean, shouldValidate?: boolean | undefined) => Promise<FormikErrors<Values>> | Promise<void>;
setFieldValue: (field: string, value: any, shouldValidate?: boolean | undefined) => import("scheduler").Task | Promise<void>;
setFieldError: (field: string, value: string | undefined) => void;
setStatus: (status: any) => void;
setSubmitting: (isSubmitting: boolean) => void;
setTouched: (touched: FormikTouched<Values>, shouldValidate?: boolean | undefined) => any;
setValues: (values: React.SetStateAction<Values>, shouldValidate?: boolean | undefined) => any;
setTouched: (touched: FormikTouched<Values>, shouldValidate?: boolean | undefined) => import("scheduler").Task | Promise<void>;
setValues: (values: React.SetStateAction<Values>, shouldValidate?: boolean | undefined) => import("scheduler").Task | Promise<void>;
submitForm: () => Promise<any>;

@@ -30,0 +31,0 @@ validateForm: (values?: Values) => Promise<FormikErrors<Values>>;

{
"name": "formik",
"description": "Forms in React, without tears",
"version": "2.2.3",
"version": "2.2.4",
"license": "Apache-2.0",

@@ -6,0 +6,0 @@ "author": "Jared Palmer <jared@palmer.net>",

Sorry, the diff of this file is too big to display

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 too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc