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.4.3 to 2.4.4

6

dist/Field.d.ts

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

}
export type FieldAttributes<T> = GenericFieldHTMLAttributes & FieldConfig<T> & T & {
export type FieldAttributes<T> = {
className?: string;
} & GenericFieldHTMLAttributes & FieldConfig<T> & T & {
name: string;

@@ -52,2 +54,2 @@ };

export declare function Field({ validate, name, render, children, as: is, // `as` is reserved in typescript lol
component, ...props }: FieldAttributes<any>): any;
component, className, ...props }: FieldAttributes<any>): any;

@@ -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=e(require("deepmerge")),t=e(require("lodash/isPlainObject")),n=require("react"),i=e(require("react-fast-compare")),a=e(require("tiny-warning")),o=e(require("lodash/clone")),u=e(require("lodash/toPath")),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=n.createContext(void 0);v.displayName="FormikContext";var h=v.Provider,m=v.Consumer;function y(){var e=n.useContext(v);return e||a(!1),e}var E=function(e){return Array.isArray(e)&&0===e.length},S=function(e){return"function"==typeof e},T=function(e){return null!==e&&"object"==typeof e},g=function(e){return String(Math.floor(Number(e)))===e},b=function(e){return"[object String]"===Object.prototype.toString.call(e)},F=function(e){return 0===n.Children.count(e)},k=function(e){return T(e)&&S(e.then)};function A(e,r,t,n){void 0===n&&(n=0);for(var i=u(r);e&&n<i.length;)e=e[i[n++]];return n===i.length||e?void 0===e?t:e:t}function _(e,r,t){for(var n=o(e),i=n,a=0,s=u(r);a<s.length-1;a++){var l=s[a],c=A(e,s.slice(0,a+1));if(c&&(T(c)||Array.isArray(c)))i=i[l]=o(c);else{var p=s[a+1];i=i[l]=g(p)&&Number(p)>=0?[]:{}}}return(0===a?e:i)[s[a]]===t?e:(void 0===t?delete i[s[a]]:i[s[a]]=t,0===a&&void 0===t&&delete n[s[a]],n)}function R(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];T(u)?t.get(u)||(t.set(u,!0),n[o]=Array.isArray(u)?[]:{},R(u,r,t,n[o])):n[o]=r}return n}var O={},C={};function I(e){var t=e.validateOnChange,a=void 0===t||t,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,h=e.onSubmit,m=d(e,["validateOnChange","validateOnBlur","validateOnMount","isInitialValid","enableReinitialize","onSubmit"]),y=c({validateOnChange:a,validateOnBlur:u,validateOnMount:l,onSubmit:h},m),E=n.useRef(y.initialValues),g=n.useRef(y.initialErrors||O),F=n.useRef(y.initialTouched||C),I=n.useRef(y.initialStatus),P=n.useRef(!1),V=n.useRef({});n.useEffect((function(){return P.current=!0,function(){P.current=!1}}),[]);var M=n.useState(0)[1],L=n.useRef({values:y.initialValues,errors:y.initialErrors||O,touched:y.initialTouched||C,status:y.initialStatus,isSubmitting:!1,isValidating:!1,submitCount:0}),j=L.current,N=n.useCallback((function(e){var r=L.current;L.current=function(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 i(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:_(e.values,r.payload.field,r.payload.value)});case"SET_FIELD_TOUCHED":return c({},e,{touched:_(e.touched,r.payload.field,r.payload.value)});case"SET_FIELD_ERROR":return c({},e,{errors:_(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:R(e.values,!0),isSubmitting:!0,submitCount:e.submitCount+1});case"SUBMIT_FAILURE":case"SUBMIT_SUCCESS":return c({},e,{isSubmitting:!1});default:return e}}(r,e),r!==L.current&&M((function(e){return e+1}))}),[]),B=n.useCallback((function(e,r){return new Promise((function(t,n){var i=y.validate(e,r);null==i?t(O):k(i)?i.then((function(e){t(e||O)}),(function(e){n(e)})):t(i)}))}),[y.validate]),q=n.useCallback((function(e,r){var t=y.validationSchema,n=S(t)?t(r):t,i=r&&n.validateAt?n.validateAt(r,e):U(e,n);return new Promise((function(e,r){i.then((function(){e(O)}),(function(t){"ValidationError"===t.name?e(x(t)):r(t)}))}))}),[y.validationSchema]),G=n.useCallback((function(e,r){return new Promise((function(t){return t(V.current[e].validate(r))}))}),[]),H=n.useCallback((function(e){var r=Object.keys(V.current).filter((function(e){return S(V.current[e].validate)})),t=r.length>0?r.map((function(r){return G(r,A(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=_(e,r[n],t)),e)}),{})}))}),[G]),W=n.useCallback((function(e){return Promise.all([H(e),y.validationSchema?q(e):{},y.validate?B(e):{}]).then((function(e){return r.all([e[0],e[1],e[2]],{arrayMerge:D})}))}),[y.validate,y.validationSchema,H,B,q]),K=w((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}))}));n.useEffect((function(){l&&!0===P.current&&i(E.current,y.initialValues)&&K(E.current)}),[l,K]);var Y=n.useCallback((function(e){var r=e&&e.values?e.values:E.current,t=e&&e.errors?e.errors:g.current?g.current:y.initialErrors||{},n=e&&e.touched?e.touched:F.current?F.current:y.initialTouched||{},i=e&&e.status?e.status:I.current?I.current:y.initialStatus;E.current=r,g.current=t,F.current=n,I.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(y.onReset){var o=y.onReset(j.values,de);k(o)?o.then(a):a()}else a()}),[y.initialErrors,y.initialStatus,y.initialTouched]);n.useEffect((function(){!0!==P.current||i(E.current,y.initialValues)||v&&(E.current=y.initialValues,Y(),l&&K(E.current))}),[v,y.initialValues,Y,l,K]),n.useEffect((function(){v&&!0===P.current&&!i(g.current,y.initialErrors)&&(g.current=y.initialErrors||O,N({type:"SET_ERRORS",payload:y.initialErrors||O}))}),[v,y.initialErrors]),n.useEffect((function(){v&&!0===P.current&&!i(F.current,y.initialTouched)&&(F.current=y.initialTouched||C,N({type:"SET_TOUCHED",payload:y.initialTouched||C}))}),[v,y.initialTouched]),n.useEffect((function(){v&&!0===P.current&&!i(I.current,y.initialStatus)&&(I.current=y.initialStatus,N({type:"SET_STATUS",payload:y.initialStatus}))}),[v,y.initialStatus,y.initialTouched]);var z=w((function(e){if(V.current[e]&&S(V.current[e].validate)){var r=A(j.values,e),t=V.current[e].validate(r);return k(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 y.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:A(r,e)}}),N({type:"SET_ISVALIDATING",payload:!1})}))):Promise.resolve()})),J=n.useCallback((function(e,r){V.current[e]={validate:r.validate}}),[]),Q=n.useCallback((function(e){delete V.current[e]}),[]),X=w((function(e,r){return N({type:"SET_TOUCHED",payload:e}),(void 0===r?u:r)?K(j.values):Promise.resolve()})),Z=n.useCallback((function(e){N({type:"SET_ERRORS",payload:e})}),[]),$=w((function(e,r){var t=S(e)?e(j.values):e;return N({type:"SET_VALUES",payload:t}),(void 0===r?a:r)?K(t):Promise.resolve()})),ee=n.useCallback((function(e,r){N({type:"SET_FIELD_ERROR",payload:{field:e,value:r}})}),[]),re=w((function(e,r,t){return N({type:"SET_FIELD_VALUE",payload:{field:e,value:r}}),(void 0===t?a:t)?K(_(j.values,e,r)):Promise.resolve()})),te=n.useCallback((function(e,r){var t,n=r,i=e;if(!b(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}(A(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=w((function(e){if(b(e))return function(r){return te(r,e)};te(e)})),ie=w((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=n.useCallback((function(e,r){e.persist&&e.persist();var t=e.target;ie(r||t.name||t.id,!0)}),[ie]),oe=w((function(e){if(b(e))return function(r){return ae(r,e)};ae(e)})),ue=n.useCallback((function(e){S(e)?N({type:"SET_FORMIK_STATE",payload:e}):N({type:"SET_FORMIK_STATE",payload:function(){return e}})}),[]),se=n.useCallback((function(e){N({type:"SET_STATUS",payload:e})}),[]),le=n.useCallback((function(e){N({type:"SET_ISSUBMITTING",payload:e})}),[]),ce=w((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=w((function(e){e&&e.preventDefault&&S(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&S(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=w((function(){return h(j.values,de)})),ve=w((function(e){e&&e.preventDefault&&S(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&S(e.stopPropagation)&&e.stopPropagation(),Y()})),he=n.useCallback((function(e){return{value:A(j.values,e),error:A(j.errors,e),touched:!!A(j.touched,e),initialValue:A(E.current,e),initialTouched:!!A(F.current,e),initialError:A(g.current,e)}}),[j.errors,j.touched,j.values]),me=n.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=n.useCallback((function(e){var r=T(e),t=r?e.name:e,n=A(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=n.useMemo((function(){return!i(E.current,j.values)}),[E.current,j.values]),Se=n.useMemo((function(){return void 0!==p?Ee?j.errors&&0===Object.keys(j.errors).length:!1!==p&&S(p)?p(y):p:j.errors&&0===Object.keys(j.errors).length}),[p,Ee,j.errors,y]);return c({},j,{initialValues:E.current,initialErrors:g.current,initialTouched:F.current,initialStatus:I.current,handleBlur:oe,handleChange:ne,handleReset:ve,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:he,getFieldHelpers:me,validateOnBlur:u,validateOnChange:a,validateOnMount:l})}function P(e){var r=I(e),t=e.component,i=e.children,a=e.render;return n.useImperativeHandle(e.innerRef,(function(){return r})),n.createElement(h,{value:r},t?n.createElement(t,r):a?a(r):i?S(i)?i(r):F(i)?null:n.Children.only(i):null)}function x(e){var r={};if(e.inner){if(0===e.inner.length)return _(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;A(r,o.path)||(r=_(r,o.path,o.message))}}return r}function U(e,r,t,n){void 0===t&&(t=!1);var i=V(e);return r[t?"validateSync":"validate"](i,{abortEarly:!1,context:n||i})}function V(e){var r=Array.isArray(e)?[]:{};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var i=String(n);r[i]=!0===Array.isArray(e[i])?e[i].map((function(e){return!0===Array.isArray(e)||t(e)?V(e):""!==e?e:void 0})):t(e[i])?V(e[i]):""!==e[i]?e[i]:void 0}return r}function D(e,t,n){var i=e.slice();return t.forEach((function(t,a){if(void 0===i[a]){var o=!1!==n.clone&&n.isMergeableObject(t);i[a]=o?r(Array.isArray(t)?[]:{},t,n):t}else n.isMergeableObject(t)?i[a]=r(e[a],t,n):-1===e.indexOf(t)&&i.push(t)})),i}var M="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?n.useLayoutEffect:n.useEffect;function w(e){var r=n.useRef(e);return M((function(){r.current=e})),n.useCallback((function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.current.apply(void 0,t)}),[])}var L=n.forwardRef((function(e,r){var t=e.action,i=d(e,["action"]),a=null!=t?t:"#",o=y();return n.createElement("form",c({onSubmit:o.handleSubmit,ref:r,onReset:o.handleReset,action:a},i))}));function j(e){var r=function(r){return n.createElement(m,null,(function(t){return t||a(!1),n.createElement(e,c({},r,{formik:t}))}))},t=e.displayName||e.name||e.constructor&&e.constructor.name||"Component";return r.WrappedComponent=e,r.displayName="FormikConnect("+t+")",s(r,e)}L.displayName="Form";var N=function(e,r,t){var n=H(e),i=n[r];return n.splice(r,1),n.splice(t,0,i),n},B=function(e,r,t){var n=H(e),i=n[r];return n[r]=n[t],n[t]=i,n},q=function(e,r,t){var n=H(e);return n.splice(r,0,t),n},G=function(e,r,t){var n=H(e);return n[r]=t,n},H=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[]},W=function(e,r){var t="function"==typeof e?e:r;return function(e){if(Array.isArray(e)||T(e)){var r=H(e);return t(r)}return e}},K=function(e){function r(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=W(n,e),o=W(r,e),u=_(t.values,a,e(A(t.values,a))),s=n?i(A(t.errors,a)):void 0,l=r?o(A(t.touched,a)):void 0;return E(s)&&(s=void 0),E(l)&&(l=void 0),c({},t,{values:u,errors:n?_(t.errors,a,s):t.errors,touched:r?_(t.touched,a,l):t.touched})}))},t.push=function(e){return t.updateArrayField((function(r){return[].concat(H(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 B(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 N(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 q(t,e,r)}),(function(r){return q(r,e,null)}),(function(r){return q(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 G(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=n.length,n}),(function(e){return e?[null].concat(e):[null]}),(function(e){return e?[null].concat(e):[null]})),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(r,e);var t=r.prototype;return t.componentDidUpdate=function(e){this.props.validateOnChange&&this.props.formik.validateOnChange&&!i(A(e.formik.values,e.name),A(this.props.formik.values,this.props.name))&&this.props.formik.validateForm(this.props.formik.values)},t.remove=function(e){var r;return this.updateArrayField((function(t){var n=t?H(t):[];return r||(r=n[e]),S(n.splice)&&n.splice(e,1),S(n.every)&&n.every((function(e){return void 0===e}))?[]:n}),!0,!0),r},t.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},t.render=function(){var e=this.props,r=e.component,t=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 r?n.createElement(r,o):t?t(o):i?"function"==typeof i?i(o):F(i)?null:n.Children.only(i):null},r}(n.Component);K.defaultProps={validateOnChange:!0};var Y=j(K),z=j(function(e){function r(){return e.apply(this,arguments)||this}p(r,e);var t=r.prototype;return t.shouldComponentUpdate=function(e){return A(this.props.formik.errors,this.props.name)!==A(e.formik.errors,this.props.name)||A(this.props.formik.touched,this.props.name)!==A(e.formik.touched,this.props.name)||Object.keys(this.props).length!==Object.keys(e).length},t.render=function(){var e=this.props,r=e.component,t=e.formik,i=e.render,a=e.children,o=e.name,u=d(e,["component","formik","render","children","name"]),s=A(t.touched,o),l=A(t.errors,o);return s&&l?i?S(i)?i(l):null:a?S(a)?a(l):null:r?n.createElement(r,u,l):l:null},r}(n.Component)),J=j(function(e){function r(r){var t;t=e.call(this,r)||this;var n=r.render,i=r.children,o=r.component,u=r.as;return n&&a(!1),o&&n&&a(!1),u&&i&&S(i)&&a(!1),o&&i&&S(i)&&a(!1),n&&i&&!F(i)&&a(!1),t}p(r,e);var t=r.prototype;return t.shouldComponentUpdate=function(e){return this.props.shouldUpdate?this.props.shouldUpdate(e,this.props):e.name!==this.props.name||A(e.formik.values,this.props.name)!==A(this.props.formik.values,this.props.name)||A(e.formik.errors,this.props.name)!==A(this.props.formik.errors,this.props.name)||A(e.formik.touched,this.props.name)!==A(this.props.formik.touched,this.props.name)||Object.keys(this.props).length!==Object.keys(e).length||e.formik.isSubmitting!==this.props.formik.isSubmitting},t.componentDidMount=function(){this.props.formik.registerField(this.props.name,{validate:this.props.validate})},t.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})},t.componentWillUnmount=function(){this.props.formik.unregisterField(this.props.name)},t.render=function(){var e=this.props,r=e.name,t=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:r},s)),f={field:p,meta:{value:A(u.values,r),error:A(u.errors,r),touched:!!A(u.touched,r),initialValue:A(u.initialValues,r),initialTouched:!!A(u.initialTouched,r),initialError:A(u.initialErrors,r)},form:l};if(t)return t(f);if(S(a))return a(f);if(o){if("string"==typeof o){var v=s.innerRef,h=d(s,["innerRef"]);return n.createElement(o,c({ref:v},p,h),a)}return n.createElement(o,c({field:p,form:u},s),a)}var m=i||"input";if("string"==typeof m){var y=s.innerRef,E=d(s,["innerRef"]);return n.createElement(m,c({ref:y},p,E),a)}return n.createElement(m,c({},p,s),a)},r}(n.Component));exports.ErrorMessage=z,exports.FastField=J,exports.Field=function(e){var r=e.validate,t=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(y(),["validate","validationSchema"]),p=l.registerField,f=l.unregisterField;n.useEffect((function(){return p(t,{validate:r}),function(){f(t)}}),[p,f,t,r]);var v=l.getFieldProps(c({name:t},s)),h=l.getFieldMeta(t),m={field:v,form:l};if(i)return i(c({},m,{meta:h}));if(S(a))return a(c({},m,{meta:h}));if(u){if("string"==typeof u){var E=s.innerRef,T=d(s,["innerRef"]);return n.createElement(u,c({ref:E},v,T),a)}return n.createElement(u,c({field:v,form:l},s),a)}var g=o||"input";if("string"==typeof g){var b=s.innerRef,F=d(s,["innerRef"]);return n.createElement(g,c({ref:b},v,F),a)}return n.createElement(g,c({},v,s),a)},exports.FieldArray=Y,exports.Form=L,exports.Formik=P,exports.FormikConsumer=m,exports.FormikContext=v,exports.FormikProvider=h,exports.connect=j,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=A,exports.insert=q,exports.isEmptyArray=E,exports.isEmptyChildren=F,exports.isFunction=S,exports.isInputEvent=function(e){return e&&T(e)&&T(e.target)},exports.isInteger=g,exports.isNaN=function(e){return e!=e},exports.isObject=T,exports.isPromise=k,exports.isString=b,exports.move=N,exports.prepareDataForValidation=V,exports.replace=G,exports.setIn=_,exports.setNestedObjectValues=R,exports.swap=B,exports.useField=function(e){var r=y(),t=r.getFieldProps,i=r.getFieldMeta,o=r.getFieldHelpers,u=r.registerField,s=r.unregisterField,l=T(e)?e:{name:e},c=l.name,p=l.validate;n.useEffect((function(){return c&&u(c,{validate:p}),function(){c&&s(c)}}),[u,s,c,p]),c||a(!1);var d=n.useMemo((function(){return o(c)}),[o,c]);return[t(l),i(c),d]},exports.useFormik=I,exports.useFormikContext=y,exports.validateYupSchema=U,exports.withFormik=function(e){var r=e.mapPropsToValues,t=void 0===r?function(e){var r={};for(var t in e)e.hasOwnProperty(t)&&"function"!=typeof e[t]&&(r[t]=e[t]);return r}:r,i=d(e,["mapPropsToValues"]);return function(e){var r=e.displayName||e.name||e.constructor&&e.constructor.name||"Component",a=function(r){function a(){for(var t,a=arguments.length,o=new Array(a),u=0;u<a;u++)o[u]=arguments[u];return(t=r.call.apply(r,[this].concat(o))||this).validate=function(e){return i.validate(e,t.props)},t.validationSchema=function(){return S(i.validationSchema)?i.validationSchema(t.props):i.validationSchema},t.handleSubmit=function(e,r){return i.handleSubmit(e,c({},r,{props:t.props}))},t.renderFormComponent=function(r){return n.createElement(e,c({},t.props,r))},t}return p(a,r),a.prototype.render=function(){var e=d(this.props,["children"]);return n.createElement(P,c({},e,i,{validate:i.validate&&this.validate,validationSchema:i.validationSchema&&this.validationSchema,initialValues:t(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}(n.Component);return a.displayName="WithFormik("+r+")",s(a,e)}},exports.yupToFormErrors=x;
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=e(require("deepmerge")),t=e(require("lodash/isPlainObject")),n=require("react"),i=e(require("react-fast-compare")),a=e(require("tiny-warning")),o=e(require("lodash/clone")),u=e(require("lodash/toPath")),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=n.createContext(void 0);v.displayName="FormikContext";var h=v.Provider,m=v.Consumer;function y(){var e=n.useContext(v);return e||a(!1),e}var E=function(e){return Array.isArray(e)&&0===e.length},S=function(e){return"function"==typeof e},T=function(e){return null!==e&&"object"==typeof e},g=function(e){return String(Math.floor(Number(e)))===e},b=function(e){return"[object String]"===Object.prototype.toString.call(e)},F=function(e){return 0===n.Children.count(e)},k=function(e){return T(e)&&S(e.then)};function A(e,r,t,n){void 0===n&&(n=0);for(var i=u(r);e&&n<i.length;)e=e[i[n++]];return n===i.length||e?void 0===e?t:e:t}function R(e,r,t){for(var n=o(e),i=n,a=0,s=u(r);a<s.length-1;a++){var l=s[a],c=A(e,s.slice(0,a+1));if(c&&(T(c)||Array.isArray(c)))i=i[l]=o(c);else{var p=s[a+1];i=i[l]=g(p)&&Number(p)>=0?[]:{}}}return(0===a?e:i)[s[a]]===t?e:(void 0===t?delete i[s[a]]:i[s[a]]=t,0===a&&void 0===t&&delete n[s[a]],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];T(u)?t.get(u)||(t.set(u,!0),n[o]=Array.isArray(u)?[]:{},_(u,r,t,n[o])):n[o]=r}return n}var O={},C={};function I(e){var t=e.validateOnChange,a=void 0===t||t,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,h=e.onSubmit,m=d(e,["validateOnChange","validateOnBlur","validateOnMount","isInitialValid","enableReinitialize","onSubmit"]),y=c({validateOnChange:a,validateOnBlur:u,validateOnMount:l,onSubmit:h},m),E=n.useRef(y.initialValues),g=n.useRef(y.initialErrors||O),F=n.useRef(y.initialTouched||C),I=n.useRef(y.initialStatus),P=n.useRef(!1),V=n.useRef({});n.useEffect((function(){return P.current=!0,function(){P.current=!1}}),[]);var M=n.useState(0)[1],L=n.useRef({values:y.initialValues,errors:y.initialErrors||O,touched:y.initialTouched||C,status:y.initialStatus,isSubmitting:!1,isValidating:!1,submitCount:0}),N=L.current,j=n.useCallback((function(e){var r=L.current;L.current=function(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 i(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:R(e.values,r.payload.field,r.payload.value)});case"SET_FIELD_TOUCHED":return c({},e,{touched:R(e.touched,r.payload.field,r.payload.value)});case"SET_FIELD_ERROR":return c({},e,{errors:R(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:_(e.values,!0),isSubmitting:!0,submitCount:e.submitCount+1});case"SUBMIT_FAILURE":case"SUBMIT_SUCCESS":return c({},e,{isSubmitting:!1});default:return e}}(r,e),r!==L.current&&M((function(e){return e+1}))}),[]),B=n.useCallback((function(e,r){return new Promise((function(t,n){var i=y.validate(e,r);null==i?t(O):k(i)?i.then((function(e){t(e||O)}),(function(e){n(e)})):t(i)}))}),[y.validate]),q=n.useCallback((function(e,r){var t=y.validationSchema,n=S(t)?t(r):t,i=r&&n.validateAt?n.validateAt(r,e):U(e,n);return new Promise((function(e,r){i.then((function(){e(O)}),(function(t){"ValidationError"===t.name?e(x(t)):r(t)}))}))}),[y.validationSchema]),G=n.useCallback((function(e,r){return new Promise((function(t){return t(V.current[e].validate(r))}))}),[]),H=n.useCallback((function(e){var r=Object.keys(V.current).filter((function(e){return S(V.current[e].validate)})),t=r.length>0?r.map((function(r){return G(r,A(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=R(e,r[n],t)),e)}),{})}))}),[G]),W=n.useCallback((function(e){return Promise.all([H(e),y.validationSchema?q(e):{},y.validate?B(e):{}]).then((function(e){return r.all([e[0],e[1],e[2]],{arrayMerge:D})}))}),[y.validate,y.validationSchema,H,B,q]),K=w((function(e){return void 0===e&&(e=N.values),j({type:"SET_ISVALIDATING",payload:!0}),W(e).then((function(e){return P.current&&(j({type:"SET_ISVALIDATING",payload:!1}),j({type:"SET_ERRORS",payload:e})),e}))}));n.useEffect((function(){l&&!0===P.current&&i(E.current,y.initialValues)&&K(E.current)}),[l,K]);var Y=n.useCallback((function(e){var r=e&&e.values?e.values:E.current,t=e&&e.errors?e.errors:g.current?g.current:y.initialErrors||{},n=e&&e.touched?e.touched:F.current?F.current:y.initialTouched||{},i=e&&e.status?e.status:I.current?I.current:y.initialStatus;E.current=r,g.current=t,F.current=n,I.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(y.onReset){var o=y.onReset(N.values,de);k(o)?o.then(a):a()}else a()}),[y.initialErrors,y.initialStatus,y.initialTouched,y.onReset]);n.useEffect((function(){!0!==P.current||i(E.current,y.initialValues)||v&&(E.current=y.initialValues,Y(),l&&K(E.current))}),[v,y.initialValues,Y,l,K]),n.useEffect((function(){v&&!0===P.current&&!i(g.current,y.initialErrors)&&(g.current=y.initialErrors||O,j({type:"SET_ERRORS",payload:y.initialErrors||O}))}),[v,y.initialErrors]),n.useEffect((function(){v&&!0===P.current&&!i(F.current,y.initialTouched)&&(F.current=y.initialTouched||C,j({type:"SET_TOUCHED",payload:y.initialTouched||C}))}),[v,y.initialTouched]),n.useEffect((function(){v&&!0===P.current&&!i(I.current,y.initialStatus)&&(I.current=y.initialStatus,j({type:"SET_STATUS",payload:y.initialStatus}))}),[v,y.initialStatus,y.initialTouched]);var z=w((function(e){if(V.current[e]&&S(V.current[e].validate)){var r=A(N.values,e),t=V.current[e].validate(r);return k(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 y.validationSchema?(j({type:"SET_ISVALIDATING",payload:!0}),q(N.values,e).then((function(e){return e})).then((function(r){j({type:"SET_FIELD_ERROR",payload:{field:e,value:A(r,e)}}),j({type:"SET_ISVALIDATING",payload:!1})}))):Promise.resolve()})),J=n.useCallback((function(e,r){V.current[e]={validate:r.validate}}),[]),Q=n.useCallback((function(e){delete V.current[e]}),[]),X=w((function(e,r){return j({type:"SET_TOUCHED",payload:e}),(void 0===r?u:r)?K(N.values):Promise.resolve()})),Z=n.useCallback((function(e){j({type:"SET_ERRORS",payload:e})}),[]),$=w((function(e,r){var t=S(e)?e(N.values):e;return j({type:"SET_VALUES",payload:t}),(void 0===r?a:r)?K(t):Promise.resolve()})),ee=n.useCallback((function(e,r){j({type:"SET_FIELD_ERROR",payload:{field:e,value:r}})}),[]),re=w((function(e,r,t){return j({type:"SET_FIELD_VALUE",payload:{field:e,value:r}}),(void 0===t?a:t)?K(R(N.values,e,r)):Promise.resolve()})),te=n.useCallback((function(e,r){var t,n=r,i=e;if(!b(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}(A(N.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,N.values]),ne=w((function(e){if(b(e))return function(r){return te(r,e)};te(e)})),ie=w((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)?K(N.values):Promise.resolve()})),ae=n.useCallback((function(e,r){e.persist&&e.persist();var t=e.target;ie(r||t.name||t.id,!0)}),[ie]),oe=w((function(e){if(b(e))return function(r){return ae(r,e)};ae(e)})),ue=n.useCallback((function(e){S(e)?j({type:"SET_FORMIK_STATE",payload:e}):j({type:"SET_FORMIK_STATE",payload:function(){return e}})}),[]),se=n.useCallback((function(e){j({type:"SET_STATUS",payload:e})}),[]),le=n.useCallback((function(e){j({type:"SET_ISSUBMITTING",payload:e})}),[]),ce=w((function(){return j({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&&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}))})),pe=w((function(e){e&&e.preventDefault&&S(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&S(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=w((function(){return h(N.values,de)})),ve=w((function(e){e&&e.preventDefault&&S(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&S(e.stopPropagation)&&e.stopPropagation(),Y()})),he=n.useCallback((function(e){return{value:A(N.values,e),error:A(N.errors,e),touched:!!A(N.touched,e),initialValue:A(E.current,e),initialTouched:!!A(F.current,e),initialError:A(g.current,e)}}),[N.errors,N.touched,N.values]),me=n.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=n.useCallback((function(e){var r=T(e),t=r?e.name:e,n=A(N.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,N.values]),Ee=n.useMemo((function(){return!i(E.current,N.values)}),[E.current,N.values]),Se=n.useMemo((function(){return void 0!==p?Ee?N.errors&&0===Object.keys(N.errors).length:!1!==p&&S(p)?p(y):p:N.errors&&0===Object.keys(N.errors).length}),[p,Ee,N.errors,y]);return c({},N,{initialValues:E.current,initialErrors:g.current,initialTouched:F.current,initialStatus:I.current,handleBlur:oe,handleChange:ne,handleReset:ve,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:he,getFieldHelpers:me,validateOnBlur:u,validateOnChange:a,validateOnMount:l})}function P(e){var r=I(e),t=e.component,i=e.children,a=e.render;return n.useImperativeHandle(e.innerRef,(function(){return r})),n.createElement(h,{value:r},t?n.createElement(t,r):a?a(r):i?S(i)?i(r):F(i)?null:n.Children.only(i):null)}function x(e){var r={};if(e.inner){if(0===e.inner.length)return R(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;A(r,o.path)||(r=R(r,o.path,o.message))}}return r}function U(e,r,t,n){void 0===t&&(t=!1);var i=V(e);return r[t?"validateSync":"validate"](i,{abortEarly:!1,context:n||i})}function V(e){var r=Array.isArray(e)?[]:{};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var i=String(n);r[i]=!0===Array.isArray(e[i])?e[i].map((function(e){return!0===Array.isArray(e)||t(e)?V(e):""!==e?e:void 0})):t(e[i])?V(e[i]):""!==e[i]?e[i]:void 0}return r}function D(e,t,n){var i=e.slice();return t.forEach((function(t,a){if(void 0===i[a]){var o=!1!==n.clone&&n.isMergeableObject(t);i[a]=o?r(Array.isArray(t)?[]:{},t,n):t}else n.isMergeableObject(t)?i[a]=r(e[a],t,n):-1===e.indexOf(t)&&i.push(t)})),i}var M="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?n.useLayoutEffect:n.useEffect;function w(e){var r=n.useRef(e);return M((function(){r.current=e})),n.useCallback((function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.current.apply(void 0,t)}),[])}var L=n.forwardRef((function(e,r){var t=e.action,i=d(e,["action"]),a=null!=t?t:"#",o=y();return n.createElement("form",c({onSubmit:o.handleSubmit,ref:r,onReset:o.handleReset,action:a},i))}));function N(e){var r=function(r){return n.createElement(m,null,(function(t){return t||a(!1),n.createElement(e,c({},r,{formik:t}))}))},t=e.displayName||e.name||e.constructor&&e.constructor.name||"Component";return r.WrappedComponent=e,r.displayName="FormikConnect("+t+")",s(r,e)}L.displayName="Form";var j=function(e,r,t){var n=H(e),i=n[r];return n.splice(r,1),n.splice(t,0,i),n},B=function(e,r,t){var n=H(e),i=n[r];return n[r]=n[t],n[t]=i,n},q=function(e,r,t){var n=H(e);return n.splice(r,0,t),n},G=function(e,r,t){var n=H(e);return n[r]=t,n},H=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[]},W=function(e,r){var t="function"==typeof e?e:r;return function(e){if(Array.isArray(e)||T(e)){var r=H(e);return t(r)}return e}},K=function(e){function r(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=W(n,e),o=W(r,e),u=R(t.values,a,e(A(t.values,a))),s=n?i(A(t.errors,a)):void 0,l=r?o(A(t.touched,a)):void 0;return E(s)&&(s=void 0),E(l)&&(l=void 0),c({},t,{values:u,errors:n?R(t.errors,a,s):t.errors,touched:r?R(t.touched,a,l):t.touched})}))},t.push=function(e){return t.updateArrayField((function(r){return[].concat(H(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 B(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 j(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 q(t,e,r)}),(function(r){return q(r,e,null)}),(function(r){return q(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 G(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=n.length,n}),(function(e){return e?[null].concat(e):[null]}),(function(e){return e?[null].concat(e):[null]})),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(r,e);var t=r.prototype;return t.componentDidUpdate=function(e){this.props.validateOnChange&&this.props.formik.validateOnChange&&!i(A(e.formik.values,e.name),A(this.props.formik.values,this.props.name))&&this.props.formik.validateForm(this.props.formik.values)},t.remove=function(e){var r;return this.updateArrayField((function(t){var n=t?H(t):[];return r||(r=n[e]),S(n.splice)&&n.splice(e,1),S(n.every)&&n.every((function(e){return void 0===e}))?[]:n}),!0,!0),r},t.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},t.render=function(){var e=this.props,r=e.component,t=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 r?n.createElement(r,o):t?t(o):i?"function"==typeof i?i(o):F(i)?null:n.Children.only(i):null},r}(n.Component);K.defaultProps={validateOnChange:!0};var Y=N(K),z=N(function(e){function r(){return e.apply(this,arguments)||this}p(r,e);var t=r.prototype;return t.shouldComponentUpdate=function(e){return A(this.props.formik.errors,this.props.name)!==A(e.formik.errors,this.props.name)||A(this.props.formik.touched,this.props.name)!==A(e.formik.touched,this.props.name)||Object.keys(this.props).length!==Object.keys(e).length},t.render=function(){var e=this.props,r=e.component,t=e.formik,i=e.render,a=e.children,o=e.name,u=d(e,["component","formik","render","children","name"]),s=A(t.touched,o),l=A(t.errors,o);return s&&l?i?S(i)?i(l):null:a?S(a)?a(l):null:r?n.createElement(r,u,l):l:null},r}(n.Component)),J=N(function(e){function r(r){var t;t=e.call(this,r)||this;var n=r.render,i=r.children,o=r.component,u=r.as;return n&&a(!1),o&&n&&a(!1),u&&i&&S(i)&&a(!1),o&&i&&S(i)&&a(!1),n&&i&&!F(i)&&a(!1),t}p(r,e);var t=r.prototype;return t.shouldComponentUpdate=function(e){return this.props.shouldUpdate?this.props.shouldUpdate(e,this.props):e.name!==this.props.name||A(e.formik.values,this.props.name)!==A(this.props.formik.values,this.props.name)||A(e.formik.errors,this.props.name)!==A(this.props.formik.errors,this.props.name)||A(e.formik.touched,this.props.name)!==A(this.props.formik.touched,this.props.name)||Object.keys(this.props).length!==Object.keys(e).length||e.formik.isSubmitting!==this.props.formik.isSubmitting},t.componentDidMount=function(){this.props.formik.registerField(this.props.name,{validate:this.props.validate})},t.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})},t.componentWillUnmount=function(){this.props.formik.unregisterField(this.props.name)},t.render=function(){var e=this.props,r=e.name,t=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:r},s)),f={field:p,meta:{value:A(u.values,r),error:A(u.errors,r),touched:!!A(u.touched,r),initialValue:A(u.initialValues,r),initialTouched:!!A(u.initialTouched,r),initialError:A(u.initialErrors,r)},form:l};if(t)return t(f);if(S(a))return a(f);if(o){if("string"==typeof o){var v=s.innerRef,h=d(s,["innerRef"]);return n.createElement(o,c({ref:v},p,h),a)}return n.createElement(o,c({field:p,form:u},s),a)}var m=i||"input";if("string"==typeof m){var y=s.innerRef,E=d(s,["innerRef"]);return n.createElement(m,c({ref:y},p,E),a)}return n.createElement(m,c({},p,s),a)},r}(n.Component));exports.ErrorMessage=z,exports.FastField=J,exports.Field=function(e){var r=e.validate,t=e.name,i=e.render,a=e.children,o=e.as,u=e.component,s=e.className,l=d(e,["validate","name","render","children","as","component","className"]),p=d(y(),["validate","validationSchema"]),f=p.registerField,v=p.unregisterField;n.useEffect((function(){return f(t,{validate:r}),function(){v(t)}}),[f,v,t,r]);var h=p.getFieldProps(c({name:t},l)),m=p.getFieldMeta(t),E={field:h,form:p};if(i)return i(c({},E,{meta:m}));if(S(a))return a(c({},E,{meta:m}));if(u){if("string"==typeof u){var T=l.innerRef,g=d(l,["innerRef"]);return n.createElement(u,c({ref:T},h,g,{className:s}),a)}return n.createElement(u,c({field:h,form:p},l,{className:s}),a)}var b=o||"input";if("string"==typeof b){var F=l.innerRef,k=d(l,["innerRef"]);return n.createElement(b,c({ref:F},h,k,{className:s}),a)}return n.createElement(b,c({},h,l,{className:s}),a)},exports.FieldArray=Y,exports.Form=L,exports.Formik=P,exports.FormikConsumer=m,exports.FormikContext=v,exports.FormikProvider=h,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=A,exports.insert=q,exports.isEmptyArray=E,exports.isEmptyChildren=F,exports.isFunction=S,exports.isInputEvent=function(e){return e&&T(e)&&T(e.target)},exports.isInteger=g,exports.isNaN=function(e){return e!=e},exports.isObject=T,exports.isPromise=k,exports.isString=b,exports.move=j,exports.prepareDataForValidation=V,exports.replace=G,exports.setIn=R,exports.setNestedObjectValues=_,exports.swap=B,exports.useField=function(e){var r=y(),t=r.getFieldProps,i=r.getFieldMeta,o=r.getFieldHelpers,u=r.registerField,s=r.unregisterField,l=T(e)?e:{name:e},c=l.name,p=l.validate;n.useEffect((function(){return c&&u(c,{validate:p}),function(){c&&s(c)}}),[u,s,c,p]),c||a(!1);var d=n.useMemo((function(){return o(c)}),[o,c]);return[t(l),i(c),d]},exports.useFormik=I,exports.useFormikContext=y,exports.validateYupSchema=U,exports.withFormik=function(e){var r=e.mapPropsToValues,t=void 0===r?function(e){var r={};for(var t in e)e.hasOwnProperty(t)&&"function"!=typeof e[t]&&(r[t]=e[t]);return r}:r,i=d(e,["mapPropsToValues"]);return function(e){var r=e.displayName||e.name||e.constructor&&e.constructor.name||"Component",a=function(r){function a(){for(var t,a=arguments.length,o=new Array(a),u=0;u<a;u++)o[u]=arguments[u];return(t=r.call.apply(r,[this].concat(o))||this).validate=function(e){return i.validate(e,t.props)},t.validationSchema=function(){return S(i.validationSchema)?i.validationSchema(t.props):i.validationSchema},t.handleSubmit=function(e,r){return i.handleSubmit(e,c({},r,{props:t.props}))},t.renderFormComponent=function(r){return n.createElement(e,c({},t.props,r))},t}return p(a,r),a.prototype.render=function(){var e=d(this.props,["children"]);return n.createElement(P,c({},e,i,{validate:i.validate&&this.validate,validationSchema:i.validationSchema&&this.validationSchema,initialValues:t(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}(n.Component);return a.displayName="WithFormik("+r+")",s(a,e)}},exports.yupToFormErrors=x;
//# sourceMappingURL=formik.cjs.production.min.js.map
{
"name": "formik",
"description": "Build forms in React, without the tears",
"version": "2.4.3",
"version": "2.4.4",
"license": "Apache-2.0",

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

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