@@ -20,6 +20,7 @@ import {
2020type ReactElement ,
2121useMemo ,
2222} from "react" ;
23+ import { cn } from "utils/cn" ;
2324
2425const SIDE_PADDING = 16 ;
2526
@@ -76,19 +77,22 @@ export const SelectMenuSearch: FC<SearchFieldProps> = (props) => {
7677) ;
7778} ;
7879
79- export const SelectMenuList :FC < MenuListProps > = ( props ) => {
80+ export const SelectMenuList :FC < MenuListProps > = ( {
81+ children,
82+ className,
83+ ...attrs
84+ } ) => {
8085const 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 ) ) {
8388throw new Error ( "SelectMenuList only accepts MenuItem children" ) ;
8489}
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+
9094return (
91- < MenuList css = { { maxHeight : 480 } } { ...props } >
95+ < MenuList className = { cn ( "max-h-[480px]" , className ) } { ...attrs } >
9296{ items }
9397</ MenuList >
9498) ;
@@ -106,25 +110,31 @@ function moveSelectedElementToFirst(items: ReactElement<MenuItemProps>[]) {
106110return newItems ;
107111}
108112
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+ ) ;
111123} ;
112124
113- export const SelectMenuItem :FC < MenuItemProps > = ( props ) => {
125+ export const SelectMenuItem :FC < MenuItemProps > = ( {
126+ children,
127+ className,
128+ selected,
129+ ...attrs
130+ } ) => {
114131return (
115132< 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 }
123135>
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" /> }
128138</ MenuItem >
129139) ;
130140} ;