@better-auth-ui/heroui 1.6.8 → 1.6.9

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 (270) hide show
  1. package/dist/components/auth/additional-field.d.ts +2 -2
  2. package/dist/components/auth/additional-field.js +133 -266
  3. package/dist/components/auth/api-key/api-key-skeleton.js +4 -20
  4. package/dist/components/auth/api-key/api-key.d.ts +6 -2
  5. package/dist/components/auth/api-key/api-key.js +16 -54
  6. package/dist/components/auth/api-key/api-keys-empty.d.ts +3 -1
  7. package/dist/components/auth/api-key/api-keys-empty.js +8 -34
  8. package/dist/components/auth/api-key/api-keys.d.ts +10 -2
  9. package/dist/components/auth/api-key/api-keys.js +21 -40
  10. package/dist/components/auth/api-key/create-api-key-dialog.d.ts +3 -1
  11. package/dist/components/auth/api-key/create-api-key-dialog.js +43 -73
  12. package/dist/components/auth/api-key/delete-api-key-dialog.d.ts +4 -2
  13. package/dist/components/auth/api-key/delete-api-key-dialog.js +16 -50
  14. package/dist/components/auth/api-key/new-api-key-dialog.js +23 -59
  15. package/dist/components/auth/api-key/organization-api-keys.d.ts +14 -0
  16. package/dist/components/auth/api-key/organization-api-keys.js +22 -0
  17. package/dist/components/auth/auth-provider.d.ts +1 -1
  18. package/dist/components/auth/auth-provider.js +10 -16
  19. package/dist/components/auth/auth.d.ts +3 -3
  20. package/dist/components/auth/auth.js +86 -61
  21. package/dist/components/auth/delete-user/danger-zone.d.ts +3 -3
  22. package/dist/components/auth/delete-user/danger-zone.js +11 -17
  23. package/dist/components/auth/delete-user/delete-account.d.ts +9 -0
  24. package/dist/components/auth/delete-user/delete-account.js +50 -0
  25. package/dist/components/auth/email/email-changed-email.d.ts +2 -2
  26. package/dist/components/auth/email/email-changed-email.js +22 -29
  27. package/dist/components/auth/email/email-verification-email.d.ts +2 -2
  28. package/dist/components/auth/email/email-verification-email.js +22 -29
  29. package/dist/components/auth/email/magic-link-email.d.ts +2 -2
  30. package/dist/components/auth/email/magic-link-email.js +22 -29
  31. package/dist/components/auth/email/new-device-email.d.ts +2 -2
  32. package/dist/components/auth/email/new-device-email.js +22 -29
  33. package/dist/components/auth/email/organization-invitation-email.d.ts +3 -0
  34. package/dist/components/auth/email/organization-invitation-email.js +23 -0
  35. package/dist/components/auth/email/otp-email.d.ts +2 -2
  36. package/dist/components/auth/email/otp-email.js +21 -28
  37. package/dist/components/auth/email/password-changed-email.d.ts +2 -2
  38. package/dist/components/auth/email/password-changed-email.js +22 -29
  39. package/dist/components/auth/email/reset-password-email.d.ts +2 -2
  40. package/dist/components/auth/email/reset-password-email.js +22 -29
  41. package/dist/components/auth/error-toaster.js +32 -16
  42. package/dist/components/auth/field-separator.d.ts +1 -1
  43. package/dist/components/auth/field-separator.js +4 -17
  44. package/dist/components/auth/forgot-password.d.ts +1 -1
  45. package/dist/components/auth/forgot-password.js +36 -88
  46. package/dist/components/auth/magic-link/magic-link-button.d.ts +1 -1
  47. package/dist/components/auth/magic-link/magic-link-button.js +33 -19
  48. package/dist/components/auth/magic-link/magic-link.d.ts +2 -2
  49. package/dist/components/auth/magic-link/magic-link.js +39 -86
  50. package/dist/components/auth/multi-session/manage-account.d.ts +1 -1
  51. package/dist/components/auth/multi-session/manage-account.js +32 -48
  52. package/dist/components/auth/multi-session/manage-accounts.d.ts +1 -1
  53. package/dist/components/auth/multi-session/manage-accounts.js +32 -33
  54. package/dist/components/auth/multi-session/switch-account-submenu-content.d.ts +3 -1
  55. package/dist/components/auth/multi-session/switch-account-submenu-content.js +24 -27
  56. package/dist/components/auth/multi-session/switch-account-submenu-item.d.ts +3 -2
  57. package/dist/components/auth/multi-session/switch-account-submenu-item.js +16 -19
  58. package/dist/components/auth/multi-session/switch-account-submenu.d.ts +2 -1
  59. package/dist/components/auth/multi-session/switch-account-submenu.js +23 -23
  60. package/dist/components/auth/organization/change-organization-logo.d.ts +4 -0
  61. package/dist/components/auth/organization/change-organization-logo.js +69 -0
  62. package/dist/components/auth/organization/create-organization-dialog.d.ts +13 -0
  63. package/dist/components/auth/organization/create-organization-dialog.js +37 -0
  64. package/dist/components/auth/organization/delete-organization-dialog.d.ts +7 -0
  65. package/dist/components/auth/organization/delete-organization-dialog.js +25 -0
  66. package/dist/components/auth/organization/delete-organization-skeleton.d.ts +4 -0
  67. package/dist/components/auth/organization/delete-organization-skeleton.js +8 -0
  68. package/dist/components/auth/organization/delete-organization.d.ts +5 -0
  69. package/dist/components/auth/organization/delete-organization.js +27 -0
  70. package/dist/components/auth/organization/invite-member-dialog.d.ts +13 -0
  71. package/dist/components/auth/organization/invite-member-dialog.js +47 -0
  72. package/dist/components/auth/organization/leave-organization-dialog.d.ts +7 -0
  73. package/dist/components/auth/organization/leave-organization-dialog.js +21 -0
  74. package/dist/components/auth/organization/leave-organization.d.ts +4 -0
  75. package/dist/components/auth/organization/leave-organization.js +16 -0
  76. package/dist/components/auth/organization/organization-danger-zone.d.ts +16 -0
  77. package/dist/components/auth/organization/organization-danger-zone.js +23 -0
  78. package/dist/components/auth/organization/organization-invitation-row-skeleton.d.ts +5 -0
  79. package/dist/components/auth/organization/organization-invitation-row-skeleton.js +9 -0
  80. package/dist/components/auth/organization/organization-invitation-row.d.ts +5 -0
  81. package/dist/components/auth/organization/organization-invitation-row.js +31 -0
  82. package/dist/components/auth/organization/organization-invitations-empty.d.ts +8 -0
  83. package/dist/components/auth/organization/organization-invitations-empty.js +13 -0
  84. package/dist/components/auth/organization/organization-invitations.d.ts +9 -0
  85. package/dist/components/auth/organization/organization-invitations.js +66 -0
  86. package/dist/components/auth/organization/organization-logo.d.ts +15 -0
  87. package/dist/components/auth/organization/organization-logo.js +14 -0
  88. package/dist/components/auth/organization/organization-member-row-skeleton.d.ts +4 -0
  89. package/dist/components/auth/organization/organization-member-row-skeleton.js +9 -0
  90. package/dist/components/auth/organization/organization-member-row.d.ts +9 -0
  91. package/dist/components/auth/organization/organization-member-row.js +34 -0
  92. package/dist/components/auth/organization/organization-members.d.ts +9 -0
  93. package/dist/components/auth/organization/organization-members.js +67 -0
  94. package/dist/components/auth/organization/organization-people.d.ts +10 -0
  95. package/dist/components/auth/organization/organization-people.js +11 -0
  96. package/dist/components/auth/organization/organization-profile.d.ts +9 -0
  97. package/dist/components/auth/organization/organization-profile.js +34 -0
  98. package/dist/components/auth/organization/organization-row.d.ts +8 -0
  99. package/dist/components/auth/organization/organization-row.js +31 -0
  100. package/dist/components/auth/organization/organization-settings.d.ts +12 -0
  101. package/dist/components/auth/organization/organization-settings.js +13 -0
  102. package/dist/components/auth/organization/organization-switcher.d.ts +20 -0
  103. package/dist/components/auth/organization/organization-switcher.js +48 -0
  104. package/dist/components/auth/organization/organization-view-skeleton.d.ts +6 -0
  105. package/dist/components/auth/organization/organization-view-skeleton.js +9 -0
  106. package/dist/components/auth/organization/organization-view.d.ts +15 -0
  107. package/dist/components/auth/organization/organization-view.js +31 -0
  108. package/dist/components/auth/organization/organization.d.ts +17 -0
  109. package/dist/components/auth/organization/organization.js +60 -0
  110. package/dist/components/auth/organization/organizations-empty.d.ts +4 -0
  111. package/dist/components/auth/organization/organizations-empty.js +9 -0
  112. package/dist/components/auth/organization/organizations-settings.d.ts +17 -0
  113. package/dist/components/auth/organization/organizations-settings.js +17 -0
  114. package/dist/components/auth/organization/organizations.d.ts +10 -0
  115. package/dist/components/auth/organization/organizations.js +21 -0
  116. package/dist/components/auth/organization/remove-member-dialog.d.ts +9 -0
  117. package/dist/components/auth/organization/remove-member-dialog.js +20 -0
  118. package/dist/components/auth/organization/slug-field.d.ts +19 -0
  119. package/dist/components/auth/organization/slug-field.js +38 -0
  120. package/dist/components/auth/organization/user-invitation-row-skeleton.d.ts +4 -0
  121. package/dist/components/auth/organization/user-invitation-row-skeleton.js +8 -0
  122. package/dist/components/auth/organization/user-invitation-row.d.ts +10 -0
  123. package/dist/components/auth/organization/user-invitation-row.js +22 -0
  124. package/dist/components/auth/organization/user-invitations-empty.d.ts +4 -0
  125. package/dist/components/auth/organization/user-invitations-empty.js +12 -0
  126. package/dist/components/auth/organization/user-invitations.d.ts +10 -0
  127. package/dist/components/auth/organization/user-invitations.js +18 -0
  128. package/dist/components/auth/passkey/add-passkey-dialog.js +21 -64
  129. package/dist/components/auth/passkey/delete-passkey-dialog.js +13 -46
  130. package/dist/components/auth/passkey/passkey-button.d.ts +1 -1
  131. package/dist/components/auth/passkey/passkey-button.js +24 -23
  132. package/dist/components/auth/passkey/passkey-skeleton.js +4 -16
  133. package/dist/components/auth/passkey/passkey.d.ts +1 -1
  134. package/dist/components/auth/passkey/passkey.js +16 -47
  135. package/dist/components/auth/passkey/passkeys-empty.js +8 -34
  136. package/dist/components/auth/passkey/passkeys.d.ts +1 -1
  137. package/dist/components/auth/passkey/passkeys.js +15 -41
  138. package/dist/components/auth/provider-button.d.ts +2 -2
  139. package/dist/components/auth/provider-button.js +28 -24
  140. package/dist/components/auth/provider-buttons.js +28 -18
  141. package/dist/components/auth/reset-password.d.ts +1 -1
  142. package/dist/components/auth/reset-password.js +56 -146
  143. package/dist/components/auth/settings/account/account-settings.d.ts +2 -2
  144. package/dist/components/auth/settings/account/account-settings.js +21 -19
  145. package/dist/components/auth/settings/account/change-avatar.js +53 -88
  146. package/dist/components/auth/settings/account/change-email.d.ts +1 -1
  147. package/dist/components/auth/settings/account/change-email.js +27 -53
  148. package/dist/components/auth/settings/account/user-profile.d.ts +1 -1
  149. package/dist/components/auth/settings/account/user-profile.js +64 -85
  150. package/dist/components/auth/settings/security/active-session.d.ts +1 -1
  151. package/dist/components/auth/settings/security/active-session.js +50 -57
  152. package/dist/components/auth/settings/security/active-sessions.d.ts +1 -1
  153. package/dist/components/auth/settings/security/active-sessions.js +21 -32
  154. package/dist/components/auth/settings/security/change-password.d.ts +1 -1
  155. package/dist/components/auth/settings/security/change-password.js +76 -186
  156. package/dist/components/auth/settings/security/linked-account.d.ts +1 -1
  157. package/dist/components/auth/settings/security/linked-account.js +37 -55
  158. package/dist/components/auth/settings/security/linked-accounts.d.ts +1 -1
  159. package/dist/components/auth/settings/security/linked-accounts.js +34 -43
  160. package/dist/components/auth/settings/security/security-settings.d.ts +2 -2
  161. package/dist/components/auth/settings/security/security-settings.js +19 -21
  162. package/dist/components/auth/settings/settings.d.ts +4 -4
  163. package/dist/components/auth/settings/settings.js +52 -44
  164. package/dist/components/auth/sign-in.d.ts +2 -2
  165. package/dist/components/auth/sign-in.js +63 -132
  166. package/dist/components/auth/sign-out.js +32 -26
  167. package/dist/components/auth/sign-up.d.ts +2 -2
  168. package/dist/components/auth/sign-up.js +97 -211
  169. package/dist/components/auth/theme/appearance.d.ts +1 -1
  170. package/dist/components/auth/theme/appearance.js +23 -71
  171. package/dist/components/auth/theme/theme-toggle-item.js +56 -61
  172. package/dist/components/auth/user/user-avatar.d.ts +4 -4
  173. package/dist/components/auth/user/user-avatar.js +31 -28
  174. package/dist/components/auth/user/user-button.d.ts +6 -7
  175. package/dist/components/auth/user/user-button.js +38 -72
  176. package/dist/components/auth/user/user-view.d.ts +13 -7
  177. package/dist/components/auth/user/user-view.js +26 -36
  178. package/dist/components/auth/username/sign-in-username.d.ts +2 -2
  179. package/dist/components/auth/username/sign-in-username.js +87 -147
  180. package/dist/components/auth/username/username-field.d.ts +1 -1
  181. package/dist/components/auth/username/username-field.js +44 -52
  182. package/dist/email.d.ts +8 -7
  183. package/dist/email.js +8 -8
  184. package/dist/index.d.ts +21 -21
  185. package/dist/index.js +21 -22
  186. package/dist/lib/auth/api-key-plugin.d.ts +7 -4
  187. package/dist/lib/auth/api-key-plugin.js +12 -10
  188. package/dist/lib/auth/auth-plugin.d.ts +10 -6
  189. package/dist/lib/auth/auth-plugin.js +1 -0
  190. package/dist/lib/auth/delete-user-plugin.d.ts +6 -6
  191. package/dist/lib/auth/delete-user-plugin.js +6 -9
  192. package/dist/lib/auth/magic-link-plugin.d.ts +5 -5
  193. package/dist/lib/auth/magic-link-plugin.js +17 -12
  194. package/dist/lib/auth/multi-session-plugin.d.ts +5 -5
  195. package/dist/lib/auth/multi-session-plugin.js +8 -11
  196. package/dist/lib/auth/organization-plugin.d.ts +37 -0
  197. package/dist/lib/auth/organization-plugin.js +19 -0
  198. package/dist/lib/auth/passkey-plugin.d.ts +5 -5
  199. package/dist/lib/auth/passkey-plugin.js +8 -11
  200. package/dist/lib/auth/theme-plugin.d.ts +6 -6
  201. package/dist/lib/auth/theme-plugin.js +25 -22
  202. package/dist/lib/auth/username-plugin.d.ts +11 -11
  203. package/dist/lib/auth/username-plugin.js +18 -17
  204. package/dist/plugins.d.ts +46 -22
  205. package/dist/plugins.js +47 -22
  206. package/package.json +25 -19
  207. package/src/components/auth/api-key/api-key.tsx +25 -16
  208. package/src/components/auth/api-key/api-keys-empty.tsx +8 -4
  209. package/src/components/auth/api-key/api-keys.tsx +52 -14
  210. package/src/components/auth/api-key/create-api-key-dialog.tsx +15 -2
  211. package/src/components/auth/api-key/delete-api-key-dialog.tsx +10 -2
  212. package/src/components/auth/api-key/organization-api-keys.tsx +55 -0
  213. package/src/components/auth/delete-user/danger-zone.tsx +3 -3
  214. package/src/components/auth/delete-user/{delete-user.tsx → delete-account.tsx} +9 -9
  215. package/src/components/auth/email/organization-invitation-email.tsx +38 -0
  216. package/src/components/auth/error-toaster.tsx +28 -10
  217. package/src/components/auth/forgot-password.tsx +10 -2
  218. package/src/components/auth/multi-session/manage-accounts.tsx +1 -1
  219. package/src/components/auth/multi-session/switch-account-submenu-content.tsx +7 -2
  220. package/src/components/auth/multi-session/switch-account-submenu-item.tsx +4 -2
  221. package/src/components/auth/multi-session/switch-account-submenu.tsx +8 -4
  222. package/src/components/auth/organization/change-organization-logo.tsx +171 -0
  223. package/src/components/auth/organization/create-organization-dialog.tsx +133 -0
  224. package/src/components/auth/organization/delete-organization-dialog.tsx +97 -0
  225. package/src/components/auth/organization/delete-organization-skeleton.tsx +17 -0
  226. package/src/components/auth/organization/delete-organization.tsx +77 -0
  227. package/src/components/auth/organization/invite-member-dialog.tsx +177 -0
  228. package/src/components/auth/organization/leave-organization-dialog.tsx +95 -0
  229. package/src/components/auth/organization/leave-organization.tsx +59 -0
  230. package/src/components/auth/organization/organization-danger-zone.tsx +68 -0
  231. package/src/components/auth/organization/organization-invitation-row-skeleton.tsx +29 -0
  232. package/src/components/auth/organization/organization-invitation-row.tsx +97 -0
  233. package/src/components/auth/organization/organization-invitations-empty.tsx +39 -0
  234. package/src/components/auth/organization/organization-invitations.tsx +351 -0
  235. package/src/components/auth/organization/organization-logo.tsx +64 -0
  236. package/src/components/auth/organization/organization-member-row-skeleton.tsx +24 -0
  237. package/src/components/auth/organization/organization-member-row.tsx +157 -0
  238. package/src/components/auth/organization/organization-members.tsx +284 -0
  239. package/src/components/auth/organization/organization-people.tsx +26 -0
  240. package/src/components/auth/organization/organization-profile.tsx +141 -0
  241. package/src/components/auth/organization/organization-row.tsx +66 -0
  242. package/src/components/auth/organization/organization-settings.tsx +38 -0
  243. package/src/components/auth/organization/organization-switcher.tsx +233 -0
  244. package/src/components/auth/organization/organization-view-skeleton.tsx +36 -0
  245. package/src/components/auth/organization/organization-view.tsx +109 -0
  246. package/src/components/auth/organization/organization.tsx +162 -0
  247. package/src/components/auth/organization/organizations-empty.tsx +35 -0
  248. package/src/components/auth/organization/organizations-settings.tsx +36 -0
  249. package/src/components/auth/organization/organizations.tsx +80 -0
  250. package/src/components/auth/organization/remove-member-dialog.tsx +95 -0
  251. package/src/components/auth/organization/slug-field.tsx +111 -0
  252. package/src/components/auth/organization/user-invitation-row-skeleton.tsx +17 -0
  253. package/src/components/auth/organization/user-invitation-row.tsx +90 -0
  254. package/src/components/auth/organization/user-invitations-empty.tsx +30 -0
  255. package/src/components/auth/organization/user-invitations.tsx +59 -0
  256. package/src/components/auth/settings/account/change-email.tsx +1 -1
  257. package/src/components/auth/settings/account/user-profile.tsx +5 -5
  258. package/src/components/auth/settings/security/active-sessions.tsx +6 -4
  259. package/src/components/auth/settings/security/linked-accounts.tsx +2 -2
  260. package/src/components/auth/settings/settings.tsx +77 -14
  261. package/src/components/auth/user/user-avatar.tsx +4 -1
  262. package/src/components/auth/user/user-button.tsx +14 -11
  263. package/src/components/auth/user/user-view.tsx +32 -12
  264. package/src/email.ts +1 -0
  265. package/src/lib/auth/api-key-plugin.ts +10 -4
  266. package/src/lib/auth/auth-plugin.ts +6 -1
  267. package/src/lib/auth/organization-plugin.tsx +32 -0
  268. package/src/plugins.ts +25 -1
  269. package/dist/components/auth/delete-user/delete-user.d.ts +0 -9
  270. package/dist/components/auth/delete-user/delete-user.js +0 -95
