@behavioral-agentic-design-system/core 0.38.0 → 0.39.1

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 (187) hide show
  1. package/package.json +2 -2
  2. package/scripts/a11y-lint.cjs +47 -34
  3. package/scripts/a11y-ratchet.mjs +10 -23
  4. package/scripts/build-tokens.cjs +42 -5
  5. package/scripts/health-report.mjs +52 -10
  6. package/scripts/lib/scan-roots.cjs +143 -0
  7. package/scripts/lint-slop.mjs +21 -28
  8. package/scripts/lint-token-intent.mjs +10 -16
  9. package/scripts/size-audit.cjs +15 -27
  10. package/src/api/layers/file.ts +1 -0
  11. package/src/app/preview/components/page.tsx +366 -0
  12. package/src/app/preview/health/page.tsx +8 -5
  13. package/src/app/preview/history/page.tsx +11 -0
  14. package/src/app/shell.tsx +262 -86
  15. package/src/components/Foundations/Typography.stories.tsx +82 -21
  16. package/src/components/customize/discipline-section.tsx +94 -0
  17. package/src/components/customize-tab.tsx +2 -0
  18. package/src/components/ui/accordion.tsx +67 -5
  19. package/src/components/ui/alert.tsx +20 -7
  20. package/src/components/ui/avatar.tsx +18 -4
  21. package/src/components/ui/breadcrumb.tsx +47 -0
  22. package/src/components/ui/checkbox-card.tsx +48 -8
  23. package/src/components/ui/checkbox.tsx +17 -8
  24. package/src/components/ui/format-date.tsx +107 -0
  25. package/src/components/ui/progress.tsx +6 -5
  26. package/src/components/ui/sparkline.tsx +210 -0
  27. package/src/components/ui/tag.tsx +17 -1
  28. package/src/components/ui/tags-input.tsx +84 -11
  29. package/src/components/ui/toggle-group.tsx +13 -0
  30. package/src/components/ui/week-picker.tsx +463 -0
  31. package/src/data/docs-index.ts +11 -0
  32. package/src/data/history.json +269 -0
  33. package/src/stories/Accordion.stories.tsx +59 -1
  34. package/src/stories/ActionBar.stories.tsx +1 -1
  35. package/src/stories/Affix.stories.tsx +1 -1
  36. package/src/stories/AiBadge.stories.tsx +1 -1
  37. package/src/stories/Alert.stories.tsx +36 -1
  38. package/src/stories/AlertDialog.stories.tsx +1 -1
  39. package/src/stories/Anchor.stories.tsx +1 -1
  40. package/src/stories/AngleSlider.stories.tsx +1 -1
  41. package/src/stories/AspectRatio.stories.tsx +1 -1
  42. package/src/stories/Autocomplete.stories.tsx +1 -1
  43. package/src/stories/Avatar.stories.tsx +41 -1
  44. package/src/stories/Badge.stories.tsx +1 -1
  45. package/src/stories/Blockquote.stories.tsx +1 -1
  46. package/src/stories/BottomNavigation.stories.tsx +1 -1
  47. package/src/stories/Breadcrumb.stories.tsx +38 -5
  48. package/src/stories/Burger.stories.tsx +1 -1
  49. package/src/stories/Button.stories.tsx +9 -1
  50. package/src/stories/ButtonGroup.stories.tsx +1 -1
  51. package/src/stories/Calendar.stories.tsx +1 -1
  52. package/src/stories/Card.stories.tsx +1 -1
  53. package/src/stories/Carousel.stories.tsx +1 -1
  54. package/src/stories/Cascader.stories.tsx +1 -1
  55. package/src/stories/Chart.stories.tsx +1 -1
  56. package/src/stories/ChatBubble.stories.tsx +1 -1
  57. package/src/stories/ChatMarker.stories.tsx +1 -1
  58. package/src/stories/Checkbox.stories.tsx +36 -5
  59. package/src/stories/CheckboxCard.stories.tsx +37 -2
  60. package/src/stories/CheckboxGroup.stories.tsx +1 -1
  61. package/src/stories/Chip.stories.tsx +1 -1
  62. package/src/stories/CircularProgress.stories.tsx +17 -1
  63. package/src/stories/Clipboard.stories.tsx +1 -1
  64. package/src/stories/CloseButton.stories.tsx +1 -1
  65. package/src/stories/Code.stories.tsx +1 -1
  66. package/src/stories/Collapsible.stories.tsx +1 -1
  67. package/src/stories/ColorPicker.stories.tsx +1 -1
  68. package/src/stories/ColorSwatch.stories.tsx +1 -1
  69. package/src/stories/Combobox.stories.tsx +1 -1
  70. package/src/stories/Command.stories.tsx +1 -1
  71. package/src/stories/Container.stories.tsx +1 -1
  72. package/src/stories/ContextMenu.stories.tsx +1 -1
  73. package/src/stories/CopyButton.stories.tsx +9 -1
  74. package/src/stories/DataList.stories.tsx +1 -1
  75. package/src/stories/DataTable.stories.tsx +1 -1
  76. package/src/stories/DateField.stories.tsx +1 -1
  77. package/src/stories/DatePicker.stories.tsx +1 -1
  78. package/src/stories/DateRangePicker.stories.tsx +1 -1
  79. package/src/stories/Dialog.stories.tsx +1 -1
  80. package/src/stories/Drawer.stories.tsx +1 -1
  81. package/src/stories/DropdownMenu.stories.tsx +1 -1
  82. package/src/stories/Editable.stories.tsx +1 -1
  83. package/src/stories/EmptyState.stories.tsx +1 -1
  84. package/src/stories/Field.stories.tsx +1 -1
  85. package/src/stories/Fieldset.stories.tsx +1 -1
  86. package/src/stories/FileButton.stories.tsx +1 -1
  87. package/src/stories/FileUpload.stories.tsx +1 -1
  88. package/src/stories/FloatLabel.stories.tsx +1 -1
  89. package/src/stories/FloatingActionButton.stories.tsx +1 -1
  90. package/src/stories/FloatingIndicator.stories.tsx +1 -1
  91. package/src/stories/FloatingPanel.stories.tsx +9 -1
  92. package/src/stories/FocusTrap.stories.tsx +1 -1
  93. package/src/stories/FormatByte.stories.tsx +1 -1
  94. package/src/stories/FormatDate.stories.tsx +174 -0
  95. package/src/stories/FormatNumber.stories.tsx +1 -1
  96. package/src/stories/Highlight.stories.tsx +1 -1
  97. package/src/stories/HoverCard.stories.tsx +1 -1
  98. package/src/stories/Image.stories.tsx +1 -1
  99. package/src/stories/Indicator.stories.tsx +17 -1
  100. package/src/stories/Input.stories.tsx +1 -1
  101. package/src/stories/InputClearButton.stories.tsx +1 -1
  102. package/src/stories/InputGroup.stories.tsx +1 -1
  103. package/src/stories/Kbd.stories.tsx +1 -1
  104. package/src/stories/KeyboardShortcut.stories.tsx +1 -1
  105. package/src/stories/Label.stories.tsx +1 -1
  106. package/src/stories/Link.stories.tsx +1 -1
  107. package/src/stories/List.stories.tsx +1 -1
  108. package/src/stories/Listbox.stories.tsx +1 -1
  109. package/src/stories/LoadingDots.stories.tsx +1 -1
  110. package/src/stories/LoadingOverlay.stories.tsx +1 -1
  111. package/src/stories/Mark.stories.tsx +1 -1
  112. package/src/stories/Marquee.stories.tsx +1 -1
  113. package/src/stories/Masonry.stories.tsx +1 -1
  114. package/src/stories/Menubar.stories.tsx +1 -1
  115. package/src/stories/Meter.stories.tsx +1 -1
  116. package/src/stories/MonthPicker.stories.tsx +1 -1
  117. package/src/stories/MotionToggle.stories.tsx +1 -1
  118. package/src/stories/MultiSelect.stories.tsx +1 -1
  119. package/src/stories/NativeSelect.stories.tsx +1 -1
  120. package/src/stories/NavLink.stories.tsx +1 -1
  121. package/src/stories/NavigationMenu.stories.tsx +1 -1
  122. package/src/stories/NavigationRail.stories.tsx +9 -1
  123. package/src/stories/Notification.stories.tsx +1 -1
  124. package/src/stories/NumberInput.stories.tsx +1 -1
  125. package/src/stories/Overlay.stories.tsx +1 -1
  126. package/src/stories/Pagination.stories.tsx +1 -1
  127. package/src/stories/PasswordInput.stories.tsx +1 -1
  128. package/src/stories/PinInput.stories.tsx +1 -1
  129. package/src/stories/Popover.stories.tsx +1 -1
  130. package/src/stories/Progress.stories.tsx +11 -1
  131. package/src/stories/Prose.stories.tsx +1 -1
  132. package/src/stories/QrCode.stories.tsx +1 -1
  133. package/src/stories/Questionnaire.stories.tsx +1 -1
  134. package/src/stories/RadioGroup.stories.tsx +1 -1
  135. package/src/stories/RatingGroup.stories.tsx +1 -1
  136. package/src/stories/Resizable.stories.tsx +1 -1
  137. package/src/stories/Result.stories.tsx +1 -1
  138. package/src/stories/Reveal.stories.tsx +1 -1
  139. package/src/stories/RollingNumber.stories.tsx +1 -1
  140. package/src/stories/ScrollArea.stories.tsx +1 -1
  141. package/src/stories/SearchInput.stories.tsx +1 -1
  142. package/src/stories/SegmentedControl.stories.tsx +1 -1
  143. package/src/stories/Select.stories.tsx +1 -1
  144. package/src/stories/Separator.stories.tsx +1 -1
  145. package/src/stories/Sheet.stories.tsx +10 -4
  146. package/src/stories/Sidebar.stories.tsx +1 -1
  147. package/src/stories/SignaturePad.stories.tsx +1 -1
  148. package/src/stories/SimpleGrid.stories.tsx +1 -1
  149. package/src/stories/Skeleton.stories.tsx +1 -1
  150. package/src/stories/SkeletonTable.stories.tsx +1 -1
  151. package/src/stories/SkipLink.stories.tsx +1 -1
  152. package/src/stories/Slider.stories.tsx +1 -1
  153. package/src/stories/Sonner.stories.tsx +1 -1
  154. package/src/stories/Sparkline.stories.tsx +244 -0
  155. package/src/stories/Spinner.stories.tsx +9 -1
  156. package/src/stories/Spoiler.stories.tsx +1 -1
  157. package/src/stories/Squircle.stories.tsx +1 -1
  158. package/src/stories/Stack.stories.tsx +1 -1
  159. package/src/stories/StatusBadge.stories.tsx +1 -1
  160. package/src/stories/Stepper.stories.tsx +1 -1
  161. package/src/stories/Switch.stories.tsx +1 -1
  162. package/src/stories/Table.stories.tsx +1 -1
  163. package/src/stories/Tabs.stories.tsx +1 -1
  164. package/src/stories/Tag.stories.tsx +23 -1
  165. package/src/stories/TagsInput.stories.tsx +46 -1
  166. package/src/stories/Text.stories.tsx +1 -1
  167. package/src/stories/Textarea.stories.tsx +1 -1
  168. package/src/stories/ThemeIcon.stories.tsx +1 -1
  169. package/src/stories/TimePicker.stories.tsx +1 -1
  170. package/src/stories/Timeline.stories.tsx +9 -1
  171. package/src/stories/Timer.stories.tsx +1 -1
  172. package/src/stories/Toggle.stories.tsx +1 -1
  173. package/src/stories/ToggleGroup.stories.tsx +21 -1
  174. package/src/stories/ToggleTip.stories.tsx +1 -1
  175. package/src/stories/Toolbar.stories.tsx +1 -1
  176. package/src/stories/Tooltip.stories.tsx +1 -1
  177. package/src/stories/Tour.stories.tsx +1 -1
  178. package/src/stories/TransferList.stories.tsx +1 -1
  179. package/src/stories/TreeSelect.stories.tsx +1 -1
  180. package/src/stories/TreeView.stories.tsx +1 -1
  181. package/src/stories/TypingIndicator.stories.tsx +1 -1
  182. package/src/stories/VisuallyHidden.stories.tsx +1 -1
  183. package/src/stories/Watermark.stories.tsx +1 -1
  184. package/src/stories/WeekPicker.stories.tsx +90 -0
  185. package/src/stories/WordRotate.stories.tsx +1 -1
  186. package/src/stories/YearPicker.stories.tsx +1 -1
  187. 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 }
