@tencentcloud/chat-uikit-react 1.1.0 → 1.2.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/CHANGELOG.md +6 -0
- package/README.md +8 -8
- package/dist/cjs/_virtual/extends.js +1 -0
- package/dist/cjs/components/Checkbox/index.d.ts +2 -1
- package/dist/cjs/components/ConversationCreate/ConversationCreatGroupDetail.js +1 -1
- package/dist/cjs/components/ConversationCreate/ConversationCreate.js +1 -1
- package/dist/cjs/components/ConversationCreate/ConversationCreateUserSelectList.js +1 -1
- package/dist/cjs/components/ConversationCreate/ConversationGroupTypeInfo.js +1 -1
- package/dist/cjs/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
- 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/ConversationSearchInput.d.ts +2 -1
- package/dist/cjs/components/ConversationSearch/ConversationSearchInput.js +1 -1
- package/dist/cjs/components/ConversationSearch/ConversationSearchResult.js +1 -1
- package/dist/cjs/components/DivWithEdit/DivWithEdit.d.ts +2 -1
- package/dist/cjs/components/EmptyStateIndicator/EmptyStateIndicator.d.ts +2 -1
- package/dist/cjs/components/Icon/Icon.d.ts +2 -1
- package/dist/cjs/components/Icon/config.js +1 -1
- package/dist/cjs/components/Icon/images/add-friend.svg.js +1 -0
- package/dist/cjs/components/Icon/images/down-arrow.png.js +1 -0
- package/dist/cjs/components/Icon/images/right-arrow.svg.js +1 -0
- package/dist/cjs/components/Icon/type.d.ts +2 -1
- package/dist/cjs/components/Icon/type.js +1 -1
- package/dist/cjs/components/Input/Input.d.ts +1 -0
- package/dist/cjs/components/Input/Input.js +1 -1
- package/dist/cjs/components/Plugins/index.d.ts +1 -0
- package/dist/cjs/components/Plugins/index.js +1 -1
- package/dist/cjs/components/Popup/index.d.ts +1 -0
- package/dist/cjs/components/Popup/index.js +1 -1
- package/dist/cjs/components/Switch/Switch.d.ts +2 -1
- package/dist/cjs/components/TUIChat/TUIChat.js +1 -1
- package/dist/cjs/components/TUIChat/hooks/useHandleMessageList.js +1 -1
- package/dist/cjs/components/TUIChatHeader/TUIChatHeaderDefault.js +1 -1
- package/dist/cjs/components/TUIContact/TUIContact.d.ts +6 -0
- package/dist/cjs/components/TUIContact/TUIContact.js +1 -0
- package/dist/cjs/components/TUIContact/TUIContactInfo/TUIContactInfo.d.ts +10 -0
- package/dist/cjs/components/TUIContact/TUIContactInfo/TUIContactInfo.js +1 -0
- package/dist/cjs/components/TUIContact/TUIContactInfo/addFriendInfo.js +1 -0
- package/dist/cjs/components/TUIContact/TUIContactInfo/basicInfo.js +1 -0
- package/dist/cjs/components/TUIContact/TUIContactInfo/blockInfo.js +1 -0
- package/dist/cjs/components/TUIContact/TUIContactInfo/friendApplication.js +1 -0
- package/dist/cjs/components/TUIContact/TUIContactInfo/friendInfo.js +1 -0
- package/dist/cjs/components/TUIContact/TUIContactInfo/hooks/useContactInfo.js +1 -0
- package/dist/cjs/components/TUIContact/TUIContactList/TUIContactList.d.ts +6 -0
- package/dist/cjs/components/TUIContact/TUIContactList/TUIContactList.js +1 -0
- package/dist/cjs/components/TUIContact/hooks/useTUIContact.js +1 -0
- package/dist/cjs/components/TUIContactSearch/TUIContactSearch.js +1 -0
- package/dist/cjs/components/TUIContactSearch/hooks/useContactSearch.js +1 -0
- package/dist/cjs/components/TUIConversationList/TUIConversationList.js +1 -1
- package/dist/cjs/components/TUIKit/TUIKit.d.ts +1 -0
- package/dist/cjs/components/TUIKit/TUIKit.js +1 -1
- package/dist/cjs/components/TUIKit/hooks/useCreateTUIKitContext.d.ts +4 -0
- package/dist/cjs/components/TUIKit/hooks/useCreateTUIKitContext.js +1 -1
- package/dist/cjs/components/TUIKit/hooks/useTUIKit.d.ts +23 -3
- package/dist/cjs/components/TUIKit/hooks/useTUIKit.js +1 -1
- package/dist/cjs/components/TUIManage/TUIManage.d.ts +3 -1
- package/dist/cjs/components/TUIManage/TUIManage.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageContext.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/MessageStatus.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageSystem.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageTip.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/emojiMap.js +1 -1
- package/dist/cjs/components/TUIMessageInput/InputPluginsDefalut.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/useCreateMessageInputContext.js +1 -1
- package/dist/cjs/components/TUIMessageInput/hooks/useEmojiPicker.js +1 -1
- package/dist/cjs/components/TUIMessageList/TUIMessageList.js +1 -1
- package/dist/cjs/components/TUIMessageList/hooks/useMessageListElement.js +1 -1
- package/dist/cjs/components/TUIProfile/TUIProfile.js +1 -1
- package/dist/cjs/components/TUIProfile/TUIProfileDefault.js +1 -1
- package/dist/cjs/components/untils.js +1 -1
- package/dist/cjs/context/ComponentContext.d.ts +2 -1
- package/dist/cjs/context/TUIContactContext.d.ts +18 -0
- package/dist/cjs/context/TUIContactContext.js +1 -0
- package/dist/cjs/context/TUIConversationContext.js +1 -1
- package/dist/cjs/context/TUIKitContext.d.ts +4 -0
- package/dist/cjs/index.css +1 -1
- package/dist/cjs/index.d.css +266 -13
- package/dist/cjs/index.d.ts +5 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/locales/en/TUIChat.js +1 -0
- package/dist/cjs/locales/en/TUIContact.js +1 -0
- package/dist/cjs/locales/en/TUIConversation.js +1 -0
- package/dist/cjs/locales/en/TUIProfile.js +1 -0
- package/dist/cjs/locales/en/index.js +1 -0
- package/dist/cjs/locales/index.js +1 -0
- package/dist/cjs/locales/zh_cn/TUIChat.js +1 -0
- package/dist/cjs/locales/zh_cn/TUIContact.js +1 -0
- package/dist/cjs/locales/zh_cn/TUIConversation.js +1 -0
- package/dist/cjs/locales/zh_cn/TUIProfile.js +1 -0
- package/dist/cjs/locales/zh_cn/index.js +1 -0
- package/dist/esm/_virtual/extends.js +1 -0
- package/dist/esm/components/Checkbox/index.d.ts +2 -1
- package/dist/esm/components/ConversationCreate/ConversationCreatGroupDetail.js +1 -1
- package/dist/esm/components/ConversationCreate/ConversationCreate.js +1 -1
- package/dist/esm/components/ConversationCreate/ConversationCreateUserSelectList.js +1 -1
- package/dist/esm/components/ConversationCreate/ConversationGroupTypeInfo.js +1 -1
- package/dist/esm/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
- 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/ConversationSearchInput.d.ts +2 -1
- package/dist/esm/components/ConversationSearch/ConversationSearchInput.js +1 -1
- package/dist/esm/components/ConversationSearch/ConversationSearchResult.js +1 -1
- package/dist/esm/components/DivWithEdit/DivWithEdit.d.ts +2 -1
- package/dist/esm/components/EmptyStateIndicator/EmptyStateIndicator.d.ts +2 -1
- package/dist/esm/components/Icon/Icon.d.ts +2 -1
- package/dist/esm/components/Icon/config.js +1 -1
- package/dist/esm/components/Icon/images/add-friend.svg.js +1 -0
- package/dist/esm/components/Icon/images/down-arrow.png.js +1 -0
- package/dist/esm/components/Icon/images/right-arrow.svg.js +1 -0
- package/dist/esm/components/Icon/type.d.ts +2 -1
- package/dist/esm/components/Icon/type.js +1 -1
- package/dist/esm/components/Input/Input.d.ts +1 -0
- package/dist/esm/components/Input/Input.js +1 -1
- package/dist/esm/components/Plugins/index.d.ts +1 -0
- package/dist/esm/components/Plugins/index.js +1 -1
- package/dist/esm/components/Popup/index.d.ts +1 -0
- package/dist/esm/components/Popup/index.js +1 -1
- package/dist/esm/components/Switch/Switch.d.ts +2 -1
- package/dist/esm/components/TUIChat/TUIChat.js +1 -1
- package/dist/esm/components/TUIChat/hooks/useHandleMessageList.js +1 -1
- package/dist/esm/components/TUIChatHeader/TUIChatHeaderDefault.js +1 -1
- package/dist/esm/components/TUIContact/TUIContact.d.ts +6 -0
- package/dist/esm/components/TUIContact/TUIContact.js +1 -0
- package/dist/esm/components/TUIContact/TUIContactInfo/TUIContactInfo.d.ts +10 -0
- package/dist/esm/components/TUIContact/TUIContactInfo/TUIContactInfo.js +1 -0
- package/dist/esm/components/TUIContact/TUIContactInfo/addFriendInfo.js +1 -0
- package/dist/esm/components/TUIContact/TUIContactInfo/basicInfo.js +1 -0
- package/dist/esm/components/TUIContact/TUIContactInfo/blockInfo.js +1 -0
- package/dist/esm/components/TUIContact/TUIContactInfo/friendApplication.js +1 -0
- package/dist/esm/components/TUIContact/TUIContactInfo/friendInfo.js +1 -0
- package/dist/esm/components/TUIContact/TUIContactInfo/hooks/useContactInfo.js +1 -0
- package/dist/esm/components/TUIContact/TUIContactList/TUIContactList.d.ts +6 -0
- package/dist/esm/components/TUIContact/TUIContactList/TUIContactList.js +1 -0
- package/dist/esm/components/TUIContact/hooks/useTUIContact.js +1 -0
- package/dist/esm/components/TUIContactSearch/TUIContactSearch.js +1 -0
- package/dist/esm/components/TUIContactSearch/hooks/useContactSearch.js +1 -0
- package/dist/esm/components/TUIConversationList/TUIConversationList.js +1 -1
- package/dist/esm/components/TUIKit/TUIKit.d.ts +1 -0
- package/dist/esm/components/TUIKit/TUIKit.js +1 -1
- package/dist/esm/components/TUIKit/hooks/useCreateTUIKitContext.d.ts +4 -0
- package/dist/esm/components/TUIKit/hooks/useCreateTUIKitContext.js +1 -1
- package/dist/esm/components/TUIKit/hooks/useTUIKit.d.ts +23 -3
- package/dist/esm/components/TUIKit/hooks/useTUIKit.js +1 -1
- package/dist/esm/components/TUIManage/TUIManage.d.ts +3 -1
- package/dist/esm/components/TUIManage/TUIManage.js +1 -1
- package/dist/esm/components/TUIMessage/MessageContext.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/MessageStatus.js +1 -1
- package/dist/esm/components/TUIMessage/MessageSystem.js +1 -1
- package/dist/esm/components/TUIMessage/MessageTip.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/emojiMap.js +1 -1
- package/dist/esm/components/TUIMessageInput/InputPluginsDefalut.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/useCreateMessageInputContext.js +1 -1
- package/dist/esm/components/TUIMessageInput/hooks/useEmojiPicker.js +1 -1
- package/dist/esm/components/TUIMessageList/TUIMessageList.js +1 -1
- package/dist/esm/components/TUIMessageList/hooks/useMessageListElement.js +1 -1
- package/dist/esm/components/TUIProfile/TUIProfile.js +1 -1
- package/dist/esm/components/TUIProfile/TUIProfileDefault.js +1 -1
- package/dist/esm/components/untils.js +1 -1
- package/dist/esm/context/ComponentContext.d.ts +2 -1
- package/dist/esm/context/TUIContactContext.d.ts +18 -0
- package/dist/esm/context/TUIContactContext.js +1 -0
- package/dist/esm/context/TUIConversationContext.js +1 -1
- package/dist/esm/context/TUIKitContext.d.ts +4 -0
- package/dist/esm/index.css +1 -1
- package/dist/esm/index.d.css +266 -13
- package/dist/esm/index.d.ts +5 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/locales/en/TUIChat.js +1 -0
- package/dist/esm/locales/en/TUIContact.js +1 -0
- package/dist/esm/locales/en/TUIConversation.js +1 -0
- package/dist/esm/locales/en/TUIProfile.js +1 -0
- package/dist/esm/locales/en/index.js +1 -0
- package/dist/esm/locales/index.js +1 -0
- package/dist/esm/locales/zh_cn/TUIChat.js +1 -0
- package/dist/esm/locales/zh_cn/TUIContact.js +1 -0
- package/dist/esm/locales/zh_cn/TUIConversation.js +1 -0
- package/dist/esm/locales/zh_cn/TUIProfile.js +1 -0
- package/dist/esm/locales/zh_cn/index.js +1 -0
- package/package.json +5 -1
- package/src/components/ConversationCreate/ConversationCreatGroupDetail.tsx +10 -8
- package/src/components/ConversationCreate/ConversationCreate.tsx +4 -1
- package/src/components/ConversationCreate/ConversationCreateUserSelectList.tsx +6 -4
- package/src/components/ConversationCreate/ConversationGroupTypeInfo.tsx +7 -3
- package/src/components/ConversationCreate/hooks/useConversationCreate.tsx +0 -1
- package/src/components/ConversationPreview/ConversationPreview.tsx +6 -5
- package/src/components/ConversationPreview/ConversationPreviewContent.tsx +4 -2
- package/src/components/ConversationPreview/utils.tsx +12 -27
- package/src/components/ConversationSearch/ConversationSearchInput.tsx +3 -1
- package/src/components/Icon/config.ts +5 -0
- package/src/components/Icon/images/add-friend.svg +15 -0
- package/src/components/Icon/images/down-arrow.png +0 -0
- package/src/components/Icon/images/right-arrow.svg +3 -0
- package/src/components/Icon/styles/index.scss +0 -1
- package/src/components/Icon/type.ts +1 -0
- package/src/components/Input/Input.tsx +11 -2
- package/src/components/Plugins/index.tsx +26 -2
- package/src/components/Popup/index.tsx +20 -2
- package/src/components/TUIChat/hooks/useHandleMessageList.tsx +3 -8
- package/src/components/TUIChatHeader/TUIChatHeaderDefault.tsx +3 -3
- package/src/components/TUIContact/TUIContact.tsx +96 -0
- package/src/components/TUIContact/TUIContactInfo/TUIContactInfo.tsx +32 -0
- package/src/components/TUIContact/TUIContactInfo/addFriendInfo.tsx +86 -0
- package/src/components/TUIContact/TUIContactInfo/basicInfo.tsx +34 -0
- package/src/components/TUIContact/TUIContactInfo/blockInfo.tsx +45 -0
- package/src/components/TUIContact/TUIContactInfo/friendApplication.tsx +66 -0
- package/src/components/TUIContact/TUIContactInfo/friendInfo.tsx +103 -0
- package/src/components/TUIContact/TUIContactInfo/hooks/useContactInfo.tsx +112 -0
- package/src/components/TUIContact/TUIContactInfo/index.scss +108 -0
- package/src/components/TUIContact/TUIContactList/TUIContactList.tsx +162 -0
- package/src/components/TUIContact/TUIContactList/index.scss +90 -0
- package/src/components/TUIContact/hooks/useTUIContact.tsx +76 -0
- package/src/components/TUIContact/index.scss +67 -0
- package/src/components/TUIContact/index.ts +3 -0
- package/src/components/TUIContactSearch/TUIContactSearch.tsx +100 -0
- package/src/components/TUIContactSearch/hooks/useContactSearch.tsx +32 -0
- package/src/components/TUIContactSearch/index.scss +24 -0
- package/src/components/TUIConversationList/TUIConversationList.tsx +3 -4
- package/src/components/TUIConversationList/index.scss +2 -2
- package/src/components/TUIKit/TUIKit.tsx +9 -2
- package/src/components/TUIKit/hooks/useCreateTUIKitContext.tsx +8 -0
- package/src/components/TUIKit/hooks/useTUIKit.tsx +43 -4
- package/src/components/TUIManage/TUIManage.tsx +5 -3
- package/src/components/TUIMessage/MessagePlugins.tsx +17 -7
- package/src/components/TUIMessage/MessageRevoke.tsx +5 -4
- package/src/components/TUIMessage/MessageStatus.tsx +3 -3
- package/src/components/TUIMessage/hooks/useMessageHandler.ts +4 -2
- package/src/components/TUIMessage/styles/layout.scss +2 -9
- package/src/components/TUIMessage/utils/emojiMap.ts +6 -2
- package/src/components/TUIMessageInput/InputPluginsDefalut.tsx +5 -3
- package/src/components/TUIMessageInput/TUIForward.tsx +8 -27
- package/src/components/TUIMessageInput/TUIMessageInputDefault.tsx +3 -1
- package/src/components/TUIMessageInput/hooks/useCreateMessageInputContext.ts +3 -3
- package/src/components/TUIMessageInput/hooks/useEmojiPicker.tsx +7 -1
- package/src/components/TUIMessageInput/styles/layout.scss +0 -1
- package/src/components/TUIMessageList/TUIMessageList.tsx +3 -1
- package/src/components/TUIMessageList/hooks/useMessageListElement.tsx +3 -2
- package/src/components/TUIProfile/TUIProfile.tsx +18 -7
- package/src/components/TUIProfile/TUIProfileDefault.tsx +64 -6
- package/src/components/TUIProfile/styles/layout.scss +1 -1
- package/src/components/index.ts +1 -0
- package/src/components/untils.ts +26 -6
- package/src/context/TUIContactContext.tsx +32 -0
- package/src/context/TUIKitContext.tsx +5 -0
- package/src/context/index.ts +1 -0
- package/src/hooks/useConversation.tsx +3 -3
- package/src/locales/en/TUIChat.ts +27 -0
- package/src/locales/en/TUIContact.ts +28 -0
- package/src/locales/en/TUIConversation.ts +34 -0
- package/src/locales/en/TUIProfile.ts +14 -0
- package/src/locales/en/index.ts +11 -0
- package/src/locales/index.ts +23 -0
- package/src/locales/zh_cn/TUIChat.ts +27 -0
- package/src/locales/zh_cn/TUIContact.ts +29 -0
- package/src/locales/zh_cn/TUIConversation.ts +33 -0
- package/src/locales/zh_cn/TUIProfile.ts +14 -0
- package/src/locales/zh_cn/index.ts +11 -0
- package/tsconfig.json +1 -0
|
@@ -41,24 +41,25 @@ export function ConversationPreview<T extends ConversationPreviewProps>(
|
|
|
41
41
|
searchValue,
|
|
42
42
|
conversationUpdateCount,
|
|
43
43
|
} = props;
|
|
44
|
+
const { language } = useTUIKitContext('TUIConversation');
|
|
44
45
|
const {
|
|
45
46
|
setActiveConversation,
|
|
46
47
|
myProfile,
|
|
47
48
|
} = useTUIKitContext('ConversationPreview');
|
|
48
49
|
const [displayImage, setDisplayImage] = useState(getDisplayImage(conversation));
|
|
49
50
|
const [displayTitle, setDisplayTitle] = useState(getDisplayTitle(conversation, searchValue));
|
|
50
|
-
const [displayMessage, setDisplayMessage] = useState(getDisplayMessage(conversation, myProfile));
|
|
51
|
-
const [displayTime, setDisplayTime] = useState(getDisplayTime(conversation));
|
|
51
|
+
const [displayMessage, setDisplayMessage] = useState(getDisplayMessage(conversation, myProfile, language));
|
|
52
|
+
const [displayTime, setDisplayTime] = useState(getDisplayTime(conversation, language));
|
|
52
53
|
const [unread, setUnread] = useState(conversation.unreadCount);
|
|
53
54
|
const isActive = activeConversation?.conversationID === conversation?.conversationID;
|
|
54
55
|
if (!Preview) return null;
|
|
55
56
|
useEffect(() => {
|
|
56
57
|
setDisplayTitle(getDisplayTitle(conversation, searchValue));
|
|
57
|
-
setDisplayMessage(getDisplayMessage(conversation, myProfile));
|
|
58
|
+
setDisplayMessage(getDisplayMessage(conversation, myProfile, language));
|
|
58
59
|
setDisplayImage(getDisplayImage(conversation));
|
|
59
|
-
setDisplayTime(getDisplayTime(conversation));
|
|
60
|
+
setDisplayTime(getDisplayTime(conversation, language));
|
|
60
61
|
setUnread(conversation.unreadCount);
|
|
61
|
-
}, [conversation, searchValue, conversationUpdateCount]);
|
|
62
|
+
}, [conversation, searchValue, conversationUpdateCount, language]);
|
|
62
63
|
|
|
63
64
|
return (
|
|
64
65
|
<Preview
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useRef, useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
2
3
|
import { ConversationPreviewUIComponentProps } from './ConversationPreview';
|
|
3
4
|
import { Avatar as DefaultAvatar } from '../Avatar/index';
|
|
4
5
|
import './styles/index.scss';
|
|
@@ -22,6 +23,7 @@ export function unMemoConversationPreviewContent<T extends ConversationPreviewUI
|
|
|
22
23
|
setActiveConversation,
|
|
23
24
|
} = props;
|
|
24
25
|
|
|
26
|
+
const { t } = useTranslation();
|
|
25
27
|
const conversationPreviewButton = useRef<HTMLButtonElement | null>(null);
|
|
26
28
|
const activeClass = active ? 'conversation-preview-content--active' : '';
|
|
27
29
|
const unreadClass = unread && unread >= 1 ? 'conversation-preview-content--unread' : '';
|
|
@@ -101,7 +103,7 @@ export function unMemoConversationPreviewContent<T extends ConversationPreviewUI
|
|
|
101
103
|
moreHandle('pin');
|
|
102
104
|
}}
|
|
103
105
|
>
|
|
104
|
-
{!conversation.isPinned ? 'Pin' : '
|
|
106
|
+
{t(!conversation.isPinned ? 'TUIConversation.Pin' : 'TUIConversation.Unpin')}
|
|
105
107
|
</div>,
|
|
106
108
|
<div
|
|
107
109
|
className="more-handle-item"
|
|
@@ -112,7 +114,7 @@ export function unMemoConversationPreviewContent<T extends ConversationPreviewUI
|
|
|
112
114
|
}}
|
|
113
115
|
role="presentation"
|
|
114
116
|
>
|
|
115
|
-
Delete
|
|
117
|
+
{t('TUIConversation.Delete')}
|
|
116
118
|
</div>,
|
|
117
119
|
]}
|
|
118
120
|
showNumber={0}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
format, isToday, isYesterday, formatDistance, isThisYear, isThisWeek,
|
|
3
|
-
} from 'date-fns';
|
|
4
1
|
import React from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
5
3
|
import TencentCloudChat, { Conversation, Group, Profile } from '@tencentcloud/chat';
|
|
6
4
|
import { defaultGroupAvatarWork, defaultUserAvatar } from '../Avatar';
|
|
7
5
|
import { formatEmojiString } from '../TUIMessage/utils/emojiMap';
|
|
6
|
+
import { getTimeStamp } from '../untils';
|
|
8
7
|
|
|
9
8
|
export const getDisplayTitle = (
|
|
10
9
|
conversation: Conversation,
|
|
@@ -14,11 +13,11 @@ export const getDisplayTitle = (
|
|
|
14
13
|
const {
|
|
15
14
|
name, nick, groupID, userID,
|
|
16
15
|
} = getMessageProfile(conversation);
|
|
17
|
-
const { type } = conversation;
|
|
16
|
+
const { type, remark } = conversation;
|
|
18
17
|
let title = '';
|
|
19
18
|
switch (type) {
|
|
20
19
|
case TencentCloudChat.TYPES.CONV_C2C:
|
|
21
|
-
title = nick || userID;
|
|
20
|
+
title = remark || nick || userID;
|
|
22
21
|
break;
|
|
23
22
|
case TencentCloudChat.TYPES.CONV_GROUP:
|
|
24
23
|
title = name || groupID;
|
|
@@ -57,7 +56,11 @@ export const getDisplayImage = (conversation: Conversation) => {
|
|
|
57
56
|
}
|
|
58
57
|
return displayImage;
|
|
59
58
|
};
|
|
60
|
-
export const getDisplayMessage = (
|
|
59
|
+
export const getDisplayMessage = (
|
|
60
|
+
conversation:Conversation,
|
|
61
|
+
myProfile:Profile,
|
|
62
|
+
language?:string,
|
|
63
|
+
) => {
|
|
61
64
|
const { lastMessage, type } = conversation;
|
|
62
65
|
const {
|
|
63
66
|
fromAccount, nick, nameCard, isRevoked,
|
|
@@ -81,7 +84,7 @@ export const getDisplayMessage = (conversation:Conversation, myProfile:Profile)
|
|
|
81
84
|
}}
|
|
82
85
|
>
|
|
83
86
|
<span>{from}</span>
|
|
84
|
-
<span>{lastMessage.isRevoked ? 'recalled a message' : formatEmojiString(lastMessage.messageForShow, 1)}</span>
|
|
87
|
+
<span>{lastMessage.isRevoked ? 'recalled a message' : formatEmojiString(lastMessage.messageForShow, 1, language)}</span>
|
|
85
88
|
</div>
|
|
86
89
|
);
|
|
87
90
|
};
|
|
@@ -102,25 +105,7 @@ export const getMessageProfile = (conversation: Conversation):TProfile => {
|
|
|
102
105
|
}
|
|
103
106
|
return result as TProfile;
|
|
104
107
|
};
|
|
105
|
-
export const getDisplayTime = (conversation: Conversation) => {
|
|
108
|
+
export const getDisplayTime = (conversation: Conversation, language?: string) => {
|
|
106
109
|
const { lastMessage } = conversation;
|
|
107
|
-
return getTimeStamp(lastMessage.lastTime * 1000);
|
|
108
|
-
};
|
|
109
|
-
export const getTimeStamp = (time: number) => {
|
|
110
|
-
if (!time) {
|
|
111
|
-
return '';
|
|
112
|
-
}
|
|
113
|
-
if (!isThisYear(time)) {
|
|
114
|
-
return format(time, 'yyyy MMM dd');
|
|
115
|
-
}
|
|
116
|
-
if (isToday(time)) {
|
|
117
|
-
return format(time, 'p');
|
|
118
|
-
}
|
|
119
|
-
if (isYesterday(time)) {
|
|
120
|
-
return formatDistance(time, new Date());
|
|
121
|
-
}
|
|
122
|
-
if (isThisWeek(time)) {
|
|
123
|
-
return format(time, 'eeee');
|
|
124
|
-
}
|
|
125
|
-
return format(time, 'MMM dd');
|
|
110
|
+
return getTimeStamp(lastMessage.lastTime * 1000, language);
|
|
126
111
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useState, useEffect, InputHTMLAttributes } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
2
3
|
import './styles/index.scss';
|
|
3
4
|
import { Icon, IconTypes } from '../Icon';
|
|
4
5
|
import { Input, InputProps } from '../Input';
|
|
@@ -12,10 +13,11 @@ export function ConversationSearchInput(props:InputProps) {
|
|
|
12
13
|
onChange: handleChange,
|
|
13
14
|
prefix = <Icon type={IconTypes.SEARCH} height={16} width={16} />,
|
|
14
15
|
} = props;
|
|
16
|
+
const { t } = useTranslation();
|
|
15
17
|
return (
|
|
16
18
|
<Input
|
|
17
19
|
className={`conversation-search-input ${className}`}
|
|
18
|
-
placeholder={placeholder || 'Search'}
|
|
20
|
+
placeholder={placeholder || t('TUIConversation.Search')}
|
|
19
21
|
clearable={clearable}
|
|
20
22
|
value={value}
|
|
21
23
|
onChange={handleChange}
|
|
@@ -41,6 +41,7 @@ import IconUnunionUrl from './images/ununion.png';
|
|
|
41
41
|
import IconVectorUrl from './images/vector.png';
|
|
42
42
|
import IconUnvectorUrl from './images/unvector.png';
|
|
43
43
|
import IconVoiceUrl from './images/voice.png';
|
|
44
|
+
import IconAddFriendUrl from './images/add-friend.svg';
|
|
44
45
|
|
|
45
46
|
import { IconTypes } from './type';
|
|
46
47
|
|
|
@@ -226,4 +227,8 @@ export const ICON_CONFIG:IconConfig = {
|
|
|
226
227
|
url: IconVoiceUrl,
|
|
227
228
|
className: 'tui-kit-icon-voice',
|
|
228
229
|
},
|
|
230
|
+
[IconTypes.ADDFRIEND]: {
|
|
231
|
+
url: IconAddFriendUrl,
|
|
232
|
+
className: 'tui-kit-icon-add-friend',
|
|
233
|
+
},
|
|
229
234
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g clip-path="url(#clip0_4042_40004)">
|
|
3
|
+
<mask id="path-1-inside-1_4042_40004" fill="white">
|
|
4
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.6893 17.8913C21.131 16.1584 21.998 13.9304 21.998 11.5C21.998 5.97715 17.5209 1.5 11.998 1.5C6.4752 1.5 1.99805 5.97715 1.99805 11.5C1.99805 17.0228 6.4752 21.5 11.998 21.5C14.1036 21.5 16.0571 20.8493 17.6686 19.738C17.6858 19.7471 17.7041 19.7551 17.7233 19.7619L19.9382 20.5463C20.2554 20.6587 20.5611 20.3529 20.4488 20.0357L19.6893 17.8913Z"/>
|
|
5
|
+
</mask>
|
|
6
|
+
<path d="M19.6893 17.8913L18.5362 16.932L17.9906 17.5879L18.2754 18.3921L19.6893 17.8913ZM17.6686 19.738L18.3687 18.4114L17.5651 17.9872L16.817 18.5031L17.6686 19.738ZM17.7233 19.7619L17.2226 21.1759H17.2226L17.7233 19.7619ZM19.9382 20.5463L20.4389 19.1324L19.9382 20.5463ZM20.4488 20.0357L19.0348 20.5365L20.4488 20.0357ZM20.498 11.5C20.498 13.5672 19.762 15.4585 18.5362 16.932L20.8425 18.8506C22.5 16.8582 23.498 14.2937 23.498 11.5H20.498ZM11.998 3C16.6925 3 20.498 6.80558 20.498 11.5H23.498C23.498 5.14873 18.3493 0 11.998 0V3ZM3.49805 11.5C3.49805 6.80558 7.30363 3 11.998 3V0C5.64677 0 0.498047 5.14873 0.498047 11.5H3.49805ZM11.998 20C7.30363 20 3.49805 16.1944 3.49805 11.5H0.498047C0.498047 17.8513 5.64677 23 11.998 23V20ZM16.817 18.5031C15.4479 19.4473 13.7898 20 11.998 20V23C14.4174 23 16.6663 22.2512 18.5201 20.9728L16.817 18.5031ZM18.2241 18.348C18.2732 18.3654 18.3216 18.3865 18.3687 18.4114L16.9684 21.0645C17.0501 21.1076 17.135 21.1448 17.2226 21.1759L18.2241 18.348ZM20.4389 19.1324L18.2241 18.348L17.2226 21.1759L19.4374 21.9603L20.4389 19.1324ZM19.0348 20.5365C18.7259 19.6641 19.5666 18.8234 20.4389 19.1324L19.4374 21.9603C20.9442 22.4939 22.3964 21.0417 21.8627 19.535L19.0348 20.5365ZM18.2754 18.3921L19.0348 20.5365L21.8627 19.535L21.1033 17.3906L18.2754 18.3921Z" fill="#147AFF" style="fill:#147AFF;fill:color(display-p3 0.0784 0.4784 1.0000);fill-opacity:1;" mask="url(#path-1-inside-1_4042_40004)"/>
|
|
7
|
+
<path d="M8 11.5H16" stroke="#147AFF" style="stroke:#147AFF;stroke:color(display-p3 0.0784 0.4784 1.0000);stroke-opacity:1;" stroke-width="1.5" stroke-linecap="round"/>
|
|
8
|
+
<path d="M12 15.5L12 7.5" stroke="#147AFF" style="stroke:#147AFF;stroke:color(display-p3 0.0784 0.4784 1.0000);stroke-opacity:1;" stroke-width="1.5" stroke-linecap="round"/>
|
|
9
|
+
</g>
|
|
10
|
+
<defs>
|
|
11
|
+
<clipPath id="clip0_4042_40004">
|
|
12
|
+
<rect width="24" height="24" fill="white" style="fill:white;fill:white;fill-opacity:1;"/>
|
|
13
|
+
</clipPath>
|
|
14
|
+
</defs>
|
|
15
|
+
</svg>
|
|
Binary file
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="6" height="10" viewBox="0 0 6 10" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M1.69071 0.283877C1.5751 0.169695 1.42795 0.107415 1.25453 0.107415C0.907683 0.107415 0.629156 0.377298 0.629156 0.719841C0.629156 0.891113 0.702729 1.04681 0.823599 1.16619L4.50226 4.71618L0.8236 8.2558C0.70273 8.37518 0.629157 8.53607 0.629157 8.70215C0.629157 9.04469 0.907684 9.31458 1.25453 9.31458C1.42795 9.31458 1.5751 9.25229 1.69071 9.13811L5.77928 5.19367C5.92643 5.05873 5.99474 4.89265 6 4.71099C6 4.52934 5.92643 4.37364 5.77928 4.23351L1.69071 0.283877Z" fill="black" style="fill:black;fill:black;fill-opacity:1;"/>
|
|
3
|
+
</svg>
|
|
@@ -16,7 +16,8 @@ export interface InputProps
|
|
|
16
16
|
value?: InputHTMLAttributes<HTMLInputElement>['value'],
|
|
17
17
|
border?: '' | 'bottom',
|
|
18
18
|
disabled?: boolean,
|
|
19
|
-
maxLength?: number
|
|
19
|
+
maxLength?: number,
|
|
20
|
+
onKeyDown?: (options?: object) => void
|
|
20
21
|
}
|
|
21
22
|
export interface InputRef {
|
|
22
23
|
focus: (options?: object) => void;
|
|
@@ -35,6 +36,7 @@ export const Input = React.forwardRef<InputRef, InputProps>(
|
|
|
35
36
|
onChange,
|
|
36
37
|
onBlur,
|
|
37
38
|
onFocus,
|
|
39
|
+
onKeyDown,
|
|
38
40
|
value: propsValue = '',
|
|
39
41
|
border = '',
|
|
40
42
|
disabled = false,
|
|
@@ -42,7 +44,7 @@ export const Input = React.forwardRef<InputRef, InputProps>(
|
|
|
42
44
|
} = props;
|
|
43
45
|
|
|
44
46
|
const [focused, setFocused] = useState<boolean>(false);
|
|
45
|
-
|
|
47
|
+
const enterCodeList = ['Enter', 'NumpadEnter'];
|
|
46
48
|
const [value, setValue] = useState(propsValue);
|
|
47
49
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
48
50
|
const handleFocus = (e) => {
|
|
@@ -53,6 +55,12 @@ export const Input = React.forwardRef<InputRef, InputProps>(
|
|
|
53
55
|
setFocused(false);
|
|
54
56
|
onBlur?.(e);
|
|
55
57
|
};
|
|
58
|
+
const handleEnterKeyDown = (e) => {
|
|
59
|
+
if (enterCodeList.indexOf(e?.key) > -1 && onKeyDown) {
|
|
60
|
+
e?.preventDefault();
|
|
61
|
+
onKeyDown(e);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
56
64
|
const clearInput = (e: React.MouseEvent<HTMLElement, MouseEvent>) => {
|
|
57
65
|
setValue('');
|
|
58
66
|
focus();
|
|
@@ -97,6 +105,7 @@ export const Input = React.forwardRef<InputRef, InputProps>(
|
|
|
97
105
|
onFocus={handleFocus}
|
|
98
106
|
onBlur={handleBlur}
|
|
99
107
|
onChange={handleChange}
|
|
108
|
+
onKeyDown={handleEnterKeyDown}
|
|
100
109
|
/>
|
|
101
110
|
{suffix}
|
|
102
111
|
{(clearable && value)
|
|
@@ -14,6 +14,7 @@ export interface PluginsProps {
|
|
|
14
14
|
MoreIcon?: any,
|
|
15
15
|
className?: string,
|
|
16
16
|
customClass?: string,
|
|
17
|
+
style?: any,
|
|
17
18
|
root?: any,
|
|
18
19
|
handleVisible?: (isVisible:any) => void,
|
|
19
20
|
showMore?: boolean,
|
|
@@ -28,6 +29,7 @@ function PluginsWithContext<T extends PluginsProps>(
|
|
|
28
29
|
showNumber,
|
|
29
30
|
MoreIcon,
|
|
30
31
|
className = '',
|
|
32
|
+
style,
|
|
31
33
|
customClass = '',
|
|
32
34
|
root,
|
|
33
35
|
handleVisible,
|
|
@@ -40,12 +42,33 @@ function PluginsWithContext<T extends PluginsProps>(
|
|
|
40
42
|
}));
|
|
41
43
|
|
|
42
44
|
const { showPicker, elements } = usePluginsElement({ plugins, showNumber });
|
|
45
|
+
const pluginRef = useRef(null);
|
|
43
46
|
|
|
44
47
|
const [show, setShow] = useState(false);
|
|
45
48
|
|
|
46
49
|
const handleShow = (e) => {
|
|
47
50
|
e.stopPropagation();
|
|
48
51
|
setShow(!show);
|
|
52
|
+
if (!show) {
|
|
53
|
+
pluginRef.current.offsetParent.removeEventListener('scroll', handleShow);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const pluginHandleVisible = (data) => {
|
|
58
|
+
if (handleVisible) {
|
|
59
|
+
const {
|
|
60
|
+
width, height,
|
|
61
|
+
} = pluginRef.current.children[1].getBoundingClientRect();
|
|
62
|
+
const { x = 0, y = 0 } = pluginRef.current.getBoundingClientRect();
|
|
63
|
+
pluginRef.current.offsetParent.addEventListener('scroll', handleShow);
|
|
64
|
+
handleVisible({
|
|
65
|
+
...data,
|
|
66
|
+
width,
|
|
67
|
+
height,
|
|
68
|
+
x,
|
|
69
|
+
y,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
49
72
|
};
|
|
50
73
|
|
|
51
74
|
return (
|
|
@@ -61,7 +84,7 @@ function PluginsWithContext<T extends PluginsProps>(
|
|
|
61
84
|
})}
|
|
62
85
|
{
|
|
63
86
|
elements?.length > 0 && (
|
|
64
|
-
<div className="plugin-popup">
|
|
87
|
+
<div className="plugin-popup" ref={pluginRef}>
|
|
65
88
|
<div role="menuitem" tabIndex={0} className="more" onClick={handleShow}>
|
|
66
89
|
{
|
|
67
90
|
!MoreIcon && <Icon width={20} height={20} type={IconTypes.ADD} />
|
|
@@ -72,10 +95,11 @@ function PluginsWithContext<T extends PluginsProps>(
|
|
|
72
95
|
</div>
|
|
73
96
|
<Popup
|
|
74
97
|
className={`plugin-popup-box ${customClass}`}
|
|
98
|
+
style={style}
|
|
75
99
|
show={show}
|
|
76
100
|
close={handleShow}
|
|
77
101
|
root={root}
|
|
78
|
-
handleVisible={
|
|
102
|
+
handleVisible={pluginHandleVisible}
|
|
79
103
|
>
|
|
80
104
|
<ul>
|
|
81
105
|
{elements.map((Item, index:number) => {
|
|
@@ -4,6 +4,7 @@ import './styles/index.scss';
|
|
|
4
4
|
|
|
5
5
|
interface PopupProps {
|
|
6
6
|
className?: string,
|
|
7
|
+
style?: any,
|
|
7
8
|
show?: boolean,
|
|
8
9
|
close?: (e) => void,
|
|
9
10
|
root?: any,
|
|
@@ -18,6 +19,7 @@ T extends PopupProps
|
|
|
18
19
|
close,
|
|
19
20
|
children,
|
|
20
21
|
className,
|
|
22
|
+
style,
|
|
21
23
|
root,
|
|
22
24
|
handleVisible,
|
|
23
25
|
} = props;
|
|
@@ -42,11 +44,27 @@ T extends PopupProps
|
|
|
42
44
|
|
|
43
45
|
useLayoutEffect(() => {
|
|
44
46
|
const io = new IntersectionObserver(([change]) => {
|
|
45
|
-
const {
|
|
47
|
+
const {
|
|
48
|
+
boundingClientRect: changeBoundingClientRec,
|
|
49
|
+
rootBounds: changeRootBounds,
|
|
50
|
+
intersectionRatio,
|
|
51
|
+
} = change;
|
|
52
|
+
const popupBoundingClientRect = popup.current.getBoundingClientRect() || {};
|
|
53
|
+
const rootRootBounds = root?.getBoundingClientRect() || {};
|
|
54
|
+
const boundingClientRect = {
|
|
55
|
+
...changeBoundingClientRec,
|
|
56
|
+
...popupBoundingClientRect,
|
|
57
|
+
};
|
|
58
|
+
const rootBounds = {
|
|
59
|
+
...changeRootBounds,
|
|
60
|
+
...rootRootBounds,
|
|
61
|
+
};
|
|
46
62
|
if (handleVisible && intersectionRatio < 1) {
|
|
47
63
|
handleVisible({
|
|
48
64
|
left: (boundingClientRect.left - boundingClientRect.width) < rootBounds.left,
|
|
49
65
|
top: (boundingClientRect.bottom + boundingClientRect.height) < rootBounds.bottom,
|
|
66
|
+
width: boundingClientRect.width,
|
|
67
|
+
height: boundingClientRect.height,
|
|
50
68
|
});
|
|
51
69
|
}
|
|
52
70
|
setIsSetPos(true);
|
|
@@ -69,7 +87,7 @@ T extends PopupProps
|
|
|
69
87
|
};
|
|
70
88
|
|
|
71
89
|
return show && (
|
|
72
|
-
<div role="button" tabIndex={0} className={`popup ${className} ${isSetPos && 'popup-show'}`} ref={popup}>
|
|
90
|
+
<div role="button" tabIndex={0} style={style} className={`popup ${className} ${isSetPos && 'popup-show'}`} ref={popup}>
|
|
73
91
|
{children}
|
|
74
92
|
</div>
|
|
75
93
|
);
|
|
@@ -33,16 +33,11 @@ export function useHandleMessageList<T extends CreateMessageProps>(props:T) {
|
|
|
33
33
|
|
|
34
34
|
const getMessageList = useCallback(async (params?: GetMessageListProps) => {
|
|
35
35
|
const data = params || {};
|
|
36
|
-
let groupType
|
|
36
|
+
let groupType;
|
|
37
37
|
if (groupProfile) {
|
|
38
|
-
|
|
39
|
-
const res = await chat.searchGroupByID(groupProfile.groupID);
|
|
40
|
-
groupType = res?.data?.group?.type;
|
|
41
|
-
} catch (error) {
|
|
42
|
-
groupType = '';
|
|
43
|
-
}
|
|
38
|
+
groupType = groupProfile.type;
|
|
44
39
|
}
|
|
45
|
-
if (isC2CConversation || (groupType
|
|
40
|
+
if (isC2CConversation || (groupType !== TencentCloudChat.TYPES.GRP_AVCHATROOM)) {
|
|
46
41
|
return chat.getMessageList({
|
|
47
42
|
...basicConfig,
|
|
48
43
|
...data,
|
|
@@ -42,7 +42,7 @@ function TUIChatHeaderDefaultWithContext <T extends TUIChatHeaderBasicProps>(
|
|
|
42
42
|
}
|
|
43
43
|
switch (conversation?.type) {
|
|
44
44
|
case TencentCloudChat.TYPES.CONV_C2C:
|
|
45
|
-
handleC2C(conversation.userProfile);
|
|
45
|
+
handleC2C(conversation.userProfile, conversation?.remark);
|
|
46
46
|
break;
|
|
47
47
|
case TencentCloudChat.TYPES.CONV_GROUP:
|
|
48
48
|
handleGroup(conversation.groupProfile);
|
|
@@ -56,9 +56,9 @@ function TUIChatHeaderDefaultWithContext <T extends TUIChatHeaderBasicProps>(
|
|
|
56
56
|
}
|
|
57
57
|
}, [conversation]);
|
|
58
58
|
|
|
59
|
-
const handleC2C = (userProfile: Profile) => {
|
|
59
|
+
const handleC2C = (userProfile: Profile, remark?: string) => {
|
|
60
60
|
if (!title) {
|
|
61
|
-
setTitle(userProfile?.nick || userProfile?.userID);
|
|
61
|
+
setTitle(remark || userProfile?.nick || userProfile?.userID);
|
|
62
62
|
}
|
|
63
63
|
if (!propAvatar) {
|
|
64
64
|
setAvatar(<Avatar size={32} image={handleDisplayAvatar(userProfile.avatar)} />);
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React, { PropsWithChildren, useMemo, useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import {
|
|
4
|
+
TUIContactContextProvider,
|
|
5
|
+
TUIContactContextValue,
|
|
6
|
+
} from '../../context/TUIContactContext';
|
|
7
|
+
import { useTUIKitContext } from '../../context';
|
|
8
|
+
import useTUIContact from './hooks/useTUIContact';
|
|
9
|
+
import { TUIContactList } from './TUIContactList/TUIContactList';
|
|
10
|
+
import { TUIContactSearch } from '../TUIContactSearch/TUIContactSearch';
|
|
11
|
+
import { Icon, IconTypes } from '../Icon';
|
|
12
|
+
import './index.scss';
|
|
13
|
+
|
|
14
|
+
export function UnMemoizedTUIContact<T>(
|
|
15
|
+
props: PropsWithChildren<T>,
|
|
16
|
+
): React.ReactElement {
|
|
17
|
+
const { children } = props;
|
|
18
|
+
const { t } = useTranslation();
|
|
19
|
+
const { setActiveContact } = useTUIKitContext('TUIContact');
|
|
20
|
+
const [isShowAddFriend, setShowAddFriend] = useState(false);
|
|
21
|
+
const addFriend = () => {
|
|
22
|
+
setActiveContact();
|
|
23
|
+
setShowAddFriend(true);
|
|
24
|
+
};
|
|
25
|
+
const addFriendBack = () => {
|
|
26
|
+
setActiveContact();
|
|
27
|
+
setShowAddFriend(false);
|
|
28
|
+
};
|
|
29
|
+
const {
|
|
30
|
+
friendList,
|
|
31
|
+
blockList,
|
|
32
|
+
blocklistProfile,
|
|
33
|
+
friendApplicationList,
|
|
34
|
+
isShowContactList,
|
|
35
|
+
setShowContactList,
|
|
36
|
+
} = useTUIContact();
|
|
37
|
+
|
|
38
|
+
const TUIContactValue: TUIContactContextValue = useMemo(
|
|
39
|
+
() => ({
|
|
40
|
+
friendList,
|
|
41
|
+
blockList,
|
|
42
|
+
blocklistProfile,
|
|
43
|
+
friendApplicationList,
|
|
44
|
+
isShowContactList,
|
|
45
|
+
setShowContactList,
|
|
46
|
+
}),
|
|
47
|
+
[
|
|
48
|
+
friendList,
|
|
49
|
+
blocklistProfile,
|
|
50
|
+
friendApplicationList,
|
|
51
|
+
isShowContactList,
|
|
52
|
+
setShowContactList,
|
|
53
|
+
],
|
|
54
|
+
);
|
|
55
|
+
return (
|
|
56
|
+
<TUIContactContextProvider value={TUIContactValue}>
|
|
57
|
+
{children || (
|
|
58
|
+
<div className="tui-contacts">
|
|
59
|
+
{!isShowAddFriend && (
|
|
60
|
+
<>
|
|
61
|
+
<div className="tui-contacts-header">
|
|
62
|
+
<div className="tui-contact-input">
|
|
63
|
+
<TUIContactSearch />
|
|
64
|
+
</div>
|
|
65
|
+
<Icon
|
|
66
|
+
onClick={addFriend}
|
|
67
|
+
type={IconTypes.ADDFRIEND}
|
|
68
|
+
width={24}
|
|
69
|
+
height={24}
|
|
70
|
+
/>
|
|
71
|
+
</div>
|
|
72
|
+
<TUIContactList />
|
|
73
|
+
</>
|
|
74
|
+
)}
|
|
75
|
+
{isShowAddFriend && (
|
|
76
|
+
<>
|
|
77
|
+
<div className="tui-contacts-add-header">
|
|
78
|
+
<Icon
|
|
79
|
+
onClick={addFriendBack}
|
|
80
|
+
type={IconTypes.BACK}
|
|
81
|
+
width={9}
|
|
82
|
+
height={16}
|
|
83
|
+
/>
|
|
84
|
+
<div className="tui-contacts-add-header-title">
|
|
85
|
+
{t('TUIContact.Add Friend')}
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
<TUIContactSearch />
|
|
89
|
+
</>
|
|
90
|
+
)}
|
|
91
|
+
</div>
|
|
92
|
+
)}
|
|
93
|
+
</TUIContactContextProvider>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
export const TUIContact = React.memo(UnMemoizedTUIContact);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
PropsWithChildren,
|
|
3
|
+
} from 'react';
|
|
4
|
+
import { useTUIKitContext } from '../../../context';
|
|
5
|
+
import { FriendInfo } from './friendInfo';
|
|
6
|
+
import { BlockInfo } from './blockInfo';
|
|
7
|
+
import { AddFriendInfo } from './addFriendInfo';
|
|
8
|
+
import { FriendApplicationInfo } from './friendApplication';
|
|
9
|
+
import './index.scss';
|
|
10
|
+
|
|
11
|
+
interface TUIContactInfoProps {
|
|
12
|
+
className?: string,
|
|
13
|
+
showChat?: () => void,
|
|
14
|
+
}
|
|
15
|
+
export function UnMemoizedTUIContactInfo<T extends TUIContactInfoProps>(
|
|
16
|
+
props: PropsWithChildren<T>,
|
|
17
|
+
): React.ReactElement {
|
|
18
|
+
const { showChat } = props;
|
|
19
|
+
const { contactData } = useTUIKitContext('TUIContact');
|
|
20
|
+
if (!contactData?.type) {
|
|
21
|
+
return (<> </>);
|
|
22
|
+
}
|
|
23
|
+
return (
|
|
24
|
+
<div className="tui-contact-info">
|
|
25
|
+
{contactData?.type === 'addFriend' && (<AddFriendInfo profile={contactData?.data} />)}
|
|
26
|
+
{contactData?.type === 'friend' && (<FriendInfo openChat={showChat} friend={contactData?.data} />)}
|
|
27
|
+
{contactData?.type === 'block' && (<BlockInfo profile={contactData?.data} />)}
|
|
28
|
+
{contactData?.type === 'friendApplication' && <FriendApplicationInfo application={contactData?.data} />}
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
export const TUIContactInfo = React.memo(UnMemoizedTUIContactInfo);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { Profile } from '@tencentcloud/chat';
|
|
4
|
+
import useContactInfo from './hooks/useContactInfo';
|
|
5
|
+
import { BasicInfo } from './basicInfo';
|
|
6
|
+
import { DivWithEdit } from '../../DivWithEdit';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
profile: Profile;
|
|
10
|
+
}
|
|
11
|
+
export function UnMemoizedAddFriendInfo<T extends Props>(
|
|
12
|
+
props: T,
|
|
13
|
+
): React.ReactElement {
|
|
14
|
+
const { profile } = props;
|
|
15
|
+
const { userID } = profile;
|
|
16
|
+
const { t } = useTranslation();
|
|
17
|
+
const [isEditName, setIsEditRemark] = useState('');
|
|
18
|
+
const [remark, setRemark] = useState('');
|
|
19
|
+
const [wording, setWording] = useState('');
|
|
20
|
+
const [isSendedAdd, setIsSendAddFriend] = useState(false);
|
|
21
|
+
|
|
22
|
+
const {
|
|
23
|
+
addFriend,
|
|
24
|
+
} = useContactInfo();
|
|
25
|
+
const handleSetEditRemark = () => {
|
|
26
|
+
setIsEditRemark('remark');
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const addFriendHandler = async () => {
|
|
30
|
+
const options = {
|
|
31
|
+
userID,
|
|
32
|
+
remark,
|
|
33
|
+
wording,
|
|
34
|
+
};
|
|
35
|
+
await addFriend(options);
|
|
36
|
+
setIsSendAddFriend(true);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const editText = (data?:any) => {
|
|
40
|
+
setRemark(data?.value);
|
|
41
|
+
setIsEditRemark('');
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const handleChange = (e) => {
|
|
45
|
+
setWording(e.target.value);
|
|
46
|
+
};
|
|
47
|
+
return (
|
|
48
|
+
<>
|
|
49
|
+
<BasicInfo profile={profile} />
|
|
50
|
+
{!isSendedAdd ? (
|
|
51
|
+
<div className="tui-contact-info-content">
|
|
52
|
+
<div className="content-item-wording">
|
|
53
|
+
<p className="content-item-label">{t('TUIContact.Enter the verification info')}</p>
|
|
54
|
+
<textarea className="content-item-wording-text" value={wording} onChange={handleChange} />
|
|
55
|
+
</div>
|
|
56
|
+
<div className="content-item">
|
|
57
|
+
<p className="content-item-label">{t('TUIContact.remark')}</p>
|
|
58
|
+
<DivWithEdit
|
|
59
|
+
name="remark"
|
|
60
|
+
className="content-item-text"
|
|
61
|
+
value={remark}
|
|
62
|
+
type="text"
|
|
63
|
+
toggle={handleSetEditRemark}
|
|
64
|
+
isEdit={isEditName === 'remark'}
|
|
65
|
+
confirm={editText}
|
|
66
|
+
close={() => {
|
|
67
|
+
setIsEditRemark('');
|
|
68
|
+
}}
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
<div className="content-btn-container">
|
|
72
|
+
<div className="content-item-btn confirm-btn" role="button" tabIndex={0} onClick={addFriendHandler}>{t('TUIContact.Send application')}</div>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
) : (
|
|
76
|
+
<div className="tui-contact-info-content">
|
|
77
|
+
<div className="content-item">
|
|
78
|
+
<p className="content-item-label">{t('TUIContact.verification info')}</p>
|
|
79
|
+
<p className="content-item-text">{wording}</p>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
)}
|
|
83
|
+
</>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
export const AddFriendInfo = React.memo(UnMemoizedAddFriendInfo);
|