import React, { useState, memo } from "react"; import DefaultTemplate from "./Template"; import type { TemplateProps } from "./Template"; import type { KcProps } from "./KcProps"; import type { KcContextBase } from "../getKcContext/KcContextBase"; import { useCssAndCx } from "../tools/useCssAndCx"; import { useConstCallback } from "powerhooks/useConstCallback"; import type { FormEventHandler } from "react"; import type { I18n } from "../i18n"; export type LoginPasswordProps = KcProps & { kcContext: KcContextBase.LoginPassword; i18n: I18n; doFetchDefaultThemeResources?: boolean; Template?: (props: TemplateProps) => JSX.Element | null; }; const LoginPassword = memo((props: LoginPasswordProps) => { const { kcContext, i18n, doFetchDefaultThemeResources = true, Template = DefaultTemplate, ...kcProps } = props; const { realm, url, login } = kcContext; const { msg, msgStr } = i18n; const { cx } = useCssAndCx(); const [isLoginButtonDisabled, setIsLoginButtonDisabled] = useState(false); const onSubmit = useConstCallback>(e => { e.preventDefault(); setIsLoginButtonDisabled(true); const formElement = e.target as HTMLFormElement; formElement.submit(); }); return (