@behavioral-agentic-design-system/core 0.8.4 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@behavioral-agentic-design-system/core",
3
- "version": "0.8.4",
3
+ "version": "0.9.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)",
@@ -62,6 +62,7 @@
62
62
  "./components/dev-identity-badge": "./src/components/dev-identity-badge.tsx",
63
63
  "./components/onboarding-wizard": "./src/components/onboarding-wizard.tsx",
64
64
  "./components/customize/*": "./src/components/customize/*.tsx",
65
+ "./components/motion/*": "./src/components/motion/*.tsx",
65
66
  "./components/Foundations/*": "./src/components/Foundations/*.tsx",
66
67
  "./app/page": "./src/app/page.tsx",
67
68
  "./app/shell": "./src/app/shell.tsx",
@@ -92,6 +93,7 @@
92
93
  "access": "public"
93
94
  },
94
95
  "dependencies": {
96
+ "@radix-ui/react-alert-dialog": "^1.1.16",
95
97
  "@xmldom/xmldom": "^0.9.10",
96
98
  "cheerio": "^1.0.0",
97
99
  "class-variance-authority": "^0.7.0",
@@ -101,10 +103,13 @@
101
103
  "tailwind-merge": "^3.0.0"
102
104
  },
103
105
  "peerDependencies": {
106
+ "@radix-ui/react-accordion": "*",
104
107
  "@radix-ui/react-avatar": "*",
105
108
  "@radix-ui/react-checkbox": "*",
106
109
  "@radix-ui/react-collapsible": "*",
110
+ "@radix-ui/react-context-menu": "*",
107
111
  "@radix-ui/react-dialog": "*",
112
+ "@radix-ui/react-navigation-menu": "*",
108
113
  "@radix-ui/react-dropdown-menu": "*",
109
114
  "@radix-ui/react-label": "*",
110
115
  "@radix-ui/react-popover": "*",
@@ -131,6 +136,9 @@
131
136
  "sonner": "*"
132
137
  },
133
138
  "peerDependenciesMeta": {
139
+ "@radix-ui/react-accordion": {
140
+ "optional": true
141
+ },
134
142
  "@radix-ui/react-avatar": {
135
143
  "optional": true
136
144
  },
@@ -140,9 +148,15 @@
140
148
  "@radix-ui/react-collapsible": {
141
149
  "optional": true
142
150
  },
151
+ "@radix-ui/react-context-menu": {
152
+ "optional": true
153
+ },
143
154
  "@radix-ui/react-dialog": {
144
155
  "optional": true
145
156
  },
157
+ "@radix-ui/react-navigation-menu": {
158
+ "optional": true
159
+ },
146
160
  "@radix-ui/react-dropdown-menu": {
147
161
  "optional": true
148
162
  },
@@ -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 === 'woff' ? 'woff' : 'woff2';
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
- const style = file.style === 'italic' ? 'italic' : 'normal';
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
  }
@@ -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: 0 1px 3px 0px hsl(0 0% 0% / ${shadowAlpha('2xl')}), 0 16px 24px -1px hsl(0 0% 0% / ${shadowAlpha('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% at var(--x, 50%) var(--y, 50%));
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(150% at var(--x, 50%) var(--y, 50%));
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
  }
@@ -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
- style: "normal" | "italic";
24
- format: "woff2" | "woff";
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 — this is the copy that ships in the npm tarball.
187
- await fs.writeFile(path.join(PKG_FONTS, out), buf);
188
- // Mirror for the dev preview's /fonts/<file> static-asset route.
189
- await fs.writeFile(path.join(PUBLIC_FONTS, out), buf);
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 pkgAbs = path.join(PKG_FONTS, fileName);
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(p);
275
+ await fs.unlink(path.join(dir, fileName));
266
276
  } catch {
267
277
  // already gone
268
278
  }
@@ -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
- const isLayerFile = /^layer-[\w-]+\//.test(norm) && /\.(md|json)$/.test(norm);
14
- const isTokensFile = norm === "packages/core/src/tokens.json";
15
- return isLayerFile || isTokensFile;
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) {