diff --git a/packages/onboarding-ui/package.json b/packages/onboarding-ui/package.json index 5eeab898f7..76e8464595 100644 --- a/packages/onboarding-ui/package.json +++ b/packages/onboarding-ui/package.json @@ -78,7 +78,7 @@ }, "dependencies": { "i18next": "~21.6.16", - "react-hook-form": "~7.27.1" + "react-hook-form": "~7.45.4" }, "peerDependencies": { "@rocket.chat/fuselage": "*", diff --git a/packages/onboarding-ui/src/flows/SelfHostedRegistration/mocks.ts b/packages/onboarding-ui/src/flows/SelfHostedRegistration/mocks.ts index 3d05be746d..b8dee5a091 100644 --- a/packages/onboarding-ui/src/flows/SelfHostedRegistration/mocks.ts +++ b/packages/onboarding-ui/src/flows/SelfHostedRegistration/mocks.ts @@ -1,6 +1,5 @@ import { action } from '@storybook/addon-actions'; import { countries } from 'countries-list'; -import type { Validate } from 'react-hook-form'; export const logSubmit = any>(onSubmit: T) => @@ -40,7 +39,7 @@ export const validateEmail = fetchMock('/email/validate', (email: string) => { return true; }); -export const validatePassword: Validate = (password: string) => { +export const validatePassword = (password: string) => { if (password.length < 6) { return `Password is too short`; } diff --git a/packages/onboarding-ui/src/forms/AdminInfoForm/AdminInfoForm.tsx b/packages/onboarding-ui/src/forms/AdminInfoForm/AdminInfoForm.tsx index b92d73fb37..be8ffe9427 100644 --- a/packages/onboarding-ui/src/forms/AdminInfoForm/AdminInfoForm.tsx +++ b/packages/onboarding-ui/src/forms/AdminInfoForm/AdminInfoForm.tsx @@ -17,7 +17,7 @@ import { useUniqueId } from '@rocket.chat/fuselage-hooks'; import { Form } from '@rocket.chat/layout'; import type { ReactElement } from 'react'; import { useRef, useEffect } from 'react'; -import type { SubmitHandler, Validate } from 'react-hook-form'; +import type { FieldPathValue, SubmitHandler, Validate } from 'react-hook-form'; import { useForm, Controller } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; @@ -35,9 +35,18 @@ type AdminInfoFormProps = { passwordRulesHint: string; keepPosted?: boolean; initialValues?: Omit; - validateUsername: Validate; - validateEmail: Validate; - validatePassword: Validate; + validateUsername: Validate< + FieldPathValue, + AdminInfoPayload + >; + validateEmail: Validate< + FieldPathValue, + AdminInfoPayload + >; + validatePassword: Validate< + FieldPathValue, + AdminInfoPayload + >; onSubmit: SubmitHandler; }; diff --git a/packages/onboarding-ui/src/forms/CreateCloudWorkspaceForm/CreateCloudWorkspaceForm.tsx b/packages/onboarding-ui/src/forms/CreateCloudWorkspaceForm/CreateCloudWorkspaceForm.tsx index f7fc41b95d..f01fc53889 100644 --- a/packages/onboarding-ui/src/forms/CreateCloudWorkspaceForm/CreateCloudWorkspaceForm.tsx +++ b/packages/onboarding-ui/src/forms/CreateCloudWorkspaceForm/CreateCloudWorkspaceForm.tsx @@ -17,7 +17,7 @@ import { } from '@rocket.chat/fuselage'; import { Form } from '@rocket.chat/layout'; import type { ReactElement, FocusEvent } from 'react'; -import type { SubmitHandler, Validate } from 'react-hook-form'; +import type { FieldPathValue, SubmitHandler, Validate } from 'react-hook-form'; import { useForm, Controller } from 'react-hook-form'; import { useTranslation, Trans } from 'react-i18next'; @@ -42,8 +42,14 @@ type CreateCloudWorkspaceFormProps = { languageOptions: SelectOption[]; domain: string; onBackButtonClick?: () => void; - validateUrl: Validate; - validateEmail: Validate; + validateUrl: Validate< + FieldPathValue, + CreateCloudWorkspaceFormPayload + >; + validateEmail: Validate< + FieldPathValue, + CreateCloudWorkspaceFormPayload + >; }; const CreateCloudWorkspaceForm = ({ diff --git a/packages/onboarding-ui/src/forms/CreateFirstMemberForm/CreateFirstMemberForm.tsx b/packages/onboarding-ui/src/forms/CreateFirstMemberForm/CreateFirstMemberForm.tsx index eda2b1b36f..c0c7d25084 100644 --- a/packages/onboarding-ui/src/forms/CreateFirstMemberForm/CreateFirstMemberForm.tsx +++ b/packages/onboarding-ui/src/forms/CreateFirstMemberForm/CreateFirstMemberForm.tsx @@ -13,7 +13,7 @@ import { } from '@rocket.chat/fuselage'; import { Form } from '@rocket.chat/layout'; import type { ReactElement } from 'react'; -import type { SubmitHandler, Validate } from 'react-hook-form'; +import type { FieldPathValue, SubmitHandler, Validate } from 'react-hook-form'; import { useForm } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; @@ -29,8 +29,14 @@ type CreateFirstMemberFormProps = { organizationName: string; onSubmit: SubmitHandler; onBackButtonClick: () => void; - validateUsername: Validate; - validatePassword: Validate; + validateUsername: Validate< + FieldPathValue, + CreateFirstMemberFormPayload + >; + validatePassword: Validate< + FieldPathValue, + CreateFirstMemberFormPayload + >; }; const CreateFirstMemberForm = ({ diff --git a/packages/onboarding-ui/src/forms/CreateNewPassword/CreateNewPassword.tsx b/packages/onboarding-ui/src/forms/CreateNewPassword/CreateNewPassword.tsx index 389a3e18e1..6e7c64b73f 100644 --- a/packages/onboarding-ui/src/forms/CreateNewPassword/CreateNewPassword.tsx +++ b/packages/onboarding-ui/src/forms/CreateNewPassword/CreateNewPassword.tsx @@ -10,7 +10,7 @@ import { } from '@rocket.chat/fuselage'; import { Form } from '@rocket.chat/layout'; import type { ReactElement } from 'react'; -import type { SubmitHandler, Validate } from 'react-hook-form'; +import type { FieldPathValue, SubmitHandler, Validate } from 'react-hook-form'; import { useForm } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; @@ -21,8 +21,14 @@ export type CreateNewPasswordPayload = { type CreateNewPasswordProps = { initialValues?: CreateNewPasswordPayload; - validatePassword: Validate; - validatePasswordConfirmation: Validate; + validatePassword: Validate< + FieldPathValue, + CreateNewPasswordPayload + >; + validatePasswordConfirmation: Validate< + FieldPathValue, + CreateNewPasswordPayload + >; onSubmit: SubmitHandler; }; diff --git a/packages/onboarding-ui/src/forms/NewAccountForm/NewAccountForm.tsx b/packages/onboarding-ui/src/forms/NewAccountForm/NewAccountForm.tsx index e22c05ad6e..bd0a7ec44b 100644 --- a/packages/onboarding-ui/src/forms/NewAccountForm/NewAccountForm.tsx +++ b/packages/onboarding-ui/src/forms/NewAccountForm/NewAccountForm.tsx @@ -15,7 +15,7 @@ import { import { Form } from '@rocket.chat/layout'; import type { ReactElement } from 'react'; import { useEffect } from 'react'; -import type { SubmitHandler, Validate } from 'react-hook-form'; +import type { FieldPathValue, SubmitHandler, Validate } from 'react-hook-form'; import { useForm } from 'react-hook-form'; import { Trans, useTranslation } from 'react-i18next'; @@ -29,9 +29,18 @@ export type NewAccountPayload = { type NewAccountFormProps = { initialValues?: Omit; - validateEmail: Validate; - validatePassword: Validate; - validateConfirmationPassword: Validate; + validateEmail: Validate< + FieldPathValue, + NewAccountPayload + >; + validatePassword: Validate< + FieldPathValue, + NewAccountPayload + >; + validateConfirmationPassword: Validate< + FieldPathValue, + NewAccountPayload + >; onSubmit: SubmitHandler; }; diff --git a/packages/onboarding-ui/src/forms/RegisterServerForm/RegisterServerForm.tsx b/packages/onboarding-ui/src/forms/RegisterServerForm/RegisterServerForm.tsx index 968f335969..b679fd5ef3 100644 --- a/packages/onboarding-ui/src/forms/RegisterServerForm/RegisterServerForm.tsx +++ b/packages/onboarding-ui/src/forms/RegisterServerForm/RegisterServerForm.tsx @@ -13,7 +13,7 @@ import { useUniqueId, useBreakpoints } from '@rocket.chat/fuselage-hooks'; import { Form } from '@rocket.chat/layout'; import type { ReactElement } from 'react'; import { useEffect, useRef } from 'react'; -import type { SubmitHandler, Validate } from 'react-hook-form'; +import type { FieldPathValue, SubmitHandler, Validate } from 'react-hook-form'; import { Controller, useForm, FormProvider } from 'react-hook-form'; import { useTranslation, Trans } from 'react-i18next'; @@ -29,7 +29,10 @@ type RegisterServerFormProps = { currentStep: number; stepCount: number; initialValues?: Partial; - validateEmail?: Validate; + validateEmail?: Validate< + FieldPathValue, + RegisterServerPayload + >; onSubmit: SubmitHandler; onClickRegisterOffline: () => void; termsHref?: string; diff --git a/packages/onboarding-ui/src/forms/RequestTrialForm/RequestTrialForm.tsx b/packages/onboarding-ui/src/forms/RequestTrialForm/RequestTrialForm.tsx index 6fe012d21f..debf0be782 100644 --- a/packages/onboarding-ui/src/forms/RequestTrialForm/RequestTrialForm.tsx +++ b/packages/onboarding-ui/src/forms/RequestTrialForm/RequestTrialForm.tsx @@ -16,7 +16,7 @@ import { } from '@rocket.chat/fuselage'; import { Form } from '@rocket.chat/layout'; import type { ReactElement } from 'react'; -import type { SubmitHandler, Validate } from 'react-hook-form'; +import type { FieldPathValue, SubmitHandler, Validate } from 'react-hook-form'; import { useForm, Controller } from 'react-hook-form'; import { useTranslation, Trans } from 'react-i18next'; @@ -35,7 +35,10 @@ type RequestTrialFormProps = { countryOptions: SelectOption[]; onSubmit: SubmitHandler; onManageWorkspaceClick: () => void; - validateEmail: Validate; + validateEmail: Validate< + FieldPathValue, + RequestTrialPayload + >; termsHref?: string; policyHref?: string; }; diff --git a/packages/onboarding-ui/src/forms/ResetPasswordForm/ResetPasswordForm.tsx b/packages/onboarding-ui/src/forms/ResetPasswordForm/ResetPasswordForm.tsx index aa08caf461..3c6fc15b7f 100644 --- a/packages/onboarding-ui/src/forms/ResetPasswordForm/ResetPasswordForm.tsx +++ b/packages/onboarding-ui/src/forms/ResetPasswordForm/ResetPasswordForm.tsx @@ -11,7 +11,7 @@ import { } from '@rocket.chat/fuselage'; import { Form } from '@rocket.chat/layout'; import type { ReactElement } from 'react'; -import type { SubmitHandler, Validate } from 'react-hook-form'; +import type { FieldPathValue, SubmitHandler, Validate } from 'react-hook-form'; import { useForm } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; @@ -21,7 +21,10 @@ export type ResetPasswordFormPayload = { type ResetPasswordFormProps = { initialValues?: ResetPasswordFormPayload; - validateEmail: Validate; + validateEmail: Validate< + FieldPathValue, + ResetPasswordFormPayload + >; onSubmit: SubmitHandler; }; diff --git a/packages/onboarding-ui/src/pages/AdminInfoPage/AdminInfoPage.tsx b/packages/onboarding-ui/src/pages/AdminInfoPage/AdminInfoPage.tsx index 796e0f5b43..a8d58c8241 100644 --- a/packages/onboarding-ui/src/pages/AdminInfoPage/AdminInfoPage.tsx +++ b/packages/onboarding-ui/src/pages/AdminInfoPage/AdminInfoPage.tsx @@ -1,6 +1,6 @@ import { BackgroundLayer } from '@rocket.chat/layout'; import type { ReactElement, ReactNode } from 'react'; -import type { SubmitHandler, Validate } from 'react-hook-form'; +import type { FieldPathValue, SubmitHandler, Validate } from 'react-hook-form'; import type { FormPageLayoutStyleProps } from '../../Types'; import FormPageLayout from '../../common/FormPageLayout'; @@ -15,9 +15,18 @@ type AdminInfoPageProps = { passwordRulesHint: string; keepPosted?: boolean; initialValues?: Omit; - validateUsername: Validate; - validateEmail: Validate; - validatePassword: Validate; + validateUsername: Validate< + FieldPathValue, + AdminInfoPayload + >; + validateEmail: Validate< + FieldPathValue, + AdminInfoPayload + >; + validatePassword: Validate< + FieldPathValue, + AdminInfoPayload + >; onSubmit: SubmitHandler; }; diff --git a/packages/onboarding-ui/src/pages/CreateNewAccountPage/CreateNewAccountPage.tsx b/packages/onboarding-ui/src/pages/CreateNewAccountPage/CreateNewAccountPage.tsx index 0c039a9a14..4d556b610d 100644 --- a/packages/onboarding-ui/src/pages/CreateNewAccountPage/CreateNewAccountPage.tsx +++ b/packages/onboarding-ui/src/pages/CreateNewAccountPage/CreateNewAccountPage.tsx @@ -6,7 +6,7 @@ import { VerticalWizardLayoutTitle, } from '@rocket.chat/layout'; import type { ReactElement } from 'react'; -import type { SubmitHandler, Validate } from 'react-hook-form'; +import type { FieldPathValue, SubmitHandler, Validate } from 'react-hook-form'; import { Trans, useTranslation } from 'react-i18next'; import NewAccountForm from '../../forms/NewAccountForm'; @@ -14,9 +14,18 @@ import type { NewAccountPayload } from '../../forms/NewAccountForm/NewAccountFor type CreateNewAccountPageProps = { initialValues?: Omit; - validateEmail: Validate; - validatePassword: Validate; - validateConfirmationPassword: Validate; + validateEmail: Validate< + FieldPathValue, + NewAccountPayload + >; + validatePassword: Validate< + FieldPathValue, + NewAccountPayload + >; + validateConfirmationPassword: Validate< + FieldPathValue, + NewAccountPayload + >; onSubmit: SubmitHandler; onLogin: () => void; }; diff --git a/packages/onboarding-ui/src/pages/CreateNewPasswordPage/CreateNewPasswordPage.tsx b/packages/onboarding-ui/src/pages/CreateNewPasswordPage/CreateNewPasswordPage.tsx index 6d1b032eb3..f953d7553e 100644 --- a/packages/onboarding-ui/src/pages/CreateNewPasswordPage/CreateNewPasswordPage.tsx +++ b/packages/onboarding-ui/src/pages/CreateNewPasswordPage/CreateNewPasswordPage.tsx @@ -1,7 +1,7 @@ import { Box } from '@rocket.chat/fuselage'; import { ActionLink } from '@rocket.chat/layout'; import type { ReactElement } from 'react'; -import type { SubmitHandler, Validate } from 'react-hook-form'; +import type { FieldPathValue, SubmitHandler, Validate } from 'react-hook-form'; import { Trans, useTranslation } from 'react-i18next'; import type { FormPageLayoutStyleProps } from '../../Types'; @@ -11,8 +11,14 @@ import type { CreateNewPasswordPayload } from '../../forms/CreateNewPassword/Cre type CreateNewPasswordPageProps = { initialValues?: CreateNewPasswordPayload; - validatePassword: Validate; - validatePasswordConfirmation: Validate; + validatePassword: Validate< + FieldPathValue, + CreateNewPasswordPayload + >; + validatePasswordConfirmation: Validate< + FieldPathValue, + CreateNewPasswordPayload + >; onSubmit: SubmitHandler; onLogin: () => void; }; diff --git a/packages/onboarding-ui/src/pages/RegisterServerPage/RegisterServerPage.tsx b/packages/onboarding-ui/src/pages/RegisterServerPage/RegisterServerPage.tsx index adc88d3f12..97c5d9b4f7 100644 --- a/packages/onboarding-ui/src/pages/RegisterServerPage/RegisterServerPage.tsx +++ b/packages/onboarding-ui/src/pages/RegisterServerPage/RegisterServerPage.tsx @@ -1,6 +1,6 @@ import { BackgroundLayer } from '@rocket.chat/layout'; import type { ReactElement } from 'react'; -import type { SubmitHandler, Validate } from 'react-hook-form'; +import type { FieldPathValue, SubmitHandler, Validate } from 'react-hook-form'; import type { FormPageLayoutStyleProps } from '../../Types'; import FormPageLayout from '../../common/FormPageLayout'; @@ -14,7 +14,10 @@ type RegisterServerPageProps = { onSubmit: SubmitHandler; onClickRegisterOffline: () => void; offline?: boolean; - validateEmail?: Validate; + validateEmail?: Validate< + FieldPathValue, + RegisterServerPayload + >; termsHref?: string; policyHref?: string; }; diff --git a/packages/onboarding-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx b/packages/onboarding-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx index 1eb53f6565..cf1073b968 100644 --- a/packages/onboarding-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx +++ b/packages/onboarding-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx @@ -1,7 +1,7 @@ import { Box } from '@rocket.chat/fuselage'; import { ActionLink, BackgroundLayer } from '@rocket.chat/layout'; import type { ReactElement } from 'react'; -import type { SubmitHandler, Validate } from 'react-hook-form'; +import type { FieldPathValue, SubmitHandler, Validate } from 'react-hook-form'; import { Trans, useTranslation } from 'react-i18next'; import type { FormPageLayoutStyleProps } from '../../Types'; @@ -11,7 +11,10 @@ import type { ResetPasswordFormPayload } from '../../forms/ResetPasswordForm/Res type ResetPasswordPageProps = { initialValues?: ResetPasswordFormPayload; - validateEmail: Validate; + validateEmail: Validate< + FieldPathValue, + ResetPasswordFormPayload + >; onSubmit: SubmitHandler; onLogin: () => void; }; diff --git a/yarn.lock b/yarn.lock index 55c38155a5..61b17c6c06 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4697,7 +4697,7 @@ __metadata: prettier: "npm:~3.3.3" react: "npm:~18.3.1" react-dom: "npm:~18.3.1" - react-hook-form: "npm:~7.27.1" + react-hook-form: "npm:~7.45.4" react-i18next: "npm:~13.2.2" rimraf: "npm:^3.0.2" storybook: "npm:~8.4.7" @@ -16403,12 +16403,12 @@ __metadata: languageName: node linkType: hard -"react-hook-form@npm:~7.27.1": - version: 7.27.1 - resolution: "react-hook-form@npm:7.27.1" +"react-hook-form@npm:~7.45.4": + version: 7.45.4 + resolution: "react-hook-form@npm:7.45.4" peerDependencies: - react: ^16.8.0 || ^17 - checksum: 10/fa22f39e7eb157e7fc71ef132a9ffc3680f51d5642529542f5ab9229d6f7064aacbfbcbcd9bcf180a929a58f9a9b85f38b69492b8790407b87dc011bbce5f06e + react: ^16.8.0 || ^17 || ^18 + checksum: 10/499d51c758161081fab0d22e7720e33e45d678fc2c8af2ff939434a61fab7043624c35afdfa27fa93fdc17d50a9683deb8b39bf308643f71b32126e561270641 languageName: node linkType: hard