@umituz/web-dashboard 8.11.0 → 9.0.0

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.
Files changed (46) hide show
  1. package/README.md +54 -7
  2. package/package.json +6 -2
  3. package/src/config/DashboardConfig.ts +4 -8
  4. package/src/domains/analytics/components/AnalyticsLayout.test.tsx +85 -0
  5. package/src/domains/analytics/components/AnalyticsLayout.tsx +103 -105
  6. package/src/domains/analytics/components/index.ts +0 -3
  7. package/src/domains/analytics/hooks/index.ts +1 -1
  8. package/src/domains/analytics/hooks/useAnalytics.test.tsx +125 -0
  9. package/src/domains/analytics/hooks/useAnalytics.ts +37 -56
  10. package/src/domains/analytics/index.ts +9 -26
  11. package/src/domains/analytics/services/index.ts +0 -1
  12. package/src/domains/analytics/types/analytics.ts +32 -149
  13. package/src/domains/analytics/types/index.ts +3 -15
  14. package/src/domains/analytics/utils/analytics.test.ts +82 -13
  15. package/src/domains/analytics/utils/analytics.ts +52 -75
  16. package/src/domains/analytics/utils/index.ts +5 -8
  17. package/src/domains/charts/charts.css +455 -0
  18. package/src/domains/charts/components/ActivityHeatmap.test.tsx +48 -0
  19. package/src/domains/charts/components/ActivityHeatmap.tsx +58 -0
  20. package/src/domains/charts/components/BarChart.test.tsx +91 -0
  21. package/src/domains/charts/components/BarChart.tsx +143 -0
  22. package/src/domains/charts/components/ChartCard.tsx +39 -0
  23. package/src/domains/charts/components/ChartPrimitives.test.tsx +90 -0
  24. package/src/domains/charts/components/ChartTip.tsx +18 -0
  25. package/src/domains/charts/components/Donut.test.tsx +51 -0
  26. package/src/domains/charts/components/Donut.tsx +97 -0
  27. package/src/domains/charts/components/HBars.tsx +31 -0
  28. package/src/domains/charts/components/Legend.tsx +21 -0
  29. package/src/domains/charts/components/LineChart.test.tsx +81 -0
  30. package/src/domains/charts/components/LineChart.tsx +244 -0
  31. package/src/domains/charts/components/Sparkline.tsx +35 -0
  32. package/src/domains/charts/components/index.ts +16 -0
  33. package/src/domains/charts/index.ts +16 -2
  34. package/src/domains/charts/ssr.test.tsx +35 -0
  35. package/src/domains/charts/types/index.ts +8 -0
  36. package/src/domains/charts/utils.ts +15 -0
  37. package/src/index.ts +6 -23
  38. package/src/styles/chrome.css +10 -490
  39. package/src/styles/dashboard.contract.test.ts +20 -5
  40. package/src/styles/dashboard.css +1 -0
  41. package/src/domains/analytics/components/AnalyticsCard.tsx +0 -87
  42. package/src/domains/analytics/components/AnalyticsChart.tsx +0 -387
  43. package/src/domains/analytics/components/MetricCard.tsx +0 -42
  44. package/src/domains/analytics/services/AnalyticsEngineService.ts +0 -300
  45. package/src/domains/charts/components.test.tsx +0 -141
  46. package/src/domains/charts/components.tsx +0 -683
