kaleido-ui 0.2.1 → 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/css/kaleido-ui.css +0 -4
- 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 +3447 -2567
- package/dist/web/index.d.cts +507 -113
- package/dist/web/index.d.ts +507 -113
- package/dist/web/index.js +612 -13675
- 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,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cn
|
|
4
|
+
} from "./chunk-PMGIJMRO.js";
|
|
5
|
+
|
|
6
|
+
// src/web/components/list-summary.tsx
|
|
7
|
+
import { jsxs } from "react/jsx-runtime";
|
|
8
|
+
var count = (n, noun) => `${n} ${n === 1 ? noun.replace(/s$/, "") : noun}`;
|
|
9
|
+
function ListSummary({
|
|
10
|
+
noun,
|
|
11
|
+
shown,
|
|
12
|
+
offset,
|
|
13
|
+
total,
|
|
14
|
+
filtersActive = false,
|
|
15
|
+
noTotalNote = ", narrowed by the filters above. The API does not report how many exist in all.",
|
|
16
|
+
className,
|
|
17
|
+
...rest
|
|
18
|
+
}) {
|
|
19
|
+
let text;
|
|
20
|
+
if (total !== void 0) {
|
|
21
|
+
text = filtersActive ? `Showing ${shown} of ${count(total, noun)}` : count(total, noun);
|
|
22
|
+
} else if (offset !== void 0 && shown > 0) {
|
|
23
|
+
text = `Showing ${noun} ${offset + 1}\u2013${offset + shown}`;
|
|
24
|
+
} else {
|
|
25
|
+
text = `Showing ${count(shown, noun)}`;
|
|
26
|
+
}
|
|
27
|
+
return /* @__PURE__ */ jsxs("p", { "data-slot": "list-summary", className: cn("m-0 text-caption tabular-nums text-muted-foreground", className), ...rest, children: [
|
|
28
|
+
text,
|
|
29
|
+
filtersActive && total === void 0 ? noTotalNote : ""
|
|
30
|
+
] });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
ListSummary
|
|
35
|
+
};
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
ChartFrame,
|
|
4
|
+
ChartLegend,
|
|
5
|
+
ChartTooltip,
|
|
6
|
+
LegendSwatch,
|
|
7
|
+
TICK_FONT,
|
|
8
|
+
axisTextWidth,
|
|
9
|
+
chartLabelIndices,
|
|
10
|
+
chartValueTicks,
|
|
11
|
+
defaultChartFormat,
|
|
12
|
+
nextActiveIndex,
|
|
13
|
+
plotClass,
|
|
14
|
+
seriesColor,
|
|
15
|
+
tooltipText,
|
|
16
|
+
useChartWidth,
|
|
17
|
+
useSeriesVisibility
|
|
18
|
+
} from "./chunk-EK5N3ZPW.js";
|
|
19
|
+
|
|
20
|
+
// src/web/components/charts/mixed-chart.tsx
|
|
21
|
+
import { useId, useState } from "react";
|
|
22
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
23
|
+
var MARK_VIEWS = {
|
|
24
|
+
bar: { value: "bar", label: "Bars", icon: "bar_chart" },
|
|
25
|
+
stacked: { value: "stacked", label: "Stacked bars", icon: "stacked_bar_chart" },
|
|
26
|
+
line: { value: "line", label: "Lines", icon: "show_chart" },
|
|
27
|
+
area: { value: "area", label: "Areas", icon: "area_chart" },
|
|
28
|
+
dots: { value: "dots", label: "Dots", icon: "scatter_plot" }
|
|
29
|
+
};
|
|
30
|
+
var MARGIN = { top: 12, right: 16, bottom: 26, left: 8 };
|
|
31
|
+
var MAX_BAR_GROUP = 56;
|
|
32
|
+
var ALL_MARKS = ["bar", "stacked", "line", "area", "dots"];
|
|
33
|
+
function MarkSwatch({ mark, color }) {
|
|
34
|
+
if (mark === "area") {
|
|
35
|
+
return /* @__PURE__ */ jsxs("svg", { width: "12", height: "12", "aria-hidden": "true", className: "shrink-0", children: [
|
|
36
|
+
/* @__PURE__ */ jsx("rect", { width: "12", height: "12", rx: "3", fill: color, fillOpacity: "0.25" }),
|
|
37
|
+
/* @__PURE__ */ jsx("line", { x1: "1", x2: "11", y1: "3", y2: "3", stroke: color, strokeWidth: "2", strokeLinecap: "round" })
|
|
38
|
+
] });
|
|
39
|
+
}
|
|
40
|
+
return /* @__PURE__ */ jsx(LegendSwatch, { color, shape: mark === "line" ? "line" : mark === "dots" ? "dot" : "rect" });
|
|
41
|
+
}
|
|
42
|
+
function MixedChart({
|
|
43
|
+
data,
|
|
44
|
+
series: allSeries,
|
|
45
|
+
label,
|
|
46
|
+
scaleLabel,
|
|
47
|
+
marks = ALL_MARKS,
|
|
48
|
+
integer = false,
|
|
49
|
+
formatValue = defaultChartFormat,
|
|
50
|
+
height = 280,
|
|
51
|
+
empty,
|
|
52
|
+
className,
|
|
53
|
+
...head
|
|
54
|
+
}) {
|
|
55
|
+
const [containerRef, width] = useChartWidth();
|
|
56
|
+
const [active, setActive] = useState(null);
|
|
57
|
+
const [chosen, setChosen] = useState(marks[0] ?? "bar");
|
|
58
|
+
const mark = marks.includes(chosen) ? chosen : marks[0] ?? "bar";
|
|
59
|
+
const idBase = `mixed-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;
|
|
60
|
+
const visibility = useSeriesVisibility(allSeries.map((s) => s.id));
|
|
61
|
+
const series = allSeries.filter((s) => visibility.isVisible(s.id));
|
|
62
|
+
const colorOf = (id) => seriesColor(allSeries.findIndex((s) => s.id === id));
|
|
63
|
+
const count = data.length;
|
|
64
|
+
if (count === 0 || allSeries.length === 0) return /* @__PURE__ */ jsx(Fragment, { children: empty ?? null });
|
|
65
|
+
const totals = data.map((d) => series.reduce((sum, s) => sum + Math.max(0, d.values[s.id] ?? 0), 0));
|
|
66
|
+
const max = mark === "stacked" ? Math.max(0, ...totals) : Math.max(0, ...data.flatMap((d) => series.map((s) => d.values[s.id] ?? 0)));
|
|
67
|
+
const ticks = chartValueTicks(max, { integer });
|
|
68
|
+
const tickLabels = ticks.map(formatValue);
|
|
69
|
+
const plotLeft = MARGIN.left + axisTextWidth(tickLabels) + 8;
|
|
70
|
+
const plotRight = width - MARGIN.right;
|
|
71
|
+
const plotTop = MARGIN.top;
|
|
72
|
+
const plotBottom = height - MARGIN.bottom;
|
|
73
|
+
const plotWidth = Math.max(1, plotRight - plotLeft);
|
|
74
|
+
const plotHeight = Math.max(1, plotBottom - plotTop);
|
|
75
|
+
const top = max > 0 ? max : 1;
|
|
76
|
+
const band = plotWidth / count;
|
|
77
|
+
const x = (index) => plotLeft + band * (index + 0.5);
|
|
78
|
+
const y = (value) => plotBottom - Math.max(0, value) / top * plotHeight;
|
|
79
|
+
const labelIndices = chartLabelIndices(count, plotWidth / 72);
|
|
80
|
+
const groupWidth = Math.min(band * 0.7, MAX_BAR_GROUP);
|
|
81
|
+
const barWidth = mark === "stacked" ? groupWidth : Math.max(1, (groupWidth - (series.length - 1) * 2) / Math.max(1, series.length));
|
|
82
|
+
const pathFor = (id) => data.map((d, index) => `${index === 0 ? "M" : "L"}${x(index).toFixed(2)},${y(d.values[id] ?? 0).toFixed(2)}`).join("");
|
|
83
|
+
const rowsAt = (index) => series.map((s) => ({
|
|
84
|
+
id: s.id,
|
|
85
|
+
label: s.label,
|
|
86
|
+
value: formatValue(data[index].values[s.id] ?? 0),
|
|
87
|
+
color: colorOf(s.id)
|
|
88
|
+
}));
|
|
89
|
+
const onPointerMove = (event) => {
|
|
90
|
+
const box = event.currentTarget.getBoundingClientRect();
|
|
91
|
+
const px = (event.clientX - box.left) / box.width * width;
|
|
92
|
+
setActive(Math.max(0, Math.min(count - 1, Math.floor((px - plotLeft) / band))));
|
|
93
|
+
};
|
|
94
|
+
const onKeyDown = (event) => {
|
|
95
|
+
if (nextActiveIndex(event.key, active, count) === void 0) return;
|
|
96
|
+
event.preventDefault();
|
|
97
|
+
setActive((current) => {
|
|
98
|
+
const next = nextActiveIndex(event.key, current, count);
|
|
99
|
+
return next === void 0 ? current : next;
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
const activeDatum = active === null ? null : data[active];
|
|
103
|
+
const strokeFor = (s) => /* @__PURE__ */ jsx(
|
|
104
|
+
"path",
|
|
105
|
+
{
|
|
106
|
+
"data-series": s.id,
|
|
107
|
+
"data-mark": mark,
|
|
108
|
+
d: pathFor(s.id),
|
|
109
|
+
fill: "none",
|
|
110
|
+
stroke: colorOf(s.id),
|
|
111
|
+
strokeWidth: mark === "area" ? 1.5 : 2,
|
|
112
|
+
strokeLinejoin: "round",
|
|
113
|
+
strokeLinecap: "round"
|
|
114
|
+
},
|
|
115
|
+
s.id
|
|
116
|
+
);
|
|
117
|
+
const marksLayer = () => {
|
|
118
|
+
if (mark === "bar" || mark === "stacked") {
|
|
119
|
+
return data.map((d, index) => {
|
|
120
|
+
let stackTop = 0;
|
|
121
|
+
return series.map((s, position) => {
|
|
122
|
+
const value = Math.max(0, d.values[s.id] ?? 0);
|
|
123
|
+
const left = mark === "stacked" ? x(index) - groupWidth / 2 : x(index) - groupWidth / 2 + position * (barWidth + 2);
|
|
124
|
+
const bottom = mark === "stacked" ? y(stackTop) : plotBottom;
|
|
125
|
+
if (mark === "stacked") stackTop += value;
|
|
126
|
+
const barTop = mark === "stacked" ? y(stackTop) : y(value);
|
|
127
|
+
return /* @__PURE__ */ jsx(
|
|
128
|
+
"rect",
|
|
129
|
+
{
|
|
130
|
+
"data-series": s.id,
|
|
131
|
+
"data-mark": mark,
|
|
132
|
+
x: left,
|
|
133
|
+
y: barTop,
|
|
134
|
+
width: barWidth,
|
|
135
|
+
height: Math.max(0, bottom - barTop - (mark === "stacked" && position > 0 ? 1 : 0)),
|
|
136
|
+
rx: mark === "stacked" ? 0 : Math.min(3, barWidth / 2),
|
|
137
|
+
fill: colorOf(s.id)
|
|
138
|
+
},
|
|
139
|
+
`${s.id}-${d.key}`
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
if (mark === "dots") {
|
|
145
|
+
return series.map((s) => /* @__PURE__ */ jsx("g", { "data-series": s.id, "data-mark": "dots", children: data.map((d, index) => /* @__PURE__ */ jsx("circle", { cx: x(index), cy: y(d.values[s.id] ?? 0), r: 4, fill: colorOf(s.id), stroke: "var(--card)", strokeWidth: 1.5 }, d.key)) }, s.id));
|
|
146
|
+
}
|
|
147
|
+
if (mark === "area") {
|
|
148
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
149
|
+
series.map((s) => /* @__PURE__ */ jsx(
|
|
150
|
+
"path",
|
|
151
|
+
{
|
|
152
|
+
d: `${pathFor(s.id)}L${x(count - 1)},${plotBottom}L${x(0)},${plotBottom}Z`,
|
|
153
|
+
fill: `url(#${idBase}-wash-${s.id})`
|
|
154
|
+
},
|
|
155
|
+
`${s.id}-wash`
|
|
156
|
+
)),
|
|
157
|
+
series.map(strokeFor)
|
|
158
|
+
] });
|
|
159
|
+
}
|
|
160
|
+
return series.map(strokeFor);
|
|
161
|
+
};
|
|
162
|
+
return /* @__PURE__ */ jsx(
|
|
163
|
+
ChartFrame,
|
|
164
|
+
{
|
|
165
|
+
...head,
|
|
166
|
+
views: marks.map((m) => MARK_VIEWS[m]),
|
|
167
|
+
chartView: mark,
|
|
168
|
+
onChartViewChange: (next) => setChosen(next),
|
|
169
|
+
label,
|
|
170
|
+
className,
|
|
171
|
+
scale: `${scaleLabel} \xB7 linear, from 0`,
|
|
172
|
+
legend: /* @__PURE__ */ jsx(
|
|
173
|
+
ChartLegend,
|
|
174
|
+
{
|
|
175
|
+
items: allSeries.map((s) => ({
|
|
176
|
+
id: s.id,
|
|
177
|
+
label: s.label,
|
|
178
|
+
color: colorOf(s.id),
|
|
179
|
+
swatch: /* @__PURE__ */ jsx(MarkSwatch, { mark, color: colorOf(s.id) })
|
|
180
|
+
})),
|
|
181
|
+
...visibility.legend
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
table: {
|
|
185
|
+
columns: ["Period", ...allSeries.map((s) => s.label)],
|
|
186
|
+
rows: data.map((d) => [d.detail ?? d.label, ...allSeries.map((s) => formatValue(d.values[s.id] ?? 0))])
|
|
187
|
+
},
|
|
188
|
+
announcement: activeDatum ? tooltipText(activeDatum.detail ?? activeDatum.label, rowsAt(active)) : void 0,
|
|
189
|
+
children: /* @__PURE__ */ jsxs(
|
|
190
|
+
"div",
|
|
191
|
+
{
|
|
192
|
+
ref: containerRef,
|
|
193
|
+
role: "group",
|
|
194
|
+
"aria-roledescription": "chart",
|
|
195
|
+
"aria-label": `${label}: ${count} periods. Arrow keys move between them.`,
|
|
196
|
+
tabIndex: 0,
|
|
197
|
+
onKeyDown,
|
|
198
|
+
onBlur: () => setActive(null),
|
|
199
|
+
className: plotClass,
|
|
200
|
+
children: [
|
|
201
|
+
/* @__PURE__ */ jsxs(
|
|
202
|
+
"svg",
|
|
203
|
+
{
|
|
204
|
+
width: "100%",
|
|
205
|
+
height,
|
|
206
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
207
|
+
className: "block overflow-visible",
|
|
208
|
+
"aria-hidden": "true",
|
|
209
|
+
onPointerMove,
|
|
210
|
+
onPointerLeave: () => setActive(null),
|
|
211
|
+
children: [
|
|
212
|
+
/* @__PURE__ */ jsx("defs", { children: mark === "area" && series.map((s) => /* @__PURE__ */ jsxs("linearGradient", { id: `${idBase}-wash-${s.id}`, x1: "0", x2: "0", y1: "0", y2: "1", children: [
|
|
213
|
+
/* @__PURE__ */ jsx("stop", { offset: "0", stopColor: colorOf(s.id), stopOpacity: "0.22" }),
|
|
214
|
+
/* @__PURE__ */ jsx("stop", { offset: "1", stopColor: colorOf(s.id), stopOpacity: "0.03" })
|
|
215
|
+
] }, s.id)) }),
|
|
216
|
+
/* @__PURE__ */ jsx("g", { "data-slot": "chart-y-axis", children: ticks.map((tick, index) => /* @__PURE__ */ jsxs("g", { children: [
|
|
217
|
+
/* @__PURE__ */ jsx("line", { x1: plotLeft, x2: plotRight, y1: y(tick), y2: y(tick), stroke: "var(--border)" }),
|
|
218
|
+
/* @__PURE__ */ jsx(
|
|
219
|
+
"text",
|
|
220
|
+
{
|
|
221
|
+
x: plotLeft - 8,
|
|
222
|
+
y: y(tick),
|
|
223
|
+
dy: "0.32em",
|
|
224
|
+
textAnchor: "end",
|
|
225
|
+
fontSize: TICK_FONT,
|
|
226
|
+
fill: "var(--muted-foreground)",
|
|
227
|
+
style: { fontVariantNumeric: "tabular-nums" },
|
|
228
|
+
children: tickLabels[index]
|
|
229
|
+
}
|
|
230
|
+
)
|
|
231
|
+
] }, tick)) }),
|
|
232
|
+
active !== null && /* @__PURE__ */ jsx(
|
|
233
|
+
"rect",
|
|
234
|
+
{
|
|
235
|
+
"data-slot": "chart-active-band",
|
|
236
|
+
x: plotLeft + band * active,
|
|
237
|
+
y: plotTop,
|
|
238
|
+
width: band,
|
|
239
|
+
height: plotBottom - plotTop,
|
|
240
|
+
fill: "var(--muted-foreground)",
|
|
241
|
+
fillOpacity: 0.08
|
|
242
|
+
}
|
|
243
|
+
),
|
|
244
|
+
/* @__PURE__ */ jsx("g", { "data-slot": "chart-marks", "data-view": mark, children: marksLayer() }),
|
|
245
|
+
active !== null && /* @__PURE__ */ jsx("g", { "data-slot": "chart-crosshair", children: (mark === "bar" || mark === "stacked" ? [] : series).map((s) => /* @__PURE__ */ jsx(
|
|
246
|
+
"circle",
|
|
247
|
+
{
|
|
248
|
+
cx: x(active),
|
|
249
|
+
cy: y(data[active].values[s.id] ?? 0),
|
|
250
|
+
r: 4.5,
|
|
251
|
+
fill: colorOf(s.id),
|
|
252
|
+
stroke: "var(--card)",
|
|
253
|
+
strokeWidth: 2
|
|
254
|
+
},
|
|
255
|
+
s.id
|
|
256
|
+
)) }),
|
|
257
|
+
/* @__PURE__ */ jsx("g", { "data-slot": "chart-x-axis", children: labelIndices.map((index) => /* @__PURE__ */ jsx(
|
|
258
|
+
"text",
|
|
259
|
+
{
|
|
260
|
+
x: x(index),
|
|
261
|
+
y: plotBottom + 18,
|
|
262
|
+
textAnchor: "middle",
|
|
263
|
+
fontSize: TICK_FONT,
|
|
264
|
+
fill: "var(--muted-foreground)",
|
|
265
|
+
children: data[index].label
|
|
266
|
+
},
|
|
267
|
+
data[index].key
|
|
268
|
+
)) })
|
|
269
|
+
]
|
|
270
|
+
}
|
|
271
|
+
),
|
|
272
|
+
activeDatum && /* @__PURE__ */ jsx(
|
|
273
|
+
ChartTooltip,
|
|
274
|
+
{
|
|
275
|
+
title: activeDatum.detail ?? activeDatum.label,
|
|
276
|
+
rows: rowsAt(active),
|
|
277
|
+
x: x(active) * (containerRef.current ? containerRef.current.clientWidth / width : 1),
|
|
278
|
+
y: plotTop,
|
|
279
|
+
width: containerRef.current?.clientWidth ?? width
|
|
280
|
+
}
|
|
281
|
+
)
|
|
282
|
+
]
|
|
283
|
+
}
|
|
284
|
+
)
|
|
285
|
+
}
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export {
|
|
290
|
+
MixedChart
|
|
291
|
+
};
|