@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 +1,147 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useAuth, useResetPassword } from "@better-auth-ui/react";
3
- import { Eye, EyeSlash } from "@gravity-ui/icons";
4
- import { Button, Card, cn, Description, FieldError, Form, InputGroup, Label, Link, Spinner, TextField, toast } from "@heroui/react";
5
- import { useEffect, useState } from "react";
6
- /**
7
- * Renders a reset password form that verifies a "token" URL parameter on mount and redirects to sign-in if absent.
8
- *
9
- * Renders password (and optional confirm-password) inputs with visibility toggles, applies min/max length constraints from the auth configuration, shows field errors, and submits the new password to the auth client.
10
- */
11
- export function ResetPassword({ className, variant, ...props }) {
12
- const { basePaths, emailAndPassword, localization, viewPaths, navigate } = useAuth();
13
- const { mutate: resetPassword, isPending } = useResetPassword({
14
- onError: (error) => toast.danger(error.error?.message || error.message),
15
- onSuccess: () => {
16
- toast.success(localization.auth.passwordResetSuccess);
17
- navigate({ to: `${basePaths.auth}/${viewPaths.auth.signIn}` });
18
- }
19
- });
20
- const [isPasswordVisible, setIsPasswordVisible] = useState(false);
21
- const [isConfirmPasswordVisible, setIsConfirmPasswordVisible] = useState(false);
22
- useEffect(() => {
23
- const searchParams = new URLSearchParams(window.location.search);
24
- const token = searchParams.get("token");
25
- if (!token) {
26
- toast.danger(localization.auth.invalidResetPasswordToken);
27
- navigate({ to: `${basePaths.auth}/${viewPaths.auth.signIn}` });
28
- }
29
- }, [
30
- basePaths.auth,
31
- localization.auth.invalidResetPasswordToken,
32
- viewPaths.auth.signIn,
33
- navigate
34
- ]);
35
- function handleSubmit(e) {
36
- e.preventDefault();
37
- const searchParams = new URLSearchParams(window.location.search);
38
- const token = searchParams.get("token");
39
- if (!token) {
40
- toast.danger(localization.auth.invalidResetPasswordToken);
41
- navigate({ to: `${basePaths.auth}/${viewPaths.auth.signIn}` });
42
- return;
43
- }
44
- const formData = new FormData(e.currentTarget);
45
- const password = formData.get("password");
46
- const confirmPassword = formData.get("confirmPassword");
47
- if (emailAndPassword?.confirmPassword && password !== confirmPassword) {
48
- toast.danger(localization.auth.passwordsDoNotMatch);
49
- return;
50
- }
51
- resetPassword({ token, newPassword: password });
52
- }
53
- return (_jsxs(Card, { className: cn("w-full max-w-sm p-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.resetPassword }) }), _jsx(Card.Content, { children: _jsxs(Form, { onSubmit: handleSubmit, className: "flex flex-col gap-4", children: [_jsxs(TextField, { minLength: emailAndPassword?.minPasswordLength, maxLength: emailAndPassword?.maxPasswordLength, name: "password", autoComplete: "new-password", isDisabled: isPending, children: [_jsx(Label, { children: localization.auth.password }), _jsxs(InputGroup, { variant: variant === "transparent" ? "primary" : "secondary", children: [_jsx(InputGroup.Input, { name: "password", placeholder: localization.auth.newPasswordPlaceholder, type: isPasswordVisible ? "text" : "password", required: true }), _jsx(InputGroup.Suffix, { className: "px-0", children: _jsx(Button, { isIconOnly: true, "aria-label": isPasswordVisible
54
- ? localization.auth.hidePassword
55
- : localization.auth.showPassword, size: "sm", variant: "ghost", onPress: () => setIsPasswordVisible(!isPasswordVisible), isDisabled: isPending, children: isPasswordVisible ? _jsx(EyeSlash, {}) : _jsx(Eye, {}) }) })] }), _jsx(FieldError, {})] }), emailAndPassword?.confirmPassword && (_jsxs(TextField, { minLength: emailAndPassword?.minPasswordLength, maxLength: emailAndPassword?.maxPasswordLength, name: "confirmPassword", autoComplete: "new-password", isDisabled: isPending, children: [_jsx(Label, { children: localization.auth.confirmPassword }), _jsxs(InputGroup, { variant: variant === "transparent" ? "primary" : "secondary", children: [_jsx(InputGroup.Input, { placeholder: localization.auth.confirmPasswordPlaceholder, type: isConfirmPasswordVisible ? "text" : "password", required: true, name: "confirmPassword" }), _jsx(InputGroup.Suffix, { className: "px-0", children: _jsx(Button, { isIconOnly: true, "aria-label": isConfirmPasswordVisible
56
- ? localization.auth.hidePassword
57
- : localization.auth.showPassword, size: "sm", variant: "ghost", onPress: () => setIsConfirmPasswordVisible(!isConfirmPasswordVisible), isDisabled: isPending, children: isConfirmPasswordVisible ? _jsx(EyeSlash, {}) : _jsx(Eye, {}) }) })] }), _jsx(FieldError, {})] })), _jsx("div", { className: "flex flex-col gap-3", children: _jsxs(Button, { type: "submit", className: "w-full", isPending: isPending, children: [isPending && _jsx(Spinner, { color: "current", size: "sm" }), localization.auth.resetPassword] }) })] }) }), _jsx(Card.Footer, { className: "flex-col", children: _jsxs(Description, { className: "text-sm", children: [localization.auth.rememberYourPassword, " ", _jsx(Link, { href: `${basePaths.auth}/${viewPaths.auth.signIn}`, className: "text-accent decoration-accent no-underline hover:underline", children: localization.auth.signIn })] }) })] }));
1
+ import { useAuth as e, useResetPassword as t } from "@better-auth-ui/react";
2
+ import { Button as n, Card as r, Description as i, FieldError as a, Form as o, InputGroup as s, Label as c, Link as l, Spinner as u, TextField as d, cn as f, toast as p } from "@heroui/react";
3
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
4
+ import { useEffect as g, useState as _ } from "react";
5
+ import { Eye as v, EyeSlash as y } from "@gravity-ui/icons";
6
+ //#region src/components/auth/reset-password.tsx
7
+ function b({ className: b, variant: x, ...S }) {
8
+ let { basePaths: C, emailAndPassword: w, localization: T, viewPaths: E, navigate: D } = e(), { mutate: O, isPending: k } = t({
9
+ onError: (e) => p.danger(e.error?.message || e.message),
10
+ onSuccess: () => {
11
+ p.success(T.auth.passwordResetSuccess), D({ to: `${C.auth}/${E.auth.signIn}` });
12
+ }
13
+ }), [A, j] = _(!1), [M, N] = _(!1);
14
+ g(() => {
15
+ new URLSearchParams(window.location.search).get("token") || (p.danger(T.auth.invalidResetPasswordToken), D({ to: `${C.auth}/${E.auth.signIn}` }));
16
+ }, [
17
+ C.auth,
18
+ T.auth.invalidResetPasswordToken,
19
+ E.auth.signIn,
20
+ D
21
+ ]);
22
+ function P(e) {
23
+ e.preventDefault();
24
+ let t = new URLSearchParams(window.location.search).get("token");
25
+ if (!t) {
26
+ p.danger(T.auth.invalidResetPasswordToken), D({ to: `${C.auth}/${E.auth.signIn}` });
27
+ return;
28
+ }
29
+ let n = new FormData(e.currentTarget), r = n.get("password"), i = n.get("confirmPassword");
30
+ if (w?.confirmPassword && r !== i) {
31
+ p.danger(T.auth.passwordsDoNotMatch);
32
+ return;
33
+ }
34
+ O({
35
+ token: t,
36
+ newPassword: r
37
+ });
38
+ }
39
+ return /* @__PURE__ */ h(r, {
40
+ className: f("w-full max-w-sm p-4 md:p-6", b),
41
+ variant: x,
42
+ ...S,
43
+ children: [
44
+ /* @__PURE__ */ m(r.Header, { children: /* @__PURE__ */ m(r.Title, {
45
+ className: "text-xl font-semibold mb-1",
46
+ children: T.auth.resetPassword
47
+ }) }),
48
+ /* @__PURE__ */ m(r.Content, { children: /* @__PURE__ */ h(o, {
49
+ onSubmit: P,
50
+ className: "flex flex-col gap-4",
51
+ children: [
52
+ /* @__PURE__ */ h(d, {
53
+ minLength: w?.minPasswordLength,
54
+ maxLength: w?.maxPasswordLength,
55
+ name: "password",
56
+ autoComplete: "new-password",
57
+ isDisabled: k,
58
+ children: [
59
+ /* @__PURE__ */ m(c, { children: T.auth.password }),
60
+ /* @__PURE__ */ h(s, {
61
+ variant: x === "transparent" ? "primary" : "secondary",
62
+ children: [/* @__PURE__ */ m(s.Input, {
63
+ name: "password",
64
+ placeholder: T.auth.newPasswordPlaceholder,
65
+ type: A ? "text" : "password",
66
+ required: !0
67
+ }), /* @__PURE__ */ m(s.Suffix, {
68
+ className: "px-0",
69
+ children: /* @__PURE__ */ m(n, {
70
+ isIconOnly: !0,
71
+ "aria-label": A ? T.auth.hidePassword : T.auth.showPassword,
72
+ size: "sm",
73
+ variant: "ghost",
74
+ onPress: () => j(!A),
75
+ isDisabled: k,
76
+ children: m(A ? y : v, {})
77
+ })
78
+ })]
79
+ }),
80
+ /* @__PURE__ */ m(a, {})
81
+ ]
82
+ }),
83
+ w?.confirmPassword && /* @__PURE__ */ h(d, {
84
+ minLength: w?.minPasswordLength,
85
+ maxLength: w?.maxPasswordLength,
86
+ name: "confirmPassword",
87
+ autoComplete: "new-password",
88
+ isDisabled: k,
89
+ children: [
90
+ /* @__PURE__ */ m(c, { children: T.auth.confirmPassword }),
91
+ /* @__PURE__ */ h(s, {
92
+ variant: x === "transparent" ? "primary" : "secondary",
93
+ children: [/* @__PURE__ */ m(s.Input, {
94
+ placeholder: T.auth.confirmPasswordPlaceholder,
95
+ type: M ? "text" : "password",
96
+ required: !0,
97
+ name: "confirmPassword"
98
+ }), /* @__PURE__ */ m(s.Suffix, {
99
+ className: "px-0",
100
+ children: /* @__PURE__ */ m(n, {
101
+ isIconOnly: !0,
102
+ "aria-label": M ? T.auth.hidePassword : T.auth.showPassword,
103
+ size: "sm",
104
+ variant: "ghost",
105
+ onPress: () => N(!M),
106
+ isDisabled: k,
107
+ children: m(M ? y : v, {})
108
+ })
109
+ })]
110
+ }),
111
+ /* @__PURE__ */ m(a, {})
112
+ ]
113
+ }),
114
+ /* @__PURE__ */ m("div", {
115
+ className: "flex flex-col gap-3",
116
+ children: /* @__PURE__ */ h(n, {
117
+ type: "submit",
118
+ className: "w-full",
119
+ isPending: k,
120
+ children: [k && /* @__PURE__ */ m(u, {
121
+ color: "current",
122
+ size: "sm"
123
+ }), T.auth.resetPassword]
124
+ })
125
+ })
126
+ ]
127
+ }) }),
128
+ /* @__PURE__ */ m(r.Footer, {
129
+ className: "flex-col",
130
+ children: /* @__PURE__ */ h(i, {
131
+ className: "text-sm",
132
+ children: [
133
+ T.auth.rememberYourPassword,
134
+ " ",
135
+ /* @__PURE__ */ m(l, {
136
+ href: `${C.auth}/${E.auth.signIn}`,
137
+ className: "text-accent decoration-accent no-underline hover:underline",
138
+ children: T.auth.signIn
139
+ })
140
+ ]
141
+ })
142
+ })
143
+ ]
144
+ });
58
145
  }
