@behavioral-agentic-design-system/core 0.40.0 → 0.45.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/README.md +2 -0
- package/package.json +41 -9
- package/scripts/a11y-lint.cjs +66 -3
- package/scripts/check-spec.mjs +73 -0
- package/scripts/deal-directions.mjs +186 -0
- package/scripts/health-report.mjs +23 -3
- package/scripts/lib/counted-lint.mjs +100 -0
- package/scripts/lib/marketing-library.mjs +129 -0
- package/scripts/lib/on-system.mjs +249 -0
- package/scripts/lib/random.mjs +22 -0
- package/scripts/lib/spec-parse.d.mts +25 -0
- package/scripts/lib/spec-parse.mjs +188 -0
- package/scripts/lib/tells.mjs +128 -0
- package/scripts/lint-css-vars.mjs +175 -0
- package/scripts/lint-html-nesting.mjs +116 -0
- package/scripts/lint-live-ctas.mjs +138 -0
- package/scripts/lint-slop.mjs +25 -1
- package/scripts/on-system-score.mjs +95 -0
- package/scripts/slop-rules.mjs +1 -1
- package/scripts/source-images.mjs +180 -0
- package/scripts/ux-tells.mjs +78 -0
- package/scripts/wcag-audit.cjs +72 -5
- package/src/api/brand-colors.ts +3 -0
- package/src/api/brand-fonts.ts +3 -0
- package/src/api/brand-mark.ts +6 -1
- package/src/api/dev-write-guard.ts +53 -0
- package/src/api/layers/file.ts +7 -4
- package/src/api/onboarding-extract.ts +85 -30
- package/src/api/onboarding.ts +3 -0
- package/src/api/save-tokens.ts +3 -0
- package/src/app/layout.tsx +6 -0
- package/src/app/opengraph-image.tsx +5 -0
- package/src/app/preview/canvas/page.tsx +12 -0
- package/src/app/preview/components/page.tsx +2003 -2
- package/src/app/preview/studio/blank-screen.tsx +143 -0
- package/src/app/preview/studio/page.tsx +7 -0
- package/src/app/shell.tsx +168 -49
- package/src/components/Foundations/Motion.stories.tsx +1 -0
- package/src/components/canvas/canvas.tsx +458 -0
- package/src/components/canvas/layout.ts +72 -0
- package/src/components/canvas/parse-canvas.ts +32 -0
- package/src/components/canvas/sample.ts +90 -0
- package/src/components/canvas/spec-frame.tsx +43 -0
- package/src/components/canvas/types.ts +33 -0
- package/src/components/customize/design-controls.tsx +16 -1
- package/src/components/docs-tab.tsx +7 -7
- package/src/components/home-recent.tsx +73 -0
- package/src/components/home-tab.tsx +13 -13
- package/src/components/layers-tab.tsx +2 -2
- package/src/components/markdown-preview.tsx +60 -12
- package/src/components/studio/control-panel.tsx +299 -0
- package/src/components/studio/control-row.tsx +77 -0
- package/src/components/studio/preview-frame.tsx +165 -0
- package/src/components/studio/preview-pane.tsx +247 -0
- package/src/components/studio/studio.tsx +158 -0
- package/src/components/studio/types.ts +218 -0
- package/src/components/studio/use-studio-tweaks.ts +128 -0
- package/src/components/studio/use-studio-view-state.ts +72 -0
- package/src/components/ui/anchor.tsx +37 -3
- package/src/components/ui/attachment.tsx +211 -0
- package/src/components/ui/autocomplete.tsx +1 -1
- package/src/components/ui/chart.tsx +3 -0
- package/src/components/ui/code.tsx +1 -1
- package/src/components/ui/color-picker.tsx +21 -5
- package/src/components/ui/data-table.tsx +64 -3
- package/src/components/ui/date-field.tsx +1 -1
- package/src/components/ui/editable.tsx +1 -0
- package/src/components/ui/faceted-filter.tsx +187 -0
- package/src/components/ui/gauge-chart.tsx +252 -0
- package/src/components/ui/heatmap.tsx +256 -0
- package/src/components/ui/index.ts +9 -0
- package/src/components/ui/infinite-scroll.tsx +103 -0
- package/src/components/ui/inline-edit.tsx +175 -0
- package/src/components/ui/json-input.tsx +351 -0
- package/src/components/ui/month-picker.tsx +1 -1
- package/src/components/ui/navigation-progress.tsx +281 -0
- package/src/components/ui/number-input.tsx +27 -7
- package/src/components/ui/otp-input.tsx +208 -0
- package/src/components/ui/password-input.tsx +2 -1
- package/src/components/ui/password-strength-input.tsx +288 -0
- package/src/components/ui/phone-input.tsx +274 -0
- package/src/components/ui/pill.tsx +140 -0
- package/src/components/ui/popover.tsx +27 -4
- package/src/components/ui/scroll-progress.tsx +100 -0
- package/src/components/ui/search-input.tsx +1 -1
- package/src/components/ui/snackbar.tsx +393 -0
- package/src/components/ui/sortable-list.tsx +342 -0
- package/src/components/ui/squircle.tsx +1 -1
- package/src/components/ui/table.tsx +1 -1
- package/src/components/ui/tags-input.tsx +1 -1
- package/src/components/ui/timer.tsx +1 -0
- package/src/components/ui/tour.tsx +1 -3
- package/src/components/ui/transfer-list.tsx +13 -26
- package/src/components/ui/week-picker.tsx +1 -1
- package/src/components/ui/year-picker.tsx +1 -1
- package/src/data/component-added.json +958 -0
- package/src/data/docs-index.ts +36 -0
- package/src/hooks/use-global-mono-font.ts +1 -0
- package/src/hooks/use-global-primary-color.ts +1 -0
- package/src/hooks/use-global-sans-font.ts +1 -0
- package/src/hooks/use-global-serif-font.ts +1 -0
- package/src/hooks/use-global-type-scale.ts +17 -2
- package/src/hooks/use-mobile.ts +2 -0
- package/src/hooks/use-sync-type-scale.ts +7 -11
- package/src/lib/clamp.ts +2 -0
- package/src/lib/spec-parse.ts +4 -0
- package/src/lib/svg-sanitize.ts +19 -9
- package/src/stories/Anchor.stories.tsx +54 -0
- package/src/stories/Attachment.stories.tsx +189 -0
- package/src/stories/Autocomplete.stories.tsx +2 -0
- package/src/stories/Canvas.stories.tsx +45 -0
- package/src/stories/Chart.stories.tsx +4 -0
- package/src/stories/Code.stories.tsx +1 -0
- package/src/stories/ColorPicker.stories.tsx +41 -0
- package/src/stories/DataTable.stories.tsx +30 -0
- package/src/stories/DateField.stories.tsx +21 -0
- package/src/stories/Editable.stories.tsx +2 -0
- package/src/stories/FacetedFilter.stories.tsx +197 -0
- package/src/stories/GaugeChart.stories.tsx +169 -0
- package/src/stories/Heatmap.stories.tsx +172 -0
- package/src/stories/InfiniteScroll.stories.tsx +225 -0
- package/src/stories/InlineEdit.stories.tsx +106 -0
- package/src/stories/JsonInput.stories.tsx +212 -0
- package/src/stories/MarkdownPreview.stories.tsx +53 -0
- package/src/stories/MonthPicker.stories.tsx +21 -0
- package/src/stories/NavigationProgress.stories.tsx +159 -0
- package/src/stories/NumberInput.stories.tsx +26 -0
- package/src/stories/OtpInput.stories.tsx +110 -0
- package/src/stories/PasswordInput.stories.tsx +4 -0
- package/src/stories/PasswordStrengthInput.stories.tsx +211 -0
- package/src/stories/PhoneInput.stories.tsx +127 -0
- package/src/stories/Pill.stories.tsx +201 -0
- package/src/stories/Popover.stories.tsx +29 -1
- package/src/stories/Portal.stories.tsx +3 -1
- package/src/stories/ScrollProgress.stories.tsx +117 -0
- package/src/stories/SearchInput.stories.tsx +2 -0
- package/src/stories/Snackbar.stories.tsx +315 -0
- package/src/stories/SortableList.stories.tsx +263 -0
- package/src/stories/Squircle.stories.tsx +1 -0
- package/src/stories/Table.stories.tsx +1 -0
- package/src/stories/TagsInput.stories.tsx +2 -0
- package/src/stories/Timer.stories.tsx +26 -0
- package/src/stories/Tour.stories.tsx +1 -0
- package/src/stories/TransferList.stories.tsx +4 -0
- package/src/stories/WeekPicker.stories.tsx +21 -0
- package/src/stories/YearPicker.stories.tsx +21 -0
- package/src/stories/story-groups.json +33 -16
- package/src/tokens.json +82 -54
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** A canvas file: sections of frames. Lives at prototypes/<slug>/canvas.json. */
|
|
2
|
+
export interface CanvasDoc {
|
|
3
|
+
sections: CanvasSection[];
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface CanvasSection {
|
|
7
|
+
title: string;
|
|
8
|
+
frames: CanvasFrame[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** A live view: an iframe of a real screen. */
|
|
12
|
+
export interface LiveFrame {
|
|
13
|
+
kind: "live";
|
|
14
|
+
/** View name. Resolved to a URL by the host through `resolveView`. */
|
|
15
|
+
view: string;
|
|
16
|
+
/** CSS pixels. Default 1280. */
|
|
17
|
+
width?: number;
|
|
18
|
+
/** CSS pixels. Default 800. */
|
|
19
|
+
height?: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** A document: a markdown file such as the prototype's spec. */
|
|
23
|
+
export interface DocFrame {
|
|
24
|
+
kind: "doc";
|
|
25
|
+
/** Key into the host's `docs` map, usually "spec.md". */
|
|
26
|
+
src: string;
|
|
27
|
+
/** CSS pixels. Default 640. */
|
|
28
|
+
width?: number;
|
|
29
|
+
/** CSS pixels. Default 900. */
|
|
30
|
+
height?: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type CanvasFrame = LiveFrame | DocFrame;
|
|
@@ -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
|
|
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>
|
|
@@ -213,10 +213,10 @@ export function DocsTab() {
|
|
|
213
213
|
{/* Sidebar — collapsible groups, doc rows, search affordance. */}
|
|
214
214
|
<aside
|
|
215
215
|
data-slot="docs-sidebar"
|
|
216
|
-
className="hidden h-full min-h-0 w-72 shrink-0 flex-col
|
|
216
|
+
className="hidden h-full min-h-0 w-72 shrink-0 flex-col bg-muted/40 md:flex"
|
|
217
217
|
aria-label="Documentation index"
|
|
218
218
|
>
|
|
219
|
-
<div className="flex shrink-0 items-center justify-between gap-2
|
|
219
|
+
<div className="flex shrink-0 items-center justify-between gap-2 px-4 py-3">
|
|
220
220
|
<div className="flex items-center gap-2">
|
|
221
221
|
<BookOpen className="size-4 text-primary" strokeWidth={1.5} />
|
|
222
222
|
<span className="text-sm font-semibold">Docs</span>
|
|
@@ -235,7 +235,7 @@ export function DocsTab() {
|
|
|
235
235
|
<span className="font-mono">⌘K</span>
|
|
236
236
|
</Button>
|
|
237
237
|
</div>
|
|
238
|
-
<div className="shrink-0
|
|
238
|
+
<div className="shrink-0 px-4 py-3">
|
|
239
239
|
<Input
|
|
240
240
|
type="search"
|
|
241
241
|
value={paletteQuery}
|
|
@@ -281,7 +281,7 @@ export function DocsTab() {
|
|
|
281
281
|
>
|
|
282
282
|
<div className="min-w-0">
|
|
283
283
|
{/* Mobile-only top bar with the Browse affordance. */}
|
|
284
|
-
<div className="flex shrink-0 items-center gap-2
|
|
284
|
+
<div className="flex shrink-0 items-center gap-2 bg-card px-4 py-3 md:hidden">
|
|
285
285
|
<BookOpen className="size-4 text-primary" strokeWidth={1.5} />
|
|
286
286
|
<span className="text-sm font-semibold">Docs</span>
|
|
287
287
|
<Badge variant="secondary" className="ml-1">
|
|
@@ -322,7 +322,7 @@ export function DocsTab() {
|
|
|
322
322
|
{/* Command palette */}
|
|
323
323
|
<Dialog open={paletteOpen} onOpenChange={setPaletteOpen}>
|
|
324
324
|
<DialogContent className="max-w-2xl gap-0 p-0">
|
|
325
|
-
<div className="
|
|
325
|
+
<div className="px-4 py-3">
|
|
326
326
|
<div className="flex items-center gap-2">
|
|
327
327
|
<Search className="size-4 text-muted-foreground" strokeWidth={1.5} />
|
|
328
328
|
<Input
|
|
@@ -389,7 +389,7 @@ export function DocsTab() {
|
|
|
389
389
|
</ul>
|
|
390
390
|
)}
|
|
391
391
|
</div>
|
|
392
|
-
<div className="flex items-center justify-between
|
|
392
|
+
<div className="flex items-center justify-between bg-muted/30 px-4 py-2 text-xs text-muted-foreground">
|
|
393
393
|
<span className="flex items-center gap-3">
|
|
394
394
|
<span>
|
|
395
395
|
<kbd className="rounded border bg-background px-1.5 py-0.5 font-mono">↑↓</kbd>{" "}
|
|
@@ -498,7 +498,7 @@ function ReadingHeader({
|
|
|
498
498
|
const githubUrl =
|
|
499
499
|
repoBase && activePath ? `${repoBase.replace(/\/$/, "")}/blob/main/${activePath}` : null;
|
|
500
500
|
return (
|
|
501
|
-
<header className="flex shrink-0 items-start justify-between gap-4
|
|
501
|
+
<header className="flex shrink-0 items-start justify-between gap-4 bg-card px-6 py-4 lg:px-10">
|
|
502
502
|
<div className="min-w-0 flex-1">
|
|
503
503
|
<h1 className="truncate text-xl font-semibold tracking-tight" title={activeEntry?.title ?? activePath}>
|
|
504
504
|
{activeEntry?.title ?? activePath}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import added from "../data/component-added.json";
|
|
4
|
+
|
|
5
|
+
export type RecentItem = { name: string; date: string; kind: "primitive" | "composition" };
|
|
6
|
+
|
|
7
|
+
/** How many of the newest additions the strip shows. */
|
|
8
|
+
const SHOWN = 8;
|
|
9
|
+
|
|
10
|
+
const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
11
|
+
|
|
12
|
+
/** "2026-10-12" -> "Oct 12". Done by hand, not Intl, so the server and the browser print the same text. */
|
|
13
|
+
function shortDate(iso: string): string {
|
|
14
|
+
const [, month, day] = iso.split("-").map(Number);
|
|
15
|
+
return `${MONTHS[(month ?? 1) - 1]} ${day}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The newest additions, newest first, ties broken by name so the order never shuffles between builds. */
|
|
19
|
+
function newest(): RecentItem[] {
|
|
20
|
+
return Object.entries(added as Record<string, { date: string; kind: RecentItem["kind"] }>)
|
|
21
|
+
.map(([name, v]) => ({ name, date: v.date, kind: v.kind }))
|
|
22
|
+
.sort((a, b) => (a.date === b.date ? a.name.localeCompare(b.name) : a.date < b.date ? 1 : -1))
|
|
23
|
+
.slice(0, SHOWN);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const ITEMS = newest();
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* "Recently added": the newest components in the system, so new work is visible without hunting for it.
|
|
30
|
+
*
|
|
31
|
+
* It reads packages/core/src/data/component-added.json, which `pnpm check:showcase-placement` requires an entry in
|
|
32
|
+
* for every registry component. A primitive opens the Components tab and a composition opens Studio's Cards, which
|
|
33
|
+
* is where each one is shown. Upstream only: a client fork has none of these compositions to open.
|
|
34
|
+
*/
|
|
35
|
+
export function RecentlyAdded({ onOpen }: { onOpen: (item: RecentItem) => void }) {
|
|
36
|
+
if (ITEMS.length === 0) return null;
|
|
37
|
+
return (
|
|
38
|
+
<section className="flex flex-col gap-5" aria-labelledby="home-recent-heading">
|
|
39
|
+
<div>
|
|
40
|
+
<h2 id="home-recent-heading" className="text-2xl font-semibold tracking-tight">
|
|
41
|
+
Recently added
|
|
42
|
+
</h2>
|
|
43
|
+
<p className="mt-1 text-sm text-muted-foreground">
|
|
44
|
+
The newest {ITEMS.length} components. Each opens where it is shown.
|
|
45
|
+
</p>
|
|
46
|
+
</div>
|
|
47
|
+
<ul className="grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4">
|
|
48
|
+
{ITEMS.map((item) => (
|
|
49
|
+
<li key={item.name} className="min-w-0">
|
|
50
|
+
<button
|
|
51
|
+
type="button"
|
|
52
|
+
onClick={() => onOpen(item)}
|
|
53
|
+
aria-label={`${item.name}, a ${item.kind} added ${shortDate(item.date)}. Opens ${
|
|
54
|
+
item.kind === "composition" ? "Studio, Cards" : "the Components tab"
|
|
55
|
+
}.`}
|
|
56
|
+
className="flex min-h-11 w-full min-w-0 flex-col gap-0.5 overflow-hidden rounded-lg bg-muted/50 px-4 py-3 text-left transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
|
|
57
|
+
style={{
|
|
58
|
+
transitionDuration: "var(--duration-fast)",
|
|
59
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
60
|
+
}}
|
|
61
|
+
title={item.name}
|
|
62
|
+
>
|
|
63
|
+
<span className="truncate text-sm font-medium text-foreground">{item.name}</span>
|
|
64
|
+
<span className="text-xs text-muted-foreground">
|
|
65
|
+
{item.kind === "composition" ? "Composition" : "Primitive"} · {shortDate(item.date)}
|
|
66
|
+
</span>
|
|
67
|
+
</button>
|
|
68
|
+
</li>
|
|
69
|
+
))}
|
|
70
|
+
</ul>
|
|
71
|
+
</section>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -28,8 +28,8 @@ import {
|
|
|
28
28
|
} from "@behavioral-agentic-design-system/core/components/ui/card";
|
|
29
29
|
import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge";
|
|
30
30
|
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
|
|
31
|
-
import { Separator } from "@behavioral-agentic-design-system/core/components/ui/separator";
|
|
32
31
|
import { BadsUpdateBanner } from "@behavioral-agentic-design-system/core/components/bads-update-banner";
|
|
32
|
+
import { RecentlyAdded, type RecentItem } from "./home-recent";
|
|
33
33
|
import registry from "@/layer-5-component-registry/component-registry.json";
|
|
34
34
|
import tokens from "@/packages/core/src/tokens.json";
|
|
35
35
|
import {
|
|
@@ -41,6 +41,8 @@ import { IS_CLIENT_FORK } from "@behavioral-agentic-design-system/core/lib/fork"
|
|
|
41
41
|
type HomeTabProps = {
|
|
42
42
|
onBrowseDocs?: () => void;
|
|
43
43
|
onBrowseComponents?: () => void;
|
|
44
|
+
/** Opens a recently added component where it is shown. When omitted, the strip is not rendered. */
|
|
45
|
+
onOpenRecent?: (item: RecentItem) => void;
|
|
44
46
|
};
|
|
45
47
|
|
|
46
48
|
const componentCount = Object.keys(registry as Record<string, unknown>).length;
|
|
@@ -226,7 +228,7 @@ function PromptCard({
|
|
|
226
228
|
};
|
|
227
229
|
|
|
228
230
|
return (
|
|
229
|
-
<Card className="flex flex-col gap-0">
|
|
231
|
+
<Card className="flex flex-col gap-0 border-transparent bg-muted/50 shadow-none">
|
|
230
232
|
<CardHeader className="gap-1.5 pb-2">
|
|
231
233
|
<CardTitle className="flex items-center gap-2 text-base">
|
|
232
234
|
<Icon className="size-4 text-muted-foreground" strokeWidth={1.5} />
|
|
@@ -235,7 +237,7 @@ function PromptCard({
|
|
|
235
237
|
<CardDescription>{blurb}</CardDescription>
|
|
236
238
|
</CardHeader>
|
|
237
239
|
<CardContent className="flex flex-1 flex-col gap-3">
|
|
238
|
-
<p className="line-clamp-3 rounded-md
|
|
240
|
+
<p className="line-clamp-3 rounded-md bg-background p-2.5 font-mono text-xs leading-relaxed text-muted-foreground">
|
|
239
241
|
{prompt}
|
|
240
242
|
</p>
|
|
241
243
|
{/* allow-small-cta: copy-to-clipboard changes no flow — no route, no
|
|
@@ -275,7 +277,7 @@ function MetricPill({
|
|
|
275
277
|
value: string | number;
|
|
276
278
|
}) {
|
|
277
279
|
return (
|
|
278
|
-
<div className="flex flex-col gap-0.5 rounded-md
|
|
280
|
+
<div className="flex flex-col gap-0.5 rounded-md bg-muted/50 px-4 py-3">
|
|
279
281
|
<span className="font-mono text-2xl font-semibold tracking-tight tabular-nums">
|
|
280
282
|
{value}
|
|
281
283
|
</span>
|
|
@@ -286,7 +288,7 @@ function MetricPill({
|
|
|
286
288
|
);
|
|
287
289
|
}
|
|
288
290
|
|
|
289
|
-
export function HomeTab({ onBrowseDocs, onBrowseComponents }: HomeTabProps) {
|
|
291
|
+
export function HomeTab({ onBrowseDocs, onBrowseComponents, onOpenRecent }: HomeTabProps) {
|
|
290
292
|
const openDocAt = (path: string) => {
|
|
291
293
|
// Persist the requested doc so DocsTab restores it on first mount.
|
|
292
294
|
try {
|
|
@@ -331,7 +333,7 @@ export function HomeTab({ onBrowseDocs, onBrowseComponents }: HomeTabProps) {
|
|
|
331
333
|
</Button>
|
|
332
334
|
<Button
|
|
333
335
|
size="lg"
|
|
334
|
-
variant="
|
|
336
|
+
variant="secondary"
|
|
335
337
|
className="gap-2"
|
|
336
338
|
onClick={onBrowseComponents}
|
|
337
339
|
>
|
|
@@ -341,7 +343,8 @@ export function HomeTab({ onBrowseDocs, onBrowseComponents }: HomeTabProps) {
|
|
|
341
343
|
</div>
|
|
342
344
|
</section>
|
|
343
345
|
|
|
344
|
-
|
|
346
|
+
{/* Upstream only: a client fork has none of these compositions to open. */}
|
|
347
|
+
{!IS_CLIENT_FORK && onOpenRecent ? <RecentlyAdded onOpen={onOpenRecent} /> : null}
|
|
345
348
|
|
|
346
349
|
<section className="flex flex-col gap-4">
|
|
347
350
|
<h2 className="text-sm font-semibold uppercase tracking-wide text-foreground">
|
|
@@ -355,7 +358,6 @@ export function HomeTab({ onBrowseDocs, onBrowseComponents }: HomeTabProps) {
|
|
|
355
358
|
</div>
|
|
356
359
|
</section>
|
|
357
360
|
|
|
358
|
-
<Separator />
|
|
359
361
|
|
|
360
362
|
<section className="flex flex-col gap-5">
|
|
361
363
|
<div className="flex items-end justify-between gap-4">
|
|
@@ -374,7 +376,7 @@ export function HomeTab({ onBrowseDocs, onBrowseComponents }: HomeTabProps) {
|
|
|
374
376
|
key={card.id}
|
|
375
377
|
type="button"
|
|
376
378
|
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
|
|
377
|
-
className="flex flex-col gap-4 rounded-lg border bg-
|
|
379
|
+
className="flex flex-col gap-4 rounded-lg border border-transparent bg-muted/50 text-card-foreground group cursor-pointer text-left w-full transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
|
|
378
380
|
style={{
|
|
379
381
|
transitionDuration: "var(--duration-fast)",
|
|
380
382
|
transitionTimingFunction: "var(--ease-out)",
|
|
@@ -411,7 +413,6 @@ export function HomeTab({ onBrowseDocs, onBrowseComponents }: HomeTabProps) {
|
|
|
411
413
|
</div>
|
|
412
414
|
</section>
|
|
413
415
|
|
|
414
|
-
<Separator />
|
|
415
416
|
|
|
416
417
|
{/* COPY-PASTE PROMPTS FOR CLAUDE CODE */}
|
|
417
418
|
<section className="flex flex-col gap-5">
|
|
@@ -451,7 +452,6 @@ export function HomeTab({ onBrowseDocs, onBrowseComponents }: HomeTabProps) {
|
|
|
451
452
|
)}
|
|
452
453
|
</section>
|
|
453
454
|
|
|
454
|
-
<Separator />
|
|
455
455
|
|
|
456
456
|
<section className="flex flex-col gap-4">
|
|
457
457
|
<h2 className="text-sm font-semibold uppercase tracking-wide text-muted-foreground">
|
|
@@ -461,8 +461,8 @@ export function HomeTab({ onBrowseDocs, onBrowseComponents }: HomeTabProps) {
|
|
|
461
461
|
{DOC_GROUPS.map((group) => (
|
|
462
462
|
<Badge
|
|
463
463
|
key={group.id}
|
|
464
|
-
variant="
|
|
465
|
-
className="cursor-pointer transition-colors hover:bg-
|
|
464
|
+
variant="secondary"
|
|
465
|
+
className="cursor-pointer transition-colors hover:bg-muted"
|
|
466
466
|
style={{
|
|
467
467
|
transitionDuration: "var(--duration-fast)",
|
|
468
468
|
transitionTimingFunction: "var(--ease-out)",
|
|
@@ -270,7 +270,7 @@ export function LayersTab() {
|
|
|
270
270
|
editor (which gets a Back control). At md+ both panes show side by
|
|
271
271
|
side as a classic two-column editor. */}
|
|
272
272
|
<aside
|
|
273
|
-
className={`w-full md:w-72 shrink-0
|
|
273
|
+
className={`w-full md:w-72 shrink-0 bg-muted/40 ${
|
|
274
274
|
activePath ? "hidden md:block" : "block"
|
|
275
275
|
}`}
|
|
276
276
|
>
|
|
@@ -380,7 +380,7 @@ export function LayersTab() {
|
|
|
380
380
|
</div>
|
|
381
381
|
) : (
|
|
382
382
|
<>
|
|
383
|
-
<header className="
|
|
383
|
+
<header className="px-4 sm:px-6 py-3 flex items-center gap-3 sm:gap-4 shrink-0">
|
|
384
384
|
<button
|
|
385
385
|
type="button"
|
|
386
386
|
onClick={() => setActivePath(null)}
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { useMemo } from "react";
|
|
4
|
-
import ReactMarkdown, { type Components } from "react-markdown";
|
|
3
|
+
import { useMemo, type ReactNode } from "react";
|
|
4
|
+
import ReactMarkdown, { defaultUrlTransform, type Components } from "react-markdown";
|
|
5
5
|
import remarkGfm from "remark-gfm";
|
|
6
|
+
import { slugify } from "../lib/spec-parse";
|
|
7
|
+
|
|
8
|
+
// Plain text of a rendered heading, so it can become an anchor id. Lets the canvas
|
|
9
|
+
// scroll a Spec frame to a section by heading text.
|
|
10
|
+
function textOf(node: ReactNode): string {
|
|
11
|
+
if (node == null || typeof node === "boolean") return "";
|
|
12
|
+
if (typeof node === "string" || typeof node === "number") return String(node);
|
|
13
|
+
if (Array.isArray(node)) return node.map(textOf).join("");
|
|
14
|
+
if (typeof node === "object" && "props" in node) return textOf((node as { props: { children?: ReactNode } }).props.children);
|
|
15
|
+
return "";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// A `frame:<view>` link points at a frame on the canvas, not at a page. The default
|
|
19
|
+
// URL transform drops unknown schemes, so let this one through.
|
|
20
|
+
const FRAME_HREF = /^frame:/i;
|
|
21
|
+
function urlTransform(url: string): string {
|
|
22
|
+
return FRAME_HREF.test(url) ? url : defaultUrlTransform(url);
|
|
23
|
+
}
|
|
6
24
|
|
|
7
25
|
// A link is "external" (open in a new tab) when it has a scheme or is a pure
|
|
8
26
|
// in-page anchor. Everything else is a repo-relative path — e.g. a doc-to-doc
|
|
@@ -19,27 +37,28 @@ const EXTERNAL_HREF = /^(https?:|mailto:|tel:|#|\/\/)/i;
|
|
|
19
37
|
// border-border, text-primary, font-mono. No hardcoded values.
|
|
20
38
|
export const MARKDOWN_COMPONENTS: Components = {
|
|
21
39
|
h1: ({ children, ...props }: any) => (
|
|
22
|
-
<h1 className="mt-6 mb-3 text-2xl font-semibold tracking-tight first:mt-0" {...props}>
|
|
40
|
+
<h1 id={slugify(textOf(children))} className="mt-6 mb-3 text-2xl font-semibold tracking-tight first:mt-0" {...props}>
|
|
23
41
|
{children}
|
|
24
42
|
</h1>
|
|
25
43
|
),
|
|
26
44
|
h2: ({ children, ...props }: any) => (
|
|
27
|
-
<h2 className="mt-6 mb-3 text-xl font-semibold tracking-tight first:mt-0" {...props}>
|
|
45
|
+
<h2 id={slugify(textOf(children))} className="mt-6 mb-3 text-xl font-semibold tracking-tight first:mt-0" {...props}>
|
|
28
46
|
{children}
|
|
29
47
|
</h2>
|
|
30
48
|
),
|
|
31
49
|
h3: ({ children, ...props }: any) => (
|
|
32
|
-
<h3 className="mt-5 mb-2 text-lg font-semibold tracking-tight" {...props}>
|
|
50
|
+
<h3 id={slugify(textOf(children))} className="mt-5 mb-2 text-lg font-semibold tracking-tight" {...props}>
|
|
33
51
|
{children}
|
|
34
52
|
</h3>
|
|
35
53
|
),
|
|
36
54
|
h4: ({ children, ...props }: any) => (
|
|
37
|
-
<h4 className="mt-4 mb-2 text-base font-semibold" {...props}>
|
|
55
|
+
<h4 id={slugify(textOf(children))} className="mt-4 mb-2 text-base font-semibold" {...props}>
|
|
38
56
|
{children}
|
|
39
57
|
</h4>
|
|
40
58
|
),
|
|
41
59
|
h5: ({ children, ...props }: any) => (
|
|
42
60
|
<h5
|
|
61
|
+
id={slugify(textOf(children))}
|
|
43
62
|
className="mt-3 mb-1 text-sm font-semibold uppercase tracking-wide text-muted-foreground"
|
|
44
63
|
{...props}
|
|
45
64
|
>
|
|
@@ -48,6 +67,7 @@ export const MARKDOWN_COMPONENTS: Components = {
|
|
|
48
67
|
),
|
|
49
68
|
h6: ({ children, ...props }: any) => (
|
|
50
69
|
<h6
|
|
70
|
+
id={slugify(textOf(children))}
|
|
51
71
|
className="mt-3 mb-1 text-sm font-semibold uppercase tracking-wide text-muted-foreground"
|
|
52
72
|
{...props}
|
|
53
73
|
>
|
|
@@ -121,7 +141,15 @@ export const MARKDOWN_COMPONENTS: Components = {
|
|
|
121
141
|
),
|
|
122
142
|
hr: () => <hr className="my-6 border-border" />,
|
|
123
143
|
table: ({ children, ...props }: any) => (
|
|
124
|
-
|
|
144
|
+
// The wrapper scrolls sideways when a wide table overflows its box. A scroll region a
|
|
145
|
+
// keyboard user cannot focus fails axe as scrollable-region-focusable, so it takes focus.
|
|
146
|
+
// A group, not a region: a doc with two tables would otherwise repeat one landmark name.
|
|
147
|
+
<div
|
|
148
|
+
className="mb-3 overflow-x-auto focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring"
|
|
149
|
+
role="group"
|
|
150
|
+
aria-label="Scrollable table"
|
|
151
|
+
tabIndex={0}
|
|
152
|
+
>
|
|
125
153
|
<table className="w-full border-collapse text-xs" {...props}>
|
|
126
154
|
{children}
|
|
127
155
|
</table>
|
|
@@ -166,6 +194,7 @@ export function MarkdownPreview({
|
|
|
166
194
|
source,
|
|
167
195
|
maxWidth = "max-w-3xl",
|
|
168
196
|
onDocLink,
|
|
197
|
+
onFrameLink,
|
|
169
198
|
}: {
|
|
170
199
|
source: string;
|
|
171
200
|
maxWidth?: string;
|
|
@@ -174,13 +203,32 @@ export function MarkdownPreview({
|
|
|
174
203
|
// navigating the browser — so they resolve to an in-app doc rather than the
|
|
175
204
|
// private source repo or a 404. External links still open in a new tab.
|
|
176
205
|
onDocLink?: (href: string) => void;
|
|
206
|
+
// When provided, `frame:<view>` links call this with the view name instead of
|
|
207
|
+
// navigating. The canvas uses it to pan to the frame an inventory row names.
|
|
208
|
+
onFrameLink?: (view: string) => void;
|
|
177
209
|
}) {
|
|
178
210
|
const components = useMemo<Components>(() => {
|
|
179
|
-
if (!onDocLink) return MARKDOWN_COMPONENTS;
|
|
211
|
+
if (!onDocLink && !onFrameLink) return MARKDOWN_COMPONENTS;
|
|
180
212
|
return {
|
|
181
213
|
...MARKDOWN_COMPONENTS,
|
|
182
214
|
a: ({ children, href, ...props }: any) => {
|
|
183
|
-
|
|
215
|
+
if (onFrameLink && typeof href === "string" && FRAME_HREF.test(href)) {
|
|
216
|
+
const view = href.replace(FRAME_HREF, "");
|
|
217
|
+
return (
|
|
218
|
+
<a
|
|
219
|
+
href={href}
|
|
220
|
+
onClick={(e) => {
|
|
221
|
+
e.preventDefault();
|
|
222
|
+
onFrameLink(view);
|
|
223
|
+
}}
|
|
224
|
+
className="cursor-pointer text-primary underline underline-offset-2 hover:text-primary/80"
|
|
225
|
+
{...props}
|
|
226
|
+
>
|
|
227
|
+
{children}
|
|
228
|
+
</a>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
const external = typeof href !== "string" || EXTERNAL_HREF.test(href) || !onDocLink;
|
|
184
232
|
if (external) {
|
|
185
233
|
return (
|
|
186
234
|
<a
|
|
@@ -201,7 +249,7 @@ export function MarkdownPreview({
|
|
|
201
249
|
// Never let a repo-relative href resolve in the browser — it would
|
|
202
250
|
// hit the private repo or 404. Route it to the in-app doc instead.
|
|
203
251
|
e.preventDefault();
|
|
204
|
-
onDocLink(href);
|
|
252
|
+
onDocLink?.(href);
|
|
205
253
|
}}
|
|
206
254
|
className="cursor-pointer text-primary underline underline-offset-2 hover:text-primary/80"
|
|
207
255
|
{...props}
|
|
@@ -211,14 +259,14 @@ export function MarkdownPreview({
|
|
|
211
259
|
);
|
|
212
260
|
},
|
|
213
261
|
};
|
|
214
|
-
}, [onDocLink]);
|
|
262
|
+
}, [onDocLink, onFrameLink]);
|
|
215
263
|
|
|
216
264
|
return (
|
|
217
265
|
<div
|
|
218
266
|
data-slot="markdown-preview"
|
|
219
267
|
className={`${maxWidth} text-sm text-foreground/90`}
|
|
220
268
|
>
|
|
221
|
-
<ReactMarkdown remarkPlugins={[remarkGfm]} components={components}>
|
|
269
|
+
<ReactMarkdown remarkPlugins={[remarkGfm]} components={components} urlTransform={urlTransform}>
|
|
222
270
|
{source}
|
|
223
271
|
</ReactMarkdown>
|
|
224
272
|
</div>
|