@better-auth-ui/heroui 1.6.7 → 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 (280) 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.d.ts +5 -0
  129. package/dist/components/auth/passkey/add-passkey-dialog.js +22 -0
  130. package/dist/components/auth/passkey/delete-passkey-dialog.d.ts +11 -0
  131. package/dist/components/auth/passkey/delete-passkey-dialog.js +14 -0
  132. package/dist/components/auth/passkey/passkey-button.d.ts +1 -1
  133. package/dist/components/auth/passkey/passkey-button.js +24 -23
  134. package/dist/components/auth/passkey/passkey-skeleton.d.ts +1 -0
  135. package/dist/components/auth/passkey/passkey-skeleton.js +5 -0
  136. package/dist/components/auth/passkey/passkey.d.ts +2 -5
  137. package/dist/components/auth/passkey/passkey.js +16 -44
  138. package/dist/components/auth/passkey/passkeys-empty.d.ts +4 -0
  139. package/dist/components/auth/passkey/passkeys-empty.js +9 -0
  140. package/dist/components/auth/passkey/passkeys.d.ts +1 -1
  141. package/dist/components/auth/passkey/passkeys.js +15 -105
  142. package/dist/components/auth/provider-button.d.ts +2 -2
  143. package/dist/components/auth/provider-button.js +28 -24
  144. package/dist/components/auth/provider-buttons.js +28 -18
  145. package/dist/components/auth/reset-password.d.ts +1 -1
  146. package/dist/components/auth/reset-password.js +56 -146
  147. package/dist/components/auth/settings/account/account-settings.d.ts +2 -2
  148. package/dist/components/auth/settings/account/account-settings.js +21 -19
  149. package/dist/components/auth/settings/account/change-avatar.js +53 -88
  150. package/dist/components/auth/settings/account/change-email.d.ts +1 -1
  151. package/dist/components/auth/settings/account/change-email.js +27 -53
  152. package/dist/components/auth/settings/account/user-profile.d.ts +1 -1
  153. package/dist/components/auth/settings/account/user-profile.js +64 -85
  154. package/dist/components/auth/settings/security/active-session.d.ts +1 -1
  155. package/dist/components/auth/settings/security/active-session.js +50 -57
  156. package/dist/components/auth/settings/security/active-sessions.d.ts +1 -1
  157. package/dist/components/auth/settings/security/active-sessions.js +21 -32
  158. package/dist/components/auth/settings/security/change-password.d.ts +1 -1
  159. package/dist/components/auth/settings/security/change-password.js +76 -186
  160. package/dist/components/auth/settings/security/linked-account.d.ts +1 -1
  161. package/dist/components/auth/settings/security/linked-account.js +37 -55
  162. package/dist/components/auth/settings/security/linked-accounts.d.ts +1 -1
  163. package/dist/components/auth/settings/security/linked-accounts.js +34 -43
  164. package/dist/components/auth/settings/security/security-settings.d.ts +2 -2
  165. package/dist/components/auth/settings/security/security-settings.js +19 -21
  166. package/dist/components/auth/settings/settings.d.ts +4 -4
  167. package/dist/components/auth/settings/settings.js +52 -44
  168. package/dist/components/auth/sign-in.d.ts +2 -2
  169. package/dist/components/auth/sign-in.js +63 -132
  170. package/dist/components/auth/sign-out.js +32 -26
  171. package/dist/components/auth/sign-up.d.ts +2 -2
  172. package/dist/components/auth/sign-up.js +97 -211
  173. package/dist/components/auth/theme/appearance.d.ts +1 -1
  174. package/dist/components/auth/theme/appearance.js +23 -71
  175. package/dist/components/auth/theme/theme-toggle-item.js +56 -61
  176. package/dist/components/auth/user/user-avatar.d.ts +4 -4
  177. package/dist/components/auth/user/user-avatar.js +31 -28
  178. package/dist/components/auth/user/user-button.d.ts +6 -7
  179. package/dist/components/auth/user/user-button.js +38 -72
  180. package/dist/components/auth/user/user-view.d.ts +13 -7
  181. package/dist/components/auth/user/user-view.js +26 -36
  182. package/dist/components/auth/username/sign-in-username.d.ts +2 -2
  183. package/dist/components/auth/username/sign-in-username.js +87 -147
  184. package/dist/components/auth/username/username-field.d.ts +1 -1
  185. package/dist/components/auth/username/username-field.js +44 -52
  186. package/dist/email.d.ts +8 -7
  187. package/dist/email.js +8 -8
  188. package/dist/index.d.ts +21 -21
  189. package/dist/index.js +21 -22
  190. package/dist/lib/auth/api-key-plugin.d.ts +7 -4
  191. package/dist/lib/auth/api-key-plugin.js +12 -10
  192. package/dist/lib/auth/auth-plugin.d.ts +10 -6
  193. package/dist/lib/auth/auth-plugin.js +1 -0
  194. package/dist/lib/auth/delete-user-plugin.d.ts +6 -6
  195. package/dist/lib/auth/delete-user-plugin.js +6 -9
  196. package/dist/lib/auth/magic-link-plugin.d.ts +5 -5
  197. package/dist/lib/auth/magic-link-plugin.js +17 -12
  198. package/dist/lib/auth/multi-session-plugin.d.ts +5 -5
  199. package/dist/lib/auth/multi-session-plugin.js +8 -11
  200. package/dist/lib/auth/organization-plugin.d.ts +37 -0
  201. package/dist/lib/auth/organization-plugin.js +19 -0
  202. package/dist/lib/auth/passkey-plugin.d.ts +9 -6
  203. package/dist/lib/auth/passkey-plugin.js +8 -11
  204. package/dist/lib/auth/theme-plugin.d.ts +6 -6
  205. package/dist/lib/auth/theme-plugin.js +25 -22
  206. package/dist/lib/auth/username-plugin.d.ts +11 -11
  207. package/dist/lib/auth/username-plugin.js +18 -17
  208. package/dist/plugins.d.ts +46 -22
  209. package/dist/plugins.js +47 -22
  210. package/package.json +25 -19
  211. package/src/components/auth/api-key/api-key.tsx +25 -16
  212. package/src/components/auth/api-key/api-keys-empty.tsx +8 -4
  213. package/src/components/auth/api-key/api-keys.tsx +52 -14
  214. package/src/components/auth/api-key/create-api-key-dialog.tsx +17 -4
  215. package/src/components/auth/api-key/delete-api-key-dialog.tsx +10 -2
  216. package/src/components/auth/api-key/organization-api-keys.tsx +55 -0
  217. package/src/components/auth/delete-user/danger-zone.tsx +3 -3
  218. package/src/components/auth/delete-user/{delete-user.tsx → delete-account.tsx} +9 -9
  219. package/src/components/auth/email/organization-invitation-email.tsx +38 -0
  220. package/src/components/auth/error-toaster.tsx +28 -10
  221. package/src/components/auth/forgot-password.tsx +10 -2
  222. package/src/components/auth/multi-session/manage-accounts.tsx +1 -1
  223. package/src/components/auth/multi-session/switch-account-submenu-content.tsx +7 -2
  224. package/src/components/auth/multi-session/switch-account-submenu-item.tsx +4 -2
  225. package/src/components/auth/multi-session/switch-account-submenu.tsx +8 -4
  226. package/src/components/auth/organization/change-organization-logo.tsx +171 -0
  227. package/src/components/auth/organization/create-organization-dialog.tsx +133 -0
  228. package/src/components/auth/organization/delete-organization-dialog.tsx +97 -0
  229. package/src/components/auth/organization/delete-organization-skeleton.tsx +17 -0
  230. package/src/components/auth/organization/delete-organization.tsx +77 -0
  231. package/src/components/auth/organization/invite-member-dialog.tsx +177 -0
  232. package/src/components/auth/organization/leave-organization-dialog.tsx +95 -0
  233. package/src/components/auth/organization/leave-organization.tsx +59 -0
  234. package/src/components/auth/organization/organization-danger-zone.tsx +68 -0
  235. package/src/components/auth/organization/organization-invitation-row-skeleton.tsx +29 -0
  236. package/src/components/auth/organization/organization-invitation-row.tsx +97 -0
  237. package/src/components/auth/organization/organization-invitations-empty.tsx +39 -0
  238. package/src/components/auth/organization/organization-invitations.tsx +351 -0
  239. package/src/components/auth/organization/organization-logo.tsx +64 -0
  240. package/src/components/auth/organization/organization-member-row-skeleton.tsx +24 -0
  241. package/src/components/auth/organization/organization-member-row.tsx +157 -0
  242. package/src/components/auth/organization/organization-members.tsx +284 -0
  243. package/src/components/auth/organization/organization-people.tsx +26 -0
  244. package/src/components/auth/organization/organization-profile.tsx +141 -0
  245. package/src/components/auth/organization/organization-row.tsx +66 -0
  246. package/src/components/auth/organization/organization-settings.tsx +38 -0
  247. package/src/components/auth/organization/organization-switcher.tsx +233 -0
  248. package/src/components/auth/organization/organization-view-skeleton.tsx +36 -0
  249. package/src/components/auth/organization/organization-view.tsx +109 -0
  250. package/src/components/auth/organization/organization.tsx +162 -0
  251. package/src/components/auth/organization/organizations-empty.tsx +35 -0
  252. package/src/components/auth/organization/organizations-settings.tsx +36 -0
  253. package/src/components/auth/organization/organizations.tsx +80 -0
  254. package/src/components/auth/organization/remove-member-dialog.tsx +95 -0
  255. package/src/components/auth/organization/slug-field.tsx +111 -0
  256. package/src/components/auth/organization/user-invitation-row-skeleton.tsx +17 -0
  257. package/src/components/auth/organization/user-invitation-row.tsx +90 -0
  258. package/src/components/auth/organization/user-invitations-empty.tsx +30 -0
  259. package/src/components/auth/organization/user-invitations.tsx +59 -0
  260. package/src/components/auth/passkey/add-passkey-dialog.tsx +109 -0
  261. package/src/components/auth/passkey/delete-passkey-dialog.tsx +95 -0
  262. package/src/components/auth/passkey/passkey-skeleton.tsx +16 -0
  263. package/src/components/auth/passkey/passkey.tsx +23 -22
  264. package/src/components/auth/passkey/passkeys-empty.tsx +35 -0
  265. package/src/components/auth/passkey/passkeys.tsx +33 -154
  266. package/src/components/auth/settings/account/change-email.tsx +1 -1
  267. package/src/components/auth/settings/account/user-profile.tsx +5 -5
  268. package/src/components/auth/settings/security/active-sessions.tsx +6 -4
  269. package/src/components/auth/settings/security/linked-accounts.tsx +2 -2
  270. package/src/components/auth/settings/settings.tsx +77 -14
  271. package/src/components/auth/user/user-avatar.tsx +4 -1
  272. package/src/components/auth/user/user-button.tsx +14 -11
  273. package/src/components/auth/user/user-view.tsx +32 -12
  274. package/src/email.ts +1 -0
  275. package/src/lib/auth/api-key-plugin.ts +10 -4
  276. package/src/lib/auth/auth-plugin.ts +6 -1
  277. package/src/lib/auth/organization-plugin.tsx +32 -0
  278. package/src/plugins.ts +25 -1
  279. package/dist/components/auth/delete-user/delete-user.d.ts +0 -9
  280. package/dist/components/auth/delete-user/delete-user.js +0 -95
