@tencentcloud/chat-uikit-react 1.2.2 → 2.1.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 (241) hide show
  1. package/.eslintrc.js +2 -1
  2. package/CHANGELOG.md +8 -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/TUIContactInfo/friendInfo.js +1 -1
  27. package/dist/cjs/components/TUIContact/TUIContactList/TUIContactList.js +1 -1
  28. package/dist/cjs/components/TUIConversation/TUIConversation.js +1 -1
  29. package/dist/cjs/components/TUIConversationList/TUIConversationList.d.ts +1 -0
  30. package/dist/cjs/components/TUIConversationList/TUIConversationList.js +1 -1
  31. package/dist/cjs/components/TUIKit/TUIKit.js +1 -1
  32. package/dist/cjs/components/TUIManage/TUIManage.js +1 -1
  33. package/dist/cjs/components/TUIMessage/MessageBubble.js +1 -1
  34. package/dist/cjs/components/TUIMessage/MessageContext.js +1 -1
  35. package/dist/cjs/components/TUIMessage/MessageCustom.js +1 -1
  36. package/dist/cjs/components/TUIMessage/MessageImage.js +1 -1
  37. package/dist/cjs/components/TUIMessage/MessageName.js +1 -1
  38. package/dist/cjs/components/TUIMessage/MessagePlugins.js +1 -1
  39. package/dist/cjs/components/TUIMessage/MessageRevoke.js +1 -1
  40. package/dist/cjs/components/TUIMessage/MessageSystem.js +1 -1
  41. package/dist/cjs/components/TUIMessage/MessageText.js +1 -1
  42. package/dist/cjs/components/TUIMessage/MessageTip.js +1 -1
  43. package/dist/cjs/components/TUIMessage/MessageVideo.js +1 -1
  44. package/dist/cjs/components/TUIMessage/TUIMessage.js +1 -1
  45. package/dist/cjs/components/TUIMessage/hooks/useMessageHandler.js +1 -1
  46. package/dist/cjs/components/TUIMessage/utils/index.js +1 -1
  47. package/dist/cjs/components/TUIMessageInput/TUIForward.js +1 -1
  48. package/dist/cjs/components/TUIMessageInput/TUIMessageInput.js +1 -1
  49. package/dist/cjs/components/TUIMessageInput/TUIMessageInputDefault.js +1 -1
  50. package/dist/cjs/components/TUIMessageInput/hooks/useEmojiPicker.js +1 -1
  51. package/dist/cjs/components/TUIMessageInput/hooks/useHandleForwardMessage.js +1 -1
  52. package/dist/cjs/components/TUIMessageInput/hooks/useMessageInputText.js +1 -1
  53. package/dist/cjs/components/TUIMessageInput/hooks/useUploadPicker.js +1 -1
  54. package/dist/cjs/components/TUIMessageList/TUIMessageList.js +1 -1
  55. package/dist/cjs/components/TUIProfile/TUIProfileDefault.js +1 -1
  56. package/dist/cjs/components/untils.js +1 -1
  57. package/dist/cjs/constants.js +1 -1
  58. package/dist/cjs/context/ComponentContext.d.ts +2 -0
  59. package/dist/cjs/context/TUIChatActionContext.d.ts +3 -14
  60. package/dist/cjs/context/TUIChatStateContext.d.ts +2 -0
  61. package/dist/cjs/context/TUIConversationContext.js +1 -1
  62. package/dist/cjs/index.css +1 -1
  63. package/dist/cjs/index.d.css +240 -12
  64. package/dist/cjs/index.js +1 -1
  65. package/dist/cjs/locales/en/TUIChat.js +1 -1
  66. package/dist/cjs/locales/en/TUIContact.js +1 -1
  67. package/dist/cjs/locales/en/TUIProfile.js +1 -1
  68. package/dist/cjs/locales/index.js +1 -1
  69. package/dist/cjs/locales/zh_cn/TUIChat.js +1 -1
  70. package/dist/cjs/locales/zh_cn/TUIContact.js +1 -1
  71. package/dist/cjs/locales/zh_cn/TUIProfile.js +1 -1
  72. package/dist/cjs/server.js +1 -0
  73. package/dist/cjs/utils/env.js +1 -0
  74. package/dist/esm/components/ConversationCreate/ConversationCreatGroupDetail.js +1 -1
  75. package/dist/esm/components/ConversationCreate/ConversationCreateUserSelectList.js +1 -1
  76. package/dist/esm/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
  77. package/dist/esm/components/ConversationPreview/ConversationPreview.d.ts +2 -0
  78. package/dist/esm/components/ConversationPreview/ConversationPreview.js +1 -1
  79. package/dist/esm/components/ConversationPreview/ConversationPreviewContent.js +1 -1
  80. package/dist/esm/components/ConversationPreview/utils.js +1 -1
  81. package/dist/esm/components/ConversationSearch/ConversationSearchResult.js +1 -1
  82. package/dist/esm/components/Icon/config.js +1 -1
  83. package/dist/esm/components/Icon/images/chats-selected.svg.js +1 -0
  84. package/dist/esm/components/Icon/images/chats.svg.js +1 -0
  85. package/dist/esm/components/Icon/images/contacts-selected.svg.js +1 -0
  86. package/dist/esm/components/Icon/images/contacts.svg.js +1 -0
  87. package/dist/esm/components/Icon/images/files.png.js +1 -0
  88. package/dist/esm/components/Icon/images/image.png.js +1 -1
  89. package/dist/esm/components/Icon/images/video.png.js +1 -1
  90. package/dist/esm/components/TUIChat/TUIChat.d.ts +5 -0
  91. package/dist/esm/components/TUIChat/TUIChat.js +1 -1
  92. package/dist/esm/components/TUIChat/TUIChatState.js +1 -1
  93. package/dist/esm/components/TUIChat/hooks/useHandleMessage.js +1 -1
  94. package/dist/esm/components/TUIChat/hooks/useHandleMessageList.js +1 -1
  95. package/dist/esm/components/TUIChat/unitls.js +1 -1
  96. package/dist/esm/components/TUIChatHeader/TUIChatHeaderDefault.js +1 -1
  97. package/dist/esm/components/TUIContact/TUIContactInfo/friendInfo.js +1 -1
  98. package/dist/esm/components/TUIContact/TUIContactList/TUIContactList.js +1 -1
  99. package/dist/esm/components/TUIConversation/TUIConversation.js +1 -1
  100. package/dist/esm/components/TUIConversationList/TUIConversationList.d.ts +1 -0
  101. package/dist/esm/components/TUIConversationList/TUIConversationList.js +1 -1
  102. package/dist/esm/components/TUIKit/TUIKit.js +1 -1
  103. package/dist/esm/components/TUIManage/TUIManage.js +1 -1
  104. package/dist/esm/components/TUIMessage/MessageBubble.js +1 -1
  105. package/dist/esm/components/TUIMessage/MessageContext.js +1 -1
  106. package/dist/esm/components/TUIMessage/MessageCustom.js +1 -1
  107. package/dist/esm/components/TUIMessage/MessageImage.js +1 -1
  108. package/dist/esm/components/TUIMessage/MessageName.js +1 -1
  109. package/dist/esm/components/TUIMessage/MessagePlugins.js +1 -1
  110. package/dist/esm/components/TUIMessage/MessageRevoke.js +1 -1
  111. package/dist/esm/components/TUIMessage/MessageSystem.js +1 -1
  112. package/dist/esm/components/TUIMessage/MessageText.js +1 -1
  113. package/dist/esm/components/TUIMessage/MessageTip.js +1 -1
  114. package/dist/esm/components/TUIMessage/MessageVideo.js +1 -1
  115. package/dist/esm/components/TUIMessage/TUIMessage.js +1 -1
  116. package/dist/esm/components/TUIMessage/hooks/useMessageHandler.js +1 -1
  117. package/dist/esm/components/TUIMessage/utils/index.js +1 -1
  118. package/dist/esm/components/TUIMessageInput/TUIForward.js +1 -1
  119. package/dist/esm/components/TUIMessageInput/TUIMessageInput.js +1 -1
  120. package/dist/esm/components/TUIMessageInput/TUIMessageInputDefault.js +1 -1
  121. package/dist/esm/components/TUIMessageInput/hooks/useEmojiPicker.js +1 -1
  122. package/dist/esm/components/TUIMessageInput/hooks/useHandleForwardMessage.js +1 -1
  123. package/dist/esm/components/TUIMessageInput/hooks/useMessageInputText.js +1 -1
  124. package/dist/esm/components/TUIMessageInput/hooks/useUploadPicker.js +1 -1
  125. package/dist/esm/components/TUIMessageList/TUIMessageList.js +1 -1
  126. package/dist/esm/components/TUIProfile/TUIProfileDefault.js +1 -1
  127. package/dist/esm/components/untils.js +1 -1
  128. package/dist/esm/constants.js +1 -1
  129. package/dist/esm/context/ComponentContext.d.ts +2 -0
  130. package/dist/esm/context/TUIChatActionContext.d.ts +3 -14
  131. package/dist/esm/context/TUIChatStateContext.d.ts +2 -0
  132. package/dist/esm/context/TUIConversationContext.js +1 -1
  133. package/dist/esm/index.css +1 -1
  134. package/dist/esm/index.d.css +240 -12
  135. package/dist/esm/index.js +1 -1
  136. package/dist/esm/locales/en/TUIChat.js +1 -1
  137. package/dist/esm/locales/en/TUIContact.js +1 -1
  138. package/dist/esm/locales/en/TUIProfile.js +1 -1
  139. package/dist/esm/locales/index.js +1 -1
  140. package/dist/esm/locales/zh_cn/TUIChat.js +1 -1
  141. package/dist/esm/locales/zh_cn/TUIContact.js +1 -1
  142. package/dist/esm/locales/zh_cn/TUIProfile.js +1 -1
  143. package/dist/esm/server.js +1 -0
  144. package/dist/esm/utils/env.js +1 -0
  145. package/package.json +7 -6
  146. package/rollup.config.js +0 -1
  147. package/scripts/publish-github.js +60 -0
  148. package/scripts/publish-intl-demo.js +14 -0
  149. package/scripts/publish-npm.js +22 -0
  150. package/src/components/Avatar/styles/index.scss +1 -0
  151. package/src/components/ConversationCreate/ConversationCreatGroupDetail.tsx +6 -3
  152. package/src/components/ConversationCreate/ConversationCreateUserSelectList.tsx +5 -1
  153. package/src/components/ConversationCreate/hooks/useConversationCreate.tsx +7 -2
  154. package/src/components/ConversationCreate/styles/conversationGroupTypeInfo.scss +1 -0
  155. package/src/components/ConversationCreate/styles/index.scss +2 -0
  156. package/src/components/ConversationPreview/ConversationPreview.tsx +2 -0
  157. package/src/components/ConversationPreview/ConversationPreviewContent.tsx +57 -9
  158. package/src/components/ConversationPreview/styles/index.scss +4 -2
  159. package/src/components/ConversationPreview/utils.tsx +5 -1
  160. package/src/components/DivWithEdit/styles/index.scss +2 -1
  161. package/src/components/Icon/config.ts +1 -1
  162. package/src/components/Icon/images/chats-selected.svg +6 -0
  163. package/src/components/Icon/images/chats.svg +9 -0
  164. package/src/components/Icon/images/contacts-selected.svg +3 -0
  165. package/src/components/Icon/images/contacts.svg +6 -0
  166. package/src/components/Icon/images/files.png +0 -0
  167. package/src/components/Icon/images/image.png +0 -0
  168. package/src/components/Icon/images/language.svg +3 -0
  169. package/src/components/Icon/images/video.png +0 -0
  170. package/src/components/Model/styles/layout.scss +1 -1
  171. package/src/components/Profile/styles/index.scss +4 -0
  172. package/src/components/TUIChat/TUIChat.tsx +74 -120
  173. package/src/components/TUIChat/TUIChatState.tsx +18 -45
  174. package/src/components/TUIChat/hooks/useHandleMessage.tsx +8 -0
  175. package/src/components/TUIChat/hooks/useHandleMessageList.tsx +2 -41
  176. package/src/components/TUIChat/unitls.ts +0 -29
  177. package/src/components/TUIChatHeader/TUIChatHeaderDefault.tsx +7 -1
  178. package/src/components/TUIContact/TUIContactInfo/friendInfo.tsx +4 -1
  179. package/src/components/TUIContact/TUIContactList/TUIContactList.tsx +1 -1
  180. package/src/components/TUIConversation/TUIConversation.tsx +1 -4
  181. package/src/components/TUIConversationList/TUIConversationList.tsx +91 -65
  182. package/src/components/TUIConversationList/index.scss +5 -0
  183. package/src/components/TUIKit/TUIKit.tsx +133 -9
  184. package/src/components/TUIKit/styles/h5.scss +34 -0
  185. package/src/components/TUIKit/styles/index.scss +103 -0
  186. package/src/components/TUIKit/styles/reset.scss +20 -0
  187. package/src/components/TUIManage/TUIManage.tsx +59 -35
  188. package/src/components/TUIManage/styles/index.scss +15 -1
  189. package/src/components/TUIMessage/MessageBubble.tsx +20 -3
  190. package/src/components/TUIMessage/MessageCustom.tsx +11 -2
  191. package/src/components/TUIMessage/MessageImage.tsx +2 -1
  192. package/src/components/TUIMessage/MessageName.tsx +1 -1
  193. package/src/components/TUIMessage/MessagePlugins.tsx +4 -2
  194. package/src/components/TUIMessage/MessageRevoke.tsx +2 -2
  195. package/src/components/TUIMessage/MessageText.tsx +25 -3
  196. package/src/components/TUIMessage/MessageVideo.tsx +8 -5
  197. package/src/components/TUIMessage/hooks/useMessageHandler.ts +13 -33
  198. package/src/components/TUIMessage/styles/color.scss +1 -0
  199. package/src/components/TUIMessage/styles/layout.scss +33 -6
  200. package/src/components/TUIMessage/utils/index.ts +1 -1
  201. package/src/components/TUIMessageInput/TUIMessageInputDefault.tsx +2 -2
  202. package/src/components/TUIMessageInput/hooks/useEmojiPicker.tsx +2 -6
  203. package/src/components/TUIMessageInput/hooks/useHandleForwardMessage.tsx +4 -3
  204. package/src/components/TUIMessageInput/hooks/useMessageInputText.tsx +10 -3
  205. package/src/components/TUIMessageInput/hooks/useUploadPicker.tsx +10 -14
  206. package/src/components/TUIMessageInput/styles/color.scss +1 -1
  207. package/src/components/TUIMessageInput/styles/layout.scss +7 -2
  208. package/src/components/TUIMessageList/TUIMessageList.tsx +9 -13
  209. package/src/components/TUIMessageList/index.ts +0 -1
  210. package/src/components/TUIProfile/TUIProfileDefault.tsx +65 -51
  211. package/src/components/TUIProfile/styles/layout.scss +6 -0
  212. package/src/components/untils.ts +9 -0
  213. package/src/constants.ts +4 -1
  214. package/src/context/ComponentContext.tsx +2 -0
  215. package/src/context/TUIChatActionContext.tsx +3 -23
  216. package/src/context/TUIChatStateContext.tsx +2 -0
  217. package/src/context/TUIKitContext.tsx +0 -1
  218. package/src/index.ts +3 -0
  219. package/src/locales/en/TUIChat.ts +2 -1
  220. package/src/locales/en/TUIContact.ts +1 -1
  221. package/src/locales/en/TUIProfile.ts +5 -4
  222. package/src/locales/index.ts +1 -1
  223. package/src/locales/zh_cn/TUIChat.ts +1 -0
  224. package/src/locales/zh_cn/TUIContact.ts +1 -1
  225. package/src/locales/zh_cn/TUIProfile.ts +1 -0
  226. package/src/server.ts +44 -0
  227. package/src/utils/env.ts +5 -0
  228. package/tsconfig.json +1 -0
  229. package/dist/cjs/components/Icon/images/document.png.js +0 -1
  230. package/dist/cjs/components/TUIChat/hooks/useCreateMessage.d.ts +0 -59
  231. package/dist/cjs/components/TUIChat/hooks/useCreateMessage.js +0 -1
  232. package/dist/cjs/components/TUIChat/hooks/useMessageReceviedListener.js +0 -1
  233. package/dist/cjs/components/TUIMessageList/hooks/useEnrichedMessageList.js +0 -1
  234. package/dist/esm/components/Icon/images/document.png.js +0 -1
  235. package/dist/esm/components/TUIChat/hooks/useCreateMessage.d.ts +0 -59
  236. package/dist/esm/components/TUIChat/hooks/useCreateMessage.js +0 -1
  237. package/dist/esm/components/TUIChat/hooks/useMessageReceviedListener.js +0 -1
  238. package/dist/esm/components/TUIMessageList/hooks/useEnrichedMessageList.js +0 -1
  239. package/src/components/TUIChat/hooks/useCreateMessage.tsx +0 -198
  240. package/src/components/TUIChat/hooks/useMessageReceviedListener.tsx +0 -26
  241. package/src/components/TUIMessageList/hooks/useEnrichedMessageList.tsx +0 -16
