@fabio.caffarello/react-design-system 4.2.0 → 4.4.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.
@@ -3,6 +3,7 @@ export * from "./tokens/spacing";
3
3
  export * from "./tokens/typography";
4
4
  export * from "./tokens/colors/index";
5
5
  export * from "./tokens/breakpoints";
6
+ export * from "./tokens/chart";
6
7
  export { cn } from "./utils";
7
8
  export { getSpacingClass, getSpacing } from "./tokens/spacing";
8
9
  export { getTypographyClasses, getTypography } from "./tokens/typography";
@@ -11,6 +12,7 @@ export { getBreakpoint, getMediaQuery } from "./tokens/breakpoints";
11
12
  export { getAnimationClass, getAnimation, getTransitionClass, } from "./tokens/animations";
12
13
  export { getZIndexClass, getZIndex } from "./tokens/z-index";
13
14
  export { getOpacityClass, getOpacity } from "./tokens/opacity";
15
+ export { getChartColor, getChartColorClass } from "./tokens/chart";
14
16
  export { ThemeProvider, ConfigProvider, ToastProvider, DialogProvider, useTheme, useConfig, useToastContext, useToastContextOptional, useDialogContext, useDialogContextOptional, ToastContext, DialogContext, type ThemeProviderProps, type ThemeContextValue, type ConfigProviderProps, type DesignSystemConfig, type ConfigContextValue, type ToastProviderProps, type DialogProviderProps, type Toast, type ToastContextValue, type ToastVariant, type DialogContextValue, } from "./providers/providers-bundle";
15
17
  export { AppProvider, useApp, type AppProviderProps, type AppProviderConfig, } from "./providers/AppProvider";
16
18
  export * from "./primitives";
@@ -0,0 +1,59 @@
1
+ import type { HTMLAttributes, ReactNode } from "react";
2
+ /**
3
+ * Semantic tone for a {@link DataBadge}. The status/brand members mirror the
4
+ * `Badge` vocabulary (role, not tone) so the soft-wash treatment is shared
5
+ * and already AA-verified; `dataviz` adds a CATEGORICAL member (a
6
+ * reddish-purple wash for "category / analytical" data, the badge-facing
7
+ * counterpart to the chart palette) that is intentionally NOT a status.
8
+ * Map a consumer's tone names onto these roles: `default → neutral`,
9
+ * `destructive → error`, `brand → primary`, `accent → dataviz` (the
10
+ * data-viz purple — RDS `accent` is cyan, so the category tone is `dataviz`).
11
+ */
12
+ export type DataBadgeTone = "neutral" | "success" | "warning" | "error" | "info" | "primary" | "secondary" | "dataviz";
13
+ export type DataBadgeSize = "sm" | "md";
14
+ export interface DataBadgeProps extends HTMLAttributes<HTMLSpanElement> {
15
+ /** Primary datum — the value the badge is about (e.g. "L2", "Aprovada"). */
16
+ label: ReactNode;
17
+ /**
18
+ * Provenance of the datum, rendered as a lesser-emphasis sub-label after
19
+ * the label (e.g. "Câmara", "Portal Transparência"). Omitted when absent.
20
+ */
21
+ source?: ReactNode;
22
+ /** Semantic tone (role-based color). Defaults to `neutral`. */
23
+ tone?: DataBadgeTone;
24
+ /** Optional decorative leading icon (rendered `aria-hidden`). */
25
+ icon?: ReactNode;
26
+ /** Size scale. Defaults to `md`. */
27
+ size?: DataBadgeSize;
28
+ }
29
+ /**
30
+ * DataBadge
31
+ *
32
+ * An inline metadata chip: a primary `label`, an optional lesser-emphasis
33
+ * `source` sub-label (the datum's provenance), a semantic `tone`, and an
34
+ * optional decorative `icon`. Built for transparency/data UIs where a value
35
+ * must travel with where it came from ("L2 · Portal Transparência").
36
+ *
37
+ * Why a separate primitive and not `Badge`: `Badge` is a single-string
38
+ * status label; `DataBadge` carries a value + its source as a structured
39
+ * pair. The `source` is the differentiator — it has no slot in `Badge` /
40
+ * `Chip` / `Info`.
41
+ *
42
+ * Accessibility: the visible text (label, then source) IS the accessible
43
+ * name — the separator and any `icon` are `aria-hidden`. Hierarchy between
44
+ * label and source is conveyed by size + weight, never by dropping the
45
+ * source below its tone's AA-safe text color. The root is a plain inline
46
+ * `<span>` with no live-region role (metadata is static, not announced);
47
+ * pass `role` / `aria-label` via props if a grouping role is wanted.
48
+ *
49
+ * Server-safe: no hooks, no client APIs, no DOM handlers of its own — ships
50
+ * from the `./server` entry.
51
+ *
52
+ * @example
53
+ * ```tsx
54
+ * <DataBadge label="L2" source="Portal Transparência" tone="warning" />
55
+ * <DataBadge label="Aprovada" tone="success" />
56
+ * ```
57
+ */
58
+ declare const DataBadge: import("react").NamedExoticComponent<DataBadgeProps & import("react").RefAttributes<HTMLSpanElement>>;
59
+ export default DataBadge;
@@ -0,0 +1,2 @@
1
+ export { default } from "./DataBadge";
2
+ export type { DataBadgeProps } from "./DataBadge";
@@ -40,3 +40,5 @@ export type { ChipProps, ChipVariant, ChipSize } from "./Chip";
40
40
  export * from "./Avatar";
