react-hook-form 7.34.0-next.0 → 7.34.0
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/README.md +334 -336
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.mjs +10 -9
- package/dist/index.esm.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/logic/createFormControl.d.ts.map +1 -1
- package/dist/types/errors.d.ts +2 -2
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/fieldArray.d.ts +4 -4
- package/dist/types/fieldArray.d.ts.map +1 -1
- package/dist/types/fields.d.ts +1 -1
- package/dist/types/fields.d.ts.map +1 -1
- package/dist/useForm.d.ts +1 -1
- package/dist/useForm.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.esm.mjs
CHANGED
@@ -659,7 +659,7 @@ var validateField = async (field, inputValue, validateAllFieldCriteria, shouldUs
|
|
659
659
|
};
|
660
660
|
};
|
661
661
|
if (isFieldArray
|
662
|
-
? Array.isArray(inputValue)
|
662
|
+
? !Array.isArray(inputValue) || !inputValue.length
|
663
663
|
: required &&
|
664
664
|
((!isRadioOrCheckbox && (isEmpty || isNullOrUndefined(inputValue))) ||
|
665
665
|
(isBoolean(inputValue) && !inputValue) ||
|
@@ -1431,7 +1431,7 @@ function createFormControl(props = {}) {
|
|
1431
1431
|
if (_proxyFormState.isValid) {
|
1432
1432
|
isValid = _options.resolver
|
1433
1433
|
? isEmptyObject((await _executeSchema()).errors)
|
1434
|
-
: await
|
1434
|
+
: await executeBuiltInValidation(_fields, true);
|
1435
1435
|
if (!shouldSkipRender && isValid !== _formState.isValid) {
|
1436
1436
|
_formState.isValid = isValid;
|
1437
1437
|
_subjects.state.next({
|
@@ -1582,7 +1582,7 @@ function createFormControl(props = {}) {
|
|
1582
1582
|
}
|
1583
1583
|
return errors;
|
1584
1584
|
};
|
1585
|
-
const
|
1585
|
+
const executeBuiltInValidation = async (fields, shouldOnlyCheckValid, context = {
|
1586
1586
|
valid: true,
|
1587
1587
|
}) => {
|
1588
1588
|
for (const name in fields) {
|
@@ -1606,7 +1606,7 @@ function createFormControl(props = {}) {
|
|
1606
1606
|
: unset(_formState.errors, _f.name));
|
1607
1607
|
}
|
1608
1608
|
fieldValue &&
|
1609
|
-
(await
|
1609
|
+
(await executeBuiltInValidation(fieldValue, shouldOnlyCheckValid, context));
|
1610
1610
|
}
|
1611
1611
|
}
|
1612
1612
|
return context.valid;
|
@@ -1801,12 +1801,12 @@ function createFormControl(props = {}) {
|
|
1801
1801
|
else if (name) {
|
1802
1802
|
validationResult = (await Promise.all(fieldNames.map(async (fieldName) => {
|
1803
1803
|
const field = get(_fields, fieldName);
|
1804
|
-
return await
|
1804
|
+
return await executeBuiltInValidation(field && field._f ? { [fieldName]: field } : field);
|
1805
1805
|
}))).every(Boolean);
|
1806
1806
|
!(!validationResult && !_formState.isValid) && _updateValid();
|
1807
1807
|
}
|
1808
1808
|
else {
|
1809
|
-
validationResult = isValid = await
|
1809
|
+
validationResult = isValid = await executeBuiltInValidation(_fields);
|
1810
1810
|
}
|
1811
1811
|
_subjects.state.next({
|
1812
1812
|
...(!isString(name) ||
|
@@ -1986,7 +1986,7 @@ function createFormControl(props = {}) {
|
|
1986
1986
|
fieldValues = values;
|
1987
1987
|
}
|
1988
1988
|
else {
|
1989
|
-
await
|
1989
|
+
await executeBuiltInValidation(_fields);
|
1990
1990
|
}
|
1991
1991
|
if (isEmptyObject(_formState.errors)) {
|
1992
1992
|
_subjects.state.next({
|
@@ -2069,9 +2069,10 @@ function createFormControl(props = {}) {
|
|
2069
2069
|
? field._f.refs[0]
|
2070
2070
|
: field._f.ref;
|
2071
2071
|
try {
|
2072
|
-
isHTMLElement(fieldReference)
|
2072
|
+
if (isHTMLElement(fieldReference)) {
|
2073
2073
|
fieldReference.closest('form').reset();
|
2074
|
-
|
2074
|
+
break;
|
2075
|
+
}
|
2075
2076
|
}
|
2076
2077
|
catch (_a) { }
|
2077
2078
|
}
|