@behavioral-agentic-design-system/core 0.16.0 → 0.18.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 (87) hide show
  1. package/package.json +1 -1
  2. package/scripts/check-stories.mjs +12 -5
  3. package/scripts/fix-stories.mjs +6 -6
  4. package/scripts/generate-stories.cjs +7 -7
  5. package/src/app/preview/components/page.tsx +165 -50
  6. package/src/components/ui/code.tsx +55 -0
  7. package/src/components/ui/index.ts +0 -1
  8. package/src/components/ui/indicator.tsx +9 -7
  9. package/src/components/ui/native-select.tsx +68 -0
  10. package/src/components/ui/navigation-menu.tsx +23 -0
  11. package/src/components/ui/sheet.tsx +23 -6
  12. package/src/components/ui/spinner.tsx +14 -3
  13. package/src/components/ui/tags-input.tsx +210 -69
  14. package/src/stories/Accordion.stories.tsx +152 -0
  15. package/src/stories/Alert.stories.tsx +102 -0
  16. package/src/stories/AlertDialog.stories.tsx +125 -0
  17. package/src/stories/AspectRatio.stories.tsx +82 -0
  18. package/src/stories/Avatar.stories.tsx +36 -0
  19. package/src/stories/Badge.stories.tsx +54 -0
  20. package/src/stories/Breadcrumb.stories.tsx +36 -0
  21. package/src/stories/Button.stories.tsx +144 -0
  22. package/src/stories/ButtonGroup.stories.tsx +176 -0
  23. package/src/stories/Calendar.stories.tsx +67 -0
  24. package/src/stories/Card.stories.tsx +43 -0
  25. package/src/stories/Carousel.stories.tsx +233 -0
  26. package/src/stories/Chart.stories.tsx +174 -0
  27. package/src/stories/Checkbox.stories.tsx +32 -0
  28. package/src/stories/CircularProgress.stories.tsx +136 -0
  29. package/src/stories/Code.stories.tsx +131 -0
  30. package/src/stories/Collapsible.stories.tsx +27 -0
  31. package/src/stories/ColorPicker.stories.tsx +155 -0
  32. package/src/stories/Combobox.stories.tsx +168 -0
  33. package/src/stories/Command.stories.tsx +40 -0
  34. package/src/stories/ContextMenu.stories.tsx +293 -0
  35. package/src/stories/CopyButton.stories.tsx +111 -0
  36. package/src/stories/DatePicker.stories.tsx +176 -0
  37. package/src/stories/DateRangePicker.stories.tsx +95 -0
  38. package/src/stories/Dialog.stories.tsx +186 -0
  39. package/src/stories/DropdownMenu.stories.tsx +47 -0
  40. package/src/stories/EmptyState.stories.tsx +199 -0
  41. package/src/stories/Field.stories.tsx +155 -0
  42. package/src/stories/FileUpload.stories.tsx +134 -0
  43. package/src/stories/HoverCard.stories.tsx +149 -0
  44. package/src/stories/Indicator.stories.tsx +255 -0
  45. package/src/stories/Input.stories.tsx +69 -0
  46. package/src/stories/Kbd.stories.tsx +123 -0
  47. package/src/stories/Label.stories.tsx +27 -0
  48. package/src/stories/List.stories.tsx +159 -0
  49. package/src/stories/Menubar.stories.tsx +190 -0
  50. package/src/stories/MultiSelect.stories.tsx +107 -0
  51. package/src/stories/NativeSelect.stories.tsx +107 -0
  52. package/src/stories/NavigationMenu.stories.tsx +322 -0
  53. package/src/stories/NumberInput.stories.tsx +100 -0
  54. package/src/stories/Pagination.stories.tsx +201 -0
  55. package/src/stories/PasswordInput.stories.tsx +62 -0
  56. package/src/stories/PinInput.stories.tsx +136 -0
  57. package/src/stories/Popover.stories.tsx +37 -0
  58. package/src/stories/Progress.stories.tsx +64 -0
  59. package/src/stories/RadioGroup.stories.tsx +39 -0
  60. package/src/stories/RatingGroup.stories.tsx +102 -0
  61. package/src/stories/Resizable.stories.tsx +28 -0
  62. package/src/stories/Reveal.stories.tsx +63 -0
  63. package/src/stories/ScrollArea.stories.tsx +76 -0
  64. package/src/stories/SegmentedControl.stories.tsx +182 -0
  65. package/src/stories/Select.stories.tsx +62 -0
  66. package/src/stories/Separator.stories.tsx +28 -0
  67. package/src/stories/Sheet.stories.tsx +193 -0
  68. package/src/stories/Sidebar.stories.tsx +53 -0
  69. package/src/stories/Skeleton.stories.tsx +32 -0
  70. package/src/stories/Slider.stories.tsx +67 -0
  71. package/src/stories/Sonner.stories.tsx +146 -0
  72. package/src/stories/Spinner.stories.tsx +94 -0
  73. package/src/stories/Stepper.stories.tsx +228 -0
  74. package/src/stories/Switch.stories.tsx +58 -0
  75. package/src/stories/Table.stories.tsx +38 -0
  76. package/src/stories/Tabs.stories.tsx +128 -0
  77. package/src/stories/Tag.stories.tsx +51 -0
  78. package/src/stories/TagsInput.stories.tsx +154 -0
  79. package/src/stories/Textarea.stories.tsx +31 -0
  80. package/src/stories/TimePicker.stories.tsx +54 -0
  81. package/src/stories/Timeline.stories.tsx +263 -0
  82. package/src/stories/Toggle.stories.tsx +45 -0
  83. package/src/stories/ToggleGroup.stories.tsx +39 -0
  84. package/src/stories/Toolbar.stories.tsx +295 -0
  85. package/src/stories/Tooltip.stories.tsx +37 -0
  86. package/src/stories/TreeView.stories.tsx +293 -0
  87. package/src/components/ui/bottom-sheet.tsx +0 -133
