@alpic-ai/ui 0.0.0-staging.gdf8e504 → 0.0.0-staging.gdfe3a14

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