@better-auth-ui/heroui 1.6.23 → 1.6.24
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/open-email-button.d.ts +18 -0
- package/dist/components/auth/verify-email.d.ts +19 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +530 -447
- package/dist/plugins.js +340 -346
- package/package.json +5 -5
- package/src/components/auth/auth.tsx +3 -1
- package/src/components/auth/open-email-button.tsx +50 -0
- package/src/components/auth/sign-in.tsx +5 -25
- package/src/components/auth/sign-up.tsx +5 -3
- package/src/components/auth/username/sign-in-username.tsx +4 -20
- package/src/components/auth/verify-email.tsx +144 -0
- package/src/index.tsx +2 -0
package/dist/index.js
CHANGED
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { a as e, i as t, n, r, t as i } from "./user-view--47tVtJ3.js";
|
|
3
|
-
import { authMutationKeys as a, authQueryKeys as o, fileToBase64 as s,
|
|
4
|
-
import { AuthProvider as
|
|
5
|
-
import { ArrowRightFromSquare as
|
|
6
|
-
import { Button as k, Calendar as A, Card as j, Checkbox as M, Chip as
|
|
7
|
-
import { fromDate as
|
|
8
|
-
import { isValidElement as
|
|
3
|
+
import { authMutationKeys as a, authQueryKeys as o, fileToBase64 as s, getEmailProviderLink 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 ee, useRequestPasswordReset as S, useResetPassword as te, useRevokeSession as C, useSendVerificationEmail as ne, useSession as w, useSignInEmail as T, 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, ArrowUpRightFromSquare as ce, Check as le, ChevronsExpandVertical as ue, CloudArrowUpIn as de, Copy as fe, Display as pe, Eye as D, EyeSlash as O, Gear as me, Link as he, LinkSlash as ge, Person as _e, PersonPlus as ve, PlugConnection as ye, Shield as be, Smartphone as xe, TrashBin as Se, Xmark as Ce } from "@gravity-ui/icons";
|
|
6
|
+
import { Button as k, Calendar as A, Card as j, Checkbox as M, Chip as we, ComboBox as Te, DateField as Ee, DatePicker as De, 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 Oe, RouterProvider as ke, Select as Ae, Skeleton as U, Slider as je, Spinner as W, Switch as Me, Tabs as G, TextArea as Ne, TextField as K, TimeField as Pe, cn as q, toast as J, useIsHydrated as Fe } from "@heroui/react";
|
|
7
|
+
import { fromDate as Ie, getLocalTimeZone as Le, parseDate as Re, parseDateTime as ze, toCalendarDate as Be, toCalendarDateTime as Ve } from "@internationalized/date";
|
|
8
|
+
import { isValidElement as He, useEffect as Y, useMemo as Ue, useRef as We, 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
|
|
10
|
+
import { matchMutation as Ge, matchQuery as Ke, useIsMutating as qe, useQueryClient as Je } from "@tanstack/react-query";
|
|
11
|
+
import { buttonVariants as Ye } from "@heroui/styles";
|
|
12
|
+
import Xe from "bowser";
|
|
12
13
|
//#region src/components/auth/additional-field.tsx
|
|
13
|
-
function
|
|
14
|
-
if (e instanceof Date) return Ie(
|
|
14
|
+
function Ze(e) {
|
|
15
|
+
if (e instanceof Date) return Be(Ie(e, Le()));
|
|
15
16
|
if (typeof e == "string") try {
|
|
16
|
-
return
|
|
17
|
+
return Re(e.slice(0, 10));
|
|
17
18
|
} catch {
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
-
if (e instanceof Date) return
|
|
22
|
+
function Qe(e) {
|
|
23
|
+
if (e instanceof Date) return Ve(Ie(e, Le()));
|
|
23
24
|
if (typeof e == "string") try {
|
|
24
|
-
return
|
|
25
|
+
return ze(e.replace(/(Z|[+-]\d{2}:?\d{2})$/, ""));
|
|
25
26
|
} catch {
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
-
let { localization: n } =
|
|
30
|
+
function $e({ getValue: e, isDisabled: t }) {
|
|
31
|
+
let { localization: n } = h(), [r, i] = X(!1);
|
|
31
32
|
async function a() {
|
|
32
33
|
let t = e();
|
|
33
34
|
if (t) try {
|
|
34
35
|
await navigator.clipboard.writeText(t), i(!0), setTimeout(() => i(!1), 1500);
|
|
35
36
|
} catch (e) {
|
|
36
|
-
|
|
37
|
+
J.danger(e instanceof Error ? e.message : String(e));
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
return /* @__PURE__ */ Q(k, {
|
|
@@ -43,11 +44,11 @@ function Ye({ getValue: e, isDisabled: t }) {
|
|
|
43
44
|
variant: "ghost",
|
|
44
45
|
isDisabled: t,
|
|
45
46
|
onPress: a,
|
|
46
|
-
children: Q(r ?
|
|
47
|
+
children: Q(r ? le : fe, { className: "size-4" })
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
|
-
function
|
|
50
|
-
let { localization: i } =
|
|
50
|
+
function et({ name: e, field: t, isPending: n, variant: r }) {
|
|
51
|
+
let { localization: i } = h(), a = d(t), o = r === "transparent" ? "primary" : "secondary";
|
|
51
52
|
if (t.render) {
|
|
52
53
|
let i = t.render;
|
|
53
54
|
return /* @__PURE__ */ Q(i, {
|
|
@@ -62,24 +63,24 @@ function Xe({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
62
63
|
name: e,
|
|
63
64
|
value: t.defaultValue == null ? "" : t.defaultValue instanceof Date ? t.defaultValue.toISOString() : String(t.defaultValue)
|
|
64
65
|
});
|
|
65
|
-
if (a === "textarea") return /* @__PURE__ */ $(
|
|
66
|
+
if (a === "textarea") return /* @__PURE__ */ $(K, {
|
|
66
67
|
name: e,
|
|
67
68
|
defaultValue: t.defaultValue == null ? void 0 : String(t.defaultValue),
|
|
68
69
|
isDisabled: n,
|
|
69
70
|
isReadOnly: t.readOnly,
|
|
70
71
|
children: [
|
|
71
|
-
/* @__PURE__ */ Q(
|
|
72
|
-
/* @__PURE__ */ Q(
|
|
72
|
+
/* @__PURE__ */ Q(B, { children: t.label }),
|
|
73
|
+
/* @__PURE__ */ Q(Ne, {
|
|
73
74
|
placeholder: t.placeholder,
|
|
74
75
|
required: t.required,
|
|
75
76
|
variant: o
|
|
76
77
|
}),
|
|
77
|
-
/* @__PURE__ */ Q(
|
|
78
|
+
/* @__PURE__ */ Q(F, {})
|
|
78
79
|
]
|
|
79
80
|
});
|
|
80
81
|
if (a === "number") {
|
|
81
82
|
let r = t.formatOptions?.maximumFractionDigits;
|
|
82
|
-
return /* @__PURE__ */ $(
|
|
83
|
+
return /* @__PURE__ */ $(Oe, {
|
|
83
84
|
name: e,
|
|
84
85
|
defaultValue: typeof t.defaultValue == "number" ? t.defaultValue : t.defaultValue != null && t.defaultValue !== "" ? Number(t.defaultValue) : void 0,
|
|
85
86
|
minValue: t.min,
|
|
@@ -90,22 +91,22 @@ function Xe({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
90
91
|
isReadOnly: t.readOnly,
|
|
91
92
|
variant: o,
|
|
92
93
|
children: [
|
|
93
|
-
/* @__PURE__ */ Q(
|
|
94
|
-
/* @__PURE__ */ $(
|
|
95
|
-
/* @__PURE__ */ Q(
|
|
96
|
-
/* @__PURE__ */ Q(
|
|
94
|
+
/* @__PURE__ */ Q(B, { children: t.label }),
|
|
95
|
+
/* @__PURE__ */ $(Oe.Group, { children: [
|
|
96
|
+
/* @__PURE__ */ Q(Oe.DecrementButton, {}),
|
|
97
|
+
/* @__PURE__ */ Q(Oe.Input, {
|
|
97
98
|
placeholder: t.placeholder,
|
|
98
99
|
required: t.required
|
|
99
100
|
}),
|
|
100
|
-
/* @__PURE__ */ Q(
|
|
101
|
+
/* @__PURE__ */ Q(Oe.IncrementButton, {})
|
|
101
102
|
] }),
|
|
102
|
-
/* @__PURE__ */ Q(
|
|
103
|
+
/* @__PURE__ */ Q(F, {})
|
|
103
104
|
]
|
|
104
105
|
});
|
|
105
106
|
}
|
|
106
107
|
if (a === "slider") {
|
|
107
108
|
let r = t.formatOptions?.maximumFractionDigits;
|
|
108
|
-
return /* @__PURE__ */ $(
|
|
109
|
+
return /* @__PURE__ */ $(je, {
|
|
109
110
|
defaultValue: typeof t.defaultValue == "number" ? t.defaultValue : t.defaultValue == null ? void 0 : Number(t.defaultValue),
|
|
110
111
|
minValue: t.min ?? 0,
|
|
111
112
|
maxValue: t.max ?? 100,
|
|
@@ -115,16 +116,16 @@ function Xe({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
115
116
|
className: "flex flex-col gap-2",
|
|
116
117
|
children: [/* @__PURE__ */ $("div", {
|
|
117
118
|
className: "flex items-center justify-between gap-2",
|
|
118
|
-
children: [/* @__PURE__ */ Q(
|
|
119
|
-
}), /* @__PURE__ */ $(
|
|
119
|
+
children: [/* @__PURE__ */ Q(B, { children: t.label }), /* @__PURE__ */ Q(je.Output, { className: "text-sm text-muted" })]
|
|
120
|
+
}), /* @__PURE__ */ $(je.Track, { children: [/* @__PURE__ */ Q(je.Fill, {}), /* @__PURE__ */ Q(je.Thumb, { name: e })] })]
|
|
120
121
|
});
|
|
121
122
|
}
|
|
122
|
-
if (a === "switch") return /* @__PURE__ */ Q(
|
|
123
|
+
if (a === "switch") return /* @__PURE__ */ Q(Me, {
|
|
123
124
|
name: e,
|
|
124
125
|
defaultSelected: t.defaultValue === !0 || t.defaultValue === "true",
|
|
125
126
|
isDisabled: n,
|
|
126
127
|
isReadOnly: t.readOnly,
|
|
127
|
-
children: /* @__PURE__ */ $(
|
|
128
|
+
children: /* @__PURE__ */ $(Me.Content, { children: [/* @__PURE__ */ Q(Me.Control, { children: /* @__PURE__ */ Q(Me.Thumb, {}) }), t.label] })
|
|
128
129
|
});
|
|
129
130
|
if (a === "checkbox") return /* @__PURE__ */ Q(M, {
|
|
130
131
|
name: e,
|
|
@@ -135,7 +136,7 @@ function Xe({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
135
136
|
variant: o,
|
|
136
137
|
children: /* @__PURE__ */ $(M.Content, { children: [/* @__PURE__ */ Q(M.Control, { children: /* @__PURE__ */ Q(M.Indicator, {}) }), t.label] })
|
|
137
138
|
});
|
|
138
|
-
if (a === "select") return /* @__PURE__ */ $(
|
|
139
|
+
if (a === "select") return /* @__PURE__ */ $(Ae, {
|
|
139
140
|
className: "[&[data-required=true]>.label]:after:content-none",
|
|
140
141
|
name: e,
|
|
141
142
|
defaultValue: t.defaultValue == null ? void 0 : String(t.defaultValue),
|
|
@@ -145,17 +146,17 @@ function Xe({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
145
146
|
variant: o,
|
|
146
147
|
fullWidth: !0,
|
|
147
148
|
children: [
|
|
148
|
-
/* @__PURE__ */ Q(
|
|
149
|
-
/* @__PURE__ */ $(
|
|
150
|
-
/* @__PURE__ */ Q(
|
|
149
|
+
/* @__PURE__ */ Q(B, { children: t.label }),
|
|
150
|
+
/* @__PURE__ */ $(Ae.Trigger, { children: [/* @__PURE__ */ Q(Ae.Value, {}), /* @__PURE__ */ Q(Ae.Indicator, {})] }),
|
|
151
|
+
/* @__PURE__ */ Q(Ae.Popover, { children: /* @__PURE__ */ Q(H, { children: t.options?.map((e) => /* @__PURE__ */ $(H.Item, {
|
|
151
152
|
id: e.value,
|
|
152
153
|
textValue: typeof e.label == "string" ? e.label : e.value,
|
|
153
|
-
children: [e.label, /* @__PURE__ */ Q(
|
|
154
|
+
children: [e.label, /* @__PURE__ */ Q(H.ItemIndicator, {})]
|
|
154
155
|
}, e.value)) }) }),
|
|
155
|
-
/* @__PURE__ */ Q(
|
|
156
|
+
/* @__PURE__ */ Q(F, {})
|
|
156
157
|
]
|
|
157
158
|
});
|
|
158
|
-
if (a === "combobox") return /* @__PURE__ */ $(
|
|
159
|
+
if (a === "combobox") return /* @__PURE__ */ $(Te, {
|
|
159
160
|
className: "[&[data-required=true]>.label]:after:content-none",
|
|
160
161
|
name: e,
|
|
161
162
|
defaultSelectedKey: t.defaultValue == null ? void 0 : String(t.defaultValue),
|
|
@@ -165,35 +166,35 @@ function Xe({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
165
166
|
variant: o,
|
|
166
167
|
fullWidth: !0,
|
|
167
168
|
children: [
|
|
168
|
-
/* @__PURE__ */ Q(
|
|
169
|
-
/* @__PURE__ */ $(
|
|
170
|
-
/* @__PURE__ */ Q(
|
|
169
|
+
/* @__PURE__ */ Q(B, { children: t.label }),
|
|
170
|
+
/* @__PURE__ */ $(Te.InputGroup, { children: [/* @__PURE__ */ Q(R, { placeholder: t.placeholder }), /* @__PURE__ */ Q(Te.Trigger, {})] }),
|
|
171
|
+
/* @__PURE__ */ Q(Te.Popover, { children: /* @__PURE__ */ Q(H, { children: t.options?.map((e) => /* @__PURE__ */ $(H.Item, {
|
|
171
172
|
id: e.value,
|
|
172
173
|
textValue: typeof e.label == "string" ? e.label : e.value,
|
|
173
|
-
children: [e.label, /* @__PURE__ */ Q(
|
|
174
|
+
children: [e.label, /* @__PURE__ */ Q(H.ItemIndicator, {})]
|
|
174
175
|
}, e.value)) }) }),
|
|
175
|
-
/* @__PURE__ */ Q(
|
|
176
|
+
/* @__PURE__ */ Q(F, {})
|
|
176
177
|
]
|
|
177
178
|
});
|
|
178
179
|
if (a === "date" || a === "datetime") {
|
|
179
180
|
let r = a === "datetime";
|
|
180
|
-
return /* @__PURE__ */ Q(
|
|
181
|
+
return /* @__PURE__ */ Q(De, {
|
|
181
182
|
className: "w-full [&[data-required=true]>.label]:after:content-none",
|
|
182
183
|
name: e,
|
|
183
|
-
defaultValue: r ?
|
|
184
|
+
defaultValue: r ? Qe(t.defaultValue) : Ze(t.defaultValue),
|
|
184
185
|
granularity: r ? "minute" : "day",
|
|
185
186
|
isDisabled: n,
|
|
186
187
|
isReadOnly: t.readOnly,
|
|
187
188
|
isRequired: t.required,
|
|
188
189
|
children: ({ state: n }) => /* @__PURE__ */ $(Z, { children: [
|
|
189
|
-
/* @__PURE__ */ Q(
|
|
190
|
-
/* @__PURE__ */ $(
|
|
190
|
+
/* @__PURE__ */ Q(B, { children: t.label }),
|
|
191
|
+
/* @__PURE__ */ $(Ee.Group, {
|
|
191
192
|
variant: o,
|
|
192
193
|
fullWidth: !0,
|
|
193
|
-
children: [/* @__PURE__ */ Q(
|
|
194
|
+
children: [/* @__PURE__ */ Q(Ee.Input, { children: (e) => /* @__PURE__ */ Q(Ee.Segment, { segment: e }) }), /* @__PURE__ */ Q(Ee.Suffix, { children: /* @__PURE__ */ Q(De.Trigger, { children: /* @__PURE__ */ Q(De.TriggerIndicator, {}) }) })]
|
|
194
195
|
}),
|
|
195
|
-
/* @__PURE__ */ Q(
|
|
196
|
-
/* @__PURE__ */ $(
|
|
196
|
+
/* @__PURE__ */ Q(F, {}),
|
|
197
|
+
/* @__PURE__ */ $(De.Popover, {
|
|
197
198
|
className: "flex flex-col gap-3",
|
|
198
199
|
children: [/* @__PURE__ */ $(A, {
|
|
199
200
|
"aria-label": typeof t.label == "string" ? t.label : e,
|
|
@@ -208,14 +209,14 @@ function Xe({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
208
209
|
]
|
|
209
210
|
}), r && /* @__PURE__ */ $("div", {
|
|
210
211
|
className: "flex items-center justify-between",
|
|
211
|
-
children: [/* @__PURE__ */ Q(
|
|
212
|
+
children: [/* @__PURE__ */ Q(B, { children: i.settings.time }), /* @__PURE__ */ Q(Pe, {
|
|
212
213
|
"aria-label": i.settings.time,
|
|
213
214
|
granularity: "minute",
|
|
214
215
|
value: n.timeValue,
|
|
215
216
|
onChange: (e) => n.setTimeValue(e),
|
|
216
|
-
children: /* @__PURE__ */ Q(
|
|
217
|
+
children: /* @__PURE__ */ Q(Pe.Group, {
|
|
217
218
|
variant: "secondary",
|
|
218
|
-
children: /* @__PURE__ */ Q(
|
|
219
|
+
children: /* @__PURE__ */ Q(Pe.Input, { children: (e) => /* @__PURE__ */ Q(Pe.Segment, { segment: e }) })
|
|
219
220
|
})
|
|
220
221
|
})]
|
|
221
222
|
})]
|
|
@@ -223,27 +224,27 @@ function Xe({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
223
224
|
] })
|
|
224
225
|
});
|
|
225
226
|
}
|
|
226
|
-
return /* @__PURE__ */ Q(
|
|
227
|
+
return /* @__PURE__ */ Q(tt, {
|
|
227
228
|
name: e,
|
|
228
229
|
field: t,
|
|
229
230
|
isPending: n,
|
|
230
231
|
variant: r
|
|
231
232
|
});
|
|
232
233
|
}
|
|
233
|
-
function
|
|
234
|
-
let i =
|
|
235
|
-
return o || s ? /* @__PURE__ */ $(
|
|
234
|
+
function tt({ name: e, field: t, isPending: n, variant: r }) {
|
|
235
|
+
let i = We(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
|
+
return o || s ? /* @__PURE__ */ $(K, {
|
|
236
237
|
name: e,
|
|
237
238
|
defaultValue: t.defaultValue == null ? void 0 : String(t.defaultValue),
|
|
238
239
|
isDisabled: n,
|
|
239
240
|
isReadOnly: t.readOnly,
|
|
240
241
|
children: [
|
|
241
|
-
/* @__PURE__ */ Q(
|
|
242
|
-
/* @__PURE__ */ $(
|
|
242
|
+
/* @__PURE__ */ Q(B, { children: t.label }),
|
|
243
|
+
/* @__PURE__ */ $(z, {
|
|
243
244
|
variant: a,
|
|
244
245
|
children: [
|
|
245
|
-
o && /* @__PURE__ */ Q(
|
|
246
|
-
/* @__PURE__ */ Q(
|
|
246
|
+
o && /* @__PURE__ */ Q(z.Prefix, { children: t.prefix }),
|
|
247
|
+
/* @__PURE__ */ Q(z.Input, {
|
|
247
248
|
ref: i,
|
|
248
249
|
placeholder: t.placeholder,
|
|
249
250
|
required: t.required,
|
|
@@ -251,25 +252,25 @@ function Ze({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
251
252
|
inputMode: d,
|
|
252
253
|
step: f
|
|
253
254
|
}),
|
|
254
|
-
t.copyable ? /* @__PURE__ */ Q(
|
|
255
|
+
t.copyable ? /* @__PURE__ */ Q(z.Suffix, {
|
|
255
256
|
className: "px-0",
|
|
256
|
-
children: /* @__PURE__ */ Q(
|
|
257
|
+
children: /* @__PURE__ */ Q($e, {
|
|
257
258
|
getValue: () => i.current?.value,
|
|
258
259
|
isDisabled: n
|
|
259
260
|
})
|
|
260
|
-
}) : t.suffix != null && /* @__PURE__ */ Q(
|
|
261
|
+
}) : t.suffix != null && /* @__PURE__ */ Q(z.Suffix, { children: t.suffix })
|
|
261
262
|
]
|
|
262
263
|
}),
|
|
263
|
-
/* @__PURE__ */ Q(
|
|
264
|
+
/* @__PURE__ */ Q(F, {})
|
|
264
265
|
]
|
|
265
|
-
}) : /* @__PURE__ */ $(
|
|
266
|
+
}) : /* @__PURE__ */ $(K, {
|
|
266
267
|
name: e,
|
|
267
268
|
defaultValue: t.defaultValue == null ? void 0 : String(t.defaultValue),
|
|
268
269
|
isDisabled: n,
|
|
269
270
|
isReadOnly: t.readOnly,
|
|
270
271
|
children: [
|
|
271
|
-
/* @__PURE__ */ Q(
|
|
272
|
-
/* @__PURE__ */ Q(
|
|
272
|
+
/* @__PURE__ */ Q(B, { children: t.label }),
|
|
273
|
+
/* @__PURE__ */ Q(R, {
|
|
273
274
|
placeholder: t.placeholder,
|
|
274
275
|
required: t.required,
|
|
275
276
|
variant: a,
|
|
@@ -277,19 +278,19 @@ function Ze({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
277
278
|
inputMode: d,
|
|
278
279
|
step: f
|
|
279
280
|
}),
|
|
280
|
-
/* @__PURE__ */ Q(
|
|
281
|
+
/* @__PURE__ */ Q(F, {})
|
|
281
282
|
]
|
|
282
283
|
});
|
|
283
284
|
}
|
|
284
285
|
//#endregion
|
|
285
286
|
//#region src/components/auth/forgot-password.tsx
|
|
286
|
-
function
|
|
287
|
-
let { authClient: n, baseURL: r, basePaths: i, localization: a, viewPaths: o, navigate: s, plugins: c } =
|
|
287
|
+
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 } = S(n, {
|
|
288
289
|
onError: () => {
|
|
289
290
|
u();
|
|
290
291
|
},
|
|
291
292
|
onSuccess: () => {
|
|
292
|
-
|
|
293
|
+
J.success(a.auth.passwordResetEmailSent), s({ to: `${i.auth}/${o.auth.signIn}` });
|
|
293
294
|
}
|
|
294
295
|
});
|
|
295
296
|
function p(e) {
|
|
@@ -299,9 +300,9 @@ function Qe({ className: e, variant: t }) {
|
|
|
299
300
|
fetchOptions: l
|
|
300
301
|
});
|
|
301
302
|
}
|
|
302
|
-
let
|
|
303
|
+
let m = c.find((e) => e.captchaComponent)?.captchaComponent;
|
|
303
304
|
return /* @__PURE__ */ $(j, {
|
|
304
|
-
className:
|
|
305
|
+
className: q("w-full max-w-sm gap-4 md:p-6", e),
|
|
305
306
|
variant: t,
|
|
306
307
|
children: [
|
|
307
308
|
/* @__PURE__ */ Q(j.Header, { children: /* @__PURE__ */ Q(j.Title, {
|
|
@@ -310,11 +311,11 @@ function Qe({ className: e, variant: t }) {
|
|
|
310
311
|
}) }),
|
|
311
312
|
/* @__PURE__ */ Q(j.Content, {
|
|
312
313
|
className: "gap-4",
|
|
313
|
-
children: /* @__PURE__ */ $(
|
|
314
|
+
children: /* @__PURE__ */ $(L, {
|
|
314
315
|
onSubmit: p,
|
|
315
316
|
className: "flex flex-col gap-4",
|
|
316
317
|
children: [
|
|
317
|
-
/* @__PURE__ */ $(
|
|
318
|
+
/* @__PURE__ */ $(K, {
|
|
318
319
|
name: "email",
|
|
319
320
|
type: "email",
|
|
320
321
|
autoComplete: "email",
|
|
@@ -324,18 +325,18 @@ function Qe({ className: e, variant: t }) {
|
|
|
324
325
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) return a.auth.invalidEmail;
|
|
325
326
|
},
|
|
326
327
|
children: [
|
|
327
|
-
/* @__PURE__ */ Q(
|
|
328
|
-
/* @__PURE__ */ Q(
|
|
328
|
+
/* @__PURE__ */ Q(B, { children: a.auth.email }),
|
|
329
|
+
/* @__PURE__ */ Q(R, {
|
|
329
330
|
placeholder: a.auth.emailPlaceholder,
|
|
330
331
|
required: !0,
|
|
331
332
|
variant: t === "transparent" ? "primary" : "secondary"
|
|
332
333
|
}),
|
|
333
|
-
/* @__PURE__ */ Q(
|
|
334
|
+
/* @__PURE__ */ Q(F, {})
|
|
334
335
|
]
|
|
335
336
|
}),
|
|
336
|
-
|
|
337
|
+
m && /* @__PURE__ */ Q("div", {
|
|
337
338
|
className: "flex justify-center",
|
|
338
|
-
children:
|
|
339
|
+
children: m
|
|
339
340
|
}),
|
|
340
341
|
/* @__PURE__ */ Q("div", {
|
|
341
342
|
className: "flex flex-col gap-3",
|
|
@@ -343,7 +344,7 @@ function Qe({ className: e, variant: t }) {
|
|
|
343
344
|
type: "submit",
|
|
344
345
|
className: "w-full",
|
|
345
346
|
isPending: f,
|
|
346
|
-
children: [f && /* @__PURE__ */ Q(
|
|
347
|
+
children: [f && /* @__PURE__ */ Q(W, {
|
|
347
348
|
color: "current",
|
|
348
349
|
size: "sm"
|
|
349
350
|
}), a.auth.sendResetLink]
|
|
@@ -354,12 +355,12 @@ function Qe({ className: e, variant: t }) {
|
|
|
354
355
|
}),
|
|
355
356
|
/* @__PURE__ */ Q(j.Footer, {
|
|
356
357
|
className: "flex-col gap-3",
|
|
357
|
-
children: /* @__PURE__ */ $(
|
|
358
|
+
children: /* @__PURE__ */ $(N, {
|
|
358
359
|
className: "text-sm",
|
|
359
360
|
children: [
|
|
360
361
|
a.auth.rememberYourPassword,
|
|
361
362
|
" ",
|
|
362
|
-
/* @__PURE__ */ Q(
|
|
363
|
+
/* @__PURE__ */ Q(V, {
|
|
363
364
|
href: `${i.auth}/${o.auth.signIn}`,
|
|
364
365
|
className: "text-accent no-underline hover:underline decoration-accent-hover",
|
|
365
366
|
children: a.auth.signIn
|
|
@@ -372,28 +373,28 @@ function Qe({ className: e, variant: t }) {
|
|
|
372
373
|
}
|
|
373
374
|
//#endregion
|
|
374
375
|
//#region src/components/auth/reset-password.tsx
|
|
375
|
-
function
|
|
376
|
-
let { authClient: n, basePaths: r, emailAndPassword: i, localization: a, viewPaths: o, navigate: s } =
|
|
377
|
-
|
|
376
|
+
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 } = te(n, { onSuccess: () => {
|
|
378
|
+
J.success(a.auth.passwordResetSuccess), s({ to: `${r.auth}/${o.auth.signIn}` });
|
|
378
379
|
} }), [u, d] = X(!1), [f, p] = X(!1);
|
|
379
|
-
|
|
380
|
-
new URLSearchParams(window.location.search).get("token") || (
|
|
380
|
+
Y(() => {
|
|
381
|
+
new URLSearchParams(window.location.search).get("token") || (J.danger(a.auth.invalidResetPasswordToken), s({ to: `${r.auth}/${o.auth.signIn}` }));
|
|
381
382
|
}, [
|
|
382
383
|
r.auth,
|
|
383
384
|
a.auth.invalidResetPasswordToken,
|
|
384
385
|
o.auth.signIn,
|
|
385
386
|
s
|
|
386
387
|
]);
|
|
387
|
-
function
|
|
388
|
+
function m(e) {
|
|
388
389
|
e.preventDefault();
|
|
389
390
|
let t = new URLSearchParams(window.location.search).get("token");
|
|
390
391
|
if (!t) {
|
|
391
|
-
|
|
392
|
+
J.danger(a.auth.invalidResetPasswordToken), s({ to: `${r.auth}/${o.auth.signIn}` });
|
|
392
393
|
return;
|
|
393
394
|
}
|
|
394
395
|
let n = new FormData(e.currentTarget), l = n.get("password"), u = n.get("confirmPassword");
|
|
395
396
|
if (i?.confirmPassword && l !== u) {
|
|
396
|
-
|
|
397
|
+
J.danger(a.auth.passwordsDoNotMatch);
|
|
397
398
|
return;
|
|
398
399
|
}
|
|
399
400
|
c({
|
|
@@ -402,7 +403,7 @@ function $e({ className: e, variant: t }) {
|
|
|
402
403
|
});
|
|
403
404
|
}
|
|
404
405
|
return /* @__PURE__ */ $(j, {
|
|
405
|
-
className:
|
|
406
|
+
className: q("w-full max-w-sm gap-4 md:p-6", e),
|
|
406
407
|
variant: t,
|
|
407
408
|
children: [
|
|
408
409
|
/* @__PURE__ */ Q(j.Header, { children: /* @__PURE__ */ Q(j.Title, {
|
|
@@ -411,11 +412,11 @@ function $e({ className: e, variant: t }) {
|
|
|
411
412
|
}) }),
|
|
412
413
|
/* @__PURE__ */ Q(j.Content, {
|
|
413
414
|
className: "gap-4",
|
|
414
|
-
children: /* @__PURE__ */ $(
|
|
415
|
-
onSubmit:
|
|
415
|
+
children: /* @__PURE__ */ $(L, {
|
|
416
|
+
onSubmit: m,
|
|
416
417
|
className: "flex flex-col gap-4",
|
|
417
418
|
children: [
|
|
418
|
-
/* @__PURE__ */ $(
|
|
419
|
+
/* @__PURE__ */ $(K, {
|
|
419
420
|
minLength: i?.minPasswordLength,
|
|
420
421
|
maxLength: i?.maxPasswordLength,
|
|
421
422
|
name: "password",
|
|
@@ -428,15 +429,15 @@ function $e({ className: e, variant: t }) {
|
|
|
428
429
|
if (n && e.length > n) return a.auth.tooLong.replace("{{max}}", String(n));
|
|
429
430
|
},
|
|
430
431
|
children: [
|
|
431
|
-
/* @__PURE__ */ Q(
|
|
432
|
-
/* @__PURE__ */ $(
|
|
432
|
+
/* @__PURE__ */ Q(B, { children: a.auth.password }),
|
|
433
|
+
/* @__PURE__ */ $(z, {
|
|
433
434
|
variant: t === "transparent" ? "primary" : "secondary",
|
|
434
|
-
children: [/* @__PURE__ */ Q(
|
|
435
|
+
children: [/* @__PURE__ */ Q(z.Input, {
|
|
435
436
|
name: "password",
|
|
436
437
|
placeholder: a.auth.newPasswordPlaceholder,
|
|
437
438
|
type: u ? "text" : "password",
|
|
438
439
|
required: !0
|
|
439
|
-
}), /* @__PURE__ */ Q(
|
|
440
|
+
}), /* @__PURE__ */ Q(z.Suffix, {
|
|
440
441
|
className: "px-0",
|
|
441
442
|
children: /* @__PURE__ */ Q(k, {
|
|
442
443
|
isIconOnly: !0,
|
|
@@ -449,10 +450,10 @@ function $e({ className: e, variant: t }) {
|
|
|
449
450
|
})
|
|
450
451
|
})]
|
|
451
452
|
}),
|
|
452
|
-
/* @__PURE__ */ Q(
|
|
453
|
+
/* @__PURE__ */ Q(F, {})
|
|
453
454
|
]
|
|
454
455
|
}),
|
|
455
|
-
i?.confirmPassword && /* @__PURE__ */ $(
|
|
456
|
+
i?.confirmPassword && /* @__PURE__ */ $(K, {
|
|
456
457
|
minLength: i?.minPasswordLength,
|
|
457
458
|
maxLength: i?.maxPasswordLength,
|
|
458
459
|
name: "confirmPassword",
|
|
@@ -465,15 +466,15 @@ function $e({ className: e, variant: t }) {
|
|
|
465
466
|
if (n && e.length > n) return a.auth.tooLong.replace("{{max}}", String(n));
|
|
466
467
|
},
|
|
467
468
|
children: [
|
|
468
|
-
/* @__PURE__ */ Q(
|
|
469
|
-
/* @__PURE__ */ $(
|
|
469
|
+
/* @__PURE__ */ Q(B, { children: a.auth.confirmPassword }),
|
|
470
|
+
/* @__PURE__ */ $(z, {
|
|
470
471
|
variant: t === "transparent" ? "primary" : "secondary",
|
|
471
|
-
children: [/* @__PURE__ */ Q(
|
|
472
|
+
children: [/* @__PURE__ */ Q(z.Input, {
|
|
472
473
|
placeholder: a.auth.confirmPasswordPlaceholder,
|
|
473
474
|
type: f ? "text" : "password",
|
|
474
475
|
required: !0,
|
|
475
476
|
name: "confirmPassword"
|
|
476
|
-
}), /* @__PURE__ */ Q(
|
|
477
|
+
}), /* @__PURE__ */ Q(z.Suffix, {
|
|
477
478
|
className: "px-0",
|
|
478
479
|
children: /* @__PURE__ */ Q(k, {
|
|
479
480
|
isIconOnly: !0,
|
|
@@ -486,7 +487,7 @@ function $e({ className: e, variant: t }) {
|
|
|
486
487
|
})
|
|
487
488
|
})]
|
|
488
489
|
}),
|
|
489
|
-
/* @__PURE__ */ Q(
|
|
490
|
+
/* @__PURE__ */ Q(F, {})
|
|
490
491
|
]
|
|
491
492
|
}),
|
|
492
493
|
/* @__PURE__ */ Q("div", {
|
|
@@ -495,7 +496,7 @@ function $e({ className: e, variant: t }) {
|
|
|
495
496
|
type: "submit",
|
|
496
497
|
className: "w-full",
|
|
497
498
|
isPending: l,
|
|
498
|
-
children: [l && /* @__PURE__ */ Q(
|
|
499
|
+
children: [l && /* @__PURE__ */ Q(W, {
|
|
499
500
|
color: "current",
|
|
500
501
|
size: "sm"
|
|
501
502
|
}), a.auth.resetPassword]
|
|
@@ -506,12 +507,12 @@ function $e({ className: e, variant: t }) {
|
|
|
506
507
|
}),
|
|
507
508
|
/* @__PURE__ */ Q(j.Footer, {
|
|
508
509
|
className: "flex-col gap-3",
|
|
509
|
-
children: /* @__PURE__ */ $(
|
|
510
|
+
children: /* @__PURE__ */ $(N, {
|
|
510
511
|
className: "text-sm",
|
|
511
512
|
children: [
|
|
512
513
|
a.auth.rememberYourPassword,
|
|
513
514
|
" ",
|
|
514
|
-
/* @__PURE__ */ Q(
|
|
515
|
+
/* @__PURE__ */ Q(V, {
|
|
515
516
|
href: `${r.auth}/${o.auth.signIn}`,
|
|
516
517
|
className: "text-accent no-underline hover:underline decoration-accent-hover",
|
|
517
518
|
children: a.auth.signIn
|
|
@@ -524,130 +525,124 @@ function $e({ className: e, variant: t }) {
|
|
|
524
525
|
}
|
|
525
526
|
//#endregion
|
|
526
527
|
//#region src/components/auth/sign-in.tsx
|
|
527
|
-
function
|
|
528
|
-
let { authClient: s, basePaths: c,
|
|
528
|
+
function it({ className: t, socialLayout: n, socialPosition: i = "bottom", variant: o }) {
|
|
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: ee, isPending: S } = T(s, {
|
|
529
530
|
onError: (e, { email: t }) => {
|
|
530
|
-
x(""), e.error?.code === "EMAIL_NOT_VERIFIED" &&
|
|
531
|
-
children: d.auth.resend,
|
|
532
|
-
onClick: () => S({
|
|
533
|
-
email: t,
|
|
534
|
-
callbackURL: `${l}${p}`
|
|
535
|
-
})
|
|
536
|
-
} }), ee();
|
|
531
|
+
x(""), e.error?.code === "EMAIL_NOT_VERIFIED" && (sessionStorage.setItem("better-auth-ui.verify-email", t), g({ to: `${c.auth}/${m.auth.verifyEmail}` })), v();
|
|
537
532
|
},
|
|
538
|
-
onSuccess: () =>
|
|
539
|
-
}),
|
|
533
|
+
onSuccess: () => g({ to: f })
|
|
534
|
+
}), te = (e) => {
|
|
540
535
|
e.preventDefault();
|
|
541
536
|
let t = new FormData(e.currentTarget), n = t.get("email"), r = t.get("rememberMe") === "on";
|
|
542
|
-
|
|
537
|
+
ee({
|
|
543
538
|
email: n,
|
|
544
539
|
password: b,
|
|
545
|
-
...
|
|
546
|
-
fetchOptions:
|
|
540
|
+
...l?.rememberMe ? { rememberMe: r } : {},
|
|
541
|
+
fetchOptions: _
|
|
547
542
|
});
|
|
548
|
-
},
|
|
543
|
+
}, C = qe({ mutationKey: a.signIn.all }) + qe({ mutationKey: a.signUp.all }) > 0, ne = d.find((e) => e.captchaComponent)?.captchaComponent, w = l?.enabled && !!p?.length;
|
|
549
544
|
return /* @__PURE__ */ $(j, {
|
|
550
|
-
className:
|
|
545
|
+
className: q("w-full max-w-sm gap-4 md:p-6", t),
|
|
551
546
|
variant: o,
|
|
552
547
|
children: [
|
|
553
548
|
/* @__PURE__ */ Q(j.Header, { children: /* @__PURE__ */ Q(j.Title, {
|
|
554
549
|
className: "text-xl font-semibold mb-1",
|
|
555
|
-
children:
|
|
550
|
+
children: u.auth.signIn
|
|
556
551
|
}) }),
|
|
557
552
|
/* @__PURE__ */ $(j.Content, {
|
|
558
553
|
className: "gap-4",
|
|
559
554
|
children: [
|
|
560
|
-
i === "top" && /* @__PURE__ */ $(Z, { children: [!!
|
|
561
|
-
|
|
562
|
-
onSubmit:
|
|
555
|
+
i === "top" && /* @__PURE__ */ $(Z, { children: [!!p?.length && /* @__PURE__ */ Q(r, { socialLayout: n }), w && /* @__PURE__ */ Q(e, { children: u.auth.or })] }),
|
|
556
|
+
l?.enabled && /* @__PURE__ */ $(L, {
|
|
557
|
+
onSubmit: te,
|
|
563
558
|
className: "flex flex-col gap-4",
|
|
564
559
|
children: [
|
|
565
|
-
/* @__PURE__ */ $(
|
|
560
|
+
/* @__PURE__ */ $(K, {
|
|
566
561
|
name: "email",
|
|
567
562
|
type: "email",
|
|
568
563
|
autoComplete: "email",
|
|
569
|
-
isDisabled:
|
|
564
|
+
isDisabled: C,
|
|
570
565
|
validate: (e) => {
|
|
571
|
-
if (!e) return
|
|
572
|
-
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) return
|
|
566
|
+
if (!e) return u.auth.fieldRequired;
|
|
567
|
+
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) return u.auth.invalidEmail;
|
|
573
568
|
},
|
|
574
569
|
children: [
|
|
575
|
-
/* @__PURE__ */ Q(
|
|
576
|
-
/* @__PURE__ */ Q(
|
|
577
|
-
placeholder:
|
|
570
|
+
/* @__PURE__ */ Q(B, { children: u.auth.email }),
|
|
571
|
+
/* @__PURE__ */ Q(R, {
|
|
572
|
+
placeholder: u.auth.emailPlaceholder,
|
|
578
573
|
variant: o === "transparent" ? "primary" : "secondary",
|
|
579
574
|
required: !0
|
|
580
575
|
}),
|
|
581
|
-
/* @__PURE__ */ Q(
|
|
576
|
+
/* @__PURE__ */ Q(F, {})
|
|
582
577
|
]
|
|
583
578
|
}),
|
|
584
|
-
/* @__PURE__ */ $(
|
|
585
|
-
minLength:
|
|
586
|
-
maxLength:
|
|
579
|
+
/* @__PURE__ */ $(K, {
|
|
580
|
+
minLength: l?.minPasswordLength,
|
|
581
|
+
maxLength: l?.maxPasswordLength,
|
|
587
582
|
name: "password",
|
|
588
583
|
type: "password",
|
|
589
584
|
autoComplete: "current-password",
|
|
590
|
-
isDisabled:
|
|
585
|
+
isDisabled: C,
|
|
591
586
|
value: b,
|
|
592
587
|
onChange: x,
|
|
593
588
|
validate: (e) => {
|
|
594
|
-
if (!e) return
|
|
595
|
-
let t =
|
|
596
|
-
if (t && e.length < t) return
|
|
597
|
-
if (n && e.length > n) return
|
|
589
|
+
if (!e) return u.auth.fieldRequired;
|
|
590
|
+
let t = l?.minPasswordLength, n = l?.maxPasswordLength;
|
|
591
|
+
if (t && e.length < t) return u.auth.tooShort.replace("{{min}}", String(t));
|
|
592
|
+
if (n && e.length > n) return u.auth.tooLong.replace("{{max}}", String(n));
|
|
598
593
|
},
|
|
599
594
|
children: [
|
|
600
|
-
/* @__PURE__ */ Q(
|
|
601
|
-
/* @__PURE__ */ Q(
|
|
602
|
-
placeholder:
|
|
595
|
+
/* @__PURE__ */ Q(B, { children: u.auth.password }),
|
|
596
|
+
/* @__PURE__ */ Q(R, {
|
|
597
|
+
placeholder: u.auth.passwordPlaceholder,
|
|
603
598
|
variant: o === "transparent" ? "primary" : "secondary",
|
|
604
599
|
required: !0
|
|
605
600
|
}),
|
|
606
|
-
/* @__PURE__ */ Q(
|
|
601
|
+
/* @__PURE__ */ Q(F, {})
|
|
607
602
|
]
|
|
608
603
|
}),
|
|
609
|
-
|
|
604
|
+
l?.rememberMe && /* @__PURE__ */ Q(M, {
|
|
610
605
|
name: "rememberMe",
|
|
611
|
-
isDisabled:
|
|
606
|
+
isDisabled: C,
|
|
612
607
|
variant: o === "transparent" ? "primary" : "secondary",
|
|
613
|
-
children: /* @__PURE__ */ $(M.Content, { children: [/* @__PURE__ */ Q(M.Control, { children: /* @__PURE__ */ Q(M.Indicator, {}) }),
|
|
608
|
+
children: /* @__PURE__ */ $(M.Content, { children: [/* @__PURE__ */ Q(M.Control, { children: /* @__PURE__ */ Q(M.Indicator, {}) }), u.auth.rememberMe] })
|
|
614
609
|
}),
|
|
615
|
-
|
|
610
|
+
ne && /* @__PURE__ */ Q("div", {
|
|
616
611
|
className: "flex justify-center",
|
|
617
|
-
children:
|
|
612
|
+
children: ne
|
|
618
613
|
}),
|
|
619
614
|
/* @__PURE__ */ $("div", {
|
|
620
615
|
className: "flex flex-col gap-3",
|
|
621
616
|
children: [/* @__PURE__ */ $(k, {
|
|
622
617
|
type: "submit",
|
|
623
618
|
className: "w-full",
|
|
624
|
-
isPending:
|
|
625
|
-
children: [
|
|
619
|
+
isPending: C,
|
|
620
|
+
children: [S && /* @__PURE__ */ Q(W, {
|
|
626
621
|
color: "current",
|
|
627
622
|
size: "sm"
|
|
628
|
-
}),
|
|
629
|
-
}),
|
|
623
|
+
}), u.auth.signIn]
|
|
624
|
+
}), d.flatMap((e) => e.authButtons?.map((t, n) => /* @__PURE__ */ Q(t, { view: "signIn" }, `${e.id}-${n.toString()}`)))]
|
|
630
625
|
})
|
|
631
626
|
]
|
|
632
627
|
}),
|
|
633
|
-
i === "bottom" && /* @__PURE__ */ $(Z, { children: [
|
|
628
|
+
i === "bottom" && /* @__PURE__ */ $(Z, { children: [w && /* @__PURE__ */ Q(e, { children: u.auth.or }), !!p?.length && /* @__PURE__ */ Q(r, { socialLayout: n })] })
|
|
634
629
|
]
|
|
635
630
|
}),
|
|
636
631
|
/* @__PURE__ */ $(j.Footer, {
|
|
637
632
|
className: "flex-col gap-3",
|
|
638
|
-
children: [
|
|
639
|
-
href: `${c.auth}/${
|
|
633
|
+
children: [l?.enabled && l?.forgotPassword && /* @__PURE__ */ Q(V, {
|
|
634
|
+
href: `${c.auth}/${m.auth.forgotPassword}`,
|
|
640
635
|
className: "text-sm no-underline hover:underline",
|
|
641
|
-
children:
|
|
642
|
-
}),
|
|
636
|
+
children: u.auth.forgotPasswordLink
|
|
637
|
+
}), l?.enabled && /* @__PURE__ */ $(N, {
|
|
643
638
|
className: "text-sm",
|
|
644
639
|
children: [
|
|
645
|
-
|
|
640
|
+
u.auth.needToCreateAnAccount,
|
|
646
641
|
" ",
|
|
647
|
-
/* @__PURE__ */ Q(
|
|
648
|
-
href: `${c.auth}/${
|
|
642
|
+
/* @__PURE__ */ Q(V, {
|
|
643
|
+
href: `${c.auth}/${m.auth.signUp}`,
|
|
649
644
|
className: "text-accent no-underline hover:underline decoration-accent-hover",
|
|
650
|
-
children:
|
|
645
|
+
children: u.auth.signUp
|
|
651
646
|
})
|
|
652
647
|
]
|
|
653
648
|
})]
|
|
@@ -657,8 +652,8 @@ function et({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
657
652
|
}
|
|
658
653
|
//#endregion
|
|
659
654
|
//#region src/components/auth/sign-out.tsx
|
|
660
|
-
function
|
|
661
|
-
let { authClient: t, basePaths: n, navigate: r, viewPaths: i } =
|
|
655
|
+
function at({ className: e }) {
|
|
656
|
+
let { authClient: t, basePaths: n, navigate: r, viewPaths: i } = h(), { mutate: a } = re(t, {
|
|
662
657
|
onError: () => {
|
|
663
658
|
r({
|
|
664
659
|
to: `${n.auth}/${i.auth.signIn}`,
|
|
@@ -669,53 +664,53 @@ function tt({ className: e }) {
|
|
|
669
664
|
to: `${n.auth}/${i.auth.signIn}`,
|
|
670
665
|
replace: !0
|
|
671
666
|
})
|
|
672
|
-
}), o =
|
|
673
|
-
return
|
|
667
|
+
}), o = We(!1);
|
|
668
|
+
return Y(() => {
|
|
674
669
|
o.current || (o.current = !0, a());
|
|
675
|
-
}, [a]), /* @__PURE__ */ Q(
|
|
676
|
-
className:
|
|
670
|
+
}, [a]), /* @__PURE__ */ Q(W, {
|
|
671
|
+
className: q("mx-auto my-auto", e),
|
|
677
672
|
color: "current"
|
|
678
673
|
});
|
|
679
674
|
}
|
|
680
675
|
//#endregion
|
|
681
676
|
//#region src/components/auth/sign-up.tsx
|
|
682
|
-
function
|
|
683
|
-
let { additionalFields: s, authClient: c, basePaths:
|
|
677
|
+
function ot({ className: t, socialLayout: n, socialPosition: i = "bottom", variant: o }) {
|
|
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(), [ee, S] = X(""), [te, C] = X(""), { mutate: ne, isPending: w } = ie(c, {
|
|
684
679
|
onError: () => {
|
|
685
|
-
S(""),
|
|
680
|
+
S(""), C(""), x();
|
|
686
681
|
},
|
|
687
|
-
onSuccess: () => {
|
|
688
|
-
d?.requireEmailVerification ? (
|
|
682
|
+
onSuccess: (e, { email: t }) => {
|
|
683
|
+
d?.requireEmailVerification ? (sessionStorage.setItem("better-auth-ui.verify-email", t), v({ to: `${l.auth}/${_.auth.verifyEmail}` })) : v({ to: m });
|
|
689
684
|
}
|
|
690
|
-
}), [
|
|
685
|
+
}), [T, re] = X(!1), [ae, oe] = X(!1), E = qe({ mutationKey: a.signIn.all }) + qe({ mutationKey: a.signUp.all }) > 0, se = p.find((e) => e.captchaComponent)?.captchaComponent, ce = async (e) => {
|
|
691
686
|
e.preventDefault();
|
|
692
687
|
let t = new FormData(e.currentTarget), n = t.get("name") ?? "", r = t.get("email");
|
|
693
|
-
if (d?.confirmPassword &&
|
|
694
|
-
|
|
688
|
+
if (d?.confirmPassword && ee !== te) {
|
|
689
|
+
J.danger(f.auth.passwordsDoNotMatch), S(""), C("");
|
|
695
690
|
return;
|
|
696
691
|
}
|
|
697
692
|
let i = {};
|
|
698
693
|
for (let e of s ?? []) {
|
|
699
694
|
if (!e.signUp || e.readOnly) continue;
|
|
700
|
-
let n =
|
|
695
|
+
let n = u(e, t.get(e.name));
|
|
701
696
|
if (e.validate) try {
|
|
702
697
|
await e.validate(n);
|
|
703
698
|
} catch (e) {
|
|
704
|
-
|
|
699
|
+
J.danger(e instanceof Error ? e.message : String(e));
|
|
705
700
|
return;
|
|
706
701
|
}
|
|
707
702
|
n !== void 0 && (i[e.name] = n);
|
|
708
703
|
}
|
|
709
|
-
|
|
704
|
+
ne({
|
|
710
705
|
name: n,
|
|
711
706
|
email: r,
|
|
712
|
-
password:
|
|
707
|
+
password: ee,
|
|
713
708
|
...i,
|
|
714
|
-
fetchOptions:
|
|
709
|
+
fetchOptions: b
|
|
715
710
|
});
|
|
716
711
|
}, le = d?.enabled && !!g?.length;
|
|
717
712
|
return /* @__PURE__ */ $(j, {
|
|
718
|
-
className:
|
|
713
|
+
className: q("w-full max-w-sm gap-4 md:p-6", t),
|
|
719
714
|
variant: o,
|
|
720
715
|
children: [
|
|
721
716
|
/* @__PURE__ */ Q(j.Header, { children: /* @__PURE__ */ Q(j.Title, {
|
|
@@ -726,11 +721,11 @@ function nt({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
726
721
|
className: "gap-4",
|
|
727
722
|
children: [
|
|
728
723
|
i === "top" && /* @__PURE__ */ $(Z, { children: [!!g?.length && /* @__PURE__ */ Q(r, { socialLayout: n }), le && /* @__PURE__ */ Q(e, { children: f.auth.or })] }),
|
|
729
|
-
d?.enabled && /* @__PURE__ */ $(
|
|
724
|
+
d?.enabled && /* @__PURE__ */ $(L, {
|
|
730
725
|
onSubmit: ce,
|
|
731
726
|
className: "flex flex-col gap-4",
|
|
732
727
|
children: [
|
|
733
|
-
d.name !== !1 && /* @__PURE__ */ $(
|
|
728
|
+
d.name !== !1 && /* @__PURE__ */ $(K, {
|
|
734
729
|
name: "name",
|
|
735
730
|
type: "text",
|
|
736
731
|
autoComplete: "name",
|
|
@@ -739,16 +734,16 @@ function nt({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
739
734
|
if (!e) return f.auth.fieldRequired;
|
|
740
735
|
},
|
|
741
736
|
children: [
|
|
742
|
-
/* @__PURE__ */ Q(
|
|
743
|
-
/* @__PURE__ */ Q(
|
|
737
|
+
/* @__PURE__ */ Q(B, { children: f.auth.name }),
|
|
738
|
+
/* @__PURE__ */ Q(R, {
|
|
744
739
|
placeholder: f.auth.namePlaceholder,
|
|
745
740
|
required: !0,
|
|
746
741
|
variant: o === "transparent" ? "primary" : "secondary"
|
|
747
742
|
}),
|
|
748
|
-
/* @__PURE__ */ Q(
|
|
743
|
+
/* @__PURE__ */ Q(F, {})
|
|
749
744
|
]
|
|
750
745
|
}),
|
|
751
|
-
/* @__PURE__ */ $(
|
|
746
|
+
/* @__PURE__ */ $(K, {
|
|
752
747
|
name: "email",
|
|
753
748
|
type: "email",
|
|
754
749
|
autoComplete: "email",
|
|
@@ -758,28 +753,28 @@ function nt({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
758
753
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) return f.auth.invalidEmail;
|
|
759
754
|
},
|
|
760
755
|
children: [
|
|
761
|
-
/* @__PURE__ */ Q(
|
|
762
|
-
/* @__PURE__ */ Q(
|
|
756
|
+
/* @__PURE__ */ Q(B, { children: f.auth.email }),
|
|
757
|
+
/* @__PURE__ */ Q(R, {
|
|
763
758
|
placeholder: f.auth.emailPlaceholder,
|
|
764
759
|
required: !0,
|
|
765
760
|
variant: o === "transparent" ? "primary" : "secondary"
|
|
766
761
|
}),
|
|
767
|
-
/* @__PURE__ */ Q(
|
|
762
|
+
/* @__PURE__ */ Q(F, {})
|
|
768
763
|
]
|
|
769
764
|
}),
|
|
770
|
-
s?.map((e) => e.signUp === "above" && /* @__PURE__ */ Q(
|
|
765
|
+
s?.map((e) => e.signUp === "above" && /* @__PURE__ */ Q(et, {
|
|
771
766
|
name: e.name,
|
|
772
767
|
field: e,
|
|
773
768
|
isPending: E,
|
|
774
769
|
variant: o
|
|
775
770
|
}, e.name)),
|
|
776
|
-
/* @__PURE__ */ $(
|
|
771
|
+
/* @__PURE__ */ $(K, {
|
|
777
772
|
minLength: d?.minPasswordLength,
|
|
778
773
|
maxLength: d?.maxPasswordLength,
|
|
779
774
|
name: "password",
|
|
780
775
|
autoComplete: "new-password",
|
|
781
776
|
isDisabled: E,
|
|
782
|
-
value:
|
|
777
|
+
value: ee,
|
|
783
778
|
onChange: S,
|
|
784
779
|
validate: (e) => {
|
|
785
780
|
if (!e) return f.auth.fieldRequired;
|
|
@@ -788,38 +783,38 @@ function nt({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
788
783
|
if (n && e.length > n) return f.auth.tooLong.replace("{{max}}", String(n));
|
|
789
784
|
},
|
|
790
785
|
children: [
|
|
791
|
-
/* @__PURE__ */ Q(
|
|
792
|
-
/* @__PURE__ */ $(
|
|
786
|
+
/* @__PURE__ */ Q(B, { children: f.auth.password }),
|
|
787
|
+
/* @__PURE__ */ $(z, {
|
|
793
788
|
variant: o === "transparent" ? "primary" : "secondary",
|
|
794
|
-
children: [/* @__PURE__ */ Q(
|
|
789
|
+
children: [/* @__PURE__ */ Q(z.Input, {
|
|
795
790
|
placeholder: f.auth.passwordPlaceholder,
|
|
796
|
-
type:
|
|
791
|
+
type: T ? "text" : "password",
|
|
797
792
|
name: "password",
|
|
798
793
|
required: !0
|
|
799
|
-
}), /* @__PURE__ */ Q(
|
|
794
|
+
}), /* @__PURE__ */ Q(z.Suffix, {
|
|
800
795
|
className: "px-0",
|
|
801
796
|
children: /* @__PURE__ */ Q(k, {
|
|
802
797
|
isIconOnly: !0,
|
|
803
|
-
"aria-label":
|
|
798
|
+
"aria-label": T ? f.auth.hidePassword : f.auth.showPassword,
|
|
804
799
|
size: "sm",
|
|
805
800
|
variant: "ghost",
|
|
806
|
-
onPress: () =>
|
|
801
|
+
onPress: () => re(!T),
|
|
807
802
|
isDisabled: E,
|
|
808
|
-
children: Q(
|
|
803
|
+
children: Q(T ? O : D, {})
|
|
809
804
|
})
|
|
810
805
|
})]
|
|
811
806
|
}),
|
|
812
|
-
/* @__PURE__ */ Q(
|
|
807
|
+
/* @__PURE__ */ Q(F, {})
|
|
813
808
|
]
|
|
814
809
|
}),
|
|
815
|
-
d?.confirmPassword && /* @__PURE__ */ $(
|
|
810
|
+
d?.confirmPassword && /* @__PURE__ */ $(K, {
|
|
816
811
|
minLength: d?.minPasswordLength,
|
|
817
812
|
maxLength: d?.maxPasswordLength,
|
|
818
813
|
name: "confirmPassword",
|
|
819
814
|
autoComplete: "new-password",
|
|
820
815
|
isDisabled: E,
|
|
821
816
|
value: te,
|
|
822
|
-
onChange:
|
|
817
|
+
onChange: C,
|
|
823
818
|
validate: (e) => {
|
|
824
819
|
if (!e) return f.auth.fieldRequired;
|
|
825
820
|
let t = d?.minPasswordLength, n = d?.maxPasswordLength;
|
|
@@ -827,31 +822,31 @@ function nt({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
827
822
|
if (n && e.length > n) return f.auth.tooLong.replace("{{max}}", String(n));
|
|
828
823
|
},
|
|
829
824
|
children: [
|
|
830
|
-
/* @__PURE__ */ Q(
|
|
831
|
-
/* @__PURE__ */ $(
|
|
825
|
+
/* @__PURE__ */ Q(B, { children: f.auth.confirmPassword }),
|
|
826
|
+
/* @__PURE__ */ $(z, {
|
|
832
827
|
variant: o === "transparent" ? "primary" : "secondary",
|
|
833
|
-
children: [/* @__PURE__ */ Q(
|
|
828
|
+
children: [/* @__PURE__ */ Q(z.Input, {
|
|
834
829
|
name: "confirmPassword",
|
|
835
830
|
placeholder: f.auth.confirmPasswordPlaceholder,
|
|
836
|
-
type:
|
|
831
|
+
type: ae ? "text" : "password",
|
|
837
832
|
required: !0
|
|
838
|
-
}), /* @__PURE__ */ Q(
|
|
833
|
+
}), /* @__PURE__ */ Q(z.Suffix, {
|
|
839
834
|
className: "px-0",
|
|
840
835
|
children: /* @__PURE__ */ Q(k, {
|
|
841
836
|
isIconOnly: !0,
|
|
842
|
-
"aria-label":
|
|
837
|
+
"aria-label": ae ? f.auth.hidePassword : f.auth.showPassword,
|
|
843
838
|
size: "sm",
|
|
844
839
|
variant: "ghost",
|
|
845
|
-
onPress: () => oe(!
|
|
840
|
+
onPress: () => oe(!ae),
|
|
846
841
|
isDisabled: E,
|
|
847
|
-
children: Q(
|
|
842
|
+
children: Q(ae ? O : D, {})
|
|
848
843
|
})
|
|
849
844
|
})]
|
|
850
845
|
}),
|
|
851
|
-
/* @__PURE__ */ Q(
|
|
846
|
+
/* @__PURE__ */ Q(F, {})
|
|
852
847
|
]
|
|
853
848
|
}),
|
|
854
|
-
s?.map((e) => e.signUp && e.signUp !== "above" && /* @__PURE__ */ Q(
|
|
849
|
+
s?.map((e) => e.signUp && e.signUp !== "above" && /* @__PURE__ */ Q(et, {
|
|
855
850
|
name: e.name,
|
|
856
851
|
field: e,
|
|
857
852
|
isPending: E,
|
|
@@ -867,7 +862,7 @@ function nt({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
867
862
|
type: "submit",
|
|
868
863
|
className: "w-full",
|
|
869
864
|
isPending: E,
|
|
870
|
-
children: [
|
|
865
|
+
children: [w && /* @__PURE__ */ Q(W, {
|
|
871
866
|
color: "current",
|
|
872
867
|
size: "sm"
|
|
873
868
|
}), f.auth.signUp]
|
|
@@ -880,13 +875,13 @@ function nt({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
880
875
|
}),
|
|
881
876
|
/* @__PURE__ */ Q(j.Footer, {
|
|
882
877
|
className: "flex-col gap-3",
|
|
883
|
-
children: /* @__PURE__ */ $(
|
|
878
|
+
children: /* @__PURE__ */ $(N, {
|
|
884
879
|
className: "text-sm",
|
|
885
880
|
children: [
|
|
886
881
|
f.auth.alreadyHaveAnAccount,
|
|
887
882
|
" ",
|
|
888
|
-
/* @__PURE__ */ Q(
|
|
889
|
-
href: `${
|
|
883
|
+
/* @__PURE__ */ Q(V, {
|
|
884
|
+
href: `${l.auth}/${_.auth.signIn}`,
|
|
890
885
|
className: "text-accent no-underline hover:underline decoration-accent-hover",
|
|
891
886
|
children: f.auth.signIn
|
|
892
887
|
})
|
|
@@ -897,23 +892,111 @@ function nt({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
|
|
|
897
892
|
});
|
|
898
893
|
}
|
|
899
894
|
//#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
|
+
//#region src/components/auth/verify-email.tsx
|
|
908
|
+
var ct = 60;
|
|
909
|
+
function lt({ className: e, variant: t }) {
|
|
910
|
+
let { authClient: n, basePaths: r, baseURL: i, localization: a, navigate: o, redirectTo: s, viewPaths: c } = h(), [l, u] = X(Fe() && sessionStorage.getItem("better-auth-ui.verify-email") || ""), [d, f] = X(ct);
|
|
911
|
+
Y(() => {
|
|
912
|
+
let e = sessionStorage.getItem("better-auth-ui.verify-email");
|
|
913
|
+
if (!e) {
|
|
914
|
+
o({ to: `${r.auth}/${c.auth.signIn}` });
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
u(e);
|
|
918
|
+
}, [
|
|
919
|
+
r.auth,
|
|
920
|
+
o,
|
|
921
|
+
c.auth.signIn
|
|
922
|
+
]), Y(() => {
|
|
923
|
+
if (d <= 0) return;
|
|
924
|
+
let e = setInterval(() => {
|
|
925
|
+
f((e) => e > 0 ? e - 1 : 0);
|
|
926
|
+
}, 1e3);
|
|
927
|
+
return () => clearInterval(e);
|
|
928
|
+
}, [d]);
|
|
929
|
+
let { mutate: p, isPending: m } = ne(n, { onSuccess: () => {
|
|
930
|
+
J.success(a.auth.verificationEmailSent), f(ct);
|
|
931
|
+
} }), g = d > 0;
|
|
932
|
+
return /* @__PURE__ */ $(j, {
|
|
933
|
+
className: q("w-full max-w-sm gap-4 md:p-6", e),
|
|
934
|
+
variant: t,
|
|
935
|
+
children: [
|
|
936
|
+
/* @__PURE__ */ Q(j.Header, { children: /* @__PURE__ */ Q(j.Title, {
|
|
937
|
+
className: "text-xl font-semibold mb-1",
|
|
938
|
+
children: a.auth.verifyEmail
|
|
939
|
+
}) }),
|
|
940
|
+
/* @__PURE__ */ $(j.Content, {
|
|
941
|
+
className: "gap-4",
|
|
942
|
+
children: [/* @__PURE__ */ Q(N, {
|
|
943
|
+
className: "text-sm",
|
|
944
|
+
children: a.auth.checkYourEmail
|
|
945
|
+
}), /* @__PURE__ */ $("div", {
|
|
946
|
+
className: "flex flex-col gap-3",
|
|
947
|
+
children: [/* @__PURE__ */ Q(st, { email: l }), /* @__PURE__ */ $(k, {
|
|
948
|
+
className: "w-full",
|
|
949
|
+
variant: "tertiary",
|
|
950
|
+
isDisabled: !l || g || m,
|
|
951
|
+
isPending: m,
|
|
952
|
+
onPress: () => p({
|
|
953
|
+
email: l,
|
|
954
|
+
callbackURL: `${i}${s}`
|
|
955
|
+
}),
|
|
956
|
+
children: [m && /* @__PURE__ */ Q(W, {
|
|
957
|
+
color: "current",
|
|
958
|
+
size: "sm"
|
|
959
|
+
}), g ? a.auth.resendIn.replace("{{seconds}}", String(d)) : a.auth.resend]
|
|
960
|
+
})]
|
|
961
|
+
})]
|
|
962
|
+
}),
|
|
963
|
+
/* @__PURE__ */ Q(j.Footer, {
|
|
964
|
+
className: "flex-col gap-3",
|
|
965
|
+
children: /* @__PURE__ */ $(N, {
|
|
966
|
+
className: "text-sm",
|
|
967
|
+
children: [
|
|
968
|
+
a.auth.alreadyVerifiedYourEmail,
|
|
969
|
+
" ",
|
|
970
|
+
/* @__PURE__ */ Q(V, {
|
|
971
|
+
href: `${r.auth}/${c.auth.signIn}`,
|
|
972
|
+
className: "text-accent no-underline hover:underline decoration-accent-hover",
|
|
973
|
+
children: a.auth.signIn
|
|
974
|
+
})
|
|
975
|
+
]
|
|
976
|
+
})
|
|
977
|
+
})
|
|
978
|
+
]
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
//#endregion
|
|
900
982
|
//#region src/components/auth/auth.tsx
|
|
901
|
-
var
|
|
983
|
+
var ut = [
|
|
902
984
|
"signUp",
|
|
903
985
|
"forgotPassword",
|
|
904
986
|
"resetPassword"
|
|
905
|
-
],
|
|
906
|
-
signIn:
|
|
907
|
-
signOut:
|
|
908
|
-
signUp:
|
|
909
|
-
forgotPassword:
|
|
910
|
-
resetPassword:
|
|
987
|
+
], dt = {
|
|
988
|
+
signIn: it,
|
|
989
|
+
signOut: at,
|
|
990
|
+
signUp: ot,
|
|
991
|
+
forgotPassword: nt,
|
|
992
|
+
resetPassword: rt,
|
|
993
|
+
verifyEmail: lt
|
|
911
994
|
};
|
|
912
|
-
function
|
|
913
|
-
let { basePaths: o, emailAndPassword: s, plugins: c, viewPaths: l, navigate: u } =
|
|
995
|
+
function ft({ className: e, path: t, socialLayout: n, socialPosition: r, variant: i, view: a }) {
|
|
996
|
+
let { basePaths: o, emailAndPassword: s, plugins: c, viewPaths: l, navigate: u } = h();
|
|
914
997
|
if (!a && !t) throw Error("[Better Auth UI] Either `view` or `path` must be provided");
|
|
915
|
-
let d = a || Object.keys(l.auth).find((e) => l.auth[e] === t), f = !s?.enabled && d &&
|
|
916
|
-
if (
|
|
998
|
+
let d = a || Object.keys(l.auth).find((e) => l.auth[e] === t), f = !s?.enabled && d && ut.includes(d);
|
|
999
|
+
if (Y(() => {
|
|
917
1000
|
f && u({
|
|
918
1001
|
to: `${o.auth}/${l.auth.signIn}`,
|
|
919
1002
|
replace: !0
|
|
@@ -944,8 +1027,8 @@ function at({ className: e, path: t, socialLayout: n, socialPosition: r, variant
|
|
|
944
1027
|
variant: i
|
|
945
1028
|
});
|
|
946
1029
|
}
|
|
947
|
-
let p = d ?
|
|
948
|
-
if (!p) throw Error(`[Better Auth UI] Unknown view "${d}". Valid views are: ${Object.keys(
|
|
1030
|
+
let p = d ? dt[d] : void 0;
|
|
1031
|
+
if (!p) throw Error(`[Better Auth UI] Unknown view "${d}". Valid views are: ${Object.keys(dt).join(", ")}`);
|
|
949
1032
|
return /* @__PURE__ */ Q(p, {
|
|
950
1033
|
className: e,
|
|
951
1034
|
socialLayout: n,
|
|
@@ -955,20 +1038,20 @@ function at({ className: e, path: t, socialLayout: n, socialPosition: r, variant
|
|
|
955
1038
|
}
|
|
956
1039
|
//#endregion
|
|
957
1040
|
//#region src/components/auth/error-toaster.tsx
|
|
958
|
-
function
|
|
959
|
-
let e =
|
|
960
|
-
return
|
|
1041
|
+
function pt() {
|
|
1042
|
+
let e = Je();
|
|
1043
|
+
return Y(() => {
|
|
961
1044
|
let t = e.getQueryCache(), n = t.config.onError;
|
|
962
1045
|
t.config.onError = (e, t) => {
|
|
963
|
-
if (n?.(e, t), !
|
|
1046
|
+
if (n?.(e, t), !Ke({ queryKey: o.all }, t)) return;
|
|
964
1047
|
let r = e;
|
|
965
|
-
r?.error?.code !== "EMAIL_NOT_VERIFIED" && r?.error &&
|
|
1048
|
+
r?.error?.code !== "EMAIL_NOT_VERIFIED" && r?.error && J.danger(r.error.message);
|
|
966
1049
|
};
|
|
967
1050
|
let r = e.getMutationCache(), i = r.config.onError;
|
|
968
1051
|
return r.config.onError = (e, t, n, r, o) => {
|
|
969
|
-
if (i?.(e, t, n, r, o), !
|
|
1052
|
+
if (i?.(e, t, n, r, o), !Ge({ mutationKey: a.all }, r)) return;
|
|
970
1053
|
let s = e;
|
|
971
|
-
s.error?.code !== "EMAIL_NOT_VERIFIED" &&
|
|
1054
|
+
s.error?.code !== "EMAIL_NOT_VERIFIED" && J.danger(s.error?.message || s.message);
|
|
972
1055
|
}, () => {
|
|
973
1056
|
t.config.onError = n, r.config.onError = i;
|
|
974
1057
|
};
|
|
@@ -976,20 +1059,20 @@ function ot() {
|
|
|
976
1059
|
}
|
|
977
1060
|
//#endregion
|
|
978
1061
|
//#region src/components/auth/auth-provider.tsx
|
|
979
|
-
function
|
|
980
|
-
return /* @__PURE__ */ Q(
|
|
1062
|
+
function mt({ children: e, navigate: t, ...n }) {
|
|
1063
|
+
return /* @__PURE__ */ Q(f, {
|
|
981
1064
|
navigate: t,
|
|
982
1065
|
...n,
|
|
983
|
-
children: /* @__PURE__ */ $(
|
|
1066
|
+
children: /* @__PURE__ */ $(ke, {
|
|
984
1067
|
navigate: (e) => t({ to: e }),
|
|
985
|
-
children: [e, /* @__PURE__ */ Q(
|
|
1068
|
+
children: [e, /* @__PURE__ */ Q(pt, {})]
|
|
986
1069
|
})
|
|
987
1070
|
});
|
|
988
1071
|
}
|
|
989
1072
|
//#endregion
|
|
990
1073
|
//#region src/components/auth/settings/account/change-email.tsx
|
|
991
|
-
function
|
|
992
|
-
let { authClient: r, localization: i, baseURL: a, viewPaths: o } =
|
|
1074
|
+
function ht({ className: e, variant: t, ...n }) {
|
|
1075
|
+
let { authClient: r, localization: i, baseURL: a, viewPaths: o } = h(), { data: s } = w(r), { mutate: c, isPending: l } = _(r, { onSuccess: () => J.success(i.settings.changeEmailSuccess) });
|
|
993
1076
|
function u(e) {
|
|
994
1077
|
e.preventDefault(), c({
|
|
995
1078
|
newEmail: new FormData(e.currentTarget).get("email"),
|
|
@@ -997,37 +1080,37 @@ function ct({ className: e, variant: t, ...n }) {
|
|
|
997
1080
|
});
|
|
998
1081
|
}
|
|
999
1082
|
return /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q("h2", {
|
|
1000
|
-
className:
|
|
1083
|
+
className: q("text-sm font-semibold mb-3"),
|
|
1001
1084
|
children: i.settings.changeEmail
|
|
1002
1085
|
}), /* @__PURE__ */ Q(j, {
|
|
1003
|
-
className:
|
|
1086
|
+
className: q("p-4 gap-4", e),
|
|
1004
1087
|
variant: t,
|
|
1005
1088
|
...n,
|
|
1006
|
-
children: /* @__PURE__ */ Q(j.Content, { children: /* @__PURE__ */ Q(
|
|
1089
|
+
children: /* @__PURE__ */ Q(j.Content, { children: /* @__PURE__ */ Q(L, {
|
|
1007
1090
|
onSubmit: u,
|
|
1008
|
-
children: /* @__PURE__ */ $(
|
|
1091
|
+
children: /* @__PURE__ */ $(I, {
|
|
1009
1092
|
className: "w-full gap-4",
|
|
1010
|
-
children: [/* @__PURE__ */ Q(
|
|
1093
|
+
children: [/* @__PURE__ */ Q(I.Group, { children: /* @__PURE__ */ $(K, {
|
|
1011
1094
|
name: "email",
|
|
1012
1095
|
type: "email",
|
|
1013
1096
|
defaultValue: s?.user.email,
|
|
1014
1097
|
isDisabled: l || !s,
|
|
1015
1098
|
children: [
|
|
1016
|
-
/* @__PURE__ */ Q(
|
|
1017
|
-
s ? /* @__PURE__ */ Q(
|
|
1099
|
+
/* @__PURE__ */ Q(B, { children: i.auth.email }),
|
|
1100
|
+
s ? /* @__PURE__ */ Q(R, {
|
|
1018
1101
|
required: !0,
|
|
1019
1102
|
variant: t === "transparent" ? "primary" : "secondary",
|
|
1020
1103
|
autoComplete: "email",
|
|
1021
1104
|
placeholder: i.auth.emailPlaceholder
|
|
1022
|
-
}) : /* @__PURE__ */ Q(
|
|
1023
|
-
/* @__PURE__ */ Q(
|
|
1105
|
+
}) : /* @__PURE__ */ Q(U, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
1106
|
+
/* @__PURE__ */ Q(F, {})
|
|
1024
1107
|
]
|
|
1025
|
-
}, `${s?.user.id}-${s?.user.email}-email`) }), /* @__PURE__ */ Q(
|
|
1108
|
+
}, `${s?.user.id}-${s?.user.email}-email`) }), /* @__PURE__ */ Q(I.Actions, { children: /* @__PURE__ */ $(k, {
|
|
1026
1109
|
type: "submit",
|
|
1027
1110
|
isPending: l,
|
|
1028
1111
|
isDisabled: !s,
|
|
1029
1112
|
size: "sm",
|
|
1030
|
-
children: [l && /* @__PURE__ */ Q(
|
|
1113
|
+
children: [l && /* @__PURE__ */ Q(W, {
|
|
1031
1114
|
color: "current",
|
|
1032
1115
|
size: "sm"
|
|
1033
1116
|
}), i.settings.updateEmail]
|
|
@@ -1038,17 +1121,17 @@ function ct({ className: e, variant: t, ...n }) {
|
|
|
1038
1121
|
}
|
|
1039
1122
|
//#endregion
|
|
1040
1123
|
//#region src/components/auth/settings/account/change-avatar.tsx
|
|
1041
|
-
function
|
|
1042
|
-
let { authClient: t, localization: r, avatar: i } =
|
|
1124
|
+
function gt({ className: e }) {
|
|
1125
|
+
let { authClient: t, localization: r, avatar: i } = h(), { data: a } = w(t), { mutate: o, isPending: c } = oe(t), l = We(null), [u, d] = X(!1), [f, p] = X(!1), m = c || u || f;
|
|
1043
1126
|
async function g(e) {
|
|
1044
1127
|
let t = e.target.files?.[0];
|
|
1045
1128
|
if (t) {
|
|
1046
1129
|
e.target.value = "", d(!0);
|
|
1047
1130
|
try {
|
|
1048
1131
|
let e = await i.resize?.(t, i.size, i.extension) || t;
|
|
1049
|
-
o({ image: await i.upload?.(e) || await s(e) }, { onSuccess: () =>
|
|
1132
|
+
o({ image: await i.upload?.(e) || await s(e) }, { onSuccess: () => J.success(r.settings.avatarChangedSuccess) });
|
|
1050
1133
|
} catch (e) {
|
|
1051
|
-
e instanceof Error &&
|
|
1134
|
+
e instanceof Error && J.danger(e.message);
|
|
1052
1135
|
}
|
|
1053
1136
|
d(!1);
|
|
1054
1137
|
}
|
|
@@ -1064,13 +1147,13 @@ function lt({ className: e }) {
|
|
|
1064
1147
|
p(!1);
|
|
1065
1148
|
}
|
|
1066
1149
|
}
|
|
1067
|
-
|
|
1150
|
+
J.success(r.settings.avatarDeletedSuccess);
|
|
1068
1151
|
} });
|
|
1069
1152
|
}
|
|
1070
1153
|
return /* @__PURE__ */ $("div", {
|
|
1071
|
-
className:
|
|
1154
|
+
className: q("flex flex-col gap-1", e),
|
|
1072
1155
|
children: [
|
|
1073
|
-
/* @__PURE__ */ Q(
|
|
1156
|
+
/* @__PURE__ */ Q(B, {
|
|
1074
1157
|
isDisabled: !a,
|
|
1075
1158
|
children: r.settings.avatar
|
|
1076
1159
|
}),
|
|
@@ -1088,29 +1171,29 @@ function lt({ className: e }) {
|
|
|
1088
1171
|
isIconOnly: !0,
|
|
1089
1172
|
variant: "ghost",
|
|
1090
1173
|
className: "p-0 h-auto w-auto rounded-full",
|
|
1091
|
-
isDisabled: !a ||
|
|
1174
|
+
isDisabled: !a || m,
|
|
1092
1175
|
onPress: () => l.current?.click(),
|
|
1093
1176
|
children: /* @__PURE__ */ Q(n, {
|
|
1094
1177
|
size: "lg",
|
|
1095
|
-
isPending:
|
|
1178
|
+
isPending: m
|
|
1096
1179
|
})
|
|
1097
|
-
}), /* @__PURE__ */ $(
|
|
1098
|
-
isDisabled: !a ||
|
|
1180
|
+
}), /* @__PURE__ */ $(P, { children: [/* @__PURE__ */ $(k, {
|
|
1181
|
+
isDisabled: !a || m,
|
|
1099
1182
|
size: "sm",
|
|
1100
1183
|
variant: "secondary",
|
|
1101
|
-
children: [
|
|
1102
|
-
}), /* @__PURE__ */ Q(
|
|
1184
|
+
children: [m && /* @__PURE__ */ Q(W, { size: "sm" }), r.settings.changeAvatar]
|
|
1185
|
+
}), /* @__PURE__ */ Q(P.Popover, {
|
|
1103
1186
|
className: "min-w-fit",
|
|
1104
|
-
children: /* @__PURE__ */ $(
|
|
1187
|
+
children: /* @__PURE__ */ $(P.Menu, { children: [/* @__PURE__ */ $(P.Item, {
|
|
1105
1188
|
textValue: r.settings.uploadAvatar,
|
|
1106
1189
|
onAction: () => l.current?.click(),
|
|
1107
|
-
children: [/* @__PURE__ */ Q(
|
|
1108
|
-
}), /* @__PURE__ */ $(
|
|
1190
|
+
children: [/* @__PURE__ */ Q(de, { className: "text-muted" }), /* @__PURE__ */ Q(B, { children: r.settings.uploadAvatar })]
|
|
1191
|
+
}), /* @__PURE__ */ $(P.Item, {
|
|
1109
1192
|
textValue: r.settings.deleteAvatar,
|
|
1110
1193
|
isDisabled: !a?.user.image,
|
|
1111
1194
|
onAction: _,
|
|
1112
1195
|
variant: "danger",
|
|
1113
|
-
children: [/* @__PURE__ */ Q(
|
|
1196
|
+
children: [/* @__PURE__ */ Q(Se, { className: "text-danger" }), /* @__PURE__ */ Q(B, { children: r.settings.deleteAvatar })]
|
|
1114
1197
|
})] })
|
|
1115
1198
|
})] })]
|
|
1116
1199
|
})
|
|
@@ -1119,18 +1202,18 @@ function lt({ className: e }) {
|
|
|
1119
1202
|
}
|
|
1120
1203
|
//#endregion
|
|
1121
1204
|
//#region src/components/auth/settings/account/user-profile.tsx
|
|
1122
|
-
function
|
|
1123
|
-
let { additionalFields: r, authClient: i, localization: a } =
|
|
1124
|
-
async function
|
|
1205
|
+
function _t({ className: e, variant: t, ...n }) {
|
|
1206
|
+
let { additionalFields: r, authClient: i, localization: a } = h(), { data: o } = w(i), { mutate: s, isPending: c } = oe(i, { onSuccess: () => J.success(a.settings.profileUpdatedSuccess) });
|
|
1207
|
+
async function l(e) {
|
|
1125
1208
|
e.preventDefault();
|
|
1126
1209
|
let t = new FormData(e.currentTarget), n = t.get("name"), i = {};
|
|
1127
1210
|
for (let e of r ?? []) {
|
|
1128
1211
|
if (e.profile === !1 || e.readOnly) continue;
|
|
1129
|
-
let n =
|
|
1212
|
+
let n = u(e, t.get(e.name));
|
|
1130
1213
|
if (e.validate) try {
|
|
1131
1214
|
await e.validate(n);
|
|
1132
1215
|
} catch (e) {
|
|
1133
|
-
|
|
1216
|
+
J.danger(e instanceof Error ? e.message : String(e));
|
|
1134
1217
|
return;
|
|
1135
1218
|
}
|
|
1136
1219
|
n !== void 0 && (i[e.name] = n);
|
|
@@ -1141,37 +1224,37 @@ function ut({ className: e, variant: t, ...n }) {
|
|
|
1141
1224
|
});
|
|
1142
1225
|
}
|
|
1143
1226
|
return /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q("h2", {
|
|
1144
|
-
className:
|
|
1227
|
+
className: q("text-sm font-semibold mb-3"),
|
|
1145
1228
|
children: a.settings.userProfile
|
|
1146
1229
|
}), /* @__PURE__ */ Q(j, {
|
|
1147
|
-
className:
|
|
1230
|
+
className: q("p-4 gap-4", e),
|
|
1148
1231
|
variant: t,
|
|
1149
1232
|
...n,
|
|
1150
|
-
children: /* @__PURE__ */ Q(j.Content, { children: /* @__PURE__ */ $(
|
|
1151
|
-
onSubmit:
|
|
1233
|
+
children: /* @__PURE__ */ Q(j.Content, { children: /* @__PURE__ */ $(L, {
|
|
1234
|
+
onSubmit: l,
|
|
1152
1235
|
className: "flex flex-col gap-4",
|
|
1153
1236
|
children: [
|
|
1154
|
-
/* @__PURE__ */ Q(
|
|
1155
|
-
/* @__PURE__ */ $(
|
|
1237
|
+
/* @__PURE__ */ Q(gt, {}),
|
|
1238
|
+
/* @__PURE__ */ $(K, {
|
|
1156
1239
|
name: "name",
|
|
1157
1240
|
defaultValue: o?.user.name,
|
|
1158
1241
|
isDisabled: c || !o,
|
|
1159
1242
|
children: [
|
|
1160
|
-
/* @__PURE__ */ Q(
|
|
1161
|
-
/* @__PURE__ */ Q(
|
|
1162
|
-
className:
|
|
1243
|
+
/* @__PURE__ */ Q(B, { children: a.auth.name }),
|
|
1244
|
+
/* @__PURE__ */ Q(R, {
|
|
1245
|
+
className: q(!o && "hidden"),
|
|
1163
1246
|
autoComplete: "name",
|
|
1164
1247
|
placeholder: a.auth.name,
|
|
1165
1248
|
variant: t === "transparent" ? "primary" : "secondary"
|
|
1166
1249
|
}),
|
|
1167
|
-
!o && /* @__PURE__ */ Q(
|
|
1168
|
-
/* @__PURE__ */ Q(
|
|
1250
|
+
!o && /* @__PURE__ */ Q(U, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
1251
|
+
/* @__PURE__ */ Q(F, {})
|
|
1169
1252
|
]
|
|
1170
1253
|
}, `${o?.user?.id}-${o?.user?.name}-name`),
|
|
1171
1254
|
r?.filter((e) => e.profile !== !1).map((e) => {
|
|
1172
|
-
if (!o) return e.inputType === "hidden" ? null : /* @__PURE__ */ Q(
|
|
1255
|
+
if (!o) return e.inputType === "hidden" ? null : /* @__PURE__ */ Q(U, { className: "h-10 md:h-9 w-full rounded-xl" }, e.name);
|
|
1173
1256
|
let n = o.user[e.name], r = `${o.user.id}-${e.name}-${n instanceof Date ? n.toISOString() : String(n ?? "")}`;
|
|
1174
|
-
return /* @__PURE__ */ Q(
|
|
1257
|
+
return /* @__PURE__ */ Q(et, {
|
|
1175
1258
|
name: e.name,
|
|
1176
1259
|
field: {
|
|
1177
1260
|
...e,
|
|
@@ -1187,7 +1270,7 @@ function ut({ className: e, variant: t, ...n }) {
|
|
|
1187
1270
|
isDisabled: !o,
|
|
1188
1271
|
size: "sm",
|
|
1189
1272
|
className: "self-start mt-1",
|
|
1190
|
-
children: [c && /* @__PURE__ */ Q(
|
|
1273
|
+
children: [c && /* @__PURE__ */ Q(W, {
|
|
1191
1274
|
color: "current",
|
|
1192
1275
|
size: "sm"
|
|
1193
1276
|
}), a.settings.saveChanges]
|
|
@@ -1198,21 +1281,21 @@ function ut({ className: e, variant: t, ...n }) {
|
|
|
1198
1281
|
}
|
|
1199
1282
|
//#endregion
|
|
1200
1283
|
//#region src/components/auth/settings/account/account-settings.tsx
|
|
1201
|
-
function
|
|
1202
|
-
let { emailAndPassword: r, plugins: i } =
|
|
1284
|
+
function vt({ className: e, variant: t, ...n }) {
|
|
1285
|
+
let { emailAndPassword: r, plugins: i } = h(), a = i.some((e) => e.id === "magicLink");
|
|
1203
1286
|
return /* @__PURE__ */ $("div", {
|
|
1204
|
-
className:
|
|
1287
|
+
className: q("flex w-full flex-col gap-4 md:gap-6", e),
|
|
1205
1288
|
...n,
|
|
1206
1289
|
children: [
|
|
1207
|
-
/* @__PURE__ */ Q(
|
|
1208
|
-
(r?.enabled || a) && /* @__PURE__ */ Q(
|
|
1290
|
+
/* @__PURE__ */ Q(_t, { variant: t }),
|
|
1291
|
+
(r?.enabled || a) && /* @__PURE__ */ Q(ht, { variant: t }),
|
|
1209
1292
|
i.flatMap((e) => e.accountCards?.map((n, r) => /* @__PURE__ */ Q(n, { variant: t }, `${e.id}-${r.toString()}`)))
|
|
1210
1293
|
]
|
|
1211
1294
|
});
|
|
1212
1295
|
}
|
|
1213
1296
|
//#endregion
|
|
1214
1297
|
//#region src/components/auth/settings/security/active-session.tsx
|
|
1215
|
-
function
|
|
1298
|
+
function yt(e) {
|
|
1216
1299
|
let t = Math.floor((Date.now() - e.getTime()) / 1e3), n = new Intl.RelativeTimeFormat(void 0, { numeric: "auto" });
|
|
1217
1300
|
for (let [e, r] of [
|
|
1218
1301
|
["year", 31536e3],
|
|
@@ -1225,27 +1308,27 @@ function ft(e) {
|
|
|
1225
1308
|
]) if (t >= r) return n.format(-Math.floor(t / r), e);
|
|
1226
1309
|
return n.format(0, "second");
|
|
1227
1310
|
}
|
|
1228
|
-
function
|
|
1229
|
-
let { authClient: t, basePaths: n, localization: r, viewPaths: i, navigate: a } =
|
|
1311
|
+
function bt({ activeSession: e }) {
|
|
1312
|
+
let { authClient: t, basePaths: n, localization: r, viewPaths: i, navigate: a } = h(), { data: o } = w(t, { refetchOnMount: !1 }), { mutate: s, isPending: c } = C(t, { onSuccess: () => J.success(r.settings.revokeSessionSuccess) }), l = e.token === o?.session.token, u = Xe.parse(e.userAgent || "");
|
|
1230
1313
|
return /* @__PURE__ */ $("div", {
|
|
1231
1314
|
className: "flex items-center gap-3",
|
|
1232
1315
|
children: [
|
|
1233
1316
|
/* @__PURE__ */ Q("div", {
|
|
1234
1317
|
className: "flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-secondary",
|
|
1235
|
-
children: u.platform.type === "mobile" || u.platform.type === "tablet" ? /* @__PURE__ */ Q(
|
|
1318
|
+
children: u.platform.type === "mobile" || u.platform.type === "tablet" ? /* @__PURE__ */ Q(xe, { className: "size-4.5" }) : /* @__PURE__ */ Q(pe, { className: "size-4.5" })
|
|
1236
1319
|
}),
|
|
1237
1320
|
/* @__PURE__ */ $("div", {
|
|
1238
1321
|
className: "flex flex-col min-w-0",
|
|
1239
1322
|
children: [/* @__PURE__ */ $("span", {
|
|
1240
1323
|
className: "text-sm font-medium truncate",
|
|
1241
1324
|
children: [u.browser.name || "Unknown Browser", u.os.name ? `, ${u.os.name}` : ""]
|
|
1242
|
-
}), l ? /* @__PURE__ */ Q(
|
|
1325
|
+
}), l ? /* @__PURE__ */ Q(we, {
|
|
1243
1326
|
color: "accent",
|
|
1244
1327
|
size: "sm",
|
|
1245
1328
|
children: r.settings.currentSession
|
|
1246
1329
|
}) : e.createdAt && /* @__PURE__ */ Q("span", {
|
|
1247
1330
|
className: "text-xs text-muted capitalize",
|
|
1248
|
-
children:
|
|
1331
|
+
children: yt(e.createdAt)
|
|
1249
1332
|
})]
|
|
1250
1333
|
}),
|
|
1251
1334
|
/* @__PURE__ */ $(k, {
|
|
@@ -1255,52 +1338,52 @@ function pt({ activeSession: e }) {
|
|
|
1255
1338
|
onPress: () => l ? a({ to: `${n.auth}/${i.auth.signOut}` }) : s(e),
|
|
1256
1339
|
isPending: c,
|
|
1257
1340
|
"aria-label": l ? r.auth.signOut : r.settings.revokeSession,
|
|
1258
|
-
children: [c ? /* @__PURE__ */ Q(
|
|
1341
|
+
children: [c ? /* @__PURE__ */ Q(W, {
|
|
1259
1342
|
color: "current",
|
|
1260
1343
|
size: "sm"
|
|
1261
|
-
}) : Q(l ?
|
|
1344
|
+
}) : Q(l ? E : Ce, {}), l ? r.auth.signOut : r.settings.revoke]
|
|
1262
1345
|
})
|
|
1263
1346
|
]
|
|
1264
1347
|
});
|
|
1265
1348
|
}
|
|
1266
1349
|
//#endregion
|
|
1267
1350
|
//#region src/components/auth/settings/security/active-sessions.tsx
|
|
1268
|
-
function
|
|
1269
|
-
let { authClient: r, localization: i } =
|
|
1351
|
+
function xt({ className: e, variant: t, ...n }) {
|
|
1352
|
+
let { authClient: r, localization: i } = h(), { data: a } = w(r), { data: o, isPending: s } = ee(r), c = o && [...o].sort((e, t) => e.id === a?.session.id ? -1 : +(t.id === a?.session.id));
|
|
1270
1353
|
return /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q("h2", {
|
|
1271
|
-
className:
|
|
1354
|
+
className: q("text-sm font-semibold mb-3"),
|
|
1272
1355
|
children: i.settings.activeSessions
|
|
1273
1356
|
}), /* @__PURE__ */ Q(j, {
|
|
1274
|
-
className:
|
|
1357
|
+
className: q(e),
|
|
1275
1358
|
variant: t,
|
|
1276
1359
|
...n,
|
|
1277
1360
|
children: /* @__PURE__ */ Q(j.Content, {
|
|
1278
1361
|
className: "gap-0",
|
|
1279
|
-
children: s ? /* @__PURE__ */ Q(
|
|
1362
|
+
children: s ? /* @__PURE__ */ Q(St, {}) : c?.map((e, t) => /* @__PURE__ */ $("div", { children: [t > 0 && /* @__PURE__ */ Q("div", { className: "border-b border-dashed -mx-4 my-4" }), /* @__PURE__ */ Q(bt, { activeSession: e })] }, e.id))
|
|
1280
1363
|
})
|
|
1281
1364
|
})] });
|
|
1282
1365
|
}
|
|
1283
|
-
function
|
|
1366
|
+
function St() {
|
|
1284
1367
|
return /* @__PURE__ */ Q("div", {
|
|
1285
1368
|
className: "flex items-center justify-between",
|
|
1286
1369
|
children: /* @__PURE__ */ $("div", {
|
|
1287
1370
|
className: "flex items-center gap-3",
|
|
1288
|
-
children: [/* @__PURE__ */ Q(
|
|
1371
|
+
children: [/* @__PURE__ */ Q(U, { className: "size-10 rounded-xl" }), /* @__PURE__ */ $("div", {
|
|
1289
1372
|
className: "flex flex-col gap-1",
|
|
1290
|
-
children: [/* @__PURE__ */ Q(
|
|
1373
|
+
children: [/* @__PURE__ */ Q(U, { className: "h-4 w-32 rounded-lg" }), /* @__PURE__ */ Q(U, { className: "h-3 w-24 rounded-lg" })]
|
|
1291
1374
|
})]
|
|
1292
1375
|
})
|
|
1293
1376
|
});
|
|
1294
1377
|
}
|
|
1295
1378
|
//#endregion
|
|
1296
1379
|
//#region src/components/auth/settings/security/change-password.tsx
|
|
1297
|
-
function
|
|
1298
|
-
let { authClient: r, emailAndPassword: i, localization: a } =
|
|
1299
|
-
return !c && !l ? /* @__PURE__ */ Q(
|
|
1380
|
+
function Ct({ className: e, variant: t, ...n }) {
|
|
1381
|
+
let { authClient: r, emailAndPassword: i, localization: a } = h(), { data: o } = w(r), { data: s, isPending: c } = x(r), l = s?.some((e) => e.providerId === "credential");
|
|
1382
|
+
return !c && !l ? /* @__PURE__ */ Q(wt, {
|
|
1300
1383
|
className: e,
|
|
1301
1384
|
variant: t,
|
|
1302
1385
|
...n
|
|
1303
|
-
}) : /* @__PURE__ */ Q(
|
|
1386
|
+
}) : /* @__PURE__ */ Q(Tt, {
|
|
1304
1387
|
className: e,
|
|
1305
1388
|
variant: t,
|
|
1306
1389
|
emailAndPassword: i,
|
|
@@ -1309,12 +1392,12 @@ function gt({ className: e, variant: t, ...n }) {
|
|
|
1309
1392
|
...n
|
|
1310
1393
|
});
|
|
1311
1394
|
}
|
|
1312
|
-
function
|
|
1313
|
-
let { authClient: r, localization: i, plugins: a } =
|
|
1395
|
+
function wt({ className: e, variant: t, ...n }) {
|
|
1396
|
+
let { authClient: r, localization: i, plugins: a } = h(), { data: o } = w(r), { fetchOptions: s, resetFetchOptions: c } = y(), { mutate: l, isPending: u } = S(r, {
|
|
1314
1397
|
onError: () => {
|
|
1315
1398
|
c();
|
|
1316
1399
|
},
|
|
1317
|
-
onSuccess: () =>
|
|
1400
|
+
onSuccess: () => J.success(i.auth.passwordResetEmailSent)
|
|
1318
1401
|
}), d = a.find((e) => e.captchaComponent)?.captchaComponent, f = () => {
|
|
1319
1402
|
o?.user.email && l({
|
|
1320
1403
|
email: o.user.email,
|
|
@@ -1322,10 +1405,10 @@ function _t({ className: e, variant: t, ...n }) {
|
|
|
1322
1405
|
});
|
|
1323
1406
|
};
|
|
1324
1407
|
return /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q("h2", {
|
|
1325
|
-
className:
|
|
1408
|
+
className: q("text-sm font-semibold mb-3"),
|
|
1326
1409
|
children: i.settings.changePassword
|
|
1327
1410
|
}), /* @__PURE__ */ Q(j, {
|
|
1328
|
-
className:
|
|
1411
|
+
className: q(e),
|
|
1329
1412
|
variant: t,
|
|
1330
1413
|
...n,
|
|
1331
1414
|
children: /* @__PURE__ */ $(j.Content, {
|
|
@@ -1343,7 +1426,7 @@ function _t({ className: e, variant: t, ...n }) {
|
|
|
1343
1426
|
isPending: u,
|
|
1344
1427
|
isDisabled: !o?.user.email,
|
|
1345
1428
|
onPress: f,
|
|
1346
|
-
children: [u && /* @__PURE__ */ Q(
|
|
1429
|
+
children: [u && /* @__PURE__ */ Q(W, {
|
|
1347
1430
|
color: "current",
|
|
1348
1431
|
size: "sm"
|
|
1349
1432
|
}), i.auth.sendResetLink]
|
|
@@ -1352,17 +1435,17 @@ function _t({ className: e, variant: t, ...n }) {
|
|
|
1352
1435
|
})
|
|
1353
1436
|
})] });
|
|
1354
1437
|
}
|
|
1355
|
-
function
|
|
1356
|
-
let { authClient: o } =
|
|
1438
|
+
function Tt({ className: e, variant: t, emailAndPassword: n, localization: r, session: i, ...a }) {
|
|
1439
|
+
let { authClient: o } = h(), [s, c] = X(""), [l, u] = X(""), [d, f] = X(""), { mutate: p, isPending: m } = v(o, {
|
|
1357
1440
|
onError: () => {
|
|
1358
1441
|
c(""), u(""), f("");
|
|
1359
1442
|
},
|
|
1360
1443
|
onSuccess: () => {
|
|
1361
|
-
c(""), u(""), f(""),
|
|
1444
|
+
c(""), u(""), f(""), J.success(r.settings.changePasswordSuccess);
|
|
1362
1445
|
}
|
|
1363
|
-
}), [g,
|
|
1446
|
+
}), [g, _] = X(!1), [y, b] = X(!1), x = (e) => {
|
|
1364
1447
|
if (e.preventDefault(), n?.confirmPassword && l !== d) {
|
|
1365
|
-
c(""), u(""), f(""),
|
|
1448
|
+
c(""), u(""), f(""), J.danger(r.auth.passwordsDoNotMatch);
|
|
1366
1449
|
return;
|
|
1367
1450
|
}
|
|
1368
1451
|
p({
|
|
@@ -1372,112 +1455,112 @@ function vt({ className: e, variant: t, emailAndPassword: n, localization: r, se
|
|
|
1372
1455
|
});
|
|
1373
1456
|
};
|
|
1374
1457
|
return /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q("h2", {
|
|
1375
|
-
className:
|
|
1458
|
+
className: q("text-sm font-semibold mb-3"),
|
|
1376
1459
|
children: r.settings.changePassword
|
|
1377
1460
|
}), /* @__PURE__ */ Q(j, {
|
|
1378
|
-
className:
|
|
1461
|
+
className: q("p-4 gap-4", e),
|
|
1379
1462
|
variant: t,
|
|
1380
1463
|
...a,
|
|
1381
|
-
children: /* @__PURE__ */ Q(j.Content, { children: /* @__PURE__ */ Q(
|
|
1382
|
-
onSubmit:
|
|
1383
|
-
children: /* @__PURE__ */ $(
|
|
1464
|
+
children: /* @__PURE__ */ Q(j.Content, { children: /* @__PURE__ */ Q(L, {
|
|
1465
|
+
onSubmit: x,
|
|
1466
|
+
children: /* @__PURE__ */ $(I, {
|
|
1384
1467
|
className: "w-full gap-4",
|
|
1385
|
-
children: [/* @__PURE__ */ $(
|
|
1386
|
-
/* @__PURE__ */ $(
|
|
1468
|
+
children: [/* @__PURE__ */ $(I.Group, { children: [
|
|
1469
|
+
/* @__PURE__ */ $(K, {
|
|
1387
1470
|
name: "currentPassword",
|
|
1388
1471
|
type: "password",
|
|
1389
|
-
isDisabled:
|
|
1472
|
+
isDisabled: m || !i,
|
|
1390
1473
|
defaultValue: "",
|
|
1391
1474
|
value: s,
|
|
1392
1475
|
onChange: c,
|
|
1393
1476
|
children: [
|
|
1394
|
-
/* @__PURE__ */ Q(
|
|
1395
|
-
/* @__PURE__ */ Q(
|
|
1396
|
-
className:
|
|
1477
|
+
/* @__PURE__ */ Q(B, { children: r.settings.currentPassword }),
|
|
1478
|
+
/* @__PURE__ */ Q(R, {
|
|
1479
|
+
className: q(!i && "hidden"),
|
|
1397
1480
|
autoComplete: "current-password",
|
|
1398
1481
|
placeholder: r.settings.currentPasswordPlaceholder,
|
|
1399
1482
|
required: !0,
|
|
1400
1483
|
variant: t === "transparent" ? "primary" : "secondary"
|
|
1401
1484
|
}),
|
|
1402
|
-
!i && /* @__PURE__ */ Q(
|
|
1403
|
-
/* @__PURE__ */ Q(
|
|
1485
|
+
!i && /* @__PURE__ */ Q(U, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
1486
|
+
/* @__PURE__ */ Q(F, {})
|
|
1404
1487
|
]
|
|
1405
1488
|
}),
|
|
1406
|
-
/* @__PURE__ */ $(
|
|
1489
|
+
/* @__PURE__ */ $(K, {
|
|
1407
1490
|
minLength: n?.minPasswordLength,
|
|
1408
1491
|
maxLength: n?.maxPasswordLength,
|
|
1409
|
-
isDisabled:
|
|
1492
|
+
isDisabled: m || !i,
|
|
1410
1493
|
value: l,
|
|
1411
1494
|
onChange: u,
|
|
1412
1495
|
children: [
|
|
1413
|
-
/* @__PURE__ */ Q(
|
|
1414
|
-
/* @__PURE__ */ $(
|
|
1415
|
-
className:
|
|
1496
|
+
/* @__PURE__ */ Q(B, { children: r.auth.newPassword }),
|
|
1497
|
+
/* @__PURE__ */ $(z, {
|
|
1498
|
+
className: q(!i && "hidden"),
|
|
1416
1499
|
variant: t === "transparent" ? "primary" : "secondary",
|
|
1417
|
-
children: [/* @__PURE__ */ Q(
|
|
1500
|
+
children: [/* @__PURE__ */ Q(z.Input, {
|
|
1418
1501
|
name: "newPassword",
|
|
1419
1502
|
type: g ? "text" : "password",
|
|
1420
1503
|
autoComplete: "new-password",
|
|
1421
1504
|
placeholder: r.auth.newPasswordPlaceholder,
|
|
1422
1505
|
required: !0
|
|
1423
|
-
}), /* @__PURE__ */ Q(
|
|
1506
|
+
}), /* @__PURE__ */ Q(z.Suffix, {
|
|
1424
1507
|
className: "px-0",
|
|
1425
1508
|
children: /* @__PURE__ */ Q(k, {
|
|
1426
1509
|
isIconOnly: !0,
|
|
1427
1510
|
"aria-label": g ? r.auth.hidePassword : r.auth.showPassword,
|
|
1428
1511
|
size: "sm",
|
|
1429
1512
|
variant: "ghost",
|
|
1430
|
-
onPress: () =>
|
|
1431
|
-
isDisabled:
|
|
1513
|
+
onPress: () => _(!g),
|
|
1514
|
+
isDisabled: m,
|
|
1432
1515
|
children: Q(g ? O : D, {})
|
|
1433
1516
|
})
|
|
1434
1517
|
})]
|
|
1435
1518
|
}),
|
|
1436
|
-
!i && /* @__PURE__ */ Q(
|
|
1437
|
-
/* @__PURE__ */ Q(
|
|
1519
|
+
!i && /* @__PURE__ */ Q(U, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
1520
|
+
/* @__PURE__ */ Q(F, {})
|
|
1438
1521
|
]
|
|
1439
1522
|
}),
|
|
1440
|
-
n?.confirmPassword && /* @__PURE__ */ $(
|
|
1523
|
+
n?.confirmPassword && /* @__PURE__ */ $(K, {
|
|
1441
1524
|
minLength: n?.minPasswordLength,
|
|
1442
1525
|
maxLength: n?.maxPasswordLength,
|
|
1443
|
-
isDisabled:
|
|
1526
|
+
isDisabled: m || !i,
|
|
1444
1527
|
isRequired: !0,
|
|
1445
1528
|
value: d,
|
|
1446
1529
|
onChange: f,
|
|
1447
1530
|
children: [
|
|
1448
|
-
/* @__PURE__ */ Q(
|
|
1449
|
-
/* @__PURE__ */ $(
|
|
1450
|
-
className:
|
|
1531
|
+
/* @__PURE__ */ Q(B, { children: r.auth.confirmPassword }),
|
|
1532
|
+
/* @__PURE__ */ $(z, {
|
|
1533
|
+
className: q(!i && "hidden"),
|
|
1451
1534
|
variant: t === "transparent" ? "primary" : "secondary",
|
|
1452
|
-
children: [/* @__PURE__ */ Q(
|
|
1535
|
+
children: [/* @__PURE__ */ Q(z.Input, {
|
|
1453
1536
|
name: "confirmPassword",
|
|
1454
1537
|
type: y ? "text" : "password",
|
|
1455
1538
|
autoComplete: "new-password",
|
|
1456
1539
|
placeholder: r.auth.confirmPasswordPlaceholder,
|
|
1457
1540
|
required: !0
|
|
1458
|
-
}), /* @__PURE__ */ Q(
|
|
1541
|
+
}), /* @__PURE__ */ Q(z.Suffix, {
|
|
1459
1542
|
className: "px-0",
|
|
1460
1543
|
children: /* @__PURE__ */ Q(k, {
|
|
1461
1544
|
isIconOnly: !0,
|
|
1462
1545
|
"aria-label": y ? r.auth.hidePassword : r.auth.showPassword,
|
|
1463
1546
|
size: "sm",
|
|
1464
1547
|
variant: "ghost",
|
|
1465
|
-
onPress: () =>
|
|
1466
|
-
isDisabled:
|
|
1548
|
+
onPress: () => b(!y),
|
|
1549
|
+
isDisabled: m,
|
|
1467
1550
|
children: Q(y ? O : D, {})
|
|
1468
1551
|
})
|
|
1469
1552
|
})]
|
|
1470
1553
|
}),
|
|
1471
|
-
!i && /* @__PURE__ */ Q(
|
|
1472
|
-
/* @__PURE__ */ Q(
|
|
1554
|
+
!i && /* @__PURE__ */ Q(U, { className: "h-10 md:h-9 w-full rounded-xl" }),
|
|
1555
|
+
/* @__PURE__ */ Q(F, {})
|
|
1473
1556
|
]
|
|
1474
1557
|
})
|
|
1475
|
-
] }), /* @__PURE__ */ Q(
|
|
1558
|
+
] }), /* @__PURE__ */ Q(I.Actions, { children: /* @__PURE__ */ $(k, {
|
|
1476
1559
|
type: "submit",
|
|
1477
|
-
isPending:
|
|
1560
|
+
isPending: m,
|
|
1478
1561
|
isDisabled: !i,
|
|
1479
1562
|
size: "sm",
|
|
1480
|
-
children: [
|
|
1563
|
+
children: [m && /* @__PURE__ */ Q(W, {
|
|
1481
1564
|
color: "current",
|
|
1482
1565
|
size: "sm"
|
|
1483
1566
|
}), r.settings.updatePassword]
|
|
@@ -1488,21 +1571,21 @@ function vt({ className: e, variant: t, emailAndPassword: n, localization: r, se
|
|
|
1488
1571
|
}
|
|
1489
1572
|
//#endregion
|
|
1490
1573
|
//#region src/components/auth/settings/security/linked-account.tsx
|
|
1491
|
-
function
|
|
1492
|
-
let { authClient: n, baseURL: r, localization: i } =
|
|
1574
|
+
function Et({ account: e, provider: t }) {
|
|
1575
|
+
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;
|
|
1493
1576
|
return /* @__PURE__ */ $("div", {
|
|
1494
1577
|
className: "flex items-center gap-3",
|
|
1495
1578
|
children: [
|
|
1496
1579
|
/* @__PURE__ */ Q("div", {
|
|
1497
|
-
className:
|
|
1498
|
-
children: Q(
|
|
1580
|
+
className: q("flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-secondary"),
|
|
1581
|
+
children: Q(f || ye, { className: "size-4.5" })
|
|
1499
1582
|
}),
|
|
1500
1583
|
/* @__PURE__ */ $("div", {
|
|
1501
1584
|
className: "flex flex-col min-w-0",
|
|
1502
1585
|
children: [/* @__PURE__ */ Q("span", {
|
|
1503
1586
|
className: "text-sm font-medium leading-tight",
|
|
1504
1587
|
children: g
|
|
1505
|
-
}), e && o ? /* @__PURE__ */ Q(
|
|
1588
|
+
}), e && o ? /* @__PURE__ */ Q(U, { className: "h-3 w-24 my-0.5 rounded-lg" }) : /* @__PURE__ */ Q("span", {
|
|
1506
1589
|
className: "text-xs text-muted truncate",
|
|
1507
1590
|
children: e ? _ : i.settings.linkProvider.replace("{{provider}}", g)
|
|
1508
1591
|
})]
|
|
@@ -1514,10 +1597,10 @@ function yt({ account: e, provider: t }) {
|
|
|
1514
1597
|
onPress: () => u({ providerId: e.providerId }),
|
|
1515
1598
|
isPending: d,
|
|
1516
1599
|
"aria-label": i.settings.unlinkProvider.replace("{{provider}}", g),
|
|
1517
|
-
children: [d ? /* @__PURE__ */ Q(
|
|
1600
|
+
children: [d ? /* @__PURE__ */ Q(W, {
|
|
1518
1601
|
color: "current",
|
|
1519
1602
|
size: "sm"
|
|
1520
|
-
}) : /* @__PURE__ */ Q(
|
|
1603
|
+
}) : /* @__PURE__ */ Q(ge, {}), i.settings.unlinkProvider.replace("{{provider}}", "").trim()]
|
|
1521
1604
|
}) : /* @__PURE__ */ $(k, {
|
|
1522
1605
|
className: "ml-auto shrink-0",
|
|
1523
1606
|
variant: "outline",
|
|
@@ -1526,20 +1609,20 @@ function yt({ account: e, provider: t }) {
|
|
|
1526
1609
|
provider: t,
|
|
1527
1610
|
callbackURL: `${r}${window.location.pathname}`
|
|
1528
1611
|
}),
|
|
1529
|
-
isPending:
|
|
1612
|
+
isPending: c,
|
|
1530
1613
|
"aria-label": i.settings.linkProvider.replace("{{provider}}", g),
|
|
1531
|
-
children: [
|
|
1614
|
+
children: [c ? /* @__PURE__ */ Q(W, {
|
|
1532
1615
|
color: "current",
|
|
1533
1616
|
size: "sm"
|
|
1534
|
-
}) : /* @__PURE__ */ Q(
|
|
1617
|
+
}) : /* @__PURE__ */ Q(he, {}), i.settings.link]
|
|
1535
1618
|
})
|
|
1536
1619
|
]
|
|
1537
1620
|
});
|
|
1538
1621
|
}
|
|
1539
1622
|
//#endregion
|
|
1540
1623
|
//#region src/components/auth/settings/security/linked-accounts.tsx
|
|
1541
|
-
function
|
|
1542
|
-
let { authClient: r, localization: i, multipleAccountsPerProvider: a, socialProviders: o } =
|
|
1624
|
+
function Dt({ className: e, variant: t, ...n }) {
|
|
1625
|
+
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) => ({
|
|
1543
1626
|
key: e.id,
|
|
1544
1627
|
account: e,
|
|
1545
1628
|
provider: e.providerId
|
|
@@ -1549,55 +1632,55 @@ function bt({ className: e, variant: t, ...n }) {
|
|
|
1549
1632
|
provider: e
|
|
1550
1633
|
})) ?? []];
|
|
1551
1634
|
return /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q("h2", {
|
|
1552
|
-
className:
|
|
1635
|
+
className: q("text-sm font-semibold mb-3"),
|
|
1553
1636
|
children: i.settings.linkedAccounts
|
|
1554
1637
|
}), /* @__PURE__ */ Q(j, {
|
|
1555
|
-
className:
|
|
1638
|
+
className: q(e),
|
|
1556
1639
|
variant: t,
|
|
1557
1640
|
...n,
|
|
1558
1641
|
children: /* @__PURE__ */ Q(j.Content, {
|
|
1559
1642
|
className: "gap-0",
|
|
1560
|
-
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(
|
|
1643
|
+
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(Ot, {})] }, e)) : f.map((e, t) => /* @__PURE__ */ $("div", { children: [t > 0 && /* @__PURE__ */ Q("div", { className: "border-b border-dashed -mx-4 my-4" }), /* @__PURE__ */ Q(Et, {
|
|
1561
1644
|
account: e.account,
|
|
1562
1645
|
provider: e.provider
|
|
1563
1646
|
})] }, e.key))
|
|
1564
1647
|
})
|
|
1565
1648
|
})] });
|
|
1566
1649
|
}
|
|
1567
|
-
function
|
|
1650
|
+
function Ot() {
|
|
1568
1651
|
return /* @__PURE__ */ Q("div", {
|
|
1569
1652
|
className: "flex items-center justify-between",
|
|
1570
1653
|
children: /* @__PURE__ */ $("div", {
|
|
1571
1654
|
className: "flex items-center gap-3",
|
|
1572
|
-
children: [/* @__PURE__ */ Q(
|
|
1655
|
+
children: [/* @__PURE__ */ Q(U, { className: "size-10 rounded-xl" }), /* @__PURE__ */ $("div", {
|
|
1573
1656
|
className: "flex flex-col gap-1",
|
|
1574
|
-
children: [/* @__PURE__ */ Q(
|
|
1657
|
+
children: [/* @__PURE__ */ Q(U, { className: "h-4 w-20 rounded-lg" }), /* @__PURE__ */ Q(U, { className: "h-3 w-32 rounded-lg" })]
|
|
1575
1658
|
})]
|
|
1576
1659
|
})
|
|
1577
1660
|
});
|
|
1578
1661
|
}
|
|
1579
1662
|
//#endregion
|
|
1580
1663
|
//#region src/components/auth/settings/security/security-settings.tsx
|
|
1581
|
-
function
|
|
1582
|
-
let { emailAndPassword: r, plugins: i, socialProviders: a } =
|
|
1664
|
+
function kt({ className: e, variant: t, ...n }) {
|
|
1665
|
+
let { emailAndPassword: r, plugins: i, socialProviders: a } = h();
|
|
1583
1666
|
return /* @__PURE__ */ $("div", {
|
|
1584
|
-
className:
|
|
1667
|
+
className: q("flex w-full flex-col gap-4 md:gap-6", e),
|
|
1585
1668
|
...n,
|
|
1586
1669
|
children: [
|
|
1587
|
-
r?.enabled && /* @__PURE__ */ Q(
|
|
1588
|
-
!!a?.length && /* @__PURE__ */ Q(
|
|
1589
|
-
/* @__PURE__ */ Q(
|
|
1670
|
+
r?.enabled && /* @__PURE__ */ Q(Ct, { variant: t }),
|
|
1671
|
+
!!a?.length && /* @__PURE__ */ Q(Dt, { variant: t }),
|
|
1672
|
+
/* @__PURE__ */ Q(xt, { variant: t }),
|
|
1590
1673
|
i.flatMap((e) => e.securityCards?.map((n, r) => /* @__PURE__ */ Q(n, { variant: t }, `${e.id}-${r.toString()}`)))
|
|
1591
1674
|
]
|
|
1592
1675
|
});
|
|
1593
1676
|
}
|
|
1594
1677
|
//#endregion
|
|
1595
1678
|
//#region src/components/auth/settings/settings.tsx
|
|
1596
|
-
function
|
|
1679
|
+
function At({ className: e, hideNav: t, path: n, variant: r, view: i, ...a }) {
|
|
1597
1680
|
if (!i && !n) throw Error("[Better Auth UI] Either `view` or `path` must be provided");
|
|
1598
|
-
let { authClient: o, basePaths: s, localization: c, viewPaths: l, plugins: u } =
|
|
1599
|
-
|
|
1600
|
-
let d =
|
|
1681
|
+
let { authClient: o, basePaths: s, localization: c, viewPaths: l, plugins: u } = h();
|
|
1682
|
+
g(o);
|
|
1683
|
+
let d = Ue(() => {
|
|
1601
1684
|
if (i) return i;
|
|
1602
1685
|
if (n) return [l.settings, ...u.map((e) => e.viewPaths?.settings)].flatMap((e) => Object.entries(e ?? {})).find(([, e]) => e === n)?.[0];
|
|
1603
1686
|
}, [
|
|
@@ -1610,17 +1693,17 @@ function Ct({ className: e, hideNav: t, path: n, variant: r, view: i, ...a }) {
|
|
|
1610
1693
|
let e = [l.settings, ...u.map((e) => e.viewPaths?.settings)].flatMap((e) => Object.values(e ?? {})).join(", ");
|
|
1611
1694
|
throw Error(`[Better Auth UI] Unknown settings path "${n}". Valid paths are: ${e}`);
|
|
1612
1695
|
}
|
|
1613
|
-
return /* @__PURE__ */ $(
|
|
1614
|
-
className:
|
|
1696
|
+
return /* @__PURE__ */ $(G, {
|
|
1697
|
+
className: q(e),
|
|
1615
1698
|
orientation: "horizontal",
|
|
1616
1699
|
selectedKey: d,
|
|
1617
1700
|
...a,
|
|
1618
1701
|
children: [
|
|
1619
|
-
/* @__PURE__ */ Q(
|
|
1702
|
+
/* @__PURE__ */ Q(G.ListContainer, { children: /* @__PURE__ */ $(G.List, {
|
|
1620
1703
|
"aria-label": c.settings.settings,
|
|
1621
1704
|
className: "max-w-fit overflow-x-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",
|
|
1622
1705
|
children: [
|
|
1623
|
-
/* @__PURE__ */ $(
|
|
1706
|
+
/* @__PURE__ */ $(G.Tab, {
|
|
1624
1707
|
id: "account",
|
|
1625
1708
|
href: `${s.settings}/${l.settings.account}`,
|
|
1626
1709
|
className: "gap-2",
|
|
@@ -1629,12 +1712,12 @@ function Ct({ className: e, hideNav: t, path: n, variant: r, view: i, ...a }) {
|
|
|
1629
1712
|
inline: "center"
|
|
1630
1713
|
}),
|
|
1631
1714
|
children: [
|
|
1632
|
-
/* @__PURE__ */ Q(
|
|
1715
|
+
/* @__PURE__ */ Q(_e, { className: "text-muted" }),
|
|
1633
1716
|
c.settings.account,
|
|
1634
|
-
/* @__PURE__ */ Q(
|
|
1717
|
+
/* @__PURE__ */ Q(G.Indicator, {})
|
|
1635
1718
|
]
|
|
1636
1719
|
}),
|
|
1637
|
-
/* @__PURE__ */ $(
|
|
1720
|
+
/* @__PURE__ */ $(G.Tab, {
|
|
1638
1721
|
id: "security",
|
|
1639
1722
|
href: `${s.settings}/${l.settings.security}`,
|
|
1640
1723
|
className: "gap-2",
|
|
@@ -1643,12 +1726,12 @@ function Ct({ className: e, hideNav: t, path: n, variant: r, view: i, ...a }) {
|
|
|
1643
1726
|
inline: "center"
|
|
1644
1727
|
}),
|
|
1645
1728
|
children: [
|
|
1646
|
-
/* @__PURE__ */ Q(
|
|
1729
|
+
/* @__PURE__ */ Q(be, { className: "text-muted" }),
|
|
1647
1730
|
c.settings.security,
|
|
1648
|
-
/* @__PURE__ */ Q(
|
|
1731
|
+
/* @__PURE__ */ Q(G.Indicator, {})
|
|
1649
1732
|
]
|
|
1650
1733
|
}),
|
|
1651
|
-
u.flatMap((e) => e.settingsTabs?.map((t, n) => /* @__PURE__ */ $(
|
|
1734
|
+
u.flatMap((e) => e.settingsTabs?.map((t, n) => /* @__PURE__ */ $(G.Tab, {
|
|
1652
1735
|
id: t.view,
|
|
1653
1736
|
href: `${s.settings}/${e.viewPaths?.settings?.[t.view]}`,
|
|
1654
1737
|
className: "gap-2",
|
|
@@ -1656,21 +1739,21 @@ function Ct({ className: e, hideNav: t, path: n, variant: r, view: i, ...a }) {
|
|
|
1656
1739
|
behavior: "smooth",
|
|
1657
1740
|
inline: "center"
|
|
1658
1741
|
}),
|
|
1659
|
-
children: [t.label, /* @__PURE__ */ Q(
|
|
1742
|
+
children: [t.label, /* @__PURE__ */ Q(G.Indicator, {})]
|
|
1660
1743
|
}, `${e.id}-${n.toString()}`)) ?? [])
|
|
1661
1744
|
]
|
|
1662
1745
|
}) }),
|
|
1663
|
-
/* @__PURE__ */ Q(
|
|
1746
|
+
/* @__PURE__ */ Q(G.Panel, {
|
|
1664
1747
|
id: "account",
|
|
1665
1748
|
className: "px-0",
|
|
1666
|
-
children: /* @__PURE__ */ Q(
|
|
1749
|
+
children: /* @__PURE__ */ Q(vt, { variant: r })
|
|
1667
1750
|
}),
|
|
1668
|
-
/* @__PURE__ */ Q(
|
|
1751
|
+
/* @__PURE__ */ Q(G.Panel, {
|
|
1669
1752
|
id: "security",
|
|
1670
1753
|
className: "px-0",
|
|
1671
|
-
children: /* @__PURE__ */ Q(
|
|
1754
|
+
children: /* @__PURE__ */ Q(kt, { variant: r })
|
|
1672
1755
|
}),
|
|
1673
|
-
u.flatMap((e) => e.settingsTabs?.map((t, n) => /* @__PURE__ */ Q(
|
|
1756
|
+
u.flatMap((e) => e.settingsTabs?.map((t, n) => /* @__PURE__ */ Q(G.Panel, {
|
|
1674
1757
|
id: t.view,
|
|
1675
1758
|
className: "px-0",
|
|
1676
1759
|
children: /* @__PURE__ */ Q(t.component, { variant: r })
|
|
@@ -1680,72 +1763,72 @@ function Ct({ className: e, hideNav: t, path: n, variant: r, view: i, ...a }) {
|
|
|
1680
1763
|
}
|
|
1681
1764
|
//#endregion
|
|
1682
1765
|
//#region src/components/auth/user/user-button.tsx
|
|
1683
|
-
function
|
|
1684
|
-
if (
|
|
1766
|
+
function jt(e, t) {
|
|
1767
|
+
if (He(e)) return e;
|
|
1685
1768
|
let { label: n, href: r, icon: i, variant: a } = e;
|
|
1686
|
-
return /* @__PURE__ */ $(
|
|
1769
|
+
return /* @__PURE__ */ $(P.Item, {
|
|
1687
1770
|
href: r,
|
|
1688
1771
|
variant: a,
|
|
1689
1772
|
textValue: typeof n == "string" ? n : void 0,
|
|
1690
|
-
children: [i, /* @__PURE__ */ Q(
|
|
1773
|
+
children: [i, /* @__PURE__ */ Q(B, { children: n })]
|
|
1691
1774
|
}, t);
|
|
1692
1775
|
}
|
|
1693
|
-
function
|
|
1694
|
-
let { authClient: l, basePaths: u, viewPaths: d, localization: f, plugins: p } =
|
|
1695
|
-
if (!
|
|
1776
|
+
function Mt({ className: e, placement: t, size: r = "default", variant: a = "ghost", links: o, hideSettings: s, hideSubtitle: c }) {
|
|
1777
|
+
let { authClient: l, basePaths: u, viewPaths: d, localization: f, plugins: p } = h(), { data: m, isPending: g } = w(l), _ = p.flatMap((e) => e.userMenuItems?.map((t, n) => /* @__PURE__ */ Q(t, { hideSubtitle: c }, `${e.id}-${n.toString()}`)) ?? []), v = o?.flatMap((e, t) => {
|
|
1778
|
+
if (!He(e)) {
|
|
1696
1779
|
let t = e.visibility ?? "always";
|
|
1697
|
-
if (t === "authenticated" && !
|
|
1780
|
+
if (t === "authenticated" && !m || t === "unauthenticated" && m) return [];
|
|
1698
1781
|
}
|
|
1699
|
-
return [
|
|
1782
|
+
return [jt(e, `user-button-link-${t.toString()}`)];
|
|
1700
1783
|
});
|
|
1701
|
-
return /* @__PURE__ */ $(
|
|
1702
|
-
className:
|
|
1784
|
+
return /* @__PURE__ */ $(P, { children: [r === "icon" ? /* @__PURE__ */ Q(P.Trigger, {
|
|
1785
|
+
className: q("rounded-full"),
|
|
1703
1786
|
children: /* @__PURE__ */ Q(n, { className: e })
|
|
1704
1787
|
}) : /* @__PURE__ */ $(k, {
|
|
1705
1788
|
variant: a,
|
|
1706
|
-
className:
|
|
1707
|
-
children: [
|
|
1789
|
+
className: q("h-auto font-normal justify-start px-2 py-2 text-left", e),
|
|
1790
|
+
children: [m || g ? /* @__PURE__ */ Q(i, {
|
|
1708
1791
|
isPending: g,
|
|
1709
1792
|
hideSubtitle: c
|
|
1710
1793
|
}) : /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q(n, {}), /* @__PURE__ */ Q("p", {
|
|
1711
1794
|
className: "text-sm font-medium",
|
|
1712
1795
|
children: f.auth.account
|
|
1713
|
-
})] }), /* @__PURE__ */ Q(
|
|
1714
|
-
}), /* @__PURE__ */ $(
|
|
1796
|
+
})] }), /* @__PURE__ */ Q(ue, { className: "ml-auto size-3 text-muted" })]
|
|
1797
|
+
}), /* @__PURE__ */ $(P.Popover, {
|
|
1715
1798
|
placement: t,
|
|
1716
1799
|
className: "min-w-40 md:min-w-56 max-w-[48svw]",
|
|
1717
|
-
children: [
|
|
1800
|
+
children: [m && /* @__PURE__ */ Q("div", {
|
|
1718
1801
|
className: "px-3 pt-3 pb-1",
|
|
1719
1802
|
children: /* @__PURE__ */ Q(i, { hideSubtitle: c })
|
|
1720
|
-
}), /* @__PURE__ */ Q(
|
|
1803
|
+
}), /* @__PURE__ */ Q(P.Menu, { children: m ? /* @__PURE__ */ $(Z, { children: [
|
|
1721
1804
|
v,
|
|
1722
|
-
!s && /* @__PURE__ */ $(
|
|
1805
|
+
!s && /* @__PURE__ */ $(P.Item, {
|
|
1723
1806
|
textValue: f.settings.settings,
|
|
1724
1807
|
href: `${u.settings}/${d.settings.account}`,
|
|
1725
|
-
children: [/* @__PURE__ */ Q(
|
|
1808
|
+
children: [/* @__PURE__ */ Q(me, { className: "text-muted" }), /* @__PURE__ */ Q(B, { children: f.settings.settings })]
|
|
1726
1809
|
}),
|
|
1727
1810
|
_,
|
|
1728
|
-
/* @__PURE__ */ $(
|
|
1811
|
+
/* @__PURE__ */ $(P.Item, {
|
|
1729
1812
|
textValue: f.auth.signOut,
|
|
1730
1813
|
href: `${u.auth}/${d.auth.signOut}`,
|
|
1731
1814
|
variant: "danger",
|
|
1732
|
-
children: [/* @__PURE__ */ Q(
|
|
1815
|
+
children: [/* @__PURE__ */ Q(E, { className: "text-danger" }), /* @__PURE__ */ Q(B, { children: f.auth.signOut })]
|
|
1733
1816
|
})
|
|
1734
1817
|
] }) : /* @__PURE__ */ $(Z, { children: [
|
|
1735
1818
|
v,
|
|
1736
|
-
/* @__PURE__ */ $(
|
|
1819
|
+
/* @__PURE__ */ $(P.Item, {
|
|
1737
1820
|
textValue: f.auth.signIn,
|
|
1738
1821
|
href: `${u.auth}/${d.auth.signIn}`,
|
|
1739
|
-
children: [/* @__PURE__ */ Q(
|
|
1822
|
+
children: [/* @__PURE__ */ Q(se, { className: "text-muted" }), /* @__PURE__ */ Q(B, { children: f.auth.signIn })]
|
|
1740
1823
|
}),
|
|
1741
|
-
/* @__PURE__ */ $(
|
|
1824
|
+
/* @__PURE__ */ $(P.Item, {
|
|
1742
1825
|
textValue: f.auth.signUp,
|
|
1743
1826
|
href: `${u.auth}/${d.auth.signUp}`,
|
|
1744
|
-
children: [/* @__PURE__ */ Q(
|
|
1827
|
+
children: [/* @__PURE__ */ Q(ve, { className: "text-muted" }), /* @__PURE__ */ Q(B, { children: f.auth.signUp })]
|
|
1745
1828
|
}),
|
|
1746
1829
|
_
|
|
1747
1830
|
] }) })]
|
|
1748
1831
|
})] });
|
|
1749
1832
|
}
|
|
1750
1833
|
//#endregion
|
|
1751
|
-
export {
|
|
1834
|
+
export { vt as AccountSettings, xt as ActiveSessions, et as AdditionalField, ft as Auth, mt as AuthProvider, ht as ChangeEmail, Ct as ChangePassword, nt as ForgotPassword, Dt as LinkedAccounts, st as OpenEmailButton, t as ProviderButton, r as ProviderButtons, rt as ResetPassword, kt as SecuritySettings, At as Settings, it as SignIn, at as SignOut, ot as SignUp, n as UserAvatar, Mt as UserButton, _t as UserProfile, i as UserView, lt as VerifyEmail };
|