@tencentcloud/chat-uikit-react 1.0.3 → 1.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 (234) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +69 -83
  3. package/dist/cjs/components/ConversationCreate/ConversationCreatGroupDetail.js +1 -1
  4. package/dist/cjs/components/ConversationCreate/ConversationCreate.js +1 -1
  5. package/dist/cjs/components/ConversationCreate/ConversationCreateUserSelectList.js +1 -1
  6. package/dist/cjs/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
  7. package/dist/cjs/components/ConversationPreview/ConversationListContainer.d.ts +1 -1
  8. package/dist/cjs/components/ConversationPreview/ConversationPreview.d.ts +1 -1
  9. package/dist/cjs/components/ConversationPreview/ConversationPreviewContent.js +1 -1
  10. package/dist/cjs/components/ConversationPreview/utils.js +1 -1
  11. package/dist/cjs/components/ConversationSearch/ConversationSearchResult.d.ts +1 -1
  12. package/dist/cjs/components/ConversationSearch/ConversationSearchResult.js +1 -1
  13. package/dist/cjs/components/TUIChat/TUIChat.d.ts +1 -1
  14. package/dist/cjs/components/TUIChat/TUIChat.js +1 -1
  15. package/dist/cjs/components/TUIChat/TUIChatState.js +1 -1
  16. package/dist/cjs/components/TUIChat/hooks/useCreateMessage.d.ts +2 -2
  17. package/dist/cjs/components/TUIChat/hooks/useCreateMessage.js +1 -1
  18. package/dist/cjs/components/TUIChat/hooks/useCreateTUIChatStateContext.js +1 -1
  19. package/dist/cjs/components/TUIChat/hooks/useHandleMessage.d.ts +1 -1
  20. package/dist/cjs/components/TUIChat/hooks/useHandleMessageList.js +1 -1
  21. package/dist/cjs/components/TUIChat/hooks/useMessageReceviedListener.js +1 -1
  22. package/dist/cjs/components/TUIChat/unitls.js +1 -1
  23. package/dist/cjs/components/TUIChatHeader/TUIChatHeader.d.ts +1 -1
  24. package/dist/cjs/components/TUIChatHeader/TUIChatHeaderDefault.d.ts +1 -1
  25. package/dist/cjs/components/TUIChatHeader/TUIChatHeaderDefault.js +1 -1
  26. package/dist/cjs/components/TUIConversation/TUIConversation.d.ts +1 -1
  27. package/dist/cjs/components/TUIConversation/TUIConversation.js +1 -1
  28. package/dist/cjs/components/TUIConversationList/TUIConversationList.d.ts +1 -1
  29. package/dist/cjs/components/TUIConversationList/TUIConversationList.js +1 -1
  30. package/dist/cjs/components/TUIConversationList/hooks/useConversationList.js +1 -1
  31. package/dist/cjs/components/TUIConversationList/hooks/useConversationUpdate.js +1 -1
  32. package/dist/cjs/components/TUIKit/TUIKit.d.ts +2 -2
  33. package/dist/cjs/components/TUIKit/TUIKit.js +1 -1
  34. package/dist/cjs/components/TUIKit/hooks/useCreateTUIKitContext.d.ts +5 -5
  35. package/dist/cjs/components/TUIKit/hooks/useCreateTUIKitContext.js +1 -1
  36. package/dist/cjs/components/TUIKit/hooks/useTUIKit.d.ts +3 -3
  37. package/dist/cjs/components/TUIKit/hooks/useTUIKit.js +1 -1
  38. package/dist/cjs/components/TUIManage/TUIManage.js +1 -1
  39. package/dist/cjs/components/TUIMessage/MessageBubble.js +1 -1
  40. package/dist/cjs/components/TUIMessage/MessageContext.d.ts +1 -1
  41. package/dist/cjs/components/TUIMessage/MessageContext.js +1 -1
  42. package/dist/cjs/components/TUIMessage/MessageCustom.js +1 -1
  43. package/dist/cjs/components/TUIMessage/MessageFile.js +1 -1
  44. package/dist/cjs/components/TUIMessage/MessageImage.js +1 -1
  45. package/dist/cjs/components/TUIMessage/MessageMerger.js +1 -1
  46. package/dist/cjs/components/TUIMessage/MessageName.js +1 -1
  47. package/dist/cjs/components/TUIMessage/MessagePlugins.d.ts +2 -2
  48. package/dist/cjs/components/TUIMessage/MessagePlugins.js +1 -1
  49. package/dist/cjs/components/TUIMessage/MessageProgress.js +1 -1
  50. package/dist/cjs/components/TUIMessage/MessageRevoke.js +1 -1
  51. package/dist/cjs/components/TUIMessage/MessageText.js +1 -1
  52. package/dist/cjs/components/TUIMessage/TUIMessage.d.ts +1 -1
  53. package/dist/cjs/components/TUIMessage/TUIMessage.js +1 -1
  54. package/dist/cjs/components/TUIMessage/TUIMessageDefault.js +1 -1
  55. package/dist/cjs/components/TUIMessage/hooks/useMessageContextHandler.js +1 -1
  56. package/dist/cjs/components/TUIMessage/hooks/useMessageHandler.js +1 -1
  57. package/dist/cjs/components/TUIMessage/hooks/useMessageReply.js +1 -1
  58. package/dist/cjs/components/TUIMessage/utils/index.js +1 -1
  59. package/dist/cjs/components/TUIMessageInput/TUIMessageInput.js +1 -1
  60. package/dist/cjs/components/TUIMessageInput/hooks/useHandleForwardMessage.js +1 -1
  61. package/dist/cjs/components/TUIMessageInput/hooks/useHandleQuoteMessage.js +1 -1
  62. package/dist/cjs/components/TUIMessageInput/hooks/useMessageInputText.js +1 -1
  63. package/dist/cjs/components/TUIMessageInput/hooks/useUploadPicker.js +1 -1
  64. package/dist/cjs/components/TUIMessageList/TUIMessageList.d.ts +1 -1
  65. package/dist/cjs/components/TUIMessageList/TUIMessageList.js +1 -1
  66. package/dist/cjs/components/TUIMessageList/hooks/useMessageListElement.js +1 -1
  67. package/dist/cjs/components/TUIProfile/TUIProfileDefault.d.ts +1 -1
  68. package/dist/cjs/components/TUIProfile/TUIProfileDefault.js +1 -1
  69. package/dist/cjs/components/TUIProfile/hooks/useMyProfile.js +1 -1
  70. package/dist/cjs/components/untils.js +1 -1
  71. package/dist/cjs/constants.js +1 -1
  72. package/dist/cjs/context/TUIChatActionContext.d.ts +3 -3
  73. package/dist/cjs/context/TUIChatStateContext.d.ts +2 -2
  74. package/dist/cjs/context/TUIConversationContext.js +1 -1
  75. package/dist/cjs/context/TUIKitContext.d.ts +2 -2
  76. package/dist/cjs/context/TUIMessageContext.d.ts +1 -1
  77. package/dist/cjs/hooks/useConversation.d.ts +3 -3
  78. package/dist/cjs/hooks/useConversation.js +1 -1
  79. package/dist/cjs/hooks/useProfile.d.ts +1 -1
  80. package/dist/cjs/index.js +1 -1
  81. package/dist/esm/components/ConversationCreate/ConversationCreatGroupDetail.js +1 -1
  82. package/dist/esm/components/ConversationCreate/ConversationCreate.js +1 -1
  83. package/dist/esm/components/ConversationCreate/ConversationCreateUserSelectList.js +1 -1
  84. package/dist/esm/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
  85. package/dist/esm/components/ConversationPreview/ConversationListContainer.d.ts +1 -1
  86. package/dist/esm/components/ConversationPreview/ConversationPreview.d.ts +1 -1
  87. package/dist/esm/components/ConversationPreview/ConversationPreviewContent.js +1 -1
  88. package/dist/esm/components/ConversationPreview/utils.js +1 -1
  89. package/dist/esm/components/ConversationSearch/ConversationSearchResult.d.ts +1 -1
  90. package/dist/esm/components/ConversationSearch/ConversationSearchResult.js +1 -1
  91. package/dist/esm/components/TUIChat/TUIChat.d.ts +1 -1
  92. package/dist/esm/components/TUIChat/TUIChat.js +1 -1
  93. package/dist/esm/components/TUIChat/TUIChatState.js +1 -1
  94. package/dist/esm/components/TUIChat/hooks/useCreateMessage.d.ts +2 -2
  95. package/dist/esm/components/TUIChat/hooks/useCreateMessage.js +1 -1
  96. package/dist/esm/components/TUIChat/hooks/useCreateTUIChatStateContext.js +1 -1
  97. package/dist/esm/components/TUIChat/hooks/useHandleMessage.d.ts +1 -1
  98. package/dist/esm/components/TUIChat/hooks/useHandleMessageList.js +1 -1
  99. package/dist/esm/components/TUIChat/hooks/useMessageReceviedListener.js +1 -1
  100. package/dist/esm/components/TUIChat/unitls.js +1 -1
  101. package/dist/esm/components/TUIChatHeader/TUIChatHeader.d.ts +1 -1
  102. package/dist/esm/components/TUIChatHeader/TUIChatHeaderDefault.d.ts +1 -1
  103. package/dist/esm/components/TUIChatHeader/TUIChatHeaderDefault.js +1 -1
  104. package/dist/esm/components/TUIConversation/TUIConversation.d.ts +1 -1
  105. package/dist/esm/components/TUIConversation/TUIConversation.js +1 -1
  106. package/dist/esm/components/TUIConversationList/TUIConversationList.d.ts +1 -1
  107. package/dist/esm/components/TUIConversationList/TUIConversationList.js +1 -1
  108. package/dist/esm/components/TUIConversationList/hooks/useConversationList.js +1 -1
  109. package/dist/esm/components/TUIConversationList/hooks/useConversationUpdate.js +1 -1
  110. package/dist/esm/components/TUIKit/TUIKit.d.ts +2 -2
  111. package/dist/esm/components/TUIKit/TUIKit.js +1 -1
  112. package/dist/esm/components/TUIKit/hooks/useCreateTUIKitContext.d.ts +5 -5
  113. package/dist/esm/components/TUIKit/hooks/useCreateTUIKitContext.js +1 -1
  114. package/dist/esm/components/TUIKit/hooks/useTUIKit.d.ts +3 -3
  115. package/dist/esm/components/TUIKit/hooks/useTUIKit.js +1 -1
  116. package/dist/esm/components/TUIManage/TUIManage.js +1 -1
  117. package/dist/esm/components/TUIMessage/MessageBubble.js +1 -1
  118. package/dist/esm/components/TUIMessage/MessageContext.d.ts +1 -1
  119. package/dist/esm/components/TUIMessage/MessageContext.js +1 -1
  120. package/dist/esm/components/TUIMessage/MessageCustom.js +1 -1
  121. package/dist/esm/components/TUIMessage/MessageFile.js +1 -1
  122. package/dist/esm/components/TUIMessage/MessageImage.js +1 -1
  123. package/dist/esm/components/TUIMessage/MessageMerger.js +1 -1
  124. package/dist/esm/components/TUIMessage/MessageName.js +1 -1
  125. package/dist/esm/components/TUIMessage/MessagePlugins.d.ts +2 -2
  126. package/dist/esm/components/TUIMessage/MessagePlugins.js +1 -1
  127. package/dist/esm/components/TUIMessage/MessageProgress.js +1 -1
  128. package/dist/esm/components/TUIMessage/MessageRevoke.js +1 -1
  129. package/dist/esm/components/TUIMessage/MessageText.js +1 -1
  130. package/dist/esm/components/TUIMessage/TUIMessage.d.ts +1 -1
  131. package/dist/esm/components/TUIMessage/TUIMessage.js +1 -1
  132. package/dist/esm/components/TUIMessage/TUIMessageDefault.js +1 -1
  133. package/dist/esm/components/TUIMessage/hooks/useMessageContextHandler.js +1 -1
  134. package/dist/esm/components/TUIMessage/hooks/useMessageHandler.js +1 -1
  135. package/dist/esm/components/TUIMessage/hooks/useMessageReply.js +1 -1
  136. package/dist/esm/components/TUIMessage/utils/index.js +1 -1
  137. package/dist/esm/components/TUIMessageInput/TUIMessageInput.js +1 -1
  138. package/dist/esm/components/TUIMessageInput/hooks/useHandleForwardMessage.js +1 -1
  139. package/dist/esm/components/TUIMessageInput/hooks/useHandleQuoteMessage.js +1 -1
  140. package/dist/esm/components/TUIMessageInput/hooks/useMessageInputText.js +1 -1
  141. package/dist/esm/components/TUIMessageInput/hooks/useUploadPicker.js +1 -1
  142. package/dist/esm/components/TUIMessageList/TUIMessageList.d.ts +1 -1
  143. package/dist/esm/components/TUIMessageList/TUIMessageList.js +1 -1
  144. package/dist/esm/components/TUIMessageList/hooks/useMessageListElement.js +1 -1
  145. package/dist/esm/components/TUIProfile/TUIProfileDefault.d.ts +1 -1
  146. package/dist/esm/components/TUIProfile/TUIProfileDefault.js +1 -1
  147. package/dist/esm/components/TUIProfile/hooks/useMyProfile.js +1 -1
  148. package/dist/esm/components/untils.js +1 -1
  149. package/dist/esm/constants.js +1 -1
  150. package/dist/esm/context/TUIChatActionContext.d.ts +3 -3
  151. package/dist/esm/context/TUIChatStateContext.d.ts +2 -2
  152. package/dist/esm/context/TUIConversationContext.js +1 -1
  153. package/dist/esm/context/TUIKitContext.d.ts +2 -2
  154. package/dist/esm/context/TUIMessageContext.d.ts +1 -1
  155. package/dist/esm/hooks/useConversation.d.ts +3 -3
  156. package/dist/esm/hooks/useConversation.js +1 -1
  157. package/dist/esm/hooks/useProfile.d.ts +1 -1
  158. package/dist/esm/index.js +1 -1
  159. package/package.json +2 -3
  160. package/src/components/ConversationCreate/ConversationCreatGroupDetail.tsx +5 -2
  161. package/src/components/ConversationCreate/ConversationCreate.tsx +3 -3
  162. package/src/components/ConversationCreate/ConversationCreateSelectView.tsx +1 -1
  163. package/src/components/ConversationCreate/ConversationCreateUserSelectList.tsx +4 -4
  164. package/src/components/ConversationCreate/ConversationGroupTypeInfo.tsx +5 -5
  165. package/src/components/ConversationCreate/hooks/useConversationCreate.tsx +6 -6
  166. package/src/components/ConversationPreview/ConversationListContainer.tsx +1 -1
  167. package/src/components/ConversationPreview/ConversationPreview.tsx +1 -1
  168. package/src/components/ConversationPreview/ConversationPreviewContent.tsx +2 -2
  169. package/src/components/ConversationPreview/utils.tsx +10 -10
  170. package/src/components/ConversationSearch/ConversationSearchResult.tsx +1 -1
  171. package/src/components/Profile/Profile.tsx +1 -1
  172. package/src/components/Profile/hooks/useProfile.tsx +5 -5
  173. package/src/components/TUIChat/TUIChat.tsx +23 -17
  174. package/src/components/TUIChat/TUIChatState.tsx +7 -7
  175. package/src/components/TUIChat/hooks/useCreateMessage.tsx +29 -29
  176. package/src/components/TUIChat/hooks/useCreateTUIChatStateContext.tsx +5 -5
  177. package/src/components/TUIChat/hooks/useHandleMessage.tsx +2 -2
  178. package/src/components/TUIChat/hooks/useHandleMessageList.tsx +28 -15
  179. package/src/components/TUIChat/hooks/useMessageReceviedListener.tsx +5 -5
  180. package/src/components/TUIChat/unitls.ts +3 -3
  181. package/src/components/TUIChatHeader/TUIChatHeader.tsx +1 -1
  182. package/src/components/TUIChatHeader/TUIChatHeaderDefault.tsx +7 -7
  183. package/src/components/TUIConversation/TUIConversation.tsx +1 -1
  184. package/src/components/TUIConversationList/TUIConversationList.tsx +3 -3
  185. package/src/components/TUIConversationList/hooks/useConversationList.tsx +5 -5
  186. package/src/components/TUIConversationList/hooks/useConversationUpdate.tsx +6 -6
  187. package/src/components/TUIKit/TUIKit.tsx +5 -5
  188. package/src/components/TUIKit/hooks/useCreateTUIKitContext.tsx +3 -3
  189. package/src/components/TUIKit/hooks/useTUIKit.tsx +8 -8
  190. package/src/components/TUIManage/TUIManage.tsx +2 -2
  191. package/src/components/TUIMessage/MessageAvatar.tsx +1 -1
  192. package/src/components/TUIMessage/MessageBubble.tsx +4 -4
  193. package/src/components/TUIMessage/MessageContext.tsx +19 -19
  194. package/src/components/TUIMessage/MessageCustom.tsx +2 -2
  195. package/src/components/TUIMessage/MessageFile.tsx +2 -2
  196. package/src/components/TUIMessage/MessageImage.tsx +2 -2
  197. package/src/components/TUIMessage/MessageMerger.tsx +2 -2
  198. package/src/components/TUIMessage/MessageName.tsx +2 -2
  199. package/src/components/TUIMessage/MessagePlugins.tsx +3 -3
  200. package/src/components/TUIMessage/MessageProgress.tsx +8 -8
  201. package/src/components/TUIMessage/MessageRevoke.tsx +2 -2
  202. package/src/components/TUIMessage/MessageStatus.tsx +1 -1
  203. package/src/components/TUIMessage/MessageText.tsx +2 -2
  204. package/src/components/TUIMessage/TUIMessage.tsx +1 -1
  205. package/src/components/TUIMessage/TUIMessageDefault.tsx +7 -8
  206. package/src/components/TUIMessage/hooks/useMessageContextHandler.ts +12 -12
  207. package/src/components/TUIMessage/hooks/useMessageHandler.ts +12 -12
  208. package/src/components/TUIMessage/hooks/useMessagePluginElement.tsx +2 -2
  209. package/src/components/TUIMessage/hooks/useMessageReply.ts +11 -11
  210. package/src/components/TUIMessage/utils/index.ts +16 -16
  211. package/src/components/TUIMessageInput/InputQuoteDefalut.tsx +1 -1
  212. package/src/components/TUIMessageInput/TUIForward.tsx +1 -1
  213. package/src/components/TUIMessageInput/TUIMessageInput.tsx +2 -2
  214. package/src/components/TUIMessageInput/hooks/useHandleForwardMessage.tsx +5 -5
  215. package/src/components/TUIMessageInput/hooks/useHandleQuoteMessage.tsx +15 -15
  216. package/src/components/TUIMessageInput/hooks/useMessageInputText.tsx +2 -2
  217. package/src/components/TUIMessageInput/hooks/useUploadPicker.tsx +2 -2
  218. package/src/components/TUIMessageList/TUIMessageList.tsx +2 -2
  219. package/src/components/TUIMessageList/hooks/useEnrichedMessageList.tsx +1 -1
  220. package/src/components/TUIMessageList/hooks/useMessageListElement.tsx +8 -11
  221. package/src/components/TUIProfile/TUIProfileDefault.tsx +6 -6
  222. package/src/components/TUIProfile/hooks/useMyProfile.tsx +9 -9
  223. package/src/components/untils.ts +4 -4
  224. package/src/constants.ts +1 -1
  225. package/src/context/TUIChatActionContext.tsx +3 -3
  226. package/src/context/TUIChatStateContext.tsx +2 -2
  227. package/src/context/TUIConversationContext.tsx +1 -1
  228. package/src/context/TUIKitContext.tsx +2 -2
  229. package/src/context/TUIMessageContext.tsx +1 -1
  230. package/src/hooks/useConversation.tsx +11 -11
  231. package/src/hooks/useProfile.tsx +2 -2
  232. package/readme.zh_cn.md +0 -60
  233. package/src/@types/index.d.ts +0 -1
  234. package/src/@types/index.js +0 -3
