@behavioral-agentic-design-system/core 0.37.0 → 0.39.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 (186) hide show
  1. package/package.json +8 -4
  2. package/scripts/a11y-lint.cjs +8 -2
  3. package/scripts/a11y-ratchet.mjs +172 -0
  4. package/scripts/accent-as-text.mjs +274 -0
  5. package/scripts/bads-doctor.mjs +2 -1
  6. package/scripts/check-stories.mjs +265 -52
  7. package/scripts/contrast.mjs +44 -0
  8. package/scripts/health-report.mjs +211 -122
  9. package/scripts/lint-slop.mjs +44 -2
  10. package/scripts/oklch-to-hex.cjs +7 -1
  11. package/scripts/ratchet.mjs +326 -0
  12. package/scripts/slop-rules.mjs +156 -0
  13. package/scripts/token-nearest.mjs +333 -0
  14. package/scripts/wcag-audit.cjs +59 -8
  15. package/src/app/preview/components/page.tsx +363 -0
  16. package/src/components/Foundations/Typography.stories.tsx +82 -21
  17. package/src/components/ui/accordion.tsx +67 -5
  18. package/src/components/ui/alert.tsx +20 -7
  19. package/src/components/ui/avatar.tsx +18 -4
  20. package/src/components/ui/breadcrumb.tsx +47 -0
  21. package/src/components/ui/checkbox-card.tsx +48 -8
  22. package/src/components/ui/checkbox.tsx +17 -8
  23. package/src/components/ui/format-date.tsx +107 -0
  24. package/src/components/ui/progress.tsx +6 -5
  25. package/src/components/ui/sparkline.tsx +198 -0
  26. package/src/components/ui/tag.tsx +17 -1
  27. package/src/components/ui/tags-input.tsx +84 -11
  28. package/src/components/ui/toggle-group.tsx +13 -0
  29. package/src/components/ui/week-picker.tsx +463 -0
  30. package/src/data/docs-index.ts +12 -0
  31. package/src/lib/theme-editor.ts +7 -1
  32. package/src/stories/Accordion.stories.tsx +59 -1
  33. package/src/stories/ActionBar.stories.tsx +1 -1
  34. package/src/stories/Affix.stories.tsx +1 -1
  35. package/src/stories/AiBadge.stories.tsx +1 -1
  36. package/src/stories/Alert.stories.tsx +36 -1
  37. package/src/stories/AlertDialog.stories.tsx +1 -1
  38. package/src/stories/Anchor.stories.tsx +1 -1
  39. package/src/stories/AngleSlider.stories.tsx +1 -1
  40. package/src/stories/AspectRatio.stories.tsx +1 -1
  41. package/src/stories/Autocomplete.stories.tsx +1 -1
  42. package/src/stories/Avatar.stories.tsx +41 -1
  43. package/src/stories/Badge.stories.tsx +1 -1
  44. package/src/stories/Blockquote.stories.tsx +1 -1
  45. package/src/stories/BottomNavigation.stories.tsx +1 -1
  46. package/src/stories/Breadcrumb.stories.tsx +38 -5
  47. package/src/stories/Burger.stories.tsx +1 -1
  48. package/src/stories/Button.stories.tsx +9 -1
  49. package/src/stories/ButtonGroup.stories.tsx +1 -1
  50. package/src/stories/Calendar.stories.tsx +1 -1
  51. package/src/stories/Card.stories.tsx +1 -1
  52. package/src/stories/Carousel.stories.tsx +1 -1
  53. package/src/stories/Cascader.stories.tsx +1 -1
  54. package/src/stories/Chart.stories.tsx +1 -1
  55. package/src/stories/ChatBubble.stories.tsx +1 -1
  56. package/src/stories/ChatMarker.stories.tsx +1 -1
  57. package/src/stories/Checkbox.stories.tsx +36 -5
  58. package/src/stories/CheckboxCard.stories.tsx +37 -2
  59. package/src/stories/CheckboxGroup.stories.tsx +1 -1
  60. package/src/stories/Chip.stories.tsx +1 -1
  61. package/src/stories/CircularProgress.stories.tsx +17 -1
  62. package/src/stories/Clipboard.stories.tsx +1 -1
  63. package/src/stories/CloseButton.stories.tsx +1 -1
  64. package/src/stories/Code.stories.tsx +1 -1
  65. package/src/stories/Collapsible.stories.tsx +1 -1
  66. package/src/stories/ColorPicker.stories.tsx +1 -1
  67. package/src/stories/ColorSwatch.stories.tsx +1 -1
  68. package/src/stories/Combobox.stories.tsx +1 -1
  69. package/src/stories/Command.stories.tsx +1 -1
  70. package/src/stories/Container.stories.tsx +1 -1
  71. package/src/stories/ContextMenu.stories.tsx +1 -1
  72. package/src/stories/CopyButton.stories.tsx +9 -1
  73. package/src/stories/DataList.stories.tsx +1 -1
  74. package/src/stories/DataTable.stories.tsx +1 -1
  75. package/src/stories/DateField.stories.tsx +1 -1
  76. package/src/stories/DatePicker.stories.tsx +1 -1
  77. package/src/stories/DateRangePicker.stories.tsx +1 -1
  78. package/src/stories/Dialog.stories.tsx +1 -1
  79. package/src/stories/Drawer.stories.tsx +1 -1
  80. package/src/stories/DropdownMenu.stories.tsx +1 -1
  81. package/src/stories/Editable.stories.tsx +1 -1
  82. package/src/stories/EmptyState.stories.tsx +1 -1
  83. package/src/stories/Field.stories.tsx +1 -1
  84. package/src/stories/Fieldset.stories.tsx +1 -1
  85. package/src/stories/FileButton.stories.tsx +1 -1
  86. package/src/stories/FileUpload.stories.tsx +1 -1
  87. package/src/stories/FloatLabel.stories.tsx +1 -1
  88. package/src/stories/FloatingActionButton.stories.tsx +1 -1
  89. package/src/stories/FloatingIndicator.stories.tsx +1 -1
  90. package/src/stories/FloatingPanel.stories.tsx +9 -1
  91. package/src/stories/FocusTrap.stories.tsx +1 -1
  92. package/src/stories/FormatByte.stories.tsx +1 -1
  93. package/src/stories/FormatDate.stories.tsx +174 -0
  94. package/src/stories/FormatNumber.stories.tsx +1 -1
  95. package/src/stories/Highlight.stories.tsx +1 -1
  96. package/src/stories/HoverCard.stories.tsx +1 -1
  97. package/src/stories/Image.stories.tsx +1 -1
  98. package/src/stories/Indicator.stories.tsx +17 -1
  99. package/src/stories/Input.stories.tsx +1 -1
  100. package/src/stories/InputClearButton.stories.tsx +1 -1
  101. package/src/stories/InputGroup.stories.tsx +1 -1
  102. package/src/stories/Kbd.stories.tsx +1 -1
  103. package/src/stories/KeyboardShortcut.stories.tsx +1 -1
  104. package/src/stories/Label.stories.tsx +1 -1
  105. package/src/stories/Link.stories.tsx +1 -1
  106. package/src/stories/List.stories.tsx +1 -1
  107. package/src/stories/Listbox.stories.tsx +1 -1
  108. package/src/stories/LoadingDots.stories.tsx +1 -1
  109. package/src/stories/LoadingOverlay.stories.tsx +1 -1
  110. package/src/stories/Mark.stories.tsx +1 -1
  111. package/src/stories/Marquee.stories.tsx +1 -1
  112. package/src/stories/Masonry.stories.tsx +1 -1
  113. package/src/stories/Menubar.stories.tsx +1 -1
  114. package/src/stories/Meter.stories.tsx +1 -1
  115. package/src/stories/MonthPicker.stories.tsx +1 -1
  116. package/src/stories/MotionToggle.stories.tsx +1 -1
  117. package/src/stories/MultiSelect.stories.tsx +1 -1
  118. package/src/stories/NativeSelect.stories.tsx +1 -1
  119. package/src/stories/NavLink.stories.tsx +1 -1
  120. package/src/stories/NavigationMenu.stories.tsx +1 -1
  121. package/src/stories/NavigationRail.stories.tsx +9 -1
  122. package/src/stories/Notification.stories.tsx +1 -1
  123. package/src/stories/NumberInput.stories.tsx +1 -1
  124. package/src/stories/Overlay.stories.tsx +1 -1
  125. package/src/stories/Pagination.stories.tsx +1 -1
  126. package/src/stories/PasswordInput.stories.tsx +1 -1
  127. package/src/stories/PinInput.stories.tsx +1 -1
  128. package/src/stories/Popover.stories.tsx +1 -1
  129. package/src/stories/Progress.stories.tsx +11 -1
  130. package/src/stories/Prose.stories.tsx +1 -1
  131. package/src/stories/QrCode.stories.tsx +1 -1
  132. package/src/stories/Questionnaire.stories.tsx +1 -1
  133. package/src/stories/RadioGroup.stories.tsx +1 -1
  134. package/src/stories/RatingGroup.stories.tsx +1 -1
  135. package/src/stories/Resizable.stories.tsx +1 -1
  136. package/src/stories/Result.stories.tsx +1 -1
  137. package/src/stories/Reveal.stories.tsx +1 -1
  138. package/src/stories/RollingNumber.stories.tsx +1 -1
  139. package/src/stories/ScrollArea.stories.tsx +1 -1
  140. package/src/stories/SearchInput.stories.tsx +1 -1
  141. package/src/stories/SegmentedControl.stories.tsx +1 -1
  142. package/src/stories/Select.stories.tsx +1 -1
  143. package/src/stories/Separator.stories.tsx +1 -1
  144. package/src/stories/Sheet.stories.tsx +1 -1
  145. package/src/stories/Sidebar.stories.tsx +1 -1
  146. package/src/stories/SignaturePad.stories.tsx +1 -1
  147. package/src/stories/SimpleGrid.stories.tsx +1 -1
  148. package/src/stories/Skeleton.stories.tsx +1 -1
  149. package/src/stories/SkeletonTable.stories.tsx +1 -1
  150. package/src/stories/SkipLink.stories.tsx +1 -1
  151. package/src/stories/Slider.stories.tsx +1 -1
  152. package/src/stories/Sonner.stories.tsx +1 -1
  153. package/src/stories/Sparkline.stories.tsx +208 -0
  154. package/src/stories/Spinner.stories.tsx +9 -1
  155. package/src/stories/Spoiler.stories.tsx +1 -1
  156. package/src/stories/Squircle.stories.tsx +1 -1
  157. package/src/stories/Stack.stories.tsx +1 -1
  158. package/src/stories/StatusBadge.stories.tsx +1 -1
  159. package/src/stories/Stepper.stories.tsx +1 -1
  160. package/src/stories/Switch.stories.tsx +1 -1
  161. package/src/stories/Table.stories.tsx +1 -1
  162. package/src/stories/Tabs.stories.tsx +1 -1
  163. package/src/stories/Tag.stories.tsx +23 -1
  164. package/src/stories/TagsInput.stories.tsx +46 -1
  165. package/src/stories/Text.stories.tsx +1 -1
  166. package/src/stories/Textarea.stories.tsx +1 -1
  167. package/src/stories/ThemeIcon.stories.tsx +1 -1
  168. package/src/stories/TimePicker.stories.tsx +1 -1
  169. package/src/stories/Timeline.stories.tsx +9 -1
  170. package/src/stories/Timer.stories.tsx +1 -1
  171. package/src/stories/Toggle.stories.tsx +1 -1
  172. package/src/stories/ToggleGroup.stories.tsx +21 -1
  173. package/src/stories/ToggleTip.stories.tsx +1 -1
  174. package/src/stories/Toolbar.stories.tsx +1 -1
  175. package/src/stories/Tooltip.stories.tsx +1 -1
  176. package/src/stories/Tour.stories.tsx +1 -1
  177. package/src/stories/TransferList.stories.tsx +1 -1
  178. package/src/stories/TreeSelect.stories.tsx +1 -1
  179. package/src/stories/TreeView.stories.tsx +1 -1
  180. package/src/stories/TypingIndicator.stories.tsx +1 -1
  181. package/src/stories/VisuallyHidden.stories.tsx +1 -1
  182. package/src/stories/Watermark.stories.tsx +1 -1
  183. package/src/stories/WeekPicker.stories.tsx +90 -0
  184. package/src/stories/WordRotate.stories.tsx +1 -1
  185. package/src/stories/YearPicker.stories.tsx +1 -1
  186. package/src/stories/story-groups.json +199 -0
