@eshal-bot/chat-widget 0.1.61 → 0.1.62

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.
@@ -91749,6 +91749,31 @@
91749
91749
  return String(n);
91750
91750
  }
91751
91751
 
91752
+ // ── Currency-aware value formatting ──────────────────────────────────────
91753
+ // A2UI chart data is normalized to `{ label, value }` by A2uiBlock's
91754
+ // numericData(), which drops the original Y-column key. A2uiBlock now threads
91755
+ // that key through as `props.yKey` so these renderers can decide whether the
91756
+ // axis / tooltip values are money. Heuristic mirrors the frontend's
91757
+ // chartShared.tsx `isCurrencyKey` — keep the keyword list in lockstep.
91758
+ // `(^|[_\W])` (not `\b`) so "average_salary" / "total_expenses" still match —
91759
+ // JS `\b` doesn't fire next to `_`.
91760
+ const CURRENCY_KEY_RE$1 = /(^|[_\W])(price|salary|cost|amount|revenue|expense|total|value|budget|spend|income|sale|balance)/i;
91761
+ function isCurrencyKey$1(key) {
91762
+ return typeof key === 'string' && CURRENCY_KEY_RE$1.test(key);
91763
+ }
91764
+
91765
+ // Compact currency for axis ticks → "$120.0k". Full currency for tooltips →
91766
+ // "$87,600" (comma-grouped, up to 2 decimals, no forced trailing zeros so a
91767
+ // whole-dollar salary reads "$81,200" not "$81,200.00").
91768
+ function formatCurrencyCompact(v) {
91769
+ return "$".concat(formatCompactNumber(v));
91770
+ }
91771
+ function formatCurrencyFull(v) {
91772
+ return "$".concat(Number(v).toLocaleString('en-US', {
91773
+ maximumFractionDigits: 2
91774
+ }));
91775
+ }
91776
+
91752
91777
  /**
91753
91778
  * Recharts bar chart — mirrors agent-sdk's eshalRenderers.BarChart.
91754
91779
  *
@@ -91761,6 +91786,11 @@
91761
91786
  isDark = false
91762
91787
  } = _ref;
91763
91788
  const data = Array.isArray(props.data) ? props.data : [];
91789
+ // Whether the Y values are money — drives the `$` on axis ticks + tooltip.
91790
+ const currency = isCurrencyKey$1(props.yKey);
91791
+ // Human series name for the tooltip ("Average Salary"), so it no longer
91792
+ // reads the generic dataKey "value".
91793
+ const seriesName = props.valueLabel || undefined;
91764
91794
  const borderColor = isDark ? '#374151' : '#e2e8f0';
91765
91795
  const bgColor = isDark ? '#1f2937' : '#ffffff';
91766
91796
  const labelColor = isDark ? '#9ca3af' : '#64748b';
@@ -91855,9 +91885,9 @@
91855
91885
  fontSize: 11,
91856
91886
  fill: labelColor
91857
91887
  } : undefined,
91858
- tickFormatter: v => props.unit ? "".concat(formatCompactNumber(v), " ").concat(props.unit) : formatCompactNumber(v)
91888
+ tickFormatter: v => currency ? formatCurrencyCompact(v) : props.unit ? "".concat(formatCompactNumber(v), " ").concat(props.unit) : formatCompactNumber(v)
91859
91889
  }), /*#__PURE__*/jsxRuntimeExports.jsx(Tooltip, {
91860
- formatter: v => props.unit ? "".concat(Number(v).toLocaleString(), " ").concat(props.unit) : Number(v).toLocaleString(),
91890
+ formatter: v => currency ? formatCurrencyFull(v) : props.unit ? "".concat(Number(v).toLocaleString(), " ").concat(props.unit) : Number(v).toLocaleString(),
91861
91891
  contentStyle: {
91862
91892
  background: tooltipBg,
91863
91893
  border: "1px solid ".concat(borderColor),
@@ -91867,6 +91897,7 @@
91867
91897
  }
91868
91898
  }), /*#__PURE__*/jsxRuntimeExports.jsx(Bar, {
91869
91899
  dataKey: "value",
91900
+ name: seriesName,
91870
91901
  fill: "#3b82f6",
91871
91902
  radius: [2, 2, 0, 0]
91872
91903
  })]
@@ -91950,6 +91981,7 @@
91950
91981
  donut = false
91951
91982
  } = _ref3;
91952
91983
  const data = Array.isArray(props.data) ? props.data : [];
91984
+ const currency = isCurrencyKey$1(props.yKey);
91953
91985
  const borderColor = isDark ? '#374151' : '#e2e8f0';
91954
91986
  const bgColor = isDark ? '#1f2937' : '#ffffff';
91955
91987
  const titleColor = isDark ? '#f3f4f6' : '#0f172a';
@@ -92000,7 +92032,7 @@
92000
92032
  fill: PIE_COLORS[i % PIE_COLORS.length]
92001
92033
  }, i))
