@tencentcloud/chat-uikit-react 2.1.3 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
  3. package/dist/cjs/components/ConversationPreview/ConversationPreviewContent.js +1 -1
  4. package/dist/cjs/components/TUIContact/TUIContactInfo/TUIContactInfo.d.ts +1 -1
  5. package/dist/cjs/components/TUIContact/TUIContactInfo/TUIContactInfo.js +1 -1
  6. package/dist/cjs/components/TUIContact/TUIContactInfo/friendInfo.js +1 -1
  7. package/dist/cjs/components/TUIContact/TUIContactInfo/groupInfo.js +1 -0
  8. package/dist/cjs/components/TUIContact/TUIContactList/TUIContactList.js +1 -1
  9. package/dist/cjs/components/TUIContact/hooks/useTUIContact.js +1 -1
  10. package/dist/cjs/components/TUIConversation/TUIConversation.js +1 -1
  11. package/dist/cjs/components/TUIConversationList/hooks/useConversationList.js +1 -1
  12. package/dist/cjs/components/TUIKit/TUIKit.js +1 -1
  13. package/dist/cjs/components/TUIKit/hooks/useTUIKit.d.ts +7 -2
  14. package/dist/cjs/components/TUIKit/hooks/useTUIKit.js +1 -1
  15. package/dist/cjs/components/TUIProfile/TUIProfile.js +1 -1
  16. package/dist/cjs/components/TUIProfile/TUIProfileDefault.d.ts +2 -2
  17. package/dist/cjs/components/TUIProfile/hooks/useMyProfile.js +1 -1
  18. package/dist/cjs/context/TUIConversationContext.js +1 -1
  19. package/dist/cjs/index.js +1 -1
  20. package/dist/cjs/locales/en/TUIContact.js +1 -1
  21. package/dist/cjs/locales/zh_cn/TUIContact.js +1 -1
  22. package/dist/esm/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
  23. package/dist/esm/components/ConversationPreview/ConversationPreviewContent.js +1 -1
  24. package/dist/esm/components/TUIContact/TUIContactInfo/TUIContactInfo.d.ts +1 -1
  25. package/dist/esm/components/TUIContact/TUIContactInfo/TUIContactInfo.js +1 -1
  26. package/dist/esm/components/TUIContact/TUIContactInfo/friendInfo.js +1 -1
  27. package/dist/esm/components/TUIContact/TUIContactInfo/groupInfo.js +1 -0
  28. package/dist/esm/components/TUIContact/TUIContactList/TUIContactList.js +1 -1
  29. package/dist/esm/components/TUIContact/hooks/useTUIContact.js +1 -1
  30. package/dist/esm/components/TUIConversation/TUIConversation.js +1 -1
  31. package/dist/esm/components/TUIConversationList/hooks/useConversationList.js +1 -1
  32. package/dist/esm/components/TUIKit/TUIKit.js +1 -1
  33. package/dist/esm/components/TUIKit/hooks/useTUIKit.d.ts +7 -2
  34. package/dist/esm/components/TUIKit/hooks/useTUIKit.js +1 -1
  35. package/dist/esm/components/TUIProfile/TUIProfile.js +1 -1
  36. package/dist/esm/components/TUIProfile/TUIProfileDefault.d.ts +2 -2
  37. package/dist/esm/components/TUIProfile/hooks/useMyProfile.js +1 -1
  38. package/dist/esm/context/TUIConversationContext.js +1 -1
  39. package/dist/esm/index.js +1 -1
  40. package/dist/esm/locales/en/TUIContact.js +1 -1
  41. package/dist/esm/locales/zh_cn/TUIContact.js +1 -1
  42. package/package.json +1 -1
  43. package/scripts/publish-intl-experience-demo.js +14 -0
  44. package/src/components/ConversationPreview/ConversationPreviewContent.tsx +1 -1
  45. package/src/components/Profile/index.ts +1 -2
  46. package/src/components/TUIContact/TUIContactInfo/TUIContactInfo.tsx +5 -3
  47. package/src/components/TUIContact/TUIContactInfo/friendInfo.tsx +10 -10
  48. package/src/components/TUIContact/TUIContactInfo/groupInfo.tsx +65 -0
  49. package/src/components/TUIContact/TUIContactList/TUIContactList.tsx +71 -65
  50. package/src/components/TUIContact/hooks/useTUIContact.tsx +14 -0
  51. package/src/components/TUIConversationList/hooks/useConversationList.tsx +19 -24
  52. package/src/components/TUIKit/TUIKit.tsx +33 -13
  53. package/src/components/TUIKit/hooks/useTUIKit.tsx +19 -9
  54. package/src/components/TUIProfile/TUIProfileDefault.tsx +2 -2
  55. package/src/components/TUIProfile/hooks/useMyProfile.tsx +18 -36
  56. package/src/locales/en/TUIContact.ts +1 -0
  57. package/src/locales/zh_cn/TUIContact.ts +1 -0
  58. package/dist/cjs/components/TUIProfile/hooks/useMyProfile.d.ts +0 -17
  59. package/dist/esm/components/TUIProfile/hooks/useMyProfile.d.ts +0 -17
  60. package/src/components/Profile/hooks/useProfile.tsx +0 -28
