@better-auth-ui/heroui 1.6.1 → 1.6.3
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/auth-provider.d.ts +1 -1
- package/dist/components/auth/auth-provider.js +16 -11
- package/dist/components/auth/auth.d.ts +4 -4
- package/dist/components/auth/auth.js +36 -41
- package/dist/components/auth/error-toaster.d.ts +1 -0
- package/dist/components/auth/error-toaster.js +17 -0
- package/dist/components/auth/field-separator.d.ts +1 -1
- package/dist/components/auth/field-separator.js +17 -4
- package/dist/components/auth/forgot-password.d.ts +2 -2
- package/dist/components/auth/forgot-password.js +66 -27
- package/dist/components/auth/magic-link-button.d.ts +1 -1
- package/dist/components/auth/magic-link-button.js +15 -18
- package/dist/components/auth/magic-link.d.ts +3 -3
- package/dist/components/auth/magic-link.js +98 -43
- package/dist/components/auth/passkey-button.js +20 -12
- package/dist/components/auth/provider-button.d.ts +15 -0
- package/dist/components/auth/provider-button.js +29 -0
- package/dist/components/auth/provider-buttons.d.ts +4 -10
- package/dist/components/auth/provider-buttons.js +19 -33
- package/dist/components/auth/reset-password.d.ts +2 -2
- package/dist/components/auth/reset-password.js +143 -57
- package/dist/components/auth/sign-in.d.ts +3 -3
- package/dist/components/auth/sign-in.js +151 -64
- package/dist/components/auth/sign-out.js +26 -32
- package/dist/components/auth/sign-up.d.ts +3 -3
- package/dist/components/auth/sign-up.js +231 -70
- package/dist/components/email/email-changed-email.d.ts +2 -2
- package/dist/components/email/email-changed-email.js +29 -22
- package/dist/components/email/email-verification-email.d.ts +2 -2
- package/dist/components/email/email-verification-email.js +29 -22
- package/dist/components/email/magic-link-email.d.ts +2 -2
- package/dist/components/email/magic-link-email.js +29 -22
- package/dist/components/email/new-device-email.d.ts +2 -2
- package/dist/components/email/new-device-email.js +29 -22
- package/dist/components/email/otp-email.d.ts +2 -2
- package/dist/components/email/otp-email.js +28 -21
- package/dist/components/email/password-changed-email.d.ts +2 -2
- package/dist/components/email/password-changed-email.js +29 -22
- package/dist/components/email/reset-password-email.d.ts +2 -2
- package/dist/components/email/reset-password-email.js +29 -22
- package/dist/components/settings/account/account-settings.d.ts +2 -2
- package/dist/components/settings/account/account-settings.js +22 -19
- package/dist/components/settings/account/appearance.d.ts +2 -2
- package/dist/components/settings/account/appearance.js +70 -27
- package/dist/components/settings/account/change-avatar.js +88 -55
- package/dist/components/settings/account/change-email.d.ts +2 -2
- package/dist/components/settings/account/change-email.js +53 -28
- package/dist/components/settings/account/manage-account.d.ts +1 -1
- package/dist/components/settings/account/manage-account.js +47 -31
- package/dist/components/settings/account/manage-accounts.d.ts +2 -2
- package/dist/components/settings/account/manage-accounts.js +32 -36
- package/dist/components/settings/account/user-profile.d.ts +4 -4
- package/dist/components/settings/account/user-profile.js +102 -22
- package/dist/components/settings/security/active-session.d.ts +1 -1
- package/dist/components/settings/security/active-session.js +57 -51
- package/dist/components/settings/security/active-sessions.d.ts +2 -2
- package/dist/components/settings/security/active-sessions.js +32 -26
- package/dist/components/settings/security/change-password.d.ts +2 -2
- package/dist/components/settings/security/change-password.js +186 -76
- package/dist/components/settings/security/danger-zone.d.ts +2 -2
- package/dist/components/settings/security/danger-zone.js +17 -11
- package/dist/components/settings/security/delete-user.d.ts +2 -2
- package/dist/components/settings/security/delete-user.js +91 -46
- package/dist/components/settings/security/linked-account.d.ts +1 -1
- package/dist/components/settings/security/linked-account.js +55 -47
- package/dist/components/settings/security/linked-accounts.d.ts +2 -2
- package/dist/components/settings/security/linked-accounts.js +43 -40
- package/dist/components/settings/security/passkey.js +42 -13
- package/dist/components/settings/security/passkeys.d.ts +2 -2
- package/dist/components/settings/security/passkeys.js +51 -19
- package/dist/components/settings/security/security-settings.d.ts +2 -2
- package/dist/components/settings/security/security-settings.js +24 -21
- package/dist/components/settings/settings.d.ts +3 -3
- package/dist/components/settings/settings.js +44 -27
- package/dist/components/user/switch-account-item.d.ts +1 -1
- package/dist/components/user/switch-account-item.js +19 -15
- package/dist/components/user/switch-account-menu.js +27 -28
- package/dist/components/user/user-avatar.d.ts +3 -3
- package/dist/components/user/user-avatar.js +28 -30
- package/dist/components/user/user-button.d.ts +1 -1
- package/dist/components/user/user-button.js +90 -23
- package/dist/components/user/user-view.d.ts +3 -3
- package/dist/components/user/user-view.js +36 -23
- package/dist/core.d.ts +1 -1
- package/dist/index.d.ts +36 -35
- package/dist/index.js +37 -35
- package/dist/react-exports.d.ts +1 -1
- package/package.json +15 -11
- package/src/components/auth/auth-provider.tsx +4 -0
- package/src/components/auth/auth.tsx +2 -2
- package/src/components/auth/error-toaster.tsx +25 -0
- package/src/components/auth/forgot-password.tsx +1 -2
- package/src/components/auth/magic-link.tsx +3 -23
- package/src/components/auth/passkey-button.tsx +1 -2
- package/src/components/auth/provider-button.tsx +67 -0
- package/src/components/auth/provider-buttons.tsx +26 -43
- package/src/components/auth/reset-password.tsx +1 -2
- package/src/components/auth/sign-in.tsx +63 -48
- package/src/components/auth/sign-up.tsx +99 -20
- package/src/components/settings/account/appearance.tsx +1 -1
- package/src/components/settings/account/change-avatar.tsx +1 -3
- package/src/components/settings/account/change-email.tsx +2 -3
- package/src/components/settings/account/manage-account.tsx +1 -4
- package/src/components/settings/account/manage-accounts.tsx +3 -8
- package/src/components/settings/account/user-profile.tsx +122 -8
- package/src/components/settings/security/active-session.tsx +0 -1
- package/src/components/settings/security/active-sessions.tsx +3 -8
- package/src/components/settings/security/change-password.tsx +7 -4
- package/src/components/settings/security/delete-user.tsx +1 -4
- package/src/components/settings/security/linked-account.tsx +4 -14
- package/src/components/settings/security/linked-accounts.tsx +3 -8
- package/src/components/settings/security/passkey.tsx +2 -4
- package/src/components/settings/security/passkeys.tsx +4 -12
- package/src/components/settings/settings.tsx +1 -1
- package/src/components/user/switch-account-item.tsx +2 -4
- package/src/components/user/switch-account-menu.tsx +2 -7
- package/src/index.tsx +1 -0
|
@@ -1,32 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useAuth, useRevokeMultiSession, useSetActiveSession, useUser } from "@better-auth-ui/react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import { UserView as e } from "../../user/user-view.js";
|
|
2
|
+
import { useAuth as t, useRevokeMultiSession as n, useSetActiveSession as r, useUser as i } from "@better-auth-ui/react";
|
|
3
|
+
import { Button as a, Dropdown as o, Spinner as s, toast as c } from "@heroui/react";
|
|
4
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
5
|
+
import { ArrowRightArrowLeft as d, ArrowRightFromSquare as f, Ellipsis as p } from "@gravity-ui/icons";
|
|
6
|
+
//#region src/components/settings/account/manage-account.tsx
|
|
7
|
+
function m({ deviceSession: m, isPending: h }) {
|
|
8
|
+
let { localization: g } = t(), { data: _ } = i(), { mutate: v, isPending: y } = r(), { mutate: b, isPending: x } = n({ onSuccess: () => c.success(g.settings.revokeSessionSuccess) }), S = m?.session.userId === _?.id, C = y || x;
|
|
9
|
+
return /* @__PURE__ */ u("div", {
|
|
10
|
+
className: "flex items-center justify-between gap-3",
|
|
11
|
+
children: [
|
|
12
|
+
/* @__PURE__ */ l(e, {
|
|
13
|
+
user: m?.user,
|
|
14
|
+
isPending: h,
|
|
15
|
+
size: "md"
|
|
16
|
+
}),
|
|
17
|
+
m && S && /* @__PURE__ */ u(a, {
|
|
18
|
+
className: "shrink-0",
|
|
19
|
+
variant: "outline",
|
|
20
|
+
size: "sm",
|
|
21
|
+
onPress: () => b({ sessionToken: m.session.token }),
|
|
22
|
+
isDisabled: C,
|
|
23
|
+
children: [x ? /* @__PURE__ */ l(s, {
|
|
24
|
+
color: "current",
|
|
25
|
+
size: "sm"
|
|
26
|
+
}) : /* @__PURE__ */ l(f, {}), g.auth.signOut]
|
|
27
|
+
}),
|
|
28
|
+
m && !S && /* @__PURE__ */ u(o, { children: [/* @__PURE__ */ l(a, {
|
|
29
|
+
isIconOnly: !0,
|
|
30
|
+
variant: "ghost",
|
|
31
|
+
className: "shrink-0",
|
|
32
|
+
size: "sm",
|
|
33
|
+
isDisabled: C,
|
|
34
|
+
children: /* @__PURE__ */ l(p, {})
|
|
35
|
+
}), /* @__PURE__ */ l(o.Popover, { children: /* @__PURE__ */ u(o.Menu, { children: [/* @__PURE__ */ u(o.Item, {
|
|
36
|
+
textValue: g.auth.switchAccount,
|
|
37
|
+
onAction: () => v({ sessionToken: m.session.token }),
|
|
38
|
+
children: [/* @__PURE__ */ l(d, { className: "text-muted" }), g.auth.switchAccount]
|
|
39
|
+
}), /* @__PURE__ */ u(o.Item, {
|
|
40
|
+
textValue: g.auth.signOut,
|
|
41
|
+
onAction: () => b({ sessionToken: m.session.token }),
|
|
42
|
+
children: [/* @__PURE__ */ l(f, { className: "text-muted" }), g.auth.signOut]
|
|
43
|
+
})] }) })] })
|
|
44
|
+
]
|
|
45
|
+
});
|
|
32
46
|
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { m as ManageAccount };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CardProps } from '@heroui/react';
|
|
2
2
|
export type ManageAccountsProps = {
|
|
3
3
|
className?: string;
|
|
4
4
|
variant?: CardProps["variant"];
|
|
@@ -11,4 +11,4 @@ export type ManageAccountsProps = {
|
|
|
11
11
|
*
|
|
12
12
|
* @returns A JSX element containing the accounts management card
|
|
13
13
|
*/
|
|
14
|
-
export declare function ManageAccounts({ className, variant, ...props }: ManageAccountsProps & CardProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function ManageAccounts({ className, variant, ...props }: ManageAccountsProps & Omit<CardProps, "children">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,37 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useAuth, useListDeviceSessions, useSession } from "@better-auth-ui/react";
|
|
3
|
-
import { Card, cn
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
key: deviceSession.session.id,
|
|
32
|
-
deviceSession,
|
|
33
|
-
isPending: false
|
|
34
|
-
})) ?? [])
|
|
35
|
-
];
|
|
36
|
-
return (_jsxs("div", { children: [_jsx("h2", { className: cn("text-sm font-semibold mb-3"), children: localization.settings.manageAccounts }), _jsx(Card, { className: cn(className), variant: variant, ...props, children: _jsx(Card.Content, { className: "gap-0", children: allRows.map((row, index) => (_jsxs("div", { children: [index > 0 && (_jsx("div", { className: "border-b border-dashed -mx-4 md:-mx-6 my-4" })), _jsx(ManageAccount, { deviceSession: row.deviceSession, isPending: row.isPending })] }, row.key))) }) })] }));
|
|
1
|
+
import { ManageAccount as e } from "./manage-account.js";
|
|
2
|
+
import { useAuth as t, useListDeviceSessions as n, useSession as r } from "@better-auth-ui/react";
|
|
3
|
+
import { Card as i, cn as a } from "@heroui/react";
|
|
4
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/settings/account/manage-accounts.tsx
|
|
6
|
+
function c({ className: c, variant: l, ...u }) {
|
|
7
|
+
let { localization: d } = t(), { data: f } = r(), { data: p, isPending: m } = n(), h = p?.filter((e) => e.session.id !== f?.session.id), g = [{
|
|
8
|
+
key: "current",
|
|
9
|
+
deviceSession: m ? null : f,
|
|
10
|
+
isPending: m
|
|
11
|
+
}, ...h?.map((e) => ({
|
|
12
|
+
key: e.session.id,
|
|
13
|
+
deviceSession: e,
|
|
14
|
+
isPending: !1
|
|
15
|
+
})) ?? []];
|
|
16
|
+
return /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("h2", {
|
|
17
|
+
className: a("text-sm font-semibold mb-3"),
|
|
18
|
+
children: d.settings.manageAccounts
|
|
19
|
+
}), /* @__PURE__ */ o(i, {
|
|
20
|
+
className: a(c),
|
|
21
|
+
variant: l,
|
|
22
|
+
...u,
|
|
23
|
+
children: /* @__PURE__ */ o(i.Content, {
|
|
24
|
+
className: "gap-0",
|
|
25
|
+
children: 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
|
+
deviceSession: t.deviceSession,
|
|
27
|
+
isPending: t.isPending
|
|
28
|
+
})] }, t.key))
|
|
29
|
+
})
|
|
30
|
+
})] });
|
|
37
31
|
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { c as ManageAccounts };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CardProps } from '@heroui/react';
|
|
2
2
|
export type UserProfileProps = {
|
|
3
3
|
className?: string;
|
|
4
4
|
variant?: CardProps["variant"];
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
7
|
-
* Render a profile card that lets the authenticated user view and update their display name and avatar.
|
|
7
|
+
* Render a profile card that lets the authenticated user view and update their display name, username, and avatar.
|
|
8
8
|
*
|
|
9
|
-
* @returns A JSX element containing the user profile card with avatar upload and
|
|
9
|
+
* @returns A JSX element containing the user profile card with avatar upload and editable form fields
|
|
10
10
|
*/
|
|
11
|
-
export declare function UserProfile({ className, variant, ...props }: UserProfileProps & CardProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function UserProfile({ className, variant, ...props }: UserProfileProps & Omit<CardProps, "children">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,23 +1,103 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useAuth, useSession, useUpdateUser } from "@better-auth-ui/react";
|
|
3
|
-
import { Button, Card
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { ChangeAvatar as e } from "./change-avatar.js";
|
|
2
|
+
import { useAuth as t, useIsUsernameAvailable as n, useSession as r, useUpdateUser as i } from "@better-auth-ui/react";
|
|
3
|
+
import { Button as a, Card as o, FieldError as s, Fieldset as c, Form as l, Input as u, InputGroup as d, Label as f, Skeleton as p, Spinner as m, TextField as h, cn as g, toast as _ } from "@heroui/react";
|
|
4
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
5
|
+
import { useEffect as b, useState as x } from "react";
|
|
6
|
+
import { Check as S, Xmark as C } from "@gravity-ui/icons";
|
|
7
|
+
import { useDebouncer as w } from "@tanstack/react-pacer";
|
|
8
|
+
//#region src/components/settings/account/user-profile.tsx
|
|
9
|
+
function T({ className: T, variant: E, ...D }) {
|
|
10
|
+
let { localization: O, username: k } = t(), { data: A } = r(), j = (k?.displayUsername ? A?.user?.displayUsername : A?.user?.username) || "", [M, N] = x(j);
|
|
11
|
+
b(() => {
|
|
12
|
+
N(j);
|
|
13
|
+
}, [j]);
|
|
14
|
+
let { mutate: P, data: F, error: I, reset: L } = n(), R = w((e) => {
|
|
15
|
+
if (!e.trim() || e.trim() === j) {
|
|
16
|
+
L();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
P({ username: e.trim() });
|
|
20
|
+
}, { wait: 500 });
|
|
21
|
+
function z(e) {
|
|
22
|
+
N(e), L(), k?.isUsernameAvailable && R.maybeExecute(e);
|
|
23
|
+
}
|
|
24
|
+
let { mutate: B, isPending: V } = i({ onSuccess: () => _.success(O.settings.profileUpdatedSuccess) });
|
|
25
|
+
function H(e) {
|
|
26
|
+
e.preventDefault(), B({
|
|
27
|
+
name: new FormData(e.currentTarget).get("name"),
|
|
28
|
+
...k?.enabled ? {
|
|
29
|
+
username: M.trim(),
|
|
30
|
+
...k.displayUsername ? { displayUsername: M.trim() } : {}
|
|
31
|
+
} : {}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return /* @__PURE__ */ y("div", { children: [/* @__PURE__ */ v("h2", {
|
|
35
|
+
className: g("text-sm font-semibold mb-3"),
|
|
36
|
+
children: O.settings.profile
|
|
37
|
+
}), /* @__PURE__ */ v(o, {
|
|
38
|
+
className: g("p-4 gap-4", T),
|
|
39
|
+
variant: E,
|
|
40
|
+
...D,
|
|
41
|
+
children: /* @__PURE__ */ v(o.Content, { children: /* @__PURE__ */ v(l, {
|
|
42
|
+
onSubmit: H,
|
|
43
|
+
children: /* @__PURE__ */ y(c, {
|
|
44
|
+
className: "w-full gap-4",
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ v(e, {}),
|
|
47
|
+
/* @__PURE__ */ y(c.Group, { children: [k?.enabled && /* @__PURE__ */ y(h, {
|
|
48
|
+
type: "text",
|
|
49
|
+
autoComplete: "username",
|
|
50
|
+
minLength: k.minUsernameLength,
|
|
51
|
+
maxLength: k.maxUsernameLength,
|
|
52
|
+
isDisabled: V || !A,
|
|
53
|
+
value: M,
|
|
54
|
+
onChange: z,
|
|
55
|
+
isInvalid: !!I || F && !F.available,
|
|
56
|
+
children: [
|
|
57
|
+
/* @__PURE__ */ v(f, { children: O.auth.username }),
|
|
58
|
+
A ? /* @__PURE__ */ y(d, {
|
|
59
|
+
variant: E === "transparent" ? "primary" : "secondary",
|
|
60
|
+
children: [/* @__PURE__ */ v(d.Input, {
|
|
61
|
+
placeholder: O.auth.usernamePlaceholder,
|
|
62
|
+
name: "username"
|
|
63
|
+
}), k.isUsernameAvailable && M.trim() && M.trim() !== j && /* @__PURE__ */ v(d.Suffix, {
|
|
64
|
+
className: "px-2",
|
|
65
|
+
children: F?.available ? /* @__PURE__ */ v(S, { className: "text-success" }) : I || F?.available === !1 ? /* @__PURE__ */ v(C, { className: "text-danger" }) : /* @__PURE__ */ v(m, {
|
|
66
|
+
size: "sm",
|
|
67
|
+
color: "current"
|
|
68
|
+
})
|
|
69
|
+
})]
|
|
70
|
+
}) : /* @__PURE__ */ v(p, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
71
|
+
/* @__PURE__ */ v(s, { children: I?.error?.message || I?.message || F?.available === !1 && O.auth.usernameTaken })
|
|
72
|
+
]
|
|
73
|
+
}), /* @__PURE__ */ y(h, {
|
|
74
|
+
name: "name",
|
|
75
|
+
defaultValue: A?.user.name,
|
|
76
|
+
isDisabled: V || !A,
|
|
77
|
+
children: [
|
|
78
|
+
/* @__PURE__ */ v(f, { children: O.auth.name }),
|
|
79
|
+
A ? /* @__PURE__ */ v(u, {
|
|
80
|
+
autoComplete: "name",
|
|
81
|
+
placeholder: O.auth.name,
|
|
82
|
+
variant: E === "transparent" ? "primary" : "secondary"
|
|
83
|
+
}) : /* @__PURE__ */ v(p, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
84
|
+
/* @__PURE__ */ v(s, {})
|
|
85
|
+
]
|
|
86
|
+
}, A?.user?.name)] }),
|
|
87
|
+
/* @__PURE__ */ v(c.Actions, { children: /* @__PURE__ */ y(a, {
|
|
88
|
+
type: "submit",
|
|
89
|
+
isPending: V,
|
|
90
|
+
isDisabled: !A,
|
|
91
|
+
size: "sm",
|
|
92
|
+
children: [V && /* @__PURE__ */ v(m, {
|
|
93
|
+
color: "current",
|
|
94
|
+
size: "sm"
|
|
95
|
+
}), O.settings.saveChanges]
|
|
96
|
+
}) })
|
|
97
|
+
]
|
|
98
|
+
})
|
|
99
|
+
}) })
|
|
100
|
+
})] });
|
|
23
101
|
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { T as UserProfile };
|
|
@@ -1,53 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (seconds >= threshold) {
|
|
20
|
-
return rtf.format(-Math.floor(seconds / threshold), unit);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return rtf.format(0, "second");
|
|
1
|
+
import { useAuth as e, useRevokeSession as t, useSession as n } from "@better-auth-ui/react";
|
|
2
|
+
import { Button as r, Chip as i, Spinner as a, toast as o } from "@heroui/react";
|
|
3
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
4
|
+
import { ArrowRightFromSquare as l, Display as u, Smartphone as d, Xmark as f } from "@gravity-ui/icons";
|
|
5
|
+
import p from "bowser";
|
|
6
|
+
//#region src/components/settings/security/active-session.tsx
|
|
7
|
+
function m(e) {
|
|
8
|
+
let t = Math.floor((Date.now() - e.getTime()) / 1e3), n = new Intl.RelativeTimeFormat(void 0, { numeric: "auto" });
|
|
9
|
+
for (let [e, r] of [
|
|
10
|
+
["year", 31536e3],
|
|
11
|
+
["month", 2592e3],
|
|
12
|
+
["week", 604800],
|
|
13
|
+
["day", 86400],
|
|
14
|
+
["hour", 3600],
|
|
15
|
+
["minute", 60],
|
|
16
|
+
["second", 1]
|
|
17
|
+
]) if (t >= r) return n.format(-Math.floor(t / r), e);
|
|
18
|
+
return n.format(0, "second");
|
|
24
19
|
}
|
|
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
|
-
|
|
20
|
+
function h({ activeSession: h }) {
|
|
21
|
+
let { basePaths: g, localization: _, viewPaths: v, navigate: y } = e(), { data: b } = n({ refetchOnMount: !1 }), { mutate: x, isPending: S } = t({ onSuccess: () => o.success(_.settings.revokeSessionSuccess) }), C = h.token === b?.session.token, w = p.parse(h.userAgent || "");
|
|
22
|
+
return /* @__PURE__ */ c("div", {
|
|
23
|
+
className: "flex items-center gap-3",
|
|
24
|
+
children: [
|
|
25
|
+
/* @__PURE__ */ s("div", {
|
|
26
|
+
className: "flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-secondary",
|
|
27
|
+
children: w.platform.type === "mobile" || w.platform.type === "tablet" ? /* @__PURE__ */ s(d, { className: "size-4.5" }) : /* @__PURE__ */ s(u, { className: "size-4.5" })
|
|
28
|
+
}),
|
|
29
|
+
/* @__PURE__ */ c("div", {
|
|
30
|
+
className: "flex flex-col min-w-0",
|
|
31
|
+
children: [/* @__PURE__ */ c("span", {
|
|
32
|
+
className: "text-sm font-medium truncate",
|
|
33
|
+
children: [w.browser.name || "Unknown Browser", w.os.name ? `, ${w.os.name}` : ""]
|
|
34
|
+
}), C ? /* @__PURE__ */ s(i, {
|
|
35
|
+
color: "accent",
|
|
36
|
+
size: "sm",
|
|
37
|
+
children: _.settings.currentSession
|
|
38
|
+
}) : h.createdAt && /* @__PURE__ */ s("span", {
|
|
39
|
+
className: "text-xs text-muted capitalize",
|
|
40
|
+
children: m(h.createdAt)
|
|
41
|
+
})]
|
|
42
|
+
}),
|
|
43
|
+
/* @__PURE__ */ c(r, {
|
|
44
|
+
className: "ml-auto shrink-0",
|
|
45
|
+
variant: "outline",
|
|
46
|
+
size: "sm",
|
|
47
|
+
onPress: () => C ? y({ to: `${g.auth}/${v.auth.signOut}` }) : x(h),
|
|
48
|
+
isPending: S,
|
|
49
|
+
"aria-label": C ? _.auth.signOut : _.settings.revokeSession,
|
|
50
|
+
children: [S ? /* @__PURE__ */ s(a, {
|
|
51
|
+
color: "current",
|
|
52
|
+
size: "sm"
|
|
53
|
+
}) : s(C ? l : f, {}), C ? _.auth.signOut : _.settings.revoke]
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
});
|
|
53
57
|
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export { h as ActiveSession };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CardProps } from '@heroui/react';
|
|
2
2
|
export type ActiveSessionsProps = {
|
|
3
3
|
className?: string;
|
|
4
4
|
variant?: CardProps["variant"];
|
|
@@ -11,4 +11,4 @@ export type ActiveSessionsProps = {
|
|
|
11
11
|
*
|
|
12
12
|
* @returns A JSX element containing the sessions card
|
|
13
13
|
*/
|
|
14
|
-
export declare function ActiveSessions({ className, variant, ...props }: ActiveSessionsProps & CardProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function ActiveSessions({ className, variant, ...props }: ActiveSessionsProps & Omit<CardProps, "children">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,28 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useAuth, useListSessions, useSession } from "@better-auth-ui/react";
|
|
3
|
-
import { Card
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const activeSessions = sessions?.toSorted((activeSession) => activeSession.id === session?.session.id ? -1 : 1);
|
|
24
|
-
return (_jsxs("div", { children: [_jsx("h2", { className: cn("text-sm font-semibold mb-3"), children: localization.settings.activeSessions }), _jsx(Card, { className: cn(className), variant: variant, ...props, children: _jsx(Card.Content, { className: "gap-0", children: isPending ? (_jsx(SessionRowSkeleton, {})) : (activeSessions?.map((activeSession, index) => (_jsxs("div", { children: [index > 0 && (_jsx("div", { className: "border-b border-dashed -mx-4 md:-mx-6 my-4" })), _jsx(ActiveSession, { activeSession: activeSession })] }, activeSession.id)))) }) })] }));
|
|
1
|
+
import { ActiveSession as e } from "./active-session.js";
|
|
2
|
+
import { useAuth as t, useListSessions as n, useSession as r } from "@better-auth-ui/react";
|
|
3
|
+
import { Card as i, Skeleton as a, cn as o } from "@heroui/react";
|
|
4
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/settings/security/active-sessions.tsx
|
|
6
|
+
function l({ className: a, variant: l, ...d }) {
|
|
7
|
+
let { localization: f } = t(), { data: p } = r(), { data: m, isPending: h } = n(), g = m?.toSorted((e) => e.id === p?.session.id ? -1 : 1);
|
|
8
|
+
return /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("h2", {
|
|
9
|
+
className: o("text-sm font-semibold mb-3"),
|
|
10
|
+
children: f.settings.activeSessions
|
|
11
|
+
}), /* @__PURE__ */ s(i, {
|
|
12
|
+
className: o(a),
|
|
13
|
+
variant: l,
|
|
14
|
+
...d,
|
|
15
|
+
children: /* @__PURE__ */ s(i.Content, {
|
|
16
|
+
className: "gap-0",
|
|
17
|
+
children: h ? /* @__PURE__ */ s(u, {}) : g?.map((t, n) => /* @__PURE__ */ c("div", { children: [n > 0 && /* @__PURE__ */ s("div", { className: "border-b border-dashed -mx-4 md:-mx-6 my-4" }), /* @__PURE__ */ s(e, { activeSession: t })] }, t.id))
|
|
18
|
+
})
|
|
19
|
+
})] });
|
|
25
20
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
21
|
+
function u() {
|
|
22
|
+
return /* @__PURE__ */ s("div", {
|
|
23
|
+
className: "flex items-center justify-between",
|
|
24
|
+
children: /* @__PURE__ */ c("div", {
|
|
25
|
+
className: "flex items-center gap-3",
|
|
26
|
+
children: [/* @__PURE__ */ s(a, { className: "size-10 rounded-xl" }), /* @__PURE__ */ c("div", {
|
|
27
|
+
className: "flex flex-col gap-1",
|
|
28
|
+
children: [/* @__PURE__ */ s(a, { className: "h-4 w-32 rounded-lg" }), /* @__PURE__ */ s(a, { className: "h-3 w-24 rounded-lg" })]
|
|
29
|
+
})]
|
|
30
|
+
})
|
|
31
|
+
});
|
|
28
32
|
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { l as ActiveSessions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CardProps } from '@heroui/react';
|
|
2
2
|
export type ChangePasswordProps = {
|
|
3
3
|
className?: string;
|
|
4
4
|
variant?: CardProps["variant"];
|
|
@@ -12,4 +12,4 @@ export type ChangePasswordProps = {
|
|
|
12
12
|
*
|
|
13
13
|
* @returns A JSX element containing the change-password or set-password card
|
|
14
14
|
*/
|
|
15
|
-
export declare function ChangePassword({ className, variant, ...props }: ChangePasswordProps & CardProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function ChangePassword({ className, variant, ...props }: ChangePasswordProps & Omit<CardProps, "children">): import("react/jsx-runtime").JSX.Element;
|