@tencentcloud/chat-uikit-react 2.2.5 → 2.2.7

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 (405) hide show
  1. package/.eslintrc.js +16 -12
  2. package/.lintstagedrc.json +1 -1
  3. package/CHANGELOG.md +18 -0
  4. package/dist/cjs/assets/fonts/iconfont.ttf +0 -0
  5. package/dist/cjs/assets/fonts/iconfont.woff +0 -0
  6. package/dist/cjs/assets/fonts/iconfont.woff2 +0 -0
  7. package/dist/cjs/components/Avatar/Avatar.d.ts +4 -4
  8. package/dist/cjs/components/Checkbox/index.d.ts +2 -2
  9. package/dist/cjs/components/ConversationCreate/ConversationCreatGroupDetail.js +1 -1
  10. package/dist/cjs/components/ConversationCreate/ConversationCreate.js +1 -1
  11. package/dist/cjs/components/ConversationCreate/ConversationCreateUserSelectList.js +1 -1
  12. package/dist/cjs/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
  13. package/dist/cjs/components/ConversationPreview/ConversationListContainer.d.ts +2 -2
  14. package/dist/cjs/components/ConversationPreview/ConversationPreview.d.ts +8 -8
  15. package/dist/cjs/components/ConversationPreview/ConversationPreview.js +1 -1
  16. package/dist/cjs/components/ConversationPreview/ConversationPreviewContent.d.ts +2 -2
  17. package/dist/cjs/components/ConversationPreview/ConversationPreviewContent.js +1 -1
  18. package/dist/cjs/components/ConversationPreview/utils.js +1 -1
  19. package/dist/cjs/components/ConversationSearch/ConversationSearchResult.d.ts +3 -3
  20. package/dist/cjs/components/ConversationSearch/ConversationSearchResult.js +1 -1
  21. package/dist/cjs/components/Icon/Icon.d.ts +3 -3
  22. package/dist/cjs/components/Icon/config.js +1 -1
  23. package/dist/cjs/components/Icon/images/video-call.svg.js +1 -0
  24. package/dist/cjs/components/Icon/images/voice-call.svg.js +1 -0
  25. package/dist/cjs/components/Icon/type.d.ts +3 -1
  26. package/dist/cjs/components/Icon/type.js +1 -1
  27. package/dist/cjs/components/InfiniteScrollPaginator/InfiniteScroll.d.ts +4 -4
  28. package/dist/cjs/components/Input/Input.d.ts +4 -4
  29. package/dist/cjs/components/Model/index.d.ts +2 -2
  30. package/dist/cjs/components/Plugins/index.d.ts +4 -4
  31. package/dist/cjs/components/Popup/index.d.ts +2 -2
  32. package/dist/cjs/components/Switch/Switch.d.ts +2 -2
  33. package/dist/cjs/components/TUIChat/TUIChat.d.ts +15 -14
  34. package/dist/cjs/components/TUIChat/TUIChat.js +1 -1
  35. package/dist/cjs/components/TUIChat/TUIChatState.js +1 -1
  36. package/dist/cjs/components/TUIChat/index.js +1 -0
  37. package/dist/cjs/components/TUIChat/server.js +1 -0
  38. package/dist/cjs/components/TUIChat/utils.js +1 -0
  39. package/dist/cjs/components/TUIChatHeader/TUIChatHeader.d.ts +6 -5
  40. package/dist/cjs/components/TUIChatHeader/TUIChatHeader.js +1 -1
  41. package/dist/cjs/components/TUIChatHeader/TUIChatHeaderDefault.d.ts +6 -5
  42. package/dist/cjs/components/TUIChatHeader/TUIChatHeaderDefault.js +1 -1
  43. package/dist/cjs/components/TUIContact/TUIContact.d.ts +3 -3
  44. package/dist/cjs/components/TUIContact/TUIContact.js +1 -1
  45. package/dist/cjs/components/TUIContact/TUIContactInfo/TUIContactInfo.d.ts +3 -3
  46. package/dist/cjs/components/TUIContact/TUIContactInfo/TUIContactInfo.js +1 -1
  47. package/dist/cjs/components/TUIContact/TUIContactInfo/basicInfo.js +1 -1
  48. package/dist/cjs/components/TUIContact/TUIContactInfo/blockInfo.js +1 -1
  49. package/dist/cjs/components/TUIContact/TUIContactInfo/friendApplication.js +1 -1
  50. package/dist/cjs/components/TUIContact/TUIContactInfo/friendInfo.js +1 -1
  51. package/dist/cjs/components/TUIContact/TUIContactInfo/groupInfo.js +1 -1
  52. package/dist/cjs/components/TUIContact/TUIContactInfo/hooks/useContactInfo.js +1 -1
  53. package/dist/cjs/components/TUIContact/TUIContactList/TUIContactList.d.ts +3 -3
  54. package/dist/cjs/components/TUIContact/TUIContactList/TUIContactList.js +1 -1
  55. package/dist/cjs/components/TUIContact/hooks/useTUIContact.js +1 -1
  56. package/dist/cjs/components/TUIContactSearch/TUIContactSearch.js +1 -1
  57. package/dist/cjs/components/TUIContactSearch/hooks/useContactSearch.js +1 -1
  58. package/dist/cjs/components/TUIConversation/TUIConversation.d.ts +2 -2
  59. package/dist/cjs/components/TUIConversationList/TUIConversationList.d.ts +6 -6
  60. package/dist/cjs/components/TUIConversationList/TUIConversationList.js +1 -1
  61. package/dist/cjs/components/TUIConversationList/hooks/useConversationUpdate.js +1 -1
  62. package/dist/cjs/components/TUIManage/TUIManage.d.ts +2 -2
  63. package/dist/cjs/components/TUIManage/TUIManage.js +1 -1
  64. package/dist/cjs/components/TUIMessage/MessageAudio.js +1 -1
  65. package/dist/cjs/components/TUIMessage/MessageAvatar.js +1 -1
  66. package/dist/cjs/components/TUIMessage/MessageBubble.js +1 -1
  67. package/dist/cjs/components/TUIMessage/MessageContext.d.ts +2 -2
  68. package/dist/cjs/components/TUIMessage/MessageContext.js +1 -1
  69. package/dist/cjs/components/TUIMessage/MessageCustom.js +1 -1
  70. package/dist/cjs/components/TUIMessage/MessageName.js +1 -1
  71. package/dist/cjs/components/TUIMessage/MessagePlugins.d.ts +4 -4
  72. package/dist/cjs/components/TUIMessage/MessagePlugins.js +1 -1
  73. package/dist/cjs/components/TUIMessage/MessageProgress.js +1 -1
  74. package/dist/cjs/components/TUIMessage/MessageRevoke.js +1 -1
  75. package/dist/cjs/components/TUIMessage/MessageStatus.js +1 -1
  76. package/dist/cjs/components/TUIMessage/MessageSystem.js +1 -1
  77. package/dist/cjs/components/TUIMessage/MessageText.js +1 -1
  78. package/dist/cjs/components/TUIMessage/MessageTip.js +1 -1
  79. package/dist/cjs/components/TUIMessage/TUIMessage.d.ts +19 -19
  80. package/dist/cjs/components/TUIMessage/TUIMessage.js +1 -1
  81. package/dist/cjs/components/TUIMessage/TUIMessageDefault.js +1 -1
  82. package/dist/cjs/components/TUIMessage/hooks/useMessageHandler.js +1 -1
  83. package/dist/cjs/components/TUIMessage/hooks/useMessageReply.js +1 -1
  84. package/dist/cjs/components/TUIMessage/utils/index.js +1 -1
  85. package/dist/cjs/components/TUIMessageInput/InputPluginsDefalut.d.ts +2 -2
  86. package/dist/cjs/components/TUIMessageInput/InputPluginsDefalut.js +1 -1
  87. package/dist/cjs/components/TUIMessageInput/InputQuoteDefalut.js +1 -1
  88. package/dist/cjs/components/TUIMessageInput/TUIForward.js +1 -1
  89. package/dist/cjs/components/TUIMessageInput/TUIMessageInput.d.ts +7 -7
  90. package/dist/cjs/components/TUIMessageInput/TUIMessageInput.js +1 -1
  91. package/dist/cjs/components/TUIMessageInput/TUIMessageInputDefault.d.ts +2 -2
  92. package/dist/cjs/components/TUIMessageInput/TUIMessageInputDefault.js +1 -1
  93. package/dist/cjs/components/TUIMessageInput/hooks/useHandleForwardMessage.js +1 -1
  94. package/dist/cjs/components/TUIMessageInput/hooks/useHandleQuoteMessage.js +1 -1
  95. package/dist/cjs/components/TUIMessageInput/hooks/useMessageInputText.js +1 -1
  96. package/dist/cjs/components/TUIMessageInput/hooks/useUploadPicker.js +1 -1
  97. package/dist/cjs/components/TUIMessageList/TUIMessageList.d.ts +2 -2
  98. package/dist/cjs/components/TUIMessageList/TUIMessageList.js +1 -1
  99. package/dist/cjs/components/TUIMessageList/hooks/useMessageListElement.js +1 -1
  100. package/dist/cjs/components/TUIProfile/TUIProfile.d.ts +3 -3
  101. package/dist/cjs/components/TUIProfile/TUIProfile.js +1 -1
  102. package/dist/cjs/components/TUIProfile/TUIProfileDefault.d.ts +2 -2
  103. package/dist/cjs/components/TUIProfile/TUIProfileDefault.js +1 -1
  104. package/dist/cjs/components/Toast/index.d.ts +2 -2
  105. package/dist/cjs/components/{untils.js → utils.js} +1 -1
  106. package/dist/cjs/context/ComponentContext.d.ts +12 -12
  107. package/dist/cjs/context/LanguageContext.js +1 -0
  108. package/dist/cjs/context/TUIChatActionContext.d.ts +5 -4
  109. package/dist/cjs/context/TUIChatStateContext.d.ts +5 -5
  110. package/dist/cjs/context/TUIContactContext.d.ts +4 -4
  111. package/dist/cjs/context/TUIConversationContext.js +1 -1
  112. package/dist/cjs/context/TUIMessageContext.d.ts +17 -17
  113. package/dist/cjs/context/TUIMessageInputContext.d.ts +4 -4
  114. package/dist/cjs/context/ThemeContext.js +1 -0
  115. package/dist/cjs/context/UIKitContext.d.ts +25 -0
  116. package/dist/cjs/context/UIKitContext.js +1 -0
  117. package/dist/cjs/context/UIManagerContext.d.ts +46 -0
  118. package/dist/cjs/context/UIManagerContext.js +1 -0
  119. package/dist/cjs/hooks/useConversation.d.ts +2 -2
  120. package/dist/cjs/index.css +1 -2
  121. package/dist/cjs/index.d.css +1345 -1547
  122. package/dist/cjs/index.d.ts +2 -4
  123. package/dist/cjs/index.js +1 -1
  124. package/dist/cjs/locales/en-US/index.js +1 -1
  125. package/dist/cjs/locales/index.js +1 -1
  126. package/dist/cjs/locales/zh-CN/index.js +1 -1
  127. package/dist/cjs/locales/zh-TW/TUIChat.js +1 -0
  128. package/dist/cjs/locales/zh-TW/TUIContact.js +1 -0
  129. package/dist/cjs/locales/zh-TW/TUIConversation.js +1 -0
  130. package/dist/cjs/locales/zh-TW/TUIProfile.js +1 -0
  131. package/dist/cjs/locales/zh-TW/index.js +1 -0
  132. package/dist/esm/assets/fonts/iconfont.ttf +0 -0
  133. package/dist/esm/assets/fonts/iconfont.woff +0 -0
  134. package/dist/esm/assets/fonts/iconfont.woff2 +0 -0
  135. package/dist/esm/components/Avatar/Avatar.d.ts +4 -4
  136. package/dist/esm/components/Checkbox/index.d.ts +2 -2
  137. package/dist/esm/components/ConversationCreate/ConversationCreatGroupDetail.js +1 -1
  138. package/dist/esm/components/ConversationCreate/ConversationCreate.js +1 -1
  139. package/dist/esm/components/ConversationCreate/ConversationCreateUserSelectList.js +1 -1
  140. package/dist/esm/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
  141. package/dist/esm/components/ConversationPreview/ConversationListContainer.d.ts +2 -2
  142. package/dist/esm/components/ConversationPreview/ConversationPreview.d.ts +8 -8
  143. package/dist/esm/components/ConversationPreview/ConversationPreview.js +1 -1
  144. package/dist/esm/components/ConversationPreview/ConversationPreviewContent.d.ts +2 -2
  145. package/dist/esm/components/ConversationPreview/ConversationPreviewContent.js +1 -1
  146. package/dist/esm/components/ConversationPreview/utils.js +1 -1
  147. package/dist/esm/components/ConversationSearch/ConversationSearchResult.d.ts +3 -3
  148. package/dist/esm/components/ConversationSearch/ConversationSearchResult.js +1 -1
  149. package/dist/esm/components/Icon/Icon.d.ts +3 -3
  150. package/dist/esm/components/Icon/config.js +1 -1
  151. package/dist/esm/components/Icon/images/video-call.svg.js +1 -0
  152. package/dist/esm/components/Icon/images/voice-call.svg.js +1 -0
  153. package/dist/esm/components/Icon/type.d.ts +3 -1
  154. package/dist/esm/components/Icon/type.js +1 -1
  155. package/dist/esm/components/InfiniteScrollPaginator/InfiniteScroll.d.ts +4 -4
  156. package/dist/esm/components/Input/Input.d.ts +4 -4
  157. package/dist/esm/components/Model/index.d.ts +2 -2
  158. package/dist/esm/components/Plugins/index.d.ts +4 -4
  159. package/dist/esm/components/Popup/index.d.ts +2 -2
  160. package/dist/esm/components/Switch/Switch.d.ts +2 -2
  161. package/dist/esm/components/TUIChat/TUIChat.d.ts +15 -14
  162. package/dist/esm/components/TUIChat/TUIChat.js +1 -1
  163. package/dist/esm/components/TUIChat/TUIChatState.js +1 -1
  164. package/dist/esm/components/TUIChat/index.js +1 -0
  165. package/dist/esm/components/TUIChat/server.js +1 -0
  166. package/dist/esm/components/TUIChat/utils.js +1 -0
  167. package/dist/esm/components/TUIChatHeader/TUIChatHeader.d.ts +6 -5
  168. package/dist/esm/components/TUIChatHeader/TUIChatHeader.js +1 -1
  169. package/dist/esm/components/TUIChatHeader/TUIChatHeaderDefault.d.ts +6 -5
  170. package/dist/esm/components/TUIChatHeader/TUIChatHeaderDefault.js +1 -1
  171. package/dist/esm/components/TUIContact/TUIContact.d.ts +3 -3
  172. package/dist/esm/components/TUIContact/TUIContact.js +1 -1
  173. package/dist/esm/components/TUIContact/TUIContactInfo/TUIContactInfo.d.ts +3 -3
  174. package/dist/esm/components/TUIContact/TUIContactInfo/TUIContactInfo.js +1 -1
  175. package/dist/esm/components/TUIContact/TUIContactInfo/basicInfo.js +1 -1
  176. package/dist/esm/components/TUIContact/TUIContactInfo/blockInfo.js +1 -1
  177. package/dist/esm/components/TUIContact/TUIContactInfo/friendApplication.js +1 -1
  178. package/dist/esm/components/TUIContact/TUIContactInfo/friendInfo.js +1 -1
  179. package/dist/esm/components/TUIContact/TUIContactInfo/groupInfo.js +1 -1
  180. package/dist/esm/components/TUIContact/TUIContactInfo/hooks/useContactInfo.js +1 -1
  181. package/dist/esm/components/TUIContact/TUIContactList/TUIContactList.d.ts +3 -3
  182. package/dist/esm/components/TUIContact/TUIContactList/TUIContactList.js +1 -1
  183. package/dist/esm/components/TUIContact/hooks/useTUIContact.js +1 -1
  184. package/dist/esm/components/TUIContactSearch/TUIContactSearch.js +1 -1
  185. package/dist/esm/components/TUIContactSearch/hooks/useContactSearch.js +1 -1
  186. package/dist/esm/components/TUIConversation/TUIConversation.d.ts +2 -2
  187. package/dist/esm/components/TUIConversationList/TUIConversationList.d.ts +6 -6
  188. package/dist/esm/components/TUIConversationList/TUIConversationList.js +1 -1
  189. package/dist/esm/components/TUIConversationList/hooks/useConversationUpdate.js +1 -1
  190. package/dist/esm/components/TUIManage/TUIManage.d.ts +2 -2
  191. package/dist/esm/components/TUIManage/TUIManage.js +1 -1
  192. package/dist/esm/components/TUIMessage/MessageAudio.js +1 -1
  193. package/dist/esm/components/TUIMessage/MessageAvatar.js +1 -1
  194. package/dist/esm/components/TUIMessage/MessageBubble.js +1 -1
  195. package/dist/esm/components/TUIMessage/MessageContext.d.ts +2 -2
  196. package/dist/esm/components/TUIMessage/MessageContext.js +1 -1
  197. package/dist/esm/components/TUIMessage/MessageCustom.js +1 -1
  198. package/dist/esm/components/TUIMessage/MessageName.js +1 -1
  199. package/dist/esm/components/TUIMessage/MessagePlugins.d.ts +4 -4
  200. package/dist/esm/components/TUIMessage/MessagePlugins.js +1 -1
  201. package/dist/esm/components/TUIMessage/MessageProgress.js +1 -1
  202. package/dist/esm/components/TUIMessage/MessageRevoke.js +1 -1
  203. package/dist/esm/components/TUIMessage/MessageStatus.js +1 -1
  204. package/dist/esm/components/TUIMessage/MessageSystem.js +1 -1
  205. package/dist/esm/components/TUIMessage/MessageText.js +1 -1
  206. package/dist/esm/components/TUIMessage/MessageTip.js +1 -1
  207. package/dist/esm/components/TUIMessage/TUIMessage.d.ts +19 -19
  208. package/dist/esm/components/TUIMessage/TUIMessage.js +1 -1
  209. package/dist/esm/components/TUIMessage/TUIMessageDefault.js +1 -1
  210. package/dist/esm/components/TUIMessage/hooks/useMessageHandler.js +1 -1
  211. package/dist/esm/components/TUIMessage/hooks/useMessageReply.js +1 -1
  212. package/dist/esm/components/TUIMessage/utils/index.js +1 -1
  213. package/dist/esm/components/TUIMessageInput/InputPluginsDefalut.d.ts +2 -2
  214. package/dist/esm/components/TUIMessageInput/InputPluginsDefalut.js +1 -1
  215. package/dist/esm/components/TUIMessageInput/InputQuoteDefalut.js +1 -1
  216. package/dist/esm/components/TUIMessageInput/TUIForward.js +1 -1
  217. package/dist/esm/components/TUIMessageInput/TUIMessageInput.d.ts +7 -7
  218. package/dist/esm/components/TUIMessageInput/TUIMessageInput.js +1 -1
  219. package/dist/esm/components/TUIMessageInput/TUIMessageInputDefault.d.ts +2 -2
  220. package/dist/esm/components/TUIMessageInput/TUIMessageInputDefault.js +1 -1
  221. package/dist/esm/components/TUIMessageInput/hooks/useHandleForwardMessage.js +1 -1
  222. package/dist/esm/components/TUIMessageInput/hooks/useHandleQuoteMessage.js +1 -1
  223. package/dist/esm/components/TUIMessageInput/hooks/useMessageInputText.js +1 -1
  224. package/dist/esm/components/TUIMessageInput/hooks/useUploadPicker.js +1 -1
  225. package/dist/esm/components/TUIMessageList/TUIMessageList.d.ts +2 -2
  226. package/dist/esm/components/TUIMessageList/TUIMessageList.js +1 -1
  227. package/dist/esm/components/TUIMessageList/hooks/useMessageListElement.js +1 -1
  228. package/dist/esm/components/TUIProfile/TUIProfile.d.ts +3 -3
  229. package/dist/esm/components/TUIProfile/TUIProfile.js +1 -1
  230. package/dist/esm/components/TUIProfile/TUIProfileDefault.d.ts +2 -2
  231. package/dist/esm/components/TUIProfile/TUIProfileDefault.js +1 -1
  232. package/dist/esm/components/Toast/index.d.ts +2 -2
  233. package/dist/esm/components/utils.js +1 -0
  234. package/dist/esm/context/ComponentContext.d.ts +12 -12
  235. package/dist/esm/context/LanguageContext.js +1 -0
  236. package/dist/esm/context/TUIChatActionContext.d.ts +5 -4
  237. package/dist/esm/context/TUIChatStateContext.d.ts +5 -5
  238. package/dist/esm/context/TUIContactContext.d.ts +4 -4
  239. package/dist/esm/context/TUIConversationContext.js +1 -1
  240. package/dist/esm/context/TUIMessageContext.d.ts +17 -17
  241. package/dist/esm/context/TUIMessageInputContext.d.ts +4 -4
  242. package/dist/esm/context/ThemeContext.js +1 -0
  243. package/dist/esm/context/UIKitContext.d.ts +25 -0
  244. package/dist/esm/context/UIKitContext.js +1 -0
  245. package/dist/esm/context/UIManagerContext.d.ts +46 -0
  246. package/dist/esm/context/UIManagerContext.js +1 -0
  247. package/dist/esm/hooks/useConversation.d.ts +2 -2
  248. package/dist/esm/index.css +1 -2
  249. package/dist/esm/index.d.css +1345 -1547
  250. package/dist/esm/index.d.ts +2 -4
  251. package/dist/esm/index.js +1 -1
  252. package/dist/esm/locales/en-US/index.js +1 -1
  253. package/dist/esm/locales/index.js +1 -1
  254. package/dist/esm/locales/zh-CN/index.js +1 -1
  255. package/dist/esm/locales/zh-TW/TUIChat.js +1 -0
  256. package/dist/esm/locales/zh-TW/TUIContact.js +1 -0
  257. package/dist/esm/locales/zh-TW/TUIConversation.js +1 -0
  258. package/dist/esm/locales/zh-TW/TUIProfile.js +1 -0
  259. package/dist/esm/locales/zh-TW/index.js +1 -0
  260. package/package.json +5 -3
  261. package/rollup.config.js +1 -1
  262. package/src/assets/fonts/iconfont.ttf +0 -0
  263. package/src/assets/fonts/iconfont.woff +0 -0
  264. package/src/assets/fonts/iconfont.woff2 +0 -0
  265. package/src/components/Avatar/styles/index.scss +11 -4
  266. package/src/components/Checkbox/styles/color.scss +17 -6
  267. package/src/components/ConversationCreate/ConversationCreatGroupDetail.tsx +4 -4
  268. package/src/components/ConversationCreate/ConversationCreate.tsx +2 -2
  269. package/src/components/ConversationCreate/ConversationCreateUserSelectList.tsx +3 -2
  270. package/src/components/ConversationCreate/hooks/useConversationCreate.tsx +5 -5
  271. package/src/components/ConversationCreate/styles/ConversationCreatGroupDetail.scss +7 -16
  272. package/src/components/ConversationCreate/styles/conversationCreateSelectView.scss +13 -8
  273. package/src/components/ConversationCreate/styles/conversationGroupTypeInfo.scss +20 -21
  274. package/src/components/ConversationCreate/styles/index.scss +30 -17
  275. package/src/components/ConversationPreview/ConversationPreview.tsx +21 -21
  276. package/src/components/ConversationPreview/ConversationPreviewContent.tsx +4 -2
  277. package/src/components/ConversationPreview/styles/index.scss +20 -20
  278. package/src/components/ConversationPreview/utils.tsx +3 -2
  279. package/src/components/DivWithEdit/styles/index.scss +30 -10
  280. package/src/components/Icon/config.ts +14 -4
  281. package/src/components/Icon/images/video-call.svg +3 -0
  282. package/src/components/Icon/images/voice-call.svg +3 -0
  283. package/src/components/Icon/type.ts +2 -0
  284. package/src/components/Input/styles/index.scss +22 -6
  285. package/src/components/Plugins/styles/color.scss +3 -11
  286. package/src/components/Profile/styles/index.scss +12 -3
  287. package/src/components/TUIChat/TUIChat.tsx +40 -35
  288. package/src/components/TUIChat/TUIChatState.tsx +41 -41
  289. package/src/components/TUIChat/index.ts +3 -0
  290. package/src/components/TUIChat/server.ts +44 -0
  291. package/src/components/TUIChat/styles/layout.scss +7 -2
  292. package/src/components/TUIChat/utils.ts +72 -0
  293. package/src/components/TUIChatHeader/TUIChatHeader.tsx +10 -7
  294. package/src/components/TUIChatHeader/TUIChatHeaderDefault.tsx +74 -31
  295. package/src/components/TUIChatHeader/styles/layout.scss +16 -9
  296. package/src/components/TUIContact/TUIContact.tsx +2 -2
  297. package/src/components/TUIContact/TUIContactInfo/TUIContactInfo.tsx +2 -2
  298. package/src/components/TUIContact/TUIContactInfo/basicInfo.tsx +2 -2
  299. package/src/components/TUIContact/TUIContactInfo/blockInfo.tsx +2 -2
  300. package/src/components/TUIContact/TUIContactInfo/friendApplication.tsx +2 -2
  301. package/src/components/TUIContact/TUIContactInfo/friendInfo.tsx +4 -3
  302. package/src/components/TUIContact/TUIContactInfo/groupInfo.tsx +3 -3
  303. package/src/components/TUIContact/TUIContactInfo/hooks/useContactInfo.tsx +2 -2
  304. package/src/components/TUIContact/TUIContactInfo/index.scss +44 -21
  305. package/src/components/TUIContact/TUIContactList/TUIContactList.tsx +80 -76
  306. package/src/components/TUIContact/TUIContactList/index.scss +40 -20
  307. package/src/components/TUIContact/hooks/useTUIContact.tsx +5 -5
  308. package/src/components/TUIContact/index.scss +30 -11
  309. package/src/components/TUIContactSearch/TUIContactSearch.tsx +2 -2
  310. package/src/components/TUIContactSearch/hooks/useContactSearch.tsx +2 -2
  311. package/src/components/TUIContactSearch/index.scss +12 -3
  312. package/src/components/TUIConversationList/TUIConversationList.tsx +3 -4
  313. package/src/components/TUIConversationList/hooks/useConversationUpdate.tsx +2 -2
  314. package/src/components/TUIConversationList/index.scss +3 -4
  315. package/src/components/TUIManage/TUIManage.tsx +3 -3
  316. package/src/components/TUIManage/styles/index.scss +20 -14
  317. package/src/components/TUIMessage/MessageAvatar.tsx +7 -7
  318. package/src/components/TUIMessage/MessageBubble.tsx +22 -21
  319. package/src/components/TUIMessage/MessageCustom.tsx +26 -5
  320. package/src/components/TUIMessage/MessageStatus.tsx +7 -7
  321. package/src/components/TUIMessage/MessageText.tsx +16 -15
  322. package/src/components/TUIMessage/hooks/useMessageHandler.ts +8 -8
  323. package/src/components/TUIMessage/hooks/useMessageReply.ts +8 -7
  324. package/src/components/TUIMessage/styles/color.scss +6 -5
  325. package/src/components/TUIMessage/styles/layout.scss +111 -42
  326. package/src/components/TUIMessage/utils/index.ts +23 -12
  327. package/src/components/TUIMessageInput/InputPluginsDefalut.tsx +12 -12
  328. package/src/components/TUIMessageInput/TUIMessageInput.tsx +1 -1
  329. package/src/components/TUIMessageInput/hooks/useHandleForwardMessage.tsx +7 -6
  330. package/src/components/TUIMessageInput/hooks/useMessageInputText.tsx +14 -14
  331. package/src/components/TUIMessageInput/hooks/useUploadPicker.tsx +4 -4
  332. package/src/components/TUIMessageInput/styles/color.scss +15 -11
  333. package/src/components/TUIMessageInput/styles/layout.scss +33 -17
  334. package/src/components/TUIMessageList/hooks/useMessageListElement.tsx +15 -11
  335. package/src/components/TUIMessageList/styles/layout.scss +16 -9
  336. package/src/components/TUIProfile/TUIProfile.tsx +3 -3
  337. package/src/components/TUIProfile/TUIProfileDefault.tsx +14 -13
  338. package/src/components/TUIProfile/styles/color.scss +6 -5
  339. package/src/components/TUIProfile/styles/layout.scss +16 -14
  340. package/src/components/index.ts +0 -1
  341. package/src/components/{untils.ts → utils.ts} +5 -4
  342. package/src/context/LanguageContext.tsx +60 -0
  343. package/src/context/TUIChatActionContext.tsx +14 -13
  344. package/src/context/ThemeContext.tsx +68 -0
  345. package/src/context/UIKitContext.tsx +76 -0
  346. package/src/context/UIManagerContext.tsx +163 -0
  347. package/src/context/index.ts +3 -2
  348. package/src/locales/en-US/index.ts +0 -3
  349. package/src/locales/index.ts +6 -2
  350. package/src/locales/zh-CN/index.ts +0 -2
  351. package/src/locales/zh-TW/TUIChat.ts +27 -0
  352. package/src/locales/zh-TW/TUIContact.ts +29 -0
  353. package/src/locales/zh-TW/TUIConversation.ts +32 -0
  354. package/src/locales/zh-TW/TUIProfile.ts +15 -0
  355. package/src/locales/zh-TW/index.ts +11 -0
  356. package/src/styles/colors/_color-dark.scss +31 -21
  357. package/src/styles/colors/_color-light.scss +31 -21
  358. package/src/styles/colors/_color-theme.scss +33 -22
  359. package/src/styles/normalize.scss +6 -0
  360. package/dist/cjs/components/Icon/images/chats-selected.svg.js +0 -1
  361. package/dist/cjs/components/Icon/images/chats.svg.js +0 -1
  362. package/dist/cjs/components/Icon/images/contacts-selected.svg.js +0 -1
  363. package/dist/cjs/components/Icon/images/contacts.svg.js +0 -1
  364. package/dist/cjs/components/Icon/images/down-arrow.png.js +0 -1
  365. package/dist/cjs/components/Icon/images/right-arrow.svg.js +0 -1
  366. package/dist/cjs/components/TUIChat/unitls.js +0 -1
  367. package/dist/cjs/components/TUIKit/TUIKit.d.ts +0 -12
  368. package/dist/cjs/components/TUIKit/TUIKit.js +0 -1
  369. package/dist/cjs/components/TUIKit/hooks/useCreateTUIKitContext.d.ts +0 -21
  370. package/dist/cjs/components/TUIKit/hooks/useCreateTUIKitContext.js +0 -1
  371. package/dist/cjs/components/TUIKit/hooks/useTUIKit.d.ts +0 -43
  372. package/dist/cjs/components/TUIKit/hooks/useTUIKit.js +0 -1
  373. package/dist/cjs/context/TUIKitContext.d.ts +0 -25
  374. package/dist/cjs/context/TUIKitContext.js +0 -1
  375. package/dist/esm/components/Icon/images/chats-selected.svg.js +0 -1
  376. package/dist/esm/components/Icon/images/chats.svg.js +0 -1
  377. package/dist/esm/components/Icon/images/contacts-selected.svg.js +0 -1
  378. package/dist/esm/components/Icon/images/contacts.svg.js +0 -1
  379. package/dist/esm/components/Icon/images/down-arrow.png.js +0 -1
  380. package/dist/esm/components/Icon/images/right-arrow.svg.js +0 -1
  381. package/dist/esm/components/TUIChat/unitls.js +0 -1
  382. package/dist/esm/components/TUIKit/TUIKit.d.ts +0 -12
  383. package/dist/esm/components/TUIKit/TUIKit.js +0 -1
  384. package/dist/esm/components/TUIKit/hooks/useCreateTUIKitContext.d.ts +0 -21
  385. package/dist/esm/components/TUIKit/hooks/useCreateTUIKitContext.js +0 -1
  386. package/dist/esm/components/TUIKit/hooks/useTUIKit.d.ts +0 -43
  387. package/dist/esm/components/TUIKit/hooks/useTUIKit.js +0 -1
  388. package/dist/esm/components/untils.js +0 -1
  389. package/dist/esm/context/TUIKitContext.d.ts +0 -25
  390. package/dist/esm/context/TUIKitContext.js +0 -1
  391. package/scripts/publish-github.js +0 -60
  392. package/scripts/publish-intl-demo.js +0 -14
  393. package/scripts/publish-intl-experience-demo.js +0 -14
  394. package/src/components/TUIChat/unitls.ts +0 -39
  395. package/src/components/TUIKit/TUIKit.tsx +0 -229
  396. package/src/components/TUIKit/hooks/useCreateTUIKitContext.tsx +0 -48
  397. package/src/components/TUIKit/hooks/useTUIKit.tsx +0 -99
  398. package/src/components/TUIKit/index.ts +0 -3
  399. package/src/components/TUIKit/styles/h5.scss +0 -34
  400. package/src/components/TUIKit/styles/index.scss +0 -132
  401. package/src/context/TUIKitContext.tsx +0 -44
  402. package/src/locales/en-US/TUIGlobal.ts +0 -6
  403. package/src/locales/ja-JP/TUIGlobal.ts +0 -6
  404. package/src/locales/ko-KR/TUIGlobal.ts +0 -6
  405. package/src/locales/zh-CN/TUIGlobal.ts +0 -6