41
41
  export { Dot } from "./Dot";
42
42
  export type { DotProps, DotVariant, DotSize } from "./Dot";
43
+ export { default as DataBadge } from "./DataBadge";
44
+ export type { DataBadgeProps } from "./DataBadge";
@@ -4,6 +4,8 @@ export { default as Button } from "./primitives/Button/Button";
4
4
  export type { ButtonProps, ButtonSize, ButtonVariant, } from "./primitives/Button/Button";
5
5
  export { default as Chip } from "./primitives/Chip/Chip";
6
6
  export type { ChipProps, ChipSize, ChipVariant } from "./primitives/Chip/Chip";
7
+ export { default as DataBadge } from "./primitives/DataBadge/DataBadge";
8
+ export type { DataBadgeProps, DataBadgeSize, DataBadgeTone, } from "./primitives/DataBadge/DataBadge";
7
9
  export { default as ErrorMessage } from "./primitives/ErrorMessage/ErrorMessage";
8
10
  export type { ErrorMessageProps } from "./primitives/ErrorMessage/ErrorMessage";
9
11
  export { default as Info } from "./primitives/Info/Info";
@@ -7,6 +7,23 @@
7
7
  * Color Palette Visualization
8
8
  */
9
9
  export declare function ColorPalette(): import("react").JSX.Element;
