Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

final-form

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

final-form - npm Package Compare versions

Comparing version 4.9.0 to 4.9.1

4

dist/final-form.cjs.js

@@ -761,3 +761,3 @@ 'use strict';

var callDebug = function callDebug() {
return debug && process.env.NODE_ENV !== 'production' && debug(convertToExternalFormState(state.formState), Object.keys(state.fields).reduce(function (result, key) {
return debug && process.env.NODE_ENV !== 'production' && debug(calculateNextFormState(), Object.keys(state.fields).reduce(function (result, key) {
result[key] = state.fields[key];

@@ -870,3 +870,3 @@ return result;

getState: function getState() {
return convertToExternalFormState(state.formState);
return calculateNextFormState();
},

@@ -873,0 +873,0 @@ initialize: function initialize(values) {

@@ -757,3 +757,3 @@ function _extends() {

var callDebug = function callDebug() {
return debug && process.env.NODE_ENV !== 'production' && debug(convertToExternalFormState(state.formState), Object.keys(state.fields).reduce(function (result, key) {
return debug && process.env.NODE_ENV !== 'production' && debug(calculateNextFormState(), Object.keys(state.fields).reduce(function (result, key) {
result[key] = state.fields[key];

@@ -866,3 +866,3 @@ return result;

getState: function getState() {
return convertToExternalFormState(state.formState);
return calculateNextFormState();
},

@@ -869,0 +869,0 @@ initialize: function initialize(values) {

@@ -763,3 +763,3 @@ (function (global, factory) {

var callDebug = function callDebug() {
return debug && "development" !== 'production' && debug(convertToExternalFormState(state.formState), Object.keys(state.fields).reduce(function (result, key) {
return debug && "development" !== 'production' && debug(calculateNextFormState(), Object.keys(state.fields).reduce(function (result, key) {
result[key] = state.fields[key];

@@ -872,3 +872,3 @@ return result;

getState: function getState() {
return convertToExternalFormState(state.formState);
return calculateNextFormState();
},

@@ -875,0 +875,0 @@ initialize: function initialize(values) {

@@ -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["final-form"]={})}(this,function(e){"use strict";function V(){return(V=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)}var u=function(e){if(null==e||!e.length)return[];if("string"!=typeof e)throw new Error("toPath() expects a string");return e.split(/[.[\]]+/).filter(Boolean)},N=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},R=function(e,t,i){if(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 function e(t,i,r,n){if(i>=r.length)return n;var a=r[i];if(isNaN(a)){var u;if(null==t){var o,s=e(void 0,i+1,r,n);return void 0===s?void 0:((o={})[a]=s,o)}if(Array.isArray(t))throw new Error("Cannot set a non-numeric property on an array");var l=e(t[a],i+1,r,n),c=Object.keys(t).length;if(void 0===l){if(void 0===t[a]&&0===c)return;if(void 0!==t[a]&&c<=1)return isNaN(r[i-1])?void 0:{}}return V({},t,((u={})[a]=l,u))}var f=Number(a);if(null==t){var d=e(void 0,i+1,r,n);if(void 0===d)return;var v=[];return v[f]=d,v}if(!Array.isArray(t))throw new Error("Cannot set a numeric property on an object");var b=e(t[f],i+1,r,n),m=t.concat();return m[f]=b,m}(e,0,u(t),i)},A="FINAL_FORM/form-error",I="FINAL_FORM/array-error",x=function(e,t){var i=e.errors,r=e.initialValues,n=e.lastSubmittedValues,a=e.submitErrors,u=e.submitFailed,o=e.submitSucceeded,s=e.values,l=t.active,c=t.blur,f=t.change,d=t.data,v=t.focus,b=t.name,m=t.touched,S=t.visited,h=N(s,b),y=N(i,b);y&&y[I]&&(y=y[I]);var g=a&&N(a,b),p=r&&N(r,b),E=t.isEqual(p,h),F=!y&&!g;return{active:l,blur:c,change:f,data:d,dirty:!E,dirtySinceLastSubmit:!(!n||t.isEqual(N(n,b),h)),error:y,focus:v,initial:p,invalid:!F,length:Array.isArray(h)?h.length:void 0,name:b,pristine:E,submitError:g,submitFailed:u,submitSucceeded:o,touched:m,valid:F,value:h,visited:S}},a=["active","data","dirty","dirtySinceLastSubmit","error","initial","invalid","length","pristine","submitError","submitFailed","submitSucceeded","touched","valid","value","visited"],L=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)?L(i[e],r[e]):i[e]===r[e])||(u=!0))}),u}var s=["data"],q=function(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},l=["active","dirty","dirtyFields","dirtySinceLastSubmit","error","errors","hasSubmitErrors","hasValidationErrors","initialValues","invalid","pristine","submitting","submitError","submitErrors","submitFailed","submitSucceeded","touched","valid","validating","values","visited"],c=["touched","visited"],P=function(e,t,i,r){var n={};return o(n,e,t,i,l,c)||!t||r?n:void 0},z=function(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!L(n[t],e)})||(n=t,a=r.apply(void 0,t)),a}},_=function(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then},C=function(e,t){return e===t},B=function i(r){return Object.keys(r).some(function(e){var t=r[e];return t&&"object"==typeof t?i(t):void 0!==t})},M=function(e){var t=e.active,i=e.dirtySinceLastSubmit,r=e.error,n=e.errors,a=e.initialValues,u=e.pristine,o=e.submitting,s=e.submitFailed,l=e.submitSucceeded,c=e.submitError,f=e.submitErrors,d=e.valid,v=e.validating,b=e.values;return{active:t,dirty:!u,dirtySinceLastSubmit:i,error:r,errors:n,hasSubmitErrors:!!(c||f&&B(f)),hasValidationErrors:!(!r&&!B(n)),invalid:!d,initialValues:a,pristine:u,submitting:o,submitFailed:s,submitSucceeded:l,submitError:c,submitErrors:f,valid:d,validating:0<v,values:b}};function D(e,t,i,r,n,a){void 0===a&&(a=!1);var u=n(i,r,t,a);u&&e(u)}function U(e,r,n,a){var u=e.entries;Object.keys(u).forEach(function(e){var t=u[Number(e)],i=t.subscription;D(t.subscriber,i,r,n,a)})}e.createForm=function(e){if(!e)throw new Error("No config specified");e.debug;var o=e.destroyOnUnregister,a=e.keepDirtyOnReinitialize,t=e.initialValues,u=e.mutators,s=e.onSubmit,v=e.validate,n=e.validateOnBlur;if(!s)throw new Error("No onSubmit function specified");var b={subscribers:{index:0,entries:{}},fieldSubscribers:{},fields:{},formState:{dirtySinceLastSubmit:!1,errors:{},initialValues:t&&V({},t),invalid:!1,pristine:!0,submitting:!1,submitFailed:!1,submitSucceeded:!1,valid:!0,validating:0,values:t?V({},t):{}},lastFormState:void 0},r=!1,m=!1,S=!1,h=0,y={},g=function(t){return function(e){return delete y[t],e}},l=function(e,t,i){var r=i(N(e.formState.values,t));e.formState.values=R(e.formState.values,t,r)||{}},i=function(a){return function(){if(u){for(var e={formState:b.formState,fields:b.fields},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:N,setIn:R,shallowEqual:L});return b.formState=e.formState,b.fields=e.fields,f(void 0,function(){d(),w()}),n}}},c=u&&Object.keys(u).reduce(function(e,t){return e[t]=i(t),e},{})||{},p=function(r){return Object.keys(r.validators).reduce(function(e,t){var i=r.validators[Number(t)]();return i&&e.push(i),e},[])},f=function(e,t){if(m)return S=!0,void(t&&t());var s=b.fields,i=b.formState,r=Object.keys(s);if(v||r.some(function(e){return p(s[e]).length})){var o=!1;if(e){var n=s[e];if(n){var a=n.validateFields;a&&(o=!0,r=a.length?a.concat(e):[e])}}var l={},c={},u=function(e){var t=[];if(v){var i=v(V({},b.formState.values));if(_(i)){var r=h++,n=i.then(e).then(g(r));t.push(n),y[r]=n}else e(i)}return t}(function(e){l=e||{}}).concat(r.reduce(function(e,t){return e.concat((n=s[t],a=function(e){c[t]=e},o=[],(i=p(n)).length&&(i.forEach(function(e){var t=e(N(b.formState.values,n.name),b.formState.values);if(t&&_(t)){var i=h++,r=t.then(a).then(g(i));o.push(r),y[i]=r}else u||(u=t)}),a(u)),o));var n,a,u,o,i},[])),f=function(){var u=V({},o?i.errors:{},l),e=function(a){r.forEach(function(e){if(s[e]){var t=N(l,e),i=N(u,e),r=p(s[e]).length,n=c[e];a(e,r&&n||v&&t||(t||o?void 0:i))}})};e(function(e,t){u=R(u,e,t)||{}}),e(function(e,t){if(t&&t[I]){var i=N(u,e).concat();i[I]=t[I],u=R(u,e,i)}}),L(i.errors,u)||(i.errors=u),i.error=l[A]};if(f(),u.length){b.formState.validating++,t&&t();var d=function(){b.formState.validating--,f(),t&&t()};Promise.all(u).then(d,d)}else t&&t()}else t&&t()},d=function(e){if(!r&&!m){var n=b.fields,a=b.fieldSubscribers,u=b.formState;Object.keys(n).forEach(function(e){var t=n[e],i=x(u,t),r=t.lastFieldState;L(i,r)||(t.lastFieldState=i,U(a[e],i,r,q))})}},E=function(){Object.keys(b.fields).forEach(function(e){b.fields[e].touched=!0})},F=function(){var i=b.fields,r=b.formState,e=b.lastFormState,t=Object.keys(i),n=!1,a=t.reduce(function(e,t){return!i[t].isEqual(N(r.values,t),N(r.initialValues||{},t))&&(n=!0,e[t]=!0),e},{});r.pristine=!n,r.dirtySinceLastSubmit=!(!r.lastSubmittedValues||t.every(function(e){var t=r.lastSubmittedValues||{};return i[e].isEqual(N(r.values,e),N(t,e))})),r.valid=!(r.error||r.submitError||B(r.errors)||r.submitErrors&&B(r.submitErrors));var u=M(r),o=t.reduce(function(e,t){return e.touched[t]=i[t].touched,e.visited[t]=i[t].visited,e},{touched:{},visited:{}}),s=o.touched,l=o.visited;return u.dirtyFields=e&&L(e.dirtyFields,a)?e.dirtyFields:a,u.touched=e&&L(e.touched,s)?e.touched:s,u.visited=e&&L(e.visited,l)?e.visited:l,e&&L(e,u)?e:u},O=!1,k=!1,w=function e(){if(O)k=!0;else{if(O=!0,!r&&!m){var t=b.lastFormState,i=F();i!==t&&(b.lastFormState=i,U(b.subscribers,i,t,P))}O=!1,k&&(k=!1,e())}};f();var j={batch:function(e){r=!0,e(),r=!1,d(),w()},blur:function(e){var t=b.fields,i=b.formState,r=t[e];r&&(delete i.active,t[e]=V({},r,{active:!1,touched:!0}),n?f(e,function(){d(),w()}):(d(),w()))},change:function(e,t){var i=b.formState;N(i.values,e)!==t&&(l(b,e,function(){return t}),n?(d(),w()):f(e,function(){d(),w()}))},focus:function(e){var t=b.fields[e];t&&!t.active&&(b.formState.active=e,t.active=!0,t.visited=!0,d(),w())},mutators:c,getFieldState:function(e){var t=b.fields[e];return t&&t.lastFieldState},getRegisteredFields:function(){return Object.keys(b.fields)},getState:function(){return M(b.formState)},initialize:function(i){var r=b.fields,n=b.formState;a||(n.values=i),Object.keys(r).forEach(function(e){var t=r[e];t.touched=!1,t.visited=!1,a&&r[e].isEqual(N(n.values,e),N(n.initialValues||{},e))&&(n.values=R(n.values,e,N(i,e)))}),n.initialValues=i,f(void 0,function(){d(),w()})},isValidationPaused:function(){return m},pauseValidation:function(){m=!0},registerField:function(t,i,r,e){void 0===r&&(r={}),b.fieldSubscribers[t]||(b.fieldSubscribers[t]={index:0,entries:{}});var n=b.fieldSubscribers[t].index++;if(b.fieldSubscribers[t].entries[n]={subscriber:z(i),subscription:r},!b.fields[t]){var a=b.formState.initialValues?N(b.formState.initialValues,t):void 0;b.fields[t]={active:!1,blur:function(){return j.blur(t)},change:function(e){return j.change(t,e)},data:{},focus:function(){return j.focus(t)},initial:a,isEqual:e&&e.isEqual||C,lastFieldState:void 0,name:t,touched:!1,valid:!0,validateFields:e&&e.validateFields,validators:{},visited:!1}}e&&e.getValidator&&(b.fields[t].validators[n]=e.getValidator);var u=!1;return f(void 0,function(){var e;w(),u||(e=x(b.formState,b.fields[t]),D(i,r,e,void 0,q,!0),b.fields[t].lastFieldState=e,u=!0),d()}),function(){delete b.fields[t].validators[n],delete b.fieldSubscribers[t].entries[n],Object.keys(b.fieldSubscribers[t].entries).length||(delete b.fieldSubscribers[t],delete b.fields[t],b.formState.errors=R(b.formState.errors,t,void 0)||{},o&&(b.formState.values=R(b.formState.values,t,void 0)||{})),f(void 0,function(){d(),w()})}},reset:function(e){void 0===e&&(e=b.formState.initialValues),b.formState.submitFailed=!1,b.formState.submitSucceeded=!1,delete b.formState.submitError,delete b.formState.submitErrors,delete b.formState.lastSubmittedValues,j.initialize(e||{})},resumeValidation:function(){m=!1,S&&f(void 0,function(){d(),w()}),S=!1},setConfig:function(e,t){switch(e){case"debug":break;case"destroyOnUnregister":o=t;break;case"initialValues":j.initialize(t);break;case"keepDirtyOnReinitialize":a=t;break;case"mutators":(u=t)?(Object.keys(c).forEach(function(e){e in t||delete c[e]}),Object.keys(t).forEach(function(e){c[e]=i(e)})):Object.keys(c).forEach(function(e){delete c[e]});break;case"onSubmit":s=t;break;case"validate":v=t,f(void 0,function(){d(),w()});break;case"validateOnBlur":n=t;break;default:throw new Error("Unrecognised option "+e)}},submit:function(){var t=b.formState;if(b.formState.error||B(b.formState.errors))return E(),b.formState.submitFailed=!0,w(),void d();var e=Object.keys(y);if(e.length)Promise.all(e.reduce(function(e,t){return e.push(y[Number(t)]),e},[])).then(j.submit,j.submit);else{var i,r=!1,n=function(e){return t.submitting=!1,e&&B(e)?(t.submitFailed=!0,t.submitSucceeded=!1,t.submitErrors=e,t.submitError=e[A],E()):(delete t.submitErrors,delete t.submitError,t.submitFailed=!1,t.submitSucceeded=!0),w(),d(),r=!0,i&&i(e),e};if(t.submitting=!0,t.submitFailed=!1,t.submitSucceeded=!1,t.lastSubmittedValues=V({},t.values),3===s.length){if(s(t.values,j,n),!r)return w(),new Promise(function(e){i=e})}else{var a=s(t.values,j);if(a&&_(a))return w(),a.then(n,n);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=b.subscribers,n=b.lastFormState,a=r.index++;r.entries[a]={subscriber:i,subscription:t};var u=F();return u!==n&&(b.lastFormState=u),D(i,t,u,u,P,!0),function(){delete r.entries[a]}}};return j},e.configOptions=["debug","initialValues","keepDirtyOnReinitialize","mutators","onSubmit","validate","validateOnBlur"],e.version="4.8.1",e.ARRAY_ERROR=I,e.FORM_ERROR=A,e.formSubscriptionItems=l,e.fieldSubscriptionItems=a,e.getIn=N,e.setIn=R,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["final-form"]={})}(this,function(e){"use strict";function V(){return(V=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)}var u=function(e){if(null==e||!e.length)return[];if("string"!=typeof e)throw new Error("toPath() expects a string");return e.split(/[.[\]]+/).filter(Boolean)},N=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},R=function(e,t,i){if(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 function e(t,i,r,n){if(i>=r.length)return n;var a=r[i];if(isNaN(a)){var u;if(null==t){var o,s=e(void 0,i+1,r,n);return void 0===s?void 0:((o={})[a]=s,o)}if(Array.isArray(t))throw new Error("Cannot set a non-numeric property on an array");var l=e(t[a],i+1,r,n),c=Object.keys(t).length;if(void 0===l){if(void 0===t[a]&&0===c)return;if(void 0!==t[a]&&c<=1)return isNaN(r[i-1])?void 0:{}}return V({},t,((u={})[a]=l,u))}var f=Number(a);if(null==t){var d=e(void 0,i+1,r,n);if(void 0===d)return;var v=[];return v[f]=d,v}if(!Array.isArray(t))throw new Error("Cannot set a numeric property on an object");var b=e(t[f],i+1,r,n),m=t.concat();return m[f]=b,m}(e,0,u(t),i)},A="FINAL_FORM/form-error",I="FINAL_FORM/array-error",x=function(e,t){var i=e.errors,r=e.initialValues,n=e.lastSubmittedValues,a=e.submitErrors,u=e.submitFailed,o=e.submitSucceeded,s=e.values,l=t.active,c=t.blur,f=t.change,d=t.data,v=t.focus,b=t.name,m=t.touched,S=t.visited,h=N(s,b),y=N(i,b);y&&y[I]&&(y=y[I]);var g=a&&N(a,b),p=r&&N(r,b),E=t.isEqual(p,h),F=!y&&!g;return{active:l,blur:c,change:f,data:d,dirty:!E,dirtySinceLastSubmit:!(!n||t.isEqual(N(n,b),h)),error:y,focus:v,initial:p,invalid:!F,length:Array.isArray(h)?h.length:void 0,name:b,pristine:E,submitError:g,submitFailed:u,submitSucceeded:o,touched:m,valid:F,value:h,visited:S}},a=["active","data","dirty","dirtySinceLastSubmit","error","initial","invalid","length","pristine","submitError","submitFailed","submitSucceeded","touched","valid","value","visited"],L=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)?L(i[e],r[e]):i[e]===r[e])||(u=!0))}),u}var s=["data"],q=function(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},l=["active","dirty","dirtyFields","dirtySinceLastSubmit","error","errors","hasSubmitErrors","hasValidationErrors","initialValues","invalid","pristine","submitting","submitError","submitErrors","submitFailed","submitSucceeded","touched","valid","validating","values","visited"],c=["touched","visited"],P=function(e,t,i,r){var n={};return o(n,e,t,i,l,c)||!t||r?n:void 0},z=function(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!L(n[t],e)})||(n=t,a=r.apply(void 0,t)),a}},_=function(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then},C=function(e,t){return e===t},B=function i(r){return Object.keys(r).some(function(e){var t=r[e];return t&&"object"==typeof t?i(t):void 0!==t})};function M(e,t,i,r,n,a){void 0===a&&(a=!1);var u=n(i,r,t,a);u&&e(u)}function D(e,r,n,a){var u=e.entries;Object.keys(u).forEach(function(e){var t=u[Number(e)],i=t.subscription;M(t.subscriber,i,r,n,a)})}e.createForm=function(e){if(!e)throw new Error("No config specified");e.debug;var o=e.destroyOnUnregister,a=e.keepDirtyOnReinitialize,t=e.initialValues,u=e.mutators,s=e.onSubmit,v=e.validate,n=e.validateOnBlur;if(!s)throw new Error("No onSubmit function specified");var w={subscribers:{index:0,entries:{}},fieldSubscribers:{},fields:{},formState:{dirtySinceLastSubmit:!1,errors:{},initialValues:t&&V({},t),invalid:!1,pristine:!0,submitting:!1,submitFailed:!1,submitSucceeded:!1,valid:!0,validating:0,values:t?V({},t):{}},lastFormState:void 0},r=!1,b=!1,m=!1,S=0,h={},y=function(t){return function(e){return delete h[t],e}},l=function(e,t,i){var r=i(N(e.formState.values,t));e.formState.values=R(e.formState.values,t,r)||{}},i=function(a){return function(){if(u){for(var e={formState:w.formState,fields:w.fields},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:N,setIn:R,shallowEqual:L});return w.formState=e.formState,w.fields=e.fields,f(void 0,function(){d(),k()}),n}}},c=u&&Object.keys(u).reduce(function(e,t){return e[t]=i(t),e},{})||{},g=function(r){return Object.keys(r.validators).reduce(function(e,t){var i=r.validators[Number(t)]();return i&&e.push(i),e},[])},f=function(e,t){if(b)return m=!0,void(t&&t());var s=w.fields,i=w.formState,r=Object.keys(s);if(v||r.some(function(e){return g(s[e]).length})){var o=!1;if(e){var n=s[e];if(n){var a=n.validateFields;a&&(o=!0,r=a.length?a.concat(e):[e])}}var l={},c={},u=function(e){var t=[];if(v){var i=v(V({},w.formState.values));if(_(i)){var r=S++,n=i.then(e).then(y(r));t.push(n),h[r]=n}else e(i)}return t}(function(e){l=e||{}}).concat(r.reduce(function(e,t){return e.concat((n=s[t],a=function(e){c[t]=e},o=[],(i=g(n)).length&&(i.forEach(function(e){var t=e(N(w.formState.values,n.name),w.formState.values);if(t&&_(t)){var i=S++,r=t.then(a).then(y(i));o.push(r),h[i]=r}else u||(u=t)}),a(u)),o));var n,a,u,o,i},[])),f=function(){var u=V({},o?i.errors:{},l),e=function(a){r.forEach(function(e){if(s[e]){var t=N(l,e),i=N(u,e),r=g(s[e]).length,n=c[e];a(e,r&&n||v&&t||(t||o?void 0:i))}})};e(function(e,t){u=R(u,e,t)||{}}),e(function(e,t){if(t&&t[I]){var i=N(u,e).concat();i[I]=t[I],u=R(u,e,i)}}),L(i.errors,u)||(i.errors=u),i.error=l[A]};if(f(),u.length){w.formState.validating++,t&&t();var d=function(){w.formState.validating--,f(),t&&t()};Promise.all(u).then(d,d)}else t&&t()}else t&&t()},d=function(e){if(!r&&!b){var n=w.fields,a=w.fieldSubscribers,u=w.formState;Object.keys(n).forEach(function(e){var t=n[e],i=x(u,t),r=t.lastFieldState;L(i,r)||(t.lastFieldState=i,D(a[e],i,r,q))})}},p=function(){Object.keys(w.fields).forEach(function(e){w.fields[e].touched=!0})},E=function(){var i=w.fields,r=w.formState,e=w.lastFormState,t=Object.keys(i),n=!1,a=t.reduce(function(e,t){return!i[t].isEqual(N(r.values,t),N(r.initialValues||{},t))&&(n=!0,e[t]=!0),e},{});r.pristine=!n,r.dirtySinceLastSubmit=!(!r.lastSubmittedValues||t.every(function(e){var t=r.lastSubmittedValues||{};return i[e].isEqual(N(r.values,e),N(t,e))})),r.valid=!(r.error||r.submitError||B(r.errors)||r.submitErrors&&B(r.submitErrors));var u,o,s,l,c,f,d,v,b,m,S,h,y,g,p,E=(o=(u=r).active,s=u.dirtySinceLastSubmit,l=u.error,c=u.errors,f=u.initialValues,d=u.pristine,v=u.submitting,b=u.submitFailed,m=u.submitSucceeded,S=u.submitError,h=u.submitErrors,y=u.valid,g=u.validating,p=u.values,{active:o,dirty:!d,dirtySinceLastSubmit:s,error:l,errors:c,hasSubmitErrors:!!(S||h&&B(h)),hasValidationErrors:!(!l&&!B(c)),invalid:!y,initialValues:f,pristine:d,submitting:v,submitFailed:b,submitSucceeded:m,submitError:S,submitErrors:h,valid:y,validating:0<g,values:p}),F=t.reduce(function(e,t){return e.touched[t]=i[t].touched,e.visited[t]=i[t].visited,e},{touched:{},visited:{}}),O=F.touched,k=F.visited;return E.dirtyFields=e&&L(e.dirtyFields,a)?e.dirtyFields:a,E.touched=e&&L(e.touched,O)?e.touched:O,E.visited=e&&L(e.visited,k)?e.visited:k,e&&L(e,E)?e:E},F=!1,O=!1,k=function e(){if(F)O=!0;else{if(F=!0,!r&&!b){var t=w.lastFormState,i=E();i!==t&&(w.lastFormState=i,D(w.subscribers,i,t,P))}F=!1,O&&(O=!1,e())}};f();var j={batch:function(e){r=!0,e(),r=!1,d(),k()},blur:function(e){var t=w.fields,i=w.formState,r=t[e];r&&(delete i.active,t[e]=V({},r,{active:!1,touched:!0}),n?f(e,function(){d(),k()}):(d(),k()))},change:function(e,t){var i=w.formState;N(i.values,e)!==t&&(l(w,e,function(){return t}),n?(d(),k()):f(e,function(){d(),k()}))},focus:function(e){var t=w.fields[e];t&&!t.active&&(w.formState.active=e,t.active=!0,t.visited=!0,d(),k())},mutators:c,getFieldState:function(e){var t=w.fields[e];return t&&t.lastFieldState},getRegisteredFields:function(){return Object.keys(w.fields)},getState:function(){return E()},initialize:function(i){var r=w.fields,n=w.formState;a||(n.values=i),Object.keys(r).forEach(function(e){var t=r[e];t.touched=!1,t.visited=!1,a&&r[e].isEqual(N(n.values,e),N(n.initialValues||{},e))&&(n.values=R(n.values,e,N(i,e)))}),n.initialValues=i,f(void 0,function(){d(),k()})},isValidationPaused:function(){return b},pauseValidation:function(){b=!0},registerField:function(t,i,r,e){void 0===r&&(r={}),w.fieldSubscribers[t]||(w.fieldSubscribers[t]={index:0,entries:{}});var n=w.fieldSubscribers[t].index++;if(w.fieldSubscribers[t].entries[n]={subscriber:z(i),subscription:r},!w.fields[t]){var a=w.formState.initialValues?N(w.formState.initialValues,t):void 0;w.fields[t]={active:!1,blur:function(){return j.blur(t)},change:function(e){return j.change(t,e)},data:{},focus:function(){return j.focus(t)},initial:a,isEqual:e&&e.isEqual||C,lastFieldState:void 0,name:t,touched:!1,valid:!0,validateFields:e&&e.validateFields,validators:{},visited:!1}}e&&e.getValidator&&(w.fields[t].validators[n]=e.getValidator);var u=!1;return f(void 0,function(){var e;k(),u||(e=x(w.formState,w.fields[t]),M(i,r,e,void 0,q,!0),w.fields[t].lastFieldState=e,u=!0),d()}),function(){delete w.fields[t].validators[n],delete w.fieldSubscribers[t].entries[n],Object.keys(w.fieldSubscribers[t].entries).length||(delete w.fieldSubscribers[t],delete w.fields[t],w.formState.errors=R(w.formState.errors,t,void 0)||{},o&&(w.formState.values=R(w.formState.values,t,void 0)||{})),f(void 0,function(){d(),k()})}},reset:function(e){void 0===e&&(e=w.formState.initialValues),w.formState.submitFailed=!1,w.formState.submitSucceeded=!1,delete w.formState.submitError,delete w.formState.submitErrors,delete w.formState.lastSubmittedValues,j.initialize(e||{})},resumeValidation:function(){b=!1,m&&f(void 0,function(){d(),k()}),m=!1},setConfig:function(e,t){switch(e){case"debug":break;case"destroyOnUnregister":o=t;break;case"initialValues":j.initialize(t);break;case"keepDirtyOnReinitialize":a=t;break;case"mutators":(u=t)?(Object.keys(c).forEach(function(e){e in t||delete c[e]}),Object.keys(t).forEach(function(e){c[e]=i(e)})):Object.keys(c).forEach(function(e){delete c[e]});break;case"onSubmit":s=t;break;case"validate":v=t,f(void 0,function(){d(),k()});break;case"validateOnBlur":n=t;break;default:throw new Error("Unrecognised option "+e)}},submit:function(){var t=w.formState;if(w.formState.error||B(w.formState.errors))return p(),w.formState.submitFailed=!0,k(),void d();var e=Object.keys(h);if(e.length)Promise.all(e.reduce(function(e,t){return e.push(h[Number(t)]),e},[])).then(j.submit,j.submit);else{var i,r=!1,n=function(e){return t.submitting=!1,e&&B(e)?(t.submitFailed=!0,t.submitSucceeded=!1,t.submitErrors=e,t.submitError=e[A],p()):(delete t.submitErrors,delete t.submitError,t.submitFailed=!1,t.submitSucceeded=!0),k(),d(),r=!0,i&&i(e),e};if(t.submitting=!0,t.submitFailed=!1,t.submitSucceeded=!1,t.lastSubmittedValues=V({},t.values),3===s.length){if(s(t.values,j,n),!r)return k(),new Promise(function(e){i=e})}else{var a=s(t.values,j);if(a&&_(a))return k(),a.then(n,n);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=w.subscribers,n=w.lastFormState,a=r.index++;r.entries[a]={subscriber:i,subscription:t};var u=E();return u!==n&&(w.lastFormState=u),M(i,t,u,u,P,!0),function(){delete r.entries[a]}}};return j},e.configOptions=["debug","initialValues","keepDirtyOnReinitialize","mutators","onSubmit","validate","validateOnBlur"],e.version="4.8.1",e.ARRAY_ERROR=I,e.FORM_ERROR=A,e.formSubscriptionItems=l,e.fieldSubscriptionItems=a,e.getIn=N,e.setIn=R,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=final-form.umd.min.js.map
{
"name": "final-form",
"version": "4.9.0",
"version": "4.9.1",
"description": "🏁 Framework agnostic, high performance, subscription-based form state management",

@@ -5,0 +5,0 @@ "main": "dist/final-form.cjs.js",

@@ -17,3 +17,3 @@ # 🏁 Final Form

✅ 💥 [**4.2k gzipped**](https://bundlephobia.com/result?p=final-form) 💥
✅ 💥 [**4.3k gzipped**](https://bundlephobia.com/result?p=final-form) 💥

@@ -20,0 +20,0 @@ ---

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc