@alpic-ai/ui 0.0.0-dev.g0999450 → 0.0.0-dev.g0a2a154
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/dist/components/accordion-card.d.mts +5 -5
- package/dist/components/accordion.d.mts +5 -5
- package/dist/components/alert.d.mts +8 -8
- package/dist/components/area-chart.d.mts +62 -0
- package/dist/components/area-chart.mjs +269 -0
- package/dist/components/attachment-tile.d.mts +1 -1
- package/dist/components/avatar.d.mts +7 -7
- package/dist/components/badge.d.mts +1 -1
- package/dist/components/bar-chart.d.mts +48 -0
- package/dist/components/bar-chart.mjs +256 -0
- package/dist/components/bar-list.d.mts +28 -0
- package/dist/components/bar-list.mjs +98 -0
- package/dist/components/breadcrumb.d.mts +10 -10
- package/dist/components/button.d.mts +5 -5
- package/dist/components/card.d.mts +9 -9
- package/dist/components/chart-card.d.mts +25 -0
- package/dist/components/chart-card.mjs +48 -0
- package/dist/components/chart-container.d.mts +20 -0
- package/dist/components/chart-container.mjs +37 -0
- package/dist/components/chart-legend.d.mts +16 -0
- package/dist/components/chart-legend.mjs +26 -0
- package/dist/components/chart-tooltip.d.mts +33 -0
- package/dist/components/chart-tooltip.mjs +52 -0
- package/dist/components/checkbox.d.mts +2 -2
- package/dist/components/collapsible.d.mts +4 -4
- package/dist/components/combobox.d.mts +10 -10
- package/dist/components/command.d.mts +9 -9
- package/dist/components/copyable.d.mts +2 -2
- package/dist/components/description-list.d.mts +5 -5
- package/dist/components/dialog.d.mts +13 -13
- package/dist/components/donut-chart.d.mts +46 -0
- package/dist/components/donut-chart.mjs +185 -0
- package/dist/components/dropdown-menu.d.mts +17 -17
- package/dist/components/form.d.mts +18 -18
- package/dist/components/form.mjs +6 -6
- package/dist/components/github-button.d.mts +1 -1
- package/dist/components/heatmap-chart.d.mts +40 -0
- package/dist/components/heatmap-chart.mjs +198 -0
- package/dist/components/input-group.d.mts +4 -4
- package/dist/components/input.d.mts +4 -4
- package/dist/components/input.mjs +2 -2
- package/dist/components/label.d.mts +2 -2
- package/dist/components/line-chart.d.mts +55 -0
- package/dist/components/line-chart.mjs +211 -0
- package/dist/components/page-loader.d.mts +1 -1
- package/dist/components/pagination.d.mts +3 -3
- package/dist/components/popover.d.mts +5 -5
- package/dist/components/radio-group.d.mts +3 -3
- package/dist/components/scroll-area.d.mts +3 -3
- package/dist/components/select.d.mts +9 -9
- package/dist/components/separator.d.mts +2 -2
- package/dist/components/sheet.d.mts +11 -11
- package/dist/components/shimmer-text.d.mts +3 -1
- package/dist/components/sidebar.d.mts +33 -33
- package/dist/components/sidebar.mjs +10 -10
- package/dist/components/skeleton.d.mts +1 -1
- package/dist/components/sonner.d.mts +5 -5
- package/dist/components/spinner.d.mts +2 -2
- package/dist/components/stat.d.mts +30 -0
- package/dist/components/stat.mjs +107 -0
- package/dist/components/status-dot.d.mts +1 -1
- package/dist/components/switch.d.mts +2 -2
- package/dist/components/table.d.mts +10 -10
- package/dist/components/tabs.d.mts +10 -10
- package/dist/components/tag.d.mts +3 -3
- package/dist/components/task-progress.d.mts +1 -1
- package/dist/components/textarea.d.mts +3 -3
- package/dist/components/textarea.mjs +2 -2
- package/dist/components/toggle-group.d.mts +3 -3
- package/dist/components/toggle-group.mjs +3 -3
- package/dist/components/tooltip.d.mts +5 -5
- package/dist/components/typography.d.mts +4 -4
- package/dist/components/wizard.d.mts +4 -22
- package/dist/components/wizard.mjs +1 -19
- package/dist/hooks/use-chart-theme.d.mts +18 -0
- package/dist/hooks/use-chart-theme.mjs +57 -0
- package/dist/hooks/use-mobile.mjs +3 -3
- package/dist/hooks/use-reduced-motion.d.mts +4 -0
- package/dist/hooks/use-reduced-motion.mjs +16 -0
- package/dist/lib/chart-palette.d.mts +4 -0
- package/dist/lib/chart-palette.mjs +95 -0
- package/dist/lib/chart.d.mts +14 -0
- package/dist/lib/chart.mjs +27 -0
- package/package.json +30 -29
- package/src/components/area-chart.tsx +339 -0
- package/src/components/bar-chart.tsx +309 -0
- package/src/components/bar-list.tsx +150 -0
- package/src/components/chart-card.tsx +63 -0
- package/src/components/chart-container.tsx +49 -0
- package/src/components/chart-legend.tsx +41 -0
- package/src/components/chart-tooltip.tsx +93 -0
- package/src/components/donut-chart.tsx +217 -0
- package/src/components/heatmap-chart.tsx +287 -0
- package/src/components/line-chart.tsx +264 -0
- package/src/components/stat.tsx +109 -0
- package/src/components/wizard.tsx +1 -35
- package/src/hooks/use-chart-theme.ts +75 -0
- package/src/hooks/use-reduced-motion.ts +17 -0
- package/src/lib/chart-palette.ts +110 -0
- package/src/lib/chart.ts +56 -0
- package/src/stories/area-chart.stories.tsx +198 -0
- package/src/stories/bar-chart.stories.tsx +167 -0
- package/src/stories/bar-list.stories.tsx +83 -0
- package/src/stories/donut-chart.stories.tsx +110 -0
- package/src/stories/heatmap-chart.stories.tsx +105 -0
- package/src/stories/line-chart.stories.tsx +144 -0
- package/src/stories/stat.stories.tsx +64 -0
- package/src/stories/wizard.stories.tsx +22 -4
- package/src/styles/tokens.css +63 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.mjs";
|
|
3
|
+
import { useReducedMotion } from "../hooks/use-reduced-motion.mjs";
|
|
4
|
+
import { orderByLuminance, resolveSeries } from "../lib/chart.mjs";
|
|
5
|
+
import { useChartContext } from "./chart-container.mjs";
|
|
6
|
+
import { ChartLegend } from "./chart-legend.mjs";
|
|
7
|
+
import { ChartTooltipContent } from "./chart-tooltip.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, 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 animated = !useReducedMotion();
|
|
18
|
+
const resolved = resolveSeries(series, paletteColors, theme);
|
|
19
|
+
const stacked = variant === "stacked" || variant === "expand";
|
|
20
|
+
const rendered = stacked ? orderByLuminance(resolved) : resolved;
|
|
21
|
+
const lead = resolved[0];
|
|
22
|
+
const withTotal = stacked && rendered.length > 1;
|
|
23
|
+
const numericMax = React$1.useMemo(() => {
|
|
24
|
+
let max = 0;
|
|
25
|
+
for (const row of data) {
|
|
26
|
+
let rowTotal = 0;
|
|
27
|
+
for (const entry of series) {
|
|
28
|
+
const value = Number(row[entry.key]);
|
|
29
|
+
if (Number.isFinite(value)) {
|
|
30
|
+
rowTotal += value;
|
|
31
|
+
if (!stacked && value > max) max = value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (stacked && rowTotal > max) max = rowTotal;
|
|
35
|
+
}
|
|
36
|
+
return max;
|
|
37
|
+
}, [
|
|
38
|
+
data,
|
|
39
|
+
series,
|
|
40
|
+
stacked
|
|
41
|
+
]);
|
|
42
|
+
const margin = {
|
|
43
|
+
top: markers?.length || valueLabels ? 18 : 8,
|
|
44
|
+
right: 8,
|
|
45
|
+
bottom: 2,
|
|
46
|
+
left: 0
|
|
47
|
+
};
|
|
48
|
+
const axis = {
|
|
49
|
+
stroke: theme.border,
|
|
50
|
+
tick: {
|
|
51
|
+
fill: theme.axisForeground,
|
|
52
|
+
fontSize: 10,
|
|
53
|
+
fontFamily: theme.fontMono
|
|
54
|
+
},
|
|
55
|
+
tickLine: false,
|
|
56
|
+
axisLine: {
|
|
57
|
+
stroke: theme.border,
|
|
58
|
+
strokeOpacity: .6
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const legendItems = resolved.map((entry) => ({
|
|
62
|
+
name: entry.name,
|
|
63
|
+
color: entry.color,
|
|
64
|
+
dashed: entry.dashed
|
|
65
|
+
}));
|
|
66
|
+
const radiusFor = (slot) => {
|
|
67
|
+
if (!stacked || slot === rendered.length - 1) return [
|
|
68
|
+
BAR_RADIUS,
|
|
69
|
+
BAR_RADIUS,
|
|
70
|
+
0,
|
|
71
|
+
0
|
|
72
|
+
];
|
|
73
|
+
return [
|
|
74
|
+
0,
|
|
75
|
+
0,
|
|
76
|
+
0,
|
|
77
|
+
0
|
|
78
|
+
];
|
|
79
|
+
};
|
|
80
|
+
const fillFor = (entry, slot) => {
|
|
81
|
+
if (texture && lead && entry.key === lead.key) return `url(#bar-hatch-${reactId})`;
|
|
82
|
+
if (stacked) return entry.color;
|
|
83
|
+
return `url(#bar-${reactId}-${slot})`;
|
|
84
|
+
};
|
|
85
|
+
const renderValueLabel = (color) => (props) => {
|
|
86
|
+
if (props.x == null || props.y == null) return null;
|
|
87
|
+
return /* @__PURE__ */ jsx("text", {
|
|
88
|
+
x: Number(props.x) + Number(props.width ?? 0) / 2,
|
|
89
|
+
y: Number(props.y) - 5,
|
|
90
|
+
textAnchor: "middle",
|
|
91
|
+
fill: color,
|
|
92
|
+
fontFamily: theme.fontMono,
|
|
93
|
+
fontSize: 10,
|
|
94
|
+
style: { fontVariantNumeric: "tabular-nums" },
|
|
95
|
+
children: valueFormatter(Number(props.value ?? 0))
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
const isEmpty = data.length === 0 || rendered.length === 0;
|
|
99
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
100
|
+
"data-slot": "bar-chart",
|
|
101
|
+
className: cn("flex w-full flex-col gap-3", className),
|
|
102
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
103
|
+
className: "w-full",
|
|
104
|
+
style: { height },
|
|
105
|
+
children: loading ? /* @__PURE__ */ jsxs("div", {
|
|
106
|
+
className: "flex h-full items-center justify-center gap-2.5 font-mono text-quaternary-foreground text-text-xs",
|
|
107
|
+
children: [/* @__PURE__ */ jsx("span", { className: "size-4 animate-spin rounded-full border-2 border-border border-t-foreground" }), "loading…"]
|
|
108
|
+
}) : isEmpty ? /* @__PURE__ */ jsx("div", {
|
|
109
|
+
className: "flex h-full items-center justify-center rounded-lg border border-border border-dashed font-mono text-quaternary-foreground text-text-xs",
|
|
110
|
+
children: "no data in range"
|
|
111
|
+
}) : /* @__PURE__ */ jsx(ResponsiveContainer, {
|
|
112
|
+
width: "100%",
|
|
113
|
+
height: "100%",
|
|
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
|
+
interval: "preserveStartEnd",
|
|
165
|
+
minTickGap: 44
|
|
166
|
+
}),
|
|
167
|
+
/* @__PURE__ */ jsx(YAxis, {
|
|
168
|
+
...axis,
|
|
169
|
+
width: yAxisWidth,
|
|
170
|
+
domain: referenceLine && variant !== "expand" ? [0, Math.ceil(Math.max(numericMax, referenceLine.y) * 1.15)] : void 0,
|
|
171
|
+
tickFormatter: (value) => variant === "expand" ? `${Math.round(value * 100)}%` : valueFormatter(value)
|
|
172
|
+
}),
|
|
173
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
174
|
+
offset: 12,
|
|
175
|
+
allowEscapeViewBox: {
|
|
176
|
+
x: false,
|
|
177
|
+
y: false
|
|
178
|
+
},
|
|
179
|
+
cursor: {
|
|
180
|
+
fill: lead?.color ?? theme.mutedForeground,
|
|
181
|
+
fillOpacity: theme.isDark ? .1 : .06
|
|
182
|
+
},
|
|
183
|
+
content: /* @__PURE__ */ jsx(ChartTooltipContent, {
|
|
184
|
+
valueFormatter,
|
|
185
|
+
labelFormatter,
|
|
186
|
+
showTotal: withTotal
|
|
187
|
+
})
|
|
188
|
+
}),
|
|
189
|
+
referenceLine?.band && /* @__PURE__ */ jsx(ReferenceArea, {
|
|
190
|
+
y1: referenceLine.y,
|
|
191
|
+
y2: numericMax,
|
|
192
|
+
fill: theme.warning,
|
|
193
|
+
fillOpacity: .06,
|
|
194
|
+
ifOverflow: "extendDomain"
|
|
195
|
+
}),
|
|
196
|
+
referenceLine && /* @__PURE__ */ jsx(ReferenceLine, {
|
|
197
|
+
y: referenceLine.y,
|
|
198
|
+
stroke: theme.warning,
|
|
199
|
+
strokeDasharray: "4 4",
|
|
200
|
+
strokeOpacity: .6,
|
|
201
|
+
label: referenceLine.label ? {
|
|
202
|
+
value: referenceLine.label,
|
|
203
|
+
fill: theme.warning,
|
|
204
|
+
fontSize: 9,
|
|
205
|
+
fontFamily: theme.fontMono,
|
|
206
|
+
position: "insideBottomRight"
|
|
207
|
+
} : void 0
|
|
208
|
+
}),
|
|
209
|
+
rendered.map((entry, slot) => /* @__PURE__ */ jsx(Bar, {
|
|
210
|
+
dataKey: entry.key,
|
|
211
|
+
name: entry.name,
|
|
212
|
+
stackId: stacked ? "stack" : void 0,
|
|
213
|
+
fill: fillFor(entry, slot),
|
|
214
|
+
stroke: entry.color,
|
|
215
|
+
strokeWidth: 0,
|
|
216
|
+
radius: radiusFor(slot),
|
|
217
|
+
maxBarSize: MAX_BAR_SIZE,
|
|
218
|
+
activeBar: {
|
|
219
|
+
fillOpacity: 1,
|
|
220
|
+
stroke: theme.card,
|
|
221
|
+
strokeWidth: 1
|
|
222
|
+
},
|
|
223
|
+
isAnimationActive: animated,
|
|
224
|
+
animationDuration: 650,
|
|
225
|
+
animationEasing: "ease-out",
|
|
226
|
+
children: valueLabels && (!stacked || rendered.length === 1) && /* @__PURE__ */ jsx(LabelList, {
|
|
227
|
+
dataKey: entry.key,
|
|
228
|
+
content: renderValueLabel(entry.color)
|
|
229
|
+
})
|
|
230
|
+
}, entry.key)),
|
|
231
|
+
markers?.map((marker) => /* @__PURE__ */ jsx(ReferenceDot, {
|
|
232
|
+
x: marker.x,
|
|
233
|
+
y: marker.y,
|
|
234
|
+
r: 3.5,
|
|
235
|
+
fill: marker.color ?? theme.foreground,
|
|
236
|
+
stroke: theme.card,
|
|
237
|
+
strokeWidth: 2,
|
|
238
|
+
label: marker.label ? {
|
|
239
|
+
value: marker.label,
|
|
240
|
+
fill: marker.color ?? theme.foreground,
|
|
241
|
+
fontSize: 9,
|
|
242
|
+
fontFamily: theme.fontMono,
|
|
243
|
+
position: "top"
|
|
244
|
+
} : void 0
|
|
245
|
+
}, `${marker.x}-${marker.y}`))
|
|
246
|
+
]
|
|
247
|
+
})
|
|
248
|
+
})
|
|
249
|
+
}), legend && !isEmpty && /* @__PURE__ */ jsx(ChartLegend, {
|
|
250
|
+
items: legendItems,
|
|
251
|
+
style: { paddingLeft: yAxisWidth }
|
|
252
|
+
})]
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
256
|
+
export { BarChart };
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
loading?: boolean;
|
|
12
|
+
valueFormatter?: (value: number) => string;
|
|
13
|
+
labelFormatter?: (label: string | number) => string;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
declare function BarList({
|
|
17
|
+
data,
|
|
18
|
+
index,
|
|
19
|
+
dataKey,
|
|
20
|
+
maxItems,
|
|
21
|
+
palette,
|
|
22
|
+
loading,
|
|
23
|
+
valueFormatter,
|
|
24
|
+
labelFormatter,
|
|
25
|
+
className
|
|
26
|
+
}: BarListProps): React$1.JSX.Element;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { BarList, BarListProps };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.mjs";
|
|
3
|
+
import { useReducedMotion } from "../hooks/use-reduced-motion.mjs";
|
|
4
|
+
import { rampColor } from "../lib/chart-palette.mjs";
|
|
5
|
+
import { formatShare } from "../lib/chart.mjs";
|
|
6
|
+
import { useChartContext } from "./chart-container.mjs";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import * as React$1 from "react";
|
|
9
|
+
//#region src/components/bar-list.tsx
|
|
10
|
+
const PLACEHOLDER_HEIGHT = 168;
|
|
11
|
+
const RAMP_CEILING = .8;
|
|
12
|
+
const IN_FILL_SHADOW = "0 1px 2px rgb(0 0 0 / 0.28)";
|
|
13
|
+
function BarList({ data, index, dataKey = "value", maxItems, palette, loading = false, valueFormatter = (value) => value.toLocaleString("en-US"), labelFormatter, className }) {
|
|
14
|
+
const { paletteName } = useChartContext(palette);
|
|
15
|
+
const reducedMotion = useReducedMotion();
|
|
16
|
+
const [mounted, setMounted] = React$1.useState(false);
|
|
17
|
+
const [active, setActive] = React$1.useState(null);
|
|
18
|
+
React$1.useEffect(() => {
|
|
19
|
+
setMounted(true);
|
|
20
|
+
}, []);
|
|
21
|
+
const total = React$1.useMemo(() => data.reduce((sum, row) => sum + (Number(row[dataKey]) || 0), 0), [data, dataKey]);
|
|
22
|
+
const rows = React$1.useMemo(() => {
|
|
23
|
+
const mapped = data.map((row) => ({
|
|
24
|
+
name: String(row[index] ?? ""),
|
|
25
|
+
value: Number(row[dataKey]) || 0
|
|
26
|
+
}));
|
|
27
|
+
mapped.sort((lower, upper) => upper.value - lower.value);
|
|
28
|
+
const capped = maxItems ? mapped.slice(0, maxItems) : mapped;
|
|
29
|
+
return capped.map((row, rank) => ({
|
|
30
|
+
...row,
|
|
31
|
+
color: rampColor(paletteName, (capped.length > 1 ? rank / (capped.length - 1) : 0) * RAMP_CEILING)
|
|
32
|
+
}));
|
|
33
|
+
}, [
|
|
34
|
+
data,
|
|
35
|
+
index,
|
|
36
|
+
dataKey,
|
|
37
|
+
maxItems,
|
|
38
|
+
paletteName
|
|
39
|
+
]);
|
|
40
|
+
const maxValue = rows.reduce((max, row) => row.value > max ? row.value : max, 0);
|
|
41
|
+
const isEmpty = rows.length === 0;
|
|
42
|
+
const formatName = (name) => labelFormatter ? labelFormatter(name) : name;
|
|
43
|
+
if (loading) return /* @__PURE__ */ jsxs("div", {
|
|
44
|
+
className: cn("flex items-center justify-center gap-2.5 font-mono text-quaternary-foreground text-text-xs", className),
|
|
45
|
+
style: { minHeight: PLACEHOLDER_HEIGHT },
|
|
46
|
+
children: [/* @__PURE__ */ jsx("span", { className: "size-4 animate-spin rounded-full border-2 border-border border-t-foreground" }), "loading…"]
|
|
47
|
+
});
|
|
48
|
+
if (isEmpty) return /* @__PURE__ */ jsx("div", {
|
|
49
|
+
className: cn("flex items-center justify-center rounded-lg border border-border border-dashed font-mono text-quaternary-foreground text-text-xs", className),
|
|
50
|
+
style: { minHeight: PLACEHOLDER_HEIGHT },
|
|
51
|
+
children: "no data in range"
|
|
52
|
+
});
|
|
53
|
+
return /* @__PURE__ */ jsx("div", {
|
|
54
|
+
"data-slot": "bar-list",
|
|
55
|
+
className: cn("flex w-full flex-col gap-2", className),
|
|
56
|
+
children: rows.map((row, slot) => {
|
|
57
|
+
const fraction = maxValue > 0 ? row.value / maxValue : 0;
|
|
58
|
+
const fillWidth = !reducedMotion && !mounted ? "0%" : `${fraction * 100}%`;
|
|
59
|
+
const dimmed = active !== null && active !== slot;
|
|
60
|
+
const isActive = active === slot;
|
|
61
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
62
|
+
onMouseEnter: () => setActive(slot),
|
|
63
|
+
onMouseLeave: () => setActive(null),
|
|
64
|
+
className: "flex items-center gap-3",
|
|
65
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
66
|
+
className: "relative h-[30px] flex-1 overflow-hidden rounded-md bg-muted",
|
|
67
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
68
|
+
className: "pointer-events-none absolute inset-x-3 top-1/2 z-0 -translate-y-1/2 truncate type-text-xs font-medium text-foreground",
|
|
69
|
+
children: formatName(row.name)
|
|
70
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
71
|
+
className: "absolute inset-y-0 left-0 z-10 overflow-hidden rounded-md motion-safe:transition-[width,opacity] motion-safe:duration-700 motion-safe:ease-out",
|
|
72
|
+
style: {
|
|
73
|
+
width: fillWidth,
|
|
74
|
+
background: `linear-gradient(90deg, ${row.color}, color-mix(in oklab, ${row.color} 82%, transparent))`,
|
|
75
|
+
boxShadow: `inset 0 0 0 1px ${row.color}`,
|
|
76
|
+
opacity: dimmed ? .45 : 1
|
|
77
|
+
},
|
|
78
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
79
|
+
className: "pointer-events-none absolute top-1/2 -translate-y-1/2 truncate type-text-xs font-medium text-white",
|
|
80
|
+
style: {
|
|
81
|
+
left: 12,
|
|
82
|
+
width: `calc(${100 / Math.max(fraction, 1e-4)}% - 24px)`,
|
|
83
|
+
textShadow: IN_FILL_SHADOW
|
|
84
|
+
},
|
|
85
|
+
children: formatName(row.name)
|
|
86
|
+
})
|
|
87
|
+
})]
|
|
88
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
89
|
+
className: "w-16 shrink-0 text-right font-mono text-text-xs tabular-nums motion-safe:transition-colors",
|
|
90
|
+
style: { color: isActive ? row.color : void 0 },
|
|
91
|
+
children: isActive ? formatShare(total > 0 ? row.value / total : 0) : valueFormatter(row.value)
|
|
92
|
+
})]
|
|
93
|
+
}, row.name);
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
export { BarList };
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import * as React from "react";
|
|
1
|
+
import * as React$1 from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/components/breadcrumb.d.ts
|
|
4
4
|
declare function Breadcrumb({
|
|
5
5
|
className,
|
|
6
6
|
...props
|
|
7
|
-
}: React.ComponentProps<"nav">):
|
|
7
|
+
}: React$1.ComponentProps<"nav">): React$1.JSX.Element;
|
|
8
8
|
declare function BreadcrumbList({
|
|
9
9
|
className,
|
|
10
10
|
...props
|
|
11
|
-
}: React.ComponentProps<"ol">):
|
|
11
|
+
}: React$1.ComponentProps<"ol">): React$1.JSX.Element;
|
|
12
12
|
declare function BreadcrumbItem({
|
|
13
13
|
className,
|
|
14
14
|
...props
|
|
15
|
-
}: React.ComponentProps<"li">):
|
|
15
|
+
}: React$1.ComponentProps<"li">): React$1.JSX.Element;
|
|
16
16
|
declare function BreadcrumbLink({
|
|
17
17
|
asChild,
|
|
18
18
|
className,
|
|
19
19
|
...props
|
|
20
|
-
}: React.ComponentProps<"a"> & {
|
|
20
|
+
}: React$1.ComponentProps<"a"> & {
|
|
21
21
|
asChild?: boolean;
|
|
22
|
-
}):
|
|
22
|
+
}): React$1.JSX.Element;
|
|
23
23
|
declare function BreadcrumbPage({
|
|
24
24
|
className,
|
|
25
25
|
...props
|
|
26
|
-
}: React.ComponentProps<"span">):
|
|
26
|
+
}: React$1.ComponentProps<"span">): React$1.JSX.Element;
|
|
27
27
|
declare function BreadcrumbSeparator({
|
|
28
28
|
children,
|
|
29
29
|
className,
|
|
30
30
|
...props
|
|
31
|
-
}: React.ComponentProps<"li">):
|
|
31
|
+
}: React$1.ComponentProps<"li">): React$1.JSX.Element;
|
|
32
32
|
declare function BreadcrumbChevron({
|
|
33
33
|
className,
|
|
34
34
|
...props
|
|
35
|
-
}: React.ComponentProps<"span">):
|
|
35
|
+
}: React$1.ComponentProps<"span">): React$1.JSX.Element;
|
|
36
36
|
declare function BreadcrumbEllipsis({
|
|
37
37
|
className,
|
|
38
38
|
...props
|
|
39
|
-
}: React.ComponentProps<"span">):
|
|
39
|
+
}: React$1.ComponentProps<"span">): React$1.JSX.Element;
|
|
40
40
|
//#endregion
|
|
41
41
|
export { Breadcrumb, BreadcrumbChevron, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { VariantProps } from "class-variance-authority";
|
|
2
|
-
import * as React from "react";
|
|
2
|
+
import * as React$1 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/components/button.d.ts
|
|
5
5
|
declare const buttonVariants: (props?: ({
|
|
6
6
|
variant?: "destructive" | "secondary" | "primary" | "tertiary" | "link" | "link-muted" | "cta" | null | undefined;
|
|
7
7
|
size?: "default" | "icon" | "icon-rounded" | "pill" | null | undefined;
|
|
8
8
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
9
|
-
interface ButtonProps extends React.ComponentProps<"button">, VariantProps<typeof buttonVariants> {
|
|
9
|
+
interface ButtonProps extends React$1.ComponentProps<"button">, VariantProps<typeof buttonVariants> {
|
|
10
10
|
asChild?: boolean;
|
|
11
11
|
loading?: boolean;
|
|
12
|
-
icon?: React.ReactNode;
|
|
13
|
-
iconTrailing?: React.ReactNode;
|
|
12
|
+
icon?: React$1.ReactNode;
|
|
13
|
+
iconTrailing?: React$1.ReactNode;
|
|
14
14
|
}
|
|
15
15
|
declare function Button({
|
|
16
16
|
className,
|
|
@@ -24,6 +24,6 @@ declare function Button({
|
|
|
24
24
|
disabled,
|
|
25
25
|
children,
|
|
26
26
|
...props
|
|
27
|
-
}: ButtonProps):
|
|
27
|
+
}: ButtonProps): React$1.JSX.Element;
|
|
28
28
|
//#endregion
|
|
29
29
|
export { Button, type ButtonProps, buttonVariants };
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import * as React from "react";
|
|
1
|
+
import * as React$1 from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/components/card.d.ts
|
|
4
4
|
declare function Card({
|
|
5
5
|
className,
|
|
6
6
|
hoverable,
|
|
7
7
|
...props
|
|
8
|
-
}: React.ComponentProps<"div"> & {
|
|
8
|
+
}: React$1.ComponentProps<"div"> & {
|
|
9
9
|
hoverable?: boolean;
|
|
10
|
-
}):
|
|
10
|
+
}): React$1.JSX.Element;
|
|
11
11
|
declare function CardHeader({
|
|
12
12
|
className,
|
|
13
13
|
...props
|
|
14
|
-
}: React.ComponentProps<"div">):
|
|
14
|
+
}: React$1.ComponentProps<"div">): React$1.JSX.Element;
|
|
15
15
|
declare function CardTitle({
|
|
16
16
|
className,
|
|
17
17
|
...props
|
|
18
|
-
}: React.ComponentProps<"div">):
|
|
18
|
+
}: React$1.ComponentProps<"div">): React$1.JSX.Element;
|
|
19
19
|
declare function CardDescription({
|
|
20
20
|
className,
|
|
21
21
|
...props
|
|
22
|
-
}: React.ComponentProps<"div">):
|
|
22
|
+
}: React$1.ComponentProps<"div">): React$1.JSX.Element;
|
|
23
23
|
declare function CardAction({
|
|
24
24
|
className,
|
|
25
25
|
...props
|
|
26
|
-
}: React.ComponentProps<"div">):
|
|
26
|
+
}: React$1.ComponentProps<"div">): React$1.JSX.Element;
|
|
27
27
|
declare function CardContent({
|
|
28
28
|
className,
|
|
29
29
|
...props
|
|
30
|
-
}: React.ComponentProps<"div">):
|
|
30
|
+
}: React$1.ComponentProps<"div">): React$1.JSX.Element;
|
|
31
31
|
declare function CardFooter({
|
|
32
32
|
className,
|
|
33
33
|
...props
|
|
34
|
-
}: React.ComponentProps<"div">):
|
|
34
|
+
}: React$1.ComponentProps<"div">): React$1.JSX.Element;
|
|
35
35
|
//#endregion
|
|
36
36
|
export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ChartPaletteName } from "../lib/chart-palette.mjs";
|
|
2
|
+
import * as React$1 from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/chart-card.d.ts
|
|
5
|
+
interface ChartCardProps extends Omit<React$1.ComponentProps<"section">, "title"> {
|
|
6
|
+
palette?: ChartPaletteName;
|
|
7
|
+
kicker?: React$1.ReactNode;
|
|
8
|
+
title?: React$1.ReactNode;
|
|
9
|
+
description?: React$1.ReactNode;
|
|
10
|
+
action?: React$1.ReactNode;
|
|
11
|
+
accent?: "top" | "left";
|
|
12
|
+
}
|
|
13
|
+
declare function ChartCard({
|
|
14
|
+
palette,
|
|
15
|
+
kicker,
|
|
16
|
+
title,
|
|
17
|
+
description,
|
|
18
|
+
action,
|
|
19
|
+
accent,
|
|
20
|
+
className,
|
|
21
|
+
children,
|
|
22
|
+
...props
|
|
23
|
+
}: ChartCardProps): React$1.JSX.Element;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { ChartCard, ChartCardProps };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.mjs";
|
|
3
|
+
import { CHART_PALETTES } from "../lib/chart-palette.mjs";
|
|
4
|
+
import { ChartContainer } from "./chart-container.mjs";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/chart-card.tsx
|
|
7
|
+
function ChartCard({ palette = "magenta", kicker, title, description, action, accent = "top", className, children, ...props }) {
|
|
8
|
+
const lead = CHART_PALETTES[palette][0];
|
|
9
|
+
const isLeft = accent === "left";
|
|
10
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
11
|
+
"data-slot": "chart-card",
|
|
12
|
+
className: cn("chart-rise relative overflow-hidden rounded-xl border bg-card p-5 text-card-foreground shadow-shadow", isLeft && "pl-6", className),
|
|
13
|
+
...props,
|
|
14
|
+
children: [
|
|
15
|
+
/* @__PURE__ */ jsx("span", {
|
|
16
|
+
"aria-hidden": true,
|
|
17
|
+
className: cn("absolute", isLeft ? "inset-y-0 left-0 w-[3px]" : "inset-x-0 top-0 h-[3px]"),
|
|
18
|
+
style: { background: lead }
|
|
19
|
+
}),
|
|
20
|
+
(kicker || title || action) && /* @__PURE__ */ jsxs("header", {
|
|
21
|
+
className: "mb-4 flex items-start justify-between gap-4",
|
|
22
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
23
|
+
className: "flex flex-col gap-1",
|
|
24
|
+
children: [
|
|
25
|
+
kicker && /* @__PURE__ */ jsx("span", {
|
|
26
|
+
className: "font-mono text-[10px] text-primary uppercase tracking-[0.18em]",
|
|
27
|
+
children: kicker
|
|
28
|
+
}),
|
|
29
|
+
title && /* @__PURE__ */ jsx("h3", {
|
|
30
|
+
className: "type-text-md font-semibold leading-none tracking-tight",
|
|
31
|
+
children: title
|
|
32
|
+
}),
|
|
33
|
+
description && /* @__PURE__ */ jsx("p", {
|
|
34
|
+
className: "type-text-xs text-muted-foreground",
|
|
35
|
+
children: description
|
|
36
|
+
})
|
|
37
|
+
]
|
|
38
|
+
}), action]
|
|
39
|
+
}),
|
|
40
|
+
/* @__PURE__ */ jsx(ChartContainer, {
|
|
41
|
+
palette,
|
|
42
|
+
children
|
|
43
|
+
})
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { ChartCard };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ChartTheme } from "../hooks/use-chart-theme.mjs";
|
|
2
|
+
import { ChartPaletteName } from "../lib/chart-palette.mjs";
|
|
3
|
+
import * as React$1 from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/chart-container.d.ts
|
|
6
|
+
interface ChartContextValue {
|
|
7
|
+
palette: readonly string[];
|
|
8
|
+
paletteName: ChartPaletteName;
|
|
9
|
+
theme: ChartTheme;
|
|
10
|
+
}
|
|
11
|
+
declare function ChartContainer({
|
|
12
|
+
palette,
|
|
13
|
+
className,
|
|
14
|
+
...props
|
|
15
|
+
}: React$1.ComponentProps<"div"> & {
|
|
16
|
+
palette?: ChartPaletteName;
|
|
17
|
+
}): React$1.JSX.Element;
|
|
18
|
+
declare function useChartContext(paletteOverride?: ChartPaletteName): ChartContextValue;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { ChartContainer, type ChartContextValue, useChartContext };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.mjs";
|
|
3
|
+
import { CHART_PALETTES } from "../lib/chart-palette.mjs";
|
|
4
|
+
import { useChartTheme } from "../hooks/use-chart-theme.mjs";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import * as React$1 from "react";
|
|
7
|
+
//#region src/components/chart-container.tsx
|
|
8
|
+
const ChartContext = React$1.createContext(null);
|
|
9
|
+
function ChartContainer({ palette = "magenta", className, ...props }) {
|
|
10
|
+
const theme = useChartTheme();
|
|
11
|
+
const value = React$1.useMemo(() => ({
|
|
12
|
+
palette: CHART_PALETTES[palette],
|
|
13
|
+
paletteName: palette,
|
|
14
|
+
theme
|
|
15
|
+
}), [palette, theme]);
|
|
16
|
+
return /* @__PURE__ */ jsx(ChartContext.Provider, {
|
|
17
|
+
value,
|
|
18
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
19
|
+
"data-slot": "chart-container",
|
|
20
|
+
className: cn("flex flex-col gap-4", className),
|
|
21
|
+
...props
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function useChartContext(paletteOverride) {
|
|
26
|
+
const provided = React$1.useContext(ChartContext);
|
|
27
|
+
const fallbackTheme = useChartTheme();
|
|
28
|
+
if (provided && !paletteOverride) return provided;
|
|
29
|
+
const paletteName = paletteOverride ?? provided?.paletteName ?? "magenta";
|
|
30
|
+
return {
|
|
31
|
+
palette: CHART_PALETTES[paletteName],
|
|
32
|
+
paletteName,
|
|
33
|
+
theme: provided?.theme ?? fallbackTheme
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { ChartContainer, useChartContext };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/components/chart-legend.d.ts
|
|
2
|
+
interface ChartLegendItem {
|
|
3
|
+
name: string;
|
|
4
|
+
color: string;
|
|
5
|
+
dashed?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface ChartLegendProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
items: ChartLegendItem[];
|
|
9
|
+
}
|
|
10
|
+
declare function ChartLegend({
|
|
11
|
+
items,
|
|
12
|
+
className,
|
|
13
|
+
...props
|
|
14
|
+
}: ChartLegendProps): import("react").JSX.Element;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { ChartLegend, ChartLegendItem, ChartLegendProps };
|