@behavioral-agentic-design-system/core 0.29.0 → 0.30.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.
@@ -0,0 +1,287 @@
1
+ import type { Meta, StoryObj } from "@storybook/react"
2
+ import * as React from "react"
3
+ import {
4
+ Questionnaire,
5
+ type QuestionnaireQuestion,
6
+ } from "@behavioral-agentic-design-system/core/components/ui/questionnaire"
7
+
8
+ const meta: Meta<typeof Questionnaire> = {
9
+ title: "Components/Questionnaire",
10
+ component: Questionnaire,
11
+ parameters: {
12
+ layout: "centered",
13
+ docs: {
14
+ description: {
15
+ component:
16
+ "One-question-at-a-time form primitive for agentic clarification prompts, onboarding flows, intake forms, and configuration wizards. Supports single-choice (radio), multiple-choice (checkboxes), freeform (textarea), and skippable questions. Questions animate in from the travel direction on each step change. Completion announces via role=status + aria-live=polite.",
17
+ },
18
+ },
19
+ },
20
+ }
21
+ export default meta
22
+ type Story = StoryObj<typeof Questionnaire>
23
+
24
+ // ─── Single question ──────────────────────────────────────────────────────────
25
+
26
+ export const Default: Story = {
27
+ render: () => (
28
+ <div className="w-96">
29
+ <Questionnaire
30
+ questions={[
31
+ {
32
+ id: "role",
33
+ prompt: "What best describes your current role?",
34
+ type: "single",
35
+ options: [
36
+ { value: "designer", label: "Designer" },
37
+ { value: "engineer", label: "Engineer" },
38
+ { value: "product", label: "Product manager" },
39
+ { value: "founder", label: "Founder or executive" },
40
+ ],
41
+ },
42
+ ]}
43
+ onComplete={(answers) => console.log("Done", answers)}
44
+ />
45
+ </div>
46
+ ),
47
+ }
48
+
49
+ // ─── Variant: single choice multi-step ───────────────────────────────────────
50
+
51
+ const ONBOARDING_SINGLE: QuestionnaireQuestion[] = [
52
+ {
53
+ id: "team-size",
54
+ prompt: "How large is your design team?",
55
+ type: "single",
56
+ options: [
57
+ { value: "solo", label: "Just me" },
58
+ { value: "small", label: "2 – 5 people" },
59
+ { value: "medium", label: "6 – 20 people" },
60
+ { value: "large", label: "20+ people" },
61
+ ],
62
+ },
63
+ {
64
+ id: "ship-cadence",
65
+ prompt: "How often does your team ship design-system updates?",
66
+ type: "single",
67
+ options: [
68
+ { value: "daily", label: "Daily or continuously" },
69
+ { value: "weekly", label: "Weekly" },
70
+ { value: "monthly", label: "Monthly" },
71
+ { value: "quarterly", label: "Quarterly or less" },
72
+ ],
73
+ },
74
+ {
75
+ id: "priority",
76
+ prompt: "What's your top design-system priority right now?",
77
+ type: "single",
78
+ options: [
79
+ { value: "tokens", label: "Token governance" },
80
+ { value: "a11y", label: "Accessibility compliance" },
81
+ { value: "onboarding", label: "Engineer onboarding speed" },
82
+ { value: "coverage", label: "Component coverage" },
83
+ ],
84
+ },
85
+ ]
86
+
87
+ export const Variant_Single: Story = {
88
+ render: () => {
89
+ const [answers, setAnswers] = React.useState<Record<string, string | string[] | null> | null>(null)
90
+ return (
91
+ <div className="w-96 space-y-4">
92
+ {answers ? (
93
+ <pre className="rounded-md bg-muted p-3 text-xs">{JSON.stringify(answers, null, 2)}</pre>
94
+ ) : (
95
+ <Questionnaire questions={ONBOARDING_SINGLE} onComplete={(a) => setAnswers(a)} />
96
+ )}
97
+ </div>
98
+ )
99
+ },
100
+ }
101
+
102
+ // ─── Variant: multiple choice ─────────────────────────────────────────────────
103
+
104
+ export const Variant_Multiple: Story = {
105
+ render: () => (
106
+ <div className="w-96">
107
+ <Questionnaire
108
+ questions={[
109
+ {
110
+ id: "frameworks",
111
+ prompt: "Which frameworks does your team use? Select all that apply.",
112
+ type: "multiple",
113
+ options: [
114
+ { value: "react", label: "React" },
115
+ { value: "vue", label: "Vue" },
116
+ { value: "svelte", label: "Svelte" },
117
+ { value: "angular", label: "Angular" },
118
+ { value: "other", label: "Other" },
119
+ ],
120
+ },
121
+ ]}
122
+ onComplete={(answers) => console.log("Done", answers)}
123
+ />
124
+ </div>
125
+ ),
126
+ }
127
+
128
+ // ─── Variant: freeform ────────────────────────────────────────────────────────
129
+
130
+ export const Variant_Freeform: Story = {
131
+ render: () => (
132
+ <div className="w-96">
133
+ <Questionnaire
134
+ questions={[
135
+ {
136
+ id: "challenge",
137
+ prompt: "What's your biggest design-system challenge right now?",
138
+ type: "freeform",
139
+ },
140
+ ]}
141
+ onComplete={(answers) => console.log("Done", answers)}
142
+ />
143
+ </div>
144
+ ),
145
+ }
146
+
147
+ // ─── Variant: skippable ───────────────────────────────────────────────────────
148
+
149
+ export const Variant_Skippable: Story = {
150
+ render: () => (
151
+ <div className="w-96">
152
+ <Questionnaire
153
+ questions={[
154
+ {
155
+ id: "role",
156
+ prompt: "What best describes your current role?",
157
+ type: "single",
158
+ options: [
159
+ { value: "designer", label: "Designer" },
160
+ { value: "engineer", label: "Engineer" },
161
+ { value: "product", label: "Product manager" },
162
+ { value: "founder", label: "Founder or executive" },
163
+ ],
164
+ },
165
+ {
166
+ id: "company",
167
+ prompt: "Which company are you at? (optional)",
168
+ type: "freeform",
169
+ skippable: true,
170
+ skipLabel: "Prefer not to say",
171
+ },
172
+ ]}
173
+ onComplete={(answers) => console.log("Done", answers)}
174
+ onSkip={(id) => console.log("Skipped", id)}
175
+ />
176
+ </div>
177
+ ),
178
+ }
179
+
180
+ // ─── Variant: mixed types ─────────────────────────────────────────────────────
181
+
182
+ const MIXED_QUESTIONS: QuestionnaireQuestion[] = [
183
+ {
184
+ id: "role",
185
+ prompt: "What best describes your current role?",
186
+ type: "single",
187
+ options: [
188
+ { value: "designer", label: "Designer" },
189
+ { value: "engineer", label: "Engineer" },
190
+ { value: "product", label: "Product manager" },
191
+ { value: "founder", label: "Founder or executive" },
192
+ ],
193
+ },
194
+ {
195
+ id: "tools",
196
+ prompt: "Which design tools does your team use? Select all that apply.",
197
+ type: "multiple",
198
+ options: [
199
+ { value: "figma", label: "Figma" },
200
+ { value: "sketch", label: "Sketch" },
201
+ { value: "framer", label: "Framer" },
202
+ { value: "storybook", label: "Storybook" },
203
+ ],
204
+ },
205
+ {
206
+ id: "goal",
207
+ prompt: "What would make BADS most useful for your team?",
208
+ type: "freeform",
209
+ skippable: true,
210
+ },
211
+ ]
212
+
213
+ export const Variant_Mixed: Story = {
214
+ render: () => {
215
+ const [answers, setAnswers] = React.useState<Record<string, string | string[] | null> | null>(null)
216
+ return (
217
+ <div className="w-96 space-y-4">
218
+ {answers ? (
219
+ <pre className="rounded-md bg-muted p-3 text-xs">{JSON.stringify(answers, null, 2)}</pre>
220
+ ) : (
221
+ <Questionnaire questions={MIXED_QUESTIONS} onComplete={(a) => setAnswers(a)} />
222
+ )}
223
+ </div>
224
+ )
225
+ },
226
+ }
227
+
228
+ // ─── RealisticUse: agent clarification prompt ─────────────────────────────────
229
+
230
+ const AGENT_QUESTIONS: QuestionnaireQuestion[] = [
231
+ {
232
+ id: "intent",
233
+ prompt: "What would you like to do with the tokens v2 proposal?",
234
+ type: "single",
235
+ options: [
236
+ { value: "review", label: "Schedule a review with the full team" },
237
+ { value: "approve", label: "Approve it as-is and move to implementation" },
238
+ { value: "revise", label: "Request revisions before moving forward" },
239
+ { value: "defer", label: "Defer until Q4 planning" },
240
+ ],
241
+ },
242
+ {
243
+ id: "stakeholders",
244
+ prompt: "Who else needs to be in the loop?",
245
+ type: "multiple",
246
+ options: [
247
+ { value: "riley", label: "Riley Okafor — brand lead" },
248
+ { value: "jordan", label: "Jordan Reeves — design systems" },
249
+ { value: "avery", label: "Avery Nakamura — engineering" },
250
+ { value: "morgan", label: "Morgan Castellano — product" },
251
+ ],
252
+ },
253
+ {
254
+ id: "notes",
255
+ prompt: "Any context you'd like added to the calendar invite? (optional)",
256
+ type: "freeform",
257
+ skippable: true,
258
+ skipLabel: "No context needed",
259
+ },
260
+ ]
261
+
262
+ export const RealisticUse: Story = {
263
+ render: () => {
264
+ const [answers, setAnswers] = React.useState<Record<string, string | string[] | null> | null>(null)
265
+ return (
266
+ <div className="w-[420px] rounded-xl border border-border bg-card p-6 shadow-sm">
267
+ <p className="mb-1 text-xs font-medium text-muted-foreground uppercase tracking-wide">
268
+ Agent · Clarify intent
269
+ </p>
270
+ {answers ? (
271
+ <div className="space-y-3">
272
+ <p className="text-sm font-medium text-foreground">
273
+ Got it. Scheduling the review with the selected stakeholders.
274
+ </p>
275
+ <pre className="rounded-md bg-muted p-3 text-xs">{JSON.stringify(answers, null, 2)}</pre>
276
+ </div>
277
+ ) : (
278
+ <Questionnaire
279
+ questions={AGENT_QUESTIONS}
280
+ onComplete={(a) => setAnswers(a)}
281
+ onSkip={(id) => console.log("Skipped", id)}
282
+ />
283
+ )}
284
+ </div>
285
+ )
286
+ },
287
+ }
@@ -1,3 +1,5 @@
1
+ // Sidebar is a client component — it builds a React context and drives its
2
+ // open/collapsed state through hooks, none of which exist on the server.
1
3
  // Motion: rail hover narrowed transition-all → transition-colors (only the after-bg animates; explicit-properties rule).