@@ -1,189 +1,79 @@
1
- import { useAuth as e, useChangePassword as t, useListAccounts as n, useRequestPasswordReset as r, useSession as i } from "@better-auth-ui/react";
2
- import { Eye as a, EyeSlash as o } from "@gravity-ui/icons";
3
- import { Button as s, Card as c, FieldError as l, Fieldset as u, Form as d, Input as f, InputGroup as p, Label as m, Skeleton as h, Spinner as g, TextField as _, cn as v, toast as y } from "@heroui/react";
4
- import { useState as b } from "react";
5
- import { jsx as x, jsxs as S } from "react/jsx-runtime";
6
- //#region src/components/auth/settings/security/change-password.tsx
7
- function C({ className: t, variant: r, ...a }) {
8
- let { authClient: o, emailAndPassword: s, localization: c } = e(), { data: l } = i(o), { data: u, isPending: d } = n(o), f = u?.some((e) => e.providerId === "credential");
9
- return !d && !f ? /* @__PURE__ */ x(w, {
10
- className: t,
11
- variant: r,
12
- ...a
13
- }) : /* @__PURE__ */ x(T, {
14
- className: t,
15
- variant: r,
16
- emailAndPassword: s,
17
- localization: c,
18
- session: d ? void 0 : l,
19
- ...a
20
- });
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useAuth, useChangePassword, useListAccounts, useRequestPasswordReset, useSession } from "@better-auth-ui/react";
3
+ import { Eye, EyeSlash } from "@gravity-ui/icons";
4
+ import { Button, Card, cn, FieldError, Fieldset, Form, Input, InputGroup, Label, Skeleton, Spinner, TextField, toast } from "@heroui/react";
5
+ import { useState } from "react";
6
+ /**
7
+ * Render a card form for changing the authenticated user's password.
8
+ *
9
+ * When the user has a credential account, displays fields for current password,
10
+ * new password, and optionally confirm password. When the user only has social
11
+ * accounts, displays a prompt to set a password via the reset flow.
12
+ *
13
+ * @returns A JSX element containing the change-password or set-password card
14
+ */
15
+ export function ChangePassword({ className, variant, ...props }) {
16
+ const { authClient, emailAndPassword, localization } = useAuth();
17
+ const { data: session } = useSession(authClient);
18
+ const { data: accounts, isPending: isAccountsPending } = useListAccounts(authClient);
19
+ const hasCredentialAccount = accounts?.some((account) => account.providerId === "credential");
20
+ if (!isAccountsPending && !hasCredentialAccount) {
21
+ return _jsx(SetPassword, { className: className, variant: variant, ...props });
22
+ }
23
+ return (_jsx(ChangePasswordForm, { className: className, variant: variant, emailAndPassword: emailAndPassword, localization: localization, session: isAccountsPending ? undefined : session, ...props }));
21
24
  }
