@@ -14,6 +14,7 @@ import { MdVideoCall, MdVolumeOff, MdVolumeUp } from 'react-icons/lib/md';
1414function ChatItem ( props ) {
1515 const [ onHoverTool , setOnHoverTool ] = useState ( false ) ;
1616 const statusColorType = props . statusColorType ;
17+ const [ onDrag , setOnDrag ] = useState ( false ) ;
1718
1819 const handleOnMouseEnter = ( ) => {
1920 setOnHoverTool ( true ) ;
@@ -32,102 +33,138 @@ function ChatItem(props) {
3233 props . onClick ( ) ;
3334 }
3435
36+ const onDragOver = ( e ) => {
37+ e . preventDefault ( ) ;
38+ if ( props . onDragOver instanceof Function )
39+ props . onDragOver ( e , props . id )
40+ }
41+
42+ const onDragEnter = ( e ) => {
43+ e . preventDefault ( ) ;
44+ if ( props . onDragEnter instanceof Function )
45+ props . onDragEnter ( e , props . id )
46+ if ( ! onDrag )
47+ setOnDrag ( true ) ;
48+ }
49+
50+ const onDragLeave = ( e ) => {
51+ e . preventDefault ( ) ;
52+ if ( props . onDragLeave instanceof Function )
53+ props . onDragLeave ( e , props . id )
54+ if ( onDrag )
55+ setOnDrag ( false ) ;
56+ }
57+
58+ const onDrop = ( e ) => {
59+ e . preventDefault ( ) ;
60+ if ( props . onDrop instanceof Function )
61+ props . onDrop ( e , props . id )
62+ if ( onDrag )
63+ setOnDrag ( false ) ;
64+ }
65+
3566 return (
3667 < div
68+ key = { props . id }
3769 className = { classNames ( 'rce-container-citem' , props . className ) }
3870 onClick = { handleOnClick }
3971 onContextMenu = { props . onContextMenu } >
40- < div className = 'rce-citem' >
41- < div className = { classNames (
42- 'rce-citem-avatar' ,
43- {
44- 'rce-citem-status-encircle' : statusColorType === 'encircle' ,
45- }
46- ) } >
47- < Avatar
48- src = { props . avatar }
49- alt = { props . alt }
50- className = { statusColorType === 'encircle' ? 'rce-citem-avatar-encircle-status' : '' }
51- size = 'large'
52- letterItem = { props . letterItem }
53- sideElement = {
54- props . statusColor &&
55- < span
56- className = 'rce-citem-status'
57- style = { statusColorType === 'encircle' ? {
58- border : `solid 2px ${ props . statusColor } `
59- } : {
60- backgroundColor : props . statusColor ,
61- } } >
62- { props . statusText }
63- </ span >
64- }
65- onError = { props . onAvatarError }
66- lazyLoadingImage = { props . lazyLoadingImage }
67- type = { classNames ( 'circle' , { 'flexible' : props . avatarFlexible } ) } />
68- </ div >
69-
70- < div className = 'rce-citem-body' >
71- < div className = 'rce-citem-body--top' >
72- < div className = 'rce-citem-body--top-title' >
73- { props . title }
74- </ div >
75- < div className = 'rce-citem-body--top-time' >
76- {
77- props . date &&
78- ! isNaN ( props . date ) &&
79- (
80- props . dateString ||
81- format ( props . date )
82- )
72+ < div className = "rce-citem"
73+ onDragOver = { onDragOver }
74+ onDragEnter = { onDragEnter }
75+ onDragLeave = { onDragLeave }
76+ onDrop = { onDrop } >
77+ {
78+ ! ! props . onDragComponent && onDrag &&
79+ props . onDragComponent ( props . id )
80+ }
81+ { ( ( onDrag && ! props . onDragComponent ) || ! onDrag ) && [
82+ < div className = { classNames ( "rce-citem-avatar" , { 'rce-citem-status-encircle' : statusColorType === 'encircle' } ) } >
83+ < Avatar
84+ src = { props . avatar }
85+ alt = { props . alt }
86+ className = { statusColorType === 'encircle' ? 'rce-citem-avatar-encircle-status' : '' }
87+ size = "large"
88+ letterItem = { props . letterItem }
89+ sideElement = {
90+ props . statusColor &&
91+ < span
92+ className = 'rce-citem-status'
93+ style = { statusColorType === 'encircle' ? {
94+ border : `solid 2px ${ props . statusColor } `
95+ } : {
96+ backgroundColor : props . statusColor ,
97+ } } >
98+ { props . statusText }
99+ </ span >
83100 }
101+ onError = { props . onAvatarError }
102+ lazyLoadingImage = { props . lazyLoadingImage }
103+ type = { classNames ( 'circle' , { 'flexible' : props . avatarFlexible } ) } />
84104 </ div >
85- </ div >
105+ ,
106+ < div className = "rce-citem-body" >
107+ < div className = "rce-citem-body--top" >
108+ < div className = "rce-citem-body--top-title" >
109+ { props . title }
110+ </ div >
111+ < div className = "rce-citem-body--top-time" >
112+ {
113+ props . date &&
114+ ! isNaN ( props . date ) &&
115+ (
116+ props . dateString ||
117+ format ( props . date )
118+ )
119+ }
120+ </ div >
121+ </ div >
86122
87- < div className = 'rce-citem-body--bottom' >
88- < div className = 'rce-citem-body--bottom-title' >
89- { props . subtitle }
90- </ div >
91- < div className = 'rce-citem-body--bottom-tools' onMouseEnter = { handleOnMouseEnter } onMouseLeave = { handleOnMouseLeave } >
92- {
93- props . showMute &&
94- < div className = 'rce-citem-body--bottom-tools-item'
95- onClick = { props . onClickMute } >
123+ < div className = "rce-citem-body--bottom" >
124+ < div className = "rce-citem-body--bottom-title" >
125+ { props . subtitle }
126+ </ div >
127+ < div className = "rce-citem-body--bottom-tools" onMouseEnter = { handleOnMouseEnter } onMouseLeave = { handleOnMouseLeave } >
96128 {
97- props . muted === true &&
98- < MdVolumeOff />
129+ props . showMute &&
130+ < div className = "rce-citem-body--bottom-tools-item"
131+ onClick = { props . onClickMute } >
132+ {
133+ props . muted === true &&
134+ < MdVolumeOff />
135+ }
136+ {
137+ props . muted === false &&
138+ < MdVolumeUp />
139+ }
140+ </ div >
99141 }
100142 {
101- props . muted === false &&
102- < MdVolumeUp />
143+ props . showVideoCall &&
144+ < div className = "rce-citem-body--bottom-tools-item"
145+ onClick = { props . onClickVideoCall } >
146+ < MdVideoCall />
147+ </ div >
103148 }
104149 </ div >
105- }
106- {
107- props . showVideoCall &&
108- < div className = 'rce-citem-body--bottom-tools-item'
109- onClick = { props . onClickVideoCall } >
110- < MdVideoCall />
150+ < div className = "rce-citem-body--bottom-tools-item-hidden-hover" >
151+ {
152+ props . showMute &&
153+ props . muted &&
154+ < div className = "rce-citem-body--bottom-tools-item" >
155+ < MdVolumeOff />
156+ </ div >
157+ }
111158 </ div >
112- }
113- </ div >
114- < div className = 'rce-citem-body--bottom-tools-item-hidden-hover' >
115- {
116- props . showMute &&
117- props . muted &&
118- < div className = 'rce-citem-body--bottom-tools-item' >
119- < MdVolumeOff />
159+ < div className = "rce-citem-body--bottom-status" >
160+ {
161+ props . unread > 0 &&
162+ < span > { props . unread } </ span >
163+ }
120164 </ div >
121- }
122- </ div >
123- < div className = 'rce-citem-body--bottom-status' >
124- {
125- props . unread > 0 &&
126- < span > { props . unread } </ span >
127- }
128165 </ div >
129166 </ div >
130- </ div >
167+ ] }
131168 </ div >
132169 </ div >
133170 ) ;
0 commit comments