2
4
  // Sidebar sticky container gained `h-svh` so the bg always spans the
3
5
  // viewport even when the menu is shorter than the screen. No new variants
@@ -90,7 +90,8 @@ export const Group_JustifyVariants: StoryObj = {
90
90
 
91
91
  export const Group_NoWrap: StoryObj = {
92
92
  render: () => (
93
- <Group wrap={false} gap="sm" className="overflow-x-auto max-w-xs">
93
+ // tabIndex={0} makes the scrollable region keyboard-accessible (axe scrollable-region-focusable)
94
+ <Group wrap={false} gap="sm" className="overflow-x-auto max-w-xs" tabIndex={0} aria-label="Workflow step progress">
94
95
  <Badge variant="secondary">Step 1</Badge>
95
96
  <Badge variant="secondary">Step 2</Badge>
96
97
  <Badge variant="secondary">Step 3</Badge>
@@ -1,3 +1,5 @@
1
+ // Textarea is a client component — the character count lives in useState, so it
2
+ // cannot be rendered from a React Server Component.
1
3
  import type { Meta, StoryObj } from "@storybook/react";
2
4
  import { Textarea } from "@behavioral-agentic-design-system/core/components/ui/textarea";
3
5
  import { Label } from "@behavioral-agentic-design-system/core/components/ui/label";