@behavioral-agentic-design-system/core 0.15.0 → 0.16.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 +8 -2
- package/scripts/a11y-lint.cjs +229 -0
- package/scripts/build-tokens.cjs +3 -3
- package/scripts/check-stories.mjs +109 -0
- package/scripts/fix-stories.mjs +785 -0
- package/scripts/generate-stories.cjs +101 -0
- package/scripts/oklch-to-hex.cjs +156 -0
- package/scripts/wcag-audit.cjs +444 -0
- package/src/app/preview/components/page.tsx +373 -1
- package/src/components/dev-identity-badge.tsx +1 -1
- package/src/components/ui/button-group.tsx +57 -0
- package/src/components/ui/calendar.tsx +4 -0
- package/src/components/ui/circular-progress.tsx +120 -0
- package/src/components/ui/copy-button.tsx +114 -0
- package/src/components/ui/empty-state.tsx +115 -0
- package/src/components/ui/indicator.tsx +144 -0
- package/src/components/ui/list.tsx +70 -0
- package/src/components/ui/multi-select.tsx +196 -0
- package/src/hooks/use-global-primary-color.ts +1 -1
- package/src/styles.css +2 -2
|
@@ -0,0 +1,785 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Auto-generate baseline Storybook stories that satisfy the strict coverage
|
|
4
|
+
* rule. Two modes:
|
|
5
|
+
*
|
|
6
|
+
* • Missing file → emit a fresh story from the component's CVA + a per-
|
|
7
|
+
* component RealisticUse composition (when known).
|
|
8
|
+
* • Stub file → detected by "single Default export with empty args" or
|
|
9
|
+
* "Default export whose args match the auto-template"
|
|
10
|
+
* pattern. Stubs from the older sync-stories.js generator
|
|
11
|
+
* get regenerated here.
|
|
12
|
+
* • Hand-edited → skipped. Anything with multiple Story exports is
|
|
13
|
+
* considered "real" and left alone.
|
|
14
|
+
*
|
|
15
|
+
* Usage: pnpm fix:stories
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { execSync } from "node:child_process";
|
|
19
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
20
|
+
import { join, basename, dirname } from "node:path";
|
|
21
|
+
import { fileURLToPath } from "node:url";
|
|
22
|
+
|
|
23
|
+
// Shipped as the `bads-fix-stories` bin. The component SOURCE is package-owned,
|
|
24
|
+
// so resolve it relative to this script inside the core package (works in the
|
|
25
|
+
// monorepo and from node_modules in a fork — the fork's packages/core/src is a
|
|
26
|
+
// stub with no components/ui). The stories OUTPUT is consumer-owned.
|
|
27
|
+
const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));
|
|
28
|
+
const ROOT = process.cwd();
|
|
29
|
+
const COMPONENTS_DIR = join(SCRIPT_DIR, "..", "src/components/ui");
|
|
30
|
+
const STORIES_DIR = join(ROOT, "components");
|
|
31
|
+
if (!existsSync(STORIES_DIR)) mkdirSync(STORIES_DIR, { recursive: true });
|
|
32
|
+
|
|
33
|
+
function pascal(kebab) {
|
|
34
|
+
return kebab
|
|
35
|
+
.replace(/\.tsx$/, "")
|
|
36
|
+
.split(/[-_]/)
|
|
37
|
+
.map((w) => w[0].toUpperCase() + w.slice(1))
|
|
38
|
+
.join("");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function pascalIdent(s) {
|
|
42
|
+
return s
|
|
43
|
+
.replace(/[^a-zA-Z0-9]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ""))
|
|
44
|
+
.replace(/^(.)/, (c) => c.toUpperCase());
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function listComponents() {
|
|
48
|
+
return readdirSync(COMPONENTS_DIR)
|
|
49
|
+
.filter((f) => f.endsWith(".tsx"))
|
|
50
|
+
.map((f) => ({
|
|
51
|
+
file: f,
|
|
52
|
+
name: pascal(f),
|
|
53
|
+
kebab: f.replace(/\.tsx$/, ""),
|
|
54
|
+
path: join(COMPONENTS_DIR, f),
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function detectExports(source) {
|
|
59
|
+
const named = new Set();
|
|
60
|
+
const re = /export\s+(?:function|const|class)\s+([A-Z][A-Za-z0-9_]*)/g;
|
|
61
|
+
let m;
|
|
62
|
+
while ((m = re.exec(source)) !== null) named.add(m[1]);
|
|
63
|
+
const re2 = /export\s*\{([^}]+)\}/g;
|
|
64
|
+
while ((m = re2.exec(source)) !== null) {
|
|
65
|
+
for (const piece of m[1].split(",")) {
|
|
66
|
+
const sym = piece.trim().split(/\s+as\s+/)[0].trim();
|
|
67
|
+
if (/^[A-Z]/.test(sym)) named.add(sym);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return Array.from(named);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function detectCva(source) {
|
|
74
|
+
const cvaIdx = source.indexOf("cva(");
|
|
75
|
+
if (cvaIdx === -1) return { variants: [], sizes: [] };
|
|
76
|
+
const tail = source.slice(cvaIdx);
|
|
77
|
+
const variantsBlock = /variants:\s*{([\s\S]*?)\n\s{0,4}}\s*[,)]/.exec(tail);
|
|
78
|
+
if (!variantsBlock) return { variants: [], sizes: [] };
|
|
79
|
+
const block = variantsBlock[1];
|
|
80
|
+
function pluck(name) {
|
|
81
|
+
const re = new RegExp(`${name}:\\s*{([\\s\\S]*?)}`, "m");
|
|
82
|
+
const sub = re.exec(block);
|
|
83
|
+
if (!sub) return [];
|
|
84
|
+
const keys = [];
|
|
85
|
+
const keyRe = /^\s*([A-Za-z][\w-]*|"[^"]+"):/gm;
|
|
86
|
+
let k;
|
|
87
|
+
while ((k = keyRe.exec(sub[1])) !== null) keys.push(k[1].replace(/"/g, ""));
|
|
88
|
+
return keys;
|
|
89
|
+
}
|
|
90
|
+
return { variants: pluck("variant"), sizes: pluck("size") };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Stub detection. The older sync-stories.js generator wrote a ~17-line file
|
|
95
|
+
* with one Default export and `args: {}`. The current fix-stories.mjs writes
|
|
96
|
+
* a longer matrix with multiple exports. Anything in between (single Story
|
|
97
|
+
* export, no realistic composition) we treat as stub-equivalent.
|
|
98
|
+
*/
|
|
99
|
+
function looksLikeStub(content) {
|
|
100
|
+
const exports = (content.match(/export\s+const\s+\w+\s*:\s*Story/g) || []).length;
|
|
101
|
+
const hasEmptyArgs = /export\s+const\s+Default\s*:\s*Story\s*=\s*\{\s*args\s*:\s*\{\s*\}\s*,?\s*\}/.test(
|
|
102
|
+
content,
|
|
103
|
+
);
|
|
104
|
+
const hasRender = /render:\s*\(/.test(content);
|
|
105
|
+
// Placeholder-content fingerprint from the old generator: `children: "X content"
|
|
106
|
+
// as any` or `children: "Loading…" as any` or `children: "Disabled" as any`.
|
|
107
|
+
// These slip past the export-count check because the old generator emitted
|
|
108
|
+
// Default + Disabled + Loading + RealisticUse — four exports, all useless.
|
|
109
|
+
const hasPlaceholderChildren =
|
|
110
|
+
/children:\s*"[A-Z][a-z]+ content"\s+as\s+any/.test(content) ||
|
|
111
|
+
/children:\s*"Loading…?"/.test(content);
|
|
112
|
+
// Variant_X / Size_X with bare-args templates. These render empty for any
|
|
113
|
+
// component that needs children (Badge / Tag / Toggle / Alert) — the
|
|
114
|
+
// controls panel works but the canvas is blank. Treat as stub-equivalent
|
|
115
|
+
// so the regenerator's render-with-children template kicks in.
|
|
116
|
+
const hasBareVariantArgs = /export\s+const\s+(?:Variant|Size)_\w+\s*:\s*Story\s*=\s*\{\s*args:\s*\{\s*(?:variant|size):\s*"[^"]+"\s*\}\s*as\s+any/.test(
|
|
117
|
+
content,
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
if (exports <= 1) return hasEmptyArgs || !hasRender;
|
|
121
|
+
return hasPlaceholderChildren || hasBareVariantArgs;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// ─── Component-specific realistic compositions ──────────────────────────────
|
|
125
|
+
// Auto-template can't guess what a Card or Avatar should contain. These
|
|
126
|
+
// overrides give those primitives a meaningful RealisticUse so Storybook
|
|
127
|
+
// renders something to look at instead of an empty box. Keep tight — three
|
|
128
|
+
// to six lines each, using sensible placeholder content.
|
|
129
|
+
//
|
|
130
|
+
// Keyed by component PascalCase name. Each entry returns the body of a
|
|
131
|
+
// `render: () => (...)` so the template can wrap it in the standard Story.
|
|
132
|
+
|
|
133
|
+
const COMPOSITIONS = {
|
|
134
|
+
Alert: {
|
|
135
|
+
imports: [
|
|
136
|
+
`import { AlertCircleIcon } from "lucide-react";`,
|
|
137
|
+
`import { Alert, AlertTitle, AlertDescription } from "@behavioral-agentic-design-system/core/components/ui/alert";`,
|
|
138
|
+
],
|
|
139
|
+
realisticBody: `<div className="w-[420px] flex flex-col gap-3">
|
|
140
|
+
<Alert>
|
|
141
|
+
<AlertCircleIcon className="h-4 w-4" />
|
|
142
|
+
<AlertTitle>Heads up</AlertTitle>
|
|
143
|
+
<AlertDescription>You can update settings any time.</AlertDescription>
|
|
144
|
+
</Alert>
|
|
145
|
+
<Alert variant="destructive">
|
|
146
|
+
<AlertCircleIcon className="h-4 w-4" />
|
|
147
|
+
<AlertTitle>Save failed</AlertTitle>
|
|
148
|
+
<AlertDescription>Couldn't reach the server. Try again.</AlertDescription>
|
|
149
|
+
</Alert>
|
|
150
|
+
</div>`,
|
|
151
|
+
// Bare `<Alert variant="X">Default</Alert>` looks broken (Alert is structured)
|
|
152
|
+
// — render the full title+description shape with the variant applied.
|
|
153
|
+
variantRender: (v, label) => `<div className="w-[420px]">
|
|
154
|
+
<Alert variant="${v}">
|
|
155
|
+
<AlertCircleIcon className="h-4 w-4" />
|
|
156
|
+
<AlertTitle>${label}</AlertTitle>
|
|
157
|
+
<AlertDescription>${
|
|
158
|
+
v === "destructive"
|
|
159
|
+
? "Couldn't reach the server. Try again."
|
|
160
|
+
: "Heads up — something to read."
|
|
161
|
+
}</AlertDescription>
|
|
162
|
+
</Alert>
|
|
163
|
+
</div>`,
|
|
164
|
+
},
|
|
165
|
+
Avatar: {
|
|
166
|
+
imports: [
|
|
167
|
+
`import { Avatar, AvatarFallback, AvatarImage } from "@behavioral-agentic-design-system/core/components/ui/avatar";`,
|
|
168
|
+
],
|
|
169
|
+
realisticBody: `<div className="flex items-center gap-3">
|
|
170
|
+
<Avatar>
|
|
171
|
+
<AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
|
|
172
|
+
<AvatarFallback>CN</AvatarFallback>
|
|
173
|
+
</Avatar>
|
|
174
|
+
<Avatar>
|
|
175
|
+
<AvatarFallback>MS</AvatarFallback>
|
|
176
|
+
</Avatar>
|
|
177
|
+
</div>`,
|
|
178
|
+
},
|
|
179
|
+
Badge: {
|
|
180
|
+
imports: [
|
|
181
|
+
`import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge";`,
|
|
182
|
+
],
|
|
183
|
+
realisticBody: `<div className="flex items-center gap-2">
|
|
184
|
+
<Badge>Default</Badge>
|
|
185
|
+
<Badge variant="secondary">Secondary</Badge>
|
|
186
|
+
<Badge variant="destructive">Destructive</Badge>
|
|
187
|
+
<Badge variant="outline">Outline</Badge>
|
|
188
|
+
</div>`,
|
|
189
|
+
},
|
|
190
|
+
Breadcrumb: {
|
|
191
|
+
imports: [
|
|
192
|
+
`import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from "@behavioral-agentic-design-system/core/components/ui/breadcrumb";`,
|
|
193
|
+
],
|
|
194
|
+
realisticBody: `<Breadcrumb>
|
|
195
|
+
<BreadcrumbList>
|
|
196
|
+
<BreadcrumbItem><BreadcrumbLink href="#">Home</BreadcrumbLink></BreadcrumbItem>
|
|
197
|
+
<BreadcrumbSeparator />
|
|
198
|
+
<BreadcrumbItem><BreadcrumbLink href="#">Components</BreadcrumbLink></BreadcrumbItem>
|
|
199
|
+
<BreadcrumbSeparator />
|
|
200
|
+
<BreadcrumbItem><BreadcrumbPage>Breadcrumb</BreadcrumbPage></BreadcrumbItem>
|
|
201
|
+
</BreadcrumbList>
|
|
202
|
+
</Breadcrumb>`,
|
|
203
|
+
},
|
|
204
|
+
Calendar: {
|
|
205
|
+
imports: [
|
|
206
|
+
`import { Calendar } from "@behavioral-agentic-design-system/core/components/ui/calendar";`,
|
|
207
|
+
],
|
|
208
|
+
realisticBody: `<Calendar mode="single" selected={new Date()} onSelect={() => {}} className="rounded-md border" />`,
|
|
209
|
+
},
|
|
210
|
+
Card: {
|
|
211
|
+
imports: [
|
|
212
|
+
`import { Card, CardContent, CardDescription, CardHeader, CardTitle, CardFooter } from "@behavioral-agentic-design-system/core/components/ui/card";`,
|
|
213
|
+
`import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";`,
|
|
214
|
+
],
|
|
215
|
+
realisticBody: `<Card className="w-[360px]">
|
|
216
|
+
<CardHeader>
|
|
217
|
+
<CardTitle>Total Revenue</CardTitle>
|
|
218
|
+
<CardDescription>+20.1% from last month</CardDescription>
|
|
219
|
+
</CardHeader>
|
|
220
|
+
<CardContent>
|
|
221
|
+
<p className="text-3xl font-semibold tabular-nums">$15,231.89</p>
|
|
222
|
+
</CardContent>
|
|
223
|
+
<CardFooter>
|
|
224
|
+
<Button size="sm">View report</Button>
|
|
225
|
+
</CardFooter>
|
|
226
|
+
</Card>`,
|
|
227
|
+
},
|
|
228
|
+
Checkbox: {
|
|
229
|
+
imports: [
|
|
230
|
+
`import { Checkbox } from "@behavioral-agentic-design-system/core/components/ui/checkbox";`,
|
|
231
|
+
`import { Label } from "@behavioral-agentic-design-system/core/components/ui/label";`,
|
|
232
|
+
],
|
|
233
|
+
realisticBody: `<div className="flex items-center gap-2">
|
|
234
|
+
<Checkbox id="terms" defaultChecked />
|
|
235
|
+
<Label htmlFor="terms">I agree to the terms</Label>
|
|
236
|
+
</div>`,
|
|
237
|
+
},
|
|
238
|
+
Collapsible: {
|
|
239
|
+
imports: [
|
|
240
|
+
`import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@behavioral-agentic-design-system/core/components/ui/collapsible";`,
|
|
241
|
+
`import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";`,
|
|
242
|
+
],
|
|
243
|
+
realisticBody: `<Collapsible className="w-[320px] space-y-2">
|
|
244
|
+
<CollapsibleTrigger asChild><Button variant="outline" size="sm">Toggle details</Button></CollapsibleTrigger>
|
|
245
|
+
<CollapsibleContent className="rounded-md border p-3 text-sm">Hidden detail content.</CollapsibleContent>
|
|
246
|
+
</Collapsible>`,
|
|
247
|
+
},
|
|
248
|
+
Command: {
|
|
249
|
+
imports: [
|
|
250
|
+
`import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@behavioral-agentic-design-system/core/components/ui/command";`,
|
|
251
|
+
],
|
|
252
|
+
realisticBody: `<Command className="rounded-lg border w-[320px]">
|
|
253
|
+
<CommandInput placeholder="Search..." />
|
|
254
|
+
<CommandList>
|
|
255
|
+
<CommandEmpty>No results.</CommandEmpty>
|
|
256
|
+
<CommandGroup heading="Suggestions">
|
|
257
|
+
<CommandItem>Calendar</CommandItem>
|
|
258
|
+
<CommandItem>Settings</CommandItem>
|
|
259
|
+
<CommandItem>Profile</CommandItem>
|
|
260
|
+
</CommandGroup>
|
|
261
|
+
</CommandList>
|
|
262
|
+
</Command>`,
|
|
263
|
+
},
|
|
264
|
+
DropdownMenu: {
|
|
265
|
+
imports: [
|
|
266
|
+
`import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "@behavioral-agentic-design-system/core/components/ui/dropdown-menu";`,
|
|
267
|
+
`import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";`,
|
|
268
|
+
],
|
|
269
|
+
realisticBody: `<DropdownMenu>
|
|
270
|
+
<DropdownMenuTrigger asChild><Button variant="outline">Open menu</Button></DropdownMenuTrigger>
|
|
271
|
+
<DropdownMenuContent>
|
|
272
|
+
<DropdownMenuLabel>Account</DropdownMenuLabel>
|
|
273
|
+
<DropdownMenuSeparator />
|
|
274
|
+
<DropdownMenuItem>Profile</DropdownMenuItem>
|
|
275
|
+
<DropdownMenuItem>Settings</DropdownMenuItem>
|
|
276
|
+
<DropdownMenuSeparator />
|
|
277
|
+
<DropdownMenuItem>Log out</DropdownMenuItem>
|
|
278
|
+
</DropdownMenuContent>
|
|
279
|
+
</DropdownMenu>`,
|
|
280
|
+
},
|
|
281
|
+
Label: {
|
|
282
|
+
imports: [
|
|
283
|
+
`import { Label } from "@behavioral-agentic-design-system/core/components/ui/label";`,
|
|
284
|
+
`import { Input } from "@behavioral-agentic-design-system/core/components/ui/input";`,
|
|
285
|
+
],
|
|
286
|
+
realisticBody: `<div className="flex flex-col gap-2 w-[280px]">
|
|
287
|
+
<Label htmlFor="email">Email</Label>
|
|
288
|
+
<Input id="email" type="email" placeholder="m@example.com" />
|
|
289
|
+
</div>`,
|
|
290
|
+
},
|
|
291
|
+
Popover: {
|
|
292
|
+
imports: [
|
|
293
|
+
`import { Popover, PopoverContent, PopoverTrigger } from "@behavioral-agentic-design-system/core/components/ui/popover";`,
|
|
294
|
+
`import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";`,
|
|
295
|
+
],
|
|
296
|
+
realisticBody: `<Popover>
|
|
297
|
+
<PopoverTrigger asChild><Button variant="outline">Open popover</Button></PopoverTrigger>
|
|
298
|
+
<PopoverContent className="w-64">
|
|
299
|
+
<p className="text-sm">Place anything inside the popover — settings, filters, a small form.</p>
|
|
300
|
+
</PopoverContent>
|
|
301
|
+
</Popover>`,
|
|
302
|
+
},
|
|
303
|
+
Progress: {
|
|
304
|
+
imports: [
|
|
305
|
+
`import { Progress } from "@behavioral-agentic-design-system/core/components/ui/progress";`,
|
|
306
|
+
],
|
|
307
|
+
realisticBody: `<div className="w-[320px] flex flex-col gap-3">
|
|
308
|
+
<Progress value={20} />
|
|
309
|
+
<Progress value={60} />
|
|
310
|
+
<Progress value={92} />
|
|
311
|
+
</div>`,
|
|
312
|
+
},
|
|
313
|
+
RadioGroup: {
|
|
314
|
+
imports: [
|
|
315
|
+
`import { RadioGroup, RadioGroupItem } from "@behavioral-agentic-design-system/core/components/ui/radio-group";`,
|
|
316
|
+
`import { Label } from "@behavioral-agentic-design-system/core/components/ui/label";`,
|
|
317
|
+
],
|
|
318
|
+
realisticBody: `<RadioGroup defaultValue="comfortable" className="flex flex-col gap-2 w-[280px]">
|
|
319
|
+
<div className="flex items-center gap-2"><RadioGroupItem value="default" id="r1" /><Label htmlFor="r1">Default</Label></div>
|
|
320
|
+
<div className="flex items-center gap-2"><RadioGroupItem value="comfortable" id="r2" /><Label htmlFor="r2">Comfortable</Label></div>
|
|
321
|
+
<div className="flex items-center gap-2"><RadioGroupItem value="compact" id="r3" /><Label htmlFor="r3">Compact</Label></div>
|
|
322
|
+
</RadioGroup>`,
|
|
323
|
+
},
|
|
324
|
+
ScrollArea: {
|
|
325
|
+
imports: [
|
|
326
|
+
`import { ScrollArea } from "@behavioral-agentic-design-system/core/components/ui/scroll-area";`,
|
|
327
|
+
],
|
|
328
|
+
realisticBody: `<ScrollArea className="h-48 w-64 rounded-md border p-3">
|
|
329
|
+
<div className="flex flex-col gap-2 text-sm">
|
|
330
|
+
{Array.from({ length: 30 }).map((_, i) => (
|
|
331
|
+
<div key={i}>Tag {i + 1}</div>
|
|
332
|
+
))}
|
|
333
|
+
</div>
|
|
334
|
+
</ScrollArea>`,
|
|
335
|
+
},
|
|
336
|
+
Select: {
|
|
337
|
+
imports: [
|
|
338
|
+
`import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@behavioral-agentic-design-system/core/components/ui/select";`,
|
|
339
|
+
],
|
|
340
|
+
realisticBody: `<Select>
|
|
341
|
+
<SelectTrigger className="w-[220px]"><SelectValue placeholder="Pick a fruit" /></SelectTrigger>
|
|
342
|
+
<SelectContent>
|
|
343
|
+
<SelectGroup>
|
|
344
|
+
<SelectLabel>Fruits</SelectLabel>
|
|
345
|
+
<SelectItem value="apple">Apple</SelectItem>
|
|
346
|
+
<SelectItem value="banana">Banana</SelectItem>
|
|
347
|
+
<SelectItem value="cherry">Cherry</SelectItem>
|
|
348
|
+
</SelectGroup>
|
|
349
|
+
</SelectContent>
|
|
350
|
+
</Select>`,
|
|
351
|
+
},
|
|
352
|
+
Separator: {
|
|
353
|
+
imports: [
|
|
354
|
+
`import { Separator } from "@behavioral-agentic-design-system/core/components/ui/separator";`,
|
|
355
|
+
],
|
|
356
|
+
realisticBody: `<div className="w-[280px] space-y-3">
|
|
357
|
+
<p className="text-sm">Section one.</p>
|
|
358
|
+
<Separator />
|
|
359
|
+
<p className="text-sm">Section two.</p>
|
|
360
|
+
</div>`,
|
|
361
|
+
},
|
|
362
|
+
Sheet: {
|
|
363
|
+
imports: [
|
|
364
|
+
`import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger } from "@behavioral-agentic-design-system/core/components/ui/sheet";`,
|
|
365
|
+
`import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";`,
|
|
366
|
+
],
|
|
367
|
+
realisticBody: `<Sheet>
|
|
368
|
+
<SheetTrigger asChild><Button variant="outline">Open sheet</Button></SheetTrigger>
|
|
369
|
+
<SheetContent>
|
|
370
|
+
<SheetHeader>
|
|
371
|
+
<SheetTitle>Edit profile</SheetTitle>
|
|
372
|
+
<SheetDescription>Make changes and save when you're done.</SheetDescription>
|
|
373
|
+
</SheetHeader>
|
|
374
|
+
</SheetContent>
|
|
375
|
+
</Sheet>`,
|
|
376
|
+
},
|
|
377
|
+
Skeleton: {
|
|
378
|
+
imports: [
|
|
379
|
+
`import { Skeleton } from "@behavioral-agentic-design-system/core/components/ui/skeleton";`,
|
|
380
|
+
],
|
|
381
|
+
realisticBody: `<div className="flex items-center gap-3 w-[320px]">
|
|
382
|
+
<Skeleton className="h-12 w-12 rounded-full" />
|
|
383
|
+
<div className="flex-1 space-y-2">
|
|
384
|
+
<Skeleton className="h-4 w-[80%]" />
|
|
385
|
+
<Skeleton className="h-4 w-[60%]" />
|
|
386
|
+
</div>
|
|
387
|
+
</div>`,
|
|
388
|
+
},
|
|
389
|
+
Slider: {
|
|
390
|
+
imports: [
|
|
391
|
+
`import { Slider } from "@behavioral-agentic-design-system/core/components/ui/slider";`,
|
|
392
|
+
],
|
|
393
|
+
realisticBody: `<Slider defaultValue={[40]} max={100} step={1} className="w-[280px]" />`,
|
|
394
|
+
},
|
|
395
|
+
Switch: {
|
|
396
|
+
imports: [
|
|
397
|
+
`import { Switch } from "@behavioral-agentic-design-system/core/components/ui/switch";`,
|
|
398
|
+
`import { Label } from "@behavioral-agentic-design-system/core/components/ui/label";`,
|
|
399
|
+
],
|
|
400
|
+
realisticBody: `<div className="flex items-center gap-2">
|
|
401
|
+
<Switch id="airplane" />
|
|
402
|
+
<Label htmlFor="airplane">Airplane mode</Label>
|
|
403
|
+
</div>`,
|
|
404
|
+
},
|
|
405
|
+
Table: {
|
|
406
|
+
imports: [
|
|
407
|
+
`import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow } from "@behavioral-agentic-design-system/core/components/ui/table";`,
|
|
408
|
+
],
|
|
409
|
+
realisticBody: `<Table className="w-[480px]">
|
|
410
|
+
<TableCaption>Recent invoices.</TableCaption>
|
|
411
|
+
<TableHeader>
|
|
412
|
+
<TableRow><TableHead>Invoice</TableHead><TableHead>Status</TableHead><TableHead className="text-right">Amount</TableHead></TableRow>
|
|
413
|
+
</TableHeader>
|
|
414
|
+
<TableBody>
|
|
415
|
+
<TableRow><TableCell>INV001</TableCell><TableCell>Paid</TableCell><TableCell className="text-right">$250.00</TableCell></TableRow>
|
|
416
|
+
<TableRow><TableCell>INV002</TableCell><TableCell>Pending</TableCell><TableCell className="text-right">$150.00</TableCell></TableRow>
|
|
417
|
+
</TableBody>
|
|
418
|
+
</Table>`,
|
|
419
|
+
},
|
|
420
|
+
Textarea: {
|
|
421
|
+
imports: [
|
|
422
|
+
`import { Textarea } from "@behavioral-agentic-design-system/core/components/ui/textarea";`,
|
|
423
|
+
`import { Label } from "@behavioral-agentic-design-system/core/components/ui/label";`,
|
|
424
|
+
],
|
|
425
|
+
realisticBody: `<div className="flex flex-col gap-2 w-[320px]">
|
|
426
|
+
<Label htmlFor="msg">Message</Label>
|
|
427
|
+
<Textarea id="msg" placeholder="Tell us what's on your mind." rows={4} />
|
|
428
|
+
</div>`,
|
|
429
|
+
},
|
|
430
|
+
Toggle: {
|
|
431
|
+
imports: [
|
|
432
|
+
`import { Toggle } from "@behavioral-agentic-design-system/core/components/ui/toggle";`,
|
|
433
|
+
`import { Bold } from "lucide-react";`,
|
|
434
|
+
],
|
|
435
|
+
realisticBody: `<Toggle aria-label="Toggle bold"><Bold className="h-4 w-4" /></Toggle>`,
|
|
436
|
+
},
|
|
437
|
+
ToggleGroup: {
|
|
438
|
+
imports: [
|
|
439
|
+
`import { ToggleGroup, ToggleGroupItem } from "@behavioral-agentic-design-system/core/components/ui/toggle-group";`,
|
|
440
|
+
`import { Bold, Italic, Underline } from "lucide-react";`,
|
|
441
|
+
],
|
|
442
|
+
realisticBody: `<ToggleGroup type="multiple">
|
|
443
|
+
<ToggleGroupItem value="bold" aria-label="Bold"><Bold className="h-4 w-4" /></ToggleGroupItem>
|
|
444
|
+
<ToggleGroupItem value="italic" aria-label="Italic"><Italic className="h-4 w-4" /></ToggleGroupItem>
|
|
445
|
+
<ToggleGroupItem value="underline" aria-label="Underline"><Underline className="h-4 w-4" /></ToggleGroupItem>
|
|
446
|
+
</ToggleGroup>`,
|
|
447
|
+
},
|
|
448
|
+
Tooltip: {
|
|
449
|
+
imports: [
|
|
450
|
+
`import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@behavioral-agentic-design-system/core/components/ui/tooltip";`,
|
|
451
|
+
`import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";`,
|
|
452
|
+
],
|
|
453
|
+
realisticBody: `<TooltipProvider>
|
|
454
|
+
<Tooltip>
|
|
455
|
+
<TooltipTrigger asChild><Button variant="outline">Hover me</Button></TooltipTrigger>
|
|
456
|
+
<TooltipContent>Helpful context</TooltipContent>
|
|
457
|
+
</Tooltip>
|
|
458
|
+
</TooltipProvider>`,
|
|
459
|
+
},
|
|
460
|
+
Tag: {
|
|
461
|
+
imports: [
|
|
462
|
+
`import { Tag } from "@behavioral-agentic-design-system/core/components/ui/tag";`,
|
|
463
|
+
],
|
|
464
|
+
realisticBody: `<div className="flex items-center gap-2 flex-wrap">
|
|
465
|
+
<Tag>Design</Tag>
|
|
466
|
+
<Tag>Engineering</Tag>
|
|
467
|
+
<Tag>Product</Tag>
|
|
468
|
+
</div>`,
|
|
469
|
+
},
|
|
470
|
+
Sonner: {
|
|
471
|
+
imports: [
|
|
472
|
+
`import { Toaster } from "@behavioral-agentic-design-system/core/components/ui/sonner";`,
|
|
473
|
+
`import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";`,
|
|
474
|
+
`import { toast } from "sonner";`,
|
|
475
|
+
],
|
|
476
|
+
realisticBody: `<>
|
|
477
|
+
<Button onClick={() => toast("Saved", { description: "Your changes are live." })}>Show toast</Button>
|
|
478
|
+
<Toaster />
|
|
479
|
+
</>`,
|
|
480
|
+
},
|
|
481
|
+
Resizable: {
|
|
482
|
+
imports: [
|
|
483
|
+
`import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@behavioral-agentic-design-system/core/components/ui/resizable";`,
|
|
484
|
+
],
|
|
485
|
+
realisticBody: `<ResizablePanelGroup direction="horizontal" className="h-40 w-[420px] rounded-md border">
|
|
486
|
+
<ResizablePanel defaultSize={40}><div className="p-3 text-sm">Left</div></ResizablePanel>
|
|
487
|
+
<ResizableHandle />
|
|
488
|
+
<ResizablePanel defaultSize={60}><div className="p-3 text-sm">Right</div></ResizablePanel>
|
|
489
|
+
</ResizablePanelGroup>`,
|
|
490
|
+
// Source file's first export is ResizableHandle, but the autodocs meta
|
|
491
|
+
// component should be the parent ResizablePanelGroup so Storybook doesn't
|
|
492
|
+
// try to render a bare <ResizableHandle /> outside its required parent.
|
|
493
|
+
metaComponent: "ResizablePanelGroup",
|
|
494
|
+
},
|
|
495
|
+
Sidebar: {
|
|
496
|
+
imports: [
|
|
497
|
+
`import { Sidebar, SidebarContent, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarProvider } from "@behavioral-agentic-design-system/core/components/ui/sidebar";`,
|
|
498
|
+
],
|
|
499
|
+
realisticBody: `<SidebarProvider>
|
|
500
|
+
<Sidebar className="h-[320px] w-[240px]">
|
|
501
|
+
<SidebarContent>
|
|
502
|
+
<SidebarGroup>
|
|
503
|
+
<SidebarGroupLabel>Workspace</SidebarGroupLabel>
|
|
504
|
+
<SidebarGroupContent>
|
|
505
|
+
<SidebarMenu>
|
|
506
|
+
<SidebarMenuItem><SidebarMenuButton>Inbox</SidebarMenuButton></SidebarMenuItem>
|
|
507
|
+
<SidebarMenuItem><SidebarMenuButton>Drafts</SidebarMenuButton></SidebarMenuItem>
|
|
508
|
+
<SidebarMenuItem><SidebarMenuButton>Sent</SidebarMenuButton></SidebarMenuItem>
|
|
509
|
+
</SidebarMenu>
|
|
510
|
+
</SidebarGroupContent>
|
|
511
|
+
</SidebarGroup>
|
|
512
|
+
</SidebarContent>
|
|
513
|
+
</Sidebar>
|
|
514
|
+
</SidebarProvider>`,
|
|
515
|
+
// Sidebar's variant prop applies to SidebarMenuButton (default vs outline).
|
|
516
|
+
// Without the Provider + content scaffolding, a bare <Sidebar variant="x" />
|
|
517
|
+
// renders nothing useful. Skip per-variant stories — Default + RealisticUse
|
|
518
|
+
// already show the component in context.
|
|
519
|
+
skipVariantStories: true,
|
|
520
|
+
skipSizeStories: true,
|
|
521
|
+
},
|
|
522
|
+
Chart: {
|
|
523
|
+
imports: [
|
|
524
|
+
`import { ChartContainer, ChartTooltip, ChartTooltipContent } from "@behavioral-agentic-design-system/core/components/ui/chart";`,
|
|
525
|
+
`import { Bar, BarChart, CartesianGrid, XAxis } from "recharts";`,
|
|
526
|
+
],
|
|
527
|
+
realisticBody: `<ChartContainer config={{ desktop: { label: "Desktop", color: "var(--chart-1)" } }} className="h-48 w-[420px]">
|
|
528
|
+
<BarChart data={[{ month: "Jan", desktop: 186 }, { month: "Feb", desktop: 305 }, { month: "Mar", desktop: 237 }]}>
|
|
529
|
+
<CartesianGrid vertical={false} />
|
|
530
|
+
<XAxis dataKey="month" tickLine={false} axisLine={false} />
|
|
531
|
+
<ChartTooltip content={<ChartTooltipContent />} />
|
|
532
|
+
<Bar dataKey="desktop" fill="var(--color-desktop)" radius={4} />
|
|
533
|
+
</BarChart>
|
|
534
|
+
</ChartContainer>`,
|
|
535
|
+
},
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
// Components for which the auto-template's Disabled story doesn't make sense
|
|
539
|
+
// (no `disabled` prop, the prop expects a complex value rather than boolean,
|
|
540
|
+
// or the component is display-only). Skip the Disabled slot when emitting.
|
|
541
|
+
//
|
|
542
|
+
// Calendar's `disabled` prop expects a Date matcher (function or Date[]), not
|
|
543
|
+
// a boolean — passing `disabled: true` doesn't crash but produces nothing
|
|
544
|
+
// meaningful. Same family for similar prop shapes.
|
|
545
|
+
const NO_INTERACTIVE_STATE = new Set([
|
|
546
|
+
"Alert",
|
|
547
|
+
"Avatar",
|
|
548
|
+
"Badge",
|
|
549
|
+
"Breadcrumb",
|
|
550
|
+
"Calendar",
|
|
551
|
+
"Card",
|
|
552
|
+
"Label",
|
|
553
|
+
"Progress",
|
|
554
|
+
"ScrollArea",
|
|
555
|
+
"Separator",
|
|
556
|
+
"Skeleton",
|
|
557
|
+
"Tag",
|
|
558
|
+
"Tooltip",
|
|
559
|
+
"Sonner",
|
|
560
|
+
"Resizable",
|
|
561
|
+
"Sidebar",
|
|
562
|
+
"Chart",
|
|
563
|
+
"ChartContainer",
|
|
564
|
+
"Collapsible",
|
|
565
|
+
"Command",
|
|
566
|
+
"DropdownMenu",
|
|
567
|
+
"Popover",
|
|
568
|
+
"Sheet",
|
|
569
|
+
"Table",
|
|
570
|
+
]);
|
|
571
|
+
|
|
572
|
+
// Components where a single-variant story renders meaningfully as
|
|
573
|
+
// `<Primary variant={v}>{label}</Primary>`. The label is the variant's
|
|
574
|
+
// pascalCase name unless overridden. Anything not in this set falls back to
|
|
575
|
+
// args-only stories (still useful for autodocs / controls panel).
|
|
576
|
+
const VARIANT_RENDERS_AS_PRIMARY = new Set([
|
|
577
|
+
"Alert",
|
|
578
|
+
"Badge",
|
|
579
|
+
"Button",
|
|
580
|
+
"Tag",
|
|
581
|
+
"Toggle",
|
|
582
|
+
]);
|
|
583
|
+
|
|
584
|
+
const SIZE_RENDERS_AS_PRIMARY = new Set([
|
|
585
|
+
"Button",
|
|
586
|
+
"Toggle",
|
|
587
|
+
"Input",
|
|
588
|
+
"Textarea",
|
|
589
|
+
]);
|
|
590
|
+
|
|
591
|
+
function template({ name, kebab, exports, variants, sizes }) {
|
|
592
|
+
const composition = COMPOSITIONS[name];
|
|
593
|
+
// Allow a per-component override for which export to use as the autodocs
|
|
594
|
+
// meta component. Default is the first export — but for some files the
|
|
595
|
+
// first export is a sub-piece (e.g. ResizableHandle) that can't render on
|
|
596
|
+
// its own. metaComponent picks the right "renderable parent" instead.
|
|
597
|
+
const primary =
|
|
598
|
+
composition?.metaComponent && exports.includes(composition.metaComponent)
|
|
599
|
+
? composition.metaComponent
|
|
600
|
+
: exports[0] ?? name;
|
|
601
|
+
const variantArgs = variants;
|
|
602
|
+
const sizeArgs = sizes;
|
|
603
|
+
const skipState = NO_INTERACTIVE_STATE.has(name);
|
|
604
|
+
|
|
605
|
+
// Component-specific composition wins for both default render and realistic
|
|
606
|
+
// use. Falls back to a generic <Primary /> render when we don't have one.
|
|
607
|
+
const importLines = composition?.imports ?? [
|
|
608
|
+
`import { ${exports.join(", ")} } from "@behavioral-agentic-design-system/core/components/ui/${kebab}";`,
|
|
609
|
+
];
|
|
610
|
+
const realisticBody =
|
|
611
|
+
composition?.realisticBody ?? `<${primary} />`;
|
|
612
|
+
|
|
613
|
+
// Three resolution paths for variant rendering, in priority order:
|
|
614
|
+
// 1. composition.variantRender — fully custom (e.g. Alert needs structured
|
|
615
|
+
// AlertTitle / AlertDescription, not plain text).
|
|
616
|
+
// 2. VARIANT_RENDERS_AS_PRIMARY — `<X variant={v}>{label}</X>` works fine
|
|
617
|
+
// (Badge / Tag / Toggle / Button).
|
|
618
|
+
// 3. composition.skipVariantStories — emit no per-variant stories at all
|
|
619
|
+
// (Sidebar / Tabs need scaffolding to render anything; let
|
|
620
|
+
// Default + RealisticUse cover the matrix visually).
|
|
621
|
+
// 4. fallback args-only — controls panel still works, canvas may be empty.
|
|
622
|
+
const variantStories =
|
|
623
|
+
variantArgs.length && !composition?.skipVariantStories
|
|
624
|
+
? variantArgs
|
|
625
|
+
.map((v) => {
|
|
626
|
+
const label = pascalIdent(v);
|
|
627
|
+
let body;
|
|
628
|
+
if (composition?.variantRender) {
|
|
629
|
+
body = `\n render: () => (${composition.variantRender(v, label)}),\n`;
|
|
630
|
+
} else if (VARIANT_RENDERS_AS_PRIMARY.has(name)) {
|
|
631
|
+
body = `\n render: () => <${primary} variant="${v}">${label}</${primary}>,\n`;
|
|
632
|
+
} else {
|
|
633
|
+
body = `\n args: { variant: "${v}" } as any,\n`;
|
|
634
|
+
}
|
|
635
|
+
return `export const Variant_${label}: Story = {${body}};`;
|
|
636
|
+
})
|
|
637
|
+
.join("\n\n")
|
|
638
|
+
: "";
|
|
639
|
+
|
|
640
|
+
const sizeStories =
|
|
641
|
+
sizeArgs.length && !composition?.skipSizeStories
|
|
642
|
+
? sizeArgs
|
|
643
|
+
.map((s) => {
|
|
644
|
+
const label = pascalIdent(s);
|
|
645
|
+
let body;
|
|
646
|
+
if (composition?.sizeRender) {
|
|
647
|
+
body = `\n render: () => (${composition.sizeRender(s, label)}),\n`;
|
|
648
|
+
} else if (SIZE_RENDERS_AS_PRIMARY.has(name)) {
|
|
649
|
+
body = `\n render: () => <${primary} size="${s}">${label}</${primary}>,\n`;
|
|
650
|
+
} else {
|
|
651
|
+
body = `\n args: { size: "${s}" } as any,\n`;
|
|
652
|
+
}
|
|
653
|
+
return `export const Size_${label}: Story = {${body}};`;
|
|
654
|
+
})
|
|
655
|
+
.join("\n\n")
|
|
656
|
+
: "";
|
|
657
|
+
|
|
658
|
+
const stateStories = skipState
|
|
659
|
+
? ""
|
|
660
|
+
: `export const Disabled: Story = {
|
|
661
|
+
args: { disabled: true } as any,
|
|
662
|
+
};`;
|
|
663
|
+
|
|
664
|
+
const sections = [
|
|
665
|
+
`export const Default: Story = {
|
|
666
|
+
render: () => (${realisticBody}),
|
|
667
|
+
};`,
|
|
668
|
+
variantStories,
|
|
669
|
+
sizeStories,
|
|
670
|
+
stateStories,
|
|
671
|
+
`export const RealisticUse: Story = {
|
|
672
|
+
render: () => (${realisticBody}),
|
|
673
|
+
};`,
|
|
674
|
+
]
|
|
675
|
+
.filter(Boolean)
|
|
676
|
+
.join("\n\n");
|
|
677
|
+
|
|
678
|
+
return `import type { Meta, StoryObj } from "@storybook/react";
|
|
679
|
+
${importLines.join("\n")}
|
|
680
|
+
|
|
681
|
+
const meta: Meta<typeof ${primary}> = {
|
|
682
|
+
title: "Components/${name}",
|
|
683
|
+
component: ${primary},
|
|
684
|
+
parameters: { layout: "centered" },
|
|
685
|
+
tags: ["autodocs"],
|
|
686
|
+
};
|
|
687
|
+
|
|
688
|
+
export default meta;
|
|
689
|
+
type Story = StoryObj<typeof meta>;
|
|
690
|
+
|
|
691
|
+
${sections}
|
|
692
|
+
`;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
function generateOne(c) {
|
|
696
|
+
const source = readFileSync(c.path, "utf8");
|
|
697
|
+
const exports = detectExports(source);
|
|
698
|
+
if (exports.length === 0) return null;
|
|
699
|
+
const { variants, sizes } = detectCva(source);
|
|
700
|
+
return template({ name: c.name, kebab: c.kebab, exports, variants, sizes });
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
const components = listComponents();
|
|
704
|
+
const generated = [];
|
|
705
|
+
const replacedStubs = [];
|
|
706
|
+
const skipped = [];
|
|
707
|
+
|
|
708
|
+
for (const c of components) {
|
|
709
|
+
const out = join(STORIES_DIR, `${c.name}.stories.tsx`);
|
|
710
|
+
const exists = existsSync(out);
|
|
711
|
+
|
|
712
|
+
if (exists) {
|
|
713
|
+
const existing = readFileSync(out, "utf8");
|
|
714
|
+
if (looksLikeStub(existing)) {
|
|
715
|
+
const content = generateOne(c);
|
|
716
|
+
if (!content) {
|
|
717
|
+
skipped.push(`${c.name} (stub but no component exports detected)`);
|
|
718
|
+
continue;
|
|
719
|
+
}
|
|
720
|
+
writeFileSync(out, content);
|
|
721
|
+
replacedStubs.push(c.name);
|
|
722
|
+
} else {
|
|
723
|
+
skipped.push(c.name);
|
|
724
|
+
}
|
|
725
|
+
continue;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
const content = generateOne(c);
|
|
729
|
+
if (!content) {
|
|
730
|
+
skipped.push(`${c.name} (no exports detected)`);
|
|
731
|
+
continue;
|
|
732
|
+
}
|
|
733
|
+
writeFileSync(out, content);
|
|
734
|
+
generated.push(c.name);
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// Orphan cleanup: remove story files whose name doesn't map to a current
|
|
738
|
+
// component. Older sync-stories.js used a simpler pascalize that left
|
|
739
|
+
// lowercase-pascal duplicates (Dropdownmenu vs DropdownMenu, Scrollarea vs
|
|
740
|
+
// ScrollArea, etc.) which Storybook tries to render and fails on. Anything
|
|
741
|
+
// in components/*.stories.tsx that doesn't match a real component name now
|
|
742
|
+
// gets deleted on every run so duplicates can't slip back in.
|
|
743
|
+
const validNames = new Set(components.map((c) => c.name));
|
|
744
|
+
const removed = [];
|
|
745
|
+
for (const f of readdirSync(STORIES_DIR)) {
|
|
746
|
+
if (!f.endsWith(".stories.tsx")) continue;
|
|
747
|
+
const name = f.replace(/\.stories\.tsx$/, "");
|
|
748
|
+
// Foundations/* and other intentional non-primitive stories live at
|
|
749
|
+
// a different path and are skipped by readdirSync (top-level only).
|
|
750
|
+
if (validNames.has(name)) continue;
|
|
751
|
+
// Skip anything that's clearly a curated/non-primitive story — we don't
|
|
752
|
+
// want to delete user-authored compositions. Only remove files whose name
|
|
753
|
+
// is a lowercase-pascal collision (e.g. Dropdownmenu when DropdownMenu
|
|
754
|
+
// exists).
|
|
755
|
+
const lowercased = name[0] + name.slice(1).toLowerCase();
|
|
756
|
+
const isCollision = [...validNames].some(
|
|
757
|
+
(v) => v.toLowerCase() === name.toLowerCase() && v !== name,
|
|
758
|
+
);
|
|
759
|
+
if (isCollision) {
|
|
760
|
+
try {
|
|
761
|
+
// eslint-disable-next-line no-undef
|
|
762
|
+
execSync(`rm "${join(STORIES_DIR, f)}"`);
|
|
763
|
+
removed.push(name);
|
|
764
|
+
} catch {}
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
console.log(`Generated ${generated.length} new story files.`);
|
|
769
|
+
for (const g of generated) console.log(` + components/${g}.stories.tsx`);
|
|
770
|
+
console.log(`\nReplaced ${replacedStubs.length} stubs.`);
|
|
771
|
+
for (const r of replacedStubs) console.log(` ↻ components/${r}.stories.tsx`);
|
|
772
|
+
if (removed.length) {
|
|
773
|
+
console.log(`\nRemoved ${removed.length} orphan duplicates:`);
|
|
774
|
+
for (const r of removed) console.log(` − components/${r}.stories.tsx`);
|
|
775
|
+
}
|
|
776
|
+
if (skipped.length) {
|
|
777
|
+
console.log(`\nSkipped ${skipped.length} (hand-edited or unparseable):`);
|
|
778
|
+
for (const s of skipped) console.log(` - ${s}`);
|
|
779
|
+
}
|
|
780
|
+
console.log("");
|
|
781
|
+
console.log("Generated stories are baselines — feel free to polish.");
|
|
782
|
+
console.log("They satisfy the strict coverage check; commit when ready.");
|
|
783
|
+
try {
|
|
784
|
+
execSync("git add components/*.stories.tsx", { stdio: "inherit" });
|
|
785
|
+
} catch {}
|