@keycloakify/svelte 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -631,13 +631,14 @@ async function command(params) {
631
631
  console.log(chalk__WEBPACK_IMPORTED_MODULE_0___default().cyan('Select the page you want to customize:'));
632
632
  const templateValue = 'Template.svelte (Layout common to every page)';
633
633
  const userProfileFormFieldsValue = 'UserProfileFormFields.svelte (Renders the form of the register.ftl, login-update-profile.ftl, update-email.ftl and idp-review-user-profile.ftl)';
634
+ const otherPageValue = "The page you're looking for isn't listed here";
634
635
  const { value: pageIdOrComponent } = await cli_select__WEBPACK_IMPORTED_MODULE_1___default()({
635
636
  values: (() => {
636
637
  switch (themeType) {
637
638
  case 'login':
638
- return [templateValue, userProfileFormFieldsValue, ..._core__WEBPACK_IMPORTED_MODULE_5__/* .LOGIN_THEME_PAGE_IDS */ .hz];
639
+ return [templateValue, userProfileFormFieldsValue, ..._core__WEBPACK_IMPORTED_MODULE_5__/* .LOGIN_THEME_PAGE_IDS */ .hz, otherPageValue];
639
640
  case 'account':
640
- return [templateValue, ..._core__WEBPACK_IMPORTED_MODULE_5__/* .ACCOUNT_THEME_PAGE_IDS */ .Hp];
641
+ return [templateValue, ..._core__WEBPACK_IMPORTED_MODULE_5__/* .ACCOUNT_THEME_PAGE_IDS */ .Hp, otherPageValue];
641
642
  case 'admin':
642
643
  return [];
643
644
  }
@@ -646,6 +647,13 @@ async function command(params) {
646
647
  }).catch(() => {
647
648
  process.exit(-1);
648
649
  });
650
+ if (pageIdOrComponent === otherPageValue) {
651
+ console.log([
652
+ 'To style a page not included in the base Keycloak, such as one added by a third-party Keycloak extension,',
653
+ 'refer to the documentation: https://docs.keycloakify.dev/features/styling-a-custom-page-not-included-in-base-keycloak',
654
+ ].join(' '));
655
+ process.exit(0);
656
+ }
649
657
  console.log(`→ ${pageIdOrComponent}`);
650
658
  const componentBasename = (() => {
651
659
  if (pageIdOrComponent === templateValue) {
@@ -10,7 +10,19 @@ export function createUseI18n(params) {
10
10
  function renderHtmlString(params) {
11
11
  const { htmlString, msgKey } = params;
12
12
  return createRawSnippet(() => ({
13
- render: () => `<div data-kc-msg="${msgKey}">${htmlString}</div>`,
13
+ render: () => {
14
+ const elementName = (() => {
15
+ if (htmlString.includes('<') && htmlString.includes('>')) {
16
+ for (const tagName of ['div', 'section', 'article', 'ul', 'ol']) {
17
+ if (htmlString.includes(`<${tagName}`)) {
18
+ return 'div';
19
+ }
20
+ }
21
+ }
22
+ return 'span';
23
+ })();
24
+ return `<${elementName} data-kc-msg="${msgKey}">${htmlString}</${elementName}>`;
25
+ },
14
26
  }));
15
27
  }
16
28
  function withSvelte(i18n_noJsx) {
@@ -39,7 +51,7 @@ export function createUseI18n(params) {
39
51
  }
40
52
  const styleElement = document.createElement('style');
41
53
  styleElement.attributes.setNamedItem(document.createAttribute(attributeName));
42
- styleElement.textContent = `[data-kc-msg] { display: inline-block; }`;
54
+ styleElement.textContent = `div[${attributeName}] { display: inline-block; }`;
43
55
  document.head.prepend(styleElement);
44
56
  }
45
57
  const { getI18n } = createGetI18n({ extraLanguageTranslations, messagesByLanguageTag_themeDefined });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keycloakify/svelte",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Svelte Components for Keycloakify",
5
5
  "keywords": [
6
6
  "keycloak",
@@ -64,7 +64,20 @@ export function createUseI18n<
64
64
  function renderHtmlString(params: { htmlString: string; msgKey: string }): Snippet {
65
65
  const { htmlString, msgKey } = params;
66
66
  return createRawSnippet(() => ({
67
- render: () => `<div data-kc-msg="${msgKey}">${htmlString}</div>`,
67
+ render: () => {
68
+ const elementName = (() => {
69
+ if (htmlString.includes('<') && htmlString.includes('>')) {
70
+ for (const tagName of ['div', 'section', 'article', 'ul', 'ol']) {
71
+ if (htmlString.includes(`<${tagName}`)) {
72
+ return 'div';
73
+ }
74
+ }
75
+ }
76
+ return 'span';
77
+ })();
78
+
79
+ return `<${elementName} data-kc-msg="${msgKey}">${htmlString}</${elementName}>`;
80
+ },
68
81
  }));
69
82
  }
70
83
 
@@ -104,7 +117,7 @@ export function createUseI18n<
104
117
 
105
118
  const styleElement = document.createElement('style');
106
119
  styleElement.attributes.setNamedItem(document.createAttribute(attributeName));
107
- styleElement.textContent = `[data-kc-msg] { display: inline-block; }`;
120
+ styleElement.textContent = `div[${attributeName}] { display: inline-block; }`;
108
121
  document.head.prepend(styleElement);
109
122
  }
110
123