@behavioral-agentic-design-system/core 0.24.0 → 0.27.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 (137) hide show
  1. package/package.json +5 -2
  2. package/scripts/build-tokens.cjs +87 -5
  3. package/src/app/preview/components/page.tsx +4745 -244
  4. package/src/app/shell.tsx +18 -6
  5. package/src/components/customize/brand-mark-section.tsx +1 -1
  6. package/src/components/customize-tab.tsx +2 -2
  7. package/src/components/home-tab.tsx +2 -2
  8. package/src/components/ui/action-bar.tsx +142 -0
  9. package/src/components/ui/affix.tsx +109 -0
  10. package/src/components/ui/alert.tsx +37 -3
  11. package/src/components/ui/anchor.tsx +136 -0
  12. package/src/components/ui/angle-slider.tsx +265 -0
  13. package/src/components/ui/autocomplete.tsx +223 -0
  14. package/src/components/ui/avatar.tsx +8 -2
  15. package/src/components/ui/blockquote.tsx +112 -0
  16. package/src/components/ui/bottom-navigation.tsx +144 -0
  17. package/src/components/ui/burger.tsx +117 -0
  18. package/src/components/ui/button.tsx +101 -3
  19. package/src/components/ui/calendar.tsx +1 -1
  20. package/src/components/ui/card.tsx +43 -5
  21. package/src/components/ui/carousel.tsx +10 -5
  22. package/src/components/ui/cascader.tsx +253 -0
  23. package/src/components/ui/checkbox-card.tsx +176 -0
  24. package/src/components/ui/checkbox-group.tsx +231 -0
  25. package/src/components/ui/checkbox.tsx +14 -3
  26. package/src/components/ui/chip.tsx +143 -0
  27. package/src/components/ui/circular-progress.tsx +2 -2
  28. package/src/components/ui/color-swatch.tsx +73 -0
  29. package/src/components/ui/copy-button.tsx +21 -4
  30. package/src/components/ui/date-picker.tsx +6 -3
  31. package/src/components/ui/date-range-picker.tsx +6 -3
  32. package/src/components/ui/float-label.tsx +114 -0
  33. package/src/components/ui/floating-action-button.tsx +179 -0
  34. package/src/components/ui/floating-panel.tsx +129 -0
  35. package/src/components/ui/format-number.tsx +122 -0
  36. package/src/components/ui/highlight.tsx +85 -0
  37. package/src/components/ui/image.tsx +195 -0
  38. package/src/components/ui/index.ts +51 -0
  39. package/src/components/ui/indicator.tsx +2 -2
  40. package/src/components/ui/input.tsx +48 -4
  41. package/src/components/ui/kbd.tsx +1 -1
  42. package/src/components/ui/link.tsx +158 -0
  43. package/src/components/ui/listbox.tsx +426 -0
  44. package/src/components/ui/loading-overlay.tsx +80 -0
  45. package/src/components/ui/marquee.tsx +193 -0
  46. package/src/components/ui/masonry.tsx +164 -0
  47. package/src/components/ui/meter.tsx +186 -0
  48. package/src/components/ui/motion-toggle.tsx +170 -0
  49. package/src/components/ui/notification.tsx +175 -0
  50. package/src/components/ui/overlay.tsx +63 -0
  51. package/src/components/ui/progress.tsx +95 -4
  52. package/src/components/ui/rating-group.tsx +1 -0
  53. package/src/components/ui/separator.tsx +57 -1
  54. package/src/components/ui/sidebar.tsx +1 -1
  55. package/src/components/ui/signature-pad.tsx +381 -0
  56. package/src/components/ui/skeleton.tsx +59 -2
  57. package/src/components/ui/skip-link.tsx +117 -0
  58. package/src/components/ui/slider.tsx +86 -1
  59. package/src/components/ui/spoiler.tsx +131 -0
  60. package/src/components/ui/tabs.tsx +1 -1
  61. package/src/components/ui/text.tsx +135 -0
  62. package/src/components/ui/textarea.tsx +66 -2
  63. package/src/components/ui/timeline.tsx +71 -14
  64. package/src/components/ui/timer.tsx +183 -0
  65. package/src/components/ui/tour.tsx +332 -0
  66. package/src/components/ui/transfer-list.tsx +343 -0
  67. package/src/components/ui/typing-indicator.tsx +96 -0
  68. package/src/components/ui/visually-hidden.tsx +42 -0
  69. package/src/components/ui/watermark.tsx +0 -0
  70. package/src/components/ui/word-rotate.tsx +82 -0
  71. package/src/data/docs-index.ts +10 -2
  72. package/src/stories/ActionBar.stories.tsx +201 -0
  73. package/src/stories/Affix.stories.tsx +165 -0
  74. package/src/stories/Alert.stories.tsx +58 -0
  75. package/src/stories/Anchor.stories.tsx +236 -0
  76. package/src/stories/AngleSlider.stories.tsx +128 -0
  77. package/src/stories/Autocomplete.stories.tsx +216 -0
  78. package/src/stories/Avatar.stories.tsx +73 -1
  79. package/src/stories/Blockquote.stories.tsx +148 -0
  80. package/src/stories/BottomNavigation.stories.tsx +195 -0
  81. package/src/stories/Burger.stories.tsx +79 -0
  82. package/src/stories/Button.stories.tsx +103 -2
  83. package/src/stories/Calendar.stories.tsx +4 -0
  84. package/src/stories/Card.stories.tsx +30 -0
  85. package/src/stories/Carousel.stories.tsx +2 -1
  86. package/src/stories/Cascader.stories.tsx +285 -0
  87. package/src/stories/Checkbox.stories.tsx +13 -0
  88. package/src/stories/CheckboxCard.stories.tsx +210 -0
  89. package/src/stories/CheckboxGroup.stories.tsx +186 -0
  90. package/src/stories/Chip.stories.tsx +173 -0
  91. package/src/stories/CircularProgress.stories.tsx +3 -0
  92. package/src/stories/ColorSwatch.stories.tsx +81 -0
  93. package/src/stories/CopyButton.stories.tsx +3 -3
  94. package/src/stories/DatePicker.stories.tsx +3 -0
  95. package/src/stories/DateRangePicker.stories.tsx +3 -0
  96. package/src/stories/Editable.stories.tsx +14 -0
  97. package/src/stories/FloatLabel.stories.tsx +148 -0
  98. package/src/stories/FloatingActionButton.stories.tsx +215 -0
  99. package/src/stories/FloatingPanel.stories.tsx +176 -0
  100. package/src/stories/FormatNumber.stories.tsx +308 -0
  101. package/src/stories/Highlight.stories.tsx +140 -0
  102. package/src/stories/Image.stories.tsx +141 -0
  103. package/src/stories/Indicator.stories.tsx +3 -0
  104. package/src/stories/Input.stories.tsx +33 -0
  105. package/src/stories/Kbd.stories.tsx +3 -0
  106. package/src/stories/Link.stories.tsx +198 -0
  107. package/src/stories/Listbox.stories.tsx +240 -0
  108. package/src/stories/LoadingOverlay.stories.tsx +148 -0
  109. package/src/stories/Marquee.stories.tsx +170 -0
  110. package/src/stories/Masonry.stories.tsx +227 -0
  111. package/src/stories/Meter.stories.tsx +150 -0
  112. package/src/stories/MotionToggle.stories.tsx +85 -0
  113. package/src/stories/Notification.stories.tsx +264 -0
  114. package/src/stories/Overlay.stories.tsx +169 -0
  115. package/src/stories/PasswordInput.stories.tsx +4 -0
  116. package/src/stories/Progress.stories.tsx +70 -27
  117. package/src/stories/RatingGroup.stories.tsx +5 -0
  118. package/src/stories/Separator.stories.tsx +41 -5
  119. package/src/stories/Sidebar.stories.tsx +2 -1
  120. package/src/stories/SignaturePad.stories.tsx +112 -0
  121. package/src/stories/Skeleton.stories.tsx +23 -4
  122. package/src/stories/SkipLink.stories.tsx +137 -0
  123. package/src/stories/Slider.stories.tsx +28 -0
  124. package/src/stories/Spoiler.stories.tsx +122 -0
  125. package/src/stories/Tabs.stories.tsx +2 -1
  126. package/src/stories/Text.stories.tsx +191 -0
  127. package/src/stories/Textarea.stories.tsx +58 -6
  128. package/src/stories/Timeline.stories.tsx +82 -0
  129. package/src/stories/Timer.stories.tsx +160 -0
  130. package/src/stories/Tour.stories.tsx +191 -0
  131. package/src/stories/TransferList.stories.tsx +190 -0
  132. package/src/stories/TypingIndicator.stories.tsx +139 -0
  133. package/src/stories/VisuallyHidden.stories.tsx +105 -0
  134. package/src/stories/Watermark.stories.tsx +212 -0
  135. package/src/stories/WordRotate.stories.tsx +101 -0
  136. package/src/styles.css +88 -6
  137. package/src/tokens.json +3 -3