22
- function w({ className: t, variant: n, ...a }) {
23
- let { authClient: o, localization: l } = e(), { data: u } = i(o), { mutate: d, isPending: f } = r(o, { onSuccess: () => y.success(l.auth.passwordResetEmailSent) }), p = () => {
24
- u?.user.email && d({ email: u.user.email });
25
- };
26
- return /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("h2", {
27
- className: v("text-sm font-semibold mb-3"),
28
- children: l.settings.changePassword
29
- }), /* @__PURE__ */ x(c, {
30
- className: v(t),
31
- variant: n,
32
- ...a,
33
- children: /* @__PURE__ */ S(c.Content, {
34
- className: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",
35
- children: [/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("p", {
36
- className: "text-sm font-medium leading-tight",
37
- children: l.settings.setPassword
38
- }), /* @__PURE__ */ x("p", {
39
- className: "text-muted text-xs mt-0.5",
40
- children: l.settings.setPasswordDescription
41
- })] }), /* @__PURE__ */ S(s, {
42
- size: "sm",
43
- isPending: f,
44
- isDisabled: !u,
45
- onPress: p,
46
- children: [f && /* @__PURE__ */ x(g, {
47
- color: "current",
48
- size: "sm"
49
- }), l.auth.sendResetLink]
50
- })]
51
- })
52
- })] });
25
+ function SetPassword({ className, variant, ...props }) {
26
+ const { authClient, localization } = useAuth();
27
+ const { data: session } = useSession(authClient);
28
+ const { mutate: requestPasswordReset, isPending } = useRequestPasswordReset(authClient, {
29
+ onSuccess: () => toast.success(localization.auth.passwordResetEmailSent)
30
+ });
31
+ const handleSetPassword = () => {
32
+ if (!session?.user.email)
33
+ return;
34
+ requestPasswordReset({ email: session.user.email });
35
+ };
36
+ return (_jsxs("div", { children: [_jsx("h2", { className: cn("text-sm font-semibold mb-3"), children: localization.settings.changePassword }), _jsx(Card, { className: cn(className), variant: variant, ...props, children: _jsxs(Card.Content, { className: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between", children: [_jsxs("div", { children: [_jsx("p", { className: "text-sm font-medium leading-tight", children: localization.settings.setPassword }), _jsx("p", { className: "text-muted text-xs mt-0.5", children: localization.settings.setPasswordDescription })] }), _jsxs(Button, { size: "sm", isPending: isPending, isDisabled: !session, onPress: handleSetPassword, children: [isPending && _jsx(Spinner, { color: "current", size: "sm" }), localization.auth.sendResetLink] })] }) })] }));
53
37
  }
54
- function T({ className: n, variant: r, emailAndPassword: i, localization: C, session: w, ...T }) {
55
- let { authClient: E } = e(), [D, O] = b(""), [k, A] = b(""), [j, M] = b(""), { mutate: N, isPending: P } = t(E, {
56
- onError: (e) => {
57
- O(""), A(""), M(""), y.danger(e.error?.message || e.message);
58
- },
59
- onSuccess: () => {
60
- O(""), A(""), M(""), y.success(C.settings.changePasswordSuccess);
61
- }
62
- }), [F, I] = b(!1), [L, R] = b(!1), z = (e) => {
63
- if (e.preventDefault(), i?.confirmPassword && k !== j) {
64
- O(""), A(""), M(""), y.danger(C.auth.passwordsDoNotMatch);
65
- return;
66
- }
67
- N({
68
- currentPassword: D,
69
- newPassword: k,
70
- revokeOtherSessions: !0
71
- });
72
- };
73
- return /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("h2", {
74
- className: v("text-sm font-semibold mb-3"),
75
- children: C.settings.changePassword
76
- }), /* @__PURE__ */ x(c, {
77
- className: v("p-4 gap-4", n),
78
- variant: r,
79
- ...T,
80
- children: /* @__PURE__ */ x(c.Content, { children: /* @__PURE__ */ x(d, {
81
- onSubmit: z,
82
- children: /* @__PURE__ */ S(u, {
83
- className: "w-full gap-4",
84
- children: [/* @__PURE__ */ S(u.Group, { children: [
85
- /* @__PURE__ */ S(_, {
86
- name: "currentPassword",
87
- type: "password",
88
- isDisabled: P || !w,
89
- defaultValue: "",
90
- value: D,
91
- onChange: O,
92
- children: [
93
- /* @__PURE__ */ x(m, { children: C.settings.currentPassword }),
94
- /* @__PURE__ */ x(f, {
95
- className: v(!w && "hidden"),
96
- autoComplete: "current-password",
97
- placeholder: C.settings.currentPasswordPlaceholder,
98
- required: !0,
99
- variant: r === "transparent" ? "primary" : "secondary"
100
- }),
101
- !w && /* @__PURE__ */ x(h, { className: "h-10 md:h-9 w-full rounded-xl" }),
102
- /* @__PURE__ */ x(l, {})
103
- ]
104
- }),
105
- /* @__PURE__ */ S(_, {
106
- minLength: i?.minPasswordLength,
107
- maxLength: i?.maxPasswordLength,
108
- isDisabled: P || !w,
109
- value: k,
110
- onChange: A,
111
- children: [
112
- /* @__PURE__ */ x(m, { children: C.auth.newPassword }),
113
- /* @__PURE__ */ S(p, {
114
- className: v(!w && "hidden"),
115
- variant: r === "transparent" ? "primary" : "secondary",
116
- children: [/* @__PURE__ */ x(p.Input, {
117
- name: "newPassword",
118
- type: F ? "text" : "password",
119
- autoComplete: "new-password",
120
- placeholder: C.auth.newPasswordPlaceholder,
121
- required: !0
122
- }), /* @__PURE__ */ x(p.Suffix, {
123
- className: "px-0",
124
- children: /* @__PURE__ */ x(s, {
125
- isIconOnly: !0,
126
- "aria-label": F ? C.auth.hidePassword : C.auth.showPassword,
127
- size: "sm",
128
- variant: "ghost",
129
- onPress: () => I(!F),
130
- isDisabled: P,
131
- children: x(F ? o : a, {})
132
- })
133
- })]
134
- }),
135
- !w && /* @__PURE__ */ x(h, { className: "h-10 md:h-9 w-full rounded-xl" }),
136
- /* @__PURE__ */ x(l, {})
137
- ]
138
- }),
139
- i?.confirmPassword && /* @__PURE__ */ S(_, {
140
- minLength: i?.minPasswordLength,
141
- maxLength: i?.maxPasswordLength,
142
- isDisabled: P || !w,
143
- isRequired: !0,
144
- value: j,
145
- onChange: M,
146
- children: [
147
- /* @__PURE__ */ x(m, { children: C.auth.confirmPassword }),
148
- /* @__PURE__ */ S(p, {
149
- className: v(!w && "hidden"),
150
- variant: r === "transparent" ? "primary" : "secondary",
151
- children: [/* @__PURE__ */ x(p.Input, {
152
- name: "confirmPassword",
153
- type: L ? "text" : "password",
154
- autoComplete: "new-password",
155
- placeholder: C.auth.confirmPasswordPlaceholder,
156
- required: !0
157
- }), /* @__PURE__ */ x(p.Suffix, {
158
- className: "px-0",
159
- children: /* @__PURE__ */ x(s, {
160
- isIconOnly: !0,
161
- "aria-label": L ? C.auth.hidePassword : C.auth.showPassword,
162
- size: "sm",
163
- variant: "ghost",
164
- onPress: () => R(!L),
165
- isDisabled: P,
166
- children: x(L ? o : a, {})
167
- })
168
- })]
169
- }),
170
- !w && /* @__PURE__ */ x(h, { className: "h-10 md:h-9 w-full rounded-xl" }),
171
- /* @__PURE__ */ x(l, {})
172
- ]
173
- })
174
- ] }), /* @__PURE__ */ x(u.Actions, { children: /* @__PURE__ */ S(s, {
175
- type: "submit",
176
- isPending: P,
177
- isDisabled: !w,
178
- size: "sm",
179
- children: [P && /* @__PURE__ */ x(g, {
180
- color: "current",
181
- size: "sm"
182
- }), C.settings.updatePassword]
183
- }) })]
184
- })
185
- }) })
186
- })] });
38
+ function ChangePasswordForm({ className, variant, emailAndPassword, localization, session, ...props }) {
39
+ const { authClient } = useAuth();
40
+ const [currentPassword, setCurrentPassword] = useState("");
41
+ const [newPassword, setNewPassword] = useState("");
42
+ const [confirmPassword, setConfirmPassword] = useState("");
43
+ const { mutate: changePassword, isPending } = useChangePassword(authClient, {
44
+ onError: (error) => {
45
+ setCurrentPassword("");
46
+ setNewPassword("");
47
+ setConfirmPassword("");
48
+ toast.danger(error.error?.message || error.message);
49
+ },
50
+ onSuccess: () => {
51
+ setCurrentPassword("");
52
+ setNewPassword("");
53
+ setConfirmPassword("");
54
+ toast.success(localization.settings.changePasswordSuccess);
55
+ }
56
+ });
57
+ const [isNewPasswordVisible, setIsNewPasswordVisible] = useState(false);
58
+ const [isConfirmPasswordVisible, setIsConfirmPasswordVisible] = useState(false);
59
+ const handleSubmit = (e) => {
60
+ e.preventDefault();
61
+ if (emailAndPassword?.confirmPassword && newPassword !== confirmPassword) {
62
+ setCurrentPassword("");
63
+ setNewPassword("");
64
+ setConfirmPassword("");
65
+ toast.danger(localization.auth.passwordsDoNotMatch);
66
+ return;
67
+ }
68
+ changePassword({
69
+ currentPassword,
70
+ newPassword,
71
+ revokeOtherSessions: true
72
+ });
73
+ };
74
+ return (_jsxs("div", { children: [_jsx("h2", { className: cn("text-sm font-semibold mb-3"), children: localization.settings.changePassword }), _jsx(Card, { className: cn("p-4 gap-4", className), variant: variant, ...props, children: _jsx(Card.Content, { children: _jsx(Form, { onSubmit: handleSubmit, children: _jsxs(Fieldset, { className: "w-full gap-4", children: [_jsxs(Fieldset.Group, { children: [_jsxs(TextField, { name: "currentPassword", type: "password", isDisabled: isPending || !session, defaultValue: "", value: currentPassword, onChange: setCurrentPassword, children: [_jsx(Label, { children: localization.settings.currentPassword }), _jsx(Input, { className: cn(!session && "hidden"), autoComplete: "current-password", placeholder: localization.settings.currentPasswordPlaceholder, required: true, variant: variant === "transparent" ? "primary" : "secondary" }), !session && (_jsx(Skeleton, { className: "h-10 md:h-9 w-full rounded-xl" })), _jsx(FieldError, {})] }), _jsxs(TextField, { minLength: emailAndPassword?.minPasswordLength, maxLength: emailAndPassword?.maxPasswordLength, isDisabled: isPending || !session, value: newPassword, onChange: setNewPassword, children: [_jsx(Label, { children: localization.auth.newPassword }), _jsxs(InputGroup, { className: cn(!session && "hidden"), variant: variant === "transparent" ? "primary" : "secondary", children: [_jsx(InputGroup.Input, { name: "newPassword", type: isNewPasswordVisible ? "text" : "password", autoComplete: "new-password", placeholder: localization.auth.newPasswordPlaceholder, required: true }), _jsx(InputGroup.Suffix, { className: "px-0", children: _jsx(Button, { isIconOnly: true, "aria-label": isNewPasswordVisible
75
+ ? localization.auth.hidePassword
76
+ : localization.auth.showPassword, size: "sm", variant: "ghost", onPress: () => setIsNewPasswordVisible(!isNewPasswordVisible), isDisabled: isPending, children: isNewPasswordVisible ? _jsx(EyeSlash, {}) : _jsx(Eye, {}) }) })] }), !session && (_jsx(Skeleton, { className: "h-10 md:h-9 w-full rounded-xl" })), _jsx(FieldError, {})] }), emailAndPassword?.confirmPassword && (_jsxs(TextField, { minLength: emailAndPassword?.minPasswordLength, maxLength: emailAndPassword?.maxPasswordLength, isDisabled: isPending || !session, isRequired: true, value: confirmPassword, onChange: setConfirmPassword, children: [_jsx(Label, { children: localization.auth.confirmPassword }), _jsxs(InputGroup, { className: cn(!session && "hidden"), variant: variant === "transparent" ? "primary" : "secondary", children: [_jsx(InputGroup.Input, { name: "confirmPassword", type: isConfirmPasswordVisible ? "text" : "password", autoComplete: "new-password", placeholder: localization.auth.confirmPasswordPlaceholder, required: true }), _jsx(InputGroup.Suffix, { className: "px-0", children: _jsx(Button, { isIconOnly: true, "aria-label": isConfirmPasswordVisible
77
+ ? localization.auth.hidePassword
78
+ : localization.auth.showPassword, size: "sm", variant: "ghost", onPress: () => setIsConfirmPasswordVisible(!isConfirmPasswordVisible), isDisabled: isPending, children: isConfirmPasswordVisible ? _jsx(EyeSlash, {}) : _jsx(Eye, {}) }) })] }), !session && (_jsx(Skeleton, { className: "h-10 md:h-9 w-full rounded-xl" })), _jsx(FieldError, {})] }))] }), _jsx(Fieldset.Actions, { children: _jsxs(Button, { type: "submit", isPending: isPending, isDisabled: !session, size: "sm", children: [isPending && _jsx(Spinner, { color: "current", size: "sm" }), localization.settings.updatePassword] }) })] }) }) }) })] }));
187
79
  }
188
- //#endregion
189
- export { C as ChangePassword };
@@ -1,4 +1,4 @@
1
- import { Account, SocialProvider } from 'better-auth';
1
+ import type { Account, SocialProvider } from "better-auth";
2
2
  export type LinkedAccountProps = {
3
3
  account?: Account;
4
4
  provider: SocialProvider;
@@ -1,56 +1,38 @@
1
- import { getProviderName as e } from "@better-auth-ui/core";
2
- import { providerIcons as t, useAccountInfo as n, useAuth as r, useLinkSocial as i, useUnlinkAccount as a } from "@better-auth-ui/react";
3
- import { Link as o, LinkSlash as s, PlugConnection as c } from "@gravity-ui/icons";
4
- import { Button as l, Skeleton as u, Spinner as d, cn as f, toast as p } from "@heroui/react";
5
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
6
- //#region src/components/auth/settings/security/linked-account.tsx
7
- function g({ account: g, provider: _ }) {
8
- let { authClient: v, baseURL: y, localization: b } = r(), { data: x, isPending: S } = n(v, { query: { accountId: g?.accountId } }), { mutate: C, isPending: w } = i(v), { mutate: T, isPending: E } = a(v, { onSuccess: () => p.success(b.settings.accountUnlinked) }), D = t[_], O = e(_), k = x?.data?.login || x?.data?.username || x?.user?.email || x?.user?.name || g?.accountId;
9
- return /* @__PURE__ */ h("div", {
10
- className: "flex items-center gap-3",
11
- children: [
12
- /* @__PURE__ */ m("div", {
13
- className: f("flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-secondary"),
14
- children: m(D || c, { className: "size-4.5" })
15
- }),
16
- /* @__PURE__ */ h("div", {
17
- className: "flex flex-col min-w-0",
18
- children: [/* @__PURE__ */ m("span", {
19
- className: "text-sm font-medium leading-tight",
20
- children: O
21
- }), g && S ? /* @__PURE__ */ m(u, { className: "h-3 w-24 my-0.5 rounded-lg" }) : /* @__PURE__ */ m("span", {
22
- className: "text-xs text-muted truncate",
23
- children: g ? k : b.settings.linkProvider.replace("{{provider}}", O)
24
- })]
25
- }),
26
- g ? /* @__PURE__ */ h(l, {
27
- className: "ml-auto shrink-0",
28
- variant: "outline",
29
- size: "sm",
30
- onPress: () => T({ providerId: g.providerId }),
31
- isPending: E,
32
- "aria-label": b.settings.unlinkProvider.replace("{{provider}}", O),
33
- children: [E ? /* @__PURE__ */ m(d, {
34
- color: "current",
35
- size: "sm"
36
- }) : /* @__PURE__ */ m(s, {}), b.settings.unlinkProvider.replace("{{provider}}", "").trim()]
37
- }) : /* @__PURE__ */ h(l, {
38
- className: "ml-auto shrink-0",
39
- variant: "outline",
40
- size: "sm",
41
- onPress: () => C({
42
- provider: _,
43
- callbackURL: `${y}${window.location.pathname}`
44
- }),
45
- isPending: w,
46
- "aria-label": b.settings.linkProvider.replace("{{provider}}", O),
47
- children: [w ? /* @__PURE__ */ m(d, {
48
- color: "current",
49
- size: "sm"
50
- }) : /* @__PURE__ */ m(o, {}), b.settings.link]
51
- })
52
- ]
53
- });
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { getProviderName } from "@better-auth-ui/core";
3
+ import { providerIcons, useAccountInfo, useAuth, useLinkSocial, useUnlinkAccount } from "@better-auth-ui/react";
4
+ import { Link, LinkSlash, PlugConnection } from "@gravity-ui/icons";
5
+ import { Button, cn, Skeleton, Spinner, toast } from "@heroui/react";
6
+ /**
7
+ * Render a single linked social account row with provider info and link/unlink control.
8
+ *
9
+ * Fetches additional account information from the provider using the accountInfo API
10
+ * and displays the provider name, account details, and a link/unlink button.
11
+ *
12
+ * @param account - The account object containing id, accountId, and providerId
13
+ * @param provider - The provider id
14
+ * @returns A JSX element containing the linked account row
15
+ */
16
+ export function LinkedAccount({ account, provider }) {
17
+ const { authClient, baseURL, localization } = useAuth();
18
+ const { data: accountInfo, isPending: isLoadingInfo } = useAccountInfo(authClient, { query: { accountId: account?.accountId } });
19
+ const { mutate: linkSocial, isPending: isLinking } = useLinkSocial(authClient);
20
+ const { mutate: unlinkAccount, isPending: isUnlinking } = useUnlinkAccount(authClient, {
21
+ onSuccess: () => toast.success(localization.settings.accountUnlinked)
22
+ });
23
+ const ProviderIcon = providerIcons[provider];
24
+ const providerName = getProviderName(provider);
25
+ const displayName = accountInfo?.data?.login ||
26
+ accountInfo?.data?.username ||
27
+ accountInfo?.user?.email ||
28
+ accountInfo?.user?.name ||
29
+ account?.accountId;
30
+ return (_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: cn("flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-secondary"), children: ProviderIcon ? (_jsx(ProviderIcon, { className: "size-4.5" })) : (_jsx(PlugConnection, { className: "size-4.5" })) }), _jsxs("div", { className: "flex flex-col min-w-0", children: [_jsx("span", { className: "text-sm font-medium leading-tight", children: providerName }), account && isLoadingInfo ? (_jsx(Skeleton, { className: "h-3 w-24 my-0.5 rounded-lg" })) : (_jsx("span", { className: "text-xs text-muted truncate", children: account
31
+ ? displayName
32
+ : localization.settings.linkProvider.replace("{{provider}}", providerName) }))] }), account ? (_jsxs(Button, { className: "ml-auto shrink-0", variant: "outline", size: "sm", onPress: () => unlinkAccount({ providerId: account.providerId }), isPending: isUnlinking, "aria-label": localization.settings.unlinkProvider.replace("{{provider}}", providerName), children: [isUnlinking ? _jsx(Spinner, { color: "current", size: "sm" }) : _jsx(LinkSlash, {}), localization.settings.unlinkProvider
33
+ .replace("{{provider}}", "")
34
+ .trim()] })) : (_jsxs(Button, { className: "ml-auto shrink-0", variant: "outline", size: "sm", onPress: () => linkSocial({
35
+ provider,
36
+ callbackURL: `${baseURL}${window.location.pathname}`
37
+ }), isPending: isLinking, "aria-label": localization.settings.linkProvider.replace("{{provider}}", providerName), children: [isLinking ? _jsx(Spinner, { color: "current", size: "sm" }) : _jsx(Link, {}), localization.settings.link] }))] }));
54
38
  }
55
- //#endregion
56
- export { g as LinkedAccount };
@@ -1,4 +1,4 @@
1
- import { CardProps } from '@heroui/react';
1
+ import { type CardProps } from "@heroui/react";
2
2
  export type LinkedAccountsProps = {
3
3
  className?: string;
4
4
  variant?: CardProps["variant"];
@@ -1,45 +1,36 @@
1
- import { LinkedAccount as e } from "./linked-account.js";
2
- import { useAuth as t, useListAccounts as n } from "@better-auth-ui/react";
3
- import { Card as r, Skeleton as i, cn as a } from "@heroui/react";
4
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
5
- //#region src/components/auth/settings/security/linked-accounts.tsx
6
- function c({ className: i, variant: c, ...u }) {
7
- let { authClient: d, localization: f, socialProviders: p } = t(), { data: m, isPending: h } = n(d), g = [...(m?.filter((e) => e.providerId !== "credential"))?.map((e) => ({
8
- key: e.id,
9
- account: e,
10
- provider: e.providerId
11
- })) ?? [], ...p?.map((e) => ({
12
- key: e,
13
- account: void 0,
14
- provider: e
15
- })) ?? []];
16
- return /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("h2", {
17
- className: a("text-sm font-semibold mb-3"),
18
- children: f.settings.linkedAccounts
19
- }), /* @__PURE__ */ o(r, {
20
- className: a(i),
21
- variant: c,
22
- ...u,
23
- children: /* @__PURE__ */ o(r.Content, {
24
- className: "gap-0",
25
- children: h ? p?.map((e, t) => /* @__PURE__ */ s("div", { children: [t > 0 && /* @__PURE__ */ o("div", { className: "border-b border-dashed -mx-4 md:-mx-6 my-4" }), /* @__PURE__ */ o(l, {})] }, e)) : g.map((t, n) => /* @__PURE__ */ s("div", { children: [n > 0 && /* @__PURE__ */ o("div", { className: "border-b border-dashed -mx-4 md:-mx-6 my-4" }), /* @__PURE__ */ o(e, {
26
- account: t.account,
27
- provider: t.provider
28
- })] }, t.key))
29
- })
30
- })] });
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useAuth, useListAccounts } from "@better-auth-ui/react";
3
+ import { Card, cn, Skeleton } from "@heroui/react";
4
+ import { LinkedAccount } from "./linked-account";
5
+ /**
6
+ * Render a card showing linked social accounts and available social providers to link.
7
+ *
8
+ * Linked accounts (excluding the "credential" provider) are shown with an unlink control;
9
+ * available providers are shown with a link control. Button states and labels reflect
10
+ * ongoing link/unlink activity and use localization for provider-specific text.
11
+ *
12
+ * @returns A JSX element containing the linked accounts card
13
+ */
14
+ export function LinkedAccounts({ className, variant, ...props }) {
15
+ const { authClient, localization, socialProviders } = useAuth();
16
+ const { data: accounts, isPending } = useListAccounts(authClient);
17
+ const linkedAccounts = accounts?.filter((account) => account.providerId !== "credential");
18
+ const allRows = [
19
+ ...(linkedAccounts?.map((account) => ({
20
+ key: account.id,
21
+ account,
22
+ provider: account.providerId
23
+ })) ?? []),
24
+ ...(socialProviders?.map((provider) => ({
25
+ key: provider,
26
+ account: undefined,
27
+ provider
28
+ })) ?? [])
29
+ ];
30
+ return (_jsxs("div", { children: [_jsx("h2", { className: cn("text-sm font-semibold mb-3"), children: localization.settings.linkedAccounts }), _jsx(Card, { className: cn(className), variant: variant, ...props, children: _jsx(Card.Content, { className: "gap-0", children: isPending
31
+ ? socialProviders?.map((provider, index) => (_jsxs("div", { children: [index > 0 && (_jsx("div", { className: "border-b border-dashed -mx-4 my-4" })), _jsx(AccountRowSkeleton, {})] }, provider)))
32
+ : allRows.map((row, index) => (_jsxs("div", { children: [index > 0 && (_jsx("div", { className: "border-b border-dashed -mx-4 my-4" })), _jsx(LinkedAccount, { account: row.account, provider: row.provider })] }, row.key))) }) })] }));
31
33
  }
32
- function l() {
33
- return /* @__PURE__ */ o("div", {
34
- className: "flex items-center justify-between",
35
- children: /* @__PURE__ */ s("div", {
36
- className: "flex items-center gap-3",
37
- children: [/* @__PURE__ */ o(i, { className: "size-10 rounded-xl" }), /* @__PURE__ */ s("div", {
38
- className: "flex flex-col gap-1",
39
- children: [/* @__PURE__ */ o(i, { className: "h-4 w-20 rounded-lg" }), /* @__PURE__ */ o(i, { className: "h-3 w-32 rounded-lg" })]
40
- })]
41
- })
42
- });
34
+ function AccountRowSkeleton() {
35
+ return (_jsx("div", { className: "flex items-center justify-between", children: _jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Skeleton, { className: "size-10 rounded-xl" }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx(Skeleton, { className: "h-4 w-20 rounded-lg" }), _jsx(Skeleton, { className: "h-3 w-32 rounded-lg" })] })] }) }));
43
36
  }
