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