react-hook-form 7.58.1 → 7.59.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.
@@ -677,7 +677,7 @@ var createSubject = () => {
677
677
 
678
678
  var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);
679
679
 
680
- function deepEqual(object1, object2) {
680
+ function deepEqual(object1, object2, _internal_visited = new WeakSet()) {
681
681
  if (isPrimitive(object1) || isPrimitive(object2)) {
682
682
  return object1 === object2;
683
683
  }
@@ -689,6 +689,11 @@ function deepEqual(object1, object2) {
689
689
  if (keys1.length !== keys2.length) {
690
690
  return false;
691
691
  }
692
+ if (_internal_visited.has(object1) || _internal_visited.has(object2)) {
693
+ return true;
694
+ }
695
+ _internal_visited.add(object1);
696
+ _internal_visited.add(object2);
692
697
  for (const key of keys1) {
693
698
  const val1 = object1[key];
694
699
  if (!keys2.includes(key)) {
@@ -699,7 +704,7 @@ function deepEqual(object1, object2) {
699
704
  if ((isDateObject(val1) && isDateObject(val2)) ||
700
705
  (isObject(val1) && isObject(val2)) ||
701
706
  (Array.isArray(val1) && Array.isArray(val2))
702
- ? !deepEqual(val1, val2)
707
+ ? !deepEqual(val1, val2, _internal_visited)
703
708
  : val1 !== val2) {
704
709
  return false;
705
710
  }
@@ -2018,14 +2023,14 @@ function createFormControl(props = {}) {
2018
2023
  if (_options.resolver) {
2019
2024
  const { errors, values } = await _runSchema();
2020
2025
  _formState.errors = errors;
2021
- fieldValues = values;
2026
+ fieldValues = cloneObject(values);
2022
2027
  }
2023
2028
  else {
2024
2029
  await executeBuiltInValidation(_fields);
2025
2030
  }
2026
2031
  if (_names.disabled.size) {
2027
2032
  for (const name of _names.disabled) {
2028
- set(fieldValues, name, undefined);
2033
+ unset(fieldValues, name);
2029
2034
  }
2030
2035
  }
2031
2036
  unset(_formState.errors, 'root');
@@ -2122,7 +2127,11 @@ function createFormControl(props = {}) {
2122
2127
  }
2123
2128
  }
2124
2129
  for (const fieldName of _names.mount) {
2125
- setValue(fieldName, get(values, fieldName));
2130
+ const value = get(values, fieldName, get(_defaultValues, fieldName));
2131
+ if (!isUndefined(value)) {
2132
+ set(values, fieldName, value);
2133
+ setValue(fieldName, get(values, fieldName));
2134
+ }
2126
2135
  }
2127
2136
  }
2128
2137
  _formValues = cloneObject(values);