@loafmarkets/ui 0.1.347 → 0.1.349

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.mjs CHANGED
@@ -6431,13 +6431,19 @@ var LoginPopup = ({
6431
6431
  renderKycWidget,
6432
6432
  onFundWallet,
6433
6433
  initialView,
6434
- kycStatus: kycStatusProp
6434
+ kycStatus: kycStatusProp,
6435
+ walletAddress,
6436
+ onSubmitReferralCode
6435
6437
  }) => {
6436
6438
  const [view, setView] = useState(() => initialView ?? "main");
6437
6439
  const [email, setEmail] = useState("");
6438
6440
  const [handle, setHandle] = useState("");
6439
6441
  const [otp, setOtp] = useState(Array(OTP_INPUT_LENGTH).fill(""));
6440
6442
  const [error, setError] = useState("");
6443
+ const [copied, setCopied] = useState(false);
6444
+ const [referralCode, setReferralCode] = useState("");
6445
+ const [referralLoading, setReferralLoading] = useState(false);
6446
+ const [referralError, setReferralError] = useState("");
6441
6447
  const [loading, setLoading] = useState(false);
6442
6448
  const [isSignUp, setIsSignUp] = useState(false);
6443
6449
  const [fundingAmount] = useState("");
@@ -6494,7 +6500,7 @@ var LoginPopup = ({
6494
6500
  if (suppressAutoCloseRef.current) {
6495
6501
  return;
6496
6502
  }
6497
- if (view === "kyc" || view === "kyc-success" || view === "kyc-failed" || view === "funding") {
6503
+ if (view === "kyc" || view === "kyc-success" || view === "kyc-failed" || view === "funding" || view === "receive" || view === "referral") {
6498
6504
  return;
6499
6505
  }
6500
6506
  if (isAuthenticated || currentUser) {
@@ -6657,7 +6663,7 @@ var LoginPopup = ({
6657
6663
  try {
6658
6664
  await onVerifyEmailCode({ code, email });
6659
6665
  if (isSignUp) {
6660
- setView("funding");
6666
+ setView(onSubmitReferralCode ? "referral" : "funding");
6661
6667
  setLoading(false);
6662
6668
  return;
6663
6669
  }
@@ -7020,7 +7026,13 @@ var LoginPopup = ({
7020
7026
  /* @__PURE__ */ jsx(OnboardingHeading, { style: { textAlign: "center" }, children: "Deposit Funds" }),
7021
7027
  /* @__PURE__ */ jsx(OnboardingSubtext, { style: { textAlign: "center", marginBottom: "1rem" }, children: "Choose how you'd like to fund your account." }),
7022
7028
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: [
7023
- /* @__PURE__ */ jsxs(ModalOptionCard, { onClick: handleCryptoFund, disabled: cryptoFundingLoading, children: [
7029
+ /* @__PURE__ */ jsxs(ModalOptionCard, { onClick: () => {
7030
+ if (walletAddress) {
7031
+ setView("receive");
7032
+ } else {
7033
+ void handleCryptoFund();
7034
+ }
7035
+ }, disabled: cryptoFundingLoading, children: [
7024
7036
  /* @__PURE__ */ jsxs("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", style: { color: "rgba(255,255,255,0.6)", flexShrink: 0 }, children: [
7025
7037
  /* @__PURE__ */ jsx("rect", { x: "2", y: "6", width: "20", height: "12", rx: "2" }),
7026
7038
  /* @__PURE__ */ jsx("path", { d: "M22 10H18a2 2 0 0 0 0 4h4" })
@@ -7052,6 +7064,193 @@ var LoginPopup = ({
7052
7064
  }
7053
7065
  ) });
7054
7066
  }
7067
+ if (view === "referral") {
7068
+ const handleReferralSubmit = async () => {
7069
+ const trimmed = referralCode.trim();
7070
+ if (!trimmed) {
7071
+ setReferralError("Please enter a referral code");
7072
+ return;
7073
+ }
7074
+ setReferralError("");
7075
+ setReferralLoading(true);
7076
+ try {
7077
+ await onSubmitReferralCode?.(trimmed);
7078
+ setView("funding");
7079
+ } catch (err) {
7080
+ setReferralError(err instanceof Error ? err.message : "Invalid referral code. Please try again.");
7081
+ } finally {
7082
+ setReferralLoading(false);
7083
+ }
7084
+ };
7085
+ return /* @__PURE__ */ jsx(Overlay2, { onClick: onClose, children: /* @__PURE__ */ jsxs(PopupContainer, { onClick: (event) => event.stopPropagation(), children: [
7086
+ /* @__PURE__ */ jsx(CloseButton, { onClick: onClose, "aria-label": "Close login popup", children: /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ 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" }) }) }),
7087
+ /* @__PURE__ */ jsxs(OnboardingStepContainer, { children: [
7088
+ /* @__PURE__ */ jsx("div", { style: {
7089
+ width: 52,
7090
+ height: 52,
7091
+ borderRadius: 14,
7092
+ background: "linear-gradient(135deg, rgba(230,200,126,0.15) 0%, rgba(230,200,126,0.08) 100%)",
7093
+ border: "1px solid rgba(230,200,126,0.25)",
7094
+ display: "flex",
7095
+ alignItems: "center",
7096
+ justifyContent: "center",
7097
+ marginBottom: "1.1rem"
7098
+ }, children: /* @__PURE__ */ jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "#e6c87e", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", children: [
7099
+ /* @__PURE__ */ jsx("path", { d: "M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" }),
7100
+ /* @__PURE__ */ jsx("circle", { cx: "9", cy: "7", r: "4" }),
7101
+ /* @__PURE__ */ jsx("path", { d: "M23 21v-2a4 4 0 0 0-3-3.87" }),
7102
+ /* @__PURE__ */ jsx("path", { d: "M16 3.13a4 4 0 0 1 0 7.75" })
7103
+ ] }) }),
7104
+ /* @__PURE__ */ jsx(OnboardingHeading, { children: "Do you have a referral code?" }),
7105
+ /* @__PURE__ */ jsx(OnboardingSubtext, { style: { marginBottom: "1.5rem" }, children: "Enter your code to unlock full access, or skip to continue." }),
7106
+ /* @__PURE__ */ jsxs(EmailFormContainer, { style: { width: "100%", marginBottom: 0 }, children: [
7107
+ /* @__PURE__ */ jsx(
7108
+ EmailInput,
7109
+ {
7110
+ type: "text",
7111
+ placeholder: "e.g. LOAF-XXXX",
7112
+ value: referralCode,
7113
+ onChange: (e) => {
7114
+ setReferralCode(e.target.value.toUpperCase());
7115
+ setReferralError("");
7116
+ },
7117
+ onKeyDown: (e) => {
7118
+ if (e.key === "Enter") void handleReferralSubmit();
7119
+ },
7120
+ autoFocus: true
7121
+ }
7122
+ ),
7123
+ /* @__PURE__ */ jsx(
7124
+ SubmitButton,
7125
+ {
7126
+ type: "button",
7127
+ onClick: () => void handleReferralSubmit(),
7128
+ disabled: referralLoading || !referralCode.trim(),
7129
+ children: referralLoading ? "Verifying\u2026" : "Apply Code"
7130
+ }
7131
+ ),
7132
+ referralError && /* @__PURE__ */ jsx(StatusMessage, { $error: true, children: referralError })
7133
+ ] }),
7134
+ /* @__PURE__ */ jsx(
7135
+ OnboardingSkipButton,
7136
+ {
7137
+ type: "button",
7138
+ onClick: () => setView("funding"),
7139
+ style: { marginTop: "0.75rem" },
7140
+ children: "Skip for now"
7141
+ }
7142
+ )
7143
+ ] })
7144
+ ] }) });
7145
+ }
7146
+ if (view === "receive") {
7147
+ const handleCopy = () => {
7148
+ if (walletAddress) {
7149
+ navigator.clipboard.writeText(walletAddress).then(() => {
7150
+ setCopied(true);
7151
+ setTimeout(() => setCopied(false), 2e3);
7152
+ }).catch(() => {
7153
+ });
7154
+ }
7155
+ };
7156
+ return /* @__PURE__ */ jsx(Overlay2, { onClick: onClose, children: /* @__PURE__ */ jsxs(PopupContainer, { onClick: (event) => event.stopPropagation(), children: [
7157
+ /* @__PURE__ */ jsx(CloseButton, { onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ 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" }) }) }),
7158
+ /* @__PURE__ */ jsxs(BackButton, { onClick: () => setView("funding"), children: [
7159
+ /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" }) }),
7160
+ "Back"
7161
+ ] }),
7162
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", paddingTop: "0.5rem" }, children: [
7163
+ /* @__PURE__ */ jsx("div", { style: {
7164
+ width: 52,
7165
+ height: 52,
7166
+ borderRadius: 14,
7167
+ background: "linear-gradient(135deg, rgba(230,200,126,0.15) 0%, rgba(230,200,126,0.08) 100%)",
7168
+ border: "1px solid rgba(230,200,126,0.25)",
7169
+ display: "flex",
7170
+ alignItems: "center",
7171
+ justifyContent: "center",
7172
+ marginBottom: "1.1rem"
7173
+ }, children: /* @__PURE__ */ jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "#e6c87e", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", children: [
7174
+ /* @__PURE__ */ jsx("path", { d: "M12 2L12 16M12 16L7 11M12 16L17 11" }),
7175
+ /* @__PURE__ */ jsx("path", { d: "M3 20H21" })
7176
+ ] }) }),
7177
+ /* @__PURE__ */ jsx(OnboardingHeading, { style: { marginBottom: "0.35rem" }, children: "Receive USDC" }),
7178
+ /* @__PURE__ */ jsxs("div", { style: {
7179
+ display: "inline-flex",
7180
+ alignItems: "center",
7181
+ gap: "0.35rem",
7182
+ background: "rgba(0,82,255,0.12)",
7183
+ border: "1px solid rgba(0,82,255,0.3)",
7184
+ borderRadius: 20,
7185
+ padding: "0.2rem 0.65rem",
7186
+ marginBottom: "1.25rem"
7187
+ }, children: [
7188
+ /* @__PURE__ */ jsx("div", { style: { width: 7, height: 7, borderRadius: "50%", background: "#0052FF", flexShrink: 0 } }),
7189
+ /* @__PURE__ */ jsx("span", { style: { fontSize: "0.72rem", fontWeight: 600, color: "#6b9fff", letterSpacing: "0.02em" }, children: "Base Sepolia" })
7190
+ ] }),
7191
+ /* @__PURE__ */ jsxs("p", { style: { fontSize: "0.82rem", color: "rgba(255,255,255,0.5)", textAlign: "center", marginBottom: "1.1rem", lineHeight: 1.5, maxWidth: 320 }, children: [
7192
+ "Send ",
7193
+ /* @__PURE__ */ jsx("strong", { style: { color: "rgba(255,255,255,0.8)" }, children: "USDC" }),
7194
+ " on Base Sepolia to the address below. Only send on this network."
7195
+ ] }),
7196
+ /* @__PURE__ */ jsxs("div", { style: {
7197
+ width: "100%",
7198
+ background: "rgba(255,255,255,0.03)",
7199
+ border: "1px solid rgba(255,255,255,0.09)",
7200
+ borderRadius: 10,
7201
+ padding: "0.85rem 1rem",
7202
+ marginBottom: "0.75rem"
7203
+ }, children: [
7204
+ /* @__PURE__ */ jsx("div", { style: { fontSize: "0.65rem", color: "rgba(255,255,255,0.35)", textTransform: "uppercase", letterSpacing: "0.06em", marginBottom: "0.4rem", fontWeight: 600 }, children: "Your wallet address" }),
7205
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "0.75rem" }, children: [
7206
+ /* @__PURE__ */ jsx("span", { style: {
7207
+ flex: 1,
7208
+ fontFamily: "monospace",
7209
+ fontSize: "0.76rem",
7210
+ color: "#eaecef",
7211
+ wordBreak: "break-all",
7212
+ lineHeight: 1.6
7213
+ }, children: walletAddress }),
7214
+ /* @__PURE__ */ jsx(
7215
+ "button",
7216
+ {
7217
+ type: "button",
7218
+ onClick: handleCopy,
7219
+ style: {
7220
+ background: copied ? "rgba(14,203,129,0.15)" : "rgba(230,200,126,0.1)",
7221
+ border: "1px solid " + (copied ? "rgba(14,203,129,0.35)" : "rgba(230,200,126,0.3)"),
7222
+ borderRadius: 6,
7223
+ padding: "0.4rem 0.8rem",
7224
+ color: copied ? "#0ecb81" : "#e6c87e",
7225
+ fontSize: "0.78rem",
7226
+ fontWeight: 600,
7227
+ cursor: "pointer",
7228
+ whiteSpace: "nowrap",
7229
+ flexShrink: 0,
7230
+ transition: "all 0.15s ease"
7231
+ },
7232
+ children: copied ? "\u2713 Copied" : "Copy"
7233
+ }
7234
+ )
7235
+ ] })
7236
+ ] }),
7237
+ /* @__PURE__ */ jsx(SubmitButton, { onClick: onClose, style: { marginBottom: "1.1rem" }, children: "Done" }),
7238
+ /* @__PURE__ */ jsxs("div", { style: {
7239
+ display: "flex",
7240
+ alignItems: "center",
7241
+ gap: "0.4rem",
7242
+ color: "rgba(255,255,255,0.28)",
7243
+ fontSize: "0.72rem"
7244
+ }, children: [
7245
+ /* @__PURE__ */ jsx("svg", { width: "13", height: "13", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" }) }),
7246
+ /* @__PURE__ */ jsxs("span", { children: [
7247
+ "Wallet secured by ",
7248
+ /* @__PURE__ */ jsx("strong", { style: { color: "rgba(255,255,255,0.45)", fontWeight: 600 }, children: "Privy" })
7249
+ ] })
7250
+ ] })
7251
+ ] })
7252
+ ] }) });
7253
+ }
7055
7254
  return null;
7056
7255
  };
7057
7256
  var Overlay2 = styled9.div`
@@ -13582,7 +13781,9 @@ function PortfolioActivityPanel({
13582
13781
  }
13583
13782
  };
13584
13783
  const mergedOrderHistory = useMemo(() => {
13585
- if (showSubscriptionsTab || offeringOrders.length === 0) return orderHistory;
13784
+ if (showSubscriptionsTab || offeringOrders.length === 0) {
13785
+ return [...orderHistory].sort((a, b) => b.createdAt - a.createdAt);
13786
+ }
13586
13787
  const mapped = offeringOrders.map((o, i) => ({
13587
13788
  id: o.ipoOrderId ?? -(i + 1),
13588
13789
  propertyId: 0,
@@ -13603,6 +13804,22 @@ function PortfolioActivityPanel({
13603
13804
  }));
13604
13805
  return [...orderHistory, ...mapped].sort((a, b) => b.createdAt - a.createdAt);
13605
13806
  }, [showSubscriptionsTab, offeringOrders, orderHistory]);
13807
+ const sortedOpenOrders = useMemo(
13808
+ () => [...openOrders].sort((a, b) => b.createdAt - a.createdAt),
13809
+ [openOrders]
13810
+ );
13811
+ const sortedOfferingOrders = useMemo(
13812
+ () => [...offeringOrders].sort((a, b) => b.createdAt - a.createdAt),
13813
+ [offeringOrders]
13814
+ );
13815
+ const sortedTradeHistory = useMemo(
13816
+ () => [...tradeHistory].sort((a, b) => b.executedAt - a.executedAt),
13817
+ [tradeHistory]
13818
+ );
13819
+ const sortedTransfers = useMemo(
13820
+ () => [...transfers].sort((a, b) => b.createdAt - a.createdAt),
13821
+ [transfers]
13822
+ );
13606
13823
  const positionsCount = positions.length;
13607
13824
  const openOrdersCount = useMemo(
13608
13825
  () => openOrders.filter((o) => o.status === "OPEN" || o.status === "PARTIALLY_FILLED").length,
@@ -13627,25 +13844,25 @@ function PortfolioActivityPanel({
13627
13844
  const activeDataLength = (() => {
13628
13845
  switch (activeTab) {
13629
13846
  case "subscriptions":
13630
- return offeringOrders.length;
13847
+ return sortedOfferingOrders.length;
13631
13848
  case "open-orders":
13632
- return openOrders.length;
13849
+ return sortedOpenOrders.length;
13633
13850
  case "orders":
13634
13851
  return mergedOrderHistory.length;
13635
13852
  case "trades":
13636
- return tradeHistory.length;
13853
+ return sortedTradeHistory.length;
13637
13854
  case "transfers":
13638
- return transfers.length;
13855
+ return sortedTransfers.length;
13639
13856
  default:
13640
13857
  return 0;
13641
13858
  }
13642
13859
  })();
13643
13860
  const totalPages = Math.ceil(activeDataLength / pageSize);
13644
- const pagedOfferingOrders = offeringOrders.slice(currentPage * pageSize, (currentPage + 1) * pageSize);
13645
- const pagedOpenOrders = openOrders.slice(currentPage * pageSize, (currentPage + 1) * pageSize);
13861
+ const pagedOfferingOrders = sortedOfferingOrders.slice(currentPage * pageSize, (currentPage + 1) * pageSize);
13862
+ const pagedOpenOrders = sortedOpenOrders.slice(currentPage * pageSize, (currentPage + 1) * pageSize);
13646
13863
  const pagedOrderHistory = mergedOrderHistory.slice(currentPage * pageSize, (currentPage + 1) * pageSize);
13647
- const pagedTradeHistory = tradeHistory.slice(currentPage * pageSize, (currentPage + 1) * pageSize);
13648
- const pagedTransfers = transfers.slice(currentPage * pageSize, (currentPage + 1) * pageSize);
13864
+ const pagedTradeHistory = sortedTradeHistory.slice(currentPage * pageSize, (currentPage + 1) * pageSize);
13865
+ const pagedTransfers = sortedTransfers.slice(currentPage * pageSize, (currentPage + 1) * pageSize);
13649
13866
  return /* @__PURE__ */ jsxs(Container2, { className, style, children: [
13650
13867
  /* @__PURE__ */ jsx(PanelTitle, { children: "Activity" }),
13651
13868
  /* @__PURE__ */ jsxs(TabContainer, { children: [
@@ -17844,10 +18061,13 @@ function ToastProvider({ children }) {
17844
18061
  setToasts((prev) => [...prev, { ...data, id }]);
17845
18062
  return id;
17846
18063
  }, []);
18064
+ const update = useCallback((id, patch) => {
18065
+ setToasts((prev) => prev.map((t) => t.id === id ? { ...t, ...patch } : t));
18066
+ }, []);
17847
18067
  const dismiss = useCallback((id) => {
17848
18068
  setToasts((prev) => prev.filter((t) => t.id !== id));
17849
18069
  }, []);
17850
- return /* @__PURE__ */ jsxs(ToastContext.Provider, { value: { toast: addToast, dismiss }, children: [
18070
+ return /* @__PURE__ */ jsxs(ToastContext.Provider, { value: { toast: addToast, update, dismiss }, children: [
17851
18071
  children,
17852
18072
  /* @__PURE__ */ jsx(Container3, { children: toasts.map((t) => /* @__PURE__ */ jsx(ToastItem, { toast: t, onDismiss: dismiss }, t.id)) })
17853
18073
  ] });