diff --git a/src/login/UserProfileFormFields.tsx b/src/login/UserProfileFormFields.tsx index fba7b571..04ad8dd4 100644 --- a/src/login/UserProfileFormFields.tsx +++ b/src/login/UserProfileFormFields.tsx @@ -4,33 +4,15 @@ import type { KcClsx } from "keycloakify/login/lib/kcClsx"; import { useUserProfileForm, getButtonToDisplayForMultivaluedAttributeField, - type KcContextLike, type FormAction, type FormFieldError } from "keycloakify/login/lib/useUserProfileForm"; +import type { UserProfileFormFieldsProps } from "keycloakify/login/UserProfileFormFieldsProps"; import type { Attribute } from "keycloakify/login/KcContext"; +import type { KcContext } from "./KcContext"; import type { I18n } from "./i18n"; -export type UserProfileFormFieldsProps = { - kcContext: KcContextLike; - i18n: I18n; - kcClsx: KcClsx; - onIsFormSubmittableValueChange: (isFormSubmittable: boolean) => void; - doMakeUserConfirmPassword: boolean; - BeforeField?: (props: BeforeAfterFieldProps) => JSX.Element | null; - AfterField?: (props: BeforeAfterFieldProps) => JSX.Element | null; -}; - -type BeforeAfterFieldProps = { - attribute: Attribute; - dispatchFormAction: React.Dispatch; - displayableErrors: FormFieldError[]; - valueOrValues: string | string[]; - kcClsx: KcClsx; - i18n: I18n; -}; - -export default function UserProfileFormFields(props: UserProfileFormFieldsProps) { +export default function UserProfileFormFields(props: UserProfileFormFieldsProps) { const { kcContext, i18n, kcClsx, onIsFormSubmittableValueChange, doMakeUserConfirmPassword, BeforeField, AfterField } = props; const { advancedMsg } = i18n; diff --git a/src/login/UserProfileFormFieldsProps.tsx b/src/login/UserProfileFormFieldsProps.tsx new file mode 100644 index 00000000..20c9e0b0 --- /dev/null +++ b/src/login/UserProfileFormFieldsProps.tsx @@ -0,0 +1,22 @@ +import { type FormAction, type FormFieldError } from "keycloakify/login/lib/useUserProfileForm"; +import type { KcClsx } from "keycloakify/login/lib/kcClsx"; +import type { Attribute } from "keycloakify/login/KcContext"; + +export type UserProfileFormFieldsProps = { + kcContext: Extract; + i18n: I18n; + kcClsx: KcClsx; + onIsFormSubmittableValueChange: (isFormSubmittable: boolean) => void; + doMakeUserConfirmPassword: boolean; + BeforeField?: (props: BeforeAfterFieldProps) => JSX.Element | null; + AfterField?: (props: BeforeAfterFieldProps) => JSX.Element | null; +}; + +type BeforeAfterFieldProps = { + attribute: Attribute; + dispatchFormAction: React.Dispatch; + displayableErrors: FormFieldError[]; + valueOrValues: string | string[]; + kcClsx: KcClsx; + i18n: I18n; +}; diff --git a/src/login/lib/useUserProfileForm.tsx b/src/login/lib/useUserProfileForm.tsx index d577fed9..bb003e9c 100644 --- a/src/login/lib/useUserProfileForm.tsx +++ b/src/login/lib/useUserProfileForm.tsx @@ -79,9 +79,9 @@ export type KcContextLike = KcContextLike_i18n & }; }; -assert extends KcContextLike ? true : false>(); +assert, { pageId: "register.ftl" }> extends KcContextLike ? true : false>(); -export type ParamsOfUseUserProfileForm = { +export type UseUserProfileFormParams = { kcContext: KcContextLike; i18n: I18n; doMakeUserConfirmPassword: boolean; @@ -105,7 +105,7 @@ namespace internal { }; } -export function useUserProfileForm(params: ParamsOfUseUserProfileForm): ReturnTypeOfUseUserProfileForm { +export function useUserProfileForm(params: UseUserProfileFormParams): ReturnTypeOfUseUserProfileForm { const { kcContext, i18n, doMakeUserConfirmPassword } = params; const { insertScriptTags } = useInsertScriptTags({