@webinex/chatify 2.0.1-alpha1 → 2.0.2-alpha2
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/dist/css/chatify.css +111 -12
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/core/api/api.d.ts +10784 -232
- package/dist/esm/types/core/api/baseApi.d.ts +1 -1
- package/dist/esm/types/ui/Conversation/Conversation.d.ts +2 -0
- package/dist/esm/types/ui/Conversation/ConversationContext.d.ts +2 -0
- package/dist/esm/types/ui/Conversation/InputBox/InputBoxFile.d.ts +8 -0
- package/dist/esm/types/ui/Conversation/InputBox/InputBoxFileList.d.ts +8 -0
- package/dist/esm/types/ui/Conversation/InputBox/InputFilesBox.d.ts +11 -1
- package/dist/esm/types/ui/Conversation/InputBox/InputSubmitButtonBox.d.ts +2 -0
- package/dist/esm/types/ui/Conversation/InputBox/InputTextBox.d.ts +1 -0
- package/dist/esm/types/ui/Conversation/InputBox/index.d.ts +8 -1
- package/dist/esm/types/ui/Conversation/Message/MessageFile.d.ts +6 -0
- package/dist/esm/types/ui/Conversation/Message/MessageFileList.d.ts +3 -0
- package/dist/esm/types/ui/Conversation/Message/index.d.ts +6 -0
- package/dist/esm/types/ui/common/Icon.d.ts +2 -0
- package/dist/esm/types/ui/customize.d.ts +2 -2
- package/dist/esm/types/ui/localizer.d.ts +5 -0
- package/dist/esm/types/ui/useFormatter.d.ts +3 -0
- package/dist/index.d.ts +10835 -239
- package/package.json +94 -93
- package/src/core/api/api.ts +643 -642
- package/src/core/api/baseApi.ts +38 -38
- package/src/core/api/index.ts +1 -1
- package/src/core/client.ts +280 -280
- package/src/core/constants.ts +1 -1
- package/src/core/debounce.ts +90 -90
- package/src/core/index.ts +4 -4
- package/src/core/types.tsx +152 -152
- package/src/index.ts +2 -2
- package/src/styles/aside.scss +162 -161
- package/src/styles/chat.scss +209 -208
- package/src/styles/index.scss +153 -110
- package/src/styles/input.scss +147 -74
- package/src/styles/keyframes.scss +14 -14
- package/src/styles/members.scss +13 -13
- package/src/styles/mixins.scss +25 -20
- package/src/styles/variables.scss +13 -10
- package/src/ui/Chat/ChatContext.tsx +30 -30
- package/src/ui/Chat/ChatEditableHeaderName.tsx +63 -63
- package/src/ui/Chat/ChatHeaderActions.tsx +19 -19
- package/src/ui/Chat/ChatPanel.tsx +30 -30
- package/src/ui/Chat/ChatView.tsx +115 -115
- package/src/ui/Chat/Members/ChatMembersButton.tsx +9 -9
- package/src/ui/Chat/Members/ChatMembersPanel.tsx +112 -112
- package/src/ui/Chat/Members/ChatMembersPreview.tsx +25 -25
- package/src/ui/Chat/Members/index.ts +13 -13
- package/src/ui/Chat/index.ts +6 -6
- package/src/ui/ChatGroup/ChatGroupContext.tsx +50 -50
- package/src/ui/ChatGroup/ChatGroupPanel.tsx +73 -73
- package/src/ui/ChatGroup/Create/CreateChatButton.tsx +15 -15
- package/src/ui/ChatGroup/Create/CreateChatForm.tsx +36 -36
- package/src/ui/ChatGroup/Create/CreateChatMemberInput.tsx +65 -65
- package/src/ui/ChatGroup/Create/CreateChatNameInput.tsx +25 -25
- package/src/ui/ChatGroup/Create/CreateChatPanel.tsx +45 -45
- package/src/ui/ChatGroup/Create/index.ts +19 -19
- package/src/ui/ChatGroup/Layout/ChatGroupAside.tsx +12 -12
- package/src/ui/ChatGroup/Layout/ChatGroupBody.tsx +10 -10
- package/src/ui/ChatGroup/Layout/ChatGroupFooter.tsx +3 -3
- package/src/ui/ChatGroup/Layout/ChatGroupHeader.tsx +5 -5
- package/src/ui/ChatGroup/Layout/ChatGroupMain.tsx +17 -17
- package/src/ui/ChatGroup/Layout/index.ts +19 -19
- package/src/ui/ChatGroup/List/ChatList.tsx +41 -41
- package/src/ui/ChatGroup/List/ChatListItemAvatar.tsx +22 -22
- package/src/ui/ChatGroup/List/ChatListItemBox.tsx +26 -26
- package/src/ui/ChatGroup/List/ChatListItemLastMessage.tsx +15 -15
- package/src/ui/ChatGroup/List/ChatListItemLastMessageAuthor.tsx +15 -15
- package/src/ui/ChatGroup/List/ChatListItemLastMessageContent.tsx +21 -21
- package/src/ui/ChatGroup/List/ChatListItemLastMessageSentAt.tsx +22 -22
- package/src/ui/ChatGroup/List/ChatListItemName.tsx +8 -8
- package/src/ui/ChatGroup/List/ChatListItemUnreadCount.tsx +12 -12
- package/src/ui/ChatGroup/List/index.ts +31 -31
- package/src/ui/ChatGroup/index.ts +5 -5
- package/src/ui/Chatify.tsx +9 -9
- package/src/ui/Conversation/Conversation.tsx +78 -76
- package/src/ui/Conversation/ConversationActions.tsx +5 -5
- package/src/ui/Conversation/ConversationBody.tsx +28 -28
- package/src/ui/Conversation/ConversationContext.ts +29 -27
- package/src/ui/Conversation/ConversationHeader.tsx +23 -23
- package/src/ui/Conversation/ConversationName.tsx +7 -7
- package/src/ui/Conversation/InputBox/InputBox.tsx +113 -40
- package/src/ui/Conversation/InputBox/InputBoxFile.tsx +38 -0
- package/src/ui/Conversation/InputBox/InputBoxFileList.tsx +21 -0
- package/src/ui/Conversation/InputBox/InputFilesBox.tsx +78 -9
- package/src/ui/Conversation/InputBox/InputSubmitButtonBox.tsx +26 -17
- package/src/ui/Conversation/InputBox/InputTextBox.tsx +55 -53
- package/src/ui/Conversation/InputBox/index.ts +23 -16
- package/src/ui/Conversation/Message/MessageAuthor.tsx +13 -13
- package/src/ui/Conversation/Message/MessageBox.tsx +20 -20
- package/src/ui/Conversation/Message/MessageContent.tsx +15 -11
- package/src/ui/Conversation/Message/MessageFile.tsx +52 -0
- package/src/ui/Conversation/Message/MessageFileList.tsx +14 -0
- package/src/ui/Conversation/Message/MessageInfoBox.tsx +28 -28
- package/src/ui/Conversation/Message/MessageRow.tsx +28 -28
- package/src/ui/Conversation/Message/MessageText.tsx +7 -7
- package/src/ui/Conversation/Message/index.ts +28 -22
- package/src/ui/Conversation/NextObserver/NextMessagesObserver.tsx +47 -47
- package/src/ui/Conversation/NextObserver/index.ts +1 -1
- package/src/ui/Conversation/ReadObserver/MessageReadObserver.tsx +49 -49
- package/src/ui/Conversation/ReadObserver/index.ts +1 -1
- package/src/ui/Conversation/SendingMessage/SendingMessageBox.tsx +16 -16
- package/src/ui/Conversation/SendingMessage/SendingMessageContent.tsx +13 -13
- package/src/ui/Conversation/SendingMessage/SendingMessageInfoBox.tsx +13 -13
- package/src/ui/Conversation/SendingMessage/SendingMessageText.tsx +7 -7
- package/src/ui/Conversation/SendingMessage/index.ts +16 -16
- package/src/ui/Conversation/SystemMessage/SystemMessageBox.tsx +20 -20
- package/src/ui/Conversation/SystemMessage/SystemMessageRow.tsx +28 -28
- package/src/ui/Conversation/SystemMessage/index.ts +10 -10
- package/src/ui/Conversation/index.ts +13 -13
- package/src/ui/Thread/ThreadActions.tsx +22 -22
- package/src/ui/Thread/ThreadContext.ts +13 -13
- package/src/ui/Thread/ThreadPanel.tsx +127 -127
- package/src/ui/Thread/index.tsx +3 -3
- package/src/ui/color.ts +20 -20
- package/src/ui/common/Avatar.tsx +20 -20
- package/src/ui/common/Icon.tsx +44 -40
- package/src/ui/common/MessageSkeleton.tsx +20 -20
- package/src/ui/common/index.ts +13 -13
- package/src/ui/customize.tsx +51 -53
- package/src/ui/index.ts +11 -11
- package/src/ui/localizer.tsx +96 -81
- package/src/ui/useFormatter.tsx +17 -0
- package/dist/esm/types/core/api/accountApi.d.ts +0 -5
- package/dist/esm/types/core/api/chatApi.d.ts +0 -16
- package/dist/esm/types/core/api/chatListApi.d.ts +0 -5
- package/dist/esm/types/core/api/chatMemberApi.d.ts +0 -6
- package/dist/esm/types/core/api/chatMessageApi.d.ts +0 -3
- package/dist/esm/types/core/api/threadApi.d.ts +0 -1
- package/dist/esm/types/core/api/threadMessageApi.d.ts +0 -6
- package/src/core/api/accountApi.ts +0 -11
- package/src/core/api/chatApi.ts +0 -87
- package/src/core/api/chatListApi.ts +0 -134
- package/src/core/api/chatMemberApi.ts +0 -20
- package/src/core/api/chatMessageApi.ts +0 -12
- package/src/core/api/threadApi.ts +0 -8
- package/src/core/api/threadMessageApi.ts +0 -20
- package/src/types/core/api/accountApi.d.ts +0 -5
- package/src/types/core/api/api.d.ts +0 -2380
- package/src/types/core/api/baseApi.d.ts +0 -15
- package/src/types/core/api/chatApi.d.ts +0 -16
- package/src/types/core/api/chatListApi.d.ts +0 -5
- package/src/types/core/api/chatMemberApi.d.ts +0 -6
- package/src/types/core/api/chatMessageApi.d.ts +0 -3
- package/src/types/core/api/index.d.ts +0 -1
- package/src/types/core/api/threadApi.d.ts +0 -1
- package/src/types/core/api/threadMessageApi.d.ts +0 -6
- package/src/types/core/client.d.ts +0 -83
- package/src/types/core/constants.d.ts +0 -1
- package/src/types/core/debounce.d.ts +0 -27
- package/src/types/core/index.d.ts +0 -4
- package/src/types/core/types.d.ts +0 -105
- package/src/types/index.d.ts +0 -2
- package/src/types/ui/Chat/ChatContext.d.ts +0 -10
- package/src/types/ui/Chat/ChatEditableHeaderName.d.ts +0 -2
- package/src/types/ui/Chat/ChatHeaderActions.d.ts +0 -2
- package/src/types/ui/Chat/ChatPanel.d.ts +0 -13
- package/src/types/ui/Chat/ChatView.d.ts +0 -17
- package/src/types/ui/Chat/Members/ChatMembersButton.d.ts +0 -2
- package/src/types/ui/Chat/Members/ChatMembersPanel.d.ts +0 -2
- package/src/types/ui/Chat/Members/ChatMembersPreview.d.ts +0 -2
- package/src/types/ui/Chat/Members/index.d.ts +0 -11
- package/src/types/ui/Chat/index.d.ts +0 -6
- package/src/types/ui/ChatGroup/ChatGroupContext.d.ts +0 -12
- package/src/types/ui/ChatGroup/ChatGroupPanel.d.ts +0 -15
- package/src/types/ui/ChatGroup/Create/CreateChatButton.d.ts +0 -2
- package/src/types/ui/ChatGroup/Create/CreateChatForm.d.ts +0 -11
- package/src/types/ui/ChatGroup/Create/CreateChatMemberInput.d.ts +0 -5
- package/src/types/ui/ChatGroup/Create/CreateChatNameInput.d.ts +0 -5
- package/src/types/ui/ChatGroup/Create/CreateChatPanel.d.ts +0 -2
- package/src/types/ui/ChatGroup/Create/index.d.ts +0 -17
- package/src/types/ui/ChatGroup/Layout/ChatGroupAside.d.ts +0 -2
- package/src/types/ui/ChatGroup/Layout/ChatGroupBody.d.ts +0 -2
- package/src/types/ui/ChatGroup/Layout/ChatGroupFooter.d.ts +0 -2
- package/src/types/ui/ChatGroup/Layout/ChatGroupHeader.d.ts +0 -2
- package/src/types/ui/ChatGroup/Layout/ChatGroupMain.d.ts +0 -2
- package/src/types/ui/ChatGroup/Layout/index.d.ts +0 -17
- package/src/types/ui/ChatGroup/List/ChatList.d.ts +0 -2
- package/src/types/ui/ChatGroup/List/ChatListItemAvatar.d.ts +0 -3
- package/src/types/ui/ChatGroup/List/ChatListItemBox.d.ts +0 -6
- package/src/types/ui/ChatGroup/List/ChatListItemLastMessage.d.ts +0 -3
- package/src/types/ui/ChatGroup/List/ChatListItemLastMessageAuthor.d.ts +0 -3
- package/src/types/ui/ChatGroup/List/ChatListItemLastMessageContent.d.ts +0 -3
- package/src/types/ui/ChatGroup/List/ChatListItemLastMessageSentAt.d.ts +0 -3
- package/src/types/ui/ChatGroup/List/ChatListItemName.d.ts +0 -3
- package/src/types/ui/ChatGroup/List/ChatListItemUnreadCount.d.ts +0 -3
- package/src/types/ui/ChatGroup/List/index.d.ts +0 -29
- package/src/types/ui/ChatGroup/index.d.ts +0 -5
- package/src/types/ui/Chatify.d.ts +0 -8
- package/src/types/ui/Conversation/Conversation.d.ts +0 -21
- package/src/types/ui/Conversation/ConversationActions.d.ts +0 -2
- package/src/types/ui/Conversation/ConversationBody.d.ts +0 -2
- package/src/types/ui/Conversation/ConversationContext.d.ts +0 -20
- package/src/types/ui/Conversation/ConversationHeader.d.ts +0 -2
- package/src/types/ui/Conversation/ConversationName.d.ts +0 -2
- package/src/types/ui/Conversation/InputBox/InputBox.d.ts +0 -2
- package/src/types/ui/Conversation/InputBox/InputFilesBox.d.ts +0 -2
- package/src/types/ui/Conversation/InputBox/InputSubmitButtonBox.d.ts +0 -5
- package/src/types/ui/Conversation/InputBox/InputTextBox.d.ts +0 -8
- package/src/types/ui/Conversation/InputBox/index.d.ts +0 -14
- package/src/types/ui/Conversation/Message/MessageAuthor.d.ts +0 -3
- package/src/types/ui/Conversation/Message/MessageBox.d.ts +0 -6
- package/src/types/ui/Conversation/Message/MessageContent.d.ts +0 -3
- package/src/types/ui/Conversation/Message/MessageInfoBox.d.ts +0 -3
- package/src/types/ui/Conversation/Message/MessageRow.d.ts +0 -6
- package/src/types/ui/Conversation/Message/MessageText.d.ts +0 -3
- package/src/types/ui/Conversation/Message/index.d.ts +0 -20
- package/src/types/ui/Conversation/NextObserver/NextMessagesObserver.d.ts +0 -5
- package/src/types/ui/Conversation/NextObserver/index.d.ts +0 -1
- package/src/types/ui/Conversation/ReadObserver/MessageReadObserver.d.ts +0 -6
- package/src/types/ui/Conversation/ReadObserver/index.d.ts +0 -1
- package/src/types/ui/Conversation/SendingMessage/SendingMessageBox.d.ts +0 -7
- package/src/types/ui/Conversation/SendingMessage/SendingMessageContent.d.ts +0 -3
- package/src/types/ui/Conversation/SendingMessage/SendingMessageInfoBox.d.ts +0 -3
- package/src/types/ui/Conversation/SendingMessage/SendingMessageText.d.ts +0 -3
- package/src/types/ui/Conversation/SendingMessage/index.d.ts +0 -14
- package/src/types/ui/Conversation/SystemMessage/SystemMessageBox.d.ts +0 -6
- package/src/types/ui/Conversation/SystemMessage/SystemMessageRow.d.ts +0 -9
- package/src/types/ui/Conversation/SystemMessage/index.d.ts +0 -8
- package/src/types/ui/Conversation/index.d.ts +0 -12
- package/src/types/ui/Thread/ThreadActions.d.ts +0 -2
- package/src/types/ui/Thread/ThreadContext.d.ts +0 -8
- package/src/types/ui/Thread/ThreadPanel.d.ts +0 -14
- package/src/types/ui/Thread/index.d.ts +0 -3
- package/src/types/ui/color.d.ts +0 -6
- package/src/types/ui/common/Avatar.d.ts +0 -6
- package/src/types/ui/common/Icon.d.ts +0 -20
- package/src/types/ui/common/MessageSkeleton.d.ts +0 -5
- package/src/types/ui/common/index.d.ts +0 -11
- package/src/types/ui/customize.d.ts +0 -9
- package/src/types/ui/index.d.ts +0 -11
- package/src/types/ui/localizer.d.ts +0 -35
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { Col, Row } from 'antd';
|
|
2
|
-
import { customize, useCustomize } from '../customize';
|
|
3
|
-
import { ConversationName } from './ConversationName';
|
|
4
|
-
import { ConversationActions } from './ConversationActions';
|
|
5
|
-
|
|
6
|
-
export const ConversationHeader = customize('ConversationHeader', () => {
|
|
7
|
-
const Actions = useCustomize(ConversationActions);
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<div className="wxchtf-conversation-header">
|
|
11
|
-
<Row justify="space-between" align="middle">
|
|
12
|
-
<Col>
|
|
13
|
-
<ConversationName />
|
|
14
|
-
</Col>
|
|
15
|
-
{Actions && (
|
|
16
|
-
<Col className="wxchtf-conversation-actions">
|
|
17
|
-
<Actions />
|
|
18
|
-
</Col>
|
|
19
|
-
)}
|
|
20
|
-
</Row>
|
|
21
|
-
</div>
|
|
22
|
-
);
|
|
23
|
-
});
|
|
1
|
+
import { Col, Row } from 'antd';
|
|
2
|
+
import { customize, useCustomize } from '../customize';
|
|
3
|
+
import { ConversationName } from './ConversationName';
|
|
4
|
+
import { ConversationActions } from './ConversationActions';
|
|
5
|
+
|
|
6
|
+
export const ConversationHeader = customize('ConversationHeader', () => {
|
|
7
|
+
const Actions = useCustomize(ConversationActions);
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<div className="wxchtf-conversation-header">
|
|
11
|
+
<Row justify="space-between" align="middle">
|
|
12
|
+
<Col>
|
|
13
|
+
<ConversationName />
|
|
14
|
+
</Col>
|
|
15
|
+
{Actions && (
|
|
16
|
+
<Col className="wxchtf-conversation-actions">
|
|
17
|
+
<Actions />
|
|
18
|
+
</Col>
|
|
19
|
+
)}
|
|
20
|
+
</Row>
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { customize } from '../customize';
|
|
2
|
-
import { useConversation } from './ConversationContext';
|
|
3
|
-
|
|
4
|
-
export const ConversationName = customize('ConversationName', () => {
|
|
5
|
-
const { name } = useConversation();
|
|
6
|
-
return <span className="wxchtf-conversation-name">{name}</span>;
|
|
7
|
-
});
|
|
1
|
+
import { customize } from '../customize';
|
|
2
|
+
import { useConversation } from './ConversationContext';
|
|
3
|
+
|
|
4
|
+
export const ConversationName = customize('ConversationName', () => {
|
|
5
|
+
const { name } = useConversation();
|
|
6
|
+
return <span className="wxchtf-conversation-name">{name}</span>;
|
|
7
|
+
});
|
|
@@ -1,40 +1,113 @@
|
|
|
1
|
-
import { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
2
|
-
import { InputFilesBox } from './InputFilesBox';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
2
|
+
import { InputFilesBox } from './InputFilesBox';
|
|
3
|
+
import { File } from '../../../core';
|
|
4
|
+
import { InputTextBox } from './InputTextBox';
|
|
5
|
+
import { customize, useCustomizeContext } from '../../customize';
|
|
6
|
+
import { InputSubmitButtonBox } from './InputSubmitButtonBox';
|
|
7
|
+
import { useConversation } from '../ConversationContext';
|
|
8
|
+
import { ConversationCustomizeValue } from '../Conversation';
|
|
9
|
+
import { InputBoxFileList } from './InputBoxFileList';
|
|
10
|
+
|
|
11
|
+
function useFormState() {
|
|
12
|
+
const { onSend } = useConversation();
|
|
13
|
+
const [text, setText] = useState('');
|
|
14
|
+
const [sending, setSending] = useState(false);
|
|
15
|
+
const { onUpload, files, loading, setFiles, showFileBox, onDeleteFile } = useFlippoInputFileBox();
|
|
16
|
+
|
|
17
|
+
const onSubmit = useCallback(() => {
|
|
18
|
+
if (text.length === 0 || loading) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
setSending(true);
|
|
23
|
+
Promise.resolve(onSend({ text, files }))
|
|
24
|
+
.finally(() => setSending(false))
|
|
25
|
+
.then(() => {
|
|
26
|
+
setFiles([]);
|
|
27
|
+
setText('');
|
|
28
|
+
});
|
|
29
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
|
+
}, [text, onSend, files, setFiles, loading]);
|
|
31
|
+
|
|
32
|
+
return [onSubmit, { text, setText, files, onUpload, loading, showFileBox, onDeleteFile, sending }] as const;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function useFlippoInputFileBox() {
|
|
36
|
+
const [loading, setLoading] = useState(false);
|
|
37
|
+
const [files, setFiles] = useState<File[]>([]);
|
|
38
|
+
const { flippo } = useCustomizeContext<ConversationCustomizeValue>();
|
|
39
|
+
|
|
40
|
+
const onUpload = useCallback(
|
|
41
|
+
(files: globalThis.File[]) => {
|
|
42
|
+
if (!flippo) return;
|
|
43
|
+
|
|
44
|
+
setLoading(true);
|
|
45
|
+
Promise.all(files.map((file) => flippo.store(file)))
|
|
46
|
+
.then((references) =>
|
|
47
|
+
setFiles((prev) => [
|
|
48
|
+
...prev,
|
|
49
|
+
...references.map((reference, index) => ({
|
|
50
|
+
name: files[index].name,
|
|
51
|
+
ref: reference,
|
|
52
|
+
bytes: files[index].size,
|
|
53
|
+
})),
|
|
54
|
+
]),
|
|
55
|
+
)
|
|
56
|
+
.finally(() => setLoading(false));
|
|
57
|
+
},
|
|
58
|
+
[flippo],
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const onDeleteFile = useCallback((file: File) => {
|
|
62
|
+
setFiles((prev) => prev.filter((f) => f !== file));
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
|
+
return { onUpload, files, loading, setFiles, showFileBox: !!flippo, onDeleteFile };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const InputBox = customize('InputBox', () => {
|
|
69
|
+
const [onSend, { text, setText, files, loading, onUpload, showFileBox, onDeleteFile, sending }] =
|
|
70
|
+
useFormState();
|
|
71
|
+
const inputRef = useRef<HTMLTextAreaElement>(null);
|
|
72
|
+
const [showFileList, setShowFileList] = useState(false);
|
|
73
|
+
const toggleShowFileList = useCallback(() => setShowFileList((prev) => !prev), []);
|
|
74
|
+
|
|
75
|
+
useLayoutEffect(() => inputRef.current?.focus(), []);
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
if (files.length === 0 && showFileList) {
|
|
79
|
+
setShowFileList(false);
|
|
80
|
+
}
|
|
81
|
+
}, [files, showFileList]);
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<div className="wxchtf-input-form">
|
|
85
|
+
<div className="wxchtf-input-box">
|
|
86
|
+
{showFileList && (
|
|
87
|
+
<div className="wxchtf-file-list-box">
|
|
88
|
+
<InputBoxFileList files={files} onDelete={onDeleteFile} disabled={sending} />
|
|
89
|
+
</div>
|
|
90
|
+
)}
|
|
91
|
+
<div className="wxchtf-input-box-row">
|
|
92
|
+
{showFileBox && (
|
|
93
|
+
<InputFilesBox
|
|
94
|
+
onAddedClick={toggleShowFileList}
|
|
95
|
+
onUpload={onUpload}
|
|
96
|
+
value={files}
|
|
97
|
+
loading={loading}
|
|
98
|
+
disabled={sending}
|
|
99
|
+
/>
|
|
100
|
+
)}
|
|
101
|
+
<InputTextBox
|
|
102
|
+
value={text}
|
|
103
|
+
onSend={onSend}
|
|
104
|
+
onChange={setText}
|
|
105
|
+
disabled={sending}
|
|
106
|
+
inputRef={inputRef}
|
|
107
|
+
/>
|
|
108
|
+
<InputSubmitButtonBox onSubmit={onSend} disabled={loading} loading={sending} />
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Button } from 'antd';
|
|
2
|
+
import { File } from '../../../core';
|
|
3
|
+
import { Icon } from '../../common';
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
import { useFormatter } from '../../useFormatter';
|
|
6
|
+
import { customize } from '../../customize';
|
|
7
|
+
|
|
8
|
+
export interface InputBoxFileProps {
|
|
9
|
+
file: File;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
onDelete: (file: File) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const InputBoxFile = customize('InputBoxFile', (props: InputBoxFileProps) => {
|
|
15
|
+
const { file, disabled, onDelete } = props;
|
|
16
|
+
const formatter = useFormatter();
|
|
17
|
+
const onDeleteClick = useCallback(() => onDelete(file), [file, onDelete]);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div className="wxchtf-file">
|
|
21
|
+
<div className="wxchtf-file-info">
|
|
22
|
+
<div className="wxchtf-file-name" title={file.name}>
|
|
23
|
+
{file.name}
|
|
24
|
+
</div>
|
|
25
|
+
<div className="wxchtf-file-size">{formatter.size(file.bytes)}</div>
|
|
26
|
+
</div>
|
|
27
|
+
<div className="wxchtf-file-actions">
|
|
28
|
+
<Button
|
|
29
|
+
disabled={disabled}
|
|
30
|
+
className="wxchtf-delete"
|
|
31
|
+
type="link"
|
|
32
|
+
icon={<Icon type="delete-file" />}
|
|
33
|
+
onClick={onDeleteClick}
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { File } from '../../../core';
|
|
2
|
+
import { customize } from '../../customize';
|
|
3
|
+
import { InputBoxFile } from './InputBoxFile';
|
|
4
|
+
|
|
5
|
+
export interface InputBoxFileListProps {
|
|
6
|
+
files: File[];
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
onDelete: (file: File) => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const InputBoxFileList = customize('InputBoxFileList', (props: InputBoxFileListProps) => {
|
|
12
|
+
const { files, onDelete, disabled } = props;
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div className="wxchtf-file-list">
|
|
16
|
+
{files.map((file) => (
|
|
17
|
+
<InputBoxFile key={file.ref} file={file} onDelete={onDelete} disabled={disabled} />
|
|
18
|
+
))}
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
});
|
|
@@ -1,9 +1,78 @@
|
|
|
1
|
-
import { Button } from 'antd';
|
|
2
|
-
import { customize } from '../../customize';
|
|
3
|
-
import { Icon } from '../../common/Icon';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { Button } from 'antd';
|
|
2
|
+
import { customize } from '../../customize';
|
|
3
|
+
import { Icon } from '../../common/Icon';
|
|
4
|
+
import { File } from '../../../core';
|
|
5
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
6
|
+
|
|
7
|
+
export interface InputFilesBoxProps {
|
|
8
|
+
value: File[];
|
|
9
|
+
accept?: string;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
onAddedClick?: () => void;
|
|
13
|
+
onUpload: (value: globalThis.File[]) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const InputFileButton = customize('InputFileButton', (props: InputFilesBoxProps) => {
|
|
17
|
+
const { onUpload, onAddedClick, accept, loading, value, disabled } = props;
|
|
18
|
+
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
19
|
+
const onClick = useCallback(() => inputRef.current?.click(), []);
|
|
20
|
+
const countButtonRef = useRef<HTMLButtonElement | null>(null);
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
countButtonRef.current?.classList.add('active');
|
|
24
|
+
}, [value]);
|
|
25
|
+
|
|
26
|
+
const onCountButtonAnimationEnd = useCallback(() => {
|
|
27
|
+
countButtonRef.current?.classList.remove('active');
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
const onInputChange = useCallback(
|
|
31
|
+
(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
32
|
+
const files = e.target.files;
|
|
33
|
+
files && files.length > 0 && onUpload(Array.from(files));
|
|
34
|
+
},
|
|
35
|
+
[onUpload],
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<>
|
|
40
|
+
<Button
|
|
41
|
+
loading={loading}
|
|
42
|
+
onClick={onClick}
|
|
43
|
+
type="link"
|
|
44
|
+
disabled={disabled}
|
|
45
|
+
icon={<Icon type="attach" />}
|
|
46
|
+
className="wxchtf-add-files-btn"
|
|
47
|
+
/>
|
|
48
|
+
{value.length > 0 && (
|
|
49
|
+
<Button
|
|
50
|
+
ref={countButtonRef}
|
|
51
|
+
className="wxchtf-add-files-added-btn"
|
|
52
|
+
onAnimationIteration={onCountButtonAnimationEnd}
|
|
53
|
+
onClick={onAddedClick}
|
|
54
|
+
type="link"
|
|
55
|
+
disabled={disabled}
|
|
56
|
+
icon={<>+{value.length}</>}
|
|
57
|
+
/>
|
|
58
|
+
)}
|
|
59
|
+
<input
|
|
60
|
+
value=""
|
|
61
|
+
accept={accept}
|
|
62
|
+
onChange={onInputChange}
|
|
63
|
+
ref={inputRef}
|
|
64
|
+
type="file"
|
|
65
|
+
multiple
|
|
66
|
+
style={{ display: 'none' }}
|
|
67
|
+
/>
|
|
68
|
+
</>
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export const InputFilesBox = customize('InputFilesBox', (props: InputFilesBoxProps) => {
|
|
73
|
+
return (
|
|
74
|
+
<div className="wxchtf-add-files-box">
|
|
75
|
+
<InputFileButton {...props} />
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
});
|
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
import { Button } from 'antd';
|
|
2
|
-
import { customize } from '../../customize';
|
|
3
|
-
import { Icon } from '../../common/Icon';
|
|
4
|
-
|
|
5
|
-
export interface InputSubmitButtonBoxProps {
|
|
6
|
-
onSubmit: () => void;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
1
|
+
import { Button } from 'antd';
|
|
2
|
+
import { customize } from '../../customize';
|
|
3
|
+
import { Icon } from '../../common/Icon';
|
|
4
|
+
|
|
5
|
+
export interface InputSubmitButtonBoxProps {
|
|
6
|
+
onSubmit: () => void;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
loading?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const InputSubmitButtonBox = customize('InputSubmitButtonBox', (props: InputSubmitButtonBoxProps) => {
|
|
12
|
+
const { onSubmit, disabled, loading } = props;
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div className="wxchtf-submit-btn-box">
|
|
16
|
+
<Button
|
|
17
|
+
onClick={onSubmit}
|
|
18
|
+
type="link"
|
|
19
|
+
icon={<Icon type="send" />}
|
|
20
|
+
className="wxchtf-submit-btn"
|
|
21
|
+
disabled={disabled}
|
|
22
|
+
loading={loading}
|
|
23
|
+
/>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
});
|
|
@@ -1,53 +1,55 @@
|
|
|
1
|
-
import { Input } from 'antd';
|
|
2
|
-
import { customize } from '../../customize';
|
|
3
|
-
import isHotkey from 'is-hotkey';
|
|
4
|
-
import { RefObject, memo, useCallback } from 'react';
|
|
5
|
-
import { useLocalizer } from '../../localizer';
|
|
6
|
-
import { TextAreaProps } from 'antd/es/input';
|
|
7
|
-
|
|
8
|
-
export interface TextInputBoxProps {
|
|
9
|
-
value: string;
|
|
10
|
-
onChange: (value: string) => void;
|
|
11
|
-
onSend: (value: string) => void;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
);
|
|
1
|
+
import { Input } from 'antd';
|
|
2
|
+
import { customize } from '../../customize';
|
|
3
|
+
import isHotkey from 'is-hotkey';
|
|
4
|
+
import { RefObject, memo, useCallback } from 'react';
|
|
5
|
+
import { useLocalizer } from '../../localizer';
|
|
6
|
+
import { TextAreaProps } from 'antd/es/input';
|
|
7
|
+
|
|
8
|
+
export interface TextInputBoxProps {
|
|
9
|
+
value: string;
|
|
10
|
+
onChange: (value: string) => void;
|
|
11
|
+
onSend: (value: string) => void;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
inputRef?: RefObject<HTMLTextAreaElement>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const isSend = isHotkey('ctrl+enter');
|
|
17
|
+
|
|
18
|
+
const AUTO_SIZE: TextAreaProps['autoSize'] = { maxRows: 5, minRows: 1 };
|
|
19
|
+
|
|
20
|
+
export const InputTextBox = customize(
|
|
21
|
+
'InputTextBox',
|
|
22
|
+
memo((props: TextInputBoxProps) => {
|
|
23
|
+
const { value, onChange, onSend, disabled, inputRef } = props;
|
|
24
|
+
const localizer = useLocalizer();
|
|
25
|
+
|
|
26
|
+
const onInputChange = useCallback(
|
|
27
|
+
(e: React.ChangeEvent<HTMLTextAreaElement>) => onChange(e.target.value),
|
|
28
|
+
[onChange],
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const onKeyDown = useCallback(
|
|
32
|
+
(e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
|
33
|
+
if (isSend(e)) {
|
|
34
|
+
onSend(value);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
[onSend, value],
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className="wxchtf-text-input-box">
|
|
42
|
+
<Input.TextArea
|
|
43
|
+
ref={inputRef}
|
|
44
|
+
value={value}
|
|
45
|
+
onChange={onInputChange}
|
|
46
|
+
autoSize={AUTO_SIZE}
|
|
47
|
+
className="wxchtf-text-input-textarea"
|
|
48
|
+
placeholder={localizer.input.placeholder()}
|
|
49
|
+
onKeyDown={onKeyDown}
|
|
50
|
+
disabled={disabled}
|
|
51
|
+
/>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import { InputBox } from './InputBox';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { InputBox } from './InputBox';
|
|
2
|
+
import { InputBoxFile } from './InputBoxFile';
|
|
3
|
+
import { InputBoxFileList } from './InputBoxFileList';
|
|
4
|
+
import { InputFileButton, InputFilesBox } from './InputFilesBox';
|
|
5
|
+
import { InputSubmitButtonBox } from './InputSubmitButtonBox';
|
|
6
|
+
import { InputTextBox } from './InputTextBox';
|
|
7
|
+
|
|
8
|
+
export * from './InputBox';
|
|
9
|
+
export * from './InputFilesBox';
|
|
10
|
+
export * from './InputSubmitButtonBox';
|
|
11
|
+
export * from './InputTextBox';
|
|
12
|
+
export * from './InputBoxFileList';
|
|
13
|
+
export * from './InputBoxFile';
|
|
14
|
+
|
|
15
|
+
export interface InputBoxCustomizeValue {
|
|
16
|
+
InputBox?: typeof InputBox.Component | null;
|
|
17
|
+
InputTextBox?: typeof InputTextBox.Component | null;
|
|
18
|
+
InputFilesBox?: typeof InputFilesBox.Component | null;
|
|
19
|
+
InputSubmitButtonBox?: typeof InputSubmitButtonBox.Component | null;
|
|
20
|
+
InputBoxFileList?: typeof InputBoxFileList.Component | null;
|
|
21
|
+
InputBoxFile?: typeof InputBoxFile.Component | null;
|
|
22
|
+
InputFileButton?: typeof InputFileButton.Component | null;
|
|
23
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { customize } from '../../customize';
|
|
2
|
-
import { Avatar } from '../../common/Avatar';
|
|
3
|
-
import type { MessageBoxProps } from './MessageBox';
|
|
4
|
-
|
|
5
|
-
export const MessageAuthor = customize('MessageAuthor', (props: MessageBoxProps) => {
|
|
6
|
-
const { sentBy } = props.message;
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<div className="wxchtf-message-author">
|
|
10
|
-
<Avatar account={sentBy} />
|
|
11
|
-
</div>
|
|
12
|
-
);
|
|
13
|
-
});
|
|
1
|
+
import { customize } from '../../customize';
|
|
2
|
+
import { Avatar } from '../../common/Avatar';
|
|
3
|
+
import type { MessageBoxProps } from './MessageBox';
|
|
4
|
+
|
|
5
|
+
export const MessageAuthor = customize('MessageAuthor', (props: MessageBoxProps) => {
|
|
6
|
+
const { sentBy } = props.message;
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<div className="wxchtf-message-author">
|
|
10
|
+
<Avatar account={sentBy} />
|
|
11
|
+
</div>
|
|
12
|
+
);
|
|
13
|
+
});
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { useRef } from 'react';
|
|
2
|
-
import { customize } from '../../customize';
|
|
3
|
-
import { MessageReadObserver } from '../ReadObserver';
|
|
4
|
-
import { MessageRow } from './MessageRow';
|
|
5
|
-
import { MessageBase } from '../../../core';
|
|
6
|
-
|
|
7
|
-
export interface MessageBoxProps {
|
|
8
|
-
message: MessageBase;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const MessageBox = customize('MessageBox', (props: MessageBoxProps) => {
|
|
12
|
-
const ref = useRef<HTMLDivElement | null>(null);
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<>
|
|
16
|
-
<MessageReadObserver messageRef={ref} {...props} />
|
|
17
|
-
<MessageRow containerRef={ref} {...props} />
|
|
18
|
-
</>
|
|
19
|
-
);
|
|
20
|
-
});
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { customize } from '../../customize';
|
|
3
|
+
import { MessageReadObserver } from '../ReadObserver';
|
|
4
|
+
import { MessageRow } from './MessageRow';
|
|
5
|
+
import { MessageBase } from '../../../core';
|
|
6
|
+
|
|
7
|
+
export interface MessageBoxProps {
|
|
8
|
+
message: MessageBase;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const MessageBox = customize('MessageBox', (props: MessageBoxProps) => {
|
|
12
|
+
const ref = useRef<HTMLDivElement | null>(null);
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<>
|
|
16
|
+
<MessageReadObserver messageRef={ref} {...props} />
|
|
17
|
+
<MessageRow containerRef={ref} {...props} />
|
|
18
|
+
</>
|
|
19
|
+
);
|
|
20
|
+
});
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { customize } from '../../customize';
|
|
2
|
-
import { MessageText } from './MessageText';
|
|
3
|
-
import type { MessageBoxProps } from './MessageBox';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
1
|
+
import { customize } from '../../customize';
|
|
2
|
+
import { MessageText } from './MessageText';
|
|
3
|
+
import type { MessageBoxProps } from './MessageBox';
|
|
4
|
+
import { MessageFileList } from './MessageFileList';
|
|
5
|
+
|
|
6
|
+
export const MessageContent = customize('MessageContent', (props: MessageBoxProps) => {
|
|
7
|
+
const { files } = props.message;
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<div className="wxchtf-message-content">
|
|
11
|
+
<MessageText {...props} />
|
|
12
|
+
{files.length > 0 && <MessageFileList {...props} />}
|
|
13
|
+
</div>
|
|
14
|
+
);
|
|
15
|
+
});
|