@fabio.caffarello/react-design-system 4.6.0 → 4.8.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.
@@ -1,7 +1,29 @@
1
1
  import type { HTMLAttributes, ReactNode } from "react";
2
2
  export interface EmptyStateProps extends HTMLAttributes<HTMLDivElement> {
3
3
  title: string;
4
- message: string;
4
+ /**
5
+ * Descriptive message below the title.
6
+ * Optional — several empty states have only a title (e.g. a section
7
+ * that speaks for itself). When absent, the `aria-label` is just the
8
+ * title; the `<p>` element is not rendered.
9
+ */
10
+ message?: string;
11
+ /**
12
+ * Action slot — accepts any ReactNode (link, button, custom CTA).
13
+ * Takes priority over `actionLabel` + `onAction`.
14
+ *
15
+ * Use this prop when the action is a server-rendered `<a>` or
16
+ * `next/link` (zero-JS route); the component renders it without
17
+ * wrapping it in a client Button. When you need a callback-driven
18
+ * button, use `actionLabel` + `onAction` instead (or pass
19
+ * `<Button onClick={…}>…</Button>` here).
20
+ *
21
+ * @example
22
+ * // Server-rendered link (zero-JS)
23
+ * <EmptyState title="Sem resultados" action={<a href="/lista">Limpar filtros</a>} />
24
+ */
25
+ action?: ReactNode;
26
+ /** @deprecated Prefer the `action` slot for new code. Still supported for backwards compat. */
5
27
  actionLabel?: string;
6
28
  onAction?: () => void;
7
29
  illustration?: ReactNode;
@@ -22,4 +44,4 @@ export interface EmptyStateProps extends HTMLAttributes<HTMLDivElement> {
22
44
  * />
23
45
  * ```
24
46
  */
25
- export default function EmptyState({ title, message, actionLabel, onAction, illustration, variant, className, ...props }: EmptyStateProps): import("react").JSX.Element;
47
+ export default function EmptyState({ title, message, action, actionLabel, onAction, illustration, variant, className, ...props }: EmptyStateProps): import("react").JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import { type HTMLAttributes, type ReactNode } from "react";
2
- export type AvatarSize = "xs" | "sm" | "md" | "lg" | "xl";
2
+ import type { AvatarSize } from "./AvatarBase";
3
+ export type { AvatarSize } from "./AvatarBase";
3
4
  export interface AvatarProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
4
5
  src?: string;
5
6
  alt?: string;
@@ -7,13 +8,42 @@ export interface AvatarProps extends Omit<HTMLAttributes<HTMLDivElement>, "child
7
8
  size?: AvatarSize;
8
9
  variant?: "circle" | "square" | "rounded";
9
10
  "aria-label"?: string;
11
+ /**
12
+ * Controls the browser's native lazy-loading behaviour for the avatar
13
+ * `<img>`. Set to `"lazy"` to defer loading until the avatar is near the
14
+ * viewport — strongly recommended for listings with many off-screen
15
+ * profile images (e.g. a 24-card parliament listing).
16
+ *
17
+ * Maps directly to the native `<img loading>` attribute and has no effect
18
+ * when `src` is absent (no `<img>` is rendered).
19
+ *
20
+ * @default 'eager'
21
+ */
22
+ loading?: "lazy" | "eager";
10
23
  }
11
24
  /**
12
25
  * Avatar Component
13
26
  *
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.
27
+ * A versatile avatar component for displaying user profile images or
28
+ * initials. Supports fallback display when image fails to load or is not
29
+ * provided. Fully accessible with ARIA attributes.
30
+ *
31
+ * ### Size scale
32
+ *
33
+ * | size | px | Use case |
34
+ * |------|-----|---------------------------------|
35
+ * | xs | 24 | Tight inline / notification dot |
36
+ * | sm | 32 | Comment thread, compact row |
37
+ * | md | 40 | Default — card header, form row |
38
+ * | lg | 48 | Expanded card, sidebar profile |
39
+ * | xl | 64 | Detail-page section header |
40
+ * | 2xl | 96 | Hero profile (PerfilHeader) |
41
+ * | 3xl | 112 | Full-bleed hero cover |
42
+ *
43
+ * ### Lazy loading
44
+ *
45
+ * Pass `loading="lazy"` on listings to defer off-screen image loads. The
46
+ * default is `"eager"` (matches browser default) for backward compatibility.
17
47
  *
18
48
  * @example
19
49
  * ```tsx
@@ -23,8 +53,11 @@ export interface AvatarProps extends Omit<HTMLAttributes<HTMLDivElement>, "child
23
53
  * // With fallback initials
24
54
  * <Avatar fallback="JD" alt="John Doe" />
25
55
  *
26
- * // Custom size
27
- * <Avatar src="/user.jpg" size="lg" />
56
+ * // Hero profile — larger size + lazy load
57
+ * <Avatar src="/perfil.jpg" alt="Dep. Silva" size="2xl" />
58
+ *
59
+ * // Listing — lazy-load all avatars below the fold
60
+ * <Avatar src="/user.jpg" alt="User Name" loading="lazy" />
28
61
  * ```
29
62
  */
30
63
  declare const Avatar: import("react").ForwardRefExoticComponent<AvatarProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,63 @@
1
+ import { type HTMLAttributes, type ReactNode } from "react";
2
+ export type AvatarSize = "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl";
3
+ export interface AvatarBaseProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
4
+ src?: string;
5
+ alt?: string;
6
+ fallback?: string | ReactNode;
7
+ size?: AvatarSize;
8
+ variant?: "circle" | "square" | "rounded";
9
+ /**
10
+ * Controls the browser's native lazy-loading behaviour for the avatar
11
+ * `<img>`. Set to `"lazy"` to defer loading until the avatar is near the
12
+ * viewport — strongly recommended for listings with many off-screen
13
+ * profile images.
14
+ *
15
+ * Has no effect when `src` is absent (no `<img>` is rendered).
16
+ *
17
+ * @default 'eager'
18
+ */
19
+ loading?: "lazy" | "eager";
20
+ "aria-label"?: string;
21
+ }
22
+ /**
23
+ * AvatarBase — the **server-safe presentational core** of `Avatar` (issue #250).
24
+ *
25
+ * It holds no React client state (`useState` / `useEffect` / hooks of any
26
+ * kind), so it is importable from
27
+ * `@fabio.caffarello/react-design-system/server` and renders inside React
28
+ * Server Components and zero-JS routes.
29
+ *
30
+ * ### Trade-off vs `Avatar`
31
+ *
32
+ * | Scenario | AvatarBase behaviour |
33
+ * |---------------------------|---------------------------------------------------|
34
+ * | `src` absent / null | Renders initials fallback — fully server-rendered |
35
+ * | `src` present, loads OK | Renders `<img>` — same as `Avatar` |
36
+ * | `src` present, 404s | Browser broken-image; no graceful JS fallback |
37
+ *
38
+ * Use `Avatar` (main entry) when you need the graceful `onError` swap to
39
+ * initials (requires `useState` — client island). Use `AvatarBase` in
40
+ * Server Components and listings that are deliberately zero-JS, where `src`
41
+ * is null for entries without a photo and a graceful 404 fallback is
42
+ * acceptable to forgo.
43
+ *
44
+ * @example
45
+ * ```tsx
46
+ * // Server Component list — zero-JS, initials rendered on server when src is null
47
+ * import { AvatarBase } from "@fabio.caffarello/react-design-system/server";
48
+ *
49
+ * export default function ParlamentarCard({ parlamentar }) {
50
+ * return (
51
+ * <AvatarBase
52
+ * src={parlamentar.fotoUrl ?? undefined}
53
+ * fallback={parlamentar.nome}
54
+ * alt={parlamentar.nome}
55
+ * size="md"
56
+ * loading="lazy"
57
+ * />
58
+ * );
59
+ * }
60
+ * ```
61
+ */
62
+ declare const AvatarBase: import("react").ForwardRefExoticComponent<AvatarBaseProps & import("react").RefAttributes<HTMLDivElement>>;
63
+ export default AvatarBase;
@@ -5,5 +5,7 @@
5
5
  */
6
6
  export { default as Avatar } from "./Avatar";
7
7
  export type { AvatarProps, AvatarSize } from "./Avatar";
8
+ export { default as AvatarBase } from "./AvatarBase";
9
+ export type { AvatarBaseProps } from "./AvatarBase";
8
10
  export { AvatarGroup } from "./AvatarGroup";
9
11
  export type { AvatarGroupProps } from "./AvatarGroup";
@@ -1,9 +1,18 @@
1
1
  import type { HTMLAttributes, ReactNode } from "react";
2
- export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
3
- content: string;
2
+ export interface TooltipProps extends Omit<HTMLAttributes<HTMLDivElement>, "content"> {
3
+ content: ReactNode;
4
4
  children: ReactNode;
5
5
  position?: "top" | "bottom" | "left" | "right";
6
6
  delay?: number;
7
+ /**
8
+ * When true, the tooltip panel stays open while the pointer hovers over it
9
+ * (150 ms grace-period bridge), and keyboard focus may move into focusable
10
+ * elements inside the panel (e.g. links). Use for educational / rich
11
+ * tooltips that contain interactive content.
12
+ *
13
+ * @default false
14
+ */
15
+ interactive?: boolean;
7
16
  "aria-label"?: string;
8
17
  /**
9
18
  * When true, the tooltip wrapper won't interfere with absolute positioning of children.
@@ -16,11 +25,31 @@ export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
16
25
  *
17
26
  * A tooltip component for displaying additional information on hover.
18
27
  *
28
+ * Pass `content` as a plain string for simple labels, or as a `ReactNode`
29
+ * for rich / educational content. Set `interactive` when the panel contains
30
+ * clickable elements (links, buttons) — the tooltip then stays open while
31
+ * the pointer is over the panel and while keyboard focus is inside it.
32
+ *
19
33
  * @example
20
34
  * ```tsx
35
+ * // Simple string
21
36
  * <Tooltip content="This is a tooltip">
22
37
  * <Button>Hover me</Button>
23
38
  * </Tooltip>
39
+ *
40
+ * // Rich interactive content
41
+ * <Tooltip
42
+ * interactive
43
+ * content={
44
+ * <>
45
+ * <strong>Pirâmide de Confiança L2</strong>
46
+ * <p>Dados verificados por fonte oficial.</p>
47
+ * <a href="/ajuda/piramide">Saiba mais</a>
48
+ * </>
49
+ * }
50
+ * >
51
+ * <Badge>L2</Badge>
52
+ * </Tooltip>
24
53
  * ```
25
54
  */
26
55
  declare const Tooltip: import("react").ForwardRefExoticComponent<TooltipProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,3 +1,5 @@
1
+ export { default as AvatarBase } from "./primitives/Avatar/AvatarBase";
2
+ export type { AvatarBaseProps, AvatarSize, } from "./primitives/Avatar/AvatarBase";
1
3
  export { default as Badge } from "./primitives/Badge/Badge";
2
4
  export type { BadgeProps, BadgeSize, BadgeStyle, BadgeVariant, } from "./primitives/Badge/Badge";
3
5
  export { default as Button } from "./primitives/Button/Button";
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.6.0",
4
+ "version": "4.8.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",