@@ -9,8 +9,8 @@ import TUIChatEngine, {
9
9
  TUIStore,
10
10
  StoreName,
11
11
  } from '@tencentcloud/chat-uikit-engine';
12
- import { JSONStringToParse } from '../untils';
13
- import { useTUIKitContext } from '../../context/TUIKitContext';
12
+ import { JSONStringToParse } from '../utils';
13
+ import { useUIKit, useUIManager } from '../../context';
14
14
  import { TUIChatStateContextProvider } from '../../context/TUIChatStateContext';
15
15
  import { TUIChatActionProvider } from '../../context/TUIChatActionContext';
16
16
  import { ComponentProvider, UnknowPorps } from '../../context/ComponentContext';
@@ -39,47 +39,49 @@ import { TUIMessageInput as TUIMessageInputElement, TUIMessageInputBasicProps }
39
39
  import { EmptyStateIndicator } from '../EmptyStateIndicator';
40
40
 
41
41
  interface TUIChatProps {
42
- className?: string,
43
- conversation?: Conversation,
44
- EmptyPlaceholder?: React.ReactElement,
45
- TUIMessage?: React.ComponentType<TUIMessageProps | UnknowPorps>,
46
- TUIChatHeader?: React.ComponentType<TUIChatHeaderDefaultProps>,
47
- MessageContext?: React.ComponentType<MessageContextProps>,
48
- TUIMessageInput?: React.ComponentType<UnknowPorps>,
49
- InputPlugins?: React.ComponentType<UnknowPorps>,
50
- InputQuote?: React.ComponentType<UnknowPorps>,
51
- MessagePlugins?: React.ComponentType<UnknowPorps>,
52
- MessageCustomPlugins?: React.ComponentType<UnknowPorps>,
53
- MessageTextPlugins?: React.ComponentType<UnknowPorps>,
42
+ className?: string;
43
+ conversation?: Conversation;
44
+ EmptyPlaceholder?: React.ReactElement;
45
+ TUIMessage?: React.ComponentType<TUIMessageProps | UnknowPorps>;
46
+ TUIChatHeader?: React.ComponentType<TUIChatHeaderDefaultProps>;
47
+ MessageContext?: React.ComponentType<MessageContextProps>;
48
+ TUIMessageInput?: React.ComponentType<UnknowPorps>;
49
+ InputPlugins?: React.ComponentType<UnknowPorps>;
50
+ InputQuote?: React.ComponentType<UnknowPorps>;
51
+ MessagePlugins?: React.ComponentType<UnknowPorps>;
52
+ MessageCustomPlugins?: React.ComponentType<UnknowPorps>;
53
+ MessageTextPlugins?: React.ComponentType<UnknowPorps>;
54
54
  onMessageRecevied?: (
55
- updateMessage: (event?: Array<Message>) => void,
55
+ updateMessage: (event?: Message[]) => void,
56
56
  event: any,
57
- ) => void,
58
- sendMessage?: (message:Message, options?:any) => Promise<Message>,
59
- revokeMessage?: (message:Message) => Promise<Message>,
60
- selectedConversation?: (conversation:Conversation) => Promise<Conversation>,
61
- filterMessage?: (messageList: Array<IMessageModel>) => Array<IMessageModel>,
62
- messageConfig?: TUIMessageProps,
63
- cloudCustomData?: string,
64
- TUIMessageInputConfig?: TUIMessageInputBasicProps,
65
- TUIMessageListConfig?: MessageListProps,
66
- [propName: string]: any,
57
+ ) => void;
58
+ sendMessage?: (message: Message, options?: any) => Promise<Message>;
59
+ revokeMessage?: (message: Message) => Promise<Message>;
60
+ selectedConversation?: (conversation: Conversation) => Promise<Conversation>;
61
+ filterMessage?: (messageList: IMessageModel[]) => IMessageModel[];
62
+ callButtonClicked?: (callMediaType?: number, callType?: any) => void;
63
+ messageConfig?: TUIMessageProps;
64
+ cloudCustomData?: string;
65
+ TUIMessageInputConfig?: TUIMessageInputBasicProps;
66
+ TUIMessageListConfig?: MessageListProps;
67
+ [propName: string]: any;
67
68
  }
