@@ -11,6 +11,7 @@ import {useGlobalListeners} from '@react-aria/utils';
1111
1212const iconList = Object . keys ( icons ) . map ( name => ( { id : name . replace ( / ^ S 2 _ I c o n _ ( .* ?) ( S i z e \d + ) ? _ 2 .* / , '$1' ) , icon : icons [ name ] . default } ) ) ;
1313const iconMap = Object . fromEntries ( iconList . map ( item => [ item . id , item . icon ] ) ) ;
14+ export const Icon = ( { icon} ) => createElement ( iconMap [ icon ] ) ;
1415
1516const itemStyle = style ( {
1617 ...focusRing ( ) ,
@@ -33,7 +34,7 @@ const itemStyle = style({
3334 justifyContent : 'center'
3435} ) ;
3536
36- type IconValue = string | { text ?: string , icon ?: string | null , iconJSX ?: ReactNode } | null ;
37+ type IconValue = string | { text ?: string , icon ?: string | null } | null ;
3738interface IconPickerProps {
3839 value : IconValue ,
3940 onChange : ( value : IconValue ) => void ,
@@ -64,12 +65,12 @@ export function IconPicker({value, onChange, label, contextualHelp}: IconPickerP
6465 return (
6566 < Select
6667 aria-label = "Icon"
67- selectedKey = { valueObject ?. icon ?? null }
68- onSelectionChange = { icon => {
68+ value = { valueObject ?. icon ?? null }
69+ onChange = { icon => {
6970 if ( ! icon || icon === valueObject ?. icon ) {
70- onChange ( { ...valueObject , icon : null , iconJSX : null } ) ;
71+ onChange ( { ...valueObject , icon : null } ) ;
7172 } else if ( icon ) {
72- onChange ( { ...valueObject , icon : icon as string , iconJSX : createElement ( iconMap [ icon ] ) } ) ;
73+ onChange ( { ...valueObject , icon : icon as string } ) ;
7374 }
7475 } }
7576 className = { style ( { display : 'flex' , flexDirection : 'column' , gap : 2 , width : 'fit' } ) } >
0 commit comments