@@ -1,89 +1,54 @@
1
- import { UserAvatar as e } from "../../user/user-avatar.js";
2
- import { fileToBase64 as t } from "@better-auth-ui/core";
3
- import { useAuth as n, useSession as r, useUpdateUser as i } from "@better-auth-ui/react";
4
- import { CloudArrowUpIn as a, TrashBin as o } from "@gravity-ui/icons";
5
- import { Button as s, Dropdown as c, Label as l, Spinner as u, cn as d, toast as f } from "@heroui/react";
6
- import { useRef as p, useState as m } from "react";
7
- import { jsx as h, jsxs as g } from "react/jsx-runtime";
8
- //#region src/components/auth/settings/account/change-avatar.tsx
9
- function _({ className: _ }) {
10
- let { authClient: v, localization: y, avatar: b } = n(), { data: x } = r(v), { mutate: S, isPending: C } = i(v), w = p(null), [T, E] = m(!1), [D, O] = m(!1), k = C || T || D;
11
- async function A(e) {
12
- let n = e.target.files?.[0];
13
- if (n) {
14
- e.target.value = "", E(!0);
15
- try {
16
- let e = await b.resize?.(n, b.size, b.extension) || n;
17
- S({ image: await b.upload?.(e) || await t(e) }, { onSuccess: () => f.success(y.settings.avatarChangedSuccess) });
18
- } catch (e) {
19
- e instanceof Error && f.danger(e.message);
20
- }
21
- E(!1);
22
- }
23
- }
24
- async function j() {
25
- let e = x?.user.image;
26
- S({ image: null }, { onSuccess: async () => {
27
- if (e) {
28
- O(!0);
29
- try {
30
- await b.delete?.(e);
31
- } finally {
32
- O(!1);
33
- }
34
- }
35
- f.success(y.settings.avatarDeletedSuccess);
36
- } });
37
- }
38
- return /* @__PURE__ */ g("div", {
39
- className: d("flex flex-col gap-1", _),
40
- children: [
41
- /* @__PURE__ */ h(l, {
42
- isDisabled: !x,
43
- children: y.settings.avatar
44
- }),
45
- /* @__PURE__ */ h("input", {
46
- ref: w,
47
- type: "file",
48
- accept: "image/*",
49
- className: "hidden",
50
- onChange: A
51
- }),
52
- /* @__PURE__ */ g("div", {
53
- className: "flex items-center gap-4",
54
- children: [/* @__PURE__ */ h(s, {
55
- type: "button",
56
- isIconOnly: !0,
57
- variant: "ghost",
58
- className: "p-0 h-auto w-auto rounded-full",
59
- isDisabled: !x || k,
60
- onPress: () => w.current?.click(),
61
- children: /* @__PURE__ */ h(e, {
62
- size: "lg",
63
- isPending: k
64
- })
65
- }), /* @__PURE__ */ g(c, { children: [/* @__PURE__ */ g(s, {
66
- isDisabled: !x || k,
67
- size: "sm",
68
- variant: "secondary",
69
- children: [k && /* @__PURE__ */ h(u, { size: "sm" }), y.settings.changeAvatar]
70
- }), /* @__PURE__ */ h(c.Popover, {
71
- className: "min-w-fit",
72
- children: /* @__PURE__ */ g(c.Menu, { children: [/* @__PURE__ */ g(c.Item, {
73
- textValue: y.settings.uploadAvatar,
74
- onAction: () => w.current?.click(),
75
- children: [/* @__PURE__ */ h(a, { className: "text-muted" }), /* @__PURE__ */ h(l, { children: y.settings.uploadAvatar })]
76
- }), /* @__PURE__ */ g(c.Item, {
77
- textValue: y.settings.deleteAvatar,
78
- isDisabled: !x?.user.image,
79
- onAction: j,
80
- variant: "danger",
81
- children: [/* @__PURE__ */ h(o, { className: "text-danger" }), /* @__PURE__ */ h(l, { children: y.settings.deleteAvatar })]
82
- })] })
83
- })] })]
84
- })
85
- ]
86
- });
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { fileToBase64 } from "@better-auth-ui/core";
3
+ import { useAuth, useSession, useUpdateUser } from "@better-auth-ui/react";
4
+ import { CloudArrowUpIn, TrashBin } from "@gravity-ui/icons";
5
+ import { Button, cn, Dropdown, Label, Spinner, toast } from "@heroui/react";
6
+ import { useRef, useState } from "react";
7
+ import { UserAvatar } from "../../user/user-avatar";
8
+ export function ChangeAvatar({ className }) {
9
+ const { authClient, localization, avatar } = useAuth();
10
+ const { data: session } = useSession(authClient);
11
+ const { mutate: updateUser, isPending: updatePending } = useUpdateUser(authClient);
12
+ const fileInputRef = useRef(null);
13
+ const [isUploading, setIsUploading] = useState(false);
14
+ const [isDeleting, setIsDeleting] = useState(false);
15
+ const isPending = updatePending || isUploading || isDeleting;
16
+ async function handleFileChange(e) {
17
+ const file = e.target.files?.[0];
18
+ if (!file)
19
+ return;
20
+ e.target.value = "";
21
+ setIsUploading(true);
22
+ try {
23
+ const resized = (await avatar.resize?.(file, avatar.size, avatar.extension)) || file;
24
+ const image = (await avatar.upload?.(resized)) || (await fileToBase64(resized));
25
+ updateUser({ image }, {
26
+ onSuccess: () => toast.success(localization.settings.avatarChangedSuccess)
27
+ });
28
+ }
29
+ catch (error) {
30
+ if (error instanceof Error) {
31
+ toast.danger(error.message);
32
+ }
33
+ }
34
+ setIsUploading(false);
35
+ }
36
+ async function handleDelete() {
37
+ const currentImage = session?.user.image;
38
+ updateUser({ image: null }, {
39
+ onSuccess: async () => {
40
+ if (currentImage) {
41
+ setIsDeleting(true);
42
+ try {
43
+ await avatar.delete?.(currentImage);
44
+ }
45
+ finally {
46
+ setIsDeleting(false);
47
+ }
48
+ }
49
+ toast.success(localization.settings.avatarDeletedSuccess);
50
+ }
51
+ });
52
+ }
53
+ return (_jsxs("div", { className: cn("flex flex-col gap-1", className), children: [_jsx(Label, { isDisabled: !session, children: localization.settings.avatar }), _jsx("input", { ref: fileInputRef, type: "file", accept: "image/*", className: "hidden", onChange: handleFileChange }), _jsxs("div", { className: "flex items-center gap-4", children: [_jsx(Button, { type: "button", isIconOnly: true, variant: "ghost", className: "p-0 h-auto w-auto rounded-full", isDisabled: !session || isPending, onPress: () => fileInputRef.current?.click(), children: _jsx(UserAvatar, { size: "lg", isPending: isPending }) }), _jsxs(Dropdown, { children: [_jsxs(Button, { isDisabled: !session || isPending, size: "sm", variant: "secondary", children: [isPending && _jsx(Spinner, { size: "sm" }), localization.settings.changeAvatar] }), _jsx(Dropdown.Popover, { className: "min-w-fit", children: _jsxs(Dropdown.Menu, { children: [_jsxs(Dropdown.Item, { textValue: localization.settings.uploadAvatar, onAction: () => fileInputRef.current?.click(), children: [_jsx(CloudArrowUpIn, { className: "text-muted" }), _jsx(Label, { children: localization.settings.uploadAvatar })] }), _jsxs(Dropdown.Item, { textValue: localization.settings.deleteAvatar, isDisabled: !session?.user.image, onAction: handleDelete, variant: "danger", children: [_jsx(TrashBin, { className: "text-danger" }), _jsx(Label, { children: localization.settings.deleteAvatar })] })] }) })] })] })] }));
87
54
  }
88
- //#endregion
89
- export { _ as ChangeAvatar };
@@ -1,4 +1,4 @@
1
- import { CardProps } from '@heroui/react';
1
+ import { type CardProps } from "@heroui/react";
2
2
  export type ChangeEmailProps = {
3
3
  className?: string;
4
4
  variant?: CardProps["variant"];
@@ -1,54 +1,28 @@
1
- import { useAuth as e, useChangeEmail as t, useSession as n } from "@better-auth-ui/react";
2
- import { Button as r, Card as i, FieldError as a, Fieldset as o, Form as s, Input as c, Label as l, Skeleton 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/settings/account/change-email.tsx
5
- function _({ className: _, variant: v, ...y }) {
6
- let { authClient: b, localization: x, baseURL: S, viewPaths: C } = e(), { data: w } = n(b), { mutate: T, isPending: E } = t(b, { onSuccess: () => m.success(x.settings.changeEmailSuccess) });
7
- function D(e) {
8
- e.preventDefault(), T({
9
- newEmail: new FormData(e.currentTarget).get("email"),
10
- callbackURL: `${S}/${C.settings.account}`
11
- });
12
- }
13
- return /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("h2", {
14
- className: p("text-sm font-semibold mb-3"),
15
- children: x.settings.changeEmail
16
- }), /* @__PURE__ */ h(i, {
17
- className: p("p-4 gap-4", _),
18
- variant: v,
19
- ...y,
20
- children: /* @__PURE__ */ h(i.Content, { children: /* @__PURE__ */ h(s, {
21
- onSubmit: D,
22
- children: /* @__PURE__ */ g(o, {
23
- className: "w-full gap-4",
24
- children: [/* @__PURE__ */ h(o.Group, { children: /* @__PURE__ */ g(f, {
25
- name: "email",
26
- type: "email",
27
- defaultValue: w?.user.email,
28
- isDisabled: E || !w,
29
- children: [
30
- /* @__PURE__ */ h(l, { children: x.auth.email }),
31
- w ? /* @__PURE__ */ h(c, {
32
- required: !0,
33
- variant: v === "transparent" ? "primary" : "secondary",
34
- autoComplete: "email",
35
- placeholder: x.auth.emailPlaceholder
36
- }) : /* @__PURE__ */ h(u, { className: "h-10 md:h-9 w-full rounded-xl" }),
37
- /* @__PURE__ */ h(a, {})
38
- ]
39
- }, w?.user.email) }), /* @__PURE__ */ h(o.Actions, { children: /* @__PURE__ */ g(r, {
40
- type: "submit",
41
- isPending: E,
42
- isDisabled: !w,
43
- size: "sm",
44
- children: [E && /* @__PURE__ */ h(d, {
45
- color: "current",
46
- size: "sm"
47
- }), x.settings.updateEmail]
48
- }) })]
49
- })
50
- }) })
51
- })] });
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useAuth, useChangeEmail, useSession } from "@better-auth-ui/react";
3
+ import { Button, Card, cn, FieldError, Fieldset, Form, Input, Label, Skeleton, Spinner, TextField, toast } from "@heroui/react";
4
+ /**
5
+ * Render a card containing a form to view and update the authenticated user's email.
6
+ *
7
+ * Shows a loading skeleton until session data is available, displays the current
8
+ * email as the form's default value, and sends a verification email to the
9
+ * new address upon successful submission.
10
+ *
11
+ * @returns A JSX element rendering the change-email card and form
12
+ */
13
+ export function ChangeEmail({ className, variant, ...props }) {
14
+ const { authClient, localization, baseURL, viewPaths } = useAuth();
15
+ const { data: session } = useSession(authClient);
16
+ const { mutate: changeEmail, isPending } = useChangeEmail(authClient, {
17
+ onSuccess: () => toast.success(localization.settings.changeEmailSuccess)
18
+ });
19
+ function handleSubmit(e) {
20
+ e.preventDefault();
21
+ const formData = new FormData(e.currentTarget);
22
+ changeEmail({
23
+ newEmail: formData.get("email"),
24
+ callbackURL: `${baseURL}/${viewPaths.settings.account}`
25
+ });
26
+ }
27
+ return (_jsxs("div", { children: [_jsx("h2", { className: cn("text-sm font-semibold mb-3"), children: localization.settings.changeEmail }), _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: [_jsx(Fieldset.Group, { children: _jsxs(TextField, { name: "email", type: "email", defaultValue: session?.user.email, isDisabled: isPending || !session, children: [_jsx(Label, { children: localization.auth.email }), session ? (_jsx(Input, { required: true, variant: variant === "transparent" ? "primary" : "secondary", autoComplete: "email", placeholder: localization.auth.emailPlaceholder })) : (_jsx(Skeleton, { className: "h-10 md:h-9 w-full rounded-xl" })), _jsx(FieldError, {})] }, `${session?.user.id}-${session?.user.email}-email`) }), _jsx(Fieldset.Actions, { children: _jsxs(Button, { type: "submit", isPending: isPending, isDisabled: !session, size: "sm", children: [isPending && _jsx(Spinner, { color: "current", size: "sm" }), localization.settings.updateEmail] }) })] }) }) }) })] }));
52
28
  }
