@better-auth-ui/heroui 1.6.27 → 1.6.28
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/forgot-password.d.ts +3 -1
- package/dist/components/auth/magic-link/magic-link-sent.d.ts +20 -0
- package/dist/components/auth/reset-link-sent.d.ts +20 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +271 -230
- package/dist/lib/auth/magic-link-plugin.d.ts +4 -0
- package/dist/plugins.d.ts +1 -0
- package/dist/plugins.js +423 -380
- package/dist/user-view-CxSDufx_.js +126 -0
- package/package.json +1 -1
- package/src/components/auth/auth.tsx +8 -1
- package/src/components/auth/forgot-password.tsx +9 -6
- package/src/components/auth/magic-link/magic-link-sent.tsx +84 -0
- package/src/components/auth/magic-link/magic-link.tsx +10 -6
- package/src/components/auth/reset-link-sent.tsx +80 -0
- package/src/components/auth/settings/security/change-password.tsx +32 -14
- package/src/index.tsx +1 -0
- package/src/lib/auth/magic-link-plugin.ts +2 -1
- package/src/plugins.ts +1 -0
- package/dist/user-view--47tVtJ3.js +0 -113
package/dist/index.js
CHANGED
|
@@ -1,33 +1,32 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { a as e, i as t, n, r,
|
|
3
|
-
import { authMutationKeys as
|
|
4
|
-
import { AuthProvider as f, providerIcons as p, useAccountInfo as m, useAuth as h, useAuthenticate as g, useChangeEmail as _, useChangePassword as v, useFetchOptions as y, useLinkSocial as b, useListAccounts as x, useListSessions as
|
|
5
|
-
import { ArrowRightFromSquare as E, ArrowRightToSquare as se,
|
|
6
|
-
import { Button as k, Calendar as A, Card as j, Checkbox as M, Chip as
|
|
7
|
-
import { fromDate as
|
|
8
|
-
import { isValidElement as
|
|
2
|
+
import { a as e, i as t, n, o as r, r as i, t as a } from "./user-view-CxSDufx_.js";
|
|
3
|
+
import { authMutationKeys as o, authQueryKeys as s, fileToBase64 as c, getProviderName as l, parseAdditionalFieldValue as u, resolveInputType as d } from "@better-auth-ui/core";
|
|
4
|
+
import { AuthProvider as f, providerIcons as p, useAccountInfo as m, useAuth as h, useAuthenticate as g, useChangeEmail as _, useChangePassword as v, useFetchOptions as y, useLinkSocial as b, useListAccounts as x, useListSessions as S, useRequestPasswordReset as C, useResetPassword as ee, useRevokeSession as w, useSendVerificationEmail as te, useSession as T, useSignInEmail as ne, useSignOut as re, useSignUpEmail as ie, useUnlinkAccount as ae, useUpdateUser as oe } from "@better-auth-ui/react";
|
|
5
|
+
import { ArrowRightFromSquare as E, ArrowRightToSquare as se, Check as ce, ChevronsExpandVertical as le, CloudArrowUpIn as ue, Copy as de, Display as fe, Eye as D, EyeSlash as O, Gear as pe, Link as me, LinkSlash as he, Person as ge, PersonPlus as _e, PlugConnection as ve, Shield as ye, Smartphone as be, TrashBin as xe, Xmark as Se } from "@gravity-ui/icons";
|
|
6
|
+
import { Button as k, Calendar as A, Card as j, Checkbox as M, Chip as Ce, ComboBox as we, DateField as Te, DatePicker as Ee, Description as N, Dropdown as P, FieldError as F, Fieldset as I, Form as L, Input as R, InputGroup as z, Label as B, Link as V, ListBox as H, NumberField as De, RouterProvider as Oe, Select as ke, Skeleton as U, Slider as Ae, Spinner as W, Switch as je, Tabs as G, TextArea as Me, TextField as K, TimeField as Ne, cn as q, toast as J, useIsHydrated as Pe } from "@heroui/react";
|
|
7
|
+
import { fromDate as Fe, getLocalTimeZone as Ie, parseDate as Le, parseDateTime as Re, toCalendarDate as ze, toCalendarDateTime as Be } from "@internationalized/date";
|
|
8
|
+
import { isValidElement as Ve, useEffect as Y, useMemo as He, useRef as Ue, useState as X } from "react";
|
|
9
9
|
import { Fragment as Z, jsx as Q, jsxs as $ } from "react/jsx-runtime";
|
|
10
|
-
import { matchMutation as
|
|
11
|
-
import
|
|
12
|
-
import Xe from "bowser";
|
|
10
|
+
import { matchMutation as We, matchQuery as Ge, useIsMutating as Ke, useQueryClient as qe } from "@tanstack/react-query";
|
|
11
|
+
import Je from "bowser";
|
|
13
12
|
//#region src/components/auth/additional-field.tsx
|
|
14
|
-
function
|
|
15
|
-
if (e instanceof Date) return
|
|
13
|
+
function Ye(e) {
|
|
14
|
+
if (e instanceof Date) return ze(Fe(e, Ie()));
|
|
16
15
|
if (typeof e == "string") try {
|
|
17
|
-
return
|
|
16
|
+
return Le(e.slice(0, 10));
|
|
18
17
|
} catch {
|
|
19
18
|
return;
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
|
-
function
|
|
23
|
-
if (e instanceof Date) return
|
|
21
|
+
function Xe(e) {
|
|
22
|
+
if (e instanceof Date) return Be(Fe(e, Ie()));
|
|
24
23
|
if (typeof e == "string") try {
|
|
25
|
-
return
|
|
24
|
+
return Re(e.replace(/(Z|[+-]\d{2}:?\d{2})$/, ""));
|
|
26
25
|
} catch {
|
|
27
26
|
return;
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
|
-
function
|
|
29
|
+
function Ze({ getValue: e, isDisabled: t }) {
|
|
31
30
|
let { localization: n } = h(), [r, i] = X(!1);
|
|
32
31
|
async function a() {
|
|
33
32
|
let t = e();
|
|
@@ -44,10 +43,10 @@ function $e({ getValue: e, isDisabled: t }) {
|
|
|
44
43
|
variant: "ghost",
|
|
45
44
|
isDisabled: t,
|
|
46
45
|
onPress: a,
|
|
47
|
-
children: Q(r ?
|
|
46
|
+
children: Q(r ? ce : de, { className: "size-4" })
|
|
48
47
|
});
|
|
49
48
|
}
|
|
50
|
-
function
|
|
49
|
+
function Qe({ name: e, field: t, isPending: n, variant: r }) {
|
|
51
50
|
let { localization: i } = h(), a = d(t), o = r === "transparent" ? "primary" : "secondary";
|
|
52
51
|
if (t.render) {
|
|
53
52
|
let i = t.render;
|
|
@@ -70,7 +69,7 @@ function et({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
70
69
|
isReadOnly: t.readOnly,
|
|
71
70
|
children: [
|
|
72
71
|
/* @__PURE__ */ Q(B, { children: t.label }),
|
|
73
|
-
/* @__PURE__ */ Q(
|
|
72
|
+
/* @__PURE__ */ Q(Me, {
|
|
74
73
|
placeholder: t.placeholder,
|
|
75
74
|
required: t.required,
|
|
76
75
|
variant: o
|
|
@@ -80,7 +79,7 @@ function et({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
80
79
|
});
|
|
81
80
|
if (a === "number") {
|
|
82
81
|
let r = t.formatOptions?.maximumFractionDigits;
|
|
83
|
-
return /* @__PURE__ */ $(
|
|
82
|
+
return /* @__PURE__ */ $(De, {
|
|
84
83
|
name: e,
|
|
85
84
|
defaultValue: typeof t.defaultValue == "number" ? t.defaultValue : t.defaultValue != null && t.defaultValue !== "" ? Number(t.defaultValue) : void 0,
|
|
86
85
|
minValue: t.min,
|
|
@@ -92,13 +91,13 @@ function et({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
92
91
|
variant: o,
|
|
93
92
|
children: [
|
|
94
93
|
/* @__PURE__ */ Q(B, { children: t.label }),
|
|
95
|
-
/* @__PURE__ */ $(
|
|
96
|
-
/* @__PURE__ */ Q(
|
|
97
|
-
/* @__PURE__ */ Q(
|
|
94
|
+
/* @__PURE__ */ $(De.Group, { children: [
|
|
95
|
+
/* @__PURE__ */ Q(De.DecrementButton, {}),
|
|
96
|
+
/* @__PURE__ */ Q(De.Input, {
|
|
98
97
|
placeholder: t.placeholder,
|
|
99
98
|
required: t.required
|
|
100
99
|
}),
|
|
101
|
-
/* @__PURE__ */ Q(
|
|
100
|
+
/* @__PURE__ */ Q(De.IncrementButton, {})
|
|
102
101
|
] }),
|
|
103
102
|
/* @__PURE__ */ Q(F, {})
|
|
104
103
|
]
|
|
@@ -106,7 +105,7 @@ function et({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
106
105
|
}
|
|
107
106
|
if (a === "slider") {
|
|
108
107
|
let r = t.formatOptions?.maximumFractionDigits;
|
|
109
|
-
return /* @__PURE__ */ $(
|
|
108
|
+
return /* @__PURE__ */ $(Ae, {
|
|
110
109
|
defaultValue: typeof t.defaultValue == "number" ? t.defaultValue : t.defaultValue == null ? void 0 : Number(t.defaultValue),
|
|
111
110
|
minValue: t.min ?? 0,
|
|
112
111
|
maxValue: t.max ?? 100,
|
|
@@ -116,16 +115,16 @@ function et({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
116
115
|
className: "flex flex-col gap-2",
|
|
117
116
|
children: [/* @__PURE__ */ $("div", {
|
|
118
117
|
className: "flex items-center justify-between gap-2",
|
|
119
|
-
children: [/* @__PURE__ */ Q(B, { children: t.label }), /* @__PURE__ */ Q(
|
|
120
|
-
}), /* @__PURE__ */ $(
|
|
118
|
+
children: [/* @__PURE__ */ Q(B, { children: t.label }), /* @__PURE__ */ Q(Ae.Output, { className: "text-sm text-muted" })]
|
|
119
|
+
}), /* @__PURE__ */ $(Ae.Track, { children: [/* @__PURE__ */ Q(Ae.Fill, {}), /* @__PURE__ */ Q(Ae.Thumb, { name: e })] })]
|
|
121
120
|
});
|
|
122
121
|
}
|
|
123
|
-
if (a === "switch") return /* @__PURE__ */ Q(
|
|
122
|
+
if (a === "switch") return /* @__PURE__ */ Q(je, {
|
|
124
123
|
name: e,
|
|
125
124
|
defaultSelected: t.defaultValue === !0 || t.defaultValue === "true",
|
|
126
125
|
isDisabled: n,
|
|
127
126
|
isReadOnly: t.readOnly,
|
|
128
|
-
children: /* @__PURE__ */ $(
|
|
127
|
+
children: /* @__PURE__ */ $(je.Content, { children: [/* @__PURE__ */ Q(je.Control, { children: /* @__PURE__ */ Q(je.Thumb, {}) }), t.label] })
|
|
129
128
|
});
|
|
130
129
|
if (a === "checkbox") return /* @__PURE__ */ Q(M, {
|
|
131
130
|
name: e,
|
|
@@ -136,7 +135,7 @@ function et({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
136
135
|
variant: o,
|
|
137
136
|
children: /* @__PURE__ */ $(M.Content, { children: [/* @__PURE__ */ Q(M.Control, { children: /* @__PURE__ */ Q(M.Indicator, {}) }), t.label] })
|
|
138
137
|
});
|
|
139
|
-
if (a === "select") return /* @__PURE__ */ $(
|
|
138
|
+
if (a === "select") return /* @__PURE__ */ $(ke, {
|
|
140
139
|
className: "[&[data-required=true]>.label]:after:content-none",
|
|
141
140
|
name: e,
|
|
142
141
|
defaultValue: t.defaultValue == null ? void 0 : String(t.defaultValue),
|
|
@@ -147,8 +146,8 @@ function et({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
147
146
|
fullWidth: !0,
|
|
148
147
|
children: [
|
|
149
148
|
/* @__PURE__ */ Q(B, { children: t.label }),
|
|
150
|
-
/* @__PURE__ */ $(
|
|
151
|
-
/* @__PURE__ */ Q(
|
|
149
|
+
/* @__PURE__ */ $(ke.Trigger, { children: [/* @__PURE__ */ Q(ke.Value, {}), /* @__PURE__ */ Q(ke.Indicator, {})] }),
|
|
150
|
+
/* @__PURE__ */ Q(ke.Popover, { children: /* @__PURE__ */ Q(H, { children: t.options?.map((e) => /* @__PURE__ */ $(H.Item, {
|
|
152
151
|
id: e.value,
|
|
153
152
|
textValue: typeof e.label == "string" ? e.label : e.value,
|
|
154
153
|
children: [e.label, /* @__PURE__ */ Q(H.ItemIndicator, {})]
|
|
@@ -156,7 +155,7 @@ function et({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
156
155
|
/* @__PURE__ */ Q(F, {})
|
|
157
156
|
]
|
|
158
157
|
});
|
|
159
|
-
if (a === "combobox") return /* @__PURE__ */ $(
|
|
158
|
+
if (a === "combobox") return /* @__PURE__ */ $(we, {
|
|
160
159
|
className: "[&[data-required=true]>.label]:after:content-none",
|
|
161
160
|
name: e,
|
|
162
161
|
defaultSelectedKey: t.defaultValue == null ? void 0 : String(t.defaultValue),
|
|
@@ -167,8 +166,8 @@ function et({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
167
166
|
fullWidth: !0,
|
|
168
167
|
children: [
|
|
169
168
|
/* @__PURE__ */ Q(B, { children: t.label }),
|
|
170
|
-
/* @__PURE__ */ $(
|
|
171
|
-
/* @__PURE__ */ Q(
|
|
169
|
+
/* @__PURE__ */ $(we.InputGroup, { children: [/* @__PURE__ */ Q(R, { placeholder: t.placeholder }), /* @__PURE__ */ Q(we.Trigger, {})] }),
|
|
170
|
+
/* @__PURE__ */ Q(we.Popover, { children: /* @__PURE__ */ Q(H, { children: t.options?.map((e) => /* @__PURE__ */ $(H.Item, {
|
|
172
171
|
id: e.value,
|
|
173
172
|
textValue: typeof e.label == "string" ? e.label : e.value,
|
|
174
173
|
children: [e.label, /* @__PURE__ */ Q(H.ItemIndicator, {})]
|
|
@@ -178,23 +177,23 @@ function et({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
178
177
|
});
|
|
179
178
|
if (a === "date" || a === "datetime") {
|
|
180
179
|
let r = a === "datetime";
|
|
181
|
-
return /* @__PURE__ */ Q(
|
|
180
|
+
return /* @__PURE__ */ Q(Ee, {
|
|
182
181
|
className: "w-full [&[data-required=true]>.label]:after:content-none",
|
|
183
182
|
name: e,
|
|
184
|
-
defaultValue: r ?
|
|
183
|
+
defaultValue: r ? Xe(t.defaultValue) : Ye(t.defaultValue),
|
|
185
184
|
granularity: r ? "minute" : "day",
|
|
186
185
|
isDisabled: n,
|
|
187
186
|
isReadOnly: t.readOnly,
|
|
188
187
|
isRequired: t.required,
|
|
189
188
|
children: ({ state: n }) => /* @__PURE__ */ $(Z, { children: [
|
|
190
189
|
/* @__PURE__ */ Q(B, { children: t.label }),
|
|
191
|
-
/* @__PURE__ */ $(
|
|
190
|
+
/* @__PURE__ */ $(Te.Group, {
|
|
192
191
|
variant: o,
|
|
193
192
|
fullWidth: !0,
|
|
194
|
-
children: [/* @__PURE__ */ Q(
|
|
193
|
+
children: [/* @__PURE__ */ Q(Te.Input, { children: (e) => /* @__PURE__ */ Q(Te.Segment, { segment: e }) }), /* @__PURE__ */ Q(Te.Suffix, { children: /* @__PURE__ */ Q(Ee.Trigger, { children: /* @__PURE__ */ Q(Ee.TriggerIndicator, {}) }) })]
|
|
195
194
|
}),
|
|
196
195
|
/* @__PURE__ */ Q(F, {}),
|
|
197
|
-
/* @__PURE__ */ $(
|
|
196
|
+
/* @__PURE__ */ $(Ee.Popover, {
|
|
198
197
|
className: "flex flex-col gap-3",
|
|
199
198
|
children: [/* @__PURE__ */ $(A, {
|
|
200
199
|
"aria-label": typeof t.label == "string" ? t.label : e,
|
|
@@ -209,14 +208,14 @@ function et({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
209
208
|
]
|
|
210
209
|
}), r && /* @__PURE__ */ $("div", {
|
|
211
210
|
className: "flex items-center justify-between",
|
|
212
|
-
children: [/* @__PURE__ */ Q(B, { children: i.settings.time }), /* @__PURE__ */ Q(
|
|
211
|
+
children: [/* @__PURE__ */ Q(B, { children: i.settings.time }), /* @__PURE__ */ Q(Ne, {
|
|
213
212
|
"aria-label": i.settings.time,
|
|
214
213
|
granularity: "minute",
|
|
215
214
|
value: n.timeValue,
|
|
216
215
|
onChange: (e) => n.setTimeValue(e),
|
|
217
|
-
children: /* @__PURE__ */ Q(
|
|
216
|
+
children: /* @__PURE__ */ Q(Ne.Group, {
|
|
218
217
|
variant: "secondary",
|
|
219
|
-
children: /* @__PURE__ */ Q(
|
|
218
|
+
children: /* @__PURE__ */ Q(Ne.Input, { children: (e) => /* @__PURE__ */ Q(Ne.Segment, { segment: e }) })
|
|
220
219
|
})
|
|
221
220
|
})]
|
|
222
221
|
})]
|
|
@@ -224,15 +223,15 @@ function et({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
224
223
|
] })
|
|
225
224
|
});
|
|
226
225
|
}
|
|
227
|
-
return /* @__PURE__ */ Q(
|
|
226
|
+
return /* @__PURE__ */ Q($e, {
|
|
228
227
|
name: e,
|
|
229
228
|
field: t,
|
|
230
229
|
isPending: n,
|
|
231
230
|
variant: r
|
|
232
231
|
});
|
|
233
232
|
}
|
|
234
|
-
function
|
|
235
|
-
let i =
|
|
233
|
+
function $e({ name: e, field: t, isPending: n, variant: r }) {
|
|
234
|
+
let i = Ue(null), a = r === "transparent" ? "primary" : "secondary", o = t.prefix != null, s = t.suffix != null || t.copyable, c = t.type === "number", l = t.formatOptions?.maximumFractionDigits, u = c ? "number" : void 0, d = c ? l ? "decimal" : "numeric" : void 0, f = l ? 1 / 10 ** l : void 0;
|
|
236
235
|
return o || s ? /* @__PURE__ */ $(K, {
|
|
237
236
|
name: e,
|
|
238
237
|
defaultValue: t.defaultValue == null ? void 0 : String(t.defaultValue),
|
|
@@ -254,7 +253,7 @@ function tt({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
254
253
|
}),
|
|
255
254
|
t.copyable ? /* @__PURE__ */ Q(z.Suffix, {
|
|
256
255
|
className: "px-0",
|
|
257
|
-
children: /* @__PURE__ */ Q(
|
|
256
|
+
children: /* @__PURE__ */ Q(Ze, {
|
|
258
257
|
getValue: () => i.current?.value,
|
|
259
258
|
isDisabled: n
|
|
260
259
|
})
|
|
@@ -283,14 +282,54 @@ function tt({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
283
282
|
});
|
|
284
283
|
}
|
|
285
284
|
//#endregion
|
|
285
|
+
//#region src/components/auth/reset-link-sent.tsx
|
|
286
|
+
var et = "better-auth-ui.reset-link-sent";
|
|
287
|
+
function tt({ className: e, variant: t }) {
|
|
288
|
+
let { basePaths: n, localization: i, viewPaths: a } = h(), [o, s] = X(Pe() && sessionStorage.getItem("better-auth-ui.reset-link-sent") || "");
|
|
289
|
+
return Y(() => {
|
|
290
|
+
s(sessionStorage.getItem("better-auth-ui.reset-link-sent") ?? "");
|
|
291
|
+
}, []), /* @__PURE__ */ $(j, {
|
|
292
|
+
className: q("w-full max-w-sm gap-4 md:p-6", e),
|
|
293
|
+
variant: t,
|
|
294
|
+
children: [
|
|
295
|
+
/* @__PURE__ */ Q(j.Header, { children: /* @__PURE__ */ Q(j.Title, {
|
|
296
|
+
className: "text-xl font-semibold mb-1",
|
|
297
|
+
children: i.auth.checkYourEmailTitle
|
|
298
|
+
}) }),
|
|
299
|
+
/* @__PURE__ */ $(j.Content, {
|
|
300
|
+
className: "gap-4",
|
|
301
|
+
children: [/* @__PURE__ */ Q(N, {
|
|
302
|
+
className: "text-sm",
|
|
303
|
+
children: o ? i.auth.resetLinkSentTo.replace("{{email}}", o) : i.auth.passwordResetEmailSent
|
|
304
|
+
}), o && /* @__PURE__ */ Q(r, { email: o })]
|
|
305
|
+
}),
|
|
306
|
+
/* @__PURE__ */ Q(j.Footer, {
|
|
307
|
+
className: "flex-col gap-3",
|
|
308
|
+
children: /* @__PURE__ */ $(N, {
|
|
309
|
+
className: "text-sm",
|
|
310
|
+
children: [
|
|
311
|
+
i.auth.rememberYourPassword,
|
|
312
|
+
" ",
|
|
313
|
+
/* @__PURE__ */ Q(V, {
|
|
314
|
+
href: `${n.auth}/${a.auth.signIn}`,
|
|
315
|
+
className: "text-accent no-underline hover:underline decoration-accent-hover",
|
|
316
|
+
children: i.auth.signIn
|
|
317
|
+
})
|
|
318
|
+
]
|
|
319
|
+
})
|
|
320
|
+
})
|
|
321
|
+
]
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
//#endregion
|
|
286
325
|
//#region src/components/auth/forgot-password.tsx
|
|
287
326
|
function nt({ className: e, variant: t }) {
|
|
288
|
-
let { authClient: n, baseURL: r, basePaths: i, localization: a, viewPaths: o, navigate: s, plugins: c } = h(), { fetchOptions: l, resetFetchOptions: u } = y(), { mutate: d, isPending: f } =
|
|
327
|
+
let { authClient: n, baseURL: r, basePaths: i, localization: a, viewPaths: o, navigate: s, plugins: c } = h(), { fetchOptions: l, resetFetchOptions: u } = y(), { mutate: d, isPending: f } = C(n, {
|
|
289
328
|
onError: () => {
|
|
290
329
|
u();
|
|
291
330
|
},
|
|
292
|
-
onSuccess: () => {
|
|
293
|
-
|
|
331
|
+
onSuccess: (e, { email: t }) => {
|
|
332
|
+
sessionStorage.setItem(et, t), s({ to: `${i.auth}/${o.auth.resetLinkSent}` });
|
|
294
333
|
}
|
|
295
334
|
});
|
|
296
335
|
function p(e) {
|
|
@@ -374,7 +413,7 @@ function nt({ className: e, variant: t }) {
|
|
|
374
413
|
//#endregion
|
|
375
414
|
//#region src/components/auth/reset-password.tsx
|
|
376
415
|
function rt({ className: e, variant: t }) {
|
|
377
|
-
let { authClient: n, basePaths: r, emailAndPassword: i, localization: a, viewPaths: o, navigate: s } = h(), { mutate: c, isPending: l } =
|
|
416
|
+
let { authClient: n, basePaths: r, emailAndPassword: i, localization: a, viewPaths: o, navigate: s } = h(), { mutate: c, isPending: l } = ee(n, { onSuccess: () => {
|
|
378
417
|
J.success(a.auth.passwordResetSuccess), s({ to: `${r.auth}/${o.auth.signIn}` });
|
|
379
418
|
} }), [u, d] = X(!1), [f, p] = X(!1);
|
|
380
419
|
Y(() => {
|
|
@@ -525,25 +564,25 @@ function rt({ className: e, variant: t }) {
|
|
|
525
564
|
}
|
|
526
565
|
//#endregion
|
|
527
566
|
//#region src/components/auth/sign-in.tsx
|
|
528
|
-
function it({ className: t, socialLayout: n, socialPosition:
|
|
529
|
-
let { authClient: s, basePaths: c, emailAndPassword: l, localization: u, plugins: d, redirectTo: f, socialProviders: p, viewPaths: m, navigate: g } = h(), { fetchOptions: _, resetFetchOptions: v } = y(), [b, x] = X(""), { mutate:
|
|
567
|
+
function it({ className: t, socialLayout: n, socialPosition: r = "bottom", variant: a }) {
|
|
568
|
+
let { authClient: s, basePaths: c, emailAndPassword: l, localization: u, plugins: d, redirectTo: f, socialProviders: p, viewPaths: m, navigate: g } = h(), { fetchOptions: _, resetFetchOptions: v } = y(), [b, x] = X(""), { mutate: S, isPending: C } = ne(s, {
|
|
530
569
|
onError: (e, { email: t }) => {
|
|
531
570
|
x(""), e.error?.code === "EMAIL_NOT_VERIFIED" && (sessionStorage.setItem("better-auth-ui.verify-email", t), g({ to: `${c.auth}/${m.auth.verifyEmail}` })), v();
|
|
532
571
|
},
|
|
533
572
|
onSuccess: () => g({ to: f })
|
|
534
|
-
}),
|
|
573
|
+
}), ee = (e) => {
|
|
535
574
|
e.preventDefault();
|
|
536
575
|
let t = new FormData(e.currentTarget), n = t.get("email"), r = t.get("rememberMe") === "on";
|
|
537
|
-
|
|
576
|
+
S({
|
|
538
577
|
email: n,
|
|
539
578
|
password: b,
|
|
540
579
|
...l?.rememberMe ? { rememberMe: r } : {},
|
|
541
580
|
fetchOptions: _
|
|
542
581
|
});
|
|
543
|
-
},
|
|
582
|
+
}, w = Ke({ mutationKey: o.signIn.all }) + Ke({ mutationKey: o.signUp.all }) > 0, te = d.find((e) => e.captchaComponent)?.captchaComponent, T = l?.enabled && !!p?.length;
|
|
544
583
|
return /* @__PURE__ */ $(j, {
|
|
545
584
|
className: q("w-full max-w-sm gap-4 md:p-6", t),
|
|
546
|
-
variant:
|
|
585
|
+
variant: a,
|
|
547
586
|
children: [
|
|
548
587
|
/* @__PURE__ */ Q(j.Header, { children: /* @__PURE__ */ Q(j.Title, {
|
|
549
588
|
className: "text-xl font-semibold mb-1",
|
|
@@ -552,16 +591,16 @@ function it({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
552
591
|
/* @__PURE__ */ $(j.Content, {
|
|
553
592
|
className: "gap-4",
|
|
554
593
|
children: [
|
|
555
|
-
|
|
594
|
+
r === "top" && /* @__PURE__ */ $(Z, { children: [!!p?.length && /* @__PURE__ */ Q(i, { socialLayout: n }), T && /* @__PURE__ */ Q(e, { children: u.auth.or })] }),
|
|
556
595
|
l?.enabled && /* @__PURE__ */ $(L, {
|
|
557
|
-
onSubmit:
|
|
596
|
+
onSubmit: ee,
|
|
558
597
|
className: "flex flex-col gap-4",
|
|
559
598
|
children: [
|
|
560
599
|
/* @__PURE__ */ $(K, {
|
|
561
600
|
name: "email",
|
|
562
601
|
type: "email",
|
|
563
602
|
autoComplete: "email",
|
|
564
|
-
isDisabled:
|
|
603
|
+
isDisabled: w,
|
|
565
604
|
validate: (e) => {
|
|
566
605
|
if (!e) return u.auth.fieldRequired;
|
|
567
606
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) return u.auth.invalidEmail;
|
|
@@ -570,7 +609,7 @@ function it({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
570
609
|
/* @__PURE__ */ Q(B, { children: u.auth.email }),
|
|
571
610
|
/* @__PURE__ */ Q(R, {
|
|
572
611
|
placeholder: u.auth.emailPlaceholder,
|
|
573
|
-
variant:
|
|
612
|
+
variant: a === "transparent" ? "primary" : "secondary",
|
|
574
613
|
required: !0
|
|
575
614
|
}),
|
|
576
615
|
/* @__PURE__ */ Q(F, {})
|
|
@@ -582,7 +621,7 @@ function it({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
582
621
|
name: "password",
|
|
583
622
|
type: "password",
|
|
584
623
|
autoComplete: "current-password",
|
|
585
|
-
isDisabled:
|
|
624
|
+
isDisabled: w,
|
|
586
625
|
value: b,
|
|
587
626
|
onChange: x,
|
|
588
627
|
validate: (e) => {
|
|
@@ -595,7 +634,7 @@ function it({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
595
634
|
/* @__PURE__ */ Q(B, { children: u.auth.password }),
|
|
596
635
|
/* @__PURE__ */ Q(R, {
|
|
597
636
|
placeholder: u.auth.passwordPlaceholder,
|
|
598
|
-
variant:
|
|
637
|
+
variant: a === "transparent" ? "primary" : "secondary",
|
|
599
638
|
required: !0
|
|
600
639
|
}),
|
|
601
640
|
/* @__PURE__ */ Q(F, {})
|
|
@@ -603,21 +642,21 @@ function it({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
603
642
|
}),
|
|
604
643
|
l?.rememberMe && /* @__PURE__ */ Q(M, {
|
|
605
644
|
name: "rememberMe",
|
|
606
|
-
isDisabled:
|
|
607
|
-
variant:
|
|
645
|
+
isDisabled: w,
|
|
646
|
+
variant: a === "transparent" ? "primary" : "secondary",
|
|
608
647
|
children: /* @__PURE__ */ $(M.Content, { children: [/* @__PURE__ */ Q(M.Control, { children: /* @__PURE__ */ Q(M.Indicator, {}) }), u.auth.rememberMe] })
|
|
609
648
|
}),
|
|
610
|
-
|
|
649
|
+
te && /* @__PURE__ */ Q("div", {
|
|
611
650
|
className: "flex justify-center",
|
|
612
|
-
children:
|
|
651
|
+
children: te
|
|
613
652
|
}),
|
|
614
653
|
/* @__PURE__ */ $("div", {
|
|
615
654
|
className: "flex flex-col gap-3",
|
|
616
655
|
children: [/* @__PURE__ */ $(k, {
|
|
617
656
|
type: "submit",
|
|
618
657
|
className: "w-full",
|
|
619
|
-
isPending:
|
|
620
|
-
children: [
|
|
658
|
+
isPending: w,
|
|
659
|
+
children: [C && /* @__PURE__ */ Q(W, {
|
|
621
660
|
color: "current",
|
|
622
661
|
size: "sm"
|
|
623
662
|
}), u.auth.signIn]
|
|
@@ -625,7 +664,7 @@ function it({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
625
664
|
})
|
|
626
665
|
]
|
|
627
666
|
}),
|
|
628
|
-
|
|
667
|
+
r === "bottom" && /* @__PURE__ */ $(Z, { children: [T && /* @__PURE__ */ Q(e, { children: u.auth.or }), !!p?.length && /* @__PURE__ */ Q(i, { socialLayout: n })] })
|
|
629
668
|
]
|
|
630
669
|
}),
|
|
631
670
|
/* @__PURE__ */ $(j.Footer, {
|
|
@@ -664,7 +703,7 @@ function at({ className: e }) {
|
|
|
664
703
|
to: `${n.auth}/${i.auth.signIn}`,
|
|
665
704
|
replace: !0
|
|
666
705
|
})
|
|
667
|
-
}), o =
|
|
706
|
+
}), o = Ue(!1);
|
|
668
707
|
return Y(() => {
|
|
669
708
|
o.current || (o.current = !0, a());
|
|
670
709
|
}, [a]), /* @__PURE__ */ Q(W, {
|
|
@@ -674,19 +713,19 @@ function at({ className: e }) {
|
|
|
674
713
|
}
|
|
675
714
|
//#endregion
|
|
676
715
|
//#region src/components/auth/sign-up.tsx
|
|
677
|
-
function ot({ className: t, socialLayout: n, socialPosition:
|
|
678
|
-
let { additionalFields: s, authClient: c, basePaths: l, emailAndPassword: d, localization: f, plugins: p, redirectTo: m, socialProviders: g, viewPaths: _, navigate: v } = h(), { fetchOptions: b, resetFetchOptions: x } = y(), [
|
|
716
|
+
function ot({ className: t, socialLayout: n, socialPosition: r = "bottom", variant: a }) {
|
|
717
|
+
let { additionalFields: s, authClient: c, basePaths: l, emailAndPassword: d, localization: f, plugins: p, redirectTo: m, socialProviders: g, viewPaths: _, navigate: v } = h(), { fetchOptions: b, resetFetchOptions: x } = y(), [S, C] = X(""), [ee, w] = X(""), { mutate: te, isPending: T } = ie(c, {
|
|
679
718
|
onError: () => {
|
|
680
|
-
|
|
719
|
+
C(""), w(""), x();
|
|
681
720
|
},
|
|
682
721
|
onSuccess: (e, { email: t }) => {
|
|
683
722
|
d?.requireEmailVerification ? (sessionStorage.setItem("better-auth-ui.verify-email", t), v({ to: `${l.auth}/${_.auth.verifyEmail}` })) : v({ to: m });
|
|
684
723
|
}
|
|
685
|
-
}), [
|
|
724
|
+
}), [ne, re] = X(!1), [ae, oe] = X(!1), E = Ke({ mutationKey: o.signIn.all }) + Ke({ mutationKey: o.signUp.all }) > 0, se = p.find((e) => e.captchaComponent)?.captchaComponent, ce = async (e) => {
|
|
686
725
|
e.preventDefault();
|
|
687
726
|
let t = new FormData(e.currentTarget), n = t.get("name") ?? "", r = t.get("email");
|
|
688
|
-
if (d?.confirmPassword &&
|
|
689
|
-
J.danger(f.auth.passwordsDoNotMatch),
|
|
727
|
+
if (d?.confirmPassword && S !== ee) {
|
|
728
|
+
J.danger(f.auth.passwordsDoNotMatch), C(""), w("");
|
|
690
729
|
return;
|
|
691
730
|
}
|
|
692
731
|
let i = {};
|
|
@@ -701,17 +740,17 @@ function ot({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
701
740
|
}
|
|
702
741
|
n !== void 0 && (i[e.name] = n);
|
|
703
742
|
}
|
|
704
|
-
|
|
743
|
+
te({
|
|
705
744
|
name: n,
|
|
706
745
|
email: r,
|
|
707
|
-
password:
|
|
746
|
+
password: S,
|
|
708
747
|
...i,
|
|
709
748
|
fetchOptions: b
|
|
710
749
|
});
|
|
711
750
|
}, le = d?.enabled && !!g?.length;
|
|
712
751
|
return /* @__PURE__ */ $(j, {
|
|
713
752
|
className: q("w-full max-w-sm gap-4 md:p-6", t),
|
|
714
|
-
variant:
|
|
753
|
+
variant: a,
|
|
715
754
|
children: [
|
|
716
755
|
/* @__PURE__ */ Q(j.Header, { children: /* @__PURE__ */ Q(j.Title, {
|
|
717
756
|
className: "text-xl font-semibold mb-1",
|
|
@@ -720,7 +759,7 @@ function ot({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
720
759
|
/* @__PURE__ */ $(j.Content, {
|
|
721
760
|
className: "gap-4",
|
|
722
761
|
children: [
|
|
723
|
-
|
|
762
|
+
r === "top" && /* @__PURE__ */ $(Z, { children: [!!g?.length && /* @__PURE__ */ Q(i, { socialLayout: n }), le && /* @__PURE__ */ Q(e, { children: f.auth.or })] }),
|
|
724
763
|
d?.enabled && /* @__PURE__ */ $(L, {
|
|
725
764
|
onSubmit: ce,
|
|
726
765
|
className: "flex flex-col gap-4",
|
|
@@ -738,7 +777,7 @@ function ot({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
738
777
|
/* @__PURE__ */ Q(R, {
|
|
739
778
|
placeholder: f.auth.namePlaceholder,
|
|
740
779
|
required: !0,
|
|
741
|
-
variant:
|
|
780
|
+
variant: a === "transparent" ? "primary" : "secondary"
|
|
742
781
|
}),
|
|
743
782
|
/* @__PURE__ */ Q(F, {})
|
|
744
783
|
]
|
|
@@ -757,16 +796,16 @@ function ot({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
757
796
|
/* @__PURE__ */ Q(R, {
|
|
758
797
|
placeholder: f.auth.emailPlaceholder,
|
|
759
798
|
required: !0,
|
|
760
|
-
variant:
|
|
799
|
+
variant: a === "transparent" ? "primary" : "secondary"
|
|
761
800
|
}),
|
|
762
801
|
/* @__PURE__ */ Q(F, {})
|
|
763
802
|
]
|
|
764
803
|
}),
|
|
765
|
-
s?.map((e) => e.signUp === "above" && /* @__PURE__ */ Q(
|
|
804
|
+
s?.map((e) => e.signUp === "above" && /* @__PURE__ */ Q(Qe, {
|
|
766
805
|
name: e.name,
|
|
767
806
|
field: e,
|
|
768
807
|
isPending: E,
|
|
769
|
-
variant:
|
|
808
|
+
variant: a
|
|
770
809
|
}, e.name)),
|
|
771
810
|
/* @__PURE__ */ $(K, {
|
|
772
811
|
minLength: d?.minPasswordLength,
|
|
@@ -774,8 +813,8 @@ function ot({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
774
813
|
name: "password",
|
|
775
814
|
autoComplete: "new-password",
|
|
776
815
|
isDisabled: E,
|
|
777
|
-
value:
|
|
778
|
-
onChange:
|
|
816
|
+
value: S,
|
|
817
|
+
onChange: C,
|
|
779
818
|
validate: (e) => {
|
|
780
819
|
if (!e) return f.auth.fieldRequired;
|
|
781
820
|
let t = d?.minPasswordLength, n = d?.maxPasswordLength;
|
|
@@ -785,22 +824,22 @@ function ot({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
785
824
|
children: [
|
|
786
825
|
/* @__PURE__ */ Q(B, { children: f.auth.password }),
|
|
787
826
|
/* @__PURE__ */ $(z, {
|
|
788
|
-
variant:
|
|
827
|
+
variant: a === "transparent" ? "primary" : "secondary",
|
|
789
828
|
children: [/* @__PURE__ */ Q(z.Input, {
|
|
790
829
|
placeholder: f.auth.passwordPlaceholder,
|
|
791
|
-
type:
|
|
830
|
+
type: ne ? "text" : "password",
|
|
792
831
|
name: "password",
|
|
793
832
|
required: !0
|
|
794
833
|
}), /* @__PURE__ */ Q(z.Suffix, {
|
|
795
834
|
className: "px-0",
|
|
796
835
|
children: /* @__PURE__ */ Q(k, {
|
|
797
836
|
isIconOnly: !0,
|
|
798
|
-
"aria-label":
|
|
837
|
+
"aria-label": ne ? f.auth.hidePassword : f.auth.showPassword,
|
|
799
838
|
size: "sm",
|
|
800
839
|
variant: "ghost",
|
|
801
|
-
onPress: () => re(!
|
|
840
|
+
onPress: () => re(!ne),
|
|
802
841
|
isDisabled: E,
|
|
803
|
-
children: Q(
|
|
842
|
+
children: Q(ne ? O : D, {})
|
|
804
843
|
})
|
|
805
844
|
})]
|
|
806
845
|
}),
|
|
@@ -813,8 +852,8 @@ function ot({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
813
852
|
name: "confirmPassword",
|
|
814
853
|
autoComplete: "new-password",
|
|
815
854
|
isDisabled: E,
|
|
816
|
-
value:
|
|
817
|
-
onChange:
|
|
855
|
+
value: ee,
|
|
856
|
+
onChange: w,
|
|
818
857
|
validate: (e) => {
|
|
819
858
|
if (!e) return f.auth.fieldRequired;
|
|
820
859
|
let t = d?.minPasswordLength, n = d?.maxPasswordLength;
|
|
@@ -824,7 +863,7 @@ function ot({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
824
863
|
children: [
|
|
825
864
|
/* @__PURE__ */ Q(B, { children: f.auth.confirmPassword }),
|
|
826
865
|
/* @__PURE__ */ $(z, {
|
|
827
|
-
variant:
|
|
866
|
+
variant: a === "transparent" ? "primary" : "secondary",
|
|
828
867
|
children: [/* @__PURE__ */ Q(z.Input, {
|
|
829
868
|
name: "confirmPassword",
|
|
830
869
|
placeholder: f.auth.confirmPasswordPlaceholder,
|
|
@@ -846,11 +885,11 @@ function ot({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
846
885
|
/* @__PURE__ */ Q(F, {})
|
|
847
886
|
]
|
|
848
887
|
}),
|
|
849
|
-
s?.map((e) => e.signUp && e.signUp !== "above" && /* @__PURE__ */ Q(
|
|
888
|
+
s?.map((e) => e.signUp && e.signUp !== "above" && /* @__PURE__ */ Q(Qe, {
|
|
850
889
|
name: e.name,
|
|
851
890
|
field: e,
|
|
852
891
|
isPending: E,
|
|
853
|
-
variant:
|
|
892
|
+
variant: a
|
|
854
893
|
}, e.name)),
|
|
855
894
|
se && /* @__PURE__ */ Q("div", {
|
|
856
895
|
className: "flex justify-center",
|
|
@@ -862,7 +901,7 @@ function ot({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
862
901
|
type: "submit",
|
|
863
902
|
className: "w-full",
|
|
864
903
|
isPending: E,
|
|
865
|
-
children: [
|
|
904
|
+
children: [T && /* @__PURE__ */ Q(W, {
|
|
866
905
|
color: "current",
|
|
867
906
|
size: "sm"
|
|
868
907
|
}), f.auth.signUp]
|
|
@@ -870,7 +909,7 @@ function ot({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
870
909
|
})
|
|
871
910
|
]
|
|
872
911
|
}),
|
|
873
|
-
|
|
912
|
+
r === "bottom" && /* @__PURE__ */ $(Z, { children: [le && /* @__PURE__ */ Q(e, { children: f.auth.or }), !!g?.length && /* @__PURE__ */ Q(i, { socialLayout: n })] })
|
|
874
913
|
]
|
|
875
914
|
}),
|
|
876
915
|
/* @__PURE__ */ Q(j.Footer, {
|
|
@@ -892,62 +931,50 @@ function ot({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
892
931
|
});
|
|
893
932
|
}
|
|
894
933
|
//#endregion
|
|
895
|
-
//#region src/components/auth/open-email-button.tsx
|
|
896
|
-
function st({ email: e, className: t }) {
|
|
897
|
-
let { localization: n } = h(), r = c(e);
|
|
898
|
-
return r ? /* @__PURE__ */ $(V, {
|
|
899
|
-
href: r.loginUrl,
|
|
900
|
-
target: "_blank",
|
|
901
|
-
rel: "noopener noreferrer",
|
|
902
|
-
className: q(Ye({ variant: "primary" }), "w-full gap-2", t),
|
|
903
|
-
children: [n.auth.openEmailProvider.replace("{{provider}}", r.companyProvider), /* @__PURE__ */ Q(ce, { className: "size-3" })]
|
|
904
|
-
}) : null;
|
|
905
|
-
}
|
|
906
|
-
//#endregion
|
|
907
934
|
//#region src/components/auth/verify-email.tsx
|
|
908
|
-
var
|
|
909
|
-
function
|
|
910
|
-
let { authClient: n, basePaths:
|
|
935
|
+
var st = 60;
|
|
936
|
+
function ct({ className: e, variant: t }) {
|
|
937
|
+
let { authClient: n, basePaths: i, baseURL: a, localization: o, redirectTo: s, viewPaths: c } = h(), [l, u] = X(Pe() && sessionStorage.getItem("better-auth-ui.verify-email") || ""), [d, f] = X(st);
|
|
911
938
|
Y(() => {
|
|
912
|
-
|
|
939
|
+
u(sessionStorage.getItem("better-auth-ui.verify-email") ?? "");
|
|
913
940
|
}, []), Y(() => {
|
|
914
|
-
if (
|
|
941
|
+
if (d <= 0 || !l) return;
|
|
915
942
|
let e = setInterval(() => {
|
|
916
|
-
|
|
943
|
+
f((e) => e > 0 ? e - 1 : 0);
|
|
917
944
|
}, 1e3);
|
|
918
945
|
return () => clearInterval(e);
|
|
919
|
-
}, [
|
|
920
|
-
let { mutate:
|
|
921
|
-
J.success(
|
|
922
|
-
} }),
|
|
946
|
+
}, [d, l]);
|
|
947
|
+
let { mutate: p, isPending: m } = te(n, { onSuccess: () => {
|
|
948
|
+
J.success(o.auth.verificationEmailSent), f(st);
|
|
949
|
+
} }), g = d > 0;
|
|
923
950
|
return /* @__PURE__ */ $(j, {
|
|
924
951
|
className: q("w-full max-w-sm gap-4 md:p-6", e),
|
|
925
952
|
variant: t,
|
|
926
953
|
children: [
|
|
927
954
|
/* @__PURE__ */ Q(j.Header, { children: /* @__PURE__ */ Q(j.Title, {
|
|
928
955
|
className: "text-xl font-semibold mb-1",
|
|
929
|
-
children:
|
|
956
|
+
children: o.auth.verifyEmail
|
|
930
957
|
}) }),
|
|
931
958
|
/* @__PURE__ */ $(j.Content, {
|
|
932
959
|
className: "gap-4",
|
|
933
960
|
children: [/* @__PURE__ */ Q(N, {
|
|
934
961
|
className: "text-sm",
|
|
935
|
-
children:
|
|
936
|
-
}),
|
|
962
|
+
children: o.auth.checkYourEmail
|
|
963
|
+
}), l && /* @__PURE__ */ $("div", {
|
|
937
964
|
className: "flex flex-col gap-3",
|
|
938
|
-
children: [/* @__PURE__ */ Q(
|
|
965
|
+
children: [/* @__PURE__ */ Q(r, { email: l }), /* @__PURE__ */ $(k, {
|
|
939
966
|
className: "w-full",
|
|
940
967
|
variant: "tertiary",
|
|
941
|
-
isDisabled: !
|
|
942
|
-
isPending:
|
|
943
|
-
onPress: () =>
|
|
944
|
-
email:
|
|
945
|
-
callbackURL: `${
|
|
968
|
+
isDisabled: !l || g || m,
|
|
969
|
+
isPending: m,
|
|
970
|
+
onPress: () => p({
|
|
971
|
+
email: l,
|
|
972
|
+
callbackURL: `${a}${s}`
|
|
946
973
|
}),
|
|
947
|
-
children: [
|
|
974
|
+
children: [m && /* @__PURE__ */ Q(W, {
|
|
948
975
|
color: "current",
|
|
949
976
|
size: "sm"
|
|
950
|
-
}),
|
|
977
|
+
}), g ? o.auth.resendIn.replace("{{seconds}}", String(d)) : o.auth.resend]
|
|
951
978
|
})]
|
|
952
979
|
})]
|
|
953
980
|
}),
|
|
@@ -956,12 +983,12 @@ function lt({ className: e, variant: t }) {
|
|
|
956
983
|
children: /* @__PURE__ */ $(N, {
|
|
957
984
|
className: "text-sm",
|
|
958
985
|
children: [
|
|
959
|
-
|
|
986
|
+
o.auth.alreadyVerifiedYourEmail,
|
|
960
987
|
" ",
|
|
961
988
|
/* @__PURE__ */ Q(V, {
|
|
962
|
-
href: `${
|
|
989
|
+
href: `${i.auth}/${c.auth.signIn}`,
|
|
963
990
|
className: "text-accent no-underline hover:underline decoration-accent-hover",
|
|
964
|
-
children:
|
|
991
|
+
children: o.auth.signIn
|
|
965
992
|
})
|
|
966
993
|
]
|
|
967
994
|
})
|
|
@@ -971,22 +998,24 @@ function lt({ className: e, variant: t }) {
|
|
|
971
998
|
}
|
|
972
999
|
//#endregion
|
|
973
1000
|
//#region src/components/auth/auth.tsx
|
|
974
|
-
var
|
|
1001
|
+
var lt = [
|
|
975
1002
|
"signUp",
|
|
976
1003
|
"forgotPassword",
|
|
977
|
-
"resetPassword"
|
|
978
|
-
|
|
1004
|
+
"resetPassword",
|
|
1005
|
+
"resetLinkSent"
|
|
1006
|
+
], ut = {
|
|
979
1007
|
signIn: it,
|
|
980
1008
|
signOut: at,
|
|
981
1009
|
signUp: ot,
|
|
982
1010
|
forgotPassword: nt,
|
|
983
1011
|
resetPassword: rt,
|
|
984
|
-
|
|
1012
|
+
resetLinkSent: tt,
|
|
1013
|
+
verifyEmail: ct
|
|
985
1014
|
};
|
|
986
|
-
function
|
|
1015
|
+
function dt({ className: e, path: t, socialLayout: n, socialPosition: r, variant: i, view: a }) {
|
|
987
1016
|
let { basePaths: o, emailAndPassword: s, plugins: c, viewPaths: l, navigate: u } = h();
|
|
988
1017
|
if (!a && !t) throw Error("[Better Auth UI] Either `view` or `path` must be provided");
|
|
989
|
-
let d = a || Object.keys(l.auth).find((e) => l.auth[e] === t), f = !s?.enabled && d &&
|
|
1018
|
+
let d = a || Object.keys(l.auth).find((e) => l.auth[e] === t), f = !s?.enabled && d && lt.includes(d);
|
|
990
1019
|
if (Y(() => {
|
|
991
1020
|
f && u({
|
|
992
1021
|
to: `${o.auth}/${l.auth.signIn}`,
|
|
@@ -1018,8 +1047,8 @@ function ft({ className: e, path: t, socialLayout: n, socialPosition: r, variant
|
|
|
1018
1047
|
variant: i
|
|
1019
1048
|
});
|
|
1020
1049
|
}
|
|
1021
|
-
let p = d ?
|
|
1022
|
-
if (!p) throw Error(`[Better Auth UI] Unknown view "${d}". Valid views are: ${Object.keys(
|
|
1050
|
+
let p = d ? ut[d] : void 0;
|
|
1051
|
+
if (!p) throw Error(`[Better Auth UI] Unknown view "${d}". Valid views are: ${Object.keys(ut).join(", ")}`);
|
|
1023
1052
|
return /* @__PURE__ */ Q(p, {
|
|
1024
1053
|
className: e,
|
|
1025
1054
|
socialLayout: n,
|
|
@@ -1029,18 +1058,18 @@ function ft({ className: e, path: t, socialLayout: n, socialPosition: r, variant
|
|
|
1029
1058
|
}
|
|
1030
1059
|
//#endregion
|
|
1031
1060
|
//#region src/components/auth/error-toaster.tsx
|
|
1032
|
-
function
|
|
1033
|
-
let e =
|
|
1061
|
+
function ft() {
|
|
1062
|
+
let e = qe();
|
|
1034
1063
|
return Y(() => {
|
|
1035
1064
|
let t = e.getQueryCache(), n = t.config.onError;
|
|
1036
1065
|
t.config.onError = (e, t) => {
|
|
1037
|
-
if (n?.(e, t), !
|
|
1066
|
+
if (n?.(e, t), !Ge({ queryKey: s.all }, t)) return;
|
|
1038
1067
|
let r = e;
|
|
1039
1068
|
r?.error?.code !== "EMAIL_NOT_VERIFIED" && r?.error && J.danger(r.error.message);
|
|
1040
1069
|
};
|
|
1041
1070
|
let r = e.getMutationCache(), i = r.config.onError;
|
|
1042
|
-
return r.config.onError = (e, t, n, r,
|
|
1043
|
-
if (i?.(e, t, n, r,
|
|
1071
|
+
return r.config.onError = (e, t, n, r, a) => {
|
|
1072
|
+
if (i?.(e, t, n, r, a), !We({ mutationKey: o.all }, r)) return;
|
|
1044
1073
|
let s = e;
|
|
1045
1074
|
s.error?.code !== "EMAIL_NOT_VERIFIED" && J.danger(s.error?.message || s.message);
|
|
1046
1075
|
}, () => {
|
|
@@ -1050,20 +1079,20 @@ function pt() {
|
|
|
1050
1079
|
}
|
|
1051
1080
|
//#endregion
|
|
1052
1081
|
//#region src/components/auth/auth-provider.tsx
|
|
1053
|
-
function
|
|
1082
|
+
function pt({ children: e, navigate: t, ...n }) {
|
|
1054
1083
|
return /* @__PURE__ */ Q(f, {
|
|
1055
1084
|
navigate: t,
|
|
1056
1085
|
...n,
|
|
1057
|
-
children: /* @__PURE__ */ $(
|
|
1086
|
+
children: /* @__PURE__ */ $(Oe, {
|
|
1058
1087
|
navigate: (e) => t({ to: e }),
|
|
1059
|
-
children: [e, /* @__PURE__ */ Q(
|
|
1088
|
+
children: [e, /* @__PURE__ */ Q(ft, {})]
|
|
1060
1089
|
})
|
|
1061
1090
|
});
|
|
1062
1091
|
}
|
|
1063
1092
|
//#endregion
|
|
1064
1093
|
//#region src/components/auth/settings/account/change-email.tsx
|
|
1065
|
-
function
|
|
1066
|
-
let { authClient: r, localization: i, baseURL: a, viewPaths: o } = h(), { data: s } =
|
|
1094
|
+
function mt({ className: e, variant: t, ...n }) {
|
|
1095
|
+
let { authClient: r, localization: i, baseURL: a, viewPaths: o } = h(), { data: s } = T(r), { mutate: c, isPending: l } = _(r, { onSuccess: () => J.success(i.settings.changeEmailSuccess) });
|
|
1067
1096
|
function u(e) {
|
|
1068
1097
|
e.preventDefault(), c({
|
|
1069
1098
|
newEmail: new FormData(e.currentTarget).get("email"),
|
|
@@ -1112,15 +1141,15 @@ function ht({ className: e, variant: t, ...n }) {
|
|
|
1112
1141
|
}
|
|
1113
1142
|
//#endregion
|
|
1114
1143
|
//#region src/components/auth/settings/account/change-avatar.tsx
|
|
1115
|
-
function
|
|
1116
|
-
let { authClient: t, localization: r, avatar: i } = h(), { data: a } =
|
|
1144
|
+
function ht({ className: e }) {
|
|
1145
|
+
let { authClient: t, localization: r, avatar: i } = h(), { data: a } = T(t), { mutate: o, isPending: s } = oe(t), l = Ue(null), [u, d] = X(!1), [f, p] = X(!1), m = s || u || f;
|
|
1117
1146
|
async function g(e) {
|
|
1118
1147
|
let t = e.target.files?.[0];
|
|
1119
1148
|
if (t) {
|
|
1120
1149
|
e.target.value = "", d(!0);
|
|
1121
1150
|
try {
|
|
1122
1151
|
let e = await i.resize?.(t, i.size, i.extension) || t;
|
|
1123
|
-
o({ image: await i.upload?.(e) || await
|
|
1152
|
+
o({ image: await i.upload?.(e) || await c(e) }, { onSuccess: () => J.success(r.settings.avatarChangedSuccess) });
|
|
1124
1153
|
} catch (e) {
|
|
1125
1154
|
e instanceof Error && J.danger(e.message);
|
|
1126
1155
|
}
|
|
@@ -1178,13 +1207,13 @@ function gt({ className: e }) {
|
|
|
1178
1207
|
children: /* @__PURE__ */ $(P.Menu, { children: [/* @__PURE__ */ $(P.Item, {
|
|
1179
1208
|
textValue: r.settings.uploadAvatar,
|
|
1180
1209
|
onAction: () => l.current?.click(),
|
|
1181
|
-
children: [/* @__PURE__ */ Q(
|
|
1210
|
+
children: [/* @__PURE__ */ Q(ue, { className: "text-muted" }), /* @__PURE__ */ Q(B, { children: r.settings.uploadAvatar })]
|
|
1182
1211
|
}), /* @__PURE__ */ $(P.Item, {
|
|
1183
1212
|
textValue: r.settings.deleteAvatar,
|
|
1184
1213
|
isDisabled: !a?.user.image,
|
|
1185
1214
|
onAction: _,
|
|
1186
1215
|
variant: "danger",
|
|
1187
|
-
children: [/* @__PURE__ */ Q(
|
|
1216
|
+
children: [/* @__PURE__ */ Q(xe, { className: "text-danger" }), /* @__PURE__ */ Q(B, { children: r.settings.deleteAvatar })]
|
|
1188
1217
|
})] })
|
|
1189
1218
|
})] })]
|
|
1190
1219
|
})
|
|
@@ -1193,8 +1222,8 @@ function gt({ className: e }) {
|
|
|
1193
1222
|
}
|
|
1194
1223
|
//#endregion
|
|
1195
1224
|
//#region src/components/auth/settings/account/user-profile.tsx
|
|
1196
|
-
function
|
|
1197
|
-
let { additionalFields: r, authClient: i, localization: a } = h(), { data: o } =
|
|
1225
|
+
function gt({ className: e, variant: t, ...n }) {
|
|
1226
|
+
let { additionalFields: r, authClient: i, localization: a } = h(), { data: o } = T(i), { mutate: s, isPending: c } = oe(i, { onSuccess: () => J.success(a.settings.profileUpdatedSuccess) });
|
|
1198
1227
|
async function l(e) {
|
|
1199
1228
|
e.preventDefault();
|
|
1200
1229
|
let t = new FormData(e.currentTarget), n = t.get("name"), i = {};
|
|
@@ -1225,7 +1254,7 @@ function _t({ className: e, variant: t, ...n }) {
|
|
|
1225
1254
|
onSubmit: l,
|
|
1226
1255
|
className: "flex flex-col gap-4",
|
|
1227
1256
|
children: [
|
|
1228
|
-
/* @__PURE__ */ Q(
|
|
1257
|
+
/* @__PURE__ */ Q(ht, {}),
|
|
1229
1258
|
/* @__PURE__ */ $(K, {
|
|
1230
1259
|
name: "name",
|
|
1231
1260
|
defaultValue: o?.user.name,
|
|
@@ -1245,7 +1274,7 @@ function _t({ className: e, variant: t, ...n }) {
|
|
|
1245
1274
|
r?.filter((e) => e.profile !== !1).map((e) => {
|
|
1246
1275
|
if (!o) return e.inputType === "hidden" ? null : /* @__PURE__ */ Q(U, { className: "h-10 md:h-9 w-full rounded-xl" }, e.name);
|
|
1247
1276
|
let n = o.user[e.name], r = `${o.user.id}-${e.name}-${n instanceof Date ? n.toISOString() : String(n ?? "")}`;
|
|
1248
|
-
return /* @__PURE__ */ Q(
|
|
1277
|
+
return /* @__PURE__ */ Q(Qe, {
|
|
1249
1278
|
name: e.name,
|
|
1250
1279
|
field: {
|
|
1251
1280
|
...e,
|
|
@@ -1272,21 +1301,21 @@ function _t({ className: e, variant: t, ...n }) {
|
|
|
1272
1301
|
}
|
|
1273
1302
|
//#endregion
|
|
1274
1303
|
//#region src/components/auth/settings/account/account-settings.tsx
|
|
1275
|
-
function
|
|
1304
|
+
function _t({ className: e, variant: t, ...n }) {
|
|
1276
1305
|
let { emailAndPassword: r, plugins: i } = h(), a = i.some((e) => e.id === "magicLink");
|
|
1277
1306
|
return /* @__PURE__ */ $("div", {
|
|
1278
1307
|
className: q("flex w-full flex-col gap-4 md:gap-6", e),
|
|
1279
1308
|
...n,
|
|
1280
1309
|
children: [
|
|
1281
|
-
/* @__PURE__ */ Q(
|
|
1282
|
-
(r?.enabled || a) && /* @__PURE__ */ Q(
|
|
1310
|
+
/* @__PURE__ */ Q(gt, { variant: t }),
|
|
1311
|
+
(r?.enabled || a) && /* @__PURE__ */ Q(mt, { variant: t }),
|
|
1283
1312
|
i.flatMap((e) => e.accountCards?.map((n, r) => /* @__PURE__ */ Q(n, { variant: t }, `${e.id}-${r.toString()}`)))
|
|
1284
1313
|
]
|
|
1285
1314
|
});
|
|
1286
1315
|
}
|
|
1287
1316
|
//#endregion
|
|
1288
1317
|
//#region src/components/auth/settings/security/active-session.tsx
|
|
1289
|
-
function
|
|
1318
|
+
function vt(e) {
|
|
1290
1319
|
let t = Math.floor((Date.now() - e.getTime()) / 1e3), n = new Intl.RelativeTimeFormat(void 0, { numeric: "auto" });
|
|
1291
1320
|
for (let [e, r] of [
|
|
1292
1321
|
["year", 31536e3],
|
|
@@ -1299,27 +1328,27 @@ function yt(e) {
|
|
|
1299
1328
|
]) if (t >= r) return n.format(-Math.floor(t / r), e);
|
|
1300
1329
|
return n.format(0, "second");
|
|
1301
1330
|
}
|
|
1302
|
-
function
|
|
1303
|
-
let { authClient: t, basePaths: n, localization: r, viewPaths: i, navigate: a } = h(), { data: o } =
|
|
1331
|
+
function yt({ activeSession: e }) {
|
|
1332
|
+
let { authClient: t, basePaths: n, localization: r, viewPaths: i, navigate: a } = h(), { data: o } = T(t, { refetchOnMount: !1 }), { mutate: s, isPending: c } = w(t, { onSuccess: () => J.success(r.settings.revokeSessionSuccess) }), l = e.token === o?.session.token, u = Je.parse(e.userAgent || "");
|
|
1304
1333
|
return /* @__PURE__ */ $("div", {
|
|
1305
1334
|
className: "flex items-center gap-3",
|
|
1306
1335
|
children: [
|
|
1307
1336
|
/* @__PURE__ */ Q("div", {
|
|
1308
1337
|
className: "flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-secondary",
|
|
1309
|
-
children: u.platform.type === "mobile" || u.platform.type === "tablet" ? /* @__PURE__ */ Q(
|
|
1338
|
+
children: u.platform.type === "mobile" || u.platform.type === "tablet" ? /* @__PURE__ */ Q(be, { className: "size-4.5" }) : /* @__PURE__ */ Q(fe, { className: "size-4.5" })
|
|
1310
1339
|
}),
|
|
1311
1340
|
/* @__PURE__ */ $("div", {
|
|
1312
1341
|
className: "flex flex-col min-w-0",
|
|
1313
1342
|
children: [/* @__PURE__ */ $("span", {
|
|
1314
1343
|
className: "text-sm font-medium truncate",
|
|
1315
1344
|
children: [u.browser.name || "Unknown Browser", u.os.name ? `, ${u.os.name}` : ""]
|
|
1316
|
-
}), l ? /* @__PURE__ */ Q(
|
|
1345
|
+
}), l ? /* @__PURE__ */ Q(Ce, {
|
|
1317
1346
|
color: "accent",
|
|
1318
1347
|
size: "sm",
|
|
1319
1348
|
children: r.settings.currentSession
|
|
1320
1349
|
}) : e.createdAt && /* @__PURE__ */ Q("span", {
|
|
1321
1350
|
className: "text-xs text-muted capitalize",
|
|
1322
|
-
children:
|
|
1351
|
+
children: vt(e.createdAt)
|
|
1323
1352
|
})]
|
|
1324
1353
|
}),
|
|
1325
1354
|
/* @__PURE__ */ $(k, {
|
|
@@ -1332,15 +1361,15 @@ function bt({ activeSession: e }) {
|
|
|
1332
1361
|
children: [c ? /* @__PURE__ */ Q(W, {
|
|
1333
1362
|
color: "current",
|
|
1334
1363
|
size: "sm"
|
|
1335
|
-
}) : Q(l ? E :
|
|
1364
|
+
}) : Q(l ? E : Se, {}), l ? r.auth.signOut : r.settings.revoke]
|
|
1336
1365
|
})
|
|
1337
1366
|
]
|
|
1338
1367
|
});
|
|
1339
1368
|
}
|
|
1340
1369
|
//#endregion
|
|
1341
1370
|
//#region src/components/auth/settings/security/active-sessions.tsx
|
|
1342
|
-
function
|
|
1343
|
-
let { authClient: r, localization: i } = h(), { data: a } =
|
|
1371
|
+
function bt({ className: e, variant: t, ...n }) {
|
|
1372
|
+
let { authClient: r, localization: i } = h(), { data: a } = T(r), { data: o, isPending: s } = S(r), c = o && [...o].sort((e, t) => e.id === a?.session.id ? -1 : +(t.id === a?.session.id));
|
|
1344
1373
|
return /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q("h2", {
|
|
1345
1374
|
className: q("text-sm font-semibold mb-3"),
|
|
1346
1375
|
children: i.settings.activeSessions
|
|
@@ -1350,11 +1379,11 @@ function xt({ className: e, variant: t, ...n }) {
|
|
|
1350
1379
|
...n,
|
|
1351
1380
|
children: /* @__PURE__ */ Q(j.Content, {
|
|
1352
1381
|
className: "gap-0",
|
|
1353
|
-
children: s ? /* @__PURE__ */ Q(
|
|
1382
|
+
children: s ? /* @__PURE__ */ Q(xt, {}) : c?.map((e, t) => /* @__PURE__ */ $("div", { children: [t > 0 && /* @__PURE__ */ Q("div", { className: "border-b border-dashed -mx-4 my-4" }), /* @__PURE__ */ Q(yt, { activeSession: e })] }, e.id))
|
|
1354
1383
|
})
|
|
1355
1384
|
})] });
|
|
1356
1385
|
}
|
|
1357
|
-
function
|
|
1386
|
+
function xt() {
|
|
1358
1387
|
return /* @__PURE__ */ Q("div", {
|
|
1359
1388
|
className: "flex items-center justify-between",
|
|
1360
1389
|
children: /* @__PURE__ */ $("div", {
|
|
@@ -1368,13 +1397,13 @@ function St() {
|
|
|
1368
1397
|
}
|
|
1369
1398
|
//#endregion
|
|
1370
1399
|
//#region src/components/auth/settings/security/change-password.tsx
|
|
1371
|
-
function
|
|
1372
|
-
let { authClient: r, emailAndPassword: i, localization: a } = h(), { data: o } =
|
|
1373
|
-
return !c && !l ? /* @__PURE__ */ Q(
|
|
1400
|
+
function St({ className: e, variant: t, ...n }) {
|
|
1401
|
+
let { authClient: r, emailAndPassword: i, localization: a } = h(), { data: o } = T(r), { data: s, isPending: c } = x(r), l = s?.some((e) => e.providerId === "credential");
|
|
1402
|
+
return !c && !l ? /* @__PURE__ */ Q(Ct, {
|
|
1374
1403
|
className: e,
|
|
1375
1404
|
variant: t,
|
|
1376
1405
|
...n
|
|
1377
|
-
}) : /* @__PURE__ */ Q(
|
|
1406
|
+
}) : /* @__PURE__ */ Q(wt, {
|
|
1378
1407
|
className: e,
|
|
1379
1408
|
variant: t,
|
|
1380
1409
|
emailAndPassword: i,
|
|
@@ -1383,21 +1412,23 @@ function Ct({ className: e, variant: t, ...n }) {
|
|
|
1383
1412
|
...n
|
|
1384
1413
|
});
|
|
1385
1414
|
}
|
|
1386
|
-
function
|
|
1387
|
-
let { authClient:
|
|
1415
|
+
function Ct({ className: e, variant: t, ...n }) {
|
|
1416
|
+
let { authClient: i, localization: a, plugins: o } = h(), { data: s } = T(i), { fetchOptions: c, resetFetchOptions: l } = y(), [u, d] = X(""), { mutate: f, isPending: p } = C(i, {
|
|
1388
1417
|
onError: () => {
|
|
1389
|
-
|
|
1418
|
+
l();
|
|
1390
1419
|
},
|
|
1391
|
-
onSuccess: () =>
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1420
|
+
onSuccess: (e, { email: t }) => {
|
|
1421
|
+
d(t);
|
|
1422
|
+
}
|
|
1423
|
+
}), m = o.find((e) => e.captchaComponent)?.captchaComponent, g = () => {
|
|
1424
|
+
s?.user.email && f({
|
|
1425
|
+
email: s.user.email,
|
|
1426
|
+
fetchOptions: c
|
|
1396
1427
|
});
|
|
1397
1428
|
};
|
|
1398
1429
|
return /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q("h2", {
|
|
1399
1430
|
className: q("text-sm font-semibold mb-3"),
|
|
1400
|
-
children:
|
|
1431
|
+
children: a.settings.changePassword
|
|
1401
1432
|
}), /* @__PURE__ */ Q(j, {
|
|
1402
1433
|
className: q(e),
|
|
1403
1434
|
variant: t,
|
|
@@ -1406,27 +1437,37 @@ function wt({ className: e, variant: t, ...n }) {
|
|
|
1406
1437
|
className: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",
|
|
1407
1438
|
children: [/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q("p", {
|
|
1408
1439
|
className: "text-sm font-medium leading-tight",
|
|
1409
|
-
children:
|
|
1440
|
+
children: a.settings.setPassword
|
|
1410
1441
|
}), /* @__PURE__ */ Q("p", {
|
|
1411
1442
|
className: "text-muted text-xs mt-0.5",
|
|
1412
|
-
children:
|
|
1413
|
-
})] }), /* @__PURE__ */ $("div", {
|
|
1443
|
+
children: a.settings.setPasswordDescription
|
|
1444
|
+
})] }), u ? /* @__PURE__ */ $("div", {
|
|
1445
|
+
className: "flex flex-col gap-3 items-start sm:items-end",
|
|
1446
|
+
children: [/* @__PURE__ */ Q("p", {
|
|
1447
|
+
className: "text-sm",
|
|
1448
|
+
role: "status",
|
|
1449
|
+
children: a.auth.resetLinkSentTo.replace("{{email}}", u)
|
|
1450
|
+
}), /* @__PURE__ */ Q(r, {
|
|
1451
|
+
email: u,
|
|
1452
|
+
className: "w-auto"
|
|
1453
|
+
})]
|
|
1454
|
+
}) : /* @__PURE__ */ $("div", {
|
|
1414
1455
|
className: "flex flex-col gap-3 items-start sm:items-end",
|
|
1415
|
-
children: [
|
|
1456
|
+
children: [m && /* @__PURE__ */ Q("div", { children: m }), /* @__PURE__ */ $(k, {
|
|
1416
1457
|
size: "sm",
|
|
1417
|
-
isPending:
|
|
1418
|
-
isDisabled: !
|
|
1419
|
-
onPress:
|
|
1420
|
-
children: [
|
|
1458
|
+
isPending: p,
|
|
1459
|
+
isDisabled: !s?.user.email,
|
|
1460
|
+
onPress: g,
|
|
1461
|
+
children: [p && /* @__PURE__ */ Q(W, {
|
|
1421
1462
|
color: "current",
|
|
1422
1463
|
size: "sm"
|
|
1423
|
-
}),
|
|
1464
|
+
}), a.auth.sendResetLink]
|
|
1424
1465
|
})]
|
|
1425
1466
|
})]
|
|
1426
1467
|
})
|
|
1427
1468
|
})] });
|
|
1428
1469
|
}
|
|
1429
|
-
function
|
|
1470
|
+
function wt({ className: e, variant: t, emailAndPassword: n, localization: r, session: i, ...a }) {
|
|
1430
1471
|
let { authClient: o } = h(), [s, c] = X(""), [l, u] = X(""), [d, f] = X(""), { mutate: p, isPending: m } = v(o, {
|
|
1431
1472
|
onError: () => {
|
|
1432
1473
|
c(""), u(""), f("");
|
|
@@ -1562,14 +1603,14 @@ function Tt({ className: e, variant: t, emailAndPassword: n, localization: r, se
|
|
|
1562
1603
|
}
|
|
1563
1604
|
//#endregion
|
|
1564
1605
|
//#region src/components/auth/settings/security/linked-account.tsx
|
|
1565
|
-
function
|
|
1606
|
+
function Tt({ account: e, provider: t }) {
|
|
1566
1607
|
let { authClient: n, baseURL: r, localization: i } = h(), { data: a, isPending: o } = m(n, { query: { accountId: e?.accountId } }), { mutate: s, isPending: c } = b(n), { mutate: u, isPending: d } = ae(n, { onSuccess: () => J.success(i.settings.accountUnlinked) }), f = p[t], g = l(t), _ = a?.data?.login || a?.data?.username || a?.user?.email || a?.user?.name || e?.accountId;
|
|
1567
1608
|
return /* @__PURE__ */ $("div", {
|
|
1568
1609
|
className: "flex items-center gap-3",
|
|
1569
1610
|
children: [
|
|
1570
1611
|
/* @__PURE__ */ Q("div", {
|
|
1571
1612
|
className: q("flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-secondary"),
|
|
1572
|
-
children: Q(f ||
|
|
1613
|
+
children: Q(f || ve, { className: "size-4.5" })
|
|
1573
1614
|
}),
|
|
1574
1615
|
/* @__PURE__ */ $("div", {
|
|
1575
1616
|
className: "flex flex-col min-w-0",
|
|
@@ -1591,7 +1632,7 @@ function Et({ account: e, provider: t }) {
|
|
|
1591
1632
|
children: [d ? /* @__PURE__ */ Q(W, {
|
|
1592
1633
|
color: "current",
|
|
1593
1634
|
size: "sm"
|
|
1594
|
-
}) : /* @__PURE__ */ Q(
|
|
1635
|
+
}) : /* @__PURE__ */ Q(he, {}), i.settings.unlinkProvider.replace("{{provider}}", "").trim()]
|
|
1595
1636
|
}) : /* @__PURE__ */ $(k, {
|
|
1596
1637
|
className: "ml-auto shrink-0",
|
|
1597
1638
|
variant: "outline",
|
|
@@ -1605,14 +1646,14 @@ function Et({ account: e, provider: t }) {
|
|
|
1605
1646
|
children: [c ? /* @__PURE__ */ Q(W, {
|
|
1606
1647
|
color: "current",
|
|
1607
1648
|
size: "sm"
|
|
1608
|
-
}) : /* @__PURE__ */ Q(
|
|
1649
|
+
}) : /* @__PURE__ */ Q(me, {}), i.settings.link]
|
|
1609
1650
|
})
|
|
1610
1651
|
]
|
|
1611
1652
|
});
|
|
1612
1653
|
}
|
|
1613
1654
|
//#endregion
|
|
1614
1655
|
//#region src/components/auth/settings/security/linked-accounts.tsx
|
|
1615
|
-
function
|
|
1656
|
+
function Et({ className: e, variant: t, ...n }) {
|
|
1616
1657
|
let { authClient: r, localization: i, multipleAccountsPerProvider: a, socialProviders: o } = h(), { data: s, isPending: c } = x(r), l = s?.filter((e) => e.providerId !== "credential"), u = new Set(l?.map((e) => e.providerId)), d = a === !1 ? o?.filter((e) => !u.has(e)) : o, f = [...l?.map((e) => ({
|
|
1617
1658
|
key: e.id,
|
|
1618
1659
|
account: e,
|
|
@@ -1631,14 +1672,14 @@ function Dt({ className: e, variant: t, ...n }) {
|
|
|
1631
1672
|
...n,
|
|
1632
1673
|
children: /* @__PURE__ */ Q(j.Content, {
|
|
1633
1674
|
className: "gap-0",
|
|
1634
|
-
children: c ? o?.map((e, t) => /* @__PURE__ */ $("div", { children: [t > 0 && /* @__PURE__ */ Q("div", { className: "border-b border-dashed -mx-4 my-4" }), /* @__PURE__ */ Q(
|
|
1675
|
+
children: c ? o?.map((e, t) => /* @__PURE__ */ $("div", { children: [t > 0 && /* @__PURE__ */ Q("div", { className: "border-b border-dashed -mx-4 my-4" }), /* @__PURE__ */ Q(Dt, {})] }, e)) : f.map((e, t) => /* @__PURE__ */ $("div", { children: [t > 0 && /* @__PURE__ */ Q("div", { className: "border-b border-dashed -mx-4 my-4" }), /* @__PURE__ */ Q(Tt, {
|
|
1635
1676
|
account: e.account,
|
|
1636
1677
|
provider: e.provider
|
|
1637
1678
|
})] }, e.key))
|
|
1638
1679
|
})
|
|
1639
1680
|
})] });
|
|
1640
1681
|
}
|
|
1641
|
-
function
|
|
1682
|
+
function Dt() {
|
|
1642
1683
|
return /* @__PURE__ */ Q("div", {
|
|
1643
1684
|
className: "flex items-center justify-between",
|
|
1644
1685
|
children: /* @__PURE__ */ $("div", {
|
|
@@ -1652,26 +1693,26 @@ function Ot() {
|
|
|
1652
1693
|
}
|
|
1653
1694
|
//#endregion
|
|
1654
1695
|
//#region src/components/auth/settings/security/security-settings.tsx
|
|
1655
|
-
function
|
|
1696
|
+
function Ot({ className: e, variant: t, ...n }) {
|
|
1656
1697
|
let { emailAndPassword: r, plugins: i, socialProviders: a } = h();
|
|
1657
1698
|
return /* @__PURE__ */ $("div", {
|
|
1658
1699
|
className: q("flex w-full flex-col gap-4 md:gap-6", e),
|
|
1659
1700
|
...n,
|
|
1660
1701
|
children: [
|
|
1661
|
-
r?.enabled && /* @__PURE__ */ Q(
|
|
1662
|
-
!!a?.length && /* @__PURE__ */ Q(
|
|
1663
|
-
/* @__PURE__ */ Q(
|
|
1702
|
+
r?.enabled && /* @__PURE__ */ Q(St, { variant: t }),
|
|
1703
|
+
!!a?.length && /* @__PURE__ */ Q(Et, { variant: t }),
|
|
1704
|
+
/* @__PURE__ */ Q(bt, { variant: t }),
|
|
1664
1705
|
i.flatMap((e) => e.securityCards?.map((n, r) => /* @__PURE__ */ Q(n, { variant: t }, `${e.id}-${r.toString()}`)))
|
|
1665
1706
|
]
|
|
1666
1707
|
});
|
|
1667
1708
|
}
|
|
1668
1709
|
//#endregion
|
|
1669
1710
|
//#region src/components/auth/settings/settings.tsx
|
|
1670
|
-
function
|
|
1711
|
+
function kt({ className: e, hideNav: t, path: n, variant: r, view: i, ...a }) {
|
|
1671
1712
|
if (!i && !n) throw Error("[Better Auth UI] Either `view` or `path` must be provided");
|
|
1672
1713
|
let { authClient: o, basePaths: s, localization: c, viewPaths: l, plugins: u } = h();
|
|
1673
1714
|
g(o);
|
|
1674
|
-
let d =
|
|
1715
|
+
let d = He(() => {
|
|
1675
1716
|
if (i) return i;
|
|
1676
1717
|
if (n) return [l.settings, ...u.map((e) => e.viewPaths?.settings)].flatMap((e) => Object.entries(e ?? {})).find(([, e]) => e === n)?.[0];
|
|
1677
1718
|
}, [
|
|
@@ -1703,7 +1744,7 @@ function At({ className: e, hideNav: t, path: n, variant: r, view: i, ...a }) {
|
|
|
1703
1744
|
inline: "center"
|
|
1704
1745
|
}),
|
|
1705
1746
|
children: [
|
|
1706
|
-
/* @__PURE__ */ Q(
|
|
1747
|
+
/* @__PURE__ */ Q(ge, { className: "text-muted" }),
|
|
1707
1748
|
c.settings.account,
|
|
1708
1749
|
/* @__PURE__ */ Q(G.Indicator, {})
|
|
1709
1750
|
]
|
|
@@ -1717,7 +1758,7 @@ function At({ className: e, hideNav: t, path: n, variant: r, view: i, ...a }) {
|
|
|
1717
1758
|
inline: "center"
|
|
1718
1759
|
}),
|
|
1719
1760
|
children: [
|
|
1720
|
-
/* @__PURE__ */ Q(
|
|
1761
|
+
/* @__PURE__ */ Q(ye, { className: "text-muted" }),
|
|
1721
1762
|
c.settings.security,
|
|
1722
1763
|
/* @__PURE__ */ Q(G.Indicator, {})
|
|
1723
1764
|
]
|
|
@@ -1737,12 +1778,12 @@ function At({ className: e, hideNav: t, path: n, variant: r, view: i, ...a }) {
|
|
|
1737
1778
|
/* @__PURE__ */ Q(G.Panel, {
|
|
1738
1779
|
id: "account",
|
|
1739
1780
|
className: "px-0",
|
|
1740
|
-
children: /* @__PURE__ */ Q(
|
|
1781
|
+
children: /* @__PURE__ */ Q(_t, { variant: r })
|
|
1741
1782
|
}),
|
|
1742
1783
|
/* @__PURE__ */ Q(G.Panel, {
|
|
1743
1784
|
id: "security",
|
|
1744
1785
|
className: "px-0",
|
|
1745
|
-
children: /* @__PURE__ */ Q(
|
|
1786
|
+
children: /* @__PURE__ */ Q(Ot, { variant: r })
|
|
1746
1787
|
}),
|
|
1747
1788
|
u.flatMap((e) => e.settingsTabs?.map((t, n) => /* @__PURE__ */ Q(G.Panel, {
|
|
1748
1789
|
id: t.view,
|
|
@@ -1754,8 +1795,8 @@ function At({ className: e, hideNav: t, path: n, variant: r, view: i, ...a }) {
|
|
|
1754
1795
|
}
|
|
1755
1796
|
//#endregion
|
|
1756
1797
|
//#region src/components/auth/user/user-button.tsx
|
|
1757
|
-
function
|
|
1758
|
-
if (
|
|
1798
|
+
function At(e, t) {
|
|
1799
|
+
if (Ve(e)) return e;
|
|
1759
1800
|
let { label: n, href: r, icon: i, variant: a } = e;
|
|
1760
1801
|
return /* @__PURE__ */ $(P.Item, {
|
|
1761
1802
|
href: r,
|
|
@@ -1764,39 +1805,39 @@ function jt(e, t) {
|
|
|
1764
1805
|
children: [i, /* @__PURE__ */ Q(B, { children: n })]
|
|
1765
1806
|
}, t);
|
|
1766
1807
|
}
|
|
1767
|
-
function
|
|
1768
|
-
let { authClient: l, basePaths: u, viewPaths: d, localization: f, plugins: p } = h(), { data: m, isPending: g } =
|
|
1769
|
-
if (!
|
|
1808
|
+
function jt({ className: e, placement: t, size: r = "default", variant: i = "ghost", links: o, hideSettings: s, hideSubtitle: c }) {
|
|
1809
|
+
let { authClient: l, basePaths: u, viewPaths: d, localization: f, plugins: p } = h(), { data: m, isPending: g } = T(l), _ = p.flatMap((e) => e.userMenuItems?.map((t, n) => /* @__PURE__ */ Q(t, { hideSubtitle: c }, `${e.id}-${n.toString()}`)) ?? []), v = o?.flatMap((e, t) => {
|
|
1810
|
+
if (!Ve(e)) {
|
|
1770
1811
|
let t = e.visibility ?? "always";
|
|
1771
1812
|
if (t === "authenticated" && !m || t === "unauthenticated" && m) return [];
|
|
1772
1813
|
}
|
|
1773
|
-
return [
|
|
1814
|
+
return [At(e, `user-button-link-${t.toString()}`)];
|
|
1774
1815
|
});
|
|
1775
1816
|
return /* @__PURE__ */ $(P, { children: [r === "icon" ? /* @__PURE__ */ Q(P.Trigger, {
|
|
1776
1817
|
className: q("rounded-full"),
|
|
1777
1818
|
children: /* @__PURE__ */ Q(n, { className: e })
|
|
1778
1819
|
}) : /* @__PURE__ */ $(k, {
|
|
1779
|
-
variant:
|
|
1820
|
+
variant: i,
|
|
1780
1821
|
className: q("h-auto font-normal justify-start px-2 py-2 text-left", e),
|
|
1781
|
-
children: [m || g ? /* @__PURE__ */ Q(
|
|
1822
|
+
children: [m || g ? /* @__PURE__ */ Q(a, {
|
|
1782
1823
|
isPending: g,
|
|
1783
1824
|
hideSubtitle: c
|
|
1784
1825
|
}) : /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q(n, {}), /* @__PURE__ */ Q("p", {
|
|
1785
1826
|
className: "text-sm font-medium",
|
|
1786
1827
|
children: f.auth.account
|
|
1787
|
-
})] }), /* @__PURE__ */ Q(
|
|
1828
|
+
})] }), /* @__PURE__ */ Q(le, { className: "ml-auto size-3 text-muted" })]
|
|
1788
1829
|
}), /* @__PURE__ */ $(P.Popover, {
|
|
1789
1830
|
placement: t,
|
|
1790
1831
|
className: "min-w-40 md:min-w-56 max-w-[48svw]",
|
|
1791
1832
|
children: [m && /* @__PURE__ */ Q("div", {
|
|
1792
1833
|
className: "px-3 pt-3 pb-1",
|
|
1793
|
-
children: /* @__PURE__ */ Q(
|
|
1834
|
+
children: /* @__PURE__ */ Q(a, { hideSubtitle: c })
|
|
1794
1835
|
}), /* @__PURE__ */ Q(P.Menu, { children: m ? /* @__PURE__ */ $(Z, { children: [
|
|
1795
1836
|
v,
|
|
1796
1837
|
!s && /* @__PURE__ */ $(P.Item, {
|
|
1797
1838
|
textValue: f.settings.settings,
|
|
1798
1839
|
href: `${u.settings}/${d.settings.account}`,
|
|
1799
|
-
children: [/* @__PURE__ */ Q(
|
|
1840
|
+
children: [/* @__PURE__ */ Q(pe, { className: "text-muted" }), /* @__PURE__ */ Q(B, { children: f.settings.settings })]
|
|
1800
1841
|
}),
|
|
1801
1842
|
_,
|
|
1802
1843
|
/* @__PURE__ */ $(P.Item, {
|
|
@@ -1815,11 +1856,11 @@ function Mt({ className: e, placement: t, size: r = "default", variant: a = "gho
|
|
|
1815
1856
|
/* @__PURE__ */ $(P.Item, {
|
|
1816
1857
|
textValue: f.auth.signUp,
|
|
1817
1858
|
href: `${u.auth}/${d.auth.signUp}`,
|
|
1818
|
-
children: [/* @__PURE__ */ Q(
|
|
1859
|
+
children: [/* @__PURE__ */ Q(_e, { className: "text-muted" }), /* @__PURE__ */ Q(B, { children: f.auth.signUp })]
|
|
1819
1860
|
}),
|
|
1820
1861
|
_
|
|
1821
1862
|
] }) })]
|
|
1822
1863
|
})] });
|
|
1823
1864
|
}
|
|
1824
1865
|
//#endregion
|
|
1825
|
-
export {
|
|
1866
|
+
export { _t as AccountSettings, bt as ActiveSessions, Qe as AdditionalField, dt as Auth, pt as AuthProvider, mt as ChangeEmail, St as ChangePassword, nt as ForgotPassword, Et as LinkedAccounts, r as OpenEmailButton, t as ProviderButton, i as ProviderButtons, et as RESET_LINK_SENT_STORAGE_KEY, tt as ResetLinkSent, rt as ResetPassword, Ot as SecuritySettings, kt as Settings, it as SignIn, at as SignOut, ot as SignUp, n as UserAvatar, jt as UserButton, gt as UserProfile, a as UserView, ct as VerifyEmail };
|