@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,45 +1,53 @@
1
- import { AccountSettings as e } from "./account/account-settings.js";
2
- import { SecuritySettings as t } from "./security/security-settings.js";
3
- import { useAuth as n, useAuthenticate as r } from "@better-auth-ui/react";
4
- import { Tabs as i, cn as a } from "@heroui/react";
5
- import { useMemo as o } from "react";
6
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
7
- //#region src/components/auth/settings/settings.tsx
8
- function l({ className: l, hideNav: u, path: d, variant: f, view: p, ...m }) {
9
- let { authClient: h, basePaths: g, localization: _, viewPaths: v } = n();
10
- if (r(h), !p && !d) throw Error("[Better Auth UI] Either `view` or `path` must be provided");
11
- let y = o(() => Object.fromEntries(Object.entries(v.settings).map(([e, t]) => [t, e])), [v.settings]), b = p || (d ? y[d] : void 0);
12
- return /* @__PURE__ */ c(i, {
13
- className: a(l),
14
- orientation: "horizontal",
15
- selectedKey: b,
16
- ...m,
17
- children: [
18
- /* @__PURE__ */ s(i.ListContainer, { children: /* @__PURE__ */ c(i.List, {
19
- "aria-label": _.settings.settings,
20
- className: "overflow-auto w-fit",
21
- children: [/* @__PURE__ */ c(i.Tab, {
22
- id: "account",
23
- href: `${g.settings}/${v.settings.account}`,
24
- children: [_.settings.account, /* @__PURE__ */ s(i.Indicator, {})]
25
- }), /* @__PURE__ */ c(i.Tab, {
26
- id: "security",
27
- href: `${g.settings}/${v.settings.security}`,
28
- children: [_.settings.security, /* @__PURE__ */ s(i.Indicator, {})]
29
- })]
30
- }) }),
31
- /* @__PURE__ */ s(i.Panel, {
32
- id: "account",
33
- className: "px-0",
34
- children: /* @__PURE__ */ s(e, { variant: f })
35
- }),
36
- /* @__PURE__ */ s(i.Panel, {
37
- id: "security",
38
- className: "px-0",
39
- children: /* @__PURE__ */ s(t, { variant: f })
40
- })
41
- ]
42
- });
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useAuth, useAuthenticate } from "@better-auth-ui/react";
3
+ import { Person, Shield } from "@gravity-ui/icons";
4
+ import { cn, Tabs } from "@heroui/react";
5
+ import { useMemo } from "react";
6
+ import { AccountSettings } from "./account/account-settings";
7
+ import { SecuritySettings } from "./security/security-settings";
8
+ /**
9
+ * Renders the settings UI and activates the appropriate settings view based on `view` or `path`.
10
+ *
11
+ * @param className - Additional CSS class names applied to the root container
12
+ * @param path - Route path used to resolve which settings view to activate when `view` is not provided
13
+ * @param view - Explicit settings view to activate, e.g. `"account"` or `"security"`
14
+ * @param hideNav - When `true`, hide the navigation tabs
15
+ * @param variant - Card variant forwarded to each settings section card
16
+ * @returns A DOM tree containing the responsive settings tabs and the currently selected settings panel
17
+ *
18
+ * @throws Error if neither `view` nor `path` is provided, or if `path` does not match any settings view
19
+ */
20
+ export function Settings({ className, hideNav, path, variant, view, ...props }) {
21
+ if (!view && !path) {
22
+ throw new Error("[Better Auth UI] Either `view` or `path` must be provided");
23
+ }
24
+ const { authClient, basePaths, localization, viewPaths, plugins } = useAuth();
25
+ useAuthenticate(authClient);
26
+ // Built-ins first, then plugin segments
27
+ const currentView = useMemo(() => {
28
+ if (view)
29
+ return view;
30
+ if (!path)
31
+ return undefined;
32
+ const match = [
33
+ viewPaths.settings,
34
+ ...plugins.map((plugin) => plugin.viewPaths?.settings)
35
+ ]
36
+ .flatMap((source) => Object.entries(source ?? {}))
37
+ .find(([, segment]) => segment === path);
38
+ return match?.[0];
39
+ }, [view, path, viewPaths.settings, plugins]);
40
+ if (!currentView) {
41
+ const validPaths = [
42
+ viewPaths.settings,
43
+ ...plugins.map((plugin) => plugin.viewPaths?.settings)
44
+ ]
45
+ .flatMap((source) => Object.values(source ?? {}))
46
+ .join(", ");
47
+ throw new Error(`[Better Auth UI] Unknown settings path "${path}". Valid paths are: ${validPaths}`);
48
+ }
49
+ return (_jsxs(Tabs, { className: cn(className), orientation: "horizontal", selectedKey: currentView, ...props, children: [_jsx(Tabs.ListContainer, { children: _jsxs(Tabs.List, { "aria-label": localization.settings.settings, className: "max-w-fit overflow-x-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden", children: [_jsxs(Tabs.Tab, { id: "account", href: `${basePaths.settings}/${viewPaths.settings.account}`, className: "gap-2", onPress: (e) => e.target.scrollIntoView({ behavior: "smooth", inline: "center" }), children: [_jsx(Person, { className: "text-muted" }), localization.settings.account, _jsx(Tabs.Indicator, {})] }), _jsxs(Tabs.Tab, { id: "security", href: `${basePaths.settings}/${viewPaths.settings.security}`, className: "gap-2", onPress: (e) => e.target.scrollIntoView({ behavior: "smooth", inline: "center" }), children: [_jsx(Shield, { className: "text-muted" }), localization.settings.security, _jsx(Tabs.Indicator, {})] }), plugins.flatMap((plugin) => plugin.settingsTabs?.map((settingsTab, index) => (_jsxs(Tabs.Tab, { id: settingsTab.view, href: `${basePaths.settings}/${plugin.viewPaths?.settings?.[settingsTab.view]}`, className: "gap-2", onPress: (e) => e.target.scrollIntoView({
50
+ behavior: "smooth",
51
+ inline: "center"
52
+ }), children: [settingsTab.label, _jsx(Tabs.Indicator, {})] }, `${plugin.id}-${index.toString()}`))) ?? [])] }) }), _jsx(Tabs.Panel, { id: "account", className: "px-0", children: _jsx(AccountSettings, { variant: variant }) }), _jsx(Tabs.Panel, { id: "security", className: "px-0", children: _jsx(SecuritySettings, { variant: variant }) }), plugins.flatMap((plugin) => plugin.settingsTabs?.map((settingsTab, index) => (_jsx(Tabs.Panel, { id: settingsTab.view, className: "px-0", children: _jsx(settingsTab.component, { variant: variant }) }, `${plugin.id}-${index.toString()}`))))] }));
43
53
  }
