@yhgale/ui 0.1.4 → 0.1.6

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.d.ts CHANGED
@@ -355,7 +355,7 @@ declare function SignOutButton({ afterSignOutUrl, children }: SignOutButtonProps
355
355
  /**
356
356
  * <UserProfile> — 用户资料管理页。
357
357
  * 对标 Clerk UserProfile: Account (Profile + Password + OAuth) / Security (Passkey + MFA + Devices + Delete)。
358
- * 所有 API 调用通过 useGaleContext().client.request(),复用 GaleProvider 的 FapiClient。
358
+ * API 调用复用 GaleProvider 的 FapiClient 与 gale-js actions。
359
359
  */
360
360
  interface UserProfileProps {
361
361
  className?: string;
package/dist/index.js CHANGED
@@ -5114,7 +5114,7 @@ function ForgotPassword({
5114
5114
  }) {
5115
5115
  const { t: t2 } = useLocalization7();
5116
5116
  const { passwordPolicy } = useEnvironment3();
5117
- const { status, sendResetCode, resetPassword } = useForgotPassword();
5117
+ const { status, sendResetCode, resetPassword: resetPassword2 } = useForgotPassword();
5118
5118
  const emailId = useId();
5119
5119
  const codeId = useId();
5120
5120
  const passwordId = useId();
@@ -5242,7 +5242,7 @@ function ForgotPassword({
5242
5242
  loadingText: t2("forgotPassword.resetting"),
5243
5243
  type: "button",
5244
5244
  onClick: async () => {
5245
- await resetPassword({ emailAddress, code, password: newPassword });
5245
+ await resetPassword2({ emailAddress, code, password: newPassword });
5246
5246
  },
5247
5247
  children: t2("forgotPassword.resetButton")
5248
5248
  }
@@ -5790,7 +5790,17 @@ function SignOutButton({ afterSignOutUrl = "/", children }) {
5790
5790
 
5791
5791
  // src/components/UserProfile.tsx
5792
5792
  import { useState as useState8, useEffect as useEffect7 } from "react";
5793
- import { getMe } from "@yhgale/gale-js";
5793
+ import QRCode from "qrcode";
5794
+ import {
5795
+ confirmTotp,
5796
+ disableTotp,
5797
+ enrollTotp,
5798
+ forgotPassword,
5799
+ generateBackupCodes,
5800
+ getMe,
5801
+ getMfaStatus,
5802
+ resetPassword
5803
+ } from "@yhgale/gale-js";
5794
5804
  import {
5795
5805
  useUser as useUser4,
5796
5806
  useSession as useSession3,
@@ -5801,13 +5811,6 @@ import {
5801
5811
  useLocalization as useLocalization12
5802
5812
  } from "@yhgale/gale-js/react";
5803
5813
  import { Fragment as Fragment5, jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
5804
- async function apiErr(r) {
5805
- try {
5806
- return await r;
5807
- } catch {
5808
- return null;
5809
- }
5810
- }
5811
5814
  function UserProfile({ className }) {
5812
5815
  const { user } = useUser4();
5813
5816
  const { t: t2 } = useLocalization12();
@@ -5847,7 +5850,7 @@ function AccountTab({
5847
5850
  return /* @__PURE__ */ jsxs6(Fragment5, { children: [
5848
5851
  /* @__PURE__ */ jsx10(Section, { title: t2("userProfile.sectionProfile"), children: /* @__PURE__ */ jsx10(ProfileForm, { user }) }),
5849
5852
  /* @__PURE__ */ jsx10(Section, { title: t2("userProfile.sectionEmailAddresses"), children: /* @__PURE__ */ jsx10(EmailAddressesSection, {}) }),
5850
- /* @__PURE__ */ jsx10(Section, { title: t2("userProfile.sectionPassword"), children: /* @__PURE__ */ jsx10(PasswordForm, {}) }),
5853
+ /* @__PURE__ */ jsx10(Section, { title: t2("userProfile.sectionPassword"), children: /* @__PURE__ */ jsx10(PasswordForm, { primaryEmail: user.primaryEmail }) }),
5851
5854
  /* @__PURE__ */ jsx10(Section, { title: t2("userProfile.sectionConnectedAccounts"), children: /* @__PURE__ */ jsx10(ConnectedAccountsSection, { identities }) })
5852
5855
  ] });
5853
5856
  }
@@ -5956,27 +5959,40 @@ var ProfileForm = ({ user }) => {
5956
5959
  ] })
5957
5960
  ] });
5958
5961
  };
5959
- var PasswordForm = () => {
5962
+ var PasswordForm = ({ primaryEmail }) => {
5960
5963
  const { t: t2 } = useLocalization12();
5961
5964
  const { client } = useGaleContext();
5962
5965
  const { passwordPolicy } = useEnvironment4();
5963
5966
  const [current, setCurrent] = useState8("");
5964
5967
  const [newPw, setNewPw] = useState8("");
5965
5968
  const [confirm2, setConfirm] = useState8("");
5969
+ const [resetMode, setResetMode] = useState8(false);
5970
+ const [resetCodeSent, setResetCodeSent] = useState8(false);
5971
+ const [resetCode, setResetCode] = useState8("");
5966
5972
  const [msg, setMsg] = useState8("");
5967
5973
  const [msgOk, setMsgOk] = useState8(false);
5968
5974
  const [saving, setSaving] = useState8(false);
5969
- const save = async () => {
5975
+ const clearFields = () => {
5976
+ setCurrent("");
5977
+ setNewPw("");
5978
+ setConfirm("");
5979
+ setResetCode("");
5980
+ };
5981
+ const validatePassword = () => {
5970
5982
  if (newPw !== confirm2) {
5971
5983
  setMsg(t2("userProfile.passwordMismatch"));
5972
5984
  setMsgOk(false);
5973
- return;
5985
+ return false;
5974
5986
  }
5975
5987
  if (newPw.length < passwordPolicy.minLength) {
5976
5988
  setMsg(t2("userProfile.passwordMinLength", { minLength: String(passwordPolicy.minLength) }));
5977
5989
  setMsgOk(false);
5978
- return;
5990
+ return false;
5979
5991
  }
5992
+ return true;
5993
+ };
5994
+ const save = async () => {
5995
+ if (!validatePassword()) return;
5980
5996
  setSaving(true);
5981
5997
  setMsg("");
5982
5998
  setMsgOk(false);
@@ -5985,9 +6001,65 @@ var PasswordForm = () => {
5985
6001
  method: "POST",
5986
6002
  json: { currentPassword: current, newPassword: newPw }
5987
6003
  });
5988
- setCurrent("");
5989
- setNewPw("");
5990
- setConfirm("");
6004
+ clearFields();
6005
+ setMsg(t2("userProfile.passwordChanged"));
6006
+ setMsgOk(true);
6007
+ } catch (e) {
6008
+ setMsg(e instanceof Error ? e.message : "Error");
6009
+ setMsgOk(false);
6010
+ } finally {
6011
+ setSaving(false);
6012
+ }
6013
+ };
6014
+ const startReset = () => {
6015
+ clearFields();
6016
+ setResetMode(true);
6017
+ setResetCodeSent(false);
6018
+ setMsg("");
6019
+ setMsgOk(false);
6020
+ };
6021
+ const cancelReset = () => {
6022
+ clearFields();
6023
+ setResetMode(false);
6024
+ setResetCodeSent(false);
6025
+ setMsg("");
6026
+ setMsgOk(false);
6027
+ };
6028
+ const sendResetCode = async () => {
6029
+ if (!primaryEmail) {
6030
+ setMsg(t2("userProfile.emailEmpty"));
6031
+ setMsgOk(false);
6032
+ return;
6033
+ }
6034
+ setSaving(true);
6035
+ setMsg("");
6036
+ setMsgOk(false);
6037
+ try {
6038
+ await forgotPassword(client, { email_address: primaryEmail });
6039
+ setResetCodeSent(true);
6040
+ setMsg(t2("userProfile.emailCodeSent"));
6041
+ setMsgOk(true);
6042
+ } catch (e) {
6043
+ setMsg(e instanceof Error ? e.message : "Error");
6044
+ setMsgOk(false);
6045
+ } finally {
6046
+ setSaving(false);
6047
+ }
6048
+ };
6049
+ const reset = async () => {
6050
+ if (!primaryEmail || !validatePassword()) return;
6051
+ setSaving(true);
6052
+ setMsg("");
6053
+ setMsgOk(false);
6054
+ try {
6055
+ await resetPassword(client, {
6056
+ email_address: primaryEmail,
6057
+ code: resetCode,
6058
+ password: newPw
6059
+ });
6060
+ clearFields();
6061
+ setResetMode(false);
6062
+ setResetCodeSent(false);
5991
6063
  setMsg(t2("userProfile.passwordChanged"));
5992
6064
  setMsgOk(true);
5993
6065
  } catch (e) {
@@ -5998,48 +6070,121 @@ var PasswordForm = () => {
5998
6070
  }
5999
6071
  };
6000
6072
  return /* @__PURE__ */ jsxs6("div", { className: "space-y-3", children: [
6001
- /* @__PURE__ */ jsx10(Field, { label: t2("userProfile.fieldCurrentPassword"), children: /* @__PURE__ */ jsx10(
6073
+ resetMode && /* @__PURE__ */ jsxs6("div", { className: "rounded-md bg-[var(--color-bg-muted)] px-3 py-2 text-xs text-[var(--color-fg-muted)]", children: [
6074
+ /* @__PURE__ */ jsx10("p", { children: t2("forgotPassword.instructions") }),
6075
+ /* @__PURE__ */ jsx10("p", { className: "mt-1 break-all font-medium text-[var(--color-fg)]", children: primaryEmail })
6076
+ ] }),
6077
+ !resetMode && /* @__PURE__ */ jsx10(Field, { label: t2("userProfile.fieldCurrentPassword"), children: /* @__PURE__ */ jsx10(
6002
6078
  "input",
6003
6079
  {
6004
6080
  type: "password",
6081
+ autoComplete: "current-password",
6005
6082
  value: current,
6006
6083
  onChange: (e) => setCurrent(e.target.value),
6007
6084
  className: inputCls
6008
6085
  }
6009
6086
  ) }),
6010
- /* @__PURE__ */ jsx10(Field, { label: t2("userProfile.fieldNewPassword"), children: /* @__PURE__ */ jsx10(
6011
- "input",
6012
- {
6013
- type: "password",
6014
- value: newPw,
6015
- onChange: (e) => setNewPw(e.target.value),
6016
- placeholder: t2("userProfile.placeholderNewPassword"),
6017
- minLength: passwordPolicy.minLength,
6018
- className: inputCls
6019
- }
6020
- ) }),
6021
- /* @__PURE__ */ jsx10(Field, { label: t2("userProfile.fieldConfirmPassword"), children: /* @__PURE__ */ jsx10(
6087
+ resetMode && resetCodeSent && /* @__PURE__ */ jsx10(Field, { label: t2("forgotPassword.codeLabel"), children: /* @__PURE__ */ jsx10(
6022
6088
  "input",
6023
6089
  {
6024
- type: "password",
6025
- value: confirm2,
6026
- onChange: (e) => setConfirm(e.target.value),
6090
+ type: "text",
6091
+ inputMode: "numeric",
6092
+ autoComplete: "one-time-code",
6093
+ value: resetCode,
6094
+ onChange: (e) => setResetCode(e.target.value.replace(/\D/g, "").slice(0, 6)),
6095
+ placeholder: "000000",
6096
+ maxLength: 6,
6027
6097
  className: inputCls
6028
6098
  }
6029
6099
  ) }),
6030
- /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-3", children: [
6031
- /* @__PURE__ */ jsx10(
6100
+ (!resetMode || resetCodeSent) && /* @__PURE__ */ jsxs6(Fragment5, { children: [
6101
+ /* @__PURE__ */ jsx10(Field, { label: t2("userProfile.fieldNewPassword"), children: /* @__PURE__ */ jsx10(
6102
+ "input",
6103
+ {
6104
+ type: "password",
6105
+ autoComplete: "new-password",
6106
+ value: newPw,
6107
+ onChange: (e) => setNewPw(e.target.value),
6108
+ placeholder: t2("userProfile.placeholderNewPassword"),
6109
+ minLength: passwordPolicy.minLength,
6110
+ className: inputCls
6111
+ }
6112
+ ) }),
6113
+ /* @__PURE__ */ jsx10(Field, { label: t2("userProfile.fieldConfirmPassword"), children: /* @__PURE__ */ jsx10(
6114
+ "input",
6115
+ {
6116
+ type: "password",
6117
+ autoComplete: "new-password",
6118
+ value: confirm2,
6119
+ onChange: (e) => setConfirm(e.target.value),
6120
+ className: inputCls
6121
+ }
6122
+ ) })
6123
+ ] }),
6124
+ /* @__PURE__ */ jsxs6("div", { className: "flex flex-wrap items-center gap-3", children: [
6125
+ !resetMode ? /* @__PURE__ */ jsxs6(Fragment5, { children: [
6126
+ /* @__PURE__ */ jsx10(
6127
+ "button",
6128
+ {
6129
+ type: "button",
6130
+ onClick: save,
6131
+ disabled: saving || !current || !newPw || !confirm2,
6132
+ className: "rounded-md bg-[var(--color-accent)] px-3 py-1.5 text-xs font-medium text-white hover:bg-[var(--color-accent-hover)] disabled:opacity-50",
6133
+ children: saving ? t2("userProfile.buttonChanging") : t2("userProfile.buttonChangePassword")
6134
+ }
6135
+ ),
6136
+ primaryEmail && /* @__PURE__ */ jsx10(
6137
+ "button",
6138
+ {
6139
+ type: "button",
6140
+ onClick: startReset,
6141
+ className: "text-xs text-[var(--color-link)] hover:underline",
6142
+ children: t2("signIn.forgotPassword")
6143
+ }
6144
+ )
6145
+ ] }) : !resetCodeSent ? /* @__PURE__ */ jsx10(
6032
6146
  "button",
6033
6147
  {
6034
6148
  type: "button",
6035
- onClick: save,
6036
- disabled: saving || !current || !newPw,
6149
+ onClick: sendResetCode,
6150
+ disabled: saving,
6037
6151
  className: "rounded-md bg-[var(--color-accent)] px-3 py-1.5 text-xs font-medium text-white hover:bg-[var(--color-accent-hover)] disabled:opacity-50",
6038
- children: saving ? t2("userProfile.buttonChanging") : t2("userProfile.buttonChangePassword")
6152
+ children: saving ? t2("forgotPassword.sending") : t2("forgotPassword.sendButton")
6039
6153
  }
6040
- ),
6041
- msg && /* @__PURE__ */ jsx10("span", { className: `text-xs ${msgOk ? "text-emerald-600" : "text-red-600"}`, children: msg })
6042
- ] })
6154
+ ) : /* @__PURE__ */ jsxs6(Fragment5, { children: [
6155
+ /* @__PURE__ */ jsx10(
6156
+ "button",
6157
+ {
6158
+ type: "button",
6159
+ onClick: reset,
6160
+ disabled: saving || resetCode.length !== 6 || !newPw || !confirm2,
6161
+ className: "rounded-md bg-[var(--color-accent)] px-3 py-1.5 text-xs font-medium text-white hover:bg-[var(--color-accent-hover)] disabled:opacity-50",
6162
+ children: saving ? t2("forgotPassword.resetting") : t2("forgotPassword.resetButton")
6163
+ }
6164
+ ),
6165
+ /* @__PURE__ */ jsx10(
6166
+ "button",
6167
+ {
6168
+ type: "button",
6169
+ onClick: sendResetCode,
6170
+ disabled: saving,
6171
+ className: "text-xs text-[var(--color-link)] hover:underline disabled:opacity-50",
6172
+ children: t2("forgotPassword.resendCode")
6173
+ }
6174
+ )
6175
+ ] }),
6176
+ resetMode && /* @__PURE__ */ jsx10(
6177
+ "button",
6178
+ {
6179
+ type: "button",
6180
+ onClick: cancelReset,
6181
+ disabled: saving,
6182
+ className: "text-xs text-[var(--color-fg-muted)] hover:underline disabled:opacity-50",
6183
+ children: t2("common.cancel")
6184
+ }
6185
+ )
6186
+ ] }),
6187
+ msg && /* @__PURE__ */ jsx10("p", { className: `text-xs ${msgOk ? "text-emerald-600" : "text-red-600"}`, children: msg })
6043
6188
  ] });
6044
6189
  };
6045
6190
  var MfaSection = () => {
@@ -6050,50 +6195,94 @@ var MfaSection = () => {
6050
6195
  const [totpStep, setTotpStep] = useState8("");
6051
6196
  const [secret, setSecret] = useState8("");
6052
6197
  const [uri, setUri] = useState8("");
6198
+ const [qrDataUrl, setQrDataUrl] = useState8("");
6053
6199
  const [code, setCode] = useState8("");
6054
6200
  const [msg, setMsg] = useState8("");
6055
6201
  const [backupCodes, setBackupCodes] = useState8(null);
6056
6202
  const fetchStatus = async () => {
6057
6203
  setLoading(true);
6058
- const r = await apiErr(client.request("/v1/me/mfa"));
6059
- if (r) setStatus(r);
6060
- setLoading(false);
6204
+ try {
6205
+ setStatus(await getMfaStatus(client));
6206
+ } catch (e) {
6207
+ setMsg(e instanceof Error ? e.message : t2("userProfile.totpEnrollFailed"));
6208
+ } finally {
6209
+ setLoading(false);
6210
+ }
6061
6211
  };
6062
6212
  useEffect7(() => {
6063
6213
  fetchStatus();
6064
6214
  }, []);
6215
+ useEffect7(() => {
6216
+ if (!uri) {
6217
+ setQrDataUrl("");
6218
+ return;
6219
+ }
6220
+ let cancelled = false;
6221
+ QRCode.toDataURL(uri, { width: 192, margin: 1 }).then((dataUrl) => {
6222
+ if (!cancelled) setQrDataUrl(dataUrl);
6223
+ }).catch((e) => {
6224
+ if (!cancelled) setMsg(e instanceof Error ? e.message : "Error");
6225
+ });
6226
+ return () => {
6227
+ cancelled = true;
6228
+ };
6229
+ }, [uri]);
6065
6230
  const enroll = async () => {
6066
- const r = await apiErr(client.request("/v1/me/totp/enroll", { method: "POST", json: {} }));
6067
- if (r) {
6231
+ setMsg("");
6232
+ setCode("");
6233
+ setQrDataUrl("");
6234
+ try {
6235
+ const r = await enrollTotp(client);
6068
6236
  setSecret(r.secretBase32);
6069
6237
  setUri(r.otpauthUri);
6070
6238
  setTotpStep("confirm");
6071
- } else setMsg(t2("userProfile.totpEnrollFailed"));
6239
+ } catch (e) {
6240
+ setMsg(e instanceof Error ? e.message : t2("userProfile.totpEnrollFailed"));
6241
+ }
6072
6242
  };
6073
6243
  const confirm2 = async () => {
6074
- const r = await apiErr(
6075
- client.request("/v1/me/totp/confirm", { method: "POST", json: { code } })
6076
- );
6077
- if (r) {
6244
+ if (!/^\d{6}$/.test(code)) {
6245
+ setMsg(t2("userProfile.totpInvalidCode"));
6246
+ return;
6247
+ }
6248
+ setMsg("");
6249
+ try {
6250
+ await confirmTotp(client, { code });
6078
6251
  setTotpStep("");
6252
+ setUri("");
6253
+ setSecret("");
6079
6254
  setCode("");
6080
- fetchStatus();
6255
+ await fetchStatus();
6081
6256
  setMsg(t2("userProfile.totpEnabledMsg"));
6082
- } else setMsg(t2("userProfile.totpInvalidCode"));
6257
+ } catch (e) {
6258
+ setMsg(e instanceof Error ? e.message : t2("userProfile.totpInvalidCode"));
6259
+ }
6260
+ };
6261
+ const cancelEnroll = () => {
6262
+ setTotpStep("");
6263
+ setUri("");
6264
+ setSecret("");
6265
+ setCode("");
6266
+ setMsg("");
6083
6267
  };
6084
6268
  const disable = async () => {
6085
- const r = await apiErr(client.request("/v1/me/totp", { method: "DELETE" }));
6086
- if (r) {
6087
- fetchStatus();
6269
+ setMsg("");
6270
+ try {
6271
+ await disableTotp(client);
6272
+ await fetchStatus();
6088
6273
  setMsg(t2("userProfile.totpDisabled"));
6089
- } else setMsg(t2("userProfile.totpDisableFailed"));
6274
+ } catch (e) {
6275
+ setMsg(e instanceof Error ? e.message : t2("userProfile.totpDisableFailed"));
6276
+ }
6090
6277
  };
6091
6278
  const genBackup = async () => {
6092
- const r = await apiErr(client.request("/v1/me/backup_codes/generate", { method: "POST" }));
6093
- if (r) {
6094
- const b = r;
6095
- setBackupCodes(b.codes || b.data?.codes || null);
6096
- fetchStatus();
6279
+ setMsg("");
6280
+ try {
6281
+ const r = await generateBackupCodes(client);
6282
+ setBackupCodes(r.codes);
6283
+ await fetchStatus();
6284
+ } catch (e) {
6285
+ setMsg(e instanceof Error ? e.message : t2("userProfile.totpEnrollFailed"));
6097
6286
  }
6098
6287
  };
6099
6288
  if (loading) return /* @__PURE__ */ jsx10("p", { className: "text-xs text-[var(--color-fg-muted)]", children: t2("common.loading") });
@@ -6105,15 +6294,42 @@ var MfaSection = () => {
6105
6294
  /* @__PURE__ */ jsx10("p", { className: "text-sm font-medium text-[var(--color-fg)]", children: t2("userProfile.totpTitle") }),
6106
6295
  /* @__PURE__ */ jsx10("p", { className: "text-xs text-[var(--color-fg-muted)]", children: totp?.enrolled ? t2("userProfile.totpEnabled") : t2("userProfile.totpNotSetUp") })
6107
6296
  ] }),
6108
- totp?.enrolled ? /* @__PURE__ */ jsx10("button", { type: "button", onClick: disable, className: "text-xs text-red-600 hover:underline", children: t2("common.remove") }) : totpStep === "confirm" ? /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2", children: [
6297
+ totp?.enrolled ? /* @__PURE__ */ jsx10("button", { type: "button", onClick: disable, className: "text-xs text-red-600 hover:underline", children: t2("common.remove") }) : totpStep !== "confirm" ? /* @__PURE__ */ jsx10(
6298
+ "button",
6299
+ {
6300
+ type: "button",
6301
+ onClick: enroll,
6302
+ className: "text-xs text-[var(--color-accent)] hover:underline",
6303
+ children: t2("common.add")
6304
+ }
6305
+ ) : null
6306
+ ] }),
6307
+ totpStep === "confirm" && uri && /* @__PURE__ */ jsxs6("div", { className: "space-y-4 rounded border border-[var(--color-border)] bg-[var(--color-bg-muted)] p-4", children: [
6308
+ /* @__PURE__ */ jsx10("p", { className: "text-xs text-[var(--color-fg-muted)]", children: t2("userProfile.totpQrHint") }),
6309
+ /* @__PURE__ */ jsxs6("div", { className: "flex flex-wrap items-center gap-4", children: [
6310
+ qrDataUrl ? /* @__PURE__ */ jsx10(
6311
+ "img",
6312
+ {
6313
+ src: qrDataUrl,
6314
+ alt: t2("userProfile.totpTitle"),
6315
+ width: 192,
6316
+ height: 192,
6317
+ className: "h-48 w-48 shrink-0 rounded bg-white p-2"
6318
+ }
6319
+ ) : /* @__PURE__ */ jsx10("div", { className: "flex h-48 w-48 items-center justify-center bg-white text-xs text-[var(--color-fg-muted)]", children: t2("common.loading") }),
6320
+ /* @__PURE__ */ jsx10("p", { className: "min-w-0 flex-1 break-all font-mono text-sm text-[var(--color-fg)]", children: secret })
6321
+ ] }),
6322
+ /* @__PURE__ */ jsxs6("div", { className: "flex flex-wrap items-center gap-2", children: [
6109
6323
  /* @__PURE__ */ jsx10(
6110
6324
  "input",
6111
6325
  {
6112
6326
  value: code,
6113
- onChange: (e) => setCode(e.target.value),
6327
+ onChange: (e) => setCode(e.target.value.replace(/\D/g, "").slice(0, 6)),
6114
6328
  placeholder: "000000",
6329
+ inputMode: "numeric",
6330
+ autoComplete: "one-time-code",
6115
6331
  maxLength: 6,
6116
- className: `${inputCls} w-20 text-center`
6332
+ className: `${inputCls} w-24 text-center`
6117
6333
  }
6118
6334
  ),
6119
6335
  /* @__PURE__ */ jsx10(
@@ -6121,7 +6337,8 @@ var MfaSection = () => {
6121
6337
  {
6122
6338
  type: "button",
6123
6339
  onClick: confirm2,
6124
- className: "rounded-md bg-[var(--color-accent)] px-2 py-1 text-xs font-medium text-white",
6340
+ disabled: code.length !== 6,
6341
+ className: "rounded-md bg-[var(--color-accent)] px-3 py-1.5 text-xs font-medium text-white hover:bg-[var(--color-accent-hover)] disabled:opacity-50",
6125
6342
  children: t2("common.verify")
6126
6343
  }
6127
6344
  ),
@@ -6129,24 +6346,12 @@ var MfaSection = () => {
6129
6346
  "button",
6130
6347
  {
6131
6348
  type: "button",
6132
- onClick: () => setTotpStep(""),
6133
- className: "text-xs text-[var(--color-fg-muted)]",
6349
+ onClick: cancelEnroll,
6350
+ className: "text-xs text-[var(--color-fg-muted)] hover:underline",
6134
6351
  children: t2("common.cancel")
6135
6352
  }
6136
6353
  )
6137
- ] }) : /* @__PURE__ */ jsx10(
6138
- "button",
6139
- {
6140
- type: "button",
6141
- onClick: enroll,
6142
- className: "text-xs text-[var(--color-accent)] hover:underline",
6143
- children: t2("common.add")
6144
- }
6145
- )
6146
- ] }),
6147
- totpStep === "confirm" && uri && /* @__PURE__ */ jsxs6("div", { className: "rounded border border-[var(--color-border)] bg-[var(--color-bg-muted)] p-3", children: [
6148
- /* @__PURE__ */ jsx10("p", { className: "text-xs text-[var(--color-fg-muted)] mb-2", children: t2("userProfile.totpQrHint") }),
6149
- /* @__PURE__ */ jsx10("p", { className: "font-mono text-xs break-all text-[var(--color-fg)]", children: secret })
6354
+ ] })
6150
6355
  ] }),
6151
6356
  /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between border-t border-[var(--color-border)] pt-3", children: [
6152
6357
  /* @__PURE__ */ jsxs6("div", { children: [
@@ -6188,7 +6393,7 @@ var ActiveDevicesSection = () => {
6188
6393
  {
6189
6394
  className: "flex items-center justify-between rounded border border-[var(--color-border)] bg-[var(--color-bg)] px-3 py-2",
6190
6395
  children: /* @__PURE__ */ jsxs6("div", { children: [
6191
- /* @__PURE__ */ jsx10("p", { className: "text-sm text-[var(--color-fg)]", children: t2("userProfile.sessionLabel", { id: d.id.slice(0, 8) }) }),
6396
+ /* @__PURE__ */ jsx10("p", { className: "break-all font-mono text-sm text-[var(--color-fg)]", children: t2("userProfile.sessionLabel", { id: d.id }) }),
6192
6397
  /* @__PURE__ */ jsxs6("p", { className: "text-[11px] text-[var(--color-fg-muted)]", children: [
6193
6398
  new Date(d.lastActiveAt ?? d.createdAt).toLocaleString(),
6194
6399
  d.id === session?.id && /* @__PURE__ */ jsx10("span", { className: "ml-2 text-xs text-[var(--color-accent)] font-medium", children: t2("common.current") })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yhgale/ui",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Headless UI components for gale (SignIn, UserButton, OrganizationSwitcher)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -24,10 +24,12 @@
24
24
  "dependencies": {
25
25
  "@emotion/cache": "^11.14.0",
26
26
  "@emotion/react": "^11.14.0",
27
- "@yhgale/gale-js": "^0.1.9"
27
+ "qrcode": "^1.5.4",
28
+ "@yhgale/gale-js": "^0.1.10"
28
29
  },
29
30
  "devDependencies": {
30
31
  "@types/node": "^22.10.2",
32
+ "@types/qrcode": "^1.5.5",
31
33
  "@types/react": "^19.0.2",
32
34
  "react": "^19.0.0",
33
35
  "tsup": "^8.5.1",