@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,212 +1,98 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
variant: k
|
|
99
|
-
}, t.name)),
|
|
100
|
-
/* @__PURE__ */ w(v, {
|
|
101
|
-
minLength: P?.minPasswordLength,
|
|
102
|
-
maxLength: P?.maxPasswordLength,
|
|
103
|
-
name: "password",
|
|
104
|
-
autoComplete: "new-password",
|
|
105
|
-
isDisabled: Z,
|
|
106
|
-
value: U,
|
|
107
|
-
onChange: W,
|
|
108
|
-
children: [
|
|
109
|
-
/* @__PURE__ */ C(h, { children: F.auth.password }),
|
|
110
|
-
/* @__PURE__ */ w(m, {
|
|
111
|
-
variant: k === "transparent" ? "primary" : "secondary",
|
|
112
|
-
children: [/* @__PURE__ */ C(m.Input, {
|
|
113
|
-
placeholder: F.auth.passwordPlaceholder,
|
|
114
|
-
type: Y ? "text" : "password",
|
|
115
|
-
name: "password",
|
|
116
|
-
required: !0
|
|
117
|
-
}), /* @__PURE__ */ C(m.Suffix, {
|
|
118
|
-
className: "px-0",
|
|
119
|
-
children: /* @__PURE__ */ C(l, {
|
|
120
|
-
isIconOnly: !0,
|
|
121
|
-
"aria-label": Y ? F.auth.hidePassword : F.auth.showPassword,
|
|
122
|
-
size: "sm",
|
|
123
|
-
variant: "ghost",
|
|
124
|
-
onPress: () => ne(!Y),
|
|
125
|
-
isDisabled: Z,
|
|
126
|
-
children: C(Y ? c : s, {})
|
|
127
|
-
})
|
|
128
|
-
})]
|
|
129
|
-
}),
|
|
130
|
-
/* @__PURE__ */ C(f, {})
|
|
131
|
-
]
|
|
132
|
-
}),
|
|
133
|
-
P?.confirmPassword && /* @__PURE__ */ w(v, {
|
|
134
|
-
minLength: P?.minPasswordLength,
|
|
135
|
-
maxLength: P?.maxPasswordLength,
|
|
136
|
-
name: "confirmPassword",
|
|
137
|
-
autoComplete: "new-password",
|
|
138
|
-
isDisabled: Z,
|
|
139
|
-
value: G,
|
|
140
|
-
onChange: K,
|
|
141
|
-
children: [
|
|
142
|
-
/* @__PURE__ */ C(h, { children: F.auth.confirmPassword }),
|
|
143
|
-
/* @__PURE__ */ w(m, {
|
|
144
|
-
variant: k === "transparent" ? "primary" : "secondary",
|
|
145
|
-
children: [/* @__PURE__ */ C(m.Input, {
|
|
146
|
-
name: "confirmPassword",
|
|
147
|
-
placeholder: F.auth.confirmPasswordPlaceholder,
|
|
148
|
-
type: X ? "text" : "password",
|
|
149
|
-
required: !0
|
|
150
|
-
}), /* @__PURE__ */ C(m.Suffix, {
|
|
151
|
-
className: "px-0",
|
|
152
|
-
children: /* @__PURE__ */ C(l, {
|
|
153
|
-
isIconOnly: !0,
|
|
154
|
-
"aria-label": X ? F.auth.hidePassword : F.auth.showPassword,
|
|
155
|
-
size: "sm",
|
|
156
|
-
variant: "ghost",
|
|
157
|
-
onPress: () => re(!X),
|
|
158
|
-
isDisabled: Z,
|
|
159
|
-
children: C(X ? c : s, {})
|
|
160
|
-
})
|
|
161
|
-
})]
|
|
162
|
-
}),
|
|
163
|
-
/* @__PURE__ */ C(f, {})
|
|
164
|
-
]
|
|
165
|
-
}),
|
|
166
|
-
j?.map((t) => t.signUp && t.signUp !== "above" && /* @__PURE__ */ C(e, {
|
|
167
|
-
name: t.name,
|
|
168
|
-
field: t,
|
|
169
|
-
isPending: Z,
|
|
170
|
-
variant: k
|
|
171
|
-
}, t.name)),
|
|
172
|
-
Q && /* @__PURE__ */ C("div", {
|
|
173
|
-
className: "flex justify-center",
|
|
174
|
-
children: Q
|
|
175
|
-
}),
|
|
176
|
-
/* @__PURE__ */ w("div", {
|
|
177
|
-
className: "flex flex-col gap-3",
|
|
178
|
-
children: [/* @__PURE__ */ w(l, {
|
|
179
|
-
type: "submit",
|
|
180
|
-
className: "w-full",
|
|
181
|
-
isPending: Z,
|
|
182
|
-
children: [J && /* @__PURE__ */ C(_, {
|
|
183
|
-
color: "current",
|
|
184
|
-
size: "sm"
|
|
185
|
-
}), F.auth.signUp]
|
|
186
|
-
}), I.flatMap((e) => e.authButtons?.map((t, n) => /* @__PURE__ */ C(t, { view: "signUp" }, `${e.id}-${n.toString()}`)))]
|
|
187
|
-
})
|
|
188
|
-
]
|
|
189
|
-
}),
|
|
190
|
-
O === "bottom" && /* @__PURE__ */ w(S, { children: [$ && /* @__PURE__ */ C(t, { children: F.auth.or }), !!R?.length && /* @__PURE__ */ C(n, { socialLayout: D })] })
|
|
191
|
-
]
|
|
192
|
-
}),
|
|
193
|
-
/* @__PURE__ */ C(u.Footer, {
|
|
194
|
-
className: "flex-col gap-3",
|
|
195
|
-
children: /* @__PURE__ */ w(d, {
|
|
196
|
-
className: "text-sm",
|
|
197
|
-
children: [
|
|
198
|
-
F.auth.alreadyHaveAnAccount,
|
|
199
|
-
" ",
|
|
200
|
-
/* @__PURE__ */ C(g, {
|
|
201
|
-
href: `${N.auth}/${z.auth.signIn}`,
|
|
202
|
-
className: "text-accent no-underline hover:underline decoration-accent-hover",
|
|
203
|
-
children: F.auth.signIn
|
|
204
|
-
})
|
|
205
|
-
]
|
|
206
|
-
})
|
|
207
|
-
})
|
|
208
|
-
]
|
|
209
|
-
});
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { authMutationKeys, parseAdditionalFieldValue } from "@better-auth-ui/core";
|
|
3
|
+
import { useAuth, useFetchOptions, useSignUpEmail } from "@better-auth-ui/react";
|
|
4
|
+
import { Eye, EyeSlash } from "@gravity-ui/icons";
|
|
5
|
+
import { Button, Card, cn, Description, FieldError, Form, Input, InputGroup, Label, Link, Spinner, TextField, toast } from "@heroui/react";
|
|
6
|
+
import { useIsMutating } from "@tanstack/react-query";
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
import { AdditionalField } from "./additional-field";
|
|
9
|
+
import { FieldSeparator } from "./field-separator";
|
|
10
|
+
import { ProviderButtons } from "./provider-buttons";
|
|
11
|
+
/**
|
|
12
|
+
* Render a sign-up form with name, email, password (and optional confirm password) fields, optional social provider buttons, and password visibility controls.
|
|
13
|
+
*
|
|
14
|
+
* The component reflects request state by disabling inputs and showing a pending indicator during sign-up or social sign-in.
|
|
15
|
+
*
|
|
16
|
+
* @param className - Additional CSS classes applied to the outer card container
|
|
17
|
+
* @param socialLayout - Social layout to apply to the provider buttons component
|
|
18
|
+
* @param socialPosition - Position of social provider buttons relative to the form; `"top"` or `"bottom"` (default `"bottom"`)
|
|
19
|
+
* @returns The sign-up form React element
|
|
20
|
+
*/
|
|
21
|
+
export function SignUp({ className, socialLayout, socialPosition = "bottom", variant, ...props }) {
|
|
22
|
+
const { additionalFields, authClient, basePaths, emailAndPassword, localization, plugins, redirectTo, socialProviders, viewPaths, navigate } = useAuth();
|
|
23
|
+
const { fetchOptions, resetFetchOptions } = useFetchOptions();
|
|
24
|
+
const [password, setPassword] = useState("");
|
|
25
|
+
const [confirmPassword, setConfirmPassword] = useState("");
|
|
26
|
+
const { mutate: signUpEmail, isPending: signUpEmailPending } = useSignUpEmail(authClient, {
|
|
27
|
+
onError: (error) => {
|
|
28
|
+
setPassword("");
|
|
29
|
+
setConfirmPassword("");
|
|
30
|
+
toast.danger(error.error?.message || error.message);
|
|
31
|
+
resetFetchOptions();
|
|
32
|
+
},
|
|
33
|
+
onSuccess: () => {
|
|
34
|
+
if (emailAndPassword?.requireEmailVerification) {
|
|
35
|
+
toast.success(localization.auth.verifyYourEmail);
|
|
36
|
+
navigate({ to: `${basePaths.auth}/${viewPaths.auth.signIn}` });
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
navigate({ to: redirectTo });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const [isPasswordVisible, setIsPasswordVisible] = useState(false);
|
|
44
|
+
const [isConfirmPasswordVisible, setIsConfirmPasswordVisible] = useState(false);
|
|
45
|
+
const signInMutating = useIsMutating({
|
|
46
|
+
mutationKey: authMutationKeys.signIn.all
|
|
47
|
+
});
|
|
48
|
+
const signUpMutating = useIsMutating({
|
|
49
|
+
mutationKey: authMutationKeys.signUp.all
|
|
50
|
+
});
|
|
51
|
+
const isPending = signInMutating + signUpMutating > 0;
|
|
52
|
+
const Captcha = plugins.find((plugin) => plugin.captchaComponent)?.captchaComponent;
|
|
53
|
+
const handleSubmit = async (e) => {
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
const formData = new FormData(e.currentTarget);
|
|
56
|
+
// `emailAndPassword.name === false` hides the name field and submits "".
|
|
57
|
+
const name = formData.get("name") ?? "";
|
|
58
|
+
const email = formData.get("email");
|
|
59
|
+
if (emailAndPassword?.confirmPassword && password !== confirmPassword) {
|
|
60
|
+
toast.danger(localization.auth.passwordsDoNotMatch);
|
|
61
|
+
setPassword("");
|
|
62
|
+
setConfirmPassword("");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const additionalFieldValues = {};
|
|
66
|
+
for (const field of additionalFields ?? []) {
|
|
67
|
+
if (!field.signUp || field.readOnly)
|
|
68
|
+
continue;
|
|
69
|
+
const value = parseAdditionalFieldValue(field, formData.get(field.name));
|
|
70
|
+
if (field.validate) {
|
|
71
|
+
try {
|
|
72
|
+
await field.validate(value);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
toast.danger(error instanceof Error ? error.message : String(error));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (value !== undefined) {
|
|
80
|
+
additionalFieldValues[field.name] = value;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
signUpEmail({
|
|
84
|
+
name,
|
|
85
|
+
email,
|
|
86
|
+
password,
|
|
87
|
+
...additionalFieldValues,
|
|
88
|
+
fetchOptions
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
const showSeparator = emailAndPassword?.enabled && !!socialProviders?.length;
|
|
92
|
+
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.signUp }) }), _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 }))] })), emailAndPassword?.enabled && (_jsxs(Form, { onSubmit: handleSubmit, className: "flex flex-col gap-4", children: [emailAndPassword.name !== false && (_jsxs(TextField, { name: "name", type: "text", autoComplete: "name", isDisabled: isPending, children: [_jsx(Label, { children: localization.auth.name }), _jsx(Input, { placeholder: localization.auth.namePlaceholder, required: true, variant: variant === "transparent" ? "primary" : "secondary" }), _jsx(FieldError, {})] })), _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, {})] }), additionalFields?.map((field) => field.signUp === "above" && (_jsx(AdditionalField, { name: field.name, field: field, isPending: isPending, variant: variant }, field.name))), _jsxs(TextField, { minLength: emailAndPassword?.minPasswordLength, maxLength: emailAndPassword?.maxPasswordLength, name: "password", autoComplete: "new-password", isDisabled: isPending, value: password, onChange: setPassword, children: [_jsx(Label, { children: localization.auth.password }), _jsxs(InputGroup, { variant: variant === "transparent" ? "primary" : "secondary", children: [_jsx(InputGroup.Input, { placeholder: localization.auth.passwordPlaceholder, type: isPasswordVisible ? "text" : "password", name: "password", required: true }), _jsx(InputGroup.Suffix, { className: "px-0", children: _jsx(Button, { isIconOnly: true, "aria-label": isPasswordVisible
|
|
93
|
+
? localization.auth.hidePassword
|
|
94
|
+
: localization.auth.showPassword, size: "sm", variant: "ghost", onPress: () => setIsPasswordVisible(!isPasswordVisible), isDisabled: isPending, children: isPasswordVisible ? _jsx(EyeSlash, {}) : _jsx(Eye, {}) }) })] }), _jsx(FieldError, {})] }), emailAndPassword?.confirmPassword && (_jsxs(TextField, { minLength: emailAndPassword?.minPasswordLength, maxLength: emailAndPassword?.maxPasswordLength, name: "confirmPassword", autoComplete: "new-password", isDisabled: isPending, value: confirmPassword, onChange: setConfirmPassword, children: [_jsx(Label, { children: localization.auth.confirmPassword }), _jsxs(InputGroup, { variant: variant === "transparent" ? "primary" : "secondary", children: [_jsx(InputGroup.Input, { name: "confirmPassword", placeholder: localization.auth.confirmPasswordPlaceholder, type: isConfirmPasswordVisible ? "text" : "password", required: true }), _jsx(InputGroup.Suffix, { className: "px-0", children: _jsx(Button, { isIconOnly: true, "aria-label": isConfirmPasswordVisible
|
|
95
|
+
? localization.auth.hidePassword
|
|
96
|
+
: localization.auth.showPassword, size: "sm", variant: "ghost", onPress: () => setIsConfirmPasswordVisible(!isConfirmPasswordVisible), isDisabled: isPending, children: isConfirmPasswordVisible ? _jsx(EyeSlash, {}) : _jsx(Eye, {}) }) })] }), _jsx(FieldError, {})] })), additionalFields?.map((field) => field.signUp &&
|
|
97
|
+
field.signUp !== "above" && (_jsx(AdditionalField, { name: field.name, field: field, isPending: isPending, variant: variant }, field.name))), Captcha && _jsx("div", { className: "flex justify-center", children: Captcha }), _jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs(Button, { type: "submit", className: "w-full", isPending: isPending, children: [signUpEmailPending && _jsx(Spinner, { color: "current", size: "sm" }), localization.auth.signUp] }), plugins.flatMap((plugin) => plugin.authButtons?.map((AuthButton, index) => (_jsx(AuthButton, { view: "signUp" }, `${plugin.id}-${index.toString()}`))))] })] })), socialPosition === "bottom" && (_jsxs(_Fragment, { children: [showSeparator && (_jsx(FieldSeparator, { children: localization.auth.or })), !!socialProviders?.length && (_jsx(ProviderButtons, { socialLayout: socialLayout }))] }))] }), _jsx(Card.Footer, { className: "flex-col gap-3", children: _jsxs(Description, { className: "text-sm", children: [localization.auth.alreadyHaveAnAccount, " ", _jsx(Link, { href: `${basePaths.auth}/${viewPaths.auth.signIn}`, className: "text-accent no-underline hover:underline decoration-accent-hover", children: localization.auth.signIn })] }) })] }));
|
|
210
98
|
}
|
|
211
|
-
//#endregion
|
|
212
|
-
export { E as SignUp };
|
|
@@ -1,72 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ThemePreviewDark
|
|
3
|
-
import { Display
|
|
4
|
-
import { Card
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
C.includes("system") && /* @__PURE__ */ m(u, {
|
|
25
|
-
value: "system",
|
|
26
|
-
className: f("mt-0 px-4 pb-4 pt-3 rounded-xl", "border border-transparent data-[selected=true]:border-accent data-[selected=true]:bg-accent/10", "data-[focus-visible=true]:border-accent data-[focus-visible=true]:bg-accent/10", _ === "transparent" ? "bg-surface" : "bg-surface-secondary"),
|
|
27
|
-
children: /* @__PURE__ */ h(u.Content, {
|
|
28
|
-
className: "gap-2",
|
|
29
|
-
children: [/* @__PURE__ */ h("div", {
|
|
30
|
-
className: "flex gap-2 justify-between",
|
|
31
|
-
children: [/* @__PURE__ */ h(l, {
|
|
32
|
-
className: "flex gap-2 items-center",
|
|
33
|
-
children: [/* @__PURE__ */ m(a, { className: "text-muted" }), b.system]
|
|
34
|
-
}), /* @__PURE__ */ m(u.Control, { children: /* @__PURE__ */ m(u.Indicator, {}) })]
|
|
35
|
-
}), /* @__PURE__ */ m(r, { className: "w-full" })]
|
|
36
|
-
})
|
|
37
|
-
}),
|
|
38
|
-
C.includes("light") && /* @__PURE__ */ m(u, {
|
|
39
|
-
value: "light",
|
|
40
|
-
className: f("mt-0 px-4 pb-4 pt-3 rounded-xl", "border border-transparent data-[selected=true]:border-accent data-[selected=true]:bg-accent/10", "data-[focus-visible=true]:border-accent data-[focus-visible=true]:bg-accent/10", _ === "transparent" ? "bg-surface" : "bg-surface-secondary"),
|
|
41
|
-
children: /* @__PURE__ */ h(u.Content, {
|
|
42
|
-
className: "gap-2",
|
|
43
|
-
children: [/* @__PURE__ */ h("div", {
|
|
44
|
-
className: "flex gap-2 justify-between",
|
|
45
|
-
children: [/* @__PURE__ */ h(l, {
|
|
46
|
-
className: "flex gap-2 items-center",
|
|
47
|
-
children: [/* @__PURE__ */ m(s, { className: "text-muted" }), b.light]
|
|
48
|
-
}), /* @__PURE__ */ m(u.Control, { children: /* @__PURE__ */ m(u.Indicator, {}) })]
|
|
49
|
-
}), /* @__PURE__ */ m(n, { className: "w-full" })]
|
|
50
|
-
})
|
|
51
|
-
}),
|
|
52
|
-
C.includes("dark") && /* @__PURE__ */ m(u, {
|
|
53
|
-
value: "dark",
|
|
54
|
-
className: f("mt-0 px-4 pb-4 pt-3 rounded-xl", "border border-transparent data-[selected=true]:border-accent data-[selected=true]:bg-accent/10", "data-[focus-visible=true]:border-accent data-[focus-visible=true]:bg-accent/10", _ === "transparent" ? "bg-surface" : "bg-surface-secondary"),
|
|
55
|
-
children: /* @__PURE__ */ h(u.Content, {
|
|
56
|
-
className: "gap-2",
|
|
57
|
-
children: [/* @__PURE__ */ h("div", {
|
|
58
|
-
className: "flex gap-2 justify-between",
|
|
59
|
-
children: [/* @__PURE__ */ h(l, {
|
|
60
|
-
className: "flex gap-2 items-center",
|
|
61
|
-
children: [/* @__PURE__ */ m(o, { className: "text-muted" }), b.dark]
|
|
62
|
-
}), /* @__PURE__ */ m(u.Control, { children: /* @__PURE__ */ m(u.Indicator, {}) })]
|
|
63
|
-
}), /* @__PURE__ */ m(t, { className: "w-full" })]
|
|
64
|
-
})
|
|
65
|
-
})
|
|
66
|
-
]
|
|
67
|
-
})
|
|
68
|
-
})] })
|
|
69
|
-
})] });
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ThemePreviewDark, ThemePreviewLight, ThemePreviewSystem, useAuthPlugin } from "@better-auth-ui/react";
|
|
3
|
+
import { Display, Moon, Sun } from "@gravity-ui/icons";
|
|
4
|
+
import { Card, cn, Label, Radio, RadioGroup, useIsHydrated } from "@heroui/react";
|
|
5
|
+
import { themePlugin } from "../../../lib/auth/theme-plugin";
|
|
6
|
+
/**
|
|
7
|
+
* Renders a theme selector card with visual theme previews.
|
|
8
|
+
*
|
|
9
|
+
* Displays a card containing radio buttons for selecting between system, light,
|
|
10
|
+
* and dark themes. Each option shows a visual preview of the theme. Theme options
|
|
11
|
+
* are conditionally shown based on the `themes` array provided via the theme plugin.
|
|
12
|
+
*/
|
|
13
|
+
export function Appearance({ className, variant, ...props }) {
|
|
14
|
+
const { useTheme, localization } = useAuthPlugin(themePlugin);
|
|
15
|
+
const { theme, setTheme, themes = [] } = useTheme();
|
|
16
|
+
const hydrated = useIsHydrated();
|
|
17
|
+
return (_jsxs("div", { children: [_jsx("h2", { className: cn("text-sm font-semibold mb-3"), children: localization.appearance }), _jsx(Card, { className: cn("p-4 gap-4", className), variant: variant, ...props, children: _jsxs(Card.Content, { children: [_jsx(Label, { children: localization.theme }), _jsx(RadioGroup, { variant: variant === "transparent" ? "secondary" : "primary", value: hydrated ? theme : "", onChange: setTheme, isDisabled: !hydrated || !theme, children: _jsxs("div", { className: "grid gap-3 grid-cols-2 sm:grid-cols-3", children: [themes.includes("system") && (_jsx(Radio, { value: "system", className: cn("mt-0 px-4 pb-4 pt-3 rounded-xl", "border border-transparent data-[selected=true]:border-accent data-[selected=true]:bg-accent/10", "data-[focus-visible=true]:border-accent data-[focus-visible=true]:bg-accent/10", variant === "transparent"
|
|
18
|
+
? "bg-surface"
|
|
19
|
+
: "bg-surface-secondary"), children: _jsxs(Radio.Content, { className: "gap-2", children: [_jsxs("div", { className: "flex gap-2 justify-between", children: [_jsxs(Label, { className: "flex gap-2 items-center", children: [_jsx(Display, { className: "text-muted" }), localization.system] }), _jsx(Radio.Control, { children: _jsx(Radio.Indicator, {}) })] }), _jsx(ThemePreviewSystem, { className: "w-full" })] }) })), themes.includes("light") && (_jsx(Radio, { value: "light", className: cn("mt-0 px-4 pb-4 pt-3 rounded-xl", "border border-transparent data-[selected=true]:border-accent data-[selected=true]:bg-accent/10", "data-[focus-visible=true]:border-accent data-[focus-visible=true]:bg-accent/10", variant === "transparent"
|
|
20
|
+
? "bg-surface"
|
|
21
|
+
: "bg-surface-secondary"), children: _jsxs(Radio.Content, { className: "gap-2", children: [_jsxs("div", { className: "flex gap-2 justify-between", children: [_jsxs(Label, { className: "flex gap-2 items-center", children: [_jsx(Sun, { className: "text-muted" }), localization.light] }), _jsx(Radio.Control, { children: _jsx(Radio.Indicator, {}) })] }), _jsx(ThemePreviewLight, { className: "w-full" })] }) })), themes.includes("dark") && (_jsx(Radio, { value: "dark", className: cn("mt-0 px-4 pb-4 pt-3 rounded-xl", "border border-transparent data-[selected=true]:border-accent data-[selected=true]:bg-accent/10", "data-[focus-visible=true]:border-accent data-[focus-visible=true]:bg-accent/10", variant === "transparent"
|
|
22
|
+
? "bg-surface"
|
|
23
|
+
: "bg-surface-secondary"), children: _jsxs(Radio.Content, { className: "gap-2", children: [_jsxs("div", { className: "flex gap-2 justify-between", children: [_jsxs(Label, { className: "flex gap-2 items-center", children: [_jsx(Moon, { className: "text-muted" }), localization.dark] }), _jsx(Radio.Control, { children: _jsx(Radio.Indicator, {}) })] }), _jsx(ThemePreviewDark, { className: "w-full" })] }) }))] }) })] }) })] }));
|
|
70
24
|
}
|
|
71
|
-
//#endregion
|
|
72
|
-
export { g as Appearance };
|
|
@@ -1,62 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useAuthPlugin
|
|
3
|
-
import { Display
|
|
4
|
-
import { Dropdown
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
})
|
|
58
|
-
]
|
|
59
|
-
});
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useAuthPlugin } from "@better-auth-ui/react";
|
|
3
|
+
import { Display, Moon, Palette, Sun } from "@gravity-ui/icons";
|
|
4
|
+
import { Dropdown, Label, Tabs } from "@heroui/react";
|
|
5
|
+
import { themePlugin } from "../../../lib/auth/theme-plugin";
|
|
6
|
+
const ACTIVE_TAB_SELECTOR = '[role="tab"][aria-selected="true"]';
|
|
7
|
+
/**
|
|
8
|
+
* Theme toggle dropdown item used inside `UserButton`. Callers are responsible
|
|
9
|
+
* for ensuring theming is configured before rendering this component.
|
|
10
|
+
*/
|
|
11
|
+
export function ThemeToggleItem() {
|
|
12
|
+
const { useTheme, localization } = useAuthPlugin(themePlugin);
|
|
13
|
+
const { theme, setTheme, themes = [] } = useTheme();
|
|
14
|
+
// The Tabs aren't part of the menu's keyboard-navigation list, so arrow-key
|
|
15
|
+
// nav can't reach them on its own. When the wrapper menu item receives focus
|
|
16
|
+
// we delegate focus to the active Tab so the user can switch themes with the
|
|
17
|
+
// Left/Right arrows. React's synthetic `onFocus` bubbles (it's wired to
|
|
18
|
+
// `focusin`), so we must guard against child-originated events: without the
|
|
19
|
+
// `target === currentTarget` check, an arrow-key focus move between tabs
|
|
20
|
+
// bubbles up here and the still-stale `aria-selected="true"` lookup yanks
|
|
21
|
+
// focus back to the previously selected tab.
|
|
22
|
+
const focusActiveTab = (event) => {
|
|
23
|
+
if (event.target !== event.currentTarget)
|
|
24
|
+
return;
|
|
25
|
+
const activeTab = event.currentTarget.querySelector(ACTIVE_TAB_SELECTOR);
|
|
26
|
+
activeTab?.focus({ preventScroll: true });
|
|
27
|
+
};
|
|
28
|
+
// Up/Down on a Tab escapes back to the previous/next sibling menu item so
|
|
29
|
+
// users can keep navigating the menu with the arrow keys after they've
|
|
30
|
+
// entered the Tabs.
|
|
31
|
+
const handleTabsKeyDown = (event) => {
|
|
32
|
+
if (event.key !== "ArrowUp" && event.key !== "ArrowDown")
|
|
33
|
+
return;
|
|
34
|
+
const target = event.target;
|
|
35
|
+
if (target.getAttribute("role") !== "tab")
|
|
36
|
+
return;
|
|
37
|
+
const wrapper = target.closest('[role="menuitem"]');
|
|
38
|
+
const menu = wrapper?.closest('[role="menu"]');
|
|
39
|
+
if (!wrapper || !menu)
|
|
40
|
+
return;
|
|
41
|
+
const items = Array.from(menu.querySelectorAll('[role="menuitem"]:not([data-disabled])'));
|
|
42
|
+
const currentIndex = items.indexOf(wrapper);
|
|
43
|
+
if (currentIndex === -1)
|
|
44
|
+
return;
|
|
45
|
+
const nextIndex = event.key === "ArrowDown" ? currentIndex + 1 : currentIndex - 1;
|
|
46
|
+
const next = items[nextIndex];
|
|
47
|
+
if (!next)
|
|
48
|
+
return;
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
next.focus();
|
|
51
|
+
};
|
|
52
|
+
return (_jsxs(Dropdown.Item, { className: "py-1 pe-2", onFocus: focusActiveTab,
|
|
53
|
+
// Without `shouldCloseOnSelect={false}` the menu auto-closes after the
|
|
54
|
+
// user changes themes, because clicking on a Tab bubbles up as a
|
|
55
|
+
// menu-item activation.
|
|
56
|
+
shouldCloseOnSelect: false, children: [_jsx(Palette, { className: "text-muted" }), _jsx(Label, { children: localization.theme }), _jsx(Tabs, { className: "ml-auto", selectedKey: theme, onSelectionChange: (key) => setTheme(key), children: _jsx(Tabs.ListContainer, { onKeyDown: handleTabsKeyDown, children: _jsxs(Tabs.List, { "aria-label": localization.theme, className: "*:h-5 *:w-5 *:p-0", children: [themes.includes("system") && (_jsxs(Tabs.Tab, { id: "system", "aria-label": localization.system, children: [_jsx(Display, { className: "size-3" }), _jsx(Tabs.Indicator, {})] })), themes.includes("light") && (_jsxs(Tabs.Tab, { id: "light", "aria-label": localization.light, children: [_jsx(Sun, { className: "size-3" }), _jsx(Tabs.Indicator, {})] })), themes.includes("dark") && (_jsxs(Tabs.Tab, { id: "dark", "aria-label": localization.dark, children: [_jsx(Moon, { className: "size-3" }), _jsx(Tabs.Indicator, {})] }))] }) }) })] }));
|
|
60
57
|
}
|
|
61
|
-
//#endregion
|
|
62
|
-
export { f as ThemeToggleItem };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { AvatarProps } from
|
|
2
|
-
import { User } from
|
|
3
|
-
import { ReactNode } from
|
|
1
|
+
import { type AvatarProps } from "@heroui/react";
|
|
2
|
+
import type { User } from "better-auth";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
4
|
export type UserAvatarProps = {
|
|
5
5
|
className?: string;
|
|
6
6
|
fallback?: ReactNode;
|
|
7
7
|
isPending?: boolean;
|
|
8
8
|
/** @remarks `User` */
|
|
9
|
-
user?: User & {
|
|
9
|
+
user?: Partial<User> & {
|
|
10
10
|
username?: string | null;
|
|
11
11
|
displayUsername?: string | null;
|
|
12
12
|
};
|