@@ -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,24 @@
1
- import React, { PropsWithChildren } from 'react';
1
+ import React, { PropsWithChildren, useState, useEffect } from 'react';
2
2
  import { ChatSDK, Conversation } from '@tencentcloud/chat';
3
+ import { TUIStore, StoreName } from '@tencentcloud/chat-uikit-engine';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { isH5, isPC } from '../../utils/env';
3
6
  import { useTUIKit } 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';
10
17
  import '../../locales/index';
18
+ import chats from '../Icon/images/chats.svg';
19
+ import chatsSelected from '../Icon/images/chats-selected.svg';
20
+ import contacts from '../Icon/images/contacts.svg';
21
+ import contactsSelected from '../Icon/images/contacts-selected.svg';
11
22
 
12
23
  export interface ChatProps {
13
24
  chat?: ChatSDK | null,
@@ -15,13 +26,94 @@ export interface ChatProps {
15
26
  customClasses?: unknown,
16
27
  activeConversation?: Conversation,
17
28
  }
29
+
30
+ interface RenderPCProps {
31
+ moduleValue: string,
32
+ tabbarRender: any,
33
+ setModuleValue: (value: string) => void
34
+ }
35
+ interface RenderH5Props {
36
+ currentConversationID: string
37
+ }
38
+
39
+ const tabbarList = [
40
+ {
41
+ id: 1,
42
+ name: 'chats',
43
+ icon: chats,
44
+ selectedIcon: chatsSelected,
45
+ value: 'chats',
46
+ },
47
+ {
48
+ id: 2,
49
+ name: 'contacts',
50
+ icon: contacts,
51
+ selectedIcon: contactsSelected,
52
+ value: 'contacts',
53
+ },
54
+ ];
55
+ const TUIMessageInputConfig = {
56
+ className: 'sample-h5-input',
57
+ isTransmitter: true,
58
+ };
59
+
60
+ function RenderForPC({ moduleValue, tabbarRender, setModuleValue } : RenderPCProps) {
61
+ return (
62
+ <>
63
+ <div className="sample-chat-left-container">
64
+ <TUIProfile className="sample-chat-profile" />
65
+ {tabbarRender}
66
+ {moduleValue === 'chats' && <TUIConversation />}
67
+ {moduleValue === 'contacts' && <TUIContact />}
68
+ </div>
69
+ {moduleValue === 'chats' && (
70
+ <>
71
+ <TUIChat />
72
+ <TUIManage />
73
+ </>
74
+ )}
75
+ {moduleValue === 'contacts' && (
76
+ <TUIContact>
77
+ <TUIContactInfo
78
+ showChat={() => {
79
+ setModuleValue('chats');
80
+ }}
81
+ />
82
+ </TUIContact>
83
+ )}
84
+ </>
85
+ );
86
+ }
87
+
88
+ function RenderForH5({ currentConversationID }: RenderH5Props) {
89
+ return (
90
+ <>
91
+ {!currentConversationID && (
92
+ <div className="sample-chat-h5-container">
93
+ <TUIProfile className="sample-profile" />
94
+ <TUIConversation />
95
+ </div>
96
+ )}
97
+ {currentConversationID && (
98
+ <>
99
+ <TUIChat TUIMessageInputConfig={TUIMessageInputConfig} />
100
+ <TUIManage />
101
+ </>
102
+ )}
103
+ </>
104
+ );
105
+ }
18
106
  export function TUIKit<
19
107
  T extends ChatProps
20
108
  >(
21
109
  props:PropsWithChildren<T>,
22
110
  ):React.ReactElement {
111
+ const [currentConversationID, setCurrentConversationID] = useState<string>('');
112
+ const [moduleValue, setModuleValue] = useState('chats');
113
+ const { t } = useTranslation();
114
+
23
115
  const {
24
- children, chat, customClasses, activeConversation, language,
116
+ children, chat, customClasses, activeConversation, language = 'en',
25
117
  } = props;
26
118
  (window as any).tencent_cloud_im_csig_react_uikit_23F_xa = true;
27
119
  const {
@@ -49,17 +141,49 @@ export function TUIKit<
49
141
  setTUIProfileShow,
50
142
  setActiveContact,
51
143
  });
144
+ useEffect(() => {
145
+ TUIStore.watch(StoreName.CONV, {
146
+ currentConversationID: onCurrentConversationID,
147
+ });
148
+ return () => {
149
+ TUIStore.unwatch(StoreName.CONV, {
150
+ currentConversationID: onCurrentConversationID,
151
+ });
152
+ };
153
+ }, []);
154
+
155
+ const onCurrentConversationID = (id: string) => {
156
+ setCurrentConversationID(id);
157
+ };
158
+ const switchTabbar = (value: string) => {
159
+ setModuleValue(value);
160
+ };
161
+
162
+ const tabbarRender = (
163
+ <div className="sample-chat-tab">
164
+ {tabbarList.map((item: any) => (
165
+ <div
166
+ className="sample-chat-tab-container"
167
+ key={item.id}
168
+ role="presentation"
169
+ onClick={() => {
170
+ switchTabbar(item.value);
171
+ }}
172
+ >
173
+ <img src={moduleValue === item.value ? item.selectedIcon : item.icon} alt="" />
174
+ <p className={`sample-chat-tab-text ${moduleValue === item.value ? 'sample-chat-tab-active' : ''}`}>
175
+ {t(item.name)}
176
+ </p>
177
+ </div>
178
+ ))}
179
+ </div>
180
+ );
52
181
 
53
182
  return (
54
183
  <TUIKitProvider value={chatContextValue}>
55
184
  <div className="tui-kit">
56
- {children || (
57
- <>
58
- <TUIConversation />
59
- <TUIChat />
60
- <TUIManage />
61
- </>
62
- )}
185
+ {children || (isPC && <RenderForPC moduleValue={moduleValue} tabbarRender={tabbarRender} setModuleValue={setModuleValue} />)
186
+ || (isH5 && <RenderForH5 currentConversationID={currentConversationID} />)}
63
187
  </div>
64
188
  </TUIKitProvider>
65
189
  );
@@ -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
+ }
@@ -7,3 +7,106 @@
7
7
  background-color: #FFFFFF;
