@fabio.caffarello/react-design-system 4.5.0 → 4.7.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.
@@ -23,6 +23,53 @@ export interface StatGroupProps extends HTMLAttributes<HTMLDivElement> {
23
23
  * @default 4
24
24
  */
25
25
  cols?: StatGroupCols;
26
+ /**
27
+ * Optional slot for a badge that floats centered over the top border of
28
+ * the container. Use when all metrics in the group share a common
29
+ * provenance mark (e.g. a trust badge, data-source seal, tier label).
30
+ *
31
+ * The slot is intentionally opaque — the consumer supplies any ReactNode
32
+ * and owns the badge's styling and a11y. `StatGroup` provides only the
33
+ * positioning, not the badge shape. This is the same convention as the
34
+ * `kicker` slot in `HeroSection` or the `badge` slot in `PageHeader`.
35
+ *
36
+ * ### Layout
37
+ *
38
+ * When `floatingBadge` is supplied the outer container gains
39
+ * `pt-4` (16 px) top padding, which creates a landing zone for the
40
+ * badge's bottom half while keeping the first stat row clear. The badge
41
+ * itself is absolutely centred at `top-4 left-1/2`, then shifted up by
42
+ * `−50%` of its own height so its centre sits on the inner container's
43
+ * top border. This calibration is accurate for badges up to ~32 px tall
44
+ * (a standard `Badge` or small `Chip`). If a taller badge is needed,
45
+ * pass a `className` that increases the top padding to match.
46
+ *
47
+ * ### Reading order
48
+ *
49
+ * The badge node appears in the DOM **before** the stat cells, so screen
50
+ * readers encounter it first — "Fonte oficial, followed by the metrics" —
51
+ * which is the correct contextual order.
52
+ *
53
+ * @example
54
+ * ```tsx
55
+ * import { CheckCircle2 } from "lucide-react";
56
+ * import { Badge } from "@fabio.caffarello/react-design-system";
57
+ *
58
+ * <StatGroup
59
+ * layout="strip"
60
+ * floatingBadge={
61
+ * <Badge variant="success" size="sm">
62
+ * <CheckCircle2 size={10} aria-hidden="true" />
63
+ * Fonte oficial
64
+ * </Badge>
65
+ * }
66
+ * >
67
+ * <Stat icon={<Users />} value="726" label="Parlam." align="center" />
68
+ * <Stat icon={<FileText />} value="28,1 mil" label="Proposições" align="center" />
69
+ * </StatGroup>
70
+ * ```
71
+ */
72
+ floatingBadge?: ReactNode;
26
73
  children: ReactNode;
27
74
  }
28
75
  /**
@@ -31,17 +78,18 @@ export interface StatGroupProps extends HTMLAttributes<HTMLDivElement> {
31
78
  *
32
79
  * ### Divider technique
33
80
  *
34
- * The container has `bg-line-default` and `gap-px` (1 px); each child
35
- * `Stat` carries its own `bg-surface-base`. The 1 px of gap exposes the
36
- * container's background as the divider line, while each cell masks its
37
- * own area with `bg-surface-base`. Works identically for the strip
38
- * layout (vertical dividers) and the grid layout (vertical AND
39
- * horizontal dividers, automatically, as the grid reflows). No separate
40
- * `Divider` component, no per-cell border logic.
81
+ * The inner container has `bg-line-default` and `gap-px` (1 px); each
82
+ * child `Stat` carries its own `bg-surface-base`. The 1 px of gap exposes
83
+ * the container's background as the divider line, while each cell masks
84
+ * its own area with `bg-surface-base`. Works identically for the strip
85
+ * layout (vertical dividers) and the grid layout (vertical AND horizontal
86
+ * dividers, automatically, as the grid reflows). No separate `Divider`
87
+ * component, no per-cell border logic.
41
88
  *
42
- * The outer ring is `border border-line-default` matching the gap color,
43
- * with `rounded-lg` and `overflow-hidden` clipping the inner cells to
44
- * the radius.
89
+ * The inner ring is `border border-line-default` matching the gap color,
90
+ * with `rounded-lg` and `overflow-hidden` clipping the inner cells to the
91
+ * radius. The outer wrapper is `relative` so the optional `floatingBadge`
92
+ * can be absolutely positioned over the inner container's top border.
45
93
  *
46
94
  * ### Server-safe
47
95
  *
@@ -65,5 +113,5 @@ export interface StatGroupProps extends HTMLAttributes<HTMLDivElement> {
65
113
  * </StatGroup>
66
114
  * ```
67
115
  */
