@@ -15,12 +15,14 @@ const ICONS_PER_ROW = 9;
1515const ROW_HEIGHT = 42 ;
1616const CATEGORY_HEIGHT = 42 ;
1717
18- function IconPicker ( {
18+ function IconPicker ( {
1919 onSelect,
2020 onEscape,
21+ size,
2122} : {
2223 onSelect : ( icon : { value : string , color : string , content : string } ) => void ;
2324 onEscape ?: ( ) => void ;
25+ size ?: [ number , number ] ;
2426} ) {
2527 const { t } = useTranslation ( ) ;
2628 const [ anchorEl , setAnchorEl ] = React . useState < null | HTMLElement > ( null ) ;
@@ -36,8 +38,8 @@ function IconPicker ({
3638 > | undefined > ( undefined ) ;
3739 const [ searchValue , setSearchValue ] = React . useState ( '' ) ;
3840 const filteredIcons = React . useMemo ( ( ) => {
39- if ( ! icons ) return { } ;
40- if ( ! searchValue ) return icons ;
41+ if ( ! icons ) return { } ;
42+ if ( ! searchValue ) return icons ;
4143 const filtered = Object . fromEntries (
4244 Object . entries ( icons ) . map ( ( [ category , icons ] ) => [
4345 category ,
@@ -54,7 +56,7 @@ function IconPicker ({
5456 } , [ icons , searchValue ] ) ;
5557
5658 const rowData = React . useMemo ( ( ) => {
57- if ( ! filteredIcons ) return [ ] ;
59+ if ( ! filteredIcons ) return [ ] ;
5860
5961 const rows : Array < {
6062 type : 'category' | 'icons' ;
@@ -69,14 +71,14 @@ function IconPicker ({
6971 } > = [ ] ;
7072
7173 Object . entries ( filteredIcons ) . forEach ( ( [ category , icons ] ) => {
72- if ( icons . length === 0 ) return ;
74+ if ( icons . length === 0 ) return ;
7375
7476 rows . push ( {
7577 type : 'category' ,
7678 category : category . replaceAll ( '_' , ' ' ) ,
7779 } ) ;
7880
79- for ( let i = 0 ; i < icons . length ; i += ICONS_PER_ROW ) {
81+ for ( let i = 0 ; i < icons . length ; i += ICONS_PER_ROW ) {
8082 rows . push ( {
8183 type : 'icons' ,
8284 icons : icons . slice ( i , i + ICONS_PER_ROW ) . map ( ( icon ) => ( {
@@ -108,7 +110,7 @@ function IconPicker ({
108110 } ) => {
109111 const row = data [ index ] ;
110112
111- if ( row . type === 'category' ) {
113+ if ( row . type === 'category' ) {
112114 return (
113115 < div
114116 style = { style }
@@ -119,7 +121,7 @@ function IconPicker ({
119121 ) ;
120122 }
121123
122- if ( ! row . icons ) return null ;
124+ if ( ! row . icons ) return null ;
123125
124126 return (
125127 < div
@@ -152,7 +154,13 @@ function IconPicker ({
152154 } , [ ] ) ;
153155
154156 return (
155- < div className = { 'flex h-[360px] max-h-[70vh] flex-col p-4 pt-2' } >
157+ < div
158+ style = { {
159+ width : size ? size [ 0 ] : undefined ,
160+ height : size ? size [ 1 ] : undefined ,
161+ } }
162+ className = { 'flex h-[360px] max-h-[70vh] flex-col p-4 pt-2' }
163+ >
156164 < div className = { 'px-0.5 py-2' } >
157165 < div className = { 'search-input flex items-end justify-between gap-2' } >
158166 < OutlinedInput
@@ -162,7 +170,7 @@ function IconPicker ({
162170 setSearchValue ( e . target . value ) ;
163171 } }
164172 onKeyUp = { ( e ) => {
165- if ( e . key === 'Escape' && onEscape ) {
173+ if ( e . key === 'Escape' && onEscape ) {
166174 onEscape ( ) ;
167175 }
168176 } }
@@ -185,7 +193,7 @@ function IconPicker ({
185193 variant = { 'outlined' }
186194 color = { 'inherit' }
187195 className = { 'h-9 w-9 min-w-[36px] px-0 py-0' }
188- onClick = { async ( ) => {
196+ onClick = { async ( ) => {
189197 const icon = await randomIcon ( ) ;
190198 const color = randomColor ( IconColors ) ;
191199
@@ -242,7 +250,7 @@ function IconPicker ({
242250 anchorEl = { anchorEl }
243251 onClose = { ( ) => setAnchorEl ( null ) }
244252 onKeyDown = { ( e ) => {
245- if ( e . key === 'Escape' ) {
253+ if ( e . key === 'Escape' ) {
246254 setAnchorEl ( null ) ;
247255 }
248256 } }
@@ -255,12 +263,12 @@ function IconPicker ({
255263 color = { 'inherit' }
256264 className = { 'h-9 w-9 min-w-[36px] px-0 py-0' }
257265 onClick = { ( ) => {
258- if ( ! selectIcon ) return ;
266+ if ( ! selectIcon ) return ;
259267 const [ groupName , iconName ] = selectIcon . split ( '/' ) ;
260268
261269 const category = icons ?. [ groupName as ICON_CATEGORY ] ;
262270
263- if ( ! category ) return ;
271+ if ( ! category ) return ;
264272
265273 const content = category . find ( ( icon ) => icon . name === iconName ) ?. content ;
266274
0 commit comments