From 917654ff5c3280cc08d105ec40c5a8c5d2ad3495 Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Fri, 12 Apr 2024 07:32:53 +1000
Subject: [PATCH 01/22] =?UTF-8?q?=F0=9F=90=9E=20fix=20#11773=20regression?=
=?UTF-8?q?=20on=20dirty=20check=20with=20reset=20(#11775)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/logic/createFormControl.ts | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/logic/createFormControl.ts b/src/logic/createFormControl.ts
index 4528dbe3..356089f0 100644
--- a/src/logic/createFormControl.ts
+++ b/src/logic/createFormControl.ts
@@ -680,6 +680,7 @@ export function createFormControl<
};
const onChange: ChangeHandler = async (event) => {
+ _state.mount = true;
const target = event.target;
let name = target.name as string;
let isFieldValueUpdated = true;
From 234d32dff937cfebd034be563e53c67a5e90ca7b Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Fri, 12 Apr 2024 07:33:08 +1000
Subject: [PATCH 02/22] 7.51.3
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index e006af6d..9ad563d7 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "react-hook-form",
"description": "Performant, flexible and extensible forms library for React Hooks",
- "version": "7.51.2",
+ "version": "7.51.3",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.mjs",
"umd:main": "dist/index.umd.js",
From 071b1e7af30a5e1c93160424badb397ad6d96303 Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Fri, 12 Apr 2024 11:04:42 +1000
Subject: [PATCH 03/22] =?UTF-8?q?=F0=9F=A9=BB=20update=20README.md=20(#117?=
=?UTF-8?q?76)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 4 ----
1 file changed, 4 deletions(-)
diff --git a/README.md b/README.md
index 894f5fab..1d5cd768 100644
--- a/README.md
+++ b/README.md
@@ -58,10 +58,6 @@ function App() {
}
```
-
-
-
-
### Sponsors
Thanks go to these kind and lovely sponsors!
From 01e75d3a63cea62c2c71fca894a59ee90aaadb16 Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Sun, 14 Apr 2024 10:03:54 +1000
Subject: [PATCH 04/22] =?UTF-8?q?=F0=9F=91=B9=20close=20#11778=20improve?=
=?UTF-8?q?=20unregister=20omit=20key=20with=20getValues=20method=20(#1177?=
=?UTF-8?q?9)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/logic/createFormControl.ts | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/logic/createFormControl.ts b/src/logic/createFormControl.ts
index 356089f0..7d32bb5a 100644
--- a/src/logic/createFormControl.ts
+++ b/src/logic/createFormControl.ts
@@ -870,8 +870,7 @@ export function createFormControl<
| ReadonlyArray>,
) => {
const values = {
- ..._defaultValues,
- ...(_state.mount ? _formValues : {}),
+ ...(_state.mount ? _formValues : _defaultValues),
};
return isUndefined(fieldNames)
From e37dc154f0348a7b2cb8640c2d5e7c7955053334 Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Sat, 4 May 2024 16:31:30 +1000
Subject: [PATCH 05/22] 7.51.4
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 9ad563d7..8adbfb43 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "react-hook-form",
"description": "Performant, flexible and extensible forms library for React Hooks",
- "version": "7.51.3",
+ "version": "7.51.4",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.mjs",
"umd:main": "dist/index.umd.js",
From 020b06f9f3851f024021b4506b49a3e8e6b0a128 Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Sat, 4 May 2024 03:00:43 -0500
Subject: [PATCH 06/22] =?UTF-8?q?=F0=9F=93=96=20fix=20broken=20link=20to?=
=?UTF-8?q?=20examples=20in=20README.md=20(#11805)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: Beier (Bill)
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 1d5cd768..4f8f0d5f 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@
API |
Form Builder |
FAQs |
- Examples
+ Examples
### Features
From 736d159de3a1a7cc5b59f5a55549f8bab676597b Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Sun, 5 May 2024 03:32:48 -0400
Subject: [PATCH 07/22] =?UTF-8?q?=E2=8C=A8=EF=B8=8F=20close:=20correct=20t?=
=?UTF-8?q?ype=20of=20`error`=20field=20in=20`getFieldState`=20return=20ob?=
=?UTF-8?q?ject=20(#11831)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix: correct type of `error` field in `getFieldState` return object
* fix: update reports
---
reports/api-extractor.md | 2 +-
src/types/form.ts | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/reports/api-extractor.md b/reports/api-extractor.md
index e47bcefe..5371dbc1 100644
--- a/reports/api-extractor.md
+++ b/reports/api-extractor.md
@@ -665,7 +665,7 @@ export type UseFormGetFieldState = [TFieldName];
};
// @public (undocumented)
diff --git a/src/types/form.ts b/src/types/form.ts
index ba3b7e0c..7e6aae4a 100644
--- a/src/types/form.ts
+++ b/src/types/form.ts
@@ -3,7 +3,7 @@ import React from 'react';
import { VALIDATION_MODE } from '../constants';
import { Subject, Subscription } from '../utils/createSubject';
-import { ErrorOption, FieldError, FieldErrors } from './errors';
+import { ErrorOption, FieldErrors } from './errors';
import { EventType } from './events';
import { FieldArray } from './fieldArray';
import {
@@ -362,7 +362,7 @@ export type UseFormGetFieldState = <
isDirty: boolean;
isTouched: boolean;
isValidating: boolean;
- error?: FieldError;
+ error?: FieldErrors[TFieldName];
};
export type UseFormWatch = {
From 8638a3b73cd8c9d05157ad0d55dc487c950a2f51 Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Sat, 18 May 2024 02:10:38 -0400
Subject: [PATCH 08/22] =?UTF-8?q?=F0=9F=90=9E=20fix=20#11842=20radio=20but?=
=?UTF-8?q?tons=20not=20disabled=20when=20multiple=20share=20a=20name=20(#?=
=?UTF-8?q?11873)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* feat: allow `iterateFieldsByAction` to iterate over multiple refs
* fix: `_disableForm` only disables one input when inputs share a name
* test: add unit tests for action iteration over multiple refs
* refactor: invert `abortEarly` param's logic to respect semantic meaning
* refactor: move ref iteration logic to if block
* chore: fix lint errors
* test: rename tests to reflect changes
* Update createFormControl.ts
* Update iterateFieldsByAction.ts
* Update iterateFieldsByAction.test.ts
---------
Co-authored-by: Beier (Bill)
---
src/__tests__/logic/iterateFieldsByAction.test.ts | 2 +-
src/logic/createFormControl.ts | 15 +++++++++------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/__tests__/logic/iterateFieldsByAction.test.ts b/src/__tests__/logic/iterateFieldsByAction.test.ts
index 7ede3c90..74803598 100644
--- a/src/__tests__/logic/iterateFieldsByAction.test.ts
+++ b/src/__tests__/logic/iterateFieldsByAction.test.ts
@@ -1,6 +1,6 @@
import iterateFieldsByAction from '../../logic/iterateFieldsByAction';
-describe('focusFieldBy', () => {
+describe('iterateFieldsByAction', () => {
it('should focus on the first error it encounter', () => {
const focus = jest.fn();
iterateFieldsByAction(
diff --git a/src/logic/createFormControl.ts b/src/logic/createFormControl.ts
index 7d32bb5a..92c100a8 100644
--- a/src/logic/createFormControl.ts
+++ b/src/logic/createFormControl.ts
@@ -1098,13 +1098,16 @@ export function createFormControl<
iterateFieldsByAction(
_fields,
(ref, name) => {
- let requiredDisabledState = disabled;
- const currentField = get(_fields, name);
- if (currentField && isBoolean(currentField._f.disabled)) {
- requiredDisabledState ||= currentField._f.disabled;
+ const currentField: Field = get(_fields, name);
+ if (currentField) {
+ ref.disabled = currentField._f.disabled || disabled;
+
+ if (Array.isArray(currentField._f.refs)) {
+ currentField._f.refs.forEach((inputRef) => {
+ inputRef.disabled = currentField._f.disabled || disabled;
+ });
+ }
}
-
- ref.disabled = requiredDisabledState;
},
0,
false,
From eda5542a9109dba2c6b7ffb2ed9b151b5017072a Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Sat, 18 May 2024 12:18:19 +0530
Subject: [PATCH 09/22] =?UTF-8?q?=F0=9F=90=9E=20fix=20#11821=20set=20value?=
=?UTF-8?q?=20with=20disabled=20false=20before=20mount=20(#11880)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix(11821): lodash get does not return defaultValue
When expression is evaluated as null the get method does not return defaultValue
* Update createFormControl.ts
---------
Co-authored-by: Beier (Bill)
---
src/logic/createFormControl.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/logic/createFormControl.ts b/src/logic/createFormControl.ts
index 92c100a8..6a3494b5 100644
--- a/src/logic/createFormControl.ts
+++ b/src/logic/createFormControl.ts
@@ -983,7 +983,7 @@ export function createFormControl<
fields,
value,
}) => {
- if (isBoolean(disabled)) {
+ if ((isBoolean(disabled) && _state.mount) || !!disabled) {
const inputValue = disabled
? undefined
: isUndefined(value)
From 4a3f9be1fc5e65ece5060aac9d43564f92f72ef8 Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Sat, 18 May 2024 20:18:19 -0400
Subject: [PATCH 10/22] =?UTF-8?q?=F0=9F=90=9E=20fix=20`setError`=20to=20pr?=
=?UTF-8?q?eserve=20existing=20errors=20elsewhere=20in=20the=20object=20(#?=
=?UTF-8?q?11888)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* Add Test to Prove that setError is not idempotent
* When setting error, preserve errors further down in object tree
---
src/__tests__/useForm/setError.test.tsx | 87 +++++++++++++++++++++++++
src/logic/createFormControl.ts | 5 ++
2 files changed, 92 insertions(+)
diff --git a/src/__tests__/useForm/setError.test.tsx b/src/__tests__/useForm/setError.test.tsx
index 8486c13b..656f3c14 100644
--- a/src/__tests__/useForm/setError.test.tsx
+++ b/src/__tests__/useForm/setError.test.tsx
@@ -164,4 +164,91 @@ describe('setError', () => {
screen.findByText('not found');
});
});
+
+ it('should allow sequential calls to set with child after ancestor', async () => {
+ const { result } = renderHook(() =>
+ useForm<{ input: { first: string; last: string } }>(),
+ );
+ result.current.formState.errors;
+
+ act(() => {
+ result.current.setError('input', {
+ type: 'test',
+ message: 'Some error that depends on both fields',
+ });
+ });
+
+ expect(result.current.formState.errors).toEqual({
+ input: {
+ type: 'test',
+ message: 'Some error that depends on both fields',
+ ref: undefined,
+ },
+ });
+
+ act(() => {
+ result.current.setError('input.first', {
+ type: 'test',
+ message: 'Name must be capitalized',
+ });
+ });
+
+ expect(result.current.formState.errors).toEqual({
+ input: {
+ type: 'test',
+ message: 'Some error that depends on both fields',
+ ref: undefined,
+ first: {
+ type: 'test',
+ message: 'Name must be capitalized',
+ ref: undefined,
+ },
+ },
+ });
+ });
+
+ it('should allow sequential calls to set with ancestor after child', async () => {
+ const { result } = renderHook(() =>
+ useForm<{ input: { first: string; last: string } }>(),
+ );
+
+ result.current.formState.errors;
+
+ act(() => {
+ result.current.setError('input.first', {
+ type: 'test',
+ message: 'Name must be capitalized',
+ });
+ });
+
+ expect(result.current.formState.errors).toEqual({
+ input: {
+ first: {
+ type: 'test',
+ message: 'Name must be capitalized',
+ ref: undefined,
+ },
+ },
+ });
+
+ act(() => {
+ result.current.setError('input', {
+ type: 'test',
+ message: 'Some error that depends on both fields',
+ });
+ });
+
+ expect(result.current.formState.errors).toEqual({
+ input: {
+ type: 'test',
+ message: 'Some error that depends on both fields',
+ ref: undefined,
+ first: {
+ type: 'test',
+ message: 'Name must be capitalized',
+ ref: undefined,
+ },
+ },
+ });
+ });
});
diff --git a/src/logic/createFormControl.ts b/src/logic/createFormControl.ts
index 6a3494b5..0a81adac 100644
--- a/src/logic/createFormControl.ts
+++ b/src/logic/createFormControl.ts
@@ -904,8 +904,13 @@ export function createFormControl<
const setError: UseFormSetError = (name, error, options) => {
const ref = (get(_fields, name, { _f: {} })._f || {}).ref;
+ const currentError = get(_formState.errors, name) || {};
+
+ // Don't override existing error messages elsewhere in the object tree.
+ const { ref: currentRef, message, type, ...restOfErrorTree } = currentError;
set(_formState.errors, name, {
+ ...restOfErrorTree,
...error,
ref,
});
From a48f88d94faafd224a9b4b5065185fae41034547 Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Sun, 19 May 2024 03:23:38 +0300
Subject: [PATCH 11/22] =?UTF-8?q?=E2=8C=A8=EF=B8=8F=20fix:=20add=20info.va?=
=?UTF-8?q?lue=20type=20to=20WatchObserver=20(#11872)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
reports/api-extractor.md | 1 +
src/types/form.ts | 1 +
2 files changed, 2 insertions(+)
diff --git a/reports/api-extractor.md b/reports/api-extractor.md
index 5371dbc1..70068bb4 100644
--- a/reports/api-extractor.md
+++ b/reports/api-extractor.md
@@ -867,6 +867,7 @@ export type WatchInternal = (fieldNames?: InternalFieldName | Inte
export type WatchObserver = (value: DeepPartial, info: {
name?: FieldPath;
type?: EventType;
+ value?: unknown;
}) => void;
// Warnings were encountered during analysis:
diff --git a/src/types/form.ts b/src/types/form.ts
index 7e6aae4a..d17cd6c5 100644
--- a/src/types/form.ts
+++ b/src/types/form.ts
@@ -825,6 +825,7 @@ export type WatchObserver = (
info: {
name?: FieldPath;
type?: EventType;
+ value?: unknown;
},
) => void;
From 8a2bdc13c54f90ff487c21a56c4e0cdf2a893bbe Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Tue, 21 May 2024 11:28:27 +1000
Subject: [PATCH 12/22] =?UTF-8?q?=F0=9F=91=AE=E2=80=8D=E2=99=80=EF=B8=8F?=
=?UTF-8?q?=20fix:=20remove=20export=20on=20`set`=20(#11911)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* remove export on react hook form set
* revert change
* update api contract
---
app/package.json | 2 +-
app/pnpm-lock.yaml | 54 ++++++++++++++++++++--------------------
reports/api-extractor.md | 3 ---
src/useController.ts | 2 +-
src/utils/index.ts | 3 +--
5 files changed, 30 insertions(+), 34 deletions(-)
diff --git a/app/package.json b/app/package.json
index d9d2ed15..1e0db29e 100644
--- a/app/package.json
+++ b/app/package.json
@@ -8,7 +8,7 @@
},
"license": "MIT",
"dependencies": {
- "@hookform/resolvers": "2.8.8",
+ "@hookform/resolvers": "3.4.2",
"@material-ui/core": "^4.12.3",
"joi": "^17.5.0",
"react": "^17.0.1",
diff --git a/app/pnpm-lock.yaml b/app/pnpm-lock.yaml
index 940426f8..0ae860d5 100644
--- a/app/pnpm-lock.yaml
+++ b/app/pnpm-lock.yaml
@@ -6,8 +6,8 @@ settings:
dependencies:
'@hookform/resolvers':
- specifier: 2.8.8
- version: 2.8.8(react-hook-form@7.51.0)
+ specifier: 3.4.2
+ version: 3.4.2(react-hook-form@7.51.4)
'@material-ui/core':
specifier: ^4.12.3
version: 4.12.4(@types/react@17.0.52)(react-dom@17.0.2)(react@17.0.2)
@@ -401,7 +401,7 @@ packages:
resolution: {integrity: sha512-AHPmaAx+RYfZz0eYu6Gviiagpmiyw98ySSlQvCUhVGDRtDFe4DBS0x1bSjdF3gqUDYOczB+yYvBTtEylYSdRhg==}
/@esbuild/android-arm@0.15.17:
- resolution: {integrity: sha512-ay6Ken4u+JStjYmqIgh71jMT0bs/rXpCCDKaMfl78B20QYWJglT5P6Ejfm4hWf6Zi+uUWNe7ZmqakRs2BQYIeg==}
+ resolution: {integrity: sha512-ay6Ken4u+JStjYmqIgh71jMT0bs/rXpCCDKaMfl78B20QYWJglT5P6Ejfm4hWf6Zi+uUWNe7ZmqakRs2BQYIeg==, tarball: https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [arm]
os: [android]
@@ -410,7 +410,7 @@ packages:
optional: true
/@esbuild/linux-loong64@0.15.17:
- resolution: {integrity: sha512-IA1O7f7qxw2DX8oqTpugHElr926phs7Rq8ULXleBMk4go5K05BU0mI8BfCkWcYAvcmVaMc13bv5W3LIUlU6Y9w==}
+ resolution: {integrity: sha512-IA1O7f7qxw2DX8oqTpugHElr926phs7Rq8ULXleBMk4go5K05BU0mI8BfCkWcYAvcmVaMc13bv5W3LIUlU6Y9w==, tarball: https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [loong64]
os: [linux]
@@ -436,8 +436,8 @@ packages:
'@hapi/hoek': 9.3.0
dev: false
- /@hookform/resolvers@2.8.8(react-hook-form@7.51.0):
- resolution: {integrity: sha512-meAEDur1IJBfKyTo9yPYAuzjIfrxA7m9Ov+1nxaW/YupsqMeseWifoUjWK03+hz/RJizsVQAaUjVxFEkyu0GWg==}
+ /@hookform/resolvers@3.4.2(react-hook-form@7.51.4):
+ resolution: {integrity: sha512-1m9uAVIO8wVf7VCDAGsuGA0t6Z3m6jVGAN50HkV9vYLl0yixKK/Z1lr01vaRvYCkIKGoy1noVRxMzQYb4y/j1Q==, tarball: https://registry.npmjs.org/@hookform/resolvers/-/resolvers-3.4.2.tgz}
peerDependencies:
react-hook-form: ^7.0.0
dependencies:
@@ -791,7 +791,7 @@ packages:
is-arrayish: 0.2.1
/esbuild-android-64@0.15.17:
- resolution: {integrity: sha512-sUs6cKMAuAyWnJ/66ezWVr9SMRGFSwoMagxzdhXYggSA12zF7krXSuc1Y9JwxHq56wtv/gFAVo97TFm7RBc1Ig==}
+ resolution: {integrity: sha512-sUs6cKMAuAyWnJ/66ezWVr9SMRGFSwoMagxzdhXYggSA12zF7krXSuc1Y9JwxHq56wtv/gFAVo97TFm7RBc1Ig==, tarball: https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [x64]
os: [android]
@@ -800,7 +800,7 @@ packages:
optional: true
/esbuild-android-arm64@0.15.17:
- resolution: {integrity: sha512-RLZuCgIx1rexwxwsXTEW40ZiZzdBI1MBphwDRFyms/iiJGwLxqCH7v75iSJk5s6AF6oa80KC6r/RmzyaX/uJNg==}
+ resolution: {integrity: sha512-RLZuCgIx1rexwxwsXTEW40ZiZzdBI1MBphwDRFyms/iiJGwLxqCH7v75iSJk5s6AF6oa80KC6r/RmzyaX/uJNg==, tarball: https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [arm64]
os: [android]
@@ -809,7 +809,7 @@ packages:
optional: true
/esbuild-darwin-64@0.15.17:
- resolution: {integrity: sha512-+6RTCZ0hfAb+RqTNq1uVsBcP441yZOSi6CyV9BIBryGGVg8RM3Bc6L45e5b68jdRloddN92ekS50e4ElI+cHQA==}
+ resolution: {integrity: sha512-+6RTCZ0hfAb+RqTNq1uVsBcP441yZOSi6CyV9BIBryGGVg8RM3Bc6L45e5b68jdRloddN92ekS50e4ElI+cHQA==, tarball: https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [x64]
os: [darwin]
@@ -818,7 +818,7 @@ packages:
optional: true
/esbuild-darwin-arm64@0.15.17:
- resolution: {integrity: sha512-ne4UWUHEKWLgYSE5SLr0/TBcID3k9LPnrzzRXzFLTfD+ygjnW1pMEgdMfmOKIe8jYBUYv8x/YoksriTdQb9r/Q==}
+ resolution: {integrity: sha512-ne4UWUHEKWLgYSE5SLr0/TBcID3k9LPnrzzRXzFLTfD+ygjnW1pMEgdMfmOKIe8jYBUYv8x/YoksriTdQb9r/Q==, tarball: https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [arm64]
os: [darwin]
@@ -827,7 +827,7 @@ packages:
optional: true
/esbuild-freebsd-64@0.15.17:
- resolution: {integrity: sha512-6my3DrwLOe1zhR8UzVRKeo9AFM9XkApJBcx0IE+qKaEbKKBxYAiDBtd2ZMtRA2agqIwRP0kuHofTiDEzpfA+ZA==}
+ resolution: {integrity: sha512-6my3DrwLOe1zhR8UzVRKeo9AFM9XkApJBcx0IE+qKaEbKKBxYAiDBtd2ZMtRA2agqIwRP0kuHofTiDEzpfA+ZA==, tarball: https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [x64]
os: [freebsd]
@@ -836,7 +836,7 @@ packages:
optional: true
/esbuild-freebsd-arm64@0.15.17:
- resolution: {integrity: sha512-LQL7+f+bz+xmAu1FcDBB304Wm2CjONUcOeF4f3TqG7wYXMxjjYQZBFv+0OVapNXyYrM2vy9JMDbps+SheuOnHg==}
+ resolution: {integrity: sha512-LQL7+f+bz+xmAu1FcDBB304Wm2CjONUcOeF4f3TqG7wYXMxjjYQZBFv+0OVapNXyYrM2vy9JMDbps+SheuOnHg==, tarball: https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [arm64]
os: [freebsd]
@@ -845,7 +845,7 @@ packages:
optional: true
/esbuild-linux-32@0.15.17:
- resolution: {integrity: sha512-7E9vZXMZhINQ4/KcxBxioJ2ao5gbXJ6Pa4/LEUd102g3gadSalpg0LrityFgw7ao6qmjcNWwdEYrXaDnOzyyYA==}
+ resolution: {integrity: sha512-7E9vZXMZhINQ4/KcxBxioJ2ao5gbXJ6Pa4/LEUd102g3gadSalpg0LrityFgw7ao6qmjcNWwdEYrXaDnOzyyYA==, tarball: https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [ia32]
os: [linux]
@@ -854,7 +854,7 @@ packages:
optional: true
/esbuild-linux-64@0.15.17:
- resolution: {integrity: sha512-TnedHtFQSUVlc0J0D4ZMMalYaQ0Zbt7HSwGy4sav7BlXVqDVc/rchJ/a9dathK51apzLgRyXQMseLf6bkloaSQ==}
+ resolution: {integrity: sha512-TnedHtFQSUVlc0J0D4ZMMalYaQ0Zbt7HSwGy4sav7BlXVqDVc/rchJ/a9dathK51apzLgRyXQMseLf6bkloaSQ==, tarball: https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [x64]
os: [linux]
@@ -863,7 +863,7 @@ packages:
optional: true
/esbuild-linux-arm64@0.15.17:
- resolution: {integrity: sha512-oupYfh0lTHg+F/2ZoTNrioB+KLd6x0Zlhjz2Oa1jhl8wCGkNvwe25RytR2/SGPYpoNVcvCeoayWQRwwRuWGgfQ==}
+ resolution: {integrity: sha512-oupYfh0lTHg+F/2ZoTNrioB+KLd6x0Zlhjz2Oa1jhl8wCGkNvwe25RytR2/SGPYpoNVcvCeoayWQRwwRuWGgfQ==, tarball: https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [arm64]
os: [linux]
@@ -872,7 +872,7 @@ packages:
optional: true
/esbuild-linux-arm@0.15.17:
- resolution: {integrity: sha512-+ugCmBTTDIlh+UuC7E/GvyJqjGTX2pNOA+g3isG78aYcfgswrHjvstTtIfljaU95AS30qrVNLgI5h/8TsRWTrg==}
+ resolution: {integrity: sha512-+ugCmBTTDIlh+UuC7E/GvyJqjGTX2pNOA+g3isG78aYcfgswrHjvstTtIfljaU95AS30qrVNLgI5h/8TsRWTrg==, tarball: https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [arm]
os: [linux]
@@ -881,7 +881,7 @@ packages:
optional: true
/esbuild-linux-mips64le@0.15.17:
- resolution: {integrity: sha512-aUVyHwUXJF1hi9jsAT+At+cBxZh2yGICi/e757N6d/zzOD+eVK3PKQj68tAvIflx6/ZpnuCTKol1GpgGYrzERg==}
+ resolution: {integrity: sha512-aUVyHwUXJF1hi9jsAT+At+cBxZh2yGICi/e757N6d/zzOD+eVK3PKQj68tAvIflx6/ZpnuCTKol1GpgGYrzERg==, tarball: https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [mips64el]
os: [linux]
@@ -890,7 +890,7 @@ packages:
optional: true
/esbuild-linux-ppc64le@0.15.17:
- resolution: {integrity: sha512-i7789iFTLfLccHPNADCbaZPx9CuQblsBqv2j4XqIBN1jKIJbpQ8iqCkWoHep4PLqqKLtBLtTWh919GsrFGdeJA==}
+ resolution: {integrity: sha512-i7789iFTLfLccHPNADCbaZPx9CuQblsBqv2j4XqIBN1jKIJbpQ8iqCkWoHep4PLqqKLtBLtTWh919GsrFGdeJA==, tarball: https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [ppc64]
os: [linux]
@@ -899,7 +899,7 @@ packages:
optional: true
/esbuild-linux-riscv64@0.15.17:
- resolution: {integrity: sha512-fEQ/8tnZ2sDniBlPfTXEdg+0OP1olps96HvYdwl8ywJdAlD7AK761EL3lRbRdfMHNOId2N6+CVca43/Fiu/0AQ==}
+ resolution: {integrity: sha512-fEQ/8tnZ2sDniBlPfTXEdg+0OP1olps96HvYdwl8ywJdAlD7AK761EL3lRbRdfMHNOId2N6+CVca43/Fiu/0AQ==, tarball: https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [riscv64]
os: [linux]
@@ -908,7 +908,7 @@ packages:
optional: true
/esbuild-linux-s390x@0.15.17:
- resolution: {integrity: sha512-ZBQekST4gYgTKHAvUJtR1kFFulHTDlRZSE8T0wRQCmQqydNkC1teWxlR31xS6MZevjZGfa7OMVJD24bBhei/2Q==}
+ resolution: {integrity: sha512-ZBQekST4gYgTKHAvUJtR1kFFulHTDlRZSE8T0wRQCmQqydNkC1teWxlR31xS6MZevjZGfa7OMVJD24bBhei/2Q==, tarball: https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [s390x]
os: [linux]
@@ -917,7 +917,7 @@ packages:
optional: true
/esbuild-netbsd-64@0.15.17:
- resolution: {integrity: sha512-onNBFaZVN9GzGJMm3aZJJv74n/Q8FjW20G9OfSDhHjvamqJ5vbd42hNk6igQX4lgBCHTZvvBlWDJAMy+tbJAAw==}
+ resolution: {integrity: sha512-onNBFaZVN9GzGJMm3aZJJv74n/Q8FjW20G9OfSDhHjvamqJ5vbd42hNk6igQX4lgBCHTZvvBlWDJAMy+tbJAAw==, tarball: https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [x64]
os: [netbsd]
@@ -926,7 +926,7 @@ packages:
optional: true
/esbuild-openbsd-64@0.15.17:
- resolution: {integrity: sha512-QFxHmvjaRrmTCvH/A3EmzqKUSZHRQ7/pbrJeATsb/Q6qckCeL9e7zg/1A3HiZqDXeBUV3yNeBeV1GJBjY6yVyA==}
+ resolution: {integrity: sha512-QFxHmvjaRrmTCvH/A3EmzqKUSZHRQ7/pbrJeATsb/Q6qckCeL9e7zg/1A3HiZqDXeBUV3yNeBeV1GJBjY6yVyA==, tarball: https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [x64]
os: [openbsd]
@@ -935,7 +935,7 @@ packages:
optional: true
/esbuild-sunos-64@0.15.17:
- resolution: {integrity: sha512-7dHZA8Kc6U8rBTKojJatXtzHTUKJ3CRYimvOGIQQ1yUDOqGx/zZkCH/HkEi3Zg5SWyDj/57E5e1YJPo4ySSw/w==}
+ resolution: {integrity: sha512-7dHZA8Kc6U8rBTKojJatXtzHTUKJ3CRYimvOGIQQ1yUDOqGx/zZkCH/HkEi3Zg5SWyDj/57E5e1YJPo4ySSw/w==, tarball: https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [x64]
os: [sunos]
@@ -944,7 +944,7 @@ packages:
optional: true
/esbuild-windows-32@0.15.17:
- resolution: {integrity: sha512-yDrNrwQ/0k4N3OZItZ6k6YnBUch8+of06YRYc3hFI8VDm7X1rkNZwhttZNAzF6+TtbnK4cIz7H2/EwdSoaGZ3g==}
+ resolution: {integrity: sha512-yDrNrwQ/0k4N3OZItZ6k6YnBUch8+of06YRYc3hFI8VDm7X1rkNZwhttZNAzF6+TtbnK4cIz7H2/EwdSoaGZ3g==, tarball: https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [ia32]
os: [win32]
@@ -953,7 +953,7 @@ packages:
optional: true
/esbuild-windows-64@0.15.17:
- resolution: {integrity: sha512-jPnXvB4zMMToNPpCBdt+OEQiYFVs9wlQ5G8vMoJkrYJBp1aEt070MRpBFa6pfBFrgXquqgUiNAohMcTdy+JVFg==}
+ resolution: {integrity: sha512-jPnXvB4zMMToNPpCBdt+OEQiYFVs9wlQ5G8vMoJkrYJBp1aEt070MRpBFa6pfBFrgXquqgUiNAohMcTdy+JVFg==, tarball: https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [x64]
os: [win32]
@@ -962,7 +962,7 @@ packages:
optional: true
/esbuild-windows-arm64@0.15.17:
- resolution: {integrity: sha512-I5QeSsz0X66V8rxVhmw03Wzn8Tz63H3L9GrsA7C5wvBXMk3qahLWuEL+l7SZ2DleKkFeZZMu1dPxOak9f1TZ4A==}
+ resolution: {integrity: sha512-I5QeSsz0X66V8rxVhmw03Wzn8Tz63H3L9GrsA7C5wvBXMk3qahLWuEL+l7SZ2DleKkFeZZMu1dPxOak9f1TZ4A==, tarball: https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.15.17.tgz}
engines: {node: '>=12'}
cpu: [arm64]
os: [win32]
@@ -1016,7 +1016,7 @@ packages:
resolution: {integrity: sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==}
/fsevents@2.3.2:
- resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
+ resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==, tarball: https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz}
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
os: [darwin]
requiresBuild: true
diff --git a/reports/api-extractor.md b/reports/api-extractor.md
index 70068bb4..1cf3db4c 100644
--- a/reports/api-extractor.md
+++ b/reports/api-extractor.md
@@ -531,9 +531,6 @@ export type ResolverSuccess = {
errors: {};
};
-// @public (undocumented)
-export const set: (object: FieldValues, path: string, value?: unknown) => FieldValues;
-
// @public (undocumented)
export type SetFieldValue = FieldValue;
diff --git a/src/useController.ts b/src/useController.ts
index 9f81698a..28372f7d 100644
--- a/src/useController.ts
+++ b/src/useController.ts
@@ -6,6 +6,7 @@ import cloneObject from './utils/cloneObject';
import get from './utils/get';
import isBoolean from './utils/isBoolean';
import isUndefined from './utils/isUndefined';
+import set from './utils/set';
import { EVENTS } from './constants';
import {
ControllerFieldState,
@@ -20,7 +21,6 @@ import {
import { useFormContext } from './useFormContext';
import { useFormState } from './useFormState';
import { useWatch } from './useWatch';
-import { set } from './utils';
/**
* Custom hook to work with controlled component, this function provide you with both form and field level state. Re-render is isolated at the hook level.
diff --git a/src/utils/index.ts b/src/utils/index.ts
index cfefb720..bf029533 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -1,4 +1,3 @@
import get from './get';
-import set from './set';
-export { get, set };
+export { get };
From 890eac0c0a978cda6a3019399cfa4cde8b767e24 Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Tue, 21 May 2024 21:32:14 +1000
Subject: [PATCH 13/22] fix issue with set api (#11915)
* fix issue with set api
* remove test file
* add test coverage and update api contract
---
reports/api-extractor.md | 3 +++
src/__tests__/utils/set.test.ts | 5 +++++
src/utils/index.ts | 3 ++-
src/utils/set.ts | 5 +++++
4 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/reports/api-extractor.md b/reports/api-extractor.md
index 1cf3db4c..3ccca66d 100644
--- a/reports/api-extractor.md
+++ b/reports/api-extractor.md
@@ -531,6 +531,9 @@ export type ResolverSuccess = {
errors: {};
};
+// @public (undocumented)
+export const set: (object: FieldValues, path: string, value?: unknown) => FieldValues | undefined;
+
// @public (undocumented)
export type SetFieldValue = FieldValue;
diff --git a/src/__tests__/utils/set.test.ts b/src/__tests__/utils/set.test.ts
index d89e06c1..7f83cfcf 100644
--- a/src/__tests__/utils/set.test.ts
+++ b/src/__tests__/utils/set.test.ts
@@ -57,4 +57,9 @@ describe('set', () => {
},
});
});
+
+ it('should not populate prototype', () => {
+ set({}, '__proto__[test2]', '456');
+ expect(Object.prototype).toEqual({});
+ });
});
diff --git a/src/utils/index.ts b/src/utils/index.ts
index bf029533..cfefb720 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -1,3 +1,4 @@
import get from './get';
+import set from './set';
-export { get };
+export { get, set };
diff --git a/src/utils/set.ts b/src/utils/set.ts
index f26e3c19..d99b3b08 100644
--- a/src/utils/set.ts
+++ b/src/utils/set.ts
@@ -23,6 +23,11 @@ export default (object: FieldValues, path: string, value?: unknown) => {
? []
: {};
}
+
+ if (key === '__proto__') {
+ return;
+ }
+
object[key] = newValue;
object = object[key];
}
From 9cbaa94f018ee354d9edc74362d166200001f7bb Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Tue, 21 May 2024 21:32:39 +1000
Subject: [PATCH 14/22] 7.51.5
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 8adbfb43..334eedd5 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "react-hook-form",
"description": "Performant, flexible and extensible forms library for React Hooks",
- "version": "7.51.4",
+ "version": "7.51.5",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.mjs",
"umd:main": "dist/index.umd.js",
From 74538d2709ac7d814c885bc8dae153c2e2d4731a Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Wed, 22 May 2024 10:44:37 +0300
Subject: [PATCH 15/22] =?UTF-8?q?=F0=9F=93=96=20fix:=20change=20info.value?=
=?UTF-8?q?s=20type=20in=20WatchObserver=20(#11917)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix: change info.values type in WatchObserver
* update API extractor
---
reports/api-extractor.md | 2 +-
src/types/form.ts | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/reports/api-extractor.md b/reports/api-extractor.md
index 3ccca66d..5c3dd9b3 100644
--- a/reports/api-extractor.md
+++ b/reports/api-extractor.md
@@ -867,7 +867,7 @@ export type WatchInternal = (fieldNames?: InternalFieldName | Inte
export type WatchObserver = (value: DeepPartial, info: {
name?: FieldPath;
type?: EventType;
- value?: unknown;
+ values?: unknown;
}) => void;
// Warnings were encountered during analysis:
diff --git a/src/types/form.ts b/src/types/form.ts
index d17cd6c5..6ec99767 100644
--- a/src/types/form.ts
+++ b/src/types/form.ts
@@ -825,7 +825,7 @@ export type WatchObserver = (
info: {
name?: FieldPath;
type?: EventType;
- value?: unknown;
+ values?: unknown;
},
) => void;
From f0ab660d1e7c48a81ff7079793a9a4be171cea34 Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Thu, 23 May 2024 21:14:57 +1000
Subject: [PATCH 16/22] =?UTF-8?q?Revert=20"=E2=8C=A8=EF=B8=8F=20close:=20c?=
=?UTF-8?q?orrect=20type=20of=20`error`=20field=20in=20`getFieldState`=20r?=
=?UTF-8?q?eturn=20object=20(#11831)"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reverts commit 4549afd5afa8a824a1522e75f776083e4168aac6.
---
reports/api-extractor.md | 2 +-
src/types/form.ts | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/reports/api-extractor.md b/reports/api-extractor.md
index 5c3dd9b3..9227ca4b 100644
--- a/reports/api-extractor.md
+++ b/reports/api-extractor.md
@@ -665,7 +665,7 @@ export type UseFormGetFieldState = [TFieldName];
+ error?: FieldError;
};
// @public (undocumented)
diff --git a/src/types/form.ts b/src/types/form.ts
index 6ec99767..d4933c8f 100644
--- a/src/types/form.ts
+++ b/src/types/form.ts
@@ -3,7 +3,7 @@ import React from 'react';
import { VALIDATION_MODE } from '../constants';
import { Subject, Subscription } from '../utils/createSubject';
-import { ErrorOption, FieldErrors } from './errors';
+import { ErrorOption, FieldError, FieldErrors } from './errors';
import { EventType } from './events';
import { FieldArray } from './fieldArray';
import {
@@ -362,7 +362,7 @@ export type UseFormGetFieldState = <
isDirty: boolean;
isTouched: boolean;
isValidating: boolean;
- error?: FieldErrors[TFieldName];
+ error?: FieldError;
};
export type UseFormWatch = {
From f73c5e08eb653483cd071d94693d0cefaf9db50c Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Sat, 25 May 2024 15:31:31 +1000
Subject: [PATCH 17/22] =?UTF-8?q?=E2=9A=9B=EF=B8=8F=20close=20#11932=20all?=
=?UTF-8?q?ow=20react=2019=20peer=20dependency=20(#11935)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 334eedd5..568a848a 100644
--- a/package.json
+++ b/package.json
@@ -123,7 +123,7 @@
]
},
"peerDependencies": {
- "react": "^16.8.0 || ^17 || ^18"
+ "react": "^16.8.0 || ^17 || ^18 || ^19"
},
"lint-staged": {
"*.{js,ts,tsx}": [
From f17a03e853e6fcfd85f9a9d83fd6a4012f0184b5 Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Sun, 26 May 2024 06:46:33 +0900
Subject: [PATCH 18/22] =?UTF-8?q?=F0=9F=9A=94=20close=20#11937=20add=20val?=
=?UTF-8?q?idation=20in=20the=20cleanup=20process=20in=20`useController`?=
=?UTF-8?q?=20(#11938)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix #11937 add validation in cleanup in useController
* Update src/useController.ts
---------
Co-authored-by: Beier (Bill)
---
package.json | 2 +-
src/useController.ts | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/package.json b/package.json
index 568a848a..96399d10 100644
--- a/package.json
+++ b/package.json
@@ -118,7 +118,7 @@
"files": [
{
"path": "./dist/index.cjs.js",
- "maxSize": "10.1 kB"
+ "maxSize": "10.2 kB"
}
]
},
diff --git a/src/useController.ts b/src/useController.ts
index 28372f7d..10021d25 100644
--- a/src/useController.ts
+++ b/src/useController.ts
@@ -85,7 +85,7 @@ export function useController<
const updateMounted = (name: InternalFieldName, value: boolean) => {
const field: Field = get(control._fields, name);
- if (field) {
+ if (field && field._f) {
field._f.mount = value;
}
};
From afda956e89d9eabe0536c15c74141b7bb4e238f6 Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Sat, 1 Jun 2024 11:24:37 +1000
Subject: [PATCH 19/22] =?UTF-8?q?=F0=9F=90=9E=20fix=20#11922=20keep=20dirt?=
=?UTF-8?q?y=20on=20reset=20with=20dirty=20fields=20(#11958)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* 🐞 fix #11922 keep dirty on reset with dirty fields
* prettier
---
src/logic/createFormControl.ts | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/logic/createFormControl.ts b/src/logic/createFormControl.ts
index 0a81adac..6f5af3b6 100644
--- a/src/logic/createFormControl.ts
+++ b/src/logic/createFormControl.ts
@@ -1307,6 +1307,8 @@ export function createFormControl<
: _formState.dirtyFields
: keepStateOptions.keepDefaultValues && formValues
? getDirtyFields(_defaultValues, formValues)
+ : keepStateOptions.keepDirty
+ ? _formState.dirtyFields
: {},
touchedFields: keepStateOptions.keepTouched
? _formState.touchedFields
From d8d4f19deac77d6f759fd386bef4934edbbfcacc Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Thu, 6 Jun 2024 03:16:34 +0300
Subject: [PATCH 20/22] =?UTF-8?q?=E2=8C=A8=EF=B8=8F=20fix:=20enforce=20typ?=
=?UTF-8?q?e=20safety=20for=20`deps`=20property=20in=20`RegisterOptions`?=
=?UTF-8?q?=20(#11969)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix: enforce type safety for `deps` property in `RegisterOptions`
* refactor: remove unused import in validator.ts
---
reports/api-extractor.md | 2 +-
src/types/validator.ts | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/reports/api-extractor.md b/reports/api-extractor.md
index 9227ca4b..0106d52d 100644
--- a/reports/api-extractor.md
+++ b/reports/api-extractor.md
@@ -486,7 +486,7 @@ export type RegisterOptions void;
onBlur?: (event: any) => void;
disabled: boolean;
- deps: InternalFieldName | InternalFieldName[];
+ deps: FieldPath | FieldPath[];
}> & ({
pattern?: ValidationRule;
valueAsNumber?: false;
diff --git a/src/types/validator.ts b/src/types/validator.ts
index 211a45c9..6c4f744b 100644
--- a/src/types/validator.ts
+++ b/src/types/validator.ts
@@ -1,7 +1,7 @@
import { INPUT_VALIDATION_RULES } from '../constants';
import { Message } from './errors';
-import { FieldValues, InternalFieldName } from './fields';
+import { FieldValues } from './fields';
import { FieldPath, FieldPathValue } from './path';
export type ValidationValue = boolean | number | string | RegExp;
@@ -45,7 +45,7 @@ export type RegisterOptions<
onChange?: (event: any) => void;
onBlur?: (event: any) => void;
disabled: boolean;
- deps: InternalFieldName | InternalFieldName[];
+ deps: FieldPath | FieldPath[];
}> &
(
| {
From ba1cba940d81c5d04548b183956cfd088b95d2d5 Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Sat, 8 Jun 2024 04:10:02 +0200
Subject: [PATCH 21/22] =?UTF-8?q?=F0=9F=90=9E=20fix=20#11985=20logic=20cre?=
=?UTF-8?q?ateFormControl=20check=20field=20before=20usage=20(#11986)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* logic createFormControl check field before usage
* fix linter error
---
src/logic/createFormControl.ts | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/logic/createFormControl.ts b/src/logic/createFormControl.ts
index 6f5af3b6..33e877d6 100644
--- a/src/logic/createFormControl.ts
+++ b/src/logic/createFormControl.ts
@@ -310,7 +310,9 @@ export function createFormControl<
name,
};
const disabledField = !!(
- get(_fields, name) && get(_fields, name)._f.disabled
+ get(_fields, name) &&
+ get(_fields, name)._f &&
+ get(_fields, name)._f.disabled
);
if (!isBlurEvent || shouldDirty) {
From fe2b06941f70e0f4bf14f1e25bffecfced37fe6b Mon Sep 17 00:00:00 2001
From: IntelCore0607
Date: Sat, 8 Jun 2024 15:15:22 +1000
Subject: [PATCH 22/22] =?UTF-8?q?=F0=9F=91=AE=E2=80=8D=E2=99=80=EF=B8=8F?=
=?UTF-8?q?=20close=20#11954=20getFieldState=20remove=20unnessaried=20inVa?=
=?UTF-8?q?lidating=20and=20touched=20subscription=20(#11995)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* 👮♀️ close #11954 getFieldState remove unnessaried inValidating and touched subscription
* revert touched field state
---
src/logic/createFormControl.ts | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/logic/createFormControl.ts b/src/logic/createFormControl.ts
index 33e877d6..ac259f55 100644
--- a/src/logic/createFormControl.ts
+++ b/src/logic/createFormControl.ts
@@ -888,9 +888,9 @@ export function createFormControl<
) => ({
invalid: !!get((formState || _formState).errors, name),
isDirty: !!get((formState || _formState).dirtyFields, name),
- isTouched: !!get((formState || _formState).touchedFields, name),
- isValidating: !!get((formState || _formState).validatingFields, name),
error: get((formState || _formState).errors, name),
+ isValidating: !!get(_formState.validatingFields, name),
+ isTouched: !!get((formState || _formState).touchedFields, name),
});
const clearErrors: UseFormClearErrors = (name) => {