Comparing version 3.0.0-next.0 to 3.0.0-next.1
# formik | ||
## 3.0.0-next.1 | ||
### Patch Changes | ||
- [`1c2175a`](https://github.com/formium/formik/commit/1c2175a24b1d1223b4cdedf424ef62057edf0063) [#2848](https://github.com/formium/formik/pull/2848) Thanks [@jaredpalmer](https://github.com/jaredpalmer)! - Ensure that parse and format aren't passed through in Field components | ||
## 3.0.0-next.0 | ||
@@ -4,0 +10,0 @@ |
@@ -37,3 +37,3 @@ import * as React from 'react'; | ||
*/ | ||
format?: (value: any, name: string) => any; | ||
format?: (value: unknown, name: string) => any; | ||
/** | ||
@@ -40,0 +40,0 @@ * Wait until blur event before formatting input value? |
@@ -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")),o=e(require("lodash/toPath")),u=e(require("tiny-warning")),s=require("scheduler"),l=e(require("hoist-non-react-statics")),c=e(require("lodash/cloneDeep"));function p(){return(p=Object.assign||function(e){for(var 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 f(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 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)},g=function(e){return 0===t.Children.count(e)},T=function(e){return y(e)&&m(e.then)},b=function(e){return e&&y(e)&&y(e.target)},F="undefined"!=typeof window&&window.navigator&&window.navigator.product&&"ReactNative"===window.navigator.product;function k(e,t,r,n){void 0===n&&(n=0);for(var i=o(t);e&&n<i.length;)e=e[i[n++]];return void 0===e?r:e}function _(e,t,r){for(var n=a(e),i=n,u=0,s=o(t);u<s.length-1;u++){var l=s[u],c=k(e,s.slice(0,u+1));if(c&&(y(c)||Array.isArray(c)))i=i[l]=a(c);else{var p=s[u+1];i=i[l]=E(p)&&Number(p)>=0?[]:{}}}return(0===u?e:i)[s[u]]===r?e:(void 0===r?delete i[s[u]]:i[s[u]]=r,0===u&&void 0===r&&delete n[s[u]],n)}function R(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 o=a[i],u=e[o];y(u)?r.get(u)||(r.set(u,!0),n[o]=Array.isArray(u)?[]:{},R(u,t,r,n[o])):n[o]=t}return n}var O=t.createContext(void 0),C=O.Provider,A=O.Consumer;function I(){var e=t.useContext(O);return e||u(!1),e}var x=function(e,t){return e},P=function(e,t){var r=parseFloat(e);return isNaN(r)?"":r},w=function(e,t){return void 0===e?"":e};function U(e,t){switch(t.type){case"SET_VALUES":return p({},e,{values:t.payload});case"SET_TOUCHED":return p({},e,{touched:t.payload});case"SET_ERRORS":return r(e.errors,t.payload)?e:p({},e,{errors:t.payload});case"SET_STATUS":return p({},e,{status:t.payload});case"SET_ISSUBMITTING":return p({},e,{isSubmitting:t.payload});case"SET_ISVALIDATING":return p({},e,{isValidating:t.payload});case"SET_FIELD_VALUE":return p({},e,{values:_(e.values,t.payload.field,t.payload.value)});case"SET_FIELD_TOUCHED":return p({},e,{touched:_(e.touched,t.payload.field,t.payload.value)});case"SET_FIELD_ERROR":return p({},e,{errors:_(e.errors,t.payload.field,t.payload.value)});case"RESET_FORM":return p({},e,t.payload);case"SET_FORMIK_STATE":return t.payload(e);case"SUBMIT_ATTEMPT":return p({},e,{touched:R(e.values,!0),isSubmitting:!0,submitCount:e.submitCount+1});case"SUBMIT_FAILURE":case"SUBMIT_SUCCESS":return p({},e,{isSubmitting:!1});default:return e}}var V={},D={};function M(e){var i=e.validateOnChange,a=void 0===i||i,o=e.validateOnBlur,u=void 0===o||o,l=e.validateOnMount,c=void 0!==l&&l,d=e.isInitialValid,v=e.enableReinitialize,h=void 0!==v&&v,E=e.onSubmit,g=f(e,["validateOnChange","validateOnBlur","validateOnMount","isInitialValid","enableReinitialize","onSubmit"]),R=p({validateOnChange:a,validateOnBlur:u,validateOnMount:c,onSubmit:E},g),O=t.useRef(R.initialValues),C=t.useRef(R.initialErrors||V),A=t.useRef(R.initialTouched||D),I=t.useRef(R.initialStatus),M=t.useRef(!1),L=t.useRef({});t.useEffect((function(){return M.current=!0,function(){M.current=!1}}),[]);var B=t.useReducer(U,{values:R.initialValues,errors:R.initialErrors||V,touched:R.initialTouched||D,status:R.initialStatus,isSubmitting:!1,isValidating:!1,submitCount:0}),W=B[0],Y=B[1],z=t.useCallback((function(e,t){return new Promise((function(r,n){var i=R.validate(e,t);null==i?r(V):T(i)?i.then((function(e){r(e||V)}),(function(e){n(e)})):r(i)}))}),[R.validate]),J=t.useCallback((function(e,t){var r=R.validationSchema,n=m(r)?r(t):r,i=t&&n.validateAt?n.validateAt(t,e):N(e,n);return new Promise((function(e,t){i.then((function(){e(V)}),(function(r){"ValidationError"===r.name?e(j(r)):t(r)}))}))}),[R.validationSchema]),Q=t.useCallback((function(e,t){return new Promise((function(r){return r(L.current[e].validate(t))}))}),[]),X=t.useCallback((function(e){var t=Object.keys(L.current).filter((function(e){return m(L.current[e].validate)})),r=t.length>0?t.map((function(t){return Q(t,k(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=_(e,t[n],r)),e)}),{})}))}),[Q]),Z=t.useCallback((function(e){return Promise.all([X(e),R.validationSchema?J(e):{},R.validate?z(e):{}]).then((function(e){return n.all([e[0],e[1],e[2]],{arrayMerge:q})}))}),[R.validate,R.validationSchema,X,z,J]),$=K((function(e){return void 0===e&&(e=W.values),t=function(){return Z(e).then((function(e){return M.current&&Y({type:"SET_ERRORS",payload:e}),e})).catch((function(e){}))},s.unstable_runWithPriority(s.unstable_LowPriority,(function(){return s.unstable_scheduleCallback(s.unstable_LowPriority,t)}));var t})),ee=K((function(e){return void 0===e&&(e=W.values),Y({type:"SET_ISVALIDATING",payload:!0}),Z(e).then((function(e){return M.current&&(Y({type:"SET_ISVALIDATING",payload:!1}),r(W.errors,e)||Y({type:"SET_ERRORS",payload:e})),e}))}));t.useEffect((function(){c&&!0===M.current&&r(O.current,R.initialValues)&&$(O.current)}),[c,$]);var te=t.useCallback((function(e){var t=e&&e.values?e.values:O.current,r=e&&e.errors?e.errors:C.current?C.current:R.initialErrors||{},n=e&&e.touched?e.touched:A.current?A.current:R.initialTouched||{},i=e&&e.status?e.status:I.current?I.current:R.initialStatus;O.current=t,C.current=r,A.current=n,I.current=i;var a=function(){Y({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(R.onReset){var o=R.onReset(W.values,ge);T(o)?o.then(a):a()}else a()}),[R.initialErrors,R.initialStatus,R.initialTouched]);t.useEffect((function(){!0!==M.current||r(O.current,R.initialValues)||(h&&(O.current=R.initialValues,te()),c&&$(O.current))}),[h,R.initialValues,te,c,$]),t.useEffect((function(){h&&!0===M.current&&!r(C.current,R.initialErrors)&&(C.current=R.initialErrors||V,Y({type:"SET_ERRORS",payload:R.initialErrors||V}))}),[h,R.initialErrors]),t.useEffect((function(){h&&!0===M.current&&!r(A.current,R.initialTouched)&&(A.current=R.initialTouched||D,Y({type:"SET_TOUCHED",payload:R.initialTouched||D}))}),[h,R.initialTouched]),t.useEffect((function(){h&&!0===M.current&&!r(I.current,R.initialStatus)&&(I.current=R.initialStatus,Y({type:"SET_STATUS",payload:R.initialStatus}))}),[h,R.initialStatus,R.initialTouched]);var re=K((function(e){if(L.current[e]&&m(L.current[e].validate)){var t=k(W.values,e),r=L.current[e].validate(t);return T(r)?(Y({type:"SET_ISVALIDATING",payload:!0}),r.then((function(e){return e})).then((function(t){Y({type:"SET_FIELD_ERROR",payload:{field:e,value:t}}),Y({type:"SET_ISVALIDATING",payload:!1})}))):(Y({type:"SET_FIELD_ERROR",payload:{field:e,value:r}}),Promise.resolve(r))}return R.validationSchema?(Y({type:"SET_ISVALIDATING",payload:!0}),J(W.values,e).then((function(e){return e})).then((function(t){Y({type:"SET_FIELD_ERROR",payload:{field:e,value:t[e]}}),Y({type:"SET_ISVALIDATING",payload:!1})}))):Promise.resolve()})),ne=t.useCallback((function(e,t){L.current[e]={validate:t.validate}}),[]),ie=t.useCallback((function(e){delete L.current[e]}),[]),ae=K((function(e,t){return Y({type:"SET_TOUCHED",payload:e}),(void 0===t?u:t)?$(W.values):Promise.resolve()})),oe=t.useCallback((function(e){Y({type:"SET_ERRORS",payload:e})}),[]),ue=K((function(e,t){var r=m(e)?e(W.values):e;return Y({type:"SET_VALUES",payload:r}),(void 0===t?a:t)?$(r):Promise.resolve()})),se=t.useCallback((function(e,t){Y({type:"SET_FIELD_ERROR",payload:{field:e,value:t}})}),[]),le=K((function(e,t,r){return Y({type:"SET_FIELD_VALUE",payload:{field:e,value:t}}),(void 0===r?a:r)?$(_(W.values,e,t)):Promise.resolve()})),ce=t.useCallback((function(e,t){var r,n=t,i=e;if(!S(e)){e.persist&&e.persist();var a=e.target?e.target:e.currentTarget,o=a.type,u=a.value,s=a.checked,l=a.options,c=a.multiple;n=t||a.name||a.id,i=/number|range/.test(o)?(r=parseFloat(u),isNaN(r)?"":r):/checkbox/.test(o)?H(k(W.values,n),s,u):c?G(l):u}n&&le(n,i)}),[le,W.values]),pe=K((function(e){if(S(e))return function(t){return ce(t,e)};ce(e)})),de=K((function(e,t,r){return void 0===t&&(t=!0),Y({type:"SET_FIELD_TOUCHED",payload:{field:e,value:t}}),(void 0===r?u:r)?$(W.values):Promise.resolve()})),fe=t.useCallback((function(e,t){e.persist&&e.persist();var r=e.target;de(t||r.name||r.id,!0)}),[de]),ve=K((function(e){if(S(e))return function(t){return fe(t,e)};fe(e)})),he=t.useCallback((function(e){m(e)?Y({type:"SET_FORMIK_STATE",payload:e}):Y({type:"SET_FORMIK_STATE",payload:function(){return e}})}),[]),me=t.useCallback((function(e){Y({type:"SET_STATUS",payload:e})}),[]),ye=t.useCallback((function(e){Y({type:"SET_ISSUBMITTING",payload:e})}),[]),Ee=K((function(){return Y({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=Te()))return}catch(e){throw e}return Promise.resolve(r).then((function(e){return M.current&&Y({type:"SUBMIT_SUCCESS"}),e})).catch((function(e){if(M.current)throw Y({type:"SUBMIT_FAILURE"}),e}))}if(M.current&&(Y({type:"SUBMIT_FAILURE"}),t))throw e}))})),Se=K((function(e){e&&e.preventDefault&&m(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&m(e.stopPropagation)&&e.stopPropagation(),Ee().catch((function(e){console.warn("Warning: An unhandled error was caught from submitForm()",e)}))})),ge={resetForm:te,validateForm:ee,validateField:re,setErrors:oe,setFieldError:se,setFieldTouched:de,setFieldValue:le,setStatus:me,setSubmitting:ye,setTouched:ae,setValues:ue,setFormikState:he,submitForm:Ee},Te=K((function(){return E(W.values,ge)})),be=K((function(e){e&&e.preventDefault&&m(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&m(e.stopPropagation)&&e.stopPropagation(),te()})),Fe=t.useCallback((function(e){return{value:k(W.values,e),error:k(W.errors,e),touched:!!k(W.touched,e),initialValue:k(O.current,e),initialTouched:!!k(A.current,e),initialError:k(C.current,e)}}),[W.errors,W.touched,W.values]),ke=K((function(e){return{setValue:function(t,r){return le(e,t,r)},setTouched:function(t,r){return de(e,t,r)},setError:function(t){return se(e,t)}}})),_e=K((function(e,t){if(!F&&e.nativeEvent&&void 0!==e.nativeEvent.text)return e.nativeEvent.text;if(F&&e.nativeEvent)return e.nativeEvent.text;var r=e.target?e.target:e.currentTarget,n=r.value,i=r.checked,a=r.options,o=r.multiple;return/checkbox/.test(r.type)?H(k(W.values,t),i,n):o?G(a):n})),Re=t.useCallback((function(e){var t=y(e),r=t?e.name?e.name:e.id:e,n=k(W.values,r),i=k(W.touched,r),a={name:r,value:n,onChange:pe,onBlur:ve};if(t){var o=e.type,u=e.value,s=e.as,l=e.multiple,c=e.parse,p=void 0===c?/number|range/.test(o)?P:x:c,d=e.format,f=void 0===d?w:d,v=e.formatOnBlur,h=void 0!==v&&v;"checkbox"===o?void 0===u?a.checked=!!n:(a.checked=!(!Array.isArray(n)||!~n.indexOf(u)),a.value=u):"radio"===o?(a.checked=n===u,a.value=u):"select"===s&&l&&(a.value=a.value||[],a.multiple=!0),"radio"!==o&&"checkbox"!==o&&f&&(!0===h?!0===i&&(a.value=f(a.value)):a.value=f(a.value)),"radio"!==o&&"checkbox"!==o&&(a.onChange=function(e){b(e)?(e.persist&&e.persist(),le(r,p(_e(e,r)))):le(r,p(e))})}return a}),[_e,ve,pe,le,W.touched,W.values]),Oe=t.useMemo((function(){return!r(O.current,W.values)}),[O.current,W.values]),Ce=t.useMemo((function(){return void 0!==d?Oe?W.errors&&0===Object.keys(W.errors).length:!1!==d&&m(d)?d(R):d:W.errors&&0===Object.keys(W.errors).length}),[d,Oe,W.errors,R]);return p({},W,{initialValues:O.current,initialErrors:C.current,initialTouched:A.current,initialStatus:I.current,handleBlur:ve,handleChange:pe,handleReset:be,handleSubmit:Se,resetForm:te,setErrors:oe,setFormikState:he,setFieldTouched:de,setFieldValue:le,setFieldError:se,setStatus:me,setSubmitting:ye,setTouched:ae,setValues:ue,submitForm:Ee,validateForm:ee,validateField:re,isValid:Ce,dirty:Oe,unregisterField:ie,registerField:ne,getFieldProps:Re,getFieldMeta:Fe,getFieldHelpers:ke,validateOnBlur:u,validateOnChange:a,validateOnMount:c})}function L(e){var r=M(e),n=e.component,i=e.children,a=e.render;return t.useImperativeHandle(e.innerRef,(function(){return r})),t.createElement(C,{value:r},n?t.createElement(n,r):a?a(r):i?m(i)?i(r):g(i)?null:t.Children.only(i):null)}function j(e){var t={};if(e.inner){if(0===e.inner.length)return _(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 o=a;k(t,o.path)||(t=_(t,o.path,o.message))}}return t}function N(e,t,r,n){void 0===r&&(r=!1),void 0===n&&(n={});var i=B(e);return t[r?"validateSync":"validate"](i,{abortEarly:!1,context:n})}function B(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)?B(e):""!==e?e:void 0})):i(e[n])?B(e[n]):""!==e[n]?e[n]:void 0}return t}function q(e,t,r){var i=e.slice();return t.forEach((function(t,a){if(void 0===i[a]){var o=!1!==r.clone&&r.isMergeableObject(t);i[a]=o?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}function G(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 H(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 W="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t.useLayoutEffect:t.useEffect;function K(e){var r=t.useRef(e);return W((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)}),[])}var Y=t.forwardRef((function(e,r){var n=e.action,i=f(e,["action"]),a=n||"#",o=I();return t.createElement("form",Object.assign({onSubmit:o.handleSubmit,ref:r,onReset:o.handleReset,action:a},i))}));function z(e){var r=function(r){return t.createElement(A,null,(function(n){return n||u(!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)}Y.displayName="Form";var J=function(e,t,r){var n=$(e),i=n[t];return n.splice(t,1),n.splice(r,0,i),n},Q=function(e,t,r){var n=$(e),i=n[t];return n[t]=n[r],n[r]=i,n},X=function(e,t,r){var n=$(e);return n.splice(t,0,r),n},Z=function(e,t,r){var n=$(e);return n[t]=r,n},$=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(p({},e,{length:t+1}))}return[]},ee=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,o="function"==typeof t?t:e,u=_(r.values,a,e(k(r.values,a))),s=n?i(k(r.errors,a)):void 0,l=t?o(k(r.touched,a)):void 0;return h(s)&&(s=void 0),h(l)&&(l=void 0),p({},r,{values:u,errors:n?_(r.errors,a,s):r.errors,touched:t?_(r.touched,a,l):r.touched})}))},r.push=function(e){return r.updateArrayField((function(t){return[].concat($(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 Q(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 J(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 X(r,e,t)}),(function(t){return X(t,e,null)}),(function(t){return X(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 Z(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(k(e.formik.values,e.name),k(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?$(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,a=e.name,o=p({},{push:this.push,pop:this.pop,swap:this.swap,move:this.move,insert:this.insert,replace:this.replace,unshift:this.unshift,remove:this.remove,handlePush:this.handlePush,handlePop:this.handlePop,handleSwap:this.handleSwap,handleMove:this.handleMove,handleInsert:this.handleInsert,handleReplace:this.handleReplace,handleUnshift:this.handleUnshift,handleRemove:this.handleRemove},{form:f(e.formik,["validate","validationSchema"]),name:a});return r?t.createElement(r,o):n?n(o):i?"function"==typeof i?i(o):g(i)?null:t.Children.only(i):null},n}(t.Component);ee.defaultProps={validateOnChange:!0};var te=z(ee),re=z(function(e){function r(){return e.apply(this,arguments)||this}d(r,e);var n=r.prototype;return n.shouldComponentUpdate=function(e){return k(this.props.formik.errors,this.props.name)!==k(e.formik.errors,this.props.name)||k(this.props.formik.touched,this.props.name)!==k(e.formik.touched,this.props.name)||Object.keys(this.props).length!==Object.keys(e).length},n.render=function(){var e=this.props,r=e.component,n=e.formik,i=e.render,a=e.children,o=e.name,u=f(e,["component","formik","render","children","name"]),s=k(n.touched,o),l=k(n.errors,o);return s&&l?i?m(i)?i(l):null:a?m(a)?a(l):null:r?t.createElement(r,u,l):l:null},r}(t.Component)),ne=z(function(e){function r(t){var r;r=e.call(this,t)||this;var n=t.render,i=t.children,a=t.component,o=t.as;return n&&u(!1),a&&n&&u(!1),o&&i&&m(i)&&u(!1),a&&i&&m(i)&&u(!1),n&&i&&!g(i)&&u(!1),r}d(r,e);var n=r.prototype;return n.shouldComponentUpdate=function(e){return this.props.shouldUpdate?this.props.shouldUpdate(e,this.props):e.name!==this.props.name||k(e.formik.values,this.props.name)!==k(this.props.formik.values,this.props.name)||k(e.formik.errors,this.props.name)!==k(this.props.formik.errors,this.props.name)||k(e.formik.touched,this.props.name)!==k(this.props.formik.touched,this.props.name)||Object.keys(this.props).length!==Object.keys(e).length||e.formik.isSubmitting!==this.props.formik.isSubmitting},n.componentDidMount=function(){this.props.formik.registerField(this.props.name,{validate:this.props.validate})},n.componentDidUpdate=function(e){this.props.name!==e.name&&(this.props.formik.unregisterField(e.name),this.props.formik.registerField(this.props.name,{validate:this.props.validate})),this.props.validate!==e.validate&&this.props.formik.registerField(this.props.name,{validate:this.props.validate})},n.componentWillUnmount=function(){this.props.formik.unregisterField(this.props.name)},n.render=function(){var e=this.props,r=e.name,n=e.render,i=e.as,a=e.children,o=e.component,u=e.formik,s=f(e,["validate","name","render","as","children","component","shouldUpdate","formik"]),l=f(u,["validate","validationSchema"]),c={value:"radio"===s.type||"checkbox"===s.type?s.value:k(u.values,r),name:r,onChange:u.handleChange,onBlur:u.handleBlur},d={field:c,meta:{value:k(u.values,r),error:k(u.errors,r),touched:!!k(u.touched,r),initialValue:k(u.initialValues,r),initialTouched:!!k(u.initialTouched,r),initialError:k(u.initialErrors,r)},form:l};if(n)return n(d);if(m(a))return a(d);if(o){if("string"==typeof o){var v=s.innerRef,h=f(s,["innerRef"]);return t.createElement(o,p({ref:v},c,h),a)}return t.createElement(o,p({field:c,form:u},s),a)}var y=i||"input";if("string"==typeof y){var E=s.innerRef,S=f(s,["innerRef"]);return t.createElement(y,p({ref:E},c,S),a)}return t.createElement(y,p({},c,s),a)},r}(t.Component));exports.ErrorMessage=re,exports.FastField=ne,exports.Field=function(e){var r=e.validate,n=e.name,i=e.render,a=e.children,o=e.as,u=e.component,s=f(e,["validate","name","render","children","as","component"]),l=f(I(),["validate","validationSchema"]),c=l.registerField,d=l.unregisterField;t.useEffect((function(){return c(n,{validate:r}),function(){d(n)}}),[c,d,n,r]);var v=l.getFieldProps(p({name:n},s)),h=l.getFieldMeta(n),y={field:v,form:l};if(i)return i(p({},y,{meta:h}));if(m(a))return a(p({},y,{meta:h}));if(u){if("string"==typeof u){var E=s.innerRef,S=f(s,["innerRef","parse","format"]);return t.createElement(u,p({ref:E},v,S),a)}return t.createElement(u,p({field:v,form:l},s),a)}var g=o||"input";if("string"==typeof g){var T=s.innerRef,b=f(s,["innerRef","parse","format"]);return t.createElement(g,p({ref:T},v,b),a)}return t.createElement(g,p({},v,s),a)},exports.FieldArray=te,exports.Form=Y,exports.Formik=L,exports.FormikConsumer=A,exports.FormikContext=O,exports.FormikProvider=C,exports.connect=z,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=k,exports.insert=X,exports.isEmptyArray=h,exports.isEmptyChildren=g,exports.isFunction=m,exports.isInputEvent=b,exports.isInteger=E,exports.isNaN=function(e){return e!=e},exports.isObject=y,exports.isPromise=T,exports.isReactNative=F,exports.isString=S,exports.move=J,exports.prepareDataForValidation=B,exports.replace=Z,exports.setIn=_,exports.setNestedObjectValues=R,exports.swap=Q,exports.useField=function(e){var r=I(),n=r.getFieldProps,i=r.getFieldMeta,a=r.getFieldHelpers,o=r.registerField,s=r.unregisterField,l=y(e)?e:{name:e},c=l.name,p=l.validate;return t.useEffect((function(){return c&&o(c,{validate:p}),function(){c&&s(c)}}),[o,s,c,p]),c||u(!1),[n(l),i(c),a(c)]},exports.useFormik=M,exports.useFormikContext=I,exports.validateYupSchema=N,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=f(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 m(i.validationSchema)?i.validationSchema(n.props):i.validationSchema},n.handleSubmit=function(e,t){return i.handleSubmit(e,p({},t,{props:n.props}))},n.renderFormComponent=function(r){return t.createElement(e,Object.assign({},n.props,r))},n}return d(a,r),a.prototype.render=function(){var e=f(this.props,["children"]);return t.createElement(L,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+")",l(a,e)}},exports.yupToFormErrors=j; | ||
"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")),o=e(require("lodash/toPath")),u=e(require("tiny-warning")),s=require("scheduler"),l=e(require("hoist-non-react-statics")),c=e(require("lodash/cloneDeep"));function p(){return(p=Object.assign||function(e){for(var 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 f(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 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)},g=function(e){return 0===t.Children.count(e)},T=function(e){return y(e)&&m(e.then)},b=function(e){return e&&y(e)&&y(e.target)},F="undefined"!=typeof window&&window.navigator&&window.navigator.product&&"ReactNative"===window.navigator.product;function k(e,t,r,n){void 0===n&&(n=0);for(var i=o(t);e&&n<i.length;)e=e[i[n++]];return void 0===e?r:e}function O(e,t,r){for(var n=a(e),i=n,u=0,s=o(t);u<s.length-1;u++){var l=s[u],c=k(e,s.slice(0,u+1));if(c&&(y(c)||Array.isArray(c)))i=i[l]=a(c);else{var p=s[u+1];i=i[l]=E(p)&&Number(p)>=0?[]:{}}}return(0===u?e:i)[s[u]]===r?e:(void 0===r?delete i[s[u]]:i[s[u]]=r,0===u&&void 0===r&&delete n[s[u]],n)}function _(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 o=a[i],u=e[o];y(u)?r.get(u)||(r.set(u,!0),n[o]=Array.isArray(u)?[]:{},_(u,t,r,n[o])):n[o]=t}return n}var R=t.createContext(void 0),C=R.Provider,A=R.Consumer;function I(){var e=t.useContext(R);return e||u(!1),e}var x=function(e,t){return e},P=function(e,t){var r=parseFloat(e);return isNaN(r)?"":r},w=function(e,t){return void 0===e?"":e};function U(e,t){switch(t.type){case"SET_VALUES":return p({},e,{values:t.payload});case"SET_TOUCHED":return p({},e,{touched:t.payload});case"SET_ERRORS":return r(e.errors,t.payload)?e:p({},e,{errors:t.payload});case"SET_STATUS":return p({},e,{status:t.payload});case"SET_ISSUBMITTING":return p({},e,{isSubmitting:t.payload});case"SET_ISVALIDATING":return p({},e,{isValidating:t.payload});case"SET_FIELD_VALUE":return p({},e,{values:O(e.values,t.payload.field,t.payload.value)});case"SET_FIELD_TOUCHED":return p({},e,{touched:O(e.touched,t.payload.field,t.payload.value)});case"SET_FIELD_ERROR":return p({},e,{errors:O(e.errors,t.payload.field,t.payload.value)});case"RESET_FORM":return p({},e,t.payload);case"SET_FORMIK_STATE":return t.payload(e);case"SUBMIT_ATTEMPT":return p({},e,{touched:_(e.values,!0),isSubmitting:!0,submitCount:e.submitCount+1});case"SUBMIT_FAILURE":case"SUBMIT_SUCCESS":return p({},e,{isSubmitting:!1});default:return e}}var V={},D={};function M(e){var i=e.validateOnChange,a=void 0===i||i,o=e.validateOnBlur,u=void 0===o||o,l=e.validateOnMount,c=void 0!==l&&l,d=e.isInitialValid,v=e.enableReinitialize,h=void 0!==v&&v,E=e.onSubmit,g=f(e,["validateOnChange","validateOnBlur","validateOnMount","isInitialValid","enableReinitialize","onSubmit"]),_=p({validateOnChange:a,validateOnBlur:u,validateOnMount:c,onSubmit:E},g),R=t.useRef(_.initialValues),C=t.useRef(_.initialErrors||V),A=t.useRef(_.initialTouched||D),I=t.useRef(_.initialStatus),M=t.useRef(!1),L=t.useRef({});t.useEffect((function(){return M.current=!0,function(){M.current=!1}}),[]);var B=t.useReducer(U,{values:_.initialValues,errors:_.initialErrors||V,touched:_.initialTouched||D,status:_.initialStatus,isSubmitting:!1,isValidating:!1,submitCount:0}),W=B[0],Y=B[1],z=t.useCallback((function(e,t){return new Promise((function(r,n){var i=_.validate(e,t);null==i?r(V):T(i)?i.then((function(e){r(e||V)}),(function(e){n(e)})):r(i)}))}),[_.validate]),J=t.useCallback((function(e,t){var r=_.validationSchema,n=m(r)?r(t):r,i=t&&n.validateAt?n.validateAt(t,e):N(e,n);return new Promise((function(e,t){i.then((function(){e(V)}),(function(r){"ValidationError"===r.name?e(j(r)):t(r)}))}))}),[_.validationSchema]),Q=t.useCallback((function(e,t){return new Promise((function(r){return r(L.current[e].validate(t))}))}),[]),X=t.useCallback((function(e){var t=Object.keys(L.current).filter((function(e){return m(L.current[e].validate)})),r=t.length>0?t.map((function(t){return Q(t,k(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=O(e,t[n],r)),e)}),{})}))}),[Q]),Z=t.useCallback((function(e){return Promise.all([X(e),_.validationSchema?J(e):{},_.validate?z(e):{}]).then((function(e){return n.all([e[0],e[1],e[2]],{arrayMerge:q})}))}),[_.validate,_.validationSchema,X,z,J]),$=K((function(e){return void 0===e&&(e=W.values),t=function(){return Z(e).then((function(e){return M.current&&Y({type:"SET_ERRORS",payload:e}),e})).catch((function(e){}))},s.unstable_runWithPriority(s.unstable_LowPriority,(function(){return s.unstable_scheduleCallback(s.unstable_LowPriority,t)}));var t})),ee=K((function(e){return void 0===e&&(e=W.values),Y({type:"SET_ISVALIDATING",payload:!0}),Z(e).then((function(e){return M.current&&(Y({type:"SET_ISVALIDATING",payload:!1}),r(W.errors,e)||Y({type:"SET_ERRORS",payload:e})),e}))}));t.useEffect((function(){c&&!0===M.current&&r(R.current,_.initialValues)&&$(R.current)}),[c,$]);var te=t.useCallback((function(e){var t=e&&e.values?e.values:R.current,r=e&&e.errors?e.errors:C.current?C.current:_.initialErrors||{},n=e&&e.touched?e.touched:A.current?A.current:_.initialTouched||{},i=e&&e.status?e.status:I.current?I.current:_.initialStatus;R.current=t,C.current=r,A.current=n,I.current=i;var a=function(){Y({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(_.onReset){var o=_.onReset(W.values,ge);T(o)?o.then(a):a()}else a()}),[_.initialErrors,_.initialStatus,_.initialTouched]);t.useEffect((function(){!0!==M.current||r(R.current,_.initialValues)||(h&&(R.current=_.initialValues,te()),c&&$(R.current))}),[h,_.initialValues,te,c,$]),t.useEffect((function(){h&&!0===M.current&&!r(C.current,_.initialErrors)&&(C.current=_.initialErrors||V,Y({type:"SET_ERRORS",payload:_.initialErrors||V}))}),[h,_.initialErrors]),t.useEffect((function(){h&&!0===M.current&&!r(A.current,_.initialTouched)&&(A.current=_.initialTouched||D,Y({type:"SET_TOUCHED",payload:_.initialTouched||D}))}),[h,_.initialTouched]),t.useEffect((function(){h&&!0===M.current&&!r(I.current,_.initialStatus)&&(I.current=_.initialStatus,Y({type:"SET_STATUS",payload:_.initialStatus}))}),[h,_.initialStatus,_.initialTouched]);var re=K((function(e){if(L.current[e]&&m(L.current[e].validate)){var t=k(W.values,e),r=L.current[e].validate(t);return T(r)?(Y({type:"SET_ISVALIDATING",payload:!0}),r.then((function(e){return e})).then((function(t){Y({type:"SET_FIELD_ERROR",payload:{field:e,value:t}}),Y({type:"SET_ISVALIDATING",payload:!1})}))):(Y({type:"SET_FIELD_ERROR",payload:{field:e,value:r}}),Promise.resolve(r))}return _.validationSchema?(Y({type:"SET_ISVALIDATING",payload:!0}),J(W.values,e).then((function(e){return e})).then((function(t){Y({type:"SET_FIELD_ERROR",payload:{field:e,value:t[e]}}),Y({type:"SET_ISVALIDATING",payload:!1})}))):Promise.resolve()})),ne=t.useCallback((function(e,t){L.current[e]={validate:t.validate}}),[]),ie=t.useCallback((function(e){delete L.current[e]}),[]),ae=K((function(e,t){return Y({type:"SET_TOUCHED",payload:e}),(void 0===t?u:t)?$(W.values):Promise.resolve()})),oe=t.useCallback((function(e){Y({type:"SET_ERRORS",payload:e})}),[]),ue=K((function(e,t){var r=m(e)?e(W.values):e;return Y({type:"SET_VALUES",payload:r}),(void 0===t?a:t)?$(r):Promise.resolve()})),se=t.useCallback((function(e,t){Y({type:"SET_FIELD_ERROR",payload:{field:e,value:t}})}),[]),le=K((function(e,t,r){return Y({type:"SET_FIELD_VALUE",payload:{field:e,value:t}}),(void 0===r?a:r)?$(O(W.values,e,t)):Promise.resolve()})),ce=t.useCallback((function(e,t){var r,n=t,i=e;if(!S(e)){e.persist&&e.persist();var a=e.target?e.target:e.currentTarget,o=a.type,u=a.value,s=a.checked,l=a.options,c=a.multiple;n=t||a.name||a.id,i=/number|range/.test(o)?(r=parseFloat(u),isNaN(r)?"":r):/checkbox/.test(o)?H(k(W.values,n),s,u):c?G(l):u}n&&le(n,i)}),[le,W.values]),pe=K((function(e){if(S(e))return function(t){return ce(t,e)};ce(e)})),de=K((function(e,t,r){return void 0===t&&(t=!0),Y({type:"SET_FIELD_TOUCHED",payload:{field:e,value:t}}),(void 0===r?u:r)?$(W.values):Promise.resolve()})),fe=t.useCallback((function(e,t){e.persist&&e.persist();var r=e.target;de(t||r.name||r.id,!0)}),[de]),ve=K((function(e){if(S(e))return function(t){return fe(t,e)};fe(e)})),he=t.useCallback((function(e){m(e)?Y({type:"SET_FORMIK_STATE",payload:e}):Y({type:"SET_FORMIK_STATE",payload:function(){return e}})}),[]),me=t.useCallback((function(e){Y({type:"SET_STATUS",payload:e})}),[]),ye=t.useCallback((function(e){Y({type:"SET_ISSUBMITTING",payload:e})}),[]),Ee=K((function(){return Y({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=Te()))return}catch(e){throw e}return Promise.resolve(r).then((function(e){return M.current&&Y({type:"SUBMIT_SUCCESS"}),e})).catch((function(e){if(M.current)throw Y({type:"SUBMIT_FAILURE"}),e}))}if(M.current&&(Y({type:"SUBMIT_FAILURE"}),t))throw e}))})),Se=K((function(e){e&&e.preventDefault&&m(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&m(e.stopPropagation)&&e.stopPropagation(),Ee().catch((function(e){console.warn("Warning: An unhandled error was caught from submitForm()",e)}))})),ge={resetForm:te,validateForm:ee,validateField:re,setErrors:oe,setFieldError:se,setFieldTouched:de,setFieldValue:le,setStatus:me,setSubmitting:ye,setTouched:ae,setValues:ue,setFormikState:he,submitForm:Ee},Te=K((function(){return E(W.values,ge)})),be=K((function(e){e&&e.preventDefault&&m(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&m(e.stopPropagation)&&e.stopPropagation(),te()})),Fe=t.useCallback((function(e){return{value:k(W.values,e),error:k(W.errors,e),touched:!!k(W.touched,e),initialValue:k(R.current,e),initialTouched:!!k(A.current,e),initialError:k(C.current,e)}}),[W.errors,W.touched,W.values]),ke=K((function(e){return{setValue:function(t,r){return le(e,t,r)},setTouched:function(t,r){return de(e,t,r)},setError:function(t){return se(e,t)}}})),Oe=K((function(e,t){if(!F&&e.nativeEvent&&void 0!==e.nativeEvent.text)return e.nativeEvent.text;if(F&&e.nativeEvent)return e.nativeEvent.text;var r=e.target?e.target:e.currentTarget,n=r.value,i=r.checked,a=r.options,o=r.multiple;return/checkbox/.test(r.type)?H(k(W.values,t),i,n):o?G(a):n})),_e=t.useCallback((function(e){var t=y(e),r=t?e.name?e.name:e.id:e,n=k(W.values,r),i=k(W.touched,r),a={name:r,value:n,onChange:pe,onBlur:ve};if(t){var o=e.type,u=e.value,s=e.as,l=e.multiple,c=e.parse,p=void 0===c?/number|range/.test(o)?P:x:c,d=e.format,f=void 0===d?w:d,v=e.formatOnBlur,h=void 0!==v&&v;"checkbox"===o?void 0===u?a.checked=!!n:(a.checked=!(!Array.isArray(n)||!~n.indexOf(u)),a.value=u):"radio"===o?(a.checked=n===u,a.value=u):"select"===s&&l&&(a.value=a.value||[],a.multiple=!0),"radio"!==o&&"checkbox"!==o&&f&&(!0===h?!0===i&&(a.value=f(a.value)):a.value=f(a.value)),"radio"!==o&&"checkbox"!==o&&(a.onChange=function(e){b(e)?(e.persist&&e.persist(),le(r,p(Oe(e,r)))):le(r,p(e))})}return a}),[Oe,ve,pe,le,W.touched,W.values]),Re=t.useMemo((function(){return!r(R.current,W.values)}),[R.current,W.values]),Ce=t.useMemo((function(){return void 0!==d?Re?W.errors&&0===Object.keys(W.errors).length:!1!==d&&m(d)?d(_):d:W.errors&&0===Object.keys(W.errors).length}),[d,Re,W.errors,_]);return p({},W,{initialValues:R.current,initialErrors:C.current,initialTouched:A.current,initialStatus:I.current,handleBlur:ve,handleChange:pe,handleReset:be,handleSubmit:Se,resetForm:te,setErrors:oe,setFormikState:he,setFieldTouched:de,setFieldValue:le,setFieldError:se,setStatus:me,setSubmitting:ye,setTouched:ae,setValues:ue,submitForm:Ee,validateForm:ee,validateField:re,isValid:Ce,dirty:Re,unregisterField:ie,registerField:ne,getFieldProps:_e,getFieldMeta:Fe,getFieldHelpers:ke,validateOnBlur:u,validateOnChange:a,validateOnMount:c})}function L(e){var r=M(e),n=e.component,i=e.children,a=e.render;return t.useImperativeHandle(e.innerRef,(function(){return r})),t.createElement(C,{value:r},n?t.createElement(n,r):a?a(r):i?m(i)?i(r):g(i)?null:t.Children.only(i):null)}function j(e){var t={};if(e.inner){if(0===e.inner.length)return O(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 o=a;k(t,o.path)||(t=O(t,o.path,o.message))}}return t}function N(e,t,r,n){void 0===r&&(r=!1),void 0===n&&(n={});var i=B(e);return t[r?"validateSync":"validate"](i,{abortEarly:!1,context:n})}function B(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)?B(e):""!==e?e:void 0})):i(e[n])?B(e[n]):""!==e[n]?e[n]:void 0}return t}function q(e,t,r){var i=e.slice();return t.forEach((function(t,a){if(void 0===i[a]){var o=!1!==r.clone&&r.isMergeableObject(t);i[a]=o?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}function G(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 H(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 W="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t.useLayoutEffect:t.useEffect;function K(e){var r=t.useRef(e);return W((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)}),[])}var Y=t.forwardRef((function(e,r){var n=e.action,i=f(e,["action"]),a=n||"#",o=I();return t.createElement("form",Object.assign({onSubmit:o.handleSubmit,ref:r,onReset:o.handleReset,action:a},i))}));function z(e){var r=function(r){return t.createElement(A,null,(function(n){return n||u(!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)}Y.displayName="Form";var J=function(e,t,r){var n=$(e),i=n[t];return n.splice(t,1),n.splice(r,0,i),n},Q=function(e,t,r){var n=$(e),i=n[t];return n[t]=n[r],n[r]=i,n},X=function(e,t,r){var n=$(e);return n.splice(t,0,r),n},Z=function(e,t,r){var n=$(e);return n[t]=r,n},$=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(p({},e,{length:t+1}))}return[]},ee=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,o="function"==typeof t?t:e,u=O(r.values,a,e(k(r.values,a))),s=n?i(k(r.errors,a)):void 0,l=t?o(k(r.touched,a)):void 0;return h(s)&&(s=void 0),h(l)&&(l=void 0),p({},r,{values:u,errors:n?O(r.errors,a,s):r.errors,touched:t?O(r.touched,a,l):r.touched})}))},r.push=function(e){return r.updateArrayField((function(t){return[].concat($(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 Q(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 J(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 X(r,e,t)}),(function(t){return X(t,e,null)}),(function(t){return X(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 Z(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(k(e.formik.values,e.name),k(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?$(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,a=e.name,o=p({},{push:this.push,pop:this.pop,swap:this.swap,move:this.move,insert:this.insert,replace:this.replace,unshift:this.unshift,remove:this.remove,handlePush:this.handlePush,handlePop:this.handlePop,handleSwap:this.handleSwap,handleMove:this.handleMove,handleInsert:this.handleInsert,handleReplace:this.handleReplace,handleUnshift:this.handleUnshift,handleRemove:this.handleRemove},{form:f(e.formik,["validate","validationSchema"]),name:a});return r?t.createElement(r,o):n?n(o):i?"function"==typeof i?i(o):g(i)?null:t.Children.only(i):null},n}(t.Component);ee.defaultProps={validateOnChange:!0};var te=z(ee),re=z(function(e){function r(){return e.apply(this,arguments)||this}d(r,e);var n=r.prototype;return n.shouldComponentUpdate=function(e){return k(this.props.formik.errors,this.props.name)!==k(e.formik.errors,this.props.name)||k(this.props.formik.touched,this.props.name)!==k(e.formik.touched,this.props.name)||Object.keys(this.props).length!==Object.keys(e).length},n.render=function(){var e=this.props,r=e.component,n=e.formik,i=e.render,a=e.children,o=e.name,u=f(e,["component","formik","render","children","name"]),s=k(n.touched,o),l=k(n.errors,o);return s&&l?i?m(i)?i(l):null:a?m(a)?a(l):null:r?t.createElement(r,u,l):l:null},r}(t.Component)),ne=z(function(e){function r(t){var r;r=e.call(this,t)||this;var n=t.render,i=t.children,a=t.component,o=t.as;return n&&u(!1),a&&n&&u(!1),o&&i&&m(i)&&u(!1),a&&i&&m(i)&&u(!1),n&&i&&!g(i)&&u(!1),r}d(r,e);var n=r.prototype;return n.shouldComponentUpdate=function(e){return this.props.shouldUpdate?this.props.shouldUpdate(e,this.props):e.name!==this.props.name||k(e.formik.values,this.props.name)!==k(this.props.formik.values,this.props.name)||k(e.formik.errors,this.props.name)!==k(this.props.formik.errors,this.props.name)||k(e.formik.touched,this.props.name)!==k(this.props.formik.touched,this.props.name)||Object.keys(this.props).length!==Object.keys(e).length||e.formik.isSubmitting!==this.props.formik.isSubmitting},n.componentDidMount=function(){this.props.formik.registerField(this.props.name,{validate:this.props.validate})},n.componentDidUpdate=function(e){this.props.name!==e.name&&(this.props.formik.unregisterField(e.name),this.props.formik.registerField(this.props.name,{validate:this.props.validate})),this.props.validate!==e.validate&&this.props.formik.registerField(this.props.name,{validate:this.props.validate})},n.componentWillUnmount=function(){this.props.formik.unregisterField(this.props.name)},n.render=function(){var e=this.props,r=e.name,n=e.render,i=e.as,a=e.children,o=e.component,u=e.formik,s=f(e,["validate","name","render","as","children","component","shouldUpdate","formik"]),l=f(u,["validate","validationSchema"]),c={value:"radio"===s.type||"checkbox"===s.type?s.value:k(u.values,r),name:r,onChange:u.handleChange,onBlur:u.handleBlur},d={field:c,meta:{value:k(u.values,r),error:k(u.errors,r),touched:!!k(u.touched,r),initialValue:k(u.initialValues,r),initialTouched:!!k(u.initialTouched,r),initialError:k(u.initialErrors,r)},form:l};if(n)return n(d);if(m(a))return a(d);if(o){if("string"==typeof o){var v=s.innerRef,h=f(s,["innerRef"]);return t.createElement(o,p({ref:v},c,h),a)}return t.createElement(o,p({field:c,form:u},s),a)}var y=i||"input";if("string"==typeof y){var E=s.innerRef,S=f(s,["innerRef"]);return t.createElement(y,p({ref:E},c,S),a)}return t.createElement(y,p({},c,s),a)},r}(t.Component));exports.ErrorMessage=re,exports.FastField=ne,exports.Field=function(e){var r=e.validate,n=e.name,i=e.render,a=e.children,o=e.as,u=e.component,s=f(e,["validate","name","render","children","as","component"]),l=f(I(),["validate","validationSchema"]),c=l.registerField,d=l.unregisterField;t.useEffect((function(){return c(n,{validate:r}),function(){d(n)}}),[c,d,n,r]);var v=l.getFieldProps(p({name:n},s)),h=l.getFieldMeta(n),y={field:v,form:l};if(i)return i(p({},y,{meta:h}));if(m(a))return a(p({},y,{meta:h}));if(u){if("string"==typeof u){var E=s.innerRef,S=f(s,["innerRef","parse","format","formatOnBlur"]);return t.createElement(u,p({ref:E},v,S),a)}var g=f(s,["parse","format","formatOnBlur"]);return t.createElement(u,p({field:v,form:l},g),a)}var T=o||"input";if("string"==typeof T){var b=s.innerRef,F=f(s,["innerRef","parse","format","formatOnBlur"]);return t.createElement(T,p({ref:b},v,F),a)}var k=f(s,["parse","format","formatOnBlur"]);return t.createElement(T,p({},v,k),a)},exports.FieldArray=te,exports.Form=Y,exports.Formik=L,exports.FormikConsumer=A,exports.FormikContext=R,exports.FormikProvider=C,exports.connect=z,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=k,exports.insert=X,exports.isEmptyArray=h,exports.isEmptyChildren=g,exports.isFunction=m,exports.isInputEvent=b,exports.isInteger=E,exports.isNaN=function(e){return e!=e},exports.isObject=y,exports.isPromise=T,exports.isReactNative=F,exports.isString=S,exports.move=J,exports.prepareDataForValidation=B,exports.replace=Z,exports.setIn=O,exports.setNestedObjectValues=_,exports.swap=Q,exports.useField=function(e){var r=I(),n=r.getFieldProps,i=r.getFieldMeta,a=r.getFieldHelpers,o=r.registerField,s=r.unregisterField,l=y(e)?e:{name:e},c=l.name,p=l.validate;return t.useEffect((function(){return c&&o(c,{validate:p}),function(){c&&s(c)}}),[o,s,c,p]),c||u(!1),[n(l),i(c),a(c)]},exports.useFormik=M,exports.useFormikContext=I,exports.validateYupSchema=N,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=f(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 m(i.validationSchema)?i.validationSchema(n.props):i.validationSchema},n.handleSubmit=function(e,t){return i.handleSubmit(e,p({},t,{props:n.props}))},n.renderFormComponent=function(r){return t.createElement(e,Object.assign({},n.props,r))},n}return d(a,r),a.prototype.render=function(){var e=f(this.props,["children"]);return t.createElement(L,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+")",l(a,e)}},exports.yupToFormErrors=j; | ||
//# sourceMappingURL=formik.cjs.production.min.js.map |
{ | ||
"name": "formik", | ||
"description": "Forms in React, without tears", | ||
"version": "3.0.0-next.0", | ||
"version": "3.0.0-next.1", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "author": "Jared Palmer <jared@palmer.net>", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
615865
4430