10
+ /**
11
+ * Solid status fills + on-color text.
12
+ *
13
+ * Each swatch is a real `bg-{status}-solid` carrying `text-fg-on-{status}`
14
+ * (white). These are the TEXT-CARRYING status solids — distinct from the
15
+ * decorative `bg-{status}` used by Dot/Progress. White clears WCAG AA for
16
+ * normal text against every fill (ratios annotated).
17
+ */
18
+ export declare function StatusSolidColors(): import("react").JSX.Element;
19
+ /**
20
+ * Data-visualization categorical palette (Okabe-Ito).
21
+ *
22
+ * Eight colorblind-safe categorical colors for chart series. Distinct from
23
+ * the semantic feedback colors — these encode category, not state. Consume
24
+ * via `getChartColor(i)` (0-based, wraps modulo 8, theme-aware).
25
+ */
26
+ export declare function ChartPalette(): import("react").JSX.Element;
10
27
  /**
11
28
  * Spacing Reference Visualization
12
29
  */
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Data-Visualization Categorical Palette (Okabe-Ito)
3
+ *
4
+ * Eight colorblind-safe categorical colors for chart series (parties, vote
5
+ * types, ranges, …). This is a SEPARATE axis from the semantic feedback
6
+ * colors: `success`/`warning`/`error`/`info` encode *state*, never
7
+ * *category* — using `error` for "series 3" is semantically wrong and
8
+ * destroys meaning. A categorical palette answers "which series is this",
9
+ * and it must stay distinguishable under color-vision deficiency.
10
+ *
11
+ * The values are the canonical Okabe & Ito (2008) palette — the reference
12
+ * categorical palette engineered to be distinguishable in deuteranopia,
13
+ * protanopia, and tritanopia — with `black` swapped for a neutral gray so
14
+ * the 8th series survives on a dark canvas. Light values are the canonical
15
+ * tones; the dark theme lifts each toward higher luminance (hue preserved)
16
+ * so every series clears the WCAG 1.4.11 graphical-object 3:1 contrast over
17
+ * `surface-canvas` (slate-950). The CSS source of truth is
18
+ * `src/styles/semantic/colors.css` (light) and `src/styles/themes/dark.css`
19
+ * (dark, both blocks).
20
+ *
21
+ * On-WHITE caveat: orange/sky-blue/yellow/gray are below 3:1 against a white
22
+ * canvas — an intrinsic property of Okabe-Ito's light hues. Fine for FILLS
23
+ * (bars, areas, large marks); for thin strokes (lines, 1px borders) add a
24
+ * stroke/outline or use a darker series first. Colorblind-safety (the point
25
+ * of the palette) is preserved regardless.
26
+ */
27
+ /** Number of distinct colors in the categorical palette. */
28
+ export declare const CHART_PALETTE_SIZE: 8;
29
+ /** 1-based position within the categorical palette. */
30
+ export type ChartColorIndex = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
31
+ export interface ChartColorToken {
32
+ /** 1-based palette position (matches the `--color-chart-N` token). */
33
+ index: ChartColorIndex;
34
+ /** Okabe-Ito hue name — use for legends / documentation. */
35
+ name: string;
36
+ /** Theme-aware CSS reference, e.g. `"var(--color-chart-1)"`. */
37
+ var: string;
38
+ /** Tailwind background class, e.g. `"bg-chart-1"`. */
39
+ bg: string;
40
+ /** Tailwind text class, e.g. `"text-chart-1"`. */
41
+ text: string;
42
+ }
43
+ /**
44
+ * Palette metadata in canonical order. The actual color values live in CSS
45
+ * (theme-aware); these tokens carry the references and human-readable names.
46
+ */
47
+ export declare const CHART_PALETTE_TOKENS: readonly ChartColorToken[];
48
+ /**
49
+ * Resolve a chart series index to a theme-aware color reference.
50
+ *
51
+ * `seriesIndex` is **0-based** (built for `data.map((d, i) => …)`) and wraps
52
+ * modulo {@link CHART_PALETTE_SIZE}, so a 10-series chart cycles back to the
53
+ * first color rather than running out. Negative indices wrap correctly too.
54
+ * The returned `var(--color-chart-N)` resolves per active theme (light/dark),
55
+ * so charts re-tint automatically — pass it straight to a recharts
56
+ * `fill`/`stroke` or an inline `style`.
57
+ *
58
+ * @example
59
+ * ```tsx
60
+ * import { getChartColor } from "@fabio.caffarello/react-design-system";
61
+ *
62
+ * {series.map((s, i) => (
63
+ * <Bar key={s.id} dataKey={s.id} fill={getChartColor(i)} />
64
+ * ))}
65
+ * ```
66
+ *
67
+ * @param seriesIndex - 0-based series position.
68
+ * @returns A `var(--color-chart-N)` reference (theme-aware).
69
+ */
70
+ export declare function getChartColor(seriesIndex: number): string;
71
+ /**
72
+ * Tailwind class variant of {@link getChartColor} for DOM elements (legend
73
+ * dots, swatches) where a class is more convenient than an inline style.
74
+ *
75
+ * @param seriesIndex - 0-based series position (wraps modulo the palette).
76
+ * @param property - `"bg"` (default) or `"text"`.
77
+ * @returns A `bg-chart-N` / `text-chart-N` class string.
78
+ */
79
+ export declare function getChartColorClass(seriesIndex: number, property?: "bg" | "text"): string;
@@ -30,3 +30,6 @@ export { SIDEBAR_TOKENS, getNestedIndentClass } from "./sidebar";
30
30
  export * from "./switch";
31
31
  export { SWITCH_TOKENS, getSwitchClasses } from "./switch";
32
32
  export type { SwitchSizeToken } from "./switch";
33
+ export * from "./chart";
34
+ export { CHART_PALETTE_SIZE, CHART_PALETTE_TOKENS, getChartColor, getChartColorClass, } from "./chart";
35
+ export type { ChartColorIndex, ChartColorToken } from "./chart";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fabio.caffarello/react-design-system",
3
3
  "private": false,
4
- "version": "4.2.0",
4
+ "version": "4.4.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",