@adoptai/genui-components 0.1.54 → 0.1.56

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/resolver.cjs CHANGED
@@ -6634,6 +6634,14 @@ init_ThemeContext();
6634
6634
  var TERRACOTTA = ACCENT;
6635
6635
  var POS = "#15803d";
6636
6636
  var NEG = "#dc2626";
6637
+ var _CURRENCY = /* @__PURE__ */ new Set(["$", "\u20AC", "\xA3", "\xA5", "\u20B9"]);
6638
+ function _abbrev(n) {
6639
+ const a = Math.abs(n);
6640
+ if (a >= 1e9) return `${(a / 1e9).toFixed(1).replace(/\.0$/, "")}B`;
6641
+ if (a >= 1e6) return `${(a / 1e6).toFixed(1).replace(/\.0$/, "")}M`;
6642
+ if (a >= 1e3) return `${(a / 1e3).toFixed(1).replace(/\.0$/, "")}K`;
6643
+ return `${a}`;
6644
+ }
6637
6645
  var tooltipStyle3 = {
6638
6646
  fontSize: "12px",
6639
6647
  borderRadius: "8px",
@@ -6648,6 +6656,15 @@ function WaterfallChartResolver(p) {
6648
6656
  const { isVisible, toggle } = useSeriesToggle(["Positive", "Negative", "Total"]);
6649
6657
  const unit = (_a = p.unit) != null ? _a : "";
6650
6658
  const bars = (_b = p.bars) != null ? _b : [];
6659
+ const fmtVal = (v, withSign = false) => {
6660
+ const sign = v < 0 ? "-" : withSign && v > 0 ? "+" : "";
6661
+ const body = _CURRENCY.has(unit) ? `${unit}${_abbrev(v)}` : `${_abbrev(v)}${unit}`;
6662
+ return `${sign}${body}`;
6663
+ };
6664
+ const yAxisWidth = Math.min(
6665
+ 72,
6666
+ Math.max(40, ...bars.map((b) => fmtVal(b.value).length * 7 + 8))
6667
+ );
6651
6668
  let running = 0;
6652
6669
  const chartData = bars.map((bar) => {
6653
6670
  const base = bar.isTotal ? 0 : running;
@@ -6657,7 +6674,7 @@ function WaterfallChartResolver(p) {
6657
6674
  }).filter((d) => isVisible(d.category));
6658
6675
  return /* @__PURE__ */ jsxRuntime.jsx(ComponentActions, { filename: (_c = p.title) != null ? _c : "waterfall-chart", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "12px" }, children: [
6659
6676
  p.title && /* @__PURE__ */ jsxRuntime.jsx("p", { style: { fontFamily: "var(--font-serif)", fontSize: "15px", fontWeight: 600, color: "var(--foreground)", letterSpacing: "-0.005em" }, children: p.title }),
6660
- /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: 200, children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.BarChart, { data: chartData, margin: { top: 4, right: 8, left: 0, bottom: 0 }, children: [
6677
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: 200, children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.BarChart, { data: chartData, margin: { top: 4, right: 8, left: 4, bottom: 0 }, children: [
6661
6678
  /* @__PURE__ */ jsxRuntime.jsx(
6662
6679
  recharts.XAxis,
6663
6680
  {
@@ -6673,17 +6690,14 @@ function WaterfallChartResolver(p) {
6673
6690
  tick: { fontSize: 11, fill: MUTED2 },
6674
6691
  axisLine: false,
6675
6692
  tickLine: false,
6676
- width: 42,
6677
- tickFormatter: (v) => `${v}${unit}`
6693
+ width: yAxisWidth,
6694
+ tickFormatter: (v) => fmtVal(Number(v))
6678
6695
  }
6679
6696
  ),
6680
6697
  /* @__PURE__ */ jsxRuntime.jsx(
6681
6698
  recharts.Tooltip,
6682
6699
  {
6683
- formatter: (value) => {
6684
- const v = Number(value);
6685
- return [`${v > 0 ? "+" : ""}${v}${unit}`, ""];
6686
- },
6700
+ formatter: (value) => [fmtVal(Number(value), true), ""],
6687
6701
  contentStyle: tooltipStyle3,
6688
6702
  cursor: { fill: "#f2f2f2" }
6689
6703
  }