react-hook-form 7.37.0-next.0 → 7.37.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 +3 -32
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.mjs +10 -12
- 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/useController.d.ts.map +1 -1
- package/dist/useFieldArray.d.ts.map +1 -1
- package/dist/utils/isPlainObject.d.ts +2 -1
- package/dist/utils/isPlainObject.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.mjs
CHANGED
@@ -395,9 +395,9 @@ function useController(props) {
|
|
395
395
|
},
|
396
396
|
type: EVENTS.BLUR,
|
397
397
|
}), [name, control]),
|
398
|
-
ref:
|
398
|
+
ref: (elm) => {
|
399
399
|
const field = get(control._fields, name);
|
400
|
-
if (
|
400
|
+
if (field && elm) {
|
401
401
|
field._f.ref = {
|
402
402
|
focus: () => elm.focus(),
|
403
403
|
select: () => elm.select(),
|
@@ -405,7 +405,7 @@ function useController(props) {
|
|
405
405
|
reportValidity: () => elm.reportValidity(),
|
406
406
|
};
|
407
407
|
}
|
408
|
-
},
|
408
|
+
},
|
409
409
|
},
|
410
410
|
formState,
|
411
411
|
fieldState: Object.defineProperties({}, {
|
@@ -793,10 +793,10 @@ function append(data, value) {
|
|
793
793
|
return [...data, ...convertToArrayPayload(value)];
|
794
794
|
}
|
795
795
|
|
796
|
-
|
796
|
+
var isPlainObject = (tempObject) => {
|
797
797
|
const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
|
798
798
|
return (isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
|
799
|
-
}
|
799
|
+
};
|
800
800
|
|
801
801
|
var isWeb = typeof window !== 'undefined' &&
|
802
802
|
typeof window.HTMLElement !== 'undefined' &&
|
@@ -1081,7 +1081,9 @@ function useFieldArray(props) {
|
|
1081
1081
|
React.useEffect(() => {
|
1082
1082
|
control._stateFlags.action = false;
|
1083
1083
|
isWatched(name, control._names) && control._subjects.state.next({});
|
1084
|
-
if (_actioned.current
|
1084
|
+
if (_actioned.current &&
|
1085
|
+
(!getValidationModes(control._options.mode).isOnSubmit ||
|
1086
|
+
control._formState.isSubmitted)) {
|
1085
1087
|
if (control._options.resolver) {
|
1086
1088
|
control._executeSchema([name]).then((result) => {
|
1087
1089
|
const error = get(result.errors, name);
|
@@ -1098,11 +1100,7 @@ function useFieldArray(props) {
|
|
1098
1100
|
}
|
1099
1101
|
else {
|
1100
1102
|
const field = get(control._fields, name);
|
1101
|
-
|
1102
|
-
if ((!validationModeBeforeSubmit.isOnSubmit ||
|
1103
|
-
control._formState.isSubmitted) &&
|
1104
|
-
field &&
|
1105
|
-
field._f) {
|
1103
|
+
if (field && field._f) {
|
1106
1104
|
validateField(field, get(control._formValues, name), control._options.criteriaMode === VALIDATION_MODE.all, control._options.shouldUseNativeValidation, true).then((error) => !isEmptyObject(error) &&
|
1107
1105
|
control._subjects.state.next({
|
1108
1106
|
errors: updateFieldArrayRootError(control._formState.errors, error, name),
|
@@ -1655,7 +1653,7 @@ function createFormControl(props = {}) {
|
|
1655
1653
|
? ''
|
1656
1654
|
: value;
|
1657
1655
|
if (isMultipleSelect(fieldReference.ref)) {
|
1658
|
-
[...fieldReference.ref.options].forEach((
|
1656
|
+
[...fieldReference.ref.options].forEach((optionRef) => (optionRef.selected = fieldValue.includes(optionRef.value)));
|
1659
1657
|
}
|
1660
1658
|
else if (fieldReference.refs) {
|
1661
1659
|
if (isCheckBoxInput(fieldReference.ref)) {
|