@behavioral-agentic-design-system/core 0.39.1 → 0.42.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/README.md +2 -0
- package/package.json +26 -5
- package/scripts/a11y-lint.cjs +88 -8
- package/scripts/bads-components.mjs +118 -0
- package/scripts/build-tokens.cjs +133 -12
- package/scripts/check-stories.mjs +1 -1
- package/scripts/health-report.mjs +16 -2
- package/scripts/lint-component-source.mjs +100 -0
- package/scripts/lint-microanimation.mjs +267 -0
- package/scripts/lint-slop.mjs +25 -1
- package/scripts/size-audit.cjs +79 -0
- package/scripts/source-of-truth.cjs +58 -0
- package/scripts/ux-smoke.mjs +438 -0
- package/scripts/wcag-audit.cjs +121 -6
- package/src/api/layers/file.ts +1 -0
- package/src/app/opengraph-image.tsx +5 -0
- package/src/app/preview/components/page.tsx +2237 -2
- package/src/app/shell.tsx +17 -16
- package/src/components/Foundations/Motion.stories.tsx +1 -0
- package/src/components/customize/brand-mark-section.tsx +4 -2
- package/src/components/customize/design-controls.tsx +17 -2
- package/src/components/customize/discipline-section.tsx +3 -6
- package/src/components/customize/font-pickers.tsx +1 -1
- package/src/components/customize/letter-spacing.tsx +1 -1
- package/src/components/customize/save-bar.tsx +2 -2
- package/src/components/customize/theme-io.tsx +7 -7
- package/src/components/customize/type-scale.tsx +1 -1
- package/src/components/customize-tab.tsx +7 -4
- package/src/components/home-tab.tsx +3 -0
- package/src/components/studio/studio.tsx +153 -0
- package/src/components/ui/accordion.tsx +7 -0
- package/src/components/ui/alert.tsx +1 -0
- package/src/components/ui/anchor.tsx +37 -3
- package/src/components/ui/announcement-bar.tsx +256 -0
- package/src/components/ui/attachment.tsx +211 -0
- package/src/components/ui/badge.tsx +1 -0
- package/src/components/ui/callout.tsx +218 -0
- package/src/components/ui/chart.tsx +5 -14
- package/src/components/ui/code.tsx +1 -1
- package/src/components/ui/color-picker.tsx +2 -2
- package/src/components/ui/format-relative-time.tsx +139 -0
- package/src/components/ui/gauge-chart.tsx +238 -0
- package/src/components/ui/grid.tsx +255 -0
- package/src/components/ui/heatmap.tsx +256 -0
- package/src/components/ui/icon.tsx +108 -0
- package/src/components/ui/index.ts +17 -0
- package/src/components/ui/infinite-scroll.tsx +103 -0
- package/src/components/ui/json-input.tsx +351 -0
- package/src/components/ui/navigation-progress.tsx +281 -0
- package/src/components/ui/number-input.tsx +1 -4
- package/src/components/ui/page-header.tsx +63 -0
- package/src/components/ui/password-input.tsx +2 -1
- package/src/components/ui/password-strength-input.tsx +288 -0
- package/src/components/ui/pill.tsx +140 -0
- package/src/components/ui/popover.tsx +27 -4
- package/src/components/ui/portal.tsx +111 -0
- package/src/components/ui/presence.tsx +172 -0
- package/src/components/ui/progress-stack.tsx +258 -0
- package/src/components/ui/scroll-progress.tsx +100 -0
- package/src/components/ui/select.tsx +89 -4
- package/src/components/ui/separator.tsx +1 -0
- package/src/components/ui/slider.tsx +83 -3
- package/src/components/ui/snackbar.tsx +393 -0
- package/src/components/ui/sortable-list.tsx +342 -0
- package/src/components/ui/sparkline.tsx +2 -14
- package/src/components/ui/squircle.tsx +1 -1
- package/src/components/ui/table.tsx +1 -1
- package/src/components/ui/textarea.tsx +28 -1
- package/src/components/ui/tour.tsx +1 -3
- package/src/data/docs-index.ts +25 -0
- package/src/hooks/use-reduced-motion.ts +6 -0
- package/src/lib/clamp.ts +2 -0
- package/src/stories/Accordion.stories.tsx +59 -0
- package/src/stories/Alert.stories.tsx +3 -1
- package/src/stories/Anchor.stories.tsx +54 -0
- package/src/stories/AnnouncementBar.stories.tsx +261 -0
- package/src/stories/Attachment.stories.tsx +189 -0
- package/src/stories/Badge.stories.tsx +3 -0
- package/src/stories/Calendar.stories.tsx +1 -1
- package/src/stories/Callout.stories.tsx +219 -0
- package/src/stories/Chart.stories.tsx +8 -0
- package/src/stories/Code.stories.tsx +1 -0
- package/src/stories/ColorPicker.stories.tsx +24 -0
- package/src/stories/FormatRelativeTime.stories.tsx +116 -0
- package/src/stories/GaugeChart.stories.tsx +163 -0
- package/src/stories/Grid.stories.tsx +197 -0
- package/src/stories/Heatmap.stories.tsx +172 -0
- package/src/stories/Icon.stories.tsx +175 -0
- package/src/stories/InfiniteScroll.stories.tsx +225 -0
- package/src/stories/JsonInput.stories.tsx +212 -0
- package/src/stories/MultiSelect.stories.tsx +1 -1
- package/src/stories/NavigationProgress.stories.tsx +159 -0
- package/src/stories/NumberInput.stories.tsx +1 -0
- package/src/stories/PageHeader.stories.tsx +102 -0
- package/src/stories/PasswordInput.stories.tsx +4 -0
- package/src/stories/PasswordStrengthInput.stories.tsx +211 -0
- package/src/stories/Pill.stories.tsx +201 -0
- package/src/stories/Popover.stories.tsx +29 -1
- package/src/stories/Portal.stories.tsx +191 -0
- package/src/stories/Presence.stories.tsx +228 -0
- package/src/stories/ProgressStack.stories.tsx +287 -0
- package/src/stories/ScrollProgress.stories.tsx +117 -0
- package/src/stories/Select.stories.tsx +25 -0
- package/src/stories/Separator.stories.tsx +3 -0
- package/src/stories/Slider.stories.tsx +54 -5
- package/src/stories/Snackbar.stories.tsx +315 -0
- package/src/stories/SortableList.stories.tsx +263 -0
- package/src/stories/Sparkline.stories.tsx +3 -0
- package/src/stories/Squircle.stories.tsx +1 -0
- package/src/stories/Table.stories.tsx +1 -0
- package/src/stories/Textarea.stories.tsx +18 -0
- package/src/stories/Tour.stories.tsx +1 -0
- package/src/stories/story-groups.json +26 -6
- package/src/styles.css +133 -12
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -15,6 +15,8 @@ import { Button } from "@behavioral-agentic-design-system/core/components/ui/but
|
|
|
15
15
|
import tokens from "@behavioral-agentic-design-system/core/tokens.json";
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
+
Import one file per component, from its own subpath, as above. The package root doesn't export components, and the `components/ui` index loads every component, including ones that need peer dependencies you may not have installed. Peer dependencies are optional: install the ones for the components you use (for example, `@tanstack/react-table` for `data-table`).
|
|
19
|
+
|
|
18
20
|
For client repos that fork the BADS template, this package is consumed via pnpm workspace protocol (`"@behavioral-agentic-design-system/core": "workspace:*"`). For client repos that just want the components, install from the registry.
|
|
19
21
|
|
|
20
22
|
## Publishing
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behavioral-agentic-design-system/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.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)",
|
|
@@ -43,23 +43,28 @@
|
|
|
43
43
|
"bads-build-tokens": "scripts/build-tokens.cjs",
|
|
44
44
|
"bads-check-stories": "scripts/check-stories.mjs",
|
|
45
45
|
"bads-check-sync": "scripts/check-sync.mjs",
|
|
46
|
+
"bads-components": "scripts/bads-components.mjs",
|
|
46
47
|
"bads-doctor": "scripts/bads-doctor.mjs",
|
|
47
48
|
"bads-fix-stories": "scripts/fix-stories.mjs",
|
|
48
49
|
"bads-generate-stories": "scripts/generate-stories.cjs",
|
|
49
50
|
"bads-health-report": "scripts/health-report.mjs",
|
|
50
51
|
"bads-lint-accent-text": "scripts/accent-as-text.mjs",
|
|
52
|
+
"bads-lint-component-source": "scripts/lint-component-source.mjs",
|
|
51
53
|
"bads-lint-ethics": "scripts/lint-ethics-contract.mjs",
|
|
54
|
+
"bads-lint-microanimation": "./scripts/lint-microanimation.mjs",
|
|
52
55
|
"bads-lint-slop": "scripts/lint-slop.mjs",
|
|
53
56
|
"bads-lint-token-intent": "scripts/lint-token-intent.mjs",
|
|
54
|
-
"bads-token-nearest": "scripts/token-nearest.mjs",
|
|
55
57
|
"bads-oklch-to-hex": "scripts/oklch-to-hex.cjs",
|
|
56
58
|
"bads-size-audit": "scripts/size-audit.cjs",
|
|
57
59
|
"bads-sync": "scripts/bads-sync.mjs",
|
|
60
|
+
"bads-token-nearest": "scripts/token-nearest.mjs",
|
|
61
|
+
"bads-ux-smoke": "./scripts/ux-smoke.mjs",
|
|
58
62
|
"bads-wcag-audit": "scripts/wcag-audit.cjs"
|
|
59
63
|
},
|
|
60
64
|
"exports": {
|
|
61
65
|
".": "./src/index.ts",
|
|
62
66
|
"./package.json": "./package.json",
|
|
67
|
+
"./scripts/*": "./scripts/*",
|
|
63
68
|
"./styles.css": "./src/styles.css",
|
|
64
69
|
"./fonts.css": "./src/fonts.css",
|
|
65
70
|
"./fonts-cdn.css": "./src/fonts-cdn.css",
|
|
@@ -123,10 +128,13 @@
|
|
|
123
128
|
"clsx": "^2.1.0",
|
|
124
129
|
"react-markdown": "^10.1.0",
|
|
125
130
|
"remark-gfm": "^4.0.1",
|
|
126
|
-
"tailwind-merge": "^3.
|
|
131
|
+
"tailwind-merge": "^3.7.0",
|
|
127
132
|
"uqr": "^0.1.3"
|
|
128
133
|
},
|
|
129
134
|
"peerDependencies": {
|
|
135
|
+
"@dnd-kit/core": ">=6",
|
|
136
|
+
"@dnd-kit/sortable": ">=7",
|
|
137
|
+
"@dnd-kit/utilities": ">=3",
|
|
130
138
|
"@radix-ui/react-accordion": "*",
|
|
131
139
|
"@radix-ui/react-aspect-ratio": "*",
|
|
132
140
|
"@radix-ui/react-avatar": "*",
|
|
@@ -152,6 +160,7 @@
|
|
|
152
160
|
"@radix-ui/react-toggle": "*",
|
|
153
161
|
"@radix-ui/react-toggle-group": "*",
|
|
154
162
|
"@radix-ui/react-tooltip": "*",
|
|
163
|
+
"@tanstack/react-table": "^8",
|
|
155
164
|
"cmdk": "*",
|
|
156
165
|
"lucide-react": "*",
|
|
157
166
|
"next-themes": "*",
|
|
@@ -163,6 +172,15 @@
|
|
|
163
172
|
"sonner": "*"
|
|
164
173
|
},
|
|
165
174
|
"peerDependenciesMeta": {
|
|
175
|
+
"@dnd-kit/core": {
|
|
176
|
+
"optional": true
|
|
177
|
+
},
|
|
178
|
+
"@dnd-kit/sortable": {
|
|
179
|
+
"optional": true
|
|
180
|
+
},
|
|
181
|
+
"@dnd-kit/utilities": {
|
|
182
|
+
"optional": true
|
|
183
|
+
},
|
|
166
184
|
"@radix-ui/react-accordion": {
|
|
167
185
|
"optional": true
|
|
168
186
|
},
|
|
@@ -238,6 +256,9 @@
|
|
|
238
256
|
"@radix-ui/react-tooltip": {
|
|
239
257
|
"optional": true
|
|
240
258
|
},
|
|
259
|
+
"@tanstack/react-table": {
|
|
260
|
+
"optional": true
|
|
261
|
+
},
|
|
241
262
|
"cmdk": {
|
|
242
263
|
"optional": true
|
|
243
264
|
},
|
|
@@ -261,6 +282,6 @@
|
|
|
261
282
|
}
|
|
262
283
|
},
|
|
263
284
|
"devDependencies": {
|
|
264
|
-
"@types/react-dom": "^19.
|
|
285
|
+
"@types/react-dom": "^19.3.0"
|
|
265
286
|
}
|
|
266
|
-
}
|
|
287
|
+
}
|
package/scripts/a11y-lint.cjs
CHANGED
|
@@ -17,12 +17,13 @@
|
|
|
17
17
|
* 2.4.13 Focus Appearance — outline-none / focus:outline-none w/o replacement
|
|
18
18
|
* 3.3.2 Labels or Instructions — <input> without associated <Label> or aria-label
|
|
19
19
|
* 4.1.2 Name, Role, Value — <button> with no text and no aria-label
|
|
20
|
-
*
|
|
20
|
+
* BADS-WEIGHT Font weight floor — text-xs/text-sm must be font-medium (500) or heavier
|
|
21
21
|
*
|
|
22
22
|
* Run:
|
|
23
23
|
* bads-a11y-lint # report violations, exit 1 on fail
|
|
24
24
|
* bads-a11y-lint --warn # report but exit 0 (advisory)
|
|
25
25
|
* bads-a11y-lint path/to.tsx # scan a specific file
|
|
26
|
+
* bads-a11y-lint path/to/dir # scan every .tsx under a directory
|
|
26
27
|
*/
|
|
27
28
|
|
|
28
29
|
'use strict';
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
const fs = require('fs');
|
|
31
32
|
const path = require('path');
|
|
32
33
|
const { resolveScanFiles, guardEmptyScan } = require('./lib/scan-roots.cjs');
|
|
34
|
+
const { readSourceOfTruth } = require('./source-of-truth.cjs');
|
|
33
35
|
|
|
34
36
|
// Shipped as the `bads-a11y-lint` bin. process.cwd() means the same script
|
|
35
37
|
// scans the right tree whether it runs in upstream BADS (CWD = repo root) or
|
|
@@ -43,7 +45,42 @@ const { resolveScanFiles, guardEmptyScan } = require('./lib/scan-roots.cjs');
|
|
|
43
45
|
const ROOT = process.cwd();
|
|
44
46
|
const advisory = process.argv.includes('--warn');
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
// allowDirArgs: this script used to take file paths only (no directory-arg
|
|
49
|
+
// support, unlike size-audit/a11y-ratchet), but a positional directory
|
|
50
|
+
// argument wasn't rejected — it fell into resolveScanFiles' "explicit path"
|
|
51
|
+
// branch, got handed straight to fs.readFileSync, threw EISDIR, and the
|
|
52
|
+
// per-file try/catch below swallowed that as if the file just couldn't be
|
|
53
|
+
// read. `bads-a11y-lint <directory>` printed "no AAA violations found"
|
|
54
|
+
// having read zero files (found 2026-09-15, from a real consumer fork run —
|
|
55
|
+
// the exact false-green class this scan-roots module exists to prevent, just
|
|
56
|
+
// via a different door: an EXPLICIT arg treated as a file, not a missing
|
|
57
|
+
// default root). Turning this on makes a directory arg behave the same way
|
|
58
|
+
// it already does for size-audit and a11y-ratchet.
|
|
59
|
+
|
|
60
|
+
// Client-owned mode (.client-identity.json → sourceOfTruth.components ===
|
|
61
|
+
// "client") downgrades the AAA and house-opinion rules below to warnings —
|
|
62
|
+
// still reported, never silently dropped — while every Level A rule keeps
|
|
63
|
+
// blocking. See docs/superpowers/specs/2026-09-10-client-owned-components-design.md
|
|
64
|
+
// → "Accessibility floor: flag, do not enforce" and CLAUDE.md → Accessibility
|
|
65
|
+
// Floor. readSourceOfTruth() never throws and defaults to "bads" when there's
|
|
66
|
+
// no identity file, so upstream BADS and every fork that hasn't opted in see
|
|
67
|
+
// zero behaviour change.
|
|
68
|
+
const CLIENT_OWNED = readSourceOfTruth(ROOT).components === 'client';
|
|
69
|
+
|
|
70
|
+
// SC codes that are a matter of AAA standard or a BADS house opinion, not a
|
|
71
|
+
// Level A defect. 1.4.6 (hex-literal contrast), 1.4.4 (inline-px-font,
|
|
72
|
+
// tiny-text — BADS' 14px floor), 2.4.13 (focus-removed), BADS-WEIGHT (font
|
|
73
|
+
// weight floor) and BADS-CHART (hand-rolled chart) all belong here. The four
|
|
74
|
+
// Level A codes (1.1.1, 2.1.1, 2.4.4, 4.1.2) are deliberately absent — those
|
|
75
|
+
// are real defects in anyone's markup and keep blocking in every mode.
|
|
76
|
+
const WARN_IN_CLIENT_MODE = new Set(['1.4.4', '1.4.6', '2.4.13', 'BADS-WEIGHT', 'BADS-CHART']);
|
|
77
|
+
const CLIENT_OWNED_NOTE = ' (warned, not failed: components are client-owned)';
|
|
78
|
+
|
|
79
|
+
function isDowngraded(it) {
|
|
80
|
+
return CLIENT_OWNED && WARN_IN_CLIENT_MODE.has(it.sc);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const scan = resolveScanFiles({ root: ROOT, argv: process.argv.slice(2), allowDirArgs: true });
|
|
47
84
|
const files = scan.files;
|
|
48
85
|
|
|
49
86
|
const issues = [];
|
|
@@ -141,9 +178,24 @@ const VAGUE_LINK_TEXT = /^(?:click here|here|read more|learn more|more|click)\.?
|
|
|
141
178
|
// comment), so the violation only ever exists in this one upstream copy.
|
|
142
179
|
const SATORI_TOKEN_EXEMPT_FILE = /\bopengraph-image\.tsx$/;
|
|
143
180
|
|
|
181
|
+
// A file discovered via walk() (scan.mode 'default' | 'dir-args' | 'env') was
|
|
182
|
+
// just confirmed to exist and be a regular file by readdirSync moments ago —
|
|
183
|
+
// it cannot fail the read below. The only paths that can are explicit ones a
|
|
184
|
+
// user typed (scan.mode 'explicit'): a typo, a path that doesn't exist, a
|
|
185
|
+
// permissions error. Report those instead of silently dropping them — the
|
|
186
|
+
// same "explicit path silently produces zero findings" failure class as the
|
|
187
|
+
// directory-arg bug above, just triggered by a bad path instead of a good
|
|
188
|
+
// directory.
|
|
189
|
+
const unreadableExplicitPaths = [];
|
|
190
|
+
|
|
144
191
|
for (const file of files) {
|
|
145
192
|
let src;
|
|
146
|
-
try {
|
|
193
|
+
try {
|
|
194
|
+
src = fs.readFileSync(file, 'utf8');
|
|
195
|
+
} catch (err) {
|
|
196
|
+
if (scan.mode === 'explicit') unreadableExplicitPaths.push({ file, message: err.message });
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
147
199
|
// Skip generated files.
|
|
148
200
|
if (src.startsWith('/* GENERATED FROM tokens.json')) continue;
|
|
149
201
|
// Skip tests + e2e specs.
|
|
@@ -208,12 +260,12 @@ for (const file of files) {
|
|
|
208
260
|
`${step} resolves to ${TS.scale[step]}px under ${TS.label}, below the ${TEXT_FLOOR_PX}px AAA floor. Use ${TS.smallestCompliant} or larger, or add "// allow-small-text" above if a vendored component forces it.`);
|
|
209
261
|
}
|
|
210
262
|
|
|
211
|
-
//
|
|
263
|
+
// BADS-WEIGHT — small text (text-xs/text-sm, <18px) must be font-medium (500) or heavier.
|
|
212
264
|
if (TS.smallTextLightWeight && TS.smallTextLightWeight.test(line)
|
|
213
265
|
&& !/\/\/\s*allow-font-normal-small/.test(line)
|
|
214
266
|
&& !(i > 0 && /allow-font-normal-small/.test(lines[i - 1]))) {
|
|
215
|
-
flag(file, lineNum, '
|
|
216
|
-
`font-normal (or lighter) on a step below ${WEIGHT_FLOOR_PX}px (${TS.smallStepsDesc}).
|
|
267
|
+
flag(file, lineNum, 'BADS-WEIGHT', 'small-text-light-weight',
|
|
268
|
+
`font-normal (or lighter) on a step below ${WEIGHT_FLOOR_PX}px (${TS.smallStepsDesc}). Weight floor: font-medium (500) minimum. Add "// allow-font-normal-small" above to intentionally bypass.`);
|
|
217
269
|
}
|
|
218
270
|
|
|
219
271
|
if (FOCUS_OUTLINE_NONE.test(line) && !/ring-|outline-|focus-visible:/.test(line)) {
|
|
@@ -290,6 +342,17 @@ for (const file of files) {
|
|
|
290
342
|
|
|
291
343
|
// ---- output ------------------------------------------------------------
|
|
292
344
|
|
|
345
|
+
if (unreadableExplicitPaths.length) {
|
|
346
|
+
console.error(
|
|
347
|
+
`a11y-lint: ${unreadableExplicitPaths.length} path argument${unreadableExplicitPaths.length === 1 ? '' : 's'} ` +
|
|
348
|
+
`could not be read — nothing under ${unreadableExplicitPaths.length === 1 ? 'it was' : 'them was'} scanned:\n\n` +
|
|
349
|
+
unreadableExplicitPaths.map((p) => ` ${p.file} — ${p.message}`).join('\n') +
|
|
350
|
+
`\n\nA directory argument is walked automatically now — this means the path doesn't exist, ` +
|
|
351
|
+
`isn't readable, or is neither a file nor a directory.`
|
|
352
|
+
);
|
|
353
|
+
process.exit(1);
|
|
354
|
+
}
|
|
355
|
+
|
|
293
356
|
if (issues.length === 0) {
|
|
294
357
|
if (guardEmptyScan(scan, 'a11y-lint')) { /* exited */ }
|
|
295
358
|
console.log(
|
|
@@ -309,9 +372,26 @@ for (const file of Object.keys(grouped).sort()) {
|
|
|
309
372
|
console.log(`\n${file}`);
|
|
310
373
|
for (const it of grouped[file]) {
|
|
311
374
|
const tag = `[SC ${it.sc} ${it.rule}]`;
|
|
312
|
-
|
|
375
|
+
const note = isDowngraded(it) ? CLIENT_OWNED_NOTE : '';
|
|
376
|
+
console.log(` L${it.line} ${tag.padEnd(28)} ${it.message}${note}`);
|
|
313
377
|
}
|
|
314
378
|
}
|
|
315
379
|
|
|
380
|
+
const blocking = issues.filter((it) => !isDowngraded(it));
|
|
381
|
+
const downgraded = issues.length - blocking.length;
|
|
382
|
+
|
|
316
383
|
console.log(`\n${issues.length} issue${issues.length === 1 ? '' : 's'} across ${Object.keys(grouped).length} file${Object.keys(grouped).length === 1 ? '' : 's'}.`);
|
|
317
|
-
|
|
384
|
+
if (downgraded > 0) {
|
|
385
|
+
// Indented deliberately: a11y-ratchet.mjs parses this script's stdout and
|
|
386
|
+
// treats any *unindented* line that doesn't match /^\d+ issues?/ as a new
|
|
387
|
+
// file-header — an unindented "N of those are warned..." line would get
|
|
388
|
+
// mistaken for a bogus file path. Indenting keeps it inert to that parser
|
|
389
|
+
// (it fails the finding regex and is simply skipped) without changing the
|
|
390
|
+
// line the ratchet and bads-doctor.mjs already key off.
|
|
391
|
+
console.log(
|
|
392
|
+
` ${downgraded} of those ${downgraded === 1 ? 'is' : 'are'} warned, not failed: components are ` +
|
|
393
|
+
`client-owned (sourceOfTruth.components === "client"), so the AAA and BADS house-opinion floor ` +
|
|
394
|
+
`is informational here. ${blocking.length} blocking issue${blocking.length === 1 ? '' : 's'} remain${blocking.length === 1 ? 's' : ''}.`,
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
process.exit(advisory || blocking.length === 0 ? 0 : 1);
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* bads-components — flip the component ownership switch for a fork.
|
|
4
|
+
*
|
|
5
|
+
* pnpm bads:components-off --library @/components/acme [--docs URL] [--scan-roots app,components/acme]
|
|
6
|
+
* pnpm bads:components-on
|
|
7
|
+
*
|
|
8
|
+
* It writes `.client-identity.json`, and it patches the fork's CLAUDE.md in
|
|
9
|
+
* place. That patch is not a convenience: CLAUDE.md is fork-owned and never
|
|
10
|
+
* syncs over npm, so editing the fork's own copy is the ONLY way the agent
|
|
11
|
+
* layer of this feature reaches an existing fork.
|
|
12
|
+
*/
|
|
13
|
+
import { readFileSync, writeFileSync, existsSync } from "node:fs";
|
|
14
|
+
import { join } from "node:path";
|
|
15
|
+
|
|
16
|
+
const ROOT = process.cwd();
|
|
17
|
+
const IDENTITY = join(ROOT, ".client-identity.json");
|
|
18
|
+
const CLAUDE = join(ROOT, "CLAUDE.md");
|
|
19
|
+
const OPEN = "<!-- bads:component-ownership -->";
|
|
20
|
+
const CLOSE = "<!-- /bads:component-ownership -->";
|
|
21
|
+
|
|
22
|
+
const [command, ...rest] = process.argv.slice(2);
|
|
23
|
+
const flag = (name) => {
|
|
24
|
+
const i = rest.indexOf(`--${name}`);
|
|
25
|
+
return i === -1 ? null : rest[i + 1] ?? null;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function die(message) {
|
|
29
|
+
console.error(`FAIL bads-components: ${message}`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!["on", "off"].includes(command)) {
|
|
34
|
+
console.error("Usage: bads-components off --library <specifier> [--docs <url>] [--scan-roots a,b]");
|
|
35
|
+
console.error(" bads-components on");
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!existsSync(IDENTITY)) {
|
|
40
|
+
die("no .client-identity.json here. Run `pnpm rename \"<Name>\" <slug>` first; this switch is a fork setting, not an upstream one.");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const identity = JSON.parse(readFileSync(IDENTITY, "utf8"));
|
|
44
|
+
|
|
45
|
+
function section(library, docs) {
|
|
46
|
+
return [
|
|
47
|
+
OPEN,
|
|
48
|
+
"",
|
|
49
|
+
"## Component ownership",
|
|
50
|
+
"",
|
|
51
|
+
`**This fork's components are client-owned.** They come from \`${library}\`${docs ? ` (docs: ${docs})` : ""}.`,
|
|
52
|
+
"",
|
|
53
|
+
"- Do not propose, build, or reach for a BADS primitive. Use the client's library.",
|
|
54
|
+
"- Do not add entries to `layer-5-component-registry/component-registry.json`.",
|
|
55
|
+
"- Do not run the component-builder skill against `@behavioral-agentic-design-system/core`.",
|
|
56
|
+
"- `pnpm lint:component-source` enforces this. The escape hatch is `// allow-bads-component <reason>`.",
|
|
57
|
+
"",
|
|
58
|
+
"Everything else in BADS still applies: the AAA accessibility floor, the CTA size contract, voice and tone, the ethics layers, the futures check, and the slop lint. Those are what this engagement is buying.",
|
|
59
|
+
"",
|
|
60
|
+
CLOSE,
|
|
61
|
+
].join("\n");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function patchClaudeMd(block) {
|
|
65
|
+
if (!existsSync(CLAUDE)) {
|
|
66
|
+
console.log(" note: no CLAUDE.md here, skipping the agent-layer patch.");
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const current = readFileSync(CLAUDE, "utf8");
|
|
70
|
+
const start = current.indexOf(OPEN);
|
|
71
|
+
const end = current.indexOf(CLOSE);
|
|
72
|
+
|
|
73
|
+
if (start !== -1 && end !== -1) {
|
|
74
|
+
const next = current.slice(0, start) + (block ?? "").trimEnd() + current.slice(end + CLOSE.length);
|
|
75
|
+
writeFileSync(CLAUDE, block ? next : next.replace(/\n{3,}/g, "\n\n"));
|
|
76
|
+
} else if (block) {
|
|
77
|
+
writeFileSync(CLAUDE, `${current.trimEnd()}\n\n${block}\n`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (command === "off") {
|
|
82
|
+
const library = flag("library");
|
|
83
|
+
if (!library) die("`off` needs --library <specifier>. It accepts an npm package (@acme/ui) or a path alias (@/components/acme).");
|
|
84
|
+
|
|
85
|
+
const docs = flag("docs");
|
|
86
|
+
const scanRoots = (flag("scan-roots") || "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
87
|
+
|
|
88
|
+
identity.sourceOfTruth = {
|
|
89
|
+
components: "client",
|
|
90
|
+
clientLibrary: library,
|
|
91
|
+
...(docs ? { clientDocs: docs } : {}),
|
|
92
|
+
...(scanRoots.length ? { scanRoots } : {}),
|
|
93
|
+
};
|
|
94
|
+
writeFileSync(IDENTITY, JSON.stringify(identity, null, 2) + "\n");
|
|
95
|
+
patchClaudeMd(section(library, docs));
|
|
96
|
+
|
|
97
|
+
console.log(`OK bads-components: components are now client-owned (${library}).`);
|
|
98
|
+
console.log(" - lint:component-source is now active");
|
|
99
|
+
console.log(` - it scans ${scanRoots.length ? scanRoots.join(", ") : "app/ (pass --scan-roots to widen)"}`);
|
|
100
|
+
console.log(" - CLAUDE.md now carries the component-ownership section");
|
|
101
|
+
} else {
|
|
102
|
+
delete identity.sourceOfTruth;
|
|
103
|
+
writeFileSync(IDENTITY, JSON.stringify(identity, null, 2) + "\n");
|
|
104
|
+
patchClaudeMd(null);
|
|
105
|
+
console.log("OK bads-components: BADS owns components again.");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Follow-ups this script cannot perform, because they live at the fork's repo
|
|
109
|
+
// root and this script does not own that code.
|
|
110
|
+
for (const [path, pattern, note] of [
|
|
111
|
+
["app/page.tsx", /DEFAULT_TABS/, "references DEFAULT_TABS directly; it needs visibleTabs() to drop the component tabs"],
|
|
112
|
+
[".storybook/main.ts", /core\/src\/stories/, "still globs the BADS component stories"],
|
|
113
|
+
]) {
|
|
114
|
+
const full = join(ROOT, path);
|
|
115
|
+
if (existsSync(full) && pattern.test(readFileSync(full, "utf8"))) {
|
|
116
|
+
console.log(` follow-up: ${path} ${note}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
package/scripts/build-tokens.cjs
CHANGED
|
@@ -362,10 +362,18 @@ const themeInline = `@theme inline {
|
|
|
362
362
|
:root above already defines --font-sans, and Tailwind picks it up
|
|
363
363
|
for the font-sans utility automatically. */
|
|
364
364
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
365
|
+
/* Per-step override hook, same shape as the type scale above: a fork whose
|
|
366
|
+
brand radius ramp isn't linear-from-one-base (e.g. Furnished Finder's
|
|
367
|
+
4/8/12/16, which no single --radius value produces from these calc()s)
|
|
368
|
+
sets --radius-sm-size etc. directly. Also closes the duplicate-value
|
|
369
|
+
trap this used to have — a brand file that declared --radius-lg in
|
|
370
|
+
:root created a second, silently-losing value under the same name as
|
|
371
|
+
this computed one; the override name is now distinct from the utility
|
|
372
|
+
name it feeds. */
|
|
373
|
+
--radius-sm: var(--radius-sm-size, calc(var(--radius) - 4px));
|
|
374
|
+
--radius-md: var(--radius-md-size, calc(var(--radius) - 2px));
|
|
375
|
+
--radius-lg: var(--radius-lg-size, var(--radius));
|
|
376
|
+
--radius-xl: var(--radius-xl-size, calc(var(--radius) + 4px));
|
|
369
377
|
|
|
370
378
|
/* Map Tailwind's shadow-* utilities through to the :root --shadow-* tokens
|
|
371
379
|
so the Customize tab's Shadow Opacity slider takes effect. Without this
|
|
@@ -418,12 +426,15 @@ const themeInline = `@theme inline {
|
|
|
418
426
|
/* Marketing tier — display sizes for landing pages, hero blocks, editorial.
|
|
419
427
|
Tailwind only emits utilities that get used, so a non-marketing fork pays
|
|
420
428
|
nothing for these. line-height drops to 1.1 at scale to keep big type
|
|
421
|
-
readable; tracking tightens slightly to compensate for optical loosening.
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
--text-
|
|
426
|
-
--text-
|
|
429
|
+
readable; tracking tightens slightly to compensate for optical loosening.
|
|
430
|
+
Same --text-*-size override hook as the body tier above, so a fork with
|
|
431
|
+
its own display scale (corrections.md-class drift otherwise) can retarget
|
|
432
|
+
these steps too instead of hitting a cliff at text-4xl. */
|
|
433
|
+
--text-4xl: calc(var(--text-4xl-size, ${text4xl}) * var(--font-size-scale, 1));
|
|
434
|
+
--text-5xl: calc(var(--text-5xl-size, ${text5xl}) * var(--font-size-scale, 1));
|
|
435
|
+
--text-6xl: calc(var(--text-6xl-size, ${text6xl}) * var(--font-size-scale, 1));
|
|
436
|
+
--text-7xl: calc(var(--text-7xl-size, ${text7xl}) * var(--font-size-scale, 1));
|
|
437
|
+
--text-8xl: calc(var(--text-8xl-size, ${text8xl}) * var(--font-size-scale, 1));
|
|
427
438
|
--text-4xl--line-height: 1.15;
|
|
428
439
|
--text-5xl--line-height: 1.10;
|
|
429
440
|
--text-6xl--line-height: 1.05;
|
|
@@ -517,8 +528,19 @@ const baseLayer = `@layer base {
|
|
|
517
528
|
body { transition: none; }
|
|
518
529
|
}
|
|
519
530
|
/* WCAG AAA 1.4.8: paragraph spacing ≥ 1.5× line-height inside running
|
|
520
|
-
text.
|
|
521
|
-
|
|
531
|
+
text. Last-child has no trailing margin so containers don't get extra
|
|
532
|
+
padding.
|
|
533
|
+
|
|
534
|
+
"UI primitives stay tight" is NOT this rule's doing — it is the flex/grid
|
|
535
|
+
carve-out immediately below, and you cannot tell that by reading this
|
|
536
|
+
selector. Measured 2026-09-11 across all eight rail destinations: exactly
|
|
537
|
+
18 paragraphs in the whole app compute to 1.5em, all of them section
|
|
538
|
+
descriptions on the Components showcase, which is running text and is
|
|
539
|
+
what the rule is for. EmptyState, Stepper, Questionnaire, FileUpload and
|
|
540
|
+
HoverCard all compute to margin-bottom 0 because their content sits in a
|
|
541
|
+
flex column. Every one of those five had been reported as "loosened by
|
|
542
|
+
this rule" from counting <p> tags in source rather than reading the DOM.
|
|
543
|
+
If you are about to rescope or delete this rule, measure first. */
|
|
522
544
|
p:not(:last-child) {
|
|
523
545
|
margin-bottom: 1.5em;
|
|
524
546
|
}
|
|
@@ -882,6 +904,105 @@ html, body {
|
|
|
882
904
|
animation: progress-stripe var(--progress-stripe-duration, 1s) linear infinite;
|
|
883
905
|
}
|
|
884
906
|
|
|
907
|
+
/* Presence enter/exit keyframes — applied via the data-slot + data-transition
|
|
908
|
+
+ data-state selectors the Presence primitive sets (spec §4 pattern (b):
|
|
909
|
+
plain CSS in the design-system layer, no Tailwind utility generation in
|
|
910
|
+
the path). The component flips data-state to "closed" and waits on
|
|
911
|
+
element.getAnimations() before unmounting, so the -out keyframe is what
|
|
912
|
+
the user actually sees.
|
|
913
|
+
|
|
914
|
+
- fill-mode "both" is load-bearing: the -out keyframe must HOLD its final
|
|
915
|
+
frame (opacity 0) until React commits the unmount, otherwise the element
|
|
916
|
+
pops back to fully visible for one frame after animationend.
|
|
917
|
+
- Translate distances are small (0.5rem) so the motion reads as a settle,
|
|
918
|
+
not a slide; scale starts at .96 for the same reason.
|
|
919
|
+
- Reduced motion: the base layer forces animation-duration to 0.01ms; the
|
|
920
|
+
finished promise still resolves, so the unmount is effectively instant. */
|
|
921
|
+
@keyframes presence-fade-in {
|
|
922
|
+
from { opacity: 0; }
|
|
923
|
+
to { opacity: 1; }
|
|
924
|
+
}
|
|
925
|
+
@keyframes presence-fade-out {
|
|
926
|
+
from { opacity: 1; }
|
|
927
|
+
to { opacity: 0; }
|
|
928
|
+
}
|
|
929
|
+
@keyframes presence-scale-in {
|
|
930
|
+
from { opacity: 0; transform: scale(0.96); }
|
|
931
|
+
to { opacity: 1; transform: scale(1); }
|
|
932
|
+
}
|
|
933
|
+
@keyframes presence-scale-out {
|
|
934
|
+
from { opacity: 1; transform: scale(1); }
|
|
935
|
+
to { opacity: 0; transform: scale(0.96); }
|
|
936
|
+
}
|
|
937
|
+
@keyframes presence-slide-up-in {
|
|
938
|
+
from { opacity: 0; transform: translateY(0.5rem); }
|
|
939
|
+
to { opacity: 1; transform: translateY(0); }
|
|
940
|
+
}
|
|
941
|
+
@keyframes presence-slide-up-out {
|
|
942
|
+
from { opacity: 1; transform: translateY(0); }
|
|
943
|
+
to { opacity: 0; transform: translateY(0.5rem); }
|
|
944
|
+
}
|
|
945
|
+
@keyframes presence-slide-down-in {
|
|
946
|
+
from { opacity: 0; transform: translateY(-0.5rem); }
|
|
947
|
+
to { opacity: 1; transform: translateY(0); }
|
|
948
|
+
}
|
|
949
|
+
@keyframes presence-slide-down-out {
|
|
950
|
+
from { opacity: 1; transform: translateY(0); }
|
|
951
|
+
to { opacity: 0; transform: translateY(-0.5rem); }
|
|
952
|
+
}
|
|
953
|
+
@keyframes presence-slide-left-in {
|
|
954
|
+
from { opacity: 0; transform: translateX(0.5rem); }
|
|
955
|
+
to { opacity: 1; transform: translateX(0); }
|
|
956
|
+
}
|
|
957
|
+
@keyframes presence-slide-left-out {
|
|
958
|
+
from { opacity: 1; transform: translateX(0); }
|
|
959
|
+
to { opacity: 0; transform: translateX(0.5rem); }
|
|
960
|
+
}
|
|
961
|
+
@keyframes presence-slide-right-in {
|
|
962
|
+
from { opacity: 0; transform: translateX(-0.5rem); }
|
|
963
|
+
to { opacity: 1; transform: translateX(0); }
|
|
964
|
+
}
|
|
965
|
+
@keyframes presence-slide-right-out {
|
|
966
|
+
from { opacity: 1; transform: translateX(0); }
|
|
967
|
+
to { opacity: 0; transform: translateX(-0.5rem); }
|
|
968
|
+
}
|
|
969
|
+
[data-slot="presence"][data-transition="fade"][data-state="open"] {
|
|
970
|
+
animation: presence-fade-in var(--duration-base) var(--ease-out) both;
|
|
971
|
+
}
|
|
972
|
+
[data-slot="presence"][data-transition="fade"][data-state="closed"] {
|
|
973
|
+
animation: presence-fade-out var(--duration-base) var(--ease-out) both;
|
|
974
|
+
}
|
|
975
|
+
[data-slot="presence"][data-transition="scale"][data-state="open"] {
|
|
976
|
+
animation: presence-scale-in var(--duration-base) var(--ease-out) both;
|
|
977
|
+
}
|
|
978
|
+
[data-slot="presence"][data-transition="scale"][data-state="closed"] {
|
|
979
|
+
animation: presence-scale-out var(--duration-base) var(--ease-out) both;
|
|
980
|
+
}
|
|
981
|
+
[data-slot="presence"][data-transition="slide-up"][data-state="open"] {
|
|
982
|
+
animation: presence-slide-up-in var(--duration-base) var(--ease-out) both;
|
|
983
|
+
}
|
|
984
|
+
[data-slot="presence"][data-transition="slide-up"][data-state="closed"] {
|
|
985
|
+
animation: presence-slide-up-out var(--duration-base) var(--ease-out) both;
|
|
986
|
+
}
|
|
987
|
+
[data-slot="presence"][data-transition="slide-down"][data-state="open"] {
|
|
988
|
+
animation: presence-slide-down-in var(--duration-base) var(--ease-out) both;
|
|
989
|
+
}
|
|
990
|
+
[data-slot="presence"][data-transition="slide-down"][data-state="closed"] {
|
|
991
|
+
animation: presence-slide-down-out var(--duration-base) var(--ease-out) both;
|
|
992
|
+
}
|
|
993
|
+
[data-slot="presence"][data-transition="slide-left"][data-state="open"] {
|
|
994
|
+
animation: presence-slide-left-in var(--duration-base) var(--ease-out) both;
|
|
995
|
+
}
|
|
996
|
+
[data-slot="presence"][data-transition="slide-left"][data-state="closed"] {
|
|
997
|
+
animation: presence-slide-left-out var(--duration-base) var(--ease-out) both;
|
|
998
|
+
}
|
|
999
|
+
[data-slot="presence"][data-transition="slide-right"][data-state="open"] {
|
|
1000
|
+
animation: presence-slide-right-in var(--duration-base) var(--ease-out) both;
|
|
1001
|
+
}
|
|
1002
|
+
[data-slot="presence"][data-transition="slide-right"][data-state="closed"] {
|
|
1003
|
+
animation: presence-slide-right-out var(--duration-base) var(--ease-out) both;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
885
1006
|
/* Prose — long-form typographic rhythm for arbitrary HTML descendants
|
|
886
1007
|
(MDX output, CMS articles, rendered markdown). Keyed off the .prose
|
|
887
1008
|
class the Prose primitive (data-slot="prose") applies — same
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* co-located story at components/<PascalCase>.stories.tsx (matching upstream
|
|
19
19
|
* pairs like components/activity-feed.tsx + components/ActivityFeed.stories.tsx),
|
|
20
20
|
* and this also covers exactly one level of subdirectory, the depth at
|
|
21
|
-
* which a fork vendors its own components (components/
|
|
21
|
+
* which a fork vendors its own components (components/acme/*.tsx),
|
|
22
22
|
* accepting a story at either the co-located subdirectory path or the
|
|
23
23
|
* top-level components/<PascalCase>.stories.tsx path, since only the
|
|
24
24
|
* top-level location is guaranteed to actually render in Storybook today.
|
|
@@ -201,8 +201,22 @@ function main() {
|
|
|
201
201
|
}
|
|
202
202
|
if (showcase === null) {
|
|
203
203
|
penalties.push({ source: "showcase", points: 0, why: "showcase-presence signal unavailable (showcase page not found locally or in the package)" });
|
|
204
|
-
} else
|
|
205
|
-
|
|
204
|
+
} else {
|
|
205
|
+
// The registry key is not always the JSX tag rendered in the showcase
|
|
206
|
+
// (TreeView's primitive exports as <Tree>, not <TreeView> — same alias
|
|
207
|
+
// gap as corrections.md #009/#010, caught 2026-10-05 when TreeView
|
|
208
|
+
// scored a false "not demonstrated" despite a full showcase section
|
|
209
|
+
// titled "Tree View"). Check every costModel.jsxNames alias too, and
|
|
210
|
+
// loosen the title match to ignore case/spacing so "Tree View" matches
|
|
211
|
+
// "TreeView".
|
|
212
|
+
const aliases = [name, ...(e.costModel?.jsxNames ?? [])];
|
|
213
|
+
const looseTitle = new RegExp(`title=["']${name.replace(/\s+/g, "")}["']`, "i");
|
|
214
|
+
const demonstrated =
|
|
215
|
+
aliases.some((a) => showcase.includes(`<${a}`) || showcase.includes(`${a}Showcase`)) ||
|
|
216
|
+
looseTitle.test(showcase.replace(/\s+/g, ""));
|
|
217
|
+
if (!demonstrated) {
|
|
218
|
+
penalties.push({ source: "showcase", points: 5, why: "not demonstrated in the components showcase" });
|
|
219
|
+
}
|
|
206
220
|
}
|
|
207
221
|
}
|
|
208
222
|
|