@@ -90,7 +90,9 @@ export const DOCS_INDEX: DocGroup[] = [
90
90
  { title: "Night Shift spec", path: "CIRCADIAN.md", summary: "The overnight agent: what it audits, researches, builds, tests, merges, and reports each night." },
91
91
  { title: "Night Shift prompt", path: "scripts/prompts/night-shift.md", summary: "The full nightly research + auto-PR pass." },
92
92
  { title: "Agent roadmap", path: "docs/agent-roadmap.md" },
93
+ { title: "Disciplines — product vs marketing", path: "disciplines/README.md", summary: "The discipline axis: one fork serves both product and marketing work on a shared spine, and a four-signal router (explicit \u2192 route \u2192 classify \u2192 default) decides which rule tree loads. The three spine manifests load for every discipline because the accessibility and ethics floors are discipline-neutral. Promoted upstream 2026-09-09 from the ohmyaura fork when a second client needed it." },
93
94
  { title: "Intent-driven context", path: "docs/intent-driven-context.md", summary: "Constraint vs guideline vs framing vs workflow — and what delivery each demands." },
95
+ { title: "Social sources bench", path: "docs/social-sources.md", summary: "Sir-curated bench of practitioner accounts (X, LinkedIn, Reddit, Medium, Bluesky/Mastodon) the Night Shift's social signal sweep checks — so it reads known-good signal, not the firehose. Carries the lowest-trust-tier rules (a social post alone is never an actionable finding) and the ToS boundaries (search-driven, never logged-in scraping; LinkedIn read-through-search only)." },
94
96
  ],
