@better-auth-ui/heroui 1.6.3 → 1.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/dist/components/auth/additional-field.d.ts +4 -0
  2. package/dist/components/auth/additional-field.js +270 -0
  3. package/dist/components/auth/auth-provider.d.ts +4 -6
  4. package/dist/components/auth/auth.d.ts +1 -1
  5. package/dist/components/auth/auth.js +54 -28
  6. package/dist/components/{settings/security → auth/delete-user}/danger-zone.d.ts +3 -4
  7. package/dist/components/{settings/security → auth/delete-user}/danger-zone.js +1 -1
  8. package/dist/components/auth/delete-user/delete-user.js +95 -0
  9. package/dist/components/{email → auth/email}/email-changed-email.d.ts +2 -2
  10. package/dist/components/{email → auth/email}/email-changed-email.js +7 -7
  11. package/dist/components/{email → auth/email}/email-verification-email.d.ts +2 -2
  12. package/dist/components/{email → auth/email}/email-verification-email.js +7 -7
  13. package/dist/components/auth/email/magic-link-email.d.ts +3 -0
  14. package/dist/components/{email → auth/email}/magic-link-email.js +7 -7
  15. package/dist/components/auth/email/new-device-email.d.ts +3 -0
  16. package/dist/components/{email → auth/email}/new-device-email.js +7 -7
  17. package/dist/components/auth/email/otp-email.d.ts +3 -0
  18. package/dist/components/{email → auth/email}/otp-email.js +6 -6
  19. package/dist/components/{email → auth/email}/password-changed-email.d.ts +2 -2
  20. package/dist/components/{email → auth/email}/password-changed-email.js +7 -7
  21. package/dist/components/{email → auth/email}/reset-password-email.d.ts +2 -2
  22. package/dist/components/{email → auth/email}/reset-password-email.js +7 -7
  23. package/dist/components/auth/forgot-password.d.ts +1 -1
  24. package/dist/components/auth/forgot-password.js +41 -38
  25. package/dist/components/auth/magic-link/magic-link-button.d.ts +11 -0
  26. package/dist/components/auth/magic-link/magic-link-button.js +20 -0
  27. package/dist/components/auth/magic-link/magic-link.d.ts +16 -0
  28. package/dist/components/auth/magic-link/magic-link.js +87 -0
  29. package/dist/components/{settings/account → auth/multi-session}/manage-account.d.ts +2 -6
  30. package/dist/components/auth/multi-session/manage-account.js +49 -0
  31. package/dist/components/auth/multi-session/manage-accounts.js +34 -0
  32. package/dist/components/{user/switch-account-menu.d.ts → auth/multi-session/switch-account-submenu-content.d.ts} +3 -3
  33. package/dist/components/auth/multi-session/switch-account-submenu-content.js +29 -0
  34. package/dist/components/{user/switch-account-item.d.ts → auth/multi-session/switch-account-submenu-item.d.ts} +2 -2
  35. package/dist/components/auth/multi-session/switch-account-submenu-item.js +20 -0
  36. package/dist/components/auth/multi-session/switch-account-submenu.d.ts +13 -0
  37. package/dist/components/auth/multi-session/switch-account-submenu.js +24 -0
  38. package/dist/components/auth/passkey/passkey-button.d.ts +6 -0
  39. package/dist/components/auth/passkey/passkey-button.js +24 -0
  40. package/dist/components/auth/passkey/passkey.js +45 -0
  41. package/dist/components/auth/passkey/passkeys.js +106 -0
  42. package/dist/components/auth/provider-button.d.ts +6 -8
  43. package/dist/components/auth/provider-button.js +16 -20
  44. package/dist/components/auth/provider-buttons.d.ts +3 -4
  45. package/dist/components/auth/provider-buttons.js +9 -10
  46. package/dist/components/auth/reset-password.js +110 -107
  47. package/dist/components/{settings → auth/settings}/account/account-settings.d.ts +5 -2
  48. package/dist/components/auth/settings/account/account-settings.js +20 -0
  49. package/dist/components/auth/settings/account/change-avatar.js +89 -0
  50. package/dist/components/{settings → auth/settings}/account/change-email.js +17 -17
  51. package/dist/components/{settings → auth/settings}/account/user-profile.d.ts +2 -3
  52. package/dist/components/auth/settings/account/user-profile.js +86 -0
  53. package/dist/components/auth/settings/security/active-session.js +59 -0
  54. package/dist/components/{settings → auth/settings}/security/active-sessions.js +4 -4
  55. package/dist/components/auth/settings/security/change-password.js +189 -0
  56. package/dist/components/auth/settings/security/linked-account.js +56 -0
  57. package/dist/components/{settings → auth/settings}/security/linked-accounts.js +5 -5
  58. package/dist/components/{settings → auth/settings}/security/security-settings.d.ts +1 -1
  59. package/dist/components/auth/settings/security/security-settings.js +22 -0
  60. package/dist/components/auth/settings/settings.js +45 -0
  61. package/dist/components/auth/sign-in.js +75 -99
  62. package/dist/components/auth/sign-out.js +11 -11
  63. package/dist/components/auth/sign-up.js +123 -148
  64. package/dist/components/{settings/account → auth/theme}/appearance.d.ts +3 -6
  65. package/dist/components/auth/theme/appearance.js +72 -0
  66. package/dist/components/auth/theme/theme-toggle-item.d.ts +5 -0
  67. package/dist/components/auth/theme/theme-toggle-item.js +58 -0
  68. package/dist/components/auth/user/user-avatar.js +29 -0
  69. package/dist/components/{user → auth/user}/user-button.d.ts +2 -6
  70. package/dist/components/auth/user/user-button.js +55 -0
  71. package/dist/components/auth/user/user-view.js +37 -0
  72. package/dist/components/auth/username/sign-in-username.d.ts +14 -0
  73. package/dist/components/auth/username/sign-in-username.js +142 -0
  74. package/dist/components/auth/username/username-field.d.ts +8 -0
  75. package/dist/components/auth/username/username-field.js +51 -0
  76. package/dist/email.d.ts +7 -0
  77. package/dist/email.js +9 -0
  78. package/dist/index.d.ts +12 -27
  79. package/dist/index.js +20 -35
  80. package/dist/lib/auth/auth-plugin.d.ts +44 -0
  81. package/dist/lib/auth/delete-user-plugin.d.ts +17 -0
  82. package/dist/lib/auth/delete-user-plugin.js +10 -0
  83. package/dist/lib/auth/magic-link-plugin.d.ts +31 -0
  84. package/dist/lib/auth/magic-link-plugin.js +13 -0
  85. package/dist/lib/auth/multi-session-plugin.d.ts +18 -0
  86. package/dist/lib/auth/multi-session-plugin.js +12 -0
  87. package/dist/lib/auth/passkey-plugin.d.ts +20 -0
  88. package/dist/lib/auth/passkey-plugin.js +12 -0
  89. package/dist/lib/auth/theme-plugin.d.ts +68 -0
  90. package/dist/lib/auth/theme-plugin.js +23 -0
  91. package/dist/lib/auth/username-plugin.d.ts +63 -0
  92. package/dist/lib/auth/username-plugin.js +18 -0
  93. package/dist/plugins.d.ts +20 -0
  94. package/dist/plugins.js +21 -0
  95. package/package.json +19 -21
  96. package/src/components/auth/additional-field.tsx +554 -0
  97. package/src/components/auth/auth-provider.tsx +5 -6
  98. package/src/components/auth/auth.tsx +99 -35
  99. package/src/components/{settings/security → auth/delete-user}/danger-zone.tsx +3 -10
  100. package/src/components/{settings/security → auth/delete-user}/delete-user.tsx +30 -20
  101. package/src/components/{email → auth/email}/email-changed-email.tsx +2 -2
  102. package/src/components/{email → auth/email}/email-verification-email.tsx +2 -2
  103. package/src/components/{email → auth/email}/magic-link-email.tsx +2 -2
  104. package/src/components/{email → auth/email}/new-device-email.tsx +2 -2
  105. package/src/components/{email → auth/email}/otp-email.tsx +2 -2
  106. package/src/components/{email → auth/email}/password-changed-email.tsx +2 -2
  107. package/src/components/{email → auth/email}/reset-password-email.tsx +2 -2
  108. package/src/components/auth/forgot-password.tsx +14 -11
  109. package/src/components/auth/magic-link/magic-link-button.tsx +61 -0
  110. package/src/components/auth/{magic-link.tsx → magic-link/magic-link.tsx} +55 -40
  111. package/src/components/{settings/account → auth/multi-session}/manage-account.tsx +16 -13
  112. package/src/components/{settings/account → auth/multi-session}/manage-accounts.tsx +14 -5
  113. package/src/components/{user/switch-account-menu.tsx → auth/multi-session/switch-account-submenu-content.tsx} +18 -11
  114. package/src/components/{user/switch-account-item.tsx → auth/multi-session/switch-account-submenu-item.tsx} +17 -5
  115. package/src/components/auth/multi-session/switch-account-submenu.tsx +50 -0
  116. package/src/components/auth/passkey/passkey-button.tsx +56 -0
  117. package/src/components/{settings/security → auth/passkey}/passkey.tsx +20 -6
  118. package/src/components/auth/passkey/passkeys.tsx +196 -0
  119. package/src/components/auth/provider-button.tsx +27 -29
  120. package/src/components/auth/provider-buttons.tsx +6 -11
  121. package/src/components/auth/reset-password.tsx +13 -7
  122. package/src/components/{settings → auth/settings}/account/account-settings.tsx +15 -13
  123. package/src/components/{settings → auth/settings}/account/change-avatar.tsx +4 -3
  124. package/src/components/{settings → auth/settings}/account/change-email.tsx +3 -3
  125. package/src/components/auth/settings/account/user-profile.tsx +171 -0
  126. package/src/components/{settings → auth/settings}/security/active-session.tsx +8 -5
  127. package/src/components/{settings → auth/settings}/security/active-sessions.tsx +3 -3
  128. package/src/components/{settings → auth/settings}/security/change-password.tsx +14 -9
  129. package/src/components/{settings → auth/settings}/security/linked-account.tsx +12 -8
  130. package/src/components/{settings → auth/settings}/security/linked-accounts.tsx +2 -2
  131. package/src/components/{settings → auth/settings}/security/security-settings.tsx +7 -6
  132. package/src/components/{settings → auth/settings}/settings.tsx +2 -2
  133. package/src/components/auth/sign-in.tsx +38 -61
  134. package/src/components/auth/sign-out.tsx +2 -2
  135. package/src/components/auth/sign-up.tsx +109 -131
  136. package/src/components/{settings/account → auth/theme}/appearance.tsx +17 -24
  137. package/src/components/auth/theme/theme-toggle-item.tsx +110 -0
  138. package/src/components/{user → auth/user}/user-avatar.tsx +12 -4
  139. package/src/components/{user → auth/user}/user-button.tsx +15 -88
  140. package/src/components/{user → auth/user}/user-view.tsx +12 -4
  141. package/src/components/auth/username/sign-in-username.tsx +283 -0
  142. package/src/components/auth/username/username-field.tsx +122 -0
  143. package/src/email.ts +9 -0
  144. package/src/index.tsx +12 -27
  145. package/src/lib/auth/auth-plugin.ts +67 -0
  146. package/src/lib/auth/delete-user-plugin.ts +15 -0
  147. package/src/lib/auth/magic-link-plugin.ts +26 -0
  148. package/src/lib/auth/multi-session-plugin.ts +17 -0
  149. package/src/lib/auth/passkey-plugin.ts +17 -0
  150. package/src/lib/auth/theme-plugin.ts +86 -0
  151. package/src/lib/auth/username-plugin.tsx +30 -0
  152. package/src/plugins.ts +23 -0
  153. package/dist/components/auth/magic-link-button.d.ts +0 -13
  154. package/dist/components/auth/magic-link-button.js +0 -16
  155. package/dist/components/auth/magic-link.d.ts +0 -17
  156. package/dist/components/auth/magic-link.js +0 -99
  157. package/dist/components/auth/passkey-button.d.ts +0 -4
  158. package/dist/components/auth/passkey-button.js +0 -21
  159. package/dist/components/email/magic-link-email.d.ts +0 -3
  160. package/dist/components/email/new-device-email.d.ts +0 -3
  161. package/dist/components/email/otp-email.d.ts +0 -3
  162. package/dist/components/settings/account/account-settings.js +0 -23
  163. package/dist/components/settings/account/appearance.js +0 -71
  164. package/dist/components/settings/account/change-avatar.js +0 -89
  165. package/dist/components/settings/account/manage-account.js +0 -48
  166. package/dist/components/settings/account/manage-accounts.js +0 -33
  167. package/dist/components/settings/account/user-profile.js +0 -103
  168. package/dist/components/settings/security/active-session.js +0 -59
  169. package/dist/components/settings/security/change-password.js +0 -189
  170. package/dist/components/settings/security/delete-user.js +0 -92
  171. package/dist/components/settings/security/linked-account.js +0 -56
  172. package/dist/components/settings/security/passkey.js +0 -43
  173. package/dist/components/settings/security/passkeys.js +0 -53
  174. package/dist/components/settings/security/security-settings.js +0 -25
  175. package/dist/components/settings/settings.js +0 -45
  176. package/dist/components/user/switch-account-item.js +0 -20
  177. package/dist/components/user/switch-account-menu.js +0 -28
  178. package/dist/components/user/user-avatar.js +0 -29
  179. package/dist/components/user/user-button.js +0 -91
  180. package/dist/components/user/user-view.js +0 -37
  181. package/dist/core.d.ts +0 -1
  182. package/dist/core.js +0 -1
  183. package/dist/react-exports.d.ts +0 -1
  184. package/dist/react-exports.js +0 -1
  185. package/src/components/auth/magic-link-button.tsx +0 -43
  186. package/src/components/auth/passkey-button.tsx +0 -35
  187. package/src/components/settings/account/user-profile.tsx +0 -217
  188. package/src/components/settings/security/passkeys.tsx +0 -96
  189. package/src/core.ts +0 -1
  190. package/src/react-exports.ts +0 -1
  191. /package/dist/components/{settings/security → auth/delete-user}/delete-user.d.ts +0 -0
  192. /package/dist/components/{settings/account → auth/multi-session}/manage-accounts.d.ts +0 -0
  193. /package/dist/components/{settings/security → auth/passkey}/passkey.d.ts +0 -0
  194. /package/dist/components/{settings/security → auth/passkey}/passkeys.d.ts +0 -0
  195. /package/dist/components/{settings → auth/settings}/account/change-avatar.d.ts +0 -0
  196. /package/dist/components/{settings → auth/settings}/account/change-email.d.ts +0 -0
  197. /package/dist/components/{settings → auth/settings}/security/active-session.d.ts +0 -0
  198. /package/dist/components/{settings → auth/settings}/security/active-sessions.d.ts +0 -0
  199. /package/dist/components/{settings → auth/settings}/security/change-password.d.ts +0 -0
  200. /package/dist/components/{settings → auth/settings}/security/linked-account.d.ts +0 -0
  201. /package/dist/components/{settings → auth/settings}/security/linked-accounts.d.ts +0 -0
  202. /package/dist/components/{settings → auth/settings}/settings.d.ts +0 -0
  203. /package/dist/components/{user → auth/user}/user-avatar.d.ts +0 -0
  204. /package/dist/components/{user → auth/user}/user-view.d.ts +0 -0
