@orangecheck/design 0.2.0 → 0.3.0
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/format.d.mts +19 -0
- package/dist/format.d.ts +19 -0
- package/dist/format.js +68 -0
- package/dist/format.js.map +1 -0
- package/dist/format.mjs +58 -0
- package/dist/format.mjs.map +1 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +379 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +361 -3
- package/dist/index.mjs.map +1 -1
- package/dist/primitives.d.mts +92 -1
- package/dist/primitives.d.ts +92 -1
- package/dist/primitives.js +319 -0
- package/dist/primitives.js.map +1 -1
- package/dist/primitives.mjs +310 -3
- package/dist/primitives.mjs.map +1 -1
- package/package.json +8 -1
package/dist/index.js
CHANGED
|
@@ -15,8 +15,11 @@ var PopoverPrimitive = require('@radix-ui/react-popover');
|
|
|
15
15
|
var AccordionPrimitive = require('@radix-ui/react-accordion');
|
|
16
16
|
var SelectPrimitive = require('@radix-ui/react-select');
|
|
17
17
|
var sonner = require('sonner');
|
|
18
|
+
var QRCode = require('qrcode');
|
|
18
19
|
var ui_star = require('@orangecheck/ui');
|
|
19
20
|
|
|
21
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
|
+
|
|
20
23
|
function _interopNamespace(e) {
|
|
21
24
|
if (e && e.__esModule) return e;
|
|
22
25
|
var n = Object.create(null);
|
|
@@ -42,6 +45,7 @@ var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive)
|
|
|
42
45
|
var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
|
|
43
46
|
var AccordionPrimitive__namespace = /*#__PURE__*/_interopNamespace(AccordionPrimitive);
|
|
44
47
|
var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
|
|
48
|
+
var QRCode__default = /*#__PURE__*/_interopDefault(QRCode);
|
|
45
49
|
var ui_star__namespace = /*#__PURE__*/_interopNamespace(ui_star);
|
|
46
50
|
|
|
47
51
|
var __defProp = Object.defineProperty;
|
|
@@ -75,8 +79,12 @@ __export(src_exports, {
|
|
|
75
79
|
AlertWithAction: () => AlertWithAction,
|
|
76
80
|
AlertWithCountdown: () => AlertWithCountdown,
|
|
77
81
|
Badge: () => Badge,
|
|
82
|
+
Bar: () => Bar,
|
|
83
|
+
BitcoinAddress: () => BitcoinAddress,
|
|
78
84
|
Button: () => Button,
|
|
85
|
+
Card: () => Card,
|
|
79
86
|
ConfirmHost: () => ConfirmHost,
|
|
87
|
+
CopyButton: () => CopyButton,
|
|
80
88
|
DEFAULT_OC_THEME: () => DEFAULT_OC_THEME,
|
|
81
89
|
Dialog: () => Dialog,
|
|
82
90
|
DialogClose: () => DialogClose,
|
|
@@ -103,6 +111,9 @@ __export(src_exports, {
|
|
|
103
111
|
PopoverContent: () => PopoverContent,
|
|
104
112
|
PopoverTrigger: () => PopoverTrigger,
|
|
105
113
|
PromptHost: () => PromptHost,
|
|
114
|
+
QrCode: () => QrCode,
|
|
115
|
+
REFERENCE_BTC_USD: () => REFERENCE_BTC_USD,
|
|
116
|
+
SatsAmount: () => SatsAmount,
|
|
106
117
|
Select: () => Select,
|
|
107
118
|
SelectContent: () => SelectContent,
|
|
108
119
|
SelectGroup: () => SelectGroup,
|
|
@@ -123,6 +134,9 @@ __export(src_exports, {
|
|
|
123
134
|
SheetTitle: () => SheetTitle,
|
|
124
135
|
SheetTrigger: () => SheetTrigger,
|
|
125
136
|
Skeleton: () => Skeleton,
|
|
137
|
+
Sparkline: () => Sparkline,
|
|
138
|
+
StatBlock: () => StatBlock,
|
|
139
|
+
StatusPill: () => StatusPill,
|
|
126
140
|
Textarea: () => Textarea,
|
|
127
141
|
ThemeToggle: () => ThemeToggle,
|
|
128
142
|
ThemeToggleLink: () => ThemeToggleLink,
|
|
@@ -133,10 +147,18 @@ __export(src_exports, {
|
|
|
133
147
|
buttonVariants: () => buttonVariants,
|
|
134
148
|
cn: () => cn,
|
|
135
149
|
confirm: () => confirm,
|
|
150
|
+
explorerUrl: () => explorerUrl,
|
|
151
|
+
formatSats: () => formatSats,
|
|
152
|
+
formatSatsCompact: () => formatSatsCompact,
|
|
136
153
|
getOcThemeInitScript: () => getOcThemeInitScript,
|
|
137
154
|
isKnownTheme: () => isKnownTheme,
|
|
155
|
+
priceBoth: () => priceBoth,
|
|
138
156
|
prompt: () => prompt,
|
|
157
|
+
relativeTime: () => relativeTime,
|
|
139
158
|
resolveTheme: () => resolveTheme,
|
|
159
|
+
satsToUsd: () => satsToUsd,
|
|
160
|
+
shortenAddress: () => shortenAddress,
|
|
161
|
+
usdToSats: () => usdToSats,
|
|
140
162
|
useOcSkin: () => useOcSkin
|
|
141
163
|
});
|
|
142
164
|
function cn(...inputs) {
|
|
@@ -1503,6 +1525,345 @@ var Toaster = ({ ...props }) => {
|
|
|
1503
1525
|
}
|
|
1504
1526
|
);
|
|
1505
1527
|
};
|
|
1528
|
+
function Card({
|
|
1529
|
+
id,
|
|
1530
|
+
title,
|
|
1531
|
+
subtitle,
|
|
1532
|
+
refreshedAt,
|
|
1533
|
+
actions,
|
|
1534
|
+
children,
|
|
1535
|
+
className,
|
|
1536
|
+
tone = "default",
|
|
1537
|
+
expandable = true
|
|
1538
|
+
}) {
|
|
1539
|
+
const [expanded, setExpanded] = React2.useState(false);
|
|
1540
|
+
const toneClass = tone === "warning" ? "border-warning/60" : tone === "destructive" ? "border-destructive/60" : tone === "muted" ? "border-border opacity-90" : "border-border";
|
|
1541
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1542
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1543
|
+
"section",
|
|
1544
|
+
{
|
|
1545
|
+
id,
|
|
1546
|
+
className: cn("terminal flex flex-col rounded-sm border scroll-mt-16", toneClass, className),
|
|
1547
|
+
children: [
|
|
1548
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "terminal-title flex items-center justify-between gap-3", children: [
|
|
1549
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1550
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "terminal-dot", "aria-hidden": true }),
|
|
1551
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "terminal-dot opacity-70", "aria-hidden": true }),
|
|
1552
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "terminal-dot opacity-50", "aria-hidden": true }),
|
|
1553
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2 truncate", children: title }),
|
|
1554
|
+
subtitle && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground/70 ml-1 truncate text-[10px] tracking-normal normal-case", children: [
|
|
1555
|
+
"\xB7 ",
|
|
1556
|
+
subtitle
|
|
1557
|
+
] })
|
|
1558
|
+
] }),
|
|
1559
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1560
|
+
refreshedAt && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground/60 hidden text-[10px] tracking-normal normal-case sm:inline", children: refreshedAt }),
|
|
1561
|
+
actions,
|
|
1562
|
+
expandable && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1563
|
+
"button",
|
|
1564
|
+
{
|
|
1565
|
+
type: "button",
|
|
1566
|
+
onClick: () => setExpanded(true),
|
|
1567
|
+
"aria-label": `expand ${title}`,
|
|
1568
|
+
title: "expand to fullscreen",
|
|
1569
|
+
className: "text-muted-foreground/70 hover:text-foreground inline-flex h-6 w-6 items-center justify-center rounded-sm",
|
|
1570
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Maximize2, { className: "size-3" })
|
|
1571
|
+
}
|
|
1572
|
+
)
|
|
1573
|
+
] })
|
|
1574
|
+
] }),
|
|
1575
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 p-4 sm:p-5", children })
|
|
1576
|
+
]
|
|
1577
|
+
}
|
|
1578
|
+
),
|
|
1579
|
+
expandable && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1580
|
+
Modal,
|
|
1581
|
+
{
|
|
1582
|
+
open: expanded,
|
|
1583
|
+
onOpenChange: setExpanded,
|
|
1584
|
+
title,
|
|
1585
|
+
...subtitle ? { subtitle } : {},
|
|
1586
|
+
actions: refreshedAt ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground/60 hidden text-[10px] tracking-normal normal-case sm:inline", children: refreshedAt }) : null,
|
|
1587
|
+
children
|
|
1588
|
+
}
|
|
1589
|
+
)
|
|
1590
|
+
] });
|
|
1591
|
+
}
|
|
1592
|
+
function Sparkline({ data, width = 96, height = 24, area = false, className }) {
|
|
1593
|
+
if (data.length === 0) {
|
|
1594
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width, height, className: cn(className), "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1595
|
+
"line",
|
|
1596
|
+
{
|
|
1597
|
+
x1: 0,
|
|
1598
|
+
x2: width,
|
|
1599
|
+
y1: height / 2,
|
|
1600
|
+
y2: height / 2,
|
|
1601
|
+
stroke: "currentColor",
|
|
1602
|
+
strokeWidth: 1,
|
|
1603
|
+
opacity: 0.25
|
|
1604
|
+
}
|
|
1605
|
+
) });
|
|
1606
|
+
}
|
|
1607
|
+
const min = Math.min(...data);
|
|
1608
|
+
const max = Math.max(...data);
|
|
1609
|
+
const range = max - min || 1;
|
|
1610
|
+
const step = data.length === 1 ? width : width / (data.length - 1);
|
|
1611
|
+
const points = data.map((v, i) => {
|
|
1612
|
+
const x = i * step;
|
|
1613
|
+
const y = height - (v - min) / range * (height - 2) - 1;
|
|
1614
|
+
return [x, y];
|
|
1615
|
+
});
|
|
1616
|
+
const linePath = points.map(([x, y], i) => `${i === 0 ? "M" : "L"}${x.toFixed(2)},${y.toFixed(2)}`).join(" ");
|
|
1617
|
+
const areaPath = area ? `${linePath} L${width.toFixed(2)},${height.toFixed(2)} L0,${height.toFixed(2)} Z` : null;
|
|
1618
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1619
|
+
"svg",
|
|
1620
|
+
{
|
|
1621
|
+
width,
|
|
1622
|
+
height,
|
|
1623
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
1624
|
+
className: cn("text-primary", className),
|
|
1625
|
+
"aria-hidden": true,
|
|
1626
|
+
children: [
|
|
1627
|
+
areaPath && /* @__PURE__ */ jsxRuntime.jsx("path", { d: areaPath, fill: "currentColor", opacity: 0.12 }),
|
|
1628
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: linePath, fill: "none", stroke: "currentColor", strokeWidth: 1.25 })
|
|
1629
|
+
]
|
|
1630
|
+
}
|
|
1631
|
+
);
|
|
1632
|
+
}
|
|
1633
|
+
function StatBlock({ label, value, sub, delta, tone = "default", className }) {
|
|
1634
|
+
const toneClass = tone === "success" ? "text-success" : tone === "warning" ? "text-warning" : tone === "destructive" ? "text-destructive" : "text-foreground";
|
|
1635
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col gap-1", className), children: [
|
|
1636
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "label-mono text-[10px]", children: label }),
|
|
1637
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("font-display text-2xl leading-none", toneClass), children: value }),
|
|
1638
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-baseline gap-2", children: [
|
|
1639
|
+
sub && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground font-mono text-[11px] tracking-wide lowercase", children: sub }),
|
|
1640
|
+
delta && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1641
|
+
"span",
|
|
1642
|
+
{
|
|
1643
|
+
className: cn(
|
|
1644
|
+
"font-mono text-[11px] tracking-wide",
|
|
1645
|
+
delta.value > 0 ? "text-success" : delta.value < 0 ? "text-destructive" : "text-muted-foreground"
|
|
1646
|
+
),
|
|
1647
|
+
children: [
|
|
1648
|
+
delta.value > 0 ? "\u25B2" : delta.value < 0 ? "\u25BC" : "\xB7",
|
|
1649
|
+
" ",
|
|
1650
|
+
Math.abs(delta.value).toFixed(1),
|
|
1651
|
+
delta.suffix ?? "%"
|
|
1652
|
+
]
|
|
1653
|
+
}
|
|
1654
|
+
)
|
|
1655
|
+
] })
|
|
1656
|
+
] });
|
|
1657
|
+
}
|
|
1658
|
+
var ACCENT = {
|
|
1659
|
+
primary: "bg-primary",
|
|
1660
|
+
warning: "bg-warning",
|
|
1661
|
+
destructive: "bg-destructive",
|
|
1662
|
+
success: "bg-success"
|
|
1663
|
+
};
|
|
1664
|
+
function Bar({ pct, accent = "primary", label, right, className }) {
|
|
1665
|
+
const clamped = Math.max(0, Math.min(100, pct));
|
|
1666
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(className), children: [
|
|
1667
|
+
(label || right) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-baseline justify-between font-mono text-[10.5px] tracking-widest uppercase", children: [
|
|
1668
|
+
label && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: label }),
|
|
1669
|
+
right && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground tabular-nums", children: right })
|
|
1670
|
+
] }),
|
|
1671
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted mt-1.5 h-1.5 w-full overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("h-full", ACCENT[accent]), style: { width: `${clamped}%` } }) })
|
|
1672
|
+
] });
|
|
1673
|
+
}
|
|
1674
|
+
var TONE = {
|
|
1675
|
+
success: "text-success",
|
|
1676
|
+
warning: "text-warning",
|
|
1677
|
+
destructive: "text-destructive",
|
|
1678
|
+
muted: "text-muted-foreground",
|
|
1679
|
+
primary: "text-primary",
|
|
1680
|
+
info: "text-info"
|
|
1681
|
+
};
|
|
1682
|
+
function StatusPill({ label, tone = "muted", icon, className }) {
|
|
1683
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1684
|
+
"span",
|
|
1685
|
+
{
|
|
1686
|
+
className: cn(
|
|
1687
|
+
"inline-flex items-center gap-1.5 font-mono text-[11px] tracking-wider lowercase",
|
|
1688
|
+
TONE[tone],
|
|
1689
|
+
className
|
|
1690
|
+
),
|
|
1691
|
+
children: [
|
|
1692
|
+
icon,
|
|
1693
|
+
label
|
|
1694
|
+
]
|
|
1695
|
+
}
|
|
1696
|
+
);
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
// src/format/index.ts
|
|
1700
|
+
var REFERENCE_BTC_USD = 95e3;
|
|
1701
|
+
function formatSats(sats) {
|
|
1702
|
+
return new Intl.NumberFormat("en-US").format(Math.round(sats));
|
|
1703
|
+
}
|
|
1704
|
+
function formatSatsCompact(sats) {
|
|
1705
|
+
const n = Math.round(sats);
|
|
1706
|
+
if (n < 1e3) return `${n} sats`;
|
|
1707
|
+
const k = n / 1e3;
|
|
1708
|
+
return `${Number.isInteger(k) ? k : k.toFixed(1)}k sats`;
|
|
1709
|
+
}
|
|
1710
|
+
function satsToUsd(sats, btcUsd = REFERENCE_BTC_USD) {
|
|
1711
|
+
const usd = sats / 1e8 * btcUsd;
|
|
1712
|
+
if (usd > 0 && usd < 0.01) return "< $0.01";
|
|
1713
|
+
const fractionDigits = usd >= 100 ? 0 : 2;
|
|
1714
|
+
return new Intl.NumberFormat("en-US", {
|
|
1715
|
+
style: "currency",
|
|
1716
|
+
currency: "USD",
|
|
1717
|
+
minimumFractionDigits: fractionDigits,
|
|
1718
|
+
maximumFractionDigits: fractionDigits
|
|
1719
|
+
}).format(usd);
|
|
1720
|
+
}
|
|
1721
|
+
function usdToSats(usd, btcUsd = REFERENCE_BTC_USD) {
|
|
1722
|
+
return Math.round(usd / btcUsd * 1e8);
|
|
1723
|
+
}
|
|
1724
|
+
function priceBoth(sats, btcUsd = REFERENCE_BTC_USD) {
|
|
1725
|
+
return `${formatSats(sats)} sats \xB7 ${satsToUsd(sats, btcUsd)}`;
|
|
1726
|
+
}
|
|
1727
|
+
function relativeTime(when) {
|
|
1728
|
+
const t = when instanceof Date ? when.getTime() : new Date(when).getTime();
|
|
1729
|
+
if (Number.isNaN(t)) return "";
|
|
1730
|
+
const diff = Date.now() - t;
|
|
1731
|
+
const m = Math.floor(diff / 6e4);
|
|
1732
|
+
if (m < 1) return "now";
|
|
1733
|
+
if (m < 60) return `${m}m ago`;
|
|
1734
|
+
const h = Math.floor(m / 60);
|
|
1735
|
+
if (h < 24) return `${h}h ago`;
|
|
1736
|
+
const d = Math.floor(h / 24);
|
|
1737
|
+
if (d < 30) return `${d}d ago`;
|
|
1738
|
+
const mo = Math.floor(d / 30);
|
|
1739
|
+
if (mo < 12) return `${mo}mo ago`;
|
|
1740
|
+
return `${Math.floor(mo / 12)}y ago`;
|
|
1741
|
+
}
|
|
1742
|
+
function shortenAddress(value, head = 8, tail = 4) {
|
|
1743
|
+
if (!value) return "";
|
|
1744
|
+
if (value.length <= head + tail + 1) return value;
|
|
1745
|
+
return `${value.slice(0, head)}\u2026${value.slice(-tail)}`;
|
|
1746
|
+
}
|
|
1747
|
+
function explorerUrl(target, network = "mainnet") {
|
|
1748
|
+
const base = network === "mainnet" ? "https://mempool.space" : `https://mempool.space/${network}`;
|
|
1749
|
+
if ("address" in target) return `${base}/address/${target.address}`;
|
|
1750
|
+
if ("tx" in target) return `${base}/tx/${target.tx}`;
|
|
1751
|
+
return `${base}/block/${target.block}`;
|
|
1752
|
+
}
|
|
1753
|
+
function SatsAmount({ sats, unit = true, usd = false, btcUsd, className }) {
|
|
1754
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cn("font-mono tabular-nums", className), children: [
|
|
1755
|
+
formatSats(sats),
|
|
1756
|
+
unit && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: " sats" }),
|
|
1757
|
+
usd && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground", children: [
|
|
1758
|
+
" \xB7 ",
|
|
1759
|
+
satsToUsd(sats, btcUsd)
|
|
1760
|
+
] })
|
|
1761
|
+
] });
|
|
1762
|
+
}
|
|
1763
|
+
function CopyButton({
|
|
1764
|
+
value,
|
|
1765
|
+
label,
|
|
1766
|
+
clearAfter,
|
|
1767
|
+
size = "md",
|
|
1768
|
+
className,
|
|
1769
|
+
title,
|
|
1770
|
+
onCopied
|
|
1771
|
+
}) {
|
|
1772
|
+
const [copied, setCopied] = React2.useState(false);
|
|
1773
|
+
const resetRef = React2.useRef(null);
|
|
1774
|
+
const copy = React2.useCallback(async () => {
|
|
1775
|
+
try {
|
|
1776
|
+
await navigator.clipboard.writeText(value);
|
|
1777
|
+
setCopied(true);
|
|
1778
|
+
onCopied?.();
|
|
1779
|
+
if (resetRef.current) clearTimeout(resetRef.current);
|
|
1780
|
+
resetRef.current = setTimeout(() => setCopied(false), 1500);
|
|
1781
|
+
if (clearAfter && clearAfter > 0) {
|
|
1782
|
+
setTimeout(() => void wipeIfUnchanged(value), clearAfter * 1e3);
|
|
1783
|
+
}
|
|
1784
|
+
} catch {
|
|
1785
|
+
}
|
|
1786
|
+
}, [value, clearAfter, onCopied]);
|
|
1787
|
+
const iconSize = size === "sm" ? "size-3" : "size-3.5";
|
|
1788
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1789
|
+
"button",
|
|
1790
|
+
{
|
|
1791
|
+
type: "button",
|
|
1792
|
+
onClick: copy,
|
|
1793
|
+
"aria-label": title ?? (copied ? "copied" : "copy"),
|
|
1794
|
+
title: title ?? "copy",
|
|
1795
|
+
className: cn(
|
|
1796
|
+
"text-muted-foreground hover:text-foreground inline-flex items-center gap-1.5 rounded-sm transition-colors outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",
|
|
1797
|
+
size === "sm" ? "text-[11px]" : "text-xs",
|
|
1798
|
+
className
|
|
1799
|
+
),
|
|
1800
|
+
children: [
|
|
1801
|
+
copied ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: cn(iconSize, "text-success"), "aria-hidden": true }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: iconSize, "aria-hidden": true }),
|
|
1802
|
+
label && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono", children: copied ? "copied" : label })
|
|
1803
|
+
]
|
|
1804
|
+
}
|
|
1805
|
+
);
|
|
1806
|
+
}
|
|
1807
|
+
async function wipeIfUnchanged(expected) {
|
|
1808
|
+
try {
|
|
1809
|
+
const current = await navigator.clipboard.readText();
|
|
1810
|
+
if (current !== expected) return;
|
|
1811
|
+
await navigator.clipboard.writeText("");
|
|
1812
|
+
} catch {
|
|
1813
|
+
try {
|
|
1814
|
+
await navigator.clipboard.writeText("");
|
|
1815
|
+
} catch {
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
function BitcoinAddress({
|
|
1820
|
+
address,
|
|
1821
|
+
head = 8,
|
|
1822
|
+
tail = 4,
|
|
1823
|
+
copyable = true,
|
|
1824
|
+
full = false,
|
|
1825
|
+
className
|
|
1826
|
+
}) {
|
|
1827
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cn("inline-flex items-center gap-1.5 font-mono text-xs", className), children: [
|
|
1828
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { title: address, children: full ? address : shortenAddress(address, head, tail) }),
|
|
1829
|
+
copyable && /* @__PURE__ */ jsxRuntime.jsx(CopyButton, { value: address, size: "sm", title: "copy address" })
|
|
1830
|
+
] });
|
|
1831
|
+
}
|
|
1832
|
+
function QrCode({ value, size = 200, label, className }) {
|
|
1833
|
+
const [svg, setSvg] = React2.useState(null);
|
|
1834
|
+
React2.useEffect(() => {
|
|
1835
|
+
let cancelled = false;
|
|
1836
|
+
QRCode__default.default.toString(value, {
|
|
1837
|
+
type: "svg",
|
|
1838
|
+
errorCorrectionLevel: "M",
|
|
1839
|
+
margin: 1,
|
|
1840
|
+
color: { dark: "#000000", light: "#ffffff" }
|
|
1841
|
+
}).then((out) => {
|
|
1842
|
+
if (!cancelled) setSvg(out);
|
|
1843
|
+
}).catch(() => {
|
|
1844
|
+
if (!cancelled) setSvg(null);
|
|
1845
|
+
});
|
|
1846
|
+
return () => {
|
|
1847
|
+
cancelled = true;
|
|
1848
|
+
};
|
|
1849
|
+
}, [value]);
|
|
1850
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1851
|
+
"div",
|
|
1852
|
+
{
|
|
1853
|
+
role: "img",
|
|
1854
|
+
"aria-label": label ?? `QR code for ${value.slice(0, 24)}\u2026`,
|
|
1855
|
+
className: "inline-block overflow-hidden rounded-md bg-white p-3 " + (className ?? ""),
|
|
1856
|
+
style: { width: size, height: size },
|
|
1857
|
+
children: svg ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1858
|
+
"div",
|
|
1859
|
+
{
|
|
1860
|
+
className: "size-full [&_svg]:block [&_svg]:size-full",
|
|
1861
|
+
dangerouslySetInnerHTML: { __html: svg }
|
|
1862
|
+
}
|
|
1863
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted/40 size-full animate-pulse rounded", "aria-hidden": true })
|
|
1864
|
+
}
|
|
1865
|
+
);
|
|
1866
|
+
}
|
|
1506
1867
|
|
|
1507
1868
|
// src/components/index.ts
|
|
1508
1869
|
var components_exports = {};
|
|
@@ -1521,8 +1882,12 @@ exports.AlertTitle = AlertTitle;
|
|
|
1521
1882
|
exports.AlertWithAction = AlertWithAction;
|
|
1522
1883
|
exports.AlertWithCountdown = AlertWithCountdown;
|
|
1523
1884
|
exports.Badge = Badge;
|
|
1885
|
+
exports.Bar = Bar;
|
|
1886
|
+
exports.BitcoinAddress = BitcoinAddress;
|
|
1524
1887
|
exports.Button = Button;
|
|
1888
|
+
exports.Card = Card;
|
|
1525
1889
|
exports.ConfirmHost = ConfirmHost;
|
|
1890
|
+
exports.CopyButton = CopyButton;
|
|
1526
1891
|
exports.DEFAULT_OC_THEME = DEFAULT_OC_THEME;
|
|
1527
1892
|
exports.Dialog = Dialog;
|
|
1528
1893
|
exports.DialogClose = DialogClose;
|
|
@@ -1549,6 +1914,9 @@ exports.PopoverAnchor = PopoverAnchor;
|
|
|
1549
1914
|
exports.PopoverContent = PopoverContent;
|
|
1550
1915
|
exports.PopoverTrigger = PopoverTrigger;
|
|
1551
1916
|
exports.PromptHost = PromptHost;
|
|
1917
|
+
exports.QrCode = QrCode;
|
|
1918
|
+
exports.REFERENCE_BTC_USD = REFERENCE_BTC_USD;
|
|
1919
|
+
exports.SatsAmount = SatsAmount;
|
|
1552
1920
|
exports.Select = Select;
|
|
1553
1921
|
exports.SelectContent = SelectContent;
|
|
1554
1922
|
exports.SelectGroup = SelectGroup;
|
|
@@ -1569,6 +1937,9 @@ exports.SheetPortal = SheetPortal;
|
|
|
1569
1937
|
exports.SheetTitle = SheetTitle;
|
|
1570
1938
|
exports.SheetTrigger = SheetTrigger;
|
|
1571
1939
|
exports.Skeleton = Skeleton;
|
|
1940
|
+
exports.Sparkline = Sparkline;
|
|
1941
|
+
exports.StatBlock = StatBlock;
|
|
1942
|
+
exports.StatusPill = StatusPill;
|
|
1572
1943
|
exports.Textarea = Textarea;
|
|
1573
1944
|
exports.ThemeToggle = ThemeToggle;
|
|
1574
1945
|
exports.ThemeToggleLink = ThemeToggleLink;
|
|
@@ -1579,10 +1950,18 @@ exports.badgeVariants = badgeVariants;
|
|
|
1579
1950
|
exports.buttonVariants = buttonVariants;
|
|
1580
1951
|
exports.cn = cn;
|
|
1581
1952
|
exports.confirm = confirm;
|
|
1953
|
+
exports.explorerUrl = explorerUrl;
|
|
1954
|
+
exports.formatSats = formatSats;
|
|
1955
|
+
exports.formatSatsCompact = formatSatsCompact;
|
|
1582
1956
|
exports.getOcThemeInitScript = getOcThemeInitScript;
|
|
1583
1957
|
exports.isKnownTheme = isKnownTheme;
|
|
1958
|
+
exports.priceBoth = priceBoth;
|
|
1584
1959
|
exports.prompt = prompt;
|
|
1960
|
+
exports.relativeTime = relativeTime;
|
|
1585
1961
|
exports.resolveTheme = resolveTheme;
|
|
1962
|
+
exports.satsToUsd = satsToUsd;
|
|
1963
|
+
exports.shortenAddress = shortenAddress;
|
|
1964
|
+
exports.usdToSats = usdToSats;
|
|
1586
1965
|
exports.useOcSkin = useOcSkin;
|
|
1587
1966
|
//# sourceMappingURL=index.js.map
|
|
1588
1967
|
//# sourceMappingURL=index.js.map
|