final-form
Advanced tools
Comparing version 4.8.3 to 4.9.0
@@ -5,34 +5,18 @@ 'use strict'; | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
return obj; | ||
} | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
ownKeys.forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
}; | ||
return target; | ||
return _extends.apply(this, arguments); | ||
} | ||
@@ -82,3 +66,3 @@ | ||
if (isNaN(key)) { | ||
var _objectSpread2; | ||
var _extends2; | ||
@@ -123,3 +107,3 @@ // object set | ||
return _objectSpread({}, current, (_objectSpread2 = {}, _objectSpread2[key] = _result, _objectSpread2)); | ||
return _extends({}, current, (_extends2 = {}, _extends2[key] = _result, _extends2)); | ||
} // array set | ||
@@ -298,3 +282,3 @@ | ||
// | ||
var formSubscriptionItems = ['active', 'dirty', 'dirtySinceLastSubmit', 'error', 'errors', 'hasSubmitErrors', 'hasValidationErrors', 'initialValues', 'invalid', 'pristine', 'submitting', 'submitError', 'submitErrors', 'submitFailed', 'submitSucceeded', 'touched', 'valid', 'validating', 'values', 'visited']; | ||
var formSubscriptionItems = ['active', 'dirty', 'dirtyFields', 'dirtySinceLastSubmit', 'error', 'errors', 'hasSubmitErrors', 'hasValidationErrors', 'initialValues', 'invalid', 'pristine', 'submitting', 'submitError', 'submitErrors', 'submitFailed', 'submitSucceeded', 'touched', 'valid', 'validating', 'values', 'visited']; | ||
@@ -444,3 +428,3 @@ // | ||
errors: {}, | ||
initialValues: initialValues && _objectSpread({}, initialValues), | ||
initialValues: initialValues && _extends({}, initialValues), | ||
invalid: false, | ||
@@ -453,3 +437,3 @@ pristine: true, | ||
validating: 0, | ||
values: initialValues ? _objectSpread({}, initialValues) : {} | ||
values: initialValues ? _extends({}, initialValues) : {} | ||
}, | ||
@@ -518,3 +502,3 @@ lastFormState: undefined | ||
if (validate) { | ||
var errorsOrPromise = validate(_objectSpread({}, state.formState.values)); // clone to avoid writing | ||
var errorsOrPromise = validate(_extends({}, state.formState.values)); // clone to avoid writing | ||
@@ -557,3 +541,4 @@ if (isPromise(errorsOrPromise)) { | ||
var asyncValidationPromiseKey = nextAsyncValidationKey++; | ||
var promise = errorOrPromise.then(setError).then(clearAsyncValidationPromise(asyncValidationPromiseKey)); | ||
var promise = errorOrPromise.then(setError) // errors must be resolved, not rejected | ||
.then(clearAsyncValidationPromise(asyncValidationPromiseKey)); | ||
promises.push(promise); | ||
@@ -625,3 +610,3 @@ asyncValidationPromises[asyncValidationPromiseKey] = promise; | ||
var processErrors = function processErrors() { | ||
var merged = _objectSpread({}, limitedFieldLevelValidation ? formState.errors : {}, recordLevelErrors); | ||
var merged = _extends({}, limitedFieldLevelValidation ? formState.errors : {}, recordLevelErrors); | ||
@@ -672,3 +657,3 @@ var forEachError = function forEachError(fn) { | ||
Promise.all(promises).then(function () { | ||
var afterPromises = function afterPromises() { | ||
state.formState.validating--; | ||
@@ -680,3 +665,5 @@ processErrors(); | ||
} | ||
}); | ||
}; | ||
Promise.all(promises).then(afterPromises, afterPromises); | ||
} else if (callback) { | ||
@@ -746,9 +733,19 @@ callback(); | ||
formState.pristine = fieldKeys.every(function (key) { | ||
return fields[key].isEqual(getIn(formState.values, key), getIn(formState.initialValues || {}, key)); | ||
}); | ||
var foundDirty = false; | ||
var dirtyFields = fieldKeys.reduce(function (result, key) { | ||
var dirty = !fields[key].isEqual(getIn(formState.values, key), getIn(formState.initialValues || {}, key)); | ||
if (dirty) { | ||
foundDirty = true; | ||
result[key] = true; | ||
} | ||
return result; | ||
}, {}); | ||
formState.pristine = !foundDirty; | ||
formState.dirtySinceLastSubmit = !!(formState.lastSubmittedValues && !fieldKeys.every(function (key) { | ||
return fields[key].isEqual(getIn(formState.values, key), // istanbul ignore next | ||
getIn(formState.lastSubmittedValues || {}, key) // || {} is for flow, but causes branch coverage complaint | ||
); | ||
// istanbul ignore next | ||
var nonNullLastSubmittedValues = formState.lastSubmittedValues || {}; // || {} is for flow, but causes branch coverage complaint | ||
return fields[key].isEqual(getIn(formState.values, key), getIn(nonNullLastSubmittedValues, key)); | ||
})); | ||
@@ -769,2 +766,3 @@ formState.valid = !formState.error && !formState.submitError && !hasAnyError(formState.errors) && !(formState.submitErrors && hasAnyError(formState.submitErrors)); | ||
nextFormState.dirtyFields = lastFormState && shallowEqual(lastFormState.dirtyFields, dirtyFields) ? lastFormState.dirtyFields : dirtyFields; | ||
nextFormState.touched = lastFormState && shallowEqual(lastFormState.touched, touched) ? lastFormState.touched : touched; | ||
@@ -829,3 +827,3 @@ nextFormState.visited = lastFormState && shallowEqual(lastFormState.visited, visited) ? lastFormState.visited : visited; | ||
delete formState.active; | ||
fields[name] = _objectSpread({}, previous, { | ||
fields[name] = _extends({}, previous, { | ||
active: false, | ||
@@ -1016,2 +1014,3 @@ touched: true | ||
state.formState.submitSucceeded = false; | ||
delete state.formState.submitError; | ||
delete state.formState.submitErrors; | ||
@@ -1110,5 +1109,3 @@ delete state.formState.lastSubmittedValues; | ||
return result; | ||
}, [])).then(function () { | ||
return api.submit(); | ||
}); | ||
}, [])).then(api.submit, api.submit); | ||
return; | ||
@@ -1150,3 +1147,3 @@ } | ||
formState.submitSucceeded = false; | ||
formState.lastSubmittedValues = _objectSpread({}, formState.values); | ||
formState.lastSubmittedValues = _extends({}, formState.values); | ||
@@ -1173,3 +1170,3 @@ if (onSubmit.length === 3) { | ||
return result.then(complete); | ||
return result.then(complete, complete); | ||
} else { | ||
@@ -1176,0 +1173,0 @@ // onSubmit is sync |
@@ -1,33 +0,17 @@ | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
return obj; | ||
} | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
ownKeys.forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
}; | ||
return target; | ||
return _extends.apply(this, arguments); | ||
} | ||
@@ -77,3 +61,3 @@ | ||
if (isNaN(key)) { | ||
var _objectSpread2; | ||
var _extends2; | ||
@@ -118,3 +102,3 @@ // object set | ||
return _objectSpread({}, current, (_objectSpread2 = {}, _objectSpread2[key] = _result, _objectSpread2)); | ||
return _extends({}, current, (_extends2 = {}, _extends2[key] = _result, _extends2)); | ||
} // array set | ||
@@ -293,3 +277,3 @@ | ||
// | ||
var formSubscriptionItems = ['active', 'dirty', 'dirtySinceLastSubmit', 'error', 'errors', 'hasSubmitErrors', 'hasValidationErrors', 'initialValues', 'invalid', 'pristine', 'submitting', 'submitError', 'submitErrors', 'submitFailed', 'submitSucceeded', 'touched', 'valid', 'validating', 'values', 'visited']; | ||
var formSubscriptionItems = ['active', 'dirty', 'dirtyFields', 'dirtySinceLastSubmit', 'error', 'errors', 'hasSubmitErrors', 'hasValidationErrors', 'initialValues', 'invalid', 'pristine', 'submitting', 'submitError', 'submitErrors', 'submitFailed', 'submitSucceeded', 'touched', 'valid', 'validating', 'values', 'visited']; | ||
@@ -439,3 +423,3 @@ // | ||
errors: {}, | ||
initialValues: initialValues && _objectSpread({}, initialValues), | ||
initialValues: initialValues && _extends({}, initialValues), | ||
invalid: false, | ||
@@ -448,3 +432,3 @@ pristine: true, | ||
validating: 0, | ||
values: initialValues ? _objectSpread({}, initialValues) : {} | ||
values: initialValues ? _extends({}, initialValues) : {} | ||
}, | ||
@@ -513,3 +497,3 @@ lastFormState: undefined | ||
if (validate) { | ||
var errorsOrPromise = validate(_objectSpread({}, state.formState.values)); // clone to avoid writing | ||
var errorsOrPromise = validate(_extends({}, state.formState.values)); // clone to avoid writing | ||
@@ -552,3 +536,4 @@ if (isPromise(errorsOrPromise)) { | ||
var asyncValidationPromiseKey = nextAsyncValidationKey++; | ||
var promise = errorOrPromise.then(setError).then(clearAsyncValidationPromise(asyncValidationPromiseKey)); | ||
var promise = errorOrPromise.then(setError) // errors must be resolved, not rejected | ||
.then(clearAsyncValidationPromise(asyncValidationPromiseKey)); | ||
promises.push(promise); | ||
@@ -620,3 +605,3 @@ asyncValidationPromises[asyncValidationPromiseKey] = promise; | ||
var processErrors = function processErrors() { | ||
var merged = _objectSpread({}, limitedFieldLevelValidation ? formState.errors : {}, recordLevelErrors); | ||
var merged = _extends({}, limitedFieldLevelValidation ? formState.errors : {}, recordLevelErrors); | ||
@@ -667,3 +652,3 @@ var forEachError = function forEachError(fn) { | ||
Promise.all(promises).then(function () { | ||
var afterPromises = function afterPromises() { | ||
state.formState.validating--; | ||
@@ -675,3 +660,5 @@ processErrors(); | ||
} | ||
}); | ||
}; | ||
Promise.all(promises).then(afterPromises, afterPromises); | ||
} else if (callback) { | ||
@@ -741,9 +728,19 @@ callback(); | ||
formState.pristine = fieldKeys.every(function (key) { | ||
return fields[key].isEqual(getIn(formState.values, key), getIn(formState.initialValues || {}, key)); | ||
}); | ||
var foundDirty = false; | ||
var dirtyFields = fieldKeys.reduce(function (result, key) { | ||
var dirty = !fields[key].isEqual(getIn(formState.values, key), getIn(formState.initialValues || {}, key)); | ||
if (dirty) { | ||
foundDirty = true; | ||
result[key] = true; | ||
} | ||
return result; | ||
}, {}); | ||
formState.pristine = !foundDirty; | ||
formState.dirtySinceLastSubmit = !!(formState.lastSubmittedValues && !fieldKeys.every(function (key) { | ||
return fields[key].isEqual(getIn(formState.values, key), // istanbul ignore next | ||
getIn(formState.lastSubmittedValues || {}, key) // || {} is for flow, but causes branch coverage complaint | ||
); | ||
// istanbul ignore next | ||
var nonNullLastSubmittedValues = formState.lastSubmittedValues || {}; // || {} is for flow, but causes branch coverage complaint | ||
return fields[key].isEqual(getIn(formState.values, key), getIn(nonNullLastSubmittedValues, key)); | ||
})); | ||
@@ -764,2 +761,3 @@ formState.valid = !formState.error && !formState.submitError && !hasAnyError(formState.errors) && !(formState.submitErrors && hasAnyError(formState.submitErrors)); | ||
nextFormState.dirtyFields = lastFormState && shallowEqual(lastFormState.dirtyFields, dirtyFields) ? lastFormState.dirtyFields : dirtyFields; | ||
nextFormState.touched = lastFormState && shallowEqual(lastFormState.touched, touched) ? lastFormState.touched : touched; | ||
@@ -824,3 +822,3 @@ nextFormState.visited = lastFormState && shallowEqual(lastFormState.visited, visited) ? lastFormState.visited : visited; | ||
delete formState.active; | ||
fields[name] = _objectSpread({}, previous, { | ||
fields[name] = _extends({}, previous, { | ||
active: false, | ||
@@ -1011,2 +1009,3 @@ touched: true | ||
state.formState.submitSucceeded = false; | ||
delete state.formState.submitError; | ||
delete state.formState.submitErrors; | ||
@@ -1105,5 +1104,3 @@ delete state.formState.lastSubmittedValues; | ||
return result; | ||
}, [])).then(function () { | ||
return api.submit(); | ||
}); | ||
}, [])).then(api.submit, api.submit); | ||
return; | ||
@@ -1145,3 +1142,3 @@ } | ||
formState.submitSucceeded = false; | ||
formState.lastSubmittedValues = _objectSpread({}, formState.values); | ||
formState.lastSubmittedValues = _extends({}, formState.values); | ||
@@ -1168,3 +1165,3 @@ if (onSubmit.length === 3) { | ||
return result.then(complete); | ||
return result.then(complete, complete); | ||
} else { | ||
@@ -1171,0 +1168,0 @@ // onSubmit is sync |
@@ -7,34 +7,18 @@ (function (global, factory) { | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
return obj; | ||
} | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
ownKeys.forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
}; | ||
return target; | ||
return _extends.apply(this, arguments); | ||
} | ||
@@ -84,3 +68,3 @@ | ||
if (isNaN(key)) { | ||
var _objectSpread2; | ||
var _extends2; | ||
@@ -125,3 +109,3 @@ // object set | ||
return _objectSpread({}, current, (_objectSpread2 = {}, _objectSpread2[key] = _result, _objectSpread2)); | ||
return _extends({}, current, (_extends2 = {}, _extends2[key] = _result, _extends2)); | ||
} // array set | ||
@@ -300,3 +284,3 @@ | ||
// | ||
var formSubscriptionItems = ['active', 'dirty', 'dirtySinceLastSubmit', 'error', 'errors', 'hasSubmitErrors', 'hasValidationErrors', 'initialValues', 'invalid', 'pristine', 'submitting', 'submitError', 'submitErrors', 'submitFailed', 'submitSucceeded', 'touched', 'valid', 'validating', 'values', 'visited']; | ||
var formSubscriptionItems = ['active', 'dirty', 'dirtyFields', 'dirtySinceLastSubmit', 'error', 'errors', 'hasSubmitErrors', 'hasValidationErrors', 'initialValues', 'invalid', 'pristine', 'submitting', 'submitError', 'submitErrors', 'submitFailed', 'submitSucceeded', 'touched', 'valid', 'validating', 'values', 'visited']; | ||
@@ -446,3 +430,3 @@ // | ||
errors: {}, | ||
initialValues: initialValues && _objectSpread({}, initialValues), | ||
initialValues: initialValues && _extends({}, initialValues), | ||
invalid: false, | ||
@@ -455,3 +439,3 @@ pristine: true, | ||
validating: 0, | ||
values: initialValues ? _objectSpread({}, initialValues) : {} | ||
values: initialValues ? _extends({}, initialValues) : {} | ||
}, | ||
@@ -520,3 +504,3 @@ lastFormState: undefined | ||
if (validate) { | ||
var errorsOrPromise = validate(_objectSpread({}, state.formState.values)); // clone to avoid writing | ||
var errorsOrPromise = validate(_extends({}, state.formState.values)); // clone to avoid writing | ||
@@ -559,3 +543,4 @@ if (isPromise(errorsOrPromise)) { | ||
var asyncValidationPromiseKey = nextAsyncValidationKey++; | ||
var promise = errorOrPromise.then(setError).then(clearAsyncValidationPromise(asyncValidationPromiseKey)); | ||
var promise = errorOrPromise.then(setError) // errors must be resolved, not rejected | ||
.then(clearAsyncValidationPromise(asyncValidationPromiseKey)); | ||
promises.push(promise); | ||
@@ -627,3 +612,3 @@ asyncValidationPromises[asyncValidationPromiseKey] = promise; | ||
var processErrors = function processErrors() { | ||
var merged = _objectSpread({}, limitedFieldLevelValidation ? formState.errors : {}, recordLevelErrors); | ||
var merged = _extends({}, limitedFieldLevelValidation ? formState.errors : {}, recordLevelErrors); | ||
@@ -674,3 +659,3 @@ var forEachError = function forEachError(fn) { | ||
Promise.all(promises).then(function () { | ||
var afterPromises = function afterPromises() { | ||
state.formState.validating--; | ||
@@ -682,3 +667,5 @@ processErrors(); | ||
} | ||
}); | ||
}; | ||
Promise.all(promises).then(afterPromises, afterPromises); | ||
} else if (callback) { | ||
@@ -748,9 +735,19 @@ callback(); | ||
formState.pristine = fieldKeys.every(function (key) { | ||
return fields[key].isEqual(getIn(formState.values, key), getIn(formState.initialValues || {}, key)); | ||
}); | ||
var foundDirty = false; | ||
var dirtyFields = fieldKeys.reduce(function (result, key) { | ||
var dirty = !fields[key].isEqual(getIn(formState.values, key), getIn(formState.initialValues || {}, key)); | ||
if (dirty) { | ||
foundDirty = true; | ||
result[key] = true; | ||
} | ||
return result; | ||
}, {}); | ||
formState.pristine = !foundDirty; | ||
formState.dirtySinceLastSubmit = !!(formState.lastSubmittedValues && !fieldKeys.every(function (key) { | ||
return fields[key].isEqual(getIn(formState.values, key), // istanbul ignore next | ||
getIn(formState.lastSubmittedValues || {}, key) // || {} is for flow, but causes branch coverage complaint | ||
); | ||
// istanbul ignore next | ||
var nonNullLastSubmittedValues = formState.lastSubmittedValues || {}; // || {} is for flow, but causes branch coverage complaint | ||
return fields[key].isEqual(getIn(formState.values, key), getIn(nonNullLastSubmittedValues, key)); | ||
})); | ||
@@ -771,2 +768,3 @@ formState.valid = !formState.error && !formState.submitError && !hasAnyError(formState.errors) && !(formState.submitErrors && hasAnyError(formState.submitErrors)); | ||
nextFormState.dirtyFields = lastFormState && shallowEqual(lastFormState.dirtyFields, dirtyFields) ? lastFormState.dirtyFields : dirtyFields; | ||
nextFormState.touched = lastFormState && shallowEqual(lastFormState.touched, touched) ? lastFormState.touched : touched; | ||
@@ -831,3 +829,3 @@ nextFormState.visited = lastFormState && shallowEqual(lastFormState.visited, visited) ? lastFormState.visited : visited; | ||
delete formState.active; | ||
fields[name] = _objectSpread({}, previous, { | ||
fields[name] = _extends({}, previous, { | ||
active: false, | ||
@@ -1018,2 +1016,3 @@ touched: true | ||
state.formState.submitSucceeded = false; | ||
delete state.formState.submitError; | ||
delete state.formState.submitErrors; | ||
@@ -1112,5 +1111,3 @@ delete state.formState.lastSubmittedValues; | ||
return result; | ||
}, [])).then(function () { | ||
return api.submit(); | ||
}); | ||
}, [])).then(api.submit, api.submit); | ||
return; | ||
@@ -1152,3 +1149,3 @@ } | ||
formState.submitSucceeded = false; | ||
formState.lastSubmittedValues = _objectSpread({}, formState.values); | ||
formState.lastSubmittedValues = _extends({}, formState.values); | ||
@@ -1175,3 +1172,3 @@ if (onSubmit.length === 3) { | ||
return result.then(complete); | ||
return result.then(complete, complete); | ||
} else { | ||
@@ -1178,0 +1175,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 V(n){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{},t=Object.keys(a);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(a).filter(function(e){return Object.getOwnPropertyDescriptor(a,e).enumerable}))),t.forEach(function(e){var t,r,i;t=n,i=a[r=e],r in t?Object.defineProperty(t,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[r]=i})}return n}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)},N=function(e,t){for(var r=u(t),i=e,n=0;n<r.length;n++){var a=r[n];if(null==i||"object"!=typeof i||Array.isArray(i)&&isNaN(a))return;i=i[a]}return i},R=function(e,t,r){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,r,i,n){if(r>=i.length)return n;var a=i[r];if(isNaN(a)){var u;if(null==t){var o,s=e(void 0,r+1,i,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],r+1,i,n),c=Object.keys(t).length;if(void 0===l){if(void 0===t[a]&&0===c)return;if(void 0!==t[a]&&c<=1)return isNaN(i[r-1])?void 0:{}}return V({},t,((u={})[a]=l,u))}var f=Number(a);if(null==t){var d=e(void 0,r+1,i,n);if(void 0===d)return;var v=[];return v[f]=d,v}if(!Array.isArray(t))throw new Error("Cannot set a numeric property on an object");var b=e(t[f],r+1,i,n),m=t.concat();return m[f]=b,m}(e,0,u(t),r)},A="FINAL_FORM/form-error",P="FINAL_FORM/array-error",I=function(e,t){var r=e.errors,i=e.initialValues,n=e.lastSubmittedValues,a=e.submitErrors,u=e.submitFailed,o=e.submitSucceeded,s=e.values,l=t.active,c=t.blur,f=t.change,d=t.data,v=t.focus,b=t.name,m=t.touched,S=t.visited,h=N(s,b),y=N(r,b);y&&y[P]&&(y=y[P]);var g=a&&N(a,b),p=i&&N(i,b),E=t.isEqual(p,h),O=!y&&!g;return{active:l,blur:c,change:f,data:d,dirty:!E,dirtySinceLastSubmit:!(!n||t.isEqual(N(n,b),h)),error:y,focus:v,initial:p,invalid:!O,length:Array.isArray(h)?h.length:void 0,name:b,pristine:E,submitError:g,submitFailed:u,submitSucceeded:o,touched:m,valid:O,value:h,visited:S}},a=["active","data","dirty","dirtySinceLastSubmit","error","initial","invalid","length","pristine","submitError","submitFailed","submitSucceeded","touched","valid","value","visited"],x=function(e,t){if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof 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};function o(t,r,i,n,e,a){var u=!1;return e.forEach(function(e){n[e]&&(t[e]=r[e],i&&(~a.indexOf(e)?x(r[e],i[e]):r[e]===i[e])||(u=!0))}),u}var s=["data"],L=function(e,t,r,i){var n={blur:e.blur,change:e.change,focus:e.focus,name:e.name};return o(n,e,t,r,a,s)||!t||i?n:void 0},l=["active","dirty","dirtySinceLastSubmit","error","errors","hasSubmitErrors","hasValidationErrors","initialValues","invalid","pristine","submitting","submitError","submitErrors","submitFailed","submitSucceeded","touched","valid","validating","values","visited"],c=["touched","visited"],q=function(e,t,r,i){var n={};return o(n,e,t,r,l,c)||!t||i?n:void 0},z=function(i){var n,a;return function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return n&&t.length===n.length&&!t.some(function(e,t){return!x(n[t],e)})||(n=t,a=i.apply(void 0,t)),a}},_=function(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then},C=function(e,t){return e===t},B=function r(i){return Object.keys(i).some(function(e){var t=i[e];return t&&"object"==typeof t?r(t):void 0!==t})},D=function(e){var t=e.active,r=e.dirtySinceLastSubmit,i=e.error,n=e.errors,a=e.initialValues,u=e.pristine,o=e.submitting,s=e.submitFailed,l=e.submitSucceeded,c=e.submitError,f=e.submitErrors,d=e.valid,v=e.validating,b=e.values;return{active:t,dirty:!u,dirtySinceLastSubmit:r,error:i,errors:n,hasSubmitErrors:!!(c||f&&B(f)),hasValidationErrors:!(!i&&!B(n)),invalid:!d,initialValues:a,pristine:u,submitting:o,submitFailed:s,submitSucceeded:l,submitError:c,submitErrors:f,valid:d,validating:0<v,values:b}};function M(e,t,r,i,n,a){void 0===a&&(a=!1);var u=n(r,i,t,a);u&&e(u)}function U(e,i,n,a){var u=e.entries;Object.keys(u).forEach(function(e){var t=u[Number(e)],r=t.subscription;M(t.subscriber,r,i,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,d=e.validate,n=e.validateOnBlur;if(!s)throw new Error("No onSubmit function specified");var v={subscribers:{index:0,entries:{}},fieldSubscribers:{},fields:{},formState:{dirtySinceLastSubmit:!1,errors:{},initialValues:t&&V({},t),invalid:!1,pristine:!0,submitting:!1,submitFailed:!1,submitSucceeded:!1,valid:!0,validating:0,values:t?V({},t):{}},lastFormState:void 0},i=!1,b=!1,m=!1,S=0,h={},y=function(t){return function(e){return delete h[t],e}},l=function(e,t,r){var i=r(N(e.formState.values,t));e.formState.values=R(e.formState.values,t,i)||{}},r=function(a){return function(){if(u){for(var e={formState:v.formState,fields:v.fields},t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];var n=u[a](r,e,{changeValue:l,getIn:N,setIn:R,shallowEqual:x});return v.formState=e.formState,v.fields=e.fields,f(void 0,function(){p(),j()}),n}}},c=u&&Object.keys(u).reduce(function(e,t){return e[t]=r(t),e},{})||{},g=function(i){return Object.keys(i.validators).reduce(function(e,t){var r=i.validators[Number(t)]();return r&&e.push(r),e},[])},f=function(e,t){if(b)return m=!0,void(t&&t());var s=v.fields,r=v.formState,i=Object.keys(s);if(d||i.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,i=a.length?a.concat(e):[e])}}var l={},c={},u=function(e){var t=[];if(d){var r=d(V({},v.formState.values));if(_(r)){var i=S++,n=r.then(e).then(y(i));t.push(n),h[i]=n}else e(r)}return t}(function(e){l=e||{}}).concat(i.reduce(function(e,t){return e.concat((n=s[t],a=function(e){c[t]=e},o=[],(r=g(n)).length&&(r.forEach(function(e){var t=e(N(v.formState.values,n.name),v.formState.values);if(t&&_(t)){var r=S++,i=t.then(a).then(y(r));o.push(i),h[r]=i}else u||(u=t)}),a(u)),o));var n,a,u,o,r},[])),f=function(){var u=V({},o?r.errors:{},l),e=function(a){i.forEach(function(e){if(s[e]){var t=N(l,e),r=N(u,e),i=g(s[e]).length,n=c[e];a(e,i&&n||d&&t||(t||o?void 0:r))}})};e(function(e,t){u=R(u,e,t)||{}}),e(function(e,t){if(t&&t[P]){var r=N(u,e).concat();r[P]=t[P],u=R(u,e,r)}}),x(r.errors,u)||(r.errors=u),r.error=l[A]};f(),u.length?(v.formState.validating++,t&&t(),Promise.all(u).then(function(){v.formState.validating--,f(),t&&t()})):t&&t()}else t&&t()},p=function(e){if(!i&&!b){var n=v.fields,a=v.fieldSubscribers,u=v.formState;Object.keys(n).forEach(function(e){var t=n[e],r=I(u,t),i=t.lastFieldState;x(r,i)||(t.lastFieldState=r,U(a[e],r,i,L))})}},E=function(){Object.keys(v.fields).forEach(function(e){v.fields[e].touched=!0})},O=function(){var r=v.fields,t=v.formState,e=v.lastFormState,i=Object.keys(r);t.pristine=i.every(function(e){return r[e].isEqual(N(t.values,e),N(t.initialValues||{},e))}),t.dirtySinceLastSubmit=!(!t.lastSubmittedValues||i.every(function(e){return r[e].isEqual(N(t.values,e),N(t.lastSubmittedValues||{},e))})),t.valid=!(t.error||t.submitError||B(t.errors)||t.submitErrors&&B(t.submitErrors));var n=D(t),a=i.reduce(function(e,t){return e.touched[t]=r[t].touched,e.visited[t]=r[t].visited,e},{touched:{},visited:{}}),u=a.touched,o=a.visited;return n.touched=e&&x(e.touched,u)?e.touched:u,n.visited=e&&x(e.visited,o)?e.visited:o,e&&x(e,n)?e:n},F=!1,w=!1,j=function e(){if(F)w=!0;else{if(F=!0,!i&&!b){var t=v.lastFormState,r=O();r!==t&&(v.lastFormState=r,U(v.subscribers,r,t,q))}F=!1,w&&(w=!1,e())}};f();var k={batch:function(e){i=!0,e(),i=!1,p(),j()},blur:function(e){var t=v.fields,r=v.formState,i=t[e];i&&(delete r.active,t[e]=V({},i,{active:!1,touched:!0}),n?f(e,function(){p(),j()}):(p(),j()))},change:function(e,t){var r=v.formState;N(r.values,e)!==t&&(l(v,e,function(){return t}),n?(p(),j()):f(e,function(){p(),j()}))},focus:function(e){var t=v.fields[e];t&&!t.active&&(v.formState.active=e,t.active=!0,t.visited=!0,p(),j())},mutators:c,getFieldState:function(e){var t=v.fields[e];return t&&t.lastFieldState},getRegisteredFields:function(){return Object.keys(v.fields)},getState:function(){return D(v.formState)},initialize:function(r){var i=v.fields,n=v.formState;a||(n.values=r),Object.keys(i).forEach(function(e){var t=i[e];t.touched=!1,t.visited=!1,a&&i[e].isEqual(N(n.values,e),N(n.initialValues||{},e))&&(n.values=R(n.values,e,N(r,e)))}),n.initialValues=r,f(void 0,function(){p(),j()})},isValidationPaused:function(){return b},pauseValidation:function(){b=!0},registerField:function(t,r,i,e){void 0===i&&(i={}),v.fieldSubscribers[t]||(v.fieldSubscribers[t]={index:0,entries:{}});var n=v.fieldSubscribers[t].index++;if(v.fieldSubscribers[t].entries[n]={subscriber:z(r),subscription:i},!v.fields[t]){var a=v.formState.initialValues?N(v.formState.initialValues,t):void 0;v.fields[t]={active:!1,blur:function(){return k.blur(t)},change:function(e){return k.change(t,e)},data:{},focus:function(){return k.focus(t)},initial:a,isEqual:e&&e.isEqual||C,lastFieldState:void 0,name:t,touched:!1,valid:!0,validateFields:e&&e.validateFields,validators:{},visited:!1}}e&&e.getValidator&&(v.fields[t].validators[n]=e.getValidator);var u=!1;return f(void 0,function(){var e;j(),u||(e=I(v.formState,v.fields[t]),M(r,i,e,void 0,L,!0),v.fields[t].lastFieldState=e,u=!0),p()}),function(){delete v.fields[t].validators[n],delete v.fieldSubscribers[t].entries[n],Object.keys(v.fieldSubscribers[t].entries).length||(delete v.fieldSubscribers[t],delete v.fields[t],v.formState.errors=R(v.formState.errors,t,void 0)||{},o&&(v.formState.values=R(v.formState.values,t,void 0)||{})),f(void 0,function(){p(),j()})}},reset:function(e){void 0===e&&(e=v.formState.initialValues),v.formState.submitFailed=!1,v.formState.submitSucceeded=!1,delete v.formState.submitErrors,delete v.formState.lastSubmittedValues,k.initialize(e||{})},resumeValidation:function(){b=!1,m&&f(void 0,function(){p(),j()}),m=!1},setConfig:function(e,t){switch(e){case"debug":break;case"destroyOnUnregister":o=t;break;case"initialValues":k.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]=r(e)})):Object.keys(c).forEach(function(e){delete c[e]});break;case"onSubmit":s=t;break;case"validate":d=t,f(void 0,function(){p(),j()});break;case"validateOnBlur":n=t;break;default:throw new Error("Unrecognised option "+e)}},submit:function(){var t=v.formState;if(v.formState.error||B(v.formState.errors))return E(),v.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(function(){return k.submit()});else{var r,i=!1,n=function(e){return t.submitting=!1,e&&B(e)?(t.submitFailed=!0,t.submitSucceeded=!1,t.submitErrors=e,t.submitError=e[A],E()):(delete t.submitErrors,delete t.submitError,t.submitFailed=!1,t.submitSucceeded=!0),j(),p(),i=!0,r&&r(e),e};if(t.submitting=!0,t.submitFailed=!1,t.submitSucceeded=!1,t.lastSubmittedValues=V({},t.values),3===s.length){if(s(t.values,k,n),!i)return j(),new Promise(function(e){r=e})}else{var a=s(t.values,k);if(a&&_(a))return j(),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 r=z(e),i=v.subscribers,n=v.lastFormState,a=i.index++;i.entries[a]={subscriber:r,subscription:t};var u=O();return u!==n&&(v.lastFormState=u),M(r,t,u,u,q,!0),function(){delete i.entries[a]}}};return k},e.configOptions=["debug","initialValues","keepDirtyOnReinitialize","mutators","onSubmit","validate","validateOnBlur"],e.version="4.8.1",e.ARRAY_ERROR=P,e.FORM_ERROR=A,e.formSubscriptionItems=l,e.fieldSubscriptionItems=a,e.getIn=N,e.setIn=R,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 V(){return(V=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}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)},N=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},R=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 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),c=Object.keys(t).length;if(void 0===l){if(void 0===t[a]&&0===c)return;if(void 0!==t[a]&&c<=1)return isNaN(r[i-1])?void 0:{}}return V({},t,((u={})[a]=l,u))}var f=Number(a);if(null==t){var d=e(void 0,i+1,r,n);if(void 0===d)return;var v=[];return v[f]=d,v}if(!Array.isArray(t))throw new Error("Cannot set a numeric property on an object");var b=e(t[f],i+1,r,n),m=t.concat();return m[f]=b,m}(e,0,u(t),i)},A="FINAL_FORM/form-error",I="FINAL_FORM/array-error",x=function(e,t){var i=e.errors,r=e.initialValues,n=e.lastSubmittedValues,a=e.submitErrors,u=e.submitFailed,o=e.submitSucceeded,s=e.values,l=t.active,c=t.blur,f=t.change,d=t.data,v=t.focus,b=t.name,m=t.touched,S=t.visited,h=N(s,b),y=N(i,b);y&&y[I]&&(y=y[I]);var g=a&&N(a,b),p=r&&N(r,b),E=t.isEqual(p,h),F=!y&&!g;return{active:l,blur:c,change:f,data:d,dirty:!E,dirtySinceLastSubmit:!(!n||t.isEqual(N(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:u,submitSucceeded:o,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"],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"],c=["touched","visited"],P=function(e,t,i,r){var n={};return o(n,e,t,i,l,c)||!t||r?n:void 0},z=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}},_=function(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then},C=function(e,t){return e===t},B=function i(r){return Object.keys(r).some(function(e){var t=r[e];return t&&"object"==typeof t?i(t):void 0!==t})},M=function(e){var t=e.active,i=e.dirtySinceLastSubmit,r=e.error,n=e.errors,a=e.initialValues,u=e.pristine,o=e.submitting,s=e.submitFailed,l=e.submitSucceeded,c=e.submitError,f=e.submitErrors,d=e.valid,v=e.validating,b=e.values;return{active:t,dirty:!u,dirtySinceLastSubmit:i,error:r,errors:n,hasSubmitErrors:!!(c||f&&B(f)),hasValidationErrors:!(!r&&!B(n)),invalid:!d,initialValues:a,pristine:u,submitting:o,submitFailed:s,submitSucceeded:l,submitError:c,submitErrors:f,valid:d,validating:0<v,values:b}};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 b={subscribers:{index:0,entries:{}},fieldSubscribers:{},fields:{},formState:{dirtySinceLastSubmit:!1,errors:{},initialValues:t&&V({},t),invalid:!1,pristine:!0,submitting:!1,submitFailed:!1,submitSucceeded:!1,valid:!0,validating:0,values:t?V({},t):{}},lastFormState:void 0},r=!1,m=!1,S=!1,h=0,y={},g=function(t){return function(e){return delete y[t],e}},l=function(e,t,i){var r=i(N(e.formState.values,t));e.formState.values=R(e.formState.values,t,r)||{}},i=function(a){return function(){if(u){for(var e={formState:b.formState,fields:b.fields},t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];var n=u[a](i,e,{changeValue:l,getIn:N,setIn:R,shallowEqual:L});return b.formState=e.formState,b.fields=e.fields,f(void 0,function(){d(),w()}),n}}},c=u&&Object.keys(u).reduce(function(e,t){return e[t]=i(t),e},{})||{},p=function(r){return Object.keys(r.validators).reduce(function(e,t){var i=r.validators[Number(t)]();return i&&e.push(i),e},[])},f=function(e,t){if(m)return S=!0,void(t&&t());var s=b.fields,i=b.formState,r=Object.keys(s);if(v||r.some(function(e){return p(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={},c={},u=function(e){var t=[];if(v){var i=v(V({},b.formState.values));if(_(i)){var r=h++,n=i.then(e).then(g(r));t.push(n),y[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){c[t]=e},o=[],(i=p(n)).length&&(i.forEach(function(e){var t=e(N(b.formState.values,n.name),b.formState.values);if(t&&_(t)){var i=h++,r=t.then(a).then(g(i));o.push(r),y[i]=r}else u||(u=t)}),a(u)),o));var n,a,u,o,i},[])),f=function(){var u=V({},o?i.errors:{},l),e=function(a){r.forEach(function(e){if(s[e]){var t=N(l,e),i=N(u,e),r=p(s[e]).length,n=c[e];a(e,r&&n||v&&t||(t||o?void 0:i))}})};e(function(e,t){u=R(u,e,t)||{}}),e(function(e,t){if(t&&t[I]){var i=N(u,e).concat();i[I]=t[I],u=R(u,e,i)}}),L(i.errors,u)||(i.errors=u),i.error=l[A]};if(f(),u.length){b.formState.validating++,t&&t();var d=function(){b.formState.validating--,f(),t&&t()};Promise.all(u).then(d,d)}else t&&t()}else t&&t()},d=function(e){if(!r&&!m){var n=b.fields,a=b.fieldSubscribers,u=b.formState;Object.keys(n).forEach(function(e){var t=n[e],i=x(u,t),r=t.lastFieldState;L(i,r)||(t.lastFieldState=i,U(a[e],i,r,q))})}},E=function(){Object.keys(b.fields).forEach(function(e){b.fields[e].touched=!0})},F=function(){var i=b.fields,r=b.formState,e=b.lastFormState,t=Object.keys(i),n=!1,a=t.reduce(function(e,t){return!i[t].isEqual(N(r.values,t),N(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(N(r.values,e),N(t,e))})),r.valid=!(r.error||r.submitError||B(r.errors)||r.submitErrors&&B(r.submitErrors));var u=M(r),o=t.reduce(function(e,t){return e.touched[t]=i[t].touched,e.visited[t]=i[t].visited,e},{touched:{},visited:{}}),s=o.touched,l=o.visited;return u.dirtyFields=e&&L(e.dirtyFields,a)?e.dirtyFields:a,u.touched=e&&L(e.touched,s)?e.touched:s,u.visited=e&&L(e.visited,l)?e.visited:l,e&&L(e,u)?e:u},O=!1,k=!1,w=function e(){if(O)k=!0;else{if(O=!0,!r&&!m){var t=b.lastFormState,i=F();i!==t&&(b.lastFormState=i,U(b.subscribers,i,t,P))}O=!1,k&&(k=!1,e())}};f();var j={batch:function(e){r=!0,e(),r=!1,d(),w()},blur:function(e){var t=b.fields,i=b.formState,r=t[e];r&&(delete i.active,t[e]=V({},r,{active:!1,touched:!0}),n?f(e,function(){d(),w()}):(d(),w()))},change:function(e,t){var i=b.formState;N(i.values,e)!==t&&(l(b,e,function(){return t}),n?(d(),w()):f(e,function(){d(),w()}))},focus:function(e){var t=b.fields[e];t&&!t.active&&(b.formState.active=e,t.active=!0,t.visited=!0,d(),w())},mutators:c,getFieldState:function(e){var t=b.fields[e];return t&&t.lastFieldState},getRegisteredFields:function(){return Object.keys(b.fields)},getState:function(){return M(b.formState)},initialize:function(i){var r=b.fields,n=b.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(N(n.values,e),N(n.initialValues||{},e))&&(n.values=R(n.values,e,N(i,e)))}),n.initialValues=i,f(void 0,function(){d(),w()})},isValidationPaused:function(){return m},pauseValidation:function(){m=!0},registerField:function(t,i,r,e){void 0===r&&(r={}),b.fieldSubscribers[t]||(b.fieldSubscribers[t]={index:0,entries:{}});var n=b.fieldSubscribers[t].index++;if(b.fieldSubscribers[t].entries[n]={subscriber:z(i),subscription:r},!b.fields[t]){var a=b.formState.initialValues?N(b.formState.initialValues,t):void 0;b.fields[t]={active:!1,blur:function(){return j.blur(t)},change:function(e){return j.change(t,e)},data:{},focus:function(){return j.focus(t)},initial:a,isEqual:e&&e.isEqual||C,lastFieldState:void 0,name:t,touched:!1,valid:!0,validateFields:e&&e.validateFields,validators:{},visited:!1}}e&&e.getValidator&&(b.fields[t].validators[n]=e.getValidator);var u=!1;return f(void 0,function(){var e;w(),u||(e=x(b.formState,b.fields[t]),D(i,r,e,void 0,q,!0),b.fields[t].lastFieldState=e,u=!0),d()}),function(){delete b.fields[t].validators[n],delete b.fieldSubscribers[t].entries[n],Object.keys(b.fieldSubscribers[t].entries).length||(delete b.fieldSubscribers[t],delete b.fields[t],b.formState.errors=R(b.formState.errors,t,void 0)||{},o&&(b.formState.values=R(b.formState.values,t,void 0)||{})),f(void 0,function(){d(),w()})}},reset:function(e){void 0===e&&(e=b.formState.initialValues),b.formState.submitFailed=!1,b.formState.submitSucceeded=!1,delete b.formState.submitError,delete b.formState.submitErrors,delete b.formState.lastSubmittedValues,j.initialize(e||{})},resumeValidation:function(){m=!1,S&&f(void 0,function(){d(),w()}),S=!1},setConfig:function(e,t){switch(e){case"debug":break;case"destroyOnUnregister":o=t;break;case"initialValues":j.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,f(void 0,function(){d(),w()});break;case"validateOnBlur":n=t;break;default:throw new Error("Unrecognised option "+e)}},submit:function(){var t=b.formState;if(b.formState.error||B(b.formState.errors))return E(),b.formState.submitFailed=!0,w(),void d();var e=Object.keys(y);if(e.length)Promise.all(e.reduce(function(e,t){return e.push(y[Number(t)]),e},[])).then(j.submit,j.submit);else{var i,r=!1,n=function(e){return t.submitting=!1,e&&B(e)?(t.submitFailed=!0,t.submitSucceeded=!1,t.submitErrors=e,t.submitError=e[A],E()):(delete t.submitErrors,delete t.submitError,t.submitFailed=!1,t.submitSucceeded=!0),w(),d(),r=!0,i&&i(e),e};if(t.submitting=!0,t.submitFailed=!1,t.submitSucceeded=!1,t.lastSubmittedValues=V({},t.values),3===s.length){if(s(t.values,j,n),!r)return w(),new Promise(function(e){i=e})}else{var a=s(t.values,j);if(a&&_(a))return w(),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=z(e),r=b.subscribers,n=b.lastFormState,a=r.index++;r.entries[a]={subscriber:i,subscription:t};var u=F();return u!==n&&(b.lastFormState=u),D(i,t,u,u,P,!0),function(){delete r.entries[a]}}};return j},e.configOptions=["debug","initialValues","keepDirtyOnReinitialize","mutators","onSubmit","validate","validateOnBlur"],e.version="4.8.1",e.ARRAY_ERROR=I,e.FORM_ERROR=A,e.formSubscriptionItems=l,e.fieldSubscriptionItems=a,e.getIn=N,e.setIn=R,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=final-form.umd.min.js.map |
{ | ||
"name": "final-form", | ||
"version": "4.8.3", | ||
"version": "4.9.0", | ||
"description": "π Framework agnostic, high performance, subscription-based form state management", | ||
@@ -30,5 +30,14 @@ "main": "dist/final-form.cjs.js", | ||
"@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-stage-2": "^7.0.0-beta.49", | ||
"@types/node": "^9.6.7", | ||
"@babel/preset-flow": "7.0.0-beta.54", | ||
"@types/node": "^10.5.4", | ||
"babel-core": "^7.0.0-bridge.0", | ||
@@ -40,3 +49,3 @@ "babel-eslint": "^8.2.3", | ||
"doctoc": "^1.3.1", | ||
"eslint": "^4.19.1", | ||
"eslint": "^5.2.0", | ||
"eslint-config-react-app": "^2.1.0", | ||
@@ -48,3 +57,3 @@ "eslint-plugin-babel": "^5.1.0", | ||
"eslint-plugin-react": "^7.8.2", | ||
"flow-bin": "^0.73.0", | ||
"flow-bin": "^0.77.0", | ||
"glow": "^1.2.2", | ||
@@ -58,3 +67,3 @@ "husky": "^0.14.3", | ||
"prettier-eslint-cli": "^4.7.1", | ||
"rollup": "^0.59.4", | ||
"rollup": "^0.63.4", | ||
"rollup-plugin-babel": "^4.0.0-beta.4", | ||
@@ -67,3 +76,3 @@ "rollup-plugin-commonjs": "^9.1.3", | ||
"tslint": "^5.10.0", | ||
"typescript": "^2.8.4" | ||
"typescript": "^3.0.1" | ||
}, | ||
@@ -70,0 +79,0 @@ "lint-staged": { |
403
README.md
@@ -100,183 +100,186 @@ # π Final Form | ||
* [Examples](#examples) | ||
* [Simple React Example](#simple-react-example) | ||
* [Official Mutators](#official-mutators) | ||
* [π Final Form Arrays](#-final-form-arrays) | ||
* [π Final Form Set Field Data](#-final-form-set-field-data) | ||
* [π Final Form Set Field Touched](#-final-form-set-field-touched) | ||
* [Libraries](#libraries) | ||
* [π React Final Form](#-react-final-form) | ||
* [Vue Final Form](#vue-final-form) | ||
* [Define Form and React Define Form](#define-form-and-react-define-form) | ||
* [π Final Form Focus π§](#-final-form-focus-) | ||
* [π React Final Form HTML5 Validation](#-react-final-form-html5-validation) | ||
* [π React Final Form Listeners](#-react-final-form-listeners) | ||
* [Field Names](#field-names) | ||
* [API](#api) | ||
* [`createForm: (config: Config) => FormApi`](#createform-config-config--formapi) | ||
* [`fieldSubscriptionItems: string[]`](#fieldsubscriptionitems-string) | ||
* [`formSubscriptionItems: string[]`](#formsubscriptionitems-string) | ||
* [`ARRAY_ERROR: string`](#array_error-string) | ||
* [`FORM_ERROR: string`](#form_error-string) | ||
* [`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) | ||
* [Types](#types) | ||
* [`Config`](#config) | ||
* [`debug?: DebugFunction`](#debug-debugfunction) | ||
* [`destroyOnUnregister?: boolean`](#destroyonunregister-boolean) | ||
* [`keepDirtyOnReinitialize?: boolean`](#keepdirtyonreinitialize-boolean) | ||
* [`initialValues?: Object`](#initialvalues-object) | ||
* [`mutators?: { [string]: Mutator }`](#mutators--string-mutator-) | ||
* [`onSubmit: (values: Object, form: FormApi, callback: ?(errors: ?Object) => void) => ?Object | Promise<?Object> | void`](#onsubmit-values-object-form-formapi-callback-errors-object--void--object--promiseobject--void) | ||
* [`validate?: (values: Object) => Object | Promise<Object>`](#validate-values-object--object--promiseobject) | ||
* [`validateOnBlur?: boolean`](#validateonblur-boolean) | ||
* [`DebugFunction: (state: FormState, fieldStates: { [string]: FieldState }) => void`](#debugfunction-state-formstate-fieldstates--string-fieldstate---void) | ||
* [`Decorator: (form: FormApi) => Unsubscribe`](#decorator-form-formapi--unsubscribe) | ||
* [`FieldConfig`](#fieldconfig) | ||
* [`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) | ||
* [`validateFields?: string[]`](#validatefields-string) | ||
* [`FieldState`](#fieldstate) | ||
* [`active?: boolean`](#active-boolean) | ||
* [`blur: () => void`](#blur---void) | ||
* [`change: (value: any) => void`](#change-value-any--void) | ||
* [`data?: Object`](#data-object) | ||
* [`dirty?: boolean`](#dirty-boolean) | ||
* [`dirtySinceLastSubmit?: boolean`](#dirtysincelastsubmit-boolean) | ||
* [`error?: any`](#error-any) | ||
* [`focus: () => void`](#focus---void) | ||
* [`initial?: any`](#initial-any) | ||
* [`invalid?: boolean`](#invalid-boolean) | ||
* [`length?: number`](#length-number) | ||
* [`name: string`](#name-string) | ||
* [`pristine?: boolean`](#pristine-boolean) | ||
* [`submitError?: any`](#submiterror-any) | ||
* [`submitFailed?: boolean`](#submitfailed-boolean) | ||
* [`submitSucceeded?: boolean`](#submitsucceeded-boolean) | ||
* [`touched?: boolean`](#touched-boolean) | ||
* [`valid?: boolean`](#valid-boolean) | ||
* [`value?: any`](#value-any) | ||
* [`visited?: boolean`](#visited-boolean) | ||
* [`FieldSubscriber: (state: FieldState) => void`](#fieldsubscriber-state-fieldstate--void) | ||
* [`FieldSubscription: { [string]: boolean }`](#fieldsubscription--string-boolean-) | ||
* [`active?: boolean`](#active-boolean-1) | ||
* [`data?: boolean`](#data-boolean) | ||
* [`dirty?: boolean`](#dirty-boolean-1) | ||
* [`dirtySinceLastSubmit?: boolean`](#dirtysincelastsubmit-boolean-1) | ||
* [`error?: boolean`](#error-boolean) | ||
* [`initial?: boolean`](#initial-boolean) | ||
* [`invalid?: boolean`](#invalid-boolean-1) | ||
* [`length?: boolean`](#length-boolean) | ||
* [`pristine?: boolean`](#pristine-boolean-1) | ||
* [`submitError?: boolean`](#submiterror-boolean) | ||
* [`submitFailed?: boolean`](#submitfailed-boolean-1) | ||
* [`submitSucceeded?: boolean`](#submitsucceeded-boolean-1) | ||
* [`touched?: boolean`](#touched-boolean-1) | ||
* [`valid?: boolean`](#valid-boolean-1) | ||
* [`value?: boolean`](#value-boolean) | ||
* [`visited?: boolean`](#visited-boolean-1) | ||
* [`FormApi`](#formapi) | ||
* [`batch: (fn: () => void) => void)`](#batch-fn---void--void) | ||
* [`blur: (name: string) => void`](#blur-name-string--void) | ||
* [`change: (name: string, value: ?any) => void`](#change-name-string-value-any--void) | ||
* [`focus: (name: string) => void`](#focus-name-string--void) | ||
* [`getFieldState: (field: string) => ?FieldState`](#getfieldstate-field-string--fieldstate) | ||
* [`getRegisteredFields: () => string[]`](#getregisteredfields---string) | ||
* [`getState: () => FormState`](#getstate---formstate) | ||
* [`initialize: (values: Object) => void`](#initialize-values-object--void) | ||
* [`isValidationPaused: () => boolean`](#isvalidationpaused---boolean) | ||
* [`mutators: ?{ [string]: Function }`](#mutators--string-function-) | ||
* [`pauseValidation: () => void`](#pausevalidation---void) | ||
* [`registerField: RegisterField`](#registerfield-registerfield) | ||
* [`reset: (initialValues: ?Object) => void`](#reset-initialvalues-object--void) | ||
* [`resumeValidation: () => void`](#resumevalidation---void) | ||
* [`submit: () => ?Promise<?Object>`](#submit---promiseobject) | ||
* [`subscribe: (subscriber: FormSubscriber, subscription: FormSubscription) => Unsubscribe`](#subscribe-subscriber-formsubscriber-subscription-formsubscription--unsubscribe) | ||
* [`FormState`](#formstate) | ||
* [`active?: string`](#active-string) | ||
* [`dirty?: boolean`](#dirty-boolean-2) | ||
* [`error?: any`](#error-any-1) | ||
* [`errors?: Object`](#errors-object) | ||
* [`hasSubmitErrors?: boolean`](#hassubmiterrors-boolean) | ||
* [`hasValidationErrors?: boolean`](#hasvalidationerrors-boolean) | ||
* [`initialValues?: Object`](#initialvalues-object-1) | ||
* [`invalid?: boolean`](#invalid-boolean-2) | ||
* [`pristine?: boolean`](#pristine-boolean-2) | ||
* [`submitError?: any`](#submiterror-any-1) | ||
* [`submitErrors?: Object`](#submiterrors-object) | ||
* [`submitFailed?: boolean`](#submitfailed-boolean-2) | ||
* [`submitSucceeded?: boolean`](#submitsucceeded-boolean-2) | ||
* [`submitting?: boolean`](#submitting-boolean) | ||
* [`touched: { [string]: boolean }`](#touched--string-boolean-) | ||
* [`valid?: boolean`](#valid-boolean-2) | ||
* [`validating?: boolean`](#validating-boolean) | ||
* [`values?: Object`](#values-object) | ||
* [`visited: { [string]: boolean }`](#visited--string-boolean-) | ||
* [`FormSubscriber: (state: FormState) => void`](#formsubscriber-state-formstate--void) | ||
* [`FormSubscription: { [string]: boolean }`](#formsubscription--string-boolean-) | ||
* [`active?: boolean`](#active-boolean-2) | ||
* [`dirty?: boolean`](#dirty-boolean-3) | ||
* [`dirtySinceLastSubmit?: boolean`](#dirtysincelastsubmit-boolean-2) | ||
* [`error?: boolean`](#error-boolean-1) | ||
* [`errors?: boolean`](#errors-boolean) | ||
* [`hasSubmitErrors?: boolean`](#hassubmiterrors-boolean-1) | ||
* [`hasValidationErrors?: boolean`](#hasvalidationerrors-boolean-1) | ||
* [`initialValues?: boolean`](#initialvalues-boolean) | ||
* [`invalid?: boolean`](#invalid-boolean-3) | ||
* [`pristine?: boolean`](#pristine-boolean-3) | ||
* [`setConfig: (name: string, value: any) => void`](#setconfig-name-string-value-any--void) | ||
* [`submitError?: boolean`](#submiterror-boolean-1) | ||
* [`submitErrors?: boolean`](#submiterrors-boolean) | ||
* [`submitFailed?: boolean`](#submitfailed-boolean-3) | ||
* [`submitSucceeded?: boolean`](#submitsucceeded-boolean-3) | ||
* [`submitting?: boolean`](#submitting-boolean-1) | ||
* [`touched?: boolean`](#touched-boolean-2) | ||
* [`valid?: boolean`](#valid-boolean-3) | ||
* [`validating?: boolean`](#validating-boolean-1) | ||
* [`values?: boolean`](#values-boolean) | ||
* [`visited?: boolean`](#visited-boolean-2) | ||
* [`InternalFieldState`](#internalfieldstate) | ||
* [`active: boolean`](#active-boolean) | ||
* [`blur: () => void`](#blur---void-1) | ||
* [`change: (value: any) => void`](#change-value-any--void-1) | ||
* [`data: Object`](#data-object) | ||
* [`focus: () => void`](#focus---void-1) | ||
* [`isEqual: (a: any, b: any) => boolean`](#isequal-a-any-b-any--boolean) | ||
* [`name: string`](#name-string-1) | ||
* [`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) | ||
* [`visited: boolean`](#visited-boolean) | ||
* [`InternalFormState`](#internalformstate) | ||
* [`active?: string`](#active-string-1) | ||
* [`dirtySinceLastSubmit: boolean`](#dirtysincelastsubmit-boolean) | ||
* [`error?: any`](#error-any-2) | ||
* [`errors: Object`](#errors-object) | ||
* [`initialValues?: Object`](#initialvalues-object-2) | ||
* [`lastSubmittedValues?: Object`](#lastsubmittedvalues-object) | ||
* [`pristine: boolean`](#pristine-boolean) | ||
* [`submitError: any`](#submiterror-any) | ||
* [`submitErrors?: Object`](#submiterrors-object-1) | ||
* [`submitFailed: boolean`](#submitfailed-boolean) | ||
* [`submitSucceeded: boolean`](#submitsucceeded-boolean) | ||
* [`submitting: boolean`](#submitting-boolean) | ||
* [`valid: boolean`](#valid-boolean-1) | ||
* [`validating: number`](#validating-number) | ||
* [`values: Object`](#values-object) | ||
* [`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, config?: FieldConfig) => Unsubscribe`](#registerfield-name-string-subscriber-fieldsubscriber-subscription-fieldsubscription-config-fieldconfig--unsubscribe) | ||
* [`Tools`](#tools) | ||
* [`Tools.changeValue: (state: MutableState, name: string, mutate: (value: any) => any) => void`](#toolschangevalue-state-mutablestate-name-string-mutate-value-any--any--void) | ||
* [`Tools.getIn: (state: Object, complexKey: string) => any`](#toolsgetin-state-object-complexkey-string--any) | ||
* [`Tools.setIn: (state: Object, key: string, value: any) => Object`](#toolssetin-state-object-key-string-value-any--object) | ||
* [`Tools.shallowEqual: (a: any, b: any) => boolean`](#toolsshallowequal-a-any-b-any--boolean) | ||
* [`Unsubscribe : () => void`](#unsubscribe----void) | ||
* [Contributors](#contributors) | ||
* [Backers](#backers) | ||
* [Sponsors](#sponsors) | ||
- [Examples](#examples) | ||
- [Simple React Example](#simple-react-example) | ||
- [Official Mutators](#official-mutators) | ||
- [π Final Form Arrays](#-final-form-arrays) | ||
- [π Final Form Set Field Data](#-final-form-set-field-data) | ||
- [π Final Form Set Field Touched](#-final-form-set-field-touched) | ||
- [Libraries](#libraries) | ||
- [π React Final Form](#-react-final-form) | ||
- [Vue Final Form](#vue-final-form) | ||
- [Define Form and React Define Form](#define-form-and-react-define-form) | ||
- [π Final Form Focus π§](#-final-form-focus-) | ||
- [π React Final Form HTML5 Validation](#-react-final-form-html5-validation) | ||
- [π React Final Form Listeners](#-react-final-form-listeners) | ||
- [Field Names](#field-names) | ||
- [API](#api) | ||
- [`createForm: (config: Config) => FormApi`](#createform-config-config--formapi) | ||
- [`fieldSubscriptionItems: string[]`](#fieldsubscriptionitems-string) | ||
- [`formSubscriptionItems: string[]`](#formsubscriptionitems-string) | ||
- [`ARRAY_ERROR: string`](#array_error-string) | ||
- [`FORM_ERROR: string`](#form_error-string) | ||
- [`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) | ||
- [Types](#types) | ||
- [`Config`](#config) | ||
- [`debug?: DebugFunction`](#debug-debugfunction) | ||
- [`destroyOnUnregister?: boolean`](#destroyonunregister-boolean) | ||
- [`keepDirtyOnReinitialize?: boolean`](#keepdirtyonreinitialize-boolean) | ||
- [`initialValues?: Object`](#initialvalues-object) | ||
- [`mutators?: { [string]: Mutator }`](#mutators--string-mutator-) | ||
- [`onSubmit: (values: Object, form: FormApi, callback: ?(errors: ?Object) => void) => ?Object | Promise<?Object> | void`](#onsubmit-values-object-form-formapi-callback-errors-object--void--object--promiseobject--void) | ||
- [`validate?: (values: Object) => Object | Promise<Object>`](#validate-values-object--object--promiseobject) | ||
- [`validateOnBlur?: boolean`](#validateonblur-boolean) | ||
- [`DebugFunction: (state: FormState, fieldStates: { [string]: FieldState }) => void`](#debugfunction-state-formstate-fieldstates--string-fieldstate---void) | ||
- [`Decorator: (form: FormApi) => Unsubscribe`](#decorator-form-formapi--unsubscribe) | ||
- [`FieldConfig`](#fieldconfig) | ||
- [`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) | ||
- [`validateFields?: string[]`](#validatefields-string) | ||
- [`FieldState`](#fieldstate) | ||
- [`active?: boolean`](#active-boolean) | ||
- [`blur: () => void`](#blur---void) | ||
- [`change: (value: any) => void`](#change-value-any--void) | ||
- [`data?: Object`](#data-object) | ||
- [`dirty?: boolean`](#dirty-boolean) | ||
- [`dirtySinceLastSubmit?: boolean`](#dirtysincelastsubmit-boolean) | ||
- [`error?: any`](#error-any) | ||
- [`focus: () => void`](#focus---void) | ||
- [`initial?: any`](#initial-any) | ||
- [`invalid?: boolean`](#invalid-boolean) | ||
- [`length?: number`](#length-number) | ||
- [`name: string`](#name-string) | ||
- [`pristine?: boolean`](#pristine-boolean) | ||
- [`submitError?: any`](#submiterror-any) | ||
- [`submitFailed?: boolean`](#submitfailed-boolean) | ||
- [`submitSucceeded?: boolean`](#submitsucceeded-boolean) | ||
- [`touched?: boolean`](#touched-boolean) | ||
- [`valid?: boolean`](#valid-boolean) | ||
- [`value?: any`](#value-any) | ||
- [`visited?: boolean`](#visited-boolean) | ||
- [`FieldSubscriber: (state: FieldState) => void`](#fieldsubscriber-state-fieldstate--void) | ||
- [`FieldSubscription: { [string]: boolean }`](#fieldsubscription--string-boolean-) | ||
- [`active?: boolean`](#active-boolean-1) | ||
- [`data?: boolean`](#data-boolean) | ||
- [`dirty?: boolean`](#dirty-boolean-1) | ||
- [`dirtySinceLastSubmit?: boolean`](#dirtysincelastsubmit-boolean-1) | ||
- [`error?: boolean`](#error-boolean) | ||
- [`initial?: boolean`](#initial-boolean) | ||
- [`invalid?: boolean`](#invalid-boolean-1) | ||
- [`length?: boolean`](#length-boolean) | ||
- [`pristine?: boolean`](#pristine-boolean-1) | ||
- [`submitError?: boolean`](#submiterror-boolean) | ||
- [`submitFailed?: boolean`](#submitfailed-boolean-1) | ||
- [`submitSucceeded?: boolean`](#submitsucceeded-boolean-1) | ||
- [`touched?: boolean`](#touched-boolean-1) | ||
- [`valid?: boolean`](#valid-boolean-1) | ||
- [`value?: boolean`](#value-boolean) | ||
- [`visited?: boolean`](#visited-boolean-1) | ||
- [`FormApi`](#formapi) | ||
- [`batch: (fn: () => void) => void)`](#batch-fn---void--void) | ||
- [`blur: (name: string) => void`](#blur-name-string--void) | ||
- [`change: (name: string, value: ?any) => void`](#change-name-string-value-any--void) | ||
- [`focus: (name: string) => void`](#focus-name-string--void) | ||
- [`getFieldState: (field: string) => ?FieldState`](#getfieldstate-field-string--fieldstate) | ||
- [`getRegisteredFields: () => string[]`](#getregisteredfields---string) | ||
- [`getState: () => FormState`](#getstate---formstate) | ||
- [`initialize: (values: Object) => void`](#initialize-values-object--void) | ||
- [`isValidationPaused: () => boolean`](#isvalidationpaused---boolean) | ||
- [`mutators: ?{ [string]: Function }`](#mutators--string-function-) | ||
- [`pauseValidation: () => void`](#pausevalidation---void) | ||
- [`registerField: RegisterField`](#registerfield-registerfield) | ||
- [`reset: (initialValues: ?Object) => void`](#reset-initialvalues-object--void) | ||
- [`resumeValidation: () => void`](#resumevalidation---void) | ||
- [`submit: () => ?Promise<?Object>`](#submit---promiseobject) | ||
- [`subscribe: (subscriber: FormSubscriber, subscription: FormSubscription) => Unsubscribe`](#subscribe-subscriber-formsubscriber-subscription-formsubscription--unsubscribe) | ||
- [`FormState`](#formstate) | ||
- [`active?: string`](#active-string) | ||
- [`dirty?: boolean`](#dirty-boolean-2) | ||
- [`dirtyFields?: { [string]: boolean }`](#dirtyfields--string-boolean-) | ||
- [`dirtySinceLastSubmit?: boolean`](#dirtysincelastsubmit-boolean-2) | ||
- [`error?: any`](#error-any-1) | ||
- [`errors?: Object`](#errors-object) | ||
- [`hasSubmitErrors?: boolean`](#hassubmiterrors-boolean) | ||
- [`hasValidationErrors?: boolean`](#hasvalidationerrors-boolean) | ||
- [`initialValues?: Object`](#initialvalues-object-1) | ||
- [`invalid?: boolean`](#invalid-boolean-2) | ||
- [`pristine?: boolean`](#pristine-boolean-2) | ||
- [`submitError?: any`](#submiterror-any-1) | ||
- [`submitErrors?: Object`](#submiterrors-object) | ||
- [`submitFailed?: boolean`](#submitfailed-boolean-2) | ||
- [`submitSucceeded?: boolean`](#submitsucceeded-boolean-2) | ||
- [`submitting?: boolean`](#submitting-boolean) | ||
- [`touched?: { [string]: boolean }`](#touched--string-boolean-) | ||
- [`valid?: boolean`](#valid-boolean-2) | ||
- [`validating?: boolean`](#validating-boolean) | ||
- [`values?: Object`](#values-object) | ||
- [`visited?: { [string]: boolean }`](#visited--string-boolean-) | ||
- [`FormSubscriber: (state: FormState) => void`](#formsubscriber-state-formstate--void) | ||
- [`FormSubscription: { [string]: boolean }`](#formsubscription--string-boolean-) | ||
- [`active?: boolean`](#active-boolean-2) | ||
- [`dirty?: boolean`](#dirty-boolean-3) | ||
- [`dirtyFields?: boolean`](#dirtyfields-boolean) | ||
- [`dirtySinceLastSubmit?: boolean`](#dirtysincelastsubmit-boolean-3) | ||
- [`error?: boolean`](#error-boolean-1) | ||
- [`errors?: boolean`](#errors-boolean) | ||
- [`hasSubmitErrors?: boolean`](#hassubmiterrors-boolean-1) | ||
- [`hasValidationErrors?: boolean`](#hasvalidationerrors-boolean-1) | ||
- [`initialValues?: boolean`](#initialvalues-boolean) | ||
- [`invalid?: boolean`](#invalid-boolean-3) | ||
- [`pristine?: boolean`](#pristine-boolean-3) | ||
- [`setConfig: (name: string, value: any) => void`](#setconfig-name-string-value-any--void) | ||
- [`submitError?: boolean`](#submiterror-boolean-1) | ||
- [`submitErrors?: boolean`](#submiterrors-boolean) | ||
- [`submitFailed?: boolean`](#submitfailed-boolean-3) | ||
- [`submitSucceeded?: boolean`](#submitsucceeded-boolean-3) | ||
- [`submitting?: boolean`](#submitting-boolean-1) | ||
- [`touched?: boolean`](#touched-boolean-2) | ||
- [`valid?: boolean`](#valid-boolean-3) | ||
- [`validating?: boolean`](#validating-boolean-1) | ||
- [`values?: boolean`](#values-boolean) | ||
- [`visited?: boolean`](#visited-boolean-2) | ||
- [`InternalFieldState`](#internalfieldstate) | ||
- [`active: boolean`](#active-boolean) | ||
- [`blur: () => void`](#blur---void-1) | ||
- [`change: (value: any) => void`](#change-value-any--void-1) | ||
- [`data: Object`](#data-object) | ||
- [`focus: () => void`](#focus---void-1) | ||
- [`isEqual: (a: any, b: any) => boolean`](#isequal-a-any-b-any--boolean) | ||
- [`name: string`](#name-string-1) | ||
- [`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) | ||
- [`visited: boolean`](#visited-boolean) | ||
- [`InternalFormState`](#internalformstate) | ||
- [`active?: string`](#active-string-1) | ||
- [`dirtySinceLastSubmit: boolean`](#dirtysincelastsubmit-boolean) | ||
- [`error?: any`](#error-any-2) | ||
- [`errors: Object`](#errors-object) | ||
- [`initialValues?: Object`](#initialvalues-object-2) | ||
- [`lastSubmittedValues?: Object`](#lastsubmittedvalues-object) | ||
- [`pristine: boolean`](#pristine-boolean) | ||
- [`submitError: any`](#submiterror-any) | ||
- [`submitErrors?: Object`](#submiterrors-object-1) | ||
- [`submitFailed: boolean`](#submitfailed-boolean) | ||
- [`submitSucceeded: boolean`](#submitsucceeded-boolean) | ||
- [`submitting: boolean`](#submitting-boolean) | ||
- [`valid: boolean`](#valid-boolean-1) | ||
- [`validating: number`](#validating-number) | ||
- [`values: Object`](#values-object) | ||
- [`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, config?: FieldConfig) => Unsubscribe`](#registerfield-name-string-subscriber-fieldsubscriber-subscription-fieldsubscription-config-fieldconfig--unsubscribe) | ||
- [`Tools`](#tools) | ||
- [`Tools.changeValue: (state: MutableState, name: string, mutate: (value: any) => any) => void`](#toolschangevalue-state-mutablestate-name-string-mutate-value-any--any--void) | ||
- [`Tools.getIn: (state: Object, complexKey: string) => any`](#toolsgetin-state-object-complexkey-string--any) | ||
- [`Tools.setIn: (state: Object, key: string, value: any) => Object`](#toolssetin-state-object-key-string-value-any--object) | ||
- [`Tools.shallowEqual: (a: any, b: any) => boolean`](#toolsshallowequal-a-any-b-any--boolean) | ||
- [`Unsubscribe : () => void`](#unsubscribe----void) | ||
- [Contributors](#contributors) | ||
- [Backers](#backers) | ||
- [Sponsors](#sponsors) | ||
@@ -343,6 +346,6 @@ <!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
* `.` and `[` are treated the same. | ||
* `]` is ignored. | ||
* `Number` keys will result in array structures. [Why?](https://github.com/final-form/final-form/blob/master/docs/faq.md#why-do-my-numeric-keys-result-in-an-array-structure) | ||
* Setting `undefined` to a field value deletes any empty object β but not array! β structures. [Why?](https://github.com/final-form/final-form/blob/master/docs/faq.md#why-does--final-form-set-my--field-value-to-undefined) | ||
- `.` and `[` are treated the same. | ||
- `]` is ignored. | ||
- `Number` keys will result in array structures. [Why?](https://github.com/final-form/final-form/blob/master/docs/faq.md#why-do-my-numeric-keys-result-in-an-array-structure) | ||
- Setting `undefined` to a field value deletes any empty object β but not array! β structures. [Why?](https://github.com/final-form/final-form/blob/master/docs/faq.md#why-does--final-form-set-my--field-value-to-undefined) | ||
@@ -431,7 +434,7 @@ It is very similar to Lodash's [`_.set()`](https://lodash.com/docs/#set), except that empty structures are removed. Let's look at some examples: | ||
* Synchronously: returns `undefined` on success, or an `Object` of submission | ||
- Synchronously: returns `undefined` on success, or an `Object` of submission | ||
errors on failure | ||
* Asynchronously with a callback: returns `undefined`, calls `callback()` with | ||
- Asynchronously with a callback: returns `undefined`, calls `callback()` with | ||
no arguments on success, or with an `Object` of submission errors on failure. | ||
* Asynchronously with a `Promise`: returns a `Promise<?Object>` that resolves | ||
- Asynchronously with a `Promise`: returns a `Promise<?Object>` that resolves | ||
with no value on success or _resolves_ with an `Object` of submission errors | ||
@@ -451,5 +454,5 @@ on failure. The reason it _resolves_ with errors is to leave _rejection_ for | ||
* Synchronously: returns `{}` or `undefined` when the values are valid, or an | ||
- Synchronously: returns `{}` or `undefined` when the values are valid, or an | ||
`Object` of validation errors when the values are invalid. | ||
* Asynchronously with a `Promise`: returns a `Promise<?Object>` that resolves | ||
- Asynchronously with a `Promise`: returns a `Promise<?Object>` that resolves | ||
with no value on success or _resolves_ with an `Object` of validation errors | ||
@@ -771,2 +774,11 @@ on failure. The reason it _resolves_ with errors is to leave _rejection_ for | ||
#### `dirtyFields?: { [string]: boolean }` | ||
An object full of booleans, with a value of `true` for each `dirty` field. _Pristine fields will not appear in this object_. Note that this is a flat object, so if your field name is `addresses.shipping.street`, the `dirty` value for that field will be available under `dirty['addresses.shipping.street']`. | ||
#### `dirtySinceLastSubmit?: boolean` | ||
`true` if the form values are different from the values it was last submitted with. | ||
`false` otherwise. Comparison is done with shallow-equals. | ||
#### `error?: any` | ||
@@ -830,3 +842,3 @@ | ||
#### `touched: { [string]: boolean }` | ||
#### `touched?: { [string]: boolean }` | ||
@@ -850,3 +862,3 @@ An object full of booleans, with a boolean value for each field name denoting whether that field is `touched` or not. Note that this is a flat object, so if your field name is `addresses.shipping.street`, the `touched` value for that field will be available under `touched['addresses.shipping.street']`. | ||
#### `visited: { [string]: boolean }` | ||
#### `visited?: { [string]: boolean }` | ||
@@ -869,4 +881,9 @@ An object full of booleans, with a boolean value for each field name denoting whether that field is `visited` or not. Note that this is a flat object, so if your field name is `addresses.shipping.street`, the `visited` value for that field will be available under `visited['addresses.shipping.street']`. | ||
When `true` the `FormSubscriber` will be notified of changes to the `dirty` | ||
value in `FormState`. This value is the opposite to the `pristine` valueΒ (`dirty = !pristine`). | ||
value in `FormState`. | ||
#### `dirtyFields?: boolean` | ||
When `true` the `FormSubscriber` will be notified of changes to the `dirtyFields` | ||
value in `FormState`. | ||
#### `dirtySinceLastSubmit?: boolean` | ||
@@ -873,0 +890,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
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
187276
1182
44
3265