@thunderid/react 1.0.7 → 1.1.0

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 (193) hide show
  1. package/dist/api/updateMeCredentials.d.ts +33 -0
  2. package/dist/api/updateMeCredentials.d.ts.map +1 -0
  3. package/dist/api/updateMeCredentials.js +29 -0
  4. package/dist/api/updateMeCredentials.js.map +1 -0
  5. package/dist/cjs/api/updateMeCredentials.cjs +31 -0
  6. package/dist/cjs/api/updateMeCredentials.cjs.map +1 -0
  7. package/dist/cjs/components/presentation/ChangeCredential/BaseChangeCredential.cjs +187 -0
  8. package/dist/cjs/components/presentation/ChangeCredential/BaseChangeCredential.cjs.map +1 -0
  9. package/dist/cjs/components/presentation/ChangeCredential/BaseChangeCredential.styles.cjs +108 -0
  10. package/dist/cjs/components/presentation/ChangeCredential/BaseChangeCredential.styles.cjs.map +1 -0
  11. package/dist/cjs/components/presentation/ChangeCredential/ChangeCredential.cjs +123 -0
  12. package/dist/cjs/components/presentation/ChangeCredential/ChangeCredential.cjs.map +1 -0
  13. package/dist/cjs/components/presentation/LanguageSwitcher/BaseLanguageSwitcher.cjs +1 -1
  14. package/dist/cjs/components/presentation/UserDropdown/BaseUserDropdown.cjs +2 -2
  15. package/dist/cjs/components/presentation/UserDropdown/BaseUserDropdown.cjs.map +1 -1
  16. package/dist/cjs/components/presentation/UserDropdown/UserDropdown.cjs +8 -4
  17. package/dist/cjs/components/presentation/UserDropdown/UserDropdown.cjs.map +1 -1
  18. package/dist/cjs/components/presentation/UserProfile/BaseUserProfile.styles.cjs +2 -0
  19. package/dist/cjs/components/presentation/UserProfile/BaseUserProfile.styles.cjs.map +1 -1
  20. package/dist/cjs/components/primitives/PasswordField/PasswordField.cjs +2 -2
  21. package/dist/cjs/components/primitives/PasswordField/PasswordField.cjs.map +1 -1
  22. package/dist/cjs/contexts/Theme/ThemeProvider.cjs +26 -4
  23. package/dist/cjs/contexts/Theme/ThemeProvider.cjs.map +1 -1
  24. package/dist/cjs/contexts/ThunderID/ThunderIDContext.cjs +2 -0
  25. package/dist/cjs/contexts/ThunderID/ThunderIDContext.cjs.map +1 -1
  26. package/dist/cjs/contexts/ThunderID/ThunderIDProvider.cjs +7 -1
  27. package/dist/cjs/contexts/ThunderID/ThunderIDProvider.cjs.map +1 -1
  28. package/dist/cjs/hooks/agents/useCreateAgent.cjs +26 -0
  29. package/dist/cjs/hooks/agents/useCreateAgent.cjs.map +1 -0
  30. package/dist/cjs/hooks/agents/useDeleteAgent.cjs +26 -0
  31. package/dist/cjs/hooks/agents/useDeleteAgent.cjs.map +1 -0
  32. package/dist/cjs/hooks/agents/useGetAgent.cjs +30 -0
  33. package/dist/cjs/hooks/agents/useGetAgent.cjs.map +1 -0
  34. package/dist/cjs/hooks/agents/useGetAgents.cjs +31 -0
  35. package/dist/cjs/hooks/agents/useGetAgents.cjs.map +1 -0
  36. package/dist/cjs/hooks/agents/useUpdateAgent.cjs +27 -0
  37. package/dist/cjs/hooks/agents/useUpdateAgent.cjs.map +1 -0
  38. package/dist/cjs/hooks/applications/useCreateApplication.cjs +31 -0
  39. package/dist/cjs/hooks/applications/useCreateApplication.cjs.map +1 -0
  40. package/dist/cjs/hooks/applications/useDeleteApplication.cjs +26 -0
  41. package/dist/cjs/hooks/applications/useDeleteApplication.cjs.map +1 -0
  42. package/dist/cjs/hooks/applications/useGetApplication.cjs +35 -0
  43. package/dist/cjs/hooks/applications/useGetApplication.cjs.map +1 -0
  44. package/dist/cjs/hooks/applications/useGetApplications.cjs +36 -0
  45. package/dist/cjs/hooks/applications/useGetApplications.cjs.map +1 -0
  46. package/dist/cjs/hooks/applications/useUpdateApplication.cjs +27 -0
  47. package/dist/cjs/hooks/applications/useUpdateApplication.cjs.map +1 -0
  48. package/dist/cjs/hooks/useManagementEndpoint.cjs +25 -0
  49. package/dist/cjs/hooks/useManagementEndpoint.cjs.map +1 -0
  50. package/dist/cjs/hooks/useResourceMutation.cjs +72 -0
  51. package/dist/cjs/hooks/useResourceMutation.cjs.map +1 -0
  52. package/dist/cjs/hooks/useResourceQuery.cjs +86 -0
  53. package/dist/cjs/hooks/useResourceQuery.cjs.map +1 -0
  54. package/dist/cjs/hooks/users/useCreateUser.cjs +26 -0
  55. package/dist/cjs/hooks/users/useCreateUser.cjs.map +1 -0
  56. package/dist/cjs/hooks/users/useDeleteUser.cjs +26 -0
  57. package/dist/cjs/hooks/users/useDeleteUser.cjs.map +1 -0
  58. package/dist/cjs/hooks/users/useGetUser.cjs +30 -0
  59. package/dist/cjs/hooks/users/useGetUser.cjs.map +1 -0
  60. package/dist/cjs/hooks/users/useGetUsers.cjs +38 -0
  61. package/dist/cjs/hooks/users/useGetUsers.cjs.map +1 -0
  62. package/dist/cjs/hooks/users/useUpdateUser.cjs +27 -0
  63. package/dist/cjs/hooks/users/useUpdateUser.cjs.map +1 -0
  64. package/dist/cjs/index.cjs +144 -0
  65. package/dist/cjs/utils/createAuthenticatedFetcher.cjs +43 -0
  66. package/dist/cjs/utils/createAuthenticatedFetcher.cjs.map +1 -0
  67. package/dist/cjs/utils/createResourceInvalidator.cjs +38 -0
  68. package/dist/cjs/utils/createResourceInvalidator.cjs.map +1 -0
  69. package/dist/components/presentation/ChangeCredential/BaseChangeCredential.d.ts +100 -0
  70. package/dist/components/presentation/ChangeCredential/BaseChangeCredential.d.ts.map +1 -0
  71. package/dist/components/presentation/ChangeCredential/BaseChangeCredential.js +183 -0
  72. package/dist/components/presentation/ChangeCredential/BaseChangeCredential.js.map +1 -0
  73. package/dist/components/presentation/ChangeCredential/BaseChangeCredential.styles.d.ts +10 -0
  74. package/dist/components/presentation/ChangeCredential/BaseChangeCredential.styles.d.ts.map +1 -0
  75. package/dist/components/presentation/ChangeCredential/BaseChangeCredential.styles.js +108 -0
  76. package/dist/components/presentation/ChangeCredential/BaseChangeCredential.styles.js.map +1 -0
  77. package/dist/components/presentation/ChangeCredential/ChangeCredential.d.ts +55 -0
  78. package/dist/components/presentation/ChangeCredential/ChangeCredential.d.ts.map +1 -0
  79. package/dist/components/presentation/ChangeCredential/ChangeCredential.js +119 -0
  80. package/dist/components/presentation/ChangeCredential/ChangeCredential.js.map +1 -0
  81. package/dist/components/presentation/LanguageSwitcher/BaseLanguageSwitcher.js +1 -1
  82. package/dist/components/presentation/UserDropdown/BaseUserDropdown.d.ts +5 -0
  83. package/dist/components/presentation/UserDropdown/BaseUserDropdown.d.ts.map +1 -1
  84. package/dist/components/presentation/UserDropdown/BaseUserDropdown.js +2 -2
  85. package/dist/components/presentation/UserDropdown/BaseUserDropdown.js.map +1 -1
  86. package/dist/components/presentation/UserDropdown/UserDropdown.d.ts +12 -0
  87. package/dist/components/presentation/UserDropdown/UserDropdown.d.ts.map +1 -1
  88. package/dist/components/presentation/UserDropdown/UserDropdown.js +8 -4
  89. package/dist/components/presentation/UserDropdown/UserDropdown.js.map +1 -1
  90. package/dist/components/presentation/UserProfile/BaseUserProfile.styles.d.ts.map +1 -1
  91. package/dist/components/presentation/UserProfile/BaseUserProfile.styles.js +2 -0
  92. package/dist/components/presentation/UserProfile/BaseUserProfile.styles.js.map +1 -1
  93. package/dist/components/primitives/PasswordField/PasswordField.d.ts +6 -0
  94. package/dist/components/primitives/PasswordField/PasswordField.d.ts.map +1 -1
  95. package/dist/components/primitives/PasswordField/PasswordField.js +2 -2
  96. package/dist/components/primitives/PasswordField/PasswordField.js.map +1 -1
  97. package/dist/contexts/Theme/ThemeProvider.d.ts +1 -1
  98. package/dist/contexts/Theme/ThemeProvider.d.ts.map +1 -1
  99. package/dist/contexts/Theme/ThemeProvider.js +27 -5
  100. package/dist/contexts/Theme/ThemeProvider.js.map +1 -1
  101. package/dist/contexts/ThunderID/ThunderIDContext.d.ts +12 -1
  102. package/dist/contexts/ThunderID/ThunderIDContext.d.ts.map +1 -1
  103. package/dist/contexts/ThunderID/ThunderIDContext.js +2 -0
  104. package/dist/contexts/ThunderID/ThunderIDContext.js.map +1 -1
  105. package/dist/contexts/ThunderID/ThunderIDProvider.d.ts.map +1 -1
  106. package/dist/contexts/ThunderID/ThunderIDProvider.js +7 -1
  107. package/dist/contexts/ThunderID/ThunderIDProvider.js.map +1 -1
  108. package/dist/hooks/agents/useCreateAgent.d.ts +11 -0
  109. package/dist/hooks/agents/useCreateAgent.d.ts.map +1 -0
  110. package/dist/hooks/agents/useCreateAgent.js +24 -0
  111. package/dist/hooks/agents/useCreateAgent.js.map +1 -0
  112. package/dist/hooks/agents/useDeleteAgent.d.ts +10 -0
  113. package/dist/hooks/agents/useDeleteAgent.d.ts.map +1 -0
  114. package/dist/hooks/agents/useDeleteAgent.js +24 -0
  115. package/dist/hooks/agents/useDeleteAgent.js.map +1 -0
  116. package/dist/hooks/agents/useGetAgent.d.ts +12 -0
  117. package/dist/hooks/agents/useGetAgent.d.ts.map +1 -0
  118. package/dist/hooks/agents/useGetAgent.js +28 -0
  119. package/dist/hooks/agents/useGetAgent.js.map +1 -0
  120. package/dist/hooks/agents/useGetAgents.d.ts +19 -0
  121. package/dist/hooks/agents/useGetAgents.d.ts.map +1 -0
  122. package/dist/hooks/agents/useGetAgents.js +29 -0
  123. package/dist/hooks/agents/useGetAgents.js.map +1 -0
  124. package/dist/hooks/agents/useUpdateAgent.d.ts +18 -0
  125. package/dist/hooks/agents/useUpdateAgent.d.ts.map +1 -0
  126. package/dist/hooks/agents/useUpdateAgent.js +25 -0
  127. package/dist/hooks/agents/useUpdateAgent.js.map +1 -0
  128. package/dist/hooks/applications/useCreateApplication.d.ts +16 -0
  129. package/dist/hooks/applications/useCreateApplication.d.ts.map +1 -0
  130. package/dist/hooks/applications/useCreateApplication.js +29 -0
  131. package/dist/hooks/applications/useCreateApplication.js.map +1 -0
  132. package/dist/hooks/applications/useDeleteApplication.d.ts +10 -0
  133. package/dist/hooks/applications/useDeleteApplication.d.ts.map +1 -0
  134. package/dist/hooks/applications/useDeleteApplication.js +24 -0
  135. package/dist/hooks/applications/useDeleteApplication.js.map +1 -0
  136. package/dist/hooks/applications/useGetApplication.d.ts +17 -0
  137. package/dist/hooks/applications/useGetApplication.d.ts.map +1 -0
  138. package/dist/hooks/applications/useGetApplication.js +33 -0
  139. package/dist/hooks/applications/useGetApplication.js.map +1 -0
  140. package/dist/hooks/applications/useGetApplications.d.ts +24 -0
  141. package/dist/hooks/applications/useGetApplications.d.ts.map +1 -0
  142. package/dist/hooks/applications/useGetApplications.js +34 -0
  143. package/dist/hooks/applications/useGetApplications.js.map +1 -0
  144. package/dist/hooks/applications/useUpdateApplication.d.ts +18 -0
  145. package/dist/hooks/applications/useUpdateApplication.d.ts.map +1 -0
  146. package/dist/hooks/applications/useUpdateApplication.js +25 -0
  147. package/dist/hooks/applications/useUpdateApplication.js.map +1 -0
  148. package/dist/hooks/useManagementEndpoint.d.ts +22 -0
  149. package/dist/hooks/useManagementEndpoint.d.ts.map +1 -0
  150. package/dist/hooks/useManagementEndpoint.js +23 -0
  151. package/dist/hooks/useManagementEndpoint.js.map +1 -0
  152. package/dist/hooks/useResourceMutation.d.ts +51 -0
  153. package/dist/hooks/useResourceMutation.d.ts.map +1 -0
  154. package/dist/hooks/useResourceMutation.js +70 -0
  155. package/dist/hooks/useResourceMutation.js.map +1 -0
  156. package/dist/hooks/useResourceQuery.d.ts +45 -0
  157. package/dist/hooks/useResourceQuery.d.ts.map +1 -0
  158. package/dist/hooks/useResourceQuery.js +83 -0
  159. package/dist/hooks/useResourceQuery.js.map +1 -0
  160. package/dist/hooks/users/useCreateUser.d.ts +11 -0
  161. package/dist/hooks/users/useCreateUser.d.ts.map +1 -0
  162. package/dist/hooks/users/useCreateUser.js +24 -0
  163. package/dist/hooks/users/useCreateUser.js.map +1 -0
  164. package/dist/hooks/users/useDeleteUser.d.ts +10 -0
  165. package/dist/hooks/users/useDeleteUser.d.ts.map +1 -0
  166. package/dist/hooks/users/useDeleteUser.js +24 -0
  167. package/dist/hooks/users/useDeleteUser.js.map +1 -0
  168. package/dist/hooks/users/useGetUser.d.ts +12 -0
  169. package/dist/hooks/users/useGetUser.d.ts.map +1 -0
  170. package/dist/hooks/users/useGetUser.js +28 -0
  171. package/dist/hooks/users/useGetUser.js.map +1 -0
  172. package/dist/hooks/users/useGetUsers.d.ts +17 -0
  173. package/dist/hooks/users/useGetUsers.d.ts.map +1 -0
  174. package/dist/hooks/users/useGetUsers.js +36 -0
  175. package/dist/hooks/users/useGetUsers.js.map +1 -0
  176. package/dist/hooks/users/useUpdateUser.d.ts +18 -0
  177. package/dist/hooks/users/useUpdateUser.d.ts.map +1 -0
  178. package/dist/hooks/users/useUpdateUser.js +25 -0
  179. package/dist/hooks/users/useUpdateUser.js.map +1 -0
  180. package/dist/index.d.ts +29 -0
  181. package/dist/index.d.ts.map +1 -1
  182. package/dist/index.js +20 -2
  183. package/dist/models/config.d.ts +13 -1
  184. package/dist/models/config.d.ts.map +1 -1
  185. package/dist/utils/createAuthenticatedFetcher.d.ts +14 -0
  186. package/dist/utils/createAuthenticatedFetcher.d.ts.map +1 -0
  187. package/dist/utils/createAuthenticatedFetcher.js +41 -0
  188. package/dist/utils/createAuthenticatedFetcher.js.map +1 -0
  189. package/dist/utils/createResourceInvalidator.d.ts +29 -0
  190. package/dist/utils/createResourceInvalidator.d.ts.map +1 -0
  191. package/dist/utils/createResourceInvalidator.js +36 -0
  192. package/dist/utils/createResourceInvalidator.js.map +1 -0
  193. package/package.json +2 -2
