@behavioral-agentic-design-system/core 0.29.0 → 0.32.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/LICENSE +21 -0
- package/package.json +2 -1
- package/scripts/build-tokens.cjs +59 -10
- package/scripts/wcag-audit.cjs +30 -4
- package/src/app/preview/components/page.tsx +305 -1
- package/src/app/preview/health/page.tsx +201 -0
- package/src/app/shell.tsx +40 -4
- package/src/components/docs-tab.tsx +26 -9
- package/src/components/home-tab.tsx +12 -3
- package/src/components/ui/badge.tsx +16 -2
- package/src/components/ui/button.tsx +10 -0
- package/src/components/ui/checkbox.tsx +21 -6
- package/src/components/ui/index.ts +1 -0
- package/src/components/ui/input-clear-button.tsx +52 -0
- package/src/components/ui/input.tsx +5 -21
- package/src/components/ui/multi-select.tsx +20 -6
- package/src/components/ui/progress.tsx +23 -1
- package/src/components/ui/questionnaire.tsx +352 -0
- package/src/components/ui/sidebar.tsx +5 -0
- package/src/components/ui/skeleton.tsx +83 -1
- package/src/components/ui/tabs.tsx +34 -0
- package/src/components/ui/textarea.tsx +5 -0
- package/src/components/ui/toggle-tip.tsx +125 -0
- package/src/data/docs-index.ts +51 -3
- package/src/fonts-cdn.css +25 -0
- package/src/lib/fork.ts +21 -0
- package/src/lib/get-icon-color.ts +66 -0
- package/src/stories/Badge.stories.tsx +66 -0
- package/src/stories/Button.stories.tsx +3 -0
- package/src/stories/Checkbox.stories.tsx +58 -4
- package/src/stories/Input.stories.tsx +3 -0
- package/src/stories/InputClearButton.stories.tsx +53 -0
- package/src/stories/MultiSelect.stories.tsx +6 -2
- package/src/stories/Progress.stories.tsx +56 -4
- package/src/stories/Questionnaire.stories.tsx +287 -0
- package/src/stories/Sidebar.stories.tsx +2 -0
- package/src/stories/SkeletonTable.stories.tsx +97 -0
- package/src/stories/Stack.stories.tsx +2 -1
- package/src/stories/Tabs.stories.tsx +56 -8
- package/src/stories/Textarea.stories.tsx +2 -0
- package/src/stories/ToggleTip.stories.tsx +106 -0
- package/src/styles.css +22 -10
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { Badge } from "../../../components/ui/badge";
|
|
4
|
+
import { Card, CardContent, CardHeader, CardTitle } from "../../../components/ui/card";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* /preview/health — the self-healing layer's Observe surface (Phase A).
|
|
8
|
+
*
|
|
9
|
+
* One page of tiles rendered from the latest generated health report
|
|
10
|
+
* (ledgers/reports/health-<YYYY-MM>.json, produced by `pnpm health:report`)
|
|
11
|
+
* plus open drift-ledger rows. Server component: reads the fork's own files
|
|
12
|
+
* at request time, so every fork gets its own health view for free.
|
|
13
|
+
*
|
|
14
|
+
* The score is INFORMATIONAL — never a gate (Goodhart guard, see
|
|
15
|
+
* docs/specs/2026-08-21-self-healing-layer.md). Placement as a bare route
|
|
16
|
+
* (no shell tab) is deliberate: Sir hasn't picked tab-vs-home placement yet,
|
|
17
|
+
* and a URL-only surface is the reversible default.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
type HealthComponent = {
|
|
21
|
+
name: string;
|
|
22
|
+
score: number;
|
|
23
|
+
band: "healthy" | "watch" | "attention";
|
|
24
|
+
insufficientData: boolean;
|
|
25
|
+
dataPoints: number;
|
|
26
|
+
penalties: { source: string; points: number; why: string }[];
|
|
27
|
+
};
|
|
28
|
+
type HealthReport = {
|
|
29
|
+
generatedFor: string;
|
|
30
|
+
summary: {
|
|
31
|
+
components: number;
|
|
32
|
+
scored: number;
|
|
33
|
+
insufficientData: number;
|
|
34
|
+
avgScore: number | null;
|
|
35
|
+
bands: { healthy: number; watch: number; attention: number };
|
|
36
|
+
};
|
|
37
|
+
components: HealthComponent[];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
function latestReport(): HealthReport | null {
|
|
41
|
+
const dir = path.join(process.cwd(), "ledgers", "reports");
|
|
42
|
+
if (!fs.existsSync(dir)) return null;
|
|
43
|
+
const file = fs
|
|
44
|
+
.readdirSync(dir)
|
|
45
|
+
.filter((f) => /^health-\d{4}-\d{2}\.json$/.test(f))
|
|
46
|
+
.sort()
|
|
47
|
+
.pop();
|
|
48
|
+
if (!file) return null;
|
|
49
|
+
try {
|
|
50
|
+
return JSON.parse(fs.readFileSync(path.join(dir, file), "utf8"));
|
|
51
|
+
} catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function openDrift(): { date: string; source: string; target: string; severity: string; signal: string }[] {
|
|
57
|
+
const p = path.join(process.cwd(), "ledgers", "drift.jsonl");
|
|
58
|
+
if (!fs.existsSync(p)) return [];
|
|
59
|
+
return fs
|
|
60
|
+
.readFileSync(p, "utf8")
|
|
61
|
+
.split("\n")
|
|
62
|
+
.filter(Boolean)
|
|
63
|
+
.map((l) => {
|
|
64
|
+
try {
|
|
65
|
+
return JSON.parse(l);
|
|
66
|
+
} catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
.filter((r): r is NonNullable<typeof r> => Boolean(r) && r.status === "open")
|
|
71
|
+
.slice(-20)
|
|
72
|
+
.reverse();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const BAND_STYLE: Record<string, string> = {
|
|
76
|
+
healthy: "text-success",
|
|
77
|
+
watch: "text-warning",
|
|
78
|
+
attention: "text-destructive",
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const dynamic = "force-dynamic";
|
|
82
|
+
|
|
83
|
+
export default function HealthPage() {
|
|
84
|
+
const report = latestReport();
|
|
85
|
+
const drift = openDrift();
|
|
86
|
+
|
|
87
|
+
if (!report) {
|
|
88
|
+
return (
|
|
89
|
+
<main className="mx-auto max-w-3xl p-8">
|
|
90
|
+
<h1 className="text-2xl font-semibold tracking-tight">System health</h1>
|
|
91
|
+
<p className="mt-4 text-sm text-muted-foreground">
|
|
92
|
+
No health report yet. Generate one with{" "}
|
|
93
|
+
<code className="font-mono text-foreground">pnpm health:report</code>, then reload.
|
|
94
|
+
</p>
|
|
95
|
+
</main>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const { summary } = report;
|
|
100
|
+
const flagged = report.components.filter((c) => !c.insufficientData && c.band !== "healthy");
|
|
101
|
+
const healthy = summary.bands.healthy;
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<main className="mx-auto max-w-6xl space-y-8 p-8">
|
|
105
|
+
<header className="space-y-1">
|
|
106
|
+
<h1 className="text-2xl font-semibold tracking-tight">System health</h1>
|
|
107
|
+
<p className="text-sm text-muted-foreground">
|
|
108
|
+
Generated {report.generatedFor} from the ledgers — informational, never a merge gate.
|
|
109
|
+
</p>
|
|
110
|
+
</header>
|
|
111
|
+
|
|
112
|
+
<section className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
|
113
|
+
<Card>
|
|
114
|
+
<CardHeader className="pb-2">
|
|
115
|
+
<CardTitle className="text-sm text-muted-foreground">Average score</CardTitle>
|
|
116
|
+
</CardHeader>
|
|
117
|
+
<CardContent className="text-3xl font-semibold">{summary.avgScore ?? "–"}</CardContent>
|
|
118
|
+
</Card>
|
|
119
|
+
<Card>
|
|
120
|
+
<CardHeader className="pb-2">
|
|
121
|
+
<CardTitle className="text-sm text-muted-foreground">Healthy</CardTitle>
|
|
122
|
+
</CardHeader>
|
|
123
|
+
<CardContent className="text-3xl font-semibold text-success">{healthy}</CardContent>
|
|
124
|
+
</Card>
|
|
125
|
+
<Card>
|
|
126
|
+
<CardHeader className="pb-2">
|
|
127
|
+
<CardTitle className="text-sm text-muted-foreground">Watch / attention</CardTitle>
|
|
128
|
+
</CardHeader>
|
|
129
|
+
<CardContent className="text-3xl font-semibold">
|
|
130
|
+
<span className="text-warning">{summary.bands.watch}</span>
|
|
131
|
+
<span className="text-muted-foreground"> / </span>
|
|
132
|
+
<span className="text-destructive">{summary.bands.attention}</span>
|
|
133
|
+
</CardContent>
|
|
134
|
+
</Card>
|
|
135
|
+
<Card>
|
|
136
|
+
<CardHeader className="pb-2">
|
|
137
|
+
<CardTitle className="text-sm text-muted-foreground">Insufficient data</CardTitle>
|
|
138
|
+
</CardHeader>
|
|
139
|
+
<CardContent className="text-3xl font-semibold">{summary.insufficientData}</CardContent>
|
|
140
|
+
</Card>
|
|
141
|
+
</section>
|
|
142
|
+
|
|
143
|
+
<section className="space-y-3">
|
|
144
|
+
<h2 className="text-lg font-semibold">Needs attention ({flagged.length})</h2>
|
|
145
|
+
{flagged.length === 0 ? (
|
|
146
|
+
<p className="text-sm text-muted-foreground">Every scored component is in the healthy band.</p>
|
|
147
|
+
) : (
|
|
148
|
+
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
|
149
|
+
{flagged
|
|
150
|
+
.sort((a, b) => a.score - b.score)
|
|
151
|
+
.map((c) => (
|
|
152
|
+
<Card key={c.name} className="overflow-hidden">
|
|
153
|
+
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
|
154
|
+
<CardTitle className="min-w-0 truncate text-base" title={c.name}>
|
|
155
|
+
{c.name}
|
|
156
|
+
</CardTitle>
|
|
157
|
+
<span className={`text-2xl font-semibold ${BAND_STYLE[c.band]}`}>{c.score}</span>
|
|
158
|
+
</CardHeader>
|
|
159
|
+
<CardContent>
|
|
160
|
+
<ul className="space-y-1">
|
|
161
|
+
{c.penalties.slice(0, 3).map((p, i) => (
|
|
162
|
+
<li key={i} className="text-sm text-muted-foreground">
|
|
163
|
+
<span className="font-mono text-xs">−{p.points}</span> {p.why}
|
|
164
|
+
</li>
|
|
165
|
+
))}
|
|
166
|
+
</ul>
|
|
167
|
+
</CardContent>
|
|
168
|
+
</Card>
|
|
169
|
+
))}
|
|
170
|
+
</div>
|
|
171
|
+
)}
|
|
172
|
+
</section>
|
|
173
|
+
|
|
174
|
+
<section className="space-y-3">
|
|
175
|
+
<h2 className="text-lg font-semibold">Open drift ({drift.length})</h2>
|
|
176
|
+
{drift.length === 0 ? (
|
|
177
|
+
<p className="text-sm text-muted-foreground">
|
|
178
|
+
Drift ledger is clear. Rows land here from the token-intent lint and month-over-month score drops.
|
|
179
|
+
</p>
|
|
180
|
+
) : (
|
|
181
|
+
<Card>
|
|
182
|
+
<CardContent className="divide-y divide-border p-0">
|
|
183
|
+
{drift.map((d, i) => (
|
|
184
|
+
<div key={i} className="flex items-start gap-3 p-4">
|
|
185
|
+
<Badge variant={d.severity === "high" ? "destructive" : "secondary"}>{d.source}</Badge>
|
|
186
|
+
<div className="min-w-0">
|
|
187
|
+
<p className="truncate text-sm font-medium" title={d.target}>
|
|
188
|
+
{d.target}
|
|
189
|
+
</p>
|
|
190
|
+
<p className="text-sm text-muted-foreground">{d.signal}</p>
|
|
191
|
+
</div>
|
|
192
|
+
<span className="ml-auto shrink-0 text-sm text-muted-foreground">{d.date}</span>
|
|
193
|
+
</div>
|
|
194
|
+
))}
|
|
195
|
+
</CardContent>
|
|
196
|
+
</Card>
|
|
197
|
+
)}
|
|
198
|
+
</section>
|
|
199
|
+
</main>
|
|
200
|
+
);
|
|
201
|
+
}
|
package/src/app/shell.tsx
CHANGED
|
@@ -434,18 +434,54 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
|
|
|
434
434
|
// small — every extra % here steals deceleration from the visible sweep
|
|
435
435
|
// (1.12 was tried first: crossing stayed a 2-frame blink).
|
|
436
436
|
// (See the theme-reveal comment in build-tokens.cjs.)
|
|
437
|
+
const cx = event.clientX;
|
|
438
|
+
const cy = event.clientY;
|
|
437
439
|
const radius = Math.hypot(
|
|
438
|
-
Math.max(
|
|
439
|
-
Math.max(
|
|
440
|
+
Math.max(cx, window.innerWidth - cx),
|
|
441
|
+
Math.max(cy, window.innerHeight - cy)
|
|
440
442
|
);
|
|
441
|
-
|
|
443
|
+
const r = Math.ceil(radius * 1.03);
|
|
444
|
+
root.style.setProperty("--r", `${r}px`);
|
|
442
445
|
const transition = (document as Document & {
|
|
443
|
-
startViewTransition: (cb: () => void) => { finished: Promise<void> };
|
|
446
|
+
startViewTransition: (cb: () => void) => { finished: Promise<void>; ready: Promise<void> };
|
|
444
447
|
}).startViewTransition(() => {
|
|
445
448
|
syncHost();
|
|
446
449
|
syncVisibleIframes();
|
|
447
450
|
setDark(next);
|
|
448
451
|
});
|
|
452
|
+
// Drive the reveal's ORIGIN from JS (literal px), not from --x/--y read
|
|
453
|
+
// inside the CSS keyframe. Current Chrome stopped propagating custom
|
|
454
|
+
// properties set on <html> into the ::view-transition pseudo tree, so the
|
|
455
|
+
// keyframe's `circle(... at var(--x,50%) var(--y,50%))` fell back to 50%
|
|
456
|
+
// 50% and the wipe started dead-center instead of at the toggle (WebKit
|
|
457
|
+
// still inherits them, which is why it only broke in Chrome). The WAAPI
|
|
458
|
+
// animation carries the same duration/easing/radius as the CSS keyframe
|
|
459
|
+
// (so the theme-old-out tail-guard's 92%/98% offsets still line up) and,
|
|
460
|
+
// being a scripted animation, wins the cascade over the CSS one — which
|
|
461
|
+
// stays as the coordinate-free fallback for engines without pseudoElement
|
|
462
|
+
// support. `ready` starts before the first animation frame paints, so the
|
|
463
|
+
// WAAPI origin is in place before any centered CSS frame is visible.
|
|
464
|
+
transition.ready.then(
|
|
465
|
+
() => {
|
|
466
|
+
try {
|
|
467
|
+
root.animate(
|
|
468
|
+
{
|
|
469
|
+
clipPath: [
|
|
470
|
+
`circle(0px at ${cx}px ${cy}px)`,
|
|
471
|
+
`circle(${r}px at ${cx}px ${cy}px)`,
|
|
472
|
+
],
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
duration: 400,
|
|
476
|
+
easing: "ease-in-out",
|
|
477
|
+
fill: "forwards",
|
|
478
|
+
pseudoElement: "::view-transition-new(root)",
|
|
479
|
+
}
|
|
480
|
+
);
|
|
481
|
+
} catch {}
|
|
482
|
+
},
|
|
483
|
+
() => {}
|
|
484
|
+
);
|
|
449
485
|
// `finished` rejects when a newer transition skips this one — converge
|
|
450
486
|
// either way. Two rAFs past `finished` so the overlay-teardown frame
|
|
451
487
|
// paints before the hidden-iframe recalc lands: with the exact radius the
|
|
@@ -14,13 +14,30 @@ import { Button } from "@behavioral-agentic-design-system/core/components/ui/but
|
|
|
14
14
|
import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge";
|
|
15
15
|
import { Dialog, DialogContent } from "@behavioral-agentic-design-system/core/components/ui/dialog";
|
|
16
16
|
import { MarkdownPreview } from "@behavioral-agentic-design-system/core/components/markdown-preview";
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
docsTotal,
|
|
19
|
+
visibleDocGroups,
|
|
20
|
+
type DocEntry,
|
|
21
|
+
type DocGroup,
|
|
22
|
+
} from "@behavioral-agentic-design-system/core/data/docs-index";
|
|
23
|
+
import { IS_CLIENT_FORK } from "@behavioral-agentic-design-system/core/lib/fork";
|
|
24
|
+
|
|
25
|
+
// The groups this repo actually surfaces. A renamed client fork drops the
|
|
26
|
+
// onboarding group (see `retireAfterRename` in docs-index) — it describes work
|
|
27
|
+
// that already happened here, so leaving it in the sidebar tells this fork's own
|
|
28
|
+
// staff to re-onboard their live design system. Resolved at build time, so the
|
|
29
|
+
// server render and the hydrated render agree.
|
|
30
|
+
//
|
|
31
|
+
// Module scope, not a hook: IS_CLIENT_FORK is a build-time constant, so this
|
|
32
|
+
// list can never change during a session.
|
|
33
|
+
const GROUPS: DocGroup[] = visibleDocGroups(IS_CLIENT_FORK);
|
|
34
|
+
const TOTAL = docsTotal(GROUPS);
|
|
18
35
|
|
|
19
36
|
// Persist last-viewed doc across reloads so the tab restores cleanly.
|
|
20
37
|
const ACTIVE_DOC_KEY = "bads:docs:active-path";
|
|
21
38
|
|
|
22
39
|
function findEntryByPath(path: string): DocEntry | undefined {
|
|
23
|
-
for (const group of
|
|
40
|
+
for (const group of GROUPS) {
|
|
24
41
|
const hit = group.entries.find((e) => e.path === path);
|
|
25
42
|
if (hit) return hit;
|
|
26
43
|
}
|
|
@@ -28,7 +45,7 @@ function findEntryByPath(path: string): DocEntry | undefined {
|
|
|
28
45
|
}
|
|
29
46
|
|
|
30
47
|
function flatEntries(): DocEntry[] {
|
|
31
|
-
return
|
|
48
|
+
return GROUPS.flatMap((g) => g.entries);
|
|
32
49
|
}
|
|
33
50
|
|
|
34
51
|
// Tiny fuzzy match: every search-token (split on whitespace) must appear
|
|
@@ -45,7 +62,7 @@ function matches(haystack: string, query: string): boolean {
|
|
|
45
62
|
}
|
|
46
63
|
|
|
47
64
|
export function DocsTab() {
|
|
48
|
-
const defaultEntry =
|
|
65
|
+
const defaultEntry = GROUPS[0]?.entries[0];
|
|
49
66
|
const [activePath, setActivePath] = useState<string>(defaultEntry?.path ?? "");
|
|
50
67
|
const [content, setContent] = useState<string>("");
|
|
51
68
|
const [loading, setLoading] = useState<boolean>(false);
|
|
@@ -148,8 +165,8 @@ export function DocsTab() {
|
|
|
148
165
|
// Sidebar items use the same matcher so sidebar + palette share behavior.
|
|
149
166
|
const sidebarGroups = useMemo<DocGroup[]>(() => {
|
|
150
167
|
const q = paletteQuery.trim();
|
|
151
|
-
if (!q) return
|
|
152
|
-
return
|
|
168
|
+
if (!q) return GROUPS;
|
|
169
|
+
return GROUPS.map((g): DocGroup => ({
|
|
153
170
|
...g,
|
|
154
171
|
entries: g.entries.filter((e) => matches(`${e.title} ${e.path} ${e.summary ?? ""}`, q)),
|
|
155
172
|
})).filter((g) => g.entries.length > 0);
|
|
@@ -204,7 +221,7 @@ export function DocsTab() {
|
|
|
204
221
|
<BookOpen className="size-4 text-primary" strokeWidth={1.5} />
|
|
205
222
|
<span className="text-sm font-semibold">Docs</span>
|
|
206
223
|
<Badge variant="secondary" className="ml-1">
|
|
207
|
-
{
|
|
224
|
+
{TOTAL}
|
|
208
225
|
</Badge>
|
|
209
226
|
</div>
|
|
210
227
|
<Button
|
|
@@ -268,7 +285,7 @@ export function DocsTab() {
|
|
|
268
285
|
<BookOpen className="size-4 text-primary" strokeWidth={1.5} />
|
|
269
286
|
<span className="text-sm font-semibold">Docs</span>
|
|
270
287
|
<Badge variant="secondary" className="ml-1">
|
|
271
|
-
{
|
|
288
|
+
{TOTAL}
|
|
272
289
|
</Badge>
|
|
273
290
|
<Button
|
|
274
291
|
variant="outline"
|
|
@@ -317,7 +334,7 @@ export function DocsTab() {
|
|
|
317
334
|
setPaletteIndex(0);
|
|
318
335
|
}}
|
|
319
336
|
onKeyDown={onPaletteKey}
|
|
320
|
-
placeholder={`Search ${
|
|
337
|
+
placeholder={`Search ${TOTAL} docs…`}
|
|
321
338
|
aria-label="Search documentation"
|
|
322
339
|
className="h-9 border-0 px-0 text-sm shadow-none focus-visible:ring-0"
|
|
323
340
|
/>
|
|
@@ -32,7 +32,11 @@ import { Separator } from "@behavioral-agentic-design-system/core/components/ui/
|
|
|
32
32
|
import { BadsUpdateBanner } from "@behavioral-agentic-design-system/core/components/bads-update-banner";
|
|
33
33
|
import registry from "@/layer-5-component-registry/component-registry.json";
|
|
34
34
|
import tokens from "@/packages/core/src/tokens.json";
|
|
35
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
AUTOMATION_COUNT,
|
|
37
|
+
visibleDocGroups,
|
|
38
|
+
} from "@behavioral-agentic-design-system/core/data/docs-index";
|
|
39
|
+
import { IS_CLIENT_FORK } from "@behavioral-agentic-design-system/core/lib/fork";
|
|
36
40
|
|
|
37
41
|
type HomeTabProps = {
|
|
38
42
|
onBrowseDocs?: () => void;
|
|
@@ -49,6 +53,11 @@ const primitiveTokenCount = Object.values(
|
|
|
49
53
|
).reduce((sum, group) => sum + Object.keys(group).length, 0);
|
|
50
54
|
const LAYER_COUNT = 10;
|
|
51
55
|
|
|
56
|
+
// Must match what the Docs tab actually renders, since clicking a badge here
|
|
57
|
+
// opens that group's first doc there — a badge for a group the tab has retired
|
|
58
|
+
// would open nothing. Both sides derive from visibleDocGroups(IS_CLIENT_FORK).
|
|
59
|
+
const DOC_GROUPS = visibleDocGroups(IS_CLIENT_FORK);
|
|
60
|
+
|
|
52
61
|
// Curated entry-points. Each points at a real path in the Docs tab so
|
|
53
62
|
// clicking through lands on a meaningful first read, not a TOC.
|
|
54
63
|
type StarterCard = {
|
|
@@ -412,10 +421,10 @@ export function HomeTab({ onBrowseDocs, onBrowseComponents }: HomeTabProps) {
|
|
|
412
421
|
|
|
413
422
|
<section className="flex flex-col gap-4">
|
|
414
423
|
<h2 className="text-sm font-semibold uppercase tracking-wide text-muted-foreground">
|
|
415
|
-
The Docs tab indexes {
|
|
424
|
+
The Docs tab indexes {DOC_GROUPS.length} categories
|
|
416
425
|
</h2>
|
|
417
426
|
<div className="flex flex-wrap gap-2">
|
|
418
|
-
{
|
|
427
|
+
{DOC_GROUPS.map((group) => (
|
|
419
428
|
<Badge
|
|
420
429
|
key={group.id}
|
|
421
430
|
variant="outline"
|
|
@@ -5,7 +5,7 @@ import { Slot } from "@radix-ui/react-slot"
|
|
|
5
5
|
import { cn } from "../../lib/utils"
|
|
6
6
|
|
|
7
7
|
const badgeVariants = cva(
|
|
8
|
-
"inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent
|
|
8
|
+
"inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none",
|
|
9
9
|
{
|
|
10
10
|
variants: {
|
|
11
11
|
variant: {
|
|
@@ -38,9 +38,21 @@ const badgeVariants = cva(
|
|
|
38
38
|
info:
|
|
39
39
|
"border-[var(--info)]! bg-info/10 text-foreground [&>svg]:text-info dark:bg-info/15",
|
|
40
40
|
},
|
|
41
|
+
/**
|
|
42
|
+
* Badge height ladder (peer parity: Mantine Badge size, MUI Chip size,
|
|
43
|
+
* Chakra Badge size). sm = dense list rows / inline labels; default =
|
|
44
|
+
* unchanged; lg = prominent status surfaces / feature flags.
|
|
45
|
+
* BADS text-xs = 14px and text-sm = 16px — never below 14px (AAA floor).
|
|
46
|
+
*/
|
|
47
|
+
size: {
|
|
48
|
+
sm: "px-1.5 py-0 text-xs font-medium [&>svg]:size-2.5",
|
|
49
|
+
default: "px-2 py-0.5 text-xs font-medium [&>svg]:size-3",
|
|
50
|
+
lg: "px-2.5 py-1 text-sm font-medium [&>svg]:size-4",
|
|
51
|
+
},
|
|
41
52
|
},
|
|
42
53
|
defaultVariants: {
|
|
43
54
|
variant: "default",
|
|
55
|
+
size: "default",
|
|
44
56
|
},
|
|
45
57
|
}
|
|
46
58
|
)
|
|
@@ -48,6 +60,7 @@ const badgeVariants = cva(
|
|
|
48
60
|
function Badge({
|
|
49
61
|
className,
|
|
50
62
|
variant = "default",
|
|
63
|
+
size = "default",
|
|
51
64
|
asChild = false,
|
|
52
65
|
...props
|
|
53
66
|
}: React.ComponentProps<"span"> &
|
|
@@ -58,7 +71,8 @@ function Badge({
|
|
|
58
71
|
<Comp
|
|
59
72
|
data-slot="badge"
|
|
60
73
|
data-variant={variant}
|
|
61
|
-
|
|
74
|
+
data-size={size}
|
|
75
|
+
className={cn(badgeVariants({ variant, size }), className)}
|
|
62
76
|
{...props}
|
|
63
77
|
/>
|
|
64
78
|
)
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
// Button always attaches an internal onClick/onKeyDown (handleClick guards the
|
|
4
|
+
// aria-disabled pattern, handleKeyDown blocks Enter/Space on it), so it hands a
|
|
5
|
+
// function to the DOM on every render — even when the caller passes no
|
|
6
|
+
// callbacks at all. Rendered from a server component that fails at prerender
|
|
7
|
+
// with "Event handlers cannot be passed to Client Component props". Alert, Tag,
|
|
8
|
+
// Input and Notification deliberately do NOT carry this directive: they only
|
|
9
|
+
// attach a handler when the consumer passes one, which is inherently a
|
|
10
|
+
// client-side act, so they stay server-renderable.
|
|
1
11
|
import * as React from "react"
|
|
2
12
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
13
|
import { Slot } from "@radix-ui/react-slot"
|
|
@@ -6,23 +6,38 @@ import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
|
|
|
6
6
|
|
|
7
7
|
import { cn } from "../../lib/utils"
|
|
8
8
|
|
|
9
|
+
type CheckboxProps = React.ComponentProps<typeof CheckboxPrimitive.Root> & {
|
|
10
|
+
/**
|
|
11
|
+
* Visual size of the checkbox box (peer parity: Mantine size, MUI size,
|
|
12
|
+
* Chakra size).
|
|
13
|
+
* sm = 24px visible box · default = 32px visible box (unchanged).
|
|
14
|
+
* The transparent ::before hit-area stays 44px in both sizes (WCAG 2.2
|
|
15
|
+
* SC 2.5.5 Enhanced — the AAA pointer-target floor). An explicit size
|
|
16
|
+
* utility in className still wins for one-off overrides.
|
|
17
|
+
*/
|
|
18
|
+
size?: "sm" | "default"
|
|
19
|
+
}
|
|
20
|
+
|
|
9
21
|
function Checkbox({
|
|
10
22
|
className,
|
|
23
|
+
size = "default",
|
|
11
24
|
...props
|
|
12
|
-
}:
|
|
25
|
+
}: CheckboxProps) {
|
|
13
26
|
return (
|
|
14
27
|
<CheckboxPrimitive.Root
|
|
15
28
|
data-slot="checkbox"
|
|
29
|
+
data-size={size}
|
|
16
30
|
className={cn(
|
|
17
|
-
// The visible box
|
|
31
|
+
// The visible box is 24px (sm) or 32px (default), but the
|
|
18
32
|
// POINTER TARGET must hit WCAG 2.2 SC 2.5.5 Enhanced (44×44, the AAA
|
|
19
33
|
// floor). A centered transparent ::before overlay (before:size-11 =
|
|
20
34
|
// 44px) extends the interactive area without enlarging the box — a
|
|
21
35
|
// pseudo-element hit-tests to its host, so clicks in the padding toggle
|
|
22
36
|
// the checkbox. It's absolutely positioned, so it adds zero layout
|
|
23
37
|
// (respects the no-jump / layout-stability principle) and never touches
|
|
24
|
-
// a neighbor's flow. Focus ring stays on the visible
|
|
25
|
-
"peer relative inline-flex
|
|
38
|
+
// a neighbor's flow. Focus ring stays on the visible box.
|
|
39
|
+
"peer relative inline-flex shrink-0 items-center justify-center border-2 border-muted-foreground/60 bg-white leading-none shadow-xs transition-[background-color,border-color,color] duration-[210ms] ease-in-out outline-none before:absolute before:left-1/2 before:top-1/2 before:size-11 before:-translate-x-1/2 before:-translate-y-1/2 before:content-[''] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground dark:aria-invalid:ring-destructive/40",
|
|
40
|
+
size === "sm" ? "size-6 rounded-[3px]" : "size-8 rounded-[4px]",
|
|
26
41
|
className
|
|
27
42
|
)}
|
|
28
43
|
{...props}
|
|
@@ -37,11 +52,11 @@ function Checkbox({
|
|
|
37
52
|
which Radix already announces). Icons keep the CheckIcon's stroke
|
|
38
53
|
weight so the glyphs read identically inside the same indicator. */}
|
|
39
54
|
<CheckIcon
|
|
40
|
-
className="hidden
|
|
55
|
+
className={cn("hidden group-data-[state=checked]/indicator:block", size === "sm" ? "size-4" : "size-6")}
|
|
41
56
|
strokeWidth={3}
|
|
42
57
|
/>
|
|
43
58
|
<MinusIcon
|
|
44
|
-
className="hidden
|
|
59
|
+
className={cn("hidden group-data-[state=indeterminate]/indicator:block", size === "sm" ? "size-4" : "size-6")}
|
|
45
60
|
strokeWidth={3}
|
|
46
61
|
/>
|
|
47
62
|
</CheckboxPrimitive.Indicator>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
// The clear affordance is split out of Input so that Input itself stays
|
|
4
|
+
// server-renderable. Input attaches no handler of its own; this button does,
|
|
5
|
+
// unconditionally, and a component that creates a function on every render can
|
|
6
|
+
// never render on the server. Keeping the split means a plain `<Input />` costs
|
|
7
|
+
// a consumer nothing on the client, while `<Input clearable />` pulls in only
|
|
8
|
+
// this button.
|
|
9
|
+
//
|
|
10
|
+
// `onChange` crosses no boundary in either direction: rendered from a server
|
|
11
|
+
// component it is necessarily undefined (a server component cannot create a
|
|
12
|
+
// callback), and rendered from a client component Input is already part of the
|
|
13
|
+
// client graph.
|
|
14
|
+
|
|
15
|
+
import * as React from "react"
|
|
16
|
+
import { XIcon } from "lucide-react"
|
|
17
|
+
|
|
18
|
+
import { cn } from "../../lib/utils"
|
|
19
|
+
|
|
20
|
+
function InputClearButton({
|
|
21
|
+
onChange,
|
|
22
|
+
className,
|
|
23
|
+
}: {
|
|
24
|
+
/** The owning input's change handler. Called with an empty value on click. */
|
|
25
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement>
|
|
26
|
+
className?: string
|
|
27
|
+
}) {
|
|
28
|
+
return (
|
|
29
|
+
<button
|
|
30
|
+
type="button"
|
|
31
|
+
aria-label="Clear input"
|
|
32
|
+
data-slot="input-clear-button"
|
|
33
|
+
className={cn(
|
|
34
|
+
"absolute top-1/2 -translate-y-1/2 inline-flex items-center justify-center size-6 rounded text-muted-foreground hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",
|
|
35
|
+
className
|
|
36
|
+
)}
|
|
37
|
+
style={{
|
|
38
|
+
transitionDuration: "var(--duration-fast)",
|
|
39
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
40
|
+
}}
|
|
41
|
+
onClick={() => {
|
|
42
|
+
onChange?.({
|
|
43
|
+
target: { value: "" },
|
|
44
|
+
} as React.ChangeEvent<HTMLInputElement>)
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
<XIcon size={14} strokeWidth={1.5} aria-hidden="true" />
|
|
48
|
+
</button>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { InputClearButton }
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as React from "react"
|
|
2
2
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
|
-
import { XIcon } from "lucide-react"
|
|
4
|
-
|
|
5
3
|
import { cn } from "../../lib/utils"
|
|
4
|
+
import { InputClearButton } from "./input-clear-button"
|
|
6
5
|
|
|
7
6
|
const inputVariants = cva(
|
|
8
7
|
"w-full min-w-0 rounded-md border border-input bg-transparent shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:border-0 file:bg-transparent file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 dark:bg-input/30 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",
|
|
@@ -94,25 +93,10 @@ function Input({
|
|
|
94
93
|
</div>
|
|
95
94
|
)}
|
|
96
95
|
{showClear && (
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"absolute top-1/2 -translate-y-1/2 inline-flex items-center justify-center size-6 rounded text-muted-foreground hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",
|
|
102
|
-
rightSection ? "right-8" : "right-1.5"
|
|
103
|
-
)}
|
|
104
|
-
style={{
|
|
105
|
-
transitionDuration: "var(--duration-fast)",
|
|
106
|
-
transitionTimingFunction: "var(--ease-out)",
|
|
107
|
-
}}
|
|
108
|
-
onClick={() => {
|
|
109
|
-
onChange?.({
|
|
110
|
-
target: { value: "" },
|
|
111
|
-
} as React.ChangeEvent<HTMLInputElement>)
|
|
112
|
-
}}
|
|
113
|
-
>
|
|
114
|
-
<XIcon size={14} strokeWidth={1.5} aria-hidden="true" />
|
|
115
|
-
</button>
|
|
96
|
+
<InputClearButton
|
|
97
|
+
onChange={onChange}
|
|
98
|
+
className={rightSection ? "right-8" : "right-1.5"}
|
|
99
|
+
/>
|
|
116
100
|
)}
|
|
117
101
|
</div>
|
|
118
102
|
)
|
|
@@ -85,6 +85,7 @@ function MultiSelect({
|
|
|
85
85
|
*/}
|
|
86
86
|
<div
|
|
87
87
|
data-slot="multi-select"
|
|
88
|
+
aria-disabled={disabled || undefined}
|
|
88
89
|
className={cn(
|
|
89
90
|
"relative flex w-full min-h-9 h-auto items-center justify-between gap-1 rounded-md border border-input bg-background px-3 py-1.5 text-sm font-medium shadow-xs",
|
|
90
91
|
"cursor-default select-none",
|
|
@@ -98,17 +99,30 @@ function MultiSelect({
|
|
|
98
99
|
transitionTimingFunction: "var(--ease-out)",
|
|
99
100
|
}}
|
|
100
101
|
>
|
|
101
|
-
{/*
|
|
102
|
-
|
|
102
|
+
{/*
|
|
103
|
+
* Trigger: absolute-fill transparent button — first in DOM for correct tab order.
|
|
104
|
+
* When disabled: skip PopoverTrigger entirely so Radix doesn't add aria-controls
|
|
105
|
+
* pointing to an unmounted PopoverContent (would fail axe aria-valid-attr-value).
|
|
106
|
+
*/}
|
|
107
|
+
{disabled ? (
|
|
103
108
|
<button
|
|
104
109
|
type="button"
|
|
105
|
-
aria-haspopup="listbox"
|
|
106
110
|
aria-label={triggerLabel}
|
|
107
|
-
disabled
|
|
108
|
-
tabIndex={
|
|
111
|
+
disabled
|
|
112
|
+
tabIndex={-1}
|
|
109
113
|
className="absolute inset-0 z-0 rounded-md focus-visible:outline-none"
|
|
110
114
|
/>
|
|
111
|
-
|
|
115
|
+
) : (
|
|
116
|
+
<PopoverTrigger asChild>
|
|
117
|
+
<button
|
|
118
|
+
type="button"
|
|
119
|
+
aria-haspopup="listbox"
|
|
120
|
+
aria-label={triggerLabel}
|
|
121
|
+
tabIndex={0}
|
|
122
|
+
className="absolute inset-0 z-0 rounded-md focus-visible:outline-none"
|
|
123
|
+
/>
|
|
124
|
+
</PopoverTrigger>
|
|
125
|
+
)}
|
|
112
126
|
|
|
113
127
|
{/* Pills + placeholder: z-10 so they render above the trigger button.
|
|
114
128
|
pointer-events-none lets clicks on badge labels fall through to the
|