@@ -0,0 +1,81 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { fireEvent, render } from "@testing-library/react";
3
+ import { LineChart } from "./LineChart";
4
+
5
+ const labels = ["1", "2", "3", "4"];
6
+
7
+ describe("LineChart", () => {
8
+ it("renders nothing without points", () => {
9
+ const { container } = render(<LineChart labels={[]} series={[]} />);
10
+ expect(container.firstChild).toBeNull();
11
+ });
12
+
13
+ it("renders a flat area by default", () => {
14
+ const { container } = render(
15
+ <LineChart labels={labels} series={[{ label: "A", values: [1, 2, 3, 4] }]} />,
16
+ );
17
+ const paths = container.querySelectorAll("path");
18
+ expect(paths).toHaveLength(2);
19
+ expect(paths[0]!.getAttribute("opacity")).toBe("0.07");
20
+ expect(container.querySelector("linearGradient")).toBeNull();
21
+ });
22
+
23
+ it("paints the area with a per-series gradient when requested", () => {
24
+ const { container } = render(
25
+ <LineChart
26
+ labels={labels}
27
+ series={[{ label: "A", values: [1, 2, 3, 4], areaFill: "gradient" }]}
28
+ />,
29
+ );
30
+ const gradient = container.querySelector("linearGradient");
31
+ expect(gradient).not.toBeNull();
32
+ expect(gradient!.querySelectorAll("stop")).toHaveLength(2);
33
+ const areaPath = [...container.querySelectorAll("path")].find((p) =>
34
+ p.getAttribute("fill")?.startsWith("url(#"),
35
+ );
36
+ expect(areaPath).toBeDefined();
37
+ expect(areaPath!.getAttribute("opacity")).toBeNull();
38
+ });
39
+
40
+ it("drops the area for dashed series", () => {
41
+ const { container } = render(
42
+ <LineChart labels={labels} series={[{ label: "A", values: [1, 2, 3, 4], dashed: true }]} />,
43
+ );
44
+ expect(container.querySelectorAll("path")).toHaveLength(1);
45
+ expect(container.querySelector("linearGradient")).toBeNull();
46
+ });
47
+
48
+ it("renders the band and a crosshair with tooltip on hover", () => {
49
+ const { container } = render(
50
+ <LineChart
51
+ labels={labels}
52
+ band={{ from: 1, to: 2 }}
53
+ series={[{ label: "A", values: [1, 2, 3, 4] }]}
54
+ />,
55
+ );
56
+ expect(container.querySelector(".udb-linechart__band")).not.toBeNull();
57
+
58
+ const svg = container.querySelector("svg")!;
59
+ fireEvent.mouseMove(svg, { clientX: 700, clientY: 50 });
60
+ expect(container.querySelector(".udb-linechart__crosshair")).not.toBeNull();
61
+ const tip = container.querySelector(".udb-linechart__tip");
62
+ expect(tip).not.toBeNull();
63
+ expect(tip!.textContent).toContain("A");
64
+ });
65
+
66
+ it("renders the built-in legend from the series", () => {
67
+ const { container } = render(
68
+ <LineChart
69
+ labels={labels}
70
+ series={[
71
+ { label: "A", values: [1, 2, 3, 4] },
72
+ { label: "B", values: [4, 3, 2, 1], axis: "right" },
73
+ ]}
74
+ />,
75
+ );
76
+ const items = container.querySelectorAll(".udb-chartlegend__item");
77
+ expect(items).toHaveLength(2);
78
+ expect(items[0]!.textContent).toContain("A");
79
+ expect(items[1]!.textContent).toContain("B");
80
+ });
81
+ });
@@ -0,0 +1,244 @@
1
+ import { useId, useMemo, useState } from 'react';
2
+ import { gridTicks, niceMax, seriesColor } from '../utils';
3
+ import { Legend } from './Legend';
4
+
5
+ export interface LineSeries {
6
+ key?: string;
7
+ label: string;
8
+ values?: readonly number[];
9
+ data?: readonly number[];
10
+ tone?: string;
11
+ color?: string;
12
+ kind?: 'line' | 'bars';
13
+ axis?: 'left' | 'right';
14
+ dashed?: boolean;
15
+ area?: boolean;
16
+ areaFill?: 'flat' | 'gradient';
17
+ }
18
+
19
+ export interface LineChartPoint {
20
+ label: string;
21
+ }
22
+
23
+ export interface LineChartProps {
24
+ points?: readonly LineChartPoint[];
25
+ labels?: readonly string[];
26
+ series: LineSeries[];
27
+ band?: { from: number; to: number };
28
+ height?: number;
29
+ formatLeft?: (v: number) => string;
30
+ formatRight?: (v: number) => string;
31
+ formatValue?: (v: number) => string;
32
+ yLabelLeft?: string;
33
+ yLabelRight?: string;
34
+ }
35
+
36
+ export function LineChart({
37
+ points,
38
+ labels,
39
+ series,
40
+ band,
41
+ height = 220,
42
+ formatLeft,
43
+ formatRight,
44
+ formatValue,
45
+ yLabelLeft,
46
+ yLabelRight,
47
+ }: LineChartProps) {
48
+ const [hover, setHover] = useState<number | null>(null);
49
+ const uid = useId();
50
+ const pts = points ?? (labels ?? []).map((label) => ({ label }));
51
+ const fmtLeft = formatLeft ?? formatValue ?? ((v: number) => String(Math.round(v)));
52
+ const fmtRight = formatRight ?? formatValue ?? ((v: number) => String(Math.round(v)));
53
+ const vals = (s: LineSeries) => s.values ?? s.data ?? [];
54
+ const w = 720;
55
+ const padLeft = 52;
56
+ const padRight = series.some((s) => s.axis === 'right') ? 46 : 14;
57
+ const padTop = 12;
58
+ const padBottom = 24;
59
+ const innerW = w - padLeft - padRight;
60
+ const innerH = height - padTop - padBottom;
61
+ const n = pts.length;
62
+
63
+ const toneOf = (s: LineSeries, i: number) => s.tone ?? s.color ?? seriesColor(i);
64
+
65
+ const leftMax = useMemo(
66
+ () => niceMax(Math.max(1, ...series.filter((s) => s.axis !== 'right').flatMap((s) => vals(s)), ...(band ? [band.from, band.to] : []))),
67
+ [series, band],
68
+ );
69
+ const rightMax = useMemo(
70
+ () => niceMax(Math.max(1, ...series.filter((s) => s.axis === 'right').flatMap((s) => vals(s)))),
71
+ [series],
72
+ );
73
+ const leftTicks = useMemo(() => gridTicks(Math.max(...series.filter((s) => s.axis !== 'right').flatMap((s) => vals(s)), ...(band ? [band.from, band.to] : []), 1)), [series, band]);
74
+
75
+ const xAt = (i: number) => padLeft + (n <= 1 ? innerW / 2 : (i / (n - 1)) * innerW);
76
+ const yLeft = (v: number) => padTop + innerH - (v / leftMax) * innerH;
77
+ const yRight = (v: number) => padTop + innerH - (v / rightMax) * innerH;
78
+ const labelEvery = Math.max(1, Math.ceil(n / 8));
79
+
80
+ if (n === 0) return null;
81
+
82
+ return (
83
+ <div className="udb-linechart">
84
+ <svg
85
+ viewBox={`0 0 ${w} ${height}`}
86
+ className="udb-linechart__svg"
87
+ style={{ height }}
88
+ onMouseLeave={() => setHover(null)}
89
+ onMouseMove={(e) => {
90
+ const rect = e.currentTarget.getBoundingClientRect();
91
+ const x = ((e.clientX - rect.left) / rect.width) * w;
92
+ const idx = Math.round(((x - padLeft) / innerW) * (n - 1));
93
+ setHover(Math.max(0, Math.min(n - 1, idx)));
94
+ }}
95
+ >
96
+ {leftTicks.map((v, i) => (
97
+ <g key={i}>
98
+ <line x1={padLeft} x2={w - padRight} y1={yLeft(v)} y2={yLeft(v)} className="udb-linechart__grid" />
99
+ <text x={padLeft - 6} y={yLeft(v) + 3} textAnchor="end" className="udb-linechart__axis">
100
+ {fmtLeft(v)}
101
+ </text>
102
+ </g>
103
+ ))}
104
+ {band && (
105
+ <rect
106
+ x={padLeft}
107
+ y={yLeft(band.to)}
108
+ width={innerW}
109
+ height={Math.max(0, yLeft(band.from) - yLeft(band.to))}
110
+ rx={2}
111
+ className="udb-linechart__band"
112
+ />
113
+ )}
114
+ {series.some((s) => s.axis === 'right') && (
115
+ <g>
116
+ {leftTicks.map((v, i) => (
117
+ <text key={i} x={w - padRight + 6} y={yLeft(v) + 3} textAnchor="start" className="udb-linechart__axis">
118
+ {fmtRight((v / leftMax) * rightMax)}
119
+ </text>
120
+ ))}
121
+ </g>
122
+ )}
123
+ {pts.map((p, i) =>
124
+ i % labelEvery === 0 ? (
125
+ <text key={i} x={xAt(i)} y={height - 8} textAnchor="middle" className="udb-linechart__axis">
126
+ {p.label}
127
+ </text>
128
+ ) : null,
129
+ )}
130
+ {series.map((s, si) => {
131
+ const yFn = s.axis === 'right' ? yRight : yLeft;
132
+ if (s.kind === 'bars') {
133
+ const barW = Math.max(3, (innerW / Math.max(1, n - 1)) * 0.5);
134
+ return (
135
+ <g key={s.key ?? s.label}>
136
+ {vals(s).slice(0, n).map((v, i) => (
137
+ <rect
138
+ key={i}
139
+ x={xAt(i) - barW / 2}
140
+ y={yFn(v)}
141
+ width={barW}
142
+ height={Math.max(0, padTop + innerH - yFn(v))}
143
+ rx={1.5}
144
+ fill={toneOf(s, si)}
145
+ opacity={hover === null || hover === i ? 0.85 : 0.35}
146
+ />
147
+ ))}
148
+ </g>
149
+ );
150
+ }
151
+ const path = vals(s)
152
+ .slice(0, n)
153
+ .map((v, i) => `${i === 0 ? 'M' : 'L'}${xAt(i).toFixed(1)},${yFn(v).toFixed(1)}`)
154
+ .join(' ');
155
+ const areaPath = `${path} L${xAt(n - 1).toFixed(1)},${padTop + innerH} L${xAt(0).toFixed(1)},${padTop + innerH} Z`;
156
+ const gradId = `lc${uid}-${si}`;
157
+ const showArea = s.area !== false && !s.dashed;
158
+ return (
159
+ <g key={s.key ?? s.label}>
160
+ {showArea &&
161
+ (s.areaFill === 'gradient' ? (
162
+ <defs>
163
+ <linearGradient id={gradId} x1="0" y1="0" x2="0" y2="1">
164
+ <stop offset="0%" stopColor={toneOf(s, si)} stopOpacity="0.28" />
165
+ <stop offset="100%" stopColor={toneOf(s, si)} stopOpacity="0" />
166
+ </linearGradient>
167
+ </defs>
168
+ ) : null)}
169
+ {showArea &&
170
+ (s.areaFill === 'gradient' ? (
171
+ <path d={areaPath} fill={`url(#${gradId})`} />
172
+ ) : (
173
+ <path d={areaPath} fill={toneOf(s, si)} opacity={0.07} />
174
+ ))}
175
+ <path
176
+ d={path}
177
+ fill="none"
178
+ stroke={toneOf(s, si)}
179
+ strokeWidth={2}
180
+ strokeLinejoin="round"
181
+ strokeLinecap="round"
182
+ strokeDasharray={s.dashed ? '4 4' : undefined}
183
+ />
184
+ {vals(s).slice(0, n).map((v, i) => (
185
+ <circle
186
+ key={i}
187
+ cx={xAt(i)}
188
+ cy={yFn(v)}
189
+ r={hover === i ? 3.4 : 0}
190
+ fill="var(--color-card)"
191
+ stroke={toneOf(s, si)}
192
+ strokeWidth={2}
193
+ />
194
+ ))}
195
+ </g>
196
+ );
197
+ })}
198
+ {hover !== null && (
199
+ <line
200
+ x1={xAt(hover)}
201
+ x2={xAt(hover)}
202
+ y1={padTop}
203
+ y2={padTop + innerH}
204
+ className="udb-linechart__crosshair"
205
+ />
206
+ )}
207
+ {yLabelLeft && (
208
+ <text x={4} y={10} className="udb-linechart__axis">
209
+ {yLabelLeft}
210
+ </text>
211
+ )}
212
+ {yLabelRight && (
213
+ <text x={w - 4} y={10} textAnchor="end" className="udb-linechart__axis">
214
+ {yLabelRight}
215
+ </text>
216
+ )}
217
+ </svg>
218
+
219
+ {hover !== null && (
220
+ <div
221
+ className="udb-linechart__tip"
222
+ style={{
223
+ left: `${(xAt(hover) / w) * 100}%`,
224
+ transform: hover > n / 2 ? 'translateX(calc(-100% - 10px))' : 'translateX(10px)',
225
+ }}
226
+ >
227
+ <div className="udb-linechart__tiptitle">{pts[hover]!.label}</div>
228
+ {series.map((s, si) => (
229
+ <div key={s.key ?? s.label} className="udb-linechart__tiprow">
230
+ <span>
231
+ <span className="udb-linechart__swatch" style={{ background: toneOf(s, si) }} />
232
+ {s.label}
233
+ </span>
234
+ <b>{(s.axis === 'right' ? fmtRight : fmtLeft)(vals(s)[hover] ?? 0)}</b>
235
+ </div>
236
+ ))}
237
+ </div>
238
+ )}
239
+ <div className="udb-linechart__legendhost">
240
+ <Legend items={series.map((s, si) => ({ label: s.label, color: toneOf(s, si) }))} />
241
+ </div>
242
+ </div>
243
+ );
244
+ }
@@ -0,0 +1,35 @@
1
+ import { useId } from 'react';
2
+
3
+ export function Sparkline({
4
+ data,
5
+ height = 34,
6
+ width = 110,
7
+ color = 'currentColor',
8
+ }: {
9
+ data: readonly number[];
10
+ height?: number;
11
+ width?: number;
12
+ color?: string;
13
+ }) {
14
+ const id = useId();
15
+ if (data.length < 2) return null;
16
+ const min = Math.min(...data);
17
+ const max = Math.max(...data);
18
+ const span = max - min || 1;
19
+ const pts = data.map((v, i) => [(i / (data.length - 1)) * width, height - 3 - ((v - min) / span) * (height - 8)]);
20
+ const line = pts.map((p, i) => `${i === 0 ? 'M' : 'L'}${p[0]!.toFixed(1)},${p[1]!.toFixed(1)}`).join(' ');
21
+ const area = `${line} L${width},${height} L0,${height} Z`;
22
+ return (
23
+ <svg width={width} height={height} viewBox={`0 0 ${width} ${height}`} aria-hidden>
24
+ <defs>
25
+ <linearGradient id={`sp${id}`} x1="0" y1="0" x2="0" y2="1">
26
+ <stop offset="0%" stopColor={color} stopOpacity="0.28" />
27
+ <stop offset="100%" stopColor={color} stopOpacity="0" />
28
+ </linearGradient>
29
+ </defs>
30
+ <path d={area} fill={`url(#sp${id})`} />
31
+ <path d={line} fill="none" stroke={color} strokeWidth="1.6" strokeLinejoin="round" strokeLinecap="round" />
32
+ <circle cx={pts.at(-1)![0]} cy={pts.at(-1)![1]} r="2.4" fill={color} />
33
+ </svg>
34
+ );
35
+ }
@@ -0,0 +1,16 @@
1
+ export { ChartTip } from './ChartTip';
2
+ export { ChartCard } from './ChartCard';
3
+ export type { ChartCardProps } from './ChartCard';
4
+ export { Legend } from './Legend';
5
+ export type { LegendItem } from './Legend';
6
+ export { Sparkline } from './Sparkline';
7
+ export { HBars } from './HBars';
8
+ export type { HBarRow } from './HBars';
9
+ export { BarChart } from './BarChart';
10
+ export type { BarSeries, BarChartGoalLine, BarChartProps } from './BarChart';
11
+ export { Donut } from './Donut';
12
+ export type { DonutSegment, DonutProps } from './Donut';
13
+ export { LineChart } from './LineChart';
14
+ export type { LineSeries, LineChartPoint, LineChartProps } from './LineChart';
15
+ export { ActivityHeatmap } from './ActivityHeatmap';
16
+ export type { HeatmapCell, ActivityHeatmapProps } from './ActivityHeatmap';
@@ -1,14 +1,28 @@
1
- export { PALETTE, useTip, niceMax, gridTicks } from './utils';
1
+ export { PALETTE, SERIES_COLORS, seriesColor, useTip, niceMax, gridTicks } from './utils';
2
2
  export type { TipRow, TipState } from './utils';