92002
92034
  }), /*#__PURE__*/jsxRuntimeExports.jsx(Tooltip, {
92003
- formatter: v => Number(v).toLocaleString(),
92035
+ formatter: v => currency ? formatCurrencyFull(v) : Number(v).toLocaleString(),
92004
92036
  contentStyle: {
92005
92037
  background: tooltipBg,
92006
92038
  border: "1px solid ".concat(borderColor),
@@ -92034,6 +92066,8 @@
92034
92066
  area = false
92035
92067
  } = _ref4;
92036
92068
  const data = Array.isArray(props.data) ? props.data : [];
92069
+ const currency = isCurrencyKey$1(props.yKey);
92070
+ const seriesName = props.valueLabel || undefined;
92037
92071
  const borderColor = isDark ? '#374151' : '#e2e8f0';
92038
92072
  const bgColor = isDark ? '#1f2937' : '#ffffff';
92039
92073
  const labelColor = isDark ? '#9ca3af' : '#64748b';
@@ -92122,9 +92156,9 @@
92122
92156
  fontSize: 11,
92123
92157
  fill: labelColor
92124
92158
  },
92125
- tickFormatter: v => props.unit ? "".concat(formatCompactNumber(v), " ").concat(props.unit) : formatCompactNumber(v)
92159
+ tickFormatter: v => currency ? formatCurrencyCompact(v) : props.unit ? "".concat(formatCompactNumber(v), " ").concat(props.unit) : formatCompactNumber(v)
92126
92160
  }), /*#__PURE__*/jsxRuntimeExports.jsx(Tooltip, {
92127
- formatter: v => props.unit ? "".concat(Number(v).toLocaleString(), " ").concat(props.unit) : Number(v).toLocaleString(),
92161
+ formatter: v => currency ? formatCurrencyFull(v) : props.unit ? "".concat(Number(v).toLocaleString(), " ").concat(props.unit) : Number(v).toLocaleString(),
92128
92162
  contentStyle: {
92129
92163
  background: tooltipBg,
92130
92164
  border: "1px solid ".concat(borderColor),
@@ -92135,6 +92169,7 @@
92135
92169
  }), area ? /*#__PURE__*/jsxRuntimeExports.jsx(Area, {
92136
92170
  type: "monotone",
92137
92171
  dataKey: "value",
92172
+ name: seriesName,
92138
92173
  stroke: "#3b82f6",
92139
92174
  fill: "#3b82f6",
92140
92175
  fillOpacity: 0.15,
@@ -92146,6 +92181,7 @@
92146
92181
  }) : /*#__PURE__*/jsxRuntimeExports.jsx(Line, {
92147
92182
  type: "monotone",
92148
92183
  dataKey: "value",
92184
+ name: seriesName,
92149
92185
  stroke: "#3b82f6",
92150
92186
  strokeWidth: 2,
92151
92187
  dot: {
@@ -92343,7 +92379,14 @@
92343
92379
  data: rows,
92344
92380
  unit: spec.unit,
92345
92381
  xAxisLabel: spec.xAxisLabel,
92346
- yAxisLabel: spec.yAxisLabel
92382
+ yAxisLabel: spec.yAxisLabel,
92383
+ // numericData() collapses the rows to { label, value }, dropping the
92384
+ // original Y-column key. Pass it through so the renderer can detect a
92385
+ // currency column (→ "$" on the Y-axis + tooltip) and label the tooltip
92386
+ // series with the human column name ("Average Salary") instead of the
92387
+ // generic dataKey "value".
92388
+ yKey: y,
92389
+ valueLabel: prettifyLabel(y)
92347
92390
  };
92348
92391
  if (t === 'pie') return /*#__PURE__*/jsxRuntimeExports.jsx(PieChartRenderer, {
92349
92392
  props: chartProps,
@@ -92716,6 +92759,14 @@
92716
92759
  if (!SNAKE_CASE_CATEGORY_RE.test(value)) return value;
92717
92760
  return prettifyLabel(value);
92718
92761
  }
92762
+
92763
+ // Numeric string under a money column, e.g. "81,200" / "105444" / "-1,250.50".
92764
+ // Markdown tables (the common concierge path) arrive as text cells, so a
92765
+ // salary value is the STRING "81,200" — not a number — and skips the
92766
+ // USD_FORMATTER branch below. We prefix "$" while keeping the source's own
92767
+ // grouping/decimals so it reads "$81,200" (not "$81,200.00"). A leading "$"
92768
+ // already present makes the regex miss, so we never double-prefix.
92769
+ const _NUMERIC_STRING_RE = /^-?\d[\d,]*(\.\d+)?$/;
92719
92770
  function formatCell(v, columnKey) {
92720
92771
  if (v == null) return '';
92721
92772
  if (typeof v === 'number') {
@@ -92725,6 +92776,11 @@
92725
92776
  return Number.isInteger(v) ? String(v) : v.toFixed(2);
92726
92777
  }
92727
92778
  if (typeof v === 'object') return JSON.stringify(v);
92779
+ // Numeric string under a money-named column → prefix "$" (Bug: concierge
92780
+ // salary table showed "81,200" with no currency symbol).
92781
+ if (isCurrencyKey(columnKey) && _NUMERIC_STRING_RE.test(String(v).trim())) {
92782
+ return "$".concat(String(v).trim());
92783
+ }
92728
92784
  // String cells: prettify snake_case category labels (e.g.
92729
92785
  // `office_supplies` → "Office Supplies") so the table reads
92730
92786
  // consistently with the chart's X-axis ticks on the same data.