95
97
  },
96
98
  {
@@ -132,6 +134,9 @@ export const DOCS_INDEX: DocGroup[] = [
132
134
  { 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
135
  { 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
136
  { 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." },
137
+ { 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." },
138
+ { 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." },
139
+ { 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." },
135
140
  { 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." },
136
141
  { 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." },
137
142
  { 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." },
@@ -189,6 +194,9 @@ export const DOCS_INDEX: DocGroup[] = [
189
194
  { title: "Ledgers README", path: "ledgers/README.md" },
190
195
  { title: "Aggregator README", path: "aggregator/README.md" },
191
196
  { title: "CTO Builder dry-run", path: "docs/cto-builder-dry-run-2026-06-12.md" },
197
+ { 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." },
198
+ { 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." },
199
+ { 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." },
192
200
  ],
193
201
  },
194
202
  {
@@ -216,6 +224,9 @@ export const DOCS_INDEX: DocGroup[] = [
216
224
  { 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)." },
217
225
  { 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." },
218
226
  { 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." },
227
+ { title: "Plan — Best-of-N", path: "docs/plans/2026-09-10-best-of-n.md", summary: "Run one judgment N times and treat disagreement as the signal. Two uses: a three-verifier unanimity panel before Code Review Carl can force-merge a fix, and an eval agreement score that finds the rules repeated runs resolve differently. Rejects a merge agent and majority vote for the gate, and says why." },
228
+ { title: "Spec — Best-of-N", path: "docs/specs/2026-09-10-best-of-n.md", summary: "The contract for scripts/verifier-panel.mjs (unanimous, fail-closed, distinct lenses, evidence-backed approvals) and scripts/eval-agreement.mjs (check stability, primitive choice, import path, drift rows only from the with-context arm). Records the first measurement: a skill rule sending agents to the package root, 3 of 15 before the fix and 0 of 15 after." },
229
+ { 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." },
219
230
  ],
220
231
  },
221
232
  ];