@better-auth-ui/heroui 1.6.21 → 1.6.23

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/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { a as e, i as t, n, r, t as i } from "./user-view--47tVtJ3.js";
3
3
  import { authMutationKeys as a, authQueryKeys as o, fileToBase64 as s, getProviderName as c, parseAdditionalFieldValue as l, resolveInputType as u } from "@better-auth-ui/core";
4
- import { AuthProvider as d, providerIcons as f, useAccountInfo as p, useAuth as m, useAuthenticate as h, useChangeEmail as g, useChangePassword as _, useFetchOptions as v, useLinkSocial as y, useListAccounts as b, useListSessions as x, useRequestPasswordReset as S, useResetPassword as ee, useRevokeSession as te, useSendVerificationEmail as ne, useSession as C, useSignInEmail as re, useSignOut as w, useSignUpEmail as ie, useUnlinkAccount as ae, useUpdateUser as T } from "@better-auth-ui/react";
4
+ import { AuthProvider as d, providerIcons as f, useAccountInfo as p, useAuth as m, useAuthenticate as h, useChangeEmail as g, useChangePassword as _, useFetchOptions as v, useLinkSocial as y, useListAccounts as ee, useListSessions as b, useRequestPasswordReset as x, useResetPassword as S, useRevokeSession as te, useSendVerificationEmail as ne, useSession as C, useSignInEmail as re, useSignOut as w, useSignUpEmail as ie, useUnlinkAccount as ae, useUpdateUser as T } from "@better-auth-ui/react";
5
5
  import { ArrowRightFromSquare as oe, ArrowRightToSquare as E, Check as se, ChevronsExpandVertical as ce, CloudArrowUpIn as le, Copy as ue, Display as de, Eye as D, EyeSlash as O, Gear as fe, Link as pe, LinkSlash as me, Person as he, PersonPlus as ge, PlugConnection as _e, Shield as ve, Smartphone as ye, TrashBin as be, Xmark as xe } from "@gravity-ui/icons";
6
6
  import { Button as k, Calendar as A, Card as j, Checkbox as M, Chip as Se, ComboBox as Ce, DateField as we, DatePicker as Te, Description as Ee, Dropdown as N, FieldError as P, Fieldset as F, Form as I, Input as L, InputGroup as R, Label as z, Link as B, ListBox as V, NumberField as H, RouterProvider as De, Select as U, Skeleton as W, Slider as Oe, Spinner as G, Switch as ke, Tabs as K, TextArea as Ae, TextField as q, TimeField as je, cn as J, toast as Y } from "@heroui/react";
7
7
  import { fromDate as Me, getLocalTimeZone as Ne, parseDate as Pe, parseDateTime as Fe, toCalendarDate as Ie, toCalendarDateTime as Le } from "@internationalized/date";
@@ -47,13 +47,16 @@ function Ye({ getValue: e, isDisabled: t }) {
47
47
  });
48
48
  }
49
49
  function Xe({ name: e, field: t, isPending: n, variant: r }) {
50
- let { localization: i } = m(), a = u(t), o = r === "transparent" ? "primary" : "secondary", s = Ve(null);
51
- if (t.render) return /* @__PURE__ */ Q(Z, { children: t.render({
52
- name: e,
53
- field: t,
54
- isPending: n,
55
- variant: r
56
- }) });
50
+ let { localization: i } = m(), a = u(t), o = r === "transparent" ? "primary" : "secondary";
51
+ if (t.render) {
52
+ let i = t.render;
53
+ return /* @__PURE__ */ Q(i, {
54
+ name: e,
55
+ field: t,
56
+ isPending: n,
57
+ variant: r
58
+ });
59
+ }
57
60
  if (a === "hidden") return /* @__PURE__ */ Q("input", {
58
61
  type: "hidden",
59
62
  name: e,
@@ -220,8 +223,16 @@ function Xe({ name: e, field: t, isPending: n, variant: r }) {
220
223
  ] })
221
224
  });
222
225
  }
