@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.
Files changed (148) hide show
  1. package/README.md +2 -0
  2. package/package.json +41 -9
  3. package/scripts/a11y-lint.cjs +66 -3
  4. package/scripts/check-spec.mjs +73 -0
  5. package/scripts/deal-directions.mjs +186 -0
  6. package/scripts/health-report.mjs +23 -3
  7. package/scripts/lib/counted-lint.mjs +100 -0
  8. package/scripts/lib/marketing-library.mjs +129 -0
  9. package/scripts/lib/on-system.mjs +249 -0
  10. package/scripts/lib/random.mjs +22 -0
  11. package/scripts/lib/spec-parse.d.mts +25 -0
  12. package/scripts/lib/spec-parse.mjs +188 -0
  13. package/scripts/lib/tells.mjs +128 -0
  14. package/scripts/lint-css-vars.mjs +175 -0
  15. package/scripts/lint-html-nesting.mjs +116 -0
  16. package/scripts/lint-live-ctas.mjs +138 -0
  17. package/scripts/lint-slop.mjs +25 -1
  18. package/scripts/on-system-score.mjs +95 -0
  19. package/scripts/slop-rules.mjs +1 -1
  20. package/scripts/source-images.mjs +180 -0
  21. package/scripts/ux-tells.mjs +78 -0
  22. package/scripts/wcag-audit.cjs +72 -5
  23. package/src/api/brand-colors.ts +3 -0
  24. package/src/api/brand-fonts.ts +3 -0
  25. package/src/api/brand-mark.ts +6 -1
  26. package/src/api/dev-write-guard.ts +53 -0
  27. package/src/api/layers/file.ts +7 -4
  28. package/src/api/onboarding-extract.ts +85 -30
  29. package/src/api/onboarding.ts +3 -0
  30. package/src/api/save-tokens.ts +3 -0
  31. package/src/app/layout.tsx +6 -0
  32. package/src/app/opengraph-image.tsx +5 -0
  33. package/src/app/preview/canvas/page.tsx +12 -0
  34. package/src/app/preview/components/page.tsx +2003 -2
  35. package/src/app/preview/studio/blank-screen.tsx +143 -0
  36. package/src/app/preview/studio/page.tsx +7 -0
  37. package/src/app/shell.tsx +168 -49
  38. package/src/components/Foundations/Motion.stories.tsx +1 -0
  39. package/src/components/canvas/canvas.tsx +458 -0
  40. package/src/components/canvas/layout.ts +72 -0
  41. package/src/components/canvas/parse-canvas.ts +32 -0
  42. package/src/components/canvas/sample.ts +90 -0
  43. package/src/components/canvas/spec-frame.tsx +43 -0
  44. package/src/components/canvas/types.ts +33 -0
  45. package/src/components/customize/design-controls.tsx +16 -1
  46. package/src/components/docs-tab.tsx +7 -7
  47. package/src/components/home-recent.tsx +73 -0
  48. package/src/components/home-tab.tsx +13 -13
  49. package/src/components/layers-tab.tsx +2 -2
  50. package/src/components/markdown-preview.tsx +60 -12
  51. package/src/components/studio/control-panel.tsx +299 -0
  52. package/src/components/studio/control-row.tsx +77 -0
  53. package/src/components/studio/preview-frame.tsx +165 -0
  54. package/src/components/studio/preview-pane.tsx +247 -0
  55. package/src/components/studio/studio.tsx +158 -0
  56. package/src/components/studio/types.ts +218 -0
  57. package/src/components/studio/use-studio-tweaks.ts +128 -0
  58. package/src/components/studio/use-studio-view-state.ts +72 -0
  59. package/src/components/ui/anchor.tsx +37 -3
  60. package/src/components/ui/attachment.tsx +211 -0
  61. package/src/components/ui/autocomplete.tsx +1 -1
  62. package/src/components/ui/chart.tsx +3 -0
  63. package/src/components/ui/code.tsx +1 -1
  64. package/src/components/ui/color-picker.tsx +21 -5
  65. package/src/components/ui/data-table.tsx +64 -3
  66. package/src/components/ui/date-field.tsx +1 -1
  67. package/src/components/ui/editable.tsx +1 -0
  68. package/src/components/ui/faceted-filter.tsx +187 -0
  69. package/src/components/ui/gauge-chart.tsx +252 -0
  70. package/src/components/ui/heatmap.tsx +256 -0
  71. package/src/components/ui/index.ts +9 -0
  72. package/src/components/ui/infinite-scroll.tsx +103 -0
  73. package/src/components/ui/inline-edit.tsx +175 -0
  74. package/src/components/ui/json-input.tsx +351 -0
  75. package/src/components/ui/month-picker.tsx +1 -1
  76. package/src/components/ui/navigation-progress.tsx +281 -0
  77. package/src/components/ui/number-input.tsx +27 -7
  78. package/src/components/ui/otp-input.tsx +208 -0
  79. package/src/components/ui/password-input.tsx +2 -1
  80. package/src/components/ui/password-strength-input.tsx +288 -0
  81. package/src/components/ui/phone-input.tsx +274 -0
  82. package/src/components/ui/pill.tsx +140 -0
  83. package/src/components/ui/popover.tsx +27 -4
  84. package/src/components/ui/scroll-progress.tsx +100 -0
  85. package/src/components/ui/search-input.tsx +1 -1
  86. package/src/components/ui/snackbar.tsx +393 -0
  87. package/src/components/ui/sortable-list.tsx +342 -0
  88. package/src/components/ui/squircle.tsx +1 -1
  89. package/src/components/ui/table.tsx +1 -1
  90. package/src/components/ui/tags-input.tsx +1 -1
  91. package/src/components/ui/timer.tsx +1 -0
  92. package/src/components/ui/tour.tsx +1 -3
  93. package/src/components/ui/transfer-list.tsx +13 -26
  94. package/src/components/ui/week-picker.tsx +1 -1
  95. package/src/components/ui/year-picker.tsx +1 -1
  96. package/src/data/component-added.json +958 -0
  97. package/src/data/docs-index.ts +36 -0
  98. package/src/hooks/use-global-mono-font.ts +1 -0
  99. package/src/hooks/use-global-primary-color.ts +1 -0
  100. package/src/hooks/use-global-sans-font.ts +1 -0
  101. package/src/hooks/use-global-serif-font.ts +1 -0
  102. package/src/hooks/use-global-type-scale.ts +17 -2
  103. package/src/hooks/use-mobile.ts +2 -0
  104. package/src/hooks/use-sync-type-scale.ts +7 -11
  105. package/src/lib/clamp.ts +2 -0
  106. package/src/lib/spec-parse.ts +4 -0
  107. package/src/lib/svg-sanitize.ts +19 -9
  108. package/src/stories/Anchor.stories.tsx +54 -0
  109. package/src/stories/Attachment.stories.tsx +189 -0
  110. package/src/stories/Autocomplete.stories.tsx +2 -0
  111. package/src/stories/Canvas.stories.tsx +45 -0
  112. package/src/stories/Chart.stories.tsx +4 -0
  113. package/src/stories/Code.stories.tsx +1 -0
  114. package/src/stories/ColorPicker.stories.tsx +41 -0
  115. package/src/stories/DataTable.stories.tsx +30 -0
  116. package/src/stories/DateField.stories.tsx +21 -0
  117. package/src/stories/Editable.stories.tsx +2 -0
  118. package/src/stories/FacetedFilter.stories.tsx +197 -0
  119. package/src/stories/GaugeChart.stories.tsx +169 -0
  120. package/src/stories/Heatmap.stories.tsx +172 -0
  121. package/src/stories/InfiniteScroll.stories.tsx +225 -0
  122. package/src/stories/InlineEdit.stories.tsx +106 -0
  123. package/src/stories/JsonInput.stories.tsx +212 -0
  124. package/src/stories/MarkdownPreview.stories.tsx +53 -0
  125. package/src/stories/MonthPicker.stories.tsx +21 -0
  126. package/src/stories/NavigationProgress.stories.tsx +159 -0
  127. package/src/stories/NumberInput.stories.tsx +26 -0
  128. package/src/stories/OtpInput.stories.tsx +110 -0
  129. package/src/stories/PasswordInput.stories.tsx +4 -0
  130. package/src/stories/PasswordStrengthInput.stories.tsx +211 -0
  131. package/src/stories/PhoneInput.stories.tsx +127 -0
  132. package/src/stories/Pill.stories.tsx +201 -0
  133. package/src/stories/Popover.stories.tsx +29 -1
  134. package/src/stories/Portal.stories.tsx +3 -1
  135. package/src/stories/ScrollProgress.stories.tsx +117 -0
  136. package/src/stories/SearchInput.stories.tsx +2 -0
  137. package/src/stories/Snackbar.stories.tsx +315 -0
  138. package/src/stories/SortableList.stories.tsx +263 -0
  139. package/src/stories/Squircle.stories.tsx +1 -0
  140. package/src/stories/Table.stories.tsx +1 -0
  141. package/src/stories/TagsInput.stories.tsx +2 -0
  142. package/src/stories/Timer.stories.tsx +26 -0
  143. package/src/stories/Tour.stories.tsx +1 -0
  144. package/src/stories/TransferList.stories.tsx +4 -0
  145. package/src/stories/WeekPicker.stories.tsx +21 -0
  146. package/src/stories/YearPicker.stories.tsx +21 -0
  147. package/src/stories/story-groups.json +33 -16
  148. package/src/tokens.json +82 -54
