@behavioral-agentic-design-system/core 0.11.1 → 0.12.1

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.11.1",
3
+ "version": "0.12.1",
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)",
@@ -50,6 +50,7 @@
50
50
  "./fonts/*": "./src/fonts/*",
51
51
  "./tokens.json": "./src/tokens.json",
52
52
  "./tokens.default.json": "./src/tokens.default.json",
53
+ "./docs-trace-globs.json": "./src/docs-trace-globs.json",
53
54
  "./lib/*": "./src/lib/*.ts",
54
55
  "./hooks/*": "./src/hooks/*.ts",
55
56
  "./data/*": "./src/data/*.ts",
@@ -11,6 +11,11 @@ const ROOT = process.cwd();
11
11
  // re-checked against the same allowlist — never write a markdown file outside
12
12
  // the same surface the Docs tab can show. Path traversal is blocked at the
13
13
  // normalize step before any pattern match runs.
14
+ //
15
+ // KEEP IN SYNC WITH ../../docs-trace-globs.json — that file lists the same
16
+ // paths as next.config `outputFileTracingIncludes` globs so the deploy bundles
17
+ // every file this allowlist can serve. Add a path here → add its glob there,
18
+ // or it 404s on Vercel (the "Couldn't load README.md" bug).
14
19
  const ALLOWED_ROOT_MD = new Set([
15
20
  "BRIEF.md",
16
21
  "README.md",
@@ -2,8 +2,7 @@ import { NextResponse } from "next/server";
2
2
  import { load, type CheerioAPI } from "cheerio";
3
3
 
4
4
  const FETCH_TIMEOUT_MS = 12_000;
5
- const USER_AGENT =
6
- "Mozilla/5.0 (compatible; BADS-Onboarding/1.0; +https://github.com/dazzag24/behavioral-agentic-design-system)";
5
+ const USER_AGENT = "Mozilla/5.0 (compatible; BADS-Onboarding/1.0)";
7
6
 
8
7
  export type ExtractedColor = {
9
8
  value: string;
@@ -41,6 +40,39 @@ export type ExtractResult = {
41
40
  warnings: string[];
42
41
  };
43
42
 
43
+ // SSRF defense-in-depth: reject URLs that point at private, internal, or
44
+ // loopback targets so a user-supplied URL can't be used to probe internal
45
+ // services or the cloud metadata endpoint. This is hostname-literal checking
46
+ // only (it inspects the string the user typed) and is NOT full DNS-rebinding
47
+ // protection — a hostname that resolves to a private IP at fetch time still
48
+ // gets through. Strip the brackets IPv6 hosts arrive wrapped in before testing.
49
+ function isBlockedHost(hostname: string): boolean {
50
+ const host = hostname.trim().toLowerCase().replace(/^\[|\]$/g, "");
51
+ if (!host) return true;
52
+
53
+ // localhost and internal-only TLD suffixes
54
+ if (host === "localhost") return true;
55
+ if (/\.local$/.test(host) || /\.internal$/.test(host)) return true;
56
+
57
+ // IPv6 loopback, unique-local (fc00::/7 → fc/fd) and link-local (fe80::)
58
+ if (host === "::1") return true;
59
+ if (/^f[cd][0-9a-f]*:/.test(host)) return true;
60
+ if (/^fe80:/.test(host)) return true;
61
+
62
+ // IPv4 unspecified, loopback 127.0.0.0/8, and link-local 169.254.0.0/16
63
+ // (covers the 169.254.169.254 cloud metadata IP)
64
+ if (host === "0.0.0.0") return true;
65
+ if (/^127\./.test(host)) return true;
66
+ if (/^169\.254\./.test(host)) return true;
67
+
68
+ // IPv4 private ranges: 10/8, 172.16-31/12, 192.168/16
69
+ if (/^10\./.test(host)) return true;
70
+ if (/^172\.(1[6-9]|2[0-9]|3[01])\./.test(host)) return true;
71
+ if (/^192\.168\./.test(host)) return true;
72
+
73
+ return false;
74
+ }
75
+
44
76
  function normalizeUrl(input: string): string | null {
45
77
  const trimmed = input.trim();
46
78
  if (!trimmed) return null;
@@ -48,6 +80,7 @@ function normalizeUrl(input: string): string | null {
48
80
  try {
49
81
  const u = new URL(withProtocol);
50
82
  if (u.protocol !== "https:" && u.protocol !== "http:") return null;
83
+ if (isBlockedHost(u.hostname)) return null;
51
84
  return u.toString();
52
85
  } catch {
53
86
  return null;
@@ -1,15 +1,30 @@
1
1
  import { NextRequest, NextResponse } from "next/server";
2
2
 
3
3
  // POST /api/site-auth handles the password submission from /site-login.
4
- // Validates against SITE_PASSWORD and sets an httpOnly cookie containing
5
- // the password value. The middleware (middleware.ts at the repo root)
6
- // reads the cookie on every subsequent request. Returns a 303 redirect
7
- // either back to the requested `next` path (success) or back to
8
- // /site-login with ?error=1 (mismatch).
4
+ // Validates against SITE_PASSWORD and sets an httpOnly cookie containing a
5
+ // derived token (the SHA-256 hex of the password), NOT the password itself,
6
+ // so a leaked cookie never reveals the configured password. The middleware
7
+ // (middleware.ts at the repo root) derives the same token and compares it on
8
+ // every subsequent request. Returns a 303 redirect either back to the
9
+ // requested `next` path (success) or back to /site-login with ?error=1
10
+ // (mismatch).
9
11
 
10
12
  const COOKIE_NAME = "bads_site_auth";
11
13
  const COOKIE_MAX_AGE_SECONDS = 60 * 60 * 24 * 30; // 30 days
12
14
 
15
+ // Hex SHA-256 of the password via Web Crypto. Kept self-contained (also
16
+ // duplicated in middleware.ts) so both sides derive the identical token and
17
+ // the gate stays consistent.
18
+ async function tokenFor(password: string): Promise<string> {
19
+ const digest = await crypto.subtle.digest(
20
+ "SHA-256",
21
+ new TextEncoder().encode(password),
22
+ );
23
+ return Array.from(new Uint8Array(digest))
24
+ .map((b) => b.toString(16).padStart(2, "0"))
25
+ .join("");
26
+ }
27
+
13
28
  export async function POST(req: NextRequest) {
14
29
  const password = process.env.SITE_PASSWORD;
15
30
  if (!password) {
@@ -34,7 +49,7 @@ export async function POST(req: NextRequest) {
34
49
  new URL(sanitizeNext(requestedNext), req.url),
35
50
  303,
36
51
  );
37
- redirect.cookies.set(COOKIE_NAME, password, {
52
+ redirect.cookies.set(COOKIE_NAME, await tokenFor(password), {
38
53
  path: "/",
39
54
  httpOnly: true,
40
55
  sameSite: "lax",
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
 
3
+ import * as React from "react";
3
4
  import {
4
5
  Pagination,
5
6
  PaginationContent,
@@ -30,7 +31,7 @@ import { Skeleton } from "@behavioral-agentic-design-system/core/components/ui/s
30
31
  import { Progress } from "@behavioral-agentic-design-system/core/components/ui/progress";
31
32
  import { Slider } from "@behavioral-agentic-design-system/core/components/ui/slider";
32
33
  import { ScrollArea } from "@behavioral-agentic-design-system/core/components/ui/scroll-area";
33
- import { Tabs, TabsContent, TabsList, TabsTrigger } from "@behavioral-agentic-design-system/core/components/ui/tabs";
34
+ import { Tabs, TabsContent, TabsList, TabsTrigger, TabsSelect } from "@behavioral-agentic-design-system/core/components/ui/tabs";
34
35
  import {
35
36
  Dialog,
36
37
  DialogContent,
@@ -106,6 +107,24 @@ import {
106
107
  NavigationMenuList,
107
108
  NavigationMenuTrigger,
108
109
  } from "@behavioral-agentic-design-system/core/components/ui/navigation-menu";
110
+ import { Combobox } from "@behavioral-agentic-design-system/core/components/ui/combobox";
111
+ import { Kbd } from "@behavioral-agentic-design-system/core/components/ui/kbd";
112
+ import {
113
+ Toolbar,
114
+ ToolbarButton,
115
+ ToolbarSeparator,
116
+ } from "@behavioral-agentic-design-system/core/components/ui/toolbar";
117
+ import {
118
+ BoldIcon,
119
+ ItalicIcon,
120
+ UnderlineIcon,
121
+ AlignLeftIcon,
122
+ AlignCenterIcon,
123
+ AlignRightIcon,
124
+ LinkIcon as ToolbarLinkIcon,
125
+ UndoIcon,
126
+ RedoIcon,
127
+ } from "lucide-react";
109
128
  import {
110
129
  Menubar,
111
130
  MenubarCheckboxItem,
@@ -155,6 +174,144 @@ function Section({ title, children }: { title: string; children: React.ReactNode
155
174
  );
156
175
  }
157
176
 
177
+ function ToolbarFormattingDemo() {
178
+ const [bold, setBold] = React.useState(false);
179
+ const [italic, setItalic] = React.useState(false);
180
+ const [underline, setUnderline] = React.useState(false);
181
+ const [align, setAlign] = React.useState<"left" | "center" | "right">("left");
182
+ return (
183
+ <div className="space-y-4">
184
+ <Toolbar aria-label="Text formatting">
185
+ <ToolbarButton aria-label="Undo"><UndoIcon strokeWidth={1.5} className="size-4" /></ToolbarButton>
186
+ <ToolbarButton aria-label="Redo"><RedoIcon strokeWidth={1.5} className="size-4" /></ToolbarButton>
187
+ <ToolbarSeparator />
188
+ <ToolbarButton aria-label="Bold" aria-pressed={bold} onClick={() => setBold(v => !v)}>
189
+ <BoldIcon strokeWidth={1.5} className="size-4" />
190
+ </ToolbarButton>
191
+ <ToolbarButton aria-label="Italic" aria-pressed={italic} onClick={() => setItalic(v => !v)}>
192
+ <ItalicIcon strokeWidth={1.5} className="size-4" />
193
+ </ToolbarButton>
194
+ <ToolbarButton aria-label="Underline" aria-pressed={underline} onClick={() => setUnderline(v => !v)}>
195
+ <UnderlineIcon strokeWidth={1.5} className="size-4" />
196
+ </ToolbarButton>
197
+ <ToolbarSeparator />
198
+ <ToolbarButton aria-label="Align left" aria-pressed={align === "left"} onClick={() => setAlign("left")}>
199
+ <AlignLeftIcon strokeWidth={1.5} className="size-4" />
200
+ </ToolbarButton>
201
+ <ToolbarButton aria-label="Align center" aria-pressed={align === "center"} onClick={() => setAlign("center")}>
202
+ <AlignCenterIcon strokeWidth={1.5} className="size-4" />
203
+ </ToolbarButton>
204
+ <ToolbarButton aria-label="Align right" aria-pressed={align === "right"} onClick={() => setAlign("right")}>
205
+ <AlignRightIcon strokeWidth={1.5} className="size-4" />
206
+ </ToolbarButton>
207
+ <ToolbarSeparator />
208
+ <ToolbarButton aria-label="Insert link"><ToolbarLinkIcon strokeWidth={1.5} className="size-4" /></ToolbarButton>
209
+ </Toolbar>
210
+ <p
211
+ className="max-w-md rounded-md border bg-muted/30 px-4 py-3 text-sm leading-relaxed"
212
+ style={{
213
+ fontWeight: bold ? 700 : 400,
214
+ fontStyle: italic ? "italic" : "normal",
215
+ textDecoration: underline ? "underline" : "none",
216
+ textAlign: align,
217
+ }}
218
+ >
219
+ Sample document text — toggle formatting above to see it reflect here.
220
+ Arrow keys navigate between toolbar buttons.
221
+ </p>
222
+ </div>
223
+ );
224
+ }
225
+
226
+ const COMBOBOX_FRAMEWORKS = [
227
+ { value: "next", label: "Next.js" },
228
+ { value: "sveltekit", label: "SvelteKit" },
229
+ { value: "nuxt", label: "Nuxt.js" },
230
+ { value: "remix", label: "Remix" },
231
+ { value: "astro", label: "Astro" },
232
+ ];
233
+
234
+ function ComboboxDemo() {
235
+ const [value, setValue] = React.useState("");
236
+ return (
237
+ <Combobox
238
+ options={COMBOBOX_FRAMEWORKS}
239
+ value={value}
240
+ onValueChange={setValue}
241
+ placeholder="Select framework..."
242
+ searchPlaceholder="Search frameworks..."
243
+ />
244
+ );
245
+ }
246
+
247
+ function ComboboxWithValueDemo() {
248
+ const [value, setValue] = React.useState("next");
249
+ return (
250
+ <Combobox
251
+ options={COMBOBOX_FRAMEWORKS}
252
+ value={value}
253
+ onValueChange={setValue}
254
+ placeholder="Select framework..."
255
+ searchPlaceholder="Search frameworks..."
256
+ />
257
+ );
258
+ }
259
+
260
+ const RESPONSIVE_TAB_SECTIONS = [
261
+ { value: "account", label: "Account Information" },
262
+ { value: "volunteer", label: "Volunteer History" },
263
+ { value: "preferences", label: "Preferences" },
264
+ { value: "billing", label: "Billing & Plan" },
265
+ ];
266
+
267
+ // Responsive tabs: TabsSelect (dropdown) under sm, the underline TabsList at sm+
268
+ // — both drive the same controlled value, so long labels never clip on mobile.
269
+ function ResponsiveTabsDemo() {
270
+ const [value, setValue] = React.useState("account");
271
+ return (
272
+ <Tabs value={value} onValueChange={setValue} className="w-full max-w-md">
273
+ <TabsSelect
274
+ items={RESPONSIVE_TAB_SECTIONS}
275
+ value={value}
276
+ onValueChange={setValue}
277
+ className="sm:hidden"
278
+ />
279
+ <TabsList variant="line" scrollable className="hidden sm:flex w-full justify-start">
280
+ {RESPONSIVE_TAB_SECTIONS.map((s) => (
281
+ <TabsTrigger key={s.value} value={s.value}>
282
+ {s.label}
283
+ </TabsTrigger>
284
+ ))}
285
+ </TabsList>
286
+ {RESPONSIVE_TAB_SECTIONS.map((s) => (
287
+ <TabsContent key={s.value} value={s.value} className="pt-4 text-sm text-muted-foreground">
288
+ {s.label} content.
289
+ </TabsContent>
290
+ ))}
291
+ </Tabs>
292
+ );
293
+ }
294
+
295
+ function ComboboxDisabledOptionsDemo() {
296
+ const [value, setValue] = React.useState("");
297
+ const options = [
298
+ { value: "next", label: "Next.js" },
299
+ { value: "sveltekit", label: "SvelteKit", disabled: true },
300
+ { value: "nuxt", label: "Nuxt.js" },
301
+ { value: "remix", label: "Remix", disabled: true },
302
+ { value: "astro", label: "Astro" },
303
+ ];
304
+ return (
305
+ <Combobox
306
+ options={options}
307
+ value={value}
308
+ onValueChange={setValue}
309
+ placeholder="Select framework..."
310
+ searchPlaceholder="Search frameworks..."
311
+ />
312
+ );
313
+ }
314
+
158
315
  export default function ComponentsPreview() {
159
316
  return (
160
317
  <div className="min-h-screen bg-background">
@@ -334,6 +491,11 @@ export default function ComponentsPreview() {
334
491
  </TabsContent>
335
492
  </Tabs>
336
493
  <Separator className="my-4" />
494
+ <p className="mb-3 text-xs font-medium text-muted-foreground">
495
+ Responsive — dropdown under sm, scrollable underline tabs at sm+ (resize to see)
496
+ </p>
497
+ <ResponsiveTabsDemo />
498
+ <Separator className="my-4" />
337
499
  <div className="flex flex-wrap gap-3">
338
500
  {(["sm", "default", "lg", "xl", "2xl"] as const).map((s) => (
339
501
  <Dialog key={s}>
@@ -1259,6 +1421,114 @@ export default function ComponentsPreview() {
1259
1421
  </div>
1260
1422
  </Section>
1261
1423
 
1424
+ <Section title="Toolbar">
1425
+ <div className="space-y-6">
1426
+ <div className="space-y-2">
1427
+ <p className="text-sm font-medium text-muted-foreground">Formatting toolbar with active state</p>
1428
+ <ToolbarFormattingDemo />
1429
+ </div>
1430
+ <div className="space-y-2">
1431
+ <p className="text-sm font-medium text-muted-foreground">Vertical orientation</p>
1432
+ <Toolbar orientation="vertical" aria-label="Document actions" className="w-fit">
1433
+ <ToolbarButton aria-label="Undo"><UndoIcon strokeWidth={1.5} className="size-4" /></ToolbarButton>
1434
+ <ToolbarButton aria-label="Redo"><RedoIcon strokeWidth={1.5} className="size-4" /></ToolbarButton>
1435
+ <ToolbarSeparator className="h-px w-full" />
1436
+ <ToolbarButton aria-label="Bold"><BoldIcon strokeWidth={1.5} className="size-4" /></ToolbarButton>
1437
+ <ToolbarButton aria-label="Italic"><ItalicIcon strokeWidth={1.5} className="size-4" /></ToolbarButton>
1438
+ </Toolbar>
1439
+ </div>
1440
+ <div className="space-y-2">
1441
+ <p className="text-sm font-medium text-muted-foreground">Disabled state</p>
1442
+ <Toolbar aria-label="Disabled toolbar">
1443
+ <ToolbarButton aria-label="Bold" disabled><BoldIcon strokeWidth={1.5} className="size-4" /></ToolbarButton>
1444
+ <ToolbarButton aria-label="Italic" disabled><ItalicIcon strokeWidth={1.5} className="size-4" /></ToolbarButton>
1445
+ <ToolbarButton aria-label="Underline" disabled><UnderlineIcon strokeWidth={1.5} className="size-4" /></ToolbarButton>
1446
+ </Toolbar>
1447
+ </div>
1448
+ </div>
1449
+ </Section>
1450
+ <Section title="Kbd">
1451
+ <div className="space-y-6">
1452
+ <div className="space-y-2">
1453
+ <p className="text-sm font-medium text-muted-foreground">Default variant</p>
1454
+ <div className="flex items-center gap-1.5">
1455
+ <Kbd>⌘</Kbd>
1456
+ <Kbd>K</Kbd>
1457
+ <Kbd>Shift</Kbd>
1458
+ <Kbd>Esc</Kbd>
1459
+ </div>
1460
+ </div>
1461
+ <div className="space-y-2">
1462
+ <p className="text-sm font-medium text-muted-foreground">Outline variant</p>
1463
+ <div className="flex items-center gap-1.5">
1464
+ <Kbd variant="outline">⌘</Kbd>
1465
+ <Kbd variant="outline">K</Kbd>
1466
+ <Kbd variant="outline">Shift</Kbd>
1467
+ <Kbd variant="outline">Esc</Kbd>
1468
+ </div>
1469
+ </div>
1470
+ <div className="space-y-2">
1471
+ <p className="text-sm font-medium text-muted-foreground">Small size</p>
1472
+ <div className="flex items-center gap-1.5">
1473
+ <Kbd size="sm">⌘</Kbd>
1474
+ <Kbd size="sm">Shift</Kbd>
1475
+ <Kbd size="sm">K</Kbd>
1476
+ </div>
1477
+ </div>
1478
+ <div className="space-y-2">
1479
+ <p className="text-sm font-medium text-muted-foreground">Keyboard shortcuts list</p>
1480
+ <div className="w-[320px] space-y-2 rounded-lg border bg-card p-4">
1481
+ {[
1482
+ { keys: ["⌘", "K"], label: "Open command palette" },
1483
+ { keys: ["⌘", "Shift", "F"], label: "Search across files" },
1484
+ { keys: ["⌘", "B"], label: "Toggle sidebar" },
1485
+ { keys: ["⌘", "Z"], label: "Undo last action" },
1486
+ ].map(({ keys, label }) => (
1487
+ <div key={label} className="flex items-center justify-between">
1488
+ <span className="text-sm text-foreground">{label}</span>
1489
+ <div className="flex items-center gap-1">
1490
+ {keys.map((key) => (
1491
+ <Kbd key={key} size="sm">{key}</Kbd>
1492
+ ))}
1493
+ </div>
1494
+ </div>
1495
+ ))}
1496
+ </div>
1497
+ </div>
1498
+ </div>
1499
+ </Section>
1500
+ <Section title="Combobox">
1501
+ <div className="space-y-6">
1502
+ <div className="grid grid-cols-1 gap-6 sm:grid-cols-2">
1503
+ <div className="space-y-2">
1504
+ <p className="text-sm font-medium text-muted-foreground">Default (no selection)</p>
1505
+ <ComboboxDemo />
1506
+ </div>
1507
+ <div className="space-y-2">
1508
+ <p className="text-sm font-medium text-muted-foreground">With value selected</p>
1509
+ <ComboboxWithValueDemo />
1510
+ </div>
1511
+ </div>
1512
+ <div className="grid grid-cols-1 gap-6 sm:grid-cols-2">
1513
+ <div className="space-y-2">
1514
+ <p className="text-sm font-medium text-muted-foreground">Disabled</p>
1515
+ <Combobox
1516
+ options={[
1517
+ { value: "next", label: "Next.js" },
1518
+ { value: "remix", label: "Remix" },
1519
+ ]}
1520
+ value="next"
1521
+ disabled
1522
+ placeholder="Select framework..."
1523
+ />
1524
+ </div>
1525
+ <div className="space-y-2">
1526
+ <p className="text-sm font-medium text-muted-foreground">With disabled options</p>
1527
+ <ComboboxDisabledOptionsDemo />
1528
+ </div>
1529
+ </div>
1530
+ </div>
1531
+ </Section>
1262
1532
  <Section title="Context Menu">
1263
1533
  <div className="space-y-6">
1264
1534
  <div className="space-y-3">
@@ -0,0 +1,107 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { CheckIcon, ChevronsUpDownIcon } from "lucide-react"
5
+
6
+ import { cn } from "../../lib/utils"
7
+ import { Button } from "./button"
8
+ import {
9
+ Command,
10
+ CommandEmpty,
11
+ CommandGroup,
12
+ CommandInput,
13
+ CommandItem,
14
+ CommandList,
15
+ } from "./command"
16
+ import { Popover, PopoverContent, PopoverTrigger } from "./popover"
17
+
18
+ export interface ComboboxOption {
19
+ value: string
20
+ label: string
21
+ disabled?: boolean
22
+ }
23
+
24
+ export interface ComboboxProps {
25
+ options: ComboboxOption[]
26
+ value?: string
27
+ onValueChange?: (value: string) => void
28
+ placeholder?: string
29
+ searchPlaceholder?: string
30
+ emptyText?: string
31
+ disabled?: boolean
32
+ className?: string
33
+ }
34
+
35
+ function Combobox({
36
+ options,
37
+ value,
38
+ onValueChange,
39
+ placeholder = "Select option...",
40
+ searchPlaceholder = "Search...",
41
+ emptyText = "No results found.",
42
+ disabled = false,
43
+ className,
44
+ }: ComboboxProps) {
45
+ const [open, setOpen] = React.useState(false)
46
+
47
+ const selected = options.find((o) => o.value === value)
48
+
49
+ return (
50
+ <Popover open={open} onOpenChange={setOpen}>
51
+ <PopoverTrigger asChild>
52
+ <Button
53
+ data-slot="combobox"
54
+ variant="outline"
55
+ aria-expanded={open}
56
+ aria-haspopup="listbox"
57
+ disabled={disabled}
58
+ className={cn("w-full justify-between font-normal", className)}
59
+ >
60
+ <span className={cn("truncate", !selected && "text-muted-foreground")}>
61
+ {selected ? selected.label : placeholder}
62
+ </span>
63
+ <ChevronsUpDownIcon
64
+ strokeWidth={1.5}
65
+ className="ml-2 size-4 shrink-0 opacity-50 transition-transform"
66
+ style={{
67
+ transitionDuration: "var(--duration-fast)",
68
+ transitionTimingFunction: "var(--ease-out)",
69
+ }}
70
+ />
71
+ </Button>
72
+ </PopoverTrigger>
73
+ <PopoverContent className="w-[var(--radix-popover-trigger-width)] min-w-[200px] p-0">
74
+ <Command>
75
+ <CommandInput placeholder={searchPlaceholder} />
76
+ <CommandList>
77
+ <CommandEmpty>{emptyText}</CommandEmpty>
78
+ <CommandGroup>
79
+ {options.map((option) => (
80
+ <CommandItem
81
+ key={option.value}
82
+ value={option.value}
83
+ disabled={option.disabled}
84
+ onSelect={(current) => {
85
+ onValueChange?.(current === value ? "" : current)
86
+ setOpen(false)
87
+ }}
88
+ >
89
+ <CheckIcon
90
+ strokeWidth={1.5}
91
+ className={cn(
92
+ "mr-2 size-4 shrink-0",
93
+ value === option.value ? "opacity-100" : "opacity-0"
94
+ )}
95
+ />
96
+ {option.label}
97
+ </CommandItem>
98
+ ))}
99
+ </CommandGroup>
100
+ </CommandList>
101
+ </Command>
102
+ </PopoverContent>
103
+ </Popover>
104
+ )
105
+ }
106
+
107
+ export { Combobox }
@@ -22,6 +22,7 @@ export * from "./dropdown-menu";
22
22
  export * from "./file-upload";
23
23
  export * from "./hover-card";
24
24
  export * from "./input";
25
+ export * from "./kbd";
25
26
  export * from "./label";
26
27
  export * from "./menubar";
27
28
  export * from "./navigation-menu";
@@ -49,4 +50,5 @@ export * from "./tag";
49
50
  export * from "./textarea";
50
51
  export * from "./toggle";
51
52
  export * from "./toggle-group";
53
+ export * from "./toolbar";
52
54
  export * from "./tooltip";
@@ -0,0 +1,48 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { cva, type VariantProps } from "class-variance-authority"
5
+
6
+ import { cn } from "../../lib/utils"
7
+
8
+ const kbdVariants = cva(
9
+ [
10
+ "inline-flex items-center justify-center",
11
+ "rounded border font-mono text-muted-foreground",
12
+ "select-none",
13
+ ],
14
+ {
15
+ variants: {
16
+ variant: {
17
+ default: "border-border bg-muted shadow-[0_1px_0_1px_hsl(var(--border))]",
18
+ outline: "border-border bg-background",
19
+ },
20
+ size: {
21
+ sm: "h-5 min-w-5 px-1 text-xs leading-none",
22
+ default: "h-6 min-w-6 px-1.5 text-xs leading-none",
23
+ },
24
+ },
25
+ defaultVariants: {
26
+ variant: "default",
27
+ size: "default",
28
+ },
29
+ }
30
+ )
31
+
32
+ export interface KbdProps
33
+ extends React.ComponentProps<"kbd">,
34
+ VariantProps<typeof kbdVariants> {}
35
+
36
+ function Kbd({ className, variant, size, children, ...props }: KbdProps) {
37
+ return (
38
+ <kbd
39
+ data-slot="kbd"
40
+ className={cn(kbdVariants({ variant, size }), className)}
41
+ {...props}
42
+ >
43
+ {children}
44
+ </kbd>
45
+ )
46
+ }
47
+
48
+ export { Kbd, kbdVariants }
@@ -25,7 +25,12 @@ function Switch({
25
25
  >
26
26
  <CheckIcon
27
27
  strokeWidth={3}
28
- className="pointer-events-none absolute left-2 size-4 text-primary-foreground opacity-0 scale-75 transition-[opacity,transform] duration-[120ms] ease-out group-data-[state=checked]/switch:opacity-100 group-data-[state=checked]/switch:scale-100"
28
+ // Inset + size track the switch size so the check clears the thumb in
29
+ // the checked state. At sm (48px track / 24px thumb) a `left-2 size-4`
30
+ // check overlaps the thumb (lands ~20px); `left-1.5 size-3` leaves a
31
+ // ~2px gap. Default keeps left-2 size-4 — it already clears its 32px
32
+ // thumb.
33
+ className="pointer-events-none absolute text-primary-foreground opacity-0 scale-75 transition-[opacity,transform] duration-[120ms] ease-out group-data-[size=default]/switch:left-2 group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:left-1.5 group-data-[size=sm]/switch:size-3 group-data-[state=checked]/switch:opacity-100 group-data-[state=checked]/switch:scale-100"
29
34
  />
30
35
  <SwitchPrimitive.Thumb
31
36
  data-slot="switch-thumb"
@@ -3,8 +3,10 @@
3
3
  import * as React from "react"
4
4
  import { cva, type VariantProps } from "class-variance-authority"
5
5
  import * as TabsPrimitive from "@radix-ui/react-tabs"
6
+ import { ChevronDown, Check } from "lucide-react"
6
7
 
7
8
  import { cn } from "../../lib/utils"
9
+ import { Popover, PopoverContent, PopoverTrigger } from "./popover"
8
10
 
9
11
  function Tabs({
10
12
  className,
@@ -43,14 +45,70 @@ const tabsListVariants = cva(
43
45
  function TabsList({
44
46
  className,
45
47
  variant = "default",
48
+ scrollable = false,
46
49
  ...props
47
50
  }: React.ComponentProps<typeof TabsPrimitive.List> &
48
- VariantProps<typeof tabsListVariants>) {
51
+ VariantProps<typeof tabsListVariants> & {
52
+ /**
53
+ * Opt-in graceful horizontal overflow: hides the scrollbar, keeps the
54
+ * active trigger scrolled into view, and fades the right edge while there's
55
+ * more to scroll — so a row of tabs too wide for the viewport stops
56
+ * clipping the active label and showing a raw scrollbar. Off by default
57
+ * (shadcn behaviour preserved); turn on for narrow/responsive tab rows.
58
+ */
59
+ scrollable?: boolean
60
+ }) {
61
+ const ref = React.useRef<HTMLDivElement>(null)
62
+
63
+ React.useEffect(() => {
64
+ if (!scrollable) return
65
+ const el = ref.current
66
+ if (!el) return
67
+
68
+ // Toggle the right edge-fade only while the row actually overflows AND
69
+ // isn't scrolled to the end (so the last/active tab is never faded out).
70
+ const update = () => {
71
+ const overflowing =
72
+ el.scrollWidth > el.clientWidth + 1 &&
73
+ el.scrollLeft + el.clientWidth < el.scrollWidth - 1
74
+ el.toggleAttribute("data-overflowing", overflowing)
75
+ }
76
+ // Keep the active trigger visible when the selection changes.
77
+ const scrollActiveIntoView = () => {
78
+ el
79
+ .querySelector<HTMLElement>('[data-slot="tabs-trigger"][data-state="active"]')
80
+ ?.scrollIntoView({ inline: "nearest", block: "nearest", behavior: "smooth" })
81
+ }
82
+
83
+ update()
84
+ scrollActiveIntoView()
85
+ el.addEventListener("scroll", update, { passive: true })
86
+ const ro = new ResizeObserver(update)
87
+ ro.observe(el)
88
+ const mo = new MutationObserver(() => {
89
+ scrollActiveIntoView()
90
+ update()
91
+ })
92
+ mo.observe(el, { attributes: true, attributeFilter: ["data-state"], subtree: true })
93
+
94
+ return () => {
95
+ el.removeEventListener("scroll", update)
96
+ ro.disconnect()
97
+ mo.disconnect()
98
+ }
99
+ }, [scrollable])
100
+
49
101
  return (
50
102
  <TabsPrimitive.List
103
+ ref={ref}
51
104
  data-slot="tabs-list"
52
105
  data-variant={variant}
53
- className={cn(tabsListVariants({ variant }), className)}
106
+ className={cn(
107
+ tabsListVariants({ variant }),
108
+ scrollable &&
109
+ "overflow-x-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden data-[overflowing]:[mask-image:linear-gradient(to_right,#000_calc(100%-2rem),transparent)]",
110
+ className
111
+ )}
54
112
  {...props}
55
113
  />
56
114
  )
@@ -151,11 +209,105 @@ function TabsPanels({
151
209
  )
152
210
  }
153
211
 
212
+ /**
213
+ * Section selector that pairs with `Tabs` for the responsive
214
+ * "dropdown on mobile / underline tabs on desktop" pattern. Controlled — pass
215
+ * the SAME `value` + `onValueChange` you pass to `Tabs`, and toggle visibility
216
+ * with breakpoint utilities:
217
+ *
218
+ * <Tabs value={v} onValueChange={setV}>
219
+ * <TabsSelect items={items} value={v} onValueChange={setV} className="sm:hidden" />
220
+ * <TabsList scrollable className="hidden sm:flex">…</TabsList>
221
+ * …content…
222
+ * </Tabs>
223
+ *
224
+ * A full-width trigger shows the current item + chevron and opens a Popover
225
+ * list. Each option is a toggle button (`aria-pressed`) with a check on the
226
+ * active one, so long labels never clip on narrow screens the way a horizontal
227
+ * tab row does.
228
+ */
229
+ function TabsSelect({
230
+ items,
231
+ value,
232
+ onValueChange,
233
+ placeholder = "Select…",
234
+ className,
235
+ "aria-label": ariaLabel = "Select section",
236
+ ...props
237
+ }: {
238
+ items: { value: string; label: string }[]
239
+ value?: string
240
+ onValueChange?: (value: string) => void
241
+ placeholder?: string
242
+ } & Omit<React.ComponentProps<"button">, "value" | "onChange">) {
243
+ const [open, setOpen] = React.useState(false)
244
+ const current = items.find((i) => i.value === value)
245
+
246
+ return (
247
+ <Popover open={open} onOpenChange={setOpen}>
248
+ <PopoverTrigger asChild>
249
+ <button
250
+ type="button"
251
+ data-slot="tabs-select-trigger"
252
+ aria-label={ariaLabel}
253
+ aria-expanded={open}
254
+ className={cn(
255
+ "flex w-full min-h-11 items-center justify-between gap-2 rounded-md border border-input bg-background px-3 text-sm font-medium text-foreground ring-offset-background transition-colors hover:bg-accent/40 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
256
+ className
257
+ )}
258
+ {...props}
259
+ >
260
+ <span className={cn("truncate", !current && "text-muted-foreground")}>
261
+ {current?.label ?? placeholder}
262
+ </span>
263
+ <ChevronDown
264
+ className="size-4 shrink-0 text-muted-foreground transition-transform duration-[var(--duration-fast,150ms)] ease-[var(--ease-out,ease-out)]"
265
+ strokeWidth={1.75}
266
+ aria-hidden
267
+ style={{ transform: open ? "rotate(180deg)" : undefined }}
268
+ />
269
+ </button>
270
+ </PopoverTrigger>
271
+ <PopoverContent
272
+ align="start"
273
+ sideOffset={6}
274
+ className="w-(--radix-popover-trigger-width) p-1"
275
+ >
276
+ {items.map((item) => {
277
+ const selected = item.value === value
278
+ return (
279
+ <button
280
+ key={item.value}
281
+ type="button"
282
+ data-slot="tabs-select-item"
283
+ aria-pressed={selected}
284
+ onClick={() => {
285
+ onValueChange?.(item.value)
286
+ setOpen(false)
287
+ }}
288
+ className={cn(
289
+ "flex w-full min-h-11 items-center justify-between gap-2 rounded-sm px-2 text-left text-sm font-medium text-popover-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-hidden focus-visible:bg-accent focus-visible:text-accent-foreground",
290
+ selected && "bg-accent text-accent-foreground"
291
+ )}
292
+ >
293
+ <span className="truncate">{item.label}</span>
294
+ {selected && (
295
+ <Check className="size-4 shrink-0" strokeWidth={2} aria-hidden />
296
+ )}
297
+ </button>
298
+ )
299
+ })}
300
+ </PopoverContent>
301
+ </Popover>
302
+ )
303
+ }
304
+
154
305
  export {
155
306
  Tabs,
156
307
  TabsList,
157
308
  TabsTrigger,
158
309
  TabsContent,
159
310
  TabsPanels,
311
+ TabsSelect,
160
312
  tabsListVariants,
161
313
  }
@@ -0,0 +1,129 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+
5
+ import { cn } from "../../lib/utils"
6
+
7
+ // ─── Toolbar ─────────────────────────────────────────────────────────────────
8
+ // role=toolbar container with arrow-key roving focus navigation.
9
+ // Arrow keys navigate between [data-toolbar-item] children; Tab exits.
10
+
11
+ function Toolbar({
12
+ className,
13
+ orientation = "horizontal",
14
+ onKeyDown,
15
+ children,
16
+ ...props
17
+ }: React.ComponentProps<"div"> & {
18
+ orientation?: "horizontal" | "vertical"
19
+ }) {
20
+ const ref = React.useRef<HTMLDivElement>(null)
21
+
22
+ function handleKeyDown(e: React.KeyboardEvent<HTMLDivElement>) {
23
+ const container = ref.current
24
+ if (!container) return
25
+
26
+ const items = Array.from(
27
+ container.querySelectorAll<HTMLElement>("[data-toolbar-item]")
28
+ ).filter((el) => !el.matches("[data-disabled]") && !el.hasAttribute("disabled"))
29
+
30
+ const idx = items.indexOf(document.activeElement as HTMLElement)
31
+ if (idx === -1) {
32
+ onKeyDown?.(e)
33
+ return
34
+ }
35
+
36
+ const prev = orientation === "horizontal" ? "ArrowLeft" : "ArrowUp"
37
+ const next = orientation === "horizontal" ? "ArrowRight" : "ArrowDown"
38
+
39
+ if (
40
+ e.key === prev ||
41
+ e.key === next ||
42
+ e.key === "Home" ||
43
+ e.key === "End"
44
+ ) {
45
+ e.preventDefault()
46
+ let target: HTMLElement | undefined
47
+ if (e.key === prev) target = items[(idx - 1 + items.length) % items.length]
48
+ else if (e.key === next) target = items[(idx + 1) % items.length]
49
+ else if (e.key === "Home") target = items[0]
50
+ else target = items[items.length - 1]
51
+ target?.focus()
52
+ }
53
+
54
+ onKeyDown?.(e)
55
+ }
56
+
57
+ return (
58
+ <div
59
+ ref={ref}
60
+ data-slot="toolbar"
61
+ role="toolbar"
62
+ aria-orientation={orientation}
63
+ className={cn(
64
+ "flex w-fit items-center gap-0.5 rounded-md border bg-background p-1",
65
+ orientation === "vertical" && "flex-col items-stretch",
66
+ className
67
+ )}
68
+ onKeyDown={handleKeyDown}
69
+ {...props}
70
+ >
71
+ {children}
72
+ </div>
73
+ )
74
+ }
75
+
76
+ // ─── ToolbarButton ────────────────────────────────────────────────────────────
77
+ // A focusable action button within a Toolbar. Carries data-toolbar-item so the
78
+ // Toolbar's arrow-key handler can include it in the navigation ring.
79
+
80
+ function ToolbarButton({
81
+ className,
82
+ children,
83
+ ...props
84
+ }: React.ComponentProps<"button">) {
85
+ return (
86
+ <button
87
+ data-slot="toolbar-button"
88
+ data-toolbar-item=""
89
+ type="button"
90
+ className={cn(
91
+ "inline-flex min-h-11 min-w-11 items-center justify-center rounded px-2",
92
+ "text-sm font-medium text-foreground",
93
+ "hover:bg-accent hover:text-accent-foreground",
94
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",
95
+ "disabled:pointer-events-none disabled:opacity-50",
96
+ "aria-pressed:bg-accent aria-pressed:text-accent-foreground",
97
+ "transition-colors",
98
+ className
99
+ )}
100
+ style={{
101
+ transitionDuration: "var(--duration-fast)",
102
+ transitionTimingFunction: "var(--ease-out)",
103
+ }}
104
+ {...props}
105
+ >
106
+ {children}
107
+ </button>
108
+ )
109
+ }
110
+
111
+ // ─── ToolbarSeparator ─────────────────────────────────────────────────────────
112
+ // A visual divider between toolbar groups. Not part of the keyboard nav ring.
113
+
114
+ function ToolbarSeparator({
115
+ className,
116
+ ...props
117
+ }: React.ComponentProps<"div">) {
118
+ return (
119
+ <div
120
+ data-slot="toolbar-separator"
121
+ role="separator"
122
+ aria-orientation="vertical"
123
+ className={cn("mx-0.5 h-6 w-px shrink-0 bg-border", className)}
124
+ {...props}
125
+ />
126
+ )
127
+ }
128
+
129
+ export { Toolbar, ToolbarButton, ToolbarSeparator }
@@ -0,0 +1,14 @@
1
+ [
2
+ "./*.md",
3
+ "./layer-*/**/*.md",
4
+ "./layer-*/**/*.json",
5
+ "./docs/**/*.md",
6
+ "./prompts/**/*.md",
7
+ "./scripts/prompts/**/*.md",
8
+ "./.claude/skills/**/SKILL.md",
9
+ "./ledgers/**/*.md",
10
+ "./aggregator/**/*.md",
11
+ "./automation/**/*.md",
12
+ "./roi/**/*.md",
13
+ "./packages/core/src/tokens.json"
14
+ ]