@sfperusacdev/sf-ui 0.2.8 → 0.2.9

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.
@@ -10,7 +10,9 @@ export type DonutBreakdownProps = {
10
10
  /** Contenido central grande (ej. el total). Si se omite, se autocalcula como la suma de `segments`. */
11
11
  centerValue?: string | number;
12
12
  centerLabel?: string;
13
+ /** Diámetro máximo; la dona se encoge con su contenedor y el texto del centro escala con ella. */
13
14
  size?: DonutGaugeSize;
15
+ /** Grosor del anillo. Se acota a un quinto del diámetro para que el centro siempre tenga hueco. */
14
16
  strokeWidth?: number;
15
17
  /** Leyenda con nombre, cantidad y porcentaje debajo del donut. Por defecto `true`. */
16
18
  showLegend?: boolean;
@@ -3,6 +3,7 @@ export type DonutGaugeProps = {
3
3
  value: number;
4
4
  label?: string;
5
5
  sublabel?: string;
6
+ /** Diámetro máximo; la dona se encoge con su contenedor y la cifra del centro escala con ella. */
6
7
  size?: DonutGaugeSize;
7
8
  color?: string;
8
9
  thresholds?: {
@@ -11,6 +12,7 @@ export type DonutGaugeProps = {
11
12
  };
12
13
  inverse?: boolean;
13
14
  showValue?: boolean;
15
+ /** Grosor del anillo. Se acota a un quinto del diámetro para que el centro siempre tenga hueco. */
14
16
  strokeWidth?: number;
15
17
  className?: string;
16
18
  };
@@ -0,0 +1,32 @@
1
+ import { CSSProperties } from 'react';
2
+ import { DonutGaugeSize } from './types';
3
+ /** Diámetro de cada tamaño, en px. Es el máximo: la dona se encoge cuando su contenedor es más angosto. */
4
+ export declare const DONUT_SIZE_PX: Record<DonutGaugeSize, number>;
5
+ export declare const DONUT_STROKE_PX: Record<DonutGaugeSize, number>;
6
+ export declare const DONUT_FONT_VALUE_PX: Record<DonutGaugeSize, number>;
7
+ export declare const DONUT_FONT_LABEL_PX: Record<DonutGaugeSize, number>;
8
+ /** Con más de un quinto del diámetro de anillo, el hueco no deja sitio al texto del centro. */
9
+ export declare const DONUT_MAX_STROKE_RATIO = 0.2;
10
+ export type DonutGeometry = {
11
+ dim: number;
12
+ stroke: number;
13
+ radius: number;
14
+ center: number;
15
+ circumference: number;
16
+ /** Diámetro del hueco interior, donde va el texto. */
17
+ hole: number;
18
+ };
19
+ /** Geometría del anillo. El grosor se acota a `DONUT_MAX_STROKE_RATIO` para que siempre quede hueco. */
20
+ export declare const donutGeometry: (size: DonutGaugeSize, strokeWidth?: number) => DonutGeometry;
21
+ /**
22
+ * Tamaño de fuente (px del viewBox) con el que `text` cabe en una línea dentro del hueco: el menor entre el tamaño
23
+ * base del donut y el que deja el ancho del hueco. Así «98.75%» no se monta sobre el anillo en una dona chica.
24
+ */
25
+ export declare const fontThatFits: (basePx: number, hole: number, text: string) => number;
26
+ /** px del viewBox → unidades del contenedor (`cqw`), para que el texto escale con el ancho real de la dona. */
27
+ export declare const toCqw: (px: number, dim: number) => string;
28
+ /**
29
+ * Variables CSS del anillo: diámetro máximo, hueco (inset del centro) y fuentes en `cqw`. Van en el elemento
30
+ * `.sf-donut__ring`, que es el contenedor de consulta (`container-type: inline-size`).
31
+ */
32
+ export declare const donutRingStyle: (g: DonutGeometry, valueText: string, baseValuePx: number, baseLabelPx: number) => CSSProperties;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sfperusacdev/sf-ui",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "SF UI — librería de componentes React (inputs, tablas, hooks) para aplicaciones SF Perú.",
5
5
  "type": "module",
6
6
  "main": "./dist/sf-ui.umd.cjs",