@@ -1,146 +1,122 @@
1
1
  import { FieldSeparator as e } from "./field-separator.js";
2
- import { MagicLinkButton as t } from "./magic-link-button.js";
3
- import { PasskeyButton as n } from "./passkey-button.js";
4
- import { ProviderButtons as r } from "./provider-buttons.js";
5
- import { useAuth as i, useSendVerificationEmail as a, useSignInEmail as o, useSignInUsername as s } from "@better-auth-ui/react";
6
- import { Button as c, Card as l, Checkbox as u, Description as d, FieldError as f, Form as p, Input as m, Label as h, Link as g, Spinner as _, TextField as v, cn as y, toast as b } from "@heroui/react";
7
- import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
8
- import { useState as w } from "react";
2
+ import { ProviderButtons as t } from "./provider-buttons.js";
3
+ import { authMutationKeys as n } from "@better-auth-ui/core";
4
+ import { useAuth as r, useSendVerificationEmail as i, useSignInEmail as a } from "@better-auth-ui/react";
5
+ import { Button as o, Card as s, Checkbox as c, Description as l, FieldError as u, Form as d, Input as f, Label as p, Link as m, Spinner as h, TextField as g, cn as _, toast as v } from "@heroui/react";
6
+ import { useState as y } from "react";
7
+ import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
8
+ import { useIsMutating as C } from "@tanstack/react-query";
9
9
  //#region src/components/auth/sign-in.tsx
