@behavioral-agentic-design-system/core 0.29.0 → 0.30.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 +1 -1
- package/scripts/wcag-audit.cjs +30 -4
- package/src/app/preview/components/page.tsx +118 -0
- package/src/app/preview/health/page.tsx +201 -0
- package/src/components/ui/button.tsx +10 -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/questionnaire.tsx +334 -0
- package/src/components/ui/sidebar.tsx +5 -0
- package/src/components/ui/textarea.tsx +5 -0
- package/src/data/docs-index.ts +2 -0
- package/src/lib/get-icon-color.ts +66 -0
- package/src/stories/Button.stories.tsx +3 -0
- 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/Questionnaire.stories.tsx +287 -0
- package/src/stories/Sidebar.stories.tsx +2 -0
- package/src/stories/Stack.stories.tsx +2 -1
- package/src/stories/Textarea.stories.tsx +2 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Matthew Stephens
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behavioral-agentic-design-system/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"description": "BADS core — tokens, shadcn/ui components, and the BADS template shell (app routes, customize tab, theme hooks). Forks consume this and re-export, keeping client repos to ~30 lines of glue.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Matthew Stephens <work@matthewstephens.com> (https://github.com/matthewlarn)",
|
package/scripts/wcag-audit.cjs
CHANGED
|
@@ -43,10 +43,36 @@
|
|
|
43
43
|
const fs = require('fs');
|
|
44
44
|
const path = require('path');
|
|
45
45
|
|
|
46
|
-
// Shipped as the `bads-wcag-audit` bin.
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
|
|
46
|
+
// Shipped as the `bads-wcag-audit` bin. The token file is consumer-owned, but
|
|
47
|
+
// "consumer" means three different repo layouts and only one of them has a
|
|
48
|
+
// packages/ directory:
|
|
49
|
+
//
|
|
50
|
+
// 1. upstream BADS / a fork → packages/core/src/tokens.json
|
|
51
|
+
// 2. an npm consumer → tokens.json at its own root
|
|
52
|
+
// 3. an npm consumer that → the package's shipped defaults, so the audit
|
|
53
|
+
// keeps @core's theme still runs instead of dying
|
|
54
|
+
//
|
|
55
|
+
// Resolving only against `<cwd>/packages/core/src/tokens.json` (the shape this
|
|
56
|
+
// script shipped with) made the command unusable for anyone who installed the
|
|
57
|
+
// package rather than forking it — it exited with ENOENT before printing
|
|
58
|
+
// anything. Found 2026-08-24 from a consumer repo.
|
|
59
|
+
const TOKEN_CANDIDATES = [
|
|
60
|
+
process.env.BADS_TOKENS,
|
|
61
|
+
path.join(process.cwd(), 'packages/core/src/tokens.json'),
|
|
62
|
+
path.join(process.cwd(), 'tokens.json'),
|
|
63
|
+
path.join(__dirname, '..', 'src', 'tokens.json'),
|
|
64
|
+
].filter(Boolean);
|
|
65
|
+
|
|
66
|
+
const TOKENS = TOKEN_CANDIDATES.find((p) => fs.existsSync(p));
|
|
67
|
+
if (!TOKENS) {
|
|
68
|
+
console.error(
|
|
69
|
+
'wcag-audit: no tokens.json found. Looked in:\n' +
|
|
70
|
+
TOKEN_CANDIDATES.map((p) => ` ${p}`).join('\n') +
|
|
71
|
+
'\n\nSet BADS_TOKENS=/path/to/tokens.json to point at it explicitly.'
|
|
72
|
+
);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
|
|
50
76
|
const BRAND_COLORS = path.join(process.cwd(), 'brand-colors.json');
|
|
51
77
|
|
|
52
78
|
const aa = process.argv.includes('--aa');
|
|
@@ -412,6 +412,7 @@ import {
|
|
|
412
412
|
TreeSelect,
|
|
413
413
|
type TreeSelectNode,
|
|
414
414
|
} from "@behavioral-agentic-design-system/core/components/ui/tree-select";
|
|
415
|
+
import { Questionnaire } from "@behavioral-agentic-design-system/core/components/ui/questionnaire";
|
|
415
416
|
|
|
416
417
|
// Stable, deterministic data for ScrollArea — never use Math.random in
|
|
417
418
|
// SSR-rendered output, it causes hydration mismatches.
|
|
@@ -6008,6 +6009,10 @@ export default function ComponentsPreview() {
|
|
|
6008
6009
|
<Section title="CloseButton">
|
|
6009
6010
|
<CloseButtonShowcase />
|
|
6010
6011
|
</Section>
|
|
6012
|
+
|
|
6013
|
+
<Section title="Questionnaire">
|
|
6014
|
+
<QuestionnaireShowcase />
|
|
6015
|
+
</Section>
|
|
6011
6016
|
</div>
|
|
6012
6017
|
</div>
|
|
6013
6018
|
);
|
|
@@ -6066,6 +6071,7 @@ function CloseButtonShowcase() {
|
|
|
6066
6071
|
Restore the dismissed notification
|
|
6067
6072
|
</Button>
|
|
6068
6073
|
) : (
|
|
6074
|
+
// lint-disable: card-bypass — inline notification row composition; CloseButton stories need the raw layout context, not a Card wrapper
|
|
6069
6075
|
<div className="flex w-full max-w-md items-start justify-between gap-3 rounded-lg border border-border bg-card p-4">
|
|
6070
6076
|
<div className="min-w-0">
|
|
6071
6077
|
<p className="text-sm font-medium text-foreground">
|
|
@@ -6112,6 +6118,7 @@ function SimpleGridShowcase() {
|
|
|
6112
6118
|
{Array.from({ length: n }, (_, i) => (
|
|
6113
6119
|
<div
|
|
6114
6120
|
key={i}
|
|
6121
|
+
// lint-disable: card-bypass — dashed-border placeholder cell for SimpleGrid columns demo; visual ruler cell, not content Card
|
|
6115
6122
|
className="flex h-12 items-center justify-center rounded-lg border border-dashed border-border bg-card"
|
|
6116
6123
|
>
|
|
6117
6124
|
<span className="text-sm text-muted-foreground">{`${
|
|
@@ -6133,6 +6140,7 @@ function SimpleGridShowcase() {
|
|
|
6133
6140
|
{Array.from({ length: 4 }, (_, i) => (
|
|
6134
6141
|
<div
|
|
6135
6142
|
key={i}
|
|
6143
|
+
// lint-disable: card-bypass — dashed-border placeholder cell for SimpleGrid responsive showcase; visual demo cell, not content Card
|
|
6136
6144
|
className="flex h-12 items-center justify-center rounded-lg border border-dashed border-border bg-card"
|
|
6137
6145
|
>
|
|
6138
6146
|
<span className="text-sm text-muted-foreground">
|
|
@@ -6213,6 +6221,7 @@ function ContainerShowcase() {
|
|
|
6213
6221
|
<div className="space-y-3 rounded-lg bg-muted/40 py-4">
|
|
6214
6222
|
{(["sm", "md", "lg", "xl", "full"] as const).map((size) => (
|
|
6215
6223
|
<Container key={size} size={size}>
|
|
6224
|
+
{/* lint-disable: card-bypass — dashed-border size label for Container showcase; visual ruler cell, not a Card */}
|
|
6216
6225
|
<div className="rounded-lg border border-dashed border-border bg-card px-4 py-2">
|
|
6217
6226
|
<p className="text-sm text-muted-foreground">{`size="${size}"`}</p>
|
|
6218
6227
|
</div>
|
|
@@ -6228,6 +6237,7 @@ function ContainerShowcase() {
|
|
|
6228
6237
|
</p>
|
|
6229
6238
|
<div className="rounded-lg bg-muted/40 py-4">
|
|
6230
6239
|
<Container size="sm" gutters={false}>
|
|
6240
|
+
{/* lint-disable: card-bypass — dashed-border label for Container gutters=false demo; visual ruler cell, not a Card */}
|
|
6231
6241
|
<div className="rounded-lg border border-dashed border-border bg-card px-4 py-2">
|
|
6232
6242
|
<p className="text-sm text-muted-foreground">
|
|
6233
6243
|
No horizontal padding of its own
|
|
@@ -6323,6 +6333,7 @@ function StatusBadgeShowcase() {
|
|
|
6323
6333
|
<p className="mb-3 text-xs font-medium text-muted-foreground">
|
|
6324
6334
|
Realistic use — service health list.
|
|
6325
6335
|
</p>
|
|
6336
|
+
{/* lint-disable: card-bypass — divide-y service health list; divide-y pattern requires the raw border container, a Card would add conflicting inner padding */}
|
|
6326
6337
|
<div className="flex w-96 flex-col divide-y divide-border rounded-lg border border-border bg-card">
|
|
6327
6338
|
{(
|
|
6328
6339
|
[
|
|
@@ -11430,3 +11441,110 @@ function DateFieldShowcase() {
|
|
|
11430
11441
|
</div>
|
|
11431
11442
|
);
|
|
11432
11443
|
}
|
|
11444
|
+
|
|
11445
|
+
function QuestionnaireShowcase() {
|
|
11446
|
+
const AGENT_QUESTIONS = [
|
|
11447
|
+
{
|
|
11448
|
+
id: "intent",
|
|
11449
|
+
prompt: "What would you like to do with the tokens v2 proposal?",
|
|
11450
|
+
type: "single" as const,
|
|
11451
|
+
options: [
|
|
11452
|
+
{ value: "review", label: "Schedule a review with the full team" },
|
|
11453
|
+
{ value: "approve", label: "Approve it as-is and move to implementation" },
|
|
11454
|
+
{ value: "revise", label: "Request revisions before moving forward" },
|
|
11455
|
+
{ value: "defer", label: "Defer until Q4 planning" },
|
|
11456
|
+
],
|
|
11457
|
+
},
|
|
11458
|
+
{
|
|
11459
|
+
id: "stakeholders",
|
|
11460
|
+
prompt: "Who else needs to be in the loop?",
|
|
11461
|
+
type: "multiple" as const,
|
|
11462
|
+
options: [
|
|
11463
|
+
{ value: "riley", label: "Riley Okafor — brand lead" },
|
|
11464
|
+
{ value: "jordan", label: "Jordan Reeves — design systems" },
|
|
11465
|
+
{ value: "avery", label: "Avery Nakamura — engineering" },
|
|
11466
|
+
{ value: "morgan", label: "Morgan Castellano — product" },
|
|
11467
|
+
],
|
|
11468
|
+
},
|
|
11469
|
+
{
|
|
11470
|
+
id: "notes",
|
|
11471
|
+
prompt: "Any context you'd like added to the calendar invite? (optional)",
|
|
11472
|
+
type: "freeform" as const,
|
|
11473
|
+
skippable: true,
|
|
11474
|
+
skipLabel: "No context needed",
|
|
11475
|
+
},
|
|
11476
|
+
];
|
|
11477
|
+
|
|
11478
|
+
return (
|
|
11479
|
+
<div className="space-y-8">
|
|
11480
|
+
<p className="text-sm text-muted-foreground">
|
|
11481
|
+
One-question-at-a-time form primitive for agentic clarification prompts,
|
|
11482
|
+
onboarding flows, and configuration wizards. Supports single-choice (radio),
|
|
11483
|
+
multiple-choice (checkboxes), freeform (textarea), and skippable questions.
|
|
11484
|
+
</p>
|
|
11485
|
+
|
|
11486
|
+
<div>
|
|
11487
|
+
<p className="mb-3 text-xs font-medium text-muted-foreground">
|
|
11488
|
+
Single-choice — radio options with highlighted selected state.
|
|
11489
|
+
</p>
|
|
11490
|
+
<div className="w-96">
|
|
11491
|
+
<Questionnaire
|
|
11492
|
+
questions={[
|
|
11493
|
+
{
|
|
11494
|
+
id: "role",
|
|
11495
|
+
prompt: "What best describes your current role?",
|
|
11496
|
+
type: "single",
|
|
11497
|
+
options: [
|
|
11498
|
+
{ value: "designer", label: "Designer" },
|
|
11499
|
+
{ value: "engineer", label: "Engineer" },
|
|
11500
|
+
{ value: "product", label: "Product manager" },
|
|
11501
|
+
{ value: "founder", label: "Founder or executive" },
|
|
11502
|
+
],
|
|
11503
|
+
},
|
|
11504
|
+
]}
|
|
11505
|
+
/>
|
|
11506
|
+
</div>
|
|
11507
|
+
</div>
|
|
11508
|
+
|
|
11509
|
+
<div>
|
|
11510
|
+
<p className="mb-3 text-xs font-medium text-muted-foreground">
|
|
11511
|
+
Multiple-choice — checkboxes, multiple selections allowed.
|
|
11512
|
+
</p>
|
|
11513
|
+
<div className="w-96">
|
|
11514
|
+
<Questionnaire
|
|
11515
|
+
questions={[
|
|
11516
|
+
{
|
|
11517
|
+
id: "tools",
|
|
11518
|
+
prompt: "Which design tools does your team use? Select all that apply.",
|
|
11519
|
+
type: "multiple",
|
|
11520
|
+
options: [
|
|
11521
|
+
{ value: "figma", label: "Figma" },
|
|
11522
|
+
{ value: "sketch", label: "Sketch" },
|
|
11523
|
+
{ value: "framer", label: "Framer" },
|
|
11524
|
+
{ value: "storybook", label: "Storybook" },
|
|
11525
|
+
],
|
|
11526
|
+
},
|
|
11527
|
+
]}
|
|
11528
|
+
/>
|
|
11529
|
+
</div>
|
|
11530
|
+
</div>
|
|
11531
|
+
|
|
11532
|
+
<div>
|
|
11533
|
+
<p className="mb-3 text-xs font-medium text-muted-foreground">
|
|
11534
|
+
Realistic use — agent clarification flow with all three question types
|
|
11535
|
+
including a skippable freeform step.
|
|
11536
|
+
</p>
|
|
11537
|
+
<div className="w-[420px] rounded-xl border border-border bg-card p-6 shadow-sm">
|
|
11538
|
+
<p className="mb-4 text-xs font-medium uppercase tracking-wide text-muted-foreground">
|
|
11539
|
+
Agent · Clarify intent
|
|
11540
|
+
</p>
|
|
11541
|
+
<Questionnaire
|
|
11542
|
+
questions={AGENT_QUESTIONS}
|
|
11543
|
+
onComplete={(answers) => console.log("Questionnaire complete", answers)}
|
|
11544
|
+
onSkip={(id) => console.log("Skipped", id)}
|
|
11545
|
+
/>
|
|
11546
|
+
</div>
|
|
11547
|
+
</div>
|
|
11548
|
+
</div>
|
|
11549
|
+
);
|
|
11550
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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"
|
|
@@ -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
|