@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,18 +1,5 @@
1
- import { Separator as e } from "@heroui/react";
2
- import { jsx as t, jsxs as n } from "react/jsx-runtime";
3
- //#region src/components/auth/field-separator.tsx
4
- function r({ children: r }) {
5
- return /* @__PURE__ */ n("div", {
6
- className: "flex items-center gap-4",
7
- children: [
8
- /* @__PURE__ */ t(e, { className: "flex-1" }),
9
- /* @__PURE__ */ t("p", {
10
- className: "text-xs text-muted shrink-0",
11
- children: r
12
- }),
13
- /* @__PURE__ */ t(e, { className: "flex-1" })
14
- ]
15
- });
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Separator } from "@heroui/react";
3
+ export function FieldSeparator({ children }) {
4
+ return (_jsxs("div", { className: "flex items-center gap-4", children: [_jsx(Separator, { className: "flex-1" }), _jsx("p", { className: "text-xs text-muted shrink-0", children: children }), _jsx(Separator, { className: "flex-1" })] }));
16
5
  }
17
- //#endregion
18
- export { r as FieldSeparator };
@@ -1,4 +1,4 @@
1
- import { CardProps } from '@heroui/react';
1
+ import { type CardProps } from "@heroui/react";
2
2
  export type ForgotPasswordProps = {
3
3
  className?: string;
4
4
  variant?: CardProps["variant"];
@@ -1,89 +1,37 @@
1
- import { useAuth as e, useFetchOptions as t, useRequestPasswordReset as n } from "@better-auth-ui/react";
2
- import { Button as r, Card as i, Description as a, FieldError as o, Form as s, Input as c, Label as l, Link as u, Spinner as d, TextField as f, cn as p, toast as m } from "@heroui/react";
3
- import { jsx as h, jsxs as g } from "react/jsx-runtime";
4
- //#region src/components/auth/forgot-password.tsx
5
- function _({ className: _, variant: v, ...y }) {
6
- let { authClient: b, basePaths: x, localization: S, viewPaths: C, navigate: w, plugins: T } = e(), { fetchOptions: E, resetFetchOptions: D } = t(), { mutate: O, isPending: k } = n(b, {
7
- onError: (e) => {
8
- m.danger(e.error?.message || e.message), D();
9
- },
10
- onSuccess: () => {
11
- m.success(S.auth.passwordResetEmailSent), w({ to: `${x.auth}/${C.auth.signIn}` });
12
- }
13
- });
14
- function A(e) {
15
- e.preventDefault(), O({
16
- email: new FormData(e.currentTarget).get("email"),
17
- fetchOptions: E
18
- });
19
- }
20
- let j = T.find((e) => e.captchaComponent)?.captchaComponent;
21
- return /* @__PURE__ */ g(i, {
22
- className: p("w-full max-w-sm gap-4 md:p-6", _),
23
- variant: v,
24
- ...y,
25
- children: [
26
- /* @__PURE__ */ h(i.Header, { children: /* @__PURE__ */ h(i.Title, {
27
- className: "text-xl font-semibold mb-1",
28
- children: S.auth.forgotPassword
29
- }) }),
30
- /* @__PURE__ */ h(i.Content, {
31
- className: "gap-4",
32
- children: /* @__PURE__ */ g(s, {
33
- onSubmit: A,
34
- className: "flex flex-col gap-4",
35
- children: [
36
- /* @__PURE__ */ g(f, {
37
- name: "email",
38
- type: "email",
39
- autoComplete: "email",
40
- isDisabled: k,
41
- children: [
42
- /* @__PURE__ */ h(l, { children: S.auth.email }),
43
- /* @__PURE__ */ h(c, {
44
- placeholder: S.auth.emailPlaceholder,
45
- required: !0,
46
- variant: v === "transparent" ? "primary" : "secondary"
47
- }),
48
- /* @__PURE__ */ h(o, {})
49
- ]
50
- }),
51
- j && /* @__PURE__ */ h("div", {
52
- className: "flex justify-center",
53
- children: j
54
- }),
55
- /* @__PURE__ */ h("div", {
56
- className: "flex flex-col gap-3",
57
- children: /* @__PURE__ */ g(r, {
58
- type: "submit",
59
- className: "w-full",
60
- isPending: k,
61
- children: [k && /* @__PURE__ */ h(d, {
62
- color: "current",
63
- size: "sm"
64
- }), S.auth.sendResetLink]
65
- })
66
- })
67
- ]
68
- })
69
- }),
70
- /* @__PURE__ */ h(i.Footer, {
71
- className: "flex-col gap-3",
72
- children: /* @__PURE__ */ g(a, {
73
- className: "text-sm",
74
- children: [
75
- S.auth.rememberYourPassword,
76
- " ",
77
- /* @__PURE__ */ h(u, {
78
- href: `${x.auth}/${C.auth.signIn}`,
79
- className: "text-accent no-underline hover:underline decoration-accent-hover",
80
- children: S.auth.signIn
81
- })
82
- ]
83
- })
84
- })
85
- ]
86
- });
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useAuth, useFetchOptions, useRequestPasswordReset } from "@better-auth-ui/react";
3
+ import { Button, Card, cn, Description, FieldError, Form, Input, Label, Link, Spinner, TextField, toast } from "@heroui/react";
4
+ /**
5
+ * Render a card-based "Forgot Password" form that sends a password-reset email.
6
+ *
7
+ * The form displays an email input, submit button, and a link back to sign-in.
8
+ * Toasts are displayed on success or error via the `useRequestPasswordReset` hook.
9
+ *
10
+ * @param className - Optional additional CSS class names applied to the card
11
+ * @returns The forgot-password form UI as a JSX element
12
+ */
13
+ export function ForgotPassword({ className, variant, ...props }) {
14
+ const { authClient, baseURL, basePaths, localization, viewPaths, navigate, plugins } = useAuth();
15
+ const { fetchOptions, resetFetchOptions } = useFetchOptions();
16
+ const { mutate: requestPasswordReset, isPending } = useRequestPasswordReset(authClient, {
17
+ onError: (error) => {
18
+ toast.danger(error.error?.message || error.message);
19
+ resetFetchOptions();
20
+ },
21
+ onSuccess: () => {
22
+ toast.success(localization.auth.passwordResetEmailSent);
23
+ navigate({ to: `${basePaths.auth}/${viewPaths.auth.signIn}` });
24
+ }
25
+ });
26
+ function handleSubmit(e) {
27
+ e.preventDefault();
28
+ const formData = new FormData(e.currentTarget);
29
+ requestPasswordReset({
30
+ email: formData.get("email"),
31
+ redirectTo: `${baseURL}${basePaths.auth}/${viewPaths.auth.resetPassword}`,
32
+ fetchOptions
33
+ });
34
+ }
35
+ const Captcha = plugins.find((plugin) => plugin.captchaComponent)?.captchaComponent;
36
+ return (_jsxs(Card, { className: cn("w-full max-w-sm gap-4 md:p-6", className), variant: variant, ...props, children: [_jsx(Card.Header, { children: _jsx(Card.Title, { className: "text-xl font-semibold mb-1", children: localization.auth.forgotPassword }) }), _jsx(Card.Content, { className: "gap-4", children: _jsxs(Form, { onSubmit: handleSubmit, className: "flex flex-col gap-4", children: [_jsxs(TextField, { name: "email", type: "email", autoComplete: "email", isDisabled: isPending, children: [_jsx(Label, { children: localization.auth.email }), _jsx(Input, { placeholder: localization.auth.emailPlaceholder, required: true, variant: variant === "transparent" ? "primary" : "secondary" }), _jsx(FieldError, {})] }), Captcha && _jsx("div", { className: "flex justify-center", children: Captcha }), _jsx("div", { className: "flex flex-col gap-3", children: _jsxs(Button, { type: "submit", className: "w-full", isPending: isPending, children: [isPending && _jsx(Spinner, { color: "current", size: "sm" }), localization.auth.sendResetLink] }) })] }) }), _jsx(Card.Footer, { className: "flex-col gap-3", children: _jsxs(Description, { className: "text-sm", children: [localization.auth.rememberYourPassword, " ", _jsx(Link, { href: `${basePaths.auth}/${viewPaths.auth.signIn}`, className: "text-accent no-underline hover:underline decoration-accent-hover", children: localization.auth.signIn })] }) })] }));
87
37
  }
88
- //#endregion
89
- export { _ as ForgotPassword };
@@ -1,4 +1,4 @@
1
- import { AuthView } from '@better-auth-ui/core';
1
+ import { type AuthView } from "@better-auth-ui/core";
2
2
  export type MagicLinkButtonProps = {
3
3
  /** @remarks `AuthView` */
4
4
  view?: AuthView;
@@ -1,20 +1,34 @@
1
- import { magicLinkPlugin as e } from "../../../lib/auth/magic-link-plugin.js";
2
- import { authMutationKeys as t } from "@better-auth-ui/core";
3
- import { useAuth as n, useAuthPlugin as r } from "@better-auth-ui/react";
4
- import { Envelope as i, Lock as a } from "@gravity-ui/icons";
5
- import { Link as o, cn as s } from "@heroui/react";
6
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
7
- import { useIsMutating as u } from "@tanstack/react-query";
8
- import { buttonVariants as d } from "@heroui/styles";
9
- //#region src/components/auth/magic-link/magic-link-button.tsx
10
- function f({ view: f }) {
11
- let { basePaths: p, emailAndPassword: m, viewPaths: h, localization: g } = n(), _ = u({ mutationKey: t.signIn.all }) + u({ mutationKey: t.signUp.all }) > 0, { localization: v, viewPaths: y } = r(e), b = f === "magicLink";
12
- return b && !m?.enabled ? null : /* @__PURE__ */ l(o, {
13
- href: `${p.auth}/${b ? h.auth.signIn : y.auth.magicLink}`,
14
- isDisabled: _,
15
- className: s(d({ variant: "tertiary" }), "w-full gap-2", _ && "status-disabled"),
16
- children: [c(b ? a : i, {}), g.auth.continueWith.replace("{{provider}}", b ? g.auth.password : v.magicLink)]
17
- });
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { authMutationKeys } from "@better-auth-ui/core";
3
+ import { useAuth, useAuthPlugin } from "@better-auth-ui/react";
4
+ import { Envelope, Lock } from "@gravity-ui/icons";
5
+ import { cn, Link } from "@heroui/react";
6
+ import { buttonVariants } from "@heroui/styles";
7
+ import { useIsMutating } from "@tanstack/react-query";
8
+ import { magicLinkPlugin } from "../../../lib/auth/magic-link-plugin";
9
+ /**
10
+ * Toggle button between the password sign-in and magic-link routes.
11
+ *
12
+ * @param view - Current auth view. On `"magicLink"` this links back to password sign-in.
13
+ */
14
+ export function MagicLinkButton({ view }) {
15
+ const { basePaths, emailAndPassword, viewPaths, localization } = useAuth();
16
+ const signInMutating = useIsMutating({
17
+ mutationKey: authMutationKeys.signIn.all
18
+ });
19
+ const signUpMutating = useIsMutating({
20
+ mutationKey: authMutationKeys.signUp.all
21
+ });
22
+ const isPending = signInMutating + signUpMutating > 0;
23
+ const { localization: magicLinkLocalization, viewPaths: magicLinkViewPaths } = useAuthPlugin(magicLinkPlugin);
24
+ const isMagicLinkView = view === "magicLink";
25
+ // On the magic-link view this button switches back to password sign-in.
26
+ // With password auth disabled there's nowhere to switch to, so hide it.
27
+ // (Other views — e.g. a phone-number plugin's surface — still get a
28
+ // "Continue with Magic Link" link.)
29
+ if (isMagicLinkView && !emailAndPassword?.enabled)
30
+ return null;
31
+ return (_jsxs(Link, { href: `${basePaths.auth}/${isMagicLinkView ? viewPaths.auth.signIn : magicLinkViewPaths.auth.magicLink}`, isDisabled: isPending, className: cn(buttonVariants({ variant: "tertiary" }), "w-full gap-2", isPending && "status-disabled"), children: [isMagicLinkView ? _jsx(Lock, {}) : _jsx(Envelope, {}), localization.auth.continueWith.replace("{{provider}}", isMagicLinkView
32
+ ? localization.auth.password
33
+ : magicLinkLocalization.magicLink)] }));
18
34
  }
19
- //#endregion
20
- export { f as MagicLinkButton };
@@ -1,5 +1,5 @@
1
- import { CardProps } from '@heroui/react';
2
- import { SocialLayout } from '../provider-buttons';
1
+ import { type CardProps } from "@heroui/react";
2
+ import { type SocialLayout } from "../provider-buttons";
3
3
  export type MagicLinkProps = {
4
4
  className?: string;
5
5
  socialLayout?: SocialLayout;
@@ -1,87 +1,40 @@
1
- import { FieldSeparator as e } from "../field-separator.js";
2
- import { ProviderButtons as t } from "../provider-buttons.js";
3
- import { magicLinkPlugin as n } from "../../../lib/auth/magic-link-plugin.js";
4
- import { authMutationKeys as r } from "@better-auth-ui/core";
5
- import { useAuth as i, useAuthPlugin as a, useSignInMagicLink as o } from "@better-auth-ui/react";
6
- import { Button as s, Card as c, Description as l, FieldError as u, Form as d, Input as f, Label as p, Link as m, Spinner as h, TextField as g, cn as _, toast as v } from "@heroui/react";
7
- import { useState as y } from "react";
8
- import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
9
- import { useIsMutating as C } from "@tanstack/react-query";
10
- //#region src/components/auth/magic-link/magic-link.tsx
11
- function w({ className: w, socialLayout: T, socialPosition: E = "bottom", variant: D, ...O }) {
12
- let { authClient: k, basePaths: A, baseURL: j, emailAndPassword: M, localization: N, plugins: P, redirectTo: F, socialProviders: I, viewPaths: L } = i(), { localization: R } = a(n), [z, B] = y(""), { mutate: V, isPending: H } = o(k, { onSuccess: () => {
13
- B(""), v.success(R.magicLinkSent);
14
- } }), U = C({ mutationKey: r.signIn.all }) + C({ mutationKey: r.signUp.all }) > 0, W = (e) => {
15
- e.preventDefault(), V({
16
- email: z,
17
- callbackURL: `${j}${F}`
18
- });
19
- }, G = !!I?.length;
20
- return /* @__PURE__ */ S(c, {
21
- className: _("w-full max-w-sm gap-4 md:p-6", w),
22
- variant: D,
23
- ...O,
24
- children: [
25
- /* @__PURE__ */ x(c.Header, { children: /* @__PURE__ */ x(c.Title, {
26
- className: "text-xl font-semibold mb-1",
27
- children: N.auth.signIn
28
- }) }),
29
- /* @__PURE__ */ S(c.Content, {
30
- className: "gap-4",
31
- children: [
32
- E === "top" && /* @__PURE__ */ S(b, { children: [!!I?.length && /* @__PURE__ */ x(t, { socialLayout: T }), G && /* @__PURE__ */ x(e, { children: N.auth.or })] }),
33
- /* @__PURE__ */ S(d, {
34
- onSubmit: W,
35
- className: "flex flex-col gap-4",
36
- children: [/* @__PURE__ */ S(g, {
37
- name: "email",
38
- type: "email",
39
- autoComplete: "email",
40
- isDisabled: U,
41
- value: z,
42
- onChange: B,
43
- children: [
44
- /* @__PURE__ */ x(p, { children: N.auth.email }),
45
- /* @__PURE__ */ x(f, {
46
- placeholder: N.auth.emailPlaceholder,
47
- required: !0,
48
- variant: D === "transparent" ? "primary" : "secondary"
49
- }),
50
- /* @__PURE__ */ x(u, {})
51
- ]
52
- }), /* @__PURE__ */ S("div", {
53
- className: "flex flex-col gap-3",
54
- children: [/* @__PURE__ */ S(s, {
55
- type: "submit",
56
- className: "w-full",
57
- isPending: U,
58
- children: [H && /* @__PURE__ */ x(h, {
59
- color: "current",
60
- size: "sm"
61
- }), R.sendMagicLink]
62
- }), P.flatMap((e) => (e.authButtons ?? []).map((t, n) => /* @__PURE__ */ x(t, { view: "magicLink" }, `${e.id}-${n.toString()}`)))]
63
- })]
64
- }),
65
- E === "bottom" && /* @__PURE__ */ S(b, { children: [G && /* @__PURE__ */ x(e, { children: N.auth.or }), !!I?.length && /* @__PURE__ */ x(t, { socialLayout: T })] })
66
- ]
67
- }),
68
- M?.enabled && /* @__PURE__ */ x(c.Footer, {
69
- className: "flex-col gap-3",
70
- children: /* @__PURE__ */ S(l, {
71
- className: "text-sm",
72
- children: [
73
- N.auth.needToCreateAnAccount,
74
- " ",
75
- /* @__PURE__ */ x(m, {
76
- href: `${A.auth}/${L.auth.signUp}`,
77
- className: "text-accent no-underline hover:underline decoration-accent-hover",
78
- children: N.auth.signUp
79
- })
80
- ]
81
- })
82
- })
83
- ]
84
- });
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { authMutationKeys } from "@better-auth-ui/core";
3
+ import { useAuth, useAuthPlugin, useSignInMagicLink } from "@better-auth-ui/react";
4
+ import { Button, Card, cn, Description, FieldError, Form, Input, Label, Link, Spinner, TextField, toast } from "@heroui/react";
5
+ import { useIsMutating } from "@tanstack/react-query";
6
+ import { useState } from "react";
7
+ import { magicLinkPlugin } from "../../../lib/auth/magic-link-plugin";
8
+ import { FieldSeparator } from "../field-separator";
9
+ import { ProviderButtons } from "../provider-buttons";
10
+ /**
11
+ * Magic-link sign-in form.
12
+ *
13
+ * @param socialLayout - Provider button layout.
14
+ * @param socialPosition - `"top"` or `"bottom"`. Defaults to `"bottom"`.
15
+ * @param variant - Card variant.
16
+ */
17
+ export function MagicLink({ className, socialLayout, socialPosition = "bottom", variant, ...props }) {
18
+ const { authClient, basePaths, baseURL, emailAndPassword, localization, plugins, redirectTo, socialProviders, viewPaths } = useAuth();
19
+ const { localization: magicLinkLocalization } = useAuthPlugin(magicLinkPlugin);
20
+ const [email, setEmail] = useState("");
21
+ const { mutate: signInMagicLink, isPending: signInMagicLinkPending } = useSignInMagicLink(authClient, {
22
+ onSuccess: () => {
23
+ setEmail("");
24
+ toast.success(magicLinkLocalization.magicLinkSent);
25
+ }
26
+ });
27
+ const signInMutating = useIsMutating({
28
+ mutationKey: authMutationKeys.signIn.all
29
+ });
30
+ const signUpMutating = useIsMutating({
31
+ mutationKey: authMutationKeys.signUp.all
32
+ });
33
+ const isPending = signInMutating + signUpMutating > 0;
34
+ const handleSubmit = (e) => {
35
+ e.preventDefault();
36
+ signInMagicLink({ email, callbackURL: `${baseURL}${redirectTo}` });
37
+ };
38
+ const showSeparator = !!socialProviders?.length;
39
+ return (_jsxs(Card, { className: cn("w-full max-w-sm gap-4 md:p-6", className), variant: variant, ...props, children: [_jsx(Card.Header, { children: _jsx(Card.Title, { className: "text-xl font-semibold mb-1", children: localization.auth.signIn }) }), _jsxs(Card.Content, { className: "gap-4", children: [socialPosition === "top" && (_jsxs(_Fragment, { children: [!!socialProviders?.length && (_jsx(ProviderButtons, { socialLayout: socialLayout })), showSeparator && (_jsx(FieldSeparator, { children: localization.auth.or }))] })), _jsxs(Form, { onSubmit: handleSubmit, className: "flex flex-col gap-4", children: [_jsxs(TextField, { name: "email", type: "email", autoComplete: "email", isDisabled: isPending, value: email, onChange: setEmail, children: [_jsx(Label, { children: localization.auth.email }), _jsx(Input, { placeholder: localization.auth.emailPlaceholder, required: true, variant: variant === "transparent" ? "primary" : "secondary" }), _jsx(FieldError, {})] }), _jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs(Button, { type: "submit", className: "w-full", isPending: isPending, children: [signInMagicLinkPending && _jsx(Spinner, { color: "current", size: "sm" }), magicLinkLocalization.sendMagicLink] }), plugins.flatMap((plugin) => (plugin.authButtons ?? []).map((AuthButton, index) => (_jsx(AuthButton, { view: "magicLink" }, `${plugin.id}-${index.toString()}`))))] })] }), socialPosition === "bottom" && (_jsxs(_Fragment, { children: [showSeparator && (_jsx(FieldSeparator, { children: localization.auth.or })), !!socialProviders?.length && (_jsx(ProviderButtons, { socialLayout: socialLayout }))] }))] }), emailAndPassword?.enabled && (_jsx(Card.Footer, { className: "flex-col gap-3", children: _jsxs(Description, { className: "text-sm", children: [localization.auth.needToCreateAnAccount, " ", _jsx(Link, { href: `${basePaths.auth}/${viewPaths.auth.signUp}`, className: "text-accent no-underline hover:underline decoration-accent-hover", children: localization.auth.signUp })] }) }))] }));
85
40
  }
86
- //#endregion
87
- export { w as MagicLink };
@@ -1,4 +1,4 @@
1
- import { ListDeviceSession } from '@better-auth-ui/react';
1
+ import { type ListDeviceSession } from "@better-auth-ui/react";
2
2
  export type ManageAccountProps = {
3
3
  deviceSession?: ListDeviceSession | null;
4
4
  isPending?: boolean;
@@ -1,49 +1,33 @@
1
- import { UserView as e } from "../user/user-view.js";
2
- import { multiSessionPlugin as t } from "../../../lib/auth/multi-session-plugin.js";
3
- import { useAuth as n, useAuthPlugin as r, useRevokeMultiSession as i, useSetActiveSession as a, useUser as o } from "@better-auth-ui/react";
4
- import { ArrowRightArrowLeft as s, ArrowRightFromSquare as c, Ellipsis as l } from "@gravity-ui/icons";
5
- import { Button as u, Dropdown as d, Spinner as f, toast as p } from "@heroui/react";
6
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
7
- //#region src/components/auth/multi-session/manage-account.tsx
8
- function g({ deviceSession: g, isPending: _ }) {
9
- let { authClient: v, localization: y } = n(), { localization: b } = r(t), { data: x } = o(v), { mutate: S, isPending: C } = a(v, { onSuccess: () => window.scrollTo({ top: 0 }) }), { mutate: w, isPending: T } = i(v, { onSuccess: () => p.success(y.settings.revokeSessionSuccess) }), E = g?.session.userId === x?.id, D = C || T;
10
- return /* @__PURE__ */ h("div", {
11
- className: "flex items-center justify-between gap-3",
12
- children: [
13
- /* @__PURE__ */ m(e, {
14
- user: g?.user,
15
- isPending: _,
16
- size: "md"
17
- }),
18
- g && E && /* @__PURE__ */ h(u, {
19
- className: "shrink-0",
20
- variant: "outline",
21
- size: "sm",
22
- onPress: () => w({ sessionToken: g.session.token }),
23
- isDisabled: D,
24
- children: [T ? /* @__PURE__ */ m(f, {
25
- color: "current",
26
- size: "sm"
27
- }) : /* @__PURE__ */ m(c, {}), y.auth.signOut]
28
- }),
29
- g && !E && /* @__PURE__ */ h(d, { children: [/* @__PURE__ */ m(u, {
30
- isIconOnly: !0,
31
- variant: "ghost",
32
- className: "shrink-0",
33
- size: "sm",
34
- isDisabled: D,
35
- children: /* @__PURE__ */ m(l, {})
36
- }), /* @__PURE__ */ m(d.Popover, { children: /* @__PURE__ */ h(d.Menu, { children: [/* @__PURE__ */ h(d.Item, {
37
- textValue: b.switchAccount,
38
- onAction: () => S({ sessionToken: g.session.token }),
39
- children: [/* @__PURE__ */ m(s, { className: "text-muted" }), b.switchAccount]
40
- }), /* @__PURE__ */ h(d.Item, {
41
- textValue: y.auth.signOut,
42
- onAction: () => w({ sessionToken: g.session.token }),
43
- children: [/* @__PURE__ */ m(c, { className: "text-muted" }), y.auth.signOut]
44
- })] }) })] })
45
- ]
46
- });
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useAuth, useAuthPlugin, useRevokeMultiSession, useSetActiveSession, useUser } from "@better-auth-ui/react";
3
+ import { ArrowRightArrowLeft, ArrowRightFromSquare, Ellipsis } from "@gravity-ui/icons";
4
+ import { Button, Dropdown, Spinner, toast } from "@heroui/react";
5
+ import { multiSessionPlugin } from "../../../lib/auth/multi-session-plugin";
6
+ import { UserView } from "../user/user-view";
7
+ /**
8
+ * Render a single account row with user info and a dropdown for switch/sign-out actions.
9
+ *
10
+ * Shows the user's avatar and info. A three-dot menu provides options to
11
+ * switch account (for non-active sessions) and sign out.
12
+ *
13
+ * @param deviceSession - The device session object containing session and user data
14
+ * @returns A JSX element containing the account row
15
+ */
16
+ export function ManageAccount({ deviceSession, isPending }) {
17
+ const { authClient, localization } = useAuth();
18
+ const { localization: multiSessionLocalization } = useAuthPlugin(multiSessionPlugin);
19
+ const { data: user } = useUser(authClient);
20
+ const { mutate: setActiveSession, isPending: isSwitching } = useSetActiveSession(authClient, {
21
+ onSuccess: () => window.scrollTo({ top: 0 })
22
+ });
23
+ const { mutate: revokeSession, isPending: isRevoking } = useRevokeMultiSession(authClient, {
24
+ onSuccess: () => toast.success(localization.settings.revokeSessionSuccess)
25
+ });
26
+ const isActive = deviceSession?.session.userId === user?.id;
27
+ const isBusy = isSwitching || isRevoking;
28
+ return (_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsx(UserView, { user: deviceSession?.user, isPending: isPending, size: "md" }), deviceSession && isActive && (_jsxs(Button, { className: "shrink-0", variant: "outline", size: "sm", onPress: () => revokeSession({ sessionToken: deviceSession.session.token }), isDisabled: isBusy, children: [isRevoking ? (_jsx(Spinner, { color: "current", size: "sm" })) : (_jsx(ArrowRightFromSquare, {})), localization.auth.signOut] })), deviceSession && !isActive && (_jsxs(Dropdown, { children: [_jsx(Button, { isIconOnly: true, variant: "ghost", className: "shrink-0", size: "sm", isDisabled: isBusy, children: _jsx(Ellipsis, {}) }), _jsx(Dropdown.Popover, { children: _jsxs(Dropdown.Menu, { children: [_jsxs(Dropdown.Item, { textValue: multiSessionLocalization.switchAccount, onAction: () => setActiveSession({
29
+ sessionToken: deviceSession.session.token
30
+ }), children: [_jsx(ArrowRightArrowLeft, { className: "text-muted" }), multiSessionLocalization.switchAccount] }), _jsxs(Dropdown.Item, { textValue: localization.auth.signOut, onAction: () => revokeSession({
31
+ sessionToken: deviceSession.session.token
32
+ }), children: [_jsx(ArrowRightFromSquare, { className: "text-muted" }), localization.auth.signOut] })] }) })] }))] }));
47
33
  }
