@webinex/chatify 1.0.2-rc3 → 1.0.3-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 +249 -143
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/core/action.d.ts +1 -0
- package/dist/esm/types/core/useAddChatMutation.d.ts +1 -1
- package/dist/esm/types/ui/ChatList/ChatListItemLastMessageSentAt.d.ts +3 -0
- package/dist/esm/types/ui/ChatList/index.d.ts +1 -0
- package/dist/esm/types/ui/Chatify.d.ts +2 -1
- package/dist/esm/types/ui/Icon.d.ts +6 -5
- package/dist/esm/types/ui/localizer.d.ts +2 -0
- package/dist/index.d.ts +13 -6
- package/package.json +1 -1
- package/src/core/action.tsx +11 -1
- package/src/core/useAddChatMutation.tsx +9 -3
- package/src/core/useGetChatQuery.tsx +1 -1
- package/src/styles/aside.scss +59 -21
- package/src/styles/chat.scss +81 -92
- package/src/styles/index.scss +34 -5
- package/src/styles/input.scss +72 -0
- package/src/styles/variables.scss +4 -4
- package/src/ui/AddChatButton.tsx +5 -3
- package/src/ui/ChatList/ChatListItemLastMessage.tsx +2 -0
- package/src/ui/ChatList/ChatListItemLastMessageSentAt.tsx +22 -0
- package/src/ui/ChatList/index.ts +1 -0
- package/src/ui/ChatPanel/ChatHeader.tsx +3 -5
- package/src/ui/ChatPanel/ChatHeaderMembers.tsx +6 -4
- package/src/ui/ChatPanel/ChatHeaderName.tsx +17 -15
- package/src/ui/ChatPanel/ChatMembersButton.tsx +1 -1
- package/src/ui/ChatPanel/ChatMembersPanel.tsx +8 -4
- package/src/ui/Chatify.tsx +11 -5
- package/src/ui/CreateChatPanel/CreateChatPanel.tsx +20 -4
- package/src/ui/Icon.tsx +7 -5
- package/src/ui/InputBox/InputTextBox.tsx +2 -1
- package/src/ui/Layout/Aside.tsx +2 -0
- package/src/ui/Layout/Header.tsx +1 -6
- package/src/ui/Message/MessageContent.tsx +0 -2
- package/src/ui/Message/MessageInfoBox.tsx +1 -0
- package/src/ui/Message/MessageRow.tsx +5 -1
- package/src/ui/localizer.tsx +4 -0
- package/src/styles/settings.scss +0 -5
|
@@ -1,31 +1,47 @@
|
|
|
1
|
-
import { useAddChatMutation } from '../../core';
|
|
1
|
+
import { useAddChatMutation, useDispatch } from '../../core';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import { uniqId } from '../../util';
|
|
4
4
|
import { useLocalizer } from '../localizer';
|
|
5
5
|
import { CreateChatForm, CreateChatFormValue } from './CreateChatForm';
|
|
6
6
|
import { customize } from '../customize';
|
|
7
|
+
import { Button } from 'antd';
|
|
8
|
+
import { Icon } from '../Icon';
|
|
7
9
|
|
|
8
10
|
function useSubmit() {
|
|
9
11
|
const [add, { isFetching }] = useAddChatMutation();
|
|
12
|
+
const dispatch = useDispatch();
|
|
13
|
+
|
|
10
14
|
const onSubmit = useCallback(
|
|
11
15
|
(value: CreateChatFormValue) =>
|
|
12
16
|
add({
|
|
13
17
|
name: value.name,
|
|
14
18
|
members: value.members,
|
|
15
19
|
requestId: uniqId(),
|
|
16
|
-
}),
|
|
17
|
-
[add],
|
|
20
|
+
}).then((id) => dispatch({ type: 'chat_open', data: { chatId: id } })),
|
|
21
|
+
[add, dispatch],
|
|
18
22
|
);
|
|
19
23
|
|
|
20
24
|
return [onSubmit, isFetching] as const;
|
|
21
25
|
}
|
|
22
26
|
|
|
27
|
+
function useOnClose() {
|
|
28
|
+
const dispatch = useDispatch();
|
|
29
|
+
return useCallback(() => dispatch({ type: 'new_chat_close', data: undefined }), [dispatch]);
|
|
30
|
+
}
|
|
31
|
+
|
|
23
32
|
export const CreateChatPanel = customize('CreateChatPanel', () => {
|
|
24
33
|
const localizer = useLocalizer();
|
|
25
34
|
const [onSubmit, submitting] = useSubmit();
|
|
35
|
+
const onClose = useOnClose();
|
|
26
36
|
|
|
27
37
|
return (
|
|
28
|
-
<div className="wxchtf-create-chat">
|
|
38
|
+
<div className="wxchtf-create-chat-panel">
|
|
39
|
+
<Button
|
|
40
|
+
onClick={onClose}
|
|
41
|
+
className="wxchtf-create-chat-panel-close"
|
|
42
|
+
type="link"
|
|
43
|
+
icon={<Icon type="close" />}
|
|
44
|
+
/>
|
|
29
45
|
<h3>{localizer.addChat.title()}</h3>
|
|
30
46
|
<CreateChatForm busy={submitting ?? false} onSubmit={onSubmit} />
|
|
31
47
|
</div>
|
package/src/ui/Icon.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import UserDeleteOutlined from '@ant-design/icons/UserDeleteOutlined';
|
|
|
8
8
|
import UsergroupDeleteOutlined from '@ant-design/icons/UsergroupDeleteOutlined';
|
|
9
9
|
import TeamOutlined from '@ant-design/icons/TeamOutlined';
|
|
10
10
|
import EditOutlined from '@ant-design/icons/EditOutlined';
|
|
11
|
+
import CloseOutlined from '@ant-design/icons/CloseOutlined';
|
|
11
12
|
|
|
12
13
|
export type IconType = keyof typeof ICONS;
|
|
13
14
|
|
|
@@ -18,12 +19,13 @@ export interface IconProps {
|
|
|
18
19
|
export const ICONS = {
|
|
19
20
|
attach: PaperClipOutlined,
|
|
20
21
|
send: SendOutlined,
|
|
21
|
-
remove: UserDeleteOutlined,
|
|
22
|
-
|
|
23
|
-
add: UserAddOutlined,
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
'remove-member': UserDeleteOutlined,
|
|
23
|
+
'remove-member-delete-history': UsergroupDeleteOutlined,
|
|
24
|
+
'add-member': UserAddOutlined,
|
|
25
|
+
'add-member-with-history': UsergroupAddOutlined,
|
|
26
|
+
members: TeamOutlined,
|
|
26
27
|
edit: EditOutlined,
|
|
28
|
+
close: CloseOutlined,
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
export const Icon = customize<FC<IconProps>>('Icon', (props) => {
|
|
@@ -3,6 +3,7 @@ import { customize } from '../customize';
|
|
|
3
3
|
import isHotkey from 'is-hotkey';
|
|
4
4
|
import { memo, useCallback } from 'react';
|
|
5
5
|
import { useLocalizer } from '../localizer';
|
|
6
|
+
import { TextAreaProps } from 'antd/es/input';
|
|
6
7
|
|
|
7
8
|
export interface TextInputBoxProps {
|
|
8
9
|
value: string;
|
|
@@ -12,7 +13,7 @@ export interface TextInputBoxProps {
|
|
|
12
13
|
|
|
13
14
|
const isSend = isHotkey('ctrl+enter');
|
|
14
15
|
|
|
15
|
-
const AUTO_SIZE = { maxRows: 5 };
|
|
16
|
+
const AUTO_SIZE: TextAreaProps['autoSize'] = { maxRows: 5, minRows: 1 };
|
|
16
17
|
|
|
17
18
|
export const InputTextBox = customize(
|
|
18
19
|
'InputTextBox',
|
package/src/ui/Layout/Aside.tsx
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { customize } from '../customize';
|
|
2
2
|
import { ChatList } from '../ChatList';
|
|
3
|
+
import { AddChatButton } from '../AddChatButton';
|
|
3
4
|
|
|
4
5
|
export const Aside = customize('Aside', () => {
|
|
5
6
|
return (
|
|
6
7
|
<div className="wxchtf-aside">
|
|
8
|
+
<AddChatButton />
|
|
7
9
|
<ChatList />
|
|
8
10
|
</div>
|
|
9
11
|
);
|
package/src/ui/Layout/Header.tsx
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { AddChatButton } from '../AddChatButton';
|
|
2
1
|
import { customize } from '../customize';
|
|
3
2
|
|
|
4
3
|
export const Header = customize('Header', () => {
|
|
5
|
-
return
|
|
6
|
-
<div className="wxchtf-header">
|
|
7
|
-
<AddChatButton />
|
|
8
|
-
</div>
|
|
9
|
-
);
|
|
4
|
+
return <div className="wxchtf-header"></div>;
|
|
10
5
|
});
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { customize } from '../customize';
|
|
2
2
|
import { MessageText } from './MessageText';
|
|
3
|
-
import { MessageInfoBox } from './MessageInfoBox';
|
|
4
3
|
import type { MessageBoxProps } from './MessageBox';
|
|
5
4
|
|
|
6
5
|
export const MessageContent = customize('MessageContent', (props: MessageBoxProps) => {
|
|
7
6
|
return (
|
|
8
7
|
<div className="wxchtf-message-content">
|
|
9
8
|
<MessageText {...props} />
|
|
10
|
-
<MessageInfoBox {...props} />
|
|
11
9
|
</div>
|
|
12
10
|
);
|
|
13
11
|
});
|
|
@@ -14,6 +14,7 @@ export const MessageInfoBox = customize('MessageInfoBox', (props: MessageBoxProp
|
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
16
|
<div className="wxchtf-message-info-box">
|
|
17
|
+
{!my && <div className="wxchtf-message-author-name">{sentBy.name},</div>}
|
|
17
18
|
<div className="wxchtf-message-sent-at">{localizer.timestamp(sentAt)}</div>
|
|
18
19
|
{!my && (
|
|
19
20
|
<div className="wxchtf-message-read-box">
|
|
@@ -4,6 +4,7 @@ import { customize } from '../customize';
|
|
|
4
4
|
import { MessageAuthor } from './MessageAuthor';
|
|
5
5
|
import { MessageContent } from './MessageContent';
|
|
6
6
|
import { MessageBoxProps } from './MessageBox';
|
|
7
|
+
import { MessageInfoBox } from './MessageInfoBox';
|
|
7
8
|
|
|
8
9
|
export interface MessageRowProps extends MessageBoxProps {
|
|
9
10
|
containerRef?: Ref<HTMLDivElement>;
|
|
@@ -18,7 +19,10 @@ export const MessageRow = customize('MessageRow', (props: MessageRowProps) => {
|
|
|
18
19
|
return (
|
|
19
20
|
<div ref={containerRef} className={'wxchtf-message' + (my ? ' --my' : '')}>
|
|
20
21
|
<MessageAuthor {...props} />
|
|
21
|
-
<
|
|
22
|
+
<div>
|
|
23
|
+
<MessageInfoBox {...props} />
|
|
24
|
+
<MessageContent {...props} />
|
|
25
|
+
</div>
|
|
22
26
|
</div>
|
|
23
27
|
);
|
|
24
28
|
});
|
package/src/ui/localizer.tsx
CHANGED
|
@@ -2,7 +2,9 @@ import dayjs from 'dayjs';
|
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
3
|
|
|
4
4
|
export interface Localizer {
|
|
5
|
+
isToday: (value: string) => boolean;
|
|
5
6
|
timestamp: (value: string) => string;
|
|
7
|
+
dateTime: (value: string) => string;
|
|
6
8
|
system: {
|
|
7
9
|
chatCreated: () => string;
|
|
8
10
|
memberAdded: () => string;
|
|
@@ -44,7 +46,9 @@ export function useLocalizer() {
|
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
export const defaultLocalizer: Localizer = {
|
|
49
|
+
isToday: (value: string) => dayjs(value).isSame(dayjs(), 'day'),
|
|
47
50
|
timestamp: (value: string) => dayjs(value).format('HH:mm'),
|
|
51
|
+
dateTime: (value: string) => dayjs(value).format('DD/MM/YYYY HH:mm'),
|
|
48
52
|
message: {
|
|
49
53
|
read: () => 'Read',
|
|
50
54
|
reading: () => 'Reading...',
|