53
- //#endregion
54
- export { _ as ChangeEmail };
@@ -1,4 +1,4 @@
1
- import { CardProps } from '@heroui/react';
1
+ import { type CardProps } from "@heroui/react";
2
2
  export type UserProfileProps = {
3
3
  className?: string;
4
4
  variant?: CardProps["variant"];
@@ -1,86 +1,65 @@
1
- import { AdditionalField as e } from "../../additional-field.js";
2
- import { ChangeAvatar as t } from "./change-avatar.js";
3
- import { parseAdditionalFieldValue as n } from "@better-auth-ui/core";
4
- import { useAuth as r, useSession as i, useUpdateUser as a } from "@better-auth-ui/react";
5
- import { Button as o, Card as s, FieldError as c, Form as l, Input as u, Label as d, Skeleton as f, Spinner as p, TextField as m, cn as h, toast as g } from "@heroui/react";
6
- import { jsx as _, jsxs as v } from "react/jsx-runtime";
7
- //#region src/components/auth/settings/account/user-profile.tsx
8
- function y({ className: y, variant: b, ...x }) {
9
- let { additionalFields: S, authClient: C, localization: w } = r(), { data: T } = i(C), { mutate: E, isPending: D } = a(C, { onSuccess: () => g.success(w.settings.profileUpdatedSuccess) });
10
- async function O(e) {
11
- e.preventDefault();
12
- let t = new FormData(e.currentTarget), r = t.get("name"), i = {};
13
- for (let e of S ?? []) {
14
- if (e.profile === !1 || e.readOnly) continue;
15
- let r = n(e, t.get(e.name));
16
- if (e.validate) try {
17
- await e.validate(r);
18
- } catch (e) {
19
- g.danger(e instanceof Error ? e.message : String(e));
20
- return;
21
- }
22
- r !== void 0 && (i[e.name] = r);
23
- }
24
- E({
25
- name: r,
26
- ...i
27
- });
28
- }
29
- return /* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("h2", {
30
- className: h("text-sm font-semibold mb-3"),
31
- children: w.settings.profile
32
- }), /* @__PURE__ */ _(s, {
33
- className: h("p-4 gap-4", y),
34
- variant: b,
35
- ...x,
36
- children: /* @__PURE__ */ _(s.Content, { children: /* @__PURE__ */ v(l, {
37
- onSubmit: O,
38
- className: "flex flex-col gap-4",
39
- children: [
40
- /* @__PURE__ */ _(t, {}),
41
- /* @__PURE__ */ v(m, {
42
- name: "name",
43
- defaultValue: T?.user.name,
44
- isDisabled: D || !T,
45
- children: [
46
- /* @__PURE__ */ _(d, { children: w.auth.name }),
47
- /* @__PURE__ */ _(u, {
48
- className: h(!T && "hidden"),
49
- autoComplete: "name",
50
- placeholder: w.auth.name,
51
- variant: b === "transparent" ? "primary" : "secondary"
52
- }),
53
- !T && /* @__PURE__ */ _(f, { className: "h-10 md:h-9 w-full rounded-xl" }),
54
- /* @__PURE__ */ _(c, {})
55
- ]
56
- }, T?.user?.name),
57
- S?.filter((e) => e.profile !== !1).map((t) => {
58
- if (!T) return t.inputType === "hidden" ? null : /* @__PURE__ */ _(f, { className: "h-10 md:h-9 w-full rounded-xl" }, t.name);
59
- let n = T.user[t.name], r = `${t.name}:${n instanceof Date ? n.toISOString() : String(n ?? "")}`;
60
- return /* @__PURE__ */ _(e, {
61
- name: t.name,
62
- field: {
63
- ...t,
64
- defaultValue: n
65
- },
66
- isPending: D,
67
- variant: b
68
- }, r);
69
- }),
70
- /* @__PURE__ */ v(o, {
71
- type: "submit",
72
- isPending: D,
73
- isDisabled: !T,
74
- size: "sm",
75
- className: "self-start mt-1",
76
- children: [D && /* @__PURE__ */ _(p, {
77
- color: "current",
78
- size: "sm"
79
- }), w.settings.saveChanges]
80
- })
81
- ]
82
- }) })
83
- })] });
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { parseAdditionalFieldValue } from "@better-auth-ui/core";
3
+ import { useAuth, useSession, useUpdateUser } from "@better-auth-ui/react";
4
+ import { Button, Card, cn, FieldError, Form, Input, Label, Skeleton, Spinner, TextField, toast } from "@heroui/react";
5
+ import { AdditionalField } from "../../additional-field";
6
+ import { ChangeAvatar } from "./change-avatar";
7
+ /**
8
+ * Render a profile card that lets the authenticated user view and update their
9
+ * display name, avatar, and any plugin- or user-supplied additional fields.
10
+ */
11
+ export function UserProfile({ className, variant, ...props }) {
12
+ const { additionalFields, authClient, localization } = useAuth();
13
+ const { data: session } = useSession(authClient);
14
+ const { mutate: updateUser, isPending } = useUpdateUser(authClient, {
15
+ onSuccess: () => toast.success(localization.settings.profileUpdatedSuccess)
16
+ });
17
+ async function handleSubmit(e) {
18
+ e.preventDefault();
19
+ const formData = new FormData(e.currentTarget);
20
+ const name = formData.get("name");
21
+ const additionalFieldValues = {};
22
+ for (const field of additionalFields ?? []) {
23
+ if (field.profile === false || field.readOnly)
24
+ continue;
25
+ const value = parseAdditionalFieldValue(field, formData.get(field.name));
26
+ if (field.validate) {
27
+ try {
28
+ await field.validate(value);
29
+ }
30
+ catch (error) {
31
+ toast.danger(error instanceof Error ? error.message : String(error));
32
+ return;
33
+ }
34
+ }
35
+ // `null` = explicit clear (forward to backend); `undefined` = omitted.
36
+ if (value !== undefined) {
37
+ additionalFieldValues[field.name] = value;
38
+ }
39
+ }
40
+ updateUser({
41
+ name,
42
+ ...additionalFieldValues
43
+ });
44
+ }
45
+ return (_jsxs("div", { children: [_jsx("h2", { className: cn("text-sm font-semibold mb-3"), children: localization.settings.userProfile }), _jsx(Card, { className: cn("p-4 gap-4", className), variant: variant, ...props, children: _jsx(Card.Content, { children: _jsxs(Form, { onSubmit: handleSubmit, className: "flex flex-col gap-4", children: [_jsx(ChangeAvatar, {}), _jsxs(TextField, { name: "name", defaultValue: session?.user.name, isDisabled: isPending || !session, children: [_jsx(Label, { children: localization.auth.name }), _jsx(Input, { className: cn(!session && "hidden"), autoComplete: "name", placeholder: localization.auth.name, variant: variant === "transparent" ? "primary" : "secondary" }), !session && (_jsx(Skeleton, { className: "h-10 md:h-9 w-full rounded-xl" })), _jsx(FieldError, {})] }, `${session?.user?.id}-${session?.user?.name}-name`), additionalFields
46
+ ?.filter((field) => field.profile !== false)
47
+ .map((field) => {
48
+ if (!session) {
49
+ if (field.inputType === "hidden") {
50
+ return null;
51
+ }
52
+ return (_jsx(Skeleton, { className: "h-10 md:h-9 w-full rounded-xl" }, field.name));
53
+ }
54
+ const value = session.user[field.name];
55
+ // Re-mount when the user or the session value changes so the
56
+ // field's uncontrolled `defaultValue` reflects the latest data.
57
+ const key = `${session.user.id}-${field.name}-${value instanceof Date
58
+ ? value.toISOString()
59
+ : String(value ?? "")}`;
60
+ return (_jsx(AdditionalField, { name: field.name, field: {
61
+ ...field,
62
+ defaultValue: value
63
+ }, isPending: isPending, variant: variant }, key));
64
+ }), _jsxs(Button, { type: "submit", isPending: isPending, isDisabled: !session, size: "sm", className: "self-start mt-1", children: [isPending && _jsx(Spinner, { color: "current", size: "sm" }), localization.settings.saveChanges] })] }) }) })] }));
84
65
  }
