keycloakify 10.0.0-rc.36 → 10.0.0-rc.38

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 (272) hide show
  1. package/account/Fallback.d.ts +1 -2
  2. package/account/Fallback.js.map +1 -1
  3. package/account/KcContext/KcContext.d.ts +6 -6
  4. package/account/KcContext/getKcContextMock.d.ts +9 -9
  5. package/account/KcContext/getKcContextMock.js +3 -3
  6. package/account/KcContext/getKcContextMock.js.map +1 -1
  7. package/account/Template.d.ts +1 -2
  8. package/account/Template.js +7 -6
  9. package/account/Template.js.map +1 -1
  10. package/account/TemplateProps.d.ts +1 -3
  11. package/account/i18n/i18n.d.ts +9 -4
  12. package/account/i18n/i18n.js +132 -87
  13. package/account/i18n/i18n.js.map +1 -1
  14. package/account/i18n/index.d.ts +9 -2
  15. package/account/i18n/index.js +5 -1
  16. package/account/i18n/index.js.map +1 -1
  17. package/account/index.d.ts +1 -1
  18. package/account/lib/kcClsx.d.ts +9 -0
  19. package/account/lib/{useGetClassName.js → kcClsx.js} +3 -3
  20. package/account/lib/kcClsx.js.map +1 -0
  21. package/account/pages/Account.d.ts +1 -2
  22. package/account/pages/Account.js +9 -7
  23. package/account/pages/Account.js.map +1 -1
  24. package/account/pages/Applications.d.ts +1 -2
  25. package/account/pages/Applications.js +7 -7
  26. package/account/pages/Applications.js.map +1 -1
  27. package/account/pages/FederatedIdentity.d.ts +1 -2
  28. package/account/pages/FederatedIdentity.js +4 -3
  29. package/account/pages/FederatedIdentity.js.map +1 -1
  30. package/account/pages/Log.d.ts +1 -2
  31. package/account/pages/Log.js +6 -5
  32. package/account/pages/Log.js.map +1 -1
  33. package/account/pages/PageProps.d.ts +2 -4
  34. package/account/pages/Password.d.ts +1 -2
  35. package/account/pages/Password.js +10 -9
  36. package/account/pages/Password.js.map +1 -1
  37. package/account/pages/Sessions.d.ts +1 -2
  38. package/account/pages/Sessions.js +6 -6
  39. package/account/pages/Sessions.js.map +1 -1
  40. package/account/pages/Totp.d.ts +1 -2
  41. package/account/pages/Totp.js +6 -5
  42. package/account/pages/Totp.js.map +1 -1
  43. package/bin/{314.index.js → 21.index.js} +162 -4
  44. package/bin/{430.index.js → 214.index.js} +161 -2
  45. package/bin/3.index.js +81 -65
  46. package/bin/526.index.js +3 -2
  47. package/bin/538.index.js +552 -0
  48. package/bin/795.index.js +3 -2
  49. package/bin/{890.index.js → 941.index.js} +2 -159
  50. package/bin/main.js +19 -7
  51. package/lib/getKcClsx.d.ts +11 -0
  52. package/lib/getKcClsx.js +44 -0
  53. package/lib/getKcClsx.js.map +1 -0
  54. package/login/Fallback.d.ts +1 -2
  55. package/login/Fallback.js.map +1 -1
  56. package/login/KcContext/KcContext.d.ts +6 -6
  57. package/login/KcContext/getKcContextMock.d.ts +9 -9
  58. package/login/KcContext/getKcContextMock.js +3 -3
  59. package/login/KcContext/getKcContextMock.js.map +1 -1
  60. package/login/Template.d.ts +1 -2
  61. package/login/Template.js +10 -9
  62. package/login/Template.js.map +1 -1
  63. package/login/TemplateProps.d.ts +1 -3
  64. package/login/UserProfileFormFields.d.ts +5 -5
  65. package/login/UserProfileFormFields.js +35 -34
  66. package/login/UserProfileFormFields.js.map +1 -1
  67. package/login/i18n/i18n.d.ts +9 -4
  68. package/login/i18n/i18n.js +136 -91
  69. package/login/i18n/i18n.js.map +1 -1
  70. package/login/i18n/index.d.ts +9 -2
  71. package/login/i18n/index.js +5 -1
  72. package/login/i18n/index.js.map +1 -1
  73. package/login/index.d.ts +1 -1
  74. package/login/lib/kcClsx.d.ts +9 -0
  75. package/login/lib/{useGetClassName.js → kcClsx.js} +3 -3
  76. package/login/lib/kcClsx.js.map +1 -0
  77. package/login/lib/useUserProfileForm.d.ts +9 -6
  78. package/login/lib/useUserProfileForm.js +7 -5
  79. package/login/lib/useUserProfileForm.js.map +1 -1
  80. package/login/pages/Code.d.ts +1 -2
  81. package/login/pages/Code.js +6 -5
  82. package/login/pages/Code.js.map +1 -1
  83. package/login/pages/DeleteAccountConfirm.d.ts +1 -2
  84. package/login/pages/DeleteAccountConfirm.js +7 -7
  85. package/login/pages/DeleteAccountConfirm.js.map +1 -1
  86. package/login/pages/DeleteCredential.d.ts +1 -2
  87. package/login/pages/DeleteCredential.js +6 -6
  88. package/login/pages/DeleteCredential.js.map +1 -1
  89. package/login/pages/Error.d.ts +1 -2
  90. package/login/pages/Error.js +4 -3
  91. package/login/pages/Error.js.map +1 -1
  92. package/login/pages/FrontchannelLogout.d.ts +1 -2
  93. package/login/pages/FrontchannelLogout.js +4 -3
  94. package/login/pages/FrontchannelLogout.js.map +1 -1
  95. package/login/pages/IdpReviewUserProfile.d.ts +1 -2
  96. package/login/pages/IdpReviewUserProfile.js +6 -6
  97. package/login/pages/IdpReviewUserProfile.js.map +1 -1
  98. package/login/pages/Info.d.ts +1 -2
  99. package/login/pages/Info.js +4 -3
  100. package/login/pages/Info.js.map +1 -1
  101. package/login/pages/Login.d.ts +1 -2
  102. package/login/pages/Login.js +10 -8
  103. package/login/pages/Login.js.map +1 -1
  104. package/login/pages/LoginConfigTotp.d.ts +1 -2
  105. package/login/pages/LoginConfigTotp.js +8 -7
  106. package/login/pages/LoginConfigTotp.js.map +1 -1
  107. package/login/pages/LoginIdpLinkConfirm.d.ts +1 -2
  108. package/login/pages/LoginIdpLinkConfirm.js +6 -6
  109. package/login/pages/LoginIdpLinkConfirm.js.map +1 -1
  110. package/login/pages/LoginIdpLinkEmail.d.ts +1 -2
  111. package/login/pages/LoginIdpLinkEmail.js +4 -3
  112. package/login/pages/LoginIdpLinkEmail.js.map +1 -1
  113. package/login/pages/LoginOauth2DeviceVerifyUserCode.d.ts +1 -2
  114. package/login/pages/LoginOauth2DeviceVerifyUserCode.js +6 -6
  115. package/login/pages/LoginOauth2DeviceVerifyUserCode.js.map +1 -1
  116. package/login/pages/LoginOauthGrant.d.ts +1 -2
  117. package/login/pages/LoginOauthGrant.js +7 -7
  118. package/login/pages/LoginOauthGrant.js.map +1 -1
  119. package/login/pages/LoginOtp.d.ts +1 -2
  120. package/login/pages/LoginOtp.js +6 -6
  121. package/login/pages/LoginOtp.js.map +1 -1
  122. package/login/pages/LoginPageExpired.d.ts +1 -2
  123. package/login/pages/LoginPageExpired.js +4 -3
  124. package/login/pages/LoginPageExpired.js.map +1 -1
  125. package/login/pages/LoginPassword.d.ts +1 -2
  126. package/login/pages/LoginPassword.js +9 -7
  127. package/login/pages/LoginPassword.js.map +1 -1
  128. package/login/pages/LoginRecoveryAuthnCodeConfig.d.ts +1 -2
  129. package/login/pages/LoginRecoveryAuthnCodeConfig.js +9 -7
  130. package/login/pages/LoginRecoveryAuthnCodeConfig.js.map +1 -1
  131. package/login/pages/LoginRecoveryAuthnCodeInput.d.ts +1 -2
  132. package/login/pages/LoginRecoveryAuthnCodeInput.js +6 -6
  133. package/login/pages/LoginRecoveryAuthnCodeInput.js.map +1 -1
  134. package/login/pages/LoginResetOtp.d.ts +1 -2
  135. package/login/pages/LoginResetOtp.js +6 -6
  136. package/login/pages/LoginResetOtp.js.map +1 -1
  137. package/login/pages/LoginResetPassword.d.ts +1 -2
  138. package/login/pages/LoginResetPassword.js +7 -7
  139. package/login/pages/LoginResetPassword.js.map +1 -1
  140. package/login/pages/LoginUpdatePassword.d.ts +1 -2
  141. package/login/pages/LoginUpdatePassword.js +10 -9
  142. package/login/pages/LoginUpdatePassword.js.map +1 -1
  143. package/login/pages/LoginUpdateProfile.d.ts +1 -2
  144. package/login/pages/LoginUpdateProfile.js +7 -12
  145. package/login/pages/LoginUpdateProfile.js.map +1 -1
  146. package/login/pages/LoginUsername.d.ts +1 -2
  147. package/login/pages/LoginUsername.js +8 -7
  148. package/login/pages/LoginUsername.js.map +1 -1
  149. package/login/pages/LoginVerifyEmail.d.ts +1 -2
  150. package/login/pages/LoginVerifyEmail.js +4 -3
  151. package/login/pages/LoginVerifyEmail.js.map +1 -1
  152. package/login/pages/LoginX509Info.d.ts +1 -2
  153. package/login/pages/LoginX509Info.js +6 -6
  154. package/login/pages/LoginX509Info.js.map +1 -1
  155. package/login/pages/LogoutConfirm.d.ts +1 -2
  156. package/login/pages/LogoutConfirm.js +6 -6
  157. package/login/pages/LogoutConfirm.js.map +1 -1
  158. package/login/pages/PageProps.d.ts +2 -4
  159. package/login/pages/Register.d.ts +1 -2
  160. package/login/pages/Register.js +8 -16
  161. package/login/pages/Register.js.map +1 -1
  162. package/login/pages/SamlPostForm.d.ts +1 -2
  163. package/login/pages/SamlPostForm.js +4 -3
  164. package/login/pages/SamlPostForm.js.map +1 -1
  165. package/login/pages/SelectAuthenticator.d.ts +1 -2
  166. package/login/pages/SelectAuthenticator.js +6 -9
  167. package/login/pages/SelectAuthenticator.js.map +1 -1
  168. package/login/pages/Terms.d.ts +1 -2
  169. package/login/pages/Terms.js +7 -7
  170. package/login/pages/Terms.js.map +1 -1
  171. package/login/pages/UpdateEmail.d.ts +1 -2
  172. package/login/pages/UpdateEmail.js +8 -12
  173. package/login/pages/UpdateEmail.js.map +1 -1
  174. package/login/pages/WebauthnAuthenticate.d.ts +1 -2
  175. package/login/pages/WebauthnAuthenticate.js +13 -12
  176. package/login/pages/WebauthnAuthenticate.js.map +1 -1
  177. package/login/pages/WebauthnError.d.ts +1 -2
  178. package/login/pages/WebauthnError.js +7 -7
  179. package/login/pages/WebauthnError.js.map +1 -1
  180. package/login/pages/WebauthnRegister.d.ts +1 -2
  181. package/login/pages/WebauthnRegister.js +9 -8
  182. package/login/pages/WebauthnRegister.js.map +1 -1
  183. package/package.json +24 -16
  184. package/src/account/Fallback.tsx +1 -2
  185. package/src/account/KcContext/KcContext.ts +7 -7
  186. package/src/account/KcContext/getKcContextMock.ts +13 -24
  187. package/src/account/Template.tsx +8 -8
  188. package/src/account/TemplateProps.ts +1 -6
  189. package/src/account/i18n/i18n.tsx +204 -125
  190. package/src/account/i18n/index.ts +10 -2
  191. package/src/account/index.ts +1 -1
  192. package/src/account/lib/{useGetClassName.ts → kcClsx.ts} +6 -2
  193. package/src/account/pages/Account.tsx +15 -21
  194. package/src/account/pages/Applications.tsx +8 -9
  195. package/src/account/pages/FederatedIdentity.tsx +5 -5
  196. package/src/account/pages/Log.tsx +8 -8
  197. package/src/account/pages/PageProps.ts +2 -4
  198. package/src/account/pages/Password.tsx +13 -16
  199. package/src/account/pages/Sessions.tsx +9 -10
  200. package/src/account/pages/Totp.tsx +19 -28
  201. package/src/bin/keycloakify/generateSrcMainResources/generateMessageProperties.ts +2 -66
  202. package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResourcesForMainTheme.ts +7 -1
  203. package/src/bin/main.ts +15 -0
  204. package/src/bin/shared/buildOptions.ts +5 -2
  205. package/src/bin/shared/generateKcGenTs.ts +61 -0
  206. package/src/bin/tools/escapeStringForPropertiesFile.ts +64 -0
  207. package/src/bin/update-kc-gen.ts +13 -0
  208. package/src/lib/getKcClsx.ts +75 -0
  209. package/src/login/Fallback.tsx +1 -2
  210. package/src/login/KcContext/KcContext.ts +7 -7
  211. package/src/login/KcContext/getKcContextMock.ts +13 -24
  212. package/src/login/Template.tsx +36 -37
  213. package/src/login/TemplateProps.ts +1 -6
  214. package/src/login/UserProfileFormFields.tsx +66 -81
  215. package/src/login/i18n/i18n.tsx +208 -129
  216. package/src/login/i18n/index.ts +10 -2
  217. package/src/login/index.ts +1 -1
  218. package/src/login/lib/{useGetClassName.ts → kcClsx.ts} +6 -2
  219. package/src/login/lib/useUserProfileForm.tsx +29 -21
  220. package/src/login/pages/Code.tsx +10 -8
  221. package/src/login/pages/DeleteAccountConfirm.tsx +9 -10
  222. package/src/login/pages/DeleteCredential.tsx +11 -10
  223. package/src/login/pages/Error.tsx +5 -5
  224. package/src/login/pages/FrontchannelLogout.tsx +7 -5
  225. package/src/login/pages/IdpReviewUserProfile.tsx +16 -25
  226. package/src/login/pages/Info.tsx +7 -5
  227. package/src/login/pages/Login.tsx +34 -53
  228. package/src/login/pages/LoginConfigTotp.tsx +30 -38
  229. package/src/login/pages/LoginIdpLinkConfirm.tsx +10 -21
  230. package/src/login/pages/LoginIdpLinkEmail.tsx +5 -5
  231. package/src/login/pages/LoginOauth2DeviceVerifyUserCode.tsx +19 -24
  232. package/src/login/pages/LoginOauthGrant.tsx +14 -21
  233. package/src/login/pages/LoginOtp.tsx +29 -33
  234. package/src/login/pages/LoginPageExpired.tsx +5 -5
  235. package/src/login/pages/LoginPassword.tsx +23 -33
  236. package/src/login/pages/LoginRecoveryAuthnCodeConfig.tsx +21 -25
  237. package/src/login/pages/LoginRecoveryAuthnCodeInput.tsx +21 -25
  238. package/src/login/pages/LoginResetOtp.tsx +21 -25
  239. package/src/login/pages/LoginResetPassword.tsx +21 -25
  240. package/src/login/pages/LoginUpdatePassword.tsx +42 -52
  241. package/src/login/pages/LoginUpdateProfile.tsx +26 -33
  242. package/src/login/pages/LoginUsername.tsx +23 -35
  243. package/src/login/pages/LoginVerifyEmail.tsx +7 -5
  244. package/src/login/pages/LoginX509Info.tsx +27 -36
  245. package/src/login/pages/LogoutConfirm.tsx +11 -17
  246. package/src/login/pages/PageProps.ts +2 -4
  247. package/src/login/pages/Register.tsx +24 -49
  248. package/src/login/pages/SamlPostForm.tsx +5 -5
  249. package/src/login/pages/SelectAuthenticator.tsx +24 -26
  250. package/src/login/pages/Terms.tsx +11 -18
  251. package/src/login/pages/UpdateEmail.tsx +26 -36
  252. package/src/login/pages/WebauthnAuthenticate.tsx +26 -32
  253. package/src/login/pages/WebauthnError.tsx +11 -22
  254. package/src/login/pages/WebauthnRegister.tsx +20 -28
  255. package/src/tools/clsx.ts +6 -48
  256. package/src/tools/clsx_withTransform.ts +55 -0
  257. package/src/vite-plugin/vite-plugin.ts +14 -6
  258. package/tools/clsx.d.ts +3 -2
  259. package/tools/clsx.js +5 -41
  260. package/tools/clsx.js.map +1 -1
  261. package/tools/clsx_withTransform.d.ts +5 -0
  262. package/tools/clsx_withTransform.js +43 -0
  263. package/tools/clsx_withTransform.js.map +1 -0
  264. package/vite-plugin/index.js +167 -37
  265. package/account/lib/useGetClassName.d.ts +0 -7
  266. package/account/lib/useGetClassName.js.map +0 -1
  267. package/lib/useGetClassName.d.ts +0 -10
  268. package/lib/useGetClassName.js +0 -14
  269. package/lib/useGetClassName.js.map +0 -1
  270. package/login/lib/useGetClassName.d.ts +0 -7
  271. package/login/lib/useGetClassName.js.map +0 -1
  272. package/src/lib/useGetClassName.ts +0 -27
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useReducer, Fragment } from "react";
2
2
  import { assert } from "tsafe/assert";
