Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

formik

Package Overview
Dependencies
11
Maintainers
1
Versions
212
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.4.0 to 2.4.1

2

dist/FieldArray.d.ts

@@ -12,4 +12,2 @@ import * as React from 'react';

validateOnChange?: boolean;
/** Override FieldArray's default shouldComponentUpdate */
shouldUpdate?: (nextProps: {}, props: {}) => boolean;
} & SharedRenderProps<FieldArrayRenderProps>;

@@ -16,0 +14,0 @@ export interface ArrayHelpers<T extends any[] = any[]> {

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

@@ -72,3 +72,3 @@ import * as React from 'react';

/** Set value of form field directly */
setFieldValue(field: string, value: any, shouldValidate?: boolean): Promise<void | FormikErrors<Values>>;
setFieldValue: (field: string, value: any, shouldValidate?: boolean) => Promise<void | FormikErrors<Values>>;
/** Set error message of a form field directly */

@@ -75,0 +75,0 @@ setFieldError: (field: string, message: string | undefined) => void;

{
"name": "formik",
"description": "Build forms in React, without the tears",
"version": "2.4.0",
"version": "2.4.1",
"license": "Apache-2.0",

@@ -42,4 +42,3 @@ "author": "Jared Palmer <jared@palmer.net> (https://jaredpalmer.com)",

"build": "tsdx build --tsconfig tsconfig.build.json",
"lint": "tsdx lint",
"prepublish": "npm run build"
"lint": "tsdx lint"
},

@@ -46,0 +45,0 @@ "dependencies": {

@@ -28,2 +28,12 @@ <p align="center">

## Contributing
This monorepo uses `yarn`, so to start you'll need the package manager installed.
To run E2E tests you'll also need Playwright set up, which can be done locally via `npx playwright install`. Afterward, run `yarn start:app` and in a separate tab run `yarn e2e:ui` to boot up the test runner.
When you're done with your changes, we use [changesets](https://github.com/changesets/changesets) to manage release notes. Run `yarn changeset` to autogenerate notes to be appended to your pull request.
Thank you!
## Contributors

@@ -30,0 +40,0 @@

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc