@tencentcloud/chat-uikit-react 1.1.1 → 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/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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren, useRef, useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
2
3
|
import TencentCloudChat from '@tencentcloud/chat';
|
|
3
4
|
import './styles/index.scss';
|
|
4
5
|
|
|
@@ -37,7 +38,9 @@ export function MessagePlugins <T extends MessagePluginsProps>(
|
|
|
37
38
|
config: propsPluginConfig,
|
|
38
39
|
} = props;
|
|
39
40
|
|
|
41
|
+
const { t } = useTranslation();
|
|
40
42
|
const [className, setClassName] = useState('');
|
|
43
|
+
const [popStyle, setPopStyle] = useState({});
|
|
41
44
|
const pluginsRef = useRef(null);
|
|
42
45
|
|
|
43
46
|
const { message, plugin: contextPlugin } = useTUIMessageContext('MessagePlugins');
|
|
@@ -86,13 +89,19 @@ export function MessagePlugins <T extends MessagePluginsProps>(
|
|
|
86
89
|
};
|
|
87
90
|
|
|
88
91
|
const handleVisible = (data) => {
|
|
89
|
-
|
|
92
|
+
if (data.x && data.y) {
|
|
93
|
+
setPopStyle({
|
|
94
|
+
position: 'fixed',
|
|
95
|
+
left: `${!data.left ? (data.x - data.width) : data.x}px`,
|
|
96
|
+
top: `${!data.top ? (data.y - data.height) : data.y}px`,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
90
99
|
};
|
|
91
100
|
|
|
92
101
|
const RevokeElement = useMessagePluginElement({
|
|
93
102
|
children: (
|
|
94
103
|
<div className="message-plugin-item">
|
|
95
|
-
<span>Recall</span>
|
|
104
|
+
<span>{t('TUIChat.Recall')}</span>
|
|
96
105
|
<Icon width={20} height={20} type={IconTypes.REVOCATION} />
|
|
97
106
|
</div>
|
|
98
107
|
),
|
|
@@ -109,7 +118,7 @@ export function MessagePlugins <T extends MessagePluginsProps>(
|
|
|
109
118
|
const DeleteElement = useMessagePluginElement({
|
|
110
119
|
children: (
|
|
111
120
|
<div className="message-plugin-item">
|
|
112
|
-
<span className="del">Delete</span>
|
|
121
|
+
<span className="del">{t('TUIChat.Delete')}</span>
|
|
113
122
|
<Icon width={20} height={20} type={IconTypes.DEL} />
|
|
114
123
|
</div>
|
|
115
124
|
),
|
|
@@ -125,7 +134,7 @@ export function MessagePlugins <T extends MessagePluginsProps>(
|
|
|
125
134
|
const ReplyElement = useMessagePluginElement({
|
|
126
135
|
children: (
|
|
127
136
|
<div className="message-plugin-item">
|
|
128
|
-
<span>
|
|
137
|
+
<span>{t('TUIChat.Reference')}</span>
|
|
129
138
|
<Icon width={20} height={20} type={IconTypes.QUOTE} />
|
|
130
139
|
</div>
|
|
131
140
|
),
|
|
@@ -141,7 +150,7 @@ export function MessagePlugins <T extends MessagePluginsProps>(
|
|
|
141
150
|
const CopyElement = useMessagePluginElement({
|
|
142
151
|
children: (
|
|
143
152
|
<div className="message-plugin-item">
|
|
144
|
-
<span>Copy</span>
|
|
153
|
+
<span>{t('TUIChat.Copy')}</span>
|
|
145
154
|
<Icon width={20} height={20} type={IconTypes.COPY} />
|
|
146
155
|
</div>
|
|
147
156
|
),
|
|
@@ -157,7 +166,7 @@ export function MessagePlugins <T extends MessagePluginsProps>(
|
|
|
157
166
|
const ResendElement = useMessagePluginElement({
|
|
158
167
|
children: (
|
|
159
168
|
<div className="message-plugin-item">
|
|
160
|
-
<span>Resend</span>
|
|
169
|
+
<span>{t('TUIChat.Resend')}</span>
|
|
161
170
|
<Icon width={20} height={20} type={IconTypes.REPLY} />
|
|
162
171
|
</div>
|
|
163
172
|
),
|
|
@@ -173,7 +182,7 @@ export function MessagePlugins <T extends MessagePluginsProps>(
|
|
|
173
182
|
const ForWardElement = useMessagePluginElement({
|
|
174
183
|
children: (
|
|
175
184
|
<div className="message-plugin-item">
|
|
176
|
-
<span>Forward</span>
|
|
185
|
+
<span>{t('TUIChat.Forward')}</span>
|
|
177
186
|
<Icon width={20} height={20} type={IconTypes.FORWARD} />
|
|
178
187
|
</div>
|
|
179
188
|
),
|
|
@@ -205,6 +214,7 @@ export function MessagePlugins <T extends MessagePluginsProps>(
|
|
|
205
214
|
<Plugins
|
|
206
215
|
className="message-plugin"
|
|
207
216
|
customClass={className}
|
|
217
|
+
style={popStyle}
|
|
208
218
|
ref={pluginsRef}
|
|
209
219
|
plugins={plugins}
|
|
210
220
|
showNumber={showNumber}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren, useCallback } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
2
3
|
import TencentCloudChat from '@tencentcloud/chat';
|
|
3
4
|
import { MESSAGE_FLOW, MESSAGE_OPERATE } from '../../constants';
|
|
4
5
|
import { useTUIChatActionContext } from '../../context';
|
|
@@ -10,7 +11,7 @@ function MessageRevokeWithContext <T extends MessageContextProps>(
|
|
|
10
11
|
const {
|
|
11
12
|
message,
|
|
12
13
|
} = props;
|
|
13
|
-
|
|
14
|
+
const { t } = useTranslation();
|
|
14
15
|
const { operateMessage } = useTUIChatActionContext('MessageRevokeWithContext');
|
|
15
16
|
|
|
16
17
|
const handleRevoke = useCallback(() => {
|
|
@@ -25,13 +26,13 @@ function MessageRevokeWithContext <T extends MessageContextProps>(
|
|
|
25
26
|
message?.flow === MESSAGE_FLOW.IN && <span>{message?.nick || message?.from}</span>
|
|
26
27
|
}
|
|
27
28
|
{
|
|
28
|
-
message?.flow !== MESSAGE_FLOW.IN && <span>
|
|
29
|
+
message?.flow !== MESSAGE_FLOW.IN && <span>{t('TUIChat.You')}</span>
|
|
29
30
|
}
|
|
30
|
-
<span>
|
|
31
|
+
<span>{t('TUIChat.recalled a message')}</span>
|
|
31
32
|
{
|
|
32
33
|
message?.flow === MESSAGE_FLOW.OUT
|
|
33
34
|
&& message?.type === TencentCloudChat.TYPES.MSG_TEXT
|
|
34
|
-
&& <span className="edit" role="button" tabIndex={0} onClick={handleRevoke}>
|
|
35
|
+
&& <span className="edit" role="button" tabIndex={0} onClick={handleRevoke}>{t('TUIChat.Re-edit')}</span>
|
|
35
36
|
}
|
|
36
37
|
</div>
|
|
37
38
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
|
2
2
|
import { Message } from '@tencentcloud/chat';
|
|
3
|
-
import { useTUIMessageContext } from '../../context';
|
|
3
|
+
import { useTUIMessageContext, useTUIKitContext } from '../../context';
|
|
4
4
|
import { getTimeStamp } from '../untils';
|
|
5
5
|
|
|
6
6
|
export interface MessageContextProps {
|
|
@@ -13,12 +13,12 @@ function MessageStatustWithContext <T extends MessageContextProps>(
|
|
|
13
13
|
const {
|
|
14
14
|
message,
|
|
15
15
|
} = props;
|
|
16
|
-
|
|
16
|
+
const { language } = useTUIKitContext('TUIChat');
|
|
17
17
|
const {
|
|
18
18
|
isShowTime,
|
|
19
19
|
} = useTUIMessageContext('MessageStatustWithContext');
|
|
20
20
|
|
|
21
|
-
const timeElement = (typeof isShowTime === 'undefined' || isShowTime) && <div className="time">{message?.time ? getTimeStamp(message.time * 1000) : 0}</div>;
|
|
21
|
+
const timeElement = (typeof isShowTime === 'undefined' || isShowTime) && <div className="time">{message?.time ? getTimeStamp(message.time * 1000, language) : 0}</div>;
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
24
|
<div className="message-status">
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
2
3
|
import { Message } from '@tencentcloud/chat';
|
|
3
4
|
import { MESSAGE_FLOW, MESSAGE_OPERATE } from '../../../constants';
|
|
4
5
|
import { useTUIChatActionContext, useTUIKitContext } from '../../../context';
|
|
@@ -21,6 +22,7 @@ export const useMessageHandler = (props?: MessageHandlerProps) => {
|
|
|
21
22
|
operateMessage,
|
|
22
23
|
revokeMessage,
|
|
23
24
|
} = useTUIChatActionContext('useDeleteHandler');
|
|
25
|
+
const { t } = useTranslation();
|
|
24
26
|
const { chat } = useTUIKitContext('useDeleteHandler');
|
|
25
27
|
|
|
26
28
|
const handleDelMessage = useCallback(async (event?) => {
|
|
@@ -39,7 +41,7 @@ export const useMessageHandler = (props?: MessageHandlerProps) => {
|
|
|
39
41
|
error,
|
|
40
42
|
});
|
|
41
43
|
} else {
|
|
42
|
-
Toast({ text: 'Error deleting message', type: 'error' });
|
|
44
|
+
Toast({ text: t('TUIChat.Error deleting message'), type: 'error' });
|
|
43
45
|
throw new Error(error);
|
|
44
46
|
}
|
|
45
47
|
}
|
|
@@ -65,7 +67,7 @@ export const useMessageHandler = (props?: MessageHandlerProps) => {
|
|
|
65
67
|
error,
|
|
66
68
|
});
|
|
67
69
|
} else {
|
|
68
|
-
const text = message.flow === MESSAGE_FLOW.OUT ? 'The message recall exceeded the time limit (default 2 minutes)' : 'Error revoke Message';
|
|
70
|
+
const text = message.flow === MESSAGE_FLOW.OUT ? t('TUIChat.The message recall exceeded the time limit (default 2 minutes)') : t('TUIChat.Error revoke Message');
|
|
69
71
|
Toast({ text, type: 'error' });
|
|
70
72
|
throw new Error(error);
|
|
71
73
|
}
|
|
@@ -356,17 +356,10 @@
|
|
|
356
356
|
transform: scale(1.5);
|
|
357
357
|
}
|
|
358
358
|
.plugin-popup-box{
|
|
359
|
-
top: 100%;
|
|
360
359
|
bottom: auto;
|
|
361
|
-
|
|
362
|
-
}
|
|
363
|
-
&-top {
|
|
364
|
-
top: auto !important;
|
|
365
|
-
bottom: 100% !important;
|
|
366
|
-
}
|
|
367
|
-
&-left {
|
|
368
|
-
left: -140px !important;
|
|
360
|
+
top: 100%;
|
|
369
361
|
}
|
|
362
|
+
|
|
370
363
|
&-box {
|
|
371
364
|
padding: 6px 0;
|
|
372
365
|
}
|
|
@@ -460,7 +460,7 @@ export const bigEmojiList:Array<IBigEmojiListItem> = [
|
|
|
460
460
|
* @param { number } type 0:Convert to Chinese expression key 1: Convert to English expression key
|
|
461
461
|
* @returns { string } the converted text
|
|
462
462
|
*/
|
|
463
|
-
export function formatEmojiString(data: string, type = 0) {
|
|
463
|
+
export function formatEmojiString(data: string, type = 0, language?: string) {
|
|
464
464
|
let text = data;
|
|
465
465
|
const replace = {
|
|
466
466
|
key: type === 0 ? 1 : 0,
|
|
@@ -468,7 +468,11 @@ export function formatEmojiString(data: string, type = 0) {
|
|
|
468
468
|
};
|
|
469
469
|
Object.entries(emojiEnKey).map((item) => {
|
|
470
470
|
if (text.includes(item[replace.key])) {
|
|
471
|
-
|
|
471
|
+
if (language && language === 'zh') {
|
|
472
|
+
text = item[replace.key];
|
|
473
|
+
} else {
|
|
474
|
+
text = transText(text, item[replace.key], item[replace.value]);
|
|
475
|
+
}
|
|
472
476
|
}
|
|
473
477
|
return item;
|
|
474
478
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useRef } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
2
3
|
import './styles/index.scss';
|
|
3
4
|
|
|
4
5
|
import { EmojiPicker } from './EmojiPicker';
|
|
@@ -14,6 +15,7 @@ export function InputPluginsDefalut():React.ReactElement {
|
|
|
14
15
|
sendUploadMessage,
|
|
15
16
|
pluginConfig: propsPluginConfig,
|
|
16
17
|
} = useTUIMessageInputContext('TUIMessageInputDefault');
|
|
18
|
+
const { t } = useTranslation();
|
|
17
19
|
|
|
18
20
|
const { TUIMessageInputConfig } = useTUIChatStateContext('TUIMessageInput');
|
|
19
21
|
|
|
@@ -64,7 +66,7 @@ export function InputPluginsDefalut():React.ReactElement {
|
|
|
64
66
|
children: (
|
|
65
67
|
<div className="input-plugin-item">
|
|
66
68
|
<Icon width={20} height={20} type={IconTypes.IMAGE} />
|
|
67
|
-
<span>Image</span>
|
|
69
|
+
<span>{t('TUIChat.Image')}</span>
|
|
68
70
|
</div>
|
|
69
71
|
),
|
|
70
72
|
type: 'image',
|
|
@@ -79,7 +81,7 @@ export function InputPluginsDefalut():React.ReactElement {
|
|
|
79
81
|
children: (
|
|
80
82
|
<div className="input-plugin-item">
|
|
81
83
|
<Icon width={20} height={20} type={IconTypes.VIDEO} />
|
|
82
|
-
<span>Video</span>
|
|
84
|
+
<span>{t('TUIChat.Video')}</span>
|
|
83
85
|
</div>
|
|
84
86
|
),
|
|
85
87
|
type: 'video',
|
|
@@ -94,7 +96,7 @@ export function InputPluginsDefalut():React.ReactElement {
|
|
|
94
96
|
children: (
|
|
95
97
|
<div className="input-plugin-item">
|
|
96
98
|
<Icon width={20} height={20} type={IconTypes.DOCUMENT} />
|
|
97
|
-
<span>
|
|
99
|
+
<span>{t('TUIChat.File')}</span>
|
|
98
100
|
</div>
|
|
99
101
|
),
|
|
100
102
|
type: 'file',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, {
|
|
2
2
|
PropsWithChildren, useCallback, useEffect, useState,
|
|
3
3
|
} from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
4
5
|
import { Conversation, Message } from '@tencentcloud/chat';
|
|
5
6
|
import { useTUIChatActionContext } from '../../context';
|
|
6
7
|
import './styles/index.scss';
|
|
@@ -28,6 +29,7 @@ export function TUIForward <T extends TUIForwardToProps>(
|
|
|
28
29
|
const {
|
|
29
30
|
handleForward: propsHandleForward,
|
|
30
31
|
} = props;
|
|
32
|
+
const { t } = useTranslation();
|
|
31
33
|
const [selectList, setSelectList] = useState([]);
|
|
32
34
|
const [searchResult, setSearchResult] = useState([]);
|
|
33
35
|
const [searchValue, setSearchValue] = useState('');
|
|
@@ -42,8 +44,8 @@ export function TUIForward <T extends TUIForwardToProps>(
|
|
|
42
44
|
});
|
|
43
45
|
}, [operateMessage]);
|
|
44
46
|
|
|
45
|
-
const FrequentlyList = conversationList.slice(0, 2);
|
|
46
|
-
const RecentList = conversationList
|
|
47
|
+
//const FrequentlyList = conversationList.slice(0, 2);
|
|
48
|
+
const RecentList = conversationList;
|
|
47
49
|
|
|
48
50
|
const handleInputChange = (e) => {
|
|
49
51
|
setSearchValue(e.target?.value);
|
|
@@ -104,7 +106,7 @@ export function TUIForward <T extends TUIForwardToProps>(
|
|
|
104
106
|
height={16}
|
|
105
107
|
onClick={handleClose}
|
|
106
108
|
/>
|
|
107
|
-
<h2 className="tui-forward-title">Forward
|
|
109
|
+
<h2 className="tui-forward-title">{t('TUIChat.Forward to')}</h2>
|
|
108
110
|
</header>
|
|
109
111
|
<div className="tui-forward-search">
|
|
110
112
|
<Input
|
|
@@ -120,7 +122,7 @@ export function TUIForward <T extends TUIForwardToProps>(
|
|
|
120
122
|
{
|
|
121
123
|
searchValue && (
|
|
122
124
|
<ul className="tui-forward-list">
|
|
123
|
-
<h3 className="tui-forward-list-title">Search Result</h3>
|
|
125
|
+
<h3 className="tui-forward-list-title">{t('TUIChat.Search Result')}</h3>
|
|
124
126
|
{
|
|
125
127
|
searchResult.length > 0 && searchResult.map((item) => (
|
|
126
128
|
<li key={item.conversationID} className="tui-forward-list-item">
|
|
@@ -138,34 +140,13 @@ export function TUIForward <T extends TUIForwardToProps>(
|
|
|
138
140
|
}
|
|
139
141
|
{
|
|
140
142
|
searchResult.length === 0
|
|
141
|
-
&& <p className="no-result">No Result</p>
|
|
143
|
+
&& <p className="no-result">{t('TUIChat.No Result')}</p>
|
|
142
144
|
}
|
|
143
145
|
</ul>
|
|
144
146
|
)
|
|
145
147
|
}
|
|
146
|
-
{ !searchValue && FrequentlyList.length > 0 && (
|
|
147
|
-
<ul className="tui-forward-list">
|
|
148
|
-
<h3 className="tui-forward-list-title">Frequently Contacted</h3>
|
|
149
|
-
{
|
|
150
|
-
FrequentlyList.map((item) => (
|
|
151
|
-
<li key={item.conversationID} className="tui-forward-list-item">
|
|
152
|
-
<label htmlFor={`${item.conversationID}`} className="info">
|
|
153
|
-
<Avatar image={getDisplayImage(item)} size={40} />
|
|
154
|
-
<div className="info-nick">{getDisplayTitle(item)}</div>
|
|
155
|
-
</label>
|
|
156
|
-
<Checkbox
|
|
157
|
-
onChange={handleCheckboxChange}
|
|
158
|
-
id={`${item.conversationID}`}
|
|
159
|
-
value={item}
|
|
160
|
-
/>
|
|
161
|
-
</li>
|
|
162
|
-
))
|
|
163
|
-
}
|
|
164
|
-
</ul>
|
|
165
|
-
)}
|
|
166
148
|
{ !searchValue && RecentList.length > 0 && (
|
|
167
149
|
<ul className="tui-forward-list">
|
|
168
|
-
<h3 className="tui-forward-list-title">Recent Chats</h3>
|
|
169
150
|
{
|
|
170
151
|
RecentList.map((item) => (
|
|
171
152
|
<li key={item.conversationID} className="tui-forward-list-item">
|
|
@@ -186,7 +167,7 @@ export function TUIForward <T extends TUIForwardToProps>(
|
|
|
186
167
|
</main>
|
|
187
168
|
<footer className="tui-forward-footer">
|
|
188
169
|
<div className="tui-forward-footer-name">{selectList.length > 0 && handleDisplayForwardName(selectList)}</div>
|
|
189
|
-
<button type="button" className="button" onClick={() => { handleForward(selectList); }} disabled={selectList.length === 0}>Forward</button>
|
|
170
|
+
<button type="button" className="button" onClick={() => { handleForward(selectList); }} disabled={selectList.length === 0}>{t('TUIChat.Forward')}</button>
|
|
190
171
|
</footer>
|
|
191
172
|
</div>
|
|
192
173
|
</Model>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
2
3
|
import { MESSAGE_OPERATE } from '../../constants';
|
|
3
4
|
import { useTUIChatStateContext } from '../../context';
|
|
4
5
|
|
|
@@ -17,6 +18,7 @@ export function TUIMessageInputDefault():React.ReactElement {
|
|
|
17
18
|
setText,
|
|
18
19
|
setCursorPos,
|
|
19
20
|
} = useTUIMessageInputContext('TUIMessageInputDefault');
|
|
21
|
+
const { t } = useTranslation();
|
|
20
22
|
const {
|
|
21
23
|
operateData,
|
|
22
24
|
} = useTUIChatStateContext('TUIMessageInputDefault');
|
|
@@ -60,7 +62,7 @@ export function TUIMessageInputDefault():React.ReactElement {
|
|
|
60
62
|
!disabled
|
|
61
63
|
&& (
|
|
62
64
|
<textarea
|
|
63
|
-
placeholder=
|
|
65
|
+
placeholder={t('TUIChat.Enter a message')}
|
|
64
66
|
rows={1}
|
|
65
67
|
value={text}
|
|
66
68
|
ref={textareaRef}
|
|
@@ -5,7 +5,7 @@ export const useCreateMessageInputContext = (value:any) => {
|
|
|
5
5
|
textareaRef,
|
|
6
6
|
handleChange,
|
|
7
7
|
handleSubmit,
|
|
8
|
-
|
|
8
|
+
handleEnterKeyDown,
|
|
9
9
|
onSelectEmoji,
|
|
10
10
|
sendFaceMessage,
|
|
11
11
|
disabled,
|
|
@@ -18,7 +18,7 @@ export const useCreateMessageInputContext = (value:any) => {
|
|
|
18
18
|
textareaRef,
|
|
19
19
|
handleChange,
|
|
20
20
|
handleSubmit,
|
|
21
|
-
|
|
21
|
+
handleEnterKeyDown,
|
|
22
22
|
onSelectEmoji,
|
|
23
23
|
sendFaceMessage,
|
|
24
24
|
disabled,
|
|
@@ -31,7 +31,7 @@ export const useCreateMessageInputContext = (value:any) => {
|
|
|
31
31
|
textareaRef,
|
|
32
32
|
handleChange,
|
|
33
33
|
handleSubmit,
|
|
34
|
-
|
|
34
|
+
handleEnterKeyDown,
|
|
35
35
|
onSelectEmoji,
|
|
36
36
|
sendFaceMessage,
|
|
37
37
|
disabled,
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
PropsWithChildren,
|
|
4
4
|
useCallback,
|
|
5
5
|
} from 'react';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
6
7
|
import { useTUIChatActionContext } from '../../../context';
|
|
7
8
|
import { emojiEnKey } from '../../TUIMessage/utils/emojiMap';
|
|
8
9
|
import type { IbaseStateProps } from './useMessageInputState';
|
|
@@ -23,10 +24,15 @@ export function useEmojiPicker<T extends useEmojiPickerProps>(props:PropsWithChi
|
|
|
23
24
|
insertText,
|
|
24
25
|
} = props;
|
|
25
26
|
|
|
27
|
+
const { i18n } = useTranslation();
|
|
26
28
|
const { sendMessage, createFaceMessage } = useTUIChatActionContext('useEmojiPicker');
|
|
27
29
|
|
|
28
30
|
const onSelectEmoji = (emoji:EmojiData) => {
|
|
29
|
-
|
|
31
|
+
if (i18n.language === 'en') {
|
|
32
|
+
insertText(emoji.data);
|
|
33
|
+
} else {
|
|
34
|
+
insertText(emojiEnKey[emoji.data]);
|
|
35
|
+
}
|
|
30
36
|
};
|
|
31
37
|
|
|
32
38
|
const sendFaceMessage = useCallback((emoji:EmojiData) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren, useState, useEffect } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
2
3
|
import { Message } from '@tencentcloud/chat';
|
|
3
4
|
import {
|
|
4
5
|
useTUIChatStateContext,
|
|
@@ -31,6 +32,7 @@ function TUIMessageListWithContext <T extends MessageListProps>(
|
|
|
31
32
|
className: propsClassName,
|
|
32
33
|
} = props;
|
|
33
34
|
|
|
35
|
+
const { t } = useTranslation();
|
|
34
36
|
const [ulElement, setUlElement] = useState<HTMLUListElement | null>(null);
|
|
35
37
|
const [firstRender, setFirstRender] = useState<boolean>(false);
|
|
36
38
|
|
|
@@ -102,7 +104,7 @@ function TUIMessageListWithContext <T extends MessageListProps>(
|
|
|
102
104
|
return (
|
|
103
105
|
<div className={`message-list ${propsClassName} ${!firstRender ? 'hide' : ''}`} ref={messageListRef}>
|
|
104
106
|
{noMore}
|
|
105
|
-
{noMore && <p className="no-more">No More</p>}
|
|
107
|
+
{noMore && <p className="no-more">{t('TUIChat.No More')}</p>}
|
|
106
108
|
<InfiniteScroll
|
|
107
109
|
className="message-list-infinite-scroll"
|
|
108
110
|
hasMore
|
|
@@ -2,7 +2,7 @@ import React, {
|
|
|
2
2
|
PropsWithChildren, useMemo,
|
|
3
3
|
} from 'react';
|
|
4
4
|
import { Message } from '@tencentcloud/chat';
|
|
5
|
-
import { UnknowPorps } from '../../../context';
|
|
5
|
+
import { UnknowPorps, useTUIKitContext } from '../../../context';
|
|
6
6
|
import { TUIMessageProps } from '../../TUIMessage/TUIMessage';
|
|
7
7
|
import { getTimeStamp } from '../../untils';
|
|
8
8
|
|
|
@@ -20,6 +20,7 @@ function useMessageListElement <T extends MessageListElementProps>(
|
|
|
20
20
|
TUIMessage,
|
|
21
21
|
intervalsTimer,
|
|
22
22
|
} = props;
|
|
23
|
+
const { language } = useTUIKitContext('TUIConversation');
|
|
23
24
|
|
|
24
25
|
return useMemo(() => enrichedMessageList?.map((item: Message, index:number) => {
|
|
25
26
|
const key = `${item.ID}-${index}`;
|
|
@@ -30,7 +31,7 @@ function useMessageListElement <T extends MessageListElementProps>(
|
|
|
30
31
|
return (
|
|
31
32
|
<li className="message-list-item" key={key}>
|
|
32
33
|
{
|
|
33
|
-
isShowIntervalsTimer && <div className="message-list-time" key={`${currrentTimer + index}`}>{currrentTimer ? getTimeStamp(currrentTimer * 1000) : 0}</div>
|
|
34
|
+
isShowIntervalsTimer && <div className="message-list-time" key={`${currrentTimer + index}`}>{currrentTimer ? getTimeStamp(currrentTimer * 1000, language) : 0}</div>
|
|
34
35
|
}
|
|
35
36
|
<TUIMessage message={item} />
|
|
36
37
|
</li>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import { Profile } from '../Profile';
|
|
2
3
|
|
|
3
4
|
import './styles/index.scss';
|
|
4
5
|
import { useMyProfile } from './hooks';
|
|
@@ -20,16 +21,26 @@ function UnMemoizedTUIProfile<T extends TUIProfileProps>(
|
|
|
20
21
|
|
|
21
22
|
const { myProfile, updateMyProfile } = useMyProfile();
|
|
22
23
|
|
|
23
|
-
const { TUIProfileShow } = useTUIKitContext('TUIProfile');
|
|
24
|
+
const { setTUIProfileShow, TUIProfileShow } = useTUIKitContext('TUIProfile');
|
|
24
25
|
|
|
25
26
|
const TUIProfileUIComponent = PropTUIProfile || TUIProfileDefault;
|
|
26
27
|
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
<Profile
|
|
31
|
+
profile={myProfile}
|
|
32
|
+
handleAvatar={() => {
|
|
33
|
+
setTUIProfileShow(true);
|
|
34
|
+
}}
|
|
35
|
+
/>
|
|
36
|
+
{TUIProfileShow && (
|
|
37
|
+
<TUIProfileUIComponent
|
|
38
|
+
className={className}
|
|
39
|
+
userInfo={myProfile}
|
|
40
|
+
update={updateMyProfile}
|
|
41
|
+
/>
|
|
42
|
+
)}
|
|
43
|
+
</>
|
|
33
44
|
);
|
|
34
45
|
}
|
|
35
46
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren, useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
2
3
|
import DatePicker from 'react-date-picker';
|
|
3
4
|
import TencentCloudChat, { Profile } from '@tencentcloud/chat';
|
|
4
5
|
|
|
@@ -15,6 +16,11 @@ const gender = {
|
|
|
15
16
|
[TencentCloudChat.TYPES.GENDER_MALE]: 'male',
|
|
16
17
|
[TencentCloudChat.TYPES.GENDER_FEMALE]: 'female',
|
|
17
18
|
};
|
|
19
|
+
const allowType = {
|
|
20
|
+
[TencentCloudChat.TYPES.ALLOW_TYPE_ALLOW_ANY]: 'allowAny',
|
|
21
|
+
[TencentCloudChat.TYPES.ALLOW_TYPE_NEED_CONFIRM]: 'needConfirm',
|
|
22
|
+
[TencentCloudChat.TYPES.ALLOW_TYPE_DENY_ANY]: 'denyAny',
|
|
23
|
+
};
|
|
18
24
|
|
|
19
25
|
const avatarList = [
|
|
20
26
|
'https://im.sdk.qcloud.com/download/tuikit-resource/avatar/avatar_1.png',
|
|
@@ -36,6 +42,21 @@ const genderList = [
|
|
|
36
42
|
},
|
|
37
43
|
];
|
|
38
44
|
|
|
45
|
+
const allowTypeList = [
|
|
46
|
+
{
|
|
47
|
+
label: 'AllowAny',
|
|
48
|
+
value: TencentCloudChat.TYPES.ALLOW_TYPE_ALLOW_ANY,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
label: 'NeedConfirm',
|
|
52
|
+
value: TencentCloudChat.TYPES.ALLOW_TYPE_NEED_CONFIRM,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: 'DenyAny',
|
|
56
|
+
value: TencentCloudChat.TYPES.ALLOW_TYPE_DENY_ANY,
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
|
|
39
60
|
export interface TUIProfileDefaultProps {
|
|
40
61
|
userInfo?: Profile,
|
|
41
62
|
update?:(option:ProfileParams) => void,
|
|
@@ -51,6 +72,7 @@ function TUIProfileDefaultWithContext <T extends TUIProfileDefaultProps>(
|
|
|
51
72
|
update,
|
|
52
73
|
} = props;
|
|
53
74
|
|
|
75
|
+
const { t } = useTranslation();
|
|
54
76
|
const { setTUIProfileShow } = useTUIKitContext('TUIProfileDefault');
|
|
55
77
|
|
|
56
78
|
const [isEditName, setIsEditName] = useState('');
|
|
@@ -83,10 +105,13 @@ function TUIProfileDefaultWithContext <T extends TUIProfileDefaultProps>(
|
|
|
83
105
|
},
|
|
84
106
|
{
|
|
85
107
|
name: 'Gender',
|
|
86
|
-
value: gender[userInfo?.gender]?.replace(
|
|
108
|
+
value: t(gender[userInfo?.gender]?.replace(
|
|
87
109
|
gender[userInfo?.gender][0],
|
|
88
110
|
gender[userInfo?.gender][0]?.toLocaleUpperCase(),
|
|
89
|
-
)
|
|
111
|
+
) ? `TUIProfile.${gender[userInfo?.gender]?.replace(
|
|
112
|
+
gender[userInfo?.gender][0],
|
|
113
|
+
gender[userInfo?.gender][0]?.toLocaleUpperCase(),
|
|
114
|
+
)}` : ''),
|
|
90
115
|
type: 'select',
|
|
91
116
|
children: (
|
|
92
117
|
<ul className="select-list">
|
|
@@ -101,7 +126,35 @@ function TUIProfileDefaultWithContext <T extends TUIProfileDefaultProps>(
|
|
|
101
126
|
key={key}
|
|
102
127
|
onClick={() => { editGender(item); }}
|
|
103
128
|
>
|
|
104
|
-
{item.label}
|
|
129
|
+
{t(`TUIProfile.${item.label}`)}
|
|
130
|
+
</li>
|
|
131
|
+
);
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
</ul>
|
|
135
|
+
),
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: 'AllowType',
|
|
139
|
+
value: t(`TUIProfile.${allowType[userInfo?.allowType]?.replace(
|
|
140
|
+
allowType[userInfo?.allowType][0],
|
|
141
|
+
allowType[userInfo?.allowType][0]?.toLocaleUpperCase(),
|
|
142
|
+
)}`),
|
|
143
|
+
type: 'select',
|
|
144
|
+
children: (
|
|
145
|
+
<ul className="select-list">
|
|
146
|
+
{
|
|
147
|
+
allowTypeList?.map((item, index) => {
|
|
148
|
+
const key = `${item.value}${index}`;
|
|
149
|
+
return (
|
|
150
|
+
<li
|
|
151
|
+
className="select-list-item"
|
|
152
|
+
role="menuitem"
|
|
153
|
+
tabIndex={index}
|
|
154
|
+
key={key}
|
|
155
|
+
onClick={() => { editAllowType(item); }}
|
|
156
|
+
>
|
|
157
|
+
{t(`TUIProfile.${item.label}`)}
|
|
105
158
|
</li>
|
|
106
159
|
);
|
|
107
160
|
})
|
|
@@ -111,7 +164,7 @@ function TUIProfileDefaultWithContext <T extends TUIProfileDefaultProps>(
|
|
|
111
164
|
},
|
|
112
165
|
{
|
|
113
166
|
name: 'Birthday',
|
|
114
|
-
value: userInfo?.birthday
|
|
167
|
+
value: `${userInfo?.birthday}`,
|
|
115
168
|
type: 'select',
|
|
116
169
|
children: (
|
|
117
170
|
<DatePicker
|
|
@@ -165,6 +218,11 @@ function TUIProfileDefaultWithContext <T extends TUIProfileDefaultProps>(
|
|
|
165
218
|
confirm({ gender: data.value });
|
|
166
219
|
};
|
|
167
220
|
|
|
221
|
+
// edit allowType
|
|
222
|
+
const editAllowType = (data) => {
|
|
223
|
+
confirm({ allowType: data.value });
|
|
224
|
+
};
|
|
225
|
+
|
|
168
226
|
// edit birthday
|
|
169
227
|
const editBirthday = (value:Date) => {
|
|
170
228
|
confirm({
|
|
@@ -181,7 +239,7 @@ function TUIProfileDefaultWithContext <T extends TUIProfileDefaultProps>(
|
|
|
181
239
|
type={IconTypes.BACK}
|
|
182
240
|
onClick={() => { setTUIProfileShow(false); }}
|
|
183
241
|
/>
|
|
184
|
-
<h1>Personal information</h1>
|
|
242
|
+
<h1>{t('TUIProfile.Personal information')}</h1>
|
|
185
243
|
</header>
|
|
186
244
|
<main className="tui-profile-main">
|
|
187
245
|
<div className="tui-profile-avatar">
|
|
@@ -213,7 +271,7 @@ function TUIProfileDefaultWithContext <T extends TUIProfileDefaultProps>(
|
|
|
213
271
|
const key = `${item.name}`;
|
|
214
272
|
return (
|
|
215
273
|
<li className="tui-profile-list-item" key={key}>
|
|
216
|
-
<h4>{item.name}</h4>
|
|
274
|
+
<h4>{t(`TUIProfile.${item.name}`)}</h4>
|
|
217
275
|
<DivWithEdit
|
|
218
276
|
className="tui-profile-div-with-edit"
|
|
219
277
|
classEditName="tui-profile-edit"
|