@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.
Files changed (115) hide show
  1. package/README.md +2 -0
  2. package/package.json +26 -5
  3. package/scripts/a11y-lint.cjs +88 -8
  4. package/scripts/bads-components.mjs +118 -0
  5. package/scripts/build-tokens.cjs +133 -12
  6. package/scripts/check-stories.mjs +1 -1
  7. package/scripts/health-report.mjs +16 -2
  8. package/scripts/lint-component-source.mjs +100 -0
  9. package/scripts/lint-microanimation.mjs +267 -0
  10. package/scripts/lint-slop.mjs +25 -1
  11. package/scripts/size-audit.cjs +79 -0
  12. package/scripts/source-of-truth.cjs +58 -0
  13. package/scripts/ux-smoke.mjs +438 -0
  14. package/scripts/wcag-audit.cjs +121 -6
  15. package/src/api/layers/file.ts +1 -0
  16. package/src/app/opengraph-image.tsx +5 -0
  17. package/src/app/preview/components/page.tsx +2237 -2
  18. package/src/app/shell.tsx +17 -16
  19. package/src/components/Foundations/Motion.stories.tsx +1 -0
  20. package/src/components/customize/brand-mark-section.tsx +4 -2
  21. package/src/components/customize/design-controls.tsx +17 -2
  22. package/src/components/customize/discipline-section.tsx +3 -6
  23. package/src/components/customize/font-pickers.tsx +1 -1
  24. package/src/components/customize/letter-spacing.tsx +1 -1
  25. package/src/components/customize/save-bar.tsx +2 -2
  26. package/src/components/customize/theme-io.tsx +7 -7
  27. package/src/components/customize/type-scale.tsx +1 -1
  28. package/src/components/customize-tab.tsx +7 -4
  29. package/src/components/home-tab.tsx +3 -0
  30. package/src/components/studio/studio.tsx +153 -0
  31. package/src/components/ui/accordion.tsx +7 -0
  32. package/src/components/ui/alert.tsx +1 -0
  33. package/src/components/ui/anchor.tsx +37 -3
  34. package/src/components/ui/announcement-bar.tsx +256 -0
  35. package/src/components/ui/attachment.tsx +211 -0
  36. package/src/components/ui/badge.tsx +1 -0
  37. package/src/components/ui/callout.tsx +218 -0
  38. package/src/components/ui/chart.tsx +5 -14
  39. package/src/components/ui/code.tsx +1 -1
  40. package/src/components/ui/color-picker.tsx +2 -2
  41. package/src/components/ui/format-relative-time.tsx +139 -0
  42. package/src/components/ui/gauge-chart.tsx +238 -0
  43. package/src/components/ui/grid.tsx +255 -0
  44. package/src/components/ui/heatmap.tsx +256 -0
  45. package/src/components/ui/icon.tsx +108 -0
  46. package/src/components/ui/index.ts +17 -0
  47. package/src/components/ui/infinite-scroll.tsx +103 -0
  48. package/src/components/ui/json-input.tsx +351 -0
  49. package/src/components/ui/navigation-progress.tsx +281 -0
  50. package/src/components/ui/number-input.tsx +1 -4
  51. package/src/components/ui/page-header.tsx +63 -0
  52. package/src/components/ui/password-input.tsx +2 -1
  53. package/src/components/ui/password-strength-input.tsx +288 -0
  54. package/src/components/ui/pill.tsx +140 -0
  55. package/src/components/ui/popover.tsx +27 -4
  56. package/src/components/ui/portal.tsx +111 -0
  57. package/src/components/ui/presence.tsx +172 -0
  58. package/src/components/ui/progress-stack.tsx +258 -0
  59. package/src/components/ui/scroll-progress.tsx +100 -0
  60. package/src/components/ui/select.tsx +89 -4
  61. package/src/components/ui/separator.tsx +1 -0
  62. package/src/components/ui/slider.tsx +83 -3
  63. package/src/components/ui/snackbar.tsx +393 -0
  64. package/src/components/ui/sortable-list.tsx +342 -0
  65. package/src/components/ui/sparkline.tsx +2 -14
  66. package/src/components/ui/squircle.tsx +1 -1
  67. package/src/components/ui/table.tsx +1 -1
  68. package/src/components/ui/textarea.tsx +28 -1
  69. package/src/components/ui/tour.tsx +1 -3
  70. package/src/data/docs-index.ts +25 -0
  71. package/src/hooks/use-reduced-motion.ts +6 -0
  72. package/src/lib/clamp.ts +2 -0
  73. package/src/stories/Accordion.stories.tsx +59 -0
  74. package/src/stories/Alert.stories.tsx +3 -1
  75. package/src/stories/Anchor.stories.tsx +54 -0
  76. package/src/stories/AnnouncementBar.stories.tsx +261 -0
  77. package/src/stories/Attachment.stories.tsx +189 -0
  78. package/src/stories/Badge.stories.tsx +3 -0
  79. package/src/stories/Calendar.stories.tsx +1 -1
  80. package/src/stories/Callout.stories.tsx +219 -0
  81. package/src/stories/Chart.stories.tsx +8 -0
  82. package/src/stories/Code.stories.tsx +1 -0
  83. package/src/stories/ColorPicker.stories.tsx +24 -0
  84. package/src/stories/FormatRelativeTime.stories.tsx +116 -0
  85. package/src/stories/GaugeChart.stories.tsx +163 -0
  86. package/src/stories/Grid.stories.tsx +197 -0
  87. package/src/stories/Heatmap.stories.tsx +172 -0
  88. package/src/stories/Icon.stories.tsx +175 -0
  89. package/src/stories/InfiniteScroll.stories.tsx +225 -0
  90. package/src/stories/JsonInput.stories.tsx +212 -0
  91. package/src/stories/MultiSelect.stories.tsx +1 -1
  92. package/src/stories/NavigationProgress.stories.tsx +159 -0
  93. package/src/stories/NumberInput.stories.tsx +1 -0
  94. package/src/stories/PageHeader.stories.tsx +102 -0
  95. package/src/stories/PasswordInput.stories.tsx +4 -0
  96. package/src/stories/PasswordStrengthInput.stories.tsx +211 -0
  97. package/src/stories/Pill.stories.tsx +201 -0
  98. package/src/stories/Popover.stories.tsx +29 -1
  99. package/src/stories/Portal.stories.tsx +191 -0
  100. package/src/stories/Presence.stories.tsx +228 -0
  101. package/src/stories/ProgressStack.stories.tsx +287 -0
  102. package/src/stories/ScrollProgress.stories.tsx +117 -0
  103. package/src/stories/Select.stories.tsx +25 -0
  104. package/src/stories/Separator.stories.tsx +3 -0
  105. package/src/stories/Slider.stories.tsx +54 -5
  106. package/src/stories/Snackbar.stories.tsx +315 -0
  107. package/src/stories/SortableList.stories.tsx +263 -0
  108. package/src/stories/Sparkline.stories.tsx +3 -0
  109. package/src/stories/Squircle.stories.tsx +1 -0
  110. package/src/stories/Table.stories.tsx +1 -0
  111. package/src/stories/Textarea.stories.tsx +18 -0
  112. package/src/stories/Tour.stories.tsx +1 -0
  113. package/src/stories/story-groups.json +26 -6
  114. package/src/styles.css +133 -12
  115. package/LICENSE +0 -21