68
69
 
69
70
  interface TUIChatInnerProps extends TUIChatProps {
70
- chat?: ChatSDK,
71
+ chat?: ChatSDK;
71
72
  key?: string;
72
73
  }
73
74
 
74
- function UnMemoizedTUIChat <T extends TUIChatProps>(
75
+ function UnMemoizedTUIChat<T extends TUIChatProps>(
75
76
  props: PropsWithChildren<T>,
76
- ):React.ReactElement {
77
+ ): React.ReactElement {
77
78
  const {
78
79
  conversation: propsConversation,
79
80
  EmptyPlaceholder = <EmptyStateIndicator listType="chat" />,
80
81
  } = props;
81
82
 
82
- const { conversation: contextConversation, chat } = useTUIKitContext('TUIChat');
83
+ const { chat } = useUIKit();
84
+ const { conversation: contextConversation } = useUIManager('TUIChat');
83
85
 
84
86
  const conversation = propsConversation || contextConversation;
85
87
 
@@ -95,9 +97,9 @@ function UnMemoizedTUIChat <T extends TUIChatProps>(
95
97
  );
96
98
  }
97
99
 
98
- function TUIChatInner <T extends TUIChatInnerProps>(
100
+ function TUIChatInner<T extends TUIChatInnerProps>(
99
101
  props: PropsWithChildren<T>,
100
- ):React.ReactElement {
102
+ ): React.ReactElement {
101
103
  const {
102
104
  chat,
103
105
  conversation,
@@ -121,6 +123,7 @@ function TUIChatInner <T extends TUIChatInnerProps>(
121
123
  cloudCustomData,
122
124
  TUIMessageInputConfig,
123
125
  TUIMessageListConfig,
126
+ callButtonClicked,
124
127
  } = props;
125
128
 
126
129
  const [state, dispatch] = useReducer<any>(chatReducer, {
@@ -162,7 +165,7 @@ function TUIChatInner <T extends TUIChatInnerProps>(
162
165
  setHighlightedMessageId,
163
166
  setActiveMessageID,
164
167
  } = useHandleMessage({
165
- // eslint-disable-next-line
168
+ // eslint-disable-next-line
166
169
  // @ts-ignore
167
170
  state,
168
171
  dispatch,
@@ -182,7 +185,7 @@ function TUIChatInner <T extends TUIChatInnerProps>(
182
185
  }, []);
183
186
 
184
187
  const onMessageListUpdated = (list: IMessageModel[]) => {
185
- const messageList = list.filter((message) => !message.isDeleted);
188
+ const messageList = list.filter(message => !message.isDeleted);
186
189
  // eslint-disable-next-line
187
190
  // @ts-ignore
188
191
  dispatch({
@@ -222,7 +225,7 @@ function TUIChatInner <T extends TUIChatInnerProps>(
222
225
  });
223
226
  }
224
227
  };
225
- // eslint-disable-next-line
228
+ // eslint-disable-next-line
226
229
  // @ts-ignore
227
230
  const chatActionContextValue: TUIChatActionContextValue = useMemo(
228
231
  () => ({
@@ -236,6 +239,7 @@ function TUIChatInner <T extends TUIChatInnerProps>(
236
239
  setActiveMessageID,
237
240
  updateUploadPendingMessageList,
238
241
  setFirstSendMessage,
242
+ callButtonClicked,
239
243
  }),
240
244
  [
241
245
  editLocalMessage,
@@ -248,6 +252,7 @@ function TUIChatInner <T extends TUIChatInnerProps>(
248
252
  setActiveMessageID,
249
253
  updateUploadPendingMessageList,
250
254
  setFirstSendMessage,
255
+ callButtonClicked,
251
256
  ],
252
257
  );
253
258
 
@@ -268,7 +273,7 @@ function TUIChatInner <T extends TUIChatInnerProps>(
268
273
 
269
274
  return (
270
275
  <div className={`chat ${className}`}>
271
- {/* // eslint-disable-next-line
276
+ {/* // eslint-disable-next-line
272
277
  // @ts-ignore */}
273
278
  <TUIChatStateContextProvider value={chatStateContextValue}>
274
279
  <TUIChatActionProvider value={chatActionContextValue}>
@@ -7,61 +7,61 @@ import { OperateMessageParams } from './hooks/useHandleMessage';
7
7
  import {
8
8
  handleEditMessage,
9
9
  handleUploadPendingMessage,
10
- } from './unitls';
10
+ } from './utils';
11
11
 
12
12
  export type ChatStateReducerAction =
13
13
  | {
14
- type: CONSTANT_DISPATCH_TYPE.SET_CONVERSATION_PRPFILE;
15
- value?: Conversation
16
- }
14
+ type: CONSTANT_DISPATCH_TYPE.SET_CONVERSATION_PRPFILE;
15
+ value?: Conversation;
16
+ }
17
17
  | {
18
- type: CONSTANT_DISPATCH_TYPE.SET_MESSAGELIST,
19
- value?: Array<IMessageModel>,
20
- }
18
+ type: CONSTANT_DISPATCH_TYPE.SET_MESSAGELIST;
19
+ value?: IMessageModel[];
20
+ }
21
21
  | {
22
- type: CONSTANT_DISPATCH_TYPE.SET_EDIT_MESSAGE,
23
- value?: Message,
24
- index?: number,
22
+ type: CONSTANT_DISPATCH_TYPE.SET_EDIT_MESSAGE;
23
+ value?: Message;
24
+ index?: number;
25
25
  }
26
26
  | {
27
- type: CONSTANT_DISPATCH_TYPE.SET_IS_COMPLETE,
28
- value?: boolean,
29
- }
27
+ type: CONSTANT_DISPATCH_TYPE.SET_IS_COMPLETE;
28
+ value?: boolean;
29
+ }
30
30
  | {
31
- type: CONSTANT_DISPATCH_TYPE.RESET;
32
- }
31
+ type: CONSTANT_DISPATCH_TYPE.RESET;
32
+ }
33
33
  | {
34
- type: CONSTANT_DISPATCH_TYPE.SET_HIGH_LIGHTED_MESSAGE_ID,
35
- value?: string,
36
- }
34
+ type: CONSTANT_DISPATCH_TYPE.SET_HIGH_LIGHTED_MESSAGE_ID;
35
+ value?: string;
36
+ }
37
37
  | {
38
- type: CONSTANT_DISPATCH_TYPE.OPERATE_MESSAGE,
39
- value?: OperateMessageParams,
40
- }
38
+ type: CONSTANT_DISPATCH_TYPE.OPERATE_MESSAGE;
39
+ value?: OperateMessageParams;
40
+ }
41
41
  | {
42
- type: CONSTANT_DISPATCH_TYPE.SET_NO_MORE,
43
- value?: boolean,
44
- }
42
+ type: CONSTANT_DISPATCH_TYPE.SET_NO_MORE;
43
+ value?: boolean;
44
+ }
45
45
  | {
46
- type: CONSTANT_DISPATCH_TYPE.SET_AUDIO_SOURCE,
47
- value?: HTMLAudioElement | null,
48
- }
46
+ type: CONSTANT_DISPATCH_TYPE.SET_AUDIO_SOURCE;
47
+ value?: HTMLAudioElement | null;
48
+ }
49
49
  | {
50
- type: CONSTANT_DISPATCH_TYPE.SET_VIDEO_SOURCE,
51
- value?: HTMLVideoElement | null,
52
- }
50
+ type: CONSTANT_DISPATCH_TYPE.SET_VIDEO_SOURCE;
51
+ value?: HTMLVideoElement | null;
52
+ }
53
53
  | {
54
- type: CONSTANT_DISPATCH_TYPE.UPDATE_UPLOAD_PENDING_MESSAGE_LIST,
55
- value?: Message,
56
- }
54
+ type: CONSTANT_DISPATCH_TYPE.UPDATE_UPLOAD_PENDING_MESSAGE_LIST;
55
+ value?: Message;
56
+ }
57
57
  | {
58
- type: CONSTANT_DISPATCH_TYPE.SET_FIRST_SEND_MESSAGE;
59
- value?: Message;
60
- }
58
+ type: CONSTANT_DISPATCH_TYPE.SET_FIRST_SEND_MESSAGE;
59
+ value?: Message;
60
+ }
61
61
  | {
62
- type: CONSTANT_DISPATCH_TYPE.SET_ACTIVE_MESSAGE_ID,
63
- value?: string,
64
- };
62
+ type: CONSTANT_DISPATCH_TYPE.SET_ACTIVE_MESSAGE_ID;
63
+ value?: string;
64
+ };
65
65
  export type ChatStateReducer = Reducer<TUIChatStateContextValue, ChatStateReducerAction>;
