Extract Props from UserProfileFormFields so it's ejectable
This commit is contained in:
parent
8b5f7eefda
commit
ffb27fc66d
@ -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<FormAction>;
|
||||
displayableErrors: FormFieldError[];
|
||||
valueOrValues: string | string[];
|
||||
kcClsx: KcClsx;
|
||||
i18n: I18n;
|
||||
};
|
||||
|
||||
export default function UserProfileFormFields(props: UserProfileFormFieldsProps) {
|
||||
export default function UserProfileFormFields(props: UserProfileFormFieldsProps<KcContext, I18n>) {
|
||||
const { kcContext, i18n, kcClsx, onIsFormSubmittableValueChange, doMakeUserConfirmPassword, BeforeField, AfterField } = props;
|
||||
|
||||
const { advancedMsg } = i18n;
|
||||
|
22
src/login/UserProfileFormFieldsProps.tsx
Normal file
22
src/login/UserProfileFormFieldsProps.tsx
Normal file
@ -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, I18n> = {
|
||||
kcContext: Extract<KcContext, { profile: unknown }>;
|
||||
i18n: I18n;
|
||||
kcClsx: KcClsx;
|
||||
onIsFormSubmittableValueChange: (isFormSubmittable: boolean) => void;
|
||||
doMakeUserConfirmPassword: boolean;
|
||||
BeforeField?: (props: BeforeAfterFieldProps<I18n>) => JSX.Element | null;
|
||||
AfterField?: (props: BeforeAfterFieldProps<I18n>) => JSX.Element | null;
|
||||
};
|
||||
|
||||
type BeforeAfterFieldProps<I18n> = {
|
||||
attribute: Attribute;
|
||||
dispatchFormAction: React.Dispatch<FormAction>;
|
||||
displayableErrors: FormFieldError[];
|
||||
valueOrValues: string | string[];
|
||||
kcClsx: KcClsx;
|
||||
i18n: I18n;
|
||||
};
|
@ -79,9 +79,9 @@ export type KcContextLike = KcContextLike_i18n &
|
||||
};
|
||||
};
|
||||
|
||||
assert<Extract<KcContext.Register, { pageId: "register.ftl" }> extends KcContextLike ? true : false>();
|
||||
assert<Extract<Extract<KcContext, { profile: unknown }>, { 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({
|
||||
|
Loading…
x
Reference in New Issue
Block a user