68
- export declare function StatGroup({ layout, cols, className, children, ...props }: StatGroupProps): import("react").JSX.Element;
116
+ export declare function StatGroup({ layout, cols, floatingBadge, className, children, ...props }: StatGroupProps): import("react").JSX.Element;
69
117
  export default StatGroup;
@@ -1,5 +1,5 @@
1
1
  import { type HTMLAttributes, type ReactNode } from "react";
2
- export type AvatarSize = "xs" | "sm" | "md" | "lg" | "xl";
2
+ export type AvatarSize = "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl";
3
3
  export interface AvatarProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
4
4
  src?: string;
5
5
  alt?: string;
@@ -7,13 +7,42 @@ export interface AvatarProps extends Omit<HTMLAttributes<HTMLDivElement>, "child
7
7
  size?: AvatarSize;
8
8
  variant?: "circle" | "square" | "rounded";
9
9
  "aria-label"?: string;
10
+ /**
11
+ * Controls the browser's native lazy-loading behaviour for the avatar
12
+ * `<img>`. Set to `"lazy"` to defer loading until the avatar is near the
13
+ * viewport — strongly recommended for listings with many off-screen
14
+ * profile images (e.g. a 24-card parliament listing).
15
+ *
16
+ * Maps directly to the native `<img loading>` attribute and has no effect
17
+ * when `src` is absent (no `<img>` is rendered).
18
+ *
19
+ * @default 'eager'
20
+ */
21
+ loading?: "lazy" | "eager";
10
22
  }
11
23
  /**
12
24
  * Avatar Component
13
25
  *
14
- * A versatile avatar component for displaying user profile images or initials.
15
- * Supports fallback display when image fails to load or is not provided.
16
- * Fully accessible with ARIA attributes.
26
+ * A versatile avatar component for displaying user profile images or
27
+ * initials. Supports fallback display when image fails to load or is not
28
+ * provided. Fully accessible with ARIA attributes.
29
+ *
30
+ * ### Size scale
31
+ *
32
+ * | size | px | Use case |
33
+ * |------|-----|---------------------------------|
34
+ * | xs | 24 | Tight inline / notification dot |
35
+ * | sm | 32 | Comment thread, compact row |
36
+ * | md | 40 | Default — card header, form row |
37
+ * | lg | 48 | Expanded card, sidebar profile |
38
+ * | xl | 64 | Detail-page section header |
39
+ * | 2xl | 96 | Hero profile (PerfilHeader) |
40
+ * | 3xl | 112 | Full-bleed hero cover |
41
+ *
42
+ * ### Lazy loading
43
+ *
44
+ * Pass `loading="lazy"` on listings to defer off-screen image loads. The
45
+ * default is `"eager"` (matches browser default) for backward compatibility.
17
46
  *
18
47
  * @example
19
48
  * ```tsx
@@ -23,8 +52,11 @@ export interface AvatarProps extends Omit<HTMLAttributes<HTMLDivElement>, "child
23
52
  * // With fallback initials
24
53
  * <Avatar fallback="JD" alt="John Doe" />
25
54
  *
26
- * // Custom size
27
- * <Avatar src="/user.jpg" size="lg" />
55
+ * // Hero profile — larger size + lazy load
56
+ * <Avatar src="/perfil.jpg" alt="Dep. Silva" size="2xl" />
57
+ *
58
+ * // Listing — lazy-load all avatars below the fold
59
+ * <Avatar src="/user.jpg" alt="User Name" loading="lazy" />
28
60
  * ```
29
61
  */
30
62
  declare const Avatar: import("react").ForwardRefExoticComponent<AvatarProps & import("react").RefAttributes<HTMLDivElement>>;
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.5.0",
4
+ "version": "4.7.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",