@@ -1 +1 @@
1
- import{__awaiter as n,__generator as t}from"tslib";import{useState as o,useEffect as e,useCallback as a}from"react";import{useTranslation as i}from"react-i18next";var r=function(r){var c=r.chat,s=r.activeConversation,v=r.language,u=i().i18n,l=o(s),f=l[0],g=l[1],d=o(),h=d[0],I=d[1],m=o(!1),w=m[0],D=m[1],p=o(!1),M=p[0],P=p[1],S=o(),T=S[0],U=S[1];e((function(){u.changeLanguage(v);n(void 0,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:return[4,null==c?void 0:c.getMyProfile()];case 1:return n=t.sent(),I(null==n?void 0:n.data),[2]}}))}))}),[c,v]);var C=a((function(n){n&&(null==c||c.setMessageRead({conversationID:n.conversationID})),f&&(null==n?void 0:n.conversationID)!==f.conversationID&&D(!1),n&&g(n)}),[c]);return e((function(){s&&g(s)}),[s]),{conversation:f,contactData:T,setActiveConversation:C,myProfile:h,TUIManageShow:w,setTUIManageShow:D,TUIProfileShow:M,setTUIProfileShow:P,setActiveContact:function(n){U(n)}}};export{r as useTUIKit};
1
+ import{useState as n,useEffect as t,useCallback as o}from"react";import{TUIStore as e,StoreName as a}from"@tencentcloud/chat-uikit-engine";import{useTranslation as i}from"react-i18next";var r=function(r){var c=r.chat,s=r.activeConversation,u=r.language,v=i().i18n,f=n(s),l=f[0],g=f[1],h=n(),I=h[0],m=h[1],w=n(!1),D=w[0],S=w[1],U=n(!1),p=U[0],P=U[1],T=n(),d=T[0],C=T[1];t((function(){v.changeLanguage(u),e.watch(a.USER,{userProfile:function(n){m(n)}})}),[u]);var M=o((function(n){n&&(null==c||c.setMessageRead({conversationID:n.conversationID})),l&&(null==n?void 0:n.conversationID)!==l.conversationID&&S(!1),g(n)}),[c]);return t((function(){s&&g(s)}),[s]),{conversation:l,contactData:d,setActiveConversation:M,myProfile:I,TUIManageShow:D,setTUIManageShow:S,TUIProfileShow:p,setTUIProfileShow:P,setActiveContact:function(n){C(n)}}};export{r as useTUIKit};
@@ -1 +1 @@
1
- import{jsxs as o,Fragment as r,jsx as e}from"react/jsx-runtime";import t from"react";import{Profile as i}from"../Profile/Profile.js";import"tslib";import{useMyProfile as f}from"./hooks/useMyProfile.js";import{TUIProfileDefault as m}from"./TUIProfileDefault.js";import{useTUIKitContext as l}from"../../context/TUIKitContext.js";import"../../context/TUIMessageContext.js";function s(t){var s=t.className,a=t.TUIProfile,n=f(),p=n.myProfile,P=n.updateMyProfile,c=l("TUIProfile"),u=c.setTUIProfileShow,I=c.TUIProfileShow,T=a||m;return o(r,{children:[e(i,{profile:p,handleAvatar:function(){u&&u(!0)}}),I&&e(T,{className:s,userInfo:p,update:P})]})}var a=t.memo(s);export{a as TUIProfile};
1
+ import{jsxs as o,Fragment as r,jsx as e}from"react/jsx-runtime";import t from"react";import{Profile as i}from"../Profile/Profile.js";import{useMyProfile as f}from"./hooks/useMyProfile.js";import{TUIProfileDefault as m}from"./TUIProfileDefault.js";import{useTUIKitContext as l}from"../../context/TUIKitContext.js";import"tslib";import"../../context/TUIMessageContext.js";function s(t){var s=t.className,a=t.TUIProfile,n=f(),p=n.myProfile,P=n.updateMyProfile,c=l("TUIProfile"),u=c.setTUIProfileShow,I=c.TUIProfileShow,T=a||m;return o(r,{children:[e(i,{profile:p,handleAvatar:function(){u&&u(!0)}}),I&&e(T,{className:s,userInfo:p,update:P})]})}var a=t.memo(s);export{a as TUIProfile};
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import { Profile } from '@tencentcloud/chat';
3
- import { ProfileParams } from './hooks/useMyProfile.js';
3
+ import { UpdateMyProfileParams } from '@tencentcloud/chat-uikit-engine';
4
4
 
5
5
  interface TUIProfileDefaultProps {
6
6
  userInfo?: Profile;
7
- update?: (option: ProfileParams) => void;
7
+ update?: (option: UpdateMyProfileParams) => void;
8
8
  className?: string;
9
9
  }
