@webinex/chatify 1.0.0-rc3 → 1.0.2-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/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/core/action.d.ts +10 -4
- package/dist/esm/types/core/state.d.ts +2 -1
- package/dist/esm/types/core/useGetAccountsQuery.d.ts +3 -1
- package/dist/esm/types/core/useGetChatListQuery.d.ts +3 -1
- package/dist/esm/types/core/useGetChatQuery.d.ts +3 -1
- package/dist/esm/types/ui/Icon.d.ts +8 -8
- package/dist/index.d.ts +21 -14
- package/package.json +92 -92
- package/src/ChatifyContext.tsx +41 -41
- package/src/core/action.tsx +421 -405
- package/src/core/client.ts +143 -143
- package/src/core/index.ts +17 -17
- package/src/core/models.tsx +82 -82
- package/src/core/reducer.tsx +87 -87
- package/src/core/state.ts +93 -92
- package/src/core/useAddChatMutation.tsx +22 -22
- package/src/core/useAddMemberMutation.tsx +25 -25
- package/src/core/useFetchNextMutation.tsx +28 -28
- package/src/core/useGetAccountsQuery.tsx +30 -33
- package/src/core/useGetChatListQuery.tsx +30 -33
- package/src/core/useGetChatQuery.tsx +31 -34
- package/src/core/useGetMessagesQuery.tsx +35 -35
- package/src/core/useReadMonitor.tsx +32 -32
- package/src/core/useRemoveMemberMutation.tsx +23 -23
- package/src/core/useSendMutation.tsx +24 -24
- package/src/core/useSignalRMonitor.tsx +66 -66
- package/src/core/useUpdateChatNameMutation.tsx +23 -23
- package/src/index.ts +3 -3
- package/src/styles/aside.scss +94 -94
- package/src/styles/chat.scss +222 -222
- package/src/styles/index.scss +79 -79
- package/src/styles/keyframes.scss +14 -14
- package/src/styles/mixins.scss +20 -20
- package/src/styles/settings.scss +5 -5
- package/src/styles/variables.scss +10 -10
- package/src/ui/AddChatButton.tsx +15 -15
- package/src/ui/Avatar.tsx +18 -18
- package/src/ui/ChatList/ChatList.tsx +42 -42
- package/src/ui/ChatList/ChatListItemBox.tsx +22 -22
- package/src/ui/ChatList/ChatListItemLastMessage.tsx +13 -13
- package/src/ui/ChatList/ChatListItemLastMessageAuthor.tsx +20 -20
- package/src/ui/ChatList/ChatListItemLastMessageContent.tsx +21 -21
- package/src/ui/ChatList/ChatListItemName.tsx +13 -13
- package/src/ui/ChatList/ChatListItemUnreadCount.tsx +12 -12
- package/src/ui/ChatList/index.ts +7 -7
- package/src/ui/ChatName.tsx +10 -10
- package/src/ui/ChatPanel/ChatBody.tsx +44 -44
- package/src/ui/ChatPanel/ChatHeader.tsx +33 -33
- package/src/ui/ChatPanel/ChatHeaderMembers.tsx +26 -26
- package/src/ui/ChatPanel/ChatHeaderName.tsx +67 -67
- package/src/ui/ChatPanel/ChatMembersButton.tsx +21 -21
- package/src/ui/ChatPanel/ChatMembersPanel.tsx +117 -117
- package/src/ui/ChatPanel/ChatPanel.tsx +27 -27
- package/src/ui/ChatPanel/index.ts +6 -6
- package/src/ui/Chatify.tsx +148 -148
- package/src/ui/CreateChatPanel/CreateChatForm.tsx +36 -36
- package/src/ui/CreateChatPanel/CreateChatMemberInput.tsx +66 -66
- package/src/ui/CreateChatPanel/CreateChatNameInput.tsx +25 -25
- package/src/ui/CreateChatPanel/CreateChatPanel.tsx +33 -33
- package/src/ui/CreateChatPanel/index.ts +4 -4
- package/src/ui/Icon.tsx +33 -33
- package/src/ui/InputBox/InputBox.tsx +38 -38
- package/src/ui/InputBox/InputFilesBox.tsx +9 -9
- package/src/ui/InputBox/InputSubmitButtonBox.tsx +17 -17
- package/src/ui/InputBox/InputTextBox.tsx +50 -50
- package/src/ui/InputBox/index.ts +4 -4
- package/src/ui/Layout/Aside.tsx +10 -10
- package/src/ui/Layout/Body.tsx +10 -10
- package/src/ui/Layout/Footer.tsx +3 -3
- package/src/ui/Layout/Header.tsx +10 -10
- package/src/ui/Layout/Main.tsx +15 -15
- package/src/ui/Layout/index.ts +5 -5
- package/src/ui/Message/MessageAuthor.tsx +13 -13
- package/src/ui/Message/MessageBox.tsx +20 -20
- package/src/ui/Message/MessageContent.tsx +13 -13
- package/src/ui/Message/MessageInfoBox.tsx +25 -25
- package/src/ui/Message/MessageRow.tsx +24 -24
- package/src/ui/Message/MessageText.tsx +7 -7
- package/src/ui/Message/index.ts +6 -6
- package/src/ui/MessageReadObserver.tsx +45 -45
- package/src/ui/MessageSkeleton.tsx +19 -19
- package/src/ui/Next.tsx +48 -48
- package/src/ui/SendingMessage/SendingMessageBox.tsx +16 -16
- package/src/ui/SendingMessage/SendingMessageContent.tsx +13 -13
- package/src/ui/SendingMessage/SendingMessageInfoBox.tsx +13 -13
- package/src/ui/SendingMessage/SendingMessageText.tsx +7 -7
- package/src/ui/SendingMessage/index.ts +4 -4
- package/src/ui/SystemMessage/SystemMessageBox.tsx +20 -20
- package/src/ui/SystemMessage/SystemMessageRow.tsx +43 -43
- package/src/ui/SystemMessage/index.ts +2 -2
- package/src/ui/customize.tsx +45 -45
- package/src/ui/index.ts +11 -11
- package/src/ui/localizer.tsx +80 -80
- package/src/util/index.ts +2 -2
- package/src/util/uniqBy.tsx +17 -17
- package/src/util/uniqId.tsx +3 -3
package/src/ui/Chatify.tsx
CHANGED
|
@@ -1,148 +1,148 @@
|
|
|
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';
|
|
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';
|
|
@@ -1,36 +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
|
-
});
|
|
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
|
+
});
|
|
@@ -1,66 +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
|
-
);
|
|
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
|
+
);
|
|
@@ -1,25 +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
|
-
});
|
|
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
|
+
});
|
|
@@ -1,33 +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
|
-
});
|
|
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
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './CreateChatForm';
|
|
2
|
-
export * from './CreateChatMemberInput';
|
|
3
|
-
export * from './CreateChatNameInput';
|
|
4
|
-
export * from './CreateChatPanel';
|
|
1
|
+
export * from './CreateChatForm';
|
|
2
|
+
export * from './CreateChatMemberInput';
|
|
3
|
+
export * from './CreateChatNameInput';
|
|
4
|
+
export * from './CreateChatPanel';
|