final-form
Advanced tools
Comparing version 4.20.7 to 4.20.8
@@ -52,2 +52,3 @@ 'use strict'; | ||
var keysCache = {}; | ||
var keysRegex = /[.[\]]+/; | ||
@@ -64,3 +65,22 @@ var toPath = function toPath(key) { | ||
if (keysCache[key] == null) { | ||
keysCache[key] = stringToPath(key); | ||
/** | ||
* The following patch fixes issue 456, introduced since v4.20.3: | ||
* | ||
* Before v4.20.3, i.e. in v4.20.2, a `key` like 'choices[]' would map to ['choices'] | ||
* (e.g. an array of choices used where 'choices[]' is name attribute of an input of type checkbox). | ||
* | ||
* Since v4.20.3, a `key` like 'choices[]' would map to ['choices', ''] which is wrong and breaks | ||
* this kind of inputs e.g. in React. | ||
* | ||
* v4.20.3 introduced an unwanted breaking change, this patch fixes it, see the issue at the link below. | ||
* | ||
* @see https://github.com/final-form/final-form/issues/456 | ||
*/ | ||
if (key.endsWith("[]")) { | ||
// v4.20.2 (a `key` like 'choices[]' should map to ['choices'], which is fine). | ||
keysCache[key] = key.split(keysRegex).filter(Boolean); | ||
} else { | ||
// v4.20.3 (a `key` like 'choices[]' maps to ['choices', ''], which breaks applications relying on inputs like `<input type="checkbox" name="choices[]" />`). | ||
keysCache[key] = stringToPath(key); | ||
} | ||
} | ||
@@ -384,3 +404,3 @@ | ||
var version = "4.20.7"; | ||
var version = "4.20.8"; | ||
@@ -1118,34 +1138,36 @@ var configOptions = ["debug", "initialValues", "keepDirtyOnReinitialize", "mutators", "onSubmit", "validate", "validateOnBlur"]; | ||
notified: false | ||
}; // create initial field state if not exists | ||
var field = state.fields[name] || { | ||
active: false, | ||
afterSubmit: fieldConfig && fieldConfig.afterSubmit, | ||
beforeSubmit: fieldConfig && fieldConfig.beforeSubmit, | ||
data: fieldConfig && fieldConfig.data || {}, | ||
isEqual: fieldConfig && fieldConfig.isEqual || tripleEquals, | ||
lastFieldState: undefined, | ||
modified: false, | ||
modifiedSinceLastSubmit: false, | ||
name: name, | ||
touched: false, | ||
valid: true, | ||
validateFields: fieldConfig && fieldConfig.validateFields, | ||
validators: {}, | ||
validating: false, | ||
visited: false | ||
}; // Mutators can create a field in order to keep the field states | ||
// We must update this field when registerField is called afterwards | ||
field.blur = field.blur || function () { | ||
return api.blur(name); | ||
}; | ||
if (!state.fields[name]) { | ||
// create initial field state | ||
state.fields[name] = { | ||
active: false, | ||
afterSubmit: fieldConfig && fieldConfig.afterSubmit, | ||
beforeSubmit: fieldConfig && fieldConfig.beforeSubmit, | ||
blur: function blur() { | ||
return api.blur(name); | ||
}, | ||
change: function change(value) { | ||
return api.change(name, value); | ||
}, | ||
data: fieldConfig && fieldConfig.data || {}, | ||
focus: function focus() { | ||
return api.focus(name); | ||
}, | ||
isEqual: fieldConfig && fieldConfig.isEqual || tripleEquals, | ||
lastFieldState: undefined, | ||
modified: false, | ||
modifiedSinceLastSubmit: false, | ||
name: name, | ||
touched: false, | ||
valid: true, | ||
validateFields: fieldConfig && fieldConfig.validateFields, | ||
validators: {}, | ||
validating: false, | ||
visited: false | ||
}; | ||
} | ||
field.change = field.change || function (value) { | ||
return api.change(name, value); | ||
}; | ||
field.focus = field.focus || function () { | ||
return api.focus(name); | ||
}; | ||
state.fields[name] = field; | ||
var haveValidator = false; | ||
@@ -1152,0 +1174,0 @@ var silent = fieldConfig && fieldConfig.silent; |
@@ -43,2 +43,3 @@ import _extends from '@babel/runtime/helpers/esm/extends'; | ||
var keysCache = {}; | ||
var keysRegex = /[.[\]]+/; | ||
@@ -55,3 +56,22 @@ var toPath = function toPath(key) { | ||
if (keysCache[key] == null) { | ||
keysCache[key] = stringToPath(key); | ||
/** | ||
* The following patch fixes issue 456, introduced since v4.20.3: | ||
* | ||
* Before v4.20.3, i.e. in v4.20.2, a `key` like 'choices[]' would map to ['choices'] | ||
* (e.g. an array of choices used where 'choices[]' is name attribute of an input of type checkbox). | ||
* | ||
* Since v4.20.3, a `key` like 'choices[]' would map to ['choices', ''] which is wrong and breaks | ||
* this kind of inputs e.g. in React. | ||
* | ||
* v4.20.3 introduced an unwanted breaking change, this patch fixes it, see the issue at the link below. | ||
* | ||
* @see https://github.com/final-form/final-form/issues/456 | ||
*/ | ||
if (key.endsWith("[]")) { | ||
// v4.20.2 (a `key` like 'choices[]' should map to ['choices'], which is fine). | ||
keysCache[key] = key.split(keysRegex).filter(Boolean); | ||
} else { | ||
// v4.20.3 (a `key` like 'choices[]' maps to ['choices', ''], which breaks applications relying on inputs like `<input type="checkbox" name="choices[]" />`). | ||
keysCache[key] = stringToPath(key); | ||
} | ||
} | ||
@@ -375,3 +395,3 @@ | ||
var version = "4.20.7"; | ||
var version = "4.20.8"; | ||
@@ -1109,34 +1129,36 @@ var configOptions = ["debug", "initialValues", "keepDirtyOnReinitialize", "mutators", "onSubmit", "validate", "validateOnBlur"]; | ||
notified: false | ||
}; // create initial field state if not exists | ||
var field = state.fields[name] || { | ||
active: false, | ||
afterSubmit: fieldConfig && fieldConfig.afterSubmit, | ||
beforeSubmit: fieldConfig && fieldConfig.beforeSubmit, | ||
data: fieldConfig && fieldConfig.data || {}, | ||
isEqual: fieldConfig && fieldConfig.isEqual || tripleEquals, | ||
lastFieldState: undefined, | ||
modified: false, | ||
modifiedSinceLastSubmit: false, | ||
name: name, | ||
touched: false, | ||
valid: true, | ||
validateFields: fieldConfig && fieldConfig.validateFields, | ||
validators: {}, | ||
validating: false, | ||
visited: false | ||
}; // Mutators can create a field in order to keep the field states | ||
// We must update this field when registerField is called afterwards | ||
field.blur = field.blur || function () { | ||
return api.blur(name); | ||
}; | ||
if (!state.fields[name]) { | ||
// create initial field state | ||
state.fields[name] = { | ||
active: false, | ||
afterSubmit: fieldConfig && fieldConfig.afterSubmit, | ||
beforeSubmit: fieldConfig && fieldConfig.beforeSubmit, | ||
blur: function blur() { | ||
return api.blur(name); | ||
}, | ||
change: function change(value) { | ||
return api.change(name, value); | ||
}, | ||
data: fieldConfig && fieldConfig.data || {}, | ||
focus: function focus() { | ||
return api.focus(name); | ||
}, | ||
isEqual: fieldConfig && fieldConfig.isEqual || tripleEquals, | ||
lastFieldState: undefined, | ||
modified: false, | ||
modifiedSinceLastSubmit: false, | ||
name: name, | ||
touched: false, | ||
valid: true, | ||
validateFields: fieldConfig && fieldConfig.validateFields, | ||
validators: {}, | ||
validating: false, | ||
visited: false | ||
}; | ||
} | ||
field.change = field.change || function (value) { | ||
return api.change(name, value); | ||
}; | ||
field.focus = field.focus || function () { | ||
return api.focus(name); | ||
}; | ||
state.fields[name] = field; | ||
var haveValidator = false; | ||
@@ -1143,0 +1165,0 @@ var silent = fieldConfig && fieldConfig.silent; |
@@ -51,2 +51,3 @@ (function (global, factory) { | ||
var keysCache = {}; | ||
var keysRegex = /[.[\]]+/; | ||
@@ -63,3 +64,22 @@ var toPath = function toPath(key) { | ||
if (keysCache[key] == null) { | ||
keysCache[key] = stringToPath(key); | ||
/** | ||
* The following patch fixes issue 456, introduced since v4.20.3: | ||
* | ||
* Before v4.20.3, i.e. in v4.20.2, a `key` like 'choices[]' would map to ['choices'] | ||
* (e.g. an array of choices used where 'choices[]' is name attribute of an input of type checkbox). | ||
* | ||
* Since v4.20.3, a `key` like 'choices[]' would map to ['choices', ''] which is wrong and breaks | ||
* this kind of inputs e.g. in React. | ||
* | ||
* v4.20.3 introduced an unwanted breaking change, this patch fixes it, see the issue at the link below. | ||
* | ||
* @see https://github.com/final-form/final-form/issues/456 | ||
*/ | ||
if (key.endsWith("[]")) { | ||
// v4.20.2 (a `key` like 'choices[]' should map to ['choices'], which is fine). | ||
keysCache[key] = key.split(keysRegex).filter(Boolean); | ||
} else { | ||
// v4.20.3 (a `key` like 'choices[]' maps to ['choices', ''], which breaks applications relying on inputs like `<input type="checkbox" name="choices[]" />`). | ||
keysCache[key] = stringToPath(key); | ||
} | ||
} | ||
@@ -383,3 +403,3 @@ | ||
var version = "4.20.7"; | ||
var version = "4.20.8"; | ||
@@ -1117,34 +1137,36 @@ var configOptions = ["debug", "initialValues", "keepDirtyOnReinitialize", "mutators", "onSubmit", "validate", "validateOnBlur"]; | ||
notified: false | ||
}; // create initial field state if not exists | ||
var field = state.fields[name] || { | ||
active: false, | ||
afterSubmit: fieldConfig && fieldConfig.afterSubmit, | ||
beforeSubmit: fieldConfig && fieldConfig.beforeSubmit, | ||
data: fieldConfig && fieldConfig.data || {}, | ||
isEqual: fieldConfig && fieldConfig.isEqual || tripleEquals, | ||
lastFieldState: undefined, | ||
modified: false, | ||
modifiedSinceLastSubmit: false, | ||
name: name, | ||
touched: false, | ||
valid: true, | ||
validateFields: fieldConfig && fieldConfig.validateFields, | ||
validators: {}, | ||
validating: false, | ||
visited: false | ||
}; // Mutators can create a field in order to keep the field states | ||
// We must update this field when registerField is called afterwards | ||
field.blur = field.blur || function () { | ||
return api.blur(name); | ||
}; | ||
if (!state.fields[name]) { | ||
// create initial field state | ||
state.fields[name] = { | ||
active: false, | ||
afterSubmit: fieldConfig && fieldConfig.afterSubmit, | ||
beforeSubmit: fieldConfig && fieldConfig.beforeSubmit, | ||
blur: function blur() { | ||
return api.blur(name); | ||
}, | ||
change: function change(value) { | ||
return api.change(name, value); | ||
}, | ||
data: fieldConfig && fieldConfig.data || {}, | ||
focus: function focus() { | ||
return api.focus(name); | ||
}, | ||
isEqual: fieldConfig && fieldConfig.isEqual || tripleEquals, | ||
lastFieldState: undefined, | ||
modified: false, | ||
modifiedSinceLastSubmit: false, | ||
name: name, | ||
touched: false, | ||
valid: true, | ||
validateFields: fieldConfig && fieldConfig.validateFields, | ||
validators: {}, | ||
validating: false, | ||
visited: false | ||
}; | ||
} | ||
field.change = field.change || function (value) { | ||
return api.change(name, value); | ||
}; | ||
field.focus = field.focus || function () { | ||
return api.focus(name); | ||
}; | ||
state.fields[name] = field; | ||
var haveValidator = false; | ||
@@ -1151,0 +1173,0 @@ var silent = fieldConfig && fieldConfig.silent; |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@babel/runtime/helpers/esm/extends"),require("@babel/runtime/helpers/esm/objectWithoutPropertiesLoose")):"function"==typeof define&&define.amd?define(["exports","@babel/runtime/helpers/esm/extends","@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["final-form"]={},e._extends,e._objectWithoutPropertiesLoose)}(this,function(e,t,i){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function u(e){if(null==e||!e.length)return[];if("string"!=typeof e)throw new Error("toPath() expects a string");var t,n;return null==d[e]&&(d[e]=(n=[],(t=e).charCodeAt(0)===a&&n.push(""),t.replace(s,function(e,t,i,r){var a=e;i?a=r.replace(o,"$1"):t&&(a=t.trim()),n.push(a)}),n)),d[e]}var A=r(t),h=r(i),a=".".charCodeAt(0),o=/\\(\\)?/g,s=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),d={},R=function(e,t){for(var i=u(t),r=e,a=0;a<i.length;a++){var n=i[a];if(null==r||"object"!=typeof r||Array.isArray(r)&&isNaN(n))return;r=r[n]}return r};function g(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 L(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 function e(t,i,r,a,n){if(i>=r.length)return a;var u=r[i];if(isNaN(u)){var o;if(null==t){var s,d=e(void 0,i+1,r,a,n);return void 0===d?void 0:((s={})[u]=d,s)}if(Array.isArray(t))throw new Error("Cannot set a non-numeric property on an array");var l=e(t[u],i+1,r,a,n);if(void 0!==l)return A.default({},t,((o={})[u]=l,o));var f=Object.keys(t).length;if(void 0===t[u]&&0===f)return;return void 0!==t[u]&&f<=1?isNaN(r[i-1])||n?void 0:{}:(t[u],h.default(t,[u].map(g)))}var c=Number(u);if(null==t){var v=e(void 0,i+1,r,a,n);if(void 0===v)return;var m=[];return m[c]=v,m}if(!Array.isArray(t))throw new Error("Cannot set a numeric property on an object");var b=e(t[c],i+1,r,a,n),S=[].concat(t);if(n&&void 0===b){if(S.splice(c,1),0===S.length)return}else S[c]=b;return S}(e,0,u(t),i,r)}var x="FINAL_FORM/form-error",P="FINAL_FORM/array-error";function q(e,t){var i=e.errors,r=e.initialValues,a=e.lastSubmittedValues,n=e.submitErrors,u=e.submitFailed,o=e.submitSucceeded,s=e.submitting,d=e.values,l=t.active,f=t.blur,c=t.change,v=t.data,m=t.focus,b=t.modified,S=t.modifiedSinceLastSubmit,h=t.name,g=t.touched,y=t.validating,p=t.visited,E=R(d,h),F=R(i,h);F&&F[P]&&(F=F[P]);var O=n&&R(n,h),V=r&&R(r,h),j=t.isEqual(V,E),k=!F&&!O;return{active:l,blur:f,change:c,data:v,dirty:!j,dirtySinceLastSubmit:!(!a||t.isEqual(R(a,h),E)),error:F,focus:m,initial:V,invalid:!k,length:Array.isArray(E)?E.length:void 0,modified:b,modifiedSinceLastSubmit:S,name:h,pristine:j,submitError:O,submitFailed:u,submitSucceeded:o,submitting:s,touched:g,valid:k,value:E,visited:p,validating:y}}var n=["active","data","dirty","dirtySinceLastSubmit","error","initial","invalid","length","modified","modifiedSinceLastSubmit","pristine","submitError","submitFailed","submitSucceeded","submitting","touched","valid","value","visited","validating"],I=function(e,t){if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(var a=Object.prototype.hasOwnProperty.bind(t),n=0;n<i.length;n++){var u=i[n];if(!a(u)||e[u]!==t[u])return!1}return!0};function l(t,i,r,a,e,n){var u=!1;return e.forEach(function(e){a[e]&&(t[e]=i[e],r&&(~n.indexOf(e)?I(i[e],r[e]):i[e]===r[e])||(u=!0))}),u}function W(e,t,i,r){var a={blur:e.blur,change:e.change,focus:e.focus,name:e.name};return l(a,e,t,i,n,f)||!t||r?a:void 0}var f=["data"],c=["active","dirty","dirtyFields","dirtyFieldsSinceLastSubmit","dirtySinceLastSubmit","error","errors","hasSubmitErrors","hasValidationErrors","initialValues","invalid","modified","modifiedSinceLastSubmit","pristine","submitting","submitError","submitErrors","submitFailed","submitSucceeded","touched","valid","validating","values","visited"],v=["touched","visited"];function _(e,t,i,r){var a={};return l(a,e,t,i,c,v)||!t||r?a:void 0}function C(r){var a,n;return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return a&&t.length===a.length&&!t.some(function(e,t){return!I(a[t],e)})||(a=t,n=r.apply(void 0,t)),n}}function z(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then}function U(e,t){return e===t}var M=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,a,n){var u=a(i,r,t,n);return u&&(e(u),1)}function D(e,n,u,o,s){var d=e.entries;Object.keys(d).forEach(function(e){var t=d[Number(e)];if(t){var i=t.subscription,r=t.subscriber,a=t.notified;B(r,i,n,u,o,s||!a)&&(t.notified=!0)}})}e.ARRAY_ERROR=P,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 d=e.destroyOnUnregister,u=e.keepDirtyOnReinitialize,t=e.initialValues,o=e.mutators,s=e.onSubmit,y=e.validate,n=e.validateOnBlur;if(!s)throw new Error("No onSubmit function specified");function l(e,t,i){var r=i(R(e.formState.values,t));e.formState.values=L(e.formState.values,t,r)||{}}function f(e,t,i){if(e.fields[t]){var r,a;e.fields=A.default({},e.fields,((r={})[i]=A.default({},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=A.default({},e.fieldSubscribers,((a={})[i]=e.fieldSubscribers[t],a)),delete e.fieldSubscribers[t];var n=R(e.formState.values,t);e.formState.values=L(e.formState.values,t,void 0)||{},e.formState.values=L(e.formState.values,i,n),delete e.lastFormState}}function i(n){return function(){if(o){for(var e={formState:N.formState,fields:N.fields,fieldSubscribers:N.fieldSubscribers,lastFormState:N.lastFormState},t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];var a=o[n](i,e,{changeValue:l,getIn:R,renameField:f,resetFieldState:w.resetFieldState,setIn:L,shallowEqual:I});return N.formState=e.formState,N.fields=e.fields,N.fieldSubscribers=e.fieldSubscribers,N.lastFormState=e.lastFormState,S(void 0,function(){h(),k()}),a}}}function p(r){return Object.keys(r.validators).reduce(function(e,t){var i=r.validators[Number(t)]();return i&&e.push(i),e},[])}function c(){Object.keys(N.fields).forEach(function(e){N.fields[e].touched=!0})}function v(){var e=N.fields,r=N.formState,t=N.lastFormState,a=A.default({},e),i=Object.keys(a),n=!1,u=i.reduce(function(e,t){return!a[t].isEqual(R(r.values,t),R(r.initialValues||{},t))&&(n=!0,e[t]=!0),e},{}),o=i.reduce(function(e,t){var i=r.lastSubmittedValues||{};return a[t].isEqual(R(r.values,t),R(i,t))||(e[t]=!0),e},{});r.pristine=!n,r.dirtySinceLastSubmit=!(!r.lastSubmittedValues||!Object.values(o).some(function(e){return e})),r.modifiedSinceLastSubmit=!(!r.lastSubmittedValues||!Object.keys(a).some(function(e){return a[e].modifiedSinceLastSubmit})),r.valid=!(r.error||r.submitError||M(r.errors)||r.submitErrors&&M(r.submitErrors));var s,d,l,f,c,v,m,b,S,h,g,y,p,E,F,O,V=(d=(s=r).active,l=s.dirtySinceLastSubmit,f=s.modifiedSinceLastSubmit,c=s.error,v=s.errors,m=s.initialValues,b=s.pristine,S=s.submitting,h=s.submitFailed,g=s.submitSucceeded,y=s.submitError,p=s.submitErrors,E=s.valid,F=s.validating,O=s.values,{active:d,dirty:!b,dirtySinceLastSubmit:l,modifiedSinceLastSubmit:f,error:c,errors:v,hasSubmitErrors:!!(y||p&&M(p)),hasValidationErrors:!(!c&&!M(v)),invalid:!E,initialValues:m,pristine:b,submitting:S,submitFailed:h,submitSucceeded:g,submitError:y,submitErrors:p,valid:E,validating:0<F,values:O}),j=i.reduce(function(e,t){return e.modified[t]=a[t].modified,e.touched[t]=a[t].touched,e.visited[t]=a[t].visited,e},{modified:{},touched:{},visited:{}}),k=j.modified,w=j.touched,L=j.visited;return V.dirtyFields=t&&I(t.dirtyFields,u)?t.dirtyFields:u,V.dirtyFieldsSinceLastSubmit=t&&I(t.dirtyFieldsSinceLastSubmit,o)?t.dirtyFieldsSinceLastSubmit:o,V.modified=t&&I(t.modified,k)?t.modified:k,V.touched=t&&I(t.touched,w)?t.touched:w,V.visited=t&&I(t.visited,L)?t.visited:L,t&&I(t,V)?t:V}function m(){return Object.keys(N.fields).forEach(function(e){return N.fields[e].modifiedSinceLastSubmit=!1})}var N={subscribers:{index:0,entries:{}},fieldSubscribers:{},fields:{},formState:{asyncErrors:{},dirtySinceLastSubmit:!1,modifiedSinceLastSubmit:!1,errors:{},initialValues:t&&A.default({},t),invalid:!1,pristine:!0,submitting:!1,submitFailed:!1,submitSucceeded:!1,resetWhileSubmitting:!1,valid:!0,validating:0,values:t?A.default({},t):{}},lastFormState:void 0},r=0,E=!1,F=!1,a=!1,O=0,V={},b=o?Object.keys(o).reduce(function(e,t){return e[t]=i(t),e},{}):{},S=function(e,t){if(E)return F=!0,void t();var o=N.fields,i=N.formState,s=A.default({},o),r=Object.keys(s);if(y||r.some(function(e){return p(s[e]).length})){var d=!1;if(e){var a=s[e];if(a){var n=a.validateFields;n&&(d=!0,r=n.length?n.concat(e):[e])}}var u,l={},f={},c={},v=[].concat(function(t){var e=[];if(y){var i=y(A.default({},N.formState.values));z(i)?e.push(i.then(function(e){return t(e,!0)})):t(i,!1)}return e}(function(e,t){t?f=e||{}:l=e||{}}),r.reduce(function(e,t){return e.concat(function(r,a){var n,u=[],e=p(r);e.length&&(e.forEach(function(e){var t=e(R(N.formState.values,r.name),N.formState.values,0===e.length||3===e.length?q(N.formState,N.fields[r.name]):void 0);if(t&&z(t)){r.validating=!0;var i=t.then(function(e){N.fields[r.name]&&(N.fields[r.name].validating=!1,a(e))});u.push(i)}else n=n||t}),a(n));return u}(o[t],function(e){c[t]=e}))},[])),m=0<v.length,b=++O,S=Promise.all(v).then((u=b,function(e){return delete V[u],e}));m&&(V[b]=S);var h=function(e){function t(n){r.forEach(function(e){if(o[e]){var t=R(l,e),i=R(u,e),r=p(s[e]).length,a=c[e];n(e,r&&a||y&&t||(t||d?void 0:i))}})}var u=A.default({},d?i.errors:{},l,e?f:i.asyncErrors);t(function(e,t){u=L(u,e,t)||{}}),t(function(e,t){if(t&&t[P]){var i=R(u,e),r=[].concat(i);r[P]=t[P],u=L(u,e,r)}}),I(i.errors,u)||(i.errors=u),e&&(i.asyncErrors=f),i.error=l[x]};if(m&&(N.formState.validating++,t()),h(!1),t(),m){var g=function(){N.formState.validating--,t()};S.then(function(){b<O||h(!0)}).then(g,g)}}else t()},h=function(e){if(!r){var t=N.fields,n=N.fieldSubscribers,u=N.formState,o=A.default({},t),i=function(e){var t=o[e],i=q(u,t),r=t.lastFieldState;t.lastFieldState=i;var a=n[e];a&&D(a,i,r,W,void 0===r)};e?i(e):Object.keys(o).forEach(i)}},g=!1,j=!1,k=function e(){if(g)j=!0;else{if(g=!0,!(r||E&&a)){var t=N.lastFormState,i=v();i!==t&&(N.lastFormState=i,D(N.subscribers,i,t,_))}g=!1,j&&(j=!1,e())}};S(void 0,function(){k()});var w={batch:function(e){r++,e(),r--,h(),k()},blur:function(e){var t=N.fields,i=N.formState,r=t[e];r&&(delete i.active,t[e]=A.default({},r,{active:!1,touched:!0}),n?S(e,function(){h(),k()}):(h(),k()))},change:function(e,t){var i=N.fields,r=N.formState;if(R(r.values,e)!==t){l(N,e,function(){return t});var a=i[e];a&&(i[e]=A.default({},a,{modified:!0,modifiedSinceLastSubmit:!!r.lastSubmittedValues})),n?(h(),k()):S(e,function(){h(),k()})}},get destroyOnUnregister(){return!!d},set destroyOnUnregister(e){d=e},focus:function(e){var t=N.fields[e];t&&!t.active&&(N.formState.active=e,t.active=!0,t.visited=!0,h(),k())},mutators:b,getFieldState:function(e){var t=N.fields[e];return t&&t.lastFieldState},getRegisteredFields:function(){return Object.keys(N.fields)},getState:function(){return v()},initialize:function(e){var t=N.fields,i=N.formState,r=A.default({},t),a="function"==typeof e?e(i.values):e;u||(i.values=a);var n=u?Object.keys(r).reduce(function(e,t){return r[t].isEqual(R(i.values,t),R(i.initialValues||{},t))||(e[t]=R(i.values,t)),e},{}):{};i.initialValues=a,i.values=a,Object.keys(n).forEach(function(e){i.values=L(i.values,e,n[e])||{}}),S(void 0,function(){h(),k()})},isValidationPaused:function(){return E},pauseValidation:function(e){void 0===e&&(e=!0),E=!0,a=e},registerField:function(r,e,t,i){void 0===t&&(t={}),N.fieldSubscribers[r]||(N.fieldSubscribers[r]={index:0,entries:{}});var a=N.fieldSubscribers[r].index++;N.fieldSubscribers[r].entries[a]={subscriber:C(e),subscription:t,notified:!1},N.fields[r]||(N.fields[r]={active:!1,afterSubmit:i&&i.afterSubmit,beforeSubmit:i&&i.beforeSubmit,blur:function(){return w.blur(r)},change:function(e){return w.change(r,e)},data:i&&i.data||{},focus:function(){return w.focus(r)},isEqual:i&&i.isEqual||U,lastFieldState:void 0,modified:!1,modifiedSinceLastSubmit:!1,name:r,touched:!1,valid:!0,validateFields:i&&i.validateFields,validators:{},validating:!1,visited:!1});function n(){o?h(r):(k(),h())}var u=!1,o=i&&i.silent;if(i){u=!(!i.getValidator||!i.getValidator()),i.getValidator&&(N.fields[r].validators[a]=i.getValidator);var s=void 0===R(N.formState.values,r);void 0===i.initialValue||!s&&R(N.formState.values,r)!==R(N.formState.initialValues,r)||(N.formState.initialValues=L(N.formState.initialValues||{},r,i.initialValue),N.formState.values=L(N.formState.values,r,i.initialValue),S(void 0,n)),void 0!==i.defaultValue&&void 0===i.initialValue&&void 0===R(N.formState.initialValues,r)&&s&&(N.formState.values=L(N.formState.values,r,i.defaultValue))}return u?S(void 0,n):n(),function(){var e=!1;N.fields[r]&&(e=!(!N.fields[r].validators[a]||!N.fields[r].validators[a]()),delete N.fields[r].validators[a]);var t=!!N.fieldSubscribers[r];t&&delete N.fieldSubscribers[r].entries[a];var i=t&&!Object.keys(N.fieldSubscribers[r].entries).length;i&&(delete N.fieldSubscribers[r],delete N.fields[r],e&&(N.formState.errors=L(N.formState.errors,r,void 0)||{}),d&&(N.formState.values=L(N.formState.values,r,void 0,!0)||{})),o||(e?S(void 0,function(){k(),h()}):i&&k())}},reset:function(e){void 0===e&&(e=N.formState.initialValues),N.formState.submitting&&(N.formState.resetWhileSubmitting=!0),N.formState.submitFailed=!1,N.formState.submitSucceeded=!1,delete N.formState.submitError,delete N.formState.submitErrors,delete N.formState.lastSubmittedValues,w.initialize(e||{})},resetFieldState:function(e){N.fields[e]=A.default({},N.fields[e],{active:!1,lastFieldState:void 0,modified:!1,touched:!1,valid:!0,validating:!1,visited:!1}),S(void 0,function(){h(),k()})},restart:function(t){void 0===t&&(t=N.formState.initialValues),w.batch(function(){for(var e in N.fields)w.resetFieldState(e),N.fields[e]=A.default({},N.fields[e],{active:!1,lastFieldState:void 0,modified:!1,modifiedSinceLastSubmit:!1,touched:!1,valid:!0,validating:!1,visited:!1});w.reset(t)})},resumeValidation:function(){a=E=!1,F&&S(void 0,function(){h(),k()}),F=!1},setConfig:function(e,t){switch(e){case"debug":0;break;case"destroyOnUnregister":d=t;break;case"initialValues":w.initialize(t);break;case"keepDirtyOnReinitialize":u=t;break;case"mutators":(o=t)?(Object.keys(b).forEach(function(e){e in t||delete b[e]}),Object.keys(t).forEach(function(e){b[e]=i(e)})):Object.keys(b).forEach(function(e){delete b[e]});break;case"onSubmit":s=t;break;case"validate":y=t,S(void 0,function(){h(),k()});break;case"validateOnBlur":n=t;break;default:throw new Error("Unrecognised option "+e)}},submit:function(){var i=N.formState;if(!i.submitting){if(delete i.submitErrors,delete i.submitError,i.lastSubmittedValues=A.default({},i.values),N.formState.error||M(N.formState.errors))return c(),m(),N.formState.submitFailed=!0,k(),void h();var e=Object.keys(V);if(e.length)Promise.all(e.map(function(e){return V[Number(e)]})).then(w.submit,console.error);else if(!Object.keys(N.fields).some(function(e){return N.fields[e].beforeSubmit&&!1===N.fields[e].beforeSubmit()})){var r,a=!1,t=function(e){i.submitting=!1;var t=i.resetWhileSubmitting;return t&&(i.resetWhileSubmitting=!1),e&&M(e)?(i.submitFailed=!0,i.submitSucceeded=!1,i.submitErrors=e,i.submitError=e[x],c()):(t||(i.submitFailed=!1,i.submitSucceeded=!0),Object.keys(N.fields).forEach(function(e){return N.fields[e].afterSubmit&&N.fields[e].afterSubmit()})),k(),h(),a=!0,r&&r(e),e};i.submitting=!0,i.submitFailed=!1,i.submitSucceeded=!1,i.lastSubmittedValues=A.default({},i.values),m();var n=s(i.values,w,t);if(!a){if(n&&z(n))return k(),h(),n.then(t,function(e){throw t(),e});if(3<=s.length)return k(),h(),new Promise(function(e){r=e});t(n)}}}},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=N.subscribers,a=r.index++;r.entries[a]={subscriber:i,subscription:t,notified:!1};var n=v();return B(i,t,n,n,_,!0),function(){delete r.entries[a]}}};return w},e.fieldSubscriptionItems=n,e.formSubscriptionItems=c,e.getIn=R,e.setIn=L,e.version="4.20.7",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@babel/runtime/helpers/esm/extends"),require("@babel/runtime/helpers/esm/objectWithoutPropertiesLoose")):"function"==typeof define&&define.amd?define(["exports","@babel/runtime/helpers/esm/extends","@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["final-form"]={},e._extends,e._objectWithoutPropertiesLoose)}(this,function(e,t,i){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function u(e){if(null==e||!e.length)return[];if("string"!=typeof e)throw new Error("toPath() expects a string");var t,n;return null==d[e]&&(e.endsWith("[]")?d[e]=e.split(l).filter(Boolean):d[e]=(n=[],(t=e).charCodeAt(0)===a&&n.push(""),t.replace(s,function(e,t,i,r){var a=e;i?a=r.replace(o,"$1"):t&&(a=t.trim()),n.push(a)}),n)),d[e]}var A=r(t),h=r(i),a=".".charCodeAt(0),o=/\\(\\)?/g,s=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),d={},l=/[.[\]]+/,R=function(e,t){for(var i=u(t),r=e,a=0;a<i.length;a++){var n=i[a];if(null==r||"object"!=typeof r||Array.isArray(r)&&isNaN(n))return;r=r[n]}return r};function g(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 L(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 function e(t,i,r,a,n){if(i>=r.length)return a;var u=r[i];if(isNaN(u)){var o;if(null==t){var s,d=e(void 0,i+1,r,a,n);return void 0===d?void 0:((s={})[u]=d,s)}if(Array.isArray(t))throw new Error("Cannot set a non-numeric property on an array");var l=e(t[u],i+1,r,a,n);if(void 0!==l)return A.default({},t,((o={})[u]=l,o));var f=Object.keys(t).length;if(void 0===t[u]&&0===f)return;return void 0!==t[u]&&f<=1?isNaN(r[i-1])||n?void 0:{}:(t[u],h.default(t,[u].map(g)))}var c=Number(u);if(null==t){var v=e(void 0,i+1,r,a,n);if(void 0===v)return;var m=[];return m[c]=v,m}if(!Array.isArray(t))throw new Error("Cannot set a numeric property on an object");var b=e(t[c],i+1,r,a,n),S=[].concat(t);if(n&&void 0===b){if(S.splice(c,1),0===S.length)return}else S[c]=b;return S}(e,0,u(t),i,r)}var x="FINAL_FORM/form-error",P="FINAL_FORM/array-error";function q(e,t){var i=e.errors,r=e.initialValues,a=e.lastSubmittedValues,n=e.submitErrors,u=e.submitFailed,o=e.submitSucceeded,s=e.submitting,d=e.values,l=t.active,f=t.blur,c=t.change,v=t.data,m=t.focus,b=t.modified,S=t.modifiedSinceLastSubmit,h=t.name,g=t.touched,y=t.validating,p=t.visited,E=R(d,h),F=R(i,h);F&&F[P]&&(F=F[P]);var O=n&&R(n,h),V=r&&R(r,h),j=t.isEqual(V,E),k=!F&&!O;return{active:l,blur:f,change:c,data:v,dirty:!j,dirtySinceLastSubmit:!(!a||t.isEqual(R(a,h),E)),error:F,focus:m,initial:V,invalid:!k,length:Array.isArray(E)?E.length:void 0,modified:b,modifiedSinceLastSubmit:S,name:h,pristine:j,submitError:O,submitFailed:u,submitSucceeded:o,submitting:s,touched:g,valid:k,value:E,visited:p,validating:y}}var n=["active","data","dirty","dirtySinceLastSubmit","error","initial","invalid","length","modified","modifiedSinceLastSubmit","pristine","submitError","submitFailed","submitSucceeded","submitting","touched","valid","value","visited","validating"],I=function(e,t){if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(var a=Object.prototype.hasOwnProperty.bind(t),n=0;n<i.length;n++){var u=i[n];if(!a(u)||e[u]!==t[u])return!1}return!0};function f(t,i,r,a,e,n){var u=!1;return e.forEach(function(e){a[e]&&(t[e]=i[e],r&&(~n.indexOf(e)?I(i[e],r[e]):i[e]===r[e])||(u=!0))}),u}function W(e,t,i,r){var a={blur:e.blur,change:e.change,focus:e.focus,name:e.name};return f(a,e,t,i,n,c)||!t||r?a:void 0}var c=["data"],v=["active","dirty","dirtyFields","dirtyFieldsSinceLastSubmit","dirtySinceLastSubmit","error","errors","hasSubmitErrors","hasValidationErrors","initialValues","invalid","modified","modifiedSinceLastSubmit","pristine","submitting","submitError","submitErrors","submitFailed","submitSucceeded","touched","valid","validating","values","visited"],m=["touched","visited"];function _(e,t,i,r){var a={};return f(a,e,t,i,v,m)||!t||r?a:void 0}function C(r){var a,n;return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return a&&t.length===a.length&&!t.some(function(e,t){return!I(a[t],e)})||(a=t,n=r.apply(void 0,t)),n}}function z(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,a,n){var u=a(i,r,t,n);return u&&(e(u),1)}function D(e,n,u,o,s){var d=e.entries;Object.keys(d).forEach(function(e){var t=d[Number(e)];if(t){var i=t.subscription,r=t.subscriber,a=t.notified;M(r,i,n,u,o,s||!a)&&(t.notified=!0)}})}e.ARRAY_ERROR=P,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 l=e.destroyOnUnregister,u=e.keepDirtyOnReinitialize,t=e.initialValues,o=e.mutators,s=e.onSubmit,y=e.validate,n=e.validateOnBlur;if(!s)throw new Error("No onSubmit function specified");function d(e,t,i){var r=i(R(e.formState.values,t));e.formState.values=L(e.formState.values,t,r)||{}}function f(e,t,i){if(e.fields[t]){var r,a;e.fields=A.default({},e.fields,((r={})[i]=A.default({},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=A.default({},e.fieldSubscribers,((a={})[i]=e.fieldSubscribers[t],a)),delete e.fieldSubscribers[t];var n=R(e.formState.values,t);e.formState.values=L(e.formState.values,t,void 0)||{},e.formState.values=L(e.formState.values,i,n),delete e.lastFormState}}function i(n){return function(){if(o){for(var e={formState:N.formState,fields:N.fields,fieldSubscribers:N.fieldSubscribers,lastFormState:N.lastFormState},t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];var a=o[n](i,e,{changeValue:d,getIn:R,renameField:f,resetFieldState:w.resetFieldState,setIn:L,shallowEqual:I});return N.formState=e.formState,N.fields=e.fields,N.fieldSubscribers=e.fieldSubscribers,N.lastFormState=e.lastFormState,S(void 0,function(){h(),k()}),a}}}function p(r){return Object.keys(r.validators).reduce(function(e,t){var i=r.validators[Number(t)]();return i&&e.push(i),e},[])}function c(){Object.keys(N.fields).forEach(function(e){N.fields[e].touched=!0})}function v(){var e=N.fields,r=N.formState,t=N.lastFormState,a=A.default({},e),i=Object.keys(a),n=!1,u=i.reduce(function(e,t){return!a[t].isEqual(R(r.values,t),R(r.initialValues||{},t))&&(n=!0,e[t]=!0),e},{}),o=i.reduce(function(e,t){var i=r.lastSubmittedValues||{};return a[t].isEqual(R(r.values,t),R(i,t))||(e[t]=!0),e},{});r.pristine=!n,r.dirtySinceLastSubmit=!(!r.lastSubmittedValues||!Object.values(o).some(function(e){return e})),r.modifiedSinceLastSubmit=!(!r.lastSubmittedValues||!Object.keys(a).some(function(e){return a[e].modifiedSinceLastSubmit})),r.valid=!(r.error||r.submitError||B(r.errors)||r.submitErrors&&B(r.submitErrors));var s,d,l,f,c,v,m,b,S,h,g,y,p,E,F,O,V=(d=(s=r).active,l=s.dirtySinceLastSubmit,f=s.modifiedSinceLastSubmit,c=s.error,v=s.errors,m=s.initialValues,b=s.pristine,S=s.submitting,h=s.submitFailed,g=s.submitSucceeded,y=s.submitError,p=s.submitErrors,E=s.valid,F=s.validating,O=s.values,{active:d,dirty:!b,dirtySinceLastSubmit:l,modifiedSinceLastSubmit:f,error:c,errors:v,hasSubmitErrors:!!(y||p&&B(p)),hasValidationErrors:!(!c&&!B(v)),invalid:!E,initialValues:m,pristine:b,submitting:S,submitFailed:h,submitSucceeded:g,submitError:y,submitErrors:p,valid:E,validating:0<F,values:O}),j=i.reduce(function(e,t){return e.modified[t]=a[t].modified,e.touched[t]=a[t].touched,e.visited[t]=a[t].visited,e},{modified:{},touched:{},visited:{}}),k=j.modified,w=j.touched,L=j.visited;return V.dirtyFields=t&&I(t.dirtyFields,u)?t.dirtyFields:u,V.dirtyFieldsSinceLastSubmit=t&&I(t.dirtyFieldsSinceLastSubmit,o)?t.dirtyFieldsSinceLastSubmit:o,V.modified=t&&I(t.modified,k)?t.modified:k,V.touched=t&&I(t.touched,w)?t.touched:w,V.visited=t&&I(t.visited,L)?t.visited:L,t&&I(t,V)?t:V}function m(){return Object.keys(N.fields).forEach(function(e){return N.fields[e].modifiedSinceLastSubmit=!1})}var N={subscribers:{index:0,entries:{}},fieldSubscribers:{},fields:{},formState:{asyncErrors:{},dirtySinceLastSubmit:!1,modifiedSinceLastSubmit:!1,errors:{},initialValues:t&&A.default({},t),invalid:!1,pristine:!0,submitting:!1,submitFailed:!1,submitSucceeded:!1,resetWhileSubmitting:!1,valid:!0,validating:0,values:t?A.default({},t):{}},lastFormState:void 0},r=0,E=!1,F=!1,a=!1,O=0,V={},b=o?Object.keys(o).reduce(function(e,t){return e[t]=i(t),e},{}):{},S=function(e,t){if(E)return F=!0,void t();var o=N.fields,i=N.formState,s=A.default({},o),r=Object.keys(s);if(y||r.some(function(e){return p(s[e]).length})){var d=!1;if(e){var a=s[e];if(a){var n=a.validateFields;n&&(d=!0,r=n.length?n.concat(e):[e])}}var u,l={},f={},c={},v=[].concat(function(t){var e=[];if(y){var i=y(A.default({},N.formState.values));z(i)?e.push(i.then(function(e){return t(e,!0)})):t(i,!1)}return e}(function(e,t){t?f=e||{}:l=e||{}}),r.reduce(function(e,t){return e.concat(function(r,a){var n,u=[],e=p(r);e.length&&(e.forEach(function(e){var t=e(R(N.formState.values,r.name),N.formState.values,0===e.length||3===e.length?q(N.formState,N.fields[r.name]):void 0);if(t&&z(t)){r.validating=!0;var i=t.then(function(e){N.fields[r.name]&&(N.fields[r.name].validating=!1,a(e))});u.push(i)}else n=n||t}),a(n));return u}(o[t],function(e){c[t]=e}))},[])),m=0<v.length,b=++O,S=Promise.all(v).then((u=b,function(e){return delete V[u],e}));m&&(V[b]=S);var h=function(e){function t(n){r.forEach(function(e){if(o[e]){var t=R(l,e),i=R(u,e),r=p(s[e]).length,a=c[e];n(e,r&&a||y&&t||(t||d?void 0:i))}})}var u=A.default({},d?i.errors:{},l,e?f:i.asyncErrors);t(function(e,t){u=L(u,e,t)||{}}),t(function(e,t){if(t&&t[P]){var i=R(u,e),r=[].concat(i);r[P]=t[P],u=L(u,e,r)}}),I(i.errors,u)||(i.errors=u),e&&(i.asyncErrors=f),i.error=l[x]};if(m&&(N.formState.validating++,t()),h(!1),t(),m){var g=function(){N.formState.validating--,t()};S.then(function(){b<O||h(!0)}).then(g,g)}}else t()},h=function(e){if(!r){var t=N.fields,n=N.fieldSubscribers,u=N.formState,o=A.default({},t),i=function(e){var t=o[e],i=q(u,t),r=t.lastFieldState;t.lastFieldState=i;var a=n[e];a&&D(a,i,r,W,void 0===r)};e?i(e):Object.keys(o).forEach(i)}},g=!1,j=!1,k=function e(){if(g)j=!0;else{if(g=!0,!(r||E&&a)){var t=N.lastFormState,i=v();i!==t&&(N.lastFormState=i,D(N.subscribers,i,t,_))}g=!1,j&&(j=!1,e())}};S(void 0,function(){k()});var w={batch:function(e){r++,e(),r--,h(),k()},blur:function(e){var t=N.fields,i=N.formState,r=t[e];r&&(delete i.active,t[e]=A.default({},r,{active:!1,touched:!0}),n?S(e,function(){h(),k()}):(h(),k()))},change:function(e,t){var i=N.fields,r=N.formState;if(R(r.values,e)!==t){d(N,e,function(){return t});var a=i[e];a&&(i[e]=A.default({},a,{modified:!0,modifiedSinceLastSubmit:!!r.lastSubmittedValues})),n?(h(),k()):S(e,function(){h(),k()})}},get destroyOnUnregister(){return!!l},set destroyOnUnregister(e){l=e},focus:function(e){var t=N.fields[e];t&&!t.active&&(N.formState.active=e,t.active=!0,t.visited=!0,h(),k())},mutators:b,getFieldState:function(e){var t=N.fields[e];return t&&t.lastFieldState},getRegisteredFields:function(){return Object.keys(N.fields)},getState:function(){return v()},initialize:function(e){var t=N.fields,i=N.formState,r=A.default({},t),a="function"==typeof e?e(i.values):e;u||(i.values=a);var n=u?Object.keys(r).reduce(function(e,t){return r[t].isEqual(R(i.values,t),R(i.initialValues||{},t))||(e[t]=R(i.values,t)),e},{}):{};i.initialValues=a,i.values=a,Object.keys(n).forEach(function(e){i.values=L(i.values,e,n[e])||{}}),S(void 0,function(){h(),k()})},isValidationPaused:function(){return E},pauseValidation:function(e){void 0===e&&(e=!0),E=!0,a=e},registerField:function(r,e,t,i){void 0===t&&(t={}),N.fieldSubscribers[r]||(N.fieldSubscribers[r]={index:0,entries:{}});var a=N.fieldSubscribers[r].index++;N.fieldSubscribers[r].entries[a]={subscriber:C(e),subscription:t,notified:!1};var n=N.fields[r]||{active:!1,afterSubmit:i&&i.afterSubmit,beforeSubmit:i&&i.beforeSubmit,data:i&&i.data||{},isEqual:i&&i.isEqual||U,lastFieldState:void 0,modified:!1,modifiedSinceLastSubmit:!1,name:r,touched:!1,valid:!0,validateFields:i&&i.validateFields,validators:{},validating:!1,visited:!1};n.blur=n.blur||function(){return w.blur(r)},n.change=n.change||function(e){return w.change(r,e)},n.focus=n.focus||function(){return w.focus(r)},N.fields[r]=n;function u(){s?h(r):(k(),h())}var o=!1,s=i&&i.silent;if(i){o=!(!i.getValidator||!i.getValidator()),i.getValidator&&(N.fields[r].validators[a]=i.getValidator);var d=void 0===R(N.formState.values,r);void 0===i.initialValue||!d&&R(N.formState.values,r)!==R(N.formState.initialValues,r)||(N.formState.initialValues=L(N.formState.initialValues||{},r,i.initialValue),N.formState.values=L(N.formState.values,r,i.initialValue),S(void 0,u)),void 0!==i.defaultValue&&void 0===i.initialValue&&void 0===R(N.formState.initialValues,r)&&d&&(N.formState.values=L(N.formState.values,r,i.defaultValue))}return o?S(void 0,u):u(),function(){var e=!1;N.fields[r]&&(e=!(!N.fields[r].validators[a]||!N.fields[r].validators[a]()),delete N.fields[r].validators[a]);var t=!!N.fieldSubscribers[r];t&&delete N.fieldSubscribers[r].entries[a];var i=t&&!Object.keys(N.fieldSubscribers[r].entries).length;i&&(delete N.fieldSubscribers[r],delete N.fields[r],e&&(N.formState.errors=L(N.formState.errors,r,void 0)||{}),l&&(N.formState.values=L(N.formState.values,r,void 0,!0)||{})),s||(e?S(void 0,function(){k(),h()}):i&&k())}},reset:function(e){void 0===e&&(e=N.formState.initialValues),N.formState.submitting&&(N.formState.resetWhileSubmitting=!0),N.formState.submitFailed=!1,N.formState.submitSucceeded=!1,delete N.formState.submitError,delete N.formState.submitErrors,delete N.formState.lastSubmittedValues,w.initialize(e||{})},resetFieldState:function(e){N.fields[e]=A.default({},N.fields[e],{active:!1,lastFieldState:void 0,modified:!1,touched:!1,valid:!0,validating:!1,visited:!1}),S(void 0,function(){h(),k()})},restart:function(t){void 0===t&&(t=N.formState.initialValues),w.batch(function(){for(var e in N.fields)w.resetFieldState(e),N.fields[e]=A.default({},N.fields[e],{active:!1,lastFieldState:void 0,modified:!1,modifiedSinceLastSubmit:!1,touched:!1,valid:!0,validating:!1,visited:!1});w.reset(t)})},resumeValidation:function(){a=E=!1,F&&S(void 0,function(){h(),k()}),F=!1},setConfig:function(e,t){switch(e){case"debug":0;break;case"destroyOnUnregister":l=t;break;case"initialValues":w.initialize(t);break;case"keepDirtyOnReinitialize":u=t;break;case"mutators":(o=t)?(Object.keys(b).forEach(function(e){e in t||delete b[e]}),Object.keys(t).forEach(function(e){b[e]=i(e)})):Object.keys(b).forEach(function(e){delete b[e]});break;case"onSubmit":s=t;break;case"validate":y=t,S(void 0,function(){h(),k()});break;case"validateOnBlur":n=t;break;default:throw new Error("Unrecognised option "+e)}},submit:function(){var i=N.formState;if(!i.submitting){if(delete i.submitErrors,delete i.submitError,i.lastSubmittedValues=A.default({},i.values),N.formState.error||B(N.formState.errors))return c(),m(),N.formState.submitFailed=!0,k(),void h();var e=Object.keys(V);if(e.length)Promise.all(e.map(function(e){return V[Number(e)]})).then(w.submit,console.error);else if(!Object.keys(N.fields).some(function(e){return N.fields[e].beforeSubmit&&!1===N.fields[e].beforeSubmit()})){var r,a=!1,t=function(e){i.submitting=!1;var t=i.resetWhileSubmitting;return t&&(i.resetWhileSubmitting=!1),e&&B(e)?(i.submitFailed=!0,i.submitSucceeded=!1,i.submitErrors=e,i.submitError=e[x],c()):(t||(i.submitFailed=!1,i.submitSucceeded=!0),Object.keys(N.fields).forEach(function(e){return N.fields[e].afterSubmit&&N.fields[e].afterSubmit()})),k(),h(),a=!0,r&&r(e),e};i.submitting=!0,i.submitFailed=!1,i.submitSucceeded=!1,i.lastSubmittedValues=A.default({},i.values),m();var n=s(i.values,w,t);if(!a){if(n&&z(n))return k(),h(),n.then(t,function(e){throw t(),e});if(3<=s.length)return k(),h(),new Promise(function(e){r=e});t(n)}}}},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=N.subscribers,a=r.index++;r.entries[a]={subscriber:i,subscription:t,notified:!1};var n=v();return M(i,t,n,n,_,!0),function(){delete r.entries[a]}}};return w},e.fieldSubscriptionItems=n,e.formSubscriptionItems=v,e.getIn=R,e.setIn=L,e.version="4.20.8",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=final-form.umd.min.js.map |
{ | ||
"name": "final-form", | ||
"version": "4.20.7", | ||
"version": "4.20.8", | ||
"description": "🏁 Framework agnostic, high performance, subscription-based form state management", | ||
@@ -92,7 +92,7 @@ "main": "dist/final-form.cjs.js", | ||
"path": "dist/final-form.es.js", | ||
"maxSize": "9.9kB" | ||
"maxSize": "10.4kB" | ||
}, | ||
{ | ||
"path": "dist/final-form.cjs.js", | ||
"maxSize": "10.1kB" | ||
"maxSize": "10.49kB" | ||
} | ||
@@ -99,0 +99,0 @@ ], |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
194990
4180