@tencentcloud/chat-uikit-react 1.2.2 → 2.1.2

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 (255) hide show
  1. package/.eslintrc.js +2 -1
  2. package/CHANGELOG.md +13 -2
  3. package/dist/cjs/components/ConversationCreate/ConversationCreatGroupDetail.js +1 -1
  4. package/dist/cjs/components/ConversationCreate/ConversationCreateUserSelectList.js +1 -1
  5. package/dist/cjs/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
  6. package/dist/cjs/components/ConversationPreview/ConversationPreview.d.ts +2 -0
  7. package/dist/cjs/components/ConversationPreview/ConversationPreview.js +1 -1
  8. package/dist/cjs/components/ConversationPreview/ConversationPreviewContent.js +1 -1
  9. package/dist/cjs/components/ConversationPreview/utils.js +1 -1
  10. package/dist/cjs/components/ConversationSearch/ConversationSearchResult.js +1 -1
  11. package/dist/cjs/components/Icon/config.js +1 -1
  12. package/dist/cjs/components/Icon/images/chats-selected.svg.js +1 -0
  13. package/dist/cjs/components/Icon/images/chats.svg.js +1 -0
  14. package/dist/cjs/components/Icon/images/contacts-selected.svg.js +1 -0
  15. package/dist/cjs/components/Icon/images/contacts.svg.js +1 -0
  16. package/dist/cjs/components/Icon/images/files.png.js +1 -0
  17. package/dist/cjs/components/Icon/images/image.png.js +1 -1
  18. package/dist/cjs/components/Icon/images/video.png.js +1 -1
  19. package/dist/cjs/components/TUIChat/TUIChat.d.ts +5 -0
  20. package/dist/cjs/components/TUIChat/TUIChat.js +1 -1
  21. package/dist/cjs/components/TUIChat/TUIChatState.js +1 -1
  22. package/dist/cjs/components/TUIChat/hooks/useHandleMessage.js +1 -1
  23. package/dist/cjs/components/TUIChat/hooks/useHandleMessageList.js +1 -1
  24. package/dist/cjs/components/TUIChat/unitls.js +1 -1
  25. package/dist/cjs/components/TUIChatHeader/TUIChatHeaderDefault.js +1 -1
  26. package/dist/cjs/components/TUIContact/TUIContact.js +1 -1
  27. package/dist/cjs/components/TUIContact/TUIContactInfo/TUIContactInfo.js +1 -1
  28. package/dist/cjs/components/TUIContact/TUIContactInfo/basicInfo.js +1 -1
  29. package/dist/cjs/components/TUIContact/TUIContactInfo/friendInfo.js +1 -1
  30. package/dist/cjs/components/TUIContact/TUIContactList/TUIContactList.js +1 -1
  31. package/dist/cjs/components/TUIConversation/TUIConversation.js +1 -1
  32. package/dist/cjs/components/TUIConversationList/TUIConversationList.d.ts +1 -0
  33. package/dist/cjs/components/TUIConversationList/TUIConversationList.js +1 -1
  34. package/dist/cjs/components/TUIKit/TUIKit.js +1 -1
  35. package/dist/cjs/components/TUIManage/TUIManage.js +1 -1
  36. package/dist/cjs/components/TUIMessage/MessageBubble.js +1 -1
  37. package/dist/cjs/components/TUIMessage/MessageContext.js +1 -1
  38. package/dist/cjs/components/TUIMessage/MessageCustom.js +1 -1
  39. package/dist/cjs/components/TUIMessage/MessageImage.js +1 -1
  40. package/dist/cjs/components/TUIMessage/MessageName.js +1 -1
  41. package/dist/cjs/components/TUIMessage/MessagePlugins.js +1 -1
  42. package/dist/cjs/components/TUIMessage/MessageRevoke.js +1 -1
  43. package/dist/cjs/components/TUIMessage/MessageSystem.js +1 -1
  44. package/dist/cjs/components/TUIMessage/MessageText.js +1 -1
  45. package/dist/cjs/components/TUIMessage/MessageTip.js +1 -1
  46. package/dist/cjs/components/TUIMessage/MessageVideo.js +1 -1
  47. package/dist/cjs/components/TUIMessage/TUIMessage.js +1 -1
  48. package/dist/cjs/components/TUIMessage/hooks/useMessageHandler.js +1 -1
  49. package/dist/cjs/components/TUIMessage/utils/index.js +1 -1
  50. package/dist/cjs/components/TUIMessageInput/TUIForward.js +1 -1
  51. package/dist/cjs/components/TUIMessageInput/TUIMessageInput.js +1 -1
  52. package/dist/cjs/components/TUIMessageInput/TUIMessageInputDefault.js +1 -1
  53. package/dist/cjs/components/TUIMessageInput/hooks/useEmojiPicker.js +1 -1
  54. package/dist/cjs/components/TUIMessageInput/hooks/useHandleForwardMessage.js +1 -1
  55. package/dist/cjs/components/TUIMessageInput/hooks/useMessageInputText.js +1 -1
  56. package/dist/cjs/components/TUIMessageInput/hooks/useUploadPicker.js +1 -1
  57. package/dist/cjs/components/TUIMessageList/TUIMessageList.js +1 -1
  58. package/dist/cjs/components/TUIProfile/TUIProfileDefault.js +1 -1
  59. package/dist/cjs/components/untils.js +1 -1
  60. package/dist/cjs/constants.js +1 -1
  61. package/dist/cjs/context/ComponentContext.d.ts +2 -0
  62. package/dist/cjs/context/TUIChatActionContext.d.ts +3 -14
  63. package/dist/cjs/context/TUIChatStateContext.d.ts +2 -0
  64. package/dist/cjs/context/TUIConversationContext.js +1 -1
  65. package/dist/cjs/index.css +1 -1
  66. package/dist/cjs/index.d.css +257 -12
  67. package/dist/cjs/index.js +1 -1
  68. package/dist/cjs/locales/en/TUIChat.js +1 -1
  69. package/dist/cjs/locales/en/TUIContact.js +1 -1
  70. package/dist/cjs/locales/en/TUIProfile.js +1 -1
  71. package/dist/cjs/locales/index.js +1 -1
  72. package/dist/cjs/locales/zh_cn/TUIChat.js +1 -1
  73. package/dist/cjs/locales/zh_cn/TUIContact.js +1 -1
  74. package/dist/cjs/locales/zh_cn/TUIProfile.js +1 -1
  75. package/dist/cjs/server.js +1 -0
  76. package/dist/cjs/utils/env.js +1 -0
  77. package/dist/esm/components/ConversationCreate/ConversationCreatGroupDetail.js +1 -1
  78. package/dist/esm/components/ConversationCreate/ConversationCreateUserSelectList.js +1 -1
  79. package/dist/esm/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
  80. package/dist/esm/components/ConversationPreview/ConversationPreview.d.ts +2 -0
  81. package/dist/esm/components/ConversationPreview/ConversationPreview.js +1 -1
  82. package/dist/esm/components/ConversationPreview/ConversationPreviewContent.js +1 -1
  83. package/dist/esm/components/ConversationPreview/utils.js +1 -1
  84. package/dist/esm/components/ConversationSearch/ConversationSearchResult.js +1 -1
  85. package/dist/esm/components/Icon/config.js +1 -1
  86. package/dist/esm/components/Icon/images/chats-selected.svg.js +1 -0
  87. package/dist/esm/components/Icon/images/chats.svg.js +1 -0
  88. package/dist/esm/components/Icon/images/contacts-selected.svg.js +1 -0
  89. package/dist/esm/components/Icon/images/contacts.svg.js +1 -0
  90. package/dist/esm/components/Icon/images/files.png.js +1 -0
  91. package/dist/esm/components/Icon/images/image.png.js +1 -1
  92. package/dist/esm/components/Icon/images/video.png.js +1 -1
  93. package/dist/esm/components/TUIChat/TUIChat.d.ts +5 -0
  94. package/dist/esm/components/TUIChat/TUIChat.js +1 -1
  95. package/dist/esm/components/TUIChat/TUIChatState.js +1 -1
  96. package/dist/esm/components/TUIChat/hooks/useHandleMessage.js +1 -1
  97. package/dist/esm/components/TUIChat/hooks/useHandleMessageList.js +1 -1
  98. package/dist/esm/components/TUIChat/unitls.js +1 -1
  99. package/dist/esm/components/TUIChatHeader/TUIChatHeaderDefault.js +1 -1
  100. package/dist/esm/components/TUIContact/TUIContact.js +1 -1
  101. package/dist/esm/components/TUIContact/TUIContactInfo/TUIContactInfo.js +1 -1
  102. package/dist/esm/components/TUIContact/TUIContactInfo/basicInfo.js +1 -1
  103. package/dist/esm/components/TUIContact/TUIContactInfo/friendInfo.js +1 -1
  104. package/dist/esm/components/TUIContact/TUIContactList/TUIContactList.js +1 -1
  105. package/dist/esm/components/TUIConversation/TUIConversation.js +1 -1
  106. package/dist/esm/components/TUIConversationList/TUIConversationList.d.ts +1 -0
  107. package/dist/esm/components/TUIConversationList/TUIConversationList.js +1 -1
  108. package/dist/esm/components/TUIKit/TUIKit.js +1 -1
  109. package/dist/esm/components/TUIManage/TUIManage.js +1 -1
  110. package/dist/esm/components/TUIMessage/MessageBubble.js +1 -1
  111. package/dist/esm/components/TUIMessage/MessageContext.js +1 -1
  112. package/dist/esm/components/TUIMessage/MessageCustom.js +1 -1
  113. package/dist/esm/components/TUIMessage/MessageImage.js +1 -1
  114. package/dist/esm/components/TUIMessage/MessageName.js +1 -1
  115. package/dist/esm/components/TUIMessage/MessagePlugins.js +1 -1
  116. package/dist/esm/components/TUIMessage/MessageRevoke.js +1 -1
  117. package/dist/esm/components/TUIMessage/MessageSystem.js +1 -1
  118. package/dist/esm/components/TUIMessage/MessageText.js +1 -1
  119. package/dist/esm/components/TUIMessage/MessageTip.js +1 -1
  120. package/dist/esm/components/TUIMessage/MessageVideo.js +1 -1
  121. package/dist/esm/components/TUIMessage/TUIMessage.js +1 -1
  122. package/dist/esm/components/TUIMessage/hooks/useMessageHandler.js +1 -1
  123. package/dist/esm/components/TUIMessage/utils/index.js +1 -1
  124. package/dist/esm/components/TUIMessageInput/TUIForward.js +1 -1
  125. package/dist/esm/components/TUIMessageInput/TUIMessageInput.js +1 -1
  126. package/dist/esm/components/TUIMessageInput/TUIMessageInputDefault.js +1 -1
  127. package/dist/esm/components/TUIMessageInput/hooks/useEmojiPicker.js +1 -1
  128. package/dist/esm/components/TUIMessageInput/hooks/useHandleForwardMessage.js +1 -1
  129. package/dist/esm/components/TUIMessageInput/hooks/useMessageInputText.js +1 -1
  130. package/dist/esm/components/TUIMessageInput/hooks/useUploadPicker.js +1 -1
  131. package/dist/esm/components/TUIMessageList/TUIMessageList.js +1 -1
  132. package/dist/esm/components/TUIProfile/TUIProfileDefault.js +1 -1
  133. package/dist/esm/components/untils.js +1 -1
  134. package/dist/esm/constants.js +1 -1
  135. package/dist/esm/context/ComponentContext.d.ts +2 -0
  136. package/dist/esm/context/TUIChatActionContext.d.ts +3 -14
  137. package/dist/esm/context/TUIChatStateContext.d.ts +2 -0
  138. package/dist/esm/context/TUIConversationContext.js +1 -1
  139. package/dist/esm/index.css +1 -1
  140. package/dist/esm/index.d.css +257 -12
  141. package/dist/esm/index.js +1 -1
  142. package/dist/esm/locales/en/TUIChat.js +1 -1
  143. package/dist/esm/locales/en/TUIContact.js +1 -1
  144. package/dist/esm/locales/en/TUIProfile.js +1 -1
  145. package/dist/esm/locales/index.js +1 -1
  146. package/dist/esm/locales/zh_cn/TUIChat.js +1 -1
  147. package/dist/esm/locales/zh_cn/TUIContact.js +1 -1
  148. package/dist/esm/locales/zh_cn/TUIProfile.js +1 -1
  149. package/dist/esm/server.js +1 -0
  150. package/dist/esm/utils/env.js +1 -0
  151. package/package.json +8 -7
  152. package/rollup.config.js +0 -1
  153. package/scripts/publish-github.js +60 -0
  154. package/scripts/publish-intl-demo.js +14 -0
  155. package/scripts/publish-npm.js +22 -0
  156. package/src/components/Avatar/styles/index.scss +1 -0
  157. package/src/components/ConversationCreate/ConversationCreatGroupDetail.tsx +6 -3
  158. package/src/components/ConversationCreate/ConversationCreateUserSelectList.tsx +5 -1
  159. package/src/components/ConversationCreate/hooks/useConversationCreate.tsx +7 -2
  160. package/src/components/ConversationCreate/styles/conversationGroupTypeInfo.scss +1 -0
  161. package/src/components/ConversationCreate/styles/index.scss +2 -0
  162. package/src/components/ConversationPreview/ConversationPreview.tsx +2 -0
  163. package/src/components/ConversationPreview/ConversationPreviewContent.tsx +57 -9
  164. package/src/components/ConversationPreview/styles/index.scss +4 -2
  165. package/src/components/ConversationPreview/utils.tsx +5 -1
  166. package/src/components/DivWithEdit/styles/index.scss +2 -1
  167. package/src/components/Icon/config.ts +4 -5
  168. package/src/components/Icon/images/chats-selected.svg +6 -0
  169. package/src/components/Icon/images/chats.svg +9 -0
  170. package/src/components/Icon/images/contacts-selected.svg +3 -0
  171. package/src/components/Icon/images/contacts.svg +6 -0
  172. package/src/components/Icon/images/files.png +0 -0
  173. package/src/components/Icon/images/image.png +0 -0
  174. package/src/components/Icon/images/language.svg +3 -0
  175. package/src/components/Icon/images/video.png +0 -0
  176. package/src/components/Model/styles/layout.scss +1 -1
  177. package/src/components/Profile/styles/index.scss +4 -0
  178. package/src/components/TUIChat/TUIChat.tsx +74 -120
  179. package/src/components/TUIChat/TUIChatState.tsx +18 -45
  180. package/src/components/TUIChat/hooks/useHandleMessage.tsx +8 -0
  181. package/src/components/TUIChat/hooks/useHandleMessageList.tsx +2 -41
  182. package/src/components/TUIChat/unitls.ts +0 -29
  183. package/src/components/TUIChatHeader/TUIChatHeaderDefault.tsx +9 -2
  184. package/src/components/TUIContact/TUIContact.tsx +2 -1
  185. package/src/components/TUIContact/TUIContactInfo/TUIContactInfo.tsx +2 -1
  186. package/src/components/TUIContact/TUIContactInfo/basicInfo.tsx +18 -0
  187. package/src/components/TUIContact/TUIContactInfo/friendInfo.tsx +4 -1
  188. package/src/components/TUIContact/TUIContactInfo/index.scss +5 -0
  189. package/src/components/TUIContact/TUIContactList/TUIContactList.tsx +3 -2
  190. package/src/components/TUIContact/TUIContactList/index.scss +5 -0
  191. package/src/components/TUIContact/index.scss +5 -0
  192. package/src/components/TUIConversation/TUIConversation.tsx +1 -4
  193. package/src/components/TUIConversationList/TUIConversationList.tsx +91 -65
  194. package/src/components/TUIConversationList/index.scss +5 -0
  195. package/src/components/TUIKit/TUIKit.tsx +152 -10
  196. package/src/components/TUIKit/styles/h5.scss +34 -0
  197. package/src/components/TUIKit/styles/index.scss +103 -0
  198. package/src/components/TUIKit/styles/reset.scss +20 -0
  199. package/src/components/TUIManage/TUIManage.tsx +59 -35
  200. package/src/components/TUIManage/styles/index.scss +15 -1
  201. package/src/components/TUIMessage/MessageBubble.tsx +20 -3
  202. package/src/components/TUIMessage/MessageCustom.tsx +11 -2
  203. package/src/components/TUIMessage/MessageImage.tsx +2 -1
  204. package/src/components/TUIMessage/MessageName.tsx +1 -1
  205. package/src/components/TUIMessage/MessagePlugins.tsx +4 -2
  206. package/src/components/TUIMessage/MessageRevoke.tsx +2 -2
  207. package/src/components/TUIMessage/MessageText.tsx +25 -3
  208. package/src/components/TUIMessage/MessageVideo.tsx +8 -5
  209. package/src/components/TUIMessage/hooks/useMessageHandler.ts +13 -33
  210. package/src/components/TUIMessage/styles/color.scss +1 -0
  211. package/src/components/TUIMessage/styles/layout.scss +33 -6
  212. package/src/components/TUIMessage/utils/index.ts +1 -1
  213. package/src/components/TUIMessageInput/TUIMessageInputDefault.tsx +2 -2
  214. package/src/components/TUIMessageInput/hooks/useEmojiPicker.tsx +2 -6
  215. package/src/components/TUIMessageInput/hooks/useHandleForwardMessage.tsx +4 -3
  216. package/src/components/TUIMessageInput/hooks/useMessageInputText.tsx +10 -3
  217. package/src/components/TUIMessageInput/hooks/useUploadPicker.tsx +10 -14
  218. package/src/components/TUIMessageInput/styles/color.scss +1 -1
  219. package/src/components/TUIMessageInput/styles/layout.scss +7 -2
  220. package/src/components/TUIMessageList/TUIMessageList.tsx +9 -13
  221. package/src/components/TUIMessageList/index.ts +0 -1
  222. package/src/components/TUIProfile/TUIProfileDefault.tsx +65 -51
  223. package/src/components/TUIProfile/styles/layout.scss +6 -0
  224. package/src/components/untils.ts +9 -0
  225. package/src/constants.ts +9 -1
  226. package/src/context/ComponentContext.tsx +2 -0
  227. package/src/context/TUIChatActionContext.tsx +3 -23
  228. package/src/context/TUIChatStateContext.tsx +2 -0
  229. package/src/context/TUIKitContext.tsx +0 -1
  230. package/src/index.ts +3 -0
  231. package/src/locales/en/TUIChat.ts +2 -1
  232. package/src/locales/en/TUIContact.ts +1 -1
  233. package/src/locales/en/TUIProfile.ts +5 -4
  234. package/src/locales/index.ts +1 -1
  235. package/src/locales/zh_cn/TUIChat.ts +1 -0
  236. package/src/locales/zh_cn/TUIContact.ts +1 -1
  237. package/src/locales/zh_cn/TUIProfile.ts +1 -0
  238. package/src/server.ts +44 -0
  239. package/src/utils/env.ts +5 -0
  240. package/tsconfig.json +1 -0
  241. package/dist/cjs/components/Icon/images/create.png.js +0 -1
  242. package/dist/cjs/components/Icon/images/document.png.js +0 -1
  243. package/dist/cjs/components/TUIChat/hooks/useCreateMessage.d.ts +0 -59
  244. package/dist/cjs/components/TUIChat/hooks/useCreateMessage.js +0 -1
  245. package/dist/cjs/components/TUIChat/hooks/useMessageReceviedListener.js +0 -1
  246. package/dist/cjs/components/TUIMessageList/hooks/useEnrichedMessageList.js +0 -1
  247. package/dist/esm/components/Icon/images/create.png.js +0 -1
  248. package/dist/esm/components/Icon/images/document.png.js +0 -1
  249. package/dist/esm/components/TUIChat/hooks/useCreateMessage.d.ts +0 -59
  250. package/dist/esm/components/TUIChat/hooks/useCreateMessage.js +0 -1
  251. package/dist/esm/components/TUIChat/hooks/useMessageReceviedListener.js +0 -1
  252. package/dist/esm/components/TUIMessageList/hooks/useEnrichedMessageList.js +0 -1
  253. package/src/components/TUIChat/hooks/useCreateMessage.tsx +0 -198
  254. package/src/components/TUIChat/hooks/useMessageReceviedListener.tsx +0 -26
  255. package/src/components/TUIMessageList/hooks/useEnrichedMessageList.tsx +0 -16
