@burdenoff/microfe-bigconsole 2026.1103.4 → 2026.1103.5

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.
@@ -1,7 +1,7 @@
1
1
  import { FC } from 'react';
2
2
  import { ChartConfig, ChartData } from './types';
3
3
  export interface FunnelChartProps {
4
- /** Chart data (should be sorted by value descending) */
4
+ /** Chart data in funnel stage order */
5
5
  data: ChartData[];
6
6
  /** Chart configuration */
7
7
  config: ChartConfig;
@@ -1,68 +1,83 @@
1
1
  import { ChartTooltip as e } from "../ChartTooltip.js";
2
- import { memo as t } from "react";
3
- import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
- import { Cell as i, Funnel as a, FunnelChart as o, LabelList as s, ResponsiveContainer as c, Tooltip as l } from "recharts";
2
+ import { funnelStages as t } from "./funnelData.js";
3
+ import { memo as n } from "react";
4
+ import { useI18n as r } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
5
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
6
+ import { Cell as o, Funnel as s, FunnelChart as c, LabelList as l, ResponsiveContainer as u, Tooltip as d } from "recharts";
5
7
  //#region src/bigconsole/components/widgets/chart/charts/FunnelChart.tsx
6
- var u = [
8
+ var f = [
7
9
  "var(--color-chart-1)",
8
10
  "var(--color-chart-2)",
9
11
  "var(--color-chart-3)",
10
12
  "var(--color-chart-4)",
11
13
  "var(--color-chart-5)"
12
- ], d = t(function({ data: t = [], config: d, dataKey: f = "value", nameKey: p = "name", onDataClick: m }) {
13
- let h = (e) => typeof e == "number" ? new Intl.NumberFormat("en-US", {
14
+ ], p = n(function({ data: n = [], config: p, dataKey: m = "value", nameKey: h = "name", onDataClick: g }) {
15
+ let { t: _, locale: v } = r(), y = t(n, m, h), b = (e) => typeof e == "number" ? new Intl.NumberFormat("en-US", {
14
16
  notation: e >= 1e4 ? "compact" : "standard",
15
17
  maximumFractionDigits: 2
16
18
  }).format(e) : String(e);
17
- if (!t?.length) return null;
18
- let g = t.map((e, n) => {
19
- if (n === 0) return {
20
- ...e,
21
- rate: 100
22
- };
23
- let r = t[n - 1][f], i = e[f], a = r > 0 ? i / r * 100 : 0;
24
- return {
25
- ...e,
26
- rate: a
27
- };
19
+ if (!y || !y.length || y.every((e) => e.value === 0)) return /* @__PURE__ */ i("div", {
20
+ role: "status",
21
+ className: "flex items-center justify-center h-full text-text-secondary text-sm p-4",
22
+ children: y ? _("bigconsole.widgets.funnel.noCounts", "No funnel counts to display. Connect data with at least one count greater than zero.") : _("bigconsole.widgets.funnel.invalidFields", "Each funnel row needs a label in \"{{labelField}}\" and a non-negative number in \"{{valueField}}\". Choose the label and value fields in Style.", {
23
+ labelField: h,
24
+ valueField: m
25
+ })
28
26
  });
29
- return /* @__PURE__ */ n(c, {
30
- width: "100%",
31
- height: "100%",
32
- children: /* @__PURE__ */ r(o, { children: [/* @__PURE__ */ n(l, { content: /* @__PURE__ */ n(e, {
33
- valueFormatter: h,
34
- labelFormatter: (e) => String(e)
35
- }) }), /* @__PURE__ */ r(a, {
36
- dataKey: f,
37
- nameKey: p,
38
- data: g,
39
- isAnimationActive: !0,
40
- onClick: ((e, t) => {
41
- m && e && m(e, t);
42
- }),
43
- children: [
44
- /* @__PURE__ */ n(s, {
45
- position: "right",
46
- fill: "var(--color-text-primary)",
47
- stroke: "none",
48
- dataKey: p,
49
- fontSize: 12
50
- }),
51
- /* @__PURE__ */ n(s, {
52
- position: "center",
53
- fill: "var(--color-text-on-primary, #ffffff)",
54
- stroke: "none",
55
- formatter: (e) => h(e),
56
- fontSize: 14,
57
- fontWeight: 600
58
- }),
59
- g.map((e, t) => /* @__PURE__ */ n(i, {
60
- fill: d.colors?.[t] || u[t % u.length],
61
- style: { cursor: m ? "pointer" : "default" }
62
- }, `cell-${t}`))
63
- ]
64
- })] })
27
+ let x = new Intl.NumberFormat(v, {
28
+ style: "percent",
29
+ maximumFractionDigits: 1
30
+ }), S = y.map((e) => ({
31
+ ...e.row,
32
+ __conversionLabel: `${e.label} (${e.conversion === void 0 ? "—" : x.format(e.conversion)})`
33
+ }));
34
+ return /* @__PURE__ */ a("div", {
35
+ className: "flex flex-col h-full",
36
+ children: [/* @__PURE__ */ i("p", {
37
+ className: "text-xs text-text-secondary mb-2",
38
+ children: _("bigconsole.widgets.funnel.conversionBasis", "Conversion from previous stage; first stage is the baseline.")
39
+ }), /* @__PURE__ */ i("div", {
40
+ className: "flex-1 min-h-0",
41
+ children: /* @__PURE__ */ i(u, {
42
+ width: "100%",
43
+ height: "100%",
44
+ children: /* @__PURE__ */ a(c, { children: [/* @__PURE__ */ i(d, { content: /* @__PURE__ */ i(e, {
45
+ valueFormatter: b,
46
+ labelFormatter: (e) => String(e)
47
+ }) }), /* @__PURE__ */ a(s, {
48
+ dataKey: m,
49
+ nameKey: h,
50
+ data: S,
51
+ isAnimationActive: !0,
52
+ onClick: (e, t) => {
53
+ t !== void 0 && n[t] && g?.(n[t], t);
54
+ },
55
+ children: [
56
+ /* @__PURE__ */ i(l, {
57
+ position: "right",
58
+ fill: "var(--color-text-primary)",
59
+ stroke: "none",
60
+ dataKey: "__conversionLabel",
61
+ fontSize: 12
62
+ }),
63
+ /* @__PURE__ */ i(l, {
64
+ position: "center",
65
+ fill: "var(--color-text-on-primary, #ffffff)",
66
+ stroke: "none",
67
+ dataKey: m,
68
+ formatter: (e) => b(e),
69
+ fontSize: 14,
70
+ fontWeight: 600
71
+ }),
72
+ S.map((e, t) => /* @__PURE__ */ i(o, {
73
+ fill: p.colors?.[t] || f[t % f.length],
74
+ style: { cursor: g ? "pointer" : "default" }
75
+ }, `cell-${t}`))
76
+ ]
77
+ })] })
78
+ })
79
+ })]
65
80
  });
66
81
  });
67
82
  //#endregion
68
- export { d as FunnelChart, d as default };
83
+ export { p as FunnelChart, p as default };
@@ -0,0 +1,8 @@
1
+ import { ChartData } from './types';
2
+ /** Keep the caller's stage order; conversions compare adjacent stages. */
3
+ export declare function funnelStages(data: ChartData[], valueField: string, labelField: string): {
4
+ row: ChartData;
5
+ value: number;
6
+ label: string;
7
+ conversion: number | undefined;
8
+ }[] | null;
@@ -0,0 +1,17 @@
1
+ //#region src/bigconsole/components/widgets/chart/charts/funnelData.ts
2
+ function e(e, t, n) {
3
+ return !Array.isArray(e) || e.some((e) => {
4
+ let r = e?.[t], i = e?.[n];
5
+ return typeof r != "number" || !Number.isFinite(r) || r < 0 || !["string", "number"].includes(typeof i) || String(i).trim() === "";
6
+ }) ? null : e.map((r, i) => {
7
+ let a = r[t], o = e[Math.max(0, i - 1)][t];
8
+ return {
9
+ row: r,
10
+ value: a,
11
+ label: String(r[n]),
12
+ conversion: o > 0 ? a / o : void 0
13
+ };
14
+ });
15
+ }
16
+ //#endregion
17
+ export { e as funnelStages };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-bigconsole",
3
- "version": "2026.1103.4",
3
+ "version": "2026.1103.5",
4
4
  "description": "BigConsole - AI-powered analytics and dashboard platform",
5
5
  "type": "module",
6
6
  "files": [