44
- //#endregion
45
- export { l as Settings };
@@ -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 interface SignInProps {
4
4
  className?: string;
5
5
  socialLayout?: SocialLayout;
@@ -1,133 +1,64 @@
1
- import { FieldSeparator as e } from "./field-separator.js";
2
- import { ProviderButtons as t } from "./provider-buttons.js";
3
- import { authMutationKeys as n } from "@better-auth-ui/core";
4
- import { useAuth as r, useFetchOptions as i, useSendVerificationEmail as a, useSignInEmail as o } from "@better-auth-ui/react";
5
- import { Button as s, Card as c, Checkbox as l, Description as u, FieldError as d, Form as f, Input as p, Label as m, Link as h, Spinner as g, TextField as _, cn as v, toast as y } from "@heroui/react";
6
- import { useState as b } from "react";
7
- import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
8
- import { useIsMutating as w } from "@tanstack/react-query";
9
- //#region src/components/auth/sign-in.tsx
10
- function T({ className: T, socialLayout: E, socialPosition: D = "bottom", variant: O, ...k }) {
11
- let { authClient: A, basePaths: j, baseURL: M, emailAndPassword: N, localization: P, plugins: F, redirectTo: I, socialProviders: L, viewPaths: R, navigate: z } = r(), { fetchOptions: B, resetFetchOptions: V } = i(), [H, U] = b(""), { mutate: W } = a(A, { onSuccess: () => y.success(P.auth.verificationEmailSent) }), { mutate: G, isPending: K } = o(A, {
12
- onError: (e, { email: t }) => {
13
- U(""), e.error?.code === "EMAIL_NOT_VERIFIED" ? y.danger(e.error?.message || e.message, { actionProps: {
14
- children: P.auth.resend,
15
- onClick: () => W({
16
- email: t,
17
- callbackURL: `${M}${I}`
18
- })
19
- } }) : y.danger(e.error?.message || e.message), V();
20
- },
21
- onSuccess: () => z({ to: I })
22
- }), q = (e) => {
23
- e.preventDefault();
24
- let t = new FormData(e.currentTarget), n = t.get("email"), r = t.get("rememberMe") === "on";
25
- G({
26
- email: n,
27
- password: H,
28
- ...N?.rememberMe ? { rememberMe: r } : {},
29
- fetchOptions: B
30
- });
31
- }, J = w({ mutationKey: n.signIn.all }) + w({ mutationKey: n.signUp.all }) > 0, Y = F.find((e) => e.captchaComponent)?.captchaComponent, X = N?.enabled && !!L?.length;
32
- return /* @__PURE__ */ C(c, {
33
- className: v("w-full max-w-sm gap-4 md:p-6", T),
34
- variant: O,
35
- ...k,
36
- children: [
37
- /* @__PURE__ */ S(c.Header, { children: /* @__PURE__ */ S(c.Title, {
38
- className: "text-xl font-semibold mb-1",
39
- children: P.auth.signIn
40
- }) }),
41
- /* @__PURE__ */ C(c.Content, {
42
- className: "gap-4",
43
- children: [
44
- D === "top" && /* @__PURE__ */ C(x, { children: [!!L?.length && /* @__PURE__ */ S(t, { socialLayout: E }), X && /* @__PURE__ */ S(e, { children: P.auth.or })] }),
45
- N?.enabled && /* @__PURE__ */ C(f, {
46
- onSubmit: q,
47
- className: "flex flex-col gap-4",
48
- children: [
49
- /* @__PURE__ */ C(_, {
50
- name: "email",
51
- type: "email",
52
- autoComplete: "email",
53
- isDisabled: J,
54
- children: [
55
- /* @__PURE__ */ S(m, { children: P.auth.email }),
56
- /* @__PURE__ */ S(p, {
57
- placeholder: P.auth.emailPlaceholder,
58
- variant: O === "transparent" ? "primary" : "secondary",
59
- required: !0
60
- }),
61
- /* @__PURE__ */ S(d, {})
62
- ]
63
- }),
64
- /* @__PURE__ */ C(_, {
65
- minLength: N?.minPasswordLength,
66
- maxLength: N?.maxPasswordLength,
67
- name: "password",
68
- type: "password",
69
- autoComplete: "current-password",
70
- isDisabled: J,
71
- value: H,
72
- onChange: U,
73
- children: [
74
- /* @__PURE__ */ S(m, { children: P.auth.password }),
75
- /* @__PURE__ */ S(p, {
76
- placeholder: P.auth.passwordPlaceholder,
77
- variant: O === "transparent" ? "primary" : "secondary",
78
- required: !0
79
- }),
80
- /* @__PURE__ */ S(d, {})
81
- ]
82
- }),
83
- N?.rememberMe && /* @__PURE__ */ C(l, {
84
- name: "rememberMe",
85
- isDisabled: J,
86
- variant: O === "transparent" ? "primary" : "secondary",
87
- children: [/* @__PURE__ */ S(l.Control, { children: /* @__PURE__ */ S(l.Indicator, {}) }), /* @__PURE__ */ S(l.Content, { children: /* @__PURE__ */ S(m, { children: P.auth.rememberMe }) })]
88
- }),
89
- Y && /* @__PURE__ */ S("div", {
90
- className: "flex justify-center",
91
- children: Y
92
- }),
93
- /* @__PURE__ */ C("div", {
94
- className: "flex flex-col gap-3",
95
- children: [/* @__PURE__ */ C(s, {
96
- type: "submit",
97
- className: "w-full",
98
- isPending: J,
99
- children: [K && /* @__PURE__ */ S(g, {
100
- color: "current",
101
- size: "sm"
102
- }), P.auth.signIn]
103
- }), F.flatMap((e) => e.authButtons?.map((t, n) => /* @__PURE__ */ S(t, { view: "signIn" }, `${e.id}-${n.toString()}`)))]
104
- })
105
- ]
106
- }),
107
- D === "bottom" && /* @__PURE__ */ C(x, { children: [X && /* @__PURE__ */ S(e, { children: P.auth.or }), !!L?.length && /* @__PURE__ */ S(t, { socialLayout: E })] })
108
- ]
109
- }),
110
- /* @__PURE__ */ C(c.Footer, {
111
- className: "flex-col gap-3",
112
- children: [N?.forgotPassword && /* @__PURE__ */ S(h, {
113
- href: `${j.auth}/${R.auth.forgotPassword}`,
114
- className: "no-underline hover:underline",
115
- children: P.auth.forgotPasswordLink
116
- }), N?.enabled && /* @__PURE__ */ C(u, {
117
- className: "text-sm",
118
- children: [
119
- P.auth.needToCreateAnAccount,
120
- " ",
121
- /* @__PURE__ */ S(h, {
122
- href: `${j.auth}/${R.auth.signUp}`,
123
- className: "text-accent no-underline hover:underline decoration-accent-hover",
124
- children: P.auth.signUp
125
- })
126
- ]
127
- })]
128
- })
129
- ]
130
- });
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, useFetchOptions, useSendVerificationEmail, useSignInEmail } from "@better-auth-ui/react";
4
+ import { Button, Card, Checkbox, 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 { FieldSeparator } from "./field-separator";
8
+ import { ProviderButtons } from "./provider-buttons";
9
+ /**
10
+ * Render the sign-in UI using auth context for configuration and localization.
11
+ *
12
+ * @returns The sign-in JSX element containing email/password fields, optional magic-link button, and social provider buttons.
13
+ */
14
+ export function SignIn({ className, socialLayout, socialPosition = "bottom", variant, ...props }) {
15
+ const { authClient, basePaths, baseURL, emailAndPassword, localization, plugins, redirectTo, socialProviders, viewPaths, navigate } = useAuth();
16
+ const { fetchOptions, resetFetchOptions } = useFetchOptions();
17
+ const [password, setPassword] = useState("");
18
+ const { mutate: sendVerificationEmail } = useSendVerificationEmail(authClient, {
19
+ onSuccess: () => toast.success(localization.auth.verificationEmailSent)
20
+ });
21
+ const { mutate: signInEmail, isPending: signInEmailPending } = useSignInEmail(authClient, {
22
+ onError: (error, { email }) => {
23
+ setPassword("");
24
+ if (error.error?.code === "EMAIL_NOT_VERIFIED") {
25
+ toast.danger(error.error?.message || error.message, {
26
+ actionProps: {
27
+ children: localization.auth.resend,
28
+ onClick: () => sendVerificationEmail({
29
+ email,
30
+ callbackURL: `${baseURL}${redirectTo}`
31
+ })
32
+ }
33
+ });
34
+ }
35
+ else {
36
+ toast.danger(error.error?.message || error.message);
37
+ }
38
+ resetFetchOptions();
39
+ },
40
+ onSuccess: () => navigate({ to: redirectTo })
41
+ });
42
+ const handleSubmit = (e) => {
43
+ e.preventDefault();
44
+ const formData = new FormData(e.currentTarget);
45
+ const email = formData.get("email");
46
+ const rememberMe = formData.get("rememberMe") === "on";
47
+ signInEmail({
48
+ email,
49
+ password,
50
+ ...(emailAndPassword?.rememberMe ? { rememberMe } : {}),
51
+ fetchOptions
52
+ });
53
+ };
54
+ const signInMutating = useIsMutating({
55
+ mutationKey: authMutationKeys.signIn.all
56
+ });
57
+ const signUpMutating = useIsMutating({
58
+ mutationKey: authMutationKeys.signUp.all
59
+ });
60
+ const isPending = signInMutating + signUpMutating > 0;
61
+ const Captcha = plugins.find((plugin) => plugin.captchaComponent)?.captchaComponent;
62
+ const showSeparator = emailAndPassword?.enabled && !!socialProviders?.length;
63
+ 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 }))] })), emailAndPassword?.enabled && (_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, variant: variant === "transparent" ? "primary" : "secondary", required: true }), _jsx(FieldError, {})] }), _jsxs(TextField, { minLength: emailAndPassword?.minPasswordLength, maxLength: emailAndPassword?.maxPasswordLength, name: "password", type: "password", autoComplete: "current-password", isDisabled: isPending, value: password, onChange: setPassword, children: [_jsx(Label, { children: localization.auth.password }), _jsx(Input, { placeholder: localization.auth.passwordPlaceholder, variant: variant === "transparent" ? "primary" : "secondary", required: true }), _jsx(FieldError, {})] }), emailAndPassword?.rememberMe && (_jsxs(Checkbox, { name: "rememberMe", isDisabled: isPending, variant: variant === "transparent" ? "primary" : "secondary", children: [_jsx(Checkbox.Control, { children: _jsx(Checkbox.Indicator, {}) }), _jsx(Checkbox.Content, { children: _jsx(Label, { children: localization.auth.rememberMe }) })] })), Captcha && _jsx("div", { className: "flex justify-center", children: Captcha }), _jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs(Button, { type: "submit", className: "w-full", isPending: isPending, children: [signInEmailPending && _jsx(Spinner, { color: "current", size: "sm" }), localization.auth.signIn] }), plugins.flatMap((plugin) => plugin.authButtons?.map((AuthButton, index) => (_jsx(AuthButton, { view: "signIn" }, `${plugin.id}-${index.toString()}`))))] })] })), socialPosition === "bottom" && (_jsxs(_Fragment, { children: [showSeparator && (_jsx(FieldSeparator, { children: localization.auth.or })), !!socialProviders?.length && (_jsx(ProviderButtons, { socialLayout: socialLayout }))] }))] }), _jsxs(Card.Footer, { className: "flex-col gap-3", children: [emailAndPassword?.forgotPassword && (_jsx(Link, { href: `${basePaths.auth}/${viewPaths.auth.forgotPassword}`, className: "no-underline hover:underline", children: localization.auth.forgotPasswordLink })), emailAndPassword?.enabled && (_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 })] }))] })] }));
131
64
  }
