@bombillazo/rhf-plus 7.56.3-plus.2 → 7.56.4-plus.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.
@@ -1354,8 +1354,6 @@ function createFormControl(props = {}) {
1354
1354
  array: createSubject(),
1355
1355
  state: createSubject(),
1356
1356
  };
1357
- const validationModeBeforeSubmit = getValidationModes(_options.mode);
1358
- const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
1359
1357
  const shouldDisplayAllAssociatedErrors = _options.criteriaMode === VALIDATION_MODE.all;
1360
1358
  const id = createId(props.id);
1361
1359
  const debounce = (callback) => (wait) => {
@@ -1627,13 +1625,17 @@ function createFormControl(props = {}) {
1627
1625
  }
1628
1626
  else if (fieldReference.refs) {
1629
1627
  if (isCheckBoxInput(fieldReference.ref)) {
1630
- fieldReference.refs.length > 1
1631
- ? fieldReference.refs.forEach((checkboxRef) => (!checkboxRef.defaultChecked || !checkboxRef.disabled) &&
1632
- (checkboxRef.checked = Array.isArray(fieldValue)
1633
- ? !!fieldValue.find((data) => data === checkboxRef.value)
1634
- : fieldValue === checkboxRef.value))
1635
- : fieldReference.refs[0] &&
1636
- (fieldReference.refs[0].checked = !!fieldValue);
1628
+ fieldReference.refs.forEach((checkboxRef) => {
1629
+ if (!checkboxRef.defaultChecked || !checkboxRef.disabled) {
1630
+ if (Array.isArray(fieldValue)) {
1631
+ checkboxRef.checked = !!fieldValue.find((data) => data === checkboxRef.value);
1632
+ }
1633
+ else {
1634
+ checkboxRef.checked =
1635
+ fieldValue === checkboxRef.value || !!fieldValue;
1636
+ }
1637
+ }
1638
+ });
1637
1639
  }
1638
1640
  else {
1639
1641
  fieldReference.refs.forEach((radioRef) => (radioRef.checked = radioRef.value === fieldValue));
@@ -1659,6 +1661,9 @@ function createFormControl(props = {}) {
1659
1661
  };
1660
1662
  const setValues = (name, value, options) => {
1661
1663
  for (const fieldKey in value) {
1664
+ if (!value.hasOwnProperty(fieldKey)) {
1665
+ return;
1666
+ }
1662
1667
  const fieldValue = value[fieldKey];
1663
1668
  const fieldName = `${name}.${fieldKey}`;
1664
1669
  const field = get(_fields, fieldName);
@@ -1715,6 +1720,8 @@ function createFormControl(props = {}) {
1715
1720
  (isDateObject(fieldValue) && isNaN(fieldValue.getTime())) ||
1716
1721
  deepEqual(fieldValue, get(_formValues, name, fieldValue));
1717
1722
  };
1723
+ const validationModeBeforeSubmit = getValidationModes(_options.mode);
1724
+ const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
1718
1725
  if (field) {
1719
1726
  let error;
1720
1727
  let isValid;