44
- //#endregion
45
- export { c as LinkedAccounts };
@@ -1,5 +1,5 @@
1
- import { CardProps } from '@heroui/react';
2
- import { ComponentProps } from 'react';
1
+ import { type CardProps } from "@heroui/react";
2
+ import type { ComponentProps } from "react";
3
3
  export type SecuritySettingsProps = {
4
4
  className?: string;
5
5
  variant?: CardProps["variant"];
@@ -1,22 +1,20 @@
1
- import { ActiveSessions as e } from "./active-sessions.js";
2
- import { ChangePassword as t } from "./change-password.js";
3
- import { LinkedAccounts as n } from "./linked-accounts.js";
4
- import { useAuth as r } from "@better-auth-ui/react";
5
- import { cn as i } from "@heroui/react";
6
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
7
- //#region src/components/auth/settings/security/security-settings.tsx
8
- function s({ className: s, variant: c, ...l }) {
9
- let { emailAndPassword: u, plugins: d, socialProviders: f } = r();
10
- return /* @__PURE__ */ o("div", {
11
- className: i("flex w-full flex-col gap-4 md:gap-6", s),
12
- ...l,
13
- children: [
14
- u?.enabled && /* @__PURE__ */ a(t, { variant: c }),
15
- !!f?.length && /* @__PURE__ */ a(n, { variant: c }),
16
- /* @__PURE__ */ a(e, { variant: c }),
17
- d.flatMap((e) => e.securityCards?.map((t, n) => /* @__PURE__ */ a(t, { variant: c }, `${e.id}-${n.toString()}`)))
18
- ]
19
- });
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useAuth } from "@better-auth-ui/react";
3
+ import { cn } from "@heroui/react";
4
+ import { ActiveSessions } from "./active-sessions";
5
+ import { ChangePassword } from "./change-password";
6
+ import { LinkedAccounts } from "./linked-accounts";
7
+ /**
8
+ * Renders the security settings layout including password management, linked accounts, and active sessions.
9
+ *
10
+ * ChangePassword is rendered when password authentication is enabled; LinkedAccounts is rendered when social providers are present.
11
+ * Each registered auth plugin may contribute `securityCards` (for example delete-user, passkeys).
12
+ *
13
+ * @param className - Optional additional CSS class names for the outer container.
14
+ * @param variant - Card variant forwarded to each security settings card.
15
+ * @returns The security settings container as a JSX element.
16
+ */
17
+ export function SecuritySettings({ className, variant, ...props }) {
18
+ const { emailAndPassword, plugins, socialProviders } = useAuth();
19
+ return (_jsxs("div", { className: cn("flex w-full flex-col gap-4 md:gap-6", className), ...props, children: [emailAndPassword?.enabled && _jsx(ChangePassword, { variant: variant }), !!socialProviders?.length && _jsx(LinkedAccounts, { variant: variant }), _jsx(ActiveSessions, { variant: variant }), plugins.flatMap((plugin) => plugin.securityCards?.map((Card, index) => (_jsx(Card, { variant: variant }, `${plugin.id}-${index.toString()}`))))] }));
20
20
  }
21
- //#endregion
22
- export { s as SecuritySettings };
@@ -1,6 +1,6 @@
1
- import { SettingsView } from '@better-auth-ui/core';
2
- import { CardProps } from '@heroui/react';
3
- import { ComponentProps } from 'react';
1
+ import type { SettingsView } from "@better-auth-ui/core";
2
+ import { type CardProps } from "@heroui/react";
3
+ import { type ComponentProps } from "react";
4
4
  export type SettingsProps = {
5
5
  className?: string;
6
6
  hideNav?: boolean;
@@ -19,6 +19,6 @@ export type SettingsProps = {
19
19
  * @param variant - Card variant forwarded to each settings section card
20
20
  * @returns A DOM tree containing the responsive settings tabs and the currently selected settings panel
21
21
  *
22
- * @throws Error if neither `view` nor `path` is provided
22
+ * @throws Error if neither `view` nor `path` is provided, or if `path` does not match any settings view
23
23
  */
24
24
  export declare function Settings({ className, hideNav, path, variant, view, ...props }: SettingsProps & ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;