8
8
  text-align: initial;
9
9
  }
10
+ .sample-chat {
11
+ position:relative;
12
+ margin: 0 auto;
13
+ width: calc(100% - 20rem);
14
+ min-width: 850px;
15
+ height: 86%;
16
+ box-sizing: border-box;
17
+ border-radius: 12px;
18
+ overflow: hidden;
19
+ &-profile {
20
+ position: absolute;
21
+ top: 0;
22
+ z-index: 1;
23
+ }
24
+ &-left-container {
25
+ max-width: 360px;
26
+ min-width: 360px;
27
+ display: flex;
28
+ flex-direction: column;
29
+ }
30
+ &-tab {
31
+ display: flex;
32
+ align-items: center;
33
+ justify-content: space-around;
34
+ margin: 12px;
35
+ }
36
+ &-tab-container {
37
+ display: flex;
38
+ flex-direction: column;
39
+ align-items: center;
40
+ justify-content: center;
41
+ cursor: pointer;
42
+ }
43
+ &-tab-text {
44
+ font-size: 15px;
45
+ line-height: 25px;
46
+ text-align: center;
47
+ }
48
+ &-tab-active {
49
+ color: #147AFF;
50
+ }
51
+ }
52
+ .tuikit-container {
53
+ display: flex;
54
+ height: 100%;
55
+ position: relative;
56
+ text-align: initial;
57
+ box-shadow: 0 11px 20px 0 rgba(0,0,0,.3);
58
+ }
59
+ .tui-chat-default {
60
+ width: 100%;
61
+ height: 100%;
62
+ background-size: cover;
63
+ background-position-x: -17px;
64
+ background-position-y: 173px;
65
+ padding: 100px 40px 0;
66
+ header {
67
+ display: flex;
68
+ align-items: center;
69
+ font-size: 1.75rem;
70
+ font-family: PingFangSC-Medium;
71
+ font-weight: 500;
72
+ color: #000;
73
+ letter-spacing: 0;
74
+ img {
75
+ width: 32px;
76
+ margin: 0 10px;
77
+ }
78
+ }
79
+ .content {
80
+ max-width: 393px;
81
+ font-size: 16px;
82
+ line-height: 24px;
83
+ font-family: PingFangSC-Regular;
84
+ font-weight: 400;
85
+ color: #666;
86
+ letter-spacing: 0;
87
+ padding: 36px 0 20px;
88
+ }
89
+ .link {
90
+ font-size: 14px;
91
+ line-height: 20px;
92
+ font-family: PingFangSC-Regular;
93
+ font-weight: 400;
94
+ color: #666;
95
+ letter-spacing: 0;
96
+ a {
97
+ font-family: PingFangSC-Regular;
98
+ font-weight: 400;
99
+ color: #006eff;
100
+ letter-spacing: 0;
101
+ text-decoration: none;
102
+ padding: 0 5px;
103
+ }
104
+ }
105
+ }
106
+
107
+
108
+ body {
109
+ #webpack-dev-server-client-overlay {
110
+ display: none !important;
111
+ }
112
+ }
@@ -45,3 +45,23 @@ table {
45
45
  border-collapse: collapse;
46
46
  border-spacing: 0;
47
47
  }
