kaleido-ui 0.2.2 → 0.2.4
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/README.md +37 -10
- package/dist/icon-AvUL0Cws.d.cts +135 -0
- package/dist/icon-AvUL0Cws.d.ts +135 -0
- package/dist/native/index.cjs +0 -126
- package/dist/native/index.js +0 -126
- package/dist/web/assets/kaleidoswap-brand.js +11 -0
- package/dist/web/assets/protocol-icons.js +7 -0
- package/dist/web/chunk-25RRZDZ2.js +269 -0
- package/dist/web/chunk-27CY5EHL.js +230 -0
- package/dist/web/chunk-2GNXC446.js +84 -0
- package/dist/web/chunk-2NCH2ZDU.js +129 -0
- package/dist/web/chunk-2OGYEUYV.js +220 -0
- package/dist/web/chunk-2Q5SSNFO.js +63 -0
- package/dist/web/chunk-2REWXJEN.js +96 -0
- package/dist/web/chunk-2VAS6VYJ.js +106 -0
- package/dist/web/chunk-2VKFRAX3.js +39 -0
- package/dist/web/chunk-2Z6KFK4Z.js +41 -0
- package/dist/web/chunk-4246Y2F2.js +276 -0
- package/dist/web/chunk-4MLPMRXA.js +85 -0
- package/dist/web/chunk-4QLR4ZNK.js +383 -0
- package/dist/web/chunk-4UMKXXAK.js +33 -0
- package/dist/web/chunk-563GMWFT.js +32 -0
- package/dist/web/chunk-5BNDC7M4.js +50 -0
- package/dist/web/chunk-5GBURTY4.js +33 -0
- package/dist/web/chunk-5MM5YGGG.js +43 -0
- package/dist/web/chunk-5PZ2XVWL.js +85 -0
- package/dist/web/chunk-5V2KMO56.js +55 -0
- package/dist/web/chunk-5WBAFYPH.js +62 -0
- package/dist/web/chunk-62HIDJCD.js +98 -0
- package/dist/web/chunk-6IBQJIHT.js +56 -0
- package/dist/web/chunk-6PNGSAJB.js +55 -0
- package/dist/web/chunk-6VKWG5FJ.js +159 -0
- package/dist/web/chunk-76DAZT7Q.js +107 -0
- package/dist/web/chunk-7NS5S2PG.js +126 -0
- package/dist/web/chunk-7OE6AXLY.js +27 -0
- package/dist/web/chunk-7YUPXESC.js +666 -0
- package/dist/web/chunk-A3TKIXSI.js +197 -0
- package/dist/web/chunk-A3XHFJ6J.js +120 -0
- package/dist/web/chunk-A6MSV4MA.js +83 -0
- package/dist/web/chunk-A7MPRLJL.js +169 -0
- package/dist/web/chunk-AP7Q2FCS.js +43 -0
- package/dist/web/chunk-ASHU5XNR.js +21 -0
- package/dist/web/chunk-BGUBHWIO.js +41 -0
- package/dist/web/chunk-BY2KCPTX.js +444 -0
- package/dist/web/chunk-C7YIQDGQ.js +57 -0
- package/dist/web/chunk-CBE7BT3M.js +87 -0
- package/dist/web/chunk-CJATW6EO.js +108 -0
- package/dist/web/chunk-CRDCVB5X.js +96 -0
- package/dist/web/chunk-CRMLYZIX.js +35 -0
- package/dist/web/chunk-CXMCWSWC.js +20 -0
- package/dist/web/chunk-CZPNI33A.js +31 -0
- package/dist/web/chunk-DCUAE6PX.js +202 -0
- package/dist/web/chunk-DDMDRAD6.js +403 -0
- package/dist/web/chunk-DH7VXKGM.js +247 -0
- package/dist/web/chunk-DNHRMPKI.js +63 -0
- package/dist/web/chunk-DXFFYCU3.js +83 -0
- package/dist/web/chunk-EK5N3ZPW.js +417 -0
- package/dist/web/chunk-F2LIZX5K.js +140 -0
- package/dist/web/chunk-FSQV54O4.js +61 -0
- package/dist/web/chunk-FWOIRFV5.js +73 -0
- package/dist/web/chunk-G2MJL3VP.js +54 -0
- package/dist/web/chunk-G2ZYNR3W.js +28 -0
- package/dist/web/chunk-G373WZMN.js +150 -0
- package/dist/web/chunk-GMJGTSCQ.js +82 -0
- package/dist/web/chunk-GX7GBHJ6.js +362 -0
- package/dist/web/chunk-GZZ5KVON.js +70 -0
- package/dist/web/chunk-H3GYLFHP.js +30 -0
- package/dist/web/chunk-HDLOPDFX.js +89 -0
- package/dist/web/chunk-HP25HN7Q.js +69 -0
- package/dist/web/chunk-HVKSBEZN.js +98 -0
- package/dist/web/chunk-HWKXZNBN.js +74 -0
- package/dist/web/chunk-HY3VMT27.js +64 -0
- package/dist/web/chunk-IK32AIOS.js +27 -0
- package/dist/web/chunk-IMER4KGH.js +151 -0
- package/dist/web/chunk-IV6AAVUE.js +177 -0
- package/dist/web/chunk-JWMFTRDC.js +254 -0
- package/dist/web/chunk-JY3H7ZAI.js +41 -0
- package/dist/web/chunk-JY73M73T.js +175 -0
- package/dist/web/chunk-JYM5NHBA.js +80 -0
- package/dist/web/chunk-JZ3BUM5L.js +368 -0
- package/dist/web/chunk-KIMWCG5N.js +108 -0
- package/dist/web/chunk-L2UPQLY7.js +43 -0
- package/dist/web/chunk-LFAORJQK.js +81 -0
- package/dist/web/chunk-LOGZGZWN.js +1 -0
- package/dist/web/chunk-LPDB7EHH.js +65 -0
- package/dist/web/chunk-LSY4DY2I.js +72 -0
- package/dist/web/chunk-LYCLVP26.js +101 -0
- package/dist/web/chunk-LZ6PIXUO.js +43 -0
- package/dist/web/chunk-LZ723UCB.js +96 -0
- package/dist/web/chunk-M6RXTQEL.js +90 -0
- package/dist/web/chunk-MTQ22SKE.js +39 -0
- package/dist/web/chunk-MTQOAMDW.js +8 -0
- package/dist/web/chunk-NEXA6VGG.js +91 -0
- package/dist/web/chunk-NSA777UY.js +89 -0
- package/dist/web/chunk-O2TTO5FS.js +24 -0
- package/dist/web/chunk-O6NPTMDN.js +191 -0
- package/dist/web/chunk-OI7WX7NE.js +17 -0
- package/dist/web/chunk-OWSKP527.js +80 -0
- package/dist/web/chunk-OX3J3FYX.js +64 -0
- package/dist/web/chunk-PCKRLEAO.js +40 -0
- package/dist/web/chunk-PMGIJMRO.js +207 -0
- package/dist/web/chunk-PS7Q6MMU.js +60 -0
- package/dist/web/chunk-PTSOVDKH.js +169 -0
- package/dist/web/chunk-QBZSLR7U.js +54 -0
- package/dist/web/chunk-QCQRA6L5.js +63 -0
- package/dist/web/chunk-QFIGSIXA.js +558 -0
- package/dist/web/chunk-QRFFLA3N.js +84 -0
- package/dist/web/chunk-QXCCUYNY.js +232 -0
- package/dist/web/chunk-QXZ2WY3B.js +38 -0
- package/dist/web/chunk-R2MV4S4U.js +50 -0
- package/dist/web/chunk-R3IIXFGK.js +48 -0
- package/dist/web/chunk-RIOY4LFJ.js +141 -0
- package/dist/web/chunk-RV7Z3B3V.js +106 -0
- package/dist/web/chunk-RXXYUYBP.js +25 -0
- package/dist/web/chunk-S2ICIIH2.js +109 -0
- package/dist/web/chunk-SJNOBBU5.js +86 -0
- package/dist/web/chunk-STMNX3QT.js +109 -0
- package/dist/web/chunk-T7CEJV6P.js +66 -0
- package/dist/web/chunk-TBEKRQGW.js +99 -0
- package/dist/web/chunk-TCFHH5TE.js +179 -0
- package/dist/web/chunk-TI7NWMEQ.js +34 -0
- package/dist/web/chunk-TKRMGN7J.js +8 -0
- package/dist/web/chunk-TMK3SVYI.js +62 -0
- package/dist/web/chunk-TPGNO74K.js +67 -0
- package/dist/web/chunk-TS4UYWJJ.js +105 -0
- package/dist/web/chunk-TY6SGZC7.js +94 -0
- package/dist/web/chunk-UHXOPILM.js +101 -0
- package/dist/web/chunk-UK6ZL4MX.js +375 -0
- package/dist/web/chunk-UXLWWQ4J.js +20 -0
- package/dist/web/chunk-UZ4LWR4X.js +26 -0
- package/dist/web/chunk-VLZMX43R.js +45 -0
- package/dist/web/chunk-VM6AGMYO.js +46 -0
- package/dist/web/chunk-VUGV3ELU.js +176 -0
- package/dist/web/chunk-VYQHGSK6.js +244 -0
- package/dist/web/chunk-VZF5C3C6.js +146 -0
- package/dist/web/chunk-W4E2N3UN.js +58 -0
- package/dist/web/chunk-WEPSTI3Z.js +83 -0
- package/dist/web/chunk-WOAWUXER.js +139 -0
- package/dist/web/chunk-WURSWAKE.js +74 -0
- package/dist/web/chunk-WWF7IJBF.js +330 -0
- package/dist/web/chunk-X2RA4EG3.js +86 -0
- package/dist/web/chunk-XCQGJYGF.js +42 -0
- package/dist/web/chunk-XDSOOOYL.js +35 -0
- package/dist/web/chunk-XPHFJPUQ.js +291 -0
- package/dist/web/chunk-XXH4TYKZ.js +276 -0
- package/dist/web/chunk-XZQUQOR3.js +48 -0
- package/dist/web/chunk-Y3W6LOOE.js +66 -0
- package/dist/web/chunk-YNB4SSLD.js +113 -0
- package/dist/web/chunk-YQDCU7ZL.js +49 -0
- package/dist/web/chunk-YQQ7GDLZ.js +30 -0
- package/dist/web/chunk-YTXWYWVD.js +70 -0
- package/dist/web/chunk-YXVOFEDT.js +85 -0
- package/dist/web/chunk-Z2SS7UJ4.js +139 -0
- package/dist/web/chunk-Z5LVT3BD.js +128 -0
- package/dist/web/chunk-Z5O67WTL.js +85 -0
- package/dist/web/chunk-ZPNGHBKB.js +86 -0
- package/dist/web/chunk-ZR32WYJA.js +55 -0
- package/dist/web/chunk-ZRIBB4EB.js +62 -0
- package/dist/web/chunk-ZTVV4KBT.js +28 -0
- package/dist/web/chunk-ZXCT3Y6P.js +56 -0
- package/dist/web/components/account-capabilities-card.js +21 -0
- package/dist/web/components/account-menu.js +18 -0
- package/dist/web/components/account-settings-shared.js +50 -0
- package/dist/web/components/account-status-tabs.js +20 -0
- package/dist/web/components/action-tile.js +8 -0
- package/dist/web/components/activity-detail-row.js +22 -0
- package/dist/web/components/activity-filter-bar.js +22 -0
- package/dist/web/components/activity-list.js +23 -0
- package/dist/web/components/activity-network-filters.js +19 -0
- package/dist/web/components/activity-row.js +15 -0
- package/dist/web/components/activity-type-tabs.js +17 -0
- package/dist/web/components/alert-banner.js +13 -0
- package/dist/web/components/amount.js +8 -0
- package/dist/web/components/app-icon.js +15 -0
- package/dist/web/components/asset-card.js +21 -0
- package/dist/web/components/asset-icon.js +10 -0
- package/dist/web/components/asset-selector.js +24 -0
- package/dist/web/components/balance-breakdown.js +18 -0
- package/dist/web/components/basic-collapsible.js +11 -0
- package/dist/web/components/bottom-nav.js +13 -0
- package/dist/web/components/bottom-sheet.js +15 -0
- package/dist/web/components/btc-unified-receive.js +28 -0
- package/dist/web/components/charts/bar-chart.js +24 -0
- package/dist/web/components/charts/bar-list.js +24 -0
- package/dist/web/components/charts/core.js +63 -0
- package/dist/web/components/charts/donut-chart.js +26 -0
- package/dist/web/components/charts/index.js +72 -0
- package/dist/web/components/charts/line-chart.js +26 -0
- package/dist/web/components/charts/meter.js +24 -0
- package/dist/web/components/charts/mixed-chart.js +24 -0
- package/dist/web/components/charts/scatter-chart.js +24 -0
- package/dist/web/components/charts/sparkline.js +8 -0
- package/dist/web/components/choice-group.js +11 -0
- package/dist/web/components/code-block.js +21 -0
- package/dist/web/components/confirm-dialog.js +15 -0
- package/dist/web/components/copy-button.js +21 -0
- package/dist/web/components/copyable.js +20 -0
- package/dist/web/components/date-range-filter.js +16 -0
- package/dist/web/components/deposit-asset-selection.js +24 -0
- package/dist/web/components/deposit-generated-view.js +23 -0
- package/dist/web/components/deposit-invoice-generation.js +35 -0
- package/dist/web/components/deposit-network-default-modal.js +13 -0
- package/dist/web/components/deposit-pre-generation.js +17 -0
- package/dist/web/components/deposit-success-screen.js +20 -0
- package/dist/web/components/deposit-ui-shared.js +28 -0
- package/dist/web/components/disclosure-card.js +11 -0
- package/dist/web/components/dotted-leader.js +8 -0
- package/dist/web/components/empty-state.js +8 -0
- package/dist/web/components/environment-indicator.js +9 -0
- package/dist/web/components/error-boundary.js +10 -0
- package/dist/web/components/event-timeline.js +8 -0
- package/dist/web/components/extension-page-frame.js +15 -0
- package/dist/web/components/filter-bar.js +15 -0
- package/dist/web/components/filter-chip-group.js +8 -0
- package/dist/web/components/filter-dropdown.js +12 -0
- package/dist/web/components/floating-notice.js +12 -0
- package/dist/web/components/form-field.js +10 -0
- package/dist/web/components/halo-backdrop.js +8 -0
- package/dist/web/components/info-chip.js +24 -0
- package/dist/web/components/info-panel.js +13 -0
- package/dist/web/components/inline-selector.js +11 -0
- package/dist/web/components/instants-statement.js +20 -0
- package/dist/web/components/kaleidoscope-hero-animation.js +11 -0
- package/dist/web/components/kaleidoswap-logo.js +12 -0
- package/dist/web/components/list-field.js +14 -0
- package/dist/web/components/list-summary.js +8 -0
- package/dist/web/components/metric-card.js +14 -0
- package/dist/web/components/mobile-hero-animation.js +8 -0
- package/dist/web/components/network-badge.js +14 -0
- package/dist/web/components/network-icon.js +21 -0
- package/dist/web/components/network-status-chip.js +11 -0
- package/dist/web/components/notice-bar.js +8 -0
- package/dist/web/components/one-time-secret-dialog.js +18 -0
- package/dist/web/components/option-selector.js +12 -0
- package/dist/web/components/page-header.js +12 -0
- package/dist/web/components/page-shell.js +18 -0
- package/dist/web/components/pager.js +11 -0
- package/dist/web/components/period-select.js +20 -0
- package/dist/web/components/qr-code.js +10 -0
- package/dist/web/components/query-state.js +19 -0
- package/dist/web/components/read-status.js +15 -0
- package/dist/web/components/record-list.js +17 -0
- package/dist/web/components/recovery-phrase-card.js +20 -0
- package/dist/web/components/restricted.js +9 -0
- package/dist/web/components/secret-reveal-card.js +20 -0
- package/dist/web/components/section-header.js +9 -0
- package/dist/web/components/section-label.js +8 -0
- package/dist/web/components/selectable-card.js +8 -0
- package/dist/web/components/setting-item.js +13 -0
- package/dist/web/components/settings-section-card.js +11 -0
- package/dist/web/components/settings-selector-row.js +8 -0
- package/dist/web/components/settings-tile.js +21 -0
- package/dist/web/components/skeleton.js +10 -0
- package/dist/web/components/status-badge.js +13 -0
- package/dist/web/components/status-icon-badge.js +15 -0
- package/dist/web/components/stepper-number-input.js +10 -0
- package/dist/web/components/summary-rows.js +9 -0
- package/dist/web/components/swap-badge.js +11 -0
- package/dist/web/components/swap-input-card.js +28 -0
- package/dist/web/components/swap-step-list.js +10 -0
- package/dist/web/components/switch-row.js +9 -0
- package/dist/web/components/theme-toggle.js +12 -0
- package/dist/web/components/transaction-card.js +14 -0
- package/dist/web/components/trend-chart.js +28 -0
- package/dist/web/components/value-list.js +20 -0
- package/dist/web/components/wallet-asset-list.js +22 -0
- package/dist/web/components/withdraw-amount-input.js +13 -0
- package/dist/web/components/withdraw-confirmation.js +17 -0
- package/dist/web/components/withdraw-destination-input.js +14 -0
- package/dist/web/components/withdraw-invoice-info.js +10 -0
- package/dist/web/components/withdraw-route-selector.js +9 -0
- package/dist/web/components/withdraw-success.js +12 -0
- package/dist/web/hooks/use-asset-icon.js +11 -0
- package/dist/web/hooks/use-copy-to-clipboard.js +7 -0
- package/dist/web/hooks/use-media-query.js +9 -0
- package/dist/web/hooks/use-theme-mode.js +9 -0
- package/dist/web/hooks/use-toast.js +11 -0
- package/dist/web/icons/filled.js +15 -0
- package/dist/web/icons/index.js +13 -0
- package/dist/web/icons/outlined.js +221 -0
- package/dist/web/icons/public.js +248 -0
- package/dist/web/icons.cjs +776 -0
- package/dist/web/icons.d.cts +123 -0
- package/dist/web/icons.d.ts +123 -0
- package/dist/web/index.cjs +2547 -2496
- package/dist/web/index.d.cts +16 -107
- package/dist/web/index.d.ts +16 -107
- package/dist/web/index.js +592 -14464
- package/dist/web/primitives/avatar.js +10 -0
- package/dist/web/primitives/button.js +10 -0
- package/dist/web/primitives/card.js +20 -0
- package/dist/web/primitives/collapsible.js +16 -0
- package/dist/web/primitives/dialog.js +30 -0
- package/dist/web/primitives/dot-pagination.js +8 -0
- package/dist/web/primitives/drawer.js +43 -0
- package/dist/web/primitives/dropdown-menu.js +28 -0
- package/dist/web/primitives/glyph-button.js +10 -0
- package/dist/web/primitives/icon-button.js +15 -0
- package/dist/web/primitives/icon-glyph.js +8 -0
- package/dist/web/primitives/icon.js +16 -0
- package/dist/web/primitives/input.js +9 -0
- package/dist/web/primitives/label.js +9 -0
- package/dist/web/primitives/menu-search.js +20 -0
- package/dist/web/primitives/number-input.js +11 -0
- package/dist/web/primitives/popover.js +18 -0
- package/dist/web/primitives/scroll-area.js +12 -0
- package/dist/web/primitives/select.js +27 -0
- package/dist/web/primitives/switch.js +8 -0
- package/dist/web/primitives/table.js +27 -0
- package/dist/web/primitives/tabs.js +14 -0
- package/dist/web/primitives/toast.js +24 -0
- package/dist/web/primitives/toaster.js +15 -0
- package/dist/web/primitives/tooltip.js +10 -0
- package/dist/web/utils/amount-display.js +13 -0
- package/dist/web/utils/cn.js +7 -0
- package/dist/web/utils/field-styles.js +7 -0
- package/dist/web/utils/type-roles.js +7 -0
- package/package.json +9 -1
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
ChartDataTable,
|
|
4
|
+
ChartHeader,
|
|
5
|
+
ChartLegend,
|
|
6
|
+
ChartLegendRow,
|
|
7
|
+
ChartTooltip,
|
|
8
|
+
tooltipText,
|
|
9
|
+
useSeriesVisibility
|
|
10
|
+
} from "./chunk-EK5N3ZPW.js";
|
|
11
|
+
import {
|
|
12
|
+
formatAmount
|
|
13
|
+
} from "./chunk-VM6AGMYO.js";
|
|
14
|
+
import {
|
|
15
|
+
cn
|
|
16
|
+
} from "./chunk-PMGIJMRO.js";
|
|
17
|
+
|
|
18
|
+
// src/web/components/trend-chart.tsx
|
|
19
|
+
import {
|
|
20
|
+
useCallback,
|
|
21
|
+
useEffect,
|
|
22
|
+
useId,
|
|
23
|
+
useLayoutEffect,
|
|
24
|
+
useRef,
|
|
25
|
+
useState
|
|
26
|
+
} from "react";
|
|
27
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
28
|
+
var toneFill = {
|
|
29
|
+
// The charts' green, so every chart draws the same one.
|
|
30
|
+
primary: "var(--series-1)",
|
|
31
|
+
danger: "var(--destructive)",
|
|
32
|
+
info: "var(--chart-4)",
|
|
33
|
+
warning: "var(--chart-2)",
|
|
34
|
+
muted: "var(--muted-foreground)"
|
|
35
|
+
};
|
|
36
|
+
var defaultFormat = (value) => formatAmount(value);
|
|
37
|
+
var MARGIN = { top: 8, right: 8, bottom: 24, left: 8 };
|
|
38
|
+
var TICK_FONT = 11;
|
|
39
|
+
var X_LABEL_SPACING = 64;
|
|
40
|
+
var FALLBACK_WIDTH = 640;
|
|
41
|
+
var MAX_BAR_WIDTH = 40;
|
|
42
|
+
function trendChartTicks(max) {
|
|
43
|
+
if (!Number.isFinite(max) || max <= 0) return [0];
|
|
44
|
+
const rough = max / 4;
|
|
45
|
+
const magnitude = 10 ** Math.floor(Math.log10(rough));
|
|
46
|
+
const step = [1, 2, 5, 10].map((m) => m * magnitude).find((s) => s >= rough) ?? 10 * magnitude;
|
|
47
|
+
const wholeStep = Math.max(1, Math.round(step));
|
|
48
|
+
const ticks = [0];
|
|
49
|
+
for (let value = wholeStep; value < max - max * 0.15; value += wholeStep) ticks.push(value);
|
|
50
|
+
ticks.push(max);
|
|
51
|
+
return ticks;
|
|
52
|
+
}
|
|
53
|
+
function trendChartLabelIndices(count, maxLabels) {
|
|
54
|
+
if (count <= 0) return [];
|
|
55
|
+
if (count === 1) return [0];
|
|
56
|
+
const slots = Math.max(2, Math.min(count, Math.floor(maxLabels)));
|
|
57
|
+
const indices = /* @__PURE__ */ new Set();
|
|
58
|
+
for (let slot = 0; slot < slots; slot += 1) {
|
|
59
|
+
indices.add(Math.round(slot * (count - 1) / (slots - 1)));
|
|
60
|
+
}
|
|
61
|
+
return [...indices].sort((a, b) => a - b);
|
|
62
|
+
}
|
|
63
|
+
var useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
64
|
+
function useElementWidth() {
|
|
65
|
+
const ref = useRef(null);
|
|
66
|
+
const [width, setWidth] = useState(FALLBACK_WIDTH);
|
|
67
|
+
useIsomorphicLayoutEffect(() => {
|
|
68
|
+
const element = ref.current;
|
|
69
|
+
if (!element) return;
|
|
70
|
+
const measured = Math.round(element.getBoundingClientRect().width);
|
|
71
|
+
if (measured > 0) setWidth(measured);
|
|
72
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
73
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
74
|
+
const next = Math.round(entry.contentRect.width);
|
|
75
|
+
if (next > 0) setWidth(next);
|
|
76
|
+
});
|
|
77
|
+
observer.observe(element);
|
|
78
|
+
return () => observer.disconnect();
|
|
79
|
+
}, []);
|
|
80
|
+
return [ref, width];
|
|
81
|
+
}
|
|
82
|
+
function TrendChart({
|
|
83
|
+
points,
|
|
84
|
+
series: allSeries,
|
|
85
|
+
scaleLabel,
|
|
86
|
+
label,
|
|
87
|
+
empty,
|
|
88
|
+
formatValue = defaultFormat,
|
|
89
|
+
height = 220,
|
|
90
|
+
view: controlledView,
|
|
91
|
+
onViewChange,
|
|
92
|
+
className,
|
|
93
|
+
...head
|
|
94
|
+
}) {
|
|
95
|
+
const [containerRef, width] = useElementWidth();
|
|
96
|
+
const [active, setActive] = useState(null);
|
|
97
|
+
const [ownView, setOwnView] = useState("chart");
|
|
98
|
+
const view = controlledView ?? ownView;
|
|
99
|
+
const setView = (next) => {
|
|
100
|
+
if (controlledView === void 0) setOwnView(next);
|
|
101
|
+
onViewChange?.(next);
|
|
102
|
+
};
|
|
103
|
+
const styledSeries = allSeries.map((s, index) => ({ ...s, texture: s.texture ?? (index === 0 ? "solid" : "hatch") }));
|
|
104
|
+
const visibility = useSeriesVisibility(allSeries.map((s) => s.id));
|
|
105
|
+
const series = styledSeries.filter((s) => visibility.isVisible(s.id));
|
|
106
|
+
const idBase = `trend-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;
|
|
107
|
+
const count = points.length;
|
|
108
|
+
const moveActive = useCallback(
|
|
109
|
+
(event) => {
|
|
110
|
+
if (count === 0) return;
|
|
111
|
+
const current = active ?? -1;
|
|
112
|
+
let next;
|
|
113
|
+
switch (event.key) {
|
|
114
|
+
case "ArrowRight":
|
|
115
|
+
next = Math.min(count - 1, current + 1);
|
|
116
|
+
break;
|
|
117
|
+
case "ArrowLeft":
|
|
118
|
+
next = current < 0 ? count - 1 : Math.max(0, current - 1);
|
|
119
|
+
break;
|
|
120
|
+
case "Home":
|
|
121
|
+
next = 0;
|
|
122
|
+
break;
|
|
123
|
+
case "End":
|
|
124
|
+
next = count - 1;
|
|
125
|
+
break;
|
|
126
|
+
case "Escape":
|
|
127
|
+
next = null;
|
|
128
|
+
break;
|
|
129
|
+
default:
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
setActive(next);
|
|
134
|
+
},
|
|
135
|
+
[active, count]
|
|
136
|
+
);
|
|
137
|
+
if (count === 0) return /* @__PURE__ */ jsx(Fragment, { children: empty ?? null });
|
|
138
|
+
const textures = series.map((s) => s.texture);
|
|
139
|
+
const totals = points.map(
|
|
140
|
+
(point) => series.reduce((sum, s) => sum + Math.max(0, point.values[s.id] ?? 0), 0)
|
|
141
|
+
);
|
|
142
|
+
const max = Math.max(0, ...totals);
|
|
143
|
+
const ticks = trendChartTicks(max);
|
|
144
|
+
const tickLabels = ticks.map(formatValue);
|
|
145
|
+
const axisWidth = Math.max(...tickLabels.map((t) => t.length)) * TICK_FONT * 0.62 + 8;
|
|
146
|
+
const plotLeft = MARGIN.left + axisWidth;
|
|
147
|
+
const plotRight = width - MARGIN.right;
|
|
148
|
+
const plotTop = MARGIN.top;
|
|
149
|
+
const plotBottom = height - MARGIN.bottom;
|
|
150
|
+
const plotWidth = Math.max(1, plotRight - plotLeft);
|
|
151
|
+
const plotHeight = Math.max(1, plotBottom - plotTop);
|
|
152
|
+
const domainTop = max > 0 ? max : 1;
|
|
153
|
+
const y = (value) => plotBottom - value / domainTop * plotHeight;
|
|
154
|
+
const band = plotWidth / count;
|
|
155
|
+
const barWidth = band >= 4 ? Math.min(band * 0.72, MAX_BAR_WIDTH) : Math.max(1, band - 0.75);
|
|
156
|
+
const barOffset = (band - barWidth) / 2;
|
|
157
|
+
const labelIndices = trendChartLabelIndices(count, plotWidth / X_LABEL_SPACING);
|
|
158
|
+
const fillFor = (index) => textures[index] === "hatch" ? `url(#${idBase}-hatch-${index})` : toneFill[series[index].tone];
|
|
159
|
+
const activePoint = active === null ? null : points[active];
|
|
160
|
+
const readoutId = `${idBase}-readout`;
|
|
161
|
+
const activeRows = activePoint ? series.map((s) => ({
|
|
162
|
+
id: s.id,
|
|
163
|
+
label: s.label,
|
|
164
|
+
value: formatValue(activePoint.values[s.id] ?? 0),
|
|
165
|
+
color: toneFill[s.tone]
|
|
166
|
+
})) : [];
|
|
167
|
+
const activeTitle = activePoint ? activePoint.detail ?? activePoint.label : "";
|
|
168
|
+
const containerWidth = containerRef.current?.clientWidth ?? width;
|
|
169
|
+
const toContainer = width > 0 ? containerWidth / width : 1;
|
|
170
|
+
return /* @__PURE__ */ jsxs(
|
|
171
|
+
"figure",
|
|
172
|
+
{
|
|
173
|
+
"data-slot": "trend-chart",
|
|
174
|
+
"aria-label": label,
|
|
175
|
+
className: cn("m-0 min-w-0 space-y-2", className),
|
|
176
|
+
children: [
|
|
177
|
+
/* @__PURE__ */ jsx(ChartHeader, { ...head, view, onViewChange: setView }),
|
|
178
|
+
view === "table" && /* @__PURE__ */ jsx(
|
|
179
|
+
ChartDataTable,
|
|
180
|
+
{
|
|
181
|
+
label,
|
|
182
|
+
table: {
|
|
183
|
+
columns: ["Period", ...series.map((s) => s.label), "Total"],
|
|
184
|
+
rows: points.map((point, index) => [
|
|
185
|
+
point.detail ?? point.label,
|
|
186
|
+
...series.map((s) => formatValue(point.values[s.id] ?? 0)),
|
|
187
|
+
formatValue(totals[index])
|
|
188
|
+
])
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
),
|
|
192
|
+
/* @__PURE__ */ jsx("p", { id: readoutId, "data-slot": "trend-chart-readout", "aria-live": "polite", className: "sr-only", children: activePoint ? tooltipText(activeTitle, activeRows) : "" }),
|
|
193
|
+
/* @__PURE__ */ jsxs(
|
|
194
|
+
"div",
|
|
195
|
+
{
|
|
196
|
+
ref: containerRef,
|
|
197
|
+
hidden: view === "table",
|
|
198
|
+
role: "group",
|
|
199
|
+
"aria-roledescription": "chart",
|
|
200
|
+
tabIndex: 0,
|
|
201
|
+
"aria-describedby": readoutId,
|
|
202
|
+
"aria-keyshortcuts": "ArrowLeft ArrowRight Home End Escape",
|
|
203
|
+
"aria-label": `${label}: ${count} periods. Arrow keys move between them.`,
|
|
204
|
+
onKeyDown: moveActive,
|
|
205
|
+
onBlur: () => setActive(null),
|
|
206
|
+
className: "relative mt-5 w-full min-w-0 rounded-xl outline-none transition-shadow focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:shadow-glow-primary-soft",
|
|
207
|
+
children: [
|
|
208
|
+
/* @__PURE__ */ jsxs(
|
|
209
|
+
"svg",
|
|
210
|
+
{
|
|
211
|
+
width: "100%",
|
|
212
|
+
height,
|
|
213
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
214
|
+
preserveAspectRatio: "none",
|
|
215
|
+
className: "block overflow-visible",
|
|
216
|
+
onPointerLeave: () => setActive(null),
|
|
217
|
+
"aria-hidden": "true",
|
|
218
|
+
children: [
|
|
219
|
+
/* @__PURE__ */ jsx("defs", { children: series.map(
|
|
220
|
+
(s, index) => textures[index] === "hatch" ? /* @__PURE__ */ jsx(Texture, { id: `${idBase}-hatch-${index}`, tone: s.tone, texture: "hatch" }, s.id) : null
|
|
221
|
+
) }),
|
|
222
|
+
/* @__PURE__ */ jsx("g", { "data-slot": "trend-chart-y-axis", children: ticks.map((tick, index) => /* @__PURE__ */ jsxs("g", { children: [
|
|
223
|
+
/* @__PURE__ */ jsx(
|
|
224
|
+
"line",
|
|
225
|
+
{
|
|
226
|
+
x1: plotLeft,
|
|
227
|
+
x2: plotRight,
|
|
228
|
+
y1: y(tick),
|
|
229
|
+
y2: y(tick),
|
|
230
|
+
stroke: "var(--border)",
|
|
231
|
+
strokeDasharray: tick === 0 ? void 0 : "2 3"
|
|
232
|
+
}
|
|
233
|
+
),
|
|
234
|
+
/* @__PURE__ */ jsx(
|
|
235
|
+
"text",
|
|
236
|
+
{
|
|
237
|
+
x: plotLeft - 6,
|
|
238
|
+
y: y(tick),
|
|
239
|
+
dy: "0.32em",
|
|
240
|
+
textAnchor: "end",
|
|
241
|
+
fontSize: TICK_FONT,
|
|
242
|
+
fill: "var(--muted-foreground)",
|
|
243
|
+
style: { fontVariantNumeric: "tabular-nums" },
|
|
244
|
+
children: tickLabels[index]
|
|
245
|
+
}
|
|
246
|
+
)
|
|
247
|
+
] }, tick)) }),
|
|
248
|
+
active !== null && /* @__PURE__ */ jsx(
|
|
249
|
+
"rect",
|
|
250
|
+
{
|
|
251
|
+
"data-slot": "trend-chart-active",
|
|
252
|
+
x: plotLeft + active * band,
|
|
253
|
+
y: plotTop,
|
|
254
|
+
width: band,
|
|
255
|
+
height: plotHeight,
|
|
256
|
+
fill: "var(--chart-4)",
|
|
257
|
+
opacity: 0.14
|
|
258
|
+
}
|
|
259
|
+
),
|
|
260
|
+
/* @__PURE__ */ jsx("g", { "data-slot": "trend-chart-bars", children: points.map((point, pointIndex) => {
|
|
261
|
+
let base = 0;
|
|
262
|
+
return /* @__PURE__ */ jsxs("g", { "data-period": point.key, children: [
|
|
263
|
+
series.map((s, seriesIndex) => {
|
|
264
|
+
const value = point.values[s.id] ?? 0;
|
|
265
|
+
if (value <= 0) return null;
|
|
266
|
+
const top = y(base + value);
|
|
267
|
+
const bottom = y(base);
|
|
268
|
+
base += value;
|
|
269
|
+
const hatched = textures[seriesIndex] === "hatch";
|
|
270
|
+
return /* @__PURE__ */ jsx(
|
|
271
|
+
"rect",
|
|
272
|
+
{
|
|
273
|
+
"data-series": s.id,
|
|
274
|
+
x: plotLeft + pointIndex * band + barOffset,
|
|
275
|
+
y: top,
|
|
276
|
+
width: barWidth,
|
|
277
|
+
height: Math.max(0.5, bottom - top - (seriesIndex > 0 ? 1 : 0)),
|
|
278
|
+
fill: fillFor(seriesIndex),
|
|
279
|
+
stroke: hatched ? toneFill[s.tone] : void 0,
|
|
280
|
+
strokeWidth: hatched && barWidth >= 4 ? 1 : 0
|
|
281
|
+
},
|
|
282
|
+
s.id
|
|
283
|
+
);
|
|
284
|
+
}),
|
|
285
|
+
/* @__PURE__ */ jsx(
|
|
286
|
+
"rect",
|
|
287
|
+
{
|
|
288
|
+
x: plotLeft + pointIndex * band,
|
|
289
|
+
y: plotTop,
|
|
290
|
+
width: band,
|
|
291
|
+
height: plotHeight,
|
|
292
|
+
fill: "transparent",
|
|
293
|
+
onPointerEnter: () => setActive(pointIndex)
|
|
294
|
+
}
|
|
295
|
+
)
|
|
296
|
+
] }, point.key);
|
|
297
|
+
}) }),
|
|
298
|
+
/* @__PURE__ */ jsx("g", { "data-slot": "trend-chart-x-axis", children: labelIndices.map((index) => /* @__PURE__ */ jsx(
|
|
299
|
+
"text",
|
|
300
|
+
{
|
|
301
|
+
x: plotLeft + index * band + band / 2,
|
|
302
|
+
y: plotBottom + 16,
|
|
303
|
+
textAnchor: index === 0 && count > 1 ? "start" : index === count - 1 && count > 1 ? "end" : "middle",
|
|
304
|
+
fontSize: TICK_FONT,
|
|
305
|
+
fill: "var(--muted-foreground)",
|
|
306
|
+
children: points[index].label
|
|
307
|
+
},
|
|
308
|
+
points[index].key
|
|
309
|
+
)) })
|
|
310
|
+
]
|
|
311
|
+
}
|
|
312
|
+
),
|
|
313
|
+
activePoint && /* @__PURE__ */ jsx(
|
|
314
|
+
ChartTooltip,
|
|
315
|
+
{
|
|
316
|
+
title: activeTitle,
|
|
317
|
+
rows: activeRows,
|
|
318
|
+
swatch: "rect",
|
|
319
|
+
x: (plotLeft + active * band + band / 2) * toContainer,
|
|
320
|
+
y: plotTop,
|
|
321
|
+
width: containerWidth
|
|
322
|
+
}
|
|
323
|
+
)
|
|
324
|
+
]
|
|
325
|
+
}
|
|
326
|
+
),
|
|
327
|
+
view === "chart" && /* @__PURE__ */ jsx(ChartLegendRow, { children: /* @__PURE__ */ jsx(
|
|
328
|
+
ChartLegend,
|
|
329
|
+
{
|
|
330
|
+
items: styledSeries.map((s, index) => ({
|
|
331
|
+
id: s.id,
|
|
332
|
+
label: s.label,
|
|
333
|
+
color: toneFill[s.tone],
|
|
334
|
+
swatch: /* @__PURE__ */ jsxs("svg", { width: "12", height: "12", "aria-hidden": "true", className: "shrink-0", children: [
|
|
335
|
+
/* @__PURE__ */ jsx(Texture, { id: `${idBase}-legend-${index}`, tone: s.tone, texture: s.texture }),
|
|
336
|
+
/* @__PURE__ */ jsx(
|
|
337
|
+
"rect",
|
|
338
|
+
{
|
|
339
|
+
width: "12",
|
|
340
|
+
height: "12",
|
|
341
|
+
rx: "2",
|
|
342
|
+
fill: s.texture === "hatch" ? `url(#${idBase}-legend-${index})` : toneFill[s.tone],
|
|
343
|
+
stroke: toneFill[s.tone]
|
|
344
|
+
}
|
|
345
|
+
)
|
|
346
|
+
] })
|
|
347
|
+
})),
|
|
348
|
+
...visibility.legend
|
|
349
|
+
}
|
|
350
|
+
) }),
|
|
351
|
+
/* @__PURE__ */ jsxs("p", { "data-slot": "trend-chart-scale", className: "sr-only", children: [
|
|
352
|
+
scaleLabel,
|
|
353
|
+
" \xB7 linear, from 0"
|
|
354
|
+
] })
|
|
355
|
+
]
|
|
356
|
+
}
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
function Texture({
|
|
360
|
+
id,
|
|
361
|
+
tone,
|
|
362
|
+
texture
|
|
363
|
+
}) {
|
|
364
|
+
if (texture !== "hatch") return null;
|
|
365
|
+
return /* @__PURE__ */ jsxs("pattern", { id, width: "4", height: "4", patternUnits: "userSpaceOnUse", patternTransform: "rotate(45)", children: [
|
|
366
|
+
/* @__PURE__ */ jsx("rect", { width: "4", height: "4", fill: toneFill[tone], opacity: 0.25 }),
|
|
367
|
+
/* @__PURE__ */ jsx("rect", { width: "2", height: "4", fill: toneFill[tone] })
|
|
368
|
+
] });
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export {
|
|
372
|
+
trendChartTicks,
|
|
373
|
+
trendChartLabelIndices,
|
|
374
|
+
TrendChart
|
|
375
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cn
|
|
4
|
+
} from "./chunk-PMGIJMRO.js";
|
|
5
|
+
|
|
6
|
+
// src/web/components/section-label.tsx
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
function SectionLabel({ children, className }) {
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
"span",
|
|
11
|
+
{
|
|
12
|
+
className: cn("text-mini font-medium uppercase tracking-eyebrow-wide text-muted-foreground", className),
|
|
13
|
+
children
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
SectionLabel
|
|
20
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cn
|
|
4
|
+
} from "./chunk-PMGIJMRO.js";
|
|
5
|
+
|
|
6
|
+
// src/web/components/empty-state.tsx
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
function EmptyState({ title, description, action, icon, className, descriptionClassName }) {
|
|
9
|
+
return /* @__PURE__ */ jsxs("div", { "data-slot": "empty-state", className: cn("flex flex-col items-center justify-center py-16 text-center", className), children: [
|
|
10
|
+
icon && /* @__PURE__ */ jsx(
|
|
11
|
+
"div",
|
|
12
|
+
{
|
|
13
|
+
"aria-hidden": "true",
|
|
14
|
+
className: "mb-4 flex size-16 items-center justify-center rounded-full bg-secondary/15 text-secondary-content shadow-glow-violet-soft",
|
|
15
|
+
children: icon
|
|
16
|
+
}
|
|
17
|
+
),
|
|
18
|
+
/* @__PURE__ */ jsx("h3", { className: "m-0 mb-1 text-body font-semibold text-foreground", children: title }),
|
|
19
|
+
description && /* @__PURE__ */ jsx("p", { className: cn("m-0 mb-4 max-w-[240px] text-caption text-muted-foreground", descriptionClassName), children: description }),
|
|
20
|
+
action
|
|
21
|
+
] });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
EmptyState
|
|
26
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/web/hooks/use-asset-icon.ts
|
|
4
|
+
import { useState, useEffect } from "react";
|
|
5
|
+
var DEFAULT_ICON_CDN_BASE_URL = "https://raw.githubusercontent.com/kaleidoswap/coinmarketcap-icons-cryptos/refs/heads/main/icons/";
|
|
6
|
+
var DICEBEAR_SHAPES_BASE_URL = "https://api.dicebear.com/9.x/shapes/svg";
|
|
7
|
+
var TICKER_MAPPINGS = {
|
|
8
|
+
SAT: "BTC",
|
|
9
|
+
None: ""
|
|
10
|
+
};
|
|
11
|
+
var VALID_ICON_TICKER_REGEX = /^[A-Z0-9-]{1,12}$/;
|
|
12
|
+
function getAssetIconUrl(ticker, cdnBaseUrl = DEFAULT_ICON_CDN_BASE_URL) {
|
|
13
|
+
if (!ticker || ticker.trim() === "") return "";
|
|
14
|
+
const normalized = ticker.toUpperCase().trim();
|
|
15
|
+
if (!VALID_ICON_TICKER_REGEX.test(normalized)) return "";
|
|
16
|
+
if (TICKER_MAPPINGS[normalized] !== void 0) {
|
|
17
|
+
const mapped = TICKER_MAPPINGS[normalized];
|
|
18
|
+
if (mapped === "") return "";
|
|
19
|
+
return getAssetIconUrl(mapped, cdnBaseUrl);
|
|
20
|
+
}
|
|
21
|
+
return `${cdnBaseUrl}${normalized.toLowerCase()}.png`;
|
|
22
|
+
}
|
|
23
|
+
function getFallbackAssetIconUrl(seed) {
|
|
24
|
+
const normalized = seed.trim();
|
|
25
|
+
if (!normalized) return "";
|
|
26
|
+
const params = new URLSearchParams({
|
|
27
|
+
seed: normalized,
|
|
28
|
+
backgroundType: "gradientLinear",
|
|
29
|
+
radius: "50"
|
|
30
|
+
});
|
|
31
|
+
return `${DICEBEAR_SHAPES_BASE_URL}?${params.toString()}`;
|
|
32
|
+
}
|
|
33
|
+
function useAssetIcon(ticker, cdnBaseUrl) {
|
|
34
|
+
const [url, setUrl] = useState(() => getAssetIconUrl(ticker, cdnBaseUrl));
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
setUrl(getAssetIconUrl(ticker, cdnBaseUrl));
|
|
37
|
+
}, [ticker, cdnBaseUrl]);
|
|
38
|
+
return url;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
getAssetIconUrl,
|
|
43
|
+
getFallbackAssetIconUrl,
|
|
44
|
+
useAssetIcon
|
|
45
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/web/utils/amount-display.ts
|
|
4
|
+
var NUMBER_RE = /^-?(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?$/;
|
|
5
|
+
function formatDisplayAmountText(value, options = {}) {
|
|
6
|
+
if (value === null || value === void 0 || value === "") return "";
|
|
7
|
+
const unit = options.unit ?? "token";
|
|
8
|
+
const raw = typeof value === "number" ? String(value) : value.trim();
|
|
9
|
+
const suffixMatch = raw.match(/(\s+[A-Za-z][\w.-]*)$/u);
|
|
10
|
+
const suffix = suffixMatch?.[1] ?? "";
|
|
11
|
+
const detectedUnit = suffix.trim() === "BTC" ? "BTC" : suffix.trim() === "sats" ? "sats" : suffix.trim() === "mBTC" ? "mBTC" : unit;
|
|
12
|
+
const maxDecimals = detectedUnit === "sats" ? 0 : detectedUnit === "BTC" ? 8 : detectedUnit === "mBTC" ? 5 : options.maxDecimals ?? 6;
|
|
13
|
+
const numeric = suffix ? raw.slice(0, -suffix.length) : raw;
|
|
14
|
+
const match = numeric.match(NUMBER_RE);
|
|
15
|
+
if (!match) return raw;
|
|
16
|
+
const num = parseFloat(numeric.replace(/,/g, ""));
|
|
17
|
+
if (!Number.isFinite(num)) return raw;
|
|
18
|
+
const factor = Math.pow(10, maxDecimals);
|
|
19
|
+
const rounded = Math.round(num * factor) / factor;
|
|
20
|
+
const formatted = rounded.toLocaleString("en-US", {
|
|
21
|
+
minimumFractionDigits: 0,
|
|
22
|
+
maximumFractionDigits: maxDecimals
|
|
23
|
+
});
|
|
24
|
+
return `${formatted}${suffix}`;
|
|
25
|
+
}
|
|
26
|
+
var DEFAULT_AMOUNT_LOCALE = "en-US";
|
|
27
|
+
function formatAmount(value, options = {}) {
|
|
28
|
+
if (!Number.isFinite(value)) return String(value);
|
|
29
|
+
return new Intl.NumberFormat(options.locale ?? DEFAULT_AMOUNT_LOCALE, {
|
|
30
|
+
maximumFractionDigits: options.maximumFractionDigits ?? 20
|
|
31
|
+
}).format(value);
|
|
32
|
+
}
|
|
33
|
+
function formatCompactAmount(value, locale = "en-US") {
|
|
34
|
+
if (!Number.isFinite(value)) return String(value);
|
|
35
|
+
return new Intl.NumberFormat(locale, {
|
|
36
|
+
notation: "compact",
|
|
37
|
+
maximumFractionDigits: 2
|
|
38
|
+
}).format(value);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
formatDisplayAmountText,
|
|
43
|
+
DEFAULT_AMOUNT_LOCALE,
|
|
44
|
+
formatAmount,
|
|
45
|
+
formatCompactAmount
|
|
46
|
+
};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
AssetIcon
|
|
4
|
+
} from "./chunk-2REWXJEN.js";
|
|
5
|
+
import {
|
|
6
|
+
NetworkBadge
|
|
7
|
+
} from "./chunk-IV6AAVUE.js";
|
|
8
|
+
import {
|
|
9
|
+
GlyphButton
|
|
10
|
+
} from "./chunk-JY3H7ZAI.js";
|
|
11
|
+
import {
|
|
12
|
+
eyebrow
|
|
13
|
+
} from "./chunk-MTQOAMDW.js";
|
|
14
|
+
import {
|
|
15
|
+
Edit
|
|
16
|
+
} from "./chunk-XXH4TYKZ.js";
|
|
17
|
+
import {
|
|
18
|
+
cn
|
|
19
|
+
} from "./chunk-PMGIJMRO.js";
|
|
20
|
+
|
|
21
|
+
// src/web/components/info-chip.tsx
|
|
22
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
23
|
+
var defaultStatusLabel = {
|
|
24
|
+
success: "Success",
|
|
25
|
+
warning: "Warning",
|
|
26
|
+
danger: "Error",
|
|
27
|
+
info: "Info"
|
|
28
|
+
};
|
|
29
|
+
var leadingToneClass = {
|
|
30
|
+
success: "bg-success/10 text-success-fg",
|
|
31
|
+
warning: "bg-warning/10 text-warning-fg",
|
|
32
|
+
danger: "bg-danger/10 text-danger-fg",
|
|
33
|
+
info: "bg-secondary/15 text-secondary-content"
|
|
34
|
+
};
|
|
35
|
+
var statusToneClass = {
|
|
36
|
+
success: "bg-success/10 text-success-fg",
|
|
37
|
+
warning: "bg-warning/10 text-warning-fg",
|
|
38
|
+
danger: "bg-danger/10 text-danger-fg",
|
|
39
|
+
info: "bg-secondary/15 text-secondary-content"
|
|
40
|
+
};
|
|
41
|
+
var statusDotClass = {
|
|
42
|
+
success: "bg-success",
|
|
43
|
+
warning: "bg-warning",
|
|
44
|
+
danger: "bg-danger",
|
|
45
|
+
info: "bg-secondary-content"
|
|
46
|
+
};
|
|
47
|
+
function StatusChip({ status, label, pulse = true, className }) {
|
|
48
|
+
return /* @__PURE__ */ jsxs(
|
|
49
|
+
"span",
|
|
50
|
+
{
|
|
51
|
+
"data-slot": "status-chip",
|
|
52
|
+
"data-status": status,
|
|
53
|
+
className: cn(
|
|
54
|
+
"inline-flex max-w-full items-center gap-1.5 rounded-full px-2 py-0.5 text-xxs font-bold leading-4",
|
|
55
|
+
statusToneClass[status],
|
|
56
|
+
className
|
|
57
|
+
),
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ jsxs("span", { "aria-hidden": "true", className: "relative flex size-1.5 shrink-0", children: [
|
|
60
|
+
pulse && /* @__PURE__ */ jsx(
|
|
61
|
+
"span",
|
|
62
|
+
{
|
|
63
|
+
"data-slot": "status-chip-pulse",
|
|
64
|
+
className: cn("absolute inset-0 rounded-full opacity-0 motion-safe:animate-ping motion-safe:opacity-75", statusDotClass[status])
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
/* @__PURE__ */ jsx("span", { className: cn("relative size-1.5 rounded-full", statusDotClass[status]) })
|
|
68
|
+
] }),
|
|
69
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: label ?? defaultStatusLabel[status] })
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
function InfoChip({
|
|
75
|
+
leading,
|
|
76
|
+
label,
|
|
77
|
+
value,
|
|
78
|
+
status,
|
|
79
|
+
statusLabel,
|
|
80
|
+
onEdit,
|
|
81
|
+
editLabel,
|
|
82
|
+
editDisabled,
|
|
83
|
+
className,
|
|
84
|
+
valueClassName,
|
|
85
|
+
"data-testid": dataTestId,
|
|
86
|
+
"data-info-kind": dataInfoKind
|
|
87
|
+
}) {
|
|
88
|
+
const readableStatus = status ? statusLabel ?? defaultStatusLabel[status] : null;
|
|
89
|
+
return /* @__PURE__ */ jsxs(
|
|
90
|
+
"div",
|
|
91
|
+
{
|
|
92
|
+
"data-slot": "info-chip",
|
|
93
|
+
"data-status": status,
|
|
94
|
+
"data-info-kind": dataInfoKind,
|
|
95
|
+
"data-testid": dataTestId,
|
|
96
|
+
className: cn(
|
|
97
|
+
"flex w-full max-w-full items-center gap-3 rounded-xl bg-surface-card bg-gradient-card px-3 py-2.5 shadow-raised",
|
|
98
|
+
className
|
|
99
|
+
),
|
|
100
|
+
children: [
|
|
101
|
+
leading && /* @__PURE__ */ jsx(
|
|
102
|
+
"span",
|
|
103
|
+
{
|
|
104
|
+
"aria-hidden": "true",
|
|
105
|
+
className: cn(
|
|
106
|
+
"flex size-9 shrink-0 items-center justify-center rounded-full bg-secondary/15 text-secondary-content [&_svg]:size-icon-lg",
|
|
107
|
+
status && leadingToneClass[status]
|
|
108
|
+
),
|
|
109
|
+
children: leading
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
/* @__PURE__ */ jsxs("dl", { className: "min-w-0 flex-1", children: [
|
|
113
|
+
/* @__PURE__ */ jsx("dt", { className: cn("truncate text-muted-foreground", eyebrow), children: label }),
|
|
114
|
+
/* @__PURE__ */ jsxs("dd", { className: "mt-0.5 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1", children: [
|
|
115
|
+
/* @__PURE__ */ jsx(
|
|
116
|
+
"span",
|
|
117
|
+
{
|
|
118
|
+
className: cn(
|
|
119
|
+
"min-w-0 max-w-full [overflow-wrap:anywhere] text-body font-semibold leading-5 text-foreground",
|
|
120
|
+
valueClassName
|
|
121
|
+
),
|
|
122
|
+
children: value
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
status && /* @__PURE__ */ jsx(StatusChip, { status, label: readableStatus ?? void 0 })
|
|
126
|
+
] })
|
|
127
|
+
] }),
|
|
128
|
+
onEdit && /* @__PURE__ */ jsx(GlyphButton, { icon: Edit, label: editLabel, onClick: onEdit, disabled: editDisabled })
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
function NetworkInfoChip({
|
|
134
|
+
network,
|
|
135
|
+
label = "Network",
|
|
136
|
+
value = network,
|
|
137
|
+
iconBasePath,
|
|
138
|
+
...infoChipProps
|
|
139
|
+
}) {
|
|
140
|
+
return /* @__PURE__ */ jsx(
|
|
141
|
+
InfoChip,
|
|
142
|
+
{
|
|
143
|
+
...infoChipProps,
|
|
144
|
+
"data-info-kind": "network",
|
|
145
|
+
leading: /* @__PURE__ */ jsx(NetworkBadge, { network, iconBasePath, size: "md" }),
|
|
146
|
+
label,
|
|
147
|
+
value
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
function AssetInfoChip({
|
|
152
|
+
ticker,
|
|
153
|
+
label = "Asset",
|
|
154
|
+
value = ticker,
|
|
155
|
+
logoUri,
|
|
156
|
+
cdnBaseUrl,
|
|
157
|
+
...infoChipProps
|
|
158
|
+
}) {
|
|
159
|
+
return /* @__PURE__ */ jsx(
|
|
160
|
+
InfoChip,
|
|
161
|
+
{
|
|
162
|
+
...infoChipProps,
|
|
163
|
+
"data-info-kind": "asset",
|
|
164
|
+
leading: /* @__PURE__ */ jsx(AssetIcon, { ticker, logoUri, cdnBaseUrl, size: 28 }),
|
|
165
|
+
label,
|
|
166
|
+
value
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export {
|
|
172
|
+
StatusChip,
|
|
173
|
+
InfoChip,
|
|
174
|
+
NetworkInfoChip,
|
|
175
|
+
AssetInfoChip
|
|
176
|
+
};
|