@behavioral-agentic-design-system/core 0.16.0 → 0.17.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@behavioral-agentic-design-system/core",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "BADS core — tokens, shadcn/ui components, and the BADS template shell (app routes, customize tab, theme hooks). Forks consume this and re-export, keeping client repos to ~30 lines of glue.",
5
5
  "license": "MIT",
6
6
  "author": "Matthew Stephens <work@matthewstephens.com> (https://github.com/matthewlarn)",
@@ -54,16 +54,6 @@ import {
54
54
  AlertDialogTrigger,
55
55
  } from "@behavioral-agentic-design-system/core/components/ui/alert-dialog";
56
56
  import { buttonVariants } from "@behavioral-agentic-design-system/core/components/ui/button";
57
- import {
58
- BottomSheet,
59
- BottomSheetClose,
60
- BottomSheetContent,
61
- BottomSheetDescription,
62
- BottomSheetFooter,
63
- BottomSheetHeader,
64
- BottomSheetTitle,
65
- BottomSheetTrigger,
66
- } from "@behavioral-agentic-design-system/core/components/ui/bottom-sheet";
67
57
  import {
68
58
  Carousel,
69
59
  CarouselContent,
@@ -123,6 +113,7 @@ import {
123
113
  import { Combobox } from "@behavioral-agentic-design-system/core/components/ui/combobox";
124
114
  import { MultiSelect } from "@behavioral-agentic-design-system/core/components/ui/multi-select";
125
115
  import { Kbd } from "@behavioral-agentic-design-system/core/components/ui/kbd";
116
+ import { Code } from "@behavioral-agentic-design-system/core/components/ui/code";
126
117
  import {
127
118
  Toolbar,
128
119
  ToolbarButton,
@@ -272,6 +263,7 @@ import {
272
263
  TreeItemContent,
273
264
  } from "@behavioral-agentic-design-system/core/components/ui/tree-view";
274
265
  import { ColorPicker } from "@behavioral-agentic-design-system/core/components/ui/color-picker";
266
+ import { NativeSelect } from "@behavioral-agentic-design-system/core/components/ui/native-select";
275
267
 
276
268
  // Stable, deterministic data for ScrollArea — never use Math.random in
277
269
  // SSR-rendered output, it causes hydration mismatches.
@@ -850,50 +842,53 @@ export default function ComponentsPreview() {
850
842
  <SegmentedControlShowcase />
851
843
  </Section>
852
844
 
853
- <Section title="BottomSheet">
845
+ <Section title="Bottom Sheet">
846
+ {/* Bottom sheets are just <Sheet> with side="bottom" — they pick up
847
+ the rounded top, grab handle, capped height + scroll, and safe-area
848
+ padding automatically. Pass showHandle={false} to hide the handle. */}
854
849
  <div className="flex flex-wrap gap-3">
855
850
  {/* Default — grab handle + close button */}
856
- <BottomSheet>
857
- <BottomSheetTrigger asChild>
851
+ <Sheet>
852
+ <SheetTrigger asChild>
858
853
  <Button variant="outline">Open</Button>
859
- </BottomSheetTrigger>
860
- <BottomSheetContent>
861
- <BottomSheetHeader>
862
- <BottomSheetTitle>Display density</BottomSheetTitle>
863
- <BottomSheetDescription>
854
+ </SheetTrigger>
855
+ <SheetContent side="bottom">
856
+ <SheetHeader>
857
+ <SheetTitle>Display density</SheetTitle>
858
+ <SheetDescription>
864
859
  Choose how much information shows on each row.
865
- </BottomSheetDescription>
866
- </BottomSheetHeader>
867
- </BottomSheetContent>
868
- </BottomSheet>
860
+ </SheetDescription>
861
+ </SheetHeader>
862
+ </SheetContent>
863
+ </Sheet>
869
864
 
870
865
  {/* No handle variant */}
871
- <BottomSheet>
872
- <BottomSheetTrigger asChild>
866
+ <Sheet>
867
+ <SheetTrigger asChild>
873
868
  <Button variant="outline">No handle</Button>
874
- </BottomSheetTrigger>
875
- <BottomSheetContent showHandle={false}>
876
- <BottomSheetHeader>
877
- <BottomSheetTitle>No grab handle</BottomSheetTitle>
878
- <BottomSheetDescription>
869
+ </SheetTrigger>
870
+ <SheetContent side="bottom" showHandle={false}>
871
+ <SheetHeader>
872
+ <SheetTitle>No grab handle</SheetTitle>
873
+ <SheetDescription>
879
874
  Handle hidden via showHandle={"{false}"}.
880
- </BottomSheetDescription>
881
- </BottomSheetHeader>
882
- </BottomSheetContent>
883
- </BottomSheet>
875
+ </SheetDescription>
876
+ </SheetHeader>
877
+ </SheetContent>
878
+ </Sheet>
884
879
 
885
880
  {/* Realistic action sheet with a footer */}
886
- <BottomSheet>
887
- <BottomSheetTrigger asChild>
881
+ <Sheet>
882
+ <SheetTrigger asChild>
888
883
  <Button>View settings</Button>
889
- </BottomSheetTrigger>
890
- <BottomSheetContent>
891
- <BottomSheetHeader>
892
- <BottomSheetTitle>View settings</BottomSheetTitle>
893
- <BottomSheetDescription>
884
+ </SheetTrigger>
885
+ <SheetContent side="bottom">
886
+ <SheetHeader>
887
+ <SheetTitle>View settings</SheetTitle>
888
+ <SheetDescription>
894
889
  These apply to the Components board only.
895
- </BottomSheetDescription>
896
- </BottomSheetHeader>
890
+ </SheetDescription>
891
+ </SheetHeader>
897
892
  <div className="flex flex-col gap-5 px-4 py-2">
898
893
  <div className="flex items-center justify-between">
899
894
  <Label htmlFor="density-group">Group by status</Label>
@@ -904,16 +899,16 @@ export default function ComponentsPreview() {
904
899
  <Switch id="density-sub" />
905
900
  </div>
906
901
  </div>
907
- <BottomSheetFooter className="flex-row justify-end gap-2">
908
- <BottomSheetClose asChild>
902
+ <SheetFooter className="flex-row justify-end gap-2">
903
+ <SheetClose asChild>
909
904
  <Button variant="ghost">Cancel</Button>
910
- </BottomSheetClose>
911
- <BottomSheetClose asChild>
905
+ </SheetClose>
906
+ <SheetClose asChild>
912
907
  <Button>Apply</Button>
913
- </BottomSheetClose>
914
- </BottomSheetFooter>
915
- </BottomSheetContent>
916
- </BottomSheet>
908
+ </SheetClose>
909
+ </SheetFooter>
910
+ </SheetContent>
911
+ </Sheet>
917
912
  </div>
918
913
  </Section>
919
914
 
@@ -1908,6 +1903,58 @@ export default function ComponentsPreview() {
1908
1903
  </div>
1909
1904
  </div>
1910
1905
  </Section>
1906
+ <Section title="Code">
1907
+ <div className="space-y-6">
1908
+ <div className="space-y-2">
1909
+ <p className="text-sm font-medium text-muted-foreground">Inline (default)</p>
1910
+ <p className="text-sm text-foreground leading-relaxed max-w-sm">
1911
+ Set the primary brand color via{" "}
1912
+ <Code>--primary</Code> in{" "}
1913
+ <Code>tokens.json</Code> and run{" "}
1914
+ <Code>pnpm build:tokens</Code> to regenerate.
1915
+ </p>
1916
+ </div>
1917
+ <div className="space-y-2">
1918
+ <p className="text-sm font-medium text-muted-foreground">Block variant</p>
1919
+ <div className="w-[480px]">
1920
+ <Code variant="block">
1921
+ {`// tokens.json — semantic layer\n{\n "theme": {\n "light": {\n "primary": "#1a1a1a",\n "primary-foreground": "#ffffff"\n }\n }\n}`}
1922
+ </Code>
1923
+ </div>
1924
+ </div>
1925
+ <div className="space-y-2">
1926
+ <p className="text-sm font-medium text-muted-foreground">Sizes — sm / default / lg</p>
1927
+ <div className="flex flex-col gap-3">
1928
+ <div className="flex items-center gap-3">
1929
+ <Code size="sm">pnpm a11y</Code>
1930
+ <Code size="default">pnpm wcag:audit</Code>
1931
+ <Code size="lg">design-tokens</Code>
1932
+ </div>
1933
+ <div className="w-[440px] space-y-1.5">
1934
+ <Code variant="block" size="sm">{`78 pass · 0 fail · 0 warn`}</Code>
1935
+ <Code variant="block" size="default">{`✓ primary on background 12.6:1 AAA`}</Code>
1936
+ <Code variant="block" size="lg">{`@behavioral-agentic-design-system/core@0.16.0`}</Code>
1937
+ </div>
1938
+ </div>
1939
+ </div>
1940
+ <div className="space-y-2">
1941
+ <p className="text-sm font-medium text-muted-foreground">Realistic use</p>
1942
+ <div className="max-w-md space-y-4 text-sm text-foreground leading-relaxed">
1943
+ <div className="space-y-1">
1944
+ <p className="font-medium text-foreground">Install the package</p>
1945
+ <Code variant="block">{`pnpm add @behavioral-agentic-design-system/core`}</Code>
1946
+ </div>
1947
+ <p>
1948
+ Import tokens via <Code>import "@behavioral-agentic-design-system/core/styles.css"</Code>{" "}
1949
+ in your root layout, then use any component:
1950
+ </p>
1951
+ <Code variant="block">
1952
+ {`import { Button } from "@behavioral-agentic-design-system/core/components/ui/button"\n\nexport function Example() {\n return <Button variant="default">Get started</Button>\n}`}
1953
+ </Code>
1954
+ </div>
1955
+ </div>
1956
+ </div>
1957
+ </Section>
1911
1958
  <Section title="Combobox">
1912
1959
  <div className="space-y-6">
1913
1960
  <div className="grid grid-cols-1 gap-6 sm:grid-cols-2">
@@ -2198,6 +2245,24 @@ export default function ComponentsPreview() {
2198
2245
  placeholder="Add stroke…"
2199
2246
  />
2200
2247
  </div>
2248
+ <div className="space-y-3">
2249
+ <p className="text-sm font-medium text-muted-foreground">With suggestions (autocomplete) — type &quot;fly&quot; or &quot;back&quot;</p>
2250
+ <TagsInputShowcase
2251
+ placeholder="Add a stroke or event…"
2252
+ suggestions={[
2253
+ "Butterfly",
2254
+ "Backstroke",
2255
+ "Breaststroke",
2256
+ "Freestyle",
2257
+ "Individual Medley",
2258
+ "50m Freestyle",
2259
+ "100m Butterfly",
2260
+ "200m Backstroke",
2261
+ "400m IM",
2262
+ "Medley Relay",
2263
+ ]}
2264
+ />
2265
+ </div>
2201
2266
  <div className="space-y-3">
2202
2267
  <p className="text-sm font-medium text-muted-foreground">Max tags (4)</p>
2203
2268
  <TagsInputShowcase
@@ -2426,6 +2491,52 @@ export default function ComponentsPreview() {
2426
2491
  </div>
2427
2492
  </Section>
2428
2493
 
2494
+ <Section title="Native Select">
2495
+ <div className="grid gap-6 sm:grid-cols-2">
2496
+ <div className="space-y-2">
2497
+ <Label htmlFor="ns-focus">Design Focus Area</Label>
2498
+ <NativeSelect id="ns-focus" defaultValue="components">
2499
+ <option value="">Choose a focus area</option>
2500
+ <option value="tokens">Design Tokens</option>
2501
+ <option value="components">Components</option>
2502
+ <option value="patterns">Patterns</option>
2503
+ <option value="a11y">Accessibility</option>
2504
+ <option value="motion">Motion &amp; Animation</option>
2505
+ </NativeSelect>
2506
+ </div>
2507
+ <div className="space-y-2">
2508
+ <Label htmlFor="ns-disabled">Disabled</Label>
2509
+ <NativeSelect id="ns-disabled" disabled defaultValue="components">
2510
+ <option value="components">Components (locked)</option>
2511
+ </NativeSelect>
2512
+ </div>
2513
+ <div className="space-y-2">
2514
+ <Label htmlFor="ns-invalid">Invalid</Label>
2515
+ <NativeSelect id="ns-invalid" aria-invalid defaultValue="">
2516
+ <option value="">Select a valid option</option>
2517
+ <option value="tokens">Design Tokens</option>
2518
+ </NativeSelect>
2519
+ </div>
2520
+ <div className="space-y-2">
2521
+ <p className="text-sm font-medium text-foreground">Sizes</p>
2522
+ <div className="flex flex-col gap-2">
2523
+ <NativeSelect size="sm" defaultValue="sm">
2524
+ <option value="sm">Small (sm)</option>
2525
+ </NativeSelect>
2526
+ <NativeSelect size="default" defaultValue="default">
2527
+ <option value="default">Default</option>
2528
+ </NativeSelect>
2529
+ <NativeSelect size="lg" defaultValue="lg">
2530
+ <option value="lg">Large (lg)</option>
2531
+ </NativeSelect>
2532
+ <NativeSelect size="xl" defaultValue="xl">
2533
+ <option value="xl">Extra Large (xl)</option>
2534
+ </NativeSelect>
2535
+ </div>
2536
+ </div>
2537
+ </div>
2538
+ </Section>
2539
+
2429
2540
  <Section title="Textarea">
2430
2541
  <div className="grid gap-6 sm:grid-cols-2">
2431
2542
  <div className="space-y-2">
@@ -2526,6 +2637,9 @@ export default function ComponentsPreview() {
2526
2637
  </Section>
2527
2638
 
2528
2639
  <Section title="Dropdown Menu">
2640
+ {/* flex wrapper keeps the trigger button content-width — Section's
2641
+ Card is a flex column, so a bare trigger stretches to full width. */}
2642
+ <div className="flex">
2529
2643
  <DropdownMenu>
2530
2644
  <DropdownMenuTrigger asChild>
2531
2645
  <Button variant="outline" className="gap-2">
@@ -2552,6 +2666,7 @@ export default function ComponentsPreview() {
2552
2666
  <DropdownMenuItem variant="destructive">Scratch swimmer</DropdownMenuItem>
2553
2667
  </DropdownMenuContent>
2554
2668
  </DropdownMenu>
2669
+ </div>
2555
2670
  </Section>
2556
2671
 
2557
2672
  <Section title="Command">
@@ -0,0 +1,55 @@
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
+ const codeVariants = cva("font-mono text-muted-foreground bg-muted", {
9
+ variants: {
10
+ variant: {
11
+ inline: "inline rounded px-[0.3em] py-[0.1em] text-xs",
12
+ block:
13
+ "block w-full rounded-md border border-border px-3 py-2.5 text-sm leading-relaxed overflow-x-auto whitespace-pre outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
14
+ },
15
+ size: {
16
+ sm: "",
17
+ default: "",
18
+ lg: "",
19
+ },
20
+ },
21
+ compoundVariants: [
22
+ { variant: "inline", size: "sm", class: "text-xs" },
23
+ { variant: "inline", size: "default", class: "text-xs" },
24
+ { variant: "inline", size: "lg", class: "text-sm" },
25
+ { variant: "block", size: "sm", class: "text-xs" },
26
+ { variant: "block", size: "default", class: "text-sm" },
27
+ { variant: "block", size: "lg", class: "text-base" },
28
+ ],
29
+ defaultVariants: {
30
+ variant: "inline",
31
+ size: "default",
32
+ },
33
+ })
34
+
35
+ export interface CodeProps
36
+ extends React.ComponentProps<"code">,
37
+ VariantProps<typeof codeVariants> {}
38
+
39
+ function Code({ className, variant, size, children, ...props }: CodeProps) {
40
+ const isBlock = variant === "block"
41
+ return (
42
+ <code
43
+ data-slot={isBlock ? "code-block" : "code"}
44
+ className={cn(codeVariants({ variant, size }), className)}
45
+ // Block code scrolls horizontally (overflow-x-auto); make the scroll
46
+ // region reachable by keyboard so it satisfies axe scrollable-region-focusable.
47
+ tabIndex={isBlock ? 0 : undefined}
48
+ {...props}
49
+ >
50
+ {children}
51
+ </code>
52
+ )
53
+ }
54
+
55
+ export { Code, codeVariants }
@@ -40,7 +40,6 @@ export * from "./scroll-area";
40
40
  export * from "./select";
41
41
  export * from "./separator";
42
42
  export * from "./sheet";
43
- export * from "./bottom-sheet";
44
43
  export * from "./sidebar";
45
44
  export * from "./skeleton";
46
45
  export * from "./slider";
@@ -26,9 +26,9 @@ const indicatorDotVariants = cva(
26
26
  },
27
27
  size: {
28
28
  // Dot-only base dimensions; labeled mode overrides height + min-width below
29
- sm: "size-1.5",
30
- default: "size-2.5",
31
- lg: "size-3.5",
29
+ sm: "size-2",
30
+ default: "size-3",
31
+ lg: "size-4",
32
32
  },
33
33
  },
34
34
  defaultVariants: {
@@ -125,10 +125,12 @@ function Indicator({
125
125
  className={cn(
126
126
  indicatorDotVariants({ variant, size }),
127
127
  positionMap[position],
128
- // Labeled mode: override to minimum 14px text + taller dot (AAA SC 1.4.4)
129
- showLabel && "text-xs leading-none px-1",
130
- showLabel && size === "default" && "h-4 min-w-4",
131
- showLabel && size === "lg" && "h-5 min-w-5",
128
+ // Labeled mode: text stays at the 14px floor (AAA SC 1.4.4); the
129
+ // circle around it is sized up via height + min-width so the count
130
+ // reads with breathing room instead of cramping the digits.
131
+ showLabel && "text-xs leading-none px-1.5",
132
+ showLabel && size === "default" && "h-5 min-w-5",
133
+ showLabel && size === "lg" && "h-6 min-w-6",
132
134
  withBorder && "ring-2 ring-background",
133
135
  indicatorClassName
134
136
  )}
@@ -0,0 +1,68 @@
1
+ import * as React from "react"
2
+ import { cva, type VariantProps } from "class-variance-authority"
3
+ import { ChevronDown } from "lucide-react"
4
+
5
+ import { cn } from "../../lib/utils"
6
+
7
+ const nativeSelectVariants = cva(
8
+ "w-full min-w-0 appearance-none rounded-md border border-input bg-transparent shadow-xs outline-none text-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 dark:bg-input/30 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",
9
+ {
10
+ variants: {
11
+ size: {
12
+ sm: "h-8 px-2.5 pr-8 py-1 text-sm",
13
+ default: "h-9 px-3 pr-9 py-1 text-base md:text-sm",
14
+ lg: "h-10 px-4 pr-10 py-2 text-base",
15
+ xl: "h-11 px-4 pr-11 py-2 text-base",
16
+ },
17
+ },
18
+ defaultVariants: {
19
+ size: "default",
20
+ },
21
+ }
22
+ )
23
+
24
+ const chevronSizeMap: Record<string, string> = {
25
+ sm: "size-3.5 right-2.5",
26
+ default: "size-4 right-3",
27
+ lg: "size-4 right-3",
28
+ xl: "size-4 right-3.5",
29
+ }
30
+
31
+ function NativeSelect({
32
+ className,
33
+ size,
34
+ children,
35
+ ...props
36
+ }: Omit<React.ComponentProps<"select">, "size"> &
37
+ VariantProps<typeof nativeSelectVariants>) {
38
+ const resolvedSize = size ?? "default"
39
+ const chevronClasses = chevronSizeMap[resolvedSize] ?? chevronSizeMap["default"]
40
+
41
+ return (
42
+ <div data-slot="native-select" className="relative w-full">
43
+ <select
44
+ data-slot="native-select-element"
45
+ data-size={resolvedSize}
46
+ className={cn(nativeSelectVariants({ size, className }))}
47
+ style={{
48
+ transitionProperty: "color, box-shadow",
49
+ transitionDuration: "var(--duration-fast)",
50
+ transitionTimingFunction: "var(--ease-out)",
51
+ }}
52
+ {...props}
53
+ >
54
+ {children}
55
+ </select>
56
+ <ChevronDown
57
+ strokeWidth={1.5}
58
+ aria-hidden
59
+ className={cn(
60
+ "pointer-events-none absolute top-1/2 -translate-y-1/2 text-muted-foreground",
61
+ chevronClasses
62
+ )}
63
+ />
64
+ </div>
65
+ )
66
+ }
67
+
68
+ export { NativeSelect, nativeSelectVariants }
@@ -57,8 +57,18 @@ function NavigationMenuItem({
57
57
  function NavigationMenuTrigger({
58
58
  className,
59
59
  children,
60
+ onClick,
61
+ onPointerEnter,
60
62
  ...props
61
63
  }: React.ComponentProps<typeof NavigationMenuPrimitive.Trigger>) {
64
+ // Radix opens this on hover, but a click on an already-open trigger toggles
65
+ // it closed — so "hover then click" flickers the panel open→closed and feels
66
+ // buggy. Swallow ONLY the click that lands right after a hover-open: record
67
+ // the hover timestamp, then preventDefault on a click within 700ms while the
68
+ // panel is open. Because Radix composes the prop handler before its internal
69
+ // toggle (with checkForDefaultPrevented), preventing the default skips the
70
+ // close. Keyboard Enter-to-close still works — it has no recent pointer-enter.
71
+ const hoverOpenedAt = React.useRef(0)
62
72
  return (
63
73
  <NavigationMenuPrimitive.Trigger
64
74
  data-slot="navigation-menu-trigger"
@@ -66,6 +76,19 @@ function NavigationMenuTrigger({
66
76
  "group inline-flex h-9 w-max items-center justify-center gap-1 rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-hidden disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50",
67
77
  className
68
78
  )}
79
+ onPointerEnter={(event) => {
80
+ hoverOpenedAt.current = event.timeStamp
81
+ onPointerEnter?.(event)
82
+ }}
83
+ onClick={(event) => {
84
+ if (
85
+ event.currentTarget.dataset.state === "open" &&
86
+ event.timeStamp - hoverOpenedAt.current < 700
87
+ ) {
88
+ event.preventDefault()
89
+ }
90
+ onClick?.(event)
91
+ }}
69
92
  {...props}
70
93
  >
71
94
  {children}
@@ -50,10 +50,17 @@ function SheetContent({
50
50
  children,
51
51
  side = "right",
52
52
  showCloseButton = true,
53
+ showHandle = side === "bottom",
53
54
  ...props
54
55
  }: React.ComponentProps<typeof SheetPrimitive.Content> & {
55
56
  side?: "top" | "right" | "bottom" | "left"
56
57
  showCloseButton?: boolean
58
+ /**
59
+ * Bottom sheets only: render the centered grab-handle affordance at the top
60
+ * (the visual signal users read as "this panel came from the bottom").
61
+ * Defaults to `true` when `side="bottom"`, ignored for every other side.
62
+ */
63
+ showHandle?: boolean
57
64
  }) {
58
65
  // Apply the active portal theme scope to the content's className so any
59
66
  // theme-scoped CSS variables a consumer uses (`--shell-chrome-bg-rgb`,
@@ -74,22 +81,32 @@ function SheetContent({
74
81
  side === "top" &&
75
82
  "inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
76
83
  side === "bottom" &&
77
- "inset-x-0 bottom-0 h-auto border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
84
+ // Bottom sheets get the full mobile treatment: rounded top, capped
85
+ // height with internal scroll so a tall sheet keeps its footer
86
+ // reachable (svh tracks the dynamic viewport), safe-area padding,
87
+ // and gap-0 so header/content/footer own their own spacing.
88
+ "inset-x-0 bottom-0 h-auto max-h-[85svh] gap-0 overflow-y-auto rounded-t-xl border-t pb-[max(1rem,env(safe-area-inset-bottom))] data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
78
89
  portalThemeClass,
79
90
  className
80
91
  )}
81
92
  {...props}
82
93
  >
94
+ {side === "bottom" && showHandle && (
95
+ <div
96
+ aria-hidden="true"
97
+ className="mx-auto mt-3 mb-1 h-1.5 w-12 shrink-0 rounded-full bg-muted-foreground/30"
98
+ />
99
+ )}
83
100
  {children}
84
101
  {showCloseButton && (
85
102
  <SheetPrimitive.Close
86
103
  data-slot="sheet-close"
87
104
  // Matches the Dialog close button: top-4 right-4, rounded-xs, a 32px
88
- // (size-8) X glyph, opacity-70→100 on hover. Shared by Sheet AND
89
- // BottomSheet (both render SheetContent), so they read as one family
90
- // with Dialog. The one intentional difference from Dialog: a 44px
91
- // (size-11) hit target wrapping the 32px glyph, so it clears BADS's
92
- // touch-target floor — invisible since there's no box fill.
105
+ // (size-8) X glyph, opacity-70→100 on hover — so Sheet (every side,
106
+ // including bottom) reads as one family with Dialog. The one
107
+ // intentional difference from Dialog: a 44px (size-11) hit target
108
+ // wrapping the 32px glyph, so it clears BADS's touch-target floor —
109
+ // invisible since there's no box fill.
93
110
  className="absolute top-4 right-4 inline-flex size-11 items-center justify-center rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-8"
94
111
  style={{ strokeWidth: '1.5px' }}
95
112
  >
@@ -49,6 +49,11 @@ function Spinner({
49
49
  viewBox="0 0 24 24"
50
50
  aria-hidden="true"
51
51
  >
52
+ {/* Track and arc are concentric circles at the same radius and the
53
+ same 1.5 stroke width, so the spinner reads as one ring with a
54
+ moving highlight — not a thin track against a heavier filled arc.
55
+ pathLength={100} normalizes the circumference so strokeDasharray
56
+ "30 70" is exactly a 30% arc regardless of size. */}
52
57
  <circle
53
58
  className="opacity-25"
54
59
  cx="12"
@@ -57,10 +62,16 @@ function Spinner({
57
62
  stroke="currentColor"
58
63
  strokeWidth="1.5"
59
64
  />
60
- <path
65
+ <circle
61
66
  className="opacity-75"
62
- fill="currentColor"
63
- d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
67
+ cx="12"
68
+ cy="12"
69
+ r="10"
70
+ stroke="currentColor"
71
+ strokeWidth="1.5"
72
+ strokeLinecap="round"
73
+ pathLength={100}
74
+ strokeDasharray="30 70"
64
75
  />
65
76
  </svg>
66
77
  </span>
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import * as React from "react";
4
- import { XIcon } from "lucide-react";
4
+ import { XIcon, CheckIcon } from "lucide-react";
5
5
  import { cn } from "../../lib/utils";
6
6
 
7
7
  // ─── Types ────────────────────────────────────────────────────────────────────
@@ -22,6 +22,11 @@ export interface TagsInputProps
22
22
  allowDuplicates?: boolean;
23
23
  /** Characters that trigger tag creation in addition to Enter. Default: [","]. */
24
24
  delimiters?: string[];
25
+ /**
26
+ * Pool of suggestion strings shown in a dropdown as the user types.
27
+ * Already-added tags are excluded from the list automatically.
28
+ */
29
+ suggestions?: string[];
25
30
  }
26
31
 
27
32
  // ─── Component ────────────────────────────────────────────────────────────────
@@ -34,15 +39,30 @@ export function TagsInput({
34
39
  maxTags,
35
40
  allowDuplicates = false,
36
41
  delimiters = [","],
42
+ suggestions,
37
43
  className,
38
44
  ...props
39
45
  }: TagsInputProps) {
40
46
  const [inputValue, setInputValue] = React.useState("");
41
47
  const [focusedTagIndex, setFocusedTagIndex] = React.useState<number | null>(null);
48
+ const [activeIndex, setActiveIndex] = React.useState(-1);
49
+ const [showSuggestions, setShowSuggestions] = React.useState(false);
42
50
  const inputRef = React.useRef<HTMLInputElement>(null);
51
+ const listboxRef = React.useRef<HTMLUListElement>(null);
52
+ const listboxId = React.useId();
43
53
 
44
54
  const atMax = maxTags !== undefined && value.length >= maxTags;
45
55
 
56
+ const filteredSuggestions = React.useMemo(() => {
57
+ if (!suggestions?.length || !inputValue.trim()) return [];
58
+ const lower = inputValue.toLowerCase();
59
+ return suggestions.filter(
60
+ (s) => s.toLowerCase().includes(lower) && (allowDuplicates || !value.includes(s))
61
+ );
62
+ }, [suggestions, inputValue, value, allowDuplicates]);
63
+
64
+ const isOpen = showSuggestions && filteredSuggestions.length > 0;
65
+
46
66
  const addTag = React.useCallback(
47
67
  (raw: string) => {
48
68
  const trimmed = raw.trim();
@@ -51,6 +71,8 @@ export function TagsInput({
51
71
  if (!allowDuplicates && value.includes(trimmed)) return;
52
72
  onValueChange([...value, trimmed]);
53
73
  setInputValue("");
74
+ setShowSuggestions(false);
75
+ setActiveIndex(-1);
54
76
  },
55
77
  [atMax, allowDuplicates, value, onValueChange]
56
78
  );
@@ -64,28 +86,79 @@ export function TagsInput({
64
86
  [value, onValueChange]
65
87
  );
66
88
 
89
+ const selectSuggestion = React.useCallback(
90
+ (suggestion: string) => {
91
+ addTag(suggestion);
92
+ inputRef.current?.focus();
93
+ },
94
+ [addTag]
95
+ );
96
+
97
+ // Scroll the active option into view
98
+ React.useEffect(() => {
99
+ if (!isOpen || activeIndex < 0) return;
100
+ const li = listboxRef.current?.children[activeIndex] as HTMLElement | undefined;
101
+ li?.scrollIntoView({ block: "nearest" });
102
+ }, [activeIndex, isOpen]);
103
+
67
104
  const handleKeyDown = React.useCallback(
68
105
  (e: React.KeyboardEvent<HTMLInputElement>) => {
106
+ if (e.key === "ArrowDown") {
107
+ if (!isOpen && filteredSuggestions.length > 0) {
108
+ setShowSuggestions(true);
109
+ setActiveIndex(0);
110
+ } else if (isOpen) {
111
+ e.preventDefault();
112
+ setActiveIndex((i) => Math.min(i + 1, filteredSuggestions.length - 1));
113
+ }
114
+ return;
115
+ }
116
+ if (e.key === "ArrowUp" && isOpen) {
117
+ e.preventDefault();
118
+ setActiveIndex((i) => (i <= 0 ? 0 : i - 1));
119
+ return;
120
+ }
69
121
  if (e.key === "Enter") {
70
122
  e.preventDefault();
71
- addTag(inputValue);
72
- } else if (e.key === "Backspace" && inputValue === "") {
123
+ if (isOpen && activeIndex >= 0) {
124
+ selectSuggestion(filteredSuggestions[activeIndex]);
125
+ } else {
126
+ addTag(inputValue);
127
+ }
128
+ return;
129
+ }
130
+ if (e.key === "Escape") {
131
+ if (isOpen) {
132
+ setShowSuggestions(false);
133
+ setActiveIndex(-1);
134
+ } else {
135
+ setFocusedTagIndex(null);
136
+ }
137
+ return;
138
+ }
139
+ if (e.key === "Backspace" && inputValue === "") {
73
140
  e.preventDefault();
74
141
  if (focusedTagIndex !== null) {
75
142
  removeTag(focusedTagIndex);
76
143
  } else if (value.length > 0) {
77
144
  setFocusedTagIndex(value.length - 1);
78
145
  }
79
- } else if (e.key === "Delete" && inputValue === "" && focusedTagIndex !== null) {
146
+ return;
147
+ }
148
+ if (e.key === "Delete" && inputValue === "" && focusedTagIndex !== null) {
80
149
  e.preventDefault();
81
150
  removeTag(focusedTagIndex);
82
- } else if (e.key === "ArrowLeft" && inputValue === "") {
151
+ return;
152
+ }
153
+ if (e.key === "ArrowLeft" && inputValue === "") {
83
154
  if (focusedTagIndex === null && value.length > 0) {
84
155
  setFocusedTagIndex(value.length - 1);
85
156
  } else if (focusedTagIndex !== null && focusedTagIndex > 0) {
86
157
  setFocusedTagIndex(focusedTagIndex - 1);
87
158
  }
88
- } else if (e.key === "ArrowRight" && inputValue === "") {
159
+ return;
160
+ }
161
+ if (e.key === "ArrowRight" && inputValue === "") {
89
162
  if (focusedTagIndex !== null) {
90
163
  if (focusedTagIndex < value.length - 1) {
91
164
  setFocusedTagIndex(focusedTagIndex + 1);
@@ -93,13 +166,21 @@ export function TagsInput({
93
166
  setFocusedTagIndex(null);
94
167
  }
95
168
  }
96
- } else if (e.key === "Escape") {
97
- setFocusedTagIndex(null);
98
- } else {
99
- setFocusedTagIndex(null);
169
+ return;
100
170
  }
171
+ setFocusedTagIndex(null);
101
172
  },
102
- [inputValue, focusedTagIndex, value, addTag, removeTag]
173
+ [
174
+ inputValue,
175
+ focusedTagIndex,
176
+ value,
177
+ addTag,
178
+ removeTag,
179
+ selectSuggestion,
180
+ isOpen,
181
+ activeIndex,
182
+ filteredSuggestions,
183
+ ]
103
184
  );
104
185
 
105
186
  const handleInputChange = React.useCallback(
@@ -110,6 +191,8 @@ export function TagsInput({
110
191
  addTag(val.slice(0, -1));
111
192
  } else {
112
193
  setInputValue(val);
194
+ setShowSuggestions(true);
195
+ setActiveIndex(-1);
113
196
  }
114
197
  setFocusedTagIndex(null);
115
198
  },
@@ -124,76 +207,134 @@ export function TagsInput({
124
207
  : undefined;
125
208
 
126
209
  return (
127
- <div
128
- data-slot="tags-input"
129
- data-disabled={disabled || undefined}
130
- aria-disabled={disabled || undefined}
131
- onClick={() => !disabled && inputRef.current?.focus()}
132
- className={cn(
133
- "flex min-h-11 flex-wrap items-center gap-1.5 rounded-md border border-input bg-background px-3 py-2",
134
- "cursor-text",
135
- "focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",
136
- disabled && "cursor-not-allowed border-border/50 bg-muted/30 pointer-events-none",
137
- className
138
- )}
139
- {...props}
140
- >
141
- {value.map((tag, index) => (
142
- <span
143
- key={`${tag}-${index}`}
144
- data-slot="tags-input-item"
145
- data-focused={focusedTagIndex === index || undefined}
210
+ <div className="relative">
211
+ <div
212
+ data-slot="tags-input"
213
+ data-disabled={disabled || undefined}
214
+ aria-disabled={disabled || undefined}
215
+ onClick={() => !disabled && inputRef.current?.focus()}
216
+ className={cn(
217
+ "flex min-h-11 flex-wrap items-center gap-1.5 rounded-md border border-input bg-background px-3 py-2",
218
+ "cursor-text",
219
+ "focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",
220
+ disabled && "cursor-not-allowed border-border/50 bg-muted/30 pointer-events-none",
221
+ className
222
+ )}
223
+ {...props}
224
+ >
225
+ {value.map((tag, index) => (
226
+ <span
227
+ key={`${tag}-${index}`}
228
+ data-slot="tags-input-item"
229
+ data-focused={focusedTagIndex === index || undefined}
230
+ className={cn(
231
+ "inline-flex max-w-[160px] items-center gap-1 rounded-md px-2 py-0.5",
232
+ "text-sm font-medium transition-colors",
233
+ disabled
234
+ ? "bg-muted text-muted-foreground"
235
+ : "bg-secondary text-secondary-foreground",
236
+ !disabled && focusedTagIndex === index && "ring-2 ring-ring ring-offset-1 ring-offset-background"
237
+ )}
238
+ >
239
+ <span className="truncate">{tag}</span>
240
+ {!disabled && (
241
+ <button
242
+ type="button"
243
+ data-slot="tags-input-item-delete"
244
+ aria-label={`Remove ${tag}`}
245
+ tabIndex={-1}
246
+ onClick={(e) => {
247
+ e.stopPropagation();
248
+ removeTag(index);
249
+ }}
250
+ className={cn(
251
+ "shrink-0 rounded-sm p-0.5",
252
+ "text-secondary-foreground/70 hover:text-secondary-foreground",
253
+ "transition-colors",
254
+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
255
+ )}
256
+ style={{
257
+ transitionDuration: "var(--duration-fast)",
258
+ transitionTimingFunction: "var(--ease-out)",
259
+ }}
260
+ >
261
+ <XIcon className="size-3" strokeWidth={1.5} aria-hidden />
262
+ </button>
263
+ )}
264
+ </span>
265
+ ))}
266
+ <input
267
+ ref={inputRef}
268
+ type="text"
269
+ role="combobox"
270
+ aria-expanded={isOpen}
271
+ aria-haspopup="listbox"
272
+ aria-controls={isOpen ? listboxId : undefined}
273
+ aria-activedescendant={isOpen && activeIndex >= 0 ? `${listboxId}-${activeIndex}` : undefined}
274
+ aria-autocomplete={suggestions?.length ? "list" : "none"}
275
+ value={inputValue}
276
+ onChange={handleInputChange}
277
+ onKeyDown={handleKeyDown}
278
+ onFocus={() => inputValue && setShowSuggestions(true)}
279
+ onBlur={() => {
280
+ // Small delay so option click fires before blur closes the list
281
+ setTimeout(() => setShowSuggestions(false), 120);
282
+ }}
283
+ disabled={disabled || atMax}
284
+ placeholder={inputPlaceholder}
285
+ aria-label={placeholder ?? "Add tags, press Enter or comma to confirm"}
146
286
  className={cn(
147
- "inline-flex max-w-[160px] items-center gap-1 rounded-md px-2 py-0.5",
148
- "text-sm font-medium transition-colors",
149
- disabled
150
- ? "bg-muted text-muted-foreground"
151
- : "bg-secondary text-secondary-foreground",
152
- !disabled && focusedTagIndex === index && "ring-2 ring-ring ring-offset-1 ring-offset-background"
287
+ "min-w-[80px] flex-1 bg-transparent text-sm outline-none",
288
+ "placeholder:text-muted-foreground",
289
+ "disabled:cursor-not-allowed disabled:opacity-0"
290
+ )}
291
+ />
292
+ </div>
293
+
294
+ {isOpen && (
295
+ <ul
296
+ ref={listboxRef}
297
+ id={listboxId}
298
+ role="listbox"
299
+ aria-label="Suggestions"
300
+ className={cn(
301
+ "absolute left-0 right-0 z-50 mt-1 max-h-56 overflow-y-auto",
302
+ "rounded-md border border-input bg-popover shadow-md",
303
+ "py-1 text-sm text-popover-foreground"
153
304
  )}
154
305
  >
155
- <span className="truncate">{tag}</span>
156
- {!disabled && (
157
- <button
158
- type="button"
159
- data-slot="tags-input-item-delete"
160
- aria-label={`Remove ${tag}`}
161
- tabIndex={-1}
162
- onClick={(e) => {
163
- e.stopPropagation();
164
- removeTag(index);
306
+ {filteredSuggestions.map((suggestion, index) => (
307
+ <li
308
+ key={suggestion}
309
+ id={`${listboxId}-${index}`}
310
+ role="option"
311
+ aria-selected={index === activeIndex}
312
+ onMouseDown={(e) => {
313
+ // prevent input blur before click registers
314
+ e.preventDefault();
315
+ selectSuggestion(suggestion);
165
316
  }}
317
+ onMouseEnter={() => setActiveIndex(index)}
166
318
  className={cn(
167
- "shrink-0 rounded-sm p-0.5",
168
- "text-secondary-foreground/70 hover:text-secondary-foreground",
319
+ "flex items-center gap-2 px-3 py-1.5 cursor-pointer select-none",
169
320
  "transition-colors",
170
- "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
321
+ index === activeIndex
322
+ ? "bg-accent text-accent-foreground"
323
+ : "hover:bg-accent hover:text-accent-foreground"
171
324
  )}
172
325
  style={{
173
326
  transitionDuration: "var(--duration-fast)",
174
327
  transitionTimingFunction: "var(--ease-out)",
175
328
  }}
176
329
  >
177
- <XIcon className="size-3" strokeWidth={1.5} aria-hidden />
178
- </button>
179
- )}
180
- </span>
181
- ))}
182
- <input
183
- ref={inputRef}
184
- type="text"
185
- value={inputValue}
186
- onChange={handleInputChange}
187
- onKeyDown={handleKeyDown}
188
- disabled={disabled || atMax}
189
- placeholder={inputPlaceholder}
190
- aria-label={placeholder ?? "Add tags, press Enter or comma to confirm"}
191
- className={cn(
192
- "min-w-[80px] flex-1 bg-transparent text-sm outline-none",
193
- "placeholder:text-muted-foreground",
194
- "disabled:cursor-not-allowed disabled:opacity-0"
195
- )}
196
- />
330
+ {suggestion}
331
+ {value.includes(suggestion) && (
332
+ <CheckIcon className="ml-auto h-3.5 w-3.5 text-primary" aria-hidden="true" strokeWidth={1.5} />
333
+ )}
334
+ </li>
335
+ ))}
336
+ </ul>
337
+ )}
197
338
  </div>
198
339
  );
199
340
  }
@@ -1,133 +0,0 @@
1
- "use client"
2
-
3
- import * as React from "react"
4
-
5
- import { cn } from "../../lib/utils"
6
- import {
7
- Sheet,
8
- SheetClose,
9
- SheetContent,
10
- SheetDescription,
11
- SheetFooter,
12
- SheetHeader,
13
- SheetTitle,
14
- SheetTrigger,
15
- } from "./sheet"
16
-
17
- /**
18
- * BottomSheet — a bottom-anchored disclosure surface, the dominant
19
- * secondary-content container in current production apps (Raycast, Linear
20
- * mobile, Arc). Built on the Radix Dialog–backed Sheet primitive with
21
- * `side="bottom"`, so it inherits Sheet's focus trap, ESC/overlay dismissal,
22
- * scroll lock, and AAA-tuned focus ring for free.
23
- *
24
- * What this adds over `<SheetContent side="bottom">`:
25
- * - Rounded top corners + a centered grab-handle affordance (the visual
26
- * signal users now read as "this panel came from the bottom").
27
- * - Mobile-first sizing: caps at 85svh and scrolls internally so a tall
28
- * sheet never pushes its footer off-screen.
29
- * - A coherent BottomSheet* API surface so callers don't mix Sheet and
30
- * BottomSheet names.
31
- *
32
- * Not draggable. This wrapper is intentionally built on Radix, not vaul, so
33
- * there are no drag-to-dismiss physics or snap points — dismissal is via the
34
- * grab handle (decorative), overlay click, ESC, or an explicit close button.
35
- * If a fork needs true drag/snap behavior, that's a separate vaul-backed
36
- * primitive and a deliberate dependency decision (see CHANGELOG 2026-05-31).
37
- */
38
-
39
- function BottomSheet({ ...props }: React.ComponentProps<typeof Sheet>) {
40
- return <Sheet data-slot="bottom-sheet" {...props} />
41
- }
42
-
43
- function BottomSheetTrigger({
44
- ...props
45
- }: React.ComponentProps<typeof SheetTrigger>) {
46
- return <SheetTrigger data-slot="bottom-sheet-trigger" {...props} />
47
- }
48
-
49
- function BottomSheetClose({
50
- ...props
51
- }: React.ComponentProps<typeof SheetClose>) {
52
- return <SheetClose data-slot="bottom-sheet-close" {...props} />
53
- }
54
-
55
- function BottomSheetContent({
56
- className,
57
- children,
58
- showHandle = true,
59
- showCloseButton = true,
60
- ...props
61
- }: React.ComponentProps<typeof SheetContent> & {
62
- /** Show the decorative grab-handle affordance at the top. Default true. */
63
- showHandle?: boolean
64
- }) {
65
- return (
66
- <SheetContent
67
- side="bottom"
68
- showCloseButton={showCloseButton}
69
- data-slot="bottom-sheet-content"
70
- className={cn(
71
- // Rounded top + capped height + internal scroll so a tall sheet keeps
72
- // its footer reachable. svh tracks the mobile dynamic viewport.
73
- "max-h-[85svh] gap-0 overflow-y-auto rounded-t-xl pb-[max(1rem,env(safe-area-inset-bottom))]",
74
- className
75
- )}
76
- {...props}
77
- >
78
- {showHandle && (
79
- <div
80
- aria-hidden="true"
81
- className="mx-auto mt-3 mb-1 h-1.5 w-12 shrink-0 rounded-full bg-muted-foreground/30"
82
- />
83
- )}
84
- {children}
85
- </SheetContent>
86
- )
87
- }
88
-
89
- // Header/Footer/Title/Description are 1:1 with Sheet's — re-exported under the
90
- // BottomSheet name so callers get a single coherent API.
91
- function BottomSheetHeader({
92
- ...props
93
- }: React.ComponentProps<typeof SheetHeader>) {
94
- return <SheetHeader data-slot="bottom-sheet-header" {...props} />
95
- }
96
-
97
- function BottomSheetFooter({
98
- ...props
99
- }: React.ComponentProps<typeof SheetFooter>) {
100
- return <SheetFooter data-slot="bottom-sheet-footer" {...props} />
101
- }
102
-
103
- function BottomSheetTitle({
104
- className,
105
- children,
106
- ...props
107
- }: React.ComponentProps<typeof SheetTitle>) {
108
- // Render as a real h3 (Sheet/Dialog Title defaults to h2 and ships no size).
109
- // asChild keeps the Radix Title wiring so the sheet stays aria-labelledby it,
110
- // while the h3 carries an explicit heading size for clear hierarchy.
111
- return (
112
- <SheetTitle asChild data-slot="bottom-sheet-title" {...props}>
113
- <h3 className={cn("text-lg", className)}>{children}</h3>
114
- </SheetTitle>
115
- )
116
- }
117
-
118
- function BottomSheetDescription({
119
- ...props
120
- }: React.ComponentProps<typeof SheetDescription>) {
121
- return <SheetDescription data-slot="bottom-sheet-description" {...props} />
122
- }
123
-
124
- export {
125
- BottomSheet,
126
- BottomSheetTrigger,
127
- BottomSheetClose,
128
- BottomSheetContent,
129
- BottomSheetHeader,
130
- BottomSheetFooter,
131
- BottomSheetTitle,
132
- BottomSheetDescription,
133
- }