@better-auth-ui/heroui 1.6.3 → 1.6.5
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.
- package/dist/components/auth/additional-field.d.ts +4 -0
- package/dist/components/auth/additional-field.js +270 -0
- package/dist/components/auth/auth-provider.d.ts +4 -6
- package/dist/components/auth/auth.d.ts +1 -1
- package/dist/components/auth/auth.js +54 -28
- package/dist/components/{settings/security → auth/delete-user}/danger-zone.d.ts +1 -1
- package/dist/components/{settings/security → auth/delete-user}/danger-zone.js +1 -1
- package/dist/components/auth/delete-user/delete-user.js +95 -0
- package/dist/components/{email → auth/email}/email-changed-email.d.ts +2 -2
- package/dist/components/{email → auth/email}/email-changed-email.js +7 -7
- package/dist/components/{email → auth/email}/email-verification-email.d.ts +2 -2
- package/dist/components/{email → auth/email}/email-verification-email.js +7 -7
- package/dist/components/auth/email/magic-link-email.d.ts +3 -0
- package/dist/components/{email → auth/email}/magic-link-email.js +7 -7
- package/dist/components/auth/email/new-device-email.d.ts +3 -0
- package/dist/components/{email → auth/email}/new-device-email.js +7 -7
- package/dist/components/auth/email/otp-email.d.ts +3 -0
- package/dist/components/{email → auth/email}/otp-email.js +6 -6
- package/dist/components/{email → auth/email}/password-changed-email.d.ts +2 -2
- package/dist/components/{email → auth/email}/password-changed-email.js +7 -7
- package/dist/components/{email → auth/email}/reset-password-email.d.ts +2 -2
- package/dist/components/{email → auth/email}/reset-password-email.js +7 -7
- package/dist/components/auth/forgot-password.d.ts +1 -1
- package/dist/components/auth/forgot-password.js +70 -48
- package/dist/components/auth/magic-link/magic-link-button.d.ts +11 -0
- package/dist/components/auth/magic-link/magic-link-button.js +20 -0
- package/dist/components/auth/magic-link/magic-link.d.ts +16 -0
- package/dist/components/auth/magic-link/magic-link.js +87 -0
- package/dist/components/{settings/account → auth/multi-session}/manage-account.d.ts +2 -6
- package/dist/components/auth/multi-session/manage-account.js +49 -0
- package/dist/components/auth/multi-session/manage-accounts.js +34 -0
- package/dist/components/{user/switch-account-menu.d.ts → auth/multi-session/switch-account-submenu-content.d.ts} +3 -3
- package/dist/components/auth/multi-session/switch-account-submenu-content.js +29 -0
- package/dist/components/{user/switch-account-item.d.ts → auth/multi-session/switch-account-submenu-item.d.ts} +2 -2
- package/dist/components/auth/multi-session/switch-account-submenu-item.js +20 -0
- package/dist/components/auth/multi-session/switch-account-submenu.d.ts +13 -0
- package/dist/components/auth/multi-session/switch-account-submenu.js +24 -0
- package/dist/components/auth/passkey/passkey-button.d.ts +6 -0
- package/dist/components/auth/passkey/passkey-button.js +24 -0
- package/dist/components/auth/passkey/passkey.js +45 -0
- package/dist/components/auth/passkey/passkeys.js +106 -0
- package/dist/components/auth/provider-button.d.ts +6 -8
- package/dist/components/auth/provider-button.js +16 -20
- package/dist/components/auth/provider-buttons.d.ts +3 -4
- package/dist/components/auth/provider-buttons.js +9 -10
- package/dist/components/auth/reset-password.js +110 -107
- package/dist/components/{settings → auth/settings}/account/account-settings.d.ts +5 -2
- package/dist/components/auth/settings/account/account-settings.js +20 -0
- package/dist/components/auth/settings/account/change-avatar.js +89 -0
- package/dist/components/{settings → auth/settings}/account/change-email.js +17 -17
- package/dist/components/{settings → auth/settings}/account/user-profile.d.ts +2 -3
- package/dist/components/auth/settings/account/user-profile.js +86 -0
- package/dist/components/auth/settings/security/active-session.js +59 -0
- package/dist/components/{settings → auth/settings}/security/active-sessions.js +4 -4
- package/dist/components/auth/settings/security/change-password.js +189 -0
- package/dist/components/auth/settings/security/linked-account.js +56 -0
- package/dist/components/{settings → auth/settings}/security/linked-accounts.js +5 -5
- package/dist/components/{settings → auth/settings}/security/security-settings.d.ts +1 -1
- package/dist/components/auth/settings/security/security-settings.js +22 -0
- package/dist/components/auth/settings/settings.js +45 -0
- package/dist/components/auth/sign-in.js +66 -85
- package/dist/components/auth/sign-out.js +11 -11
- package/dist/components/auth/sign-up.js +128 -148
- package/dist/components/{settings/account → auth/theme}/appearance.d.ts +3 -6
- package/dist/components/auth/theme/appearance.js +72 -0
- package/dist/components/auth/theme/theme-toggle-item.d.ts +5 -0
- package/dist/components/auth/theme/theme-toggle-item.js +58 -0
- package/dist/components/auth/user/user-avatar.js +29 -0
- package/dist/components/{user → auth/user}/user-button.d.ts +2 -6
- package/dist/components/auth/user/user-button.js +55 -0
- package/dist/components/auth/user/user-view.js +37 -0
- package/dist/components/auth/username/sign-in-username.d.ts +14 -0
- package/dist/components/auth/username/sign-in-username.js +148 -0
- package/dist/components/auth/username/username-field.d.ts +8 -0
- package/dist/components/auth/username/username-field.js +53 -0
- package/dist/email.d.ts +7 -0
- package/dist/email.js +9 -0
- package/dist/index.d.ts +12 -27
- package/dist/index.js +20 -35
- package/dist/lib/auth/auth-plugin.d.ts +44 -0
- package/dist/lib/auth/delete-user-plugin.d.ts +17 -0
- package/dist/lib/auth/delete-user-plugin.js +10 -0
- package/dist/lib/auth/magic-link-plugin.d.ts +31 -0
- package/dist/lib/auth/magic-link-plugin.js +13 -0
- package/dist/lib/auth/multi-session-plugin.d.ts +18 -0
- package/dist/lib/auth/multi-session-plugin.js +12 -0
- package/dist/lib/auth/passkey-plugin.d.ts +20 -0
- package/dist/lib/auth/passkey-plugin.js +12 -0
- package/dist/lib/auth/theme-plugin.d.ts +68 -0
- package/dist/lib/auth/theme-plugin.js +23 -0
- package/dist/lib/auth/username-plugin.d.ts +63 -0
- package/dist/lib/auth/username-plugin.js +18 -0
- package/dist/plugins.d.ts +20 -0
- package/dist/plugins.js +21 -0
- package/package.json +19 -21
- package/src/components/auth/additional-field.tsx +554 -0
- package/src/components/auth/auth-provider.tsx +5 -6
- package/src/components/auth/auth.tsx +99 -35
- package/src/components/{settings/security → auth/delete-user}/danger-zone.tsx +1 -1
- package/src/components/{settings/security → auth/delete-user}/delete-user.tsx +30 -20
- package/src/components/{email → auth/email}/email-changed-email.tsx +2 -2
- package/src/components/{email → auth/email}/email-verification-email.tsx +2 -2
- package/src/components/{email → auth/email}/magic-link-email.tsx +2 -2
- package/src/components/{email → auth/email}/new-device-email.tsx +2 -2
- package/src/components/{email → auth/email}/otp-email.tsx +2 -2
- package/src/components/{email → auth/email}/password-changed-email.tsx +2 -2
- package/src/components/{email → auth/email}/reset-password-email.tsx +2 -2
- package/src/components/auth/forgot-password.tsx +42 -17
- package/src/components/auth/magic-link/magic-link-button.tsx +61 -0
- package/src/components/auth/{magic-link.tsx → magic-link/magic-link.tsx} +55 -40
- package/src/components/{settings/account → auth/multi-session}/manage-account.tsx +16 -13
- package/src/components/{settings/account → auth/multi-session}/manage-accounts.tsx +14 -5
- package/src/components/{user/switch-account-menu.tsx → auth/multi-session/switch-account-submenu-content.tsx} +18 -11
- package/src/components/{user/switch-account-item.tsx → auth/multi-session/switch-account-submenu-item.tsx} +17 -5
- package/src/components/auth/multi-session/switch-account-submenu.tsx +50 -0
- package/src/components/auth/passkey/passkey-button.tsx +56 -0
- package/src/components/{settings/security → auth/passkey}/passkey.tsx +20 -6
- package/src/components/auth/passkey/passkeys.tsx +196 -0
- package/src/components/auth/provider-button.tsx +27 -29
- package/src/components/auth/provider-buttons.tsx +6 -11
- package/src/components/auth/reset-password.tsx +13 -7
- package/src/components/{settings → auth/settings}/account/account-settings.tsx +15 -13
- package/src/components/{settings → auth/settings}/account/change-avatar.tsx +4 -3
- package/src/components/{settings → auth/settings}/account/change-email.tsx +3 -3
- package/src/components/auth/settings/account/user-profile.tsx +171 -0
- package/src/components/{settings → auth/settings}/security/active-session.tsx +8 -5
- package/src/components/{settings → auth/settings}/security/active-sessions.tsx +3 -3
- package/src/components/{settings → auth/settings}/security/change-password.tsx +14 -9
- package/src/components/{settings → auth/settings}/security/linked-account.tsx +12 -8
- package/src/components/{settings → auth/settings}/security/linked-accounts.tsx +2 -2
- package/src/components/{settings → auth/settings}/security/security-settings.tsx +7 -6
- package/src/components/{settings → auth/settings}/settings.tsx +2 -2
- package/src/components/auth/sign-in.tsx +50 -61
- package/src/components/auth/sign-out.tsx +2 -2
- package/src/components/auth/sign-up.tsx +119 -131
- package/src/components/{settings/account → auth/theme}/appearance.tsx +17 -24
- package/src/components/auth/theme/theme-toggle-item.tsx +110 -0
- package/src/components/{user → auth/user}/user-avatar.tsx +12 -4
- package/src/components/{user → auth/user}/user-button.tsx +15 -88
- package/src/components/{user → auth/user}/user-view.tsx +12 -4
- package/src/components/auth/username/sign-in-username.tsx +299 -0
- package/src/components/auth/username/username-field.tsx +124 -0
- package/src/email.ts +9 -0
- package/src/index.tsx +12 -27
- package/src/lib/auth/auth-plugin.ts +67 -0
- package/src/lib/auth/delete-user-plugin.ts +15 -0
- package/src/lib/auth/magic-link-plugin.ts +26 -0
- package/src/lib/auth/multi-session-plugin.ts +17 -0
- package/src/lib/auth/passkey-plugin.ts +17 -0
- package/src/lib/auth/theme-plugin.ts +86 -0
- package/src/lib/auth/username-plugin.tsx +30 -0
- package/src/plugins.ts +23 -0
- package/dist/components/auth/magic-link-button.d.ts +0 -13
- package/dist/components/auth/magic-link-button.js +0 -16
- package/dist/components/auth/magic-link.d.ts +0 -17
- package/dist/components/auth/magic-link.js +0 -99
- package/dist/components/auth/passkey-button.d.ts +0 -4
- package/dist/components/auth/passkey-button.js +0 -21
- package/dist/components/email/magic-link-email.d.ts +0 -3
- package/dist/components/email/new-device-email.d.ts +0 -3
- package/dist/components/email/otp-email.d.ts +0 -3
- package/dist/components/settings/account/account-settings.js +0 -23
- package/dist/components/settings/account/appearance.js +0 -71
- package/dist/components/settings/account/change-avatar.js +0 -89
- package/dist/components/settings/account/manage-account.js +0 -48
- package/dist/components/settings/account/manage-accounts.js +0 -33
- package/dist/components/settings/account/user-profile.js +0 -103
- package/dist/components/settings/security/active-session.js +0 -59
- package/dist/components/settings/security/change-password.js +0 -189
- package/dist/components/settings/security/delete-user.js +0 -92
- package/dist/components/settings/security/linked-account.js +0 -56
- package/dist/components/settings/security/passkey.js +0 -43
- package/dist/components/settings/security/passkeys.js +0 -53
- package/dist/components/settings/security/security-settings.js +0 -25
- package/dist/components/settings/settings.js +0 -45
- package/dist/components/user/switch-account-item.js +0 -20
- package/dist/components/user/switch-account-menu.js +0 -28
- package/dist/components/user/user-avatar.js +0 -29
- package/dist/components/user/user-button.js +0 -91
- package/dist/components/user/user-view.js +0 -37
- package/dist/core.d.ts +0 -1
- package/dist/core.js +0 -1
- package/dist/react-exports.d.ts +0 -1
- package/dist/react-exports.js +0 -1
- package/src/components/auth/magic-link-button.tsx +0 -43
- package/src/components/auth/passkey-button.tsx +0 -35
- package/src/components/settings/account/user-profile.tsx +0 -217
- package/src/components/settings/security/passkeys.tsx +0 -96
- package/src/core.ts +0 -1
- package/src/react-exports.ts +0 -1
- /package/dist/components/{settings/security → auth/delete-user}/delete-user.d.ts +0 -0
- /package/dist/components/{settings/account → auth/multi-session}/manage-accounts.d.ts +0 -0
- /package/dist/components/{settings/security → auth/passkey}/passkey.d.ts +0 -0
- /package/dist/components/{settings/security → auth/passkey}/passkeys.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/account/change-avatar.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/account/change-email.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/security/active-session.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/security/active-sessions.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/security/change-password.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/security/linked-account.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/security/linked-accounts.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/settings.d.ts +0 -0
- /package/dist/components/{user → auth/user}/user-avatar.d.ts +0 -0
- /package/dist/components/{user → auth/user}/user-view.d.ts +0 -0
|
@@ -1,226 +1,206 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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 {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
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";
|
|
10
11
|
//#region src/components/auth/sign-up.tsx
|
|
11
|
-
function
|
|
12
|
-
let { basePaths:
|
|
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 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, {
|
|
23
14
|
onError: (e) => {
|
|
24
|
-
|
|
15
|
+
W(""), K(""), b.danger(e.error?.message || e.message), H();
|
|
25
16
|
},
|
|
26
17
|
onSuccess: () => {
|
|
27
|
-
|
|
18
|
+
P?.requireEmailVerification ? (b.success(F.auth.verifyYourEmail), B({ to: `${N.auth}/${z.auth.signIn}` })) : B({ to: L });
|
|
28
19
|
}
|
|
29
|
-
}), [
|
|
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) => {
|
|
30
21
|
e.preventDefault();
|
|
31
|
-
let t = new FormData(e.currentTarget), n = t.get("name"), r = t.get("email");
|
|
32
|
-
if (
|
|
33
|
-
|
|
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("");
|
|
34
25
|
return;
|
|
35
26
|
}
|
|
36
|
-
|
|
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({
|
|
37
40
|
name: n,
|
|
38
41
|
email: r,
|
|
39
|
-
password:
|
|
40
|
-
...
|
|
41
|
-
|
|
42
|
-
...F.displayUsername ? { displayUsername: H.trim() } : {}
|
|
43
|
-
} : {}
|
|
42
|
+
password: U,
|
|
43
|
+
...a,
|
|
44
|
+
fetchOptions: V
|
|
44
45
|
});
|
|
45
|
-
}, $ =
|
|
46
|
-
return /* @__PURE__ */
|
|
47
|
-
className:
|
|
48
|
-
variant:
|
|
49
|
-
...
|
|
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,
|
|
50
51
|
children: [
|
|
51
|
-
/* @__PURE__ */
|
|
52
|
+
/* @__PURE__ */ C(u.Header, { children: /* @__PURE__ */ C(u.Title, {
|
|
52
53
|
className: "text-xl font-semibold mb-1",
|
|
53
|
-
children:
|
|
54
|
+
children: F.auth.signUp
|
|
54
55
|
}) }),
|
|
55
|
-
/* @__PURE__ */
|
|
56
|
+
/* @__PURE__ */ w(u.Content, {
|
|
56
57
|
className: "gap-4",
|
|
57
58
|
children: [
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}), $ && /* @__PURE__ */ g(e, { children: j.auth.or })] }),
|
|
62
|
-
A?.enabled && /* @__PURE__ */ _(ne, {
|
|
63
|
-
onSubmit: ce,
|
|
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,
|
|
64
62
|
className: "flex flex-col gap-4",
|
|
65
63
|
children: [
|
|
66
|
-
/* @__PURE__ */
|
|
64
|
+
P.name !== !1 && /* @__PURE__ */ w(v, {
|
|
67
65
|
name: "name",
|
|
68
66
|
type: "text",
|
|
69
67
|
autoComplete: "name",
|
|
70
|
-
isDisabled:
|
|
68
|
+
isDisabled: Z,
|
|
71
69
|
children: [
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
placeholder:
|
|
70
|
+
/* @__PURE__ */ C(h, { children: F.auth.name }),
|
|
71
|
+
/* @__PURE__ */ C(p, {
|
|
72
|
+
placeholder: F.auth.namePlaceholder,
|
|
75
73
|
required: !0,
|
|
76
|
-
variant:
|
|
74
|
+
variant: k === "transparent" ? "primary" : "secondary"
|
|
77
75
|
}),
|
|
78
|
-
/* @__PURE__ */
|
|
76
|
+
/* @__PURE__ */ C(f, {})
|
|
79
77
|
]
|
|
80
78
|
}),
|
|
81
|
-
|
|
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
|
-
})]
|
|
105
|
-
}),
|
|
106
|
-
/* @__PURE__ */ g(s, { children: K?.error?.message || K?.message || (G?.available === !1 ? j.auth.usernameTaken : null) })
|
|
107
|
-
]
|
|
108
|
-
}),
|
|
109
|
-
/* @__PURE__ */ _(f, {
|
|
79
|
+
/* @__PURE__ */ w(v, {
|
|
110
80
|
name: "email",
|
|
111
81
|
type: "email",
|
|
112
82
|
autoComplete: "email",
|
|
113
|
-
isDisabled:
|
|
83
|
+
isDisabled: Z,
|
|
114
84
|
children: [
|
|
115
|
-
/* @__PURE__ */
|
|
116
|
-
/* @__PURE__ */
|
|
117
|
-
placeholder:
|
|
85
|
+
/* @__PURE__ */ C(h, { children: F.auth.email }),
|
|
86
|
+
/* @__PURE__ */ C(p, {
|
|
87
|
+
placeholder: F.auth.emailPlaceholder,
|
|
118
88
|
required: !0,
|
|
119
|
-
variant:
|
|
89
|
+
variant: k === "transparent" ? "primary" : "secondary"
|
|
120
90
|
}),
|
|
121
|
-
/* @__PURE__ */
|
|
91
|
+
/* @__PURE__ */ C(f, {})
|
|
122
92
|
]
|
|
123
93
|
}),
|
|
124
|
-
/* @__PURE__ */
|
|
125
|
-
|
|
126
|
-
|
|
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,
|
|
127
103
|
name: "password",
|
|
128
104
|
autoComplete: "new-password",
|
|
129
|
-
isDisabled:
|
|
130
|
-
value:
|
|
131
|
-
onChange:
|
|
105
|
+
isDisabled: Z,
|
|
106
|
+
value: U,
|
|
107
|
+
onChange: W,
|
|
132
108
|
children: [
|
|
133
|
-
/* @__PURE__ */
|
|
134
|
-
/* @__PURE__ */
|
|
135
|
-
variant:
|
|
136
|
-
children: [/* @__PURE__ */
|
|
137
|
-
placeholder:
|
|
138
|
-
type:
|
|
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",
|
|
139
115
|
name: "password",
|
|
140
116
|
required: !0
|
|
141
|
-
}), /* @__PURE__ */
|
|
117
|
+
}), /* @__PURE__ */ C(m.Suffix, {
|
|
142
118
|
className: "px-0",
|
|
143
|
-
children: /* @__PURE__ */
|
|
119
|
+
children: /* @__PURE__ */ C(l, {
|
|
144
120
|
isIconOnly: !0,
|
|
145
|
-
"aria-label":
|
|
121
|
+
"aria-label": Y ? F.auth.hidePassword : F.auth.showPassword,
|
|
146
122
|
size: "sm",
|
|
147
123
|
variant: "ghost",
|
|
148
|
-
onPress: () =>
|
|
149
|
-
isDisabled:
|
|
150
|
-
children:
|
|
124
|
+
onPress: () => ne(!Y),
|
|
125
|
+
isDisabled: Z,
|
|
126
|
+
children: C(Y ? c : s, {})
|
|
151
127
|
})
|
|
152
128
|
})]
|
|
153
129
|
}),
|
|
154
|
-
/* @__PURE__ */
|
|
130
|
+
/* @__PURE__ */ C(f, {})
|
|
155
131
|
]
|
|
156
132
|
}),
|
|
157
|
-
|
|
158
|
-
minLength:
|
|
159
|
-
maxLength:
|
|
133
|
+
P?.confirmPassword && /* @__PURE__ */ w(v, {
|
|
134
|
+
minLength: P?.minPasswordLength,
|
|
135
|
+
maxLength: P?.maxPasswordLength,
|
|
160
136
|
name: "confirmPassword",
|
|
161
137
|
autoComplete: "new-password",
|
|
162
|
-
isDisabled:
|
|
163
|
-
value:
|
|
164
|
-
onChange:
|
|
138
|
+
isDisabled: Z,
|
|
139
|
+
value: G,
|
|
140
|
+
onChange: K,
|
|
165
141
|
children: [
|
|
166
|
-
/* @__PURE__ */
|
|
167
|
-
/* @__PURE__ */
|
|
168
|
-
variant:
|
|
169
|
-
children: [/* @__PURE__ */
|
|
142
|
+
/* @__PURE__ */ C(h, { children: F.auth.confirmPassword }),
|
|
143
|
+
/* @__PURE__ */ w(m, {
|
|
144
|
+
variant: k === "transparent" ? "primary" : "secondary",
|
|
145
|
+
children: [/* @__PURE__ */ C(m.Input, {
|
|
170
146
|
name: "confirmPassword",
|
|
171
|
-
placeholder:
|
|
172
|
-
type:
|
|
147
|
+
placeholder: F.auth.confirmPasswordPlaceholder,
|
|
148
|
+
type: X ? "text" : "password",
|
|
173
149
|
required: !0
|
|
174
|
-
}), /* @__PURE__ */
|
|
150
|
+
}), /* @__PURE__ */ C(m.Suffix, {
|
|
175
151
|
className: "px-0",
|
|
176
|
-
children: /* @__PURE__ */
|
|
152
|
+
children: /* @__PURE__ */ C(l, {
|
|
177
153
|
isIconOnly: !0,
|
|
178
|
-
"aria-label":
|
|
154
|
+
"aria-label": X ? F.auth.hidePassword : F.auth.showPassword,
|
|
179
155
|
size: "sm",
|
|
180
156
|
variant: "ghost",
|
|
181
|
-
onPress: () =>
|
|
182
|
-
isDisabled:
|
|
183
|
-
children:
|
|
157
|
+
onPress: () => re(!X),
|
|
158
|
+
isDisabled: Z,
|
|
159
|
+
children: C(X ? c : s, {})
|
|
184
160
|
})
|
|
185
161
|
})]
|
|
186
162
|
}),
|
|
187
|
-
/* @__PURE__ */
|
|
163
|
+
/* @__PURE__ */ C(f, {})
|
|
188
164
|
]
|
|
189
165
|
}),
|
|
190
|
-
/* @__PURE__ */
|
|
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", {
|
|
191
177
|
className: "flex flex-col gap-3",
|
|
192
|
-
children: [/* @__PURE__ */
|
|
178
|
+
children: [/* @__PURE__ */ w(l, {
|
|
193
179
|
type: "submit",
|
|
194
180
|
className: "w-full",
|
|
195
|
-
isPending:
|
|
196
|
-
children: [
|
|
181
|
+
isPending: Z,
|
|
182
|
+
children: [J && /* @__PURE__ */ C(_, {
|
|
197
183
|
color: "current",
|
|
198
184
|
size: "sm"
|
|
199
|
-
}),
|
|
200
|
-
}),
|
|
201
|
-
view: "signUp",
|
|
202
|
-
isPending: Q
|
|
203
|
-
})]
|
|
185
|
+
}), F.auth.signUp]
|
|
186
|
+
}), I.flatMap((e) => e.authButtons?.map((t, n) => /* @__PURE__ */ C(t, { view: "signUp" }, `${e.id}-${n.toString()}`)))]
|
|
204
187
|
})
|
|
205
188
|
]
|
|
206
189
|
}),
|
|
207
|
-
|
|
208
|
-
socialLayout: T,
|
|
209
|
-
isPending: Q
|
|
210
|
-
})] })
|
|
190
|
+
O === "bottom" && /* @__PURE__ */ w(S, { children: [$ && /* @__PURE__ */ C(t, { children: F.auth.or }), !!R?.length && /* @__PURE__ */ C(n, { socialLayout: D })] })
|
|
211
191
|
]
|
|
212
192
|
}),
|
|
213
|
-
/* @__PURE__ */
|
|
214
|
-
className: "flex-col",
|
|
215
|
-
children: /* @__PURE__ */
|
|
193
|
+
/* @__PURE__ */ C(u.Footer, {
|
|
194
|
+
className: "flex-col gap-3",
|
|
195
|
+
children: /* @__PURE__ */ w(d, {
|
|
216
196
|
className: "text-sm",
|
|
217
197
|
children: [
|
|
218
|
-
|
|
198
|
+
F.auth.alreadyHaveAnAccount,
|
|
219
199
|
" ",
|
|
220
|
-
/* @__PURE__ */ g
|
|
221
|
-
href: `${
|
|
222
|
-
className: "text-accent
|
|
223
|
-
children:
|
|
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
|
|
224
204
|
})
|
|
225
205
|
]
|
|
226
206
|
})
|
|
@@ -229,4 +209,4 @@ function w({ className: w, socialLayout: T, socialPosition: E = "bottom", varian
|
|
|
229
209
|
});
|
|
230
210
|
}
|
|
231
211
|
//#endregion
|
|
232
|
-
export {
|
|
212
|
+
export { E 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.
|
|
11
|
-
*
|
|
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
|
|
13
|
+
export declare function Appearance({ className, variant, ...props }: AppearanceProps & Omit<CardProps, "children">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,72 @@
|
|
|
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 };
|
|
@@ -0,0 +1,58 @@
|
|
|
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, Sun as i } from "@gravity-ui/icons";
|
|
4
|
+
import { Dropdown as a, Label as o, Tabs as s } from "@heroui/react";
|
|
5
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/auth/theme/theme-toggle-item.tsx
|
|
7
|
+
var u = "[role=\"tab\"][aria-selected=\"true\"]";
|
|
8
|
+
function d() {
|
|
9
|
+
let { useTheme: d, localization: f } = t(e), { theme: p, setTheme: m, themes: h = [] } = d();
|
|
10
|
+
return /* @__PURE__ */ l(a.Item, {
|
|
11
|
+
className: "py-1 pe-2",
|
|
12
|
+
onFocus: (e) => {
|
|
13
|
+
e.target === e.currentTarget && e.currentTarget.querySelector(u)?.focus({ preventScroll: !0 });
|
|
14
|
+
},
|
|
15
|
+
shouldCloseOnSelect: !1,
|
|
16
|
+
children: [/* @__PURE__ */ c(o, { children: f.theme }), /* @__PURE__ */ c(s, {
|
|
17
|
+
className: "ml-auto",
|
|
18
|
+
selectedKey: p,
|
|
19
|
+
onSelectionChange: (e) => m(e),
|
|
20
|
+
children: /* @__PURE__ */ c(s.ListContainer, {
|
|
21
|
+
onKeyDown: (e) => {
|
|
22
|
+
if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
|
|
23
|
+
let t = e.target;
|
|
24
|
+
if (t.getAttribute("role") !== "tab") return;
|
|
25
|
+
let n = t.closest("[role=\"menuitem\"]"), r = n?.closest("[role=\"menu\"]");
|
|
26
|
+
if (!n || !r) return;
|
|
27
|
+
let i = Array.from(r.querySelectorAll("[role=\"menuitem\"]:not([data-disabled])")), a = i.indexOf(n);
|
|
28
|
+
if (a === -1) return;
|
|
29
|
+
let o = i[e.key === "ArrowDown" ? a + 1 : a - 1];
|
|
30
|
+
o && (e.preventDefault(), o.focus());
|
|
31
|
+
},
|
|
32
|
+
children: /* @__PURE__ */ l(s.List, {
|
|
33
|
+
"aria-label": f.theme,
|
|
34
|
+
className: "*:h-5 *:w-5 *:p-0",
|
|
35
|
+
children: [
|
|
36
|
+
h.includes("system") && /* @__PURE__ */ l(s.Tab, {
|
|
37
|
+
id: "system",
|
|
38
|
+
"aria-label": f.system,
|
|
39
|
+
children: [/* @__PURE__ */ c(n, { className: "size-3" }), /* @__PURE__ */ c(s.Indicator, {})]
|
|
40
|
+
}),
|
|
41
|
+
h.includes("light") && /* @__PURE__ */ l(s.Tab, {
|
|
42
|
+
id: "light",
|
|
43
|
+
"aria-label": f.light,
|
|
44
|
+
children: [/* @__PURE__ */ c(i, { className: "size-3" }), /* @__PURE__ */ c(s.Indicator, {})]
|
|
45
|
+
}),
|
|
46
|
+
h.includes("dark") && /* @__PURE__ */ l(s.Tab, {
|
|
47
|
+
id: "dark",
|
|
48
|
+
"aria-label": f.dark,
|
|
49
|
+
children: [/* @__PURE__ */ c(r, { className: "size-3" }), /* @__PURE__ */ c(s.Indicator, {})]
|
|
50
|
+
})
|
|
51
|
+
]
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
})]
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { d as ThemeToggleItem };
|
|
@@ -0,0 +1,29 @@
|
|
|
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 };
|
|
@@ -7,19 +7,15 @@ export type UserButtonProps = {
|
|
|
7
7
|
* @default "bottom"
|
|
8
8
|
*/
|
|
9
9
|
placement?: DropdownPopoverProps["placement"];
|
|
10
|
-
themeToggle?: boolean;
|
|
11
10
|
variant?: ButtonProps["variant"];
|
|
12
11
|
};
|
|
13
12
|
/**
|
|
14
|
-
* Render a user account dropdown button that shows account actions
|
|
15
|
-
*
|
|
16
|
-
* Renders either an icon-only trigger or a full button showing the current user state; its dropdown contains account settings, multi-session switching (when enabled), theme selection (when enabled), and sign-in/sign-out flows depending on authentication state.
|
|
13
|
+
* Render a user account dropdown button that shows account actions.
|
|
17
14
|
*
|
|
18
15
|
* @param className - Additional CSS classes applied to the trigger element
|
|
19
16
|
* @param placement - Dropdown popover placement (e.g., "bottom", "top-start", "bottom-end")
|
|
20
17
|
* @param size - "icon" renders an avatar-only trigger; "default" renders a button with label and chevron
|
|
21
18
|
* @param variant - Button visual variant passed to the underlying Button component
|
|
22
|
-
* @param themeToggle - When true and theming is available, show theme selection controls in the menu
|
|
23
19
|
* @returns The user button and its dropdown menu as a JSX element
|
|
24
20
|
*/
|
|
25
|
-
export declare function UserButton({ className, placement, size, variant
|
|
21
|
+
export declare function UserButton({ className, placement, size, variant }: UserButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,55 @@
|
|
|
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, Separator as f, cn as p } from "@heroui/react";
|
|
6
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/auth/user/user-button.tsx
|
|
8
|
+
function _({ className: _, placement: v = "bottom", size: y = "default", variant: b = "ghost" }) {
|
|
9
|
+
let { authClient: x, basePaths: S, viewPaths: C, localization: w, plugins: T } = n(), { data: E, isPending: D } = r(x), O = T.flatMap((e) => e.userMenuItems?.map((t, n) => /* @__PURE__ */ h(t, {}, `${e.id}-${n.toString()}`)) ?? []);
|
|
10
|
+
return /* @__PURE__ */ g(u, { children: [y === "icon" ? /* @__PURE__ */ h(u.Trigger, {
|
|
11
|
+
className: p("rounded-full", _),
|
|
12
|
+
children: /* @__PURE__ */ h(e, {})
|
|
13
|
+
}) : /* @__PURE__ */ g(l, {
|
|
14
|
+
variant: b,
|
|
15
|
+
className: p("h-auto font-normal justify-start px-3 py-2 text-left", _),
|
|
16
|
+
children: [E || D ? /* @__PURE__ */ h(t, { isPending: D }) : /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(e, {}), /* @__PURE__ */ h("p", {
|
|
17
|
+
className: "text-sm font-medium",
|
|
18
|
+
children: w.auth.account
|
|
19
|
+
})] }), /* @__PURE__ */ h(o, { className: "ml-auto size-3.5" })]
|
|
20
|
+
}), /* @__PURE__ */ g(u.Popover, {
|
|
21
|
+
placement: v,
|
|
22
|
+
className: "min-w-40 md:min-w-56 max-w-[48svw]",
|
|
23
|
+
children: [E && /* @__PURE__ */ h("div", {
|
|
24
|
+
className: "px-3 pt-3 pb-1",
|
|
25
|
+
children: /* @__PURE__ */ h(t, {})
|
|
26
|
+
}), /* @__PURE__ */ h(u.Menu, { children: E ? /* @__PURE__ */ g(m, { children: [
|
|
27
|
+
/* @__PURE__ */ g(u.Item, {
|
|
28
|
+
textValue: w.settings.settings,
|
|
29
|
+
href: `${S.settings}/${C.settings.account}`,
|
|
30
|
+
children: [/* @__PURE__ */ h(s, { className: "text-muted" }), /* @__PURE__ */ h(d, { children: w.settings.settings })]
|
|
31
|
+
}),
|
|
32
|
+
O,
|
|
33
|
+
/* @__PURE__ */ h(f, {}),
|
|
34
|
+
/* @__PURE__ */ g(u.Item, {
|
|
35
|
+
textValue: w.auth.signOut,
|
|
36
|
+
href: `${S.auth}/${C.auth.signOut}`,
|
|
37
|
+
children: [/* @__PURE__ */ h(i, { className: "text-muted" }), /* @__PURE__ */ h(d, { children: w.auth.signOut })]
|
|
38
|
+
})
|
|
39
|
+
] }) : /* @__PURE__ */ g(m, { children: [
|
|
40
|
+
/* @__PURE__ */ g(u.Item, {
|
|
41
|
+
textValue: w.auth.signIn,
|
|
42
|
+
href: `${S.auth}/${C.auth.signIn}`,
|
|
43
|
+
children: [/* @__PURE__ */ h(a, { className: "text-muted" }), /* @__PURE__ */ h(d, { children: w.auth.signIn })]
|
|
44
|
+
}),
|
|
45
|
+
/* @__PURE__ */ g(u.Item, {
|
|
46
|
+
textValue: w.auth.signUp,
|
|
47
|
+
href: `${S.auth}/${C.auth.signUp}`,
|
|
48
|
+
children: [/* @__PURE__ */ h(c, { className: "text-muted" }), /* @__PURE__ */ h(d, { children: w.auth.signUp })]
|
|
49
|
+
}),
|
|
50
|
+
O
|
|
51
|
+
] }) })]
|
|
52
|
+
})] });
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { _ as UserButton };
|