Compare commits

..

16 Commits

Author SHA1 Message Date
bccaddc2de Bump version 2024-11-13 14:38:48 +01:00
97c12c8a12 Merge pull request #720 from sukvvon/fix/add-versatility-in-runFormat
fix(runFormat.ts): improve filtering in scriptNames
2024-11-13 13:38:25 +00:00
b349a819ba fix(runFormat.ts): improve filtering in scriptNames 2024-11-13 21:49:55 +09:00
792d4262c8 Bump version 2024-11-10 14:30:00 +01:00
37a9046a40 Merge pull request #718 from kathari00/fix_storyname
fix story
2024-11-10 13:29:39 +00:00
5ad29d9f43 fix story 2024-11-10 10:33:21 +00:00
79a580b4a5 Bump version 2024-11-09 19:50:48 +01:00
994f1f8d3d #714 #713 2024-11-09 19:50:29 +01:00
a2ea81b3b8 Bump version 2024-11-06 10:10:55 +01:00
a0461e3ef0 #711 2024-11-06 10:10:27 +01:00
5357626317 Bump version 2024-10-31 11:05:43 +01:00
552c95c59e https://github.com/keycloakify/keycloakify/pull/705#issuecomment-2448689532 2024-10-31 11:05:25 +01:00
50590697ca Bump version 2024-10-30 15:51:32 +01:00
e261736fa3 Fix: kcContext.scripts can be undefined in error.ftl 2024-10-30 15:51:16 +01:00
263f55fdd3 Bump version 2024-10-26 22:07:54 +00:00
2b7f8a24a3 Fix import.meta.env.BASE_URL not being corectly replaced when build in windows 2024-10-26 22:07:29 +00:00
9 changed files with 36 additions and 21 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "keycloakify", "name": "keycloakify",
"version": "11.3.12", "version": "11.3.19",
"description": "Framework to create custom Keycloak UIs", "description": "Framework to create custom Keycloak UIs",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -44,7 +44,12 @@ export function runFormat(params: { packageJsonFilePath: string }) {
return; return;
} }
for (const scriptName of ["format", "lint"]) { const scriptKeys = Object.keys(scripts);
const scriptNames = scriptKeys.filter(scriptKey =>
scriptKey.trim().match(/^(lint|format)/)
);
for (const scriptName of scriptNames) {
if (!(scriptName in scripts)) { if (!(scriptName in scripts)) {
continue; continue;
} }

View File

@ -51,7 +51,7 @@ export async function command(params: { buildContext: BuildContext }) {
2 2
)};`, )};`,
``, ``,
`export type KcContext =`, `type KcContext =`,
hasLoginTheme && ` | import("./login/KcContext").KcContext`, hasLoginTheme && ` | import("./login/KcContext").KcContext`,
hasAccountTheme && ` | import("./account/KcContext").KcContext`, hasAccountTheme && ` | import("./account/KcContext").KcContext`,
` ;`, ` ;`,

View File

@ -102,7 +102,7 @@ export declare namespace KcContext {
showTryAnotherWayLink?: boolean; showTryAnotherWayLink?: boolean;
attemptedUsername?: string; attemptedUsername?: string;
}; };
scripts: string[]; scripts?: string[];
message?: { message?: {
type: "success" | "warning" | "error" | "info"; type: "success" | "warning" | "error" | "info";
summary: string; summary: string;

View File

@ -10,7 +10,7 @@ export type KcContextLike = {
resourcesPath: string; resourcesPath: string;
ssoLoginInOtherTabsUrl: string; ssoLoginInOtherTabsUrl: string;
}; };
scripts: string[]; scripts?: string[];
}; };
assert<keyof KcContextLike extends keyof KcContext ? true : false>(); assert<keyof KcContextLike extends keyof KcContext ? true : false>();
@ -45,10 +45,12 @@ export function useInitialize(params: {
type: "module", type: "module",
src: `${url.resourcesPath}/js/menu-button-links.js` src: `${url.resourcesPath}/js/menu-button-links.js`
}, },
...scripts.map(src => ({ ...(scripts === undefined
type: "text/javascript" as const, ? []
src : scripts.map(src => ({
})), type: "text/javascript" as const,
src
}))),
{ {
type: "module", type: "module",
textContent: ` textContent: `

View File

@ -16,6 +16,9 @@ import type { GenericI18n_noJsx } from "./GenericI18n_noJsx";
export type KcContextLike = { export type KcContextLike = {
themeName: string; themeName: string;
realm: {
internationalizationEnabled: boolean;
};
locale?: { locale?: {
currentLanguageTag: string; currentLanguageTag: string;
supported: { languageTag: string; url: string; label: string }[]; supported: { languageTag: string; url: string; label: string }[];
@ -91,14 +94,16 @@ export function createGetI18n<
return cachedResult; return cachedResult;
} }
const kcContextLocale = params.kcContext.realm.internationalizationEnabled ? params.kcContext.locale : undefined;
{ {
const currentLanguageTag = kcContext.locale?.currentLanguageTag ?? FALLBACK_LANGUAGE_TAG; const currentLanguageTag = kcContextLocale?.currentLanguageTag ?? FALLBACK_LANGUAGE_TAG;
const html = document.querySelector("html"); const html = document.querySelector("html");
assert(html !== null); assert(html !== null);
html.lang = currentLanguageTag; html.lang = currentLanguageTag;
const isRtl = (() => { const isRtl = (() => {
const { rtl } = kcContext.locale ?? {}; const { rtl } = kcContextLocale ?? {};
if (rtl !== undefined) { if (rtl !== undefined) {
return rtl; return rtl;
@ -154,11 +159,11 @@ export function createGetI18n<
} }
from_server: { from_server: {
if (kcContext.locale === undefined) { if (kcContextLocale === undefined) {
break from_server; break from_server;
} }
const supportedEntry = kcContext.locale.supported.find(entry => entry.languageTag === languageTag); const supportedEntry = kcContextLocale.supported.find(entry => entry.languageTag === languageTag);
if (supportedEntry === undefined) { if (supportedEntry === undefined) {
break from_server; break from_server;
@ -180,7 +185,7 @@ export function createGetI18n<
}; };
const currentLanguage: I18n["currentLanguage"] = (() => { const currentLanguage: I18n["currentLanguage"] = (() => {
const languageTag = id<string>(kcContext.locale?.currentLanguageTag ?? FALLBACK_LANGUAGE_TAG) as LanguageTag; const languageTag = id<string>(kcContextLocale?.currentLanguageTag ?? FALLBACK_LANGUAGE_TAG) as LanguageTag;
return { return {
languageTag, languageTag,
@ -191,8 +196,8 @@ export function createGetI18n<
const enabledLanguages: I18n["enabledLanguages"] = (() => { const enabledLanguages: I18n["enabledLanguages"] = (() => {
const enabledLanguages: I18n["enabledLanguages"] = []; const enabledLanguages: I18n["enabledLanguages"] = [];
if (kcContext.locale !== undefined) { if (kcContextLocale !== undefined) {
for (const entry of kcContext.locale.supported ?? []) { for (const entry of kcContextLocale.supported ?? []) {
const languageTag = id<string>(entry.languageTag) as LanguageTag; const languageTag = id<string>(entry.languageTag) as LanguageTag;
enabledLanguages.push({ enabledLanguages.push({

View File

@ -70,9 +70,9 @@ export default function LoginRecoveryAuthnCodeConfig(props: PageProps<Extract<Kc
type="checkbox" type="checkbox"
id="kcRecoveryCodesConfirmationCheck" id="kcRecoveryCodesConfirmationCheck"
name="kcRecoveryCodesConfirmationCheck" name="kcRecoveryCodesConfirmationCheck"
onChange={function () { onChange={event => {
//@ts-expect-error: This is code from the original theme, we trust it. //@ts-expect-error: This is inherited from the original code
document.getElementById("saveRecoveryAuthnCodesBtn").disabled = !this.checked; document.getElementById("saveRecoveryAuthnCodesBtn").disabled = !event.target.checked;
}} }}
/> />
<label htmlFor="kcRecoveryCodesConfirmationCheck">{msg("recovery-codes-confirmation-message")}</label> <label htmlFor="kcRecoveryCodesConfirmationCheck">{msg("recovery-codes-confirmation-message")}</label>

View File

@ -16,6 +16,7 @@ import {
} from "../bin/shared/buildContext"; } from "../bin/shared/buildContext";
import MagicString from "magic-string"; import MagicString from "magic-string";
import { command as updateKcGenCommand } from "../bin/update-kc-gen"; import { command as updateKcGenCommand } from "../bin/update-kc-gen";
import { replaceAll } from "../bin/tools/String.prototype.replaceAll";
export namespace keycloakify { export namespace keycloakify {
export type Params = BuildOptions & { export type Params = BuildOptions & {
@ -130,6 +131,8 @@ export function keycloakify(params: keycloakify.Params) {
await updateKcGenCommand({ buildContext }); await updateKcGenCommand({ buildContext });
}, },
transform: (code, id) => { transform: (code, id) => {
id = replaceAll(id, "/", pathSep);
assert(command !== undefined); assert(command !== undefined);
assert(shouldGenerateSourcemap !== undefined); assert(shouldGenerateSourcemap !== undefined);

View File

@ -2,10 +2,10 @@ import React from "react";
import type { Meta, StoryObj } from "@storybook/react"; import type { Meta, StoryObj } from "@storybook/react";
import { createKcPageStory } from "../KcPageStory"; import { createKcPageStory } from "../KcPageStory";
const { KcPageStory } = createKcPageStory({ pageId: "login-oauth2-device-verify-user-code.ftl" }); const { KcPageStory } = createKcPageStory({ pageId: "login-device-verify-user-code.ftl" });
const meta = { const meta = {
title: "login/login-oauth2-device-verify-user-code.ftl", title: "login/login-device-verify-user-code.ftl",
component: KcPageStory component: KcPageStory
} satisfies Meta<typeof KcPageStory>; } satisfies Meta<typeof KcPageStory>;