223
- let c = t.prefix != null, l = t.suffix != null || t.copyable, d = t.type === "number", f = t.formatOptions?.maximumFractionDigits, p = d ? "number" : void 0, h = d ? f ? "decimal" : "numeric" : void 0, g = f ? 1 / 10 ** f : void 0;
224
- return c || l ? /* @__PURE__ */ $(q, {
226
+ return /* @__PURE__ */ Q(Ze, {
227
+ name: e,
228
+ field: t,
229
+ isPending: n,
230
+ variant: r
231
+ });
232
+ }
233
+ function Ze({ name: e, field: t, isPending: n, variant: r }) {
234
+ let i = Ve(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;
235
+ return o || s ? /* @__PURE__ */ $(q, {
225
236
  name: e,
226
237
  defaultValue: t.defaultValue == null ? void 0 : String(t.defaultValue),
227
238
  isDisabled: n,
@@ -229,21 +240,21 @@ function Xe({ name: e, field: t, isPending: n, variant: r }) {
229
240
  children: [
230
241
  /* @__PURE__ */ Q(z, { children: t.label }),
231
242
  /* @__PURE__ */ $(R, {
232
- variant: o,
243
+ variant: a,
233
244
  children: [
234
- c && /* @__PURE__ */ Q(R.Prefix, { children: t.prefix }),
245
+ o && /* @__PURE__ */ Q(R.Prefix, { children: t.prefix }),
235
246
  /* @__PURE__ */ Q(R.Input, {
236
- ref: s,
247
+ ref: i,
237
248
  placeholder: t.placeholder,
238
249
  required: t.required,
239
- type: p,
240
- inputMode: h,
241
- step: g
250
+ type: u,
251
+ inputMode: d,
252
+ step: f
242
253
  }),
243
254
  t.copyable ? /* @__PURE__ */ Q(R.Suffix, {
244
255
  className: "px-0",
245
256
  children: /* @__PURE__ */ Q(Ye, {
246
- getValue: () => s.current?.value,
257
+ getValue: () => i.current?.value,
247
258
  isDisabled: n
248
259
  })
249
260
  }) : t.suffix != null && /* @__PURE__ */ Q(R.Suffix, { children: t.suffix })
@@ -261,10 +272,10 @@ function Xe({ name: e, field: t, isPending: n, variant: r }) {
261
272
  /* @__PURE__ */ Q(L, {
262
273
  placeholder: t.placeholder,
263
274
  required: t.required,
264
- variant: o,
265
- type: p,
266
- inputMode: h,
267
- step: g
275
+ variant: a,
276
+ type: u,
277
+ inputMode: d,
278
+ step: f
268
279
  }),
269
280
  /* @__PURE__ */ Q(P, {})
270
281
  ]
@@ -272,8 +283,8 @@ function Xe({ name: e, field: t, isPending: n, variant: r }) {
272
283
  }
273
284
  //#endregion
274
285
  //#region src/components/auth/forgot-password.tsx
275
- function Ze({ className: e, variant: t }) {
276
- let { authClient: n, baseURL: r, basePaths: i, localization: a, viewPaths: o, navigate: s, plugins: c } = m(), { fetchOptions: l, resetFetchOptions: u } = v(), { mutate: d, isPending: f } = S(n, {
286
+ function Qe({ className: e, variant: t }) {
287
+ let { authClient: n, baseURL: r, basePaths: i, localization: a, viewPaths: o, navigate: s, plugins: c } = m(), { fetchOptions: l, resetFetchOptions: u } = v(), { mutate: d, isPending: f } = x(n, {
277
288
  onError: () => {
278
289
  u();
279
290
  },
@@ -361,8 +372,8 @@ function Ze({ className: e, variant: t }) {
361
372
  }
362
373
  //#endregion
363
374
  //#region src/components/auth/reset-password.tsx
364
- function Qe({ className: e, variant: t }) {
365
- let { authClient: n, basePaths: r, emailAndPassword: i, localization: a, viewPaths: o, navigate: s } = m(), { mutate: c, isPending: l } = ee(n, { onSuccess: () => {
375
+ function $e({ className: e, variant: t }) {
376
+ let { authClient: n, basePaths: r, emailAndPassword: i, localization: a, viewPaths: o, navigate: s } = m(), { mutate: c, isPending: l } = S(n, { onSuccess: () => {
366
377
  Y.success(a.auth.passwordResetSuccess), s({ to: `${r.auth}/${o.auth.signIn}` });
367
378
  } }), [u, d] = X(!1), [f, p] = X(!1);
368
379
  ze(() => {
@@ -513,16 +524,16 @@ function Qe({ className: e, variant: t }) {
513
524
  }
514
525
  //#endregion
515
526
  //#region src/components/auth/sign-in.tsx
516
- function $e({ className: t, socialLayout: n, socialPosition: i = "bottom", variant: o }) {
517
- let { authClient: s, basePaths: c, baseURL: l, emailAndPassword: u, localization: d, plugins: f, redirectTo: p, socialProviders: h, viewPaths: g, navigate: _ } = m(), { fetchOptions: y, resetFetchOptions: b } = v(), [x, S] = X(""), { mutate: ee } = ne(s, { onSuccess: () => Y.success(d.auth.verificationEmailSent) }), { mutate: te, isPending: C } = re(s, {
527
+ function et({ className: t, socialLayout: n, socialPosition: i = "bottom", variant: o }) {
528
+ let { authClient: s, basePaths: c, baseURL: l, emailAndPassword: u, localization: d, plugins: f, redirectTo: p, socialProviders: h, viewPaths: g, navigate: _ } = m(), { fetchOptions: y, resetFetchOptions: ee } = v(), [b, x] = X(""), { mutate: S } = ne(s, { onSuccess: () => Y.success(d.auth.verificationEmailSent) }), { mutate: te, isPending: C } = re(s, {
518
529
  onError: (e, { email: t }) => {
519
- S(""), e.error?.code === "EMAIL_NOT_VERIFIED" && Y.danger(e.error?.message || e.message, { actionProps: {
530
+ x(""), e.error?.code === "EMAIL_NOT_VERIFIED" && Y.danger(e.error?.message || e.message, { actionProps: {
520
531
  children: d.auth.resend,
521
- onClick: () => ee({
532
+ onClick: () => S({
522
533
  email: t,
523
534
  callbackURL: `${l}${p}`
524
535
  })
525
- } }), b();
536
+ } }), ee();
526
537
  },
527
538
  onSuccess: () => _({ to: p })
528
539
  }), w = (e) => {
@@ -530,7 +541,7 @@ function $e({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
530
541
  let t = new FormData(e.currentTarget), n = t.get("email"), r = t.get("rememberMe") === "on";
531
542
  te({
532
543
  email: n,
533
- password: x,
544
+ password: b,
534
545
  ...u?.rememberMe ? { rememberMe: r } : {},
535
546
  fetchOptions: y
536
547
  });
@@ -577,8 +588,8 @@ function $e({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
577
588
  type: "password",
578
589
  autoComplete: "current-password",
579
590
  isDisabled: ie,
580
- value: x,
581
- onChange: S,
591
+ value: b,
592
+ onChange: x,
582
593
  validate: (e) => {
583
594
  if (!e) return d.auth.fieldRequired;
584
595
  let t = u?.minPasswordLength, n = u?.maxPasswordLength;
@@ -646,7 +657,7 @@ function $e({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
646
657
  }
647
658
  //#endregion
648
659
  //#region src/components/auth/sign-out.tsx
649
- function et({ className: e }) {
660
+ function tt({ className: e }) {
650
661
  let { authClient: t, basePaths: n, navigate: r, viewPaths: i } = m(), { mutate: a } = w(t, {
651
662
  onError: () => {
652
663
  r({
@@ -668,10 +679,10 @@ function et({ className: e }) {
668
679
  }
669
680
  //#endregion
670
681
  //#region src/components/auth/sign-up.tsx
671
- function tt({ className: t, socialLayout: n, socialPosition: i = "bottom", variant: o }) {
672
- let { additionalFields: s, authClient: c, basePaths: u, emailAndPassword: d, localization: f, plugins: p, redirectTo: h, socialProviders: g, viewPaths: _, navigate: y } = m(), { fetchOptions: b, resetFetchOptions: x } = v(), [S, ee] = X(""), [te, ne] = X(""), { mutate: C, isPending: re } = ie(c, {
682
+ function nt({ className: t, socialLayout: n, socialPosition: i = "bottom", variant: o }) {
683
+ let { additionalFields: s, authClient: c, basePaths: u, emailAndPassword: d, localization: f, plugins: p, redirectTo: h, socialProviders: g, viewPaths: _, navigate: y } = m(), { fetchOptions: ee, resetFetchOptions: b } = v(), [x, S] = X(""), [te, ne] = X(""), { mutate: C, isPending: re } = ie(c, {
673
684
  onError: () => {
674
- ee(""), ne(""), x();
685
+ S(""), ne(""), b();
675
686
  },
676
687
  onSuccess: () => {
677
688
  d?.requireEmailVerification ? (Y.success(f.auth.verifyYourEmail), y({ to: `${u.auth}/${_.auth.signIn}` })) : y({ to: h });
@@ -679,8 +690,8 @@ function tt({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
679
690
  }), [w, ae] = X(!1), [T, oe] = X(!1), E = We({ mutationKey: a.signIn.all }) + We({ mutationKey: a.signUp.all }) > 0, se = p.find((e) => e.captchaComponent)?.captchaComponent, ce = async (e) => {
680
691
  e.preventDefault();
681
692
  let t = new FormData(e.currentTarget), n = t.get("name") ?? "", r = t.get("email");
682
- if (d?.confirmPassword && S !== te) {
683
- Y.danger(f.auth.passwordsDoNotMatch), ee(""), ne("");
693
+ if (d?.confirmPassword && x !== te) {
694
+ Y.danger(f.auth.passwordsDoNotMatch), S(""), ne("");
684
695
  return;
685
696
  }
686
697
  let i = {};
@@ -698,9 +709,9 @@ function tt({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
698
709
  C({
699
710
  name: n,
700
711
  email: r,
701
- password: S,
712
+ password: x,
702
713
  ...i,
703
- fetchOptions: b
714
+ fetchOptions: ee
704
715
  });
705
716
  }, le = d?.enabled && !!g?.length;
706
717
  return /* @__PURE__ */ $(j, {
@@ -768,8 +779,8 @@ function tt({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
768
779
  name: "password",
769
780
  autoComplete: "new-password",
770
781
  isDisabled: E,
771
- value: S,
772
- onChange: ee,
782
+ value: x,
783
+ onChange: S,
773
784
  validate: (e) => {
774
785
  if (!e) return f.auth.fieldRequired;
775
786
  let t = d?.minPasswordLength, n = d?.maxPasswordLength;
@@ -887,21 +898,21 @@ function tt({ className: t, socialLayout: n, socialPosition: i = "bottom", varia
887
898
  }
888
899
  //#endregion
889
900
  //#region src/components/auth/auth.tsx
890
- var nt = [
901
+ var rt = [
891
902
  "signUp",
892
903
  "forgotPassword",
893
904
  "resetPassword"
894
- ], rt = {
895
- signIn: $e,
896
- signOut: et,
897
- signUp: tt,
898
- forgotPassword: Ze,
899
- resetPassword: Qe
905
+ ], it = {
906
+ signIn: et,
907
+ signOut: tt,
908
+ signUp: nt,
909
+ forgotPassword: Qe,
910
+ resetPassword: $e
900
911
  };
901
- function it({ className: e, path: t, socialLayout: n, socialPosition: r, variant: i, view: a }) {
912
+ function at({ className: e, path: t, socialLayout: n, socialPosition: r, variant: i, view: a }) {
902
913
  let { basePaths: o, emailAndPassword: s, plugins: c, viewPaths: l, navigate: u } = m();
903
914
  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 && nt.includes(d);
915
+ let d = a || Object.keys(l.auth).find((e) => l.auth[e] === t), f = !s?.enabled && d && rt.includes(d);
905
916
  if (ze(() => {
906
917
  f && u({
907
918
  to: `${o.auth}/${l.auth.signIn}`,
@@ -933,8 +944,8 @@ function it({ className: e, path: t, socialLayout: n, socialPosition: r, variant
933
944
  variant: i
934
945
  });
935
946
  }
936
- let p = d ? rt[d] : void 0;
937
- if (!p) throw Error(`[Better Auth UI] Unknown view "${d}". Valid views are: ${Object.keys(rt).join(", ")}`);
947
+ let p = d ? it[d] : void 0;
948
+ if (!p) throw Error(`[Better Auth UI] Unknown view "${d}". Valid views are: ${Object.keys(it).join(", ")}`);
938
949
  return /* @__PURE__ */ Q(p, {
939
950
  className: e,
940
951
  socialLayout: n,
@@ -944,7 +955,7 @@ function it({ className: e, path: t, socialLayout: n, socialPosition: r, variant
944
955
  }
945
956
  //#endregion
946
957
  //#region src/components/auth/error-toaster.tsx
947
- function at() {
958
+ function ot() {
948
959
  let e = Ge();
949
960
  return ze(() => {
950
961
  let t = e.getQueryCache(), n = t.config.onError;
@@ -965,19 +976,19 @@ function at() {
965
976
  }
966
977
  //#endregion
967
978
  //#region src/components/auth/auth-provider.tsx
968
- function ot({ children: e, navigate: t, ...n }) {
979
+ function st({ children: e, navigate: t, ...n }) {
969
980
  return /* @__PURE__ */ Q(d, {
970
981
  navigate: t,
971
982
  ...n,
972
983
  children: /* @__PURE__ */ $(De, {
973
984
  navigate: (e) => t({ to: e }),
974
- children: [e, /* @__PURE__ */ Q(at, {})]
985
+ children: [e, /* @__PURE__ */ Q(ot, {})]
975
986
  })
976
987
  });
977
988
  }
978
989
  //#endregion
979
990
  //#region src/components/auth/settings/account/change-email.tsx
980
- function st({ className: e, variant: t, ...n }) {
991
+ function ct({ className: e, variant: t, ...n }) {
981
992
  let { authClient: r, localization: i, baseURL: a, viewPaths: o } = m(), { data: s } = C(r), { mutate: c, isPending: l } = g(r, { onSuccess: () => Y.success(i.settings.changeEmailSuccess) });
982
993
  function u(e) {
983
994
  e.preventDefault(), c({
@@ -1027,7 +1038,7 @@ function st({ className: e, variant: t, ...n }) {
1027
1038
  }
1028
1039
  //#endregion
1029
1040
  //#region src/components/auth/settings/account/change-avatar.tsx
1030
- function ct({ className: e }) {
1041
+ function lt({ className: e }) {
1031
1042
  let { authClient: t, localization: r, avatar: i } = m(), { data: a } = C(t), { mutate: o, isPending: c } = T(t), l = Ve(null), [u, d] = X(!1), [f, p] = X(!1), h = c || u || f;
1032
1043
  async function g(e) {
1033
1044
  let t = e.target.files?.[0];
@@ -1108,7 +1119,7 @@ function ct({ className: e }) {
1108
1119
  }
1109
1120
  //#endregion
1110
1121
  //#region src/components/auth/settings/account/user-profile.tsx
1111
- function lt({ className: e, variant: t, ...n }) {
1122
+ function ut({ className: e, variant: t, ...n }) {
1112
1123
  let { additionalFields: r, authClient: i, localization: a } = m(), { data: o } = C(i), { mutate: s, isPending: c } = T(i, { onSuccess: () => Y.success(a.settings.profileUpdatedSuccess) });
1113
1124
  async function u(e) {
1114
1125
  e.preventDefault();
@@ -1140,7 +1151,7 @@ function lt({ className: e, variant: t, ...n }) {
1140
1151
  onSubmit: u,
1141
1152
  className: "flex flex-col gap-4",
1142
1153
  children: [
1143
- /* @__PURE__ */ Q(ct, {}),
1154
+ /* @__PURE__ */ Q(lt, {}),
1144
1155
  /* @__PURE__ */ $(q, {
1145
1156
  name: "name",
1146
1157
  defaultValue: o?.user.name,
@@ -1187,21 +1198,21 @@ function lt({ className: e, variant: t, ...n }) {
1187
1198
  }
1188
1199
  //#endregion
1189
1200
  //#region src/components/auth/settings/account/account-settings.tsx
1190
- function ut({ className: e, variant: t, ...n }) {
1201
+ function dt({ className: e, variant: t, ...n }) {
1191
1202
  let { emailAndPassword: r, plugins: i } = m(), a = i.some((e) => e.id === "magicLink");
1192
1203
  return /* @__PURE__ */ $("div", {
1193
1204
  className: J("flex w-full flex-col gap-4 md:gap-6", e),
1194
1205
  ...n,
1195
1206
  children: [
1196
- /* @__PURE__ */ Q(lt, { variant: t }),
1197
- (r?.enabled || a) && /* @__PURE__ */ Q(st, { variant: t }),
1207
+ /* @__PURE__ */ Q(ut, { variant: t }),
1208
+ (r?.enabled || a) && /* @__PURE__ */ Q(ct, { variant: t }),
1198
1209
  i.flatMap((e) => e.accountCards?.map((n, r) => /* @__PURE__ */ Q(n, { variant: t }, `${e.id}-${r.toString()}`)))
1199
1210
  ]
1200
1211
  });
1201
1212
  }
1202
1213
  //#endregion
1203
1214
  //#region src/components/auth/settings/security/active-session.tsx
1204
- function dt(e) {
1215
+ function ft(e) {
1205
1216
  let t = Math.floor((Date.now() - e.getTime()) / 1e3), n = new Intl.RelativeTimeFormat(void 0, { numeric: "auto" });
1206
1217
  for (let [e, r] of [
1207
1218
  ["year", 31536e3],
@@ -1214,7 +1225,7 @@ function dt(e) {
1214
1225
  ]) if (t >= r) return n.format(-Math.floor(t / r), e);
1215
1226
  return n.format(0, "second");
1216
1227
  }
1217
- function ft({ activeSession: e }) {
1228
+ function pt({ activeSession: e }) {
1218
1229
  let { authClient: t, basePaths: n, localization: r, viewPaths: i, navigate: a } = m(), { data: o } = C(t, { refetchOnMount: !1 }), { mutate: s, isPending: c } = te(t, { onSuccess: () => Y.success(r.settings.revokeSessionSuccess) }), l = e.token === o?.session.token, u = Ke.parse(e.userAgent || "");
1219
1230
  return /* @__PURE__ */ $("div", {
1220
1231
  className: "flex items-center gap-3",
@@ -1234,7 +1245,7 @@ function ft({ activeSession: e }) {
1234
1245
  children: r.settings.currentSession
1235
1246
  }) : e.createdAt && /* @__PURE__ */ Q("span", {
1236
1247
  className: "text-xs text-muted capitalize",
1237
- children: dt(e.createdAt)
1248
+ children: ft(e.createdAt)
1238
1249
  })]
1239
1250
  }),
1240
1251
  /* @__PURE__ */ $(k, {
@@ -1254,8 +1265,8 @@ function ft({ activeSession: e }) {
1254
1265
  }
1255
1266
  //#endregion
1256
1267
  //#region src/components/auth/settings/security/active-sessions.tsx
1257
- function pt({ className: e, variant: t, ...n }) {
1258
- let { authClient: r, localization: i } = m(), { data: a } = C(r), { data: o, isPending: s } = x(r), c = o && [...o].sort((e, t) => e.id === a?.session.id ? -1 : +(t.id === a?.session.id));
1268
+ function mt({ className: e, variant: t, ...n }) {
1269
+ let { authClient: r, localization: i } = m(), { data: a } = C(r), { data: o, isPending: s } = b(r), c = o && [...o].sort((e, t) => e.id === a?.session.id ? -1 : +(t.id === a?.session.id));
1259
1270
  return /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q("h2", {
1260
1271
  className: J("text-sm font-semibold mb-3"),
1261
1272
  children: i.settings.activeSessions
@@ -1265,11 +1276,11 @@ function pt({ className: e, variant: t, ...n }) {
1265
1276
  ...n,
1266
1277
  children: /* @__PURE__ */ Q(j.Content, {
1267
1278
  className: "gap-0",
1268
- children: s ? /* @__PURE__ */ Q(mt, {}) : c?.map((e, t) => /* @__PURE__ */ $("div", { children: [t > 0 && /* @__PURE__ */ Q("div", { className: "border-b border-dashed -mx-4 my-4" }), /* @__PURE__ */ Q(ft, { activeSession: e })] }, e.id))
1279
+ children: s ? /* @__PURE__ */ Q(ht, {}) : c?.map((e, t) => /* @__PURE__ */ $("div", { children: [t > 0 && /* @__PURE__ */ Q("div", { className: "border-b border-dashed -mx-4 my-4" }), /* @__PURE__ */ Q(pt, { activeSession: e })] }, e.id))
1269
1280
  })
1270
1281
  })] });
1271
1282
  }
1272
- function mt() {
1283
+ function ht() {
1273
1284
  return /* @__PURE__ */ Q("div", {
1274
1285
  className: "flex items-center justify-between",
1275
1286
  children: /* @__PURE__ */ $("div", {
@@ -1283,13 +1294,13 @@ function mt() {
1283
1294
  }
1284
1295
  //#endregion
1285
1296
  //#region src/components/auth/settings/security/change-password.tsx
1286
- function ht({ className: e, variant: t, ...n }) {
1287
- let { authClient: r, emailAndPassword: i, localization: a } = m(), { data: o } = C(r), { data: s, isPending: c } = b(r), l = s?.some((e) => e.providerId === "credential");
1288
- return !c && !l ? /* @__PURE__ */ Q(gt, {
1297
+ function gt({ className: e, variant: t, ...n }) {
1298
+ let { authClient: r, emailAndPassword: i, localization: a } = m(), { data: o } = C(r), { data: s, isPending: c } = ee(r), l = s?.some((e) => e.providerId === "credential");
1299
+ return !c && !l ? /* @__PURE__ */ Q(_t, {
1289
1300
  className: e,
1290
1301
  variant: t,
1291
1302
  ...n
1292
- }) : /* @__PURE__ */ Q(_t, {
1303
+ }) : /* @__PURE__ */ Q(vt, {
1293
1304
  className: e,
1294
1305
  variant: t,
1295
1306
  emailAndPassword: i,
@@ -1298,8 +1309,8 @@ function ht({ className: e, variant: t, ...n }) {
1298
1309
  ...n
1299
1310
  });
1300
1311
  }
1301
- function gt({ className: e, variant: t, ...n }) {
1302
- let { authClient: r, localization: i, plugins: a } = m(), { data: o } = C(r), { fetchOptions: s, resetFetchOptions: c } = v(), { mutate: l, isPending: u } = S(r, {
1312
+ function _t({ className: e, variant: t, ...n }) {
1313
+ let { authClient: r, localization: i, plugins: a } = m(), { data: o } = C(r), { fetchOptions: s, resetFetchOptions: c } = v(), { mutate: l, isPending: u } = x(r, {
1303
1314
  onError: () => {
1304
1315
  c();
1305
1316
  },
@@ -1341,7 +1352,7 @@ function gt({ className: e, variant: t, ...n }) {
1341
1352
  })
1342
1353
  })] });
1343
1354
  }
1344
- function _t({ className: e, variant: t, emailAndPassword: n, localization: r, session: i, ...a }) {
1355
+ function vt({ className: e, variant: t, emailAndPassword: n, localization: r, session: i, ...a }) {
1345
1356
  let { authClient: o } = m(), [s, c] = X(""), [l, u] = X(""), [d, f] = X(""), { mutate: p, isPending: h } = _(o, {
1346
1357
  onError: () => {
1347
1358
  c(""), u(""), f("");
@@ -1349,7 +1360,7 @@ function _t({ className: e, variant: t, emailAndPassword: n, localization: r, se
1349
1360
  onSuccess: () => {
1350
1361
  c(""), u(""), f(""), Y.success(r.settings.changePasswordSuccess);
1351
1362
  }
1352
- }), [g, v] = X(!1), [y, b] = X(!1), x = (e) => {
1363
+ }), [g, v] = X(!1), [y, ee] = X(!1), b = (e) => {
1353
1364
  if (e.preventDefault(), n?.confirmPassword && l !== d) {
1354
1365
  c(""), u(""), f(""), Y.danger(r.auth.passwordsDoNotMatch);
1355
1366
  return;
@@ -1368,7 +1379,7 @@ function _t({ className: e, variant: t, emailAndPassword: n, localization: r, se
1368
1379
  variant: t,
1369
1380
  ...a,
1370
1381
  children: /* @__PURE__ */ Q(j.Content, { children: /* @__PURE__ */ Q(I, {
1371
- onSubmit: x,
1382
+ onSubmit: b,
1372
1383
  children: /* @__PURE__ */ $(F, {
1373
1384
  className: "w-full gap-4",
1374
1385
  children: [/* @__PURE__ */ $(F.Group, { children: [
@@ -1451,7 +1462,7 @@ function _t({ className: e, variant: t, emailAndPassword: n, localization: r, se
1451
1462
  "aria-label": y ? r.auth.hidePassword : r.auth.showPassword,
1452
1463
  size: "sm",
1453
1464
  variant: "ghost",
1454
- onPress: () => b(!y),
1465
+ onPress: () => ee(!y),
1455
1466
  isDisabled: h,
1456
1467
  children: Q(y ? O : D, {})
1457
1468
  })
@@ -1477,7 +1488,7 @@ function _t({ className: e, variant: t, emailAndPassword: n, localization: r, se
1477
1488
  }
1478
1489
  //#endregion
1479
1490
  //#region src/components/auth/settings/security/linked-account.tsx
1480
- function vt({ account: e, provider: t }) {
1491
+ function yt({ account: e, provider: t }) {
1481
1492
  let { authClient: n, baseURL: r, localization: i } = m(), { data: a, isPending: o } = p(n, { query: { accountId: e?.accountId } }), { mutate: s, isPending: l } = y(n), { mutate: u, isPending: d } = ae(n, { onSuccess: () => Y.success(i.settings.accountUnlinked) }), h = f[t], g = c(t), _ = a?.data?.login || a?.data?.username || a?.user?.email || a?.user?.name || e?.accountId;
1482
1493
  return /* @__PURE__ */ $("div", {
1483
1494
  className: "flex items-center gap-3",
@@ -1527,8 +1538,8 @@ function vt({ account: e, provider: t }) {
1527
1538
  }
1528
1539
  //#endregion
1529
1540
  //#region src/components/auth/settings/security/linked-accounts.tsx
1530
- function yt({ className: e, variant: t, ...n }) {
1531
- let { authClient: r, localization: i, multipleAccountsPerProvider: a, socialProviders: o } = m(), { data: s, isPending: c } = b(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) => ({
1541
+ function bt({ className: e, variant: t, ...n }) {
1542
+ let { authClient: r, localization: i, multipleAccountsPerProvider: a, socialProviders: o } = m(), { data: s, isPending: c } = ee(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
1543
  key: e.id,
1533
1544
  account: e,
1534
1545
  provider: e.providerId
@@ -1546,14 +1557,14 @@ function yt({ className: e, variant: t, ...n }) {
1546
1557
  ...n,
1547
1558
  children: /* @__PURE__ */ Q(j.Content, {
1548
1559
  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(bt, {})] }, e)) : f.map((e, t) => /* @__PURE__ */ $("div", { children: [t > 0 && /* @__PURE__ */ Q("div", { className: "border-b border-dashed -mx-4 my-4" }), /* @__PURE__ */ Q(vt, {
1560
+ children: c ? o?.map((e, t) => /* @__PURE__ */ $("div", { children: [t > 0 && /* @__PURE__ */ Q("div", { className: "border-b border-dashed -mx-4 my-4" }), /* @__PURE__ */ Q(xt, {})] }, e)) : f.map((e, t) => /* @__PURE__ */ $("div", { children: [t > 0 && /* @__PURE__ */ Q("div", { className: "border-b border-dashed -mx-4 my-4" }), /* @__PURE__ */ Q(yt, {
1550
1561
  account: e.account,
1551
1562
  provider: e.provider
1552
1563
  })] }, e.key))
1553
1564
  })
1554
1565
  })] });
1555
1566
  }
1556
- function bt() {
1567
+ function xt() {
1557
1568
  return /* @__PURE__ */ Q("div", {
1558
1569
  className: "flex items-center justify-between",
1559
1570
  children: /* @__PURE__ */ $("div", {
@@ -1567,22 +1578,22 @@ function bt() {
1567
1578
  }
1568
1579
  //#endregion
1569
1580
  //#region src/components/auth/settings/security/security-settings.tsx
1570
- function xt({ className: e, variant: t, ...n }) {
1581
+ function St({ className: e, variant: t, ...n }) {
1571
1582
  let { emailAndPassword: r, plugins: i, socialProviders: a } = m();
1572
1583
  return /* @__PURE__ */ $("div", {
1573
1584
  className: J("flex w-full flex-col gap-4 md:gap-6", e),
1574
1585
  ...n,
1575
1586
  children: [
1576
- r?.enabled && /* @__PURE__ */ Q(ht, { variant: t }),
1577
- !!a?.length && /* @__PURE__ */ Q(yt, { variant: t }),
1578
- /* @__PURE__ */ Q(pt, { variant: t }),
1587
+ r?.enabled && /* @__PURE__ */ Q(gt, { variant: t }),
1588
+ !!a?.length && /* @__PURE__ */ Q(bt, { variant: t }),
1589
+ /* @__PURE__ */ Q(mt, { variant: t }),
1579
1590
  i.flatMap((e) => e.securityCards?.map((n, r) => /* @__PURE__ */ Q(n, { variant: t }, `${e.id}-${r.toString()}`)))
1580
1591
  ]
1581
1592
  });
1582
1593
  }
1583
1594
  //#endregion
1584
1595
  //#region src/components/auth/settings/settings.tsx
1585
- function St({ className: e, hideNav: t, path: n, variant: r, view: i, ...a }) {
1596
+ function Ct({ className: e, hideNav: t, path: n, variant: r, view: i, ...a }) {
1586
1597
  if (!i && !n) throw Error("[Better Auth UI] Either `view` or `path` must be provided");
1587
1598
  let { authClient: o, basePaths: s, localization: c, viewPaths: l, plugins: u } = m();
1588
1599
  h(o);
@@ -1652,12 +1663,12 @@ function St({ className: e, hideNav: t, path: n, variant: r, view: i, ...a }) {
1652
1663
  /* @__PURE__ */ Q(K.Panel, {
1653
1664
  id: "account",
1654
1665
  className: "px-0",
1655
- children: /* @__PURE__ */ Q(ut, { variant: r })
1666
+ children: /* @__PURE__ */ Q(dt, { variant: r })
1656
1667
  }),
1657
1668
  /* @__PURE__ */ Q(K.Panel, {
1658
1669
  id: "security",
1659
1670
  className: "px-0",
1660
- children: /* @__PURE__ */ Q(xt, { variant: r })
1671
+ children: /* @__PURE__ */ Q(St, { variant: r })
1661
1672
  }),
1662
1673
  u.flatMap((e) => e.settingsTabs?.map((t, n) => /* @__PURE__ */ Q(K.Panel, {
1663
1674
  id: t.view,
@@ -1669,7 +1680,7 @@ function St({ className: e, hideNav: t, path: n, variant: r, view: i, ...a }) {
1669
1680
  }
1670
1681
  //#endregion
1671
1682
  //#region src/components/auth/user/user-button.tsx
1672
- function Ct(e, t) {
1683
+ function wt(e, t) {
1673
1684
  if (Re(e)) return e;
1674
1685
  let { label: n, href: r, icon: i, variant: a } = e;
1675
1686
  return /* @__PURE__ */ $(N.Item, {
@@ -1679,13 +1690,13 @@ function Ct(e, t) {
1679
1690
  children: [i, /* @__PURE__ */ Q(z, { children: n })]
1680
1691
  }, t);
1681
1692
  }
1682
- function wt({ className: e, placement: t, size: r = "default", variant: a = "ghost", links: o, hideSettings: s, hideSubtitle: c }) {
1693
+ function Tt({ className: e, placement: t, size: r = "default", variant: a = "ghost", links: o, hideSettings: s, hideSubtitle: c }) {
1683
1694
  let { authClient: l, basePaths: u, viewPaths: d, localization: f, plugins: p } = m(), { data: h, isPending: g } = C(l), _ = p.flatMap((e) => e.userMenuItems?.map((t, n) => /* @__PURE__ */ Q(t, { hideSubtitle: c }, `${e.id}-${n.toString()}`)) ?? []), v = o?.flatMap((e, t) => {
1684
1695
  if (!Re(e)) {
1685
1696
  let t = e.visibility ?? "always";
1686
1697
  if (t === "authenticated" && !h || t === "unauthenticated" && h) return [];
1687
1698
  }
1688
- return [Ct(e, `user-button-link-${t.toString()}`)];
1699
+ return [wt(e, `user-button-link-${t.toString()}`)];
1689
1700
  });
1690
1701
  return /* @__PURE__ */ $(N, { children: [r === "icon" ? /* @__PURE__ */ Q(N.Trigger, {
1691
1702
  className: J("rounded-full"),
@@ -1737,4 +1748,4 @@ function wt({ className: e, placement: t, size: r = "default", variant: a = "gho
1737
1748
  })] });
1738
1749
  }
1739
1750
  //#endregion
1740
- export { ut as AccountSettings, pt as ActiveSessions, Xe as AdditionalField, it as Auth, ot as AuthProvider, st as ChangeEmail, ht as ChangePassword, Ze as ForgotPassword, yt as LinkedAccounts, t as ProviderButton, r as ProviderButtons, Qe as ResetPassword, xt as SecuritySettings, St as Settings, $e as SignIn, et as SignOut, tt as SignUp, n as UserAvatar, wt as UserButton, lt as UserProfile, i as UserView };
1751
+ export { dt as AccountSettings, mt as ActiveSessions, Xe as AdditionalField, at as Auth, st as AuthProvider, ct as ChangeEmail, gt as ChangePassword, Qe as ForgotPassword, bt as LinkedAccounts, t as ProviderButton, r as ProviderButtons, $e as ResetPassword, St as SecuritySettings, Ct as Settings, et as SignIn, tt as SignOut, nt as SignUp, n as UserAvatar, Tt as UserButton, ut as UserProfile, i as UserView };
package/dist/plugins.js CHANGED
@@ -731,17 +731,17 @@ function Vt({ value: e, onChange: t, currentSlug: n, variant: r, ...i }) {
731
731
  //#endregion
732
732
  //#region src/components/auth/organization/create-organization-dialog.tsx
733
733
  function Ht({ isOpen: e, onOpenChange: t }) {
734
- let { authClient: n, localization: r } = p(), { localization: i } = m($), [a, o] = q(""), [s, c] = q(""), { mutate: l, isPending: u } = y(n, { onSuccess: () => t(!1) });
734
+ let { authClient: n, localization: r } = p(), { localization: i } = m($), [a, o] = q(""), [s, c] = q(""), [l, u] = q(!1), { mutate: d, isPending: f } = y(n, { onSuccess: () => t(!1) });
735
735
  return at(() => {
736
- e || (c(""), o(""));
736
+ e || (c(""), o(""), u(!1));
737
737
  }, [e]), at(() => {
738
- c(Bt(a));
739
- }, [a]), /* @__PURE__ */ Y(O.Backdrop, {
738
+ l || c(Bt(a));
739
+ }, [a, l]), /* @__PURE__ */ Y(O.Backdrop, {
740
740
  isOpen: e,
741
741
  onOpenChange: t,
742
742
  children: /* @__PURE__ */ Y(O.Container, { children: /* @__PURE__ */ Y(O.Dialog, { children: /* @__PURE__ */ X(P, {
743
743
  onSubmit: (e) => {
744
- e.preventDefault(), l({
744
+ e.preventDefault(), d({
745
745
  name: a,
746
746
  slug: s
747
747
  });
@@ -762,7 +762,7 @@ function Ht({ isOpen: e, onOpenChange: t }) {
762
762
  /* @__PURE__ */ X(W, {
763
763
  id: "name",
764
764
  name: "name",
765
- isDisabled: u,
765
+ isDisabled: f,
766
766
  value: a,
767
767
  onChange: o,
768
768
  validate: (e) => {
@@ -781,8 +781,10 @@ function Ht({ isOpen: e, onOpenChange: t }) {
781
781
  }),
782
782
  /* @__PURE__ */ Y(Vt, {
783
783
  value: s,
784
- onChange: c,
785
- isDisabled: u,
784
+ onChange: (e) => {
785
+ c(e), u(!0);
786
+ },
787
+ isDisabled: f,
786
788
  variant: "secondary"
787
789
  })
788
790
  ]
@@ -790,12 +792,12 @@ function Ht({ isOpen: e, onOpenChange: t }) {
790
792
  /* @__PURE__ */ X(O.Footer, { children: [/* @__PURE__ */ Y(k, {
791
793
  slot: "close",
792
794
  variant: "tertiary",
793
- isDisabled: u,
795
+ isDisabled: f,
794
796
  children: r.settings.cancel
795
797
  }), /* @__PURE__ */ X(k, {
796
798
  type: "submit",
797
- isPending: u,
798
- children: [u && /* @__PURE__ */ Y(V, {
799
+ isPending: f,
800
+ children: [f && /* @__PURE__ */ Y(V, {
799
801
  color: "current",
800
802
  size: "sm"
801
803
  }), i.createOrganization]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth-ui/heroui",
3
- "version": "1.6.21",
3
+ "version": "1.6.23",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "vite build",
@@ -34,7 +34,7 @@ import {
34
34
  toCalendarDate,
35
35
  toCalendarDateTime
36
36
  } from "@internationalized/date"
37
- import { useRef, useState } from "react"
37
+ import { type ComponentType, useRef, useState } from "react"
38
38
 
39
39
  import type { AdditionalFieldProps } from "../../lib/auth/auth-plugin"
40
40
 
@@ -128,12 +128,17 @@ export function AdditionalField({
128
128
  const { localization } = useAuth()
129
129
  const inputType = resolveInputType(field)
130
130
  const inputVariant = variant === "transparent" ? "primary" : "secondary"
131
- // Used by `inputType: "input"` with `copyable: true` so the copy button
132
- // reads the input's *live* value rather than a stale `defaultValue`.
133
- const inputRef = useRef<HTMLInputElement>(null)
134
131
 
135
132
  if (field.render) {
136
- return <>{field.render({ name, field, isPending, variant })}</>
133
+ const FieldRenderer = field.render as ComponentType<AdditionalFieldProps>
134
+ return (
135
+ <FieldRenderer
136
+ name={name}
137
+ field={field}
138
+ isPending={isPending}
139
+ variant={variant}
140
+ />
141
+ )
137
142
  }
138
143
 
139
144
  if (inputType === "hidden") {
@@ -471,13 +476,28 @@ export function AdditionalField({
471
476
  )
472
477
  }
473
478
 
474
- // inputType === "input"
479
+ return (
480
+ <HeroInputField
481
+ name={name}
482
+ field={field}
483
+ isPending={isPending}
484
+ variant={variant}
485
+ />
486
+ )
487
+ }
488
+
489
+ function HeroInputField({
490
+ name,
491
+ field,
492
+ isPending,
493
+ variant
494
+ }: AdditionalFieldProps) {
495
+ const inputRef = useRef<HTMLInputElement>(null)
496
+ const inputVariant = variant === "transparent" ? "primary" : "secondary"
497
+
475
498
  const hasPrefix = field.prefix != null
476
499
  const hasSuffix = field.suffix != null || field.copyable
477
500
 
478
- // When `inputType: "input"` is paired with `type: "number"`, restrict the
479
- // native input to numbers. `formatOptions.maximumFractionDigits` enables
480
- // fractional input via `step`.
481
501
  const isNumeric = field.type === "number"
482
502
  const maxFractionDigits = field.formatOptions?.maximumFractionDigits
483
503
  const nativeInputType = isNumeric ? "number" : undefined
@@ -43,6 +43,7 @@ export function CreateOrganizationDialog({
43
43
 
44
44
  const [name, setName] = useState("")
45
45
  const [slug, setSlug] = useState("")
46
+ const [slugEdited, setSlugEdited] = useState(false)
46
47
 
47
48
  const { mutate: createOrganization, isPending: isCreating } =
48
49
  useCreateOrganization(authClient as OrganizationAuthClient, {
@@ -58,12 +59,14 @@ export function CreateOrganizationDialog({
58
59
  if (!isOpen) {
59
60
  setSlug("")
60
61
  setName("")
62
+ setSlugEdited(false)
61
63
  }
62
64
  }, [isOpen])
63
65
 
64
66
  useEffect(() => {
67
+ if (slugEdited) return
65
68
  setSlug(sanitizeSlug(name))
66
- }, [name])
69
+ }, [name, slugEdited])
67
70
 
68
71
  return (
69
72
  <AlertDialog.Backdrop isOpen={isOpen} onOpenChange={onOpenChange}>
@@ -111,7 +114,10 @@ export function CreateOrganizationDialog({
111
114
 
112
115
  <SlugField
113
116
  value={slug}
114
- onChange={setSlug}
117
+ onChange={(value) => {
118
+ setSlug(value)
119
+ setSlugEdited(true)
120
+ }}
115
121
  isDisabled={isCreating}
116
122
  variant="secondary"
117
123
  />