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.17.0 to 4.18.0

34

dist/final-form.cjs.js

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

var version = "4.17.0";
var version = "4.18.0";

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

renameField: renameField,
resetFieldState: api.resetFieldState,
setIn: setIn,

@@ -717,3 +718,3 @@ shallowEqual: shallowEqual

if (!shallowEqual(fieldState, lastFieldState) || field.forceUpdate) {
if (!shallowEqual(fieldState, lastFieldState)) {
// **************************************************************

@@ -746,6 +747,4 @@ // Curious about why a field is getting notified? Uncomment this.

if (fieldSubscriber) {
notify(fieldSubscriber, fieldState, lastFieldState, filterFieldState, field.forceUpdate);
notify(fieldSubscriber, fieldState, lastFieldState, filterFieldState, lastFieldState === undefined);
}
field.forceUpdate = false;
}

@@ -1031,3 +1030,2 @@ });

},
forceUpdate: false,
isEqual: fieldConfig && fieldConfig.isEqual || tripleEquals,

@@ -1080,6 +1078,3 @@ lastFieldState: undefined,

return function () {
if (state.fields[name]) {
delete state.fields[name].validators[index];
}
delete state.fields[name].validators[index];
delete state.fieldSubscribers[name].entries[index];

@@ -1119,2 +1114,21 @@

},
/**
* Resets all field flags (e.g. touched, visited, etc.) to their initial state
*/
resetFieldState: function resetFieldState(name) {
state.fields[name] = _extends({}, state.fields[name], {
active: false,
lastFieldState: undefined,
modified: false,
touched: false,
valid: true,
validating: false,
visited: false
});
runValidation(undefined, function () {
notifyFieldListeners();
notifyFormListeners();
});
},
resumeValidation: function resumeValidation() {

@@ -1121,0 +1135,0 @@ validationPaused = false;

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

var version = "4.17.0";
var version = "4.18.0";

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

renameField: renameField,
resetFieldState: api.resetFieldState,
setIn: setIn,

@@ -711,3 +712,3 @@ shallowEqual: shallowEqual

if (!shallowEqual(fieldState, lastFieldState) || field.forceUpdate) {
if (!shallowEqual(fieldState, lastFieldState)) {
// **************************************************************

@@ -740,6 +741,4 @@ // Curious about why a field is getting notified? Uncomment this.

if (fieldSubscriber) {
notify(fieldSubscriber, fieldState, lastFieldState, filterFieldState, field.forceUpdate);
notify(fieldSubscriber, fieldState, lastFieldState, filterFieldState, lastFieldState === undefined);
}
field.forceUpdate = false;
}

@@ -1025,3 +1024,2 @@ });

},
forceUpdate: false,
isEqual: fieldConfig && fieldConfig.isEqual || tripleEquals,

@@ -1074,6 +1072,3 @@ lastFieldState: undefined,

return function () {
if (state.fields[name]) {
delete state.fields[name].validators[index];
}
delete state.fields[name].validators[index];
delete state.fieldSubscribers[name].entries[index];

@@ -1113,2 +1108,21 @@

},
/**
* Resets all field flags (e.g. touched, visited, etc.) to their initial state
*/
resetFieldState: function resetFieldState(name) {
state.fields[name] = _extends({}, state.fields[name], {
active: false,
lastFieldState: undefined,
modified: false,
touched: false,
valid: true,
validating: false,
visited: false
});
runValidation(undefined, function () {
notifyFieldListeners();
notifyFormListeners();
});
},
resumeValidation: function resumeValidation() {

@@ -1115,0 +1129,0 @@ validationPaused = false;

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

var version = "4.17.0";
var version = "4.18.0";

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

renameField: renameField,
resetFieldState: api.resetFieldState,
setIn: setIn,

@@ -747,3 +748,3 @@ shallowEqual: shallowEqual

if (!shallowEqual(fieldState, lastFieldState) || field.forceUpdate) {
if (!shallowEqual(fieldState, lastFieldState)) {
// **************************************************************

@@ -776,6 +777,4 @@ // Curious about why a field is getting notified? Uncomment this.

if (fieldSubscriber) {
notify(fieldSubscriber, fieldState, lastFieldState, filterFieldState, field.forceUpdate);
notify(fieldSubscriber, fieldState, lastFieldState, filterFieldState, lastFieldState === undefined);
}
field.forceUpdate = false;
}

@@ -1061,3 +1060,2 @@ });

},
forceUpdate: false,
isEqual: fieldConfig && fieldConfig.isEqual || tripleEquals,

