@fabio.caffarello/react-design-system 4.7.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.
- package/dist/granular/index.js +405 -403
- package/dist/granular/index.js.map +1 -1
- package/dist/granular/ui/components/EmptyState/EmptyState.js +52 -50
- package/dist/granular/ui/components/EmptyState/EmptyState.js.map +1 -1
- package/dist/granular/ui/primitives/Avatar/Avatar.js.map +1 -1
- package/dist/granular/ui/primitives/Avatar/AvatarBase.js +122 -0
- package/dist/granular/ui/primitives/Avatar/AvatarBase.js.map +1 -0
- package/dist/granular/ui/primitives/Tooltip/Tooltip.js +140 -117
- package/dist/granular/ui/primitives/Tooltip/Tooltip.js.map +1 -1
- package/dist/index.cjs +86 -86
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3054 -2936
- package/dist/index.js.map +1 -1
- package/dist/react-design-system.css +1 -1
- package/dist/server/index.cjs +6 -6
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +493 -400
- package/dist/server/index.js.map +1 -1
- package/dist/ui/components/EmptyState/EmptyState.d.ts +24 -2
- package/dist/ui/primitives/Avatar/Avatar.d.ts +2 -1
- package/dist/ui/primitives/Avatar/AvatarBase.d.ts +63 -0
- package/dist/ui/primitives/Avatar/index.d.ts +2 -0
- package/dist/ui/primitives/Tooltip/Tooltip.d.ts +31 -2
- package/dist/ui/server.d.ts +2 -0
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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
|
-
|
|
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:
|
|
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>>;
|
package/dist/ui/server.d.ts
CHANGED
|
@@ -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";
|