@better-auth-ui/heroui 1.6.8 → 1.6.10

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 (195) hide show
  1. package/dist/components/auth/api-key/api-key.d.ts +5 -1
  2. package/dist/components/auth/api-key/api-keys-empty.d.ts +3 -1
  3. package/dist/components/auth/api-key/api-keys.d.ts +9 -1
  4. package/dist/components/auth/api-key/create-api-key-dialog.d.ts +3 -1
  5. package/dist/components/auth/api-key/delete-api-key-dialog.d.ts +3 -1
  6. package/dist/components/auth/api-key/organization-api-keys.d.ts +14 -0
  7. package/dist/components/auth/delete-user/danger-zone.d.ts +1 -1
  8. package/dist/components/auth/delete-user/{delete-user.d.ts → delete-account.d.ts} +2 -2
  9. package/dist/components/auth/email/organization-invitation-email.d.ts +3 -0
  10. package/dist/components/auth/multi-session/switch-account-submenu-content.d.ts +3 -1
  11. package/dist/components/auth/multi-session/switch-account-submenu-item.d.ts +2 -1
  12. package/dist/components/auth/multi-session/switch-account-submenu.d.ts +2 -1
  13. package/dist/components/auth/organization/change-organization-logo.d.ts +4 -0
  14. package/dist/components/auth/organization/create-organization-dialog.d.ts +13 -0
  15. package/dist/components/auth/organization/delete-organization-dialog.d.ts +7 -0
  16. package/dist/components/auth/organization/delete-organization-skeleton.d.ts +4 -0
  17. package/dist/components/auth/organization/delete-organization.d.ts +5 -0
  18. package/dist/components/auth/organization/invite-member-dialog.d.ts +13 -0
  19. package/dist/components/auth/organization/leave-organization-dialog.d.ts +7 -0
  20. package/dist/components/auth/organization/leave-organization.d.ts +4 -0
  21. package/dist/components/auth/organization/organization-danger-zone.d.ts +16 -0
  22. package/dist/components/auth/organization/organization-invitation-row-skeleton.d.ts +5 -0
  23. package/dist/components/auth/organization/organization-invitation-row.d.ts +5 -0
  24. package/dist/components/auth/organization/organization-invitations-empty.d.ts +8 -0
  25. package/dist/components/auth/organization/organization-invitations.d.ts +9 -0
  26. package/dist/components/auth/organization/organization-logo.d.ts +15 -0
  27. package/dist/components/auth/organization/organization-member-row-skeleton.d.ts +4 -0
  28. package/dist/components/auth/organization/organization-member-row.d.ts +9 -0
  29. package/dist/components/auth/organization/organization-members.d.ts +9 -0
  30. package/dist/components/auth/organization/organization-people.d.ts +10 -0
  31. package/dist/components/auth/organization/organization-profile.d.ts +9 -0
  32. package/dist/components/auth/organization/organization-row.d.ts +8 -0
  33. package/dist/components/auth/organization/organization-settings.d.ts +12 -0
  34. package/dist/components/auth/organization/organization-switcher.d.ts +20 -0
  35. package/dist/components/auth/organization/organization-view-skeleton.d.ts +6 -0
  36. package/dist/components/auth/organization/organization-view.d.ts +15 -0
  37. package/dist/components/auth/organization/organization.d.ts +17 -0
  38. package/dist/components/auth/organization/organizations-empty.d.ts +4 -0
  39. package/dist/components/auth/organization/organizations-settings.d.ts +17 -0
  40. package/dist/components/auth/organization/organizations.d.ts +10 -0
  41. package/dist/components/auth/organization/remove-member-dialog.d.ts +9 -0
  42. package/dist/components/auth/organization/slug-field.d.ts +19 -0
  43. package/dist/components/auth/organization/user-invitation-row-skeleton.d.ts +4 -0
  44. package/dist/components/auth/organization/user-invitation-row.d.ts +10 -0
  45. package/dist/components/auth/organization/user-invitations-empty.d.ts +4 -0
  46. package/dist/components/auth/organization/user-invitations.d.ts +10 -0
  47. package/dist/components/auth/settings/settings.d.ts +1 -1
  48. package/dist/components/auth/user/user-avatar.d.ts +1 -1
  49. package/dist/components/auth/user/user-button.d.ts +4 -5
  50. package/dist/components/auth/user/user-view.d.ts +10 -4
  51. package/dist/email.d.ts +1 -0
  52. package/dist/email.js +211 -8
  53. package/dist/index.js +1682 -22
  54. package/dist/lib/auth/api-key-plugin.d.ts +5 -2
  55. package/dist/lib/auth/auth-plugin.d.ts +6 -2
  56. package/dist/lib/auth/delete-user-plugin.d.ts +4 -4
  57. package/dist/lib/auth/magic-link-plugin.d.ts +2 -2
  58. package/dist/lib/auth/multi-session-plugin.d.ts +2 -2
  59. package/dist/lib/auth/organization-plugin.d.ts +37 -0
  60. package/dist/lib/auth/passkey-plugin.d.ts +2 -2
  61. package/dist/lib/auth/theme-plugin.d.ts +3 -3
  62. package/dist/lib/auth/username-plugin.d.ts +8 -8
  63. package/dist/plugins.d.ts +25 -1
  64. package/dist/plugins.js +2824 -22
  65. package/dist/user-view--47tVtJ3.js +113 -0
  66. package/package.json +23 -18
  67. package/src/components/auth/api-key/api-key.tsx +25 -16
  68. package/src/components/auth/api-key/api-keys-empty.tsx +8 -4
  69. package/src/components/auth/api-key/api-keys.tsx +52 -14
  70. package/src/components/auth/api-key/create-api-key-dialog.tsx +15 -2
  71. package/src/components/auth/api-key/delete-api-key-dialog.tsx +10 -2
  72. package/src/components/auth/api-key/organization-api-keys.tsx +55 -0
  73. package/src/components/auth/delete-user/danger-zone.tsx +3 -3
  74. package/src/components/auth/delete-user/{delete-user.tsx → delete-account.tsx} +9 -9
  75. package/src/components/auth/email/organization-invitation-email.tsx +38 -0
  76. package/src/components/auth/error-toaster.tsx +28 -10
  77. package/src/components/auth/forgot-password.tsx +10 -2
  78. package/src/components/auth/multi-session/manage-accounts.tsx +1 -1
  79. package/src/components/auth/multi-session/switch-account-submenu-content.tsx +7 -2
  80. package/src/components/auth/multi-session/switch-account-submenu-item.tsx +4 -2
  81. package/src/components/auth/multi-session/switch-account-submenu.tsx +8 -4
  82. package/src/components/auth/organization/change-organization-logo.tsx +171 -0
  83. package/src/components/auth/organization/create-organization-dialog.tsx +133 -0
  84. package/src/components/auth/organization/delete-organization-dialog.tsx +97 -0
  85. package/src/components/auth/organization/delete-organization-skeleton.tsx +17 -0
  86. package/src/components/auth/organization/delete-organization.tsx +77 -0
  87. package/src/components/auth/organization/invite-member-dialog.tsx +177 -0
  88. package/src/components/auth/organization/leave-organization-dialog.tsx +95 -0
  89. package/src/components/auth/organization/leave-organization.tsx +59 -0
  90. package/src/components/auth/organization/organization-danger-zone.tsx +68 -0
  91. package/src/components/auth/organization/organization-invitation-row-skeleton.tsx +29 -0
  92. package/src/components/auth/organization/organization-invitation-row.tsx +97 -0
  93. package/src/components/auth/organization/organization-invitations-empty.tsx +39 -0
  94. package/src/components/auth/organization/organization-invitations.tsx +351 -0
  95. package/src/components/auth/organization/organization-logo.tsx +64 -0
  96. package/src/components/auth/organization/organization-member-row-skeleton.tsx +24 -0
  97. package/src/components/auth/organization/organization-member-row.tsx +157 -0
  98. package/src/components/auth/organization/organization-members.tsx +284 -0
  99. package/src/components/auth/organization/organization-people.tsx +26 -0
  100. package/src/components/auth/organization/organization-profile.tsx +141 -0
  101. package/src/components/auth/organization/organization-row.tsx +66 -0
  102. package/src/components/auth/organization/organization-settings.tsx +38 -0
  103. package/src/components/auth/organization/organization-switcher.tsx +233 -0
  104. package/src/components/auth/organization/organization-view-skeleton.tsx +36 -0
  105. package/src/components/auth/organization/organization-view.tsx +109 -0
  106. package/src/components/auth/organization/organization.tsx +162 -0
  107. package/src/components/auth/organization/organizations-empty.tsx +35 -0
  108. package/src/components/auth/organization/organizations-settings.tsx +36 -0
  109. package/src/components/auth/organization/organizations.tsx +80 -0
  110. package/src/components/auth/organization/remove-member-dialog.tsx +95 -0
  111. package/src/components/auth/organization/slug-field.tsx +111 -0
  112. package/src/components/auth/organization/user-invitation-row-skeleton.tsx +17 -0
  113. package/src/components/auth/organization/user-invitation-row.tsx +90 -0
  114. package/src/components/auth/organization/user-invitations-empty.tsx +30 -0
  115. package/src/components/auth/organization/user-invitations.tsx +59 -0
  116. package/src/components/auth/settings/account/change-email.tsx +1 -1
  117. package/src/components/auth/settings/account/user-profile.tsx +5 -5
  118. package/src/components/auth/settings/security/active-sessions.tsx +6 -4
  119. package/src/components/auth/settings/security/linked-accounts.tsx +2 -2
  120. package/src/components/auth/settings/settings.tsx +77 -14
  121. package/src/components/auth/user/user-avatar.tsx +4 -1
  122. package/src/components/auth/user/user-button.tsx +14 -11
  123. package/src/components/auth/user/user-view.tsx +32 -12
  124. package/src/email.ts +1 -0
  125. package/src/lib/auth/api-key-plugin.ts +10 -4
  126. package/src/lib/auth/auth-plugin.ts +6 -1
  127. package/src/lib/auth/organization-plugin.tsx +32 -0
  128. package/src/plugins.ts +25 -1
  129. package/dist/components/auth/additional-field.js +0 -270
  130. package/dist/components/auth/api-key/api-key-skeleton.js +0 -21
  131. package/dist/components/auth/api-key/api-key.js +0 -55
  132. package/dist/components/auth/api-key/api-keys-empty.js +0 -35
  133. package/dist/components/auth/api-key/api-keys.js +0 -41
  134. package/dist/components/auth/api-key/create-api-key-dialog.js +0 -74
  135. package/dist/components/auth/api-key/delete-api-key-dialog.js +0 -51
  136. package/dist/components/auth/api-key/new-api-key-dialog.js +0 -60
  137. package/dist/components/auth/auth-provider.js +0 -17
  138. package/dist/components/auth/auth.js +0 -63
  139. package/dist/components/auth/delete-user/danger-zone.js +0 -18
  140. package/dist/components/auth/delete-user/delete-user.js +0 -95
  141. package/dist/components/auth/email/email-changed-email.js +0 -30
  142. package/dist/components/auth/email/email-verification-email.js +0 -30
  143. package/dist/components/auth/email/magic-link-email.js +0 -30
  144. package/dist/components/auth/email/new-device-email.js +0 -30
  145. package/dist/components/auth/email/otp-email.js +0 -29
  146. package/dist/components/auth/email/password-changed-email.js +0 -30
  147. package/dist/components/auth/email/reset-password-email.js +0 -30
  148. package/dist/components/auth/error-toaster.js +0 -17
  149. package/dist/components/auth/field-separator.js +0 -18
  150. package/dist/components/auth/forgot-password.js +0 -89
  151. package/dist/components/auth/magic-link/magic-link-button.js +0 -20
  152. package/dist/components/auth/magic-link/magic-link.js +0 -87
  153. package/dist/components/auth/multi-session/manage-account.js +0 -49
  154. package/dist/components/auth/multi-session/manage-accounts.js +0 -34
  155. package/dist/components/auth/multi-session/switch-account-submenu-content.js +0 -28
  156. package/dist/components/auth/multi-session/switch-account-submenu-item.js +0 -20
  157. package/dist/components/auth/multi-session/switch-account-submenu.js +0 -24
  158. package/dist/components/auth/passkey/add-passkey-dialog.js +0 -65
  159. package/dist/components/auth/passkey/delete-passkey-dialog.js +0 -47
  160. package/dist/components/auth/passkey/passkey-button.js +0 -24
  161. package/dist/components/auth/passkey/passkey-skeleton.js +0 -17
  162. package/dist/components/auth/passkey/passkey.js +0 -48
  163. package/dist/components/auth/passkey/passkeys-empty.js +0 -35
  164. package/dist/components/auth/passkey/passkeys.js +0 -42
  165. package/dist/components/auth/provider-button.js +0 -25
  166. package/dist/components/auth/provider-buttons.js +0 -19
  167. package/dist/components/auth/reset-password.js +0 -147
  168. package/dist/components/auth/settings/account/account-settings.js +0 -20
  169. package/dist/components/auth/settings/account/change-avatar.js +0 -89
  170. package/dist/components/auth/settings/account/change-email.js +0 -54
  171. package/dist/components/auth/settings/account/user-profile.js +0 -86
  172. package/dist/components/auth/settings/security/active-session.js +0 -59
  173. package/dist/components/auth/settings/security/active-sessions.js +0 -34
  174. package/dist/components/auth/settings/security/change-password.js +0 -189
  175. package/dist/components/auth/settings/security/linked-account.js +0 -56
  176. package/dist/components/auth/settings/security/linked-accounts.js +0 -45
  177. package/dist/components/auth/settings/security/security-settings.js +0 -22
  178. package/dist/components/auth/settings/settings.js +0 -45
  179. package/dist/components/auth/sign-in.js +0 -133
  180. package/dist/components/auth/sign-out.js +0 -27
  181. package/dist/components/auth/sign-up.js +0 -212
  182. package/dist/components/auth/theme/appearance.js +0 -72
  183. package/dist/components/auth/theme/theme-toggle-item.js +0 -62
  184. package/dist/components/auth/user/user-avatar.js +0 -29
  185. package/dist/components/auth/user/user-button.js +0 -74
  186. package/dist/components/auth/user/user-view.js +0 -37
  187. package/dist/components/auth/username/sign-in-username.js +0 -148
  188. package/dist/components/auth/username/username-field.js +0 -53
  189. package/dist/lib/auth/api-key-plugin.js +0 -10
  190. package/dist/lib/auth/delete-user-plugin.js +0 -10
  191. package/dist/lib/auth/magic-link-plugin.js +0 -13
  192. package/dist/lib/auth/multi-session-plugin.js +0 -12
  193. package/dist/lib/auth/passkey-plugin.js +0 -12
  194. package/dist/lib/auth/theme-plugin.js +0 -23
  195. package/dist/lib/auth/username-plugin.js +0 -18
