@oussemasahbeni/keycloakify-login-shadcn 250004.0.3 → 250004.0.8

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.
Files changed (187) hide show
  1. package/keycloak-theme/components/langauges.tsx +1 -1
  2. package/keycloak-theme/components/theme-toggle.tsx +0 -1
  3. package/keycloak-theme/components/ui/alert.tsx +1 -2
  4. package/keycloak-theme/components/ui/button.tsx +1 -2
  5. package/keycloak-theme/components/ui/card.tsx +0 -1
  6. package/keycloak-theme/components/ui/checkbox.tsx +0 -1
  7. package/keycloak-theme/components/ui/dropdown-menu.tsx +14 -4
  8. package/keycloak-theme/components/ui/field.tsx +0 -1
  9. package/keycloak-theme/components/ui/input-otp.tsx +0 -1
  10. package/keycloak-theme/components/ui/input.tsx +0 -1
  11. package/keycloak-theme/components/ui/label.tsx +1 -2
  12. package/keycloak-theme/components/ui/radio-group.tsx +0 -1
  13. package/keycloak-theme/components/ui/select.tsx +12 -4
  14. package/keycloak-theme/components/ui/separator.tsx +0 -1
  15. package/keycloak-theme/components/ui/tooltip.tsx +0 -1
  16. package/keycloak-theme/login/KcContext.ts +23 -23
  17. package/keycloak-theme/login/KcPage.tsx +45 -47
  18. package/keycloak-theme/login/assets/img/auth-logo.svg +100 -100
  19. package/keycloak-theme/login/assets/img/shape.svg +71 -71
  20. package/keycloak-theme/login/components/LogoutOtherSessions.tsx +24 -26
  21. package/keycloak-theme/login/components/PasswordWrapper.tsx +35 -35
  22. package/keycloak-theme/login/components/Template/Template.tsx +279 -227
  23. package/keycloak-theme/login/components/Template/index.ts +1 -1
  24. package/keycloak-theme/login/components/Template/useInitializeTemplate.ts +61 -61
  25. package/keycloak-theme/login/components/UserProfileFormFields/AddRemoveButtonsMultiValuedAttribute.tsx +65 -61
  26. package/keycloak-theme/login/components/UserProfileFormFields/DO_MAKE_USER_CONFIRM_PASSWORD.ts +2 -2
  27. package/keycloak-theme/login/components/UserProfileFormFields/FieldErrors.tsx +33 -29
  28. package/keycloak-theme/login/components/UserProfileFormFields/GroupLabel.tsx +90 -71
  29. package/keycloak-theme/login/components/UserProfileFormFields/InputFieldByType.tsx +66 -59
  30. package/keycloak-theme/login/components/UserProfileFormFields/InputLabel.tsx +0 -1
  31. package/keycloak-theme/login/components/UserProfileFormFields/InputTag.tsx +133 -116
  32. package/keycloak-theme/login/components/UserProfileFormFields/InputTagSelects.tsx +150 -136
  33. package/keycloak-theme/login/components/UserProfileFormFields/SelectTag.tsx +135 -114
  34. package/keycloak-theme/login/components/UserProfileFormFields/TextareaTag.tsx +55 -43
  35. package/keycloak-theme/login/components/UserProfileFormFields/UserProfileFormFields.tsx +133 -127
  36. package/keycloak-theme/login/components/UserProfileFormFields/index.ts +1 -1
  37. package/keycloak-theme/login/i18n.ts +47 -47
  38. package/keycloak-theme/login/mocks/KcPageStory.tsx +6 -2
  39. package/keycloak-theme/login/mocks/getKcContextMock.ts +22 -22
  40. package/keycloak-theme/login/pages/PageIndex.tsx +130 -134
  41. package/keycloak-theme/login/pages/code/Page.stories.tsx +57 -70
  42. package/keycloak-theme/login/pages/code/Page.tsx +89 -89
  43. package/keycloak-theme/login/pages/code/index.ts +3 -3
  44. package/keycloak-theme/login/pages/delete-account-confirm/Page.stories.tsx +37 -46
  45. package/keycloak-theme/login/pages/delete-account-confirm/Page.tsx +60 -63
  46. package/keycloak-theme/login/pages/delete-account-confirm/index.ts +3 -3
  47. package/keycloak-theme/login/pages/delete-credential/Page.stories.tsx +25 -30
  48. package/keycloak-theme/login/pages/delete-credential/Page.tsx +56 -51
  49. package/keycloak-theme/login/pages/delete-credential/index.ts +3 -3
  50. package/keycloak-theme/login/pages/error/Page.stories.tsx +46 -58
  51. package/keycloak-theme/login/pages/error/Page.tsx +43 -42
  52. package/keycloak-theme/login/pages/error/index.ts +3 -3
  53. package/keycloak-theme/login/pages/frontchannel-logout/Page.stories.tsx +25 -32
  54. package/keycloak-theme/login/pages/frontchannel-logout/Page.tsx +82 -84
  55. package/keycloak-theme/login/pages/frontchannel-logout/index.ts +3 -3
  56. package/keycloak-theme/login/pages/idp-review-user-profile/Page.stories.tsx +46 -59
  57. package/keycloak-theme/login/pages/idp-review-user-profile/Page.tsx +49 -52
  58. package/keycloak-theme/login/pages/idp-review-user-profile/index.ts +3 -3
  59. package/keycloak-theme/login/pages/info/Page.stories.tsx +50 -60
  60. package/keycloak-theme/login/pages/info/Page.tsx +94 -92
  61. package/keycloak-theme/login/pages/link-idp-action/Page.stories.tsx +32 -16
  62. package/keycloak-theme/login/pages/link-idp-action/Page.tsx +45 -43
  63. package/keycloak-theme/login/pages/link-idp-action/index.ts +3 -3
  64. package/keycloak-theme/login/pages/login/Form.tsx +242 -242
  65. package/keycloak-theme/login/pages/login/Info.tsx +29 -29
  66. package/keycloak-theme/login/pages/login/Page.stories.tsx +346 -365
  67. package/keycloak-theme/login/pages/login/Page.tsx +43 -44
  68. package/keycloak-theme/login/pages/login/SocialProviders.tsx +93 -107
  69. package/keycloak-theme/login/pages/login/index.ts +3 -3
  70. package/keycloak-theme/login/pages/login/providers/apple.svg +3 -3
  71. package/keycloak-theme/login/pages/login/providers/bitbucket.svg +11 -11
  72. package/keycloak-theme/login/pages/login/providers/discord.svg +4 -4
  73. package/keycloak-theme/login/pages/login/providers/facebook.svg +5 -5
  74. package/keycloak-theme/login/pages/login/providers/github.svg +3 -3
  75. package/keycloak-theme/login/pages/login/providers/gitlab.svg +7 -7
  76. package/keycloak-theme/login/pages/login/providers/google.svg +7 -7
  77. package/keycloak-theme/login/pages/login/providers/instagram.svg +31 -31
  78. package/keycloak-theme/login/pages/login/providers/linkedin.svg +3 -3
  79. package/keycloak-theme/login/pages/login/providers/microsoft.svg +6 -6
  80. package/keycloak-theme/login/pages/login/providers/oidc.svg +5 -5
  81. package/keycloak-theme/login/pages/login/providers/openshift.svg +7 -7
  82. package/keycloak-theme/login/pages/login/providers/paypal.svg +6 -6
  83. package/keycloak-theme/login/pages/login/providers/slack.svg +11 -11
  84. package/keycloak-theme/login/pages/login/providers/stackoverflow.svg +5 -5
  85. package/keycloak-theme/login/pages/login/providers/x.svg +3 -3
  86. package/keycloak-theme/login/pages/login/useProviderLogos.tsx +39 -39
  87. package/keycloak-theme/login/pages/login/useScript.tsx +62 -62
  88. package/keycloak-theme/login/pages/login-config-totp/Page.stories.tsx +45 -60
  89. package/keycloak-theme/login/pages/login-config-totp/Page.tsx +253 -240
  90. package/keycloak-theme/login/pages/login-config-totp/index.ts +3 -3
  91. package/keycloak-theme/login/pages/login-idp-link-confirm/Page.stories.tsx +30 -35
  92. package/keycloak-theme/login/pages/login-idp-link-confirm/Page.tsx +40 -43
  93. package/keycloak-theme/login/pages/login-idp-link-confirm/index.ts +3 -3
  94. package/keycloak-theme/login/pages/login-idp-link-confirm-override/Page.stories.tsx +16 -23
  95. package/keycloak-theme/login/pages/login-idp-link-confirm-override/Page.tsx +44 -47
  96. package/keycloak-theme/login/pages/login-idp-link-confirm-override/index.ts +3 -3
  97. package/keycloak-theme/login/pages/login-idp-link-email/Page.stories.tsx +54 -63
  98. package/keycloak-theme/login/pages/login-idp-link-email/Page.tsx +51 -54
  99. package/keycloak-theme/login/pages/login-idp-link-email/index.ts +3 -3
  100. package/keycloak-theme/login/pages/login-oauth-grant/Page.stories.tsx +39 -45
  101. package/keycloak-theme/login/pages/login-oauth-grant/Page.tsx +136 -126
  102. package/keycloak-theme/login/pages/login-oauth-grant/index.ts +3 -3
  103. package/keycloak-theme/login/pages/login-oauth2-device-verify-user-code/Page.stories.tsx +38 -48
  104. package/keycloak-theme/login/pages/login-oauth2-device-verify-user-code/Page.tsx +56 -58
  105. package/keycloak-theme/login/pages/login-oauth2-device-verify-user-code/index.ts +3 -3
  106. package/keycloak-theme/login/pages/login-otp/Page.stories.tsx +82 -97
  107. package/keycloak-theme/login/pages/login-otp/Page.tsx +117 -108
  108. package/keycloak-theme/login/pages/login-otp/index.ts +3 -3
  109. package/keycloak-theme/login/pages/login-page-expired/Page.stories.tsx +28 -37
  110. package/keycloak-theme/login/pages/login-page-expired/Page.tsx +45 -47
  111. package/keycloak-theme/login/pages/login-page-expired/index.ts +3 -3
  112. package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/Page.stories.tsx +20 -0
  113. package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/Page.tsx +290 -233
  114. package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/index.ts +3 -3
  115. package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/useScript.tsx +63 -63
  116. package/keycloak-theme/login/pages/login-password/Page.stories.tsx +55 -56
  117. package/keycloak-theme/login/pages/login-password/Page.tsx +148 -149
  118. package/keycloak-theme/login/pages/login-password/index.ts +3 -3
  119. package/keycloak-theme/login/pages/login-password/useScript.tsx +62 -63
  120. package/keycloak-theme/login/pages/login-recovery-authn-code-config/Page.stories.tsx +28 -36
  121. package/keycloak-theme/login/pages/login-recovery-authn-code-config/Page.tsx +178 -181
  122. package/keycloak-theme/login/pages/login-recovery-authn-code-config/index.ts +3 -3
  123. package/keycloak-theme/login/pages/login-recovery-authn-code-config/useScript.tsx +145 -145
  124. package/keycloak-theme/login/pages/login-recovery-authn-code-input/Page.stories.tsx +16 -22
  125. package/keycloak-theme/login/pages/login-recovery-authn-code-input/Page.tsx +69 -70
  126. package/keycloak-theme/login/pages/login-recovery-authn-code-input/index.ts +3 -3
  127. package/keycloak-theme/login/pages/login-reset-otp/Page.stories.tsx +62 -75
  128. package/keycloak-theme/login/pages/login-reset-otp/Page.tsx +85 -86
  129. package/keycloak-theme/login/pages/login-reset-otp/index.ts +3 -3
  130. package/keycloak-theme/login/pages/login-reset-password/Form.tsx +67 -68
  131. package/keycloak-theme/login/pages/login-reset-password/Page.stories.tsx +44 -55
  132. package/keycloak-theme/login/pages/login-reset-password/Page.tsx +27 -27
  133. package/keycloak-theme/login/pages/login-reset-password/index.ts +3 -3
  134. package/keycloak-theme/login/pages/login-update-password/Page.stories.tsx +40 -51
  135. package/keycloak-theme/login/pages/login-update-password/Page.tsx +109 -111
  136. package/keycloak-theme/login/pages/login-update-password/index.ts +3 -3
  137. package/keycloak-theme/login/pages/login-update-profile/Page.stories.tsx +28 -37
  138. package/keycloak-theme/login/pages/login-update-profile/Page.tsx +67 -68
  139. package/keycloak-theme/login/pages/login-update-profile/index.ts +3 -3
  140. package/keycloak-theme/login/pages/login-username/Page.stories.tsx +32 -43
  141. package/keycloak-theme/login/pages/login-username/Page.tsx +246 -246
  142. package/keycloak-theme/login/pages/login-username/index.ts +3 -3
  143. package/keycloak-theme/login/pages/login-username/useScript.tsx +62 -62
  144. package/keycloak-theme/login/pages/login-verify-email/Page.stories.tsx +68 -81
  145. package/keycloak-theme/login/pages/login-verify-email/Page.tsx +37 -38
  146. package/keycloak-theme/login/pages/login-verify-email/index.ts +3 -3
  147. package/keycloak-theme/login/pages/login-x509-info/Page.stories.tsx +29 -38
  148. package/keycloak-theme/login/pages/login-x509-info/Page.tsx +72 -75
  149. package/keycloak-theme/login/pages/login-x509-info/index.ts +3 -3
  150. package/keycloak-theme/login/pages/logout-confirm/Page.stories.tsx +34 -43
  151. package/keycloak-theme/login/pages/logout-confirm/Page.tsx +50 -53
  152. package/keycloak-theme/login/pages/logout-confirm/index.ts +3 -3
  153. package/keycloak-theme/login/pages/register/Form.tsx +107 -106
  154. package/keycloak-theme/login/pages/register/Page.stories.tsx +40 -14
  155. package/keycloak-theme/login/pages/register/Page.tsx +26 -26
  156. package/keycloak-theme/login/pages/register/TermsAcceptance.tsx +55 -56
  157. package/keycloak-theme/login/pages/register/index.ts +3 -3
  158. package/keycloak-theme/login/pages/saml-post-form/Page.stories.tsx +16 -23
  159. package/keycloak-theme/login/pages/saml-post-form/Page.tsx +64 -66
  160. package/keycloak-theme/login/pages/saml-post-form/index.ts +3 -3
  161. package/keycloak-theme/login/pages/select-authenticator/Page.stories.tsx +83 -96
  162. package/keycloak-theme/login/pages/select-authenticator/Page.tsx +97 -100
  163. package/keycloak-theme/login/pages/select-authenticator/index.ts +3 -3
  164. package/keycloak-theme/login/pages/select-organization/Page.stories.tsx +62 -49
  165. package/keycloak-theme/login/pages/select-organization/Page.tsx +123 -126
  166. package/keycloak-theme/login/pages/select-organization/index.ts +3 -3
  167. package/keycloak-theme/login/pages/terms/Page.stories.tsx +15 -0
  168. package/keycloak-theme/login/pages/terms/Page.tsx +49 -51
  169. package/keycloak-theme/login/pages/terms/index.ts +3 -3
  170. package/keycloak-theme/login/pages/update-email/Page.stories.tsx +27 -36
  171. package/keycloak-theme/login/pages/update-email/Page.tsx +61 -62
  172. package/keycloak-theme/login/pages/update-email/index.ts +3 -3
  173. package/keycloak-theme/login/pages/webauthn-authenticate/Page.stories.tsx +112 -127
  174. package/keycloak-theme/login/pages/webauthn-authenticate/Page.tsx +206 -202
  175. package/keycloak-theme/login/pages/webauthn-authenticate/index.ts +3 -3
  176. package/keycloak-theme/login/pages/webauthn-authenticate/useScript.tsx +55 -55
  177. package/keycloak-theme/login/pages/webauthn-error/Page.stories.tsx +52 -67
  178. package/keycloak-theme/login/pages/webauthn-error/Page.tsx +70 -73
  179. package/keycloak-theme/login/pages/webauthn-error/index.ts +3 -3
  180. package/keycloak-theme/login/pages/webauthn-register/Page.stories.tsx +39 -50
  181. package/keycloak-theme/login/pages/webauthn-register/Page.tsx +78 -78
  182. package/keycloak-theme/login/pages/webauthn-register/index.ts +3 -3
  183. package/keycloak-theme/login/pages/webauthn-register/useScript.tsx +62 -62
  184. package/keycloak-theme/login/shared/getColorScheme.ts +45 -45
  185. package/keycloak-theme/login/styleLevelCustomization.tsx +34 -36
  186. package/keycloak-theme/public/site.webmanifest +11 -1
  187. package/package.json +6 -2
