@behavioral-agentic-design-system/core 0.28.0 → 0.29.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/package.json +2 -2
- package/scripts/a11y-lint.cjs +78 -9
- package/scripts/build-tokens.cjs +273 -15
- package/scripts/wcag-audit.cjs +37 -7
- package/src/api/layers/file.ts +1 -0
- package/src/app/font-ready.tsx +6 -5
- package/src/app/layout.tsx +54 -3
- package/src/app/preview/components/page.tsx +5532 -3044
- package/src/app/preview/layout.tsx +4 -1
- package/src/app/preview/showcase-filter.tsx +66 -0
- package/src/app/preview/tab-replay.tsx +63 -0
- package/src/app/shell.tsx +74 -18
- package/src/components/customize/save-bar.tsx +19 -6
- package/src/components/docs-tab.tsx +36 -24
- package/src/components/layers-tab.tsx +37 -5
- package/src/components/ui/alert.tsx +12 -0
- package/src/components/ui/badge.tsx +19 -0
- package/src/components/ui/chat-marker.tsx +120 -0
- package/src/components/ui/checkbox.tsx +9 -1
- package/src/components/ui/close-button.tsx +71 -0
- package/src/components/ui/combobox.tsx +62 -3
- package/src/components/ui/container.tsx +65 -0
- package/src/components/ui/date-field.tsx +368 -0
- package/src/components/ui/drawer.tsx +334 -0
- package/src/components/ui/file-button.tsx +145 -0
- package/src/components/ui/floating-indicator.tsx +217 -0
- package/src/components/ui/format-byte.tsx +113 -0
- package/src/components/ui/index.ts +21 -0
- package/src/components/ui/input.tsx +38 -3
- package/src/components/ui/keyboard-shortcut.tsx +146 -0
- package/src/components/ui/loading-dots.tsx +99 -0
- package/src/components/ui/month-picker.tsx +296 -0
- package/src/components/ui/multi-select.tsx +15 -13
- package/src/components/ui/nav-link.tsx +200 -0
- package/src/components/ui/navigation-rail.tsx +256 -0
- package/src/components/ui/notification.tsx +20 -0
- package/src/components/ui/password-input.tsx +34 -1
- package/src/components/ui/progress.tsx +15 -1
- package/src/components/ui/prose.tsx +62 -0
- package/src/components/ui/result.tsx +151 -0
- package/src/components/ui/rolling-number.tsx +1 -0
- package/src/components/ui/simple-grid.tsx +110 -0
- package/src/components/ui/skeleton.tsx +52 -3
- package/src/components/ui/squircle.tsx +274 -0
- package/src/components/ui/stack.tsx +105 -0
- package/src/components/ui/status-badge.tsx +93 -0
- package/src/components/ui/tabs.tsx +34 -7
- package/src/components/ui/tag.tsx +46 -5
- package/src/components/ui/theme-icon.tsx +138 -0
- package/src/components/ui/timeline.tsx +27 -10
- package/src/components/ui/tooltip.tsx +12 -1
- package/src/components/ui/tree-select.tsx +386 -0
- package/src/components/ui/year-picker.tsx +307 -0
- package/src/data/docs-index.ts +10 -0
- package/src/hooks/use-global-primary-color.ts +57 -6
- package/src/stories/Alert.stories.tsx +31 -1
- package/src/stories/Badge.stories.tsx +63 -6
- package/src/stories/ChatMarker.stories.tsx +59 -0
- package/src/stories/Checkbox.stories.tsx +5 -0
- package/src/stories/CloseButton.stories.tsx +65 -0
- package/src/stories/Combobox.stories.tsx +74 -3
- package/src/stories/Container.stories.tsx +134 -0
- package/src/stories/DateField.stories.tsx +114 -0
- package/src/stories/Drawer.stories.tsx +211 -0
- package/src/stories/FileButton.stories.tsx +117 -0
- package/src/stories/FloatingIndicator.stories.tsx +343 -0
- package/src/stories/FormatByte.stories.tsx +142 -0
- package/src/stories/Input.stories.tsx +91 -0
- package/src/stories/KeyboardShortcut.stories.tsx +87 -0
- package/src/stories/LoadingDots.stories.tsx +73 -0
- package/src/stories/MonthPicker.stories.tsx +99 -0
- package/src/stories/MultiSelect.stories.tsx +3 -1
- package/src/stories/NavLink.stories.tsx +213 -0
- package/src/stories/NavigationRail.stories.tsx +413 -0
- package/src/stories/Notification.stories.tsx +53 -0
- package/src/stories/PasswordInput.stories.tsx +21 -0
- package/src/stories/Progress.stories.tsx +38 -0
- package/src/stories/Prose.stories.tsx +232 -0
- package/src/stories/Result.stories.tsx +145 -0
- package/src/stories/RollingNumber.stories.tsx +1 -1
- package/src/stories/SimpleGrid.stories.tsx +130 -0
- package/src/stories/Skeleton.stories.tsx +62 -1
- package/src/stories/Squircle.stories.tsx +127 -0
- package/src/stories/Stack.stories.tsx +139 -0
- package/src/stories/StatusBadge.stories.tsx +125 -0
- package/src/stories/Tabs.stories.tsx +56 -1
- package/src/stories/Tag.stories.tsx +31 -0
- package/src/stories/ThemeIcon.stories.tsx +97 -0
- package/src/stories/Timeline.stories.tsx +69 -0
- package/src/stories/Tooltip.stories.tsx +18 -0
- package/src/stories/TreeSelect.stories.tsx +222 -0
- package/src/stories/YearPicker.stories.tsx +100 -0
- package/src/styles.css +289 -15
- package/src/tokens.json +96 -1
- package/LICENSE +0 -21
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Slot, Slottable } from "@radix-ui/react-slot";
|
|
5
|
+
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* NavLink — individual sidebar navigation link primitive.
|
|
10
|
+
*
|
|
11
|
+
* Pairs with BADS' Sidebar container component, filling the gap between the
|
|
12
|
+
* full sidebar shell and the individual clickable destination. Sources:
|
|
13
|
+
* Mantine NavLink (icon/badge/nested API), Radix-based composition (asChild
|
|
14
|
+
* for Next.js Link).
|
|
15
|
+
*
|
|
16
|
+
* Active state is CSS-only via `aria-current="page"` — the `active` prop sets
|
|
17
|
+
* the attribute; the attribute selector in the className does the styling.
|
|
18
|
+
* No JS class toggling needed, which means the active mark survives SSR,
|
|
19
|
+
* hydration, and static export intact.
|
|
20
|
+
*
|
|
21
|
+
* Icon slot: enforces 1.5 stroke width via `[&>svg]:stroke-[1.5]` so the
|
|
22
|
+
* consumer only needs to pass a Lucide icon (or any SVG) — no manual
|
|
23
|
+
* strokeWidth wiring required.
|
|
24
|
+
*
|
|
25
|
+
* Badge slot: `ml-auto` pushes it to the trailing edge regardless of label
|
|
26
|
+
* length. Wraps arbitrary ReactNode so the consumer can pass a `<Badge>`,
|
|
27
|
+
* a count string, or a status dot.
|
|
28
|
+
*
|
|
29
|
+
* asChild idiom (same as Button / Link) — when `asChild={true}`, the Slot
|
|
30
|
+
* from @radix-ui/react-slot merges NavLink's props onto the single child
|
|
31
|
+
* element, making `<NavLink asChild><NextLink href="...">…</NextLink></NavLink>`
|
|
32
|
+
* pattern work with no wrapper div.
|
|
33
|
+
*
|
|
34
|
+
* // Basic
|
|
35
|
+
* <NavLink href="/dashboard" icon={<LayoutDashboard />}>Dashboard</NavLink>
|
|
36
|
+
*
|
|
37
|
+
* // Active
|
|
38
|
+
* <NavLink href="/settings" icon={<Settings />} active>Settings</NavLink>
|
|
39
|
+
*
|
|
40
|
+
* // With badge
|
|
41
|
+
* <NavLink href="/inbox" icon={<Bell />} badge="3">Notifications</NavLink>
|
|
42
|
+
*
|
|
43
|
+
* // Nested / indented sub-item
|
|
44
|
+
* <NavLink href="/reports/monthly" nested>Monthly</NavLink>
|
|
45
|
+
*
|
|
46
|
+
* // As Next.js Link
|
|
47
|
+
* <NavLink asChild active={pathname === "/dashboard"}>
|
|
48
|
+
* <NextLink href="/dashboard">Dashboard</NextLink>
|
|
49
|
+
* </NavLink>
|
|
50
|
+
*
|
|
51
|
+
* AAA notes:
|
|
52
|
+
* - Native `<a>` element preserves link semantics; Tab/Shift+Tab navigation
|
|
53
|
+
* is handled by the browser with no extra JS.
|
|
54
|
+
* - `aria-current="page"` is the ARIA pattern for marking the current page
|
|
55
|
+
* in a navigation landmark (SC 2.4.8 Location; ARIA APG).
|
|
56
|
+
* - Target height: `py-2` (8px × 2) + `text-sm` (16px × 1.5 line-height =
|
|
57
|
+
* 24px) = 40px base; min-h-11 (44px) ensures the WCAG 2.2 SC 2.5.5
|
|
58
|
+
* Enhanced floor is always met.
|
|
59
|
+
* - Icon is aria-hidden by convention — consumers should add sr-only text
|
|
60
|
+
* or ensure the label is present alongside the icon.
|
|
61
|
+
*
|
|
62
|
+
* Motion pattern (c) — inline var() for one-off hover transition:
|
|
63
|
+
* transition-colors (explicit property, not transition-all)
|
|
64
|
+
* style={{ transitionDuration: 'var(--duration-fast)', transitionTimingFunction: 'var(--ease-out)' }}
|
|
65
|
+
*
|
|
66
|
+
* @param active - Sets `aria-current="page"` + active styling via CSS attribute selector
|
|
67
|
+
* @param icon - Left slot. Renders at 16px; `[&>svg]:stroke-[1.5]` enforces 1.5 stroke.
|
|
68
|
+
* @param badge - Right slot. Pushed to trailing edge via ml-auto. Pass a Badge, count, or dot.
|
|
69
|
+
* @param nested - Adds `pl-8` indent for sub-navigation items under a parent item.
|
|
70
|
+
* @param asChild - Radix Slot idiom — merge styles onto single child (e.g. Next.js Link).
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
export interface NavLinkProps extends React.ComponentProps<"a"> {
|
|
74
|
+
/**
|
|
75
|
+
* Marks this link as the current page — sets `aria-current="page"` on the
|
|
76
|
+
* root element and activates the accent-background styling via a CSS
|
|
77
|
+
* attribute selector (no JS class toggling).
|
|
78
|
+
*/
|
|
79
|
+
active?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Left icon slot. Expected size: 16px (size-4). The icon container applies
|
|
82
|
+
* `[&>svg]:size-4 [&>svg]:stroke-[1.5]` so stroke width and sizing are
|
|
83
|
+
* enforced at the NavLink level — the consumer only passes the icon node.
|
|
84
|
+
* Use aria-hidden="true" on decorative icons (the default for most nav icons
|
|
85
|
+
* where the text label carries the accessible name).
|
|
86
|
+
*/
|
|
87
|
+
icon?: React.ReactNode;
|
|
88
|
+
/**
|
|
89
|
+
* Right badge slot. Pushed to the trailing edge via `ml-auto`. Pass a BADS
|
|
90
|
+
* `<Badge>`, a plain count string, an unread dot, or any ReactNode. When
|
|
91
|
+
* count-only (no visible text label beside it), add an `aria-label` on the
|
|
92
|
+
* badge element so screen readers announce the full meaning
|
|
93
|
+
* (e.g. `aria-label="3 unread notifications"`).
|
|
94
|
+
*/
|
|
95
|
+
badge?: React.ReactNode;
|
|
96
|
+
/**
|
|
97
|
+
* Indented variant for sub-navigation items nested under a parent item.
|
|
98
|
+
* Applies `pl-8` (32px left padding) to convey the hierarchy visually and
|
|
99
|
+
* spatially — no JavaScript state required, purely a visual/layout signal.
|
|
100
|
+
*/
|
|
101
|
+
nested?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* When true, renders as the child element instead of the default `<a>` tag.
|
|
104
|
+
* Use for semantic overrides (e.g. `<NavLink asChild><NextLink href="…">…</NextLink></NavLink>`).
|
|
105
|
+
* The Slot from @radix-ui/react-slot merges all NavLink props and className
|
|
106
|
+
* onto the single child element. `Slottable` marks which child carries the
|
|
107
|
+
* user-provided element while icon/badge spans are passed through as
|
|
108
|
+
* additional children of the merged element.
|
|
109
|
+
*/
|
|
110
|
+
asChild?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Visually and semantically disables the link. Sets `aria-disabled="true"`
|
|
113
|
+
* and suppresses pointer events so keyboard and screen-reader users are
|
|
114
|
+
* informed without relying on the non-standard HTML `disabled` on `<a>`.
|
|
115
|
+
*/
|
|
116
|
+
disabled?: boolean;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function NavLink({
|
|
120
|
+
active = false,
|
|
121
|
+
icon,
|
|
122
|
+
badge,
|
|
123
|
+
nested = false,
|
|
124
|
+
asChild = false,
|
|
125
|
+
className,
|
|
126
|
+
style,
|
|
127
|
+
children,
|
|
128
|
+
disabled,
|
|
129
|
+
...props
|
|
130
|
+
}: NavLinkProps) {
|
|
131
|
+
const Comp = asChild ? Slot : "a";
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<Comp
|
|
135
|
+
data-slot="nav-link"
|
|
136
|
+
aria-current={active ? "page" : undefined}
|
|
137
|
+
aria-disabled={disabled ? "true" : undefined}
|
|
138
|
+
className={cn(
|
|
139
|
+
// Base layout — full-width flex row, token spacing + radius
|
|
140
|
+
"flex min-h-11 w-full items-center gap-2 rounded-md px-3 py-2 text-sm font-medium text-foreground outline-none",
|
|
141
|
+
// Hover state — accent surface + foreground, token-driven transition
|
|
142
|
+
"hover:bg-accent hover:text-accent-foreground",
|
|
143
|
+
// Active / current-page state — CSS-only via aria-current attribute
|
|
144
|
+
// selector. No JS class needed; survives SSR + hydration.
|
|
145
|
+
"aria-[current=page]:bg-accent aria-[current=page]:text-accent-foreground",
|
|
146
|
+
// Focus visible — 2px ring with offset per WCAG 2.2 SC 2.4.13
|
|
147
|
+
"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
148
|
+
// Nested / indented sub-item
|
|
149
|
+
nested && "pl-8",
|
|
150
|
+
// Disabled
|
|
151
|
+
disabled && "pointer-events-none opacity-50",
|
|
152
|
+
className
|
|
153
|
+
)}
|
|
154
|
+
// Motion pattern (c): token-driven one-off transition.
|
|
155
|
+
// transition-colors targets background + color changes only (never
|
|
156
|
+
// transition-all — avoids animating focus rings and layout props).
|
|
157
|
+
// Duration + easing resolve at runtime against :root CSS vars generated
|
|
158
|
+
// from tokens.json via pnpm build:tokens. Reduced-motion handled by the
|
|
159
|
+
// base-layer @media rule — no per-component guard needed.
|
|
160
|
+
style={{
|
|
161
|
+
transitionDuration: "var(--duration-fast)",
|
|
162
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
163
|
+
...style,
|
|
164
|
+
}}
|
|
165
|
+
{...props}
|
|
166
|
+
>
|
|
167
|
+
{icon != null && (
|
|
168
|
+
// Icon container — enforces 16px size and 1.5 stroke width at the
|
|
169
|
+
// system level, decoupling consumers from the BADS icon stroke rule.
|
|
170
|
+
<span
|
|
171
|
+
data-slot="nav-link-icon"
|
|
172
|
+
aria-hidden="true"
|
|
173
|
+
className="shrink-0 [&>svg]:size-4 [&>svg]:stroke-[1.5]"
|
|
174
|
+
>
|
|
175
|
+
{icon}
|
|
176
|
+
</span>
|
|
177
|
+
)}
|
|
178
|
+
|
|
179
|
+
{/* Label — when asChild, Slottable marks the user-provided child as the
|
|
180
|
+
merge target for Slot (icon/badge siblings become its children).
|
|
181
|
+
When not asChild, a plain span carries the flex-1 + truncate styling. */}
|
|
182
|
+
{asChild ? (
|
|
183
|
+
<Slottable>{children}</Slottable>
|
|
184
|
+
) : (
|
|
185
|
+
<span className="flex-1 truncate">{children}</span>
|
|
186
|
+
)}
|
|
187
|
+
|
|
188
|
+
{badge != null && (
|
|
189
|
+
// Badge slot — pushed to trailing edge via ml-auto; the `flex-1` on
|
|
190
|
+
// the label span ensures ml-auto resolves relative to the link width
|
|
191
|
+
// not the label width.
|
|
192
|
+
<span data-slot="nav-link-badge" className="ml-auto shrink-0">
|
|
193
|
+
{badge}
|
|
194
|
+
</span>
|
|
195
|
+
)}
|
|
196
|
+
</Comp>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export { NavLink };
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
|
|
6
|
+
// ─── Context ──────────────────────────────────────────────────────────────────
|
|
7
|
+
|
|
8
|
+
interface NavigationRailContextValue {
|
|
9
|
+
value: string;
|
|
10
|
+
onValueChange: (value: string) => void;
|
|
11
|
+
expanded: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const NavigationRailContext = React.createContext<NavigationRailContextValue>({
|
|
15
|
+
value: "",
|
|
16
|
+
onValueChange: () => {},
|
|
17
|
+
expanded: false,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// ─── Root ─────────────────────────────────────────────────────────────────────
|
|
21
|
+
|
|
22
|
+
export interface NavigationRailProps
|
|
23
|
+
extends Omit<React.HTMLAttributes<HTMLElement>, "onChange"> {
|
|
24
|
+
/** The value of the currently active destination (controlled). */
|
|
25
|
+
value?: string;
|
|
26
|
+
/** Initial active destination (uncontrolled). */
|
|
27
|
+
defaultValue?: string;
|
|
28
|
+
/** Callback fired when the user activates a destination. */
|
|
29
|
+
onValueChange?: (value: string) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Expanded layout: icon beside label in a wider rail. Compact (default)
|
|
32
|
+
* stacks the label under the icon in an 80px strip.
|
|
33
|
+
*/
|
|
34
|
+
expanded?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Accessible label for the navigation landmark. Keeps multiple nav
|
|
37
|
+
* landmarks on a page distinguishable to screen readers.
|
|
38
|
+
*/
|
|
39
|
+
label?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Narrow vertical navigation rail — a `<nav>` landmark holding icon+label
|
|
44
|
+
* destination buttons, one of which is current. The vertical partner of
|
|
45
|
+
* BottomNavigation for desktop and tablet app shells (the Material Design
|
|
46
|
+
* "navigation rail" pattern).
|
|
47
|
+
*
|
|
48
|
+
* NOT a tablist: it navigates between top-level destinations
|
|
49
|
+
* (`aria-current="page"` on the active item), it does not switch visible
|
|
50
|
+
* content panels in place. For in-place switching use Tabs; for a wide
|
|
51
|
+
* collapsible navigation panel with groups, use Sidebar.
|
|
52
|
+
*/
|
|
53
|
+
export function NavigationRail({
|
|
54
|
+
value: valueProp,
|
|
55
|
+
defaultValue,
|
|
56
|
+
onValueChange,
|
|
57
|
+
expanded = false,
|
|
58
|
+
label = "Primary navigation",
|
|
59
|
+
className,
|
|
60
|
+
children,
|
|
61
|
+
...props
|
|
62
|
+
}: NavigationRailProps) {
|
|
63
|
+
const [internalValue, setInternalValue] = React.useState(defaultValue ?? "");
|
|
64
|
+
const value = valueProp ?? internalValue;
|
|
65
|
+
|
|
66
|
+
const handleValueChange = React.useCallback(
|
|
67
|
+
(next: string) => {
|
|
68
|
+
setInternalValue(next);
|
|
69
|
+
onValueChange?.(next);
|
|
70
|
+
},
|
|
71
|
+
[onValueChange]
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<NavigationRailContext.Provider
|
|
76
|
+
value={{ value, onValueChange: handleValueChange, expanded }}
|
|
77
|
+
>
|
|
78
|
+
<nav
|
|
79
|
+
aria-label={label}
|
|
80
|
+
data-slot="navigation-rail"
|
|
81
|
+
data-orientation="vertical"
|
|
82
|
+
data-expanded={expanded ? "true" : "false"}
|
|
83
|
+
className={cn(
|
|
84
|
+
"flex h-full flex-col items-stretch gap-1 border-r border-border bg-background px-1.5 py-3",
|
|
85
|
+
// Compact rail is 80px (the Material/desktop convention) — a 56px
|
|
86
|
+
// strip couldn't fit even short 4–5 char labels ("Home", "Setup"),
|
|
87
|
+
// truncating every one to an ellipsis. 80px leaves ~60px usable so
|
|
88
|
+
// typical rail labels render in full; `truncate` on the label stays
|
|
89
|
+
// as graceful fallback for anything genuinely long. (corrections.md)
|
|
90
|
+
expanded ? "w-52" : "w-20",
|
|
91
|
+
className
|
|
92
|
+
)}
|
|
93
|
+
{...props}
|
|
94
|
+
>
|
|
95
|
+
{children}
|
|
96
|
+
</nav>
|
|
97
|
+
</NavigationRailContext.Provider>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ─── Header ───────────────────────────────────────────────────────────────────
|
|
102
|
+
|
|
103
|
+
export type NavigationRailHeaderProps = React.HTMLAttributes<HTMLDivElement>;
|
|
104
|
+
|
|
105
|
+
/** Optional slot above the destination items — logo, wordmark, menu toggle. */
|
|
106
|
+
export function NavigationRailHeader({
|
|
107
|
+
className,
|
|
108
|
+
children,
|
|
109
|
+
...props
|
|
110
|
+
}: NavigationRailHeaderProps) {
|
|
111
|
+
const { expanded } = React.useContext(NavigationRailContext);
|
|
112
|
+
return (
|
|
113
|
+
<div
|
|
114
|
+
data-slot="navigation-rail-header"
|
|
115
|
+
className={cn(
|
|
116
|
+
"flex min-w-0 items-center gap-3 pb-2",
|
|
117
|
+
expanded ? "justify-start px-3" : "justify-center px-1",
|
|
118
|
+
className
|
|
119
|
+
)}
|
|
120
|
+
>
|
|
121
|
+
{children}
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// ─── Footer ───────────────────────────────────────────────────────────────────
|
|
127
|
+
|
|
128
|
+
export type NavigationRailFooterProps = React.HTMLAttributes<HTMLDivElement>;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Optional slot below the destination items — settings, help, profile.
|
|
132
|
+
* Pushed to the rail's bottom edge; put secondary NavigationRailItems here.
|
|
133
|
+
*/
|
|
134
|
+
export function NavigationRailFooter({
|
|
135
|
+
className,
|
|
136
|
+
children,
|
|
137
|
+
...props
|
|
138
|
+
}: NavigationRailFooterProps) {
|
|
139
|
+
return (
|
|
140
|
+
<div
|
|
141
|
+
data-slot="navigation-rail-footer"
|
|
142
|
+
className={cn("mt-auto flex flex-col items-stretch gap-1 pt-2", className)}
|
|
143
|
+
{...props}
|
|
144
|
+
>
|
|
145
|
+
{children}
|
|
146
|
+
</div>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// ─── Item ─────────────────────────────────────────────────────────────────────
|
|
151
|
+
|
|
152
|
+
export interface NavigationRailItemProps
|
|
153
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
154
|
+
/** The destination value this item represents. */
|
|
155
|
+
value: string;
|
|
156
|
+
/** Icon for the destination. Must be a Lucide icon with strokeWidth={1.5}. */
|
|
157
|
+
icon: React.ReactNode;
|
|
158
|
+
/** Visible text label. Always shown — hiding labels hurts comprehension. */
|
|
159
|
+
label: string;
|
|
160
|
+
/** Optional count badge overlaid on the icon (unread counts, alerts). */
|
|
161
|
+
badge?: string | number;
|
|
162
|
+
/**
|
|
163
|
+
* Screen-reader label for the badge. Defaults to "<badge> notifications" —
|
|
164
|
+
* override when the count means something else ("3 unread messages").
|
|
165
|
+
*/
|
|
166
|
+
badgeLabel?: string;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function NavigationRailItem({
|
|
170
|
+
value,
|
|
171
|
+
icon,
|
|
172
|
+
label,
|
|
173
|
+
badge,
|
|
174
|
+
badgeLabel,
|
|
175
|
+
className,
|
|
176
|
+
disabled,
|
|
177
|
+
onClick,
|
|
178
|
+
...props
|
|
179
|
+
}: NavigationRailItemProps) {
|
|
180
|
+
const {
|
|
181
|
+
value: activeValue,
|
|
182
|
+
onValueChange,
|
|
183
|
+
expanded,
|
|
184
|
+
} = React.useContext(NavigationRailContext);
|
|
185
|
+
const isActive = activeValue === value;
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<button
|
|
189
|
+
type="button"
|
|
190
|
+
aria-current={isActive ? "page" : undefined}
|
|
191
|
+
data-slot="navigation-rail-item"
|
|
192
|
+
data-state={isActive ? "active" : "inactive"}
|
|
193
|
+
disabled={disabled}
|
|
194
|
+
onClick={(event) => {
|
|
195
|
+
onClick?.(event);
|
|
196
|
+
if (!event.defaultPrevented && !disabled) onValueChange(value);
|
|
197
|
+
}}
|
|
198
|
+
className={cn(
|
|
199
|
+
"group flex min-h-[44px] w-full cursor-pointer select-none rounded-lg",
|
|
200
|
+
expanded
|
|
201
|
+
? "flex-row items-center justify-start gap-3 px-3 py-2.5"
|
|
202
|
+
: "flex-col items-center justify-center gap-0.5 px-1 py-1.5",
|
|
203
|
+
"text-muted-foreground transition-colors",
|
|
204
|
+
"hover:bg-accent/60 hover:text-foreground",
|
|
205
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
206
|
+
"disabled:pointer-events-none disabled:opacity-50",
|
|
207
|
+
"data-[state=active]:bg-accent data-[state=active]:text-accent-foreground",
|
|
208
|
+
className
|
|
209
|
+
)}
|
|
210
|
+
style={{
|
|
211
|
+
transitionDuration: "var(--duration-fast)",
|
|
212
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
213
|
+
}}
|
|
214
|
+
{...props}
|
|
215
|
+
>
|
|
216
|
+
<span
|
|
217
|
+
data-slot="navigation-rail-icon"
|
|
218
|
+
className={cn(
|
|
219
|
+
"relative shrink-0 transition-transform",
|
|
220
|
+
!expanded && "group-data-[state=active]:-translate-y-0.5"
|
|
221
|
+
)}
|
|
222
|
+
style={{
|
|
223
|
+
transitionDuration: "var(--duration-base)",
|
|
224
|
+
transitionTimingFunction: "var(--ease-spring)",
|
|
225
|
+
}}
|
|
226
|
+
>
|
|
227
|
+
<span aria-hidden="true" className="block [&>svg]:size-5 [&>svg]:stroke-[1.5]">
|
|
228
|
+
{icon}
|
|
229
|
+
</span>
|
|
230
|
+
{badge !== undefined && (
|
|
231
|
+
<>
|
|
232
|
+
<span
|
|
233
|
+
aria-hidden="true"
|
|
234
|
+
data-slot="navigation-rail-badge"
|
|
235
|
+
className="absolute -right-2.5 -top-2 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-xs font-medium leading-none text-primary-foreground"
|
|
236
|
+
>
|
|
237
|
+
{badge}
|
|
238
|
+
</span>
|
|
239
|
+
<span className="sr-only">
|
|
240
|
+
{badgeLabel ?? `${badge} notifications`}
|
|
241
|
+
</span>
|
|
242
|
+
</>
|
|
243
|
+
)}
|
|
244
|
+
</span>
|
|
245
|
+
<span
|
|
246
|
+
data-slot="navigation-rail-label"
|
|
247
|
+
className={cn(
|
|
248
|
+
"min-w-0 max-w-full truncate font-medium group-data-[state=active]:font-semibold",
|
|
249
|
+
expanded ? "text-sm" : "text-xs"
|
|
250
|
+
)}
|
|
251
|
+
>
|
|
252
|
+
{label}
|
|
253
|
+
</span>
|
|
254
|
+
</button>
|
|
255
|
+
);
|
|
256
|
+
}
|
|
@@ -53,6 +53,13 @@ type NotificationProps = Omit<React.ComponentProps<"div">, "title"> &
|
|
|
53
53
|
icon?: React.ReactNode
|
|
54
54
|
/** Meta line, e.g. "2 min ago" / "Just now". */
|
|
55
55
|
timestamp?: React.ReactNode
|
|
56
|
+
/**
|
|
57
|
+
* Inline action buttons rendered below the description/timestamp,
|
|
58
|
+
* inside the content column — typically 1–2 `<Button size="sm">`.
|
|
59
|
+
* DOM order keeps these BEFORE the built-in dismiss button, so
|
|
60
|
+
* keyboard users reach the meaningful actions first.
|
|
61
|
+
*/
|
|
62
|
+
actions?: React.ReactNode
|
|
56
63
|
/** Marks the item unread: renders the dot indicator + `data-unread`. */
|
|
57
64
|
unread?: boolean
|
|
58
65
|
/** Shows a Spinner in the icon slot and sets `aria-busy` on the root. */
|
|
@@ -68,6 +75,7 @@ function Notification({
|
|
|
68
75
|
description,
|
|
69
76
|
icon,
|
|
70
77
|
timestamp,
|
|
78
|
+
actions,
|
|
71
79
|
unread,
|
|
72
80
|
loading,
|
|
73
81
|
onDismiss,
|
|
@@ -142,6 +150,18 @@ function Notification({
|
|
|
142
150
|
{timestamp}
|
|
143
151
|
</div>
|
|
144
152
|
)}
|
|
153
|
+
{/* Action slot — last in the content column so tab order runs
|
|
154
|
+
title/description context → actions → dismiss (dismiss button is
|
|
155
|
+
a later DOM sibling). flex-wrap lets long/localized labels wrap
|
|
156
|
+
inside the min-w-0 column instead of overflowing. */}
|
|
157
|
+
{actions && (
|
|
158
|
+
<div
|
|
159
|
+
data-slot="notification-actions"
|
|
160
|
+
className="mt-3 flex flex-wrap gap-2"
|
|
161
|
+
>
|
|
162
|
+
{actions}
|
|
163
|
+
</div>
|
|
164
|
+
)}
|
|
145
165
|
</div>
|
|
146
166
|
|
|
147
167
|
{/* Built-in dismiss. A small utility action (Tag/Sonner-close class),
|
|
@@ -63,6 +63,7 @@ function PasswordInput({
|
|
|
63
63
|
const [visibleState, setVisibleState] = React.useState(defaultVisible);
|
|
64
64
|
const isControlled = visibleProp !== undefined;
|
|
65
65
|
const visible = isControlled ? visibleProp : visibleState;
|
|
66
|
+
const inputRef = React.useRef<HTMLInputElement>(null);
|
|
66
67
|
|
|
67
68
|
function toggle() {
|
|
68
69
|
const next = !visible;
|
|
@@ -70,6 +71,33 @@ function PasswordInput({
|
|
|
70
71
|
onVisibilityChange?.(next);
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
// Return focus to the input after a pointer-click on the toggle button so
|
|
75
|
+
// the cursor position is preserved and the field stays focused (Radix
|
|
76
|
+
// PasswordToggleField behaviour, 2026-08-18 ecosystem research).
|
|
77
|
+
function handleTogglePointerDown(e: React.PointerEvent<HTMLButtonElement>) {
|
|
78
|
+
// Only redirect for pointer (mouse/touch), not keyboard — keyboard users
|
|
79
|
+
// should keep focus on the button so they can toggle again without tabbing.
|
|
80
|
+
if (e.pointerType === "mouse" || e.pointerType === "touch" || e.pointerType === "pen") {
|
|
81
|
+
e.preventDefault(); // stop button from taking focus
|
|
82
|
+
toggle();
|
|
83
|
+
inputRef.current?.focus();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Reset visibility to "password" on form submit to prevent accidental
|
|
88
|
+
// autofill leakage (passwords should not persist in "text" mode across
|
|
89
|
+
// submissions — Radix PasswordToggleField behaviour).
|
|
90
|
+
React.useEffect(() => {
|
|
91
|
+
const form = inputRef.current?.closest("form");
|
|
92
|
+
if (!form) return;
|
|
93
|
+
function handleSubmit() {
|
|
94
|
+
if (!isControlled) setVisibleState(false);
|
|
95
|
+
onVisibilityChange?.(false);
|
|
96
|
+
}
|
|
97
|
+
form.addEventListener("submit", handleSubmit);
|
|
98
|
+
return () => form.removeEventListener("submit", handleSubmit);
|
|
99
|
+
}, [isControlled, onVisibilityChange]);
|
|
100
|
+
|
|
73
101
|
const paddingBySize: Record<string, string> = {
|
|
74
102
|
sm: "px-2.5 py-1",
|
|
75
103
|
default: "px-3 py-1",
|
|
@@ -105,6 +133,7 @@ function PasswordInput({
|
|
|
105
133
|
className={cn(passwordInputVariants({ size, className }))}
|
|
106
134
|
>
|
|
107
135
|
<input
|
|
136
|
+
ref={inputRef}
|
|
108
137
|
id={inputId}
|
|
109
138
|
type={visible ? "text" : "password"}
|
|
110
139
|
disabled={disabled}
|
|
@@ -119,7 +148,11 @@ function PasswordInput({
|
|
|
119
148
|
/>
|
|
120
149
|
<button
|
|
121
150
|
type="button"
|
|
122
|
-
|
|
151
|
+
onPointerDown={handleTogglePointerDown}
|
|
152
|
+
onClick={(e) => {
|
|
153
|
+
// keyboard-triggered clicks don't fire pointerdown — handle here
|
|
154
|
+
if (e.detail === 0) toggle();
|
|
155
|
+
}}
|
|
123
156
|
disabled={disabled}
|
|
124
157
|
tabIndex={0}
|
|
125
158
|
aria-label={visible ? "Hide password" : "Show password"}
|
|
@@ -22,6 +22,15 @@ type ProgressProps = React.ComponentProps<typeof ProgressPrimitive.Root> & {
|
|
|
22
22
|
* progress is indeterminate (no numeric value).
|
|
23
23
|
*/
|
|
24
24
|
showValue?: boolean
|
|
25
|
+
/**
|
|
26
|
+
* Track height (peer parity: Mantine / Chakra / Ark Progress size).
|
|
27
|
+
* sm = 4px (quiet inline progress — table rows, list items),
|
|
28
|
+
* default = 8px (unchanged), lg = 12px (prominent surfaces — upload
|
|
29
|
+
* panels, onboarding). Only the track thickness changes; the header row
|
|
30
|
+
* (label / showValue) is size-independent. An explicit height utility in
|
|
31
|
+
* className still wins for one-off values.
|
|
32
|
+
*/
|
|
33
|
+
size?: "sm" | "default" | "lg"
|
|
25
34
|
}
|
|
26
35
|
|
|
27
36
|
// Mirrors Radix Progress's built-in getValueLabel default so the visible
|
|
@@ -37,6 +46,7 @@ function Progress({
|
|
|
37
46
|
getValueLabel,
|
|
38
47
|
label,
|
|
39
48
|
showValue,
|
|
49
|
+
size = "default",
|
|
40
50
|
...props
|
|
41
51
|
}: ProgressProps) {
|
|
42
52
|
const labelId = React.useId()
|
|
@@ -55,13 +65,17 @@ function Progress({
|
|
|
55
65
|
const track = (
|
|
56
66
|
<ProgressPrimitive.Root
|
|
57
67
|
data-slot="progress"
|
|
68
|
+
data-size={size}
|
|
58
69
|
className={cn(
|
|
59
70
|
// Asymmetric alpha: /30 in light gives a faint "empty track" feel
|
|
60
71
|
// (typical progress UX, ~2.0:1 — under AAA 1.4.11), /60 in dark hits
|
|
61
72
|
// 6.79:1 (AAA pass). Documented exception in CLAUDE.md → "Known AAA
|
|
62
73
|
// exceptions" because no symmetric value reads correctly in both modes
|
|
63
74
|
// with a near-black primary.
|
|
64
|
-
|
|
75
|
+
// Size ladder rides data-size so the base h-2 (default) stays
|
|
76
|
+
// byte-identical and a consumer's explicit height utility in
|
|
77
|
+
// className still wins (data-[size]:h-* only fires for sm/lg).
|
|
78
|
+
"relative h-2 w-full overflow-hidden rounded-full bg-primary/30 data-[size=lg]:h-3 data-[size=sm]:h-1 dark:bg-primary/60",
|
|
65
79
|
className
|
|
66
80
|
)}
|
|
67
81
|
// max / getValueLabel always reach Radix (they rode {...props} before
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
5
|
+
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Long-form typography wrapper. Applies consistent, token-driven typographic
|
|
10
|
+
* rhythm — heading scale, paragraph spacing, list indentation, blockquote,
|
|
11
|
+
* inline/block code, links, tables — to arbitrary HTML descendants: MDX
|
|
12
|
+
* output, remote CMS articles, rendered markdown, anything you didn't author
|
|
13
|
+
* element-by-element. The Chakra `Prose` / Mantine `TypographyStylesProvider`
|
|
14
|
+
* shape, with every value sourced from BADS tokens instead of
|
|
15
|
+
* `@tailwindcss/typography` (whose stock scale and gray palette would breach
|
|
16
|
+
* the AAA 14px / 7:1 floors).
|
|
17
|
+
*
|
|
18
|
+
* <Prose>
|
|
19
|
+
* <h2>Getting started</h2>
|
|
20
|
+
* <p>Fork it, rename it, customize the brand colors, and start building.</p>
|
|
21
|
+
* </Prose>
|
|
22
|
+
*
|
|
23
|
+
* // Semantic override — pick the landmark yourself:
|
|
24
|
+
* <Prose asChild>
|
|
25
|
+
* <article dangerouslySetInnerHTML={{ __html: cmsArticle }} />
|
|
26
|
+
* </Prose>
|
|
27
|
+
*
|
|
28
|
+
* NOT the same as `Text` / `Heading` (single authored elements you control).
|
|
29
|
+
* Reach for Prose only when the markup arrives as a passage; keep authoring
|
|
30
|
+
* individual UI strings with the per-element primitives.
|
|
31
|
+
*
|
|
32
|
+
* The element styles live in the design-system CSS layer (a `.prose` block
|
|
33
|
+
* generated by `packages/core/scripts/build-tokens.cjs` into styles.css /
|
|
34
|
+
* globals.css), keyed off the class this component applies — the same
|
|
35
|
+
* pattern the Accordion/Marquee keyframes use. Zero new tokens: colors,
|
|
36
|
+
* fonts, sizes, radii, and the link-hover transition all resolve through
|
|
37
|
+
* existing `var(--*)` tokens, so token edits propagate via `pnpm
|
|
38
|
+
* build:tokens` with no component change.
|
|
39
|
+
*
|
|
40
|
+
* Display-only: adds no roles, no landmarks, no ARIA, no focus management —
|
|
41
|
+
* the content's own semantics pass through untouched. Width is deliberately
|
|
42
|
+
* consumer-controlled (pair with `max-w-prose` for a 65ch measure); baking a
|
|
43
|
+
* max-width in would fight card and panel layouts.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
export interface ProseProps extends React.ComponentProps<"div"> {
|
|
47
|
+
/**
|
|
48
|
+
* When true, renders as the child element instead of the default `<div>`
|
|
49
|
+
* (Radix Slot). Use for semantic overrides, e.g.
|
|
50
|
+
* `<Prose asChild><article>…</article></Prose>`.
|
|
51
|
+
*/
|
|
52
|
+
asChild?: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function Prose({ className, asChild = false, ...props }: ProseProps) {
|
|
56
|
+
const Comp = asChild ? Slot : "div";
|
|
57
|
+
return (
|
|
58
|
+
<Comp data-slot="prose" className={cn("prose", className)} {...props} />
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { Prose };
|