@behavioral-agentic-design-system/core 0.32.1 → 0.36.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.
@@ -3,33 +3,64 @@
3
3
  import * as React from "react"
4
4
  import { CircleIcon } from "lucide-react"
5
5
  import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
6
+ import { cva, type VariantProps } from "class-variance-authority"
6
7
 
7
8
  import { cn } from "../../lib/utils"
8
9
 
9
10
  function RadioGroup({
10
11
  className,
12
+ orientation,
11
13
  ...props
12
14
  }: React.ComponentProps<typeof RadioGroupPrimitive.Root>) {
13
15
  return (
14
16
  <RadioGroupPrimitive.Root
15
17
  data-slot="radio-group"
16
- className={cn("grid gap-3", className)}
18
+ orientation={orientation}
19
+ className={cn(
20
+ orientation === "horizontal"
21
+ ? "flex flex-row flex-wrap gap-x-6 gap-y-3"
22
+ : "grid gap-3",
23
+ className
24
+ )}
17
25
  {...props}
18
26
  />
19
27
  )
20
28
  }
21
29
 
30
+ const radioGroupItemVariants = cva(
31
+ "aspect-square shrink-0 rounded-full border-2 border-muted-foreground/60 bg-white text-primary shadow-xs transition-[background-color,border-color,color] duration-[210ms] ease-in-out 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 dark:aria-invalid:ring-destructive/40 data-[state=checked]:bg-primary data-[state=checked]:border-primary",
32
+ {
33
+ variants: {
34
+ size: {
35
+ sm: "size-7",
36
+ default: "size-9",
37
+ lg: "size-11",
38
+ },
39
+ },
40
+ defaultVariants: { size: "default" },
41
+ }
42
+ )
43
+
44
+ const indicatorIconSizeMap: Record<NonNullable<VariantProps<typeof radioGroupItemVariants>["size"]>, string> = {
45
+ sm: "size-3",
46
+ default: "size-4",
47
+ lg: "size-5",
48
+ }
49
+
50
+ interface RadioGroupItemProps
51
+ extends React.ComponentProps<typeof RadioGroupPrimitive.Item>,
52
+ VariantProps<typeof radioGroupItemVariants> {}
53
+
22
54
  function RadioGroupItem({
23
55
  className,
56
+ size,
24
57
  ...props
25
- }: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {
58
+ }: RadioGroupItemProps) {
59
+ const iconSize = indicatorIconSizeMap[size ?? "default"]
26
60
  return (
27
61
  <RadioGroupPrimitive.Item
28
62
  data-slot="radio-group-item"
29
- className={cn(
30
- "aspect-square size-9 shrink-0 rounded-full border-2 border-muted-foreground/60 bg-white text-primary shadow-xs transition-[background-color,border-color,color] duration-[210ms] ease-in-out 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 dark:aria-invalid:ring-destructive/40 data-[state=checked]:bg-primary data-[state=checked]:border-primary",
31
- className
32
- )}
63
+ className={cn(radioGroupItemVariants({ size }), className)}
33
64
  {...props}
34
65
  >
35
66
  <RadioGroupPrimitive.Indicator
@@ -37,10 +68,10 @@ function RadioGroupItem({
37
68
  data-slot="radio-group-indicator"
38
69
  className="flex h-full w-full items-center justify-center opacity-0 scale-75 transition-[opacity,transform] duration-[120ms] ease-out data-[state=checked]:opacity-100 data-[state=checked]:scale-100"
39
70
  >
40
- <CircleIcon className="size-4 fill-primary-foreground stroke-primary-foreground" />
71
+ <CircleIcon className={cn(iconSize, "fill-primary-foreground stroke-primary-foreground")} />
41
72
  </RadioGroupPrimitive.Indicator>
42
73
  </RadioGroupPrimitive.Item>
43
74
  )
44
75
  }
45
76
 
46
- export { RadioGroup, RadioGroupItem }
77
+ export { RadioGroup, RadioGroupItem, radioGroupItemVariants }
@@ -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}
@@ -11,14 +11,14 @@ function Switch({
11
11
  size = "default",
12
12
  ...props
13
13
  }: React.ComponentProps<typeof SwitchPrimitive.Root> & {
14
- size?: "sm" | "default"
14
+ size?: "sm" | "default" | "lg"
15
15
  }) {
16
16
  return (
17
17
  <SwitchPrimitive.Root
18
18
  data-slot="switch"
19
19
  data-size={size}
20
20
  className={cn(
21
- "peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-[background-color] duration-[210ms] ease-in-out outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[2.3rem] data-[size=default]:w-16 data-[size=sm]:h-7 data-[size=sm]:w-12 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80",
21
+ "peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-[background-color] duration-[210ms] ease-in-out outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[2.3rem] data-[size=default]:w-16 data-[size=sm]:h-7 data-[size=sm]:w-12 data-[size=lg]:h-11 data-[size=lg]:w-20 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80",
22
22
  className
23
23
  )}
24
24
  {...props}
@@ -30,7 +30,7 @@ function Switch({
30
30
  // check overlaps the thumb (lands ~20px); `left-1.5 size-3` leaves a
31
31
  // ~2px gap. Default keeps left-2 size-4 — it already clears its 32px
32
32
  // thumb.
33
- className="pointer-events-none absolute text-primary-foreground opacity-0 scale-75 transition-[opacity,transform] duration-[120ms] ease-out group-data-[size=default]/switch:left-2 group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:left-1.5 group-data-[size=sm]/switch:size-3 group-data-[state=checked]/switch:opacity-100 group-data-[state=checked]/switch:scale-100"
33
+ className="pointer-events-none absolute text-primary-foreground opacity-0 scale-75 transition-[opacity,transform] duration-[120ms] ease-out group-data-[size=default]/switch:left-2 group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:left-1.5 group-data-[size=sm]/switch:size-3 group-data-[size=lg]/switch:left-2.5 group-data-[size=lg]/switch:size-5 group-data-[state=checked]/switch:opacity-100 group-data-[state=checked]/switch:scale-100"
34
34
  />
35
35
  <SwitchPrimitive.Thumb
36
36
  data-slot="switch-thumb"
@@ -41,7 +41,7 @@ function Switch({
41
41
  // the thumb always contrasts the track: near-white thumb on
42
42
  // near-black track in light, near-black thumb on near-white
43
43
  // track in dark.
44
- "pointer-events-none block rounded-full bg-white data-[state=checked]:bg-primary-foreground ring-0 shadow-sm transition-[translate,background-color] duration-[175ms] ease-[cubic-bezier(0.25,0.46,0.45,0.94)] group-data-[size=default]/switch:size-8 group-data-[size=sm]/switch:size-6 data-[state=checked]:translate-x-[calc(100%-4px)] data-[state=unchecked]:translate-x-[2px]"
44
+ "pointer-events-none block rounded-full bg-white data-[state=checked]:bg-primary-foreground ring-0 shadow-sm transition-[translate,background-color] duration-[175ms] ease-[cubic-bezier(0.25,0.46,0.45,0.94)] group-data-[size=default]/switch:size-8 group-data-[size=sm]/switch:size-6 group-data-[size=lg]/switch:size-10 data-[state=checked]:translate-x-[calc(100%-4px)] data-[state=unchecked]:translate-x-[2px]"
45
45
  )}
46
46
  />
47
47
  </SwitchPrimitive.Root>
@@ -1,76 +1,92 @@
1
1
  "use client"
2
-
3
2
  import * as React from "react"
4
-
5
3
  import { cn } from "../../lib/utils"
6
4
 
7
- function Table({ className, ...props }: React.ComponentProps<"table">) {
5
+ interface TableVariantContextValue {
6
+ striped: boolean
7
+ bordered: boolean
8
+ compact: boolean
9
+ }
10
+
11
+ const TableVariantContext = React.createContext<TableVariantContextValue>({
12
+ striped: false,
13
+ bordered: false,
14
+ compact: false,
15
+ })
16
+
17
+ type TableSection = "header" | "body" | "footer"
18
+
19
+ const TableSectionContext = React.createContext<TableSection>("body")
20
+
21
+ interface TableProps extends React.ComponentProps<"table"> {
22
+ wrapperClassName?: string
23
+ wrapperStyle?: React.CSSProperties
24
+ /** Zebra-stripe even body rows (bg-muted/30) for scanability on wide tables. Visual only — never the sole carrier of meaning. */
25
+ striped?: boolean
26
+ /** Draw a rounded outer border on the scroll container plus column separators between cells. */
27
+ bordered?: boolean
28
+ /** Reduced vertical density: h-8 header cells, py-1 body cells. For data-only rows — a flow-changing CTA inside a compact row keeps its own min-h-11. */
29
+ compact?: boolean
30
+ }
31
+
32
+ function Table({ className, wrapperClassName, wrapperStyle, striped = false, bordered = false, compact = false, ...props }: TableProps) {
33
+ const variants = React.useMemo(() => ({ striped, bordered, compact }), [striped, bordered, compact])
8
34
  return (
9
- <div
10
- data-slot="table-container"
11
- // The container scrolls horizontally, so it must be keyboard-reachable:
12
- // axe fails an unfocusable scroll region as `scrollable-region-focusable`
13
- // (serious), and a pointer-free user otherwise cannot reach the columns
14
- // past the fold at all. Same treatment `code.tsx` already applies to its
15
- // block variant. Unconditional rather than measured: a table's width
16
- // depends on its content and its container, neither of which is known
17
- // here, and a tab stop that is occasionally redundant is a far smaller
18
- // cost than columns that are sometimes unreachable.
19
- tabIndex={0}
20
- // scrollbar-thin + a token-coloured thumb, so the scroller reads as part
21
- // of the system instead of the OS default. First-party Tailwind v4.3
22
- // utilities — no plugin. --border is the quiet mid-grey already audited
23
- // at 3.79:1 against the page, clearing SC 1.4.11's 3:1 non-text floor.
24
- className="relative w-full overflow-x-auto scrollbar-thin scrollbar-thumb-border scrollbar-track-transparent"
25
- >
26
- <table
27
- data-slot="table"
28
- className={cn("w-full caption-bottom text-sm", className)}
29
- {...props}
30
- />
31
- </div>
35
+ <TableVariantContext.Provider value={variants}>
36
+ <div data-slot="table-container" tabIndex={0}
37
+ className={cn(
38
+ "relative w-full overflow-x-auto scrollbar-thin scrollbar-thumb-border scrollbar-track-transparent",
39
+ bordered && "rounded-md border",
40
+ wrapperClassName
41
+ )}
42
+ style={wrapperStyle}
43
+ >
44
+ <table
45
+ data-slot="table"
46
+ data-striped={striped ? "" : undefined}
47
+ data-bordered={bordered ? "" : undefined}
48
+ data-compact={compact ? "" : undefined}
49
+ className={cn("w-full caption-bottom text-sm", className)}
50
+ {...props}
51
+ />
52
+ </div>
53
+ </TableVariantContext.Provider>
32
54
  )
33
55
  }
34
56
 
35
57
  function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
36
58
  return (
37
- <thead
38
- data-slot="table-header"
39
- className={cn("[&_tr]:border-b", className)}
40
- {...props}
41
- />
59
+ <TableSectionContext.Provider value="header">
60
+ <thead data-slot="table-header" className={cn("[&_tr]:border-b", className)} {...props} />
61
+ </TableSectionContext.Provider>
42
62
  )
43
63
  }
44
64
 
45
65
  function TableBody({ className, ...props }: React.ComponentProps<"tbody">) {
46
66
  return (
47
- <tbody
48
- data-slot="table-body"
49
- className={cn("[&_tr:last-child]:border-0", className)}
50
- {...props}
51
- />
67
+ <TableSectionContext.Provider value="body">
68
+ <tbody data-slot="table-body" className={cn("[&_tr:last-child]:border-0", className)} {...props} />
69
+ </TableSectionContext.Provider>
52
70
  )
53
71
  }
54
72
 
55
73
  function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
56
74
  return (
57
- <tfoot
58
- data-slot="table-footer"
59
- className={cn(
60
- "border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
61
- className
62
- )}
63
- {...props}
64
- />
75
+ <TableSectionContext.Provider value="footer">
76
+ <tfoot data-slot="table-footer" className={cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className)} {...props} />
77
+ </TableSectionContext.Provider>
65
78
  )
66
79
  }
67
80
 
68
81
  function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
82
+ const { striped } = React.useContext(TableVariantContext)
83
+ const section = React.useContext(TableSectionContext)
69
84
  return (
70
85
  <tr
71
86
  data-slot="table-row"
72
87
  className={cn(
73
88
  "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
89
+ striped && section === "body" && "even:bg-muted/30",
74
90
  className
75
91
  )}
76
92
  {...props}
@@ -79,11 +95,14 @@ function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
79
95
  }
80
96
 
81
97
  function TableHead({ className, ...props }: React.ComponentProps<"th">) {
98
+ const { bordered, compact } = React.useContext(TableVariantContext)
82
99
  return (
83
100
  <th
84
101
  data-slot="table-head"
85
102
  className={cn(
86
- "h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
103
+ compact ? "h-8" : "h-10",
104
+ "px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
105
+ bordered && "border-r last:border-r-0",
87
106
  className
88
107
  )}
89
108
  {...props}
@@ -92,11 +111,14 @@ function TableHead({ className, ...props }: React.ComponentProps<"th">) {
92
111
  }
93
112
 
94
113
  function TableCell({ className, ...props }: React.ComponentProps<"td">) {
114
+ const { bordered, compact } = React.useContext(TableVariantContext)
95
115
  return (
96
116
  <td
97
117
  data-slot="table-cell"
98
118
  className={cn(
99
- "p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
119
+ compact ? "px-2 py-1" : "p-2",
120
+ "align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
121
+ bordered && "border-r last:border-r-0",
100
122
  className
101
123
  )}
102
124
  {...props}
@@ -104,26 +126,8 @@ function TableCell({ className, ...props }: React.ComponentProps<"td">) {
104
126
  )
105
127
  }
106
128
 
107
- function TableCaption({
108
- className,
109
- ...props
110
- }: React.ComponentProps<"caption">) {
111
- return (
112
- <caption
113
- data-slot="table-caption"
114
- className={cn("mt-4 text-sm text-muted-foreground", className)}
115
- {...props}
116
- />
117
- )
129
+ function TableCaption({ className, ...props }: React.ComponentProps<"caption">) {
130
+ return <caption data-slot="table-caption" className={cn("mt-4 text-sm text-muted-foreground", className)} {...props} />
118
131
  }
119
132
 
120
- export {
121
- Table,
122
- TableHeader,
123
- TableBody,
124
- TableFooter,
125
- TableHead,
126
- TableRow,
127
- TableCell,
128
- TableCaption,
129
- }
133
+ export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption }
@@ -4,10 +4,28 @@
4
4
  // a server component at all. See the note in button.tsx for why the components
5
5
  // that merely forward an optional callback are left server-renderable.
6
6
  import * as React from "react"
7
+ import { cva, type VariantProps } from "class-variance-authority"
7
8
 
8
9
  import { cn } from "../../lib/utils"
9
10
 
10
- interface TextareaProps extends React.ComponentProps<"textarea"> {
11
+ const textareaVariants = cva(
12
+ "flex field-sizing-content w-full rounded-md border border-input bg-transparent shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground 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 dark:bg-input/30 dark:aria-invalid:ring-destructive/40",
13
+ {
14
+ variants: {
15
+ size: {
16
+ sm: "min-h-14 px-2.5 py-1.5 text-sm",
17
+ default: "min-h-16 px-3 py-2 text-base md:text-sm",
18
+ lg: "min-h-20 px-4 py-2.5 text-base",
19
+ xl: "min-h-24 px-5 py-3 text-lg",
20
+ },
21
+ },
22
+ defaultVariants: { size: "default" },
23
+ }
24
+ )
25
+
26
+ interface TextareaProps
27
+ extends React.ComponentProps<"textarea">,
28
+ VariantProps<typeof textareaVariants> {
11
29
  /** Show a character count below the textarea. Default false. */
12
30
  showCount?: boolean
13
31
  /**
@@ -22,6 +40,7 @@ interface TextareaProps extends React.ComponentProps<"textarea"> {
22
40
 
23
41
  function Textarea({
24
42
  className,
43
+ size,
25
44
  showCount = false,
26
45
  maxLength,
27
46
  countId,
@@ -50,10 +69,7 @@ function Textarea({
50
69
  data-slot="textarea"
51
70
  maxLength={maxLength}
52
71
  aria-describedby={showCount ? resolvedCountId : undefined}
53
- className={cn(
54
- "flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground 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 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40",
55
- className
56
- )}
72
+ className={cn(textareaVariants({ size }), className)}
57
73
  value={value}
58
74
  defaultValue={defaultValue}
59
75
  onChange={handleChange}
@@ -83,5 +99,5 @@ function Textarea({
83
99
  )
84
100
  }
85
101
 
86
- export { Textarea }
102
+ export { Textarea, textareaVariants }
87
103
  export type { TextareaProps }
@@ -209,6 +209,8 @@ export const DOCS_INDEX: DocGroup[] = [
209
209
  { title: "Spec — skill package", path: "docs/specs/2026-08-21-skill-package.md", summary: "The durable contract for packages/skill: generated-only output, usage-focused recipes, ≤2k-word SKILL.md, deterministic builds, the check:skill staleness gate, and the eval --context=skill acceptance instrument." },
210
210
  { title: "Plan — self-healing layer", path: "docs/plans/2026-08-21-self-healing-layer.md", summary: "Approved plan: the watch-half of the system — drift ledger, token intent validator, component health score, and a Health surface, assembled from signals BADS already owns; runtime telemetry deliberately deferred behind consent + futures-check." },
211
211
  { title: "Spec — self-healing layer", path: "docs/specs/2026-08-21-self-healing-layer.md", summary: "Phase A contract: informational-only health score (Goodhart guard), no runtime telemetry, deterministic visible-copy intent rules, drift-ledger status convention, and the calibration record (6→0 false positives; two scoring bugs caught by face-checking)." },
212
+ { title: "Plan — drift elimination", path: "docs/plans/2026-08-31-drift-elimination.md", summary: "Closing the loop between upstream, client forks, and prototype repos. Built on the one artifact every working template-sync tool shares: a committed record of which upstream version a downstream copy is layered on. Three phases ordered by risk — additive checks, then PR-gated fork sync, then the deferred structural calls." },
213
+ { title: "Spec — drift elimination", path: "docs/specs/2026-08-31-drift-elimination.md", summary: "Phase A contract: precision over recall (unverifiable is never reported as drift), advisory-by-default with one blocking generated-artifact gate, additive-only sync manifest, and declared expected-drift allowlists. Calibration: 51→0 false positives on the registry checker, and real drift caught including llms.txt advertising 79 components when there were 173." },
212
214
  ],
213
215
  },
214
216
  ];
@@ -253,6 +253,44 @@ const REALISTIC_COLUMNS: ColumnDef<ComponentRow>[] = [
253
253
  { accessorKey: "lastUpdated", header: "Last Updated" },
254
254
  ];
255
255
 
256
+ // ---------------------------------------------------------------------------
257
+ // StickyHeader — header stays visible as rows scroll
258
+ // ---------------------------------------------------------------------------
259
+
260
+ export const StickyHeader: Story = {
261
+ render: () => (
262
+ <DataTable
263
+ columns={ADOPTION_COLUMNS}
264
+ data={ADOPTION_DATA}
265
+ stickyHeader
266
+ scrollHeight="260px"
267
+ />
268
+ ),
269
+ };
270
+
271
+ // ---------------------------------------------------------------------------
272
+ // WideOverflowing — a min-width table in a constrained wrapper (scroll test)
273
+ // ---------------------------------------------------------------------------
274
+
275
+ export const WideOverflowing: Story = {
276
+ render: () => (
277
+ <div className="w-[380px]">
278
+ <DataTable
279
+ columns={[
280
+ { accessorKey: "component", header: "Component", size: 200 },
281
+ { accessorKey: "status", header: "Status", size: 120 },
282
+ { accessorKey: "adopters", header: "Adopters", size: 100 },
283
+ { accessorKey: "coverage", header: "Coverage", size: 100 },
284
+ { accessorKey: "lastUpdated", header: "Last Updated", size: 140 },
285
+ ]}
286
+ data={ADOPTION_DATA.slice(0, 6)}
287
+ stickyHeader
288
+ scrollHeight="200px"
289
+ />
290
+ </div>
291
+ ),
292
+ };
293
+
256
294
  export const RealisticUse: Story = {
257
295
  render: () => (
258
296
  <div className="space-y-2">
@@ -66,6 +66,60 @@ export const WithError: Story = {
66
66
  },
67
67
  };
68
68
 
69
+ export const Variant_Ghost: Story = {
70
+ name: "Variant: Ghost (inline edit)",
71
+ render: () => {
72
+ const [value, setValue] = React.useState("Amara Okafor");
73
+ return (
74
+ <div className="flex w-72 flex-col gap-4">
75
+ <Input
76
+ variant="ghost"
77
+ type="search"
78
+ aria-label="Search projects"
79
+ placeholder="Search projects…"
80
+ leftSection={<SearchIcon size={16} strokeWidth={1.5} aria-hidden="true" />}
81
+ />
82
+ <Input
83
+ variant="ghost"
84
+ aria-label="Assignee name"
85
+ value={value}
86
+ onChange={(e) => setValue(e.target.value)}
87
+ />
88
+ </div>
89
+ );
90
+ },
91
+ };
92
+
93
+ export const Variant_Filled: Story = {
94
+ name: "Variant: Filled",
95
+ render: () => {
96
+ const [value, setValue] = React.useState("maya.chen@lumenworks.studio");
97
+ return (
98
+ <div className="flex w-72 flex-col gap-4">
99
+ <Input variant="filled" aria-label="Filter by name" placeholder="Filter by name" />
100
+ <Input
101
+ variant="filled"
102
+ type="email"
103
+ aria-label="Work email"
104
+ value={value}
105
+ onChange={(e) => setValue(e.target.value)}
106
+ />
107
+ </div>
108
+ );
109
+ },
110
+ };
111
+
112
+ export const Variant_AllThree: Story = {
113
+ name: "Variant: outline / ghost / filled",
114
+ render: () => (
115
+ <div className="flex w-72 flex-col gap-4">
116
+ <Input variant="outline" aria-label="Outline variant" placeholder="Search projects…" />
117
+ <Input variant="ghost" aria-label="Ghost variant" placeholder="Search projects…" />
118
+ <Input variant="filled" aria-label="Filled variant" placeholder="Search projects…" />
119
+ </div>
120
+ ),
121
+ };
122
+
69
123
  export const Variant_WithLeftIcon: Story = {
70
124
  name: "Variant: With left icon",
71
125
  args: {