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 1.3.5 to 2.0.0

43

dist/final-form.cjs.js

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

var initial = initialValues && getIn(initialValues, name);
var pristine = initial === value;
var pristine = field.isEqual(initial, value);
var valid = !error && !submitError;

@@ -317,3 +317,3 @@ return {

//
var subscriptionFilter = function (dest, src, previous, subscription, keys, shallowEqualKeys) {
function subscriptionFilter (dest, src, previous, subscription, keys, shallowEqualKeys) {
var different = false;

@@ -329,3 +329,3 @@ keys.forEach(function (key) {

return different;
};
}

@@ -391,2 +391,6 @@ //

var tripleEquals = function tripleEquals(a, b) {
return a === b;
};
var convertToExternalFormState = function convertToExternalFormState(_ref) {

@@ -508,3 +512,3 @@ var active = _ref.active,

state.fields = mutatableState.fields;
runValidation(function () {
runValidation(undefined, function () {
notifyFieldListeners();

@@ -553,3 +557,3 @@ notifyFormListeners();

var runValidation = function runValidation(callback) {
var runValidation = function runValidation(fieldChanged, callback) {
var fields = state.fields,

@@ -568,2 +572,11 @@ formState = state.formState;

// pare down field keys to actually validate
if (fieldChanged) {
var validateFields = fields[fieldChanged].validateFields;
if (validateFields) {
fieldKeys = validateFields.length ? validateFields.concat(fieldChanged) : [fieldChanged];
}
}
var recordLevelErrors = {};

@@ -652,3 +665,3 @@ var fieldLevelErrors = {};

formState.pristine = fieldKeys.every(function (key) {
return getIn(formState.values, key) === getIn(formState.initialValues, key);
return fields[key].isEqual(getIn(formState.values, key), getIn(formState.initialValues, key));
});

@@ -706,3 +719,3 @@ formState.valid = !formState.error && !formState.submitError && !Object.keys(formState.errors).length && !(formState.submitErrors && Object.keys(formState.submitErrors).length);

if (validateOnBlur) {
runValidation(function () {
runValidation(name, function () {
notifyFieldListeners();

@@ -730,3 +743,3 @@ notifyFormListeners();

} else {
runValidation(function () {
runValidation(name, function () {
notifyFieldListeners();

@@ -771,3 +784,3 @@ notifyFormListeners();

});
runValidation(function () {
runValidation(undefined, function () {
notifyFieldListeners();

@@ -780,3 +793,3 @@ notifyFormListeners();

var subscription = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var validate = arguments[3];
var fieldConfig = arguments[3];

@@ -810,2 +823,3 @@ if (!state.fieldSubscribers[name]) {

initial: initial,
isEqual: fieldConfig && fieldConfig.isEqual || tripleEquals,
lastFieldState: undefined,

@@ -816,2 +830,3 @@ name: name,

valid: true,
validateFields: fieldConfig && fieldConfig.validateFields,
validators: {},

@@ -821,4 +836,4 @@ visited: false

}
if (validate) {
state.fields[name].validators[index] = validate;
if (fieldConfig && fieldConfig.validate) {
state.fields[name].validators[index] = fieldConfig.validate;
}

@@ -834,3 +849,3 @@

runValidation(function () {
runValidation(undefined, function () {
notifyFormListeners();

@@ -850,3 +865,3 @@ if (!sentFirstNotification) {

}
runValidation(function () {
runValidation(undefined, function () {
notifyFieldListeners();

@@ -853,0 +868,0 @@ notifyFormListeners();

@@ -258,3 +258,3 @@ //

var initial = initialValues && getIn(initialValues, name);
var pristine = initial === value;
var pristine = field.isEqual(initial, value);
var valid = !error && !submitError;

@@ -313,3 +313,3 @@ return {

//
var subscriptionFilter = function (dest, src, previous, subscription, keys, shallowEqualKeys) {
function subscriptionFilter (dest, src, previous, subscription, keys, shallowEqualKeys) {
var different = false;

@@ -325,3 +325,3 @@ keys.forEach(function (key) {

return different;
};
}

@@ -387,2 +387,6 @@ //

var tripleEquals = function tripleEquals(a, b) {
return a === b;
};
var convertToExternalFormState = function convertToExternalFormState(_ref) {

@@ -504,3 +508,3 @@ var active = _ref.active,

state.fields = mutatableState.fields;
runValidation(function () {
runValidation(undefined, function () {
notifyFieldListeners();

@@ -549,3 +553,3 @@ notifyFormListeners();

var runValidation = function runValidation(callback) {
var runValidation = function runValidation(fieldChanged, callback) {
var fields = state.fields,

@@ -564,2 +568,11 @@ formState = state.formState;

// pare down field keys to actually validate
if (fieldChanged) {
var validateFields = fields[fieldChanged].validateFields;
if (validateFields) {
fieldKeys = validateFields.length ? validateFields.concat(fieldChanged) : [fieldChanged];
}
}
var recordLevelErrors = {};

@@ -648,3 +661,3 @@ var fieldLevelErrors = {};

formState.pristine = fieldKeys.every(function (key) {
return getIn(formState.values, key) === getIn(formState.initialValues, key);
return fields[key].isEqual(getIn(formState.values, key), getIn(formState.initialValues, key));
});

@@ -702,3 +715,3 @@ formState.valid = !formState.error && !formState.submitError && !Object.keys(formState.errors).length && !(formState.submitErrors && Object.keys(formState.submitErrors).length);

if (validateOnBlur) {
runValidation(function () {
runValidation(name, function () {
notifyFieldListeners();

@@ -726,3 +739,3 @@ notifyFormListeners();

} else {
runValidation(function () {
runValidation(name, function () {
notifyFieldListeners();

@@ -767,3 +780,3 @@ notifyFormListeners();

});
runValidation(function () {
runValidation(undefined, function () {
notifyFieldListeners();

@@ -776,3 +789,3 @@ notifyFormListeners();

var subscription = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var validate = arguments[3];
var fieldConfig = arguments[3];

@@ -806,2 +819,3 @@ if (!state.fieldSubscribers[name]) {

initial: initial,
isEqual: fieldConfig && fieldConfig.isEqual || tripleEquals,
lastFieldState: undefined,

@@ -812,2 +826,3 @@ name: name,

valid: true,
validateFields: fieldConfig && fieldConfig.validateFields,
validators: {},

@@ -817,4 +832,4 @@ visited: false

}
if (validate) {
state.fields[name].validators[index] = validate;
if (fieldConfig && fieldConfig.validate) {
state.fields[name].validators[index] = fieldConfig.validate;
}

@@ -830,3 +845,3 @@

runValidation(function () {
runValidation(undefined, function () {
notifyFormListeners();

@@ -846,3 +861,3 @@ if (!sentFirstNotification) {

}
runValidation(function () {
runValidation(undefined, function () {
notifyFieldListeners();

@@ -849,0 +864,0 @@ notifyFormListeners();

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

var initial = initialValues && getIn(initialValues, name);
var pristine = initial === value;
var pristine = field.isEqual(initial, value);
var valid = !error && !submitError;

@@ -319,3 +319,3 @@ return {

//
var subscriptionFilter = function (dest, src, previous, subscription, keys, shallowEqualKeys) {
function subscriptionFilter (dest, src, previous, subscription, keys, shallowEqualKeys) {
var different = false;

@@ -331,3 +331,3 @@ keys.forEach(function (key) {

return different;
};
}

@@ -393,2 +393,6 @@ //

var tripleEquals = function tripleEquals(a, b) {
return a === b;
};
var convertToExternalFormState = function convertToExternalFormState(_ref) {

@@ -510,3 +514,3 @@ var active = _ref.active,

state.fields = mutatableState.fields;
runValidation(function () {
runValidation(undefined, function () {
notifyFieldListeners();

@@ -555,3 +559,3 @@ notifyFormListeners();

var runValidation = function runValidation(callback) {
var runValidation = function runValidation(fieldChanged, callback) {
var fields = state.fields,

@@ -570,2 +574,11 @@ formState = state.formState;

// pare down field keys to actually validate
if (fieldChanged) {
var validateFields = fields[fieldChanged].validateFields;
if (validateFields) {
fieldKeys = validateFields.length ? validateFields.concat(fieldChanged) : [fieldChanged];
}
}
var recordLevelErrors = {};

@@ -654,3 +667,3 @@ var fieldLevelErrors = {};

formState.pristine = fieldKeys.every(function (key) {
return getIn(formState.values, key) === getIn(formState.initialValues, key);
return fields[key].isEqual(getIn(formState.values, key), getIn(formState.initialValues, key));
});

@@ -708,3 +721,3 @@ formState.valid = !formState.error && !formState.submitError && !Object.keys(formState.errors).length && !(formState.submitErrors && Object.keys(formState.submitErrors).length);

if (validateOnBlur) {
runValidation(function () {
runValidation(name, function () {
notifyFieldListeners();

@@ -732,3 +745,3 @@ notifyFormListeners();

} else {
runValidation(function () {
runValidation(name, function () {
notifyFieldListeners();

@@ -773,3 +786,3 @@ notifyFormListeners();

});
runValidation(function () {
runValidation(undefined, function () {
notifyFieldListeners();

@@ -782,3 +795,3 @@ notifyFormListeners();

var subscription = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var validate = arguments[3];
var fieldConfig = arguments[3];

@@ -812,2 +825,3 @@ if (!state.fieldSubscribers[name]) {

initial: initial,
isEqual: fieldConfig && fieldConfig.isEqual || tripleEquals,
lastFieldState: undefined,

@@ -818,2 +832,3 @@ name: name,

valid: true,
validateFields: fieldConfig && fieldConfig.validateFields,
validators: {},

@@ -823,4 +838,4 @@ visited: false

}
if (validate) {
state.fields[name].validators[index] = validate;
if (fieldConfig && fieldConfig.validate) {
state.fields[name].validators[index] = fieldConfig.validate;
}

@@ -836,3 +851,3 @@

runValidation(function () {
runValidation(undefined, function () {
notifyFormListeners();

@@ -852,3 +867,3 @@ if (!sentFirstNotification) {

}
runValidation(function () {
runValidation(undefined, function () {
notifyFieldListeners();

@@ -855,0 +870,0 @@ notifyFormListeners();

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e["final-form"]={})}(this,function(e){"use strict";function t(e,t,r,i,n){var o=n(r,i,t,arguments.length>5&&void 0!==arguments[5]&&arguments[5]);o&&e(o)}function r(e,r,i,n){var o=e.entries;Object.keys(o).forEach(function(e){var a=o[Number(e)],u=a.subscription;t(a.subscriber,u,r,i,n)})}var i=function(e){if(null===e||void 0===e)return[];if("string"!=typeof e)throw new Error("toPath() expects a string");return e.length?e.split(/[.[\]]+/).filter(Boolean):[]},n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},u=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)},s=function(e,t){var r=i(t),o=e,a=!0,u=!1,s=void 0;try{for(var l,f=r[Symbol.iterator]();!(a=(l=f.next()).done);a=!0){var c=l.value;if(void 0===o||null===o||"object"!==(void 0===o?"undefined":n(o))||Array.isArray(o)&&isNaN(c))return;o=o[c]}}catch(e){u=!0,s=e}finally{try{!a&&f.return&&f.return()}finally{if(u)throw s}}return o},l=function(e,t,r){if(void 0===e||null===e)throw new Error("Cannot call setIn() with "+String(e)+" state");if(void 0===t||null===t)throw new Error("Cannot call setIn() with "+String(t)+" key");return function e(t,r,i,n){if(r>=i.length)return n;var s=i[r];if(isNaN(s)){if(void 0===t||null===t){var l=e(void 0,r+1,i,n);return void 0===l?void 0:o({},s,l)}if(Array.isArray(t))throw new Error("Cannot set a non-numeric property on an array");var f=e(t[s],r+1,i,n),c=Object.keys(t).length;if(void 0===f){if(void 0===t[s]&&0===c)return;if(void 0!==t[s]&&c<=1)return isNaN(i[r-1])?void 0:{}}return a({},t,o({},s,f))}var d=Number(s);if(void 0===t||null===t){var v=e(void 0,r+1,i,n);if(void 0===v)return;var b=[];return b[d]=v,b}if(!Array.isArray(t))throw new Error("Cannot set a numeric property on an object");var m=e(t[d],r+1,i,n),y=[].concat(u(t));return void 0===m?y.splice(d,1):y[d]=m,y}(e,0,i(t),r)},f=function(e,t){var r=e.errors,i=e.initialValues,n=e.submitErrors,o=e.submitFailed,a=e.submitSucceeded,u=e.values,l=t.active,f=t.blur,c=t.change,d=t.data,v=t.focus,b=t.name,m=t.touched,y=t.visited,h=s(u,b),S=s(r,b),g=n&&s(n,b),p=i&&s(i,b),E=p===h,O=!S&&!g;return{active:l,blur:f,change:c,data:d,dirty:!E,error:S,focus:v,initial:p,invalid:!O,length:Array.isArray(h)?h.length:void 0,name:b,pristine:E,submitError:g,submitFailed:o,submitSucceeded:a,touched:m,valid:O,value:h,visited:y}},c=["active","data","dirty","error","initial","invalid","length","pristine","submitError","submitFailed","submitSucceeded","touched","valid","value","visited"],d=function(e,t){if(e===t)return!0;if("object"!==(void 0===e?"undefined":n(e))||!e||"object"!==(void 0===t?"undefined":n(t))||!t)return!1;var r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(var o=Object.prototype.hasOwnProperty.bind(t),a=0;a<r.length;a++){var u=r[a];if(!o(u)||e[u]!==t[u])return!1}return!0},v=function(e,t,r,i,n,o){var a=!1;return n.forEach(function(n){i[n]&&(e[n]=t[n],r&&(~o.indexOf(n)?d(t[n],r[n]):t[n]===r[n])||(a=!0))}),a},b=["data"],m=function(e,t,r,i){var n={blur:e.blur,change:e.change,focus:e.focus,name:e.name};return v(n,e,t,r,c,b)||!t||i?n:void 0},y=["active","dirty","error","errors","initialValues","invalid","pristine","submitting","submitError","submitErrors","submitFailed","submitSucceeded","valid","validating","values"],h=[],S=function(e,t,r,i){var n={};return v(n,e,t,r,y,h)||!t||i?n:void 0},g=function(e){var t=void 0,r=void 0;return function(){for(var i=arguments.length,n=Array(i),o=0;o<i;o++)n[o]=arguments[o];return t&&n.length===t.length&&!n.some(function(e,r){return!d(t[r],e)})||(t=n,r=e.apply(void 0,n)),r}},p=function(e){return!!e&&("object"===(void 0===e?"undefined":n(e))||"function"==typeof e)&&"function"==typeof e.then},E=Symbol("form-error"),O=function(e){var t=e.active,r=e.error,i=e.errors,n=e.initialValues,o=e.pristine,a=e.submitting,u=e.submitFailed,s=e.submitSucceeded,l=e.submitError,f=e.submitErrors,c=e.valid;return{active:t,dirty:!o,error:r,errors:i,invalid:!c,initialValues:n,pristine:o,submitting:a,submitFailed:u,submitSucceeded:s,submitError:l,submitErrors:f,valid:c,validating:e.validating>0,values:e.values}};e.createForm=function(e){if(!e)throw new Error("No config specified");e.debug;var i=e.initialValues,n=e.mutators,o=e.onSubmit,c=e.validate,v=e.validateOnBlur;if(!o)throw new Error("No onSubmit function specified");var b={subscribers:{index:0,entries:{}},fieldSubscribers:{},fields:{},formState:{dirty:!1,errors:{},initialValues:i&&a({},i),invalid:!1,pristine:!0,submitting:!1,submitFailed:!1,submitSucceeded:!1,valid:!0,validating:0,values:i?a({},i):{}},lastFormState:void 0},y=!1,h=function(e,t,r){if(e.fields[t]){var i=r(s(e.formState.values,t));e.formState.values=l(e.formState.values,t,i)||{}}},j=n&&Object.keys(n).reduce(function(e,t){return e[t]=function(){for(var e=arguments.length,r=Array(e),i=0;i<e;i++)r[i]=arguments[i];var o={formState:b.formState,fields:b.fields},a=n[t](r,o,{changeValue:h,getIn:s,setIn:l,shallowEqual:d});return b.formState=o.formState,b.fields=o.fields,w(function(){F(),A()}),a},e},{}),w=function(e){var t=b.fields,r=b.formState,i=Object.keys(t);if(c||i.some(function(e){return t[e].validators&&Object.keys(t[e].validators).length})){var n={},o={},f=[].concat(u(function(e){var t=[];if(c){var r=c(a({},b.formState.values));p(r)?t.push(r.then(e)):e(r)}return t}(function(e){n=e||{}})),u(i.reduce(function(e,r){return e.concat(function(e,t){var r=e.validators,i=[];if(Object.keys(r).length){var n=void 0;Object.keys(r).forEach(function(o){var a=(0,r[Number(o)])(s(b.formState.values,e.name),b.formState.values);a&&p(a)?i.push(a.then(t)):n||(n=a)}),t(n)}return i}(t[r],function(e){o[r]=e}))},[]))),v=function(){var e=a({},n);i.forEach(function(r){if(t[r]){var i=o[r]||s(n,r);i&&(e=l(e,r,i))}}),d(r.errors,e)||(r.errors=e),r.error=n[E]};v(),f.length?(b.formState.validating++,e&&e(),Promise.all(f).then(function(){b.formState.validating--,v(),e&&e()})):e&&e()}else e&&e()},F=function(e){if(!y){var t=b.fields,i=b.fieldSubscribers,n=b.formState;Object.keys(t).forEach(function(e){var o=t[e],a=f(n,o),u=o.lastFieldState;d(a,u)||(o.lastFieldState=a,r(i[e],a,u,m))})}},k=function(){var e=b.fields,t=b.formState,r=b.lastFormState,i=Object.keys(e);t.pristine=i.every(function(e){return s(t.values,e)===s(t.initialValues,e)}),t.valid=!(t.error||t.submitError||Object.keys(t.errors).length||t.submitErrors&&Object.keys(t.submitErrors).length);var n=O(t);return r&&d(r,n)?r:n},A=function(){if(!y){var e=b.lastFormState,t=k();t!==e&&(b.lastFormState=t,r(b.subscribers,t,e,S))}};w();var N={batch:function(e){y=!0,e(),y=!1,F(),A()},blur:function(e){var t=b.fields,r=b.formState,i=t[e];i&&(delete r.active,t[e]=a({},i,{active:!1,touched:!0}),v?w(function(){F(),A()}):(F(),A()))},change:function(e,t){var r=b.fields,i=b.formState;r[e]&&s(i.values,e)!==t&&(h(b,e,function(){return t}),v?(F(),A()):w(function(){F(),A()}))},focus:function(e){var t=b.fields[e];t&&!t.active&&(b.formState.active=e,t.active=!0,t.visited=!0,F(),A())},mutators:j,getRegisteredFields:function(){return Object.keys(b.fields)},getState:function(){return O(b.formState)},initialize:function(e){var t=b.fields,r=b.formState;r.initialValues=e,r.values=e,Object.keys(t).forEach(function(e){var r=t[e];r.touched=!1,r.visited=!1}),w(function(){F(),A()})},registerField:function(e,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments[3];b.fieldSubscribers[e]||(b.fieldSubscribers[e]={index:0,entries:{}});var o=b.fieldSubscribers[e].index++;if(b.fieldSubscribers[e].entries[o]={subscriber:g(r),subscription:i},!b.fields[e]){var a=b.formState.initialValues?s(b.formState.initialValues,e):void 0;b.fields[e]={active:!1,blur:function(){return N.blur(e)},change:function(t){return N.change(e,t)},data:{},focus:function(){return N.focus(e)},initial:a,lastFieldState:void 0,name:e,pristine:!0,touched:!1,valid:!0,validators:{},visited:!1}}n&&(b.fields[e].validators[o]=n);var u=!1;return w(function(){A(),u||function(){var n=f(b.formState,b.fields[e]);t(r,i,n,void 0,m,!0),b.fields[e].lastFieldState=n,u=!0}(),F()}),function(){delete b.fields[e].validators[o],delete b.fieldSubscribers[e].entries[o],Object.keys(b.fieldSubscribers[e].entries).length||(delete b.fieldSubscribers[e],delete b.fields[e]),w(function(){F(),A()})}},reset:function(){N.initialize(b.formState.initialValues||{})},submit:function(){var e=b.formState,t=b.fields;if(b.formState.error||Object.keys(b.formState.errors).length)return Object.keys(t).forEach(function(e){t[e].touched=!0}),void F();var r=void 0,i=!1,n=function(t){e.submitting=!1,t&&(Object.keys(t).length||Object.getOwnPropertySymbols(t).length)?(e.submitFailed=!0,e.submitSucceeded=!1,e.submitErrors=t,e.submitError=t[E]):(delete e.submitErrors,delete e.submitError,e.submitFailed=!1,e.submitSucceeded=!0),A(),F(),i=!0,r&&r()};if(e.submitting=!0,e.submitFailed=!1,e.submitSucceeded=!1,2===o.length){if(o(e.values,n),!i)return A(),new Promise(function(e){r=e})}else{var a=o(e.values);if(a&&p(a))return A(),a.then(n);n(a)}},subscribe:function(e,r){if(!e)throw new Error("No callback given.");if(!r)throw new Error("No subscription provided. What values do you want to listen to?");var i=g(e),n=b.subscribers,o=b.lastFormState,a=n.index++;n.entries[a]={subscriber:i,subscription:r};var u=k();return u!==o&&(b.lastFormState=u),t(i,r,u,u,S,!0),function(){delete n.entries[a]}}};return N},e.FORM_ERROR=E,e.version="1.3.5",e.formSubscriptionItems=y,e.fieldSubscriptionItems=c,e.getIn=s,e.setIn=l,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e["final-form"]={})}(this,function(e){"use strict";function t(e,t,r,i,n,o){var a=!1;return n.forEach(function(n){i[n]&&(e[n]=t[n],r&&(~o.indexOf(n)?v(t[n],r[n]):t[n]===r[n])||(a=!0))}),a}function r(e,t,r,i,n){var o=n(r,i,t,arguments.length>5&&void 0!==arguments[5]&&arguments[5]);o&&e(o)}function i(e,t,i,n){var o=e.entries;Object.keys(o).forEach(function(e){var a=o[Number(e)],u=a.subscription;r(a.subscriber,u,t,i,n)})}var n=function(e){if(null===e||void 0===e)return[];if("string"!=typeof e)throw new Error("toPath() expects a string");return e.length?e.split(/[.[\]]+/).filter(Boolean):[]},o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},s=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)},l=function(e,t){var r=n(t),i=e,a=!0,u=!1,s=void 0;try{for(var l,f=r[Symbol.iterator]();!(a=(l=f.next()).done);a=!0){var c=l.value;if(void 0===i||null===i||"object"!==(void 0===i?"undefined":o(i))||Array.isArray(i)&&isNaN(c))return;i=i[c]}}catch(e){u=!0,s=e}finally{try{!a&&f.return&&f.return()}finally{if(u)throw s}}return i},f=function(e,t,r){if(void 0===e||null===e)throw new Error("Cannot call setIn() with "+String(e)+" state");if(void 0===t||null===t)throw new Error("Cannot call setIn() with "+String(t)+" key");return function e(t,r,i,n){if(r>=i.length)return n;var o=i[r];if(isNaN(o)){if(void 0===t||null===t){var l=e(void 0,r+1,i,n);return void 0===l?void 0:a({},o,l)}if(Array.isArray(t))throw new Error("Cannot set a non-numeric property on an array");var f=e(t[o],r+1,i,n),c=Object.keys(t).length;if(void 0===f){if(void 0===t[o]&&0===c)return;if(void 0!==t[o]&&c<=1)return isNaN(i[r-1])?void 0:{}}return u({},t,a({},o,f))}var d=Number(o);if(void 0===t||null===t){var v=e(void 0,r+1,i,n);if(void 0===v)return;var b=[];return b[d]=v,b}if(!Array.isArray(t))throw new Error("Cannot set a numeric property on an object");var m=e(t[d],r+1,i,n),h=[].concat(s(t));return void 0===m?h.splice(d,1):h[d]=m,h}(e,0,n(t),r)},c=function(e,t){var r=e.errors,i=e.initialValues,n=e.submitErrors,o=e.submitFailed,a=e.submitSucceeded,u=e.values,s=t.active,f=t.blur,c=t.change,d=t.data,v=t.focus,b=t.name,m=t.touched,h=t.visited,y=l(u,b),S=l(r,b),g=n&&l(n,b),p=i&&l(i,b),E=t.isEqual(p,y),O=!S&&!g;return{active:s,blur:f,change:c,data:d,dirty:!E,error:S,focus:v,initial:p,invalid:!O,length:Array.isArray(y)?y.length:void 0,name:b,pristine:E,submitError:g,submitFailed:o,submitSucceeded:a,touched:m,valid:O,value:y,visited:h}},d=["active","data","dirty","error","initial","invalid","length","pristine","submitError","submitFailed","submitSucceeded","touched","valid","value","visited"],v=function(e,t){if(e===t)return!0;if("object"!==(void 0===e?"undefined":o(e))||!e||"object"!==(void 0===t?"undefined":o(t))||!t)return!1;var r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(var n=Object.prototype.hasOwnProperty.bind(t),a=0;a<r.length;a++){var u=r[a];if(!n(u)||e[u]!==t[u])return!1}return!0},b=["data"],m=function(e,r,i,n){var o={blur:e.blur,change:e.change,focus:e.focus,name:e.name};return t(o,e,r,i,d,b)||!r||n?o:void 0},h=["active","dirty","error","errors","initialValues","invalid","pristine","submitting","submitError","submitErrors","submitFailed","submitSucceeded","valid","validating","values"],y=[],S=function(e,r,i,n){var o={};return t(o,e,r,i,h,y)||!r||n?o:void 0},g=function(e){var t=void 0,r=void 0;return function(){for(var i=arguments.length,n=Array(i),o=0;o<i;o++)n[o]=arguments[o];return t&&n.length===t.length&&!n.some(function(e,r){return!v(t[r],e)})||(t=n,r=e.apply(void 0,n)),r}},p=function(e){return!!e&&("object"===(void 0===e?"undefined":o(e))||"function"==typeof e)&&"function"==typeof e.then},E=Symbol("form-error"),O=function(e){var t=e.active,r=e.error,i=e.errors,n=e.initialValues,o=e.pristine,a=e.submitting,u=e.submitFailed,s=e.submitSucceeded,l=e.submitError,f=e.submitErrors,c=e.valid;return{active:t,dirty:!o,error:r,errors:i,invalid:!c,initialValues:n,pristine:o,submitting:a,submitFailed:u,submitSucceeded:s,submitError:l,submitErrors:f,valid:c,validating:e.validating>0,values:e.values}};e.createForm=function(e){if(!e)throw new Error("No config specified");e.debug;var t=e.initialValues,n=e.mutators,o=e.onSubmit,a=e.validate,d=e.validateOnBlur;if(!o)throw new Error("No onSubmit function specified");var b={subscribers:{index:0,entries:{}},fieldSubscribers:{},fields:{},formState:{dirty:!1,errors:{},initialValues:t&&u({},t),invalid:!1,pristine:!0,submitting:!1,submitFailed:!1,submitSucceeded:!1,valid:!0,validating:0,values:t?u({},t):{}},lastFormState:void 0},h=!1,y=function(e,t,r){if(e.fields[t]){var i=r(l(e.formState.values,t));e.formState.values=f(e.formState.values,t,i)||{}}},j=n&&Object.keys(n).reduce(function(e,t){return e[t]=function(){for(var e=arguments.length,r=Array(e),i=0;i<e;i++)r[i]=arguments[i];var o={formState:b.formState,fields:b.fields},a=n[t](r,o,{changeValue:y,getIn:l,setIn:f,shallowEqual:v});return b.formState=o.formState,b.fields=o.fields,w(void 0,function(){F(),A()}),a},e},{}),w=function(e,t){var r=b.fields,i=b.formState,n=Object.keys(r);if(a||n.some(function(e){return r[e].validators&&Object.keys(r[e].validators).length})){if(e){var o=r[e].validateFields;o&&(n=o.length?o.concat(e):[e])}var c={},d={},m=[].concat(s(function(e){var t=[];if(a){var r=a(u({},b.formState.values));p(r)?t.push(r.then(e)):e(r)}return t}(function(e){c=e||{}})),s(n.reduce(function(e,t){return e.concat(function(e,t){var r=e.validators,i=[];if(Object.keys(r).length){var n=void 0;Object.keys(r).forEach(function(o){var a=(0,r[Number(o)])(l(b.formState.values,e.name),b.formState.values);a&&p(a)?i.push(a.then(t)):n||(n=a)}),t(n)}return i}(r[t],function(e){d[t]=e}))},[]))),h=function(){var e=u({},c);n.forEach(function(t){if(r[t]){var i=d[t]||l(c,t);i&&(e=f(e,t,i))}}),v(i.errors,e)||(i.errors=e),i.error=c[E]};h(),m.length?(b.formState.validating++,t&&t(),Promise.all(m).then(function(){b.formState.validating--,h(),t&&t()})):t&&t()}else t&&t()},F=function(e){if(!h){var t=b.fields,r=b.fieldSubscribers,n=b.formState;Object.keys(t).forEach(function(e){var o=t[e],a=c(n,o),u=o.lastFieldState;v(a,u)||(o.lastFieldState=a,i(r[e],a,u,m))})}},k=function(){var e=b.fields,t=b.formState,r=b.lastFormState,i=Object.keys(e);t.pristine=i.every(function(r){return e[r].isEqual(l(t.values,r),l(t.initialValues,r))}),t.valid=!(t.error||t.submitError||Object.keys(t.errors).length||t.submitErrors&&Object.keys(t.submitErrors).length);var n=O(t);return r&&v(r,n)?r:n},A=function(){if(!h){var e=b.lastFormState,t=k();t!==e&&(b.lastFormState=t,i(b.subscribers,t,e,S))}};w();var N={batch:function(e){h=!0,e(),h=!1,F(),A()},blur:function(e){var t=b.fields,r=b.formState,i=t[e];i&&(delete r.active,t[e]=u({},i,{active:!1,touched:!0}),d?w(e,function(){F(),A()}):(F(),A()))},change:function(e,t){var r=b.fields,i=b.formState;r[e]&&l(i.values,e)!==t&&(y(b,e,function(){return t}),d?(F(),A()):w(e,function(){F(),A()}))},focus:function(e){var t=b.fields[e];t&&!t.active&&(b.formState.active=e,t.active=!0,t.visited=!0,F(),A())},mutators:j,getRegisteredFields:function(){return Object.keys(b.fields)},getState:function(){return O(b.formState)},initialize:function(e){var t=b.fields,r=b.formState;r.initialValues=e,r.values=e,Object.keys(t).forEach(function(e){var r=t[e];r.touched=!1,r.visited=!1}),w(void 0,function(){F(),A()})},registerField:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments[3];b.fieldSubscribers[e]||(b.fieldSubscribers[e]={index:0,entries:{}});var o=b.fieldSubscribers[e].index++;if(b.fieldSubscribers[e].entries[o]={subscriber:g(t),subscription:i},!b.fields[e]){var a=b.formState.initialValues?l(b.formState.initialValues,e):void 0;b.fields[e]={active:!1,blur:function(){return N.blur(e)},change:function(t){return N.change(e,t)},data:{},focus:function(){return N.focus(e)},initial:a,isEqual:n&&n.isEqual||function(e,t){return e===t},lastFieldState:void 0,name:e,pristine:!0,touched:!1,valid:!0,validateFields:n&&n.validateFields,validators:{},visited:!1}}n&&n.validate&&(b.fields[e].validators[o]=n.validate);var u=!1;return w(void 0,function(){A(),u||function(){var n=c(b.formState,b.fields[e]);r(t,i,n,void 0,m,!0),b.fields[e].lastFieldState=n,u=!0}(),F()}),function(){delete b.fields[e].validators[o],delete b.fieldSubscribers[e].entries[o],Object.keys(b.fieldSubscribers[e].entries).length||(delete b.fieldSubscribers[e],delete b.fields[e]),w(void 0,function(){F(),A()})}},reset:function(){N.initialize(b.formState.initialValues||{})},submit:function(){var e=b.formState,t=b.fields;if(b.formState.error||Object.keys(b.formState.errors).length)return Object.keys(t).forEach(function(e){t[e].touched=!0}),void F();var r=void 0,i=!1,n=function(t){e.submitting=!1,t&&(Object.keys(t).length||Object.getOwnPropertySymbols(t).length)?(e.submitFailed=!0,e.submitSucceeded=!1,e.submitErrors=t,e.submitError=t[E]):(delete e.submitErrors,delete e.submitError,e.submitFailed=!1,e.submitSucceeded=!0),A(),F(),i=!0,r&&r()};if(e.submitting=!0,e.submitFailed=!1,e.submitSucceeded=!1,2===o.length){if(o(e.values,n),!i)return A(),new Promise(function(e){r=e})}else{var a=o(e.values);if(a&&p(a))return A(),a.then(n);n(a)}},subscribe:function(e,t){if(!e)throw new Error("No callback given.");if(!t)throw new Error("No subscription provided. What values do you want to listen to?");var i=g(e),n=b.subscribers,o=b.lastFormState,a=n.index++;n.entries[a]={subscriber:i,subscription:t};var u=k();return u!==o&&(b.lastFormState=u),r(i,t,u,u,S,!0),function(){delete n.entries[a]}}};return N},e.FORM_ERROR=E,e.version="1.3.5",e.formSubscriptionItems=h,e.fieldSubscriptionItems=d,e.getIn=l,e.setIn=f,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=final-form.umd.min.js.map
export type Subscription = { [key: string]: boolean }
export type Subscriber<V> = (value: V) => void
export type IsEqual = (a: any, b: any) => boolean
export type FormSubscription = Partial<{
active: boolean,
dirty: boolean,
error: boolean,
errors: boolean,
initialValues: boolean,
invalid: boolean,
pristine: boolean,
submitError: boolean,
submitErrors: boolean,
submitFailed: boolean,
submitSucceeded: boolean,
submitting: boolean,
valid: boolean,
validating: boolean,
active: boolean
dirty: boolean
error: boolean
errors: boolean
initialValues: boolean
invalid: boolean
pristine: boolean
submitError: boolean
submitErrors: boolean
submitFailed: boolean
submitSucceeded: boolean
submitting: boolean
valid: boolean
validating: boolean
values: boolean
}> & Subscription
}> &
Subscription
export type FormState = Partial<{
// all values are optional because they must be subscribed to
active: string,
dirty: boolean,
error: any,
errors: object,
initialValues: object,
invalid: boolean,
pristine: boolean,
submitError: any,
submitErrors: object,
submitFailed: boolean,
submitSucceeded: boolean,
submitting: boolean,
valid: boolean,
validating: boolean,
active: string
dirty: boolean
error: any
errors: object
initialValues: object
invalid: boolean
pristine: boolean
submitError: any
submitErrors: object
submitFailed: boolean
submitSucceeded: boolean
submitting: boolean
valid: boolean
validating: boolean
values: object

@@ -44,20 +46,20 @@ }>

export type FieldState = {
active?: boolean,
blur: () => void,
change: (value: any) => void,
data?: object,
dirty?: boolean,
error?: any,
focus: () => void,
initial?: any,
invalid?: boolean,
length?: number,
name: string,
pristine?: boolean,
submitError?: any,
submitFailed?: boolean,
submitSucceeded?: boolean,
touched?: boolean,
valid?: boolean,
value?: any,
active?: boolean
blur: () => void
change: (value: any) => void
data?: object
dirty?: boolean
error?: any
focus: () => void
initial?: any
invalid?: boolean
length?: number
name: string
pristine?: boolean
submitError?: any
submitFailed?: boolean
submitSucceeded?: boolean
touched?: boolean
valid?: boolean
value?: any
visited?: boolean

@@ -67,18 +69,19 @@ }

export type FieldSubscription = Partial<{
active: boolean,
data: boolean,
dirty: boolean,
error: boolean,
initial: boolean,
invalid: boolean,
length: boolean,
pristine: boolean,
submitError: boolean,
submitFailed: boolean,
submitSucceeded: boolean,
touched: boolean,
valid: boolean,
value: boolean,
active: boolean
data: boolean
dirty: boolean
error: boolean
initial: boolean
invalid: boolean
length: boolean
pristine: boolean
submitError: boolean
submitFailed: boolean
submitSucceeded: boolean
touched: boolean
valid: boolean
value: boolean
visited: boolean
}> & Subscription
}> &
Subscription

@@ -89,2 +92,8 @@ export type FieldSubscriber = Subscriber<FieldState>

export type FieldConfig = Partial<{
isEqual: IsEqual
validate: (value: any, allValues: object) => any
validateFields: string[]
}>
export type RegisterField = (

@@ -94,22 +103,24 @@ name: string,

subscription: FieldSubscription,
validate?: (value: any, allValues: object) => any
config: FieldConfig
) => Unsubscribe
export type InternalFieldState = {
active: boolean,
blur: () => void,
change: (value: any) => void,
data: object,
error?: any,
focus: () => void,
lastFieldState?: FieldState,
length?: any,
name: string,
submitError?: any,
pristine: boolean,
touched: boolean,
active: boolean
blur: () => void
change: (value: any) => void
data: object
error?: any
focus: () => void
isEqual: IsEqual
lastFieldState?: FieldState
length?: any
name: string
submitError?: any
pristine: boolean
touched: boolean
validateFields?: string[]
validators: {
[index: number]: (value: any, allValues: object) => any | Promise<any>
},
valid: boolean,
}
valid: boolean
visited: boolean

@@ -119,14 +130,14 @@ }

export type InternalFormState = {
active?: string,
error?: any,
errors: object,
initialValues?: object,
pristine: boolean,
submitError?: any,
submitErrors?: object,
submitFailed: boolean,
submitSucceeded: boolean,
submitting: boolean,
valid: boolean,
validating: number,
active?: string
error?: any
errors: object
initialValues?: object
pristine: boolean
submitError?: any
submitErrors?: object
submitFailed: boolean
submitSucceeded: boolean
submitting: boolean
valid: boolean
validating: number
values: object

@@ -136,16 +147,16 @@ }

export type FormApi = {
batch: (fn: () => void) => void,
blur: (name: string) => void,
change: (name: string, value?: any) => void,
focus: (name: string) => void,
initialize: (values: object) => void,
getRegisteredFields: () => string[],
getState: () => FormState,
mutators?: { [key: string]: Function },
submit: () => Promise<object | undefined> | undefined,
batch: (fn: () => void) => void
blur: (name: string) => void
change: (name: string, value?: any) => void
focus: (name: string) => void
initialize: (values: object) => void
getRegisteredFields: () => string[]
getState: () => FormState
mutators?: { [key: string]: Function }
submit: () => Promise<object | undefined> | undefined
subscribe: (
subscriber: FormSubscriber,
subscription: FormSubscription
) => Unsubscribe,
registerField: RegisterField,
) => Unsubscribe
registerField: RegisterField
reset: () => void

@@ -160,3 +171,3 @@ }

export type MutableState = {
formState: InternalFormState,
formState: InternalFormState
fields: {

@@ -169,3 +180,2 @@ [key: string]: InternalFieldState

export type SetIn = (state: object, key: string, value: any) => object
export type ShallowEqual = (a: any, b: any) => boolean
export type ChangeValue = (

@@ -177,6 +187,6 @@ state: MutableState,

export type Tools = {
changeValue: ChangeValue,
getIn: GetIn,
setIn: SetIn,
shallowEqual: ShallowEqual
changeValue: ChangeValue
getIn: GetIn
setIn: SetIn
shallowEqual: IsEqual
}

@@ -187,10 +197,10 @@

export type Config = {
debug?: DebugFunction,
initialValues?: object,
mutators?: { [key: string]: Mutator },
debug?: DebugFunction
initialValues?: object
mutators?: { [key: string]: Mutator }
onSubmit: (
values: object,
callback?: (errors?: object) => void
) => object | Promise<object | undefined> | undefined | void,
validate?: (values: object) => object | Promise<object>,
) => object | Promise<object | undefined> | undefined | void
validate?: (values: object) => object | Promise<object>
validateOnBlur?: boolean

@@ -197,0 +207,0 @@ }

{
"name": "final-form",
"version": "1.3.5",
"version": "2.0.0",
"description":

@@ -9,2 +9,3 @@ "🏁 Framework agnostic, high performance, subscription-based form state management",

"module": "dist/final-form.es.js",
"typings": "dist/index.d.js",
"files": ["dist"],

@@ -28,3 +29,3 @@ "scripts": {

"devDependencies": {
"babel-eslint": "^8.0.2",
"babel-eslint": "^8.0.3",
"babel-jest": "^21.2.0",

@@ -37,19 +38,19 @@ "babel-plugin-external-helpers": "^6.22.0",

"doctoc": "^1.3.0",
"eslint": "^4.11.0",
"eslint": "^4.13.1",
"eslint-config-react-app": "^2.0.1",
"eslint-plugin-babel": "^4.1.2",
"eslint-plugin-flowtype": "^2.37.0",
"eslint-plugin-flowtype": "^2.40.1",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.5.1",
"flow": "^0.2.3",
"flow-bin": "^0.59.0",
"flow-bin": "^0.61.0",
"husky": "^0.14.3",
"jest": "^21.2.1",
"lint-staged": "^5.0.0",
"lint-staged": "^6.0.0",
"nps": "^5.7.1",
"nps-utils": "^1.5.0",
"prettier": "^1.8.2",
"prettier-eslint-cli": "^4.4.0",
"rollup": "^0.51.8",
"prettier": "^1.9.2",
"prettier-eslint-cli": "^4.6.1",
"rollup": "^0.52.2",
"rollup-plugin-babel": "^3.0.2",

@@ -63,3 +64,3 @@ "rollup-plugin-commonjs": "^8.2.6",

"lint-staged": {
"*.{js,json,md,css}": ["prettier --write", "git add"]
"*.{js*,ts,json,md,css}": ["prettier --write", "git add"]
},

@@ -66,0 +67,0 @@ "bundlesize": [

@@ -101,2 +101,4 @@ # 🏁 Final Form

* [`FORM_ERROR: Symbol`](#form_error-symbol)
* [`getIn(state: Object, complexKey: string): any`](#getinstate-object-complexkey-string-any)
* [`setIn(state: Object, key: string, value: any): Object`](#setinstate-object-key-string-value-any-object)
* [`version: string`](#version-string)

@@ -113,2 +115,6 @@ * [Types](#types)

* [`Decorator: (form: FormApi) => Unsubscribe`](#decorator-form-formapi--unsubscribe)
* [`FieldConfig`](#fieldconfig)
* [`isEqual?: (a: any, b: any) => boolean`](#isequal-a-any-b-any--boolean)
* [`validate?: (value: ?any, allValues: Object) => ?any`](#validate-value-any-allvalues-object--any)
* [`validateFields?: string[]`](#validatefields-string)
* [`FieldState`](#fieldstate)

@@ -203,8 +209,9 @@ * [`active?: boolean`](#active-boolean)

* [`focus: () => void`](#focus---void-1)
* [`initial?: any`](#initial-any-1)
* [`isEqual: (a: any, b: any) => boolean`](#isequal-a-any-b-any--boolean)
* [`name: string`](#name-string-1)
* [`pristine: boolean`](#pristine-boolean)
* [`touched: boolean`](#touched-boolean)
* [`validateFields: ?(string[])`](#validatefields-string)
* [`validators: { [number]: (value: ?any, allValues: Object) => ?any | Promise<?any> } }`](#validators--number-value-any-allvalues-object--any--promiseany--)
* [`valid: boolean`](#valid-boolean)
* [`value?: any`](#value-any-1)
* [`visited: boolean`](#visited-boolean)

@@ -225,5 +232,7 @@ * [`InternalFormState`](#internalformstate)

* [`values: Object`](#values-object)
* [`MutableState: { formState: InternalFormState, fields: { [string]: InternalFieldState } }`](#mutablestate--formstate-internalformstate-fields--string-internalfieldstate--)
* [`MutableState`](#mutablestate)
* [`formState: InternalFormState`](#formstate-internalformstate)
* [`fields: { [string]: InternalFieldState }`](#fields--string-internalfieldstate-)
* [`Mutator: (args: any[], state: MutableState, tools: Tools) => any`](#mutator-args-any-state-mutablestate-tools-tools--any)
* [`RegisterField: (name: string, subscriber: FieldSubscriber, subscription: FieldSubscription, validate?: (value: ?any, allValues: Object) => ?any) => Unsubscribe`](#registerfield-name-string-subscriber-fieldsubscriber-subscription-fieldsubscription-validate-value-any-allvalues-object--any--unsubscribe)
* [`RegisterField: (name: string, subscriber: FieldSubscriber, subscription: FieldSubscription, config?: FieldConfig) => Unsubscribe`](#registerfield-name-string-subscriber-fieldsubscriber-subscription-fieldsubscription-config-fieldconfig--unsubscribe)
* [`Tools`](#tools)

@@ -280,2 +289,6 @@ * [`Tools.changeValue: (state: MutableState, name: string, mutate: (value: any) => any) => void`](#toolschangevalue-state-mutablestate-name-string-mutate-value-any--any--void)

### `getIn(state: Object, complexKey: string): any`
### `setIn(state: Object, key: string, value: any): Object`
### `version: string`

@@ -356,2 +369,21 @@

### `FieldConfig`
#### `isEqual?: (a: any, b: any) => boolean`
A function to determine if two values are equal. Defaults to `===`.
#### `validate?: (value: ?any, allValues: Object) => ?any`
A field-level validation function to validate a single field value. Returns an
error if the value is not valid, or `undefined` if the value is valid.
#### `validateFields?: string[]`
An array of field names to validate when this field changes. If `undefined`,
_every_ field will be validated when this one changes; if `[]`, _only this
field_ will have its field-level validation function called when it changes; if
other field names are specified, those fields _and this one_ will be validated
when this field changes.
### `FieldState`

@@ -775,5 +807,6 @@

#### `initial?: any`
#### `isEqual: (a: any, b: any) => boolean`
The initial value of the field. `undefined` if it was never initialized.
A function to determine if two values are equal. Used to calculate
`pristine`/`dirty`.

@@ -794,2 +827,10 @@ #### `name: string`

#### `validateFields: ?(string[])`
Fields to validate when this field value changes.
#### `validators: { [number]: (value: ?any, allValues: Object) => ?any | Promise<?any> } }`
Field-level validators for each field that is registered.
#### `valid: boolean`

@@ -799,6 +840,2 @@

#### `value?: any`
The value of the field.
#### `visited: boolean`

@@ -875,7 +912,14 @@

### `MutableState: { formState: InternalFormState, fields: { [string]: InternalFieldState } }`
### `MutableState`
A container for the [`InternalFormState`](#internalformstate) and an object of
[`InternalFieldState`](#internalfieldstate)s.
`MutableState` is an object containing the following:
#### `formState: InternalFormState`
The [`InternalFormState`](#internalformstate).
#### `fields: { [string]: InternalFieldState }`
An object of [`InternalFieldState`](#internalfieldstate)s.
### `Mutator: (args: any[], state: MutableState, tools: Tools) => any`

@@ -887,4 +931,9 @@

### `RegisterField: (name: string, subscriber: FieldSubscriber, subscription: FieldSubscription, validate?: (value: ?any, allValues: Object) => ?any) => Unsubscribe`
### `RegisterField: (name: string, subscriber: FieldSubscriber, subscription: FieldSubscription, config?: FieldConfig) => Unsubscribe`
Takes a name, and a
[`FieldSubscriber`](#fieldsubscriber-state-fieldstate--void),
[`FieldSubscriber`](#fieldsubscriber-state-fieldstate--void), and a
[`FieldConfig`](#fieldconfig) and registers a field subscription.
### `Tools`

@@ -891,0 +940,0 @@

Sorry, the diff of this file is not supported yet

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