@better-auth-ui/heroui 1.6.0 → 1.6.2

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 (221) hide show
  1. package/dist/components/auth/auth-provider.d.ts +1 -1
  2. package/dist/components/auth/auth-provider.js +15 -11
  3. package/dist/components/auth/auth.d.ts +3 -3
  4. package/dist/components/auth/auth.js +36 -41
  5. package/dist/components/auth/field-separator.d.ts +1 -1
  6. package/dist/components/auth/field-separator.js +17 -4
  7. package/dist/components/auth/forgot-password.d.ts +1 -1
  8. package/dist/components/auth/forgot-password.js +69 -27
  9. package/dist/components/auth/magic-link-button.d.ts +1 -1
  10. package/dist/components/auth/magic-link-button.js +15 -18
  11. package/dist/components/auth/magic-link.d.ts +2 -2
  12. package/dist/components/auth/magic-link.js +110 -42
  13. package/dist/components/auth/passkey-button.d.ts +4 -0
  14. package/dist/components/auth/passkey-button.js +24 -0
  15. package/dist/components/auth/provider-buttons.d.ts +1 -1
  16. package/dist/components/auth/provider-buttons.js +26 -33
  17. package/dist/components/auth/reset-password.d.ts +1 -1
  18. package/dist/components/auth/reset-password.js +146 -57
  19. package/dist/components/auth/sign-in.d.ts +2 -2
  20. package/dist/components/auth/sign-in.js +163 -63
  21. package/dist/components/auth/sign-out.js +26 -32
  22. package/dist/components/auth/sign-up.d.ts +2 -2
  23. package/dist/components/auth/sign-up.js +240 -70
  24. package/dist/components/email/email-changed-email.d.ts +2 -2
  25. package/dist/components/email/email-changed-email.js +29 -22
  26. package/dist/components/email/email-verification-email.d.ts +2 -2
  27. package/dist/components/email/email-verification-email.js +29 -22
  28. package/dist/components/email/magic-link-email.d.ts +2 -2
  29. package/dist/components/email/magic-link-email.js +29 -22
  30. package/dist/components/email/new-device-email.d.ts +2 -2
  31. package/dist/components/email/new-device-email.js +29 -22
  32. package/dist/components/email/otp-email.d.ts +2 -2
  33. package/dist/components/email/otp-email.js +28 -21
  34. package/dist/components/email/password-changed-email.d.ts +2 -2
  35. package/dist/components/email/password-changed-email.js +29 -22
  36. package/dist/components/email/reset-password-email.d.ts +2 -2
  37. package/dist/components/email/reset-password-email.js +29 -22
  38. package/dist/components/settings/account/account-settings.d.ts +2 -2
  39. package/dist/components/settings/account/account-settings.js +22 -19
  40. package/dist/components/settings/account/appearance.d.ts +1 -1
  41. package/dist/components/settings/account/appearance.js +70 -27
  42. package/dist/components/settings/account/change-avatar.js +88 -55
  43. package/dist/components/settings/account/change-email.d.ts +1 -1
  44. package/dist/components/settings/account/change-email.js +56 -28
  45. package/dist/components/settings/account/manage-account.d.ts +1 -1
  46. package/dist/components/settings/account/manage-account.js +50 -31
  47. package/dist/components/settings/account/manage-accounts.d.ts +1 -1
  48. package/dist/components/settings/account/manage-accounts.js +32 -36
  49. package/dist/components/settings/account/user-profile.d.ts +3 -3
  50. package/dist/components/settings/account/user-profile.js +105 -22
  51. package/dist/components/settings/security/active-session.d.ts +1 -1
  52. package/dist/components/settings/security/active-session.js +60 -51
  53. package/dist/components/settings/security/active-sessions.d.ts +1 -1
  54. package/dist/components/settings/security/active-sessions.js +32 -26
  55. package/dist/components/settings/security/change-password.d.ts +1 -1
  56. package/dist/components/settings/security/change-password.js +189 -76
  57. package/dist/components/settings/security/danger-zone.d.ts +2 -2
  58. package/dist/components/settings/security/danger-zone.js +17 -11
  59. package/dist/components/settings/security/delete-user.d.ts +1 -1
  60. package/dist/components/settings/security/delete-user.js +96 -46
  61. package/dist/components/settings/security/linked-account.d.ts +1 -1
  62. package/dist/components/settings/security/linked-account.js +61 -47
  63. package/dist/components/settings/security/linked-accounts.d.ts +1 -1
  64. package/dist/components/settings/security/linked-accounts.js +43 -40
  65. package/dist/components/settings/security/passkey.d.ts +8 -0
  66. package/dist/components/settings/security/passkey.js +43 -0
  67. package/dist/components/settings/security/passkeys.d.ts +6 -0
  68. package/dist/components/settings/security/passkeys.js +53 -0
  69. package/dist/components/settings/security/security-settings.d.ts +2 -2
  70. package/dist/components/settings/security/security-settings.js +24 -20
  71. package/dist/components/settings/settings.d.ts +3 -3
  72. package/dist/components/settings/settings.js +44 -27
  73. package/dist/components/user/switch-account-item.d.ts +1 -1
  74. package/dist/components/user/switch-account-item.js +19 -15
  75. package/dist/components/user/switch-account-menu.js +27 -28
  76. package/dist/components/user/user-avatar.d.ts +3 -3
  77. package/dist/components/user/user-avatar.js +28 -30
  78. package/dist/components/user/user-button.d.ts +1 -1
  79. package/dist/components/user/user-button.js +90 -23
  80. package/dist/components/user/user-view.d.ts +3 -3
  81. package/dist/components/user/user-view.js +36 -23
  82. package/dist/core.d.ts +1 -1
  83. package/dist/index.d.ts +35 -33
  84. package/dist/index.js +36 -33
  85. package/dist/react-exports.d.ts +1 -1
  86. package/package.json +17 -10
  87. package/src/components/auth/auth.tsx +1 -1
  88. package/src/components/auth/magic-link.tsx +4 -0
  89. package/src/components/auth/passkey-button.tsx +36 -0
  90. package/src/components/auth/sign-in.tsx +67 -30
  91. package/src/components/auth/sign-up.tsx +97 -3
  92. package/src/components/settings/account/user-profile.tsx +121 -6
  93. package/src/components/settings/security/passkey.tsx +51 -0
  94. package/src/components/settings/security/passkeys.tsx +104 -0
  95. package/src/components/settings/security/security-settings.tsx +3 -1
  96. package/src/components/settings/settings.tsx +1 -1
  97. package/src/index.tsx +2 -0
  98. package/dist/components/account/account.d.ts +0 -18
  99. package/dist/components/account/account.js +0 -24
  100. package/dist/components/account/settings/account-settings.d.ts +0 -5
  101. package/dist/components/account/settings/account-settings.js +0 -6
  102. package/dist/components/account/settings/settings.d.ts +0 -5
  103. package/dist/components/account/settings/settings.js +0 -5
  104. package/dist/components/account/settings/user-profile.d.ts +0 -5
  105. package/dist/components/account/settings/user-profile.js +0 -20
  106. package/dist/components/settings/account/accounts.d.ts +0 -14
  107. package/dist/components/settings/account/accounts.js +0 -26
  108. package/dist/components/settings/account/theme-selector.d.ts +0 -16
  109. package/dist/components/settings/account/theme-selector.js +0 -33
  110. package/dist/components/settings/account/theme-settings.d.ts +0 -16
  111. package/dist/components/settings/account/theme-settings.js +0 -31
  112. package/dist/components/settings/account-settings.d.ts +0 -5
  113. package/dist/components/settings/account-settings.js +0 -6
  114. package/dist/components/settings/account.d.ts +0 -18
  115. package/dist/components/settings/account.js +0 -24
  116. package/dist/components/settings/security/connected-account.d.ts +0 -16
  117. package/dist/components/settings/security/connected-account.js +0 -46
  118. package/dist/components/settings/security/connected-accounts.d.ts +0 -15
  119. package/dist/components/settings/security/connected-accounts.js +0 -31
  120. package/dist/components/settings/security/sessions.d.ts +0 -14
  121. package/dist/components/settings/security/sessions.js +0 -40
  122. package/dist/components/settings/settings/account-settings.d.ts +0 -5
  123. package/dist/components/settings/settings/account-settings.js +0 -6
  124. package/dist/components/settings/settings/user-profile.d.ts +0 -5
  125. package/dist/components/settings/settings/user-profile.js +0 -20
  126. package/dist/components/settings/user-profile.d.ts +0 -5
  127. package/dist/components/settings/user-profile.js +0 -20
  128. package/dist/components/user/switch-account-popover.d.ts +0 -10
  129. package/dist/components/user/switch-account-popover.js +0 -25
  130. package/dist/components/user/switch-account-submenu.d.ts +0 -10
  131. package/dist/components/user/switch-account-submenu.js +0 -25
  132. package/dist/hooks/use-auth.d.ts +0 -2
  133. package/dist/hooks/use-auth.js +0 -8
  134. package/dist/hooks/use-redirect-to.d.ts +0 -8
  135. package/dist/hooks/use-redirect-to.js +0 -19
  136. package/dist/hooks/use-sign-in.d.ts +0 -8
  137. package/dist/hooks/use-sign-in.js +0 -53
  138. package/dist/lib/utils.d.ts +0 -2
  139. package/dist/lib/utils.js +0 -5
  140. package/dist/server.d.ts +0 -1
  141. package/dist/server.js +0 -1
  142. package/dist/src/components/auth/auth-provider.d.ts +0 -8
  143. package/dist/src/components/auth/auth-provider.js +0 -13
  144. package/dist/src/components/auth/auth.d.ts +0 -22
  145. package/dist/src/components/auth/auth.js +0 -42
  146. package/dist/src/components/auth/field-separator.d.ts +0 -4
  147. package/dist/src/components/auth/field-separator.js +0 -5
  148. package/dist/src/components/auth/forgot-password.d.ts +0 -15
  149. package/dist/src/components/auth/forgot-password.js +0 -29
  150. package/dist/src/components/auth/magic-link-button.d.ts +0 -13
  151. package/dist/src/components/auth/magic-link-button.js +0 -20
  152. package/dist/src/components/auth/magic-link.d.ts +0 -17
  153. package/dist/src/components/auth/magic-link.js +0 -37
  154. package/dist/src/components/auth/provider-buttons.d.ts +0 -19
  155. package/dist/src/components/auth/provider-buttons.js +0 -35
  156. package/dist/src/components/auth/reset-password.d.ts +0 -11
  157. package/dist/src/components/auth/reset-password.js +0 -59
  158. package/dist/src/components/auth/sign-in.d.ts +0 -14
  159. package/dist/src/components/auth/sign-in.js +0 -58
  160. package/dist/src/components/auth/sign-out.d.ts +0 -11
  161. package/dist/src/components/auth/sign-out.js +0 -34
  162. package/dist/src/components/auth/sign-up.d.ts +0 -19
  163. package/dist/src/components/auth/sign-up.js +0 -65
  164. package/dist/src/components/email/email-changed-email.d.ts +0 -3
  165. package/dist/src/components/email/email-changed-email.js +0 -23
  166. package/dist/src/components/email/email-verification-email.d.ts +0 -3
  167. package/dist/src/components/email/email-verification-email.js +0 -23
  168. package/dist/src/components/email/magic-link-email.d.ts +0 -3
  169. package/dist/src/components/email/magic-link-email.js +0 -23
  170. package/dist/src/components/email/new-device-email.d.ts +0 -3
  171. package/dist/src/components/email/new-device-email.js +0 -23
  172. package/dist/src/components/email/otp-email.d.ts +0 -3
  173. package/dist/src/components/email/otp-email.js +0 -22
  174. package/dist/src/components/email/password-changed-email.d.ts +0 -3
  175. package/dist/src/components/email/password-changed-email.js +0 -23
  176. package/dist/src/components/email/reset-password-email.d.ts +0 -3
  177. package/dist/src/components/email/reset-password-email.js +0 -23
  178. package/dist/src/components/settings/account/account-settings.d.ts +0 -13
  179. package/dist/src/components/settings/account/account-settings.js +0 -19
  180. package/dist/src/components/settings/account/appearance.d.ts +0 -16
  181. package/dist/src/components/settings/account/appearance.js +0 -28
  182. package/dist/src/components/settings/account/change-email.d.ts +0 -15
  183. package/dist/src/components/settings/account/change-email.js +0 -35
  184. package/dist/src/components/settings/account/manage-account.d.ts +0 -19
  185. package/dist/src/components/settings/account/manage-account.js +0 -27
  186. package/dist/src/components/settings/account/manage-accounts.d.ts +0 -14
  187. package/dist/src/components/settings/account/manage-accounts.js +0 -27
  188. package/dist/src/components/settings/account/user-profile.d.ts +0 -13
  189. package/dist/src/components/settings/account/user-profile.js +0 -29
  190. package/dist/src/components/settings/security/active-session.d.ts +0 -14
  191. package/dist/src/components/settings/security/active-session.js +0 -35
  192. package/dist/src/components/settings/security/active-sessions.d.ts +0 -14
  193. package/dist/src/components/settings/security/active-sessions.js +0 -29
  194. package/dist/src/components/settings/security/change-password.d.ts +0 -15
  195. package/dist/src/components/settings/security/change-password.js +0 -57
  196. package/dist/src/components/settings/security/linked-account.d.ts +0 -16
  197. package/dist/src/components/settings/security/linked-account.js +0 -46
  198. package/dist/src/components/settings/security/linked-accounts.d.ts +0 -15
  199. package/dist/src/components/settings/security/linked-accounts.js +0 -31
  200. package/dist/src/components/settings/security/security-settings.d.ts +0 -15
  201. package/dist/src/components/settings/security/security-settings.js +0 -18
  202. package/dist/src/components/settings/settings.d.ts +0 -29
  203. package/dist/src/components/settings/settings.js +0 -39
  204. package/dist/src/components/user/switch-account-item.d.ts +0 -16
  205. package/dist/src/components/user/switch-account-item.js +0 -14
  206. package/dist/src/components/user/switch-account-menu.d.ts +0 -10
  207. package/dist/src/components/user/switch-account-menu.js +0 -23
  208. package/dist/src/components/user/user-avatar.d.ts +0 -24
  209. package/dist/src/components/user/user-avatar.js +0 -31
  210. package/dist/src/components/user/user-button.d.ts +0 -21
  211. package/dist/src/components/user/user-button.js +0 -24
  212. package/dist/src/components/user/user-view.d.ts +0 -21
  213. package/dist/src/components/user/user-view.js +0 -24
  214. package/dist/src/core.d.ts +0 -1
  215. package/dist/src/core.js +0 -1
  216. package/dist/src/index.d.ts +0 -31
  217. package/dist/src/index.js +0 -32
  218. package/dist/src/lib/utils.d.ts +0 -2
  219. package/dist/src/lib/utils.js +0 -5
  220. package/dist/src/react-exports.d.ts +0 -1
  221. package/dist/src/react-exports.js +0 -1
