kaleido-ui 0.1.10 → 0.1.11

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.
@@ -5518,7 +5518,23 @@ function DepositPreGeneration({
5518
5518
  }
5519
5519
 
5520
5520
  // src/web/components/deposit-asset-selection.tsx
5521
+ var import_react14 = require("react");
5521
5522
  var import_jsx_runtime58 = require("react/jsx-runtime");
5523
+ var PROTOCOL_BADGE = {
5524
+ RGB: { label: "RGB", className: "bg-network-rgb-chip text-network-rgb-text" },
5525
+ SPARK: { label: "Spark", className: "bg-network-spark-chip text-network-spark-text" },
5526
+ ARKADE: { label: "Arkade", className: "bg-network-arkade-chip text-network-arkade-text" }
5527
+ };
5528
+ function formatAssetBalance(asset) {
5529
+ const raw = asset.balance ?? 0;
5530
+ if (raw === 0) return "0";
5531
+ const precision = asset.precision ?? 0;
5532
+ const value = raw / Math.pow(10, precision);
5533
+ return value.toLocaleString("en-US", {
5534
+ minimumFractionDigits: 0,
5535
+ maximumFractionDigits: Math.min(precision, 8)
5536
+ });
5537
+ }
5522
5538
  function NetBadge({ icon, className }) {
5523
5539
  return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: cn("inline-flex items-center justify-center rounded border px-1.5 py-0.5", className), children: icon });
5524
5540
  }