@@ -1,212 +0,0 @@
1
- import { AdditionalField as e } from "./additional-field.js";
2
- import { FieldSeparator as t } from "./field-separator.js";
3
- import { ProviderButtons as n } from "./provider-buttons.js";
4
- import { authMutationKeys as r, parseAdditionalFieldValue as i } from "@better-auth-ui/core";
5
- import { useAuth as a, useFetchOptions as o, useSignUpEmail as ee } 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 te, Input as p, InputGroup as m, Label as h, Link as g, Spinner as _, TextField as v, cn as y, toast as b } from "@heroui/react";
8
- import { useState as x } from "react";
9
- import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
10
- import { useIsMutating as T } from "@tanstack/react-query";
11
- //#region src/components/auth/sign-up.tsx
12
- function E({ className: E, socialLayout: D, socialPosition: O = "bottom", variant: k, ...A }) {
13
- let { additionalFields: j, authClient: M, basePaths: N, emailAndPassword: P, localization: F, plugins: I, redirectTo: L, socialProviders: R, viewPaths: z, navigate: B } = a(), { fetchOptions: V, resetFetchOptions: H } = o(), [U, W] = x(""), [G, K] = x(""), { mutate: q, isPending: J } = ee(M, {
14
- onError: (e) => {
15
- W(""), K(""), b.danger(e.error?.message || e.message), H();
16
- },
17
- onSuccess: () => {
18
- P?.requireEmailVerification ? (b.success(F.auth.verifyYourEmail), B({ to: `${N.auth}/${z.auth.signIn}` })) : B({ to: L });
19
- }
20
- }), [Y, ne] = x(!1), [X, re] = x(!1), Z = T({ mutationKey: r.signIn.all }) + T({ mutationKey: r.signUp.all }) > 0, Q = I.find((e) => e.captchaComponent)?.captchaComponent, ie = async (e) => {
21
- e.preventDefault();
22
- let t = new FormData(e.currentTarget), n = t.get("name") ?? "", r = t.get("email");
23
- if (P?.confirmPassword && U !== G) {
24
- b.danger(F.auth.passwordsDoNotMatch), W(""), K("");
25
- return;
26
- }
27
- let a = {};
28
- for (let e of j ?? []) {
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
- b.danger(e instanceof Error ? e.message : String(e));
35
- return;
36
- }
37
- n !== void 0 && (a[e.name] = n);
38
- }
39
- q({
40
- name: n,
41
- email: r,
42
- password: U,
43
- ...a,
44
- fetchOptions: V
45
- });
46
- }, $ = P?.enabled && !!R?.length;
47
- return /* @__PURE__ */ w(u, {
48
- className: y("w-full max-w-sm gap-4 md:p-6", E),
49
- variant: k,
50
- ...A,
51
- children: [
52
- /* @__PURE__ */ C(u.Header, { children: /* @__PURE__ */ C(u.Title, {
53
- className: "text-xl font-semibold mb-1",
54
- children: F.auth.signUp
55
- }) }),
56
- /* @__PURE__ */ w(u.Content, {
57
- className: "gap-4",
58
- children: [
59
- O === "top" && /* @__PURE__ */ w(S, { children: [!!R?.length && /* @__PURE__ */ C(n, { socialLayout: D }), $ && /* @__PURE__ */ C(t, { children: F.auth.or })] }),
60
- P?.enabled && /* @__PURE__ */ w(te, {
61
- onSubmit: ie,
62
- className: "flex flex-col gap-4",
63
- children: [
64
- P.name !== !1 && /* @__PURE__ */ w(v, {
65
- name: "name",
66
- type: "text",
67
- autoComplete: "name",
68
- isDisabled: Z,
69
- children: [
70
- /* @__PURE__ */ C(h, { children: F.auth.name }),
71
- /* @__PURE__ */ C(p, {
72
- placeholder: F.auth.namePlaceholder,
73
- required: !0,
74
- variant: k === "transparent" ? "primary" : "secondary"
75
- }),
76
- /* @__PURE__ */ C(f, {})
77
- ]
78
- }),
79
- /* @__PURE__ */ w(v, {
80
- name: "email",
81
- type: "email",
82
- autoComplete: "email",
83
- isDisabled: Z,
84
- children: [
85
- /* @__PURE__ */ C(h, { children: F.auth.email }),
86
- /* @__PURE__ */ C(p, {
87
- placeholder: F.auth.emailPlaceholder,
88
- required: !0,
89
- variant: k === "transparent" ? "primary" : "secondary"
90
- }),
91
- /* @__PURE__ */ C(f, {})
92
- ]
93
- }),
94
- j?.map((t) => t.signUp === "above" && /* @__PURE__ */ C(e, {
95
- name: t.name,
96
- field: t,
97
- isPending: Z,
98
- variant: k
99
- }, t.name)),
100
- /* @__PURE__ */ w(v, {
101
- minLength: P?.minPasswordLength,
102
- maxLength: P?.maxPasswordLength,
103
- name: "password",
104
- autoComplete: "new-password",
105
- isDisabled: Z,
106
- value: U,
107
- onChange: W,
108
- children: [
109
- /* @__PURE__ */ C(h, { children: F.auth.password }),
110
- /* @__PURE__ */ w(m, {
111
- variant: k === "transparent" ? "primary" : "secondary",
112
- children: [/* @__PURE__ */ C(m.Input, {
113
- placeholder: F.auth.passwordPlaceholder,
114
- type: Y ? "text" : "password",
115
- name: "password",
116
- required: !0
117
- }), /* @__PURE__ */ C(m.Suffix, {
118
- className: "px-0",
119
- children: /* @__PURE__ */ C(l, {
120
- isIconOnly: !0,
121
- "aria-label": Y ? F.auth.hidePassword : F.auth.showPassword,
122
- size: "sm",
123
- variant: "ghost",
124
- onPress: () => ne(!Y),
125
- isDisabled: Z,
126
- children: C(Y ? c : s, {})
127
- })
128
- })]
129
- }),
130
- /* @__PURE__ */ C(f, {})
131
- ]
132
- }),
133
- P?.confirmPassword && /* @__PURE__ */ w(v, {
134
- minLength: P?.minPasswordLength,
135
- maxLength: P?.maxPasswordLength,
136
- name: "confirmPassword",
137
- autoComplete: "new-password",
138
- isDisabled: Z,
139
- value: G,
140
- onChange: K,
141
- children: [
142
- /* @__PURE__ */ C(h, { children: F.auth.confirmPassword }),
143
- /* @__PURE__ */ w(m, {
144
- variant: k === "transparent" ? "primary" : "secondary",
145
- children: [/* @__PURE__ */ C(m.Input, {
146
- name: "confirmPassword",
147
- placeholder: F.auth.confirmPasswordPlaceholder,
148
- type: X ? "text" : "password",
149
- required: !0
150
- }), /* @__PURE__ */ C(m.Suffix, {
151
- className: "px-0",
152
- children: /* @__PURE__ */ C(l, {
153
- isIconOnly: !0,
154
- "aria-label": X ? F.auth.hidePassword : F.auth.showPassword,
155
- size: "sm",
156
- variant: "ghost",
157
- onPress: () => re(!X),
158
- isDisabled: Z,
159
- children: C(X ? c : s, {})
160
- })
161
- })]
162
- }),
163
- /* @__PURE__ */ C(f, {})
164
- ]
165
- }),
166
- j?.map((t) => t.signUp && t.signUp !== "above" && /* @__PURE__ */ C(e, {
167
- name: t.name,
168
- field: t,
169
- isPending: Z,
170
- variant: k
171
- }, t.name)),
172
- Q && /* @__PURE__ */ C("div", {
173
- className: "flex justify-center",
174
- children: Q
175
- }),
176
- /* @__PURE__ */ w("div", {
177
- className: "flex flex-col gap-3",
178
- children: [/* @__PURE__ */ w(l, {
179
- type: "submit",
180
- className: "w-full",
181
- isPending: Z,
182
- children: [J && /* @__PURE__ */ C(_, {
183
- color: "current",
184
- size: "sm"
185
- }), F.auth.signUp]
186
- }), I.flatMap((e) => e.authButtons?.map((t, n) => /* @__PURE__ */ C(t, { view: "signUp" }, `${e.id}-${n.toString()}`)))]
187
- })
188
- ]
189
- }),
190
- O === "bottom" && /* @__PURE__ */ w(S, { children: [$ && /* @__PURE__ */ C(t, { children: F.auth.or }), !!R?.length && /* @__PURE__ */ C(n, { socialLayout: D })] })
191
- ]
192
- }),
193
- /* @__PURE__ */ C(u.Footer, {
194
- className: "flex-col gap-3",
195
- children: /* @__PURE__ */ w(d, {
196
- className: "text-sm",
197
- children: [
198
- F.auth.alreadyHaveAnAccount,
199
- " ",
200
- /* @__PURE__ */ C(g, {
201
- href: `${N.auth}/${z.auth.signIn}`,
202
- className: "text-accent no-underline hover:underline decoration-accent-hover",
203
- children: F.auth.signIn
204
- })
205
- ]
206
- })
207
- })
208
- ]
209
- });
210
- }
211
- //#endregion
212
- export { E as SignUp };
@@ -1,72 +0,0 @@
1
- import { themePlugin as e } from "../../../lib/auth/theme-plugin.js";
2
- import { ThemePreviewDark as t, ThemePreviewLight as n, ThemePreviewSystem as r, useAuthPlugin as i } from "@better-auth-ui/react";
3
- import { Display as a, Moon as o, Sun as s } from "@gravity-ui/icons";
4
- import { Card as c, Label as l, Radio as u, RadioGroup as d, cn as f, useIsHydrated as p } from "@heroui/react";
5
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
6
- //#region src/components/auth/theme/appearance.tsx
7
- function g({ className: g, variant: _, ...v }) {
8
- let { useTheme: y, localization: b } = i(e), { theme: x, setTheme: S, themes: C = [] } = y(), w = p();
9
- return /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("h2", {
10
- className: f("text-sm font-semibold mb-3"),
11
- children: b.appearance
12
- }), /* @__PURE__ */ m(c, {
13
- className: f("p-4 gap-4", g),
14
- variant: _,
15
- ...v,
16
- children: /* @__PURE__ */ h(c.Content, { children: [/* @__PURE__ */ m(l, { children: b.theme }), /* @__PURE__ */ m(d, {
17
- variant: _ === "transparent" ? "secondary" : "primary",
18
- value: w ? x : "",
19
- onChange: S,
20
- isDisabled: !w || !x,
21
- children: /* @__PURE__ */ h("div", {
22
- className: "grid gap-3 grid-cols-2 sm:grid-cols-3",
23
- children: [
24
- C.includes("system") && /* @__PURE__ */ m(u, {
25
- value: "system",
26
- className: f("mt-0 px-4 pb-4 pt-3 rounded-xl", "border border-transparent data-[selected=true]:border-accent data-[selected=true]:bg-accent/10", "data-[focus-visible=true]:border-accent data-[focus-visible=true]:bg-accent/10", _ === "transparent" ? "bg-surface" : "bg-surface-secondary"),
27
- children: /* @__PURE__ */ h(u.Content, {
28
- className: "gap-2",
29
- children: [/* @__PURE__ */ h("div", {
30
- className: "flex gap-2 justify-between",
31
- children: [/* @__PURE__ */ h(l, {
32
- className: "flex gap-2 items-center",
33
- children: [/* @__PURE__ */ m(a, { className: "text-muted" }), b.system]
34
- }), /* @__PURE__ */ m(u.Control, { children: /* @__PURE__ */ m(u.Indicator, {}) })]
35
- }), /* @__PURE__ */ m(r, { className: "w-full" })]
36
- })
37
- }),
38
- C.includes("light") && /* @__PURE__ */ m(u, {
39
- value: "light",
40
- className: f("mt-0 px-4 pb-4 pt-3 rounded-xl", "border border-transparent data-[selected=true]:border-accent data-[selected=true]:bg-accent/10", "data-[focus-visible=true]:border-accent data-[focus-visible=true]:bg-accent/10", _ === "transparent" ? "bg-surface" : "bg-surface-secondary"),
41
- children: /* @__PURE__ */ h(u.Content, {
42
- className: "gap-2",
43
- children: [/* @__PURE__ */ h("div", {
44
- className: "flex gap-2 justify-between",
45
- children: [/* @__PURE__ */ h(l, {
46
- className: "flex gap-2 items-center",
47
- children: [/* @__PURE__ */ m(s, { className: "text-muted" }), b.light]
48
- }), /* @__PURE__ */ m(u.Control, { children: /* @__PURE__ */ m(u.Indicator, {}) })]
49
- }), /* @__PURE__ */ m(n, { className: "w-full" })]
50
- })
51
- }),
52
- C.includes("dark") && /* @__PURE__ */ m(u, {
53
- value: "dark",
54
- className: f("mt-0 px-4 pb-4 pt-3 rounded-xl", "border border-transparent data-[selected=true]:border-accent data-[selected=true]:bg-accent/10", "data-[focus-visible=true]:border-accent data-[focus-visible=true]:bg-accent/10", _ === "transparent" ? "bg-surface" : "bg-surface-secondary"),
55
- children: /* @__PURE__ */ h(u.Content, {
56
- className: "gap-2",
57
- children: [/* @__PURE__ */ h("div", {
58
- className: "flex gap-2 justify-between",
59
- children: [/* @__PURE__ */ h(l, {
60
- className: "flex gap-2 items-center",
61
- children: [/* @__PURE__ */ m(o, { className: "text-muted" }), b.dark]
62
- }), /* @__PURE__ */ m(u.Control, { children: /* @__PURE__ */ m(u.Indicator, {}) })]
63
- }), /* @__PURE__ */ m(t, { className: "w-full" })]
64
- })
65
- })
66
- ]
67
- })
68
- })] })
69
- })] });
70
- }
71
- //#endregion
72
- export { g as Appearance };
@@ -1,62 +0,0 @@
1
- import { themePlugin as e } from "../../../lib/auth/theme-plugin.js";
2
- import { useAuthPlugin as t } from "@better-auth-ui/react";
3
- import { Display as n, Moon as r, Palette as i, Sun as a } from "@gravity-ui/icons";
4
- import { Dropdown as o, Label as s, Tabs as c } from "@heroui/react";
5
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
6
- //#region src/components/auth/theme/theme-toggle-item.tsx
7
- var d = "[role=\"tab\"][aria-selected=\"true\"]";
8
- function f() {
9
- let { useTheme: f, localization: p } = t(e), { theme: m, setTheme: h, themes: g = [] } = f();
10
- return /* @__PURE__ */ u(o.Item, {
11
- className: "py-1 pe-2",
12
- onFocus: (e) => {
13
- e.target === e.currentTarget && e.currentTarget.querySelector(d)?.focus({ preventScroll: !0 });
14
- },
15
- shouldCloseOnSelect: !1,
16
- children: [
17
- /* @__PURE__ */ l(i, { className: "text-muted" }),
18
- /* @__PURE__ */ l(s, { children: p.theme }),
19
- /* @__PURE__ */ l(c, {
20
- className: "ml-auto",
21
- selectedKey: m,
22
- onSelectionChange: (e) => h(e),
23
- children: /* @__PURE__ */ l(c.ListContainer, {
24
- onKeyDown: (e) => {
25
- if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
26
- let t = e.target;
27
- if (t.getAttribute("role") !== "tab") return;
28
- let n = t.closest("[role=\"menuitem\"]"), r = n?.closest("[role=\"menu\"]");
29
- if (!n || !r) return;
30
- let i = Array.from(r.querySelectorAll("[role=\"menuitem\"]:not([data-disabled])")), a = i.indexOf(n);
31
- if (a === -1) return;
32
- let o = i[e.key === "ArrowDown" ? a + 1 : a - 1];
33
- o && (e.preventDefault(), o.focus());
34
- },
35
- children: /* @__PURE__ */ u(c.List, {
36
- "aria-label": p.theme,
37
- className: "*:h-5 *:w-5 *:p-0",
38
- children: [
39
- g.includes("system") && /* @__PURE__ */ u(c.Tab, {
40
- id: "system",
41
- "aria-label": p.system,
42
- children: [/* @__PURE__ */ l(n, { className: "size-3" }), /* @__PURE__ */ l(c.Indicator, {})]
43
- }),
44
- g.includes("light") && /* @__PURE__ */ u(c.Tab, {
45
- id: "light",
46
- "aria-label": p.light,
47
- children: [/* @__PURE__ */ l(a, { className: "size-3" }), /* @__PURE__ */ l(c.Indicator, {})]
48
- }),
49
- g.includes("dark") && /* @__PURE__ */ u(c.Tab, {
50
- id: "dark",
51
- "aria-label": p.dark,
52
- children: [/* @__PURE__ */ l(r, { className: "size-3" }), /* @__PURE__ */ l(c.Indicator, {})]
53
- })
54
- ]
55
- })
56
- })
57
- })
58
- ]
59
- });
60
- }
61
- //#endregion
62
- export { f as ThemeToggleItem };
@@ -1,29 +0,0 @@
1
- import { useAuth as e, useSession as t } from "@better-auth-ui/react";
2
- import { Person as n } from "@gravity-ui/icons";
3
- import { Avatar as r, Skeleton as i, cn as a } from "@heroui/react";
4
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
5
- //#region src/components/auth/user/user-avatar.tsx
6
- function c({ className: c, fallback: l, isPending: u, user: d, size: f = "sm", style: p, ...m }) {
7
- let { authClient: h } = e(), { data: g, isPending: _ } = t(h, { enabled: !d && !u });
8
- if ((u || _) && !d) return /* @__PURE__ */ o(i, {
9
- className: a("rounded-full", f === "sm" ? "size-8" : f === "md" ? "size-10" : "size-12", c),
10
- style: p
11
- });
12
- let v = d ?? g?.user, y = (v?.username || v?.name || v?.email)?.slice(0, 2).toUpperCase();
13
- return /* @__PURE__ */ s(r, {
14
- size: f,
15
- className: a("rounded-full", c),
16
- style: p,
17
- ...m,
18
- children: [/* @__PURE__ */ o(r.Image, {
19
- alt: v?.displayUsername || v?.name || v?.email,
20
- src: v?.image ?? void 0
21
- }), /* @__PURE__ */ o(r.Fallback, {
22
- className: a(f === "lg" ? "text-xl" : f === "md" ? "text-base" : "text-sm"),
23
- delayMs: v?.image ? 600 : void 0,
24
- children: l || y || /* @__PURE__ */ o(n, { className: "size-4" })
25
- })]
26
- });
27
- }
28
- //#endregion
29
- export { c as UserAvatar };
@@ -1,74 +0,0 @@
1
- import { UserAvatar as e } from "./user-avatar.js";
2
- import { UserView as t } from "./user-view.js";
3
- import { useAuth as n, useSession as r } from "@better-auth-ui/react";
4
- import { ArrowRightFromSquare as i, ArrowRightToSquare as a, ChevronsExpandVertical as o, Gear as s, PersonPlus as c } from "@gravity-ui/icons";
5
- import { Button as l, Dropdown as u, Label as d, cn as f } from "@heroui/react";
6
- import { isValidElement as p } from "react";
7
- import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
8
- //#region src/components/auth/user/user-button.tsx
9
- function _(e, t) {
10
- if (p(e)) return e;
11
- let { label: n, href: r, icon: i, variant: a } = e;
12
- return /* @__PURE__ */ g(u.Item, {
13
- href: r,
14
- variant: a,
15
- textValue: typeof n == "string" ? n : void 0,
16
- children: [i, /* @__PURE__ */ h(d, { children: n })]
17
- }, t);
18
- }
19
- function v({ className: v, placement: y = "bottom", size: b = "default", variant: x = "ghost", links: S, hideSettings: C = !1 }) {
20
- let { authClient: w, basePaths: T, viewPaths: E, localization: D, plugins: O } = n(), { data: k, isPending: A } = r(w), j = O.flatMap((e) => e.userMenuItems?.map((t, n) => /* @__PURE__ */ h(t, {}, `${e.id}-${n.toString()}`)) ?? []), M = S?.flatMap((e, t) => {
21
- if (!p(e)) {
22
- let t = e.visibility ?? "always";
23
- if (t === "authenticated" && !k || t === "unauthenticated" && k) return [];
24
- }
25
- return [_(e, `user-button-link-${t.toString()}`)];
26
- });
27
- return /* @__PURE__ */ g(u, { children: [b === "icon" ? /* @__PURE__ */ h(u.Trigger, {
28
- className: f("rounded-full", v),
29
- children: /* @__PURE__ */ h(e, {})
30
- }) : /* @__PURE__ */ g(l, {
31
- variant: x,
32
- className: f("h-auto font-normal justify-start px-3 py-2 text-left", v),
33
- children: [k || A ? /* @__PURE__ */ h(t, { isPending: A }) : /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(e, {}), /* @__PURE__ */ h("p", {
34
- className: "text-sm font-medium",
35
- children: D.auth.account
36
- })] }), /* @__PURE__ */ h(o, { className: "ml-auto size-3.5" })]
37
- }), /* @__PURE__ */ g(u.Popover, {
38
- placement: y,
39
- className: "min-w-40 md:min-w-56 max-w-[48svw]",
40
- children: [k && /* @__PURE__ */ h("div", {
41
- className: "px-3 pt-3 pb-1",
42
- children: /* @__PURE__ */ h(t, {})
43
- }), /* @__PURE__ */ h(u.Menu, { children: k ? /* @__PURE__ */ g(m, { children: [
44
- M,
45
- !C && /* @__PURE__ */ g(u.Item, {
46
- textValue: D.settings.settings,
47
- href: `${T.settings}/${E.settings.account}`,
48
- children: [/* @__PURE__ */ h(s, { className: "text-muted" }), /* @__PURE__ */ h(d, { children: D.settings.settings })]
49
- }),
50
- j,
51
- /* @__PURE__ */ g(u.Item, {
52
- textValue: D.auth.signOut,
53
- href: `${T.auth}/${E.auth.signOut}`,
54
- variant: "danger",
55
- children: [/* @__PURE__ */ h(i, { className: "text-danger" }), /* @__PURE__ */ h(d, { children: D.auth.signOut })]
56
- })
57
- ] }) : /* @__PURE__ */ g(m, { children: [
58
- M,
59
- /* @__PURE__ */ g(u.Item, {
60
- textValue: D.auth.signIn,
61
- href: `${T.auth}/${E.auth.signIn}`,
62
- children: [/* @__PURE__ */ h(a, { className: "text-muted" }), /* @__PURE__ */ h(d, { children: D.auth.signIn })]
63
- }),
64
- /* @__PURE__ */ g(u.Item, {
65
- textValue: D.auth.signUp,
66
- href: `${T.auth}/${E.auth.signUp}`,
67
- children: [/* @__PURE__ */ h(c, { className: "text-muted" }), /* @__PURE__ */ h(d, { children: D.auth.signUp })]
68
- }),
69
- j
70
- ] }) })]
71
- })] });
72
- }
73
- //#endregion
74
- export { v as UserButton };
@@ -1,37 +0,0 @@
1
- import { UserAvatar as e } from "./user-avatar.js";
2
- import { useAuth as t, useSession as n } from "@better-auth-ui/react";
3
- import { Skeleton as r, cn as i } from "@heroui/react";
4
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
5
- //#region src/components/auth/user/user-view.tsx
6
- function s({ className: s, isPending: c, size: l = "sm", user: u, ...d }) {
7
- let { authClient: f } = t(), { data: p, isPending: m } = n(f, { enabled: !u && !c }), h = u ?? p?.user;
8
- return (c || m) && !u ? /* @__PURE__ */ o("div", {
9
- className: i("flex items-center gap-2 min-w-0", s),
10
- ...d,
11
- children: [/* @__PURE__ */ a(e, {
12
- isPending: !0,
13
- size: l
14
- }), /* @__PURE__ */ o("div", {
15
- className: "flex flex-col gap-1 min-w-0",
16
- children: [/* @__PURE__ */ a(r, { className: "h-3.5 w-24 rounded-lg" }), /* @__PURE__ */ a(r, { className: "h-3 w-32 rounded-lg" })]
17
- })]
18
- }) : /* @__PURE__ */ o("div", {
19
- className: i("flex items-center gap-2 min-w-0", s),
20
- ...d,
21
- children: [/* @__PURE__ */ a(e, {
22
- user: h,
23
- size: l
24
- }), /* @__PURE__ */ o("div", {
25
- className: "min-w-0",
26
- children: [/* @__PURE__ */ a("p", {
27
- className: "text-sm font-medium truncate leading-tight",
28
- children: h?.displayUsername || h?.name || h?.email
29
- }), (h?.displayUsername || h?.name) && /* @__PURE__ */ a("p", {
30
- className: "text-muted text-xs mb-0.5 truncate overflow-x-hidden",
31
- children: h?.email
32
- })]
33
- })]
34
- });
35
- }
36
- //#endregion
37
- export { s as UserView };
@@ -1,148 +0,0 @@
1
- import { FieldSeparator as e } from "../field-separator.js";
2
- import { ProviderButtons as t } from "../provider-buttons.js";
3
- import { usernamePlugin as n } from "../../../lib/auth/username-plugin.js";
4
- import { authMutationKeys as r } from "@better-auth-ui/core";
5
- import { useAuth as i, useAuthPlugin as a, useFetchOptions as o, useSendVerificationEmail as s, useSignInEmail as c, useSignInUsername as l } from "@better-auth-ui/react";
6
- import { Button as ee, Card as u, Checkbox as d, Description as f, FieldError as p, Form as te, Input as m, Label as h, Link as g, Spinner as ne, TextField as _, cn as v, toast as y } from "@heroui/react";
7
- import { useState as re } from "react";
8
- import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
9
- import { useIsMutating as C } from "@tanstack/react-query";
10
- //#region src/components/auth/username/sign-in-username.tsx
11
- function w({ className: w, socialLayout: T, socialPosition: E = "bottom", variant: D, ...O }) {
12
- let { authClient: k, basePaths: A, baseURL: j, emailAndPassword: M, localization: N, plugins: P, redirectTo: F, socialProviders: I, viewPaths: L, navigate: R } = i(), { fetchOptions: z, resetFetchOptions: B } = o(), { localization: V } = a(n), [H, U] = re(""), { mutate: W } = s(k, { onSuccess: () => y.success(N.auth.verificationEmailSent) });
13
- function G(e) {
14
- return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
15
- }
16
- let { mutate: K, isPending: q } = c(k, {
17
- onError: (e, { email: t }) => {
18
- U(""), e.error?.code === "EMAIL_NOT_VERIFIED" ? y.danger(e.error?.message || e.message, { actionProps: {
19
- children: N.auth.resend,
20
- onClick: () => W({
21
- email: t,
22
- callbackURL: `${j}${F}`
23
- })
24
- } }) : y.danger(e.error?.message || e.message), B();
25
- },
26
- onSuccess: () => R({ to: F })
27
- }), { mutate: J, isPending: Y } = l(k, {
28
- onError: (e) => {
29
- U(""), y.danger(e.error?.message || e.message), B();
30
- },
31
- onSuccess: () => R({ to: F })
32
- }), ie = (e) => {
33
- e.preventDefault();
34
- let t = new FormData(e.currentTarget), n = t.get("email"), r = t.get("rememberMe") === "on";
35
- G(n) ? K({
36
- email: n,
37
- password: H,
38
- ...M?.rememberMe ? { rememberMe: r } : {},
39
- fetchOptions: z
40
- }) : J({
41
- username: n,
42
- password: H,
43
- ...M?.rememberMe ? { rememberMe: r } : {},
44
- fetchOptions: z
45
- });
46
- }, X = C({ mutationKey: r.signIn.all }) + C({ mutationKey: r.signUp.all }) > 0, Z = q || Y, Q = P.find((e) => e.captchaComponent)?.captchaComponent, $ = M?.enabled && !!I?.length;
47
- return /* @__PURE__ */ S(u, {
48
- className: v("w-full max-w-sm gap-4 md:p-6", w),
49
- variant: D,
50
- ...O,
51
- children: [
52
- /* @__PURE__ */ x(u.Header, { children: /* @__PURE__ */ x(u.Title, {
53
- className: "text-xl font-semibold mb-1",
54
- children: N.auth.signIn
55
- }) }),
56
- /* @__PURE__ */ S(u.Content, {
57
- className: "gap-4",
58
- children: [
59
- E === "top" && /* @__PURE__ */ S(b, { children: [!!I?.length && /* @__PURE__ */ x(t, { socialLayout: T }), $ && /* @__PURE__ */ x(e, { children: N.auth.or })] }),
60
- M?.enabled && /* @__PURE__ */ S(te, {
61
- onSubmit: ie,
62
- className: "flex flex-col gap-4",
63
- children: [
64
- /* @__PURE__ */ S(_, {
65
- name: "email",
66
- type: "text",
67
- autoComplete: "username email",
68
- isDisabled: X,
69
- children: [
70
- /* @__PURE__ */ x(h, { children: V.username }),
71
- /* @__PURE__ */ x(m, {
72
- placeholder: V.usernameOrEmailPlaceholder,
73
- variant: D === "transparent" ? "primary" : "secondary",
74
- required: !0
75
- }),
76
- /* @__PURE__ */ x(p, {})
77
- ]
78
- }),
79
- /* @__PURE__ */ S(_, {
80
- minLength: M?.minPasswordLength,
81
- maxLength: M?.maxPasswordLength,
82
- name: "password",
83
- type: "password",
84
- autoComplete: "current-password",
85
- isDisabled: X,
86
- value: H,
87
- onChange: U,
88
- children: [
89
- /* @__PURE__ */ x(h, { children: N.auth.password }),
90
- /* @__PURE__ */ x(m, {
91
- placeholder: N.auth.passwordPlaceholder,
92
- variant: D === "transparent" ? "primary" : "secondary",
93
- required: !0
94
- }),
95
- /* @__PURE__ */ x(p, {})
96
- ]
97
- }),
98
- M?.rememberMe && /* @__PURE__ */ S(d, {
99
- name: "rememberMe",
100
- isDisabled: X,
101
- variant: D === "transparent" ? "primary" : "secondary",
102
- children: [/* @__PURE__ */ x(d.Control, { children: /* @__PURE__ */ x(d.Indicator, {}) }), /* @__PURE__ */ x(d.Content, { children: /* @__PURE__ */ x(h, { children: N.auth.rememberMe }) })]
103
- }),
104
- Q && /* @__PURE__ */ x("div", {
105
- className: "flex justify-center",
106
- children: Q
107
- }),
108
- /* @__PURE__ */ S("div", {
109
- className: "flex flex-col gap-3",
110
- children: [/* @__PURE__ */ S(ee, {
111
- type: "submit",
112
- className: "w-full",
113
- isPending: Z || X,
114
- children: [Z && /* @__PURE__ */ x(ne, {
115
- color: "current",
116
- size: "sm"
117
- }), N.auth.signIn]
118
- }), P.flatMap((e) => e.authButtons?.map((t, n) => /* @__PURE__ */ x(t, { view: "signIn" }, `${e.id}-${n.toString()}`)))]
119
- })
120
- ]
121
- }),
122
- E === "bottom" && /* @__PURE__ */ S(b, { children: [$ && /* @__PURE__ */ x(e, { children: N.auth.or }), !!I?.length && /* @__PURE__ */ x(t, { socialLayout: T })] })
123
- ]
124
- }),
125
- /* @__PURE__ */ S(u.Footer, {
126
- className: "flex-col gap-3",
127
- children: [M?.forgotPassword && /* @__PURE__ */ x(g, {
128
- href: `${A.auth}/${L.auth.forgotPassword}`,
129
- className: "no-underline hover:underline",
130
- children: N.auth.forgotPasswordLink
131
- }), M?.enabled && /* @__PURE__ */ S(f, {
132
- className: "text-sm",
133
- children: [
134
- N.auth.needToCreateAnAccount,
135
- " ",
136
- /* @__PURE__ */ x(g, {
137
- href: `${A.auth}/${L.auth.signUp}`,
138
- className: "text-accent no-underline hover:underline decoration-accent-hover",
139
- children: N.auth.signUp
140
- })
141
- ]
142
- })]
143
- })
144
- ]
145
- });
146
- }
147
- //#endregion
148
- export { w as SignInUsername };