48
+ html, body {
49
+ height: 100%;
50
+ width: 100%;
51
+ margin: 0;
52
+ -webkit-text-size-adjust: 100%;
53
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
54
+ }
55
+ *{
56
+ -webkit-touch-callout:none;
57
+ -webkit-user-select:none;
58
+ -khtml-user-select:none;
59
+ -moz-user-select:none;
60
+ -ms-user-select:none;
61
+ user-select:none;
62
+ }
63
+ .text-ellipsis {
64
+ text-overflow: ellipsis;
65
+ white-space: nowrap;
66
+ overflow: hidden;
67
+ }
@@ -5,6 +5,7 @@ import { Icon, IconTypes } from '../Icon';
5
5
  import { Avatar, defaultGroupAvatarWork, defaultUserAvatar } from '../Avatar';
6
6
  import { Switch } from '../Switch';
7
7
  import { useTUIKitContext } from '../../context';
8
+ import { isH5, isPC } from '../../utils/env';
8
9
  import { getMessageProfile } from '../ConversationPreview/utils';
9
10
  import { useConversationUpdate } from '../TUIConversationList/hooks/useConversationUpdate';
10
11
  import { useConversation } from '../../hooks';
@@ -46,43 +47,66 @@ export function TUIManage() {
46
47
  setIsPinned(activeConversation ? activeConversation.isPinned : false);
47
48
  }, [activeConversation, forceUpdateCount]);
