@better-auth-ui/heroui 1.6.2 → 1.6.4

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 (213) hide show
  1. package/dist/components/auth/additional-field.d.ts +4 -0
  2. package/dist/components/auth/additional-field.js +270 -0
  3. package/dist/components/auth/auth-provider.d.ts +4 -6
  4. package/dist/components/auth/auth-provider.js +12 -11
  5. package/dist/components/auth/auth.d.ts +1 -1
  6. package/dist/components/auth/auth.js +54 -28
  7. package/dist/components/{settings/security → auth/delete-user}/danger-zone.d.ts +3 -4
  8. package/dist/components/{settings/security → auth/delete-user}/danger-zone.js +1 -1
  9. package/dist/components/{settings/security → auth/delete-user}/delete-user.d.ts +1 -1
  10. package/dist/components/auth/delete-user/delete-user.js +95 -0
  11. package/dist/components/{email → auth/email}/email-changed-email.d.ts +2 -2
  12. package/dist/components/{email → auth/email}/email-changed-email.js +7 -7
  13. package/dist/components/{email → auth/email}/email-verification-email.d.ts +2 -2
  14. package/dist/components/{email → auth/email}/email-verification-email.js +7 -7
  15. package/dist/components/auth/email/magic-link-email.d.ts +3 -0
  16. package/dist/components/{email → auth/email}/magic-link-email.js +7 -7
  17. package/dist/components/auth/email/new-device-email.d.ts +3 -0
  18. package/dist/components/{email → auth/email}/new-device-email.js +7 -7
  19. package/dist/components/auth/email/otp-email.d.ts +3 -0
  20. package/dist/components/{email → auth/email}/otp-email.js +6 -6
  21. package/dist/components/{email → auth/email}/password-changed-email.d.ts +2 -2
  22. package/dist/components/{email → auth/email}/password-changed-email.js +7 -7
  23. package/dist/components/{email → auth/email}/reset-password-email.d.ts +2 -2
  24. package/dist/components/{email → auth/email}/reset-password-email.js +7 -7
  25. package/dist/components/auth/error-toaster.d.ts +1 -0
  26. package/dist/components/auth/error-toaster.js +17 -0
  27. package/dist/components/auth/forgot-password.d.ts +2 -2
  28. package/dist/components/auth/forgot-password.js +42 -42
  29. package/dist/components/auth/magic-link/magic-link-button.d.ts +11 -0
  30. package/dist/components/auth/magic-link/magic-link-button.js +20 -0
  31. package/dist/components/auth/magic-link/magic-link.d.ts +16 -0
  32. package/dist/components/auth/magic-link/magic-link.js +87 -0
  33. package/dist/components/{settings/account → auth/multi-session}/manage-account.d.ts +2 -6
  34. package/dist/components/auth/multi-session/manage-account.js +49 -0
  35. package/dist/components/{settings/account → auth/multi-session}/manage-accounts.d.ts +1 -1
  36. package/dist/components/auth/multi-session/manage-accounts.js +34 -0
  37. package/dist/components/{user/switch-account-menu.d.ts → auth/multi-session/switch-account-submenu-content.d.ts} +3 -3
  38. package/dist/components/auth/multi-session/switch-account-submenu-content.js +29 -0
  39. package/dist/components/{user/switch-account-item.d.ts → auth/multi-session/switch-account-submenu-item.d.ts} +2 -2
  40. package/dist/components/auth/multi-session/switch-account-submenu-item.js +20 -0
  41. package/dist/components/auth/multi-session/switch-account-submenu.d.ts +13 -0
  42. package/dist/components/auth/multi-session/switch-account-submenu.js +24 -0
  43. package/dist/components/auth/passkey/passkey-button.d.ts +6 -0
  44. package/dist/components/auth/passkey/passkey-button.js +24 -0
  45. package/dist/components/auth/passkey/passkey.js +45 -0
  46. package/dist/components/{settings/security → auth/passkey}/passkeys.d.ts +1 -1
  47. package/dist/components/auth/passkey/passkeys.js +106 -0
  48. package/dist/components/auth/provider-button.d.ts +13 -0
  49. package/dist/components/auth/provider-button.js +25 -0
  50. package/dist/components/auth/provider-buttons.d.ts +3 -10
  51. package/dist/components/auth/provider-buttons.js +14 -22
  52. package/dist/components/auth/reset-password.d.ts +1 -1
  53. package/dist/components/auth/reset-password.js +110 -110
  54. package/dist/components/{settings → auth/settings}/account/account-settings.d.ts +5 -2
  55. package/dist/components/auth/settings/account/account-settings.js +20 -0
  56. package/dist/components/auth/settings/account/change-avatar.js +89 -0
  57. package/dist/components/{settings → auth/settings}/account/change-email.d.ts +1 -1
  58. package/dist/components/{settings → auth/settings}/account/change-email.js +17 -20
  59. package/dist/components/{settings → auth/settings}/account/user-profile.d.ts +3 -4
  60. package/dist/components/auth/settings/account/user-profile.js +86 -0
  61. package/dist/components/auth/settings/security/active-session.js +59 -0
  62. package/dist/components/{settings → auth/settings}/security/active-sessions.d.ts +1 -1
  63. package/dist/components/auth/settings/security/active-sessions.js +34 -0
  64. package/dist/components/{settings → auth/settings}/security/change-password.d.ts +1 -1
  65. package/dist/components/auth/settings/security/change-password.js +189 -0
  66. package/dist/components/auth/settings/security/linked-account.js +56 -0
  67. package/dist/components/{settings → auth/settings}/security/linked-accounts.d.ts +1 -1
  68. package/dist/components/auth/settings/security/linked-accounts.js +45 -0
  69. package/dist/components/{settings → auth/settings}/security/security-settings.d.ts +1 -1
  70. package/dist/components/auth/settings/security/security-settings.js +22 -0
  71. package/dist/components/auth/settings/settings.js +45 -0
  72. package/dist/components/auth/sign-in.d.ts +1 -1
  73. package/dist/components/auth/sign-in.js +64 -100
  74. package/dist/components/auth/sign-out.js +11 -11
  75. package/dist/components/auth/sign-up.d.ts +1 -1
  76. package/dist/components/auth/sign-up.js +123 -157
  77. package/dist/components/{settings/account → auth/theme}/appearance.d.ts +3 -6
  78. package/dist/components/auth/theme/appearance.js +72 -0
  79. package/dist/components/auth/theme/theme-toggle-item.d.ts +5 -0
  80. package/dist/components/auth/theme/theme-toggle-item.js +58 -0
  81. package/dist/components/auth/user/user-avatar.js +29 -0
  82. package/dist/components/{user → auth/user}/user-button.d.ts +2 -6
  83. package/dist/components/auth/user/user-button.js +55 -0
  84. package/dist/components/auth/user/user-view.js +37 -0
  85. package/dist/components/auth/username/sign-in-username.d.ts +14 -0
  86. package/dist/components/auth/username/sign-in-username.js +142 -0
  87. package/dist/components/auth/username/username-field.d.ts +8 -0
  88. package/dist/components/auth/username/username-field.js +51 -0
  89. package/dist/email.d.ts +7 -0
  90. package/dist/email.js +9 -0
  91. package/dist/index.d.ts +13 -27
  92. package/dist/index.js +22 -36
  93. package/dist/lib/auth/auth-plugin.d.ts +44 -0
  94. package/dist/lib/auth/delete-user-plugin.d.ts +17 -0
  95. package/dist/lib/auth/delete-user-plugin.js +10 -0
  96. package/dist/lib/auth/magic-link-plugin.d.ts +31 -0
  97. package/dist/lib/auth/magic-link-plugin.js +13 -0
  98. package/dist/lib/auth/multi-session-plugin.d.ts +18 -0
  99. package/dist/lib/auth/multi-session-plugin.js +12 -0
  100. package/dist/lib/auth/passkey-plugin.d.ts +20 -0
  101. package/dist/lib/auth/passkey-plugin.js +12 -0
  102. package/dist/lib/auth/theme-plugin.d.ts +68 -0
  103. package/dist/lib/auth/theme-plugin.js +23 -0
  104. package/dist/lib/auth/username-plugin.d.ts +63 -0
  105. package/dist/lib/auth/username-plugin.js +18 -0
  106. package/dist/plugins.d.ts +20 -0
  107. package/dist/plugins.js +21 -0
  108. package/package.json +22 -22
  109. package/src/components/auth/additional-field.tsx +554 -0
  110. package/src/components/auth/auth-provider.tsx +8 -5
  111. package/src/components/auth/auth.tsx +100 -36
  112. package/src/components/{settings/security → auth/delete-user}/danger-zone.tsx +3 -10
  113. package/src/components/{settings/security → auth/delete-user}/delete-user.tsx +31 -24
  114. package/src/components/{email → auth/email}/email-changed-email.tsx +2 -2
  115. package/src/components/{email → auth/email}/email-verification-email.tsx +2 -2
  116. package/src/components/{email → auth/email}/magic-link-email.tsx +2 -2
  117. package/src/components/{email → auth/email}/new-device-email.tsx +2 -2
  118. package/src/components/{email → auth/email}/otp-email.tsx +2 -2
  119. package/src/components/{email → auth/email}/password-changed-email.tsx +2 -2
  120. package/src/components/{email → auth/email}/reset-password-email.tsx +2 -2
  121. package/src/components/auth/error-toaster.tsx +25 -0
  122. package/src/components/auth/forgot-password.tsx +15 -13
  123. package/src/components/auth/magic-link/magic-link-button.tsx +61 -0
  124. package/src/components/auth/{magic-link.tsx → magic-link/magic-link.tsx} +52 -57
  125. package/src/components/{settings/account → auth/multi-session}/manage-account.tsx +15 -15
  126. package/src/components/{settings/account → auth/multi-session}/manage-accounts.tsx +16 -12
  127. package/src/components/{user/switch-account-menu.tsx → auth/multi-session/switch-account-submenu-content.tsx} +19 -17
  128. package/src/components/{user/switch-account-item.tsx → auth/multi-session/switch-account-submenu-item.tsx} +18 -8
  129. package/src/components/auth/multi-session/switch-account-submenu.tsx +50 -0
  130. package/src/components/auth/passkey/passkey-button.tsx +56 -0
  131. package/src/components/{settings/security → auth/passkey}/passkey.tsx +21 -9
  132. package/src/components/auth/passkey/passkeys.tsx +196 -0
  133. package/src/components/auth/provider-button.tsx +65 -0
  134. package/src/components/auth/provider-buttons.tsx +23 -45
  135. package/src/components/auth/reset-password.tsx +14 -9
  136. package/src/components/{settings → auth/settings}/account/account-settings.tsx +15 -13
  137. package/src/components/{settings → auth/settings}/account/change-avatar.tsx +4 -5
  138. package/src/components/{settings → auth/settings}/account/change-email.tsx +5 -6
  139. package/src/components/auth/settings/account/user-profile.tsx +171 -0
  140. package/src/components/{settings → auth/settings}/security/active-session.tsx +8 -6
  141. package/src/components/{settings → auth/settings}/security/active-sessions.tsx +5 -10
  142. package/src/components/{settings → auth/settings}/security/change-password.tsx +22 -14
  143. package/src/components/{settings → auth/settings}/security/linked-account.tsx +10 -16
  144. package/src/components/{settings → auth/settings}/security/linked-accounts.tsx +4 -9
  145. package/src/components/{settings → auth/settings}/security/security-settings.tsx +7 -6
  146. package/src/components/{settings → auth/settings}/settings.tsx +2 -2
  147. package/src/components/auth/sign-in.tsx +39 -80
  148. package/src/components/auth/sign-out.tsx +2 -2
  149. package/src/components/auth/sign-up.tsx +110 -147
  150. package/src/components/{settings/account → auth/theme}/appearance.tsx +18 -25
  151. package/src/components/auth/theme/theme-toggle-item.tsx +110 -0
  152. package/src/components/{user → auth/user}/user-avatar.tsx +12 -4
  153. package/src/components/{user → auth/user}/user-button.tsx +15 -88
  154. package/src/components/{user → auth/user}/user-view.tsx +12 -4
  155. package/src/components/auth/username/sign-in-username.tsx +283 -0
  156. package/src/components/auth/username/username-field.tsx +122 -0
  157. package/src/email.ts +9 -0
  158. package/src/index.tsx +13 -27
  159. package/src/lib/auth/auth-plugin.ts +67 -0
  160. package/src/lib/auth/delete-user-plugin.ts +15 -0
  161. package/src/lib/auth/magic-link-plugin.ts +26 -0
  162. package/src/lib/auth/multi-session-plugin.ts +17 -0
  163. package/src/lib/auth/passkey-plugin.ts +17 -0
  164. package/src/lib/auth/theme-plugin.ts +86 -0
  165. package/src/lib/auth/username-plugin.tsx +30 -0
  166. package/src/plugins.ts +23 -0
  167. package/dist/components/auth/magic-link-button.d.ts +0 -13
  168. package/dist/components/auth/magic-link-button.js +0 -16
  169. package/dist/components/auth/magic-link.d.ts +0 -17
  170. package/dist/components/auth/magic-link.js +0 -111
  171. package/dist/components/auth/passkey-button.d.ts +0 -4
  172. package/dist/components/auth/passkey-button.js +0 -24
  173. package/dist/components/email/magic-link-email.d.ts +0 -3
  174. package/dist/components/email/new-device-email.d.ts +0 -3
  175. package/dist/components/email/otp-email.d.ts +0 -3
  176. package/dist/components/settings/account/account-settings.js +0 -23
  177. package/dist/components/settings/account/appearance.js +0 -71
  178. package/dist/components/settings/account/change-avatar.js +0 -89
  179. package/dist/components/settings/account/manage-account.js +0 -51
  180. package/dist/components/settings/account/manage-accounts.js +0 -33
  181. package/dist/components/settings/account/user-profile.js +0 -106
  182. package/dist/components/settings/security/active-session.js +0 -62
  183. package/dist/components/settings/security/active-sessions.js +0 -34
  184. package/dist/components/settings/security/change-password.js +0 -192
  185. package/dist/components/settings/security/delete-user.js +0 -97
  186. package/dist/components/settings/security/linked-account.js +0 -62
  187. package/dist/components/settings/security/linked-accounts.js +0 -45
  188. package/dist/components/settings/security/passkey.js +0 -43
  189. package/dist/components/settings/security/passkeys.js +0 -53
  190. package/dist/components/settings/security/security-settings.js +0 -25
  191. package/dist/components/settings/settings.js +0 -45
  192. package/dist/components/user/switch-account-item.js +0 -20
  193. package/dist/components/user/switch-account-menu.js +0 -28
  194. package/dist/components/user/user-avatar.js +0 -29
  195. package/dist/components/user/user-button.js +0 -91
  196. package/dist/components/user/user-view.js +0 -37
  197. package/dist/core.d.ts +0 -1
  198. package/dist/core.js +0 -1
  199. package/dist/react-exports.d.ts +0 -1
  200. package/dist/react-exports.js +0 -1
  201. package/src/components/auth/magic-link-button.tsx +0 -43
  202. package/src/components/auth/passkey-button.tsx +0 -36
  203. package/src/components/settings/account/user-profile.tsx +0 -218
  204. package/src/components/settings/security/passkeys.tsx +0 -104
  205. package/src/core.ts +0 -1
  206. package/src/react-exports.ts +0 -1
  207. /package/dist/components/{settings/security → auth/passkey}/passkey.d.ts +0 -0
  208. /package/dist/components/{settings → auth/settings}/account/change-avatar.d.ts +0 -0
  209. /package/dist/components/{settings → auth/settings}/security/active-session.d.ts +0 -0
  210. /package/dist/components/{settings → auth/settings}/security/linked-account.d.ts +0 -0
  211. /package/dist/components/{settings → auth/settings}/settings.d.ts +0 -0
  212. /package/dist/components/{user → auth/user}/user-avatar.d.ts +0 -0
  213. /package/dist/components/{user → auth/user}/user-view.d.ts +0 -0
