@behavioral-agentic-design-system/core 0.8.4 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -1
- package/scripts/build-fonts.cjs +26 -3
- package/scripts/build-tokens.cjs +68 -6
- package/src/api/brand-fonts.ts +20 -10
- package/src/api/layers/file.ts +39 -4
- package/src/app/preview/components/page.tsx +718 -1
- package/src/app/shell.tsx +61 -15
- package/src/components/brand-mark.tsx +1 -1
- package/src/components/docs-tab.tsx +497 -0
- package/src/components/home-tab.tsx +341 -2043
- package/src/components/layers-tab.tsx +3 -91
- package/src/components/markdown-preview.tsx +226 -0
- package/src/components/motion/chart-reveal.tsx +164 -0
- package/src/components/motion/reveal.tsx +156 -0
- package/src/components/ui/accordion.tsx +117 -0
- package/src/components/ui/alert-dialog.tsx +162 -0
- package/src/components/ui/carousel.tsx +357 -0
- package/src/components/ui/context-menu.tsx +258 -0
- package/src/components/ui/file-upload.tsx +278 -0
- package/src/components/ui/index.ts +10 -0
- package/src/components/ui/navigation-menu.tsx +154 -0
- package/src/components/ui/number-input.tsx +229 -0
- package/src/components/ui/pagination.tsx +143 -0
- package/src/components/ui/pin-input.tsx +257 -0
- package/src/components/ui/sheet.tsx +10 -4
- package/src/components/ui/spinner.tsx +70 -0
- package/src/components/ui/stepper.tsx +272 -0
- package/src/data/docs-index.ts +163 -0
- package/src/hooks/use-reduced-motion.ts +13 -0
- package/src/styles.css +56 -6
- package/src/tokens.json +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behavioral-agentic-design-system/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
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)",
|
|
@@ -52,6 +52,8 @@
|
|
|
52
52
|
"./tokens.default.json": "./src/tokens.default.json",
|
|
53
53
|
"./lib/*": "./src/lib/*.ts",
|
|
54
54
|
"./hooks/*": "./src/hooks/*.ts",
|
|
55
|
+
"./data/*": "./src/data/*.ts",
|
|
56
|
+
"./components/*": "./src/components/*.tsx",
|
|
55
57
|
"./components/ui": "./src/components/ui/index.ts",
|
|
56
58
|
"./components/ui/*": "./src/components/ui/*.tsx",
|
|
57
59
|
"./components/customize-tab": "./src/components/customize-tab.tsx",
|
|
@@ -62,6 +64,7 @@
|
|
|
62
64
|
"./components/dev-identity-badge": "./src/components/dev-identity-badge.tsx",
|
|
63
65
|
"./components/onboarding-wizard": "./src/components/onboarding-wizard.tsx",
|
|
64
66
|
"./components/customize/*": "./src/components/customize/*.tsx",
|
|
67
|
+
"./components/motion/*": "./src/components/motion/*.tsx",
|
|
65
68
|
"./components/Foundations/*": "./src/components/Foundations/*.tsx",
|
|
66
69
|
"./app/page": "./src/app/page.tsx",
|
|
67
70
|
"./app/shell": "./src/app/shell.tsx",
|
|
@@ -92,6 +95,7 @@
|
|
|
92
95
|
"access": "public"
|
|
93
96
|
},
|
|
94
97
|
"dependencies": {
|
|
98
|
+
"@radix-ui/react-alert-dialog": "^1.1.16",
|
|
95
99
|
"@xmldom/xmldom": "^0.9.10",
|
|
96
100
|
"cheerio": "^1.0.0",
|
|
97
101
|
"class-variance-authority": "^0.7.0",
|
|
@@ -101,10 +105,13 @@
|
|
|
101
105
|
"tailwind-merge": "^3.0.0"
|
|
102
106
|
},
|
|
103
107
|
"peerDependencies": {
|
|
108
|
+
"@radix-ui/react-accordion": "*",
|
|
104
109
|
"@radix-ui/react-avatar": "*",
|
|
105
110
|
"@radix-ui/react-checkbox": "*",
|
|
106
111
|
"@radix-ui/react-collapsible": "*",
|
|
112
|
+
"@radix-ui/react-context-menu": "*",
|
|
107
113
|
"@radix-ui/react-dialog": "*",
|
|
114
|
+
"@radix-ui/react-navigation-menu": "*",
|
|
108
115
|
"@radix-ui/react-dropdown-menu": "*",
|
|
109
116
|
"@radix-ui/react-label": "*",
|
|
110
117
|
"@radix-ui/react-popover": "*",
|
|
@@ -131,6 +138,9 @@
|
|
|
131
138
|
"sonner": "*"
|
|
132
139
|
},
|
|
133
140
|
"peerDependenciesMeta": {
|
|
141
|
+
"@radix-ui/react-accordion": {
|
|
142
|
+
"optional": true
|
|
143
|
+
},
|
|
134
144
|
"@radix-ui/react-avatar": {
|
|
135
145
|
"optional": true
|
|
136
146
|
},
|
|
@@ -140,9 +150,15 @@
|
|
|
140
150
|
"@radix-ui/react-collapsible": {
|
|
141
151
|
"optional": true
|
|
142
152
|
},
|
|
153
|
+
"@radix-ui/react-context-menu": {
|
|
154
|
+
"optional": true
|
|
155
|
+
},
|
|
143
156
|
"@radix-ui/react-dialog": {
|
|
144
157
|
"optional": true
|
|
145
158
|
},
|
|
159
|
+
"@radix-ui/react-navigation-menu": {
|
|
160
|
+
"optional": true
|
|
161
|
+
},
|
|
146
162
|
"@radix-ui/react-dropdown-menu": {
|
|
147
163
|
"optional": true
|
|
148
164
|
},
|
package/scripts/build-fonts.cjs
CHANGED
|
@@ -54,15 +54,38 @@ function escapeFamily(label) {
|
|
|
54
54
|
return `'${String(label).replace(/'/g, "\\'")}'`;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
// Known src formats. Variable faces use the `-variations` formats and a
|
|
58
|
+
// weight RANGE; static faces use woff2/woff + a single numeric weight. Both
|
|
59
|
+
// are emitted by the same function — the schema just carries more fields for
|
|
60
|
+
// a variable font.
|
|
61
|
+
// Allowlist of accepted source formats; anything else falls back to woff2.
|
|
62
|
+
const SRC_FORMATS = new Set([
|
|
63
|
+
'woff2',
|
|
64
|
+
'woff',
|
|
65
|
+
'woff2-variations',
|
|
66
|
+
'truetype-variations',
|
|
67
|
+
'truetype',
|
|
68
|
+
'opentype',
|
|
69
|
+
]);
|
|
70
|
+
|
|
57
71
|
function emitFace(family, file) {
|
|
58
|
-
const format = file.format
|
|
72
|
+
const format = SRC_FORMATS.has(file.format) ? file.format : 'woff2';
|
|
73
|
+
// weight: a number (static face) OR a "min max" range string (variable
|
|
74
|
+
// face, e.g. "300 900"). Emitted as-is so both shapes pass through.
|
|
59
75
|
const weight = file.weight ?? 400;
|
|
60
|
-
|
|
76
|
+
// style: "normal" | "italic" | a range like "oblique 0deg 12deg" (variable).
|
|
77
|
+
const rawStyle = String(file.style ?? '').trim();
|
|
78
|
+
const style = rawStyle === 'italic' || /\s/.test(rawStyle) ? rawStyle : 'normal';
|
|
79
|
+
// variationSettings: optional default axis settings, e.g. "'opsz' 18".
|
|
80
|
+
// Lets a fork pin a variable axis on the brand face without app-level CSS.
|
|
81
|
+
const variation = file.variationSettings
|
|
82
|
+
? `\n font-variation-settings: ${file.variationSettings};`
|
|
83
|
+
: '';
|
|
61
84
|
return `@font-face {
|
|
62
85
|
font-family: ${family};
|
|
63
86
|
src: url('${file.path}') format('${format}');
|
|
64
87
|
font-weight: ${weight};
|
|
65
|
-
font-style: ${style}
|
|
88
|
+
font-style: ${style};${variation}
|
|
66
89
|
font-display: swap;
|
|
67
90
|
}`;
|
|
68
91
|
}
|
package/scripts/build-tokens.cjs
CHANGED
|
@@ -151,6 +151,18 @@ const shadowAlpha = (lvl) =>
|
|
|
151
151
|
shadowMul(lvl, '1') === '1.0' || shadowMul(lvl, '1') === '1'
|
|
152
152
|
? `var(--shadow-opacity)`
|
|
153
153
|
: `calc(var(--shadow-opacity) * ${shadowMul(lvl, '1')})`;
|
|
154
|
+
// Explicit shadow override — if tokens.json defines `shadow.<level>.$value`
|
|
155
|
+
// as a literal CSS shadow string, use it verbatim instead of generating
|
|
156
|
+
// from the opacity-multiplier rhythm. Lets a brand define an elevated
|
|
157
|
+
// lifted shadow (e.g. `0 10px 30px -12px ...`) at the 2xl tier without
|
|
158
|
+
// changing every other tier or the runtime opacity slider.
|
|
159
|
+
const shadowExplicit = (lvl) => {
|
|
160
|
+
const v = tokens.shadow?.[lvl]?.$value;
|
|
161
|
+
return typeof v === 'string' && v.includes('px') ? v : null;
|
|
162
|
+
};
|
|
163
|
+
const shadowDefault2xl =
|
|
164
|
+
shadowExplicit('2xl') ??
|
|
165
|
+
`0 1px 3px 0px hsl(0 0% 0% / ${shadowAlpha('2xl')}), 0 16px 24px -1px hsl(0 0% 0% / ${shadowAlpha('2xl')})`;
|
|
154
166
|
const shadowBlock = ` --shadow-opacity: ${shadowOpacity};
|
|
155
167
|
--shadow-2xs: 0 1px 3px 0px hsl(0 0% 0% / ${shadowAlpha('2xs')});
|
|
156
168
|
--shadow-xs: 0 1px 3px 0px hsl(0 0% 0% / ${shadowAlpha('xs')});
|
|
@@ -159,7 +171,7 @@ const shadowBlock = ` --shadow-opacity: ${shadowOpacity};
|
|
|
159
171
|
--shadow-md: 0 1px 3px 0px hsl(0 0% 0% / ${shadowAlpha('md')}), 0 2px 4px -1px hsl(0 0% 0% / ${shadowAlpha('md')});
|
|
160
172
|
--shadow-lg: 0 1px 3px 0px hsl(0 0% 0% / ${shadowAlpha('lg')}), 0 4px 6px -1px hsl(0 0% 0% / ${shadowAlpha('lg')});
|
|
161
173
|
--shadow-xl: 0 1px 3px 0px hsl(0 0% 0% / ${shadowAlpha('xl')}), 0 8px 10px -1px hsl(0 0% 0% / ${shadowAlpha('xl')});
|
|
162
|
-
--shadow-2xl:
|
|
174
|
+
--shadow-2xl: ${shadowDefault2xl};`;
|
|
163
175
|
|
|
164
176
|
// Animation tokens emitted into :root from tokens.json. Components reference
|
|
165
177
|
// var(--duration-*) and var(--ease-*) so Sir's edits in tokens.json (or any
|
|
@@ -336,6 +348,14 @@ const themeInline = `@theme inline {
|
|
|
336
348
|
--ease-spring-snappy: var(--spring-snappy);
|
|
337
349
|
--ease-spring-bounce: var(--spring-bounce);
|
|
338
350
|
|
|
351
|
+
/* Animation utilities — declared here for token reference / future
|
|
352
|
+
Tailwind v4 utility generation when reliable. Currently the
|
|
353
|
+
accordion-up/down keyframes are applied via direct CSS selectors
|
|
354
|
+
keyed off Radix's data-slot + data-state attributes (see the
|
|
355
|
+
keyframe block below) — that's the deterministic path while we
|
|
356
|
+
verify which @theme inline patterns Tailwind v4 reliably generates
|
|
357
|
+
utilities for in this setup. */
|
|
358
|
+
|
|
339
359
|
/* Accessibility floor — minimum 14px for text-xs (vs Tailwind's 12px default).
|
|
340
360
|
Font sizes are dynamically computed by useGlobalTypeScale hook and set as
|
|
341
361
|
--text-xs-size, --text-sm-size, etc. These are then scaled by --font-size-scale
|
|
@@ -578,7 +598,26 @@ html, body {
|
|
|
578
598
|
|
|
579
599
|
/* Theme toggle: iris reveal via View Transitions API. The click coords are
|
|
580
600
|
written to --x / --y on <html> before startViewTransition fires (see
|
|
581
|
-
app/page.tsx toggleDark).
|
|
601
|
+
app/page.tsx toggleDark).
|
|
602
|
+
|
|
603
|
+
Two deliberate choices, both learned the hard way (swimtopia, 2026-06):
|
|
604
|
+
1. Radius is a VIEWPORT unit (150vmax), not a percentage. circle(150%)
|
|
605
|
+
resolves against the snapshot box, so on a large/wide desktop the wipe
|
|
606
|
+
can finish before it has covered the viewport — a glitch at the END of
|
|
607
|
+
the animation that only shows on big displays. 150vmax always overshoots
|
|
608
|
+
the farthest corner of any viewport (diagonal <= sqrt(2)*vmax < 1.5vmax),
|
|
609
|
+
AND is box-independent, so if a fork names sticky chrome as its own
|
|
610
|
+
view-transition group the radius matches the root exactly (no seam).
|
|
611
|
+
2. PURE clip-path reveal, no opacity fade. A 0.7->1 opacity blend makes the
|
|
612
|
+
growing edge translucent, showing the old theme through the new — which
|
|
613
|
+
paints a muddy grey smear (worst dark->light). The wipe should be a crisp
|
|
614
|
+
hard edge at full opacity.
|
|
615
|
+
|
|
616
|
+
Forks with sticky chrome (a sidebar / top bar that stays put while the page
|
|
617
|
+
scrolls): see CLAUDE.md -> "Theme transition and sticky chrome" before
|
|
618
|
+
naming any chrome. NEVER give a backdrop-filter element a view-transition-
|
|
619
|
+
name (its snapshot has no backdrop to sample and rasterizes as an opaque
|
|
620
|
+
white flash). */
|
|
582
621
|
::view-transition-old(root),
|
|
583
622
|
::view-transition-new(root) {
|
|
584
623
|
animation: none;
|
|
@@ -589,15 +628,38 @@ html, body {
|
|
|
589
628
|
|
|
590
629
|
@keyframes theme-reveal {
|
|
591
630
|
from {
|
|
592
|
-
clip-path: circle(0
|
|
593
|
-
opacity: 0.7;
|
|
631
|
+
clip-path: circle(0 at var(--x, 50%) var(--y, 50%));
|
|
594
632
|
}
|
|
595
633
|
to {
|
|
596
|
-
clip-path: circle(
|
|
597
|
-
opacity: 1;
|
|
634
|
+
clip-path: circle(150vmax at var(--x, 50%) var(--y, 50%));
|
|
598
635
|
}
|
|
599
636
|
}
|
|
600
637
|
|
|
638
|
+
/* Accordion disclosure keyframes — used by Radix-based AccordionContent.
|
|
639
|
+
Radix injects the actual content height as \`--radix-accordion-content-height\`
|
|
640
|
+
at runtime, which these keyframes interpolate against. Duration + timing
|
|
641
|
+
come from BADS motion tokens. */
|
|
642
|
+
@keyframes accordion-down {
|
|
643
|
+
from { height: 0; }
|
|
644
|
+
to { height: var(--radix-accordion-content-height); }
|
|
645
|
+
}
|
|
646
|
+
@keyframes accordion-up {
|
|
647
|
+
from { height: var(--radix-accordion-content-height); }
|
|
648
|
+
to { height: 0; }
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/* Apply the keyframes directly via the data-slot + data-state selectors
|
|
652
|
+
that Radix sets on AccordionContent. Plain CSS — no Tailwind utility
|
|
653
|
+
generation in the path. The previous @theme inline \`--animate-accordion-*\`
|
|
654
|
+
tokens were unreliable; this matches the deterministic pattern used by
|
|
655
|
+
tw-animate-css for its own animate-in / animate-out utilities. */
|
|
656
|
+
[data-slot="accordion-content"][data-state="open"] {
|
|
657
|
+
animation: accordion-down var(--duration-base) var(--ease-out);
|
|
658
|
+
}
|
|
659
|
+
[data-slot="accordion-content"][data-state="closed"] {
|
|
660
|
+
animation: accordion-up var(--duration-base) var(--ease-out);
|
|
661
|
+
}
|
|
662
|
+
|
|
601
663
|
::view-transition-new(root) {
|
|
602
664
|
animation: theme-reveal 0.4s ease-in-out forwards;
|
|
603
665
|
}
|
package/src/api/brand-fonts.ts
CHANGED
|
@@ -19,9 +19,19 @@ const PUBLIC_FONTS = path.join(process.cwd(), "public", "fonts");
|
|
|
19
19
|
|
|
20
20
|
type BrandFontFile = {
|
|
21
21
|
path: string;
|
|
22
|
+
// A single weight (static face) or a "min max" range string (variable
|
|
23
|
+
// face, e.g. "300 900"). The Customize-tab upload path always writes a
|
|
24
|
+
// single weight; hand-authored variable entries use a range.
|
|
22
25
|
weight: number | string;
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
// "normal" | "italic" for static faces; a variable face may carry an
|
|
27
|
+
// oblique range like "oblique 0deg 12deg". The `(string & {})` keeps the two
|
|
28
|
+
// literals as autocomplete hints without collapsing the union to bare string.
|
|
29
|
+
style: "normal" | "italic" | (string & {});
|
|
30
|
+
// Static formats come from uploads; the `-variations` formats let a
|
|
31
|
+
// hand-authored entry declare a variable face. build-fonts emits each as-is.
|
|
32
|
+
format: "woff2" | "woff" | "woff2-variations" | "truetype-variations" | "truetype" | "opentype";
|
|
33
|
+
// Optional default axis settings for a variable face, e.g. "'opsz' 18".
|
|
34
|
+
variationSettings?: string;
|
|
25
35
|
};
|
|
26
36
|
|
|
27
37
|
type BrandFontEntry = {
|
|
@@ -183,10 +193,12 @@ export async function POST(request: Request) {
|
|
|
183
193
|
// Stable deterministic filename so re-uploads overwrite the same path.
|
|
184
194
|
const out = `${id}-${String(weight).replace(/\s+/g, "_")}-${style}.${format}`;
|
|
185
195
|
const buf = Buffer.from(await f.arrayBuffer());
|
|
186
|
-
// Canonical write
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
196
|
+
// Canonical write (ships in the npm tarball) + the dev preview mirror for
|
|
197
|
+
// /fonts/<file>. Independent paths, so write them concurrently.
|
|
198
|
+
await Promise.all([
|
|
199
|
+
fs.writeFile(path.join(PKG_FONTS, out), buf),
|
|
200
|
+
fs.writeFile(path.join(PUBLIC_FONTS, out), buf),
|
|
201
|
+
]);
|
|
190
202
|
written.push({
|
|
191
203
|
path: `/fonts/${out}`,
|
|
192
204
|
weight,
|
|
@@ -258,11 +270,9 @@ export async function POST(request: Request) {
|
|
|
258
270
|
if (target.files) {
|
|
259
271
|
for (const f of target.files) {
|
|
260
272
|
const fileName = f.path.replace(/^\/fonts\//, "");
|
|
261
|
-
const
|
|
262
|
-
const publicAbs = path.join(PUBLIC_FONTS, fileName);
|
|
263
|
-
for (const p of [pkgAbs, publicAbs]) {
|
|
273
|
+
for (const dir of [PKG_FONTS, PUBLIC_FONTS]) {
|
|
264
274
|
try {
|
|
265
|
-
await fs.unlink(
|
|
275
|
+
await fs.unlink(path.join(dir, fileName));
|
|
266
276
|
} catch {
|
|
267
277
|
// already gone
|
|
268
278
|
}
|
package/src/api/layers/file.ts
CHANGED
|
@@ -6,13 +6,48 @@ import { promisify } from "node:util";
|
|
|
6
6
|
const execAsync = promisify(exec);
|
|
7
7
|
const ROOT = process.cwd();
|
|
8
8
|
|
|
9
|
+
// Read allowlist. Reads are public (open-source docs) so we expand freely to
|
|
10
|
+
// cover everything the Docs tab surfaces. Writes (POST) are dev-only AND
|
|
11
|
+
// re-checked against the same allowlist — never write a markdown file outside
|
|
12
|
+
// the same surface the Docs tab can show. Path traversal is blocked at the
|
|
13
|
+
// normalize step before any pattern match runs.
|
|
14
|
+
const ALLOWED_ROOT_MD = new Set([
|
|
15
|
+
"BRIEF.md",
|
|
16
|
+
"README.md",
|
|
17
|
+
"CLAUDE.md",
|
|
18
|
+
"CAPABILITIES.md",
|
|
19
|
+
"AGENTS.md",
|
|
20
|
+
"BADS_SYNC.md",
|
|
21
|
+
"CHANGELOG.md",
|
|
22
|
+
"CIRCADIAN.md",
|
|
23
|
+
"CLIENT_ONBOARDING.md",
|
|
24
|
+
"COMPONENT_DESIGN.md",
|
|
25
|
+
"COMPONENT_INDEX.md",
|
|
26
|
+
"CONTRIBUTING.md",
|
|
27
|
+
"DESIGN.md",
|
|
28
|
+
"DESIGN_SYSTEM_STACK.md",
|
|
29
|
+
"ENGINEERING.md",
|
|
30
|
+
"MIGRATION_UNRENAME.md",
|
|
31
|
+
"PROPOSAL-bads-as-libraries.md",
|
|
32
|
+
"SECURITY.md",
|
|
33
|
+
"STORYBOOK_RULE.md",
|
|
34
|
+
"V0_SYSTEM.md",
|
|
35
|
+
"corrections.md",
|
|
36
|
+
"references.md",
|
|
37
|
+
]);
|
|
38
|
+
|
|
9
39
|
function isAllowed(rel: string) {
|
|
10
|
-
// Only allow paths inside layer-*/ or specific allowlisted files to prevent traversal abuse.
|
|
11
40
|
const norm = path.normalize(rel);
|
|
12
41
|
if (norm.startsWith("..") || path.isAbsolute(norm)) return false;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
42
|
+
if (norm === "packages/core/src/tokens.json") return true;
|
|
43
|
+
if (/^layer-[\w-]+\//.test(norm) && /\.(md|json)$/.test(norm)) return true;
|
|
44
|
+
if (/^docs\/[\w.-]+\.md$/.test(norm)) return true;
|
|
45
|
+
if (/^prompts\/[\w.-]+\.md$/.test(norm)) return true;
|
|
46
|
+
if (/^\.claude\/skills\/[\w.-]+\/SKILL\.md$/.test(norm)) return true;
|
|
47
|
+
if (/^(ledgers|aggregator|automation|roi)\/README\.md$/.test(norm)) return true;
|
|
48
|
+
if (/^scripts\/prompts\/[\w.-]+\.md$/.test(norm)) return true;
|
|
49
|
+
if (ALLOWED_ROOT_MD.has(norm)) return true;
|
|
50
|
+
return false;
|
|
16
51
|
}
|
|
17
52
|
|
|
18
53
|
export async function GET(request: Request) {
|