package/src/app/shell.tsx CHANGED
@@ -6,8 +6,8 @@ import { Sheet, SheetContent, SheetHeader, SheetTitle } from "@behavioral-agenti
6
6
  import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
7
7
  import {
8
8
  Sun, Moon, BookOpen, X, ExternalLink, Menu,
9
- House, Blocks, LayoutGrid, LayoutDashboard, SlidersHorizontal,
10
- Type, Shapes, FileText, Layers as LayersIcon, Activity, GitCommitHorizontal,
9
+ House, Blocks,
10
+ Type, Shapes, FileText, Layers as LayersIcon, Activity, GitCommitHorizontal, SlidersHorizontal as StudioIcon,
11
11
  } from "lucide-react";
12
12
  import registry from "@/layer-5-component-registry/component-registry.json";
13
13
 
@@ -31,7 +31,7 @@ function GithubMark({ className }: { className?: string }) {
31
31
  );
32
32
  }
33
33
  import { brand } from "@/brand.config";
34
- import { CustomizeTab } from "@behavioral-agentic-design-system/core/components/customize-tab";
34
+ import Studio from "../components/studio/studio";
35
35
  import { LayersTab } from "@behavioral-agentic-design-system/core/components/layers-tab";
36
36
  import { HomeTab } from "@behavioral-agentic-design-system/core/components/home-tab";
37
37
  import { DocsTab } from "@behavioral-agentic-design-system/core/components/docs-tab";
