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