@tencentcloud/chat-uikit-react 1.2.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +2 -1
- package/CHANGELOG.md +8 -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/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 +240 -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/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 +240 -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 +7 -6
- 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 +1 -1
- 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 +7 -1
- package/src/components/TUIContact/TUIContactInfo/friendInfo.tsx +4 -1
- package/src/components/TUIContact/TUIContactList/TUIContactList.tsx +1 -1
- 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 +133 -9
- 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 +4 -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/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/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
|
@@ -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,24 @@
|
|
|
1
|
-
import React, { PropsWithChildren } from 'react';
|
|
1
|
+
import React, { PropsWithChildren, useState, useEffect } from 'react';
|
|
2
2
|
import { ChatSDK, Conversation } from '@tencentcloud/chat';
|
|
3
|
+
import { TUIStore, StoreName } from '@tencentcloud/chat-uikit-engine';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { isH5, isPC } from '../../utils/env';
|
|
3
6
|
import { useTUIKit } from './hooks/useTUIKit';
|
|
4
7
|
import { useCreateTUIKitContext } from './hooks/useCreateTUIKitContext';
|
|
5
8
|
import { TUIKitProvider } from '../../context/TUIKitContext';
|
|
6
9
|
import './styles/index.scss';
|
|
10
|
+
import './styles/h5.scss';
|
|
7
11
|
import { TUIConversation } from '../TUIConversation';
|
|
8
12
|
import { TUIChat } from '../TUIChat';
|
|
9
13
|
import { TUIManage } from '../TUIManage';
|
|
14
|
+
import { TUIProfile } from '../TUIProfile';
|
|
15
|
+
import { TUIContact } from '../TUIContact';
|
|
16
|
+
import { TUIContactInfo } from '../TUIContact/TUIContactInfo/TUIContactInfo';
|
|
10
17
|
import '../../locales/index';
|
|
18
|
+
import chats from '../Icon/images/chats.svg';
|
|
19
|
+
import chatsSelected from '../Icon/images/chats-selected.svg';
|
|
20
|
+
import contacts from '../Icon/images/contacts.svg';
|
|
21
|
+
import contactsSelected from '../Icon/images/contacts-selected.svg';
|
|
11
22
|
|
|
12
23
|
export interface ChatProps {
|
|
13
24
|
chat?: ChatSDK | null,
|
|
@@ -15,13 +26,94 @@ export interface ChatProps {
|
|
|
15
26
|
customClasses?: unknown,
|
|
16
27
|
activeConversation?: Conversation,
|
|
17
28
|
}
|
|
29
|
+
|
|
30
|
+
interface RenderPCProps {
|
|
31
|
+
moduleValue: string,
|
|
32
|
+
tabbarRender: any,
|
|
33
|
+
setModuleValue: (value: string) => void
|
|
34
|
+
}
|
|
35
|
+
interface RenderH5Props {
|
|
36
|
+
currentConversationID: string
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const tabbarList = [
|
|
40
|
+
{
|
|
41
|
+
id: 1,
|
|
42
|
+
name: 'chats',
|
|
43
|
+
icon: chats,
|
|
44
|
+
selectedIcon: chatsSelected,
|
|
45
|
+
value: 'chats',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 2,
|
|
49
|
+
name: 'contacts',
|
|
50
|
+
icon: contacts,
|
|
51
|
+
selectedIcon: contactsSelected,
|
|
52
|
+
value: 'contacts',
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
const TUIMessageInputConfig = {
|
|
56
|
+
className: 'sample-h5-input',
|
|
57
|
+
isTransmitter: true,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
function RenderForPC({ moduleValue, tabbarRender, setModuleValue } : RenderPCProps) {
|
|
61
|
+
return (
|
|
62
|
+
<>
|
|
63
|
+
<div className="sample-chat-left-container">
|
|
64
|
+
<TUIProfile className="sample-chat-profile" />
|
|
65
|
+
{tabbarRender}
|
|
66
|
+
{moduleValue === 'chats' && <TUIConversation />}
|
|
67
|
+
{moduleValue === 'contacts' && <TUIContact />}
|
|
68
|
+
</div>
|
|
69
|
+
{moduleValue === 'chats' && (
|
|
70
|
+
<>
|
|
71
|
+
<TUIChat />
|
|
72
|
+
<TUIManage />
|
|
73
|
+
</>
|
|
74
|
+
)}
|
|
75
|
+
{moduleValue === 'contacts' && (
|
|
76
|
+
<TUIContact>
|
|
77
|
+
<TUIContactInfo
|
|
78
|
+
showChat={() => {
|
|
79
|
+
setModuleValue('chats');
|
|
80
|
+
}}
|
|
81
|
+
/>
|
|
82
|
+
</TUIContact>
|
|
83
|
+
)}
|
|
84
|
+
</>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function RenderForH5({ currentConversationID }: RenderH5Props) {
|
|
89
|
+
return (
|
|
90
|
+
<>
|
|
91
|
+
{!currentConversationID && (
|
|
92
|
+
<div className="sample-chat-h5-container">
|
|
93
|
+
<TUIProfile className="sample-profile" />
|
|
94
|
+
<TUIConversation />
|
|
95
|
+
</div>
|
|
96
|
+
)}
|
|
97
|
+
{currentConversationID && (
|
|
98
|
+
<>
|
|
99
|
+
<TUIChat TUIMessageInputConfig={TUIMessageInputConfig} />
|
|
100
|
+
<TUIManage />
|
|
101
|
+
</>
|
|
102
|
+
)}
|
|
103
|
+
</>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
18
106
|
export function TUIKit<
|
|
19
107
|
T extends ChatProps
|
|
20
108
|
>(
|
|
21
109
|
props:PropsWithChildren<T>,
|
|
22
110
|
):React.ReactElement {
|
|
111
|
+
const [currentConversationID, setCurrentConversationID] = useState<string>('');
|
|
112
|
+
const [moduleValue, setModuleValue] = useState('chats');
|
|
113
|
+
const { t } = useTranslation();
|
|
114
|
+
|
|
23
115
|
const {
|
|
24
|
-
children, chat, customClasses, activeConversation, language,
|
|
116
|
+
children, chat, customClasses, activeConversation, language = 'en',
|
|
25
117
|
} = props;
|
|
26
118
|
(window as any).tencent_cloud_im_csig_react_uikit_23F_xa = true;
|
|
27
119
|
const {
|
|
@@ -49,17 +141,49 @@ export function TUIKit<
|
|
|
49
141
|
setTUIProfileShow,
|
|
50
142
|
setActiveContact,
|
|
51
143
|
});
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
TUIStore.watch(StoreName.CONV, {
|
|
146
|
+
currentConversationID: onCurrentConversationID,
|
|
147
|
+
});
|
|
148
|
+
return () => {
|
|
149
|
+
TUIStore.unwatch(StoreName.CONV, {
|
|
150
|
+
currentConversationID: onCurrentConversationID,
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
}, []);
|
|
154
|
+
|
|
155
|
+
const onCurrentConversationID = (id: string) => {
|
|
156
|
+
setCurrentConversationID(id);
|
|
157
|
+
};
|
|
158
|
+
const switchTabbar = (value: string) => {
|
|
159
|
+
setModuleValue(value);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const tabbarRender = (
|
|
163
|
+
<div className="sample-chat-tab">
|
|
164
|
+
{tabbarList.map((item: any) => (
|
|
165
|
+
<div
|
|
166
|
+
className="sample-chat-tab-container"
|
|
167
|
+
key={item.id}
|
|
168
|
+
role="presentation"
|
|
169
|
+
onClick={() => {
|
|
170
|
+
switchTabbar(item.value);
|
|
171
|
+
}}
|
|
172
|
+
>
|
|
173
|
+
<img src={moduleValue === item.value ? item.selectedIcon : item.icon} alt="" />
|
|
174
|
+
<p className={`sample-chat-tab-text ${moduleValue === item.value ? 'sample-chat-tab-active' : ''}`}>
|
|
175
|
+
{t(item.name)}
|
|
176
|
+
</p>
|
|
177
|
+
</div>
|
|
178
|
+
))}
|
|
179
|
+
</div>
|
|
180
|
+
);
|
|
52
181
|
|
|
53
182
|
return (
|
|
54
183
|
<TUIKitProvider value={chatContextValue}>
|
|
55
184
|
<div className="tui-kit">
|
|
56
|
-
{children || (
|
|
57
|
-
|
|
58
|
-
<TUIConversation />
|
|
59
|
-
<TUIChat />
|
|
60
|
-
<TUIManage />
|
|
61
|
-
</>
|
|
62
|
-
)}
|
|
185
|
+
{children || (isPC && <RenderForPC moduleValue={moduleValue} tabbarRender={tabbarRender} setModuleValue={setModuleValue} />)
|
|
186
|
+
|| (isH5 && <RenderForH5 currentConversationID={currentConversationID} />)}
|
|
63
187
|
</div>
|
|
64
188
|
</TUIKitProvider>
|
|
65
189
|
);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.App {
|
|
2
|
+
height: 100%;
|
|
3
|
+
}
|
|
4
|
+
#root {
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
margin: 0;
|
|
8
|
+
}
|
|
9
|
+
.sample-chat-h5 {
|
|
10
|
+
position:relative;
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 100%;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
&-container {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
width: 100%;
|
|
18
|
+
height: 100%;
|
|
19
|
+
.sample-profile {
|
|
20
|
+
position: absolute;
|
|
21
|
+
top: 0;
|
|
22
|
+
z-index: 1;
|
|
23
|
+
width:100%;
|
|
24
|
+
max-width: 100%;
|
|
25
|
+
min-width: 100%;
|
|
26
|
+
}
|
|
27
|
+
.tui-kit-input-box.tui-kit-input-box--focus {
|
|
28
|
+
outline: none;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
.tui-message-input .tui-kit-input-box--focus {
|
|
32
|
+
outline: none;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -7,3 +7,106 @@
|
|
|
7
7
|
background-color: #FFFFFF;
|
|
8
8
|
text-align: initial;
|
|
9
9
|
}
|
|
10
|
+
.sample-chat {
|
|
11
|
+
position:relative;
|
|
12
|
+
margin: 0 auto;
|
|
13
|
+
width: calc(100% - 20rem);
|
|
14
|
+
min-width: 850px;
|
|
15
|
+
height: 86%;
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
border-radius: 12px;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
&-profile {
|
|
20
|
+
position: absolute;
|
|
21
|
+
top: 0;
|
|
22
|
+
z-index: 1;
|
|
23
|
+
}
|
|
24
|
+
&-left-container {
|
|
25
|
+
max-width: 360px;
|
|
26
|
+
min-width: 360px;
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
}
|
|
30
|
+
&-tab {
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
justify-content: space-around;
|
|
34
|
+
margin: 12px;
|
|
35
|
+
}
|
|
36
|
+
&-tab-container {
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
align-items: center;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
}
|
|
43
|
+
&-tab-text {
|
|
44
|
+
font-size: 15px;
|
|
45
|
+
line-height: 25px;
|
|
46
|
+
text-align: center;
|
|
47
|
+
}
|
|
48
|
+
&-tab-active {
|
|
49
|
+
color: #147AFF;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
.tuikit-container {
|
|
53
|
+
display: flex;
|
|
54
|
+
height: 100%;
|
|
55
|
+
position: relative;
|
|
56
|
+
text-align: initial;
|
|
57
|
+
box-shadow: 0 11px 20px 0 rgba(0,0,0,.3);
|
|
58
|
+
}
|
|
59
|
+
.tui-chat-default {
|
|
60
|
+
width: 100%;
|
|
61
|
+
height: 100%;
|
|
62
|
+
background-size: cover;
|
|
63
|
+
background-position-x: -17px;
|
|
64
|
+
background-position-y: 173px;
|
|
65
|
+
padding: 100px 40px 0;
|
|
66
|
+
header {
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
font-size: 1.75rem;
|
|
70
|
+
font-family: PingFangSC-Medium;
|
|
71
|
+
font-weight: 500;
|
|
72
|
+
color: #000;
|
|
73
|
+
letter-spacing: 0;
|
|
74
|
+
img {
|
|
75
|
+
width: 32px;
|
|
76
|
+
margin: 0 10px;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
.content {
|
|
80
|
+
max-width: 393px;
|
|
81
|
+
font-size: 16px;
|
|
82
|
+
line-height: 24px;
|
|
83
|
+
font-family: PingFangSC-Regular;
|
|
84
|
+
font-weight: 400;
|
|
85
|
+
color: #666;
|
|
86
|
+
letter-spacing: 0;
|
|
87
|
+
padding: 36px 0 20px;
|
|
88
|
+
}
|
|
89
|
+
.link {
|
|
90
|
+
font-size: 14px;
|
|
91
|
+
line-height: 20px;
|
|
92
|
+
font-family: PingFangSC-Regular;
|
|
93
|
+
font-weight: 400;
|
|
94
|
+
color: #666;
|
|
95
|
+
letter-spacing: 0;
|
|
96
|
+
a {
|
|
97
|
+
font-family: PingFangSC-Regular;
|
|
98
|
+
font-weight: 400;
|
|
99
|
+
color: #006eff;
|
|
100
|
+
letter-spacing: 0;
|
|
101
|
+
text-decoration: none;
|
|
102
|
+
padding: 0 5px;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
body {
|
|
109
|
+
#webpack-dev-server-client-overlay {
|
|
110
|
+
display: none !important;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -45,3 +45,23 @@ table {
|
|
|
45
45
|
border-collapse: collapse;
|
|
46
46
|
border-spacing: 0;
|
|
47
47
|
}
|
|
48
|
+
html, body {
|
|
49
|
+
height: 100%;
|
|
50
|
+
width: 100%;
|
|
51
|
+
margin: 0;
|
|
52
|
+
-webkit-text-size-adjust: 100%;
|
|
53
|
+
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
54
|
+
}
|
|
55
|
+
*{
|
|
56
|
+
-webkit-touch-callout:none;
|
|
57
|
+
-webkit-user-select:none;
|
|
58
|
+
-khtml-user-select:none;
|
|
59
|
+
-moz-user-select:none;
|
|
60
|
+
-ms-user-select:none;
|
|
61
|
+
user-select:none;
|
|
62
|
+
}
|
|
63
|
+
.text-ellipsis {
|
|
64
|
+
text-overflow: ellipsis;
|
|
65
|
+
white-space: nowrap;
|
|
66
|
+
overflow: hidden;
|
|
67
|
+
}
|
|
@@ -5,6 +5,7 @@ import { Icon, IconTypes } from '../Icon';
|
|
|
5
5
|
import { Avatar, defaultGroupAvatarWork, defaultUserAvatar } from '../Avatar';
|
|
6
6
|
import { Switch } from '../Switch';
|
|
7
7
|
import { useTUIKitContext } from '../../context';
|
|
8
|
+
import { isH5, isPC } from '../../utils/env';
|
|
8
9
|
import { getMessageProfile } from '../ConversationPreview/utils';
|
|
9
10
|
import { useConversationUpdate } from '../TUIConversationList/hooks/useConversationUpdate';
|
|
10
11
|
import { useConversation } from '../../hooks';
|
|
@@ -46,43 +47,66 @@ export function TUIManage() {
|
|
|
46
47
|
setIsPinned(activeConversation ? activeConversation.isPinned : false);
|
|
47
48
|
}, [activeConversation, forceUpdateCount]);
|
|
48
49
|
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
return (
|
|
51
|
+
TUIManageShow
|
|
52
|
+
&& activeConversation && (
|
|
53
|
+
<div className={`tui-manage ${isH5 ? 'tui-h5-manage' : ''}`}>
|
|
54
|
+
<div className="tui-manage-title">
|
|
55
|
+
{isPC && (
|
|
56
|
+
<Icon
|
|
57
|
+
onClick={close}
|
|
58
|
+
type={IconTypes.CANCEL}
|
|
59
|
+
width={9}
|
|
60
|
+
height={16}
|
|
61
|
+
/>
|
|
62
|
+
)}
|
|
63
|
+
{isH5 && (
|
|
64
|
+
<Icon onClick={close} type={IconTypes.BACK} width={9} height={16} />
|
|
65
|
+
)}
|
|
66
|
+
<span style={{ marginLeft: '10px' }}>
|
|
67
|
+
{t('TUIConversation.Conversation Information')}
|
|
68
|
+
</span>
|
|
64
69
|
</div>
|
|
65
|
-
<div className="
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
70
|
+
<div className="tui-manage-container">
|
|
71
|
+
<div className="tui-manage-info">
|
|
72
|
+
<div className="info-avatar">
|
|
73
|
+
<Avatar
|
|
74
|
+
size={64}
|
|
75
|
+
image={
|
|
76
|
+
profile?.avatar
|
|
77
|
+
|| (profile?.groupID
|
|
78
|
+
? defaultGroupAvatarWork
|
|
79
|
+
: defaultUserAvatar)
|
|
80
|
+
}
|
|
81
|
+
/>
|
|
82
|
+
</div>
|
|
83
|
+
<div className="info-name">{profile?.nick || profile?.name}</div>
|
|
84
|
+
<div className="info-id">
|
|
85
|
+
ID:
|
|
86
|
+
{profile?.userID || profile?.groupID}
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
<div className="tui-manage-handle">
|
|
90
|
+
<div className="manage-handle-box">
|
|
91
|
+
<div className="manage-handle-title">
|
|
92
|
+
{t('TUIConversation.Pin')}
|
|
93
|
+
</div>
|
|
94
|
+
<Switch onChange={pinChatChange} checked={isPinned} />
|
|
95
|
+
</div>
|
|
96
|
+
{isPC && (
|
|
97
|
+
<div
|
|
98
|
+
className="manage-handle-box"
|
|
99
|
+
role="presentation"
|
|
100
|
+
onClick={handleDelete}
|
|
101
|
+
>
|
|
102
|
+
<div className="manage-handle-title red">
|
|
103
|
+
{t('TUIConversation.Delete')}
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
)}
|
|
107
|
+
</div>
|
|
83
108
|
</div>
|
|
84
109
|
</div>
|
|
85
|
-
|
|
86
|
-
</div>
|
|
110
|
+
)
|
|
87
111
|
);
|
|
88
112
|
}
|