@@ -1110,6 +1108,3 @@ lastFieldState: undefined,

return function () {
if (state.fields[name]) {
delete state.fields[name].validators[index];
}
delete state.fields[name].validators[index];
delete state.fieldSubscribers[name].entries[index];

@@ -1149,2 +1144,21 @@

},
/**
* Resets all field flags (e.g. touched, visited, etc.) to their initial state
*/
resetFieldState: function resetFieldState(name) {
state.fields[name] = _extends({}, state.fields[name], {
active: false,
lastFieldState: undefined,
modified: false,
touched: false,
valid: true,
validating: false,
visited: false
});
runValidation(undefined, function () {
notifyFieldListeners();
notifyFormListeners();
});
},
resumeValidation: function resumeValidation() {

@@ -1151,0 +1165,0 @@ validationPaused = false;

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

@@ -154,3 +154,2 @@ export type Subscription = { [key: string]: boolean }

focus: () => void
forceUpdate: boolean
isEqual: IsEqual

@@ -206,2 +205,3 @@ lastFieldState?: FieldState<FieldValue>

reset: (initialValues?: object) => void
resetFieldState: (name: string) => void
resumeValidation: () => void

@@ -246,2 +246,3 @@ setConfig: (name: ConfigKey, value: any) => void

renameField: RenameField<FormValues>
resetFieldState: (name: string) => void
setIn: SetIn

@@ -248,0 +249,0 @@ shallowEqual: IsEqual

{
"name": "final-form",
"version": "4.17.0",
"version": "4.18.0",
"description": "🏁 Framework agnostic, high performance, subscription-based form state management",

@@ -95,7 +95,7 @@ "main": "dist/final-form.cjs.js",

"path": "dist/final-form.es.js",
"maxSize": "8.50kB"
"maxSize": "8.60kB"
},
{
"path": "dist/final-form.cjs.js",
"maxSize": "8.60kB"
"maxSize": "8.70kB"
}

@@ -102,0 +102,0 @@ ],

@@ -269,3 +269,2 @@ # 🏁 Final Form

- [`focus: () => void`](#focus---void-1)
- [`forceUpdate: boolean`](#forceupdate-boolean)
- [`isEqual: (a: any, b: any) => boolean`](#isequal-a-any-b-any--boolean)

@@ -307,2 +306,3 @@ - [`modified: boolean`](#modified-boolean)

- [`Tools.renameField: (state: MutableState, from: string, to: string) => any) => void`](#toolsrenamefield-state-mutablestate-from-string-to-string--any--void)
- [`Tools.resetFieldState: (name: string) => void`](#toolsresetfieldstate-name-string--void)
- [`Tools.setIn: (state: Object, key: string, value: any) => Object`](#toolssetin-state-object-key-string-value-any--object)

@@ -847,2 +847,6 @@ - [`Tools.shallowEqual: (a: any, b: any) => boolean`](#toolsshallowequal-a-any-b-any--boolean)

#### `resetFieldState: (name: string) => void`
Resets all of a field's flags (e.g. `touched`, `visited`, etc.) to their initial state.
#### `resumeValidation: () => void`

@@ -1111,6 +1115,2 @@

#### `forceUpdate: boolean`
When set to `true`, this field's subscribers will be sent a notification even if the state has not changed.
#### `isEqual: (a: any, b: any) => boolean`

@@ -1281,2 +1281,6 @@

#### `Tools.resetFieldState: (name: string) => void`
A utility function to reset all of a field's flags (e.g. `touched`, `visited`, etc.) to their initial state. This can be useful for inserting a new field that has the same name as an existing field.
#### `Tools.setIn: (state: Object, key: string, value: any) => Object`

@@ -1283,0 +1287,0 @@

Sorry, the diff of this file is not supported yet

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