@sesionario/blocks 1.26.1 → 1.28.0

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.
@@ -0,0 +1,247 @@
1
+ import * as React from 'react';
2
+ import { ReactNode, RefObject } from 'react';
3
+ import { Transition } from 'motion/react';
4
+
5
+ /** Subset of `Intl.NumberFormatOptions` supported by NumberFlow */
6
+ interface ChartStatFlowFormat {
7
+ notation?: "standard" | "compact";
8
+ compactDisplay?: "short" | "long";
9
+ minimumFractionDigits?: number;
10
+ maximumFractionDigits?: number;
11
+ minimumIntegerDigits?: number;
12
+ minimumSignificantDigits?: number;
13
+ maximumSignificantDigits?: number;
14
+ style?: "decimal" | "percent" | "currency";
15
+ currency?: string;
16
+ currencyDisplay?: "symbol" | "narrowSymbol" | "code" | "name";
17
+ unit?: string;
18
+ unitDisplay?: "short" | "long" | "narrow";
19
+ }
20
+ declare const defaultChartStatFlowFormat: ChartStatFlowFormat;
21
+ interface ChartStatFlowProps {
22
+ value: number;
23
+ label: string;
24
+ formatOptions?: ChartStatFlowFormat;
25
+ prefix?: string;
26
+ suffix?: string;
27
+ valueClassName?: string;
28
+ labelClassName?: string;
29
+ icon?: ReactNode;
30
+ }
31
+ /**
32
+ * Shared value + label stack using NumberFlow (same layout as pie / ring centers).
33
+ * Parent should provide flex alignment and sizing when needed.
34
+ */
35
+ declare function ChartStatFlow({ value, label, formatOptions, prefix, suffix, valueClassName, labelClassName, icon, }: ChartStatFlowProps): React.JSX.Element;
36
+ declare namespace ChartStatFlow {
37
+ var displayName: string;
38
+ }
39
+
40
+ type GaugeLabelPlacement = "top" | "bottom" | "left" | "right";
41
+ type GaugeLabelAlign = "start" | "center" | "end";
42
+
43
+ type GaugeOrientation = "arc" | "linear";
44
+ interface GaugeProps {
45
+ /** Arc (default) or horizontal linear notch track */
46
+ orientation?: GaugeOrientation;
47
+ /** Fill level 0–100 */
48
+ value: number;
49
+ /** Number of notches */
50
+ totalNotches?: number;
51
+ /** Percentage of the track reserved for gaps between notches */
52
+ spacing?: number;
53
+ notchCornerRadius?: number;
54
+ /** `true` = rectangular notches; `false` = tapered toward center / midline */
55
+ uniformWidth?: boolean;
56
+ startAngle?: number;
57
+ endAngle?: number;
58
+ useGradient?: boolean;
59
+ activeGradient?: readonly [string, string];
60
+ inactiveGradient?: readonly [string, string];
61
+ /** Center statistic — omit to hide the label block */
62
+ centerValue?: number;
63
+ defaultLabel?: string;
64
+ prefix?: string;
65
+ suffix?: string;
66
+ formatOptions?: ChartStatFlowFormat;
67
+ /** Label position for `orientation="linear"`. Arc gauges always overlay center. */
68
+ labelPlacement?: GaugeLabelPlacement;
69
+ /** Cross-axis alignment (start / center / end), same model as chart legend */
70
+ labelAlign?: GaugeLabelAlign;
71
+ inactiveFill?: string;
72
+ activeFill?: string;
73
+ inactiveFillOpacity?: number;
74
+ activeFillOpacity?: number;
75
+ children?: ReactNode;
76
+ className?: string;
77
+ width?: number;
78
+ height?: number;
79
+ minWidth?: number;
80
+ notchLengthPercent?: number;
81
+ /** Linear only — notch width as % of each slot (default 80) */
82
+ notchWidthPercent?: number;
83
+ /** Linear only — bar thickness in px when responsive (default 24) */
84
+ linearHeight?: number;
85
+ enterTransition?: Transition;
86
+ enterStaggerScale?: number;
87
+ /** Studio-only: static paths while scrubbing geometry controls */
88
+ geometryScrubbing?: boolean;
89
+ }
90
+ declare function Gauge({ width: widthProp, height: heightProp, className, minWidth, orientation, linearHeight, ...props }: GaugeProps): React.JSX.Element;
91
+ declare namespace Gauge {
92
+ var displayName: string;
93
+ }
94
+
95
+ declare const ringCssVars: {
96
+ background: string;
97
+ foreground: string;
98
+ foregroundMuted: string;
99
+ label: string;
100
+ ringBackground: string;
101
+ ring1: string;
102
+ ring2: string;
103
+ ring3: string;
104
+ ring4: string;
105
+ ring5: string;
106
+ };
107
+ declare const defaultRingColors: string[];
108
+ interface RingData {
109
+ /** Display label for the ring */
110
+ label: string;
111
+ /** Current value */
112
+ value: number;
113
+ /** Maximum value (determines progress percentage) */
114
+ maxValue: number;
115
+ /** Optional color override - falls back to palette */
116
+ color?: string;
117
+ }
118
+ interface RingHoverContextValue {
119
+ hoveredIndex: number | null;
120
+ setHoveredIndex: (index: number | null) => void;
121
+ }
122
+ interface RingStableContextValue {
123
+ data: RingData[];
124
+ size: number;
125
+ center: number;
126
+ strokeWidth: number;
127
+ ringGap: number;
128
+ baseInnerRadius: number;
129
+ animationKey: number;
130
+ isLoaded: boolean;
131
+ enterTransition?: Transition;
132
+ enterStaggerScale: number;
133
+ containerRef: RefObject<HTMLDivElement | null>;
134
+ totalValue: number;
135
+ getColor: (index: number) => string;
136
+ getRingRadii: (index: number) => {
137
+ innerRadius: number;
138
+ outerRadius: number;
139
+ };
140
+ startAngle: number;
141
+ endAngle: number;
142
+ /**
143
+ * Studio geometry scrub — skip Motion path morphing and use plain SVG paths.
144
+ * @default false
145
+ */
146
+ geometryScrubbing: boolean;
147
+ }
148
+ type RingContextValue = RingStableContextValue & RingHoverContextValue;
149
+ declare function RingProvider({ children, value, }: {
150
+ children: ReactNode;
151
+ value: RingContextValue;
152
+ }): React.JSX.Element;
153
+ declare function useRingStable(): RingStableContextValue;
154
+ declare function useRingHover(): RingHoverContextValue;
155
+ declare function useRing(): RingContextValue;
156
+
157
+ interface RingChartProps {
158
+ /** Data array - each item represents a ring */
159
+ data: RingData[];
160
+ /** Chart size in pixels. If not provided, uses parent container size */
161
+ size?: number;
162
+ /** Stroke width of each ring. Default: 12 */
163
+ strokeWidth?: number;
164
+ /** Gap between rings. Default: 6 */
165
+ ringGap?: number;
166
+ /** Inner radius of the innermost ring. Default: 60 */
167
+ baseInnerRadius?: number;
168
+ /** Animation duration in milliseconds. Default: 1100 */
169
+ animationDuration?: number;
170
+ /** Additional class name for the container */
171
+ className?: string;
172
+ /** Controlled hover state - index of hovered ring */
173
+ hoveredIndex?: number | null;
174
+ /** Callback when hover state changes */
175
+ onHoverChange?: (index: number | null) => void;
176
+ /** Start angle in radians. Default: -PI/2 (top) */
177
+ startAngle?: number;
178
+ /** End angle in radians. Default: 3*PI/2 (full circle) */
179
+ endAngle?: number;
180
+ /** Framer Motion transition for ring enter animation */
181
+ enterTransition?: Transition;
182
+ /** Scales ring stagger delays (1 = default). */
183
+ enterStaggerScale?: number;
184
+ /**
185
+ * High-frequency geometry updates (e.g. studio NumberField scrub).
186
+ * Uses plain SVG paths instead of Motion `d` morphing.
187
+ */
188
+ geometryScrubbing?: boolean;
189
+ /** Child components (Ring, RingCenter, etc.) */
190
+ children: ReactNode;
191
+ }
192
+ declare function RingChart({ data, size: fixedSize, strokeWidth, ringGap, baseInnerRadius, className, hoveredIndex, onHoverChange, startAngle, endAngle, enterTransition, enterStaggerScale, geometryScrubbing, children, }: RingChartProps): React.JSX.Element;
193
+
194
+ type RingLineCap = "round" | "butt";
195
+ interface RingProps {
196
+ index: number;
197
+ color?: string;
198
+ animate?: boolean;
199
+ showGlow?: boolean;
200
+ lineCap?: RingLineCap;
201
+ }
202
+ declare const Ring: React.NamedExoticComponent<RingProps>;
203
+
204
+ interface RingCenterProps {
205
+ /** Label shown below the value. Default: "Total" when not hovering */
206
+ defaultLabel?: string;
207
+ /** Format options for NumberFlow. Default: standard notation */
208
+ formatOptions?: ChartStatFlowFormat;
209
+ /** Custom render function for complete control over center content */
210
+ children?: (props: {
211
+ value: number;
212
+ label: string;
213
+ isHovered: boolean;
214
+ data: {
215
+ label: string;
216
+ value: number;
217
+ maxValue: number;
218
+ color?: string;
219
+ };
220
+ }) => ReactNode;
221
+ /** Additional class name for the container */
222
+ className?: string;
223
+ /** Class name for the value text. Scales with center size via container queries. */
224
+ valueClassName?: string;
225
+ /** Class name for the label text. Scales with center size via container queries. */
226
+ labelClassName?: string;
227
+ /** Prefix to show before the number (e.g., "$") */
228
+ prefix?: string;
229
+ /** Suffix to show after the number (e.g., "%") */
230
+ suffix?: string;
231
+ }
232
+ /**
233
+ * RingCenter displays content in the center of the ring chart.
234
+ *
235
+ * This component renders as pure HTML (not inside SVG foreignObject) to avoid
236
+ * Safari's WebKit bug #23113 where HTML content with CSS transforms/opacity
237
+ * inside foreignObject renders at incorrect positions.
238
+ *
239
+ * The parent RingChart uses CSS Grid stacking to overlay this HTML content
240
+ * on top of the SVG rings.
241
+ */
242
+ declare function RingCenter({ defaultLabel, formatOptions, children, className, valueClassName, labelClassName, prefix, suffix, }: RingCenterProps): React.JSX.Element;
243
+ declare namespace RingCenter {
244
+ var displayName: string;
245
+ }
246
+
247
+ export { ChartStatFlow, type ChartStatFlowFormat, type ChartStatFlowProps, Gauge, type GaugeLabelAlign, type GaugeLabelPlacement, type GaugeOrientation, type GaugeProps, Ring, RingCenter, type RingCenterProps, RingChart, type RingChartProps, type RingContextValue, type RingData, type RingHoverContextValue, type RingLineCap, type RingProps, RingProvider, type RingStableContextValue, defaultChartStatFlowFormat, defaultRingColors, ringCssVars, useRing, useRingHover, useRingStable };