@behavioral-agentic-design-system/core 0.32.1 → 0.34.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.32.1",
3
+ "version": "0.34.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)",
@@ -414,6 +414,7 @@ import {
414
414
  } from "@behavioral-agentic-design-system/core/components/ui/tree-select";
415
415
  import { Questionnaire } from "@behavioral-agentic-design-system/core/components/ui/questionnaire";
416
416
  import { ToggleTip } from "@behavioral-agentic-design-system/core/components/ui/toggle-tip";
417
+ import { SearchInput } from "@behavioral-agentic-design-system/core/components/ui/search-input";
417
418
 
418
419
  // Stable, deterministic data for ScrollArea — never use Math.random in
419
420
  // SSR-rendered output, it causes hydration mismatches.
@@ -2952,6 +2953,51 @@ export default function ComponentsPreview() {
2952
2953
  </Select>
2953
2954
  </div>
2954
2955
  </div>
2956
+ <div className="mt-6 space-y-3">
2957
+ <p className="text-sm text-muted-foreground">Sizes — sm · default · lg · xl</p>
2958
+ <div className="flex flex-wrap items-end gap-3">
2959
+ <Select>
2960
+ <SelectTrigger size="sm" className="w-[180px]" aria-label="Environment (small)">
2961
+ <SelectValue placeholder="Environment" />
2962
+ </SelectTrigger>
2963
+ <SelectContent>
2964
+ <SelectItem value="prod">Production</SelectItem>
2965
+ <SelectItem value="staging">Staging</SelectItem>
2966
+ <SelectItem value="dev">Development</SelectItem>
2967
+ </SelectContent>
2968
+ </Select>
2969
+ <Select>
2970
+ <SelectTrigger size="default" className="w-[180px]" aria-label="Environment (default)">
2971
+ <SelectValue placeholder="Environment" />
2972
+ </SelectTrigger>
2973
+ <SelectContent>
2974
+ <SelectItem value="prod">Production</SelectItem>
2975
+ <SelectItem value="staging">Staging</SelectItem>
2976
+ <SelectItem value="dev">Development</SelectItem>
2977
+ </SelectContent>
2978
+ </Select>
2979
+ <Select>
2980
+ <SelectTrigger size="lg" className="w-[180px]" aria-label="Environment (large)">
2981
+ <SelectValue placeholder="Environment" />
2982
+ </SelectTrigger>
2983
+ <SelectContent>
2984
+ <SelectItem value="prod">Production</SelectItem>
2985
+ <SelectItem value="staging">Staging</SelectItem>
2986
+ <SelectItem value="dev">Development</SelectItem>
2987
+ </SelectContent>
2988
+ </Select>
2989
+ <Select>
2990
+ <SelectTrigger size="xl" className="w-[180px]" aria-label="Environment (extra-large)">
2991
+ <SelectValue placeholder="Environment" />
2992
+ </SelectTrigger>
2993
+ <SelectContent>
2994
+ <SelectItem value="prod">Production</SelectItem>
2995
+ <SelectItem value="staging">Staging</SelectItem>
2996
+ <SelectItem value="dev">Development</SelectItem>
2997
+ </SelectContent>
2998
+ </Select>
2999
+ </div>
3000
+ </div>
2955
3001
  </Section>
2956
3002
 
2957
3003
  <Section title="Textarea">
@@ -6066,6 +6112,9 @@ export default function ComponentsPreview() {
6066
6112
  <Section title="SkeletonTable">
6067
6113
  <SkeletonTableShowcase />
6068
6114
  </Section>
6115
+ <Section title="SearchInput">
6116
+ <SearchInputShowcase />
6117
+ </Section>
6069
6118
  </div>
6070
6119
  </div>
6071
6120
  );
@@ -11734,3 +11783,43 @@ function SkeletonTableShowcase() {
11734
11783
  </div>
11735
11784
  );
11736
11785
  }
