react-hook-form 7.56.3 → 7.56.4

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 +1 @@
1
- {"version":3,"file":"createFormControl.d.ts","sourceRoot":"","sources":["../../src/logic/createFormControl.ts"],"names":[],"mappings":"AACA,OAAO,EAaL,WAAW,EAgBX,YAAY,EAIZ,aAAa,EAUd,MAAM,UAAU,CAAC;AAoDlB,wBAAgB,iBAAiB,CAC/B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,QAAQ,GAAG,GAAG,EACd,kBAAkB,GAAG,YAAY,EAEjC,KAAK,GAAE,YAAY,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAM,GACnE,IAAI,CACL,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAC,EACzD,WAAW,CACZ,GAAG;IACF,WAAW,EAAE,IAAI,CACf,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAC,EACzD,WAAW,CACZ,CAAC;CACH,CAy5CA"}
1
+ {"version":3,"file":"createFormControl.d.ts","sourceRoot":"","sources":["../../src/logic/createFormControl.ts"],"names":[],"mappings":"AACA,OAAO,EAaL,WAAW,EAgBX,YAAY,EAIZ,aAAa,EAUd,MAAM,UAAU,CAAC;AAoDlB,wBAAgB,iBAAiB,CAC/B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,QAAQ,GAAG,GAAG,EACd,kBAAkB,GAAG,YAAY,EAEjC,KAAK,GAAE,YAAY,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAM,GACnE,IAAI,CACL,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAC,EACzD,WAAW,CACZ,GAAG;IACF,WAAW,EAAE,IAAI,CACf,aAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAC,EACzD,WAAW,CACZ,CAAC;CACH,CA+5CA"}
@@ -811,8 +811,6 @@ function createFormControl(props = {}) {
811
811
  array: createSubject(),
812
812
  state: createSubject(),
813
813
  };
814
- const validationModeBeforeSubmit = getValidationModes(_options.mode);
815
- const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
816
814
  const shouldDisplayAllAssociatedErrors = _options.criteriaMode === VALIDATION_MODE.all;
817
815
  const debounce = (callback) => (wait) => {
818
816
  clearTimeout(timer);
@@ -1083,13 +1081,17 @@ function createFormControl(props = {}) {
1083
1081
  }
1084
1082
  else if (fieldReference.refs) {
1085
1083
  if (isCheckBoxInput(fieldReference.ref)) {
1086
- fieldReference.refs.length > 1
1087
- ? fieldReference.refs.forEach((checkboxRef) => (!checkboxRef.defaultChecked || !checkboxRef.disabled) &&
1088
- (checkboxRef.checked = Array.isArray(fieldValue)
1089
- ? !!fieldValue.find((data) => data === checkboxRef.value)
1090
- : fieldValue === checkboxRef.value))
1091
- : fieldReference.refs[0] &&
1092
- (fieldReference.refs[0].checked = !!fieldValue);
1084
+ fieldReference.refs.forEach((checkboxRef) => {
1085
+ if (!checkboxRef.defaultChecked || !checkboxRef.disabled) {
1086
+ if (Array.isArray(fieldValue)) {
1087
+ checkboxRef.checked = !!fieldValue.find((data) => data === checkboxRef.value);
1088
+ }
1089
+ else {
1090
+ checkboxRef.checked =
1091
+ fieldValue === checkboxRef.value || !!fieldValue;
1092
+ }
1093
+ }
1094
+ });
1093
1095
  }
1094
1096
  else {
1095
1097
  fieldReference.refs.forEach((radioRef) => (radioRef.checked = radioRef.value === fieldValue));
@@ -1115,6 +1117,9 @@ function createFormControl(props = {}) {
1115
1117
  };
1116
1118
  const setValues = (name, value, options) => {
1117
1119
  for (const fieldKey in value) {
1120
+ if (!value.hasOwnProperty(fieldKey)) {
1121
+ return;
1122
+ }
1118
1123
  const fieldValue = value[fieldKey];
1119
1124
  const fieldName = `${name}.${fieldKey}`;
1120
1125
  const field = get(_fields, fieldName);
@@ -1171,6 +1176,8 @@ function createFormControl(props = {}) {
1171
1176
  (isDateObject(fieldValue) && isNaN(fieldValue.getTime())) ||
1172
1177
  deepEqual(fieldValue, get(_formValues, name, fieldValue));
1173
1178
  };
1179
+ const validationModeBeforeSubmit = getValidationModes(_options.mode);
1180
+ const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
1174
1181
  if (field) {
1175
1182
  let error;
1176
1183
  let isValid;