@hanzo/ui 5.3.19 → 5.3.22
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/3d/button.js +298 -1
- package/dist/3d/button.mjs +273 -1
- package/dist/3d/card.js +234 -1
- package/dist/3d/card.mjs +207 -1
- package/dist/3d/carousel.js +371 -1
- package/dist/3d/carousel.mjs +344 -1
- package/dist/3d/grid.js +362 -1
- package/dist/3d/grid.mjs +337 -1
- package/dist/3d/index.js +1518 -1
- package/dist/3d/index.mjs +1472 -1
- package/dist/3d/marquee.js +352 -1
- package/dist/3d/marquee.mjs +327 -1
- package/dist/3d/pin.js +46 -1
- package/dist/3d/pin.mjs +24 -1
- package/dist/accordion.js +80 -1
- package/dist/accordion.mjs +55 -1
- package/dist/alert-dialog.js +220 -1
- package/dist/alert-dialog.mjs +187 -1
- package/dist/alert.js +68 -1
- package/dist/alert.mjs +64 -1
- package/dist/animation/animated-background.js +424 -1
- package/dist/animation/animated-background.mjs +418 -1
- package/dist/animation/animated-beam.js +119 -1
- package/dist/animation/animated-beam.mjs +97 -1
- package/dist/animation/animated-cursor.js +275 -1
- package/dist/animation/animated-cursor.mjs +270 -1
- package/dist/animation/animated-icon.js +357 -2
- package/dist/animation/animated-icon.mjs +351 -2
- package/dist/animation/animated-list.js +339 -1
- package/dist/animation/animated-list.mjs +333 -1
- package/dist/animation/animated-number.js +283 -1
- package/dist/animation/animated-number.mjs +277 -1
- package/dist/animation/animated-testimonials.js +97 -1
- package/dist/animation/animated-testimonials.mjs +75 -1
- package/dist/animation/animated-tooltip.js +67 -1
- package/dist/animation/animated-tooltip.mjs +45 -1
- package/dist/animation/apple-cards-carousel.js +308 -1
- package/dist/animation/apple-cards-carousel.mjs +285 -1
- package/dist/animation/apple-hello-effect.js +60 -1
- package/dist/animation/apple-hello-effect.mjs +38 -1
- package/dist/animation/index.js +1952 -2
- package/dist/animation/index.mjs +1921 -2
- package/dist/avatar.js +71 -1
- package/dist/avatar.mjs +47 -1
- package/dist/badge.js +66 -1
- package/dist/badge.mjs +40 -1
- package/dist/blocks/index.js +1665 -2
- package/dist/blocks/index.mjs +1626 -2
- package/dist/breadcrumb.js +107 -1
- package/dist/breadcrumb.mjs +99 -1
- package/dist/calendar.js +189 -1
- package/dist/calendar.mjs +164 -1
- package/dist/carousel.js +278 -1
- package/dist/carousel.mjs +249 -1
- package/dist/checkbox.js +60 -1
- package/dist/checkbox.mjs +35 -1
- package/dist/code/block.js +226 -2
- package/dist/code/block.mjs +203 -2
- package/dist/code/compare.js +445 -5
- package/dist/code/compare.mjs +422 -5
- package/dist/code/diff.js +430 -12
- package/dist/code/diff.mjs +406 -11
- package/dist/code/editor.js +243 -1
- package/dist/code/editor.mjs +218 -1
- package/dist/code/explorer.js +291 -1
- package/dist/code/explorer.mjs +268 -1
- package/dist/code/index.js +2515 -26
- package/dist/code/index.mjs +2472 -24
- package/dist/code/preview.js +364 -6
- package/dist/code/preview.mjs +341 -6
- package/dist/code/snippet.js +274 -2
- package/dist/code/snippet.mjs +250 -2
- package/dist/code/tabs.js +75 -1
- package/dist/code/tabs.mjs +53 -1
- package/dist/code/terminal.js +437 -3
- package/dist/code/terminal.mjs +414 -3
- package/dist/collapsible.js +33 -1
- package/dist/collapsible.mjs +9 -1
- package/dist/command.js +262 -1
- package/dist/command.mjs +232 -1
- package/dist/context-menu.js +207 -1
- package/dist/context-menu.mjs +171 -1
- package/dist/device/index.js +3 -1
- package/dist/device/index.mjs +2 -0
- package/dist/dialog.js +151 -1
- package/dist/dialog.mjs +121 -1
- package/dist/dock/basic.js +174 -1
- package/dist/dock/basic.mjs +151 -1
- package/dist/dock/index.js +628 -1
- package/dist/dock/index.mjs +601 -1
- package/dist/dock/limelight-nav.js +295 -1
- package/dist/dock/limelight-nav.mjs +274 -1
- package/dist/dock/macos.js +141 -1
- package/dist/dock/macos.mjs +118 -1
- package/dist/dock/menu.js +70 -1
- package/dist/dock/menu.mjs +48 -1
- package/dist/dock/message.js +144 -1
- package/dist/dock/message.mjs +122 -1
- package/dist/drawer.js +115 -1
- package/dist/drawer.mjs +103 -1
- package/dist/dropdown-menu.js +202 -1
- package/dist/dropdown-menu.mjs +166 -1
- package/dist/finance/AdvancedChart.js +48 -2
- package/dist/finance/AdvancedChart.mjs +46 -2
- package/dist/finance/CompanyProfile.js +48 -2
- package/dist/finance/CompanyProfile.mjs +46 -2
- package/dist/finance/CryptoScreener.js +45 -2
- package/dist/finance/CryptoScreener.mjs +43 -2
- package/dist/finance/Financials.js +52 -2
- package/dist/finance/Financials.mjs +50 -2
- package/dist/finance/ForexScreener.js +46 -2
- package/dist/finance/ForexScreener.mjs +44 -2
- package/dist/finance/MarketOverview.js +104 -2
- package/dist/finance/MarketOverview.mjs +102 -2
- package/dist/finance/NewsTimeline.js +44 -2
- package/dist/finance/NewsTimeline.mjs +42 -2
- package/dist/finance/OrderEntry.js +131 -1
- package/dist/finance/OrderEntry.mjs +129 -1
- package/dist/finance/OrdersHistory.js +64 -1
- package/dist/finance/OrdersHistory.mjs +62 -1
- package/dist/finance/PositionsList.js +80 -1
- package/dist/finance/PositionsList.mjs +78 -1
- package/dist/finance/StockScreener.js +46 -2
- package/dist/finance/StockScreener.mjs +44 -2
- package/dist/finance/SymbolInfo.js +46 -2
- package/dist/finance/SymbolInfo.mjs +44 -2
- package/dist/finance/TechnicalAnalysis.js +54 -2
- package/dist/finance/TechnicalAnalysis.mjs +52 -2
- package/dist/finance/TickerTape.js +56 -2
- package/dist/finance/TickerTape.mjs +54 -2
- package/dist/finance/TradingPanel.js +191 -1
- package/dist/finance/TradingPanel.mjs +189 -1
- package/dist/finance/index.js +930 -2
- package/dist/finance/index.mjs +914 -2
- package/dist/form/index.js +155 -1
- package/dist/form/index.mjs +125 -1
- package/dist/form.js +172 -1
- package/dist/form.mjs +142 -1
- package/dist/hover-card.js +58 -1
- package/dist/hover-card.mjs +34 -1
- package/dist/index.js +8467 -192
- package/dist/index.mjs +8087 -192
- package/dist/input-otp.js +79 -1
- package/dist/input-otp.mjs +54 -1
- package/dist/lib/utils.js +28 -1
- package/dist/lib/utils.mjs +24 -1
- package/dist/navigation/index.js +98 -1
- package/dist/navigation/index.mjs +79 -1
- package/dist/navigation-menu.js +149 -1
- package/dist/navigation-menu.mjs +116 -1
- package/dist/pattern/grid-pattern.js +326 -3
- package/dist/pattern/grid-pattern.mjs +303 -3
- package/dist/pattern/index.js +326 -3
- package/dist/pattern/index.mjs +303 -3
- package/dist/popover.js +63 -1
- package/dist/popover.mjs +37 -1
- package/dist/primitives/index.js +8467 -192
- package/dist/primitives/index.mjs +8087 -192
- package/dist/primitives-export.js +8467 -192
- package/dist/primitives-export.mjs +8087 -192
- package/dist/progress.js +62 -1
- package/dist/progress.mjs +37 -1
- package/dist/project/gantt.js +65 -1
- package/dist/project/gantt.mjs +43 -1
- package/dist/project/index.js +636 -1
- package/dist/project/index.mjs +611 -1
- package/dist/project/kanban.js +597 -1
- package/dist/project/kanban.mjs +572 -1
- package/dist/project/list.js +35 -1
- package/dist/project/list.mjs +12 -1
- package/dist/radio-group.js +68 -1
- package/dist/radio-group.mjs +45 -1
- package/dist/resizable.js +72 -1
- package/dist/resizable.mjs +48 -1
- package/dist/scroll-area.js +89 -1
- package/dist/scroll-area.mjs +66 -1
- package/dist/select.js +140 -1
- package/dist/select.mjs +111 -1
- package/dist/separator.js +59 -1
- package/dist/separator.mjs +34 -1
- package/dist/sheet.js +148 -1
- package/dist/sheet.mjs +117 -1
- package/dist/skeleton.js +32 -1
- package/dist/skeleton.mjs +27 -1
- package/dist/slider.js +99 -1
- package/dist/slider.mjs +73 -1
- package/dist/sonner.js +34 -1
- package/dist/sonner.mjs +29 -1
- package/dist/switch.js +62 -1
- package/dist/switch.mjs +37 -1
- package/dist/table.js +110 -1
- package/dist/table.mjs +101 -1
- package/dist/tabs.js +82 -1
- package/dist/tabs.mjs +57 -1
- package/dist/tailwind/index.js +2023 -1
- package/dist/tailwind/index.mjs +2011 -1
- package/dist/textarea.js +78 -1
- package/dist/textarea.mjs +56 -1
- package/dist/toggle-group.js +118 -1
- package/dist/toggle-group.mjs +93 -1
- package/dist/toggle.js +71 -1
- package/dist/toggle.mjs +48 -1
- package/dist/tooltip.js +67 -1
- package/dist/tooltip.mjs +40 -1
- package/dist/types/index.js +57 -1
- package/dist/types/index.mjs +51 -1
- package/dist/ui/announcement.js +129 -1
- package/dist/ui/announcement.mjs +107 -1
- package/dist/ui/avatar-group.js +88 -1
- package/dist/ui/avatar-group.mjs +65 -1
- package/dist/ui/banner.js +85 -1
- package/dist/ui/banner.mjs +62 -1
- package/dist/ui/cursor.js +78 -1
- package/dist/ui/cursor.mjs +56 -1
- package/dist/ui/index.js +475 -1
- package/dist/ui/index.mjs +442 -1
- package/dist/ui/marquee.js +74 -1
- package/dist/ui/marquee.mjs +52 -1
- package/dist/ui/pill.js +85 -1
- package/dist/ui/pill.mjs +62 -1
- package/dist/ui/spinner.js +28 -1
- package/dist/ui/spinner.mjs +26 -1
- package/dist/ui/tags.js +101 -1
- package/dist/ui/tags.mjs +79 -1
- package/dist/ui/ticker.js +73 -1
- package/dist/ui/ticker.mjs +51 -1
- package/dist/util/index.js +457 -1
- package/dist/util/index.mjs +399 -1
- package/package.json +1 -1
|
@@ -1,2 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
function TickerTape() {
|
|
10
|
+
const container = react.useRef(null);
|
|
11
|
+
react.useEffect(() => {
|
|
12
|
+
if (!container.current) return;
|
|
13
|
+
if (container.current.dataset.initialized === "true") {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
container.current.dataset.initialized = "true";
|
|
17
|
+
const script = document.createElement("script");
|
|
18
|
+
script.src = "https://s3.tradingview.com/external-embedding/embed-widget-ticker-tape.js";
|
|
19
|
+
script.type = "text/javascript";
|
|
20
|
+
script.async = true;
|
|
21
|
+
script.innerHTML = JSON.stringify({
|
|
22
|
+
symbols: [
|
|
23
|
+
{ proName: "FOREXCOM:SPXUSD", title: "S&P 500" },
|
|
24
|
+
{ proName: "FOREXCOM:NSXUSD", title: "US 100" },
|
|
25
|
+
{ proName: "FX_IDC:EURUSD", title: "EUR/USD" },
|
|
26
|
+
{ proName: "BITSTAMP:BTCUSD", title: "Bitcoin" },
|
|
27
|
+
{ proName: "BITSTAMP:ETHUSD", title: "Ethereum" },
|
|
28
|
+
{ description: "Tesla", proName: "NASDAQ:TSLA" },
|
|
29
|
+
{ description: "Apple", proName: "NASDAQ:AAPL" },
|
|
30
|
+
{ description: "Amazon", proName: "NASDAQ:AMZN" },
|
|
31
|
+
{ description: "NVIDIA", proName: "NASDAQ:NVDA" },
|
|
32
|
+
{ description: "Microsoft", proName: "NASDAQ:MSFT" },
|
|
33
|
+
{ description: "Google", proName: "NASDAQ:GOOGL" },
|
|
34
|
+
{ description: "Meta", proName: "NASDAQ:META" }
|
|
35
|
+
],
|
|
36
|
+
showSymbolLogo: true,
|
|
37
|
+
isTransparent: false,
|
|
38
|
+
displayMode: "adaptive",
|
|
39
|
+
colorTheme: "dark",
|
|
40
|
+
locale: "en"
|
|
41
|
+
});
|
|
42
|
+
container.current.appendChild(script);
|
|
43
|
+
return () => {
|
|
44
|
+
if (container.current) {
|
|
45
|
+
delete container.current.dataset.initialized;
|
|
46
|
+
const scripts = container.current.querySelectorAll("script");
|
|
47
|
+
scripts.forEach((s) => s.remove());
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}, []);
|
|
51
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container w-full", ref: container, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container__widget" }) });
|
|
52
|
+
}
|
|
53
|
+
__name(TickerTape, "TickerTape");
|
|
54
|
+
var TickerTape_default = react.memo(TickerTape);
|
|
55
|
+
|
|
56
|
+
module.exports = TickerTape_default;
|
|
@@ -1,2 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { memo, useRef, useEffect } from 'react';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
function TickerTape() {
|
|
8
|
+
const container = useRef(null);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (!container.current) return;
|
|
11
|
+
if (container.current.dataset.initialized === "true") {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
container.current.dataset.initialized = "true";
|
|
15
|
+
const script = document.createElement("script");
|
|
16
|
+
script.src = "https://s3.tradingview.com/external-embedding/embed-widget-ticker-tape.js";
|
|
17
|
+
script.type = "text/javascript";
|
|
18
|
+
script.async = true;
|
|
19
|
+
script.innerHTML = JSON.stringify({
|
|
20
|
+
symbols: [
|
|
21
|
+
{ proName: "FOREXCOM:SPXUSD", title: "S&P 500" },
|
|
22
|
+
{ proName: "FOREXCOM:NSXUSD", title: "US 100" },
|
|
23
|
+
{ proName: "FX_IDC:EURUSD", title: "EUR/USD" },
|
|
24
|
+
{ proName: "BITSTAMP:BTCUSD", title: "Bitcoin" },
|
|
25
|
+
{ proName: "BITSTAMP:ETHUSD", title: "Ethereum" },
|
|
26
|
+
{ description: "Tesla", proName: "NASDAQ:TSLA" },
|
|
27
|
+
{ description: "Apple", proName: "NASDAQ:AAPL" },
|
|
28
|
+
{ description: "Amazon", proName: "NASDAQ:AMZN" },
|
|
29
|
+
{ description: "NVIDIA", proName: "NASDAQ:NVDA" },
|
|
30
|
+
{ description: "Microsoft", proName: "NASDAQ:MSFT" },
|
|
31
|
+
{ description: "Google", proName: "NASDAQ:GOOGL" },
|
|
32
|
+
{ description: "Meta", proName: "NASDAQ:META" }
|
|
33
|
+
],
|
|
34
|
+
showSymbolLogo: true,
|
|
35
|
+
isTransparent: false,
|
|
36
|
+
displayMode: "adaptive",
|
|
37
|
+
colorTheme: "dark",
|
|
38
|
+
locale: "en"
|
|
39
|
+
});
|
|
40
|
+
container.current.appendChild(script);
|
|
41
|
+
return () => {
|
|
42
|
+
if (container.current) {
|
|
43
|
+
delete container.current.dataset.initialized;
|
|
44
|
+
const scripts = container.current.querySelectorAll("script");
|
|
45
|
+
scripts.forEach((s) => s.remove());
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}, []);
|
|
49
|
+
return /* @__PURE__ */ jsx("div", { className: "tradingview-widget-container w-full", ref: container, children: /* @__PURE__ */ jsx("div", { className: "tradingview-widget-container__widget" }) });
|
|
50
|
+
}
|
|
51
|
+
__name(TickerTape, "TickerTape");
|
|
52
|
+
var TickerTape_default = memo(TickerTape);
|
|
53
|
+
|
|
54
|
+
export { TickerTape_default as default };
|
|
@@ -1 +1,191 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var lucideReact = require('lucide-react');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
function TradingPanel({ symbol, currentPrice }) {
|
|
11
|
+
const [orderType, setOrderType] = react.useState("buy");
|
|
12
|
+
const [quantity, setQuantity] = react.useState("");
|
|
13
|
+
const [portfolio, setPortfolio] = react.useState(null);
|
|
14
|
+
const [message, setMessage] = react.useState(null);
|
|
15
|
+
react.useEffect(() => {
|
|
16
|
+
loadPortfolio();
|
|
17
|
+
}, []);
|
|
18
|
+
const loadPortfolio = /* @__PURE__ */ __name(() => {
|
|
19
|
+
const storedPortfolio = localStorage.getItem("begm_portfolio");
|
|
20
|
+
if (storedPortfolio) {
|
|
21
|
+
setPortfolio(JSON.parse(storedPortfolio));
|
|
22
|
+
} else {
|
|
23
|
+
const initialPortfolio = {
|
|
24
|
+
cash: 1e5,
|
|
25
|
+
holdings: []
|
|
26
|
+
};
|
|
27
|
+
localStorage.setItem("begm_portfolio", JSON.stringify(initialPortfolio));
|
|
28
|
+
setPortfolio(initialPortfolio);
|
|
29
|
+
}
|
|
30
|
+
}, "loadPortfolio");
|
|
31
|
+
const executeTrade = /* @__PURE__ */ __name(() => {
|
|
32
|
+
if (!quantity || parseFloat(quantity) <= 0) {
|
|
33
|
+
setMessage({ type: "error", text: "Please enter a valid quantity" });
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const qty = parseFloat(quantity);
|
|
37
|
+
const total = qty * currentPrice;
|
|
38
|
+
if (orderType === "buy") {
|
|
39
|
+
if (total > portfolio.cash) {
|
|
40
|
+
setMessage({ type: "error", text: "Insufficient funds" });
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const existingHolding = portfolio.holdings.find((h) => h.symbol === symbol);
|
|
44
|
+
if (existingHolding) {
|
|
45
|
+
const newQuantity = existingHolding.quantity + qty;
|
|
46
|
+
const newAveragePrice = (existingHolding.averagePrice * existingHolding.quantity + currentPrice * qty) / newQuantity;
|
|
47
|
+
existingHolding.quantity = newQuantity;
|
|
48
|
+
existingHolding.averagePrice = newAveragePrice;
|
|
49
|
+
existingHolding.currentPrice = currentPrice;
|
|
50
|
+
} else {
|
|
51
|
+
portfolio.holdings.push({
|
|
52
|
+
symbol,
|
|
53
|
+
quantity: qty,
|
|
54
|
+
averagePrice: currentPrice,
|
|
55
|
+
currentPrice
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
portfolio.cash -= total;
|
|
59
|
+
} else {
|
|
60
|
+
const existingHolding = portfolio.holdings.find((h) => h.symbol === symbol);
|
|
61
|
+
if (!existingHolding || existingHolding.quantity < qty) {
|
|
62
|
+
setMessage({ type: "error", text: "Insufficient shares" });
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
existingHolding.quantity -= qty;
|
|
66
|
+
existingHolding.currentPrice = currentPrice;
|
|
67
|
+
if (existingHolding.quantity === 0) {
|
|
68
|
+
portfolio.holdings = portfolio.holdings.filter((h) => h.symbol !== symbol);
|
|
69
|
+
}
|
|
70
|
+
portfolio.cash += total;
|
|
71
|
+
}
|
|
72
|
+
localStorage.setItem("begm_portfolio", JSON.stringify(portfolio));
|
|
73
|
+
setPortfolio({ ...portfolio });
|
|
74
|
+
const orders = JSON.parse(localStorage.getItem("begm_orders") || "[]");
|
|
75
|
+
orders.push({
|
|
76
|
+
id: `ORD-${Date.now()}`,
|
|
77
|
+
symbol,
|
|
78
|
+
type: orderType,
|
|
79
|
+
quantity: qty,
|
|
80
|
+
price: currentPrice,
|
|
81
|
+
total,
|
|
82
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
83
|
+
status: "completed"
|
|
84
|
+
});
|
|
85
|
+
localStorage.setItem("begm_orders", JSON.stringify(orders));
|
|
86
|
+
setMessage({
|
|
87
|
+
type: "success",
|
|
88
|
+
text: `Successfully ${orderType === "buy" ? "bought" : "sold"} ${qty} shares of ${symbol}`
|
|
89
|
+
});
|
|
90
|
+
setQuantity("");
|
|
91
|
+
setTimeout(() => setMessage(null), 3e3);
|
|
92
|
+
}, "executeTrade");
|
|
93
|
+
const getHoldingInfo = /* @__PURE__ */ __name(() => {
|
|
94
|
+
if (!portfolio) return null;
|
|
95
|
+
const holding2 = portfolio.holdings.find((h) => h.symbol === symbol);
|
|
96
|
+
return holding2;
|
|
97
|
+
}, "getHoldingInfo");
|
|
98
|
+
const holding = getHoldingInfo();
|
|
99
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white/5 border border-white/10 rounded-lg p-6 backdrop-blur-xl", children: [
|
|
100
|
+
/* @__PURE__ */ jsxRuntime.jsxs("h3", { className: "text-lg font-bold text-white mb-4", children: [
|
|
101
|
+
"Trade ",
|
|
102
|
+
symbol
|
|
103
|
+
] }),
|
|
104
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2 mb-4", children: [
|
|
105
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
106
|
+
"button",
|
|
107
|
+
{
|
|
108
|
+
onClick: () => setOrderType("buy"),
|
|
109
|
+
className: `flex-1 py-2 rounded-lg font-medium transition-all ${orderType === "buy" ? "bg-success text-white" : "bg-white/5 text-white/60 hover:bg-white/10"}`,
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.TrendingUp, { size: 16, className: "inline mr-2" }),
|
|
112
|
+
"Buy"
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
),
|
|
116
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
117
|
+
"button",
|
|
118
|
+
{
|
|
119
|
+
onClick: () => setOrderType("sell"),
|
|
120
|
+
className: `flex-1 py-2 rounded-lg font-medium transition-all ${orderType === "sell" ? "bg-danger text-white" : "bg-white/5 text-white/60 hover:bg-white/10"}`,
|
|
121
|
+
children: [
|
|
122
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.TrendingDown, { size: 16, className: "inline mr-2" }),
|
|
123
|
+
"Sell"
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
)
|
|
127
|
+
] }),
|
|
128
|
+
holding && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4 p-3 bg-white/5 rounded-lg", children: [
|
|
129
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-white/60 mb-1", children: "Your Holdings" }),
|
|
130
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-white", children: [
|
|
131
|
+
holding.quantity,
|
|
132
|
+
" shares @ $",
|
|
133
|
+
holding.averagePrice.toFixed(2),
|
|
134
|
+
" avg"
|
|
135
|
+
] })
|
|
136
|
+
] }),
|
|
137
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4 p-3 bg-white/5 rounded-lg", children: [
|
|
138
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-white/60 mb-1", children: "Current Price" }),
|
|
139
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-lg font-bold text-white", children: [
|
|
140
|
+
"$",
|
|
141
|
+
currentPrice.toFixed(2)
|
|
142
|
+
] })
|
|
143
|
+
] }),
|
|
144
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4", children: [
|
|
145
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "block text-sm font-medium text-white/80 mb-2", children: "Quantity (Shares)" }),
|
|
146
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
147
|
+
"input",
|
|
148
|
+
{
|
|
149
|
+
type: "number",
|
|
150
|
+
value: quantity,
|
|
151
|
+
onChange: (e) => setQuantity(e.target.value),
|
|
152
|
+
min: "1",
|
|
153
|
+
step: "1",
|
|
154
|
+
placeholder: "Enter quantity",
|
|
155
|
+
className: "w-full px-4 py-2 bg-white/5 border border-white/10 rounded-lg text-white placeholder-white/40 focus:outline-none focus:border-success"
|
|
156
|
+
}
|
|
157
|
+
)
|
|
158
|
+
] }),
|
|
159
|
+
quantity && parseFloat(quantity) > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-4 p-3 bg-white/5 rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between items-center", children: [
|
|
160
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-white/60", children: "Estimated Total" }),
|
|
161
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-lg font-bold text-white", children: [
|
|
162
|
+
"$",
|
|
163
|
+
(parseFloat(quantity) * currentPrice).toFixed(2)
|
|
164
|
+
] })
|
|
165
|
+
] }) }),
|
|
166
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-4 p-3 bg-white/5 rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between items-center", children: [
|
|
167
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-white/60", children: "Available Cash" }),
|
|
168
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm font-medium text-white", children: [
|
|
169
|
+
"$",
|
|
170
|
+
portfolio?.cash.toLocaleString() || "0"
|
|
171
|
+
] })
|
|
172
|
+
] }) }),
|
|
173
|
+
message && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `mb-4 p-3 rounded-lg ${message.type === "success" ? "bg-success/20 text-success" : "bg-danger/20 text-danger"}`, children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", children: message.text }) }),
|
|
174
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
175
|
+
"button",
|
|
176
|
+
{
|
|
177
|
+
onClick: executeTrade,
|
|
178
|
+
className: `w-full py-3 rounded-lg font-medium transition-all ${orderType === "buy" ? "bg-success hover:bg-success/90 text-white" : "bg-danger hover:bg-danger/90 text-white"}`,
|
|
179
|
+
children: [
|
|
180
|
+
orderType === "buy" ? "Buy" : "Sell",
|
|
181
|
+
" ",
|
|
182
|
+
symbol
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
),
|
|
186
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-white/40 text-center mt-4", children: "This is a demo account. No real money is at risk." })
|
|
187
|
+
] });
|
|
188
|
+
}
|
|
189
|
+
__name(TradingPanel, "TradingPanel");
|
|
190
|
+
|
|
191
|
+
exports.TradingPanel = TradingPanel;
|
|
@@ -1 +1,189 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { TrendingUp, TrendingDown } from 'lucide-react';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
function TradingPanel({ symbol, currentPrice }) {
|
|
9
|
+
const [orderType, setOrderType] = useState("buy");
|
|
10
|
+
const [quantity, setQuantity] = useState("");
|
|
11
|
+
const [portfolio, setPortfolio] = useState(null);
|
|
12
|
+
const [message, setMessage] = useState(null);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
loadPortfolio();
|
|
15
|
+
}, []);
|
|
16
|
+
const loadPortfolio = /* @__PURE__ */ __name(() => {
|
|
17
|
+
const storedPortfolio = localStorage.getItem("begm_portfolio");
|
|
18
|
+
if (storedPortfolio) {
|
|
19
|
+
setPortfolio(JSON.parse(storedPortfolio));
|
|
20
|
+
} else {
|
|
21
|
+
const initialPortfolio = {
|
|
22
|
+
cash: 1e5,
|
|
23
|
+
holdings: []
|
|
24
|
+
};
|
|
25
|
+
localStorage.setItem("begm_portfolio", JSON.stringify(initialPortfolio));
|
|
26
|
+
setPortfolio(initialPortfolio);
|
|
27
|
+
}
|
|
28
|
+
}, "loadPortfolio");
|
|
29
|
+
const executeTrade = /* @__PURE__ */ __name(() => {
|
|
30
|
+
if (!quantity || parseFloat(quantity) <= 0) {
|
|
31
|
+
setMessage({ type: "error", text: "Please enter a valid quantity" });
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const qty = parseFloat(quantity);
|
|
35
|
+
const total = qty * currentPrice;
|
|
36
|
+
if (orderType === "buy") {
|
|
37
|
+
if (total > portfolio.cash) {
|
|
38
|
+
setMessage({ type: "error", text: "Insufficient funds" });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const existingHolding = portfolio.holdings.find((h) => h.symbol === symbol);
|
|
42
|
+
if (existingHolding) {
|
|
43
|
+
const newQuantity = existingHolding.quantity + qty;
|
|
44
|
+
const newAveragePrice = (existingHolding.averagePrice * existingHolding.quantity + currentPrice * qty) / newQuantity;
|
|
45
|
+
existingHolding.quantity = newQuantity;
|
|
46
|
+
existingHolding.averagePrice = newAveragePrice;
|
|
47
|
+
existingHolding.currentPrice = currentPrice;
|
|
48
|
+
} else {
|
|
49
|
+
portfolio.holdings.push({
|
|
50
|
+
symbol,
|
|
51
|
+
quantity: qty,
|
|
52
|
+
averagePrice: currentPrice,
|
|
53
|
+
currentPrice
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
portfolio.cash -= total;
|
|
57
|
+
} else {
|
|
58
|
+
const existingHolding = portfolio.holdings.find((h) => h.symbol === symbol);
|
|
59
|
+
if (!existingHolding || existingHolding.quantity < qty) {
|
|
60
|
+
setMessage({ type: "error", text: "Insufficient shares" });
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
existingHolding.quantity -= qty;
|
|
64
|
+
existingHolding.currentPrice = currentPrice;
|
|
65
|
+
if (existingHolding.quantity === 0) {
|
|
66
|
+
portfolio.holdings = portfolio.holdings.filter((h) => h.symbol !== symbol);
|
|
67
|
+
}
|
|
68
|
+
portfolio.cash += total;
|
|
69
|
+
}
|
|
70
|
+
localStorage.setItem("begm_portfolio", JSON.stringify(portfolio));
|
|
71
|
+
setPortfolio({ ...portfolio });
|
|
72
|
+
const orders = JSON.parse(localStorage.getItem("begm_orders") || "[]");
|
|
73
|
+
orders.push({
|
|
74
|
+
id: `ORD-${Date.now()}`,
|
|
75
|
+
symbol,
|
|
76
|
+
type: orderType,
|
|
77
|
+
quantity: qty,
|
|
78
|
+
price: currentPrice,
|
|
79
|
+
total,
|
|
80
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
81
|
+
status: "completed"
|
|
82
|
+
});
|
|
83
|
+
localStorage.setItem("begm_orders", JSON.stringify(orders));
|
|
84
|
+
setMessage({
|
|
85
|
+
type: "success",
|
|
86
|
+
text: `Successfully ${orderType === "buy" ? "bought" : "sold"} ${qty} shares of ${symbol}`
|
|
87
|
+
});
|
|
88
|
+
setQuantity("");
|
|
89
|
+
setTimeout(() => setMessage(null), 3e3);
|
|
90
|
+
}, "executeTrade");
|
|
91
|
+
const getHoldingInfo = /* @__PURE__ */ __name(() => {
|
|
92
|
+
if (!portfolio) return null;
|
|
93
|
+
const holding2 = portfolio.holdings.find((h) => h.symbol === symbol);
|
|
94
|
+
return holding2;
|
|
95
|
+
}, "getHoldingInfo");
|
|
96
|
+
const holding = getHoldingInfo();
|
|
97
|
+
return /* @__PURE__ */ jsxs("div", { className: "bg-white/5 border border-white/10 rounded-lg p-6 backdrop-blur-xl", children: [
|
|
98
|
+
/* @__PURE__ */ jsxs("h3", { className: "text-lg font-bold text-white mb-4", children: [
|
|
99
|
+
"Trade ",
|
|
100
|
+
symbol
|
|
101
|
+
] }),
|
|
102
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2 mb-4", children: [
|
|
103
|
+
/* @__PURE__ */ jsxs(
|
|
104
|
+
"button",
|
|
105
|
+
{
|
|
106
|
+
onClick: () => setOrderType("buy"),
|
|
107
|
+
className: `flex-1 py-2 rounded-lg font-medium transition-all ${orderType === "buy" ? "bg-success text-white" : "bg-white/5 text-white/60 hover:bg-white/10"}`,
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ jsx(TrendingUp, { size: 16, className: "inline mr-2" }),
|
|
110
|
+
"Buy"
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
/* @__PURE__ */ jsxs(
|
|
115
|
+
"button",
|
|
116
|
+
{
|
|
117
|
+
onClick: () => setOrderType("sell"),
|
|
118
|
+
className: `flex-1 py-2 rounded-lg font-medium transition-all ${orderType === "sell" ? "bg-danger text-white" : "bg-white/5 text-white/60 hover:bg-white/10"}`,
|
|
119
|
+
children: [
|
|
120
|
+
/* @__PURE__ */ jsx(TrendingDown, { size: 16, className: "inline mr-2" }),
|
|
121
|
+
"Sell"
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
] }),
|
|
126
|
+
holding && /* @__PURE__ */ jsxs("div", { className: "mb-4 p-3 bg-white/5 rounded-lg", children: [
|
|
127
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-white/60 mb-1", children: "Your Holdings" }),
|
|
128
|
+
/* @__PURE__ */ jsxs("p", { className: "text-sm text-white", children: [
|
|
129
|
+
holding.quantity,
|
|
130
|
+
" shares @ $",
|
|
131
|
+
holding.averagePrice.toFixed(2),
|
|
132
|
+
" avg"
|
|
133
|
+
] })
|
|
134
|
+
] }),
|
|
135
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-4 p-3 bg-white/5 rounded-lg", children: [
|
|
136
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-white/60 mb-1", children: "Current Price" }),
|
|
137
|
+
/* @__PURE__ */ jsxs("p", { className: "text-lg font-bold text-white", children: [
|
|
138
|
+
"$",
|
|
139
|
+
currentPrice.toFixed(2)
|
|
140
|
+
] })
|
|
141
|
+
] }),
|
|
142
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-4", children: [
|
|
143
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium text-white/80 mb-2", children: "Quantity (Shares)" }),
|
|
144
|
+
/* @__PURE__ */ jsx(
|
|
145
|
+
"input",
|
|
146
|
+
{
|
|
147
|
+
type: "number",
|
|
148
|
+
value: quantity,
|
|
149
|
+
onChange: (e) => setQuantity(e.target.value),
|
|
150
|
+
min: "1",
|
|
151
|
+
step: "1",
|
|
152
|
+
placeholder: "Enter quantity",
|
|
153
|
+
className: "w-full px-4 py-2 bg-white/5 border border-white/10 rounded-lg text-white placeholder-white/40 focus:outline-none focus:border-success"
|
|
154
|
+
}
|
|
155
|
+
)
|
|
156
|
+
] }),
|
|
157
|
+
quantity && parseFloat(quantity) > 0 && /* @__PURE__ */ jsx("div", { className: "mb-4 p-3 bg-white/5 rounded-lg", children: /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
|
|
158
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-white/60", children: "Estimated Total" }),
|
|
159
|
+
/* @__PURE__ */ jsxs("span", { className: "text-lg font-bold text-white", children: [
|
|
160
|
+
"$",
|
|
161
|
+
(parseFloat(quantity) * currentPrice).toFixed(2)
|
|
162
|
+
] })
|
|
163
|
+
] }) }),
|
|
164
|
+
/* @__PURE__ */ jsx("div", { className: "mb-4 p-3 bg-white/5 rounded-lg", children: /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
|
|
165
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-white/60", children: "Available Cash" }),
|
|
166
|
+
/* @__PURE__ */ jsxs("span", { className: "text-sm font-medium text-white", children: [
|
|
167
|
+
"$",
|
|
168
|
+
portfolio?.cash.toLocaleString() || "0"
|
|
169
|
+
] })
|
|
170
|
+
] }) }),
|
|
171
|
+
message && /* @__PURE__ */ jsx("div", { className: `mb-4 p-3 rounded-lg ${message.type === "success" ? "bg-success/20 text-success" : "bg-danger/20 text-danger"}`, children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: message.text }) }),
|
|
172
|
+
/* @__PURE__ */ jsxs(
|
|
173
|
+
"button",
|
|
174
|
+
{
|
|
175
|
+
onClick: executeTrade,
|
|
176
|
+
className: `w-full py-3 rounded-lg font-medium transition-all ${orderType === "buy" ? "bg-success hover:bg-success/90 text-white" : "bg-danger hover:bg-danger/90 text-white"}`,
|
|
177
|
+
children: [
|
|
178
|
+
orderType === "buy" ? "Buy" : "Sell",
|
|
179
|
+
" ",
|
|
180
|
+
symbol
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-white/40 text-center mt-4", children: "This is a demo account. No real money is at risk." })
|
|
185
|
+
] });
|
|
186
|
+
}
|
|
187
|
+
__name(TradingPanel, "TradingPanel");
|
|
188
|
+
|
|
189
|
+
export { TradingPanel };
|