Socket
Socket
Sign inDemoInstall

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 3.0.0-next.6 to 3.0.0-next.7

dist/hooks.d.ts

20

CHANGELOG.md
# formik
## 3.0.0-next.7
### Patch Changes
- [`90fd693`](https://github.com/formium/formik/commit/90fd693b0900e1b82ff56b39bd1a020327c0bcb6) [#2921](https://github.com/formium/formik/pull/2921) Thanks [@jaredpalmer](https://github.com/jaredpalmer)! - Add hooks `useSetValue`, `useSetErrors`, `useSetTouched`, `useSetStatus`, `useSubmitForm`, `useResetForm`, `useIsSubmitting`, `useIsValid`, `useIsDirty`, `useValidateForm`, `useValidateField`
## 3.0.0-next.6

@@ -53,2 +59,16 @@

## 2.2.5
### Patch Changes
- [`ebad985`](https://github.com/formium/formik/commit/ebad98569e034c5bd8f52a7926480b7d63127cd4) [#2891](https://github.com/formium/formik/pull/2891) Thanks [@jaredpalmer](https://github.com/jaredpalmer)! - Remove low-priority validation implementation
* [`0dfa23b`](https://github.com/formium/formik/commit/0dfa23b6b312db1f2c3d22019975212f0f901c00) [#2889](https://github.com/formium/formik/pull/2889) Thanks [@jaredpalmer](https://github.com/jaredpalmer)! - Fixed botched typescript builds including scheduler types
## 2.2.4
### Patch Changes
- [`199e77a`](https://github.com/formium/formik/commit/199e77a3f69e9886d88fc7114c37769cd365d9c6) [#2882](https://github.com/formium/formik/pull/2882) Thanks [@umidbekkarimov](https://github.com/umidbekkarimov)! - Validate `setFieldTouched` with high priority
## 2.2.3

@@ -55,0 +75,0 @@

2

dist/FastField.d.ts
import { FieldInputProps, FieldMetaProps, GenericFieldHTMLAttributes, SharedFieldProps } from './types';
import { UseFieldProps } from './useField';
import { UseFieldProps } from './hooks';
export declare type FastFieldProps<FieldValue = any> = {

@@ -4,0 +4,0 @@ field: FieldInputProps<FieldValue>;

import { FieldInputProps, FieldMetaProps, FormikProps, GenericFieldHTMLAttributes, SharedFieldProps } from './types';
import { UseFieldProps } from './useField';
import { UseFieldProps } from './hooks';
export interface FieldProps<V = any, FormValues = any> {

@@ -4,0 +4,0 @@ field: FieldInputProps<V>;

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

@@ -21,9 +21,9 @@ import * as React from 'react';

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

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

@@ -12,2 +12,2 @@ export * from './Formik';

export * from './FastField';
export * from './useField';
export * from './hooks';
{
"name": "formik",
"description": "Forms in React, without tears",
"version": "3.0.0-next.6",
"version": "3.0.0-next.7",
"license": "Apache-2.0",

@@ -41,3 +41,2 @@ "author": "Jared Palmer <jared@palmer.net>",

"react-fast-compare": "^2.0.1",
"scheduler": "^0.20.1",
"tiny-warning": "^1.0.2",

@@ -44,0 +43,0 @@ "tslib": "^1.10.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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc