@behavioral-agentic-design-system/core 0.40.0 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/README.md +2 -0
  2. package/package.json +41 -9
  3. package/scripts/a11y-lint.cjs +66 -3
  4. package/scripts/check-spec.mjs +73 -0
  5. package/scripts/deal-directions.mjs +186 -0
  6. package/scripts/health-report.mjs +23 -3
  7. package/scripts/lib/counted-lint.mjs +100 -0
  8. package/scripts/lib/marketing-library.mjs +129 -0
  9. package/scripts/lib/on-system.mjs +249 -0
  10. package/scripts/lib/random.mjs +22 -0
  11. package/scripts/lib/spec-parse.d.mts +25 -0
  12. package/scripts/lib/spec-parse.mjs +188 -0
  13. package/scripts/lib/tells.mjs +128 -0
  14. package/scripts/lint-css-vars.mjs +175 -0
  15. package/scripts/lint-html-nesting.mjs +116 -0
  16. package/scripts/lint-live-ctas.mjs +138 -0
  17. package/scripts/lint-slop.mjs +25 -1
  18. package/scripts/on-system-score.mjs +95 -0
  19. package/scripts/slop-rules.mjs +1 -1
  20. package/scripts/source-images.mjs +180 -0
  21. package/scripts/ux-tells.mjs +78 -0
  22. package/scripts/wcag-audit.cjs +72 -5
  23. package/src/api/brand-colors.ts +3 -0
  24. package/src/api/brand-fonts.ts +3 -0
  25. package/src/api/brand-mark.ts +6 -1
  26. package/src/api/dev-write-guard.ts +53 -0
  27. package/src/api/layers/file.ts +7 -4
  28. package/src/api/onboarding-extract.ts +85 -30
  29. package/src/api/onboarding.ts +3 -0
  30. package/src/api/save-tokens.ts +3 -0
  31. package/src/app/layout.tsx +6 -0
  32. package/src/app/opengraph-image.tsx +5 -0
  33. package/src/app/preview/canvas/page.tsx +12 -0
  34. package/src/app/preview/components/page.tsx +2003 -2
  35. package/src/app/preview/studio/blank-screen.tsx +143 -0
  36. package/src/app/preview/studio/page.tsx +7 -0
  37. package/src/app/shell.tsx +168 -49
  38. package/src/components/Foundations/Motion.stories.tsx +1 -0
  39. package/src/components/canvas/canvas.tsx +458 -0
  40. package/src/components/canvas/layout.ts +72 -0
  41. package/src/components/canvas/parse-canvas.ts +32 -0
  42. package/src/components/canvas/sample.ts +90 -0
  43. package/src/components/canvas/spec-frame.tsx +43 -0
  44. package/src/components/canvas/types.ts +33 -0
  45. package/src/components/customize/design-controls.tsx +16 -1
  46. package/src/components/docs-tab.tsx +7 -7
  47. package/src/components/home-recent.tsx +73 -0
  48. package/src/components/home-tab.tsx +13 -13
  49. package/src/components/layers-tab.tsx +2 -2
  50. package/src/components/markdown-preview.tsx +60 -12
  51. package/src/components/studio/control-panel.tsx +299 -0
  52. package/src/components/studio/control-row.tsx +77 -0
  53. package/src/components/studio/preview-frame.tsx +165 -0
  54. package/src/components/studio/preview-pane.tsx +247 -0
  55. package/src/components/studio/studio.tsx +158 -0
  56. package/src/components/studio/types.ts +218 -0
  57. package/src/components/studio/use-studio-tweaks.ts +128 -0
  58. package/src/components/studio/use-studio-view-state.ts +72 -0
  59. package/src/components/ui/anchor.tsx +37 -3
  60. package/src/components/ui/attachment.tsx +211 -0
  61. package/src/components/ui/autocomplete.tsx +1 -1
  62. package/src/components/ui/chart.tsx +3 -0
  63. package/src/components/ui/code.tsx +1 -1
  64. package/src/components/ui/color-picker.tsx +21 -5
  65. package/src/components/ui/data-table.tsx +64 -3
  66. package/src/components/ui/date-field.tsx +1 -1
  67. package/src/components/ui/editable.tsx +1 -0
  68. package/src/components/ui/faceted-filter.tsx +187 -0
  69. package/src/components/ui/gauge-chart.tsx +252 -0
  70. package/src/components/ui/heatmap.tsx +256 -0
  71. package/src/components/ui/index.ts +9 -0
  72. package/src/components/ui/infinite-scroll.tsx +103 -0
  73. package/src/components/ui/inline-edit.tsx +175 -0
  74. package/src/components/ui/json-input.tsx +351 -0
  75. package/src/components/ui/month-picker.tsx +1 -1
  76. package/src/components/ui/navigation-progress.tsx +281 -0
  77. package/src/components/ui/number-input.tsx +27 -7
  78. package/src/components/ui/otp-input.tsx +208 -0
  79. package/src/components/ui/password-input.tsx +2 -1
  80. package/src/components/ui/password-strength-input.tsx +288 -0
  81. package/src/components/ui/phone-input.tsx +274 -0
  82. package/src/components/ui/pill.tsx +140 -0
  83. package/src/components/ui/popover.tsx +27 -4
  84. package/src/components/ui/scroll-progress.tsx +100 -0
  85. package/src/components/ui/search-input.tsx +1 -1
  86. package/src/components/ui/snackbar.tsx +393 -0
  87. package/src/components/ui/sortable-list.tsx +342 -0
  88. package/src/components/ui/squircle.tsx +1 -1
  89. package/src/components/ui/table.tsx +1 -1
  90. package/src/components/ui/tags-input.tsx +1 -1
  91. package/src/components/ui/timer.tsx +1 -0
  92. package/src/components/ui/tour.tsx +1 -3
  93. package/src/components/ui/transfer-list.tsx +13 -26
  94. package/src/components/ui/week-picker.tsx +1 -1
  95. package/src/components/ui/year-picker.tsx +1 -1
  96. package/src/data/component-added.json +958 -0
  97. package/src/data/docs-index.ts +36 -0
  98. package/src/hooks/use-global-mono-font.ts +1 -0
  99. package/src/hooks/use-global-primary-color.ts +1 -0
  100. package/src/hooks/use-global-sans-font.ts +1 -0
  101. package/src/hooks/use-global-serif-font.ts +1 -0
  102. package/src/hooks/use-global-type-scale.ts +17 -2
  103. package/src/hooks/use-mobile.ts +2 -0
  104. package/src/hooks/use-sync-type-scale.ts +7 -11
  105. package/src/lib/clamp.ts +2 -0
  106. package/src/lib/spec-parse.ts +4 -0
  107. package/src/lib/svg-sanitize.ts +19 -9
  108. package/src/stories/Anchor.stories.tsx +54 -0
  109. package/src/stories/Attachment.stories.tsx +189 -0
  110. package/src/stories/Autocomplete.stories.tsx +2 -0
  111. package/src/stories/Canvas.stories.tsx +45 -0
  112. package/src/stories/Chart.stories.tsx +4 -0
  113. package/src/stories/Code.stories.tsx +1 -0
  114. package/src/stories/ColorPicker.stories.tsx +41 -0
  115. package/src/stories/DataTable.stories.tsx +30 -0
  116. package/src/stories/DateField.stories.tsx +21 -0
  117. package/src/stories/Editable.stories.tsx +2 -0
  118. package/src/stories/FacetedFilter.stories.tsx +197 -0
  119. package/src/stories/GaugeChart.stories.tsx +169 -0
  120. package/src/stories/Heatmap.stories.tsx +172 -0
  121. package/src/stories/InfiniteScroll.stories.tsx +225 -0
  122. package/src/stories/InlineEdit.stories.tsx +106 -0
  123. package/src/stories/JsonInput.stories.tsx +212 -0
  124. package/src/stories/MarkdownPreview.stories.tsx +53 -0
  125. package/src/stories/MonthPicker.stories.tsx +21 -0
  126. package/src/stories/NavigationProgress.stories.tsx +159 -0
  127. package/src/stories/NumberInput.stories.tsx +26 -0
  128. package/src/stories/OtpInput.stories.tsx +110 -0
  129. package/src/stories/PasswordInput.stories.tsx +4 -0
  130. package/src/stories/PasswordStrengthInput.stories.tsx +211 -0
  131. package/src/stories/PhoneInput.stories.tsx +127 -0
  132. package/src/stories/Pill.stories.tsx +201 -0
  133. package/src/stories/Popover.stories.tsx +29 -1
  134. package/src/stories/Portal.stories.tsx +3 -1
  135. package/src/stories/ScrollProgress.stories.tsx +117 -0
  136. package/src/stories/SearchInput.stories.tsx +2 -0
  137. package/src/stories/Snackbar.stories.tsx +315 -0
  138. package/src/stories/SortableList.stories.tsx +263 -0
  139. package/src/stories/Squircle.stories.tsx +1 -0
  140. package/src/stories/Table.stories.tsx +1 -0
  141. package/src/stories/TagsInput.stories.tsx +2 -0
  142. package/src/stories/Timer.stories.tsx +26 -0
  143. package/src/stories/Tour.stories.tsx +1 -0
  144. package/src/stories/TransferList.stories.tsx +4 -0
  145. package/src/stories/WeekPicker.stories.tsx +21 -0
  146. package/src/stories/YearPicker.stories.tsx +21 -0
  147. package/src/stories/story-groups.json +33 -16
  148. package/src/tokens.json +82 -54
@@ -0,0 +1,342 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import {
5
+ DndContext,
6
+ closestCenter,
7
+ KeyboardSensor,
8
+ PointerSensor,
9
+ useSensor,
10
+ useSensors,
11
+ DragEndEvent,
12
+ DragStartEvent,
13
+ DragOverlay,
14
+ UniqueIdentifier,
15
+ } from "@dnd-kit/core";
16
+ import {
17
+ arrayMove,
18
+ SortableContext,
19
+ sortableKeyboardCoordinates,
20
+ useSortable,
21
+ verticalListSortingStrategy,
22
+ horizontalListSortingStrategy,
23
+ } from "@dnd-kit/sortable";
24
+ import { CSS } from "@dnd-kit/utilities";
25
+ import { cva, type VariantProps } from "class-variance-authority";
26
+ import { GripVertical, GripHorizontal } from "lucide-react";
27
+ import { cn } from "../../lib/utils";
28
+
29
+ /**
30
+ * Drag-and-drop reorderable list.
31
+ *
32
+ * Uses @dnd-kit/core + @dnd-kit/sortable for pointer and keyboard drag.
33
+ * Fully accessible: keyboard sensor handles Space/Enter to lift, arrow keys
34
+ * to move, and Space/Enter/Escape to drop/cancel. Screen-reader announcements
35
+ * are generated by dnd-kit's built-in accessibility provider.
36
+ *
37
+ * Items must have a stable `id` string or number. Order state is managed by
38
+ * the parent — provide `items` + `onReorder` for controlled use.
39
+ *
40
+ * @example
41
+ * // Controlled vertical list
42
+ * const [items, setItems] = React.useState(initialItems)
43
+ * <SortableList items={items} onReorder={setItems} renderItem={(item) => item.label} />
44
+ *
45
+ * @example
46
+ * // Without drag handle (whole row is draggable)
47
+ * <SortableList items={items} onReorder={setItems} handle={false} renderItem={(item) => item.label} />
48
+ */
49
+
50
+ // ── Variants ──────────────────────────────────────────────────────────────────
51
+
52
+ const sortableListVariants = cva("flex w-full", {
53
+ variants: {
54
+ orientation: {
55
+ vertical: "flex-col",
56
+ horizontal: "flex-row flex-wrap",
57
+ },
58
+ size: {
59
+ sm: "gap-1",
60
+ default: "gap-2",
61
+ lg: "gap-3",
62
+ },
63
+ },
64
+ defaultVariants: {
65
+ orientation: "vertical",
66
+ size: "default",
67
+ },
68
+ });
69
+
70
+ const sortableItemVariants = cva(
71
+ [
72
+ "group flex items-center rounded-md border border-border bg-card text-card-foreground",
73
+ "outline-hidden ring-ring focus-visible:ring-2 focus-visible:ring-offset-2",
74
+ "select-none touch-none",
75
+ ].join(" "),
76
+ {
77
+ variants: {
78
+ size: {
79
+ sm: "gap-2 px-2 py-1.5 text-sm",
80
+ default: "gap-3 px-3 py-2.5 text-sm",
81
+ lg: "gap-3 px-4 py-3 text-base",
82
+ },
83
+ isDragging: {
84
+ true: "opacity-50",
85
+ false: "",
86
+ },
87
+ },
88
+ defaultVariants: {
89
+ size: "default",
90
+ isDragging: false,
91
+ },
92
+ },
93
+ );
94
+
95
+ // ── Types ─────────────────────────────────────────────────────────────────────
96
+
97
+ export interface SortableItem {
98
+ id: UniqueIdentifier;
99
+ [key: string]: unknown;
100
+ }
101
+
102
+ export interface SortableListProps<T extends SortableItem>
103
+ extends VariantProps<typeof sortableListVariants> {
104
+ /** The ordered list of items. Each item must have a stable `id`. */
105
+ items: T[];
106
+ /** Called after a drag-drop reorder with the new item order. */
107
+ onReorder: (newItems: T[]) => void;
108
+ /** Render function for each item's content. */
109
+ renderItem: (item: T, index: number) => React.ReactNode;
110
+ /** Show a drag-handle icon (default: true). When false, the whole row drags. */
111
+ handle?: boolean;
112
+ /** Disables all drag interactions. */
113
+ disabled?: boolean;
114
+ /** Extra classes on the list wrapper. */
115
+ className?: string;
116
+ /** A11y: label for the sortable list (read by screen readers). */
117
+ "aria-label"?: string;
118
+ }
119
+
120
+ // ── SortableItem (inner) ──────────────────────────────────────────────────────
121
+
122
+ interface SortableItemInnerProps {
123
+ id: UniqueIdentifier;
124
+ children: React.ReactNode;
125
+ size: "sm" | "default" | "lg";
126
+ handle: boolean;
127
+ disabled: boolean;
128
+ orientation: "vertical" | "horizontal";
129
+ isOverlay?: boolean;
130
+ }
131
+
132
+ function SortableItemInner({
133
+ id,
134
+ children,
135
+ size,
136
+ handle,
137
+ disabled,
138
+ isOverlay = false,
139
+ }: SortableItemInnerProps) {
140
+ const {
141
+ attributes,
142
+ listeners,
143
+ setNodeRef,
144
+ setActivatorNodeRef,
145
+ transform,
146
+ transition,
147
+ isDragging,
148
+ } = useSortable({ id, disabled });
149
+
150
+ const style: React.CSSProperties = {
151
+ transform: CSS.Transform.toString(transform),
152
+ transition,
153
+ // Overlay is rendered separately via DragOverlay; the source gets opacity:50
154
+ };
155
+
156
+ const HandleIcon = size === "lg" ? GripVertical : GripVertical;
157
+
158
+ // When handle=false the whole row acts as the drag activator
159
+ const rowListeners = handle ? {} : listeners;
160
+ const rowAttributes = handle ? {} : attributes;
161
+
162
+ return (
163
+ <div
164
+ ref={setNodeRef}
165
+ style={style}
166
+ className={sortableItemVariants({
167
+ size,
168
+ isDragging: isDragging && !isOverlay,
169
+ })}
170
+ {...rowAttributes}
171
+ {...rowListeners}
172
+ >
173
+ {handle && !disabled && (
174
+ <button
175
+ ref={setActivatorNodeRef}
176
+ type="button"
177
+ aria-label="Drag to reorder"
178
+ className={cn(
179
+ "shrink-0 cursor-grab rounded text-muted-foreground",
180
+ "active:cursor-grabbing",
181
+ "focus-visible:ring-ring outline-hidden focus-visible:ring-2 focus-visible:ring-offset-1",
182
+ "transition-colors",
183
+ "hover:text-foreground",
184
+ )}
185
+ style={{
186
+ transitionDuration: "var(--duration-fast)",
187
+ transitionTimingFunction: "var(--ease-out)",
188
+ }}
189
+ {...attributes}
190
+ {...listeners}
191
+ >
192
+ {size === "sm" ? (
193
+ <HandleIcon
194
+ className="size-3.5"
195
+ strokeWidth={1.5}
196
+ aria-hidden="true"
197
+ />
198
+ ) : size === "lg" ? (
199
+ <HandleIcon
200
+ className="size-5"
201
+ strokeWidth={1.5}
202
+ aria-hidden="true"
203
+ />
204
+ ) : (
205
+ <HandleIcon
206
+ className="size-4"
207
+ strokeWidth={1.5}
208
+ aria-hidden="true"
209
+ />
210
+ )}
211
+ </button>
212
+ )}
213
+ <div className="min-w-0 flex-1">{children}</div>
214
+ </div>
215
+ );
216
+ }
217
+
218
+ // ── SortableList ──────────────────────────────────────────────────────────────
219
+
220
+ function SortableListInner<T extends SortableItem>(
221
+ {
222
+ items,
223
+ onReorder,
224
+ renderItem,
225
+ handle = true,
226
+ disabled = false,
227
+ orientation = "vertical",
228
+ size = "default",
229
+ className,
230
+ "aria-label": ariaLabel,
231
+ }: SortableListProps<T>,
232
+ ref: React.Ref<HTMLDivElement>,
233
+ ) {
234
+ const [activeId, setActiveId] = React.useState<UniqueIdentifier | null>(null);
235
+
236
+ const sensors = useSensors(
237
+ useSensor(PointerSensor, {
238
+ activationConstraint: { distance: 4 },
239
+ }),
240
+ useSensor(KeyboardSensor, {
241
+ coordinateGetter: sortableKeyboardCoordinates,
242
+ }),
243
+ );
244
+
245
+ const strategy =
246
+ orientation === "horizontal"
247
+ ? horizontalListSortingStrategy
248
+ : verticalListSortingStrategy;
249
+
250
+ function handleDragStart({ active }: DragStartEvent) {
251
+ setActiveId(active.id);
252
+ }
253
+
254
+ function handleDragEnd({ active, over }: DragEndEvent) {
255
+ setActiveId(null);
256
+ if (!over || active.id === over.id) return;
257
+ const oldIndex = items.findIndex((item) => item.id === active.id);
258
+ const newIndex = items.findIndex((item) => item.id === over.id);
259
+ if (oldIndex !== -1 && newIndex !== -1) {
260
+ onReorder(arrayMove(items, oldIndex, newIndex));
261
+ }
262
+ }
263
+
264
+ function handleDragCancel() {
265
+ setActiveId(null);
266
+ }
267
+
268
+ const activeItem = activeId != null
269
+ ? items.find((item) => item.id === activeId) ?? null
270
+ : null;
271
+ const activeIndex = activeItem
272
+ ? items.findIndex((item) => item.id === activeId)
273
+ : -1;
274
+
275
+ return (
276
+ <DndContext
277
+ sensors={sensors}
278
+ collisionDetection={closestCenter}
279
+ onDragStart={handleDragStart}
280
+ onDragEnd={handleDragEnd}
281
+ onDragCancel={handleDragCancel}
282
+ >
283
+ <SortableContext items={items.map((i) => i.id)} strategy={strategy}>
284
+ <div
285
+ ref={ref}
286
+ role="list"
287
+ aria-label={ariaLabel}
288
+ className={cn(sortableListVariants({ orientation, size }), className)}
289
+ >
290
+ {items.map((item, index) => (
291
+ <div key={item.id} role="listitem">
292
+ <SortableItemInner
293
+ id={item.id}
294
+ size={size ?? "default"}
295
+ handle={handle}
296
+ disabled={disabled}
297
+ orientation={orientation ?? "vertical"}
298
+ >
299
+ {renderItem(item, index)}
300
+ </SortableItemInner>
301
+ </div>
302
+ ))}
303
+ </div>
304
+ </SortableContext>
305
+
306
+ {/* Drag overlay — renders the "floating" item while dragging */}
307
+ <DragOverlay>
308
+ {activeItem ? (
309
+ <div
310
+ style={{
311
+ opacity: 1,
312
+ transitionDuration: "var(--duration-fast)",
313
+ transitionTimingFunction: "var(--ease-out)",
314
+ boxShadow:
315
+ "0 4px 16px -4px rgb(0 0 0 / 0.16), 0 1px 4px -1px rgb(0 0 0 / 0.08)",
316
+ }}
317
+ >
318
+ <SortableItemInner
319
+ id={activeItem.id}
320
+ size={size ?? "default"}
321
+ handle={handle}
322
+ disabled={false}
323
+ orientation={orientation ?? "vertical"}
324
+ isOverlay
325
+ >
326
+ {renderItem(activeItem, activeIndex)}
327
+ </SortableItemInner>
328
+ </div>
329
+ ) : null}
330
+ </DragOverlay>
331
+ </DndContext>
332
+ );
333
+ }
334
+
335
+ // Use generic forwardRef workaround (TypeScript limitation with generics + forwardRef)
336
+ const SortableList = React.forwardRef(SortableListInner) as <
337
+ T extends SortableItem,
338
+ >(
339
+ props: SortableListProps<T> & { ref?: React.Ref<HTMLDivElement> },
340
+ ) => React.ReactElement;
341
+
342
+ export { SortableList };
@@ -3,6 +3,7 @@
3
3
  import * as React from "react"
