@behavioral-agentic-design-system/core 0.8.3 → 0.9.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.
@@ -0,0 +1,117 @@
1
+ "use client";
2
+
3
+ import * as AccordionPrimitive from "@radix-ui/react-accordion";
4
+ import { ChevronDownIcon } from "lucide-react";
5
+
6
+ import { cn } from "@behavioral-agentic-design-system/core/lib/utils";
7
+
8
+ function Accordion({
9
+ ...props
10
+ }: React.ComponentProps<typeof AccordionPrimitive.Root>) {
11
+ return <AccordionPrimitive.Root data-slot="accordion" {...props} />;
12
+ }
13
+
14
+ function AccordionItem({
15
+ className,
16
+ ...props
17
+ }: React.ComponentProps<typeof AccordionPrimitive.Item>) {
18
+ return (
19
+ <AccordionPrimitive.Item
20
+ data-slot="accordion-item"
21
+ className={cn("border-b last:border-b-0", className)}
22
+ {...props}
23
+ />
24
+ );
25
+ }
26
+
27
+ function AccordionTrigger({
28
+ className,
29
+ children,
30
+ ...props
31
+ }: React.ComponentProps<typeof AccordionPrimitive.Trigger>) {
32
+ return (
33
+ <AccordionPrimitive.Header className="flex">
34
+ <AccordionPrimitive.Trigger
35
+ data-slot="accordion-trigger"
36
+ className={cn(
37
+ // Layout + interactivity (tokens via Tailwind utilities work for
38
+ // color/spacing/radius — the v4 namespaces for --color-* and friends
39
+ // are wired correctly).
40
+ "group/accordion-trigger flex flex-1 items-center justify-between gap-4 py-4 text-left text-sm font-medium rounded-sm",
41
+ // The transition PROPERTY is Tailwind-driven (transition-colors is
42
+ // a stock utility that maps to transition-property: color, ...).
43
+ "transition-colors",
44
+ // Focus + a11y
45
+ "outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
46
+ // Hover — subtle accent tint instead of muting the label text.
47
+ "hover:bg-accent/50",
48
+ // States
49
+ "disabled:pointer-events-none disabled:opacity-50",
50
+ // Open-state hint on the chevron (rotation transition lives on the icon)
51
+ "[&[data-state=open]>svg]:rotate-180",
52
+ className
53
+ )}
54
+ // The transition DURATION + TIMING are driven from BADS motion tokens
55
+ // via inline style. Tailwind v4 generates `--ease-*` utilities from
56
+ // the theme but does NOT auto-generate `--duration-*` utilities, so the
57
+ // duration utility never compiles and arbitrary-value duration classes
58
+ // have unreliable scanner pickup. (Do not write that arbitrary-value
59
+ // class literally in this file — Tailwind's content scanner extracts it
60
+ // even from comments and emits invalid CSS that breaks the build.)
61
+ // Inline style with var() references is the
62
+ // BADS-canonical pattern used by Foundations/Motion stories — the
63
+ // CSS vars resolve at runtime against the :root definitions in
64
+ // styles.css and propagate through `pnpm build:tokens`.
65
+ style={{
66
+ transitionDuration: "var(--duration-fast)",
67
+ transitionTimingFunction: "var(--ease-out)",
68
+ }}
69
+ {...props}
70
+ >
71
+ {children}
72
+ <ChevronDownIcon
73
+ strokeWidth={1.5}
74
+ className={cn(
75
+ "pointer-events-none size-4 shrink-0 text-muted-foreground",
76
+ // Tailwind handles transition property; durations + easings come
77
+ // from BADS tokens via inline style below.
78
+ "transition-transform",
79
+ // Chevron warms toward foreground on hover so it tracks the
80
+ // trigger's hover state without competing with the label text.
81
+ "group-hover/accordion-trigger:text-foreground"
82
+ )}
83
+ style={{
84
+ // --duration-base + --ease-spring for the contained 180° rotation
85
+ // overshoot. Short motion, defined endpoint — ideal for spring.
86
+ transitionDuration: "var(--duration-base)",
87
+ transitionTimingFunction: "var(--ease-spring)",
88
+ }}
89
+ />
90
+ </AccordionPrimitive.Trigger>
91
+ </AccordionPrimitive.Header>
92
+ );
93
+ }
94
+
95
+ function AccordionContent({
96
+ className,
97
+ children,
98
+ ...props
99
+ }: React.ComponentProps<typeof AccordionPrimitive.Content>) {
100
+ return (
101
+ <AccordionPrimitive.Content
102
+ data-slot="accordion-content"
103
+ className={cn("overflow-hidden text-sm", className)}
104
+ // The expand/collapse animation lives in styles.css keyed off the
105
+ // [data-slot="accordion-content"][data-state="open"|"closed"] selector
106
+ // pattern that Radix sets at runtime. Plain CSS — no Tailwind utility
107
+ // generation in the path. See packages/core/scripts/build-tokens.cjs
108
+ // for the keyframes + rules. Duration + timing come from
109
+ // var(--duration-base) + var(--ease-out) motion tokens.
110
+ {...props}
111
+ >
112
+ <div className="pb-4 pt-0">{children}</div>
113
+ </AccordionPrimitive.Content>
114
+ );
115
+ }
116
+
117
+ export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
@@ -0,0 +1,162 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"
5
+
6
+ import { cn } from "../../lib/utils"
7
+ import { buttonVariants } from "./button"
8
+ import { usePortalThemeClass } from "../../hooks/use-portal-theme-class"
9
+
10
+ function AlertDialog({
11
+ ...props
12
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Root>) {
13
+ return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />
14
+ }
15
+
16
+ function AlertDialogTrigger({
17
+ ...props
18
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>) {
19
+ return (
20
+ <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />
21
+ )
22
+ }
23
+
24
+ function AlertDialogPortal({
25
+ ...props
26
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) {
27
+ return (
28
+ <AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />
29
+ )
30
+ }
31
+
32
+ function AlertDialogOverlay({
33
+ className,
34
+ ...props
35
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>) {
36
+ return (
37
+ <AlertDialogPrimitive.Overlay
38
+ data-slot="alert-dialog-overlay"
39
+ className={cn(
40
+ "fixed inset-0 z-50 bg-black/40 backdrop-blur-sm data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
41
+ className
42
+ )}
43
+ {...props}
44
+ />
45
+ )
46
+ }
47
+
48
+ function AlertDialogContent({
49
+ className,
50
+ ...props
51
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Content>) {
52
+ const portalThemeClass = usePortalThemeClass()
53
+ return (
54
+ <AlertDialogPortal>
55
+ <AlertDialogOverlay />
56
+ <AlertDialogPrimitive.Content
57
+ data-slot="alert-dialog-content"
58
+ className={cn(
59
+ "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-2xl ring-1 ring-white/10 outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",
60
+ portalThemeClass,
61
+ className
62
+ )}
63
+ {...props}
64
+ />
65
+ </AlertDialogPortal>
66
+ )
67
+ }
68
+
69
+ function AlertDialogHeader({
70
+ className,
71
+ ...props
72
+ }: React.ComponentProps<"div">) {
73
+ return (
74
+ <div
75
+ data-slot="alert-dialog-header"
76
+ className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
77
+ {...props}
78
+ />
79
+ )
80
+ }
81
+
82
+ function AlertDialogFooter({
83
+ className,
84
+ ...props
85
+ }: React.ComponentProps<"div">) {
86
+ return (
87
+ <div
88
+ data-slot="alert-dialog-footer"
89
+ className={cn(
90
+ "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
91
+ className
92
+ )}
93
+ {...props}
94
+ />
95
+ )
96
+ }
97
+
98
+ function AlertDialogTitle({
99
+ className,
100
+ ...props
101
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {
102
+ return (
103
+ <AlertDialogPrimitive.Title
104
+ data-slot="alert-dialog-title"
105
+ className={cn("text-lg leading-none font-semibold", className)}
106
+ {...props}
107
+ />
108
+ )
109
+ }
110
+
111
+ function AlertDialogDescription({
112
+ className,
113
+ ...props
114
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {
115
+ return (
116
+ <AlertDialogPrimitive.Description
117
+ data-slot="alert-dialog-description"
118
+ className={cn("text-sm text-muted-foreground", className)}
119
+ {...props}
120
+ />
121
+ )
122
+ }
123
+
124
+ function AlertDialogAction({
125
+ className,
126
+ ...props
127
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Action>) {
128
+ return (
129
+ <AlertDialogPrimitive.Action
130
+ data-slot="alert-dialog-action"
131
+ className={cn(buttonVariants(), className)}
132
+ {...props}
133
+ />
134
+ )
135
+ }
136
+
137
+ function AlertDialogCancel({
138
+ className,
139
+ ...props
140
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Cancel>) {
141
+ return (
142
+ <AlertDialogPrimitive.Cancel
143
+ data-slot="alert-dialog-cancel"
144
+ className={cn(buttonVariants({ variant: "outline" }), className)}
145
+ {...props}
146
+ />
147
+ )
148
+ }
149
+
150
+ export {
151
+ AlertDialog,
152
+ AlertDialogAction,
153
+ AlertDialogCancel,
154
+ AlertDialogContent,
155
+ AlertDialogDescription,
156
+ AlertDialogFooter,
157
+ AlertDialogHeader,
158
+ AlertDialogOverlay,
159
+ AlertDialogPortal,
160
+ AlertDialogTitle,
161
+ AlertDialogTrigger,
162
+ }
@@ -0,0 +1,357 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
5
+
6
+ import { cn } from "@behavioral-agentic-design-system/core/lib/utils";
7
+
8
+ // ─── Context ─────────────────────────────────────────────────────────────────
9
+
10
+ type CarouselContextValue = {
11
+ /** 0-based index of the currently centred slide */
12
+ currentIndex: number;
13
+ totalSlides: number;
14
+ scrollToIndex: (index: number) => void;
15
+ listRef: React.RefObject<HTMLDivElement | null>;
16
+ orientation: "horizontal" | "vertical";
17
+ handleKeyDown: (e: React.KeyboardEvent) => void;
18
+ };
19
+
20
+ const CarouselContext = React.createContext<CarouselContextValue | null>(null);
21
+
22
+ function useCarousel() {
23
+ const ctx = React.useContext(CarouselContext);
24
+ if (!ctx) throw new Error("Carousel sub-components must be used inside <Carousel>");
25
+ return ctx;
26
+ }
27
+
28
+ // ─── Root ─────────────────────────────────────────────────────────────────────
29
+
30
+ type CarouselProps = {
31
+ orientation?: "horizontal" | "vertical";
32
+ "aria-label"?: string;
33
+ } & React.ComponentPropsWithoutRef<"section">;
34
+
35
+ function Carousel({
36
+ orientation = "horizontal",
37
+ className,
38
+ children,
39
+ "aria-label": ariaLabel = "Content carousel",
40
+ ...props
41
+ }: CarouselProps) {
42
+ const listRef = React.useRef<HTMLDivElement>(null);
43
+ const [currentIndex, setCurrentIndex] = React.useState(0);
44
+ const [totalSlides, setTotalSlides] = React.useState(0);
45
+
46
+ // Track visible slide via IntersectionObserver
47
+ React.useEffect(() => {
48
+ const list = listRef.current;
49
+ if (!list) return;
50
+
51
+ const items = Array.from(list.querySelectorAll("[data-slot='carousel-item']"));
52
+ setTotalSlides(items.length);
53
+ if (items.length === 0) return;
54
+
55
+ // Persist every slide's latest intersection ratio. Each callback only
56
+ // carries the entries that *changed*, so picking the max within a single
57
+ // batch makes currentIndex bounce mid-scroll (the dots flutter). Keeping a
58
+ // running ratio per slide and choosing the global argmax is stable.
59
+ const ratios = new Array(items.length).fill(0);
60
+ const observer = new IntersectionObserver(
61
+ (entries) => {
62
+ entries.forEach((entry) => {
63
+ const idx = items.indexOf(entry.target as HTMLElement);
64
+ if (idx !== -1) ratios[idx] = entry.intersectionRatio;
65
+ });
66
+ let maxRatio = 0;
67
+ let visibleIndex = -1;
68
+ ratios.forEach((r, idx) => {
69
+ if (r > maxRatio) {
70
+ maxRatio = r;
71
+ visibleIndex = idx;
72
+ }
73
+ });
74
+ if (visibleIndex !== -1 && maxRatio > 0) setCurrentIndex(visibleIndex);
75
+ },
76
+ { root: list, threshold: Array.from({ length: 11 }, (_, i) => i / 10) }
77
+ );
78
+
79
+ items.forEach((item) => observer.observe(item));
80
+ return () => observer.disconnect();
81
+ }, [children]);
82
+
83
+ const scrollToIndex = React.useCallback((index: number) => {
84
+ const list = listRef.current;
85
+ if (!list) return;
86
+ const items = Array.from(list.querySelectorAll("[data-slot='carousel-item']"));
87
+ const target = items[index] as HTMLElement | undefined;
88
+ if (!target) return;
89
+ // Scroll ONLY this carousel's track — never Element.scrollIntoView, which
90
+ // also scrolls every ancestor (including the page) to bring the slide into
91
+ // view, yanking the viewport vertically. Compute the target's offset within
92
+ // the track and scroll the container itself.
93
+ const listRect = list.getBoundingClientRect();
94
+ const targetRect = target.getBoundingClientRect();
95
+ if (orientation === "vertical") {
96
+ list.scrollTo({ top: list.scrollTop + (targetRect.top - listRect.top), behavior: "smooth" });
97
+ } else {
98
+ list.scrollTo({ left: list.scrollLeft + (targetRect.left - listRect.left), behavior: "smooth" });
99
+ }
100
+ }, [orientation]);
101
+
102
+ // Keyboard navigation on the root section
103
+ const handleKeyDown = React.useCallback((e: React.KeyboardEvent) => {
104
+ if (orientation === "horizontal") {
105
+ if (e.key === "ArrowLeft") { e.preventDefault(); scrollToIndex(Math.max(0, currentIndex - 1)); }
106
+ if (e.key === "ArrowRight") { e.preventDefault(); scrollToIndex(Math.min(totalSlides - 1, currentIndex + 1)); }
107
+ } else {
108
+ if (e.key === "ArrowUp") { e.preventDefault(); scrollToIndex(Math.max(0, currentIndex - 1)); }
109
+ if (e.key === "ArrowDown") { e.preventDefault(); scrollToIndex(Math.min(totalSlides - 1, currentIndex + 1)); }
110
+ }
111
+ if (e.key === "Home") { e.preventDefault(); scrollToIndex(0); }
112
+ if (e.key === "End") { e.preventDefault(); scrollToIndex(totalSlides - 1); }
113
+ }, [currentIndex, totalSlides, scrollToIndex, orientation]);
114
+
115
+ // Split indicators out of the viewport so the overlay arrows (positioned
116
+ // against the viewport) center on the CONTENT height, not the section —
117
+ // otherwise the indicator row drags the arrows' vertical midpoint down.
118
+ const childArray = React.Children.toArray(children);
119
+ const isIndicators = (c: React.ReactNode) =>
120
+ React.isValidElement(c) && c.type === CarouselIndicators;
121
+ const viewportChildren = childArray.filter((c) => !isIndicators(c));
122
+ const indicatorChildren = childArray.filter(isIndicators);
123
+
124
+ return (
125
+ <CarouselContext.Provider value={{ currentIndex, totalSlides, scrollToIndex, listRef, orientation, handleKeyDown }}>
126
+ <section
127
+ data-slot="carousel"
128
+ role="region"
129
+ aria-roledescription="carousel"
130
+ aria-label={ariaLabel}
131
+ className={cn("relative", className)}
132
+ {...props}
133
+ >
134
+ <div
135
+ data-slot="carousel-viewport"
136
+ className={cn(
137
+ "relative",
138
+ // When overlay prev/next controls are present (as DIRECT children),
139
+ // narrow the scroll track with side MARGIN so the 44px arrow circles
140
+ // sit in the resulting gutters over the page background. Margin (not
141
+ // padding) is load-bearing: it shrinks the scrollport so the next
142
+ // slide is clipped at the track edge — no peek under the arrows.
143
+ // No-arrow tracks (swipe/indicator-only, or static bottom controls
144
+ // nested in a wrapper) keep full width.
145
+ "[&:has(>[data-slot=carousel-next])_[data-slot=carousel-content]]:mx-20"
146
+ )}
147
+ >
148
+ {viewportChildren}
149
+ </div>
150
+ {indicatorChildren}
151
+ </section>
152
+ </CarouselContext.Provider>
153
+ );
154
+ }
155
+
156
+ // ─── Content ──────────────────────────────────────────────────────────────────
157
+
158
+ function CarouselContent({
159
+ className,
160
+ ...props
161
+ }: React.ComponentPropsWithoutRef<"div">) {
162
+ const { listRef, orientation, handleKeyDown } = useCarousel();
163
+ return (
164
+ <div
165
+ ref={listRef}
166
+ data-slot="carousel-content"
167
+ aria-live="polite"
168
+ tabIndex={0}
169
+ onKeyDown={handleKeyDown}
170
+ className={cn(
171
+ // gap-4 puts breathing room between slides — visible as you scroll
172
+ // from one card to the next. basis-full slides still snap one-per-view
173
+ // (the gap sits offscreen at rest), so no peek is introduced.
174
+ "flex gap-4",
175
+ orientation === "horizontal"
176
+ ? "overflow-x-auto snap-x snap-mandatory scroll-smooth"
177
+ : "flex-col overflow-y-auto snap-y snap-mandatory scroll-smooth",
178
+ // Hide scrollbar visually while keeping scroll functionality
179
+ "[scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
180
+ // BADS focus ring on the keyboard-navigable scroll container
181
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
182
+ className
183
+ )}
184
+ {...props}
185
+ />
186
+ );
187
+ }
188
+
189
+ // ─── Item ─────────────────────────────────────────────────────────────────────
190
+
191
+ type CarouselItemProps = {
192
+ /** 0-based index of this slide — required for ARIA labeling */
193
+ index?: number;
194
+ } & React.ComponentPropsWithoutRef<"div">;
195
+
196
+ function CarouselItem({
197
+ className,
198
+ index,
199
+ children,
200
+ ...props
201
+ }: CarouselItemProps) {
202
+ const { totalSlides } = useCarousel();
203
+ return (
204
+ <div
205
+ data-slot="carousel-item"
206
+ role="group"
207
+ aria-roledescription="slide"
208
+ aria-label={index !== undefined ? `Slide ${index + 1} of ${totalSlides}` : undefined}
209
+ className={cn(
210
+ "min-w-0 shrink-0 grow-0 basis-full snap-start",
211
+ className
212
+ )}
213
+ {...props}
214
+ >
215
+ {children}
216
+ </div>
217
+ );
218
+ }
219
+
220
+ // ─── Previous button ──────────────────────────────────────────────────────────
221
+
222
+ function CarouselPrevious({
223
+ className,
224
+ ...props
225
+ }: Omit<React.ComponentPropsWithoutRef<"button">, "aria-label">) {
226
+ const { currentIndex, scrollToIndex } = useCarousel();
227
+ const disabled = currentIndex === 0;
228
+ return (
229
+ <button
230
+ data-slot="carousel-previous"
231
+ aria-label="Previous slide"
232
+ disabled={disabled}
233
+ onClick={() => scrollToIndex(currentIndex - 1)}
234
+ className={cn(
235
+ // Size — 44×44 touch target (SC 2.5.5)
236
+ "inline-flex items-center justify-center size-11",
237
+ "rounded-full border border-input bg-background",
238
+ "text-foreground",
239
+ // Transitions — BADS pattern (c): inline style for duration/easing
240
+ "transition-colors",
241
+ "hover:bg-accent hover:text-accent-foreground",
242
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
243
+ "active:scale-95",
244
+ "disabled:pointer-events-none disabled:opacity-50",
245
+ // Position — sits in the left gutter, vertically centred on the content
246
+ "absolute left-4 top-1/2 -translate-y-1/2 z-10",
247
+ className
248
+ )}
249
+ style={{
250
+ transitionDuration: "var(--duration-fast)",
251
+ transitionTimingFunction: "var(--ease-out)",
252
+ }}
253
+ {...props}
254
+ >
255
+ <ChevronLeftIcon size={16} strokeWidth={1.5} />
256
+ </button>
257
+ );
258
+ }
259
+
260
+ // ─── Next button ──────────────────────────────────────────────────────────────
261
+
262
+ function CarouselNext({
263
+ className,
264
+ ...props
265
+ }: Omit<React.ComponentPropsWithoutRef<"button">, "aria-label">) {
266
+ const { currentIndex, totalSlides, scrollToIndex } = useCarousel();
267
+ const disabled = currentIndex === totalSlides - 1;
268
+ return (
269
+ <button
270
+ data-slot="carousel-next"
271
+ aria-label="Next slide"
272
+ disabled={disabled}
273
+ onClick={() => scrollToIndex(currentIndex + 1)}
274
+ className={cn(
275
+ "inline-flex items-center justify-center size-11",
276
+ "rounded-full border border-input bg-background",
277
+ "text-foreground",
278
+ "transition-colors",
279
+ "hover:bg-accent hover:text-accent-foreground",
280
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
281
+ "active:scale-95",
282
+ "disabled:pointer-events-none disabled:opacity-50",
283
+ "absolute right-4 top-1/2 -translate-y-1/2 z-10",
284
+ className
285
+ )}
286
+ style={{
287
+ transitionDuration: "var(--duration-fast)",
288
+ transitionTimingFunction: "var(--ease-out)",
289
+ }}
290
+ {...props}
291
+ >
292
+ <ChevronRightIcon size={16} strokeWidth={1.5} />
293
+ </button>
294
+ );
295
+ }
296
+
297
+ // ─── Indicators (dot row) ─────────────────────────────────────────────────────
298
+
299
+ function CarouselIndicators({ className, ...props }: React.ComponentPropsWithoutRef<"div">) {
300
+ const { currentIndex, totalSlides, scrollToIndex } = useCarousel();
301
+ return (
302
+ <div
303
+ data-slot="carousel-indicators"
304
+ role="tablist"
305
+ aria-label="Slide indicators"
306
+ className={cn("flex items-center justify-center gap-1 pt-4", className)}
307
+ {...props}
308
+ >
309
+ {Array.from({ length: totalSlides }).map((_, i) => (
310
+ <button
311
+ key={i}
312
+ role="tab"
313
+ aria-label={`Go to slide ${i + 1}`}
314
+ aria-selected={i === currentIndex}
315
+ onClick={() => scrollToIndex(i)}
316
+ // Tap area stays a full 44px tall (SC 2.5.5 height) but hugs the dot
317
+ // horizontally so the indicators read as a tight cluster. Width is
318
+ // set explicitly (w-6) rather than via padding: with border-box, a
319
+ // stray global `[role=tab]` padding reset — e.g. the one Storybook
320
+ // injects for its own UI tabs — can't inflate the button and spread
321
+ // the dots. The dot is centred and overflows the (zeroed) content box
322
+ // harmlessly if such padding is inherited.
323
+ className={cn(
324
+ "group flex h-11 w-6 items-center justify-center rounded-full",
325
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
326
+ )}
327
+ >
328
+ <span
329
+ className={cn(
330
+ // True circles in every state — differentiate the active dot by
331
+ // fill, never by stretching it into a pill. shrink-0 keeps the dot
332
+ // at full size even if an inherited padding (see button comment)
333
+ // collapses the flex content box to zero width.
334
+ "block shrink-0 rounded-full transition-colors",
335
+ i === currentIndex
336
+ ? "size-5 bg-primary"
337
+ : "size-4 bg-muted-foreground/50 group-hover:bg-muted-foreground/80"
338
+ )}
339
+ style={{
340
+ transitionDuration: "var(--duration-base)",
341
+ transitionTimingFunction: "var(--ease-out)",
342
+ }}
343
+ />
344
+ </button>
345
+ ))}
346
+ </div>
347
+ );
348
+ }
349
+
350
+ export {
351
+ Carousel,
352
+ CarouselContent,
353
+ CarouselItem,
354
+ CarouselPrevious,
355
+ CarouselNext,
356
+ CarouselIndicators,
357
+ };