From 07be73bafa3e57de14cf15f61e68cfb9969d6ec7 Mon Sep 17 00:00:00 2001 From: Sebastien Romain Date: Fri, 20 Oct 2023 16:54:18 +0200 Subject: [PATCH 01/20] deps: bump react-hook-form to 7.X --- packages/design-docs/package.json | 2 +- packages/forms/package.json | 2 +- packages/stepper/src/stories/Stepper.components.tsx | 12 ++++++------ packages/storybook-one/package.json | 2 +- yarn.lock | 8 ++++---- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/design-docs/package.json b/packages/design-docs/package.json index 5f38cebca52..0ce550566c8 100644 --- a/packages/design-docs/package.json +++ b/packages/design-docs/package.json @@ -31,7 +31,7 @@ "classnames": "^2.3.1", "color-contrast-checker": "^2.1.0", "figma-js": "^1.16.0", - "react-hook-form": "^6.15.8", + "react-hook-form": "^7.47.0", "react": "^17.0.2", "react-dom": "^17.0.2", "use-overflow": "^1.2.0" diff --git a/packages/forms/package.json b/packages/forms/package.json index b0ba146a647..5440a6616c3 100644 --- a/packages/forms/package.json +++ b/packages/forms/package.json @@ -51,7 +51,7 @@ "react-autowhatever": "10.2.0", "@talend/react-bootstrap": "^1.35.2", "react-ace": "10.1.0", - "react-hook-form": "^6.15.8", + "react-hook-form": "^7.47.0", "react-jsonschema-form": "0.51.0", "tv4": "^1.3.0" }, diff --git a/packages/stepper/src/stories/Stepper.components.tsx b/packages/stepper/src/stories/Stepper.components.tsx index 3d2122e370c..3e48138a684 100644 --- a/packages/stepper/src/stories/Stepper.components.tsx +++ b/packages/stepper/src/stories/Stepper.components.tsx @@ -20,7 +20,7 @@ export const FormComponentStep1 = () => { defaultValues: { ...stepsData[0] }, }); - const { field, meta } = useController({ + const { field, fieldState } = useController({ control: rhf.control, name: 'randomInput', rules: { @@ -63,7 +63,7 @@ export const FormComponentStep1 = () => { }} /> - {meta.invalid && ( + {fieldState.invalid && ( )} { defaultValues: { ...stepsData[1] }, }); - const { field, meta } = useController({ + const { field, fieldState } = useController({ control: rhf.control, name: 'randomInput', rules: { @@ -124,7 +124,7 @@ export const FormComponentStep2 = () => { }} /> - {meta.invalid && ( + {fieldState.invalid && ( )} { defaultValues: { ...stepsData[2] }, }); - const { field, meta } = useController({ + const { field, fieldState } = useController({ control: rhf.control, name: 'randomInput', rules: { @@ -171,7 +171,7 @@ export const FormComponentStep3 = () => {
- {meta.invalid && ( + {fieldState.invalid && ( )} Date: Fri, 20 Oct 2023 16:54:55 +0200 Subject: [PATCH 02/20] add changeset --- .changeset/lovely-chefs-remain.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/lovely-chefs-remain.md diff --git a/.changeset/lovely-chefs-remain.md b/.changeset/lovely-chefs-remain.md new file mode 100644 index 00000000000..6cb41ceabe3 --- /dev/null +++ b/.changeset/lovely-chefs-remain.md @@ -0,0 +1,7 @@ +--- +'@talend/design-docs': minor +'@talend/react-stepper': minor +'@talend/react-forms': minor +--- + +deps: bump react-hook-form to 7.X From a03bb9a0e6ccee2fcca4da97dccb7afc4a4ca542 Mon Sep 17 00:00:00 2001 From: Sebastien Romain Date: Mon, 23 Oct 2023 10:49:25 +0200 Subject: [PATCH 03/20] migrate component :) --- packages/forms/src/rhf/fields/Input/RHFInput.component.js | 5 +++-- packages/forms/src/rhf/fields/Select/RHFSelect.component.js | 5 +++-- .../forms/src/rhf/fields/TextArea/RHFTextArea.component.js | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/forms/src/rhf/fields/Input/RHFInput.component.js b/packages/forms/src/rhf/fields/Input/RHFInput.component.js index 443d54df9da..489c3cd5fff 100644 --- a/packages/forms/src/rhf/fields/Input/RHFInput.component.js +++ b/packages/forms/src/rhf/fields/Input/RHFInput.component.js @@ -5,15 +5,16 @@ import get from 'lodash/get'; import Input from '../../../widgets/fields/Input'; function RHFInput(props) { - const { rules = {}, ...rest } = props; + const { rules = {}, name = '', ...rest } = props; const { errors, register } = useFormContext(); const error = get(errors, rest.name)?.message; - return ; + return ; } if (process.env.NODE_ENV !== 'production') { RHFInput.propTypes = { rules: PropTypes.object, + name: PropTypes.string, }; } diff --git a/packages/forms/src/rhf/fields/Select/RHFSelect.component.js b/packages/forms/src/rhf/fields/Select/RHFSelect.component.js index e71d9ec4f60..52f93b6d9af 100644 --- a/packages/forms/src/rhf/fields/Select/RHFSelect.component.js +++ b/packages/forms/src/rhf/fields/Select/RHFSelect.component.js @@ -5,15 +5,16 @@ import get from 'lodash/get'; import Select from '../../../widgets/fields/Select'; function RHFSelect(props) { - const { rules = {}, ...rest } = props; + const { rules = {}, name = '', ...rest } = props; const { errors, register } = useFormContext(); const error = get(errors, rest.name)?.message; - return ; } if (process.env.NODE_ENV !== 'production') { RHFSelect.propTypes = { rules: PropTypes.object, + name: PropTypes.string, }; } diff --git a/packages/forms/src/rhf/fields/TextArea/RHFTextArea.component.js b/packages/forms/src/rhf/fields/TextArea/RHFTextArea.component.js index 558a6d13879..71037c1d2dd 100644 --- a/packages/forms/src/rhf/fields/TextArea/RHFTextArea.component.js +++ b/packages/forms/src/rhf/fields/TextArea/RHFTextArea.component.js @@ -5,15 +5,16 @@ import get from 'lodash/get'; import TextArea from '../../../widgets/fields/TextArea'; function RHFTextArea(props) { - const { rules = {}, ...rest } = props; + const { rules = {}, name = '', ...rest } = props; const { errors, register } = useFormContext(); const error = get(errors, rest.name)?.message; - return