@schemavaults/ui 0.41.1 → 0.42.2

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.
@@ -148,3 +148,5 @@ export * from "./color-swatch";
148
148
  export type * from "./color-swatch";
149
149
  export * from "./calendar-heatmap";
150
150
  export type * from "./calendar-heatmap";
151
+ export * from "./pie-chart";
152
+ export type * from "./pie-chart";
@@ -73,4 +73,5 @@ export * from "./sparkline";
73
73
  export * from "./aspect-ratio";
74
74
  export * from "./color-swatch";
75
75
  export * from "./calendar-heatmap";
76
+ export * from "./pie-chart";
76
77
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AAGzB,cAAc,aAAa,CAAC;AAG5B,cAAc,SAAS,CAAC;AAGxB,cAAc,WAAW,CAAC;AAG1B,cAAc,SAAS,CAAC;AAGxB,cAAc,mBAAmB,CAAC;AAGlC,cAAc,0BAA0B,CAAC;AAGzC,cAAc,UAAU,CAAC;AAGzB,cAAc,SAAS,CAAC;AAGxB,cAAc,kBAAkB,CAAC;AAGjC,cAAc,aAAa,CAAC;AAG5B,cAAc,kCAAkC,CAAC;AAGjD,cAAc,cAAc,CAAC;AAG7B,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC;AAExB,cAAc,WAAW,CAAC;AAG1B,cAAc,YAAY,CAAC;AAG3B,cAAc,QAAQ,CAAC;AAGvB,cAAc,QAAQ,CAAC;AAGvB,cAAc,aAAa,CAAC;AAG5B,cAAc,iBAAiB,CAAC;AAGhC,cAAc,WAAW,CAAC;AAG1B,cAAc,mBAAmB,CAAC;AAGlC,cAAc,UAAU,CAAC;AAGzB,cAAc,WAAW,CAAC;AAG1B,cAAc,WAAW,CAAC;AAG1B,cAAc,YAAY,CAAC;AAG3B,cAAc,SAAS,CAAC;AAGxB,cAAc,aAAa,CAAC;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;AAGnC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,QAAQ,CAAC;AAGvB,cAAc,QAAQ,CAAC;AAGvB,cAAc,UAAU,CAAC;AAGzB,cAAc,UAAU,CAAC;AAGzB,cAAc,gBAAgB,CAAC;AAG/B,cAAc,qBAAqB,CAAC;AAGpC,cAAc,cAAc,CAAC;AAG7B,cAAc,cAAc,CAAC;AAG7B,cAAc,OAAO,CAAC;AAGtB,cAAc,eAAe,CAAC;AAG9B,cAAc,WAAW,CAAC;AAG1B,cAAc,UAAU,CAAC;AAGzB,cAAc,eAAe,CAAC;AAG9B,cAAc,aAAa,CAAC;AAG5B,cAAc,YAAY,CAAC;AAG3B,cAAc,UAAU,CAAC;AAGzB,cAAc,gBAAgB,CAAC;AAG/B,cAAc,cAAc,CAAC;AAG7B,cAAc,qBAAqB,CAAC;AAGpC,cAAc,WAAW,CAAC;AAG1B,cAAc,UAAU,CAAC;AAGzB,cAAc,QAAQ,CAAC;AAGvB,cAAc,cAAc,CAAC;AAG7B,cAAc,iBAAiB,CAAC;AAGhC,cAAc,aAAa,CAAC;AAG5B,cAAc,gBAAgB,CAAC;AAG/B,cAAc,gBAAgB,CAAC;AAG/B,cAAc,oBAAoB,CAAC;AAGnC,cAAc,aAAa,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { PieChart, pieChartVariants, pieChartSizeIds, pieChartSegmentColorIds, } from "./pie-chart";
2
+ export type * from "./pie-chart";
3
+ export { PieChart as default } from "./pie-chart";
@@ -0,0 +1,3 @@
1
+ export { PieChart, pieChartVariants, pieChartSizeIds, pieChartSegmentColorIds, } from "./pie-chart";
2
+ export { PieChart as default } from "./pie-chart";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ui/pie-chart/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,91 @@
1
+ import { type VariantProps } from "class-variance-authority";
2
+ import type { HTMLAttributes, KeyboardEvent, MouseEvent, ReactElement, ReactNode, Ref } from "react";
3
+ export declare const pieChartSizeIds: ["sm", "md", "lg", "xl"];
4
+ export type PieChartSizeId = (typeof pieChartSizeIds)[number];
5
+ export declare const pieChartSegmentColorIds: ["default", "primary", "positive", "warning", "destructive", "muted"];
6
+ export type PieChartSegmentColorId = (typeof pieChartSegmentColorIds)[number];
7
+ export declare const pieChartVariants: (props?: ({
8
+ size?: "sm" | "lg" | "xl" | "md" | null | undefined;
9
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
10
+ export interface PieChartSegment {
11
+ /** Stable identifier for the segment. Used as React key and click payload. */
12
+ id: string;
13
+ /**
14
+ * Relative size of the segment. Segment angle is `value / sum(values)`.
15
+ * Non-positive values are skipped.
16
+ */
17
+ value: number;
18
+ /** Optional human-readable label exposed via `aria-label` and tooltips. */
19
+ label?: string;
20
+ /** Preset color id from the chart palette. Ignored if `fill` is provided. */
21
+ color?: PieChartSegmentColorId;
22
+ /**
23
+ * Override the fill with a raw CSS color (e.g. `"#ff0080"` or
24
+ * `"hsl(var(--chart-1))"`). Takes precedence over `color`.
25
+ */
26
+ fill?: string;
27
+ /** Extra classes applied to this segment's `<path>`. */
28
+ className?: string;
29
+ /** Fired when this segment is clicked or activated via keyboard. */
30
+ onClick?: (segment: PieChartSegment, event: MouseEvent<SVGPathElement> | KeyboardEvent<SVGPathElement>) => void;
31
+ }
32
+ export interface PieChartProps extends Omit<HTMLAttributes<HTMLDivElement>, "onClick">, VariantProps<typeof pieChartVariants> {
33
+ /** Segments to render, in order (clockwise from 12 o'clock). */
34
+ segments: ReadonlyArray<PieChartSegment>;
35
+ /** Accessible label describing what the chart represents. */
36
+ label: string;
37
+ /**
38
+ * Inner radius as a fraction of the outer radius (0–1). `0` is a solid pie,
39
+ * values like `0.55` produce a donut. Defaults to `0`.
40
+ */
41
+ innerRadius?: number;
42
+ /** Override the rendered diameter in pixels (defaults are size-aware). */
43
+ diameter?: number;
44
+ /**
45
+ * Width of the divider stroke between segments. Defaults to `1`. Set to `0`
46
+ * to remove the divider.
47
+ */
48
+ segmentGap?: number;
49
+ /**
50
+ * Fallback handler invoked for any segment that doesn't have its own
51
+ * `onClick`. Receives the clicked segment.
52
+ */
53
+ onSegmentClick?: (segment: PieChartSegment, event: MouseEvent<SVGPathElement> | KeyboardEvent<SVGPathElement>) => void;
54
+ /** Optional content rendered in the center of the chart (useful for donuts). */
55
+ children?: ReactNode;
56
+ /** Extra classes for the centered content wrapper. */
57
+ centerClassName?: string;
58
+ /**
59
+ * When true, renders each segment's `label` inside the slice. Use
60
+ * `segmentLabelFormatter` to customize the displayed string (e.g. show a
61
+ * percentage instead of the raw label).
62
+ */
63
+ showSegmentLabels?: boolean;
64
+ /**
65
+ * Customize the in-segment label text. Return `null` to skip a segment.
66
+ * Defaults to `segment.label ?? segment.id`.
67
+ */
68
+ segmentLabelFormatter?: (params: {
69
+ segment: PieChartSegment;
70
+ value: number;
71
+ /** Share of the total, in the range 0–1. */
72
+ fraction: number;
73
+ /** Share of the total, in the range 0–100. */
74
+ percentage: number;
75
+ index: number;
76
+ }) => string | null;
77
+ /**
78
+ * Minimum segment sweep (in radians) required to render its label. Smaller
79
+ * segments are skipped to avoid overlap. Defaults to ~11.5° (0.2 rad).
80
+ */
81
+ minSegmentLabelAngle?: number;
82
+ /** Extra classes applied to every segment-label `<text>` element. */
83
+ segmentLabelClassName?: string;
84
+ /** Optional ref forwarded to the wrapper element. */
85
+ ref?: Ref<HTMLDivElement>;
86
+ }
87
+ declare function PieChart({ segments, label, size, innerRadius, diameter, segmentGap, onSegmentClick, children, className, centerClassName, showSegmentLabels, segmentLabelFormatter, minSegmentLabelAngle, segmentLabelClassName, ref, ...props }: PieChartProps): ReactElement;
88
+ declare namespace PieChart {
89
+ var displayName: string;
90
+ }
91
+ export { PieChart };
@@ -0,0 +1,192 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { cva } from "class-variance-authority";
4
+ import { useId } from "react";
5
+ import { cn } from "../../../lib/utils";
6
+ export const pieChartSizeIds = [
7
+ "sm",
8
+ "md",
9
+ "lg",
10
+ "xl",
11
+ ];
12
+ export const pieChartSegmentColorIds = [
13
+ "default",
14
+ "primary",
15
+ "positive",
16
+ "warning",
17
+ "destructive",
18
+ "muted",
19
+ ];
20
+ const SIZE_TO_PIXELS = {
21
+ sm: 96,
22
+ md: 160,
23
+ lg: 224,
24
+ xl: 320,
25
+ };
26
+ const SEGMENT_FILL_CLASSES = {
27
+ default: "fill-schemavaults-brand-blue",
28
+ primary: "fill-primary",
29
+ positive: "fill-emerald-500 dark:fill-emerald-400",
30
+ warning: "fill-warning",
31
+ destructive: "fill-destructive",
32
+ muted: "fill-muted-foreground",
33
+ };
34
+ /**
35
+ * Fallback color rotation when a segment doesn't specify its own color. Index
36
+ * is the segment position in the input array, modulo the palette length.
37
+ */
38
+ const DEFAULT_COLOR_ROTATION = [
39
+ "default",
40
+ "positive",
41
+ "warning",
42
+ "destructive",
43
+ "primary",
44
+ "muted",
45
+ ];
46
+ export const pieChartVariants = cva("relative inline-flex shrink-0 items-center justify-center", {
47
+ variants: {
48
+ size: {
49
+ sm: "h-24 w-24",
50
+ md: "h-40 w-40",
51
+ lg: "h-56 w-56",
52
+ xl: "h-80 w-80",
53
+ },
54
+ },
55
+ defaultVariants: {
56
+ size: "md",
57
+ },
58
+ });
59
+ /** Convert a polar coordinate (angle in radians, measured from 12 o'clock,
60
+ * clockwise) into an SVG cartesian point. */
61
+ function polarToCartesian(cx, cy, radius, angle) {
62
+ // -π/2 rotates so 0 rad sits at the top of the circle.
63
+ const a = angle - Math.PI / 2;
64
+ return [cx + radius * Math.cos(a), cy + radius * Math.sin(a)];
65
+ }
66
+ function buildSegmentPath(cx, cy, outerRadius, innerRadius, startAngle, endAngle) {
67
+ const sweep = endAngle - startAngle;
68
+ const largeArc = sweep > Math.PI ? 1 : 0;
69
+ // Full-circle case: SVG arcs can't span 360°, so render as two half-arcs
70
+ // (or two annular halves for the donut case).
71
+ if (sweep >= Math.PI * 2 - 1e-6) {
72
+ const [oTopX, oTopY] = polarToCartesian(cx, cy, outerRadius, 0);
73
+ const [oBotX, oBotY] = polarToCartesian(cx, cy, outerRadius, Math.PI);
74
+ if (innerRadius <= 0) {
75
+ return [
76
+ `M ${oTopX} ${oTopY}`,
77
+ `A ${outerRadius} ${outerRadius} 0 1 1 ${oBotX} ${oBotY}`,
78
+ `A ${outerRadius} ${outerRadius} 0 1 1 ${oTopX} ${oTopY}`,
79
+ "Z",
80
+ ].join(" ");
81
+ }
82
+ const [iTopX, iTopY] = polarToCartesian(cx, cy, innerRadius, 0);
83
+ const [iBotX, iBotY] = polarToCartesian(cx, cy, innerRadius, Math.PI);
84
+ return [
85
+ `M ${oTopX} ${oTopY}`,
86
+ `A ${outerRadius} ${outerRadius} 0 1 1 ${oBotX} ${oBotY}`,
87
+ `A ${outerRadius} ${outerRadius} 0 1 1 ${oTopX} ${oTopY}`,
88
+ `M ${iTopX} ${iTopY}`,
89
+ `A ${innerRadius} ${innerRadius} 0 1 0 ${iBotX} ${iBotY}`,
90
+ `A ${innerRadius} ${innerRadius} 0 1 0 ${iTopX} ${iTopY}`,
91
+ "Z",
92
+ ].join(" ");
93
+ }
94
+ const [oStartX, oStartY] = polarToCartesian(cx, cy, outerRadius, startAngle);
95
+ const [oEndX, oEndY] = polarToCartesian(cx, cy, outerRadius, endAngle);
96
+ if (innerRadius <= 0) {
97
+ return [
98
+ `M ${cx} ${cy}`,
99
+ `L ${oStartX} ${oStartY}`,
100
+ `A ${outerRadius} ${outerRadius} 0 ${largeArc} 1 ${oEndX} ${oEndY}`,
101
+ "Z",
102
+ ].join(" ");
103
+ }
104
+ const [iStartX, iStartY] = polarToCartesian(cx, cy, innerRadius, endAngle);
105
+ const [iEndX, iEndY] = polarToCartesian(cx, cy, innerRadius, startAngle);
106
+ return [
107
+ `M ${oStartX} ${oStartY}`,
108
+ `A ${outerRadius} ${outerRadius} 0 ${largeArc} 1 ${oEndX} ${oEndY}`,
109
+ `L ${iStartX} ${iStartY}`,
110
+ `A ${innerRadius} ${innerRadius} 0 ${largeArc} 0 ${iEndX} ${iEndY}`,
111
+ "Z",
112
+ ].join(" ");
113
+ }
114
+ function PieChart({ segments, label, size, innerRadius, diameter, segmentGap = 1, onSegmentClick, children, className, centerClassName, showSegmentLabels = false, segmentLabelFormatter, minSegmentLabelAngle = 0.2, segmentLabelClassName, ref, ...props }) {
115
+ const resolvedSize = size ?? "md";
116
+ const pixelSize = diameter ?? SIZE_TO_PIXELS[resolvedSize];
117
+ const cx = pixelSize / 2;
118
+ const cy = pixelSize / 2;
119
+ const outerRadius = pixelSize / 2;
120
+ const innerR = Math.max(0, Math.min(0.95, innerRadius ?? 0) * outerRadius);
121
+ const titleId = useId();
122
+ const validSegments = segments.filter((s) => s.value > 0 && Number.isFinite(s.value));
123
+ const total = validSegments.reduce((acc, s) => acc + s.value, 0);
124
+ const resolved = (() => {
125
+ if (total <= 0)
126
+ return [];
127
+ let angle = 0;
128
+ return validSegments.map((segment, index) => {
129
+ const sweep = (segment.value / total) * Math.PI * 2;
130
+ const startAngle = angle;
131
+ const endAngle = angle + sweep;
132
+ angle = endAngle;
133
+ const presetColor = segment.color ??
134
+ DEFAULT_COLOR_ROTATION[index % DEFAULT_COLOR_ROTATION.length];
135
+ const fillClass = segment.fill
136
+ ? undefined
137
+ : SEGMENT_FILL_CLASSES[presetColor];
138
+ return {
139
+ segment,
140
+ startAngle,
141
+ endAngle,
142
+ fillClass,
143
+ fill: segment.fill,
144
+ };
145
+ });
146
+ })();
147
+ return (_jsxs("div", { ref: ref, role: "img", "aria-labelledby": titleId, "data-slot": "pie-chart", className: cn(pieChartVariants({ size }), className), style: { width: pixelSize, height: pixelSize }, ...props, children: [_jsxs("svg", { width: pixelSize, height: pixelSize, viewBox: `0 0 ${pixelSize} ${pixelSize}`, "aria-hidden": children ? "true" : undefined, className: "h-full w-full overflow-visible", children: [_jsx("title", { id: titleId, children: label }), resolved.length === 0 ? (_jsx("circle", { cx: cx, cy: cy, r: outerRadius, className: "fill-muted/40 dark:fill-muted/30" })) : (resolved.map(({ segment, startAngle, endAngle, fillClass, fill }) => {
148
+ const d = buildSegmentPath(cx, cy, outerRadius, innerR, startAngle, endAngle);
149
+ const handler = segment.onClick ?? onSegmentClick;
150
+ const isInteractive = typeof handler === "function";
151
+ return (_jsx("path", { d: d, fill: fill, stroke: "hsl(var(--background))", strokeWidth: segmentGap, strokeLinejoin: "round", "data-segment-id": segment.id, role: isInteractive ? "button" : undefined, tabIndex: isInteractive ? 0 : undefined, "aria-label": segment.label ?? segment.id, onClick: isInteractive
152
+ ? (event) => {
153
+ handler(segment, event);
154
+ }
155
+ : undefined, onKeyDown: isInteractive
156
+ ? (event) => {
157
+ if (event.key === "Enter" || event.key === " ") {
158
+ event.preventDefault();
159
+ handler(segment, event);
160
+ }
161
+ }
162
+ : undefined, className: cn("transition-opacity", fillClass, isInteractive &&
163
+ "cursor-pointer hover:opacity-80 focus:outline-none focus-visible:opacity-80", segment.className) }, segment.id));
164
+ })), showSegmentLabels && resolved.length > 0 ? (_jsx("g", { "aria-hidden": "true", "data-slot": "pie-chart-segment-labels", className: "pointer-events-none select-none", children: resolved.map(({ segment, startAngle, endAngle }, index) => {
165
+ const sweep = endAngle - startAngle;
166
+ if (sweep < minSegmentLabelAngle)
167
+ return null;
168
+ const value = segment.value;
169
+ const fraction = value / total;
170
+ const percentage = fraction * 100;
171
+ const text = segmentLabelFormatter
172
+ ? segmentLabelFormatter({
173
+ segment,
174
+ value,
175
+ fraction,
176
+ percentage,
177
+ index,
178
+ })
179
+ : (segment.label ?? segment.id);
180
+ if (text === null || text === "")
181
+ return null;
182
+ const midAngle = (startAngle + endAngle) / 2;
183
+ const labelRadius = innerR > 0
184
+ ? (innerR + outerRadius) / 2
185
+ : outerRadius * 0.65;
186
+ const [lx, ly] = polarToCartesian(cx, cy, labelRadius, midAngle);
187
+ return (_jsx("text", { x: lx, y: ly, textAnchor: "middle", dominantBaseline: "central", className: cn("fill-white text-[11px] font-medium [paint-order:stroke] [stroke:rgba(0,0,0,0.35)] [stroke-width:2px]", segmentLabelClassName), children: text }, `${segment.id}-label`));
188
+ }) })) : null] }), children ? (_jsx("div", { className: cn("pointer-events-none absolute inset-0 flex items-center justify-center text-center", centerClassName), children: children })) : null] }));
189
+ }
190
+ PieChart.displayName = "PieChart";
191
+ export { PieChart };
192
+ //# sourceMappingURL=pie-chart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pie-chart.js","sourceRoot":"","sources":["../../../../src/components/ui/pie-chart/pie-chart.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AASlE,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;CACuB,CAAC;AAG9B,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,SAAS;IACT,SAAS;IACT,UAAU;IACV,SAAS;IACT,aAAa;IACb,OAAO;CACoB,CAAC;AAG9B,MAAM,cAAc,GAAmC;IACrD,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,GAAG;IACP,EAAE,EAAE,GAAG;IACP,EAAE,EAAE,GAAG;CACR,CAAC;AAEF,MAAM,oBAAoB,GAA2C;IACnE,OAAO,EAAE,8BAA8B;IACvC,OAAO,EAAE,cAAc;IACvB,QAAQ,EAAE,wCAAwC;IAClD,OAAO,EAAE,cAAc;IACvB,WAAW,EAAE,kBAAkB;IAC/B,KAAK,EAAE,u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AAC,CACV,cACE,SAAS,EAAE,EAAE,CACX,mFAAmF,EACnF,eAAe,CAChB,YAEA,QAAQ,GACL,CACP,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC;AACD,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schemavaults/ui",
3
- "version": "0.41.1",
3
+ "version": "0.42.2",
4
4
  "private": false,
5
5
  "license": "UNLICENSED",
6
6
  "description": "React.js UI components for SchemaVaults frontend applications",