@@ -1,6 +1,11 @@
1
1
  import React from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import { Profile } from '@tencentcloud/chat';
4
+ import { TUIConversationService } from '@tencentcloud/chat-uikit-engine';
5
+ import { useTUIKitContext } from '../../../context';
6
+ import { Icon, IconTypes } from '../../Icon';
7
+ import { isH5 } from '../../../utils/env';
8
+
4
9
  import { Avatar, defaultUserAvatar } from '../../Avatar';
5
10
 
6
11
  interface Props {
@@ -14,8 +19,21 @@ export function UnMemoizedBasicInfo<T extends Props>(
14
19
  const {
15
20
  userID, nick, selfSignature, avatar,
16
21
  } = profile;
22
+ const { setActiveContact } = useTUIKitContext('TUIContact');
23
+ const back = () => {
24
+ TUIConversationService.switchConversation('');
25
+ setActiveContact();
26
+ };
17
27
  return (
18
28
  <div className="tui-contact-info-header">
29
+ {isH5 && (
30
+ <Icon
31
+ width={9}
32
+ height={16}
33
+ type={IconTypes.BACK}
34
+ onClick={back}
35
+ />
36
+ )}
19
37
  <div className="header-container">
20
38
  <div className="header-container-avatar">
21
39
  <Avatar size={60} image={avatar || defaultUserAvatar} />
@@ -1,6 +1,7 @@
1
1
  import React, { useState, useEffect } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import { Friend } from '@tencentcloud/chat';
4
+ import { TUIConversationService } from '@tencentcloud/chat-uikit-engine';
4
5
  import { useTUIKitContext } from '../../../context';
5
6
  import { BasicInfo } from './basicInfo';
6
7
  import { Switch } from '../../Switch';
@@ -60,7 +61,9 @@ export function UnMemoizedFriendInfo<T extends Props>(
60
61
  setActiveContact();
61
62
  };
62
63
  const openC2CConversation = async () => {
63
- const conversation = await createConversation(`C2C${userID}`);
64
+ const conversationID = `C2C${userID}`;
65
+ const conversation = await createConversation(conversationID);
66
+ TUIConversationService.switchConversation(conversationID);
64
67
  setActiveConversation(conversation);
65
68
  openChat();
66
69
  };
@@ -28,6 +28,7 @@
28
28
  line-height: 50px;
29
29
  font-weight: 400;
30
30
  color: #999999;
31
+ word-break: break-all;
31
32
  }
32
33
  }
33
34
  }