85
- //#endregion
86
- export { y as UserProfile };
@@ -1,4 +1,4 @@
1
- import { Session } from 'better-auth';
1
+ import type { Session } from "better-auth";
2
2
  export type ActiveSessionProps = {
3
3
  activeSession: Session;
4
4
  };
@@ -1,59 +1,52 @@
1
- import { useAuth as e, useRevokeSession as t, useSession as n } from "@better-auth-ui/react";
2
- import { ArrowRightFromSquare as r, Display as i, Smartphone as a, Xmark as o } from "@gravity-ui/icons";
3
- import { Button as s, Chip as c, Spinner as l, toast as u } from "@heroui/react";
4
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
5
- import p from "bowser";
6
- //#region src/components/auth/settings/security/active-session.tsx
7
- function m(e) {
8
- let t = Math.floor((Date.now() - e.getTime()) / 1e3), n = new Intl.RelativeTimeFormat(void 0, { numeric: "auto" });
9
- for (let [e, r] of [
10
- ["year", 31536e3],
11
- ["month", 2592e3],
12
- ["week", 604800],
13
- ["day", 86400],
14
- ["hour", 3600],
15
- ["minute", 60],
16
- ["second", 1]
17
- ]) if (t >= r) return n.format(-Math.floor(t / r), e);
18
- return n.format(0, "second");
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useAuth, useRevokeSession, useSession } from "@better-auth-ui/react";
3
+ import { ArrowRightFromSquare, Display, Smartphone, Xmark } from "@gravity-ui/icons";
4
+ import { Button, Chip, Spinner, toast } from "@heroui/react";
5
+ import Bowser from "bowser";
6
+ function timeAgo(date) {
7
+ const seconds = Math.floor((Date.now() - date.getTime()) / 1000);
8
+ const rtf = new Intl.RelativeTimeFormat(undefined, { numeric: "auto" });
9
+ const UNITS = [
10
+ ["year", 31536000],
11
+ ["month", 2592000],
12
+ ["week", 604800],
13
+ ["day", 86400],
14
+ ["hour", 3600],
15
+ ["minute", 60],
16
+ ["second", 1]
17
+ ];
18
+ for (const [unit, threshold] of UNITS) {
19
+ if (seconds >= threshold) {
20
+ return rtf.format(-Math.floor(seconds / threshold), unit);
21
+ }
22
+ }
23
+ return rtf.format(0, "second");
19
24
  }
