@better-auth-ui/heroui 1.6.24 → 1.6.26
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/lib/auth/organization-plugin.d.ts +1 -0
- package/dist/lib/auth/username-plugin.d.ts +1 -0
- package/dist/plugins.js +119 -105
- package/package.json +1 -1
- package/src/components/auth/organization/organization-row.tsx +3 -2
- package/src/components/auth/organization/organization-switcher.tsx +4 -3
- package/src/components/auth/organization/organization-view.tsx +4 -3
- package/src/components/auth/organization/organization.tsx +4 -3
- package/src/components/auth/organization/slug-field.tsx +11 -2
- package/src/components/auth/username/username-field.tsx +8 -1
|
@@ -8,6 +8,7 @@ export declare const organizationPlugin: ((options?: OrganizationPluginOptions |
|
|
|
8
8
|
component: typeof OrganizationsSettings;
|
|
9
9
|
}[];
|
|
10
10
|
slug: string | null | undefined;
|
|
11
|
+
slugPrefix: string;
|
|
11
12
|
checkSlug: boolean;
|
|
12
13
|
logo: {
|
|
13
14
|
delete?: (url: string) => Promise<void>;
|
package/dist/plugins.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { a as e, r as t, t as n } from "./user-view--47tVtJ3.js";
|
|
3
3
|
import { authMutationKeys as r, authQueryKeys as i, createAuthPlugin as a, fileToBase64 as o } from "@better-auth-ui/core";
|
|
4
|
-
import { ThemePreviewDark as s, ThemePreviewLight as c, ThemePreviewSystem as l, useAcceptInvitation as u, useActiveOrganization as d, useAddPasskey as f, useAuth as p, useAuthPlugin as m, useAuthenticate as h, useCancelInvitation as g, useCheckSlug as _, useCreateApiKey as v, useCreateOrganization as y, useDeleteApiKey as b, useDeleteOrganization as x, useDeletePasskey as S, useDeleteUser as C, useFetchOptions as ee, useHasPermission as w, useInviteMember as
|
|
4
|
+
import { ThemePreviewDark as s, ThemePreviewLight as c, ThemePreviewSystem as l, useAcceptInvitation as u, useActiveOrganization as d, useAddPasskey as f, useAuth as p, useAuthPlugin as m, useAuthenticate as h, useCancelInvitation as g, useCheckSlug as _, useCreateApiKey as v, useCreateOrganization as y, useDeleteApiKey as b, useDeleteOrganization as x, useDeletePasskey as S, useDeleteUser as C, useFetchOptions as ee, useHasPermission as w, useInviteMember as T, useIsUsernameAvailable as te, useLeaveOrganization as ne, useListAccounts as re, useListApiKeys as ie, useListDeviceSessions as ae, useListOrganizationInvitations as oe, useListOrganizationMembers as se, useListOrganizations as ce, useListPasskeys as le, useListUserInvitations as ue, useRejectInvitation as de, useRemoveMember as fe, useRevokeMultiSession as pe, useSession as E, useSetActiveOrganization as me, useSetActiveSession as he, useSignInEmail as ge, useSignInMagicLink as _e, useSignInPasskey as ve, useSignInUsername as ye, useUpdateMemberRole as be, useUpdateOrganization as xe, useUser as Se } from "@better-auth-ui/react";
|
|
5
5
|
import { ArrowRightArrowLeft as Ce, ArrowRightFromSquare as we, Briefcase as Te, Check as Ee, ChevronsExpandVertical as De, CirclePlus as Oe, Clock as ke, CloudArrowUpIn as Ae, Copy as je, Display as Me, Ellipsis as Ne, Envelope as Pe, Fingerprint as Fe, Funnel as Ie, Gear as Le, Key as Re, Lock as ze, Moon as Be, Palette as Ve, PaperPlane as He, Pencil as Ue, Person as We, PersonPlus as Ge, Sun as Ke, TrashBin as qe, TriangleExclamation as Je, Xmark as D } from "@gravity-ui/icons";
|
|
6
6
|
import { AlertDialog as O, Avatar as Ye, Button as k, Card as A, Checkbox as Xe, Chip as j, Description as Ze, Dropdown as M, EmptyState as Qe, FieldError as N, Form as P, Input as F, InputGroup as I, Label as L, Link as $e, ListBox as et, Radio as R, RadioGroup as tt, SearchField as z, Select as nt, Skeleton as B, Spinner as V, Table as H, Tabs as U, TextField as W, cn as G, toast as K, useIsHydrated as rt } from "@heroui/react";
|
|
7
7
|
import { useEffect as it, useMemo as at, useRef as ot, useState as q } from "react";
|
|
@@ -300,7 +300,7 @@ function Tt({ isOpen: e, onOpenChange: t, organizationId: n }) {
|
|
|
300
300
|
//#endregion
|
|
301
301
|
//#region src/components/auth/api-key/api-keys.tsx
|
|
302
302
|
function Et({ className: e, variant: t, organizationId: n, isPending: r, hideCreate: i, hideDelete: a }) {
|
|
303
|
-
let { authClient: o } = p(), { localization: s } = m(yt), { data: c, isPending: l } =
|
|
303
|
+
let { authClient: o } = p(), { localization: s } = m(yt), { data: c, isPending: l } = ie(o, {
|
|
304
304
|
enabled: !r,
|
|
305
305
|
...n ? { query: {
|
|
306
306
|
organizationId: n,
|
|
@@ -351,7 +351,7 @@ var Dt = a(ut.id, (e = {}) => ({
|
|
|
351
351
|
//#endregion
|
|
352
352
|
//#region src/components/auth/delete-user/delete-account.tsx
|
|
353
353
|
function Ot({ className: e, variant: t, ...n }) {
|
|
354
|
-
let { authClient: r, basePaths: a, localization: o, navigate: s, viewPaths: c } = p(), { localization: l, sendDeleteAccountVerification: u } = m(Dt), { data: d } =
|
|
354
|
+
let { authClient: r, basePaths: a, localization: o, navigate: s, viewPaths: c } = p(), { localization: l, sendDeleteAccountVerification: u } = m(Dt), { data: d } = re(r), f = st(), [h, g] = q(!1), [_, v] = q(""), y = d?.some((e) => e.providerId === "credential"), b = !u && y, { mutate: x, isPending: S } = C(r), ee = (e) => {
|
|
355
355
|
g(e), v("");
|
|
356
356
|
}, w = async (e) => {
|
|
357
357
|
e.preventDefault(), x({ ...b ? { password: _ } : {} }, { onSuccess: () => {
|
|
@@ -686,18 +686,18 @@ function zt(e) {
|
|
|
686
686
|
return e.toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
|
687
687
|
}
|
|
688
688
|
function Bt({ value: e, onChange: t, currentSlug: n, variant: r, ...i }) {
|
|
689
|
-
let { authClient: a, localization: o } = p(), { localization: s, checkSlug: c } = m($), { mutate:
|
|
690
|
-
!c || !e.trim() || e.trim() === n ||
|
|
689
|
+
let { authClient: a, localization: o } = p(), { localization: s, checkSlug: c, slugPrefix: l } = m($), { mutate: u, data: d, error: f, reset: h } = _(a), g = _t((e) => {
|
|
690
|
+
!c || !e.trim() || e.trim() === n || u({ slug: e.trim() });
|
|
691
691
|
}, { wait: 500 });
|
|
692
692
|
it(() => {
|
|
693
|
-
c && (
|
|
693
|
+
c && (h(), g.maybeExecute(e));
|
|
694
694
|
}, [
|
|
695
695
|
c,
|
|
696
696
|
e,
|
|
697
|
-
|
|
698
|
-
|
|
697
|
+
g.maybeExecute,
|
|
698
|
+
h
|
|
699
699
|
]);
|
|
700
|
-
let
|
|
700
|
+
let v = (e) => {
|
|
701
701
|
t(zt(e));
|
|
702
702
|
};
|
|
703
703
|
return /* @__PURE__ */ X(W, {
|
|
@@ -705,7 +705,7 @@ function Bt({ value: e, onChange: t, currentSlug: n, variant: r, ...i }) {
|
|
|
705
705
|
name: "slug",
|
|
706
706
|
...i,
|
|
707
707
|
value: e,
|
|
708
|
-
onChange:
|
|
708
|
+
onChange: v,
|
|
709
709
|
validate: (e) => {
|
|
710
710
|
if (!e) return o.auth.fieldRequired;
|
|
711
711
|
},
|
|
@@ -713,16 +713,23 @@ function Bt({ value: e, onChange: t, currentSlug: n, variant: r, ...i }) {
|
|
|
713
713
|
/* @__PURE__ */ Y(L, { children: s.slug }),
|
|
714
714
|
/* @__PURE__ */ X(I, {
|
|
715
715
|
variant: r,
|
|
716
|
-
children: [
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
716
|
+
children: [
|
|
717
|
+
l && /* @__PURE__ */ Y(I.Prefix, {
|
|
718
|
+
className: "pr-1.5 text-muted",
|
|
719
|
+
children: l
|
|
720
|
+
}),
|
|
721
|
+
/* @__PURE__ */ Y(I.Input, {
|
|
722
|
+
placeholder: s.slugPlaceholder,
|
|
723
|
+
required: !0
|
|
724
|
+
}),
|
|
725
|
+
c && !!e.trim() && e.trim() !== n && /* @__PURE__ */ Y(I.Suffix, {
|
|
726
|
+
className: "px-2",
|
|
727
|
+
children: d?.status ? /* @__PURE__ */ Y(Ee, { className: "text-success" }) : f ? /* @__PURE__ */ Y(D, { className: "text-danger" }) : /* @__PURE__ */ Y(V, {
|
|
728
|
+
size: "sm",
|
|
729
|
+
color: "current"
|
|
730
|
+
})
|
|
724
731
|
})
|
|
725
|
-
|
|
732
|
+
]
|
|
726
733
|
}),
|
|
727
734
|
/* @__PURE__ */ Y(N, {})
|
|
728
735
|
]
|
|
@@ -848,11 +855,11 @@ function Ut({ className: e, hideSlug: t, size: n = "md", ...r }) {
|
|
|
848
855
|
//#endregion
|
|
849
856
|
//#region src/components/auth/organization/organization-view.tsx
|
|
850
857
|
function Q({ className: e, isPending: t, size: n = "md", hideSlug: r, hideRole: i, organization: a, ...o }) {
|
|
851
|
-
let { authClient: s } = p(), { roles: c } = m($), { data:
|
|
852
|
-
query: { organizationId:
|
|
853
|
-
enabled: !!
|
|
854
|
-
}),
|
|
855
|
-
return t || !a &&
|
|
858
|
+
let { authClient: s } = p(), { roles: c, slugPrefix: l } = m($), { data: u } = E(s), { data: f, isPending: h } = d(s, { enabled: !a && !t }), g = a ?? f, { data: _, isPending: v } = se(s, {
|
|
859
|
+
query: { organizationId: g?.id },
|
|
860
|
+
enabled: !!g?.id && !i
|
|
861
|
+
}), y = _?.members?.find((e) => e.userId === u?.user.id);
|
|
862
|
+
return t || !a && h || !i && g?.id && v ? /* @__PURE__ */ Y(Ut, {
|
|
856
863
|
className: e,
|
|
857
864
|
hideSlug: r,
|
|
858
865
|
size: n,
|
|
@@ -861,7 +868,7 @@ function Q({ className: e, isPending: t, size: n = "md", hideSlug: r, hideRole:
|
|
|
861
868
|
className: G("flex min-w-0 items-center gap-2", e),
|
|
862
869
|
...o,
|
|
863
870
|
children: [/* @__PURE__ */ Y(Ht, {
|
|
864
|
-
organization:
|
|
871
|
+
organization: g,
|
|
865
872
|
className: n === "sm" ? "size-5 [&>span]:text-xs" : void 0,
|
|
866
873
|
size: n === "lg" ? "md" : "sm"
|
|
867
874
|
}), /* @__PURE__ */ X("div", {
|
|
@@ -870,15 +877,15 @@ function Q({ className: e, isPending: t, size: n = "md", hideSlug: r, hideRole:
|
|
|
870
877
|
className: "flex min-w-0 items-center gap-2",
|
|
871
878
|
children: [/* @__PURE__ */ Y("p", {
|
|
872
879
|
className: "text-foreground text-sm font-medium truncate leading-tight",
|
|
873
|
-
children:
|
|
874
|
-
}), !i && !!
|
|
880
|
+
children: g?.name
|
|
881
|
+
}), !i && !!y && /* @__PURE__ */ Y(j, {
|
|
875
882
|
className: "shrink-0 -my-0.5",
|
|
876
883
|
size: "sm",
|
|
877
|
-
children: c?.[
|
|
884
|
+
children: c?.[y.role] ?? y.role
|
|
878
885
|
})]
|
|
879
|
-
}), !r && /* @__PURE__ */
|
|
886
|
+
}), !r && !!g?.slug && /* @__PURE__ */ X("p", {
|
|
880
887
|
className: "text-muted text-xs truncate overflow-x-hidden font-mono leading-tight",
|
|
881
|
-
children:
|
|
888
|
+
children: [l, g.slug]
|
|
882
889
|
})]
|
|
883
890
|
})]
|
|
884
891
|
});
|
|
@@ -886,11 +893,11 @@ function Q({ className: e, isPending: t, size: n = "md", hideSlug: r, hideRole:
|
|
|
886
893
|
//#endregion
|
|
887
894
|
//#region src/components/auth/organization/organization-row.tsx
|
|
888
895
|
function Wt({ organization: e }) {
|
|
889
|
-
let { authClient: t, basePaths: n, navigate: r } = p(), { localization: i, viewPaths: a, slug: o } = m($), { mutate:
|
|
896
|
+
let { authClient: t, basePaths: n, navigate: r } = p(), { localization: i, viewPaths: a, slug: o, slugPrefix: s } = m($), { mutate: c, isPending: l } = me(t, { onSuccess: () => {
|
|
890
897
|
r({ to: `${n.organization}/${a.organization.settings}` });
|
|
891
898
|
} });
|
|
892
|
-
function
|
|
893
|
-
o === void 0 ?
|
|
899
|
+
function u() {
|
|
900
|
+
o === void 0 ? c({ organizationId: e.id }) : r({ to: `${n.organization}/${s}${e.slug}/${a.organization.settings}` });
|
|
894
901
|
}
|
|
895
902
|
return /* @__PURE__ */ X("div", {
|
|
896
903
|
className: "flex items-center gap-3",
|
|
@@ -898,10 +905,10 @@ function Wt({ organization: e }) {
|
|
|
898
905
|
className: "ml-auto shrink-0",
|
|
899
906
|
variant: "outline",
|
|
900
907
|
size: "sm",
|
|
901
|
-
isPending:
|
|
902
|
-
onPress:
|
|
908
|
+
isPending: l,
|
|
909
|
+
onPress: u,
|
|
903
910
|
"aria-label": i.manage,
|
|
904
|
-
children: [
|
|
911
|
+
children: [l ? /* @__PURE__ */ Y(V, {
|
|
905
912
|
color: "current",
|
|
906
913
|
size: "sm"
|
|
907
914
|
}) : /* @__PURE__ */ Y(Le, {}), i.manage]
|
|
@@ -1284,7 +1291,7 @@ function rn({ isOpen: e, onOpenChange: t }) {
|
|
|
1284
1291
|
return t.includes(e) ? e : nn(t);
|
|
1285
1292
|
});
|
|
1286
1293
|
}, [a]);
|
|
1287
|
-
let { mutate: c, isPending: l } =
|
|
1294
|
+
let { mutate: c, isPending: l } = T(n, { onSuccess: () => {
|
|
1288
1295
|
t(!1), K.success(i.inviteMemberSuccess);
|
|
1289
1296
|
} }), u = Object.keys(a).includes(o);
|
|
1290
1297
|
return /* @__PURE__ */ Y(O.Backdrop, {
|
|
@@ -1373,7 +1380,7 @@ function rn({ isOpen: e, onOpenChange: t }) {
|
|
|
1373
1380
|
//#endregion
|
|
1374
1381
|
//#region src/components/auth/organization/leave-organization-dialog.tsx
|
|
1375
1382
|
function an({ isOpen: e, onOpenChange: t, organization: n }) {
|
|
1376
|
-
let { authClient: r, basePaths: i, localization: a, navigate: o } = p(), { localization: s, viewPaths: c } = m($), { mutate: l, isPending: u } =
|
|
1383
|
+
let { authClient: r, basePaths: i, localization: a, navigate: o } = p(), { localization: s, viewPaths: c } = m($), { mutate: l, isPending: u } = ne(r, { onSuccess: () => {
|
|
1377
1384
|
t(!1), K.success(s.leftOrganization), o({
|
|
1378
1385
|
to: `${i.settings}/${c.settings.organizations}`,
|
|
1379
1386
|
replace: !0
|
|
@@ -1845,7 +1852,7 @@ function mn({ className: e, ...t }) {
|
|
|
1845
1852
|
]), C = at(() => !g || !S ? S : [...S].sort((e, t) => {
|
|
1846
1853
|
let n = g.column, r = n === "user" ? e.user.name || e.user.email : String(e[n]), i = n === "user" ? t.user.name || t.user.email : String(t[n]), a = r.localeCompare(i);
|
|
1847
1854
|
return g.direction === "descending" && (a *= -1), a;
|
|
1848
|
-
}), [g, S]), [ee,
|
|
1855
|
+
}), [g, S]), [ee, T] = q(!1), te = c?.members.some((e) => e.role === "owner" && e.userId === a?.user.id);
|
|
1849
1856
|
return /* @__PURE__ */ X("div", {
|
|
1850
1857
|
className: G("flex flex-col gap-3", e),
|
|
1851
1858
|
...t,
|
|
@@ -1859,7 +1866,7 @@ function mn({ className: e, ...t }) {
|
|
|
1859
1866
|
className: "shrink-0",
|
|
1860
1867
|
size: "sm",
|
|
1861
1868
|
isDisabled: h,
|
|
1862
|
-
onPress: () =>
|
|
1869
|
+
onPress: () => T(!0),
|
|
1863
1870
|
children: r.inviteMember
|
|
1864
1871
|
})]
|
|
1865
1872
|
}),
|
|
@@ -1955,7 +1962,7 @@ function mn({ className: e, ...t }) {
|
|
|
1955
1962
|
})
|
|
1956
1963
|
] }), /* @__PURE__ */ Y(H.Body, { children: h ? /* @__PURE__ */ Y(dn, {}) : !!o && C?.map((e) => /* @__PURE__ */ Y(pn, {
|
|
1957
1964
|
member: e,
|
|
1958
|
-
isOwner:
|
|
1965
|
+
isOwner: te,
|
|
1959
1966
|
organization: o
|
|
1960
1967
|
}, e.id)) })]
|
|
1961
1968
|
}) }) })
|
|
@@ -1963,7 +1970,7 @@ function mn({ className: e, ...t }) {
|
|
|
1963
1970
|
}),
|
|
1964
1971
|
/* @__PURE__ */ Y(rn, {
|
|
1965
1972
|
isOpen: ee,
|
|
1966
|
-
onOpenChange:
|
|
1973
|
+
onOpenChange: T
|
|
1967
1974
|
})
|
|
1968
1975
|
]
|
|
1969
1976
|
});
|
|
@@ -2084,32 +2091,32 @@ function yn({ className: e, hideNav: t, path: n, variant: r, view: i, ...a }) {
|
|
|
2084
2091
|
if (!i && !n) throw Error("[Better Auth UI] Either `view` or `path` must be provided");
|
|
2085
2092
|
let { authClient: o, basePaths: s, localization: c, navigate: l } = p();
|
|
2086
2093
|
h(o);
|
|
2087
|
-
let { localization: u, viewPaths: f, slug: g } = m($), { data:
|
|
2094
|
+
let { localization: u, viewPaths: f, slug: g, slugPrefix: _ } = m($), { data: v, isPending: y } = d(o);
|
|
2088
2095
|
it(() => {
|
|
2089
|
-
!
|
|
2096
|
+
!y && !v && l({
|
|
2090
2097
|
to: `${s.settings}/${f.settings?.organizations}`,
|
|
2091
2098
|
replace: !0
|
|
2092
2099
|
});
|
|
2093
2100
|
}, [
|
|
2094
2101
|
s.settings,
|
|
2095
|
-
|
|
2102
|
+
y,
|
|
2096
2103
|
l,
|
|
2097
2104
|
f.settings?.organizations,
|
|
2098
|
-
|
|
2105
|
+
v
|
|
2099
2106
|
]);
|
|
2100
|
-
let
|
|
2107
|
+
let b = at(() => i || Object.entries(f.organization).find(([, e]) => e === n)?.[0], [
|
|
2101
2108
|
i,
|
|
2102
2109
|
n,
|
|
2103
2110
|
f.organization
|
|
2104
2111
|
]);
|
|
2105
|
-
if (!
|
|
2112
|
+
if (!b) {
|
|
2106
2113
|
let e = Object.values(f.organization).join(", ");
|
|
2107
2114
|
throw Error(`[Better Auth UI] Unknown organization path "${n}". Valid paths are: ${e}`);
|
|
2108
2115
|
}
|
|
2109
|
-
return !
|
|
2116
|
+
return !y && !v ? null : /* @__PURE__ */ X(U, {
|
|
2110
2117
|
className: G(e),
|
|
2111
2118
|
orientation: "horizontal",
|
|
2112
|
-
selectedKey:
|
|
2119
|
+
selectedKey: b,
|
|
2113
2120
|
...a,
|
|
2114
2121
|
children: [
|
|
2115
2122
|
!t && /* @__PURE__ */ Y(U.ListContainer, { children: /* @__PURE__ */ X(U.List, {
|
|
@@ -2117,7 +2124,7 @@ function yn({ className: e, hideNav: t, path: n, variant: r, view: i, ...a }) {
|
|
|
2117
2124
|
className: "max-w-fit overflow-x-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",
|
|
2118
2125
|
children: [/* @__PURE__ */ X(U.Tab, {
|
|
2119
2126
|
id: "settings",
|
|
2120
|
-
href: g ? `${s.organization}/${g}/${f.organization.settings}` : `${s.organization}/${f.organization.settings}`,
|
|
2127
|
+
href: g ? `${s.organization}/${_}${g}/${f.organization.settings}` : `${s.organization}/${f.organization.settings}`,
|
|
2121
2128
|
className: "gap-2",
|
|
2122
2129
|
onPress: (e) => e.target.scrollIntoView({
|
|
2123
2130
|
behavior: "smooth",
|
|
@@ -2130,7 +2137,7 @@ function yn({ className: e, hideNav: t, path: n, variant: r, view: i, ...a }) {
|
|
|
2130
2137
|
]
|
|
2131
2138
|
}), /* @__PURE__ */ X(U.Tab, {
|
|
2132
2139
|
id: "people",
|
|
2133
|
-
href: g ? `${s.organization}/${g}/${f.organization.people}` : `${s.organization}/${f.organization.people}`,
|
|
2140
|
+
href: g ? `${s.organization}/${_}${g}/${f.organization.people}` : `${s.organization}/${f.organization.people}`,
|
|
2134
2141
|
className: "gap-2",
|
|
2135
2142
|
onPress: (e) => e.target.scrollIntoView({
|
|
2136
2143
|
behavior: "smooth",
|
|
@@ -2159,25 +2166,25 @@ function yn({ className: e, hideNav: t, path: n, variant: r, view: i, ...a }) {
|
|
|
2159
2166
|
//#endregion
|
|
2160
2167
|
//#region src/components/auth/organization/organization-switcher.tsx
|
|
2161
2168
|
function bn({ className: e, hideCreate: t, hidePersonal: r, hideSettings: i, hideSlug: a = !0, setActive: o, placement: s, variant: c = "ghost", size: l = "md", trigger: u, ...f }) {
|
|
2162
|
-
let { authClient: h, navigate: g, basePaths: _, localization: v, viewPaths: y } = p(), { data: b, isPending: x } = E(h), { localization: S, viewPaths: C, slug: ee } = m($), { data:
|
|
2163
|
-
function
|
|
2164
|
-
o ? o(e) : ee === void 0 ? ie({ organizationId: e?.id ?? null }) : g({ to: e ? `${_.organization}/${e.slug}/${C.organization.settings}` : `${_.settings}/${y.settings.account}` });
|
|
2169
|
+
let { authClient: h, navigate: g, basePaths: _, localization: v, viewPaths: y } = p(), { data: b, isPending: x } = E(h), { localization: S, viewPaths: C, slug: ee, slugPrefix: w } = m($), { data: T, isPending: te } = d(h), { data: ne, isPending: re } = ce(h), { mutate: ie } = me(h), ae = x || !!b && (re || te), [oe, se] = q(!1), [le, ue] = q(!1);
|
|
2170
|
+
function de(e) {
|
|
2171
|
+
o ? o(e) : ee === void 0 ? ie({ organizationId: e?.id ?? null }) : g({ to: e ? `${_.organization}/${w}${e.slug}/${C.organization.settings}` : `${_.settings}/${y.settings.account}` });
|
|
2165
2172
|
}
|
|
2166
2173
|
return /* @__PURE__ */ X(J, { children: [/* @__PURE__ */ X(M, {
|
|
2167
|
-
isOpen:
|
|
2168
|
-
onOpenChange:
|
|
2174
|
+
isOpen: le,
|
|
2175
|
+
onOpenChange: ue,
|
|
2169
2176
|
children: [u ? /* @__PURE__ */ Y(M.Trigger, { children: u }) : /* @__PURE__ */ X(k, {
|
|
2170
2177
|
variant: c,
|
|
2171
2178
|
className: G("h-auto px-2 py-2 text-left", e),
|
|
2172
|
-
isDisabled: !b ||
|
|
2179
|
+
isDisabled: !b || ae,
|
|
2173
2180
|
"aria-label": S.organization,
|
|
2174
2181
|
...f,
|
|
2175
|
-
children: [
|
|
2182
|
+
children: [ae ? /* @__PURE__ */ Y(Q, {
|
|
2176
2183
|
size: l,
|
|
2177
2184
|
isPending: !0,
|
|
2178
2185
|
hideRole: !0,
|
|
2179
2186
|
hideSlug: a
|
|
2180
|
-
}) :
|
|
2187
|
+
}) : T ? /* @__PURE__ */ Y(Q, {
|
|
2181
2188
|
size: l,
|
|
2182
2189
|
hideRole: !0,
|
|
2183
2190
|
hideSlug: a
|
|
@@ -2193,22 +2200,22 @@ function bn({ className: e, hideCreate: t, hidePersonal: r, hideSettings: i, hid
|
|
|
2193
2200
|
}), /* @__PURE__ */ X(M.Popover, {
|
|
2194
2201
|
placement: s,
|
|
2195
2202
|
className: "max-w-svw",
|
|
2196
|
-
children: [
|
|
2203
|
+
children: [T ? /* @__PURE__ */ X("div", {
|
|
2197
2204
|
className: "flex items-center justify-between gap-4 px-4 pt-3",
|
|
2198
2205
|
children: [/* @__PURE__ */ Y(Q, {
|
|
2199
2206
|
hideRole: !0,
|
|
2200
2207
|
hideSlug: a,
|
|
2201
|
-
organization:
|
|
2208
|
+
organization: T
|
|
2202
2209
|
}), !i && /* @__PURE__ */ X($e, {
|
|
2203
|
-
href: ee ? `${_.organization}/${ee}/${C.organization.settings}` : `${_.organization}/${C.organization.settings}`,
|
|
2210
|
+
href: ee ? `${_.organization}/${w}${ee}/${C.organization.settings}` : `${_.organization}/${C.organization.settings}`,
|
|
2204
2211
|
className: G(ct({
|
|
2205
2212
|
variant: "outline",
|
|
2206
2213
|
size: "sm"
|
|
2207
2214
|
}), "shrink-0 gap-2"),
|
|
2208
|
-
onPress: () =>
|
|
2215
|
+
onPress: () => ue(!1),
|
|
2209
2216
|
children: [/* @__PURE__ */ Y(Le, { className: "text-muted" }), S.manage]
|
|
2210
2217
|
})]
|
|
2211
|
-
}) : !
|
|
2218
|
+
}) : !ae && b?.user && !r ? /* @__PURE__ */ X("div", {
|
|
2212
2219
|
className: "flex items-center justify-between gap-4 px-4 pt-3",
|
|
2213
2220
|
children: [/* @__PURE__ */ Y(n, { hideSubtitle: a }), !i && /* @__PURE__ */ X($e, {
|
|
2214
2221
|
href: `${_.settings}/${y.settings.account}`,
|
|
@@ -2216,18 +2223,18 @@ function bn({ className: e, hideCreate: t, hidePersonal: r, hideSettings: i, hid
|
|
|
2216
2223
|
variant: "outline",
|
|
2217
2224
|
size: "sm"
|
|
2218
2225
|
}), "shrink-0 gap-2"),
|
|
2219
|
-
onPress: () =>
|
|
2226
|
+
onPress: () => ue(!1),
|
|
2220
2227
|
children: [/* @__PURE__ */ Y(Le, { className: "text-muted" }), v.settings.settings]
|
|
2221
2228
|
})]
|
|
2222
2229
|
}) : null, /* @__PURE__ */ X(M.Menu, { children: [
|
|
2223
|
-
!!
|
|
2230
|
+
!!T && !r && /* @__PURE__ */ Y(M.Item, {
|
|
2224
2231
|
textValue: S.personalAccount,
|
|
2225
|
-
onPress: () =>
|
|
2232
|
+
onPress: () => de(null),
|
|
2226
2233
|
children: /* @__PURE__ */ Y(n, { hideSubtitle: a })
|
|
2227
2234
|
}),
|
|
2228
|
-
ne?.filter((e) => e.id !==
|
|
2235
|
+
ne?.filter((e) => e.id !== T?.id)?.map((e) => /* @__PURE__ */ Y(M.Item, {
|
|
2229
2236
|
textValue: e.name,
|
|
2230
|
-
onPress: () =>
|
|
2237
|
+
onPress: () => de(e),
|
|
2231
2238
|
children: /* @__PURE__ */ Y(Q, {
|
|
2232
2239
|
hideRole: !0,
|
|
2233
2240
|
hideSlug: a,
|
|
@@ -2236,14 +2243,14 @@ function bn({ className: e, hideCreate: t, hidePersonal: r, hideSettings: i, hid
|
|
|
2236
2243
|
}, e.id)),
|
|
2237
2244
|
!t && /* @__PURE__ */ X(M.Item, {
|
|
2238
2245
|
textValue: S.createOrganization,
|
|
2239
|
-
onPress: () =>
|
|
2246
|
+
onPress: () => se(!0),
|
|
2240
2247
|
children: [/* @__PURE__ */ Y(Oe, { className: "text-muted" }), /* @__PURE__ */ Y(L, { children: S.createOrganization })]
|
|
2241
2248
|
})
|
|
2242
2249
|
] })]
|
|
2243
2250
|
})]
|
|
2244
2251
|
}), /* @__PURE__ */ Y(Vt, {
|
|
2245
|
-
isOpen:
|
|
2246
|
-
onOpenChange:
|
|
2252
|
+
isOpen: oe,
|
|
2253
|
+
onOpenChange: se
|
|
2247
2254
|
})] });
|
|
2248
2255
|
}
|
|
2249
2256
|
//#endregion
|
|
@@ -2627,18 +2634,18 @@ function Mn({ className: e, variant: t, ...n }) {
|
|
|
2627
2634
|
//#endregion
|
|
2628
2635
|
//#region src/components/auth/username/username-field.tsx
|
|
2629
2636
|
function Nn({ name: e, field: t, isPending: n, variant: r }) {
|
|
2630
|
-
let { authClient: i } = p(), { localization: a, minUsernameLength: o, maxUsernameLength: s, isUsernameAvailable: c } = m(Pn),
|
|
2637
|
+
let { authClient: i } = p(), { localization: a, minUsernameLength: o, maxUsernameLength: s, isUsernameAvailable: c, usernamePrefix: l } = m(Pn), u = String(t.defaultValue ?? ""), [d, f] = q(u), { mutate: h, data: g, error: _, reset: v } = te(i, { onError: () => {} }), y = _t((e) => {
|
|
2631
2638
|
let t = e.trim();
|
|
2632
|
-
if (!t || t ===
|
|
2633
|
-
|
|
2639
|
+
if (!t || t === u) {
|
|
2640
|
+
v();
|
|
2634
2641
|
return;
|
|
2635
2642
|
}
|
|
2636
|
-
|
|
2643
|
+
h({ username: t });
|
|
2637
2644
|
}, { wait: 500 });
|
|
2638
|
-
function
|
|
2639
|
-
|
|
2645
|
+
function b(e) {
|
|
2646
|
+
f(e), v(), c && y.maybeExecute(e);
|
|
2640
2647
|
}
|
|
2641
|
-
let
|
|
2648
|
+
let x = !!c && !!d.trim() && d.trim() !== u, { localization: S } = p();
|
|
2642
2649
|
return /* @__PURE__ */ X(W, {
|
|
2643
2650
|
name: e,
|
|
2644
2651
|
type: "text",
|
|
@@ -2647,28 +2654,35 @@ function Nn({ name: e, field: t, isPending: n, variant: r }) {
|
|
|
2647
2654
|
maxLength: s,
|
|
2648
2655
|
isDisabled: n,
|
|
2649
2656
|
isReadOnly: t.readOnly,
|
|
2650
|
-
value:
|
|
2651
|
-
onChange:
|
|
2657
|
+
value: d,
|
|
2658
|
+
onChange: b,
|
|
2652
2659
|
validate: (e) => {
|
|
2653
|
-
if (!e) return t.required ?
|
|
2654
|
-
if (o && e.length < o) return
|
|
2655
|
-
if (s && e.length > s) return
|
|
2660
|
+
if (!e) return t.required ? S.auth.fieldRequired : void 0;
|
|
2661
|
+
if (o && e.length < o) return S.auth.tooShort.replace("{{min}}", String(o));
|
|
2662
|
+
if (s && e.length > s) return S.auth.tooLong.replace("{{max}}", String(s));
|
|
2656
2663
|
},
|
|
2657
2664
|
children: [
|
|
2658
2665
|
/* @__PURE__ */ Y(L, { children: t.label }),
|
|
2659
2666
|
/* @__PURE__ */ X(I, {
|
|
2660
2667
|
variant: r === "transparent" ? "primary" : "secondary",
|
|
2661
|
-
children: [
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2668
|
+
children: [
|
|
2669
|
+
l && /* @__PURE__ */ Y(I.Prefix, {
|
|
2670
|
+
className: "pr-1.5 text-muted",
|
|
2671
|
+
children: l
|
|
2672
|
+
}),
|
|
2673
|
+
/* @__PURE__ */ Y(I.Input, {
|
|
2674
|
+
placeholder: t.placeholder,
|
|
2675
|
+
required: t.required
|
|
2676
|
+
}),
|
|
2677
|
+
x && /* @__PURE__ */ Y(I.Suffix, {
|
|
2678
|
+
"aria-label": g?.available ? a.usernameAvailable : g?.available === !1 ? a.usernameTaken : void 0,
|
|
2679
|
+
className: "px-2",
|
|
2680
|
+
children: g?.available ? /* @__PURE__ */ Y(Ee, { className: "text-success" }) : _ || g?.available === !1 ? /* @__PURE__ */ Y(D, { className: "text-danger" }) : /* @__PURE__ */ Y(V, {
|
|
2681
|
+
size: "sm",
|
|
2682
|
+
color: "current"
|
|
2683
|
+
})
|
|
2670
2684
|
})
|
|
2671
|
-
|
|
2685
|
+
]
|
|
2672
2686
|
}),
|
|
2673
2687
|
/* @__PURE__ */ Y(N, {})
|
|
2674
2688
|
]
|
|
@@ -2694,17 +2708,17 @@ function Fn({ className: n, socialLayout: i, socialPosition: a = "bottom", varia
|
|
|
2694
2708
|
function C(e) {
|
|
2695
2709
|
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
|
|
2696
2710
|
}
|
|
2697
|
-
let { mutate: w, isPending:
|
|
2711
|
+
let { mutate: w, isPending: T } = ge(s, {
|
|
2698
2712
|
onError: (e, { email: t }) => {
|
|
2699
2713
|
S(""), e.error?.code === "EMAIL_NOT_VERIFIED" && (sessionStorage.setItem("better-auth-ui.verify-email", t), _({ to: `${c.auth}/${g.auth.verifyEmail}` })), y();
|
|
2700
2714
|
},
|
|
2701
2715
|
onSuccess: () => _({ to: f })
|
|
2702
|
-
}), { mutate:
|
|
2716
|
+
}), { mutate: te, isPending: ne } = ye(s, {
|
|
2703
2717
|
onError: () => {
|
|
2704
2718
|
S(""), y();
|
|
2705
2719
|
},
|
|
2706
2720
|
onSuccess: () => _({ to: f })
|
|
2707
|
-
}),
|
|
2721
|
+
}), re = (e) => {
|
|
2708
2722
|
e.preventDefault();
|
|
2709
2723
|
let t = new FormData(e.currentTarget), n = t.get("email"), r = t.get("rememberMe") === "on";
|
|
2710
2724
|
C(n) ? w({
|
|
@@ -2712,13 +2726,13 @@ function Fn({ className: n, socialLayout: i, socialPosition: a = "bottom", varia
|
|
|
2712
2726
|
password: x,
|
|
2713
2727
|
...l?.rememberMe ? { rememberMe: r } : {},
|
|
2714
2728
|
fetchOptions: v
|
|
2715
|
-
}) :
|
|
2729
|
+
}) : te({
|
|
2716
2730
|
username: n,
|
|
2717
2731
|
password: x,
|
|
2718
2732
|
...l?.rememberMe ? { rememberMe: r } : {},
|
|
2719
2733
|
fetchOptions: v
|
|
2720
2734
|
});
|
|
2721
|
-
},
|
|
2735
|
+
}, ie = Z({ mutationKey: r.signIn.all }) + Z({ mutationKey: r.signUp.all }) > 0, ae = T || ne, oe = d.find((e) => e.captchaComponent)?.captchaComponent, se = l?.enabled && !!h?.length;
|
|
2722
2736
|
return /* @__PURE__ */ X(A, {
|
|
2723
2737
|
className: G("w-full max-w-sm gap-4 md:p-6", n),
|
|
2724
2738
|
variant: o,
|
|
@@ -2732,14 +2746,14 @@ function Fn({ className: n, socialLayout: i, socialPosition: a = "bottom", varia
|
|
|
2732
2746
|
children: [
|
|
2733
2747
|
a === "top" && /* @__PURE__ */ X(J, { children: [!!h?.length && /* @__PURE__ */ Y(t, { socialLayout: i }), se && /* @__PURE__ */ Y(e, { children: u.auth.or })] }),
|
|
2734
2748
|
l?.enabled && /* @__PURE__ */ X(P, {
|
|
2735
|
-
onSubmit:
|
|
2749
|
+
onSubmit: re,
|
|
2736
2750
|
className: "flex flex-col gap-4",
|
|
2737
2751
|
children: [
|
|
2738
2752
|
/* @__PURE__ */ X(W, {
|
|
2739
2753
|
name: "email",
|
|
2740
2754
|
type: "text",
|
|
2741
2755
|
autoComplete: "username email",
|
|
2742
|
-
isDisabled:
|
|
2756
|
+
isDisabled: ie,
|
|
2743
2757
|
validate: (e) => {
|
|
2744
2758
|
if (!e) return u.auth.fieldRequired;
|
|
2745
2759
|
},
|
|
@@ -2759,7 +2773,7 @@ function Fn({ className: n, socialLayout: i, socialPosition: a = "bottom", varia
|
|
|
2759
2773
|
name: "password",
|
|
2760
2774
|
type: "password",
|
|
2761
2775
|
autoComplete: "current-password",
|
|
2762
|
-
isDisabled:
|
|
2776
|
+
isDisabled: ie,
|
|
2763
2777
|
value: x,
|
|
2764
2778
|
onChange: S,
|
|
2765
2779
|
validate: (e) => {
|
|
@@ -2780,7 +2794,7 @@ function Fn({ className: n, socialLayout: i, socialPosition: a = "bottom", varia
|
|
|
2780
2794
|
}),
|
|
2781
2795
|
l?.rememberMe && /* @__PURE__ */ Y(Xe, {
|
|
2782
2796
|
name: "rememberMe",
|
|
2783
|
-
isDisabled:
|
|
2797
|
+
isDisabled: ie,
|
|
2784
2798
|
variant: o === "transparent" ? "primary" : "secondary",
|
|
2785
2799
|
children: /* @__PURE__ */ X(Xe.Content, { children: [/* @__PURE__ */ Y(Xe.Control, { children: /* @__PURE__ */ Y(Xe.Indicator, {}) }), u.auth.rememberMe] })
|
|
2786
2800
|
}),
|
|
@@ -2793,7 +2807,7 @@ function Fn({ className: n, socialLayout: i, socialPosition: a = "bottom", varia
|
|
|
2793
2807
|
children: [/* @__PURE__ */ X(k, {
|
|
2794
2808
|
type: "submit",
|
|
2795
2809
|
className: "w-full",
|
|
2796
|
-
isPending: ae ||
|
|
2810
|
+
isPending: ae || ie,
|
|
2797
2811
|
children: [ae && /* @__PURE__ */ Y(V, {
|
|
2798
2812
|
color: "current",
|
|
2799
2813
|
size: "sm"
|
package/package.json
CHANGED
|
@@ -23,7 +23,8 @@ export function OrganizationRow({ organization }: OrganizationRowProps) {
|
|
|
23
23
|
const {
|
|
24
24
|
localization: organizationLocalization,
|
|
25
25
|
viewPaths: organizationViewPaths,
|
|
26
|
-
slug
|
|
26
|
+
slug,
|
|
27
|
+
slugPrefix
|
|
27
28
|
} = useAuthPlugin(organizationPlugin)
|
|
28
29
|
|
|
29
30
|
const { mutate: setActiveOrganization, isPending: setActivePending } =
|
|
@@ -38,7 +39,7 @@ export function OrganizationRow({ organization }: OrganizationRowProps) {
|
|
|
38
39
|
function manageOrganization() {
|
|
39
40
|
if (slug !== undefined) {
|
|
40
41
|
navigate({
|
|
41
|
-
to: `${basePaths.organization}/${organization.slug}/${organizationViewPaths.organization.settings}`
|
|
42
|
+
to: `${basePaths.organization}/${slugPrefix}${organization.slug}/${organizationViewPaths.organization.settings}`
|
|
42
43
|
})
|
|
43
44
|
} else {
|
|
44
45
|
setActiveOrganization({ organizationId: organization.id })
|
|
@@ -60,7 +60,8 @@ export function OrganizationSwitcher({
|
|
|
60
60
|
const {
|
|
61
61
|
localization: organizationLocalization,
|
|
62
62
|
viewPaths: organizationViewPaths,
|
|
63
|
-
slug
|
|
63
|
+
slug,
|
|
64
|
+
slugPrefix
|
|
64
65
|
} = useAuthPlugin(organizationPlugin)
|
|
65
66
|
|
|
66
67
|
const { data: activeOrganization, isPending: activeOrganizationPending } =
|
|
@@ -86,7 +87,7 @@ export function OrganizationSwitcher({
|
|
|
86
87
|
} else if (slug !== undefined) {
|
|
87
88
|
navigate({
|
|
88
89
|
to: organization
|
|
89
|
-
? `${basePaths.organization}/${organization.slug}/${organizationViewPaths.organization.settings}`
|
|
90
|
+
? `${basePaths.organization}/${slugPrefix}${organization.slug}/${organizationViewPaths.organization.settings}`
|
|
90
91
|
: `${basePaths.settings}/${viewPaths.settings.account}`
|
|
91
92
|
})
|
|
92
93
|
} else {
|
|
@@ -146,7 +147,7 @@ export function OrganizationSwitcher({
|
|
|
146
147
|
<Link
|
|
147
148
|
href={
|
|
148
149
|
slug
|
|
149
|
-
? `${basePaths.organization}/${slug}/${organizationViewPaths.organization.settings}`
|
|
150
|
+
? `${basePaths.organization}/${slugPrefix}${slug}/${organizationViewPaths.organization.settings}`
|
|
150
151
|
: `${basePaths.organization}/${organizationViewPaths.organization.settings}`
|
|
151
152
|
}
|
|
152
153
|
className={cn(
|
|
@@ -36,7 +36,7 @@ export function OrganizationView({
|
|
|
36
36
|
...props
|
|
37
37
|
}: OrganizationViewProps & ComponentProps<"div">) {
|
|
38
38
|
const { authClient } = useAuth()
|
|
39
|
-
const { roles } = useAuthPlugin(organizationPlugin)
|
|
39
|
+
const { roles, slugPrefix } = useAuthPlugin(organizationPlugin)
|
|
40
40
|
|
|
41
41
|
const { data: session } = useSession(authClient)
|
|
42
42
|
|
|
@@ -98,9 +98,10 @@ export function OrganizationView({
|
|
|
98
98
|
)}
|
|
99
99
|
</div>
|
|
100
100
|
|
|
101
|
-
{!hideSlug && (
|
|
101
|
+
{!hideSlug && !!resolvedOrganization?.slug && (
|
|
102
102
|
<p className="text-muted text-xs truncate overflow-x-hidden font-mono leading-tight">
|
|
103
|
-
{
|
|
103
|
+
{slugPrefix}
|
|
104
|
+
{resolvedOrganization.slug}
|
|
104
105
|
</p>
|
|
105
106
|
)}
|
|
106
107
|
</div>
|
|
@@ -45,7 +45,8 @@ export function Organization({
|
|
|
45
45
|
const {
|
|
46
46
|
localization: organizationLocalization,
|
|
47
47
|
viewPaths: organizationViewPaths,
|
|
48
|
-
slug
|
|
48
|
+
slug,
|
|
49
|
+
slugPrefix
|
|
49
50
|
} = useAuthPlugin(organizationPlugin)
|
|
50
51
|
|
|
51
52
|
const { data: activeOrganization, isPending } = useActiveOrganization(
|
|
@@ -107,7 +108,7 @@ export function Organization({
|
|
|
107
108
|
id="settings"
|
|
108
109
|
href={
|
|
109
110
|
slug
|
|
110
|
-
? `${basePaths.organization}/${slug}/${organizationViewPaths.organization.settings}`
|
|
111
|
+
? `${basePaths.organization}/${slugPrefix}${slug}/${organizationViewPaths.organization.settings}`
|
|
111
112
|
: `${basePaths.organization}/${organizationViewPaths.organization.settings}`
|
|
112
113
|
}
|
|
113
114
|
className="gap-2"
|
|
@@ -129,7 +130,7 @@ export function Organization({
|
|
|
129
130
|
id="people"
|
|
130
131
|
href={
|
|
131
132
|
slug
|
|
132
|
-
? `${basePaths.organization}/${slug}/${organizationViewPaths.organization.people}`
|
|
133
|
+
? `${basePaths.organization}/${slugPrefix}${slug}/${organizationViewPaths.organization.people}`
|
|
133
134
|
: `${basePaths.organization}/${organizationViewPaths.organization.people}`
|
|
134
135
|
}
|
|
135
136
|
className="gap-2"
|
|
@@ -48,8 +48,11 @@ export function SlugField({
|
|
|
48
48
|
...props
|
|
49
49
|
}: SlugFieldProps & TextFieldProps) {
|
|
50
50
|
const { authClient, localization: authLocalization } = useAuth()
|
|
51
|
-
const {
|
|
52
|
-
|
|
51
|
+
const {
|
|
52
|
+
localization,
|
|
53
|
+
checkSlug: checkSlugEnabled,
|
|
54
|
+
slugPrefix
|
|
55
|
+
} = useAuthPlugin(organizationPlugin)
|
|
53
56
|
|
|
54
57
|
const {
|
|
55
58
|
mutate: checkSlug,
|
|
@@ -93,6 +96,12 @@ export function SlugField({
|
|
|
93
96
|
<Label>{localization.slug}</Label>
|
|
94
97
|
|
|
95
98
|
<InputGroup variant={variant}>
|
|
99
|
+
{slugPrefix && (
|
|
100
|
+
<InputGroup.Prefix className="pr-1.5 text-muted">
|
|
101
|
+
{slugPrefix}
|
|
102
|
+
</InputGroup.Prefix>
|
|
103
|
+
)}
|
|
104
|
+
|
|
96
105
|
<InputGroup.Input placeholder={localization.slugPlaceholder} required />
|
|
97
106
|
|
|
98
107
|
{checkSlugEnabled && !!value.trim() && value.trim() !== currentSlug && (
|
|
@@ -34,7 +34,8 @@ export function UsernameField({
|
|
|
34
34
|
localization,
|
|
35
35
|
minUsernameLength,
|
|
36
36
|
maxUsernameLength,
|
|
37
|
-
isUsernameAvailable: checkAvailability
|
|
37
|
+
isUsernameAvailable: checkAvailability,
|
|
38
|
+
usernamePrefix
|
|
38
39
|
} = useAuthPlugin(usernamePlugin)
|
|
39
40
|
|
|
40
41
|
const currentUsername = String(field.defaultValue ?? "")
|
|
@@ -109,6 +110,12 @@ export function UsernameField({
|
|
|
109
110
|
<Label>{field.label}</Label>
|
|
110
111
|
|
|
111
112
|
<InputGroup variant={variant === "transparent" ? "primary" : "secondary"}>
|
|
113
|
+
{usernamePrefix && (
|
|
114
|
+
<InputGroup.Prefix className="pr-1.5 text-muted">
|
|
115
|
+
{usernamePrefix}
|
|
116
|
+
</InputGroup.Prefix>
|
|
117
|
+
)}
|
|
118
|
+
|
|
112
119
|
<InputGroup.Input
|
|
113
120
|
placeholder={field.placeholder}
|
|
114
121
|
required={field.required}
|