@@ -106,3 +107,7 @@
106
107
  }
107
108
  }
108
109
  }
110
+ .tui-contact-info-h5 {
111
+ padding: 8px;
112
+
113
+ }
@@ -1,6 +1,7 @@
1
1
  import React, { useState } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import TencentCloudChat from '@tencentcloud/chat';
4
+ import { isH5 } from '../../../utils/env';
4
5
  import { useTUIKitContext, useTUIContactContext } from '../../../context';
5
6
  import useContactInfo from '../TUIContactInfo/hooks/useContactInfo';
6
7
 
@@ -31,7 +32,7 @@ function UnMemoizedTUIContactList<T>(): React.ReactElement {
31
32
  };
32
33
  return (
33
34
  isShowContactList && (
34
- <div className="tui-contacts-list">
35
+ <div className={`tui-contacts-list ${isH5 ? 'tui-contacts-list-h5' : ''} `}>
35
36
  <div
36
37
  className="tui-contacts-title"
37
38
  role="button"
@@ -130,7 +131,7 @@ function UnMemoizedTUIContactList<T>(): React.ReactElement {
130
131
  tabIndex={0}
131
132
  onClick={() => setShowFriends(!iShowFriends)}
132
133
  >
133
- <div className="tui-contacts-list-title">{t('TUIContact.Friend')}</div>
134
+ <div className="tui-contacts-list-title">{t('TUIContact.Friends')}</div>
134
135
  <div className="tui-contacts-list-icon">
135
136
  <img src={iShowFriends ? downArrow : rightArrow} alt="" />
136
137
  </div>
@@ -88,3 +88,8 @@
88
88
  ::-webkit-scrollbar {
89
89
  display: none;
90
90
  }
91
+ .tui-contacts-list-h5 {
92
+ min-width: 100%;
93
+ width: 100%;
94
+ max-width: 100%;
95
+ }
@@ -65,3 +65,8 @@
65
65
  }
66
66
  }
67
67
  }
