react-hook-form 7.21.1 → 7.22.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.
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
 
3
3
  var isCheckBoxInput = (element) => element.type === 'checkbox';
4
4
 
@@ -1314,7 +1314,7 @@ function createFormControl(props = {}) {
1314
1314
  : defaultValue));
1315
1315
  return generateWatchOutput(names, _names, fieldValues, isGlobal);
1316
1316
  };
1317
- const _getFieldArray = (name) => get(_stateFlags.mount ? _formValues : _defaultValues, name, props.shouldUnregister ? get(_defaultValues, name, []) : []);
1317
+ const _getFieldArray = (name) => compact(get(_stateFlags.mount ? _formValues : _defaultValues, name, props.shouldUnregister ? get(_defaultValues, name, []) : []));
1318
1318
  const setFieldValue = (name, value, options = {}) => {
1319
1319
  const field = get(_fields, name);
1320
1320
  let fieldValue = value;
@@ -1673,14 +1673,14 @@ function createFormControl(props = {}) {
1673
1673
  const reset = (formValues, keepStateOptions = {}) => {
1674
1674
  const updatedValues = formValues || _defaultValues;
1675
1675
  const cloneUpdatedValues = cloneObject(updatedValues);
1676
- const values = !isEmptyObject(formValues)
1676
+ const values = formValues && !isEmptyObject(formValues)
1677
1677
  ? cloneUpdatedValues
1678
1678
  : _defaultValues;
1679
1679
  if (!keepStateOptions.keepDefaultValues) {
1680
1680
  _defaultValues = updatedValues;
1681
1681
  }
1682
1682
  if (!keepStateOptions.keepValues) {
1683
- if (isWeb) {
1683
+ if (isWeb && isUndefined(formValues)) {
1684
1684
  for (const name of _names.mount) {
1685
1685
  const field = get(_fields, name);
1686
1686
  if (field && field._f) {
@@ -1717,6 +1717,9 @@ function createFormControl(props = {}) {
1717
1717
  watchAll: false,
1718
1718
  focus: '',
1719
1719
  };
1720
+ _stateFlags.mount =
1721
+ !_proxyFormState.isValid || !!keepStateOptions.keepIsValid;
1722
+ _stateFlags.watch = !!props.shouldUnregister;
1720
1723
  _subjects.state.next({
1721
1724
  submitCount: keepStateOptions.keepSubmitCount
1722
1725
  ? _formState.submitCount
@@ -1743,9 +1746,6 @@ function createFormControl(props = {}) {
1743
1746
  isSubmitting: false,
1744
1747
  isSubmitSuccessful: false,
1745
1748
  });
1746
- _stateFlags.mount =
1747
- !_proxyFormState.isValid || !!keepStateOptions.keepIsValid;
1748
- _stateFlags.watch = !!props.shouldUnregister;
1749
1749
  };
1750
1750
  const setFocus = (name) => {
1751
1751
  const field = get(_fields, name)._f;