@bombillazo/rhf-plus 7.56.3-plus.1 → 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.
- package/README.md +5 -4
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.mjs +20 -10
- package/dist/index.esm.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/logic/createFormControl.d.ts.map +1 -1
- package/dist/react-server.esm.mjs +16 -9
- package/dist/react-server.esm.mjs.map +1 -1
- package/dist/useController.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.mjs
CHANGED
|
@@ -357,7 +357,10 @@ function useWatch(props) {
|
|
|
357
357
|
*/
|
|
358
358
|
function useController(props) {
|
|
359
359
|
const methods = useFormContext();
|
|
360
|
-
const { name, disabled, control = methods.control, shouldUnregister } = props;
|
|
360
|
+
const { name, disabled, control = methods === null || methods === void 0 ? void 0 : methods.control, shouldUnregister, } = props;
|
|
361
|
+
if (!control) {
|
|
362
|
+
throw new Error('useController: missing `control`. Pass `control` as a prop or provide it via FormProvider.');
|
|
363
|
+
}
|
|
361
364
|
const isArrayField = isNameInFieldArray(control._names.array, name);
|
|
362
365
|
const value = useWatch({
|
|
363
366
|
control,
|
|
@@ -1351,8 +1354,6 @@ function createFormControl(props = {}) {
|
|
|
1351
1354
|
array: createSubject(),
|
|
1352
1355
|
state: createSubject(),
|
|
1353
1356
|
};
|
|
1354
|
-
const validationModeBeforeSubmit = getValidationModes(_options.mode);
|
|
1355
|
-
const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
|
|
1356
1357
|
const shouldDisplayAllAssociatedErrors = _options.criteriaMode === VALIDATION_MODE.all;
|
|
1357
1358
|
const id = createId(props.id);
|
|
1358
1359
|
const debounce = (callback) => (wait) => {
|
|
@@ -1624,13 +1625,17 @@ function createFormControl(props = {}) {
|
|
|
1624
1625
|
}
|
|
1625
1626
|
else if (fieldReference.refs) {
|
|
1626
1627
|
if (isCheckBoxInput(fieldReference.ref)) {
|
|
1627
|
-
fieldReference.refs.
|
|
1628
|
-
|
|
1629
|
-
(
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
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
|
+
});
|
|
1634
1639
|
}
|
|
1635
1640
|
else {
|
|
1636
1641
|
fieldReference.refs.forEach((radioRef) => (radioRef.checked = radioRef.value === fieldValue));
|
|
@@ -1656,6 +1661,9 @@ function createFormControl(props = {}) {
|
|
|
1656
1661
|
};
|
|
1657
1662
|
const setValues = (name, value, options) => {
|
|
1658
1663
|
for (const fieldKey in value) {
|
|
1664
|
+
if (!value.hasOwnProperty(fieldKey)) {
|
|
1665
|
+
return;
|
|
1666
|
+
}
|
|
1659
1667
|
const fieldValue = value[fieldKey];
|
|
1660
1668
|
const fieldName = `${name}.${fieldKey}`;
|
|
1661
1669
|
const field = get(_fields, fieldName);
|
|
@@ -1712,6 +1720,8 @@ function createFormControl(props = {}) {
|
|
|
1712
1720
|
(isDateObject(fieldValue) && isNaN(fieldValue.getTime())) ||
|
|
1713
1721
|
deepEqual(fieldValue, get(_formValues, name, fieldValue));
|
|
1714
1722
|
};
|
|
1723
|
+
const validationModeBeforeSubmit = getValidationModes(_options.mode);
|
|
1724
|
+
const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
|
|
1715
1725
|
if (field) {
|
|
1716
1726
|
let error;
|
|
1717
1727
|
let isValid;
|