68
+ .tui-contacts-h5 {
69
+ min-width: 100%;
70
+ width: 100%;
71
+ max-width: 100%;
72
+ }
@@ -35,10 +35,7 @@ export function UnMemoizedTUIConversation<T extends TUIConversationProps>(
35
35
  return (
36
36
  <TUIConversationProvider value={TUIConversationValue}>
37
37
  {children || (
38
- <>
39
- <TUIConversationList />
40
- <TUIProfile />
41
- </>
38
+ <TUIConversationList />
42
39
  )}
43
40
  </TUIConversationProvider>
44
41
  );
@@ -2,6 +2,7 @@ import React, { useRef, useState } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import { Conversation } from '@tencentcloud/chat';
4
4
  import { useTUIKitContext } from '../../context';
5
+ import { isH5 } from '../../utils/env';
5
6
  import useConversationList from './hooks/useConversationList';
6
7
  import './index.scss';
7
8
  import { ConversationPreview, ConversationPreviewUIComponentProps } from '../ConversationPreview';
@@ -17,6 +18,7 @@ import { useConversationUpdate } from './hooks/useConversationUpdate';
17
18
  import { useTUIConversationContext } from '../../context/TUIConversationContext';
18
19
 
19
20
  interface Props {
21
+ componentVisibleOptions?: any,
20
22
  filters?: object,
21
23
  sort?: object,
22
24
  options?: object,
@@ -34,31 +36,41 @@ export function UnMemoTUIConversationList<T extends Props>(props: T):React.React
34
36
  Container = ConversationListContainer,
35
37
  onConversationListUpdated,
36
38
  filterConversation: propsFilterConversation,
39
+ componentVisibleOptions = {
40
+ isProfileShow: true,
41
+ isSearchInputShow: true,
42
+ isContainerShow: true,
43
+ },
37
44
  } = props;
38
45
  const { t } = useTranslation();
39
46
  const {
40
- chat, customClasses, conversation, setActiveConversation, setTUIProfileShow,
47
+ chat,
48
+ customClasses,
49
+ conversation,
50
+ setActiveConversation,
51
+ setTUIProfileShow,
41
52
  } = useTUIKitContext('TUIConversationList');
42
- const {
43
- filterConversation: contextFilterConversation,
44
- } = useTUIConversationContext('TUIConversationList');
53
+ const { filterConversation: contextFilterConversation } = useTUIConversationContext('TUIConversationList');
45
54
  const filterConversation = propsFilterConversation || contextFilterConversation;
46
55
  const [conversationUpdateCount, setConversationUpdateCount] = useState(0);
47
56
  const forceUpdate = () => setConversationUpdateCount((count) => count + 1);
48
57
 
49
58
  const activeConversationHandler = (
50
59
  conversationList: Array<Conversation>,
51
- setConversationList: React.Dispatch<React.SetStateAction<Array<Conversation>>>,
60
+ setConversationList: React.Dispatch<
61
+ React.SetStateAction<Array<Conversation>>
62
+ >,
52
63
  ) => {
53
64
  if (!conversationList.length) {
54
65
  return;
55
66
  }
56
67
  setActiveConversation(conversation);
57
68
  };
58
- const {
59
- conversationList,
60
- setConversationList,
61
- } = useConversationList(chat, activeConversationHandler, filterConversation);
69
+ const { conversationList, setConversationList } = useConversationList(
70
+ chat,
71
+ activeConversationHandler,
72
+ filterConversation,
73
+ );
62
74
  useConversationUpdate(
63
75
  setConversationList,
64
76
  onConversationListUpdated,
@@ -68,13 +80,16 @@ export function UnMemoTUIConversationList<T extends Props>(props: T):React.React
68
80
  const [searchValue, setSearchValue] = useState('');
69
81
  const [searchResult, setSearchResult] = useState(conversationList);
70
82
  const [conversationCreated, setConversationCreated] = useState(false);
83
+ const [activeConversationID, setActiveConversationID] = useState('');
71
84
 
72
85
  const handleSearchValueChange = (e) => {
73
86
  setSearchValue(e.target?.value);
74
87
  if (e.target?.value) {
75
88
  const result = conversationList.filter(
76
89
  // eslint-disable-next-line max-len
77
- (item) => (getDisplayTitle(item) as string).toLocaleLowerCase().includes(e.target?.value.toLocaleLowerCase()),
90
+ (item) => (getDisplayTitle(item) as string)
91
+ .toLocaleLowerCase()
92
+ .includes(e.target?.value.toLocaleLowerCase()),
78
93
  );
79
94
  setSearchResult(result);
80
95
  } else {
@@ -88,65 +103,76 @@ export function UnMemoTUIConversationList<T extends Props>(props: T):React.React
88
103
  };
89
104
  const conversationListRef = useRef(null);
90
105
  return (
91
- <div className={`tui-conversation ${customClasses || ''}`} ref={conversationListRef}>
92
- {
93
- conversationCreated
94
- ? (
95
- <ConversationCreate
96
- conversationList={conversationList}
97
- setConversationCreated={setConversationCreated}
98
- />
99
- )
100
- : (
101
- <>
102
- <div className="tui-conversation-header">
103
- <ConversationSearchInput
104
- value={searchValue}
105
- clearable
106
- onChange={handleSearchValueChange}
106
+ <div
107
+ className={`tui-conversation ${isH5 ? 'tui-conversation-h5' : ''} ${customClasses || ''} `}
108
+ ref={conversationListRef}
109
+ >
110
+ {conversationCreated ? (
111
+ <ConversationCreate
112
+ conversationList={conversationList}
113
+ setConversationCreated={setConversationCreated}
114
+ />
115
+ ) : (
116
+ <>
117
+ {componentVisibleOptions.isSearchInputShow && (
118
+ <div className="tui-conversation-header">
119
+ <ConversationSearchInput
120
+ value={searchValue}
121
+ clearable
122
+ onChange={handleSearchValueChange}
123
+ />
124
+ <div className="tui-conversation-create-icon">
125
+ <Icon
126
+ onClick={handleConversationCreate}
127
+ type={IconTypes.CREATE}
128
+ height={24}
129
+ width={24}
107
130
  />
108
- <div className="tui-conversation-create-icon">
131
+ </div>
132
+ </div>
133
+ )}
134
+ {componentVisibleOptions.isContainerShow && (
135
+ <Container setConversationList={setConversationList}>
136
+ {/* eslint-disable-next-line no-nested-ternary */}
137
+ {conversationList.length === 0 ? (
138
+ <div className="no-result">
109
139
  <Icon
110
- onClick={handleConversationCreate}
111
- type={IconTypes.CREATE}
112
- height={24}
113
- width={24}
140
+ className="no-result-icon"
141
+ type={IconTypes.EFFORT}
142
+ width={42}
143
+ height={42}
114
144
  />
145
+ <div className="no-result-message">No conversation</div>
115
146
  </div>
116
- </div>
117
- <Container setConversationList={setConversationList}>
118
- {/* eslint-disable-next-line no-nested-ternary */}
119
- {conversationList.length === 0
120
- ? (
121
- <div className="no-result">
122
- <Icon className="no-result-icon" type={IconTypes.EFFORT} width={42} height={42} />
123
- <div className="no-result-message">{t('TUIConversation.No conversation')}</div>
124
- </div>
125
- )
126
- : searchValue
127
- ? (
128
- <ConversationSearchResult
129
- Preview={Preview}
130
- searchValue={searchValue}
131
- result={searchResult}
132
- />
133
- )
134
- : conversationList.map((item) => {
135
- const previewProps = {
136
- activeConversation: conversation,
137
- conversation: item,
138
- setActiveConversation,
139
- Preview,
140
- conversationUpdateCount,
141
- };
142
- return (
143
- <ConversationPreview key={item.conversationID} {...previewProps} />
144
- );
145
- })}
146
- </Container>
147
- </>
148
- )
149
- }
147
+ ) : searchValue ? (
148
+ <ConversationSearchResult
149
+ Preview={Preview}
150
+ searchValue={searchValue}
151
+ result={searchResult}
152
+ />
153
+ ) : (
154
+ conversationList.map((item) => {
155
+ const previewProps = {
156
+ activeConversation: conversation,
157
+ conversation: item,
158
+ setActiveConversation,
159
+ Preview,
160
+ conversationUpdateCount,
161
+ activeConversationID,
162
+ setActiveConversationID,
163
+ };
164
+ return (
165
+ <ConversationPreview
166
+ key={item.conversationID}
167
+ {...previewProps}
168
+ />
169
+ );
170
+ })
171
+ )}
172
+ </Container>
173
+ )}
174
+ </>
175
+ )}
150
176
  </div>
151
177
  );
152
178
  }
@@ -35,3 +35,8 @@
35
35
  }
36
36
  }