@@ -50,10 +50,17 @@ function SheetContent({
50
50
  children,
51
51
  side = "right",
52
52
  showCloseButton = true,
53
+ showHandle = side === "bottom",
53
54
  ...props
54
55
  }: React.ComponentProps<typeof SheetPrimitive.Content> & {
55
56
  side?: "top" | "right" | "bottom" | "left"
56
57
  showCloseButton?: boolean
58
+ /**
59
+ * Bottom sheets only: render the centered grab-handle affordance at the top
60
+ * (the visual signal users read as "this panel came from the bottom").
61
+ * Defaults to `true` when `side="bottom"`, ignored for every other side.
62
+ */
63
+ showHandle?: boolean
57
64
  }) {
58
65
  // Apply the active portal theme scope to the content's className so any
59
66
  // theme-scoped CSS variables a consumer uses (`--shell-chrome-bg-rgb`,
@@ -74,22 +81,32 @@ function SheetContent({
74
81
  side === "top" &&
75
82
  "inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
76
83
  side === "bottom" &&
77
- "inset-x-0 bottom-0 h-auto border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
84
+ // Bottom sheets get the full mobile treatment: rounded top, capped
85
+ // height with internal scroll so a tall sheet keeps its footer
86
+ // reachable (svh tracks the dynamic viewport), safe-area padding,
87
+ // and gap-0 so header/content/footer own their own spacing.
88
+ "inset-x-0 bottom-0 h-auto max-h-[85svh] gap-0 overflow-y-auto rounded-t-xl border-t pb-[max(1rem,env(safe-area-inset-bottom))] data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
78
89
  portalThemeClass,
79
90
  className
80
91
  )}
81
92
  {...props}
82
93
  >
94
+ {side === "bottom" && showHandle && (
95
+ <div
96
+ aria-hidden="true"
97
+ className="mx-auto mt-3 mb-1 h-1.5 w-12 shrink-0 rounded-full bg-muted-foreground/30"
98
+ />
99
+ )}
83
100
  {children}
84
101
  {showCloseButton && (
85
102
  <SheetPrimitive.Close
86
103
  data-slot="sheet-close"
87
104
  // Matches the Dialog close button: top-4 right-4, rounded-xs, a 32px
88
- // (size-8) X glyph, opacity-70→100 on hover. Shared by Sheet AND
89
- // BottomSheet (both render SheetContent), so they read as one family
90
- // with Dialog. The one intentional difference from Dialog: a 44px
91
- // (size-11) hit target wrapping the 32px glyph, so it clears BADS's
92
- // touch-target floor — invisible since there's no box fill.
105
+ // (size-8) X glyph, opacity-70→100 on hover — so Sheet (every side,
106
+ // including bottom) reads as one family with Dialog. The one
107
+ // intentional difference from Dialog: a 44px (size-11) hit target
108
+ // wrapping the 32px glyph, so it clears BADS's touch-target floor —
109
+ // invisible since there's no box fill.
93
110
  className="absolute top-4 right-4 inline-flex size-11 items-center justify-center rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-8"
94
111
  style={{ strokeWidth: '1.5px' }}
95
112
  >
@@ -49,6 +49,11 @@ function Spinner({
49
49
  viewBox="0 0 24 24"
50
50
  aria-hidden="true"
51
51
  >
52
+ {/* Track and arc are concentric circles at the same radius and the
53
+ same 1.5 stroke width, so the spinner reads as one ring with a
54
+ moving highlight — not a thin track against a heavier filled arc.
55
+ pathLength={100} normalizes the circumference so strokeDasharray
56
+ "30 70" is exactly a 30% arc regardless of size. */}
52
57
  <circle
53
58
  className="opacity-25"
54
59
  cx="12"
@@ -57,10 +62,16 @@ function Spinner({
57
62
  stroke="currentColor"
58
63
  strokeWidth="1.5"
59
64
  />
60
- <path
65
+ <circle
61
66
  className="opacity-75"
62
- fill="currentColor"
63
- d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
67
+ cx="12"
68
+ cy="12"
69
+ r="10"
70
+ stroke="currentColor"
71
+ strokeWidth="1.5"
72
+ strokeLinecap="round"
73
+ pathLength={100}
74
+ strokeDasharray="30 70"
64
75
  />
65
76
  </svg>
66
77
  </span>
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import * as React from "react";
4
- import { XIcon } from "lucide-react";
4
+ import { XIcon, CheckIcon } from "lucide-react";
5
5
  import { cn } from "../../lib/utils";
6
6
 
7
7
  // ─── Types ────────────────────────────────────────────────────────────────────
@@ -22,6 +22,11 @@ export interface TagsInputProps
22
22
  allowDuplicates?: boolean;
23
23
  /** Characters that trigger tag creation in addition to Enter. Default: [","]. */
24
24
  delimiters?: string[];
25
+ /**
26
+ * Pool of suggestion strings shown in a dropdown as the user types.
27
+ * Already-added tags are excluded from the list automatically.
28
+ */
29
+ suggestions?: string[];
25
30
  }
26
31
 
27
32
  // ─── Component ────────────────────────────────────────────────────────────────
@@ -34,15 +39,30 @@ export function TagsInput({
34
39
  maxTags,
35
40
  allowDuplicates = false,
36
41
  delimiters = [","],
42
+ suggestions,
37
43
  className,
38
44
  ...props
39
45
  }: TagsInputProps) {
40
46
  const [inputValue, setInputValue] = React.useState("");
41
47
  const [focusedTagIndex, setFocusedTagIndex] = React.useState<number | null>(null);
48
+ const [activeIndex, setActiveIndex] = React.useState(-1);
49
+ const [showSuggestions, setShowSuggestions] = React.useState(false);
42
50
  const inputRef = React.useRef<HTMLInputElement>(null);
51
+ const listboxRef = React.useRef<HTMLUListElement>(null);
52
+ const listboxId = React.useId();
43
53
 
44
54
  const atMax = maxTags !== undefined && value.length >= maxTags;
45
55
 
56
+ const filteredSuggestions = React.useMemo(() => {
57
+ if (!suggestions?.length || !inputValue.trim()) return [];
58
+ const lower = inputValue.toLowerCase();
59
+ return suggestions.filter(
60
+ (s) => s.toLowerCase().includes(lower) && (allowDuplicates || !value.includes(s))
61
+ );
62
+ }, [suggestions, inputValue, value, allowDuplicates]);
63
+
64
+ const isOpen = showSuggestions && filteredSuggestions.length > 0;
65
+
46
66
  const addTag = React.useCallback(
47
67
  (raw: string) => {
48
68
  const trimmed = raw.trim();
@@ -51,6 +71,8 @@ export function TagsInput({
51
71
  if (!allowDuplicates && value.includes(trimmed)) return;
52
72
  onValueChange([...value, trimmed]);
53
73
  setInputValue("");
74
+ setShowSuggestions(false);
75
+ setActiveIndex(-1);
54
76
  },
55
77
  [atMax, allowDuplicates, value, onValueChange]
56
78
  );
@@ -64,28 +86,79 @@ export function TagsInput({
64
86
  [value, onValueChange]
65
87
  );
66
88
 
89
+ const selectSuggestion = React.useCallback(
90
+ (suggestion: string) => {
91
+ addTag(suggestion);
92
+ inputRef.current?.focus();
93
+ },
94
+ [addTag]
95
+ );
96
+
97
+ // Scroll the active option into view
98
+ React.useEffect(() => {
99
+ if (!isOpen || activeIndex < 0) return;
100
+ const li = listboxRef.current?.children[activeIndex] as HTMLElement | undefined;
101
+ li?.scrollIntoView({ block: "nearest" });
102
+ }, [activeIndex, isOpen]);
103
+
67
104
  const handleKeyDown = React.useCallback(
68
105
  (e: React.KeyboardEvent<HTMLInputElement>) => {
106
+ if (e.key === "ArrowDown") {
107
+ if (!isOpen && filteredSuggestions.length > 0) {
108
+ setShowSuggestions(true);
109
+ setActiveIndex(0);
110
+ } else if (isOpen) {
111
+ e.preventDefault();
112
+ setActiveIndex((i) => Math.min(i + 1, filteredSuggestions.length - 1));
113
+ }
114
+ return;
115
+ }
116
+ if (e.key === "ArrowUp" && isOpen) {
117
+ e.preventDefault();
118
+ setActiveIndex((i) => (i <= 0 ? 0 : i - 1));
119
+ return;
120
+ }
69
121
  if (e.key === "Enter") {
70
122
  e.preventDefault();
71
- addTag(inputValue);
72
- } else if (e.key === "Backspace" && inputValue === "") {
123
+ if (isOpen && activeIndex >= 0) {
124
+ selectSuggestion(filteredSuggestions[activeIndex]);
125
+ } else {
126
+ addTag(inputValue);
127
+ }
128
+ return;
129
+ }
130
+ if (e.key === "Escape") {
131
+ if (isOpen) {
132
+ setShowSuggestions(false);
133
+ setActiveIndex(-1);
134
+ } else {
135
+ setFocusedTagIndex(null);
136
+ }
137
+ return;
138
+ }
139
+ if (e.key === "Backspace" && inputValue === "") {
73
140
  e.preventDefault();
74
141
  if (focusedTagIndex !== null) {
75
142
  removeTag(focusedTagIndex);
76
143
  } else if (value.length > 0) {
77
144
  setFocusedTagIndex(value.length - 1);
78
145
  }
79
- } else if (e.key === "Delete" && inputValue === "" && focusedTagIndex !== null) {
146
+ return;
147
+ }
148
+ if (e.key === "Delete" && inputValue === "" && focusedTagIndex !== null) {
80
149
  e.preventDefault();
81
150
  removeTag(focusedTagIndex);
82
- } else if (e.key === "ArrowLeft" && inputValue === "") {
151
+ return;
152
+ }
153
+ if (e.key === "ArrowLeft" && inputValue === "") {
83
154
  if (focusedTagIndex === null && value.length > 0) {
84
155
  setFocusedTagIndex(value.length - 1);
85
156
  } else if (focusedTagIndex !== null && focusedTagIndex > 0) {
86
157
  setFocusedTagIndex(focusedTagIndex - 1);
87
158
  }
88
- } else if (e.key === "ArrowRight" && inputValue === "") {
159
+ return;
160
+ }
161
+ if (e.key === "ArrowRight" && inputValue === "") {
89
162
  if (focusedTagIndex !== null) {
90
163
  if (focusedTagIndex < value.length - 1) {
91
164
  setFocusedTagIndex(focusedTagIndex + 1);
@@ -93,13 +166,21 @@ export function TagsInput({
93
166
  setFocusedTagIndex(null);
94
167
  }
95
168
  }
96
- } else if (e.key === "Escape") {
97
- setFocusedTagIndex(null);
98
- } else {
99
- setFocusedTagIndex(null);
169
+ return;
100
170
  }
171
+ setFocusedTagIndex(null);
101
172
  },
102
- [inputValue, focusedTagIndex, value, addTag, removeTag]
173
+ [
174
+ inputValue,
175
+ focusedTagIndex,
176
+ value,
177
+ addTag,
178
+ removeTag,
179
+ selectSuggestion,
180
+ isOpen,
181
+ activeIndex,
182
+ filteredSuggestions,
183
+ ]
103
184
  );
104
185
 
105
186
  const handleInputChange = React.useCallback(
@@ -110,6 +191,8 @@ export function TagsInput({
110
191
  addTag(val.slice(0, -1));
111
192
  } else {
112
193
  setInputValue(val);
194
+ setShowSuggestions(true);
195
+ setActiveIndex(-1);
113
196
  }
114
197
  setFocusedTagIndex(null);
115
198
  },
@@ -124,76 +207,134 @@ export function TagsInput({
124
207
  : undefined;
125
208
 
126
209
  return (
127
- <div
128
- data-slot="tags-input"
129
- data-disabled={disabled || undefined}
130
- aria-disabled={disabled || undefined}
131
- onClick={() => !disabled && inputRef.current?.focus()}
132
- className={cn(
133
- "flex min-h-11 flex-wrap items-center gap-1.5 rounded-md border border-input bg-background px-3 py-2",
134
- "cursor-text",
135
- "focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",
136
- disabled && "cursor-not-allowed border-border/50 bg-muted/30 pointer-events-none",
137
- className
138
- )}
139
- {...props}
140
- >
141
- {value.map((tag, index) => (
142
- <span
143
- key={`${tag}-${index}`}
144
- data-slot="tags-input-item"
145
- data-focused={focusedTagIndex === index || undefined}
210
+ <div className="relative">
211
+ <div
212
+ data-slot="tags-input"
213
+ data-disabled={disabled || undefined}
214
+ aria-disabled={disabled || undefined}
215
+ onClick={() => !disabled && inputRef.current?.focus()}
216
+ className={cn(
217
+ "flex min-h-11 flex-wrap items-center gap-1.5 rounded-md border border-input bg-background px-3 py-2",
218
+ "cursor-text",
219
+ "focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",
220
+ disabled && "cursor-not-allowed border-border/50 bg-muted/30 pointer-events-none",
221
+ className
222
+ )}
223
+ {...props}
224
+ >
225
+ {value.map((tag, index) => (
226
+ <span
227
+ key={`${tag}-${index}`}
228
+ data-slot="tags-input-item"
229
+ data-focused={focusedTagIndex === index || undefined}
230
+ className={cn(
231
+ "inline-flex max-w-[160px] items-center gap-1 rounded-md px-2 py-0.5",
232
+ "text-sm font-medium transition-colors",
233
+ disabled
234
+ ? "bg-muted text-muted-foreground"
235
+ : "bg-secondary text-secondary-foreground",
236
+ !disabled && focusedTagIndex === index && "ring-2 ring-ring ring-offset-1 ring-offset-background"
237
+ )}
238
+ >
239
+ <span className="truncate">{tag}</span>
240
+ {!disabled && (
241
+ <button
242
+ type="button"
243
+ data-slot="tags-input-item-delete"
244
+ aria-label={`Remove ${tag}`}
245
+ tabIndex={-1}
246
+ onClick={(e) => {
247
+ e.stopPropagation();
248
+ removeTag(index);
249
+ }}
250
+ className={cn(
251
+ "shrink-0 rounded-sm p-0.5",
252
+ "text-secondary-foreground/70 hover:text-secondary-foreground",
253
+ "transition-colors",
254
+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
255
+ )}
256
+ style={{
257
+ transitionDuration: "var(--duration-fast)",
258
+ transitionTimingFunction: "var(--ease-out)",
259
+ }}
260
+ >
261
+ <XIcon className="size-3" strokeWidth={1.5} aria-hidden />
262
+ </button>
263
+ )}
264
+ </span>
265
+ ))}
266
+ <input
267
+ ref={inputRef}
268
+ type="text"
269
+ role="combobox"
270
+ aria-expanded={isOpen}
271
+ aria-haspopup="listbox"
272
+ aria-controls={isOpen ? listboxId : undefined}
273
+ aria-activedescendant={isOpen && activeIndex >= 0 ? `${listboxId}-${activeIndex}` : undefined}
274
+ aria-autocomplete={suggestions?.length ? "list" : "none"}
275
+ value={inputValue}
276
+ onChange={handleInputChange}
277
+ onKeyDown={handleKeyDown}
278
+ onFocus={() => inputValue && setShowSuggestions(true)}
279
+ onBlur={() => {
280
+ // Small delay so option click fires before blur closes the list
281
+ setTimeout(() => setShowSuggestions(false), 120);
282
+ }}
283
+ disabled={disabled || atMax}
284
+ placeholder={inputPlaceholder}
285
+ aria-label={placeholder ?? "Add tags, press Enter or comma to confirm"}
146
286
  className={cn(
147
- "inline-flex max-w-[160px] items-center gap-1 rounded-md px-2 py-0.5",
148
- "text-sm font-medium transition-colors",
149
- disabled
150
- ? "bg-muted text-muted-foreground"
151
- : "bg-secondary text-secondary-foreground",
152
- !disabled && focusedTagIndex === index && "ring-2 ring-ring ring-offset-1 ring-offset-background"
287
+ "min-w-[80px] flex-1 bg-transparent text-sm outline-none",
288
+ "placeholder:text-muted-foreground",
289
+ "disabled:cursor-not-allowed disabled:opacity-0"
290
+ )}
291
+ />
292
+ </div>
293
+
294
+ {isOpen && (
295
+ <ul
296
+ ref={listboxRef}
297
+ id={listboxId}
298
+ role="listbox"
299
+ aria-label="Suggestions"
300
+ className={cn(
301
+ "absolute left-0 right-0 z-50 mt-1 max-h-56 overflow-y-auto",
302
+ "rounded-md border border-input bg-popover shadow-md",
303
+ "py-1 text-sm text-popover-foreground"
153
304
  )}
154
305
  >
155
- <span className="truncate">{tag}</span>
156
- {!disabled && (
157
- <button
158
- type="button"
159
- data-slot="tags-input-item-delete"
160
- aria-label={`Remove ${tag}`}
161
- tabIndex={-1}
162
- onClick={(e) => {
163
- e.stopPropagation();
164
- removeTag(index);
306
+ {filteredSuggestions.map((suggestion, index) => (
307
+ <li
308
+ key={suggestion}
309
+ id={`${listboxId}-${index}`}
310
+ role="option"
311
+ aria-selected={index === activeIndex}
312
+ onMouseDown={(e) => {
313
+ // prevent input blur before click registers
314
+ e.preventDefault();
315
+ selectSuggestion(suggestion);
165
316
  }}
317
+ onMouseEnter={() => setActiveIndex(index)}
166
318
  className={cn(
167
- "shrink-0 rounded-sm p-0.5",
168
- "text-secondary-foreground/70 hover:text-secondary-foreground",
319
+ "flex items-center gap-2 px-3 py-1.5 cursor-pointer select-none",
169
320
  "transition-colors",
170
- "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
321
+ index === activeIndex
322
+ ? "bg-accent text-accent-foreground"
323
+ : "hover:bg-accent hover:text-accent-foreground"
171
324
  )}
172
325
  style={{
173
326
  transitionDuration: "var(--duration-fast)",
174
327
  transitionTimingFunction: "var(--ease-out)",
175
328
  }}
176
329
  >
177
- <XIcon className="size-3" strokeWidth={1.5} aria-hidden />
178
- </button>
179
- )}
180
- </span>
181
- ))}
182
- <input
183
- ref={inputRef}
184
- type="text"
185
- value={inputValue}
186
- onChange={handleInputChange}
187
- onKeyDown={handleKeyDown}
188
- disabled={disabled || atMax}
189
- placeholder={inputPlaceholder}
190
- aria-label={placeholder ?? "Add tags, press Enter or comma to confirm"}
191
- className={cn(
192
- "min-w-[80px] flex-1 bg-transparent text-sm outline-none",
193
- "placeholder:text-muted-foreground",
194
- "disabled:cursor-not-allowed disabled:opacity-0"
195
- )}
196
- />
330
+ {suggestion}
331
+ {value.includes(suggestion) && (
332
+ <CheckIcon className="ml-auto h-3.5 w-3.5 text-primary" aria-hidden="true" strokeWidth={1.5} />
333
+ )}
334
+ </li>
335
+ ))}
336
+ </ul>
337
+ )}
197
338
  </div>
198
339
  );
199
340
  }
@@ -0,0 +1,152 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import {
3
+ Accordion,
4
+ AccordionItem,
5
+ AccordionTrigger,
6
+ AccordionContent,
7
+ } from "@behavioral-agentic-design-system/core/components/ui/accordion";
8
+
9
+ // Note: Accordion drives its transition duration/timing via inline style with
10
+ // var() references (BADS motion tokens), not Tailwind duration utilities.
11
+ // Never write an arbitrary-value duration class literally in the accordion
12
+ // source or here — Tailwind's content scanner extracts class-like tokens even
13
+ // from comments and compiles them into invalid CSS that breaks the build.
14
+
15
+ const meta: Meta<typeof Accordion> = {
16
+ title: "Components/Accordion",
17
+ component: Accordion,
18
+ parameters: { layout: "centered" },
19
+ tags: ["autodocs"],
20
+ };
21
+
22
+ export default meta;
23
+ type Story = StoryObj<typeof meta>;
24
+
25
+ export const Default: Story = {
26
+ render: () => (
27
+ <Accordion type="single" collapsible className="w-[400px]">
28
+ <AccordionItem value="item-1">
29
+ <AccordionTrigger>What is BADS?</AccordionTrigger>
30
+ <AccordionContent>
31
+ BADS (Behavioral Agentic Design System) is a portable, distributable
32
+ design system built as the starting point for client engagements. It
33
+ ships tokens, components, ethics layers, and agent interfaces in one
34
+ cohesive package.
35
+ </AccordionContent>
36
+ </AccordionItem>
37
+ <AccordionItem value="item-2">
38
+ <AccordionTrigger>How do I customize tokens?</AccordionTrigger>
39
+ <AccordionContent>
40
+ Edit <code>tokens.json</code> and run{" "}
41
+ <code>pnpm build:tokens</code>. Both the published CSS and the local
42
+ preview regenerate automatically.
43
+ </AccordionContent>
44
+ </AccordionItem>
45
+ <AccordionItem value="item-3">
46
+ <AccordionTrigger>What accessibility standard does BADS target?</AccordionTrigger>
47
+ <AccordionContent>
48
+ BADS targets WCAG 2.2 AAA out of the box — 7:1 contrast for normal
49
+ text, 44 × 44 px touch targets, reduced-motion respected, and
50
+ focus-visible on every interactive element.
51
+ </AccordionContent>
52
+ </AccordionItem>
53
+ </Accordion>
54
+ ),
55
+ };
56
+
57
+ export const Variant_Multiple: Story = {
58
+ render: () => (
59
+ <Accordion type="multiple" className="w-[400px]">
60
+ <AccordionItem value="item-1">
61
+ <AccordionTrigger>Primary membership</AccordionTrigger>
62
+ <AccordionContent>
63
+ Covers the account holder and up to two dependents. Includes all
64
+ scheduled group classes and open lap swim.
65
+ </AccordionContent>
66
+ </AccordionItem>
67
+ <AccordionItem value="item-2">
68
+ <AccordionTrigger>Guest passes</AccordionTrigger>
69
+ <AccordionContent>
70
+ Members can bring one guest per visit at no charge. Guests must
71
+ sign a liability waiver at the front desk.
72
+ </AccordionContent>
73
+ </AccordionItem>
74
+ <AccordionItem value="item-3">
75
+ <AccordionTrigger>Facility hours</AccordionTrigger>
76
+ <AccordionContent>
77
+ Weekdays 5:30 am – 10:00 pm. Weekends 7:00 am – 8:00 pm. Holiday
78
+ hours posted on the bulletin board.
79
+ </AccordionContent>
80
+ </AccordionItem>
81
+ </Accordion>
82
+ ),
83
+ };
84
+
85
+ export const Disabled: Story = {
86
+ render: () => (
87
+ <Accordion type="single" collapsible className="w-[400px]">
88
+ <AccordionItem value="item-1">
89
+ <AccordionTrigger>Available — click to expand</AccordionTrigger>
90
+ <AccordionContent>
91
+ This item is enabled and interactive.
92
+ </AccordionContent>
93
+ </AccordionItem>
94
+ <AccordionItem value="item-2">
95
+ <AccordionTrigger disabled>Disabled item</AccordionTrigger>
96
+ <AccordionContent>
97
+ This content is inaccessible when the trigger is disabled.
98
+ </AccordionContent>
99
+ </AccordionItem>
100
+ <AccordionItem value="item-3">
101
+ <AccordionTrigger>Another available item</AccordionTrigger>
102
+ <AccordionContent>
103
+ This item is also enabled and interactive.
104
+ </AccordionContent>
105
+ </AccordionItem>
106
+ </Accordion>
107
+ ),
108
+ };
109
+
110
+ export const RealisticUse: Story = {
111
+ render: () => (
112
+ <div className="w-[480px] rounded-lg border bg-card p-6">
113
+ <h3 className="mb-4 text-2xl font-semibold">Frequently asked questions</h3>
114
+ <Accordion type="single" collapsible>
115
+ <AccordionItem value="q1">
116
+ <AccordionTrigger>How long does onboarding take?</AccordionTrigger>
117
+ <AccordionContent className="text-muted-foreground">
118
+ Most teams are fully set up within one afternoon. The onboarding
119
+ wizard walks you through brand tokens, voice calibration, and
120
+ component scoping — no design-system experience required.
121
+ </AccordionContent>
122
+ </AccordionItem>
123
+ <AccordionItem value="q2">
124
+ <AccordionTrigger>Can I use my own font stack?</AccordionTrigger>
125
+ <AccordionContent className="text-muted-foreground">
126
+ Yes. Add your font files to <code>public/fonts/</code> and declare
127
+ them in <code>brand-fonts.json</code>. Run{" "}
128
+ <code>pnpm build:fonts</code> and the CSS updates automatically.
129
+ </AccordionContent>
130
+ </AccordionItem>
131
+ <AccordionItem value="q3">
132
+ <AccordionTrigger>Is Figma sync supported?</AccordionTrigger>
133
+ <AccordionContent className="text-muted-foreground">
134
+ Figma sync (Token Studio export → BADS import) is a v2 feature on
135
+ the roadmap. Today, tokens live in <code>tokens.json</code> and
136
+ are the single source of truth.
137
+ </AccordionContent>
138
+ </AccordionItem>
139
+ <AccordionItem value="q4">
140
+ <AccordionTrigger>What if I need a component BADS doesn't ship?</AccordionTrigger>
141
+ <AccordionContent className="text-muted-foreground">
142
+ Run the Component Readiness Audit in{" "}
143
+ <code>prompts/component-readiness-audit.md</code>. If the outcome
144
+ is "new primitive," surface it for approval. The Night Shift agent
145
+ builds one new primitive per night and hands you a draft PR in the
146
+ morning.
147
+ </AccordionContent>
148
+ </AccordionItem>
149
+ </Accordion>
150
+ </div>
151
+ ),
152
+ };