@meetreeve/ui 0.21.0 → 0.22.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.
- package/README.md +59 -0
- package/THIRD_PARTY_NOTICES.md +68 -0
- package/dist/charts/index.d.mts +331 -0
- package/dist/charts/index.d.ts +331 -0
- package/dist/charts/index.js +913 -0
- package/dist/charts/index.mjs +860 -0
- package/dist/tokens.css +39 -0
- package/package.json +18 -4
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, ReactElement } from 'react';
|
|
3
|
+
import { Tooltip, LabelProps } from 'recharts';
|
|
4
|
+
|
|
5
|
+
/** Number of categorical series tokens (`--chart-1` … `--chart-8`). */
|
|
6
|
+
declare const CHART_SERIES_COUNT = 8;
|
|
7
|
+
/** `var(--chart-n)` for the i-th series (0-based, wraps after CHART_SERIES_COUNT). */
|
|
8
|
+
declare function chartColor(index: number): string;
|
|
9
|
+
/** The categorical series tokens in order. */
|
|
10
|
+
declare const chartPalette: readonly string[];
|
|
11
|
+
/** Semantic tokens. Polarity colours drive KpiCard deltas and up/down series. */
|
|
12
|
+
declare const chartTokens: {
|
|
13
|
+
readonly positive: "var(--chart-positive)";
|
|
14
|
+
readonly negative: "var(--chart-negative)";
|
|
15
|
+
readonly grid: "var(--chart-grid, var(--border))";
|
|
16
|
+
readonly muted: "var(--chart-muted, var(--muted-foreground))";
|
|
17
|
+
readonly foreground: "var(--foreground)";
|
|
18
|
+
readonly card: "var(--card)";
|
|
19
|
+
};
|
|
20
|
+
/** A token at reduced opacity — `color-mix` keeps it a token, not a baked rgba. */
|
|
21
|
+
declare function withAlpha(color: string, percent: number): string;
|
|
22
|
+
/** Shared Recharts styling: axis ticks, grid, tooltip surface. */
|
|
23
|
+
declare const chartConfig: {
|
|
24
|
+
readonly tooltip: {
|
|
25
|
+
readonly background: "var(--card)";
|
|
26
|
+
readonly border: string;
|
|
27
|
+
readonly text: "var(--foreground)";
|
|
28
|
+
readonly label: "var(--chart-muted, var(--muted-foreground))";
|
|
29
|
+
};
|
|
30
|
+
readonly grid: {
|
|
31
|
+
readonly stroke: "var(--chart-grid, var(--border))";
|
|
32
|
+
};
|
|
33
|
+
readonly axis: {
|
|
34
|
+
readonly stroke: "var(--chart-grid, var(--border))";
|
|
35
|
+
readonly tick: "var(--chart-muted, var(--muted-foreground))";
|
|
36
|
+
readonly fontSize: 11;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type ChartConfig = Record<string, {
|
|
41
|
+
label?: ReactNode;
|
|
42
|
+
color?: string;
|
|
43
|
+
}>;
|
|
44
|
+
declare function useChart(): {
|
|
45
|
+
config: ChartConfig;
|
|
46
|
+
};
|
|
47
|
+
/** True when the OS asks for reduced motion; charts then skip their entry animation. */
|
|
48
|
+
declare function usePrefersReducedMotion(): boolean;
|
|
49
|
+
interface ChartContainerProps {
|
|
50
|
+
/** Optional per-key labels/colours; each colour is exposed as `--color-<key>` inside the chart. */
|
|
51
|
+
config?: ChartConfig;
|
|
52
|
+
height?: number;
|
|
53
|
+
/** Render a pulsing placeholder instead of the chart. */
|
|
54
|
+
loading?: boolean;
|
|
55
|
+
className?: string;
|
|
56
|
+
children: ReactElement;
|
|
57
|
+
}
|
|
58
|
+
declare function ChartContainer({ config, height, loading, className, children }: ChartContainerProps): react.JSX.Element;
|
|
59
|
+
/** Loading placeholder: a row of muted bars, pulsing unless reduced motion is on. */
|
|
60
|
+
declare function ChartSkeleton({ height }: {
|
|
61
|
+
height?: number;
|
|
62
|
+
}): react.JSX.Element;
|
|
63
|
+
interface TooltipPayloadItem {
|
|
64
|
+
name: string;
|
|
65
|
+
value: number;
|
|
66
|
+
color: string;
|
|
67
|
+
}
|
|
68
|
+
interface ChartTooltipContentProps {
|
|
69
|
+
active?: boolean;
|
|
70
|
+
payload?: TooltipPayloadItem[];
|
|
71
|
+
label?: ReactNode;
|
|
72
|
+
formatter?: (value: number, name: string) => string;
|
|
73
|
+
}
|
|
74
|
+
declare function ChartTooltipContent({ active, payload, label, formatter }: ChartTooltipContentProps): react.JSX.Element | null;
|
|
75
|
+
/** Recharts' Tooltip, re-exported so consumers composing raw charts need one import. */
|
|
76
|
+
declare const ChartTooltip: typeof Tooltip;
|
|
77
|
+
|
|
78
|
+
type AreaVariant = "gradient" | "solid" | "dotted" | "hatched" | "lines";
|
|
79
|
+
type Curve = "monotone" | "step" | "bump" | "linear";
|
|
80
|
+
|
|
81
|
+
interface AreaChartSeries {
|
|
82
|
+
dataKey: string;
|
|
83
|
+
name: string;
|
|
84
|
+
/** Any CSS colour; defaults to the series' `--chart-n` token. The fill follows it. */
|
|
85
|
+
color?: string;
|
|
86
|
+
/** Fill style for this series; overrides the chart-level `variant`. */
|
|
87
|
+
variant?: AreaVariant;
|
|
88
|
+
stackId?: string;
|
|
89
|
+
}
|
|
90
|
+
interface AreaChartProps {
|
|
91
|
+
data: Record<string, unknown>[];
|
|
92
|
+
xKey: string;
|
|
93
|
+
series: AreaChartSeries[];
|
|
94
|
+
height?: number;
|
|
95
|
+
showGrid?: boolean;
|
|
96
|
+
showLegend?: boolean;
|
|
97
|
+
/** Hide the value axis (e.g. a compact card). Default shown. */
|
|
98
|
+
showYAxis?: boolean;
|
|
99
|
+
tooltipFormatter?: (value: number, name: string) => string;
|
|
100
|
+
/** Formats the value-axis ticks. */
|
|
101
|
+
yTickFormatter?: (value: number) => string;
|
|
102
|
+
/** Default fill style (EvilCharts variants). Default `gradient`. */
|
|
103
|
+
variant?: AreaVariant;
|
|
104
|
+
curve?: Curve;
|
|
105
|
+
/** `stacked` stacks every series; `expanded` stacks to 100%. Per-series `stackId` still works. */
|
|
106
|
+
stack?: "none" | "stacked" | "expanded";
|
|
107
|
+
loading?: boolean;
|
|
108
|
+
}
|
|
109
|
+
declare function AreaChart({ data, xKey, series, height, showGrid, showLegend, showYAxis, tooltipFormatter, yTickFormatter, variant, curve, stack, loading, }: AreaChartProps): react.JSX.Element;
|
|
110
|
+
|
|
111
|
+
interface LineChartSeries {
|
|
112
|
+
dataKey: string;
|
|
113
|
+
name: string;
|
|
114
|
+
color?: string;
|
|
115
|
+
/** Soft outer glow on the stroke (EvilCharts `glowing`). */
|
|
116
|
+
glow?: boolean;
|
|
117
|
+
/** Dashed stroke, e.g. a forecast or a comparison period. */
|
|
118
|
+
dashed?: boolean;
|
|
119
|
+
/** Show a dot on every point. Default off. */
|
|
120
|
+
dots?: boolean;
|
|
121
|
+
}
|
|
122
|
+
interface LineChartProps {
|
|
123
|
+
data: Record<string, unknown>[];
|
|
124
|
+
xKey: string;
|
|
125
|
+
series: LineChartSeries[];
|
|
126
|
+
height?: number;
|
|
127
|
+
showGrid?: boolean;
|
|
128
|
+
showLegend?: boolean;
|
|
129
|
+
showYAxis?: boolean;
|
|
130
|
+
tooltipFormatter?: (value: number, name: string) => string;
|
|
131
|
+
yTickFormatter?: (value: number) => string;
|
|
132
|
+
curve?: Curve;
|
|
133
|
+
loading?: boolean;
|
|
134
|
+
}
|
|
135
|
+
declare function LineChart({ data, xKey, series, height, showGrid, showLegend, showYAxis, tooltipFormatter, yTickFormatter, curve, loading, }: LineChartProps): react.JSX.Element;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Recharts applies `barCategoryGap` on BOTH sides of a band, so neighbouring
|
|
139
|
+
* bars sit 2 × gap apart. band/12 per side → gap = band/6, bar = 5·band/6,
|
|
140
|
+
* i.e. bar:gap = 5:1 (the gap is ~16.7% of the band in total).
|
|
141
|
+
*/
|
|
142
|
+
declare const BAR_CATEGORY_GAP = "8.33%";
|
|
143
|
+
/** Preset props for a Recharts <BarChart> that can't use the wrapper. */
|
|
144
|
+
declare const BAR_STANDARD: {
|
|
145
|
+
readonly barCategoryGap: "8.33%";
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* LabelList `content` for bar value labels: the formatted value centred above
|
|
149
|
+
* the bar (or, with `orientation: 'horizontal'`, just past the end of a
|
|
150
|
+
* horizontal bar). A label wider than its slot (bar width + `slack`, where a
|
|
151
|
+
* number is a fraction of the bar width and a function returns pixels) is
|
|
152
|
+
* dropped rather than colliding with its neighbours; dense charts fall back
|
|
153
|
+
* to the tooltip.
|
|
154
|
+
*/
|
|
155
|
+
declare function barValueLabel(format?: (value: number) => string, { slack, orientation, }?: {
|
|
156
|
+
slack?: number | ((barWidth: number) => number);
|
|
157
|
+
orientation?: "vertical" | "horizontal";
|
|
158
|
+
}): ({ value, offset, viewBox }: Pick<LabelProps, "value" | "offset" | "viewBox">) => react.JSX.Element | null;
|
|
159
|
+
interface BarChartSeries {
|
|
160
|
+
dataKey: string;
|
|
161
|
+
name: string;
|
|
162
|
+
color?: string;
|
|
163
|
+
radius?: number;
|
|
164
|
+
}
|
|
165
|
+
interface BarChartProps {
|
|
166
|
+
data: Record<string, unknown>[];
|
|
167
|
+
xKey: string;
|
|
168
|
+
series: BarChartSeries[];
|
|
169
|
+
height?: number;
|
|
170
|
+
showGrid?: boolean;
|
|
171
|
+
showLegend?: boolean;
|
|
172
|
+
tooltipFormatter?: (value: number, name: string) => string;
|
|
173
|
+
/** Formats the value printed above each bar. Defaults to tooltipFormatter, then toLocaleString. */
|
|
174
|
+
labelFormatter?: (value: number, name: string) => string;
|
|
175
|
+
/** Value labels above the bars (the standard). Default true. */
|
|
176
|
+
showValueLabels?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Opt-out of the no-y-axis standard. Only for a chart with a real reason
|
|
179
|
+
* (e.g. it is read against a scale rather than per-bar values).
|
|
180
|
+
*/
|
|
181
|
+
showYAxis?: boolean;
|
|
182
|
+
loading?: boolean;
|
|
183
|
+
}
|
|
184
|
+
declare function BarChart({ data, xKey, series, height, showGrid, showLegend, tooltipFormatter, labelFormatter, showValueLabels, showYAxis, loading, }: BarChartProps): react.JSX.Element;
|
|
185
|
+
|
|
186
|
+
interface DonutDataItem {
|
|
187
|
+
name: string;
|
|
188
|
+
value: number;
|
|
189
|
+
fill?: string;
|
|
190
|
+
}
|
|
191
|
+
interface DonutChartProps {
|
|
192
|
+
data: DonutDataItem[];
|
|
193
|
+
height?: number;
|
|
194
|
+
innerRadius?: number;
|
|
195
|
+
outerRadius?: number;
|
|
196
|
+
showLegend?: boolean;
|
|
197
|
+
tooltipFormatter?: (value: number, name: string) => string;
|
|
198
|
+
centerLabel?: string;
|
|
199
|
+
centerValue?: string;
|
|
200
|
+
loading?: boolean;
|
|
201
|
+
}
|
|
202
|
+
declare function DonutChart({ data, height, innerRadius, outerRadius, showLegend, tooltipFormatter, centerLabel, centerValue, loading, }: DonutChartProps): react.JSX.Element;
|
|
203
|
+
|
|
204
|
+
interface RadialChartItem {
|
|
205
|
+
name: string;
|
|
206
|
+
value: number;
|
|
207
|
+
fill?: string;
|
|
208
|
+
}
|
|
209
|
+
interface RadialChartProps {
|
|
210
|
+
/** One ring per item. */
|
|
211
|
+
data: RadialChartItem[];
|
|
212
|
+
/** The value a full ring represents (e.g. 100 for percentages). */
|
|
213
|
+
max?: number;
|
|
214
|
+
height?: number;
|
|
215
|
+
centerValue?: string;
|
|
216
|
+
centerLabel?: string;
|
|
217
|
+
loading?: boolean;
|
|
218
|
+
}
|
|
219
|
+
/** Progress rings (goal attainment, budget used), adapted from EvilCharts' radial chart. */
|
|
220
|
+
declare function RadialChart({ data, max, height, centerValue, centerLabel, loading }: RadialChartProps): react.JSX.Element;
|
|
221
|
+
|
|
222
|
+
interface SparklineProps {
|
|
223
|
+
/** Values in time order. Non-finite values are dropped. */
|
|
224
|
+
values: number[];
|
|
225
|
+
color?: string;
|
|
226
|
+
height?: number;
|
|
227
|
+
/** Fill under the line. Default true. */
|
|
228
|
+
filled?: boolean;
|
|
229
|
+
}
|
|
230
|
+
/** Axis-less trend line for a KPI tile. Never animates: it is decoration, not data entry. */
|
|
231
|
+
declare function Sparkline({ values, color, height, filled }: SparklineProps): react.JSX.Element | null;
|
|
232
|
+
|
|
233
|
+
/** Whether a rise is good news (revenue), bad news (cost, CPA), or neither. */
|
|
234
|
+
type Polarity = "up-is-good" | "up-is-bad" | "neutral";
|
|
235
|
+
type DeltaTone = "positive" | "negative" | "neutral";
|
|
236
|
+
/** Card state. `setup` replaces raw errors with a "connect X" prompt (DEV-16631). */
|
|
237
|
+
type ModuleState = "ok" | "empty" | "setup";
|
|
238
|
+
declare function deltaTone(delta: number | null | undefined, polarity?: Polarity): DeltaTone;
|
|
239
|
+
interface KpiCardProps {
|
|
240
|
+
label: ReactNode;
|
|
241
|
+
/** Already formatted by the caller ("$12,400", "3.2×"). */
|
|
242
|
+
value?: ReactNode;
|
|
243
|
+
/** Relative change as a fraction (0.12 = +12%). */
|
|
244
|
+
delta?: number | null;
|
|
245
|
+
/** e.g. "vs prior 30d". */
|
|
246
|
+
deltaLabel?: ReactNode;
|
|
247
|
+
deltaFormatter?: (delta: number) => string;
|
|
248
|
+
polarity?: Polarity;
|
|
249
|
+
/** Values in time order for the inline sparkline. */
|
|
250
|
+
trend?: number[];
|
|
251
|
+
/** Short definition behind a "?" tip. */
|
|
252
|
+
info?: ReactNode;
|
|
253
|
+
loading?: boolean;
|
|
254
|
+
state?: ModuleState;
|
|
255
|
+
/** Message for `empty` / `setup`. */
|
|
256
|
+
message?: ReactNode;
|
|
257
|
+
/** CTA slot, shown in the `setup` state (e.g. a "Connect Meta" link). */
|
|
258
|
+
action?: ReactNode;
|
|
259
|
+
className?: string;
|
|
260
|
+
}
|
|
261
|
+
declare function KpiCard({ label, value, delta, deltaLabel, deltaFormatter, polarity, trend, info, loading, state, message, action, className, }: KpiCardProps): react.JSX.Element;
|
|
262
|
+
|
|
263
|
+
type ChartRange = "7d" | "30d" | "90d" | "custom";
|
|
264
|
+
type ChartCardState = "ok" | "loading" | "empty" | "setup" | "error";
|
|
265
|
+
interface ChartCardRange {
|
|
266
|
+
value: ChartRange;
|
|
267
|
+
onChange: (range: ChartRange) => void;
|
|
268
|
+
/** Which toggles to show. Default 7d / 30d / 90d. */
|
|
269
|
+
options?: ChartRange[];
|
|
270
|
+
}
|
|
271
|
+
interface ChartCardProps {
|
|
272
|
+
title: ReactNode;
|
|
273
|
+
subtitle?: ReactNode;
|
|
274
|
+
info?: ReactNode;
|
|
275
|
+
/** Header slot on the right (a menu, a "View all" link). */
|
|
276
|
+
action?: ReactNode;
|
|
277
|
+
/** Controlled range toggle; the caller refetches on change. */
|
|
278
|
+
range?: ChartCardRange;
|
|
279
|
+
legend?: ReactNode;
|
|
280
|
+
state?: ChartCardState;
|
|
281
|
+
/** Message for empty / setup / error. */
|
|
282
|
+
message?: ReactNode;
|
|
283
|
+
/** CTA slot for the setup state. */
|
|
284
|
+
setupAction?: ReactNode;
|
|
285
|
+
/** Skeleton height while loading. */
|
|
286
|
+
height?: number;
|
|
287
|
+
className?: string;
|
|
288
|
+
children?: ReactNode;
|
|
289
|
+
}
|
|
290
|
+
declare function ChartCard({ title, subtitle, info, action, range, legend, state, message, setupAction, height, className, children, }: ChartCardProps): react.JSX.Element;
|
|
291
|
+
|
|
292
|
+
type DashboardItemSize = "sm" | "md" | "lg" | "wide" | "full";
|
|
293
|
+
/**
|
|
294
|
+
* Bento layout tiers, keyed on the GRID'S OWN width (a CSS container query),
|
|
295
|
+
* not the viewport: the docked /insights pane is 1044px inside a 1440px window
|
|
296
|
+
* (DEV-14525). One table drives both the emitted CSS and `dashboardSpan`, so
|
|
297
|
+
* the tests pin the same numbers the browser uses.
|
|
298
|
+
*/
|
|
299
|
+
declare const DASHBOARD_TIERS: readonly {
|
|
300
|
+
minWidth: number;
|
|
301
|
+
columns: number;
|
|
302
|
+
span: Record<DashboardItemSize, number>;
|
|
303
|
+
}[];
|
|
304
|
+
/** Columns an item of `size` spans, and how many fit per row, at a container `width`. */
|
|
305
|
+
declare function dashboardSpan(width: number, size: DashboardItemSize): {
|
|
306
|
+
columns: number;
|
|
307
|
+
span: number;
|
|
308
|
+
perRow: number;
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* The grid's stylesheet. Self-contained so it works whether or not the host's
|
|
312
|
+
* Tailwind scans this package. No quotes or `>`: React 18's server renderer
|
|
313
|
+
* HTML-escapes <style> text, which would kill those rules on first paint.
|
|
314
|
+
*/
|
|
315
|
+
declare const DASHBOARD_GRID_CSS: string;
|
|
316
|
+
interface DashboardGridProps {
|
|
317
|
+
className?: string;
|
|
318
|
+
children: ReactNode;
|
|
319
|
+
}
|
|
320
|
+
declare function DashboardGridRoot({ className, children }: DashboardGridProps): react.JSX.Element;
|
|
321
|
+
interface DashboardGridItemProps {
|
|
322
|
+
size?: DashboardItemSize;
|
|
323
|
+
className?: string;
|
|
324
|
+
children: ReactNode;
|
|
325
|
+
}
|
|
326
|
+
declare function DashboardGridItem({ size, className, children }: DashboardGridItemProps): react.JSX.Element;
|
|
327
|
+
declare const DashboardGrid: typeof DashboardGridRoot & {
|
|
328
|
+
Item: typeof DashboardGridItem;
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
export { AreaChart, type AreaChartProps, type AreaChartSeries, type AreaVariant, BAR_CATEGORY_GAP, BAR_STANDARD, BarChart, type BarChartProps, type BarChartSeries, CHART_SERIES_COUNT, ChartCard, type ChartCardProps, type ChartCardRange, type ChartCardState, type ChartConfig, ChartContainer, type ChartContainerProps, type ChartRange, ChartSkeleton, ChartTooltip, ChartTooltipContent, type ChartTooltipContentProps, type Curve, DASHBOARD_GRID_CSS, DASHBOARD_TIERS, DashboardGrid, type DashboardGridItemProps, type DashboardGridProps, type DashboardItemSize, type DeltaTone, DonutChart, type DonutChartProps, type DonutDataItem, KpiCard, type KpiCardProps, LineChart, type LineChartProps, type LineChartSeries, type ModuleState, type Polarity, RadialChart, type RadialChartItem, type RadialChartProps, Sparkline, type SparklineProps, barValueLabel, chartColor, chartConfig, chartPalette, chartTokens, dashboardSpan, deltaTone, useChart, usePrefersReducedMotion, withAlpha };
|