@fabio.caffarello/react-design-system 4.7.0 → 4.9.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;
@@ -0,0 +1,52 @@
1
+ import { type HTMLAttributes, type ReactNode } from "react";
2
+ export interface EmptyStateBaseProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
3
+ title: string;
4
+ /**
5
+ * Descriptive message below the title. Optional — several empty states
6
+ * have only a title. When absent, `aria-label` is just the title and no
7
+ * `<p>` element is rendered.
8
+ */
9
+ message?: string;
10
+ /**
11
+ * Optional decorative illustration (icon, SVG, image). Rendered
12
+ * `aria-hidden` above the title.
13
+ */
14
+ illustration?: ReactNode;
15
+ /**
16
+ * Action slot — any ReactNode (link, button, custom CTA). Rendered
17
+ * below the message (or title when message is absent).
18
+ *
19
+ * Use a plain `<a href>` or `next/link` here to keep the component
20
+ * zero-JS in Server Components; the slot is passed through with no
21
+ * wrapper or event handler added.
22
+ *
23
+ * @example
24
+ * // Zero-JS link — Server Component safe
25
+ * <EmptyStateBase
26
+ * title="Sem resultados"
27
+ * action={<a href="/">Limpar filtros</a>}
28
+ * />
29
+ */
30
+ action?: ReactNode;
31
+ }
32
+ /**
33
+ * EmptyStateBase — the **server-safe presentational core** of `EmptyState`
34
+ * (issue #252 follow-up).
35
+ *
36
+ * It holds no React client state (no hooks, no `"use client"` directive), so
37
+ * it can be imported from `@fabio.caffarello/react-design-system/server` and
38
+ * rendered inside React Server Components and zero-JS routes.
39
+ *
40
+ * ### Trade-off vs `EmptyState`
41
+ *
42
+ * | Feature | EmptyStateBase | EmptyState |
43
+ * |------------------------------|----------------------|-----------------------------|
44
+ * | `action` ReactNode slot | ✅ | ✅ |
45
+ * | `onAction` callback button | ❌ (needs client JS) | ✅ |
46
+ * | `./server` exportable | ✅ | ❌ (barrel pulls Input/useId)|
47
+ *
48
+ * Use `EmptyState` when you need a client-driven callback button (`onAction`).
49
+ * Use `EmptyStateBase` in Server Components where the CTA is a zero-JS link.
50
+ */
51
+ declare const EmptyStateBase: import("react").ForwardRefExoticComponent<EmptyStateBaseProps & import("react").RefAttributes<HTMLDivElement>>;
52
+ export default EmptyStateBase;
@@ -1,2 +1,4 @@
1
1
  export { default } from "./EmptyState";
2
2
  export type { EmptyStateProps } from "./EmptyState";
3
+ export { default as EmptyStateBase } from "./EmptyStateBase";
4
+ export type { EmptyStateBaseProps } from "./EmptyStateBase";
@@ -1,5 +1,6 @@
1
1
  import { type HTMLAttributes, type ReactNode } from "react";
2
- export type AvatarSize = "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl";
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;
@@ -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";
@@ -29,6 +31,8 @@ export { Stack } from "./layouts/Stack/Stack";
29
31
  export type { StackProps } from "./layouts/Stack/Stack";
30
32
  export { default as Breadcrumb } from "./components/Breadcrumb/Breadcrumb";
31
33
  export type { BreadcrumbItem } from "./components/Breadcrumb/Breadcrumb";
34
+ export { default as EmptyStateBase } from "./components/EmptyState/EmptyStateBase";
35
+ export type { EmptyStateBaseProps } from "./components/EmptyState/EmptyStateBase";
32
36
  export { default as Card } from "./components/Card/Card";
33
37
  export type { CardProps } from "./components/Card/Card";
34
38
  export { CardHeader } from "./components/Card/CardHeader";
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.7.0",
4
+ "version": "4.9.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",