@better-auth-ui/heroui 1.6.8 → 1.6.9
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 +2 -2
- package/dist/components/auth/additional-field.js +133 -266
- package/dist/components/auth/api-key/api-key-skeleton.js +4 -20
- package/dist/components/auth/api-key/api-key.d.ts +6 -2
- package/dist/components/auth/api-key/api-key.js +16 -54
- package/dist/components/auth/api-key/api-keys-empty.d.ts +3 -1
- package/dist/components/auth/api-key/api-keys-empty.js +8 -34
- package/dist/components/auth/api-key/api-keys.d.ts +10 -2
- package/dist/components/auth/api-key/api-keys.js +21 -40
- package/dist/components/auth/api-key/create-api-key-dialog.d.ts +3 -1
- package/dist/components/auth/api-key/create-api-key-dialog.js +43 -73
- package/dist/components/auth/api-key/delete-api-key-dialog.d.ts +4 -2
- package/dist/components/auth/api-key/delete-api-key-dialog.js +16 -50
- package/dist/components/auth/api-key/new-api-key-dialog.js +23 -59
- package/dist/components/auth/api-key/organization-api-keys.d.ts +14 -0
- package/dist/components/auth/api-key/organization-api-keys.js +22 -0
- package/dist/components/auth/auth-provider.d.ts +1 -1
- package/dist/components/auth/auth-provider.js +10 -16
- package/dist/components/auth/auth.d.ts +3 -3
- package/dist/components/auth/auth.js +86 -61
- package/dist/components/auth/delete-user/danger-zone.d.ts +3 -3
- package/dist/components/auth/delete-user/danger-zone.js +11 -17
- package/dist/components/auth/delete-user/delete-account.d.ts +9 -0
- package/dist/components/auth/delete-user/delete-account.js +50 -0
- package/dist/components/auth/email/email-changed-email.d.ts +2 -2
- package/dist/components/auth/email/email-changed-email.js +22 -29
- package/dist/components/auth/email/email-verification-email.d.ts +2 -2
- package/dist/components/auth/email/email-verification-email.js +22 -29
- package/dist/components/auth/email/magic-link-email.d.ts +2 -2
- package/dist/components/auth/email/magic-link-email.js +22 -29
- package/dist/components/auth/email/new-device-email.d.ts +2 -2
- package/dist/components/auth/email/new-device-email.js +22 -29
- package/dist/components/auth/email/organization-invitation-email.d.ts +3 -0
- package/dist/components/auth/email/organization-invitation-email.js +23 -0
- package/dist/components/auth/email/otp-email.d.ts +2 -2
- package/dist/components/auth/email/otp-email.js +21 -28
- package/dist/components/auth/email/password-changed-email.d.ts +2 -2
- package/dist/components/auth/email/password-changed-email.js +22 -29
- package/dist/components/auth/email/reset-password-email.d.ts +2 -2
- package/dist/components/auth/email/reset-password-email.js +22 -29
- package/dist/components/auth/error-toaster.js +32 -16
- package/dist/components/auth/field-separator.d.ts +1 -1
- package/dist/components/auth/field-separator.js +4 -17
- package/dist/components/auth/forgot-password.d.ts +1 -1
- package/dist/components/auth/forgot-password.js +36 -88
- package/dist/components/auth/magic-link/magic-link-button.d.ts +1 -1
- package/dist/components/auth/magic-link/magic-link-button.js +33 -19
- package/dist/components/auth/magic-link/magic-link.d.ts +2 -2
- package/dist/components/auth/magic-link/magic-link.js +39 -86
- package/dist/components/auth/multi-session/manage-account.d.ts +1 -1
- package/dist/components/auth/multi-session/manage-account.js +32 -48
- package/dist/components/auth/multi-session/manage-accounts.d.ts +1 -1
- package/dist/components/auth/multi-session/manage-accounts.js +32 -33
- package/dist/components/auth/multi-session/switch-account-submenu-content.d.ts +3 -1
- package/dist/components/auth/multi-session/switch-account-submenu-content.js +24 -27
- package/dist/components/auth/multi-session/switch-account-submenu-item.d.ts +3 -2
- package/dist/components/auth/multi-session/switch-account-submenu-item.js +16 -19
- package/dist/components/auth/multi-session/switch-account-submenu.d.ts +2 -1
- package/dist/components/auth/multi-session/switch-account-submenu.js +23 -23
- package/dist/components/auth/organization/change-organization-logo.d.ts +4 -0
- package/dist/components/auth/organization/change-organization-logo.js +69 -0
- package/dist/components/auth/organization/create-organization-dialog.d.ts +13 -0
- package/dist/components/auth/organization/create-organization-dialog.js +37 -0
- package/dist/components/auth/organization/delete-organization-dialog.d.ts +7 -0
- package/dist/components/auth/organization/delete-organization-dialog.js +25 -0
- package/dist/components/auth/organization/delete-organization-skeleton.d.ts +4 -0
- package/dist/components/auth/organization/delete-organization-skeleton.js +8 -0
- package/dist/components/auth/organization/delete-organization.d.ts +5 -0
- package/dist/components/auth/organization/delete-organization.js +27 -0
- package/dist/components/auth/organization/invite-member-dialog.d.ts +13 -0
- package/dist/components/auth/organization/invite-member-dialog.js +47 -0
- package/dist/components/auth/organization/leave-organization-dialog.d.ts +7 -0
- package/dist/components/auth/organization/leave-organization-dialog.js +21 -0
- package/dist/components/auth/organization/leave-organization.d.ts +4 -0
- package/dist/components/auth/organization/leave-organization.js +16 -0
- package/dist/components/auth/organization/organization-danger-zone.d.ts +16 -0
- package/dist/components/auth/organization/organization-danger-zone.js +23 -0
- package/dist/components/auth/organization/organization-invitation-row-skeleton.d.ts +5 -0
- package/dist/components/auth/organization/organization-invitation-row-skeleton.js +9 -0
- package/dist/components/auth/organization/organization-invitation-row.d.ts +5 -0
- package/dist/components/auth/organization/organization-invitation-row.js +31 -0
- package/dist/components/auth/organization/organization-invitations-empty.d.ts +8 -0
- package/dist/components/auth/organization/organization-invitations-empty.js +13 -0
- package/dist/components/auth/organization/organization-invitations.d.ts +9 -0
- package/dist/components/auth/organization/organization-invitations.js +66 -0
- package/dist/components/auth/organization/organization-logo.d.ts +15 -0
- package/dist/components/auth/organization/organization-logo.js +14 -0
- package/dist/components/auth/organization/organization-member-row-skeleton.d.ts +4 -0
- package/dist/components/auth/organization/organization-member-row-skeleton.js +9 -0
- package/dist/components/auth/organization/organization-member-row.d.ts +9 -0
- package/dist/components/auth/organization/organization-member-row.js +34 -0
- package/dist/components/auth/organization/organization-members.d.ts +9 -0
- package/dist/components/auth/organization/organization-members.js +67 -0
- package/dist/components/auth/organization/organization-people.d.ts +10 -0
- package/dist/components/auth/organization/organization-people.js +11 -0
- package/dist/components/auth/organization/organization-profile.d.ts +9 -0
- package/dist/components/auth/organization/organization-profile.js +34 -0
- package/dist/components/auth/organization/organization-row.d.ts +8 -0
- package/dist/components/auth/organization/organization-row.js +31 -0
- package/dist/components/auth/organization/organization-settings.d.ts +12 -0
- package/dist/components/auth/organization/organization-settings.js +13 -0
- package/dist/components/auth/organization/organization-switcher.d.ts +20 -0
- package/dist/components/auth/organization/organization-switcher.js +48 -0
- package/dist/components/auth/organization/organization-view-skeleton.d.ts +6 -0
- package/dist/components/auth/organization/organization-view-skeleton.js +9 -0
- package/dist/components/auth/organization/organization-view.d.ts +15 -0
- package/dist/components/auth/organization/organization-view.js +31 -0
- package/dist/components/auth/organization/organization.d.ts +17 -0
- package/dist/components/auth/organization/organization.js +60 -0
- package/dist/components/auth/organization/organizations-empty.d.ts +4 -0
- package/dist/components/auth/organization/organizations-empty.js +9 -0
- package/dist/components/auth/organization/organizations-settings.d.ts +17 -0
- package/dist/components/auth/organization/organizations-settings.js +17 -0
- package/dist/components/auth/organization/organizations.d.ts +10 -0
- package/dist/components/auth/organization/organizations.js +21 -0
- package/dist/components/auth/organization/remove-member-dialog.d.ts +9 -0
- package/dist/components/auth/organization/remove-member-dialog.js +20 -0
- package/dist/components/auth/organization/slug-field.d.ts +19 -0
- package/dist/components/auth/organization/slug-field.js +38 -0
- package/dist/components/auth/organization/user-invitation-row-skeleton.d.ts +4 -0
- package/dist/components/auth/organization/user-invitation-row-skeleton.js +8 -0
- package/dist/components/auth/organization/user-invitation-row.d.ts +10 -0
- package/dist/components/auth/organization/user-invitation-row.js +22 -0
- package/dist/components/auth/organization/user-invitations-empty.d.ts +4 -0
- package/dist/components/auth/organization/user-invitations-empty.js +12 -0
- package/dist/components/auth/organization/user-invitations.d.ts +10 -0
- package/dist/components/auth/organization/user-invitations.js +18 -0
- package/dist/components/auth/passkey/add-passkey-dialog.js +21 -64
- package/dist/components/auth/passkey/delete-passkey-dialog.js +13 -46
- package/dist/components/auth/passkey/passkey-button.d.ts +1 -1
- package/dist/components/auth/passkey/passkey-button.js +24 -23
- package/dist/components/auth/passkey/passkey-skeleton.js +4 -16
- package/dist/components/auth/passkey/passkey.d.ts +1 -1
- package/dist/components/auth/passkey/passkey.js +16 -47
- package/dist/components/auth/passkey/passkeys-empty.js +8 -34
- package/dist/components/auth/passkey/passkeys.d.ts +1 -1
- package/dist/components/auth/passkey/passkeys.js +15 -41
- package/dist/components/auth/provider-button.d.ts +2 -2
- package/dist/components/auth/provider-button.js +28 -24
- package/dist/components/auth/provider-buttons.js +28 -18
- package/dist/components/auth/reset-password.d.ts +1 -1
- package/dist/components/auth/reset-password.js +56 -146
- package/dist/components/auth/settings/account/account-settings.d.ts +2 -2
- package/dist/components/auth/settings/account/account-settings.js +21 -19
- package/dist/components/auth/settings/account/change-avatar.js +53 -88
- package/dist/components/auth/settings/account/change-email.d.ts +1 -1
- package/dist/components/auth/settings/account/change-email.js +27 -53
- package/dist/components/auth/settings/account/user-profile.d.ts +1 -1
- package/dist/components/auth/settings/account/user-profile.js +64 -85
- package/dist/components/auth/settings/security/active-session.d.ts +1 -1
- package/dist/components/auth/settings/security/active-session.js +50 -57
- package/dist/components/auth/settings/security/active-sessions.d.ts +1 -1
- package/dist/components/auth/settings/security/active-sessions.js +21 -32
- package/dist/components/auth/settings/security/change-password.d.ts +1 -1
- package/dist/components/auth/settings/security/change-password.js +76 -186
- package/dist/components/auth/settings/security/linked-account.d.ts +1 -1
- package/dist/components/auth/settings/security/linked-account.js +37 -55
- package/dist/components/auth/settings/security/linked-accounts.d.ts +1 -1
- package/dist/components/auth/settings/security/linked-accounts.js +34 -43
- package/dist/components/auth/settings/security/security-settings.d.ts +2 -2
- package/dist/components/auth/settings/security/security-settings.js +19 -21
- package/dist/components/auth/settings/settings.d.ts +4 -4
- package/dist/components/auth/settings/settings.js +52 -44
- package/dist/components/auth/sign-in.d.ts +2 -2
- package/dist/components/auth/sign-in.js +63 -132
- package/dist/components/auth/sign-out.js +32 -26
- package/dist/components/auth/sign-up.d.ts +2 -2
- package/dist/components/auth/sign-up.js +97 -211
- package/dist/components/auth/theme/appearance.d.ts +1 -1
- package/dist/components/auth/theme/appearance.js +23 -71
- package/dist/components/auth/theme/theme-toggle-item.js +56 -61
- package/dist/components/auth/user/user-avatar.d.ts +4 -4
- package/dist/components/auth/user/user-avatar.js +31 -28
- package/dist/components/auth/user/user-button.d.ts +6 -7
- package/dist/components/auth/user/user-button.js +38 -72
- package/dist/components/auth/user/user-view.d.ts +13 -7
- package/dist/components/auth/user/user-view.js +26 -36
- package/dist/components/auth/username/sign-in-username.d.ts +2 -2
- package/dist/components/auth/username/sign-in-username.js +87 -147
- package/dist/components/auth/username/username-field.d.ts +1 -1
- package/dist/components/auth/username/username-field.js +44 -52
- package/dist/email.d.ts +8 -7
- package/dist/email.js +8 -8
- package/dist/index.d.ts +21 -21
- package/dist/index.js +21 -22
- package/dist/lib/auth/api-key-plugin.d.ts +7 -4
- package/dist/lib/auth/api-key-plugin.js +12 -10
- package/dist/lib/auth/auth-plugin.d.ts +10 -6
- package/dist/lib/auth/auth-plugin.js +1 -0
- package/dist/lib/auth/delete-user-plugin.d.ts +6 -6
- package/dist/lib/auth/delete-user-plugin.js +6 -9
- package/dist/lib/auth/magic-link-plugin.d.ts +5 -5
- package/dist/lib/auth/magic-link-plugin.js +17 -12
- package/dist/lib/auth/multi-session-plugin.d.ts +5 -5
- package/dist/lib/auth/multi-session-plugin.js +8 -11
- package/dist/lib/auth/organization-plugin.d.ts +37 -0
- package/dist/lib/auth/organization-plugin.js +19 -0
- package/dist/lib/auth/passkey-plugin.d.ts +5 -5
- package/dist/lib/auth/passkey-plugin.js +8 -11
- package/dist/lib/auth/theme-plugin.d.ts +6 -6
- package/dist/lib/auth/theme-plugin.js +25 -22
- package/dist/lib/auth/username-plugin.d.ts +11 -11
- package/dist/lib/auth/username-plugin.js +18 -17
- package/dist/plugins.d.ts +46 -22
- package/dist/plugins.js +47 -22
- package/package.json +25 -19
- package/src/components/auth/api-key/api-key.tsx +25 -16
- package/src/components/auth/api-key/api-keys-empty.tsx +8 -4
- package/src/components/auth/api-key/api-keys.tsx +52 -14
- package/src/components/auth/api-key/create-api-key-dialog.tsx +15 -2
- package/src/components/auth/api-key/delete-api-key-dialog.tsx +10 -2
- package/src/components/auth/api-key/organization-api-keys.tsx +55 -0
- package/src/components/auth/delete-user/danger-zone.tsx +3 -3
- package/src/components/auth/delete-user/{delete-user.tsx → delete-account.tsx} +9 -9
- package/src/components/auth/email/organization-invitation-email.tsx +38 -0
- package/src/components/auth/error-toaster.tsx +28 -10
- package/src/components/auth/forgot-password.tsx +10 -2
- package/src/components/auth/multi-session/manage-accounts.tsx +1 -1
- package/src/components/auth/multi-session/switch-account-submenu-content.tsx +7 -2
- package/src/components/auth/multi-session/switch-account-submenu-item.tsx +4 -2
- package/src/components/auth/multi-session/switch-account-submenu.tsx +8 -4
- package/src/components/auth/organization/change-organization-logo.tsx +171 -0
- package/src/components/auth/organization/create-organization-dialog.tsx +133 -0
- package/src/components/auth/organization/delete-organization-dialog.tsx +97 -0
- package/src/components/auth/organization/delete-organization-skeleton.tsx +17 -0
- package/src/components/auth/organization/delete-organization.tsx +77 -0
- package/src/components/auth/organization/invite-member-dialog.tsx +177 -0
- package/src/components/auth/organization/leave-organization-dialog.tsx +95 -0
- package/src/components/auth/organization/leave-organization.tsx +59 -0
- package/src/components/auth/organization/organization-danger-zone.tsx +68 -0
- package/src/components/auth/organization/organization-invitation-row-skeleton.tsx +29 -0
- package/src/components/auth/organization/organization-invitation-row.tsx +97 -0
- package/src/components/auth/organization/organization-invitations-empty.tsx +39 -0
- package/src/components/auth/organization/organization-invitations.tsx +351 -0
- package/src/components/auth/organization/organization-logo.tsx +64 -0
- package/src/components/auth/organization/organization-member-row-skeleton.tsx +24 -0
- package/src/components/auth/organization/organization-member-row.tsx +157 -0
- package/src/components/auth/organization/organization-members.tsx +284 -0
- package/src/components/auth/organization/organization-people.tsx +26 -0
- package/src/components/auth/organization/organization-profile.tsx +141 -0
- package/src/components/auth/organization/organization-row.tsx +66 -0
- package/src/components/auth/organization/organization-settings.tsx +38 -0
- package/src/components/auth/organization/organization-switcher.tsx +233 -0
- package/src/components/auth/organization/organization-view-skeleton.tsx +36 -0
- package/src/components/auth/organization/organization-view.tsx +109 -0
- package/src/components/auth/organization/organization.tsx +162 -0
- package/src/components/auth/organization/organizations-empty.tsx +35 -0
- package/src/components/auth/organization/organizations-settings.tsx +36 -0
- package/src/components/auth/organization/organizations.tsx +80 -0
- package/src/components/auth/organization/remove-member-dialog.tsx +95 -0
- package/src/components/auth/organization/slug-field.tsx +111 -0
- package/src/components/auth/organization/user-invitation-row-skeleton.tsx +17 -0
- package/src/components/auth/organization/user-invitation-row.tsx +90 -0
- package/src/components/auth/organization/user-invitations-empty.tsx +30 -0
- package/src/components/auth/organization/user-invitations.tsx +59 -0
- package/src/components/auth/settings/account/change-email.tsx +1 -1
- package/src/components/auth/settings/account/user-profile.tsx +5 -5
- package/src/components/auth/settings/security/active-sessions.tsx +6 -4
- package/src/components/auth/settings/security/linked-accounts.tsx +2 -2
- package/src/components/auth/settings/settings.tsx +77 -14
- package/src/components/auth/user/user-avatar.tsx +4 -1
- package/src/components/auth/user/user-button.tsx +14 -11
- package/src/components/auth/user/user-view.tsx +32 -12
- package/src/email.ts +1 -0
- package/src/lib/auth/api-key-plugin.ts +10 -4
- package/src/lib/auth/auth-plugin.ts +6 -1
- package/src/lib/auth/organization-plugin.tsx +32 -0
- package/src/plugins.ts +25 -1
- package/dist/components/auth/delete-user/delete-user.d.ts +0 -9
- package/dist/components/auth/delete-user/delete-user.js +0 -95
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return /* @__PURE__ */ n("div", {
|
|
6
|
-
className: "flex items-center gap-4",
|
|
7
|
-
children: [
|
|
8
|
-
/* @__PURE__ */ t(e, { className: "flex-1" }),
|
|
9
|
-
/* @__PURE__ */ t("p", {
|
|
10
|
-
className: "text-xs text-muted shrink-0",
|
|
11
|
-
children: r
|
|
12
|
-
}),
|
|
13
|
-
/* @__PURE__ */ t(e, { className: "flex-1" })
|
|
14
|
-
]
|
|
15
|
-
});
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Separator } from "@heroui/react";
|
|
3
|
+
export function FieldSeparator({ children }) {
|
|
4
|
+
return (_jsxs("div", { className: "flex items-center gap-4", children: [_jsx(Separator, { className: "flex-1" }), _jsx("p", { className: "text-xs text-muted shrink-0", children: children }), _jsx(Separator, { className: "flex-1" })] }));
|
|
16
5
|
}
|
|
17
|
-
//#endregion
|
|
18
|
-
export { r as FieldSeparator };
|
|
@@ -1,89 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
name: "email",
|
|
38
|
-
type: "email",
|
|
39
|
-
autoComplete: "email",
|
|
40
|
-
isDisabled: k,
|
|
41
|
-
children: [
|
|
42
|
-
/* @__PURE__ */ h(l, { children: S.auth.email }),
|
|
43
|
-
/* @__PURE__ */ h(c, {
|
|
44
|
-
placeholder: S.auth.emailPlaceholder,
|
|
45
|
-
required: !0,
|
|
46
|
-
variant: v === "transparent" ? "primary" : "secondary"
|
|
47
|
-
}),
|
|
48
|
-
/* @__PURE__ */ h(o, {})
|
|
49
|
-
]
|
|
50
|
-
}),
|
|
51
|
-
j && /* @__PURE__ */ h("div", {
|
|
52
|
-
className: "flex justify-center",
|
|
53
|
-
children: j
|
|
54
|
-
}),
|
|
55
|
-
/* @__PURE__ */ h("div", {
|
|
56
|
-
className: "flex flex-col gap-3",
|
|
57
|
-
children: /* @__PURE__ */ g(r, {
|
|
58
|
-
type: "submit",
|
|
59
|
-
className: "w-full",
|
|
60
|
-
isPending: k,
|
|
61
|
-
children: [k && /* @__PURE__ */ h(d, {
|
|
62
|
-
color: "current",
|
|
63
|
-
size: "sm"
|
|
64
|
-
}), S.auth.sendResetLink]
|
|
65
|
-
})
|
|
66
|
-
})
|
|
67
|
-
]
|
|
68
|
-
})
|
|
69
|
-
}),
|
|
70
|
-
/* @__PURE__ */ h(i.Footer, {
|
|
71
|
-
className: "flex-col gap-3",
|
|
72
|
-
children: /* @__PURE__ */ g(a, {
|
|
73
|
-
className: "text-sm",
|
|
74
|
-
children: [
|
|
75
|
-
S.auth.rememberYourPassword,
|
|
76
|
-
" ",
|
|
77
|
-
/* @__PURE__ */ h(u, {
|
|
78
|
-
href: `${x.auth}/${C.auth.signIn}`,
|
|
79
|
-
className: "text-accent no-underline hover:underline decoration-accent-hover",
|
|
80
|
-
children: S.auth.signIn
|
|
81
|
-
})
|
|
82
|
-
]
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
]
|
|
86
|
-
});
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useAuth, useFetchOptions, useRequestPasswordReset } from "@better-auth-ui/react";
|
|
3
|
+
import { Button, Card, cn, Description, FieldError, Form, Input, Label, Link, Spinner, TextField, toast } from "@heroui/react";
|
|
4
|
+
/**
|
|
5
|
+
* Render a card-based "Forgot Password" form that sends a password-reset email.
|
|
6
|
+
*
|
|
7
|
+
* The form displays an email input, submit button, and a link back to sign-in.
|
|
8
|
+
* Toasts are displayed on success or error via the `useRequestPasswordReset` hook.
|
|
9
|
+
*
|
|
10
|
+
* @param className - Optional additional CSS class names applied to the card
|
|
11
|
+
* @returns The forgot-password form UI as a JSX element
|
|
12
|
+
*/
|
|
13
|
+
export function ForgotPassword({ className, variant, ...props }) {
|
|
14
|
+
const { authClient, baseURL, basePaths, localization, viewPaths, navigate, plugins } = useAuth();
|
|
15
|
+
const { fetchOptions, resetFetchOptions } = useFetchOptions();
|
|
16
|
+
const { mutate: requestPasswordReset, isPending } = useRequestPasswordReset(authClient, {
|
|
17
|
+
onError: (error) => {
|
|
18
|
+
toast.danger(error.error?.message || error.message);
|
|
19
|
+
resetFetchOptions();
|
|
20
|
+
},
|
|
21
|
+
onSuccess: () => {
|
|
22
|
+
toast.success(localization.auth.passwordResetEmailSent);
|
|
23
|
+
navigate({ to: `${basePaths.auth}/${viewPaths.auth.signIn}` });
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
function handleSubmit(e) {
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
const formData = new FormData(e.currentTarget);
|
|
29
|
+
requestPasswordReset({
|
|
30
|
+
email: formData.get("email"),
|
|
31
|
+
redirectTo: `${baseURL}${basePaths.auth}/${viewPaths.auth.resetPassword}`,
|
|
32
|
+
fetchOptions
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const Captcha = plugins.find((plugin) => plugin.captchaComponent)?.captchaComponent;
|
|
36
|
+
return (_jsxs(Card, { className: cn("w-full max-w-sm gap-4 md:p-6", className), variant: variant, ...props, children: [_jsx(Card.Header, { children: _jsx(Card.Title, { className: "text-xl font-semibold mb-1", children: localization.auth.forgotPassword }) }), _jsx(Card.Content, { className: "gap-4", children: _jsxs(Form, { onSubmit: handleSubmit, className: "flex flex-col gap-4", children: [_jsxs(TextField, { name: "email", type: "email", autoComplete: "email", isDisabled: isPending, children: [_jsx(Label, { children: localization.auth.email }), _jsx(Input, { placeholder: localization.auth.emailPlaceholder, required: true, variant: variant === "transparent" ? "primary" : "secondary" }), _jsx(FieldError, {})] }), Captcha && _jsx("div", { className: "flex justify-center", children: Captcha }), _jsx("div", { className: "flex flex-col gap-3", children: _jsxs(Button, { type: "submit", className: "w-full", isPending: isPending, children: [isPending && _jsx(Spinner, { color: "current", size: "sm" }), localization.auth.sendResetLink] }) })] }) }), _jsx(Card.Footer, { className: "flex-col gap-3", children: _jsxs(Description, { className: "text-sm", children: [localization.auth.rememberYourPassword, " ", _jsx(Link, { href: `${basePaths.auth}/${viewPaths.auth.signIn}`, className: "text-accent no-underline hover:underline decoration-accent-hover", children: localization.auth.signIn })] }) })] }));
|
|
87
37
|
}
|
|
88
|
-
//#endregion
|
|
89
|
-
export { _ as ForgotPassword };
|
|
@@ -1,20 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { authMutationKeys
|
|
3
|
-
import { useAuth
|
|
4
|
-
import { Envelope
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { useIsMutating
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { authMutationKeys } from "@better-auth-ui/core";
|
|
3
|
+
import { useAuth, useAuthPlugin } from "@better-auth-ui/react";
|
|
4
|
+
import { Envelope, Lock } from "@gravity-ui/icons";
|
|
5
|
+
import { cn, Link } from "@heroui/react";
|
|
6
|
+
import { buttonVariants } from "@heroui/styles";
|
|
7
|
+
import { useIsMutating } from "@tanstack/react-query";
|
|
8
|
+
import { magicLinkPlugin } from "../../../lib/auth/magic-link-plugin";
|
|
9
|
+
/**
|
|
10
|
+
* Toggle button between the password sign-in and magic-link routes.
|
|
11
|
+
*
|
|
12
|
+
* @param view - Current auth view. On `"magicLink"` this links back to password sign-in.
|
|
13
|
+
*/
|
|
14
|
+
export function MagicLinkButton({ view }) {
|
|
15
|
+
const { basePaths, emailAndPassword, viewPaths, localization } = useAuth();
|
|
16
|
+
const signInMutating = useIsMutating({
|
|
17
|
+
mutationKey: authMutationKeys.signIn.all
|
|
18
|
+
});
|
|
19
|
+
const signUpMutating = useIsMutating({
|
|
20
|
+
mutationKey: authMutationKeys.signUp.all
|
|
21
|
+
});
|
|
22
|
+
const isPending = signInMutating + signUpMutating > 0;
|
|
23
|
+
const { localization: magicLinkLocalization, viewPaths: magicLinkViewPaths } = useAuthPlugin(magicLinkPlugin);
|
|
24
|
+
const isMagicLinkView = view === "magicLink";
|
|
25
|
+
// On the magic-link view this button switches back to password sign-in.
|
|
26
|
+
// With password auth disabled there's nowhere to switch to, so hide it.
|
|
27
|
+
// (Other views — e.g. a phone-number plugin's surface — still get a
|
|
28
|
+
// "Continue with Magic Link" link.)
|
|
29
|
+
if (isMagicLinkView && !emailAndPassword?.enabled)
|
|
30
|
+
return null;
|
|
31
|
+
return (_jsxs(Link, { href: `${basePaths.auth}/${isMagicLinkView ? viewPaths.auth.signIn : magicLinkViewPaths.auth.magicLink}`, isDisabled: isPending, className: cn(buttonVariants({ variant: "tertiary" }), "w-full gap-2", isPending && "status-disabled"), children: [isMagicLinkView ? _jsx(Lock, {}) : _jsx(Envelope, {}), localization.auth.continueWith.replace("{{provider}}", isMagicLinkView
|
|
32
|
+
? localization.auth.password
|
|
33
|
+
: magicLinkLocalization.magicLink)] }));
|
|
18
34
|
}
|
|
19
|
-
//#endregion
|
|
20
|
-
export { f as MagicLinkButton };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CardProps } from
|
|
2
|
-
import { SocialLayout } from
|
|
1
|
+
import { type CardProps } from "@heroui/react";
|
|
2
|
+
import { type SocialLayout } from "../provider-buttons";
|
|
3
3
|
export type MagicLinkProps = {
|
|
4
4
|
className?: string;
|
|
5
5
|
socialLayout?: SocialLayout;
|
|
@@ -1,87 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
isDisabled: U,
|
|
41
|
-
value: z,
|
|
42
|
-
onChange: B,
|
|
43
|
-
children: [
|
|
44
|
-
/* @__PURE__ */ x(p, { children: N.auth.email }),
|
|
45
|
-
/* @__PURE__ */ x(f, {
|
|
46
|
-
placeholder: N.auth.emailPlaceholder,
|
|
47
|
-
required: !0,
|
|
48
|
-
variant: D === "transparent" ? "primary" : "secondary"
|
|
49
|
-
}),
|
|
50
|
-
/* @__PURE__ */ x(u, {})
|
|
51
|
-
]
|
|
52
|
-
}), /* @__PURE__ */ S("div", {
|
|
53
|
-
className: "flex flex-col gap-3",
|
|
54
|
-
children: [/* @__PURE__ */ S(s, {
|
|
55
|
-
type: "submit",
|
|
56
|
-
className: "w-full",
|
|
57
|
-
isPending: U,
|
|
58
|
-
children: [H && /* @__PURE__ */ x(h, {
|
|
59
|
-
color: "current",
|
|
60
|
-
size: "sm"
|
|
61
|
-
}), R.sendMagicLink]
|
|
62
|
-
}), P.flatMap((e) => (e.authButtons ?? []).map((t, n) => /* @__PURE__ */ x(t, { view: "magicLink" }, `${e.id}-${n.toString()}`)))]
|
|
63
|
-
})]
|
|
64
|
-
}),
|
|
65
|
-
E === "bottom" && /* @__PURE__ */ S(b, { children: [G && /* @__PURE__ */ x(e, { children: N.auth.or }), !!I?.length && /* @__PURE__ */ x(t, { socialLayout: T })] })
|
|
66
|
-
]
|
|
67
|
-
}),
|
|
68
|
-
M?.enabled && /* @__PURE__ */ x(c.Footer, {
|
|
69
|
-
className: "flex-col gap-3",
|
|
70
|
-
children: /* @__PURE__ */ S(l, {
|
|
71
|
-
className: "text-sm",
|
|
72
|
-
children: [
|
|
73
|
-
N.auth.needToCreateAnAccount,
|
|
74
|
-
" ",
|
|
75
|
-
/* @__PURE__ */ x(m, {
|
|
76
|
-
href: `${A.auth}/${L.auth.signUp}`,
|
|
77
|
-
className: "text-accent no-underline hover:underline decoration-accent-hover",
|
|
78
|
-
children: N.auth.signUp
|
|
79
|
-
})
|
|
80
|
-
]
|
|
81
|
-
})
|
|
82
|
-
})
|
|
83
|
-
]
|
|
84
|
-
});
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { authMutationKeys } from "@better-auth-ui/core";
|
|
3
|
+
import { useAuth, useAuthPlugin, useSignInMagicLink } from "@better-auth-ui/react";
|
|
4
|
+
import { Button, Card, cn, Description, FieldError, Form, Input, Label, Link, Spinner, TextField, toast } from "@heroui/react";
|
|
5
|
+
import { useIsMutating } from "@tanstack/react-query";
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import { magicLinkPlugin } from "../../../lib/auth/magic-link-plugin";
|
|
8
|
+
import { FieldSeparator } from "../field-separator";
|
|
9
|
+
import { ProviderButtons } from "../provider-buttons";
|
|
10
|
+
/**
|
|
11
|
+
* Magic-link sign-in form.
|
|
12
|
+
*
|
|
13
|
+
* @param socialLayout - Provider button layout.
|
|
14
|
+
* @param socialPosition - `"top"` or `"bottom"`. Defaults to `"bottom"`.
|
|
15
|
+
* @param variant - Card variant.
|
|
16
|
+
*/
|
|
17
|
+
export function MagicLink({ className, socialLayout, socialPosition = "bottom", variant, ...props }) {
|
|
18
|
+
const { authClient, basePaths, baseURL, emailAndPassword, localization, plugins, redirectTo, socialProviders, viewPaths } = useAuth();
|
|
19
|
+
const { localization: magicLinkLocalization } = useAuthPlugin(magicLinkPlugin);
|
|
20
|
+
const [email, setEmail] = useState("");
|
|
21
|
+
const { mutate: signInMagicLink, isPending: signInMagicLinkPending } = useSignInMagicLink(authClient, {
|
|
22
|
+
onSuccess: () => {
|
|
23
|
+
setEmail("");
|
|
24
|
+
toast.success(magicLinkLocalization.magicLinkSent);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const signInMutating = useIsMutating({
|
|
28
|
+
mutationKey: authMutationKeys.signIn.all
|
|
29
|
+
});
|
|
30
|
+
const signUpMutating = useIsMutating({
|
|
31
|
+
mutationKey: authMutationKeys.signUp.all
|
|
32
|
+
});
|
|
33
|
+
const isPending = signInMutating + signUpMutating > 0;
|
|
34
|
+
const handleSubmit = (e) => {
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
signInMagicLink({ email, callbackURL: `${baseURL}${redirectTo}` });
|
|
37
|
+
};
|
|
38
|
+
const showSeparator = !!socialProviders?.length;
|
|
39
|
+
return (_jsxs(Card, { className: cn("w-full max-w-sm gap-4 md:p-6", className), variant: variant, ...props, children: [_jsx(Card.Header, { children: _jsx(Card.Title, { className: "text-xl font-semibold mb-1", children: localization.auth.signIn }) }), _jsxs(Card.Content, { className: "gap-4", children: [socialPosition === "top" && (_jsxs(_Fragment, { children: [!!socialProviders?.length && (_jsx(ProviderButtons, { socialLayout: socialLayout })), showSeparator && (_jsx(FieldSeparator, { children: localization.auth.or }))] })), _jsxs(Form, { onSubmit: handleSubmit, className: "flex flex-col gap-4", children: [_jsxs(TextField, { name: "email", type: "email", autoComplete: "email", isDisabled: isPending, value: email, onChange: setEmail, children: [_jsx(Label, { children: localization.auth.email }), _jsx(Input, { placeholder: localization.auth.emailPlaceholder, required: true, variant: variant === "transparent" ? "primary" : "secondary" }), _jsx(FieldError, {})] }), _jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs(Button, { type: "submit", className: "w-full", isPending: isPending, children: [signInMagicLinkPending && _jsx(Spinner, { color: "current", size: "sm" }), magicLinkLocalization.sendMagicLink] }), plugins.flatMap((plugin) => (plugin.authButtons ?? []).map((AuthButton, index) => (_jsx(AuthButton, { view: "magicLink" }, `${plugin.id}-${index.toString()}`))))] })] }), socialPosition === "bottom" && (_jsxs(_Fragment, { children: [showSeparator && (_jsx(FieldSeparator, { children: localization.auth.or })), !!socialProviders?.length && (_jsx(ProviderButtons, { socialLayout: socialLayout }))] }))] }), emailAndPassword?.enabled && (_jsx(Card.Footer, { className: "flex-col gap-3", children: _jsxs(Description, { className: "text-sm", children: [localization.auth.needToCreateAnAccount, " ", _jsx(Link, { href: `${basePaths.auth}/${viewPaths.auth.signUp}`, className: "text-accent no-underline hover:underline decoration-accent-hover", children: localization.auth.signUp })] }) }))] }));
|
|
85
40
|
}
|
|
86
|
-
//#endregion
|
|
87
|
-
export { w as MagicLink };
|
|
@@ -1,49 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
size: "sm",
|
|
34
|
-
isDisabled: D,
|
|
35
|
-
children: /* @__PURE__ */ m(l, {})
|
|
36
|
-
}), /* @__PURE__ */ m(d.Popover, { children: /* @__PURE__ */ h(d.Menu, { children: [/* @__PURE__ */ h(d.Item, {
|
|
37
|
-
textValue: b.switchAccount,
|
|
38
|
-
onAction: () => S({ sessionToken: g.session.token }),
|
|
39
|
-
children: [/* @__PURE__ */ m(s, { className: "text-muted" }), b.switchAccount]
|
|
40
|
-
}), /* @__PURE__ */ h(d.Item, {
|
|
41
|
-
textValue: y.auth.signOut,
|
|
42
|
-
onAction: () => w({ sessionToken: g.session.token }),
|
|
43
|
-
children: [/* @__PURE__ */ m(c, { className: "text-muted" }), y.auth.signOut]
|
|
44
|
-
})] }) })] })
|
|
45
|
-
]
|
|
46
|
-
});
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useAuth, useAuthPlugin, useRevokeMultiSession, useSetActiveSession, useUser } from "@better-auth-ui/react";
|
|
3
|
+
import { ArrowRightArrowLeft, ArrowRightFromSquare, Ellipsis } from "@gravity-ui/icons";
|
|
4
|
+
import { Button, Dropdown, Spinner, toast } from "@heroui/react";
|
|
5
|
+
import { multiSessionPlugin } from "../../../lib/auth/multi-session-plugin";
|
|
6
|
+
import { UserView } from "../user/user-view";
|
|
7
|
+
/**
|
|
8
|
+
* Render a single account row with user info and a dropdown for switch/sign-out actions.
|
|
9
|
+
*
|
|
10
|
+
* Shows the user's avatar and info. A three-dot menu provides options to
|
|
11
|
+
* switch account (for non-active sessions) and sign out.
|
|
12
|
+
*
|
|
13
|
+
* @param deviceSession - The device session object containing session and user data
|
|
14
|
+
* @returns A JSX element containing the account row
|
|
15
|
+
*/
|
|
16
|
+
export function ManageAccount({ deviceSession, isPending }) {
|
|
17
|
+
const { authClient, localization } = useAuth();
|
|
18
|
+
const { localization: multiSessionLocalization } = useAuthPlugin(multiSessionPlugin);
|
|
19
|
+
const { data: user } = useUser(authClient);
|
|
20
|
+
const { mutate: setActiveSession, isPending: isSwitching } = useSetActiveSession(authClient, {
|
|
21
|
+
onSuccess: () => window.scrollTo({ top: 0 })
|
|
22
|
+
});
|
|
23
|
+
const { mutate: revokeSession, isPending: isRevoking } = useRevokeMultiSession(authClient, {
|
|
24
|
+
onSuccess: () => toast.success(localization.settings.revokeSessionSuccess)
|
|
25
|
+
});
|
|
26
|
+
const isActive = deviceSession?.session.userId === user?.id;
|
|
27
|
+
const isBusy = isSwitching || isRevoking;
|
|
28
|
+
return (_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsx(UserView, { user: deviceSession?.user, isPending: isPending, size: "md" }), deviceSession && isActive && (_jsxs(Button, { className: "shrink-0", variant: "outline", size: "sm", onPress: () => revokeSession({ sessionToken: deviceSession.session.token }), isDisabled: isBusy, children: [isRevoking ? (_jsx(Spinner, { color: "current", size: "sm" })) : (_jsx(ArrowRightFromSquare, {})), localization.auth.signOut] })), deviceSession && !isActive && (_jsxs(Dropdown, { children: [_jsx(Button, { isIconOnly: true, variant: "ghost", className: "shrink-0", size: "sm", isDisabled: isBusy, children: _jsx(Ellipsis, {}) }), _jsx(Dropdown.Popover, { children: _jsxs(Dropdown.Menu, { children: [_jsxs(Dropdown.Item, { textValue: multiSessionLocalization.switchAccount, onAction: () => setActiveSession({
|
|
29
|
+
sessionToken: deviceSession.session.token
|
|
30
|
+
}), children: [_jsx(ArrowRightArrowLeft, { className: "text-muted" }), multiSessionLocalization.switchAccount] }), _jsxs(Dropdown.Item, { textValue: localization.auth.signOut, onAction: () => revokeSession({
|
|
31
|
+
sessionToken: deviceSession.session.token
|
|
32
|
+
}), children: [_jsx(ArrowRightFromSquare, { className: "text-muted" }), localization.auth.signOut] })] }) })] }))] }));
|
|
47
33
|
}
|
|
48
|
-
//#endregion
|
|
49
|
-
export { g as ManageAccount };
|
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useAuth, useAuthPlugin, useListDeviceSessions, useSession } from "@better-auth-ui/react";
|
|
3
|
+
import { Card, cn } from "@heroui/react";
|
|
4
|
+
import { multiSessionPlugin } from "../../../lib/auth/multi-session-plugin";
|
|
5
|
+
import { ManageAccount } from "./manage-account";
|
|
6
|
+
/**
|
|
7
|
+
* Render a card that lists and manages all device sessions for the current user.
|
|
8
|
+
*
|
|
9
|
+
* Shows each session with user information and actions to switch to or revoke a session.
|
|
10
|
+
* When device session data is loading, a pending placeholder row is displayed.
|
|
11
|
+
*
|
|
12
|
+
* @returns A JSX element containing the accounts management card
|
|
13
|
+
*/
|
|
14
|
+
export function ManageAccounts({ className, variant, ...props }) {
|
|
15
|
+
const { authClient } = useAuth();
|
|
16
|
+
const { localization: multiSessionLocalization } = useAuthPlugin(multiSessionPlugin);
|
|
17
|
+
const { data: session } = useSession(authClient);
|
|
18
|
+
const { data: deviceSessions, isPending } = useListDeviceSessions(authClient);
|
|
19
|
+
const otherSessions = deviceSessions?.filter((deviceSession) => deviceSession.session.id !== session?.session.id);
|
|
20
|
+
const allRows = [
|
|
21
|
+
{
|
|
22
|
+
key: session?.session.id ?? "current",
|
|
23
|
+
deviceSession: !isPending ? session : null,
|
|
24
|
+
isPending
|
|
25
|
+
},
|
|
26
|
+
...(otherSessions?.map((deviceSession) => ({
|
|
27
|
+
key: deviceSession.session.id,
|
|
28
|
+
deviceSession,
|
|
29
|
+
isPending: false
|
|
30
|
+
})) ?? [])
|
|
31
|
+
];
|
|
32
|
+
return (_jsxs("div", { children: [_jsx("h2", { className: cn("text-sm font-semibold mb-3"), children: multiSessionLocalization.manageAccounts }), _jsx(Card, { className: cn(className), variant: variant, ...props, children: _jsx(Card.Content, { className: "gap-0", children: allRows.map((row, index) => (_jsxs("div", { children: [index > 0 && (_jsx("div", { className: "border-b border-dashed -mx-4 my-4" })), _jsx(ManageAccount, { deviceSession: row.deviceSession, isPending: row.isPending })] }, row.key))) }) })] }));
|
|
32
33
|
}
|
|
33
|
-
//#endregion
|
|
34
|
-
export { u as ManageAccounts };
|
|
@@ -7,4 +7,6 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @returns The switch account submenu content as a JSX element
|
|
9
9
|
*/
|
|
10
|
-
export declare function SwitchAccountSubmenuContent(
|
|
10
|
+
export declare function SwitchAccountSubmenuContent({ hideSubtitle }: {
|
|
11
|
+
hideSubtitle?: boolean;
|
|
12
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useAuth, useAuthPlugin, useListDeviceSessions, useSession } from "@better-auth-ui/react";
|
|
3
|
+
import { Check, CirclePlus } from "@gravity-ui/icons";
|
|
4
|
+
import { Dropdown, Label } from "@heroui/react";
|
|
5
|
+
import { multiSessionPlugin } from "../../../lib/auth/multi-session-plugin";
|
|
6
|
+
import { UserView } from "../user/user-view";
|
|
7
|
+
import { SwitchAccountSubmenuItem } from "./switch-account-submenu-item";
|
|
8
|
+
/**
|
|
9
|
+
* Render the submenu content for switching between multiple authenticated sessions.
|
|
10
|
+
*
|
|
11
|
+
* Shows the current session with a checkmark, lists other device sessions that can be activated,
|
|
12
|
+
* and provides an option to add a new account. This component should be rendered inside a
|
|
13
|
+
* Dropdown.SubmenuTrigger to defer the useListDeviceSessions query until the submenu is opened.
|
|
14
|
+
*
|
|
15
|
+
* @returns The switch account submenu content as a JSX element
|
|
16
|
+
*/
|
|
17
|
+
export function SwitchAccountSubmenuContent({ hideSubtitle }) {
|
|
18
|
+
const { authClient, basePaths, viewPaths } = useAuth();
|
|
19
|
+
const { localization: multiSessionLocalization } = useAuthPlugin(multiSessionPlugin);
|
|
20
|
+
const { data: session } = useSession(authClient);
|
|
21
|
+
const { data: deviceSessions, isPending } = useListDeviceSessions(authClient);
|
|
22
|
+
return (_jsx(Dropdown.Popover, { className: "min-w-40 md:min-w-56 max-w-[48svw]", children: _jsxs(Dropdown.Menu, { children: [_jsxs(Dropdown.Item, { className: "px-2", children: [_jsx(UserView, { isPending: isPending, hideSubtitle: hideSubtitle }), !isPending && _jsx(Check, { className: "ml-auto" })] }), deviceSessions
|
|
23
|
+
?.filter((deviceSession) => deviceSession.session.id !== session?.session?.id)
|
|
24
|
+
.map((deviceSession) => (_jsx(SwitchAccountSubmenuItem, { deviceSession: deviceSession, hideSubtitle: hideSubtitle }, deviceSession.session.id))), _jsxs(Dropdown.Item, { textValue: multiSessionLocalization.addAccount, href: `${basePaths.auth}/${viewPaths.auth.signIn}`, children: [_jsx(CirclePlus, { className: "text-muted" }), _jsx(Label, { children: multiSessionLocalization.addAccount })] })] }) }));
|
|
26
25
|
}
|
|
27
|
-
//#endregion
|
|
28
|
-
export { p as SwitchAccountSubmenuContent };
|