@better-auth-ui/heroui 1.6.9 → 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.
- package/dist/components/auth/additional-field.d.ts +2 -2
- package/dist/components/auth/api-key/api-key.d.ts +1 -1
- package/dist/components/auth/api-key/api-keys.d.ts +1 -1
- package/dist/components/auth/api-key/delete-api-key-dialog.d.ts +1 -1
- package/dist/components/auth/api-key/organization-api-keys.d.ts +1 -1
- package/dist/components/auth/auth-provider.d.ts +1 -1
- package/dist/components/auth/auth.d.ts +3 -3
- package/dist/components/auth/delete-user/danger-zone.d.ts +2 -2
- package/dist/components/auth/delete-user/delete-account.d.ts +1 -1
- package/dist/components/auth/email/email-changed-email.d.ts +2 -2
- package/dist/components/auth/email/email-verification-email.d.ts +2 -2
- package/dist/components/auth/email/magic-link-email.d.ts +2 -2
- package/dist/components/auth/email/new-device-email.d.ts +2 -2
- package/dist/components/auth/email/organization-invitation-email.d.ts +2 -2
- package/dist/components/auth/email/otp-email.d.ts +2 -2
- package/dist/components/auth/email/password-changed-email.d.ts +2 -2
- package/dist/components/auth/email/reset-password-email.d.ts +2 -2
- package/dist/components/auth/field-separator.d.ts +1 -1
- package/dist/components/auth/forgot-password.d.ts +1 -1
- package/dist/components/auth/magic-link/magic-link-button.d.ts +1 -1
- package/dist/components/auth/magic-link/magic-link.d.ts +2 -2
- package/dist/components/auth/multi-session/manage-account.d.ts +1 -1
- package/dist/components/auth/multi-session/manage-accounts.d.ts +1 -1
- package/dist/components/auth/multi-session/switch-account-submenu-item.d.ts +1 -1
- package/dist/components/auth/organization/delete-organization-dialog.d.ts +1 -1
- package/dist/components/auth/organization/leave-organization-dialog.d.ts +1 -1
- package/dist/components/auth/organization/organization-danger-zone.d.ts +2 -2
- package/dist/components/auth/organization/organization-invitation-row.d.ts +1 -1
- package/dist/components/auth/organization/organization-invitations.d.ts +1 -1
- package/dist/components/auth/organization/organization-logo.d.ts +3 -3
- package/dist/components/auth/organization/organization-member-row.d.ts +1 -1
- package/dist/components/auth/organization/organization-members.d.ts +1 -1
- package/dist/components/auth/organization/organization-people.d.ts +1 -1
- package/dist/components/auth/organization/organization-profile.d.ts +1 -1
- package/dist/components/auth/organization/organization-row.d.ts +1 -1
- package/dist/components/auth/organization/organization-settings.d.ts +2 -2
- package/dist/components/auth/organization/organization-switcher.d.ts +3 -3
- package/dist/components/auth/organization/organization-view-skeleton.d.ts +2 -2
- package/dist/components/auth/organization/organization-view.d.ts +3 -3
- package/dist/components/auth/organization/organization.d.ts +3 -3
- package/dist/components/auth/organization/organizations-settings.d.ts +2 -2
- package/dist/components/auth/organization/organizations.d.ts +1 -1
- package/dist/components/auth/organization/remove-member-dialog.d.ts +1 -1
- package/dist/components/auth/organization/slug-field.d.ts +1 -1
- package/dist/components/auth/organization/user-invitation-row.d.ts +1 -1
- package/dist/components/auth/organization/user-invitations.d.ts +1 -1
- package/dist/components/auth/passkey/passkey-button.d.ts +1 -1
- package/dist/components/auth/passkey/passkey.d.ts +1 -1
- package/dist/components/auth/passkey/passkeys.d.ts +1 -1
- package/dist/components/auth/provider-button.d.ts +2 -2
- package/dist/components/auth/reset-password.d.ts +1 -1
- package/dist/components/auth/settings/account/account-settings.d.ts +2 -2
- package/dist/components/auth/settings/account/change-email.d.ts +1 -1
- package/dist/components/auth/settings/account/user-profile.d.ts +1 -1
- package/dist/components/auth/settings/security/active-session.d.ts +1 -1
- package/dist/components/auth/settings/security/active-sessions.d.ts +1 -1
- package/dist/components/auth/settings/security/change-password.d.ts +1 -1
- package/dist/components/auth/settings/security/linked-account.d.ts +1 -1
- package/dist/components/auth/settings/security/linked-accounts.d.ts +1 -1
- package/dist/components/auth/settings/security/security-settings.d.ts +2 -2
- package/dist/components/auth/settings/settings.d.ts +3 -3
- package/dist/components/auth/sign-in.d.ts +2 -2
- package/dist/components/auth/sign-up.d.ts +2 -2
- package/dist/components/auth/theme/appearance.d.ts +1 -1
- package/dist/components/auth/user/user-avatar.d.ts +3 -3
- package/dist/components/auth/user/user-button.d.ts +2 -2
- package/dist/components/auth/user/user-view.d.ts +3 -3
- package/dist/components/auth/username/sign-in-username.d.ts +2 -2
- package/dist/components/auth/username/username-field.d.ts +1 -1
- package/dist/email.d.ts +8 -8
- package/dist/email.js +211 -8
- package/dist/index.d.ts +21 -21
- package/dist/index.js +1682 -21
- package/dist/lib/auth/api-key-plugin.d.ts +3 -3
- package/dist/lib/auth/auth-plugin.d.ts +5 -5
- package/dist/lib/auth/delete-user-plugin.d.ts +2 -2
- package/dist/lib/auth/magic-link-plugin.d.ts +3 -3
- package/dist/lib/auth/multi-session-plugin.d.ts +3 -3
- package/dist/lib/auth/organization-plugin.d.ts +2 -2
- package/dist/lib/auth/passkey-plugin.d.ts +3 -3
- package/dist/lib/auth/theme-plugin.d.ts +3 -3
- package/dist/lib/auth/username-plugin.d.ts +3 -3
- package/dist/plugins.d.ts +46 -46
- package/dist/plugins.js +2824 -47
- package/dist/user-view--47tVtJ3.js +113 -0
- package/package.json +2 -3
- package/dist/components/auth/additional-field.js +0 -137
- package/dist/components/auth/api-key/api-key-skeleton.js +0 -5
- package/dist/components/auth/api-key/api-key.js +0 -17
- package/dist/components/auth/api-key/api-keys-empty.js +0 -9
- package/dist/components/auth/api-key/api-keys.js +0 -22
- package/dist/components/auth/api-key/create-api-key-dialog.js +0 -44
- package/dist/components/auth/api-key/delete-api-key-dialog.js +0 -17
- package/dist/components/auth/api-key/new-api-key-dialog.js +0 -24
- package/dist/components/auth/api-key/organization-api-keys.js +0 -22
- package/dist/components/auth/auth-provider.js +0 -11
- package/dist/components/auth/auth.js +0 -88
- package/dist/components/auth/delete-user/danger-zone.js +0 -12
- package/dist/components/auth/delete-user/delete-account.js +0 -50
- package/dist/components/auth/email/email-changed-email.js +0 -23
- package/dist/components/auth/email/email-verification-email.js +0 -23
- package/dist/components/auth/email/magic-link-email.js +0 -23
- package/dist/components/auth/email/new-device-email.js +0 -23
- package/dist/components/auth/email/organization-invitation-email.js +0 -23
- package/dist/components/auth/email/otp-email.js +0 -22
- package/dist/components/auth/email/password-changed-email.js +0 -23
- package/dist/components/auth/email/reset-password-email.js +0 -23
- package/dist/components/auth/error-toaster.js +0 -33
- package/dist/components/auth/field-separator.js +0 -5
- package/dist/components/auth/forgot-password.js +0 -37
- package/dist/components/auth/magic-link/magic-link-button.js +0 -34
- package/dist/components/auth/magic-link/magic-link.js +0 -40
- package/dist/components/auth/multi-session/manage-account.js +0 -33
- package/dist/components/auth/multi-session/manage-accounts.js +0 -33
- package/dist/components/auth/multi-session/switch-account-submenu-content.js +0 -25
- package/dist/components/auth/multi-session/switch-account-submenu-item.js +0 -17
- package/dist/components/auth/multi-session/switch-account-submenu.js +0 -24
- package/dist/components/auth/organization/change-organization-logo.js +0 -69
- package/dist/components/auth/organization/create-organization-dialog.js +0 -37
- package/dist/components/auth/organization/delete-organization-dialog.js +0 -25
- package/dist/components/auth/organization/delete-organization-skeleton.js +0 -8
- package/dist/components/auth/organization/delete-organization.js +0 -27
- package/dist/components/auth/organization/invite-member-dialog.js +0 -47
- package/dist/components/auth/organization/leave-organization-dialog.js +0 -21
- package/dist/components/auth/organization/leave-organization.js +0 -16
- package/dist/components/auth/organization/organization-danger-zone.js +0 -23
- package/dist/components/auth/organization/organization-invitation-row-skeleton.js +0 -9
- package/dist/components/auth/organization/organization-invitation-row.js +0 -31
- package/dist/components/auth/organization/organization-invitations-empty.js +0 -13
- package/dist/components/auth/organization/organization-invitations.js +0 -66
- package/dist/components/auth/organization/organization-logo.js +0 -14
- package/dist/components/auth/organization/organization-member-row-skeleton.js +0 -9
- package/dist/components/auth/organization/organization-member-row.js +0 -34
- package/dist/components/auth/organization/organization-members.js +0 -67
- package/dist/components/auth/organization/organization-people.js +0 -11
- package/dist/components/auth/organization/organization-profile.js +0 -34
- package/dist/components/auth/organization/organization-row.js +0 -31
- package/dist/components/auth/organization/organization-settings.js +0 -13
- package/dist/components/auth/organization/organization-switcher.js +0 -48
- package/dist/components/auth/organization/organization-view-skeleton.js +0 -9
- package/dist/components/auth/organization/organization-view.js +0 -31
- package/dist/components/auth/organization/organization.js +0 -60
- package/dist/components/auth/organization/organizations-empty.js +0 -9
- package/dist/components/auth/organization/organizations-settings.js +0 -17
- package/dist/components/auth/organization/organizations.js +0 -21
- package/dist/components/auth/organization/remove-member-dialog.js +0 -20
- package/dist/components/auth/organization/slug-field.js +0 -38
- package/dist/components/auth/organization/user-invitation-row-skeleton.js +0 -8
- package/dist/components/auth/organization/user-invitation-row.js +0 -22
- package/dist/components/auth/organization/user-invitations-empty.js +0 -12
- package/dist/components/auth/organization/user-invitations.js +0 -18
- package/dist/components/auth/passkey/add-passkey-dialog.js +0 -22
- package/dist/components/auth/passkey/delete-passkey-dialog.js +0 -14
- package/dist/components/auth/passkey/passkey-button.js +0 -25
- package/dist/components/auth/passkey/passkey-skeleton.js +0 -5
- package/dist/components/auth/passkey/passkey.js +0 -17
- package/dist/components/auth/passkey/passkeys-empty.js +0 -9
- package/dist/components/auth/passkey/passkeys.js +0 -16
- package/dist/components/auth/provider-button.js +0 -29
- package/dist/components/auth/provider-buttons.js +0 -29
- package/dist/components/auth/reset-password.js +0 -57
- package/dist/components/auth/settings/account/account-settings.js +0 -22
- package/dist/components/auth/settings/account/change-avatar.js +0 -54
- package/dist/components/auth/settings/account/change-email.js +0 -28
- package/dist/components/auth/settings/account/user-profile.js +0 -65
- package/dist/components/auth/settings/security/active-session.js +0 -52
- package/dist/components/auth/settings/security/active-sessions.js +0 -23
- package/dist/components/auth/settings/security/change-password.js +0 -79
- package/dist/components/auth/settings/security/linked-account.js +0 -38
- package/dist/components/auth/settings/security/linked-accounts.js +0 -36
- package/dist/components/auth/settings/security/security-settings.js +0 -20
- package/dist/components/auth/settings/settings.js +0 -53
- package/dist/components/auth/sign-in.js +0 -64
- package/dist/components/auth/sign-out.js +0 -33
- package/dist/components/auth/sign-up.js +0 -98
- package/dist/components/auth/theme/appearance.js +0 -24
- package/dist/components/auth/theme/theme-toggle-item.js +0 -57
- package/dist/components/auth/user/user-avatar.js +0 -32
- package/dist/components/auth/user/user-button.js +0 -40
- package/dist/components/auth/user/user-view.js +0 -27
- package/dist/components/auth/username/sign-in-username.js +0 -88
- package/dist/components/auth/username/username-field.js +0 -45
- package/dist/lib/auth/api-key-plugin.js +0 -12
- package/dist/lib/auth/auth-plugin.js +0 -1
- package/dist/lib/auth/delete-user-plugin.js +0 -7
- package/dist/lib/auth/magic-link-plugin.js +0 -18
- package/dist/lib/auth/multi-session-plugin.js +0 -9
- package/dist/lib/auth/organization-plugin.js +0 -19
- package/dist/lib/auth/passkey-plugin.js +0 -9
- package/dist/lib/auth/theme-plugin.js +0 -26
- package/dist/lib/auth/username-plugin.js +0 -19
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { EmailChangedEmail as EmailChangedEmailPrimitive } from "@better-auth-ui/react/email";
|
|
3
|
-
import { cn } from "@heroui/react";
|
|
4
|
-
export function EmailChangedEmail({ colors, classNames, ...props }) {
|
|
5
|
-
return (_jsx(EmailChangedEmailPrimitive, { colors: {
|
|
6
|
-
light: {
|
|
7
|
-
background: "#F5F5F5",
|
|
8
|
-
primary: "#0285F7",
|
|
9
|
-
primaryForeground: "#FCFCFC",
|
|
10
|
-
...colors?.light
|
|
11
|
-
},
|
|
12
|
-
dark: {
|
|
13
|
-
background: "#060607",
|
|
14
|
-
primary: "#0584F6",
|
|
15
|
-
primaryForeground: "#FCFCFC",
|
|
16
|
-
...colors?.dark
|
|
17
|
-
}
|
|
18
|
-
}, classNames: {
|
|
19
|
-
...classNames,
|
|
20
|
-
card: cn("border-none rounded-3xl", classNames?.card),
|
|
21
|
-
button: cn("rounded-full", classNames?.button)
|
|
22
|
-
}, ...props }));
|
|
23
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { EmailVerificationEmail as EmailVerificationEmailPrimitive } from "@better-auth-ui/react/email";
|
|
3
|
-
import { cn } from "@heroui/react";
|
|
4
|
-
export function EmailVerificationEmail({ colors, classNames, ...props }) {
|
|
5
|
-
return (_jsx(EmailVerificationEmailPrimitive, { colors: {
|
|
6
|
-
light: {
|
|
7
|
-
background: "#F5F5F5",
|
|
8
|
-
primary: "#0285F7",
|
|
9
|
-
primaryForeground: "#FCFCFC",
|
|
10
|
-
...colors?.light
|
|
11
|
-
},
|
|
12
|
-
dark: {
|
|
13
|
-
background: "#060607",
|
|
14
|
-
primary: "#0584F6",
|
|
15
|
-
primaryForeground: "#FCFCFC",
|
|
16
|
-
...colors?.dark
|
|
17
|
-
}
|
|
18
|
-
}, classNames: {
|
|
19
|
-
...classNames,
|
|
20
|
-
card: cn("border-none rounded-3xl", classNames?.card),
|
|
21
|
-
button: cn("rounded-full", classNames?.button)
|
|
22
|
-
}, ...props }));
|
|
23
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { MagicLinkEmail as MagicLinkEmailPrimitive } from "@better-auth-ui/react/email";
|
|
3
|
-
import { cn } from "@heroui/react";
|
|
4
|
-
export function MagicLinkEmail({ colors, classNames, ...props }) {
|
|
5
|
-
return (_jsx(MagicLinkEmailPrimitive, { colors: {
|
|
6
|
-
light: {
|
|
7
|
-
background: "#F5F5F5",
|
|
8
|
-
primary: "#0285F7",
|
|
9
|
-
primaryForeground: "#FCFCFC",
|
|
10
|
-
...colors?.light
|
|
11
|
-
},
|
|
12
|
-
dark: {
|
|
13
|
-
background: "#060607",
|
|
14
|
-
primary: "#0584F6",
|
|
15
|
-
primaryForeground: "#FCFCFC",
|
|
16
|
-
...colors?.dark
|
|
17
|
-
}
|
|
18
|
-
}, classNames: {
|
|
19
|
-
...classNames,
|
|
20
|
-
card: cn("border-none rounded-3xl", classNames?.card),
|
|
21
|
-
button: cn("rounded-full", classNames?.button)
|
|
22
|
-
}, ...props }));
|
|
23
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { NewDeviceEmail as NewDeviceEmailPrimitive } from "@better-auth-ui/react/email";
|
|
3
|
-
import { cn } from "@heroui/react";
|
|
4
|
-
export function NewDeviceEmail({ colors, classNames, ...props }) {
|
|
5
|
-
return (_jsx(NewDeviceEmailPrimitive, { colors: {
|
|
6
|
-
light: {
|
|
7
|
-
background: "#F5F5F5",
|
|
8
|
-
primary: "#0285F7",
|
|
9
|
-
primaryForeground: "#FCFCFC",
|
|
10
|
-
...colors?.light
|
|
11
|
-
},
|
|
12
|
-
dark: {
|
|
13
|
-
background: "#060607",
|
|
14
|
-
primary: "#0584F6",
|
|
15
|
-
primaryForeground: "#FCFCFC",
|
|
16
|
-
...colors?.dark
|
|
17
|
-
}
|
|
18
|
-
}, classNames: {
|
|
19
|
-
...classNames,
|
|
20
|
-
card: cn("border-none rounded-3xl", classNames?.card),
|
|
21
|
-
button: cn("rounded-full", classNames?.button)
|
|
22
|
-
}, ...props }));
|
|
23
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { OrganizationInvitationEmail as OrganizationInvitationEmailPrimitive } from "@better-auth-ui/react/email";
|
|
3
|
-
import { cn } from "@heroui/react";
|
|
4
|
-
export function OrganizationInvitationEmail({ colors, classNames, ...props }) {
|
|
5
|
-
return (_jsx(OrganizationInvitationEmailPrimitive, { colors: {
|
|
6
|
-
light: {
|
|
7
|
-
background: "#F5F5F5",
|
|
8
|
-
primary: "#0285F7",
|
|
9
|
-
primaryForeground: "#FCFCFC",
|
|
10
|
-
...colors?.light
|
|
11
|
-
},
|
|
12
|
-
dark: {
|
|
13
|
-
background: "#060607",
|
|
14
|
-
primary: "#0584F6",
|
|
15
|
-
primaryForeground: "#FCFCFC",
|
|
16
|
-
...colors?.dark
|
|
17
|
-
}
|
|
18
|
-
}, classNames: {
|
|
19
|
-
...classNames,
|
|
20
|
-
card: cn("border-none rounded-3xl", classNames?.card),
|
|
21
|
-
button: cn("rounded-full", classNames?.button)
|
|
22
|
-
}, ...props }));
|
|
23
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { OtpEmail as OtpEmailPrimitive } from "@better-auth-ui/react/email";
|
|
3
|
-
import { cn } from "@heroui/react";
|
|
4
|
-
export function OtpEmail({ colors, classNames, ...props }) {
|
|
5
|
-
return (_jsx(OtpEmailPrimitive, { colors: {
|
|
6
|
-
light: {
|
|
7
|
-
background: "#F5F5F5",
|
|
8
|
-
primary: "#0285F7",
|
|
9
|
-
primaryForeground: "#FCFCFC",
|
|
10
|
-
...colors?.light
|
|
11
|
-
},
|
|
12
|
-
dark: {
|
|
13
|
-
background: "#060607",
|
|
14
|
-
primary: "#0584F6",
|
|
15
|
-
primaryForeground: "#FCFCFC",
|
|
16
|
-
...colors?.dark
|
|
17
|
-
}
|
|
18
|
-
}, classNames: {
|
|
19
|
-
...classNames,
|
|
20
|
-
card: cn("border-none rounded-3xl", classNames?.card)
|
|
21
|
-
}, ...props }));
|
|
22
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { PasswordChangedEmail as PasswordChangedEmailPrimitive } from "@better-auth-ui/react/email";
|
|
3
|
-
import { cn } from "@heroui/react";
|
|
4
|
-
export function PasswordChangedEmail({ colors, classNames, ...props }) {
|
|
5
|
-
return (_jsx(PasswordChangedEmailPrimitive, { colors: {
|
|
6
|
-
light: {
|
|
7
|
-
background: "#F5F5F5",
|
|
8
|
-
primary: "#0285F7",
|
|
9
|
-
primaryForeground: "#FCFCFC",
|
|
10
|
-
...colors?.light
|
|
11
|
-
},
|
|
12
|
-
dark: {
|
|
13
|
-
background: "#060607",
|
|
14
|
-
primary: "#0584F6",
|
|
15
|
-
primaryForeground: "#FCFCFC",
|
|
16
|
-
...colors?.dark
|
|
17
|
-
}
|
|
18
|
-
}, classNames: {
|
|
19
|
-
...classNames,
|
|
20
|
-
card: cn("border-none rounded-3xl", classNames?.card),
|
|
21
|
-
button: cn("rounded-full", classNames?.button)
|
|
22
|
-
}, ...props }));
|
|
23
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { ResetPasswordEmail as ResetPasswordEmailPrimitive } from "@better-auth-ui/react/email";
|
|
3
|
-
import { cn } from "@heroui/react";
|
|
4
|
-
export function ResetPasswordEmail({ colors, classNames, ...props }) {
|
|
5
|
-
return (_jsx(ResetPasswordEmailPrimitive, { colors: {
|
|
6
|
-
light: {
|
|
7
|
-
background: "#F5F5F5",
|
|
8
|
-
primary: "#0285F7",
|
|
9
|
-
primaryForeground: "#FCFCFC",
|
|
10
|
-
...colors?.light
|
|
11
|
-
},
|
|
12
|
-
dark: {
|
|
13
|
-
background: "#060607",
|
|
14
|
-
primary: "#0584F6",
|
|
15
|
-
primaryForeground: "#FCFCFC",
|
|
16
|
-
...colors?.dark
|
|
17
|
-
}
|
|
18
|
-
}, classNames: {
|
|
19
|
-
...classNames,
|
|
20
|
-
card: cn("border-none rounded-3xl", classNames?.card),
|
|
21
|
-
button: cn("rounded-full", classNames?.button)
|
|
22
|
-
}, ...props }));
|
|
23
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { authMutationKeys, authQueryKeys } from "@better-auth-ui/core";
|
|
2
|
-
import { toast } from "@heroui/react";
|
|
3
|
-
import { matchMutation, matchQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
|
-
import { useEffect } from "react";
|
|
5
|
-
export function ErrorToaster() {
|
|
6
|
-
const queryClient = useQueryClient();
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
const unsubscribeQuery = queryClient.getQueryCache().subscribe((event) => {
|
|
9
|
-
if (event.type !== "updated" || event.action.type !== "error")
|
|
10
|
-
return;
|
|
11
|
-
if (!matchQuery({ queryKey: authQueryKeys.all }, event.query))
|
|
12
|
-
return;
|
|
13
|
-
const err = event.action.error;
|
|
14
|
-
if (err?.error)
|
|
15
|
-
toast.danger(err.error.message);
|
|
16
|
-
});
|
|
17
|
-
const unsubscribeMutation = queryClient
|
|
18
|
-
.getMutationCache()
|
|
19
|
-
.subscribe((event) => {
|
|
20
|
-
if (event.type !== "updated" || event.action.type !== "error")
|
|
21
|
-
return;
|
|
22
|
-
if (!matchMutation({ mutationKey: authMutationKeys.all }, event.mutation))
|
|
23
|
-
return;
|
|
24
|
-
const err = event.action.error;
|
|
25
|
-
toast.danger(err.error?.message || err.message);
|
|
26
|
-
});
|
|
27
|
-
return () => {
|
|
28
|
-
unsubscribeQuery();
|
|
29
|
-
unsubscribeMutation();
|
|
30
|
-
};
|
|
31
|
-
}, [queryClient]);
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
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" })] }));
|
|
5
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
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 })] }) })] }));
|
|
37
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
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)] }));
|
|
34
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
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 })] }) }))] }));
|
|
40
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
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] })] }) })] }))] }));
|
|
33
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
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))) }) })] }));
|
|
33
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
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 })] })] }) }));
|
|
25
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useAuth, useSetActiveSession } from "@better-auth-ui/react";
|
|
3
|
-
import { Dropdown, Spinner } from "@heroui/react";
|
|
4
|
-
import { UserView } from "../user/user-view";
|
|
5
|
-
/**
|
|
6
|
-
* Render a dropdown item for switching to a different authenticated session.
|
|
7
|
-
*
|
|
8
|
-
* @param deviceSession - The device session to display and switch to when pressed
|
|
9
|
-
* @returns The switch account dropdown item as a JSX element
|
|
10
|
-
*/
|
|
11
|
-
export function SwitchAccountSubmenuItem({ deviceSession, hideSubtitle }) {
|
|
12
|
-
const { authClient } = useAuth();
|
|
13
|
-
const { mutate: setActiveSession, isPending } = useSetActiveSession(authClient, {
|
|
14
|
-
onSuccess: () => window.scrollTo({ top: 0 })
|
|
15
|
-
});
|
|
16
|
-
return (_jsxs(Dropdown.Item, { className: "px-2", isDisabled: isPending, onPress: () => setActiveSession({ sessionToken: deviceSession.session.token }), children: [_jsx(UserView, { user: deviceSession.user, hideSubtitle: hideSubtitle }), isPending && _jsx(Spinner, { color: "current", size: "sm", className: "ml-auto" })] }));
|
|
17
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useAuth, useAuthPlugin, useSession } from "@better-auth-ui/react";
|
|
3
|
-
import { ArrowRightArrowLeft } from "@gravity-ui/icons";
|
|
4
|
-
import { Dropdown, Label } from "@heroui/react";
|
|
5
|
-
import { multiSessionPlugin } from "../../../lib/auth/multi-session-plugin";
|
|
6
|
-
import { SwitchAccountSubmenuContent } from "./switch-account-submenu-content";
|
|
7
|
-
/**
|
|
8
|
-
* Render a dropdown submenu for switching between multiple authenticated sessions.
|
|
9
|
-
*
|
|
10
|
-
* This component renders as a submenu trigger that opens the switch account menu.
|
|
11
|
-
* It should be rendered inside a Dropdown.Menu.
|
|
12
|
-
*
|
|
13
|
-
* @param className - Optional additional CSS class names
|
|
14
|
-
* @returns The switch account submenu as a JSX element
|
|
15
|
-
*/
|
|
16
|
-
export function SwitchAccountSubmenu({ className, hideSubtitle }) {
|
|
17
|
-
const { authClient } = useAuth();
|
|
18
|
-
const { data: session } = useSession(authClient);
|
|
19
|
-
const { localization: multiSessionLocalization } = useAuthPlugin(multiSessionPlugin);
|
|
20
|
-
if (!session) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
return (_jsxs(Dropdown.SubmenuTrigger, { children: [_jsxs(Dropdown.Item, { className: className, textValue: multiSessionLocalization.switchAccount, children: [_jsx(ArrowRightArrowLeft, { className: "text-muted" }), _jsx(Label, { children: multiSessionLocalization.switchAccount }), _jsx(Dropdown.SubmenuIndicator, {})] }), _jsx(Dropdown.Popover, { className: "min-w-40 md:min-w-56 max-w-[48svw]", children: _jsx(SwitchAccountSubmenuContent, { hideSubtitle: hideSubtitle }) })] }));
|
|
24
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { fileToBase64 } from "@better-auth-ui/core";
|
|
3
|
-
import { useActiveOrganization, useAuth, useAuthPlugin, useUpdateOrganization } from "@better-auth-ui/react";
|
|
4
|
-
import { CloudArrowUpIn, TrashBin } from "@gravity-ui/icons";
|
|
5
|
-
import { Button, cn, Dropdown, Label, Spinner, toast } from "@heroui/react";
|
|
6
|
-
import { useRef, useState } from "react";
|
|
7
|
-
import { organizationPlugin } from "../../../lib/auth/organization-plugin";
|
|
8
|
-
import { OrganizationLogo } from "./organization-logo";
|
|
9
|
-
export function ChangeOrganizationLogo({ className }) {
|
|
10
|
-
const { authClient } = useAuth();
|
|
11
|
-
const { logo, localization: organizationLocalization } = useAuthPlugin(organizationPlugin);
|
|
12
|
-
const { data: activeOrganization, isPending: activeOrganizationPending } = useActiveOrganization(authClient);
|
|
13
|
-
const { mutate: updateOrganization, isPending: updatePending } = useUpdateOrganization(authClient);
|
|
14
|
-
const fileInputRef = useRef(null);
|
|
15
|
-
const [isUploading, setIsUploading] = useState(false);
|
|
16
|
-
const [isDeleting, setIsDeleting] = useState(false);
|
|
17
|
-
const isPending = updatePending || isUploading || isDeleting;
|
|
18
|
-
async function handleFileChange(e) {
|
|
19
|
-
const file = e.target.files?.[0];
|
|
20
|
-
if (!file || !activeOrganization)
|
|
21
|
-
return;
|
|
22
|
-
e.target.value = "";
|
|
23
|
-
setIsUploading(true);
|
|
24
|
-
try {
|
|
25
|
-
const resized = (await logo.resize?.(file, logo.size, logo.extension)) || file;
|
|
26
|
-
const image = (await logo.upload?.(resized)) || (await fileToBase64(resized));
|
|
27
|
-
updateOrganization({ data: { logo: image } }, {
|
|
28
|
-
onSuccess: () => toast.success(organizationLocalization.logoChangedSuccess),
|
|
29
|
-
onSettled: () => setIsUploading(false)
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
setIsUploading(false);
|
|
34
|
-
if (error instanceof Error) {
|
|
35
|
-
toast.danger(error.message);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
async function handleDelete() {
|
|
40
|
-
const currentLogo = activeOrganization?.logo;
|
|
41
|
-
updateOrganization({
|
|
42
|
-
data: { logo: "" }
|
|
43
|
-
}, {
|
|
44
|
-
onSuccess: async () => {
|
|
45
|
-
if (!currentLogo) {
|
|
46
|
-
toast.success(organizationLocalization.logoDeletedSuccess);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
setIsDeleting(true);
|
|
50
|
-
try {
|
|
51
|
-
await logo.delete?.(currentLogo);
|
|
52
|
-
toast.success(organizationLocalization.logoDeletedSuccess);
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
if (error instanceof Error) {
|
|
56
|
-
toast.danger(error.message);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
finally {
|
|
60
|
-
setIsDeleting(false);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
if (!logo.enabled) {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
return (_jsxs("div", { className: cn("flex flex-col gap-1", className), children: [_jsx(Label, { isDisabled: !activeOrganization, children: organizationLocalization.logo }), _jsx("input", { ref: fileInputRef, type: "file", accept: "image/*", className: "hidden", onChange: handleFileChange }), _jsxs("div", { className: "flex items-center gap-4", children: [_jsx(Button, { type: "button", isIconOnly: true, variant: "ghost", className: "p-0 h-auto w-auto rounded-full", isDisabled: !activeOrganization || isPending, onPress: () => fileInputRef.current?.click(), children: _jsx(OrganizationLogo, { size: "lg", isPending: activeOrganizationPending, organization: activeOrganization }) }), _jsxs(Dropdown, { children: [_jsxs(Button, { isDisabled: !activeOrganization || isPending, size: "sm", variant: "secondary", children: [isPending && _jsx(Spinner, { size: "sm" }), organizationLocalization.changeLogo] }), _jsx(Dropdown.Popover, { className: "min-w-fit", children: _jsxs(Dropdown.Menu, { children: [_jsxs(Dropdown.Item, { textValue: organizationLocalization.uploadLogo, onAction: () => fileInputRef.current?.click(), children: [_jsx(CloudArrowUpIn, { className: "text-muted" }), _jsx(Label, { children: organizationLocalization.uploadLogo })] }), _jsxs(Dropdown.Item, { textValue: organizationLocalization.deleteLogo, isDisabled: !activeOrganization?.logo, onAction: handleDelete, variant: "danger", children: [_jsx(TrashBin, { className: "text-danger" }), _jsx(Label, { children: organizationLocalization.deleteLogo })] })] }) })] })] })] }));
|
|
69
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useAuth, useAuthPlugin, useCreateOrganization } from "@better-auth-ui/react";
|
|
3
|
-
import { Briefcase } from "@gravity-ui/icons";
|
|
4
|
-
import { AlertDialog, Button, FieldError, Form, Input, Label, Spinner, TextField } from "@heroui/react";
|
|
5
|
-
import { useEffect, useState } from "react";
|
|
6
|
-
import { organizationPlugin } from "../../../lib/auth/organization-plugin";
|
|
7
|
-
import { SlugField, sanitizeSlug } from "./slug-field";
|
|
8
|
-
/**
|
|
9
|
-
* Render a dialog for creating a new organization.
|
|
10
|
-
*
|
|
11
|
-
* @param isOpen - Whether the dialog is open
|
|
12
|
-
* @param onOpenChange - Callback for when the dialog open state changes
|
|
13
|
-
* @returns The create organization dialog as a JSX element
|
|
14
|
-
*/
|
|
15
|
-
export function CreateOrganizationDialog({ isOpen, onOpenChange }) {
|
|
16
|
-
const { authClient, localization } = useAuth();
|
|
17
|
-
const { localization: organizationLocalization } = useAuthPlugin(organizationPlugin);
|
|
18
|
-
const [name, setName] = useState("");
|
|
19
|
-
const [slug, setSlug] = useState("");
|
|
20
|
-
const { mutate: createOrganization, isPending: isCreating } = useCreateOrganization(authClient, {
|
|
21
|
-
onSuccess: () => onOpenChange(false)
|
|
22
|
-
});
|
|
23
|
-
const handleSubmit = (e) => {
|
|
24
|
-
e.preventDefault();
|
|
25
|
-
createOrganization({ name, slug });
|
|
26
|
-
};
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (!isOpen) {
|
|
29
|
-
setSlug("");
|
|
30
|
-
setName("");
|
|
31
|
-
}
|
|
32
|
-
}, [isOpen]);
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
setSlug(sanitizeSlug(name));
|
|
35
|
-
}, [name]);
|
|
36
|
-
return (_jsx(AlertDialog.Backdrop, { isOpen: isOpen, onOpenChange: onOpenChange, children: _jsx(AlertDialog.Container, { children: _jsx(AlertDialog.Dialog, { children: _jsxs(Form, { onSubmit: handleSubmit, children: [_jsx(AlertDialog.CloseTrigger, {}), _jsxs(AlertDialog.Header, { children: [_jsx(AlertDialog.Icon, { status: "default", children: _jsx(Briefcase, {}) }), _jsx(AlertDialog.Heading, { children: organizationLocalization.createOrganization })] }), _jsxs(AlertDialog.Body, { className: "flex flex-col gap-4 overflow-visible", children: [_jsx("p", { className: "text-muted text-sm", children: organizationLocalization.organizationsDescription }), _jsxs(TextField, { id: "name", name: "name", isDisabled: isCreating, value: name, onChange: setName, children: [_jsx(Label, { children: organizationLocalization.name }), _jsx(Input, { required: true, autoFocus: true, placeholder: organizationLocalization.namePlaceholder, variant: "secondary" }), _jsx(FieldError, {})] }), _jsx(SlugField, { value: slug, onChange: setSlug, isDisabled: isCreating, variant: "secondary" })] }), _jsxs(AlertDialog.Footer, { children: [_jsx(Button, { slot: "close", variant: "tertiary", isDisabled: isCreating, children: localization.settings.cancel }), _jsxs(Button, { type: "submit", isPending: isCreating, children: [isCreating && _jsx(Spinner, { color: "current", size: "sm" }), organizationLocalization.createOrganization] })] })] }) }) }) }));
|
|
37
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useAuth, useAuthPlugin, useDeleteOrganization } from "@better-auth-ui/react";
|
|
3
|
-
import { TriangleExclamation } from "@gravity-ui/icons";
|
|
4
|
-
import { AlertDialog, Button, Card, Form, Spinner, toast } from "@heroui/react";
|
|
5
|
-
import { organizationPlugin } from "../../../lib/auth/organization-plugin";
|
|
6
|
-
import { OrganizationView } from "./organization-view";
|
|
7
|
-
export function DeleteOrganizationDialog({ isOpen, onOpenChange, organization }) {
|
|
8
|
-
const { authClient, basePaths, localization, navigate } = useAuth();
|
|
9
|
-
const { localization: organizationLocalization, viewPaths: organizationPluginViewPaths } = useAuthPlugin(organizationPlugin);
|
|
10
|
-
const { mutate: deleteOrganization, isPending } = useDeleteOrganization(authClient, {
|
|
11
|
-
onSuccess: () => {
|
|
12
|
-
onOpenChange(false);
|
|
13
|
-
toast.success(organizationLocalization.organizationDeleted);
|
|
14
|
-
navigate({
|
|
15
|
-
to: `${basePaths.settings}/${organizationPluginViewPaths.settings.organizations}`,
|
|
16
|
-
replace: true
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
function handleSubmit(e) {
|
|
21
|
-
e.preventDefault();
|
|
22
|
-
deleteOrganization({ organizationId: organization.id });
|
|
23
|
-
}
|
|
24
|
-
return (_jsx(AlertDialog.Backdrop, { isOpen: isOpen, onOpenChange: onOpenChange, children: _jsx(AlertDialog.Container, { children: _jsx(AlertDialog.Dialog, { children: _jsxs(Form, { onSubmit: handleSubmit, children: [_jsx(AlertDialog.CloseTrigger, {}), _jsxs(AlertDialog.Header, { children: [_jsx(AlertDialog.Icon, { status: "danger", children: _jsx(TriangleExclamation, {}) }), _jsx(AlertDialog.Heading, { children: organizationLocalization.deleteOrganization })] }), _jsxs(AlertDialog.Body, { className: "flex flex-col gap-4 overflow-visible", children: [_jsx("p", { className: "text-muted text-sm", children: organizationLocalization.deleteOrganizationDescription }), _jsx(Card, { variant: "secondary", children: _jsx(Card.Content, { children: _jsx(OrganizationView, { organization: organization, hideRole: true }) }) })] }), _jsxs(AlertDialog.Footer, { children: [_jsx(Button, { slot: "close", variant: "tertiary", isDisabled: isPending, children: localization.settings.cancel }), _jsxs(Button, { type: "submit", variant: "danger", isPending: isPending, children: [isPending && _jsx(Spinner, { color: "current", size: "sm" }), organizationLocalization.deleteOrganization] })] })] }) }) }) }));
|
|
25
|
-
}
|