11786
+
11787
+ function SearchInputShowcase() {
11788
+ const [q, setQ] = React.useState("");
11789
+ const [loading, setLoading] = React.useState(false);
11790
+
11791
+ function handleSearch(val: string) {
11792
+ if (!val.trim()) return;
11793
+ setLoading(true);
11794
+ setTimeout(() => setLoading(false), 800);
11795
+ }
11796
+
11797
+ return (
11798
+ <div className="space-y-4">
11799
+ <div>
11800
+ <p className="mb-3 text-xs font-medium text-muted-foreground">Sizes</p>
11801
+ <div className="flex flex-col gap-2 max-w-xs">
11802
+ <SearchInput size="sm" placeholder="Size sm — h-8" />
11803
+ <SearchInput size="default" placeholder="Size default — h-9" />
11804
+ <SearchInput size="lg" placeholder="Size lg — h-11 (SC 2.5.5 touch target)" />
11805
+ </div>
11806
+ </div>
11807
+ <div>
11808
+ <p className="mb-3 text-xs font-medium text-muted-foreground">With clear + loading</p>
11809
+ <div className="flex flex-col gap-2 max-w-xs">
11810
+ <SearchInput
11811
+ value={q}
11812
+ onValueChange={setQ}
11813
+ onSearch={handleSearch}
11814
+ loading={loading}
11815
+ placeholder="Type and press Enter…"
11816
+ />
11817
+ </div>
11818
+ </div>
11819
+ <div>
11820
+ <p className="mb-3 text-xs font-medium text-muted-foreground">Disabled</p>
11821
+ <SearchInput value="accessibility" disabled className="max-w-xs" />
11822
+ </div>
11823
+ </div>
11824
+ );
11825
+ }
@@ -0,0 +1,136 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { LoaderCircleIcon, SearchIcon, XIcon } from "lucide-react"
5
+
6
+ import { cn } from "../../lib/utils"
7
+
8
+ export interface SearchInputProps extends Omit<React.ComponentProps<"input">, "onChange" | "type" | "size"> {
9
+ value?: string
10
+ onValueChange?: (value: string) => void
11
+ onSearch?: (value: string) => void
12
+ placeholder?: string
13
+ disabled?: boolean
14
+ loading?: boolean
15
+ size?: "sm" | "default" | "lg"
16
+ className?: string
17
+ }
18
+
19
+ function SearchInput({
20
+ value,
21
+ onValueChange,
22
+ onSearch,
23
+ placeholder = "Search…",
24
+ disabled = false,
25
+ loading = false,
26
+ size = "default",
27
+ className,
28
+ ...props
29
+ }: SearchInputProps) {
30
+ const inputRef = React.useRef<HTMLInputElement>(null)
31
+
32
+ function handleChange(e: React.ChangeEvent<HTMLInputElement>) {
33
+ onValueChange?.(e.target.value)
34
+ }
35
+
36
+ function handleClear() {
37
+ onValueChange?.("")
38
+ onSearch?.("")
39
+ inputRef.current?.focus()
40
+ }
41
+
42
+ function handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {
43
+ if (e.key === "Enter") {
44
+ onSearch?.(value ?? "")
45
+ }
46
+ if (e.key === "Escape") {
47
+ handleClear()
48
+ }
49
+ }
50
+
51
+ const showClear = !loading && (value?.length ?? 0) > 0
52
+
53
+ return (
54
+ <div
55
+ role="search"
56
+ data-slot="search-input"
57
+ data-size={size}
58
+ className={cn(
59
+ "relative flex items-center overflow-hidden rounded-md border border-input bg-background",
60
+ "ring-offset-background transition-colors focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",
61
+ {
62
+ "h-8 text-xs": size === "sm",
63
+ "h-9 text-sm": size === "default",
64
+ "h-11 text-base": size === "lg",
65
+ },
66
+ disabled && "cursor-not-allowed opacity-50",
67
+ className
68
+ )}
69
+ >
70
+ <span
71
+ aria-hidden="true"
72
+ className={cn(
73
+ "pointer-events-none flex shrink-0 items-center text-muted-foreground",
74
+ {
75
+ "pl-2.5": size === "sm",
76
+ "pl-3": size === "default" || size === "lg",
77
+ }
78
+ )}
79
+ >
80
+ {loading ? (
81
+ <LoaderCircleIcon
82
+ strokeWidth={1.5}
83
+ className={cn("animate-spin", size === "sm" ? "size-3.5" : "size-4")}
84
+ />
85
+ ) : (
86
+ <SearchIcon strokeWidth={1.5} className={size === "sm" ? "size-3.5" : "size-4"} />
87
+ )}
88
+ </span>
89
+ <input
90
+ ref={inputRef}
91
+ type="search"
92
+ role="searchbox"
93
+ value={value}
94
+ onChange={handleChange}
95
+ onKeyDown={handleKeyDown}
96
+ placeholder={placeholder}
97
+ disabled={disabled || loading}
98
+ className={cn(
99
+ "min-w-0 flex-1 bg-transparent font-normal text-foreground outline-none placeholder:text-muted-foreground",
100
+ "disabled:cursor-not-allowed",
101
+ "[&::-webkit-search-cancel-button]:hidden",
102
+ {
103
+ "px-2 py-1": size === "sm",
104
+ "px-2.5 py-2": size === "default",
105
+ "px-3 py-2.5": size === "lg",
106
+ }
107
+ )}
108
+ {...props}
109
+ />
110
+ {showClear && (
111
+ <button
112
+ type="button"
113
+ aria-label="Clear search"
114
+ onClick={handleClear}
115
+ className={cn(
116
+ "flex shrink-0 items-center justify-center text-muted-foreground",
117
+ "hover:text-foreground transition-colors",
118
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",
119
+ {
120
+ "mr-1.5 size-5 rounded": size === "sm",
121
+ "mr-2 size-6 rounded": size === "default" || size === "lg",
122
+ }
123
+ )}
124
+ style={{
125
+ transitionDuration: "var(--duration-fast)",
126
+ transitionTimingFunction: "var(--ease-out)",
127
+ }}
128
+ >
129
+ <XIcon strokeWidth={1.5} className={size === "sm" ? "size-3" : "size-3.5"} />
130
+ </button>
131
+ )}
132
+ </div>
133
+ )
134
+ }
135
+
136
+ export { SearchInput }
@@ -31,14 +31,14 @@ function SelectTrigger({
31
31
  children,
32
32
  ...props
33
33
  }: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
34
- size?: "sm" | "default"
34
+ size?: "sm" | "default" | "lg" | "xl"
35
35
  }) {
36
36
  return (
37
37
  <SelectPrimitive.Trigger
38
38
  data-slot="select-trigger"
39
39
  data-size={size}
40
40
  className={cn(
41
- "flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",
41
+ "flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=sm]:h-8 data-[size=default]:h-9 data-[size=lg]:h-10 data-[size=xl]:h-11 data-[size=xl]:text-base *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",
42
42
  className
43
43
  )}
44
44
  {...props}
@@ -0,0 +1,162 @@
1
+ import * as React from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ import { SearchInput } from "@behavioral-agentic-design-system/core/components/ui/search-input";
4
+ import { Label } from "@behavioral-agentic-design-system/core/components/ui/label";
5
+
6
+ const meta: Meta<typeof SearchInput> = {
7
+ title: "Components/SearchInput",
8
+ component: SearchInput,
9
+ parameters: { layout: "centered" },
10
+ tags: ["autodocs"],
11
+ decorators: [
12
+ (Story) => (
13
+ <div className="w-[320px]">
14
+ <Story />
15
+ </div>
16
+ ),
17
+ ],
18
+ };
19
+
20
+ export default meta;
21
+ type Story = StoryObj<typeof meta>;
22
+
23
+ export const Default: Story = {
24
+ render: () => {
25
+ const [value, setValue] = React.useState("");
26
+ return (
27
+ <SearchInput
28
+ value={value}
29
+ onValueChange={setValue}
30
+ placeholder="Search components…"
31
+ />
32
+ );
33
+ },
34
+ };
35
+
36
+ export const WithValue: Story = {
37
+ render: () => {
38
+ const [value, setValue] = React.useState("button");
39
+ return (
40
+ <SearchInput
41
+ value={value}
42
+ onValueChange={setValue}
43
+ placeholder="Search components…"
44
+ />
45
+ );
46
+ },
47
+ };
48
+
49
+ export const Size_Sm: Story = {
50
+ name: "Size — sm",
51
+ render: () => {
52
+ const [value, setValue] = React.useState("");
53
+ return (
54
+ <SearchInput
55
+ size="sm"
56
+ value={value}
57
+ onValueChange={setValue}
58
+ placeholder="Search…"
59
+ />
60
+ );
61
+ },
62
+ };
63
+
64
+ export const Size_Default: Story = {
65
+ name: "Size — default",
66
+ render: () => {
67
+ const [value, setValue] = React.useState("");
68
+ return (
69
+ <SearchInput
70
+ size="default"
71
+ value={value}
72
+ onValueChange={setValue}
73
+ placeholder="Search…"
74
+ />
75
+ );
76
+ },
77
+ };
78
+
79
+ export const Size_Lg: Story = {
80
+ name: "Size — lg",
81
+ render: () => {
82
+ const [value, setValue] = React.useState("");
83
+ return (
84
+ <SearchInput
85
+ size="lg"
86
+ value={value}
87
+ onValueChange={setValue}
88
+ placeholder="Search…"
89
+ />
90
+ );
91
+ },
92
+ };
93
+
94
+ export const Disabled: Story = {
95
+ render: () => (
96
+ <SearchInput value="accessibility" disabled placeholder="Search…" />
97
+ ),
98
+ };
99
+
100
+ export const Loading: Story = {
101
+ render: () => (
102
+ <SearchInput value="motion" loading placeholder="Searching…" />
103
+ ),
104
+ };
105
+
106
+ export const RealisticUse: Story = {
107
+ decorators: [
108
+ (Story) => (
109
+ <div className="w-[400px] rounded-lg border bg-card p-5 shadow-sm">
110
+ <Story />
111
+ </div>
112
+ ),
113
+ ],
114
+ render: () => {
115
+ const [value, setValue] = React.useState("");
116
+ const [loading, setLoading] = React.useState(false);
117
+ const [results, setResults] = React.useState<string[]>([]);
118
+
119
+ const items = [
120
+ "Accordion", "Alert", "Badge", "Button", "Calendar", "Card",
121
+ "Checkbox", "Combobox", "Command", "Dialog", "Drawer", "Input",
122
+ "Label", "Popover", "Progress", "Select", "Sheet", "Slider",
123
+ "Switch", "Table", "Tabs", "Textarea", "Toast", "Tooltip",
124
+ ];
125
+
126
+ function handleSearch(q: string) {
127
+ if (!q.trim()) { setResults([]); return; }
128
+ setLoading(true);
129
+ setTimeout(() => {
130
+ setResults(items.filter((i) => i.toLowerCase().includes(q.toLowerCase())));
131
+ setLoading(false);
132
+ }, 600);
133
+ }
134
+
135
+ return (
136
+ <div className="space-y-3">
137
+ <div className="space-y-1.5">
138
+ <Label>Component search</Label>
139
+ <SearchInput
140
+ value={value}
141
+ onValueChange={setValue}
142
+ onSearch={handleSearch}
143
+ loading={loading}
144
+ placeholder="Search components… (Enter to search)"
145
+ />
146
+ </div>
147
+ {results.length > 0 && (
148
+ <ul className="space-y-1">
149
+ {results.map((r) => (
150
+ <li key={r} className="rounded px-2 py-1 text-sm hover:bg-accent">
151
+ {r}
152
+ </li>
153
+ ))}
154
+ </ul>
155
+ )}
156
+ {!loading && value && results.length === 0 && (
157
+ <p className="text-sm text-muted-foreground">No components match "{value}".</p>
158
+ )}
159
+ </div>
160
+ );
161
+ },
162
+ };
@@ -47,6 +47,78 @@ export const Disabled: Story = {
47
47
  ),
48
48
  };
49
49
 
50
+ export const Size_Sm: Story = {
51
+ render: () => (
52
+ <Select>
53
+ <SelectTrigger size="sm" className="w-[220px]" aria-label="Pick a fruit (small)">
54
+ <SelectValue placeholder="Pick a fruit" />
55
+ </SelectTrigger>
56
+ <SelectContent>
57
+ <SelectGroup>
58
+ <SelectLabel>Fruits</SelectLabel>
59
+ <SelectItem value="apple">Apple</SelectItem>
60
+ <SelectItem value="banana">Banana</SelectItem>
61
+ <SelectItem value="cherry">Cherry</SelectItem>
62
+ </SelectGroup>
63
+ </SelectContent>
64
+ </Select>
65
+ ),
66
+ };
67
+
68
+ export const Size_Default: Story = {
69
+ render: () => (
70
+ <Select>
71
+ <SelectTrigger size="default" className="w-[220px]" aria-label="Pick a fruit (default)">
72
+ <SelectValue placeholder="Pick a fruit" />
73
+ </SelectTrigger>
74
+ <SelectContent>
75
+ <SelectGroup>
76
+ <SelectLabel>Fruits</SelectLabel>
77
+ <SelectItem value="apple">Apple</SelectItem>
78
+ <SelectItem value="banana">Banana</SelectItem>
79
+ <SelectItem value="cherry">Cherry</SelectItem>
80
+ </SelectGroup>
81
+ </SelectContent>
82
+ </Select>
83
+ ),
84
+ };
85
+
86
+ export const Size_Lg: Story = {
87
+ render: () => (
88
+ <Select>
89
+ <SelectTrigger size="lg" className="w-[220px]" aria-label="Pick a fruit (large)">
90
+ <SelectValue placeholder="Pick a fruit" />
91
+ </SelectTrigger>
92
+ <SelectContent>
93
+ <SelectGroup>
94
+ <SelectLabel>Fruits</SelectLabel>
95
+ <SelectItem value="apple">Apple</SelectItem>
96
+ <SelectItem value="banana">Banana</SelectItem>
97
+ <SelectItem value="cherry">Cherry</SelectItem>
98
+ </SelectGroup>
99
+ </SelectContent>
100
+ </Select>
101
+ ),
102
+ };
103
+
104
+ export const Size_Xl: Story = {
105
+ render: () => (
106
+ <Select>
107
+ <SelectTrigger size="xl" className="w-[220px]" aria-label="Pick a fruit (extra-large)">
108
+ <SelectValue placeholder="Pick a fruit" />
109
+ </SelectTrigger>
110
+ <SelectContent>
111
+ <SelectGroup>
112
+ <SelectLabel>Fruits</SelectLabel>
113
+ <SelectItem value="apple">Apple</SelectItem>
114
+ <SelectItem value="banana">Banana</SelectItem>
115
+ <SelectItem value="cherry">Cherry</SelectItem>
116
+ </SelectGroup>
117
+ </SelectContent>
118
+ </Select>
119
+ ),
120
+ };
121
+
50
122
  export const RealisticUse: Story = {
51
123
  render: () => (<Select>
52
124
  <SelectTrigger className="w-[220px]" aria-label="Pick a fruit"><SelectValue placeholder="Pick a fruit" /></SelectTrigger>