@loafmarkets/ui 0.1.363 → 0.1.365

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.mts CHANGED
@@ -524,7 +524,7 @@ type DemoLoginResult = {
524
524
  success: boolean;
525
525
  };
526
526
  type DemoLoginHandler = (email: string, handle?: string | null) => Promise<DemoLoginResult | void> | DemoLoginResult | void;
527
- type LoginPopupView = "main" | "email" | "otp" | "kyc" | "kyc-success" | "kyc-failed" | "funding" | "receive" | "referral";
527
+ type LoginPopupView = "main" | "email" | "otp" | "kyc" | "kyc-success" | "kyc-failed" | "funding" | "receive" | "referral" | "wallet-handle";
528
528
  type FundWalletParams = {
529
529
  amount: string;
530
530
  mode?: "crypto" | "fiat";
@@ -586,8 +586,18 @@ type LoginPopupProps = {
586
586
  onSubmitReferralCode?: (code: string) => Promise<void> | void;
587
587
  /** Called when the user skips the referral code and joins the waitlist. Receives their signup email. Resolves to a success message. */
588
588
  onJoinWaitlist?: (email: string) => Promise<string> | void;
589
- /** Handler invoked when the user selects "Sign in with Wallet". */
590
- onWalletLogin?: () => Promise<void> | void;
589
+ /**
590
+ * Handler invoked when the user selects "Sign in with Wallet". Returns
591
+ * `{ needsHandle: true }` when the connected account has no handle yet, so the
592
+ * popup collects one (mirroring the email signup flow) instead of closing.
593
+ */
594
+ onWalletLogin?: () => Promise<{
595
+ needsHandle: boolean;
596
+ } | void> | {
597
+ needsHandle: boolean;
598
+ } | void;
599
+ /** Handler invoked when a new wallet user submits their chosen handle. */
600
+ onWalletSignup?: (handle: string) => Promise<void> | void;
591
601
  /** Handler invoked when the user selects "Sign in with Passkey". When omitted, the button is hidden. */
592
602
  onPasskeyLogin?: () => Promise<void> | void;
593
603
  /** Current KYC status — used to show "Resume Verification" when previously started. */
package/dist/index.d.ts CHANGED
@@ -524,7 +524,7 @@ type DemoLoginResult = {
524
524
  success: boolean;
525
525
  };
526
526
  type DemoLoginHandler = (email: string, handle?: string | null) => Promise<DemoLoginResult | void> | DemoLoginResult | void;
527
- type LoginPopupView = "main" | "email" | "otp" | "kyc" | "kyc-success" | "kyc-failed" | "funding" | "receive" | "referral";
527
+ type LoginPopupView = "main" | "email" | "otp" | "kyc" | "kyc-success" | "kyc-failed" | "funding" | "receive" | "referral" | "wallet-handle";
528
528
  type FundWalletParams = {
529
529
  amount: string;
530
530
  mode?: "crypto" | "fiat";
@@ -586,8 +586,18 @@ type LoginPopupProps = {
586
586
  onSubmitReferralCode?: (code: string) => Promise<void> | void;
587
587
  /** Called when the user skips the referral code and joins the waitlist. Receives their signup email. Resolves to a success message. */
588
588
  onJoinWaitlist?: (email: string) => Promise<string> | void;
589
- /** Handler invoked when the user selects "Sign in with Wallet". */
590
- onWalletLogin?: () => Promise<void> | void;
589
+ /**
590
+ * Handler invoked when the user selects "Sign in with Wallet". Returns
591
+ * `{ needsHandle: true }` when the connected account has no handle yet, so the
592
+ * popup collects one (mirroring the email signup flow) instead of closing.
593
+ */
594
+ onWalletLogin?: () => Promise<{
595
+ needsHandle: boolean;
596
+ } | void> | {
597
+ needsHandle: boolean;
598
+ } | void;
599
+ /** Handler invoked when a new wallet user submits their chosen handle. */
600
+ onWalletSignup?: (handle: string) => Promise<void> | void;
591
601
  /** Handler invoked when the user selects "Sign in with Passkey". When omitted, the button is hidden. */
592
602
  onPasskeyLogin?: () => Promise<void> | void;
593
603
  /** Current KYC status — used to show "Resume Verification" when previously started. */
package/dist/index.js CHANGED
@@ -6465,6 +6465,7 @@ var LoginPopup = ({
6465
6465
  onClose,
6466
6466
  onOpenEarlyAccess,
6467
6467
  onWalletLogin,
6468
+ onWalletSignup,
6468
6469
  onPasskeyLogin,
6469
6470
  isAuthenticated,
6470
6471
  currentUser,
@@ -6550,7 +6551,7 @@ var LoginPopup = ({
6550
6551
  if (suppressAutoCloseRef.current) {
6551
6552
  return;
6552
6553
  }
6553
- if (view === "kyc" || view === "kyc-success" || view === "kyc-failed" || view === "funding" || view === "receive" || view === "referral") {
6554
+ if (view === "kyc" || view === "kyc-success" || view === "kyc-failed" || view === "funding" || view === "receive" || view === "referral" || view === "wallet-handle") {
6554
6555
  return;
6555
6556
  }
6556
6557
  if (isAuthenticated || currentUser) {
@@ -6566,12 +6567,21 @@ var LoginPopup = ({
6566
6567
  }, [onClose]);
6567
6568
  const handleWalletLogin = async () => {
6568
6569
  if (onWalletLogin) {
6570
+ suppressAutoCloseRef.current = true;
6569
6571
  try {
6570
- await onWalletLogin();
6572
+ const result = await onWalletLogin();
6573
+ if (result && result.needsHandle && onWalletSignup) {
6574
+ setHandle("");
6575
+ setError("");
6576
+ setView("wallet-handle");
6577
+ return;
6578
+ }
6579
+ suppressAutoCloseRef.current = false;
6571
6580
  onClose();
6572
6581
  return;
6573
6582
  } catch (err) {
6574
6583
  console.error("[LoginTrace][Popup] Wallet login failed", err);
6584
+ suppressAutoCloseRef.current = false;
6575
6585
  }
6576
6586
  }
6577
6587
  onClose();
@@ -6579,6 +6589,31 @@ var LoginPopup = ({
6579
6589
  onOpenEarlyAccess();
6580
6590
  }
6581
6591
  };
6592
+ const handleWalletSignupSubmit = async (event) => {
6593
+ event?.preventDefault();
6594
+ if (!handle.trim()) {
6595
+ setError("Please claim a handle to continue");
6596
+ return;
6597
+ }
6598
+ if (!onWalletSignup) {
6599
+ onClose();
6600
+ return;
6601
+ }
6602
+ setLoading(true);
6603
+ setError("");
6604
+ try {
6605
+ await onWalletSignup(handle.trim());
6606
+ if (onSubmitReferralCode) {
6607
+ setView("referral");
6608
+ } else {
6609
+ onClose();
6610
+ }
6611
+ } catch (err) {
6612
+ setError(err instanceof Error ? err.message : "Couldn't complete sign up. Please try again.");
6613
+ } finally {
6614
+ setLoading(false);
6615
+ }
6616
+ };
6582
6617
  const handlePasskeyLogin = async () => {
6583
6618
  if (!onPasskeyLogin) return;
6584
6619
  setError("");
@@ -6905,6 +6940,31 @@ var LoginPopup = ({
6905
6940
  isSignUp && /* @__PURE__ */ jsxRuntime.jsx(MiniLiveFeed, {})
6906
6941
  ] }) });
6907
6942
  }
6943
+ if (view === "wallet-handle") {
6944
+ return /* @__PURE__ */ jsxRuntime.jsx(Overlay2, { onClick: loading ? void 0 : onClose, children: /* @__PURE__ */ jsxRuntime.jsxs(PopupContainer, { onClick: (event) => event.stopPropagation(), children: [
6945
+ !loading && /* @__PURE__ */ jsxRuntime.jsx(CloseButton, { onClick: onClose, "aria-label": "Close login popup", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) }) }),
6946
+ /* @__PURE__ */ jsxRuntime.jsxs(Title, { children: [
6947
+ /* @__PURE__ */ jsxRuntime.jsx(LogoContainer3, { children: /* @__PURE__ */ jsxRuntime.jsx(LogoImage, { src: logoSrc, alt: logoAlt }) }),
6948
+ "Claim your handle"
6949
+ ] }),
6950
+ /* @__PURE__ */ jsxRuntime.jsx("form", { onSubmit: handleWalletSignupSubmit, children: /* @__PURE__ */ jsxRuntime.jsxs(EmailFormContainer, { children: [
6951
+ /* @__PURE__ */ jsxRuntime.jsx(
6952
+ EmailInput,
6953
+ {
6954
+ type: "text",
6955
+ placeholder: "Claim your handle (e.g. Landlord)",
6956
+ value: handle,
6957
+ onChange: (event) => setHandle(event.target.value),
6958
+ autoFocus: true
6959
+ }
6960
+ ),
6961
+ /* @__PURE__ */ jsxRuntime.jsx(SubmitButton, { type: "submit", disabled: loading || !handle.trim(), children: loading ? "Setting up your account\u2026" : "Continue" }),
6962
+ error && /* @__PURE__ */ jsxRuntime.jsx(StatusMessage, { $error: true, children: error })
6963
+ ] }) }),
6964
+ /* @__PURE__ */ jsxRuntime.jsx(InfoText, { children: "Pick a public handle for your Loaf profile." }),
6965
+ /* @__PURE__ */ jsxRuntime.jsx(MiniLiveFeed, {})
6966
+ ] }) });
6967
+ }
6908
6968
  if (view === "otp") {
6909
6969
  return /* @__PURE__ */ jsxRuntime.jsx(Overlay2, { onClick: loading ? void 0 : onClose, children: /* @__PURE__ */ jsxRuntime.jsxs(PopupContainer, { onClick: (event) => event.stopPropagation(), children: [
6910
6970
  !loading && /* @__PURE__ */ jsxRuntime.jsx(CloseButton, { onClick: onClose, "aria-label": "Close login popup", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) }) }),
@@ -7123,7 +7183,7 @@ var LoginPopup = ({
7123
7183
  }
7124
7184
  };
7125
7185
  const handleJoinWaitlistSkip = async () => {
7126
- if (!onJoinWaitlist) {
7186
+ if (!onJoinWaitlist || !email) {
7127
7187
  onClose();
7128
7188
  return;
7129
7189
  }
@@ -7197,7 +7257,7 @@ var LoginPopup = ({
7197
7257
  onClick: () => void handleJoinWaitlistSkip(),
7198
7258
  disabled: waitlistLoading,
7199
7259
  style: { marginTop: "0.75rem" },
7200
- children: waitlistLoading ? "Joining\u2026" : "Skip for now & join Waitlist"
7260
+ children: waitlistLoading ? "Joining\u2026" : email ? "Skip for now & join Waitlist" : "Skip for now"
7201
7261
  }
7202
7262
  )
7203
7263
  ] })