4
4
 
5
5
  import { cn } from "../../lib/utils"
6
+ import { clamp } from "../../lib/clamp"
6
7
 
7
8
  /* -------------------------------------------------------------------------------------------------
8
9
  * Superellipse path math — Figma's corner-smoothing model
@@ -21,7 +22,6 @@ const toRadians = (deg: number) => (deg * Math.PI) / 180
21
22
  /** Trim float noise so identical sizes produce identical cache keys / paths. */
22
23
  const n = (v: number) => Number(v.toFixed(4))
23
24
 
24
- const clamp = (v: number, min: number, max: number) => Math.min(max, Math.max(min, v))
25
25
 
26
26
  interface CornerParams {
27
27
  a: number
@@ -35,7 +35,7 @@ function Table({ className, wrapperClassName, wrapperStyle, striped = false, bor
35
35
  <TableVariantContext.Provider value={variants}>
36
36
  <div data-slot="table-container" tabIndex={0}
37
37
  className={cn(
38
- "relative w-full overflow-x-auto scrollbar-thin scrollbar-thumb-border scrollbar-track-transparent",
38
+ "relative w-full overflow-x-auto [scrollbar-width:thin] [scrollbar-color:theme(colors.border)_transparent]",
39
39
  bordered && "rounded-md border",
40
40
  wrapperClassName
41
41
  )}
@@ -197,7 +197,7 @@ export function TagsInput({
197
197
  setActiveIndex((i) => (i <= 0 ? 0 : i - 1));
198
198
  return;
199
199
  }
200
- if (e.key === "Enter") {
200
+ if (e.key === "Enter" && !e.nativeEvent.isComposing) {
201
201
  e.preventDefault();
202
202
  if (isOpen && activeIndex >= 0) {
203
203
  selectSuggestion(filteredSuggestions[activeIndex]);
@@ -172,6 +172,7 @@ function Timer({
172
172
  {/* Entering the DOM on completion triggers exactly one polite
173
173
  announcement — the only tick worth interrupting for. */}
174
174
  {completed && (
175
+ // allow-conditional-aria-live intentional one-shot completion announce — mounting triggers a single polite read and the region then leaves the DOM
175
176
  <span data-slot="timer-announcement" role="status" className="sr-only">
176
177
  {completeAnnouncement}
177
178
  </span>
@@ -5,6 +5,7 @@ import * as DialogPrimitive from "@radix-ui/react-dialog"
5
5
  import { XIcon } from "lucide-react"
6
6
 
7
7
  import { cn } from "../../lib/utils"
8
+ import { clamp } from "../../lib/clamp"
8
9
  import { usePortalThemeClass } from "../../hooks/use-portal-theme-class"
9
10
  import { Button } from "./button"
10
11
 
@@ -88,9 +89,6 @@ function measureTarget(selector: string | null | undefined): TargetRect | null {
88
89
  return { top: r.top, left: r.left, width: r.width, height: r.height }
89
90
  }
90
91
 
91
- function clamp(value: number, min: number, max: number) {
92
- return Math.min(Math.max(value, min), Math.max(min, max))
93
- }
94
92
 
95
93
  function computePanelPosition(
96
94
  target: TargetRect,
@@ -11,6 +11,7 @@ import {
11
11
  import { cn } from "../../lib/utils"
12
12
  import { Button } from "../ui/button"
13
13
  import { Badge } from "../ui/badge"
14
+ import { Checkbox } from "../ui/checkbox"
14
15
  import { Input } from "../ui/input"
15
16
 
16
17
  // ────────────────────────────────────────────────────────────────────────────
@@ -154,32 +155,18 @@ function Panel({ label, items, checked, onToggle, searchable }: PanelProps) {
154
155
  transitionTimingFunction: "var(--ease-out)",
155
156
  }}
156
157
  >
157
- {/* Visual checkbox indicator */}
158
- <span
159
- aria-hidden="true"
160
- className={cn(
161
- "inline-flex shrink-0 size-4 items-center justify-center rounded-sm border",
162
- isChecked
163
- ? "border-primary bg-primary text-primary-foreground"
164
- : "border-muted-foreground/60 bg-background"
165
- )}
166
- >
167
- {isChecked && (
168
- <svg
169
- width="10"
170
- height="8"
171
- viewBox="0 0 10 8"
172
- fill="none"
173
- stroke="currentColor"
174
- strokeWidth="1.5"
175
- strokeLinecap="round"
176
- strokeLinejoin="round"
177
- aria-hidden="true"
178
- >
179
- <polyline points="1 4 3.5 6.5 9 1" />
180
- </svg>
181
- )}
182
- </span>
158
+ {/* Decorative, not the real control: the <li role="option"> above already
159
+ handles the click/toggle. A second focusable checkbox nested in the
160
+ same row would double the controls a screen reader announces for one
161
+ choice — tabIndex, pointer-events, and aria-hidden are what make the
162
+ real Checkbox primitive safe to use purely as a visual here. */}
163
+ <Checkbox
164
+ size="sm"
165
+ checked={isChecked}
166
+ tabIndex={-1}
167
+ aria-hidden
168
+ className="pointer-events-none"
169
+ />
183
170
  <span className="min-w-0 truncate" title={item}>
184
171
  {item}
185
172
  </span>
@@ -147,7 +147,7 @@ function WeekPicker({
147
147
  className,
148
148
  id,
149
149
  }: WeekPickerProps) {
150
- const isControlled = value !== undefined
150
+ const isControlled = value !== undefined || onValueChange !== undefined
151
151
  const [internalValue, setInternalValue] = React.useState<Date | undefined>(
152
152
  defaultValue ? isoWeekStart(defaultValue) : undefined
153
153
  )
@@ -64,7 +64,7 @@ function YearPicker({
64
64
  const resolvedMin = minYear ?? currentYear - 100
65
65
  const resolvedMax = maxYear ?? currentYear + 10
66
66
 
67
- const isControlled = value !== undefined
67
+ const isControlled = value !== undefined || onValueChange !== undefined
68
68
  const [internalValue, setInternalValue] = React.useState<number | undefined>(
69
69
  defaultValue
70
70
  )