@better-auth-ui/heroui 1.6.3 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/auth/additional-field.d.ts +4 -0
- package/dist/components/auth/additional-field.js +270 -0
- package/dist/components/auth/auth-provider.d.ts +4 -6
- package/dist/components/auth/auth.d.ts +1 -1
- package/dist/components/auth/auth.js +54 -28
- package/dist/components/{settings/security → auth/delete-user}/danger-zone.d.ts +3 -4
- package/dist/components/{settings/security → auth/delete-user}/danger-zone.js +1 -1
- package/dist/components/auth/delete-user/delete-user.js +95 -0
- package/dist/components/{email → auth/email}/email-changed-email.d.ts +2 -2
- package/dist/components/{email → auth/email}/email-changed-email.js +7 -7
- package/dist/components/{email → auth/email}/email-verification-email.d.ts +2 -2
- package/dist/components/{email → auth/email}/email-verification-email.js +7 -7
- package/dist/components/auth/email/magic-link-email.d.ts +3 -0
- package/dist/components/{email → auth/email}/magic-link-email.js +7 -7
- package/dist/components/auth/email/new-device-email.d.ts +3 -0
- package/dist/components/{email → auth/email}/new-device-email.js +7 -7
- package/dist/components/auth/email/otp-email.d.ts +3 -0
- package/dist/components/{email → auth/email}/otp-email.js +6 -6
- package/dist/components/{email → auth/email}/password-changed-email.d.ts +2 -2
- package/dist/components/{email → auth/email}/password-changed-email.js +7 -7
- package/dist/components/{email → auth/email}/reset-password-email.d.ts +2 -2
- package/dist/components/{email → auth/email}/reset-password-email.js +7 -7
- package/dist/components/auth/forgot-password.d.ts +1 -1
- package/dist/components/auth/forgot-password.js +41 -38
- package/dist/components/auth/magic-link/magic-link-button.d.ts +11 -0
- package/dist/components/auth/magic-link/magic-link-button.js +20 -0
- package/dist/components/auth/magic-link/magic-link.d.ts +16 -0
- package/dist/components/auth/magic-link/magic-link.js +87 -0
- package/dist/components/{settings/account → auth/multi-session}/manage-account.d.ts +2 -6
- package/dist/components/auth/multi-session/manage-account.js +49 -0
- package/dist/components/auth/multi-session/manage-accounts.js +34 -0
- package/dist/components/{user/switch-account-menu.d.ts → auth/multi-session/switch-account-submenu-content.d.ts} +3 -3
- package/dist/components/auth/multi-session/switch-account-submenu-content.js +29 -0
- package/dist/components/{user/switch-account-item.d.ts → auth/multi-session/switch-account-submenu-item.d.ts} +2 -2
- package/dist/components/auth/multi-session/switch-account-submenu-item.js +20 -0
- package/dist/components/auth/multi-session/switch-account-submenu.d.ts +13 -0
- package/dist/components/auth/multi-session/switch-account-submenu.js +24 -0
- package/dist/components/auth/passkey/passkey-button.d.ts +6 -0
- package/dist/components/auth/passkey/passkey-button.js +24 -0
- package/dist/components/auth/passkey/passkey.js +45 -0
- package/dist/components/auth/passkey/passkeys.js +106 -0
- package/dist/components/auth/provider-button.d.ts +6 -8
- package/dist/components/auth/provider-button.js +16 -20
- package/dist/components/auth/provider-buttons.d.ts +3 -4
- package/dist/components/auth/provider-buttons.js +9 -10
- package/dist/components/auth/reset-password.js +110 -107
- package/dist/components/{settings → auth/settings}/account/account-settings.d.ts +5 -2
- package/dist/components/auth/settings/account/account-settings.js +20 -0
- package/dist/components/auth/settings/account/change-avatar.js +89 -0
- package/dist/components/{settings → auth/settings}/account/change-email.js +17 -17
- package/dist/components/{settings → auth/settings}/account/user-profile.d.ts +2 -3
- package/dist/components/auth/settings/account/user-profile.js +86 -0
- package/dist/components/auth/settings/security/active-session.js +59 -0
- package/dist/components/{settings → auth/settings}/security/active-sessions.js +4 -4
- package/dist/components/auth/settings/security/change-password.js +189 -0
- package/dist/components/auth/settings/security/linked-account.js +56 -0
- package/dist/components/{settings → auth/settings}/security/linked-accounts.js +5 -5
- package/dist/components/{settings → auth/settings}/security/security-settings.d.ts +1 -1
- package/dist/components/auth/settings/security/security-settings.js +22 -0
- package/dist/components/auth/settings/settings.js +45 -0
- package/dist/components/auth/sign-in.js +75 -99
- package/dist/components/auth/sign-out.js +11 -11
- package/dist/components/auth/sign-up.js +123 -148
- package/dist/components/{settings/account → auth/theme}/appearance.d.ts +3 -6
- package/dist/components/auth/theme/appearance.js +72 -0
- package/dist/components/auth/theme/theme-toggle-item.d.ts +5 -0
- package/dist/components/auth/theme/theme-toggle-item.js +58 -0
- package/dist/components/auth/user/user-avatar.js +29 -0
- package/dist/components/{user → auth/user}/user-button.d.ts +2 -6
- package/dist/components/auth/user/user-button.js +55 -0
- package/dist/components/auth/user/user-view.js +37 -0
- package/dist/components/auth/username/sign-in-username.d.ts +14 -0
- package/dist/components/auth/username/sign-in-username.js +142 -0
- package/dist/components/auth/username/username-field.d.ts +8 -0
- package/dist/components/auth/username/username-field.js +51 -0
- package/dist/email.d.ts +7 -0
- package/dist/email.js +9 -0
- package/dist/index.d.ts +12 -27
- package/dist/index.js +20 -35
- package/dist/lib/auth/auth-plugin.d.ts +44 -0
- package/dist/lib/auth/delete-user-plugin.d.ts +17 -0
- package/dist/lib/auth/delete-user-plugin.js +10 -0
- package/dist/lib/auth/magic-link-plugin.d.ts +31 -0
- package/dist/lib/auth/magic-link-plugin.js +13 -0
- package/dist/lib/auth/multi-session-plugin.d.ts +18 -0
- package/dist/lib/auth/multi-session-plugin.js +12 -0
- package/dist/lib/auth/passkey-plugin.d.ts +20 -0
- package/dist/lib/auth/passkey-plugin.js +12 -0
- package/dist/lib/auth/theme-plugin.d.ts +68 -0
- package/dist/lib/auth/theme-plugin.js +23 -0
- package/dist/lib/auth/username-plugin.d.ts +63 -0
- package/dist/lib/auth/username-plugin.js +18 -0
- package/dist/plugins.d.ts +20 -0
- package/dist/plugins.js +21 -0
- package/package.json +19 -21
- package/src/components/auth/additional-field.tsx +554 -0
- package/src/components/auth/auth-provider.tsx +5 -6
- package/src/components/auth/auth.tsx +99 -35
- package/src/components/{settings/security → auth/delete-user}/danger-zone.tsx +3 -10
- package/src/components/{settings/security → auth/delete-user}/delete-user.tsx +30 -20
- package/src/components/{email → auth/email}/email-changed-email.tsx +2 -2
- package/src/components/{email → auth/email}/email-verification-email.tsx +2 -2
- package/src/components/{email → auth/email}/magic-link-email.tsx +2 -2
- package/src/components/{email → auth/email}/new-device-email.tsx +2 -2
- package/src/components/{email → auth/email}/otp-email.tsx +2 -2
- package/src/components/{email → auth/email}/password-changed-email.tsx +2 -2
- package/src/components/{email → auth/email}/reset-password-email.tsx +2 -2
- package/src/components/auth/forgot-password.tsx +14 -11
- package/src/components/auth/magic-link/magic-link-button.tsx +61 -0
- package/src/components/auth/{magic-link.tsx → magic-link/magic-link.tsx} +55 -40
- package/src/components/{settings/account → auth/multi-session}/manage-account.tsx +16 -13
- package/src/components/{settings/account → auth/multi-session}/manage-accounts.tsx +14 -5
- package/src/components/{user/switch-account-menu.tsx → auth/multi-session/switch-account-submenu-content.tsx} +18 -11
- package/src/components/{user/switch-account-item.tsx → auth/multi-session/switch-account-submenu-item.tsx} +17 -5
- package/src/components/auth/multi-session/switch-account-submenu.tsx +50 -0
- package/src/components/auth/passkey/passkey-button.tsx +56 -0
- package/src/components/{settings/security → auth/passkey}/passkey.tsx +20 -6
- package/src/components/auth/passkey/passkeys.tsx +196 -0
- package/src/components/auth/provider-button.tsx +27 -29
- package/src/components/auth/provider-buttons.tsx +6 -11
- package/src/components/auth/reset-password.tsx +13 -7
- package/src/components/{settings → auth/settings}/account/account-settings.tsx +15 -13
- package/src/components/{settings → auth/settings}/account/change-avatar.tsx +4 -3
- package/src/components/{settings → auth/settings}/account/change-email.tsx +3 -3
- package/src/components/auth/settings/account/user-profile.tsx +171 -0
- package/src/components/{settings → auth/settings}/security/active-session.tsx +8 -5
- package/src/components/{settings → auth/settings}/security/active-sessions.tsx +3 -3
- package/src/components/{settings → auth/settings}/security/change-password.tsx +14 -9
- package/src/components/{settings → auth/settings}/security/linked-account.tsx +12 -8
- package/src/components/{settings → auth/settings}/security/linked-accounts.tsx +2 -2
- package/src/components/{settings → auth/settings}/security/security-settings.tsx +7 -6
- package/src/components/{settings → auth/settings}/settings.tsx +2 -2
- package/src/components/auth/sign-in.tsx +38 -61
- package/src/components/auth/sign-out.tsx +2 -2
- package/src/components/auth/sign-up.tsx +109 -131
- package/src/components/{settings/account → auth/theme}/appearance.tsx +17 -24
- package/src/components/auth/theme/theme-toggle-item.tsx +110 -0
- package/src/components/{user → auth/user}/user-avatar.tsx +12 -4
- package/src/components/{user → auth/user}/user-button.tsx +15 -88
- package/src/components/{user → auth/user}/user-view.tsx +12 -4
- package/src/components/auth/username/sign-in-username.tsx +283 -0
- package/src/components/auth/username/username-field.tsx +122 -0
- package/src/email.ts +9 -0
- package/src/index.tsx +12 -27
- package/src/lib/auth/auth-plugin.ts +67 -0
- package/src/lib/auth/delete-user-plugin.ts +15 -0
- package/src/lib/auth/magic-link-plugin.ts +26 -0
- package/src/lib/auth/multi-session-plugin.ts +17 -0
- package/src/lib/auth/passkey-plugin.ts +17 -0
- package/src/lib/auth/theme-plugin.ts +86 -0
- package/src/lib/auth/username-plugin.tsx +30 -0
- package/src/plugins.ts +23 -0
- package/dist/components/auth/magic-link-button.d.ts +0 -13
- package/dist/components/auth/magic-link-button.js +0 -16
- package/dist/components/auth/magic-link.d.ts +0 -17
- package/dist/components/auth/magic-link.js +0 -99
- package/dist/components/auth/passkey-button.d.ts +0 -4
- package/dist/components/auth/passkey-button.js +0 -21
- package/dist/components/email/magic-link-email.d.ts +0 -3
- package/dist/components/email/new-device-email.d.ts +0 -3
- package/dist/components/email/otp-email.d.ts +0 -3
- package/dist/components/settings/account/account-settings.js +0 -23
- package/dist/components/settings/account/appearance.js +0 -71
- package/dist/components/settings/account/change-avatar.js +0 -89
- package/dist/components/settings/account/manage-account.js +0 -48
- package/dist/components/settings/account/manage-accounts.js +0 -33
- package/dist/components/settings/account/user-profile.js +0 -103
- package/dist/components/settings/security/active-session.js +0 -59
- package/dist/components/settings/security/change-password.js +0 -189
- package/dist/components/settings/security/delete-user.js +0 -92
- package/dist/components/settings/security/linked-account.js +0 -56
- package/dist/components/settings/security/passkey.js +0 -43
- package/dist/components/settings/security/passkeys.js +0 -53
- package/dist/components/settings/security/security-settings.js +0 -25
- package/dist/components/settings/settings.js +0 -45
- package/dist/components/user/switch-account-item.js +0 -20
- package/dist/components/user/switch-account-menu.js +0 -28
- package/dist/components/user/user-avatar.js +0 -29
- package/dist/components/user/user-button.js +0 -91
- package/dist/components/user/user-view.js +0 -37
- package/dist/core.d.ts +0 -1
- package/dist/core.js +0 -1
- package/dist/react-exports.d.ts +0 -1
- package/dist/react-exports.js +0 -1
- package/src/components/auth/magic-link-button.tsx +0 -43
- package/src/components/auth/passkey-button.tsx +0 -35
- package/src/components/settings/account/user-profile.tsx +0 -217
- package/src/components/settings/security/passkeys.tsx +0 -96
- package/src/core.ts +0 -1
- package/src/react-exports.ts +0 -1
- /package/dist/components/{settings/security → auth/delete-user}/delete-user.d.ts +0 -0
- /package/dist/components/{settings/account → auth/multi-session}/manage-accounts.d.ts +0 -0
- /package/dist/components/{settings/security → auth/passkey}/passkey.d.ts +0 -0
- /package/dist/components/{settings/security → auth/passkey}/passkeys.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/account/change-avatar.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/account/change-email.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/security/active-session.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/security/active-sessions.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/security/change-password.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/security/linked-account.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/security/linked-accounts.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/settings.d.ts +0 -0
- /package/dist/components/{user → auth/user}/user-avatar.d.ts +0 -0
- /package/dist/components/{user → auth/user}/user-view.d.ts +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { passkeyPlugin as e } from "../../../lib/auth/passkey-plugin.js";
|
|
2
|
+
import { Passkey as t } from "./passkey.js";
|
|
3
|
+
import { useAddPasskey as n, useAuth as r, useAuthPlugin as i, useListPasskeys as a } from "@better-auth-ui/react";
|
|
4
|
+
import { Fingerprint as o } from "@gravity-ui/icons";
|
|
5
|
+
import { AlertDialog as s, Button as c, Card as l, FieldError as u, Form as d, Input as f, Label as p, Skeleton as m, Spinner as h, TextField as g, cn as _ } from "@heroui/react";
|
|
6
|
+
import { useState as v } from "react";
|
|
7
|
+
import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/auth/passkey/passkeys.tsx
|
|
9
|
+
function S({ className: m, variant: S, ...w }) {
|
|
10
|
+
let { authClient: T, localization: E } = r(), { localization: D } = i(e), { data: O, isPending: k } = a(T), { mutate: A, isPending: j } = n(T), [M, N] = v(!1), [P, F] = v(""), I = (e) => {
|
|
11
|
+
N(e), F("");
|
|
12
|
+
}, L = async (e) => {
|
|
13
|
+
e.preventDefault(), A({ name: P.trim() || void 0 }, { onSuccess: () => {
|
|
14
|
+
N(!1), F("");
|
|
15
|
+
} });
|
|
16
|
+
};
|
|
17
|
+
return /* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("h2", {
|
|
18
|
+
className: _("text-sm font-semibold mb-3"),
|
|
19
|
+
children: D.passkeys
|
|
20
|
+
}), /* @__PURE__ */ b(l, {
|
|
21
|
+
className: _(m),
|
|
22
|
+
variant: S,
|
|
23
|
+
...w,
|
|
24
|
+
children: /* @__PURE__ */ x(l.Content, {
|
|
25
|
+
className: "gap-0",
|
|
26
|
+
children: [/* @__PURE__ */ x("div", {
|
|
27
|
+
className: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",
|
|
28
|
+
children: [/* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("p", {
|
|
29
|
+
className: "text-sm font-medium leading-tight",
|
|
30
|
+
children: D.passkeysDescription
|
|
31
|
+
}), /* @__PURE__ */ b("p", {
|
|
32
|
+
className: "text-muted text-xs mt-0.5",
|
|
33
|
+
children: D.passkeysInstructions
|
|
34
|
+
})] }), /* @__PURE__ */ x(s, { children: [/* @__PURE__ */ b(c, {
|
|
35
|
+
className: "shrink-0",
|
|
36
|
+
size: "sm",
|
|
37
|
+
isDisabled: k,
|
|
38
|
+
onPress: () => N(!0),
|
|
39
|
+
children: D.addPasskey
|
|
40
|
+
}), /* @__PURE__ */ b(s.Backdrop, {
|
|
41
|
+
isOpen: M,
|
|
42
|
+
onOpenChange: I,
|
|
43
|
+
children: /* @__PURE__ */ b(s.Container, { children: /* @__PURE__ */ b(s.Dialog, { children: /* @__PURE__ */ x(d, {
|
|
44
|
+
onSubmit: L,
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ b(s.CloseTrigger, {}),
|
|
47
|
+
/* @__PURE__ */ x(s.Header, { children: [/* @__PURE__ */ b(s.Icon, {
|
|
48
|
+
status: "default",
|
|
49
|
+
children: /* @__PURE__ */ b(o, {})
|
|
50
|
+
}), /* @__PURE__ */ b(s.Heading, { children: D.addPasskey })] }),
|
|
51
|
+
/* @__PURE__ */ x(s.Body, {
|
|
52
|
+
className: "overflow-visible",
|
|
53
|
+
children: [/* @__PURE__ */ b("p", {
|
|
54
|
+
className: "text-muted text-sm",
|
|
55
|
+
children: D.passkeysInstructions
|
|
56
|
+
}), /* @__PURE__ */ x(g, {
|
|
57
|
+
className: "mt-4",
|
|
58
|
+
name: "passkey-name",
|
|
59
|
+
isDisabled: j,
|
|
60
|
+
value: P,
|
|
61
|
+
onChange: F,
|
|
62
|
+
children: [
|
|
63
|
+
/* @__PURE__ */ b(p, { children: D.passkey }),
|
|
64
|
+
/* @__PURE__ */ b(f, {
|
|
65
|
+
autoFocus: !0,
|
|
66
|
+
placeholder: E.settings.optional,
|
|
67
|
+
variant: "secondary"
|
|
68
|
+
}),
|
|
69
|
+
/* @__PURE__ */ b(u, {})
|
|
70
|
+
]
|
|
71
|
+
})]
|
|
72
|
+
}),
|
|
73
|
+
/* @__PURE__ */ x(s.Footer, { children: [/* @__PURE__ */ b(c, {
|
|
74
|
+
slot: "close",
|
|
75
|
+
variant: "tertiary",
|
|
76
|
+
isDisabled: j,
|
|
77
|
+
children: E.settings.cancel
|
|
78
|
+
}), /* @__PURE__ */ x(c, {
|
|
79
|
+
type: "submit",
|
|
80
|
+
isPending: j,
|
|
81
|
+
children: [j && /* @__PURE__ */ b(h, {
|
|
82
|
+
color: "current",
|
|
83
|
+
size: "sm"
|
|
84
|
+
}), D.addPasskey]
|
|
85
|
+
})] })
|
|
86
|
+
]
|
|
87
|
+
}) }) })
|
|
88
|
+
})] })]
|
|
89
|
+
}), k ? /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b("div", { className: "border-b border-dashed -mx-4 md:-mx-6 my-4" }), /* @__PURE__ */ b(C, {})] }) : O?.map((e) => /* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("div", { className: "border-b border-dashed -mx-4 md:-mx-6 my-4" }), /* @__PURE__ */ b(t, { passkey: e })] }, e.id))]
|
|
90
|
+
})
|
|
91
|
+
})] });
|
|
92
|
+
}
|
|
93
|
+
function C() {
|
|
94
|
+
return /* @__PURE__ */ b("div", {
|
|
95
|
+
className: "flex items-center justify-between",
|
|
96
|
+
children: /* @__PURE__ */ x("div", {
|
|
97
|
+
className: "flex items-center gap-3",
|
|
98
|
+
children: [/* @__PURE__ */ b(m, { className: "size-10 rounded-xl" }), /* @__PURE__ */ x("div", {
|
|
99
|
+
className: "flex flex-col gap-1",
|
|
100
|
+
children: [/* @__PURE__ */ b(m, { className: "h-4 w-24 rounded-lg" }), /* @__PURE__ */ b(m, { className: "h-3 w-20 rounded-lg" })]
|
|
101
|
+
})]
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { S as Passkeys };
|
|
@@ -2,14 +2,12 @@ import { ButtonProps } from '@heroui/react';
|
|
|
2
2
|
import { SocialProvider } from 'better-auth/social-providers';
|
|
3
3
|
export type ProviderButtonProps = {
|
|
4
4
|
provider: SocialProvider;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} & Omit<ButtonProps, "children" | "onPress" | "isPending">;
|
|
5
|
+
display?: "full" | "name" | "icon";
|
|
6
|
+
} & Omit<ButtonProps, "children" | "onPress" | "isPending" | "isDisabled">;
|
|
8
7
|
/**
|
|
9
|
-
*
|
|
8
|
+
* Social provider sign-in button.
|
|
10
9
|
*
|
|
11
|
-
* @param provider -
|
|
12
|
-
* @param
|
|
13
|
-
* @param isDisabled - External disabled state (e.g. a sibling provider is mid-redirect).
|
|
10
|
+
* @param provider - Provider to sign in with.
|
|
11
|
+
* @param display - `"full"` (e.g. "Continue with Google"), `"name"` (just the provider name), or `"icon"` (icon only).
|
|
14
12
|
*/
|
|
15
|
-
export declare function ProviderButton({ provider,
|
|
13
|
+
export declare function ProviderButton({ provider, display, variant, ...props }: ProviderButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { authMutationKeys as e, getProviderName as t } from "@better-auth-ui/core";
|
|
2
|
+
import { providerIcons as n, useAuth as r, useSignInSocial as i } from "@better-auth-ui/react";
|
|
3
|
+
import { Button as a, Spinner as o } from "@heroui/react";
|
|
4
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
5
|
+
import { useIsMutating as l } from "@tanstack/react-query";
|
|
6
6
|
//#region src/components/auth/provider-button.tsx
|
|
7
|
-
function
|
|
8
|
-
let {
|
|
9
|
-
|
|
10
|
-
y(!1);
|
|
11
|
-
}, 5e3);
|
|
12
|
-
} }), S = e[l], C = x || v;
|
|
13
|
-
return /* @__PURE__ */ o(r, {
|
|
7
|
+
function u({ provider: u, display: d = "full", variant: f = "tertiary", ...p }) {
|
|
8
|
+
let { authClient: m, baseURL: h, localization: g, redirectTo: _ } = r(), v = `${h}${_}`, { mutate: y, isPending: b } = i(m), x = n[u];
|
|
9
|
+
return /* @__PURE__ */ c(a, {
|
|
14
10
|
variant: f,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
callbackURL: _
|
|
11
|
+
isPending: l({ mutationKey: e.signIn.all }) + l({ mutationKey: e.signUp.all }) > 0,
|
|
12
|
+
onPress: () => y({
|
|
13
|
+
provider: u,
|
|
14
|
+
callbackURL: v
|
|
20
15
|
}),
|
|
21
16
|
...p,
|
|
22
|
-
|
|
17
|
+
"aria-label": t(u),
|
|
18
|
+
children: [b ? /* @__PURE__ */ s(o, {
|
|
23
19
|
color: "current",
|
|
24
20
|
size: "sm"
|
|
25
|
-
}) : /* @__PURE__ */
|
|
21
|
+
}) : /* @__PURE__ */ s(x, {}), d === "full" ? g.auth.continueWith.replace("{{provider}}", t(u)) : d === "name" ? t(u) : null]
|
|
26
22
|
});
|
|
27
23
|
}
|
|
28
24
|
//#endregion
|
|
29
|
-
export {
|
|
25
|
+
export { u as ProviderButton };
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
export type ProviderButtonsProps = {
|
|
2
|
-
isPending?: boolean;
|
|
3
2
|
socialLayout?: SocialLayout;
|
|
4
3
|
};
|
|
5
4
|
export type SocialLayout = "auto" | "horizontal" | "vertical" | "grid";
|
|
6
5
|
/**
|
|
7
|
-
* Render social provider sign-in buttons. Each button owns its own sign-in
|
|
6
|
+
* Render social provider sign-in buttons. Each button owns its own sign-in
|
|
7
|
+
* mutation and reads shared auth pending state from React Query.
|
|
8
8
|
*
|
|
9
|
-
* @param isPending - External pending state (e.g. parent form submitting) that disables all buttons.
|
|
10
9
|
* @param socialLayout - Preferred layout for the buttons; `"auto"` picks `"horizontal"` when there are four or more providers, otherwise `"vertical"`.
|
|
11
10
|
* @returns The JSX element that renders the configured social provider buttons.
|
|
12
11
|
*/
|
|
13
|
-
export declare function ProviderButtons({
|
|
12
|
+
export declare function ProviderButtons({ socialLayout }: ProviderButtonsProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { ProviderButton as e } from "./provider-button.js";
|
|
2
2
|
import { useAuth as t } from "@better-auth-ui/react";
|
|
3
3
|
import { cn as n } from "@heroui/react";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { useMemo as r } from "react";
|
|
5
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/auth/provider-buttons.tsx
|
|
7
|
-
function a({
|
|
8
|
-
let { socialProviders:
|
|
9
|
-
return /* @__PURE__ */
|
|
10
|
-
className: n("gap-3",
|
|
11
|
-
children:
|
|
7
|
+
function a({ socialLayout: a = "auto" }) {
|
|
8
|
+
let { socialProviders: o } = t(), s = r(() => a === "auto" ? o?.length && o.length >= 4 ? "horizontal" : "vertical" : a, [a, o?.length]);
|
|
9
|
+
return /* @__PURE__ */ i("div", {
|
|
10
|
+
className: n("gap-3", s === "grid" && "grid grid-cols-2", s === "vertical" && "flex flex-col", s === "horizontal" && "flex flex-wrap"),
|
|
11
|
+
children: o?.map((t) => /* @__PURE__ */ i(e, {
|
|
12
12
|
provider: t,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
className: n("w-full", c === "horizontal" && "flex-1")
|
|
13
|
+
display: s === "vertical" ? "full" : s === "grid" ? "name" : "icon",
|
|
14
|
+
className: n("w-full", s === "horizontal" && "flex-1")
|
|
16
15
|
}, t))
|
|
17
16
|
});
|
|
18
17
|
}
|
|
@@ -1,138 +1,141 @@
|
|
|
1
1
|
import { useAuth as e, useResetPassword as t } from "@better-auth-ui/react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Eye as n, EyeSlash as r } from "@gravity-ui/icons";
|
|
3
|
+
import { Button as i, Card as a, Description as o, FieldError as s, Form as c, InputGroup as l, Label as u, Link as d, Spinner as f, TextField as p, cn as m, toast as h } from "@heroui/react";
|
|
4
4
|
import { useEffect as g, useState as _ } from "react";
|
|
5
|
-
import {
|
|
5
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/auth/reset-password.tsx
|
|
7
7
|
function b({ className: b, variant: x, ...S }) {
|
|
8
|
-
let {
|
|
9
|
-
|
|
10
|
-
} }), [
|
|
8
|
+
let { authClient: C, basePaths: w, emailAndPassword: T, localization: E, viewPaths: D, navigate: O } = e(), { mutate: k, isPending: A } = t(C, { onSuccess: () => {
|
|
9
|
+
h.success(E.auth.passwordResetSuccess), O({ to: `${w.auth}/${D.auth.signIn}` });
|
|
10
|
+
} }), [j, M] = _(!1), [N, P] = _(!1);
|
|
11
11
|
g(() => {
|
|
12
|
-
new URLSearchParams(window.location.search).get("token") || (
|
|
12
|
+
new URLSearchParams(window.location.search).get("token") || (h.danger(E.auth.invalidResetPasswordToken), O({ to: `${w.auth}/${D.auth.signIn}` }));
|
|
13
13
|
}, [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
w.auth,
|
|
15
|
+
E.auth.invalidResetPasswordToken,
|
|
16
|
+
D.auth.signIn,
|
|
17
|
+
O
|
|
18
18
|
]);
|
|
19
|
-
function
|
|
19
|
+
function F(e) {
|
|
20
20
|
e.preventDefault();
|
|
21
21
|
let t = new URLSearchParams(window.location.search).get("token");
|
|
22
22
|
if (!t) {
|
|
23
|
-
|
|
23
|
+
h.danger(E.auth.invalidResetPasswordToken), O({ to: `${w.auth}/${D.auth.signIn}` });
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
let n = new FormData(e.currentTarget), r = n.get("password"), i = n.get("confirmPassword");
|
|
27
|
-
if (
|
|
28
|
-
|
|
27
|
+
if (T?.confirmPassword && r !== i) {
|
|
28
|
+
h.danger(E.auth.passwordsDoNotMatch);
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
k({
|
|
32
32
|
token: t,
|
|
33
33
|
newPassword: r
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
|
-
return /* @__PURE__ */
|
|
37
|
-
className:
|
|
36
|
+
return /* @__PURE__ */ y(a, {
|
|
37
|
+
className: m("w-full max-w-sm gap-4 md:p-6", b),
|
|
38
38
|
variant: x,
|
|
39
39
|
...S,
|
|
40
40
|
children: [
|
|
41
|
-
/* @__PURE__ */
|
|
41
|
+
/* @__PURE__ */ v(a.Header, { children: /* @__PURE__ */ v(a.Title, {
|
|
42
42
|
className: "text-xl font-semibold mb-1",
|
|
43
|
-
children:
|
|
43
|
+
children: E.auth.resetPassword
|
|
44
44
|
}) }),
|
|
45
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
45
|
+
/* @__PURE__ */ v(a.Content, {
|
|
46
|
+
className: "gap-4",
|
|
47
|
+
children: /* @__PURE__ */ y(c, {
|
|
48
|
+
onSubmit: F,
|
|
49
|
+
className: "flex flex-col gap-4",
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ y(p, {
|
|
52
|
+
minLength: T?.minPasswordLength,
|
|
53
|
+
maxLength: T?.maxPasswordLength,
|
|
54
|
+
name: "password",
|
|
55
|
+
autoComplete: "new-password",
|
|
56
|
+
isDisabled: A,
|
|
57
|
+
children: [
|
|
58
|
+
/* @__PURE__ */ v(u, { children: E.auth.password }),
|
|
59
|
+
/* @__PURE__ */ y(l, {
|
|
60
|
+
variant: x === "transparent" ? "primary" : "secondary",
|
|
61
|
+
children: [/* @__PURE__ */ v(l.Input, {
|
|
62
|
+
name: "password",
|
|
63
|
+
placeholder: E.auth.newPasswordPlaceholder,
|
|
64
|
+
type: j ? "text" : "password",
|
|
65
|
+
required: !0
|
|
66
|
+
}), /* @__PURE__ */ v(l.Suffix, {
|
|
67
|
+
className: "px-0",
|
|
68
|
+
children: /* @__PURE__ */ v(i, {
|
|
69
|
+
isIconOnly: !0,
|
|
70
|
+
"aria-label": j ? E.auth.hidePassword : E.auth.showPassword,
|
|
71
|
+
size: "sm",
|
|
72
|
+
variant: "ghost",
|
|
73
|
+
onPress: () => M(!j),
|
|
74
|
+
isDisabled: A,
|
|
75
|
+
children: v(j ? r : n, {})
|
|
76
|
+
})
|
|
77
|
+
})]
|
|
78
|
+
}),
|
|
79
|
+
/* @__PURE__ */ v(s, {})
|
|
80
|
+
]
|
|
81
|
+
}),
|
|
82
|
+
T?.confirmPassword && /* @__PURE__ */ y(p, {
|
|
83
|
+
minLength: T?.minPasswordLength,
|
|
84
|
+
maxLength: T?.maxPasswordLength,
|
|
85
|
+
name: "confirmPassword",
|
|
86
|
+
autoComplete: "new-password",
|
|
87
|
+
isDisabled: A,
|
|
88
|
+
children: [
|
|
89
|
+
/* @__PURE__ */ v(u, { children: E.auth.confirmPassword }),
|
|
90
|
+
/* @__PURE__ */ y(l, {
|
|
91
|
+
variant: x === "transparent" ? "primary" : "secondary",
|
|
92
|
+
children: [/* @__PURE__ */ v(l.Input, {
|
|
93
|
+
placeholder: E.auth.confirmPasswordPlaceholder,
|
|
94
|
+
type: N ? "text" : "password",
|
|
95
|
+
required: !0,
|
|
96
|
+
name: "confirmPassword"
|
|
97
|
+
}), /* @__PURE__ */ v(l.Suffix, {
|
|
98
|
+
className: "px-0",
|
|
99
|
+
children: /* @__PURE__ */ v(i, {
|
|
100
|
+
isIconOnly: !0,
|
|
101
|
+
"aria-label": N ? E.auth.hidePassword : E.auth.showPassword,
|
|
102
|
+
size: "sm",
|
|
103
|
+
variant: "ghost",
|
|
104
|
+
onPress: () => P(!N),
|
|
105
|
+
isDisabled: A,
|
|
106
|
+
children: v(N ? r : n, {})
|
|
107
|
+
})
|
|
108
|
+
})]
|
|
109
|
+
}),
|
|
110
|
+
/* @__PURE__ */ v(s, {})
|
|
111
|
+
]
|
|
112
|
+
}),
|
|
113
|
+
/* @__PURE__ */ v("div", {
|
|
114
|
+
className: "flex flex-col gap-3",
|
|
115
|
+
children: /* @__PURE__ */ y(i, {
|
|
116
|
+
type: "submit",
|
|
117
|
+
className: "w-full",
|
|
118
|
+
isPending: A,
|
|
119
|
+
children: [A && /* @__PURE__ */ v(f, {
|
|
120
|
+
color: "current",
|
|
121
|
+
size: "sm"
|
|
122
|
+
}), E.auth.resetPassword]
|
|
123
|
+
})
|
|
121
124
|
})
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
})
|
|
125
|
-
/* @__PURE__ */
|
|
126
|
-
className: "flex-col",
|
|
127
|
-
children: /* @__PURE__ */
|
|
125
|
+
]
|
|
126
|
+
})
|
|
127
|
+
}),
|
|
128
|
+
/* @__PURE__ */ v(a.Footer, {
|
|
129
|
+
className: "flex-col gap-3",
|
|
130
|
+
children: /* @__PURE__ */ y(o, {
|
|
128
131
|
className: "text-sm",
|
|
129
132
|
children: [
|
|
130
|
-
|
|
133
|
+
E.auth.rememberYourPassword,
|
|
131
134
|
" ",
|
|
132
|
-
/* @__PURE__ */
|
|
133
|
-
href: `${
|
|
134
|
-
className: "text-accent
|
|
135
|
-
children:
|
|
135
|
+
/* @__PURE__ */ v(d, {
|
|
136
|
+
href: `${w.auth}/${D.auth.signIn}`,
|
|
137
|
+
className: "text-accent no-underline hover:underline decoration-accent-hover",
|
|
138
|
+
children: E.auth.signIn
|
|
136
139
|
})
|
|
137
140
|
]
|
|
138
141
|
})
|
|
@@ -5,9 +5,12 @@ export type AccountSettingsProps = {
|
|
|
5
5
|
variant?: CardProps["variant"];
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
|
-
* Renders the account settings layout
|
|
8
|
+
* Renders the account settings layout.
|
|
9
9
|
*
|
|
10
|
-
* UserProfile
|
|
10
|
+
* `UserProfile` always renders. `ChangeEmail` renders when password auth is
|
|
11
|
+
* enabled or the `magicLink` plugin is registered. Plugin-contributed account
|
|
12
|
+
* cards (e.g. `Appearance` from the theme plugin, multi-session accounts) are
|
|
13
|
+
* rendered via the plugins array.
|
|
11
14
|
*
|
|
12
15
|
* @param className - Optional additional CSS class names for the outer container.
|
|
13
16
|
* @param variant - Card variant forwarded to each account settings card.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ChangeEmail as e } from "./change-email.js";
|
|
2
|
+
import { UserProfile as t } from "./user-profile.js";
|
|
3
|
+
import { useAuth as n } from "@better-auth-ui/react";
|
|
4
|
+
import { cn as r } from "@heroui/react";
|
|
5
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/auth/settings/account/account-settings.tsx
|
|
7
|
+
function o({ className: o, variant: s, ...c }) {
|
|
8
|
+
let { emailAndPassword: l, plugins: u } = n(), d = u.some((e) => e.id === "magicLink");
|
|
9
|
+
return /* @__PURE__ */ a("div", {
|
|
10
|
+
className: r("flex w-full flex-col gap-4 md:gap-6", o),
|
|
11
|
+
...c,
|
|
12
|
+
children: [
|
|
13
|
+
/* @__PURE__ */ i(t, { variant: s }),
|
|
14
|
+
(l?.enabled || d) && /* @__PURE__ */ i(e, { variant: s }),
|
|
15
|
+
u.flatMap((e) => e.accountCards?.map((t, n) => /* @__PURE__ */ i(t, { variant: s }, `${e.id}-${n.toString()}`)))
|
|
16
|
+
]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { o as AccountSettings };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { UserAvatar as e } from "../../user/user-avatar.js";
|
|
2
|
+
import { fileToBase64 as t } from "@better-auth-ui/core";
|
|
3
|
+
import { useAuth as n, useSession as r, useUpdateUser as i } from "@better-auth-ui/react";
|
|
4
|
+
import { CloudArrowUpIn as a, TrashBin as o } from "@gravity-ui/icons";
|
|
5
|
+
import { Button as s, Dropdown as c, Label as l, Spinner as u, cn as d, toast as f } from "@heroui/react";
|
|
6
|
+
import { useRef as p, useState as m } from "react";
|
|
7
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/auth/settings/account/change-avatar.tsx
|
|
9
|
+
function _({ className: _ }) {
|
|
10
|
+
let { authClient: v, localization: y, avatar: b } = n(), { data: x } = r(v), { mutate: S, isPending: C } = i(v), w = p(null), [T, E] = m(!1), [D, O] = m(!1), k = C || T || D;
|
|
11
|
+
async function A(e) {
|
|
12
|
+
let n = e.target.files?.[0];
|
|
13
|
+
if (n) {
|
|
14
|
+
e.target.value = "", E(!0);
|
|
15
|
+
try {
|
|
16
|
+
let e = await b.resize?.(n, b.size, b.extension) || n;
|
|
17
|
+
S({ image: await b.upload?.(e) || await t(e) }, { onSuccess: () => f.success(y.settings.avatarChangedSuccess) });
|
|
18
|
+
} catch (e) {
|
|
19
|
+
e instanceof Error && f.danger(e.message);
|
|
20
|
+
}
|
|
21
|
+
E(!1);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function j() {
|
|
25
|
+
let e = x?.user.image;
|
|
26
|
+
S({ image: null }, { onSuccess: async () => {
|
|
27
|
+
if (e) {
|
|
28
|
+
O(!0);
|
|
29
|
+
try {
|
|
30
|
+
await b.delete?.(e);
|
|
31
|
+
} finally {
|
|
32
|
+
O(!1);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
f.success(y.settings.avatarDeletedSuccess);
|
|
36
|
+
} });
|
|
37
|
+
}
|
|
38
|
+
return /* @__PURE__ */ g("div", {
|
|
39
|
+
className: d("flex flex-col gap-1", _),
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ h(l, {
|
|
42
|
+
isDisabled: !x,
|
|
43
|
+
children: y.settings.avatar
|
|
44
|
+
}),
|
|
45
|
+
/* @__PURE__ */ h("input", {
|
|
46
|
+
ref: w,
|
|
47
|
+
type: "file",
|
|
48
|
+
accept: "image/*",
|
|
49
|
+
className: "hidden",
|
|
50
|
+
onChange: A
|
|
51
|
+
}),
|
|
52
|
+
/* @__PURE__ */ g("div", {
|
|
53
|
+
className: "flex items-center gap-4",
|
|
54
|
+
children: [/* @__PURE__ */ h(s, {
|
|
55
|
+
type: "button",
|
|
56
|
+
isIconOnly: !0,
|
|
57
|
+
variant: "ghost",
|
|
58
|
+
className: "p-0 h-auto w-auto rounded-full",
|
|
59
|
+
isDisabled: !x || k,
|
|
60
|
+
onPress: () => w.current?.click(),
|
|
61
|
+
children: /* @__PURE__ */ h(e, {
|
|
62
|
+
size: "lg",
|
|
63
|
+
isPending: k
|
|
64
|
+
})
|
|
65
|
+
}), /* @__PURE__ */ g(c, { children: [/* @__PURE__ */ g(s, {
|
|
66
|
+
isDisabled: !x || k,
|
|
67
|
+
size: "sm",
|
|
68
|
+
variant: "secondary",
|
|
69
|
+
children: [k && /* @__PURE__ */ h(u, { size: "sm" }), y.settings.changeAvatar]
|
|
70
|
+
}), /* @__PURE__ */ h(c.Popover, {
|
|
71
|
+
className: "min-w-fit",
|
|
72
|
+
children: /* @__PURE__ */ g(c.Menu, { children: [/* @__PURE__ */ g(c.Item, {
|
|
73
|
+
textValue: y.settings.uploadAvatar,
|
|
74
|
+
onAction: () => w.current?.click(),
|
|
75
|
+
children: [/* @__PURE__ */ h(a, { className: "text-muted" }), /* @__PURE__ */ h(l, { children: y.settings.uploadAvatar })]
|
|
76
|
+
}), /* @__PURE__ */ g(c.Item, {
|
|
77
|
+
textValue: y.settings.deleteAvatar,
|
|
78
|
+
isDisabled: !x?.user.image,
|
|
79
|
+
onAction: j,
|
|
80
|
+
variant: "danger",
|
|
81
|
+
children: [/* @__PURE__ */ h(o, { className: "text-danger" }), /* @__PURE__ */ h(l, { children: y.settings.deleteAvatar })]
|
|
82
|
+
})] })
|
|
83
|
+
})] })]
|
|
84
|
+
})
|
|
85
|
+
]
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
export { _ as ChangeAvatar };
|