@alpic-ai/ui 0.0.0-staging.gfab86f0 → 0.0.0-staging.gfabea7f
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 +1 -5
- package/dist/components/accordion-card.mjs +1 -5
- package/dist/components/accordion.d.mts +1 -5
- package/dist/components/accordion.mjs +1 -5
- package/dist/components/attachment-tile.d.mts +0 -5
- package/dist/components/bar-chart.d.mts +3 -1
- package/dist/components/bar-chart.mjs +17 -9
- package/dist/components/bar-list.d.mts +4 -1
- package/dist/components/bar-list.mjs +44 -10
- package/dist/components/chart-legend.d.mts +4 -1
- package/dist/components/chart-legend.mjs +21 -7
- package/dist/components/chart-primitives.d.mts +3 -8
- package/dist/components/chart-primitives.mjs +3 -8
- package/dist/components/combobox.d.mts +0 -1
- package/dist/components/combobox.mjs +3 -2
- package/dist/components/form.d.mts +2 -2
- package/dist/components/line-chart.d.mts +3 -1
- package/dist/components/line-chart.mjs +7 -4
- package/dist/components/select-trigger-variants.d.mts +1 -5
- package/dist/components/select-trigger-variants.mjs +1 -5
- package/dist/components/stat.d.mts +9 -3
- package/dist/components/stat.mjs +73 -63
- package/dist/components/table.d.mts +1 -5
- package/dist/components/task-progress.d.mts +1 -4
- package/dist/lib/chart-palette.d.mts +16 -1
- package/dist/lib/chart-palette.mjs +1 -20
- package/dist/lib/chart.d.mts +1 -4
- package/dist/lib/chart.mjs +2 -11
- package/package.json +36 -32
- package/src/components/accordion-card.tsx +1 -5
- package/src/components/accordion.tsx +1 -5
- package/src/components/area-chart.tsx +4 -1
- package/src/components/attachment-tile.tsx +0 -5
- package/src/components/avatar.tsx +0 -2
- package/src/components/bar-chart.tsx +36 -22
- package/src/components/bar-list.tsx +57 -17
- package/src/components/chart-legend.tsx +47 -10
- package/src/components/chart-primitives.tsx +3 -9
- package/src/components/combobox.tsx +28 -37
- package/src/components/dropdown-menu.tsx +0 -12
- package/src/components/form.tsx +2 -4
- package/src/components/heatmap-chart.tsx +4 -10
- package/src/components/input-group.tsx +1 -0
- package/src/components/line-chart.tsx +17 -3
- package/src/components/select-trigger-variants.ts +1 -5
- package/src/components/select.tsx +0 -10
- package/src/components/sidebar.tsx +2 -2
- package/src/components/stat.tsx +84 -45
- package/src/components/table.tsx +1 -5
- package/src/components/tabs.tsx +1 -18
- package/src/components/tag.tsx +0 -6
- package/src/components/task-progress.tsx +2 -14
- package/src/components/wizard.tsx +0 -6
- package/src/hooks/use-chart-theme.ts +2 -0
- package/src/lib/chart-palette.ts +3 -22
- package/src/lib/chart.ts +3 -15
- package/src/stories/area-chart.stories.tsx +2 -0
- package/src/stories/bar-chart.stories.tsx +2 -0
- package/src/stories/button.stories.tsx +1 -15
- package/src/stories/combobox.stories.tsx +0 -12
- package/src/stories/dropdown-menu.stories.tsx +0 -4
- package/src/stories/form.stories.tsx +0 -6
- package/src/stories/heatmap-chart.stories.tsx +0 -1
- package/src/stories/input-group.stories.tsx +0 -4
- package/src/stories/input.stories.tsx +0 -8
- package/src/stories/line-chart.stories.tsx +120 -80
- package/src/stories/sidebar.stories.tsx +1 -4
- package/src/stories/skeleton.stories.tsx +0 -2
- package/src/stories/table.stories.tsx +0 -5
- package/src/stories/tabs.stories.tsx +0 -11
- package/src/stories/toggle-group.stories.tsx +0 -5
- package/src/stories/wizard.stories.tsx +0 -4
|
@@ -9,11 +9,7 @@ declare function AccordionCard({ defaultOpen, open, onOpenChange, disabled, clas
|
|
|
9
9
|
} & Omit<React$1.ComponentProps<typeof AccordionPrimitive.Root>, "type" | "collapsible" | "defaultValue" | "value" | "onValueChange" | "disabled">): React$1.JSX.Element;
|
|
10
10
|
declare function AccordionCardHeader({ className, children, ...props }: React$1.ComponentProps<typeof AccordionPrimitive.Trigger>): React$1.JSX.Element;
|
|
11
11
|
declare function AccordionCardTitle({ className, children, ...props }: React$1.HTMLAttributes<HTMLHeadingElement>): React$1.JSX.Element;
|
|
12
|
-
/**
|
|
13
|
-
* `className` is forwarded to the inner padding wrapper, not the Radix Content root.
|
|
14
|
-
* The root always applies overflow-hidden and the accordion animations.
|
|
15
|
-
* To override overflow or animation behavior, wrap this component in an additional element.
|
|
16
|
-
*/
|
|
12
|
+
/** `className` styles the inner padding wrapper, not the Radix Content root, which keeps overflow-hidden and the accordion animations. */
|
|
17
13
|
declare function AccordionCardContent({ className, children, ...props }: React$1.ComponentProps<typeof AccordionPrimitive.Content>): React$1.JSX.Element;
|
|
18
14
|
//#endregion
|
|
19
15
|
export { AccordionCard, AccordionCardContent, AccordionCardHeader, AccordionCardTitle };
|
|
@@ -41,11 +41,7 @@ function AccordionCardTitle({ className, children, ...props }) {
|
|
|
41
41
|
children
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
/**
|
|
45
|
-
* `className` is forwarded to the inner padding wrapper, not the Radix Content root.
|
|
46
|
-
* The root always applies overflow-hidden and the accordion animations.
|
|
47
|
-
* To override overflow or animation behavior, wrap this component in an additional element.
|
|
48
|
-
*/
|
|
44
|
+
/** `className` styles the inner padding wrapper, not the Radix Content root, which keeps overflow-hidden and the accordion animations. */
|
|
49
45
|
function AccordionCardContent({ className, children, ...props }) {
|
|
50
46
|
return /* @__PURE__ */ jsx(AccordionPrimitive.Content, {
|
|
51
47
|
"data-slot": "accordion-card-content",
|
|
@@ -4,11 +4,7 @@ import * as React$1 from "react";
|
|
|
4
4
|
declare function Accordion({ ...props }: React$1.ComponentProps<typeof AccordionPrimitive.Root>): React$1.JSX.Element;
|
|
5
5
|
declare function AccordionItem({ className, ...props }: React$1.ComponentProps<typeof AccordionPrimitive.Item>): React$1.JSX.Element;
|
|
6
6
|
declare function AccordionTrigger({ className, children, ...props }: React$1.ComponentProps<typeof AccordionPrimitive.Trigger>): React$1.JSX.Element;
|
|
7
|
-
/**
|
|
8
|
-
* `className` is forwarded to the inner padding wrapper, not the Radix Content root.
|
|
9
|
-
* The root always applies overflow-hidden and the accordion animations.
|
|
10
|
-
* To override overflow or animation behavior, wrap this component in an additional element.
|
|
11
|
-
*/
|
|
7
|
+
/** `className` styles the inner padding wrapper, not the Radix Content root, which keeps overflow-hidden and the accordion animations. */
|
|
12
8
|
declare function AccordionContent({ className, children, ...props }: React$1.ComponentProps<typeof AccordionPrimitive.Content>): React$1.JSX.Element;
|
|
13
9
|
//#endregion
|
|
14
10
|
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger };
|
|
@@ -28,11 +28,7 @@ function AccordionTrigger({ className, children, ...props }) {
|
|
|
28
28
|
})
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
/**
|
|
32
|
-
* `className` is forwarded to the inner padding wrapper, not the Radix Content root.
|
|
33
|
-
* The root always applies overflow-hidden and the accordion animations.
|
|
34
|
-
* To override overflow or animation behavior, wrap this component in an additional element.
|
|
35
|
-
*/
|
|
31
|
+
/** `className` styles the inner padding wrapper, not the Radix Content root, which keeps overflow-hidden and the accordion animations. */
|
|
36
32
|
function AccordionContent({ className, children, ...props }) {
|
|
37
33
|
return /* @__PURE__ */ jsx(AccordionPrimitive.Content, {
|
|
38
34
|
"data-slot": "accordion-content",
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
//#region src/components/attachment-tile.d.ts
|
|
2
2
|
interface AttachmentTileProps {
|
|
3
|
-
/** Source URL for the attachment thumbnail */
|
|
4
3
|
src?: string;
|
|
5
|
-
/** Whether the attachment is an image */
|
|
6
4
|
isImage?: boolean;
|
|
7
|
-
/** Accessible label describing the attachment */
|
|
8
5
|
label?: string;
|
|
9
|
-
/** Called when the remove button is clicked */
|
|
10
6
|
onRemove?: () => void;
|
|
11
|
-
/** Called when the tile is clicked (e.g. to open a preview) */
|
|
12
7
|
onClick?: () => void;
|
|
13
8
|
className?: string;
|
|
14
9
|
}
|
|
@@ -13,6 +13,8 @@ interface BarChartProps {
|
|
|
13
13
|
valueLabels?: boolean;
|
|
14
14
|
height?: number;
|
|
15
15
|
yAxisWidth?: number;
|
|
16
|
+
bare?: boolean;
|
|
17
|
+
barCategoryGap?: number | string;
|
|
16
18
|
palette?: ChartPaletteName;
|
|
17
19
|
referenceLine?: {
|
|
18
20
|
y: number;
|
|
@@ -27,6 +29,6 @@ interface BarChartProps {
|
|
|
27
29
|
labelFormatter?: (label: string | number) => string;
|
|
28
30
|
className?: string;
|
|
29
31
|
}
|
|
30
|
-
declare function BarChart({ data, index, series, variant, legend, legendAlign, valueLabels, height, yAxisWidth, palette, referenceLine, markers, texture, partialLastBar, loading, valueFormatter, labelFormatter, className }: BarChartProps): React$1.JSX.Element;
|
|
32
|
+
declare function BarChart({ data, index, series, variant, legend, legendAlign, valueLabels, height, yAxisWidth, bare, barCategoryGap, palette, referenceLine, markers, texture, partialLastBar, loading, valueFormatter, labelFormatter, className }: BarChartProps): React$1.JSX.Element;
|
|
31
33
|
//#endregion
|
|
32
34
|
export { BarChart, BarChartProps };
|
|
@@ -12,7 +12,7 @@ import { Bar, BarChart as BarChart$1, CartesianGrid, Cell, LabelList, Responsive
|
|
|
12
12
|
//#region src/components/bar-chart.tsx
|
|
13
13
|
const BAR_RADIUS = 4;
|
|
14
14
|
const MAX_BAR_SIZE = 48;
|
|
15
|
-
function BarChart({ data, index, series, variant = "stacked", legend = false, legendAlign = "left", valueLabels = false, height = 200, yAxisWidth = 48, palette, referenceLine, markers, texture = false, partialLastBar = false, loading = false, valueFormatter = (value) => value.toLocaleString("en-US"), labelFormatter, className }) {
|
|
15
|
+
function BarChart({ data, index, series, variant = "stacked", legend = false, legendAlign = "left", valueLabels = false, height = 200, yAxisWidth = 48, bare = false, barCategoryGap, palette, referenceLine, markers, texture = false, partialLastBar = false, loading = false, valueFormatter = (value) => value.toLocaleString("en-US"), labelFormatter, className }) {
|
|
16
16
|
const { palette: paletteColors, theme } = useChartContext(palette);
|
|
17
17
|
const reactId = React$1.useId().replace(/:/g, "");
|
|
18
18
|
const resolved = resolveSeries(series, paletteColors, theme);
|
|
@@ -39,7 +39,12 @@ function BarChart({ data, index, series, variant = "stacked", legend = false, le
|
|
|
39
39
|
rendered,
|
|
40
40
|
stacked
|
|
41
41
|
]);
|
|
42
|
-
const margin = {
|
|
42
|
+
const margin = bare ? {
|
|
43
|
+
top: 0,
|
|
44
|
+
right: 0,
|
|
45
|
+
bottom: 0,
|
|
46
|
+
left: 0
|
|
47
|
+
} : {
|
|
43
48
|
top: markers?.length || valueLabels ? 18 : 8,
|
|
44
49
|
right: 8,
|
|
45
50
|
bottom: 2,
|
|
@@ -100,7 +105,7 @@ function BarChart({ data, index, series, variant = "stacked", legend = false, le
|
|
|
100
105
|
data,
|
|
101
106
|
stackOffset: variant === "expand" ? "expand" : "none",
|
|
102
107
|
margin,
|
|
103
|
-
barCategoryGap: stacked ? "20%" : "16%",
|
|
108
|
+
barCategoryGap: barCategoryGap ?? (stacked ? "20%" : "16%"),
|
|
104
109
|
children: [
|
|
105
110
|
/* @__PURE__ */ jsxs("defs", { children: [!stacked && rendered.map((entry, slot) => /* @__PURE__ */ jsxs("linearGradient", {
|
|
106
111
|
id: `bar-${reactId}-${slot}`,
|
|
@@ -138,7 +143,7 @@ function BarChart({ data, index, series, variant = "stacked", legend = false, le
|
|
|
138
143
|
strokeOpacity: .65
|
|
139
144
|
})]
|
|
140
145
|
})] }),
|
|
141
|
-
/* @__PURE__ */ jsx(CartesianGrid, {
|
|
146
|
+
!bare && /* @__PURE__ */ jsx(CartesianGrid, {
|
|
142
147
|
vertical: false,
|
|
143
148
|
stroke: theme.grid,
|
|
144
149
|
strokeDasharray: "2 4"
|
|
@@ -146,17 +151,20 @@ function BarChart({ data, index, series, variant = "stacked", legend = false, le
|
|
|
146
151
|
/* @__PURE__ */ jsx(XAxis, {
|
|
147
152
|
dataKey: index,
|
|
148
153
|
...axis,
|
|
154
|
+
hide: bare,
|
|
155
|
+
height: bare ? 0 : void 0,
|
|
149
156
|
tick: makeXAxisTick(theme),
|
|
150
157
|
interval: "preserveStartEnd",
|
|
151
158
|
minTickGap: 56
|
|
152
159
|
}),
|
|
153
160
|
/* @__PURE__ */ jsx(YAxis, {
|
|
154
161
|
...axis,
|
|
155
|
-
|
|
162
|
+
hide: bare,
|
|
163
|
+
width: bare ? 0 : yAxisWidth,
|
|
156
164
|
domain: referenceLine && variant !== "expand" ? [0, Math.ceil(Math.max(numericMax, referenceLine.y) * 1.15)] : void 0,
|
|
157
165
|
tickFormatter: (value) => variant === "expand" ? `${Math.round(value * 100)}%` : valueFormatter(value)
|
|
158
166
|
}),
|
|
159
|
-
/* @__PURE__ */ jsx(Tooltip, {
|
|
167
|
+
!bare && /* @__PURE__ */ jsx(Tooltip, {
|
|
160
168
|
offset: 12,
|
|
161
169
|
allowEscapeViewBox: {
|
|
162
170
|
x: false,
|
|
@@ -172,7 +180,7 @@ function BarChart({ data, index, series, variant = "stacked", legend = false, le
|
|
|
172
180
|
showTotal: withTotal
|
|
173
181
|
})
|
|
174
182
|
}),
|
|
175
|
-
renderReferenceLine({
|
|
183
|
+
!bare && renderReferenceLine({
|
|
176
184
|
referenceLine,
|
|
177
185
|
numericMax,
|
|
178
186
|
theme
|
|
@@ -215,11 +223,11 @@ function BarChart({ data, index, series, variant = "stacked", legend = false, le
|
|
|
215
223
|
content: renderValueLabel(entry.color)
|
|
216
224
|
})]
|
|
217
225
|
}, entry.key)),
|
|
218
|
-
renderMarkers(markers, theme)
|
|
226
|
+
!bare && renderMarkers(markers, theme)
|
|
219
227
|
]
|
|
220
228
|
})
|
|
221
229
|
})
|
|
222
|
-
}), legend && !isEmpty && /* @__PURE__ */ jsx(ChartLegend, {
|
|
230
|
+
}), legend && !bare && !isEmpty && /* @__PURE__ */ jsx(ChartLegend, {
|
|
223
231
|
items: legendItems,
|
|
224
232
|
align: legendAlign,
|
|
225
233
|
insetLeft: yAxisWidth
|
|
@@ -5,6 +5,9 @@ interface BarListProps {
|
|
|
5
5
|
data: ReadonlyArray<Record<string, string | number | null | undefined>>;
|
|
6
6
|
index: string;
|
|
7
7
|
dataKey?: string;
|
|
8
|
+
secondaryKey?: string;
|
|
9
|
+
secondaryVariantKey?: string;
|
|
10
|
+
titleKey?: string;
|
|
8
11
|
maxItems?: number;
|
|
9
12
|
palette?: ChartPaletteName;
|
|
10
13
|
/** Renders bars in a single semantic hue (e.g. red for errors) rather than the palette ramp. */
|
|
@@ -14,6 +17,6 @@ interface BarListProps {
|
|
|
14
17
|
labelFormatter?: (label: string | number) => string;
|
|
15
18
|
className?: string;
|
|
16
19
|
}
|
|
17
|
-
declare function BarList({ data, index, dataKey, maxItems, palette, semantic, loading, valueFormatter, labelFormatter, className }: BarListProps): React$1.JSX.Element;
|
|
20
|
+
declare function BarList({ data, index, dataKey, secondaryKey, secondaryVariantKey, titleKey, maxItems, palette, semantic, loading, valueFormatter, labelFormatter, className }: BarListProps): React$1.JSX.Element;
|
|
18
21
|
//#endregion
|
|
19
22
|
export { BarList, BarListProps };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../lib/cn.mjs";
|
|
3
3
|
import { rampColor } from "../lib/chart-palette.mjs";
|
|
4
|
-
import { formatShare } from "../lib/chart.mjs";
|
|
5
4
|
import { useChartContext } from "./chart-container.mjs";
|
|
5
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip.mjs";
|
|
6
|
+
import { Badge } from "./badge.mjs";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import * as React$1 from "react";
|
|
8
9
|
//#region src/components/bar-list.tsx
|
|
@@ -11,19 +12,28 @@ const SEMANTIC_KEY = {
|
|
|
11
12
|
warning: "warning",
|
|
12
13
|
success: "success"
|
|
13
14
|
};
|
|
15
|
+
const SECONDARY_BADGE_VARIANT = {
|
|
16
|
+
error: "error",
|
|
17
|
+
warning: "warning",
|
|
18
|
+
success: "success"
|
|
19
|
+
};
|
|
14
20
|
const PLACEHOLDER_HEIGHT = 168;
|
|
15
21
|
const RAMP_CEILING = .8;
|
|
16
22
|
const SEMANTIC_FLOOR = .62;
|
|
17
23
|
const IN_FILL_SHADOW = "0 1px 2px rgb(0 0 0 / 0.28)";
|
|
18
|
-
|
|
24
|
+
const ROW_INTERACTIVE_CLASS = "rounded-md text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card";
|
|
25
|
+
function BarList({ data, index, dataKey = "value", secondaryKey, secondaryVariantKey, titleKey, maxItems, palette, semantic, loading = false, valueFormatter = (value) => value.toLocaleString("en-US"), labelFormatter, className }) {
|
|
19
26
|
const { paletteName, theme } = useChartContext(palette);
|
|
20
27
|
const accent = semantic ? theme[SEMANTIC_KEY[semantic]] : null;
|
|
21
28
|
const [active, setActive] = React$1.useState(null);
|
|
22
|
-
const total = React$1.useMemo(() => data.reduce((sum, row) => sum + (Number(row[dataKey]) || 0), 0), [data, dataKey]);
|
|
23
29
|
const rows = React$1.useMemo(() => {
|
|
30
|
+
const optionalText = (row, key) => key != null && row[key] != null ? String(row[key]) : void 0;
|
|
24
31
|
const mapped = data.map((row) => ({
|
|
25
32
|
name: String(row[index] ?? ""),
|
|
26
|
-
value: Number(row[dataKey]) || 0
|
|
33
|
+
value: Number(row[dataKey]) || 0,
|
|
34
|
+
secondary: optionalText(row, secondaryKey),
|
|
35
|
+
secondaryVariant: SECONDARY_BADGE_VARIANT[optionalText(row, secondaryVariantKey) ?? ""],
|
|
36
|
+
title: optionalText(row, titleKey)
|
|
27
37
|
}));
|
|
28
38
|
mapped.sort((lower, upper) => upper.value - lower.value);
|
|
29
39
|
const capped = maxItems ? mapped.slice(0, maxItems) : mapped;
|
|
@@ -39,11 +49,15 @@ function BarList({ data, index, dataKey = "value", maxItems, palette, semantic,
|
|
|
39
49
|
data,
|
|
40
50
|
index,
|
|
41
51
|
dataKey,
|
|
52
|
+
secondaryKey,
|
|
53
|
+
secondaryVariantKey,
|
|
54
|
+
titleKey,
|
|
42
55
|
maxItems,
|
|
43
56
|
paletteName,
|
|
44
57
|
accent
|
|
45
58
|
]);
|
|
46
59
|
const maxValue = rows.reduce((max, row) => row.value > max ? row.value : max, 0);
|
|
60
|
+
const hasSecondary = rows.some((row) => row.secondary != null);
|
|
47
61
|
const isEmpty = rows.length === 0;
|
|
48
62
|
const formatName = (name) => labelFormatter ? labelFormatter(name) : name;
|
|
49
63
|
if (loading) return /* @__PURE__ */ jsxs("div", {
|
|
@@ -64,10 +78,12 @@ function BarList({ data, index, dataKey = "value", maxItems, palette, semantic,
|
|
|
64
78
|
const fillWidth = `${fraction * 100}%`;
|
|
65
79
|
const dimmed = active !== null && active !== slot;
|
|
66
80
|
const isActive = active === slot;
|
|
67
|
-
|
|
81
|
+
const hasTooltip = row.title != null;
|
|
82
|
+
const bar = /* @__PURE__ */ jsxs(hasTooltip ? "button" : "div", {
|
|
83
|
+
type: hasTooltip ? "button" : void 0,
|
|
68
84
|
onMouseEnter: () => setActive(slot),
|
|
69
85
|
onMouseLeave: () => setActive(null),
|
|
70
|
-
className: "flex items-center gap-3 py-1",
|
|
86
|
+
className: cn("flex items-center gap-3 py-1", hasTooltip && ROW_INTERACTIVE_CLASS),
|
|
71
87
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
72
88
|
className: "relative h-[30px] flex-1 overflow-hidden rounded-md bg-muted",
|
|
73
89
|
children: [/* @__PURE__ */ jsx("span", {
|
|
@@ -91,12 +107,30 @@ function BarList({ data, index, dataKey = "value", maxItems, palette, semantic,
|
|
|
91
107
|
children: formatName(row.name)
|
|
92
108
|
})
|
|
93
109
|
})]
|
|
94
|
-
}), /* @__PURE__ */
|
|
95
|
-
className: "
|
|
96
|
-
|
|
97
|
-
|
|
110
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
111
|
+
className: "flex shrink-0 items-center justify-end gap-2.5 whitespace-nowrap font-mono text-text-xs tabular-nums",
|
|
112
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
113
|
+
className: "min-w-[4rem] text-right motion-safe:transition-colors",
|
|
114
|
+
style: { color: isActive ? row.color : void 0 },
|
|
115
|
+
children: valueFormatter(row.value)
|
|
116
|
+
}), hasSecondary && /* @__PURE__ */ jsx("span", {
|
|
117
|
+
className: "flex min-w-[3.5rem] justify-end",
|
|
118
|
+
children: row.secondary != null && /* @__PURE__ */ jsx(Badge, {
|
|
119
|
+
variant: row.secondaryVariant ?? "secondary",
|
|
120
|
+
size: "sm",
|
|
121
|
+
children: row.secondary
|
|
122
|
+
})
|
|
123
|
+
})]
|
|
98
124
|
})]
|
|
99
125
|
}, row.name);
|
|
126
|
+
if (row.title == null) return bar;
|
|
127
|
+
return /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
128
|
+
asChild: true,
|
|
129
|
+
children: bar
|
|
130
|
+
}), /* @__PURE__ */ jsx(TooltipContent, {
|
|
131
|
+
className: "max-w-md text-pretty text-left",
|
|
132
|
+
children: row.title
|
|
133
|
+
})] }, row.name);
|
|
100
134
|
})
|
|
101
135
|
});
|
|
102
136
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
//#region src/components/chart-legend.d.ts
|
|
2
2
|
interface ChartLegendItem {
|
|
3
|
+
key: string;
|
|
3
4
|
name: string;
|
|
4
5
|
color: string;
|
|
5
6
|
dashed?: boolean;
|
|
@@ -8,7 +9,9 @@ interface ChartLegendProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
8
9
|
items: ChartLegendItem[];
|
|
9
10
|
align?: "left" | "center" | "right";
|
|
10
11
|
insetLeft?: number;
|
|
12
|
+
hiddenKeys?: ReadonlySet<string>;
|
|
13
|
+
onItemClick?: (key: string) => void;
|
|
11
14
|
}
|
|
12
|
-
declare function ChartLegend({ items, align, insetLeft, className, style, ...props }: ChartLegendProps): import("react").JSX.Element;
|
|
15
|
+
declare function ChartLegend({ items, align, insetLeft, hiddenKeys, onItemClick, className, style, ...props }: ChartLegendProps): import("react").JSX.Element;
|
|
13
16
|
//#endregion
|
|
14
17
|
export { ChartLegend, ChartLegendItem, ChartLegendProps };
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../lib/cn.mjs";
|
|
3
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
//#region src/components/chart-legend.tsx
|
|
5
5
|
const ALIGN_CLASS = {
|
|
6
6
|
left: "justify-start",
|
|
7
7
|
center: "justify-center",
|
|
8
8
|
right: "justify-end"
|
|
9
9
|
};
|
|
10
|
+
const ITEM_CLASS = "inline-flex items-center gap-1.5 font-mono text-[10px] text-muted-foreground uppercase tracking-[0.12em]";
|
|
11
|
+
const INTERACTIVE_CLASS = "rounded-sm outline-none transition-opacity focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card [@media(hover:hover)]:hover:text-foreground";
|
|
10
12
|
function Swatch({ color, dashed }) {
|
|
11
13
|
return /* @__PURE__ */ jsx("span", {
|
|
12
14
|
"aria-hidden": true,
|
|
@@ -14,7 +16,7 @@ function Swatch({ color, dashed }) {
|
|
|
14
16
|
style: dashed ? { border: `1.5px solid ${color}` } : { background: color }
|
|
15
17
|
});
|
|
16
18
|
}
|
|
17
|
-
function ChartLegend({ items, align = "left", insetLeft, className, style, ...props }) {
|
|
19
|
+
function ChartLegend({ items, align = "left", insetLeft, hiddenKeys, onItemClick, className, style, ...props }) {
|
|
18
20
|
return /* @__PURE__ */ jsx("div", {
|
|
19
21
|
className: cn("flex flex-wrap gap-x-4 gap-y-1.5", ALIGN_CLASS[align], className),
|
|
20
22
|
style: {
|
|
@@ -22,13 +24,25 @@ function ChartLegend({ items, align = "left", insetLeft, className, style, ...pr
|
|
|
22
24
|
...style
|
|
23
25
|
},
|
|
24
26
|
...props,
|
|
25
|
-
children: items.map((item) =>
|
|
26
|
-
|
|
27
|
-
children: [/* @__PURE__ */ jsx(Swatch, {
|
|
27
|
+
children: items.map((item) => {
|
|
28
|
+
const swatchAndName = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Swatch, {
|
|
28
29
|
color: item.color,
|
|
29
30
|
dashed: item.dashed
|
|
30
|
-
}), item.name]
|
|
31
|
-
|
|
31
|
+
}), item.name] });
|
|
32
|
+
if (!onItemClick) return /* @__PURE__ */ jsx("span", {
|
|
33
|
+
className: ITEM_CLASS,
|
|
34
|
+
children: swatchAndName
|
|
35
|
+
}, item.key);
|
|
36
|
+
const hidden = hiddenKeys?.has(item.key) ?? false;
|
|
37
|
+
return /* @__PURE__ */ jsx("button", {
|
|
38
|
+
type: "button",
|
|
39
|
+
"aria-label": `${item.name} series`,
|
|
40
|
+
"aria-pressed": !hidden,
|
|
41
|
+
onClick: () => onItemClick(item.key),
|
|
42
|
+
className: cn(ITEM_CLASS, INTERACTIVE_CLASS, hidden && "opacity-40"),
|
|
43
|
+
children: swatchAndName
|
|
44
|
+
}, item.key);
|
|
45
|
+
})
|
|
32
46
|
});
|
|
33
47
|
}
|
|
34
48
|
//#endregion
|
|
@@ -22,14 +22,12 @@ declare function makeChartAxis(theme: ChartTheme): {
|
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
declare function makeLegendItems(resolved: ResolvedSeries[]): {
|
|
25
|
+
key: string;
|
|
25
26
|
name: string;
|
|
26
27
|
color: string;
|
|
27
28
|
dashed: boolean | undefined;
|
|
28
29
|
}[];
|
|
29
|
-
/**
|
|
30
|
-
* Stacked series must reach the stack height (sum per x-point), not the tallest
|
|
31
|
-
* single series, or reference bands and explicit Y domains clip a tall stack short.
|
|
32
|
-
*/
|
|
30
|
+
/** Stacked series must reach the stack height (sum per x-point), or reference bands and explicit Y domains clip a tall stack short. */
|
|
33
31
|
declare function computeNumericMax(data: ChartData, series: ChartSeries[], stacked: boolean): number;
|
|
34
32
|
declare function makeActiveDot(entry: ResolvedSeries, { valueFlags, theme, valueFormatter }: {
|
|
35
33
|
valueFlags: boolean;
|
|
@@ -55,10 +53,7 @@ declare function makeLastValueLabel(color: string, { dataLength, theme, valueFor
|
|
|
55
53
|
value?: string | number | boolean | Array<string | number | boolean> | null;
|
|
56
54
|
index?: number;
|
|
57
55
|
}) => import("react").JSX.Element | null;
|
|
58
|
-
/**
|
|
59
|
-
* Returns recharts elements (not a wrapper component) so recharts still detects
|
|
60
|
-
* them as direct children when spread into a chart via `{renderReferenceLine(...)}`.
|
|
61
|
-
*/
|
|
56
|
+
/** Returns recharts elements (not a wrapper component) so recharts still detects them as direct chart children. */
|
|
62
57
|
declare function renderReferenceLine({ referenceLine, numericMax, theme }: {
|
|
63
58
|
referenceLine: ReferenceLineConfig | undefined;
|
|
64
59
|
numericMax: number;
|
|
@@ -19,15 +19,13 @@ function makeChartAxis(theme) {
|
|
|
19
19
|
}
|
|
20
20
|
function makeLegendItems(resolved) {
|
|
21
21
|
return resolved.map((entry) => ({
|
|
22
|
+
key: entry.key,
|
|
22
23
|
name: entry.name,
|
|
23
24
|
color: entry.color,
|
|
24
25
|
dashed: entry.dashed
|
|
25
26
|
}));
|
|
26
27
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Stacked series must reach the stack height (sum per x-point), not the tallest
|
|
29
|
-
* single series, or reference bands and explicit Y domains clip a tall stack short.
|
|
30
|
-
*/
|
|
28
|
+
/** Stacked series must reach the stack height (sum per x-point), or reference bands and explicit Y domains clip a tall stack short. */
|
|
31
29
|
function computeNumericMax(data, series, stacked) {
|
|
32
30
|
let max = 0;
|
|
33
31
|
for (const row of data) {
|
|
@@ -87,10 +85,7 @@ function makeLastValueLabel(color, { dataLength, theme, valueFormatter }) {
|
|
|
87
85
|
});
|
|
88
86
|
};
|
|
89
87
|
}
|
|
90
|
-
/**
|
|
91
|
-
* Returns recharts elements (not a wrapper component) so recharts still detects
|
|
92
|
-
* them as direct children when spread into a chart via `{renderReferenceLine(...)}`.
|
|
93
|
-
*/
|
|
88
|
+
/** Returns recharts elements (not a wrapper component) so recharts still detects them as direct chart children. */
|
|
94
89
|
function renderReferenceLine({ referenceLine, numericMax, theme }) {
|
|
95
90
|
if (!referenceLine) return null;
|
|
96
91
|
return [referenceLine.band ? /* @__PURE__ */ jsx(ReferenceArea, {
|
|
@@ -42,7 +42,6 @@ declare function ComboboxEmpty({ className, ...props }: React.ComponentProps<typ
|
|
|
42
42
|
declare function ComboboxGroup({ className, ...props }: React.ComponentProps<typeof Command.Group>): import("react").JSX.Element;
|
|
43
43
|
declare function ComboboxSeparator({ className, ...props }: React.ComponentProps<typeof Command.Separator>): import("react").JSX.Element;
|
|
44
44
|
interface ComboboxItemProps extends Omit<React.ComponentProps<typeof Command.Item>, "onSelect"> {
|
|
45
|
-
/** The value stored when this item is selected */
|
|
46
45
|
itemValue: string;
|
|
47
46
|
}
|
|
48
47
|
declare function ComboboxItem({ className, children, itemValue, ...props }: ComboboxItemProps): import("react").JSX.Element;
|
|
@@ -102,6 +102,7 @@ function Combobox(props) {
|
|
|
102
102
|
function ComboboxTrigger({ className, size, placeholder, children, ...props }) {
|
|
103
103
|
const { multiple, value, values, open, onDeselect } = useComboboxContext();
|
|
104
104
|
const isEmpty = multiple ? values.length === 0 : value === null || value === void 0;
|
|
105
|
+
const hasCustomMultipleValue = multiple && children !== void 0;
|
|
105
106
|
return /* @__PURE__ */ jsx(PopoverTrigger, {
|
|
106
107
|
asChild: true,
|
|
107
108
|
children: /* @__PURE__ */ jsxs("button", {
|
|
@@ -112,8 +113,8 @@ function ComboboxTrigger({ className, size, placeholder, children, ...props }) {
|
|
|
112
113
|
className: cn(selectTriggerVariants({ size }), className),
|
|
113
114
|
...props,
|
|
114
115
|
children: [/* @__PURE__ */ jsx("span", {
|
|
115
|
-
className: cn("flex flex-1 items-center gap-1.5 text-left", multiple && "flex-wrap", isEmpty && "text-placeholder"),
|
|
116
|
-
children: isEmpty ? placeholder : multiple ? /* @__PURE__ */ jsx(ComboboxTags, {
|
|
116
|
+
className: cn("flex min-w-0 flex-1 items-center gap-1.5 text-left", multiple && !hasCustomMultipleValue && "flex-wrap", isEmpty && !hasCustomMultipleValue && "text-placeholder"),
|
|
117
|
+
children: hasCustomMultipleValue ? children : isEmpty ? placeholder : multiple ? /* @__PURE__ */ jsx(ComboboxTags, {
|
|
117
118
|
values,
|
|
118
119
|
onDeselect
|
|
119
120
|
}) : children
|
|
@@ -5,14 +5,14 @@ import * as React$1 from "react";
|
|
|
5
5
|
import { Slot } from "@radix-ui/react-slot";
|
|
6
6
|
import { ControllerProps, FieldPath, FieldValues } from "react-hook-form";
|
|
7
7
|
//#region src/components/form.d.ts
|
|
8
|
-
declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>({ children, watch, getValues, getFieldState, setError, clearErrors, setValue, setValues, trigger, formState, resetField, reset, handleSubmit, unregister, control, register, setFocus, subscribe }: import("react-hook-form").FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React$1.JSX.Element;
|
|
8
|
+
declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>({ children, watch, getValues, getFieldState, setError, clearErrors, setValue, setValues, trigger, formState, resetField, reset, resetDefaultValues, handleSubmit, unregister, control, register, setFocus, subscribe }: import("react-hook-form").FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React$1.JSX.Element;
|
|
9
9
|
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => React$1.JSX.Element;
|
|
10
10
|
declare const useFormField: () => {
|
|
11
11
|
invalid: boolean;
|
|
12
12
|
isDirty: boolean;
|
|
13
13
|
isTouched: boolean;
|
|
14
14
|
isValidating: boolean;
|
|
15
|
-
error?: import("react-hook-form").FieldError;
|
|
15
|
+
error?: import("react-hook-form").FieldError | undefined;
|
|
16
16
|
id: string;
|
|
17
17
|
name: string;
|
|
18
18
|
formItemId: string;
|
|
@@ -28,10 +28,12 @@ interface LineChartProps {
|
|
|
28
28
|
markers?: ChartMarker[];
|
|
29
29
|
lastValueLabel?: boolean;
|
|
30
30
|
loading?: boolean;
|
|
31
|
+
hiddenSeries?: ReadonlySet<string>;
|
|
32
|
+
onLegendItemClick?: (key: string) => void;
|
|
31
33
|
valueFormatter?: (value: number) => string;
|
|
32
34
|
labelFormatter?: (label: string | number) => string;
|
|
33
35
|
className?: string;
|
|
34
36
|
}
|
|
35
|
-
declare function LineChart({ data, index, series, curve, legend, legendAlign, valueFlags, dots, height, yAxisWidth, palette, referenceLine, markers, lastValueLabel, loading, valueFormatter, labelFormatter, className }: LineChartProps): React$1.JSX.Element;
|
|
37
|
+
declare function LineChart({ data, index, series, curve, legend, legendAlign, valueFlags, dots, height, yAxisWidth, palette, referenceLine, markers, lastValueLabel, loading, hiddenSeries, onLegendItemClick, valueFormatter, labelFormatter, className }: LineChartProps): React$1.JSX.Element;
|
|
36
38
|
//#endregion
|
|
37
39
|
export { LineChart, LineChartProps };
|
|
@@ -15,10 +15,11 @@ const CURVE_TYPE = {
|
|
|
15
15
|
linear: "linear",
|
|
16
16
|
step: "stepAfter"
|
|
17
17
|
};
|
|
18
|
-
function LineChart({ data, index, series, curve = "monotone", legend = false, legendAlign = "left", valueFlags = false, dots = false, height = 200, yAxisWidth = 48, palette, referenceLine, markers, lastValueLabel = false, loading = false, valueFormatter = (value) => value.toLocaleString("en-US"), labelFormatter, className }) {
|
|
18
|
+
function LineChart({ data, index, series, curve = "monotone", legend = false, legendAlign = "left", valueFlags = false, dots = false, height = 200, yAxisWidth = 48, palette, referenceLine, markers, lastValueLabel = false, loading = false, hiddenSeries, onLegendItemClick, valueFormatter = (value) => value.toLocaleString("en-US"), labelFormatter, className }) {
|
|
19
19
|
const { palette: paletteColors, theme } = useChartContext(palette);
|
|
20
20
|
const resolved = resolveSeries(series, paletteColors, theme);
|
|
21
|
-
const
|
|
21
|
+
const visible = resolved.filter((entry) => !hiddenSeries?.has(entry.key));
|
|
22
|
+
const numericMax = React$1.useMemo(() => computeNumericMax(data, visible, false), [data, visible]);
|
|
22
23
|
const curveType = CURVE_TYPE[curve];
|
|
23
24
|
const margin = {
|
|
24
25
|
top: markers?.length ? 18 : 8,
|
|
@@ -88,7 +89,7 @@ function LineChart({ data, index, series, curve = "monotone", legend = false, le
|
|
|
88
89
|
numericMax,
|
|
89
90
|
theme
|
|
90
91
|
}),
|
|
91
|
-
|
|
92
|
+
visible.map((entry) => /* @__PURE__ */ jsx(Line, {
|
|
92
93
|
type: curveType,
|
|
93
94
|
dataKey: entry.key,
|
|
94
95
|
name: entry.name,
|
|
@@ -124,7 +125,9 @@ function LineChart({ data, index, series, curve = "monotone", legend = false, le
|
|
|
124
125
|
}), legend && !isEmpty && /* @__PURE__ */ jsx(ChartLegend, {
|
|
125
126
|
items: legendItems,
|
|
126
127
|
align: legendAlign,
|
|
127
|
-
insetLeft: yAxisWidth
|
|
128
|
+
insetLeft: yAxisWidth,
|
|
129
|
+
hiddenKeys: hiddenSeries,
|
|
130
|
+
onItemClick: onLegendItemClick
|
|
128
131
|
})]
|
|
129
132
|
});
|
|
130
133
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
//#region src/components/select-trigger-variants.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Shared trigger styles for Select and Combobox.
|
|
4
|
-
* Both components use the same visual treatment for their trigger buttons.
|
|
5
|
-
* Edit here to keep them in sync.
|
|
6
|
-
*/
|
|
2
|
+
/** Shared by Select and Combobox so their trigger buttons stay visually in sync. */
|
|
7
3
|
declare const selectTriggerVariants: (props?: ({
|
|
8
4
|
size?: "sm" | "md" | null | undefined;
|
|
9
5
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { cva } from "class-variance-authority";
|
|
2
2
|
//#region src/components/select-trigger-variants.ts
|
|
3
|
-
/**
|
|
4
|
-
* Shared trigger styles for Select and Combobox.
|
|
5
|
-
* Both components use the same visual treatment for their trigger buttons.
|
|
6
|
-
* Edit here to keep them in sync.
|
|
7
|
-
*/
|
|
3
|
+
/** Shared by Select and Combobox so their trigger buttons stay visually in sync. */
|
|
8
4
|
const selectTriggerVariants = cva([
|
|
9
5
|
"flex w-full items-center gap-2 rounded-md border bg-background text-foreground shadow-xs outline-hidden",
|
|
10
6
|
"transition-colors",
|
|
@@ -8,8 +8,9 @@ interface StatDelta {
|
|
|
8
8
|
direction: "up" | "down";
|
|
9
9
|
invert?: boolean;
|
|
10
10
|
label?: React$1.ReactNode;
|
|
11
|
+
indicator?: "arrow" | "sign";
|
|
11
12
|
}
|
|
12
|
-
interface StatProps extends React$1.
|
|
13
|
+
interface StatProps extends Omit<React$1.HTMLAttributes<HTMLElement>, "onClick"> {
|
|
13
14
|
value: React$1.ReactNode;
|
|
14
15
|
unit?: string;
|
|
15
16
|
delta?: StatDelta | null;
|
|
@@ -17,7 +18,12 @@ interface StatProps extends React$1.ComponentProps<"div"> {
|
|
|
17
18
|
value: number;
|
|
18
19
|
}>;
|
|
19
20
|
semantic?: "error" | "warning" | "success";
|
|
21
|
+
compact?: boolean;
|
|
22
|
+
onClick?: () => void;
|
|
20
23
|
}
|
|
21
|
-
declare function Stat({ value, unit, delta, sparkline, semantic, className, ...props }: StatProps): React$1.JSX.Element;
|
|
24
|
+
declare function Stat({ value, unit, delta, sparkline, semantic, compact, className, onClick, ...props }: StatProps): React$1.JSX.Element;
|
|
25
|
+
declare function StatSparkline({ sparkline, semantic, className }: Pick<StatProps, "sparkline" | "semantic"> & {
|
|
26
|
+
className?: string;
|
|
27
|
+
}): React$1.JSX.Element | null;
|
|
22
28
|
//#endregion
|
|
23
|
-
export { Stat, StatDelta, StatProps, statDeltaVariants };
|
|
29
|
+
export { Stat, StatDelta, StatProps, StatSparkline, statDeltaVariants };
|