@behavioral-agentic-design-system/core 0.8.3 → 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.3",
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)",
@@ -46,6 +46,7 @@
46
46
  "./styles.css": "./src/styles.css",
47
47
  "./fonts.css": "./src/fonts.css",
48
48
  "./brand-fonts.css": "./src/brand-fonts.css",
49
+ "./density.css": "./src/density.css",
49
50
  "./fonts/*": "./src/fonts/*",
50
51
  "./tokens.json": "./src/tokens.json",
51
52
  "./tokens.default.json": "./src/tokens.default.json",
@@ -61,6 +62,7 @@
61
62
  "./components/dev-identity-badge": "./src/components/dev-identity-badge.tsx",
62
63
  "./components/onboarding-wizard": "./src/components/onboarding-wizard.tsx",
63
64
  "./components/customize/*": "./src/components/customize/*.tsx",
65
+ "./components/motion/*": "./src/components/motion/*.tsx",
64
66
  "./components/Foundations/*": "./src/components/Foundations/*.tsx",
65
67
  "./app/page": "./src/app/page.tsx",
66
68
  "./app/shell": "./src/app/shell.tsx",
@@ -91,6 +93,7 @@
91
93
  "access": "public"
92
94
  },
93
95
  "dependencies": {
96
+ "@radix-ui/react-alert-dialog": "^1.1.16",
94
97
  "@xmldom/xmldom": "^0.9.10",
95
98
  "cheerio": "^1.0.0",
96
99
  "class-variance-authority": "^0.7.0",
@@ -100,10 +103,13 @@
100
103
  "tailwind-merge": "^3.0.0"
101
104
  },
102
105
  "peerDependencies": {
106
+ "@radix-ui/react-accordion": "*",
103
107
  "@radix-ui/react-avatar": "*",
104
108
  "@radix-ui/react-checkbox": "*",
105
109
  "@radix-ui/react-collapsible": "*",
110
+ "@radix-ui/react-context-menu": "*",
106
111
  "@radix-ui/react-dialog": "*",
112
+ "@radix-ui/react-navigation-menu": "*",
107
113
  "@radix-ui/react-dropdown-menu": "*",
108
114
  "@radix-ui/react-label": "*",
109
115
  "@radix-ui/react-popover": "*",
@@ -130,6 +136,9 @@
130
136
  "sonner": "*"
131
137
  },