132
- //#endregion
133
- export { T as SignIn };
@@ -1,27 +1,33 @@
1
- import { useAuth as e, useSignOut as t } from "@better-auth-ui/react";
2
- import { Spinner as n, cn as r, toast as i } from "@heroui/react";
3
- import { useEffect as a, useRef as o } from "react";
4
- import { jsx as s } from "react/jsx-runtime";
5
- //#region src/components/auth/sign-out.tsx
6
- function c({ className: c }) {
7
- let { authClient: l, basePaths: u, navigate: d, viewPaths: f } = e(), { mutate: p } = t(l, {
8
- onError: (e) => {
9
- i.danger(e.error?.message || e.message), d({
10
- to: `${u.auth}/${f.auth.signIn}`,
11
- replace: !0
12
- });
13
- },
14
- onSuccess: () => d({
15
- to: `${u.auth}/${f.auth.signIn}`,
16
- replace: !0
17
- })
18
- }), m = o(!1);
19
- return a(() => {
20
- m.current || (m.current = !0, p());
21
- }, [p]), /* @__PURE__ */ s(n, {
22
- className: r("mx-auto my-auto", c),
23
- color: "current"
24
- });
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useAuth, useSignOut } from "@better-auth-ui/react";
3
+ import { cn, Spinner, toast } from "@heroui/react";
4
+ import { useEffect, useRef } from "react";
5
+ /**
6
+ * Initiates sign-out on mount and renders a loading card while sign-out proceeds.
7
+ *
8
+ * @returns A Card containing a centered Spinner shown during the sign-out process
9
+ */
10
+ export function SignOut({ className }) {
11
+ const { authClient, basePaths, navigate, viewPaths } = useAuth();
12
+ const { mutate: signOut } = useSignOut(authClient, {
13
+ onError: (error) => {
14
+ toast.danger(error.error?.message || error.message);
15
+ navigate({
16
+ to: `${basePaths.auth}/${viewPaths.auth.signIn}`,
17
+ replace: true
18
+ });
19
+ },
20
+ onSuccess: () => navigate({
21
+ to: `${basePaths.auth}/${viewPaths.auth.signIn}`,
22
+ replace: true
23
+ })
24
+ });
25
+ const hasSignedOut = useRef(false);
26
+ useEffect(() => {
27
+ if (hasSignedOut.current)
28
+ return;
29
+ hasSignedOut.current = true;
30
+ signOut();
31
+ }, [signOut]);
32
+ return (_jsx(Spinner, { className: cn("mx-auto my-auto", className), color: "current" }));
25
33
  }
26
- //#endregion
27
- export { c as SignOut };
@@ -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 SignUpProps = {
4
4
  className?: string;
5
5
  socialLayout?: SocialLayout;