3
- import type { ClassKey } from "keycloakify/login/TemplateProps";
3
+ import type { KcClsx } from "keycloakify/login/lib/kcClsx";
4
4
  import {
5
5
  useUserProfileForm,
6
6
  getButtonToDisplayForMultivaluedAttributeField,
@@ -9,12 +9,11 @@ import {
9
9
  type FormFieldError
10
10
  } from "keycloakify/login/lib/useUserProfileForm";
11
11
  import type { Attribute } from "keycloakify/login/KcContext";
12
- import type { I18n } from "./i18n";
12
+ import { useI18n, type I18n } from "./i18n";
13
13
 
14
14
  export type UserProfileFormFieldsProps = {
15
15
  kcContext: KcContextLike;
16
- i18n: I18n;
17
- getClassName: (classKey: ClassKey) => string;
16
+ kcClsx: KcClsx;
18
17
  onIsFormSubmittableValueChange: (isFormSubmittable: boolean) => void;
19
18
  BeforeField?: (props: BeforeAfterFieldProps) => JSX.Element | null;
20
19
  AfterField?: (props: BeforeAfterFieldProps) => JSX.Element | null;
@@ -24,24 +23,24 @@ type BeforeAfterFieldProps = {
24
23
  attribute: Attribute;
25
24
  dispatchFormAction: React.Dispatch<FormAction>;
26
25
  displayableErrors: FormFieldError[];
27
- i18n: I18n;
28
26
  valueOrValues: string | string[];
27
+ kcClsx: KcClsx;
28
+ i18n: I18n;
29
29
  };
30
30
 
31
31
  // NOTE: Enabled by default but it's a UX best practice to set it to false.
32
32
  const doMakeUserConfirmPassword = true;
33
33
 
34
34
  export default function UserProfileFormFields(props: UserProfileFormFieldsProps) {
35
- const { kcContext, onIsFormSubmittableValueChange, i18n, getClassName, BeforeField, AfterField } = props;
35
+ const { kcContext, kcClsx, onIsFormSubmittableValueChange, BeforeField, AfterField } = props;
36
36
 
37
- const { advancedMsg } = i18n;
37
+ const { advancedMsg } = useI18n({ kcContext });
38
38
 
39
39
  const {
40
40
  formState: { formFieldStates, isFormSubmittable },
41
41
  dispatchFormAction
42
42
  } = useUserProfileForm({
43
43
  kcContext,
44
- i18n,
45
44
  doMakeUserConfirmPassword
46
45
  });
47
46
 
@@ -49,6 +48,8 @@ export default function UserProfileFormFields(props: UserProfileFormFieldsProps)
49
48
  onIsFormSubmittableValueChange(isFormSubmittable);
50
49
  }, [isFormSubmittable]);
51
50
 
51
+ const i18n = useI18n({ kcContext });
52
+
52
53
  const groupNameRef = { current: "" };
53
54
 
54
55
  return (
@@ -56,32 +57,33 @@ export default function UserProfileFormFields(props: UserProfileFormFieldsProps)
56
57
  {formFieldStates.map(({ attribute, displayableErrors, valueOrValues }) => {
57
58
  return (
58
59
  <Fragment key={attribute.name}>
59
- <GroupLabel attribute={attribute} getClassName={getClassName} i18n={i18n} groupNameRef={groupNameRef} />
60
+ <GroupLabel attribute={attribute} groupNameRef={groupNameRef} i18n={i18n} kcClsx={kcClsx} />
60
61
  {BeforeField !== undefined && (
61
62
  <BeforeField
62
63
  attribute={attribute}
63
64
  dispatchFormAction={dispatchFormAction}
64
65
  displayableErrors={displayableErrors}
65
- i18n={i18n}
66
66
  valueOrValues={valueOrValues}
67
+ kcClsx={kcClsx}
68
+ i18n={i18n}
67
69
  />
68
70
  )}
69
71
  <div
70
- className={getClassName("kcFormGroupClass")}
72
+ className={kcClsx("kcFormGroupClass")}
71
73
  style={{
72
74
  display: attribute.name === "password-confirm" && !doMakeUserConfirmPassword ? "none" : undefined
73
75
  }}
74
76
  >
75
- <div className={getClassName("kcLabelWrapperClass")}>
76
- <label htmlFor={attribute.name} className={getClassName("kcLabelClass")}>
77
+ <div className={kcClsx("kcLabelWrapperClass")}>
78
+ <label htmlFor={attribute.name} className={kcClsx("kcLabelClass")}>
77
79
  {advancedMsg(attribute.displayName ?? "")}
78
80
  </label>
79
81
  {attribute.required && <>*</>}
80
82
  </div>
81
- <div className={getClassName("kcInputWrapperClass")}>
83
+ <div className={kcClsx("kcInputWrapperClass")}>
82
84
  {attribute.annotations.inputHelperTextBefore !== undefined && (
83
85
  <div
84
- className={getClassName("kcInputHelperTextBeforeClass")}
86
+ className={kcClsx("kcInputHelperTextBeforeClass")}
85
87
  id={`form-help-text-before-${attribute.name}`}
86
88
  aria-live="polite"
87
89
  >
@@ -92,19 +94,14 @@ export default function UserProfileFormFields(props: UserProfileFormFieldsProps)
92
94
  attribute={attribute}
93
95
  valueOrValues={valueOrValues}
94
96
  displayableErrors={displayableErrors}
95
- formValidationDispatch={dispatchFormAction}
96
- getClassName={getClassName}
97
+ dispatchFormAction={dispatchFormAction}
98
+ kcClsx={kcClsx}
97
99
  i18n={i18n}
98
100
  />
99
- <FieldErrors
100
- attribute={attribute}
101
- getClassName={getClassName}
102
- displayableErrors={displayableErrors}
103
- fieldIndex={undefined}
104
- />
101
+ <FieldErrors attribute={attribute} displayableErrors={displayableErrors} kcClsx={kcClsx} fieldIndex={undefined} />
105
102
  {attribute.annotations.inputHelperTextAfter !== undefined && (
106
103
  <div
107
- className={getClassName("kcInputHelperTextAfterClass")}
104
+ className={kcClsx("kcInputHelperTextAfterClass")}
108
105
  id={`form-help-text-after-${attribute.name}`}
109
106
  aria-live="polite"
110
107
  >
@@ -117,8 +114,9 @@ export default function UserProfileFormFields(props: UserProfileFormFieldsProps)
117
114
  attribute={attribute}
118
115
  dispatchFormAction={dispatchFormAction}
119
116
  displayableErrors={displayableErrors}
120
- i18n={i18n}
121
117
  valueOrValues={valueOrValues}
118
+ kcClsx={kcClsx}
119
+ i18n={i18n}
122
120
  />
123
121
  )}
124
122
  {/* NOTE: Downloading of html5DataAnnotations scripts is done in the useUserProfileForm hook */}
@@ -133,13 +131,13 @@ export default function UserProfileFormFields(props: UserProfileFormFieldsProps)
133
131
 
134
132
  function GroupLabel(props: {
135
133
  attribute: Attribute;
136
- getClassName: UserProfileFormFieldsProps["getClassName"];
137
- i18n: I18n;
138
134
  groupNameRef: {
139
135
  current: string;
140
136
  };
137
+ i18n: I18n;
138
+ kcClsx: KcClsx;
141
139
  }) {
142
- const { attribute, getClassName, i18n, groupNameRef } = props;
140
+ const { attribute, groupNameRef, i18n, kcClsx } = props;
143
141
 
144
142
  const { advancedMsg } = i18n;
145
143
 
@@ -151,7 +149,7 @@ function GroupLabel(props: {
151
149
 
152
150
  return (
153
151
  <div
154
- className={getClassName("kcFormGroupClass")}
152
+ className={kcClsx("kcFormGroupClass")}
155
153
  {...Object.fromEntries(Object.entries(attribute.group.html5DataAnnotations).map(([key, value]) => [`data-${key}`, value]))}
156
154
  >
157
155
  {(() => {
@@ -159,8 +157,8 @@ function GroupLabel(props: {
159
157
  const groupHeaderText = groupDisplayHeader !== "" ? advancedMsg(groupDisplayHeader) : attribute.group.name;
160
158
 
161
159
  return (
162
- <div className={getClassName("kcContentWrapperClass")}>
163
- <label id={`header-${attribute.group.name}`} className={getClassName("kcFormGroupHeader")}>
160
+ <div className={kcClsx("kcContentWrapperClass")}>
161
+ <label id={`header-${attribute.group.name}`} className={kcClsx("kcFormGroupHeader")}>
164
162
  {groupHeaderText}
165
163
  </label>
166
164
  </div>
@@ -173,8 +171,8 @@ function GroupLabel(props: {
173
171
  const groupDescriptionText = advancedMsg(groupDisplayDescription);
174
172
 
175
173
  return (
176
- <div className={getClassName("kcLabelWrapperClass")}>
177
- <label id={`description-${attribute.group.name}`} className={getClassName("kcLabelClass")}>
174
+ <div className={kcClsx("kcLabelWrapperClass")}>
175
+ <label id={`description-${attribute.group.name}`} className={kcClsx("kcLabelClass")}>
178
176
  {groupDescriptionText}
179
177
  </label>
180
178
  </div>
@@ -191,13 +189,8 @@ function GroupLabel(props: {
191
189
  return null;
192
190
  }
193
191
 
194
- function FieldErrors(props: {
195
- attribute: Attribute;
196
- getClassName: UserProfileFormFieldsProps["getClassName"];
197
- displayableErrors: FormFieldError[];
198
- fieldIndex: number | undefined;
199
- }) {
200
- const { attribute, getClassName, fieldIndex } = props;
192
+ function FieldErrors(props: { attribute: Attribute; displayableErrors: FormFieldError[]; fieldIndex: number | undefined; kcClsx: KcClsx }) {
193
+ const { attribute, fieldIndex, kcClsx } = props;
201
194
 
202
195
  const displayableErrors = props.displayableErrors.filter(error => error.fieldIndex === fieldIndex);
203
196
 
@@ -208,7 +201,7 @@ function FieldErrors(props: {
208
201
  return (
209
202
  <span
210
203
  id={`input-error-${attribute.name}${fieldIndex === undefined ? "" : `-${fieldIndex}`}`}
211
- className={getClassName("kcInputErrorMessageClass")}
204
+ className={kcClsx("kcInputErrorMessageClass")}
212
205
  aria-live="polite"
213
206
  >
214
207
  {displayableErrors
@@ -227,9 +220,9 @@ type InputFiledByTypeProps = {
227
220
  attribute: Attribute;
228
221
  valueOrValues: string | string[];
229
222
  displayableErrors: FormFieldError[];
230
- formValidationDispatch: React.Dispatch<FormAction>;
231
- getClassName: UserProfileFormFieldsProps["getClassName"];
223
+ dispatchFormAction: React.Dispatch<FormAction>;
232
224
  i18n: I18n;
225
+ kcClsx: KcClsx;
233
226
  };
234
227
 
235
228
  function InputFiledByType(props: InputFiledByTypeProps) {
@@ -259,7 +252,7 @@ function InputFiledByType(props: InputFiledByTypeProps) {
259
252
 
260
253
  if (attribute.name === "password" || attribute.name === "password-confirm") {
261
254
  return (
262
- <PasswordWrapper getClassName={props.getClassName} i18n={props.i18n} passwordInputId={attribute.name}>
255
+ <PasswordWrapper kcClsx={props.kcClsx} i18n={props.i18n} passwordInputId={attribute.name}>
263
256
  {inputNode}
264
257
  </PasswordWrapper>
265
258
  );
@@ -270,8 +263,8 @@ function InputFiledByType(props: InputFiledByTypeProps) {
270
263
  }
271
264
  }
272
265
 
273
- function PasswordWrapper(props: { getClassName: (classKey: ClassKey) => string; i18n: I18n; passwordInputId: string; children: JSX.Element }) {
274
- const { getClassName, i18n, passwordInputId, children } = props;
266
+ function PasswordWrapper(props: { kcClsx: KcClsx; i18n: I18n; passwordInputId: string; children: JSX.Element }) {
267
+ const { kcClsx, i18n, passwordInputId, children } = props;
275
268
 
276
269
  const { msgStr } = i18n;
277
270
 
@@ -286,26 +279,23 @@ function PasswordWrapper(props: { getClassName: (classKey: ClassKey) => string;
286
279
  }, [isPasswordRevealed]);
287
280
 
288
281
  return (
289
- <div className={getClassName("kcInputGroup")}>
282
+ <div className={kcClsx("kcInputGroup")}>
290
283
  {children}
291
284
  <button
292
285
  type="button"
293
- className={getClassName("kcFormPasswordVisibilityButtonClass")}
286
+ className={kcClsx("kcFormPasswordVisibilityButtonClass")}
294
287
  aria-label={msgStr(isPasswordRevealed ? "hidePassword" : "showPassword")}
295
288
  aria-controls={passwordInputId}
296
289
  onClick={toggleIsPasswordRevealed}
297
290
  >
298
- <i
299
- className={getClassName(isPasswordRevealed ? "kcFormPasswordVisibilityIconHide" : "kcFormPasswordVisibilityIconShow")}
300
- aria-hidden
301
- />
291
+ <i className={kcClsx(isPasswordRevealed ? "kcFormPasswordVisibilityIconHide" : "kcFormPasswordVisibilityIconShow")} aria-hidden />
302
292
  </button>
303
293
  </div>
304
294
  );
305
295
  }
306
296
 
307
297
  function InputTag(props: InputFiledByTypeProps & { fieldIndex: number | undefined }) {
308
- const { attribute, fieldIndex, getClassName, formValidationDispatch, valueOrValues, i18n, displayableErrors } = props;
298
+ const { attribute, fieldIndex, kcClsx, dispatchFormAction, valueOrValues, i18n, displayableErrors } = props;
309
299
 
310
300
  return (
311
301
  <>
@@ -331,7 +321,7 @@ function InputTag(props: InputFiledByTypeProps & { fieldIndex: number | undefine
331
321
 
332
322
  return valueOrValues;
333
323
  })()}
334
- className={getClassName("kcInputClass")}
324
+ className={kcClsx("kcInputClass")}
335
325
  aria-invalid={displayableErrors.find(error => error.fieldIndex === fieldIndex) !== undefined}
336
326
  disabled={attribute.readOnly}
337
327
  autoComplete={attribute.autocomplete}
@@ -349,7 +339,7 @@ function InputTag(props: InputFiledByTypeProps & { fieldIndex: number | undefine
349
339
  step={attribute.annotations.inputTypeStep}
350
340
  {...Object.fromEntries(Object.entries(attribute.html5DataAnnotations ?? {}).map(([key, value]) => [`data-${key}`, value]))}
351
341
  onChange={event =>
352
- formValidationDispatch({
342
+ dispatchFormAction({
353
343
  action: "update",
354
344
  name: attribute.name,
355
345
  valueOrValues: (() => {
@@ -370,7 +360,7 @@ function InputTag(props: InputFiledByTypeProps & { fieldIndex: number | undefine
370
360
  })
371
361
  }
372
362
  onBlur={() =>
373
- props.formValidationDispatch({
363
+ dispatchFormAction({
374
364
  action: "focus lost",
375
365
  name: attribute.name,
376
366
  fieldIndex: fieldIndex
@@ -388,17 +378,12 @@ function InputTag(props: InputFiledByTypeProps & { fieldIndex: number | undefine
388
378
 
389
379
  return (
390
380
  <>
391
- <FieldErrors
392
- attribute={attribute}
393
- getClassName={getClassName}
394
- displayableErrors={displayableErrors}
395
- fieldIndex={fieldIndex}
396
- />
381
+ <FieldErrors attribute={attribute} kcClsx={kcClsx} displayableErrors={displayableErrors} fieldIndex={fieldIndex} />
397
382
  <AddRemoveButtonsMultiValuedAttribute
398
383
  attribute={attribute}
399
384
  values={values}
400
385
  fieldIndex={fieldIndex}
401
- dispatchFormAction={formValidationDispatch}
386
+ dispatchFormAction={dispatchFormAction}
402
387
  i18n={i18n}
403
388
  />
404
389
  </>
@@ -465,7 +450,7 @@ function AddRemoveButtonsMultiValuedAttribute(props: {
465
450
  }
466
451
 
467
452
  function InputTagSelects(props: InputFiledByTypeProps) {
468
- const { attribute, formValidationDispatch, getClassName, valueOrValues } = props;
453
+ const { attribute, dispatchFormAction, kcClsx, valueOrValues } = props;
469
454
 
470
455
  const { advancedMsg } = props.i18n;
471
456
 
@@ -478,16 +463,16 @@ function InputTagSelects(props: InputFiledByTypeProps) {
478
463
  case "select-radiobuttons":
479
464
  return {
480
465
  inputType: "radio",
481
- classDiv: getClassName("kcInputClassRadio"),
482
- classInput: getClassName("kcInputClassRadioInput"),
483
- classLabel: getClassName("kcInputClassRadioLabel")
466
+ classDiv: kcClsx("kcInputClassRadio"),
467
+ classInput: kcClsx("kcInputClassRadioInput"),
468
+ classLabel: kcClsx("kcInputClassRadioLabel")
484
469
  };
485
470
  case "multiselect-checkboxes":
486
471
  return {
487
472
  inputType: "checkbox",
488
- classDiv: getClassName("kcInputClassCheckbox"),
489
- classInput: getClassName("kcInputClassCheckboxInput"),
490
- classLabel: getClassName("kcInputClassCheckboxLabel")
473
+ classDiv: kcClsx("kcInputClassCheckbox"),
474
+ classInput: kcClsx("kcInputClassCheckboxInput"),
475
+ classLabel: kcClsx("kcInputClassCheckboxLabel")
491
476
  };
492
477
  }
493
478
  })();
@@ -530,7 +515,7 @@ function InputTagSelects(props: InputFiledByTypeProps) {
530
515
  disabled={attribute.readOnly}
531
516
  checked={valueOrValues instanceof Array ? valueOrValues.includes(option) : valueOrValues === option}
532
517
  onChange={event =>
533
- formValidationDispatch({
518
+ dispatchFormAction({
534
519
  action: "update",
535
520
  name: attribute.name,
536
521
  valueOrValues: (() => {
@@ -553,7 +538,7 @@ function InputTagSelects(props: InputFiledByTypeProps) {
553
538
  })
554
539
  }
555
540
  onBlur={() =>
556
- formValidationDispatch({
541
+ dispatchFormAction({
557
542
  action: "focus lost",
558
543
  name: attribute.name,
559
544
  fieldIndex: undefined
@@ -562,7 +547,7 @@ function InputTagSelects(props: InputFiledByTypeProps) {
562
547
  />
563
548
  <label
564
549
  htmlFor={`${attribute.name}-${option}`}
565
- className={`${classLabel}${attribute.readOnly ? ` ${getClassName("kcInputClassRadioCheckboxLabelDisabled")}` : ""}`}
550
+ className={`${classLabel}${attribute.readOnly ? ` ${kcClsx("kcInputClassRadioCheckboxLabelDisabled")}` : ""}`}
566
551
  >
567
552
  {advancedMsg(option)}
568
553
  </label>
@@ -573,7 +558,7 @@ function InputTagSelects(props: InputFiledByTypeProps) {
573
558
  }
574
559
 
575
560
  function TextareaTag(props: InputFiledByTypeProps) {
576
- const { attribute, formValidationDispatch, getClassName, displayableErrors, valueOrValues } = props;
561
+ const { attribute, dispatchFormAction, kcClsx, displayableErrors, valueOrValues } = props;
577
562
 
578
563
  assert(typeof valueOrValues === "string");
579
564
 
@@ -583,7 +568,7 @@ function TextareaTag(props: InputFiledByTypeProps) {
583
568
  <textarea
584
569
  id={attribute.name}
585
570
  name={attribute.name}
586
- className={getClassName("kcInputClass")}
571
+ className={kcClsx("kcInputClass")}
587
572
  aria-invalid={displayableErrors.length !== 0}
588
573
  disabled={attribute.readOnly}
589
574
  cols={attribute.annotations.inputTypeCols === undefined ? undefined : parseInt(`${attribute.annotations.inputTypeCols}`)}
@@ -591,14 +576,14 @@ function TextareaTag(props: InputFiledByTypeProps) {
591
576
  maxLength={attribute.annotations.inputTypeMaxlength === undefined ? undefined : parseInt(`${attribute.annotations.inputTypeMaxlength}`)}
592
577
  value={value}
593
578
  onChange={event =>
594
- formValidationDispatch({
579
+ dispatchFormAction({
595
580
  action: "update",
596
581
  name: attribute.name,
597
582
  valueOrValues: event.target.value
598
583
  })
599
584
  }
600
585
  onBlur={() =>
601
- formValidationDispatch({
586
+ dispatchFormAction({
602
587
  action: "focus lost",
603
588
  name: attribute.name,
604
589
  fieldIndex: undefined
@@ -609,7 +594,7 @@ function TextareaTag(props: InputFiledByTypeProps) {
609
594
  }
610
595
 
611
596
  function SelectTag(props: InputFiledByTypeProps) {
612
- const { attribute, formValidationDispatch, getClassName, displayableErrors, i18n, valueOrValues } = props;
597
+ const { attribute, dispatchFormAction, kcClsx, displayableErrors, i18n, valueOrValues } = props;
613
598
 
614
599
  const { advancedMsg } = i18n;
615
600
 
@@ -619,14 +604,14 @@ function SelectTag(props: InputFiledByTypeProps) {
619
604
  <select
620
605
  id={attribute.name}
621
606
  name={attribute.name}
622
- className={getClassName("kcInputClass")}
607
+ className={kcClsx("kcInputClass")}
623
608
  aria-invalid={displayableErrors.length !== 0}
624
609
  disabled={attribute.readOnly}
625
610
  multiple={isMultiple}
626
611
  size={attribute.annotations.inputTypeSize === undefined ? undefined : parseInt(`${attribute.annotations.inputTypeSize}`)}
627
612
  value={valueOrValues}
628
613
  onChange={event =>
629
- formValidationDispatch({
614
+ dispatchFormAction({
630
615
  action: "update",
631
616
  name: attribute.name,
632
617
  valueOrValues: (() => {
@@ -639,7 +624,7 @@ function SelectTag(props: InputFiledByTypeProps) {
639
624
  })
640
625
  }
641
626
  onBlur={() =>
642
- formValidationDispatch({
627
+ dispatchFormAction({
643
628
  action: "focus lost",
644
629
  name: attribute.name,
645
630
  fieldIndex: undefined