@@ -1,5 +1,5 @@
1
1
  import React, { MutableRefObject, PropsWithChildren } from 'react';
2
- import TIM from 'tim-js-sdk';
2
+ import TencentCloudChat from '@tencentcloud/chat';
3
3
  import { TUIMessageInputContextProvider } from '../../context/TUIMessageInputContext';
4
4
  import { useMessageInputState, useCreateMessageInputContext } from './hooks';
5
5
  import './styles/index.scss';
@@ -53,7 +53,7 @@ function TUIMessageInputProvider<T extends TUIMessageInputProps>(props: PropsWit
53
53
  const messageInputState = useMessageInputState(props);
54
54
  const { textareaRef, conversation } = useTUIChatStateContext('TUIMessageInput');
55
55
 
56
- const contextDisabled = conversation?.type === TIM.TYPES.CONV_SYSTEM;
56
+ const contextDisabled = conversation?.type === TencentCloudChat.TYPES.CONV_SYSTEM;
57
57
 
58
58
  const { TUIMessageInputConfig } = useTUIChatStateContext('TUIMessageInput');
59
59
 
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useState } from 'react';
2
- import TIM, { Conversation, Message } from 'tim-js-sdk';
2
+ import TencentCloudChat, { Conversation, Message } from '@tencentcloud/chat';
3
3
  import { MESSAGE_OPERATE } from '../../../constants';
