@@ -7,9 +7,11 @@ import { FieldWidgetProps } from './types';
77 * Avatar field widget - provides an avatar/profile picture uploader
88 * Supports image URLs or file uploads
99 */
10- export function AvatarField ( { value, onChange, field, readonly } : FieldWidgetProps < string > ) {
10+ export function AvatarField ( { value, onChange, field, readonly, ... props } : FieldWidgetProps < string > ) {
1111 const [ isHovered , setIsHovered ] = React . useState ( false ) ;
1212 const fileInputRef = React . useRef < HTMLInputElement > ( null ) ;
13+
14+ const avatarField = ( field || ( props as any ) . schema ) as any ;
1315
1416 const handleFileSelect = ( event : React . ChangeEvent < HTMLInputElement > ) => {
1517 const file = event . target . files ?. [ 0 ] ;
@@ -41,7 +43,7 @@ export function AvatarField({ value, onChange, field, readonly }: FieldWidgetPro
4143
4244 // Extract initials for fallback
4345 const getInitials = ( ) : string => {
44- const name = ( field as any ) . defaultName || field . label || 'User' ;
46+ const name = avatarField ? .defaultName || avatarField ? .label || 'User' ;
4547 return name
4648 . split ( ' ' )
4749 . map ( ( word : string ) => word [ 0 ] )
@@ -53,7 +55,7 @@ export function AvatarField({ value, onChange, field, readonly }: FieldWidgetPro
5355 if ( readonly ) {
5456 return (
5557 < Avatar className = "w-16 h-16" >
56- { value && < AvatarImage src = { value } alt = { field . label } /> }
58+ { value && < AvatarImage src = { value } alt = { avatarField ? .label } /> }
5759 < AvatarFallback > { getInitials ( ) } </ AvatarFallback >
5860 </ Avatar >
5961 ) ;
@@ -67,7 +69,7 @@ export function AvatarField({ value, onChange, field, readonly }: FieldWidgetPro
6769 onMouseLeave = { ( ) => setIsHovered ( false ) }
6870 >
6971 < Avatar className = "w-16 h-16" >
70- { value && < AvatarImage src = { value } alt = { field . label } /> }
72+ { value && < AvatarImage src = { value } alt = { avatarField ? .label } /> }
7173 < AvatarFallback > { getInitials ( ) } </ AvatarFallback >
7274 </ Avatar >
7375 { ! readonly && isHovered && value && (
0 commit comments