@@ -20,6 +20,7 @@ import {
20
20
type ReactElement ,
21
21
useMemo ,
22
22
} from "react" ;
23
+ import { cn } from "utils/cn" ;
23
24
24
25
const SIDE_PADDING = 16 ;
25
26
@@ -76,19 +77,22 @@ export const SelectMenuSearch: FC<SearchFieldProps> = (props) => {
76
77
) ;
77
78
} ;
78
79
79
- export const SelectMenuList : FC < MenuListProps > = ( props ) => {
80
+ export const SelectMenuList : FC < MenuListProps > = ( {
81
+ children,
82
+ className,
83
+ ...attrs
84
+ } ) => {
80
85
const items = useMemo ( ( ) => {
81
- let children = Children . toArray ( props . children ) ;
82
- if ( ! children . every ( isValidElement ) ) {
86
+ let items = Children . toArray ( children ) ;
87
+ if ( ! items . every ( isValidElement ) ) {
83
88
throw new Error ( "SelectMenuList only accepts MenuItem children" ) ;
84
89
}
85
- children = moveSelectedElementToFirst (
86
- children as ReactElement < MenuItemProps > [ ] ,
87
- ) ;
88
- return children ;
89
- } , [ props . children ] ) ;
90
+ items = moveSelectedElementToFirst ( items as ReactElement < MenuItemProps > [ ] ) ;
91
+ return items ;
92
+ } , [ children ] ) ;
93
+
90
94
return (
91
- < MenuList css = { { maxHeight : 480 } } { ...props } >
95
+ < MenuList className = { cn ( "max-h-[480px]" , className ) } { ...attrs } >
92
96
{ items }
93
97
</ MenuList >
94
98
) ;
@@ -106,25 +110,31 @@ function moveSelectedElementToFirst(items: ReactElement<MenuItemProps>[]) {
106
110
return newItems ;
107
111
}
108
112
109
- export const SelectMenuIcon : FC < HTMLProps < HTMLDivElement > > = ( props ) => {
110
- return < div css = { { marginRight : 16 } } { ...props } /> ;
113
+ export const SelectMenuIcon : FC < HTMLProps < HTMLDivElement > > = ( {
114
+ children,
115
+ className,
116
+ ...attrs
117
+ } ) => {
118
+ return (
119
+ < div className = { cn ( "mr-4" , className ) } { ...attrs } >
120
+ { children }
121
+ </ div >
122
+ ) ;
111
123
} ;
112
124
113
- export const SelectMenuItem : FC < MenuItemProps > = ( props ) => {
125
+ export const SelectMenuItem : FC < MenuItemProps > = ( {
126
+ children,
127
+ className,
128
+ selected,
129
+ ...attrs
130
+ } ) => {
114
131
return (
115
132
< MenuItem
116
- css = { {
117
- fontSize : 14 ,
118
- gap : 0 ,
119
- lineHeight : 1 ,
120
- padding : `12px ${ SIDE_PADDING } px` ,
121
- } }
122
- { ...props }
133
+ className = { cn ( "text-sm gap-0 leading-none py-3 px-4" , className ) }
134
+ { ...attrs }
123
135
>
124
- { props . children }
125
- { props . selected && (
126
- < CheckIcon className = "size-icon-xs" css = { { marginLeft : "auto" } } />
127
- ) }
136
+ { children }
137
+ { selected && < CheckIcon className = "size-icon-xs ml-auto" /> }
128
138
</ MenuItem >
129
139
) ;
130
140
} ;
0 commit comments