20
- function h({ activeSession: h }) {
21
- let { authClient: g, basePaths: _, localization: v, viewPaths: y, navigate: b } = e(), { data: x } = n(g, { refetchOnMount: !1 }), { mutate: S, isPending: C } = t(g, { onSuccess: () => u.success(v.settings.revokeSessionSuccess) }), w = h.token === x?.session.token, T = p.parse(h.userAgent || "");
22
- return /* @__PURE__ */ f("div", {
23
- className: "flex items-center gap-3",
24
- children: [
25
- /* @__PURE__ */ d("div", {
26
- className: "flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-secondary",
27
- children: T.platform.type === "mobile" || T.platform.type === "tablet" ? /* @__PURE__ */ d(a, { className: "size-4.5" }) : /* @__PURE__ */ d(i, { className: "size-4.5" })
28
- }),
29
- /* @__PURE__ */ f("div", {
30
- className: "flex flex-col min-w-0",
31
- children: [/* @__PURE__ */ f("span", {
32
- className: "text-sm font-medium truncate",
33
- children: [T.browser.name || "Unknown Browser", T.os.name ? `, ${T.os.name}` : ""]
34
- }), w ? /* @__PURE__ */ d(c, {
35
- color: "accent",
36
- size: "sm",
37
- children: v.settings.currentSession
38
- }) : h.createdAt && /* @__PURE__ */ d("span", {
39
- className: "text-xs text-muted capitalize",
40
- children: m(h.createdAt)
41
- })]
42
- }),
43
- /* @__PURE__ */ f(s, {
44
- className: "ml-auto shrink-0",
45
- variant: "outline",
46
- size: "sm",
47
- onPress: () => w ? b({ to: `${_.auth}/${y.auth.signOut}` }) : S(h),
48
- isPending: C,
49
- "aria-label": w ? v.auth.signOut : v.settings.revokeSession,
50
- children: [C ? /* @__PURE__ */ d(l, {
51
- color: "current",
52
- size: "sm"
53
- }) : d(w ? r : o, {}), w ? v.auth.signOut : v.settings.revoke]
54
- })
55
- ]
56
- });
25
+ /**
26
+ * Render a single active session row with device info and revoke control.
27
+ *
28
+ * Shows the session's browser, OS, IP address, and creation time. The current session is marked
29
+ * and navigates to sign-out on click, while other sessions can be revoked individually.
30
+ *
31
+ * @param session - The session object containing id, token, userAgent, ipAddress, and createdAt
32
+ * @returns A JSX element containing the active session row
33
+ */
34
+ export function ActiveSession({ activeSession }) {
35
+ const { authClient, basePaths, localization, viewPaths, navigate } = useAuth();
36
+ const { data: session } = useSession(authClient, { refetchOnMount: false });
37
+ const { mutate: revokeSession, isPending: isRevoking } = useRevokeSession(authClient, {
38
+ onSuccess: () => toast.success(localization.settings.revokeSessionSuccess)
39
+ });
40
+ const isCurrentSession = activeSession.token === session?.session.token;
41
+ const ua = Bowser.parse(activeSession.userAgent || "");
42
+ const isMobile = ua.platform.type === "mobile" || ua.platform.type === "tablet";
43
+ return (_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-secondary", children: isMobile ? (_jsx(Smartphone, { className: "size-4.5" })) : (_jsx(Display, { className: "size-4.5" })) }), _jsxs("div", { className: "flex flex-col min-w-0", children: [_jsxs("span", { className: "text-sm font-medium truncate", children: [ua.browser.name || "Unknown Browser", ua.os.name ? `, ${ua.os.name}` : ""] }), isCurrentSession ? (_jsx(Chip, { color: "accent", size: "sm", children: localization.settings.currentSession })) : (activeSession.createdAt && (_jsx("span", { className: "text-xs text-muted capitalize", children: timeAgo(activeSession.createdAt) })))] }), _jsxs(Button, { className: "ml-auto shrink-0", variant: "outline", size: "sm", onPress: () => isCurrentSession
44
+ ? navigate({
45
+ to: `${basePaths.auth}/${viewPaths.auth.signOut}`
46
+ })
47
+ : revokeSession(activeSession), isPending: isRevoking, "aria-label": isCurrentSession
48
+ ? localization.auth.signOut
49
+ : localization.settings.revokeSession, children: [isRevoking ? (_jsx(Spinner, { color: "current", size: "sm" })) : isCurrentSession ? (_jsx(ArrowRightFromSquare, {})) : (_jsx(Xmark, {})), isCurrentSession
50
+ ? localization.auth.signOut
51
+ : localization.settings.revoke] })] }));
57
52
  }