10
- function T(e) {
11
- return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
12
- }
13
- function E({ className: E, socialLayout: D, socialPosition: O = "bottom", variant: k, ...A }) {
14
- let { basePaths: j, baseURL: M, emailAndPassword: N, localization: P, magicLink: F, passkey: I, redirectTo: L, socialProviders: R, username: z, viewPaths: B, navigate: V } = i(), [H, U] = w(""), { mutate: W } = a({ onSuccess: () => b.success(P.auth.verificationEmailSent) }), { mutate: G, isPending: K } = o({
10
+ function w({ className: w, socialLayout: T, socialPosition: E = "bottom", variant: D, ...O }) {
11
+ let { authClient: k, basePaths: A, baseURL: j, emailAndPassword: M, localization: N, plugins: P, redirectTo: F, socialProviders: I, viewPaths: L, navigate: R } = r(), [z, B] = y(""), { mutate: V } = i(k, { onSuccess: () => v.success(N.auth.verificationEmailSent) }), { mutate: H, isPending: U } = a(k, {
15
12
  onError: (e, { email: t }) => {
16
- U(""), e.error?.code === "EMAIL_NOT_VERIFIED" ? b.danger(e.error?.message || e.message, { actionProps: {
17
- children: P.auth.resend,
18
- onClick: () => W({
13
+ B(""), e.error?.code === "EMAIL_NOT_VERIFIED" ? v.danger(e.error?.message || e.message, { actionProps: {
14
+ children: N.auth.resend,
15
+ onClick: () => V({
19
16
  email: t,
20
- callbackURL: `${M}${L}`
17
+ callbackURL: `${j}${F}`
21
18
  })
22
- } }) : b.danger(e.error?.message || e.message);
23
- },
24
- onSuccess: () => V({ to: L })
25
- }), { mutate: q, isPending: J } = s({
26
- onError: (e) => {
27
- U(""), b.danger(e.error?.message || e.message);
19
+ } }) : v.danger(e.error?.message || e.message);
28
20
  },
29
- onSuccess: () => V({ to: L })
30
- }), Y = (e) => {
21
+ onSuccess: () => R({ to: F })
22
+ }), W = (e) => {
31
23
  e.preventDefault();
32
24
  let t = new FormData(e.currentTarget), n = t.get("email"), r = t.get("rememberMe") === "on";
33
- z?.enabled && !T(n) ? q({
34
- username: n,
35
- password: H
36
- }) : G({
25
+ H({
37
26
  email: n,
38
- password: H,
39
- ...N?.rememberMe ? { rememberMe: r } : {}
27
+ password: z,
28
+ ...M?.rememberMe ? { rememberMe: r } : {}
40
29
  });
41
- }, X = K || J, Z = N?.enabled && !!R?.length;
42
- return /* @__PURE__ */ C(l, {
43
- className: y("w-full max-w-sm gap-4 md:p-6", E),
44
- variant: k,
45
- ...A,
30
+ }, G = C({ mutationKey: n.signIn.all }) + C({ mutationKey: n.signUp.all }) > 0, K = M?.enabled && !!I?.length;
31
+ return /* @__PURE__ */ S(s, {
32
+ className: _("w-full max-w-sm gap-4 md:p-6", w),
33
+ variant: D,
34
+ ...O,
46
35
  children: [
47
- /* @__PURE__ */ S(l.Header, { children: /* @__PURE__ */ S(l.Title, {
36
+ /* @__PURE__ */ x(s.Header, { children: /* @__PURE__ */ x(s.Title, {
48
37
  className: "text-xl font-semibold mb-1",
49
- children: P.auth.signIn
38
+ children: N.auth.signIn
50
39
  }) }),
51
- /* @__PURE__ */ C(l.Content, {
40
+ /* @__PURE__ */ S(s.Content, {
52
41
  className: "gap-4",
53
42
  children: [
54
- O === "top" && /* @__PURE__ */ C(x, { children: [!!R?.length && /* @__PURE__ */ S(r, {
55
- socialLayout: D,
56
- isPending: X
57
- }), Z && /* @__PURE__ */ S(e, { children: P.auth.or })] }),
58
- N?.enabled && /* @__PURE__ */ C(p, {
59
- onSubmit: Y,
43
+ E === "top" && /* @__PURE__ */ S(b, { children: [!!I?.length && /* @__PURE__ */ x(t, { socialLayout: T }), K && /* @__PURE__ */ x(e, { children: N.auth.or })] }),
44
+ M?.enabled && /* @__PURE__ */ S(d, {
45
+ onSubmit: W,
60
46
  className: "flex flex-col gap-4",
61
47
  children: [
62
- /* @__PURE__ */ C(v, {
48
+ /* @__PURE__ */ S(g, {
63
49
  name: "email",
64
- type: z?.enabled ? "text" : "email",
65
- autoComplete: z?.enabled ? "username" : "email",
66
- isDisabled: X,
50
+ type: "email",
51
+ autoComplete: "email",
52
+ isDisabled: G,
67
53
  children: [
68
- /* @__PURE__ */ S(h, { children: z?.enabled ? P.auth.username : P.auth.email }),
69
- /* @__PURE__ */ S(m, {
70
- placeholder: z?.enabled ? P.auth.usernameOrEmailPlaceholder : P.auth.emailPlaceholder,
71
- variant: k === "transparent" ? "primary" : "secondary",
54
+ /* @__PURE__ */ x(p, { children: N.auth.email }),
55
+ /* @__PURE__ */ x(f, {
56
+ placeholder: N.auth.emailPlaceholder,
57
+ variant: D === "transparent" ? "primary" : "secondary",
72
58
  required: !0
73
59
  }),
74
- /* @__PURE__ */ S(f, {})
60
+ /* @__PURE__ */ x(u, {})
75
61
  ]
76
62
  }),
77
- /* @__PURE__ */ C(v, {
78
- minLength: N?.minPasswordLength,
79
- maxLength: N?.maxPasswordLength,
63
+ /* @__PURE__ */ S(g, {
64
+ minLength: M?.minPasswordLength,
65
+ maxLength: M?.maxPasswordLength,
80
66
  name: "password",
81
67
  type: "password",
82
68
  autoComplete: "current-password",
83
- isDisabled: X,
84
- value: H,
85
- onChange: U,
69
+ isDisabled: G,
70
+ value: z,
71
+ onChange: B,
86
72
  children: [
87
- /* @__PURE__ */ S(h, { children: P.auth.password }),
88
- /* @__PURE__ */ S(m, {
89
- placeholder: P.auth.passwordPlaceholder,
90
- variant: k === "transparent" ? "primary" : "secondary",
73
+ /* @__PURE__ */ x(p, { children: N.auth.password }),
74
+ /* @__PURE__ */ x(f, {
75
+ placeholder: N.auth.passwordPlaceholder,
76
+ variant: D === "transparent" ? "primary" : "secondary",
91
77
  required: !0
92
78
  }),
93
- /* @__PURE__ */ S(f, {})
79
+ /* @__PURE__ */ x(u, {})
94
80
  ]
95
81
  }),
96
- N?.rememberMe && /* @__PURE__ */ C(u, {
82
+ M?.rememberMe && /* @__PURE__ */ S(c, {
97
83
  name: "rememberMe",
98
- isDisabled: X,
99
- variant: k === "transparent" ? "primary" : "secondary",
100
- children: [/* @__PURE__ */ S(u.Control, { children: /* @__PURE__ */ S(u.Indicator, {}) }), /* @__PURE__ */ S(u.Content, { children: /* @__PURE__ */ S(h, { children: P.auth.rememberMe }) })]
84
+ isDisabled: G,
85
+ variant: D === "transparent" ? "primary" : "secondary",
86
+ children: [/* @__PURE__ */ x(c.Control, { children: /* @__PURE__ */ x(c.Indicator, {}) }), /* @__PURE__ */ x(c.Content, { children: /* @__PURE__ */ x(p, { children: N.auth.rememberMe }) })]
101
87
  }),
102
- /* @__PURE__ */ C("div", {
88
+ /* @__PURE__ */ S("div", {
103
89
  className: "flex flex-col gap-3",
104
- children: [
105
- /* @__PURE__ */ C(c, {
106
- type: "submit",
107
- className: "w-full",
108
- isPending: X,
109
- children: [X && /* @__PURE__ */ S(_, {
110
- color: "current",
111
- size: "sm"
112
- }), P.auth.signIn]
113
- }),
114
- F && /* @__PURE__ */ S(t, {
115
- view: "signIn",
116
- isPending: X
117
- }),
118
- I && /* @__PURE__ */ S(n, { isPending: X })
119
- ]
90
+ children: [/* @__PURE__ */ S(o, {
91
+ type: "submit",
92
+ className: "w-full",
93
+ isPending: G,
94
+ children: [U && /* @__PURE__ */ x(h, {
95
+ color: "current",
96
+ size: "sm"
97
+ }), N.auth.signIn]
98
+ }), P.flatMap((e) => e.authButtons?.map((t, n) => /* @__PURE__ */ x(t, { view: "signIn" }, `${e.id}-${n.toString()}`)))]
120
99
  })
121
100
  ]
122
101
  }),
123
- O === "bottom" && /* @__PURE__ */ C(x, { children: [Z && /* @__PURE__ */ S(e, { children: P.auth.or }), !!R?.length && /* @__PURE__ */ S(r, {
124
- socialLayout: D,
125
- isPending: X
126
- })] })
102
+ E === "bottom" && /* @__PURE__ */ S(b, { children: [K && /* @__PURE__ */ x(e, { children: N.auth.or }), !!I?.length && /* @__PURE__ */ x(t, { socialLayout: T })] })
127
103
  ]
128
104
  }),
129
- /* @__PURE__ */ C(l.Footer, {
105
+ /* @__PURE__ */ S(s.Footer, {
130
106
  className: "flex-col gap-3",
131
- children: [N?.forgotPassword && /* @__PURE__ */ S(g, {
132
- href: `${j.auth}/${B.auth.forgotPassword}`,
107
+ children: [M?.forgotPassword && /* @__PURE__ */ x(m, {
108
+ href: `${A.auth}/${L.auth.forgotPassword}`,
133
109
  className: "no-underline hover:underline",
134
- children: P.auth.forgotPasswordLink
135
- }), N?.enabled && /* @__PURE__ */ C(d, {
110
+ children: N.auth.forgotPasswordLink
111
+ }), M?.enabled && /* @__PURE__ */ S(l, {
136
112
  className: "text-sm",
137
113
  children: [
138
- P.auth.needToCreateAnAccount,
114
+ N.auth.needToCreateAnAccount,
139
115
  " ",
140
- /* @__PURE__ */ S(g, {
141
- href: `${j.auth}/${B.auth.signUp}`,
116
+ /* @__PURE__ */ x(m, {
117
+ href: `${A.auth}/${L.auth.signUp}`,
142
118
  className: "text-accent no-underline hover:underline decoration-accent-hover",
143
- children: P.auth.signUp
119
+ children: N.auth.signUp
144
120
  })
145
121
  ]
146
122
  })]
@@ -149,4 +125,4 @@ function E({ className: E, socialLayout: D, socialPosition: O = "bottom", varian
149
125
  });
150
126
  }
151
127
  //#endregion
152
- export { E as SignIn };
128
+ export { w as SignIn };
@@ -1,24 +1,24 @@
1
1
  import { useAuth as e, useSignOut as t } from "@better-auth-ui/react";
2
2
  import { Spinner as n, cn as r, toast as i } from "@heroui/react";
3
- import { jsx as a } from "react/jsx-runtime";
4
- import { useEffect as o, useRef as s } from "react";
3
+ import { useEffect as a, useRef as o } from "react";
4
+ import { jsx as s } from "react/jsx-runtime";
5
5
  //#region src/components/auth/sign-out.tsx
6
6
  function c({ className: c }) {
7
- let { basePaths: l, navigate: u, viewPaths: d } = e(), { mutate: f } = t({
7
+ let { authClient: l, basePaths: u, navigate: d, viewPaths: f } = e(), { mutate: p } = t(l, {
8
8
  onError: (e) => {
9
- i.danger(e.error?.message || e.message), u({
10
- to: `${l.auth}/${d.auth.signIn}`,
9
+ i.danger(e.error?.message || e.message), d({
10
+ to: `${u.auth}/${f.auth.signIn}`,
11
11
  replace: !0
12
12
  });
13
13
  },
14
- onSuccess: () => u({
15
- to: `${l.auth}/${d.auth.signIn}`,
14
+ onSuccess: () => d({
15
+ to: `${u.auth}/${f.auth.signIn}`,
16
16
  replace: !0
17
17
  })
18
- }), p = s(!1);
19
- return o(() => {
20
- p.current || (p.current = !0, f());
21
- }, [f]), /* @__PURE__ */ a(n, {
18
+ }), m = o(!1);
19
+ return a(() => {
20
+ m.current || (m.current = !0, p());
21
+ }, [p]), /* @__PURE__ */ s(n, {
22
22
  className: r("mx-auto my-auto", c),
23
23
  color: "current"
24
24
  });
@@ -1,226 +1,201 @@
1
- import { FieldSeparator as e } from "./field-separator.js";
2
- import { MagicLinkButton as t } from "./magic-link-button.js";
1
+ import { AdditionalField as e } from "./additional-field.js";
2
+ import { FieldSeparator as t } from "./field-separator.js";
3
3
  import { ProviderButtons as n } from "./provider-buttons.js";
4
- import { useAuth as r, useIsUsernameAvailable as i, useSignUpEmail as ee } from "@better-auth-ui/react";
5
- import { Button as a, Card as o, Description as te, FieldError as s, Form as ne, Input as c, InputGroup as l, Label as u, Link as re, Spinner as d, TextField as f, cn as p, toast as m } from "@heroui/react";
6
- import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
7
- import { useState as v } from "react";
8
- import { Check as y, Eye as b, EyeSlash as x, Xmark as S } from "@gravity-ui/icons";
9
- import { useDebouncer as C } from "@tanstack/react-pacer";
4
+ import { authMutationKeys as r, parseAdditionalFieldValue as i } from "@better-auth-ui/core";
5
+ import { useAuth as a, useSignUpEmail as o } from "@better-auth-ui/react";
6
+ import { Eye as s, EyeSlash as c } from "@gravity-ui/icons";
7
+ import { Button as l, Card as u, Description as d, FieldError as f, Form as p, Input as m, InputGroup as h, Label as g, Link as _, Spinner as v, TextField as y, cn as b, toast as x } from "@heroui/react";
8
+ import { useState as S } from "react";
9
+ import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
10
+ import { useIsMutating as E } from "@tanstack/react-query";
10
11
  //#region src/components/auth/sign-up.tsx
11
- function w({ className: w, socialLayout: T, socialPosition: E = "bottom", variant: D, ...O }) {
12
- let { basePaths: k, emailAndPassword: A, localization: j, magicLink: M, redirectTo: N, socialProviders: P, username: F, viewPaths: I, navigate: L } = r(), [R, z] = v(""), [B, V] = v(""), [H, U] = v(""), { mutate: W, data: G, error: K, reset: q } = i(), J = C((e) => {
13
- if (!e.trim()) {
14
- q();
15
- return;
16
- }
17
- W({ username: e.trim() });
18
- }, { wait: 500 });
19
- function Y(e) {
20
- U(e), q(), F?.isUsernameAvailable && J.maybeExecute(e);
21
- }
22
- let { mutate: ie, isPending: ae } = ee({
12
+ function D({ className: D, socialLayout: O, socialPosition: k = "bottom", variant: A, ...j }) {
13
+ let { additionalFields: M, authClient: ee, basePaths: N, emailAndPassword: P, localization: F, plugins: I, redirectTo: L, socialProviders: R, viewPaths: z, navigate: B } = a(), [V, H] = S(""), [U, W] = S(""), { mutate: G, isPending: K } = o(ee, {
23
14
  onError: (e) => {
24
- z(""), V(""), m.danger(e.error?.message || e.message);
15
+ H(""), W(""), x.danger(e.error?.message || e.message);
25
16
  },
26
17
  onSuccess: () => {
27
- A?.requireEmailVerification ? (m.success(j.auth.verifyYourEmail), L({ to: `${k.auth}/${I.auth.signIn}` })) : L({ to: N });
18
+ P?.requireEmailVerification ? (x.success(F.auth.verifyYourEmail), B({ to: `${N.auth}/${z.auth.signIn}` })) : B({ to: L });
28
19
  }
29
- }), [X, oe] = v(!1), [Z, se] = v(!1), Q = ae, ce = (e) => {
20
+ }), [q, J] = S(!1), [Y, X] = S(!1), Z = E({ mutationKey: r.signIn.all }) + E({ mutationKey: r.signUp.all }) > 0, Q = async (e) => {
30
21
  e.preventDefault();
31
- let t = new FormData(e.currentTarget), n = t.get("name"), r = t.get("email");
32
- if (A?.confirmPassword && R !== B) {
33
- m.danger(j.auth.passwordsDoNotMatch), z(""), V("");
22
+ let t = new FormData(e.currentTarget), n = t.get("name") ?? "", r = t.get("email");
23
+ if (P?.confirmPassword && V !== U) {
24
+ x.danger(F.auth.passwordsDoNotMatch), H(""), W("");
34
25
  return;
35
26
  }
36
- ie({
27
+ let a = {};
28
+ for (let e of M ?? []) {
29
+ if (!e.signUp || e.readOnly) continue;
30
+ let n = i(e, t.get(e.name));
31
+ if (e.validate) try {
32
+ await e.validate(n);
33
+ } catch (e) {
34
+ x.danger(e instanceof Error ? e.message : String(e));
35
+ return;
36
+ }
37
+ n !== void 0 && (a[e.name] = n);
38
+ }
39
+ G({
37
40
  name: n,
38
41
  email: r,
39
- password: R,
40
- ...F?.enabled ? {
41
- username: H.trim(),
42
- ...F.displayUsername ? { displayUsername: H.trim() } : {}
43
- } : {}
42
+ password: V,
43
+ ...a
44
44
  });
45
- }, $ = A?.enabled && !!P?.length;
46
- return /* @__PURE__ */ _(o, {
47
- className: p("w-full max-w-sm p-4 md:p-6", w),
48
- variant: D,
49
- ...O,
45
+ }, $ = P?.enabled && !!R?.length;
46
+ return /* @__PURE__ */ T(u, {
47
+ className: b("w-full max-w-sm gap-4 md:p-6", D),
48
+ variant: A,
49
+ ...j,
50
50
  children: [
51
- /* @__PURE__ */ g(o.Header, { children: /* @__PURE__ */ g(o.Title, {
51
+ /* @__PURE__ */ w(u.Header, { children: /* @__PURE__ */ w(u.Title, {
52
52
  className: "text-xl font-semibold mb-1",
53
- children: j.auth.signUp
53
+ children: F.auth.signUp
54
54
  }) }),
55
- /* @__PURE__ */ _(o.Content, {
55
+ /* @__PURE__ */ T(u.Content, {
56
56
  className: "gap-4",
57
57
  children: [
58
- E === "top" && /* @__PURE__ */ _(h, { children: [!!P?.length && /* @__PURE__ */ g(n, {
59
- isPending: Q,
60
- socialLayout: T
61
- }), $ && /* @__PURE__ */ g(e, { children: j.auth.or })] }),
62
- A?.enabled && /* @__PURE__ */ _(ne, {
63
- onSubmit: ce,
58
+ k === "top" && /* @__PURE__ */ T(C, { children: [!!R?.length && /* @__PURE__ */ w(n, { socialLayout: O }), $ && /* @__PURE__ */ w(t, { children: F.auth.or })] }),
59
+ P?.enabled && /* @__PURE__ */ T(p, {
60
+ onSubmit: Q,
64
61
  className: "flex flex-col gap-4",
65
62
  children: [
66
- /* @__PURE__ */ _(f, {
63
+ P.name !== !1 && /* @__PURE__ */ T(y, {
67
64
  name: "name",
68
65
  type: "text",
69
66
  autoComplete: "name",
70
- isDisabled: Q,
67
+ isDisabled: Z,
71
68
  children: [
72
- /* @__PURE__ */ g(u, { children: j.auth.name }),
73
- /* @__PURE__ */ g(c, {
74
- placeholder: j.auth.namePlaceholder,
69
+ /* @__PURE__ */ w(g, { children: F.auth.name }),
70
+ /* @__PURE__ */ w(m, {
71
+ placeholder: F.auth.namePlaceholder,
75
72
  required: !0,
76
- variant: D === "transparent" ? "primary" : "secondary"
77
- }),
78
- /* @__PURE__ */ g(s, {})
79
- ]
80
- }),
81
- F?.enabled && /* @__PURE__ */ _(f, {
82
- name: "username",
83
- type: "text",
84
- autoComplete: "username",
85
- minLength: F.minUsernameLength,
86
- maxLength: F.maxUsernameLength,
87
- isDisabled: Q,
88
- value: H,
89
- onChange: Y,
90
- isInvalid: !!K || G && !G.available,
91
- children: [
92
- /* @__PURE__ */ g(u, { children: j.auth.username }),
93
- /* @__PURE__ */ _(l, {
94
- variant: D === "transparent" ? "primary" : "secondary",
95
- children: [/* @__PURE__ */ g(l.Input, {
96
- placeholder: j.auth.usernamePlaceholder,
97
- required: !0
98
- }), F.isUsernameAvailable && H.trim() && /* @__PURE__ */ g(l.Suffix, {
99
- className: "px-2",
100
- children: G?.available ? /* @__PURE__ */ g(y, { className: "text-success" }) : K || G?.available === !1 ? /* @__PURE__ */ g(S, { className: "text-danger" }) : /* @__PURE__ */ g(d, {
101
- size: "sm",
102
- color: "current"
103
- })
104
- })]
73
+ variant: A === "transparent" ? "primary" : "secondary"
105
74
  }),
106
- /* @__PURE__ */ g(s, { children: K?.error?.message || K?.message || (G?.available === !1 ? j.auth.usernameTaken : null) })
75
+ /* @__PURE__ */ w(f, {})
107
76
  ]
108
77
  }),
109
- /* @__PURE__ */ _(f, {
78
+ /* @__PURE__ */ T(y, {
110
79
  name: "email",
111
80
  type: "email",
112
81
  autoComplete: "email",
113
- isDisabled: Q,
82
+ isDisabled: Z,
114
83
  children: [
115
- /* @__PURE__ */ g(u, { children: j.auth.email }),
116
- /* @__PURE__ */ g(c, {
117
- placeholder: j.auth.emailPlaceholder,
84
+ /* @__PURE__ */ w(g, { children: F.auth.email }),
85
+ /* @__PURE__ */ w(m, {
86
+ placeholder: F.auth.emailPlaceholder,
118
87
  required: !0,
119
- variant: D === "transparent" ? "primary" : "secondary"
88
+ variant: A === "transparent" ? "primary" : "secondary"
120
89
  }),
121
- /* @__PURE__ */ g(s, {})
90
+ /* @__PURE__ */ w(f, {})
122
91
  ]
123
92
  }),
124
- /* @__PURE__ */ _(f, {
125
- minLength: A?.minPasswordLength,
126
- maxLength: A?.maxPasswordLength,
93
+ M?.map((t) => t.signUp === "above" && /* @__PURE__ */ w(e, {
94
+ name: t.name,
95
+ field: t,
96
+ isPending: Z,
97
+ variant: A
98
+ }, t.name)),
99
+ /* @__PURE__ */ T(y, {
100
+ minLength: P?.minPasswordLength,
101
+ maxLength: P?.maxPasswordLength,
127
102
  name: "password",
128
103
  autoComplete: "new-password",
129
- isDisabled: Q,
130
- value: R,
131
- onChange: z,
104
+ isDisabled: Z,
105
+ value: V,
106
+ onChange: H,
132
107
  children: [
133
- /* @__PURE__ */ g(u, { children: j.auth.password }),
134
- /* @__PURE__ */ _(l, {
135
- variant: D === "transparent" ? "primary" : "secondary",
136
- children: [/* @__PURE__ */ g(l.Input, {
137
- placeholder: j.auth.passwordPlaceholder,
138
- type: X ? "text" : "password",
108
+ /* @__PURE__ */ w(g, { children: F.auth.password }),
109
+ /* @__PURE__ */ T(h, {
110
+ variant: A === "transparent" ? "primary" : "secondary",
111
+ children: [/* @__PURE__ */ w(h.Input, {
112
+ placeholder: F.auth.passwordPlaceholder,
113
+ type: q ? "text" : "password",
139
114
  name: "password",
140
115
  required: !0
141
- }), /* @__PURE__ */ g(l.Suffix, {
116
+ }), /* @__PURE__ */ w(h.Suffix, {
142
117
  className: "px-0",
143
- children: /* @__PURE__ */ g(a, {
118
+ children: /* @__PURE__ */ w(l, {
144
119
  isIconOnly: !0,
145
- "aria-label": X ? j.auth.hidePassword : j.auth.showPassword,
120
+ "aria-label": q ? F.auth.hidePassword : F.auth.showPassword,
146
121
  size: "sm",
147
122
  variant: "ghost",
148
- onPress: () => oe(!X),
149
- isDisabled: Q,
150
- children: g(X ? x : b, {})
123
+ onPress: () => J(!q),
124
+ isDisabled: Z,
125
+ children: w(q ? c : s, {})
151
126
  })
152
127
  })]
153
128
  }),
154
- /* @__PURE__ */ g(s, {})
129
+ /* @__PURE__ */ w(f, {})
155
130
  ]
156
131
  }),
157
- A?.confirmPassword && /* @__PURE__ */ _(f, {
158
- minLength: A?.minPasswordLength,
159
- maxLength: A?.maxPasswordLength,
132
+ P?.confirmPassword && /* @__PURE__ */ T(y, {
133
+ minLength: P?.minPasswordLength,
134
+ maxLength: P?.maxPasswordLength,
160
135
  name: "confirmPassword",
161
136
  autoComplete: "new-password",
162
- isDisabled: Q,
163
- value: B,
164
- onChange: V,
137
+ isDisabled: Z,
138
+ value: U,
139
+ onChange: W,
165
140
  children: [
166
- /* @__PURE__ */ g(u, { children: j.auth.confirmPassword }),
167
- /* @__PURE__ */ _(l, {
168
- variant: D === "transparent" ? "primary" : "secondary",
169
- children: [/* @__PURE__ */ g(l.Input, {
141
+ /* @__PURE__ */ w(g, { children: F.auth.confirmPassword }),
142
+ /* @__PURE__ */ T(h, {
143
+ variant: A === "transparent" ? "primary" : "secondary",
144
+ children: [/* @__PURE__ */ w(h.Input, {
170
145
  name: "confirmPassword",
171
- placeholder: j.auth.confirmPasswordPlaceholder,
172
- type: Z ? "text" : "password",
146
+ placeholder: F.auth.confirmPasswordPlaceholder,
147
+ type: Y ? "text" : "password",
173
148
  required: !0
174
- }), /* @__PURE__ */ g(l.Suffix, {
149
+ }), /* @__PURE__ */ w(h.Suffix, {
175
150
  className: "px-0",
176
- children: /* @__PURE__ */ g(a, {
151
+ children: /* @__PURE__ */ w(l, {
177
152
  isIconOnly: !0,
178
- "aria-label": Z ? j.auth.hidePassword : j.auth.showPassword,
153
+ "aria-label": Y ? F.auth.hidePassword : F.auth.showPassword,
179
154
  size: "sm",
180
155
  variant: "ghost",
181
- onPress: () => se(!Z),
182
- isDisabled: Q,
183
- children: g(Z ? x : b, {})
156
+ onPress: () => X(!Y),
157
+ isDisabled: Z,
158
+ children: w(Y ? c : s, {})
184
159
  })
185
160
  })]
186
161
  }),
187
- /* @__PURE__ */ g(s, {})
162
+ /* @__PURE__ */ w(f, {})
188
163
  ]
189
164
  }),
190
- /* @__PURE__ */ _("div", {
165
+ M?.map((t) => t.signUp && t.signUp !== "above" && /* @__PURE__ */ w(e, {
166
+ name: t.name,
167
+ field: t,
168
+ isPending: Z,
169
+ variant: A
170
+ }, t.name)),
171
+ /* @__PURE__ */ T("div", {
191
172
  className: "flex flex-col gap-3",
192
- children: [/* @__PURE__ */ _(a, {
173
+ children: [/* @__PURE__ */ T(l, {
193
174
  type: "submit",
194
175
  className: "w-full",
195
- isPending: Q,
196
- children: [Q && /* @__PURE__ */ g(d, {
176
+ isPending: Z,
177
+ children: [K && /* @__PURE__ */ w(v, {
197
178
  color: "current",
198
179
  size: "sm"
199
- }), j.auth.signUp]
200
- }), M && /* @__PURE__ */ g(t, {
201
- view: "signUp",
202
- isPending: Q
203
- })]
180
+ }), F.auth.signUp]
181
+ }), I.flatMap((e) => e.authButtons?.map((t, n) => /* @__PURE__ */ w(t, { view: "signUp" }, `${e.id}-${n.toString()}`)))]
204
182
  })
205
183
  ]
206
184
  }),
207
- E === "bottom" && /* @__PURE__ */ _(h, { children: [$ && /* @__PURE__ */ g(e, { children: j.auth.or }), !!P?.length && /* @__PURE__ */ g(n, {
208
- socialLayout: T,
209
- isPending: Q
210
- })] })
185
+ k === "bottom" && /* @__PURE__ */ T(C, { children: [$ && /* @__PURE__ */ w(t, { children: F.auth.or }), !!R?.length && /* @__PURE__ */ w(n, { socialLayout: O })] })
211
186
  ]
212
187
  }),
213
- /* @__PURE__ */ g(o.Footer, {
214
- className: "flex-col",
215
- children: /* @__PURE__ */ _(te, {
188
+ /* @__PURE__ */ w(u.Footer, {
189
+ className: "flex-col gap-3",
190
+ children: /* @__PURE__ */ T(d, {
216
191
  className: "text-sm",
217
192
  children: [
218
- j.auth.alreadyHaveAnAccount,
193
+ F.auth.alreadyHaveAnAccount,
219
194
  " ",
220
- /* @__PURE__ */ g(re, {
221
- href: `${k.auth}/${I.auth.signIn}`,
222
- className: "text-accent decoration-accent no-underline hover:underline",
223
- children: j.auth.signIn
195
+ /* @__PURE__ */ w(_, {
196
+ href: `${N.auth}/${z.auth.signIn}`,
197
+ className: "text-accent no-underline hover:underline decoration-accent-hover",
198
+ children: F.auth.signIn
224
199
  })
225
200
  ]
226
201
  })
@@ -229,4 +204,4 @@ function w({ className: w, socialLayout: T, socialPosition: E = "bottom", varian
229
204
  });
230
205
  }
231
206
  //#endregion
232
- export { w as SignUp };
207
+ export { D as SignUp };
@@ -7,10 +7,7 @@ export type AppearanceProps = {
7
7
  * Renders a theme selector card with visual theme previews.
8
8
  *
9
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.
10
+ * and dark themes. Each option shows a visual preview of the theme. Theme options
11
+ * are conditionally shown based on the `themes` array provided via the theme plugin.
15
12
  */
16
- export declare function Appearance({ className, variant, ...props }: AppearanceProps & Omit<CardProps, "children">): import("react/jsx-runtime").JSX.Element | null;
13
+ export declare function Appearance({ className, variant, ...props }: AppearanceProps & Omit<CardProps, "children">): import("react/jsx-runtime").JSX.Element;