66
66
 
67
67
  export const chatReducer = (
@@ -78,7 +78,7 @@ export const chatReducer = (
78
78
  messageList: action.value,
79
79
  };
80
80
  case CONSTANT_DISPATCH_TYPE.SET_EDIT_MESSAGE:
81
- return state.messageList && action.value && {
81
+ return state.messageList && action.value && {
82
82
  ...state,
83
83
  messageList: [...handleEditMessage(state.messageList, action.value)],
84
84
  };
@@ -110,7 +110,7 @@ export const chatReducer = (
110
110
  }
111
111
  };
112
112
 
113
- export const initialState:TUIChatStateContextValue = {
113
+ export const initialState: TUIChatStateContextValue = {
114
114
  conversation: {} as Conversation,
115
115
  messageList: [],
116
116
  nextReqMessageID: '',
@@ -1,2 +1,5 @@
1
+ import Server from './server';
2
+
3
+ new Server();
1
4
  export * from './TUIChat';
2
5
  export * from './hooks/useCreateTUIChatStateContext';
@@ -0,0 +1,44 @@
1
+ import TUICore, { TUIConstants } from '@tencentcloud/tui-core';
2
+ import {
3
+ IMessageModel,
4
+ TUIStore,
5
+ StoreName,
6
+ TUIChatService,
7
+ } from '@tencentcloud/chat-uikit-engine';
8
+
9
+ export default class TUIChatServer {
10
+ public currentConversationID = '';
11
+ public currentMessageList: IMessageModel[] = [];
12
+
13
+ constructor() {
14
+ // register service
15
+ TUICore.registerService(TUIConstants.TUIChat.SERVICE.NAME, this);
16
+ // watch current conversationID
17
+ TUIStore.watch(StoreName.CONV, {
18
+ currentConversationID: (id: string) => {
19
+ this.currentConversationID = id;
20
+ },
21
+ });
22
+ }
23
+
24
+ public onCall(method: string, params: Record<string, any>, callback: void): any {
25
+ let message;
26
+ switch (method) {
27
+ case TUIConstants.TUIChat.SERVICE.METHOD.UPDATE_MESSAGE_LIST:
28
+ message = params.message;
29
+ // Two screen-up situations
30
+ // 1. If the call message conversationID is currentConversation,
31
+ // You need to use UPDATE_MESSAGE_LIST to update the messageList of TUIStore in the engine to display it on the screen
32
+ // (because you cannot get the messages you sent at this time)
33
+ // 2. If the call message conversationID is not currentConversation,
34
+ // The next time you switch to the conversation where the call message is located, getMessageList can get all the call messages you sent
35
+ // No need to process here
36
+ if (message?.conversationID === this.currentConversationID) {
37
+ TUIChatService.updateMessageList([message], 'push');
38
+ }
39
+ break;
40
+ default:
41
+ break;
42
+ }
43
+ }
44
+ }
@@ -1,3 +1,5 @@
1
+ @use "../../../styles/colors/color-theme" as *;
2
+
1
3
  .chat {
2
4
  flex: 1;
3
5
  width: 100%;
@@ -6,5 +8,8 @@
6
8
  display: flex;
7
9
  flex-direction: column;
8
10
  position: relative;
9
- background: #FFFFFF;
10
- }
11
+
12
+ @include theme() {
13
+ background-color: get(bg-color-operate);
14
+ }
15
+ }
@@ -0,0 +1,72 @@
1
+ import TencentCloudChat, { Message, Conversation } from '@tencentcloud/chat';
2
+ import TUICore, { TUIConstants } from '@tencentcloud/tui-core';
3
+ import TUIChatEngine from '@tencentcloud/chat-uikit-engine';
4
+ import { useTUIChatActionContext } from '../../context';
5
+ import constant from '../../constants';
6
+ import { JSONStringToParse } from '../utils';
7
+
8
+ export const handleMessage = (messageList: Message[]): Message[] => {
9
+ let customPayloadData: any = null;
10
+ return messageList.filter((item) => {
11
+ if (item.type === TencentCloudChat.TYPES.MSG_CUSTOM) {
12
+ customPayloadData = JSONStringToParse(item?.payload?.data);
13
+ }
14
+ if (customPayloadData && customPayloadData?.businessID === constant.TYPE_TYPING) {
15
+ return false;
16
+ }
17
+ return true;
18
+ });
19
+ };
20
+
21
+ export const handleEditMessage = (
22
+ messageList: Message[],
23
+ message: Message,
24
+ ) => {
25
+ const list = [...messageList];
26
+ const index = list.findIndex(item => item?.ID === message?.ID);
27
+ list[index] = message;
28
+ return list;
29
+ };
30
+
31
+ export const handleUploadPendingMessage = (
32
+ messageList: Message[],
33
+ message: Message,
34
+ ) => {
35
+ const list = [...messageList];
36
+ if (!list.some((item: Message) => item.ID === message?.ID)) {
37
+ list.push(message);
38
+ }
39
+ const index = list.findIndex(item => item?.ID === message?.ID);
40
+ list[index] = message;
41
+ return list;
42
+ };
43
+
44
+ interface IStartCallParams {
45
+ callType: any;
46
+ callMediaType: number;
47
+ userIDList: string[];
48
+ callButtonClicked?: (callMediaType?: number, callType?: any) => void;
49
+ }
50
+ export const startCall = (params: IStartCallParams) => {
51
+ const { callType, callMediaType, userIDList, callButtonClicked } = params;
52
+ if (callType === TUIChatEngine.TYPES.CONV_C2C) {
53
+ callButtonClicked && callButtonClicked(callMediaType, callType);
54
+ TUICore.callService({
55
+ serviceName: TUIConstants.TUICalling.SERVICE.NAME,
56
+ method: TUIConstants.TUICalling.SERVICE.METHOD.START_CALL,
57
+ params: {
58
+ userIDList,
59
+ type: callMediaType,
60
+ callParams: {
61
+ // doc: https://cloud.tencent.com/document/product/269/105713
62
+ offlinePushInfo: {
63
+ title: 'call',
64
+ description: 'you have a call',
65
+ androidSound: 'private_ring',
66
+ iOSSound: '01.caf',
67
+ },
68
+ },
69
+ },
70
+ });
71
+ }
72
+ };
@@ -8,29 +8,31 @@ import './styles/index.scss';
8
8
  import { useComponentContext } from '../../context';
9
9
 
10
10
  interface TUIChatHeaderProps {
11
- title?: string,
12
- TUIChatHeader?: React.ComponentType<TUIChatHeaderDefaultProps>,
13
- conversation?: Conversation,
14
- avatar?: React.ReactElement | string,
15
- headerOpateIcon?: React.ReactElement | string,
11
+ title?: string;
12
+ TUIChatHeader?: React.ComponentType<TUIChatHeaderDefaultProps>;
13
+ conversation?: Conversation;
14
+ avatar?: React.ReactElement | string;
15
+ headerOpateIcon?: React.ReactElement | string;
16
+ enableCall?: boolean;
16
17
  }
17
18
 
18
19
  function UnMemoizedTUIChatHeader<T extends TUIChatHeaderProps>(
19
20
  props: PropsWithChildren<T>,
20
- ):React.ReactElement {
21
+ ): React.ReactElement {
21
22
  const {
22
23
  title,
23
24
  conversation: propsConversation,
24
25
  TUIChatHeader: propTUIChatHeader,
25
26
  avatar,
26
27
  headerOpateIcon,
28
+ enableCall,
27
29
  } = props;
28
30
 
29
31
  const { conversation: contextConversation } = useTUIChatStateContext('TUIChatHeader');
30
32
  const { TUIChatHeader: ContextTUIChatHeader } = useComponentContext('TUIChatHeader');
31
33
 
32
34
  const TUIChatHeaderUIComponent = propTUIChatHeader
33
- || ContextTUIChatHeader || TUIChatHeaderDefault;
35
+ || ContextTUIChatHeader || TUIChatHeaderDefault;
34
36
  const conversation = propsConversation || contextConversation;
35
37
 
36
38
  return (
@@ -39,6 +41,7 @@ function UnMemoizedTUIChatHeader<T extends TUIChatHeaderProps>(
39
41
  conversation={conversation}
40
42
  avatar={avatar}
41
43
  opateIcon={headerOpateIcon}
44
+ enableCall={enableCall}
42
45
  />
43
46
  );
44
47
  }
@@ -1,29 +1,32 @@
1
1
  import React, { PropsWithChildren, useEffect, useState } from 'react';
2
+ import TUICore, { TUIConstants } from '@tencentcloud/tui-core';
2
3
  import TencentCloudChat, { Conversation, Group, Profile } from '@tencentcloud/chat';
3
4
  import { TUIConversationService } from '@tencentcloud/chat-uikit-engine';
4
5
  import { Avatar } from '../Avatar';
5
- import { handleDisplayAvatar } from '../untils';
6
+ import { handleDisplayAvatar } from '../utils';
6
7
  import { isH5 } from '../../utils/env';
7
8
  import './styles/index.scss';
8
9
  import { Icon, IconTypes } from '../Icon';
9
- import { useTUIKitContext } from '../../context';
10
+ import { useUIManager, useTUIChatActionContext } from '../../context';
11
+ import { startCall } from '../TUIChat/utils';
10
12
 
11
13
  export interface TUIChatHeaderDefaultProps {
12
- title?: string,
13
- avatar?: React.ReactElement | string,
14
- isOnline?: boolean,
15
- conversation?: Conversation,
16
- pluginComponentList?: Array<React.ComponentType>,
14
+ title?: string;
15
+ avatar?: React.ReactElement | string;
16
+ isOnline?: boolean;
17
+ conversation?: Conversation;
18
+ pluginComponentList?: React.ComponentType[];
19
+ enableCall?: boolean;
17
20
  }
18
21
 
19
22
  export interface TUIChatHeaderBasicProps extends TUIChatHeaderDefaultProps {
20
- isLive?: boolean,
21
- opateIcon?: React.ReactElement | string,
23
+ isLive?: boolean;
24
+ opateIcon?: React.ReactElement | string;
22
25
  }
23
26
 
24
- function TUIChatHeaderDefaultWithContext <T extends TUIChatHeaderBasicProps>(
27
+ function TUIChatHeaderDefaultWithContext<T extends TUIChatHeaderBasicProps>(
25
28
  props: PropsWithChildren<T>,
26
- ):React.ReactElement {
29
+ ): React.ReactElement {
27
30
  const {
28
31
  title: propTitle = '',
29
32
  avatar: propAvatar,
@@ -31,11 +34,13 @@ function TUIChatHeaderDefaultWithContext <T extends TUIChatHeaderBasicProps>(
31
34
  conversation,
32
35
  isLive,
33
36
  opateIcon,
37
+ enableCall: propCallEnabled = false,
34
38
  } = props;
35
- const { setActiveContact } = useTUIKitContext('TUIContact');
39
+ const { callButtonClicked } = useTUIChatActionContext('TUIChat');
40
+ const { setActiveContact } = useUIManager('TUIContact');
36
41
  const [title, setTitle] = useState(propTitle);
37
42
  const [avatar, setAvatar] = useState<React.ReactElement | string>('');
38
-
43
+ const [isShowCallIcon, setIsShowCallIcon] = useState<boolean>(false);
39
44
  useEffect(() => {
40
45
  setTitle(propTitle);
41
46
  if (propAvatar) {
@@ -44,6 +49,8 @@ function TUIChatHeaderDefaultWithContext <T extends TUIChatHeaderBasicProps>(
44
49
  switch (conversation?.type) {
45
50
  case TencentCloudChat.TYPES.CONV_C2C:
46
51
  handleC2C(conversation.userProfile, conversation?.remark);
52
+ const isCalling = TUICore.getService(TUIConstants.TUICalling.SERVICE.NAME) ? true : false;
53
+ setIsShowCallIcon(isCalling && propCallEnabled);
47
54
  break;
48
55
  case TencentCloudChat.TYPES.CONV_GROUP:
49
56
  handleGroup(conversation.groupProfile);
@@ -57,58 +64,95 @@ function TUIChatHeaderDefaultWithContext <T extends TUIChatHeaderBasicProps>(
57
64
  }
58
65
  }, [conversation]);
59
66
 
60
- const handleC2C = (userProfile: Profile, remark?: string) => {
67
+ function handleC2C(userProfile: Profile, remark?: string) {
61
68
  if (!title) {
62
69
  setTitle(remark || userProfile?.nick || userProfile?.userID);
63
70
  }
64
71
  if (!propAvatar) {
65
72
  setAvatar(<Avatar size={32} image={handleDisplayAvatar(userProfile.avatar)} />);
66
73
  }
67
- };
74
+ }
68
75
 
69
- const handleGroup = (groupProfile: Group) => {
76
+ function handleGroup(groupProfile: Group) {
70
77
  if (!title) {
71
78
  setTitle(groupProfile?.name || groupProfile?.groupID);
72
79
  }
73
80
  if (!propAvatar) {
74
- setAvatar(<Avatar
75
- size={32}
76
- image={handleDisplayAvatar(groupProfile.avatar, TencentCloudChat.TYPES.CONV_GROUP)}
77
- />);
81
+ setAvatar(
82
+ <Avatar
83
+ size={32}
84
+ image={handleDisplayAvatar(groupProfile.avatar, TencentCloudChat.TYPES.CONV_GROUP)}
85
+ />,
86
+ );
78
87
  }
79
- };
88
+ }
80
89
 
81
90
  const back = () => {
82
91
  TUIConversationService.switchConversation('');
83
92
  setActiveContact();
84
93
  };
85
- const { setTUIManageShow } = useTUIKitContext();
94
+ const { setTUIManageShow } = useUIManager();
86
95
  const openTUIManage = () => {
87
96
  setTUIManageShow && setTUIManageShow(true);
88
97
  };
89
-
98
+ const handleCall = (callMediaType: number) => {
99
+ const userID = conversation?.userProfile?.userID || '';
100
+ const callType = conversation?.type || TencentCloudChat.TYPES.CONV_C2C;
101
+ startCall({ callType, callMediaType, userIDList: [userID], callButtonClicked });
102
+ };
90
103
  return (
91
104
  <header
92
105
  className={`tui-chat-header ${isLive ? 'tui-chat-live-header' : ''}`}
93
106
  key={conversation?.conversationID}
94
107
  >
95
- {isH5 && (<div style={{ paddingRight: '10px' }}><Icon onClick={back} type={IconTypes.BACK} width={9} height={16} /></div>)}
108
+ {isH5 && (
109
+ <div style={{ paddingRight: '10px' }}>
110
+ <Icon onClick={back} type={IconTypes.BACK} width={9} height={16} />
111
+ </div>
112
+ )}
96
113
  <div
97
- className={`tui-chat-header-left ${conversation?.type === TencentCloudChat.TYPES.CONV_SYSTEM ? 'system' : ''}`}
114
+ className={`tui-chat-header-left ${
115
+ conversation?.type === TencentCloudChat.TYPES.CONV_SYSTEM
116
+ ? 'system'
117
+ : ''
118
+ }`}
98
119
  >
99
120
  {conversation?.type !== TencentCloudChat.TYPES.CONV_SYSTEM && avatar}
100
121
  </div>
101
122
  <div className="header-content">
102
123
  <h3 className="title">{title}</h3>
103
124
  </div>
125
+ {isShowCallIcon && (
126
+ <div className="call-btn-container">
127
+ <Icon
128
+ className="call-btn"
129
+ onClick={() =>
130
+ handleCall(2)}
131
+ type={IconTypes.VIDEOCALL}
132
+ width={24}
133
+ />
134
+ <Icon
135
+ className="call-btn"
136
+ onClick={() =>
137
+ handleCall(1)}
138
+ type={IconTypes.VOICECALL}
139
+ width={20}
140
+ />
141
+ </div>
142
+ )}
104
143
  <div className="tui-chat-header-right">
105
144
  <div className="header-handle">
106
- {
107
- opateIcon || <Icon className="header-handle-more" onClick={openTUIManage} type={IconTypes.ELLIPSE} width={18} height={5} />
108
- }
145
+ {opateIcon || (
146
+ <Icon
147
+ className="header-handle-more"
148
+ onClick={openTUIManage}
149
+ type={IconTypes.ELLIPSE}
150
+ width={18}
151
+ height={5}
152
+ />
153
+ )}
109
154
  </div>
110
155
  </div>
111
-
112
156
  </header>
113
157
  );
114
158
  }
@@ -116,8 +160,7 @@ function TUIChatHeaderDefaultWithContext <T extends TUIChatHeaderBasicProps>(
116
160
  const MemoizedTUIChatHeaderDefault = React.memo(TUIChatHeaderDefaultWithContext) as
117
161
  typeof TUIChatHeaderDefaultWithContext;
118
162
 
119
- export function TUIChatHeaderDefault(props: TUIChatHeaderBasicProps)
120
- :React.ReactElement {
163
+ export function TUIChatHeaderDefault(props: TUIChatHeaderBasicProps): React.ReactElement {
121
164
  const options = { ...props };
122
165
  return <MemoizedTUIChatHeaderDefault {...options} />;
123
166
  }