58
- //#endregion
59
- export { h as ActiveSession };
@@ -1,4 +1,4 @@
1
- import { CardProps } from '@heroui/react';
1
+ import { type CardProps } from "@heroui/react";
2
2
  export type ActiveSessionsProps = {
3
3
  className?: string;
4
4
  variant?: CardProps["variant"];
@@ -1,34 +1,23 @@
1
- import { ActiveSession as e } from "./active-session.js";
2
- import { useAuth as t, useListSessions as n, useSession as r } from "@better-auth-ui/react";
3
- import { Card as i, Skeleton as a, cn as o } from "@heroui/react";
4
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
5
- //#region src/components/auth/settings/security/active-sessions.tsx
6
- function l({ className: a, variant: l, ...d }) {
7
- let { authClient: f, localization: p } = t(), { data: m } = r(f), { data: h, isPending: g } = n(f), _ = h?.toSorted((e) => e.id === m?.session.id ? -1 : 1);
8
- return /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("h2", {
9
- className: o("text-sm font-semibold mb-3"),
10
- children: p.settings.activeSessions
11
- }), /* @__PURE__ */ s(i, {
12
- className: o(a),
13
- variant: l,
14
- ...d,
15
- children: /* @__PURE__ */ s(i.Content, {
16
- className: "gap-0",
17
- children: g ? /* @__PURE__ */ s(u, {}) : _?.map((t, n) => /* @__PURE__ */ c("div", { children: [n > 0 && /* @__PURE__ */ s("div", { className: "border-b border-dashed -mx-4 md:-mx-6 my-4" }), /* @__PURE__ */ s(e, { activeSession: t })] }, t.id))
18
- })
19
- })] });
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useAuth, useListSessions, useSession } from "@better-auth-ui/react";
3
+ import { Card, cn, Skeleton } from "@heroui/react";
4
+ import { ActiveSession } from "./active-session";
5
+ /**
6
+ * Render a card listing all active sessions for the current user with revoke controls.
7
+ *
8
+ * Shows each session's browser, OS, IP address, and creation time. The current session is marked
9
+ * and navigates to sign-out on click, while other sessions can be revoked individually.
10
+ *
11
+ * @returns A JSX element containing the sessions card
12
+ */
13
+ export function ActiveSessions({ className, variant, ...props }) {
14
+ const { authClient, localization } = useAuth();
15
+ const { data: session } = useSession(authClient);
16
+ const { data: sessions, isPending } = useListSessions(authClient);
17
+ const activeSessions = sessions &&
18
+ [...sessions].sort((a, b) => a.id === session?.session.id ? -1 : b.id === session?.session.id ? 1 : 0);
19
+ return (_jsxs("div", { children: [_jsx("h2", { className: cn("text-sm font-semibold mb-3"), children: localization.settings.activeSessions }), _jsx(Card, { className: cn(className), variant: variant, ...props, children: _jsx(Card.Content, { className: "gap-0", children: isPending ? (_jsx(SessionRowSkeleton, {})) : (activeSessions?.map((activeSession, index) => (_jsxs("div", { children: [index > 0 && (_jsx("div", { className: "border-b border-dashed -mx-4 my-4" })), _jsx(ActiveSession, { activeSession: activeSession })] }, activeSession.id)))) }) })] }));
20
20
  }
21
- function u() {
22
- return /* @__PURE__ */ s("div", {
23
- className: "flex items-center justify-between",
24
- children: /* @__PURE__ */ c("div", {
25
- className: "flex items-center gap-3",
26
- children: [/* @__PURE__ */ s(a, { className: "size-10 rounded-xl" }), /* @__PURE__ */ c("div", {
27
- className: "flex flex-col gap-1",
28
- children: [/* @__PURE__ */ s(a, { className: "h-4 w-32 rounded-lg" }), /* @__PURE__ */ s(a, { className: "h-3 w-24 rounded-lg" })]
29
- })]
30
- })
31
- });
21
+ function SessionRowSkeleton() {
22
+ 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-32 rounded-lg" }), _jsx(Skeleton, { className: "h-3 w-24 rounded-lg" })] })] }) }));
32
23
  }
33
- //#endregion
34
- export { l as ActiveSessions };
@@ -1,4 +1,4 @@
1
- import { CardProps } from '@heroui/react';
1
+ import { type CardProps } from "@heroui/react";
2
2
  export type ChangePasswordProps = {
3
3
  className?: string;
4
4
  variant?: CardProps["variant"];