@@ -0,0 +1,33 @@
1
+ import { UpdateMeCredentialsConfig as BaseUpdateMeCredentialsConfig } from '@thunderid/browser';
2
+ /**
3
+ * Configuration for the updateMeCredentials request (React-specific)
4
+ */
5
+ export interface UpdateMeCredentialsConfig extends Omit<BaseUpdateMeCredentialsConfig, 'fetcher'> {
6
+ /**
7
+ * Optional custom fetcher function. If not provided, the ThunderID SPA client's httpClient will be used
8
+ * which is a wrapper around axios http.request
9
+ */
10
+ fetcher?: (url: string, config: RequestInit) => Promise<Response>;
11
+ /**
12
+ * Optional instance ID for multi-instance support. Defaults to 0.
13
+ */
14
+ instanceId?: number;
15
+ }
16
+ /**
17
+ * Updates one or more of the signed-in user's credentials at the /users/me/update-credentials
18
+ * endpoint. Uses the ThunderID SPA client's httpClient by default, which attaches the access
19
+ * token, but allows a custom fetcher.
20
+ *
21
+ * @param config - Configuration object with URL, payload and optional request config.
22
+ * @returns A promise that resolves once the credentials have been updated.
23
+ * @example
24
+ * ```typescript
25
+ * await updateMeCredentials({
26
+ * url: "https://localhost:8090/users/me/update-credentials",
27
+ * payload: {password: "n3wP@ssword!"}
28
+ * });
29
+ * ```
30
+ */
31
+ declare const updateMeCredentials: ({ fetcher, instanceId, ...requestConfig }: UpdateMeCredentialsConfig) => Promise<void>;
32
+ export default updateMeCredentials;
33
+ //# sourceMappingURL=updateMeCredentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateMeCredentials.d.ts","sourceRoot":"","sources":["../../src/api/updateMeCredentials.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,yBAAyB,IAAI,6BAA6B,EAC3D,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,IAAI,CAAC,6BAA6B,EAAE,SAAS,CAAC;IAC/F;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClE;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,mBAAmB,GAAU,2CAIhC,yBAAyB,KAAG,OAAO,CAAC,IAAI,CAK1C,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { createHttpClientFetcher, updateMeCredentials } from "@thunderid/browser";
2
+
3
+ //#region src/api/updateMeCredentials.ts
4
+ /**
5
+ * Updates one or more of the signed-in user's credentials at the /users/me/update-credentials
6
+ * endpoint. Uses the ThunderID SPA client's httpClient by default, which attaches the access
7
+ * token, but allows a custom fetcher.
8
+ *
9
+ * @param config - Configuration object with URL, payload and optional request config.
10
+ * @returns A promise that resolves once the credentials have been updated.
11
+ * @example
12
+ * ```typescript
13
+ * await updateMeCredentials({
14
+ * url: "https://localhost:8090/users/me/update-credentials",
15
+ * payload: {password: "n3wP@ssword!"}
16
+ * });
17
+ * ```
18
+ */
19
+ const updateMeCredentials$1 = async ({ fetcher, instanceId = 0,...requestConfig }) => {
20
+ return updateMeCredentials({
21
+ ...requestConfig,
22
+ fetcher: fetcher || createHttpClientFetcher(instanceId)
23
+ });
24
+ };
25
+ var updateMeCredentials_default = updateMeCredentials$1;
26
+
27
+ //#endregion
28
+ export { updateMeCredentials_default as default };
29
+ //# sourceMappingURL=updateMeCredentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateMeCredentials.js","names":["updateMeCredentials","baseUpdateMeCredentials"],"sources":["../../src/api/updateMeCredentials.ts"],"sourcesContent":["// Copyright 2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n createHttpClientFetcher,\n updateMeCredentials as baseUpdateMeCredentials,\n UpdateMeCredentialsConfig as BaseUpdateMeCredentialsConfig,\n} from '@thunderid/browser';\n\n/**\n * Configuration for the updateMeCredentials request (React-specific)\n */\nexport interface UpdateMeCredentialsConfig extends Omit<BaseUpdateMeCredentialsConfig, 'fetcher'> {\n /**\n * Optional custom fetcher function. If not provided, the ThunderID SPA client's httpClient will be used\n * which is a wrapper around axios http.request\n */\n fetcher?: (url: string, config: RequestInit) => Promise<Response>;\n /**\n * Optional instance ID for multi-instance support. Defaults to 0.\n */\n instanceId?: number;\n}\n\n/**\n * Updates one or more of the signed-in user's credentials at the /users/me/update-credentials\n * endpoint. Uses the ThunderID SPA client's httpClient by default, which attaches the access\n * token, but allows a custom fetcher.\n *\n * @param config - Configuration object with URL, payload and optional request config.\n * @returns A promise that resolves once the credentials have been updated.\n * @example\n * ```typescript\n * await updateMeCredentials({\n * url: \"https://localhost:8090/users/me/update-credentials\",\n * payload: {password: \"n3wP@ssword!\"}\n * });\n * ```\n */\nconst updateMeCredentials = async ({\n fetcher,\n instanceId = 0,\n ...requestConfig\n}: UpdateMeCredentialsConfig): Promise<void> => {\n return baseUpdateMeCredentials({\n ...requestConfig,\n fetcher: fetcher || createHttpClientFetcher(instanceId),\n });\n};\n\nexport default updateMeCredentials;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuCA,MAAMA,wBAAsB,OAAO,EACjC,SACA,aAAa,EACb,GAAG,oBAC2C;AAC9C,QAAOC,oBAAwB;EAC7B,GAAG;EACH,SAAS,WAAW,wBAAwB,WAAW;EACxD,CAAC;;AAGJ,kCAAeD"}
@@ -0,0 +1,31 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let __thunderid_browser = require("@thunderid/browser");
3
+ __thunderid_browser = require_rolldown_runtime.__toESM(__thunderid_browser);
4
+
5
+ //#region src/api/updateMeCredentials.ts
6
+ /**
7
+ * Updates one or more of the signed-in user's credentials at the /users/me/update-credentials
8
+ * endpoint. Uses the ThunderID SPA client's httpClient by default, which attaches the access
9
+ * token, but allows a custom fetcher.
10
+ *
11
+ * @param config - Configuration object with URL, payload and optional request config.
12
+ * @returns A promise that resolves once the credentials have been updated.
13
+ * @example
14
+ * ```typescript
15
+ * await updateMeCredentials({
16
+ * url: "https://localhost:8090/users/me/update-credentials",
17
+ * payload: {password: "n3wP@ssword!"}
18
+ * });
19
+ * ```
20
+ */
21
+ const updateMeCredentials = async ({ fetcher, instanceId = 0,...requestConfig }) => {
22
+ return (0, __thunderid_browser.updateMeCredentials)({
23
+ ...requestConfig,
24
+ fetcher: fetcher || (0, __thunderid_browser.createHttpClientFetcher)(instanceId)
25
+ });
26
+ };
27
+ var updateMeCredentials_default = updateMeCredentials;
28
+
29
+ //#endregion
30
+ exports.default = updateMeCredentials_default;
31
+ //# sourceMappingURL=updateMeCredentials.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateMeCredentials.cjs","names":[],"sources":["../../../src/api/updateMeCredentials.ts"],"sourcesContent":["// Copyright 2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n createHttpClientFetcher,\n updateMeCredentials as baseUpdateMeCredentials,\n UpdateMeCredentialsConfig as BaseUpdateMeCredentialsConfig,\n} from '@thunderid/browser';\n\n/**\n * Configuration for the updateMeCredentials request (React-specific)\n */\nexport interface UpdateMeCredentialsConfig extends Omit<BaseUpdateMeCredentialsConfig, 'fetcher'> {\n /**\n * Optional custom fetcher function. If not provided, the ThunderID SPA client's httpClient will be used\n * which is a wrapper around axios http.request\n */\n fetcher?: (url: string, config: RequestInit) => Promise<Response>;\n /**\n * Optional instance ID for multi-instance support. Defaults to 0.\n */\n instanceId?: number;\n}\n\n/**\n * Updates one or more of the signed-in user's credentials at the /users/me/update-credentials\n * endpoint. Uses the ThunderID SPA client's httpClient by default, which attaches the access\n * token, but allows a custom fetcher.\n *\n * @param config - Configuration object with URL, payload and optional request config.\n * @returns A promise that resolves once the credentials have been updated.\n * @example\n * ```typescript\n * await updateMeCredentials({\n * url: \"https://localhost:8090/users/me/update-credentials\",\n * payload: {password: \"n3wP@ssword!\"}\n * });\n * ```\n */\nconst updateMeCredentials = async ({\n fetcher,\n instanceId = 0,\n ...requestConfig\n}: UpdateMeCredentialsConfig): Promise<void> => {\n return baseUpdateMeCredentials({\n ...requestConfig,\n fetcher: fetcher || createHttpClientFetcher(instanceId),\n });\n};\n\nexport default updateMeCredentials;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuCA,MAAM,sBAAsB,OAAO,EACjC,SACA,aAAa,EACb,GAAG,oBAC2C;AAC9C,qDAA+B;EAC7B,GAAG;EACH,SAAS,4DAAmC,WAAW;EACxD,CAAC;;AAGJ,kCAAe"}
@@ -0,0 +1,187 @@
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ const require_emotion = require('../../../styles/emotion.cjs');
3
+ const require_useTheme = require('../../../contexts/Theme/useTheme.cjs');
4
+ const require_useTranslation = require('../../../hooks/useTranslation.cjs');
5
+ const require_Button = require('../../primitives/Button/Button.cjs');
6
+ const require_Typography = require('../../primitives/Typography/Typography.cjs');
7
+ const require_Alert = require('../../primitives/Alert/Alert.cjs');
8
+ const require_X = require('../../primitives/Icons/X.cjs');
9
+ const require_PasswordField = require('../../primitives/PasswordField/PasswordField.cjs');
10
+ const require_BaseChangeCredential_styles = require('./BaseChangeCredential.styles.cjs');
11
+ const require_Check = require('../../primitives/Icons/Check.cjs');
12
+ let __thunderid_browser = require("@thunderid/browser");
13
+ __thunderid_browser = require_rolldown_runtime.__toESM(__thunderid_browser);
14
+ let react = require("react");
15
+ react = require_rolldown_runtime.__toESM(react);
16
+ let react_jsx_runtime = require("react/jsx-runtime");
17
+ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
18
+
19
+ //#region src/components/presentation/ChangeCredential/BaseChangeCredential.tsx
20
+ /**
21
+ * Presentational change-credential form with just the two fields a first-time or
22
+ * unverified credential change needs: new value and confirmation.
23
+ *
24
+ * Holds no context and performs no network calls: it renders the fields, evaluates the
25
+ * policy for the checklist and the submit gate, and hands validated values to `onSubmit`.
26
+ * Use {@link ChangeCredential} for the context-wired variant.
27
+ *
28
+ * @example
29
+ * ```tsx
30
+ * <BaseChangeCredential
31
+ * policy={{regex: '^.{12,}$'}}
32
+ * onSubmit={({newPassword}) => save(newPassword)}
33
+ * />
34
+ * ```
35
+ */
36
+ const BaseChangeCredential = ({ cardLayout = false, className = "", credentialDisplayName = "Password", error = null, fieldErrors = {}, loading = false, onSubmit = void 0, policy = {}, preferences = void 0, showRequirements = true, success = false, title = void 0, unavailable = false }) => {
37
+ const { theme, colorScheme } = require_useTheme.default();
38
+ const styles = require_BaseChangeCredential_styles.default(theme, colorScheme);
39
+ const { t } = require_useTranslation.default(preferences?.i18n);
40
+ const labelParams = {
41
+ credential: credentialDisplayName,
42
+ credentialLower: credentialDisplayName.toLowerCase()
43
+ };
44
+ const resolvedTitle = title ?? t("user.change_password.heading", labelParams);
45
+ const [newPassword, setNewPassword] = (0, react.useState)("");
46
+ const [confirmPassword, setConfirmPassword] = (0, react.useState)("");
47
+ const [submitted, setSubmitted] = (0, react.useState)(false);
48
+ const [prevSuccess, setPrevSuccess] = (0, react.useState)(success);
49
+ if (success !== prevSuccess) {
50
+ setPrevSuccess(success);
51
+ if (success) {
52
+ setNewPassword("");
53
+ setConfirmPassword("");
54
+ setSubmitted(false);
55
+ }
56
+ }
57
+ const { confirmMatches, isValid, ruleResults } = (0, react.useMemo)(() => (0, __thunderid_browser.evaluateChangePasswordForm)({
58
+ confirmPassword,
59
+ newPassword
60
+ }, policy), [
61
+ confirmPassword,
62
+ newPassword,
63
+ policy
64
+ ]);
65
+ const interactionDisabled = loading || unavailable;
66
+ const canSubmit = !interactionDisabled && isValid;
67
+ const handleSubmit = (event) => {
68
+ event.preventDefault();
69
+ setSubmitted(true);
70
+ if (!canSubmit) return;
71
+ onSubmit?.({ newPassword });
72
+ };
73
+ const renderRequirement = (rule) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
74
+ "data-passed": rule.passed,
75
+ className: require_emotion.cx((0, __thunderid_browser.withVendorCSSClassPrefix)((0, __thunderid_browser.bem)("change-credential", "requirement")), styles["requirement"], rule.passed ? styles["requirementPassed"] : styles["requirementPending"]),
76
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
77
+ className: require_emotion.cx((0, __thunderid_browser.withVendorCSSClassPrefix)((0, __thunderid_browser.bem)("change-credential", "requirement-icon")), styles["requirementIcon"]),
78
+ children: rule.passed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Check.default, {
79
+ width: 14,
80
+ height: 14
81
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_X.default, {
82
+ width: 14,
83
+ height: 14
84
+ })
85
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Typography.default, {
86
+ variant: "body2",
87
+ component: "span",
88
+ children: t(rule.messageKey, rule.params)
89
+ })]
90
+ }, rule.key);
91
+ const confirmError = submitted && !confirmMatches ? t("user.change_password.mismatch.error", labelParams) : void 0;
92
+ const newPasswordError = fieldErrors["newPassword"];
93
+ const form = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
94
+ noValidate: true,
95
+ onSubmit: handleSubmit,
96
+ className: require_emotion.cx((0, __thunderid_browser.withVendorCSSClassPrefix)("change-credential"), styles["root"], cardLayout ? styles["card"] : "", className),
97
+ children: [
98
+ resolvedTitle && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Typography.default, {
99
+ variant: "h5",
100
+ className: require_emotion.cx((0, __thunderid_browser.withVendorCSSClassPrefix)((0, __thunderid_browser.bem)("change-credential", "heading")), styles["heading"]),
101
+ children: resolvedTitle
102
+ }),
103
+ error && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Alert.default, {
104
+ variant: "error",
105
+ className: require_emotion.cx((0, __thunderid_browser.withVendorCSSClassPrefix)((0, __thunderid_browser.bem)("change-credential", "alert")), styles["alert"]),
106
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Alert.default.Title, { children: t("errors.heading") || "Error" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Alert.default.Description, { children: error })]
107
+ }),
108
+ success && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Alert.default, {
109
+ variant: "success",
110
+ className: require_emotion.cx((0, __thunderid_browser.withVendorCSSClassPrefix)((0, __thunderid_browser.bem)("change-credential", "alert")), styles["alert"]),
111
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Alert.default.Description, { children: t("user.change_password.success", labelParams) })
112
+ }),
113
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
114
+ className: require_emotion.cx((0, __thunderid_browser.withVendorCSSClassPrefix)((0, __thunderid_browser.bem)("change-credential", "fields")), styles["fields"]),
115
+ children: [
116
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PasswordField.default, {
117
+ name: "newPassword",
118
+ autoComplete: "new-password",
119
+ label: t("user.change_password.new.label", labelParams),
120
+ placeholder: t("user.change_password.new.placeholder", labelParams),
121
+ value: newPassword,
122
+ onChange: setNewPassword,
123
+ disabled: interactionDisabled,
124
+ error: newPasswordError,
125
+ required: true
126
+ }),
127
+ showRequirements && ruleResults.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
128
+ className: require_emotion.cx((0, __thunderid_browser.withVendorCSSClassPrefix)((0, __thunderid_browser.bem)("change-credential", "requirements"))),
129
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Typography.default, {
130
+ variant: "body2",
131
+ component: "p",
132
+ className: require_emotion.cx((0, __thunderid_browser.withVendorCSSClassPrefix)((0, __thunderid_browser.bem)("change-credential", "requirements-heading")), styles["requirementsHeading"]),
133
+ children: t("user.change_password.requirements.heading", labelParams)
134
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
135
+ className: styles["requirements"],
136
+ children: ruleResults.map(renderRequirement)
137
+ })]
138
+ }),
139
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PasswordField.default, {
140
+ name: "confirmPassword",
141
+ autoComplete: "new-password",
142
+ label: t("user.change_password.confirm.label", labelParams),
143
+ placeholder: t("user.change_password.confirm.placeholder", labelParams),
144
+ value: confirmPassword,
145
+ onChange: setConfirmPassword,
146
+ disabled: interactionDisabled,
147
+ error: confirmError,
148
+ required: true
149
+ })
150
+ ]
151
+ }),
152
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
153
+ className: require_emotion.cx((0, __thunderid_browser.withVendorCSSClassPrefix)((0, __thunderid_browser.bem)("change-credential", "actions")), styles["actions"]),
154
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Button.default, {
155
+ type: "submit",
156
+ color: "primary",
157
+ variant: "solid",
158
+ loading,
159
+ disabled: !canSubmit,
160
+ children: t("user.change_password.submit", labelParams)
161
+ })
162
+ })
163
+ ]
164
+ });
165
+ if (!unavailable) return form;
166
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
167
+ className: require_emotion.cx((0, __thunderid_browser.withVendorCSSClassPrefix)((0, __thunderid_browser.bem)("change-credential", "unavailable")), styles["unavailableRoot"], className),
168
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
169
+ "aria-hidden": "true",
170
+ className: require_emotion.cx((0, __thunderid_browser.withVendorCSSClassPrefix)((0, __thunderid_browser.bem)("change-credential", "unavailable-content")), styles["unavailableContent"]),
171
+ children: form
172
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
173
+ role: "status",
174
+ className: require_emotion.cx((0, __thunderid_browser.withVendorCSSClassPrefix)((0, __thunderid_browser.bem)("change-credential", "unavailable-overlay")), styles["unavailableOverlay"]),
175
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Alert.default, {
176
+ variant: "warning",
177
+ className: require_emotion.cx((0, __thunderid_browser.withVendorCSSClassPrefix)((0, __thunderid_browser.bem)("change-credential", "alert")), styles["alert"]),
178
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Alert.default.Title, { children: t("user.change_password.unavailable.heading", labelParams) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Alert.default.Description, { children: t("user.change_password.unavailable.description", labelParams) })]
179
+ })
180
+ })]
181
+ });
182
+ };
183
+ var BaseChangeCredential_default = BaseChangeCredential;
184
+
185
+ //#endregion
186
+ exports.default = BaseChangeCredential_default;
187
+ //# sourceMappingURL=BaseChangeCredential.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseChangeCredential.cjs","names":["BaseChangeCredential: FC<BaseChangeCredentialProps>","useTheme","styles: Record<string, string>","useStyles","useTranslation","labelParams: Record<string, string>","resolvedTitle: string","interactionDisabled: boolean","canSubmit: boolean","cx","Check","X","Typography","confirmError: string | undefined","newPasswordError: string | undefined","form: ReactElement","AlertPrimitive","PasswordField","Button"],"sources":["../../../../../src/components/presentation/ChangeCredential/BaseChangeCredential.tsx"],"sourcesContent":["// Copyright 2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n ChangePasswordFormEvaluation,\n PasswordPolicy,\n PasswordRuleResult,\n Preferences,\n bem,\n evaluateChangePasswordForm,\n withVendorCSSClassPrefix,\n} from '@thunderid/browser';\nimport {FC, FormEvent, ReactElement, useMemo, useState} from 'react';\nimport useStyles from './BaseChangeCredential.styles';\nimport useTheme from '../../../contexts/Theme/useTheme';\nimport useTranslation from '../../../hooks/useTranslation';\nimport {cx} from '../../../styles/emotion';\nimport AlertPrimitive from '../../primitives/Alert/Alert';\nimport Button from '../../primitives/Button/Button';\nimport Check from '../../primitives/Icons/Check';\nimport X from '../../primitives/Icons/X';\nimport PasswordField from '../../primitives/PasswordField/PasswordField';\nimport Typography from '../../primitives/Typography/Typography';\n\n/**\n * The values collected by the form and handed to `onSubmit`.\n *\n * There is deliberately no current-value field here. The self-service credential write\n * endpoint does not verify the account's existing value today, so a field the server\n * ignores would only teach the user a false sense of security.\n */\nexport interface ChangePasswordValues {\n /**\n * The value to set.\n */\n newPassword: string;\n}\n\nexport interface BaseChangeCredentialProps {\n /**\n * Whether to wrap the form in a bordered card.\n */\n cardLayout?: boolean;\n /**\n * Additional CSS class names\n */\n className?: string;\n /**\n * The human-readable name of the credential, substituted into every default label,\n * placeholder and message (for example \"Change {credential}\", \"New {credential}\").\n * Defaults to `Password`. {@link ChangeCredential} resolves this from the attribute's own\n * `displayName` in the user schema; set it directly here when using this presentational\n * component without that context.\n */\n credentialDisplayName?: string;\n /**\n * A form-level error, typically a server failure that maps to no single field.\n */\n error?: string | null;\n /**\n * Server-supplied errors keyed by field name (`newPassword`).\n */\n fieldErrors?: Record<string, string>;\n /**\n * Whether a submission is in flight.\n */\n loading?: boolean;\n /**\n * Called with the collected values once client-side validation passes.\n */\n onSubmit?: (values: ChangePasswordValues) => void;\n /**\n * The rules the new value must satisfy. Defaults to no rules, in which case the checklist\n * is empty and the only submit gate is a non-empty value; the caller is expected to source\n * this from the user type schema (see {@link ChangeCredential}) or supply its own.\n */\n policy?: PasswordPolicy;\n /**\n * Component-level preference overrides, including i18n.\n */\n preferences?: Preferences;\n /**\n * Whether to render the live requirement checklist. Defaults to `true`.\n */\n showRequirements?: boolean;\n /**\n * Whether the last submission succeeded.\n */\n success?: boolean;\n /**\n * Overrides the default \"Change {credential}\" heading. Pass an empty string to omit the\n * heading entirely, for example when an app's own surrounding layout (a card header, a\n * dialog title) already names the credential and a second heading would be redundant.\n * Defaults to the translated `user.change_password.heading` string.\n */\n title?: string;\n /**\n * Whether the account cannot have this credential changed at all, because the user type's\n * schema defines no attribute of this name. The form is rendered inert behind an\n * explanatory message rather than hidden, so an integrator who placed the component can see\n * why it is not usable instead of finding an empty space.\n */\n unavailable?: boolean;\n}\n\n/**\n * Presentational change-credential form with just the two fields a first-time or\n * unverified credential change needs: new value and confirmation.\n *\n * Holds no context and performs no network calls: it renders the fields, evaluates the\n * policy for the checklist and the submit gate, and hands validated values to `onSubmit`.\n * Use {@link ChangeCredential} for the context-wired variant.\n *\n * @example\n * ```tsx\n * <BaseChangeCredential\n * policy={{regex: '^.{12,}$'}}\n * onSubmit={({newPassword}) => save(newPassword)}\n * />\n * ```\n */\nconst BaseChangeCredential: FC<BaseChangeCredentialProps> = ({\n cardLayout = false,\n className = '',\n credentialDisplayName = 'Password',\n error = null,\n fieldErrors = {},\n loading = false,\n onSubmit = undefined,\n policy = {},\n preferences = undefined,\n showRequirements = true,\n success = false,\n title = undefined,\n unavailable = false,\n}: BaseChangeCredentialProps) => {\n const {theme, colorScheme}: ReturnType<typeof useTheme> = useTheme();\n const styles: Record<string, string> = useStyles(theme, colorScheme);\n const {t} = useTranslation(preferences?.i18n);\n\n // Substituted into every default label, placeholder and message. A caller-supplied\n // translation that carries no `{credential}`/`{credentialLower}` placeholder is unaffected.\n const labelParams: Record<string, string> = {\n credential: credentialDisplayName,\n credentialLower: credentialDisplayName.toLowerCase(),\n };\n\n // `title` overrides the default heading; an explicit empty string omits it entirely.\n const resolvedTitle: string = title ?? t('user.change_password.heading', labelParams);\n\n const [newPassword, setNewPassword] = useState<string>('');\n const [confirmPassword, setConfirmPassword] = useState<string>('');\n const [submitted, setSubmitted] = useState<boolean>(false);\n\n // Clear the entered values once the container reports the write succeeded, so a shared\n // machine is not left with the new credential sitting in the form. Adjusting state during\n // render (rather than in an effect) is React's documented way to reset on a prop change and\n // avoids the extra commit an effect would cause.\n const [prevSuccess, setPrevSuccess] = useState<boolean>(success);\n\n if (success !== prevSuccess) {\n setPrevSuccess(success);\n\n if (success) {\n setNewPassword('');\n setConfirmPassword('');\n setSubmitted(false);\n }\n }\n\n const {confirmMatches, isValid, ruleResults}: ChangePasswordFormEvaluation = useMemo(\n () => evaluateChangePasswordForm({confirmPassword, newPassword}, policy),\n [confirmPassword, newPassword, policy],\n );\n\n // A schema with no attribute of this name makes every control pointless, so they are\n // disabled outright rather than left focusable behind the overlay.\n const interactionDisabled: boolean = loading || unavailable;\n const canSubmit: boolean = !interactionDisabled && isValid;\n\n const handleSubmit = (event: FormEvent<HTMLFormElement>): void => {\n event.preventDefault();\n setSubmitted(true);\n\n if (!canSubmit) {\n return;\n }\n\n onSubmit?.({newPassword});\n };\n\n const renderRequirement = (rule: PasswordRuleResult): ReactElement => (\n <li\n key={rule.key}\n data-passed={rule.passed}\n className={cx(\n withVendorCSSClassPrefix(bem('change-credential', 'requirement')),\n styles['requirement'],\n rule.passed ? styles['requirementPassed'] : styles['requirementPending'],\n )}\n >\n <span\n className={cx(\n withVendorCSSClassPrefix(bem('change-credential', 'requirement-icon')),\n styles['requirementIcon'],\n )}\n >\n {rule.passed ? <Check width={14} height={14} /> : <X width={14} height={14} />}\n </span>\n <Typography variant=\"body2\" component=\"span\">\n {t(rule.messageKey, rule.params)}\n </Typography>\n </li>\n );\n\n // Only surface the local error once the user has attempted a submit, so the form does\n // not flag fields the user has not finished filling in.\n const confirmError: string | undefined =\n submitted && !confirmMatches ? t('user.change_password.mismatch.error', labelParams) : undefined;\n const newPasswordError: string | undefined = fieldErrors['newPassword'];\n\n const form: ReactElement = (\n <form\n noValidate\n onSubmit={handleSubmit}\n className={cx(\n withVendorCSSClassPrefix('change-credential'),\n styles['root'],\n cardLayout ? styles['card'] : '',\n className,\n )}\n >\n {resolvedTitle && (\n <Typography\n variant=\"h5\"\n className={cx(withVendorCSSClassPrefix(bem('change-credential', 'heading')), styles['heading'])}\n >\n {resolvedTitle}\n </Typography>\n )}\n\n {error && (\n <AlertPrimitive\n variant=\"error\"\n className={cx(withVendorCSSClassPrefix(bem('change-credential', 'alert')), styles['alert'])}\n >\n <AlertPrimitive.Title>{t('errors.heading') || 'Error'}</AlertPrimitive.Title>\n <AlertPrimitive.Description>{error}</AlertPrimitive.Description>\n </AlertPrimitive>\n )}\n\n {success && (\n <AlertPrimitive\n variant=\"success\"\n className={cx(withVendorCSSClassPrefix(bem('change-credential', 'alert')), styles['alert'])}\n >\n <AlertPrimitive.Description>{t('user.change_password.success', labelParams)}</AlertPrimitive.Description>\n </AlertPrimitive>\n )}\n\n <div className={cx(withVendorCSSClassPrefix(bem('change-credential', 'fields')), styles['fields'])}>\n <PasswordField\n name=\"newPassword\"\n autoComplete=\"new-password\"\n label={t('user.change_password.new.label', labelParams)}\n placeholder={t('user.change_password.new.placeholder', labelParams)}\n value={newPassword}\n onChange={setNewPassword}\n disabled={interactionDisabled}\n error={newPasswordError}\n required\n />\n\n {showRequirements && ruleResults.length > 0 && (\n <div className={cx(withVendorCSSClassPrefix(bem('change-credential', 'requirements')))}>\n <Typography\n variant=\"body2\"\n component=\"p\"\n className={cx(\n withVendorCSSClassPrefix(bem('change-credential', 'requirements-heading')),\n styles['requirementsHeading'],\n )}\n >\n {t('user.change_password.requirements.heading', labelParams)}\n </Typography>\n <ul className={styles['requirements']}>{ruleResults.map(renderRequirement)}</ul>\n </div>\n )}\n\n <PasswordField\n name=\"confirmPassword\"\n autoComplete=\"new-password\"\n label={t('user.change_password.confirm.label', labelParams)}\n placeholder={t('user.change_password.confirm.placeholder', labelParams)}\n value={confirmPassword}\n onChange={setConfirmPassword}\n disabled={interactionDisabled}\n error={confirmError}\n required\n />\n </div>\n\n <div className={cx(withVendorCSSClassPrefix(bem('change-credential', 'actions')), styles['actions'])}>\n <Button type=\"submit\" color=\"primary\" variant=\"solid\" loading={loading} disabled={!canSubmit}>\n {t('user.change_password.submit', labelParams)}\n </Button>\n </div>\n </form>\n );\n\n if (!unavailable) {\n return form;\n }\n\n return (\n <div\n className={cx(\n withVendorCSSClassPrefix(bem('change-credential', 'unavailable')),\n styles['unavailableRoot'],\n className,\n )}\n >\n <div\n aria-hidden=\"true\"\n className={cx(\n withVendorCSSClassPrefix(bem('change-credential', 'unavailable-content')),\n styles['unavailableContent'],\n )}\n >\n {form}\n </div>\n\n <div\n role=\"status\"\n className={cx(\n withVendorCSSClassPrefix(bem('change-credential', 'unavailable-overlay')),\n styles['unavailableOverlay'],\n )}\n >\n <AlertPrimitive\n variant=\"warning\"\n className={cx(withVendorCSSClassPrefix(bem('change-credential', 'alert')), styles['alert'])}\n >\n <AlertPrimitive.Title>{t('user.change_password.unavailable.heading', labelParams)}</AlertPrimitive.Title>\n <AlertPrimitive.Description>\n {t('user.change_password.unavailable.description', labelParams)}\n </AlertPrimitive.Description>\n </AlertPrimitive>\n </div>\n </div>\n );\n};\n\nexport default BaseChangeCredential;\n"],"mappings":"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"}
@@ -0,0 +1,108 @@
1
+ const require_emotion = require('../../../styles/emotion.cjs');
2
+
3
+ //#region src/components/presentation/ChangeCredential/BaseChangeCredential.styles.ts
4
+ /**
5
+ * Creates styles for the BaseChangeCredential component
6
+ * @param theme - The theme object containing design tokens
7
+ * @param colorScheme - The current color scheme (used for memoization)
8
+ * @returns Object containing CSS class names for component styling
9
+ */
10
+ const useStyles = (theme, colorScheme) => {
11
+ const root = require_emotion.css`
12
+ display: flex;
13
+ flex-direction: column;
14
+ gap: calc(${theme.vars.spacing.unit} * 2);
15
+ width: 100%;
16
+ `;
17
+ const card = require_emotion.css`
18
+ padding: calc(${theme.vars.spacing.unit} * 3);
19
+ border: 1px solid ${theme.vars.colors.border};
20
+ border-radius: ${theme.vars.borderRadius.large};
21
+ `;
22
+ const heading = require_emotion.css`
23
+ margin: 0;
24
+ `;
25
+ const fields = require_emotion.css`
26
+ display: flex;
27
+ flex-direction: column;
28
+ gap: calc(${theme.vars.spacing.unit} * 2);
29
+ `;
30
+ const requirements = require_emotion.css`
31
+ display: flex;
32
+ flex-direction: column;
33
+ gap: calc(${theme.vars.spacing.unit} / 2);
34
+ margin: 0;
35
+ padding: 0;
36
+ list-style: none;
37
+ `;
38
+ const requirementsHeading = require_emotion.css`
39
+ margin: 0 0 calc(${theme.vars.spacing.unit} / 2) 0;
40
+ opacity: 0.8;
41
+ `;
42
+ const requirement = require_emotion.css`
43
+ display: flex;
44
+ align-items: center;
45
+ gap: ${theme.vars.spacing.unit};
46
+ `;
47
+ const requirementPassed = require_emotion.css`
48
+ color: ${theme.vars.colors.success.main};
49
+ `;
50
+ const requirementPending = require_emotion.css`
51
+ opacity: 0.7;
52
+ `;
53
+ const requirementIcon = require_emotion.css`
54
+ flex-shrink: 0;
55
+ width: 14px;
56
+ height: 14px;
57
+ `;
58
+ const alert = require_emotion.css`
59
+ width: 100%;
60
+ `;
61
+ const actions = require_emotion.css`
62
+ display: flex;
63
+ gap: ${theme.vars.spacing.unit};
64
+ align-items: center;
65
+ justify-content: flex-end;
66
+ `;
67
+ const unavailableRoot = require_emotion.css`
68
+ position: relative;
69
+ display: flex;
70
+ width: 100%;
71
+ `;
72
+ return {
73
+ actions,
74
+ alert,
75
+ card,
76
+ colorScheme,
77
+ fields,
78
+ heading,
79
+ requirement,
80
+ requirementIcon,
81
+ requirementPassed,
82
+ requirementPending,
83
+ requirements,
84
+ requirementsHeading,
85
+ root,
86
+ unavailableContent: require_emotion.css`
87
+ width: 100%;
88
+ filter: blur(3px);
89
+ opacity: 0.55;
90
+ pointer-events: none;
91
+ user-select: none;
92
+ `,
93
+ unavailableOverlay: require_emotion.css`
94
+ position: absolute;
95
+ inset: 0;
96
+ display: flex;
97
+ align-items: center;
98
+ justify-content: center;
99
+ padding: calc(${theme.vars.spacing.unit} * 2);
100
+ `,
101
+ unavailableRoot
102
+ };
103
+ };
104
+ var BaseChangeCredential_styles_default = useStyles;
105
+
106
+ //#endregion
107
+ exports.default = BaseChangeCredential_styles_default;
108
+ //# sourceMappingURL=BaseChangeCredential.styles.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseChangeCredential.styles.cjs","names":["root: string","card: string","heading: string","fields: string","requirements: string","requirementsHeading: string","requirement: string","requirementPassed: string","requirementPending: string","requirementIcon: string","alert: string","actions: string","unavailableRoot: string"],"sources":["../../../../../src/components/presentation/ChangeCredential/BaseChangeCredential.styles.ts"],"sourcesContent":["// Copyright 2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {Theme} from '@thunderid/browser';\nimport {css} from '../../../styles/emotion';\n\n/**\n * Creates styles for the BaseChangeCredential component\n * @param theme - The theme object containing design tokens\n * @param colorScheme - The current color scheme (used for memoization)\n * @returns Object containing CSS class names for component styling\n */\nconst useStyles = (theme: Theme, colorScheme: string): Record<string, string> => {\n const root: string = css`\n display: flex;\n flex-direction: column;\n gap: calc(${theme.vars.spacing.unit} * 2);\n width: 100%;\n `;\n\n const card: string = css`\n padding: calc(${theme.vars.spacing.unit} * 3);\n border: 1px solid ${theme.vars.colors.border};\n border-radius: ${theme.vars.borderRadius.large};\n `;\n\n const heading: string = css`\n margin: 0;\n `;\n\n const fields: string = css`\n display: flex;\n flex-direction: column;\n gap: calc(${theme.vars.spacing.unit} * 2);\n `;\n\n const requirements: string = css`\n display: flex;\n flex-direction: column;\n gap: calc(${theme.vars.spacing.unit} / 2);\n margin: 0;\n padding: 0;\n list-style: none;\n `;\n\n const requirementsHeading: string = css`\n margin: 0 0 calc(${theme.vars.spacing.unit} / 2) 0;\n opacity: 0.8;\n `;\n\n const requirement: string = css`\n display: flex;\n align-items: center;\n gap: ${theme.vars.spacing.unit};\n `;\n\n const requirementPassed: string = css`\n color: ${theme.vars.colors.success.main};\n `;\n\n const requirementPending: string = css`\n opacity: 0.7;\n `;\n\n const requirementIcon: string = css`\n flex-shrink: 0;\n width: 14px;\n height: 14px;\n `;\n\n const alert: string = css`\n width: 100%;\n `;\n\n const actions: string = css`\n display: flex;\n gap: ${theme.vars.spacing.unit};\n align-items: center;\n justify-content: flex-end;\n `;\n\n const unavailableRoot: string = css`\n position: relative;\n display: flex;\n width: 100%;\n `;\n\n const unavailableContent: string = css`\n width: 100%;\n filter: blur(3px);\n opacity: 0.55;\n pointer-events: none;\n user-select: none;\n `;\n\n const unavailableOverlay: string = css`\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: calc(${theme.vars.spacing.unit} * 2);\n `;\n\n return {\n actions,\n alert,\n card,\n colorScheme,\n fields,\n heading,\n requirement,\n requirementIcon,\n requirementPassed,\n requirementPending,\n requirements,\n requirementsHeading,\n root,\n unavailableContent,\n unavailableOverlay,\n unavailableRoot,\n };\n};\n\nexport default useStyles;\n"],"mappings":";;;;;;;;;AAYA,MAAM,aAAa,OAAc,gBAAgD;CAC/E,MAAMA,OAAe,mBAAG;;;gBAGV,MAAM,KAAK,QAAQ,KAAK;;;CAItC,MAAMC,OAAe,mBAAG;oBACN,MAAM,KAAK,QAAQ,KAAK;wBACpB,MAAM,KAAK,OAAO,OAAO;qBAC5B,MAAM,KAAK,aAAa,MAAM;;CAGjD,MAAMC,UAAkB,mBAAG;;;CAI3B,MAAMC,SAAiB,mBAAG;;;gBAGZ,MAAM,KAAK,QAAQ,KAAK;;CAGtC,MAAMC,eAAuB,mBAAG;;;gBAGlB,MAAM,KAAK,QAAQ,KAAK;;;;;CAMtC,MAAMC,sBAA8B,mBAAG;uBAClB,MAAM,KAAK,QAAQ,KAAK;;;CAI7C,MAAMC,cAAsB,mBAAG;;;WAGtB,MAAM,KAAK,QAAQ,KAAK;;CAGjC,MAAMC,oBAA4B,mBAAG;aAC1B,MAAM,KAAK,OAAO,QAAQ,KAAK;;CAG1C,MAAMC,qBAA6B,mBAAG;;;CAItC,MAAMC,kBAA0B,mBAAG;;;;;CAMnC,MAAMC,QAAgB,mBAAG;;;CAIzB,MAAMC,UAAkB,mBAAG;;WAElB,MAAM,KAAK,QAAQ,KAAK;;;;CAKjC,MAAMC,kBAA0B,mBAAG;;;;;AAuBnC,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,oBA/BiC,mBAAG;;;;;;;EAgCpC,oBAxBiC,mBAAG;;;;;;oBAMpB,MAAM,KAAK,QAAQ,KAAK;;EAmBxC;EACD;;AAGH,0CAAe"}
@@ -0,0 +1,123 @@
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ const require_useThunderID = require('../../../contexts/ThunderID/useThunderID.cjs');
3
+ const require_useUser = require('../../../contexts/User/useUser.cjs');
4
+ const require_useTranslation = require('../../../hooks/useTranslation.cjs');
5
+ const require_BaseChangeCredential = require('./BaseChangeCredential.cjs');
6
+ const require_updateMeCredentials = require('../../../api/updateMeCredentials.cjs');
7
+ let __thunderid_browser = require("@thunderid/browser");
8
+ __thunderid_browser = require_rolldown_runtime.__toESM(__thunderid_browser);
9
+ let react = require("react");
10
+ react = require_rolldown_runtime.__toESM(react);
11
+ let react_jsx_runtime = require("react/jsx-runtime");
12
+ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
13
+
14
+ //#region src/components/presentation/ChangeCredential/ChangeCredential.tsx
15
+ /**
16
+ * Title-cases a credential attribute name for use as a display-name fallback when the schema
17
+ * declares no `displayName` for it, e.g. `pin` -> `Pin`.
18
+ */
19
+ const defaultDisplayName = (attribute) => attribute.charAt(0).toUpperCase() + attribute.slice(1);
20
+ /**
21
+ * ChangeCredential lets the signed-in user set a new value for one of their own credentials.
22
+ *
23
+ * It collects only a new value and its confirmation. The self-service credential write path
24
+ * does not verify the account's existing value today, so this component does not ask for one;
25
+ * once server-side current-value verification ships, that field returns without a breaking
26
+ * change to this component's public props.
27
+ *
28
+ * It reads the applicable rules from the user schema already resolved by the ThunderID
29
+ * provider, so it adds no network request beyond the write itself, and posts to
30
+ * `/users/me/update-credentials` with the access token attached by the SDK's HTTP client.
31
+ *
32
+ * Defaults to managing the `password` credential. To manage a different one (for example a
33
+ * PIN declared on the user type schema), set `attribute`; render the component once per
34
+ * credential to let a user manage several. Every default label, placeholder and message is
35
+ * built from the attribute's own `displayName` in the schema (`GET /users/me/meta`), so it
36
+ * always matches whatever an admin named the attribute there; when the schema carries no
37
+ * `displayName` for it, it falls back to the attribute name title-cased (`pin` -> `Pin`).
38
+ * Override individual strings via `preferences.i18n` for full control (including other
39
+ * languages) if the schema-derived name isn't the right fit.
40
+ *
41
+ * @example
42
+ * ```tsx
43
+ * // Basic usage, manages the password
44
+ * <ChangeCredential onSuccess={() => toast('Password updated')} />
45
+ *
46
+ * // With an explicit rule instead of the schema-derived policy
47
+ * <ChangeCredential
48
+ * policy={{regex: '^.{12,}$'}}
49
+ * />
50
+ *
51
+ * // Managing a different credential declared on the schema; labels use the schema's own
52
+ * // displayName for it automatically
53
+ * <ChangeCredential attribute="pin" />
54
+ * ```
55
+ */
56
+ const ChangeCredential = ({ attribute = __thunderid_browser.CredentialConstants.PASSWORD, onSuccess = void 0, policy = void 0, preferences = void 0,...rest }) => {
57
+ const { baseUrl, endpoints, instanceId, preferences: contextPreferences } = require_useThunderID.default();
58
+ const { userSchema } = require_useUser.default();
59
+ const resolvedDisplayName = userSchema?.[attribute]?.displayName ?? defaultDisplayName(attribute);
60
+ const resolvedPreferences = (0, react.useMemo)(() => ({
61
+ ...contextPreferences,
62
+ ...preferences,
63
+ user: {
64
+ ...contextPreferences?.user,
65
+ ...preferences?.user
66
+ }
67
+ }), [contextPreferences, preferences]);
68
+ const { t } = require_useTranslation.default(resolvedPreferences?.i18n);
69
+ const [error, setError] = (0, react.useState)(null);
70
+ const [fieldErrors, setFieldErrors] = (0, react.useState)({});
71
+ const [loading, setLoading] = (0, react.useState)(false);
72
+ const [success, setSuccess] = (0, react.useState)(false);
73
+ const resolvedPolicy = (0, react.useMemo)(() => (0, __thunderid_browser.resolveChangeCredentialPolicy)(userSchema, attribute, policy), [
74
+ userSchema,
75
+ attribute,
76
+ policy
77
+ ]);
78
+ const handleSubmit = async ({ newPassword }) => {
79
+ setError(null);
80
+ setFieldErrors({});
81
+ setSuccess(false);
82
+ setLoading(true);
83
+ try {
84
+ await require_updateMeCredentials.default({
85
+ baseUrl,
86
+ instanceId,
87
+ payload: { [attribute]: newPassword },
88
+ url: (0, __thunderid_browser.resolveResourceEndpoint)("usersMeCredentials", { endpoints })
89
+ });
90
+ setSuccess(true);
91
+ onSuccess?.();
92
+ } catch (caughtError) {
93
+ const { field, message, messageKey } = (0, __thunderid_browser.mapCredentialUpdateError)(caughtError);
94
+ const text = message ?? t(messageKey, {
95
+ credential: resolvedDisplayName,
96
+ credentialLower: resolvedDisplayName.toLowerCase()
97
+ });
98
+ if (field) setFieldErrors({ [field]: text });
99
+ else setError(text);
100
+ } finally {
101
+ setLoading(false);
102
+ }
103
+ };
104
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_BaseChangeCredential.default, {
105
+ ...rest,
106
+ credentialDisplayName: resolvedDisplayName,
107
+ error,
108
+ fieldErrors,
109
+ loading,
110
+ policy: resolvedPolicy,
111
+ preferences: resolvedPreferences,
112
+ success,
113
+ unavailable: !(0, __thunderid_browser.supportsCredential)(userSchema, attribute),
114
+ onSubmit: (values) => {
115
+ handleSubmit(values);
116
+ }
117
+ });
118
+ };
119
+ var ChangeCredential_default = ChangeCredential;
120
+
121
+ //#endregion
122
+ exports.default = ChangeCredential_default;
123
+ //# sourceMappingURL=ChangeCredential.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChangeCredential.cjs","names":["ChangeCredential: FC<ChangeCredentialProps>","CredentialConstants","useThunderID","useUser","resolvedDisplayName: string","useTranslation","resolvedPolicy: PasswordPolicy","updateMeCredentials","caughtError: unknown","text: string","BaseChangeCredential"],"sources":["../../../../../src/components/presentation/ChangeCredential/ChangeCredential.tsx"],"sourcesContent":["// Copyright 2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n CredentialConstants,\n CredentialUpdateErrorResult,\n PasswordPolicy,\n mapCredentialUpdateError,\n resolveChangeCredentialPolicy,\n resolveResourceEndpoint,\n supportsCredential,\n} from '@thunderid/browser';\nimport {FC, useMemo, useState} from 'react';\nimport BaseChangeCredential, {BaseChangeCredentialProps, ChangePasswordValues} from './BaseChangeCredential';\nimport updateMeCredentials from '../../../api/updateMeCredentials';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\nimport useUser from '../../../contexts/User/useUser';\nimport useTranslation from '../../../hooks/useTranslation';\n\n/**\n * Title-cases a credential attribute name for use as a display-name fallback when the schema\n * declares no `displayName` for it, e.g. `pin` -> `Pin`.\n */\nconst defaultDisplayName = (attribute: string): string => attribute.charAt(0).toUpperCase() + attribute.slice(1);\n\nexport interface ChangeCredentialProps\n extends Omit<\n BaseChangeCredentialProps,\n 'credentialDisplayName' | 'error' | 'fieldErrors' | 'loading' | 'onSubmit' | 'success'\n > {\n /**\n * The credential attribute this instance manages, any attribute the user's entity type\n * schema declares `credential: true` (for example `password` or `pin`). Defaults to\n * `password`. Render the component once per credential to let a user manage more than one,\n * for example `<ChangeCredential />` for the password and\n * `<ChangeCredential attribute=\"pin\" />` for a PIN.\n */\n attribute?: string;\n /**\n * Called after the credential has been changed successfully.\n */\n onSuccess?: () => void;\n}\n\n/**\n * ChangeCredential lets the signed-in user set a new value for one of their own credentials.\n *\n * It collects only a new value and its confirmation. The self-service credential write path\n * does not verify the account's existing value today, so this component does not ask for one;\n * once server-side current-value verification ships, that field returns without a breaking\n * change to this component's public props.\n *\n * It reads the applicable rules from the user schema already resolved by the ThunderID\n * provider, so it adds no network request beyond the write itself, and posts to\n * `/users/me/update-credentials` with the access token attached by the SDK's HTTP client.\n *\n * Defaults to managing the `password` credential. To manage a different one (for example a\n * PIN declared on the user type schema), set `attribute`; render the component once per\n * credential to let a user manage several. Every default label, placeholder and message is\n * built from the attribute's own `displayName` in the schema (`GET /users/me/meta`), so it\n * always matches whatever an admin named the attribute there; when the schema carries no\n * `displayName` for it, it falls back to the attribute name title-cased (`pin` -> `Pin`).\n * Override individual strings via `preferences.i18n` for full control (including other\n * languages) if the schema-derived name isn't the right fit.\n *\n * @example\n * ```tsx\n * // Basic usage, manages the password\n * <ChangeCredential onSuccess={() => toast('Password updated')} />\n *\n * // With an explicit rule instead of the schema-derived policy\n * <ChangeCredential\n * policy={{regex: '^.{12,}$'}}\n * />\n *\n * // Managing a different credential declared on the schema; labels use the schema's own\n * // displayName for it automatically\n * <ChangeCredential attribute=\"pin\" />\n * ```\n */\nconst ChangeCredential: FC<ChangeCredentialProps> = ({\n attribute = CredentialConstants.PASSWORD,\n onSuccess = undefined,\n policy = undefined,\n preferences = undefined,\n ...rest\n}: ChangeCredentialProps) => {\n const {baseUrl, endpoints, instanceId, preferences: contextPreferences} = useThunderID();\n const {userSchema} = useUser();\n const resolvedDisplayName: string = userSchema?.[attribute]?.displayName ?? defaultDisplayName(attribute);\n\n const resolvedPreferences = useMemo(\n () => ({\n ...contextPreferences,\n ...preferences,\n user: {...contextPreferences?.user, ...preferences?.user},\n }),\n [contextPreferences, preferences],\n );\n const {t} = useTranslation(resolvedPreferences?.i18n);\n\n const [error, setError] = useState<string | null>(null);\n const [fieldErrors, setFieldErrors] = useState<Record<string, string>>({});\n const [loading, setLoading] = useState<boolean>(false);\n const [success, setSuccess] = useState<boolean>(false);\n\n const resolvedPolicy: PasswordPolicy = useMemo(\n () => resolveChangeCredentialPolicy(userSchema, attribute, policy),\n [userSchema, attribute, policy],\n );\n\n const handleSubmit = async ({newPassword}: ChangePasswordValues): Promise<void> => {\n setError(null);\n setFieldErrors({});\n setSuccess(false);\n setLoading(true);\n\n try {\n await updateMeCredentials({\n baseUrl,\n instanceId,\n payload: {[attribute]: newPassword},\n url: resolveResourceEndpoint('usersMeCredentials', {endpoints}),\n });\n\n setSuccess(true);\n onSuccess?.();\n } catch (caughtError: unknown) {\n const {field, message, messageKey}: CredentialUpdateErrorResult = mapCredentialUpdateError(caughtError);\n const text: string =\n message ?? t(messageKey, {credential: resolvedDisplayName, credentialLower: resolvedDisplayName.toLowerCase()});\n\n if (field) {\n setFieldErrors({[field]: text});\n } else {\n setError(text);\n }\n } finally {\n setLoading(false);\n }\n };\n\n return (\n <BaseChangeCredential\n {...rest}\n credentialDisplayName={resolvedDisplayName}\n error={error}\n fieldErrors={fieldErrors}\n loading={loading}\n policy={resolvedPolicy}\n preferences={resolvedPreferences}\n success={success}\n unavailable={!supportsCredential(userSchema, attribute)}\n onSubmit={(values: ChangePasswordValues): void => {\n void handleSubmit(values);\n }}\n />\n );\n};\n\nexport default ChangeCredential;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuBA,MAAM,sBAAsB,cAA8B,UAAU,OAAO,EAAE,CAAC,aAAa,GAAG,UAAU,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDhH,MAAMA,oBAA+C,EACnD,YAAYC,wCAAoB,UAChC,YAAY,QACZ,SAAS,QACT,cAAc,OACd,GAAG,WACwB;CAC3B,MAAM,EAAC,SAAS,WAAW,YAAY,aAAa,uBAAsBC,8BAAc;CACxF,MAAM,EAAC,eAAcC,yBAAS;CAC9B,MAAMC,sBAA8B,aAAa,YAAY,eAAe,mBAAmB,UAAU;CAEzG,MAAM,gDACG;EACL,GAAG;EACH,GAAG;EACH,MAAM;GAAC,GAAG,oBAAoB;GAAM,GAAG,aAAa;GAAK;EAC1D,GACD,CAAC,oBAAoB,YAAY,CAClC;CACD,MAAM,EAAC,MAAKC,+BAAe,qBAAqB,KAAK;CAErD,MAAM,CAAC,OAAO,gCAAoC,KAAK;CACvD,MAAM,CAAC,aAAa,sCAAmD,EAAE,CAAC;CAC1E,MAAM,CAAC,SAAS,kCAAgC,MAAM;CACtD,MAAM,CAAC,SAAS,kCAAgC,MAAM;CAEtD,MAAMC,iGACgC,YAAY,WAAW,OAAO,EAClE;EAAC;EAAY;EAAW;EAAO,CAChC;CAED,MAAM,eAAe,OAAO,EAAC,kBAAsD;AACjF,WAAS,KAAK;AACd,iBAAe,EAAE,CAAC;AAClB,aAAW,MAAM;AACjB,aAAW,KAAK;AAEhB,MAAI;AACF,SAAMC,oCAAoB;IACxB;IACA;IACA,SAAS,GAAE,YAAY,aAAY;IACnC,sDAA6B,sBAAsB,EAAC,WAAU,CAAC;IAChE,CAAC;AAEF,cAAW,KAAK;AAChB,gBAAa;WACNC,aAAsB;GAC7B,MAAM,EAAC,OAAO,SAAS,iEAAoE,YAAY;GACvG,MAAMC,OACJ,WAAW,EAAE,YAAY;IAAC,YAAY;IAAqB,iBAAiB,oBAAoB,aAAa;IAAC,CAAC;AAEjH,OAAI,MACF,gBAAe,GAAE,QAAQ,MAAK,CAAC;OAE/B,UAAS,KAAK;YAER;AACR,cAAW,MAAM;;;AAIrB,QACE,2CAACC;EACC,GAAI;EACJ,uBAAuB;EAChB;EACM;EACJ;EACT,QAAQ;EACR,aAAa;EACJ;EACT,aAAa,6CAAoB,YAAY,UAAU;EACvD,WAAW,WAAuC;AAChD,GAAK,aAAa,OAAO;;GAE3B;;AAIN,+BAAe"}
@@ -1,8 +1,8 @@
1
1
  const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
