Comparing version 2.0.1-rc.13 to 2.0.1-rc.14
@@ -122,3 +122,3 @@ 'use strict'; | ||
if (currentObj) { | ||
if (currentObj && (isObject(currentObj) || Array.isArray(currentObj))) { | ||
resVal = resVal[currentPath] = clone(currentObj); | ||
@@ -233,5 +233,7 @@ } else { | ||
case 'RESET_FORM': | ||
case 'SET_FORMIK_STATE': | ||
return _extends({}, state, msg.payload); | ||
case 'SET_FORMIK_STATE': | ||
return msg.payload(state); | ||
case 'SUBMIT_ATTEMPT': | ||
@@ -266,2 +268,4 @@ return _extends({}, state, { | ||
validateOnBlur = _ref$validateOnBlur === void 0 ? true : _ref$validateOnBlur, | ||
_ref$validateOnMount = _ref.validateOnMount, | ||
validateOnMount = _ref$validateOnMount === void 0 ? false : _ref$validateOnMount, | ||
isInitialValid = _ref.isInitialValid, | ||
@@ -271,3 +275,3 @@ _ref$enableReinitiali = _ref.enableReinitialize, | ||
onSubmit = _ref.onSubmit, | ||
rest = _objectWithoutPropertiesLoose(_ref, ["validateOnChange", "validateOnBlur", "isInitialValid", "enableReinitialize", "onSubmit"]); | ||
rest = _objectWithoutPropertiesLoose(_ref, ["validateOnChange", "validateOnBlur", "validateOnMount", "isInitialValid", "enableReinitialize", "onSubmit"]); | ||
@@ -277,2 +281,3 @@ var props = _extends({ | ||
validateOnBlur: validateOnBlur, | ||
validateOnMount: validateOnMount, | ||
onSubmit: onSubmit | ||
@@ -333,6 +338,6 @@ }, rest); | ||
var runValidationSchema = React.useCallback(function (values, field) { | ||
var validationSchema = props.validationSchema; | ||
var schema = isFunction(validationSchema) ? validationSchema(field) : validationSchema; | ||
var promise = field && schema.validateAt ? schema.validateAt(field, values) : validateYupSchema(values, schema); | ||
return new Promise(function (resolve, reject) { | ||
var validationSchema = props.validationSchema; | ||
var schema = isFunction(validationSchema) ? validationSchema(field) : validationSchema; | ||
var promise = field && schema.validateAt ? schema.validateAt(field, values) : validateYupSchema(values, schema); | ||
promise.then(function () { | ||
@@ -463,2 +468,29 @@ resolve(emptyErrors); | ||
}, [enableReinitialize, props.initialValues, resetForm]); | ||
React.useEffect(function () { | ||
if (enableReinitialize && isMounted.current === true && !isEqual(initialErrors.current, props.initialErrors)) { | ||
initialErrors.current = props.initialErrors || emptyErrors; | ||
dispatch({ | ||
type: 'SET_ERRORS', | ||
payload: props.initialErrors || emptyErrors | ||
}); | ||
} | ||
}, [enableReinitialize, props.initialErrors]); | ||
React.useEffect(function () { | ||
if (enableReinitialize && isMounted.current === true && !isEqual(initialTouched.current, props.initialTouched)) { | ||
initialTouched.current = props.initialTouched || emptyTouched; | ||
dispatch({ | ||
type: 'SET_TOUCHED', | ||
payload: props.initialTouched || emptyTouched | ||
}); | ||
} | ||
}, [enableReinitialize, props.initialTouched]); | ||
React.useEffect(function () { | ||
if (enableReinitialize && isMounted.current === true && !isEqual(initialStatus.current, props.initialStatus)) { | ||
initialStatus.current = props.initialStatus; | ||
dispatch({ | ||
type: 'SET_STATUS', | ||
payload: props.initialStatus | ||
}); | ||
} | ||
}, [enableReinitialize, props.initialStatus, props.initialTouched]); | ||
var validateField = useEventCallback(function (name) { | ||
@@ -648,8 +680,7 @@ if (isFunction(fieldRegistry.current[name].validate)) { | ||
}, [executeBlur]); | ||
function setFormikState(stateOrCb) { | ||
var setFormikState = React.useCallback(function (stateOrCb) { | ||
if (isFunction(stateOrCb)) { | ||
dispatch({ | ||
type: 'SET_FORMIK_STATE', | ||
payload: stateOrCb(state) | ||
payload: stateOrCb | ||
}); | ||
@@ -659,7 +690,8 @@ } else { | ||
type: 'SET_FORMIK_STATE', | ||
payload: stateOrCb | ||
payload: function payload() { | ||
return stateOrCb; | ||
} | ||
}); | ||
} | ||
} | ||
}, []); | ||
var setStatus = React.useCallback(function (status) { | ||
@@ -842,3 +874,4 @@ dispatch({ | ||
validateOnBlur: validateOnBlur, | ||
validateOnChange: validateOnChange | ||
validateOnChange: validateOnChange, | ||
validateOnMount: validateOnMount | ||
}); | ||
@@ -868,22 +901,24 @@ | ||
if (yupError.inner.length === 0) { | ||
return setIn(errors, yupError.path, yupError.message); | ||
} | ||
if (yupError.inner) { | ||
if (yupError.inner.length === 0) { | ||
return setIn(errors, yupError.path, yupError.message); | ||
} | ||
for (var _iterator = yupError.inner, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref6; | ||
for (var _iterator = yupError.inner, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref6; | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref6 = _iterator[_i++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref6 = _i.value; | ||
} | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref6 = _iterator[_i++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref6 = _i.value; | ||
} | ||
var err = _ref6; | ||
var err = _ref6; | ||
if (!errors[err.path]) { | ||
errors = setIn(errors, err.path, err.message); | ||
if (!getIn(errors, err.path)) { | ||
errors = setIn(errors, err.path, err.message); | ||
} | ||
} | ||
@@ -903,15 +938,33 @@ } | ||
var validateData = {}; | ||
var validateData = prepareDataForValidation(values); | ||
return schema[sync ? 'validateSync' : 'validate'](validateData, { | ||
abortEarly: false, | ||
context: context | ||
}); | ||
} | ||
function prepareDataForValidation(values) { | ||
var data = {}; | ||
for (var k in values) { | ||
if (values.hasOwnProperty(k)) { | ||
var key = String(k); | ||
validateData[key] = values[key] !== '' ? values[key] : undefined; | ||
if (Array.isArray(values[key]) === true) { | ||
data[key] = values[key].map(function (value) { | ||
if (Array.isArray(value) === true || typeof value === 'object') { | ||
return prepareDataForValidation(value); | ||
} else { | ||
return value !== '' ? value : undefined; | ||
} | ||
}); | ||
} else if (typeof values[key] === 'object' && values[key] !== null) { | ||
data[key] = prepareDataForValidation(values[key]); | ||
} else { | ||
data[key] = values[key] !== '' ? values[key] : undefined; | ||
} | ||
} | ||
} | ||
return schema[sync ? 'validateSync' : 'validate'](validateData, { | ||
abortEarly: false, | ||
context: context | ||
}); | ||
return data; | ||
} | ||
@@ -936,3 +989,3 @@ | ||
function getSelectedValues(options) { | ||
return options.filter(function (el) { | ||
return Array.from(options).filter(function (el) { | ||
return el.selected; | ||
@@ -966,5 +1019,7 @@ }).map(function (el) { | ||
var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? React.useLayoutEffect : React.useEffect; | ||
function useEventCallback(fn) { | ||
var ref = React.useRef(); | ||
React.useLayoutEffect(function () { | ||
var ref = React.useRef(fn); | ||
useIsomorphicLayoutEffect(function () { | ||
ref.current = fn; | ||
@@ -1106,2 +1161,7 @@ }); | ||
function Form(props) { | ||
var action = props.action, | ||
rest = _objectWithoutPropertiesLoose(props, ["action"]); | ||
var _action = action || "#"; | ||
var _useFormikContext = useFormikContext(), | ||
@@ -1113,4 +1173,5 @@ handleReset = _useFormikContext.handleReset, | ||
onSubmit: handleSubmit, | ||
onReset: handleReset | ||
}, props)); | ||
onReset: handleReset, | ||
action: _action | ||
}, rest)); | ||
} | ||
@@ -1117,0 +1178,0 @@ Form.displayName = 'Form'; |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=require("react"),r=e(require("react-fast-compare")),n=e(require("deepmerge")),i=e(require("lodash/clone")),a=e(require("lodash/toPath")),o=e(require("tiny-warning")),u=require("scheduler"),l=e(require("hoist-non-react-statics")),s=e(require("lodash/cloneDeep"));function c(){return(c=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={},a=Object.keys(e);for(n=0;n<a.length;n++)t.indexOf(r=a[n])>=0||(i[r]=e[r]);return i}function f(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var v=function(e){return"function"==typeof e},h=function(e){return null!==e&&"object"==typeof e},m=function(e){return String(Math.floor(Number(e)))===e},y=function(e){return"[object String]"===Object.prototype.toString.call(e)},S=function(e){return 0===t.Children.count(e)},E=function(e){return h(e)&&v(e.then)};function T(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 b(e,t,r){for(var n=i(e),o=n,u=0,l=a(t);u<l.length-1;u++){var s=l[u],c=T(e,l.slice(0,u+1));if(c)o=o[s]=i(c);else{var d=l[u+1];o=o[s]=m(d)&&Number(d)>=0?[]:{}}}return(0===u?e:o)[l[u]]===r?e:(void 0===r?delete o[l[u]]:o[l[u]]=r,0===u&&void 0===r&&delete n[l[u]],n)}function g(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];h(u)?r.get(u)||(r.set(u,!0),n[o]=Array.isArray(u)?[]:{},g(u,t,r,n[o])):n[o]=t}return n}var F=t.createContext(void 0),_=F.Provider,R=F.Consumer;function C(){var e=t.useContext(F);return e||o(!1),e}function O(e,t){switch(t.type){case"SET_VALUES":return c({},e,{values:t.payload});case"SET_TOUCHED":return c({},e,{touched:t.payload});case"SET_ERRORS":return c({},e,{errors:t.payload});case"SET_STATUS":return c({},e,{status:t.payload});case"SET_ISSUBMITTING":return c({},e,{isSubmitting:t.payload});case"SET_ISVALIDATING":return c({},e,{isValidating:t.payload});case"SET_FIELD_VALUE":return c({},e,{values:b(e.values,t.payload.field,t.payload.value)});case"SET_FIELD_TOUCHED":return c({},e,{touched:b(e.touched,t.payload.field,t.payload.value)});case"SET_FIELD_ERROR":return c({},e,{errors:b(e.errors,t.payload.field,t.payload.value)});case"RESET_FORM":case"SET_FORMIK_STATE":return c({},e,t.payload);case"SUBMIT_ATTEMPT":return c({},e,{touched:g(e.values,!0),isSubmitting:!0,submitCount:e.submitCount+1});case"SUBMIT_FAILURE":case"SUBMIT_SUCCESS":return c({},e,{isSubmitting:!1});default:return e}}var k={},I={};function A(e){var i=e.validateOnChange,a=void 0===i||i,o=e.validateOnBlur,l=void 0===o||o,s=e.isInitialValid,d=e.enableReinitialize,f=void 0!==d&&d,h=e.onSubmit,m=p(e,["validateOnChange","validateOnBlur","isInitialValid","enableReinitialize","onSubmit"]),S=c({validateOnChange:a,validateOnBlur:l,onSubmit:h},m),g=t.useRef(S.initialValues),F=t.useRef(S.initialErrors||k),_=t.useRef(S.initialTouched||I),R=t.useRef(S.initialStatus),C=t.useRef(!1),A=t.useRef({});t.useEffect(function(){},[s]),t.useEffect(function(){return C.current=!0,function(){C.current=!1}},[]);var P=t.useReducer(O,{values:S.initialValues,errors:S.initialErrors||k,touched:S.initialTouched||I,status:S.initialStatus,isSubmitting:!1,isValidating:!1,submitCount:0}),L=P[0],M=P[1],j=t.useCallback(function(e,t){return new Promise(function(r,n){var i=S.validate(e,t);null==i?r(k):E(i)?i.then(function(e){r(e||k)},function(e){n(e)}):r(i)})},[S.validate]),w=t.useCallback(function(e,t){return new Promise(function(r,n){var i=S.validationSchema,a=v(i)?i(t):i;(t&&a.validateAt?a.validateAt(t,e):V(e,a)).then(function(){r(k)},function(e){"ValidationError"===e.name?r(x(e)):n(e)})})},[S.validationSchema]),N=t.useCallback(function(e,t){return new Promise(function(r){return r(A.current[e].validate(t))})},[]),B=t.useCallback(function(e){var t=Object.keys(A.current).filter(function(e){return v(A.current[e].validate)}),r=t.length>0?t.map(function(t){return N(t,T(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=b(e,t[n],r)),e)},{})})},[N]),q=t.useCallback(function(e){return Promise.all([B(e),S.validationSchema?w(e):{},S.validate?j(e):{}]).then(function(e){return n.all([e[0],e[1],e[2]],{arrayMerge:D})})},[S.validate,S.validationSchema,B,j,w]),G=U(function(e){return void 0===e&&(e=L.values),u.unstable_runWithPriority(u.LowPriority,function(){return q(e).then(function(e){return C.current&&M({type:"SET_ERRORS",payload:e}),e})})}),W=U(function(e){return void 0===e&&(e=L.values),M({type:"SET_ISVALIDATING",payload:!0}),q(e).then(function(e){return C.current&&(M({type:"SET_ISVALIDATING",payload:!1}),r(L.errors,e)||M({type:"SET_ERRORS",payload:e})),e})}),H=t.useCallback(function(e){var t=e&&e.values?e.values:g.current,r=e&&e.errors?e.errors:F.current?F.current:S.initialErrors||{},n=e&&e.touched?e.touched:_.current?_.current:S.initialTouched||{},i=e&&e.status?e.status:R.current?R.current:S.initialStatus;g.current=t,F.current=r,_.current=n,R.current=i,M({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}})},[S.initialErrors,S.initialStatus,S.initialTouched]);t.useEffect(function(){f&&!0===C.current&&!r(g.current,S.initialValues)&&(g.current=S.initialValues,H())},[f,S.initialValues,H]);var K=U(function(e){if(v(A.current[e].validate)){var t=T(L.values,e),r=A.current[e].validate(t);return E(r)?(M({type:"SET_ISVALIDATING",payload:!0}),r.then(function(e){return e}).then(function(t){M({type:"SET_FIELD_ERROR",payload:{field:e,value:t}}),M({type:"SET_ISVALIDATING",payload:!1})})):(M({type:"SET_FIELD_ERROR",payload:{field:e,value:r}}),Promise.resolve(r))}return Promise.resolve()}),Y=t.useCallback(function(e,t){A.current[e]={validate:t.validate}},[]),z=t.useCallback(function(e){delete A.current[e]},[]),J=U(function(e){return M({type:"SET_TOUCHED",payload:e}),l?G(L.values):Promise.resolve()}),Q=t.useCallback(function(e){M({type:"SET_ERRORS",payload:e})},[]),X=U(function(e){return M({type:"SET_VALUES",payload:e}),a?G(L.values):Promise.resolve()}),Z=t.useCallback(function(e,t){M({type:"SET_FIELD_ERROR",payload:{field:e,value:t}})},[]),$=U(function(e,t,r){return void 0===r&&(r=!0),M({type:"SET_FIELD_VALUE",payload:{field:e,value:t}}),a&&r?G(b(L.values,e,t)):Promise.resolve()}),ee=t.useCallback(function(e,t){var r,n=t,i=e;if(!y(e)){e.persist&&e.persist();var a=e.target,o=a.type,u=a.value,l=a.checked,s=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)?function(e,t,r){if("true"==r||"false"==r)return!!t;if(t)return Array.isArray(e)?e.concat(r):[r];if(!Array.isArray(e))return!!e;var n=e.indexOf(r);return n<0?e:e.slice(0,n).concat(e.slice(n+1))}(T(L.values,n),l,u):c?function(e){return e.filter(function(e){return e.selected}).map(function(e){return e.value})}(s):u}n&&$(n,i)},[$,L.values]),te=t.useCallback(function(e){if(y(e))return function(t){return ee(t,e)};ee(e)},[ee]),re=U(function(e,t,r){return void 0===t&&(t=!0),void 0===r&&(r=!0),M({type:"SET_FIELD_TOUCHED",payload:{field:e,value:t}}),l&&r?G(L.values):Promise.resolve()}),ne=t.useCallback(function(e,t){e.persist&&e.persist();var r=e.target;re(t||r.name||r.id,!0)},[re]),ie=t.useCallback(function(e){if(y(e))return function(t){return ne(t,e)};ne(e)},[ne]);function ae(e){v(e)?M({type:"SET_FORMIK_STATE",payload:e(L)}):M({type:"SET_FORMIK_STATE",payload:e})}var oe=t.useCallback(function(e){M({type:"SET_STATUS",payload:e})},[]),ue=t.useCallback(function(e){M({type:"SET_ISSUBMITTING",payload:e})},[]),le={resetForm:H,validateForm:W,validateField:K,setErrors:Q,setFieldError:Z,setFieldTouched:re,setFieldValue:$,setStatus:oe,setSubmitting:ue,setTouched:J,setValues:X,setFormikState:ae},se=U(function(){return h(L.values,le)}),ce=U(function(){return M({type:"SUBMIT_ATTEMPT"}),W().then(function(e){if(0===Object.keys(e).length)return Promise.resolve(se()).then(function(){C.current&&M({type:"SUBMIT_SUCCESS"})}).catch(function(e){if(C.current)throw M({type:"SUBMIT_FAILURE"}),e});C.current&&M({type:"SUBMIT_FAILURE"})})}),de=U(function(e){e&&e.preventDefault&&v(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&v(e.stopPropagation)&&e.stopPropagation(),ce()}),pe=U(function(e){if(e&&e.preventDefault&&v(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&v(e.stopPropagation)&&e.stopPropagation(),S.onReset){var t=S.onReset(L.values,le);E(t)?t.then(H):H()}else H()}),fe=t.useCallback(function(e){return{value:T(L.values,e),error:T(L.errors,e),touched:!!T(L.touched,e),initialValue:T(g.current,e),initialTouched:!!T(_.current,e),initialError:T(F.current,e)}},[L.errors,L.touched,L.values]),ve=t.useCallback(function(e){var t=e.name,r=e.type,n=e.value,i=e.as,a=e.multiple,o=T(L.values,t),u={name:t,value:o,onChange:te,onBlur:ie};return"checkbox"===r?void 0===n?u.checked=!!o:(u.checked=!(!Array.isArray(o)||!~o.indexOf(n)),u.value=n):"radio"===r?(u.checked=o===n,u.value=n):"select"===i&&a&&(u.value=u.value||[],u.multiple=!0),[u,fe(t)]},[fe,ie,te,L.values]),he=t.useMemo(function(){return!r(g.current,L.values)},[L.values]),me=t.useMemo(function(){return void 0!==s?he?L.errors&&0===Object.keys(L.errors).length:!1!==s&&v(s)?s(S):s:L.errors&&0===Object.keys(L.errors).length},[s,he,L.errors,S]);return c({},L,{initialValues:g.current,initialErrors:F.current,initialTouched:_.current,initialStatus:R.current,handleBlur:ie,handleChange:te,handleReset:pe,handleSubmit:de,resetForm:H,setErrors:Q,setFormikState:ae,setFieldTouched:re,setFieldValue:$,setFieldError:Z,setStatus:oe,setSubmitting:ue,setTouched:J,setValues:X,submitForm:ce,validateForm:W,validateField:K,isValid:me,dirty:he,unregisterField:z,registerField:Y,getFieldProps:ve,validateOnBlur:l,validateOnChange:a})}function P(e){var r=A(e),n=e.component,i=e.children,a=e.render;return t.createElement(_,{value:r},n?t.createElement(n,r):a?a(r):i?v(i)?i(r):S(i)?null:t.Children.only(i):null)}function x(e){var t={};if(0===e.inner.length)return b(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}t[a.path]||(t=b(t,a.path,a.message))}return t}function V(e,t,r,n){void 0===r&&(r=!1),void 0===n&&(n={});var i={};for(var a in e)if(e.hasOwnProperty(a)){var o=String(a);i[o]=""!==e[o]?e[o]:void 0}return t[r?"validateSync":"validate"](i,{abortEarly:!1,context:n})}function D(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 U(e){var r=t.useRef();return t.useLayoutEffect(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 L(e){var r=e.validate,n=e.name,i=e.render,a=e.children,o=e.as,u=e.component,l=p(e,["validate","name","render","children","as","component"]),s=p(C(),["validate","validationSchema"]);t.useEffect(function(){},[]);var d=s.registerField,f=s.unregisterField;t.useEffect(function(){return d(n,{validate:r}),function(){f(n)}},[d,f,n,r]);var h=s.getFieldProps(c({name:n},l)),m=h[0],y=h[1],S={field:m,form:s};if(i)return i(S);if(v(a))return a(c({},S,{meta:y}));if(u){if("string"==typeof u){var E=l.innerRef,T=p(l,["innerRef"]);return t.createElement(u,c({ref:E},m,T),a)}return t.createElement(u,c({field:m,form:s},l),a)}var b=o||"input";if("string"==typeof b){var g=l.innerRef,F=p(l,["innerRef"]);return t.createElement(b,c({ref:g},m,F),a)}return t.createElement(b,c({},m,l),a)}var M=L;function j(e){var r=C();return t.createElement("form",Object.assign({onSubmit:r.handleSubmit,onReset:r.handleReset},e))}function w(e){var r=function(r){return t.createElement(R,null,function(n){return n||o(!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)}j.displayName="Form";var N=function(e,t,r){var n=[].concat(e||[]),i=n[t];return n.splice(t,1),n.splice(r,0,i),n},B=function(e,t,r){var n=[].concat(e||[]),i=n[t];return n[t]=n[r],n[r]=i,n},q=function(e,t,r){var n=[].concat(e||[]);return n.splice(t,0,r),n},G=function(e,t,r){var n=[].concat(e||[]);return n[t]=r,n},W=function(e){function r(t){var r;return(r=e.call(this,t)||this).updateArrayField=function(e,t,n){var i=r.props,a=i.name,o=i.validateOnChange,u=i.formik,l=u.validateForm;(0,u.setFormikState)(function(r){var i="function"==typeof n?n:e,o="function"==typeof t?t:e;return c({},r,{values:b(r.values,a,e(T(r.values,a))),errors:n?b(r.errors,a,i(T(r.errors,a))):r.errors,touched:t?b(r.touched,a,o(T(r.touched,a))):r.touched})},function(){o&&l()})},r.push=function(e){return r.updateArrayField(function(t){return[].concat(t||[],[s(e)])},!1,!1)},r.handlePush=function(e){return function(){return r.push(e)}},r.swap=function(e,t){return r.updateArrayField(function(r){return B(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 N(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 q(r,e,t)},function(t){return q(t,e,null)},function(t){return q(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 G(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(f(r)),r.pop=r.pop.bind(f(r)),r}d(r,e);var n=r.prototype;return n.remove=function(e){var t;return this.updateArrayField(function(r){var n=r?[].concat(r):[];return t||(t=n[e]),v(n.splice)&&n.splice(e,1),n},!0,!0),t},n.pop=function(){var e;return this.updateArrayField(function(t){var r=t;return e||(e=r&&r.pop&&r.pop()),r},!0,!0),e},n.render=function(){var e=this.props,r=e.component,n=e.render,i=e.children,a=e.name,o=c({},{push:this.push,pop:this.pop,swap:this.swap,move:this.move,insert:this.insert,replace:this.replace,unshift:this.unshift,remove:this.remove,handlePush:this.handlePush,handlePop:this.handlePop,handleSwap:this.handleSwap,handleMove:this.handleMove,handleInsert:this.handleInsert,handleReplace:this.handleReplace,handleUnshift:this.handleUnshift,handleRemove:this.handleRemove},{form:p(e.formik,["validate","validationSchema"]),name:a});return r?t.createElement(r,o):n?n(o):i?"function"==typeof i?i(o):S(i)?null:t.Children.only(i):null},r}(t.Component);W.defaultProps={validateOnChange:!0};var H=w(W);exports.ErrorMessage=w(function(e){function r(){return e.apply(this,arguments)||this}d(r,e);var n=r.prototype;return n.shouldComponentUpdate=function(e){return T(this.props.formik.errors,this.props.name)!==T(e.formik.errors,this.props.name)||T(this.props.formik.touched,this.props.name)!==T(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=p(e,["component","formik","render","children","name"]),l=T(n.touched,o),s=T(n.errors,o);return l&&s?i?v(i)?i(s):null:a?v(a)?a(s):null:r?t.createElement(r,u,s):s:null},r}(t.Component)),exports.FastField=M,exports.Field=L,exports.FieldArray=H,exports.Form=j,exports.Formik=P,exports.FormikConsumer=R,exports.FormikProvider=_,exports.connect=w,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=T,exports.insert=q,exports.isEmptyChildren=S,exports.isFunction=v,exports.isInputEvent=function(e){return e&&h(e)&&h(e.target)},exports.isInteger=m,exports.isNaN=function(e){return e!=e},exports.isObject=h,exports.isPromise=E,exports.isString=y,exports.move=N,exports.replace=G,exports.setIn=b,exports.setNestedObjectValues=g,exports.swap=B,exports.useField=function(e){var r=C(),n=r.getFieldProps,i=r.registerField,a=r.unregisterField,o=h(e),u=o?e.name:e,l=o?e.validate:void 0;return t.useEffect(function(){return u&&i(u,{validate:l}),function(){u&&a(u)}},[i,a,u,l]),h(e)?n(e):n({name:e})},exports.useFormik=A,exports.useFormikContext=C,exports.validateYupSchema=V,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",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 v(i.validationSchema)?i.validationSchema(n.props):i.validationSchema},n.handleSubmit=function(e,t){return i.handleSubmit(e,c({},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=p(this.props,["children"]);return t.createElement(P,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,render:this.renderFormComponent}))},a}(t.Component);return a.displayName="WithFormik("+r+")",l(a,e)}},exports.yupToFormErrors=x; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=require("react"),r=e(require("react-fast-compare")),n=e(require("deepmerge")),i=e(require("lodash/clone")),a=e(require("lodash/toPath")),o=e(require("tiny-warning")),u=require("scheduler"),l=e(require("hoist-non-react-statics")),s=e(require("lodash/cloneDeep"));function c(){return(c=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={},a=Object.keys(e);for(n=0;n<a.length;n++)t.indexOf(r=a[n])>=0||(i[r]=e[r]);return i}function f(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var v=function(e){return"function"==typeof e},h=function(e){return null!==e&&"object"==typeof e},m=function(e){return String(Math.floor(Number(e)))===e},y=function(e){return"[object String]"===Object.prototype.toString.call(e)},E=function(e){return 0===t.Children.count(e)},S=function(e){return h(e)&&v(e.then)};function T(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 b(e,t,r){for(var n=i(e),o=n,u=0,l=a(t);u<l.length-1;u++){var s=l[u],c=T(e,l.slice(0,u+1));if(c&&(h(c)||Array.isArray(c)))o=o[s]=i(c);else{var d=l[u+1];o=o[s]=m(d)&&Number(d)>=0?[]:{}}}return(0===u?e:o)[l[u]]===r?e:(void 0===r?delete o[l[u]]:o[l[u]]=r,0===u&&void 0===r&&delete n[l[u]],n)}function g(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];h(u)?r.get(u)||(r.set(u,!0),n[o]=Array.isArray(u)?[]:{},g(u,t,r,n[o])):n[o]=t}return n}var F=t.createContext(void 0),_=F.Provider,O=F.Consumer;function R(){var e=t.useContext(F);return e||o(!1),e}function C(e,t){switch(t.type){case"SET_VALUES":return c({},e,{values:t.payload});case"SET_TOUCHED":return c({},e,{touched:t.payload});case"SET_ERRORS":return c({},e,{errors:t.payload});case"SET_STATUS":return c({},e,{status:t.payload});case"SET_ISSUBMITTING":return c({},e,{isSubmitting:t.payload});case"SET_ISVALIDATING":return c({},e,{isValidating:t.payload});case"SET_FIELD_VALUE":return c({},e,{values:b(e.values,t.payload.field,t.payload.value)});case"SET_FIELD_TOUCHED":return c({},e,{touched:b(e.touched,t.payload.field,t.payload.value)});case"SET_FIELD_ERROR":return c({},e,{errors:b(e.errors,t.payload.field,t.payload.value)});case"RESET_FORM":return c({},e,t.payload);case"SET_FORMIK_STATE":return t.payload(e);case"SUBMIT_ATTEMPT":return c({},e,{touched:g(e.values,!0),isSubmitting:!0,submitCount:e.submitCount+1});case"SUBMIT_FAILURE":case"SUBMIT_SUCCESS":return c({},e,{isSubmitting:!1});default:return e}}var A={},k={};function I(e){var i=e.validateOnChange,a=void 0===i||i,o=e.validateOnBlur,l=void 0===o||o,s=e.validateOnMount,d=void 0!==s&&s,f=e.isInitialValid,h=e.enableReinitialize,m=void 0!==h&&h,E=e.onSubmit,g=p(e,["validateOnChange","validateOnBlur","validateOnMount","isInitialValid","enableReinitialize","onSubmit"]),F=c({validateOnChange:a,validateOnBlur:l,validateOnMount:d,onSubmit:E},g),_=t.useRef(F.initialValues),O=t.useRef(F.initialErrors||A),R=t.useRef(F.initialTouched||k),I=t.useRef(F.initialStatus),P=t.useRef(!1),D=t.useRef({});t.useEffect(function(){},[f]),t.useEffect(function(){return P.current=!0,function(){P.current=!1}},[]);var w=t.useReducer(C,{values:F.initialValues,errors:F.initialErrors||A,touched:F.initialTouched||k,status:F.initialStatus,isSubmitting:!1,isValidating:!1,submitCount:0}),L=w[0],j=w[1],N=t.useCallback(function(e,t){return new Promise(function(r,n){var i=F.validate(e,t);null==i?r(A):S(i)?i.then(function(e){r(e||A)},function(e){n(e)}):r(i)})},[F.validate]),B=t.useCallback(function(e,t){var r=F.validationSchema,n=v(r)?r(t):r,i=t&&n.validateAt?n.validateAt(t,e):U(e,n);return new Promise(function(e,t){i.then(function(){e(A)},function(r){"ValidationError"===r.name?e(x(r)):t(r)})})},[F.validationSchema]),q=t.useCallback(function(e,t){return new Promise(function(r){return r(D.current[e].validate(t))})},[]),G=t.useCallback(function(e){var t=Object.keys(D.current).filter(function(e){return v(D.current[e].validate)}),r=t.length>0?t.map(function(t){return q(t,T(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=b(e,t[n],r)),e)},{})})},[q]),W=t.useCallback(function(e){return Promise.all([G(e),F.validationSchema?B(e):{},F.validate?N(e):{}]).then(function(e){return n.all([e[0],e[1],e[2]],{arrayMerge:V})})},[F.validate,F.validationSchema,G,N,B]),H=M(function(e){return void 0===e&&(e=L.values),u.unstable_runWithPriority(u.LowPriority,function(){return W(e).then(function(e){return P.current&&j({type:"SET_ERRORS",payload:e}),e})})}),K=M(function(e){return void 0===e&&(e=L.values),j({type:"SET_ISVALIDATING",payload:!0}),W(e).then(function(e){return P.current&&(j({type:"SET_ISVALIDATING",payload:!1}),r(L.errors,e)||j({type:"SET_ERRORS",payload:e})),e})}),Y=t.useCallback(function(e){var t=e&&e.values?e.values:_.current,r=e&&e.errors?e.errors:O.current?O.current:F.initialErrors||{},n=e&&e.touched?e.touched:R.current?R.current:F.initialTouched||{},i=e&&e.status?e.status:I.current?I.current:F.initialStatus;_.current=t,O.current=r,R.current=n,I.current=i,j({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}})},[F.initialErrors,F.initialStatus,F.initialTouched]);t.useEffect(function(){m&&!0===P.current&&!r(_.current,F.initialValues)&&(_.current=F.initialValues,Y())},[m,F.initialValues,Y]),t.useEffect(function(){m&&!0===P.current&&!r(O.current,F.initialErrors)&&(O.current=F.initialErrors||A,j({type:"SET_ERRORS",payload:F.initialErrors||A}))},[m,F.initialErrors]),t.useEffect(function(){m&&!0===P.current&&!r(R.current,F.initialTouched)&&(R.current=F.initialTouched||k,j({type:"SET_TOUCHED",payload:F.initialTouched||k}))},[m,F.initialTouched]),t.useEffect(function(){m&&!0===P.current&&!r(I.current,F.initialStatus)&&(I.current=F.initialStatus,j({type:"SET_STATUS",payload:F.initialStatus}))},[m,F.initialStatus,F.initialTouched]);var z=M(function(e){if(v(D.current[e].validate)){var t=T(L.values,e),r=D.current[e].validate(t);return S(r)?(j({type:"SET_ISVALIDATING",payload:!0}),r.then(function(e){return e}).then(function(t){j({type:"SET_FIELD_ERROR",payload:{field:e,value:t}}),j({type:"SET_ISVALIDATING",payload:!1})})):(j({type:"SET_FIELD_ERROR",payload:{field:e,value:r}}),Promise.resolve(r))}return Promise.resolve()}),J=t.useCallback(function(e,t){D.current[e]={validate:t.validate}},[]),Q=t.useCallback(function(e){delete D.current[e]},[]),X=M(function(e){return j({type:"SET_TOUCHED",payload:e}),l?H(L.values):Promise.resolve()}),Z=t.useCallback(function(e){j({type:"SET_ERRORS",payload:e})},[]),$=M(function(e){return j({type:"SET_VALUES",payload:e}),a?H(L.values):Promise.resolve()}),ee=t.useCallback(function(e,t){j({type:"SET_FIELD_ERROR",payload:{field:e,value:t}})},[]),te=M(function(e,t,r){return void 0===r&&(r=!0),j({type:"SET_FIELD_VALUE",payload:{field:e,value:t}}),a&&r?H(b(L.values,e,t)):Promise.resolve()}),re=t.useCallback(function(e,t){var r,n=t,i=e;if(!y(e)){e.persist&&e.persist();var a=e.target,o=a.type,u=a.value,l=a.checked,s=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)?function(e,t,r){if("true"==r||"false"==r)return!!t;if(t)return Array.isArray(e)?e.concat(r):[r];if(!Array.isArray(e))return!!e;var n=e.indexOf(r);return n<0?e:e.slice(0,n).concat(e.slice(n+1))}(T(L.values,n),l,u):c?function(e){return Array.from(e).filter(function(e){return e.selected}).map(function(e){return e.value})}(s):u}n&&te(n,i)},[te,L.values]),ne=t.useCallback(function(e){if(y(e))return function(t){return re(t,e)};re(e)},[re]),ie=M(function(e,t,r){return void 0===t&&(t=!0),void 0===r&&(r=!0),j({type:"SET_FIELD_TOUCHED",payload:{field:e,value:t}}),l&&r?H(L.values):Promise.resolve()}),ae=t.useCallback(function(e,t){e.persist&&e.persist();var r=e.target;ie(t||r.name||r.id,!0)},[ie]),oe=t.useCallback(function(e){if(y(e))return function(t){return ae(t,e)};ae(e)},[ae]),ue=t.useCallback(function(e){v(e)?j({type:"SET_FORMIK_STATE",payload:e}):j({type:"SET_FORMIK_STATE",payload:function(){return e}})},[]),le=t.useCallback(function(e){j({type:"SET_STATUS",payload:e})},[]),se=t.useCallback(function(e){j({type:"SET_ISSUBMITTING",payload:e})},[]),ce={resetForm:Y,validateForm:K,validateField:z,setErrors:Z,setFieldError:ee,setFieldTouched:ie,setFieldValue:te,setStatus:le,setSubmitting:se,setTouched:X,setValues:$,setFormikState:ue},de=M(function(){return E(L.values,ce)}),pe=M(function(){return j({type:"SUBMIT_ATTEMPT"}),K().then(function(e){if(0===Object.keys(e).length)return Promise.resolve(de()).then(function(){P.current&&j({type:"SUBMIT_SUCCESS"})}).catch(function(e){if(P.current)throw j({type:"SUBMIT_FAILURE"}),e});P.current&&j({type:"SUBMIT_FAILURE"})})}),fe=M(function(e){e&&e.preventDefault&&v(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&v(e.stopPropagation)&&e.stopPropagation(),pe()}),ve=M(function(e){if(e&&e.preventDefault&&v(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&v(e.stopPropagation)&&e.stopPropagation(),F.onReset){var t=F.onReset(L.values,ce);S(t)?t.then(Y):Y()}else Y()}),he=t.useCallback(function(e){return{value:T(L.values,e),error:T(L.errors,e),touched:!!T(L.touched,e),initialValue:T(_.current,e),initialTouched:!!T(R.current,e),initialError:T(O.current,e)}},[L.errors,L.touched,L.values]),me=t.useCallback(function(e){var t=e.name,r=e.type,n=e.value,i=e.as,a=e.multiple,o=T(L.values,t),u={name:t,value:o,onChange:ne,onBlur:oe};return"checkbox"===r?void 0===n?u.checked=!!o:(u.checked=!(!Array.isArray(o)||!~o.indexOf(n)),u.value=n):"radio"===r?(u.checked=o===n,u.value=n):"select"===i&&a&&(u.value=u.value||[],u.multiple=!0),[u,he(t)]},[he,oe,ne,L.values]),ye=t.useMemo(function(){return!r(_.current,L.values)},[L.values]),Ee=t.useMemo(function(){return void 0!==f?ye?L.errors&&0===Object.keys(L.errors).length:!1!==f&&v(f)?f(F):f:L.errors&&0===Object.keys(L.errors).length},[f,ye,L.errors,F]);return c({},L,{initialValues:_.current,initialErrors:O.current,initialTouched:R.current,initialStatus:I.current,handleBlur:oe,handleChange:ne,handleReset:ve,handleSubmit:fe,resetForm:Y,setErrors:Z,setFormikState:ue,setFieldTouched:ie,setFieldValue:te,setFieldError:ee,setStatus:le,setSubmitting:se,setTouched:X,setValues:$,submitForm:pe,validateForm:K,validateField:z,isValid:Ee,dirty:ye,unregisterField:Q,registerField:J,getFieldProps:me,validateOnBlur:l,validateOnChange:a,validateOnMount:d})}function P(e){var r=I(e),n=e.component,i=e.children,a=e.render;return t.createElement(_,{value:r},n?t.createElement(n,r):a?a(r):i?v(i)?i(r):E(i)?null:t.Children.only(i):null)}function x(e){var t={};if(e.inner){if(0===e.inner.length)return b(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;T(t,o.path)||(t=b(t,o.path,o.message))}}return t}function U(e,t,r,n){void 0===r&&(r=!1),void 0===n&&(n={});var i=function e(t){var r={};for(var n in t)if(t.hasOwnProperty(n)){var i=String(n);r[i]=!0===Array.isArray(t[i])?t[i].map(function(t){return!0===Array.isArray(t)||"object"==typeof t?e(t):""!==t?t:void 0}):"object"==typeof t[i]&&null!==t[i]?e(t[i]):""!==t[i]?t[i]:void 0}return r}(e);return t[r?"validateSync":"validate"](i,{abortEarly:!1,context:n})}function V(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}var D="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t.useLayoutEffect:t.useEffect;function M(e){var r=t.useRef(e);return D(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 w(e){var r=e.validate,n=e.name,i=e.render,a=e.children,o=e.as,u=e.component,l=p(e,["validate","name","render","children","as","component"]),s=p(R(),["validate","validationSchema"]);t.useEffect(function(){},[]);var d=s.registerField,f=s.unregisterField;t.useEffect(function(){return d(n,{validate:r}),function(){f(n)}},[d,f,n,r]);var h=s.getFieldProps(c({name:n},l)),m=h[0],y=h[1],E={field:m,form:s};if(i)return i(E);if(v(a))return a(c({},E,{meta:y}));if(u){if("string"==typeof u){var S=l.innerRef,T=p(l,["innerRef"]);return t.createElement(u,c({ref:S},m,T),a)}return t.createElement(u,c({field:m,form:s},l),a)}var b=o||"input";if("string"==typeof b){var g=l.innerRef,F=p(l,["innerRef"]);return t.createElement(b,c({ref:g},m,F),a)}return t.createElement(b,c({},m,l),a)}var L=w;function j(e){var r=e.action,n=p(e,["action"]),i=r||"#",a=R();return t.createElement("form",Object.assign({onSubmit:a.handleSubmit,onReset:a.handleReset,action:i},n))}function N(e){var r=function(r){return t.createElement(O,null,function(n){return n||o(!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)}j.displayName="Form";var B=function(e,t,r){var n=[].concat(e||[]),i=n[t];return n.splice(t,1),n.splice(r,0,i),n},q=function(e,t,r){var n=[].concat(e||[]),i=n[t];return n[t]=n[r],n[r]=i,n},G=function(e,t,r){var n=[].concat(e||[]);return n.splice(t,0,r),n},W=function(e,t,r){var n=[].concat(e||[]);return n[t]=r,n},H=function(e){function r(t){var r;return(r=e.call(this,t)||this).updateArrayField=function(e,t,n){var i=r.props,a=i.name,o=i.validateOnChange,u=i.formik,l=u.validateForm;(0,u.setFormikState)(function(r){var i="function"==typeof n?n:e,o="function"==typeof t?t:e;return c({},r,{values:b(r.values,a,e(T(r.values,a))),errors:n?b(r.errors,a,i(T(r.errors,a))):r.errors,touched:t?b(r.touched,a,o(T(r.touched,a))):r.touched})},function(){o&&l()})},r.push=function(e){return r.updateArrayField(function(t){return[].concat(t||[],[s(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 B(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 G(r,e,t)},function(t){return G(t,e,null)},function(t){return G(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 W(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(f(r)),r.pop=r.pop.bind(f(r)),r}d(r,e);var n=r.prototype;return n.remove=function(e){var t;return this.updateArrayField(function(r){var n=r?[].concat(r):[];return t||(t=n[e]),v(n.splice)&&n.splice(e,1),n},!0,!0),t},n.pop=function(){var e;return this.updateArrayField(function(t){var r=t;return e||(e=r&&r.pop&&r.pop()),r},!0,!0),e},n.render=function(){var e=this.props,r=e.component,n=e.render,i=e.children,a=e.name,o=c({},{push:this.push,pop:this.pop,swap:this.swap,move:this.move,insert:this.insert,replace:this.replace,unshift:this.unshift,remove:this.remove,handlePush:this.handlePush,handlePop:this.handlePop,handleSwap:this.handleSwap,handleMove:this.handleMove,handleInsert:this.handleInsert,handleReplace:this.handleReplace,handleUnshift:this.handleUnshift,handleRemove:this.handleRemove},{form:p(e.formik,["validate","validationSchema"]),name:a});return r?t.createElement(r,o):n?n(o):i?"function"==typeof i?i(o):E(i)?null:t.Children.only(i):null},r}(t.Component);H.defaultProps={validateOnChange:!0};var K=N(H);exports.ErrorMessage=N(function(e){function r(){return e.apply(this,arguments)||this}d(r,e);var n=r.prototype;return n.shouldComponentUpdate=function(e){return T(this.props.formik.errors,this.props.name)!==T(e.formik.errors,this.props.name)||T(this.props.formik.touched,this.props.name)!==T(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=p(e,["component","formik","render","children","name"]),l=T(n.touched,o),s=T(n.errors,o);return l&&s?i?v(i)?i(s):null:a?v(a)?a(s):null:r?t.createElement(r,u,s):s:null},r}(t.Component)),exports.FastField=L,exports.Field=w,exports.FieldArray=K,exports.Form=j,exports.Formik=P,exports.FormikConsumer=O,exports.FormikProvider=_,exports.connect=N,exports.getActiveElement=function(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}},exports.getIn=T,exports.insert=G,exports.isEmptyChildren=E,exports.isFunction=v,exports.isInputEvent=function(e){return e&&h(e)&&h(e.target)},exports.isInteger=m,exports.isNaN=function(e){return e!=e},exports.isObject=h,exports.isPromise=S,exports.isString=y,exports.move=B,exports.replace=W,exports.setIn=b,exports.setNestedObjectValues=g,exports.swap=q,exports.useField=function(e){var r=R(),n=r.getFieldProps,i=r.registerField,a=r.unregisterField,o=h(e),u=o?e.name:e,l=o?e.validate:void 0;return t.useEffect(function(){return u&&i(u,{validate:l}),function(){u&&a(u)}},[i,a,u,l]),h(e)?n(e):n({name:e})},exports.useFormik=I,exports.useFormikContext=R,exports.validateYupSchema=U,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",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 v(i.validationSchema)?i.validationSchema(n.props):i.validationSchema},n.handleSubmit=function(e,t){return i.handleSubmit(e,c({},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=p(this.props,["children"]);return t.createElement(P,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,render:this.renderFormComponent}))},a}(t.Component);return a.displayName="WithFormik("+r+")",l(a,e)}},exports.yupToFormErrors=x; | ||
//# sourceMappingURL=formik.cjs.production.min.js.map |
import * as React from 'react'; | ||
import { FormikConfig, FormikErrors, FormikState, FormikTouched, FormikValues, FieldMetaProps, FieldInputProps } from './types'; | ||
export declare function useFormik<Values extends FormikValues = FormikValues>({ validateOnChange, validateOnBlur, isInitialValid, enableReinitialize, onSubmit, ...rest }: FormikConfig<Values>): { | ||
export declare function useFormik<Values extends FormikValues = FormikValues>({ validateOnChange, validateOnBlur, validateOnMount, isInitialValid, enableReinitialize, onSubmit, ...rest }: FormikConfig<Values>): { | ||
initialValues: Values; | ||
@@ -32,2 +32,3 @@ initialErrors: FormikErrors<unknown>; | ||
validateOnChange: boolean; | ||
validateOnMount: boolean; | ||
values: Values; | ||
@@ -34,0 +35,0 @@ errors: FormikErrors<Values>; |
@@ -119,3 +119,3 @@ import * as React from 'react'; | ||
if (currentObj) { | ||
if (currentObj && (isObject(currentObj) || Array.isArray(currentObj))) { | ||
resVal = resVal[currentPath] = clone(currentObj); | ||
@@ -230,5 +230,7 @@ } else { | ||
case 'RESET_FORM': | ||
case 'SET_FORMIK_STATE': | ||
return _extends({}, state, msg.payload); | ||
case 'SET_FORMIK_STATE': | ||
return msg.payload(state); | ||
case 'SUBMIT_ATTEMPT': | ||
@@ -263,2 +265,4 @@ return _extends({}, state, { | ||
validateOnBlur = _ref$validateOnBlur === void 0 ? true : _ref$validateOnBlur, | ||
_ref$validateOnMount = _ref.validateOnMount, | ||
validateOnMount = _ref$validateOnMount === void 0 ? false : _ref$validateOnMount, | ||
isInitialValid = _ref.isInitialValid, | ||
@@ -268,3 +272,3 @@ _ref$enableReinitiali = _ref.enableReinitialize, | ||
onSubmit = _ref.onSubmit, | ||
rest = _objectWithoutPropertiesLoose(_ref, ["validateOnChange", "validateOnBlur", "isInitialValid", "enableReinitialize", "onSubmit"]); | ||
rest = _objectWithoutPropertiesLoose(_ref, ["validateOnChange", "validateOnBlur", "validateOnMount", "isInitialValid", "enableReinitialize", "onSubmit"]); | ||
@@ -274,2 +278,3 @@ var props = _extends({ | ||
validateOnBlur: validateOnBlur, | ||
validateOnMount: validateOnMount, | ||
onSubmit: onSubmit | ||
@@ -330,6 +335,6 @@ }, rest); | ||
var runValidationSchema = useCallback(function (values, field) { | ||
var validationSchema = props.validationSchema; | ||
var schema = isFunction(validationSchema) ? validationSchema(field) : validationSchema; | ||
var promise = field && schema.validateAt ? schema.validateAt(field, values) : validateYupSchema(values, schema); | ||
return new Promise(function (resolve, reject) { | ||
var validationSchema = props.validationSchema; | ||
var schema = isFunction(validationSchema) ? validationSchema(field) : validationSchema; | ||
var promise = field && schema.validateAt ? schema.validateAt(field, values) : validateYupSchema(values, schema); | ||
promise.then(function () { | ||
@@ -460,2 +465,29 @@ resolve(emptyErrors); | ||
}, [enableReinitialize, props.initialValues, resetForm]); | ||
useEffect(function () { | ||
if (enableReinitialize && isMounted.current === true && !isEqual(initialErrors.current, props.initialErrors)) { | ||
initialErrors.current = props.initialErrors || emptyErrors; | ||
dispatch({ | ||
type: 'SET_ERRORS', | ||
payload: props.initialErrors || emptyErrors | ||
}); | ||
} | ||
}, [enableReinitialize, props.initialErrors]); | ||
useEffect(function () { | ||
if (enableReinitialize && isMounted.current === true && !isEqual(initialTouched.current, props.initialTouched)) { | ||
initialTouched.current = props.initialTouched || emptyTouched; | ||
dispatch({ | ||
type: 'SET_TOUCHED', | ||
payload: props.initialTouched || emptyTouched | ||
}); | ||
} | ||
}, [enableReinitialize, props.initialTouched]); | ||
useEffect(function () { | ||
if (enableReinitialize && isMounted.current === true && !isEqual(initialStatus.current, props.initialStatus)) { | ||
initialStatus.current = props.initialStatus; | ||
dispatch({ | ||
type: 'SET_STATUS', | ||
payload: props.initialStatus | ||
}); | ||
} | ||
}, [enableReinitialize, props.initialStatus, props.initialTouched]); | ||
var validateField = useEventCallback(function (name) { | ||
@@ -645,8 +677,7 @@ if (isFunction(fieldRegistry.current[name].validate)) { | ||
}, [executeBlur]); | ||
function setFormikState(stateOrCb) { | ||
var setFormikState = useCallback(function (stateOrCb) { | ||
if (isFunction(stateOrCb)) { | ||
dispatch({ | ||
type: 'SET_FORMIK_STATE', | ||
payload: stateOrCb(state) | ||
payload: stateOrCb | ||
}); | ||
@@ -656,7 +687,8 @@ } else { | ||
type: 'SET_FORMIK_STATE', | ||
payload: stateOrCb | ||
payload: function payload() { | ||
return stateOrCb; | ||
} | ||
}); | ||
} | ||
} | ||
}, []); | ||
var setStatus = useCallback(function (status) { | ||
@@ -839,3 +871,4 @@ dispatch({ | ||
validateOnBlur: validateOnBlur, | ||
validateOnChange: validateOnChange | ||
validateOnChange: validateOnChange, | ||
validateOnMount: validateOnMount | ||
}); | ||
@@ -865,22 +898,24 @@ | ||
if (yupError.inner.length === 0) { | ||
return setIn(errors, yupError.path, yupError.message); | ||
} | ||
if (yupError.inner) { | ||
if (yupError.inner.length === 0) { | ||
return setIn(errors, yupError.path, yupError.message); | ||
} | ||
for (var _iterator = yupError.inner, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref6; | ||
for (var _iterator = yupError.inner, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref6; | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref6 = _iterator[_i++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref6 = _i.value; | ||
} | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref6 = _iterator[_i++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref6 = _i.value; | ||
} | ||
var err = _ref6; | ||
var err = _ref6; | ||
if (!errors[err.path]) { | ||
errors = setIn(errors, err.path, err.message); | ||
if (!getIn(errors, err.path)) { | ||
errors = setIn(errors, err.path, err.message); | ||
} | ||
} | ||
@@ -900,15 +935,33 @@ } | ||
var validateData = {}; | ||
var validateData = prepareDataForValidation(values); | ||
return schema[sync ? 'validateSync' : 'validate'](validateData, { | ||
abortEarly: false, | ||
context: context | ||
}); | ||
} | ||
function prepareDataForValidation(values) { | ||
var data = {}; | ||
for (var k in values) { | ||
if (values.hasOwnProperty(k)) { | ||
var key = String(k); | ||
validateData[key] = values[key] !== '' ? values[key] : undefined; | ||
if (Array.isArray(values[key]) === true) { | ||
data[key] = values[key].map(function (value) { | ||
if (Array.isArray(value) === true || typeof value === 'object') { | ||
return prepareDataForValidation(value); | ||
} else { | ||
return value !== '' ? value : undefined; | ||
} | ||
}); | ||
} else if (typeof values[key] === 'object' && values[key] !== null) { | ||
data[key] = prepareDataForValidation(values[key]); | ||
} else { | ||
data[key] = values[key] !== '' ? values[key] : undefined; | ||
} | ||
} | ||
} | ||
return schema[sync ? 'validateSync' : 'validate'](validateData, { | ||
abortEarly: false, | ||
context: context | ||
}); | ||
return data; | ||
} | ||
@@ -933,3 +986,3 @@ | ||
function getSelectedValues(options) { | ||
return options.filter(function (el) { | ||
return Array.from(options).filter(function (el) { | ||
return el.selected; | ||
@@ -963,5 +1016,7 @@ }).map(function (el) { | ||
var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? useLayoutEffect : useEffect; | ||
function useEventCallback(fn) { | ||
var ref = useRef(); | ||
useLayoutEffect(function () { | ||
var ref = useRef(fn); | ||
useIsomorphicLayoutEffect(function () { | ||
ref.current = fn; | ||
@@ -1103,2 +1158,7 @@ }); | ||
function Form(props) { | ||
var action = props.action, | ||
rest = _objectWithoutPropertiesLoose(props, ["action"]); | ||
var _action = action || "#"; | ||
var _useFormikContext = useFormikContext(), | ||
@@ -1110,4 +1170,5 @@ handleReset = _useFormikContext.handleReset, | ||
onSubmit: handleSubmit, | ||
onReset: handleReset | ||
}, props)); | ||
onReset: handleReset, | ||
action: _action | ||
}, rest)); | ||
} | ||
@@ -1114,0 +1175,0 @@ Form.displayName = 'Form'; |
@@ -122,3 +122,3 @@ (function (global, factory) { | ||
if (currentObj) { | ||
if (currentObj && (isObject(currentObj) || Array.isArray(currentObj))) { | ||
resVal = resVal[currentPath] = clone(currentObj); | ||
@@ -233,5 +233,7 @@ } else { | ||
case 'RESET_FORM': | ||
case 'SET_FORMIK_STATE': | ||
return _extends({}, state, msg.payload); | ||
case 'SET_FORMIK_STATE': | ||
return msg.payload(state); | ||
case 'SUBMIT_ATTEMPT': | ||
@@ -266,2 +268,4 @@ return _extends({}, state, { | ||
validateOnBlur = _ref$validateOnBlur === void 0 ? true : _ref$validateOnBlur, | ||
_ref$validateOnMount = _ref.validateOnMount, | ||
validateOnMount = _ref$validateOnMount === void 0 ? false : _ref$validateOnMount, | ||
isInitialValid = _ref.isInitialValid, | ||
@@ -271,3 +275,3 @@ _ref$enableReinitiali = _ref.enableReinitialize, | ||
onSubmit = _ref.onSubmit, | ||
rest = _objectWithoutPropertiesLoose(_ref, ["validateOnChange", "validateOnBlur", "isInitialValid", "enableReinitialize", "onSubmit"]); | ||
rest = _objectWithoutPropertiesLoose(_ref, ["validateOnChange", "validateOnBlur", "validateOnMount", "isInitialValid", "enableReinitialize", "onSubmit"]); | ||
@@ -277,2 +281,3 @@ var props = _extends({ | ||
validateOnBlur: validateOnBlur, | ||
validateOnMount: validateOnMount, | ||
onSubmit: onSubmit | ||
@@ -333,6 +338,6 @@ }, rest); | ||
var runValidationSchema = React.useCallback(function (values, field) { | ||
var validationSchema = props.validationSchema; | ||
var schema = isFunction(validationSchema) ? validationSchema(field) : validationSchema; | ||
var promise = field && schema.validateAt ? schema.validateAt(field, values) : validateYupSchema(values, schema); | ||
return new Promise(function (resolve, reject) { | ||
var validationSchema = props.validationSchema; | ||
var schema = isFunction(validationSchema) ? validationSchema(field) : validationSchema; | ||
var promise = field && schema.validateAt ? schema.validateAt(field, values) : validateYupSchema(values, schema); | ||
promise.then(function () { | ||
@@ -463,2 +468,29 @@ resolve(emptyErrors); | ||
}, [enableReinitialize, props.initialValues, resetForm]); | ||
React.useEffect(function () { | ||
if (enableReinitialize && isMounted.current === true && !isEqual(initialErrors.current, props.initialErrors)) { | ||
initialErrors.current = props.initialErrors || emptyErrors; | ||
dispatch({ | ||
type: 'SET_ERRORS', | ||
payload: props.initialErrors || emptyErrors | ||
}); | ||
} | ||
}, [enableReinitialize, props.initialErrors]); | ||
React.useEffect(function () { | ||
if (enableReinitialize && isMounted.current === true && !isEqual(initialTouched.current, props.initialTouched)) { | ||
initialTouched.current = props.initialTouched || emptyTouched; | ||
dispatch({ | ||
type: 'SET_TOUCHED', | ||
payload: props.initialTouched || emptyTouched | ||
}); | ||
} | ||
}, [enableReinitialize, props.initialTouched]); | ||
React.useEffect(function () { | ||
if (enableReinitialize && isMounted.current === true && !isEqual(initialStatus.current, props.initialStatus)) { | ||
initialStatus.current = props.initialStatus; | ||
dispatch({ | ||
type: 'SET_STATUS', | ||
payload: props.initialStatus | ||
}); | ||
} | ||
}, [enableReinitialize, props.initialStatus, props.initialTouched]); | ||
var validateField = useEventCallback(function (name) { | ||
@@ -648,8 +680,7 @@ if (isFunction(fieldRegistry.current[name].validate)) { | ||
}, [executeBlur]); | ||
function setFormikState(stateOrCb) { | ||
var setFormikState = React.useCallback(function (stateOrCb) { | ||
if (isFunction(stateOrCb)) { | ||
dispatch({ | ||
type: 'SET_FORMIK_STATE', | ||
payload: stateOrCb(state) | ||
payload: stateOrCb | ||
}); | ||
@@ -659,7 +690,8 @@ } else { | ||
type: 'SET_FORMIK_STATE', | ||
payload: stateOrCb | ||
payload: function payload() { | ||
return stateOrCb; | ||
} | ||
}); | ||
} | ||
} | ||
}, []); | ||
var setStatus = React.useCallback(function (status) { | ||
@@ -842,3 +874,4 @@ dispatch({ | ||
validateOnBlur: validateOnBlur, | ||
validateOnChange: validateOnChange | ||
validateOnChange: validateOnChange, | ||
validateOnMount: validateOnMount | ||
}); | ||
@@ -868,22 +901,24 @@ | ||
if (yupError.inner.length === 0) { | ||
return setIn(errors, yupError.path, yupError.message); | ||
} | ||
if (yupError.inner) { | ||
if (yupError.inner.length === 0) { | ||
return setIn(errors, yupError.path, yupError.message); | ||
} | ||
for (var _iterator = yupError.inner, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref6; | ||
for (var _iterator = yupError.inner, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref6; | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref6 = _iterator[_i++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref6 = _i.value; | ||
} | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref6 = _iterator[_i++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref6 = _i.value; | ||
} | ||
var err = _ref6; | ||
var err = _ref6; | ||
if (!errors[err.path]) { | ||
errors = setIn(errors, err.path, err.message); | ||
if (!getIn(errors, err.path)) { | ||
errors = setIn(errors, err.path, err.message); | ||
} | ||
} | ||
@@ -903,15 +938,33 @@ } | ||
var validateData = {}; | ||
var validateData = prepareDataForValidation(values); | ||
return schema[sync ? 'validateSync' : 'validate'](validateData, { | ||
abortEarly: false, | ||
context: context | ||
}); | ||
} | ||
function prepareDataForValidation(values) { | ||
var data = {}; | ||
for (var k in values) { | ||
if (values.hasOwnProperty(k)) { | ||
var key = String(k); | ||
validateData[key] = values[key] !== '' ? values[key] : undefined; | ||
if (Array.isArray(values[key]) === true) { | ||
data[key] = values[key].map(function (value) { | ||
if (Array.isArray(value) === true || typeof value === 'object') { | ||
return prepareDataForValidation(value); | ||
} else { | ||
return value !== '' ? value : undefined; | ||
} | ||
}); | ||
} else if (typeof values[key] === 'object' && values[key] !== null) { | ||
data[key] = prepareDataForValidation(values[key]); | ||
} else { | ||
data[key] = values[key] !== '' ? values[key] : undefined; | ||
} | ||
} | ||
} | ||
return schema[sync ? 'validateSync' : 'validate'](validateData, { | ||
abortEarly: false, | ||
context: context | ||
}); | ||
return data; | ||
} | ||
@@ -936,3 +989,3 @@ | ||
function getSelectedValues(options) { | ||
return options.filter(function (el) { | ||
return Array.from(options).filter(function (el) { | ||
return el.selected; | ||
@@ -966,5 +1019,7 @@ }).map(function (el) { | ||
var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? React.useLayoutEffect : React.useEffect; | ||
function useEventCallback(fn) { | ||
var ref = React.useRef(); | ||
React.useLayoutEffect(function () { | ||
var ref = React.useRef(fn); | ||
useIsomorphicLayoutEffect(function () { | ||
ref.current = fn; | ||
@@ -1106,2 +1161,7 @@ }); | ||
function Form(props) { | ||
var action = props.action, | ||
rest = _objectWithoutPropertiesLoose(props, ["action"]); | ||
var _action = action || "#"; | ||
var _useFormikContext = useFormikContext(), | ||
@@ -1113,4 +1173,5 @@ handleReset = _useFormikContext.handleReset, | ||
onSubmit: handleSubmit, | ||
onReset: handleReset | ||
}, props)); | ||
onReset: handleReset, | ||
action: _action | ||
}, rest)); | ||
} | ||
@@ -1117,0 +1178,0 @@ Form.displayName = 'Form'; |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-fast-compare"),require("deepmerge"),require("lodash-es/clone"),require("lodash-es/toPath"),require("tiny-warning"),require("scheduler"),require("hoist-non-react-statics"),require("lodash-es/cloneDeep")):"function"==typeof define&&define.amd?define(["exports","react","react-fast-compare","deepmerge","lodash-es/clone","lodash-es/toPath","tiny-warning","scheduler","hoist-non-react-statics","lodash-es/cloneDeep"],t):t((e=e||self).formik={},e.React,e.isEqual,e.deepmerge,e.clone,e.toPath,e.invariant,e.scheduler,e.hoistNonReactStatics,e.cloneDeep)}(this,function(e,t,r,n,a,i,u,o,l,s){"use strict";function c(){return(c=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,a={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||(a[r]=e[r]);return a}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}r=r&&r.hasOwnProperty("default")?r.default:r,n=n&&n.hasOwnProperty("default")?n.default:n,a=a&&a.hasOwnProperty("default")?a.default:a,i=i&&i.hasOwnProperty("default")?i.default:i,u=u&&u.hasOwnProperty("default")?u.default:u,l=l&&l.hasOwnProperty("default")?l.default:l,s=s&&s.hasOwnProperty("default")?s.default:s;var v=function(e){return"function"==typeof e},h=function(e){return null!==e&&"object"==typeof e},m=function(e){return String(Math.floor(Number(e)))===e},y=function(e){return"[object String]"===Object.prototype.toString.call(e)},S=function(e){return 0===t.Children.count(e)},E=function(e){return h(e)&&v(e.then)};function T(e,t,r,n){void 0===n&&(n=0);for(var a=i(t);e&&n<a.length;)e=e[a[n++]];return void 0===e?r:e}function b(e,t,r){for(var n=a(e),u=n,o=0,l=i(t);o<l.length-1;o++){var s=l[o],c=T(e,l.slice(0,o+1));if(c)u=u[s]=a(c);else{var d=l[o+1];u=u[s]=m(d)&&Number(d)>=0?[]:{}}}return(0===o?e:u)[l[o]]===r?e:(void 0===r?delete u[l[o]]:u[l[o]]=r,0===o&&void 0===r&&delete n[l[o]],n)}function g(e,t,r,n){void 0===r&&(r=new WeakMap),void 0===n&&(n={});for(var a=0,i=Object.keys(e);a<i.length;a++){var u=i[a],o=e[u];h(o)?r.get(o)||(r.set(o,!0),n[u]=Array.isArray(o)?[]:{},g(o,t,r,n[u])):n[u]=t}return n}var F=t.createContext(void 0),O=F.Provider,_=F.Consumer;function R(){var e=t.useContext(F);return e||u(!1),e}function C(e,t){switch(t.type){case"SET_VALUES":return c({},e,{values:t.payload});case"SET_TOUCHED":return c({},e,{touched:t.payload});case"SET_ERRORS":return c({},e,{errors:t.payload});case"SET_STATUS":return c({},e,{status:t.payload});case"SET_ISSUBMITTING":return c({},e,{isSubmitting:t.payload});case"SET_ISVALIDATING":return c({},e,{isValidating:t.payload});case"SET_FIELD_VALUE":return c({},e,{values:b(e.values,t.payload.field,t.payload.value)});case"SET_FIELD_TOUCHED":return c({},e,{touched:b(e.touched,t.payload.field,t.payload.value)});case"SET_FIELD_ERROR":return c({},e,{errors:b(e.errors,t.payload.field,t.payload.value)});case"RESET_FORM":case"SET_FORMIK_STATE":return c({},e,t.payload);case"SUBMIT_ATTEMPT":return c({},e,{touched:g(e.values,!0),isSubmitting:!0,submitCount:e.submitCount+1});case"SUBMIT_FAILURE":case"SUBMIT_SUCCESS":return c({},e,{isSubmitting:!1});default:return e}}var k={},P={};function I(e){var a=e.validateOnChange,i=void 0===a||a,u=e.validateOnBlur,l=void 0===u||u,s=e.isInitialValid,d=e.enableReinitialize,p=void 0!==d&&d,h=e.onSubmit,m=f(e,["validateOnChange","validateOnBlur","isInitialValid","enableReinitialize","onSubmit"]),S=c({validateOnChange:i,validateOnBlur:l,onSubmit:h},m),g=t.useRef(S.initialValues),F=t.useRef(S.initialErrors||k),O=t.useRef(S.initialTouched||P),_=t.useRef(S.initialStatus),R=t.useRef(!1),I=t.useRef({});t.useEffect(function(){},[s]),t.useEffect(function(){return R.current=!0,function(){R.current=!1}},[]);var A=t.useReducer(C,{values:S.initialValues,errors:S.initialErrors||k,touched:S.initialTouched||P,status:S.initialStatus,isSubmitting:!1,isValidating:!1,submitCount:0}),L=A[0],M=A[1],j=t.useCallback(function(e,t){return new Promise(function(r,n){var a=S.validate(e,t);null==a?r(k):E(a)?a.then(function(e){r(e||k)},function(e){n(e)}):r(a)})},[S.validate]),N=t.useCallback(function(e,t){return new Promise(function(r,n){var a=S.validationSchema,i=v(a)?a(t):a;(t&&i.validateAt?i.validateAt(t,e):V(e,i)).then(function(){r(k)},function(e){"ValidationError"===e.name?r(D(e)):n(e)})})},[S.validationSchema]),B=t.useCallback(function(e,t){return new Promise(function(r){return r(I.current[e].validate(t))})},[]),x=t.useCallback(function(e){var t=Object.keys(I.current).filter(function(e){return v(I.current[e].validate)}),r=t.length>0?t.map(function(t){return B(t,T(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=b(e,t[n],r)),e)},{})})},[B]),q=t.useCallback(function(e){return Promise.all([x(e),S.validationSchema?N(e):{},S.validate?j(e):{}]).then(function(e){return n.all([e[0],e[1],e[2]],{arrayMerge:w})})},[S.validate,S.validationSchema,x,j,N]),G=U(function(e){return void 0===e&&(e=L.values),o.unstable_runWithPriority(o.LowPriority,function(){return q(e).then(function(e){return R.current&&M({type:"SET_ERRORS",payload:e}),e})})}),W=U(function(e){return void 0===e&&(e=L.values),M({type:"SET_ISVALIDATING",payload:!0}),q(e).then(function(e){return R.current&&(M({type:"SET_ISVALIDATING",payload:!1}),r(L.errors,e)||M({type:"SET_ERRORS",payload:e})),e})}),H=t.useCallback(function(e){var t=e&&e.values?e.values:g.current,r=e&&e.errors?e.errors:F.current?F.current:S.initialErrors||{},n=e&&e.touched?e.touched:O.current?O.current:S.initialTouched||{},a=e&&e.status?e.status:_.current?_.current:S.initialStatus;g.current=t,F.current=r,O.current=n,_.current=a,M({type:"RESET_FORM",payload:{isSubmitting:!!e&&!!e.isSubmitting,errors:r,touched:n,status:a,values:t,isValidating:!!e&&!!e.isValidating,submitCount:e&&e.submitCount&&"number"==typeof e.submitCount?e.submitCount:0}})},[S.initialErrors,S.initialStatus,S.initialTouched]);t.useEffect(function(){p&&!0===R.current&&!r(g.current,S.initialValues)&&(g.current=S.initialValues,H())},[p,S.initialValues,H]);var K=U(function(e){if(v(I.current[e].validate)){var t=T(L.values,e),r=I.current[e].validate(t);return E(r)?(M({type:"SET_ISVALIDATING",payload:!0}),r.then(function(e){return e}).then(function(t){M({type:"SET_FIELD_ERROR",payload:{field:e,value:t}}),M({type:"SET_ISVALIDATING",payload:!1})})):(M({type:"SET_FIELD_ERROR",payload:{field:e,value:r}}),Promise.resolve(r))}return Promise.resolve()}),Y=t.useCallback(function(e,t){I.current[e]={validate:t.validate}},[]),z=t.useCallback(function(e){delete I.current[e]},[]),J=U(function(e){return M({type:"SET_TOUCHED",payload:e}),l?G(L.values):Promise.resolve()}),Q=t.useCallback(function(e){M({type:"SET_ERRORS",payload:e})},[]),X=U(function(e){return M({type:"SET_VALUES",payload:e}),i?G(L.values):Promise.resolve()}),Z=t.useCallback(function(e,t){M({type:"SET_FIELD_ERROR",payload:{field:e,value:t}})},[]),$=U(function(e,t,r){return void 0===r&&(r=!0),M({type:"SET_FIELD_VALUE",payload:{field:e,value:t}}),i&&r?G(b(L.values,e,t)):Promise.resolve()}),ee=t.useCallback(function(e,t){var r,n=t,a=e;if(!y(e)){e.persist&&e.persist();var i=e.target,u=i.type,o=i.value,l=i.checked,s=i.options,c=i.multiple;n=t||i.name||i.id,a=/number|range/.test(u)?(r=parseFloat(o),isNaN(r)?"":r):/checkbox/.test(u)?function(e,t,r){if("true"==r||"false"==r)return!!t;if(t)return Array.isArray(e)?e.concat(r):[r];if(!Array.isArray(e))return!!e;var n=e.indexOf(r);return n<0?e:e.slice(0,n).concat(e.slice(n+1))}(T(L.values,n),l,o):c?function(e){return e.filter(function(e){return e.selected}).map(function(e){return e.value})}(s):o}n&&$(n,a)},[$,L.values]),te=t.useCallback(function(e){if(y(e))return function(t){return ee(t,e)};ee(e)},[ee]),re=U(function(e,t,r){return void 0===t&&(t=!0),void 0===r&&(r=!0),M({type:"SET_FIELD_TOUCHED",payload:{field:e,value:t}}),l&&r?G(L.values):Promise.resolve()}),ne=t.useCallback(function(e,t){e.persist&&e.persist();var r=e.target;re(t||r.name||r.id,!0)},[re]),ae=t.useCallback(function(e){if(y(e))return function(t){return ne(t,e)};ne(e)},[ne]);function ie(e){v(e)?M({type:"SET_FORMIK_STATE",payload:e(L)}):M({type:"SET_FORMIK_STATE",payload:e})}var ue=t.useCallback(function(e){M({type:"SET_STATUS",payload:e})},[]),oe=t.useCallback(function(e){M({type:"SET_ISSUBMITTING",payload:e})},[]),le={resetForm:H,validateForm:W,validateField:K,setErrors:Q,setFieldError:Z,setFieldTouched:re,setFieldValue:$,setStatus:ue,setSubmitting:oe,setTouched:J,setValues:X,setFormikState:ie},se=U(function(){return h(L.values,le)}),ce=U(function(){return M({type:"SUBMIT_ATTEMPT"}),W().then(function(e){if(0===Object.keys(e).length)return Promise.resolve(se()).then(function(){R.current&&M({type:"SUBMIT_SUCCESS"})}).catch(function(e){if(R.current)throw M({type:"SUBMIT_FAILURE"}),e});R.current&&M({type:"SUBMIT_FAILURE"})})}),de=U(function(e){e&&e.preventDefault&&v(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&v(e.stopPropagation)&&e.stopPropagation(),ce()}),fe=U(function(e){if(e&&e.preventDefault&&v(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&v(e.stopPropagation)&&e.stopPropagation(),S.onReset){var t=S.onReset(L.values,le);E(t)?t.then(H):H()}else H()}),pe=t.useCallback(function(e){return{value:T(L.values,e),error:T(L.errors,e),touched:!!T(L.touched,e),initialValue:T(g.current,e),initialTouched:!!T(O.current,e),initialError:T(F.current,e)}},[L.errors,L.touched,L.values]),ve=t.useCallback(function(e){var t=e.name,r=e.type,n=e.value,a=e.as,i=e.multiple,u=T(L.values,t),o={name:t,value:u,onChange:te,onBlur:ae};return"checkbox"===r?void 0===n?o.checked=!!u:(o.checked=!(!Array.isArray(u)||!~u.indexOf(n)),o.value=n):"radio"===r?(o.checked=u===n,o.value=n):"select"===a&&i&&(o.value=o.value||[],o.multiple=!0),[o,pe(t)]},[pe,ae,te,L.values]),he=t.useMemo(function(){return!r(g.current,L.values)},[L.values]),me=t.useMemo(function(){return void 0!==s?he?L.errors&&0===Object.keys(L.errors).length:!1!==s&&v(s)?s(S):s:L.errors&&0===Object.keys(L.errors).length},[s,he,L.errors,S]);return c({},L,{initialValues:g.current,initialErrors:F.current,initialTouched:O.current,initialStatus:_.current,handleBlur:ae,handleChange:te,handleReset:fe,handleSubmit:de,resetForm:H,setErrors:Q,setFormikState:ie,setFieldTouched:re,setFieldValue:$,setFieldError:Z,setStatus:ue,setSubmitting:oe,setTouched:J,setValues:X,submitForm:ce,validateForm:W,validateField:K,isValid:me,dirty:he,unregisterField:z,registerField:Y,getFieldProps:ve,validateOnBlur:l,validateOnChange:i})}function A(e){var r=I(e),n=e.component,a=e.children,i=e.render;return t.createElement(O,{value:r},n?t.createElement(n,r):i?i(r):a?v(a)?a(r):S(a)?null:t.Children.only(a):null)}function D(e){var t={};if(0===e.inner.length)return b(t,e.path,e.message);var r=e.inner,n=Array.isArray(r),a=0;for(r=n?r:r[Symbol.iterator]();;){var i;if(n){if(a>=r.length)break;i=r[a++]}else{if((a=r.next()).done)break;i=a.value}t[i.path]||(t=b(t,i.path,i.message))}return t}function V(e,t,r,n){void 0===r&&(r=!1),void 0===n&&(n={});var a={};for(var i in e)if(e.hasOwnProperty(i)){var u=String(i);a[u]=""!==e[u]?e[u]:void 0}return t[r?"validateSync":"validate"](a,{abortEarly:!1,context:n})}function w(e,t,r){var a=e.slice();return t.forEach(function(t,i){if(void 0===a[i]){var u=!1!==r.clone&&r.isMergeableObject(t);a[i]=u?n(Array.isArray(t)?[]:{},t,r):t}else r.isMergeableObject(t)?a[i]=n(e[i],t,r):-1===e.indexOf(t)&&a.push(t)}),a}function U(e){var r=t.useRef();return t.useLayoutEffect(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 L(e){var r=e.validate,n=e.name,a=e.render,i=e.children,u=e.as,o=e.component,l=f(e,["validate","name","render","children","as","component"]),s=f(R(),["validate","validationSchema"]);t.useEffect(function(){},[]);var d=s.registerField,p=s.unregisterField;t.useEffect(function(){return d(n,{validate:r}),function(){p(n)}},[d,p,n,r]);var h=s.getFieldProps(c({name:n},l)),m=h[0],y=h[1],S={field:m,form:s};if(a)return a(S);if(v(i))return i(c({},S,{meta:y}));if(o){if("string"==typeof o){var E=l.innerRef,T=f(l,["innerRef"]);return t.createElement(o,c({ref:E},m,T),i)}return t.createElement(o,c({field:m,form:s},l),i)}var b=u||"input";if("string"==typeof b){var g=l.innerRef,F=f(l,["innerRef"]);return t.createElement(b,c({ref:g},m,F),i)}return t.createElement(b,c({},m,l),i)}var M=L;function j(e){var r=R();return t.createElement("form",Object.assign({onSubmit:r.handleSubmit,onReset:r.handleReset},e))}function N(e){var r=function(r){return t.createElement(_,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)}j.displayName="Form";var B=function(e,t,r){var n=[].concat(e||[]),a=n[t];return n.splice(t,1),n.splice(r,0,a),n},x=function(e,t,r){var n=[].concat(e||[]),a=n[t];return n[t]=n[r],n[r]=a,n},q=function(e,t,r){var n=[].concat(e||[]);return n.splice(t,0,r),n},G=function(e,t,r){var n=[].concat(e||[]);return n[t]=r,n},W=function(e){function r(t){var r;return(r=e.call(this,t)||this).updateArrayField=function(e,t,n){var a=r.props,i=a.name,u=a.validateOnChange,o=a.formik,l=o.validateForm;(0,o.setFormikState)(function(r){var a="function"==typeof n?n:e,u="function"==typeof t?t:e;return c({},r,{values:b(r.values,i,e(T(r.values,i))),errors:n?b(r.errors,i,a(T(r.errors,i))):r.errors,touched:t?b(r.touched,i,u(T(r.touched,i))):r.touched})},function(){u&&l()})},r.push=function(e){return r.updateArrayField(function(t){return[].concat(t||[],[s(e)])},!1,!1)},r.handlePush=function(e){return function(){return r.push(e)}},r.swap=function(e,t){return r.updateArrayField(function(r){return x(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 B(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 q(r,e,t)},function(t){return q(t,e,null)},function(t){return q(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 G(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(p(r)),r.pop=r.pop.bind(p(r)),r}d(r,e);var n=r.prototype;return n.remove=function(e){var t;return this.updateArrayField(function(r){var n=r?[].concat(r):[];return t||(t=n[e]),v(n.splice)&&n.splice(e,1),n},!0,!0),t},n.pop=function(){var e;return this.updateArrayField(function(t){var r=t;return e||(e=r&&r.pop&&r.pop()),r},!0,!0),e},n.render=function(){var e=this.props,r=e.component,n=e.render,a=e.children,i=e.name,u=c({},{push:this.push,pop:this.pop,swap:this.swap,move:this.move,insert:this.insert,replace:this.replace,unshift:this.unshift,remove:this.remove,handlePush:this.handlePush,handlePop:this.handlePop,handleSwap:this.handleSwap,handleMove:this.handleMove,handleInsert:this.handleInsert,handleReplace:this.handleReplace,handleUnshift:this.handleUnshift,handleRemove:this.handleRemove},{form:f(e.formik,["validate","validationSchema"]),name:i});return r?t.createElement(r,u):n?n(u):a?"function"==typeof a?a(u):S(a)?null:t.Children.only(a):null},r}(t.Component);W.defaultProps={validateOnChange:!0};var H=N(W);e.ErrorMessage=N(function(e){function r(){return e.apply(this,arguments)||this}d(r,e);var n=r.prototype;return n.shouldComponentUpdate=function(e){return T(this.props.formik.errors,this.props.name)!==T(e.formik.errors,this.props.name)||T(this.props.formik.touched,this.props.name)!==T(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,a=e.render,i=e.children,u=e.name,o=f(e,["component","formik","render","children","name"]),l=T(n.touched,u),s=T(n.errors,u);return l&&s?a?v(a)?a(s):null:i?v(i)?i(s):null:r?t.createElement(r,o,s):s:null},r}(t.Component)),e.FastField=M,e.Field=L,e.FieldArray=H,e.Form=j,e.Formik=A,e.FormikConsumer=_,e.FormikProvider=O,e.connect=N,e.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}},e.getIn=T,e.insert=q,e.isEmptyChildren=S,e.isFunction=v,e.isInputEvent=function(e){return e&&h(e)&&h(e.target)},e.isInteger=m,e.isNaN=function(e){return e!=e},e.isObject=h,e.isPromise=E,e.isString=y,e.move=B,e.replace=G,e.setIn=b,e.setNestedObjectValues=g,e.swap=x,e.useField=function(e){var r=R(),n=r.getFieldProps,a=r.registerField,i=r.unregisterField,u=h(e),o=u?e.name:e,l=u?e.validate:void 0;return t.useEffect(function(){return o&&a(o,{validate:l}),function(){o&&i(o)}},[a,i,o,l]),h(e)?n(e):n({name:e})},e.useFormik=I,e.useFormikContext=R,e.validateYupSchema=V,e.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,a=f(e,["mapPropsToValues"]);return function(e){var r=e.displayName||e.name||e.constructor&&e.constructor.name||"Component",i=function(r){function i(){var n;return(n=r.apply(this,arguments)||this).validate=function(e){return a.validate(e,n.props)},n.validationSchema=function(){return v(a.validationSchema)?a.validationSchema(n.props):a.validationSchema},n.handleSubmit=function(e,t){return a.handleSubmit(e,c({},t,{props:n.props}))},n.renderFormComponent=function(r){return t.createElement(e,Object.assign({},n.props,r))},n}return d(i,r),i.prototype.render=function(){var e=f(this.props,["children"]);return t.createElement(A,Object.assign({},e,a,{validate:a.validate&&this.validate,validationSchema:a.validationSchema&&this.validationSchema,initialValues:n(this.props),initialStatus:a.mapPropsToStatus&&a.mapPropsToStatus(this.props),initialErrors:a.mapPropsToErrors&&a.mapPropsToErrors(this.props),initialTouched:a.mapPropsToTouched&&a.mapPropsToTouched(this.props),onSubmit:this.handleSubmit,render:this.renderFormComponent}))},i}(t.Component);return i.displayName="WithFormik("+r+")",l(i,e)}},e.yupToFormErrors=D}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-fast-compare"),require("deepmerge"),require("lodash-es/clone"),require("lodash-es/toPath"),require("tiny-warning"),require("scheduler"),require("hoist-non-react-statics"),require("lodash-es/cloneDeep")):"function"==typeof define&&define.amd?define(["exports","react","react-fast-compare","deepmerge","lodash-es/clone","lodash-es/toPath","tiny-warning","scheduler","hoist-non-react-statics","lodash-es/cloneDeep"],t):t((e=e||self).formik={},e.React,e.isEqual,e.deepmerge,e.clone,e.toPath,e.invariant,e.scheduler,e.hoistNonReactStatics,e.cloneDeep)}(this,function(e,t,r,n,a,i,u,o,l,s){"use strict";function c(){return(c=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,a={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||(a[r]=e[r]);return a}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}r=r&&r.hasOwnProperty("default")?r.default:r,n=n&&n.hasOwnProperty("default")?n.default:n,a=a&&a.hasOwnProperty("default")?a.default:a,i=i&&i.hasOwnProperty("default")?i.default:i,u=u&&u.hasOwnProperty("default")?u.default:u,l=l&&l.hasOwnProperty("default")?l.default:l,s=s&&s.hasOwnProperty("default")?s.default:s;var v=function(e){return"function"==typeof e},h=function(e){return null!==e&&"object"==typeof e},m=function(e){return String(Math.floor(Number(e)))===e},y=function(e){return"[object String]"===Object.prototype.toString.call(e)},E=function(e){return 0===t.Children.count(e)},S=function(e){return h(e)&&v(e.then)};function T(e,t,r,n){void 0===n&&(n=0);for(var a=i(t);e&&n<a.length;)e=e[a[n++]];return void 0===e?r:e}function b(e,t,r){for(var n=a(e),u=n,o=0,l=i(t);o<l.length-1;o++){var s=l[o],c=T(e,l.slice(0,o+1));if(c&&(h(c)||Array.isArray(c)))u=u[s]=a(c);else{var d=l[o+1];u=u[s]=m(d)&&Number(d)>=0?[]:{}}}return(0===o?e:u)[l[o]]===r?e:(void 0===r?delete u[l[o]]:u[l[o]]=r,0===o&&void 0===r&&delete n[l[o]],n)}function g(e,t,r,n){void 0===r&&(r=new WeakMap),void 0===n&&(n={});for(var a=0,i=Object.keys(e);a<i.length;a++){var u=i[a],o=e[u];h(o)?r.get(o)||(r.set(o,!0),n[u]=Array.isArray(o)?[]:{},g(o,t,r,n[u])):n[u]=t}return n}var F=t.createContext(void 0),O=F.Provider,_=F.Consumer;function R(){var e=t.useContext(F);return e||u(!1),e}function C(e,t){switch(t.type){case"SET_VALUES":return c({},e,{values:t.payload});case"SET_TOUCHED":return c({},e,{touched:t.payload});case"SET_ERRORS":return c({},e,{errors:t.payload});case"SET_STATUS":return c({},e,{status:t.payload});case"SET_ISSUBMITTING":return c({},e,{isSubmitting:t.payload});case"SET_ISVALIDATING":return c({},e,{isValidating:t.payload});case"SET_FIELD_VALUE":return c({},e,{values:b(e.values,t.payload.field,t.payload.value)});case"SET_FIELD_TOUCHED":return c({},e,{touched:b(e.touched,t.payload.field,t.payload.value)});case"SET_FIELD_ERROR":return c({},e,{errors:b(e.errors,t.payload.field,t.payload.value)});case"RESET_FORM":return c({},e,t.payload);case"SET_FORMIK_STATE":return t.payload(e);case"SUBMIT_ATTEMPT":return c({},e,{touched:g(e.values,!0),isSubmitting:!0,submitCount:e.submitCount+1});case"SUBMIT_FAILURE":case"SUBMIT_SUCCESS":return c({},e,{isSubmitting:!1});default:return e}}var k={},A={};function P(e){var a=e.validateOnChange,i=void 0===a||a,u=e.validateOnBlur,l=void 0===u||u,s=e.validateOnMount,d=void 0!==s&&s,p=e.isInitialValid,h=e.enableReinitialize,m=void 0!==h&&h,E=e.onSubmit,g=f(e,["validateOnChange","validateOnBlur","validateOnMount","isInitialValid","enableReinitialize","onSubmit"]),F=c({validateOnChange:i,validateOnBlur:l,validateOnMount:d,onSubmit:E},g),O=t.useRef(F.initialValues),_=t.useRef(F.initialErrors||k),R=t.useRef(F.initialTouched||A),P=t.useRef(F.initialStatus),I=t.useRef(!1),V=t.useRef({});t.useEffect(function(){},[p]),t.useEffect(function(){return I.current=!0,function(){I.current=!1}},[]);var L=t.useReducer(C,{values:F.initialValues,errors:F.initialErrors||k,touched:F.initialTouched||A,status:F.initialStatus,isSubmitting:!1,isValidating:!1,submitCount:0}),j=L[0],N=L[1],B=t.useCallback(function(e,t){return new Promise(function(r,n){var a=F.validate(e,t);null==a?r(k):S(a)?a.then(function(e){r(e||k)},function(e){n(e)}):r(a)})},[F.validate]),x=t.useCallback(function(e,t){var r=F.validationSchema,n=v(r)?r(t):r,a=t&&n.validateAt?n.validateAt(t,e):D(e,n);return new Promise(function(e,t){a.then(function(){e(k)},function(r){"ValidationError"===r.name?e(w(r)):t(r)})})},[F.validationSchema]),q=t.useCallback(function(e,t){return new Promise(function(r){return r(V.current[e].validate(t))})},[]),G=t.useCallback(function(e){var t=Object.keys(V.current).filter(function(e){return v(V.current[e].validate)}),r=t.length>0?t.map(function(t){return q(t,T(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=b(e,t[n],r)),e)},{})})},[q]),W=t.useCallback(function(e){return Promise.all([G(e),F.validationSchema?x(e):{},F.validate?B(e):{}]).then(function(e){return n.all([e[0],e[1],e[2]],{arrayMerge:U})})},[F.validate,F.validationSchema,G,B,x]),H=M(function(e){return void 0===e&&(e=j.values),o.unstable_runWithPriority(o.LowPriority,function(){return W(e).then(function(e){return I.current&&N({type:"SET_ERRORS",payload:e}),e})})}),K=M(function(e){return void 0===e&&(e=j.values),N({type:"SET_ISVALIDATING",payload:!0}),W(e).then(function(e){return I.current&&(N({type:"SET_ISVALIDATING",payload:!1}),r(j.errors,e)||N({type:"SET_ERRORS",payload:e})),e})}),Y=t.useCallback(function(e){var t=e&&e.values?e.values:O.current,r=e&&e.errors?e.errors:_.current?_.current:F.initialErrors||{},n=e&&e.touched?e.touched:R.current?R.current:F.initialTouched||{},a=e&&e.status?e.status:P.current?P.current:F.initialStatus;O.current=t,_.current=r,R.current=n,P.current=a,N({type:"RESET_FORM",payload:{isSubmitting:!!e&&!!e.isSubmitting,errors:r,touched:n,status:a,values:t,isValidating:!!e&&!!e.isValidating,submitCount:e&&e.submitCount&&"number"==typeof e.submitCount?e.submitCount:0}})},[F.initialErrors,F.initialStatus,F.initialTouched]);t.useEffect(function(){m&&!0===I.current&&!r(O.current,F.initialValues)&&(O.current=F.initialValues,Y())},[m,F.initialValues,Y]),t.useEffect(function(){m&&!0===I.current&&!r(_.current,F.initialErrors)&&(_.current=F.initialErrors||k,N({type:"SET_ERRORS",payload:F.initialErrors||k}))},[m,F.initialErrors]),t.useEffect(function(){m&&!0===I.current&&!r(R.current,F.initialTouched)&&(R.current=F.initialTouched||A,N({type:"SET_TOUCHED",payload:F.initialTouched||A}))},[m,F.initialTouched]),t.useEffect(function(){m&&!0===I.current&&!r(P.current,F.initialStatus)&&(P.current=F.initialStatus,N({type:"SET_STATUS",payload:F.initialStatus}))},[m,F.initialStatus,F.initialTouched]);var z=M(function(e){if(v(V.current[e].validate)){var t=T(j.values,e),r=V.current[e].validate(t);return S(r)?(N({type:"SET_ISVALIDATING",payload:!0}),r.then(function(e){return e}).then(function(t){N({type:"SET_FIELD_ERROR",payload:{field:e,value:t}}),N({type:"SET_ISVALIDATING",payload:!1})})):(N({type:"SET_FIELD_ERROR",payload:{field:e,value:r}}),Promise.resolve(r))}return Promise.resolve()}),J=t.useCallback(function(e,t){V.current[e]={validate:t.validate}},[]),Q=t.useCallback(function(e){delete V.current[e]},[]),X=M(function(e){return N({type:"SET_TOUCHED",payload:e}),l?H(j.values):Promise.resolve()}),Z=t.useCallback(function(e){N({type:"SET_ERRORS",payload:e})},[]),$=M(function(e){return N({type:"SET_VALUES",payload:e}),i?H(j.values):Promise.resolve()}),ee=t.useCallback(function(e,t){N({type:"SET_FIELD_ERROR",payload:{field:e,value:t}})},[]),te=M(function(e,t,r){return void 0===r&&(r=!0),N({type:"SET_FIELD_VALUE",payload:{field:e,value:t}}),i&&r?H(b(j.values,e,t)):Promise.resolve()}),re=t.useCallback(function(e,t){var r,n=t,a=e;if(!y(e)){e.persist&&e.persist();var i=e.target,u=i.type,o=i.value,l=i.checked,s=i.options,c=i.multiple;n=t||i.name||i.id,a=/number|range/.test(u)?(r=parseFloat(o),isNaN(r)?"":r):/checkbox/.test(u)?function(e,t,r){if("true"==r||"false"==r)return!!t;if(t)return Array.isArray(e)?e.concat(r):[r];if(!Array.isArray(e))return!!e;var n=e.indexOf(r);return n<0?e:e.slice(0,n).concat(e.slice(n+1))}(T(j.values,n),l,o):c?function(e){return Array.from(e).filter(function(e){return e.selected}).map(function(e){return e.value})}(s):o}n&&te(n,a)},[te,j.values]),ne=t.useCallback(function(e){if(y(e))return function(t){return re(t,e)};re(e)},[re]),ae=M(function(e,t,r){return void 0===t&&(t=!0),void 0===r&&(r=!0),N({type:"SET_FIELD_TOUCHED",payload:{field:e,value:t}}),l&&r?H(j.values):Promise.resolve()}),ie=t.useCallback(function(e,t){e.persist&&e.persist();var r=e.target;ae(t||r.name||r.id,!0)},[ae]),ue=t.useCallback(function(e){if(y(e))return function(t){return ie(t,e)};ie(e)},[ie]),oe=t.useCallback(function(e){v(e)?N({type:"SET_FORMIK_STATE",payload:e}):N({type:"SET_FORMIK_STATE",payload:function(){return e}})},[]),le=t.useCallback(function(e){N({type:"SET_STATUS",payload:e})},[]),se=t.useCallback(function(e){N({type:"SET_ISSUBMITTING",payload:e})},[]),ce={resetForm:Y,validateForm:K,validateField:z,setErrors:Z,setFieldError:ee,setFieldTouched:ae,setFieldValue:te,setStatus:le,setSubmitting:se,setTouched:X,setValues:$,setFormikState:oe},de=M(function(){return E(j.values,ce)}),fe=M(function(){return N({type:"SUBMIT_ATTEMPT"}),K().then(function(e){if(0===Object.keys(e).length)return Promise.resolve(de()).then(function(){I.current&&N({type:"SUBMIT_SUCCESS"})}).catch(function(e){if(I.current)throw N({type:"SUBMIT_FAILURE"}),e});I.current&&N({type:"SUBMIT_FAILURE"})})}),pe=M(function(e){e&&e.preventDefault&&v(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&v(e.stopPropagation)&&e.stopPropagation(),fe()}),ve=M(function(e){if(e&&e.preventDefault&&v(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&v(e.stopPropagation)&&e.stopPropagation(),F.onReset){var t=F.onReset(j.values,ce);S(t)?t.then(Y):Y()}else Y()}),he=t.useCallback(function(e){return{value:T(j.values,e),error:T(j.errors,e),touched:!!T(j.touched,e),initialValue:T(O.current,e),initialTouched:!!T(R.current,e),initialError:T(_.current,e)}},[j.errors,j.touched,j.values]),me=t.useCallback(function(e){var t=e.name,r=e.type,n=e.value,a=e.as,i=e.multiple,u=T(j.values,t),o={name:t,value:u,onChange:ne,onBlur:ue};return"checkbox"===r?void 0===n?o.checked=!!u:(o.checked=!(!Array.isArray(u)||!~u.indexOf(n)),o.value=n):"radio"===r?(o.checked=u===n,o.value=n):"select"===a&&i&&(o.value=o.value||[],o.multiple=!0),[o,he(t)]},[he,ue,ne,j.values]),ye=t.useMemo(function(){return!r(O.current,j.values)},[j.values]),Ee=t.useMemo(function(){return void 0!==p?ye?j.errors&&0===Object.keys(j.errors).length:!1!==p&&v(p)?p(F):p:j.errors&&0===Object.keys(j.errors).length},[p,ye,j.errors,F]);return c({},j,{initialValues:O.current,initialErrors:_.current,initialTouched:R.current,initialStatus:P.current,handleBlur:ue,handleChange:ne,handleReset:ve,handleSubmit:pe,resetForm:Y,setErrors:Z,setFormikState:oe,setFieldTouched:ae,setFieldValue:te,setFieldError:ee,setStatus:le,setSubmitting:se,setTouched:X,setValues:$,submitForm:fe,validateForm:K,validateField:z,isValid:Ee,dirty:ye,unregisterField:Q,registerField:J,getFieldProps:me,validateOnBlur:l,validateOnChange:i,validateOnMount:d})}function I(e){var r=P(e),n=e.component,a=e.children,i=e.render;return t.createElement(O,{value:r},n?t.createElement(n,r):i?i(r):a?v(a)?a(r):E(a)?null:t.Children.only(a):null)}function w(e){var t={};if(e.inner){if(0===e.inner.length)return b(t,e.path,e.message);var r=e.inner,n=Array.isArray(r),a=0;for(r=n?r:r[Symbol.iterator]();;){var i;if(n){if(a>=r.length)break;i=r[a++]}else{if((a=r.next()).done)break;i=a.value}var u=i;T(t,u.path)||(t=b(t,u.path,u.message))}}return t}function D(e,t,r,n){void 0===r&&(r=!1),void 0===n&&(n={});var a=function e(t){var r={};for(var n in t)if(t.hasOwnProperty(n)){var a=String(n);r[a]=!0===Array.isArray(t[a])?t[a].map(function(t){return!0===Array.isArray(t)||"object"==typeof t?e(t):""!==t?t:void 0}):"object"==typeof t[a]&&null!==t[a]?e(t[a]):""!==t[a]?t[a]:void 0}return r}(e);return t[r?"validateSync":"validate"](a,{abortEarly:!1,context:n})}function U(e,t,r){var a=e.slice();return t.forEach(function(t,i){if(void 0===a[i]){var u=!1!==r.clone&&r.isMergeableObject(t);a[i]=u?n(Array.isArray(t)?[]:{},t,r):t}else r.isMergeableObject(t)?a[i]=n(e[i],t,r):-1===e.indexOf(t)&&a.push(t)}),a}var V="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?t.useLayoutEffect:t.useEffect;function M(e){var r=t.useRef(e);return V(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 L(e){var r=e.validate,n=e.name,a=e.render,i=e.children,u=e.as,o=e.component,l=f(e,["validate","name","render","children","as","component"]),s=f(R(),["validate","validationSchema"]);t.useEffect(function(){},[]);var d=s.registerField,p=s.unregisterField;t.useEffect(function(){return d(n,{validate:r}),function(){p(n)}},[d,p,n,r]);var h=s.getFieldProps(c({name:n},l)),m=h[0],y=h[1],E={field:m,form:s};if(a)return a(E);if(v(i))return i(c({},E,{meta:y}));if(o){if("string"==typeof o){var S=l.innerRef,T=f(l,["innerRef"]);return t.createElement(o,c({ref:S},m,T),i)}return t.createElement(o,c({field:m,form:s},l),i)}var b=u||"input";if("string"==typeof b){var g=l.innerRef,F=f(l,["innerRef"]);return t.createElement(b,c({ref:g},m,F),i)}return t.createElement(b,c({},m,l),i)}var j=L;function N(e){var r=e.action,n=f(e,["action"]),a=r||"#",i=R();return t.createElement("form",Object.assign({onSubmit:i.handleSubmit,onReset:i.handleReset,action:a},n))}function B(e){var r=function(r){return t.createElement(_,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)}N.displayName="Form";var x=function(e,t,r){var n=[].concat(e||[]),a=n[t];return n.splice(t,1),n.splice(r,0,a),n},q=function(e,t,r){var n=[].concat(e||[]),a=n[t];return n[t]=n[r],n[r]=a,n},G=function(e,t,r){var n=[].concat(e||[]);return n.splice(t,0,r),n},W=function(e,t,r){var n=[].concat(e||[]);return n[t]=r,n},H=function(e){function r(t){var r;return(r=e.call(this,t)||this).updateArrayField=function(e,t,n){var a=r.props,i=a.name,u=a.validateOnChange,o=a.formik,l=o.validateForm;(0,o.setFormikState)(function(r){var a="function"==typeof n?n:e,u="function"==typeof t?t:e;return c({},r,{values:b(r.values,i,e(T(r.values,i))),errors:n?b(r.errors,i,a(T(r.errors,i))):r.errors,touched:t?b(r.touched,i,u(T(r.touched,i))):r.touched})},function(){u&&l()})},r.push=function(e){return r.updateArrayField(function(t){return[].concat(t||[],[s(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 x(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 G(r,e,t)},function(t){return G(t,e,null)},function(t){return G(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 W(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(p(r)),r.pop=r.pop.bind(p(r)),r}d(r,e);var n=r.prototype;return n.remove=function(e){var t;return this.updateArrayField(function(r){var n=r?[].concat(r):[];return t||(t=n[e]),v(n.splice)&&n.splice(e,1),n},!0,!0),t},n.pop=function(){var e;return this.updateArrayField(function(t){var r=t;return e||(e=r&&r.pop&&r.pop()),r},!0,!0),e},n.render=function(){var e=this.props,r=e.component,n=e.render,a=e.children,i=e.name,u=c({},{push:this.push,pop:this.pop,swap:this.swap,move:this.move,insert:this.insert,replace:this.replace,unshift:this.unshift,remove:this.remove,handlePush:this.handlePush,handlePop:this.handlePop,handleSwap:this.handleSwap,handleMove:this.handleMove,handleInsert:this.handleInsert,handleReplace:this.handleReplace,handleUnshift:this.handleUnshift,handleRemove:this.handleRemove},{form:f(e.formik,["validate","validationSchema"]),name:i});return r?t.createElement(r,u):n?n(u):a?"function"==typeof a?a(u):E(a)?null:t.Children.only(a):null},r}(t.Component);H.defaultProps={validateOnChange:!0};var K=B(H);e.ErrorMessage=B(function(e){function r(){return e.apply(this,arguments)||this}d(r,e);var n=r.prototype;return n.shouldComponentUpdate=function(e){return T(this.props.formik.errors,this.props.name)!==T(e.formik.errors,this.props.name)||T(this.props.formik.touched,this.props.name)!==T(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,a=e.render,i=e.children,u=e.name,o=f(e,["component","formik","render","children","name"]),l=T(n.touched,u),s=T(n.errors,u);return l&&s?a?v(a)?a(s):null:i?v(i)?i(s):null:r?t.createElement(r,o,s):s:null},r}(t.Component)),e.FastField=j,e.Field=L,e.FieldArray=K,e.Form=N,e.Formik=I,e.FormikConsumer=_,e.FormikProvider=O,e.connect=B,e.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}},e.getIn=T,e.insert=G,e.isEmptyChildren=E,e.isFunction=v,e.isInputEvent=function(e){return e&&h(e)&&h(e.target)},e.isInteger=m,e.isNaN=function(e){return e!=e},e.isObject=h,e.isPromise=S,e.isString=y,e.move=x,e.replace=W,e.setIn=b,e.setNestedObjectValues=g,e.swap=q,e.useField=function(e){var r=R(),n=r.getFieldProps,a=r.registerField,i=r.unregisterField,u=h(e),o=u?e.name:e,l=u?e.validate:void 0;return t.useEffect(function(){return o&&a(o,{validate:l}),function(){o&&i(o)}},[a,i,o,l]),h(e)?n(e):n({name:e})},e.useFormik=P,e.useFormikContext=R,e.validateYupSchema=D,e.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,a=f(e,["mapPropsToValues"]);return function(e){var r=e.displayName||e.name||e.constructor&&e.constructor.name||"Component",i=function(r){function i(){var n;return(n=r.apply(this,arguments)||this).validate=function(e){return a.validate(e,n.props)},n.validationSchema=function(){return v(a.validationSchema)?a.validationSchema(n.props):a.validationSchema},n.handleSubmit=function(e,t){return a.handleSubmit(e,c({},t,{props:n.props}))},n.renderFormComponent=function(r){return t.createElement(e,Object.assign({},n.props,r))},n}return d(i,r),i.prototype.render=function(){var e=f(this.props,["children"]);return t.createElement(I,Object.assign({},e,a,{validate:a.validate&&this.validate,validationSchema:a.validationSchema&&this.validationSchema,initialValues:n(this.props),initialStatus:a.mapPropsToStatus&&a.mapPropsToStatus(this.props),initialErrors:a.mapPropsToErrors&&a.mapPropsToErrors(this.props),initialTouched:a.mapPropsToTouched&&a.mapPropsToTouched(this.props),onSubmit:this.handleSubmit,render:this.renderFormComponent}))},i}(t.Component);return i.displayName="WithFormik("+r+")",l(i,e)}},e.yupToFormErrors=w}); | ||
//# sourceMappingURL=formik.umd.production.min.js.map |
@@ -54,2 +54,3 @@ import * as React from 'react'; | ||
validateOnBlur?: boolean; | ||
validateOnMount?: boolean; | ||
isInitialValid?: boolean | ((props: Props) => boolean); | ||
@@ -56,0 +57,0 @@ enableReinitialize?: boolean; |
{ | ||
"name": "formik", | ||
"description": "Forms in React, without tears", | ||
"version": "2.0.1-rc.13", | ||
"version": "2.0.1-rc.14", | ||
"license": "MIT", | ||
@@ -34,3 +34,3 @@ "author": "Jared Palmer <jared@palmer.net>", | ||
"build": "cross-env NODE_ENV=production tsdx build --format=cjs,esm,umd", | ||
"prepublish": "npm run build", | ||
"prepublishOnly": "npm run build", | ||
"format": "prettier --trailing-comma es5 --single-quote --write 'src/**/*' 'test/**/*' 'README.md' '/docs/**/*.md'", | ||
@@ -37,0 +37,0 @@ "precommit": "lint-staged", |
@@ -11,3 +11,3 @@ <p align="center"> | ||
[![Stable Release](https://img.shields.io/npm/v/formik.svg)](https://npm.im/formik) | ||
[![Financial Contributors on Open Collective](https://opencollective.com/formik/all/badge.svg?label=financial+contributors)](https://opencollective.com/formik) [![Stable Release](https://img.shields.io/npm/v/formik.svg)](https://npm.im/formik) | ||
[![Blazing Fast](https://badgen.now.sh/badge/speed/blazing%20%F0%9F%94%A5/green)](https://npm.im/formik) | ||
@@ -107,1 +107,31 @@ [![gzip size](http://img.badgesize.io/https://unpkg.com/formik@latest/dist/formik.umd.production.js?compression=gzip)](https://unpkg.com/formik@latest/dist/formik.umd.production.js) | ||
--- | ||
## Contributors | ||
### Code Contributors | ||
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)]. | ||
<a href="https://github.com/jaredpalmer/formik/graphs/contributors"><img src="https://opencollective.com/formik/contributors.svg?width=890&button=false" /></a> | ||
### Financial Contributors | ||
Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/formik/contribute)] | ||
#### Individuals | ||
<a href="https://opencollective.com/formik"><img src="https://opencollective.com/formik/individuals.svg?width=890"></a> | ||
#### Organizations | ||
Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/formik/contribute)] | ||
<a href="https://opencollective.com/formik/organization/0/website"><img src="https://opencollective.com/formik/organization/0/avatar.svg"></a> | ||
<a href="https://opencollective.com/formik/organization/1/website"><img src="https://opencollective.com/formik/organization/1/avatar.svg"></a> | ||
<a href="https://opencollective.com/formik/organization/2/website"><img src="https://opencollective.com/formik/organization/2/avatar.svg"></a> | ||
<a href="https://opencollective.com/formik/organization/3/website"><img src="https://opencollective.com/formik/organization/3/avatar.svg"></a> | ||
<a href="https://opencollective.com/formik/organization/4/website"><img src="https://opencollective.com/formik/organization/4/avatar.svg"></a> | ||
<a href="https://opencollective.com/formik/organization/5/website"><img src="https://opencollective.com/formik/organization/5/avatar.svg"></a> | ||
<a href="https://opencollective.com/formik/organization/6/website"><img src="https://opencollective.com/formik/organization/6/avatar.svg"></a> | ||
<a href="https://opencollective.com/formik/organization/7/website"><img src="https://opencollective.com/formik/organization/7/avatar.svg"></a> | ||
<a href="https://opencollective.com/formik/organization/8/website"><img src="https://opencollective.com/formik/organization/8/avatar.svg"></a> | ||
<a href="https://opencollective.com/formik/organization/9/website"><img src="https://opencollective.com/formik/organization/9/avatar.svg"></a> |
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 not supported yet
Sorry, the diff of this file is not supported yet
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
727139
4568
136