@@ -0,0 +1,463 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
5
+
6
+ import { cn } from "../../lib/utils"
7
+ import { Button } from "./button"
8
+
9
+ export interface WeekPickerProps {
10
+ /**
11
+ * Controlled selected week, represented as the ISO Monday of that week
12
+ * (local time). The component normalises any supplied date to its
13
+ * ISO-week Monday.
14
+ */
15
+ value?: Date
16
+ /** Uncontrolled initial selection. */
17
+ defaultValue?: Date
18
+ /**
19
+ * Fires with the ISO-week Monday (local time) whenever a new week is
20
+ * selected. Re-clicking the current week is a no-op — to implement clear,
21
+ * track state externally.
22
+ */
23
+ onValueChange?: (weekStart: Date) => void
24
+ /** Disables the entire control. */
25
+ disabled?: boolean
26
+ /** Placeholder shown in the trigger when no week is selected. */
27
+ placeholder?: string
28
+ /**
29
+ * BCP 47 locale tag used to format month/year labels and weekday headers.
30
+ * Defaults to "en-US" (explicit, SSR-safe).
31
+ */
32
+ locale?: string
33
+ className?: string
34
+ /** Forwarded to the root container — pair with an external Label. */
35
+ id?: string
36
+ }
37
+
38
+ // ---------------------------------------------------------------------------
39
+ // ISO 8601 week helpers
40
+ // ---------------------------------------------------------------------------
41
+
42
+ /**
43
+ * Returns the ISO Monday (start of the ISO week) for any date, in local time.
44
+ * ISO weeks start on Monday; week 1 is the week containing the year's first
45
+ * Thursday.
46
+ */
47
+ function isoWeekStart(d: Date): Date {
48
+ const day = new Date(d)
49
+ day.setHours(0, 0, 0, 0)
50
+ // getDay(): 0=Sun,1=Mon,...,6=Sat → shift so Mon=0
51
+ const dow = (day.getDay() + 6) % 7 // 0=Mon…6=Sun
52
+ day.setDate(day.getDate() - dow)
53
+ return day
54
+ }
55
+
56
+ /** Returns the ISO week number (1–53) for a date in local time. */
57
+ function isoWeekNumber(d: Date): number {
58
+ // Algorithm: find the Thursday of the ISO week; the week number is the
59
+ // number of days from Jan 4 of that year's Thursday-year to that Thursday,
60
+ // divided by 7 and floored, plus 1.
61
+ const thursday = new Date(d)
62
+ thursday.setDate(thursday.getDate() - ((thursday.getDay() + 6) % 7) + 3)
63
+ const jan4 = new Date(thursday.getFullYear(), 0, 4)
64
+ return (
65
+ 1 +
66
+ Math.round(
67
+ (thursday.getTime() - isoWeekStart(jan4).getTime()) / 86_400_000 / 7
68
+ )
69
+ )
70
+ }
71
+
72
+ /** Returns the ISO year (may differ from calendar year at year boundaries). */
73
+ function isoWeekYear(d: Date): number {
74
+ const thursday = new Date(d)
75
+ thursday.setDate(thursday.getDate() - ((thursday.getDay() + 6) % 7) + 3)
76
+ return thursday.getFullYear()
77
+ }
78
+
79
+ /** Returns the number of ISO weeks in a given year (52 or 53). */
80
+ function isoWeeksInYear(year: number): number {
81
+ // A year has 53 ISO weeks if Jan 1 is Thursday, or if it's a leap year
82
+ // whose Jan 1 is Wednesday.
83
+ const jan1 = new Date(year, 0, 1).getDay() // 0=Sun
84
+ return jan1 === 4 || (jan1 === 3 && isLeapYear(year)) ? 53 : 52
85
+ }
86
+
87
+ function isLeapYear(year: number): boolean {
88
+ return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0
89
+ }
90
+
91
+ /** Number of days in a given month (0-indexed). */
92
+ function daysInMonth(year: number, month: number): number {
93
+ return new Date(year, month + 1, 0).getDate()
94
+ }
95
+
96
+ // ---------------------------------------------------------------------------
97
+ // Calendar grid helpers
98
+ // ---------------------------------------------------------------------------
99
+
100
+ /** Returns all Monday-start weeks that overlap the displayed month. */
101
+ function weeksInMonth(year: number, month: number): Date[] {
102
+ const first = new Date(year, month, 1)
103
+ // Start from the Monday on or before the 1st.
104
+ const start = isoWeekStart(first)
105
+ const weeks: Date[] = []
106
+ const cur = new Date(start)
107
+ while (cur.getMonth() === month || weeks.length === 0) {
108
+ weeks.push(new Date(cur))
109
+ cur.setDate(cur.getDate() + 7)
110
+ // Stop once Monday is past the last day of the month.
111
+ if (
112
+ cur.getMonth() !== month &&
113
+ cur.getDate() > daysInMonth(year, month)
114
+ ) {
115
+ break
116
+ }
117
+ }
118
+ return weeks
119
+ }
120
+
121
+ // Explicit locale constants — same SSR-safe convention as FormatNumber.
122
+ const WEEKDAY_HEADERS = Array.from({ length: 7 }, (_, i) => {
123
+ // Start from Monday: use a known Monday (2000-01-03).
124
+ const d = new Date(2000, 0, 3 + i)
125
+ return d.toLocaleString("en-US", { weekday: "narrow" })
126
+ })
127
+
128
+ /**
129
+ * ISO-week picker — a calendar-month grid where clicking any row selects
130
+ * that ISO week and fires `onValueChange` with the week's Monday.
131
+ *
132
+ * The trigger button displays "Week N, YYYY" format. Internal navigation
133
+ * moves one month at a time (PageUp/PageDown) and one year at a time
134
+ * (Shift+PageUp/PageDown). Row-level keyboard navigation: ArrowUp / ArrowDown
135
+ * move between week rows; Enter / Space select the focused week.
136
+ *
137
+ * ARIA: the grid uses role="grid" with row-level aria-selected and a roving
138
+ * tabindex so the selected week row is the natural tab stop.
139
+ */
140
+ function WeekPicker({
141
+ value,
142
+ defaultValue,
143
+ onValueChange,
144
+ disabled = false,
145
+ placeholder = "Select week",
146
+ locale = "en-US",
147
+ className,
148
+ id,
149
+ }: WeekPickerProps) {
150
+ const isControlled = value !== undefined
151
+ const [internalValue, setInternalValue] = React.useState<Date | undefined>(
152
+ defaultValue ? isoWeekStart(defaultValue) : undefined
153
+ )
154
+ const selected = isControlled
155
+ ? value
156
+ ? isoWeekStart(value)
157
+ : undefined
158
+ : internalValue
159
+
160
+ const today = React.useMemo(() => new Date(), [])
161
+ const [viewYear, setViewYear] = React.useState<number>(
162
+ () => (selected ?? today).getFullYear()
163
+ )
164
+ const [viewMonth, setViewMonth] = React.useState<number>(
165
+ () => (selected ?? today).getMonth()
166
+ )
167
+
168
+ // Roving tabindex: index of the focused week row.
169
+ const [focusedRow, setFocusedRow] = React.useState<number | null>(null)
170
+ const rowRefs = React.useRef<Array<HTMLButtonElement | null>>([])
171
+
172
+ // Follow a controlled value into its month.
173
+ const valueTime = selected?.getTime()
174
+ React.useEffect(() => {
175
+ if (valueTime !== undefined) {
176
+ const d = new Date(valueTime)
177
+ setViewYear(d.getFullYear())
178
+ setViewMonth(d.getMonth())
179
+ }
180
+ }, [valueTime])
181
+
182
+ const weeks = React.useMemo(
183
+ () => weeksInMonth(viewYear, viewMonth),
184
+ [viewYear, viewMonth]
185
+ )
186
+
187
+ // Reset focused row when the month changes.
188
+ React.useEffect(() => {
189
+ setFocusedRow(null)
190
+ }, [viewYear, viewMonth])
191
+
192
+ function selectWeek(weekStart: Date) {
193
+ if (disabled) return
194
+ if (!isControlled) setInternalValue(weekStart)
195
+ onValueChange?.(weekStart)
196
+ }
197
+
198
+ function prevMonth() {
199
+ if (disabled) return
200
+ setViewMonth((m) => {
201
+ if (m === 0) {
202
+ setViewYear((y) => y - 1)
203
+ return 11
204
+ }
205
+ return m - 1
206
+ })
207
+ }
208
+
209
+ function nextMonth() {
210
+ if (disabled) return
211
+ setViewMonth((m) => {
212
+ if (m === 11) {
213
+ setViewYear((y) => y + 1)
214
+ return 0
215
+ }
216
+ return m + 1
217
+ })
218
+ }
219
+
220
+ function handleGridKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {
221
+ const from = focusedRow ?? selectedRowIdx ?? 0
222
+ switch (event.key) {
223
+ case "ArrowUp": {
224
+ event.preventDefault()
225
+ const prev = from - 1
226
+ if (prev >= 0) rowRefs.current[prev]?.focus()
227
+ break
228
+ }
229
+ case "ArrowDown": {
230
+ event.preventDefault()
231
+ const next = from + 1
232
+ if (next < weeks.length) rowRefs.current[next]?.focus()
233
+ break
234
+ }
235
+ case "PageUp":
236
+ event.preventDefault()
237
+ if (event.shiftKey) {
238
+ setViewYear((y) => y - 1)
239
+ } else {
240
+ prevMonth()
241
+ }
242
+ break
243
+ case "PageDown":
244
+ event.preventDefault()
245
+ if (event.shiftKey) {
246
+ setViewYear((y) => y + 1)
247
+ } else {
248
+ nextMonth()
249
+ }
250
+ break
251
+ case "Home":
252
+ event.preventDefault()
253
+ rowRefs.current[0]?.focus()
254
+ break
255
+ case "End":
256
+ event.preventDefault()
257
+ rowRefs.current[weeks.length - 1]?.focus()
258
+ break
259
+ }
260
+ }
261
+
262
+ // The index of the selected week in the current month view (or null).
263
+ const selectedRowIdx = React.useMemo(() => {
264
+ if (!selected) return null
265
+ const selTime = selected.getTime()
266
+ return weeks.findIndex((w) => w.getTime() === selTime)
267
+ }, [selected, weeks])
268
+
269
+ const tabbableRow =
270
+ focusedRow !== null ? focusedRow : selectedRowIdx ?? 0
271
+
272
+ // Month/year header label.
273
+ const monthLabel = new Date(viewYear, viewMonth, 1).toLocaleString(locale, {
274
+ month: "long",
275
+ year: "numeric",
276
+ })
277
+
278
+ // Trigger label.
279
+ const triggerLabel = selected
280
+ ? `Week ${isoWeekNumber(selected)}, ${isoWeekYear(selected)}`
281
+ : placeholder
282
+
283
+ return (
284
+ <div
285
+ id={id}
286
+ data-slot="week-picker"
287
+ data-disabled={disabled || undefined}
288
+ className={cn("w-fit bg-background p-3", className)}
289
+ >
290
+ {/* Trigger / selection display */}
291
+ <div
292
+ data-slot="week-picker-trigger"
293
+ className={cn(
294
+ "mb-3 rounded-md border border-input px-3 py-2 text-sm",
295
+ disabled ? "cursor-not-allowed text-muted-foreground" : "text-foreground"
296
+ )}
297
+ aria-live="polite"
298
+ >
299
+ {triggerLabel}
300
+ </div>
301
+
302
+ {/* Month navigation header */}
303
+ <div
304
+ data-slot="week-picker-header"
305
+ className="mb-2 flex items-center justify-between gap-1"
306
+ >
307
+ <Button
308
+ type="button"
309
+ variant="ghost"
310
+ size="icon-xl"
311
+ aria-label="Previous month"
312
+ disabled={disabled}
313
+ onClick={prevMonth}
314
+ >
315
+ <ChevronLeftIcon strokeWidth={1.5} aria-hidden="true" />
316
+ </Button>
317
+ <span
318
+ aria-live="polite"
319
+ className={cn(
320
+ "text-sm font-medium select-none",
321
+ disabled ? "text-muted-foreground" : "text-foreground"
322
+ )}
323
+ >
324
+ {monthLabel}
325
+ </span>
326
+ <Button
327
+ type="button"
328
+ variant="ghost"
329
+ size="icon-xl"
330
+ aria-label="Next month"
331
+ disabled={disabled}
332
+ onClick={nextMonth}
333
+ >
334
+ <ChevronRightIcon strokeWidth={1.5} aria-hidden="true" />
335
+ </Button>
336
+ </div>
337
+
338
+ {/* Weekday header row */}
339
+ <div
340
+ data-slot="week-picker-weekdays"
341
+ className="mb-1 grid grid-cols-8 gap-0.5"
342
+ aria-hidden="true"
343
+ >
344
+ {/* Wk label column */}
345
+ <span className="flex h-7 items-center justify-center text-xs font-medium text-muted-foreground select-none">
346
+ Wk
347
+ </span>
348
+ {WEEKDAY_HEADERS.map((h) => (
349
+ <span
350
+ key={h}
351
+ className="flex h-7 items-center justify-center text-xs font-medium text-muted-foreground select-none"
352
+ >
353
+ {h}
354
+ </span>
355
+ ))}
356
+ </div>
357
+
358
+ {/* Week grid */}
359
+ <div
360
+ role="grid"
361
+ aria-label="Week picker"
362
+ aria-disabled={disabled || undefined}
363
+ data-slot="week-picker-grid"
364
+ tabIndex={disabled ? 0 : -1}
365
+ onKeyDown={handleGridKeyDown}
366
+ className="space-y-0.5"
367
+ >
368
+ {weeks.map((weekStart, rowIdx) => {
369
+ const weekNum = isoWeekNumber(weekStart)
370
+ const weekYear = isoWeekYear(weekStart)
371
+ const isSelected =
372
+ selected !== undefined && weekStart.getTime() === selected.getTime()
373
+ const isThisWeek =
374
+ weekStart.getTime() === isoWeekStart(today).getTime()
375
+
376
+ // Generate the 7 days of this week.
377
+ const days = Array.from({ length: 7 }, (_, i) => {
378
+ const d = new Date(weekStart)
379
+ d.setDate(d.getDate() + i)
380
+ return d
381
+ })
382
+
383
+ return (
384
+ <div key={weekStart.getTime()} role="row" className="flex gap-0.5">
385
+ {/* Row = one week button spanning the whole row */}
386
+ <button
387
+ ref={(el) => {
388
+ rowRefs.current[rowIdx] = el
389
+ }}
390
+ type="button"
391
+ role="gridcell"
392
+ data-slot="week-picker-row"
393
+ data-selected={isSelected || undefined}
394
+ data-this-week={isThisWeek || undefined}
395
+ aria-label={`Week ${weekNum}, ${weekYear}`}
396
+ aria-selected={isSelected}
397
+ disabled={disabled}
398
+ tabIndex={!disabled && rowIdx === tabbableRow ? 0 : -1}
399
+ onClick={() => selectWeek(weekStart)}
400
+ onFocus={() => setFocusedRow(rowIdx)}
401
+ // Motion pattern (c): token-driven one-off transition.
402
+ style={{
403
+ transitionDuration: "var(--duration-fast)",
404
+ transitionTimingFunction: "var(--ease-out)",
405
+ }}
406
+ className={cn(
407
+ "flex min-h-9 w-full items-center rounded-md px-1 transition-colors outline-none",
408
+ "focus-visible:ring-[3px] focus-visible:ring-ring/50",
409
+ "disabled:pointer-events-none disabled:opacity-50",
410
+ isSelected
411
+ ? "bg-primary text-primary-foreground hover:bg-primary/90"
412
+ : "text-foreground hover:bg-accent hover:text-accent-foreground",
413
+ isThisWeek && !isSelected && "font-medium ring-1 ring-border"
414
+ )}
415
+ >
416
+ {/* Week number column */}
417
+ <span
418
+ className={cn(
419
+ "mr-1 flex h-7 w-7 shrink-0 items-center justify-center rounded text-xs tabular-nums select-none",
420
+ isSelected
421
+ ? "bg-primary-foreground/20 text-primary-foreground"
422
+ : "text-muted-foreground"
423
+ )}
424
+ >
425
+ {weekNum}
426
+ </span>
427
+
428
+ {/* Day cells */}
429
+ <span className="flex flex-1 justify-between">
430
+ {days.map((day) => {
431
+ const isCurrentMonth = day.getMonth() === viewMonth
432
+ const isToday =
433
+ day.getDate() === today.getDate() &&
434
+ day.getMonth() === today.getMonth() &&
435
+ day.getFullYear() === today.getFullYear()
436
+ return (
437
+ <span
438
+ key={day.getTime()}
439
+ aria-hidden="true"
440
+ data-today={isToday || undefined}
441
+ className={cn(
442
+ "flex h-7 w-7 items-center justify-center rounded-sm text-xs tabular-nums select-none",
443
+ !isCurrentMonth && "opacity-40",
444
+ isToday &&
445
+ !isSelected &&
446
+ "font-semibold underline underline-offset-2"
447
+ )}
448
+ >
449
+ {day.getDate()}
450
+ </span>
451
+ )
452
+ })}
453
+ </span>
454
+ </button>
455
+ </div>
456
+ )
457
+ })}
458
+ </div>
459
+ </div>
460
+ )
461
+ }
462
+
463
+ export { WeekPicker }
@@ -75,6 +75,7 @@ export const DOCS_INDEX: DocGroup[] = [
75
75
  { title: "Storybook rule", path: "STORYBOOK_RULE.md" },
76
76
  { title: "CTA size contract", path: "prompts/cta-size-contract.md" },
77
77
  { title: "Motion spec", path: "prompts/motion-spec.md" },
78
+ { title: "Elevation and shadow", path: "docs/elevation.md", summary: "The shadow MODEL behind the shadow scale: raised vs inset are opposite treatments, the contact/cast alpha crossover as elevation rises, why inset values can't be copied between light and dark surfaces, and the box-shadow trap where a second declaration silently discards the first. Reconciles the ≥40px-blur anti-slop rule with legitimate modal elevation." },
78
79
  { title: "Motion choreography", path: "prompts/motion-choreography.md", summary: "Page-scale motion for expressive/motion-led surfaces (hero, landing) — timing budget, stagger-by-hierarchy, coverage sweep, signature-techniques menu, linear() springs. Opt-in, gated on the brand's motion dial; reconciled with BADS' anti-defaults. Adapted from VibeCurb's awwwards-motion." },
79
80
  ],