@@ -0,0 +1,45 @@
1
+ import { LinkedAccount as e } from "./linked-account.js";
2
+ import { useAuth as t, useListAccounts as n } from "@better-auth-ui/react";
3
+ import { Card as r, Skeleton as i, cn as a } from "@heroui/react";
4
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
5
+ //#region src/components/auth/settings/security/linked-accounts.tsx
6
+ function c({ className: i, variant: c, ...u }) {
7
+ let { authClient: d, localization: f, socialProviders: p } = t(), { data: m, isPending: h } = n(d), g = [...(m?.filter((e) => e.providerId !== "credential"))?.map((e) => ({
8
+ key: e.id,
9
+ account: e,
10
+ provider: e.providerId
11
+ })) ?? [], ...p?.map((e) => ({
12
+ key: e,
13
+ account: void 0,
14
+ provider: e
15
+ })) ?? []];
16
+ return /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("h2", {
17
+ className: a("text-sm font-semibold mb-3"),
18
+ children: f.settings.linkedAccounts
19
+ }), /* @__PURE__ */ o(r, {
20
+ className: a(i),
21
+ variant: c,
22
+ ...u,
23
+ children: /* @__PURE__ */ o(r.Content, {
24
+ className: "gap-0",
25
+ children: h ? p?.map((e, t) => /* @__PURE__ */ s("div", { children: [t > 0 && /* @__PURE__ */ o("div", { className: "border-b border-dashed -mx-4 md:-mx-6 my-4" }), /* @__PURE__ */ o(l, {})] }, e)) : g.map((t, n) => /* @__PURE__ */ s("div", { children: [n > 0 && /* @__PURE__ */ o("div", { className: "border-b border-dashed -mx-4 md:-mx-6 my-4" }), /* @__PURE__ */ o(e, {
26
+ account: t.account,
27
+ provider: t.provider
28
+ })] }, t.key))
29
+ })
30
+ })] });
31
+ }
32
+ function l() {
33
+ return /* @__PURE__ */ o("div", {
34
+ className: "flex items-center justify-between",
35
+ children: /* @__PURE__ */ s("div", {
36
+ className: "flex items-center gap-3",
37
+ children: [/* @__PURE__ */ o(i, { className: "size-10 rounded-xl" }), /* @__PURE__ */ s("div", {
38
+ className: "flex flex-col gap-1",
39
+ children: [/* @__PURE__ */ o(i, { className: "h-4 w-20 rounded-lg" }), /* @__PURE__ */ o(i, { className: "h-3 w-32 rounded-lg" })]
40
+ })]
41
+ })
42
+ });
43
+ }
44
+ //#endregion
45
+ export { c as LinkedAccounts };
@@ -8,7 +8,7 @@ export type SecuritySettingsProps = {
8
8
  * Renders the security settings layout including password management, linked accounts, and active sessions.
9
9
  *
10
10
  * ChangePassword is rendered when password authentication is enabled; LinkedAccounts is rendered when social providers are present.
11
- * DangerZone is rendered when `deleteUser.enabled` is true in auth config.
11
+ * Each registered auth plugin may contribute `securityCards` (for example delete-user, passkeys).
12
12
  *
13
13
  * @param className - Optional additional CSS class names for the outer container.
14
14
  * @param variant - Card variant forwarded to each security settings card.
@@ -0,0 +1,22 @@
1
+ import { ActiveSessions as e } from "./active-sessions.js";
2
+ import { ChangePassword as t } from "./change-password.js";
3
+ import { LinkedAccounts as n } from "./linked-accounts.js";
4
+ import { useAuth as r } from "@better-auth-ui/react";
5
+ import { cn as i } from "@heroui/react";
6
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
7
+ //#region src/components/auth/settings/security/security-settings.tsx
8
+ function s({ className: s, variant: c, ...l }) {
9
+ let { emailAndPassword: u, plugins: d, socialProviders: f } = r();
10
+ return /* @__PURE__ */ o("div", {
11
+ className: i("flex w-full flex-col gap-4 md:gap-6", s),
12
+ ...l,
13
+ children: [
14
+ u?.enabled && /* @__PURE__ */ a(t, { variant: c }),
15
+ !!f?.length && /* @__PURE__ */ a(n, { variant: c }),
16
+ /* @__PURE__ */ a(e, { variant: c }),
17
+ d.flatMap((e) => e.securityCards?.map((t, n) => /* @__PURE__ */ a(t, { variant: c }, `${e.id}-${n.toString()}`)))
18
+ ]
19
+ });
20
+ }
21
+ //#endregion
22
+ export { s as SecuritySettings };
@@ -0,0 +1,45 @@
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
+ });
43
+ }
44
+ //#endregion
45
+ export { l as Settings };
@@ -11,4 +11,4 @@ export interface SignInProps {
11
11
  *
12
12
  * @returns The sign-in JSX element containing email/password fields, optional magic-link button, and social provider buttons.
13
13
  */
14
- export declare function SignIn({ className, socialLayout, socialPosition, variant, ...props }: SignInProps & CardProps): import("react/jsx-runtime").JSX.Element;
14
+ export declare function SignIn({ className, socialLayout, socialPosition, variant, ...props }: SignInProps & Omit<CardProps, "children">): import("react/jsx-runtime").JSX.Element;
@@ -1,156 +1,120 @@
1
1
  import { FieldSeparator as e } from "./field-separator.js";
2
- import { MagicLinkButton as t } from "./magic-link-button.js";
3
- import { PasskeyButton as n } from "./passkey-button.js";
4
- import { ProviderButtons as r } from "./provider-buttons.js";
5
- import { useAuth as i, useSendVerificationEmail as a, useSignInEmail as o, useSignInSocial as s, useSignInUsername as c } from "@better-auth-ui/react";
6
- import { Button as ee, Card as l, Checkbox as u, Description as te, 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";
2
+ import { ProviderButtons as t } from "./provider-buttons.js";
3
+ import { authMutationKeys as n } from "@better-auth-ui/core";
4
+ import { useAuth as r, useSendVerificationEmail as i, useSignInEmail as a } from "@better-auth-ui/react";
5
+ import { Button as o, Card as s, Checkbox 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";
6
+ import { useState as y } from "react";
7
7
  import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
8
- import { useState as C } from "react";
8
+ import { useIsMutating as C } from "@tanstack/react-query";
9
9
  //#region src/components/auth/sign-in.tsx
10
- function w(e) {
11
- return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
12
- }
13
- function T({ className: T, socialLayout: E, socialPosition: D = "bottom", variant: O, ...k }) {
14
- let { basePaths: A, baseURL: j, emailAndPassword: M, localization: N, magicLink: P, passkey: F, redirectTo: I, socialProviders: L, username: R, viewPaths: z, navigate: B } = i(), [V, H] = C(""), { mutate: U } = a({
15
- onError: (e) => y.danger(e.error?.message || e.message),
16
- onSuccess: () => y.success(N.auth.verificationEmailSent)
17
- }), { mutate: W, isPending: G } = o({
10
+ function w({ className: w, socialLayout: T, socialPosition: E = "bottom", variant: D, ...O }) {
11
+ let { authClient: k, basePaths: A, baseURL: j, emailAndPassword: M, localization: N, plugins: P, redirectTo: F, socialProviders: I, viewPaths: L, navigate: R } = r(), [z, B] = y(""), { mutate: V } = i(k, { onSuccess: () => v.success(N.auth.verificationEmailSent) }), { mutate: H, isPending: U } = a(k, {
18
12
  onError: (e, { email: t }) => {
19
- H(""), e.error?.code === "EMAIL_NOT_VERIFIED" ? y.danger(e.error?.message || e.message, { actionProps: {
13
+ B(""), e.error?.code === "EMAIL_NOT_VERIFIED" ? v.danger(e.error?.message || e.message, { actionProps: {
20
14
  children: N.auth.resend,
21
- onClick: () => U({
15
+ onClick: () => V({
22
16
  email: t,
23
- callbackURL: `${j}${I}`
17
+ callbackURL: `${j}${F}`
24
18
  })
25
- } }) : y.danger(e.error?.message || e.message);
26
- },
27
- onSuccess: () => B({ to: I })
28
- }), { mutate: K, isPending: q } = c({
29
- onError: (e) => {
30
- H(""), y.danger(e.error?.message || e.message);
19
+ } }) : v.danger(e.error?.message || e.message);
31
20
  },
32
- onSuccess: () => B({ to: I })
33
- }), [J, Y] = C(!1), { mutate: X, isPending: Z } = s({
34
- onError: (e) => y.danger(e.error?.message || e.message),
35
- onSuccess: () => {
36
- Y(!0), setTimeout(() => {
37
- Y(!1);
38
- }, 5e3);
39
- }
40
- }), ne = (e) => {
21
+ onSuccess: () => R({ to: F })
22
+ }), W = (e) => {
41
23
  e.preventDefault();
42
24
  let t = new FormData(e.currentTarget), n = t.get("email"), r = t.get("rememberMe") === "on";
43
- R?.enabled && !w(n) ? K({
44
- username: n,
45
- password: V
46
- }) : W({
25
+ H({
47
26
  email: n,
48
- password: V,
27
+ password: z,
49
28
  ...M?.rememberMe ? { rememberMe: r } : {}
50
29
  });
51
- }, Q = G || q || Z || J, $ = M?.enabled && !!L?.length;
52
- return /* @__PURE__ */ S(l, {
53
- className: v("w-full max-w-sm gap-4 md:p-6", T),
54
- variant: O,
55
- ...k,
30
+ }, G = C({ mutationKey: n.signIn.all }) + C({ mutationKey: n.signUp.all }) > 0, K = M?.enabled && !!I?.length;
31
+ return /* @__PURE__ */ S(s, {
32
+ className: _("w-full max-w-sm gap-4 md:p-6", w),
33
+ variant: D,
34
+ ...O,
56
35
  children: [
57
- /* @__PURE__ */ x(l.Header, { children: /* @__PURE__ */ x(l.Title, {
36
+ /* @__PURE__ */ x(s.Header, { children: /* @__PURE__ */ x(s.Title, {
58
37
  className: "text-xl font-semibold mb-1",
59
38
  children: N.auth.signIn
60
39
  }) }),
61
- /* @__PURE__ */ S(l.Content, {
40
+ /* @__PURE__ */ S(s.Content, {
62
41
  className: "gap-4",
63
42
  children: [
64
- D === "top" && /* @__PURE__ */ S(b, { children: [!!L?.length && /* @__PURE__ */ x(r, {
65
- socialLayout: E,
66
- signInSocial: X,
67
- isPending: Q
68
- }), $ && /* @__PURE__ */ x(e, { children: N.auth.or })] }),
69
- M?.enabled && /* @__PURE__ */ S(f, {
70
- onSubmit: ne,
43
+ E === "top" && /* @__PURE__ */ S(b, { children: [!!I?.length && /* @__PURE__ */ x(t, { socialLayout: T }), K && /* @__PURE__ */ x(e, { children: N.auth.or })] }),
44
+ M?.enabled && /* @__PURE__ */ S(d, {
45
+ onSubmit: W,
71
46
  className: "flex flex-col gap-4",
72
47
  children: [
73
- /* @__PURE__ */ S(_, {
48
+ /* @__PURE__ */ S(g, {
74
49
  name: "email",
75
- type: R?.enabled ? "text" : "email",
76
- autoComplete: R?.enabled ? "username" : "email",
77
- isDisabled: Q,
50
+ type: "email",
51
+ autoComplete: "email",
52
+ isDisabled: G,
78
53
  children: [
79
- /* @__PURE__ */ x(m, { children: R?.enabled ? N.auth.username : N.auth.email }),
80
- /* @__PURE__ */ x(p, {
81
- placeholder: R?.enabled ? N.auth.usernameOrEmailPlaceholder : N.auth.emailPlaceholder,
82
- variant: O === "transparent" ? "primary" : "secondary",
54
+ /* @__PURE__ */ x(p, { children: N.auth.email }),
55
+ /* @__PURE__ */ x(f, {
56
+ placeholder: N.auth.emailPlaceholder,
57
+ variant: D === "transparent" ? "primary" : "secondary",
83
58
  required: !0
84
59
  }),
85
- /* @__PURE__ */ x(d, {})
60
+ /* @__PURE__ */ x(u, {})
86
61
  ]
87
62
  }),
88
- /* @__PURE__ */ S(_, {
63
+ /* @__PURE__ */ S(g, {
89
64
  minLength: M?.minPasswordLength,
90
65
  maxLength: M?.maxPasswordLength,
91
66
  name: "password",
92
67
  type: "password",
93
68
  autoComplete: "current-password",
94
- isDisabled: Q,
95
- value: V,
96
- onChange: H,
69
+ isDisabled: G,
70
+ value: z,
71
+ onChange: B,
97
72
  children: [
98
- /* @__PURE__ */ x(m, { children: N.auth.password }),
99
- /* @__PURE__ */ x(p, {
73
+ /* @__PURE__ */ x(p, { children: N.auth.password }),
74
+ /* @__PURE__ */ x(f, {
100
75
  placeholder: N.auth.passwordPlaceholder,
101
- variant: O === "transparent" ? "primary" : "secondary",
76
+ variant: D === "transparent" ? "primary" : "secondary",
102
77
  required: !0
103
78
  }),
104
- /* @__PURE__ */ x(d, {})
79
+ /* @__PURE__ */ x(u, {})
105
80
  ]
106
81
  }),
107
- M?.rememberMe && /* @__PURE__ */ S(u, {
82
+ M?.rememberMe && /* @__PURE__ */ S(c, {
108
83
  name: "rememberMe",
109
- isDisabled: Q,
110
- variant: O === "transparent" ? "primary" : "secondary",
111
- children: [/* @__PURE__ */ x(u.Control, { children: /* @__PURE__ */ x(u.Indicator, {}) }), /* @__PURE__ */ x(u.Content, { children: /* @__PURE__ */ x(m, { children: N.auth.rememberMe }) })]
84
+ isDisabled: G,
85
+ variant: D === "transparent" ? "primary" : "secondary",
86
+ children: [/* @__PURE__ */ x(c.Control, { children: /* @__PURE__ */ x(c.Indicator, {}) }), /* @__PURE__ */ x(c.Content, { children: /* @__PURE__ */ x(p, { children: N.auth.rememberMe }) })]
112
87
  }),
113
88
  /* @__PURE__ */ S("div", {
114
89
  className: "flex flex-col gap-3",
115
- children: [
116
- /* @__PURE__ */ S(ee, {
117
- type: "submit",
118
- className: "w-full",
119
- isPending: Q,
120
- children: [Q && /* @__PURE__ */ x(g, {
121
- color: "current",
122
- size: "sm"
123
- }), N.auth.signIn]
124
- }),
125
- P && /* @__PURE__ */ x(t, {
126
- view: "signIn",
127
- isPending: Q
128
- }),
129
- F && /* @__PURE__ */ x(n, { isPending: Q })
130
- ]
90
+ children: [/* @__PURE__ */ S(o, {
91
+ type: "submit",
92
+ className: "w-full",
93
+ isPending: G,
94
+ children: [U && /* @__PURE__ */ x(h, {
95
+ color: "current",
96
+ size: "sm"
97
+ }), N.auth.signIn]
98
+ }), P.flatMap((e) => e.authButtons?.map((t, n) => /* @__PURE__ */ x(t, { view: "signIn" }, `${e.id}-${n.toString()}`)))]
131
99
  })
132
100
  ]
133
101
  }),
134
- D === "bottom" && /* @__PURE__ */ S(b, { children: [$ && /* @__PURE__ */ x(e, { children: N.auth.or }), !!L?.length && /* @__PURE__ */ x(r, {
135
- socialLayout: E,
136
- signInSocial: X,
137
- isPending: Q
138
- })] })
102
+ E === "bottom" && /* @__PURE__ */ S(b, { children: [K && /* @__PURE__ */ x(e, { children: N.auth.or }), !!I?.length && /* @__PURE__ */ x(t, { socialLayout: T })] })
139
103
  ]
140
104
  }),
141
- /* @__PURE__ */ S(l.Footer, {
105
+ /* @__PURE__ */ S(s.Footer, {
142
106
  className: "flex-col gap-3",
143
- children: [M?.forgotPassword && /* @__PURE__ */ x(h, {
144
- href: `${A.auth}/${z.auth.forgotPassword}`,
107
+ children: [M?.forgotPassword && /* @__PURE__ */ x(m, {
108
+ href: `${A.auth}/${L.auth.forgotPassword}`,
145
109
  className: "no-underline hover:underline",
146
110
  children: N.auth.forgotPasswordLink
147
- }), M?.enabled && /* @__PURE__ */ S(te, {
111
+ }), M?.enabled && /* @__PURE__ */ S(l, {
148
112
  className: "text-sm",
149
113
  children: [
150
114
  N.auth.needToCreateAnAccount,
151
115
  " ",
152
- /* @__PURE__ */ x(h, {
153
- href: `${A.auth}/${z.auth.signUp}`,
116
+ /* @__PURE__ */ x(m, {
117
+ href: `${A.auth}/${L.auth.signUp}`,
154
118
  className: "text-accent no-underline hover:underline decoration-accent-hover",
155
119
  children: N.auth.signUp
156
120
  })
@@ -161,4 +125,4 @@ function T({ className: T, socialLayout: E, socialPosition: D = "bottom", varian
161
125
  });
162
126
  }
163
127
  //#endregion
164
- export { T as SignIn };
128
+ export { w as SignIn };
@@ -1,24 +1,24 @@
1
1
  import { useAuth as e, useSignOut as t } from "@better-auth-ui/react";
2
2
  import { Spinner as n, cn as r, toast as i } from "@heroui/react";
3
- import { jsx as a } from "react/jsx-runtime";
4
- import { useEffect as o, useRef as s } from "react";
3
+ import { useEffect as a, useRef as o } from "react";
4
+ import { jsx as s } from "react/jsx-runtime";
5
5
  //#region src/components/auth/sign-out.tsx
6
6
  function c({ className: c }) {
7
- let { basePaths: l, navigate: u, viewPaths: d } = e(), { mutate: f } = t({
7
+ let { authClient: l, basePaths: u, navigate: d, viewPaths: f } = e(), { mutate: p } = t(l, {
8
8
  onError: (e) => {
9
- i.danger(e.error?.message || e.message), u({
10
- to: `${l.auth}/${d.auth.signIn}`,
9
+ i.danger(e.error?.message || e.message), d({
10
+ to: `${u.auth}/${f.auth.signIn}`,
11
11
  replace: !0
12
12
  });
13
13
  },
14
- onSuccess: () => u({
15
- to: `${l.auth}/${d.auth.signIn}`,
14
+ onSuccess: () => d({
15
+ to: `${u.auth}/${f.auth.signIn}`,
16
16
  replace: !0
17
17
  })
18
- }), p = s(!1);
19
- return o(() => {
20
- p.current || (p.current = !0, f());
21
- }, [f]), /* @__PURE__ */ a(n, {
18
+ }), m = o(!1);
19
+ return a(() => {
20
+ m.current || (m.current = !0, p());
21
+ }, [p]), /* @__PURE__ */ s(n, {
22
22
  className: r("mx-auto my-auto", c),
23
23
  color: "current"
24
24
  });
@@ -16,4 +16,4 @@ export type SignUpProps = {
16
16
  * @param socialPosition - Position of social provider buttons relative to the form; `"top"` or `"bottom"` (default `"bottom"`)
17
17
  * @returns The sign-up form React element
18
18
  */
19
- export declare function SignUp({ className, socialLayout, socialPosition, variant, ...props }: SignUpProps & CardProps): import("react/jsx-runtime").JSX.Element;
19
+ export declare function SignUp({ className, socialLayout, socialPosition, variant, ...props }: SignUpProps & Omit<CardProps, "children">): import("react/jsx-runtime").JSX.Element;