146
+ //#endregion
147
+ export { b as ResetPassword };
@@ -1,5 +1,5 @@
1
- import { type CardProps } from "@heroui/react";
2
- import { type SocialLayout } from "./provider-buttons";
1
+ import { CardProps } from '@heroui/react';
2
+ import { SocialLayout } from './provider-buttons';
3
3
  export interface SignInProps {
4
4
  className?: string;
5
5
  socialLayout?: SocialLayout;
@@ -1,64 +1,164 @@
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, cn, Description, FieldError, Form, Input, Label, Link, Spinner, TextField, toast } from "@heroui/react";
4
- import { useState } from "react";
5
- import { FieldSeparator } from "./field-separator";
6
- import { MagicLinkButton } from "./magic-link-button";
7
- import { ProviderButtons } from "./provider-buttons";
8
- /**
9
- * Render the sign-in UI using auth context for configuration and localization.
10
- *
11
- * @returns The sign-in JSX element containing email/password fields, optional magic-link button, and social provider buttons.
12
- */
13
- export function SignIn({ className, socialLayout, socialPosition = "bottom", variant, ...props }) {
14
- const { basePaths, baseURL, emailAndPassword, localization, magicLink, redirectTo, socialProviders, viewPaths, navigate } = useAuth();
15
- const [password, setPassword] = useState("");
16
- const { mutate: sendVerificationEmail } = useSendVerificationEmail({
17
- onError: (error) => toast.danger(error.error?.message || error.message),
18
- onSuccess: () => toast.success(localization.auth.verificationEmailSent)
19
- });
20
- const { mutate: signInEmail, isPending: signInPending } = useSignInEmail({
21
- onError: (error, { email }) => {
22
- setPassword("");
23
- if (error.error?.code === "EMAIL_NOT_VERIFIED") {
24
- toast.danger(error.error?.message || error.message, {
25
- actionProps: {
26
- children: localization.auth.resend,
27
- onClick: () => sendVerificationEmail({
28
- email,
29
- callbackURL: `${baseURL}${redirectTo}`
30
- })
31
- }
32
- });
33
- }
34
- else {
35
- toast.danger(error.error?.message || error.message);
36
- }
37
- },
38
- onSuccess: () => navigate({ to: redirectTo })
39
- });
40
- const [socialRedirecting, setSocialRedirecting] = useState(false);
41
- const { mutate: signInSocial, isPending: socialPending } = useSignInSocial({
42
- onError: (error) => toast.danger(error.error?.message || error.message),
43
- onSuccess: () => {
44
- setSocialRedirecting(true);
45
- setTimeout(() => {
46
- setSocialRedirecting(false);
47
- }, 5000);
48
- }
49
- });
50
- const handleSubmit = (e) => {
51
- e.preventDefault();
52
- const formData = new FormData(e.currentTarget);
53
- const email = formData.get("email");
54
- const rememberMe = formData.get("rememberMe") === "on";
55
- signInEmail({
56
- email,
57
- password,
58
- ...(emailAndPassword?.rememberMe ? { rememberMe } : {})
59
- });
60
- };
61
- const isPending = signInPending || socialPending || socialRedirecting;
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, 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, {})] }), _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 }) })] })), _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?.length && (_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", 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 })] }))] })] }));
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";
7
+ import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
8
+ import { useState as C } from "react";
9
+ //#region src/components/auth/sign-in.tsx
10
+ function w(e) {
11
+ return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
64
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({
18
+ onError: (e, { email: t }) => {
19
+ H(""), e.error?.code === "EMAIL_NOT_VERIFIED" ? y.danger(e.error?.message || e.message, { actionProps: {
20
+ children: N.auth.resend,
21
+ onClick: () => U({
22
+ email: t,
23
+ callbackURL: `${j}${I}`
24
+ })
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);
31
+ },
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) => {
41
+ e.preventDefault();
42
+ 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({
47
+ email: n,
48
+ password: V,
49
+ ...M?.rememberMe ? { rememberMe: r } : {}
50
+ });
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,
56
+ children: [
57
+ /* @__PURE__ */ x(l.Header, { children: /* @__PURE__ */ x(l.Title, {
58
+ className: "text-xl font-semibold mb-1",
59
+ children: N.auth.signIn
60
+ }) }),
61
+ /* @__PURE__ */ S(l.Content, {
62
+ className: "gap-4",
63
+ 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,
71
+ className: "flex flex-col gap-4",
72
+ children: [
73
+ /* @__PURE__ */ S(_, {
74
+ name: "email",
75
+ type: R?.enabled ? "text" : "email",
76
+ autoComplete: R?.enabled ? "username" : "email",
77
+ isDisabled: Q,
78
+ 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",
83
+ required: !0
84
+ }),
85
+ /* @__PURE__ */ x(d, {})
86
+ ]
87
+ }),
88
+ /* @__PURE__ */ S(_, {
89
+ minLength: M?.minPasswordLength,
90
+ maxLength: M?.maxPasswordLength,
91
+ name: "password",
92
+ type: "password",
93
+ autoComplete: "current-password",
94
+ isDisabled: Q,
95
+ value: V,
96
+ onChange: H,
97
+ children: [
98
+ /* @__PURE__ */ x(m, { children: N.auth.password }),
99
+ /* @__PURE__ */ x(p, {
100
+ placeholder: N.auth.passwordPlaceholder,
101
+ variant: O === "transparent" ? "primary" : "secondary",
102
+ required: !0
103
+ }),
104
+ /* @__PURE__ */ x(d, {})
105
+ ]
106
+ }),
107
+ M?.rememberMe && /* @__PURE__ */ S(u, {
108
+ 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 }) })]
112
+ }),
113
+ /* @__PURE__ */ S("div", {
114
+ 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
+ ]
131
+ })
132
+ ]
133
+ }),
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
+ })] })
139
+ ]
140
+ }),
141
+ /* @__PURE__ */ S(l.Footer, {
142
+ className: "flex-col gap-3",
143
+ children: [M?.forgotPassword && /* @__PURE__ */ x(h, {
144
+ href: `${A.auth}/${z.auth.forgotPassword}`,
145
+ className: "no-underline hover:underline",
146
+ children: N.auth.forgotPasswordLink
147
+ }), M?.enabled && /* @__PURE__ */ S(te, {
148
+ className: "text-sm",
149
+ children: [
150
+ N.auth.needToCreateAnAccount,
151
+ " ",
152
+ /* @__PURE__ */ x(h, {
153
+ href: `${A.auth}/${z.auth.signUp}`,
154
+ className: "text-accent no-underline hover:underline decoration-accent-hover",
155
+ children: N.auth.signUp
156
+ })
157
+ ]
158
+ })]
159
+ })
160
+ ]
161
+ });
162
+ }
163
+ //#endregion
164
+ export { T as SignIn };
@@ -1,33 +1,27 @@
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 { basePaths, navigate, viewPaths } = useAuth();
12
- const { mutate: signOut } = useSignOut({
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" }));
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 { jsx as a } from "react/jsx-runtime";
4
+ import { useEffect as o, useRef as s } from "react";
5
+ //#region src/components/auth/sign-out.tsx
6
+ function c({ className: c }) {
7
+ let { basePaths: l, navigate: u, viewPaths: d } = e(), { mutate: f } = t({
8
+ onError: (e) => {
9
+ i.danger(e.error?.message || e.message), u({
10
+ to: `${l.auth}/${d.auth.signIn}`,
11
+ replace: !0
12
+ });
13
+ },
14
+ onSuccess: () => u({
15
+ to: `${l.auth}/${d.auth.signIn}`,
16
+ replace: !0
17
+ })
18
+ }), p = s(!1);
19
+ return o(() => {
20
+ p.current || (p.current = !0, f());
21
+ }, [f]), /* @__PURE__ */ a(n, {
22
+ className: r("mx-auto my-auto", c),
23
+ color: "current"
24
+ });
33
25
  }
26
+ //#endregion
27
+ export { c as SignOut };
@@ -1,5 +1,5 @@
1
- import { type CardProps } from "@heroui/react";
2
- import { type SocialLayout } from "./provider-buttons";
1
+ import { CardProps } from '@heroui/react';
2
+ import { SocialLayout } from './provider-buttons';
3
3
  export type SignUpProps = {
4
4
  className?: string;
5
5
  socialLayout?: SocialLayout;