22
33import * as SelectPrimitive from "@radix-ui/react-select" ;
44import { CheckIcon , ChevronDownIcon , ChevronUpIcon , X } from "lucide-react" ;
5- import { createContext , useContext , useId } from "react" ;
5+ import {
6+ ComponentProps ,
7+ createContext ,
8+ KeyboardEvent ,
9+ MouseEvent ,
10+ useContext ,
11+ useId ,
12+ } from "react" ;
613
714import { cn } from "@/lib/utils" ;
815
@@ -26,7 +33,7 @@ function Select({
2633 onMultiValueChange,
2734 ariaLabel,
2835 ...props
29- } : Omit < React . ComponentProps < typeof SelectPrimitive . Root > , "onValueChange" > & {
36+ } : Omit < ComponentProps < typeof SelectPrimitive . Root > , "onValueChange" > & {
3037 allowDeselect ?: boolean ;
3138 multiple ?: boolean ;
3239 selectedValues ?: string [ ] ;
@@ -92,15 +99,15 @@ function Select({
9299
93100function SelectGroup ( {
94101 ...props
95- } : React . ComponentProps < typeof SelectPrimitive . Group > ) {
102+ } : ComponentProps < typeof SelectPrimitive . Group > ) {
96103 return < SelectPrimitive . Group data-slot = "select-group" { ...props } /> ;
97104}
98105
99106function SelectValue ( {
100107 placeholder,
101108 children,
102109 ...props
103- } : React . ComponentProps < typeof SelectPrimitive . Value > ) {
110+ } : ComponentProps < typeof SelectPrimitive . Value > ) {
104111 const { multiple, selectedValues } = useContext ( SelectContext ) ;
105112
106113 // For multi-select, render custom children or placeholder
@@ -129,14 +136,16 @@ function SelectTrigger({
129136 size = "default" ,
130137 children,
131138 ...props
132- } : React . ComponentProps < typeof SelectPrimitive . Trigger > & {
139+ } : ComponentProps < typeof SelectPrimitive . Trigger > & {
133140 size ?: "sm" | "default" ;
134141} ) {
135142 const { multiple, selectedValues, onMultiValueChange, ariaLabel } =
136143 useContext ( SelectContext ) ;
137144 const hasSelection = multiple && selectedValues && selectedValues . length > 0 ;
138145
139- const handleClear = ( e : React . MouseEvent ) => {
146+ const handleClear = (
147+ e : MouseEvent < HTMLSpanElement > | KeyboardEvent < HTMLSpanElement > ,
148+ ) => {
140149 e . stopPropagation ( ) ;
141150 if ( onMultiValueChange ) {
142151 onMultiValueChange ( [ ] ) ;
@@ -168,7 +177,7 @@ function SelectTrigger({
168177 if ( e . key === "Enter" || e . key === " " ) {
169178 e . preventDefault ( ) ;
170179 e . stopPropagation ( ) ;
171- handleClear ( e as unknown as React . MouseEvent ) ;
180+ handleClear ( e ) ;
172181 }
173182 } }
174183 className = "pointer-events-auto cursor-pointer rounded-sm p-0.5 opacity-70 transition-opacity hover:opacity-100 focus:opacity-100 focus:ring-2 focus:ring-slate-600 focus:ring-offset-2 focus:outline-none dark:focus:ring-slate-400"
@@ -197,7 +206,7 @@ function SelectContent({
197206 position = "popper" ,
198207 align = "center" ,
199208 ...props
200- } : React . ComponentProps < typeof SelectPrimitive . Content > ) {
209+ } : ComponentProps < typeof SelectPrimitive . Content > ) {
201210 return (
202211 < SelectPrimitive . Portal >
203212 < SelectPrimitive . Content
@@ -231,7 +240,7 @@ function SelectContent({
231240function SelectLabel ( {
232241 className,
233242 ...props
234- } : React . ComponentProps < typeof SelectPrimitive . Label > ) {
243+ } : ComponentProps < typeof SelectPrimitive . Label > ) {
235244 return (
236245 < SelectPrimitive . Label
237246 data-slot = "select-label"
@@ -246,7 +255,7 @@ function SelectItem({
246255 children,
247256 value,
248257 ...props
249- } : React . ComponentProps < typeof SelectPrimitive . Item > ) {
258+ } : ComponentProps < typeof SelectPrimitive . Item > ) {
250259 const { multiple, selectedValues } = useContext ( SelectContext ) ;
251260 const isSelected = multiple && selectedValues ?. includes ( value ) ;
252261
@@ -290,7 +299,7 @@ function SelectItem({
290299function SelectSeparator ( {
291300 className,
292301 ...props
293- } : React . ComponentProps < typeof SelectPrimitive . Separator > ) {
302+ } : ComponentProps < typeof SelectPrimitive . Separator > ) {
294303 return (
295304 < SelectPrimitive . Separator
296305 data-slot = "select-separator"
@@ -303,7 +312,7 @@ function SelectSeparator({
303312function SelectScrollUpButton ( {
304313 className,
305314 ...props
306- } : React . ComponentProps < typeof SelectPrimitive . ScrollUpButton > ) {
315+ } : ComponentProps < typeof SelectPrimitive . ScrollUpButton > ) {
307316 return (
308317 < SelectPrimitive . ScrollUpButton
309318 data-slot = "select-scroll-up-button"
@@ -321,7 +330,7 @@ function SelectScrollUpButton({
321330function SelectScrollDownButton ( {
322331 className,
323332 ...props
324- } : React . ComponentProps < typeof SelectPrimitive . ScrollDownButton > ) {
333+ } : ComponentProps < typeof SelectPrimitive . ScrollDownButton > ) {
325334 return (
326335 < SelectPrimitive . ScrollDownButton
327336 data-slot = "select-scroll-down-button"
0 commit comments