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.18.4 to 4.18.5

65

dist/final-form.cjs.js

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

var version = "4.18.4";
var version = "4.18.5";

@@ -721,3 +721,3 @@ var configOptions = ['debug', 'initialValues', 'keepDirtyOnReinitialize', 'mutators', 'onSubmit', 'validate', 'validateOnBlur'];

var notifyFieldListeners = function notifyFieldListeners() {
var notifyFieldListeners = function notifyFieldListeners(name) {
if (inBatch) {

@@ -733,3 +733,3 @@ return;

Object.keys(safeFields).forEach(function (name) {
var notifyField = function notifyField(name) {
var field = safeFields[name];

@@ -744,3 +744,9 @@ var fieldState = publishFieldState(formState, field);

}
});
};
if (name) {
notifyField(name);
} else {
Object.keys(safeFields).forEach(notifyField);
}
};

@@ -858,3 +864,5 @@

runValidation(undefined, function () {});
runValidation(undefined, function () {
notifyFormListeners();
});
var api = {

@@ -1039,3 +1047,7 @@ batch: function batch(fn) {

var haveValidator = false;
if (fieldConfig) {
haveValidator = !!(fieldConfig.getValidator && fieldConfig.getValidator());
if (fieldConfig.getValidator) {

@@ -1055,10 +1067,18 @@ state.fields[name].validators[index] = fieldConfig.getValidator;

runValidation(undefined, function () {
if (haveValidator) {
runValidation(undefined, function () {
notifyFormListeners();
notifyFieldListeners();
});
} else {
notifyFormListeners();
notifyFieldListeners();
});
notifyFieldListeners(name);
}
return function () {
// istanbul ignore next
var validatorRemoved = false; // istanbul ignore next
if (state.fields[name]) {
// state.fields[name] may have been removed by a mutator
validatorRemoved = !!(state.fields[name].validators[index] && state.fields[name].validators[index]());
delete state.fields[name].validators[index];

@@ -1068,8 +1088,12 @@ }

delete state.fieldSubscribers[name].entries[index];
var lastOne = !Object.keys(state.fieldSubscribers[name].entries).length;
if (!Object.keys(state.fieldSubscribers[name].entries).length) {
if (lastOne) {
delete state.fieldSubscribers[name];
delete state.fields[name];
state.formState.errors = setIn(state.formState.errors, name, undefined) || {};
if (validatorRemoved) {
state.formState.errors = setIn(state.formState.errors, name, undefined) || {};
}
if (destroyOnUnregister) {

@@ -1080,6 +1104,11 @@ state.formState.values = setIn(state.formState.values, name, undefined, true) || {};

runValidation(undefined, function () {
notifyFieldListeners();
if (validatorRemoved) {
runValidation(undefined, function () {
notifyFormListeners();
notifyFieldListeners();
});
} else if (lastOne) {
// values or errors may have changed
notifyFormListeners();
});
}
};

@@ -1298,4 +1327,3 @@ },

var memoized = memoize(subscriber);
var subscribers = state.subscribers,
lastFormState = state.lastFormState;
var subscribers = state.subscribers;
var index = subscribers.index++;

@@ -1308,7 +1336,2 @@ subscribers.entries[index] = {

var nextFormState = calculateNextFormState();
if (nextFormState !== lastFormState) {
state.lastFormState = nextFormState;
}
notifySubscriber(memoized, subscription, nextFormState, nextFormState, filterFormState, true);

@@ -1315,0 +1338,0 @@ return function () {

@@ -328,3 +328,3 @@ import _extends from '@babel/runtime/helpers/esm/extends';

var version = "4.18.4";
var version = "4.18.5";

@@ -715,3 +715,3 @@ var configOptions = ['debug', 'initialValues', 'keepDirtyOnReinitialize', 'mutators', 'onSubmit', 'validate', 'validateOnBlur'];

var notifyFieldListeners = function notifyFieldListeners() {
var notifyFieldListeners = function notifyFieldListeners(name) {
if (inBatch) {

@@ -727,3 +727,3 @@ return;

Object.keys(safeFields).forEach(function (name) {
var notifyField = function notifyField(name) {
var field = safeFields[name];

@@ -738,3 +738,9 @@ var fieldState = publishFieldState(formState, field);

}
});
};
if (name) {
notifyField(name);
} else {
Object.keys(safeFields).forEach(notifyField);
}
};

@@ -852,3 +858,5 @@

runValidation(undefined, function () {});
runValidation(undefined, function () {
notifyFormListeners();
});
var api = {

@@ -1033,3 +1041,7 @@ batch: function batch(fn) {

var haveValidator = false;
if (fieldConfig) {
haveValidator = !!(fieldConfig.getValidator && fieldConfig.getValidator());
if (fieldConfig.getValidator) {

@@ -1049,10 +1061,18 @@ state.fields[name].validators[index] = fieldConfig.getValidator;

runValidation(undefined, function () {
if (haveValidator) {
runValidation(undefined, function () {
notifyFormListeners();
notifyFieldListeners();
});
} else {
notifyFormListeners();
notifyFieldListeners();
});
notifyFieldListeners(name);
}
return function () {
// istanbul ignore next
var validatorRemoved = false; // istanbul ignore next
if (state.fields[name]) {
// state.fields[name] may have been removed by a mutator
validatorRemoved = !!(state.fields[name].validators[index] && state.fields[name].validators[index]());
delete state.fields[name].validators[index];

@@ -1062,8 +1082,12 @@ }

delete state.fieldSubscribers[name].entries[index];
var lastOne = !Object.keys(state.fieldSubscribers[name].entries).length;
if (!Object.keys(state.fieldSubscribers[name].entries).length) {
if (lastOne) {
delete state.fieldSubscribers[name];
delete state.fields[name];
state.formState.errors = setIn(state.formState.errors, name, undefined) || {};
if (validatorRemoved) {
state.formState.errors = setIn(state.formState.errors, name, undefined) || {};
}
if (destroyOnUnregister) {

@@ -1074,6 +1098,11 @@ state.formState.values = setIn(state.formState.values, name, undefined, true) || {};

runValidation(undefined, function () {
notifyFieldListeners();
if (validatorRemoved) {
runValidation(undefined, function () {
notifyFormListeners();
notifyFieldListeners();
});
} else if (lastOne) {
// values or errors may have changed
notifyFormListeners();
});
}
};

@@ -1292,4 +1321,3 @@ },

var memoized = memoize(subscriber);
var subscribers = state.subscribers,
lastFormState = state.lastFormState;
var subscribers = state.subscribers;
var index = subscribers.index++;

@@ -1302,7 +1330,2 @@ subscribers.entries[index] = {

var nextFormState = calculateNextFormState();
if (nextFormState !== lastFormState) {
state.lastFormState = nextFormState;
}
notifySubscriber(memoized, subscription, nextFormState, nextFormState, filterFormState, true);

@@ -1309,0 +1332,0 @@ return function () {

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

var version = "4.18.4";
var version = "4.18.5";

@@ -751,3 +751,3 @@ var configOptions = ['debug', 'initialValues', 'keepDirtyOnReinitialize', 'mutators', 'onSubmit', 'validate', 'validateOnBlur'];

var notifyFieldListeners = function notifyFieldListeners() {
var notifyFieldListeners = function notifyFieldListeners(name) {
if (inBatch) {

@@ -763,3 +763,3 @@ return;

Object.keys(safeFields).forEach(function (name) {
var notifyField = function notifyField(name) {
var field = safeFields[name];

@@ -774,3 +774,9 @@ var fieldState = publishFieldState(formState, field);

}
});
};
if (name) {
notifyField(name);
} else {
Object.keys(safeFields).forEach(notifyField);
}
};

@@ -888,3 +894,5 @@

runValidation(undefined, function () {});
runValidation(undefined, function () {
notifyFormListeners();
});
var api = {

@@ -1069,3 +1077,7 @@ batch: function batch(fn) {

var haveValidator = false;
if (fieldConfig) {
haveValidator = !!(fieldConfig.getValidator && fieldConfig.getValidator());
if (fieldConfig.getValidator) {

@@ -1085,10 +1097,18 @@ state.fields[name].validators[index] = fieldConfig.getValidator;

runValidation(undefined, function () {
if (haveValidator) {
runValidation(undefined, function () {
notifyFormListeners();
notifyFieldListeners();
});
} else {
notifyFormListeners();
notifyFieldListeners();
});
notifyFieldListeners(name);
}
return function () {
// istanbul ignore next
var validatorRemoved = false; // istanbul ignore next
if (state.fields[name]) {
// state.fields[name] may have been removed by a mutator
validatorRemoved = !!(state.fields[name].validators[index] && state.fields[name].validators[index]());
delete state.fields[name].validators[index];

@@ -1098,8 +1118,12 @@ }

delete state.fieldSubscribers[name].entries[index];
var lastOne = !Object.keys(state.fieldSubscribers[name].entries).length;
if (!Object.keys(state.fieldSubscribers[name].entries).length) {
if (lastOne) {
delete state.fieldSubscribers[name];
delete state.fields[name];
state.formState.errors = setIn(state.formState.errors, name, undefined) || {};
if (validatorRemoved) {
state.formState.errors = setIn(state.formState.errors, name, undefined) || {};
}
if (destroyOnUnregister) {

@@ -1110,6 +1134,11 @@ state.formState.values = setIn(state.formState.values, name, undefined, true) || {};

runValidation(undefined, function () {
notifyFieldListeners();
if (validatorRemoved) {
runValidation(undefined, function () {
notifyFormListeners();
notifyFieldListeners();
});
} else if (lastOne) {
// values or errors may have changed
notifyFormListeners();
});
}
};

@@ -1328,4 +1357,3 @@ },

var memoized = memoize(subscriber);
var subscribers = state.subscribers,
lastFormState = state.lastFormState;
var subscribers = state.subscribers;
var index = subscribers.index++;

@@ -1338,7 +1366,2 @@ subscribers.entries[index] = {

var nextFormState = calculateNextFormState();
if (nextFormState !== lastFormState) {
state.lastFormState = nextFormState;
}
notifySubscriber(memoized, subscription, nextFormState, nextFormState, filterFormState, true);

@@ -1345,0 +1368,0 @@ return function () {

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

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc