@loafmarkets/ui 0.1.325 → 0.1.327
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 +25 -24
- package/dist/index.d.ts +25 -24
- package/dist/index.js +197 -195
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +197 -195
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -12405,192 +12405,6 @@ var HomeSpinner = styled9.span`
|
|
|
12405
12405
|
to { transform: rotate(360deg); }
|
|
12406
12406
|
}
|
|
12407
12407
|
`;
|
|
12408
|
-
var slideIn2 = keyframes`
|
|
12409
|
-
from { transform: translateX(110%); opacity: 0; }
|
|
12410
|
-
to { transform: translateX(0); opacity: 1; }
|
|
12411
|
-
`;
|
|
12412
|
-
var slideOut2 = keyframes`
|
|
12413
|
-
from { transform: translateX(0); opacity: 1; }
|
|
12414
|
-
to { transform: translateX(110%); opacity: 0; }
|
|
12415
|
-
`;
|
|
12416
|
-
var progressShrink = keyframes`
|
|
12417
|
-
from { width: 100%; }
|
|
12418
|
-
to { width: 0%; }
|
|
12419
|
-
`;
|
|
12420
|
-
var VARIANT_COLORS = {
|
|
12421
|
-
success: { accent: "#0ecb81", icon: "\u2713" },
|
|
12422
|
-
error: { accent: "#f6465d", icon: "\u2715" },
|
|
12423
|
-
sell: { accent: "#f6465d", icon: "\u2713" },
|
|
12424
|
-
info: { accent: "#E6C656", icon: "\u2139" },
|
|
12425
|
-
pending: { accent: "#7EB3E6", icon: "\u25CC" }
|
|
12426
|
-
};
|
|
12427
|
-
var Wrapper2 = styled9.div`
|
|
12428
|
-
position: relative;
|
|
12429
|
-
display: flex;
|
|
12430
|
-
flex-direction: column;
|
|
12431
|
-
gap: 0;
|
|
12432
|
-
width: 340px;
|
|
12433
|
-
background: #0d0f1a;
|
|
12434
|
-
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
12435
|
-
border-radius: 10px;
|
|
12436
|
-
overflow: hidden;
|
|
12437
|
-
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.04);
|
|
12438
|
-
animation: ${({ $exiting }) => $exiting ? css`${slideOut2} 0.28s cubic-bezier(0.4,0,1,1) forwards` : css`${slideIn2} 0.32s cubic-bezier(0,0,0.2,1) forwards`};
|
|
12439
|
-
pointer-events: all;
|
|
12440
|
-
`;
|
|
12441
|
-
var Body = styled9.div`
|
|
12442
|
-
display: flex;
|
|
12443
|
-
align-items: flex-start;
|
|
12444
|
-
gap: 12px;
|
|
12445
|
-
padding: 14px 16px 12px;
|
|
12446
|
-
`;
|
|
12447
|
-
var IconDot = styled9.div`
|
|
12448
|
-
flex-shrink: 0;
|
|
12449
|
-
width: 28px;
|
|
12450
|
-
height: 28px;
|
|
12451
|
-
border-radius: 50%;
|
|
12452
|
-
background: ${({ $color }) => $color}1a;
|
|
12453
|
-
border: 1px solid ${({ $color }) => $color}55;
|
|
12454
|
-
display: flex;
|
|
12455
|
-
align-items: center;
|
|
12456
|
-
justify-content: center;
|
|
12457
|
-
font-size: 0.75rem;
|
|
12458
|
-
font-weight: 700;
|
|
12459
|
-
color: ${({ $color }) => $color};
|
|
12460
|
-
margin-top: 1px;
|
|
12461
|
-
`;
|
|
12462
|
-
var Content = styled9.div`
|
|
12463
|
-
flex: 1;
|
|
12464
|
-
min-width: 0;
|
|
12465
|
-
`;
|
|
12466
|
-
var Title2 = styled9.p`
|
|
12467
|
-
margin: 0 0 2px;
|
|
12468
|
-
font-size: 0.8rem;
|
|
12469
|
-
font-weight: 600;
|
|
12470
|
-
color: #fff;
|
|
12471
|
-
letter-spacing: 0.01em;
|
|
12472
|
-
`;
|
|
12473
|
-
var Amount = styled9.p`
|
|
12474
|
-
margin: 0 0 6px;
|
|
12475
|
-
font-size: 1.05rem;
|
|
12476
|
-
font-weight: 700;
|
|
12477
|
-
color: #E6C656;
|
|
12478
|
-
letter-spacing: -0.01em;
|
|
12479
|
-
`;
|
|
12480
|
-
var TxRow = styled9.a`
|
|
12481
|
-
display: inline-flex;
|
|
12482
|
-
align-items: center;
|
|
12483
|
-
gap: 5px;
|
|
12484
|
-
font-family: 'IBM Plex Mono', 'Space Mono', monospace;
|
|
12485
|
-
font-size: 0.68rem;
|
|
12486
|
-
color: rgba(255, 255, 255, 0.4);
|
|
12487
|
-
text-decoration: none;
|
|
12488
|
-
transition: color 0.15s;
|
|
12489
|
-
&:hover {
|
|
12490
|
-
color: #7EB3E6;
|
|
12491
|
-
}
|
|
12492
|
-
`;
|
|
12493
|
-
var TxArrow = styled9.span`
|
|
12494
|
-
font-size: 0.6rem;
|
|
12495
|
-
opacity: 0.6;
|
|
12496
|
-
`;
|
|
12497
|
-
var CloseBtn = styled9.button`
|
|
12498
|
-
flex-shrink: 0;
|
|
12499
|
-
background: none;
|
|
12500
|
-
border: none;
|
|
12501
|
-
padding: 2px 4px;
|
|
12502
|
-
cursor: pointer;
|
|
12503
|
-
color: rgba(255, 255, 255, 0.25);
|
|
12504
|
-
font-size: 0.9rem;
|
|
12505
|
-
line-height: 1;
|
|
12506
|
-
transition: color 0.15s;
|
|
12507
|
-
&:hover { color: rgba(255, 255, 255, 0.7); }
|
|
12508
|
-
`;
|
|
12509
|
-
var ProgressBar = styled9.div`
|
|
12510
|
-
height: 2px;
|
|
12511
|
-
background: rgba(255, 255, 255, 0.06);
|
|
12512
|
-
position: relative;
|
|
12513
|
-
&::after {
|
|
12514
|
-
content: '';
|
|
12515
|
-
position: absolute;
|
|
12516
|
-
left: 0;
|
|
12517
|
-
top: 0;
|
|
12518
|
-
height: 100%;
|
|
12519
|
-
background: ${({ $color }) => $color};
|
|
12520
|
-
animation: ${css`${progressShrink} ${({ $duration }) => $duration}ms linear forwards`};
|
|
12521
|
-
}
|
|
12522
|
-
`;
|
|
12523
|
-
var Container2 = styled9.div`
|
|
12524
|
-
position: fixed;
|
|
12525
|
-
bottom: 24px;
|
|
12526
|
-
right: 24px;
|
|
12527
|
-
z-index: 9999;
|
|
12528
|
-
display: flex;
|
|
12529
|
-
flex-direction: column-reverse;
|
|
12530
|
-
gap: 10px;
|
|
12531
|
-
pointer-events: none;
|
|
12532
|
-
`;
|
|
12533
|
-
var DEFAULT_EXPLORER = "https://sepolia.basescan.org/tx/";
|
|
12534
|
-
function truncateHash(hash) {
|
|
12535
|
-
return `${hash.slice(0, 6)}\u2026${hash.slice(-4)}`;
|
|
12536
|
-
}
|
|
12537
|
-
function ToastItem({ toast, onDismiss }) {
|
|
12538
|
-
const [exiting, setExiting] = useState(false);
|
|
12539
|
-
const timerRef = useRef(null);
|
|
12540
|
-
const dismiss = useCallback(() => {
|
|
12541
|
-
setExiting(true);
|
|
12542
|
-
setTimeout(() => onDismiss(toast.id), 280);
|
|
12543
|
-
}, [onDismiss, toast.id]);
|
|
12544
|
-
useEffect(() => {
|
|
12545
|
-
const duration2 = toast.duration ?? 6e3;
|
|
12546
|
-
if (duration2 > 0) {
|
|
12547
|
-
timerRef.current = setTimeout(dismiss, duration2);
|
|
12548
|
-
}
|
|
12549
|
-
return () => {
|
|
12550
|
-
if (timerRef.current) clearTimeout(timerRef.current);
|
|
12551
|
-
};
|
|
12552
|
-
}, [dismiss, toast.duration]);
|
|
12553
|
-
const { accent, icon } = VARIANT_COLORS[toast.variant];
|
|
12554
|
-
const duration = toast.duration ?? 6e3;
|
|
12555
|
-
const explorerBase = toast.explorerUrl ?? DEFAULT_EXPLORER;
|
|
12556
|
-
const txUrl = toast.txHash ? `${explorerBase}${toast.txHash}` : void 0;
|
|
12557
|
-
return /* @__PURE__ */ jsxs(Wrapper2, { $exiting: exiting, children: [
|
|
12558
|
-
/* @__PURE__ */ jsxs(Body, { children: [
|
|
12559
|
-
/* @__PURE__ */ jsx(IconDot, { $color: accent, children: icon }),
|
|
12560
|
-
/* @__PURE__ */ jsxs(Content, { children: [
|
|
12561
|
-
/* @__PURE__ */ jsx(Title2, { children: toast.title }),
|
|
12562
|
-
toast.amount && /* @__PURE__ */ jsx(Amount, { children: toast.amount }),
|
|
12563
|
-
toast.txHash && txUrl && /* @__PURE__ */ jsxs(TxRow, { href: txUrl, target: "_blank", rel: "noopener noreferrer", children: [
|
|
12564
|
-
truncateHash(toast.txHash),
|
|
12565
|
-
/* @__PURE__ */ jsx(TxArrow, { children: "\u2197" })
|
|
12566
|
-
] })
|
|
12567
|
-
] }),
|
|
12568
|
-
/* @__PURE__ */ jsx(CloseBtn, { type: "button", onClick: dismiss, "aria-label": "Dismiss", children: "\u2715" })
|
|
12569
|
-
] }),
|
|
12570
|
-
duration > 0 && /* @__PURE__ */ jsx(ProgressBar, { $color: accent, $duration: duration })
|
|
12571
|
-
] });
|
|
12572
|
-
}
|
|
12573
|
-
var ToastContext = createContext(null);
|
|
12574
|
-
function ToastProvider({ children }) {
|
|
12575
|
-
const [toasts, setToasts] = useState([]);
|
|
12576
|
-
const addToast = useCallback((data) => {
|
|
12577
|
-
const id = `toast-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`;
|
|
12578
|
-
setToasts((prev) => [...prev, { ...data, id }]);
|
|
12579
|
-
return id;
|
|
12580
|
-
}, []);
|
|
12581
|
-
const dismiss = useCallback((id) => {
|
|
12582
|
-
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
12583
|
-
}, []);
|
|
12584
|
-
return /* @__PURE__ */ jsxs(ToastContext.Provider, { value: { toast: addToast, dismiss }, children: [
|
|
12585
|
-
children,
|
|
12586
|
-
/* @__PURE__ */ jsx(Container2, { children: toasts.map((t) => /* @__PURE__ */ jsx(ToastItem, { toast: t, onDismiss: dismiss }, t.id)) })
|
|
12587
|
-
] });
|
|
12588
|
-
}
|
|
12589
|
-
function useToast() {
|
|
12590
|
-
const ctx = useContext(ToastContext);
|
|
12591
|
-
if (!ctx) throw new Error("useToast must be used within a ToastProvider");
|
|
12592
|
-
return ctx;
|
|
12593
|
-
}
|
|
12594
12408
|
function useCountdown(opensAt) {
|
|
12595
12409
|
const [now, setNow] = useState(() => Math.floor(Date.now() / 1e3));
|
|
12596
12410
|
useEffect(() => {
|
|
@@ -12639,9 +12453,9 @@ function OrderPanel({
|
|
|
12639
12453
|
onDeposit,
|
|
12640
12454
|
onVerifyIdentity,
|
|
12641
12455
|
tokenDisplayName,
|
|
12642
|
-
tokenSymbol
|
|
12456
|
+
tokenSymbol,
|
|
12457
|
+
toast
|
|
12643
12458
|
}) {
|
|
12644
|
-
const { toast } = useToast();
|
|
12645
12459
|
const countdown = useCountdown(opensAt);
|
|
12646
12460
|
const [payInputValue, setPayInputValue] = useState("");
|
|
12647
12461
|
const [receiveInputValue, setReceiveInputValue] = useState("");
|
|
@@ -14140,7 +13954,7 @@ function PortfolioActivityPanel({
|
|
|
14140
13954
|
const handleTabChange = (tab) => {
|
|
14141
13955
|
setActiveTab(tab);
|
|
14142
13956
|
};
|
|
14143
|
-
return /* @__PURE__ */ jsxs(
|
|
13957
|
+
return /* @__PURE__ */ jsxs(Container2, { className, style, children: [
|
|
14144
13958
|
/* @__PURE__ */ jsx(PanelTitle, { children: "Activity" }),
|
|
14145
13959
|
/* @__PURE__ */ jsxs(TabContainer, { children: [
|
|
14146
13960
|
showPositionsTab && /* @__PURE__ */ jsxs(Tab, { $active: activeTab === "positions", onClick: () => handleTabChange("positions"), children: [
|
|
@@ -14323,11 +14137,11 @@ function PortfolioActivityPanel({
|
|
|
14323
14137
|
] })
|
|
14324
14138
|
] }),
|
|
14325
14139
|
onClosePosition && /* @__PURE__ */ jsx(PositionsCell, { children: /* @__PURE__ */ jsxs(CloseActions, { children: [
|
|
14326
|
-
/* @__PURE__ */ jsx(
|
|
14140
|
+
/* @__PURE__ */ jsx(CloseBtn, { onClick: (e) => {
|
|
14327
14141
|
e.stopPropagation();
|
|
14328
14142
|
onClosePosition(pos.tokenName, "market", pos.quantity, pos.marketPrice);
|
|
14329
14143
|
}, children: "Market Sell" }),
|
|
14330
|
-
/* @__PURE__ */ jsx(
|
|
14144
|
+
/* @__PURE__ */ jsx(CloseBtn, { onClick: (e) => {
|
|
14331
14145
|
e.stopPropagation();
|
|
14332
14146
|
onClosePosition(pos.tokenName, "limit", pos.quantity, pos.marketPrice);
|
|
14333
14147
|
}, children: "Limit Sell" })
|
|
@@ -14564,7 +14378,7 @@ function PortfolioActivityPanel({
|
|
|
14564
14378
|
] }) })
|
|
14565
14379
|
] });
|
|
14566
14380
|
}
|
|
14567
|
-
var
|
|
14381
|
+
var Container2 = styled9.div`
|
|
14568
14382
|
display: flex;
|
|
14569
14383
|
flex-direction: column;
|
|
14570
14384
|
overflow: hidden;
|
|
@@ -14988,7 +14802,7 @@ var CloseActions = styled9.div`
|
|
|
14988
14802
|
gap: 0.35rem;
|
|
14989
14803
|
align-items: center;
|
|
14990
14804
|
`;
|
|
14991
|
-
var
|
|
14805
|
+
var CloseBtn = styled9.button`
|
|
14992
14806
|
background: transparent;
|
|
14993
14807
|
border: 1px solid rgba(230, 200, 126, 0.25);
|
|
14994
14808
|
border-radius: 4px;
|
|
@@ -15342,7 +15156,8 @@ function PropertyBuy({
|
|
|
15342
15156
|
onVerifyIdentity,
|
|
15343
15157
|
portfolioActivity,
|
|
15344
15158
|
newsItems = [],
|
|
15345
|
-
newsConnectionStatus
|
|
15159
|
+
newsConnectionStatus,
|
|
15160
|
+
toast
|
|
15346
15161
|
}) {
|
|
15347
15162
|
const [sliderValue, setSliderValue] = useState(0);
|
|
15348
15163
|
const [availableBalance, setAvailableBalance] = useState(walletUsdcBalance ?? 0);
|
|
@@ -15577,7 +15392,8 @@ function PropertyBuy({
|
|
|
15577
15392
|
hasInsufficientFunds,
|
|
15578
15393
|
onPlaceAnotherOrder: handlePlaceAnotherOrder,
|
|
15579
15394
|
onDeposit,
|
|
15580
|
-
onVerifyIdentity
|
|
15395
|
+
onVerifyIdentity,
|
|
15396
|
+
toast
|
|
15581
15397
|
}
|
|
15582
15398
|
),
|
|
15583
15399
|
purchaseError && /* @__PURE__ */ jsx("div", { style: { marginTop: "0.75rem", padding: "0.75rem 1rem", borderRadius: "8px", background: "rgba(246,70,93,0.1)", border: "1px solid rgba(246,70,93,0.3)", color: "#f6465d", fontSize: "0.8rem", fontWeight: 500 }, children: purchaseError })
|
|
@@ -18242,6 +18058,192 @@ function GalleryContent({ galleryImages, startIndex, title, subtitle, onClose })
|
|
|
18242
18058
|
}
|
|
18243
18059
|
);
|
|
18244
18060
|
}
|
|
18061
|
+
var slideIn2 = keyframes`
|
|
18062
|
+
from { transform: translateX(110%); opacity: 0; }
|
|
18063
|
+
to { transform: translateX(0); opacity: 1; }
|
|
18064
|
+
`;
|
|
18065
|
+
var slideOut2 = keyframes`
|
|
18066
|
+
from { transform: translateX(0); opacity: 1; }
|
|
18067
|
+
to { transform: translateX(110%); opacity: 0; }
|
|
18068
|
+
`;
|
|
18069
|
+
var progressShrink = keyframes`
|
|
18070
|
+
from { width: 100%; }
|
|
18071
|
+
to { width: 0%; }
|
|
18072
|
+
`;
|
|
18073
|
+
var VARIANT_COLORS = {
|
|
18074
|
+
success: { accent: "#0ecb81", icon: "\u2713" },
|
|
18075
|
+
error: { accent: "#f6465d", icon: "\u2715" },
|
|
18076
|
+
sell: { accent: "#f6465d", icon: "\u2713" },
|
|
18077
|
+
info: { accent: "#E6C656", icon: "\u2139" },
|
|
18078
|
+
pending: { accent: "#7EB3E6", icon: "\u25CC" }
|
|
18079
|
+
};
|
|
18080
|
+
var Wrapper2 = styled9.div`
|
|
18081
|
+
position: relative;
|
|
18082
|
+
display: flex;
|
|
18083
|
+
flex-direction: column;
|
|
18084
|
+
gap: 0;
|
|
18085
|
+
width: 340px;
|
|
18086
|
+
background: #0d0f1a;
|
|
18087
|
+
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
18088
|
+
border-radius: 10px;
|
|
18089
|
+
overflow: hidden;
|
|
18090
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.04);
|
|
18091
|
+
animation: ${({ $exiting }) => $exiting ? css`${slideOut2} 0.28s cubic-bezier(0.4,0,1,1) forwards` : css`${slideIn2} 0.32s cubic-bezier(0,0,0.2,1) forwards`};
|
|
18092
|
+
pointer-events: all;
|
|
18093
|
+
`;
|
|
18094
|
+
var Body = styled9.div`
|
|
18095
|
+
display: flex;
|
|
18096
|
+
align-items: flex-start;
|
|
18097
|
+
gap: 12px;
|
|
18098
|
+
padding: 14px 16px 12px;
|
|
18099
|
+
`;
|
|
18100
|
+
var IconDot = styled9.div`
|
|
18101
|
+
flex-shrink: 0;
|
|
18102
|
+
width: 28px;
|
|
18103
|
+
height: 28px;
|
|
18104
|
+
border-radius: 50%;
|
|
18105
|
+
background: ${({ $color }) => $color}1a;
|
|
18106
|
+
border: 1px solid ${({ $color }) => $color}55;
|
|
18107
|
+
display: flex;
|
|
18108
|
+
align-items: center;
|
|
18109
|
+
justify-content: center;
|
|
18110
|
+
font-size: 0.75rem;
|
|
18111
|
+
font-weight: 700;
|
|
18112
|
+
color: ${({ $color }) => $color};
|
|
18113
|
+
margin-top: 1px;
|
|
18114
|
+
`;
|
|
18115
|
+
var Content = styled9.div`
|
|
18116
|
+
flex: 1;
|
|
18117
|
+
min-width: 0;
|
|
18118
|
+
`;
|
|
18119
|
+
var Title2 = styled9.p`
|
|
18120
|
+
margin: 0 0 2px;
|
|
18121
|
+
font-size: 0.8rem;
|
|
18122
|
+
font-weight: 600;
|
|
18123
|
+
color: #fff;
|
|
18124
|
+
letter-spacing: 0.01em;
|
|
18125
|
+
`;
|
|
18126
|
+
var Amount = styled9.p`
|
|
18127
|
+
margin: 0 0 6px;
|
|
18128
|
+
font-size: 1.05rem;
|
|
18129
|
+
font-weight: 700;
|
|
18130
|
+
color: #E6C656;
|
|
18131
|
+
letter-spacing: -0.01em;
|
|
18132
|
+
`;
|
|
18133
|
+
var TxRow = styled9.a`
|
|
18134
|
+
display: inline-flex;
|
|
18135
|
+
align-items: center;
|
|
18136
|
+
gap: 5px;
|
|
18137
|
+
font-family: 'IBM Plex Mono', 'Space Mono', monospace;
|
|
18138
|
+
font-size: 0.68rem;
|
|
18139
|
+
color: rgba(255, 255, 255, 0.4);
|
|
18140
|
+
text-decoration: none;
|
|
18141
|
+
transition: color 0.15s;
|
|
18142
|
+
&:hover {
|
|
18143
|
+
color: #7EB3E6;
|
|
18144
|
+
}
|
|
18145
|
+
`;
|
|
18146
|
+
var TxArrow = styled9.span`
|
|
18147
|
+
font-size: 0.6rem;
|
|
18148
|
+
opacity: 0.6;
|
|
18149
|
+
`;
|
|
18150
|
+
var CloseBtn2 = styled9.button`
|
|
18151
|
+
flex-shrink: 0;
|
|
18152
|
+
background: none;
|
|
18153
|
+
border: none;
|
|
18154
|
+
padding: 2px 4px;
|
|
18155
|
+
cursor: pointer;
|
|
18156
|
+
color: rgba(255, 255, 255, 0.25);
|
|
18157
|
+
font-size: 0.9rem;
|
|
18158
|
+
line-height: 1;
|
|
18159
|
+
transition: color 0.15s;
|
|
18160
|
+
&:hover { color: rgba(255, 255, 255, 0.7); }
|
|
18161
|
+
`;
|
|
18162
|
+
var ProgressBar = styled9.div`
|
|
18163
|
+
height: 2px;
|
|
18164
|
+
background: rgba(255, 255, 255, 0.06);
|
|
18165
|
+
position: relative;
|
|
18166
|
+
&::after {
|
|
18167
|
+
content: '';
|
|
18168
|
+
position: absolute;
|
|
18169
|
+
left: 0;
|
|
18170
|
+
top: 0;
|
|
18171
|
+
height: 100%;
|
|
18172
|
+
background: ${({ $color }) => $color};
|
|
18173
|
+
animation: ${css`${progressShrink} ${({ $duration }) => $duration}ms linear forwards`};
|
|
18174
|
+
}
|
|
18175
|
+
`;
|
|
18176
|
+
var Container3 = styled9.div`
|
|
18177
|
+
position: fixed;
|
|
18178
|
+
bottom: 24px;
|
|
18179
|
+
right: 24px;
|
|
18180
|
+
z-index: 9999;
|
|
18181
|
+
display: flex;
|
|
18182
|
+
flex-direction: column-reverse;
|
|
18183
|
+
gap: 10px;
|
|
18184
|
+
pointer-events: none;
|
|
18185
|
+
`;
|
|
18186
|
+
var DEFAULT_EXPLORER = "https://sepolia.basescan.org/tx/";
|
|
18187
|
+
function truncateHash(hash) {
|
|
18188
|
+
return `${hash.slice(0, 6)}\u2026${hash.slice(-4)}`;
|
|
18189
|
+
}
|
|
18190
|
+
function ToastItem({ toast, onDismiss }) {
|
|
18191
|
+
const [exiting, setExiting] = useState(false);
|
|
18192
|
+
const timerRef = useRef(null);
|
|
18193
|
+
const dismiss = useCallback(() => {
|
|
18194
|
+
setExiting(true);
|
|
18195
|
+
setTimeout(() => onDismiss(toast.id), 280);
|
|
18196
|
+
}, [onDismiss, toast.id]);
|
|
18197
|
+
useEffect(() => {
|
|
18198
|
+
const duration2 = toast.duration ?? 6e3;
|
|
18199
|
+
if (duration2 > 0) {
|
|
18200
|
+
timerRef.current = setTimeout(dismiss, duration2);
|
|
18201
|
+
}
|
|
18202
|
+
return () => {
|
|
18203
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
18204
|
+
};
|
|
18205
|
+
}, [dismiss, toast.duration]);
|
|
18206
|
+
const { accent, icon } = VARIANT_COLORS[toast.variant];
|
|
18207
|
+
const duration = toast.duration ?? 6e3;
|
|
18208
|
+
const explorerBase = toast.explorerUrl ?? DEFAULT_EXPLORER;
|
|
18209
|
+
const txUrl = toast.txHash ? `${explorerBase}${toast.txHash}` : void 0;
|
|
18210
|
+
return /* @__PURE__ */ jsxs(Wrapper2, { $exiting: exiting, children: [
|
|
18211
|
+
/* @__PURE__ */ jsxs(Body, { children: [
|
|
18212
|
+
/* @__PURE__ */ jsx(IconDot, { $color: accent, children: icon }),
|
|
18213
|
+
/* @__PURE__ */ jsxs(Content, { children: [
|
|
18214
|
+
/* @__PURE__ */ jsx(Title2, { children: toast.title }),
|
|
18215
|
+
toast.amount && /* @__PURE__ */ jsx(Amount, { children: toast.amount }),
|
|
18216
|
+
toast.txHash && txUrl && /* @__PURE__ */ jsxs(TxRow, { href: txUrl, target: "_blank", rel: "noopener noreferrer", children: [
|
|
18217
|
+
truncateHash(toast.txHash),
|
|
18218
|
+
/* @__PURE__ */ jsx(TxArrow, { children: "\u2197" })
|
|
18219
|
+
] })
|
|
18220
|
+
] }),
|
|
18221
|
+
/* @__PURE__ */ jsx(CloseBtn2, { type: "button", onClick: dismiss, "aria-label": "Dismiss", children: "\u2715" })
|
|
18222
|
+
] }),
|
|
18223
|
+
duration > 0 && /* @__PURE__ */ jsx(ProgressBar, { $color: accent, $duration: duration })
|
|
18224
|
+
] });
|
|
18225
|
+
}
|
|
18226
|
+
var ToastContext = createContext(null);
|
|
18227
|
+
function ToastProvider({ children }) {
|
|
18228
|
+
const [toasts, setToasts] = useState([]);
|
|
18229
|
+
const addToast = useCallback((data) => {
|
|
18230
|
+
const id = `toast-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`;
|
|
18231
|
+
setToasts((prev) => [...prev, { ...data, id }]);
|
|
18232
|
+
return id;
|
|
18233
|
+
}, []);
|
|
18234
|
+
const dismiss = useCallback((id) => {
|
|
18235
|
+
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
18236
|
+
}, []);
|
|
18237
|
+
return /* @__PURE__ */ jsxs(ToastContext.Provider, { value: { toast: addToast, dismiss }, children: [
|
|
18238
|
+
children,
|
|
18239
|
+
/* @__PURE__ */ jsx(Container3, { children: toasts.map((t) => /* @__PURE__ */ jsx(ToastItem, { toast: t, onDismiss: dismiss }, t.id)) })
|
|
18240
|
+
] });
|
|
18241
|
+
}
|
|
18242
|
+
function useToast() {
|
|
18243
|
+
const ctx = useContext(ToastContext);
|
|
18244
|
+
if (!ctx) throw new Error("useToast must be used within a ToastProvider");
|
|
18245
|
+
return ctx;
|
|
18246
|
+
}
|
|
18245
18247
|
var INTERVALS = [1e3, 2e3, 4e3, 5e3, 7e3, 1e4, 12e3];
|
|
18246
18248
|
function useAdaptivePolling({ enabled, onPoll }) {
|
|
18247
18249
|
const onPollRef = useRef(onPoll);
|