37
37
  }
38
+ .tui-conversation-h5 {
39
+ min-width: 100%;
40
+ width: 100%;
41
+ max-width: 100%;
42
+ }
@@ -1,13 +1,25 @@
1
- import React, { PropsWithChildren } from 'react';
1
+ import React, { PropsWithChildren, useState, useEffect } from 'react';
2
2
  import { ChatSDK, Conversation } from '@tencentcloud/chat';
3
- import { useTUIKit } from './hooks/useTUIKit';
3
+ import { TUIStore, StoreName } from '@tencentcloud/chat-uikit-engine';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { isH5, isPC } from '../../utils/env';
6
+ import { useTUIKit, UseContactParams } from './hooks/useTUIKit';
4
7
  import { useCreateTUIKitContext } from './hooks/useCreateTUIKitContext';
5
8
  import { TUIKitProvider } from '../../context/TUIKitContext';
6
9
  import './styles/index.scss';
10
+ import './styles/h5.scss';
7
11
  import { TUIConversation } from '../TUIConversation';
8
12
  import { TUIChat } from '../TUIChat';
9
13
  import { TUIManage } from '../TUIManage';
14
+ import { TUIProfile } from '../TUIProfile';
15
+ import { TUIContact } from '../TUIContact';
16
+ import { TUIContactInfo } from '../TUIContact/TUIContactInfo/TUIContactInfo';
17
+ import { TUIKIT_TABBAR } from '../../constants';
10
18
  import '../../locales/index';
