@alpic-ai/ui 1.153.0 → 1.154.1
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 +4 -25
- package/dist/components/accordion.d.mts +4 -18
- package/dist/components/alert.d.mts +5 -24
- package/dist/components/area-chart.d.mts +1 -22
- package/dist/components/area-chart.mjs +20 -109
- package/dist/components/attachment-tile.d.mts +1 -8
- package/dist/components/avatar.d.mts +4 -27
- package/dist/components/badge.d.mts +1 -8
- package/dist/components/bar-chart.d.mts +1 -21
- package/dist/components/bar-chart.mjs +10 -68
- package/dist/components/bar-list.d.mts +1 -13
- package/dist/components/breadcrumb.d.mts +8 -35
- package/dist/components/button.d.mts +1 -14
- package/dist/components/card.d.mts +7 -30
- package/dist/components/chart-card.d.mts +1 -12
- package/dist/components/chart-container.d.mts +1 -6
- package/dist/components/chart-legend.d.mts +1 -8
- package/dist/components/chart-primitives.d.mts +69 -0
- package/dist/components/chart-primitives.mjs +134 -0
- package/dist/components/chart-tooltip.d.mts +1 -11
- package/dist/components/checkbox.d.mts +1 -5
- package/dist/components/collapsible.d.mts +3 -10
- package/dist/components/combobox.d.mts +9 -45
- package/dist/components/command.d.mts +8 -32
- package/dist/components/copyable.d.mts +2 -9
- package/dist/components/description-list.d.mts +4 -17
- package/dist/components/dialog.d.mts +10 -42
- package/dist/components/donut-chart.d.mts +1 -16
- package/dist/components/dropdown-menu.d.mts +13 -55
- package/dist/components/field.d.mts +14 -0
- package/dist/components/field.mjs +41 -0
- package/dist/components/form.d.mts +15 -115
- package/dist/components/github-button.d.mts +1 -6
- package/dist/components/heatmap-chart.d.mts +1 -23
- package/dist/components/input-group.d.mts +3 -15
- package/dist/components/input.d.mts +1 -14
- package/dist/components/input.mjs +25 -49
- package/dist/components/label.d.mts +1 -5
- package/dist/components/line-chart.d.mts +1 -21
- package/dist/components/line-chart.mjs +20 -102
- package/dist/components/page-loader.d.mts +1 -3
- package/dist/components/pagination.d.mts +1 -8
- package/dist/components/popover.d.mts +4 -16
- package/dist/components/radio-group.d.mts +2 -9
- package/dist/components/scroll-area.d.mts +2 -11
- package/dist/components/select.d.mts +8 -35
- package/dist/components/separator.d.mts +1 -7
- package/dist/components/sheet.d.mts +9 -35
- package/dist/components/shimmer-text.d.mts +1 -5
- package/dist/components/sidebar.d.mts +22 -113
- package/dist/components/skeleton.d.mts +1 -6
- package/dist/components/sonner.d.mts +1 -8
- package/dist/components/spinner.d.mts +2 -14
- package/dist/components/stat.d.mts +1 -10
- package/dist/components/status-dot.d.mts +1 -7
- package/dist/components/switch.d.mts +1 -5
- package/dist/components/table.d.mts +8 -35
- package/dist/components/tabs.d.mts +7 -36
- package/dist/components/tag.d.mts +3 -20
- package/dist/components/task-progress.d.mts +1 -7
- package/dist/components/textarea.d.mts +1 -11
- package/dist/components/textarea.mjs +17 -41
- package/dist/components/toggle-group.d.mts +2 -15
- package/dist/components/tooltip-icon-button.d.mts +0 -1
- package/dist/components/tooltip.d.mts +4 -17
- package/dist/components/typography.d.mts +4 -17
- package/dist/components/wizard.d.mts +1 -7
- package/dist/hooks/use-copy-to-clipboard.d.mts +1 -3
- package/dist/lib/chart-palette.mjs +39 -21
- package/dist/lib/chart.d.mts +6 -1
- package/dist/lib/cn.d.mts +0 -1
- package/package.json +19 -19
- package/src/components/area-chart.tsx +21 -142
- package/src/components/bar-chart.tsx +12 -81
- package/src/components/chart-primitives.tsx +188 -0
- package/src/components/field.tsx +57 -0
- package/src/components/input.tsx +3 -33
- package/src/components/line-chart.tsx +21 -133
- package/src/components/textarea.tsx +3 -33
- package/src/stories/area-chart.stories.tsx +8 -6
- package/src/stories/bar-chart.stories.tsx +8 -6
- package/src/stories/donut-chart.stories.tsx +8 -6
- package/src/stories/line-chart.stories.tsx +8 -6
- package/src/stories/stat.stories.tsx +8 -6
|
@@ -6,9 +6,6 @@ import {
|
|
|
6
6
|
LabelList,
|
|
7
7
|
Line,
|
|
8
8
|
LineChart as RechartsLineChart,
|
|
9
|
-
ReferenceArea,
|
|
10
|
-
ReferenceDot,
|
|
11
|
-
ReferenceLine,
|
|
12
9
|
ResponsiveContainer,
|
|
13
10
|
Tooltip,
|
|
14
11
|
XAxis,
|
|
@@ -21,6 +18,15 @@ import { cn } from "../lib/cn";
|
|
|
21
18
|
import type { ChartMarker } from "./area-chart";
|
|
22
19
|
import { useChartContext } from "./chart-container";
|
|
23
20
|
import { ChartLegend } from "./chart-legend";
|
|
21
|
+
import {
|
|
22
|
+
computeNumericMax,
|
|
23
|
+
makeActiveDot,
|
|
24
|
+
makeChartAxis,
|
|
25
|
+
makeLastValueLabel,
|
|
26
|
+
makeLegendItems,
|
|
27
|
+
renderMarkers,
|
|
28
|
+
renderReferenceLine,
|
|
29
|
+
} from "./chart-primitives";
|
|
24
30
|
import { ChartTooltipContent } from "./chart-tooltip";
|
|
25
31
|
import { Skeleton } from "./skeleton";
|
|
26
32
|
|
|
@@ -71,89 +77,14 @@ function LineChart({
|
|
|
71
77
|
|
|
72
78
|
const resolved = resolveSeries(series, paletteColors, theme);
|
|
73
79
|
|
|
74
|
-
const numericMax = React.useMemo(() =>
|
|
75
|
-
let max = 0;
|
|
76
|
-
for (const row of data) {
|
|
77
|
-
for (const entry of series) {
|
|
78
|
-
const value = Number(row[entry.key]);
|
|
79
|
-
if (Number.isFinite(value) && value > max) {
|
|
80
|
-
max = value;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return max;
|
|
85
|
-
}, [data, series]);
|
|
80
|
+
const numericMax = React.useMemo(() => computeNumericMax(data, series, false), [data, series]);
|
|
86
81
|
|
|
87
82
|
const curveType = CURVE_TYPE[curve];
|
|
88
83
|
const margin = { top: markers?.length ? 18 : 8, right: lastValueLabel ? 56 : 8, bottom: 2, left: 0 };
|
|
89
84
|
|
|
90
|
-
const axis =
|
|
91
|
-
stroke: theme.border,
|
|
92
|
-
tick: { fill: theme.axisForeground, fontSize: 10, fontFamily: theme.fontMono },
|
|
93
|
-
tickLine: false as const,
|
|
94
|
-
axisLine: { stroke: theme.border, strokeOpacity: 0.6 },
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const legendItems = resolved.map((entry) => ({ name: entry.name, color: entry.color, dashed: entry.dashed }));
|
|
85
|
+
const axis = makeChartAxis(theme);
|
|
98
86
|
|
|
99
|
-
const
|
|
100
|
-
valueFlags
|
|
101
|
-
? (dotProps: { cx?: number; cy?: number; value?: number | string }) => {
|
|
102
|
-
if (dotProps.cx == null || dotProps.cy == null) {
|
|
103
|
-
return <g />;
|
|
104
|
-
}
|
|
105
|
-
return (
|
|
106
|
-
<g>
|
|
107
|
-
<circle
|
|
108
|
-
cx={dotProps.cx}
|
|
109
|
-
cy={dotProps.cy}
|
|
110
|
-
r={3.5}
|
|
111
|
-
fill={entry.color}
|
|
112
|
-
stroke={theme.card}
|
|
113
|
-
strokeWidth={2}
|
|
114
|
-
/>
|
|
115
|
-
<text
|
|
116
|
-
x={dotProps.cx}
|
|
117
|
-
y={dotProps.cy - 8}
|
|
118
|
-
textAnchor="middle"
|
|
119
|
-
fill={entry.color}
|
|
120
|
-
fontFamily={theme.fontMono}
|
|
121
|
-
fontSize={10}
|
|
122
|
-
style={{ fontVariantNumeric: "tabular-nums" }}
|
|
123
|
-
>
|
|
124
|
-
{valueFormatter(Number(dotProps.value ?? 0))}
|
|
125
|
-
</text>
|
|
126
|
-
</g>
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
: { r: 3.5, fill: entry.color, stroke: theme.card, strokeWidth: 2 };
|
|
130
|
-
|
|
131
|
-
const renderLastLabel =
|
|
132
|
-
(color: string) =>
|
|
133
|
-
(props: {
|
|
134
|
-
x?: string | number;
|
|
135
|
-
y?: string | number;
|
|
136
|
-
value?: string | number | boolean | Array<string | number | boolean> | null;
|
|
137
|
-
index?: number;
|
|
138
|
-
}) => {
|
|
139
|
-
if (props.index !== data.length - 1 || props.x == null || props.y == null) {
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
return (
|
|
143
|
-
<text
|
|
144
|
-
x={Number(props.x) + 6}
|
|
145
|
-
y={Number(props.y)}
|
|
146
|
-
dy={3}
|
|
147
|
-
fill={color}
|
|
148
|
-
fontFamily={theme.fontMono}
|
|
149
|
-
fontSize={10}
|
|
150
|
-
textAnchor="start"
|
|
151
|
-
style={{ fontVariantNumeric: "tabular-nums" }}
|
|
152
|
-
>
|
|
153
|
-
{valueFormatter(Number(props.value ?? 0))}
|
|
154
|
-
</text>
|
|
155
|
-
);
|
|
156
|
-
};
|
|
87
|
+
const legendItems = makeLegendItems(resolved);
|
|
157
88
|
|
|
158
89
|
const isEmpty = data.length === 0 || resolved.length === 0;
|
|
159
90
|
|
|
@@ -196,34 +127,7 @@ function LineChart({
|
|
|
196
127
|
cursor={{ stroke: theme.axisForeground, strokeWidth: 1, strokeDasharray: "3 3" }}
|
|
197
128
|
content={<ChartTooltipContent valueFormatter={valueFormatter} labelFormatter={labelFormatter} />}
|
|
198
129
|
/>
|
|
199
|
-
{referenceLine
|
|
200
|
-
<ReferenceArea
|
|
201
|
-
y1={referenceLine.y}
|
|
202
|
-
y2={numericMax}
|
|
203
|
-
fill={theme.warning}
|
|
204
|
-
fillOpacity={0.06}
|
|
205
|
-
ifOverflow="extendDomain"
|
|
206
|
-
/>
|
|
207
|
-
)}
|
|
208
|
-
{referenceLine && (
|
|
209
|
-
<ReferenceLine
|
|
210
|
-
y={referenceLine.y}
|
|
211
|
-
stroke={theme.warning}
|
|
212
|
-
strokeDasharray="4 4"
|
|
213
|
-
strokeOpacity={0.6}
|
|
214
|
-
label={
|
|
215
|
-
referenceLine.label
|
|
216
|
-
? {
|
|
217
|
-
value: referenceLine.label,
|
|
218
|
-
fill: theme.warning,
|
|
219
|
-
fontSize: 9,
|
|
220
|
-
fontFamily: theme.fontMono,
|
|
221
|
-
position: "insideBottomRight",
|
|
222
|
-
}
|
|
223
|
-
: undefined
|
|
224
|
-
}
|
|
225
|
-
/>
|
|
226
|
-
)}
|
|
130
|
+
{renderReferenceLine({ referenceLine, numericMax, theme })}
|
|
227
131
|
|
|
228
132
|
{resolved.map((entry) => (
|
|
229
133
|
<Line
|
|
@@ -235,37 +139,21 @@ function LineChart({
|
|
|
235
139
|
strokeWidth={entry.dashed ? 2 : 1.8}
|
|
236
140
|
strokeDasharray={entry.dashed ? "5 3" : undefined}
|
|
237
141
|
dot={dots ? { r: 2.5, fill: entry.color, strokeWidth: 0 } : false}
|
|
238
|
-
activeDot={
|
|
142
|
+
activeDot={makeActiveDot(entry, { valueFlags, theme, valueFormatter })}
|
|
239
143
|
isAnimationActive={false}
|
|
240
144
|
animationDuration={650}
|
|
241
145
|
animationEasing="ease-out"
|
|
242
146
|
>
|
|
243
|
-
{lastValueLabel &&
|
|
147
|
+
{lastValueLabel && (
|
|
148
|
+
<LabelList
|
|
149
|
+
dataKey={entry.key}
|
|
150
|
+
content={makeLastValueLabel(entry.color, { dataLength: data.length, theme, valueFormatter })}
|
|
151
|
+
/>
|
|
152
|
+
)}
|
|
244
153
|
</Line>
|
|
245
154
|
))}
|
|
246
155
|
|
|
247
|
-
{markers
|
|
248
|
-
<ReferenceDot
|
|
249
|
-
key={`${marker.x}-${marker.y}`}
|
|
250
|
-
x={marker.x}
|
|
251
|
-
y={marker.y}
|
|
252
|
-
r={3.5}
|
|
253
|
-
fill={marker.color ?? theme.foreground}
|
|
254
|
-
stroke={theme.card}
|
|
255
|
-
strokeWidth={2}
|
|
256
|
-
label={
|
|
257
|
-
marker.label
|
|
258
|
-
? {
|
|
259
|
-
value: marker.label,
|
|
260
|
-
fill: marker.color ?? theme.foreground,
|
|
261
|
-
fontSize: 9,
|
|
262
|
-
fontFamily: theme.fontMono,
|
|
263
|
-
position: "top",
|
|
264
|
-
}
|
|
265
|
-
: undefined
|
|
266
|
-
}
|
|
267
|
-
/>
|
|
268
|
-
))}
|
|
156
|
+
{renderMarkers(markers, theme)}
|
|
269
157
|
</RechartsLineChart>
|
|
270
158
|
</ResponsiveContainer>
|
|
271
159
|
)}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { Info } from "lucide-react";
|
|
4
3
|
import * as React from "react";
|
|
5
4
|
|
|
6
5
|
import { cn } from "../lib/cn";
|
|
7
|
-
import {
|
|
8
|
-
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip";
|
|
6
|
+
import { Field } from "./field";
|
|
9
7
|
|
|
10
8
|
interface TextareaProps extends React.ComponentProps<"textarea"> {
|
|
11
9
|
label?: string;
|
|
@@ -43,37 +41,9 @@ function Textarea({ className, id, label, required, hint, error, tooltip, ...pro
|
|
|
43
41
|
);
|
|
44
42
|
|
|
45
43
|
return (
|
|
46
|
-
<
|
|
47
|
-
{label && (
|
|
48
|
-
<div className="flex items-center gap-0.5">
|
|
49
|
-
<Label htmlFor={fieldId} className="type-text-sm font-medium text-muted-foreground">
|
|
50
|
-
{label}
|
|
51
|
-
</Label>
|
|
52
|
-
{required && (
|
|
53
|
-
<span aria-hidden className="type-text-sm font-medium text-required">
|
|
54
|
-
*
|
|
55
|
-
</span>
|
|
56
|
-
)}
|
|
57
|
-
{tooltip && (
|
|
58
|
-
<Tooltip>
|
|
59
|
-
<TooltipTrigger asChild>
|
|
60
|
-
<Info className="size-4 text-muted-foreground" />
|
|
61
|
-
</TooltipTrigger>
|
|
62
|
-
<TooltipContent>{tooltip}</TooltipContent>
|
|
63
|
-
</Tooltip>
|
|
64
|
-
)}
|
|
65
|
-
</div>
|
|
66
|
-
)}
|
|
44
|
+
<Field fieldId={fieldId} label={label} required={required} hint={hint} error={error} tooltip={tooltip}>
|
|
67
45
|
{textarea}
|
|
68
|
-
|
|
69
|
-
<p
|
|
70
|
-
id={fieldId ? `${fieldId}-description` : undefined}
|
|
71
|
-
className={cn("type-text-sm", error ? "text-destructive" : "text-subtle-foreground")}
|
|
72
|
-
>
|
|
73
|
-
{error ?? hint}
|
|
74
|
-
</p>
|
|
75
|
-
)}
|
|
76
|
-
</div>
|
|
46
|
+
</Field>
|
|
77
47
|
);
|
|
78
48
|
}
|
|
79
49
|
|
|
@@ -6,12 +6,14 @@ import { Stat } from "../components/stat";
|
|
|
6
6
|
|
|
7
7
|
export default { title: "Charts/Area Chart" };
|
|
8
8
|
|
|
9
|
-
const mulberry32 = (seed: number) =>
|
|
10
|
-
seed
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const mulberry32 = (seed: number) => {
|
|
10
|
+
let state = seed | 0;
|
|
11
|
+
return () => {
|
|
12
|
+
state = (state + 0x6d2b79f5) | 0;
|
|
13
|
+
let hash = Math.imul(state ^ (state >>> 15), 1 | state);
|
|
14
|
+
hash = (hash + Math.imul(hash ^ (hash >>> 7), 61 | hash)) ^ hash;
|
|
15
|
+
return ((hash ^ (hash >>> 14)) >>> 0) / 4294967296;
|
|
16
|
+
};
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
const CLIENTS = ["ChatGPT", "Claude Code", "Claude", "Anthropic", "Goose", "VS Code"];
|
|
@@ -6,12 +6,14 @@ import { Stat } from "../components/stat";
|
|
|
6
6
|
|
|
7
7
|
export default { title: "Charts/Bar Chart" };
|
|
8
8
|
|
|
9
|
-
const mulberry32 = (seed: number) =>
|
|
10
|
-
seed
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const mulberry32 = (seed: number) => {
|
|
10
|
+
let state = seed | 0;
|
|
11
|
+
return () => {
|
|
12
|
+
state = (state + 0x6d2b79f5) | 0;
|
|
13
|
+
let hash = Math.imul(state ^ (state >>> 15), 1 | state);
|
|
14
|
+
hash = (hash + Math.imul(hash ^ (hash >>> 7), 61 | hash)) ^ hash;
|
|
15
|
+
return ((hash ^ (hash >>> 14)) >>> 0) / 4294967296;
|
|
16
|
+
};
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
const CLIENTS = ["ChatGPT", "Claude Code", "Claude", "Anthropic", "Goose", "VS Code"];
|
|
@@ -6,12 +6,14 @@ import { Stat } from "../components/stat";
|
|
|
6
6
|
|
|
7
7
|
export default { title: "Charts/Donut Chart" };
|
|
8
8
|
|
|
9
|
-
const mulberry32 = (seed: number) =>
|
|
10
|
-
seed
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const mulberry32 = (seed: number) => {
|
|
10
|
+
let state = seed | 0;
|
|
11
|
+
return () => {
|
|
12
|
+
state = (state + 0x6d2b79f5) | 0;
|
|
13
|
+
let hash = Math.imul(state ^ (state >>> 15), 1 | state);
|
|
14
|
+
hash = (hash + Math.imul(hash ^ (hash >>> 7), 61 | hash)) ^ hash;
|
|
15
|
+
return ((hash ^ (hash >>> 14)) >>> 0) / 4294967296;
|
|
16
|
+
};
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
const CLIENTS = ["ChatGPT", "Claude Code", "Claude", "Anthropic", "Goose", "VS Code"];
|
|
@@ -6,12 +6,14 @@ import { Stat } from "../components/stat";
|
|
|
6
6
|
|
|
7
7
|
export default { title: "Charts/Line Chart" };
|
|
8
8
|
|
|
9
|
-
const mulberry32 = (seed: number) =>
|
|
10
|
-
seed
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const mulberry32 = (seed: number) => {
|
|
10
|
+
let state = seed | 0;
|
|
11
|
+
return () => {
|
|
12
|
+
state = (state + 0x6d2b79f5) | 0;
|
|
13
|
+
let hash = Math.imul(state ^ (state >>> 15), 1 | state);
|
|
14
|
+
hash = (hash + Math.imul(hash ^ (hash >>> 7), 61 | hash)) ^ hash;
|
|
15
|
+
return ((hash ^ (hash >>> 14)) >>> 0) / 4294967296;
|
|
16
|
+
};
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
const hourLabel = (index: number, length: number) =>
|
|
@@ -5,12 +5,14 @@ import { Stat } from "../components/stat";
|
|
|
5
5
|
|
|
6
6
|
export default { title: "Charts/Stat" };
|
|
7
7
|
|
|
8
|
-
const mulberry32 = (seed: number) =>
|
|
9
|
-
seed
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const mulberry32 = (seed: number) => {
|
|
9
|
+
let state = seed | 0;
|
|
10
|
+
return () => {
|
|
11
|
+
state = (state + 0x6d2b79f5) | 0;
|
|
12
|
+
let hash = Math.imul(state ^ (state >>> 15), 1 | state);
|
|
13
|
+
hash = (hash + Math.imul(hash ^ (hash >>> 7), 61 | hash)) ^ hash;
|
|
14
|
+
return ((hash ^ (hash >>> 14)) >>> 0) / 4294967296;
|
|
15
|
+
};
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
const spark = (seed: number, length = 24) => {
|