48
- //#endregion
49
- export { g as ManageAccount };
@@ -1,4 +1,4 @@
1
- import { CardProps } from '@heroui/react';
1
+ import { type CardProps } from "@heroui/react";
2
2
  export type ManageAccountsProps = {
3
3
  className?: string;
4
4
  variant?: CardProps["variant"];
@@ -1,34 +1,33 @@
1
- import { multiSessionPlugin as e } from "../../../lib/auth/multi-session-plugin.js";
2
- import { ManageAccount as t } from "./manage-account.js";
3
- import { useAuth as n, useAuthPlugin as r, useListDeviceSessions as i, useSession as a } from "@better-auth-ui/react";
4
- import { Card as o, cn as s } from "@heroui/react";
5
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
6
- //#region src/components/auth/multi-session/manage-accounts.tsx
7
- function u({ className: u, variant: d, ...f }) {
8
- let { authClient: p } = n(), { localization: m } = r(e), { data: h } = a(p), { data: g, isPending: _ } = i(p), v = g?.filter((e) => e.session.id !== h?.session.id), y = [{
9
- key: h?.session.id ?? "current",
10
- deviceSession: _ ? null : h,
11
- isPending: _
12
- }, ...v?.map((e) => ({
13
- key: e.session.id,
14
- deviceSession: e,
15
- isPending: !1
16
- })) ?? []];
17
- return /* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("h2", {
18
- className: s("text-sm font-semibold mb-3"),
19
- children: m.manageAccounts
20
- }), /* @__PURE__ */ c(o, {
21
- className: s(u),
22
- variant: d,
23
- ...f,
24
- children: /* @__PURE__ */ c(o.Content, {
25
- className: "gap-0",
26
- children: y.map((e, n) => /* @__PURE__ */ l("div", { children: [n > 0 && /* @__PURE__ */ c("div", { className: "border-b border-dashed -mx-4 md:-mx-6 my-4" }), /* @__PURE__ */ c(t, {
27
- deviceSession: e.deviceSession,
28
- isPending: e.isPending
29
- })] }, e.key))
30
- })
31
- })] });
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useAuth, useAuthPlugin, useListDeviceSessions, useSession } from "@better-auth-ui/react";
3
+ import { Card, cn } from "@heroui/react";
4
+ import { multiSessionPlugin } from "../../../lib/auth/multi-session-plugin";
5
+ import { ManageAccount } from "./manage-account";
6
+ /**
7
+ * Render a card that lists and manages all device sessions for the current user.
8
+ *
9
+ * Shows each session with user information and actions to switch to or revoke a session.
10
+ * When device session data is loading, a pending placeholder row is displayed.
11
+ *
12
+ * @returns A JSX element containing the accounts management card
13
+ */
14
+ export function ManageAccounts({ className, variant, ...props }) {
15
+ const { authClient } = useAuth();
16
+ const { localization: multiSessionLocalization } = useAuthPlugin(multiSessionPlugin);
17
+ const { data: session } = useSession(authClient);
18
+ const { data: deviceSessions, isPending } = useListDeviceSessions(authClient);
19
+ const otherSessions = deviceSessions?.filter((deviceSession) => deviceSession.session.id !== session?.session.id);
20
+ const allRows = [
21
+ {
22
+ key: session?.session.id ?? "current",
23
+ deviceSession: !isPending ? session : null,
24
+ isPending
25
+ },
26
+ ...(otherSessions?.map((deviceSession) => ({
27
+ key: deviceSession.session.id,
28
+ deviceSession,
29
+ isPending: false
30
+ })) ?? [])
31
+ ];
32
+ return (_jsxs("div", { children: [_jsx("h2", { className: cn("text-sm font-semibold mb-3"), children: multiSessionLocalization.manageAccounts }), _jsx(Card, { className: cn(className), variant: variant, ...props, children: _jsx(Card.Content, { className: "gap-0", children: allRows.map((row, index) => (_jsxs("div", { children: [index > 0 && (_jsx("div", { className: "border-b border-dashed -mx-4 my-4" })), _jsx(ManageAccount, { deviceSession: row.deviceSession, isPending: row.isPending })] }, row.key))) }) })] }));
32
33
  }