4
4
  import {
5
5
  useTUIChatActionContext, useTUIChatStateContext, useTUIKitContext,
@@ -12,7 +12,7 @@ export function useHandleForwardMessage(msg?:Message) {
12
12
 
13
13
  const [conversationList, setConversationList] = useState([]);
14
14
  const { sendMessage, createForwardMessage } = useTUIChatActionContext('useHandleForwardMessage');
15
- const { tim } = useTUIKitContext('TUIChat');
15
+ const { chat } = useTUIKitContext('TUIChat');
16
16
 
17
17
  const message = msg || operateData[MESSAGE_OPERATE.FORWARD];
18
18
 
@@ -26,12 +26,12 @@ export function useHandleForwardMessage(msg?:Message) {
26
26
 
27
27
  useEffect(() => {
28
28
  (async () => {
29
- const res = await tim.getConversationList();
29
+ const res = await chat.getConversationList();
30
30
  setConversationList(res?.data?.conversationList.filter(
31
- (item) => item.type !== TIM.TYPES.CONV_SYSTEM,
31
+ (item) => item.type !== TencentCloudChat.TYPES.CONV_SYSTEM,
32
32
  ));
33
33
  })();
34
- }, [tim]);
34
+ }, [chat]);
35
35
 
36
36
  return {
37
37
  message,
@@ -1,25 +1,25 @@
1
1
  import { useEffect, useState } from 'react';
2
- import TIM, { Message } from 'tim-js-sdk';
2
+ import TencentCloudChat, { Message } from '@tencentcloud/chat';
3
3
  import { MESSAGE_OPERATE } from '../../../constants';
4
4
  import { useTUIChatStateContext } from '../../../context';
5
5
 
6
6
  const quoteConfigType = {
7
- [TIM.TYPES.MSG_TEXT]: 1,
8
- [TIM.TYPES.MSG_CUSTOM]: 2,
9
- [TIM.TYPES.MSG_IMAGE]: 3,
10
- [TIM.TYPES.MSG_AUDIO]: 4,
11
- [TIM.TYPES.MSG_VIDEO]: 5,
12
- [TIM.TYPES.MSG_FILE]: 6,
13
- [TIM.TYPES.MSG_FACE]: 8,
7
+ [TencentCloudChat.TYPES.MSG_TEXT]: 1,
8
+ [TencentCloudChat.TYPES.MSG_CUSTOM]: 2,
9
+ [TencentCloudChat.TYPES.MSG_IMAGE]: 3,
10
+ [TencentCloudChat.TYPES.MSG_AUDIO]: 4,
11
+ [TencentCloudChat.TYPES.MSG_VIDEO]: 5,
12
+ [TencentCloudChat.TYPES.MSG_FILE]: 6,
13
+ [TencentCloudChat.TYPES.MSG_FACE]: 8,
14
14
  };
15
15
 
16
16
  const quoteConfigForShow = {
17
- [TIM.TYPES.MSG_CUSTOM]: '[custom]',
18
- [TIM.TYPES.MSG_IMAGE]: '[image]',
19
- [TIM.TYPES.MSG_AUDIO]: '[audio]',
20
- [TIM.TYPES.MSG_VIDEO]: '[video]',
21
- [TIM.TYPES.MSG_FILE]: '[file]',
22
- [TIM.TYPES.MSG_FACE]: '[face]',
17
+ [TencentCloudChat.TYPES.MSG_CUSTOM]: '[custom]',
18
+ [TencentCloudChat.TYPES.MSG_IMAGE]: '[image]',
19
+ [TencentCloudChat.TYPES.MSG_AUDIO]: '[audio]',
20
+ [TencentCloudChat.TYPES.MSG_VIDEO]: '[video]',
21
+ [TencentCloudChat.TYPES.MSG_FILE]: '[file]',
22
+ [TencentCloudChat.TYPES.MSG_FACE]: '[face]',
23
23
  };
24
24
 
25
25
  export function useHandleQuoteMessage(msg?:Message) {
@@ -31,7 +31,7 @@ export function useHandleQuoteMessage(msg?:Message) {
31
31
 
32
32
  const handleQuoteMessage = (message: Message) => {
33
33
  const messageType = quoteConfigType[message?.type];
34
- const messageAbstract = message?.type === TIM.TYPES.MSG_TEXT
34
+ const messageAbstract = message?.type === TencentCloudChat.TYPES.MSG_TEXT
35
35
  ? message?.payload?.text
36
36
  : quoteConfigForShow[message?.type];
37
37
 
@@ -28,7 +28,7 @@ export const useMessageInputText = (props:useMessageInputTextProps) => {
28
28
  sendUploadMessage,
29
29
  } = props;
30
30
 
31
- const { tim } = useTUIKitContext('useMessageInputText');
31
+ const { chat } = useTUIKitContext('useMessageInputText');
32
32
  const { sendMessage, createTextMessage, operateMessage } = useTUIChatActionContext('TUIMessageInput');
33
33
 
34
34
  const { cloudCustomData } = useHandleQuoteMessage();
@@ -46,7 +46,7 @@ export const useMessageInputText = (props:useMessageInputTextProps) => {
46
46
  getNewText: (text:string) => event.target.value,
47
47
  });
48
48
  },
49
- [tim],
49
+ [chat],
50
50
  );
51
51
 
52
52
  const handleSubmit = async (
@@ -16,7 +16,7 @@ export function useUploadPicker<T extends IbaseStateProps>(props:PropsWithChildr
16
16
  createImageMessage,
17
17
  createVideoMessage,
18
18
  createFileMessage,
19
- updataUploadPenddingMessageList,
19
+ updateUploadPendingMessageList,
20
20
  } = useTUIChatActionContext('useUploadPicker');
21
21
 
22
22
  const creatUploadMessage = {
@@ -30,7 +30,7 @@ export function useUploadPicker<T extends IbaseStateProps>(props:PropsWithChildr
30
30
  payload: file,
31
31
  onProgress(num:number) {
32
32
  message.progress = num;
33
- updataUploadPenddingMessageList(message);
33
+ updateUploadPendingMessageList(message);
34
34
  },
35
35
  });
36
36
  sendMessage(message);
@@ -1,5 +1,5 @@
1
1
  import React, { PropsWithChildren, useState, useEffect } from 'react';
2
- import { Message } from 'tim-js-sdk';
2
+ import { Message } from '@tencentcloud/chat';
3
3
  import {
4
4
  useTUIChatStateContext,
5
5
  useTUIChatActionContext,
@@ -88,7 +88,7 @@ function TUIMessageListWithContext <T extends MessageListProps>(
88
88
  if (!element) {
89
89
  return;
90
90
  }
91
- const { children } = element.children[1];
91
+ const { children } = element;
92
92
  children[children.length - 1].classList.add('high-lighted');
93
93
  element?.scrollIntoView({ block: 'center' });
94
94
  const timer = setTimeout(() => {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Message } from 'tim-js-sdk';
2
+ import { Message } from '@tencentcloud/chat';
3
3
 
4
4
  interface EnrichedMessageListProps {
5
5
  messageList: Array<Message>;
@@ -1,7 +1,7 @@
1
1
  import React, {
2
2
  PropsWithChildren, useMemo,
3
3
  } from 'react';
4
- import { Message } from 'tim-js-sdk';
4
+ import { Message } from '@tencentcloud/chat';
5
5
  import { UnknowPorps } from '../../../context';
6
6
  import { TUIMessageProps } from '../../TUIMessage/TUIMessage';
7
7
  import { getTimeStamp } from '../../untils';
@@ -22,21 +22,18 @@ function useMessageListElement <T extends MessageListElementProps>(
22
22
  } = props;
23
23
 
24
24
  return useMemo(() => enrichedMessageList?.map((item: Message, index:number) => {
25
- const key = `${JSON.stringify(item)}${index}`;
25
+ const key = `${item.ID}-${index}`;
26
26
  const preMessageTImer = index > 0 ? enrichedMessageList[index - 1]?.time : -1;
27
27
  const currrentTimer = item?.time || 0;
28
- const isShowIntervalsTImer = preMessageTImer !== -1
28
+ const isShowIntervalsTimer = preMessageTImer !== -1
29
29
  ? (currrentTimer - preMessageTImer) >= intervalsTimer : false;
30
30
  return (
31
- <>
31
+ <li className="message-list-item" key={key}>
32
32
  {
33
- isShowIntervalsTImer && <div className="message-list-time" key={`${currrentTimer + index}`}>{currrentTimer ? getTimeStamp(currrentTimer * 1000) : 0}</div>
34
- }
35
- <li className="message-list-item" key={key}>
36
- <TUIMessage message={item} key={key} />
37
- </li>
38
-
39
- </>
33
+ isShowIntervalsTimer && <div className="message-list-time" key={`${currrentTimer + index}`}>{currrentTimer ? getTimeStamp(currrentTimer * 1000) : 0}</div>
34
+ }
35
+ <TUIMessage message={item} />
36
+ </li>
40
37
  );
41
38
  }), [enrichedMessageList]);
42
39
  }
@@ -1,6 +1,6 @@
1
1
  import React, { PropsWithChildren, useState } from 'react';
2
2
  import DatePicker from 'react-date-picker';
3
- import TIM, { Profile } from 'tim-js-sdk';
3
+ import TencentCloudChat, { Profile } from '@tencentcloud/chat';
4
4
 
5
5
  import { useTUIKitContext } from '../../context';
6
6
 
@@ -11,9 +11,9 @@ import { handleDisplayAvatar } from '../untils';
11
11
  import { ProfileParams } from './hooks';
12
12
 
13
13
  const gender = {
14
- [TIM.TYPES.GENDER_UNKNOWN]: 'unknow',
15
- [TIM.TYPES.GENDER_MALE]: 'male',
16
- [TIM.TYPES.GENDER_FEMALE]: 'female',
14
+ [TencentCloudChat.TYPES.GENDER_UNKNOWN]: 'unknow',
15
+ [TencentCloudChat.TYPES.GENDER_MALE]: 'male',
16
+ [TencentCloudChat.TYPES.GENDER_FEMALE]: 'female',
17
17
  };
18
18
 
19
19
  const avatarList = [
@@ -28,11 +28,11 @@ const avatarList = [
28
28
  const genderList = [
29
29
  {
30
30
  label: 'Male',
31
- value: TIM.TYPES.GENDER_MALE,
31
+ value: TencentCloudChat.TYPES.GENDER_MALE,
32
32
  },
33
33
  {
34
34
  label: 'Female',
35
- value: TIM.TYPES.GENDER_FEMALE,
35
+ value: TencentCloudChat.TYPES.GENDER_FEMALE,
36
36
  },
37
37
  ];
38
38
 
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useEffect, useState } from 'react';
2
- import TIM from 'tim-js-sdk';
2
+ import TencentCloudChat from '@tencentcloud/chat';
3
3
  import { useTUIKitContext } from '../../../context';
4
4
 
5
5
  export interface ProfileParams {
@@ -20,19 +20,19 @@ export interface ProfileParams {
20
20
 
21
21
  export function useMyProfile() {
22
22
  const [myProfile, setMyPofile] = useState(null);
23
- const { tim, myProfile: contextProfile } = useTUIKitContext('useMyProfile');
23
+ const { chat, myProfile: contextProfile } = useTUIKitContext('useMyProfile');
24
24
 
25
25
  const getMyProfile = useCallback(async () => {
26
26
  if (contextProfile) {
27
27
  setMyPofile(contextProfile);
28
28
  } else {
29
- const res = await tim?.getMyProfile();
29
+ const res = await chat?.getMyProfile();
30
30
  setMyPofile(res?.data);
31
31
  }
32
- }, [tim]);
32
+ }, [chat]);
33
33
 
34
34
  const updateMyProfile = useCallback(async (options) => {
35
- const res = await tim?.updateMyProfile(options);
35
+ const res = await chat?.updateMyProfile(options);
36
36
  const userInfo = { ...myProfile };
37
37
  const keys = Object.keys(res.data);
38
38
  keys.map((name) => {
@@ -41,7 +41,7 @@ export function useMyProfile() {
41
41
  });
42
42
  setMyPofile(userInfo);
43
43
  return res;
44
- }, [tim]);
44
+ }, [chat]);
45
45
 
46
46
  const onProfileUpdated = (event) => {
47
47
  console.log('onProfileUpdated', event.data); // 包含 Profile 对象的数组
@@ -51,11 +51,11 @@ export function useMyProfile() {
51
51
  (async () => {
52
52
  await getMyProfile();
53
53
  })();
54
- tim?.on(TIM.EVENT.PROFILE_UPDATED, onProfileUpdated);
54
+ chat?.on(TencentCloudChat.EVENT.PROFILE_UPDATED, onProfileUpdated);
55
55
  return () => {
56
- tim?.off(TIM.EVENT.PROFILE_UPDATED, onProfileUpdated);
56
+ chat?.off(TencentCloudChat.EVENT.PROFILE_UPDATED, onProfileUpdated);
57
57
  };
58
- }, [tim]);
58
+ }, [chat]);
59
59
 
60
60
  return {
61
61
  myProfile,
@@ -6,7 +6,7 @@ import {
6
6
  isToday,
7
7
  isYesterday,
8
8
  } from 'date-fns';
9
- import TIM from 'tim-js-sdk';
9
+ import TencentCloudChat from '@tencentcloud/chat';
10
10
  import { defaultGroupAvatarWork, defaultUserAvatar } from './Avatar';
11
11
 
12
12
  // Determine if it is a JSON string
@@ -33,14 +33,14 @@ export function JSONStringToParse(str: string) {
33
33
  return JSON.parse(str);
34
34
  }
35
35
 
36
- export const handleDisplayAvatar = (avatar: string, type:string = TIM.TYPES.CONV_C2C) => {
36
+ export const handleDisplayAvatar = (avatar: string, type:string = TencentCloudChat.TYPES.CONV_C2C) => {
37
37
  let displayImage = avatar;
38
38
  if (!avatar) {
39
39
  switch (type) {
40
- case TIM.TYPES.CONV_C2C:
40
+ case TencentCloudChat.TYPES.CONV_C2C:
41
41
  displayImage = defaultUserAvatar;
42
42
  break;
43
- case TIM.TYPES.CONV_GROUP:
43
+ case TencentCloudChat.TYPES.CONV_GROUP:
44
44
  displayImage = defaultGroupAvatarWork;
45
45
  break;
46
46
  default:
package/src/constants.ts CHANGED
@@ -44,7 +44,7 @@ export enum CONSTANT_DISPATCH_TYPE {
44
44
  SET_CURSOR_POS = 'setCursorPos',
45
45
  SET_AUDIO_SOURCE = 'setAudioSource',
46
46
  SET_VIDEO_SOURCE = 'setVideoSource',
47
- UPDATE_UPLOAD_PENDDING_MESSAGE_LIST = 'updateUploadPenddingMessageList'
47
+ UPDATE_UPLOAD_PENDING_MESSAGE_LIST = 'updateUploadPendingMessageList'
48
48
  }
49
49
 
50
50
  export enum MESSAGE_TYPE {
@@ -1,5 +1,5 @@
1
1
  import React, { PropsWithChildren, useContext } from 'react';
2
- import { Message } from 'tim-js-sdk';
2
+ import { Message } from '@tencentcloud/chat';
3
3
  import type {
4
4
  CreateCustomMessageProps,
5
5
  CreateFaceMessageProps,
@@ -27,14 +27,14 @@ export interface TUIChatActionContextValue {
27
27
  createTextAtMessage?: (options: CreateTextAtMessageProps) => Message,
28
28
  createLocationMessage?: (options: CreateLocationMessageProps) => Message,
29
29
  createMergerMessage?: (options: CreateMergerMessageProps) => Message,
30
- editLocalmessage?: (message: Message) => void,
30
+ editLocalMessage?: (message: Message) => void,
31
31
  operateMessage?: (data?: OperateMessageParams) => void,
32
32
  loadMore?: () => Promise<void>,
33
33
  revokeMessage?: (message:Message) => Promise<Message>,
34
34
  setAudioSource?: (source: HTMLAudioElement | null) => void,
35
35
  setVideoSource?: (source: HTMLVideoElement | null) => void,
36
36
  setHighlightedMessageId?: (highlightedMessageId: string) => void,
37
- updataUploadPenddingMessageList?: (message?:Message) => void,
37
+ updateUploadPendingMessageList?: (message?:Message) => void,
38
38
  }
39
39
 
40
40
  export const TUIChatActionContext = React.createContext<
@@ -1,7 +1,7 @@
1
1
  import React, {
2
2
  PropsWithChildren, useContext, MutableRefObject, RefObject,
3
3
  } from 'react';
4
- import { Conversation, Message } from 'tim-js-sdk';
4
+ import { Conversation, Message } from '@tencentcloud/chat';
5
5
  import { MessageListProps, TUIMessageInputBasicProps, TUIMessageProps } from '../components';
6
6
  import { OperateMessageParams } from '../components/TUIChat/hooks/useHandleMessage';
7
7
 
@@ -24,7 +24,7 @@ export interface TUIChatStateContextValue {
24
24
  audioSource?: HTMLAudioElement,
25
25
  vidoeSource?: HTMLVideoElement,
26
26
  TUIMessageListConfig?: MessageListProps,
27
- uploadPenddingMessageList?: Array<Message>,
27
+ uploadPendingMessageList?: Array<Message>,
28
28
  }
29
29
 
30
30
  export const TUIChatStateContext = React.createContext<TUIChatStateContextValue>(null);
@@ -1,5 +1,5 @@
1
1
  import React, { useContext } from 'react';
2
- import { Conversation } from 'tim-js-sdk';
2
+ import { Conversation } from '@tencentcloud/chat';
3
3
  import { TUIConversationList } from '../components';
4
4
 
5
5
  export interface TUIConversationContextValue {
@@ -3,10 +3,10 @@ import {
3
3
  ChatSDK,
4
4
  Conversation,
5
5
  Profile,
6
- } from 'tim-js-sdk';
6
+ } from '@tencentcloud/chat';
7
7
 
8
8
  export interface TUIKitContextValue {
9
- tim: ChatSDK,
9
+ chat: ChatSDK,
10
10
  conversation?: Conversation,
11
11
  setActiveConversation: (conversation?: Conversation) => void,
12
12
  customClasses?: unknown,
@@ -1,5 +1,5 @@
1
1
  import React, { PropsWithChildren, ReactEventHandler, useContext } from 'react';
2
- import { Message } from 'tim-js-sdk';
2
+ import { Message } from '@tencentcloud/chat';
3
3
  import { MessagePluginsProps } from '../components';
4
4
 
5
5
  export enum messageShowType {
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
- import TIM from 'tim-js-sdk';
2
+ import TencentCloudChat from '@tencentcloud/chat';
3
3
  import { useTUIConversationContext } from '../context/TUIConversationContext';
4
4
 
5
5
  export interface CreateGroupConversationParams {
6
6
  name: string;
7
- type?: TIM.TYPES;
7
+ type?: TencentCloudChat.TYPES;
8
8
  groupID?: string;
9
9
  introduction?: string;
10
10
  notification?: string;
@@ -15,7 +15,7 @@ export interface CreateGroupConversationParams {
15
15
  groupCustomField?: Array<object>;
16
16
  isSupportTopic?: boolean;
17
17
  }
18
- export const useConversation = (tim) => {
18
+ export const useConversation = (chat) => {
19
19
  const {
20
20
  createConversation: contextCreateConversation,
21
21
  deleteConversation: contextDeleteConversation,
@@ -25,7 +25,7 @@ export const useConversation = (tim) => {
25
25
  ) => {
26
26
  // create c2c conversation
27
27
  if (typeof params === 'string') {
28
- const { data } = await tim.getConversationProfile(params);
28
+ const { data } = await chat.getConversationProfile(params);
29
29
  return data.conversation;
30
30
  }
31
31
  // create group conversation
@@ -42,7 +42,7 @@ export const useConversation = (tim) => {
42
42
  groupCustomField = [],
43
43
  isSupportTopic,
44
44
  } = params;
45
- const res = await tim.createGroup({
45
+ const res = await chat.createGroup({
46
46
  name,
47
47
  type,
48
48
  groupID,
@@ -56,20 +56,20 @@ export const useConversation = (tim) => {
56
56
  isSupportTopic,
57
57
  });
58
58
  const { groupID: createdGroupId } = res.data.group;
59
- if (type === TIM.TYPES.GRP_AVCHATROOM) {
60
- await tim.joinGroup({
59
+ if (type === TencentCloudChat.TYPES.GRP_AVCHATROOM) {
60
+ await chat.joinGroup({
61
61
  groupID: createdGroupId,
62
- type: TIM.TYPES.GRP_AVCHATROOM,
62
+ type: TencentCloudChat.TYPES.GRP_AVCHATROOM,
63
63
  });
64
64
  }
65
- const { data } = await tim.getConversationProfile(`GROUP${createdGroupId}`);
65
+ const { data } = await chat.getConversationProfile(`GROUP${createdGroupId}`);
66
66
  return data.conversation;
67
67
  };
68
68
  const pinConversation = (options: {
69
69
  conversationID: string;
70
70
  isPinned: boolean;
71
- }) => tim.pinConversation(options);
72
- const deleteConversation = (conversationID: string) => tim.deleteConversation(conversationID);
71
+ }) => chat.pinConversation(options);
72
+ const deleteConversation = (conversationID: string) => chat.deleteConversation(conversationID);
73
73
  return {
74
74
  createConversation: contextCreateConversation || createConversation,
75
75
  pinConversation,
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
 
3
- export const useProfile = (tim) => {
4
- const getUserProfile = (userIDList) => tim.getUserProfile({ userIDList });
3
+ export const useProfile = (chat) => {
4
+ const getUserProfile = (userIDList) => chat.getUserProfile({ userIDList });
5
5
  return {
6
6
  getUserProfile,
7
7
  };
package/readme.zh_cn.md DELETED
@@ -1,60 +0,0 @@
1
- _[English](README.md) | 简体中文_
2
- # [chat-uikit-react](https://www.tencentcloud.com/document/product/1047/34279/)
3
- >Chat UIKit 是基于腾讯云 IM SDK 的一款 UI 组件库,它提供了一些通用的 UI 组件,包含会话、聊天、关系链、群组、音视频通话等功能。
4
- 基于 UI 组件您可以像搭积木一样快速搭建起自己的业务逻辑。
5
- Chat UIKit 中的组件在实现 UI 功能的同时,会调用 IM SDK 相应的接口实现 IM 相关逻辑和数据的处理,因而开发者在使用 Chat UIKit 时只需关注自身业务或个性化扩展即可。
6
-
7
- ## Demos
8
- 我们已经构建了用于展示聊天功能的实例演示程序,您可以在我们的网站上预览这些
9
-
10
- | | sample-chat | live-chat |
11
- | ------ | ------ | ------ |
12
- | | ![img.png](https://web.sdk.qcloud.com/im/demo/TUIkit/react-static/images/home.png) | ![img.png](https://web.sdk.qcloud.com/im/demo/TUIkit/react-static/images/live-demo.png) |
13
- | demo 在线体验地址 | [sample-chat](https://web.sdk.qcloud.com/im/demo/intl/index.html) | [live-chat](https://web.sdk.qcloud.com/im/demo/intl/index.html?scene=live) |
14
- | 源码地址 | [sample-chat-code](https://github.com/TencentCloud/chat-uikit-react/tree/main/examples/sample-chat) | [live-chat-code](https://github.com/TencentCloud/chat-uikit-react/tree/main/examples/live-chat) |
15
-
16
- 您可以通过 [demos](https://web.sdk.qcloud.com/im/demo/intl/index.html) 体验效果, 并可以通过 [open source code](https://github.com/TencentCloud/chat-uikit-react) 获取源码
17
-
18
-
19
- ## Running Demo
20
-
21
- ### 步骤一:下载源码
22
- ```
23
- # Run the code in CLI
24
- $ git clone https://github.com/TencentCloud/chat-uikit-react
25
- # Go to the project
26
- $ cd chat-uikit-react
27
- # Install dependencies of the demo
28
- $ npm install && cd examples/sample-chat && npm install
29
- ```
30
- ### 步骤二:配置 demo
31
- 1. 打开`examples/sample-chat`项目,通过路径`./examples/sample-chat/src/debug/GenerateTestUserSig.js`找到`GenerateTestUserSig.js`文件。
32
- 2. 在`GenerateTestUserSig.js`文件中设置 `SDKAPPID` 和 `SECRETKEY` ,其值可以在[IM控制台](https://console.tencentcloud.com/im)中获取。 点击目标应用卡片,进入其配置页面。
33
- ![](https://qcloudimg.tencent-cloud.cn/raw/8d469e975f1ca5a2f3dbc9c6fe8774f5.png)
34
- 3. 在 **Basic Information** 区域,点击 **Display key**,将密钥信息复制并保存到 GenerateTestUserSig 文件中。
35
- >!
36
- >- 本文提到的生成 UserSig 的方案是在客户端代码中配置 SECRETKEY,该方法中 SECRETKEY 很容易被反编译逆向破解,一旦您的密钥泄露,攻击者就可以盗用您的腾讯云流量,因此**该方法仅适合本地跑通 Demo 和功能调试。**
37
- >- 正确的 UserSig 签发方式是将 UserSig 的计算代码集成到您的服务端,并提供面向 App 的接口,在需要 UserSig 时由您的 App 向业务服务器发起请求获取动态 UserSig。更多详情请参见 [服务端生成 UserSig](https://www.tencentcloud.com/document/product/1047/34385)。
38
-
39
- ### 步骤三:启动项目
40
- ```
41
- # Launch the project
42
- $ cd examples/sample-chat
43
- $ npm run start
44
- ```
45
-
46
- ### 步骤四:发送您的第一条消息
47
- 1. 项目启动成功后,点击“+”图标,进行创建会话。
48
- 2. 在输入框中搜索另一个用户的 userID。
49
- 3. 点击用户头像发起会话。
50
- 4. 在输入框输入消息,按下"enter"键发送。
51
- ![](https://web.sdk.qcloud.com/im/demo/TUIkit/react-static/images/chat.gif)
52
-
53
-
54
- ### Quick links
55
- - [Web demo](https://web.sdk.qcloud.com/im/demo/intl/index.html)
56
- - [Client APIs](https://www.tencentcloud.com/document/product/1047/33999)
57
- - [Free demo download](https://www.tencentcloud.com/document/product/1047/34279)
58
- - [FAQs](https://www.tencentcloud.com/document/product/1047/34455)
59
- - [Source code in GitHub](https://github.com/TencentCloud/chat-uikit-react)
60
- - [Generating UserSig](https://www.tencentcloud.com/document/product/1047/34385)
@@ -1 +0,0 @@
1
- export default TIM;
@@ -1,3 +0,0 @@
1
- import TIM from 'tim-js-sdk/tim-js-friendship';
2
-
3
- export default TIM;