@@ -224,10 +224,10 @@ export type ShellProps = {
224
224
  export const DEFAULT_TABS: ShellTab[] = [
225
225
  { value: "home", label: "Home", icon: House, render: ({ goToTab }) => <HomeTab onBrowseDocs={() => goToTab("docs")} onBrowseComponents={() => goToTab("components")} /> },
226
226
 
227
+ // Studio absorbs what Customize, Cards and Dashboard used to be: you tune a
228
+ // value and the specimens beside it repaint, instead of navigating to find out.
229
+ { value: "studio", label: "Studio", group: "build", icon: StudioIcon, render: () => <Studio /> },
227
230
  { value: "components", label: "Components", group: "build", icon: Blocks, count: COMPONENT_COUNT, render: ({ dark }) => <IframePreview dark={dark} src="/preview/components" title="Components preview" /> },
228
- { value: "cards", label: "Cards", group: "build", icon: LayoutGrid, render: ({ dark }) => <IframePreview dark={dark} src="/preview/cards" title="Cards preview" /> },
229
- { value: "dashboard", label: "Dashboard", group: "build", icon: LayoutDashboard, hidden: "md", render: ({ dark }) => <IframePreview dark={dark} src="/preview/dashboard" minWidth="1400px" title="Dashboard preview" /> },
230
- { value: "customize", label: "Customize", group: "build", icon: SlidersHorizontal, render: () => <CustomizeTab /> },
231
231
 
232
232
  // Typography was a route with no way to reach it — /preview/typography has
233
233
  // rendered fine and been unlinked. The Foundations group is where it belongs.
@@ -268,9 +268,12 @@ function RailTrigger({ tab, className }: { tab: ShellTab; className: string }) {
268
268
  {Icon ? <Icon className="size-4 shrink-0" strokeWidth={1.5} /> : null}
269
269
  <span className="min-w-0 flex-1 truncate text-left">{tab.label}</span>
270
270
  {typeof tab.count === "number" ? (
271
- <span className="shrink-0 text-xs tabular-nums text-muted-foreground">
272
- {tab.count}
273
- </span>
271
+ // No explicit color here on purpose: it inherits from the trigger, exactly like the
272
+ // label span above it. RAIL_ITEM already sets the right color per data-state (muted when
273
+ // inactive, --primary-foreground when active). A hardcoded text-muted-foreground here
274
+ // used to win over that inheritance, so the count stayed muted-gray even on the active
275
+ // row's near-black bg-primary pill -- dark-gray-on-near-black, unreadable.
276
+ <span className="shrink-0 text-xs tabular-nums">{tab.count}</span>
274
277
  ) : null}
275
278
  </TabsTrigger>
276
279
  );
@@ -716,8 +719,8 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
716
719
  documents under "Theme transition and sticky chrome", not the fix.
717
720
  The panel area scrolls inside itself, which is what keeps the rail
718
721
  out of sticky-chrome territory in the first place. */}
719
- <aside className="hidden w-60 shrink-0 flex-col border-r bg-card md:flex">
720
- <div className="flex h-14 shrink-0 items-center border-b px-4">
722
+ <aside className="hidden w-72 shrink-0 flex-col bg-card md:flex">
723
+ <div className="flex shrink-0 items-center px-4 py-3">
721
724
  <div className="flex items-center gap-2 min-w-0">
722
725
  {brand.logo?.lockup ? (
723
726
  // Full lockup slot: a brand whose identity is a combined
@@ -748,11 +751,9 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
748
751
  (it is brand identity, not decoration) and truncate keeps
749
752
  an arbitrary-length fork tagline inside the rail. */}
750
753
  <span className="flex min-w-0 flex-col leading-tight">
751
- <span className="truncate text-base font-semibold">{brand.name}</span>
754
+ <span className="text-base font-semibold">{brand.name}</span>
752
755
  {brand.tagline ? (
753
- <span className="truncate text-xs text-muted-foreground" title={brand.tagline}>
754
- {brand.tagline}
755
- </span>
756
+ <span className="text-xs text-muted-foreground">{brand.tagline}</span>
756
757
  ) : null}
757
758
  </span>
758
759
  </>
@@ -787,7 +788,7 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
787
788
  </TabsList>
788
789
  </nav>
789
790
 
790
- <div className="shrink-0 border-t p-3">
791
+ <div className="shrink-0 p-3">
791
792
  <div className="flex flex-wrap items-center gap-1.5 sm:gap-2 shrink-0">
792
793
  {/* Fork-configurable header links — set `headerLinks` in brand.config
793
794
  to add buttons (e.g. a link to a fork's prototypes site) without
@@ -259,6 +259,7 @@ export const ReducedMotion: Story = {
259
259
  {/* The transition only exists under no-preference, so reduced-motion
260
260
  users get an instant jump — the point of this story. When disarmed
261
261
  we also force transition:none so the snap-to-start never animates. */}
262
+ {/* allow-inline-style: this story's whole point is demonstrating the reduced-motion media-query gate via raw CSS. */}
262
263
  <style>{`
263
264
  @media (prefers-reduced-motion: no-preference) {
264
265
  .reduced-motion-demo[data-armed="true"] {
@@ -143,7 +143,7 @@ export function BrandMarkSection() {
143
143
  <code className="font-mono text-xs">brand-mark.json</code>.
144
144
  </p>
145
145
 
146
- <div className="grid gap-6 lg:grid-cols-2">
146
+ <div className="grid gap-6 @2xl/panel:grid-cols-2">
147
147
  {/* Inputs column */}
148
148
  <div className="flex flex-col gap-4">
149
149
  <div className="flex flex-col gap-2">
@@ -235,7 +235,9 @@ function PreviewTile({ mode, svg }: { mode: "light" | "dark"; svg: string | null
235
235
  isLight ? "bg-white text-zinc-900" : "bg-zinc-950 text-zinc-50"
236
236
  }`}
237
237
  >
238
- <div className="flex items-center gap-4">
238
+ {/* wrap: this row is re-housed into Studio's ~400px controls column,
239
+ narrower than the full-width tab it was built for. */}
240
+ <div className="flex flex-wrap items-center gap-4">
239
241
  {/* 32px size — matches header rhythm */}
240
242
  <Mark size={32} svg={svg} mode={mode} />
241
243
  {/* 96px size — login/branded surfaces */}
@@ -90,6 +90,21 @@ function SpacingPreview({ value }: { value: number }) {
90
90
  );
91
91
  }
92
92
 
93
+ // Static lookup, not a template-literal interpolation. Tailwind's build-time
94
+ // scanner reads literal text in source, not runtime JS values — a
95
+ // `` `shadow-${s}` `` interpolation is never seen by the scanner, so none of
96
+ // the four classes generate CSS in a production build and every swatch
97
+ // below silently rendered with no shadow at all. Writing the four class
98
+ // names out literally (even inside an object the scanner doesn't
99
+ // "understand") is what makes them visible to it. Caught by
100
+ // scripts/lint-static-classes.mjs, 2026-09-14.
101
+ const SHADOW_CLASS: Record<"sm" | "md" | "lg" | "xl", string> = {
102
+ sm: "shadow-sm",
103
+ md: "shadow-md",
104
+ lg: "shadow-lg",
105
+ xl: "shadow-xl",
106
+ };
107
+
93
108
  function ShadowPreview() {
94
109
  const sizes = ["sm", "md", "lg", "xl"] as const;
95
110
  return (
@@ -97,7 +112,7 @@ function ShadowPreview() {
97
112
  {sizes.map((s) => (
98
113
  <div key={s} className="flex flex-col items-center gap-1.5">
99
114
  <div
100
- className={`h-10 w-10 rounded-md bg-card shadow-${s}`}
115
+ className={`h-10 w-10 rounded-md bg-card ${SHADOW_CLASS[s]}`}
101
116
  />
102
117
  <span className="text-xs text-muted-foreground font-mono">{s}</span>
103
118
  </div>
@@ -132,7 +147,7 @@ export function DesignControlsPanel() {
132
147
  preview screen and persist on refresh.
133
148
  </p>
134
149
 
135
- <div className="grid grid-cols-1 lg:grid-cols-2 gap-x-10 gap-y-8">
150
+ <div className="grid grid-cols-1 @2xl/panel:grid-cols-2 gap-x-10 gap-y-8">
136
151
  <ControlRow
137
152
  label="Border Radius"
138
153
  description="Drives every rounded corner. sm/md/lg/xl scale from this base."
@@ -70,12 +70,9 @@ export function DisciplineSection() {
70
70
 
71
71
  return (
72
72
  <div>
73
- <h2 className="mb-2 text-2xl font-semibold tracking-tight">Discipline</h2>
74
- <p className="mb-5 max-w-prose text-sm text-muted-foreground">
75
- Which rule tree agents load for this work. Product covers app surfaces
76
- such as dashboards, forms and settings. Marketing covers expressive brand
77
- surfaces such as landing pages, email and campaigns. The accessibility
78
- and ethics floors load for both either way.
73
+ <h2 className="mb-2 text-base font-semibold">Discipline</h2>
74
+ <p className="mb-4 text-sm text-muted-foreground">
75
+ Which rule tree agents load. Both keep the accessibility and ethics floors.
79
76
  </p>
80
77
  <SegmentedControl
81
78
  value={discipline}
@@ -320,7 +320,7 @@ function FontCardGrid<K extends string>({
320
320
  }) {
321
321
  const keys = Object.keys(options) as K[];
322
322
  return (
323
- <div className="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-3">
323
+ <div className="grid grid-cols-2 @lg/panel:grid-cols-3 @2xl/panel:grid-cols-4 @3xl/panel:grid-cols-5 gap-3">
324
324
  {keys.map((key) => {
325
325
  const opt = options[key];
326
326
  const isActive = key === active;
@@ -47,7 +47,7 @@ export function LetterSpacingPanel() {
47
47
  labels all retrack live as you slide.
48
48
  </p>
49
49
 
50
- <div className="grid grid-cols-1 lg:grid-cols-2 gap-x-10 gap-y-8 mb-10">
50
+ <div className="grid grid-cols-1 @2xl/panel:grid-cols-2 gap-x-10 gap-y-8 mb-10">
51
51
  <div className="space-y-3">
52
52
  <div className="flex items-baseline justify-between gap-3">
53
53
  <label className="text-sm font-semibold">Tracking</label>
@@ -376,7 +376,7 @@ export function SaveBar() {
376
376
  <div className="flex items-center gap-2 shrink-0">
377
377
  <Button
378
378
  variant="ghost"
379
- size="sm"
379
+ size="xl"
380
380
  onClick={handleResetAll}
381
381
  disabled={status === "saving"}
382
382
  className="gap-2"
@@ -385,7 +385,7 @@ export function SaveBar() {
385
385
  Reset all
386
386
  </Button>
387
387
  <Button
388
- size="sm"
388
+ size="xl"
389
389
  onClick={handleSave}
390
390
  disabled={status === "saving" || count === 0}
391
391
  className="gap-2"
@@ -122,7 +122,7 @@ export function ThemeIO() {
122
122
  <div className="flex flex-wrap gap-2">
123
123
  <Dialog open={importOpen} onOpenChange={setImportOpen}>
124
124
  <DialogTrigger asChild>
125
- <Button variant="outline" size="sm" className="gap-2">
125
+ <Button variant="outline" size="xl" className="gap-2">
126
126
  <Upload className="h-4 w-4" />
127
127
  Import theme
128
128
  </Button>
@@ -161,7 +161,7 @@ export function ThemeIO() {
161
161
  <DialogFooter>
162
162
  <Button
163
163
  variant="outline"
164
- size="sm"
164
+ size="xl"
165
165
  onClick={() => {
166
166
  setImportOpen(false);
167
167
  setImportValue("");
@@ -170,7 +170,7 @@ export function ThemeIO() {
170
170
  >
171
171
  Cancel
172
172
  </Button>
173
- <Button size="sm" onClick={handleImport} disabled={!importValue.trim()}>
173
+ <Button size="xl" onClick={handleImport} disabled={!importValue.trim()}>
174
174
  Apply theme
175
175
  </Button>
176
176
  </DialogFooter>
@@ -179,7 +179,7 @@ export function ThemeIO() {
179
179
 
180
180
  <Dialog open={exportOpen} onOpenChange={setExportOpen}>
181
181
  <DialogTrigger asChild>
182
- <Button variant="outline" size="sm" className="gap-2" onClick={handleOpenExport}>
182
+ <Button variant="outline" size="xl" className="gap-2" onClick={handleOpenExport}>
183
183
  <Download className="h-4 w-4" />
184
184
  Export theme
185
185
  </Button>
@@ -213,10 +213,10 @@ export function ThemeIO() {
213
213
  onFocus={(e) => e.currentTarget.select()}
214
214
  />
215
215
  <DialogFooter>
216
- <Button variant="outline" size="sm" onClick={() => setExportOpen(false)}>
216
+ <Button variant="outline" size="xl" onClick={() => setExportOpen(false)}>
217
217
  Close
218
218
  </Button>
219
- <Button size="sm" onClick={handleCopy} className="gap-2">
219
+ <Button size="xl" onClick={handleCopy} className="gap-2">
220
220
  {copied ? (
221
221
  <>
222
222
  <Check className="h-4 w-4" />
@@ -234,7 +234,7 @@ export function ThemeIO() {
234
234
  </Dialog>
235
235
 
236
236
  {hasTheme && (
237
- <Button variant="ghost" size="sm" className="gap-2" onClick={clearTheme}>
237
+ <Button variant="ghost" size="xl" className="gap-2" onClick={clearTheme}>
238
238
  <RotateCcw className="h-4 w-4" />
239
239
  Reset to default
240
240
  </Button>
@@ -46,7 +46,7 @@ export function TypeScalePanel() {
46
46
  whole hierarchy stays harmonic when you change either control.
47
47
  </p>
48
48
 
49
- <div className="grid grid-cols-1 lg:grid-cols-2 gap-x-10 gap-y-8 mb-10">
49
+ <div className="grid grid-cols-1 @2xl/panel:grid-cols-2 gap-x-10 gap-y-8 mb-10">
50
50
  <div className="space-y-3">
51
51
  <div className="flex items-baseline justify-between gap-3">
52
52
  <label className="text-sm font-semibold">Base Size</label>
@@ -253,7 +253,7 @@ function ColorSection({
253
253
  <h4 className="text-base font-semibold">{title}</h4>
254
254
  {action}
255
255
  </div>
256
- <div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-3">
256
+ <div className="grid grid-cols-2 @lg/panel:grid-cols-3 @xl/panel:grid-cols-4 @2xl/panel:grid-cols-5 gap-3">
257
257
  {children}
258
258
  </div>
259
259
  </div>
@@ -640,7 +640,7 @@ function PrimaryColorPicker() {
640
640
  </div>
641
641
  )}
642
642
 
643
- <div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-4 xl:grid-cols-8 gap-3">
643
+ <div className="grid grid-cols-2 @lg/panel:grid-cols-3 @xl/panel:grid-cols-4 @2xl/panel:grid-cols-4 @3xl/panel:grid-cols-8 gap-3">
644
644
  {keys.map((key) => {
645
645
  const opt = options[key];
646
646
  const isCustom = key in customs;
@@ -673,7 +673,7 @@ function PrimaryColorPicker() {
673
673
  );
674
674
  }
675
675
 
676
- function ColorPalette() {
676
+ export function ColorPalette() {
677
677
  const { options, addCustomSilent } = useGlobalPrimaryColor();
678
678
  const { overrides, updateOverride, remove } = useTokenOverrides();
679
679
  const swatchCtx = useMemo<TokenSwatchPickerCtx>(
@@ -683,7 +683,10 @@ function ColorPalette() {
683
683
 
684
684
  return (
685
685
  <TokenSwatchPicker.Provider value={swatchCtx}>
686
- <div className="p-4 sm:p-6 lg:p-8 pb-32 max-w-7xl mx-auto space-y-12 sm:space-y-20">
686
+ {/* No padding here: Studio's column already pads. Two layers cost 96px of
687
+ a 400px column. No max-w/mx-auto either — this is a panel, not a page.
688
+ gap-6 is the DESIGN.md section rhythm; space-y-20 was page rhythm. */}
689
+ <div className="flex flex-col gap-10">
687
690
  <ThemeIO />
688
691
  <PrimaryColorPicker />
689
692
  <BrandMarkSection />
@@ -238,6 +238,9 @@ function PromptCard({
238
238
  <p className="line-clamp-3 rounded-md border bg-muted/40 p-2.5 font-mono text-xs leading-relaxed text-muted-foreground">
239
239
  {prompt}
240
240
  </p>
241
+ {/* allow-small-cta: copy-to-clipboard changes no flow — no route, no
242
+ modal, no filter — so the 44px CTA floor does not apply. It is
243
+ full-width to line up with the card's prompt block above it. */}
241
244
  <Button
242
245
  size="sm"
243
246
  variant={copied ? "default" : "outline"}
@@ -0,0 +1,153 @@
1
+ "use client";
2
+
3
+ import { useState } from "react";
4
+ import { PanelLeftClose, PanelLeftOpen } from "lucide-react";
5
+ import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
6
+ import { ScrollArea } from "@behavioral-agentic-design-system/core/components/ui/scroll-area";
7
+ import { ColorPalette } from "@behavioral-agentic-design-system/core/components/customize-tab";
8
+ import { DisciplineSection } from "@behavioral-agentic-design-system/core/components/customize/discipline-section";
9
+ import CardsDemo from "@/components/examples/cards";
10
+ import DashboardDemo from "@/components/examples/dashboard";
11
+ import {
12
+ SegmentedControl,
13
+ SegmentedControlItem,
14
+ } from "@behavioral-agentic-design-system/core/components/ui/segmented-control";
15
+
16
+ /**
17
+ * Studio — tune the system and watch real compositions respond.
18
+ *
19
+ * Replaces the Customize tab, and absorbs what Cards showed. The problem it
20
+ * solves is that those were separate destinations: you changed a token in one
21
+ * and had to navigate to another to see what it did, which meant the authoring
22
+ * surface could not show you the consequence of authoring.
23
+ *
24
+ * ONE architectural constraint decides this whole component, and it is why the
25
+ * specimens are rendered INLINE rather than in an <IframePreview> like every
26
+ * other showcase surface:
27
+ *
28
+ * `useTokenOverrides` writes to `document.documentElement.style`.
29
+ *
30
+ * An iframe is a separate document with its own documentElement, so an iframed
31
+ * specimen would keep its old values until reloaded. Inline, the specimens sit
32
+ * under the same root the overrides are written to, so a colour change repaints
33
+ * them on the same frame with no wiring at all. Do not "tidy" this into an
34
+ * iframe later — the live repaint is the feature, and the iframe is what broke
35
+ * it in the first place.
36
+ *
37
+ * Direction A ("The Inspector"), chosen 2026-09-09. Two costs were named at
38
+ * sketch time and both are answered here rather than shipped:
39
+ *
40
+ * - Two nested columns eat horizontal space beside a 240px rail. So the
41
+ * controls column collapses, and the collapse state persists.
42
+ * - A flat list of primitives is a poor authoring interface (the token-vs-
43
+ * editor critique). So controls are grouped by DECISION with the section
44
+ * saying what it governs, not by raw token name.
45
+ */
46
+
47
+ const COLLAPSE_KEY = "bads:studio:controls-collapsed";
48
+
49
+ /** The specimen sets Studio absorbs. Cards is the default: it is the denser
50
+ * read on a token change, and it fits the pane without horizontal scroll. */
51
+ const SPECIMENS = [
52
+ { id: "cards", label: "Cards" },
53
+ { id: "dashboard", label: "Dashboard" },
54
+ ] as const;
55
+
56
+ export default function Studio() {
57
+ const [collapsed, setCollapsed] = useState(false);
58
+ const [specimen, setSpecimen] = useState<string>("cards");
59
+
60
+ // Restore the collapse choice. Read lazily rather than in useState's
61
+ // initialiser so the server render and the first client render agree.
62
+ useState(() => {
63
+ if (typeof window === "undefined") return;
64
+ try {
65
+ if (window.localStorage.getItem(COLLAPSE_KEY) === "1") setCollapsed(true);
66
+ } catch {
67
+ // Storage disabled — open is the safe default.
68
+ }
69
+ });
70
+
71
+ function toggle() {
72
+ setCollapsed((prev) => {
73
+ const next = !prev;
74
+ try {
75
+ window.localStorage.setItem(COLLAPSE_KEY, next ? "1" : "0");
76
+ } catch {
77
+ // Non-fatal: the panel still toggles for this session.
78
+ }
79
+ return next;
80
+ });
81
+ }
82
+
83
+ return (
84
+ <div className="flex size-full min-h-0">
85
+ {/* ── Controls ───────────────────────────────────────────────────── */}
86
+ {collapsed ? null : (
87
+ <div className="@container/panel flex w-[360px] shrink-0 flex-col border-r">
88
+ <div className="flex h-14 shrink-0 items-center justify-between border-b px-4">
89
+ <h2 className="text-sm font-semibold">Controls</h2>
90
+ <Button
91
+ variant="ghost"
92
+ size="icon"
93
+ onClick={toggle}
94
+ aria-label="Collapse controls"
95
+ className="size-11"
96
+ >
97
+ <PanelLeftClose className="size-4" strokeWidth={1.5} />
98
+ </Button>
99
+ </div>
100
+ <ScrollArea className="min-h-0 flex-1">
101
+ {/* The existing, working panels — re-housed, not rewritten. They
102
+ already carry their own previews (swatches, font specimens),
103
+ which is what makes a decision legible instead of a raw value. */}
104
+ <div className="flex flex-col gap-10 px-4 py-5">
105
+ {/* Re-homed here when Studio replaced CustomizeTab. Renders null
106
+ on a single-discipline fork, so upstream sees nothing. */}
107
+ <DisciplineSection />
108
+ <ColorPalette />
109
+ </div>
110
+ </ScrollArea>
111
+ </div>
112
+ )}
113
+
114
+ {/* ── Specimens ──────────────────────────────────────────────────── */}
115
+ <div className="flex min-w-0 flex-1 flex-col">
116
+ <div className="flex h-14 shrink-0 items-center gap-3 border-b px-4">
117
+ {collapsed ? (
118
+ <Button
119
+ variant="ghost"
120
+ size="icon"
121
+ onClick={toggle}
122
+ aria-label="Show controls"
123
+ className="size-11"
124
+ >
125
+ <PanelLeftOpen className="size-4" strokeWidth={1.5} />
126
+ </Button>
127
+ ) : null}
128
+ <SegmentedControl
129
+ value={specimen}
130
+ onValueChange={setSpecimen}
131
+ label="Specimen set"
132
+ >
133
+ {SPECIMENS.map((s) => (
134
+ <SegmentedControlItem key={s.id} value={s.id}>
135
+ {s.label}
136
+ </SegmentedControlItem>
137
+ ))}
138
+ </SegmentedControl>
139
+ <p className="truncate text-sm text-muted-foreground">
140
+ Real compositions. They repaint as you change a value.
141
+ </p>
142
+ </div>
143
+ <ScrollArea className="min-h-0 flex-1">
144
+ {/* Dashboard is a wide layout; it gets its own horizontal scroll
145
+ rather than forcing the whole pane wide. */}
146
+ <div className={specimen === "dashboard" ? "min-w-[960px]" : "p-6"}>
147
+ {specimen === "dashboard" ? <DashboardDemo withSidebar={false} /> : <CardsDemo />}
148
+ </div>
149
+ </ScrollArea>
150
+ </div>
151
+ </div>
152
+ );
153
+ }
@@ -41,6 +41,10 @@ function Accordion({
41
41
  <AccordionPrimitive.Root
42
42
  data-slot="accordion"
43
43
  data-variant={variant}
44
+ // A primitive is the layer that draws a card surface, so it cannot
45
+ // compose Card to get one, and these classes belong on Radix's own
46
+ // Root, which a wrapping Card would displace.
47
+ // lint-disable: card-bypass
44
48
  className={cn(
45
49
  // contained: shared card — divide-y handles item separators so
46
50
  // AccordionItem needs no border of its own.
@@ -64,6 +68,9 @@ function AccordionItem({
64
68
  return (
65
69
  <AccordionPrimitive.Item
66
70
  data-slot="accordion-item"
71
+ // Same reason as the Root above. The separated variant's per-item card is
72
+ // this primitive's own surface, not a consumer hand-rolling one.
73
+ // lint-disable: card-bypass
67
74
  className={cn(
68
75
  // default: bottom border on every item except the last.
69
76
  variant === "default" && "border-b last:border-b-0",
@@ -33,6 +33,7 @@ const alertVariants = cva(
33
33
  // emitted), so the color silently fell through to the `:root *`
34
34
  // `border-border` base reset (the bug that made these accents render
35
35
  // grey). Arbitrary values always generate; `!` wins over `:root *`.
36
+ // @recipe-note: The left-accent and border colors are set with `!` (border-l-[var(--primary)]!). An override must match that importance — `border-l-transparent` alone will not beat it. Use `border-l-transparent!` to remove the accent, not `border-l-transparent`.
36
37
  default: "border-border border-l-4 border-l-[var(--primary)]! bg-primary/5 text-foreground [&>svg]:text-primary dark:bg-primary/10",
37
38
  // Full red border (all four sides) so the error reads as an error at a
38
39
  // glance, with the 4px left bar as the accent. bg-destructive/5 tint
@@ -19,6 +19,15 @@ interface AnchorProps extends React.ComponentProps<"nav"> {
19
19
  label?: string
20
20
  /** Offset in px from the top of the viewport for IntersectionObserver rootMargin. Default 0. */
21
21
  offset?: number
22
+ /**
23
+ * Controlled active item. When provided, the component highlights this id
24
+ * instead of its own scroll-spy result; the observer keeps running and
25
+ * reports what it sees through `onActiveChange`, so the consumer can mirror
26
+ * it into a URL hash, a store, or a sibling surface. Omit for uncontrolled.
27
+ */
28
+ activeId?: string | null
29
+ /** Fires whenever the scroll-spy resolves a new visible section. */
30
+ onActiveChange?: (id: string) => void
22
31
  }
23
32
 
24
33
  // Each depth level adds pl-3 of indentation. Clamped at depth 2.
@@ -31,15 +40,35 @@ const DEPTH_PADDING = ["pl-3", "pl-6", "pl-9"] as const
31
40
  *
32
41
  * Distinct from NavigationMenu (multi-page) and Breadcrumb (path hierarchy).
33
42
  * Cross-system references: Mantine TableOfContents, Ant Design Anchor.
43
+ * This IS BADS's table-of-contents primitive — the name follows Ant Design,
44
+ * and the registry lists `TableOfContents` as an alias so the candidate
45
+ * pre-screen doesn't re-propose it (ledgers/component-builds.jsonl,
46
+ * 2026-08-21 and 2026-09-15).
47
+ *
48
+ * Uncontrolled by default. Pass `activeId` (+ `onActiveChange`) to control
49
+ * the highlight — e.g. to drive it from the URL hash or a shared store.
34
50
  */
35
51
  function Anchor({
36
52
  items,
37
53
  label = "On this page",
38
54
  offset = 0,
55
+ activeId: activeIdProp,
56
+ onActiveChange,
39
57
  className,
40
58
  ...props
41
59
  }: AnchorProps) {
42
- const [activeId, setActiveId] = React.useState<string | null>(null)
60
+ const [internalActiveId, setInternalActiveId] = React.useState<
61
+ string | null
62
+ >(null)
63
+ const isControlled = activeIdProp !== undefined
64
+ const activeId = isControlled ? activeIdProp : internalActiveId
65
+
66
+ // Latest-callback ref so the observer effect doesn't re-subscribe every
67
+ // render when the consumer passes an inline arrow for onActiveChange.
68
+ const onActiveChangeRef = React.useRef(onActiveChange)
69
+ React.useEffect(() => {
70
+ onActiveChangeRef.current = onActiveChange
71
+ }, [onActiveChange])
43
72
 
44
73
  // Key the effect off the id list (not array identity) so consumers can
45
74
  // inline `items` without tearing the observer down on every render.
@@ -62,7 +91,12 @@ function Anchor({
62
91
  // is visible wins. Keep the previous active id while nothing is
63
92
  // visible (e.g. mid-jump between long sections).
64
93
  const first = ids.find((id) => visible.has(id))
65
- if (first) setActiveId(first)
94
+ if (first) {
95
+ // Uncontrolled: own the highlight. Controlled: only report; the
96
+ // consumer decides whether to mirror it back through `activeId`.
97
+ if (!isControlled) setInternalActiveId(first)
98
+ onActiveChangeRef.current?.(first)
99
+ }
66
100
  },
67
101
  { rootMargin: `${-offset}px 0px 0px 0px`, threshold: 0 }
68
102
  )
@@ -73,7 +107,7 @@ function Anchor({
73
107
  }
74
108
 
75
109
  return () => observer.disconnect()
76
- }, [idKey, offset])
110
+ }, [idKey, offset, isControlled])
77
111
 
78
112
  return (
79
113
  <nav