@@ -1,58 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useAuth, useSendVerificationEmail, useSignInEmail, useSignInSocial } from "@better-auth-ui/react";
3
- import { Button, Card, Checkbox, Description, FieldError, Form, Input, Label, Link, Spinner, TextField, toast } from "@heroui/react";
4
- import { useState } from "react";
5
- import { cn } from "../../lib/utils";
6
- import { FieldSeparator } from "./field-separator";
7
- import { MagicLinkButton } from "./magic-link-button";
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 { basePaths, baseURL, emailAndPassword, localization, magicLink, navigate, redirectTo, socialProviders, viewPaths } = useAuth();
16
- const [password, setPassword] = useState("");
17
- const { mutate: sendVerificationEmail } = useSendVerificationEmail({
18
- onError: (error) => toast.danger(error.error?.message || error.message),
19
- onSuccess: () => toast.success(localization.auth.verificationEmailSent)
20
- });
21
- const { mutate: signInEmail, isPending: signInPending } = useSignInEmail({
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
- },
39
- onSuccess: () => navigate({ to: redirectTo })
40
- });
41
- const { mutate: signInSocial, isPending: socialPending } = useSignInSocial({
42
- onError: (error) => toast.danger(error.error?.message || error.message)
43
- });
44
- const handleSubmit = (e) => {
45
- e.preventDefault();
46
- const formData = new FormData(e.currentTarget);
47
- const email = formData.get("email");
48
- const rememberMe = formData.get("rememberMe") === "on";
49
- signInEmail({
50
- email,
51
- password,
52
- ...(emailAndPassword?.rememberMe ? { rememberMe } : {})
53
- });
54
- };
55
- const isPending = signInPending || socialPending;
56
- const showSeparator = emailAndPassword?.enabled && socialProviders && socialProviders.length > 0;
57
- return (_jsxs(Card, { className: cn("w-full max-w-sm p-4 md:p-6 gap-4", className), variant: variant, ...props, children: [_jsx(Card.Header, { children: _jsx(Card.Title, { className: "text-xl", children: localization.auth.signIn }) }), _jsxs(Card.Content, { className: "gap-4", children: [socialPosition === "top" && (_jsxs(_Fragment, { children: [socialProviders && socialProviders.length > 0 && (_jsx(ProviderButtons, { socialLayout: socialLayout, signInSocial: signInSocial, isPending: isPending })), 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, { className: "text-wrap" })] }), _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, { className: "text-wrap" })] }), 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 }) })] })), _jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs(Button, { type: "submit", className: "w-full", isPending: isPending, children: [isPending && _jsx(Spinner, { color: "current", size: "sm" }), localization.auth.signIn] }), magicLink && (_jsx(MagicLinkButton, { view: "signIn", isPending: isPending }))] })] })), socialPosition === "bottom" && (_jsxs(_Fragment, { children: [showSeparator && (_jsx(FieldSeparator, { children: localization.auth.or })), socialProviders && socialProviders.length > 0 && (_jsx(ProviderButtons, { socialLayout: socialLayout, signInSocial: signInSocial, isPending: isPending }))] }))] }), _jsxs(Card.Footer, { className: "flex-col gap-3", children: [emailAndPassword?.forgotPassword && (_jsx(Link, { href: `${basePaths.auth}/${viewPaths.auth.forgotPassword}`, className: "no-underline hover:underline self-center", children: localization.auth.forgotPasswordLink })), emailAndPassword?.enabled && (_jsxs(Description, { className: "justify-center 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 })] }))] })] }));
58
- }
@@ -1,11 +0,0 @@
1
- import { type CardProps } from "@heroui/react";
2
- export type SignOutProps = {
3
- className?: string;
4
- variant?: CardProps["variant"];
5
- };
6
- /**
7
- * Initiates sign-out on mount and renders a loading card while sign-out proceeds.
8
- *
9
- * @returns A Card containing a centered Spinner shown during the sign-out process
10
- */
11
- export declare function SignOut({ className, ...props }: SignOutProps & CardProps): import("react/jsx-runtime").JSX.Element;
@@ -1,34 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useAuth, useSignOut } from "@better-auth-ui/react";
3
- import { Card, Spinner, toast } from "@heroui/react";
4
- import { useEffect, useRef } from "react";
5
- import { cn } from "../../lib/utils";
6
- /**
7
- * Initiates sign-out on mount and renders a loading card while sign-out proceeds.
8
- *
9
- * @returns A Card containing a centered Spinner shown during the sign-out process
10
- */
11
- export function SignOut({ className, ...props }) {
12
- const { basePaths, navigate, viewPaths } = useAuth();
13
- const { mutate: signOut } = useSignOut({
14
- onError: (error) => {
15
- toast.danger(error.error?.message || error.message);
16
- navigate({
17
- to: `${basePaths.auth}/${viewPaths.auth.signIn}`,
18
- replace: true
19
- });
20
- },
21
- onSuccess: () => navigate({
22
- to: `${basePaths.auth}/${viewPaths.auth.signIn}`,
23
- replace: true
24
- })
25
- });
26
- const hasSignedOut = useRef(false);
27
- useEffect(() => {
28
- if (hasSignedOut.current)
29
- return;
30
- hasSignedOut.current = true;
31
- signOut();
32
- }, [signOut]);
33
- return (_jsx(Card, { variant: "transparent", className: cn("w-full max-w-sm", className), ...props, children: _jsx(Spinner, { className: "mx-auto my-auto", color: "current" }) }));
34
- }
@@ -1,19 +0,0 @@
1
- import { type CardProps } from "@heroui/react";
2
- import { type SocialLayout } from "./provider-buttons";
3
- export type SignUpProps = {
4
- className?: string;
5
- socialLayout?: SocialLayout;
6
- socialPosition?: "top" | "bottom";
7
- variant?: CardProps["variant"];
8
- };
9
- /**
10
- * Render a sign-up form with name, email, password (and optional confirm password) fields, optional social provider buttons, and password visibility controls.
11
- *
12
- * The component reflects request state by disabling inputs and showing a pending indicator during sign-up or social sign-in.
13
- *
14
- * @param className - Additional CSS classes applied to the outer card container
15
- * @param socialLayout - Social layout to apply to the provider buttons component
16
- * @param socialPosition - Position of social provider buttons relative to the form; `"top"` or `"bottom"` (default `"bottom"`)
17
- * @returns The sign-up form React element
18
- */
19
- export declare function SignUp({ className, socialLayout, socialPosition, variant, ...props }: SignUpProps & CardProps): import("react/jsx-runtime").JSX.Element;
@@ -1,65 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useAuth, useSignInSocial, useSignUpEmail } from "@better-auth-ui/react";
3
- import { Eye, EyeSlash } from "@gravity-ui/icons";
4
- import { Button, Card, Description, FieldError, Fieldset, Form, Input, InputGroup, Label, Link, Spinner, TextField, toast } from "@heroui/react";
5
- import { useState } from "react";
6
- import { cn } from "../../lib/utils";
7
- import { FieldSeparator } from "./field-separator";
8
- import { MagicLinkButton } from "./magic-link-button";
9
- import { ProviderButtons } from "./provider-buttons";
10
- /**
11
- * Render a sign-up form with name, email, password (and optional confirm password) fields, optional social provider buttons, and password visibility controls.
12
- *
13
- * The component reflects request state by disabling inputs and showing a pending indicator during sign-up or social sign-in.
14
- *
15
- * @param className - Additional CSS classes applied to the outer card container
16
- * @param socialLayout - Social layout to apply to the provider buttons component
17
- * @param socialPosition - Position of social provider buttons relative to the form; `"top"` or `"bottom"` (default `"bottom"`)
18
- * @returns The sign-up form React element
19
- */
20
- export function SignUp({ className, socialLayout, socialPosition = "bottom", variant, ...props }) {
21
- const { basePaths, emailAndPassword, localization, magicLink, navigate, redirectTo, socialProviders, viewPaths } = useAuth();
22
- const [password, setPassword] = useState("");
23
- const [confirmPassword, setConfirmPassword] = useState("");
24
- const { mutate: signUpEmail, isPending: signUpPending } = useSignUpEmail({
25
- onError: (error) => {
26
- setPassword("");
27
- setConfirmPassword("");
28
- toast.danger(error.error?.message || error.message);
29
- },
30
- onSuccess: () => {
31
- if (emailAndPassword?.requireEmailVerification) {
32
- toast.success(localization.auth.verifyYourEmail);
33
- navigate({ to: `${basePaths.auth}/${viewPaths.auth.signIn}` });
34
- }
35
- else {
36
- navigate({ to: redirectTo });
37
- }
38
- }
39
- });
40
- const { mutate: signInSocial, isPending: socialPending } = useSignInSocial({
41
- onError: (error) => toast.danger(error.error?.message || error.message)
42
- });
43
- const [isPasswordVisible, setIsPasswordVisible] = useState(false);
44
- const [isConfirmPasswordVisible, setIsConfirmPasswordVisible] = useState(false);
45
- const isPending = signUpPending || socialPending;
46
- const handleSubmit = (e) => {
47
- e.preventDefault();
48
- const formData = new FormData(e.currentTarget);
49
- const name = formData.get("name");
50
- const email = formData.get("email");
51
- if (emailAndPassword?.confirmPassword && password !== confirmPassword) {
52
- toast.danger(localization.auth.passwordsDoNotMatch);
53
- setPassword("");
54
- setConfirmPassword("");
55
- return;
56
- }
57
- signUpEmail({ name, email, password });
58
- };
59
- const showSeparator = emailAndPassword?.enabled && socialProviders && socialProviders.length > 0;
60
- return (_jsx(Card, { className: cn("w-full max-w-sm p-4 md:p-6", className), variant: variant, ...props, children: _jsx(Card.Content, { children: _jsxs(Fieldset, { className: "gap-4", children: [_jsx(Label, { className: "text-xl", children: localization.auth.signUp }), socialPosition === "top" && (_jsxs(_Fragment, { children: [socialProviders && socialProviders.length > 0 && (_jsx(ProviderButtons, { isPending: isPending, socialLayout: socialLayout, signInSocial: signInSocial })), showSeparator && (_jsx(FieldSeparator, { children: localization.auth.or }))] })), emailAndPassword?.enabled && (_jsxs(Form, { onSubmit: handleSubmit, className: "flex flex-col gap-4", children: [_jsxs(Fieldset.Group, { children: [_jsxs(TextField, { name: "name", type: "text", autoComplete: "name", isDisabled: isPending, children: [_jsx(Label, { children: localization.auth.name }), _jsx(Input, { placeholder: localization.auth.namePlaceholder, required: true, variant: variant === "transparent" ? "primary" : "secondary" }), _jsx(FieldError, { className: "text-wrap" })] }), _jsxs(TextField, { name: "email", type: "email", autoComplete: "email", isDisabled: isPending, children: [_jsx(Label, { children: localization.auth.email }), _jsx(Input, { placeholder: localization.auth.emailPlaceholder, required: true, variant: variant === "transparent" ? "primary" : "secondary" }), _jsx(FieldError, { className: "text-wrap" })] }), _jsxs(TextField, { minLength: emailAndPassword?.minPasswordLength, maxLength: emailAndPassword?.maxPasswordLength, name: "password", autoComplete: "new-password", isDisabled: isPending, value: password, onChange: setPassword, children: [_jsx(Label, { children: localization.auth.password }), _jsxs(InputGroup, { variant: variant === "transparent" ? "primary" : "secondary", children: [_jsx(InputGroup.Input, { placeholder: localization.auth.passwordPlaceholder, type: isPasswordVisible ? "text" : "password", name: "password", required: true }), _jsx(InputGroup.Suffix, { className: "px-0", children: _jsx(Button, { isIconOnly: true, "aria-label": isPasswordVisible
61
- ? localization.auth.hidePassword
62
- : localization.auth.showPassword, size: "sm", variant: "ghost", onPress: () => setIsPasswordVisible(!isPasswordVisible), isDisabled: isPending, children: isPasswordVisible ? _jsx(EyeSlash, {}) : _jsx(Eye, {}) }) })] }), _jsx(FieldError, { className: "text-wrap" })] }), emailAndPassword?.confirmPassword && (_jsxs(TextField, { minLength: emailAndPassword?.minPasswordLength, maxLength: emailAndPassword?.maxPasswordLength, name: "confirmPassword", autoComplete: "new-password", isDisabled: isPending, value: confirmPassword, onChange: setConfirmPassword, children: [_jsx(Label, { children: localization.auth.confirmPassword }), _jsxs(InputGroup, { variant: variant === "transparent" ? "primary" : "secondary", children: [_jsx(InputGroup.Input, { name: "confirmPassword", placeholder: localization.auth.confirmPasswordPlaceholder, type: isConfirmPasswordVisible ? "text" : "password", required: true }), _jsx(InputGroup.Suffix, { className: "px-0", children: _jsx(Button, { isIconOnly: true, "aria-label": isConfirmPasswordVisible
63
- ? localization.auth.hidePassword
64
- : localization.auth.showPassword, size: "sm", variant: "ghost", onPress: () => setIsConfirmPasswordVisible(!isConfirmPasswordVisible), isDisabled: isPending, children: isConfirmPasswordVisible ? _jsx(EyeSlash, {}) : _jsx(Eye, {}) }) })] }), _jsx(FieldError, { className: "text-wrap" })] }))] }), _jsxs(Fieldset.Actions, { className: "flex-col gap-3", children: [_jsxs(Button, { type: "submit", className: "w-full", isPending: isPending, children: [isPending && _jsx(Spinner, { color: "current", size: "sm" }), localization.auth.signUp] }), magicLink && (_jsx(MagicLinkButton, { view: "signUp", isPending: isPending }))] })] })), socialPosition === "bottom" && (_jsxs(_Fragment, { children: [showSeparator && (_jsx(FieldSeparator, { children: localization.auth.or })), socialProviders && socialProviders.length > 0 && (_jsx(ProviderButtons, { socialLayout: socialLayout, signInSocial: signInSocial, isPending: isPending }))] })), emailAndPassword?.enabled && (_jsxs(Description, { className: "text-center text-sm", children: [localization.auth.alreadyHaveAnAccount, " ", _jsx(Link, { href: `${basePaths.auth}/${viewPaths.auth.signIn}`, className: "text-accent decoration-accent no-underline hover:underline", children: localization.auth.signIn })] }))] }) }) }));
65
- }
@@ -1,3 +0,0 @@
1
- import { type EmailChangedEmailProps } from "@better-auth-ui/react";
2
- export type { EmailChangedEmailProps } from "@better-auth-ui/react";
3
- export declare function EmailChangedEmail({ colors, classNames, ...props }: EmailChangedEmailProps): import("react/jsx-runtime").JSX.Element;
@@ -1,23 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { EmailChangedEmail as EmailChangedEmailPrimitive } from "@better-auth-ui/react";
3
- import { cn } from "@heroui/react";
4
- export function EmailChangedEmail({ colors, classNames, ...props }) {
5
- return (_jsx(EmailChangedEmailPrimitive, { colors: {
6
- light: {
7
- background: "#F5F5F5",
8
- primary: "#0285F7",
9
- primaryForeground: "#FCFCFC",
10
- ...colors?.light
11
- },
12
- dark: {
13
- background: "#060607",
14
- primary: "#0584F6",
15
- primaryForeground: "#FCFCFC",
16
- ...colors?.dark
17
- }
18
- }, classNames: {
19
- ...classNames,
20
- card: cn("border-none rounded-3xl", classNames?.card),
21
- button: cn("rounded-full", classNames?.button)
22
- }, ...props }));
23
- }
@@ -1,3 +0,0 @@
1
- import { type EmailVerificationEmailProps } from "@better-auth-ui/react";
2
- export type { EmailVerificationEmailProps } from "@better-auth-ui/react";
3
- export declare function EmailVerificationEmail({ colors, classNames, ...props }: EmailVerificationEmailProps): import("react/jsx-runtime").JSX.Element;
@@ -1,23 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { EmailVerificationEmail as EmailVerificationEmailPrimitive } from "@better-auth-ui/react";
3
- import { cn } from "@heroui/react";
4
- export function EmailVerificationEmail({ colors, classNames, ...props }) {
5
- return (_jsx(EmailVerificationEmailPrimitive, { colors: {
6
- light: {
7
- background: "#F5F5F5",
8
- primary: "#0285F7",
9
- primaryForeground: "#FCFCFC",
10
- ...colors?.light
11
- },
12
- dark: {
13
- background: "#060607",
14
- primary: "#0584F6",
15
- primaryForeground: "#FCFCFC",
16
- ...colors?.dark
17
- }
18
- }, classNames: {
19
- ...classNames,
20
- card: cn("border-none rounded-3xl", classNames?.card),
21
- button: cn("rounded-full", classNames?.button)
22
- }, ...props }));
23
- }
@@ -1,3 +0,0 @@
1
- import { type MagicLinkEmailProps } from "@better-auth-ui/react";
2
- export type { MagicLinkEmailProps } from "@better-auth-ui/react";
3
- export declare function MagicLinkEmail({ colors, classNames, ...props }: MagicLinkEmailProps): import("react/jsx-runtime").JSX.Element;
@@ -1,23 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { MagicLinkEmail as MagicLinkEmailPrimitive } from "@better-auth-ui/react";
3
- import { cn } from "@heroui/react";
4
- export function MagicLinkEmail({ colors, classNames, ...props }) {
5
- return (_jsx(MagicLinkEmailPrimitive, { colors: {
6
- light: {
7
- background: "#F5F5F5",
8
- primary: "#0285F7",
9
- primaryForeground: "#FCFCFC",
10
- ...colors?.light
11
- },
12
- dark: {
13
- background: "#060607",
14
- primary: "#0584F6",
15
- primaryForeground: "#FCFCFC",
16
- ...colors?.dark
17
- }
18
- }, classNames: {
19
- ...classNames,
20
- card: cn("border-none rounded-3xl", classNames?.card),
21
- button: cn("rounded-full", classNames?.button)
22
- }, ...props }));
23
- }
@@ -1,3 +0,0 @@
1
- import { type NewDeviceEmailProps } from "@better-auth-ui/react";
2
- export type { NewDeviceEmailProps } from "@better-auth-ui/react";
3
- export declare function NewDeviceEmail({ colors, classNames, ...props }: NewDeviceEmailProps): import("react/jsx-runtime").JSX.Element;
@@ -1,23 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { NewDeviceEmail as NewDeviceEmailPrimitive } from "@better-auth-ui/react";
3
- import { cn } from "@heroui/react";
4
- export function NewDeviceEmail({ colors, classNames, ...props }) {
5
- return (_jsx(NewDeviceEmailPrimitive, { colors: {
6
- light: {
7
- background: "#F5F5F5",
8
- primary: "#0285F7",
9
- primaryForeground: "#FCFCFC",
10
- ...colors?.light
11
- },
12
- dark: {
13
- background: "#060607",
14
- primary: "#0584F6",
15
- primaryForeground: "#FCFCFC",
16
- ...colors?.dark
17
- }
18
- }, classNames: {
19
- ...classNames,
20
- card: cn("border-none rounded-3xl", classNames?.card),
21
- button: cn("rounded-full", classNames?.button)
22
- }, ...props }));
23
- }
@@ -1,3 +0,0 @@
1
- import { type OtpEmailProps } from "@better-auth-ui/react";
2
- export type { OtpEmailProps } from "@better-auth-ui/react";
3
- export declare function OtpEmail({ colors, classNames, ...props }: OtpEmailProps): import("react/jsx-runtime").JSX.Element;
@@ -1,22 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { OtpEmail as OtpEmailPrimitive } from "@better-auth-ui/react";
3
- import { cn } from "@heroui/react";
4
- export function OtpEmail({ colors, classNames, ...props }) {
5
- return (_jsx(OtpEmailPrimitive, { colors: {
6
- light: {
7
- background: "#F5F5F5",
8
- primary: "#0285F7",
9
- primaryForeground: "#FCFCFC",
10
- ...colors?.light
11
- },
12
- dark: {
13
- background: "#060607",
14
- primary: "#0584F6",
15
- primaryForeground: "#FCFCFC",
16
- ...colors?.dark
17
- }
18
- }, classNames: {
19
- ...classNames,
20
- card: cn("border-none rounded-3xl", classNames?.card)
21
- }, ...props }));
22
- }
@@ -1,3 +0,0 @@
1
- import { type PasswordChangedEmailProps } from "@better-auth-ui/react";
2
- export type { PasswordChangedEmailProps } from "@better-auth-ui/react";
3
- export declare function PasswordChangedEmail({ colors, classNames, ...props }: PasswordChangedEmailProps): import("react/jsx-runtime").JSX.Element;
@@ -1,23 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { PasswordChangedEmail as PasswordChangedEmailPrimitive } from "@better-auth-ui/react";
3
- import { cn } from "@heroui/react";
4
- export function PasswordChangedEmail({ colors, classNames, ...props }) {
5
- return (_jsx(PasswordChangedEmailPrimitive, { colors: {
6
- light: {
7
- background: "#F5F5F5",
8
- primary: "#0285F7",
9
- primaryForeground: "#FCFCFC",
10
- ...colors?.light
11
- },
12
- dark: {
13
- background: "#060607",
14
- primary: "#0584F6",
15
- primaryForeground: "#FCFCFC",
16
- ...colors?.dark
17
- }
18
- }, classNames: {
19
- ...classNames,
20
- card: cn("border-none rounded-3xl", classNames?.card),
21
- button: cn("rounded-full", classNames?.button)
22
- }, ...props }));
23
- }
@@ -1,3 +0,0 @@
1
- import { type ResetPasswordEmailProps } from "@better-auth-ui/react";
2
- export type { ResetPasswordEmailProps } from "@better-auth-ui/react";
3
- export declare function ResetPasswordEmail({ colors, classNames, ...props }: ResetPasswordEmailProps): import("react/jsx-runtime").JSX.Element;
@@ -1,23 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ResetPasswordEmail as ResetPasswordEmailPrimitive } from "@better-auth-ui/react";
3
- import { cn } from "@heroui/react";
4
- export function ResetPasswordEmail({ colors, classNames, ...props }) {
5
- return (_jsx(ResetPasswordEmailPrimitive, { colors: {
6
- light: {
7
- background: "#F5F5F5",
8
- primary: "#0285F7",
9
- primaryForeground: "#FCFCFC",
10
- ...colors?.light
11
- },
12
- dark: {
13
- background: "#060607",
14
- primary: "#0584F6",
15
- primaryForeground: "#FCFCFC",
16
- ...colors?.dark
17
- }
18
- }, classNames: {
19
- ...classNames,
20
- card: cn("border-none rounded-3xl", classNames?.card),
21
- button: cn("rounded-full", classNames?.button)
22
- }, ...props }));
23
- }
@@ -1,13 +0,0 @@
1
- import type { ComponentProps } from "react";
2
- export type AccountSettingsProps = {
3
- className?: string;
4
- };
5
- /**
6
- * Renders the account settings layout including user profile, change email, appearance, and accounts management.
7
- *
8
- * UserProfile, ChangeEmail, and Appearance are always rendered; Accounts is rendered when `multiSession` is enabled.
9
- *
10
- * @param className - Optional additional CSS class names for the outer container.
11
- * @returns The account settings container as a JSX element.
12
- */
13
- export declare function AccountSettings({ className, ...props }: AccountSettingsProps & ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
@@ -1,19 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useAuth } from "@better-auth-ui/react";
3
- import { cn } from "../../../lib/utils";
4
- import { Appearance } from "./appearance";
5
- import { ChangeEmail } from "./change-email";
6
- import { ManageAccounts } from "./manage-accounts";
7
- import { UserProfile } from "./user-profile";
8
- /**
9
- * Renders the account settings layout including user profile, change email, appearance, and accounts management.
10
- *
11
- * UserProfile, ChangeEmail, and Appearance are always rendered; Accounts is rendered when `multiSession` is enabled.
12
- *
13
- * @param className - Optional additional CSS class names for the outer container.
14
- * @returns The account settings container as a JSX element.
15
- */
16
- export function AccountSettings({ className, ...props }) {
17
- const { multiSession } = useAuth();
18
- return (_jsxs("div", { className: cn("flex w-full flex-col gap-4 md:gap-6", className), ...props, children: [_jsx(UserProfile, {}), _jsx(ChangeEmail, {}), _jsx(Appearance, {}), multiSession && _jsx(ManageAccounts, {})] }));
19
- }
@@ -1,16 +0,0 @@
1
- import { type CardProps } from "@heroui/react";
2
- export type AppearanceProps = {
3
- className?: string;
4
- variant?: CardProps["variant"];
5
- };
6
- /**
7
- * Renders a theme selector card with visual theme previews.
8
- *
9
- * Displays a card containing radio buttons for selecting between system, light,
10
- * and dark themes. Each option shows a visual preview of the theme. Only renders
11
- * if theme settings are configured (theme, setTheme, and themes are provided).
12
- *
13
- * @param className - Optional additional CSS class names for the card container.
14
- * @returns A JSX element containing the theme selector card, or null if theme settings are not configured.
15
- */
16
- export declare function Appearance({ className, variant, ...props }: AppearanceProps & CardProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1,28 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ThemePreviewDark, ThemePreviewLight, ThemePreviewSystem, useAuth } from "@better-auth-ui/react";
3
- import { Display, Moon, Sun } from "@gravity-ui/icons";
4
- import { Card, cn, Label, Radio, RadioGroup, useIsHydrated } from "@heroui/react";
5
- /**
6
- * Renders a theme selector card with visual theme previews.
7
- *
8
- * Displays a card containing radio buttons for selecting between system, light,
9
- * and dark themes. Each option shows a visual preview of the theme. Only renders
10
- * if theme settings are configured (theme, setTheme, and themes are provided).
11
- *
12
- * @param className - Optional additional CSS class names for the card container.
13
- * @returns A JSX element containing the theme selector card, or null if theme settings are not configured.
14
- */
15
- export function Appearance({ className, variant, ...props }) {
16
- const { localization, settings: { theme, setTheme, themes } } = useAuth();
17
- const hydrated = useIsHydrated();
18
- if (!setTheme || !themes?.length) {
19
- return null;
20
- }
21
- return (_jsxs(Card, { className: cn("p-4 md:p-6 gap-4", className), variant: variant, ...props, children: [_jsx(Card.Header, { children: _jsx(Card.Title, { className: "text-xl", children: localization.settings.appearance }) }), _jsx(Card.Content, { children: _jsxs(RadioGroup, { variant: variant === "transparent" ? "secondary" : "primary", value: hydrated ? theme : undefined, onChange: setTheme, isDisabled: !hydrated || !theme, children: [_jsx(Label, { className: "mb-2", children: localization.settings.theme }), _jsxs("div", { className: "grid gap-3 sm:grid-cols-2 lg:grid-cols-3", children: [themes.includes("system") && (_jsxs(Radio, { value: "system", className: cn(variant === "transparent"
22
- ? "bg-surface"
23
- : "bg-surface-secondary", "mt-0 group relative flex-col gap-4 rounded-xl border border-transparent px-5 py-4 transition-all data-[selected=true]:border-accent data-[selected=true]:bg-accent/10", "data-[focus-visible=true]:border-accent data-[focus-visible=true]:bg-accent/10"), children: [_jsx(Radio.Control, { className: "absolute top-3 right-3 size-5", children: _jsx(Radio.Indicator, {}) }), _jsxs(Radio.Content, { className: "flex flex-col gap-3", children: [_jsxs(Label, { className: "cursor-pointer font-medium flex gap-2 items-center", children: [_jsx(Display, { className: "text-muted" }), localization.settings.system] }), _jsx(ThemePreviewSystem, { className: "w-full" })] })] })), themes.includes("light") && (_jsxs(Radio, { value: "light", className: cn(variant === "transparent"
24
- ? "bg-surface"
25
- : "bg-surface-secondary", "mt-0 group relative flex-col gap-4 rounded-xl border border-transparent px-5 py-4 transition-all data-[selected=true]:border-accent data-[selected=true]:bg-accent/10", "data-[focus-visible=true]:border-accent data-[focus-visible=true]:bg-accent/10"), children: [_jsx(Radio.Control, { className: "absolute top-3 right-3 size-5", children: _jsx(Radio.Indicator, {}) }), _jsxs(Radio.Content, { className: "flex flex-col gap-3", children: [_jsxs(Label, { className: "cursor-pointer font-medium flex gap-2 items-center", children: [_jsx(Sun, { className: "text-muted" }), localization.settings.light] }), _jsx(ThemePreviewLight, { className: "w-full" })] })] })), themes.includes("dark") && (_jsxs(Radio, { value: "dark", className: cn(variant === "transparent"
26
- ? "bg-surface"
27
- : "bg-surface-secondary", "mt-0 group relative flex-col gap-4 rounded-xl border border-transparent px-5 py-4 transition-all data-[selected=true]:border-accent data-[selected=true]:bg-accent/10", "data-[focus-visible=true]:border-accent data-[focus-visible=true]:bg-accent/10"), children: [_jsx(Radio.Control, { className: "absolute top-3 right-3 size-5", children: _jsx(Radio.Indicator, {}) }), _jsxs(Radio.Content, { className: "flex flex-col gap-3", children: [_jsxs(Label, { className: "cursor-pointer font-medium flex gap-2 items-center", children: [_jsx(Moon, { className: "text-muted" }), localization.settings.dark] }), _jsx(ThemePreviewDark, { className: "w-full" })] })] }))] })] }) })] }));
28
- }
@@ -1,15 +0,0 @@
1
- import { type CardProps } from "@heroui/react";
2
- export type ChangeEmailProps = {
3
- className?: string;
4
- variant?: CardProps["variant"];
5
- };
6
- /**
7
- * Render a card containing a form to view and update the authenticated user's email.
8
- *
9
- * Shows a loading skeleton until session data is available, displays the current
10
- * email as the form's default value, and sends a verification email to the
11
- * new address upon successful submission.
12
- *
13
- * @returns A JSX element rendering the change-email card and form
14
- */
15
- export declare function ChangeEmail({ className, variant, ...props }: ChangeEmailProps & CardProps): import("react/jsx-runtime").JSX.Element;
@@ -1,35 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useAuth, useChangeEmail, useSession } from "@better-auth-ui/react";
3
- import { Check, Envelope } from "@gravity-ui/icons";
4
- import { Button, Card, cn, FieldError, Fieldset, Form, InputGroup, Label, Skeleton, Spinner, TextField, toast } from "@heroui/react";
5
- /**
6
- * Render a card containing a form to view and update the authenticated user's email.
7
- *
8
- * Shows a loading skeleton until session data is available, displays the current
9
- * email as the form's default value, and sends a verification email to the
10
- * new address upon successful submission.
11
- *
12
- * @returns A JSX element rendering the change-email card and form
13
- */
14
- export function ChangeEmail({ className, variant, ...props }) {
15
- const { localization, baseURL, viewPaths } = useAuth();
16
- const { data: sessionData } = useSession({
17
- throwOnError: (error) => {
18
- toast.danger(error.error?.message || error.message);
19
- return false;
20
- }
21
- });
22
- const { mutate: changeEmail, isPending } = useChangeEmail({
23
- onSuccess: () => toast.success(localization.settings.changeEmailSuccess),
24
- onError: (error) => toast.danger(error.error?.message || error.message)
25
- });
26
- function handleSubmit(e) {
27
- e.preventDefault();
28
- const formData = new FormData(e.currentTarget);
29
- changeEmail({
30
- newEmail: formData.get("email"),
31
- callbackURL: `${baseURL}/${viewPaths.settings.account}`
32
- });
33
- }
34
- return (_jsxs(Card, { className: cn("p-4 md:p-6 gap-4", className), variant: variant, ...props, children: [_jsx(Card.Header, { children: _jsx(Card.Title, { className: "text-xl", children: localization.settings.changeEmail }) }), _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: sessionData?.user.email, isDisabled: isPending || !sessionData, children: [_jsx(Label, { children: localization.auth.email }), sessionData ? (_jsxs(InputGroup, { variant: variant === "transparent" ? "primary" : "secondary", children: [_jsx(InputGroup.Prefix, { children: _jsx(Envelope, {}) }), _jsx(InputGroup.Input, { required: true, autoComplete: "email", placeholder: localization.auth.emailPlaceholder })] })) : (_jsx(Skeleton, { className: "h-10 md:h-9 w-full rounded-xl" })), _jsx(FieldError, {})] }, sessionData?.user.email) }), _jsx(Fieldset.Actions, { children: _jsxs(Button, { type: "submit", isPending: isPending, isDisabled: !sessionData, children: [isPending ? _jsx(Spinner, { color: "current", size: "sm" }) : _jsx(Check, {}), localization.settings.updateEmail] }) })] }) }) })] }));
35
- }
@@ -1,19 +0,0 @@
1
- import type { Session, User } from "better-auth";
2
- export type DeviceSession = {
3
- session: Session;
4
- user: User;
5
- };
6
- export type ManageAccountProps = {
7
- deviceSession?: DeviceSession | null;
8
- isPending?: boolean;
9
- };
10
- /**
11
- * Render a single account card with user info and switch/revoke controls.
12
- *
13
- * Shows the user's avatar and info. For non-active sessions, provides a switch button.
14
- * All sessions have a revoke/sign-out button.
15
- *
16
- * @param deviceSession - The device session object containing session and user data
17
- * @returns A JSX element containing the account card
18
- */
19
- export declare function ManageAccount({ deviceSession, isPending }: ManageAccountProps): import("react/jsx-runtime").JSX.Element;
@@ -1,27 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useAuth, useRevokeMultiSession, useSession, useSetActiveSession } from "@better-auth-ui/react";
3
- import { ArrowRightArrowLeft, ArrowRightFromSquare } from "@gravity-ui/icons";
4
- import { Button, Card, Spinner, toast } from "@heroui/react";
5
- import { UserView } from "../../user/user-view";
6
- /**
7
- * Render a single account card with user info and switch/revoke controls.
8
- *
9
- * Shows the user's avatar and info. For non-active sessions, provides a switch button.
10
- * All sessions have a revoke/sign-out button.
11
- *
12
- * @param deviceSession - The device session object containing session and user data
13
- * @returns A JSX element containing the account card
14
- */
15
- export function ManageAccount({ deviceSession, isPending }) {
16
- const { localization } = useAuth();
17
- const { data: sessionData } = useSession();
18
- const { mutate: setActiveSession, isPending: isSwitching } = useSetActiveSession({
19
- onError: (error) => toast.danger(error.error?.message || error.message)
20
- });
21
- const { mutate: revokeSession, isPending: isRevoking } = useRevokeMultiSession({
22
- onError: (error) => toast.danger(error.error?.message || error.message),
23
- onSuccess: () => toast.success(localization.settings.revokeSessionSuccess)
24
- });
25
- const isActive = deviceSession?.session.userId === sessionData?.session.userId;
26
- return (_jsxs(Card, { className: "flex-row items-center border p-3 shadow-none", children: [_jsx(UserView, { user: deviceSession?.user, isPending: isPending, size: "md" }), deviceSession && (_jsxs("div", { className: "flex items-center gap-1 shrink-0 ml-auto", children: [!isActive && (_jsx(Button, { isIconOnly: true, variant: "ghost", size: "sm", onPress: () => setActiveSession({ sessionToken: deviceSession.session.token }), isPending: isSwitching || isRevoking, "aria-label": localization.auth.switchAccount, children: isSwitching ? (_jsx(Spinner, { color: "current", size: "sm" })) : (_jsx(ArrowRightArrowLeft, {})) })), _jsx(Button, { isIconOnly: true, variant: "ghost", size: "sm", onPress: () => revokeSession({ sessionToken: deviceSession.session.token }), isPending: isSwitching || isRevoking, "aria-label": localization.auth.signOut, children: isRevoking ? (_jsx(Spinner, { color: "current", size: "sm" })) : (_jsx(ArrowRightFromSquare, {})) })] }))] }));
27
- }
@@ -1,14 +0,0 @@
1
- import { type CardProps } from "@heroui/react";
2
- export type ManageAccountsProps = {
3
- className?: string;
4
- variant?: CardProps["variant"];
5
- };
6
- /**
7
- * Render a card that lists and manages all device sessions for the current user.
8
- *
9
- * Shows each session with user information and actions to switch to or revoke a session.
10
- * When device session data is loading, a pending placeholder row is displayed.
11
- *
12
- * @returns A JSX element containing the accounts management card
13
- */
14
- export declare function ManageAccounts({ className, ...props }: ManageAccountsProps & CardProps): import("react/jsx-runtime").JSX.Element;