@@ -5539,8 +5555,15 @@ function DepositAssetSelection({
5539
5555
  isArkadeConnected
5540
5556
  }) {
5541
5557
  const btcAsset = filteredAssets.find((asset) => asset.ticker === "BTC");
5542
- const rgbAssets = filteredAssets.filter((asset) => asset.ticker !== "BTC");
5558
+ const ownedAssets = filteredAssets.filter((asset) => asset.ticker !== "BTC").slice().sort((a, b) => (b.balance ?? 0) - (a.balance ?? 0));
5559
+ const ownedAssetsCount = ownedAssets.length;
5543
5560
  const noResults = filteredAssets.length === 0 && !!searchQuery;
5561
+ const isSearching = !!searchQuery;
5562
+ const [assetsExpanded, setAssetsExpanded] = (0, import_react14.useState)(false);
5563
+ (0, import_react14.useEffect)(() => {
5564
+ if (isSearching) setAssetsExpanded(true);
5565
+ }, [isSearching]);
5566
+ const showOwnedAssets = isSearching ? true : assetsExpanded;
5544
5567
  const newAssetOptions = [
5545
5568
  {
5546
5569
  account: "RGB",
@@ -5654,42 +5677,66 @@ function DepositAssetSelection({
5654
5677
  'No assets match "',
5655
5678
  searchQuery,
5656
5679
  '"'
5657
- ] }) : rgbAssets.map((asset) => /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
5658
- "button",
5659
- {
5660
- type: "button",
5661
- className: "group flex w-full items-center gap-3 rounded-2xl border border-white/8 bg-white/3 px-4 py-3 text-sm transition-all hover:border-border hover:bg-accent",
5662
- onClick: () => onSelectAsset(asset),
5663
- children: [
5664
- /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "relative flex-shrink-0", children: [
5665
- /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(AssetIcon, { ticker: asset.ticker, size: 40 }),
5666
- /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "absolute -bottom-1 -right-1 flex size-4 items-center justify-center rounded-full border bg-card", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("img", { src: "/icons/rgb/rgb-logo.svg", className: "block h-2.5 w-2.5 object-contain", alt: "RGB" }) })
5667
- ] }),
5668
- /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "min-w-0 flex-1 text-left", children: [
5669
- /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "font-bold tracking-wide text-white transition-colors group-hover:text-primary/90", children: asset.ticker }),
5670
- /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "mt-0.5 truncate text-xs text-white/40", children: asset.name ?? "RGB Asset" })
5671
- ] }),
5672
- /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "flex flex-shrink-0 gap-1", children: [
5673
- /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
5674
- NetBadge,
5675
- {
5676
- className: "border-network-bitcoin/20 bg-network-bitcoin/15",
5677
- icon: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "material-symbols-outlined leading-none text-network-bitcoin", style: { fontSize: 10 }, children: "link" })
5678
- }
5679
- ),
5680
- /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
5681
- NetBadge,
5682
- {
5683
- className: "border-warning/20 bg-warning/15",
5684
- icon: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("img", { src: "/icons/lightning/lightning.svg", className: "h-2.5 w-2.5", alt: "" })
5685
- }
5686
- )
5687
- ] }),
5688
- /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "material-symbols-outlined flex-shrink-0 text-icon-md text-white/20 transition-colors group-hover:text-white/50", children: "arrow_forward" })
5689
- ]
5690
- },
5691
- asset.asset_id
5692
- )),
5680
+ ] }) : ownedAssetsCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "space-y-1.5 pt-1", children: [
5681
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
5682
+ "button",
5683
+ {
5684
+ type: "button",
5685
+ "data-testid": "deposit-toggle-owned-assets",
5686
+ onClick: () => !isSearching && setAssetsExpanded((value) => !value),
5687
+ disabled: isSearching,
5688
+ className: cn(
5689
+ "flex w-full items-center gap-2 rounded-2xl border px-4 py-2.5 transition-all",
5690
+ showOwnedAssets ? "border-white/10 bg-white/4" : "border-white/8 bg-white/3 hover:border-border hover:bg-accent",
5691
+ isSearching && "cursor-default"
5692
+ ),
5693
+ children: [
5694
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "text-xxs font-bold uppercase tracking-[0.18em] text-white/55", children: "Your assets" }),
5695
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "rounded-full bg-white/10 px-1.5 py-0.5 text-tiny font-bold text-white/70", children: ownedAssetsCount }),
5696
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "flex-1" }),
5697
+ !isSearching && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "material-symbols-outlined text-icon-md text-white/40", children: showOwnedAssets ? "expand_less" : "expand_more" })
5698
+ ]
5699
+ }
5700
+ ),
5701
+ showOwnedAssets && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "space-y-1.5 duration-200 animate-in fade-in slide-in-from-top-1", children: ownedAssets.map((asset) => {
5702
+ const protocolBadge = asset.accountId ? PROTOCOL_BADGE[asset.accountId] : null;
5703
+ const balance = asset.balance ?? 0;
5704
+ return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
5705
+ "button",
5706
+ {
5707
+ type: "button",
5708
+ "data-testid": `deposit-asset-${asset.asset_id}`,
5709
+ className: "group flex w-full items-center gap-3 rounded-2xl border border-white/8 bg-white/3 px-4 py-3 text-sm transition-all hover:border-border hover:bg-accent",
5710
+ onClick: () => onSelectAsset(asset),
5711
+ children: [
5712
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(AssetIcon, { ticker: asset.ticker, size: 40, className: "flex-shrink-0" }),
5713
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "min-w-0 flex-1 text-left", children: [
5714
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "flex items-center gap-1.5", children: [
5715
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "truncate font-bold tracking-wide text-white transition-colors group-hover:text-primary/90", children: asset.ticker }),
5716
+ protocolBadge && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
5717
+ "span",
5718
+ {
5719
+ className: cn(
5720
+ "shrink-0 rounded-full px-1.5 py-0.5 text-tiny font-bold uppercase tracking-wider",
5721
+ protocolBadge.className
5722
+ ),
5723
+ children: protocolBadge.label
5724
+ }
5725
+ )
5726
+ ] }),
5727
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "mt-0.5 truncate text-xs text-white/40", children: asset.name ?? "Asset" })
5728
+ ] }),
5729
+ balance > 0 && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "flex-shrink-0 text-right", children: [
5730
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "font-mono text-xs font-bold text-white", children: formatAssetBalance(asset) }),
5731
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "mt-0.5 text-tiny uppercase tracking-wider text-white/35", children: asset.ticker })
5732
+ ] }),
5733
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "material-symbols-outlined flex-shrink-0 text-icon-sm text-white/20 transition-colors group-hover:text-white/50", children: "arrow_forward" })
5734
+ ]
5735
+ },
5736
+ asset.asset_id
5737
+ );
5738
+ }) })
5739
+ ] }) : null,
5693
5740
  !searchQuery && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "pb-1 pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