80
81
  },
@@ -109,6 +110,7 @@ export const DOCS_INDEX: DocGroup[] = [
109
110
  { title: "Prompt — conceptual model", path: "prompts/conceptual-model.md", summary: "Before sketching a product surface, name its domain objects, states, relationships, and vocabulary — Jamie Mill's 'most neglected layer,' wired into Path B as design-exploration step 3.5. Feeds the real-content pool, state patterns, and primitive selection." },
110
111
  { title: "Prompt — parallel rollout", path: "prompts/parallel-rollout.md", summary: "For a Path B build that's N similar surfaces: build one reference screen, turn it into an explicit contract, sign off on the contract, then fan the rest out against it (via Workflow) and verify each to the contract. Stops multi-screen drift. Adapted from the design-spec-framework." },
111
112
  { title: "Prompt — design directions", path: "prompts/design-directions.md" },
113
+ { title: "Prompt — color ramp", path: "prompts/color-ramp.md", summary: "Build a 9-shade ramp from the single brand hex a client hands you: place 500, find the edges, fill inward, and move with hue rotation (capped 20-30°) rather than lightness alone so dark shades don't go grey. Adapted to BADS's AAA floor, which is stricter than the source and pushes the dark end further than it looks." },
112
114
  { title: "Prompt — plan & spec", path: "prompts/plan-and-spec.md", summary: "Lightweight per-feature convention: a matched plan (how you'll build it) + spec (the durable contract, in RFC-2119 language) under docs/plans/ and docs/specs/, dated and slugged the same. The trail that lets the next agent — or the client's team after the engagement — reconstruct why. Adapted from web-common's superpowers/plans + specs." },
113
115
  { title: "Prompt — macrostructures", path: "prompts/macrostructures.md", summary: "Named menu of ~16 structural paradigms (the positive counterpart to the anti-defaults) with when-it-fits / what-it-costs each, plus a diversification rule so a fork's screens don't converge on one shape. Consumed at design-exploration step 3.7. Adapted BADS-native from Nutlope's Hallmark." },
114
116
  { title: "Prompt — design critique", path: "prompts/design-critique.md" },
@@ -127,6 +129,12 @@ export const DOCS_INDEX: DocGroup[] = [
127
129
  { title: "Release-please evaluation", path: "docs/release-please-evaluation.md", summary: "Decision record: release-please vs changesets. Recommendation — stay on changesets (BADS ships one package; human-authored changelogs fit the intentional-output ethos), revisit release-please when BADS goes multi-package or Night Shift's auto-merge cadence outpaces manual changeset authoring. Item 12 from the web-common spec." },
128
130
  { title: "Oxlint + anti-slop evaluation", path: "docs/oxlint-anti-slop-evaluation.md", summary: "Spike (paused): dmmulroy/anti-slop TS rules + oxlint adoption (web-common Item 3). Finding — BADS's TypeScript is already clean of the low-signal patterns; the cheap win is oxlint's baseline (72 mostly-autofixable warnings), not the anti-slop pack. Recommended split: baseline + web-common React/cn rules + a few zero-cost ratchet rules; skip the high-backlog ones." },
129
131
  { title: "StyleX evaluation", path: "docs/stylex-evaluation.md", summary: "Scouting note (not adopted): Meta's compile-time atomic CSS-in-JS. Verdict — a replacement for BADS's Tailwind-v4 foundation, not an addition; rewriting it would invalidate the className-scanning lint suite that is BADS's value. Worth remembering only for a green-field v2 'creative OS' layer, for its deterministic cross-boundary token merge." },
132
+ { title: "lieflat-charts evaluation", path: "docs/lieflat-charts-evaluation.md", summary: "Scouting note (not adopted): an editorial data-viz agent skill. Blocker — PolyForm Noncommercial license; its code must never be vendored into a commercial fork. BADS already holds the philosophy (chart-design.md). One license-clean idea borrowed: a data-shape → chart-type selector added to chart-design.md." },
133
+ { title: "PRAXIST evaluation", path: "docs/praxist-evaluation.md", summary: "Scouting note (not vendored): sapientinc/PRAXIST, an autonomous measurable-research engine. Blocker — Fair Source License, and it optimizes a single number where most BADS research is qualitative. The loop shape (iterate-search-evaluate) is borrowed via the existing auto-research skill for the Night Shift weekly deep-dive (step 3a); the measurable-metric optimization lab is designed here but deferred." },
134
+ { title: "Deep-dive research questions", path: "docs/research-questions.md", summary: "Sir-curated queue for the Night Shift's weekly deep-dive (step 3a, Monday). The agent takes the top open question, runs the auto-research skill against it, and lands a report in ledgers/reports/. Empty queue is fine — the agent derives a question from recurring open ledger themes." },
135
+ { title: "HumanLayer skills evaluation", path: "docs/humanlayer-skills-evaluation.md", summary: "Scouting note (MIT — no adoption blocker): humanlayer/skills. design-control-loop's sensor/controller/actuator vocabulary maps 1:1 onto the Night Shift crew (borrowed as docs/control-loop.md); improve-claude-md's <important if> technique complements the de-blobbing (proposal filed); narrow-react-prop-types wired into Carl. build-iterated-agentic-loop + show-me skipped as redundant." },
136
+ { title: "jakubkrehel/skills evaluation", path: "docs/jakubkrehel-skills-evaluation.md", summary: "Scouting note (MIT, nothing adopted): a design-engineering skill collection on BADS's home turf — every dimension (UI, type, color, a11y, layout, writing) is already covered by BADS with enforcement (lints/tokens/contracts), not just review prompts. The one real borrow is the source, not a skill: Jakub Krehel's Interfaces magazine added to the Friday research rotation." },
137
+ { title: "HIGAgentSkills evaluation", path: "docs/hig-agent-skills-evaluation.md", summary: "Scouting note (content not vendored): justinwetch/HIGAgentSkills, a distilled Apple HIG corpus. Blockers — no license + Apple IP, web-vs-native mismatch, and BADS deliberately diverges from Apple. But its tiered routing-index architecture validates BADS's manifest approach and surfaces one real gap (a unified keyword→file lookup), filed as a proposal." },
130
138
  { title: "Token migration", path: "docs/token-migration.md", summary: "The pattern for renaming/restructuring tokens in a fork without a heroic all-at-once PR: a token-migration.json old→new mapping enforced diff-aware (changed files held to new names, legacy tolerated in untouched files) via pnpm check:token-migration, plus a copy-pasteable mapping table. Adapted from web-common." },
131
139
  { title: "Chart color palette", path: "docs/chart-color-palette.md", summary: "Accessible 5-color categorical palette for data viz — Okabe-Ito-derived, reviewed against WCAG 1.4.11 non-text contrast." },
132
140
  { title: "Chart design", path: "docs/chart-design.md", summary: "Chart composition rules — grid, axes, labels, legend, tooltip, number formatting, states, motion. The 'data is the only saturated thing' register; companion to the color palette." },
@@ -184,6 +192,9 @@ export const DOCS_INDEX: DocGroup[] = [
184
192
  { title: "Ledgers README", path: "ledgers/README.md" },
185
193
  { title: "Aggregator README", path: "aggregator/README.md" },
186
194
  { title: "CTO Builder dry-run", path: "docs/cto-builder-dry-run-2026-06-12.md" },
195
+ { title: "Control loops", path: "docs/control-loop.md", summary: "The shape every Night Shift crew member shares, named with HumanLayer's set point / sensor / controller / actuator vocabulary (MIT). A completeness table showing which loops are closed (auto-merge) and which are open by design (the trust audit + gate-coverage auditor stop at a recommendation — the loops that govern other loops shouldn't close on themselves), and the four questions any new crew member must answer." },
196
+ { title: "Proposal — <important if> for CLAUDE.md", path: "scripts/proposals/important-if-claude-md.md", summary: "Proposal (gated on Sir's go): apply HumanLayer's <important if> relevance blocks to the CLAUDE.md always-loaded floor, complementary to the manifest de-blobbing — externalize what you can, flag-when-relevant what must stay inline. Includes a worked before/after trial on the Charts section and an incremental, measure-first rollout." },
197
+ { title: "Proposal — unified routing index", path: "scripts/proposals/unified-routing-index.md", summary: "Proposal (gated on Sir's go): one generated keyword→file routing index over the three layer manifests, so an agent turns 'I'm about to do X' into the exact load set without hunting across manifests + CLAUDE.md prose. Derived from the manifests (never hand-maintained) with a drift check, mirroring build:tokens. Idea borrowed from HIGAgentSkills' routing-index; folds into the same de-blobbing as the <important if> proposal." },
187
198
  ],
188
199
  },
189
200
  {
@@ -211,6 +222,7 @@ export const DOCS_INDEX: DocGroup[] = [
211
222
  { title: "Spec — self-healing layer", path: "docs/specs/2026-08-21-self-healing-layer.md", summary: "Phase A contract: informational-only health score (Goodhart guard), no runtime telemetry, deterministic visible-copy intent rules, drift-ledger status convention, and the calibration record (6→0 false positives; two scoring bugs caught by face-checking)." },
212
223
  { title: "Plan — drift elimination", path: "docs/plans/2026-08-31-drift-elimination.md", summary: "Closing the loop between upstream, client forks, and prototype repos. Built on the one artifact every working template-sync tool shares: a committed record of which upstream version a downstream copy is layered on. Three phases ordered by risk — additive checks, then PR-gated fork sync, then the deferred structural calls." },
213
224
  { title: "Spec — drift elimination", path: "docs/specs/2026-08-31-drift-elimination.md", summary: "Phase A contract: precision over recall (unverifiable is never reported as drift), advisory-by-default with one blocking generated-artifact gate, additive-only sync manifest, and declared expected-drift allowlists. Calibration: 51→0 false positives on the registry checker, and real drift caught including llms.txt advertising 79 components when there were 173." },
225
+ { title: "Roadmap — ClosedLoop import candidates", path: "docs/roadmap-closedloop-import.md", summary: "Fourteen production patterns surfaced by auditing the closedloop-ai GitHub org (40 repos, 17 cloned, 2026-09-03). Three shipped immediately; the rest carry activation signals matching the standard roadmap format." },
214
226
  ],
215
227
  },
216
228
  ];
