react-hook-form 7.38.0 → 7.39.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/README.md +9 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.mjs +21 -14
- 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/logic/getDirtyFields.d.ts.map +1 -1
- package/dist/utils/sleep.d.ts +2 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.esm.mjs
CHANGED
@@ -632,8 +632,8 @@ var validateField = async (field, inputValue, validateAllFieldCriteria, shouldUs
|
|
632
632
|
}
|
633
633
|
const inputRef = refs ? refs[0] : ref;
|
634
634
|
const setCustomValidity = (message) => {
|
635
|
-
if (shouldUseNativeValidation &&
|
636
|
-
inputRef.setCustomValidity(
|
635
|
+
if (shouldUseNativeValidation && isString(message)) {
|
636
|
+
inputRef.setCustomValidity(message);
|
637
637
|
inputRef.reportValidity();
|
638
638
|
}
|
639
639
|
};
|
@@ -1259,7 +1259,9 @@ function getDirtyFieldsFromDefaultValues(data, formValues, dirtyFieldsFromValues
|
|
1259
1259
|
}
|
1260
1260
|
}
|
1261
1261
|
else {
|
1262
|
-
|
1262
|
+
deepEqual(data[key], formValues[key])
|
1263
|
+
? delete dirtyFieldsFromValues[key]
|
1264
|
+
: (dirtyFieldsFromValues[key] = true);
|
1263
1265
|
}
|
1264
1266
|
}
|
1265
1267
|
}
|
@@ -1442,13 +1444,13 @@ function createFormControl(props = {}) {
|
|
1442
1444
|
clearTimeout(timer);
|
1443
1445
|
timer = window.setTimeout(callback, wait);
|
1444
1446
|
};
|
1445
|
-
const _updateValid = async (
|
1447
|
+
const _updateValid = async () => {
|
1446
1448
|
let isValid = false;
|
1447
1449
|
if (_proxyFormState.isValid) {
|
1448
1450
|
isValid = _options.resolver
|
1449
1451
|
? isEmptyObject((await _executeSchema()).errors)
|
1450
1452
|
: await executeBuiltInValidation(_fields, true);
|
1451
|
-
if (
|
1453
|
+
if (isValid !== _formState.isValid) {
|
1452
1454
|
_formState.isValid = isValid;
|
1453
1455
|
_subjects.state.next({
|
1454
1456
|
isValid,
|
@@ -1542,9 +1544,11 @@ function createFormControl(props = {}) {
|
|
1542
1544
|
isFieldDirty && shouldRender && _subjects.state.next(output);
|
1543
1545
|
return isFieldDirty ? output : {};
|
1544
1546
|
};
|
1545
|
-
const shouldRenderByError =
|
1547
|
+
const shouldRenderByError = (name, isValid, error, fieldState) => {
|
1546
1548
|
const previousFieldError = get(_formState.errors, name);
|
1547
|
-
const shouldUpdateValid = _proxyFormState.isValid &&
|
1549
|
+
const shouldUpdateValid = _proxyFormState.isValid &&
|
1550
|
+
isBoolean(isValid) &&
|
1551
|
+
_formState.isValid !== isValid;
|
1548
1552
|
if (props.delayError && error) {
|
1549
1553
|
delayErrorCallback = debounce(() => updateErrors(name, error));
|
1550
1554
|
delayErrorCallback(props.delayError);
|
@@ -1561,7 +1565,7 @@ function createFormControl(props = {}) {
|
|
1561
1565
|
shouldUpdateValid) {
|
1562
1566
|
const updatedFormState = {
|
1563
1567
|
...fieldState,
|
1564
|
-
...(shouldUpdateValid ? { isValid } : {}),
|
1568
|
+
...(shouldUpdateValid && isBoolean(isValid) ? { isValid } : {}),
|
1565
1569
|
errors: _formState.errors,
|
1566
1570
|
name,
|
1567
1571
|
};
|
@@ -1775,11 +1779,14 @@ function createFormControl(props = {}) {
|
|
1775
1779
|
type: event.type,
|
1776
1780
|
});
|
1777
1781
|
if (shouldSkipValidation) {
|
1782
|
+
_proxyFormState.isValid && _updateValid();
|
1778
1783
|
return (shouldRender &&
|
1779
1784
|
_subjects.state.next({ name, ...(watched ? {} : fieldState) }));
|
1780
1785
|
}
|
1781
1786
|
!isBlurEvent && watched && _subjects.state.next({});
|
1782
|
-
validateFields[name] = validateFields[name]
|
1787
|
+
validateFields[name] = validateFields[name]
|
1788
|
+
? validateFields[name] + 1
|
1789
|
+
: 1;
|
1783
1790
|
_subjects.state.next({
|
1784
1791
|
isValidating: true,
|
1785
1792
|
});
|
@@ -1793,7 +1800,7 @@ function createFormControl(props = {}) {
|
|
1793
1800
|
}
|
1794
1801
|
else {
|
1795
1802
|
error = (await validateField(field, get(_formValues, name), shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation))[name];
|
1796
|
-
|
1803
|
+
_updateValid();
|
1797
1804
|
}
|
1798
1805
|
field._f.deps &&
|
1799
1806
|
trigger(field._f.deps);
|
@@ -2086,13 +2093,13 @@ function createFormControl(props = {}) {
|
|
2086
2093
|
const fieldReference = Array.isArray(field._f.refs)
|
2087
2094
|
? field._f.refs[0]
|
2088
2095
|
: field._f.ref;
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2096
|
+
if (isHTMLElement(fieldReference)) {
|
2097
|
+
const form = fieldReference.closest('form');
|
2098
|
+
if (form) {
|
2099
|
+
form.reset();
|
2092
2100
|
break;
|
2093
2101
|
}
|
2094
2102
|
}
|
2095
|
-
catch (_a) { }
|
2096
2103
|
}
|
2097
2104
|
}
|
2098
2105
|
}
|