@@ -9,6 +9,7 @@ import classNames from 'classnames'
99
1010import { MdVideoCall , MdVolumeOff , MdVolumeUp } from 'react-icons/md'
1111import { IChatItemProps } from '../type'
12+ import { FaArrowDown , FaArrowUp } from 'react-icons/fa'
1213
1314const ChatItem : React . FC < IChatItemProps > = ( {
1415 avatarFlexible = false ,
@@ -65,86 +66,99 @@ const ChatItem: React.FC<IChatItemProps> = ({
6566 if ( onDrag ) setOnDrag ( false )
6667 }
6768
68- return (
69- < div
70- key = { props . id as Key }
71- className = { classNames ( 'rce-container-citem' , props . className ) }
72- onClick = { handleOnClick }
73- onContextMenu = { props . onContextMenu }
74- >
75- < div className = 'rce-citem' onDragOver = { onDragOver } onDragEnter = { onDragEnter } onDragLeave = { onDragLeave } onDrop = { onDrop } >
76- { ! ! props . onDragComponent && onDrag && props . onDragComponent ( props . id ) }
77- { ( ( onDrag && ! props . onDragComponent ) || ! onDrag ) && [
78- < div
79- key = { 'avatar' }
80- className = { classNames ( 'rce-citem-avatar' , { 'rce-citem-status-encircle' : statusColorType === 'encircle' } ) }
81- >
82- < Avatar
83- src = { props . avatar }
84- alt = { props . alt }
85- className = { statusColorType === 'encircle' ? 'rce-citem-avatar-encircle-status' : '' }
86- size = 'large'
87- letterItem = { props . letterItem }
88- sideElement = {
89- props . statusColor ? (
90- < span
91- className = 'rce-citem-status'
92- style = {
93- statusColorType === 'encircle'
94- ? {
95- border : `solid 2px ${ props . statusColor } ` ,
96- }
97- : {
98- backgroundColor : props . statusColor ,
99- }
100- }
101- >
102- { props . statusText }
103- </ span >
104- ) : (
105- < > </ >
106- )
107- }
108- onError = { onAvatarError }
109- lazyLoadingImage = { lazyLoadingImage }
110- type = { classNames ( 'circle' , { 'flexible' : avatarFlexible } ) }
111- />
112- </ div > ,
113- < div key = { 'rce-citem-body' } className = 'rce-citem-body' >
114- < div className = 'rce-citem-body--top' >
115- < div className = 'rce-citem-body--top-title' > { props . title } </ div >
116- < div className = 'rce-citem-body--top-time' > { date && ( props . dateString || format ( date ) ) } </ div >
117- </ div >
69+ const onExpandItem = ( e : React . MouseEvent , id : string | number ) => {
70+ e . preventDefault ( ) ;
71+ e . stopPropagation ( ) ;
72+ if ( props . onExpandItem instanceof Function ) props . onExpandItem ( id ) ;
73+ }
11874
119- < div className = 'rce-citem-body--bottom' >
120- < div className = 'rce-citem-body--bottom-title' > { props . subtitle } </ div >
121- < div className = 'rce-citem-body--bottom-tools' onMouseEnter = { handleOnMouseEnter } onMouseLeave = { handleOnMouseLeave } >
122- { props . showMute && (
123- < div className = 'rce-citem-body--bottom-tools-item' onClick = { props . onClickMute } >
124- { props . muted === true && < MdVolumeOff /> }
125- { props . muted === false && < MdVolumeUp /> }
126- </ div >
127- ) }
128- { props . showVideoCall && (
129- < div className = 'rce-citem-body--bottom-tools-item' onClick = { props . onClickVideoCall } >
130- < MdVideoCall />
131- </ div >
132- ) }
133- </ div >
134- < div className = 'rce-citem-body--bottom-tools-item-hidden-hover' >
135- { props . showMute && props . muted && (
136- < div className = 'rce-citem-body--bottom-tools-item' >
137- < MdVolumeOff />
138- </ div >
139- ) }
140- </ div >
141- < div className = 'rce-citem-body--bottom-status' > { unread && unread > 0 ? < span > { unread } </ span > : null } </ div >
142- { props . customStatusComponents !== undefined ? props . customStatusComponents . map ( Item => < Item /> ) : null }
75+ return (
76+ < >
77+ < div
78+ key = { props . id as Key }
79+ className = { classNames ( 'rce-container-citem' , props . className ) }
80+ onClick = { handleOnClick }
81+ onContextMenu = { props . onContextMenu }
82+ >
83+ < div className = 'rce-citem' onDragOver = { onDragOver } onDragEnter = { onDragEnter } onDragLeave = { onDragLeave } onDrop = { onDrop } >
84+ { ! ! props . onDragComponent && onDrag && props . onDragComponent ( props . id ) }
85+ { ( ( onDrag && ! props . onDragComponent ) || ! onDrag ) && [
86+ < div
87+ key = { 'avatar' }
88+ className = { classNames ( 'rce-citem-avatar' , { 'rce-citem-status-encircle' : statusColorType === 'encircle' } ) }
89+ >
90+ < Avatar
91+ src = { props . avatar }
92+ alt = { props . alt }
93+ className = { statusColorType === 'encircle' ? 'rce-citem-avatar-encircle-status' : '' }
94+ size = { props . avatarSize || 'large' }
95+ letterItem = { props . letterItem }
96+ sideElement = {
97+ props . statusColor ? (
98+ < span
99+ className = 'rce-citem-status'
100+ style = {
101+ statusColorType === 'encircle'
102+ ? {
103+ border : `solid 2px ${ props . statusColor } ` ,
104+ }
105+ : {
106+ backgroundColor : props . statusColor ,
107+ }
108+ }
109+ >
110+ { props . statusText }
111+ </ span >
112+ ) : (
113+ < > </ >
114+ )
115+ }
116+ onError = { onAvatarError }
117+ lazyLoadingImage = { lazyLoadingImage }
118+ type = { classNames ( 'circle' , { 'flexible' : avatarFlexible } ) }
119+ />
120+ { props . subList && props . subList . length > 0 && (
121+ < button className = 'rce-citem-expand-button' onClick = { ( e ) => onExpandItem ( e , props . id ) } >
122+ { props . expanded ? < FaArrowUp /> : < FaArrowDown /> }
123+ </ button >
124+ ) }
125+ </ div > ,
126+ < div key = { 'rce-citem-body' } className = 'rce-citem-body' >
127+ < div className = 'rce-citem-body--top' >
128+ < div className = 'rce-citem-body--top-title' > { props . title } </ div >
129+ < div className = 'rce-citem-body--top-time' > { date && ( props . dateString || format ( date ) ) } </ div >
130+ </ div >
131+
132+ < div className = 'rce-citem-body--bottom' >
133+ < div className = 'rce-citem-body--bottom-title' > { props . subtitle } </ div >
134+ < div className = 'rce-citem-body--bottom-tools' onMouseEnter = { handleOnMouseEnter } onMouseLeave = { handleOnMouseLeave } >
135+ { props . showMute && (
136+ < div className = 'rce-citem-body--bottom-tools-item' onClick = { props . onClickMute } >
137+ { props . muted === true && < MdVolumeOff /> }
138+ { props . muted === false && < MdVolumeUp /> }
139+ </ div >
140+ ) }
141+ { props . showVideoCall && (
142+ < div className = 'rce-citem-body--bottom-tools-item' onClick = { props . onClickVideoCall } >
143+ < MdVideoCall />
144+ </ div >
145+ ) }
146+ </ div >
147+ < div className = 'rce-citem-body--bottom-tools-item-hidden-hover' >
148+ { props . showMute && props . muted && (
149+ < div className = 'rce-citem-body--bottom-tools-item' >
150+ < MdVolumeOff />
151+ </ div >
152+ ) }
153+ </ div >
154+ < div className = 'rce-citem-body--bottom-status' > { unread && unread > 0 ? < span > { unread } </ span > : null } </ div >
155+ { props . customStatusComponents !== undefined ? props . customStatusComponents . map ( Item => < Item /> ) : null }
156+ </ div >
157+ </ div > ,
158+ ] }
143159 </ div >
144- </ div > ,
145- ] }
146- </ div >
147- </ div >
160+ </ div >
161+ </ >
148162 )
149163}
150164
0 commit comments