2
  const require_emotion = require('../../../styles/emotion.cjs');
3
3
  const require_useTheme = require('../../../contexts/Theme/useTheme.cjs');
4
- const require_BaseLanguageSwitcher_styles = require('./BaseLanguageSwitcher.styles.cjs');
5
4
  const require_Check = require('../../primitives/Icons/Check.cjs');
5
+ const require_BaseLanguageSwitcher_styles = require('./BaseLanguageSwitcher.styles.cjs');
6
6
  const require_ChevronDown = require('../../primitives/Icons/ChevronDown.cjs');
7
7
  let react = require("react");
8
8
  react = require_rolldown_runtime.__toESM(react);
@@ -24,7 +24,7 @@ __floating_ui_react = require_rolldown_runtime.__toESM(__floating_ui_react);
24
24
  * When clicked, it shows a popover with customizable menu items.
25
25
  * This component serves as the base for framework-specific implementations.
26
26
  */
27
- const BaseUserDropdown = ({ fallback = null, className = "", user, isLoading = false, portalId = "thunderid-user-dropdown", menuItems = [], showTriggerLabel = false, avatarSize = 32, onManageProfile, onSignOut, attributeMapping = {} }) => {
27
+ const BaseUserDropdown = ({ fallback = null, className = "", user, isLoading = false, portalId = "thunderid-user-dropdown", menuItems = [], showTriggerLabel = false, avatarSize = 32, manageProfileLabel = "Manage Profile", onManageProfile, onSignOut, attributeMapping = {} }) => {
28
28
  const { theme, colorScheme } = require_useTheme.default();
29
29
  const styles = require_BaseUserDropdown_styles.default(theme, colorScheme);
30
30
  const [isOpen, setIsOpen] = (0, react.useState)(false);
@@ -73,7 +73,7 @@ const BaseUserDropdown = ({ fallback = null, className = "", user, isLoading = f
73
73
  width: "16",
74
74
  height: "16"
75
75
  }),
76
- label: "Manage Profile",
76
+ label: manageProfileLabel,
77
77
  onClick: onManageProfile
78
78
  });
79
79
  if (onSignOut) defaultMenuItems.push({