10
10
  declare function TUIProfileDefault(props: TUIProfileDefaultProps): React.ReactElement;
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as n,__assign as e}from"tslib";import{useState as r,useCallback as o,useEffect as i}from"react";import u from"@tencentcloud/chat";import{useTUIKitContext as c}from"../../../context/TUIKitContext.js";import"react/jsx-runtime";import"../../../context/TUIMessageContext.js";function a(){var a=this,l=r(),s=l[0],f=l[1],d=c("useMyProfile"),m=d.chat,v=d.myProfile,p=o((function(){return t(a,void 0,void 0,(function(){var t;return n(this,(function(n){switch(n.label){case 0:return v?(f(v),[3,3]):[3,1];case 1:return[4,null==m?void 0:m.getMyProfile()];case 2:t=n.sent(),f(null==t?void 0:t.data),n.label=3;case 3:return[2]}}))}))}),[m]),P=o((function(r){return t(a,void 0,void 0,(function(){var t,o;return n(this,(function(n){switch(n.label){case 0:return[4,null==m?void 0:m.updateMyProfile(r)];case 1:return t=n.sent(),o=e({},s),Object.keys(t.data).map((function(n){return o[n]=t.data[n],n})),f(o),[2,t]}}))}))}),[m]),h=function(t){console.log("onProfileUpdated",t.data)};return i((function(){return t(a,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,p()];case 1:return t.sent(),[2]}}))})),null==m||m.on(u.EVENT.PROFILE_UPDATED,h),function(){null==m||m.off(u.EVENT.PROFILE_UPDATED,h)}}),[m]),{myProfile:s,updateMyProfile:P}}export{a as useMyProfile};
1
+ import{__assign as t}from"tslib";import{useState as r,useEffect as o}from"react";import{TUIStore as i,StoreName as e,TUIUserService as n}from"@tencentcloud/chat-uikit-engine";function f(){var f=r(),u=f[0],c=f[1];return o((function(){i.watch(e.USER,{userProfile:function(t){c(t)}})}),[]),{myProfile:u,updateMyProfile:function(r){n.updateMyProfile(r);var o=t({},u);c(o)}}}export{f as useMyProfile};
@@ -1 +1 @@
1
- import{__assign as t}from"tslib";import{jsx as o}from"react/jsx-runtime";import e,{useContext as s}from"react";import"../components/TUIKit/TUIKit.js";import"react-i18next";import{TUIConversationList as n}from"../components/TUIConversationList/TUIConversationList.js";import"@tencentcloud/chat";import"@tencentcloud/chat-uikit-engine";import"date-fns";import"date-fns/locale";import"../components/Icon/config.js";import"../components/Icon/type.js";import"./TUIMessageContext.js";import"../constants.js";import"../components/TUIMessage/hooks/useMessageReply.js";import"../components/TUIMessage/MessagePlugins.js";import"../components/TUIMessage/MessageContext.js";import"../utils/env.js";import"../components/TUIMessageInput/hooks/useHandleQuoteMessage.js";import"../components/TUIProfile/TUIProfileDefault.js";var r=e.createContext({});function i(e){var s=e.children,i=e.value;return o(r.Provider,t({value:i},{children:s||o(n,{})}))}var m=function(t){var o=s(r);return!o&&t?{}:o};export{r as TUIConversationContext,i as TUIConversationProvider,m as useTUIConversationContext};
1
+ import{__assign as t}from"tslib";import{jsx as o}from"react/jsx-runtime";import e,{useContext as s}from"react";import"../components/TUIKit/TUIKit.js";import"@tencentcloud/chat-uikit-engine";import"react-i18next";import{TUIConversationList as n}from"../components/TUIConversationList/TUIConversationList.js";import"@tencentcloud/chat";import"date-fns";import"date-fns/locale";import"../components/Icon/config.js";import"../components/Icon/type.js";import"./TUIMessageContext.js";import"../constants.js";import"../components/TUIMessage/hooks/useMessageReply.js";import"../components/TUIMessage/MessagePlugins.js";import"../components/TUIMessage/MessageContext.js";import"../utils/env.js";import"../components/TUIMessageInput/hooks/useHandleQuoteMessage.js";import"../components/TUIProfile/TUIProfileDefault.js";var r=e.createContext({});function i(e){var s=e.children,i=e.value;return o(r.Provider,t({value:i},{children:s||o(n,{})}))}var m=function(t){var o=s(r);return!o&&t?{}:o};export{r as TUIConversationContext,i as TUIConversationProvider,m as useTUIConversationContext};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import o from"./server.js";export{TUIKit}from"./components/TUIKit/TUIKit.js";export{useTUIKit}from"./components/TUIKit/hooks/useTUIKit.js";export{useCreateTUIKitContext}from"./components/TUIKit/hooks/useCreateTUIKitContext.js";export{TUIConversation,UnMemoizedTUIConversation}from"./components/TUIConversation/TUIConversation.js";export{TUIConversationList,UnMemoTUIConversationList}from"./components/TUIConversationList/TUIConversationList.js";import"tslib";import"react";import"@tencentcloud/chat";export{TUIChat}from"./components/TUIChat/TUIChat.js";export{ConversationPreview}from"./components/ConversationPreview/ConversationPreview.js";export{ConversationPreviewContent,unMemoConversationPreviewContent}from"./components/ConversationPreview/ConversationPreviewContent.js";export{TUIChatHeader}from"./components/TUIChatHeader/TUIChatHeader.js";export{TUIChatHeaderDefault}from"./components/TUIChatHeader/TUIChatHeaderDefault.js";export{TUIMessageList}from"./components/TUIMessageList/TUIMessageList.js";export{TUIMessage}from"./components/TUIMessage/TUIMessage.js";export{MessagePlugins}from"./components/TUIMessage/MessagePlugins.js";export{MessageContext}from"./components/TUIMessage/MessageContext.js";export{TUIMessageInput}from"./components/TUIMessageInput/TUIMessageInput.js";export{TUIMessageInputDefault}from"./components/TUIMessageInput/TUIMessageInputDefault.js";export{InputPluginsDefalut}from"./components/TUIMessageInput/InputPluginsDefalut.js";export{TUIProfile}from"./components/TUIProfile/TUIProfile.js";export{TUIProfileDefault}from"./components/TUIProfile/TUIProfileDefault.js";export{Avatar}from"./components/Avatar/Avatar.js";export{defaultGroupAvatarAVChatRoom,defaultGroupAvatarMeeting,defaultGroupAvatarPublic,defaultGroupAvatarWork,defaultUserAvatar}from"./components/Avatar/default.js";export{ConversationSearchInput}from"./components/ConversationSearch/ConversationSearchInput.js";export{ConversationSearchResult}from"./components/ConversationSearch/ConversationSearchResult.js";export{TUIManage}from"./components/TUIManage/TUIManage.js";export{Popup}from"./components/Popup/index.js";export{Checkbox}from"./components/Checkbox/index.js";export{DivWithEdit}from"./components/DivWithEdit/DivWithEdit.js";export{Icon,changeTypeToIconClassName}from"./components/Icon/Icon.js";export{IconTypes}from"./components/Icon/type.js";export{EmptyStateIndicator}from"./components/EmptyStateIndicator/EmptyStateIndicator.js";export{Input}from"./components/Input/Input.js";export{Model}from"./components/Model/index.js";export{Plugins}from"./components/Plugins/index.js";export{Switch}from"./components/Switch/Switch.js";export{Toast}from"./components/Toast/index.js";export{TUIContactList}from"./components/TUIContact/TUIContactList/TUIContactList.js";export{TUIContactInfo,UnMemoizedTUIContactInfo}from"./components/TUIContact/TUIContactInfo/TUIContactInfo.js";export{TUIContact,UnMemoizedTUIContact}from"./components/TUIContact/TUIContact.js";export{TUIKitContext,TUIKitProvider,useTUIKitContext}from"./context/TUIKitContext.js";export{TUIChatStateContext,TUIChatStateContextProvider,useTUIChatStateContext}from"./context/TUIChatStateContext.js";export{TUIChatActionContext,TUIChatActionProvider,useTUIChatActionContext}from"./context/TUIChatActionContext.js";export{TUIMessageContext,TUIMessageContextProvider,messageShowType,useTUIMessageContext}from"./context/TUIMessageContext.js";export{ComponentContext,ComponentProvider,useComponentContext}from"./context/ComponentContext.js";export{TUIMessageInputContext,TUIMessageInputContextProvider,useTUIMessageInputContext}from"./context/TUIMessageInputContext.js";export{TUIContactContext,TUIContactContextProvider,useTUIContactContext}from"./context/TUIContactContext.js";export{useConversation}from"./hooks/useConversation.js";export{useProfile}from"./hooks/useProfile.js";export{t}from"./locales/index.js";export{default as i18next}from"i18next";new o;
1
+ import o from"./server.js";export{TUIKit}from"./components/TUIKit/TUIKit.js";export{useTUIKit}from"./components/TUIKit/hooks/useTUIKit.js";export{useCreateTUIKitContext}from"./components/TUIKit/hooks/useCreateTUIKitContext.js";export{TUIConversation,UnMemoizedTUIConversation}from"./components/TUIConversation/TUIConversation.js";export{TUIConversationList,UnMemoTUIConversationList}from"./components/TUIConversationList/TUIConversationList.js";import"react";import"@tencentcloud/chat";import"@tencentcloud/chat-uikit-engine";export{TUIChat}from"./components/TUIChat/TUIChat.js";import"tslib";export{ConversationPreview}from"./components/ConversationPreview/ConversationPreview.js";export{ConversationPreviewContent,unMemoConversationPreviewContent}from"./components/ConversationPreview/ConversationPreviewContent.js";export{TUIChatHeader}from"./components/TUIChatHeader/TUIChatHeader.js";export{TUIChatHeaderDefault}from"./components/TUIChatHeader/TUIChatHeaderDefault.js";export{TUIMessageList}from"./components/TUIMessageList/TUIMessageList.js";export{TUIMessage}from"./components/TUIMessage/TUIMessage.js";export{MessagePlugins}from"./components/TUIMessage/MessagePlugins.js";export{MessageContext}from"./components/TUIMessage/MessageContext.js";export{TUIMessageInput}from"./components/TUIMessageInput/TUIMessageInput.js";export{TUIMessageInputDefault}from"./components/TUIMessageInput/TUIMessageInputDefault.js";export{InputPluginsDefalut}from"./components/TUIMessageInput/InputPluginsDefalut.js";export{TUIProfile}from"./components/TUIProfile/TUIProfile.js";export{TUIProfileDefault}from"./components/TUIProfile/TUIProfileDefault.js";export{Avatar}from"./components/Avatar/Avatar.js";export{defaultGroupAvatarAVChatRoom,defaultGroupAvatarMeeting,defaultGroupAvatarPublic,defaultGroupAvatarWork,defaultUserAvatar}from"./components/Avatar/default.js";export{ConversationSearchInput}from"./components/ConversationSearch/ConversationSearchInput.js";export{ConversationSearchResult}from"./components/ConversationSearch/ConversationSearchResult.js";export{TUIManage}from"./components/TUIManage/TUIManage.js";export{Popup}from"./components/Popup/index.js";export{Checkbox}from"./components/Checkbox/index.js";export{DivWithEdit}from"./components/DivWithEdit/DivWithEdit.js";export{Icon,changeTypeToIconClassName}from"./components/Icon/Icon.js";export{IconTypes}from"./components/Icon/type.js";export{EmptyStateIndicator}from"./components/EmptyStateIndicator/EmptyStateIndicator.js";export{Input}from"./components/Input/Input.js";export{Model}from"./components/Model/index.js";export{Plugins}from"./components/Plugins/index.js";export{Switch}from"./components/Switch/Switch.js";export{Toast}from"./components/Toast/index.js";export{TUIContactList}from"./components/TUIContact/TUIContactList/TUIContactList.js";export{TUIContactInfo,UnMemoizedTUIContactInfo}from"./components/TUIContact/TUIContactInfo/TUIContactInfo.js";export{TUIContact,UnMemoizedTUIContact}from"./components/TUIContact/TUIContact.js";export{TUIKitContext,TUIKitProvider,useTUIKitContext}from"./context/TUIKitContext.js";export{TUIChatStateContext,TUIChatStateContextProvider,useTUIChatStateContext}from"./context/TUIChatStateContext.js";export{TUIChatActionContext,TUIChatActionProvider,useTUIChatActionContext}from"./context/TUIChatActionContext.js";export{TUIMessageContext,TUIMessageContextProvider,messageShowType,useTUIMessageContext}from"./context/TUIMessageContext.js";export{ComponentContext,ComponentProvider,useComponentContext}from"./context/ComponentContext.js";export{TUIMessageInputContext,TUIMessageInputContextProvider,useTUIMessageInputContext}from"./context/TUIMessageInputContext.js";export{TUIContactContext,TUIContactContextProvider,useTUIContactContext}from"./context/TUIContactContext.js";export{useConversation}from"./hooks/useConversation.js";export{useProfile}from"./hooks/useProfile.js";export{t}from"./locales/index.js";export{default as i18next}from"i18next";new o;
@@ -1 +1 @@
1
- var e={"Enter a userID":"Enter a userID","Enter the verification info":"Enter the verification info","Request to join":"Request to join",Requested:"Requested",Accept:"Accept",Refuse:"Refuse",Handled:"Handled",Friends:"Friends","Send Message":"Send Message",Signature:"Signature","New Contacts":"New Contacts","Blocked List":"Blocked List","No Result":"No Result",ID:"ID",User:"User","Add Friend":"Add Friend",remark:"remark",block:"block","Delete friend":"Delete friend","waiting for verification":"waiting for verification","verification info":"verification info","Send application":"Send application",Agree:"Agree"};export{e as default};
1
+ var e={"Enter a userID":"Enter a userID","Enter the verification info":"Enter the verification info","Request to join":"Request to join",Requested:"Requested",Accept:"Accept",Refuse:"Refuse",Handled:"Handled",Friends:"Friends","Send Message":"Send Message",Signature:"Signature","New Contacts":"New Contacts","Blocked List":"Blocked List","Group List":"Group List","No Result":"No Result",ID:"ID",User:"User","Add Friend":"Add Friend",remark:"remark",block:"block","Delete friend":"Delete friend","waiting for verification":"waiting for verification","verification info":"verification info","Send application":"Send application",Agree:"Agree"};export{e as default};
@@ -1 +1 @@
1
- var e={"Enter a userID":"请输入用户 ID,回车搜索","Enter the verification info":"请填写验证信息","Request to join":"申请加入",Requested:"已申请",Accept:"接受",Refuse:"拒绝",Handled:"已处理",Friends:"我的好友","Send Message":"发送消息",Signature:"个性签名","Successful application, waiting for the administrator to agree to join the group application":"等待管理员同意","New Contacts":"新的联系人","Blocked List":"黑名单","No Result":"无搜索结果",ID:"ID",User:"联系人","Add Friend":"添加好友",remark:"备注",block:"加入黑名单","Delete friend":"删除好友","waiting for verification":"等待验证","verification info":"验证信息","Send application":"发送申请",Agree:"同意"};export{e as default};
1
+ var e={"Enter a userID":"请输入用户 ID,回车搜索","Enter the verification info":"请填写验证信息","Request to join":"申请加入",Requested:"已申请",Accept:"接受",Refuse:"拒绝",Handled:"已处理",Friends:"我的好友","Send Message":"发送消息",Signature:"个性签名","Successful application, waiting for the administrator to agree to join the group application":"等待管理员同意","New Contacts":"新的联系人","Blocked List":"黑名单","Group List":"我的群聊","No Result":"无搜索结果",ID:"ID",User:"联系人","Add Friend":"添加好友",remark:"备注",block:"加入黑名单","Delete friend":"删除好友","waiting for verification":"等待验证","verification info":"验证信息","Send application":"发送申请",Agree:"同意"};export{e as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tencentcloud/chat-uikit-react",
3
- "version": "2.1.3",
3
+ "version": "2.2.2",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "license": "MIT",
@@ -0,0 +1,14 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const { execSync } = require('child_process');
4
+
5
+ // Change directory to tuikit/examples/sample-chat
6
+ process.chdir(path.join('examples', 'sample-chat'));
7
+
8
+ // Change directory to src
9
+ process.chdir('src');
10
+ process.chdir('demo');
11
+ // Remove file
12
+ fs.unlinkSync('SampleChat.tsx');
13
+ // Rename index-intl.tsx to index
14
+ fs.renameSync('SampleChat-experience.tsx', 'SampleChat.tsx');
@@ -103,7 +103,7 @@ export function unMemoConversationPreviewContent<T extends ConversationPreviewUI
103
103
  break;
104
104
  case 'delete':
105
105
  deleteConversation(conversationID);
106
- if (setActiveConversation && conversation === activeConversation) {
106
+ if (setActiveConversation && conversationID === activeConversation?.conversationID) {
107
107
  setActiveConversation(undefined);
108
108
  }
109
109
  break;
@@ -1,2 +1 @@
1
- export * from './Profile';
2
- export * from './hooks/useProfile';
1
+ export * from './Profile';
@@ -6,17 +6,18 @@ import { isH5 } from '../../../utils/env';
6
6
  import { FriendInfo } from './friendInfo';
7
7
  import { BlockInfo } from './blockInfo';
8
8
  import { AddFriendInfo } from './addFriendInfo';
9
+ import { GroupInfo } from './groupInfo';
9
10
  import { FriendApplicationInfo } from './friendApplication';
10
11
  import './index.scss';
11
12
 
12
13
  interface TUIContactInfoProps {
13
14
  className?: string,
14
- showChat?: () => void,
15
+ showChats?: () => void,
15
16
  }
16
17
  export function UnMemoizedTUIContactInfo<T extends TUIContactInfoProps>(
17
18
  props: PropsWithChildren<T>,
18
19
  ): React.ReactElement {
19
- const { showChat } = props;
20
+ const { showChats } = props;
20
21
  const { contactData } = useTUIKitContext('TUIContact');
21
22
  if (!contactData?.type) {
22
23
  return (<> </>);
@@ -24,8 +25,9 @@ export function UnMemoizedTUIContactInfo<T extends TUIContactInfoProps>(
24
25
  return (
25
26
  <div className={`tui-contact-info ${isH5 ? 'tui-contact-info-h5' : ''} `}>
26
27
  {contactData?.type === 'addFriend' && (<AddFriendInfo profile={contactData?.data} />)}
27
- {contactData?.type === 'friend' && (<FriendInfo openChat={showChat} friend={contactData?.data} />)}
28
+ {contactData?.type === 'friend' && (<FriendInfo showChats={showChats} friend={contactData?.data} />)}
28
29
  {contactData?.type === 'block' && (<BlockInfo profile={contactData?.data} />)}
30
+ {contactData?.type === 'group' && (<GroupInfo showChats={showChats} group={contactData?.data} />)}
29
31
  {contactData?.type === 'friendApplication' && <FriendApplicationInfo application={contactData?.data} />}
30
32
  </div>
31
33
  );
@@ -1,18 +1,17 @@
1
1
  import React, { useState, useEffect } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import { Friend } from '@tencentcloud/chat';
4
- import { TUIConversationService } from '@tencentcloud/chat-uikit-engine';
4
+ import { TUIConversationService, IConversationModel } from '@tencentcloud/chat-uikit-engine';
5
5
  import { useTUIKitContext } from '../../../context';
6
6
  import { BasicInfo } from './basicInfo';
7
7
  import { Switch } from '../../Switch';
8
8
  import useContactInfo from './hooks/useContactInfo';
9
9
  import { DivWithEdit } from '../../DivWithEdit';
10
- import { useConversation } from '../../../hooks';
11
10
  import '../index.scss';
12
11
 
13
12
  interface Props {
14
13
  friend: Friend;
15
- openChat?: () => void,
14
+ showChats?: () => void,
16
15
  }
17
16
  export function UnMemoizedFriendInfo<T extends Props>(
18
17
  props: T,
@@ -21,7 +20,7 @@ export function UnMemoizedFriendInfo<T extends Props>(
21
20
  chat, contactData, setActiveContact, setActiveConversation,
22
21
  } = useTUIKitContext('TUIContact');
23
22
  const { t } = useTranslation();
24
- const { friend, openChat } = props;
23
+ const { friend, showChats } = props;
25
24
  const { userID, profile, remark } = friend;
26
25
  const [isEditName, setIsEditRemark] = useState('');
27
26
  const [remarkValue, setRemarkValue] = useState('');
@@ -30,7 +29,6 @@ export function UnMemoizedFriendInfo<T extends Props>(
30
29
  addToBlocklist,
31
30
  deleteFriend,
32
31
  } = useContactInfo();
33
- const { createConversation } = useConversation(chat);
34
32
  useEffect(() => {
35
33
  setIsAddToBlocklist(false);
36
34
  setRemarkValue(remark);
@@ -59,12 +57,14 @@ export function UnMemoizedFriendInfo<T extends Props>(
59
57
  await deleteFriend(userID);
60
58
  setActiveContact();
61
59
  };
62
- const openC2CConversation = async () => {
60
+ const openC2CConversation = () => {
63
61
  const conversationID = `C2C${userID}`;
64
- const conversation = await createConversation(conversationID);
65
- TUIConversationService.switchConversation(conversationID);
66
- setActiveConversation(conversation);
67
- openChat && openChat();
62
+ showChats && showChats();
63
+ TUIConversationService.switchConversation(conversationID).then(
64
+ (conversationModel: IConversationModel) => {
65
+ setActiveConversation(conversationModel.getConversation());
66
+ }
67
+ );
68
68
  };
69
69
 
70
70
  return (
@@ -0,0 +1,65 @@
1
+ import React from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { TUIConversationService, IGroupModel, IConversationModel } from '@tencentcloud/chat-uikit-engine';
4
+ import { useTUIKitContext } from '../../../context';
5
+ import { Icon, IconTypes } from '../../Icon';
6
+ import { isH5 } from '../../../utils/env';
7
+ import '../index.scss';
8
+ import { Avatar, defaultUserAvatar } from '../../Avatar';
9
+
10
+ interface Props {
11
+ group: IGroupModel;
12
+ showChats?: () => void,
13
+ }
14
+
15
+ export function UnMemoizedGroupInfo<T extends Props>(
16
+ props: T,
17
+ ): React.ReactElement {
18
+ const { group, showChats } = props;
19
+
20
+ const { setActiveContact, setActiveConversation } = useTUIKitContext('TUIContact');
21
+ const { t } = useTranslation();
22
+ const { groupID, name, avatar } = group;
23
+
24
+ const back = () => {
25
+ TUIConversationService.switchConversation('');
26
+ setActiveContact();
27
+ };
28
+ const openGroupConversation = () => {
29
+ const conversationID = `GROUP${groupID}`;
30
+ showChats && showChats();
31
+ TUIConversationService.switchConversation(conversationID).then(
32
+ (conversationModel: IConversationModel) => {
33
+ setActiveConversation(conversationModel.getConversation());
34
+ }
35
+ );
36
+ };
37
+
38
+ return (
39
+ <>
40
+ <div className="tui-contact-info-header">
41
+ {isH5 && (
42
+ <Icon
43
+ width={9}
44
+ height={16}
45
+ type={IconTypes.BACK}
46
+ onClick={back}
47
+ />
48
+ )}
49
+ <div className="header-container">
50
+ <div className="header-container-avatar">
51
+ <Avatar size={60} image={avatar || defaultUserAvatar} />
52
+ <div className="header-container-name">{name || groupID}</div>
53
+ </div>
54
+ <div className="header-container-text">{`groupID:${groupID}`}</div>
55
+ </div>
56
+ </div>
57
+ <div className="tui-contact-info-content">
58
+ <div className="content-btn-container">
59
+ <div className="content-item-btn confirm-btn" role="button" tabIndex={0} onClick={openGroupConversation}>{t('TUIContact.Send Message')}</div>
60
+ </div>
61
+ </div>
62
+ </>
63
+ );
64
+ }
65
+ export const GroupInfo = React.memo(UnMemoizedGroupInfo);
@@ -4,13 +4,20 @@ import TencentCloudChat from '@tencentcloud/chat';
4
4
  import { isH5 } from '../../../utils/env';
5
5
  import { useTUIKitContext, useTUIContactContext } from '../../../context';
6
6
  import useContactInfo from '../TUIContactInfo/hooks/useContactInfo';
7
-
7
+ import useTUIContact from '../hooks/useTUIContact';
8
8
  import { Avatar, defaultUserAvatar } from '../../Avatar';
9
9
  import rightArrow from '../../Icon/images/right-arrow.svg';
10
10
  import downArrow from '../../Icon/images/down-arrow.png';
11
-
12
11
  import './index.scss';
13
12
 
13
+ interface RenderContactListProps {
14
+ type: 'group' | 'block' | 'friend' ,
15
+ isShow: boolean,
16
+ title: string,
17
+ list: Array<any> | undefined,
18
+ setShow: (value: boolean) => void
19
+ }
20
+
14
21
  function UnMemoizedTUIContactList<T>(): React.ReactElement {
15
22
  const { setActiveContact } = useTUIKitContext();
16
23
  const { t } = useTranslation();
@@ -20,16 +27,56 @@ function UnMemoizedTUIContactList<T>(): React.ReactElement {
20
27
  const {
21
28
  acceptFriendApplication,
22
29
  } = useContactInfo();
23
-
30
+ const { groupList } = useTUIContact();
24
31
  const [iShowFriendApplication, setShowFriendApplication] = useState(false);
25
32
  const [iShowFriends, setShowFriends] = useState(false);
26
33
  const [isShowBlocklist, setShowBlocklist] = useState(false);
34
+ const [isShowGrouplist, setShowGrouplist] = useState(false);
27
35
 
28
36
  const acceptFriendApplicationHandle = (e: any, userID: string) => {
29
37
  e.stopPropagation();
30
38
  acceptFriendApplication(userID);
31
39
  setActiveContact();
32
40
  };
41
+
42
+ const RenderContactList = ({ type, isShow, setShow, list, title } : RenderContactListProps) => {
43
+ return (
44
+ <>
45
+ <div
46
+ className="tui-contacts-title"
47
+ role="button"
48
+ tabIndex={0}
49
+ onClick={() => setShow(!isShow)}
50
+ >
51
+ <div className="tui-contacts-list-title">{title}</div>
52
+ <div className="tui-contacts-list-icon">
53
+ <img src={isShow ? downArrow : rightArrow} alt="" />
54
+ </div>
55
+ </div>
56
+ {isShow
57
+ && list?.map((item: any) => {
58
+ const { userID, groupID, avatar, name, nick } = item.profile || item;
59
+ const showName = item.remark || nick || userID || name || groupID;
60
+ return (
61
+ <div
62
+ role="button"
63
+ tabIndex={0}
64
+ className="tui-contacts-list-item"
65
+ key={userID || groupID}
66
+ onClick={() => {
67
+ setActiveContact({ type, data: item });
68
+ }}
69
+ >
70
+ <Avatar size={30} image={avatar || defaultUserAvatar} />
71
+ <div className="tui-contacts-list-item-container">
72
+ <p className="tui-contacts-list-item-name">{ showName }</p>
73
+ </div>
74
+ </div>
75
+ );
76
+ })}
77
+ </>
78
+ );
79
+ }
33
80
  // eslint-disable-next-line
34
81
  // @ts-ignore
35
82
  return (
@@ -96,68 +143,27 @@ function UnMemoizedTUIContactList<T>(): React.ReactElement {
96
143
  </div>
97
144
  );
98
145
  })}
99
- <div
100
- className="tui-contacts-title"
101
- role="button"
102
- tabIndex={0}
103
- onClick={() => setShowBlocklist(!isShowBlocklist)}
104
- >
105
- <div className="tui-contacts-list-title">{t('TUIContact.Blocked List')}</div>
106
- <div className="tui-contacts-list-icon">
107
- <img src={isShowBlocklist ? downArrow : rightArrow} alt="" />
108
- </div>
109
- </div>
110
- {isShowBlocklist
111
- && blocklistProfile?.map((item, index) => {
112
- const { userID, avatar, nick } = item;
113
- return (
114
- <div
115
- role="button"
116
- tabIndex={0}
117
- className="tui-contacts-list-item"
118
- key={userID}
119
- onClick={() => {
120
- setActiveContact({ type: 'block', data: item });
121
- }}
122
- >
123
- <Avatar size={30} image={avatar || defaultUserAvatar} />
124
- <div className="tui-contacts-list-item-container">
125
- <p className="tui-contacts-list-item-name">{ nick || userID}</p>
126
- </div>
127
- </div>
128
- );
129
- })}
130
- <div
131
- className="tui-contacts-title"
132
- role="button"
133
- tabIndex={0}
134
- onClick={() => setShowFriends(!iShowFriends)}
135
- >
136
- <div className="tui-contacts-list-title">{t('TUIContact.Friends')}</div>
137
- <div className="tui-contacts-list-icon">
138
- <img src={iShowFriends ? downArrow : rightArrow} alt="" />
139
- </div>
140
- </div>
141
- {iShowFriends
142
- && friendList?.map((item, index) => {
143
- const { userID, avatar, nick } = item.profile;
144
- return (
145
- <div
146
- className="tui-contacts-list-item"
147
- key={userID}
148
- role="button"
149
- tabIndex={0}
150
- onClick={() => {
151
- setActiveContact({ type: 'friend', data: item });
152
- }}
153
- >
154
- <Avatar size={30} image={avatar || defaultUserAvatar} />
155
- <div className="tui-contacts-list-item-container">
156
- <p className="tui-contacts-list-item-name">{item.remark || nick || userID}</p>
157
- </div>
158
- </div>
159
- );
160
- })}
146
+ <RenderContactList
147
+ type={'block'}
148
+ title={t('TUIContact.Blocked List')}
149
+ isShow={isShowBlocklist}
150
+ setShow={setShowBlocklist}
151
+ list={blocklistProfile}
152
+ />
153
+ <RenderContactList
154
+ type={'group'}
155
+ title={t('TUIContact.Group List')}
156
+ setShow={setShowGrouplist}
157
+ isShow={isShowGrouplist}
158
+ list={groupList}
159
+ />
160
+ <RenderContactList
161
+ type={'friend'}
162
+ title={t('TUIContact.Friends')}
163
+ setShow={setShowFriends}
164
+ isShow={iShowFriends}
165
+ list={friendList}
166
+ />
161
167
  </div>
162
168
  )
163
169
  );
@@ -1,5 +1,10 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import TencentCloudChat from '@tencentcloud/chat';
3
+ import {
4
+ TUIStore,
5
+ StoreName,
6
+ IGroupModel,
7
+ } from '@tencentcloud/chat-uikit-engine';
3
8
  import { useTUIKitContext } from '../../../context';
4
9
 
5
10
  function useTUIContact() {
@@ -8,14 +13,22 @@ function useTUIContact() {
8
13
  const [blockList, setBlockList] = useState([]);
9
14
  const [friendApplicationList, setFriendApplicationList] = useState([]);
10
15
  const [blocklistProfile, setBlocklistProfile] = useState([]);
16
+ const [groupList, setGroupList] = useState<IGroupModel[]>();
17
+
11
18
  const [isShowContactList, setShowContactList] = useState(true);
12
19
 
13
20
  useEffect(() => {
21
+ TUIStore.watch(StoreName.GRP, {
22
+ groupList: onGroupListUpdated,
23
+ });
14
24
  getFriendList();
15
25
  getBlocklist();
16
26
  getFriendApplicationList();
17
27
  }, [chat]);
18
28
 
29
+ const onGroupListUpdated = (list: IGroupModel[]) => {
30
+ setGroupList(list);
31
+ };
19
32
  useEffect(() => {
20
33
  chat?.on(TencentCloudChat.EVENT.BLACKLIST_UPDATED, onBlocklistUpdated);
21
34
  chat?.on(TencentCloudChat.EVENT.FRIEND_LIST_UPDATED, onFriendListUpdated);
@@ -64,6 +77,7 @@ function useTUIContact() {
64
77
 
65
78
  return {
66
79
  friendList,
80
+ groupList,
67
81
  blocklistProfile,
68
82
  friendApplicationList,
69
83
  blockList,
@@ -1,6 +1,9 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import TencentCloudChat, { ChatSDK, Conversation } from '@tencentcloud/chat';
3
-
3
+ import {
4
+ TUIStore,
5
+ StoreName,
6
+ } from '@tencentcloud/chat-uikit-engine';
4
7
  function useConversationList(
5
8
  chat: ChatSDK,
6
9
  activeConversationHandler?:(
@@ -10,33 +13,25 @@ function useConversationList(
10
13
  filterConversation?:(conversationList: Array<Conversation>) => Array<Conversation>,
11
14
  ) {
12
15
  const [conversationList, setConversationList] = useState<Array<Conversation>>([]);
13
- const queryConversation = async (queryType?: string) => {
14
- if (queryType === 'reload') {
15
- setConversationList([]);
16
+ const onConversationListUpdated = (list: any) => {
17
+ let resConversationList = [];
18
+ if (filterConversation) {
19
+ resConversationList = filterConversation(list);
20
+ } else {
21
+ resConversationList = list.filter(
22
+ (item: any) => item.type !== TencentCloudChat.TYPES.CONV_SYSTEM,
23
+ );
16
24
  }
17
- const offset = queryType === 'reload' ? 0 : conversationList.length;
18
-
19
- const res = await chat?.getConversationList();
20
- if (res?.code === 0) {
21
- let resConversationList = [];
22
- if (filterConversation) {
23
- resConversationList = filterConversation(res.data.conversationList);
24
- } else {
25
- resConversationList = res.data.conversationList.filter(
26
- (item: any) => item.type !== TencentCloudChat.TYPES.CONV_SYSTEM,
27
- );
28
- }
29
- const newConversationList = queryType === 'reload'
30
- ? resConversationList
31
- : [...conversationList, resConversationList];
32
- setConversationList(newConversationList);
33
- if (!offset && activeConversationHandler) {
34
- activeConversationHandler(newConversationList, setConversationList);
35
- }
25
+ setConversationList(resConversationList);
26
+ if (activeConversationHandler) {
27
+ activeConversationHandler(resConversationList, setConversationList);
36
28
  }
37
29
  };
30
+
38
31
  useEffect(() => {
39
- queryConversation('reload');
32
+ TUIStore.watch(StoreName.CONV, {
33
+ conversationList: onConversationListUpdated,
34
+ });
40
35
  }, [chat]);
41
36
  return {
42
37
  conversationList,