@tencentcloud/chat-uikit-react 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +8 -8
  3. package/dist/cjs/_virtual/extends.js +1 -0
  4. package/dist/cjs/components/Checkbox/index.d.ts +2 -1
  5. package/dist/cjs/components/ConversationCreate/ConversationCreatGroupDetail.js +1 -1
  6. package/dist/cjs/components/ConversationCreate/ConversationCreate.js +1 -1
  7. package/dist/cjs/components/ConversationCreate/ConversationCreateUserSelectList.js +1 -1
  8. package/dist/cjs/components/ConversationCreate/ConversationGroupTypeInfo.js +1 -1
  9. package/dist/cjs/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
  10. package/dist/cjs/components/ConversationPreview/ConversationPreview.js +1 -1
  11. package/dist/cjs/components/ConversationPreview/ConversationPreviewContent.js +1 -1
  12. package/dist/cjs/components/ConversationPreview/utils.js +1 -1
  13. package/dist/cjs/components/ConversationSearch/ConversationSearchInput.d.ts +2 -1
  14. package/dist/cjs/components/ConversationSearch/ConversationSearchInput.js +1 -1
  15. package/dist/cjs/components/ConversationSearch/ConversationSearchResult.js +1 -1
  16. package/dist/cjs/components/DivWithEdit/DivWithEdit.d.ts +2 -1
  17. package/dist/cjs/components/EmptyStateIndicator/EmptyStateIndicator.d.ts +2 -1
  18. package/dist/cjs/components/Icon/Icon.d.ts +2 -1
  19. package/dist/cjs/components/Icon/config.js +1 -1
  20. package/dist/cjs/components/Icon/images/add-friend.svg.js +1 -0
  21. package/dist/cjs/components/Icon/images/down-arrow.png.js +1 -0
  22. package/dist/cjs/components/Icon/images/right-arrow.svg.js +1 -0
  23. package/dist/cjs/components/Icon/type.d.ts +2 -1
  24. package/dist/cjs/components/Icon/type.js +1 -1
  25. package/dist/cjs/components/Input/Input.d.ts +1 -0
  26. package/dist/cjs/components/Input/Input.js +1 -1
  27. package/dist/cjs/components/Plugins/index.d.ts +1 -0
  28. package/dist/cjs/components/Plugins/index.js +1 -1
  29. package/dist/cjs/components/Popup/index.d.ts +1 -0
  30. package/dist/cjs/components/Popup/index.js +1 -1
  31. package/dist/cjs/components/Switch/Switch.d.ts +2 -1
  32. package/dist/cjs/components/TUIChat/TUIChat.js +1 -1
  33. package/dist/cjs/components/TUIChat/hooks/useHandleMessageList.js +1 -1
  34. package/dist/cjs/components/TUIChatHeader/TUIChatHeaderDefault.js +1 -1
  35. package/dist/cjs/components/TUIContact/TUIContact.d.ts +6 -0
  36. package/dist/cjs/components/TUIContact/TUIContact.js +1 -0
  37. package/dist/cjs/components/TUIContact/TUIContactInfo/TUIContactInfo.d.ts +10 -0
  38. package/dist/cjs/components/TUIContact/TUIContactInfo/TUIContactInfo.js +1 -0
  39. package/dist/cjs/components/TUIContact/TUIContactInfo/addFriendInfo.js +1 -0
  40. package/dist/cjs/components/TUIContact/TUIContactInfo/basicInfo.js +1 -0
  41. package/dist/cjs/components/TUIContact/TUIContactInfo/blockInfo.js +1 -0
  42. package/dist/cjs/components/TUIContact/TUIContactInfo/friendApplication.js +1 -0
  43. package/dist/cjs/components/TUIContact/TUIContactInfo/friendInfo.js +1 -0
  44. package/dist/cjs/components/TUIContact/TUIContactInfo/hooks/useContactInfo.js +1 -0
  45. package/dist/cjs/components/TUIContact/TUIContactList/TUIContactList.d.ts +6 -0
  46. package/dist/cjs/components/TUIContact/TUIContactList/TUIContactList.js +1 -0
  47. package/dist/cjs/components/TUIContact/hooks/useTUIContact.js +1 -0
  48. package/dist/cjs/components/TUIContactSearch/TUIContactSearch.js +1 -0
  49. package/dist/cjs/components/TUIContactSearch/hooks/useContactSearch.js +1 -0
  50. package/dist/cjs/components/TUIConversationList/TUIConversationList.js +1 -1
  51. package/dist/cjs/components/TUIKit/TUIKit.d.ts +1 -0
  52. package/dist/cjs/components/TUIKit/TUIKit.js +1 -1
  53. package/dist/cjs/components/TUIKit/hooks/useCreateTUIKitContext.d.ts +4 -0
  54. package/dist/cjs/components/TUIKit/hooks/useCreateTUIKitContext.js +1 -1
  55. package/dist/cjs/components/TUIKit/hooks/useTUIKit.d.ts +23 -3
  56. package/dist/cjs/components/TUIKit/hooks/useTUIKit.js +1 -1
  57. package/dist/cjs/components/TUIManage/TUIManage.d.ts +3 -1
  58. package/dist/cjs/components/TUIManage/TUIManage.js +1 -1
  59. package/dist/cjs/components/TUIMessage/MessageContext.js +1 -1
  60. package/dist/cjs/components/TUIMessage/MessagePlugins.js +1 -1
  61. package/dist/cjs/components/TUIMessage/MessageRevoke.js +1 -1
  62. package/dist/cjs/components/TUIMessage/MessageStatus.js +1 -1
  63. package/dist/cjs/components/TUIMessage/MessageSystem.js +1 -1
  64. package/dist/cjs/components/TUIMessage/MessageTip.js +1 -1
  65. package/dist/cjs/components/TUIMessage/TUIMessage.js +1 -1
  66. package/dist/cjs/components/TUIMessage/hooks/useMessageHandler.js +1 -1
  67. package/dist/cjs/components/TUIMessage/utils/emojiMap.js +1 -1
  68. package/dist/cjs/components/TUIMessageInput/InputPluginsDefalut.js +1 -1
  69. package/dist/cjs/components/TUIMessageInput/TUIForward.js +1 -1
  70. package/dist/cjs/components/TUIMessageInput/TUIMessageInput.js +1 -1
  71. package/dist/cjs/components/TUIMessageInput/TUIMessageInputDefault.js +1 -1
  72. package/dist/cjs/components/TUIMessageInput/hooks/useCreateMessageInputContext.js +1 -1
  73. package/dist/cjs/components/TUIMessageInput/hooks/useEmojiPicker.js +1 -1
  74. package/dist/cjs/components/TUIMessageList/TUIMessageList.js +1 -1
  75. package/dist/cjs/components/TUIMessageList/hooks/useMessageListElement.js +1 -1
  76. package/dist/cjs/components/TUIProfile/TUIProfile.js +1 -1
  77. package/dist/cjs/components/TUIProfile/TUIProfileDefault.js +1 -1
  78. package/dist/cjs/components/untils.js +1 -1
  79. package/dist/cjs/context/ComponentContext.d.ts +2 -1
  80. package/dist/cjs/context/TUIContactContext.d.ts +18 -0
  81. package/dist/cjs/context/TUIContactContext.js +1 -0
  82. package/dist/cjs/context/TUIConversationContext.js +1 -1
  83. package/dist/cjs/context/TUIKitContext.d.ts +4 -0
  84. package/dist/cjs/index.css +1 -1
  85. package/dist/cjs/index.d.css +266 -13
  86. package/dist/cjs/index.d.ts +5 -1
  87. package/dist/cjs/index.js +1 -1
  88. package/dist/cjs/locales/en/TUIChat.js +1 -0
  89. package/dist/cjs/locales/en/TUIContact.js +1 -0
  90. package/dist/cjs/locales/en/TUIConversation.js +1 -0
  91. package/dist/cjs/locales/en/TUIProfile.js +1 -0
  92. package/dist/cjs/locales/en/index.js +1 -0
  93. package/dist/cjs/locales/index.js +1 -0
  94. package/dist/cjs/locales/zh_cn/TUIChat.js +1 -0
  95. package/dist/cjs/locales/zh_cn/TUIContact.js +1 -0
  96. package/dist/cjs/locales/zh_cn/TUIConversation.js +1 -0
  97. package/dist/cjs/locales/zh_cn/TUIProfile.js +1 -0
  98. package/dist/cjs/locales/zh_cn/index.js +1 -0
  99. package/dist/esm/_virtual/extends.js +1 -0
  100. package/dist/esm/components/Checkbox/index.d.ts +2 -1
  101. package/dist/esm/components/ConversationCreate/ConversationCreatGroupDetail.js +1 -1
  102. package/dist/esm/components/ConversationCreate/ConversationCreate.js +1 -1
  103. package/dist/esm/components/ConversationCreate/ConversationCreateUserSelectList.js +1 -1
  104. package/dist/esm/components/ConversationCreate/ConversationGroupTypeInfo.js +1 -1
  105. package/dist/esm/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
  106. package/dist/esm/components/ConversationPreview/ConversationPreview.js +1 -1
  107. package/dist/esm/components/ConversationPreview/ConversationPreviewContent.js +1 -1
  108. package/dist/esm/components/ConversationPreview/utils.js +1 -1
  109. package/dist/esm/components/ConversationSearch/ConversationSearchInput.d.ts +2 -1
  110. package/dist/esm/components/ConversationSearch/ConversationSearchInput.js +1 -1
  111. package/dist/esm/components/ConversationSearch/ConversationSearchResult.js +1 -1
  112. package/dist/esm/components/DivWithEdit/DivWithEdit.d.ts +2 -1
  113. package/dist/esm/components/EmptyStateIndicator/EmptyStateIndicator.d.ts +2 -1
  114. package/dist/esm/components/Icon/Icon.d.ts +2 -1
  115. package/dist/esm/components/Icon/config.js +1 -1
  116. package/dist/esm/components/Icon/images/add-friend.svg.js +1 -0
  117. package/dist/esm/components/Icon/images/down-arrow.png.js +1 -0
  118. package/dist/esm/components/Icon/images/right-arrow.svg.js +1 -0
  119. package/dist/esm/components/Icon/type.d.ts +2 -1
  120. package/dist/esm/components/Icon/type.js +1 -1
  121. package/dist/esm/components/Input/Input.d.ts +1 -0
  122. package/dist/esm/components/Input/Input.js +1 -1
  123. package/dist/esm/components/Plugins/index.d.ts +1 -0
  124. package/dist/esm/components/Plugins/index.js +1 -1
  125. package/dist/esm/components/Popup/index.d.ts +1 -0
  126. package/dist/esm/components/Popup/index.js +1 -1
  127. package/dist/esm/components/Switch/Switch.d.ts +2 -1
  128. package/dist/esm/components/TUIChat/TUIChat.js +1 -1
  129. package/dist/esm/components/TUIChat/hooks/useHandleMessageList.js +1 -1
  130. package/dist/esm/components/TUIChatHeader/TUIChatHeaderDefault.js +1 -1
  131. package/dist/esm/components/TUIContact/TUIContact.d.ts +6 -0
  132. package/dist/esm/components/TUIContact/TUIContact.js +1 -0
  133. package/dist/esm/components/TUIContact/TUIContactInfo/TUIContactInfo.d.ts +10 -0
  134. package/dist/esm/components/TUIContact/TUIContactInfo/TUIContactInfo.js +1 -0
  135. package/dist/esm/components/TUIContact/TUIContactInfo/addFriendInfo.js +1 -0
  136. package/dist/esm/components/TUIContact/TUIContactInfo/basicInfo.js +1 -0
  137. package/dist/esm/components/TUIContact/TUIContactInfo/blockInfo.js +1 -0
  138. package/dist/esm/components/TUIContact/TUIContactInfo/friendApplication.js +1 -0
  139. package/dist/esm/components/TUIContact/TUIContactInfo/friendInfo.js +1 -0
  140. package/dist/esm/components/TUIContact/TUIContactInfo/hooks/useContactInfo.js +1 -0
  141. package/dist/esm/components/TUIContact/TUIContactList/TUIContactList.d.ts +6 -0
  142. package/dist/esm/components/TUIContact/TUIContactList/TUIContactList.js +1 -0
  143. package/dist/esm/components/TUIContact/hooks/useTUIContact.js +1 -0
  144. package/dist/esm/components/TUIContactSearch/TUIContactSearch.js +1 -0
  145. package/dist/esm/components/TUIContactSearch/hooks/useContactSearch.js +1 -0
  146. package/dist/esm/components/TUIConversationList/TUIConversationList.js +1 -1
  147. package/dist/esm/components/TUIKit/TUIKit.d.ts +1 -0
  148. package/dist/esm/components/TUIKit/TUIKit.js +1 -1
  149. package/dist/esm/components/TUIKit/hooks/useCreateTUIKitContext.d.ts +4 -0
  150. package/dist/esm/components/TUIKit/hooks/useCreateTUIKitContext.js +1 -1
  151. package/dist/esm/components/TUIKit/hooks/useTUIKit.d.ts +23 -3
  152. package/dist/esm/components/TUIKit/hooks/useTUIKit.js +1 -1
  153. package/dist/esm/components/TUIManage/TUIManage.d.ts +3 -1
  154. package/dist/esm/components/TUIManage/TUIManage.js +1 -1
  155. package/dist/esm/components/TUIMessage/MessageContext.js +1 -1
  156. package/dist/esm/components/TUIMessage/MessagePlugins.js +1 -1
  157. package/dist/esm/components/TUIMessage/MessageRevoke.js +1 -1
  158. package/dist/esm/components/TUIMessage/MessageStatus.js +1 -1
  159. package/dist/esm/components/TUIMessage/MessageSystem.js +1 -1
  160. package/dist/esm/components/TUIMessage/MessageTip.js +1 -1
  161. package/dist/esm/components/TUIMessage/TUIMessage.js +1 -1
  162. package/dist/esm/components/TUIMessage/hooks/useMessageHandler.js +1 -1
  163. package/dist/esm/components/TUIMessage/utils/emojiMap.js +1 -1
  164. package/dist/esm/components/TUIMessageInput/InputPluginsDefalut.js +1 -1
  165. package/dist/esm/components/TUIMessageInput/TUIForward.js +1 -1
  166. package/dist/esm/components/TUIMessageInput/TUIMessageInput.js +1 -1
  167. package/dist/esm/components/TUIMessageInput/TUIMessageInputDefault.js +1 -1
  168. package/dist/esm/components/TUIMessageInput/hooks/useCreateMessageInputContext.js +1 -1
  169. package/dist/esm/components/TUIMessageInput/hooks/useEmojiPicker.js +1 -1
  170. package/dist/esm/components/TUIMessageList/TUIMessageList.js +1 -1
  171. package/dist/esm/components/TUIMessageList/hooks/useMessageListElement.js +1 -1
  172. package/dist/esm/components/TUIProfile/TUIProfile.js +1 -1
  173. package/dist/esm/components/TUIProfile/TUIProfileDefault.js +1 -1
  174. package/dist/esm/components/untils.js +1 -1
  175. package/dist/esm/context/ComponentContext.d.ts +2 -1
  176. package/dist/esm/context/TUIContactContext.d.ts +18 -0
  177. package/dist/esm/context/TUIContactContext.js +1 -0
  178. package/dist/esm/context/TUIConversationContext.js +1 -1
  179. package/dist/esm/context/TUIKitContext.d.ts +4 -0
  180. package/dist/esm/index.css +1 -1
  181. package/dist/esm/index.d.css +266 -13
  182. package/dist/esm/index.d.ts +5 -1
  183. package/dist/esm/index.js +1 -1
  184. package/dist/esm/locales/en/TUIChat.js +1 -0
  185. package/dist/esm/locales/en/TUIContact.js +1 -0
  186. package/dist/esm/locales/en/TUIConversation.js +1 -0
  187. package/dist/esm/locales/en/TUIProfile.js +1 -0
  188. package/dist/esm/locales/en/index.js +1 -0
  189. package/dist/esm/locales/index.js +1 -0
  190. package/dist/esm/locales/zh_cn/TUIChat.js +1 -0
  191. package/dist/esm/locales/zh_cn/TUIContact.js +1 -0
  192. package/dist/esm/locales/zh_cn/TUIConversation.js +1 -0
  193. package/dist/esm/locales/zh_cn/TUIProfile.js +1 -0
  194. package/dist/esm/locales/zh_cn/index.js +1 -0
  195. package/package.json +5 -1
  196. package/src/components/ConversationCreate/ConversationCreatGroupDetail.tsx +10 -8
  197. package/src/components/ConversationCreate/ConversationCreate.tsx +4 -1
  198. package/src/components/ConversationCreate/ConversationCreateUserSelectList.tsx +6 -4
  199. package/src/components/ConversationCreate/ConversationGroupTypeInfo.tsx +7 -3
  200. package/src/components/ConversationCreate/hooks/useConversationCreate.tsx +0 -1
  201. package/src/components/ConversationPreview/ConversationPreview.tsx +6 -5
  202. package/src/components/ConversationPreview/ConversationPreviewContent.tsx +4 -2
  203. package/src/components/ConversationPreview/utils.tsx +12 -27
  204. package/src/components/ConversationSearch/ConversationSearchInput.tsx +3 -1
  205. package/src/components/Icon/config.ts +5 -0
  206. package/src/components/Icon/images/add-friend.svg +15 -0
  207. package/src/components/Icon/images/down-arrow.png +0 -0
  208. package/src/components/Icon/images/right-arrow.svg +3 -0
  209. package/src/components/Icon/styles/index.scss +0 -1
  210. package/src/components/Icon/type.ts +1 -0
  211. package/src/components/Input/Input.tsx +11 -2
  212. package/src/components/Plugins/index.tsx +26 -2
  213. package/src/components/Popup/index.tsx +20 -2
  214. package/src/components/TUIChat/hooks/useHandleMessageList.tsx +3 -8
  215. package/src/components/TUIChatHeader/TUIChatHeaderDefault.tsx +3 -3
  216. package/src/components/TUIContact/TUIContact.tsx +96 -0
  217. package/src/components/TUIContact/TUIContactInfo/TUIContactInfo.tsx +32 -0
  218. package/src/components/TUIContact/TUIContactInfo/addFriendInfo.tsx +86 -0
  219. package/src/components/TUIContact/TUIContactInfo/basicInfo.tsx +34 -0
  220. package/src/components/TUIContact/TUIContactInfo/blockInfo.tsx +45 -0
  221. package/src/components/TUIContact/TUIContactInfo/friendApplication.tsx +66 -0
  222. package/src/components/TUIContact/TUIContactInfo/friendInfo.tsx +103 -0
  223. package/src/components/TUIContact/TUIContactInfo/hooks/useContactInfo.tsx +112 -0
  224. package/src/components/TUIContact/TUIContactInfo/index.scss +108 -0
  225. package/src/components/TUIContact/TUIContactList/TUIContactList.tsx +162 -0
  226. package/src/components/TUIContact/TUIContactList/index.scss +90 -0
  227. package/src/components/TUIContact/hooks/useTUIContact.tsx +76 -0
  228. package/src/components/TUIContact/index.scss +67 -0
  229. package/src/components/TUIContact/index.ts +3 -0
  230. package/src/components/TUIContactSearch/TUIContactSearch.tsx +100 -0
  231. package/src/components/TUIContactSearch/hooks/useContactSearch.tsx +32 -0
  232. package/src/components/TUIContactSearch/index.scss +24 -0
  233. package/src/components/TUIConversationList/TUIConversationList.tsx +3 -4
  234. package/src/components/TUIConversationList/index.scss +2 -2
  235. package/src/components/TUIKit/TUIKit.tsx +9 -2
  236. package/src/components/TUIKit/hooks/useCreateTUIKitContext.tsx +8 -0
  237. package/src/components/TUIKit/hooks/useTUIKit.tsx +43 -4
  238. package/src/components/TUIManage/TUIManage.tsx +5 -3
  239. package/src/components/TUIMessage/MessagePlugins.tsx +17 -7
  240. package/src/components/TUIMessage/MessageRevoke.tsx +5 -4
  241. package/src/components/TUIMessage/MessageStatus.tsx +3 -3
  242. package/src/components/TUIMessage/hooks/useMessageHandler.ts +4 -2
  243. package/src/components/TUIMessage/styles/layout.scss +2 -9
  244. package/src/components/TUIMessage/utils/emojiMap.ts +6 -2
  245. package/src/components/TUIMessageInput/InputPluginsDefalut.tsx +5 -3
  246. package/src/components/TUIMessageInput/TUIForward.tsx +8 -27
  247. package/src/components/TUIMessageInput/TUIMessageInputDefault.tsx +3 -1
  248. package/src/components/TUIMessageInput/hooks/useCreateMessageInputContext.ts +3 -3
  249. package/src/components/TUIMessageInput/hooks/useEmojiPicker.tsx +7 -1
  250. package/src/components/TUIMessageInput/styles/layout.scss +0 -1
  251. package/src/components/TUIMessageList/TUIMessageList.tsx +3 -1
  252. package/src/components/TUIMessageList/hooks/useMessageListElement.tsx +3 -2
  253. package/src/components/TUIProfile/TUIProfile.tsx +18 -7
  254. package/src/components/TUIProfile/TUIProfileDefault.tsx +64 -6
  255. package/src/components/TUIProfile/styles/layout.scss +1 -1
  256. package/src/components/index.ts +1 -0
  257. package/src/components/untils.ts +26 -6
  258. package/src/context/TUIContactContext.tsx +32 -0
  259. package/src/context/TUIKitContext.tsx +5 -0
  260. package/src/context/index.ts +1 -0
  261. package/src/hooks/useConversation.tsx +3 -3
  262. package/src/locales/en/TUIChat.ts +27 -0
  263. package/src/locales/en/TUIContact.ts +28 -0
  264. package/src/locales/en/TUIConversation.ts +34 -0
  265. package/src/locales/en/TUIProfile.ts +14 -0
  266. package/src/locales/en/index.ts +11 -0
  267. package/src/locales/index.ts +23 -0
  268. package/src/locales/zh_cn/TUIChat.ts +27 -0
  269. package/src/locales/zh_cn/TUIContact.ts +29 -0
  270. package/src/locales/zh_cn/TUIConversation.ts +33 -0
  271. package/src/locales/zh_cn/TUIProfile.ts +14 -0
  272. package/src/locales/zh_cn/index.ts +11 -0
  273. package/tsconfig.json +1 -0
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { Profile } from '@tencentcloud/chat';
4
+ import { Avatar, defaultUserAvatar } from '../../Avatar';
5
+
6
+ interface Props {
7
+ profile: Profile;
8
+ }
9
+ export function UnMemoizedBasicInfo<T extends Props>(
10
+ props: T,
11
+ ): React.ReactElement {
12
+ const { profile } = props;
13
+ const { t } = useTranslation();
14
+ const {
15
+ userID, nick, selfSignature, avatar,
16
+ } = profile;
17
+ return (
18
+ <div className="tui-contact-info-header">
19
+ <div className="header-container">
20
+ <div className="header-container-avatar">
21
+ <Avatar size={60} image={avatar || defaultUserAvatar} />
22
+ <div className="header-container-name">{nick || userID}</div>
23
+ </div>
24
+ <div className="header-container-text">{`ID:${userID}`}</div>
25
+ <div className="header-container-text">
26
+ {t('TUIContact.Signature')}
27
+ :
28
+ {selfSignature || ''}
29
+ </div>
30
+ </div>
31
+ </div>
32
+ );
33
+ }
34
+ export const BasicInfo = React.memo(UnMemoizedBasicInfo);
@@ -0,0 +1,45 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { Profile } from '@tencentcloud/chat';
4
+ import { useTUIKitContext } from '../../../context';
5
+ import { BasicInfo } from './basicInfo';
6
+ import { Switch } from '../../Switch';
7
+ import useContactInfo from './hooks/useContactInfo';
8
+
9
+ interface Props {
10
+ profile: Profile;
11
+ }
12
+ export function UnMemoizedBlockInfo<T extends Props>(
13
+ props: T,
14
+ ): React.ReactElement {
15
+ const { profile } = props;
16
+ const { contactData, setActiveContact } = useTUIKitContext('TUIContact');
17
+ const { t } = useTranslation();
18
+ const [isAddToBlocklist, setIsAddToBlocklist] = useState(false);
19
+
20
+ const {
21
+ removeFromBlocklist,
22
+ } = useContactInfo();
23
+
24
+ useEffect(() => {
25
+ setIsAddToBlocklist(true);
26
+ }, [contactData]);
27
+
28
+ const removeFromBlocklistHandler = async () => {
29
+ await removeFromBlocklist(profile.userID);
30
+ setIsAddToBlocklist(false);
31
+ setActiveContact();
32
+ };
33
+ return (
34
+ <>
35
+ <BasicInfo profile={profile} />
36
+ <div className="tui-contact-info-content">
37
+ <div className="content-item">
38
+ <p className="content-item-label">{t('TUIContact.block')}</p>
39
+ <Switch className="content-item-text" onChange={removeFromBlocklistHandler} checked={isAddToBlocklist} />
40
+ </div>
41
+ </div>
42
+ </>
43
+ );
44
+ }
45
+ export const BlockInfo = React.memo(UnMemoizedBlockInfo);
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import TencentCloudChat, { FriendApplication } from '@tencentcloud/chat';
4
+ import { useTUIKitContext } from '../../../context';
5
+ import { Avatar, defaultUserAvatar } from '../../Avatar';
6
+ import useContactInfo from './hooks/useContactInfo';
7
+
8
+ interface Props {
9
+ application: FriendApplication;
10
+ }
11
+ export function UnMemoizedFriendApplication<T extends Props>(
12
+ props: T,
13
+ ): React.ReactElement {
14
+ const { setActiveContact } = useTUIKitContext('TUIContact');
15
+ const { t } = useTranslation();
16
+ const { application } = props;
17
+ const {
18
+ userID,
19
+ nick,
20
+ avatar,
21
+ type,
22
+ wording,
23
+ } = application;
24
+ const {
25
+ acceptFriendApplication,
26
+ refuseFriendApplication,
27
+ } = useContactInfo();
28
+ const acceptFriendApplicationHandler = () => {
29
+ setActiveContact();
30
+ acceptFriendApplication(userID);
31
+ };
32
+
33
+ const refuseFriendApplicationHandler = () => {
34
+ setActiveContact();
35
+ refuseFriendApplication(userID);
36
+ };
37
+
38
+ return (
39
+ <>
40
+ <div className="tui-contact-info-header">
41
+ <div className="header-container">
42
+ <div className="header-container-avatar">
43
+ <Avatar size={60} image={avatar || defaultUserAvatar} />
44
+ <div className="header-container-name">{nick || userID}</div>
45
+ </div>
46
+ <div className="header-container-text">{`ID:${userID}`}</div>
47
+ </div>
48
+ </div>
49
+ <div className="tui-contact-info-content">
50
+ <div className="content-item">
51
+ <p className="content-item-label">{t('TUIContact.verification info')}</p>
52
+ <p className="content-item-text">{wording}</p>
53
+ </div>
54
+ </div>
55
+ {type === TencentCloudChat.TYPES.SNS_APPLICATION_SENT_TO_ME && (
56
+ <div className="tui-contact-info-content">
57
+ <div className="content-btn-container">
58
+ <div className="content-item-btn delete-btn" role="button" tabIndex={0} onClick={refuseFriendApplicationHandler}>{t('TUIContact.Refuse')}</div>
59
+ <div className="content-item-btn confirm-btn" role="button" tabIndex={0} onClick={acceptFriendApplicationHandler}>{t('TUIContact.Agree')}</div>
60
+ </div>
61
+ </div>
62
+ )}
63
+ </>
64
+ );
65
+ }
66
+ export const FriendApplicationInfo = React.memo(UnMemoizedFriendApplication);
@@ -0,0 +1,103 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { Friend } from '@tencentcloud/chat';
4
+ import { useTUIKitContext } from '../../../context';
5
+ import { BasicInfo } from './basicInfo';
6
+ import { Switch } from '../../Switch';
7
+ import useContactInfo from './hooks/useContactInfo';
8
+ import { DivWithEdit } from '../../DivWithEdit';
9
+ import { useConversation } from '../../../hooks';
10
+ import '../index.scss';
11
+
12
+ interface Props {
13
+ friend: Friend;
14
+ openChat?: () => void,
15
+ }
16
+ export function UnMemoizedFriendInfo<T extends Props>(
17
+ props: T,
18
+ ): React.ReactElement {
19
+ const {
20
+ chat, contactData, setActiveContact, setActiveConversation,
21
+ } = useTUIKitContext('TUIContact');
22
+ const { t } = useTranslation();
23
+ const { friend, openChat } = props;
24
+ const { userID, profile, remark } = friend;
25
+ const [isEditName, setIsEditRemark] = useState('');
26
+ const [remarkValue, setRemarkValue] = useState('');
27
+ const [isAddToBlocklist, setIsAddToBlocklist] = useState(false);
28
+ const {
29
+ addToBlocklist,
30
+ deleteFriend,
31
+ } = useContactInfo();
32
+ const { createConversation } = useConversation(chat);
33
+ useEffect(() => {
34
+ setIsAddToBlocklist(false);
35
+ setRemarkValue(remark);
36
+ }, [contactData, remark]);
37
+
38
+ const handleSetEditRemark = () => {
39
+ setIsEditRemark('remark');
40
+ };
41
+
42
+ const editText = (data?: any) => {
43
+ chat.updateFriend({
44
+ userID,
45
+ remark: data?.value,
46
+ });
47
+ setRemarkValue(data?.value);
48
+ setIsEditRemark('');
49
+ };
50
+
51
+ const addToBlocklistHandler = async () => {
52
+ await addToBlocklist(userID);
53
+ setIsAddToBlocklist(true);
54
+ // 清空右侧 container 内容
55
+ setActiveContact();
56
+ };
57
+
58
+ const deleteFriendHandler = async () => {
59
+ await deleteFriend(userID);
60
+ setActiveContact();
61
+ };
62
+ const openC2CConversation = async () => {
63
+ const conversation = await createConversation(`C2C${userID}`);
64
+ setActiveConversation(conversation);
65
+ openChat();
66
+ };
67
+
68
+ return (
69
+ <>
70
+ <BasicInfo profile={profile} />
71
+ <div className="tui-contact-info-content">
72
+ <div className="content-item">
73
+ <p className="content-item-label">{t('TUIContact.remark')}</p>
74
+ <DivWithEdit
75
+ name="remark"
76
+ className="content-item-text"
77
+ value={remarkValue}
78
+ type="text"
79
+ toggle={handleSetEditRemark}
80
+ isEdit={isEditName === 'remark'}
81
+ confirm={editText}
82
+ close={() => {
83
+ setIsEditRemark('');
84
+ }}
85
+ />
86
+ </div>
87
+ <div className="content-item">
88
+ <p className="content-item-label">{t('TUIContact.block')}</p>
89
+ <Switch
90
+ className="content-item-text"
91
+ onChange={addToBlocklistHandler}
92
+ checked={isAddToBlocklist}
93
+ />
94
+ </div>
95
+ <div className="content-btn-container">
96
+ <div className="content-item-btn delete-btn" role="button" tabIndex={0} onClick={deleteFriendHandler}>{t('TUIContact.Delete friend')}</div>
97
+ <div className="content-item-btn confirm-btn" role="button" tabIndex={0} onClick={openC2CConversation}>{t('TUIContact.Send Message')}</div>
98
+ </div>
99
+ </div>
100
+ </>
101
+ );
102
+ }
103
+ export const FriendInfo = React.memo(UnMemoizedFriendInfo);
@@ -0,0 +1,112 @@
1
+ import React, { useCallback } from 'react';
2
+ import TencentCloudChat from '@tencentcloud/chat';
3
+ import { Toast } from '../../../Toast';
4
+ import { useTUIKitContext } from '../../../../context';
5
+
6
+ function useContactInfo() {
7
+ const { chat } = useTUIKitContext('useContactInfo');
8
+
9
+ // 移除黑名单
10
+ const removeFromBlocklist = useCallback((userID: string) => {
11
+ chat.removeFromBlacklist({
12
+ userIDList: [userID],
13
+ });
14
+ }, [chat]);
15
+
16
+ // 添加好友
17
+ const addFriend = useCallback((param: any) => {
18
+ chat.addFriend({
19
+ to: param?.userID,
20
+ source: 'AddSource_Type_Web',
21
+ remark: param?.remark,
22
+ wording: param?.wording,
23
+ }).catch((error: any) => {
24
+ console.warn('delete friend failed:', error);
25
+ Toast({
26
+ text: error,
27
+ type: 'error',
28
+ });
29
+ });
30
+ }, [chat]);
31
+
32
+ // 删除好友
33
+ const deleteFriend = useCallback((userID: string) => {
34
+ chat.deleteFriend({
35
+ userIDList: [userID],
36
+ });
37
+ }, [chat]);
38
+
39
+ // 添加黑名单
40
+ const addToBlocklist = useCallback((userID: string) => {
41
+ chat.addToBlacklist({
42
+ userIDList: [userID],
43
+ });
44
+ }, [chat]);
45
+
46
+ const acceptFriendApplication = useCallback((userID: string) => {
47
+ chat.acceptFriendApplication({
48
+ userID,
49
+ type: TencentCloudChat.TYPES.SNS_APPLICATION_AGREE_AND_ADD,
50
+ });
51
+ }, [chat]);
52
+
53
+ const refuseFriendApplication = useCallback((userID: string) => {
54
+ chat.refuseFriendApplication({
55
+ userID,
56
+ });
57
+ }, [chat]);
58
+ // 好友相关
59
+ // 判断是否为双向好友关系
60
+ const isFriend = (info: any): Promise<boolean> => (
61
+ new Promise((resolve, reject) => {
62
+ chat.checkFriend({
63
+ userIDList: [info?.userID],
64
+ type: TencentCloudChat.TYPES.SNS_CHECK_TYPE_BOTH,
65
+ })
66
+ .then((res: any) => {
67
+ switch (res?.data?.successUserIDList[0]?.relation) {
68
+ // 无好友关系:A 的好友表中没有 B,B 的好友表中也没有 A
69
+ case TencentCloudChat.TYPES.SNS_TYPE_NO_RELATION:
70
+ resolve(false);
71
+ break;
72
+ // 单项好友:A 的好友表中有 B,但 B 的好友表中没有 A
73
+ case TencentCloudChat.TYPES.SNS_TYPE_A_WITH_B:
74
+ resolve(false);
75
+ break;
76
+ // 单项好友:A 的好友表中没有 B,但 B 的好友表中有 A
77
+ case TencentCloudChat.TYPES.SNS_TYPE_B_WITH_A:
78
+ resolve(false);
79
+ break;
80
+ // 双向好友关系
81
+ case TencentCloudChat.TYPES.SNS_TYPE_BOTH_WAY:
82
+ resolve(true);
83
+ break;
84
+ default:
85
+ resolve(false);
86
+ break;
87
+ }
88
+ })
89
+ .catch((error: any) => {
90
+ console.warn('checkFriend error', error);
91
+ reject(error);
92
+ });
93
+ })
94
+ );
95
+ const isBlock = async (userID: string) => {
96
+ const { data } = await chat.getBlacklist();
97
+ return data.includes(userID);
98
+ };
99
+
100
+ return {
101
+ addToBlocklist,
102
+ removeFromBlocklist,
103
+ isFriend,
104
+ isBlock,
105
+ addFriend,
106
+ deleteFriend,
107
+ acceptFriendApplication,
108
+ refuseFriendApplication,
109
+ };
110
+ }
111
+
112
+ export default useContactInfo;
@@ -0,0 +1,108 @@
1
+ .tui-contact-info {
2
+ width: 100%;
3
+ height: 100%;
4
+ display: flex;
5
+ padding: 60px;
6
+ box-sizing: border-box;
7
+ flex-direction: column;
8
+ overflow: hidden;
9
+ .tui-contact-info-header {
10
+ padding-bottom: 15px;
11
+ border-bottom: 1px solid #ddd;
12
+ overflow: hidden;
13
+ box-sizing: border-box;
14
+ width: 100%;
15
+ .header-container {
16
+ flex: 1;
17
+ .header-container-avatar {
18
+ display: flex;
19
+ align-items: center;
20
+ padding: 10px;
21
+ }
22
+ .header-container-name {
23
+ font-size: 24px;
24
+ padding: 15px;
25
+ }
26
+ .header-container-text {
27
+ font-size: 16px;
28
+ line-height: 50px;
29
+ font-weight: 400;
30
+ color: #999999;
31
+ }
32
+ }
33
+ }
34
+ .tui-contact-info-content {
35
+ padding: 15px 0;
36
+ overflow: hidden;
37
+ .content-item {
38
+ display: flex;
39
+ flex-direction: row;
40
+ align-items: center;
41
+ padding: 6px 0;
42
+ font-size: 16px;
43
+ font-weight: 400;
44
+ min-height: 56px;
45
+ }
46
+ .content-item-wording {
47
+ padding: 6px 0;
48
+ font-size: 16px;
49
+ font-weight: 400;
50
+ min-height: 56px;
51
+ }
52
+ .content-item-wording-text {
53
+ margin-top: 5px;
54
+ flex: 1;
55
+ border: 1px solid #e8e8e9;
56
+ border-radius: 4px;
57
+ padding: 4px;
58
+ color: inherit;
59
+ resize: none;
60
+ height: 100px;
61
+ width: 95%;
62
+ }
63
+ .content-item-label {
64
+ color: #999;
65
+ margin-right: 5px;
66
+ }
67
+ .content-item-text {
68
+ flex: 1;
69
+ display: flex;
70
+ flex-direction: row;
71
+ color: #333;
72
+ overflow: hidden;
73
+ }
74
+ .content-btn-container {
75
+ display: flex;
76
+ padding: 30px;
77
+ justify-content: center;
78
+ .content-item-btn {
79
+ margin: 15px;
80
+ width: 122px;
81
+ height: 26px;
82
+ padding: 8px 20px;
83
+ border-radius: 25px;
84
+ border: none;
85
+ font-size: 14px;
86
+ text-align: center;
87
+ line-height: 26px;
88
+ font-weight: 400;
89
+ letter-spacing: 0;
90
+ min-width: 100px;
91
+ cursor: pointer;
92
+ -webkit-user-select: none;
93
+ user-select: none;
94
+ }
95
+ .delete-btn {
96
+ border: 1px solid #e54545;
97
+ background: transparent;
98
+ color: #e54545;
99
+ }
100
+ .confirm-btn {
101
+ border: 1px solid #006eff;
102
+ background: #006eff;
103
+ color: #fff;
104
+ }
105
+
106
+ }
107
+ }
108
+ }
@@ -0,0 +1,162 @@
1
+ import React, { useState } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import TencentCloudChat from '@tencentcloud/chat';
4
+ import { useTUIKitContext, useTUIContactContext } from '../../../context';
5
+ import useContactInfo from '../TUIContactInfo/hooks/useContactInfo';
6
+
7
+ import { Avatar, defaultUserAvatar } from '../../Avatar';
8
+ import rightArrow from '../../Icon/images/right-arrow.svg';
9
+ import downArrow from '../../Icon/images/down-arrow.png';
10
+
11
+ import './index.scss';
12
+
13
+ function UnMemoizedTUIContactList<T>(): React.ReactElement {
14
+ const { setActiveContact } = useTUIKitContext();
15
+ const { t } = useTranslation();
16
+ const {
17
+ isShowContactList, friendList, blocklistProfile, friendApplicationList,
18
+ } = useTUIContactContext('TUIContactList');
19
+ const {
20
+ acceptFriendApplication,
21
+ } = useContactInfo();
22
+
23
+ const [iShowFriendApplication, setShowFriendApplication] = useState(false);
24
+ const [iShowFriends, setShowFriends] = useState(false);
25
+ const [isShowBlocklist, setShowBlocklist] = useState(false);
26
+
27
+ const acceptFriendApplicationHandle = (e: any, userID: string) => {
28
+ e.stopPropagation();
29
+ acceptFriendApplication(userID);
30
+ setActiveContact();
31
+ };
32
+ return (
33
+ isShowContactList && (
34
+ <div className="tui-contacts-list">
35
+ <div
36
+ className="tui-contacts-title"
37
+ role="button"
38
+ tabIndex={0}
39
+ onClick={() => setShowFriendApplication(!iShowFriendApplication)}
40
+ >
41
+ <p className="tui-contacts-list-title">{t('TUIContact.New Contacts')}</p>
42
+ <div className="tui-contacts-list-icon">
43
+ <img src={iShowFriendApplication ? downArrow : rightArrow} alt="" />
44
+ </div>
45
+ </div>
46
+ {iShowFriendApplication
47
+ && friendApplicationList.map((item, index) => {
48
+ const {
49
+ userID, avatar, nick, wording, type,
50
+ } = item;
51
+ return (
52
+ <div
53
+ role="button"
54
+ tabIndex={0}
55
+ className="tui-contacts-list-item"
56
+ key={userID}
57
+ onClick={(e) => {
58
+ e.stopPropagation();
59
+ setActiveContact({
60
+ type: 'friendApplication',
61
+ data: item,
62
+ });
63
+ }}
64
+ >
65
+ <Avatar size={30} image={avatar || defaultUserAvatar} />
66
+ <div className="tui-contacts-list-item-card">
67
+ <div>
68
+ <p className="tui-contacts-list-item-name text-ellipsis">
69
+ {nick || userID}
70
+ </p>
71
+ {wording !== '' && (
72
+ <p className="tui-contacts-list-item-text text-ellipsis">
73
+ {wording}
74
+ </p>
75
+ )}
76
+ </div>
77
+ {type === TencentCloudChat.TYPES.SNS_APPLICATION_SENT_BY_ME && (
78
+ <p className="tui-contacts-list-btn-text text-ellipsis">{t('TUIContact.waiting for verification')}</p>
79
+ )}
80
+ {type === TencentCloudChat.TYPES.SNS_APPLICATION_SENT_TO_ME && (
81
+ <div
82
+ className="application-btn"
83
+ role="button"
84
+ tabIndex={0}
85
+ onClick={(e) => {
86
+ acceptFriendApplicationHandle(e, userID);
87
+ }}
88
+ >
89
+ {t('TUIContact.Agree')}
90
+ </div>
91
+ )}
92
+ </div>
93
+ </div>
94
+ );
95
+ })}
96
+ <div
97
+ className="tui-contacts-title"
98
+ role="button"
99
+ tabIndex={0}
100
+ onClick={() => setShowBlocklist(!isShowBlocklist)}
101
+ >
102
+ <div className="tui-contacts-list-title">{t('TUIContact.Blocked List')}</div>
103
+ <div className="tui-contacts-list-icon">
104
+ <img src={isShowBlocklist ? downArrow : rightArrow} alt="" />
105
+ </div>
106
+ </div>
107
+ {isShowBlocklist
108
+ && blocklistProfile.map((item, index) => {
109
+ const { userID, avatar, nick } = item;
110
+ return (
111
+ <div
112
+ role="button"
113
+ tabIndex={0}
114
+ className="tui-contacts-list-item"
115
+ key={userID}
116
+ onClick={() => {
117
+ setActiveContact({ type: 'block', data: item });
118
+ }}
119
+ >
120
+ <Avatar size={30} image={avatar || defaultUserAvatar} />
121
+ <div className="tui-contacts-list-item-container">
122
+ <p className="tui-contacts-list-item-name">{ nick || userID}</p>
123
+ </div>
124
+ </div>
125
+ );
126
+ })}
127
+ <div
128
+ className="tui-contacts-title"
129
+ role="button"
130
+ tabIndex={0}
131
+ onClick={() => setShowFriends(!iShowFriends)}
132
+ >
133
+ <div className="tui-contacts-list-title">{t('TUIContact.Friend')}</div>
134
+ <div className="tui-contacts-list-icon">
135
+ <img src={iShowFriends ? downArrow : rightArrow} alt="" />
136
+ </div>
137
+ </div>
138
+ {iShowFriends
139
+ && friendList.map((item, index) => {
140
+ const { userID, avatar, nick } = item.profile;
141
+ return (
142
+ <div
143
+ className="tui-contacts-list-item"
144
+ key={userID}
145
+ role="button"
146
+ tabIndex={0}
147
+ onClick={() => {
148
+ setActiveContact({ type: 'friend', data: item });
149
+ }}
150
+ >
151
+ <Avatar size={30} image={avatar || defaultUserAvatar} />
152
+ <div className="tui-contacts-list-item-container">
153
+ <p className="tui-contacts-list-item-name">{item.remark || nick || userID}</p>
154
+ </div>
155
+ </div>
156
+ );
157
+ })}
158
+ </div>
159
+ )
160
+ );
161
+ }
162
+ export const TUIContactList = React.memo(UnMemoizedTUIContactList);