@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,79 +1,189 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return _jsx(SetPassword, { className: className, variant: variant, ...props });
|
|
22
|
-
}
|
|
23
|
-
return (_jsx(ChangePasswordForm, { className: className, variant: variant, emailAndPassword: emailAndPassword, localization: localization, session: isAccountsPending ? undefined : session, ...props }));
|
|
1
|
+
import { useAuth as e, useChangePassword as t, useListAccounts as n, useRequestPasswordReset as r, useSession as i } from "@better-auth-ui/react";
|
|
2
|
+
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";
|
|
3
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
4
|
+
import { useState as b } from "react";
|
|
5
|
+
import { Eye as x, EyeSlash as S } from "@gravity-ui/icons";
|
|
6
|
+
//#region src/components/settings/security/change-password.tsx
|
|
7
|
+
function C({ className: t, variant: r, ...a }) {
|
|
8
|
+
let { emailAndPassword: o, localization: s } = e(), { data: c } = i(), { data: l, isPending: u } = n(), d = l?.some((e) => e.providerId === "credential");
|
|
9
|
+
return !u && !d ? /* @__PURE__ */ v(w, {
|
|
10
|
+
className: t,
|
|
11
|
+
variant: r,
|
|
12
|
+
...a
|
|
13
|
+
}) : /* @__PURE__ */ v(T, {
|
|
14
|
+
className: t,
|
|
15
|
+
variant: r,
|
|
16
|
+
emailAndPassword: o,
|
|
17
|
+
localization: s,
|
|
18
|
+
session: u ? void 0 : c,
|
|
19
|
+
...a
|
|
20
|
+
});
|
|
24
21
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
22
|
+
function w({ className: t, variant: n, ...s }) {
|
|
23
|
+
let { localization: c } = e(), { data: l } = i(), { mutate: u, isPending: d } = r({ onSuccess: () => _.success(c.auth.passwordResetEmailSent) }), f = () => {
|
|
24
|
+
l?.user.email && u({ email: l.user.email });
|
|
25
|
+
};
|
|
26
|
+
return /* @__PURE__ */ y("div", { children: [/* @__PURE__ */ v("h2", {
|
|
27
|
+
className: g("text-sm font-semibold mb-3"),
|
|
28
|
+
children: c.settings.changePassword
|
|
29
|
+
}), /* @__PURE__ */ v(o, {
|
|
30
|
+
className: g(t),
|
|
31
|
+
variant: n,
|
|
32
|
+
...s,
|
|
33
|
+
children: /* @__PURE__ */ y(o.Content, {
|
|
34
|
+
className: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",
|
|
35
|
+
children: [/* @__PURE__ */ y("div", { children: [/* @__PURE__ */ v("p", {
|
|
36
|
+
className: "text-sm font-medium leading-tight",
|
|
37
|
+
children: c.settings.setPassword
|
|
38
|
+
}), /* @__PURE__ */ v("p", {
|
|
39
|
+
className: "text-muted text-xs mt-0.5",
|
|
40
|
+
children: c.settings.setPasswordDescription
|
|
41
|
+
})] }), /* @__PURE__ */ y(a, {
|
|
42
|
+
size: "sm",
|
|
43
|
+
isPending: d,
|
|
44
|
+
isDisabled: !l,
|
|
45
|
+
onPress: f,
|
|
46
|
+
children: [d && /* @__PURE__ */ v(m, {
|
|
47
|
+
color: "current",
|
|
48
|
+
size: "sm"
|
|
49
|
+
}), c.auth.sendResetLink]
|
|
50
|
+
})]
|
|
51
|
+
})
|
|
52
|
+
})] });
|
|
38
53
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
54
|
+
function T({ className: e, variant: n, emailAndPassword: r, localization: i, session: C, ...w }) {
|
|
55
|
+
let [T, E] = b(""), [D, O] = b(""), [k, A] = b(""), { mutate: j, isPending: M } = t({
|
|
56
|
+
onError: (e) => {
|
|
57
|
+
E(""), O(""), A(""), _.danger(e.error?.message || e.message);
|
|
58
|
+
},
|
|
59
|
+
onSuccess: () => {
|
|
60
|
+
E(""), O(""), A(""), _.success(i.settings.changePasswordSuccess);
|
|
61
|
+
}
|
|
62
|
+
}), [N, P] = b(!1), [F, I] = b(!1), L = (e) => {
|
|
63
|
+
if (e.preventDefault(), r?.confirmPassword && D !== k) {
|
|
64
|
+
E(""), O(""), A(""), _.danger(i.auth.passwordsDoNotMatch);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
j({
|
|
68
|
+
currentPassword: T,
|
|
69
|
+
newPassword: D,
|
|
70
|
+
revokeOtherSessions: !0
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
return /* @__PURE__ */ y("div", { children: [/* @__PURE__ */ v("h2", {
|
|
74
|
+
className: g("text-sm font-semibold mb-3"),
|
|
75
|
+
children: i.settings.changePassword
|
|
76
|
+
}), /* @__PURE__ */ v(o, {
|
|
77
|
+
className: g("p-4 gap-4", e),
|
|
78
|
+
variant: n,
|
|
79
|
+
...w,
|
|
80
|
+
children: /* @__PURE__ */ v(o.Content, { children: /* @__PURE__ */ v(l, {
|
|
81
|
+
onSubmit: L,
|
|
82
|
+
children: /* @__PURE__ */ y(c, {
|
|
83
|
+
className: "w-full gap-4",
|
|
84
|
+
children: [/* @__PURE__ */ y(c.Group, { children: [
|
|
85
|
+
/* @__PURE__ */ y(h, {
|
|
86
|
+
name: "currentPassword",
|
|
87
|
+
type: "password",
|
|
88
|
+
isDisabled: M || !C,
|
|
89
|
+
defaultValue: "",
|
|
90
|
+
value: T,
|
|
91
|
+
onChange: E,
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ v(f, { children: i.settings.currentPassword }),
|
|
94
|
+
/* @__PURE__ */ v(u, {
|
|
95
|
+
className: g(!C && "hidden"),
|
|
96
|
+
autoComplete: "current-password",
|
|
97
|
+
placeholder: i.settings.currentPasswordPlaceholder,
|
|
98
|
+
required: !0,
|
|
99
|
+
variant: n === "transparent" ? "primary" : "secondary"
|
|
100
|
+
}),
|
|
101
|
+
!C && /* @__PURE__ */ v(p, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
102
|
+
/* @__PURE__ */ v(s, {})
|
|
103
|
+
]
|
|
104
|
+
}),
|
|
105
|
+
/* @__PURE__ */ y(h, {
|
|
106
|
+
minLength: r?.minPasswordLength,
|
|
107
|
+
maxLength: r?.maxPasswordLength,
|
|
108
|
+
isDisabled: M || !C,
|
|
109
|
+
value: D,
|
|
110
|
+
onChange: O,
|
|
111
|
+
children: [
|
|
112
|
+
/* @__PURE__ */ v(f, { children: i.auth.newPassword }),
|
|
113
|
+
/* @__PURE__ */ y(d, {
|
|
114
|
+
className: g(!C && "hidden"),
|
|
115
|
+
variant: n === "transparent" ? "primary" : "secondary",
|
|
116
|
+
children: [/* @__PURE__ */ v(d.Input, {
|
|
117
|
+
name: "newPassword",
|
|
118
|
+
type: N ? "text" : "password",
|
|
119
|
+
autoComplete: "new-password",
|
|
120
|
+
placeholder: i.auth.newPasswordPlaceholder,
|
|
121
|
+
required: !0
|
|
122
|
+
}), /* @__PURE__ */ v(d.Suffix, {
|
|
123
|
+
className: "px-0",
|
|
124
|
+
children: /* @__PURE__ */ v(a, {
|
|
125
|
+
isIconOnly: !0,
|
|
126
|
+
"aria-label": N ? i.auth.hidePassword : i.auth.showPassword,
|
|
127
|
+
size: "sm",
|
|
128
|
+
variant: "ghost",
|
|
129
|
+
onPress: () => P(!N),
|
|
130
|
+
isDisabled: M,
|
|
131
|
+
children: v(N ? S : x, {})
|
|
132
|
+
})
|
|
133
|
+
})]
|
|
134
|
+
}),
|
|
135
|
+
!C && /* @__PURE__ */ v(p, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
136
|
+
/* @__PURE__ */ v(s, {})
|
|
137
|
+
]
|
|
138
|
+
}),
|
|
139
|
+
r?.confirmPassword && /* @__PURE__ */ y(h, {
|
|
140
|
+
minLength: r?.minPasswordLength,
|
|
141
|
+
maxLength: r?.maxPasswordLength,
|
|
142
|
+
isDisabled: M || !C,
|
|
143
|
+
isRequired: !0,
|
|
144
|
+
value: k,
|
|
145
|
+
onChange: A,
|
|
146
|
+
children: [
|
|
147
|
+
/* @__PURE__ */ v(f, { children: i.auth.confirmPassword }),
|
|
148
|
+
/* @__PURE__ */ y(d, {
|
|
149
|
+
className: g(!C && "hidden"),
|
|
150
|
+
variant: n === "transparent" ? "primary" : "secondary",
|
|
151
|
+
children: [/* @__PURE__ */ v(d.Input, {
|
|
152
|
+
name: "confirmPassword",
|
|
153
|
+
type: F ? "text" : "password",
|
|
154
|
+
autoComplete: "new-password",
|
|
155
|
+
placeholder: i.auth.confirmPasswordPlaceholder,
|
|
156
|
+
required: !0
|
|
157
|
+
}), /* @__PURE__ */ v(d.Suffix, {
|
|
158
|
+
className: "px-0",
|
|
159
|
+
children: /* @__PURE__ */ v(a, {
|
|
160
|
+
isIconOnly: !0,
|
|
161
|
+
"aria-label": F ? i.auth.hidePassword : i.auth.showPassword,
|
|
162
|
+
size: "sm",
|
|
163
|
+
variant: "ghost",
|
|
164
|
+
onPress: () => I(!F),
|
|
165
|
+
isDisabled: M,
|
|
166
|
+
children: v(F ? S : x, {})
|
|
167
|
+
})
|
|
168
|
+
})]
|
|
169
|
+
}),
|
|
170
|
+
!C && /* @__PURE__ */ v(p, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
171
|
+
/* @__PURE__ */ v(s, {})
|
|
172
|
+
]
|
|
173
|
+
})
|
|
174
|
+
] }), /* @__PURE__ */ v(c.Actions, { children: /* @__PURE__ */ y(a, {
|
|
175
|
+
type: "submit",
|
|
176
|
+
isPending: M,
|
|
177
|
+
isDisabled: !C,
|
|
178
|
+
size: "sm",
|
|
179
|
+
children: [M && /* @__PURE__ */ v(m, {
|
|
180
|
+
color: "current",
|
|
181
|
+
size: "sm"
|
|
182
|
+
}), i.settings.updatePassword]
|
|
183
|
+
}) })]
|
|
184
|
+
})
|
|
185
|
+
}) })
|
|
186
|
+
})] });
|
|
79
187
|
}
|
|
188
|
+
//#endregion
|
|
189
|
+
export { C as ChangePassword };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { CardProps } from '@heroui/react';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
3
|
export type DangerZoneProps = {
|
|
4
4
|
className?: string;
|
|
5
5
|
variant?: CardProps["variant"];
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useAuth } from "@better-auth-ui/react";
|
|
3
|
-
import { cn } from "@heroui/react";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { DeleteUser as e } from "./delete-user.js";
|
|
2
|
+
import { useAuth as t } from "@better-auth-ui/react";
|
|
3
|
+
import { cn as n } from "@heroui/react";
|
|
4
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/settings/security/danger-zone.tsx
|
|
6
|
+
function a({ className: a, variant: o, ...s }) {
|
|
7
|
+
let { localization: c } = t();
|
|
8
|
+
return /* @__PURE__ */ i("div", {
|
|
9
|
+
className: n("flex w-full flex-col", a),
|
|
10
|
+
...s,
|
|
11
|
+
children: [/* @__PURE__ */ r("h2", {
|
|
12
|
+
className: n("text-sm font-semibold mb-3"),
|
|
13
|
+
children: c.settings.dangerZone
|
|
14
|
+
}), /* @__PURE__ */ r(e, { variant: o })]
|
|
15
|
+
});
|
|
12
16
|
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { a as DangerZone };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CardProps } from '@heroui/react';
|
|
2
2
|
export type DeleteUserProps = {
|
|
3
3
|
className?: string;
|
|
4
4
|
variant?: CardProps["variant"];
|
|
@@ -6,4 +6,4 @@ export type DeleteUserProps = {
|
|
|
6
6
|
/**
|
|
7
7
|
* Danger-zone card to delete the authenticated account, with a confirmation dialog and toasts.
|
|
8
8
|
*/
|
|
9
|
-
export declare function DeleteUser({ className, variant, ...props }: DeleteUserProps & CardProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function DeleteUser({ className, variant, ...props }: DeleteUserProps & Omit<CardProps, "children">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,47 +1,92 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
import { useAuth as e, useDeleteUser as t, useListAccounts as n } from "@better-auth-ui/react";
|
|
2
|
+
import { AlertDialog as r, Button as i, Card as a, FieldError as o, Form as s, Input as c, Label as l, Spinner as u, TextField as d, cn as f, toast as p } from "@heroui/react";
|
|
3
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
4
|
+
import { useState as g } from "react";
|
|
5
|
+
import { TriangleExclamation as _ } from "@gravity-ui/icons";
|
|
6
|
+
//#region src/components/settings/security/delete-user.tsx
|
|
7
|
+
function v({ className: v, variant: y, ...b }) {
|
|
8
|
+
let { basePaths: x, deleteUser: S, localization: C, navigate: w, viewPaths: T } = e(), { data: E } = n(), [D, O] = g(!1), [k, A] = g(""), j = E?.some((e) => e.providerId === "credential"), M = !S?.sendDeleteAccountVerification && j, { mutate: N, isPending: P } = t(), F = (e) => {
|
|
9
|
+
O(e), A("");
|
|
10
|
+
}, I = async (e) => {
|
|
11
|
+
e.preventDefault(), N({ ...M ? { password: k } : {} }, { onSuccess: () => {
|
|
12
|
+
O(!1), A(""), S?.sendDeleteAccountVerification ? p.success(C.settings.deleteUserVerificationSent) : (p.success(C.settings.deleteUserSuccess), w({
|
|
13
|
+
to: `${x.auth}/${T.auth.signIn}`,
|
|
14
|
+
replace: !0
|
|
15
|
+
}));
|
|
16
|
+
} });
|
|
17
|
+
};
|
|
18
|
+
return /* @__PURE__ */ m(a, {
|
|
19
|
+
className: f("border border-danger", v),
|
|
20
|
+
variant: y,
|
|
21
|
+
...b,
|
|
22
|
+
children: /* @__PURE__ */ h(a.Content, {
|
|
23
|
+
className: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",
|
|
24
|
+
children: [/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("p", {
|
|
25
|
+
className: "text-sm font-medium leading-tight",
|
|
26
|
+
children: C.settings.deleteUser
|
|
27
|
+
}), /* @__PURE__ */ m("p", {
|
|
28
|
+
className: "text-muted text-xs mt-0.5",
|
|
29
|
+
children: C.settings.deleteUserDescription
|
|
30
|
+
})] }), /* @__PURE__ */ h(r, { children: [/* @__PURE__ */ m(i, {
|
|
31
|
+
isDisabled: !E,
|
|
32
|
+
size: "sm",
|
|
33
|
+
variant: "danger",
|
|
34
|
+
onPress: () => O(!0),
|
|
35
|
+
children: C.settings.deleteUser
|
|
36
|
+
}), /* @__PURE__ */ m(r.Backdrop, {
|
|
37
|
+
isOpen: D,
|
|
38
|
+
onOpenChange: F,
|
|
39
|
+
children: /* @__PURE__ */ m(r.Container, { children: /* @__PURE__ */ m(r.Dialog, { children: /* @__PURE__ */ h(s, {
|
|
40
|
+
onSubmit: I,
|
|
41
|
+
children: [
|
|
42
|
+
/* @__PURE__ */ m(r.CloseTrigger, {}),
|
|
43
|
+
/* @__PURE__ */ h(r.Header, { children: [/* @__PURE__ */ m(r.Icon, {
|
|
44
|
+
status: "danger",
|
|
45
|
+
children: /* @__PURE__ */ m(_, {})
|
|
46
|
+
}), /* @__PURE__ */ m(r.Heading, { children: C.settings.deleteUser })] }),
|
|
47
|
+
/* @__PURE__ */ h(r.Body, {
|
|
48
|
+
className: "overflow-visible",
|
|
49
|
+
children: [/* @__PURE__ */ m("p", {
|
|
50
|
+
className: "text-muted text-sm",
|
|
51
|
+
children: C.settings.deleteUserDescription
|
|
52
|
+
}), M && /* @__PURE__ */ h(d, {
|
|
53
|
+
className: "mt-4",
|
|
54
|
+
name: "password",
|
|
55
|
+
type: "password",
|
|
56
|
+
isDisabled: P,
|
|
57
|
+
value: k,
|
|
58
|
+
onChange: A,
|
|
59
|
+
children: [
|
|
60
|
+
/* @__PURE__ */ m(l, { children: C.auth.password }),
|
|
61
|
+
/* @__PURE__ */ m(c, {
|
|
62
|
+
autoComplete: "current-password",
|
|
63
|
+
placeholder: C.auth.passwordPlaceholder,
|
|
64
|
+
required: !0,
|
|
65
|
+
variant: "secondary"
|
|
66
|
+
}),
|
|
67
|
+
/* @__PURE__ */ m(o, {})
|
|
68
|
+
]
|
|
69
|
+
})]
|
|
70
|
+
}),
|
|
71
|
+
/* @__PURE__ */ h(r.Footer, { children: [/* @__PURE__ */ m(i, {
|
|
72
|
+
slot: "close",
|
|
73
|
+
variant: "tertiary",
|
|
74
|
+
isDisabled: P,
|
|
75
|
+
children: C.settings.cancel
|
|
76
|
+
}), /* @__PURE__ */ h(i, {
|
|
77
|
+
type: "submit",
|
|
78
|
+
variant: "danger",
|
|
79
|
+
isPending: P,
|
|
80
|
+
children: [P && /* @__PURE__ */ m(u, {
|
|
81
|
+
color: "current",
|
|
82
|
+
size: "sm"
|
|
83
|
+
}), C.settings.deleteUser]
|
|
84
|
+
})] })
|
|
85
|
+
]
|
|
86
|
+
}) }) })
|
|
87
|
+
})] })]
|
|
88
|
+
})
|
|
89
|
+
});
|
|
47
90
|
}
|
|
91
|
+
//#endregion
|
|
92
|
+
export { v as DeleteUser };
|
|
@@ -1,48 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Link, LinkSlash, PlugConnection } from "@gravity-ui/icons";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
1
|
+
import { providerIcons as e, useAccountInfo as t, useAuth as n, useLinkSocial as r, useUnlinkAccount as i } from "@better-auth-ui/react";
|
|
2
|
+
import { Button as a, Skeleton as o, Spinner as s, cn as c, toast as l } from "@heroui/react";
|
|
3
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
4
|
+
import { Link as f, LinkSlash as p, PlugConnection as m } from "@gravity-ui/icons";
|
|
5
|
+
import { getProviderName as h } from "@better-auth-ui/core";
|
|
6
|
+
//#region src/components/settings/security/linked-account.tsx
|
|
7
|
+
function g({ account: g, provider: _ }) {
|
|
8
|
+
let { baseURL: v, localization: y } = n(), { data: b, isPending: x } = t({ query: { accountId: g?.accountId } }), { mutate: S, isPending: C } = r(), { mutate: w, isPending: T } = i({ onSuccess: () => l.success(y.settings.accountUnlinked) }), E = e[_], D = h(_), O = b?.data?.login || b?.data?.username || b?.user?.email || b?.user?.name || g?.accountId;
|
|
9
|
+
return /* @__PURE__ */ d("div", {
|
|
10
|
+
className: "flex items-center gap-3",
|
|
11
|
+
children: [
|
|
12
|
+
/* @__PURE__ */ u("div", {
|
|
13
|
+
className: c("flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-secondary"),
|
|
14
|
+
children: u(E || m, { className: c("size-4.5", !g && "opacity-50") })
|
|
15
|
+
}),
|
|
16
|
+
/* @__PURE__ */ d("div", {
|
|
17
|
+
className: "flex flex-col min-w-0",
|
|
18
|
+
children: [/* @__PURE__ */ u("span", {
|
|
19
|
+
className: "text-sm font-medium leading-tight",
|
|
20
|
+
children: D
|
|
21
|
+
}), g && x ? /* @__PURE__ */ u(o, { className: "h-3 w-24 my-0.5 rounded-lg" }) : /* @__PURE__ */ u("span", {
|
|
22
|
+
className: "text-xs text-muted truncate",
|
|
23
|
+
children: g ? O : y.settings.linkProvider.replace("{{provider}}", D)
|
|
24
|
+
})]
|
|
25
|
+
}),
|
|
26
|
+
g ? /* @__PURE__ */ d(a, {
|
|
27
|
+
className: "ml-auto shrink-0",
|
|
28
|
+
variant: "outline",
|
|
29
|
+
size: "sm",
|
|
30
|
+
onPress: () => w({ providerId: g.providerId }),
|
|
31
|
+
isPending: T,
|
|
32
|
+
"aria-label": y.settings.unlinkProvider.replace("{{provider}}", D),
|
|
33
|
+
children: [T ? /* @__PURE__ */ u(s, {
|
|
34
|
+
color: "current",
|
|
35
|
+
size: "sm"
|
|
36
|
+
}) : /* @__PURE__ */ u(p, {}), y.settings.unlinkProvider.replace("{{provider}}", "").trim()]
|
|
37
|
+
}) : /* @__PURE__ */ d(a, {
|
|
38
|
+
className: "ml-auto shrink-0",
|
|
39
|
+
variant: "outline",
|
|
40
|
+
size: "sm",
|
|
41
|
+
onPress: () => S({
|
|
42
|
+
provider: _,
|
|
43
|
+
callbackURL: `${v}${window.location.pathname}`
|
|
44
|
+
}),
|
|
45
|
+
isPending: C,
|
|
46
|
+
"aria-label": y.settings.linkProvider.replace("{{provider}}", D),
|
|
47
|
+
children: [C ? /* @__PURE__ */ u(s, {
|
|
48
|
+
color: "current",
|
|
49
|
+
size: "sm"
|
|
50
|
+
}) : /* @__PURE__ */ u(f, {}), y.settings.link]
|
|
51
|
+
})
|
|
52
|
+
]
|
|
53
|
+
});
|
|
48
54
|
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { g as LinkedAccount };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CardProps } from '@heroui/react';
|
|
2
2
|
export type LinkedAccountsProps = {
|
|
3
3
|
className?: string;
|
|
4
4
|
variant?: CardProps["variant"];
|
|
@@ -12,4 +12,4 @@ export type LinkedAccountsProps = {
|
|
|
12
12
|
*
|
|
13
13
|
* @returns A JSX element containing the linked accounts card
|
|
14
14
|
*/
|
|
15
|
-
export declare function LinkedAccounts({ className, variant, ...props }: LinkedAccountsProps & CardProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function LinkedAccounts({ className, variant, ...props }: LinkedAccountsProps & Omit<CardProps, "children">): import("react/jsx-runtime").JSX.Element;
|