48
49
 
49
- return TUIManageShow && activeConversation && (
50
- <div className="tui-manage">
51
- <div className="tui-manage-title">
52
- <Icon type={IconTypes.CANCEL} width={16} height={16} onClick={close} />
53
- <span>{t('TUIConversation.Conversation Information')}</span>
54
- </div>
55
- <div className="tui-manage-container">
56
- <div className="tui-manage-info">
57
- <div className="info-avatar">
58
- <Avatar
59
- size={64}
60
- image={
61
- profile?.avatar || (profile?.groupID ? defaultGroupAvatarWork : defaultUserAvatar)
62
- }
63
- />
50
+ return (
51
+ TUIManageShow
52
+ && activeConversation && (
53
+ <div className={`tui-manage ${isH5 ? 'tui-h5-manage' : ''}`}>
54
+ <div className="tui-manage-title">
55
+ {isPC && (
56
+ <Icon
57
+ onClick={close}
58
+ type={IconTypes.CANCEL}
59
+ width={9}
60
+ height={16}
61
+ />
62
+ )}
63
+ {isH5 && (
64
+ <Icon onClick={close} type={IconTypes.BACK} width={9} height={16} />
65
+ )}
66
+ <span style={{ marginLeft: '10px' }}>
67
+ {t('TUIConversation.Conversation Information')}
68
+ </span>
64
69
  </div>
65
- <div className="info-name">
66
- {profile?.nick || profile?.name}
67
- </div>
68
- <div className="info-id">
69
- ID:
70
- {profile?.userID || profile?.groupID}
71
- </div>
72
- </div>
73
- <div className="tui-manage-handle">
74
- <div className="manage-handle-box">
75
- <div className="manage-handle-title">{t('TUIConversation.Pin')}</div>
76
- <Switch
77
- onChange={pinChatChange}
78
- checked={isPinned}
79
- />
80
- </div>
81
- <div className="manage-handle-box" role="presentation" onClick={handleDelete}>
82
- <div className="manage-handle-title red">{t('TUIConversation.Delete')}</div>
70
+ <div className="tui-manage-container">
71
+ <div className="tui-manage-info">
72
+ <div className="info-avatar">
73
+ <Avatar
74
+ size={64}
75
+ image={
76
+ profile?.avatar
77
+ || (profile?.groupID
78
+ ? defaultGroupAvatarWork
79
+ : defaultUserAvatar)
80
+ }
81
+ />
82
+ </div>
83
+ <div className="info-name">{profile?.nick || profile?.name}</div>
84
+ <div className="info-id">
85
+ ID:
86
+ {profile?.userID || profile?.groupID}
87
+ </div>
88
+ </div>
89
+ <div className="tui-manage-handle">
90
+ <div className="manage-handle-box">
91
+ <div className="manage-handle-title">
92
+ {t('TUIConversation.Pin')}
93
+ </div>
94
+ <Switch onChange={pinChatChange} checked={isPinned} />
95
+ </div>
96
+ {isPC && (
97
+ <div
98
+ className="manage-handle-box"
99
+ role="presentation"
100
+ onClick={handleDelete}
101
+ >
102
+ <div className="manage-handle-title red">
103
+ {t('TUIConversation.Delete')}
104
+ </div>
105
+ </div>
106
+ )}
107
+ </div>
83
108
  </div>
84
109
  </div>
85
- </div>
86
- </div>
110
+ )
87
111
  );
88
112
  }