final-form
Advanced tools
Comparing version 4.20.0 to 4.20.1
@@ -343,3 +343,3 @@ 'use strict'; | ||
var version = "4.20.0"; | ||
var version = "4.20.1"; | ||
@@ -346,0 +346,0 @@ var configOptions = ['debug', 'initialValues', 'keepDirtyOnReinitialize', 'mutators', 'onSubmit', 'validate', 'validateOnBlur']; |
@@ -337,3 +337,3 @@ import _extends from '@babel/runtime/helpers/esm/extends'; | ||
var version = "4.20.0"; | ||
var version = "4.20.1"; | ||
@@ -340,0 +340,0 @@ var configOptions = ['debug', 'initialValues', 'keepDirtyOnReinitialize', 'mutators', 'onSubmit', 'validate', 'validateOnBlur']; |
@@ -373,3 +373,3 @@ (function (global, factory) { | ||
var version = "4.20.0"; | ||
var version = "4.20.1"; | ||
@@ -376,0 +376,0 @@ var configOptions = ['debug', 'initialValues', 'keepDirtyOnReinitialize', 'mutators', 'onSubmit', 'validate', 'validateOnBlur']; |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self)["final-form"]={})}(this,function(e){"use strict";function R(){return(R=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}function u(e){if(null==e||!e.length)return[];if("string"!=typeof e)throw new Error("toPath() expects a string");return null==t[e]&&(t[e]=e.split(i).filter(Boolean)),t[e]}var t={},i=/[.[\]]+/,A=function(e,t){for(var i=u(t),r=e,n=0;n<i.length;n++){var a=i[n];if(null==r||"object"!=typeof r||Array.isArray(r)&&isNaN(a))return;r=r[a]}return r};function S(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0===i)return("string"===t?String:Number)(e);var r=i.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"==typeof t?t:String(t)}function h(e,t,i,r,n){if(t>=i.length)return r;var a=i[t];if(isNaN(a)){var u;if(null==e){var o,s=h(void 0,t+1,i,r,n);return void 0===s?void 0:((o={})[a]=s,o)}if(Array.isArray(e))throw new Error("Cannot set a non-numeric property on an array");var d=h(e[a],t+1,i,r,n);if(void 0!==d)return R({},e,((u={})[a]=d,u));var l=Object.keys(e).length;if(void 0===e[a]&&0===l)return;if(void 0!==e[a]&&l<=1)return isNaN(i[t-1])||n?void 0:{};e[a];return function(e,t){if(null==e)return{};var i,r,n={},a=Object.keys(e);for(r=0;r<a.length;r++)i=a[r],0<=t.indexOf(i)||(n[i]=e[i]);return n}(e,[a].map(S))}var f=Number(a);if(null==e){var c=h(void 0,t+1,i,r,n);if(void 0===c)return;var v=[];return v[f]=c,v}if(!Array.isArray(e))throw new Error("Cannot set a numeric property on an object");var m=h(e[f],t+1,i,r,n),b=[].concat(e);if(n&&void 0===m){if(b.splice(f,1),0===b.length)return}else b[f]=m;return b}function k(e,t,i,r){if(void 0===r&&(r=!1),null==e)throw new Error("Cannot call setIn() with "+String(e)+" state");if(null==t)throw new Error("Cannot call setIn() with "+String(t)+" key");return h(e,0,u(t),i,r)}var w="FINAL_FORM/form-error",L="FINAL_FORM/array-error";function x(e,t){var i=e.errors,r=e.initialValues,n=e.lastSubmittedValues,a=e.submitErrors,u=e.submitFailed,o=e.submitSucceeded,s=e.submitting,d=e.values,l=t.active,f=t.blur,c=t.change,v=t.data,m=t.focus,b=t.modified,S=t.modifiedSinceLastSubmit,h=t.name,g=t.touched,y=t.validating,p=t.visited,E=A(d,h),F=A(i,h);F&&F[L]&&(F=F[L]);var O=a&&A(a,h),V=r&&A(r,h),j=t.isEqual(V,E),k=!F&&!O;return{active:l,blur:f,change:c,data:v,dirty:!j,dirtySinceLastSubmit:!(!n||t.isEqual(A(n,h),E)),error:F,focus:m,initial:V,invalid:!k,length:Array.isArray(E)?E.length:void 0,modified:b,modifiedSinceLastSubmit:S,name:h,pristine:j,submitError:O,submitFailed:u,submitSucceeded:o,submitting:s,touched:g,valid:k,value:E,visited:p,validating:y}}var a=["active","data","dirty","dirtySinceLastSubmit","error","initial","invalid","length","modified","modifiedSinceLastSubmit","pristine","submitError","submitFailed","submitSucceeded","submitting","touched","valid","value","visited","validating"],I=function(e,t){if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(var n=Object.prototype.hasOwnProperty.bind(t),a=0;a<i.length;a++){var u=i[a];if(!n(u)||e[u]!==t[u])return!1}return!0};function o(t,i,r,n,e,a){var u=!1;return e.forEach(function(e){n[e]&&(t[e]=i[e],r&&(~a.indexOf(e)?I(i[e],r[e]):i[e]===r[e])||(u=!0))}),u}function P(e,t,i,r){var n={blur:e.blur,change:e.change,focus:e.focus,name:e.name};return o(n,e,t,i,a,s)||!t||r?n:void 0}var s=["data"],d=["active","dirty","dirtyFields","dirtyFieldsSinceLastSubmit","dirtySinceLastSubmit","error","errors","hasSubmitErrors","hasValidationErrors","initialValues","invalid","modified","modifiedSinceLastSubmit","pristine","submitting","submitError","submitErrors","submitFailed","submitSucceeded","touched","valid","validating","values","visited"],l=["touched","visited"];function q(e,t,i,r){var n={};return o(n,e,t,i,d,l)||!t||r?n:void 0}function z(r){var n,a;return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return n&&t.length===n.length&&!t.some(function(e,t){return!I(n[t],e)})||(n=t,a=r.apply(void 0,t)),a}}function C(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then}function _(e,t){return e===t}var U=function i(r){return Object.keys(r).some(function(e){var t=r[e];return!t||"object"!=typeof t||t instanceof Error?void 0!==t:i(t)})};function B(e,t,i,r,n,a){var u=n(i,r,t,a);return u&&(e(u),1)}function M(e,a,u,o,s){var d=e.entries;Object.keys(d).forEach(function(e){var t=d[Number(e)];if(t){var i=t.subscription,r=t.subscriber,n=t.notified;B(r,i,a,u,o,s||!n)&&(t.notified=!0)}})}e.ARRAY_ERROR=L,e.FORM_ERROR=w,e.configOptions=["debug","initialValues","keepDirtyOnReinitialize","mutators","onSubmit","validate","validateOnBlur"],e.createForm=function(e){if(!e)throw new Error("No config specified");e.debug;var s=e.destroyOnUnregister,u=e.keepDirtyOnReinitialize,t=e.initialValues,o=e.mutators,d=e.onSubmit,g=e.validate,a=e.validateOnBlur;if(!d)throw new Error("No onSubmit function specified");function l(e,t,i){var r=i(A(e.formState.values,t));e.formState.values=k(e.formState.values,t,r)||{}}function f(e,t,i){if(e.fields[t]){var r,n;e.fields=R({},e.fields,((r={})[i]=R({},e.fields[t],{name:i,blur:function(){return j.blur(i)},change:function(e){return j.change(i,e)},focus:function(){return j.focus(i)},lastFieldState:void 0}),r)),delete e.fields[t],e.fieldSubscribers=R({},e.fieldSubscribers,((n={})[i]=e.fieldSubscribers[t],n)),delete e.fieldSubscribers[t];var a=A(e.formState.values,t);e.formState.values=k(e.formState.values,t,void 0)||{},e.formState.values=k(e.formState.values,i,a),delete e.lastFormState}}function i(a){return function(){if(o){for(var e={formState:N.formState,fields:N.fields,fieldSubscribers:N.fieldSubscribers,lastFormState:N.lastFormState},t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];var n=o[a](i,e,{changeValue:l,getIn:A,renameField:f,resetFieldState:j.resetFieldState,setIn:k,shallowEqual:I});return N.formState=e.formState,N.fields=e.fields,N.fieldSubscribers=e.fieldSubscribers,N.lastFormState=e.lastFormState,m(void 0,function(){b(),V()}),n}}}function y(r){return Object.keys(r.validators).reduce(function(e,t){var i=r.validators[Number(t)]();return i&&e.push(i),e},[])}function c(){Object.keys(N.fields).forEach(function(e){N.fields[e].touched=!0})}function v(){var e=N.fields,r=N.formState,t=N.lastFormState,n=R({},e),i=Object.keys(n),a=!1,u=i.reduce(function(e,t){return!n[t].isEqual(A(r.values,t),A(r.initialValues||{},t))&&(a=!0,e[t]=!0),e},{}),o=i.reduce(function(e,t){var i=r.lastSubmittedValues||{};return n[t].isEqual(A(r.values,t),A(i,t))||(e[t]=!0),e},{});r.pristine=!a,r.dirtySinceLastSubmit=!(!r.lastSubmittedValues||!Object.values(o).some(function(e){return e})),r.modifiedSinceLastSubmit=!(!r.lastSubmittedValues||!Object.keys(n).some(function(e){return n[e].modifiedSinceLastSubmit})),r.valid=!(r.error||r.submitError||U(r.errors)||r.submitErrors&&U(r.submitErrors));var s,d,l,f,c,v,m,b,S,h,g,y,p,E,F,O,V=(d=(s=r).active,l=s.dirtySinceLastSubmit,f=s.modifiedSinceLastSubmit,c=s.error,v=s.errors,m=s.initialValues,b=s.pristine,S=s.submitting,h=s.submitFailed,g=s.submitSucceeded,y=s.submitError,p=s.submitErrors,E=s.valid,F=s.validating,O=s.values,{active:d,dirty:!b,dirtySinceLastSubmit:l,modifiedSinceLastSubmit:f,error:c,errors:v,hasSubmitErrors:!!(y||p&&U(p)),hasValidationErrors:!(!c&&!U(v)),invalid:!E,initialValues:m,pristine:b,submitting:S,submitFailed:h,submitSucceeded:g,submitError:y,submitErrors:p,valid:E,validating:0<F,values:O}),j=i.reduce(function(e,t){return e.modified[t]=n[t].modified,e.touched[t]=n[t].touched,e.visited[t]=n[t].visited,e},{modified:{},touched:{},visited:{}}),k=j.modified,w=j.touched,L=j.visited;return V.dirtyFields=t&&I(t.dirtyFields,u)?t.dirtyFields:u,V.dirtyFieldsSinceLastSubmit=t&&I(t.dirtyFieldsSinceLastSubmit,o)?t.dirtyFieldsSinceLastSubmit:o,V.modified=t&&I(t.modified,k)?t.modified:k,V.touched=t&&I(t.touched,w)?t.touched:w,V.visited=t&&I(t.visited,L)?t.visited:L,t&&I(t,V)?t:V}var N={subscribers:{index:0,entries:{}},fieldSubscribers:{},fields:{},formState:{dirtySinceLastSubmit:!1,modifiedSinceLastSubmit:!1,errors:{},initialValues:t&&R({},t),invalid:!1,pristine:!0,submitting:!1,submitFailed:!1,submitSucceeded:!1,valid:!0,validating:0,values:t?R({},t):{}},lastFormState:void 0},r=0,p=!1,E=!1,F=0,O={},n=o?Object.keys(o).reduce(function(e,t){return e[t]=i(t),e},{}):{},m=function(e,t){if(p)return E=!0,void t();var o=N.fields,i=N.formState,s=R({},o),r=Object.keys(s);if(g||r.some(function(e){return y(s[e]).length})){var d=!1;if(e){var n=s[e];if(n){var a=n.validateFields;a&&(d=!0,r=a.length?a.concat(e):[e])}}var u,l={},f={},c=[].concat(function(e){var t=[];if(g){var i=g(R({},N.formState.values));C(i)?t.push(i.then(e)):e(i)}return t}(function(e){l=e||{}}),r.reduce(function(e,t){return e.concat(function(r,n){var a,u=[],e=y(r);e.length&&(e.forEach(function(e){var t=e(A(N.formState.values,r.name),N.formState.values,0===e.length||3===e.length?x(N.formState,N.fields[r.name]):void 0);if(t&&C(t)){r.validating=!0;var i=t.then(function(e){r.validating=!1,n(e)});u.push(i)}else a=a||t}),n(a));return u}(o[t],function(e){f[t]=e}))},[])),v=0<c.length,m=++F,b=Promise.all(c).then((u=m,function(e){return delete O[u],e}));v&&(O[m]=b);var S=function(){function e(a){r.forEach(function(e){if(o[e]){var t=A(l,e),i=A(u,e),r=y(s[e]).length,n=f[e];a(e,r&&n||g&&t||(t||d?void 0:i))}})}var u=R({},d?i.errors:{},l);e(function(e,t){u=k(u,e,t)||{}}),e(function(e,t){if(t&&t[L]){var i=A(u,e),r=[].concat(i);r[L]=t[L],u=k(u,e,r)}}),I(i.errors,u)||(i.errors=u),i.error=l[w]};if(S(),t(),v){N.formState.validating++,t();var h=function(){N.formState.validating--,t()};b.then(function(){m<F||S()}).then(h,h)}}else t()},b=function(e){if(!r){var t=N.fields,a=N.fieldSubscribers,u=N.formState,o=R({},t),i=function(e){var t=o[e],i=x(u,t),r=t.lastFieldState;t.lastFieldState=i;var n=a[e];n&&M(n,i,r,P,void 0===r)};e?i(e):Object.keys(o).forEach(i)}},S=!1,h=!1,V=function e(){if(S)h=!0;else{if(S=!0,!r&&!p){var t=N.lastFormState,i=v();i!==t&&(N.lastFormState=i,M(N.subscribers,i,t,q))}S=!1,h&&(h=!1,e())}};m(void 0,function(){V()});var j={batch:function(e){r++,e(),r--,b(),V()},blur:function(e){var t=N.fields,i=N.formState,r=t[e];r&&(delete i.active,t[e]=R({},r,{active:!1,touched:!0}),a?m(e,function(){b(),V()}):(b(),V()))},change:function(e,t){var i=N.fields,r=N.formState;if(A(r.values,e)!==t){l(N,e,function(){return t});var n=i[e];n&&(i[e]=R({},n,{modified:!0,modifiedSinceLastSubmit:!!r.lastSubmittedValues})),a?(b(),V()):m(e,function(){b(),V()})}},get destroyOnUnregister(){return!!s},set destroyOnUnregister(e){s=e},focus:function(e){var t=N.fields[e];t&&!t.active&&(N.formState.active=e,t.active=!0,t.visited=!0,b(),V())},mutators:n,getFieldState:function(e){var t=N.fields[e];return t&&t.lastFieldState},getRegisteredFields:function(){return Object.keys(N.fields)},getState:function(){return v()},initialize:function(e){var t=N.fields,i=N.formState,r=R({},t),n="function"==typeof e?e(i.values):e;u||(i.values=n);var a=u?Object.keys(r).reduce(function(e,t){return r[t].isEqual(A(i.values,t),A(i.initialValues||{},t))||(e[t]=A(i.values,t)),e},{}):{};i.initialValues=n,i.values=n,Object.keys(a).forEach(function(e){i.values=k(i.values,e,a[e])}),m(void 0,function(){b(),V()})},isValidationPaused:function(){return p},pauseValidation:function(){p=!0},registerField:function(i,e,t,r){void 0===t&&(t={}),N.fieldSubscribers[i]||(N.fieldSubscribers[i]={index:0,entries:{}});var n=N.fieldSubscribers[i].index++;N.fieldSubscribers[i].entries[n]={subscriber:z(e),subscription:t,notified:!1},N.fields[i]||(N.fields[i]={active:!1,afterSubmit:r&&r.afterSubmit,beforeSubmit:r&&r.beforeSubmit,blur:function(){return j.blur(i)},change:function(e){return j.change(i,e)},data:r&&r.data||{},focus:function(){return j.focus(i)},isEqual:r&&r.isEqual||_,lastFieldState:void 0,modified:!1,modifiedSinceLastSubmit:!1,name:i,touched:!1,valid:!0,validateFields:r&&r.validateFields,validators:{},validating:!1,visited:!1});function a(){o?b(i):(V(),b())}var u=!1,o=r&&r.silent;return r&&(u=!(!r.getValidator||!r.getValidator()),r.getValidator&&(N.fields[i].validators[n]=r.getValidator),void 0!==r.initialValue&&void 0===A(N.formState.values,i)&&(N.formState.initialValues=k(N.formState.initialValues||{},i,r.initialValue),N.formState.values=k(N.formState.values,i,r.initialValue),m(void 0,a)),void 0!==r.defaultValue&&void 0===r.initialValue&&void 0===A(N.formState.initialValues,i)&&(N.formState.values=k(N.formState.values,i,r.defaultValue))),u?m(void 0,a):a(),function(){var e=!1;N.fields[i]&&(e=!(!N.fields[i].validators[n]||!N.fields[i].validators[n]()),delete N.fields[i].validators[n]),delete N.fieldSubscribers[i].entries[n];var t=!Object.keys(N.fieldSubscribers[i].entries).length;t&&(delete N.fieldSubscribers[i],delete N.fields[i],e&&(N.formState.errors=k(N.formState.errors,i,void 0)||{}),s&&(N.formState.values=k(N.formState.values,i,void 0,!0)||{})),o||(e?m(void 0,function(){V(),b()}):t&&V())}},reset:function(e){if(void 0===e&&(e=N.formState.initialValues),N.formState.submitting)throw Error("Cannot reset() in onSubmit(), use setTimeout(form.reset)");N.formState.submitFailed=!1,N.formState.submitSucceeded=!1,delete N.formState.submitError,delete N.formState.submitErrors,delete N.formState.lastSubmittedValues,j.initialize(e||{})},resetFieldState:function(e){N.fields[e]=R({},N.fields[e],{active:!1,lastFieldState:void 0,modified:!1,touched:!1,valid:!0,validating:!1,visited:!1}),m(void 0,function(){b(),V()})},restart:function(t){void 0===t&&(t=N.formState.initialValues),j.batch(function(){for(var e in N.fields)j.resetFieldState(e),N.fields[e]=R({},N.fields[e],{active:!1,lastFieldState:void 0,modified:!1,modifiedSinceLastSubmit:!1,touched:!1,valid:!0,validating:!1,visited:!1});j.reset(t)})},resumeValidation:function(){p=!1,E&&m(void 0,function(){b(),V()}),E=!1},setConfig:function(e,t){switch(e){case"debug":0;break;case"destroyOnUnregister":s=t;break;case"initialValues":j.initialize(t);break;case"keepDirtyOnReinitialize":u=t;break;case"mutators":(o=t)?(Object.keys(n).forEach(function(e){e in t||delete n[e]}),Object.keys(t).forEach(function(e){n[e]=i(e)})):Object.keys(n).forEach(function(e){delete n[e]});break;case"onSubmit":d=t;break;case"validate":g=t,m(void 0,function(){b(),V()});break;case"validateOnBlur":a=t;break;default:throw new Error("Unrecognised option "+e)}},submit:function(){var t=N.formState;if(!t.submitting){if(delete t.submitErrors,delete t.submitError,t.lastSubmittedValues=R({},t.values),N.formState.error||U(N.formState.errors))return c(),N.formState.submitFailed=!0,V(),void b();var e=Object.keys(O);if(e.length)Promise.all(e.map(function(e){return O[Number(e)]})).then(j.submit,console.error);else if(!Object.keys(N.fields).some(function(e){return N.fields[e].beforeSubmit&&!1===N.fields[e].beforeSubmit()})){var i,r=!1,n=function(e){return t.submitting=!1,e&&U(e)?(t.submitFailed=!0,t.submitSucceeded=!1,t.submitErrors=e,t.submitError=e[w],c()):(t.submitFailed=!1,t.submitSucceeded=!0,Object.keys(N.fields).forEach(function(e){return N.fields[e].afterSubmit&&N.fields[e].afterSubmit()})),V(),b(),r=!0,i&&i(e),e};t.submitting=!0,t.submitFailed=!1,t.submitSucceeded=!1,t.lastSubmittedValues=R({},t.values),Object.keys(N.fields).forEach(function(e){return N.fields[e].modifiedSinceLastSubmit=!1});var a=d(t.values,j,n);if(!r){if(a&&C(a))return V(),b(),a.then(n,function(e){throw n(),e});if(3<=d.length)return V(),b(),new Promise(function(e){i=e});n(a)}}}},subscribe:function(e,t){if(!e)throw new Error("No callback given.");if(!t)throw new Error("No subscription provided. What values do you want to listen to?");var i=z(e),r=N.subscribers,n=r.index++;r.entries[n]={subscriber:i,subscription:t,notified:!1};var a=v();return B(i,t,a,a,q,!0),function(){delete r.entries[n]}}};return j},e.fieldSubscriptionItems=a,e.formSubscriptionItems=d,e.getIn=A,e.setIn=k,e.version="4.20.0",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self)["final-form"]={})}(this,function(e){"use strict";function R(){return(R=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}function o(e){if(null==e||!e.length)return[];if("string"!=typeof e)throw new Error("toPath() expects a string");return null==t[e]&&(t[e]=e.split(i).filter(Boolean)),t[e]}var t={},i=/[.[\]]+/,A=function(e,t){for(var i=o(t),r=e,n=0;n<i.length;n++){var a=i[n];if(null==r||"object"!=typeof r||Array.isArray(r)&&isNaN(a))return;r=r[a]}return r};function S(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0===i)return("string"===t?String:Number)(e);var r=i.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"==typeof t?t:String(t)}function h(e,t,i,r,n){if(t>=i.length)return r;var a,o=i[t];if(isNaN(o)){if(null==e){var u,s=h(void 0,t+1,i,r,n);return void 0===s?void 0:((u={})[o]=s,u)}if(Array.isArray(e))throw new Error("Cannot set a non-numeric property on an array");var d=h(e[o],t+1,i,r,n);if(void 0!==d)return R({},e,((a={})[o]=d,a));var l=Object.keys(e).length;if(void 0===e[o]&&0===l)return;if(void 0!==e[o]&&l<=1)return isNaN(i[t-1])||n?void 0:{};e[o];return function(e,t){if(null==e)return{};for(var i,r={},n=Object.keys(e),a=0;a<n.length;a++)i=n[a],0<=t.indexOf(i)||(r[i]=e[i]);return r}(e,[o].map(S))}var f=Number(o);if(null==e){var c=h(void 0,t+1,i,r,n);if(void 0===c)return;var v=[];return v[f]=c,v}if(!Array.isArray(e))throw new Error("Cannot set a numeric property on an object");var m=h(e[f],t+1,i,r,n),b=[].concat(e);if(n&&void 0===m){if(b.splice(f,1),0===b.length)return}else b[f]=m;return b}function w(e,t,i,r){if(void 0===r&&(r=!1),null==e)throw new Error("Cannot call setIn() with "+String(e)+" state");if(null==t)throw new Error("Cannot call setIn() with "+String(t)+" key");return h(e,0,o(t),i,r)}var L="FINAL_FORM/form-error",x="FINAL_FORM/array-error";function I(e,t){var i=e.errors,r=e.initialValues,n=e.lastSubmittedValues,a=e.submitErrors,o=e.submitFailed,u=e.submitSucceeded,s=e.submitting,d=e.values,l=t.active,f=t.blur,c=t.change,v=t.data,m=t.focus,b=t.modified,S=t.modifiedSinceLastSubmit,h=t.name,g=t.touched,y=t.validating,p=t.visited,E=A(d,h),F=A(i,h);F&&F[x]&&(F=F[x]);var O=a&&A(a,h),V=r&&A(r,h),j=t.isEqual(V,E),k=!F&&!O;return{active:l,blur:f,change:c,data:v,dirty:!j,dirtySinceLastSubmit:!(!n||t.isEqual(A(n,h),E)),error:F,focus:m,initial:V,invalid:!k,length:Array.isArray(E)?E.length:void 0,modified:b,modifiedSinceLastSubmit:S,name:h,pristine:j,submitError:O,submitFailed:o,submitSucceeded:u,submitting:s,touched:g,valid:k,value:E,visited:p,validating:y}}var a=["active","data","dirty","dirtySinceLastSubmit","error","initial","invalid","length","modified","modifiedSinceLastSubmit","pristine","submitError","submitFailed","submitSucceeded","submitting","touched","valid","value","visited","validating"],P=function(e,t){if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(var n=Object.prototype.hasOwnProperty.bind(t),a=0;a<i.length;a++){var o=i[a];if(!n(o)||e[o]!==t[o])return!1}return!0};function u(t,i,r,n,e,a){var o=!1;return e.forEach(function(e){n[e]&&(t[e]=i[e],r&&(~a.indexOf(e)?P(i[e],r[e]):i[e]===r[e])||(o=!0))}),o}function p(e,t,i,r){var n={blur:e.blur,change:e.change,focus:e.focus,name:e.name};return u(n,e,t,i,a,s)||!t||r?n:void 0}var s=["data"],d=["active","dirty","dirtyFields","dirtyFieldsSinceLastSubmit","dirtySinceLastSubmit","error","errors","hasSubmitErrors","hasValidationErrors","initialValues","invalid","modified","modifiedSinceLastSubmit","pristine","submitting","submitError","submitErrors","submitFailed","submitSucceeded","touched","valid","validating","values","visited"],l=["touched","visited"];function q(e,t,i,r){var n={};return u(n,e,t,i,d,l)||!t||r?n:void 0}function z(r){var n,a;return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return n&&t.length===n.length&&!t.some(function(e,t){return!P(n[t],e)})||(n=t,a=r.apply(void 0,t)),a}}function C(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then}function _(e,t){return e===t}var U=function i(r){return Object.keys(r).some(function(e){var t=r[e];return!t||"object"!=typeof t||t instanceof Error?void 0!==t:i(t)})};function B(e,t,i,r,n,a){var o=n(i,r,t,a);return o&&(e(o),1)}function M(e,a,o,u,s){var d=e.entries;Object.keys(d).forEach(function(e){var t,i,r,n=d[Number(e)];n&&(t=n.subscription,i=n.subscriber,r=n.notified,B(i,t,a,o,u,s||!r)&&(n.notified=!0))})}e.ARRAY_ERROR=x,e.FORM_ERROR=L,e.configOptions=["debug","initialValues","keepDirtyOnReinitialize","mutators","onSubmit","validate","validateOnBlur"],e.createForm=function(e){if(!e)throw new Error("No config specified");e.debug;var s=e.destroyOnUnregister,o=e.keepDirtyOnReinitialize,t=e.initialValues,u=e.mutators,d=e.onSubmit,E=e.validate,a=e.validateOnBlur;if(!d)throw new Error("No onSubmit function specified");function l(e,t,i){var r=i(A(e.formState.values,t));e.formState.values=w(e.formState.values,t,r)||{}}function f(e,t,i){var r,n,a;e.fields[t]&&(e.fields=R({},e.fields,((r={})[i]=R({},e.fields[t],{name:i,blur:function(){return y.blur(i)},change:function(e){return y.change(i,e)},focus:function(){return y.focus(i)},lastFieldState:void 0}),r)),delete e.fields[t],e.fieldSubscribers=R({},e.fieldSubscribers,((n={})[i]=e.fieldSubscribers[t],n)),delete e.fieldSubscribers[t],a=A(e.formState.values,t),e.formState.values=w(e.formState.values,t,void 0)||{},e.formState.values=w(e.formState.values,i,a),delete e.lastFormState)}function i(a){return function(){if(u){for(var e={formState:N.formState,fields:N.fields,fieldSubscribers:N.fieldSubscribers,lastFormState:N.lastFormState},t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];var n=u[a](i,e,{changeValue:l,getIn:A,renameField:f,resetFieldState:y.resetFieldState,setIn:w,shallowEqual:P});return N.formState=e.formState,N.fields=e.fields,N.fieldSubscribers=e.fieldSubscribers,N.lastFormState=e.lastFormState,m(void 0,function(){b(),g()}),n}}}function F(r){return Object.keys(r.validators).reduce(function(e,t){var i=r.validators[Number(t)]();return i&&e.push(i),e},[])}function c(){Object.keys(N.fields).forEach(function(e){N.fields[e].touched=!0})}function v(){var e=N.fields,r=N.formState,t=N.lastFormState,n=R({},e),i=Object.keys(n),a=!1,o=i.reduce(function(e,t){return!n[t].isEqual(A(r.values,t),A(r.initialValues||{},t))&&(a=!0,e[t]=!0),e},{}),u=i.reduce(function(e,t){var i=r.lastSubmittedValues||{};return n[t].isEqual(A(r.values,t),A(i,t))||(e[t]=!0),e},{});r.pristine=!a,r.dirtySinceLastSubmit=!(!r.lastSubmittedValues||!Object.values(u).some(function(e){return e})),r.modifiedSinceLastSubmit=!(!r.lastSubmittedValues||!Object.keys(n).some(function(e){return n[e].modifiedSinceLastSubmit})),r.valid=!(r.error||r.submitError||U(r.errors)||r.submitErrors&&U(r.submitErrors));var s,d,l,f,c,v,m,b,S,h,g,y,p,E,F,O,V=(d=(s=r).active,l=s.dirtySinceLastSubmit,f=s.modifiedSinceLastSubmit,c=s.error,v=s.errors,m=s.initialValues,b=s.pristine,S=s.submitting,h=s.submitFailed,g=s.submitSucceeded,y=s.submitError,p=s.submitErrors,E=s.valid,F=s.validating,O=s.values,{active:d,dirty:!b,dirtySinceLastSubmit:l,modifiedSinceLastSubmit:f,error:c,errors:v,hasSubmitErrors:!!(y||p&&U(p)),hasValidationErrors:!(!c&&!U(v)),invalid:!E,initialValues:m,pristine:b,submitting:S,submitFailed:h,submitSucceeded:g,submitError:y,submitErrors:p,valid:E,validating:0<F,values:O}),j=i.reduce(function(e,t){return e.modified[t]=n[t].modified,e.touched[t]=n[t].touched,e.visited[t]=n[t].visited,e},{modified:{},touched:{},visited:{}}),k=j.modified,w=j.touched,L=j.visited;return V.dirtyFields=t&&P(t.dirtyFields,o)?t.dirtyFields:o,V.dirtyFieldsSinceLastSubmit=t&&P(t.dirtyFieldsSinceLastSubmit,u)?t.dirtyFieldsSinceLastSubmit:u,V.modified=t&&P(t.modified,k)?t.modified:k,V.touched=t&&P(t.touched,w)?t.touched:w,V.visited=t&&P(t.visited,L)?t.visited:L,t&&P(t,V)?t:V}var N={subscribers:{index:0,entries:{}},fieldSubscribers:{},fields:{},formState:{dirtySinceLastSubmit:!1,modifiedSinceLastSubmit:!1,errors:{},initialValues:t&&R({},t),invalid:!1,pristine:!0,submitting:!1,submitFailed:!1,submitSucceeded:!1,valid:!0,validating:0,values:t?R({},t):{}},lastFormState:void 0},r=0,O=!1,V=!1,j=0,k={},n=u?Object.keys(u).reduce(function(e,t){return e[t]=i(t),e},{}):{},m=function(e,t){if(O)return V=!0,void t();var u,i,r,s,d,n,a,o,l,f,c,v,m,b,S,h=N.fields,g=N.formState,y=R({},h),p=Object.keys(y);E||p.some(function(e){return F(y[e]).length})?(u=!1,e&&(!(i=y[e])||(r=i.validateFields)&&(u=!0,p=r.length?r.concat(e):[e])),s={},d={},f=0<(n=[].concat((a=function(e){s=e||{}},l=[],E&&(o=E(R({},N.formState.values)),C(o)?l.push(o.then(a)):a(o)),l),p.reduce(function(e,t){return e.concat((r=h[t],n=function(e){d[t]=e},o=[],(i=F(r)).length&&(i.forEach(function(e){var t,i=e(A(N.formState.values,r.name),N.formState.values,0===e.length||3===e.length?I(N.formState,N.fields[r.name]):void 0);i&&C(i)?(r.validating=!0,t=i.then(function(e){r.validating=!1,n(e)}),o.push(t)):a=a||i}),n(a)),o));var r,n,a,o,i},[]))).length,c=++j,v=Promise.all(n).then((m=c,function(e){return delete k[m],e})),f&&(k[c]=v),(b=function(){function e(a){p.forEach(function(e){var t,i,r,n;h[e]&&(t=A(s,e),i=A(o,e),r=F(y[e]).length,n=d[e],a(e,r&&n||E&&t||(t||u?void 0:i)))})}var o=R({},u?g.errors:{},s);e(function(e,t){o=w(o,e,t)||{}}),e(function(e,t){var i,r;t&&t[x]&&(i=A(o,e),(r=[].concat(i))[x]=t[x],o=w(o,e,r))}),P(g.errors,o)||(g.errors=o),g.error=s[L]})(),t(),f&&(N.formState.validating++,t(),S=function(){N.formState.validating--,t()},v.then(function(){c<j||b()}).then(S,S))):t()},b=function(e){var t,a,o,u,i;r||(t=N.fields,a=N.fieldSubscribers,o=N.formState,u=R({},t),i=function(e){var t=u[e],i=I(o,t),r=t.lastFieldState;t.lastFieldState=i;var n=a[e];n&&M(n,i,r,p,void 0===r)},e?i(e):Object.keys(u).forEach(i))},S=!1,h=!1,g=function e(){var t,i;S?h=!0:(S=!0,r||O||(t=N.lastFormState,(i=v())!==t&&(N.lastFormState=i,M(N.subscribers,i,t,q))),S=!1,h&&(h=!1,e()))};m(void 0,function(){g()});var y={batch:function(e){r++,e(),r--,b(),g()},blur:function(e){var t=N.fields,i=N.formState,r=t[e];r&&(delete i.active,t[e]=R({},r,{active:!1,touched:!0}),a?m(e,function(){b(),g()}):(b(),g()))},change:function(e,t){var i,r=N.fields,n=N.formState;A(n.values,e)!==t&&(l(N,e,function(){return t}),(i=r[e])&&(r[e]=R({},i,{modified:!0,modifiedSinceLastSubmit:!!n.lastSubmittedValues})),a?(b(),g()):m(e,function(){b(),g()}))},get destroyOnUnregister(){return!!s},set destroyOnUnregister(e){s=e},focus:function(e){var t=N.fields[e];t&&!t.active&&(N.formState.active=e,t.active=!0,t.visited=!0,b(),g())},mutators:n,getFieldState:function(e){var t=N.fields[e];return t&&t.lastFieldState},getRegisteredFields:function(){return Object.keys(N.fields)},getState:v,initialize:function(e){var t=N.fields,i=N.formState,r=R({},t),n="function"==typeof e?e(i.values):e;o||(i.values=n);var a=o?Object.keys(r).reduce(function(e,t){return r[t].isEqual(A(i.values,t),A(i.initialValues||{},t))||(e[t]=A(i.values,t)),e},{}):{};i.initialValues=n,i.values=n,Object.keys(a).forEach(function(e){i.values=w(i.values,e,a[e])}),m(void 0,function(){b(),g()})},isValidationPaused:function(){return O},pauseValidation:function(){O=!0},registerField:function(i,e,t,r){void 0===t&&(t={}),N.fieldSubscribers[i]||(N.fieldSubscribers[i]={index:0,entries:{}});var n=N.fieldSubscribers[i].index++;N.fieldSubscribers[i].entries[n]={subscriber:z(e),subscription:t,notified:!1},N.fields[i]||(N.fields[i]={active:!1,afterSubmit:r&&r.afterSubmit,beforeSubmit:r&&r.beforeSubmit,blur:function(){return y.blur(i)},change:function(e){return y.change(i,e)},data:r&&r.data||{},focus:function(){return y.focus(i)},isEqual:r&&r.isEqual||_,lastFieldState:void 0,modified:!1,modifiedSinceLastSubmit:!1,name:i,touched:!1,valid:!0,validateFields:r&&r.validateFields,validators:{},validating:!1,visited:!1});function a(){u?b(i):(g(),b())}var o=!1,u=r&&r.silent;return r&&(o=!(!r.getValidator||!r.getValidator()),r.getValidator&&(N.fields[i].validators[n]=r.getValidator),void 0!==r.initialValue&&void 0===A(N.formState.values,i)&&(N.formState.initialValues=w(N.formState.initialValues||{},i,r.initialValue),N.formState.values=w(N.formState.values,i,r.initialValue),m(void 0,a)),void 0!==r.defaultValue&&void 0===r.initialValue&&void 0===A(N.formState.initialValues,i)&&(N.formState.values=w(N.formState.values,i,r.defaultValue))),o?m(void 0,a):a(),function(){var e=!1;N.fields[i]&&(e=!(!N.fields[i].validators[n]||!N.fields[i].validators[n]()),delete N.fields[i].validators[n]),delete N.fieldSubscribers[i].entries[n];var t=!Object.keys(N.fieldSubscribers[i].entries).length;t&&(delete N.fieldSubscribers[i],delete N.fields[i],e&&(N.formState.errors=w(N.formState.errors,i,void 0)||{}),s&&(N.formState.values=w(N.formState.values,i,void 0,!0)||{})),u||(e?m(void 0,function(){g(),b()}):t&&g())}},reset:function(e){if(void 0===e&&(e=N.formState.initialValues),N.formState.submitting)throw Error("Cannot reset() in onSubmit(), use setTimeout(form.reset)");N.formState.submitFailed=!1,N.formState.submitSucceeded=!1,delete N.formState.submitError,delete N.formState.submitErrors,delete N.formState.lastSubmittedValues,y.initialize(e||{})},resetFieldState:function(e){N.fields[e]=R({},N.fields[e],{active:!1,lastFieldState:void 0,modified:!1,touched:!1,valid:!0,validating:!1,visited:!1}),m(void 0,function(){b(),g()})},restart:function(t){void 0===t&&(t=N.formState.initialValues),y.batch(function(){for(var e in N.fields)y.resetFieldState(e),N.fields[e]=R({},N.fields[e],{active:!1,lastFieldState:void 0,modified:!1,modifiedSinceLastSubmit:!1,touched:!1,valid:!0,validating:!1,visited:!1});y.reset(t)})},resumeValidation:function(){O=!1,V&&m(void 0,function(){b(),g()}),V=!1},setConfig:function(e,t){switch(e){case"debug":0;break;case"destroyOnUnregister":s=t;break;case"initialValues":y.initialize(t);break;case"keepDirtyOnReinitialize":o=t;break;case"mutators":(u=t)?(Object.keys(n).forEach(function(e){e in t||delete n[e]}),Object.keys(t).forEach(function(e){n[e]=i(e)})):Object.keys(n).forEach(function(e){delete n[e]});break;case"onSubmit":d=t;break;case"validate":E=t,m(void 0,function(){b(),g()});break;case"validateOnBlur":a=t;break;default:throw new Error("Unrecognised option "+e)}},submit:function(){var t=N.formState;if(!t.submitting){if(delete t.submitErrors,delete t.submitError,t.lastSubmittedValues=R({},t.values),N.formState.error||U(N.formState.errors))return c(),N.formState.submitFailed=!0,g(),void b();var e=Object.keys(k);if(e.length)Promise.all(e.map(function(e){return k[Number(e)]})).then(y.submit,console.error);else if(!Object.keys(N.fields).some(function(e){return N.fields[e].beforeSubmit&&!1===N.fields[e].beforeSubmit()})){var i,r=!1,n=function(e){return t.submitting=!1,e&&U(e)?(t.submitFailed=!0,t.submitSucceeded=!1,t.submitErrors=e,t.submitError=e[L],c()):(t.submitFailed=!1,t.submitSucceeded=!0,Object.keys(N.fields).forEach(function(e){return N.fields[e].afterSubmit&&N.fields[e].afterSubmit()})),g(),b(),r=!0,i&&i(e),e};t.submitting=!0,t.submitFailed=!1,t.submitSucceeded=!1,t.lastSubmittedValues=R({},t.values),Object.keys(N.fields).forEach(function(e){return N.fields[e].modifiedSinceLastSubmit=!1});var a=d(t.values,y,n);if(!r){if(a&&C(a))return g(),b(),a.then(n,function(e){throw n(),e});if(3<=d.length)return g(),b(),new Promise(function(e){i=e});n(a)}}}},subscribe:function(e,t){if(!e)throw new Error("No callback given.");if(!t)throw new Error("No subscription provided. What values do you want to listen to?");var i=z(e),r=N.subscribers,n=r.index++;r.entries[n]={subscriber:i,subscription:t,notified:!1};var a=v();return B(i,t,a,a,q,!0),function(){delete r.entries[n]}}};return y},e.fieldSubscriptionItems=a,e.formSubscriptionItems=d,e.getIn=A,e.setIn=w,e.version="4.20.1",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=final-form.umd.min.js.map |
{ | ||
"name": "final-form", | ||
"version": "4.20.0", | ||
"version": "4.20.1", | ||
"description": "🏁 Framework agnostic, high performance, subscription-based form state management", | ||
@@ -108,5 +108,4 @@ "main": "dist/final-form.cjs.js", | ||
"dependencies": { | ||
"@babel/runtime": "^7.10.0", | ||
"@scarf/scarf": "^1.0.5" | ||
"@babel/runtime": "^7.10.0" | ||
} | ||
} |
@@ -31,2 +31,10 @@ [<img src="form-nerd-logo.png" align="left"/>](https://formnerd.co/final-form-readme) **You build great forms, but do you know HOW users use your forms? [Find out with Form Nerd!](https://formnerd.co/final-form-readme) Professional analytics from the creator of Final Form.** | ||
[<img align="right" src="docs/sencha.svg" height="100"/>](https://www.sencha.com/) | ||
### Final Form is sponsored by [Sencha](https://www.sencha.com/). | ||
Comprehensive JS framework and UI components for building enterprise-grade web apps. | ||
--- | ||
## 💬 [Give Feedback on Final Form](https://goo.gl/forms/dxdfxKNy64DLb99z2) 💬 | ||
@@ -33,0 +41,0 @@ |
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
179034
1
58
- Removed@scarf/scarf@^1.0.5
- Removed@scarf/scarf@1.4.0(transitive)