react-hook-form 7.31.0 → 7.31.3
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 +14 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.mjs +24 -9
- 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/logic/focusFieldBy.d.ts +2 -2
- package/dist/logic/focusFieldBy.d.ts.map +1 -1
- package/dist/logic/generateWatchOutput.d.ts +1 -1
- package/dist/logic/generateWatchOutput.d.ts.map +1 -1
- package/dist/logic/getCheckboxValue.d.ts +1 -1
- package/dist/logic/getCheckboxValue.d.ts.map +1 -1
- package/dist/logic/getProxyFormState.d.ts +1 -1
- package/dist/logic/getProxyFormState.d.ts.map +1 -1
- package/dist/logic/getRadioValue.d.ts +1 -1
- package/dist/logic/getRadioValue.d.ts.map +1 -1
- package/dist/logic/getResolverOptions.d.ts +1 -1
- package/dist/logic/getResolverOptions.d.ts.map +1 -1
- package/dist/logic/getRuleValue.d.ts +1 -1
- package/dist/logic/getRuleValue.d.ts.map +1 -1
- package/dist/logic/getValueAndMessage.d.ts +1 -1
- package/dist/logic/getValueAndMessage.d.ts.map +1 -1
- package/dist/logic/isWatched.d.ts +1 -1
- package/dist/logic/isWatched.d.ts.map +1 -1
- package/dist/logic/shouldRenderFormState.d.ts +1 -1
- package/dist/logic/shouldRenderFormState.d.ts.map +1 -1
- package/dist/logic/shouldSubscribeByName.d.ts +1 -1
- package/dist/logic/shouldSubscribeByName.d.ts.map +1 -1
- package/dist/logic/validateField.d.ts +1 -1
- package/dist/logic/validateField.d.ts.map +1 -1
- package/dist/types/form.d.ts +1 -1
- package/dist/useController.d.ts.map +1 -1
- package/dist/utils/cloneObject.d.ts.map +1 -1
- package/dist/utils/getValidationModes.d.ts +2 -1
- package/dist/utils/getValidationModes.d.ts.map +1 -1
- package/dist/utils/remove.d.ts +1 -1
- package/dist/utils/remove.d.ts.map +1 -1
- package/package.json +14 -13
- package/dist/logic/setCustomValidty.d.ts +0 -3
- package/dist/logic/setCustomValidty.d.ts.map +0 -1
package/dist/index.esm.mjs
CHANGED
@@ -416,7 +416,20 @@ function useController(props) {
|
|
416
416
|
}, [name, control._fields]),
|
417
417
|
},
|
418
418
|
formState,
|
419
|
-
fieldState:
|
419
|
+
fieldState: Object.defineProperties({}, {
|
420
|
+
invalid: {
|
421
|
+
get: () => !!get(formState.errors, name),
|
422
|
+
},
|
423
|
+
isDirty: {
|
424
|
+
get: () => !!get(formState.dirtyFields, name),
|
425
|
+
},
|
426
|
+
isTouched: {
|
427
|
+
get: () => !!get(formState.touchedFields, name),
|
428
|
+
},
|
429
|
+
error: {
|
430
|
+
get: () => get(formState.errors, name),
|
431
|
+
},
|
432
|
+
}),
|
420
433
|
};
|
421
434
|
}
|
422
435
|
|
@@ -545,6 +558,10 @@ function append(data, value) {
|
|
545
558
|
return [...data, ...convertToArrayPayload(value)];
|
546
559
|
}
|
547
560
|
|
561
|
+
var isWeb = typeof window !== 'undefined' &&
|
562
|
+
typeof window.HTMLElement !== 'undefined' &&
|
563
|
+
typeof document !== 'undefined';
|
564
|
+
|
548
565
|
function cloneObject(data) {
|
549
566
|
let copy;
|
550
567
|
const isArray = Array.isArray(data);
|
@@ -554,7 +571,8 @@ function cloneObject(data) {
|
|
554
571
|
else if (data instanceof Set) {
|
555
572
|
copy = new Set(data);
|
556
573
|
}
|
557
|
-
else if (
|
574
|
+
else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) &&
|
575
|
+
(isArray || isObject(data))) {
|
558
576
|
copy = isArray ? [] : {};
|
559
577
|
for (const key in data) {
|
560
578
|
copy[key] = isFunction(data[key]) ? data[key] : cloneObject(data[key]);
|
@@ -928,10 +946,6 @@ var isRadioInput = (element) => element.type === 'radio';
|
|
928
946
|
|
929
947
|
var isRadioOrCheckbox = (ref) => isRadioInput(ref) || isCheckBoxInput(ref);
|
930
948
|
|
931
|
-
var isWeb = typeof window !== 'undefined' &&
|
932
|
-
typeof window.HTMLElement !== 'undefined' &&
|
933
|
-
typeof document !== 'undefined';
|
934
|
-
|
935
949
|
var live = (ref) => isHTMLElement(ref) && ref.isConnected;
|
936
950
|
|
937
951
|
function markFieldsDirty(data, fields = {}) {
|
@@ -1926,8 +1940,7 @@ function createFormControl(props = {}) {
|
|
1926
1940
|
else {
|
1927
1941
|
await executeBuildInValidation(_fields);
|
1928
1942
|
}
|
1929
|
-
if (isEmptyObject(_formState.errors)
|
1930
|
-
Object.keys(_formState.errors).every((name) => get(fieldValues, name))) {
|
1943
|
+
if (isEmptyObject(_formState.errors)) {
|
1931
1944
|
_subjects.state.next({
|
1932
1945
|
errors: {},
|
1933
1946
|
isSubmitting: true,
|
@@ -2049,7 +2062,9 @@ function createFormControl(props = {}) {
|
|
2049
2062
|
? _formState.isDirty
|
2050
2063
|
: !!(keepStateOptions.keepDefaultValues &&
|
2051
2064
|
!deepEqual(formValues, _defaultValues)),
|
2052
|
-
isSubmitted:
|
2065
|
+
isSubmitted: keepStateOptions.keepIsSubmitted
|
2066
|
+
? _formState.isSubmitted
|
2067
|
+
: false,
|
2053
2068
|
dirtyFields: keepStateOptions.keepDirty || keepStateOptions.keepDirtyValues
|
2054
2069
|
? _formState.dirtyFields
|
2055
2070
|
: keepStateOptions.keepDefaultValues && formValues
|