import React, { useState, memo } from "react"; import Template 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"; const LoginPassword = memo( ({ kcContext, i18n, doFetchDefaultThemeResources = true, ...props }: { kcContext: KcContextBase.LoginPassword; i18n: I18n; doFetchDefaultThemeResources?: boolean } & KcProps) => { 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 (