This commit is contained in:
Joseph Garrone 2024-06-09 10:24:14 +02:00
parent 5a42b618bd
commit b6159180ea
10 changed files with 83 additions and 59 deletions

View file

@ -18,7 +18,7 @@
"license": "MIT",
"keywords": [],
"dependencies": {
"keycloakify": "10.0.0-rc.37",
"keycloakify": "10.0.0-rc.40",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},

View file

@ -1,21 +1,12 @@
import { Suspense, lazy } from "react";
import { Suspense } from "react";
import type { ClassKey } from "keycloakify/account";
import type { KcContext } from "./KcContext";
import { useI18n } from "./i18n";
import Fallback from "keycloakify/account/Fallback";
import Template from "keycloakify/account/Template";
const Fallback = lazy(() => import("keycloakify/account/Fallback"));
const classes = {} satisfies { [key in ClassKey]?: string };
export default function KcApp(props: { kcContext: KcContext }) {
const { kcContext } = props;
const i18n = useI18n({ kcContext });
if (i18n === null) {
return null;
}
return (
<Suspense>
{(() => {
@ -23,12 +14,9 @@ export default function KcApp(props: { kcContext: KcContext }) {
default:
return (
<Fallback
{...{
kcContext,
i18n,
classes,
Template
}}
kcContext={kcContext}
classes={classes}
Template={Template}
doUseDefaultCss={true}
/>
);
@ -37,3 +25,5 @@ export default function KcApp(props: { kcContext: KcContext }) {
</Suspense>
);
}
const classes = {} satisfies { [key in ClassKey]?: string };

View file

@ -1,11 +1,15 @@
/* eslint-disable @typescript-eslint/ban-types */
import type { ExtendKcContext } from "keycloakify/account";
import type { KcEnvName, ThemeName } from "../kc.gen";
export type KcContextExtraProperties = {};
export type KcContextExtension = {
themeName: ThemeName;
properties: Record<KcEnvName, string> & {};
};
export type KcContextExtraPropertiesPerPage = {};
export type KcContextExtensionPerPage = {};
export type KcContext = ExtendKcContext<
KcContextExtraProperties,
KcContextExtraPropertiesPerPage
KcContextExtension,
KcContextExtensionPerPage
>;

View file

@ -2,17 +2,23 @@ import type { DeepPartial } from "keycloakify/tools/DeepPartial";
import type { KcContext } from "./KcContext";
import { createGetKcContextMock } from "keycloakify/account/KcContext";
import type {
KcContextExtraProperties,
KcContextExtraPropertiesPerPage
KcContextExtension,
KcContextExtensionPerPage
} from "./KcContext";
import KcApp from "./KcApp";
import { themeNames, kcEnvDefaults } from "../kc.gen";
const kcContextExtraProperties: KcContextExtraProperties = {};
const kcContextExtraPropertiesPerPage: KcContextExtraPropertiesPerPage = {};
const kcContextExtension: KcContextExtension = {
themeName: themeNames[0],
properties: {
...kcEnvDefaults
}
};
const kcContextExtensionPerPage: KcContextExtensionPerPage = {};
export const { getKcContextMock } = createGetKcContextMock({
kcContextExtraProperties,
kcContextExtraPropertiesPerPage,
kcContextExtension,
kcContextExtensionPerPage,
overrides: {},
overridesPerPage: {}
});

21
src/kc.gen.ts Normal file
View file

@ -0,0 +1,21 @@
/* prettier-ignore-start */
/* eslint-disable */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
// This file is auto-generated by Keycloakify
export type ThemeName = "keycloakify-starter";
export const themeNames: ThemeName[] = ["keycloakify-starter"];
export type KcEnvName = never;
export const KcEnvNames: KcEnvName[] = [];
export const kcEnvDefaults: Record<KcEnvName, string> = {};
/* prettier-ignore-end */

View file

@ -1,19 +1,16 @@
import { Suspense, lazy } from "react";
import type { ClassKey } from "keycloakify/login";
import type { KcContext } from "./KcContext";
import { useI18n } from "./i18n";
import { useDownloadTerms } from "keycloakify/login";
import Fallback from "keycloakify/login/Fallback";
import Template from "keycloakify/login/Template";
const Fallback = lazy(() => import("keycloakify/login/Fallback"));
const UserProfileFormFields = lazy(() => import("keycloakify/login/UserProfileFormFields"));
const classes = {} satisfies { [key in ClassKey]?: string };
const doMakeUserConfirmPassword = true;
export default function KcApp(props: { kcContext: KcContext }) {
const { kcContext } = props;
const i18n = useI18n({ kcContext });
useDownloadTerms({
kcContext,
downloadTermsMarkdown: async ({ currentLanguageTag }) => {
@ -39,10 +36,6 @@ export default function KcApp(props: { kcContext: KcContext }) {
}
});
if (i18n === null) {
return null;
}
return (
<Suspense>
{(() => {
@ -50,14 +43,12 @@ export default function KcApp(props: { kcContext: KcContext }) {
default:
return (
<Fallback
{...{
kcContext,
i18n,
classes,
Template,
UserProfileFormFields
}}
kcContext={kcContext}
classes={classes}
Template={Template}
doUseDefaultCss={true}
UserProfileFormFields={UserProfileFormFields}
doMakeUserConfirmPassword={doMakeUserConfirmPassword}
/>
);
}
@ -65,3 +56,5 @@ export default function KcApp(props: { kcContext: KcContext }) {
</Suspense>
);
}
const classes = {} satisfies { [key in ClassKey]?: string };

View file

@ -1,11 +1,15 @@
/* eslint-disable @typescript-eslint/ban-types */
import type { ExtendKcContext } from "keycloakify/login";
import type { KcEnvName, ThemeName } from "../kc.gen";
export type KcContextExtraProperties = {};
export type KcContextExtension = {
themeName: ThemeName;
properties: Record<KcEnvName, string> & {};
};
export type KcContextExtraPropertiesPerPage = {};
export type KcContextExtensionPerPage = {};
export type KcContext = ExtendKcContext<
KcContextExtraProperties,
KcContextExtraPropertiesPerPage
KcContextExtension,
KcContextExtensionPerPage
>;

View file

@ -3,16 +3,22 @@ import type { KcContext } from "./KcContext";
import KcApp from "./KcApp";
import { createGetKcContextMock } from "keycloakify/login/KcContext";
import type {
KcContextExtraProperties,
KcContextExtraPropertiesPerPage
KcContextExtension,
KcContextExtensionPerPage
} from "./KcContext";
import { themeNames, kcEnvDefaults } from "../kc.gen";
const kcContextExtraProperties: KcContextExtraProperties = {};
const kcContextExtraPropertiesPerPage: KcContextExtraPropertiesPerPage = {};
const kcContextExtension: KcContextExtension = {
themeName: themeNames[0],
properties: {
...kcEnvDefaults
}
};
const kcContextExtensionPerPage: KcContextExtensionPerPage = {};
export const { getKcContextMock } = createGetKcContextMock({
kcContextExtraProperties,
kcContextExtraPropertiesPerPage,
kcContextExtension,
kcContextExtensionPerPage,
overrides: {},
overridesPerPage: {}
});

View file

@ -4,7 +4,7 @@ import { keycloakify } from "keycloakify/vite-plugin";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), keycloakify()],
plugins: [react(), keycloakify({})],
build: {
sourcemap: true
}

View file

@ -5011,10 +5011,10 @@ jsonfile@^6.0.1:
optionalDependencies:
graceful-fs "^4.1.6"
keycloakify@10.0.0-rc.37:
version "10.0.0-rc.37"
resolved "https://registry.yarnpkg.com/keycloakify/-/keycloakify-10.0.0-rc.37.tgz#30481c94c8f8404ab3e9c30da43088096a44f98a"
integrity sha512-FBNxMijjDzdm564Gs68J8BYGY6fHUkB7Ipo6nASONKNZZY32e6f7JYLFg3o/r0hagoebriSSWs+LkjtgPhGKFA==
keycloakify@10.0.0-rc.40:
version "10.0.0-rc.40"
resolved "https://registry.yarnpkg.com/keycloakify/-/keycloakify-10.0.0-rc.40.tgz#f383e72b4981da1973d09c6211103fdbd2efa818"
integrity sha512-JL3UJAAunCfZSw0JOMv/B9BD75jnOiLjxIIbbs/Gj+Djg9Db+w2kg5N11Q5/EIxkQRRCdFSVIII3NgZ7EQevcw==
dependencies:
react-markdown "^5.0.3"
tsafe "^1.6.6"