@alpic-ai/ui 0.0.0-staging.g5c24de5 → 0.0.0-staging.g5fc2bcf

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 (60) hide show
  1. package/dist/components/area-chart.d.mts +64 -0
  2. package/dist/components/area-chart.mjs +273 -0
  3. package/dist/components/bar-chart.d.mts +50 -0
  4. package/dist/components/bar-chart.mjs +260 -0
  5. package/dist/components/bar-list.d.mts +31 -0
  6. package/dist/components/bar-list.mjs +104 -0
  7. package/dist/components/chart-card.d.mts +25 -0
  8. package/dist/components/chart-card.mjs +48 -0
  9. package/dist/components/chart-container.d.mts +20 -0
  10. package/dist/components/chart-container.mjs +37 -0
  11. package/dist/components/chart-legend.d.mts +21 -0
  12. package/dist/components/chart-legend.mjs +35 -0
  13. package/dist/components/chart-tooltip.d.mts +33 -0
  14. package/dist/components/chart-tooltip.mjs +54 -0
  15. package/dist/components/donut-chart.d.mts +46 -0
  16. package/dist/components/donut-chart.mjs +187 -0
  17. package/dist/components/form.mjs +3 -1
  18. package/dist/components/heatmap-chart.d.mts +48 -0
  19. package/dist/components/heatmap-chart.mjs +229 -0
  20. package/dist/components/line-chart.d.mts +57 -0
  21. package/dist/components/line-chart.mjs +216 -0
  22. package/dist/components/stat.d.mts +32 -0
  23. package/dist/components/stat.mjs +117 -0
  24. package/dist/components/textarea.mjs +1 -1
  25. package/dist/components/wizard.d.mts +1 -19
  26. package/dist/components/wizard.mjs +1 -19
  27. package/dist/hooks/use-chart-theme.d.mts +18 -0
  28. package/dist/hooks/use-chart-theme.mjs +57 -0
  29. package/dist/lib/chart-palette.d.mts +4 -0
  30. package/dist/lib/chart-palette.mjs +95 -0
  31. package/dist/lib/chart.d.mts +14 -0
  32. package/dist/lib/chart.mjs +42 -0
  33. package/package.json +24 -23
  34. package/src/components/area-chart.tsx +344 -0
  35. package/src/components/bar-chart.tsx +314 -0
  36. package/src/components/bar-list.tsx +158 -0
  37. package/src/components/chart-card.tsx +65 -0
  38. package/src/components/chart-container.tsx +51 -0
  39. package/src/components/chart-legend.tsx +49 -0
  40. package/src/components/chart-tooltip.tsx +93 -0
  41. package/src/components/donut-chart.tsx +214 -0
  42. package/src/components/form.tsx +4 -2
  43. package/src/components/heatmap-chart.tsx +331 -0
  44. package/src/components/line-chart.tsx +274 -0
  45. package/src/components/stat.tsx +113 -0
  46. package/src/components/textarea.tsx +1 -1
  47. package/src/components/wizard.tsx +1 -35
  48. package/src/hooks/use-chart-theme.ts +75 -0
  49. package/src/lib/chart-palette.ts +110 -0
  50. package/src/lib/chart.ts +90 -0
  51. package/src/stories/area-chart.stories.tsx +198 -0
  52. package/src/stories/bar-chart.stories.tsx +167 -0
  53. package/src/stories/bar-list.stories.tsx +83 -0
  54. package/src/stories/donut-chart.stories.tsx +110 -0
  55. package/src/stories/heatmap-chart.stories.tsx +105 -0
  56. package/src/stories/line-chart.stories.tsx +144 -0
  57. package/src/stories/stat.stories.tsx +64 -0
  58. package/src/stories/textarea.stories.tsx +7 -0
  59. package/src/stories/wizard.stories.tsx +23 -5
  60. package/src/styles/tokens.css +18 -0