33
- //#endregion
34
- export { u as ManageAccounts };
@@ -7,4 +7,6 @@
7
7
  *
8
8
  * @returns The switch account submenu content as a JSX element
9
9
  */
10
- export declare function SwitchAccountSubmenuContent(): import("react/jsx-runtime").JSX.Element;
10
+ export declare function SwitchAccountSubmenuContent({ hideSubtitle }: {
11
+ hideSubtitle?: boolean;
12
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,28 +1,25 @@
1
- import { UserView as e } from "../user/user-view.js";
2
- import { SwitchAccountSubmenuItem as t } from "./switch-account-submenu-item.js";
3
- import { multiSessionPlugin as n } from "../../../lib/auth/multi-session-plugin.js";
4
- import { useAuth as r, useAuthPlugin as i, useListDeviceSessions as a, useSession as o } from "@better-auth-ui/react";
5
- import { Check as s, CirclePlus as c } from "@gravity-ui/icons";
6
- import { Dropdown as l, Label as u } from "@heroui/react";
7
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
8
- //#region src/components/auth/multi-session/switch-account-submenu-content.tsx
9
- function p() {
10
- let { authClient: p, basePaths: m, viewPaths: h } = r(), { localization: g } = i(n), { data: _ } = o(p), { data: v, isPending: y } = a(p);
11
- return /* @__PURE__ */ d(l.Popover, {
12
- className: "min-w-40 md:min-w-56 max-w-[48svw]",
13
- children: /* @__PURE__ */ f(l.Menu, { children: [
14
- /* @__PURE__ */ f(l.Item, {
15
- className: "px-2",
16
- children: [/* @__PURE__ */ d(e, { isPending: y }), !y && /* @__PURE__ */ d(s, { className: "ml-auto" })]
17
- }),
18
- v?.filter((e) => e.session.id !== _?.session?.id).map((e) => /* @__PURE__ */ d(t, { deviceSession: e }, e.session.id)),
19
- /* @__PURE__ */ f(l.Item, {
20
- textValue: g.addAccount,
21
- href: `${m.auth}/${h.auth.signIn}`,
22
- children: [/* @__PURE__ */ d(c, { className: "text-muted" }), /* @__PURE__ */ d(u, { children: g.addAccount })]
23
- })
24
- ] })
25
- });
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useAuth, useAuthPlugin, useListDeviceSessions, useSession } from "@better-auth-ui/react";
3
+ import { Check, CirclePlus } from "@gravity-ui/icons";
4
+ import { Dropdown, Label } from "@heroui/react";
5
+ import { multiSessionPlugin } from "../../../lib/auth/multi-session-plugin";
6
+ import { UserView } from "../user/user-view";
7
+ import { SwitchAccountSubmenuItem } from "./switch-account-submenu-item";
8
+ /**
9
+ * Render the submenu content for switching between multiple authenticated sessions.
10
+ *
11
+ * Shows the current session with a checkmark, lists other device sessions that can be activated,
12
+ * and provides an option to add a new account. This component should be rendered inside a
13
+ * Dropdown.SubmenuTrigger to defer the useListDeviceSessions query until the submenu is opened.
14
+ *
15
+ * @returns The switch account submenu content as a JSX element
16
+ */
17
+ export function SwitchAccountSubmenuContent({ hideSubtitle }) {
18
+ const { authClient, basePaths, viewPaths } = useAuth();
19
+ const { localization: multiSessionLocalization } = useAuthPlugin(multiSessionPlugin);
20
+ const { data: session } = useSession(authClient);
21
+ const { data: deviceSessions, isPending } = useListDeviceSessions(authClient);
22
+ return (_jsx(Dropdown.Popover, { className: "min-w-40 md:min-w-56 max-w-[48svw]", children: _jsxs(Dropdown.Menu, { children: [_jsxs(Dropdown.Item, { className: "px-2", children: [_jsx(UserView, { isPending: isPending, hideSubtitle: hideSubtitle }), !isPending && _jsx(Check, { className: "ml-auto" })] }), deviceSessions
23
+ ?.filter((deviceSession) => deviceSession.session.id !== session?.session?.id)
24
+ .map((deviceSession) => (_jsx(SwitchAccountSubmenuItem, { deviceSession: deviceSession, hideSubtitle: hideSubtitle }, deviceSession.session.id))), _jsxs(Dropdown.Item, { textValue: multiSessionLocalization.addAccount, href: `${basePaths.auth}/${viewPaths.auth.signIn}`, children: [_jsx(CirclePlus, { className: "text-muted" }), _jsx(Label, { children: multiSessionLocalization.addAccount })] })] }) }));
26
25
  }
27
- //#endregion
28
- export { p as SwitchAccountSubmenuContent };