@@ -0,0 +1,225 @@
1
+ import type { Meta, StoryObj } from "@storybook/react"
2
+ import * as React from "react"
3
+ import { InfiniteScroll } from "@behavioral-agentic-design-system/core/components/ui/infinite-scroll"
4
+ import { Card, CardContent } from "@behavioral-agentic-design-system/core/components/ui/card"
5
+ import { Avatar, AvatarFallback } from "@behavioral-agentic-design-system/core/components/ui/avatar"
6
+ import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge"
7
+ import { Separator } from "@behavioral-agentic-design-system/core/components/ui/separator"
8
+
9
+ const meta: Meta<typeof InfiniteScroll> = {
10
+ title: "Components/Layout/InfiniteScroll",
11
+ component: InfiniteScroll,
12
+ parameters: { layout: "padded" },
13
+ tags: ["autodocs"],
14
+ }
15
+ export default meta
16
+ type Story = StoryObj<typeof InfiniteScroll>
17
+
18
+ type Item = { id: number; name: string; role: string; initials: string }
19
+
20
+ function makeItems(start: number, count: number): Item[] {
21
+ const names = [
22
+ { name: "Priya Chandrasekaran", role: "Product designer", initials: "PC" },
23
+ { name: "Marcus Oliveira", role: "Frontend engineer", initials: "MO" },
24
+ { name: "Aisha Tanaka", role: "Engineering manager", initials: "AT" },
25
+ { name: "Samuel Adeyemi", role: "Backend engineer", initials: "SA" },
26
+ { name: "Lena Bergmann", role: "UX researcher", initials: "LB" },
27
+ ]
28
+ return Array.from({ length: count }, (_, i) => ({
29
+ id: start + i,
30
+ ...names[(start + i) % names.length],
31
+ }))
32
+ }
33
+
34
+ export const Default: Story = {
35
+ parameters: {
36
+ controls: { disable: true },
37
+ docs: {
38
+ description: {
39
+ story:
40
+ "Scroll to the bottom repeatedly: every time the sentinel re-enters the viewport another page loads (8 → 16 → 24 → 32), then the end message renders. `onLoadMore` fires once per sentinel entry, not once per `hasMore` change.",
41
+ },
42
+ },
43
+ },
44
+ render: () => {
45
+ const PAGE = 8
46
+ const MAX = 32
47
+ const [items, setItems] = React.useState<Item[]>(() => makeItems(0, PAGE))
48
+ const [loading, setLoading] = React.useState(false)
49
+
50
+ function loadMore() {
51
+ if (loading) return
52
+ setLoading(true)
53
+ setTimeout(() => {
54
+ setItems((prev) => [...prev, ...makeItems(prev.length, PAGE)])
55
+ setLoading(false)
56
+ }, 800)
57
+ }
58
+
59
+ return (
60
+ <div className="max-h-[480px] overflow-y-auto rounded-lg border bg-card">
61
+ <InfiniteScroll
62
+ onLoadMore={loadMore}
63
+ hasMore={items.length < MAX}
64
+ endMessage={
65
+ <p className="py-6 text-center text-sm text-muted-foreground">
66
+ All {MAX} team members loaded
67
+ </p>
68
+ }
69
+ >
70
+ <ul>
71
+ {items.map((item, i) => (
72
+ <li key={item.id}>
73
+ {i > 0 && <Separator />}
74
+ <div className="flex items-center gap-3 px-4 py-3">
75
+ <Avatar size="sm">
76
+ <AvatarFallback>{item.initials}</AvatarFallback>
77
+ </Avatar>
78
+ <div className="min-w-0 flex-1">
79
+ <p className="truncate text-sm font-medium">{item.name}</p>
80
+ <p className="truncate text-xs text-muted-foreground">{item.role}</p>
81
+ </div>
82
+ </div>
83
+ </li>
84
+ ))}
85
+ </ul>
86
+ </InfiniteScroll>
87
+ </div>
88
+ )
89
+ },
90
+ }
91
+
92
+ export const CardGrid: Story = {
93
+ parameters: { controls: { disable: true } },
94
+ render: () => {
95
+ const PAGE = 6
96
+ const MAX = 24
97
+ const [items, setItems] = React.useState<Item[]>(() => makeItems(0, PAGE))
98
+
99
+ function loadMore() {
100
+ setTimeout(() => {
101
+ setItems((prev) => [...prev, ...makeItems(prev.length, PAGE)])
102
+ }, 600)
103
+ }
104
+
105
+ return (
106
+ <div className="max-h-[500px] overflow-y-auto">
107
+ <InfiniteScroll
108
+ onLoadMore={loadMore}
109
+ hasMore={items.length < MAX}
110
+ endMessage={
111
+ <p className="py-4 text-center text-sm text-muted-foreground">
112
+ No more results
113
+ </p>
114
+ }
115
+ >
116
+ <div className="grid grid-cols-2 gap-3 p-1 sm:grid-cols-3">
117
+ {items.map((item) => (
118
+ <Card key={item.id} className="shadow-none">
119
+ <CardContent className="flex flex-col items-center gap-2 p-4 text-center">
120
+ <Avatar size="lg">
121
+ <AvatarFallback>{item.initials}</AvatarFallback>
122
+ </Avatar>
123
+ <div className="min-w-0">
124
+ <p className="truncate text-sm font-medium">{item.name}</p>
125
+ <Badge variant="secondary" className="mt-1 text-xs">
126
+ {item.role}
127
+ </Badge>
128
+ </div>
129
+ </CardContent>
130
+ </Card>
131
+ ))}
132
+ </div>
133
+ </InfiniteScroll>
134
+ </div>
135
+ )
136
+ },
137
+ }
138
+
139
+ export const CustomLoader: Story = {
140
+ parameters: { controls: { disable: true } },
141
+ render: () => {
142
+ const PAGE = 5
143
+ const MAX = 15
144
+ const [items, setItems] = React.useState<Item[]>(() => makeItems(0, PAGE))
145
+ const [loading, setLoading] = React.useState(false)
146
+
147
+ function loadMore() {
148
+ setLoading(true)
149
+ setTimeout(() => {
150
+ setItems((prev) => [...prev, ...makeItems(prev.length, PAGE)])
151
+ setLoading(false)
152
+ }, 1000)
153
+ }
154
+
155
+ return (
156
+ <div className="max-h-[400px] overflow-y-auto rounded-lg border">
157
+ <InfiniteScroll
158
+ onLoadMore={loadMore}
159
+ hasMore={items.length < MAX}
160
+ loader={
161
+ loading ? (
162
+ <p className="py-4 text-center text-sm text-muted-foreground animate-pulse">
163
+ Loading more…
164
+ </p>
165
+ ) : null
166
+ }
167
+ >
168
+ <ul className="divide-y">
169
+ {items.map((item) => (
170
+ <li key={item.id} className="px-4 py-3 text-sm">
171
+ <span className="font-medium">{item.name}</span>{" "}
172
+ <span className="text-muted-foreground">— {item.role}</span>
173
+ </li>
174
+ ))}
175
+ </ul>
176
+ </InfiniteScroll>
177
+ </div>
178
+ )
179
+ },
180
+ }
181
+
182
+ export const RealisticUse: Story = {
183
+ parameters: { controls: { disable: true } },
184
+ render: () => {
185
+ const [items, setItems] = React.useState<Item[]>(() => makeItems(0, 10))
186
+
187
+ return (
188
+ <div className="space-y-2">
189
+ <p className="text-sm text-muted-foreground">
190
+ Scroll the list to load more. Total cap: 40 items.
191
+ </p>
192
+ <div className="max-h-[360px] overflow-y-auto rounded-lg border bg-background">
193
+ <InfiniteScroll
194
+ onLoadMore={() =>
195
+ setTimeout(
196
+ () => setItems((p) => [...p, ...makeItems(p.length, 10)]),
197
+ 700
198
+ )
199
+ }
200
+ hasMore={items.length < 40}
201
+ endMessage={
202
+ <div className="py-6 text-center text-sm text-muted-foreground">
203
+ You&apos;ve seen everything
204
+ </div>
205
+ }
206
+ >
207
+ <ul className="divide-y">
208
+ {items.map((item) => (
209
+ <li key={item.id} className="flex items-center gap-3 px-4 py-3">
210
+ <Avatar size="sm">
211
+ <AvatarFallback>{item.initials}</AvatarFallback>
212
+ </Avatar>
213
+ <div className="min-w-0">
214
+ <p className="truncate text-sm font-medium">{item.name}</p>
215
+ <p className="truncate text-xs text-muted-foreground">{item.role}</p>
216
+ </div>
217
+ </li>
218
+ ))}
219
+ </ul>
220
+ </InfiniteScroll>
221
+ </div>
222
+ </div>
223
+ )
224
+ },
225
+ }
@@ -0,0 +1,106 @@
1
+ import type { Meta, StoryObj } from "@storybook/react"
2
+ import * as React from "react"
3
+ import { InlineEdit } from "@behavioral-agentic-design-system/core/components/ui/inline-edit"
4
+
5
+ const meta: Meta<typeof InlineEdit> = {
6
+ title: "Components/Forms/InlineEdit",
7
+ component: InlineEdit,
8
+ parameters: { layout: "centered" },
9
+ tags: ["autodocs"],
10
+ }
11
+
12
+ export default meta
13
+ type Story = StoryObj<typeof meta>
14
+
15
+ export const Default: Story = {
16
+ args: { defaultValue: "Click to edit me" },
17
+ render: (args) => (
18
+ <div className="w-64">
19
+ <InlineEdit {...args} />
20
+ </div>
21
+ ),
22
+ }
23
+
24
+ export const Variant_Ghost: Story = {
25
+ args: { variant: "ghost", defaultValue: "Ghost variant" },
26
+ render: (args) => (
27
+ <div className="w-64">
28
+ <InlineEdit {...args} />
29
+ </div>
30
+ ),
31
+ }
32
+
33
+ export const Variant_Outline: Story = {
34
+ args: { variant: "outline", defaultValue: "Outline variant" },
35
+ render: (args) => (
36
+ <div className="w-64">
37
+ <InlineEdit {...args} />
38
+ </div>
39
+ ),
40
+ }
41
+
42
+ export const Size_Sm: Story = {
43
+ args: { size: "sm", defaultValue: "Small size" },
44
+ render: (args) => (
45
+ <div className="w-64">
46
+ <InlineEdit {...args} />
47
+ </div>
48
+ ),
49
+ }
50
+
51
+ export const Size_Default: Story = {
52
+ args: { size: "default", defaultValue: "Default size" },
53
+ render: (args) => (
54
+ <div className="w-64">
55
+ <InlineEdit {...args} />
56
+ </div>
57
+ ),
58
+ }
59
+
60
+ export const Size_Lg: Story = {
61
+ args: { size: "lg", defaultValue: "Large size" },
62
+ render: (args) => (
63
+ <div className="w-64">
64
+ <InlineEdit {...args} />
65
+ </div>
66
+ ),
67
+ }
68
+
69
+ export const Disabled: Story = {
70
+ args: { disabled: true, defaultValue: "Cannot edit" },
71
+ render: (args) => (
72
+ <div className="w-64">
73
+ <InlineEdit {...args} />
74
+ </div>
75
+ ),
76
+ }
77
+
78
+ export const Empty: Story = {
79
+ args: { placeholder: "Enter a project name…" },
80
+ render: (args) => (
81
+ <div className="w-64">
82
+ <InlineEdit {...args} />
83
+ </div>
84
+ ),
85
+ }
86
+
87
+ export const RealisticUse: Story = {
88
+ parameters: { controls: { disable: true } },
89
+ render: () => {
90
+ const [name, setName] = React.useState("Untitled project")
91
+ return (
92
+ <div className="flex w-72 flex-col gap-2">
93
+ <p className="text-muted-foreground text-xs">Project name</p>
94
+ <InlineEdit
95
+ value={name}
96
+ onConfirm={setName}
97
+ placeholder="Enter project name…"
98
+ variant="outline"
99
+ />
100
+ <p className="text-muted-foreground text-xs">
101
+ Saved: <span className="text-foreground">{name}</span>
102
+ </p>
103
+ </div>
104
+ )
105
+ },
106
+ }
@@ -0,0 +1,212 @@
1
+ import * as React from "react"
2
+ import type { Meta, StoryObj } from "@storybook/react"
3
+ import { JsonInput } from "@behavioral-agentic-design-system/core/components/ui/json-input"
4
+ import {
5
+ Field,
6
+ FieldLabel,
7
+ FieldHelper,
8
+ } from "@behavioral-agentic-design-system/core/components/ui/field"
9
+
10
+ // Real content from content/personas/bads.json — names/orgs, never Lorem/Acme.
11
+ // Storybook 8 + autodocs.
12
+
13
+ const meta: Meta<typeof JsonInput> = {
14
+ title: "Components/Forms/JsonInput",
15
+ component: JsonInput,
16
+ parameters: {
17
+ layout: "centered",
18
+ docs: {
19
+ description: {
20
+ component:
21
+ "A <Textarea> specialized for JSON text entry. Validates on every keystroke (or on blur) and shows an inline error when the text is not valid JSON. Fires onValidChange(parsed) whenever valid JSON is present. An optional \"Format\" button auto-indents the content. Peer parity: Mantine JsonInput, config-panel patterns in Ant Design and shadcn. Zero new dependencies — uses native JSON.parse.",
22
+ },
23
+ },
24
+ },
25
+ tags: ["autodocs"],
26
+ argTypes: {
27
+ validateOn: { control: "select", options: ["change", "blur"] },
28
+ size: { control: "select", options: ["sm", "default", "lg", "xl"] },
29
+ showFormatButton: { control: "boolean" },
30
+ formatIndent: { control: { type: "number", min: 0, max: 8 } },
31
+ disabled: { control: "boolean" },
32
+ externalError: { control: "text" },
33
+ },
34
+ }
35
+
36
+ export default meta
37
+ type Story = StoryObj<typeof meta>
38
+
39
+ // ─── Default ───────────────────────────────────────────────────────────────────
40
+
41
+ export const Default: Story = {
42
+ args: {
43
+ placeholder: '{"key": "value"}',
44
+ className: "w-80",
45
+ },
46
+ }
47
+
48
+ // ─── With valid JSON pre-filled ────────────────────────────────────────────────
49
+
50
+ const meridianConfig = JSON.stringify(
51
+ {
52
+ brand: "Meridian Payments",
53
+ primaryColor: "#1a56db",
54
+ radius: "md",
55
+ density: "comfortable",
56
+ },
57
+ null,
58
+ 2
59
+ )
60
+
61
+ export const WithValidJson: Story = {
62
+ args: {
63
+ defaultValue: meridianConfig,
64
+ className: "w-96",
65
+ },
66
+ }
67
+
68
+ // ─── With invalid JSON pre-filled ──────────────────────────────────────────────
69
+
70
+ export const WithInvalidJson: Story = {
71
+ args: {
72
+ defaultValue: '{"brand": "Fieldnote Labs", missing_quote: true}',
73
+ className: "w-96",
74
+ },
75
+ }
76
+
77
+ // ─── Validate on blur ──────────────────────────────────────────────────────────
78
+
79
+ export const ValidateOnBlur: Story = {
80
+ args: {
81
+ validateOn: "blur",
82
+ placeholder: '{"brand": "Lumen Analytics"}',
83
+ className: "w-80",
84
+ },
85
+ parameters: {
86
+ docs: {
87
+ description: {
88
+ story:
89
+ "Set `validateOn=\"blur\"` to defer validation until the user leaves the field — preferred for forms where live inline errors would feel intrusive.",
90
+ },
91
+ },
92
+ },
93
+ }
94
+
95
+ // ─── Without Format button ─────────────────────────────────────────────────────
96
+
97
+ export const NoFormatButton: Story = {
98
+ args: {
99
+ showFormatButton: false,
100
+ defaultValue: '{"org":"Cedar & Pine Studio","theme":"light","compact":false}',
101
+ className: "w-80",
102
+ },
103
+ }
104
+
105
+ // ─── Size_Sm ───────────────────────────────────────────────────────────────────
106
+
107
+ export const Size_Sm: Story = {
108
+ args: {
109
+ size: "sm",
110
+ placeholder: '{"key": "value"}',
111
+ className: "w-72",
112
+ },
113
+ }
114
+
115
+ // ─── Size_Default ─────────────────────────────────────────────────────────────
116
+
117
+ export const Size_Default: Story = {
118
+ args: {
119
+ size: "default",
120
+ placeholder: '{"key": "value"}',
121
+ className: "w-80",
122
+ },
123
+ }
124
+
125
+ // ─── Size_Lg ──────────────────────────────────────────────────────────────────
126
+
127
+ export const Size_Lg: Story = {
128
+ args: {
129
+ size: "lg",
130
+ placeholder: '{"key": "value"}',
131
+ className: "w-96",
132
+ },
133
+ }
134
+
135
+ // ─── Disabled ─────────────────────────────────────────────────────────────────
136
+
137
+ export const Disabled: Story = {
138
+ args: {
139
+ disabled: true,
140
+ defaultValue: JSON.stringify({ org: "Northwind Health", locale: "en-US" }, null, 2),
141
+ className: "w-80",
142
+ },
143
+ }
144
+
145
+ // ─── External error (server validation) ───────────────────────────────────────
146
+
147
+ export const ExternalError: Story = {
148
+ args: {
149
+ defaultValue: '{"plan":"enterprise","seats":25}',
150
+ externalError: "\"seats\" must be 50 or greater on the enterprise plan",
151
+ className: "w-96",
152
+ },
153
+ parameters: {
154
+ docs: {
155
+ description: {
156
+ story:
157
+ "Pass `externalError` to surface a server-side validation message even when the JSON itself parses correctly. Set `externalError={null}` to clear it.",
158
+ },
159
+ },
160
+ },
161
+ }
162
+
163
+ // ─── Realistic use — inside a Field ───────────────────────────────────────────
164
+
165
+ function RealisticUseDemo() {
166
+ const [value, setValue] = React.useState<string>("")
167
+ const [parsed, setParsed] = React.useState<unknown>(null)
168
+ const [error, setError] = React.useState<string | null>(null)
169
+
170
+ return (
171
+ <div className="w-96 space-y-4">
172
+ <Field name="json-webhook">
173
+ <FieldLabel>Webhook filter rules</FieldLabel>
174
+ <FieldHelper>Enter a JSON object that defines which events trigger this webhook.</FieldHelper>
175
+ <JsonInput
176
+ id="json-webhook"
177
+ value={value}
178
+ onChange={(e) => setValue(e.target.value)}
179
+ onValidChange={setParsed}
180
+ onError={setError}
181
+ placeholder='{"events": ["user.created"], "org": "Harborline Logistics"}'
182
+ className="w-full"
183
+ />
184
+ </Field>
185
+
186
+ {parsed !== null && (
187
+ <div className="rounded-md border border-border bg-muted p-3 text-xs text-muted-foreground">
188
+ <p className="mb-1 font-medium text-foreground">Parsed result:</p>
189
+ <pre className="font-mono text-xs whitespace-pre-wrap break-all">
190
+ {JSON.stringify(parsed, null, 2)}
191
+ </pre>
192
+ </div>
193
+ )}
194
+ {error && (
195
+ <p className="text-xs text-muted-foreground">Validation state: invalid</p>
196
+ )}
197
+ </div>
198
+ )
199
+ }
200
+
201
+ export const RealisticUse: Story = {
202
+ render: () => <RealisticUseDemo />,
203
+ parameters: {
204
+ controls: { disable: true },
205
+ docs: {
206
+ description: {
207
+ story:
208
+ "Used inside a `Field` wrapper with `label`, `description`, controlled state, and `onValidChange` to capture the parsed result for downstream use — e.g. a webhook configuration panel at Harborline Logistics.",
209
+ },
210
+ },
211
+ },
212
+ }
@@ -0,0 +1,53 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { MarkdownPreview } from "@behavioral-agentic-design-system/core/components/markdown-preview";
3
+
4
+ const meta: Meta<typeof MarkdownPreview> = {
5
+ title: "Components/Content and data/MarkdownPreview",
6
+ component: MarkdownPreview,
7
+ parameters: { layout: "padded" },
8
+ tags: ["autodocs"],
9
+ };
10
+
11
+ export default meta;
12
+ type Story = StoryObj<typeof meta>;
13
+
14
+ export const Default: Story = {
15
+ args: {
16
+ source: "# Release notes\n\nThe canvas ships with **doc frames**.\n\n- Pan and zoom\n- Pin the spec\n\n## Next\n\nSee [the report](docs/prototype-spec-report.md).",
17
+ },
18
+ };
19
+
20
+ /** Headings carry an id built from their text, so a frame can scroll to a section. */
21
+ export const HeadingAnchors: Story = {
22
+ args: { source: "## Element inventory\n\nEvery drawn element.\n\n## Open questions\n\nOne per line." },
23
+ };
24
+
25
+ /**
26
+ * A `frame:` link calls onFrameLink instead of navigating. The canvas uses it to pan to
27
+ * the frame an inventory row names.
28
+ */
29
+ export const FrameLink: Story = {
30
+ args: {
31
+ source: "| Element | View |\n|---|---|\n| Card grid | [cards](frame:cards) |",
32
+ onFrameLink: () => {},
33
+ },
34
+ };
35
+
36
+ /**
37
+ * A table wider than its box scrolls sideways. The scroll region takes focus, so a
38
+ * keyboard user can reach the clipped columns (axe: scrollable-region-focusable).
39
+ */
40
+ export const WideOverflowing: Story = {
41
+ decorators: [(Story) => <div className="w-[380px]"><Story /></div>],
42
+ args: {
43
+ source:
44
+ "| Element | Source | Built | Notes | View |\n|---|---|---|---|---|\n| Filter drawer, Sort by group | companion text, depth 2 | yes | Three options, ranked by distance, price, and rating. | listing-editorial |\n| Version number in footer | wireframe | deferred | Approved by Matthew on 2026-10-14. | |",
45
+ },
46
+ };
47
+
48
+ export const RealisticUse: Story = {
49
+ args: {
50
+ source:
51
+ "# Spec\n\n## Open questions\n\n- Matthew: Should the dashboard ship a loading state before the first client review?\n- Kelsey: Does the share dialog need real event copy?\n",
52
+ },
53
+ };
@@ -97,3 +97,24 @@ export const RealisticUse: Story = {
97
97
  );
98
98
  },
99
99
  };
100
+
101
+ // Controlled from an empty state: `useState<Date>()` starts as undefined, which used to read as
102
+ // "uncontrolled", so a later Clear showed the first pick again.
103
+ export const ControlledStartsEmpty: Story = {
104
+ parameters: { controls: { disable: true } },
105
+ render: () => {
106
+ const [value, setValue] = useState<Date>()
107
+ return (
108
+ <div className="flex flex-col items-start gap-3">
109
+ <MonthPicker value={value} onChange={(v) => setValue(v)} />
110
+ <button
111
+ type="button"
112
+ className="min-h-11 rounded-md border px-4 text-sm font-medium"
113
+ onClick={() => setValue(undefined)}
114
+ >
115
+ Clear
116
+ </button>
117
+ </div>
118
+ )
119
+ },
120
+ }