@alpic-ai/ui 0.0.0-staging.gc7bbb68 → 0.0.0-staging.gc7eb024
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/package.json +1 -1
- package/src/components/area-chart.tsx +4 -1
- package/src/components/bar-chart.tsx +5 -1
- package/src/components/combobox.tsx +14 -4
- package/src/components/form.tsx +2 -0
- package/src/components/input-group.tsx +1 -0
- package/src/components/line-chart.tsx +1 -0
- package/src/components/sidebar.tsx +2 -0
- package/src/hooks/use-chart-theme.ts +2 -0
- package/src/stories/area-chart.stories.tsx +2 -0
- package/src/stories/bar-chart.stories.tsx +2 -0
package/package.json
CHANGED
|
@@ -133,7 +133,10 @@ function AreaChart({
|
|
|
133
133
|
) : (
|
|
134
134
|
<ResponsiveContainer width="100%" height="100%" initialDimension={{ width: 0, height }}>
|
|
135
135
|
<RechartsAreaChart
|
|
136
|
-
data={
|
|
136
|
+
data={
|
|
137
|
+
// biome-ignore lint/plugin/no-type-assertion: Recharts expects a string-indexed data shape.
|
|
138
|
+
data as Record<string, string | number>[]
|
|
139
|
+
}
|
|
137
140
|
stackOffset={variant === "expand" ? "expand" : "none"}
|
|
138
141
|
margin={margin}
|
|
139
142
|
>
|
|
@@ -176,7 +176,10 @@ function BarChart({
|
|
|
176
176
|
) : (
|
|
177
177
|
<ResponsiveContainer width="100%" height="100%" initialDimension={{ width: 0, height }}>
|
|
178
178
|
<RechartsBarChart
|
|
179
|
-
data={
|
|
179
|
+
data={
|
|
180
|
+
// biome-ignore lint/plugin/no-type-assertion: Recharts expects a string-indexed data shape.
|
|
181
|
+
data as Record<string, string | number>[]
|
|
182
|
+
}
|
|
180
183
|
stackOffset={variant === "expand" ? "expand" : "none"}
|
|
181
184
|
margin={margin}
|
|
182
185
|
barCategoryGap={barCategoryGap ?? (stacked ? "20%" : "16%")}
|
|
@@ -262,6 +265,7 @@ function BarChart({
|
|
|
262
265
|
data.map((row, rowIndex) => {
|
|
263
266
|
const roundedTop = stacked ? topSlotByRow[rowIndex] === slot : true;
|
|
264
267
|
const isPartial = partialLastBar && rowIndex === data.length - 1;
|
|
268
|
+
// biome-ignore lint/plugin/no-type-assertion: Recharts' Cell radius type does not model its tuple input.
|
|
265
269
|
const cellRadius = (roundedTop
|
|
266
270
|
? [BAR_RADIUS, BAR_RADIUS, 0, 0]
|
|
267
271
|
: [0, 0, 0, 0]) as unknown as number;
|
|
@@ -69,10 +69,12 @@ function Combobox(props: ComboboxProps) {
|
|
|
69
69
|
} = props;
|
|
70
70
|
|
|
71
71
|
const [uncontrolledSingleValue, setUncontrolledSingleValue] = useState<string | null>(
|
|
72
|
+
// biome-ignore lint/plugin/no-type-assertion: discriminated props cannot narrow through the separate multiple flag.
|
|
72
73
|
!multiple ? ((props as ComboboxSingleProps).defaultValue ?? null) : null,
|
|
73
74
|
);
|
|
74
75
|
|
|
75
76
|
const [uncontrolledMultiValue, setUncontrolledMultiValue] = useState<string[]>(
|
|
77
|
+
// biome-ignore lint/plugin/no-type-assertion: discriminated props cannot narrow through the separate multiple flag.
|
|
76
78
|
multiple ? ((props as ComboboxMultipleProps).defaultValue ?? []) : [],
|
|
77
79
|
);
|
|
78
80
|
|
|
@@ -93,13 +95,17 @@ function Combobox(props: ComboboxProps) {
|
|
|
93
95
|
|
|
94
96
|
const singleValue = multiple
|
|
95
97
|
? null
|
|
96
|
-
:
|
|
97
|
-
|
|
98
|
+
: // biome-ignore lint/plugin/no-type-assertion: discriminated props cannot narrow through the separate multiple flag.
|
|
99
|
+
(((props as ComboboxSingleProps).value !== undefined
|
|
100
|
+
? // biome-ignore lint/plugin/no-type-assertion: discriminated props cannot narrow through the separate multiple flag.
|
|
101
|
+
(props as ComboboxSingleProps).value
|
|
98
102
|
: uncontrolledSingleValue) ?? null);
|
|
99
103
|
|
|
100
104
|
const multiValues = multiple
|
|
101
|
-
?
|
|
102
|
-
|
|
105
|
+
? // biome-ignore lint/plugin/no-type-assertion: discriminated props cannot narrow through the separate multiple flag.
|
|
106
|
+
(props as ComboboxMultipleProps).value !== undefined
|
|
107
|
+
? // biome-ignore lint/plugin/no-type-assertion: discriminated props cannot narrow through the separate multiple flag.
|
|
108
|
+
((props as ComboboxMultipleProps).value as string[])
|
|
103
109
|
: uncontrolledMultiValue
|
|
104
110
|
: [];
|
|
105
111
|
|
|
@@ -114,9 +120,13 @@ function Combobox(props: ComboboxProps) {
|
|
|
114
120
|
);
|
|
115
121
|
|
|
116
122
|
// Extract specific callbacks to avoid depending on the entire props object
|
|
123
|
+
// biome-ignore lint/plugin/no-type-assertion: discriminated props cannot narrow through the separate multiple flag.
|
|
117
124
|
const onValueChangeSingle = !multiple ? (props as ComboboxSingleProps).onValueChange : undefined;
|
|
125
|
+
// biome-ignore lint/plugin/no-type-assertion: discriminated props cannot narrow through the separate multiple flag.
|
|
118
126
|
const onValueChangeMulti = multiple ? (props as ComboboxMultipleProps).onValueChange : undefined;
|
|
127
|
+
// biome-ignore lint/plugin/no-type-assertion: discriminated props cannot narrow through the separate multiple flag.
|
|
119
128
|
const isControlledSingle = !multiple && (props as ComboboxSingleProps).value !== undefined;
|
|
129
|
+
// biome-ignore lint/plugin/no-type-assertion: discriminated props cannot narrow through the separate multiple flag.
|
|
120
130
|
const isControlledMulti = multiple && (props as ComboboxMultipleProps).value !== undefined;
|
|
121
131
|
|
|
122
132
|
const onSelect = useCallback(
|
package/src/components/form.tsx
CHANGED
|
@@ -31,6 +31,7 @@ type FormFieldContextValue<
|
|
|
31
31
|
name: TName;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
+
// biome-ignore lint/plugin/no-type-assertion: consumers require a non-null context default before a provider is mounted.
|
|
34
35
|
const FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue);
|
|
35
36
|
|
|
36
37
|
const FormField = <
|
|
@@ -74,6 +75,7 @@ type FormItemContextValue = {
|
|
|
74
75
|
id: string;
|
|
75
76
|
};
|
|
76
77
|
|
|
78
|
+
// biome-ignore lint/plugin/no-type-assertion: consumers require a non-null context default before a provider is mounted.
|
|
77
79
|
const FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);
|
|
78
80
|
|
|
79
81
|
function FormItem({ className, ...props }: React.ComponentProps<"div">) {
|
|
@@ -68,6 +68,7 @@ function InputGroupAddon({
|
|
|
68
68
|
data-align={align}
|
|
69
69
|
className={cn(inputGroupAddonVariants({ align }), className)}
|
|
70
70
|
onClick={(event) => {
|
|
71
|
+
// biome-ignore lint/plugin/no-type-assertion: click targets are DOM elements for this handler.
|
|
71
72
|
if ((event.target as HTMLElement).closest("button")) {
|
|
72
73
|
return;
|
|
73
74
|
}
|
|
@@ -111,6 +111,7 @@ function LineChart({
|
|
|
111
111
|
</div>
|
|
112
112
|
) : (
|
|
113
113
|
<ResponsiveContainer width="100%" height="100%" initialDimension={{ width: 0, height }}>
|
|
114
|
+
{/* biome-ignore lint/plugin/no-type-assertion: Recharts expects a string-indexed data shape. */}
|
|
114
115
|
<RechartsLineChart data={data as Record<string, string | number>[]} margin={margin}>
|
|
115
116
|
<CartesianGrid vertical={false} stroke={theme.grid} strokeDasharray="2 4" />
|
|
116
117
|
<XAxis
|
|
@@ -127,6 +127,7 @@ function SidebarProvider({
|
|
|
127
127
|
<div
|
|
128
128
|
data-slot="sidebar-wrapper"
|
|
129
129
|
style={
|
|
130
|
+
// biome-ignore lint/plugin/no-type-assertion: CSS custom properties are not included in React's style type.
|
|
130
131
|
{
|
|
131
132
|
"--sidebar-width": SIDEBAR_WIDTH,
|
|
132
133
|
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
@@ -195,6 +196,7 @@ function Sidebar({
|
|
|
195
196
|
data-mobile="true"
|
|
196
197
|
className="bg-sidebar-surface text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden"
|
|
197
198
|
style={
|
|
199
|
+
// biome-ignore lint/plugin/no-type-assertion: CSS custom properties are not included in React's style type.
|
|
198
200
|
{
|
|
199
201
|
"--sidebar-width": SIDEBAR_WIDTH_MOBILE,
|
|
200
202
|
} as React.CSSProperties
|
|
@@ -54,8 +54,10 @@ const readTheme = (): ChartTheme => {
|
|
|
54
54
|
const styles = window.getComputedStyle(document.documentElement);
|
|
55
55
|
const entries = Object.entries(TOKEN_MAP).map(([key, token]) => {
|
|
56
56
|
const value = styles.getPropertyValue(token).trim();
|
|
57
|
+
// biome-ignore lint/plugin/no-type-assertion: token keys correspond to the chart theme's required color keys.
|
|
57
58
|
return [key, value || FALLBACK[key as keyof ChartTheme]] as const;
|
|
58
59
|
});
|
|
60
|
+
// biome-ignore lint/plugin/no-type-assertion: Object.fromEntries cannot preserve the statically known chart-theme keys.
|
|
59
61
|
const colors = Object.fromEntries(entries) as unknown as Omit<ChartTheme, "isDark">;
|
|
60
62
|
return { ...colors, isDark: document.documentElement.classList.contains("dark") };
|
|
61
63
|
};
|
|
@@ -82,9 +82,11 @@ const fmtK = (value: number) => (value >= 1000 ? `${(value / 1000).toFixed(value
|
|
|
82
82
|
const ms = (value: number) => `${value}ms`;
|
|
83
83
|
|
|
84
84
|
const sessionsTotal = stacked.reduce(
|
|
85
|
+
// biome-ignore lint/plugin/no-type-assertion: each client key is populated with a numeric sample in this fixture.
|
|
85
86
|
(sum, row) => sum + CLIENTS.reduce((acc, client) => acc + (row[client] as number), 0),
|
|
86
87
|
0,
|
|
87
88
|
);
|
|
89
|
+
// biome-ignore lint/plugin/no-type-assertion: each client key is populated with a numeric sample in this fixture.
|
|
88
90
|
const sessionsSpark = stacked.map((row) => CLIENTS.reduce((acc, client) => acc + (row[client] as number), 0));
|
|
89
91
|
|
|
90
92
|
const latencyPeak = latency.reduce((best, row) => (row.p95 > best.p95 ? row : best));
|
|
@@ -70,9 +70,11 @@ const fmtK = (value: number) => (value >= 1000 ? `${(value / 1000).toFixed(value
|
|
|
70
70
|
const ms = (value: number) => `${value}ms`;
|
|
71
71
|
|
|
72
72
|
const sessionsTotal = stacked.reduce(
|
|
73
|
+
// biome-ignore lint/plugin/no-type-assertion: each client key is populated with a numeric sample in this fixture.
|
|
73
74
|
(sum, row) => sum + CLIENTS.reduce((acc, client) => acc + (row[client] as number), 0),
|
|
74
75
|
0,
|
|
75
76
|
);
|
|
77
|
+
// biome-ignore lint/plugin/no-type-assertion: each client key is populated with a numeric sample in this fixture.
|
|
76
78
|
const sessionsSpark = stacked.map((row) => CLIENTS.reduce((acc, client) => acc + (row[client] as number), 0));
|
|
77
79
|
|
|
78
80
|
const errorsPeak = errors.reduce((best, row) => (row.mcp + row.tool > best.mcp + best.tool ? row : best));
|