@@ -5,9 +5,9 @@ import { useOverlayTriggerState } from 'react-stately';
55import { PopoverContent , PopoverTrigger } from './popover' ;
66import { cn } from './utils' ;
77
8- export interface SelectOption {
8+ export interface SelectOption < T = string > {
99 label : string ;
10- value : string ;
10+ value : T ;
1111}
1212
1313export interface SelectUIComponents {
@@ -22,10 +22,11 @@ export interface SelectUIComponents {
2222 ChevronIcon ?: React . ComponentType < React . SVGProps < SVGSVGElement > > ;
2323}
2424
25- export interface SelectProps extends Omit < React . ButtonHTMLAttributes < HTMLButtonElement > , 'value' | 'onChange' > {
26- options : SelectOption [ ] ;
27- value ?: string ;
28- onValueChange ?: ( value : string ) => void ;
25+ export interface SelectProps < T = string >
26+ extends Omit < React . ButtonHTMLAttributes < HTMLButtonElement > , 'value' | 'onChange' > {
27+ options : SelectOption < T > [ ] ;
28+ value ?: T ;
29+ onValueChange ?: ( value : T ) => void ;
2930 placeholder ?: string ;
3031 disabled ?: boolean ;
3132 className ?: string ;
@@ -34,7 +35,7 @@ export interface SelectProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonE
3435 components ?: Partial < SelectUIComponents > ;
3536}
3637
37- export function Select ( {
38+ export function Select < T = string > ( {
3839 options,
3940 value,
4041 onValueChange,
@@ -45,7 +46,7 @@ export function Select({
4546 itemClassName,
4647 components,
4748 ...buttonProps
48- } : SelectProps ) {
49+ } : SelectProps < T > ) {
4950 const popoverState = useOverlayTriggerState ( { } ) ;
5051 const listboxId = React . useId ( ) ;
5152 const [ query , setQuery ] = React . useState ( '' ) ;
@@ -174,7 +175,7 @@ export function Select({
174175 const isSelected = option . value === value ;
175176 const isEnterCandidate = query . trim ( ) !== '' && enterCandidate ?. value === option . value && ! isSelected ;
176177 return (
177- < li key = { option . value } className = "list-none" >
178+ < li key = { String ( option . value ) } className = "list-none" >
178179 < Item
179180 ref = { isSelected ? selectedItemRef : undefined }
180181 onClick = { ( ) => {
0 commit comments