react-hook-form 7.51.0 → 7.51.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.mjs
CHANGED
@@ -1354,8 +1354,6 @@ var isRadioOrCheckbox = (ref) => isRadioInput(ref) || isCheckBoxInput(ref);
|
|
1354
1354
|
|
1355
1355
|
var live = (ref) => isHTMLElement(ref) && ref.isConnected;
|
1356
1356
|
|
1357
|
-
var objectHasTruthyValue = (value) => isObject(value) && Object.values(value).some((val) => val);
|
1358
|
-
|
1359
1357
|
var objectHasFunction = (data) => {
|
1360
1358
|
for (const key in data) {
|
1361
1359
|
if (isFunction(data[key])) {
|
@@ -1598,18 +1596,15 @@ function createFormControl(props = {}) {
|
|
1598
1596
|
}
|
1599
1597
|
}
|
1600
1598
|
};
|
1601
|
-
const _updateIsValidating = (
|
1602
|
-
if (
|
1603
|
-
|
1599
|
+
const _updateIsValidating = (names, isValidating) => {
|
1600
|
+
if (_proxyFormState.isValidating || _proxyFormState.validatingFields) {
|
1601
|
+
(names || Array.from(_names.mount)).forEach((name) => name && set(_formState.validatingFields, name, !!isValidating));
|
1602
|
+
_formState.isValidating = Object.values(_formState.validatingFields).some((val) => val);
|
1603
|
+
_subjects.state.next({
|
1604
|
+
validatingFields: _formState.validatingFields,
|
1605
|
+
isValidating: _formState.isValidating,
|
1606
|
+
});
|
1604
1607
|
}
|
1605
|
-
names.forEach((name) => {
|
1606
|
-
set(_formState.validatingFields, name, isValidating);
|
1607
|
-
});
|
1608
|
-
_formState.isValidating = objectHasTruthyValue(_formState.validatingFields);
|
1609
|
-
_subjects.state.next({
|
1610
|
-
validatingFields: _formState.validatingFields,
|
1611
|
-
isValidating: _formState.isValidating,
|
1612
|
-
});
|
1613
1608
|
};
|
1614
1609
|
const _updateFieldArray = (name, values = [], method, args, shouldSetValues = true, shouldUpdateFieldsAndState = true) => {
|
1615
1610
|
if (args && method) {
|
@@ -1739,9 +1734,13 @@ function createFormControl(props = {}) {
|
|
1739
1734
|
};
|
1740
1735
|
_subjects.state.next(updatedFormState);
|
1741
1736
|
}
|
1742
|
-
_updateIsValidating(false, Object.keys(_formState.validatingFields).filter((key) => key === name));
|
1743
1737
|
};
|
1744
|
-
const _executeSchema = async (name) =>
|
1738
|
+
const _executeSchema = async (name) => {
|
1739
|
+
_updateIsValidating(name, true);
|
1740
|
+
const result = await _options.resolver(_formValues, _options.context, getResolverOptions(name || _names.mount, _fields, _options.criteriaMode, _options.shouldUseNativeValidation));
|
1741
|
+
_updateIsValidating(name);
|
1742
|
+
return result;
|
1743
|
+
};
|
1745
1744
|
const executeSchemaAndUpdateState = async (names) => {
|
1746
1745
|
const { errors } = await _executeSchema(names);
|
1747
1746
|
if (names) {
|
@@ -1766,7 +1765,9 @@ function createFormControl(props = {}) {
|
|
1766
1765
|
const { _f, ...fieldValue } = field;
|
1767
1766
|
if (_f) {
|
1768
1767
|
const isFieldArrayRoot = _names.array.has(_f.name);
|
1768
|
+
_updateIsValidating([name], true);
|
1769
1769
|
const fieldError = await validateField(field, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation && !shouldOnlyCheckValid, isFieldArrayRoot);
|
1770
|
+
_updateIsValidating([name]);
|
1770
1771
|
if (fieldError[_f.name]) {
|
1771
1772
|
context.valid = false;
|
1772
1773
|
if (shouldOnlyCheckValid) {
|
@@ -1943,7 +1944,6 @@ function createFormControl(props = {}) {
|
|
1943
1944
|
_subjects.state.next({ name, ...(watched ? {} : fieldState) }));
|
1944
1945
|
}
|
1945
1946
|
!isBlurEvent && watched && _subjects.state.next({ ..._formState });
|
1946
|
-
_updateIsValidating(true, [name]);
|
1947
1947
|
if (_options.resolver) {
|
1948
1948
|
const { errors } = await _executeSchema([name]);
|
1949
1949
|
_updateIsFieldValueUpdated(fieldValue);
|
@@ -1956,7 +1956,9 @@ function createFormControl(props = {}) {
|
|
1956
1956
|
}
|
1957
1957
|
}
|
1958
1958
|
else {
|
1959
|
+
_updateIsValidating([name], true);
|
1959
1960
|
error = (await validateField(field, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation))[name];
|
1961
|
+
_updateIsValidating([name]);
|
1960
1962
|
_updateIsFieldValueUpdated(fieldValue);
|
1961
1963
|
if (isFieldValueUpdated) {
|
1962
1964
|
if (error) {
|
@@ -1985,7 +1987,6 @@ function createFormControl(props = {}) {
|
|
1985
1987
|
let isValid;
|
1986
1988
|
let validationResult;
|
1987
1989
|
const fieldNames = convertToArrayPayload(name);
|
1988
|
-
_updateIsValidating(true, fieldNames);
|
1989
1990
|
if (_options.resolver) {
|
1990
1991
|
const errors = await executeSchemaAndUpdateState(isUndefined(name) ? name : fieldNames);
|
1991
1992
|
isValid = isEmptyObject(errors);
|
@@ -2010,7 +2011,6 @@ function createFormControl(props = {}) {
|
|
2010
2011
|
: { name }),
|
2011
2012
|
...(_options.resolver || !name ? { isValid } : {}),
|
2012
2013
|
errors: _formState.errors,
|
2013
|
-
isValidating: false,
|
2014
2014
|
});
|
2015
2015
|
options.shouldFocus &&
|
2016
2016
|
!validationResult &&
|