3
- export { ChartTip, ChartCard, Legend, Sparkline, HBars, BarChart, Donut, LineChart, ActivityHeatmap } from './components';
3
+ export {
4
+ ChartTip,
5
+ ChartCard,
6
+ Legend,
7
+ Sparkline,
8
+ HBars,
9
+ BarChart,
10
+ Donut,
11
+ LineChart,
12
+ ActivityHeatmap,
13
+ } from './components';
4
14
  export type {
5
15
  ChartCardProps,
6
16
  LegendItem,
7
17
  HBarRow,
8
18
  BarSeries,
19
+ BarChartGoalLine,
20
+ BarChartProps,
9
21
  DonutSegment,
22
+ DonutProps,
10
23
  LineSeries,
11
24
  LineChartPoint,
25
+ LineChartProps,
12
26
  HeatmapCell,
13
27
  ActivityHeatmapProps,
14
28
  } from './components';
@@ -0,0 +1,35 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { renderToString } from "react-dom/server";
3
+ import { BarChart } from "./components/BarChart";
4
+ import { Donut } from "./components/Donut";
5
+ import { LineChart } from "./components/LineChart";
6
+ import { ActivityHeatmap } from "./components/ActivityHeatmap";
7
+ import { ChartCard } from "./components/ChartCard";
8
+ import { HBars } from "./components/HBars";
9
+ import { Sparkline } from "./components/Sparkline";
10
+
11
+ describe("charts server rendering", () => {
12
+ it("renders every chart primitive to static markup", () => {
13
+ const html = [
14
+ renderToString(
15
+ <ChartCard title="T" tip={null}>
16
+ <span>body</span>
17
+ </ChartCard>,
18
+ ),
19
+ renderToString(<BarChart labels={["a", "b"]} series={[{ label: "A", values: [1, 2] }]} />),
20
+ renderToString(<BarChart labels={["a"]} stacking="stacked" series={[{ label: "A", values: [2] }, { label: "B", values: [2] }]} />),
21
+ renderToString(<Donut segments={[{ label: "A", value: 1 }]} centerValue="1" />),
22
+ renderToString(<LineChart labels={["a", "b"]} series={[{ label: "A", values: [1, 2], areaFill: "gradient" }]} />),
23
+ renderToString(<ActivityHeatmap cells={[{ day: "2026-01-01", value: 3 }]} />),
24
+ renderToString(<Sparkline data={[1, 2]} />),
25
+ renderToString(<HBars rows={[{ label: "A", value: 1 }]} />),
26
+ ].join("");
27
+ expect(html).toContain("udb-chartcard");
28
+ expect(html).toContain("udb-barchart__bars--stacked");
29
+ expect(html).toContain("udb-donut");
30
+ expect(html).toContain("udb-linechart");
31
+ expect(html).toContain("linearGradient");
32
+ expect(html).toContain("udb-heatmap__cell--l");
33
+ expect(html).toContain("udb-hbars");
34
+ });
35
+ });
@@ -0,0 +1,8 @@
1
+ export type { TipRow, TipState } from '../utils';
2
+ export type { ChartCardProps } from '../components/ChartCard';
3
+ export type { LegendItem } from '../components/Legend';
4
+ export type { HBarRow } from '../components/HBars';
5
+ export type { BarSeries, BarChartGoalLine, BarChartProps } from '../components/BarChart';
6
+ export type { DonutSegment, DonutProps } from '../components/Donut';
7
+ export type { LineSeries, LineChartPoint, LineChartProps } from '../components/LineChart';
8
+ export type { HeatmapCell, ActivityHeatmapProps } from '../components/ActivityHeatmap';
@@ -2,6 +2,21 @@ import { useRef, useState } from 'react';
2
2
 