19
+ import chats from '../Icon/images/chats.svg';
20
+ import chatsSelected from '../Icon/images/chats-selected.svg';
21
+ import contacts from '../Icon/images/contacts.svg';
22
+ import contactsSelected from '../Icon/images/contacts-selected.svg';
11
23
 
12
24
  export interface ChatProps {
13
25
  chat?: ChatSDK | null,
@@ -15,13 +27,111 @@ export interface ChatProps {
15
27
  customClasses?: unknown,
16
28
  activeConversation?: Conversation,
17
29
  }
30
+
31
+ interface RenderPCProps {
32
+ moduleValue: string,
33
+ tabbarRender: any,
34
+ setModuleValue: (value: string) => void
35
+ }
36
+ interface RenderH5Props {
37
+ moduleValue: string,
38
+ currentConversationID: string,
39
+ tabbarRender: any,
40
+ contactData: UseContactParams,
41
+ setModuleValue: (value: string) => void
42
+ }
43
+
44
+ const tabbarList = [
45
+ {
46
+ id: 1,
47
+ name: TUIKIT_TABBAR.CHATS,
48
+ icon: chats,
49
+ selectedIcon: chatsSelected,
50
+ value: TUIKIT_TABBAR.CHATS,
51
+ },
52
+ {
53
+ id: 2,
54
+ name: TUIKIT_TABBAR.CONTACTS,
55
+ icon: contacts,
56
+ selectedIcon: contactsSelected,
57
+ value: TUIKIT_TABBAR.CONTACTS,
58
+ },
59
+ ];
60
+ const TUIMessageInputConfig = {
61
+ className: 'sample-h5-input',
62
+ isTransmitter: true,
63
+ };
64
+
65
+ function RenderForPC({ moduleValue, tabbarRender, setModuleValue } : RenderPCProps) {
66
+ return (
67
+ <>
68
+ <div className="sample-chat-left-container">
69
+ <TUIProfile className="sample-chat-profile" />
70
+ {tabbarRender}
71
+ {moduleValue === TUIKIT_TABBAR.CHATS && <TUIConversation />}
72
+ {moduleValue === TUIKIT_TABBAR.CONTACTS && <TUIContact />}
73
+ </div>
74
+ {moduleValue === TUIKIT_TABBAR.CHATS && (
75
+ <>
76
+ <TUIChat />
77
+ <TUIManage />
78
+ </>
79
+ )}
80
+ {moduleValue === TUIKIT_TABBAR.CONTACTS && (
81
+ <TUIContact>
82
+ <TUIContactInfo
83
+ showChat={() => {
84
+ setModuleValue(TUIKIT_TABBAR.CHATS);
85
+ }}
86
+ />
87
+ </TUIContact>
88
+ )}
89
+ </>
90
+ );
91
+ }
92
+
93
+ function RenderForH5({
94
+ moduleValue, contactData, tabbarRender, currentConversationID, setModuleValue,
95
+ }: RenderH5Props) {
96
+ return (
97
+ <>
98
+ {!currentConversationID && !contactData && (
99
+ <div className="sample-chat-h5-container">
100
+ <TUIProfile className="sample-profile" />
101
+ {tabbarRender}
102
+ {moduleValue === TUIKIT_TABBAR.CHATS && <TUIConversation />}
103
+ {moduleValue === TUIKIT_TABBAR.CONTACTS && <TUIContact />}
104
+ </div>
105
+ )}
106
+ {moduleValue === TUIKIT_TABBAR.CHATS && currentConversationID && (
107
+ <>
108
+ <TUIChat TUIMessageInputConfig={TUIMessageInputConfig} />
109
+ <TUIManage />
110
+ </>
111
+ )}
112
+ { moduleValue === TUIKIT_TABBAR.CONTACTS && contactData && (
113
+ <TUIContact>
114
+ <TUIContactInfo
115
+ showChat={() => {
116
+ setModuleValue(TUIKIT_TABBAR.CHATS);
117
+ }}
118
+ />
119
+ </TUIContact>
120
+ )}
121
+ </>
122
+ );
123
+ }
18
124
  export function TUIKit<
19
125
  T extends ChatProps
20
126
  >(
21
127
  props:PropsWithChildren<T>,
22
128
  ):React.ReactElement {
129
+ const [currentConversationID, setCurrentConversationID] = useState<string>('');
130
+ const [moduleValue, setModuleValue] = useState('chats');
131
+ const { t } = useTranslation();
132
+
23
133
  const {
24
- children, chat, customClasses, activeConversation, language,
134
+ children, chat, customClasses, activeConversation, language = 'en',
25
135
  } = props;
26
136
  (window as any).tencent_cloud_im_csig_react_uikit_23F_xa = true;
27
137
  const {
@@ -49,17 +159,49 @@ export function TUIKit<
49
159
  setTUIProfileShow,
50
160
  setActiveContact,
51
161
  });
162
+ useEffect(() => {
163
+ TUIStore.watch(StoreName.CONV, {
164
+ currentConversationID: onCurrentConversationID,
165
+ });
166
+ return () => {
167
+ TUIStore.unwatch(StoreName.CONV, {
168
+ currentConversationID: onCurrentConversationID,
169
+ });
170
+ };
171
+ }, []);
172
+
173
+ const onCurrentConversationID = (id: string) => {
174
+ setCurrentConversationID(id);
175
+ };
176
+ const switchTabbar = (value: string) => {
177
+ setModuleValue(value);
178
+ };
179
+
180
+ const tabbarRender = (
181
+ <div className="sample-chat-tab">
182
+ {tabbarList.map((item: any) => (
183
+ <div
184
+ className="sample-chat-tab-container"
185
+ key={item.id}
186
+ role="presentation"
187
+ onClick={() => {
188
+ switchTabbar(item.value);
189
+ }}
190
+ >
191
+ <img src={moduleValue === item.value ? item.selectedIcon : item.icon} alt="" />
192
+ <p className={`sample-chat-tab-text ${moduleValue === item.value ? 'sample-chat-tab-active' : ''}`}>
193
+ {t(item.name)}
194
+ </p>
195
+ </div>
196
+ ))}
197
+ </div>
198
+ );
52
199
 
53
200
  return (
54
201
  <TUIKitProvider value={chatContextValue}>
55
202
  <div className="tui-kit">
56
- {children || (
57
- <>
58
- <TUIConversation />
59
- <TUIChat />
60
- <TUIManage />
61
- </>
62
- )}
203
+ {children || (isPC && <RenderForPC moduleValue={moduleValue} tabbarRender={tabbarRender} setModuleValue={setModuleValue} />)
204
+ || (isH5 && <RenderForH5 contactData={contactData} moduleValue={moduleValue} tabbarRender={tabbarRender} currentConversationID={currentConversationID} setModuleValue={setModuleValue} />)}
63
205
  </div>
64
206
  </TUIKitProvider>
65
207
  );
@@ -0,0 +1,34 @@
1
+ .App {
2
+ height: 100%;
3
+ }
4
+ #root {
5
+ width: 100%;
6
+ height: 100%;
7
+ margin: 0;
8
+ }
9
+ .sample-chat-h5 {
10
+ position:relative;
11
+ width: 100%;
12
+ height: 100%;
13
+ overflow: hidden;
14
+ &-container {
15
+ display: flex;
16
+ flex-direction: column;
17
+ width: 100%;
18
+ height: 100%;
19
+ .sample-profile {
20
+ position: absolute;
21
+ top: 0;
22
+ z-index: 1;
23
+ width:100%;
24
+ max-width: 100%;
25
+ min-width: 100%;
26
+ }
27
+ .tui-kit-input-box.tui-kit-input-box--focus {
28
+ outline: none;
29
+ }
30
+ }
31
+ .tui-message-input .tui-kit-input-box--focus {
32
+ outline: none;
33
+ }
34
+ }