@webinex/chatify 1.0.0-alpha07 → 1.0.0-build1

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.
@@ -35,14 +35,14 @@ export interface SendMessageRequest {
35
35
  files: File[];
36
36
  requestId: string;
37
37
  }
38
- export interface MessageContent {
38
+ export interface MessageBody {
39
39
  text: string;
40
40
  files: File[];
41
41
  }
42
42
  export interface AddChatRequest {
43
43
  requestId: string;
44
44
  name: string;
45
- message?: MessageContent;
45
+ message?: MessageBody;
46
46
  members: string[];
47
47
  }
48
48
  export interface ReadRequest {
@@ -8,8 +8,9 @@ import { AddChatButton } from './AddChatButton';
8
8
  import { Footer } from './Footer';
9
9
  import { ChatName } from './ChatName';
10
10
  import { ChatListItemBox, ChatListItemLastMessage, ChatListItemLastMessageAuthor, ChatListItemLastMessageContent, ChatListItemName, ChatListItemUnreadCount } from './ChatListItem';
11
- import { SendingMessage, SendingMessageBody, SendingMessageInfoBox, SendingMessageText } from './SendingMessage';
12
- import { MessageAuthor, MessageBody, MessageBox, MessageInfoBox, MessageReadObserver, MessageRow, MessageText } from './Message';
11
+ import { SendingMessage, SendingMessageContent, SendingMessageInfoBox, SendingMessageText } from './SendingMessage';
12
+ import { MessageAuthor, MessageContent, MessageBox, MessageInfoBox, MessageReadObserver, MessageRow, MessageText } from './Message';
13
+ import { Icon } from './Icon';
13
14
  export interface ChatifyCustomizeValue {
14
15
  Avatar?: typeof Avatar.Component | null;
15
16
  Header?: typeof Header.Component | null;
@@ -25,16 +26,17 @@ export interface ChatifyCustomizeValue {
25
26
  ChatListItemLastMessageAuthor?: typeof ChatListItemLastMessageAuthor.Component | null;
26
27
  ChatListItemLastMessageContent?: typeof ChatListItemLastMessageContent.Component | null;
27
28
  SendingMessage?: typeof SendingMessage.Component | null;
28
- SendingMessageBody?: typeof SendingMessageBody.Component | null;
29
+ SendingMessageBody?: typeof SendingMessageContent.Component | null;
29
30
  SendingMessageInfoBox?: typeof SendingMessageInfoBox.Component | null;
30
31
  SendingMessageText?: typeof SendingMessageText.Component | null;
31
32
  MessageBox?: typeof MessageBox.Component | null;
32
33
  MessageReadObserver?: typeof MessageReadObserver.Component | null;
33
34
  MessageRow?: typeof MessageRow.Component | null;
34
- MessageBody?: typeof MessageBody.Component | null;
35
+ MessageContent?: typeof MessageContent.Component | null;
35
36
  MessageInfoBox?: typeof MessageInfoBox.Component | null;
36
37
  MessageText?: typeof MessageText.Component | null;
37
38
  MessageAuthor?: typeof MessageAuthor.Component | null;
39
+ Icon?: typeof Icon.Component | null;
38
40
  }
39
41
  export interface ChatifyProps {
40
42
  className?: string;
@@ -0,0 +1,7 @@
1
+ import { FC } from 'react';
2
+ export type IconType = 'attach' | 'send';
3
+ export interface IconProps {
4
+ type: IconType;
5
+ }
6
+ export declare const ICONS: Record<IconType, React.ComponentType>;
7
+ export declare const Icon: import("../util").Customizable<FC<IconProps>, string>;
@@ -9,7 +9,7 @@ export interface MessageRowProps extends MessageBoxProps {
9
9
  export declare const MessageAuthor: import("../util").Customizable<FC<MessageBoxProps>, string>;
10
10
  export declare const MessageText: import("../util").Customizable<FC<MessageBoxProps>, string>;
11
11
  export declare const MessageInfoBox: import("../util").Customizable<FC<MessageBoxProps>, string>;
12
- export declare const MessageBody: import("../util").Customizable<FC<MessageBoxProps>, string>;
12
+ export declare const MessageContent: import("../util").Customizable<FC<MessageBoxProps>, string>;
13
13
  export declare const MessageRow: import("../util").Customizable<FC<MessageRowProps>, string>;
14
14
  export declare const MessageBox: import("../util").Customizable<FC<MessageBoxProps>, string>;
15
15
  export interface MessageReadObserverProps extends MessageBoxProps {
@@ -6,5 +6,5 @@ export interface SendingMessageProps {
6
6
  }
7
7
  export declare const SendingMessageText: import("../util").Customizable<FC<SendingMessageProps>, string>;
8
8
  export declare const SendingMessageInfoBox: import("../util").Customizable<FC<SendingMessageProps>, string>;
9
- export declare const SendingMessageBody: import("../util").Customizable<FC<SendingMessageProps>, string>;
9
+ export declare const SendingMessageContent: import("../util").Customizable<FC<SendingMessageProps>, string>;
10
10
  export declare const SendingMessage: import("../util").Customizable<FC<SendingMessageProps>, string>;
@@ -8,3 +8,4 @@ export * from './ChatHeaderMembers';
8
8
  export * from './ChatListItem';
9
9
  export * from './Message';
10
10
  export * from './SystemMessage';
11
+ export * from './Icon';
@@ -3,6 +3,7 @@ export interface Localizer {
3
3
  timestamp: (value: string) => string;
4
4
  system: {
5
5
  chatCreated: () => string;
6
+ memberAdded: () => string;
6
7
  };
7
8
  message: {
8
9
  read: () => React.ReactNode;
@@ -22,6 +23,9 @@ export interface Localizer {
22
23
  };
23
24
  submitBtn: () => React.ReactNode;
24
25
  };
26
+ input: {
27
+ placeholder: () => string;
28
+ };
25
29
  }
26
30
  export declare const LocalizerContext: React.Context<Localizer>;
27
31
  export declare function useLocalizer(): Localizer;
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ interface Localizer {
7
7
  timestamp: (value: string) => string;
8
8
  system: {
9
9
  chatCreated: () => string;
10
+ memberAdded: () => string;
10
11
  };
11
12
  message: {
12
13
  read: () => React$1.ReactNode;
@@ -26,6 +27,9 @@ interface Localizer {
26
27
  };
27
28
  submitBtn: () => React$1.ReactNode;
28
29
  };
30
+ input: {
31
+ placeholder: () => string;
32
+ };
29
33
  }
30
34
  declare const LocalizerContext: React$1.Context<Localizer>;
31
35
  declare function useLocalizer(): Localizer;
@@ -73,14 +77,14 @@ interface SendMessageRequest {
73
77
  files: File[];
74
78
  requestId: string;
75
79
  }
76
- interface MessageContent {
80
+ interface MessageBody {
77
81
  text: string;
78
82
  files: File[];
79
83
  }
80
84
  interface AddChatRequest {
81
85
  requestId: string;
82
86
  name: string;
83
- message?: MessageContent;
87
+ message?: MessageBody;
84
88
  members: string[];
85
89
  }
86
90
  interface ReadRequest {
@@ -214,9 +218,12 @@ declare const ACTIONS: {
214
218
  read_received: (state: State, { events }: {
215
219
  events: ReadEvent[];
216
220
  }) => State;
217
- member_added: (state: State, { chatId, account }: {
221
+ member_added: (state: State, { chatId, chatName, account, me, message, }: {
218
222
  chatId: string;
223
+ chatName: string;
219
224
  account: Account;
225
+ me: string;
226
+ message: Message;
220
227
  }) => State;
221
228
  member_removed: (state: State, { chatId, accountId, deleteHistory, me, }: {
222
229
  chatId: string;
@@ -318,7 +325,7 @@ interface SendingMessageProps {
318
325
  }
319
326
  declare const SendingMessageText: Customizable<FC<SendingMessageProps>, string>;
320
327
  declare const SendingMessageInfoBox: Customizable<FC<SendingMessageProps>, string>;
321
- declare const SendingMessageBody: Customizable<FC<SendingMessageProps>, string>;
328
+ declare const SendingMessageContent: Customizable<FC<SendingMessageProps>, string>;
322
329
  declare const SendingMessage: Customizable<FC<SendingMessageProps>, string>;
323
330
 
324
331
  interface MessageBoxProps {
@@ -330,7 +337,7 @@ interface MessageRowProps extends MessageBoxProps {
330
337
  declare const MessageAuthor: Customizable<FC<MessageBoxProps>, string>;
331
338
  declare const MessageText: Customizable<FC<MessageBoxProps>, string>;
332
339
  declare const MessageInfoBox: Customizable<FC<MessageBoxProps>, string>;
333
- declare const MessageBody: Customizable<FC<MessageBoxProps>, string>;
340
+ declare const MessageContent: Customizable<FC<MessageBoxProps>, string>;
334
341
  declare const MessageRow: Customizable<FC<MessageRowProps>, string>;
335
342
  declare const MessageBox: Customizable<FC<MessageBoxProps>, string>;
336
343
  interface MessageReadObserverProps extends MessageBoxProps {
@@ -338,6 +345,13 @@ interface MessageReadObserverProps extends MessageBoxProps {
338
345
  }
339
346
  declare const MessageReadObserver: Customizable<FC<MessageReadObserverProps>, string>;
340
347
 
348
+ type IconType = 'attach' | 'send';
349
+ interface IconProps {
350
+ type: IconType;
351
+ }
352
+ declare const ICONS: Record<IconType, React.ComponentType>;
353
+ declare const Icon: Customizable<FC<IconProps>, string>;
354
+
341
355
  interface ChatifyCustomizeValue {
342
356
  Avatar?: typeof Avatar.Component | null;
343
357
  Header?: typeof Header.Component | null;
@@ -353,16 +367,17 @@ interface ChatifyCustomizeValue {
353
367
  ChatListItemLastMessageAuthor?: typeof ChatListItemLastMessageAuthor.Component | null;
354
368
  ChatListItemLastMessageContent?: typeof ChatListItemLastMessageContent.Component | null;
355
369
  SendingMessage?: typeof SendingMessage.Component | null;
356
- SendingMessageBody?: typeof SendingMessageBody.Component | null;
370
+ SendingMessageBody?: typeof SendingMessageContent.Component | null;
357
371
  SendingMessageInfoBox?: typeof SendingMessageInfoBox.Component | null;
358
372
  SendingMessageText?: typeof SendingMessageText.Component | null;
359
373
  MessageBox?: typeof MessageBox.Component | null;
360
374
  MessageReadObserver?: typeof MessageReadObserver.Component | null;
361
375
  MessageRow?: typeof MessageRow.Component | null;
362
- MessageBody?: typeof MessageBody.Component | null;
376
+ MessageContent?: typeof MessageContent.Component | null;
363
377
  MessageInfoBox?: typeof MessageInfoBox.Component | null;
364
378
  MessageText?: typeof MessageText.Component | null;
365
379
  MessageAuthor?: typeof MessageAuthor.Component | null;
380
+ Icon?: typeof Icon.Component | null;
366
381
  }
367
382
  interface ChatifyProps {
368
383
  className?: string;
@@ -394,4 +409,4 @@ declare function ChatifyContext({ value, children }: PropsWithChildren<{
394
409
  value: ChatifyContextValue;
395
410
  }>): react_jsx_runtime.JSX.Element;
396
411
 
397
- export { ACTIONS, Account, Action, AddChatButton, AddChatRequest, AddMemberRequest, Avatar, AvatarProps, Chat, ChatHeader, ChatHeaderMembers, ChatHeaderMembersProps, ChatHeaderProps, ChatListItem, ChatListItemBox, ChatListItemBoxProps, ChatListItemLastMessage, ChatListItemLastMessageAuthor, ChatListItemLastMessageContent, ChatListItemName, ChatListItemUnreadCount, Chatify, ChatifyClient, ChatifyClientConfig, ChatifyContext, ChatifyContextValue, ChatifyCustomizeValue, ChatifyProps, ChatifySignalRConfig, File, Header, Localizer, LocalizerContext, Message, MessageAuthor, MessageBody, MessageBox, MessageBoxProps, MessageContent, MessageInfoBox, MessageReadObserver, MessageReadObserverProps, MessageRow, MessageRowProps, MessageState, MessageText, ReadEvent, ReadRequest, Reducer, ReducerProvider, RemoveMemberRequest, SendMessageRequest, SystemMessage, SystemMessageProps, defaultLocalizer, formatSystemMessage, useAccounts, useAddChat, useAddMember, useChat, useChatList, useClient, useDispatch, useLoadMore, useLocalizer, useMe, useMessages, useReadMonitor, useReducer, useRemoveMember, useSelect, useSignalRMonitor, useStateRef };
412
+ export { ACTIONS, Account, Action, AddChatButton, AddChatRequest, AddMemberRequest, Avatar, AvatarProps, Chat, ChatHeader, ChatHeaderMembers, ChatHeaderMembersProps, ChatHeaderProps, ChatListItem, ChatListItemBox, ChatListItemBoxProps, ChatListItemLastMessage, ChatListItemLastMessageAuthor, ChatListItemLastMessageContent, ChatListItemName, ChatListItemUnreadCount, Chatify, ChatifyClient, ChatifyClientConfig, ChatifyContext, ChatifyContextValue, ChatifyCustomizeValue, ChatifyProps, ChatifySignalRConfig, File, Header, ICONS, Icon, IconProps, IconType, Localizer, LocalizerContext, Message, MessageAuthor, MessageBody, MessageBox, MessageBoxProps, MessageContent, MessageInfoBox, MessageReadObserver, MessageReadObserverProps, MessageRow, MessageRowProps, MessageState, MessageText, ReadEvent, ReadRequest, Reducer, ReducerProvider, RemoveMemberRequest, SendMessageRequest, SystemMessage, SystemMessageProps, defaultLocalizer, formatSystemMessage, useAccounts, useAddChat, useAddMember, useChat, useChatList, useClient, useDispatch, useLoadMore, useLocalizer, useMe, useMessages, useReadMonitor, useReducer, useRemoveMember, useSelect, useSignalRMonitor, useStateRef };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@webinex/chatify",
3
3
  "description": "Webinex Wispo",
4
4
  "private": false,
5
- "version": "1.0.0-alpha07",
5
+ "version": "1.0.0-build1",
6
6
  "author": "Webinex Dev",
7
7
  "license": "Apache-2.0",
8
8
  "main": "dist/cjs/index.js",
@@ -214,7 +214,16 @@ export const ACTIONS = {
214
214
  return state;
215
215
  },
216
216
 
217
- member_added: (state: State, { chatId, account }: { chatId: string; account: Account }): State => {
217
+ member_added: (
218
+ state: State,
219
+ {
220
+ chatId,
221
+ chatName,
222
+ account,
223
+ me,
224
+ message,
225
+ }: { chatId: string; chatName: string; account: Account; me: string; message: Message },
226
+ ): State => {
218
227
  state = {
219
228
  ...state,
220
229
  query: {
@@ -230,6 +239,34 @@ export const ACTIONS = {
230
239
  state.query['chat.' + chatId].data.members = [...state.query['chat.' + chatId].data.members, account];
231
240
  }
232
241
 
242
+ if (state.query['messages.' + chatId]?.data !== undefined) {
243
+ state.query['messages.' + chatId] = {
244
+ ...state.query['messages.' + chatId],
245
+ data: [{ type: 'message', ...message }, ...state.query['messages.' + chatId].data],
246
+ };
247
+ }
248
+
249
+ if (account.id !== me && state.query['chat-list'].data !== undefined) {
250
+ state.query['chat-list'] = { ...state.query['chat-list'] };
251
+ state.query['chat-list'].data = state.query['chat-list'].data.map((x: ChatListItem) =>
252
+ x.id === chatId ? { ...x, message: { ...message } } : x,
253
+ );
254
+ }
255
+
256
+ if (account.id === me && state.query['chat-list'].data !== undefined) {
257
+ const listItem: ChatListItem = {
258
+ id: chatId,
259
+ name: chatName,
260
+ message: { ...message },
261
+ unreadCount: 0,
262
+ };
263
+
264
+ state.query['chat-list'] = {
265
+ ...state.query['chat-list'],
266
+ data: [...state.query['chat-list'].data, listItem],
267
+ };
268
+ }
269
+
233
270
  return state;
234
271
  },
235
272
 
@@ -41,7 +41,7 @@ export interface SendMessageRequest {
41
41
  requestId: string;
42
42
  }
43
43
 
44
- export interface MessageContent {
44
+ export interface MessageBody {
45
45
  text: string;
46
46
  files: File[];
47
47
  }
@@ -49,7 +49,7 @@ export interface MessageContent {
49
49
  export interface AddChatRequest {
50
50
  requestId: string;
51
51
  name: string;
52
- message?: MessageContent;
52
+ message?: MessageBody;
53
53
  members: string[];
54
54
  }
55
55
 
@@ -26,9 +26,12 @@ export function useSignalRMonitor(me: string, client: ChatifyClient) {
26
26
  }),
27
27
  );
28
28
  unsubscribes.push(
29
- client.subscribe('chatify://member-added', ([chatId, account]: [string, Account]) => {
30
- dispatch({ type: 'member_added', data: { chatId, account } });
31
- }),
29
+ client.subscribe(
30
+ 'chatify://member-added',
31
+ ([chatId, chatName, account, message]: [string, string, Account, Message]) => {
32
+ dispatch({ type: 'member_added', data: { chatId, chatName, account, me, message } });
33
+ },
34
+ ),
32
35
  );
33
36
  unsubscribes.push(
34
37
  client.subscribe(
@@ -9,7 +9,7 @@ function Member(props: { account: Account; chatId: string }) {
9
9
  const [remove] = useRemoveMember();
10
10
 
11
11
  const onRemoveClick = useCallback(
12
- () => remove({ chatId, accountId: account.id, deleteHistory: true }),
12
+ () => remove({ chatId, accountId: account.id, deleteHistory: false }),
13
13
  [remove, chatId, account.id],
14
14
  );
15
15
 
@@ -21,19 +21,20 @@ import {
21
21
  } from './ChatListItem';
22
22
  import {
23
23
  SendingMessage,
24
- SendingMessageBody,
24
+ SendingMessageContent,
25
25
  SendingMessageInfoBox,
26
26
  SendingMessageText,
27
27
  } from './SendingMessage';
28
28
  import {
29
29
  MessageAuthor,
30
- MessageBody,
30
+ MessageContent,
31
31
  MessageBox,
32
32
  MessageInfoBox,
33
33
  MessageReadObserver,
34
34
  MessageRow,
35
35
  MessageText,
36
36
  } from './Message';
37
+ import { Icon } from './Icon';
37
38
 
38
39
  export interface ChatifyCustomizeValue {
39
40
  Avatar?: typeof Avatar.Component | null;
@@ -50,16 +51,17 @@ export interface ChatifyCustomizeValue {
50
51
  ChatListItemLastMessageAuthor?: typeof ChatListItemLastMessageAuthor.Component | null;
51
52
  ChatListItemLastMessageContent?: typeof ChatListItemLastMessageContent.Component | null;
52
53
  SendingMessage?: typeof SendingMessage.Component | null;
53
- SendingMessageBody?: typeof SendingMessageBody.Component | null;
54
+ SendingMessageBody?: typeof SendingMessageContent.Component | null;
54
55
  SendingMessageInfoBox?: typeof SendingMessageInfoBox.Component | null;
55
56
  SendingMessageText?: typeof SendingMessageText.Component | null;
56
57
  MessageBox?: typeof MessageBox.Component | null;
57
58
  MessageReadObserver?: typeof MessageReadObserver.Component | null;
58
59
  MessageRow?: typeof MessageRow.Component | null;
59
- MessageBody?: typeof MessageBody.Component | null;
60
+ MessageContent?: typeof MessageContent.Component | null;
60
61
  MessageInfoBox?: typeof MessageInfoBox.Component | null;
61
62
  MessageText?: typeof MessageText.Component | null;
62
63
  MessageAuthor?: typeof MessageAuthor.Component | null;
64
+ Icon?: typeof Icon.Component | null;
63
65
  }
64
66
 
65
67
  export interface ChatifyProps {
@@ -0,0 +1,21 @@
1
+ import { FC } from 'react';
2
+ import { customize } from '../util';
3
+ import SendOutlined from '@ant-design/icons/SendOutlined';
4
+ import FileAddOutlined from '@ant-design/icons/FileAddOutlined';
5
+
6
+ export type IconType = 'attach' | 'send';
7
+
8
+ export interface IconProps {
9
+ type: IconType;
10
+ }
11
+
12
+ export const ICONS: Record<IconType, React.ComponentType> = {
13
+ attach: FileAddOutlined,
14
+ send: SendOutlined,
15
+ };
16
+
17
+ export const Icon = customize<FC<IconProps>, string>('Icon', (props) => {
18
+ const { type } = props;
19
+ const IconComponent = ICONS[type];
20
+ return IconComponent ? <IconComponent /> : null;
21
+ });
@@ -1,16 +1,19 @@
1
1
  import { Button, Input } from 'antd';
2
- import SendOutlined from '@ant-design/icons/SendOutlined';
3
- import FileAddOutlined from '@ant-design/icons/FileAddOutlined';
4
2
  import { useCallback, useState } from 'react';
5
3
  import isHotkey from 'is-hotkey';
6
4
  import { useAddMessage } from '../core/useAddMessage';
7
5
  import { uniqId } from '../util';
8
6
  import { useSelect } from '../core';
7
+ import { useLocalizer } from './localizer';
8
+ import { Icon } from './Icon';
9
+
10
+ const isSend = isHotkey('ctrl+enter');
9
11
 
10
12
  export function InputForm() {
11
13
  const chatId = useSelect((x) => x.ui.chatId!, []);
12
14
  const [add] = useAddMessage({ chatId });
13
15
  const [text, setText] = useState('');
16
+ const localizer = useLocalizer();
14
17
 
15
18
  const onSend = useCallback(() => {
16
19
  setText('');
@@ -23,7 +26,7 @@ export function InputForm() {
23
26
  <div className="wxchtf-input-form">
24
27
  <div className="wxchtf-input-box">
25
28
  <div className="wxchtf-add-files-box">
26
- <Button type="link" icon={<FileAddOutlined />} className="wxchtf-add-files-btn" />
29
+ <Button type="link" icon={<Icon type="attach" />} className="wxchtf-add-files-btn" />
27
30
  </div>
28
31
  <div className="wxchtf-text-input-box">
29
32
  <Input.TextArea
@@ -31,16 +34,16 @@ export function InputForm() {
31
34
  onChange={(e) => setText(e.target.value)}
32
35
  autoSize={{ maxRows: 5 }}
33
36
  className="wxchtf-text-input-textarea"
34
- placeholder="Start typing (Ctrl/⌘Cmd + Enter to send) ..."
37
+ placeholder={localizer.input.placeholder()}
35
38
  onKeyDown={(event) => {
36
- if (isHotkey('ctrl+enter')(event)) {
39
+ if (isSend(event)) {
37
40
  onSend();
38
41
  }
39
42
  }}
40
43
  />
41
44
  </div>
42
45
  <div className="wxchtf-submit-btn-box">
43
- <Button onClick={onSend} type="link" icon={<SendOutlined />} className="wxchtf-submit-btn" />
46
+ <Button onClick={onSend} type="link" icon={<Icon type="send" />} className="wxchtf-submit-btn" />
44
47
  </div>
45
48
  </div>
46
49
  </div>
@@ -48,9 +48,9 @@ export const MessageInfoBox = customize<FC<MessageBoxProps>, string>('MessageInf
48
48
  );
49
49
  });
50
50
 
51
- export const MessageBody = customize<FC<MessageBoxProps>, string>('MessageBody', (props) => {
51
+ export const MessageContent = customize<FC<MessageBoxProps>, string>('MessageContent', (props) => {
52
52
  return (
53
- <div className="wxchtf-message-body">
53
+ <div className="wxchtf-message-content">
54
54
  <MessageText {...props} />
55
55
  <MessageInfoBox {...props} />
56
56
  </div>
@@ -66,7 +66,7 @@ export const MessageRow = customize<FC<MessageRowProps>, string>('MessageRow', (
66
66
  return (
67
67
  <div ref={containerRef} className={'wxchtf-message' + (my ? ' --my' : '')}>
68
68
  <MessageAuthor {...props} />
69
- <MessageBody {...props} />
69
+ <MessageContent {...props} />
70
70
  </div>
71
71
  );
72
72
  });
@@ -29,11 +29,11 @@ export const SendingMessageInfoBox = customize<FC<SendingMessageProps>, string>(
29
29
  },
30
30
  );
31
31
 
32
- export const SendingMessageBody = customize<FC<SendingMessageProps>, string>(
33
- 'SendingMessageBody',
32
+ export const SendingMessageContent = customize<FC<SendingMessageProps>, string>(
33
+ 'SendingMessageContent',
34
34
  (props) => {
35
35
  return (
36
- <div className="wxchtf-sending-message-body">
36
+ <div className="wxchtf-sending-message-content">
37
37
  <SendingMessageText {...props} />
38
38
  <SendingMessageInfoBox {...props} />
39
39
  </div>
@@ -44,7 +44,7 @@ export const SendingMessageBody = customize<FC<SendingMessageProps>, string>(
44
44
  export const SendingMessage = customize<FC<SendingMessageProps>, string>('SendingMessage', (props) => {
45
45
  return (
46
46
  <div className="wxchtf-sending-message">
47
- <SendingMessageBody {...props} />
47
+ <SendingMessageContent {...props} />
48
48
  </div>
49
49
  );
50
50
  });
@@ -10,7 +10,11 @@ export function formatSystemMessage(localizer: Localizer, text: string): React.R
10
10
  return localizer.system.chatCreated();
11
11
  }
12
12
 
13
- throw new Error(`Unknown system message ${text}`);
13
+ if (text.startsWith('chatify://member-added::')) {
14
+ return localizer.system.memberAdded();
15
+ }
16
+
17
+ return text;
14
18
  }
15
19
 
16
20
  export function SystemMessage(props: SystemMessageProps) {
package/src/ui/index.ts CHANGED
@@ -8,3 +8,4 @@ export * from './ChatHeaderMembers';
8
8
  export * from './ChatListItem';
9
9
  export * from './Message';
10
10
  export * from './SystemMessage';
11
+ export * from './Icon';
@@ -5,6 +5,7 @@ export interface Localizer {
5
5
  timestamp: (value: string) => string;
6
6
  system: {
7
7
  chatCreated: () => string;
8
+ memberAdded: () => string;
8
9
  };
9
10
  message: {
10
11
  read: () => React.ReactNode;
@@ -24,6 +25,10 @@ export interface Localizer {
24
25
  };
25
26
  submitBtn: () => React.ReactNode;
26
27
  };
28
+
29
+ input: {
30
+ placeholder: () => string;
31
+ };
27
32
  }
28
33
 
29
34
  export const LocalizerContext = React.createContext<Localizer>(null!);
@@ -54,5 +59,10 @@ export const defaultLocalizer: Localizer = {
54
59
  },
55
60
  system: {
56
61
  chatCreated: () => 'Chat created',
62
+ memberAdded: () => 'New member added',
63
+ },
64
+
65
+ input: {
66
+ placeholder: () => 'Start typing (Ctrl/⌘Cmd + Enter to send) ...',
57
67
  },
58
68
  };
@@ -69,10 +69,6 @@
69
69
  width: 100%;
70
70
  align-items: flex-end;
71
71
 
72
- &.--sending {
73
- animation: fadeInFromNone 0.5s ease-out;
74
- }
75
-
76
72
  &.--my {
77
73
  direction: rtl;
78
74
  justify-content: flex-start;
@@ -82,8 +78,8 @@
82
78
  margin-left: 15px;
83
79
  }
84
80
 
85
- .wxchtf-message-body,
86
- .wxchtf-sending-message-body {
81
+ .wxchtf-message-content,
82
+ .wxchtf-sending-message-content {
87
83
  direction: ltr;
88
84
  border-bottom-left-radius: 10px;
89
85
  border-bottom-right-radius: 0;
@@ -100,8 +96,8 @@
100
96
  }
101
97
  }
102
98
 
103
- .wxchtf-message-body,
104
- .wxchtf-sending-message-body {
99
+ .wxchtf-message-content,
100
+ .wxchtf-sending-message-content {
105
101
  min-width: 300px;
106
102
  max-width: 70%;
107
103
  border-radius: $messageBorderRadius;