3
3
  export const PALETTE = ['#357344', '#b06e22', '#3e5f80', '#7a6ba8', '#8a5a3b', '#5e7d5a', '#a8b5a0', '#c9862f'];
4
4
 
5
+ export const SERIES_COLORS = [
6
+ 'var(--udb-chart-1, #357344)',
7
+ 'var(--udb-chart-2, #b06e22)',
8
+ 'var(--udb-chart-3, #3e5f80)',
9
+ 'var(--udb-chart-4, #7a6ba8)',
10
+ 'var(--udb-chart-5, #8a5a3b)',
11
+ 'var(--udb-chart-6, #5e7d5a)',
12
+ 'var(--udb-chart-7, #a8b5a0)',
13
+ 'var(--udb-chart-8, #c9862f)',
14
+ ] as const;
15
+
16
+ export function seriesColor(index: number): string {
17
+ return SERIES_COLORS[index % SERIES_COLORS.length]!;
18
+ }
19
+
5
20
  export interface TipRow {
6
21
  label: string;
7
22
  value: string;
package/src/index.ts CHANGED
@@ -6,42 +6,25 @@ export * from './domains/organization';
6
6
  export * from './domains/tour';
7
7
  export {
8
8
  useAnalytics,
9
- MetricCard,
10
- AnalyticsChart,
11
- AnalyticsCard,
12
9
  AnalyticsLayout,
13
10
  formatNumber,
14
11
  formatPercentage,
15
12
  formatCurrency,
16
13
  calculateGrowth,
17
14
  getTrend,
18
- createKPI,
19
- createMetric,
20
- formatMetricValue,
15
+ toKpiDelta,
16
+ toCsv,
17
+ downloadCsv,
18
+ exportCsv,
21
19
  calculateConversionRate,
22
20
  calculateDropOffRate,
23
- createDateRangePreset,
24
- getDateRangePresets,
25
21
  aggregateByPeriod,
26
22
  calculateMovingAverage,
27
23
  detectOutliers,
28
24
  roundTo,
29
- generateColor,
30
- generateChartColors,
31
- type Metric,
25
+ type KpiDatum,
26
+ type TimeSeriesDatum,
32
27
  type TimeSeriesData,
33
- type ChartData,
34
- type FunnelStep,
35
- type FunnelData,
36
- type CohortAnalysis,
37
- type UserSegment,
38
- type KPIData,
39
- type KPIs,
40
- type ChartType,
41
- type ChartConfig,
42
- type MetricCardProps,
43
- type AnalyticsCardProps,
44
- type AnalyticsLayoutProps,
45
28
  type DateRangePreset,
46
29
  type DateRangeValue,
47
30
  type AnalyticsExportOptions,