@loafmarkets/ui 0.1.368 → 0.1.369
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 +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +134 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +134 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React5 from 'react';
|
|
2
|
-
import React5__default, { createContext, useState, useRef, useCallback, useEffect,
|
|
2
|
+
import React5__default, { createContext, useState, useRef, useMemo, useCallback, useEffect, useContext } from 'react';
|
|
3
3
|
import { Slot } from '@radix-ui/react-slot';
|
|
4
4
|
import { cva } from 'class-variance-authority';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
@@ -18574,7 +18574,139 @@ var SiteFooter = () => {
|
|
|
18574
18574
|
showContactPopup && /* @__PURE__ */ jsx(ContactPopup, { onClose: () => setShowContactPopup(false) })
|
|
18575
18575
|
] });
|
|
18576
18576
|
};
|
|
18577
|
+
var PAD_Y = 2;
|
|
18578
|
+
function lerp(a, b, t) {
|
|
18579
|
+
return a + (b - a) * t;
|
|
18580
|
+
}
|
|
18581
|
+
function extractSparkline(candles, maxPoints = 20) {
|
|
18582
|
+
if (!candles.length) return [];
|
|
18583
|
+
const step = Math.max(1, Math.floor(candles.length / maxPoints));
|
|
18584
|
+
const points = [];
|
|
18585
|
+
for (let i = 0; i < candles.length; i += step) {
|
|
18586
|
+
points.push(candles[i].close);
|
|
18587
|
+
}
|
|
18588
|
+
if (points.length > 0) {
|
|
18589
|
+
const last = candles[candles.length - 1].close;
|
|
18590
|
+
if (points[points.length - 1] !== last) {
|
|
18591
|
+
points.push(last);
|
|
18592
|
+
}
|
|
18593
|
+
}
|
|
18594
|
+
return points;
|
|
18595
|
+
}
|
|
18596
|
+
var SparklineChart = React5__default.memo(function SparklineChart2({ data, width, height, positive }) {
|
|
18597
|
+
const [hoverX, setHoverX] = useState(null);
|
|
18598
|
+
const svgRef = useRef(null);
|
|
18599
|
+
const { linePath, fillPath, points } = useMemo(() => {
|
|
18600
|
+
const mn = Math.min(...data);
|
|
18601
|
+
const mx = Math.max(...data);
|
|
18602
|
+
const range = mx - mn || 1;
|
|
18603
|
+
const stepX = width / (data.length - 1);
|
|
18604
|
+
const pts = data.map((v, i) => ({
|
|
18605
|
+
x: i * stepX,
|
|
18606
|
+
y: height - (v - mn) / range * (height - PAD_Y * 2) - PAD_Y
|
|
18607
|
+
}));
|
|
18608
|
+
const line = pts.map((p, i) => `${i === 0 ? "M" : "L"}${p.x},${p.y}`).join(" ");
|
|
18609
|
+
const fill = `${line} L${width},${height} L0,${height} Z`;
|
|
18610
|
+
return { linePath: line, fillPath: fill, points: pts };
|
|
18611
|
+
}, [data, width, height]);
|
|
18612
|
+
const interpolated = useMemo(() => {
|
|
18613
|
+
if (hoverX == null || points.length < 2) return null;
|
|
18614
|
+
const stepX = width / (data.length - 1);
|
|
18615
|
+
const rawIdx = hoverX / stepX;
|
|
18616
|
+
const i0 = Math.floor(rawIdx);
|
|
18617
|
+
const i1 = Math.min(i0 + 1, data.length - 1);
|
|
18618
|
+
const t = rawIdx - i0;
|
|
18619
|
+
return {
|
|
18620
|
+
x: hoverX,
|
|
18621
|
+
y: lerp(points[i0].y, points[i1].y, t),
|
|
18622
|
+
price: lerp(data[i0], data[i1], t)
|
|
18623
|
+
};
|
|
18624
|
+
}, [hoverX, points, data, width]);
|
|
18625
|
+
const handleMouseMove = useCallback((e) => {
|
|
18626
|
+
const svg = svgRef.current;
|
|
18627
|
+
if (!svg) return;
|
|
18628
|
+
const rect = svg.getBoundingClientRect();
|
|
18629
|
+
const x = Math.max(0, Math.min(width, e.clientX - rect.left));
|
|
18630
|
+
setHoverX(x);
|
|
18631
|
+
}, [width]);
|
|
18632
|
+
const handleMouseLeave = useCallback(() => setHoverX(null), []);
|
|
18633
|
+
if (data.length < 2) return null;
|
|
18634
|
+
const color = positive ? "#00C076" : "#FF5757";
|
|
18635
|
+
const gradId = `spark-grad-${positive ? "up" : "dn"}`;
|
|
18636
|
+
return /* @__PURE__ */ jsxs(
|
|
18637
|
+
"svg",
|
|
18638
|
+
{
|
|
18639
|
+
ref: svgRef,
|
|
18640
|
+
width,
|
|
18641
|
+
height,
|
|
18642
|
+
style: { display: "block", overflow: "visible", cursor: hoverX != null ? "crosshair" : "default" },
|
|
18643
|
+
onMouseMove: handleMouseMove,
|
|
18644
|
+
onMouseLeave: handleMouseLeave,
|
|
18645
|
+
children: [
|
|
18646
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: gradId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
18647
|
+
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: color, stopOpacity: 0.15 }),
|
|
18648
|
+
/* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: color, stopOpacity: 0 })
|
|
18649
|
+
] }) }),
|
|
18650
|
+
/* @__PURE__ */ jsx("path", { d: fillPath, fill: `url(#${gradId})` }),
|
|
18651
|
+
/* @__PURE__ */ jsx("path", { d: linePath, fill: "none", stroke: color, strokeWidth: 1.5, strokeLinejoin: "round", strokeLinecap: "round" }),
|
|
18652
|
+
interpolated && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
18653
|
+
/* @__PURE__ */ jsx(
|
|
18654
|
+
"line",
|
|
18655
|
+
{
|
|
18656
|
+
x1: interpolated.x,
|
|
18657
|
+
y1: 0,
|
|
18658
|
+
x2: interpolated.x,
|
|
18659
|
+
y2: height,
|
|
18660
|
+
stroke: "rgba(255,255,255,0.2)",
|
|
18661
|
+
strokeWidth: 1,
|
|
18662
|
+
strokeDasharray: "2,2"
|
|
18663
|
+
}
|
|
18664
|
+
),
|
|
18665
|
+
/* @__PURE__ */ jsx("circle", { cx: interpolated.x, cy: interpolated.y, r: 3, fill: color, stroke: "#0A0A0C", strokeWidth: 1.5 }),
|
|
18666
|
+
(() => {
|
|
18667
|
+
const above = interpolated.y > 24;
|
|
18668
|
+
const tooltipY = above ? interpolated.y - 26 : interpolated.y + 8;
|
|
18669
|
+
const tooltipX = Math.min(Math.max(interpolated.x - 28, 0), width - 56);
|
|
18670
|
+
const textX = tooltipX + 28;
|
|
18671
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
18672
|
+
/* @__PURE__ */ jsx(
|
|
18673
|
+
"rect",
|
|
18674
|
+
{
|
|
18675
|
+
x: tooltipX,
|
|
18676
|
+
y: tooltipY,
|
|
18677
|
+
width: 56,
|
|
18678
|
+
height: 16,
|
|
18679
|
+
rx: 3,
|
|
18680
|
+
fill: "rgba(0,0,0,0.75)",
|
|
18681
|
+
stroke: "rgba(255,255,255,0.1)",
|
|
18682
|
+
strokeWidth: 0.5
|
|
18683
|
+
}
|
|
18684
|
+
),
|
|
18685
|
+
/* @__PURE__ */ jsxs(
|
|
18686
|
+
"text",
|
|
18687
|
+
{
|
|
18688
|
+
x: textX,
|
|
18689
|
+
y: tooltipY + 11.5,
|
|
18690
|
+
textAnchor: "middle",
|
|
18691
|
+
fill: "#fff",
|
|
18692
|
+
fontSize: 9,
|
|
18693
|
+
fontWeight: 600,
|
|
18694
|
+
fontFamily: "inherit",
|
|
18695
|
+
style: { fontVariantNumeric: "tabular-nums" },
|
|
18696
|
+
children: [
|
|
18697
|
+
"$",
|
|
18698
|
+
interpolated.price.toFixed(2)
|
|
18699
|
+
]
|
|
18700
|
+
}
|
|
18701
|
+
)
|
|
18702
|
+
] });
|
|
18703
|
+
})()
|
|
18704
|
+
] })
|
|
18705
|
+
]
|
|
18706
|
+
}
|
|
18707
|
+
);
|
|
18708
|
+
});
|
|
18577
18709
|
|
|
18578
|
-
export { AssetSelectorBar, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ContactPopup, Header, HousePositionSlider, HousePositionSliderMobile, LoafLiquidityBadge, LoafLiquidityLogo, LoginPopup, MobileTradeNav, OfferingProgressCard, Orderbook, owner_booking_default as OwnerBooking, PaymentPopup, PortfolioActivityPanel, PortfolioSummary, PriceChart, PropertyBuy, PropertyCompareBar, PropertyDocuments, PropertyHeroHeader, PropertyHistory, PropertyInspectionTimes, PropertyMediaRow, PropertyNewsUpdates, PropertyOffers, PropertyOverview, PropertyPhotoGallery, PropertySubheader, PropertyTour, PropertyValuation, SiteFooter, Skeleton, SlideDigit, ToastProvider, TradeConfirmationModal, TradingSlider, YourOrders, badgeVariants, buttonVariants, hasPendingActivity, useAdaptivePolling, useToast };
|
|
18710
|
+
export { AssetSelectorBar, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ContactPopup, Header, HousePositionSlider, HousePositionSliderMobile, LoafLiquidityBadge, LoafLiquidityLogo, LoginPopup, MobileTradeNav, OfferingProgressCard, Orderbook, owner_booking_default as OwnerBooking, PaymentPopup, PortfolioActivityPanel, PortfolioSummary, PriceChart, PropertyBuy, PropertyCompareBar, PropertyDocuments, PropertyHeroHeader, PropertyHistory, PropertyInspectionTimes, PropertyMediaRow, PropertyNewsUpdates, PropertyOffers, PropertyOverview, PropertyPhotoGallery, PropertySubheader, PropertyTour, PropertyValuation, SiteFooter, Skeleton, SlideDigit, SparklineChart, ToastProvider, TradeConfirmationModal, TradingSlider, YourOrders, badgeVariants, buttonVariants, extractSparkline, hasPendingActivity, useAdaptivePolling, useToast };
|
|
18579
18711
|
//# sourceMappingURL=index.mjs.map
|
|
18580
18712
|
//# sourceMappingURL=index.mjs.map
|