@@ -25,6 +25,7 @@ import { IconControl } from "comps/controls/iconControl";
2525import {
2626 clickEvent ,
2727 eventHandlerControl ,
28+ doubleClickEvent ,
2829} from "../controls/eventHandlerControl" ;
2930import { Avatar , AvatarProps , Badge , Dropdown , Menu } from "antd" ;
3031import { LeftRightControl , dropdownControl } from "../controls/dropdownControl" ;
@@ -34,6 +35,8 @@ import { BadgeBasicSection, badgeChildren } from "./badgeComp/badgeConstants";
3435import { DropdownOptionControl } from "../controls/optionsControl" ;
3536import { ReactElement , useContext , useEffect } from "react" ;
3637import { CompNameContext , EditorContext } from "../editorState" ;
38+ import { useCompClickEventHandler } from "@lowcoder-ee/comps/utils/useCompClickEventHandler" ;
39+
3740
3841const AvatarWrapper = styled ( Avatar ) < AvatarProps & { $cursorPointer ?: boolean , $style : AvatarStyleType } > `
3942 background: ${ ( props ) => props . $style . background } ;
@@ -106,7 +109,7 @@ padding: ${props=>props.$style.padding};
106109background: ${ props => props . $style . background } ;
107110text-decoration: ${ props => props . $style . textDecoration } ;
108111`
109- const EventOptions = [ clickEvent ] as const ;
112+ const EventOptions = [ clickEvent , doubleClickEvent ] as const ;
110113const sharpOptions = [
111114 { label : trans ( "avatarComp.square" ) , value : "square" } ,
112115 { label : trans ( "avatarComp.circle" ) , value : "circle" } ,
@@ -140,6 +143,8 @@ const childrenMap = {
140143const AvatarView = ( props : RecordConstructorToView < typeof childrenMap > ) => {
141144 const { shape, title, src, iconSize } = props ;
142145 const comp = useContext ( EditorContext ) . getUICompByName ( useContext ( CompNameContext ) ) ;
146+ const handleClickEvent = useCompClickEventHandler ( { onEvent : props . onEvent } )
147+
143148 // const eventsCount = comp ? Object.keys(comp?.children.comp.children.onEvent.children).length : 0;
144149 const hasIcon = props . options . findIndex ( ( option ) => ( option . prefixIcon as ReactElement ) ?. props . value ) > - 1 ;
145150 const items = props . options
@@ -181,8 +186,7 @@ const AvatarView = (props: RecordConstructorToView<typeof childrenMap>) => {
181186 shape = { shape }
182187 $style = { props . avatarStyle }
183188 src = { src . value }
184- // $cursorPointer={eventsCount > 0}
185- onClick = { ( ) => props . onEvent ( "click" ) }
189+ onClick = { handleClickEvent }
186190 >
187191 { title . value }
188192 </ AvatarWrapper >
0 commit comments