132
138
  "peerDependenciesMeta": {
139
+ "@radix-ui/react-accordion": {
140
+ "optional": true
141
+ },
133
142
  "@radix-ui/react-avatar": {
134
143
  "optional": true
135
144
  },
@@ -139,9 +148,15 @@
139
148
  "@radix-ui/react-collapsible": {
140
149
  "optional": true
141
150
  },
151
+ "@radix-ui/react-context-menu": {
152
+ "optional": true
153
+ },
142
154
  "@radix-ui/react-dialog": {
143
155
  "optional": true
144
156
  },
157
+ "@radix-ui/react-navigation-menu": {
158
+ "optional": true
159
+ },
145
160
  "@radix-ui/react-dropdown-menu": {
146
161
  "optional": true
147
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
@@ -529,6 +549,42 @@ const baseLayer = `@layer base {
529
549
  color: GrayText;
530
550
  }
531
551
  }
552
+ /* Clickable cursor — every interactive primitive gets cursor: pointer
553
+ * so click affordance is visually consistent. Tailwind v4 dropped the
554
+ * implicit pointer on <button> from v3's preflight; this restores it
555
+ * + extends to every other clickable native element and ARIA widget
556
+ * role. Disabled state → cursor: not-allowed so "off" reads as
557
+ * intentional rather than broken.
558
+ *
559
+ * Promoted from swimtopia-prototypes globals.css (2026-06-10) per
560
+ * Sir's "if it's clickable, the cursor says so" rule. */
561
+ button:not(:disabled),
562
+ a[href]:not([aria-disabled="true"]),
563
+ [role="button"]:not([aria-disabled="true"]),
564
+ [role="link"]:not([aria-disabled="true"]),
565
+ [role="tab"]:not([aria-disabled="true"]),
566
+ [role="menuitem"]:not([aria-disabled="true"]),
567
+ [role="option"]:not([aria-disabled="true"]),
568
+ [role="checkbox"]:not([aria-disabled="true"]),
569
+ [role="radio"]:not([aria-disabled="true"]),
570
+ [role="switch"]:not([aria-disabled="true"]),
571
+ input[type="button"]:not(:disabled),
572
+ input[type="submit"]:not(:disabled),
573
+ input[type="reset"]:not(:disabled),
574
+ input[type="checkbox"]:not(:disabled),
575
+ input[type="radio"]:not(:disabled),
576
+ select:not(:disabled),
577
+ label[for],
578
+ summary {
579
+ cursor: pointer;
580
+ }
581
+ button:disabled,
582
+ input:disabled,
583
+ select:disabled,
584
+ textarea:disabled,
585
+ [aria-disabled="true"] {
586
+ cursor: not-allowed;
587
+ }
532
588
  }
533
589
 
534
590
  /* Global tracking offset — the Letter Spacing slider in the Customize
@@ -542,7 +598,26 @@ html, body {
542
598
 
543
599
  /* Theme toggle: iris reveal via View Transitions API. The click coords are
544
600
  written to --x / --y on <html> before startViewTransition fires (see
545
- 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). */
546
621
  ::view-transition-old(root),
547
622
  ::view-transition-new(root) {
548
623
  animation: none;
@@ -553,15 +628,38 @@ html, body {
553
628
 
554
629
  @keyframes theme-reveal {
555
630
  from {
556
- clip-path: circle(0% at var(--x, 50%) var(--y, 50%));
557
- opacity: 0.7;
631
+ clip-path: circle(0 at var(--x, 50%) var(--y, 50%));
558
632
  }
559
633
  to {
560
- clip-path: circle(150% at var(--x, 50%) var(--y, 50%));
561
- opacity: 1;
634
+ clip-path: circle(150vmax at var(--x, 50%) var(--y, 50%));
562
635
  }
563
636
  }
564
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
+
565
663
  ::view-transition-new(root) {
566
664
  animation: theme-reveal 0.4s ease-in-out forwards;
567
665
  }
@@ -570,23 +668,30 @@ html, body {
570
668
  ::view-transition-new(root) { animation: none; }
571
669
  }`;
572
670
 
573
- // ---- Border-color utilities (workaround for a Tailwind v4 generation gap) -
671
+ // ---- Border-color utilities (workaround for a TURBOPACK bug) --------------
672
+ //
673
+ // ROOT CAUSE (confirmed 2026-06-09, see ledgers/research.jsonl): Next's
674
+ // Turbopack does NOT emit PLAIN named border-color utilities (`border-primary`,
675
+ // `border-destructive`, `border-l-primary`, ...). It keeps the `/opacity`
676
+ // variants (`border-primary/30`), arbitrary values (`border-[var(--x)]`), and
677
+ // every other utility family (`text-*`, `bg-*`, ...) — only the plain
678
+ // border-color set is dropped. The class lands on the element but no rule is
679
+ // emitted, so the color falls through to the `:where(:root *)` default and
680
+ // renders as --border grey. Proven by a same-source A/B: `@tailwindcss/postcss`
681
+ // (webpack / Storybook) generates `.border-primary {…}` fine; `next build`
682
+ // (Turbopack) does not. Nothing in this theme or the base reset causes it —
683
+ // ruled out via real builds (theme var-indirection, @apply-vs-raw reset).
574
684
  //
575
- // In this v4 setup, PLAIN named border-color utilities (`border-primary`,
576
- // `border-destructive`, `border-l-primary`, ...) silently don't get generated
577
- // — the class lands on the element but no rule is emitted, so the color falls
578
- // through to the `:where(:root *)` default and renders as --border grey. Only
579
- // the opacity variants (`border-primary/30`) and arbitrary `border-[var(--x)]`
580
- // generate. That made ~20 components render colored borders as grey (mostly
581
- // hidden on filled controls, visible on outlined ones — checkbox/radio boxes,
582
- // input error borders, selected-card borders, alerts).
685
+ // That made ~20 components render colored borders as grey (mostly hidden on
686
+ // filled controls, visible on outlined ones — checkbox/radio boxes, input
687
+ // error borders, selected-card borders, alerts).
583
688
  //
584
- // Rather than convert every call site to arbitrary values, we emit the plain
585
- // utilities here, once, for the whole semantic palette — so every existing
586
- // `border-<color>` across all components AND every downstream fork just works.
587
- // Emitted in @layer utilities so they beat the base reset but still lose to a
588
- // component's own higher-specificity state variants (e.g. hover:border-*).
589
- // See ledgers/research.jsonl 2026-06-05 for the full diagnosis.
689
+ // Rather than convert every call site to arbitrary values or drop Turbopack,
690
+ // we emit the plain utilities here, once, for the whole semantic palette — so
691
+ // every existing `border-<color>` across all components AND every downstream
692
+ // fork just works under Turbopack. Emitted in @layer utilities so they beat
693
+ // the base reset but still lose to a component's own higher-specificity state
694
+ // variants (e.g. hover:border-*). Revisit if/when Turbopack fixes the gap.
590
695
  const BORDER_COLOR_NAMES = [
591
696
  'background', 'foreground', 'card', 'card-foreground', 'popover',
592
697
  'popover-foreground', 'primary', 'primary-foreground', 'link', 'secondary',
@@ -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) {
@@ -3,6 +3,7 @@ import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import { Atkinson_Hyperlegible, Inter, JetBrains_Mono, Lora, Source_Serif_4 } from "next/font/google";
5
5
  import "@/styles/globals.css";
6
+ import "../density.css";
6
7
  import { brand } from "@/brand.config";
7
8
  import Providers from "./providers";
8
9
  import { FontReady } from "./font-ready";