@fabio.caffarello/react-design-system 3.10.0 → 3.11.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 +253 -251
- package/dist/granular/index.js.map +1 -1
- package/dist/granular/ui/components/TabsAsLinks/TabsAsLinks.js +145 -0
- package/dist/granular/ui/components/TabsAsLinks/TabsAsLinks.js.map +1 -0
- package/dist/index.cjs +58 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1244 -1131
- package/dist/index.js.map +1 -1
- package/dist/react-design-system.css +1 -1
- package/dist/server/index.cjs +9 -9
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +548 -435
- package/dist/server/index.js.map +1 -1
- package/dist/ui/components/TabsAsLinks/TabsAsLinks.d.ts +80 -0
- package/dist/ui/components/TabsAsLinks/index.d.ts +2 -0
- package/dist/ui/components/index.d.ts +2 -0
- package/dist/ui/server.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { ElementType, HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
/** Visual hierarchy: `default` = primary tab bar, `sub` = nested sub-tabs. */
|
|
3
|
+
export type TabsAsLinksVariant = "default" | "sub";
|
|
4
|
+
/** A single navigation tab. The active state is decided by the caller. */
|
|
5
|
+
export interface TabAsLink {
|
|
6
|
+
/** Visible tab label. */
|
|
7
|
+
label: ReactNode;
|
|
8
|
+
/** Destination URL — pre-computed by the caller. */
|
|
9
|
+
href: string;
|
|
10
|
+
/**
|
|
11
|
+
* Whether this tab is the current one. The caller derives it (from
|
|
12
|
+
* `pathname` / `searchParams`); the component does no detection of its own.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
active?: boolean;
|
|
16
|
+
/** Optional leading icon (decorative — rendered `aria-hidden`). */
|
|
17
|
+
icon?: ReactNode;
|
|
18
|
+
/** Optional trailing count (e.g. number of items behind the tab). */
|
|
19
|
+
count?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface TabsAsLinksProps extends HTMLAttributes<HTMLElement> {
|
|
22
|
+
/** The tabs to render, in order. */
|
|
23
|
+
items: TabAsLink[];
|
|
24
|
+
/**
|
|
25
|
+
* Visual hierarchy.
|
|
26
|
+
* @default 'default'
|
|
27
|
+
*/
|
|
28
|
+
variant?: TabsAsLinksVariant;
|
|
29
|
+
/**
|
|
30
|
+
* Element/component each tab renders as. Defaults to a plain `<a>` (zero
|
|
31
|
+
* JS, works without hydration). Pass a router link — e.g. Next's `Link` —
|
|
32
|
+
* to keep client-side navigation/prefetch: `linkComponent={Link}`. It
|
|
33
|
+
* receives `href`, `className`, `aria-current`, and `children`.
|
|
34
|
+
* @default 'a'
|
|
35
|
+
*/
|
|
36
|
+
linkComponent?: ElementType;
|
|
37
|
+
/** Additional CSS classes merged onto the root `<nav>`. */
|
|
38
|
+
className?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* `TabsAsLinks` — tabs rendered as **navigation links**, with the active tab
|
|
42
|
+
* decided by the caller (from the URL), not by interactive state.
|
|
43
|
+
*
|
|
44
|
+
* This is the server-safe counterpart to the interactive `Tabs` widget. Use
|
|
45
|
+
* it for tab bars whose selection lives in the URL (`?tab=`, `/section`) so
|
|
46
|
+
* they work without JavaScript and survive a shared link. Because each tab is
|
|
47
|
+
* a real link to a distinct destination, the component uses the **navigation**
|
|
48
|
+
* pattern — a named `<nav>` landmark with `aria-current="page"` on the active
|
|
49
|
+
* link — NOT the `role="tab"` widget pattern (which would promise arrow-key
|
|
50
|
+
* semantics that links don't have).
|
|
51
|
+
*
|
|
52
|
+
* ### Accessible name
|
|
53
|
+
*
|
|
54
|
+
* Renders a `<nav>` landmark, which must be named so screen-reader users can
|
|
55
|
+
* tell multiple tab bars apart. Pass `aria-label` (e.g. `"Painel"`) or
|
|
56
|
+
* `aria-labelledby`. With neither, a dev-only warning fires (the landmark
|
|
57
|
+
* still renders, just anonymously).
|
|
58
|
+
*
|
|
59
|
+
* ### Server-safe
|
|
60
|
+
*
|
|
61
|
+
* No hooks, no event handlers on the DOM — pure presentation. Ships in the
|
|
62
|
+
* `./server` entry. Defaults to a plain `<a>`; pass `linkComponent={Link}` to
|
|
63
|
+
* keep a router's client-side navigation, which crosses the RSC boundary as a
|
|
64
|
+
* client reference.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```tsx
|
|
68
|
+
* // Next App Router — active derived from searchParams in a Server Component
|
|
69
|
+
* <TabsAsLinks
|
|
70
|
+
* aria-label="Painel"
|
|
71
|
+
* linkComponent={Link}
|
|
72
|
+
* items={[
|
|
73
|
+
* { label: "Visão geral", href: "/painel?tab=overview", active: tab === "overview" },
|
|
74
|
+
* { label: "Alertas", href: "/painel?tab=alerts", active: tab === "alerts", count: 3 },
|
|
75
|
+
* ]}
|
|
76
|
+
* />
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
declare const TabsAsLinks: import("react").ForwardRefExoticComponent<TabsAsLinksProps & import("react").RefAttributes<HTMLElement>>;
|
|
80
|
+
export default TabsAsLinks;
|
|
@@ -81,3 +81,5 @@ export { DataTablePattern, type DataTablePatternProps, type DataTableColumn, } f
|
|
|
81
81
|
export { FormWizardPattern, type FormWizardPatternProps, type FormWizardStep, } from "./FormWizardPattern";
|
|
82
82
|
export { SearchAndFilterPattern, type SearchAndFilterPatternProps, type FilterConfig, type FilterOption, } from "./SearchAndFilterPattern";
|
|
83
83
|
export { DashboardLayout, type DashboardLayoutProps } from "./DashboardLayout";
|
|
84
|
+
export { default as TabsAsLinks } from "./TabsAsLinks";
|
|
85
|
+
export type { TabsAsLinksProps, TabAsLink, TabsAsLinksVariant, } from "./TabsAsLinks";
|
package/dist/ui/server.d.ts
CHANGED
|
@@ -61,5 +61,7 @@ export { StatGroup } from "./components/Stat/StatGroup";
|
|
|
61
61
|
export type { StatGroupProps, StatGroupLayout, StatGroupCols, } from "./components/Stat/StatGroup";
|
|
62
62
|
export { default as TableCell } from "./components/Table/TableCell";
|
|
63
63
|
export type { TableCellProps } from "./components/Table/TableCell";
|
|
64
|
+
export { default as TabsAsLinks } from "./components/TabsAsLinks/TabsAsLinks";
|
|
65
|
+
export type { TabsAsLinksProps, TabAsLink, TabsAsLinksVariant, } from "./components/TabsAsLinks/TabsAsLinks";
|
|
64
66
|
export { default as Timeline } from "./components/Timeline/Timeline";
|
|
65
67
|
export type { TimelineItem, TimelineOrientation, TimelineProps, } from "./components/Timeline/Timeline";
|