@@ -0,0 +1,265 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { cva, type VariantProps } from "class-variance-authority"
5
+
6
+ import { cn } from "../../lib/utils"
7
+
8
+ /**
9
+ * Per-size geometry. The whole circle is the interactive target, so every
10
+ * size clears SC 2.5.5 Enhanced (44px) — sm is the 64px floor (registry
11
+ * antiPatterns forbid rendering smaller; circular touch accuracy degrades
12
+ * faster than linear).
13
+ */
14
+ const SIZES = {
15
+ sm: { size: 64, handle: 12, strokeWidth: 4 },
16
+ md: { size: 96, handle: 16, strokeWidth: 6 },
17
+ lg: { size: 128, handle: 20, strokeWidth: 8 },
18
+ } as const
19
+
20
+ type SizeKey = keyof typeof SIZES
21
+
22
+ const angleSliderVariants = cva(
23
+ // The root div is the focusable slider node. AAA focus ring per the
24
+ // system floor; base layer adds outline-offset on :focus-visible.
25
+ "group relative inline-flex shrink-0 touch-none items-center justify-center rounded-full select-none ring-ring/50 focus-visible:ring-4 focus-visible:outline-hidden data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
26
+ {
27
+ variants: {
28
+ size: {
29
+ sm: "size-16",
30
+ md: "size-24",
31
+ lg: "size-32",
32
+ },
33
+ },
34
+ defaultVariants: {
35
+ size: "md",
36
+ },
37
+ }
38
+ )
39
+
40
+ export interface AngleSliderProps
41
+ extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange" | "defaultValue">,
42
+ VariantProps<typeof angleSliderVariants> {
43
+ /** Controlled angle in degrees. Clamped to [min, max]. */
44
+ value?: number
45
+ /** Uncontrolled initial angle in degrees. */
46
+ defaultValue?: number
47
+ /** Fires with the new angle on every drag move and keyboard step. */
48
+ onChange?: (value: number) => void
49
+ min?: number
50
+ max?: number
51
+ step?: number
52
+ size?: SizeKey
53
+ disabled?: boolean
54
+ /**
55
+ * Accessible name — required for meaning since the visual angle is not
56
+ * self-describing to screen reader users. Defaults to "Angle".
57
+ */
58
+ "aria-label"?: string
59
+ }
60
+
61
+ function AngleSlider({
62
+ value: valueProp,
63
+ defaultValue = 0,
64
+ onChange,
65
+ min = 0,
66
+ max = 360,
67
+ step = 1,
68
+ size = "md",
69
+ disabled = false,
70
+ "aria-label": ariaLabel = "Angle",
71
+ className,
72
+ onPointerDown,
73
+ onKeyDown,
74
+ ...props
75
+ }: AngleSliderProps) {
76
+ const rootRef = React.useRef<HTMLDivElement>(null)
77
+ const [internalValue, setInternalValue] = React.useState(defaultValue)
78
+ const [dragging, setDragging] = React.useState(false)
79
+
80
+ const isControlled = valueProp !== undefined
81
+ const clamp = React.useCallback(
82
+ (v: number) => Math.min(max, Math.max(min, v)),
83
+ [min, max]
84
+ )
85
+ const value = clamp(isControlled ? valueProp : internalValue)
86
+
87
+ const commit = React.useCallback(
88
+ (next: number) => {
89
+ const clamped = clamp(next)
90
+ if (!isControlled) setInternalValue(clamped)
91
+ onChange?.(clamped)
92
+ },
93
+ [clamp, isControlled, onChange]
94
+ )
95
+
96
+ /** Pointer XY → degrees, 0° at 12 o'clock, clockwise. Snapped to step. */
97
+ const angleFromPointer = React.useCallback(
98
+ (clientX: number, clientY: number) => {
99
+ const rect = rootRef.current?.getBoundingClientRect()
100
+ if (!rect) return value
101
+ const dx = clientX - (rect.left + rect.width / 2)
102
+ const dy = clientY - (rect.top + rect.height / 2)
103
+ const deg = (Math.atan2(dy, dx) * (180 / Math.PI) + 90 + 360) % 360
104
+ // Snap to step, guard float drift (e.g. step 0.1).
105
+ const snapped = Math.round(deg / step) * step
106
+ return Number(snapped.toFixed(3))
107
+ },
108
+ [step, value]
109
+ )
110
+
111
+ // Drag: pointerdown on the circle jumps to the pressed point and starts
112
+ // tracking; pointer capture keeps move/up events flowing to the root even
113
+ // when the pointer leaves its bounds (unified mouse + touch; the
114
+ // `touch-none` class stops the page from scrolling mid-drag).
115
+ const handlePointerDown = (event: React.PointerEvent<HTMLDivElement>) => {
116
+ onPointerDown?.(event)
117
+ if (disabled || event.defaultPrevented || event.button > 0) return
118
+ event.preventDefault()
119
+ rootRef.current?.focus()
120
+ event.currentTarget.setPointerCapture(event.pointerId)
121
+ setDragging(true)
122
+ commit(angleFromPointer(event.clientX, event.clientY))
123
+ }
124
+
125
+ const handlePointerMove = (event: React.PointerEvent<HTMLDivElement>) => {
126
+ if (!dragging || disabled) return
127
+ commit(angleFromPointer(event.clientX, event.clientY))
128
+ }
129
+
130
+ const endDrag = (event: React.PointerEvent<HTMLDivElement>) => {
131
+ if (!dragging) return
132
+ setDragging(false)
133
+ if (event.currentTarget.hasPointerCapture(event.pointerId)) {
134
+ event.currentTarget.releasePointerCapture(event.pointerId)
135
+ }
136
+ }
137
+
138
+ const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
139
+ onKeyDown?.(event)
140
+ if (disabled || event.defaultPrevented) return
141
+ const delta = event.shiftKey ? step * 10 : step
142
+ let next: number | null = null
143
+ switch (event.key) {
144
+ case "ArrowUp":
145
+ case "ArrowRight":
146
+ next = value + delta
147
+ break
148
+ case "ArrowDown":
149
+ case "ArrowLeft":
150
+ next = value - delta
151
+ break
152
+ case "Home":
153
+ next = min
154
+ break
155
+ case "End":
156
+ next = max
157
+ break
158
+ }
159
+ if (next !== null) {
160
+ event.preventDefault()
161
+ commit(next)
162
+ }
163
+ }
164
+
165
+ const { size: px, handle, strokeWidth } = SIZES[size ?? "md"]
166
+ // Handle rides the track path: same radius for the SVG circle and the
167
+ // rotated dot, chosen so the dot stays inside the root's bounds.
168
+ const radius = px / 2 - handle / 2
169
+ const circumference = 2 * Math.PI * radius
170
+ // Arc sweep is geometric truth (fraction of a full turn), independent of
171
+ // a narrowed [min, max] window.
172
+ const sweep = Math.min(1, Math.max(0, value / 360))
173
+
174
+ // Motion pattern (c): tokens via inline style. Eased on keyboard steps and
175
+ // pointer release; instant while dragging (an eased handle reads as lag).
176
+ const valueMotionStyle: React.CSSProperties = dragging
177
+ ? { transitionProperty: "none" }
178
+ : {
179
+ transitionDuration: "var(--duration-base)",
180
+ transitionTimingFunction: "var(--ease-out)",
181
+ }
182
+
183
+ return (
184
+ <div
185
+ ref={rootRef}
186
+ role="slider"
187
+ tabIndex={disabled ? -1 : 0}
188
+ aria-valuemin={min}
189
+ aria-valuemax={max}
190
+ aria-valuenow={value}
191
+ aria-valuetext={`${value} degrees`}
192
+ aria-label={ariaLabel}
193
+ aria-disabled={disabled || undefined}
194
+ data-slot="angle-slider"
195
+ data-size={size}
196
+ data-disabled={disabled ? "" : undefined}
197
+ data-dragging={dragging ? "" : undefined}
198
+ className={cn(angleSliderVariants({ size }), className)}
199
+ onPointerDown={handlePointerDown}
200
+ onPointerMove={handlePointerMove}
201
+ onPointerUp={endDrag}
202
+ onPointerCancel={endDrag}
203
+ onKeyDown={handleKeyDown}
204
+ {...props}
205
+ >
206
+ <svg
207
+ data-slot="angle-slider-track"
208
+ aria-hidden="true"
209
+ width={px}
210
+ height={px}
211
+ viewBox={`0 0 ${px} ${px}`}
212
+ fill="none"
213
+ // Start the arc at 12 o'clock (SVG circles start at 3 o'clock).
214
+ className="-rotate-90"
215
+ >
216
+ {/* Track ring — same asymmetric alpha convention as Slider/Progress
217
+ (documented light-mode AAA exception; brand-tinted via primary). */}
218
+ <circle
219
+ cx={px / 2}
220
+ cy={px / 2}
221
+ r={radius}
222
+ strokeWidth={strokeWidth}
223
+ className="stroke-primary/30 dark:stroke-primary/60"
224
+ />
225
+ {/* Value arc — sweeps clockwise from 0° to the current angle. */}
226
+ <circle
227
+ cx={px / 2}
228
+ cy={px / 2}
229
+ r={radius}
230
+ strokeWidth={strokeWidth}
231
+ strokeLinecap="round"
232
+ className="stroke-primary transition-[stroke-dashoffset]"
233
+ style={{
234
+ strokeDasharray: circumference,
235
+ strokeDashoffset: circumference * (1 - sweep),
236
+ ...valueMotionStyle,
237
+ }}
238
+ />
239
+ </svg>
240
+ {/* Rotation wrapper — the CSS var --angle drives handle position. */}
241
+ <div
242
+ aria-hidden="true"
243
+ className="pointer-events-none absolute inset-0 transition-transform"
244
+ style={{
245
+ "--angle": `${value}deg`,
246
+ transform: "rotate(var(--angle))",
247
+ ...valueMotionStyle,
248
+ } as React.CSSProperties}
249
+ >
250
+ <span
251
+ data-slot="angle-slider-handle"
252
+ className="absolute top-0 left-1/2 block -translate-x-1/2 rounded-full border-2 border-background bg-primary shadow-sm ring-ring/50 transition-[box-shadow,background-color] group-hover:ring-4 group-data-[disabled]:ring-0"
253
+ style={{
254
+ width: handle,
255
+ height: handle,
256
+ transitionDuration: "var(--duration-fast)",
257
+ transitionTimingFunction: "var(--ease-out)",
258
+ }}
259
+ />
260
+ </div>
261
+ </div>
262
+ )
263
+ }
264
+
265
+ export { AngleSlider, angleSliderVariants }
@@ -0,0 +1,223 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { CheckIcon } from "lucide-react";
5
+ import { type VariantProps } from "class-variance-authority";
6
+
7
+ import { cn } from "../../lib/utils";
8
+ import { Input, inputVariants } from "./input";
9
+
10
+ // ─── Types ────────────────────────────────────────────────────────────────────
11
+
12
+ export interface AutocompleteProps
13
+ extends Omit<
14
+ React.ComponentProps<"input">,
15
+ "size" | "value" | "defaultValue" | "onChange"
16
+ >,
17
+ VariantProps<typeof inputVariants> {
18
+ /**
19
+ * Suggestion pool. Filtered case-insensitively against the typed value —
20
+ * an accelerator, never a restriction: the typed text is always a valid
21
+ * value (use Combobox when the value must come from the list).
22
+ */
23
+ options: string[];
24
+ /** Controlled input value — free text. */
25
+ value: string;
26
+ /** Fires on every keystroke and when a suggestion is committed. */
27
+ onValueChange: (value: string) => void;
28
+ /**
29
+ * Fires only when a suggestion is committed from the list (click, or Enter
30
+ * on a highlighted option) — lets consumers distinguish picked from typed.
31
+ */
32
+ onOptionSelect?: (option: string) => void;
33
+ }
34
+
35
+ // ─── Component ────────────────────────────────────────────────────────────────
36
+
37
+ /**
38
+ * Free-text input with a filtered suggestions listbox (ARIA 1.2 editable
39
+ * combobox, list autocomplete). DOM focus never leaves the input; the list
40
+ * is navigated with a virtual cursor via aria-activedescendant.
41
+ */
42
+ export function Autocomplete({
43
+ options,
44
+ value,
45
+ onValueChange,
46
+ onOptionSelect,
47
+ size,
48
+ disabled,
49
+ className,
50
+ onKeyDown,
51
+ onFocus,
52
+ onBlur,
53
+ ...props
54
+ }: AutocompleteProps) {
55
+ const [open, setOpen] = React.useState(false);
56
+ const [activeIndex, setActiveIndex] = React.useState(-1);
57
+ const listboxRef = React.useRef<HTMLUListElement>(null);
58
+ const listboxId = React.useId();
59
+
60
+ const filteredOptions = React.useMemo(() => {
61
+ const query = value.trim().toLowerCase();
62
+ if (!query) return options;
63
+ return options.filter((option) => option.toLowerCase().includes(query));
64
+ }, [options, value]);
65
+
66
+ // The listbox hides when nothing matches — the input is the primary
67
+ // surface, the list is an accelerator.
68
+ const isOpen = open && !disabled && filteredOptions.length > 0;
69
+
70
+ const selectOption = React.useCallback(
71
+ (option: string) => {
72
+ onValueChange(option);
73
+ onOptionSelect?.(option);
74
+ setOpen(false);
75
+ setActiveIndex(-1);
76
+ },
77
+ [onValueChange, onOptionSelect]
78
+ );
79
+
80
+ // Keep the virtual cursor visible while arrowing through a long list.
81
+ React.useEffect(() => {
82
+ if (!isOpen || activeIndex < 0) return;
83
+ const li = listboxRef.current?.children[activeIndex] as
84
+ | HTMLElement
85
+ | undefined;
86
+ li?.scrollIntoView({ block: "nearest" });
87
+ }, [activeIndex, isOpen]);
88
+
89
+ const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
90
+ onKeyDown?.(e);
91
+ if (e.defaultPrevented) return;
92
+ if (e.key === "ArrowDown") {
93
+ e.preventDefault();
94
+ if (!isOpen) {
95
+ if (filteredOptions.length > 0) {
96
+ setOpen(true);
97
+ setActiveIndex(0);
98
+ }
99
+ } else {
100
+ setActiveIndex((i) => Math.min(i + 1, filteredOptions.length - 1));
101
+ }
102
+ return;
103
+ }
104
+ if (e.key === "ArrowUp") {
105
+ if (isOpen) {
106
+ e.preventDefault();
107
+ setActiveIndex((i) => (i <= 0 ? 0 : i - 1));
108
+ }
109
+ return;
110
+ }
111
+ if (e.key === "Enter") {
112
+ // Free-text contract: only intercept Enter when an option is
113
+ // highlighted. Otherwise the typed text stands and the event falls
114
+ // through (form submit keeps working).
115
+ if (isOpen && activeIndex >= 0) {
116
+ e.preventDefault();
117
+ selectOption(filteredOptions[activeIndex]);
118
+ }
119
+ return;
120
+ }
121
+ if (e.key === "Escape") {
122
+ if (isOpen) {
123
+ setOpen(false);
124
+ setActiveIndex(-1);
125
+ }
126
+ return;
127
+ }
128
+ };
129
+
130
+ return (
131
+ <div data-slot="autocomplete" className={cn("relative w-full", className)}>
132
+ <Input
133
+ data-slot="autocomplete-input"
134
+ role="combobox"
135
+ aria-expanded={isOpen}
136
+ aria-haspopup="listbox"
137
+ aria-autocomplete="list"
138
+ aria-controls={isOpen ? listboxId : undefined}
139
+ aria-activedescendant={
140
+ isOpen && activeIndex >= 0
141
+ ? `${listboxId}-option-${activeIndex}`
142
+ : undefined
143
+ }
144
+ autoComplete="off"
145
+ size={size}
146
+ disabled={disabled}
147
+ value={value}
148
+ onChange={(e) => {
149
+ onValueChange(e.target.value);
150
+ setOpen(true);
151
+ setActiveIndex(-1);
152
+ }}
153
+ onKeyDown={handleKeyDown}
154
+ onFocus={(e) => {
155
+ onFocus?.(e);
156
+ if (value.trim()) setOpen(true);
157
+ }}
158
+ onBlur={(e) => {
159
+ onBlur?.(e);
160
+ // Small delay so an option's mousedown/click lands before the
161
+ // blur closes the list (same guard TagsInput ships).
162
+ setTimeout(() => {
163
+ setOpen(false);
164
+ setActiveIndex(-1);
165
+ }, 120);
166
+ }}
167
+ {...props}
168
+ />
169
+
170
+ {isOpen && (
171
+ <ul
172
+ ref={listboxRef}
173
+ id={listboxId}
174
+ data-slot="autocomplete-list"
175
+ role="listbox"
176
+ aria-label="Suggestions"
177
+ className={cn(
178
+ "absolute left-0 right-0 z-50 mt-1 max-h-60 overflow-y-auto",
179
+ "rounded-md border border-input bg-popover p-1 shadow-md",
180
+ "text-sm text-popover-foreground",
181
+ "animate-in fade-in-0 zoom-in-95"
182
+ )}
183
+ >
184
+ {filteredOptions.map((option, index) => (
185
+ <li
186
+ key={option}
187
+ id={`${listboxId}-option-${index}`}
188
+ data-slot="autocomplete-option"
189
+ role="option"
190
+ aria-selected={index === activeIndex}
191
+ title={option}
192
+ onMouseDown={(e) => {
193
+ // Prevent the input blur so the click commits reliably.
194
+ e.preventDefault();
195
+ selectOption(option);
196
+ }}
197
+ onMouseEnter={() => setActiveIndex(index)}
198
+ className={cn(
199
+ "flex min-h-11 cursor-pointer select-none items-center gap-2",
200
+ "overflow-hidden rounded-sm px-3 py-2",
201
+ "transition-colors",
202
+ index === activeIndex && "bg-accent text-accent-foreground"
203
+ )}
204
+ style={{
205
+ transitionDuration: "var(--duration-fast)",
206
+ transitionTimingFunction: "var(--ease-out)",
207
+ }}
208
+ >
209
+ <span className="min-w-0 flex-1 truncate">{option}</span>
210
+ {option === value && (
211
+ <CheckIcon
212
+ className="size-4 shrink-0 text-primary"
213
+ strokeWidth={1.5}
214
+ aria-hidden="true"
215
+ />
216
+ )}
217
+ </li>
218
+ ))}
219
+ </ul>
220
+ )}
221
+ </div>
222
+ );
223
+ }
@@ -8,16 +8,22 @@ import { cn } from "../../lib/utils"
8
8
  function Avatar({
9
9
  className,
10
10
  size = "default",
11
+ shape = "circle",
11
12
  ...props
12
13
  }: React.ComponentProps<typeof AvatarPrimitive.Root> & {
13
14
  size?: "default" | "sm" | "lg"
15
+ /** Circle (default) or a rounded square, for product/brand avatars. */
16
+ shape?: "circle" | "square"
14
17
  }) {
15
18
  return (
16
19
  <AvatarPrimitive.Root
17
20
  data-slot="avatar"
18
21
  data-size={size}
22
+ data-shape={shape}
19
23
  className={cn(
20
- "group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6",
24
+ // shape drives the radius; circle (default) keeps rounded-full so every
25
+ // existing avatar is unchanged, square opts into rounded-md.
26
+ "group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6 data-[shape=square]:rounded-md",
21
27
  className
22
28
  )}
23
29
  {...props}
@@ -46,7 +52,7 @@ function AvatarFallback({
46
52
  <AvatarPrimitive.Fallback
47
53
  data-slot="avatar-fallback"
48
54
  className={cn(
49
- "flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",
55
+ "flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs group-data-[shape=square]/avatar:rounded-md",
50
56
  className
51
57
  )}
52
58
  {...props}
@@ -0,0 +1,112 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { cva, type VariantProps } from "class-variance-authority";
5
+
6
+ import { cn } from "../../lib/utils";
7
+
8
+ /**
9
+ * Semantic quotation display primitive. Renders the spec-clean
10
+ * <figure> → <blockquote> + <figcaption> structure, so attribution lives
11
+ * OUTSIDE the quote element — a bare byline nested inside <blockquote>
12
+ * misattributes the attribution as quoted text (WHATWG blockquote content
13
+ * model). Chakra v3's Blockquote.Root uses the same figure shape.
14
+ *
15
+ * <Blockquote variant="accent">
16
+ * <BlockquoteContent cite="https://design.bads.com">
17
+ * If a primitive needs a paragraph of explanation, the API is wrong.
18
+ * </BlockquoteContent>
19
+ * <BlockquoteAttribution>
20
+ * Seo-yun Park, <cite>BADS release notes</cite>
21
+ * </BlockquoteAttribution>
22
+ * </Blockquote>
23
+ *
24
+ * Display-only: no interaction, no focus, no motion. The native `cite` URL
25
+ * attribute on BlockquoteContent is machine metadata (screen readers don't
26
+ * expose it) — always pair it with a visible BlockquoteAttribution when the
27
+ * source matters to the reader.
28
+ */
29
+
30
+ const blockquoteVariants = cva(
31
+ // min-w-0 + overflow-wrap:anywhere — long-label overflow contract
32
+ // (corrections.md #001): arbitrary runtime strings (names, emails, URLs)
33
+ // wrap instead of bleeding out of flex/grid parents.
34
+ "min-w-0 [overflow-wrap:anywhere]",
35
+ {
36
+ variants: {
37
+ variant: {
38
+ default: "border-l-2 border-border py-1 pl-4",
39
+ accent: "border-l-2 border-primary py-1 pl-4",
40
+ plain: "",
41
+ },
42
+ },
43
+ defaultVariants: {
44
+ variant: "default",
45
+ },
46
+ }
47
+ );
48
+
49
+ export interface BlockquoteProps
50
+ extends React.ComponentProps<"figure">,
51
+ VariantProps<typeof blockquoteVariants> {}
52
+
53
+ function Blockquote({ className, variant, children, ...props }: BlockquoteProps) {
54
+ return (
55
+ <figure
56
+ data-slot="blockquote"
57
+ className={cn(blockquoteVariants({ variant }), className)}
58
+ {...props}
59
+ >
60
+ {children}
61
+ </figure>
62
+ );
63
+ }
64
+
65
+ /**
66
+ * The quoted text itself — a semantic <blockquote>. Pass the source URL via
67
+ * the native `cite` attribute (passthrough). Quoted content only: put the
68
+ * byline in BlockquoteAttribution, never in here.
69
+ */
70
+ function BlockquoteContent({
71
+ className,
72
+ children,
73
+ ...props
74
+ }: React.ComponentProps<"blockquote">) {
75
+ return (
76
+ <blockquote
77
+ data-slot="blockquote-content"
78
+ className={cn("text-base leading-relaxed text-foreground", className)}
79
+ {...props}
80
+ >
81
+ {children}
82
+ </blockquote>
83
+ );
84
+ }
85
+
86
+ /**
87
+ * Attribution for the quote — a <figcaption> sibling of the <blockquote>,
88
+ * per the WHATWG-recommended figure pattern. Wrap a work title in a plain
89
+ * <cite> element; it renders non-italic here (the browser-default italic is
90
+ * a UA style, not a semantic requirement, and italics hurt legibility for
91
+ * non-Latin scripts).
92
+ */
93
+ function BlockquoteAttribution({
94
+ className,
95
+ children,
96
+ ...props
97
+ }: React.ComponentProps<"figcaption">) {
98
+ return (
99
+ <figcaption
100
+ data-slot="blockquote-attribution"
101
+ className={cn(
102
+ "mt-2 text-sm text-muted-foreground [&_cite]:not-italic",
103
+ className
104
+ )}
105
+ {...props}
106
+ >
107
+ {children}
108
+ </figcaption>
109
+ );
110
+ }
111
+
112
+ export { Blockquote, BlockquoteContent, BlockquoteAttribution, blockquoteVariants };