// Copy pasted from: https://github.com/InseeFrLab/keycloakify/blob/main/src/lib/components/shared/Template.tsx // You can replace all relative imports by cherry picking files from the keycloakify module. // For example, the following import: // import { assert } from "./tools/assert"; // becomes: import { assert } from "keycloakify/lib/tools/assert"; import { clsx } from "keycloakify/lib/tools/clsx"; import type { TemplateProps } from "keycloakify/lib/KcProps"; import { usePrepareTemplate } from "keycloakify/lib/Template"; import type { KcContext } from "./kcContext"; import type { I18n } from "./i18n"; export default function Template(props: TemplateProps) { const { displayInfo = false, displayMessage = true, displayRequiredFields = false, displayWide = false, showAnotherWayIfPresent = true, headerNode, showUsernameNode = null, formNode, infoNode = null, kcContext, i18n, doFetchDefaultThemeResources, stylesCommon, styles, scripts, kcHtmlClass } = props; const { msg, changeLocale, labelBySupportedLanguageTag, currentLanguageTag } = i18n; const { realm, locale, auth, url, message, isAppInitiatedAction } = kcContext; const { isReady } = usePrepareTemplate({ doFetchDefaultThemeResources, stylesCommon, styles, scripts, url, kcHtmlClass }); if (!isReady) { return null; } return (
{msg("loginTitleHtml", realm.displayNameHtml)}
{realm.internationalizationEnabled && (assert(locale !== undefined), true) && locale.supported.length > 1 && (
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */} {labelBySupportedLanguageTag[currentLanguageTag]}
)} {!(auth !== undefined && auth.showUsername && !auth.showResetCredentials) ? ( displayRequiredFields ? (
* {msg("requiredFields")}

{headerNode}

) : (

{headerNode}

) ) : displayRequiredFields ? (
* {msg("requiredFields")}
{showUsernameNode}
{msg("restartLoginTooltip")}
) : ( <> {showUsernameNode}
{msg("restartLoginTooltip")}
)}
{/* App-initiated actions should not see warning messages about the need to complete the action during login. */} {displayMessage && message !== undefined && (message.type !== "warning" || !isAppInitiatedAction) && (
{message.type === "success" && } {message.type === "warning" && } {message.type === "error" && } {message.type === "info" && }
)} {formNode} {auth !== undefined && auth.showTryAnotherWayLink && showAnotherWayIfPresent && (
)} {displayInfo && (
{infoNode}
)}
); }