@behavioral-agentic-design-system/core 0.21.0 → 0.23.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 +3 -2
- package/scripts/size-audit.cjs +147 -0
- package/src/api/layers/file.ts +0 -1
- package/src/app/layout.tsx +29 -4
- package/src/app/opengraph-image.tsx +103 -0
- package/src/app/preview/components/page.tsx +164 -5
- package/src/app/shell.tsx +31 -7
- package/src/components/customize-tab.tsx +111 -139
- package/src/components/home-tab.tsx +7 -14
- package/src/components/layers-tab.tsx +5 -0
- package/src/components/onboarding-wizard.tsx +1 -1
- package/src/components/ui/editable.tsx +323 -0
- package/src/components/ui/fieldset.tsx +238 -0
- package/src/components/ui/index.ts +3 -0
- package/src/components/ui/input-group.tsx +194 -0
- package/src/data/docs-index.ts +13 -0
- package/src/stories/Accordion.stories.tsx +21 -0
- package/src/stories/Button.stories.tsx +15 -0
- package/src/stories/CopyButton.stories.tsx +2 -2
- package/src/stories/Dialog.stories.tsx +33 -0
- package/src/stories/Editable.stories.tsx +170 -0
- package/src/stories/Field.stories.tsx +1 -1
- package/src/stories/Fieldset.stories.tsx +249 -0
- package/src/stories/InputGroup.stories.tsx +229 -0
- package/src/stories/Label.stories.tsx +2 -2
- package/src/stories/Tabs.stories.tsx +24 -0
- package/src/styles.css +0 -12
- package/src/tokens.json +45 -49
|
@@ -84,41 +84,50 @@ function ColorSwatch({
|
|
|
84
84
|
const currentHex = overrides[variable]?.toUpperCase();
|
|
85
85
|
const entries = Object.entries(options);
|
|
86
86
|
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
//
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
87
|
+
// wheelHex drives the HexColorPicker (always a valid 6-char hex).
|
|
88
|
+
// inputValue leads the hex input and may be incomplete while the user types.
|
|
89
|
+
const [wheelHex, setWheelHex] = useState(currentHex ?? "#808080");
|
|
90
|
+
const [inputValue, setInputValue] = useState(currentHex ?? "");
|
|
91
|
+
|
|
92
|
+
// True when the current wheelHex already exists in the brand palette.
|
|
93
|
+
const inPalette = useMemo(
|
|
94
|
+
() =>
|
|
95
|
+
entries.some(([, opt]) => {
|
|
96
|
+
const swatch = (opt.swatch ?? opt.primary ?? "").toUpperCase();
|
|
97
|
+
return swatch !== "" && swatch === wheelHex;
|
|
98
|
+
}),
|
|
99
|
+
[entries, wheelHex],
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
// Apply a validated hex to the token and sync both local states.
|
|
103
|
+
const applyHex = (hex: string) => {
|
|
104
|
+
const upper = hex.toUpperCase();
|
|
105
|
+
setWheelHex(upper);
|
|
106
|
+
setInputValue(upper);
|
|
107
|
+
setToken(variable, upper);
|
|
103
108
|
};
|
|
104
109
|
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (!id) {
|
|
113
|
-
setAddError("Could not add color");
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
setToken(variable, value.toUpperCase());
|
|
117
|
-
resetAddState();
|
|
110
|
+
const handleReset = () => {
|
|
111
|
+
resetToken(variable);
|
|
112
|
+
// Chart vars are written inline by use-global-primary-color; clearing the
|
|
113
|
+
// override here won't restore the brand-derived ramp without this call.
|
|
114
|
+
if (variable.startsWith("--chart-")) reapplyChartRamp();
|
|
115
|
+
setWheelHex("#808080");
|
|
116
|
+
setInputValue("");
|
|
118
117
|
};
|
|
119
118
|
|
|
120
119
|
return (
|
|
121
|
-
<Popover
|
|
120
|
+
<Popover
|
|
121
|
+
onOpenChange={(open) => {
|
|
122
|
+
if (open) {
|
|
123
|
+
// Sync to the current override each time the popover opens so the
|
|
124
|
+
// wheel reflects the live token value rather than stale local state.
|
|
125
|
+
const cur = overrides[variable]?.toUpperCase();
|
|
126
|
+
setWheelHex(cur ?? "#808080");
|
|
127
|
+
setInputValue(cur ?? "");
|
|
128
|
+
}
|
|
129
|
+
}}
|
|
130
|
+
>
|
|
122
131
|
<PopoverTrigger asChild>
|
|
123
132
|
<button
|
|
124
133
|
type="button"
|
|
@@ -138,129 +147,91 @@ function ColorSwatch({
|
|
|
138
147
|
<PopoverContent align="start" className="w-72 p-3">
|
|
139
148
|
<div className="flex items-center justify-between gap-2 mb-3">
|
|
140
149
|
<p className="text-xs font-mono text-muted-foreground truncate">{variable}</p>
|
|
141
|
-
{
|
|
150
|
+
{isOverridden && (
|
|
142
151
|
<button
|
|
143
152
|
type="button"
|
|
144
|
-
onClick={
|
|
145
|
-
resetToken(variable);
|
|
146
|
-
// Chart vars are written inline by use-global-primary-color
|
|
147
|
-
// so clearing the override here doesn't put the live --chart-N
|
|
148
|
-
// back into a brand-derived state — call back into the hook
|
|
149
|
-
// to re-evaluate the ramp against the current --primary.
|
|
150
|
-
if (variable.startsWith("--chart-")) {
|
|
151
|
-
reapplyChartRamp();
|
|
152
|
-
}
|
|
153
|
-
}}
|
|
153
|
+
onClick={handleReset}
|
|
154
154
|
className="inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors"
|
|
155
155
|
>
|
|
156
156
|
<RotateCcw className="h-3 w-3" strokeWidth={1.5} />
|
|
157
157
|
Reset
|
|
158
158
|
</button>
|
|
159
159
|
)}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
160
|
+
</div>
|
|
161
|
+
|
|
162
|
+
{/* Color wheel — always visible; no sub-flow required */}
|
|
163
|
+
<HexColorPicker
|
|
164
|
+
style={{ width: "100%", height: "180px" }}
|
|
165
|
+
color={isValidHex(wheelHex) ? wheelHex : "#808080"}
|
|
166
|
+
onChange={(c) => applyHex(c)}
|
|
167
|
+
/>
|
|
168
|
+
|
|
169
|
+
{/* Hex input synced with the wheel + save-to-palette when not already there */}
|
|
170
|
+
<div className="flex items-center gap-2 mt-2">
|
|
171
|
+
<Input
|
|
172
|
+
value={inputValue}
|
|
173
|
+
onChange={(e) => {
|
|
174
|
+
setInputValue(e.target.value);
|
|
175
|
+
if (isValidHex(e.target.value.trim())) {
|
|
176
|
+
applyHex(e.target.value.trim());
|
|
177
|
+
}
|
|
178
|
+
}}
|
|
179
|
+
placeholder="#1F1F1F"
|
|
180
|
+
className="h-9 flex-1 min-w-0 font-mono text-sm"
|
|
181
|
+
/>
|
|
182
|
+
{!inPalette && isValidHex(wheelHex) && (
|
|
183
|
+
<Button
|
|
165
184
|
type="button"
|
|
166
|
-
|
|
167
|
-
|
|
185
|
+
size="icon"
|
|
186
|
+
variant="outline"
|
|
187
|
+
className="h-9 w-9 shrink-0"
|
|
188
|
+
onClick={() => addCustomSilent(wheelHex)}
|
|
189
|
+
title="Save to brand palette"
|
|
168
190
|
>
|
|
169
|
-
|
|
170
|
-
</
|
|
191
|
+
<Plus className="h-4 w-4" strokeWidth={1.5} />
|
|
192
|
+
</Button>
|
|
171
193
|
)}
|
|
172
194
|
</div>
|
|
173
195
|
|
|
174
|
-
{
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}}
|
|
197
|
-
onKeyDown={(e) => {
|
|
198
|
-
if (e.key === "Enter") handleAddAndApply();
|
|
199
|
-
}}
|
|
200
|
-
placeholder="#1F1F1F"
|
|
201
|
-
className="h-9 flex-1 min-w-0 font-mono text-sm"
|
|
202
|
-
/>
|
|
203
|
-
<Button size="sm" onClick={handleAddAndApply}>
|
|
204
|
-
Add
|
|
205
|
-
</Button>
|
|
206
|
-
</div>
|
|
207
|
-
{addError && <span className="text-xs text-destructive">{addError}</span>}
|
|
208
|
-
<p className="text-xs text-muted-foreground">
|
|
209
|
-
Saved to your brand colors and applied here.
|
|
210
|
-
</p>
|
|
211
|
-
</div>
|
|
212
|
-
) : (
|
|
213
|
-
<div className="grid grid-cols-4 gap-2">
|
|
214
|
-
{entries.map(([key, opt]) => {
|
|
215
|
-
const swatch = opt.swatch ?? opt.primary;
|
|
216
|
-
const isActive =
|
|
217
|
-
currentHex !== undefined &&
|
|
218
|
-
currentHex === (swatch ?? "").toUpperCase();
|
|
219
|
-
return (
|
|
220
|
-
<button
|
|
221
|
-
key={key}
|
|
222
|
-
type="button"
|
|
223
|
-
onClick={() => setToken(variable, swatch)}
|
|
224
|
-
title={`${opt.label} · ${swatch}`}
|
|
225
|
-
className={`group/sw flex flex-col items-center gap-1.5 rounded-md border p-2 transition-all ${
|
|
226
|
-
isActive
|
|
227
|
-
? "border-primary ring-2 ring-primary/30"
|
|
228
|
-
: "border-border hover:border-primary/40"
|
|
229
|
-
}`}
|
|
196
|
+
{/* Brand color presets — clicking applies the color and syncs the wheel */}
|
|
197
|
+
<div className="grid grid-cols-4 gap-2 mt-3">
|
|
198
|
+
{entries.map(([key, opt]) => {
|
|
199
|
+
const swatch = opt.swatch ?? opt.primary;
|
|
200
|
+
const isActive =
|
|
201
|
+
swatch != null && swatch.toUpperCase() === wheelHex;
|
|
202
|
+
return (
|
|
203
|
+
<button
|
|
204
|
+
key={key}
|
|
205
|
+
type="button"
|
|
206
|
+
onClick={() => { if (swatch) applyHex(swatch); }}
|
|
207
|
+
aria-label={`${opt.label} — ${swatch}${isActive ? ", selected" : ""}`}
|
|
208
|
+
aria-pressed={isActive}
|
|
209
|
+
className={`group/sw flex flex-col items-center gap-1.5 rounded-md border p-2 transition-all ${
|
|
210
|
+
isActive
|
|
211
|
+
? "border-primary ring-2 ring-primary/30"
|
|
212
|
+
: "border-border hover:border-primary/40"
|
|
213
|
+
}`}
|
|
214
|
+
>
|
|
215
|
+
<div
|
|
216
|
+
className="relative h-7 w-7 rounded-full border border-border/50"
|
|
217
|
+
style={{ backgroundColor: swatch }}
|
|
230
218
|
>
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
);
|
|
248
|
-
})}
|
|
249
|
-
<button
|
|
250
|
-
type="button"
|
|
251
|
-
onClick={() => setShowAdd(true)}
|
|
252
|
-
title="Add a new brand color and apply it here"
|
|
253
|
-
className="group/sw flex flex-col items-center gap-1.5 rounded-md border border-dashed border-border p-2 transition-all hover:border-primary/40"
|
|
254
|
-
>
|
|
255
|
-
<div className="flex h-7 w-7 items-center justify-center rounded-full border border-dashed border-border/60 text-muted-foreground group-hover/sw:text-foreground">
|
|
256
|
-
<Plus className="h-3.5 w-3.5" strokeWidth={1.5} />
|
|
257
|
-
</div>
|
|
258
|
-
<span className="text-xs leading-tight text-muted-foreground group-hover/sw:text-foreground truncate w-full text-center">
|
|
259
|
-
Add
|
|
260
|
-
</span>
|
|
261
|
-
</button>
|
|
262
|
-
</div>
|
|
263
|
-
)}
|
|
219
|
+
{isActive && (
|
|
220
|
+
<Check
|
|
221
|
+
aria-hidden="true"
|
|
222
|
+
className="absolute inset-0 m-auto h-3.5 w-3.5"
|
|
223
|
+
style={{ color: opt.swatchForeground ?? opt.primaryForeground }}
|
|
224
|
+
strokeWidth={1.5}
|
|
225
|
+
/>
|
|
226
|
+
)}
|
|
227
|
+
</div>
|
|
228
|
+
<span className="text-xs leading-tight truncate w-full text-center">
|
|
229
|
+
{opt.label}
|
|
230
|
+
</span>
|
|
231
|
+
</button>
|
|
232
|
+
);
|
|
233
|
+
})}
|
|
234
|
+
</div>
|
|
264
235
|
</PopoverContent>
|
|
265
236
|
</Popover>
|
|
266
237
|
);
|
|
@@ -518,6 +489,7 @@ function BrandColorCard({
|
|
|
518
489
|
>
|
|
519
490
|
{isActive && (
|
|
520
491
|
<Check
|
|
492
|
+
aria-hidden="true"
|
|
521
493
|
className="absolute inset-0 m-auto h-5 w-5"
|
|
522
494
|
style={{ color: swatchFg }}
|
|
523
495
|
strokeWidth={1.5}
|
|
@@ -250,7 +250,7 @@ function MetricPill({
|
|
|
250
250
|
<span className="font-mono text-2xl font-semibold tracking-tight tabular-nums">
|
|
251
251
|
{value}
|
|
252
252
|
</span>
|
|
253
|
-
<span className="text-xs uppercase tracking-wide text-
|
|
253
|
+
<span className="text-xs uppercase tracking-wide text-foreground">
|
|
254
254
|
{label}
|
|
255
255
|
</span>
|
|
256
256
|
</div>
|
|
@@ -315,7 +315,7 @@ export function HomeTab({ onBrowseDocs, onBrowseComponents }: HomeTabProps) {
|
|
|
315
315
|
<Separator />
|
|
316
316
|
|
|
317
317
|
<section className="flex flex-col gap-4">
|
|
318
|
-
<h2 className="text-sm font-semibold uppercase tracking-wide text-
|
|
318
|
+
<h2 className="text-sm font-semibold uppercase tracking-wide text-foreground">
|
|
319
319
|
What ships today
|
|
320
320
|
</h2>
|
|
321
321
|
<div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
|
|
@@ -341,18 +341,11 @@ export function HomeTab({ onBrowseDocs, onBrowseComponents }: HomeTabProps) {
|
|
|
341
341
|
{STARTER_CARDS.map((card) => {
|
|
342
342
|
const Icon = card.icon;
|
|
343
343
|
return (
|
|
344
|
-
<
|
|
344
|
+
<button
|
|
345
345
|
key={card.id}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
onKeyDown={(e) => {
|
|
350
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
351
|
-
e.preventDefault();
|
|
352
|
-
openDocAt(card.path);
|
|
353
|
-
}
|
|
354
|
-
}}
|
|
355
|
-
className="group cursor-pointer transition-colors hover:border-primary/40 hover:bg-accent/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
|
|
346
|
+
type="button"
|
|
347
|
+
onClick={() => openDocAt(card.path)} // lint-disable: card-bypass — whole card is a click target, so it must be a <button> for keyboard activation, not a <Card> div
|
|
348
|
+
className="flex flex-col gap-4 rounded-lg border bg-card text-card-foreground shadow-sm group cursor-pointer text-left w-full transition-colors hover:border-primary/40 hover:bg-accent/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
|
|
356
349
|
style={{
|
|
357
350
|
transitionDuration: "var(--duration-fast)",
|
|
358
351
|
transitionTimingFunction: "var(--ease-out)",
|
|
@@ -383,7 +376,7 @@ export function HomeTab({ onBrowseDocs, onBrowseComponents }: HomeTabProps) {
|
|
|
383
376
|
/>
|
|
384
377
|
</div>
|
|
385
378
|
</CardContent>
|
|
386
|
-
</
|
|
379
|
+
</button>
|
|
387
380
|
);
|
|
388
381
|
})}
|
|
389
382
|
</div>
|
|
@@ -163,6 +163,11 @@ export function LayersTab() {
|
|
|
163
163
|
setStatus("idle");
|
|
164
164
|
setStatusMessage("");
|
|
165
165
|
|
|
166
|
+
// Markdown files default to the rendered preview so they're never blank.
|
|
167
|
+
if (isMarkdown(activePath)) {
|
|
168
|
+
setViewMode("preview");
|
|
169
|
+
}
|
|
170
|
+
|
|
166
171
|
// Synthetic semantic-tokens view: read tokens.json (the only non-layer
|
|
167
172
|
// path the file route allows) and pull the theme.light / theme.dark
|
|
168
173
|
// maps into a name → {light, dark} table. Always read-only.
|