@@ -1,4 +1,10 @@
1
- import tokens from "../tokens.json";
1
+ // Relative "../tokens.json" resolves to upstream's own copy — indistinguishable
2
+ // from the alias inside this repo, but a fork's own tokens.json never gets read
3
+ // once published. "@/" is transpiled against the CONSUMER's tsconfig per the
4
+ // alias contract in CLIENT_ONBOARDING.md, so this reaches the fork's real
5
+ // tokens.json instead. See scripts/check-consumer-imports.mjs, which enforces
6
+ // this for every file under packages/core/src/.
7
+ import tokens from "@/packages/core/src/tokens.json";
2
8
  import { storageKey, readMigrated } from "@behavioral-agentic-design-system/core/lib/storage";
3
9
 
4
10
  // Both keys derive from the runtime slug so a renamed fork uses
@@ -14,7 +14,7 @@ import {
14
14
  // from comments and compiles them into invalid CSS that breaks the build.
15
15
 
16
16
  const meta: Meta<typeof Accordion> = {
17
- title: "Components/Accordion",
17
+ title: "Components/Layout/Accordion",
18
18
  component: Accordion,
19
19
  parameters: { layout: "centered" },
20
20
  tags: ["autodocs"],
@@ -86,6 +86,64 @@ export const Variant_Multiple: Story = {
86
86
  ),
87
87
  };
88
88
 
89
+ export const Variant_Contained: Story = {
90
+ render: () => (
91
+ <Accordion type="single" collapsible variant="contained" className="w-[400px]">
92
+ <AccordionItem value="item-1">
93
+ <AccordionTrigger>Workspace settings</AccordionTrigger>
94
+ <AccordionContent className="text-muted-foreground">
95
+ Configure your workspace name, slug, and time zone. Changes take
96
+ effect immediately for all members.
97
+ </AccordionContent>
98
+ </AccordionItem>
99
+ <AccordionItem value="item-2">
100
+ <AccordionTrigger>Billing and plan</AccordionTrigger>
101
+ <AccordionContent className="text-muted-foreground">
102
+ View your current plan, payment method, and invoices. Upgrade or
103
+ downgrade at any time — changes apply at the next billing cycle.
104
+ </AccordionContent>
105
+ </AccordionItem>
106
+ <AccordionItem value="item-3">
107
+ <AccordionTrigger>Notifications</AccordionTrigger>
108
+ <AccordionContent className="text-muted-foreground">
109
+ Control which events send an email or in-app notification to your
110
+ team. Per-member overrides are available in each member's profile.
111
+ </AccordionContent>
112
+ </AccordionItem>
113
+ </Accordion>
114
+ ),
115
+ };
116
+
117
+ export const Variant_Separated: Story = {
118
+ render: () => (
119
+ <Accordion type="single" collapsible variant="separated" className="w-[400px]">
120
+ <AccordionItem value="item-1">
121
+ <AccordionTrigger>What is BADS?</AccordionTrigger>
122
+ <AccordionContent className="text-muted-foreground">
123
+ BADS (Behavioral Agentic Design System) is a portable, distributable
124
+ design system built as the starting point for client engagements. It
125
+ ships tokens, components, ethics layers, and agent interfaces.
126
+ </AccordionContent>
127
+ </AccordionItem>
128
+ <AccordionItem value="item-2">
129
+ <AccordionTrigger>How do I customize tokens?</AccordionTrigger>
130
+ <AccordionContent className="text-muted-foreground">
131
+ Edit <code>tokens.json</code> and run{" "}
132
+ <code>pnpm build:tokens</code>. Both the published CSS and the local
133
+ preview regenerate automatically.
134
+ </AccordionContent>
135
+ </AccordionItem>
136
+ <AccordionItem value="item-3">
137
+ <AccordionTrigger>What accessibility standard does BADS target?</AccordionTrigger>
138
+ <AccordionContent className="text-muted-foreground">
139
+ BADS targets WCAG 2.2 AAA out of the box — 7:1 contrast for normal
140
+ text, 44 × 44 px touch targets, and reduced-motion respected.
141
+ </AccordionContent>
142
+ </AccordionItem>
143
+ </Accordion>
144
+ ),
145
+ };
146
+
89
147
  export const Disabled: Story = {
90
148
  render: () => (
91
149
  <Accordion type="single" collapsible className="w-[400px]">
@@ -7,7 +7,7 @@ import { Checkbox } from "@behavioral-agentic-design-system/core/components/ui/c
7
7
  import { Label } from "@behavioral-agentic-design-system/core/components/ui/label";
8
8
 
9
9
  const meta: Meta<typeof ActionBar> = {
10
- title: "Components/ActionBar",
10
+ title: "Components/Navigation/ActionBar",
11
11
  component: ActionBar,
12
12
  parameters: { layout: "fullscreen" },
13
13
  tags: ["autodocs"],
@@ -6,7 +6,7 @@ import { Button } from "@behavioral-agentic-design-system/core/components/ui/but
6
6
  import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge";
7
7
 
8
8
  const meta: Meta<typeof Affix> = {
9
- title: "Components/Affix",
9
+ title: "Components/Layout/Affix",
10
10
  component: Affix,
11
11
  parameters: {
12
12
  layout: "centered",
@@ -2,7 +2,7 @@ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { AiBadge } from "@behavioral-agentic-design-system/core/components/ui/ai-badge";
3
3
 
4
4
  const meta: Meta<typeof AiBadge> = {
5
- title: "Components/AiBadge",
5
+ title: "Components/Badges and avatars/AiBadge",
6
6
  component: AiBadge,
7
7
  parameters: { layout: "centered" },
8
8
  tags: ["autodocs"],