@adoptai/genui-components 0.1.54 → 0.1.55

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/renderer.js CHANGED
@@ -6606,6 +6606,14 @@ init_ThemeContext();
6606
6606
  var TERRACOTTA = ACCENT;
6607
6607
  var POS = "#15803d";
6608
6608
  var NEG = "#dc2626";
6609
+ var _CURRENCY = /* @__PURE__ */ new Set(["$", "\u20AC", "\xA3", "\xA5", "\u20B9"]);
6610
+ function _abbrev(n) {
6611
+ const a = Math.abs(n);
6612
+ if (a >= 1e9) return `${(a / 1e9).toFixed(1).replace(/\.0$/, "")}B`;
6613
+ if (a >= 1e6) return `${(a / 1e6).toFixed(1).replace(/\.0$/, "")}M`;
6614
+ if (a >= 1e3) return `${(a / 1e3).toFixed(1).replace(/\.0$/, "")}K`;
6615
+ return `${a}`;
6616
+ }
6609
6617
  var tooltipStyle3 = {
6610
6618
  fontSize: "12px",
6611
6619
  borderRadius: "8px",
@@ -6620,6 +6628,15 @@ function WaterfallChartResolver(p) {
6620
6628
  const { isVisible, toggle } = useSeriesToggle(["Positive", "Negative", "Total"]);
6621
6629
  const unit = (_a = p.unit) != null ? _a : "";
6622
6630
  const bars = (_b = p.bars) != null ? _b : [];
6631
+ const fmtVal = (v, withSign = false) => {
6632
+ const sign = v < 0 ? "-" : withSign && v > 0 ? "+" : "";
6633
+ const body = _CURRENCY.has(unit) ? `${unit}${_abbrev(v)}` : `${_abbrev(v)}${unit}`;
6634
+ return `${sign}${body}`;
6635
+ };
6636
+ const yAxisWidth = Math.min(
6637
+ 72,
6638
+ Math.max(40, ...bars.map((b) => fmtVal(b.value).length * 7 + 8))
6639
+ );
6623
6640
  let running = 0;
6624
6641
  const chartData = bars.map((bar) => {
6625
6642
  const base = bar.isTotal ? 0 : running;
@@ -6629,7 +6646,7 @@ function WaterfallChartResolver(p) {
6629
6646
  }).filter((d) => isVisible(d.category));
6630
6647
  return /* @__PURE__ */ jsx(ComponentActions, { filename: (_c = p.title) != null ? _c : "waterfall-chart", children: /* @__PURE__ */ jsxs("div", { style: { width: "100%", display: "flex", flexDirection: "column", gap: "12px" }, children: [
6631
6648
  p.title && /* @__PURE__ */ jsx("p", { style: { fontFamily: "var(--font-serif)", fontSize: "15px", fontWeight: 600, color: "var(--foreground)", letterSpacing: "-0.005em" }, children: p.title }),
6632
- /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: 200, children: /* @__PURE__ */ jsxs(BarChart, { data: chartData, margin: { top: 4, right: 8, left: 0, bottom: 0 }, children: [
6649
+ /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: 200, children: /* @__PURE__ */ jsxs(BarChart, { data: chartData, margin: { top: 4, right: 8, left: 4, bottom: 0 }, children: [
6633
6650
  /* @__PURE__ */ jsx(
6634
6651
  XAxis,
6635
6652
  {
@@ -6645,17 +6662,14 @@ function WaterfallChartResolver(p) {
6645
6662
  tick: { fontSize: 11, fill: MUTED2 },
6646
6663
  axisLine: false,
6647
6664
  tickLine: false,
6648
- width: 42,
6649
- tickFormatter: (v) => `${v}${unit}`
6665
+ width: yAxisWidth,
6666
+ tickFormatter: (v) => fmtVal(Number(v))
6650
6667
  }
6651
6668
  ),
6652
6669
  /* @__PURE__ */ jsx(
6653
6670
  Tooltip,
6654
6671
  {
6655
- formatter: (value) => {
6656
- const v = Number(value);
6657
- return [`${v > 0 ? "+" : ""}${v}${unit}`, ""];
6658
- },
6672
+ formatter: (value) => [fmtVal(Number(value), true), ""],
6659
6673
  contentStyle: tooltipStyle3,
6660
6674
  cursor: { fill: "#f2f2f2" }
6661
6675
  }