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", "license": "MIT",
"keywords": [], "keywords": [],
"dependencies": { "dependencies": {
"keycloakify": "10.0.0-rc.37", "keycloakify": "10.0.0-rc.40",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^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 { ClassKey } from "keycloakify/account";
import type { KcContext } from "./KcContext"; import type { KcContext } from "./KcContext";
import { useI18n } from "./i18n"; import Fallback from "keycloakify/account/Fallback";
import Template from "keycloakify/account/Template"; 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 }) { export default function KcApp(props: { kcContext: KcContext }) {
const { kcContext } = props; const { kcContext } = props;
const i18n = useI18n({ kcContext });
if (i18n === null) {
return null;
}
return ( return (
<Suspense> <Suspense>
{(() => { {(() => {
@ -23,12 +14,9 @@ export default function KcApp(props: { kcContext: KcContext }) {
default: default:
return ( return (
<Fallback <Fallback
{...{ kcContext={kcContext}
kcContext, classes={classes}
i18n, Template={Template}
classes,
Template
}}
doUseDefaultCss={true} doUseDefaultCss={true}
/> />
); );
@ -37,3 +25,5 @@ export default function KcApp(props: { kcContext: KcContext }) {
</Suspense> </Suspense>
); );
} }
const classes = {} satisfies { [key in ClassKey]?: string };

View File

@ -1,11 +1,15 @@
/* eslint-disable @typescript-eslint/ban-types */ /* eslint-disable @typescript-eslint/ban-types */
import type { ExtendKcContext } from "keycloakify/account"; 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< export type KcContext = ExtendKcContext<
KcContextExtraProperties, KcContextExtension,
KcContextExtraPropertiesPerPage KcContextExtensionPerPage
>; >;

View File

@ -2,17 +2,23 @@ import type { DeepPartial } from "keycloakify/tools/DeepPartial";
import type { KcContext } from "./KcContext"; import type { KcContext } from "./KcContext";
import { createGetKcContextMock } from "keycloakify/account/KcContext"; import { createGetKcContextMock } from "keycloakify/account/KcContext";
import type { import type {
KcContextExtraProperties, KcContextExtension,
KcContextExtraPropertiesPerPage KcContextExtensionPerPage
} from "./KcContext"; } from "./KcContext";
import KcApp from "./KcApp"; import KcApp from "./KcApp";
import { themeNames, kcEnvDefaults } from "../kc.gen";
const kcContextExtraProperties: KcContextExtraProperties = {}; const kcContextExtension: KcContextExtension = {
const kcContextExtraPropertiesPerPage: KcContextExtraPropertiesPerPage = {}; themeName: themeNames[0],
properties: {
...kcEnvDefaults
}
};
const kcContextExtensionPerPage: KcContextExtensionPerPage = {};
export const { getKcContextMock } = createGetKcContextMock({ export const { getKcContextMock } = createGetKcContextMock({
kcContextExtraProperties, kcContextExtension,
kcContextExtraPropertiesPerPage, kcContextExtensionPerPage,
overrides: {}, overrides: {},
overridesPerPage: {} 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 { Suspense, lazy } from "react";
import type { ClassKey } from "keycloakify/login"; import type { ClassKey } from "keycloakify/login";
import type { KcContext } from "./KcContext"; import type { KcContext } from "./KcContext";
import { useI18n } from "./i18n";
import { useDownloadTerms } from "keycloakify/login"; import { useDownloadTerms } from "keycloakify/login";
import Fallback from "keycloakify/login/Fallback";
import Template from "keycloakify/login/Template"; import Template from "keycloakify/login/Template";
const Fallback = lazy(() => import("keycloakify/login/Fallback"));
const UserProfileFormFields = lazy(() => import("keycloakify/login/UserProfileFormFields")); const UserProfileFormFields = lazy(() => import("keycloakify/login/UserProfileFormFields"));
const classes = {} satisfies { [key in ClassKey]?: string }; const doMakeUserConfirmPassword = true;
export default function KcApp(props: { kcContext: KcContext }) { export default function KcApp(props: { kcContext: KcContext }) {
const { kcContext } = props; const { kcContext } = props;
const i18n = useI18n({ kcContext });
useDownloadTerms({ useDownloadTerms({
kcContext, kcContext,
downloadTermsMarkdown: async ({ currentLanguageTag }) => { downloadTermsMarkdown: async ({ currentLanguageTag }) => {
@ -39,10 +36,6 @@ export default function KcApp(props: { kcContext: KcContext }) {
} }
}); });
if (i18n === null) {
return null;
}
return ( return (
<Suspense> <Suspense>
{(() => { {(() => {
@ -50,14 +43,12 @@ export default function KcApp(props: { kcContext: KcContext }) {
default: default:
return ( return (
<Fallback <Fallback
{...{ kcContext={kcContext}
kcContext, classes={classes}
i18n, Template={Template}
classes,
Template,
UserProfileFormFields
}}
doUseDefaultCss={true} doUseDefaultCss={true}
UserProfileFormFields={UserProfileFormFields}
doMakeUserConfirmPassword={doMakeUserConfirmPassword}
/> />
); );
} }
@ -65,3 +56,5 @@ export default function KcApp(props: { kcContext: KcContext }) {
</Suspense> </Suspense>
); );
} }
const classes = {} satisfies { [key in ClassKey]?: string };

View File

@ -1,11 +1,15 @@
/* eslint-disable @typescript-eslint/ban-types */ /* eslint-disable @typescript-eslint/ban-types */
import type { ExtendKcContext } from "keycloakify/login"; 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< export type KcContext = ExtendKcContext<
KcContextExtraProperties, KcContextExtension,
KcContextExtraPropertiesPerPage KcContextExtensionPerPage
>; >;

View File

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

View File

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

View File

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