@loafmarkets/ui 0.1.44 → 0.1.46
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 +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +62 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -51
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1777,20 +1777,20 @@ function getTradeKey(trade, fallbackIndex) {
|
|
|
1777
1777
|
if (trade.time != null) return `t-${trade.time}-${trade.type}-${trade.price}-${trade.amount}`;
|
|
1778
1778
|
return `idx-${fallbackIndex}-${trade.type}-${trade.price}-${trade.amount}`;
|
|
1779
1779
|
}
|
|
1780
|
-
function useAmountChangeFlash(ref, amount) {
|
|
1780
|
+
function useAmountChangeFlash(ref, amount, side) {
|
|
1781
1781
|
const prevAmountRef = React9.useRef(amount);
|
|
1782
1782
|
React9.useEffect(() => {
|
|
1783
1783
|
const prev = prevAmountRef.current;
|
|
1784
1784
|
const node = ref.current;
|
|
1785
1785
|
if (prev !== amount && node && typeof node.animate === "function") {
|
|
1786
|
-
const color =
|
|
1786
|
+
const color = side === "bid" ? FLASH_UP_COLOR : FLASH_DOWN_COLOR;
|
|
1787
1787
|
node.animate(
|
|
1788
1788
|
[{ backgroundColor: color }, { backgroundColor: "transparent" }],
|
|
1789
1789
|
{ duration: FLASH_DURATION_MS, easing: "ease-out" }
|
|
1790
1790
|
);
|
|
1791
1791
|
}
|
|
1792
1792
|
prevAmountRef.current = amount;
|
|
1793
|
-
}, [amount, ref]);
|
|
1793
|
+
}, [amount, ref, side]);
|
|
1794
1794
|
}
|
|
1795
1795
|
function useMidPriceFlash(ref, midPrice, restBgColor) {
|
|
1796
1796
|
const prevMidRef = React9.useRef(midPrice);
|
|
@@ -1880,41 +1880,49 @@ function DepthRow({
|
|
|
1880
1880
|
}) {
|
|
1881
1881
|
const isAsk = side === "ask";
|
|
1882
1882
|
const rowRef = React9.useRef(null);
|
|
1883
|
-
useAmountChangeFlash(rowRef, amount);
|
|
1884
|
-
return /* @__PURE__ */ jsxs(
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1883
|
+
useAmountChangeFlash(rowRef, amount, side);
|
|
1884
|
+
return /* @__PURE__ */ jsxs(
|
|
1885
|
+
"div",
|
|
1886
|
+
{
|
|
1887
|
+
ref: rowRef,
|
|
1888
|
+
className: "relative grid grid-cols-2 items-center gap-3 px-3 text-[0.8rem]",
|
|
1889
|
+
style: { height: `${DEPTH_ROW_HEIGHT_PX}px` },
|
|
1890
|
+
children: [
|
|
1891
|
+
/* @__PURE__ */ jsx(
|
|
1892
|
+
"div",
|
|
1893
|
+
{
|
|
1894
|
+
className: cn(
|
|
1895
|
+
"absolute inset-y-0 right-0",
|
|
1896
|
+
isAsk ? "bg-rose-900/30" : "bg-emerald-900/30"
|
|
1897
|
+
),
|
|
1898
|
+
style: { width: `${clamp3(depthPct, 0, 100)}%`, transition: "width 300ms ease-out" }
|
|
1899
|
+
}
|
|
1891
1900
|
),
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
]
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
] });
|
|
1901
|
+
hasUserOrder ? /* @__PURE__ */ jsx(
|
|
1902
|
+
"span",
|
|
1903
|
+
{
|
|
1904
|
+
"aria-label": "Your order at this price",
|
|
1905
|
+
className: "absolute left-2 top-1/2 -translate-y-1/2 z-[2] h-[6px] w-[6px] rounded-full bg-[#C9A227] shadow-[0_0_6px_rgba(201,162,39,0.7)]"
|
|
1906
|
+
}
|
|
1907
|
+
) : null,
|
|
1908
|
+
/* @__PURE__ */ jsxs(
|
|
1909
|
+
"div",
|
|
1910
|
+
{
|
|
1911
|
+
className: cn("relative z-[1] tabular-nums", isAsk ? "text-[#f6465d]" : "text-[#0ecb81]"),
|
|
1912
|
+
children: [
|
|
1913
|
+
"$",
|
|
1914
|
+
formatNumber(price, precision)
|
|
1915
|
+
]
|
|
1916
|
+
}
|
|
1917
|
+
),
|
|
1918
|
+
/* @__PURE__ */ jsx("div", { className: "relative z-[1] text-right tabular-nums text-white/90", children: formatNumber(amount, amountPrecision) })
|
|
1919
|
+
]
|
|
1920
|
+
}
|
|
1921
|
+
);
|
|
1914
1922
|
}
|
|
1915
1923
|
var clamp3 = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
1916
1924
|
var LEVEL_ROWS_VISIBLE = 6;
|
|
1917
|
-
var DEPTH_ROW_HEIGHT_PX =
|
|
1925
|
+
var DEPTH_ROW_HEIGHT_PX = 26;
|
|
1918
1926
|
var COMPACT_ROWS_VISIBLE = 5;
|
|
1919
1927
|
var COMPACT_ROW_HEIGHT_PX = 30;
|
|
1920
1928
|
var COMPACT_BREAKPOINT_PX = 1024;
|
|
@@ -1931,13 +1939,15 @@ var Orderbook = React9.forwardRef(
|
|
|
1931
1939
|
amountPrecision = 2,
|
|
1932
1940
|
defaultTab = "orderbook",
|
|
1933
1941
|
onTabChange,
|
|
1934
|
-
rightHeader
|
|
1942
|
+
rightHeader,
|
|
1935
1943
|
variant = "auto",
|
|
1936
1944
|
userOrderPrices,
|
|
1937
1945
|
isLoading = false,
|
|
1946
|
+
onLoafLiquidityClick,
|
|
1938
1947
|
className,
|
|
1939
1948
|
...props
|
|
1940
1949
|
}, ref) => {
|
|
1950
|
+
const resolvedRightHeader = rightHeader ?? /* @__PURE__ */ jsx(LoafLiquidityBadge, { className: "text-[0.6rem]", onClick: onLoafLiquidityClick });
|
|
1941
1951
|
const [tab, setTab] = React9.useState(defaultTab);
|
|
1942
1952
|
const [tradeFilter, setTradeFilter] = React9.useState("all");
|
|
1943
1953
|
const viewportCompact = useViewportCompact(COMPACT_BREAKPOINT_PX);
|
|
@@ -1988,7 +1998,7 @@ var Orderbook = React9.forwardRef(
|
|
|
1988
1998
|
handleTab,
|
|
1989
1999
|
tradeFilter,
|
|
1990
2000
|
setTradeFilter,
|
|
1991
|
-
rightHeader,
|
|
2001
|
+
rightHeader: resolvedRightHeader,
|
|
1992
2002
|
priceLabel,
|
|
1993
2003
|
amountLabel,
|
|
1994
2004
|
tradeFiltered,
|
|
@@ -2174,9 +2184,9 @@ function DesktopOrderbookLayout({
|
|
|
2174
2184
|
/* @__PURE__ */ jsx(
|
|
2175
2185
|
"div",
|
|
2176
2186
|
{
|
|
2177
|
-
className: "flex flex-col justify-end divide-y divide-white/5 overflow-
|
|
2178
|
-
style: { height: `${sectionHeight}px
|
|
2179
|
-
children: isLoading ? Array.from({ length: LEVEL_ROWS_VISIBLE }).map((_, i) => /* @__PURE__ */ jsx(SkeletonRow, {}, `ask-skel-${i}`)) : asks.length === 0 ? /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center px-3 text-xs text-white/40", children: "No asks" }) : asks.map((l) => /* @__PURE__ */ jsx(
|
|
2187
|
+
className: "flex flex-col justify-end divide-y divide-white/5 overflow-hidden",
|
|
2188
|
+
style: { height: `${sectionHeight}px` },
|
|
2189
|
+
children: isLoading ? Array.from({ length: LEVEL_ROWS_VISIBLE }).map((_, i) => /* @__PURE__ */ jsx(SkeletonRow, {}, `ask-skel-${i}`)) : asks.length === 0 ? /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center px-3 text-xs text-white/40", children: "No asks" }) : asks.slice(-LEVEL_ROWS_VISIBLE).map((l) => /* @__PURE__ */ jsx(
|
|
2180
2190
|
DepthRow,
|
|
2181
2191
|
{
|
|
2182
2192
|
side: "ask",
|
|
@@ -2213,9 +2223,9 @@ function DesktopOrderbookLayout({
|
|
|
2213
2223
|
/* @__PURE__ */ jsx(
|
|
2214
2224
|
"div",
|
|
2215
2225
|
{
|
|
2216
|
-
className: "divide-y divide-white/5 overflow-
|
|
2217
|
-
style: { height: `${sectionHeight}px
|
|
2218
|
-
children: isLoading ? Array.from({ length: LEVEL_ROWS_VISIBLE }).map((_, i) => /* @__PURE__ */ jsx(SkeletonRow, {}, `bid-skel-${i}`)) : bids.length === 0 ? /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center px-3 text-xs text-white/40", children: "No bids" }) : bids.map((l) => /* @__PURE__ */ jsx(
|
|
2226
|
+
className: "divide-y divide-white/5 overflow-hidden",
|
|
2227
|
+
style: { height: `${sectionHeight}px` },
|
|
2228
|
+
children: isLoading ? Array.from({ length: LEVEL_ROWS_VISIBLE }).map((_, i) => /* @__PURE__ */ jsx(SkeletonRow, {}, `bid-skel-${i}`)) : bids.length === 0 ? /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center px-3 text-xs text-white/40", children: "No bids" }) : bids.slice(0, LEVEL_ROWS_VISIBLE).map((l) => /* @__PURE__ */ jsx(
|
|
2219
2229
|
DepthRow,
|
|
2220
2230
|
{
|
|
2221
2231
|
side: "bid",
|
|
@@ -2260,7 +2270,7 @@ function MobileOrderbookLayout({
|
|
|
2260
2270
|
}) {
|
|
2261
2271
|
const midRef = React9.useRef(null);
|
|
2262
2272
|
useMidPriceFlash(midRef, midPrice, "transparent");
|
|
2263
|
-
const visibleAsks = React9.useMemo(() => asks.slice(
|
|
2273
|
+
const visibleAsks = React9.useMemo(() => asks.slice(-COMPACT_ROWS_VISIBLE), [asks]);
|
|
2264
2274
|
const visibleBids = React9.useMemo(() => bids.slice(0, COMPACT_ROWS_VISIBLE), [bids]);
|
|
2265
2275
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2266
2276
|
/* @__PURE__ */ jsx("div", { className: "px-3 pt-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
@@ -2430,7 +2440,7 @@ function MobileDepthRow({
|
|
|
2430
2440
|
}) {
|
|
2431
2441
|
const isAsk = side === "ask";
|
|
2432
2442
|
const rowRef = React9.useRef(null);
|
|
2433
|
-
useAmountChangeFlash(rowRef, amount);
|
|
2443
|
+
useAmountChangeFlash(rowRef, amount, side);
|
|
2434
2444
|
return /* @__PURE__ */ jsxs(
|
|
2435
2445
|
"div",
|
|
2436
2446
|
{
|
|
@@ -2449,14 +2459,14 @@ function MobileDepthRow({
|
|
|
2449
2459
|
"aria-label": "Your order at this price",
|
|
2450
2460
|
style: {
|
|
2451
2461
|
position: "absolute",
|
|
2452
|
-
left:
|
|
2453
|
-
top:
|
|
2454
|
-
|
|
2455
|
-
width: "
|
|
2462
|
+
left: "6px",
|
|
2463
|
+
top: "50%",
|
|
2464
|
+
transform: "translateY(-50%)",
|
|
2465
|
+
width: "6px",
|
|
2466
|
+
height: "6px",
|
|
2467
|
+
borderRadius: "50%",
|
|
2456
2468
|
backgroundColor: "#C9A227",
|
|
2457
|
-
boxShadow: "0 0 6px rgba(201,162,39,0.
|
|
2458
|
-
borderTopRightRadius: "2px",
|
|
2459
|
-
borderBottomRightRadius: "2px",
|
|
2469
|
+
boxShadow: "0 0 6px rgba(201,162,39,0.7)",
|
|
2460
2470
|
zIndex: 2
|
|
2461
2471
|
}
|
|
2462
2472
|
}
|
|
@@ -11296,6 +11306,7 @@ var TabContainer = styled24.div`
|
|
|
11296
11306
|
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
|
|
11297
11307
|
margin-bottom: 0.75rem;
|
|
11298
11308
|
overflow-x: auto;
|
|
11309
|
+
overflow-y: hidden;
|
|
11299
11310
|
-webkit-overflow-scrolling: touch;
|
|
11300
11311
|
scrollbar-width: none;
|
|
11301
11312
|
&::-webkit-scrollbar { display: none; }
|