@loafmarkets/ui 0.1.410 → 0.1.412

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
@@ -1615,12 +1615,23 @@ var StatusDot = styled10.span`
1615
1615
  width: 6px;
1616
1616
  height: 6px;
1617
1617
  border-radius: 50%;
1618
- background: #0ecb81;
1619
1618
  flex-shrink: 0;
1620
- animation: ${breathe} 3s ease-in-out infinite;
1619
+
1620
+ ${({ $state }) => $state === "active" ? css`
1621
+ background: #0ecb81;
1622
+ animation: ${breathe} 3s ease-in-out infinite;
1623
+ ` : $state === "reduced" ? css`
1624
+ background: #e6c87e;
1625
+ box-shadow: 0 0 4px rgba(240, 185, 11, 0.4);
1626
+ ` : $state === "free" ? css`
1627
+ background: #f6465d;
1628
+ box-shadow: 0 0 4px rgba(246, 70, 93, 0.4);
1629
+ ` : css`
1630
+ background: rgba(255, 255, 255, 0.3);
1631
+ `}
1621
1632
  `;
1622
1633
  var LoafLiquidityBadge = React5.forwardRef(
1623
- ({ className, isGlowing, onClick, children, ...props }, ref) => {
1634
+ ({ className, isGlowing, status = "unknown", onClick, children, ...props }, ref) => {
1624
1635
  return /* @__PURE__ */ jsxs(
1625
1636
  LogoContainer,
1626
1637
  {
@@ -1631,11 +1642,11 @@ var LoafLiquidityBadge = React5.forwardRef(
1631
1642
  role: onClick ? "button" : void 0,
1632
1643
  ...props,
1633
1644
  children: [
1634
- /* @__PURE__ */ jsxs(LogoText, { children: [
1645
+ /* @__PURE__ */ jsxs(LogoText, { className: "loaf-ll-label", children: [
1635
1646
  /* @__PURE__ */ jsx(LoafLogoImage, { src: Loaf_logo_Banner_default, alt: "Loaf" }),
1636
1647
  /* @__PURE__ */ jsx(LiquidityText, { children: children ?? "Liquidity" })
1637
1648
  ] }),
1638
- /* @__PURE__ */ jsx(StatusDot, {})
1649
+ /* @__PURE__ */ jsx(StatusDot, { $state: status, "data-liquidity": status })
1639
1650
  ]
1640
1651
  }
1641
1652
  );
@@ -1882,13 +1893,21 @@ var Orderbook = React5.forwardRef(
1882
1893
  isLoading = false,
1883
1894
  onPriceClick,
1884
1895
  onLoafLiquidityClick,
1896
+ liquidityStatus,
1885
1897
  tradeExplorerUrl,
1886
1898
  maxLevels,
1887
1899
  fillHeight = false,
1888
1900
  className,
1889
1901
  ...props
1890
1902
  }, ref) => {
1891
- const resolvedRightHeader = rightHeader ?? /* @__PURE__ */ jsx(LoafLiquidityBadge, { className: "text-[0.6rem] orderbook-ll-badge", onClick: onLoafLiquidityClick });
1903
+ const resolvedRightHeader = rightHeader ?? /* @__PURE__ */ jsx(
1904
+ LoafLiquidityBadge,
1905
+ {
1906
+ className: "text-[0.6rem] orderbook-ll-badge",
1907
+ onClick: onLoafLiquidityClick,
1908
+ status: liquidityStatus
1909
+ }
1910
+ );
1892
1911
  const [tab, setTabState] = React5.useState(defaultTab);
1893
1912
  const setTab = setTabState;
1894
1913
  const effectiveTab = showTradesTab ? tab : "orderbook";
@@ -15178,6 +15197,7 @@ function PortfolioActivityPanel({
15178
15197
  onSharePosition,
15179
15198
  onAssetClick,
15180
15199
  onClosePosition,
15200
+ onCloseAllPositions,
15181
15201
  offeringOrders = [],
15182
15202
  openOrders = [],
15183
15203
  orderHistory = [],
@@ -15202,6 +15222,8 @@ function PortfolioActivityPanel({
15202
15222
  const [cancellingAll, setCancellingAll] = useState(false);
15203
15223
  const [closeAllOpen, setCloseAllOpen] = useState(false);
15204
15224
  const [closeAllType, setCloseAllType] = useState("market");
15225
+ const [closingAll, setClosingAll] = useState(false);
15226
+ const hasPositionActions = !!(onClosePosition || onSharePosition || onCloseAllPositions);
15205
15227
  const [posSortKey, setPosSortKey] = useState("asset");
15206
15228
  const [posSortAsc, setPosSortAsc] = useState(true);
15207
15229
  const handlePosSort = (key) => {
@@ -15380,7 +15402,6 @@ function PortfolioActivityPanel({
15380
15402
  const pagedTradeHistory = sortedTradeHistory.slice(currentPage * pageSize, (currentPage + 1) * pageSize);
15381
15403
  const pagedTransfers = sortedTransfers.slice(currentPage * pageSize, (currentPage + 1) * pageSize);
15382
15404
  return /* @__PURE__ */ jsxs(Container2, { className, style, children: [
15383
- /* @__PURE__ */ jsx(PanelTitle, { children: "Activity" }),
15384
15405
  /* @__PURE__ */ jsxs(TabContainer, { children: [
15385
15406
  showPositionsTab && /* @__PURE__ */ jsxs(Tab, { $active: activeTab === "positions", onClick: () => handleTabChange("positions"), children: [
15386
15407
  "Trading Positions",
@@ -15436,7 +15457,7 @@ function PortfolioActivityPanel({
15436
15457
  ] }),
15437
15458
  /* @__PURE__ */ jsxs(CToolbarActions, { children: [
15438
15459
  /* @__PURE__ */ jsx(CToolbarLink, { onClick: toggleExpandAll, children: allExpanded ? "Collapse All" : "Expand All" }),
15439
- onClosePosition && /* @__PURE__ */ jsx(CToolbarLink, { onClick: () => setCloseAllOpen(true), children: "Sell All" })
15460
+ onCloseAllPositions && /* @__PURE__ */ jsx(CToolbarLink, { onClick: () => setCloseAllOpen(true), children: "Sell All" })
15440
15461
  ] })
15441
15462
  ] }),
15442
15463
  sortedPositions.map((pos) => {
@@ -15512,7 +15533,7 @@ function PortfolioActivityPanel({
15512
15533
  })
15513
15534
  ] }),
15514
15535
  positions.length > 0 && !compactPositions && /* @__PURE__ */ jsxs(Fragment, { children: [
15515
- /* @__PURE__ */ jsxs(PositionsHeader, { $hasClose: !!(onClosePosition || onSharePosition), children: [
15536
+ /* @__PURE__ */ jsxs(PositionsHeader, { $hasClose: hasPositionActions, children: [
15516
15537
  /* @__PURE__ */ jsxs(SortableHeaderCell, { $active: posSortKey === "asset", onClick: () => handlePosSort("asset"), children: [
15517
15538
  "Asset ",
15518
15539
  posSortKey === "asset" && (posSortAsc ? "\u2191" : "\u2193")
@@ -15537,7 +15558,7 @@ function PortfolioActivityPanel({
15537
15558
  "PNL (%) ",
15538
15559
  posSortKey === "pnl" && (posSortAsc ? "\u2191" : "\u2193")
15539
15560
  ] }),
15540
- onClosePosition && /* @__PURE__ */ jsx(PositionsHeaderCell, { children: /* @__PURE__ */ jsx(CloseAllHeaderBtn, { onClick: () => setCloseAllOpen(true), children: "Sell All" }) })
15561
+ onCloseAllPositions && /* @__PURE__ */ jsx(PositionsHeaderCell, { children: /* @__PURE__ */ jsx(CloseAllHeaderBtn, { onClick: () => setCloseAllOpen(true), children: "Sell All" }) })
15541
15562
  ] }),
15542
15563
  sortedPositions.map((pos) => {
15543
15564
  const currentValue = pos.totalQuantity * pos.marketPrice;
@@ -15545,7 +15566,7 @@ function PortfolioActivityPanel({
15545
15566
  const pnl = pos.propertyPnl ?? currentValue - costBasis;
15546
15567
  const pnlPercent = pos.propertyPnlPercent ?? pos.percentChange ?? 0;
15547
15568
  const isPositive = pnl >= 0;
15548
- return /* @__PURE__ */ jsxs(PositionsRow, { $hasClose: !!(onClosePosition || onSharePosition), children: [
15569
+ return /* @__PURE__ */ jsxs(PositionsRow, { $hasClose: hasPositionActions, children: [
15549
15570
  /* @__PURE__ */ jsx(PositionsCell, { children: /* @__PURE__ */ jsxs("span", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
15550
15571
  /* @__PURE__ */ jsx(HoldingsPropertyLink, { onClick: () => onPositionClick?.(pos.tokenName, pos.isIpoAllocation), children: pos.tokenName }),
15551
15572
  pos.settling && /* @__PURE__ */ jsx(SettlingTip, { children: /* @__PURE__ */ jsx(SettlingSpinner, {}) })
@@ -15592,11 +15613,15 @@ function PortfolioActivityPanel({
15592
15613
  ] }, pos.tokenName);
15593
15614
  })
15594
15615
  ] }),
15595
- positions.length > 0 && closeAllOpen && onClosePosition && typeof document !== "undefined" && createPortal(
15596
- /* @__PURE__ */ jsx(CloseAllOverlay, { onClick: () => setCloseAllOpen(false), children: /* @__PURE__ */ jsxs(CloseAllModal, { onClick: (e) => e.stopPropagation(), children: [
15597
- /* @__PURE__ */ jsx(CloseAllModalX, { onClick: () => setCloseAllOpen(false), children: "\xD7" }),
15616
+ positions.length > 0 && closeAllOpen && onCloseAllPositions && typeof document !== "undefined" && createPortal(
15617
+ /* @__PURE__ */ jsx(CloseAllOverlay, { onClick: () => {
15618
+ if (!closingAll) setCloseAllOpen(false);
15619
+ }, children: /* @__PURE__ */ jsxs(CloseAllModal, { onClick: (e) => e.stopPropagation(), children: [
15620
+ /* @__PURE__ */ jsx(CloseAllModalX, { onClick: () => {
15621
+ if (!closingAll) setCloseAllOpen(false);
15622
+ }, children: "\xD7" }),
15598
15623
  /* @__PURE__ */ jsx(CloseAllTitle, { children: "Confirm Sell All" }),
15599
- /* @__PURE__ */ jsx(CloseAllDesc, { children: "This will sell all your positions and cancel their associated TP/SL orders." }),
15624
+ /* @__PURE__ */ jsx(CloseAllDesc, { children: "This places a sell order for every position you hold, one at a time." }),
15600
15625
  /* @__PURE__ */ jsxs(CloseAllOption, { onClick: () => setCloseAllType("market"), children: [
15601
15626
  /* @__PURE__ */ jsx(CloseAllRadio, { $selected: closeAllType === "market" }),
15602
15627
  /* @__PURE__ */ jsx("span", { children: "Market Sell" })
@@ -15605,14 +15630,22 @@ function PortfolioActivityPanel({
15605
15630
  /* @__PURE__ */ jsx(CloseAllRadio, { $selected: closeAllType === "limit" }),
15606
15631
  /* @__PURE__ */ jsx("span", { children: "Limit Sell at Mid Price" })
15607
15632
  ] }),
15608
- /* @__PURE__ */ jsxs(CloseAllConfirmBtn, { onClick: () => {
15609
- positions.forEach((pos) => onClosePosition(pos.tokenName, closeAllType, pos.quantity, pos.marketPrice));
15610
- setCloseAllOpen(false);
15611
- }, children: [
15612
- "Confirm ",
15613
- closeAllType === "market" ? "Market" : "Limit",
15614
- " Sell"
15615
- ] })
15633
+ /* @__PURE__ */ jsx(
15634
+ CloseAllConfirmBtn,
15635
+ {
15636
+ disabled: closingAll,
15637
+ onClick: async () => {
15638
+ setClosingAll(true);
15639
+ try {
15640
+ await onCloseAllPositions(closeAllType);
15641
+ } finally {
15642
+ setClosingAll(false);
15643
+ setCloseAllOpen(false);
15644
+ }
15645
+ },
15646
+ children: closingAll ? "Selling\u2026" : `Confirm ${closeAllType === "market" ? "Market" : "Limit"} Sell`
15647
+ }
15648
+ )
15616
15649
  ] }) }),
15617
15650
  document.body
15618
15651
  )
@@ -16171,17 +16204,6 @@ var ContentScroll = styled10.div`
16171
16204
  &::-webkit-scrollbar-track { background: transparent; }
16172
16205
  &::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 2px; }
16173
16206
  `;
16174
- var PanelTitle = styled10.h3`
16175
- font-size: 1rem;
16176
- font-weight: 600;
16177
- color: var(--color-text, #fff);
16178
- margin: 0 0 0.75rem;
16179
- padding-left: 1rem;
16180
- /* Redundant on mobile — the tab row already says what this is. Reclaim the space. */
16181
- @media (max-width: 768px) {
16182
- display: none;
16183
- }
16184
- `;
16185
16207
  var TabContainer = styled10.div`
16186
16208
  display: flex;
16187
16209
  gap: 0;
@@ -16634,9 +16656,14 @@ var CloseAllConfirmBtn = styled10.button`
16634
16656
  cursor: pointer;
16635
16657
  transition: all 0.15s ease;
16636
16658
 
16637
- &:hover {
16659
+ &:hover:not(:disabled) {
16638
16660
  background: rgba(246, 70, 93, 0.25);
16639
16661
  }
16662
+
16663
+ &:disabled {
16664
+ opacity: 0.5;
16665
+ cursor: not-allowed;
16666
+ }
16640
16667
  `;
16641
16668
  var CToolbar = styled10.div`
16642
16669
  display: flex;