5694
5741
  "button",
5695
5742
  {
@@ -1171,6 +1171,10 @@ interface DepositSelectionAsset {
1171
1171
  ticker: string;
1172
1172
  name?: string;
1173
1173
  precision?: number;
1174
+ /** Account/protocol the asset lives on — drives the protocol badge in "Your assets". */
1175
+ accountId?: DepositAccountId;
1176
+ /** Spendable balance in raw (smallest) units; used for sorting and the right-aligned amount. */
1177
+ balance?: number;
1174
1178
  }
1175
1179
  interface DepositAssetSelectionProps<TView extends string = string> {
1176
1180
  setCurrentView: (view: TView) => void;
@@ -1171,6 +1171,10 @@ interface DepositSelectionAsset {
1171
1171
  ticker: string;
1172
1172
  name?: string;
1173
1173
  precision?: number;
1174
+ /** Account/protocol the asset lives on — drives the protocol badge in "Your assets". */
1175
+ accountId?: DepositAccountId;
1176
+ /** Spendable balance in raw (smallest) units; used for sorting and the right-aligned amount. */
1177
+ balance?: number;
1174
1178
  }
1175
1179
  interface DepositAssetSelectionProps<TView extends string = string> {
1176
1180
  setCurrentView: (view: TView) => void;
package/dist/web/index.js CHANGED
@@ -5363,7 +5363,23 @@ function DepositPreGeneration({
5363
5363
  }
5364
5364
 
5365
5365
  // src/web/components/deposit-asset-selection.tsx
5366
+ import { useEffect as useEffect7, useState as useState13 } from "react";
5366
5367
  import { Fragment as Fragment13, jsx as jsx58, jsxs as jsxs45 } from "react/jsx-runtime";
5368
+ var PROTOCOL_BADGE = {
5369
+ RGB: { label: "RGB", className: "bg-network-rgb-chip text-network-rgb-text" },
5370
+ SPARK: { label: "Spark", className: "bg-network-spark-chip text-network-spark-text" },
5371
+ ARKADE: { label: "Arkade", className: "bg-network-arkade-chip text-network-arkade-text" }
5372
+ };
5373
+ function formatAssetBalance(asset) {
5374
+ const raw = asset.balance ?? 0;
5375
+ if (raw === 0) return "0";
5376
+ const precision = asset.precision ?? 0;
5377
+ const value = raw / Math.pow(10, precision);
5378
+ return value.toLocaleString("en-US", {
5379
+ minimumFractionDigits: 0,
5380
+ maximumFractionDigits: Math.min(precision, 8)
5381
+ });
5382
+ }
5367
5383
  function NetBadge({ icon, className }) {
5368
5384
  return /* @__PURE__ */ jsx58("span", { className: cn("inline-flex items-center justify-center rounded border px-1.5 py-0.5", className), children: icon });
5369
5385
  }
@@ -5384,8 +5400,15 @@ function DepositAssetSelection({
5384
5400
  isArkadeConnected
5385
5401
  }) {
5386
5402
  const btcAsset = filteredAssets.find((asset) => asset.ticker === "BTC");
5387
- const rgbAssets = filteredAssets.filter((asset) => asset.ticker !== "BTC");
5403
+ const ownedAssets = filteredAssets.filter((asset) => asset.ticker !== "BTC").slice().sort((a, b) => (b.balance ?? 0) - (a.balance ?? 0));
5404
+ const ownedAssetsCount = ownedAssets.length;
5388
5405
  const noResults = filteredAssets.length === 0 && !!searchQuery;
5406
+ const isSearching = !!searchQuery;
5407
+ const [assetsExpanded, setAssetsExpanded] = useState13(false);
5408
+ useEffect7(() => {
5409
+ if (isSearching) setAssetsExpanded(true);
5410
+ }, [isSearching]);
5411
+ const showOwnedAssets = isSearching ? true : assetsExpanded;
5389
5412
  const newAssetOptions = [
5390
5413
  {
5391
5414
  account: "RGB",
@@ -5499,42 +5522,66 @@ function DepositAssetSelection({
5499
5522
  'No assets match "',
5500
5523
  searchQuery,
5501
5524
  '"'
5502
- ] }) : rgbAssets.map((asset) => /* @__PURE__ */ jsxs45(
5503
- "button",
5504
- {
5505
- type: "button",
5506
- className: "group flex w-full items-center gap-3 rounded-2xl border border-white/8 bg-white/3 px-4 py-3 text-sm transition-all hover:border-border hover:bg-accent",
5507
- onClick: () => onSelectAsset(asset),
5508
- children: [
5509
- /* @__PURE__ */ jsxs45("div", { className: "relative flex-shrink-0", children: [
5510
- /* @__PURE__ */ jsx58(AssetIcon, { ticker: asset.ticker, size: 40 }),
5511
- /* @__PURE__ */ jsx58("div", { className: "absolute -bottom-1 -right-1 flex size-4 items-center justify-center rounded-full border bg-card", children: /* @__PURE__ */ jsx58("img", { src: "/icons/rgb/rgb-logo.svg", className: "block h-2.5 w-2.5 object-contain", alt: "RGB" }) })
5512
- ] }),
5513
- /* @__PURE__ */ jsxs45("div", { className: "min-w-0 flex-1 text-left", children: [
5514
- /* @__PURE__ */ jsx58("div", { className: "font-bold tracking-wide text-white transition-colors group-hover:text-primary/90", children: asset.ticker }),
5515
- /* @__PURE__ */ jsx58("div", { className: "mt-0.5 truncate text-xs text-white/40", children: asset.name ?? "RGB Asset" })
5516
- ] }),
5517
- /* @__PURE__ */ jsxs45("div", { className: "flex flex-shrink-0 gap-1", children: [
5518
- /* @__PURE__ */ jsx58(
5519
- NetBadge,
5520
- {
5521
- className: "border-network-bitcoin/20 bg-network-bitcoin/15",
5522
- icon: /* @__PURE__ */ jsx58("span", { className: "material-symbols-outlined leading-none text-network-bitcoin", style: { fontSize: 10 }, children: "link" })
5523
- }
5524
- ),
5525
- /* @__PURE__ */ jsx58(
5526
- NetBadge,
5527
- {
5528
- className: "border-warning/20 bg-warning/15",
5529
- icon: /* @__PURE__ */ jsx58("img", { src: "/icons/lightning/lightning.svg", className: "h-2.5 w-2.5", alt: "" })
5530
- }
5531
- )
5532
- ] }),
5533
- /* @__PURE__ */ jsx58("span", { className: "material-symbols-outlined flex-shrink-0 text-icon-md text-white/20 transition-colors group-hover:text-white/50", children: "arrow_forward" })
5534
- ]
5535
- },
5536
- asset.asset_id
5537
- )),
5525
+ ] }) : ownedAssetsCount > 0 ? /* @__PURE__ */ jsxs45("div", { className: "space-y-1.5 pt-1", children: [
5526
+ /* @__PURE__ */ jsxs45(
5527
+ "button",
5528
+ {
5529
+ type: "button",
5530
+ "data-testid": "deposit-toggle-owned-assets",
5531
+ onClick: () => !isSearching && setAssetsExpanded((value) => !value),
5532
+ disabled: isSearching,
5533
+ className: cn(
5534
+ "flex w-full items-center gap-2 rounded-2xl border px-4 py-2.5 transition-all",
5535
+ showOwnedAssets ? "border-white/10 bg-white/4" : "border-white/8 bg-white/3 hover:border-border hover:bg-accent",
5536
+ isSearching && "cursor-default"
5537
+ ),
5538
+ children: [
5539
+ /* @__PURE__ */ jsx58("span", { className: "text-xxs font-bold uppercase tracking-[0.18em] text-white/55", children: "Your assets" }),
5540
+ /* @__PURE__ */ jsx58("span", { className: "rounded-full bg-white/10 px-1.5 py-0.5 text-tiny font-bold text-white/70", children: ownedAssetsCount }),
5541
+ /* @__PURE__ */ jsx58("div", { className: "flex-1" }),
5542
+ !isSearching && /* @__PURE__ */ jsx58("span", { className: "material-symbols-outlined text-icon-md text-white/40", children: showOwnedAssets ? "expand_less" : "expand_more" })
5543
+ ]
5544
+ }
5545
+ ),
5546
+ showOwnedAssets && /* @__PURE__ */ jsx58("div", { className: "space-y-1.5 duration-200 animate-in fade-in slide-in-from-top-1", children: ownedAssets.map((asset) => {
5547
+ const protocolBadge = asset.accountId ? PROTOCOL_BADGE[asset.accountId] : null;
5548
+ const balance = asset.balance ?? 0;
5549
+ return /* @__PURE__ */ jsxs45(
5550
+ "button",
5551
+ {
5552
+ type: "button",
5553
+ "data-testid": `deposit-asset-${asset.asset_id}`,
5554
+ className: "group flex w-full items-center gap-3 rounded-2xl border border-white/8 bg-white/3 px-4 py-3 text-sm transition-all hover:border-border hover:bg-accent",
5555
+ onClick: () => onSelectAsset(asset),
5556
+ children: [
5557
+ /* @__PURE__ */ jsx58(AssetIcon, { ticker: asset.ticker, size: 40, className: "flex-shrink-0" }),
5558
+ /* @__PURE__ */ jsxs45("div", { className: "min-w-0 flex-1 text-left", children: [
5559
+ /* @__PURE__ */ jsxs45("div", { className: "flex items-center gap-1.5", children: [
5560
+ /* @__PURE__ */ jsx58("span", { className: "truncate font-bold tracking-wide text-white transition-colors group-hover:text-primary/90", children: asset.ticker }),
5561
+ protocolBadge && /* @__PURE__ */ jsx58(
5562
+ "span",
5563
+ {
5564
+ className: cn(
5565
+ "shrink-0 rounded-full px-1.5 py-0.5 text-tiny font-bold uppercase tracking-wider",
5566
+ protocolBadge.className
5567
+ ),
5568
+ children: protocolBadge.label
5569
+ }
5570
+ )
5571
+ ] }),
5572
+ /* @__PURE__ */ jsx58("div", { className: "mt-0.5 truncate text-xs text-white/40", children: asset.name ?? "Asset" })
5573
+ ] }),
5574
+ balance > 0 && /* @__PURE__ */ jsxs45("div", { className: "flex-shrink-0 text-right", children: [
5575
+ /* @__PURE__ */ jsx58("div", { className: "font-mono text-xs font-bold text-white", children: formatAssetBalance(asset) }),
5576
+ /* @__PURE__ */ jsx58("div", { className: "mt-0.5 text-tiny uppercase tracking-wider text-white/35", children: asset.ticker })
5577
+ ] }),
5578
+ /* @__PURE__ */ jsx58("span", { className: "material-symbols-outlined flex-shrink-0 text-icon-sm text-white/20 transition-colors group-hover:text-white/50", children: "arrow_forward" })
5579
+ ]
5580
+ },
5581
+ asset.asset_id
5582
+ );
5583
+ }) })
5584
+ ] }) : null,
5538
5585
  !searchQuery && /* @__PURE__ */ jsx58("div", { className: "pb-1 pt-2", children: /* @__PURE__ */ jsxs45(
5539
5586
  "button",
5540
5587
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kaleido-ui",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "KaleidoSwap shared UI library — design tokens, web components (Tailwind + Radix), and React Native components extending WDK UI Kit",
5
5
  "license": "MIT",
6
6
  "type": "module",