@better-auth-ui/heroui 1.6.2 → 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-provider.js +12 -11
- 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/{settings/security → auth/delete-user}/delete-user.d.ts +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/error-toaster.d.ts +1 -0
- package/dist/components/auth/error-toaster.js +17 -0
- package/dist/components/auth/forgot-password.d.ts +2 -2
- package/dist/components/auth/forgot-password.js +42 -42
- 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/{settings/account → auth/multi-session}/manage-accounts.d.ts +1 -1
- 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/{settings/security → auth/passkey}/passkeys.d.ts +1 -1
- package/dist/components/auth/passkey/passkeys.js +106 -0
- package/dist/components/auth/provider-button.d.ts +13 -0
- package/dist/components/auth/provider-button.js +25 -0
- package/dist/components/auth/provider-buttons.d.ts +3 -10
- package/dist/components/auth/provider-buttons.js +14 -22
- package/dist/components/auth/reset-password.d.ts +1 -1
- package/dist/components/auth/reset-password.js +110 -110
- 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.d.ts +1 -1
- package/dist/components/{settings → auth/settings}/account/change-email.js +17 -20
- package/dist/components/{settings → auth/settings}/account/user-profile.d.ts +3 -4
- 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.d.ts +1 -1
- package/dist/components/auth/settings/security/active-sessions.js +34 -0
- package/dist/components/{settings → auth/settings}/security/change-password.d.ts +1 -1
- 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.d.ts +1 -1
- package/dist/components/auth/settings/security/linked-accounts.js +45 -0
- 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.d.ts +1 -1
- package/dist/components/auth/sign-in.js +64 -100
- package/dist/components/auth/sign-out.js +11 -11
- package/dist/components/auth/sign-up.d.ts +1 -1
- package/dist/components/auth/sign-up.js +123 -157
- 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 +13 -27
- package/dist/index.js +22 -36
- 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 +22 -22
- package/src/components/auth/additional-field.tsx +554 -0
- package/src/components/auth/auth-provider.tsx +8 -5
- package/src/components/auth/auth.tsx +100 -36
- package/src/components/{settings/security → auth/delete-user}/danger-zone.tsx +3 -10
- package/src/components/{settings/security → auth/delete-user}/delete-user.tsx +31 -24
- 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/error-toaster.tsx +25 -0
- package/src/components/auth/forgot-password.tsx +15 -13
- package/src/components/auth/magic-link/magic-link-button.tsx +61 -0
- package/src/components/auth/{magic-link.tsx → magic-link/magic-link.tsx} +52 -57
- package/src/components/{settings/account → auth/multi-session}/manage-account.tsx +15 -15
- package/src/components/{settings/account → auth/multi-session}/manage-accounts.tsx +16 -12
- package/src/components/{user/switch-account-menu.tsx → auth/multi-session/switch-account-submenu-content.tsx} +19 -17
- package/src/components/{user/switch-account-item.tsx → auth/multi-session/switch-account-submenu-item.tsx} +18 -8
- 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 +21 -9
- package/src/components/auth/passkey/passkeys.tsx +196 -0
- package/src/components/auth/provider-button.tsx +65 -0
- package/src/components/auth/provider-buttons.tsx +23 -45
- package/src/components/auth/reset-password.tsx +14 -9
- package/src/components/{settings → auth/settings}/account/account-settings.tsx +15 -13
- package/src/components/{settings → auth/settings}/account/change-avatar.tsx +4 -5
- package/src/components/{settings → auth/settings}/account/change-email.tsx +5 -6
- package/src/components/auth/settings/account/user-profile.tsx +171 -0
- package/src/components/{settings → auth/settings}/security/active-session.tsx +8 -6
- package/src/components/{settings → auth/settings}/security/active-sessions.tsx +5 -10
- package/src/components/{settings → auth/settings}/security/change-password.tsx +22 -14
- package/src/components/{settings → auth/settings}/security/linked-account.tsx +10 -16
- package/src/components/{settings → auth/settings}/security/linked-accounts.tsx +4 -9
- 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 +39 -80
- package/src/components/auth/sign-out.tsx +2 -2
- package/src/components/auth/sign-up.tsx +110 -147
- package/src/components/{settings/account → auth/theme}/appearance.tsx +18 -25
- 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 +13 -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 -111
- package/dist/components/auth/passkey-button.d.ts +0 -4
- package/dist/components/auth/passkey-button.js +0 -24
- 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 -51
- package/dist/components/settings/account/manage-accounts.js +0 -33
- package/dist/components/settings/account/user-profile.js +0 -106
- package/dist/components/settings/security/active-session.js +0 -62
- package/dist/components/settings/security/active-sessions.js +0 -34
- package/dist/components/settings/security/change-password.js +0 -192
- package/dist/components/settings/security/delete-user.js +0 -97
- package/dist/components/settings/security/linked-account.js +0 -62
- package/dist/components/settings/security/linked-accounts.js +0 -45
- 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 -36
- package/src/components/settings/account/user-profile.tsx +0 -218
- package/src/components/settings/security/passkeys.tsx +0 -104
- package/src/core.ts +0 -1
- package/src/react-exports.ts +0 -1
- /package/dist/components/{settings/security → auth/passkey}/passkey.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/account/change-avatar.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/security/active-session.d.ts +0 -0
- /package/dist/components/{settings → auth/settings}/security/linked-account.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,45 @@
|
|
|
1
|
+
import { LinkedAccount as e } from "./linked-account.js";
|
|
2
|
+
import { useAuth as t, useListAccounts as n } from "@better-auth-ui/react";
|
|
3
|
+
import { Card as r, Skeleton as i, cn as a } from "@heroui/react";
|
|
4
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/auth/settings/security/linked-accounts.tsx
|
|
6
|
+
function c({ className: i, variant: c, ...u }) {
|
|
7
|
+
let { authClient: d, localization: f, socialProviders: p } = t(), { data: m, isPending: h } = n(d), g = [...(m?.filter((e) => e.providerId !== "credential"))?.map((e) => ({
|
|
8
|
+
key: e.id,
|
|
9
|
+
account: e,
|
|
10
|
+
provider: e.providerId
|
|
11
|
+
})) ?? [], ...p?.map((e) => ({
|
|
12
|
+
key: e,
|
|
13
|
+
account: void 0,
|
|
14
|
+
provider: e
|
|
15
|
+
})) ?? []];
|
|
16
|
+
return /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("h2", {
|
|
17
|
+
className: a("text-sm font-semibold mb-3"),
|
|
18
|
+
children: f.settings.linkedAccounts
|
|
19
|
+
}), /* @__PURE__ */ o(r, {
|
|
20
|
+
className: a(i),
|
|
21
|
+
variant: c,
|
|
22
|
+
...u,
|
|
23
|
+
children: /* @__PURE__ */ o(r.Content, {
|
|
24
|
+
className: "gap-0",
|
|
25
|
+
children: h ? p?.map((e, t) => /* @__PURE__ */ s("div", { children: [t > 0 && /* @__PURE__ */ o("div", { className: "border-b border-dashed -mx-4 md:-mx-6 my-4" }), /* @__PURE__ */ o(l, {})] }, e)) : g.map((t, n) => /* @__PURE__ */ s("div", { children: [n > 0 && /* @__PURE__ */ o("div", { className: "border-b border-dashed -mx-4 md:-mx-6 my-4" }), /* @__PURE__ */ o(e, {
|
|
26
|
+
account: t.account,
|
|
27
|
+
provider: t.provider
|
|
28
|
+
})] }, t.key))
|
|
29
|
+
})
|
|
30
|
+
})] });
|
|
31
|
+
}
|
|
32
|
+
function l() {
|
|
33
|
+
return /* @__PURE__ */ o("div", {
|
|
34
|
+
className: "flex items-center justify-between",
|
|
35
|
+
children: /* @__PURE__ */ s("div", {
|
|
36
|
+
className: "flex items-center gap-3",
|
|
37
|
+
children: [/* @__PURE__ */ o(i, { className: "size-10 rounded-xl" }), /* @__PURE__ */ s("div", {
|
|
38
|
+
className: "flex flex-col gap-1",
|
|
39
|
+
children: [/* @__PURE__ */ o(i, { className: "h-4 w-20 rounded-lg" }), /* @__PURE__ */ o(i, { className: "h-3 w-32 rounded-lg" })]
|
|
40
|
+
})]
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { c as LinkedAccounts };
|
|
@@ -8,7 +8,7 @@ export type SecuritySettingsProps = {
|
|
|
8
8
|
* Renders the security settings layout including password management, linked accounts, and active sessions.
|
|
9
9
|
*
|
|
10
10
|
* ChangePassword is rendered when password authentication is enabled; LinkedAccounts is rendered when social providers are present.
|
|
11
|
-
*
|
|
11
|
+
* Each registered auth plugin may contribute `securityCards` (for example delete-user, passkeys).
|
|
12
12
|
*
|
|
13
13
|
* @param className - Optional additional CSS class names for the outer container.
|
|
14
14
|
* @param variant - Card variant forwarded to each security settings card.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ActiveSessions as e } from "./active-sessions.js";
|
|
2
|
+
import { ChangePassword as t } from "./change-password.js";
|
|
3
|
+
import { LinkedAccounts as n } from "./linked-accounts.js";
|
|
4
|
+
import { useAuth as r } from "@better-auth-ui/react";
|
|
5
|
+
import { cn as i } from "@heroui/react";
|
|
6
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/auth/settings/security/security-settings.tsx
|
|
8
|
+
function s({ className: s, variant: c, ...l }) {
|
|
9
|
+
let { emailAndPassword: u, plugins: d, socialProviders: f } = r();
|
|
10
|
+
return /* @__PURE__ */ o("div", {
|
|
11
|
+
className: i("flex w-full flex-col gap-4 md:gap-6", s),
|
|
12
|
+
...l,
|
|
13
|
+
children: [
|
|
14
|
+
u?.enabled && /* @__PURE__ */ a(t, { variant: c }),
|
|
15
|
+
!!f?.length && /* @__PURE__ */ a(n, { variant: c }),
|
|
16
|
+
/* @__PURE__ */ a(e, { variant: c }),
|
|
17
|
+
d.flatMap((e) => e.securityCards?.map((t, n) => /* @__PURE__ */ a(t, { variant: c }, `${e.id}-${n.toString()}`)))
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { s as SecuritySettings };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AccountSettings as e } from "./account/account-settings.js";
|
|
2
|
+
import { SecuritySettings as t } from "./security/security-settings.js";
|
|
3
|
+
import { useAuth as n, useAuthenticate as r } from "@better-auth-ui/react";
|
|
4
|
+
import { Tabs as i, cn as a } from "@heroui/react";
|
|
5
|
+
import { useMemo as o } from "react";
|
|
6
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/auth/settings/settings.tsx
|
|
8
|
+
function l({ className: l, hideNav: u, path: d, variant: f, view: p, ...m }) {
|
|
9
|
+
let { authClient: h, basePaths: g, localization: _, viewPaths: v } = n();
|
|
10
|
+
if (r(h), !p && !d) throw Error("[Better Auth UI] Either `view` or `path` must be provided");
|
|
11
|
+
let y = o(() => Object.fromEntries(Object.entries(v.settings).map(([e, t]) => [t, e])), [v.settings]), b = p || (d ? y[d] : void 0);
|
|
12
|
+
return /* @__PURE__ */ c(i, {
|
|
13
|
+
className: a(l),
|
|
14
|
+
orientation: "horizontal",
|
|
15
|
+
selectedKey: b,
|
|
16
|
+
...m,
|
|
17
|
+
children: [
|
|
18
|
+
/* @__PURE__ */ s(i.ListContainer, { children: /* @__PURE__ */ c(i.List, {
|
|
19
|
+
"aria-label": _.settings.settings,
|
|
20
|
+
className: "overflow-auto w-fit",
|
|
21
|
+
children: [/* @__PURE__ */ c(i.Tab, {
|
|
22
|
+
id: "account",
|
|
23
|
+
href: `${g.settings}/${v.settings.account}`,
|
|
24
|
+
children: [_.settings.account, /* @__PURE__ */ s(i.Indicator, {})]
|
|
25
|
+
}), /* @__PURE__ */ c(i.Tab, {
|
|
26
|
+
id: "security",
|
|
27
|
+
href: `${g.settings}/${v.settings.security}`,
|
|
28
|
+
children: [_.settings.security, /* @__PURE__ */ s(i.Indicator, {})]
|
|
29
|
+
})]
|
|
30
|
+
}) }),
|
|
31
|
+
/* @__PURE__ */ s(i.Panel, {
|
|
32
|
+
id: "account",
|
|
33
|
+
className: "px-0",
|
|
34
|
+
children: /* @__PURE__ */ s(e, { variant: f })
|
|
35
|
+
}),
|
|
36
|
+
/* @__PURE__ */ s(i.Panel, {
|
|
37
|
+
id: "security",
|
|
38
|
+
className: "px-0",
|
|
39
|
+
children: /* @__PURE__ */ s(t, { variant: f })
|
|
40
|
+
})
|
|
41
|
+
]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { l as Settings };
|
|
@@ -11,4 +11,4 @@ export interface SignInProps {
|
|
|
11
11
|
*
|
|
12
12
|
* @returns The sign-in JSX element containing email/password fields, optional magic-link button, and social provider buttons.
|
|
13
13
|
*/
|
|
14
|
-
export declare function SignIn({ className, socialLayout, socialPosition, variant, ...props }: SignInProps & CardProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function SignIn({ className, socialLayout, socialPosition, variant, ...props }: SignInProps & Omit<CardProps, "children">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,156 +1,120 @@
|
|
|
1
1
|
import { FieldSeparator as e } from "./field-separator.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { ProviderButtons as t } from "./provider-buttons.js";
|
|
3
|
+
import { authMutationKeys as n } from "@better-auth-ui/core";
|
|
4
|
+
import { useAuth as r, useSendVerificationEmail as i, useSignInEmail as a } from "@better-auth-ui/react";
|
|
5
|
+
import { Button as o, Card as s, Checkbox as c, Description as l, FieldError as u, Form as d, Input as f, Label as p, Link as m, Spinner as h, TextField as g, cn as _, toast as v } from "@heroui/react";
|
|
6
|
+
import { useState as y } from "react";
|
|
7
7
|
import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
8
|
-
import {
|
|
8
|
+
import { useIsMutating as C } from "@tanstack/react-query";
|
|
9
9
|
//#region src/components/auth/sign-in.tsx
|
|
10
|
-
function w(
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
function T({ className: T, socialLayout: E, socialPosition: D = "bottom", variant: O, ...k }) {
|
|
14
|
-
let { basePaths: A, baseURL: j, emailAndPassword: M, localization: N, magicLink: P, passkey: F, redirectTo: I, socialProviders: L, username: R, viewPaths: z, navigate: B } = i(), [V, H] = C(""), { mutate: U } = a({
|
|
15
|
-
onError: (e) => y.danger(e.error?.message || e.message),
|
|
16
|
-
onSuccess: () => y.success(N.auth.verificationEmailSent)
|
|
17
|
-
}), { mutate: W, isPending: G } = o({
|
|
10
|
+
function w({ className: w, socialLayout: T, socialPosition: E = "bottom", variant: D, ...O }) {
|
|
11
|
+
let { authClient: k, basePaths: A, baseURL: j, emailAndPassword: M, localization: N, plugins: P, redirectTo: F, socialProviders: I, viewPaths: L, navigate: R } = r(), [z, B] = y(""), { mutate: V } = i(k, { onSuccess: () => v.success(N.auth.verificationEmailSent) }), { mutate: H, isPending: U } = a(k, {
|
|
18
12
|
onError: (e, { email: t }) => {
|
|
19
|
-
|
|
13
|
+
B(""), e.error?.code === "EMAIL_NOT_VERIFIED" ? v.danger(e.error?.message || e.message, { actionProps: {
|
|
20
14
|
children: N.auth.resend,
|
|
21
|
-
onClick: () =>
|
|
15
|
+
onClick: () => V({
|
|
22
16
|
email: t,
|
|
23
|
-
callbackURL: `${j}${
|
|
17
|
+
callbackURL: `${j}${F}`
|
|
24
18
|
})
|
|
25
|
-
} }) :
|
|
26
|
-
},
|
|
27
|
-
onSuccess: () => B({ to: I })
|
|
28
|
-
}), { mutate: K, isPending: q } = c({
|
|
29
|
-
onError: (e) => {
|
|
30
|
-
H(""), y.danger(e.error?.message || e.message);
|
|
19
|
+
} }) : v.danger(e.error?.message || e.message);
|
|
31
20
|
},
|
|
32
|
-
onSuccess: () =>
|
|
33
|
-
}),
|
|
34
|
-
onError: (e) => y.danger(e.error?.message || e.message),
|
|
35
|
-
onSuccess: () => {
|
|
36
|
-
Y(!0), setTimeout(() => {
|
|
37
|
-
Y(!1);
|
|
38
|
-
}, 5e3);
|
|
39
|
-
}
|
|
40
|
-
}), ne = (e) => {
|
|
21
|
+
onSuccess: () => R({ to: F })
|
|
22
|
+
}), W = (e) => {
|
|
41
23
|
e.preventDefault();
|
|
42
24
|
let t = new FormData(e.currentTarget), n = t.get("email"), r = t.get("rememberMe") === "on";
|
|
43
|
-
|
|
44
|
-
username: n,
|
|
45
|
-
password: V
|
|
46
|
-
}) : W({
|
|
25
|
+
H({
|
|
47
26
|
email: n,
|
|
48
|
-
password:
|
|
27
|
+
password: z,
|
|
49
28
|
...M?.rememberMe ? { rememberMe: r } : {}
|
|
50
29
|
});
|
|
51
|
-
},
|
|
52
|
-
return /* @__PURE__ */ S(
|
|
53
|
-
className:
|
|
54
|
-
variant:
|
|
55
|
-
...
|
|
30
|
+
}, G = C({ mutationKey: n.signIn.all }) + C({ mutationKey: n.signUp.all }) > 0, K = M?.enabled && !!I?.length;
|
|
31
|
+
return /* @__PURE__ */ S(s, {
|
|
32
|
+
className: _("w-full max-w-sm gap-4 md:p-6", w),
|
|
33
|
+
variant: D,
|
|
34
|
+
...O,
|
|
56
35
|
children: [
|
|
57
|
-
/* @__PURE__ */ x(
|
|
36
|
+
/* @__PURE__ */ x(s.Header, { children: /* @__PURE__ */ x(s.Title, {
|
|
58
37
|
className: "text-xl font-semibold mb-1",
|
|
59
38
|
children: N.auth.signIn
|
|
60
39
|
}) }),
|
|
61
|
-
/* @__PURE__ */ S(
|
|
40
|
+
/* @__PURE__ */ S(s.Content, {
|
|
62
41
|
className: "gap-4",
|
|
63
42
|
children: [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
isPending: Q
|
|
68
|
-
}), $ && /* @__PURE__ */ x(e, { children: N.auth.or })] }),
|
|
69
|
-
M?.enabled && /* @__PURE__ */ S(f, {
|
|
70
|
-
onSubmit: ne,
|
|
43
|
+
E === "top" && /* @__PURE__ */ S(b, { children: [!!I?.length && /* @__PURE__ */ x(t, { socialLayout: T }), K && /* @__PURE__ */ x(e, { children: N.auth.or })] }),
|
|
44
|
+
M?.enabled && /* @__PURE__ */ S(d, {
|
|
45
|
+
onSubmit: W,
|
|
71
46
|
className: "flex flex-col gap-4",
|
|
72
47
|
children: [
|
|
73
|
-
/* @__PURE__ */ S(
|
|
48
|
+
/* @__PURE__ */ S(g, {
|
|
74
49
|
name: "email",
|
|
75
|
-
type:
|
|
76
|
-
autoComplete:
|
|
77
|
-
isDisabled:
|
|
50
|
+
type: "email",
|
|
51
|
+
autoComplete: "email",
|
|
52
|
+
isDisabled: G,
|
|
78
53
|
children: [
|
|
79
|
-
/* @__PURE__ */ x(
|
|
80
|
-
/* @__PURE__ */ x(
|
|
81
|
-
placeholder:
|
|
82
|
-
variant:
|
|
54
|
+
/* @__PURE__ */ x(p, { children: N.auth.email }),
|
|
55
|
+
/* @__PURE__ */ x(f, {
|
|
56
|
+
placeholder: N.auth.emailPlaceholder,
|
|
57
|
+
variant: D === "transparent" ? "primary" : "secondary",
|
|
83
58
|
required: !0
|
|
84
59
|
}),
|
|
85
|
-
/* @__PURE__ */ x(
|
|
60
|
+
/* @__PURE__ */ x(u, {})
|
|
86
61
|
]
|
|
87
62
|
}),
|
|
88
|
-
/* @__PURE__ */ S(
|
|
63
|
+
/* @__PURE__ */ S(g, {
|
|
89
64
|
minLength: M?.minPasswordLength,
|
|
90
65
|
maxLength: M?.maxPasswordLength,
|
|
91
66
|
name: "password",
|
|
92
67
|
type: "password",
|
|
93
68
|
autoComplete: "current-password",
|
|
94
|
-
isDisabled:
|
|
95
|
-
value:
|
|
96
|
-
onChange:
|
|
69
|
+
isDisabled: G,
|
|
70
|
+
value: z,
|
|
71
|
+
onChange: B,
|
|
97
72
|
children: [
|
|
98
|
-
/* @__PURE__ */ x(
|
|
99
|
-
/* @__PURE__ */ x(
|
|
73
|
+
/* @__PURE__ */ x(p, { children: N.auth.password }),
|
|
74
|
+
/* @__PURE__ */ x(f, {
|
|
100
75
|
placeholder: N.auth.passwordPlaceholder,
|
|
101
|
-
variant:
|
|
76
|
+
variant: D === "transparent" ? "primary" : "secondary",
|
|
102
77
|
required: !0
|
|
103
78
|
}),
|
|
104
|
-
/* @__PURE__ */ x(
|
|
79
|
+
/* @__PURE__ */ x(u, {})
|
|
105
80
|
]
|
|
106
81
|
}),
|
|
107
|
-
M?.rememberMe && /* @__PURE__ */ S(
|
|
82
|
+
M?.rememberMe && /* @__PURE__ */ S(c, {
|
|
108
83
|
name: "rememberMe",
|
|
109
|
-
isDisabled:
|
|
110
|
-
variant:
|
|
111
|
-
children: [/* @__PURE__ */ x(
|
|
84
|
+
isDisabled: G,
|
|
85
|
+
variant: D === "transparent" ? "primary" : "secondary",
|
|
86
|
+
children: [/* @__PURE__ */ x(c.Control, { children: /* @__PURE__ */ x(c.Indicator, {}) }), /* @__PURE__ */ x(c.Content, { children: /* @__PURE__ */ x(p, { children: N.auth.rememberMe }) })]
|
|
112
87
|
}),
|
|
113
88
|
/* @__PURE__ */ S("div", {
|
|
114
89
|
className: "flex flex-col gap-3",
|
|
115
|
-
children: [
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}),
|
|
125
|
-
P && /* @__PURE__ */ x(t, {
|
|
126
|
-
view: "signIn",
|
|
127
|
-
isPending: Q
|
|
128
|
-
}),
|
|
129
|
-
F && /* @__PURE__ */ x(n, { isPending: Q })
|
|
130
|
-
]
|
|
90
|
+
children: [/* @__PURE__ */ S(o, {
|
|
91
|
+
type: "submit",
|
|
92
|
+
className: "w-full",
|
|
93
|
+
isPending: G,
|
|
94
|
+
children: [U && /* @__PURE__ */ x(h, {
|
|
95
|
+
color: "current",
|
|
96
|
+
size: "sm"
|
|
97
|
+
}), N.auth.signIn]
|
|
98
|
+
}), P.flatMap((e) => e.authButtons?.map((t, n) => /* @__PURE__ */ x(t, { view: "signIn" }, `${e.id}-${n.toString()}`)))]
|
|
131
99
|
})
|
|
132
100
|
]
|
|
133
101
|
}),
|
|
134
|
-
|
|
135
|
-
socialLayout: E,
|
|
136
|
-
signInSocial: X,
|
|
137
|
-
isPending: Q
|
|
138
|
-
})] })
|
|
102
|
+
E === "bottom" && /* @__PURE__ */ S(b, { children: [K && /* @__PURE__ */ x(e, { children: N.auth.or }), !!I?.length && /* @__PURE__ */ x(t, { socialLayout: T })] })
|
|
139
103
|
]
|
|
140
104
|
}),
|
|
141
|
-
/* @__PURE__ */ S(
|
|
105
|
+
/* @__PURE__ */ S(s.Footer, {
|
|
142
106
|
className: "flex-col gap-3",
|
|
143
|
-
children: [M?.forgotPassword && /* @__PURE__ */ x(
|
|
144
|
-
href: `${A.auth}/${
|
|
107
|
+
children: [M?.forgotPassword && /* @__PURE__ */ x(m, {
|
|
108
|
+
href: `${A.auth}/${L.auth.forgotPassword}`,
|
|
145
109
|
className: "no-underline hover:underline",
|
|
146
110
|
children: N.auth.forgotPasswordLink
|
|
147
|
-
}), M?.enabled && /* @__PURE__ */ S(
|
|
111
|
+
}), M?.enabled && /* @__PURE__ */ S(l, {
|
|
148
112
|
className: "text-sm",
|
|
149
113
|
children: [
|
|
150
114
|
N.auth.needToCreateAnAccount,
|
|
151
115
|
" ",
|
|
152
|
-
/* @__PURE__ */ x(
|
|
153
|
-
href: `${A.auth}/${
|
|
116
|
+
/* @__PURE__ */ x(m, {
|
|
117
|
+
href: `${A.auth}/${L.auth.signUp}`,
|
|
154
118
|
className: "text-accent no-underline hover:underline decoration-accent-hover",
|
|
155
119
|
children: N.auth.signUp
|
|
156
120
|
})
|
|
@@ -161,4 +125,4 @@ function T({ className: T, socialLayout: E, socialPosition: D = "bottom", varian
|
|
|
161
125
|
});
|
|
162
126
|
}
|
|
163
127
|
//#endregion
|
|
164
|
-
export {
|
|
128
|
+
export { w as SignIn };
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { useAuth as e, useSignOut as t } from "@better-auth-ui/react";
|
|
2
2
|
import { Spinner as n, cn as r, toast as i } from "@heroui/react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { useEffect as a, useRef as o } from "react";
|
|
4
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
5
5
|
//#region src/components/auth/sign-out.tsx
|
|
6
6
|
function c({ className: c }) {
|
|
7
|
-
let {
|
|
7
|
+
let { authClient: l, basePaths: u, navigate: d, viewPaths: f } = e(), { mutate: p } = t(l, {
|
|
8
8
|
onError: (e) => {
|
|
9
|
-
i.danger(e.error?.message || e.message),
|
|
10
|
-
to: `${
|
|
9
|
+
i.danger(e.error?.message || e.message), d({
|
|
10
|
+
to: `${u.auth}/${f.auth.signIn}`,
|
|
11
11
|
replace: !0
|
|
12
12
|
});
|
|
13
13
|
},
|
|
14
|
-
onSuccess: () =>
|
|
15
|
-
to: `${
|
|
14
|
+
onSuccess: () => d({
|
|
15
|
+
to: `${u.auth}/${f.auth.signIn}`,
|
|
16
16
|
replace: !0
|
|
17
17
|
})
|
|
18
|
-
}),
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
}, [
|
|
18
|
+
}), m = o(!1);
|
|
19
|
+
return a(() => {
|
|
20
|
+
m.current || (m.current = !0, p());
|
|
21
|
+
}, [p]), /* @__PURE__ */ s(n, {
|
|
22
22
|
className: r("mx-auto my-auto", c),
|
|
23
23
|
color: "current"
|
|
24
24
|
});
|
|
@@ -16,4 +16,4 @@ export type SignUpProps = {
|
|
|
16
16
|
* @param socialPosition - Position of social provider buttons relative to the form; `"top"` or `"bottom"` (default `"bottom"`)
|
|
17
17
|
* @returns The sign-up form React element
|
|
18
18
|
*/
|
|
19
|
-
export declare function SignUp({ className, socialLayout, socialPosition, variant, ...props }: SignUpProps & CardProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare function SignUp({ className, socialLayout, socialPosition, variant, ...props }: SignUpProps & Omit<CardProps, "children">): import("react/jsx-runtime").JSX.Element;
|