final-form
Advanced tools
Comparing version 4.10.0 to 4.11.0
@@ -5,20 +5,7 @@ 'use strict'; | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
var _extends = _interopDefault(require('@babel/runtime/helpers/extends')); | ||
var _objectWithoutPropertiesLoose = _interopDefault(require('@babel/runtime/helpers/objectWithoutPropertiesLoose')); | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
// | ||
@@ -57,2 +44,6 @@ var toPath = function toPath(key) { | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
var setInRecursor = function setInRecursor(current, index, path, value) { | ||
@@ -104,2 +95,7 @@ if (index >= path.length) { | ||
} | ||
var _removed = current[key], | ||
final = _objectWithoutPropertiesLoose(current, [key].map(_toPropertyKey)); | ||
return final; | ||
} // set result in key | ||
@@ -171,2 +167,3 @@ | ||
submitSucceeded = formState.submitSucceeded, | ||
submitting = formState.submitting, | ||
values = formState.values; | ||
@@ -210,2 +207,3 @@ var active = field.active, | ||
submitSucceeded: submitSucceeded, | ||
submitting: submitting, | ||
touched: touched, | ||
@@ -219,3 +217,3 @@ valid: valid, | ||
// | ||
var fieldSubscriptionItems = ['active', 'data', 'dirty', 'dirtySinceLastSubmit', 'error', 'initial', 'invalid', 'length', 'pristine', 'submitError', 'submitFailed', 'submitSucceeded', 'touched', 'valid', 'value', 'visited']; | ||
var fieldSubscriptionItems = ['active', 'data', 'dirty', 'dirtySinceLastSubmit', 'error', 'initial', 'invalid', 'length', 'pristine', 'submitError', 'submitFailed', 'submitSucceeded', 'submitting', 'touched', 'valid', 'value', 'visited']; | ||
@@ -1160,9 +1158,16 @@ // | ||
formState.submitSucceeded = false; | ||
formState.lastSubmittedValues = _extends({}, formState.values); | ||
formState.lastSubmittedValues = _extends({}, formState.values); // onSubmit is either sync, callback or async with a Promise | ||
if (onSubmit.length === 3) { | ||
// onSubmit is expecting a callback, first try synchronously | ||
onSubmit(formState.values, api, complete); | ||
var result = onSubmit(formState.values, api, complete); | ||
if (!completeCalled) { | ||
if (!completeCalled) { | ||
if (result && isPromise(result)) { | ||
// onSubmit is async with a Promise | ||
notifyFormListeners(); // let everyone know we are submitting | ||
return result.then(complete, function (error) { | ||
complete(); | ||
throw error; | ||
}); | ||
} else if (onSubmit.length >= 3) { | ||
// must be async, so we should return a Promise | ||
@@ -1174,12 +1179,2 @@ notifyFormListeners(); // let everyone know we are submitting | ||
}); | ||
} | ||
} else { | ||
// onSubmit is either sync or async with a Promise | ||
var result = onSubmit(formState.values, api); | ||
if (result && isPromise(result)) { | ||
// onSubmit is async with a Promise | ||
notifyFormListeners(); // let everyone know we are submitting | ||
return result.then(complete, complete); | ||
} else { | ||
@@ -1186,0 +1181,0 @@ // onSubmit is sync |
@@ -1,19 +0,4 @@ | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
import _extends from '@babel/runtime/helpers/esm/extends'; | ||
import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/esm/objectWithoutPropertiesLoose'; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
// | ||
@@ -52,2 +37,6 @@ var toPath = function toPath(key) { | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
var setInRecursor = function setInRecursor(current, index, path, value) { | ||
@@ -99,2 +88,7 @@ if (index >= path.length) { | ||
} | ||
var _removed = current[key], | ||
final = _objectWithoutPropertiesLoose(current, [key].map(_toPropertyKey)); | ||
return final; | ||
} // set result in key | ||
@@ -166,2 +160,3 @@ | ||
submitSucceeded = formState.submitSucceeded, | ||
submitting = formState.submitting, | ||
values = formState.values; | ||
@@ -205,2 +200,3 @@ var active = field.active, | ||
submitSucceeded: submitSucceeded, | ||
submitting: submitting, | ||
touched: touched, | ||
@@ -214,3 +210,3 @@ valid: valid, | ||
// | ||
var fieldSubscriptionItems = ['active', 'data', 'dirty', 'dirtySinceLastSubmit', 'error', 'initial', 'invalid', 'length', 'pristine', 'submitError', 'submitFailed', 'submitSucceeded', 'touched', 'valid', 'value', 'visited']; | ||
var fieldSubscriptionItems = ['active', 'data', 'dirty', 'dirtySinceLastSubmit', 'error', 'initial', 'invalid', 'length', 'pristine', 'submitError', 'submitFailed', 'submitSucceeded', 'submitting', 'touched', 'valid', 'value', 'visited']; | ||
@@ -785,3 +781,3 @@ // | ||
var callDebug = function callDebug() { | ||
return debug && process.env.NODE_ENV !== 'production' && debug(calculateNextFormState(), Object.keys(state.fields).reduce(function (result, key) { | ||
return debug && "development" !== 'production' && debug(calculateNextFormState(), Object.keys(state.fields).reduce(function (result, key) { | ||
result[key] = state.fields[key]; | ||
@@ -1156,9 +1152,16 @@ return result; | ||
formState.submitSucceeded = false; | ||
formState.lastSubmittedValues = _extends({}, formState.values); | ||
formState.lastSubmittedValues = _extends({}, formState.values); // onSubmit is either sync, callback or async with a Promise | ||
if (onSubmit.length === 3) { | ||
// onSubmit is expecting a callback, first try synchronously | ||
onSubmit(formState.values, api, complete); | ||
var result = onSubmit(formState.values, api, complete); | ||
if (!completeCalled) { | ||
if (!completeCalled) { | ||
if (result && isPromise(result)) { | ||
// onSubmit is async with a Promise | ||
notifyFormListeners(); // let everyone know we are submitting | ||
return result.then(complete, function (error) { | ||
complete(); | ||
throw error; | ||
}); | ||
} else if (onSubmit.length >= 3) { | ||
// must be async, so we should return a Promise | ||
@@ -1170,12 +1173,2 @@ notifyFormListeners(); // let everyone know we are submitting | ||
}); | ||
} | ||
} else { | ||
// onSubmit is either sync or async with a Promise | ||
var result = onSubmit(formState.values, api); | ||
if (result && isPromise(result)) { | ||
// onSubmit is async with a Promise | ||
notifyFormListeners(); // let everyone know we are submitting | ||
return result.then(complete, complete); | ||
} else { | ||
@@ -1182,0 +1175,0 @@ // onSubmit is sync |
@@ -58,2 +58,21 @@ (function (global, factory) { | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {}; | ||
var target = {}; | ||
var sourceKeys = Object.keys(source); | ||
var key, i; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
target[key] = source[key]; | ||
} | ||
return target; | ||
} | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
var setInRecursor = function setInRecursor(current, index, path, value) { | ||
@@ -105,2 +124,7 @@ if (index >= path.length) { | ||
} | ||
var _removed = current[key], | ||
final = _objectWithoutPropertiesLoose(current, [key].map(_toPropertyKey)); | ||
return final; | ||
} // set result in key | ||
@@ -172,2 +196,3 @@ | ||
submitSucceeded = formState.submitSucceeded, | ||
submitting = formState.submitting, | ||
values = formState.values; | ||
@@ -211,2 +236,3 @@ var active = field.active, | ||
submitSucceeded: submitSucceeded, | ||
submitting: submitting, | ||
touched: touched, | ||
@@ -220,3 +246,3 @@ valid: valid, | ||
// | ||
var fieldSubscriptionItems = ['active', 'data', 'dirty', 'dirtySinceLastSubmit', 'error', 'initial', 'invalid', 'length', 'pristine', 'submitError', 'submitFailed', 'submitSucceeded', 'touched', 'valid', 'value', 'visited']; | ||
var fieldSubscriptionItems = ['active', 'data', 'dirty', 'dirtySinceLastSubmit', 'error', 'initial', 'invalid', 'length', 'pristine', 'submitError', 'submitFailed', 'submitSucceeded', 'submitting', 'touched', 'valid', 'value', 'visited']; | ||
@@ -1161,9 +1187,16 @@ // | ||
formState.submitSucceeded = false; | ||
formState.lastSubmittedValues = _extends({}, formState.values); | ||
formState.lastSubmittedValues = _extends({}, formState.values); // onSubmit is either sync, callback or async with a Promise | ||
if (onSubmit.length === 3) { | ||
// onSubmit is expecting a callback, first try synchronously | ||
onSubmit(formState.values, api, complete); | ||
var result = onSubmit(formState.values, api, complete); | ||
if (!completeCalled) { | ||
if (!completeCalled) { | ||
if (result && isPromise(result)) { | ||
// onSubmit is async with a Promise | ||
notifyFormListeners(); // let everyone know we are submitting | ||
return result.then(complete, function (error) { | ||
complete(); | ||
throw error; | ||
}); | ||
} else if (onSubmit.length >= 3) { | ||
// must be async, so we should return a Promise | ||
@@ -1175,12 +1208,2 @@ notifyFormListeners(); // let everyone know we are submitting | ||
}); | ||
} | ||
} else { | ||
// onSubmit is either sync or async with a Promise | ||
var result = onSubmit(formState.values, api); | ||
if (result && isPromise(result)) { | ||
// onSubmit is async with a Promise | ||
notifyFormListeners(); // let everyone know we are submitting | ||
return result.then(complete, complete); | ||
} else { | ||
@@ -1187,0 +1210,0 @@ // onSubmit is sync |
@@ -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 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)}var s=function(e){if(null==e||!e.length)return[];if("string"!=typeof e)throw new Error("toPath() expects a string");return e.split(/[.[\]]+/).filter(Boolean)},R=function(e,t){for(var i=s(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},A=function(e,t,i){if(null==e)throw new Error("Cannot call setIn() with "+String(e)+" state");if(null==t)throw new Error("Cannot call setIn() with "+String(t)+" key");return function e(t,i,r,n){if(i>=r.length)return n;var a=r[i];if(isNaN(a)){var s;if(null==t){var u,o=e(void 0,i+1,r,n);return void 0===o?void 0:((u={})[a]=o,u)}if(Array.isArray(t))throw new Error("Cannot set a non-numeric property on an array");var l=e(t[a],i+1,r,n),f=Object.keys(t).length;if(void 0===l){if(void 0===t[a]&&0===f)return;if(void 0!==t[a]&&f<=1)return isNaN(r[i-1])?void 0:{}}return N({},t,((s={})[a]=l,s))}var d=Number(a);if(null==t){var c=e(void 0,i+1,r,n);if(void 0===c)return;var v=[];return v[d]=c,v}if(!Array.isArray(t))throw new Error("Cannot set a numeric property on an object");var b=e(t[d],i+1,r,n),m=t.concat();return m[d]=b,m}(e,0,s(t),i)},I="FINAL_FORM/form-error",x="FINAL_FORM/array-error",L=function(e,t){var i=e.errors,r=e.initialValues,n=e.lastSubmittedValues,a=e.submitErrors,s=e.submitFailed,u=e.submitSucceeded,o=e.values,l=t.active,f=t.blur,d=t.change,c=t.data,v=t.focus,b=t.name,m=t.touched,S=t.visited,h=R(o,b),y=R(i,b);y&&y[x]&&(y=y[x]);var g=a&&R(a,b),p=r&&R(r,b),E=t.isEqual(p,h),F=!y&&!g;return{active:l,blur:f,change:d,data:c,dirty:!E,dirtySinceLastSubmit:!(!n||t.isEqual(R(n,b),h)),error:y,focus:v,initial:p,invalid:!F,length:Array.isArray(h)?h.length:void 0,name:b,pristine:E,submitError:g,submitFailed:s,submitSucceeded:u,touched:m,valid:F,value:h,visited:S}},a=["active","data","dirty","dirtySinceLastSubmit","error","initial","invalid","length","pristine","submitError","submitFailed","submitSucceeded","touched","valid","value","visited"],q=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 s=i[a];if(!n(s)||e[s]!==t[s])return!1}return!0};function u(t,i,r,n,e,a){var s=!1;return e.forEach(function(e){n[e]&&(t[e]=i[e],r&&(~a.indexOf(e)?q(i[e],r[e]):i[e]===r[e])||(s=!0))}),s}var o=["data"],P=function(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,o)||!t||r?n:void 0},l=["active","dirty","dirtyFields","dirtySinceLastSubmit","error","errors","hasSubmitErrors","hasValidationErrors","initialValues","invalid","pristine","submitting","submitError","submitErrors","submitFailed","submitSucceeded","touched","valid","validating","values","visited"],f=["touched","visited"],z=function(e,t,i,r){var n={};return u(n,e,t,i,l,f)||!t||r?n:void 0},_=function(r){var n,a;return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return n&&t.length===n.length&&!t.some(function(e,t){return!q(n[t],e)})||(n=t,a=r.apply(void 0,t)),a}},C=function(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then},B=function(e,t){return e===t},M=function i(r){return Object.keys(r).some(function(e){var t=r[e];return t&&"object"==typeof t?i(t):void 0!==t})};function D(e,t,i,r,n,a){void 0===a&&(a=!1);var s=n(i,r,t,a);s&&e(s)}function U(e,r,n,a){var s=e.entries;Object.keys(s).forEach(function(e){var t=s[Number(e)],i=t.subscription;D(t.subscriber,i,r,n,a)})}e.createForm=function(e){if(!e)throw new Error("No config specified");e.debug;var u=e.destroyOnUnregister,a=e.keepDirtyOnReinitialize,t=e.initialValues,s=e.mutators,o=e.onSubmit,v=e.validate,n=e.validateOnBlur;if(!o)throw new Error("No onSubmit function specified");var w={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,b=!1,m=!1,S=0,h={},y=function(t){return function(e){return delete h[t],e}},l=function(e,t,i){var r=i(R(e.formState.values,t));e.formState.values=A(e.formState.values,t,r)||{}},f=function(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}},i=function(a){return function(){if(s){for(var e={formState:w.formState,fields:w.fields,fieldSubscribers:w.fieldSubscribers,lastFormState:w.lastFormState},t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];var n=s[a](i,e,{changeValue:l,getIn:R,renameField:f,setIn:A,shallowEqual:q});return w.formState=e.formState,w.fields=e.fields,w.fieldSubscribers=e.fieldSubscribers,w.lastFormState=e.lastFormState,c(void 0,function(){p(),j()}),n}}},d=s?Object.keys(s).reduce(function(e,t){return e[t]=i(t),e},{}):{},g=function(r){return Object.keys(r.validators).reduce(function(e,t){var i=r.validators[Number(t)]();return i&&e.push(i),e},[])},c=function(e,t){if(b)return m=!0,void(t&&t());var o=w.fields,i=w.formState,r=Object.keys(o);if(v||r.some(function(e){return g(o[e]).length})){var u=!1;if(e){var n=o[e];if(n){var a=n.validateFields;a&&(u=!0,r=a.length?a.concat(e):[e])}}var l={},f={},s=function(e){var t=[];if(v){var i=v(N({},w.formState.values));if(C(i)){var r=S++,n=i.then(e).then(y(r));t.push(n),h[r]=n}else e(i)}return t}(function(e){l=e||{}}).concat(r.reduce(function(e,t){return e.concat((n=o[t],a=function(e){f[t]=e},u=[],(i=g(n)).length&&(i.forEach(function(e){var t=e(R(w.formState.values,n.name),w.formState.values,3===e.length?L(w.formState,w.fields[n.name]):void 0);if(t&&C(t)){var i=S++,r=t.then(a).then(y(i));u.push(r),h[i]=r}else s||(s=t)}),a(s)),u));var n,a,s,u,i},[])),d=function(){var s=N({},u?i.errors:{},l),e=function(a){r.forEach(function(e){if(o[e]){var t=R(l,e),i=R(s,e),r=g(o[e]).length,n=f[e];a(e,r&&n||v&&t||(t||u?void 0:i))}})};e(function(e,t){s=A(s,e,t)||{}}),e(function(e,t){if(t&&t[x]){var i=R(s,e).concat();i[x]=t[x],s=A(s,e,i)}}),q(i.errors,s)||(i.errors=s),i.error=l[I]};if(d(),s.length){w.formState.validating++,t&&t();var c=function(){w.formState.validating--,d(),t&&t()};Promise.all(s).then(c,c)}else t&&t()}else t&&t()},p=function(e){if(!r&&!b){var n=w.fields,a=w.fieldSubscribers,s=w.formState;Object.keys(n).forEach(function(e){var t=n[e],i=L(s,t),r=t.lastFieldState;q(i,r)||(t.lastFieldState=i,U(a[e],i,r,P))})}},E=function(){Object.keys(w.fields).forEach(function(e){w.fields[e].touched=!0})},F=function(){var i=w.fields,r=w.formState,e=w.lastFormState,t=Object.keys(i),n=!1,a=t.reduce(function(e,t){return!i[t].isEqual(R(r.values,t),R(r.initialValues||{},t))&&(n=!0,e[t]=!0),e},{});r.pristine=!n,r.dirtySinceLastSubmit=!(!r.lastSubmittedValues||t.every(function(e){var t=r.lastSubmittedValues||{};return i[e].isEqual(R(r.values,e),R(t,e))})),r.valid=!(r.error||r.submitError||M(r.errors)||r.submitErrors&&M(r.submitErrors));var s,u,o,l,f,d,c,v,b,m,S,h,y,g,p,E=(u=(s=r).active,o=s.dirtySinceLastSubmit,l=s.error,f=s.errors,d=s.initialValues,c=s.pristine,v=s.submitting,b=s.submitFailed,m=s.submitSucceeded,S=s.submitError,h=s.submitErrors,y=s.valid,g=s.validating,p=s.values,{active:u,dirty:!c,dirtySinceLastSubmit:o,error:l,errors:f,hasSubmitErrors:!!(S||h&&M(h)),hasValidationErrors:!(!l&&!M(f)),invalid:!y,initialValues:d,pristine:c,submitting:v,submitFailed:b,submitSucceeded:m,submitError:S,submitErrors:h,valid:y,validating:0<g,values:p}),F=t.reduce(function(e,t){return e.touched[t]=i[t].touched,e.visited[t]=i[t].visited,e},{touched:{},visited:{}}),O=F.touched,k=F.visited;return E.dirtyFields=e&&q(e.dirtyFields,a)?e.dirtyFields:a,E.touched=e&&q(e.touched,O)?e.touched:O,E.visited=e&&q(e.visited,k)?e.visited:k,e&&q(e,E)?e:E},O=!1,k=!1,j=function e(){if(O)k=!0;else{if(O=!0,!r&&!b){var t=w.lastFormState,i=F();i!==t&&(w.lastFormState=i,U(w.subscribers,i,t,z))}O=!1,k&&(k=!1,e())}};c();var V={batch:function(e){r=!0,e(),r=!1,p(),j()},blur:function(e){var t=w.fields,i=w.formState,r=t[e];r&&(delete i.active,t[e]=N({},r,{active:!1,touched:!0}),n?c(e,function(){p(),j()}):(p(),j()))},change:function(e,t){var i=w.formState;R(i.values,e)!==t&&(l(w,e,function(){return t}),n?(p(),j()):c(e,function(){p(),j()}))},focus:function(e){var t=w.fields[e];t&&!t.active&&(w.formState.active=e,t.active=!0,t.visited=!0,p(),j())},mutators:d,getFieldState:function(e){var t=w.fields[e];return t&&t.lastFieldState},getRegisteredFields:function(){return Object.keys(w.fields)},getState:function(){return F()},initialize:function(i){var r=w.fields,n=w.formState;a||(n.values=i),Object.keys(r).forEach(function(e){var t=r[e];t.touched=!1,t.visited=!1,a&&r[e].isEqual(R(n.values,e),R(n.initialValues||{},e))&&(n.values=A(n.values,e,R(i,e)))}),n.initialValues=i,c(void 0,function(){p(),j()})},isValidationPaused:function(){return b},pauseValidation:function(){b=!0},registerField:function(t,i,r,e){void 0===r&&(r={}),w.fieldSubscribers[t]||(w.fieldSubscribers[t]={index:0,entries:{}});var n=w.fieldSubscribers[t].index++;if(w.fieldSubscribers[t].entries[n]={subscriber:_(i),subscription:r},!w.fields[t]){var a=w.formState.initialValues?R(w.formState.initialValues,t):void 0;w.fields[t]={active:!1,blur:function(){return V.blur(t)},change:function(e){return V.change(t,e)},data:{},focus:function(){return V.focus(t)},initial:a,isEqual:e&&e.isEqual||B,lastFieldState:void 0,name:t,touched:!1,valid:!0,validateFields:e&&e.validateFields,validators:{},visited:!1}}e&&e.getValidator&&(w.fields[t].validators[n]=e.getValidator);var s=!1;return c(void 0,function(){var e;j(),s||(e=L(w.formState,w.fields[t]),D(i,r,e,void 0,P,!0),w.fields[t].lastFieldState=e,s=!0),p()}),function(){delete w.fields[t].validators[n],delete w.fieldSubscribers[t].entries[n],Object.keys(w.fieldSubscribers[t].entries).length||(delete w.fieldSubscribers[t],delete w.fields[t],w.formState.errors=A(w.formState.errors,t,void 0)||{},u&&(w.formState.values=A(w.formState.values,t,void 0)||{})),c(void 0,function(){p(),j()})}},reset:function(e){void 0===e&&(e=w.formState.initialValues),w.formState.submitFailed=!1,w.formState.submitSucceeded=!1,delete w.formState.submitError,delete w.formState.submitErrors,delete w.formState.lastSubmittedValues,V.initialize(e||{})},resumeValidation:function(){b=!1,m&&c(void 0,function(){p(),j()}),m=!1},setConfig:function(e,t){switch(e){case"debug":break;case"destroyOnUnregister":u=t;break;case"initialValues":V.initialize(t);break;case"keepDirtyOnReinitialize":a=t;break;case"mutators":(s=t)?(Object.keys(d).forEach(function(e){e in t||delete d[e]}),Object.keys(t).forEach(function(e){d[e]=i(e)})):Object.keys(d).forEach(function(e){delete d[e]});break;case"onSubmit":o=t;break;case"validate":v=t,c(void 0,function(){p(),j()});break;case"validateOnBlur":n=t;break;default:throw new Error("Unrecognised option "+e)}},submit:function(){var t=w.formState;if(w.formState.error||M(w.formState.errors))return E(),w.formState.submitFailed=!0,j(),void p();var e=Object.keys(h);if(e.length)Promise.all(e.reduce(function(e,t){return e.push(h[Number(t)]),e},[])).then(V.submit,V.submit);else{var i,r=!1,n=function(e){return t.submitting=!1,e&&M(e)?(t.submitFailed=!0,t.submitSucceeded=!1,t.submitErrors=e,t.submitError=e[I],E()):(delete t.submitErrors,delete t.submitError,t.submitFailed=!1,t.submitSucceeded=!0),j(),p(),r=!0,i&&i(e),e};if(t.submitting=!0,t.submitFailed=!1,t.submitSucceeded=!1,t.lastSubmittedValues=N({},t.values),3===o.length){if(o(t.values,V,n),!r)return j(),new Promise(function(e){i=e})}else{var a=o(t.values,V);if(a&&C(a))return j(),a.then(n,n);n(a)}}},subscribe:function(e,t){if(!e)throw new Error("No callback given.");if(!t)throw new Error("No subscription provided. What values do you want to listen to?");var i=_(e),r=w.subscribers,n=w.lastFormState,a=r.index++;r.entries[a]={subscriber:i,subscription:t};var s=F();return s!==n&&(w.lastFormState=s),D(i,t,s,s,z,!0),function(){delete r.entries[a]}}};return V},e.configOptions=["debug","initialValues","keepDirtyOnReinitialize","mutators","onSubmit","validate","validateOnBlur"],e.version="4.8.1",e.ARRAY_ERROR=x,e.FORM_ERROR=I,e.formSubscriptionItems=l,e.fieldSubscriptionItems=a,e.getIn=R,e.setIn=A,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 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)}var u=function(e){if(null==e||!e.length)return[];if("string"!=typeof e)throw new Error("toPath() expects a string");return e.split(/[.[\]]+/).filter(Boolean)},R=function(e,t){for(var i=u(t),r=e,n=0;n<i.length;n++){var a=i[n];if(null==r||"object"!=typeof r||Array.isArray(r)&&isNaN(a))return;r=r[a]}return r};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)}var r=function e(t,i,r,n){if(i>=r.length)return n;var a=r[i];if(isNaN(a)){var u;if(null==t){var o,s=e(void 0,i+1,r,n);return void 0===s?void 0:((o={})[a]=s,o)}if(Array.isArray(t))throw new Error("Cannot set a non-numeric property on an array");var l=e(t[a],i+1,r,n),f=Object.keys(t).length;if(void 0!==l)return N({},t,((u={})[a]=l,u));if(void 0===t[a]&&0===f)return;if(void 0!==t[a]&&f<=1)return isNaN(r[i-1])?void 0:{};t[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}(t,[a].map(S))}var c=Number(a);if(null==t){var d=e(void 0,i+1,r,n);if(void 0===d)return;var v=[];return v[c]=d,v}if(!Array.isArray(t))throw new Error("Cannot set a numeric property on an object");var b=e(t[c],i+1,r,n),m=t.concat();return m[c]=b,m},A=function(e,t,i){if(null==e)throw new Error("Cannot call setIn() with "+String(e)+" state");if(null==t)throw new Error("Cannot call setIn() with "+String(t)+" key");return r(e,0,u(t),i)},x="FINAL_FORM/form-error",I="FINAL_FORM/array-error",P=function(e,t){var i=e.errors,r=e.initialValues,n=e.lastSubmittedValues,a=e.submitErrors,u=e.submitFailed,o=e.submitSucceeded,s=e.submitting,l=e.values,f=t.active,c=t.blur,d=t.change,v=t.data,b=t.focus,m=t.name,S=t.touched,h=t.visited,y=R(l,m),g=R(i,m);g&&g[I]&&(g=g[I]);var p=a&&R(a,m),E=r&&R(r,m),F=t.isEqual(E,y),O=!g&&!p;return{active:f,blur:c,change:d,data:v,dirty:!F,dirtySinceLastSubmit:!(!n||t.isEqual(R(n,m),y)),error:g,focus:b,initial:E,invalid:!O,length:Array.isArray(y)?y.length:void 0,name:m,pristine:F,submitError:p,submitFailed:u,submitSucceeded:o,submitting:s,touched:S,valid:O,value:y,visited:h}},a=["active","data","dirty","dirtySinceLastSubmit","error","initial","invalid","length","pristine","submitError","submitFailed","submitSucceeded","submitting","touched","valid","value","visited"],L=function(e,t){if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(var n=Object.prototype.hasOwnProperty.bind(t),a=0;a<i.length;a++){var u=i[a];if(!n(u)||e[u]!==t[u])return!1}return!0};function o(t,i,r,n,e,a){var u=!1;return e.forEach(function(e){n[e]&&(t[e]=i[e],r&&(~a.indexOf(e)?L(i[e],r[e]):i[e]===r[e])||(u=!0))}),u}var s=["data"],q=function(e,t,i,r){var n={blur:e.blur,change:e.change,focus:e.focus,name:e.name};return o(n,e,t,i,a,s)||!t||r?n:void 0},l=["active","dirty","dirtyFields","dirtySinceLastSubmit","error","errors","hasSubmitErrors","hasValidationErrors","initialValues","invalid","pristine","submitting","submitError","submitErrors","submitFailed","submitSucceeded","touched","valid","validating","values","visited"],f=["touched","visited"],z=function(e,t,i,r){var n={};return o(n,e,t,i,l,f)||!t||r?n:void 0},_=function(r){var n,a;return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return n&&t.length===n.length&&!t.some(function(e,t){return!L(n[t],e)})||(n=t,a=r.apply(void 0,t)),a}},C=function(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then},B=function(e,t){return e===t},M=function i(r){return Object.keys(r).some(function(e){var t=r[e];return t&&"object"==typeof t?i(t):void 0!==t})};function D(e,t,i,r,n,a){void 0===a&&(a=!1);var u=n(i,r,t,a);u&&e(u)}function U(e,r,n,a){var u=e.entries;Object.keys(u).forEach(function(e){var t=u[Number(e)],i=t.subscription;D(t.subscriber,i,r,n,a)})}e.createForm=function(e){if(!e)throw new Error("No config specified");e.debug;var o=e.destroyOnUnregister,a=e.keepDirtyOnReinitialize,t=e.initialValues,u=e.mutators,s=e.onSubmit,v=e.validate,n=e.validateOnBlur;if(!s)throw new Error("No onSubmit function specified");var j={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,b=!1,m=!1,S=0,h={},y=function(t){return function(e){return delete h[t],e}},l=function(e,t,i){var r=i(R(e.formState.values,t));e.formState.values=A(e.formState.values,t,r)||{}},f=function(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}},i=function(a){return function(){if(u){for(var e={formState:j.formState,fields:j.fields,fieldSubscribers:j.fieldSubscribers,lastFormState:j.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:f,setIn:A,shallowEqual:L});return j.formState=e.formState,j.fields=e.fields,j.fieldSubscribers=e.fieldSubscribers,j.lastFormState=e.lastFormState,d(void 0,function(){p(),k()}),n}}},c=u?Object.keys(u).reduce(function(e,t){return e[t]=i(t),e},{}):{},g=function(r){return Object.keys(r.validators).reduce(function(e,t){var i=r.validators[Number(t)]();return i&&e.push(i),e},[])},d=function(e,t){if(b)return m=!0,void(t&&t());var s=j.fields,i=j.formState,r=Object.keys(s);if(v||r.some(function(e){return g(s[e]).length})){var o=!1;if(e){var n=s[e];if(n){var a=n.validateFields;a&&(o=!0,r=a.length?a.concat(e):[e])}}var l={},f={},u=function(e){var t=[];if(v){var i=v(N({},j.formState.values));if(C(i)){var r=S++,n=i.then(e).then(y(r));t.push(n),h[r]=n}else e(i)}return t}(function(e){l=e||{}}).concat(r.reduce(function(e,t){return e.concat((n=s[t],a=function(e){f[t]=e},o=[],(i=g(n)).length&&(i.forEach(function(e){var t=e(R(j.formState.values,n.name),j.formState.values,3===e.length?P(j.formState,j.fields[n.name]):void 0);if(t&&C(t)){var i=S++,r=t.then(a).then(y(i));o.push(r),h[i]=r}else u||(u=t)}),a(u)),o));var n,a,u,o,i},[])),c=function(){var u=N({},o?i.errors:{},l),e=function(a){r.forEach(function(e){if(s[e]){var t=R(l,e),i=R(u,e),r=g(s[e]).length,n=f[e];a(e,r&&n||v&&t||(t||o?void 0:i))}})};e(function(e,t){u=A(u,e,t)||{}}),e(function(e,t){if(t&&t[I]){var i=R(u,e).concat();i[I]=t[I],u=A(u,e,i)}}),L(i.errors,u)||(i.errors=u),i.error=l[x]};if(c(),u.length){j.formState.validating++,t&&t();var d=function(){j.formState.validating--,c(),t&&t()};Promise.all(u).then(d,d)}else t&&t()}else t&&t()},p=function(e){if(!r&&!b){var n=j.fields,a=j.fieldSubscribers,u=j.formState;Object.keys(n).forEach(function(e){var t=n[e],i=P(u,t),r=t.lastFieldState;L(i,r)||(t.lastFieldState=i,U(a[e],i,r,q))})}},E=function(){Object.keys(j.fields).forEach(function(e){j.fields[e].touched=!0})},F=function(){var i=j.fields,r=j.formState,e=j.lastFormState,t=Object.keys(i),n=!1,a=t.reduce(function(e,t){return!i[t].isEqual(R(r.values,t),R(r.initialValues||{},t))&&(n=!0,e[t]=!0),e},{});r.pristine=!n,r.dirtySinceLastSubmit=!(!r.lastSubmittedValues||t.every(function(e){var t=r.lastSubmittedValues||{};return i[e].isEqual(R(r.values,e),R(t,e))})),r.valid=!(r.error||r.submitError||M(r.errors)||r.submitErrors&&M(r.submitErrors));var u,o,s,l,f,c,d,v,b,m,S,h,y,g,p,E=(o=(u=r).active,s=u.dirtySinceLastSubmit,l=u.error,f=u.errors,c=u.initialValues,d=u.pristine,v=u.submitting,b=u.submitFailed,m=u.submitSucceeded,S=u.submitError,h=u.submitErrors,y=u.valid,g=u.validating,p=u.values,{active:o,dirty:!d,dirtySinceLastSubmit:s,error:l,errors:f,hasSubmitErrors:!!(S||h&&M(h)),hasValidationErrors:!(!l&&!M(f)),invalid:!y,initialValues:c,pristine:d,submitting:v,submitFailed:b,submitSucceeded:m,submitError:S,submitErrors:h,valid:y,validating:0<g,values:p}),F=t.reduce(function(e,t){return e.touched[t]=i[t].touched,e.visited[t]=i[t].visited,e},{touched:{},visited:{}}),O=F.touched,w=F.visited;return E.dirtyFields=e&&L(e.dirtyFields,a)?e.dirtyFields:a,E.touched=e&&L(e.touched,O)?e.touched:O,E.visited=e&&L(e.visited,w)?e.visited:w,e&&L(e,E)?e:E},O=!1,w=!1,k=function e(){if(O)w=!0;else{if(O=!0,!r&&!b){var t=j.lastFormState,i=F();i!==t&&(j.lastFormState=i,U(j.subscribers,i,t,z))}O=!1,w&&(w=!1,e())}};d();var V={batch:function(e){r=!0,e(),r=!1,p(),k()},blur:function(e){var t=j.fields,i=j.formState,r=t[e];r&&(delete i.active,t[e]=N({},r,{active:!1,touched:!0}),n?d(e,function(){p(),k()}):(p(),k()))},change:function(e,t){var i=j.formState;R(i.values,e)!==t&&(l(j,e,function(){return t}),n?(p(),k()):d(e,function(){p(),k()}))},focus:function(e){var t=j.fields[e];t&&!t.active&&(j.formState.active=e,t.active=!0,t.visited=!0,p(),k())},mutators:c,getFieldState:function(e){var t=j.fields[e];return t&&t.lastFieldState},getRegisteredFields:function(){return Object.keys(j.fields)},getState:function(){return F()},initialize:function(i){var r=j.fields,n=j.formState;a||(n.values=i),Object.keys(r).forEach(function(e){var t=r[e];t.touched=!1,t.visited=!1,a&&r[e].isEqual(R(n.values,e),R(n.initialValues||{},e))&&(n.values=A(n.values,e,R(i,e)))}),n.initialValues=i,d(void 0,function(){p(),k()})},isValidationPaused:function(){return b},pauseValidation:function(){b=!0},registerField:function(t,i,r,e){void 0===r&&(r={}),j.fieldSubscribers[t]||(j.fieldSubscribers[t]={index:0,entries:{}});var n=j.fieldSubscribers[t].index++;if(j.fieldSubscribers[t].entries[n]={subscriber:_(i),subscription:r},!j.fields[t]){var a=j.formState.initialValues?R(j.formState.initialValues,t):void 0;j.fields[t]={active:!1,blur:function(){return V.blur(t)},change:function(e){return V.change(t,e)},data:{},focus:function(){return V.focus(t)},initial:a,isEqual:e&&e.isEqual||B,lastFieldState:void 0,name:t,touched:!1,valid:!0,validateFields:e&&e.validateFields,validators:{},visited:!1}}e&&e.getValidator&&(j.fields[t].validators[n]=e.getValidator);var u=!1;return d(void 0,function(){var e;k(),u||(e=P(j.formState,j.fields[t]),D(i,r,e,void 0,q,!0),j.fields[t].lastFieldState=e,u=!0),p()}),function(){delete j.fields[t].validators[n],delete j.fieldSubscribers[t].entries[n],Object.keys(j.fieldSubscribers[t].entries).length||(delete j.fieldSubscribers[t],delete j.fields[t],j.formState.errors=A(j.formState.errors,t,void 0)||{},o&&(j.formState.values=A(j.formState.values,t,void 0)||{})),d(void 0,function(){p(),k()})}},reset:function(e){void 0===e&&(e=j.formState.initialValues),j.formState.submitFailed=!1,j.formState.submitSucceeded=!1,delete j.formState.submitError,delete j.formState.submitErrors,delete j.formState.lastSubmittedValues,V.initialize(e||{})},resumeValidation:function(){b=!1,m&&d(void 0,function(){p(),k()}),m=!1},setConfig:function(e,t){switch(e){case"debug":break;case"destroyOnUnregister":o=t;break;case"initialValues":V.initialize(t);break;case"keepDirtyOnReinitialize":a=t;break;case"mutators":(u=t)?(Object.keys(c).forEach(function(e){e in t||delete c[e]}),Object.keys(t).forEach(function(e){c[e]=i(e)})):Object.keys(c).forEach(function(e){delete c[e]});break;case"onSubmit":s=t;break;case"validate":v=t,d(void 0,function(){p(),k()});break;case"validateOnBlur":n=t;break;default:throw new Error("Unrecognised option "+e)}},submit:function(){var t=j.formState;if(j.formState.error||M(j.formState.errors))return E(),j.formState.submitFailed=!0,k(),void p();var e=Object.keys(h);if(e.length)Promise.all(e.reduce(function(e,t){return e.push(h[Number(t)]),e},[])).then(V.submit,V.submit);else{var i,r=!1,n=function(e){return t.submitting=!1,e&&M(e)?(t.submitFailed=!0,t.submitSucceeded=!1,t.submitErrors=e,t.submitError=e[x],E()):(delete t.submitErrors,delete t.submitError,t.submitFailed=!1,t.submitSucceeded=!0),k(),p(),r=!0,i&&i(e),e};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 k(),a.then(n,function(e){throw n(),e});if(3<=s.length)return k(),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=_(e),r=j.subscribers,n=j.lastFormState,a=r.index++;r.entries[a]={subscriber:i,subscription:t};var u=F();return u!==n&&(j.lastFormState=u),D(i,t,u,u,z,!0),function(){delete r.entries[a]}}};return V},e.configOptions=["debug","initialValues","keepDirtyOnReinitialize","mutators","onSubmit","validate","validateOnBlur"],e.version="4.8.1",e.ARRAY_ERROR=I,e.FORM_ERROR=x,e.formSubscriptionItems=l,e.fieldSubscriptionItems=a,e.getIn=R,e.setIn=A,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=final-form.umd.min.js.map |
@@ -11,2 +11,3 @@ export type Subscription = { [key: string]: boolean } | ||
dirty?: boolean | ||
dirtyFields?: boolean | ||
dirtySinceLastSubmit?: boolean | ||
@@ -36,2 +37,3 @@ error?: boolean | ||
dirty: boolean | ||
dirtyFields: { [key: string]: boolean } | ||
dirtySinceLastSubmit: boolean | ||
@@ -76,2 +78,3 @@ error: any | ||
submitSucceeded?: boolean | ||
submitting?: boolean | ||
touched?: boolean | ||
@@ -96,2 +99,3 @@ valid?: boolean | ||
submitSucceeded?: boolean | ||
submitting?: boolean | ||
touched?: boolean | ||
@@ -239,3 +243,3 @@ valid?: boolean | ||
export interface Config { | ||
export interface Config<FormData = object> { | ||
debug?: DebugFunction | ||
@@ -247,3 +251,3 @@ destroyOnUnregister?: boolean | ||
onSubmit: ( | ||
values: object, | ||
values: FormData, | ||
form: FormApi, | ||
@@ -258,3 +262,3 @@ callback?: (errors?: object) => void | ||
export function createForm(config: Config): FormApi | ||
export function createForm<FormData>(config: Config<FormData>): FormApi | ||
export const fieldSubscriptionItems: string[] | ||
@@ -261,0 +265,0 @@ export const formSubscriptionItems: string[] |
{ | ||
"name": "final-form", | ||
"version": "4.10.0", | ||
"version": "4.11.0", | ||
"description": "🏁 Framework agnostic, high performance, subscription-based form state management", | ||
@@ -16,3 +16,3 @@ "main": "dist/final-form.cjs.js", | ||
"precommit": "lint-staged && npm start validate", | ||
"prepublish": "lint-staged && npm start validate" | ||
"prepare": "lint-staged && npm start validate" | ||
}, | ||
@@ -30,45 +30,46 @@ "author": "Erik Rasmussen <rasmussenerik@gmail.com> (http://github.com/erikras)", | ||
"devDependencies": { | ||
"@babel/core": "^7.0.0-beta.49", | ||
"@babel/plugin-proposal-class-properties": "7.0.0-beta.54", | ||
"@babel/plugin-proposal-decorators": "7.0.0-beta.54", | ||
"@babel/plugin-proposal-export-namespace-from": "7.0.0-beta.54", | ||
"@babel/plugin-proposal-function-sent": "7.0.0-beta.54", | ||
"@babel/plugin-proposal-json-strings": "7.0.0-beta.54", | ||
"@babel/plugin-proposal-numeric-separator": "7.0.0-beta.54", | ||
"@babel/plugin-proposal-throw-expressions": "7.0.0-beta.54", | ||
"@babel/plugin-syntax-dynamic-import": "7.0.0-beta.54", | ||
"@babel/plugin-syntax-import-meta": "7.0.0-beta.54", | ||
"@babel/preset-env": "^7.0.0-beta.49", | ||
"@babel/preset-flow": "7.0.0-beta.54", | ||
"@types/node": "^10.9.1", | ||
"@babel/core": "^7.1.6", | ||
"@babel/plugin-proposal-class-properties": "^7.1.0", | ||
"@babel/plugin-proposal-decorators": "^7.1.6", | ||
"@babel/plugin-proposal-export-namespace-from": "7.0.0", | ||
"@babel/plugin-proposal-function-sent": "^7.1.0", | ||
"@babel/plugin-proposal-json-strings": "7.0.0", | ||
"@babel/plugin-proposal-numeric-separator": "7.0.0", | ||
"@babel/plugin-proposal-throw-expressions": "7.0.0", | ||
"@babel/plugin-syntax-dynamic-import": "7.0.0", | ||
"@babel/plugin-syntax-import-meta": "7.0.0", | ||
"@babel/plugin-transform-runtime": "^7.1.0", | ||
"@babel/preset-env": "^7.1.6", | ||
"@babel/preset-flow": "7.0.0", | ||
"@types/node": "^10.12.8", | ||
"babel-core": "^7.0.0-bridge.0", | ||
"babel-eslint": "^8.2.6", | ||
"babel-jest": "^23.4.2", | ||
"babel-eslint": "^10.0.1", | ||
"babel-jest": "^23.6.0", | ||
"bundlesize": "^0.17.0", | ||
"doctoc": "^1.3.1", | ||
"eslint": "^5.4.0", | ||
"eslint-config-react-app": "^2.1.0", | ||
"eslint-plugin-babel": "^5.1.0", | ||
"eslint-plugin-flowtype": "^2.48.0", | ||
"eslint": "^5.9.0", | ||
"eslint-config-react-app": "^3.0.5", | ||
"eslint-plugin-babel": "^5.2.1", | ||
"eslint-plugin-flowtype": "^3.2.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-jsx-a11y": "^6.0.3", | ||
"eslint-plugin-jsx-a11y": "^6.1.2", | ||
"eslint-plugin-react": "^7.11.1", | ||
"flow-bin": "^0.79.1", | ||
"flow-bin": "^0.86.0", | ||
"glow": "^1.2.2", | ||
"husky": "^0.14.3", | ||
"jest": "^23.5.0", | ||
"lint-staged": "^7.2.2", | ||
"husky": "^1.1.4", | ||
"jest": "^23.6.0", | ||
"lint-staged": "^8.0.4", | ||
"nps": "^5.9.3", | ||
"nps-utils": "^1.7.0", | ||
"prettier": "^1.14.2", | ||
"prettier": "^1.15.2", | ||
"prettier-eslint-cli": "^4.7.1", | ||
"rollup": "^0.64.1", | ||
"rollup-plugin-babel": "^4.0.0-beta.4", | ||
"rollup-plugin-commonjs": "^9.1.5", | ||
"rollup": "^0.67.1", | ||
"rollup-plugin-babel": "^4.0.2", | ||
"rollup-plugin-commonjs": "^9.2.0", | ||
"rollup-plugin-flow": "^1.1.1", | ||
"rollup-plugin-node-resolve": "^3.2.0", | ||
"rollup-plugin-replace": "^2.0.0", | ||
"rollup-plugin-uglify": "^4.0.0", | ||
"rollup-plugin-replace": "^2.1.0", | ||
"rollup-plugin-uglify": "^6.0.0", | ||
"tslint": "^5.10.0", | ||
"typescript": "^3.0.1" | ||
"typescript": "^3.1.6" | ||
}, | ||
@@ -87,13 +88,16 @@ "lint-staged": { | ||
"path": "dist/final-form.umd.min.js", | ||
"maxSize": "4.5kB" | ||
"maxSize": "4.7kB" | ||
}, | ||
{ | ||
"path": "dist/final-form.es.js", | ||
"maxSize": "8kB" | ||
"maxSize": "8.1kB" | ||
}, | ||
{ | ||
"path": "dist/final-form.cjs.js", | ||
"maxSize": "8kB" | ||
"maxSize": "8.1kB" | ||
} | ||
] | ||
], | ||
"dependencies": { | ||
"@babel/runtime": "^7.1.5" | ||
} | ||
} |
@@ -11,3 +11,3 @@ # 🏁 Final Form | ||
✅ **Zero** dependencies | ||
✅ **Zero** dependencies [\*](#zero-dependencies) | ||
@@ -18,3 +18,3 @@ ✅ Framework agnostic | ||
✅ 💥 [**4.4k gzipped**](https://bundlephobia.com/result?p=final-form) 💥 | ||
✅ 💥 [**4.6k gzipped**](https://bundlephobia.com/result?p=final-form) 💥 | ||
@@ -43,2 +43,6 @@ --- | ||
## Zero Dependencies | ||
Technically there is a dependency on `@babel/runtime`, but [this actually makes your final bundle size _smaller_ by sharing common babel code between libraries](https://babeljs.io/docs/en/babel-runtime#why). | ||
## Getting Started | ||
@@ -138,3 +142,3 @@ | ||
- [`isEqual?: (a: any, b: any) => boolean`](#isequal-a-any-b-any--boolean) | ||
- [`getValidator?: () => (value: ?any, allValues: Object) => ?any | ?Promise<any>`](#getvalidator---value-any-allvalues-object--any--promiseany) | ||
- [`getValidator?: () => (value: ?any, allValues: Object, meta: FieldState) => ?any | ?Promise<any>`](#getvalidator---value-any-allvalues-object--any--promiseany) | ||
- [`validateFields?: string[]`](#validatefields-string) | ||
@@ -158,2 +162,3 @@ - [`FieldState`](#fieldstate) | ||
- [`submitSucceeded?: boolean`](#submitsucceeded-boolean) | ||
- [`submitting?: boolean`](#submitting-boolean) | ||
- [`touched?: boolean`](#touched-boolean) | ||
@@ -177,2 +182,3 @@ - [`valid?: boolean`](#valid-boolean) | ||
- [`submitSucceeded?: boolean`](#submitsucceeded-boolean-1) | ||
- [`submitting?: boolean`](#submitting-boolean-1) | ||
- [`touched?: boolean`](#touched-boolean-1) | ||
@@ -215,3 +221,3 @@ - [`valid?: boolean`](#valid-boolean-1) | ||
- [`submitSucceeded?: boolean`](#submitsucceeded-boolean-2) | ||
- [`submitting?: boolean`](#submitting-boolean) | ||
- [`submitting?: boolean`](#submitting-boolean-2) | ||
- [`touched?: { [string]: boolean }`](#touched--string-boolean-) | ||
@@ -240,3 +246,3 @@ - [`valid?: boolean`](#valid-boolean-2) | ||
- [`submitSucceeded?: boolean`](#submitsucceeded-boolean-3) | ||
- [`submitting?: boolean`](#submitting-boolean-1) | ||
- [`submitting?: boolean`](#submitting-boolean-3) | ||
- [`touched?: boolean`](#touched-boolean-2) | ||
@@ -272,3 +278,3 @@ - [`valid?: boolean`](#valid-boolean-3) | ||
- [`submitSucceeded: boolean`](#submitsucceeded-boolean) | ||
- [`submitting: boolean`](#submitting-boolean) | ||
- [`submitting: boolean`](#submitting-boolean-4) | ||
- [`valid: boolean`](#valid-boolean-1) | ||
@@ -497,3 +503,3 @@ - [`validating: number`](#validating-number) | ||
#### `getValidator?: () => (value: ?any, allValues: Object) => ?any | ?Promise<any>` | ||
#### `getValidator?: () => (value: ?any, allValues: Object, meta: FieldState) => ?any | ?Promise<any>` | ||
@@ -566,3 +572,3 @@ A callback that will return a field-level validation function to validate a single field value. The validation function should return an error if the value is not valid, or `undefined` if the value is valid. | ||
`true` if the current value is `===` to the initial value, `false` if the values | ||
are `!===`. | ||
are `!==`. | ||
@@ -581,2 +587,7 @@ #### `submitError?: any` | ||
#### `submitting?: boolean` | ||
`true` if the form is currently being submitted asynchronously. `false` | ||
otherwise. | ||
#### `touched?: boolean` | ||
@@ -663,2 +674,7 @@ | ||
#### `submitting?: boolean` | ||
When `true` the `FieldSubscriber` will be notified of changes to the | ||
`submitting` value in `FieldState`. | ||
#### `touched?: boolean` | ||
@@ -665,0 +681,0 @@ |
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
196382
3362
1211
1
44
1
+ Added@babel/runtime@^7.1.5
+ Added@babel/runtime@7.26.0(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)