react-hook-form 7.21.3-beta.0 → 7.22.3
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/CHANGELOG.md +29 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.mjs +12 -15
- package/dist/index.esm.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +15 -15
package/dist/index.esm.mjs
CHANGED
@@ -235,14 +235,11 @@ function useController(props) {
|
|
235
235
|
updateMounted(name, true);
|
236
236
|
return () => {
|
237
237
|
const _shouldUnregisterField = control._options.shouldUnregister || shouldUnregister;
|
238
|
-
|
238
|
+
isArrayField
|
239
239
|
? _shouldUnregisterField && !control._stateFlags.action
|
240
|
-
: _shouldUnregisterField
|
241
|
-
|
242
|
-
|
243
|
-
else {
|
244
|
-
updateMounted(name, false);
|
245
|
-
}
|
240
|
+
: _shouldUnregisterField
|
241
|
+
? control.unregister(name)
|
242
|
+
: updateMounted(name, false);
|
246
243
|
};
|
247
244
|
}, [name, control, isArrayField, shouldUnregister]);
|
248
245
|
return {
|
@@ -1314,7 +1311,7 @@ function createFormControl(props = {}) {
|
|
1314
1311
|
: defaultValue));
|
1315
1312
|
return generateWatchOutput(names, _names, fieldValues, isGlobal);
|
1316
1313
|
};
|
1317
|
-
const _getFieldArray = (name) => get(_stateFlags.mount ? _formValues : _defaultValues, name, props.shouldUnregister ? get(_defaultValues, name, []) : []);
|
1314
|
+
const _getFieldArray = (name) => compact(get(_stateFlags.mount ? _formValues : _defaultValues, name, props.shouldUnregister ? get(_defaultValues, name, []) : []));
|
1318
1315
|
const setFieldValue = (name, value, options = {}) => {
|
1319
1316
|
const field = get(_fields, name);
|
1320
1317
|
let fieldValue = value;
|
@@ -1673,14 +1670,14 @@ function createFormControl(props = {}) {
|
|
1673
1670
|
const reset = (formValues, keepStateOptions = {}) => {
|
1674
1671
|
const updatedValues = formValues || _defaultValues;
|
1675
1672
|
const cloneUpdatedValues = cloneObject(updatedValues);
|
1676
|
-
const values = !isEmptyObject(formValues)
|
1673
|
+
const values = formValues && !isEmptyObject(formValues)
|
1677
1674
|
? cloneUpdatedValues
|
1678
1675
|
: _defaultValues;
|
1679
1676
|
if (!keepStateOptions.keepDefaultValues) {
|
1680
1677
|
_defaultValues = updatedValues;
|
1681
1678
|
}
|
1682
1679
|
if (!keepStateOptions.keepValues) {
|
1683
|
-
if (isWeb) {
|
1680
|
+
if (isWeb && isUndefined(formValues)) {
|
1684
1681
|
for (const name of _names.mount) {
|
1685
1682
|
const field = get(_fields, name);
|
1686
1683
|
if (field && field._f) {
|
@@ -1702,10 +1699,10 @@ function createFormControl(props = {}) {
|
|
1702
1699
|
: {}
|
1703
1700
|
: cloneUpdatedValues;
|
1704
1701
|
_fields = {};
|
1705
|
-
_subjects.
|
1702
|
+
_subjects.array.next({
|
1706
1703
|
values,
|
1707
1704
|
});
|
1708
|
-
_subjects.
|
1705
|
+
_subjects.watch.next({
|
1709
1706
|
values,
|
1710
1707
|
});
|
1711
1708
|
}
|
@@ -1717,6 +1714,9 @@ function createFormControl(props = {}) {
|
|
1717
1714
|
watchAll: false,
|
1718
1715
|
focus: '',
|
1719
1716
|
};
|
1717
|
+
_stateFlags.mount =
|
1718
|
+
!_proxyFormState.isValid || !!keepStateOptions.keepIsValid;
|
1719
|
+
_stateFlags.watch = !!props.shouldUnregister;
|
1720
1720
|
_subjects.state.next({
|
1721
1721
|
submitCount: keepStateOptions.keepSubmitCount
|
1722
1722
|
? _formState.submitCount
|
@@ -1743,9 +1743,6 @@ function createFormControl(props = {}) {
|
|
1743
1743
|
isSubmitting: false,
|
1744
1744
|
isSubmitSuccessful: false,
|
1745
1745
|
});
|
1746
|
-
_stateFlags.mount =
|
1747
|
-
!_proxyFormState.isValid || !!keepStateOptions.keepIsValid;
|
1748
|
-
_stateFlags.watch = !!props.shouldUnregister;
|
1749
1746
|
};
|
1750
1747
|
const setFocus = (name) => {
|
1751
1748
|
const field = get(_fields, name)._f;
|