@@ -1,61 +1,61 @@
1
- import { useEffect } from "react";
2
- import { useInsertScriptTags } from "@keycloakify/login-ui/tools/useInsertScriptTags";
3
- import { useInsertLinkTags } from "@keycloakify/login-ui/tools/useInsertLinkTags";
4
- import { useKcClsx } from "@keycloakify/login-ui/useKcClsx";
5
- import { BASE_URL } from "../../../kc.gen";
6
- import { useKcContext } from "../../KcContext";
7
-
8
- export function useInitializeTemplate() {
9
- const { kcContext } = useKcContext();
10
-
11
- const { doUseDefaultCss } = useKcClsx();
12
-
13
- const { areAllStyleSheetsLoaded } = useInsertLinkTags({
14
- effectId: "Template",
15
- hrefs: !doUseDefaultCss
16
- ? []
17
- : [
18
- `${BASE_URL}keycloak-theme/login/resources-common/node_modules/@patternfly/patternfly/patternfly.min.css`,
19
- `${BASE_URL}keycloak-theme/login/resources-common/node_modules/patternfly/dist/css/patternfly.min.css`,
20
- `${BASE_URL}keycloak-theme/login/resources-common/node_modules/patternfly/dist/css/patternfly-additions.min.css`,
21
- `${BASE_URL}keycloak-theme/login/resources-common/lib/pficon/pficon.css`,
22
- `${BASE_URL}keycloak-theme/login/css/login.css`
23
- ]
24
- });
25
-
26
- const { insertScriptTags } = useInsertScriptTags({
27
- effectId: "Template",
28
- scriptTags: [
29
- // NOTE: The importmap is added in by the FTL script because it's too late to add it here.
30
- {
31
- type: "module",
32
- src: `${BASE_URL}keycloak-theme/login/js/menu-button-links.js`
33
- },
34
- ...(kcContext.scripts === undefined
35
- ? []
36
- : kcContext.scripts.map(src => ({
37
- type: "text/javascript" as const,
38
- src
39
- }))),
40
- {
41
- type: "module",
42
- textContent: [
43
- `import { startSessionPolling, checkAuthSession } from "${BASE_URL}keycloak-theme/login/js/authChecker.js";`,
44
- ``,
45
- `startSessionPolling("${kcContext.url.ssoLoginInOtherTabsUrl}");`,
46
- kcContext.authenticationSession === undefined
47
- ? ""
48
- : `checkAuthSession("${kcContext.authenticationSession.authSessionIdHash}");`
49
- ].join("\n")
50
- }
51
- ]
52
- });
53
-
54
- useEffect(() => {
55
- if (areAllStyleSheetsLoaded) {
56
- insertScriptTags();
57
- }
58
- }, [areAllStyleSheetsLoaded]);
59
-
60
- return { isReadyToRender: areAllStyleSheetsLoaded };
61
- }
1
+ import { useEffect } from "react";
2
+ import { useInsertScriptTags } from "@keycloakify/login-ui/tools/useInsertScriptTags";
3
+ import { useInsertLinkTags } from "@keycloakify/login-ui/tools/useInsertLinkTags";
4
+ import { useKcClsx } from "@keycloakify/login-ui/useKcClsx";
5
+ import { BASE_URL } from "../../../kc.gen";
6
+ import { useKcContext } from "../../KcContext";
7
+
8
+ export function useInitializeTemplate() {
9
+ const { kcContext } = useKcContext();
10
+
11
+ const { doUseDefaultCss } = useKcClsx();
12
+
13
+ const { areAllStyleSheetsLoaded } = useInsertLinkTags({
14
+ effectId: "Template",
15
+ hrefs: !doUseDefaultCss
16
+ ? []
17
+ : [
18
+ `${BASE_URL}keycloak-theme/login/resources-common/node_modules/@patternfly/patternfly/patternfly.min.css`,
19
+ `${BASE_URL}keycloak-theme/login/resources-common/node_modules/patternfly/dist/css/patternfly.min.css`,
20
+ `${BASE_URL}keycloak-theme/login/resources-common/node_modules/patternfly/dist/css/patternfly-additions.min.css`,
21
+ `${BASE_URL}keycloak-theme/login/resources-common/lib/pficon/pficon.css`,
22
+ `${BASE_URL}keycloak-theme/login/css/login.css`
23
+ ]
24
+ });
25
+
26
+ const { insertScriptTags } = useInsertScriptTags({
27
+ effectId: "Template",
28
+ scriptTags: [
29
+ // NOTE: The importmap is added in by the FTL script because it's too late to add it here.
30
+ {
31
+ type: "module",
32
+ src: `${BASE_URL}keycloak-theme/login/js/menu-button-links.js`
33
+ },
34
+ ...(kcContext.scripts === undefined
35
+ ? []
36
+ : kcContext.scripts.map(src => ({
37
+ type: "text/javascript" as const,
38
+ src
39
+ }))),
40
+ {
41
+ type: "module",
42
+ textContent: [
43
+ `import { startSessionPolling, checkAuthSession } from "${BASE_URL}keycloak-theme/login/js/authChecker.js";`,
44
+ ``,
45
+ `startSessionPolling("${kcContext.url.ssoLoginInOtherTabsUrl}");`,
46
+ kcContext.authenticationSession === undefined
47
+ ? ""
48
+ : `checkAuthSession("${kcContext.authenticationSession.authSessionIdHash}");`
49
+ ].join("\n")
50
+ }
51
+ ]
52
+ });
53
+
54
+ useEffect(() => {
55
+ if (areAllStyleSheetsLoaded) {
56
+ insertScriptTags();
57
+ }
58
+ }, [areAllStyleSheetsLoaded]);
59
+
60
+ return { isReadyToRender: areAllStyleSheetsLoaded };
61
+ }
@@ -1,61 +1,65 @@
1
- import { Button } from '@/components/ui/button';
2
- import { useI18n } from '@/login/i18n';
3
- import type { Attribute } from "@keycloakify/login-ui/KcContext";
4
- import {
5
- getButtonToDisplayForMultivaluedAttributeField,
6
- type FormAction
7
- } from "@keycloakify/login-ui/useUserProfileForm";
8
-
9
- export function AddRemoveButtonsMultiValuedAttribute(props: {
10
- attribute: Attribute;
11
- values: string[];
12
- fieldIndex: number;
13
- dispatchFormAction: React.Dispatch<Extract<FormAction, { action: "update" }>>;
14
- }) {
15
- const { attribute, values, fieldIndex, dispatchFormAction } = props;
16
-
17
- const { msg } = useI18n();
18
-
19
- const { hasAdd, hasRemove } = getButtonToDisplayForMultivaluedAttributeField({ attribute, values, fieldIndex });
20
-
21
- const idPostfix = `-${attribute.name}-${fieldIndex + 1}`;
22
-
23
- return (
24
- <div className="flex items-center gap-2 mt-2">
25
- {hasRemove && (
26
- <Button
27
- id={`kc-remove${idPostfix}`}
28
- type="button"
29
- variant="ghost"
30
- size="sm"
31
- onClick={() =>
32
- dispatchFormAction({
33
- action: "update",
34
- name: attribute.name,
35
- valueOrValues: values.filter((_, i) => i !== fieldIndex)
36
- })
37
- }
38
- >
39
- {msg("remove")}
40
- </Button>
41
- )}
42
- {hasAdd && (
43
- <Button
44
- id={`kc-add${idPostfix}`}
45
- type="button"
46
- variant="outline"
47
- size="sm"
48
- onClick={() =>
49
- dispatchFormAction({
50
- action: "update",
51
- name: attribute.name,
52
- valueOrValues: [...values, ""]
53
- })
54
- }
55
- >
56
- {msg("addValue")}
57
- </Button>
58
- )}
59
- </div>
60
- );
61
- }
1
+ import { Button } from "@/components/ui/button";
2
+ import { useI18n } from "@/login/i18n";
3
+ import type { Attribute } from "@keycloakify/login-ui/KcContext";
4
+ import {
5
+ getButtonToDisplayForMultivaluedAttributeField,
6
+ type FormAction
7
+ } from "@keycloakify/login-ui/useUserProfileForm";
8
+
9
+ export function AddRemoveButtonsMultiValuedAttribute(props: {
10
+ attribute: Attribute;
11
+ values: string[];
12
+ fieldIndex: number;
13
+ dispatchFormAction: React.Dispatch<Extract<FormAction, { action: "update" }>>;
14
+ }) {
15
+ const { attribute, values, fieldIndex, dispatchFormAction } = props;
16
+
17
+ const { msg } = useI18n();
18
+
19
+ const { hasAdd, hasRemove } = getButtonToDisplayForMultivaluedAttributeField({
20
+ attribute,
21
+ values,
22
+ fieldIndex
23
+ });
24
+
25
+ const idPostfix = `-${attribute.name}-${fieldIndex + 1}`;
26
+
27
+ return (
28
+ <div className="flex items-center gap-2 mt-2">
29
+ {hasRemove && (
30
+ <Button
31
+ id={`kc-remove${idPostfix}`}
32
+ type="button"
33
+ variant="ghost"
34
+ size="sm"
35
+ onClick={() =>
36
+ dispatchFormAction({
37
+ action: "update",
38
+ name: attribute.name,
39
+ valueOrValues: values.filter((_, i) => i !== fieldIndex)
40
+ })
41
+ }
42
+ >
43
+ {msg("remove")}
44
+ </Button>
45
+ )}
46
+ {hasAdd && (
47
+ <Button
48
+ id={`kc-add${idPostfix}`}
49
+ type="button"
50
+ variant="outline"
51
+ size="sm"
52
+ onClick={() =>
53
+ dispatchFormAction({
54
+ action: "update",
55
+ name: attribute.name,
56
+ valueOrValues: [...values, ""]
57
+ })
58
+ }
59
+ >
60
+ {msg("addValue")}
61
+ </Button>
62
+ )}
63
+ </div>
64
+ );
65
+ }
@@ -1,2 +1,2 @@
1
- // Change this to true to disable the confirm password field
2
- export const DO_MAKE_USER_CONFIRM_PASSWORD = true;
1
+ // Change this to true to disable the confirm password field
2
+ export const DO_MAKE_USER_CONFIRM_PASSWORD = true;
@@ -1,29 +1,33 @@
1
- import { FieldError } from '@/components/ui/field';
2
- import type { Attribute } from "@keycloakify/login-ui/KcContext";
3
- import type { FormFieldError } from "@keycloakify/login-ui/useUserProfileForm";
4
- import { Fragment } from "react";
5
-
6
- export function FieldErrors(props: {
7
- attribute: Attribute;
8
- displayableErrors: FormFieldError[];
9
- fieldIndex: number | undefined;
10
- }) {
11
- const { attribute, fieldIndex } = props;
12
-
13
- const displayableErrors = props.displayableErrors.filter(error => error.fieldIndex === fieldIndex);
14
-
15
- if (displayableErrors.length === 0) {
16
- return null;
17
- }
18
-
19
- return (
20
- <FieldError id={`input-error-${attribute.name}${fieldIndex === undefined ? "" : `-${fieldIndex}`}`}>
21
- {displayableErrors.map(({ errorMessage }, i, arr) => (
22
- <Fragment key={i}>
23
- {errorMessage}
24
- {arr.length - 1 !== i && <br />}
25
- </Fragment>
26
- ))}
27
- </FieldError>
28
- );
29
- }
1
+ import { FieldError } from "@/components/ui/field";
2
+ import type { Attribute } from "@keycloakify/login-ui/KcContext";
3
+ import type { FormFieldError } from "@keycloakify/login-ui/useUserProfileForm";
4
+ import { Fragment } from "react";
5
+
6
+ export function FieldErrors(props: {
7
+ attribute: Attribute;
8
+ displayableErrors: FormFieldError[];
9
+ fieldIndex: number | undefined;
10
+ }) {
11
+ const { attribute, fieldIndex } = props;
12
+
13
+ const displayableErrors = props.displayableErrors.filter(
14
+ error => error.fieldIndex === fieldIndex
15
+ );
16
+
17
+ if (displayableErrors.length === 0) {
18
+ return null;
19
+ }
20
+
21
+ return (
22
+ <FieldError
23
+ id={`input-error-${attribute.name}${fieldIndex === undefined ? "" : `-${fieldIndex}`}`}
24
+ >
25
+ {displayableErrors.map(({ errorMessage }, i, arr) => (
26
+ <Fragment key={i}>
27
+ {errorMessage}
28
+ {arr.length - 1 !== i && <br />}
29
+ </Fragment>
30
+ ))}
31
+ </FieldError>
32
+ );
33
+ }
@@ -1,71 +1,90 @@
1
-
2
-
3
- import { cn } from '@/components/lib/utils';
4
- import { useI18n } from '@/login/i18n';
5
- import type { Attribute } from "@keycloakify/login-ui/KcContext";
6
- import { useKcClsx } from '@keycloakify/login-ui/useKcClsx';
7
- import { assert } from "tsafe/assert";
8
-
9
- export function GroupLabel(props: {
10
- attribute: Attribute;
11
- groupNameRef: {
12
- current: string;
13
- };
14
- }) {
15
- const { attribute, groupNameRef } = props;
16
-
17
- const { advancedMsg } = useI18n();
18
-
19
- const { kcClsx } = useKcClsx();
20
-
21
-
22
- if (attribute.group?.name !== groupNameRef.current) {
23
- groupNameRef.current = attribute.group?.name ?? "";
24
-
25
- if (groupNameRef.current !== "") {
26
- assert(attribute.group !== undefined);
27
-
28
- return (
29
- <div
30
- className={cn("space-y-4 p-4 border rounded-lg bg-card", kcClsx("kcFormGroupClass"))}
31
- {...Object.fromEntries(Object.entries(attribute.group.html5DataAnnotations).map(([key, value]) => [`data-${key}`, value]))}
32
- >
33
- {(() => {
34
- const groupDisplayHeader = attribute.group.displayHeader ?? "";
35
- const groupHeaderText = groupDisplayHeader !== "" ? advancedMsg(groupDisplayHeader) : attribute.group.name;
36
-
37
- return (
38
- <div className={cn("", kcClsx("kcContentWrapperClass"))}>
39
- <h3 id={`header-${attribute.group.name}`} className={cn("text-lg font-semibold", kcClsx("kcFormGroupHeader"))}>
40
- {groupHeaderText}
41
- </h3>
42
- </div>
43
- );
44
- })()}
45
- {(() => {
46
- const groupDisplayDescription = attribute.group.displayDescription ?? "";
47
-
48
- if (groupDisplayDescription !== "") {
49
- const groupDescriptionText = advancedMsg(groupDisplayDescription);
50
-
51
- return (
52
- <div className={cn("", kcClsx("kcLabelWrapperClass"))}>
53
- <p
54
- id={`description-${attribute.group.name}`}
55
- className={cn("text-sm text-muted-foreground", kcClsx("kcLabelClass"))}
56
- >
57
- {groupDescriptionText}
58
- </p>
59
- </div>
60
- );
61
- }
62
-
63
- return null;
64
- })()}
65
- </div>
66
- );
67
- }
68
- }
69
-
70
- return null;
71
- }
1
+ import { cn } from "@/components/lib/utils";
2
+ import { useI18n } from "@/login/i18n";
3
+ import type { Attribute } from "@keycloakify/login-ui/KcContext";
4
+ import { useKcClsx } from "@keycloakify/login-ui/useKcClsx";
5
+ import { assert } from "tsafe/assert";
6
+
7
+ export function GroupLabel(props: {
8
+ attribute: Attribute;
9
+ groupNameRef: {
10
+ current: string;
11
+ };
12
+ }) {
13
+ const { attribute, groupNameRef } = props;
14
+
15
+ const { advancedMsg } = useI18n();
16
+
17
+ const { kcClsx } = useKcClsx();
18
+
19
+ if (attribute.group?.name !== groupNameRef.current) {
20
+ groupNameRef.current = attribute.group?.name ?? "";
21
+
22
+ if (groupNameRef.current !== "") {
23
+ assert(attribute.group !== undefined);
24
+
25
+ return (
26
+ <div
27
+ className={cn(
28
+ "space-y-4 p-4 border rounded-lg bg-card",
29
+ kcClsx("kcFormGroupClass")
30
+ )}
31
+ {...Object.fromEntries(
32
+ Object.entries(attribute.group.html5DataAnnotations).map(
33
+ ([key, value]) => [`data-${key}`, value]
34
+ )
35
+ )}
36
+ >
37
+ {(() => {
38
+ const groupDisplayHeader = attribute.group.displayHeader ?? "";
39
+ const groupHeaderText =
40
+ groupDisplayHeader !== ""
41
+ ? advancedMsg(groupDisplayHeader)
42
+ : attribute.group.name;
43
+
44
+ return (
45
+ <div className={cn("", kcClsx("kcContentWrapperClass"))}>
46
+ <h3
47
+ id={`header-${attribute.group.name}`}
48
+ className={cn(
49
+ "text-lg font-semibold",
50
+ kcClsx("kcFormGroupHeader")
51
+ )}
52
+ >
53
+ {groupHeaderText}
54
+ </h3>
55
+ </div>
56
+ );
57
+ })()}
58
+ {(() => {
59
+ const groupDisplayDescription =
60
+ attribute.group.displayDescription ?? "";
61
+
62
+ if (groupDisplayDescription !== "") {
63
+ const groupDescriptionText = advancedMsg(
64
+ groupDisplayDescription
65
+ );
66
+
67
+ return (
68
+ <div className={cn("", kcClsx("kcLabelWrapperClass"))}>
69
+ <p
70
+ id={`description-${attribute.group.name}`}
71
+ className={cn(
72
+ "text-sm text-muted-foreground",
73
+ kcClsx("kcLabelClass")
74
+ )}
75
+ >
76
+ {groupDescriptionText}
77
+ </p>
78
+ </div>
79
+ );
80
+ }
81
+
82
+ return null;
83
+ })()}
84
+ </div>
85
+ );
86
+ }
87
+ }
88
+
89
+ return null;
90
+ }
@@ -1,59 +1,66 @@
1
- import type { Attribute } from "@keycloakify/login-ui/KcContext";
2
- import type {
3
- FormAction,
4
- FormFieldError
5
- } from "@keycloakify/login-ui/useUserProfileForm";
6
- import { PasswordWrapper } from "../PasswordWrapper";
7
- import { InputTag } from "./InputTag";
8
- import { InputTagSelects } from "./InputTagSelects";
9
- import { SelectTag } from "./SelectTag";
10
- import { TextareaTag } from "./TextareaTag";
11
-
12
- export type InputFieldByTypeProps = {
13
- attribute: Attribute;
14
- valueOrValues: string | string[];
15
- displayableErrors: FormFieldError[];
16
- dispatchFormAction: React.Dispatch<FormAction>;
17
- };
18
-
19
- export function InputFieldByType(props: InputFieldByTypeProps) {
20
- const { attribute, valueOrValues } = props;
21
-
22
- switch (attribute.annotations.inputType) {
23
- // NOTE: Unfortunately, keycloak won't let you define input type="hidden" in the Admin Console.
24
- // sometimes in the future it might.
25
- case "hidden":
26
- return <input type="hidden" id={attribute.name} name={attribute.name} value={valueOrValues as string} />;
27
- case "textarea":
28
- return <TextareaTag {...props} />;
29
- case "select":
30
- case "multiselect":
31
- return <SelectTag {...props} />;
32
- case "select-radiobuttons":
33
- case "multiselect-checkboxes":
34
- return <InputTagSelects {...props} />;
35
- default: {
36
- if (valueOrValues instanceof Array) {
37
- return (
38
- <>
39
- {valueOrValues.map((...[, i]) => (
40
- <InputTag key={i} {...props} fieldIndex={i} />
41
- ))}
42
- </>
43
- );
44
- }
45
-
46
- const inputNode = <InputTag {...props} fieldIndex={undefined} />;
47
-
48
- if (attribute.name === "password" || attribute.name === "password-confirm") {
49
- return (
50
- <PasswordWrapper passwordInputId={attribute.name}>
51
- {inputNode}
52
- </PasswordWrapper>
53
- );
54
- }
55
-
56
- return inputNode;
57
- }
58
- }
59
- }
1
+ import type { Attribute } from "@keycloakify/login-ui/KcContext";
2
+ import type {
3
+ FormAction,
4
+ FormFieldError
5
+ } from "@keycloakify/login-ui/useUserProfileForm";
6
+ import { PasswordWrapper } from "../PasswordWrapper";
7
+ import { InputTag } from "./InputTag";
8
+ import { InputTagSelects } from "./InputTagSelects";
9
+ import { SelectTag } from "./SelectTag";
10
+ import { TextareaTag } from "./TextareaTag";
11
+
12
+ export type InputFieldByTypeProps = {
13
+ attribute: Attribute;
14
+ valueOrValues: string | string[];
15
+ displayableErrors: FormFieldError[];
16
+ dispatchFormAction: React.Dispatch<FormAction>;
17
+ };
18
+
19
+ export function InputFieldByType(props: InputFieldByTypeProps) {
20
+ const { attribute, valueOrValues } = props;
21
+
22
+ switch (attribute.annotations.inputType) {
23
+ // NOTE: Unfortunately, keycloak won't let you define input type="hidden" in the Admin Console.
24
+ // sometimes in the future it might.
25
+ case "hidden":
26
+ return (
27
+ <input
28
+ type="hidden"
29
+ id={attribute.name}
30
+ name={attribute.name}
31
+ value={valueOrValues as string}
32
+ />
33
+ );
34
+ case "textarea":
35
+ return <TextareaTag {...props} />;
36
+ case "select":
37
+ case "multiselect":
38
+ return <SelectTag {...props} />;
39
+ case "select-radiobuttons":
40
+ case "multiselect-checkboxes":
41
+ return <InputTagSelects {...props} />;
42
+ default: {
43
+ if (valueOrValues instanceof Array) {
44
+ return (
45
+ <>
46
+ {valueOrValues.map((...[, i]) => (
47
+ <InputTag key={i} {...props} fieldIndex={i} />
48
+ ))}
49
+ </>
50
+ );
51
+ }
52
+
53
+ const inputNode = <InputTag {...props} fieldIndex={undefined} />;
54
+
55
+ if (attribute.name === "password" || attribute.name === "password-confirm") {
56
+ return (
57
+ <PasswordWrapper passwordInputId={attribute.name}>
58
+ {inputNode}
59
+ </PasswordWrapper>
60
+ );
61
+ }
62
+
63
+ return inputNode;
64
+ }
65
+ }
66
+ }
@@ -1,4 +1,3 @@
1
-
2
1
  import type { Attribute } from "@keycloakify/login-ui/KcContext";
3
2
  import { useI18n } from "../../i18n";
4
3