@webinex/chatify 1.0.0-rc2 → 1.0.1-rc3
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 +183 -141
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/core/action.d.ts +110 -42
- package/dist/esm/types/core/client.d.ts +2 -1
- package/dist/esm/types/core/index.d.ts +11 -8
- package/dist/esm/types/core/models.d.ts +10 -4
- package/dist/esm/types/core/state.d.ts +36 -7
- package/dist/esm/types/core/useAddChatMutation.d.ts +2 -0
- package/dist/esm/types/core/useAddMemberMutation.d.ts +2 -0
- package/dist/esm/types/core/useFetchNextMutation.d.ts +3 -0
- package/dist/esm/types/core/useGetAccountsQuery.d.ts +1 -0
- package/dist/esm/types/core/useGetChatListQuery.d.ts +1 -0
- package/dist/{cjs/types/core/useChat.d.ts → esm/types/core/useGetChatQuery.d.ts} +1 -1
- package/dist/esm/types/core/useGetMessagesQuery.d.ts +4 -0
- package/dist/esm/types/core/useRemoveMemberMutation.d.ts +2 -0
- package/dist/esm/types/core/useSendMutation.d.ts +2 -0
- package/dist/esm/types/core/useUpdateChatNameMutation.d.ts +2 -0
- package/dist/esm/types/ui/AddChatButton.d.ts +2 -2
- package/dist/esm/types/ui/Avatar.d.ts +2 -2
- package/dist/esm/types/ui/ChatList/ChatList.d.ts +2 -0
- package/dist/esm/types/ui/ChatList/ChatListItemBox.d.ts +6 -0
- package/dist/esm/types/ui/ChatList/ChatListItemLastMessage.d.ts +3 -0
- package/dist/esm/types/ui/ChatList/ChatListItemLastMessageAuthor.d.ts +3 -0
- package/dist/esm/types/ui/ChatList/ChatListItemLastMessageContent.d.ts +3 -0
- package/dist/esm/types/ui/ChatList/ChatListItemName.d.ts +3 -0
- package/dist/esm/types/ui/ChatList/ChatListItemUnreadCount.d.ts +3 -0
- package/dist/esm/types/ui/ChatList/index.d.ts +7 -0
- package/dist/esm/types/ui/ChatName.d.ts +2 -2
- package/dist/esm/types/ui/ChatPanel/ChatBody.d.ts +5 -0
- package/dist/esm/types/ui/ChatPanel/ChatHeader.d.ts +5 -0
- package/dist/esm/types/ui/ChatPanel/ChatHeaderMembers.d.ts +5 -0
- package/dist/esm/types/ui/ChatPanel/ChatHeaderName.d.ts +5 -0
- package/dist/esm/types/ui/ChatPanel/ChatMembersButton.d.ts +5 -0
- package/dist/esm/types/ui/ChatPanel/ChatMembersPanel.d.ts +5 -0
- package/dist/esm/types/ui/ChatPanel/ChatPanel.d.ts +5 -0
- package/dist/esm/types/ui/ChatPanel/index.d.ts +6 -0
- package/dist/esm/types/ui/Chatify.d.ts +45 -23
- package/dist/esm/types/ui/CreateChatPanel/CreateChatForm.d.ts +11 -0
- package/dist/esm/types/ui/CreateChatPanel/CreateChatMemberInput.d.ts +5 -0
- package/dist/esm/types/ui/CreateChatPanel/CreateChatNameInput.d.ts +5 -0
- package/dist/esm/types/ui/CreateChatPanel/CreateChatPanel.d.ts +2 -0
- package/dist/esm/types/ui/CreateChatPanel/index.d.ts +4 -0
- package/dist/esm/types/ui/Icon.d.ts +13 -4
- package/dist/esm/types/ui/InputBox/InputBox.d.ts +2 -0
- package/dist/esm/types/ui/InputBox/InputFilesBox.d.ts +2 -0
- package/dist/esm/types/ui/InputBox/InputSubmitButtonBox.d.ts +5 -0
- package/dist/esm/types/ui/InputBox/InputTextBox.d.ts +7 -0
- package/dist/esm/types/ui/InputBox/index.d.ts +4 -0
- package/dist/esm/types/ui/Layout/Aside.d.ts +2 -0
- package/dist/esm/types/ui/Layout/Body.d.ts +2 -0
- package/dist/esm/types/ui/Layout/Footer.d.ts +2 -0
- package/dist/esm/types/ui/Layout/Header.d.ts +2 -0
- package/dist/esm/types/ui/Layout/Main.d.ts +2 -0
- package/dist/esm/types/ui/Layout/index.d.ts +5 -0
- package/dist/esm/types/ui/Message/MessageAuthor.d.ts +3 -0
- package/dist/esm/types/ui/Message/MessageBox.d.ts +6 -0
- package/dist/esm/types/ui/Message/MessageContent.d.ts +3 -0
- package/dist/esm/types/ui/Message/MessageInfoBox.d.ts +3 -0
- package/dist/esm/types/ui/Message/MessageRow.d.ts +6 -0
- package/dist/esm/types/ui/Message/MessageText.d.ts +3 -0
- package/dist/esm/types/ui/Message/index.d.ts +6 -0
- package/dist/esm/types/ui/MessageReadObserver.d.ts +6 -0
- package/dist/esm/types/ui/Next.d.ts +4 -0
- package/dist/esm/types/ui/SendingMessage/SendingMessageBox.d.ts +7 -0
- package/dist/esm/types/ui/SendingMessage/SendingMessageContent.d.ts +3 -0
- package/dist/esm/types/ui/SendingMessage/SendingMessageInfoBox.d.ts +3 -0
- package/dist/esm/types/ui/SendingMessage/SendingMessageText.d.ts +3 -0
- package/dist/esm/types/ui/SendingMessage/index.d.ts +4 -0
- package/dist/esm/types/ui/SystemMessage/SystemMessageBox.d.ts +6 -0
- package/dist/esm/types/ui/SystemMessage/SystemMessageRow.d.ts +9 -0
- package/dist/esm/types/ui/SystemMessage/index.d.ts +2 -0
- package/dist/esm/types/{util → ui}/customize.d.ts +2 -3
- package/dist/esm/types/ui/index.d.ts +6 -6
- package/dist/esm/types/ui/localizer.d.ts +5 -0
- package/dist/esm/types/util/index.d.ts +0 -1
- package/dist/index.d.ts +353 -142
- package/package.json +92 -90
- package/src/ChatifyContext.tsx +41 -41
- package/src/core/action.tsx +405 -319
- package/src/core/client.ts +143 -137
- package/src/core/index.ts +17 -14
- package/src/core/models.tsx +82 -75
- package/src/core/reducer.tsx +87 -86
- package/src/core/state.ts +92 -38
- package/src/core/useAddChatMutation.tsx +22 -0
- package/src/core/useAddMemberMutation.tsx +25 -0
- package/src/core/useFetchNextMutation.tsx +28 -0
- package/src/core/useGetAccountsQuery.tsx +33 -0
- package/src/core/useGetChatListQuery.tsx +33 -0
- package/src/core/useGetChatQuery.tsx +34 -0
- package/src/core/useGetMessagesQuery.tsx +35 -0
- package/src/core/useReadMonitor.tsx +32 -31
- package/src/core/useRemoveMemberMutation.tsx +23 -0
- package/src/core/useSendMutation.tsx +24 -0
- package/src/core/useSignalRMonitor.tsx +66 -52
- package/src/core/useUpdateChatNameMutation.tsx +23 -0
- package/src/index.ts +3 -3
- package/src/{ui/styles → styles}/aside.scss +94 -94
- package/src/styles/chat.scss +222 -0
- package/src/styles/index.scss +79 -0
- package/src/{ui/styles → styles}/keyframes.scss +14 -14
- package/src/{ui/styles → styles}/mixins.scss +20 -20
- package/src/styles/settings.scss +5 -0
- package/src/{ui/styles → styles}/variables.scss +10 -10
- package/src/ui/AddChatButton.tsx +15 -19
- package/src/ui/Avatar.tsx +18 -18
- package/src/ui/ChatList/ChatList.tsx +42 -0
- package/src/ui/ChatList/ChatListItemBox.tsx +22 -0
- package/src/ui/ChatList/ChatListItemLastMessage.tsx +13 -0
- package/src/ui/ChatList/ChatListItemLastMessageAuthor.tsx +20 -0
- package/src/ui/ChatList/ChatListItemLastMessageContent.tsx +21 -0
- package/src/ui/ChatList/ChatListItemName.tsx +13 -0
- package/src/ui/ChatList/ChatListItemUnreadCount.tsx +12 -0
- package/src/ui/ChatList/index.ts +7 -0
- package/src/ui/ChatName.tsx +10 -15
- package/src/ui/ChatPanel/ChatBody.tsx +44 -0
- package/src/ui/ChatPanel/ChatHeader.tsx +33 -0
- package/src/ui/{ChatHeaderMembers.tsx → ChatPanel/ChatHeaderMembers.tsx} +26 -30
- package/src/ui/ChatPanel/ChatHeaderName.tsx +67 -0
- package/src/ui/ChatPanel/ChatMembersButton.tsx +21 -0
- package/src/ui/ChatPanel/ChatMembersPanel.tsx +117 -0
- package/src/ui/ChatPanel/ChatPanel.tsx +27 -0
- package/src/ui/ChatPanel/index.ts +6 -0
- package/src/ui/Chatify.tsx +148 -106
- package/src/ui/CreateChatPanel/CreateChatForm.tsx +36 -0
- package/src/ui/CreateChatPanel/CreateChatMemberInput.tsx +66 -0
- package/src/ui/CreateChatPanel/CreateChatNameInput.tsx +25 -0
- package/src/ui/CreateChatPanel/CreateChatPanel.tsx +33 -0
- package/src/ui/CreateChatPanel/index.ts +4 -0
- package/src/ui/Icon.tsx +33 -21
- package/src/ui/InputBox/InputBox.tsx +38 -0
- package/src/ui/InputBox/InputFilesBox.tsx +9 -0
- package/src/ui/InputBox/InputSubmitButtonBox.tsx +17 -0
- package/src/ui/InputBox/InputTextBox.tsx +50 -0
- package/src/ui/InputBox/index.ts +4 -0
- package/src/ui/Layout/Aside.tsx +10 -0
- package/src/ui/Layout/Body.tsx +10 -0
- package/src/ui/Layout/Footer.tsx +3 -0
- package/src/ui/Layout/Header.tsx +10 -0
- package/src/ui/Layout/Main.tsx +15 -0
- package/src/ui/Layout/index.ts +5 -0
- package/src/ui/Message/MessageAuthor.tsx +13 -0
- package/src/ui/Message/MessageBox.tsx +20 -0
- package/src/ui/Message/MessageContent.tsx +13 -0
- package/src/ui/Message/MessageInfoBox.tsx +25 -0
- package/src/ui/Message/MessageRow.tsx +24 -0
- package/src/ui/Message/MessageText.tsx +7 -0
- package/src/ui/Message/index.ts +6 -0
- package/src/ui/MessageReadObserver.tsx +45 -0
- package/src/ui/MessageSkeleton.tsx +19 -19
- package/src/ui/Next.tsx +48 -0
- package/src/ui/SendingMessage/SendingMessageBox.tsx +16 -0
- package/src/ui/SendingMessage/SendingMessageContent.tsx +13 -0
- package/src/ui/SendingMessage/SendingMessageInfoBox.tsx +13 -0
- package/src/ui/SendingMessage/SendingMessageText.tsx +7 -0
- package/src/ui/SendingMessage/index.ts +4 -0
- package/src/ui/SystemMessage/SystemMessageBox.tsx +20 -0
- package/src/ui/SystemMessage/SystemMessageRow.tsx +43 -0
- package/src/ui/SystemMessage/index.ts +2 -0
- package/src/{util → ui}/customize.tsx +45 -45
- package/src/ui/index.ts +11 -11
- package/src/ui/localizer.tsx +80 -68
- package/src/util/index.ts +2 -3
- package/src/util/uniqBy.tsx +17 -17
- package/src/util/uniqId.tsx +3 -3
- package/dist/cjs/index.js +0 -2
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/types/ChatifyContext.d.ts +0 -11
- package/dist/cjs/types/core/action.d.ts +0 -76
- package/dist/cjs/types/core/client.d.ts +0 -35
- package/dist/cjs/types/core/index.d.ts +0 -14
- package/dist/cjs/types/core/models.d.ts +0 -64
- package/dist/cjs/types/core/reducer.d.ts +0 -11
- package/dist/cjs/types/core/state.d.ts +0 -25
- package/dist/cjs/types/core/useAccounts.d.ts +0 -1
- package/dist/cjs/types/core/useAddChat.d.ts +0 -2
- package/dist/cjs/types/core/useAddMember.d.ts +0 -2
- package/dist/cjs/types/core/useAddMessage.d.ts +0 -5
- package/dist/cjs/types/core/useChatList.d.ts +0 -1
- package/dist/cjs/types/core/useLoadMore.d.ts +0 -3
- package/dist/cjs/types/core/useMessages.d.ts +0 -15
- package/dist/cjs/types/core/useMutation.d.ts +0 -12
- package/dist/cjs/types/core/useQuery.d.ts +0 -7
- package/dist/cjs/types/core/useReadMonitor.d.ts +0 -1
- package/dist/cjs/types/core/useRemoveMember.d.ts +0 -2
- package/dist/cjs/types/core/useSignalRMonitor.d.ts +0 -2
- package/dist/cjs/types/index.d.ts +0 -3
- package/dist/cjs/types/ui/AddChat.d.ts +0 -1
- package/dist/cjs/types/ui/AddChatButton.d.ts +0 -2
- package/dist/cjs/types/ui/Aside.d.ts +0 -1
- package/dist/cjs/types/ui/Avatar.d.ts +0 -6
- package/dist/cjs/types/ui/Chat.d.ts +0 -4
- package/dist/cjs/types/ui/ChatBody.d.ts +0 -4
- package/dist/cjs/types/ui/ChatHeader.d.ts +0 -4
- package/dist/cjs/types/ui/ChatHeaderMembers.d.ts +0 -5
- package/dist/cjs/types/ui/ChatHeaderSettingsButton.d.ts +0 -5
- package/dist/cjs/types/ui/ChatListItem.d.ts +0 -11
- package/dist/cjs/types/ui/ChatName.d.ts +0 -5
- package/dist/cjs/types/ui/ChatSettings.d.ts +0 -1
- package/dist/cjs/types/ui/Chatify.d.ts +0 -49
- package/dist/cjs/types/ui/Footer.d.ts +0 -2
- package/dist/cjs/types/ui/Header.d.ts +0 -2
- package/dist/cjs/types/ui/Icon.d.ts +0 -7
- package/dist/cjs/types/ui/InputForm.d.ts +0 -1
- package/dist/cjs/types/ui/LoadMore.d.ts +0 -4
- package/dist/cjs/types/ui/Main.d.ts +0 -1
- package/dist/cjs/types/ui/Message.d.ts +0 -18
- package/dist/cjs/types/ui/MessageSkeleton.d.ts +0 -4
- package/dist/cjs/types/ui/SendingMessage.d.ts +0 -10
- package/dist/cjs/types/ui/SystemMessage.d.ts +0 -8
- package/dist/cjs/types/ui/index.d.ts +0 -11
- package/dist/cjs/types/ui/localizer.d.ts +0 -32
- package/dist/cjs/types/util/customize.d.ts +0 -12
- package/dist/cjs/types/util/index.d.ts +0 -3
- package/dist/cjs/types/util/uniqBy.d.ts +0 -1
- package/dist/cjs/types/util/uniqId.d.ts +0 -1
- package/dist/esm/types/core/useAccounts.d.ts +0 -1
- package/dist/esm/types/core/useAddChat.d.ts +0 -2
- package/dist/esm/types/core/useAddMember.d.ts +0 -2
- package/dist/esm/types/core/useAddMessage.d.ts +0 -5
- package/dist/esm/types/core/useChat.d.ts +0 -3
- package/dist/esm/types/core/useChatList.d.ts +0 -1
- package/dist/esm/types/core/useLoadMore.d.ts +0 -3
- package/dist/esm/types/core/useMessages.d.ts +0 -15
- package/dist/esm/types/core/useMutation.d.ts +0 -12
- package/dist/esm/types/core/useQuery.d.ts +0 -7
- package/dist/esm/types/core/useRemoveMember.d.ts +0 -2
- package/dist/esm/types/ui/AddChat.d.ts +0 -1
- package/dist/esm/types/ui/Aside.d.ts +0 -1
- package/dist/esm/types/ui/Chat.d.ts +0 -4
- package/dist/esm/types/ui/ChatBody.d.ts +0 -4
- package/dist/esm/types/ui/ChatHeader.d.ts +0 -4
- package/dist/esm/types/ui/ChatHeaderMembers.d.ts +0 -5
- package/dist/esm/types/ui/ChatHeaderSettingsButton.d.ts +0 -5
- package/dist/esm/types/ui/ChatListItem.d.ts +0 -11
- package/dist/esm/types/ui/ChatSettings.d.ts +0 -1
- package/dist/esm/types/ui/Footer.d.ts +0 -2
- package/dist/esm/types/ui/Header.d.ts +0 -2
- package/dist/esm/types/ui/InputForm.d.ts +0 -1
- package/dist/esm/types/ui/LoadMore.d.ts +0 -4
- package/dist/esm/types/ui/Main.d.ts +0 -1
- package/dist/esm/types/ui/Message.d.ts +0 -18
- package/dist/esm/types/ui/SendingMessage.d.ts +0 -10
- package/dist/esm/types/ui/SystemMessage.d.ts +0 -8
- package/src/core/useAccounts.tsx +0 -11
- package/src/core/useAddChat.tsx +0 -12
- package/src/core/useAddMember.tsx +0 -12
- package/src/core/useAddMessage.tsx +0 -40
- package/src/core/useChat.tsx +0 -12
- package/src/core/useChatList.tsx +0 -10
- package/src/core/useLoadMore.tsx +0 -42
- package/src/core/useMessages.tsx +0 -23
- package/src/core/useMutation.tsx +0 -48
- package/src/core/useQuery.tsx +0 -45
- package/src/core/useRemoveMember.tsx +0 -12
- package/src/ui/AddChat.tsx +0 -55
- package/src/ui/Aside.tsx +0 -41
- package/src/ui/Chat.tsx +0 -26
- package/src/ui/ChatBody.tsx +0 -43
- package/src/ui/ChatHeader.tsx +0 -33
- package/src/ui/ChatHeaderSettingsButton.tsx +0 -26
- package/src/ui/ChatListItem.tsx +0 -101
- package/src/ui/ChatSettings.tsx +0 -59
- package/src/ui/Footer.tsx +0 -7
- package/src/ui/Header.tsx +0 -14
- package/src/ui/InputForm.tsx +0 -51
- package/src/ui/LoadMore.tsx +0 -40
- package/src/ui/Main.tsx +0 -16
- package/src/ui/Message.tsx +0 -118
- package/src/ui/SendingMessage.tsx +0 -50
- package/src/ui/SystemMessage.tsx +0 -32
- package/src/ui/styles/index.scss +0 -248
package/src/ui/Chatify.tsx
CHANGED
|
@@ -1,106 +1,148 @@
|
|
|
1
|
-
import { CSSProperties, FC } from 'react';
|
|
2
|
-
import { useReadMonitor } from '../core';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
ChatListItemName,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
SendingMessageContent,
|
|
25
|
-
SendingMessageInfoBox,
|
|
26
|
-
SendingMessageText,
|
|
27
|
-
} from './SendingMessage';
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
} from './Message';
|
|
37
|
-
|
|
38
|
-
import {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
1
|
+
import { CSSProperties, FC } from 'react';
|
|
2
|
+
import { useReadMonitor } from '../core';
|
|
3
|
+
import { Localizer, LocalizerContext, defaultLocalizer } from './localizer';
|
|
4
|
+
import { Avatar } from './Avatar';
|
|
5
|
+
import { CustomizeProvider } from './customize';
|
|
6
|
+
import { ChatHeaderMembers } from './ChatPanel/ChatHeaderMembers';
|
|
7
|
+
import { ChatMembersButton } from './ChatPanel/ChatMembersButton';
|
|
8
|
+
import { AddChatButton } from './AddChatButton';
|
|
9
|
+
import { ChatName } from './ChatName';
|
|
10
|
+
|
|
11
|
+
import { Aside, Main, Body, Footer, Header } from './Layout';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
ChatListItemBox,
|
|
15
|
+
ChatListItemLastMessageContent,
|
|
16
|
+
ChatListItemLastMessageAuthor,
|
|
17
|
+
ChatListItemLastMessage,
|
|
18
|
+
ChatListItemUnreadCount,
|
|
19
|
+
ChatListItemName,
|
|
20
|
+
} from './ChatList';
|
|
21
|
+
|
|
22
|
+
import {
|
|
23
|
+
SendingMessageBox,
|
|
24
|
+
SendingMessageContent,
|
|
25
|
+
SendingMessageInfoBox,
|
|
26
|
+
SendingMessageText,
|
|
27
|
+
} from './SendingMessage';
|
|
28
|
+
|
|
29
|
+
import {
|
|
30
|
+
MessageBox,
|
|
31
|
+
MessageRow,
|
|
32
|
+
MessageContent,
|
|
33
|
+
MessageText,
|
|
34
|
+
MessageAuthor,
|
|
35
|
+
MessageInfoBox,
|
|
36
|
+
} from './Message';
|
|
37
|
+
|
|
38
|
+
import { MessageReadObserver } from './MessageReadObserver';
|
|
39
|
+
import { Icon } from './Icon';
|
|
40
|
+
import { SystemMessageRow } from './SystemMessage/SystemMessageRow';
|
|
41
|
+
import { ChatList } from './ChatList';
|
|
42
|
+
import { ChatBody, ChatHeader, ChatHeaderName, ChatPanel } from './ChatPanel';
|
|
43
|
+
import { InputBox, InputFilesBox, InputSubmitButtonBox, InputTextBox } from './InputBox';
|
|
44
|
+
import { SystemMessageBox } from './SystemMessage';
|
|
45
|
+
import {
|
|
46
|
+
CreateChatForm,
|
|
47
|
+
CreateChatMemberInput,
|
|
48
|
+
CreateChatNameInput,
|
|
49
|
+
CreateChatPanel,
|
|
50
|
+
} from './CreateChatPanel';
|
|
51
|
+
|
|
52
|
+
export interface ChatifyCustomizeValue {
|
|
53
|
+
// ./ChatList
|
|
54
|
+
ChatList?: typeof ChatList.Component | null;
|
|
55
|
+
ChatListItemBox?: typeof ChatListItemBox.Component | null;
|
|
56
|
+
ChatListItemName?: typeof ChatListItemName.Component | null;
|
|
57
|
+
ChatListItemUnreadCount?: typeof ChatListItemUnreadCount.Component | null;
|
|
58
|
+
ChatListItemLastMessage?: typeof ChatListItemLastMessage.Component | null;
|
|
59
|
+
ChatListItemLastMessageAuthor?: typeof ChatListItemLastMessageAuthor.Component | null;
|
|
60
|
+
ChatListItemLastMessageContent?: typeof ChatListItemLastMessageContent.Component | null;
|
|
61
|
+
|
|
62
|
+
// ./Layout
|
|
63
|
+
Header?: typeof Header.Component | null;
|
|
64
|
+
Footer?: typeof Footer.Component | null;
|
|
65
|
+
Body?: typeof Body.Component | null;
|
|
66
|
+
Main?: typeof Main.Component | null;
|
|
67
|
+
Aside?: typeof Aside.Component | null;
|
|
68
|
+
|
|
69
|
+
// ./Message
|
|
70
|
+
MessageAuthor?: typeof MessageAuthor.Component | null;
|
|
71
|
+
MessageBox?: typeof MessageBox.Component | null;
|
|
72
|
+
MessageContent?: typeof MessageContent.Component | null;
|
|
73
|
+
MessageInfoBox?: typeof MessageInfoBox.Component | null;
|
|
74
|
+
MessageRow?: typeof MessageRow.Component | null;
|
|
75
|
+
MessageText?: typeof MessageText.Component | null;
|
|
76
|
+
|
|
77
|
+
// ./SendingMessage
|
|
78
|
+
SendingMessageBox?: typeof SendingMessageBox.Component | null;
|
|
79
|
+
SendingMessageContent?: typeof SendingMessageContent.Component | null;
|
|
80
|
+
SendingMessageInfoBox?: typeof SendingMessageInfoBox.Component | null;
|
|
81
|
+
SendingMessageText?: typeof SendingMessageText.Component | null;
|
|
82
|
+
|
|
83
|
+
// ./ChatPanel
|
|
84
|
+
ChatBody?: typeof ChatBody.Component | null;
|
|
85
|
+
ChatHeader?: typeof ChatHeader.Component | null;
|
|
86
|
+
ChatHeaderMembers?: typeof ChatHeaderMembers.Component | null;
|
|
87
|
+
ChatHeaderName?: typeof ChatHeaderName.Component | null;
|
|
88
|
+
ChatPanel?: typeof ChatPanel.Component | null;
|
|
89
|
+
ChatMembersButton?: typeof ChatMembersButton.Component | null;
|
|
90
|
+
|
|
91
|
+
// ./InputBox
|
|
92
|
+
InputBox?: typeof InputBox.Component | null;
|
|
93
|
+
InputFilesBox?: typeof InputFilesBox.Component | null;
|
|
94
|
+
InputSubmitButtonBox?: typeof InputSubmitButtonBox.Component | null;
|
|
95
|
+
InputTextBox?: typeof InputTextBox.Component | null;
|
|
96
|
+
|
|
97
|
+
// ./SystemMessage
|
|
98
|
+
SystemMessageBox?: typeof SystemMessageBox.Component | null;
|
|
99
|
+
SystemMessageRow?: typeof SystemMessageRow.Component | null;
|
|
100
|
+
|
|
101
|
+
// ./CreateChatPanel
|
|
102
|
+
CreateChatForm?: typeof CreateChatForm.Component | null;
|
|
103
|
+
CreateChatMemberInput?: typeof CreateChatMemberInput.Component | null;
|
|
104
|
+
CreateChatNameInput?: typeof CreateChatNameInput.Component | null;
|
|
105
|
+
CreateChatPanel?: typeof CreateChatPanel.Component | null;
|
|
106
|
+
|
|
107
|
+
MessageReadObserver?: typeof MessageReadObserver.Component | null;
|
|
108
|
+
Avatar?: typeof Avatar.Component | null;
|
|
109
|
+
AddChatButton?: typeof AddChatButton.Component | null;
|
|
110
|
+
ChatName?: typeof ChatName.Component | null;
|
|
111
|
+
Icon?: typeof Icon.Component | null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface ChatifyProps {
|
|
115
|
+
className?: string;
|
|
116
|
+
style?: CSSProperties;
|
|
117
|
+
localizer?: Localizer;
|
|
118
|
+
customize?: ChatifyCustomizeValue;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function Content(props: Pick<ChatifyProps, 'className' | 'style'>) {
|
|
122
|
+
const { className = '', style } = props;
|
|
123
|
+
useReadMonitor();
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<div className={className + ' wxchtf-chatify'} style={style}>
|
|
127
|
+
<Header />
|
|
128
|
+
<Body />
|
|
129
|
+
<Footer />
|
|
130
|
+
</div>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const EMPTY_CUSTOMIZE = {};
|
|
135
|
+
|
|
136
|
+
export const Chatify: FC<ChatifyProps> = (props) => {
|
|
137
|
+
const { localizer = defaultLocalizer, customize = EMPTY_CUSTOMIZE } = props;
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<LocalizerContext.Provider value={localizer}>
|
|
141
|
+
<CustomizeProvider value={customize}>
|
|
142
|
+
<Content {...props} />
|
|
143
|
+
</CustomizeProvider>
|
|
144
|
+
</LocalizerContext.Provider>
|
|
145
|
+
);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
Chatify.displayName = 'Chatify';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Button, Form } from 'antd';
|
|
2
|
+
import { customize } from '../customize';
|
|
3
|
+
import { CreateChatNameInput } from './CreateChatNameInput';
|
|
4
|
+
import { CreateChatMemberInput } from './CreateChatMemberInput';
|
|
5
|
+
import { useLocalizer } from '../localizer';
|
|
6
|
+
|
|
7
|
+
export interface CreateChatFormValue {
|
|
8
|
+
name: string;
|
|
9
|
+
members: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface CreateChatFormProps {
|
|
13
|
+
value?: CreateChatFormValue;
|
|
14
|
+
onSubmit: (value: CreateChatFormValue) => void;
|
|
15
|
+
busy?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const INITIAL_VALUE: CreateChatFormValue = {
|
|
19
|
+
name: '',
|
|
20
|
+
members: [],
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const CreateChatForm = customize('CreateChatForm', (props: CreateChatFormProps) => {
|
|
24
|
+
const { value = INITIAL_VALUE, onSubmit, busy = false } = props;
|
|
25
|
+
const localizer = useLocalizer();
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Form onFinish={onSubmit} layout="vertical" disabled={busy} initialValues={value}>
|
|
29
|
+
<CreateChatNameInput name="name" />
|
|
30
|
+
<CreateChatMemberInput name="members" />
|
|
31
|
+
<Button loading={busy} type="primary" block htmlType="submit">
|
|
32
|
+
{localizer.addChat.submitBtn()}
|
|
33
|
+
</Button>
|
|
34
|
+
</Form>
|
|
35
|
+
);
|
|
36
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useGetAccountsQuery } from '../../core';
|
|
3
|
+
import { customize } from '../customize';
|
|
4
|
+
import { Checkbox, Form, List } from 'antd';
|
|
5
|
+
import { useLocalizer } from '../localizer';
|
|
6
|
+
import { useMe } from '../../ChatifyContext';
|
|
7
|
+
import { Avatar } from '../Avatar';
|
|
8
|
+
|
|
9
|
+
export interface CreateChatMemberInputProps {
|
|
10
|
+
name: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface CheckboxListProps {
|
|
14
|
+
value?: string[];
|
|
15
|
+
onChange?: (value: string[]) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function CheckboxList(props: CheckboxListProps) {
|
|
19
|
+
const { value, onChange } = props;
|
|
20
|
+
const { data: accounts, isFetching } = useGetAccountsQuery();
|
|
21
|
+
const me = useMe();
|
|
22
|
+
const dataSource = useMemo(() => accounts?.filter((x) => x.id !== me) ?? [], [accounts, me]);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<List
|
|
26
|
+
rowKey="id"
|
|
27
|
+
className="wxchtf-create-chat-member-input-list"
|
|
28
|
+
loading={isFetching}
|
|
29
|
+
dataSource={dataSource}
|
|
30
|
+
renderItem={(x) => {
|
|
31
|
+
const checked = value!.includes(x.id);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<List.Item className={checked ? '--selected' : ''}>
|
|
35
|
+
<Checkbox
|
|
36
|
+
checked={checked}
|
|
37
|
+
onChange={() =>
|
|
38
|
+
onChange!(value!.includes(x.id) ? value!.filter((y) => y !== x.id) : [...value!, x.id])
|
|
39
|
+
}
|
|
40
|
+
>
|
|
41
|
+
<List.Item.Meta avatar={<Avatar account={x} />} title={x.name} />
|
|
42
|
+
</Checkbox>
|
|
43
|
+
</List.Item>
|
|
44
|
+
);
|
|
45
|
+
}}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const CreateChatMemberInput = customize(
|
|
51
|
+
'CreateChatMemberInput',
|
|
52
|
+
(props: CreateChatMemberInputProps) => {
|
|
53
|
+
const { name } = props;
|
|
54
|
+
const localizer = useLocalizer();
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<Form.Item
|
|
58
|
+
label={localizer.addChat.members.label()}
|
|
59
|
+
rules={[{ required: true, message: localizer.addChat.members.required() }]}
|
|
60
|
+
name={name}
|
|
61
|
+
>
|
|
62
|
+
<CheckboxList />
|
|
63
|
+
</Form.Item>
|
|
64
|
+
);
|
|
65
|
+
},
|
|
66
|
+
);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Form, Input } from 'antd';
|
|
2
|
+
import { customize } from '../customize';
|
|
3
|
+
import { useLocalizer } from '../localizer';
|
|
4
|
+
|
|
5
|
+
export interface CreateChatNameInputProps {
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const CreateChatNameInput = customize('CreateChatNameInput', (props: CreateChatNameInputProps) => {
|
|
10
|
+
const { name } = props;
|
|
11
|
+
const localizer = useLocalizer();
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<Form.Item
|
|
15
|
+
name={name}
|
|
16
|
+
label={localizer.addChat.name.label()}
|
|
17
|
+
rules={[
|
|
18
|
+
{ required: true, message: localizer.addChat.name.required() },
|
|
19
|
+
{ max: 250, message: localizer.addChat.name.max250() },
|
|
20
|
+
]}
|
|
21
|
+
>
|
|
22
|
+
<Input />
|
|
23
|
+
</Form.Item>
|
|
24
|
+
);
|
|
25
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useAddChatMutation } from '../../core';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { uniqId } from '../../util';
|
|
4
|
+
import { useLocalizer } from '../localizer';
|
|
5
|
+
import { CreateChatForm, CreateChatFormValue } from './CreateChatForm';
|
|
6
|
+
import { customize } from '../customize';
|
|
7
|
+
|
|
8
|
+
function useSubmit() {
|
|
9
|
+
const [add, { isFetching }] = useAddChatMutation();
|
|
10
|
+
const onSubmit = useCallback(
|
|
11
|
+
(value: CreateChatFormValue) =>
|
|
12
|
+
add({
|
|
13
|
+
name: value.name,
|
|
14
|
+
members: value.members,
|
|
15
|
+
requestId: uniqId(),
|
|
16
|
+
}),
|
|
17
|
+
[add],
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
return [onSubmit, isFetching] as const;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const CreateChatPanel = customize('CreateChatPanel', () => {
|
|
24
|
+
const localizer = useLocalizer();
|
|
25
|
+
const [onSubmit, submitting] = useSubmit();
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div className="wxchtf-create-chat">
|
|
29
|
+
<h3>{localizer.addChat.title()}</h3>
|
|
30
|
+
<CreateChatForm busy={submitting ?? false} onSubmit={onSubmit} />
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
});
|
package/src/ui/Icon.tsx
CHANGED
|
@@ -1,21 +1,33 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { customize } from '
|
|
3
|
-
import SendOutlined from '@ant-design/icons/SendOutlined';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { customize } from './customize';
|
|
3
|
+
import SendOutlined from '@ant-design/icons/SendOutlined';
|
|
4
|
+
import PaperClipOutlined from '@ant-design/icons/PaperClipOutlined';
|
|
5
|
+
import UserAddOutlined from '@ant-design/icons/UserAddOutlined';
|
|
6
|
+
import UsergroupAddOutlined from '@ant-design/icons/UsergroupAddOutlined';
|
|
7
|
+
import UserDeleteOutlined from '@ant-design/icons/UserDeleteOutlined';
|
|
8
|
+
import UsergroupDeleteOutlined from '@ant-design/icons/UsergroupDeleteOutlined';
|
|
9
|
+
import TeamOutlined from '@ant-design/icons/TeamOutlined';
|
|
10
|
+
import EditOutlined from '@ant-design/icons/EditOutlined';
|
|
11
|
+
|
|
12
|
+
export type IconType = keyof typeof ICONS;
|
|
13
|
+
|
|
14
|
+
export interface IconProps {
|
|
15
|
+
type: IconType;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const ICONS = {
|
|
19
|
+
attach: PaperClipOutlined,
|
|
20
|
+
send: SendOutlined,
|
|
21
|
+
remove: UserDeleteOutlined,
|
|
22
|
+
remove_delete_history: UsergroupDeleteOutlined,
|
|
23
|
+
add: UserAddOutlined,
|
|
24
|
+
add_with_history: UsergroupAddOutlined,
|
|
25
|
+
team: TeamOutlined,
|
|
26
|
+
edit: EditOutlined,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const Icon = customize<FC<IconProps>>('Icon', (props) => {
|
|
30
|
+
const { type } = props;
|
|
31
|
+
const IconComponent = ICONS[type];
|
|
32
|
+
return IconComponent ? <IconComponent /> : null;
|
|
33
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { useSelect, useSendMutation } from '../../core';
|
|
3
|
+
import { uniqId } from '../../util';
|
|
4
|
+
import { InputFilesBox } from './InputFilesBox';
|
|
5
|
+
import { InputTextBox } from './InputTextBox';
|
|
6
|
+
import { customize } from '../customize';
|
|
7
|
+
import { InputSubmitButtonBox } from './InputSubmitButtonBox';
|
|
8
|
+
|
|
9
|
+
function useSend(text: string, setText: (value: string) => void) {
|
|
10
|
+
const chatId = useSelect((x) => x.ui.chatId!, []);
|
|
11
|
+
const [add] = useSendMutation();
|
|
12
|
+
|
|
13
|
+
return useCallback(() => {
|
|
14
|
+
if (text.length === 0) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
setText('');
|
|
19
|
+
add({ chatId, text: text, files: [], requestId: uniqId() });
|
|
20
|
+
|
|
21
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
22
|
+
}, [chatId, text]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const InputBox = customize('InputBox', () => {
|
|
26
|
+
const [text, setText] = useState('');
|
|
27
|
+
const onSend = useSend(text, setText);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className="wxchtf-input-form">
|
|
31
|
+
<div className="wxchtf-input-box">
|
|
32
|
+
<InputFilesBox />
|
|
33
|
+
<InputTextBox value={text} onSend={onSend} onChange={setText} />
|
|
34
|
+
<InputSubmitButtonBox onSubmit={onSend} />
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Button } from 'antd';
|
|
2
|
+
import { customize } from '../customize';
|
|
3
|
+
import { Icon } from '../Icon';
|
|
4
|
+
|
|
5
|
+
export const InputFilesBox = customize('InputFilesBox', () => (
|
|
6
|
+
<div className="wxchtf-add-files-box">
|
|
7
|
+
<Button type="link" icon={<Icon type="attach" />} className="wxchtf-add-files-btn" />
|
|
8
|
+
</div>
|
|
9
|
+
));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Button } from 'antd';
|
|
2
|
+
import { customize } from '../customize';
|
|
3
|
+
import { Icon } from '../Icon';
|
|
4
|
+
|
|
5
|
+
export interface InputSubmitButtonBoxProps {
|
|
6
|
+
onSubmit: () => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const InputSubmitButtonBox = customize('InputSubmitButtonBox', (props: InputSubmitButtonBoxProps) => {
|
|
10
|
+
const { onSubmit } = props;
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<div className="wxchtf-submit-btn-box">
|
|
14
|
+
<Button onClick={onSubmit} type="link" icon={<Icon type="send" />} className="wxchtf-submit-btn" />
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Input } from 'antd';
|
|
2
|
+
import { customize } from '../customize';
|
|
3
|
+
import isHotkey from 'is-hotkey';
|
|
4
|
+
import { memo, useCallback } from 'react';
|
|
5
|
+
import { useLocalizer } from '../localizer';
|
|
6
|
+
|
|
7
|
+
export interface TextInputBoxProps {
|
|
8
|
+
value: string;
|
|
9
|
+
onChange: (value: string) => void;
|
|
10
|
+
onSend: (value: string) => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const isSend = isHotkey('ctrl+enter');
|
|
14
|
+
|
|
15
|
+
const AUTO_SIZE = { maxRows: 5 };
|
|
16
|
+
|
|
17
|
+
export const InputTextBox = customize(
|
|
18
|
+
'InputTextBox',
|
|
19
|
+
memo((props: TextInputBoxProps) => {
|
|
20
|
+
const { value, onChange, onSend } = props;
|
|
21
|
+
const localizer = useLocalizer();
|
|
22
|
+
|
|
23
|
+
const onInputChange = useCallback(
|
|
24
|
+
(e: React.ChangeEvent<HTMLTextAreaElement>) => onChange(e.target.value),
|
|
25
|
+
[onChange],
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const onKeyDown = useCallback(
|
|
29
|
+
(e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
|
30
|
+
if (isSend(e)) {
|
|
31
|
+
onSend(value);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
[onSend, value],
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div className="wxchtf-text-input-box">
|
|
39
|
+
<Input.TextArea
|
|
40
|
+
value={value}
|
|
41
|
+
onChange={onInputChange}
|
|
42
|
+
autoSize={AUTO_SIZE}
|
|
43
|
+
className="wxchtf-text-input-textarea"
|
|
44
|
+
placeholder={localizer.input.placeholder()}
|
|
45
|
+
onKeyDown={onKeyDown}
|
|
46
|
+
/>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}),
|
|
50
|
+
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useSelect } from '../../core';
|
|
2
|
+
import { customize } from '../customize';
|
|
3
|
+
import { CreateChatPanel } from '../CreateChatPanel';
|
|
4
|
+
import { ChatPanel } from '../ChatPanel';
|
|
5
|
+
|
|
6
|
+
export const Main = customize('Main', () => {
|
|
7
|
+
const { view, chatId } = useSelect((x) => ({ view: x.ui.view, chatId: x.ui.chatId }), []);
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<div className="wxchtf-main">
|
|
11
|
+
{view === 'chat' && chatId && <ChatPanel id={chatId} key={chatId} />}
|
|
12
|
+
{view === 'new-chat' && <CreateChatPanel />}
|
|
13
|
+
</div>
|
|
14
|
+
);
|
|
15
|
+
});
|