@@ -0,0 +1,64 @@
1
+ import { ChartSeries } from "../lib/chart.mjs";
2
+ import { ChartPaletteName } from "../lib/chart-palette.mjs";
3
+ import * as React$1 from "react";
4
+
5
+ //#region src/components/area-chart.d.ts
6
+ declare const CURVE_TYPE: {
7
+ readonly monotone: "monotone";
8
+ readonly linear: "linear";
9
+ readonly step: "stepAfter";
10
+ };
11
+ interface ChartMarker {
12
+ x: string | number;
13
+ y: number;
14
+ label?: string;
15
+ color?: string;
16
+ }
17
+ interface AreaChartProps {
18
+ data: ReadonlyArray<Record<string, string | number | null | undefined>>;
19
+ index: string;
20
+ series: ChartSeries[];
21
+ variant?: "stacked" | "grouped" | "expand";
22
+ curve?: keyof typeof CURVE_TYPE;
23
+ legend?: boolean;
24
+ legendAlign?: "left" | "center" | "right";
25
+ valueFlags?: boolean;
26
+ height?: number;
27
+ yAxisWidth?: number;
28
+ palette?: ChartPaletteName;
29
+ referenceLine?: {
30
+ y: number;
31
+ label?: string;
32
+ band?: boolean;
33
+ };
34
+ markers?: ChartMarker[];
35
+ lastValueLabel?: boolean;
36
+ texture?: boolean;
37
+ loading?: boolean;
38
+ valueFormatter?: (value: number) => string;
39
+ labelFormatter?: (label: string | number) => string;
40
+ className?: string;
41
+ }
42
+ declare function AreaChart({
43
+ data,
44
+ index,
45
+ series,
46
+ variant,
47
+ curve,
48
+ legend,
49
+ legendAlign,
50
+ valueFlags,
51
+ height,
52
+ yAxisWidth,
53
+ palette,
54
+ referenceLine,
55
+ markers,
56
+ lastValueLabel,
57
+ texture,
58
+ loading,
59
+ valueFormatter,
60
+ labelFormatter,
61
+ className
62
+ }: AreaChartProps): React$1.JSX.Element;
63
+ //#endregion
64
+ export { AreaChart, AreaChartProps, ChartMarker };
@@ -0,0 +1,273 @@
1
+ "use client";
2
+ import { cn } from "../lib/cn.mjs";
3
+ import { makeXAxisTick, orderByLuminance, resolveSeries } from "../lib/chart.mjs";
4
+ import { useChartContext } from "./chart-container.mjs";
5
+ import { ChartLegend } from "./chart-legend.mjs";
6
+ import { ChartTooltipContent } from "./chart-tooltip.mjs";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ import * as React$1 from "react";
9
+ import { Area, AreaChart as AreaChart$1, CartesianGrid, LabelList, ReferenceArea, ReferenceDot, ReferenceLine, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
10
+ //#region src/components/area-chart.tsx
11
+ const CURVE_TYPE = {
12
+ monotone: "monotone",
13
+ linear: "linear",
14
+ step: "stepAfter"
15
+ };
16
+ function AreaChart({ data, index, series, variant = "stacked", curve = "monotone", legend = false, legendAlign = "left", valueFlags = false, height = 200, yAxisWidth = 48, palette, referenceLine, markers, lastValueLabel = false, texture = false, loading = false, valueFormatter = (value) => value.toLocaleString("en-US"), labelFormatter, className }) {
17
+ const { palette: paletteColors, theme } = useChartContext(palette);
18
+ const reactId = React$1.useId().replace(/:/g, "");
19
+ const resolved = resolveSeries(series, paletteColors, theme);
20
+ const stacked = variant === "stacked" || variant === "expand";
21
+ const rendered = stacked ? orderByLuminance(resolved) : resolved;
22
+ const filled = !(variant === "grouped" && rendered.length > 1);
23
+ const lead = resolved[0];
24
+ const withTotal = stacked && rendered.length > 1;
25
+ const numericMax = React$1.useMemo(() => {
26
+ let max = 0;
27
+ for (const row of data) {
28
+ let rowTotal = 0;
29
+ for (const entry of series) {
30
+ const value = Number(row[entry.key]);
31
+ if (Number.isFinite(value)) {
32
+ rowTotal += value;
33
+ if (!stacked && value > max) max = value;
34
+ }
35
+ }
36
+ if (stacked && rowTotal > max) max = rowTotal;
37
+ }
38
+ return max;
39
+ }, [
40
+ data,
41
+ series,
42
+ stacked
43
+ ]);
44
+ const curveType = CURVE_TYPE[curve];
45
+ const margin = {
46
+ top: markers?.length ? 18 : 8,
47
+ right: lastValueLabel ? 56 : 8,
48
+ bottom: 2,
49
+ left: 0
50
+ };
51
+ const axis = {
52
+ stroke: theme.border,
53
+ tick: {
54
+ fill: theme.axisForeground,
55
+ fontSize: 10,
56
+ fontFamily: theme.fontMono
57
+ },
58
+ tickLine: false,
59
+ axisLine: {
60
+ stroke: theme.border,
61
+ strokeOpacity: .6
62
+ }
63
+ };
64
+ const legendItems = resolved.map((entry) => ({
65
+ name: entry.name,
66
+ color: entry.color,
67
+ dashed: entry.dashed
68
+ }));
69
+ const activeDotFor = (entry) => valueFlags ? (dotProps) => {
70
+ if (dotProps.cx == null || dotProps.cy == null) return /* @__PURE__ */ jsx("g", {});
71
+ return /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("circle", {
72
+ cx: dotProps.cx,
73
+ cy: dotProps.cy,
74
+ r: 3.5,
75
+ fill: entry.color,
76
+ stroke: theme.card,
77
+ strokeWidth: 2
78
+ }), /* @__PURE__ */ jsx("text", {
79
+ x: dotProps.cx,
80
+ y: dotProps.cy - 8,
81
+ textAnchor: "middle",
82
+ fill: entry.color,
83
+ fontFamily: theme.fontMono,
84
+ fontSize: 10,
85
+ style: { fontVariantNumeric: "tabular-nums" },
86
+ children: valueFormatter(Number(dotProps.value ?? 0))
87
+ })] });
88
+ } : {
89
+ r: 3.5,
90
+ fill: entry.color,
91
+ stroke: theme.card,
92
+ strokeWidth: 2
93
+ };
94
+ const fillFor = (entry, slot) => {
95
+ if (!filled) return "none";
96
+ if (texture && lead && entry.key === lead.key) return `url(#hatch-${reactId})`;
97
+ return `url(#area-${reactId}-${slot})`;
98
+ };
99
+ const renderLastLabel = (color) => (props) => {
100
+ if (props.index !== data.length - 1 || props.x == null || props.y == null) return null;
101
+ return /* @__PURE__ */ jsx("text", {
102
+ x: Number(props.x) + 6,
103
+ y: Number(props.y),
104
+ dy: 3,
105
+ fill: color,
106
+ fontFamily: theme.fontMono,
107
+ fontSize: 10,
108
+ textAnchor: "start",
109
+ style: { fontVariantNumeric: "tabular-nums" },
110
+ children: valueFormatter(Number(props.value ?? 0))
111
+ });
112
+ };
113
+ const isEmpty = data.length === 0 || rendered.length === 0;
114
+ return /* @__PURE__ */ jsxs("div", {
115
+ "data-slot": "area-chart",
116
+ className: cn("flex w-full flex-col gap-3", className),
117
+ children: [/* @__PURE__ */ jsx("div", {
118
+ className: "w-full",
119
+ style: { height },
120
+ children: loading ? /* @__PURE__ */ jsxs("div", {
121
+ className: "flex h-full items-center justify-center gap-2.5 font-mono text-quaternary-foreground text-text-xs",
122
+ children: [/* @__PURE__ */ jsx("span", { className: "size-4 animate-spin rounded-full border-2 border-border border-t-foreground" }), "loading…"]
123
+ }) : isEmpty ? /* @__PURE__ */ jsx("div", {
124
+ className: "flex h-full items-center justify-center rounded-lg border border-border border-dashed font-mono text-quaternary-foreground text-text-xs",
125
+ children: "no data in range"
126
+ }) : /* @__PURE__ */ jsx(ResponsiveContainer, {
127
+ width: "100%",
128
+ height: "100%",
129
+ initialDimension: {
130
+ width: 0,
131
+ height
132
+ },
133
+ children: /* @__PURE__ */ jsxs(AreaChart$1, {
134
+ data,
135
+ stackOffset: variant === "expand" ? "expand" : "none",
136
+ margin,
137
+ children: [
138
+ /* @__PURE__ */ jsxs("defs", { children: [filled && rendered.map((entry, slot) => /* @__PURE__ */ jsxs("linearGradient", {
139
+ id: `area-${reactId}-${slot}`,
140
+ x1: "0",
141
+ y1: "0",
142
+ x2: "0",
143
+ y2: "1",
144
+ children: [/* @__PURE__ */ jsx("stop", {
145
+ offset: "0%",
146
+ stopColor: entry.color,
147
+ stopOpacity: stacked ? .78 : .5
148
+ }), /* @__PURE__ */ jsx("stop", {
149
+ offset: "100%",
150
+ stopColor: entry.color,
151
+ stopOpacity: stacked ? .32 : .04
152
+ })]
153
+ }, entry.key)), texture && filled && lead && /* @__PURE__ */ jsxs("pattern", {
154
+ id: `hatch-${reactId}`,
155
+ patternUnits: "userSpaceOnUse",
156
+ width: 6,
157
+ height: 6,
158
+ patternTransform: "rotate(45)",
159
+ children: [/* @__PURE__ */ jsx("rect", {
160
+ width: 6,
161
+ height: 6,
162
+ fill: lead.color,
163
+ fillOpacity: .18
164
+ }), /* @__PURE__ */ jsx("line", {
165
+ x1: 0,
166
+ y1: 0,
167
+ x2: 0,
168
+ y2: 6,
169
+ stroke: lead.color,
170
+ strokeWidth: 1.2,
171
+ strokeOpacity: .6
172
+ })]
173
+ })] }),
174
+ /* @__PURE__ */ jsx(CartesianGrid, {
175
+ vertical: false,
176
+ stroke: theme.grid,
177
+ strokeDasharray: "2 4"
178
+ }),
179
+ /* @__PURE__ */ jsx(XAxis, {
180
+ dataKey: index,
181
+ ...axis,
182
+ tick: makeXAxisTick(theme),
183
+ interval: "preserveStartEnd",
184
+ minTickGap: 44
185
+ }),
186
+ /* @__PURE__ */ jsx(YAxis, {
187
+ ...axis,
188
+ width: yAxisWidth,
189
+ tickFormatter: (value) => variant === "expand" ? `${Math.round(value * 100)}%` : valueFormatter(value)
190
+ }),
191
+ /* @__PURE__ */ jsx(Tooltip, {
192
+ offset: 12,
193
+ allowEscapeViewBox: {
194
+ x: false,
195
+ y: false
196
+ },
197
+ cursor: {
198
+ stroke: theme.axisForeground,
199
+ strokeWidth: 1,
200
+ strokeDasharray: "3 3"
201
+ },
202
+ content: /* @__PURE__ */ jsx(ChartTooltipContent, {
203
+ valueFormatter,
204
+ labelFormatter,
205
+ showTotal: withTotal
206
+ })
207
+ }),
208
+ referenceLine?.band && /* @__PURE__ */ jsx(ReferenceArea, {
209
+ y1: referenceLine.y,
210
+ y2: numericMax,
211
+ fill: theme.warning,
212
+ fillOpacity: .06,
213
+ ifOverflow: "extendDomain"
214
+ }),
215
+ referenceLine && /* @__PURE__ */ jsx(ReferenceLine, {
216
+ y: referenceLine.y,
217
+ stroke: theme.warning,
218
+ strokeDasharray: "4 4",
219
+ strokeOpacity: .6,
220
+ label: referenceLine.label ? {
221
+ value: referenceLine.label,
222
+ fill: theme.warning,
223
+ fontSize: 9,
224
+ fontFamily: theme.fontMono,
225
+ position: "insideBottomRight"
226
+ } : void 0
227
+ }),
228
+ rendered.map((entry, slot) => /* @__PURE__ */ jsx(Area, {
229
+ type: curveType,
230
+ dataKey: entry.key,
231
+ name: entry.name,
232
+ stackId: stacked ? "stack" : void 0,
233
+ stroke: entry.color,
234
+ strokeWidth: entry.dashed ? 2 : 1.6,
235
+ strokeDasharray: entry.dashed ? "5 3" : void 0,
236
+ fill: fillFor(entry, slot),
237
+ dot: false,
238
+ activeDot: activeDotFor(entry),
239
+ isAnimationActive: false,
240
+ animationDuration: 650,
241
+ animationEasing: "ease-out",
242
+ children: lastValueLabel && /* @__PURE__ */ jsx(LabelList, {
243
+ dataKey: entry.key,
244
+ content: renderLastLabel(entry.color)
245
+ })
246
+ }, entry.key)),
247
+ markers?.map((marker) => /* @__PURE__ */ jsx(ReferenceDot, {
248
+ x: marker.x,
249
+ y: marker.y,
250
+ r: 3.5,
251
+ fill: marker.color ?? theme.foreground,
252
+ stroke: theme.card,
253
+ strokeWidth: 2,
254
+ label: marker.label ? {
255
+ value: marker.label,
256
+ fill: marker.color ?? theme.foreground,
257
+ fontSize: 9,
258
+ fontFamily: theme.fontMono,
259
+ position: "top"
260
+ } : void 0
261
+ }, `${marker.x}-${marker.y}`))
262
+ ]
263
+ })
264
+ })
265
+ }), legend && !isEmpty && /* @__PURE__ */ jsx(ChartLegend, {
266
+ items: legendItems,
267
+ align: legendAlign,
268
+ insetLeft: yAxisWidth
269
+ })]
270
+ });
271
+ }
272
+ //#endregion
273
+ export { AreaChart };
@@ -0,0 +1,50 @@
1
+ import { ChartSeries } from "../lib/chart.mjs";
2
+ import { ChartPaletteName } from "../lib/chart-palette.mjs";
3
+ import { ChartMarker } from "./area-chart.mjs";
4
+ import * as React$1 from "react";
5
+
6
+ //#region src/components/bar-chart.d.ts
7
+ interface BarChartProps {
8
+ data: ReadonlyArray<Record<string, string | number | null | undefined>>;
9
+ index: string;
10
+ series: ChartSeries[];
11
+ variant?: "stacked" | "grouped" | "expand";
12
+ legend?: boolean;
13
+ legendAlign?: "left" | "center" | "right";
14
+ valueLabels?: boolean;
15
+ height?: number;
16
+ yAxisWidth?: number;
17
+ palette?: ChartPaletteName;
18
+ referenceLine?: {
19
+ y: number;
20
+ label?: string;
21
+ band?: boolean;
22
+ };
23
+ markers?: ChartMarker[];
24
+ texture?: boolean;
25
+ loading?: boolean;
26
+ valueFormatter?: (value: number) => string;
27
+ labelFormatter?: (label: string | number) => string;
28
+ className?: string;
29
+ }
30
+ declare function BarChart({
31
+ data,
32
+ index,
33
+ series,
34
+ variant,
35
+ legend,
36
+ legendAlign,
37
+ valueLabels,
38
+ height,
39
+ yAxisWidth,
40
+ palette,
41
+ referenceLine,
42
+ markers,
43
+ texture,
44
+ loading,
45
+ valueFormatter,
46
+ labelFormatter,
47
+ className
48
+ }: BarChartProps): React$1.JSX.Element;
49
+ //#endregion
50
+ export { BarChart, BarChartProps };
@@ -0,0 +1,260 @@
1
+ "use client";
2
+ import { cn } from "../lib/cn.mjs";
3
+ import { makeXAxisTick, orderByLuminance, resolveSeries } from "../lib/chart.mjs";
4
+ import { useChartContext } from "./chart-container.mjs";
5
+ import { ChartLegend } from "./chart-legend.mjs";
6
+ import { ChartTooltipContent } from "./chart-tooltip.mjs";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ import * as React$1 from "react";
9
+ import { Bar, BarChart as BarChart$1, CartesianGrid, LabelList, ReferenceArea, ReferenceDot, ReferenceLine, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
10
+ //#region src/components/bar-chart.tsx
11
+ const BAR_RADIUS = 4;
12
+ const MAX_BAR_SIZE = 48;
13
+ function BarChart({ data, index, series, variant = "stacked", legend = false, legendAlign = "left", valueLabels = false, height = 200, yAxisWidth = 48, palette, referenceLine, markers, texture = false, loading = false, valueFormatter = (value) => value.toLocaleString("en-US"), labelFormatter, className }) {
14
+ const { palette: paletteColors, theme } = useChartContext(palette);
15
+ const reactId = React$1.useId().replace(/:/g, "");
16
+ const resolved = resolveSeries(series, paletteColors, theme);
17
+ const stacked = variant === "stacked" || variant === "expand";
18
+ const rendered = stacked ? orderByLuminance(resolved) : resolved;
19
+ const lead = resolved[0];
20
+ const withTotal = stacked && rendered.length > 1;
21
+ const numericMax = React$1.useMemo(() => {
22
+ let max = 0;
23
+ for (const row of data) {
24
+ let rowTotal = 0;
25
+ for (const entry of series) {
26
+ const value = Number(row[entry.key]);
27
+ if (Number.isFinite(value)) {
28
+ rowTotal += value;
29
+ if (!stacked && value > max) max = value;
30
+ }
31
+ }
32
+ if (stacked && rowTotal > max) max = rowTotal;
33
+ }
34
+ return max;
35
+ }, [
36
+ data,
37
+ series,
38
+ stacked
39
+ ]);
40
+ const margin = {
41
+ top: markers?.length || valueLabels ? 18 : 8,
42
+ right: 8,
43
+ bottom: 2,
44
+ left: 0
45
+ };
46
+ const axis = {
47
+ stroke: theme.border,
48
+ tick: {
49
+ fill: theme.axisForeground,
50
+ fontSize: 10,
51
+ fontFamily: theme.fontMono
52
+ },
53
+ tickLine: false,
54
+ axisLine: {
55
+ stroke: theme.border,
56
+ strokeOpacity: .6
57
+ }
58
+ };
59
+ const legendItems = resolved.map((entry) => ({
60
+ name: entry.name,
61
+ color: entry.color,
62
+ dashed: entry.dashed
63
+ }));
64
+ const radiusFor = (slot) => {
65
+ if (!stacked || slot === rendered.length - 1) return [
66
+ BAR_RADIUS,
67
+ BAR_RADIUS,
68
+ 0,
69
+ 0
70
+ ];
71
+ return [
72
+ 0,
73
+ 0,
74
+ 0,
75
+ 0
76
+ ];
77
+ };
78
+ const fillFor = (entry, slot) => {
79
+ if (texture && lead && entry.key === lead.key) return `url(#bar-hatch-${reactId})`;
80
+ if (stacked) return entry.color;
81
+ return `url(#bar-${reactId}-${slot})`;
82
+ };
83
+ const renderValueLabel = (color) => (props) => {
84
+ if (props.x == null || props.y == null) return null;
85
+ return /* @__PURE__ */ jsx("text", {
86
+ x: Number(props.x) + Number(props.width ?? 0) / 2,
87
+ y: Number(props.y) - 5,
88
+ textAnchor: "middle",
89
+ fill: color,
90
+ fontFamily: theme.fontMono,
91
+ fontSize: 10,
92
+ style: { fontVariantNumeric: "tabular-nums" },
93
+ children: valueFormatter(Number(props.value ?? 0))
94
+ });
95
+ };
96
+ const isEmpty = data.length === 0 || rendered.length === 0;
97
+ return /* @__PURE__ */ jsxs("div", {
98
+ "data-slot": "bar-chart",
99
+ className: cn("flex w-full flex-col gap-3", className),
100
+ children: [/* @__PURE__ */ jsx("div", {
101
+ className: "w-full",
102
+ style: { height },
103
+ children: loading ? /* @__PURE__ */ jsxs("div", {
104
+ className: "flex h-full items-center justify-center gap-2.5 font-mono text-quaternary-foreground text-text-xs",
105
+ children: [/* @__PURE__ */ jsx("span", { className: "size-4 animate-spin rounded-full border-2 border-border border-t-foreground" }), "loading…"]
106
+ }) : isEmpty ? /* @__PURE__ */ jsx("div", {
107
+ className: "flex h-full items-center justify-center rounded-lg border border-border border-dashed font-mono text-quaternary-foreground text-text-xs",
108
+ children: "no data in range"
109
+ }) : /* @__PURE__ */ jsx(ResponsiveContainer, {
110
+ width: "100%",
111
+ height: "100%",
112
+ initialDimension: {
113
+ width: 0,
114
+ height
115
+ },
116
+ children: /* @__PURE__ */ jsxs(BarChart$1, {
117
+ data,
118
+ stackOffset: variant === "expand" ? "expand" : "none",
119
+ margin,
120
+ barCategoryGap: stacked ? "20%" : "16%",
121
+ children: [
122
+ /* @__PURE__ */ jsxs("defs", { children: [!stacked && rendered.map((entry, slot) => /* @__PURE__ */ jsxs("linearGradient", {
123
+ id: `bar-${reactId}-${slot}`,
124
+ x1: "0",
125
+ y1: "0",
126
+ x2: "0",
127
+ y2: "1",
128
+ children: [/* @__PURE__ */ jsx("stop", {
129
+ offset: "0%",
130
+ stopColor: entry.color,
131
+ stopOpacity: .95
132
+ }), /* @__PURE__ */ jsx("stop", {
133
+ offset: "100%",
134
+ stopColor: entry.color,
135
+ stopOpacity: .5
136
+ })]
137
+ }, entry.key)), texture && lead && /* @__PURE__ */ jsxs("pattern", {
138
+ id: `bar-hatch-${reactId}`,
139
+ patternUnits: "userSpaceOnUse",
140
+ width: 6,
141
+ height: 6,
142
+ patternTransform: "rotate(45)",
143
+ children: [/* @__PURE__ */ jsx("rect", {
144
+ width: 6,
145
+ height: 6,
146
+ fill: lead.color,
147
+ fillOpacity: .22
148
+ }), /* @__PURE__ */ jsx("line", {
149
+ x1: 0,
150
+ y1: 0,
151
+ x2: 0,
152
+ y2: 6,
153
+ stroke: lead.color,
154
+ strokeWidth: 1.2,
155
+ strokeOpacity: .65
156
+ })]
157
+ })] }),
158
+ /* @__PURE__ */ jsx(CartesianGrid, {
159
+ vertical: false,
160
+ stroke: theme.grid,
161
+ strokeDasharray: "2 4"
162
+ }),
163
+ /* @__PURE__ */ jsx(XAxis, {
164
+ dataKey: index,
165
+ ...axis,
166
+ tick: makeXAxisTick(theme),
167
+ interval: "preserveStartEnd",
168
+ minTickGap: 44
169
+ }),
170
+ /* @__PURE__ */ jsx(YAxis, {
171
+ ...axis,
172
+ width: yAxisWidth,
173
+ domain: referenceLine && variant !== "expand" ? [0, Math.ceil(Math.max(numericMax, referenceLine.y) * 1.15)] : void 0,
174
+ tickFormatter: (value) => variant === "expand" ? `${Math.round(value * 100)}%` : valueFormatter(value)
175
+ }),
176
+ /* @__PURE__ */ jsx(Tooltip, {
177
+ offset: 12,
178
+ allowEscapeViewBox: {
179
+ x: false,
180
+ y: false
181
+ },
182
+ cursor: {
183
+ fill: lead?.color ?? theme.mutedForeground,
184
+ fillOpacity: theme.isDark ? .1 : .06
185
+ },
186
+ content: /* @__PURE__ */ jsx(ChartTooltipContent, {
187
+ valueFormatter,
188
+ labelFormatter,
189
+ showTotal: withTotal
190
+ })
191
+ }),
192
+ referenceLine?.band && /* @__PURE__ */ jsx(ReferenceArea, {
193
+ y1: referenceLine.y,
194
+ y2: numericMax,
195
+ fill: theme.warning,
196
+ fillOpacity: .06,
197
+ ifOverflow: "extendDomain"
198
+ }),
199
+ referenceLine && /* @__PURE__ */ jsx(ReferenceLine, {
200
+ y: referenceLine.y,
201
+ stroke: theme.warning,
202
+ strokeDasharray: "4 4",
203
+ strokeOpacity: .6,
204
+ label: referenceLine.label ? {
205
+ value: referenceLine.label,
206
+ fill: theme.warning,
207
+ fontSize: 9,
208
+ fontFamily: theme.fontMono,
209
+ position: "insideBottomRight"
210
+ } : void 0
211
+ }),
212
+ rendered.map((entry, slot) => /* @__PURE__ */ jsx(Bar, {
213
+ dataKey: entry.key,
214
+ name: entry.name,
215
+ stackId: stacked ? "stack" : void 0,
216
+ fill: fillFor(entry, slot),
217
+ stroke: entry.color,
218
+ strokeWidth: 0,
219
+ radius: radiusFor(slot),
220
+ maxBarSize: MAX_BAR_SIZE,
221
+ activeBar: {
222
+ fillOpacity: 1,
223
+ stroke: theme.card,
224
+ strokeWidth: 1
225
+ },
226
+ isAnimationActive: false,
227
+ animationDuration: 650,
228
+ animationEasing: "ease-out",
229
+ children: valueLabels && (!stacked || rendered.length === 1) && /* @__PURE__ */ jsx(LabelList, {
230
+ dataKey: entry.key,
231
+ content: renderValueLabel(entry.color)
232
+ })
233
+ }, entry.key)),
234
+ markers?.map((marker) => /* @__PURE__ */ jsx(ReferenceDot, {
235
+ x: marker.x,
236
+ y: marker.y,
237
+ r: 3.5,
238
+ fill: marker.color ?? theme.foreground,
239
+ stroke: theme.card,
240
+ strokeWidth: 2,
241
+ label: marker.label ? {
242
+ value: marker.label,
243
+ fill: marker.color ?? theme.foreground,
244
+ fontSize: 9,
245
+ fontFamily: theme.fontMono,
246
+ position: "top"
247
+ } : void 0
248
+ }, `${marker.x}-${marker.y}`))
249
+ ]
250
+ })
251
+ })
252
+ }), legend && !isEmpty && /* @__PURE__ */ jsx(ChartLegend, {
253
+ items: legendItems,
254
+ align: legendAlign,
255
+ insetLeft: yAxisWidth
256
+ })]
257
+ });
258
+ }
259
+ //#endregion
260
+ export { BarChart };
@@ -0,0 +1,31 @@
1
+ import { ChartPaletteName } from "../lib/chart-palette.mjs";
2
+ import * as React$1 from "react";
3
+
4
+ //#region src/components/bar-list.d.ts
5
+ interface BarListProps {
6
+ data: ReadonlyArray<Record<string, string | number | null | undefined>>;
7
+ index: string;
8
+ dataKey?: string;
9
+ maxItems?: number;
10
+ palette?: ChartPaletteName;
11
+ /** Renders bars in a single semantic hue (e.g. red for errors) rather than the palette ramp. */
12
+ semantic?: "error" | "warning" | "success";
13
+ loading?: boolean;
14
+ valueFormatter?: (value: number) => string;
15
+ labelFormatter?: (label: string | number) => string;
16
+ className?: string;
17
+ }
18
+ declare function BarList({
19
+ data,
20
+ index,
21
+ dataKey,
22
+ maxItems,
23
+ palette,
24
+ semantic,
25
+ loading,
26
+ valueFormatter,
27
+ labelFormatter,
28
+ className
29
+ }: BarListProps): React$1.JSX.Element;
30
+ //#endregion
31
+ export { BarList, BarListProps };